diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a63..000000000 --- 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 5f302863c..000000000 --- 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 1c88e69c0..000000000 --- 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 4a34c0e57..000000000 --- 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/array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 e4f10fed4..000000000 --- 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 b5291db63..000000000 --- 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 12efb6504..000000000 --- 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/array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 29849010f..000000000 --- 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 458473075..000000000 --- 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: '9 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 f4575e923..000000000 --- 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 ns = require( '@stdlib/array' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### ns @@ -271,11 +277,21 @@ Lastly, the namespace contains various other functions for dealing with arrays, -```javascript -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( '@stdlib/array' ); +```html + + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4ca7..000000000 --- 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/base/README.md b/base/README.md deleted file mode 100644 index 3732a7fee..000000000 --- a/base/README.md +++ /dev/null @@ -1,749 +0,0 @@ - - -# base - -> Base (i.e., lower-level) array utilities. - -
- -## Usage - -```javascript -var ns = require( '@stdlib/array/base' ); -``` - -#### ns - -Array utilities. - -```javascript -var o = ns; -// returns {...} -``` - -The namespace exports the following: - - - -
- -- [`accessorGetter( dtype )`][@stdlib/array/base/accessor-getter]: return an accessor function for retrieving an element from an array-like object supporting the get/set protocol. -- [`accessorSetter( dtype )`][@stdlib/array/base/accessor-setter]: return an accessor function for setting an element in an array-like object supporting the get/set protocol. -- [`AccessorArray( arr )`][@stdlib/array/base/accessor]: create a minimal array-like object supporting the accessor protocol from another array-like object. -- [`accessors( x )`][@stdlib/array/base/accessors]: return element accessors for a provided array-like object. -- [`anyByRight( x, predicate[, thisArg] )`][@stdlib/array/base/any-by-right]: test whether at least one element in an array passes a test implemented by a predicate function, while iterating from right to left. -- [`anyBy( x, predicate[, thisArg] )`][@stdlib/array/base/any-by]: test whether at least one element in an array passes a test implemented by a predicate function. -- [`anyHasOwnProp( arr, property )`][@stdlib/array/base/any-has-own-property]: test whether at least one element in a provided array has a specified own property. -- [`anyHasProp( arr, property )`][@stdlib/array/base/any-has-property]: test whether at least one element in a provided array has a specified property, either own or inherited. -- [`anyIsEntryIn( arr, property, value )`][@stdlib/array/base/any-is-entry-in]: test whether at least one element in a provided array has a specified property key-value pair, either own or inherited. -- [`anyIsEntry( arr, property, value )`][@stdlib/array/base/any-is-entry]: test whether at least one element in a provided array has a specified own property key-value pair. -- [`any( x )`][@stdlib/array/base/any]: test whether at least one element in an array is truthy. -- [`arraylike2object( x )`][@stdlib/array/base/arraylike2object]: convert an array-like object to an object likely to have the same "shape". -- [`assert`][@stdlib/array/base/assert]: base array assertion utilities. -- [`at( x, index )`][@stdlib/array/base/at]: return an element from an array. -- [`at2d( x, i0, i1 )`][@stdlib/array/base/at2d]: return an element from a two-dimensional nested array. -- [`at3d( x, i0, i1, i2 )`][@stdlib/array/base/at3d]: return an element from a three-dimensional nested array. -- [`at4d( x, i0, i1, i2, i3 )`][@stdlib/array/base/at4d]: return an element from a four-dimensional nested array. -- [`at5d( x, i0, i1, i2, i3, i4 )`][@stdlib/array/base/at5d]: return an element from a five-dimensional nested array. -- [`atnd( x, i0[, ...indices] )`][@stdlib/array/base/atnd]: return an element from an n-dimensional nested array. -- [`banded`][@stdlib/array/base/banded]: banded array utilities. -- [`bifurcateEntriesBy( x, predicate[, thisArg] )`][@stdlib/array/base/bifurcate-entries-by]: split element entries into two groups according to a predicate function. -- [`bifurcateEntries( x, filter )`][@stdlib/array/base/bifurcate-entries]: split array element entries into two groups. -- [`bifurcateIndicesBy( x, predicate[, thisArg] )`][@stdlib/array/base/bifurcate-indices-by]: split element indices into two groups according to a predicate function. -- [`bifurcateIndices( x, filter )`][@stdlib/array/base/bifurcate-indices]: split array element indices into two groups. -- [`bifurcateValuesBy( x, predicate[, thisArg] )`][@stdlib/array/base/bifurcate-values-by]: split element values into two groups according to a predicate function. -- [`bifurcateValues( x, filter )`][@stdlib/array/base/bifurcate-values]: split array element values into two groups. -- [`binary2d( arrays, shape, fcn )`][@stdlib/array/base/binary2d]: apply a binary callback to elements in two two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. -- [`binary3d( arrays, shape, fcn )`][@stdlib/array/base/binary3d]: apply a binary callback to elements in two three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. -- [`binary4d( arrays, shape, fcn )`][@stdlib/array/base/binary4d]: apply a binary callback to elements in two four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. -- [`binary5d( arrays, shape, fcn )`][@stdlib/array/base/binary5d]: apply a binary callback to elements in two five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. -- [`binarynd( arrays, shape, fcn )`][@stdlib/array/base/binarynd]: apply a binary callback to elements in two n-dimensional nested input arrays and assign results to elements in an n-dimensional nested output array. -- [`broadcastArray( x, inShape, outShape )`][@stdlib/array/base/broadcast-array]: broadcast an array to a specified shape. -- [`bbinary2d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-binary2d]: apply a binary callback to elements in two broadcasted nested input arrays and assign results to elements in a two-dimensional nested output array. -- [`bbinary3d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-binary3d]: apply a binary callback to elements in two broadcasted nested input arrays and assign results to elements in a three-dimensional nested output array. -- [`bbinary4d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-binary4d]: apply a binary callback to elements in two broadcasted nested input arrays and assign results to elements in a four-dimensional nested output array. -- [`bbinary5d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-binary5d]: apply a binary callback to elements in two broadcasted nested input arrays and assign results to elements in a five-dimensional nested output array. -- [`bquaternary2d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-quaternary2d]: apply a quaternary callback to elements in four broadcasted nested input arrays and assign results to elements in a two-dimensional nested output array. -- [`bquaternary3d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-quaternary3d]: apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a three-dimensional nested output array. -- [`bquaternary4d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-quaternary4d]: apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a four-dimensional nested output array. -- [`bquaternary5d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-quaternary5d]: apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a five-dimensional nested output array. -- [`bquinary2d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-quinary2d]: apply a quinary callback to elements in five broadcasted nested input arrays and assign results to elements in a two-dimensional nested output array. -- [`bquinary4d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-quinary4d]: apply a quinary callback to elements in five broadcasted input arrays and assign results to elements in a four-dimensional nested output array. -- [`bternary2d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-ternary2d]: apply a ternary callback to elements in three broadcasted nested input arrays and assign results to elements in a two-dimensional nested output array. -- [`bternary3d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-ternary3d]: apply a ternary callback to elements in three broadcasted nested input arrays and assign results to elements in a three-dimensional nested output array. -- [`bternary4d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-ternary4d]: apply a ternary callback to elements in three broadcasted nested input arrays and assign results to elements in a four-dimensional nested output array. -- [`bternary5d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-ternary5d]: apply a ternary callback to elements in three broadcasted nested input arrays and assign results to elements in a five-dimensional nested output array. -- [`bunary2d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-unary2d]: apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a two-dimensional nested output array. -- [`bunary3d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-unary3d]: apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a three-dimensional nested output array. -- [`bunary4d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-unary4d]: apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a four-dimensional nested output array. -- [`bunary5d( arrays, shapes, fcn )`][@stdlib/array/base/broadcasted-unary5d]: apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a five-dimensional nested output array. -- [`cartesianPower( x, n )`][@stdlib/array/base/cartesian-power]: return the Cartesian power. -- [`cartesianProduct( x1, x2 )`][@stdlib/array/base/cartesian-product]: return the Cartesian product. -- [`cartesianSquare( x )`][@stdlib/array/base/cartesian-square]: return the Cartesian square. -- [`copyIndexed( x )`][@stdlib/array/base/copy-indexed]: copy the elements of an indexed array-like object to a new "generic" array. -- [`copy( x )`][@stdlib/array/base/copy]: copy the elements of an array-like object to a new "generic" array. -- [`countFalsy( x )`][@stdlib/array/base/count-falsy]: count the number of falsy elements in an array. -- [`countIf( x, predicate[, thisArg] )`][@stdlib/array/base/count-if]: count the number of elements in an array which pass a test implemented by a predicate function. -- [`countIfs( x0, predicate0[, x1, predicate1[, x2, predicate2[, ...args]]] )`][@stdlib/array/base/count-ifs]: perform element-wise evaluation of one or more input arrays according to provided predicate functions and count the number of elements for which all predicates respectively return `true`. -- [`countSameValueZero( x, value )`][@stdlib/array/base/count-same-value-zero]: count the number of elements in an array that are equal to a specified value. -- [`countSameValue( x, value )`][@stdlib/array/base/count-same-value]: count the number of elements in an array that are equal to a specified value. -- [`countTruthy( x )`][@stdlib/array/base/count-truthy]: count the number of truthy elements in an array. -- [`cuany( x )`][@stdlib/array/base/cuany]: cumulatively test whether at least one element in a provided array is truthy. -- [`cuevery( x )`][@stdlib/array/base/cuevery]: cumulatively test whether every element in a provided array is truthy. -- [`cunone( x )`][@stdlib/array/base/cunone]: cumulatively test whether every element in a provided array is falsy. -- [`dedupe( x, limit, equalNaNs )`][@stdlib/array/base/dedupe]: remove consecutive duplicated values. -- [`everyByRight( x, predicate[, thisArg] )`][@stdlib/array/base/every-by-right]: test whether all elements in an array pass a test implemented by a predicate function, iterating from right to left. -- [`everyBy( x, predicate[, thisArg] )`][@stdlib/array/base/every-by]: test whether all elements in an array pass a test implemented by a predicate function. -- [`every( x )`][@stdlib/array/base/every]: test whether all elements in an array are truthy. -- [`fancySliceAssign( x, y, s, strict )`][@stdlib/array/base/fancy-slice-assign]: assign element values from a broadcasted input array to corresponding elements in an output array. -- [`fancySlice( x, s, strict )`][@stdlib/array/base/fancy-slice]: return a shallow copy of a portion of an array. -- [`fillBy( x, start, end, fcn[, thisArg] )`][@stdlib/array/base/fill-by]: fill all elements within a portion of an array according to a callback function. -- [`fill( x, value, start, end )`][@stdlib/array/base/fill]: fill all elements within a portion of an array with a specified value. -- [`filledBy( len, clbk[, thisArg] )`][@stdlib/array/base/filled-by]: create a filled "generic" array according to a provided callback function. -- [`filled( value, len )`][@stdlib/array/base/filled]: create a filled "generic" array. -- [`filled2dBy( shape, clbk[, thisArg] )`][@stdlib/array/base/filled2d-by]: create a filled two-dimensional nested array according to a provided callback function. -- [`filled2d( value, shape )`][@stdlib/array/base/filled2d]: create a filled two-dimensional nested array. -- [`filled3dBy( shape, clbk[, thisArg] )`][@stdlib/array/base/filled3d-by]: create a filled three-dimensional nested array according to a provided callback function. -- [`filled3d( value, shape )`][@stdlib/array/base/filled3d]: create a filled three-dimensional nested array. -- [`filled4dBy( shape, clbk[, thisArg] )`][@stdlib/array/base/filled4d-by]: create a filled four-dimensional nested array according to a provided callback function. -- [`filled4d( value, shape )`][@stdlib/array/base/filled4d]: create a filled four-dimensional nested array. -- [`filled5dBy( shape, clbk[, thisArg] )`][@stdlib/array/base/filled5d-by]: create a filled five-dimensional nested array according to a provided callback function. -- [`filled5d( value, shape )`][@stdlib/array/base/filled5d]: create a filled five-dimensional nested array. -- [`filledndBy( shape, clbk[, thisArg] )`][@stdlib/array/base/fillednd-by]: create a filled n-dimensional nested array according to a provided callback function. -- [`fillednd( value, shape )`][@stdlib/array/base/fillednd]: create a filled n-dimensional nested array. -- [`filter( x, predicate[, thisArg] )`][@stdlib/array/base/filter]: return a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -- [`first( x )`][@stdlib/array/base/first]: return the first element of an array-like object. -- [`flattenBy( x, shape, colexicographic, clbk[, thisArg] )`][@stdlib/array/base/flatten-by]: flatten an n-dimensional nested array according to a callback function. -- [`flatten( x, shape, colexicographic )`][@stdlib/array/base/flatten]: flatten an n-dimensional nested array. -- [`flatten2dBy( x, shape, colexicographic, clbk[, thisArg] )`][@stdlib/array/base/flatten2d-by]: flatten a two-dimensional nested array according to a callback function. -- [`flatten2d( x, shape, colexicographic )`][@stdlib/array/base/flatten2d]: flatten a two-dimensional nested array. -- [`flatten3dBy( x, shape, colexicographic, clbk[, thisArg] )`][@stdlib/array/base/flatten3d-by]: flatten a three-dimensional nested array according to a callback function. -- [`flatten3d( x, shape, colexicographic )`][@stdlib/array/base/flatten3d]: flatten a three-dimensional nested array. -- [`flatten4dBy( x, shape, colexicographic, clbk[, thisArg] )`][@stdlib/array/base/flatten4d-by]: flatten a four-dimensional nested array according to a callback function. -- [`flatten4d( x, shape, colexicographic )`][@stdlib/array/base/flatten4d]: flatten a four-dimensional nested array. -- [`flatten5dBy( x, shape, colexicographic, clbk[, thisArg] )`][@stdlib/array/base/flatten5d-by]: flatten a five-dimensional nested array according to a callback function. -- [`flatten5d( x, shape, colexicographic )`][@stdlib/array/base/flatten5d]: flatten a five-dimensional nested array. -- [`fliplr2d( x )`][@stdlib/array/base/fliplr2d]: reverse the order of elements along the last dimension of a two-dimensional nested input array. -- [`fliplr3d( x )`][@stdlib/array/base/fliplr3d]: reverse the order of elements along the last dimension of a three-dimensional nested input array. -- [`fliplr4d( x )`][@stdlib/array/base/fliplr4d]: reverse the order of elements along the last dimension of a four-dimensional nested input array. -- [`fliplr5d( x )`][@stdlib/array/base/fliplr5d]: reverse the order of elements along the last dimension of a five-dimensional nested input array. -- [`flipud2d( x )`][@stdlib/array/base/flipud2d]: reverse the order of elements along the first dimension of a two-dimensional nested input array. -- [`flipud3d( x )`][@stdlib/array/base/flipud3d]: reverse the order of elements along the second-to-last dimension of a three-dimensional nested input array. -- [`flipud4d( x )`][@stdlib/array/base/flipud4d]: reverse the order of elements along the second-to-last dimension of a four-dimensional nested input array. -- [`flipud5d( x )`][@stdlib/array/base/flipud5d]: reverse the order of elements along the second-to-last dimension of a five-dimensional nested input array. -- [`strided2array( N, x, stride, offset )`][@stdlib/array/base/from-strided]: convert a strided array to a non-strided generic array. -- [`getter( dtype )`][@stdlib/array/base/getter]: return an accessor function for retrieving an element from an indexed array-like object. -- [`groupEntriesBy( x, indicator[, thisArg] )`][@stdlib/array/base/group-entries-by]: group element entries according to an indicator function. -- [`groupEntries( x, groups )`][@stdlib/array/base/group-entries]: group element entries as arrays associated with distinct keys. -- [`groupIndicesBy( x, indicator[, thisArg] )`][@stdlib/array/base/group-indices-by]: group element indices according to an indicator function. -- [`groupIndices( x, groups )`][@stdlib/array/base/group-indices]: group element indices as arrays associated with distinct keys. -- [`groupValuesBy( x, indicator[, thisArg] )`][@stdlib/array/base/group-values-by]: group element values according to an indicator function. -- [`groupValues( x, groups )`][@stdlib/array/base/group-values]: group elements as arrays associated with distinct keys. -- [`incrspace( start, stop, increment )`][@stdlib/array/base/incrspace]: generate a linearly spaced numeric array according to a provided increment. -- [`indexOfSameValue( x, searchElement, fromIndex )`][@stdlib/array/base/index-of-same-value]: return the index of the first element which equals a provided search element according to the SameValue Algorithm. -- [`indexOf( x, searchElement, fromIndex )`][@stdlib/array/base/index-of]: return the index of the first element which equals a provided search element. -- [`indicesComplement( N, indices )`][@stdlib/array/base/indices-complement]: return the complement of a list of array indices. -- [`join( x, separator )`][@stdlib/array/base/join]: return a string created by joining array elements using a specified separator. -- [`lastIndexOfSameValue( x, searchElement, fromIndex )`][@stdlib/array/base/last-index-of-same-value]: return the index of the last element which equals a provided search element according to the SameValue Algorithm. -- [`lastIndexOf( x, searchElement, fromIndex )`][@stdlib/array/base/last-index-of]: return the index of the last element which equals a provided search element. -- [`last( x )`][@stdlib/array/base/last]: return the last element of an array-like object. -- [`linspace( start, stop, length )`][@stdlib/array/base/linspace]: generate a linearly spaced numeric array. -- [`linspace2d( start, stop, shape, colexicographic )`][@stdlib/array/base/linspace2d]: generate a linearly spaced two-dimensional nested numeric array. -- [`logspace( a, b, length )`][@stdlib/array/base/logspace]: generate a logarithmically spaced numeric array. -- [`map2d( x, shape, fcn[, thisArg] )`][@stdlib/array/base/map2d]: apply a function to elements in a two-dimensional nested input array and assign results to elements in a new two-dimensional nested output array. -- [`map3d( x, shape, fcn[, thisArg] )`][@stdlib/array/base/map3d]: apply a function to elements in a three-dimensional nested input array and assign results to elements in a new three-dimensional nested output array. -- [`map4d( x, shape, fcn[, thisArg] )`][@stdlib/array/base/map4d]: apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -- [`map5d( x, shape, fcn[, thisArg] )`][@stdlib/array/base/map5d]: apply a function to elements in a five-dimensional nested input array and assign results to elements in a new five-dimensional nested output array. -- [`minSignedIntegerDataType( value )`][@stdlib/array/base/min-signed-integer-dtype]: determine the minimum array data type for storing a provided signed integer value. -- [`minUnsignedIntegerDataType( value )`][@stdlib/array/base/min-unsigned-integer-dtype]: determine the minimum array data type for storing a provided unsigned integer value. -- [`mskbinary2d( arrays, shape, fcn )`][@stdlib/array/base/mskbinary2d]: apply a binary callback to elements in two two-dimensional nested input arrays according to elements in a two-dimensional nested mask array and assign results to elements in a two-dimensional nested output array. -- [`mskbinary3d( arrays, shape, fcn )`][@stdlib/array/base/mskbinary3d]: apply a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assign results to elements in a three-dimensional nested output array. -- [`mskbinary4d( arrays, shape, fcn )`][@stdlib/array/base/mskbinary4d]: apply a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assign results to elements in a four-dimensional nested output array. -- [`mskbinary5d( arrays, shape, fcn )`][@stdlib/array/base/mskbinary5d]: apply a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assign results to elements in a five-dimensional nested output array. -- [`mskfilterMap( x, mask, clbk[, thisArg] )`][@stdlib/array/base/mskfilter-map]: apply a mask and a callback function to a provided input array. -- [`mskfilter( x, mask )`][@stdlib/array/base/mskfilter]: apply a mask to a provided input array. -- [`mskfilter2( x, y, mask )`][@stdlib/array/base/mskfilter2]: apply a mask to two provided input arrays in a single pass. -- [`mskfiltern( x, [...arrays,] mask )`][@stdlib/array/base/mskfiltern]: apply a mask to one or more provided input arrays in a single pass. -- [`mskput( x, mask, values, mode )`][@stdlib/array/base/mskput]: replace elements of an array with provided values according to a provided mask array. -- [`mskreject( x, mask )`][@stdlib/array/base/mskreject]: apply a mask to a provided input array. -- [`mskunary2d( arrays, shape, fcn )`][@stdlib/array/base/mskunary2d]: apply a unary callback to elements in a two-dimensional nested input array according to elements in a two-dimensional nested mask array and assign results to elements in a two-dimensional nested output array. -- [`mskunary3d( arrays, shape, fcn )`][@stdlib/array/base/mskunary3d]: apply a unary callback to elements in a three-dimensional nested input array according to elements in a three-dimensional nested mask array and assign results to elements in a three-dimensional nested output array. -- [`mskunary4d( arrays, shape, fcn )`][@stdlib/array/base/mskunary4d]: apply a unary callback to elements in a four-dimensional nested input array according to elements in a four-dimensional nested mask array and assign results to elements in a four-dimensional nested output array. -- [`mskunary5d( arrays, shape, fcn )`][@stdlib/array/base/mskunary5d]: apply a unary callback to elements in a five-dimensional nested input array according to elements in a five-dimensional nested mask array and assign results to elements in a five-dimensional nested output array. -- [`nCartesianProduct( x1, x2[, ...xN] )`][@stdlib/array/base/n-cartesian-product]: return the n-fold Cartesian product. -- [`noneByRight( x, predicate[, thisArg] )`][@stdlib/array/base/none-by-right]: test whether all elements in an array fail a test implemented by a predicate function, iterating from right to left. -- [`noneBy( x, predicate[, thisArg] )`][@stdlib/array/base/none-by]: test whether all elements in an array fail a test implemented by a predicate function. -- [`none( x )`][@stdlib/array/base/none]: test whether all elements in an array are falsy. -- [`nulls( len )`][@stdlib/array/base/nulls]: create a "generic" array filled with null values. -- [`oneTo( n )`][@stdlib/array/base/one-to]: generate a linearly spaced numeric array whose elements increment by 1 starting from one. -- [`ones( len )`][@stdlib/array/base/ones]: create a "generic" array filled with ones. -- [`ones2d( shape )`][@stdlib/array/base/ones2d]: create a two-dimensional nested array filled with ones. -- [`ones3d( shape )`][@stdlib/array/base/ones3d]: create a three-dimensional nested array filled with ones. -- [`ones4d( shape )`][@stdlib/array/base/ones4d]: create a four-dimensional nested array filled with ones. -- [`ones5d( shape )`][@stdlib/array/base/ones5d]: create a five-dimensional nested array filled with ones. -- [`onesnd( shape )`][@stdlib/array/base/onesnd]: create an n-dimensional nested array filled with ones. -- [`place( x, mask, values, mode )`][@stdlib/array/base/place]: replace elements of an array with provided values according to a provided mask array. -- [`put( x, indices, values, mode )`][@stdlib/array/base/put]: replace specified elements of an array with provided values. -- [`quaternary2d( arrays, shape, fcn )`][@stdlib/array/base/quaternary2d]: apply a quaternary callback to elements in four two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. -- [`quaternary3d( arrays, shape, fcn )`][@stdlib/array/base/quaternary3d]: apply a quaternary callback to elements in four three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. -- [`quaternary4d( arrays, shape, fcn )`][@stdlib/array/base/quaternary4d]: apply a quaternary callback to elements in four four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. -- [`quaternary5d( arrays, shape, fcn )`][@stdlib/array/base/quaternary5d]: apply a quaternary callback to elements in four five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. -- [`quinary2d( arrays, shape, fcn )`][@stdlib/array/base/quinary2d]: apply a quinary callback to elements in five two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. -- [`quinary3d( arrays, shape, fcn )`][@stdlib/array/base/quinary3d]: apply a quinary callback to elements in five three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. -- [`quinary4d( arrays, shape, fcn )`][@stdlib/array/base/quinary4d]: apply a quinary callback to elements in five four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. -- [`quinary5d( arrays, shape, fcn )`][@stdlib/array/base/quinary5d]: apply a quinary callback to elements in five five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. -- [`reject( x, predicate[, thisArg] )`][@stdlib/array/base/reject]: return a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -- [`removeAt( x, index )`][@stdlib/array/base/remove-at]: remove an element from an array. -- [`reshape( x, fromShape, toShape, colexicographic )`][@stdlib/array/base/reshape]: reshape a nested array into another nested array having a desired shape. -- [`resolveGetter( x )`][@stdlib/array/base/resolve-getter]: return an accessor function for retrieving an element from an array-like object. -- [`resolveSetter( x )`][@stdlib/array/base/resolve-setter]: return an accessor function for setting an element in an array-like object. -- [`reverse( x )`][@stdlib/array/base/reverse]: reverse an array in-place. -- [`scatterFilled( fill, len, indices, values, mode )`][@stdlib/array/base/scatter-filled]: scatter a list of provided values to specified indices in a new filled "generic" array. -- [`scattered( len, indices, values, mode )`][@stdlib/array/base/scattered]: scatter a list of provided values to specified indices in a new zero-filled "generic" array. -- [`setter( dtype )`][@stdlib/array/base/setter]: return an accessor function for setting an element in an indexed array-like object. -- [`slice( x, start, end )`][@stdlib/array/base/slice]: return a shallow copy of a portion of an array. -- [`strided2array2d( x, shape, strides, offset )`][@stdlib/array/base/strided2array2d]: convert a strided array to a two-dimensional nested array. -- [`strided2array3d( x, shape, strides, offset )`][@stdlib/array/base/strided2array3d]: convert a strided array to a three-dimensional nested array. -- [`strided2array4d( x, shape, strides, offset )`][@stdlib/array/base/strided2array4d]: convert a strided array to a four-dimensional nested array. -- [`strided2array5d( x, shape, strides, offset )`][@stdlib/array/base/strided2array5d]: convert a strided array to a five-dimensional nested array. -- [`symmetricBanded`][@stdlib/array/base/symmetric-banded]: symmetric banded array utilities. -- [`symmetric`][@stdlib/array/base/symmetric]: symmetric array utilities. -- [`takeIndexed( x, indices )`][@stdlib/array/base/take-indexed]: take elements from an indexed array. -- [`takeIndexed2( x, y, indices )`][@stdlib/array/base/take-indexed2]: take elements from two indexed arrays in a single pass. -- [`take( x, indices, mode )`][@stdlib/array/base/take]: take elements from an array. -- [`take2d( x, indices, dimension, mode )`][@stdlib/array/base/take2d]: take elements from a two-dimensional nested array. -- [`take3d( x, indices, dimension, mode )`][@stdlib/array/base/take3d]: take elements from a three-dimensional nested array. -- [`ternary2d( arrays, shape, fcn )`][@stdlib/array/base/ternary2d]: apply a ternary callback to elements in three two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. -- [`ternary3d( arrays, shape, fcn )`][@stdlib/array/base/ternary3d]: apply a ternary callback to elements in three three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. -- [`ternary4d( arrays, shape, fcn )`][@stdlib/array/base/ternary4d]: apply a ternary callback to elements in three four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. -- [`ternary5d( arrays, shape, fcn )`][@stdlib/array/base/ternary5d]: apply a ternary callback to elements in three five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. -- [`toAccessorArray( arr )`][@stdlib/array/base/to-accessor-array]: convert an array-like object to a minimal array-like object supporting the accessor protocol. -- [`toDeduped( x, limit, equalNaNs )`][@stdlib/array/base/to-deduped]: copy elements to a new "generic" array after removing consecutive duplicated values. -- [`toReversed( x )`][@stdlib/array/base/to-reversed]: return a new array with elements in reverse order. -- [`unary2dBy( arrays, shape, fcn, clbk[, thisArg] )`][@stdlib/array/base/unary2d-by]: apply a unary function to each element retrieved from a two-dimensional nested input array according to a callback function and assign results to elements in a two-dimensional nested output array. -- [`unary2d( arrays, shape, fcn )`][@stdlib/array/base/unary2d]: apply a unary callback to elements in a two-dimensional nested input array and assign results to elements in a two-dimensional nested output array. -- [`unary3dBy( arrays, shape, fcn, clbk[, thisArg] )`][@stdlib/array/base/unary3d-by]: apply a unary function to each element retrieved from a three-dimensional nested input array according to a callback function and assign results to elements in a three-dimensional nested output array. -- [`unary3d( arrays, shape, fcn )`][@stdlib/array/base/unary3d]: apply a unary callback to elements in a three-dimensional nested input array and assign results to elements in a three-dimensional nested output array. -- [`unary4dBy( arrays, shape, fcn, clbk[, thisArg] )`][@stdlib/array/base/unary4d-by]: apply a unary function to each element retrieved from a four-dimensional nested input array according to a callback function and assign results to elements in a four-dimensional nested output array. -- [`unary4d( arrays, shape, fcn )`][@stdlib/array/base/unary4d]: apply a unary callback to elements in a four-dimensional nested input array and assign results to elements in a four-dimensional nested output array. -- [`unary5dBy( arrays, shape, fcn, clbk[, thisArg] )`][@stdlib/array/base/unary5d-by]: apply a unary function to each element retrieved from a five-dimensional nested input array according to a callback function and assign results to elements in a five-dimensional nested output array. -- [`unary5d( arrays, shape, fcn )`][@stdlib/array/base/unary5d]: apply a unary callback to elements in a five-dimensional nested input array and assign results to elements in a five-dimensional nested output array. -- [`unarynd( arrays, shape, fcn )`][@stdlib/array/base/unarynd]: apply a unary callback to elements in an n-dimensional nested input array and assign results to elements in an n-dimensional nested output array. -- [`unitspace( start, stop )`][@stdlib/array/base/unitspace]: generate a linearly spaced numeric array whose elements increment by 1. -- [`where( condition, x, y )`][@stdlib/array/base/where]: take elements from either one of two arrays depending on a condition. -- [`arrayWith( x, index, value )`][@stdlib/array/base/with]: return a new array with the element at the specified index replaced with a provided value. -- [`without( x, index )`][@stdlib/array/base/without]: return a new array containing every element from an input array, except for the element at a specified index. -- [`zeroTo( n )`][@stdlib/array/base/zero-to]: generate a linearly spaced numeric array whose elements increment by 1 starting from zero. -- [`zeros( len )`][@stdlib/array/base/zeros]: create a zero-filled "generic" array. -- [`zeros2d( shape )`][@stdlib/array/base/zeros2d]: create a zero-filled two-dimensional nested array. -- [`zeros3d( shape )`][@stdlib/array/base/zeros3d]: create a zero-filled three-dimensional nested array. -- [`zeros4d( shape )`][@stdlib/array/base/zeros4d]: create a zero-filled four-dimensional nested array. -- [`zeros5d( shape )`][@stdlib/array/base/zeros5d]: create a zero-filled five-dimensional nested array. -- [`zerosnd( shape )`][@stdlib/array/base/zerosnd]: create a zero-filled n-dimensional nested array. - -
- - - -
- - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var ns = require( '@stdlib/array/base' ); - -// Create a zero-filled array: -var zeros = ns.zeros( 5 ); -// returns [ 0, 0, 0, 0, 0 ] - -// Create an array filled with a specific value: -var filled = ns.filled( 7, 4 ); -// returns [ 7, 7, 7, 7 ] - -// Create a linearly spaced array: -var linear = ns.linspace( 0, 1, 5 ); -// returns [ 0, 0.25, 0.5, 0.75, 1 ] - -// Create a two-dimensional array: -var arr2d = ns.ones2d( [ 2, 3 ] ); -// returns [ [ 1, 1, 1 ], [ 1, 1, 1 ] ] - -// Map a function over a 2D array: -var squared = ns.map2d( arr2d, [ 2, 3 ], randu ); -// e.g., returns [ [ ~0.123, ~0.789, ~0.456 ], [ ~0.321, ~0.654, ~0.987 ] ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/accessor-getter/README.md b/base/accessor-getter/README.md deleted file mode 100644 index 5baeddd55..000000000 --- a/base/accessor-getter/README.md +++ /dev/null @@ -1,148 +0,0 @@ - - -# accessorGetter - -> Return an accessor function for retrieving an element from an array-like object supporting the get/set protocol. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var accessorGetter = require( '@stdlib/array/base/accessor-getter' ); -``` - -#### accessorGetter( dtype ) - -Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol. - -```javascript -var Complex64Array = require( '@stdlib/array/complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( [ 1, 2, 3, 4 ] ); - -var get = accessorGetter( 'complex64' ); -var v = get( arr, 1 ); -// returns - -var re = realf( v ); -// returns 3.0 - -var im = imagf( v ); -// returns 4.0 -``` - -The returned accessor function accepts the following arguments: - -- **arr**: input array. -- **idx**: element index. - -
- - - - - -
- -## Notes - -- If provided an unsupported [`dtype`][@stdlib/array/dtypes], the function returns a default accessor function for accessing elements from any indexed array-like object supporting the get/set protocol; otherwise, the function returns an accessor function which should **only** be provided an array instance corresponding to `dtype` (e.g., if `dtype` is `'complex64'`, the returned accessor function should only be provided instances of `Complex64Array`). -- Accessor functions do **not** verify that provided input arrays are array instances corresponding to `dtype`, as doing so would introduce performance overhead. If array instances corresponding to other data types are provided to an accessor function, JavaScript runtimes will consider the function polymorphic, potentially triggering de-optimization. In order to ensure maximum performance, **always** ensure that an accessor function is monomorphic. -- Accessor functions do **not** perform bounds checking. -- Accessor functions do **not** verify that provided input arrays actually implement the get/set protocol. -- An array-like object supporting the get/set protocol is a data structure in which one accesses elements using explicit `get` and `set` methods (e.g., `Complex64Array` and `Complex128Array`). - -
- - - - - -
- -## Examples - - - -```javascript -var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex64Array = require( '@stdlib/array/complex64' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var dtype = require( '@stdlib/array/dtype' ); -var accessorGetter = require( '@stdlib/array/base/accessor-getter' ); - -var arr = new Complex128Array( zeroTo( 10 ) ); -var v = accessorGetter( dtype( arr ) )( arr, 2 ); -// returns - -console.log( v.toString() ); -// => '4 + 5i' - -arr = new Complex64Array( zeroTo( 10 ) ); -v = accessorGetter( dtype( arr ) )( arr, 4 ); -// returns - -console.log( v.toString() ); -// => '8 + 9i' -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/accessor-getter/benchmark/benchmark.js b/base/accessor-getter/benchmark/benchmark.js deleted file mode 100644 index b09ccfead..000000000 --- a/base/accessor-getter/benchmark/benchmark.js +++ /dev/null @@ -1,123 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isFunction = require( '@stdlib/assert/is-function' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var filledBy = require( './../../../filled-by' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var dtype = require( './../../../dtype' ); -var pkg = require( './../package.json' ).name; -var getter = require( './../lib' ); - - -// VARIABLES // - -var rand = discreteUniform( 0, 127 ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var get; - var dt; - var i; - - dt = [ - 'complex128', - 'complex64', - 'foo' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - get = getter( dt[ i%dt.length ] ); - if ( typeof get !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( get ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var buf; - var get; - var i; - var v; - - buf = filledBy( 100, 'float64', rand ); - arr = new Complex128Array( buf.buffer ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( isnan( real( v ) ) || isnan( imag( v ) ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var buf; - var get; - var i; - var v; - - buf = filledBy( 100, 'float32', rand ); - arr = new Complex64Array( buf.buffer ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( isnanf( realf( v ) ) || isnanf( imagf( v ) ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/accessor-getter/docs/repl.txt b/base/accessor-getter/docs/repl.txt deleted file mode 100644 index 68ead221c..000000000 --- a/base/accessor-getter/docs/repl.txt +++ /dev/null @@ -1,55 +0,0 @@ - -{{alias}}( dtype ) - Returns an accessor function for retrieving an element from an array-like - object supporting the get/set protocol. - - An accessor function accepts the following arguments: - - - arr: input array. - - idx: element index. - - If provided an unsupported `dtype`, the function returns a default accessor - function for accessing elements from any indexed array-like object - supporting the get/set protocol. - - Otherwise, the function returns an accessor function which should *only* be - provided an array instance corresponding to `dtype` (e.g., if `dtype` is - 'complex64', the returned accessor function should only be provided - instances of Complex64Array). - - Accessor functions do *not* verify that provided input arrays are array - instances corresponding to `dtype`, as doing so would introduce performance - overhead. If array instances corresponding to other data types are provided - to an accessor function, JavaScript runtimes will consider the function - polymorphic, potentially triggering de-optimization. In order to ensure - maximum performance, *always* ensure that an accessor function is - monomorphic. - - Accessor functions do *not* perform bounds checking. - - Accessor functions do *not* verify that provided input arrays actually - implement the get/set protocol. - - Parameters - ---------- - dtype: string - Array data type. - - Returns - ------- - f: Function - Accessor function. - - Examples - -------- - > var f = {{alias}}( 'complex64' ); - > var v = f( {{alias:@stdlib/array/complex64}}( [ 1, 2, 3, 4 ] ), 1 ) - - > var r = {{alias:@stdlib/complex/float32/real}}( v ) - 3.0 - > var i = {{alias:@stdlib/complex/float32/imag}}( v ) - 4.0 - - See Also - -------- - diff --git a/base/accessor-getter/docs/types/index.d.ts b/base/accessor-getter/docs/types/index.d.ts deleted file mode 100644 index 3e014798e..000000000 --- a/base/accessor-getter/docs/types/index.d.ts +++ /dev/null @@ -1,132 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Complex64, Complex128 } from '@stdlib/types/complex'; -import { Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns an element from a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetArrayLike = ( arr: AccessorArrayLike, idx: number ) => T; - -/** -* Returns an accessor function for retrieving an element from a `Complex128Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var real = require( '@stdlib/array/real' ); -* var imag = require( '@stdlib/array/imag' ); -* -* var arr = new Complex128Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( 'complex128' ); -* var v = get( arr, 1 ); -* // returns -* -* var re = real( v ); -* // returns 3.0 -* -* var im = imag( v ); -* // returns 4.0 -*/ -declare function getter( dtype: 'complex128' ): GetComplex128; - -/** -* Returns an accessor function for retrieving an element from a `Complex64Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* var realf = require( '@stdlib/array/realf' ); -* var imagf = require( '@stdlib/array/imagf' ); -* -* var arr = new Complex64Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( 'complex64' ); -* var v = get( arr, 1 ); -* // returns -* -* var re = realf( v ); -* // returns 3.0 -* -* var im = imagf( v ); -* // returns 4.0 -*/ -declare function getter( dtype: 'complex64' ): GetComplex64; - -/** -* Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* function aget( idx ) { -* return arr[ idx ]; -* } -* -* function aset( value, idx ) { -* arr[ idx ] = value; -* } -* -* arr.get = aget; -* arr.set = aset; -* -* var get = getter( 'foo' ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function getter( dtype: string ): GetArrayLike; - - -// EXPORTS // - -export = getter; diff --git a/base/accessor-getter/docs/types/test.ts b/base/accessor-getter/docs/types/test.ts deleted file mode 100644 index d0d568163..000000000 --- a/base/accessor-getter/docs/types/test.ts +++ /dev/null @@ -1,154 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import getter = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @returns array-like object -*/ -function accessorArray(): AccessorArrayLike { - const arr: AccessorArrayLike = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - - -// TESTS // - -// The function returns a function... -{ - getter( 'complex128' ); // $ExpectType GetComplex128 - getter( 'complex64' ); // $ExpectType GetComplex64 - getter( 'foo' ); // $ExpectType GetArrayLike -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - getter( 5 ); // $ExpectError - getter( true ); // $ExpectError - getter( false ); // $ExpectError - getter( null ); // $ExpectError - getter( {} ); // $ExpectError - getter( [] ); // $ExpectError - getter( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - getter(); // $ExpectError - getter( 'complex128', {} ); // $ExpectError -} - -// The function returns a function which returns an array element... -{ - const get1 = getter( 'foo' ); - const x1 = accessorArray(); - get1( x1, 2 ); // $ExpectType number - - const get2 = getter( 'complex128' ); - const x2 = new Complex128Array( [ 1, 2, 3, 4 ] ); - get2( x2, 1 ); // $ExpectType void | Complex128 - - const get3 = getter( 'complex64' ); - const x3 = new Complex64Array( [ 1, 2, 3, 4 ] ); - get3( x3, 1 ); // $ExpectType void | Complex64 -} - -// The compiler throws an error if the returned function is provided a first argument which is not a accessor array... -{ - const get1 = getter( 'foo' ); - get1( 5, 1 ); // $ExpectError - get1( true, 1 ); // $ExpectError - get1( false, 1 ); // $ExpectError - get1( null, 1 ); // $ExpectError - get1( {}, 1 ); // $ExpectError - - const get2 = getter( 'complex128' ); - get2( 5, 1 ); // $ExpectError - get2( true, 1 ); // $ExpectError - get2( false, 1 ); // $ExpectError - get2( null, 1 ); // $ExpectError - get2( {}, 1 ); // $ExpectError - - const get3 = getter( 'complex64' ); - get3( 5, 1 ); // $ExpectError - get3( true, 1 ); // $ExpectError - get3( false, 1 ); // $ExpectError - get3( null, 1 ); // $ExpectError - get3( {}, 1 ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided a second argument which is not a number... -{ - const get1 = getter( 'foo' ); - get1( accessorArray(), '5' ); // $ExpectError - get1( accessorArray(), true ); // $ExpectError - get1( accessorArray(), false ); // $ExpectError - get1( accessorArray(), null ); // $ExpectError - get1( accessorArray(), {} ); // $ExpectError - - const get2 = getter( 'complex128' ); - get2( new Complex128Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get2( new Complex128Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get2( new Complex128Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get2( new Complex128Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get2( new Complex128Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get3 = getter( 'complex64' ); - get3( new Complex64Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get3( new Complex64Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get3( new Complex64Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get3( new Complex64Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get3( new Complex64Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided an unsupported number of arguments... -{ - const get1 = getter( 'foo' ); - get1(); // $ExpectError - get1( [] ); // $ExpectError - get1( [], 1, 2 ); // $ExpectError - - const get2 = getter( 'complex128' ); - get2(); // $ExpectError - get2( new Complex128Array( [] ) ); // $ExpectError - get2( new Complex128Array( [] ), 1, 2 ); // $ExpectError - - const get3 = getter( 'complex64' ); - get3(); // $ExpectError - get3( new Complex64Array( [] ) ); // $ExpectError - get3( new Complex64Array( [] ), 1, 2 ); // $ExpectError -} diff --git a/base/accessor-getter/examples/index.js b/base/accessor-getter/examples/index.js deleted file mode 100644 index c05d4e71b..000000000 --- a/base/accessor-getter/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var zeroTo = require( './../../../base/zero-to' ); -var dtype = require( './../../../dtype' ); -var accessorGetter = require( './../lib' ); - -var arr = new Complex128Array( zeroTo( 10 ) ); -var v = accessorGetter( dtype( arr ) )( arr, 2 ); -// returns - -console.log( '%s', v.toString() ); - -arr = new Complex64Array( zeroTo( 10 ) ); -v = accessorGetter( dtype( arr ) )( arr, 4 ); -// returns - -console.log( '%s', v.toString() ); diff --git a/base/accessor-getter/lib/index.js b/base/accessor-getter/lib/index.js deleted file mode 100644 index 7590cf316..000000000 --- a/base/accessor-getter/lib/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an accessor function for retrieving an element from an array-like object supporting the get/set protocol. -* -* @module @stdlib/array/base/accessor-getter -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var dtype = require( '@stdlib/array/dtype' ); -* var getter = require( '@stdlib/array/base/accessor-getter' ); -* -* var arr = new Complex64Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( dtype( arr ) ); -* var v = get( arr, 1 ); -* // returns -* -* var re = realf( v ); -* // returns 3.0 -* -* var im = imagf( v ); -* // returns 4.0 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/accessor-getter/lib/main.js b/base/accessor-getter/lib/main.js deleted file mode 100644 index c192e6cf1..000000000 --- a/base/accessor-getter/lib/main.js +++ /dev/null @@ -1,155 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var GETTERS = { - 'complex128': getComplex128, - 'complex64': getComplex64, - 'default': getArrayLike -}; - - -// FUNCTIONS // - -/** -* Returns an element from a `Complex128Array`. -* -* @private -* @param {Complex128Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {number} element value -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var arr = new Complex128Array( [ 1, 2, 3, 4 ] ); -* -* var v = getComplex128( arr, 1 ); -* // returns -* -* var re = real( v ); -* // returns 3.0 -* -* var im = imag( v ); -* // returns 4.0 -*/ -function getComplex128( arr, idx ) { - return arr.get( idx ); -} - -/** -* Returns an element from a `Complex64Array`. -* -* @private -* @param {Complex64Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {number} element value -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var arr = new Complex64Array( [ 1, 2, 3, 4 ] ); -* -* var v = getComplex64( arr, 1 ); -* // returns -* -* var re = realf( v ); -* // returns 3.0 -* -* var im = imagf( v ); -* // returns 4.0 -*/ -function getComplex64( arr, idx ) { - return arr.get( idx ); -} - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @private -* @param {Collection} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element value -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return arr[ idx ]; -* } -* -* function set( value, idx ) { -* arr[ idx ] = value; -* } -* -* arr.get = get; -* arr.set = set; -* -* var v = getArrayLike( arr, 2 ); -* // returns 3 -*/ -function getArrayLike( arr, idx ) { - return arr.get( idx ); -} - - -// MAIN // - -/** -* Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol. -* -* @param {string} dtype - array dtype -* @returns {Function} accessor -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var dtype = require( '@stdlib/array/dtype' ); -* -* var arr = new Complex64Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( dtype( arr ) ); -* var v = get( arr, 1 ); -* // returns -* -* var re = realf( v ); -* // returns 3.0 -* -* var im = imagf( v ); -* // returns 4.0 -*/ -function getter( dtype ) { - var f = GETTERS[ dtype ]; - if ( typeof f === 'function' ) { - return f; - } - return GETTERS.default; -} - - -// EXPORTS // - -module.exports = getter; diff --git a/base/accessor-getter/package.json b/base/accessor-getter/package.json deleted file mode 100644 index fe3c1a2db..000000000 --- a/base/accessor-getter/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/accessor-getter", - "version": "0.0.0", - "description": "Return an accessor function for retrieving an element from an array-like object supporting the get/set protocol.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "array", - "generic", - "get", - "accessor", - "access", - "retrieve", - "getter" - ] -} diff --git a/base/accessor-getter/test/test.js b/base/accessor-getter/test/test.js deleted file mode 100644 index 36d1e27cf..000000000 --- a/base/accessor-getter/test/test.js +++ /dev/null @@ -1,142 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var zeroTo = require( './../../../base/zero-to' ); -var getter = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns an accessor array-like object. -* -* @private -* @returns {ArrayLikeObject} array-like object -*/ -function accessorArray() { - var arr = [ 1, 2, 3, 4 ]; - arr.set = set; - arr.get = get; - return arr; - - /** - * Returns an array element. - * - * @private - * @param {NonNegativeInteger} idx - index - * @returns {number} element - */ - function get( idx ) { - return arr[ idx ]; - } - - /** - * Sets an array element. - * - * @private - * @param {number} value - value to set - * @param {NonNegativeInteger} idx - index - */ - function set( value, idx ) { - arr[ idx ] = value; - } -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof getter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function for returning an array element', function test( t ) { - var arr; - var get; - var v; - - get = getter( 'complex128' ); - arr = new Complex128Array( zeroTo( 10 ) ); - v = get( arr, 2 ); - t.strictEqual( real( v ), 4.0, 'returns expected value' ); - t.strictEqual( imag( v ), 5.0, 'returns expected value' ); - - get = getter( 'complex64' ); - arr = new Complex64Array( zeroTo( 10 ) ); - v = get( arr, 2 ); - t.strictEqual( realf( v ), 4.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 5.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function for returning an array element (unrecognized dtype)', function test( t ) { - var arr; - var get; - var v; - - get = getter( 'foo' ); - arr = accessorArray(); - v = get( arr, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned function does not perform bounds checks', function test( t ) { - var arr; - var get; - var v; - - get = getter( 'complex128' ); - arr = new Complex128Array( zeroTo( 10 ) ); - v = get( arr, arr.length+10 ); - t.strictEqual( v, void 0, 'returns expected value' ); - - get = getter( 'complex64' ); - arr = new Complex64Array( zeroTo( 10 ) ); - v = get( arr, arr.length+10 ); - t.strictEqual( v, void 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (unrecognized dtype)', function test( t ) { - var arr; - var get; - var v; - - get = getter( 'foo' ); - arr = accessorArray(); - v = get( arr, arr.length+10 ); - t.strictEqual( v, void 0, 'returns expected value' ); - - t.end(); -}); diff --git a/base/accessor-setter/README.md b/base/accessor-setter/README.md deleted file mode 100644 index 6d23e00d2..000000000 --- a/base/accessor-setter/README.md +++ /dev/null @@ -1,159 +0,0 @@ - - -# accessorSetter - -> Return an accessor function for setting an element in an array-like object supporting the get/set protocol. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var accessorSetter = require( '@stdlib/array/base/accessor-setter' ); -``` - -#### accessorSetter( dtype ) - -Returns an accessor function for setting an element in an array-like object supporting the get/set protocol. - -```javascript -var Complex64Array = require( '@stdlib/array/complex64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( [ 1, 2, 3, 4 ] ); - -var set = accessorSetter( 'complex64' ); -set( arr, 1, new Complex64( 10.0, 11.0 ) ); - -var v = arr.get( 1 ); -// returns - -var re = realf( v ); -// returns 10.0 - -var im = imagf( v ); -// returns 11.0 -``` - -The returned accessor function accepts the following arguments: - -- **arr**: input array. -- **idx**: element index. -- **value**: value to set. - -
- - - - - -
- -## Notes - -- If provided an unsupported [`dtype`][@stdlib/array/dtypes], the function returns a default accessor function for accessing elements from any indexed array-like object supporting the get/set protocol; otherwise, the function returns an accessor function which should **only** be provided an array instance corresponding to `dtype` (e.g., if `dtype` is `'complex64'`, the returned accessor function should only be provided instances of `Complex64Array`). -- Accessor functions do **not** verify that provided input arrays are array instances corresponding to `dtype`, as doing so would introduce performance overhead. If array instances corresponding to other data types are provided to an accessor function, JavaScript runtimes will consider the function polymorphic, potentially triggering de-optimization. In order to ensure maximum performance, **always** ensure that an accessor function is monomorphic. -- Accessor functions do **not** perform bounds checking. -- Accessor functions do **not** validate input values. -- Accessor functions do **not** verify that provided input arrays actually implement the get/set protocol. -- An array-like object supporting the get/set protocol is a data structure in which one accesses elements using explicit `get` and `set` methods (e.g., `Complex64Array` and `Complex128Array`). - -
- - - - - -
- -## Examples - - - -```javascript -var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex64Array = require( '@stdlib/array/complex64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var dtype = require( '@stdlib/array/dtype' ); -var accessorSetter = require( '@stdlib/array/base/accessor-setter' ); - -var arr = new Complex128Array( zeroTo( 10 ) ); -accessorSetter( dtype( arr ) )( arr, 2, new Complex128( 100.0, 101.0 ) ); - -var v = arr.get( 2 ); -// returns - -console.log( '%s', v.toString() ); -// => '100 + 101i' - -arr = new Complex64Array( zeroTo( 10 ) ); -accessorSetter( dtype( arr ) )( arr, 4, new Complex64( 102.0, 103.0 ) ); - -v = arr.get( 4 ); -// returns - -console.log( '%s', v.toString() ); -// => '102 + 103i' -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/accessor-setter/benchmark/benchmark.js b/base/accessor-setter/benchmark/benchmark.js deleted file mode 100644 index 04a2dca7b..000000000 --- a/base/accessor-setter/benchmark/benchmark.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isFunction = require( '@stdlib/assert/is-function' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var filledBy = require( './../../../filled-by' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var dtype = require( './../../../dtype' ); -var pkg = require( './../package.json' ).name; -var setter = require( './../lib' ); - - -// VARIABLES // - -var rand = discreteUniform( 0, 127 ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var set; - var dt; - var i; - - dt = [ - 'complex128', - 'complex64', - 'foo' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - set = setter( dt[ i%dt.length ] ); - if ( typeof set !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( set ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var values; - var arr; - var buf; - var set; - var i; - var j; - var v; - - values = [ - new Complex128( 1.0, 2.0 ), - new Complex128( 3.0, 4.0 ), - new Complex128( 5.0, 6.0 ) - ]; - - buf = filledBy( 100, 'float64', rand ); - arr = new Complex128Array( buf.buffer ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, values[ i%values.length ] ); - v = arr.get( j ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( isnan( real( v ) ) || isnan( imag( v ) ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var values; - var arr; - var buf; - var set; - var i; - var j; - var v; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ) - ]; - - buf = filledBy( 100, 'float32', rand ); - arr = new Complex64Array( buf.buffer ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, values[ i%values.length ] ); - v = arr.get( j ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( isnanf( realf( v ) ) || isnanf( imagf( v ) ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/accessor-setter/docs/repl.txt b/base/accessor-setter/docs/repl.txt deleted file mode 100644 index f0fee0973..000000000 --- a/base/accessor-setter/docs/repl.txt +++ /dev/null @@ -1,60 +0,0 @@ - -{{alias}}( dtype ) - Returns an accessor function for setting an element in an array-like object - supporting the get/set protocol. - - An accessor function accepts the following arguments: - - - arr: input array. - - idx: element index. - - value: value to set. - - If provided an unsupported `dtype`, the function returns a default accessor - function for accessing elements in any indexed array-like object supporting - the get/set protocol. - - Otherwise, the function returns an accessor function which should *only* be - provided an array instance corresponding to `dtype` (e.g., if `dtype` is - 'complex64', the returned accessor function should only be provided - instances of Complex64Array). - - Accessor functions do *not* verify that provided input arrays are array - instances corresponding to `dtype`, as doing so would introduce performance - overhead. If array instances corresponding to other data types are provided - to an accessor function, JavaScript runtimes will consider the function - polymorphic, potentially triggering de-optimization. In order to ensure - maximum performance, *always* ensure that an accessor function is - monomorphic. - - Accessor functions do *not* perform bounds checking. - - Accessor functions do *not* validate input values. - - Accessor functions do *not* verify that provided input arrays actually - implement the get/set protocol. - - Parameters - ---------- - dtype: string - Array data type. - - Returns - ------- - f: Function - Accessor function. - - Examples - -------- - > var f = {{alias}}( 'complex64' ); - > var x = {{alias:@stdlib/array/complex64}}( [ 1, 2, 3, 4 ] ); - > f( x, 1, new {{alias:@stdlib/complex/float32/ctor}}( 10.0, 11.0 ) ); - > var v = x.get( 1 ) - - > var r = {{alias:@stdlib/complex/float32/real}}( v ) - 10.0 - > var i = {{alias:@stdlib/complex/float32/imag}}( v ) - 11.0 - - See Also - -------- - diff --git a/base/accessor-setter/docs/types/index.d.ts b/base/accessor-setter/docs/types/index.d.ts deleted file mode 100644 index bb2cb0471..000000000 --- a/base/accessor-setter/docs/types/index.d.ts +++ /dev/null @@ -1,140 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { ComplexLike } from '@stdlib/types/complex'; -import { Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Returns an accessor function for setting an element in a `Complex128Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/array/real' ); -* var imag = require( '@stdlib/array/imag' ); -* -* var arr = new Complex128Array( [ 1, 2, 3, 4 ] ); -* -* var set = setter( 'complex128' ); -* set( arr, 1, new Complex128( 10.0, 11.0 ) ); -* -* var v = arr.get( 1 ); -* // returns -* -* var re = real( v ); -* // returns 10.0 -* -* var im = imag( v ); -* // returns 11.0 -*/ -declare function setter( dtype: 'complex128' ): SetComplex128; - -/** -* Returns an accessor function for setting an element in a `Complex64Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/array/realf' ); -* var imagf = require( '@stdlib/array/imagf' ); -* -* var arr = new Complex64Array( [ 1, 2, 3, 4 ] ); -* -* var set = setter( 'complex64' ); -* set( arr, 1, new Complex64( 10.0, 11.0 ) ); -* -* var v = arr.get( 1 ); -* // returns -* -* var re = realf( v ); -* // returns 3.0 -* -* var im = imagf( v ); -* // returns 4.0 -*/ -declare function setter( dtype: 'complex64' ): SetComplex64; - -/** -* Returns an accessor function for setting an element in an array-like object supporting the get/set protocol. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* function aget( idx ) { -* return arr[ idx ]; -* } -* -* function aset( value, idx ) { -* arr[ idx ] = value; -* } -* -* arr.get = aget; -* arr.set = aset; -* -* var set = setter( 'foo' ); -* set( arr, 2, 10 ); -* -* var v = arr.get( 2 ); -* // returns 3 -*/ -declare function setter( dtype: string ): SetArrayLike; - - -// EXPORTS // - -export = setter; diff --git a/base/accessor-setter/docs/types/test.ts b/base/accessor-setter/docs/types/test.ts deleted file mode 100644 index 1fc5398e4..000000000 --- a/base/accessor-setter/docs/types/test.ts +++ /dev/null @@ -1,151 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 AccessorArray = require( './../../../../base/accessor' ); -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import Complex64 = require( '@stdlib/complex/float32/ctor' ); -import setter = require( './index' ); - -// TESTS // - -// The function returns a function... -{ - setter( 'complex128' ); // $ExpectType SetComplex128 - setter( 'complex64' ); // $ExpectType SetComplex64 - setter( 'foo' ); // $ExpectType SetArrayLike -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - setter( 5 ); // $ExpectError - setter( true ); // $ExpectError - setter( false ); // $ExpectError - setter( null ); // $ExpectError - setter( {} ); // $ExpectError - setter( [] ); // $ExpectError - setter( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - setter(); // $ExpectError - setter( 'complex128', {} ); // $ExpectError -} - -// The function returns a function which sets an array element... -{ - const set1 = setter( 'foo' ); - const x1 = new AccessorArray( [ 1, 2, 3 ] ); - set1( x1, 2, 10 ); // $ExpectType void - - const set2 = setter( 'complex128' ); - const x2 = new Complex128Array( [ 1, 2, 3, 4 ] ); - set2( x2, 1, new Complex128( 5, 6 ) ); // $ExpectType void - - const set3 = setter( 'complex64' ); - const x3 = new Complex64Array( [ 1, 2, 3, 4 ] ); - set3( x3, 1, new Complex64( 7, 8 ) ); // $ExpectType void -} - -// The compiler throws an error if the returned function is provided a first argument which is not a accessor array... -{ - const set1 = setter( 'foo' ); - set1( 5, 1, 3 ); // $ExpectError - set1( true, 1, 3 ); // $ExpectError - set1( false, 1, 3 ); // $ExpectError - set1( null, 1, 3 ); // $ExpectError - set1( {}, 1, 3 ); // $ExpectError - - const set2 = setter( 'complex128' ); - set2( 5, 1, new Complex128( 5, 6 ) ); // $ExpectError - set2( true, 1, new Complex128( 5, 6 ) ); // $ExpectError - set2( false, 1, new Complex128( 5, 6 ) ); // $ExpectError - set2( null, 1, new Complex128( 5, 6 ) ); // $ExpectError - set2( {}, 1, new Complex128( 5, 6 ) ); // $ExpectError - - const set3 = setter( 'complex64' ); - set3( 5, 1, new Complex64( 7, 8 ) ); // $ExpectError - set3( true, 1, new Complex64( 7, 8 ) ); // $ExpectError - set3( false, 1, new Complex64( 7, 8 ) ); // $ExpectError - set3( null, 1, new Complex64( 7, 8 ) ); // $ExpectError - set3( {}, 1, new Complex64( 7, 8 ) ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided a second argument which is not a number... -{ - const set1 = setter( 'foo' ); - set1( new AccessorArray( [ 1, 2, 3 ] ), '5', 3 ); // $ExpectError - set1( new AccessorArray( [ 1, 2, 3 ] ), true, 3 ); // $ExpectError - set1( new AccessorArray( [ 1, 2, 3 ] ), false, 3 ); // $ExpectError - set1( new AccessorArray( [ 1, 2, 3 ] ), null, 3 ); // $ExpectError - set1( new AccessorArray( [ 1, 2, 3 ] ), {}, 3 ); // $ExpectError - - const set2 = setter( 'complex128' ); - set2( new Complex128Array( [ 1, 2, 3, 4 ] ), '5', new Complex128( 5, 6 ) ); // $ExpectError - set2( new Complex128Array( [ 1, 2, 3, 4 ] ), true, new Complex128( 5, 6 ) ); // $ExpectError - set2( new Complex128Array( [ 1, 2, 3, 4 ] ), false, new Complex128( 5, 6 ) ); // $ExpectError - set2( new Complex128Array( [ 1, 2, 3, 4 ] ), null, new Complex128( 5, 6 ) ); // $ExpectError - set2( new Complex128Array( [ 1, 2, 3, 4 ] ), {}, new Complex128( 5, 6 ) ); // $ExpectError - - const set3 = setter( 'complex64' ); - set3( new Complex64Array( [ 1, 2, 3, 4 ] ), '5', new Complex64( 7, 8 ) ); // $ExpectError - set3( new Complex64Array( [ 1, 2, 3, 4 ] ), true, new Complex64( 7, 8 ) ); // $ExpectError - set3( new Complex64Array( [ 1, 2, 3, 4 ] ), false, new Complex64( 7, 8 ) ); // $ExpectError - set3( new Complex64Array( [ 1, 2, 3, 4 ] ), null, new Complex64( 7, 8 ) ); // $ExpectError - set3( new Complex64Array( [ 1, 2, 3, 4 ] ), {}, new Complex64( 7, 8 ) ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided a third argument which is not a valid value... -{ - const set2 = setter( 'complex128' ); - set2( new Complex128Array( [ 1, 2, 3, 4 ] ), 1, '5' ); // $ExpectError - set2( new Complex128Array( [ 1, 2, 3, 4 ] ), 1, true ); // $ExpectError - set2( new Complex128Array( [ 1, 2, 3, 4 ] ), 1, false ); // $ExpectError - set2( new Complex128Array( [ 1, 2, 3, 4 ] ), 1, null ); // $ExpectError - set2( new Complex128Array( [ 1, 2, 3, 4 ] ), 1, {} ); // $ExpectError - - const set3 = setter( 'complex64' ); - set3( new Complex64Array( [ 1, 2, 3, 4 ] ), 1, '5' ); // $ExpectError - set3( new Complex64Array( [ 1, 2, 3, 4 ] ), 1, true ); // $ExpectError - set3( new Complex64Array( [ 1, 2, 3, 4 ] ), 1, false ); // $ExpectError - set3( new Complex64Array( [ 1, 2, 3, 4 ] ), 1, null ); // $ExpectError - set3( new Complex64Array( [ 1, 2, 3, 4 ] ), 1, {} ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided an unsupported number of arguments... -{ - const set1 = setter( 'foo' ); - set1(); // $ExpectError - set1( [] ); // $ExpectError - set1( [], 1 ); // $ExpectError - set1( [], 1, 2, 2 ); // $ExpectError - - const set2 = setter( 'complex128' ); - set2(); // $ExpectError - set2( new Complex128Array( [] ) ); // $ExpectError - set2( new Complex128Array( [] ), 1 ); // $ExpectError - set2( new Complex128Array( [] ), 1, new Complex128( 5, 6 ), 2 ); // $ExpectError - - const set3 = setter( 'complex64' ); - set3(); // $ExpectError - set3( new Complex64Array( [] ) ); // $ExpectError - set3( new Complex64Array( [] ), 1 ); // $ExpectError - set3( new Complex64Array( [] ), 1, new Complex64( 7, 8 ), 2 ); // $ExpectError -} diff --git a/base/accessor-setter/examples/index.js b/base/accessor-setter/examples/index.js deleted file mode 100644 index 58f0a5b8b..000000000 --- a/base/accessor-setter/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var zeroTo = require( './../../../base/zero-to' ); -var dtype = require( './../../../dtype' ); -var accessorSetter = require( './../lib' ); - -var arr = new Complex128Array( zeroTo( 10 ) ); -accessorSetter( dtype( arr ) )( arr, 2, new Complex128( 100.0, 101.0 ) ); - -var v = arr.get( 2 ); -// returns - -console.log( '%s', v.toString() ); -// => '100 + 101i' - -arr = new Complex64Array( zeroTo( 10 ) ); -accessorSetter( dtype( arr ) )( arr, 4, new Complex64( 102.0, 103.0 ) ); - -v = arr.get( 4 ); -// returns - -console.log( '%s', v.toString() ); -// => '102 + 103i' diff --git a/base/accessor-setter/lib/index.js b/base/accessor-setter/lib/index.js deleted file mode 100644 index 3f99b69ad..000000000 --- a/base/accessor-setter/lib/index.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an accessor function for setting an element in an array-like object supporting the get/set protocol. -* -* @module @stdlib/array/base/accessor-setter -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var dtype = require( '@stdlib/array/dtype' ); -* var setter = require( '@stdlib/array/base/accessor-setter' ); -* -* var arr = new Complex64Array( [ 1, 2, 3, 4 ] ); -* -* var set = setter( dtype( arr ) ); -* set( arr, 1, new Complex64( 10.0, 11.0 ) ); -* -* var v = arr.get( 1 ); -* // returns -* -* var re = realf( v ); -* // returns 10.0 -* -* var im = imagf( v ); -* // returns 11.0 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/accessor-setter/lib/main.js b/base/accessor-setter/lib/main.js deleted file mode 100644 index 46371aa41..000000000 --- a/base/accessor-setter/lib/main.js +++ /dev/null @@ -1,164 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var SETTERS = { - 'complex128': setComplex128, - 'complex64': setComplex64, - 'default': setArrayLike -}; - - -// FUNCTIONS // - -/** -* Sets an element in a `Complex128Array`. -* -* @private -* @param {Complex128Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {(Collection|Complex|ComplexArray)} value - value(s) -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var arr = new Complex128Array( [ 1, 2, 3, 4 ] ); -* -* setComplex128( arr, 1, new Complex128( 10.0, 11.0 ) ); -* var v = arr.get( 1 ); -* // returns -* -* var re = real( v ); -* // returns 10.0 -* -* var im = imag( v ); -* // returns 11.0 -*/ -function setComplex128( arr, idx, value ) { - arr.set( value, idx ); -} - -/** -* Sets an element in a `Complex64Array`. -* -* @private -* @param {Complex64Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {(Collection|Complex|ComplexArray)} value - value(s) -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var arr = new Complex64Array( [ 1, 2, 3, 4 ] ); -* -* setComplex64( arr, 1, new Complex64( 10.0, 11.0 ) ); -* var v = arr.get( 1 ); -* // returns -* -* var re = realf( v ); -* // returns 10.0 -* -* var im = imagf( v ); -* // returns 11.0 -*/ -function setComplex64( arr, idx, value ) { - arr.set( value, idx ); -} - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @private -* @param {Collection} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {(Collection|Complex|ComplexArray)} value - value(s) -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return arr[ idx ]; -* } -* -* function set( value, idx ) { -* arr[ idx ] = value; -* } -* -* arr.get = get; -* arr.set = set; -* -* setArrayLike( arr, 2, 10 ); -* -* var v = arr[ 2 ]; -* // returns 10 -*/ -function setArrayLike( arr, idx, value ) { - arr.set( value, idx ); -} - - -// MAIN // - -/** -* Returns an accessor function for setting an element in an array-like object supporting the get/set protocol. -* -* @param {string} dtype - array dtype -* @returns {Function} accessor -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var dtype = require( '@stdlib/array/dtype' ); -* -* var arr = new Complex64Array( [ 1, 2, 3, 4 ] ); -* -* var set = setter( dtype( arr ) ); -* set( arr, 1, new Complex64( 10.0, 11.0 ) ); -* -* var v = arr.get( 1 ); -* // returns -* -* var re = realf( v ); -* // returns 10.0 -* -* var im = imagf( v ); -* // returns 11.0 -*/ -function setter( dtype ) { - var f = SETTERS[ dtype ]; - if ( typeof f === 'function' ) { - return f; - } - return SETTERS.default; -} - - -// EXPORTS // - -module.exports = setter; diff --git a/base/accessor-setter/package.json b/base/accessor-setter/package.json deleted file mode 100644 index 78f3b52e8..000000000 --- a/base/accessor-setter/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/accessor-setter", - "version": "0.0.0", - "description": "Return an accessor function for setting an element in an array-like object supporting the get/set protocol.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "array", - "generic", - "set", - "accessor", - "access", - "retrieve", - "setter" - ] -} diff --git a/base/accessor-setter/test/test.js b/base/accessor-setter/test/test.js deleted file mode 100644 index 12d99a068..000000000 --- a/base/accessor-setter/test/test.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var zeroTo = require( './../../../base/zero-to' ); -var setter = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns an accessor array-like object. -* -* @private -* @returns {ArrayLikeObject} array-like object -*/ -function accessorArray() { - var arr = [ 1, 2, 3, 4 ]; - arr.set = set; - arr.get = get; - return arr; - - /** - * Returns an array element. - * - * @private - * @param {NonNegativeInteger} idx - index - * @returns {number} element - */ - function get( idx ) { - return arr[ idx ]; - } - - /** - * Sets an array element. - * - * @private - * @param {number} value - value to set - * @param {NonNegativeInteger} idx - index - */ - function set( value, idx ) { - arr[ idx ] = value; - } -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof setter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function for setting an array element', function test( t ) { - var arr; - var set; - var v; - - set = setter( 'complex128' ); - arr = new Complex128Array( zeroTo( 10 ) ); - set( arr, 2, new Complex128( 100.0, 101.0 ) ); - v = arr.get( 2 ); - t.strictEqual( real( v ), 100.0, 'returns expected value' ); - t.strictEqual( imag( v ), 101.0, 'returns expected value' ); - - set = setter( 'complex64' ); - arr = new Complex64Array( zeroTo( 10 ) ); - set( arr, 2, new Complex64( 102.0, 103.0 ) ); - v = arr.get( 2 ); - t.strictEqual( realf( v ), 102.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 103.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function for setting an array element (unrecognized dtype)', function test( t ) { - var arr; - var set; - var v; - - set = setter( 'foo' ); - arr = accessorArray(); - set( arr, 2, 105 ); - v = arr.get( 2 ); - t.strictEqual( v, 105, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (unrecognized dtype)', function test( t ) { - var arr; - var set; - var v; - - set = setter( 'foo' ); - arr = accessorArray(); - set( arr, 20, 10 ); - v = arr.get( 20 ); - t.strictEqual( v, 10, 'returns expected value' ); - - t.end(); -}); diff --git a/base/accessor/README.md b/base/accessor/README.md deleted file mode 100644 index d42557ef7..000000000 --- a/base/accessor/README.md +++ /dev/null @@ -1,226 +0,0 @@ - - -# AccessorArray - -> Create a minimal array-like object supporting the accessor protocol from another array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var AccessorArray = require( '@stdlib/array/base/accessor' ); -``` - - - -#### AccessorArray( arr ) - -Creates a minimal array-like object supporting the accessor protocol from another array-like object. - -```javascript -var arr = new AccessorArray( [ 1, 2, 3 ] ); -// returns -``` - -* * * - -### Properties - - - -#### AccessorArray.prototype.length - -Number of array elements. - -```javascript -var arr = new AccessorArray( [ 1, 2, 3 ] ); -// returns - -var len = arr.length; -// returns 3 -``` - -* * * - -### Methods - - - -#### AccessorArray.prototype.get( i ) - -Returns an array element located at position (index) `i`. - -```javascript -var arr = new AccessorArray( [ 1, 2, 3 ] ); - -// Get the first element: -var v = arr.get( 0 ); -// returns 1 -``` - - - -#### AccessorArray.prototype.set( v\[, i] ) - -Sets an array element. - -```javascript -var arr = new AccessorArray( [ 1, 2, 3 ] ); - -// Get the first element: -var v = arr.get( 0 ); -// returns 1 - -// Set the first element: -arr.set( 5 ); - -// Get the first element: -v = arr.get( 0 ); -// returns 5 -``` - -By default, the method sets array elements starting at position (index) `i = 0`. To set elements starting elsewhere in the array, provide an index argument `i`. - -```javascript -var arr = new AccessorArray( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] ); - -// Get the fifth element: -var v = arr.get( 4 ); -// returns 5 - -// Set the fifth element: -arr.set( 11, 4 ); - -// Get the fifth element: -v = arr.get( 4 ); -// returns 11 -``` - -
- - - - - -
- -
- - - - - -
- -* * * - -## Examples - - - - - -```javascript -var AccessorArray = require( '@stdlib/array/base/accessor' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/accessor/benchmark/benchmark.js b/base/accessor/benchmark/benchmark.js deleted file mode 100644 index a606d287f..000000000 --- a/base/accessor/benchmark/benchmark.js +++ /dev/null @@ -1,126 +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 bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../../float64' ); -var randu = require( '@stdlib/random/base/randu' ); -var pkg = require( './../package.json' ).name; -var AccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = new AccessorArray( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !(o instanceof AccessorArray) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':length', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.length; // note: this benchmark may be optimized away - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var arr; - var o; - var v; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - v = o.get( i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':set', function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - o = new AccessorArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o.set( i, i%arr.length ); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/accessor/docs/repl.txt b/base/accessor/docs/repl.txt deleted file mode 100644 index 9a075854c..000000000 --- a/base/accessor/docs/repl.txt +++ /dev/null @@ -1,86 +0,0 @@ - -{{alias}}( arr ) - Creates a minimal array-like object supporting the accessor protocol from - another array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - -{{alias}}.prototype.length - Read/write accessor for getting and setting the number of elements. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var len = out.length - 4 - - -{{alias}}.prototype.get( i ) - Returns an array element. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - v: any - Array element. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - - -{{alias}}.prototype.set( v[, i] ) - Sets an array element. - - Parameters - ---------- - v: any - Value to set. - - i: integer (optional) - Element index. Default: 0. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/base/accessor/docs/types/index.d.ts b/base/accessor/docs/types/index.d.ts deleted file mode 100644 index 71b73be30..000000000 --- a/base/accessor/docs/types/index.d.ts +++ /dev/null @@ -1,145 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Class for creating a minimal array-like object supporting the accessor protocol from another array-like object. -*/ -declare class AccessorArray implements AccessorArrayLike { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - constructor( arr: ArrayLike ); - - /** - * Number of array elements. - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - get( i: number ): T; - - /** - * Sets an array element. - * - * @param value - value - * @param i - element index at which to start writing values (default: 0) - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * arr.set( 5, 0 ); - * - * v = arr.get( 0 ); - * // returns 5 - */ - set( value: T, i?: number ): void; -} - -/** -* Interface defining an accessor array constructor which is both "newable" and "callable". -*/ -interface AccessorArrayConstructor { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - new ( arr: ArrayLike ): AccessorArray; - - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - ( arr: ArrayLike ): AccessorArray; -} - -/** -* Accessor array constructor. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -declare var ctor: AccessorArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/base/accessor/docs/types/test.ts b/base/accessor/docs/types/test.ts deleted file mode 100644 index b3cf22bbc..000000000 --- a/base/accessor/docs/types/test.ts +++ /dev/null @@ -1,131 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import AccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray - - new AccessorArray( arr ); // $ExpectType AccessorArray - AccessorArray( arr ); // $ExpectType AccessorArray -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - new AccessorArray( 123 ); // $ExpectError - new AccessorArray( true ); // $ExpectError - new AccessorArray( false ); // $ExpectError - new AccessorArray( null ); // $ExpectError - new AccessorArray( {} ); // $ExpectError - - AccessorArray( 123 ); // $ExpectError - AccessorArray( true ); // $ExpectError - AccessorArray( false ); // $ExpectError - AccessorArray( null ); // $ExpectError - AccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - new AccessorArray(); // $ExpectError - new AccessorArray( x, 5 ); // $ExpectError - - AccessorArray(); // $ExpectError - AccessorArray( x, 5 ); // $ExpectError -} - -// The function returns an accessor array which has a `length` property... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.length; // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.length; // $ExpectType number -} - -// The function returns an accessor array which has a `get` method for accessing array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.get( 0 ); // $ExpectType number - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.get( 0 ); // $ExpectType any -} - -// The compiler throws an error if the `get` method is not provided a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.get( '123' ); // $ExpectError - o.get( true ); // $ExpectError - o.get( false ); // $ExpectError - o.get( null ); // $ExpectError - o.get( [] ); // $ExpectError - o.get( {} ); // $ExpectError -} - -// The function returns an accessor array which has a `set` method for setting array elements... -{ - const arr1 = [ 1, 2, 3 ]; - const o1 = new AccessorArray( arr1 ); // $ExpectType AccessorArray - o1.set( 0 ); // $ExpectType void - o1.set( 0, 1 ); // $ExpectType void - - const arr2 = [ 1, '2', true ]; - const o2 = AccessorArray( arr2 ); // $ExpectType AccessorArray - o2.set( 0 ); // $ExpectType void - o2.set( 0, 1 ); // $ExpectType void -} - -// The compiler throws an error if the `set` method is provided any invalid first argument... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( '123' ); // $ExpectError - o.set( true ); // $ExpectError - o.set( false ); // $ExpectError - o.set( null ); // $ExpectError - o.set( {} ); // $ExpectError -} - -// The compiler throws an error if the `set` method is not provided a second argument which is a number... -{ - const o = new AccessorArray( [ 1, 2, 3 ] ); - - o.set( 0, '123' ); // $ExpectError - o.set( 0, true ); // $ExpectError - o.set( 0, false ); // $ExpectError - o.set( 0, null ); // $ExpectError - o.set( 0, [] ); // $ExpectError - o.set( 0, {} ); // $ExpectError -} diff --git a/base/accessor/examples/index.js b/base/accessor/examples/index.js deleted file mode 100644 index bc8d0bb57..000000000 --- a/base/accessor/examples/index.js +++ /dev/null @@ -1,67 +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. -*/ - -/* eslint-disable no-restricted-syntax */ - -'use strict'; - -var AccessorArray = require( './../lib' ); - -// Define a class for creating a minimal sparse array-like object... -function SparseArray( len, values ) { - this.length = len; - this._data = values; - return this; -} - -SparseArray.prototype.get = function get( i ) { - var v = this._data[ i ]; - if ( v === void 0 ) { - return 0; - } - return v; -}; - -SparseArray.prototype.set = function set( v, i ) { - this._data[ i ] = v; -}; - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %d', name, i, x.get( i ) ); - } -} - -// Create a sparse array-like object: -var sparse = new SparseArray( 10, { - '2': 1, - '3': 2, - '8': 3 -}); - -// Create a dense array: -var arr = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Convert the dense array to an accessor array to allow for uniform iteration: -var dense = new AccessorArray( arr ); - -// Print the contents of each array... -printArray( 'sparse', sparse ); -printArray( 'dense', dense ); diff --git a/base/accessor/lib/index.js b/base/accessor/lib/index.js deleted file mode 100644 index 4b73d45fc..000000000 --- a/base/accessor/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Create a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @module @stdlib/array/base/accessor -* -* @example -* var AccessorArray = require( '@stdlib/array/base/accessor' ); -* -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/accessor/lib/main.js b/base/accessor/lib/main.js deleted file mode 100644 index dddb878bb..000000000 --- a/base/accessor/lib/main.js +++ /dev/null @@ -1,164 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadWriteAccessor = require( '@stdlib/utils/define-nonenumerable-read-write-accessor' ); -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var accessors = require( './../../../base/accessors' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var format = require( '@stdlib/string/format' ); - - -// FUNCTIONS // - -/** -* Sets the length of an array-like object. -* -* @private -* @param {NonNegativeInteger} len - length -*/ -function setLength( len ) { - this._buffer.length = len; -} - -/** -* Returns the length of an array-like object. -* -* @private -* @returns {NonNegativeInteger} length -*/ -function getLength() { - return this._buffer.length; -} - - -// MAIN // - -/** -* Creates a minimal array-like object supporting the accessor protocol from another array-like object. -* -* @constructor -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {AccessorArray} accessor array instance -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -function AccessorArray( arr ) { - var o; - if ( !(this instanceof AccessorArray) ) { - return new AccessorArray( arr ); - } - if ( !isCollection( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); - } - o = accessors( arr ); - this._buffer = arr; - this._getter = o.accessors[ 0 ]; - this._setter = o.accessors[ 1 ]; - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof AccessorArray -* @readonly -* @type {string} -* @default 'AccessorArray' -* -* @example -* var name = AccessorArray.name; -* // returns 'AccessorArray' -*/ -setReadOnly( AccessorArray, 'name', 'AccessorArray' ); - -/** -* Read/write accessor for getting/setting the number of elements. -* -* @name length -* @memberof AccessorArray.prototype -* @type {NonNegativeInteger} -*/ -setReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength ); - -/** -* Returns an element. -* -* @name get -* @memberof AccessorArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @returns {*} element -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -*/ -setReadOnly( AccessorArray.prototype, 'get', function get( idx ) { - return this._getter( this._buffer, idx ); -}); - -/** -* Sets one or more elements. -* -* @name set -* @memberof AccessorArray.prototype -* @type {Function} -* @param {*} value - value to set -* @param {integer} [idx] - element index -* @returns {void} -* -* @example -* var arr = new AccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* arr.set( 5, 0 ); -* -* v = arr.get( 0 ); -* // returns 5 -*/ -setReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) { - if ( arguments.length < 2 ) { - this._setter( this._buffer, 0, value ); - return; - } - this._setter( this._buffer, idx, value ); -}); - - -// EXPORTS // - -module.exports = AccessorArray; diff --git a/base/accessor/package.json b/base/accessor/package.json deleted file mode 100644 index d64c804d5..000000000 --- a/base/accessor/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/accessor", - "version": "0.0.0", - "description": "Create a minimal array-like object supporting the accessor protocol from another array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "array-like", - "object", - "accessor", - "accessors", - "protocol" - ] -} diff --git a/base/accessor/test/test.get.js b/base/accessor/test/test.get.js deleted file mode 100644 index b2b72e101..000000000 --- a/base/accessor/test/test.get.js +++ /dev/null @@ -1,54 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var i; - - arr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - arr = new AccessorArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr.get( i ), i+1, 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/base/accessor/test/test.js b/base/accessor/test/test.js deleted file mode 100644 index 46229f306..000000000 --- a/base/accessor/test/test.js +++ /dev/null @@ -1,99 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = AccessorArray; - - arr = ctor( [ 1, 2, 3 ] ); - t.strictEqual( arr instanceof AccessorArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( isAccessorArray( arr ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray, 'name' ), true, 'has property' ); - t.strictEqual( AccessorArray.name, 'AccessorArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr = new AccessorArray( [ 1, 2, 3 ] ); - t.strictEqual( arr.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new AccessorArray( value ); - }; - } -}); diff --git a/base/accessor/test/test.set.js b/base/accessor/test/test.set.js deleted file mode 100644 index af3b77ed1..000000000 --- a/base/accessor/test/test.set.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var AccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof AccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( AccessorArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( AccessorArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new AccessorArray( [ 1, 2, 3, 4, 5 ] ); - t.strictEqual( arr.get( 0 ), 1, 'returns expected value' ); - - // No index argument: - arr.set( 6 ); - t.strictEqual( arr.get( 0 ), 6, 'returns expected value' ); - - // Reset the value: - arr.set( 1 ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, i+1, 'returns expected value' ); - - arr.set( i+10, i ); - - v = arr.get( i ); - t.strictEqual( v, i+10, 'returns expected value' ); - } - t.end(); -}); diff --git a/base/accessors/README.md b/base/accessors/README.md deleted file mode 100644 index 4c48495ab..000000000 --- a/base/accessors/README.md +++ /dev/null @@ -1,149 +0,0 @@ - - -# accessors - -> Return element accessors for a provided array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var accessors = require( '@stdlib/array/base/accessors' ); -``` - -#### accessors( x ) - -Returns element accessors for a provided array-like object. - -```javascript -var obj = accessors( [ 1, 2, 3, 4 ] ); -// returns {...} - -var bool = obj.accessorProtocol; -// returns false - -var fcns = obj.accessors; -// returns [ , ] -``` - -
- - - - - -
- -## Notes - -- The returned object has the following properties: - - - **accessorProtocol**: `boolean` indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - - **accessors**: a two-element array whose first element is an accessor for retrieving an array element (i.e., a getter) and whose second element is an accessor for setting an array element (i.e., a setter). - -- The getter accessor accepts two arguments: - - - **arr**: array-like object. - - **idx**: element index. - -- The setter accessor accepts three arguments: - - - **arr**: array-like object. - - **idx**: element index. - - **value**: value to set. - -- The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element access via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. - -
- - - - - -
- -## Examples - - - -```javascript -var Complex64Array = require( '@stdlib/array/complex64' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var accessors = require( '@stdlib/array/base/accessors' ); - -// Create an array: -var x = new Complex64Array( zeroTo( 10 ) ); - -// Get accessor functions for retrieving array elements: -var obj = accessors( x ); -// returns {...} - -// Check whether the array supports the accessor protocol: -var bool = obj.accessorProtocol; -// returns true - -console.log( 'Accessor protocol: %s', bool ); - -// Retrieve an array element: -var v = obj.accessors[ 0 ]( x, 1 ); -// returns - -console.log( 'x[1] = %s', v.toString() ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/accessors/benchmark/benchmark.js b/base/accessors/benchmark/benchmark.js deleted file mode 100644 index 096d5350a..000000000 --- a/base/accessors/benchmark/benchmark.js +++ /dev/null @@ -1,133 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../../float64' ); -var Complex128Array = require( './../../../complex128' ); -var zeros = require( './../../../base/zeros' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var pkg = require( './../package.json' ).name; -var accessors = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = accessors( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real_typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = accessors( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex_typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Complex128Array( 10 ), - new Complex128Array( 10 ), - new Complex128Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = accessors( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = accessors( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/accessors/docs/repl.txt b/base/accessors/docs/repl.txt deleted file mode 100644 index 44b95aa8a..000000000 --- a/base/accessors/docs/repl.txt +++ /dev/null @@ -1,56 +0,0 @@ - -{{alias}}( x ) - Returns element accessors for a provided array-like object. - - The returned object has the following properties: - - - accessorProtocol: indicating whether the provided array-like object - supports the get/set protocol (i.e., uses accessors for getting and - setting elements). - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - The intent of this function is to provide a minimal abstraction over how - elements are accessed when operating on indexed (i.e., array-like objects - supporting element accesss via integer indices using bracket `[]` syntax) - and accessor (i.e., array-like objects supporting the get/set protocol in - which explicit `get` and `set` methods are used for element access) array- - like objects. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing accessor data. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ) - {...} - > var bool = out.accessorProtocol - false - > var fcns = out.accessors - [ , ] - > fcns[ 0 ]( x, 1 ) - 2 - - See Also - -------- - diff --git a/base/accessors/docs/types/index.d.ts b/base/accessors/docs/types/index.d.ts deleted file mode 100644 index 545692f4f..000000000 --- a/base/accessors/docs/types/index.d.ts +++ /dev/null @@ -1,895 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Returns element accessors for a provided `Float64Array`. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: Float64Array ): Float64AccessorObject; - -/** -* Returns element accessors for a provided `Float32Array`. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: Float32Array ): Float32AccessorObject; - -/** -* Returns element accessors for a provided `Int32Array`. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: Int32Array ): Int32AccessorObject; - -/** -* Returns element accessors for a provided `Int16Array`. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: Int16Array ): Int16AccessorObject; - -/** -* Returns element accessors for a provided `Int8Array`. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: Int8Array ): Int8AccessorObject; - -/** -* Returns element accessors for a provided `Uint32Array`. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: Uint32Array ): Uint32AccessorObject; - -/** -* Returns element accessors for a provided `Uint16Array`. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: Uint16Array ): Uint16AccessorObject; - -/** -* Returns element accessors for a provided `Uint8Array`. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: Uint8Array ): Uint8AccessorObject; - -/** -* Returns element accessors for a provided `Uint8ClampedArray`. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Returns element accessors for a provided `Complex128Array`. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function accessors( x: Complex128Array ): Complex128AccessorObject; - -/** -* Returns element accessors for a provided `Complex64Array`. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function accessors( x: Complex64Array ): Complex64AccessorObject; - -/** -* Returns element accessors for a provided array-like object supporting the get/set protocol. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Returns element accessors for a provided "generic" array. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: Array ): GenericAccessorObject; - -/** -* Returns element accessors for a provided array-like object. -* -* ## Notes -* -* - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. -* -* @param x - input array -* @returns object containing accessor data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 -* }; -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -declare function accessors( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = accessors; diff --git a/base/accessors/docs/types/test.ts b/base/accessors/docs/types/test.ts deleted file mode 100644 index 39f21bacc..000000000 --- a/base/accessors/docs/types/test.ts +++ /dev/null @@ -1,126 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import accessors = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @returns array-like object -*/ -function accessorArray(): AccessorArrayLike { - const arr: AccessorArrayLike = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @returns array-like object -*/ -function arrayLike(): ArrayLike { - const arr: ArrayLike = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an accessor object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - accessors( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - accessors( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - accessors( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - accessors( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - accessors( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - accessors( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - accessors( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - accessors( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - accessors( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - accessors( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - accessors( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - accessors( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - accessors( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - accessors( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - accessors( 123 ); // $ExpectError - accessors( true ); // $ExpectError - accessors( false ); // $ExpectError - accessors( null ); // $ExpectError - accessors( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - accessors(); // $ExpectError - accessors( x, 5 ); // $ExpectError -} diff --git a/base/accessors/examples/index.js b/base/accessors/examples/index.js deleted file mode 100644 index db97a7ea5..000000000 --- a/base/accessors/examples/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( './../../../complex64' ); -var zeroTo = require( './../../../base/zero-to' ); -var accessors = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( zeroTo( 10 ) ); - -// Get accessor functions for retrieving array elements: -var obj = accessors( x ); -// returns {...} - -// Check whether the array supports the accessor protocol: -var bool = obj.accessorProtocol; -// returns true - -console.log( 'Accessor protocol: %s', bool ); - -// Retrieve an array element: -var v = obj.accessors[ 0 ]( x, 1 ); -// returns - -console.log( 'x[1] = %s', v.toString() ); diff --git a/base/accessors/lib/index.js b/base/accessors/lib/index.js deleted file mode 100644 index e067f2853..000000000 --- a/base/accessors/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return element accessors for a provided array-like object. -* -* @module @stdlib/array/base/accessors -* -* @example -* var accessors = require( '@stdlib/array/base/accessors' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/accessors/lib/main.js b/base/accessors/lib/main.js deleted file mode 100644 index 16e81ec1d..000000000 --- a/base/accessors/lib/main.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var getter = require( './../../../base/getter' ); -var setter = require( './../../../base/setter' ); -var accessorGetter = require( './../../../base/accessor-getter' ); -var accessorSetter = require( './../../../base/accessor-setter' ); -var dtype = require( './../../../dtype' ); - - -// MAIN // - -/** -* Returns element accessors for a provided array-like object. -* -* ## Notes -* -* - The returned object has the following properties: -* -* - **accessorProtocol**: `boolean` indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing accessor data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = accessors( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 2 ); -* // returns 3 -*/ -function accessors( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = accessors; diff --git a/base/accessors/package.json b/base/accessors/package.json deleted file mode 100644 index ae56ef497..000000000 --- a/base/accessors/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/array/base/accessors", - "version": "0.0.0", - "description": "Return element accessors for a provided array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "standardize", - "accessors", - "accessor", - "getter", - "setter", - "get", - "set", - "protocol", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/base/accessors/test/test.js b/base/accessors/test/test.js deleted file mode 100644 index fa08e947b..000000000 --- a/base/accessors/test/test.js +++ /dev/null @@ -1,150 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../../float64' ); -var Complex64Array = require( './../../../complex64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var getter = require( './../../../base/getter' ); -var setter = require( './../../../base/setter' ); -var accessorGetter = require( './../../../base/accessor-getter' ); -var accessorSetter = require( './../../../base/accessor-setter' ); -var dtype = require( './../../../dtype' ); -var accessors = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof accessors, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an accessor object (generic array)', function test( t ) { - var expected; - var actual; - var dt; - var x; - var v; - - x = [ 0, 0, 0, 0, 0, 0 ]; - dt = dtype( x ); - - expected = { - 'accessorProtocol': false, - 'accessors': [ getter( dt ), setter( dt ) ] - }; - actual = accessors( x ); - - t.strictEqual( actual.accessors.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual.accessors[ 1 ]( x, 0, 1 ); - v = actual.accessors[ 0 ]( x, 0 ); - t.strictEqual( v, 1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an accessor object (typed array)', function test( t ) { - var expected; - var actual; - var dt; - var x; - var v; - - x = new Float64Array( 10 ); - dt = dtype( x ); - - expected = { - 'accessorProtocol': false, - 'accessors': [ getter( dt ), setter( dt ) ] - }; - actual = accessors( x ); - - t.strictEqual( actual.accessors.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual.accessors[ 1 ]( x, 0, 1.0 ); - v = actual.accessors[ 0 ]( x, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an accessor object (complex typed array)', function test( t ) { - var expected; - var actual; - var dt; - var x; - var v; - - x = new Complex64Array( 10 ); - dt = dtype( x ); - - expected = { - 'accessorProtocol': true, - 'accessors': [ accessorGetter( dt ), accessorSetter( dt ) ] - }; - actual = accessors( x ); - - t.strictEqual( actual.accessors.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual.accessors[ 1 ]( x, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( x, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an accessor object (array-like object)', function test( t ) { - var expected; - var actual; - var dt; - var x; - var v; - - x = { - 'length': 10 - }; - dt = dtype( x ); - - expected = { - 'accessorProtocol': false, - 'accessors': [ getter( dt ), setter( dt ) ] - }; - actual = accessors( x ); - - t.strictEqual( actual.accessors.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual.accessors[ 1 ]( x, 0, 1 ); - v = actual.accessors[ 0 ]( x, 0 ); - t.strictEqual( v, 1, 'returns expected value' ); - - t.end(); -}); diff --git a/base/any-by-right/README.md b/base/any-by-right/README.md deleted file mode 100644 index fbf87377c..000000000 --- a/base/any-by-right/README.md +++ /dev/null @@ -1,166 +0,0 @@ - - -# anyByRight - -> Test whether at least one element in an array passes a test implemented by a predicate function, while iterating from right to left. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var anyByRight = require( '@stdlib/array/base/any-by-right' ); -``` - -#### anyByRight( x, predicate\[, thisArg] ) - -Tests whether at least one element in an array passes a test implemented by a `predicate` function, while iterating from right to left. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 0, 0, 1, 0 ]; - -var bool = anyByRight( x, isPositive ); -// returns true -``` - -If a `predicate` function returns a truthy value, the function **immediately** returns `false`. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ -1, -2, -3, -4 ]; - -var bool = anyByRight( x, isPositive ); -// returns false -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( value ) { - this.count += 1; - return ( value > 0 ); -} - -var x = [ -1, -2, 3, -4 ]; - -var context = { - 'count': 0 -}; - -var bool = anyByRight( x, predicate, context ); -// returns true - -var cnt = context.count; -// returns 2 -``` - -
- - - - - -
- -## Notes - -- The function performs a linear scan and returns immediately upon encountering a truthy return value. Unlike [`Array.prototype.some`][mdn-array-some], when performing a linear scan, the function does **not** skip `undefined` elements. -- If provided an empty array, the function returns `false`. - -
- - - - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var anyByRight = require( '@stdlib/array/base/any-by-right' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = anyByRight( x, naryFunction( isPositiveInteger, 1 ) ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/any-by-right/benchmark/benchmark.length.js b/base/any-by-right/benchmark/benchmark.length.js deleted file mode 100644 index f0673819b..000000000 --- a/base/any-by-right/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var anyByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = anyByRight( x, isPositiveInteger ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/any-by-right/docs/repl.txt b/base/any-by-right/docs/repl.txt deleted file mode 100644 index 1bcb41bd1..000000000 --- a/base/any-by-right/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Tests whether at least one element in an array passes a test implemented by - a predicate function, while iterating from right to left. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - The function performs a linear scan and returns immediately upon - encountering a truthy return value. - - If provided an empty array, the function returns `false`. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - bool: boolean - The function returns `true` if the predicate function returns a truthy - value for at least one element; otherwise, the function returns `false`. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 1, 0 ]; - > var out = {{alias}}( x, f ) - true - - See Also - -------- - diff --git a/base/any-by-right/docs/types/index.d.ts b/base/any-by-right/docs/types/index.d.ts deleted file mode 100644 index 3cf70f161..000000000 --- a/base/any-by-right/docs/types/index.d.ts +++ /dev/null @@ -1,97 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function, while iterating from right to left. -* -* ## Notes -* -* - The function immediately returns upon encountering a truthy return value. -* - If provided an empty collection, the function returns `false`. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns boolean indicating whether all elements pass a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 1, 0 ]; -* -* var out = anyByRight( x, isPositive ); -* // returns true -*/ -declare function anyByRight( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - -// EXPORTS // - -export = anyByRight; diff --git a/base/any-by-right/docs/types/test.ts b/base/any-by-right/docs/types/test.ts deleted file mode 100644 index d82341a98..000000000 --- a/base/any-by-right/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import anyByRight = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a boolean... -{ - anyByRight( [ 1, 2, 3 ], isPositive ); // $ExpectType boolean - anyByRight( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyByRight( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyByRight( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyByRight( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyByRight( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyByRight( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyByRight( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyByRight( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyByRight( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyByRight( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - - anyByRight( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType boolean - anyByRight( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyByRight( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyByRight( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyByRight( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyByRight( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyByRight( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyByRight( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyByRight( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyByRight( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyByRight( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - anyByRight( 2, isPositive ); // $ExpectError - anyByRight( false, isPositive ); // $ExpectError - anyByRight( true, isPositive ); // $ExpectError - anyByRight( {}, isPositive ); // $ExpectError - - anyByRight( 2, isPositive, {} ); // $ExpectError - anyByRight( false, isPositive, {} ); // $ExpectError - anyByRight( true, isPositive, {} ); // $ExpectError - anyByRight( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - anyByRight( [ 1, 2, 3 ], 'abc' ); // $ExpectError - anyByRight( [ 1, 2, 3 ], 2 ); // $ExpectError - anyByRight( [ 1, 2, 3 ], false ); // $ExpectError - anyByRight( [ 1, 2, 3 ], true ); // $ExpectError - anyByRight( [ 1, 2, 3 ], null ); // $ExpectError - anyByRight( [ 1, 2, 3 ], void 0 ); // $ExpectError - anyByRight( [ 1, 2, 3 ], {} ); // $ExpectError - anyByRight( [ 1, 2, 3 ], [] ); // $ExpectError - - anyByRight( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - anyByRight( [ 1, 2, 3 ], 2, {} ); // $ExpectError - anyByRight( [ 1, 2, 3 ], false, {} ); // $ExpectError - anyByRight( [ 1, 2, 3 ], true, {} ); // $ExpectError - anyByRight( [ 1, 2, 3 ], null, {} ); // $ExpectError - anyByRight( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - anyByRight( [ 1, 2, 3 ], {}, {} ); // $ExpectError - anyByRight( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - anyByRight(); // $ExpectError - anyByRight( [ 1, 2, 3 ] ); // $ExpectError - anyByRight( [ 1, 2, 3 ], isPositive, {}, 3 ); // $ExpectError -} diff --git a/base/any-by-right/examples/index.js b/base/any-by-right/examples/index.js deleted file mode 100644 index 4808215cb..000000000 --- a/base/any-by-right/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var anyByRight = require( './../lib' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = anyByRight( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/any-by-right/lib/index.js b/base/any-by-right/lib/index.js deleted file mode 100644 index ff5039aa0..000000000 --- a/base/any-by-right/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Test whether at least one element in an array passes a test implemented by a predicate function, while iterating from right to left. -* -* @module @stdlib/array/base/any-by-right -* -* @example -* var anyByRight = require( '@stdlib/array/base/any-by-right' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 1, 0 ]; -* -* var out = anyByRight( x, isPositive ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/any-by-right/lib/main.js b/base/any-by-right/lib/main.js deleted file mode 100644 index 2302c1bb7..000000000 --- a/base/any-by-right/lib/main.js +++ /dev/null @@ -1,127 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 1, 0 ]; -* -* var out = internal( x, isPositive ); -* // returns true -*/ -function internal( x, predicate, thisArg ) { - var i; - for ( i = x.length-1; i >= 0; i-- ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - return true; - } - } - return false; -} - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @private -* @param {Object} x - input array object -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* -* var out = accessors( x, isPositive ); -* // returns true -*/ -function accessors( x, predicate, thisArg ) { - var data; - var get; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - for ( i = data.length-1; i >= 0; i-- ) { - if ( predicate.call( thisArg, get( data, i ), i, data ) ) { - return true; - } - } - return false; -} - - -// MAIN // - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function, while iterating from right to left. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 1, 0 ]; -* -* var out = anyByRight( x, isPositive ); -* // returns true -*/ -function anyByRight( x, predicate, thisArg ) { - var obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, predicate, thisArg ); - } - return internal( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = anyByRight; diff --git a/base/any-by-right/package.json b/base/any-by-right/package.json deleted file mode 100644 index 08fb734ab..000000000 --- a/base/any-by-right/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/any-by-right", - "version": "0.0.0", - "description": "Test whether at least one element in an array passes a test implemented by a predicate function, while iterating from right to left.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "predicate", - "any", - "some", - "array.some", - "validate" - ] -} diff --git a/base/any-by-right/test/test.js b/base/any-by-right/test/test.js deleted file mode 100644 index 740ab68f7..000000000 --- a/base/any-by-right/test/test.js +++ /dev/null @@ -1,252 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var anyByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Tests whether a value is positive. -* -* @private -* @param {number} value - input value -* @returns {boolean} boolean indicating if a value is positive -*/ -function isPositive( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof anyByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `false` (generic)', function test( t ) { - var out; - var arr; - - arr = []; - out = anyByRight( arr, foo ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `false` (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [] ); - out = anyByRight( arr, foo ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `false` (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [] ); - out = anyByRight( arr, foo ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the function returns `true` if at least one element passes a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ -1, 2, 3 ]; - out = anyByRight( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element passes a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ -1.0, 2.0, -3.0 ] ); - out = anyByRight( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element passes a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 1, -2, 3 ] ); - out = anyByRight( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element passes a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': -1, - '1': -2, - '2': 3 - }; - out = anyByRight( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements fail a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ -1, -2, -3 ]; - out = anyByRight( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements fail a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ -1.0, -2.0, -3.0 ] ); - out = anyByRight( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements fail a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ -1, -2, -3 ] ); - out = anyByRight( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements fail a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': -1, - '1': -2, - '2': -3 - }; - out = anyByRight( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var out; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = [ -1, 2, -3 ]; - out = anyByRight( arr, predicate, ctx ); - - t.strictEqual( out, true, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (generic)', function test( t ) { - var expected; - var out; - var arr; - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = anyByRight( arr, predicate ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return false; - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (accessor)', function test( t ) { - var expected; - var out; - var arr; - - arr = new AccessorArray( [ 1, , , 4 ] ); // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = anyByRight( arr, predicate ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return false; - } -}); diff --git a/base/any-by/README.md b/base/any-by/README.md deleted file mode 100644 index eb2db5f67..000000000 --- a/base/any-by/README.md +++ /dev/null @@ -1,173 +0,0 @@ - - -# anyBy - -> Test whether at least one element in an array passes a test implemented by a predicate function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var anyBy = require( '@stdlib/array/base/any-by' ); -``` - -#### anyBy( x, predicate\[, thisArg] ) - -Tests whether at least one element in an array passes a test implemented by a `predicate` function. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 0, 0, 1, 0 ]; - -var bool = anyBy( x, isPositive ); -// returns true -``` - -If a `predicate` function returns a truthy value, the function **immediately** returns `false`. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ -1, -2, -3, -4 ]; - -var bool = anyBy( x, isPositive ); -// returns false -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( value ) { - this.count += 1; - return ( value > 0 ); -} - -var x = [ -1, -2, 3, -4 ]; - -var context = { - 'count': 0 -}; - -var bool = anyBy( x, predicate, context ); -// returns true - -var cnt = context.count; -// returns 3 -``` - -
- - - - - -
- -## Notes - -- If provided an array-like object having a `some` method (**as defined by the ECMAScript Standard**), the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.some( predicate, thisArg ) - ``` - -- If provided an array-like object without a `some` method, the function performs a linear scan and returns immediately upon encountering a truthy return value. Unlike [`Array.prototype.some`][mdn-array-some], when performing a linear scan, the function does **not** skip `undefined` elements. - -- If provided an empty array, the function returns `false`. - -
- - - - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var anyBy = require( '@stdlib/array/base/any-by' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = anyBy( x, naryFunction( isPositiveInteger, 1 ) ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/any-by/benchmark/benchmark.length.js b/base/any-by/benchmark/benchmark.length.js deleted file mode 100644 index d1830b1aa..000000000 --- a/base/any-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var anyBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = anyBy( x, isPositiveInteger ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/any-by/docs/repl.txt b/base/any-by/docs/repl.txt deleted file mode 100644 index 2afb39318..000000000 --- a/base/any-by/docs/repl.txt +++ /dev/null @@ -1,50 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Tests whether at least one element in an array passes a test implemented by - a predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - If provided an array-like object having a `some` method , the function - defers execution to that method and assumes that the method has the - following signature: - - x.some( predicate, thisArg ) - - If provided an array-like object without a `some` method, the function - performs a linear scan and returns immediately upon encountering a - truthy return value. - - If provided an empty array, the function returns `false`. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - bool: boolean - The function returns `true` if the predicate function returns a truthy - value for at least one element; otherwise, the function returns `false`. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 1, 0 ]; - > var out = {{alias}}( x, f ) - true - - See Also - -------- - diff --git a/base/any-by/docs/types/index.d.ts b/base/any-by/docs/types/index.d.ts deleted file mode 100644 index 942ce7f9e..000000000 --- a/base/any-by/docs/types/index.d.ts +++ /dev/null @@ -1,97 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* ## Notes -* -* - The function immediately returns upon encountering a truthy return value. -* - If provided an empty collection, the function returns `false`. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns boolean indicating whether all elements pass a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 1, 0 ]; -* -* var out = anyBy( x, isPositive ); -* // returns true -*/ -declare function anyBy( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - -// EXPORTS // - -export = anyBy; diff --git a/base/any-by/docs/types/test.ts b/base/any-by/docs/types/test.ts deleted file mode 100644 index a8c758d29..000000000 --- a/base/any-by/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import anyBy = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a boolean... -{ - anyBy( [ 1, 2, 3 ], isPositive ); // $ExpectType boolean - anyBy( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyBy( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyBy( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyBy( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyBy( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyBy( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyBy( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyBy( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyBy( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - anyBy( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - - anyBy( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType boolean - anyBy( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyBy( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyBy( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyBy( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyBy( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyBy( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyBy( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyBy( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyBy( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - anyBy( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - anyBy( 2, isPositive ); // $ExpectError - anyBy( false, isPositive ); // $ExpectError - anyBy( true, isPositive ); // $ExpectError - anyBy( {}, isPositive ); // $ExpectError - - anyBy( 2, isPositive, {} ); // $ExpectError - anyBy( false, isPositive, {} ); // $ExpectError - anyBy( true, isPositive, {} ); // $ExpectError - anyBy( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - anyBy( [ 1, 2, 3 ], 'abc' ); // $ExpectError - anyBy( [ 1, 2, 3 ], 2 ); // $ExpectError - anyBy( [ 1, 2, 3 ], false ); // $ExpectError - anyBy( [ 1, 2, 3 ], true ); // $ExpectError - anyBy( [ 1, 2, 3 ], null ); // $ExpectError - anyBy( [ 1, 2, 3 ], void 0 ); // $ExpectError - anyBy( [ 1, 2, 3 ], {} ); // $ExpectError - anyBy( [ 1, 2, 3 ], [] ); // $ExpectError - - anyBy( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - anyBy( [ 1, 2, 3 ], 2, {} ); // $ExpectError - anyBy( [ 1, 2, 3 ], false, {} ); // $ExpectError - anyBy( [ 1, 2, 3 ], true, {} ); // $ExpectError - anyBy( [ 1, 2, 3 ], null, {} ); // $ExpectError - anyBy( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - anyBy( [ 1, 2, 3 ], {}, {} ); // $ExpectError - anyBy( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - anyBy(); // $ExpectError - anyBy( [ 1, 2, 3 ] ); // $ExpectError - anyBy( [ 1, 2, 3 ], isPositive, {}, 3 ); // $ExpectError -} diff --git a/base/any-by/examples/index.js b/base/any-by/examples/index.js deleted file mode 100644 index 7390e4f1b..000000000 --- a/base/any-by/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var anyBy = require( './../lib' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = anyBy( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/any-by/lib/index.js b/base/any-by/lib/index.js deleted file mode 100644 index d563a850f..000000000 --- a/base/any-by/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Test whether at least one element in an array passes a test implemented by a predicate function. -* -* @module @stdlib/array/base/any-by -* -* @example -* var anyBy = require( '@stdlib/array/base/any-by' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 1, 0 ]; -* -* var out = anyBy( x, isPositive ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/any-by/lib/main.js b/base/any-by/lib/main.js deleted file mode 100644 index 2b60519be..000000000 --- a/base/any-by/lib/main.js +++ /dev/null @@ -1,151 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'some' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 1, 0 ]; -* -* var out = internal( x, isPositive ); -* // returns true -*/ -function internal( x, predicate, thisArg ) { - var i; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - return true; - } - } - return false; -} - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @private -* @param {Object} x - input array object -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* -* var out = accessors( x, isPositive ); -* // returns true -*/ -function accessors( x, predicate, thisArg ) { - var data; - var get; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - for ( i = 0; i < data.length; i++ ) { - if ( predicate.call( thisArg, get( data, i ), i, data ) ) { - return true; - } - } - return false; -} - - -// MAIN // - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 1, 0 ]; -* -* var out = anyBy( x, isPositive ); -* // returns true -*/ -function anyBy( x, predicate, thisArg ) { - var obj; - if ( hasMethod( x, 'some' ) ) { - return x.some( predicate, thisArg ); - } - obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, predicate, thisArg ); - } - return internal( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = anyBy; diff --git a/base/any-by/package.json b/base/any-by/package.json deleted file mode 100644 index afe6e78e1..000000000 --- a/base/any-by/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/any-by", - "version": "0.0.0", - "description": "Test whether at least one element in an array passes a test implemented by a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "predicate", - "any", - "some", - "array.some", - "validate" - ] -} diff --git a/base/any-by/test/test.js b/base/any-by/test/test.js deleted file mode 100644 index 5541ab6ed..000000000 --- a/base/any-by/test/test.js +++ /dev/null @@ -1,252 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var anyBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Tests whether a value is positive. -* -* @private -* @param {number} value - input value -* @returns {boolean} boolean indicating if a value is positive -*/ -function isPositive( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof anyBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `false` (generic)', function test( t ) { - var out; - var arr; - - arr = []; - out = anyBy( arr, foo ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `false` (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [] ); - out = anyBy( arr, foo ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `false` (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [] ); - out = anyBy( arr, foo ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the function returns `true` if at least one element passes a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ -1, 2, 3 ]; - out = anyBy( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element passes a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ -1.0, 2.0, -3.0 ] ); - out = anyBy( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element passes a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 1, -2, 3 ] ); - out = anyBy( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element passes a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': -1, - '1': -2, - '2': 3 - }; - out = anyBy( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements fail a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ -1, -2, -3 ]; - out = anyBy( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements fail a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ -1.0, -2.0, -3.0 ] ); - out = anyBy( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements fail a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ -1, -2, -3 ] ); - out = anyBy( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements fail a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': -1, - '1': -2, - '2': -3 - }; - out = anyBy( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var out; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = [ -1, -2, -3 ]; - out = anyBy( arr, predicate, ctx ); - - t.strictEqual( out, false, 'returns expected value' ); - t.strictEqual( ctx.count, arr.length, 'returns expected value' ); - - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (generic)', function test( t ) { - var expected; - var out; - var arr; - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = anyBy( arr, predicate ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return false; - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (accessor)', function test( t ) { - var expected; - var out; - var arr; - - arr = new AccessorArray( [ 1, , , 4 ] ); // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = anyBy( arr, predicate ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return false; - } -}); diff --git a/base/any-has-own-property/README.md b/base/any-has-own-property/README.md deleted file mode 100644 index 7dca3581f..000000000 --- a/base/any-has-own-property/README.md +++ /dev/null @@ -1,136 +0,0 @@ - - -# anyHasOwnProp - -> Test whether at least one element in a provided array has a specified own property. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var anyHasOwnProp = require( '@stdlib/array/base/any-has-own-property' ); -``` - -#### anyHasOwnProp( arr, property ) - -Tests whether at least one element in a provided array has a specified own property. - -```javascript -var o1 = { - 'a': 1 -}; -var o2 = { - 'b': 2 -}; -var o3 = { - 'c': 3 -}; - -var bool = anyHasOwnProp( [ o1, o2, o3 ], 'b' ); -// returns true - -bool = anyHasOwnProp( [ o1, o2, o3 ], 'd' ); -// returns false - -bool = anyHasOwnProp( [ o1, o2, o3 ], 'toString' ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var fromCodePoint = require( '@stdlib/string/from-code-point' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( '@stdlib/array/filled-by' ); -var anyHasOwnProp = require( '@stdlib/array/base/any-has-own-property' ); - -function randomObject() { - var o = {}; - o[ fromCodePoint( 97+discreteUniform( 0, 25 ) ) ] = 0; - return o; -} - -var arr = filledBy( 10, 'generic', randomObject ); -console.log( arr ); - -var bool = anyHasOwnProp( arr, 'a' ); -console.log( 'a: %s', bool ); - -bool = anyHasOwnProp( arr, 'b' ); -console.log( 'b: %s', bool ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/any-has-own-property/benchmark/benchmark.length.js b/base/any-has-own-property/benchmark/benchmark.length.js deleted file mode 100644 index 9394ae71c..000000000 --- a/base/any-has-own-property/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var filled = require( './../../../filled' ); -var pkg = require( './../package.json' ).name; -var anyHasOwnProp = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( {}, len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = anyHasOwnProp( x, 'foo' ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/any-has-own-property/docs/repl.txt b/base/any-has-own-property/docs/repl.txt deleted file mode 100644 index bc96a8e4c..000000000 --- a/base/any-has-own-property/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arr, property ) - Tests whether at least one element in a provided indexed array has a - specified own property. - - Parameters - ---------- - arr: Array|TypedArray|Object - Input array. - - property: string|symbol|number - Property. - - Returns - ------- - bool: boolean - Result. - - Examples - -------- - > var o1 = { 'a': 1 }; - > var o2 = { 'b': 2 }; - > var o3 = { 'c': 3 }; - > var x = [ o1, o2, o3 ]; - > var out = {{alias}}( x, 'a' ) - true - > out = {{alias}}( x, 'd' ) - false - > out = {{alias}}( x, 'toString' ) - false - - See Also - -------- - diff --git a/base/any-has-own-property/docs/types/index.d.ts b/base/any-has-own-property/docs/types/index.d.ts deleted file mode 100644 index 08a183238..000000000 --- a/base/any-has-own-property/docs/types/index.d.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import { PropertyName } from '@stdlib/types/object'; - -/** -* Tests whether at least one element in a provided array has a specified own property. -* -* @param arr - input array -* @param prop - property -* @returns result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyHasOwnProp( [ o1, o2, o3 ], 'b' ); -* // returns true -* -* bool = anyHasOwnProp( [ o1, o2, o3 ], 'd' ); -* // returns false -* -* bool = anyHasOwnProp( [ o1, o2, o3 ], 'toString' ); -* // returns false -*/ -declare function anyHasOwnProp( arr: Collection | AccessorArrayLike, prop: PropertyName | number ): boolean; - - -// EXPORTS // - -export = anyHasOwnProp; diff --git a/base/any-has-own-property/docs/types/test.ts b/base/any-has-own-property/docs/types/test.ts deleted file mode 100644 index 345aa0805..000000000 --- a/base/any-has-own-property/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import anyHasOwnProp = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - const x = [ 1, 2, 3 ]; - - anyHasOwnProp( x, 'a' ); // $ExpectType boolean - anyHasOwnProp( new Float64Array( x ), 'a' ); // $ExpectType boolean - anyHasOwnProp( new Float32Array( x ), 'a' ); // $ExpectType boolean - anyHasOwnProp( new Int32Array( x ), 'a' ); // $ExpectType boolean - anyHasOwnProp( new Int16Array( x ), 'a' ); // $ExpectType boolean - anyHasOwnProp( new Int8Array( x ), 'a' ); // $ExpectType boolean - anyHasOwnProp( new Uint32Array( x ), 'a' ); // $ExpectType boolean - anyHasOwnProp( new Uint16Array( x ), 'a' ); // $ExpectType boolean - anyHasOwnProp( new Uint8Array( x ), 'a' ); // $ExpectType boolean - anyHasOwnProp( new Uint8ClampedArray( x ), 'a' ); // $ExpectType boolean - anyHasOwnProp( toAccessorArray( x ), 'a' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - anyHasOwnProp( 2, 'a' ); // $ExpectError - anyHasOwnProp( null, 'a' ); // $ExpectError - anyHasOwnProp( false, 'a' ); // $ExpectError - anyHasOwnProp( true, 'a' ); // $ExpectError - anyHasOwnProp( {}, 'a' ); // $ExpectError - anyHasOwnProp( ( x: number ): number => x, 'a' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid property... -{ - const x = [ 1, 2, 3 ]; - - anyHasOwnProp( x, null ); // $ExpectError - anyHasOwnProp( x, false ); // $ExpectError - anyHasOwnProp( x, true ); // $ExpectError - anyHasOwnProp( x, {} ); // $ExpectError - anyHasOwnProp( x, [] ); // $ExpectError - anyHasOwnProp( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - anyHasOwnProp(); // $ExpectError - anyHasOwnProp( x ); // $ExpectError - anyHasOwnProp( x, 'a', {} ); // $ExpectError -} diff --git a/base/any-has-own-property/examples/index.js b/base/any-has-own-property/examples/index.js deleted file mode 100644 index de069f8b9..000000000 --- a/base/any-has-own-property/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var fromCodePoint = require( '@stdlib/string/from-code-point' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( './../../../filled-by' ); -var anyHasOwnProp = require( './../lib' ); - -function randomObject() { - var o = {}; - o[ fromCodePoint( 97+discreteUniform( 0, 25 ) ) ] = 0; - return o; -} - -var arr = filledBy( 10, 'generic', randomObject ); -console.log( arr ); - -var bool = anyHasOwnProp( arr, 'a' ); -console.log( 'a: %s', bool ); - -bool = anyHasOwnProp( arr, 'b' ); -console.log( 'b: %s', bool ); diff --git a/base/any-has-own-property/lib/index.js b/base/any-has-own-property/lib/index.js deleted file mode 100644 index b1e225f6c..000000000 --- a/base/any-has-own-property/lib/index.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether at least one element in a provided array has a specified own property. -* -* @module @stdlib/array/base/any-has-own-property -* -* @example -* var anyHasOwnProp = require( '@stdlib/array/base/any-has-own-property' ); -* -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyHasOwnProp( [ o1, o2, o3 ], 'b' ); -* // returns true -* -* bool = anyHasOwnProp( [ o1, o2, o3 ], 'd' ); -* // returns false -* -* bool = anyHasOwnProp( [ o1, o2, o3 ], 'toString' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/any-has-own-property/lib/main.js b/base/any-has-own-property/lib/main.js deleted file mode 100644 index 012c44cfb..000000000 --- a/base/any-has-own-property/lib/main.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); - - -// FUNCTIONS // - -/** -* Tests whether at least one element in a provided indexed array has a specified own property. -* -* @private -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @returns {boolean} result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = indexed( [ o1, o2, o3 ], 'b' ); -* // returns true -* -* bool = indexed( [ o1, o2, o3 ], 'd' ); -* // returns false -* -* bool = indexed( [ o1, o2, o3 ], 'toString' ); -* // returns false -*/ -function indexed( arr, prop ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - if ( hasOwnProp( arr[ i ], prop ) ) { - return true; - } - } - return false; -} - -/** -* Tests whether at least one element in a provided accessor array has a specified own property. -* -* @private -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @returns {boolean} result -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b' ); -* // returns true -* -* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd' ); -* // returns false -* -* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'toString' ); -* // returns false -*/ -function accessors( arr, prop ) { - var get; - var i; - - get = resolveGetter( arr ); - for ( i = 0; i < arr.length; i++ ) { - if ( hasOwnProp( get( arr, i ), prop ) ) { - return true; - } - } - return false; -} - - -// MAIN // - -/** -* Tests whether at least one element in a provided array has a specified own property. -* -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @returns {boolean} result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyHasOwnProp( [ o1, o2, o3 ], 'b' ); -* // returns true -* -* bool = anyHasOwnProp( [ o1, o2, o3 ], 'd' ); -* // returns false -* -* bool = anyHasOwnProp( [ o1, o2, o3 ], 'toString' ); -* // returns false -*/ -function anyHasOwnProp( arr, prop ) { - if ( isAccessorArray( arr ) ) { - return accessors( arr, prop ); - } - return indexed( arr, prop ); -} - - -// EXPORTS // - -module.exports = anyHasOwnProp; diff --git a/base/any-has-own-property/package.json b/base/any-has-own-property/package.json deleted file mode 100644 index 1a4d65371..000000000 --- a/base/any-has-own-property/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/any-has-own-property", - "version": "0.0.0", - "description": "Test whether at least one element in a provided array has a specified own property.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "assert", - "validate", - "any", - "has", - "own", - "property", - "prop" - ] -} diff --git a/base/any-has-own-property/test/test.js b/base/any-has-own-property/test/test.js deleted file mode 100644 index 846e74b17..000000000 --- a/base/any-has-own-property/test/test.js +++ /dev/null @@ -1,76 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var anyHasOwnProp = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof anyHasOwnProp, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function tests whether an input array contains at least one object having a specified property (indexed)', function test( t ) { - var arr = [ - { - 'a': 0 - }, - { - 'b': 1 - }, - { - 'c': 2 - } - ]; - t.strictEqual( anyHasOwnProp( arr, 'a' ), true, 'returns expected value' ); - t.strictEqual( anyHasOwnProp( arr, 'b' ), true, 'returns expected value' ); - t.strictEqual( anyHasOwnProp( arr, 'c' ), true, 'returns expected value' ); - t.strictEqual( anyHasOwnProp( arr, 'toString' ), false, 'returns expected value' ); - t.strictEqual( anyHasOwnProp( arr, 'd' ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tests whether an input array contains at least one object having a specified property (accessors)', function test( t ) { - var arr = toAccessorArray([ - { - 'a': 0 - }, - { - 'b': 1 - }, - { - 'c': 2 - } - ]); - t.strictEqual( anyHasOwnProp( arr, 'a' ), true, 'returns expected value' ); - t.strictEqual( anyHasOwnProp( arr, 'b' ), true, 'returns expected value' ); - t.strictEqual( anyHasOwnProp( arr, 'c' ), true, 'returns expected value' ); - t.strictEqual( anyHasOwnProp( arr, 'toString' ), false, 'returns expected value' ); - t.strictEqual( anyHasOwnProp( arr, 'd' ), false, 'returns expected value' ); - - t.end(); -}); diff --git a/base/any-has-property/README.md b/base/any-has-property/README.md deleted file mode 100644 index 06356c240..000000000 --- a/base/any-has-property/README.md +++ /dev/null @@ -1,136 +0,0 @@ - - -# anyHasProp - -> Test whether at least one element in a provided array has a specified property, either own or inherited. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var anyHasProp = require( '@stdlib/array/base/any-has-property' ); -``` - -#### anyHasProp( arr, property ) - -Tests whether at least one element in a provided array has a specified property, either own or inherited. - -```javascript -var o1 = { - 'a': 1 -}; -var o2 = { - 'b': 2 -}; -var o3 = { - 'c': 3 -}; - -var bool = anyHasProp( [ o1, o2, o3 ], 'b' ); -// returns true - -bool = anyHasProp( [ o1, o2, o3 ], 'd' ); -// returns false - -bool = anyHasProp( [ o1, o2, o3 ], 'toString' ); -// returns true -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var fromCodePoint = require( '@stdlib/string/from-code-point' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( '@stdlib/array/filled-by' ); -var anyHasProp = require( '@stdlib/array/base/any-has-property' ); - -function randomObject() { - var o = {}; - o[ fromCodePoint( 97+discreteUniform( 0, 25 ) ) ] = 0; - return o; -} - -var arr = filledBy( 10, 'generic', randomObject ); -console.log( arr ); - -var bool = anyHasProp( arr, 'a' ); -console.log( 'a: %s', bool ); - -bool = anyHasProp( arr, 'b' ); -console.log( 'b: %s', bool ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/any-has-property/benchmark/benchmark.length.js b/base/any-has-property/benchmark/benchmark.length.js deleted file mode 100644 index f57f4e03f..000000000 --- a/base/any-has-property/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var filled = require( './../../../filled' ); -var pkg = require( './../package.json' ).name; -var anyHasProp = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( {}, len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = anyHasProp( x, 'foo' ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/any-has-property/docs/repl.txt b/base/any-has-property/docs/repl.txt deleted file mode 100644 index 7f9d3e93f..000000000 --- a/base/any-has-property/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arr, property ) - Tests whether at least one element in a provided indexed array has a - specified property, either own or inherited. - - Parameters - ---------- - arr: Array|TypedArray|Object - Input array. - - property: string|symbol|number - Property. - - Returns - ------- - bool: boolean - Result. - - Examples - -------- - > var o1 = { 'a': 1 }; - > var o2 = { 'b': 2 }; - > var o3 = { 'c': 3 }; - > var x = [ o1, o2, o3 ]; - > var out = {{alias}}( x, 'a' ) - true - > out = {{alias}}( x, 'd' ) - false - > out = {{alias}}( x, 'toString' ) - true - - See Also - -------- - diff --git a/base/any-has-property/docs/types/index.d.ts b/base/any-has-property/docs/types/index.d.ts deleted file mode 100644 index cca0ff947..000000000 --- a/base/any-has-property/docs/types/index.d.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import { PropertyName } from '@stdlib/types/object'; - -/** -* Tests whether at least one element in a provided array has a specified property, either own or inherited. -* -* @param arr - input array -* @param prop - property -* @returns result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyHasProp( [ o1, o2, o3 ], 'b' ); -* // returns true -* -* bool = anyHasProp( [ o1, o2, o3 ], 'd' ); -* // returns false -* -* bool = anyHasProp( [ o1, o2, o3 ], 'toString' ); -* // returns true -*/ -declare function anyHasProp( arr: Collection | AccessorArrayLike, prop: PropertyName | number ): boolean; - - -// EXPORTS // - -export = anyHasProp; diff --git a/base/any-has-property/docs/types/test.ts b/base/any-has-property/docs/types/test.ts deleted file mode 100644 index 50e61eb1c..000000000 --- a/base/any-has-property/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import anyHasProp = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - const x = [ 1, 2, 3 ]; - - anyHasProp( x, 'a' ); // $ExpectType boolean - anyHasProp( new Float64Array( x ), 'a' ); // $ExpectType boolean - anyHasProp( new Float32Array( x ), 'a' ); // $ExpectType boolean - anyHasProp( new Int32Array( x ), 'a' ); // $ExpectType boolean - anyHasProp( new Int16Array( x ), 'a' ); // $ExpectType boolean - anyHasProp( new Int8Array( x ), 'a' ); // $ExpectType boolean - anyHasProp( new Uint32Array( x ), 'a' ); // $ExpectType boolean - anyHasProp( new Uint16Array( x ), 'a' ); // $ExpectType boolean - anyHasProp( new Uint8Array( x ), 'a' ); // $ExpectType boolean - anyHasProp( new Uint8ClampedArray( x ), 'a' ); // $ExpectType boolean - anyHasProp( toAccessorArray( x ), 'a' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - anyHasProp( 2, 'a' ); // $ExpectError - anyHasProp( null, 'a' ); // $ExpectError - anyHasProp( false, 'a' ); // $ExpectError - anyHasProp( true, 'a' ); // $ExpectError - anyHasProp( {}, 'a' ); // $ExpectError - anyHasProp( ( x: number ): number => x, 'a' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid property... -{ - const x = [ 1, 2, 3 ]; - - anyHasProp( x, null ); // $ExpectError - anyHasProp( x, false ); // $ExpectError - anyHasProp( x, true ); // $ExpectError - anyHasProp( x, {} ); // $ExpectError - anyHasProp( x, [] ); // $ExpectError - anyHasProp( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - anyHasProp(); // $ExpectError - anyHasProp( x ); // $ExpectError - anyHasProp( x, 'a', {} ); // $ExpectError -} diff --git a/base/any-has-property/examples/index.js b/base/any-has-property/examples/index.js deleted file mode 100644 index 066289c01..000000000 --- a/base/any-has-property/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var fromCodePoint = require( '@stdlib/string/from-code-point' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( './../../../filled-by' ); -var anyHasProp = require( './../lib' ); - -function randomObject() { - var o = {}; - o[ fromCodePoint( 97+discreteUniform( 0, 25 ) ) ] = 0; - return o; -} - -var arr = filledBy( 10, 'generic', randomObject ); -console.log( arr ); - -var bool = anyHasProp( arr, 'a' ); -console.log( 'a: %s', bool ); - -bool = anyHasProp( arr, 'b' ); -console.log( 'b: %s', bool ); diff --git a/base/any-has-property/lib/index.js b/base/any-has-property/lib/index.js deleted file mode 100644 index 9ab239cf8..000000000 --- a/base/any-has-property/lib/index.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether at least one element in a provided array has a specified property, either own or inherited. -* -* @module @stdlib/array/base/any-has-property -* -* @example -* var anyHasProp = require( '@stdlib/array/base/any-has-property' ); -* -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyHasProp( [ o1, o2, o3 ], 'b' ); -* // returns true -* -* bool = anyHasProp( [ o1, o2, o3 ], 'd' ); -* // returns false -* -* bool = anyHasProp( [ o1, o2, o3 ], 'toString' ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/any-has-property/lib/main.js b/base/any-has-property/lib/main.js deleted file mode 100644 index 799fe2af2..000000000 --- a/base/any-has-property/lib/main.js +++ /dev/null @@ -1,151 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var hasProp = require( '@stdlib/assert/has-property' ); - - -// FUNCTIONS // - -/** -* Tests whether at least one element in a provided indexed array has a specified property, either own or inherited. -* -* @private -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @returns {boolean} result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = indexed( [ o1, o2, o3 ], 'b' ); -* // returns true -* -* bool = indexed( [ o1, o2, o3 ], 'd' ); -* // returns false -* -* bool = indexed( [ o1, o2, o3 ], 'toString' ); -* // returns true -*/ -function indexed( arr, prop ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - if ( hasProp( arr[ i ], prop ) ) { - return true; - } - } - return false; -} - -/** -* Tests whether at least one element in a provided accessor array has a specified property, either own or inherited. -* -* @private -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @returns {boolean} result -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b' ); -* // returns true -* -* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd' ); -* // returns false -* -* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'toString' ); -* // returns true -*/ -function accessors( arr, prop ) { - var get; - var i; - - get = resolveGetter( arr ); - for ( i = 0; i < arr.length; i++ ) { - if ( hasProp( get( arr, i ), prop ) ) { - return true; - } - } - return false; -} - - -// MAIN // - -/** -* Tests whether at least one element in a provided array has a specified property, either own or inherited. -* -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @returns {boolean} result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyHasProp( [ o1, o2, o3 ], 'b' ); -* // returns true -* -* bool = anyHasProp( [ o1, o2, o3 ], 'd' ); -* // returns false -* -* bool = anyHasProp( [ o1, o2, o3 ], 'toString' ); -* // returns true -*/ -function anyHasProp( arr, prop ) { - if ( isAccessorArray( arr ) ) { - return accessors( arr, prop ); - } - return indexed( arr, prop ); -} - - -// EXPORTS // - -module.exports = anyHasProp; diff --git a/base/any-has-property/package.json b/base/any-has-property/package.json deleted file mode 100644 index 0d10f1c38..000000000 --- a/base/any-has-property/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/any-has-property", - "version": "0.0.0", - "description": "Test whether at least one element in a provided array has a specified property, either own or inherited.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "assert", - "validate", - "any", - "has", - "property", - "prop" - ] -} diff --git a/base/any-has-property/test/test.js b/base/any-has-property/test/test.js deleted file mode 100644 index dbfe570fb..000000000 --- a/base/any-has-property/test/test.js +++ /dev/null @@ -1,76 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var anyHasProp = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof anyHasProp, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function tests whether an input array contains at least one object having a specified property (indexed)', function test( t ) { - var arr = [ - { - 'a': 0 - }, - { - 'b': 1 - }, - { - 'c': 2 - } - ]; - t.strictEqual( anyHasProp( arr, 'a' ), true, 'returns expected value' ); - t.strictEqual( anyHasProp( arr, 'b' ), true, 'returns expected value' ); - t.strictEqual( anyHasProp( arr, 'c' ), true, 'returns expected value' ); - t.strictEqual( anyHasProp( arr, 'toString' ), true, 'returns expected value' ); - t.strictEqual( anyHasProp( arr, 'd' ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tests whether an input array contains at least one object having a specified property (accessors)', function test( t ) { - var arr = toAccessorArray([ - { - 'a': 0 - }, - { - 'b': 1 - }, - { - 'c': 2 - } - ]); - t.strictEqual( anyHasProp( arr, 'a' ), true, 'returns expected value' ); - t.strictEqual( anyHasProp( arr, 'b' ), true, 'returns expected value' ); - t.strictEqual( anyHasProp( arr, 'c' ), true, 'returns expected value' ); - t.strictEqual( anyHasProp( arr, 'toString' ), true, 'returns expected value' ); - t.strictEqual( anyHasProp( arr, 'd' ), false, 'returns expected value' ); - - t.end(); -}); diff --git a/base/any-is-entry-in/README.md b/base/any-is-entry-in/README.md deleted file mode 100644 index 0919a0313..000000000 --- a/base/any-is-entry-in/README.md +++ /dev/null @@ -1,136 +0,0 @@ - - -# anyIsEntryIn - -> Test whether at least one element in a provided array has a specified property key-value pair, either own or inherited. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var anyIsEntryIn = require( '@stdlib/array/base/any-is-entry-in' ); -``` - -#### anyIsEntryIn( arr, property, value ) - -Tests whether at least one element in a provided array has a specified property key-value pair, either own or inherited. - -```javascript -var o1 = { - 'a': 1 -}; -var o2 = { - 'b': 2 -}; -var o3 = { - 'c': 3 -}; - -var bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 2 ); -// returns true - -bool = anyIsEntryIn( [ o1, o2, o3 ], 'd', 0 ); -// returns false - -bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 0 ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var fromCodePoint = require( '@stdlib/string/from-code-point' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( '@stdlib/array/filled-by' ); -var anyIsEntryIn = require( '@stdlib/array/base/any-is-entry-in' ); - -function randomObject() { - var o = {}; - o[ fromCodePoint( 97+discreteUniform( 0, 25 ) ) ] = 0; - return o; -} - -var arr = filledBy( 10, 'generic', randomObject ); -console.log( arr ); - -var bool = anyIsEntryIn( arr, 'a', 0 ); -console.log( 'a: %s', bool ); - -bool = anyIsEntryIn( arr, 'b', 0 ); -console.log( 'b: %s', bool ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/any-is-entry-in/benchmark/benchmark.length.js b/base/any-is-entry-in/benchmark/benchmark.length.js deleted file mode 100644 index 35fcaeafa..000000000 --- a/base/any-is-entry-in/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var filled = require( './../../../filled' ); -var pkg = require( './../package.json' ).name; -var anyIsEntryIn = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( {}, len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = anyIsEntryIn( x, 'foo', 'bar' ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/any-is-entry-in/docs/repl.txt b/base/any-is-entry-in/docs/repl.txt deleted file mode 100644 index 1edaa037c..000000000 --- a/base/any-is-entry-in/docs/repl.txt +++ /dev/null @@ -1,37 +0,0 @@ - -{{alias}}( arr, property, value ) - Tests whether at least one element in a provided indexed array has a - specified property key-value pair, either own or inherited. - - Parameters - ---------- - arr: Array|TypedArray|Object - Input array. - - property: string|symbol|number - Property. - - value: any - Property value. - - Returns - ------- - bool: boolean - Result. - - Examples - -------- - > var o1 = { 'a': 1 }; - > var o2 = { 'b': 2 }; - > var o3 = { 'c': 3 }; - > var x = [ o1, o2, o3 ]; - > var out = {{alias}}( x, 'a', 1 ) - true - > out = {{alias}}( x, 'b', 0 ) - false - > out = {{alias}}( x, 'b', 2 ) - true - - See Also - -------- - diff --git a/base/any-is-entry-in/docs/types/index.d.ts b/base/any-is-entry-in/docs/types/index.d.ts deleted file mode 100644 index 826888aee..000000000 --- a/base/any-is-entry-in/docs/types/index.d.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import { PropertyName } from '@stdlib/types/object'; - -/** -* Tests whether at least one element in a provided array has a specified property key-value pair, either own or inherited. -* -* @param arr - input array -* @param prop - property -* @param value - property value -* @returns result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 2 ); -* // returns true -* -* bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 3 ); -* // returns false -* -* bool = anyIsEntryIn( [ o1, o2, o3 ], 'd', 0 ); -* // returns false -*/ -declare function anyIsEntryIn( arr: Collection | AccessorArrayLike, prop: PropertyName | number, value: unknown ): boolean; - - -// EXPORTS // - -export = anyIsEntryIn; diff --git a/base/any-is-entry-in/docs/types/test.ts b/base/any-is-entry-in/docs/types/test.ts deleted file mode 100644 index f55fc957d..000000000 --- a/base/any-is-entry-in/docs/types/test.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import anyIsEntryIn = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - const x = [ 1, 2, 3 ]; - - anyIsEntryIn( x, 'a', 0 ); // $ExpectType boolean - anyIsEntryIn( new Float64Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntryIn( new Float32Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntryIn( new Int32Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntryIn( new Int16Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntryIn( new Int8Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntryIn( new Uint32Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntryIn( new Uint16Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntryIn( new Uint8Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntryIn( new Uint8ClampedArray( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntryIn( toAccessorArray( x ), 'a', 0 ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - anyIsEntryIn( 2, 'a', 0 ); // $ExpectError - anyIsEntryIn( null, 'a', 0 ); // $ExpectError - anyIsEntryIn( false, 'a', 0 ); // $ExpectError - anyIsEntryIn( true, 'a', 0 ); // $ExpectError - anyIsEntryIn( {}, 'a', 0 ); // $ExpectError - anyIsEntryIn( ( x: number ): number => x, 'a', 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid property... -{ - const x = [ 1, 2, 3 ]; - - anyIsEntryIn( x, null, 0 ); // $ExpectError - anyIsEntryIn( x, false, 0 ); // $ExpectError - anyIsEntryIn( x, true, 0 ); // $ExpectError - anyIsEntryIn( x, {}, 0 ); // $ExpectError - anyIsEntryIn( x, [], 0 ); // $ExpectError - anyIsEntryIn( x, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - anyIsEntryIn(); // $ExpectError - anyIsEntryIn( x ); // $ExpectError - anyIsEntryIn( x, 'a' ); // $ExpectError - anyIsEntryIn( x, 'a', 0, {} ); // $ExpectError -} diff --git a/base/any-is-entry-in/examples/index.js b/base/any-is-entry-in/examples/index.js deleted file mode 100644 index 3d586ad12..000000000 --- a/base/any-is-entry-in/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var fromCodePoint = require( '@stdlib/string/from-code-point' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( './../../../filled-by' ); -var anyIsEntryIn = require( './../lib' ); - -function randomObject() { - var o = {}; - o[ fromCodePoint( 97+discreteUniform( 0, 25 ) ) ] = 0; - return o; -} - -var arr = filledBy( 10, 'generic', randomObject ); -console.log( arr ); - -var bool = anyIsEntryIn( arr, 'a', 0 ); -console.log( 'a: %s', bool ); - -bool = anyIsEntryIn( arr, 'b', 0 ); -console.log( 'b: %s', bool ); diff --git a/base/any-is-entry-in/lib/index.js b/base/any-is-entry-in/lib/index.js deleted file mode 100644 index f43ccbe59..000000000 --- a/base/any-is-entry-in/lib/index.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether at least one element in a provided array has a specified property key-value pair, either own or inherited. -* -* @module @stdlib/array/base/any-is-entry-in -* -* @example -* var anyIsEntryIn = require( '@stdlib/array/base/any-is-entry-in' ); -* -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 2 ); -* // returns true -* -* bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 3 ); -* // returns false -* -* bool = anyIsEntryIn( [ o1, o2, o3 ], 'd', 0 ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/any-is-entry-in/lib/main.js b/base/any-is-entry-in/lib/main.js deleted file mode 100644 index a690b57c2..000000000 --- a/base/any-is-entry-in/lib/main.js +++ /dev/null @@ -1,174 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var hasProp = require( '@stdlib/assert/has-property' ); - - -// FUNCTIONS // - -/** -* Tests whether at least one element in a provided indexed array has a specified property key-value pair, either own or inherited. -* -* @private -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @param {*} value - property value -* @returns {boolean} result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = indexed( [ o1, o2, o3 ], 'b', 2 ); -* // returns true -* -* bool = indexed( [ o1, o2, o3 ], 'b', 3 ); -* // returns false -* -* bool = indexed( [ o1, o2, o3 ], 'd', 0 ); -* // returns false -*/ -function indexed( arr, prop, value ) { - var v; - var i; - if ( value === void 0 ) { - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - if ( hasProp( v, prop ) && v[ prop ] === value ) { - return true; - } - } - return false; - } - for ( i = 0; i < arr.length; i++ ) { - if ( arr[ i ][ prop ] === value ) { - return true; - } - } - return false; -} - -/** -* Tests whether at least one element in a provided accessor array has a specified property key-value pair, either own or inherited. -* -* @private -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @param {*} value - property value -* @returns {boolean} result -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 2 ); -* // returns true -* -* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 3 ); -* // returns false -* -* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd', 0 ); -* // returns false -*/ -function accessors( arr, prop, value ) { - var get; - var v; - var i; - - get = resolveGetter( arr ); - if ( value === void 0 ) { - for ( i = 0; i < arr.length; i++ ) { - v = get( arr, i ); - if ( hasProp( v, prop ) && v[ prop ] === value ) { - return true; - } - } - return false; - } - for ( i = 0; i < arr.length; i++ ) { - if ( get( arr, i )[ prop ] === value ) { - return true; - } - } - return false; -} - - -// MAIN // - -/** -* Tests whether at least one element in a provided array has a specified property key-value pair, either own or inherited. -* -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @param {*} value - property value -* @returns {boolean} result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 2 ); -* // returns true -* -* bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 3 ); -* // returns false -* -* bool = anyIsEntryIn( [ o1, o2, o3 ], 'd', 0 ); -* // returns false -*/ -function anyIsEntryIn( arr, prop, value ) { - if ( isAccessorArray( arr ) ) { - return accessors( arr, prop, value ); - } - return indexed( arr, prop, value ); -} - - -// EXPORTS // - -module.exports = anyIsEntryIn; diff --git a/base/any-is-entry-in/package.json b/base/any-is-entry-in/package.json deleted file mode 100644 index f8fc10da0..000000000 --- a/base/any-is-entry-in/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/any-is-entry-in", - "version": "0.0.0", - "description": "Test whether at least one element in a provided array has a specified property key-value pair, either own or inherited.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "assert", - "validate", - "any", - "has", - "property", - "prop", - "entry", - "key-value" - ] -} diff --git a/base/any-is-entry-in/test/test.js b/base/any-is-entry-in/test/test.js deleted file mode 100644 index 95b744cf8..000000000 --- a/base/any-is-entry-in/test/test.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var anyIsEntryIn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof anyIsEntryIn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function tests whether an input array contains at least one object having a specified property key-value pair (indexed)', function test( t ) { - var arr = [ - { - 'a': 0 - }, - { - 'b': 1 - }, - { - 'c': 2 - }, - { - 'd': void 0 - } - ]; - t.strictEqual( anyIsEntryIn( arr, 'a', 0 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntryIn( arr, 'b', 1 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntryIn( arr, 'c', 2 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntryIn( arr, 'toString', arr[ 0 ].toString ), true, 'returns expected value' ); - t.strictEqual( anyIsEntryIn( arr, 'd', 0 ), false, 'returns expected value' ); - t.strictEqual( anyIsEntryIn( arr, 'd', void 0 ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tests whether an input array contains at least one object having a specified property key-value pair (accessors)', function test( t ) { - var arr = toAccessorArray([ - { - 'a': 0 - }, - { - 'b': 1 - }, - { - 'c': 2 - }, - { - 'd': void 0 - } - ]); - t.strictEqual( anyIsEntryIn( arr, 'a', 0 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntryIn( arr, 'b', 1 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntryIn( arr, 'c', 2 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntryIn( arr, 'toString', arr.get( 0 ).toString ), true, 'returns expected value' ); - t.strictEqual( anyIsEntryIn( arr, 'd', 0 ), false, 'returns expected value' ); - t.strictEqual( anyIsEntryIn( arr, 'd', void 0 ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/base/any-is-entry/README.md b/base/any-is-entry/README.md deleted file mode 100644 index 852ad1e3b..000000000 --- a/base/any-is-entry/README.md +++ /dev/null @@ -1,136 +0,0 @@ - - -# anyIsEntry - -> Test whether at least one element in a provided array has a specified own property key-value pair. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var anyIsEntry = require( '@stdlib/array/base/any-is-entry' ); -``` - -#### anyIsEntry( arr, property, value ) - -Tests whether at least one element in a provided array has a specified own property key-value pair. - -```javascript -var o1 = { - 'a': 1 -}; -var o2 = { - 'b': 2 -}; -var o3 = { - 'c': 3 -}; - -var bool = anyIsEntry( [ o1, o2, o3 ], 'b', 2 ); -// returns true - -bool = anyIsEntry( [ o1, o2, o3 ], 'd', 0 ); -// returns false - -bool = anyIsEntry( [ o1, o2, o3 ], 'b', 0 ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var fromCodePoint = require( '@stdlib/string/from-code-point' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( '@stdlib/array/filled-by' ); -var anyIsEntry = require( '@stdlib/array/base/any-is-entry' ); - -function randomObject() { - var o = {}; - o[ fromCodePoint( 97+discreteUniform( 0, 25 ) ) ] = 0; - return o; -} - -var arr = filledBy( 10, 'generic', randomObject ); -console.log( arr ); - -var bool = anyIsEntry( arr, 'a', 0 ); -console.log( 'a: %s', bool ); - -bool = anyIsEntry( arr, 'b', 0 ); -console.log( 'b: %s', bool ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/any-is-entry/benchmark/benchmark.length.js b/base/any-is-entry/benchmark/benchmark.length.js deleted file mode 100644 index adb14579b..000000000 --- a/base/any-is-entry/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var filled = require( './../../../filled' ); -var pkg = require( './../package.json' ).name; -var anyIsEntry = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( {}, len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = anyIsEntry( x, 'foo', 'bar' ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/any-is-entry/docs/repl.txt b/base/any-is-entry/docs/repl.txt deleted file mode 100644 index 964270381..000000000 --- a/base/any-is-entry/docs/repl.txt +++ /dev/null @@ -1,37 +0,0 @@ - -{{alias}}( arr, property, value ) - Tests whether at least one element in a provided indexed array has a - specified own property key-value pair. - - Parameters - ---------- - arr: Array|TypedArray|Object - Input array. - - property: string|symbol|number - Property. - - value: any - Property value. - - Returns - ------- - bool: boolean - Result. - - Examples - -------- - > var o1 = { 'a': 1 }; - > var o2 = { 'b': 2 }; - > var o3 = { 'c': 3 }; - > var x = [ o1, o2, o3 ]; - > var out = {{alias}}( x, 'a', 1 ) - true - > out = {{alias}}( x, 'b', 0 ) - false - > out = {{alias}}( x, 'b', 2 ) - true - - See Also - -------- - diff --git a/base/any-is-entry/docs/types/index.d.ts b/base/any-is-entry/docs/types/index.d.ts deleted file mode 100644 index c814e5493..000000000 --- a/base/any-is-entry/docs/types/index.d.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import { PropertyName } from '@stdlib/types/object'; - -/** -* Tests whether at least one element in a provided array has a specified own property key-value pair. -* -* @param arr - input array -* @param prop - property -* @param value - property value -* @returns result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyIsEntry( [ o1, o2, o3 ], 'b', 2 ); -* // returns true -* -* bool = anyIsEntry( [ o1, o2, o3 ], 'b', 3 ); -* // returns false -* -* bool = anyIsEntry( [ o1, o2, o3 ], 'd', 0 ); -* // returns false -*/ -declare function anyIsEntry( arr: Collection | AccessorArrayLike, prop: PropertyName | number, value: unknown ): boolean; - - -// EXPORTS // - -export = anyIsEntry; diff --git a/base/any-is-entry/docs/types/test.ts b/base/any-is-entry/docs/types/test.ts deleted file mode 100644 index 65b85dbd3..000000000 --- a/base/any-is-entry/docs/types/test.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import anyIsEntry = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - const x = [ 1, 2, 3 ]; - - anyIsEntry( x, 'a', 0 ); // $ExpectType boolean - anyIsEntry( new Float64Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntry( new Float32Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntry( new Int32Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntry( new Int16Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntry( new Int8Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntry( new Uint32Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntry( new Uint16Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntry( new Uint8Array( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntry( new Uint8ClampedArray( x ), 'a', 0 ); // $ExpectType boolean - anyIsEntry( toAccessorArray( x ), 'a', 0 ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - anyIsEntry( 2, 'a', 0 ); // $ExpectError - anyIsEntry( null, 'a', 0 ); // $ExpectError - anyIsEntry( false, 'a', 0 ); // $ExpectError - anyIsEntry( true, 'a', 0 ); // $ExpectError - anyIsEntry( {}, 'a', 0 ); // $ExpectError - anyIsEntry( ( x: number ): number => x, 'a', 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid property... -{ - const x = [ 1, 2, 3 ]; - - anyIsEntry( x, null, 0 ); // $ExpectError - anyIsEntry( x, false, 0 ); // $ExpectError - anyIsEntry( x, true, 0 ); // $ExpectError - anyIsEntry( x, {}, 0 ); // $ExpectError - anyIsEntry( x, [], 0 ); // $ExpectError - anyIsEntry( x, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - anyIsEntry(); // $ExpectError - anyIsEntry( x ); // $ExpectError - anyIsEntry( x, 'a' ); // $ExpectError - anyIsEntry( x, 'a', 0, {} ); // $ExpectError -} diff --git a/base/any-is-entry/examples/index.js b/base/any-is-entry/examples/index.js deleted file mode 100644 index 94266a54e..000000000 --- a/base/any-is-entry/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var fromCodePoint = require( '@stdlib/string/from-code-point' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( './../../../filled-by' ); -var anyIsEntry = require( './../lib' ); - -function randomObject() { - var o = {}; - o[ fromCodePoint( 97+discreteUniform( 0, 25 ) ) ] = 0; - return o; -} - -var arr = filledBy( 10, 'generic', randomObject ); -console.log( arr ); - -var bool = anyIsEntry( arr, 'a', 0 ); -console.log( 'a: %s', bool ); - -bool = anyIsEntry( arr, 'b', 0 ); -console.log( 'b: %s', bool ); diff --git a/base/any-is-entry/lib/index.js b/base/any-is-entry/lib/index.js deleted file mode 100644 index 71b6c36d1..000000000 --- a/base/any-is-entry/lib/index.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test whether at least one element in a provided array has a specified own property key-value pair. -* -* @module @stdlib/array/base/any-is-entry -* -* @example -* var anyIsEntry = require( '@stdlib/array/base/any-is-entry' ); -* -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyIsEntry( [ o1, o2, o3 ], 'b', 2 ); -* // returns true -* -* bool = anyIsEntry( [ o1, o2, o3 ], 'b', 3 ); -* // returns false -* -* bool = anyIsEntry( [ o1, o2, o3 ], 'd', 0 ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/any-is-entry/lib/main.js b/base/any-is-entry/lib/main.js deleted file mode 100644 index 07e1bfdeb..000000000 --- a/base/any-is-entry/lib/main.js +++ /dev/null @@ -1,158 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); - - -// FUNCTIONS // - -/** -* Tests whether at least one element in a provided indexed array has a specified own property key-value pair. -* -* @private -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @param {*} value - property value -* @returns {boolean} result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = indexed( [ o1, o2, o3 ], 'b', 2 ); -* // returns true -* -* bool = indexed( [ o1, o2, o3 ], 'b', 3 ); -* // returns false -* -* bool = indexed( [ o1, o2, o3 ], 'd', 0 ); -* // returns false -*/ -function indexed( arr, prop, value ) { - var v; - var i; - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - if ( hasOwnProp( v, prop ) && v[ prop ] === value ) { - return true; - } - } - return false; -} - -/** -* Tests whether at least one element in a provided accessor array has a specified own property key-value pair. -* -* @private -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @param {*} value - property value -* @returns {boolean} result -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 2 ); -* // returns true -* -* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 3 ); -* // returns false -* -* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd', 0 ); -* // returns false -*/ -function accessors( arr, prop, value ) { - var get; - var v; - var i; - - get = resolveGetter( arr ); - for ( i = 0; i < arr.length; i++ ) { - v = get( arr, i ); - if ( hasOwnProp( v, prop ) && v[ prop ] === value ) { - return true; - } - } - return false; -} - - -// MAIN // - -/** -* Tests whether at least one element in a provided array has a specified own property key-value pair. -* -* @param {Collection} arr - input array -* @param {(string|symbol|number)} prop - property -* @param {*} value - property value -* @returns {boolean} result -* -* @example -* var o1 = { -* 'a': 1 -* }; -* var o2 = { -* 'b': 2 -* }; -* var o3 = { -* 'c': 3 -* }; -* -* var bool = anyIsEntry( [ o1, o2, o3 ], 'b', 2 ); -* // returns true -* -* bool = anyIsEntry( [ o1, o2, o3 ], 'b', 3 ); -* // returns false -* -* bool = anyIsEntry( [ o1, o2, o3 ], 'd', 0 ); -* // returns false -*/ -function anyIsEntry( arr, prop, value ) { - if ( isAccessorArray( arr ) ) { - return accessors( arr, prop, value ); - } - return indexed( arr, prop, value ); -} - - -// EXPORTS // - -module.exports = anyIsEntry; diff --git a/base/any-is-entry/package.json b/base/any-is-entry/package.json deleted file mode 100644 index 05b1ed6f9..000000000 --- a/base/any-is-entry/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/any-is-entry", - "version": "0.0.0", - "description": "Test whether at least one element in a provided array has a specified own property key-value pair.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "assert", - "validate", - "any", - "has", - "own", - "property", - "prop", - "entry", - "key-value" - ] -} diff --git a/base/any-is-entry/test/test.js b/base/any-is-entry/test/test.js deleted file mode 100644 index 2e1c08b1d..000000000 --- a/base/any-is-entry/test/test.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var anyIsEntry = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof anyIsEntry, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function tests whether an input array contains at least one object having a specified property key-value pair (indexed)', function test( t ) { - var arr = [ - { - 'a': 0 - }, - { - 'b': 1 - }, - { - 'c': 2 - }, - { - 'd': void 0 - } - ]; - t.strictEqual( anyIsEntry( arr, 'a', 0 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntry( arr, 'b', 1 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntry( arr, 'c', 2 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntry( arr, 'toString', arr[ 0 ].toString ), false, 'returns expected value' ); - t.strictEqual( anyIsEntry( arr, 'd', 0 ), false, 'returns expected value' ); - t.strictEqual( anyIsEntry( arr, 'd', void 0 ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tests whether an input array contains at least one object having a specified property key-value pair (accessors)', function test( t ) { - var arr = toAccessorArray([ - { - 'a': 0 - }, - { - 'b': 1 - }, - { - 'c': 2 - }, - { - 'd': void 0 - } - ]); - t.strictEqual( anyIsEntry( arr, 'a', 0 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntry( arr, 'b', 1 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntry( arr, 'c', 2 ), true, 'returns expected value' ); - t.strictEqual( anyIsEntry( arr, 'toString', arr.get( 0 ).toString ), false, 'returns expected value' ); - t.strictEqual( anyIsEntry( arr, 'd', 0 ), false, 'returns expected value' ); - t.strictEqual( anyIsEntry( arr, 'd', void 0 ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/base/any/README.md b/base/any/README.md deleted file mode 100644 index 68be44a19..000000000 --- a/base/any/README.md +++ /dev/null @@ -1,118 +0,0 @@ - - -# any - -> Test whether at least one element in an array is truthy. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var any = require( '@stdlib/array/base/any' ); -``` - -#### any( x ) - -Tests whether at least one element in an array is truthy. - -```javascript -var x = [ 0, 0, 1, 0 ]; - -var bool = any( x ); -// returns true -``` - -
- - - - - -
- -## Notes - -- If provided an empty array, the function returns `false`. -- The function does **not** skip `undefined` elements and is thus not optimized for sparse arrays. - -
- - - - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var any = require( '@stdlib/array/base/any' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = any( x ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/any/benchmark/benchmark.length.js b/base/any/benchmark/benchmark.length.js deleted file mode 100644 index 2d3dd5db8..000000000 --- a/base/any/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var any = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = any( x ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/any/docs/repl.txt b/base/any/docs/repl.txt deleted file mode 100644 index 3aa9a7433..000000000 --- a/base/any/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( x ) - Tests whether at least one element in an array is truthy. - - The function returns immediately upon encountering a truthy value. - - If provided an empty array, the function returns `false`. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - Returns - ------- - bool: boolean - The function returns `true` if at least one element is truthy; - otherwise, the function returns `false`. - - Examples - -------- - > var x = [ 0, 0, 1, 0 ]; - > var out = {{alias}}( x ) - true - - See Also - -------- - diff --git a/base/any/docs/types/index.d.ts b/base/any/docs/types/index.d.ts deleted file mode 100644 index 0976a6732..000000000 --- a/base/any/docs/types/index.d.ts +++ /dev/null @@ -1,47 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Tests whether at least one element in an array is truthy. -* -* ## Notes -* -* - The function immediately returns upon encountering a truthy value. -* - If provided an empty collection, the function returns `false`. -* -* @param x - input array -* @returns boolean indicating whether at least one element is truthy -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* -* var out = any( x ); -* // returns true -*/ -declare function any( x: Collection | AccessorArrayLike ): boolean; - - -// EXPORTS // - -export = any; diff --git a/base/any/docs/types/test.ts b/base/any/docs/types/test.ts deleted file mode 100644 index da8c2529d..000000000 --- a/base/any/docs/types/test.ts +++ /dev/null @@ -1,52 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import any = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - any( [ 1, 2, 3 ] ); // $ExpectType boolean - any( new Float64Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - any( new Float32Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - any( new Int32Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - any( new Int16Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - any( new Int8Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - any( new Uint32Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - any( new Uint16Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - any( new Uint8Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - any( new Uint8ClampedArray( [ 1, 2, 3 ] ) ); // $ExpectType boolean - any( toAccessorArray( [ 1, 2, 3 ] ) ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - any( 2 ); // $ExpectError - any( false ); // $ExpectError - any( true ); // $ExpectError - any( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - any(); // $ExpectError - any( [ 1, 2, 3 ], {}, 3 ); // $ExpectError -} diff --git a/base/any/examples/index.js b/base/any/examples/index.js deleted file mode 100644 index 3b827a0a1..000000000 --- a/base/any/examples/index.js +++ /dev/null @@ -1,33 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var any = require( './../lib' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = any( x ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/any/lib/index.js b/base/any/lib/index.js deleted file mode 100644 index d7a40d4ea..000000000 --- a/base/any/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Test whether at least one element in an array is truthy. -* -* @module @stdlib/array/base/any -* -* @example -* var any = require( '@stdlib/array/base/any' ); -* -* var x = [ 0, 0, 1, 0 ]; -* -* var out = any( x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/any/lib/main.js b/base/any/lib/main.js deleted file mode 100644 index 1b493d1b3..000000000 --- a/base/any/lib/main.js +++ /dev/null @@ -1,147 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplex128Array = require( './../../../base/assert/is-complex128array' ); -var isComplex64Array = require( './../../../base/assert/is-complex64array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Tests whether at least one element in an array is truthy. -* -* @private -* @param {Collection} x - input array -* @returns {boolean} boolean indicating whether at least one element is truthy -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* -* var out = internal( x ); -* // returns true -* -* @example -* var x = [ 0, 0, 0, 0 ]; -* -* var out = internal( x ); -* // returns false -*/ -function internal( x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - if ( x[ i ] ) { - return true; - } - } - return false; -} - -/** -* Tests whether at least one element in an array is truthy. -* -* @private -* @param {Object} x - input array object -* @returns {boolean} boolean indicating whether at least one element is truthy -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* -* var out = accessors( x ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) ); -* -* var out = accessors( x ); -* // returns false -*/ -function accessors( x ) { - var data; - var get; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - for ( i = 0; i < data.length; i++ ) { - if ( get( data, i ) ) { - return true; - } - } - return false; -} - - -// MAIN // - -/** -* Tests whether at least one element in an array is truthy. -* -* @param {Collection} x - input array -* @returns {boolean} boolean indicating whether at least one element is truthy -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* -* var out = any( x ); -* // returns true -* -* @example -* var x = [ 0, 0, 0, 0 ]; -* -* var out = any( x ); -* // returns false -*/ -function any( x ) { - var obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - // If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero... - if ( isComplex128Array( x ) ) { - return internal( reinterpret128( x, 0 ) ); - } - if ( isComplex64Array( x ) ) { - return internal( reinterpret64( x, 0 ) ); - } - // If provided a boolean array, reinterpret as typed array and test for truthiness... - if ( isBooleanArray( x ) ) { - return internal( reinterpretBoolean( x, 0 ) ); - } - return accessors( obj ); - } - return internal( x ); -} - - -// EXPORTS // - -module.exports = any; diff --git a/base/any/package.json b/base/any/package.json deleted file mode 100644 index 52ad73a06..000000000 --- a/base/any/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/any", - "version": "0.0.0", - "description": "Test whether at least one element in an array is truthy.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "any", - "some", - "array.some", - "validate" - ] -} diff --git a/base/any/test/test.js b/base/any/test/test.js deleted file mode 100644 index 39a496065..000000000 --- a/base/any/test/test.js +++ /dev/null @@ -1,272 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Complex64Array = require( './../../../complex64' ); -var Complex128Array = require( './../../../complex128' ); -var BooleanArray = require( './../../../bool' ); -var any = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof any, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `false` (generic)', function test( t ) { - var out; - var arr; - - arr = []; - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `false` (real typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [] ); - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `false` (complex typed array)', function test( t ) { - var out; - var arr; - - arr = new Complex64Array( [] ); - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - - arr = new Complex128Array( [] ); - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `false` (boolean array)', function test( t ) { - var out; - var arr; - - arr = new BooleanArray( [] ); - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `false` (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [] ); - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element is truthy (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, 0, 3 ]; - out = any( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element is truthy (real typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = any( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element is truthy (complex typed array)', function test( t ) { - var out; - var arr; - - arr = new Complex64Array( [ 0.0, 2.0, 0.0, 0.0 ] ); - out = any( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - - arr = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - out = any( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element is truthy (boolean array)', function test( t ) { - var out; - var arr; - - arr = new BooleanArray( [ false, false, true ] ); - out = any( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element is truthy (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 0, 2, 3 ] ); - out = any( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if at least one element is truthy (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - out = any( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements are falsy (generic)', function test( t ) { - var out; - var arr; - - arr = [ 0, 0, 0 ]; - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements are falsy (real typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 0.0, 0.0, 0.0 ] ); - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements are falsy (complex typed array)', function test( t ) { - var out; - var arr; - - arr = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - - arr = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements are falsy (boolean array)', function test( t ) { - var out; - var arr; - - arr = new BooleanArray( [ false, false, false, false ] ); - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements are falsy (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 0, 0, 0 ] ); - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if all elements are falsy (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (generic)', function test( t ) { - var out; - var arr; - - arr = [ 0, , , 0 ]; // eslint-disable-line no-sparse-arrays - out = any( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 0, , , 1 ] ); // eslint-disable-line no-sparse-arrays - out = any( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); diff --git a/base/arraylike2object/README.md b/base/arraylike2object/README.md deleted file mode 100644 index b2ad2f8be..000000000 --- a/base/arraylike2object/README.md +++ /dev/null @@ -1,136 +0,0 @@ - - -# arraylike2object - -> Convert an array-like object to an object likely to have the same "shape". - - - -
- -
- - - - - -
- -## Usage - -```javascript -var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -``` - -#### arraylike2object( x ) - -Converts an array-like object to an object likely to have the same "shape". - -```javascript -var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -// returns {...} -``` - -
- - - - - -
- -## Notes - -- The returned object has the following properties: - - - **data**: reference to the input array. - - **dtype**: input array data type. If unable to resolve the [data type][@stdlib/array/dtype] of the input array, the property value is `null`. - - **accessorProtocol**: `boolean` indicating whether the input uses accessors for getting and setting elements. - - **accessors**: a two-element array whose first element is an accessor for retrieving an array element (i.e., a getter) and whose second element is an accessor for setting an array element (i.e., a setter). - -- The getter accessor accepts two arguments: - - - **data**: input array. - - **idx**: element index. - -- The setter accessor accepts three arguments: - - - **data**: input array. - - **idx**: element index. - - **value**: value to set. - -- This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". - -
- - - - - -
- -## Examples - - - -```javascript -var Complex64Array = require( '@stdlib/array/complex64' ); -var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/arraylike2object/benchmark/benchmark.js b/base/arraylike2object/benchmark/benchmark.js deleted file mode 100644 index 817579aa7..000000000 --- a/base/arraylike2object/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../../float64' ); -var zeros = require( './../../../base/zeros' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/arraylike2object/docs/repl.txt b/base/arraylike2object/docs/repl.txt deleted file mode 100644 index 39828bfe2..000000000 --- a/base/arraylike2object/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array uses accessors for getting - and setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/base/arraylike2object/docs/types/index.d.ts b/base/arraylike2object/docs/types/index.d.ts deleted file mode 100644 index 651e9d5c9..000000000 --- a/base/arraylike2object/docs/types/index.d.ts +++ /dev/null @@ -1,1037 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Data type. - */ - dtype: 'float64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Data type. - */ - dtype: 'float32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Data type. - */ - dtype: 'int32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Data type. - */ - dtype: 'int16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Data type. - */ - dtype: 'int8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Data type. - */ - dtype: 'uint32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Data type. - */ - dtype: 'uint16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Data type. - */ - dtype: 'uint8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Data type. - */ - dtype: 'uint8c'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Data type. - */ - dtype: 'complex128'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Data type. - */ - dtype: 'complex64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Data type. - */ - dtype: 'generic'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 -* }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/base/arraylike2object/docs/types/test.ts b/base/arraylike2object/docs/types/test.ts deleted file mode 100644 index 45e7fd18d..000000000 --- a/base/arraylike2object/docs/types/test.ts +++ /dev/null @@ -1,126 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @returns array-like object -*/ -function accessorArray(): AccessorArrayLike { - const arr: AccessorArrayLike = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @returns array-like object -*/ -function arrayLike(): ArrayLike { - const arr: ArrayLike = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/base/arraylike2object/examples/index.js b/base/arraylike2object/examples/index.js deleted file mode 100644 index 553814213..000000000 --- a/base/arraylike2object/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( './../../../complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/base/arraylike2object/lib/index.js b/base/arraylike2object/lib/index.js deleted file mode 100644 index c79698c66..000000000 --- a/base/arraylike2object/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array/base/arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/arraylike2object/lib/main.js b/base/arraylike2object/lib/main.js deleted file mode 100644 index a975488e9..000000000 --- a/base/arraylike2object/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var getter = require( './../../../base/getter' ); -var setter = require( './../../../base/setter' ); -var accessorGetter = require( './../../../base/accessor-getter' ); -var accessorSetter = require( './../../../base/accessor-setter' ); -var dtype = require( './../../../dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/base/arraylike2object/package.json b/base/arraylike2object/package.json deleted file mode 100644 index cc384c4e1..000000000 --- a/base/arraylike2object/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/arraylike2object", - "version": "0.0.0", - "description": "Convert an array-like object to an object likely to have the same \"shape\".", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "standardize", - "shape", - "hidden", - "objectify", - "meta", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/base/arraylike2object/test/test.js b/base/arraylike2object/test/test.js deleted file mode 100644 index afbcee1b4..000000000 --- a/base/arraylike2object/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../../float64' ); -var Complex64Array = require( './../../../complex64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); diff --git a/base/assert/README.md b/base/assert/README.md deleted file mode 100644 index 4b0bc9acd..000000000 --- a/base/assert/README.md +++ /dev/null @@ -1,230 +0,0 @@ - - -# assert - -> Base array assertion utilities. - -
- -## Usage - -```javascript -var ns = require( '@stdlib/array/base/assert' ); -``` - -#### ns - -Assertion utilities. - -```javascript -var o = ns; -// returns {...} -``` - -The namespace exports the following: - - - -
- -- [`contains( x, value )`][@stdlib/array/base/assert/contains]: test if an array contains a provided search value. -- [`hasEqualValuesIndexed( x, y )`][@stdlib/array/base/assert/has-equal-values-indexed]: test if two indexed arrays have equal values. -- [`hasEqualValues( x, y )`][@stdlib/array/base/assert/has-equal-values]: test if two arrays have equal values. -- [`hasSameValues( x, y )`][@stdlib/array/base/assert/has-same-values]: test if two arrays have the same values. -- [`isAccessorArray( value )`][@stdlib/array/base/assert/is-accessor-array]: test if an array-like object supports the accessor (get/set) protocol. -- [`isBooleanDataType( value )`][@stdlib/array/base/assert/is-boolean-data-type]: test if an input value is a supported array boolean data type. -- [`isBooleanArray( value )`][@stdlib/array/base/assert/is-booleanarray]: test if a value is a `BooleanArray`. -- [`isByteOrder( value )`][@stdlib/array/base/assert/is-byte-order]: test if an input value is a supported array byte order. -- [`isComplexFloatingPointDataType( value )`][@stdlib/array/base/assert/is-complex-floating-point-data-type]: test if an input value is a supported array complex-valued floating-point data type. -- [`isComplexTypedArray( value )`][@stdlib/array/base/assert/is-complex-typed-array]: test if a value is a complex typed array. -- [`isComplex128Array( value )`][@stdlib/array/base/assert/is-complex128array]: test if a value is a `Complex128Array`. -- [`isComplex64Array( value )`][@stdlib/array/base/assert/is-complex64array]: test if a value is a `Complex64Array`. -- [`isDataType( value )`][@stdlib/array/base/assert/is-data-type]: test if an input value is a supported array data type. -- [`isFloatingPointDataType( value )`][@stdlib/array/base/assert/is-floating-point-data-type]: test if an input value is a supported array floating-point data type. -- [`isIntegerDataType( value )`][@stdlib/array/base/assert/is-integer-data-type]: test if an input value is a supported array integer data type. -- [`isMostlySafeDataTypeCast( from, to )`][@stdlib/array/base/assert/is-mostly-safe-data-type-cast]: determine whether an array data type can be safely cast or, for floating-point data types, downcast to another array data type. -- [`isNumericDataType( value )`][@stdlib/array/base/assert/is-numeric-data-type]: test if an input value is a supported array numeric data type. -- [`isRealDataType( value )`][@stdlib/array/base/assert/is-real-data-type]: test if an input value is a supported array real-valued data type. -- [`isRealFloatingPointDataType( value )`][@stdlib/array/base/assert/is-real-floating-point-data-type]: test if an input value is a supported array real-valued floating-point data type. -- [`isSafeDataTypeCast( from, to )`][@stdlib/array/base/assert/is-safe-data-type-cast]: determine whether an array data type can be safely cast to another array data type. -- [`isSameKindDataTypeCast( from, to )`][@stdlib/array/base/assert/is-same-kind-data-type-cast]: determine whether an array data type can be safely cast to, or is of the same "kind" as, another array data type. -- [`isSignedIntegerDataType( value )`][@stdlib/array/base/assert/is-signed-integer-data-type]: test if an input value is a supported array signed integer data type. -- [`isSortedAscending( x )`][@stdlib/array/base/assert/is-sorted-ascending]: test if an array is sorted in ascending order. -- [`isUnsignedIntegerDataType( value )`][@stdlib/array/base/assert/is-unsigned-integer-data-type]: test if an input value is a supported array unsigned integer data type. - -
- - - -
- - - -
- -## Examples - - - - - -```javascript -var ns = require( '@stdlib/array/base/assert' ); -var dtype = require( '@stdlib/array/dtype' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Int32Array = require( '@stdlib/array/int32' ); -var Uint8Array = require( '@stdlib/array/uint8' ); -var Complex128Array = require( '@stdlib/array/complex128' ); - -// Create various arrays: -var arr1 = new Float64Array( [ 1.1, 2.2, 3.3 ] ); -var arr2 = new Int32Array( [ 1, 2, 3 ] ); -var arr3 = new Uint8Array( [ 1, 2, 3 ] ); -var arr4 = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0 ] ); // two complex numbers: 1+1i, 2+2i - -// Get data types: -var dt1 = dtype( arr1 ); -var dt2 = dtype( arr2 ); -var dt3 = dtype( arr3 ); -var dt4 = dtype( arr4 ); - -// Check data types: -console.log( dt1 + ' is floating-point data type: ' + ns.isFloatingPointDataType( dt1 ) ); -// => 'float64 is floating-point data type: true' - -console.log( dt2 + ' is integer data type: ' + ns.isIntegerDataType( dt2 ) ); -// => 'int32 is integer data type: true' - -console.log( dt3 + ' is unsigned integer data type: ' + ns.isUnsignedIntegerDataType( dt3 ) ); -// => 'uint8 is unsigned integer data type: true' - -console.log( dt4 + ' is complex floating-point data type: ' + ns.isComplexFloatingPointDataType( dt4 ) ); -// => 'complex128 is complex floating-point data type: true' - -// Check if arrays have the same values: -console.log( 'arr2 and arr3 have same values: ' + ns.hasSameValues( arr2, arr3 ) ); -// => 'arr2 and arr3 have same values: true' - -console.log( 'arr1 and arr2 have same values: ' + ns.hasSameValues( arr1, arr2 ) ); -// => 'arr1 and arr2 have same values: false' - -// Check safe data type casts: -console.log( 'Can safely cast from ' + dt2 + ' to ' + dt1 + ': ' + ns.isSafeDataTypeCast( dt2, dt1 ) ); -// => 'Can safely cast from int32 to float64: true' - -console.log( 'Can safely cast from ' + dt1 + ' to ' + dt2 + ': ' + ns.isSafeDataTypeCast( dt1, dt2 ) ); -// => 'Can safely cast from float64 to int32: false' - -console.log( 'Can safely cast from ' + dt3 + ' to ' + dt2 + ': ' + ns.isSafeDataTypeCast( dt3, dt2 ) ); -// => 'Can safely cast from uint8 to int32: true' - -console.log( 'Can safely cast from ' + dt4 + ' to ' + dt1 + ': ' + ns.isSafeDataTypeCast( dt4, dt1 ) ); -// => 'Can safely cast from complex128 to float64: false' - -// Check if arrays contain specific values: -console.log( 'arr1 contains 2.2: ' + ns.contains( arr1, 2.2 ) ); -// => 'arr1 contains 2.2: true' - -console.log( 'arr2 contains 2: ' + ns.contains( arr2, 2 ) ); -// => 'arr2 contains 2: true' - -console.log( 'arr2 contains 2.2: ' + ns.contains( arr2, 2.2 ) ); -// => 'arr2 contains 2.2: false' - -// Check complex array types: -console.log( 'arr4 is Complex128Array: ' + ns.isComplex128Array( arr4 ) ); -// => 'arr4 is Complex128Array: true' - -console.log( 'arr4 is complex typed array: ' + ns.isComplexTypedArray( arr4 ) ); -// => 'arr4 is complex typed array: true' -``` - -
- - - - - - - - - - - - - - diff --git a/base/assert/contains/README.md b/base/assert/contains/README.md deleted file mode 100644 index b4ab728d0..000000000 --- a/base/assert/contains/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# contains - -> Test if an array contains a provided search value. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var contains = require( '@stdlib/array/base/assert/contains' ); -``` - -#### contains( x, value ) - -Tests if an array contains a provided search value. - -```javascript -var x = [ 1, 2, 3 ]; - -var out = contains( x, 2 ); -// returns true -``` - -#### contains.factory( x ) - -Returns a function which tests if an array contains a provided search value. - -```javascript -var x = [ 1, 2, 3 ]; - -var fcn = contains.factory( x ); -// returns - -var out = fcn( 2 ); -// returns true - -out = fcn( 4 ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var AccessorArray = require( '@stdlib/array/base/accessor' ); -var contains = require( '@stdlib/array/base/assert/contains' ); - -// Create an accessor array: -var arr = new AccessorArray( [ 1, 2, 3, 4 ] ); - -// Check whether the array contains various values... -var bool = contains( arr, 2 ); -// returns true - -bool = contains( arr, 4 ); -// returns true - -bool = contains( arr, 9 ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/contains/benchmark/benchmark.accessors.length.js b/base/assert/contains/benchmark/benchmark.accessors.length.js deleted file mode 100644 index dc03531a3..000000000 --- a/base/assert/contains/benchmark/benchmark.accessors.length.js +++ /dev/null @@ -1,97 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var ones = require( './../../../../base/ones' ); -var AccessorArray = require( './../../../../base/accessor' ); -var pkg = require( './../package.json' ).name; -var contains = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = new AccessorArray( ones( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = contains( x, 2 ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+'::accessors:len='+len, f ); - } -} - -main(); diff --git a/base/assert/contains/benchmark/benchmark.length.js b/base/assert/contains/benchmark/benchmark.length.js deleted file mode 100644 index 7acc8178e..000000000 --- a/base/assert/contains/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var ones = require( './../../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var contains = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = contains( x, 2 ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/assert/contains/docs/repl.txt b/base/assert/contains/docs/repl.txt deleted file mode 100644 index a8c177f92..000000000 --- a/base/assert/contains/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( x, value ) - Tests if an array contains a provided search value. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - value: any - Search value. - - Returns - ------- - out: boolean - Boolean indicating if an array contains a search value. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3 ], 2 ) - true - - -{{alias}}.factory( x ) - Returns a function which tests if an array contains a provided search value. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - fcn: Function - Function which tests if an array contains a provided search value. - - Examples - -------- - > var f = {{alias}}.factory( [ 1, 2, 3 ] ); - > f( 2 ) - true - > f( 4 ) - false - - See Also - -------- - diff --git a/base/assert/contains/docs/types/index.d.ts b/base/assert/contains/docs/types/index.d.ts deleted file mode 100644 index b199a25c9..000000000 --- a/base/assert/contains/docs/types/index.d.ts +++ /dev/null @@ -1,94 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Unary function which tests whether an array contains a provided search value. -* -* @param value - search value -* @returns boolean indicating whether an array contains a search value -*/ -type Unary = ( x: any ) => boolean; - -/** -* Interface for testing whether an array contains a provided search value. -*/ -interface Contains { - /** - * Tests if an array contains a provided search value. - * - * @param x - input array - * @param value - search value - * @returns boolean indicating if an array contains a search value - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = contains( x, 2 ); - * // returns true - */ - ( x: Collection, value: any ): boolean; - - /** - * Returns a function to test if an array contains a provided search value. - * - * @param x - input array - * @returns function to test if an array contains a search value - * - * @example - * var fcn = contains.factory( [ 1, 2, 3 ] ); - * - * var bool = fcn( 2 ); - * // returns true - */ - factory( x: Collection ): Unary; -} - -/** -* Tests if an array contains a provided search value. -* -* @param x - input array -* @param value - search value -* @returns boolean indicating if an array contains a search value -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = contains( x, 2 ); -* // returns true -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var fcn = contains.factory( x ); -* // returns -* -* var out = fcn( 2 ); -* // returns true -*/ -declare var contains: Contains; - - -// EXPORTS // - -export = contains; diff --git a/base/assert/contains/docs/types/test.ts b/base/assert/contains/docs/types/test.ts deleted file mode 100644 index 3a513ce58..000000000 --- a/base/assert/contains/docs/types/test.ts +++ /dev/null @@ -1,62 +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. -*/ - -import contains = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - contains( [ 1, 2, 3 ], 2 ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - contains( 5, 2 ); // $ExpectError - contains( true, 2 ); // $ExpectError - contains( false, 2 ); // $ExpectError - contains( null, 2 ); // $ExpectError - contains( {}, 2 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - contains(); // $ExpectError - contains( [ 1, 2, 3 ] ); // $ExpectError - contains( [ 1, 2, 3 ], 2, 3 ); // $ExpectError -} - -// Attached to the function is a `factory` method which returns a function... -{ - contains.factory( [ 1, 2, 3 ] ); // $ExpectType Unary -} - -// The function returned by the `factory` method returns a boolean... -{ - const fcn = contains.factory( [ 1, 2, 3 ] ); - fcn( 2 ); // $ExpectType boolean -} - -// The compiler throws an error if the `factory` method is provided an unsupported number of arguments... -{ - const fcn = contains.factory( [ 1, 2, 3 ] ); - - fcn(); // $ExpectError - fcn( 1, 2 ); // $ExpectError -} diff --git a/base/assert/contains/examples/index.js b/base/assert/contains/examples/index.js deleted file mode 100644 index 734fa2fcb..000000000 --- a/base/assert/contains/examples/index.js +++ /dev/null @@ -1,38 +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'; - -var AccessorArray = require( './../../../../base/accessor' ); -var contains = require( './../lib' ); - -// Create an accessor array: -var arr = new AccessorArray( [ 1, 2, 3, 4 ] ); - -// Check whether the array contains various values... -var bool = contains( arr, 2 ); -console.log( bool ); -// => true - -bool = contains( arr, 4 ); -console.log( bool ); -// => true - -bool = contains( arr, 9 ); -console.log( bool ); -// => false diff --git a/base/assert/contains/lib/factory.js b/base/assert/contains/lib/factory.js deleted file mode 100644 index a04912a06..000000000 --- a/base/assert/contains/lib/factory.js +++ /dev/null @@ -1,106 +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 isCollection = require( '@stdlib/assert/is-collection' ); -var isAccessorArray = require( './../../../../base/assert/is-accessor-array' ); -var accessorGetter = require( './../../../../base/accessor-getter' ); -var dtype = require( './../../../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns a function to tests if an array contains a provided search value. -* -* @param {Collection} x - input array -* @throws {TypeError} must provide an array-like object -* @returns {Function} function to test if an array contains a search value -* -* @example -* var contains = factory( [ 1, 2, 3 ] ); -* // returns -* -* var bool = contains( 2 ); -* // returns true -*/ -function factory( x ) { - var get; - var len; - var dt; - - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', x ) ); - } - // Resolve the input array data type: - dt = dtype( x ); - - // Resolve an accessor for retrieving input array elements: - if ( isAccessorArray( x ) ) { - get = accessorGetter( dt ); - } - // Get the number of elements over which to iterate: - len = x.length; - - return ( get === void 0 ) ? contains : accessors; - /** - * Tests if an array contains a provided search value. - * - * @private - * @param {*} value - search value - * @returns {boolean} boolean indicating if an array contains a search value - * - * @example - * var out = contains( [ 1, 2, 3 ], 2 ); - * // returns true - */ - function contains( value ) { - var i; - for ( i = 0; i < len; i++ ) { - if ( x[ i ] === value ) { - return true; - } - } - return false; - } - /** - * Tests if an array contains a provided search value. - * - * @private - * @param {*} value - search value - * @returns {boolean} boolean indicating if an array contains a search value - */ - function accessors( value ) { - var i; - for ( i = 0; i < len; i++ ) { - if ( get( x, i ) === value ) { - return true; - } - } - return false; - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/base/assert/contains/lib/index.js b/base/assert/contains/lib/index.js deleted file mode 100644 index 4ef6bd959..000000000 --- a/base/assert/contains/lib/index.js +++ /dev/null @@ -1,49 +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'; - -/** -* Test if an array contains a provided search value. -* -* @module @stdlib/array/base/assert/contains -* -* @example -* var contains = require( '@stdlib/array/base/assert/contains' ); -* -* var out = contains( [ 1, 2, 3 ], 2 ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "factory": "main.factory" } diff --git a/base/assert/contains/lib/main.js b/base/assert/contains/lib/main.js deleted file mode 100644 index 6cd0104ed..000000000 --- a/base/assert/contains/lib/main.js +++ /dev/null @@ -1,72 +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 isAccessorArray = require( './../../../../base/assert/is-accessor-array' ); -var accessorGetter = require( './../../../../base/accessor-getter' ); -var getter = require( './../../../../base/getter' ); -var dtype = require( './../../../../dtype' ); - - -// MAIN // - -/** -* Tests if an array contains a provided search value. -* -* @param {Collection} x - input array -* @param {*} value - search value -* @returns {boolean} boolean indicating if an array contains a search value -* -* @example -* var out = contains( [ 1, 2, 3 ], 2 ); -* // returns true -*/ -function contains( x, value ) { - var len; - var get; - var dt; - var i; - - // Resolve the input array data type: - dt = dtype( x ); - - // Resolve an accessor for retrieving input array elements: - if ( isAccessorArray( x ) ) { - get = accessorGetter( dt ); - } else { - get = getter( dt ); - } - // Get the number of elements over which to iterate: - len = x.length; - - // Loop over the elements... - for ( i = 0; i < len; i++ ) { - if ( get( x, i ) === value ) { - return true; - } - } - return false; -} - - -// EXPORTS // - -module.exports = contains; diff --git a/base/assert/contains/package.json b/base/assert/contains/package.json deleted file mode 100644 index 62e2812c1..000000000 --- a/base/assert/contains/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/contains", - "version": "0.0.0", - "description": "Test if an array contains a provided search value.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "contains", - "search", - "assert" - ] -} diff --git a/base/assert/contains/test/test.factory.js b/base/assert/contains/test/test.factory.js deleted file mode 100644 index 8e0e6c965..000000000 --- a/base/assert/contains/test/test.factory.js +++ /dev/null @@ -1,123 +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 AccessorArray = require( './../../../../base/accessor' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided '+values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( value ); - }; - } -}); - -tape( 'the function returns a function which searches an array-like object', function test( t ) { - var expected; - var contains; - var values; - var x; - var i; - - values = [ - 0, - 1, - 2, - 3, - 4, - 5 - ]; - expected = [ - false, - true, - true, - true, - false, - false - ]; - x = [ 1, 2, 3 ]; - contains = factory( x ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( contains( values[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns a function which searches an array-like object (accessors)', function test( t ) { - var expected; - var contains; - var values; - var x; - var i; - - values = [ - 0, - 1, - 2, - 3, - 4, - 5 - ]; - expected = [ - false, - true, - true, - true, - false, - false - ]; - x = new AccessorArray( [ 1, 2, 3 ] ); - contains = factory( x ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( contains( values[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); diff --git a/base/assert/contains/test/test.js b/base/assert/contains/test/test.js deleted file mode 100644 index f84ea72a0..000000000 --- a/base/assert/contains/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var contains = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof contains, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `factory` method', function test( t ) { - t.strictEqual( hasOwnProp( contains, 'factory' ), true, 'has property' ); - t.strictEqual( typeof contains.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/base/assert/contains/test/test.main.js b/base/assert/contains/test/test.main.js deleted file mode 100644 index 4141919ca..000000000 --- a/base/assert/contains/test/test.main.js +++ /dev/null @@ -1,92 +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 AccessorArray = require( './../../../../base/accessor' ); -var contains = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof contains, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function searches an array-like object', function test( t ) { - var expected; - var values; - var x; - var i; - - values = [ - 0, - 1, - 2, - 3, - 4, - 5 - ]; - expected = [ - false, - true, - true, - true, - false, - false - ]; - x = [ 1, 2, 3 ]; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( contains( x, values[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function searches an array-like object (accessors)', function test( t ) { - var expected; - var values; - var x; - var i; - - values = [ - 0, - 1, - 2, - 3, - 4, - 5 - ]; - expected = [ - false, - true, - true, - true, - false, - false - ]; - x = new AccessorArray( [ 1, 2, 3 ] ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( contains( x, values[ i ] ), expected[ i ], 'returns expected value' ); - } - t.end(); -}); diff --git a/base/assert/docs/types/index.d.ts b/base/assert/docs/types/index.d.ts deleted file mode 100644 index 88bcf4a32..000000000 --- a/base/assert/docs/types/index.d.ts +++ /dev/null @@ -1,776 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable max-lines */ - -import contains = require( './../../../../base/assert/contains' ); -import hasEqualValues = require( './../../../../base/assert/has-equal-values' ); -import hasEqualValuesIndexed = require( './../../../../base/assert/has-equal-values-indexed' ); -import hasSameValues = require( './../../../../base/assert/has-same-values' ); -import isAccessorArray = require( './../../../../base/assert/is-accessor-array' ); -import isBooleanDataType = require( './../../../../base/assert/is-boolean-data-type' ); -import isBooleanArray = require( './../../../../base/assert/is-booleanarray' ); -import isByteOrder = require( './../../../../base/assert/is-byte-order' ); -import isComplexFloatingPointDataType = require( './../../../../base/assert/is-complex-floating-point-data-type' ); -import isComplexTypedArray = require( './../../../../base/assert/is-complex-typed-array' ); -import isComplex64Array = require( './../../../../base/assert/is-complex64array' ); -import isComplex128Array = require( './../../../../base/assert/is-complex128array' ); -import isDataType = require( './../../../../base/assert/is-data-type' ); -import isFloatingPointDataType = require( './../../../../base/assert/is-floating-point-data-type' ); -import isIntegerDataType = require( './../../../../base/assert/is-integer-data-type' ); -import isMostlySafeDataTypeCast = require( './../../../../base/assert/is-mostly-safe-data-type-cast' ); -import isNumericDataType = require( './../../../../base/assert/is-numeric-data-type' ); -import isRealDataType = require( './../../../../base/assert/is-real-data-type' ); -import isRealFloatingPointDataType = require( './../../../../base/assert/is-real-floating-point-data-type' ); -import isSafeDataTypeCast = require( './../../../../base/assert/is-safe-data-type-cast' ); -import isSameKindDataTypeCast = require( './../../../../base/assert/is-same-kind-data-type-cast' ); -import isSignedIntegerDataType = require( './../../../../base/assert/is-signed-integer-data-type' ); -import isSortedAscending = require( './../../../../base/assert/is-sorted-ascending' ); -import isUnsignedIntegerDataType = require( './../../../../base/assert/is-unsigned-integer-data-type' ); - -/** -* Interface describing the `assert` namespace. -*/ -interface Namespace { - /** - * Tests if an array contains a provided search value. - * - * @param x - input array - * @param value - search value - * @returns boolean indicating if an array contains a search value - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = ns.contains( x, 2 ); - * // returns true - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var fcn = ns.contains.factory( x ); - * // returns - * - * var out = fcn( 2 ); - * // returns true - */ - contains: typeof contains; - - /** - * Tests if two arrays have equal values. - * - * ## Notes - * - * - If provided arrays of unequal length, the function returns `false`. - * - * @param x - first input array - * @param y - second input array - * @returns boolean indicating whether both arrays have equal values - * - * @example - * var x = [ 0, 0, 1, 0 ]; - * var y = [ 0, 0, 1, 0 ]; - * - * var out = ns.hasEqualValues( x, y ); - * // returns true - */ - hasEqualValues: typeof hasEqualValues; - - /** - * Tests if two indexed arrays have equal values. - * - * ## Notes - * - * - If provided arrays of unequal length, the function returns `false`. - * - * @param x - first input array - * @param y - second input array - * @returns boolean indicating whether both arrays have equal values - * - * @example - * var x = [ 0, 0, 1, 0 ]; - * var y = [ 0, 0, 1, 0 ]; - * - * var out = ns.hasEqualValuesIndexed( x, y ); - * // returns true - */ - hasEqualValuesIndexed: typeof hasEqualValuesIndexed; - - /** - * Tests if two arrays have the same values. - * - * ## Notes - * - * - If provided arrays of unequal length, the function returns `false`. - * - * @param x - first input array - * @param y - second input array - * @returns boolean indicating whether both arrays have the same values - * - * @example - * var x = [ 0, 0, 1, 0 ]; - * var y = [ 0, 0, 1, 0 ]; - * - * var out = ns.hasSameValues( x, y ); - * // returns true - */ - hasSameValues: typeof hasSameValues; - - /** - * Tests if an array-like object supports the accessor (get/set) protocol. - * - * @param value - value to test - * @returns boolean indicating whether a value is an accessor array - * - * @example - * var Complex128Array = require( './../../../../complex128' ); - * - * var arr = new Complex128Array( 10 ); - * var bool = ns.isAccessorArray( arr ); - * // returns true - * - * @example - * var bool = ns.isAccessorArray( [] ); - * // returns false - */ - isAccessorArray: typeof isAccessorArray; - - /** - * Tests whether an input value is a supported array boolean data type. - * - * @param v - value to test - * @returns boolean indicating whether an input value is a supported array boolean data type - * - * @example - * var bool = ns.isBooleanDataType( 'bool' ); - * // returns true - * - * bool = ns.isBooleanDataType( 'complex64' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'complex128' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'float32' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'float64' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'generic' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'int16' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'int32' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'int8' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'uint16' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'uint32' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'uint8' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'uint8c' ); - * // returns false - * - * bool = ns.isBooleanDataType( 'foo' ); - * // returns false - */ - isBooleanDataType: typeof isBooleanDataType; - - /** - * Tests if a value is a `BooleanArray`. - * - * @param value - value to test - * @returns boolean indicating whether a value is a `BooleanArray` - * - * @example - * var BooleanArray = require( './../../../../bool' ); - * - * var arr = new BooleanArray( 10 ); - * var bool = ns.isBooleanArray( arr ); - * // returns true - * - * @example - * var bool = ns.isBooleanArray( [] ); - * // returns false - */ - isBooleanArray: typeof isBooleanArray; - - /** - * Tests whether an input value is a supported array byte order. - * - * @param v - value to test - * @returns boolean indicating whether an input value is a supported array byte order - * - * @example - * var bool = ns.isByteOrder( 'little-endian' ); - * // returns true - * - * bool = ns.isByteOrder( 'big-endian' ); - * // returns true - * - * bool = ns.isByteOrder( 'foo' ); - * // returns false - */ - isByteOrder: typeof isByteOrder; - - /** - * Tests whether an input value is a supported array complex-valued floating-point data type. - * - * @param v - value to test - * @returns boolean indicating whether an input value is a supported array complex-valued floating-point data type - * - * @example - * var bool = ns.isComplexFloatingPointDataType( 'complex64' ); - * // returns true - * - * bool = ns.isComplexFloatingPointDataType( 'complex128' ); - * // returns true - * - * bool = ns.isComplexFloatingPointDataType( 'float32' ); - * // returns false - * - * bool = ns.isComplexFloatingPointDataType( 'float64' ); - * // returns false - * - * bool = ns.isComplexFloatingPointDataType( 'generic' ); - * // returns false - * - * bool = ns.isComplexFloatingPointDataType( 'int16' ); - * // returns false - * - * bool = ns.isComplexFloatingPointDataType( 'int32' ); - * // returns false - * - * bool = ns.isComplexFloatingPointDataType( 'int8' ); - * // returns false - * - * bool = ns.isComplexFloatingPointDataType( 'uint16' ); - * // returns false - * - * bool = ns.isComplexFloatingPointDataType( 'uint32' ); - * // returns false - * - * bool = ns.isComplexFloatingPointDataType( 'uint8' ); - * // returns false - * - * bool = ns.isComplexFloatingPointDataType( 'uint8c' ); - * // returns false - * - * bool = ns.isComplexFloatingPointDataType( 'foo' ); - * // returns false - */ - isComplexFloatingPointDataType: typeof isComplexFloatingPointDataType; - - /** - * Tests if a value is a complex typed array. - * - * @param value - value to test - * @returns boolean indicating whether a value is complex typed array - * - * @example - * var Complex128Array = require( './../../../../complex128' ); - * - * var arr = new Complex128Array( 10 ); - * var bool = ns.isComplexTypedArray( arr ); - * // returns true - * - * @example - * var bool = ns.isComplexTypedArray( [] ); - * // returns false - */ - isComplexTypedArray: typeof isComplexTypedArray; - - /** - * Tests if a value is a `Complex64Array`. - * - * @param value - value to test - * @returns boolean indicating whether a value is a `Complex64Array` - * - * @example - * var Complex64Array = require( './../../../../complex64' ); - * - * var arr = new Complex64Array( 10 ); - * var bool = ns.isComplex64Array( arr ); - * // returns true - * - * @example - * var bool = ns.isComplex64Array( [] ); - * // returns false - */ - isComplex64Array: typeof isComplex64Array; - - /** - * Tests if a value is a `Complex128Array`. - * - * @param value - value to test - * @returns boolean indicating whether a value is a `Complex128Array` - * - * @example - * var Complex128Array = require( './../../../../complex128' ); - * - * var arr = new Complex128Array( 10 ); - * var bool = ns.isComplex128Array( arr ); - * // returns true - * - * @example - * var bool = ns.isComplex128Array( [] ); - * // returns false - */ - isComplex128Array: typeof isComplex128Array; - - /** - * Tests whether an input value is a supported array data type. - * - * @param v - value to test - * @returns boolean indicating whether an input value is a supported array data type - * - * @example - * var bool = ns.isDataType( 'float32' ); - * // returns true - * - * bool = ns.isDataType( 'float64' ); - * // returns true - * - * bool = ns.isDataType( 'generic' ); - * // returns true - * - * bool = ns.isDataType( 'int16' ); - * // returns true - * - * bool = ns.isDataType( 'int32' ); - * // returns true - * - * bool = ns.isDataType( 'int8' ); - * // returns true - * - * bool = ns.isDataType( 'uint16' ); - * // returns true - * - * bool = ns.isDataType( 'uint32' ); - * // returns true - * - * bool = ns.isDataType( 'uint8' ); - * // returns true - * - * bool = ns.isDataType( 'uint8c' ); - * // returns true - * - * bool = ns.isDataType( 'foo' ); - * // returns false - */ - isDataType: typeof isDataType; - - /** - * Tests whether an input value is a supported array floating-point data type. - * - * @param v - value to test - * @returns boolean indicating whether an input value is a supported array floating-point data type - * - * @example - * var bool = ns.isFloatingPointDataType( 'float32' ); - * // returns true - * - * bool = ns.isFloatingPointDataType( 'float64' ); - * // returns true - * - * bool = ns.isFloatingPointDataType( 'generic' ); - * // returns false - * - * bool = ns.isFloatingPointDataType( 'int16' ); - * // returns false - * - * bool = ns.isFloatingPointDataType( 'int32' ); - * // returns false - * - * bool = ns.isFloatingPointDataType( 'int8' ); - * // returns false - * - * bool = ns.isFloatingPointDataType( 'uint16' ); - * // returns false - * - * bool = ns.isFloatingPointDataType( 'uint32' ); - * // returns false - * - * bool = ns.isFloatingPointDataType( 'uint8' ); - * // returns false - * - * bool = ns.isFloatingPointDataType( 'uint8c' ); - * // returns false - * - * bool = ns.isFloatingPointDataType( 'foo' ); - * // returns false - */ - isFloatingPointDataType: typeof isFloatingPointDataType; - - /** - * Tests whether an input value is a supported array integer (i.e., signed or unsigned integer) data type. - * - * @param v - value to test - * @returns boolean indicating whether an input value is a supported array integer data type - * - * @example - * var bool = ns.isIntegerDataType( 'float32' ); - * // returns false - * - * bool = ns.isIntegerDataType( 'float64' ); - * // returns false - * - * bool = ns.isIntegerDataType( 'generic' ); - * // returns false - * - * bool = ns.isIntegerDataType( 'int16' ); - * // returns true - * - * bool = ns.isIntegerDataType( 'int32' ); - * // returns true - * - * bool = ns.isIntegerDataType( 'int8' ); - * // returns true - * - * bool = ns.isIntegerDataType( 'uint16' ); - * // returns true - * - * bool = ns.isIntegerDataType( 'uint32' ); - * // returns true - * - * bool = ns.isIntegerDataType( 'uint8' ); - * // returns true - * - * bool = ns.isIntegerDataType( 'uint8c' ); - * // returns true - * - * bool = ns.isIntegerDataType( 'foo' ); - * // returns false - */ - isIntegerDataType: typeof isIntegerDataType; - - /** - * Returns a boolean indicating if a provided array data type can be safely cast or, for floating-point data types, downcast to another array data type. - * - * @param from - array data type - * @param to - array data type - * @returns boolean indicating if a data type can be cast to another data type - * - * @example - * var bool = ns.isMostlySafeDataTypeCast( 'float32', 'float64' ); - * // returns true - * - * bool = ns.isMostlySafeDataTypeCast( 'float64', 'int32' ); - * // returns false - */ - isMostlySafeDataTypeCast: typeof isMostlySafeDataTypeCast; - - /** - * Tests whether an input value is a supported array numeric data type. - * - * @param v - value to test - * @returns boolean indicating whether an input value is a supported array numeric data type - * - * @example - * var bool = ns.isNumericDataType( 'float32' ); - * // returns true - * - * bool = ns.isNumericDataType( 'float64' ); - * // returns true - * - * bool = ns.isNumericDataType( 'generic' ); - * // returns false - * - * bool = ns.isNumericDataType( 'int16' ); - * // returns true - * - * bool = ns.isNumericDataType( 'int32' ); - * // returns true - * - * bool = ns.isNumericDataType( 'int8' ); - * // returns true - * - * bool = ns.isNumericDataType( 'uint16' ); - * // returns true - * - * bool = ns.isNumericDataType( 'uint32' ); - * // returns true - * - * bool = ns.isNumericDataType( 'uint8' ); - * // returns true - * - * bool = ns.isNumericDataType( 'uint8c' ); - * // returns true - * - * bool = ns.isNumericDataType( 'foo' ); - * // returns false - */ - isNumericDataType: typeof isNumericDataType; - - /** - * Tests whether an input value is a supported array real-valued data type. - * - * @param v - value to test - * @returns boolean indicating whether an input value is a supported array real-valued data type - * - * @example - * var bool = ns.isRealDataType( 'float32' ); - * // returns true - * - * bool = ns.isRealDataType( 'float64' ); - * // returns true - * - * bool = ns.isRealDataType( 'complex128' ); - * // returns false - * - * bool = ns.isRealDataType( 'generic' ); - * // returns false - * - * bool = ns.isRealDataType( 'int16' ); - * // returns true - * - * bool = ns.isRealDataType( 'int32' ); - * // returns true - * - * bool = ns.isRealDataType( 'int8' ); - * // returns true - * - * bool = ns.isRealDataType( 'uint16' ); - * // returns true - * - * bool = ns.isRealDataType( 'uint32' ); - * // returns true - * - * bool = ns.isRealDataType( 'uint8' ); - * // returns true - * - * bool = ns.isRealDataType( 'uint8c' ); - * // returns true - * - * bool = ns.isRealDataType( 'foo' ); - * // returns false - */ - isRealDataType: typeof isRealDataType; - - /** - * Tests whether an input value is a supported array real-valued floating-point data type. - * - * @param v - value to test - * @returns boolean indicating whether an input value is a supported array real-valued floating-point data type - * - * @example - * var bool = ns.isRealFloatingPointDataType( 'float32' ); - * // returns true - * - * bool = ns.isRealFloatingPointDataType( 'float64' ); - * // returns true - * - * bool = ns.isRealFloatingPointDataType( 'generic' ); - * // returns false - * - * bool = ns.isRealFloatingPointDataType( 'int16' ); - * // returns false - * - * bool = ns.isRealFloatingPointDataType( 'int32' ); - * // returns false - * - * bool = ns.isRealFloatingPointDataType( 'int8' ); - * // returns false - * - * bool = ns.isRealFloatingPointDataType( 'uint16' ); - * // returns false - * - * bool = ns.isRealFloatingPointDataType( 'uint32' ); - * // returns false - * - * bool = ns.isRealFloatingPointDataType( 'uint8' ); - * // returns false - * - * bool = ns.isRealFloatingPointDataType( 'uint8c' ); - * // returns false - * - * bool = ns.isRealFloatingPointDataType( 'foo' ); - * // returns false - */ - isRealFloatingPointDataType: typeof isRealFloatingPointDataType; - - /** - * Returns a boolean indicating if a provided array data type can be safely cast to another array data type. - * - * @param from - array data type - * @param to - array data type - * @returns boolean indicating if a data type can be safely cast to another data type - * - * @example - * var bool = ns.isSafeDataTypeCast( 'float32', 'float64' ); - * // returns true - * - * bool = ns.isSafeDataTypeCast( 'float64', 'int32' ); - * // returns false - */ - isSafeDataTypeCast: typeof isSafeDataTypeCast; - - /** - * Returns a boolean indicating if a provided array data type can be safely cast to, or is of the same "kind" as, another array data type. - * - * @param from - array data type - * @param to - array data type - * @returns boolean indicating if a data type can be cast to another data type - * - * @example - * var bool = ns.isSameKindDataTypeCast( 'float32', 'float64' ); - * // returns true - * - * bool = ns.isSameKindDataTypeCast( 'uint16', 'int16' ); - * // returns false - */ - isSameKindDataTypeCast: typeof isSameKindDataTypeCast; - - /** - * Tests whether an input value is a supported array signed integer data type. - * - * @param v - value to test - * @returns boolean indicating whether an input value is a supported array signed integer data type - * - * @example - * var bool = ns.isSignedIntegerDataType( 'float32' ); - * // returns false - * - * bool = ns.isSignedIntegerDataType( 'float64' ); - * // returns false - * - * bool = ns.isSignedIntegerDataType( 'generic' ); - * // returns false - * - * bool = ns.isSignedIntegerDataType( 'int16' ); - * // returns true - * - * bool = ns.isSignedIntegerDataType( 'int32' ); - * // returns true - * - * bool = ns.isSignedIntegerDataType( 'int8' ); - * // returns true - * - * bool = ns.isSignedIntegerDataType( 'uint16' ); - * // returns false - * - * bool = ns.isSignedIntegerDataType( 'uint32' ); - * // returns false - * - * bool = ns.isSignedIntegerDataType( 'uint8' ); - * // returns false - * - * bool = ns.isSignedIntegerDataType( 'uint8c' ); - * // returns false - * - * bool = ns.isSignedIntegerDataType( 'foo' ); - * // returns false - */ - isSignedIntegerDataType: typeof isSignedIntegerDataType; - - /** - * Tests if an array is sorted in ascending order. - * - * @param x - input array - * @returns boolean indicating if an array is sorted in ascending order - * - * @example - * var out = ns.isSortedAscending( [ 1, 2, 3 ] ); - * // returns true - * - * @example - * var out = ns.isSortedAscending( [ 3, 2, 1 ] ); - * // returns false - * - * @example - * var out = ns.isSortedAscending( [ 3, 3, 3 ] ); - * // returns true - * - * @example - * var out = ns.isSortedAscending( [ 3 ] ); - * // returns true - * - * @example - * var out = ns.isSortedAscending( [] ); - * // returns false - * - * @example - * var out = ns.isSortedAscending( [ 1, 3, 2 ] ); - * // returns false - */ - isSortedAscending: typeof isSortedAscending; - - /** - * Tests whether an input value is a supported array unsigned integer data type. - * - * @param v - value to test - * @returns boolean indicating whether an input value is a supported array unsigned integer data type - * - * @example - * var bool = ns.isUnsignedIntegerDataType( 'float32' ); - * // returns false - * - * bool = ns.isUnsignedIntegerDataType( 'float64' ); - * // returns false - * - * bool = ns.isUnsignedIntegerDataType( 'generic' ); - * // returns false - * - * bool = ns.isUnsignedIntegerDataType( 'int16' ); - * // returns false - * - * bool = ns.isUnsignedIntegerDataType( 'int32' ); - * // returns false - * - * bool = ns.isUnsignedIntegerDataType( 'int8' ); - * // returns false - * - * bool = ns.isUnsignedIntegerDataType( 'uint16' ); - * // returns true - * - * bool = ns.isUnsignedIntegerDataType( 'uint32' ); - * // returns true - * - * bool = ns.isUnsignedIntegerDataType( 'uint8' ); - * // returns true - * - * bool = ns.isUnsignedIntegerDataType( 'uint8c' ); - * // returns true - * - * bool = ns.isUnsignedIntegerDataType( 'foo' ); - * // returns false - */ - isUnsignedIntegerDataType: typeof isUnsignedIntegerDataType; -} - -/** -* Base array assertion utilities. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/base/assert/docs/types/test.ts b/base/assert/docs/types/test.ts deleted file mode 100644 index e344b7914..000000000 --- a/base/assert/docs/types/test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/base/assert/examples/index.js b/base/assert/examples/index.js deleted file mode 100644 index 69dba4bea..000000000 --- a/base/assert/examples/index.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtype = require( './../../../dtype' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var Uint8Array = require( './../../../uint8' ); -var Complex128Array = require( './../../../complex128' ); -var ns = require( './../lib' ); - -// Create various arrays: -var arr1 = new Float64Array( [ 1.1, 2.2, 3.3 ] ); -var arr2 = new Int32Array( [ 1, 2, 3 ] ); -var arr3 = new Uint8Array( [ 1, 2, 3 ] ); -var arr4 = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0 ] ); // two complex numbers: 1+1i, 2+2i - -// Get data types: -var dt1 = dtype( arr1 ); -var dt2 = dtype( arr2 ); -var dt3 = dtype( arr3 ); -var dt4 = dtype( arr4 ); - -// Check data types: -console.log( dt1 + ' is floating-point data type: ' + ns.isFloatingPointDataType( dt1 ) ); -// => 'float64 is floating-point data type: true' - -console.log( dt2 + ' is integer data type: ' + ns.isIntegerDataType( dt2 ) ); -// => 'int32 is integer data type: true' - -console.log( dt3 + ' is unsigned integer data type: ' + ns.isUnsignedIntegerDataType( dt3 ) ); -// => 'uint8 is unsigned integer data type: true' - -console.log( dt4 + ' is complex floating-point data type: ' + ns.isComplexFloatingPointDataType( dt4 ) ); -// => 'complex128 is complex floating-point data type: true' - -// Check if arrays have the same values: -console.log( 'arr2 and arr3 have same values: ' + ns.hasSameValues( arr2, arr3 ) ); -// => 'arr2 and arr3 have same values: true' - -console.log( 'arr1 and arr2 have same values: ' + ns.hasSameValues( arr1, arr2 ) ); -// => 'arr1 and arr2 have same values: false' - -// Check safe data type casts: -console.log( 'Can safely cast from ' + dt2 + ' to ' + dt1 + ': ' + ns.isSafeDataTypeCast( dt2, dt1 ) ); -// => 'Can safely cast from int32 to float64: true' - -console.log( 'Can safely cast from ' + dt1 + ' to ' + dt2 + ': ' + ns.isSafeDataTypeCast( dt1, dt2 ) ); -// => 'Can safely cast from float64 to int32: false' - -console.log( 'Can safely cast from ' + dt3 + ' to ' + dt2 + ': ' + ns.isSafeDataTypeCast( dt3, dt2 ) ); -// => 'Can safely cast from uint8 to int32: true' - -console.log( 'Can safely cast from ' + dt4 + ' to ' + dt1 + ': ' + ns.isSafeDataTypeCast( dt4, dt1 ) ); -// => 'Can safely cast from complex128 to float64: false' - -// Check if arrays contain specific values: -console.log( 'arr1 contains 2.2: ' + ns.contains( arr1, 2.2 ) ); -// => 'arr1 contains 2.2: true' - -console.log( 'arr2 contains 2: ' + ns.contains( arr2, 2 ) ); -// => 'arr2 contains 2: true' - -console.log( 'arr2 contains 2.2: ' + ns.contains( arr2, 2.2 ) ); -// => 'arr2 contains 2.2: false' - -// Check complex array types: -console.log( 'arr4 is Complex128Array: ' + ns.isComplex128Array( arr4 ) ); -// => 'arr4 is Complex128Array: true' - -console.log( 'arr4 is complex typed array: ' + ns.isComplexTypedArray( arr4 ) ); -// => 'arr4 is complex typed array: true' diff --git a/base/assert/has-almost-equal-values/README.md b/base/assert/has-almost-equal-values/README.md deleted file mode 100644 index 01df30975..000000000 --- a/base/assert/has-almost-equal-values/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# hasAlmostEqualValues - -> Test if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place). - - - -
- -
- - - - - -
- -## Usage - -```javascript -var hasAlmostEqualValues = require( '@stdlib/array/base/assert/has-almost-equal-values' ); -``` - -#### hasAlmostEqualValues( x, y, maxULP ) - -Tests if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place). - -```javascript -var x = [ 0, 0, 1, 0 ]; -var y = [ 0, 0, 1, 0 ]; - -var bool = hasAlmostEqualValues( x, y, 1 ); -// returns true -``` - -
- - - - - -
- -## Notes - -- If provided arrays of unequal length, the function returns `false`. -- The function does **not** skip `undefined` elements and is thus not optimized for sparse arrays. - -
- - - - - -
- -## Examples - - - -```javascript -var uniform = require( '@stdlib/random/array/uniform' ); -var Complex128Array = require( '@stdlib/array/complex128' ); -var hasAlmostEqualValues = require( '@stdlib/array/base/assert/has-almost-equal-values' ); - -var buf = uniform( 10, 0, 10 ); -// returns - -var x = new Complex128Array( buf ); -// returns - -var y = new Complex128Array( buf ); -// returns - -var out = hasAlmostEqualValues( x, y, 1 ); -// returns true -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/has-almost-equal-values/benchmark/benchmark.length.js b/base/assert/has-almost-equal-values/benchmark/benchmark.length.js deleted file mode 100644 index a0549488c..000000000 --- a/base/assert/has-almost-equal-values/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var zeros = require( './../../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var hasAlmostEqualValues = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = hasAlmostEqualValues( x, x, 1 ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/assert/has-almost-equal-values/docs/repl.txt b/base/assert/has-almost-equal-values/docs/repl.txt deleted file mode 100644 index 98404e144..000000000 --- a/base/assert/has-almost-equal-values/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( x, y, maxULP ) - Tests if two arrays have respective elements which are approximately equal - within a specified number of ULPs (units in the last place). - - If provided arrays of unequal length, the function returns `false`. - - Parameters - ---------- - x: Array|TypedArray|Object - First input array. - - y: Array|TypedArray|Object - Second input array. - - maxULP: integer - Maximum allowed ULP difference. - - Returns - ------- - bool: boolean - Boolean indicating whether two arrays are approximately equal. - - Examples - -------- - > var x = [ 0, 0, 1, 0 ]; - > var y = [ 0, 0, 1, 0 ]; - > var out = {{alias}}( x, y, 0 ) - true - - See Also - -------- - diff --git a/base/assert/has-almost-equal-values/docs/types/index.d.ts b/base/assert/has-almost-equal-values/docs/types/index.d.ts deleted file mode 100644 index cb6bbab2d..000000000 --- a/base/assert/has-almost-equal-values/docs/types/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Tests if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place). -* -* ## Notes -* -* - If provided arrays of unequal length, the function returns `false`. -* -* @param x - first input array -* @param y - second input array -* @param maxULP - maximum allowed ULP difference -* @returns boolean indicating whether both arrays are approximately equal -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasAlmostEqualValues( x, y, 0 ); -* // returns true -*/ -declare function hasAlmostEqualValues( x: Collection | AccessorArrayLike, y: Collection | AccessorArrayLike, maxULP: number ): boolean; - - -// EXPORTS // - -export = hasAlmostEqualValues; diff --git a/base/assert/has-almost-equal-values/docs/types/test.ts b/base/assert/has-almost-equal-values/docs/types/test.ts deleted file mode 100644 index 77ff643c1..000000000 --- a/base/assert/has-almost-equal-values/docs/types/test.ts +++ /dev/null @@ -1,84 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import toAccessorArray = require( './../../../../../base/to-accessor-array' ); -import hasAlmostEqualValues = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - const x = [ 1, 2, 3 ]; - - hasAlmostEqualValues( x, x, 0 ); // $ExpectType boolean - hasAlmostEqualValues( new Float64Array( x ), new Float64Array( x ), 0 ); // $ExpectType boolean - hasAlmostEqualValues( new Float32Array( x ), new Float32Array( x ), 0 ); // $ExpectType boolean - hasAlmostEqualValues( new Int32Array( x ), new Int32Array( x ), 0 ); // $ExpectType boolean - hasAlmostEqualValues( new Int16Array( x ), new Int16Array( x ), 0 ); // $ExpectType boolean - hasAlmostEqualValues( new Int8Array( x ), new Int8Array( x ), 0 ); // $ExpectType boolean - hasAlmostEqualValues( new Uint32Array( x ), new Uint32Array( x ), 0 ); // $ExpectType boolean - hasAlmostEqualValues( new Uint16Array( x ), new Uint16Array( x ), 0 ); // $ExpectType boolean - hasAlmostEqualValues( new Uint8Array( x ), new Uint8Array( x ), 0 ); // $ExpectType boolean - hasAlmostEqualValues( new Uint8ClampedArray( x ), new Uint8ClampedArray( x ), 0 ); // $ExpectType boolean - hasAlmostEqualValues( toAccessorArray( x ), toAccessorArray( x ), 0 ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - hasAlmostEqualValues( 2, x, 0 ); // $ExpectError - hasAlmostEqualValues( false, x, 0 ); // $ExpectError - hasAlmostEqualValues( true, x, 0 ); // $ExpectError - hasAlmostEqualValues( {}, x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - hasAlmostEqualValues( x, 2, 0 ); // $ExpectError - hasAlmostEqualValues( x, false, 0 ); // $ExpectError - hasAlmostEqualValues( x, true, 0 ); // $ExpectError - hasAlmostEqualValues( x, {}, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - hasAlmostEqualValues( x, x, '2' ); // $ExpectError - hasAlmostEqualValues( x, x, false ); // $ExpectError - hasAlmostEqualValues( x, x, true ); // $ExpectError - hasAlmostEqualValues( x, x, null ); // $ExpectError - hasAlmostEqualValues( x, x, undefined ); // $ExpectError - hasAlmostEqualValues( x, x, {} ); // $ExpectError - hasAlmostEqualValues( x, x, [] ); // $ExpectError - hasAlmostEqualValues( x, x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - hasAlmostEqualValues(); // $ExpectError - hasAlmostEqualValues( x ); // $ExpectError - hasAlmostEqualValues( x, x ); // $ExpectError - hasAlmostEqualValues( x, x, 0, 1 ); // $ExpectError -} diff --git a/base/assert/has-almost-equal-values/examples/index.js b/base/assert/has-almost-equal-values/examples/index.js deleted file mode 100644 index 2f573129d..000000000 --- a/base/assert/has-almost-equal-values/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var uniform = require( '@stdlib/random/array/uniform' ); -var Complex128Array = require( './../../../../complex128' ); -var hasAlmostEqualValues = require( './../lib' ); - -var buf = uniform( 10, 0, 10 ); -// returns - -var x = new Complex128Array( buf ); -// returns - -var y = new Complex128Array( buf ); -// returns - -var out = hasAlmostEqualValues( x, y, 1 ); -// returns true - -console.log( out ); -// => true diff --git a/base/assert/has-almost-equal-values/lib/index.js b/base/assert/has-almost-equal-values/lib/index.js deleted file mode 100644 index 09f65b749..000000000 --- a/base/assert/has-almost-equal-values/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place). -* -* @module @stdlib/array/base/assert/has-almost-equal-values -* -* @example -* var hasAlmostEqualValues = require( '@stdlib/array/base/assert/has-almost-equal-values' ); -* -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasAlmostEqualValues( x, y, 1 ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/has-almost-equal-values/lib/main.js b/base/assert/has-almost-equal-values/lib/main.js deleted file mode 100644 index 00d2ddbf1..000000000 --- a/base/assert/has-almost-equal-values/lib/main.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isComplex128Array = require( './../../../../base/assert/is-complex128array' ); -var isComplex64Array = require( './../../../../base/assert/is-complex64array' ); -var isBooleanArray = require( './../../../../base/assert/is-booleanarray' ); -var arraylike2object = require( './../../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var isAlmostEqualF32 = require( '@stdlib/number/float32/base/assert/is-almost-equal' ); -var isAlmostEqualF64 = require( '@stdlib/number/float64/base/assert/is-almost-equal' ); -var isAlmostEqual = require( '@stdlib/assert/is-almost-equal' ); - - -// FUNCTIONS // - -/** -* Tests if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place). -* -* @private -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @param {NonNegativeInteger} maxULP - maximum allowed ULP difference -* @param {Function} fcn - function which tests approximate equality -* @returns {boolean} boolean indicating if both arrays have respective elements which are approximately equal -* -* @example -* var base = require( '@stdlib/number/float64/base/assert/is-almost-equal' ); -* -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = internal( x, y, 1, base ); -* // returns true -* -* @example -* var base = require( '@stdlib/number/float64/base/assert/is-almost-equal' ); -* -* var x = [ 0, 0, 0, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = internal( x, y, 1, base ); -* // returns false -*/ -function internal( x, y, maxULP, fcn ) { - var i; - for ( i = 0; i < x.length; i++ ) { - if ( !fcn( x[ i ], y[ i ], maxULP ) ) { - return false; - } - } - return true; -} - -/** -* Tests if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place). -* -* @private -* @param {Object} x - first input array object -* @param {Object} y - second input array object -* @param {NonNegativeInteger} maxULP - maximum allowed ULP difference -* @param {Function} fcn - function which tests approximate equality -* @returns {boolean} boolean indicating if both arrays have respective elements which are approximately equal -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* var assert = require( '@stdlib/assert/is-almost-equal' ); -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* -* var out = accessors( x, y, 0, assert ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* var assert = require( '@stdlib/assert/is-almost-equal' ); -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) ); -* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* -* var out = accessors( x, y, 1, assert ); -* // returns false -*/ -function accessors( x, y, maxULP, fcn ) { - var xdata; - var ydata; - var xget; - var yget; - var i; - - xdata = x.data; - ydata = y.data; - - xget = x.accessors[ 0 ]; - yget = y.accessors[ 0 ]; - - for ( i = 0; i < xdata.length; i++ ) { - if ( !fcn( xget( xdata, i ), yget( ydata, i ), maxULP ) ) { - return false; - } - } - return true; -} - - -// MAIN // - -/** -* Tests if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place). -* -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @param {NonNegativeInteger} maxULP - maximum allowed ULP difference -* @returns {boolean} boolean indicating if both arrays have respective elements which are approximately equal -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasAlmostEqualValues( x, y, 0 ); -* // returns true -* -* @example -* var x = [ 0, 0, 0, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasAlmostEqualValues( x, y, 1 ); -* // returns false -*/ -function hasAlmostEqualValues( x, y, maxULP ) { - var FLG; - var xo; - var yo; - var xr; - var yr; - - if ( x.length !== y.length ) { - return false; - } - xo = arraylike2object( x ); - yo = arraylike2object( y ); - if ( xo.accessorProtocol || yo.accessorProtocol ) { - FLG = 2; - - // If provided boolean arrays, reinterpret the arrays to avoid using accessors to access array elements... - if ( isBooleanArray( x ) ) { - if ( isBooleanArray( y ) ) { - return internal( reinterpretBoolean( x, 0 ), reinterpretBoolean( y, 0 ), maxULP, isAlmostEqualF64 ); // eslint-disable-line max-len - } - return accessors( xo, yo, maxULP, isAlmostEqual ); // general accessors should always use general comparison - } - // If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components... - if ( isComplex128Array( x ) ) { - xr = reinterpret128( x, 0 ); - FLG -= 1; - } else if ( isComplex64Array( x ) ) { - xr = reinterpret64( x, 0 ); - FLG -= 1; - } - if ( isComplex128Array( y ) ) { - yr = reinterpret128( y, 0 ); - FLG -= 1; - } else if ( isComplex64Array( y ) ) { - yr = reinterpret64( y, 0 ); - FLG -= 1; - } - if ( FLG === 0 ) { - // Determine whether we should use double-precision or single-precision comparison... - if ( xr.BYTES_PER_ELEMENT === 8 || yr.BYTES_PER_ELEMENT === 8 ) { - return internal( xr, yr, maxULP, isAlmostEqualF64 ); - } - return internal( xr, yr, maxULP, isAlmostEqualF32 ); - } - return accessors( xo, yo, maxULP, isAlmostEqual ); // general accessors should always use general comparison - } - // Determine whether we should use double-precision or single-precision comparison... - if ( x.BYTES_PER_ELEMENT === 4 && y.BYTES_PER_ELEMENT === 4 ) { - return internal( x, y, maxULP, isAlmostEqualF32 ); - } - return internal( x, y, maxULP, isAlmostEqual ); // default to general comparison -} - - -// EXPORTS // - -module.exports = hasAlmostEqualValues; diff --git a/base/assert/has-almost-equal-values/package.json b/base/assert/has-almost-equal-values/package.json deleted file mode 100644 index 6dfa56daa..000000000 --- a/base/assert/has-almost-equal-values/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/has-almost-equal-values", - "version": "0.0.0", - "description": "Test if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place).", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "assert", - "validate", - "same", - "deep", - "equal", - "equality", - "compare", - "comparison" - ] -} diff --git a/base/assert/has-almost-equal-values/test/test.js b/base/assert/has-almost-equal-values/test/test.js deleted file mode 100644 index 979e3320f..000000000 --- a/base/assert/has-almost-equal-values/test/test.js +++ /dev/null @@ -1,529 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var FLOAT64_EPS = require( '@stdlib/constants/float64/eps' ); -var FLOAT32_EPS = require( '@stdlib/constants/float32/eps' ); -var AccessorArray = require( './../../../../base/accessor' ); -var Float64Array = require( './../../../../float64' ); -var Float32Array = require( './../../../../float32' ); -var Complex64Array = require( './../../../../complex64' ); -var Complex128Array = require( './../../../../complex128' ); -var BooleanArray = require( './../../../../bool' ); -var hasAlmostEqualValues = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof hasAlmostEqualValues, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided collections of unequal length, the function returns `false`', function test( t ) { - var out; - var x; - var y; - - x = []; - y = [ 1, 2, 3 ]; - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - x = [ 1, 2 ]; - y = [ 1, 2, 3 ]; - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 1 ] ); - y = []; - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (generic)', function test( t ) { - var out; - var x; - var y; - - x = []; - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = []; - y = []; - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [] ); - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [] ); - y = new Float64Array( [] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (mixed)', function test( t ) { - var out; - var x; - var y; - - x = []; - y = new Float64Array( [] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [] ); - y = []; - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [] ); - y = []; - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = []; - y = new BooleanArray( [] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (boolean array)', function test( t ) { - var out; - var x; - var y; - - x = new BooleanArray( [] ); - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [] ); - y = new BooleanArray( [] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (complex typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Complex64Array( [] ); - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex64Array( [] ); - y = new Complex64Array( [] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [] ); - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [] ); - y = new Complex128Array( [] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (accessor)', function test( t ) { - var out; - var x; - var y; - - x = new AccessorArray( [] ); - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new AccessorArray( [] ); - y = new AccessorArray( [] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have respective elements which are approximately equal (generic)', function test( t ) { - var out; - var x; - var y; - - x = [ 1, 0, 3 ]; - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = [ 1, 0, 3 ]; - y = [ 1, 0, 3 ]; - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have respective elements which are approximately equal (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - y = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 1.0+FLOAT64_EPS ] ); - y = new Float64Array( [ 0.0, 2.0, 1.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float32Array( [ 0.0, 2.0, 1.0+FLOAT32_EPS ] ); - y = new Float32Array( [ 0.0, 2.0, 1.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have respective elements which are approximately equal (mixed)', function test( t ) { - var out; - var x; - var y; - - // Exactly equal... - x = [ 0.0, 2.0, 0.0 ]; - y = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float32Array( [ 0.0, 2.0, 0.0 ] ); - y = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - y = [ 0.0, 2.0, 0.0 ]; - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - y = new Float32Array( [ 0.0, 2.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true ] ); - y = [ true, false, true ]; - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = [ true, false, true ]; - y = new BooleanArray( [ true, false, true ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - // Approximately equal... - x = [ 0.0, 2.0, 1.0 ]; - y = new Float64Array( [ 0.0, 2.0, 1.0+FLOAT64_EPS ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 1.0 ] ); - y = [ 0.0, 2.0, 1.0+FLOAT64_EPS ]; - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 1.0+FLOAT64_EPS ] ); - y = new Float32Array( [ 0.0, 2.0, 1.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have respective elements which are approximately equal (boolean array)', function test( t ) { - var out; - var x; - var y; - - x = new BooleanArray( [ true, false, true ] ); - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true ] ); - y = new BooleanArray( [ true, false, true ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have respective elements which are approximately equal (complex typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Complex64Array( [ 0.0, 2.0, 0.0, 0.0 ] ); - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 2.0, 0.0, 0.0 ] ); - y = new Complex64Array( [ 0.0, 2.0, 0.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - y = new Complex64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - // Approximately equal... - x = new Complex128Array( [ 0.0, 1.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 1.0+FLOAT64_EPS, 3.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 1.0+FLOAT64_EPS, 3.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 1.0, 3.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 1.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 1.0+FLOAT64_EPS, 3.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 1.0, 3.0, 0.0 ] ); - y = new Complex64Array( [ 0.0, 1.0+FLOAT32_EPS, 3.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have respective elements which are approximately equal (accessor)', function test( t ) { - var out; - var x; - var y; - - x = new AccessorArray( [ 0, 2, 3 ] ); - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new AccessorArray( [ 0, 2, 3 ] ); - y = new AccessorArray( [ 0, 2, 3 ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have respective elements which are approximately equal (array-like object)', function test( t ) { - var out; - var x; - var y; - - x = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - out = hasAlmostEqualValues( x, x, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - x = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - y = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have respective elements which are approximately equal (generic)', function test( t ) { - var out; - var x; - var y; - - x = [ 0, 0, 0 ]; - y = [ 0, 1, 0 ]; - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have respective elements which are approximately equal (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [ 0.0, 0.0, 0.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0+FLOAT64_EPS+FLOAT64_EPS ] ); - y = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have respective elements which are approximately equal (mixed)', function test( t ) { - var out; - var x; - var y; - - x = [ 0.0, 0.0, 0.0 ]; - y = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - y = [ 0.0, 0.0, 0.0 ]; - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have respective elements which are approximately equal (boolean array)', function test( t ) { - var out; - var x; - var y; - - x = new BooleanArray( [ true, false, false, true ] ); - y = new BooleanArray( [ true, true, false, false ] ); - out = hasAlmostEqualValues( x, y, 0 ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have respective elements which are approximately equal (complex typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - y = new Complex64Array( [ 0.0, 0.0, 0.0, 1.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - y = new Complex128Array( [ 1.0, 0.0, 0.0, 0.0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have respective elements which are approximately equal (accessor)', function test( t ) { - var out; - var x; - var y; - - x = new AccessorArray( [ 0, 0, 1 ] ); - y = new AccessorArray( [ 0, 0, 0 ] ); - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have respective elements which are approximately equal (array-like object)', function test( t ) { - var out; - var x; - var y; - - x = { - 'length': 3, - '0': 0, - '1': 1, - '2': 0 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - out = hasAlmostEqualValues( x, y, 1 ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); diff --git a/base/assert/has-equal-values-indexed/README.md b/base/assert/has-equal-values-indexed/README.md deleted file mode 100644 index 74aca0069..000000000 --- a/base/assert/has-equal-values-indexed/README.md +++ /dev/null @@ -1,130 +0,0 @@ - - -# hasEqualValuesIndexed - -> Test if two indexed arrays have equal values. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var hasEqualValuesIndexed = require( '@stdlib/array/base/assert/has-equal-values-indexed' ); -``` - -#### hasEqualValuesIndexed( x, y ) - -Tests if two indexed arrays have equal values. - -```javascript -var x = [ 0, 0, 1, 0 ]; -var y = [ 0, 0, 1, 0 ]; - -var bool = hasEqualValuesIndexed( x, y ); -// returns true -``` - -
- - - - - -
- -## Notes - -- If provided arrays of unequal length, the function returns `false`. -- The function performs **strict** equality comparison. -- The function does **not** skip `undefined` elements and is thus not optimized for sparse arrays. -- An _indexed_ array-like object is a data structure in which one retrieves elements via integer indices using bracket `[]` notation (e.g., `Float64Array`, `Int32Array`, `Array`, etc). This is in contrast to an _accessor_ array-like object in which one retrieves elements using `get` and `set` methods (e.g., [`Complex64Array`][@stdlib/array/complex64] and [`Complex128Array`][@stdlib/array/complex128]). - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var Float64Array = require( '@stdlib/array/float64' ); -var hasEqualValuesIndexed = require( '@stdlib/array/base/assert/has-equal-values-indexed' ); - -var buf = discreteUniform( 10, 0, 10 ); -// returns - -var x = new Float64Array( buf ); -// returns - -var y = new Float64Array( buf ); -// returns - -var out = hasEqualValuesIndexed( x, y ); -// returns true -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/has-equal-values-indexed/benchmark/benchmark.length.js b/base/assert/has-equal-values-indexed/benchmark/benchmark.length.js deleted file mode 100644 index c19aded81..000000000 --- a/base/assert/has-equal-values-indexed/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var zeros = require( './../../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var hasEqualValuesIndexed = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = hasEqualValuesIndexed( x, x ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/assert/has-equal-values-indexed/docs/repl.txt b/base/assert/has-equal-values-indexed/docs/repl.txt deleted file mode 100644 index f1c5f1d67..000000000 --- a/base/assert/has-equal-values-indexed/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, y ) - Tests if two indexed arrays have equal values. - - If provided arrays of unequal length, the function returns `false`. - - Parameters - ---------- - x: Array|TypedArray|Object - First input array. - - y: Array|TypedArray|Object - Second input array. - - Returns - ------- - bool: boolean - The function returns `true` if both arrays have equal values; otherwise, - the function returns `false`. - - Examples - -------- - > var x = [ 0, 0, 1, 0 ]; - > var y = [ 0, 0, 1, 0 ]; - > var out = {{alias}}( x, y ) - true - - See Also - -------- - diff --git a/base/assert/has-equal-values-indexed/docs/types/index.d.ts b/base/assert/has-equal-values-indexed/docs/types/index.d.ts deleted file mode 100644 index 0ed05d071..000000000 --- a/base/assert/has-equal-values-indexed/docs/types/index.d.ts +++ /dev/null @@ -1,48 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Tests if two indexed arrays have equal values. -* -* ## Notes -* -* - If provided arrays of unequal length, the function returns `false`. -* -* @param x - first input array -* @param y - second input array -* @returns boolean indicating whether both arrays have equal values -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasEqualValuesIndexed( x, y ); -* // returns true -*/ -declare function hasEqualValuesIndexed( x: Collection, y: Collection ): boolean; - - -// EXPORTS // - -export = hasEqualValuesIndexed; diff --git a/base/assert/has-equal-values-indexed/docs/types/test.ts b/base/assert/has-equal-values-indexed/docs/types/test.ts deleted file mode 100644 index abe20a1ed..000000000 --- a/base/assert/has-equal-values-indexed/docs/types/test.ts +++ /dev/null @@ -1,67 +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. -*/ - -import hasEqualValuesIndexed = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - const x = [ 1, 2, 3 ]; - - hasEqualValuesIndexed( x, x ); // $ExpectType boolean - hasEqualValuesIndexed( new Float64Array( x ), new Float64Array( x ) ); // $ExpectType boolean - hasEqualValuesIndexed( new Float32Array( x ), new Float32Array( x ) ); // $ExpectType boolean - hasEqualValuesIndexed( new Int32Array( x ), new Int32Array( x ) ); // $ExpectType boolean - hasEqualValuesIndexed( new Int16Array( x ), new Int16Array( x ) ); // $ExpectType boolean - hasEqualValuesIndexed( new Int8Array( x ), new Int8Array( x ) ); // $ExpectType boolean - hasEqualValuesIndexed( new Uint32Array( x ), new Uint32Array( x ) ); // $ExpectType boolean - hasEqualValuesIndexed( new Uint16Array( x ), new Uint16Array( x ) ); // $ExpectType boolean - hasEqualValuesIndexed( new Uint8Array( x ), new Uint8Array( x ) ); // $ExpectType boolean - hasEqualValuesIndexed( new Uint8ClampedArray( x ), new Uint8ClampedArray( x ) ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - hasEqualValuesIndexed( 2, x ); // $ExpectError - hasEqualValuesIndexed( false, x ); // $ExpectError - hasEqualValuesIndexed( true, x ); // $ExpectError - hasEqualValuesIndexed( {}, x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - hasEqualValuesIndexed( x, 2 ); // $ExpectError - hasEqualValuesIndexed( x, false ); // $ExpectError - hasEqualValuesIndexed( x, true ); // $ExpectError - hasEqualValuesIndexed( x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - hasEqualValuesIndexed(); // $ExpectError - hasEqualValuesIndexed( x ); // $ExpectError - hasEqualValuesIndexed( x, x, x ); // $ExpectError -} diff --git a/base/assert/has-equal-values-indexed/examples/index.js b/base/assert/has-equal-values-indexed/examples/index.js deleted file mode 100644 index 92d6aa072..000000000 --- a/base/assert/has-equal-values-indexed/examples/index.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var Float64Array = require( './../../../../float64' ); -var hasEqualValuesIndexed = require( './../lib' ); - -var buf = discreteUniform( 10, 0, 10 ); -// returns - -var x = new Float64Array( buf ); -// returns - -var y = new Float64Array( buf ); -// returns - -var out = hasEqualValuesIndexed( x, y ); -// returns true - -console.log( out ); -// => true diff --git a/base/assert/has-equal-values-indexed/lib/index.js b/base/assert/has-equal-values-indexed/lib/index.js deleted file mode 100644 index b1576dc4f..000000000 --- a/base/assert/has-equal-values-indexed/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Test if two indexed arrays have equal values. -* -* @module @stdlib/array/base/assert/has-equal-values-indexed -* -* @example -* var hasEqualValuesIndexed = require( '@stdlib/array/base/assert/has-equal-values-indexed' ); -* -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasEqualValuesIndexed( x, y ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/has-equal-values-indexed/lib/main.js b/base/assert/has-equal-values-indexed/lib/main.js deleted file mode 100644 index 741ee0316..000000000 --- a/base/assert/has-equal-values-indexed/lib/main.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Tests if two indexed arrays have equal values. -* -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @returns {boolean} boolean indicating if both arrays have equal values -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasEqualValuesIndexed( x, y ); -* // returns true -* -* @example -* var x = [ 0, 0, 0, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasEqualValuesIndexed( x, y ); -* // returns false -*/ -function hasEqualValuesIndexed( x, y ) { - var i; - if ( x.length !== y.length ) { - return false; - } - for ( i = 0; i < x.length; i++ ) { - if ( x[ i ] !== y[ i ] ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = hasEqualValuesIndexed; diff --git a/base/assert/has-equal-values-indexed/package.json b/base/assert/has-equal-values-indexed/package.json deleted file mode 100644 index d87c38dae..000000000 --- a/base/assert/has-equal-values-indexed/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/has-equal-values-indexed", - "version": "0.0.0", - "description": "Test if two indexed arrays have equal values.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "assert", - "validate", - "same", - "deep", - "equal", - "equality", - "compare", - "comparison" - ] -} diff --git a/base/assert/has-equal-values-indexed/test/test.js b/base/assert/has-equal-values-indexed/test/test.js deleted file mode 100644 index 47cd5d44d..000000000 --- a/base/assert/has-equal-values-indexed/test/test.js +++ /dev/null @@ -1,270 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../../float64' ); -var hasEqualValuesIndexed = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof hasEqualValuesIndexed, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided collections of unequal length, the function returns `false`', function test( t ) { - var out; - var x; - var y; - - x = []; - y = [ 1, 2, 3 ]; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = [ 1, 2 ]; - y = [ 1, 2, 3 ]; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 1 ] ); - y = []; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (generic)', function test( t ) { - var out; - var x; - var y; - - x = []; - out = hasEqualValuesIndexed( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = []; - y = []; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [] ); - out = hasEqualValuesIndexed( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [] ); - y = new Float64Array( [] ); - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (mixed)', function test( t ) { - var out; - var x; - var y; - - x = []; - y = new Float64Array( [] ); - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [] ); - y = []; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have equal values (generic)', function test( t ) { - var out; - var x; - var y; - - x = [ 1, 0, 3 ]; - out = hasEqualValuesIndexed( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = [ 1, 0, 3 ]; - y = [ 1, 0, 3 ]; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have equal values (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasEqualValuesIndexed( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - y = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have equal values (mixed)', function test( t ) { - var out; - var x; - var y; - - x = [ 0.0, 2.0, 0.0 ]; - y = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - y = [ 0.0, 2.0, 0.0 ]; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have equal values (array-like object)', function test( t ) { - var out; - var x; - var y; - - x = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - out = hasEqualValuesIndexed( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - y = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have equal values (generic)', function test( t ) { - var out; - var x; - var y; - - x = [ 0, 0, 0 ]; - y = [ 0, 1, 0 ]; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have equal values (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [ 0.0, 0.0, 0.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 0.0, NaN, 1.0 ] ); - y = new Float64Array( [ 0.0, NaN, 1.0 ] ); - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have equal values (mixed)', function test( t ) { - var out; - var x; - var y; - - x = [ 0.0, 0.0, 0.0 ]; - y = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - y = [ 0.0, 0.0, 0.0 ]; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0 ] ); - y = [ 0.0, 0.0, 0.0, 0.0 ]; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have equal values (array-like object)', function test( t ) { - var out; - var x; - var y; - - x = { - 'length': 3, - '0': 0, - '1': 1, - '2': 0 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - out = hasEqualValuesIndexed( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); diff --git a/base/assert/has-equal-values/README.md b/base/assert/has-equal-values/README.md deleted file mode 100644 index de060ec87..000000000 --- a/base/assert/has-equal-values/README.md +++ /dev/null @@ -1,125 +0,0 @@ - - -# hasEqualValues - -> Test if two arrays have equal values. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); -``` - -#### hasEqualValues( x, y ) - -Tests if two arrays have equal values. - -```javascript -var x = [ 0, 0, 1, 0 ]; -var y = [ 0, 0, 1, 0 ]; - -var bool = hasEqualValues( x, y ); -// returns true -``` - -
- - - - - -
- -## Notes - -- If provided arrays of unequal length, the function returns `false`. -- The function performs **strict** equality comparison. -- The function does **not** skip `undefined` elements and is thus not optimized for sparse arrays. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var Complex128Array = require( '@stdlib/array/complex128' ); -var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); - -var buf = discreteUniform( 10, 0, 10 ); -// returns - -var x = new Complex128Array( buf ); -// returns - -var y = new Complex128Array( buf ); -// returns - -var out = hasEqualValues( x, y ); -// returns true -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/has-equal-values/benchmark/benchmark.length.js b/base/assert/has-equal-values/benchmark/benchmark.length.js deleted file mode 100644 index 2dca1a757..000000000 --- a/base/assert/has-equal-values/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var zeros = require( './../../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var hasEqualValues = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = hasEqualValues( x, x ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/assert/has-equal-values/docs/repl.txt b/base/assert/has-equal-values/docs/repl.txt deleted file mode 100644 index 7a3284beb..000000000 --- a/base/assert/has-equal-values/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, y ) - Tests if two arrays have equal values. - - If provided arrays of unequal length, the function returns `false`. - - Parameters - ---------- - x: Array|TypedArray|Object - First input array. - - y: Array|TypedArray|Object - Second input array. - - Returns - ------- - bool: boolean - The function returns `true` if both arrays have equal values; otherwise, - the function returns `false`. - - Examples - -------- - > var x = [ 0, 0, 1, 0 ]; - > var y = [ 0, 0, 1, 0 ]; - > var out = {{alias}}( x, y ) - true - - See Also - -------- - diff --git a/base/assert/has-equal-values/docs/types/index.d.ts b/base/assert/has-equal-values/docs/types/index.d.ts deleted file mode 100644 index cc5420bca..000000000 --- a/base/assert/has-equal-values/docs/types/index.d.ts +++ /dev/null @@ -1,48 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Tests if two arrays have equal values. -* -* ## Notes -* -* - If provided arrays of unequal length, the function returns `false`. -* -* @param x - first input array -* @param y - second input array -* @returns boolean indicating whether both arrays have equal values -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasEqualValues( x, y ); -* // returns true -*/ -declare function hasEqualValues( x: Collection | AccessorArrayLike, y: Collection | AccessorArrayLike ): boolean; - - -// EXPORTS // - -export = hasEqualValues; diff --git a/base/assert/has-equal-values/docs/types/test.ts b/base/assert/has-equal-values/docs/types/test.ts deleted file mode 100644 index cac0e8da5..000000000 --- a/base/assert/has-equal-values/docs/types/test.ts +++ /dev/null @@ -1,69 +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. -*/ - -import toAccessorArray = require( './../../../../../base/to-accessor-array' ); -import hasEqualValues = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - const x = [ 1, 2, 3 ]; - - hasEqualValues( x, x ); // $ExpectType boolean - hasEqualValues( new Float64Array( x ), new Float64Array( x ) ); // $ExpectType boolean - hasEqualValues( new Float32Array( x ), new Float32Array( x ) ); // $ExpectType boolean - hasEqualValues( new Int32Array( x ), new Int32Array( x ) ); // $ExpectType boolean - hasEqualValues( new Int16Array( x ), new Int16Array( x ) ); // $ExpectType boolean - hasEqualValues( new Int8Array( x ), new Int8Array( x ) ); // $ExpectType boolean - hasEqualValues( new Uint32Array( x ), new Uint32Array( x ) ); // $ExpectType boolean - hasEqualValues( new Uint16Array( x ), new Uint16Array( x ) ); // $ExpectType boolean - hasEqualValues( new Uint8Array( x ), new Uint8Array( x ) ); // $ExpectType boolean - hasEqualValues( new Uint8ClampedArray( x ), new Uint8ClampedArray( x ) ); // $ExpectType boolean - hasEqualValues( toAccessorArray( x ), toAccessorArray( x ) ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - hasEqualValues( 2, x ); // $ExpectError - hasEqualValues( false, x ); // $ExpectError - hasEqualValues( true, x ); // $ExpectError - hasEqualValues( {}, x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - hasEqualValues( x, 2 ); // $ExpectError - hasEqualValues( x, false ); // $ExpectError - hasEqualValues( x, true ); // $ExpectError - hasEqualValues( x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - hasEqualValues(); // $ExpectError - hasEqualValues( x ); // $ExpectError - hasEqualValues( x, x, x ); // $ExpectError -} diff --git a/base/assert/has-equal-values/examples/index.js b/base/assert/has-equal-values/examples/index.js deleted file mode 100644 index 50c397b49..000000000 --- a/base/assert/has-equal-values/examples/index.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var Complex128Array = require( './../../../../complex128' ); -var hasEqualValues = require( './../lib' ); - -var buf = discreteUniform( 10, 0, 10 ); -// returns - -var x = new Complex128Array( buf ); -// returns - -var y = new Complex128Array( buf ); -// returns - -var out = hasEqualValues( x, y ); -// returns true - -console.log( out ); -// => true diff --git a/base/assert/has-equal-values/lib/index.js b/base/assert/has-equal-values/lib/index.js deleted file mode 100644 index ac4c40b78..000000000 --- a/base/assert/has-equal-values/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Test if two arrays have equal values. -* -* @module @stdlib/array/base/assert/has-equal-values -* -* @example -* var hasEqualValues = require( '@stdlib/array/base/assert/has-equal-values' ); -* -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasEqualValues( x, y ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/has-equal-values/lib/main.js b/base/assert/has-equal-values/lib/main.js deleted file mode 100644 index 094025ea0..000000000 --- a/base/assert/has-equal-values/lib/main.js +++ /dev/null @@ -1,187 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplex128Array = require( './../../../../base/assert/is-complex128array' ); -var isComplex64Array = require( './../../../../base/assert/is-complex64array' ); -var isBooleanArray = require( './../../../../base/assert/is-booleanarray' ); -var arraylike2object = require( './../../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Tests if two arrays have equal values. -* -* @private -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @returns {boolean} boolean indicating if both arrays have equal values -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = internal( x, y ); -* // returns true -* -* @example -* var x = [ 0, 0, 0, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = internal( x, y ); -* // returns false -*/ -function internal( x, y ) { - var i; - for ( i = 0; i < x.length; i++ ) { - if ( x[ i ] !== y[ i ] ) { - return false; - } - } - return true; -} - -/** -* Tests if two arrays have equal values. -* -* @private -* @param {Object} x - first input array object -* @param {Object} y - second input array object -* @returns {boolean} boolean indicating if both arrays have equal values -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* -* var out = accessors( x, y ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) ); -* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* -* var out = accessors( x, y ); -* // returns false -*/ -function accessors( x, y ) { - var xdata; - var ydata; - var xget; - var yget; - var i; - - xdata = x.data; - ydata = y.data; - - xget = x.accessors[ 0 ]; - yget = y.accessors[ 0 ]; - - for ( i = 0; i < xdata.length; i++ ) { - if ( xget( xdata, i ) !== yget( ydata, i ) ) { - return false; - } - } - return true; -} - - -// MAIN // - -/** -* Tests if two arrays have equal values. -* -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @returns {boolean} boolean indicating if both arrays have equal values -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasEqualValues( x, y ); -* // returns true -* -* @example -* var x = [ 0, 0, 0, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasEqualValues( x, y ); -* // returns false -*/ -function hasEqualValues( x, y ) { - var FLG; - var xo; - var yo; - var xr; - var yr; - - if ( x.length !== y.length ) { - return false; - } - xo = arraylike2object( x ); - yo = arraylike2object( y ); - if ( xo.accessorProtocol || yo.accessorProtocol ) { - FLG = 2; - - // If provided boolean arrays, reinterpret the arrays to avoid using accessors to access array elements... - if ( isBooleanArray( x ) ) { - if ( isBooleanArray( y ) ) { - return internal( reinterpretBoolean( x, 0 ), reinterpretBoolean( y, 0 ) ); // eslint-disable-line max-len - } - return accessors( xo, yo ); - } - // If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components... - if ( isComplex128Array( x ) ) { - xr = reinterpret128( x, 0 ); - FLG -= 1; - } else if ( isComplex64Array( x ) ) { - xr = reinterpret64( x, 0 ); - FLG -= 1; - } - if ( isComplex128Array( y ) ) { - yr = reinterpret128( y, 0 ); - FLG -= 1; - } else if ( isComplex64Array( y ) ) { - yr = reinterpret64( y, 0 ); - FLG -= 1; - } - if ( FLG === 0 ) { - return internal( xr, yr ); - } - return accessors( xo, yo ); - } - return internal( x, y ); -} - - -// EXPORTS // - -module.exports = hasEqualValues; diff --git a/base/assert/has-equal-values/package.json b/base/assert/has-equal-values/package.json deleted file mode 100644 index a214413fb..000000000 --- a/base/assert/has-equal-values/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/has-equal-values", - "version": "0.0.0", - "description": "Test if two arrays have equal values.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "assert", - "validate", - "same", - "deep", - "equal", - "equality", - "compare", - "comparison" - ] -} diff --git a/base/assert/has-equal-values/test/test.js b/base/assert/has-equal-values/test/test.js deleted file mode 100644 index c4a3fb23f..000000000 --- a/base/assert/has-equal-values/test/test.js +++ /dev/null @@ -1,458 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../../base/accessor' ); -var Float64Array = require( './../../../../float64' ); -var Complex64Array = require( './../../../../complex64' ); -var Complex128Array = require( './../../../../complex128' ); -var BooleanArray = require( './../../../../bool' ); -var hasEqualValues = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof hasEqualValues, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided collections of unequal length, the function returns `false`', function test( t ) { - var out; - var x; - var y; - - x = []; - y = [ 1, 2, 3 ]; - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = [ 1, 2 ]; - y = [ 1, 2, 3 ]; - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 1 ] ); - y = []; - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (generic)', function test( t ) { - var out; - var x; - var y; - - x = []; - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = []; - y = []; - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [] ); - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [] ); - y = new Float64Array( [] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (mixed)', function test( t ) { - var out; - var x; - var y; - - x = []; - y = new Float64Array( [] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [] ); - y = []; - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [] ); - y = []; - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = []; - y = new BooleanArray( [] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (boolean array)', function test( t ) { - var out; - var x; - var y; - - x = new BooleanArray( [] ); - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [] ); - y = new BooleanArray( [] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (complex typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Complex64Array( [] ); - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex64Array( [] ); - y = new Complex64Array( [] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [] ); - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [] ); - y = new Complex128Array( [] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (accessor)', function test( t ) { - var out; - var x; - var y; - - x = new AccessorArray( [] ); - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new AccessorArray( [] ); - y = new AccessorArray( [] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have equal values (generic)', function test( t ) { - var out; - var x; - var y; - - x = [ 1, 0, 3 ]; - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = [ 1, 0, 3 ]; - y = [ 1, 0, 3 ]; - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have equal values (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - y = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have equal values (mixed)', function test( t ) { - var out; - var x; - var y; - - x = [ 0.0, 2.0, 0.0 ]; - y = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - y = [ 0.0, 2.0, 0.0 ]; - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true ] ); - y = [ true, false, true ]; - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = [ true, false, true ]; - y = new BooleanArray( [ true, false, true ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have equal values (boolean array)', function test( t ) { - var out; - var x; - var y; - - x = new BooleanArray( [ true, false, true ] ); - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true ] ); - y = new BooleanArray( [ true, false, true ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have equal values (complex typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Complex64Array( [ 0.0, 2.0, 0.0, 0.0 ] ); - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 2.0, 0.0, 0.0 ] ); - y = new Complex64Array( [ 0.0, 2.0, 0.0, 0.0 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have equal values (accessor)', function test( t ) { - var out; - var x; - var y; - - x = new AccessorArray( [ 0, 2, 3 ] ); - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new AccessorArray( [ 0, 2, 3 ] ); - y = new AccessorArray( [ 0, 2, 3 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have equal values (array-like object)', function test( t ) { - var out; - var x; - var y; - - x = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - out = hasEqualValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - y = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - out = hasEqualValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have equal values (generic)', function test( t ) { - var out; - var x; - var y; - - x = [ 0, 0, 0 ]; - y = [ 0, 1, 0 ]; - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have equal values (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [ 0.0, 0.0, 0.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 0.0, NaN, 1.0 ] ); - y = new Float64Array( [ 0.0, NaN, 1.0 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have equal values (mixed)', function test( t ) { - var out; - var x; - var y; - - x = [ 0.0, 0.0, 0.0 ]; - y = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - y = [ 0.0, 0.0, 0.0 ]; - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have equal values (boolean array)', function test( t ) { - var out; - var x; - var y; - - x = new BooleanArray( [ true, false, false, true ] ); - y = new BooleanArray( [ true, true, false, false ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have equal values (complex typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - y = new Complex64Array( [ 0.0, 0.0, 0.0, 1.0 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - y = new Complex128Array( [ 1.0, 0.0, 0.0, 0.0 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have equal values (accessor)', function test( t ) { - var out; - var x; - var y; - - x = new AccessorArray( [ 0, 0, 1 ] ); - y = new AccessorArray( [ 0, 0, 0 ] ); - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have equal values (array-like object)', function test( t ) { - var out; - var x; - var y; - - x = { - 'length': 3, - '0': 0, - '1': 1, - '2': 0 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - out = hasEqualValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); diff --git a/base/assert/has-same-values/README.md b/base/assert/has-same-values/README.md deleted file mode 100644 index 120a9652a..000000000 --- a/base/assert/has-same-values/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# hasSameValues - -> Test if two arrays have the same values. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); -``` - -#### hasSameValues( x, y ) - -Tests if two arrays have the same values. - -```javascript -var x = [ 0, 0, 1, 0 ]; -var y = [ 0, 0, 1, 0 ]; - -var bool = hasSameValues( x, y ); -// returns true -``` - -
- - - - - -
- -## Notes - -- If provided arrays of unequal length, the function returns `false`. -- The function does **not** skip `undefined` elements and is thus not optimized for sparse arrays. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var Complex128Array = require( '@stdlib/array/complex128' ); -var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); - -var buf = discreteUniform( 10, 0, 10 ); -// returns - -var x = new Complex128Array( buf ); -// returns - -var y = new Complex128Array( buf ); -// returns - -var out = hasSameValues( x, y ); -// returns true -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/has-same-values/benchmark/benchmark.length.js b/base/assert/has-same-values/benchmark/benchmark.length.js deleted file mode 100644 index 663fc63ff..000000000 --- a/base/assert/has-same-values/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var zeros = require( './../../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var hasSameValues = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = hasSameValues( x, x ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/assert/has-same-values/docs/repl.txt b/base/assert/has-same-values/docs/repl.txt deleted file mode 100644 index 3879571cc..000000000 --- a/base/assert/has-same-values/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, y ) - Tests if two arrays have the same values. - - If provided arrays of unequal length, the function returns `false`. - - Parameters - ---------- - x: Array|TypedArray|Object - First input array. - - y: Array|TypedArray|Object - Second input array. - - Returns - ------- - bool: boolean - The function returns `true` if both arrays have the same values; - otherwise, the function returns `false`. - - Examples - -------- - > var x = [ 0, 0, 1, 0 ]; - > var y = [ 0, 0, 1, 0 ]; - > var out = {{alias}}( x, y ) - true - - See Also - -------- - diff --git a/base/assert/has-same-values/docs/types/index.d.ts b/base/assert/has-same-values/docs/types/index.d.ts deleted file mode 100644 index 0a2203008..000000000 --- a/base/assert/has-same-values/docs/types/index.d.ts +++ /dev/null @@ -1,48 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Tests if two arrays have the same values. -* -* ## Notes -* -* - If provided arrays of unequal length, the function returns `false`. -* -* @param x - first input array -* @param y - second input array -* @returns boolean indicating whether both arrays have the same values -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasSameValues( x, y ); -* // returns true -*/ -declare function hasSameValues( x: Collection | AccessorArrayLike, y: Collection | AccessorArrayLike ): boolean; - - -// EXPORTS // - -export = hasSameValues; diff --git a/base/assert/has-same-values/docs/types/test.ts b/base/assert/has-same-values/docs/types/test.ts deleted file mode 100644 index efcaaa928..000000000 --- a/base/assert/has-same-values/docs/types/test.ts +++ /dev/null @@ -1,69 +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. -*/ - -import toAccessorArray = require( './../../../../../base/to-accessor-array' ); -import hasSameValues = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - const x = [ 1, 2, 3 ]; - - hasSameValues( x, x ); // $ExpectType boolean - hasSameValues( new Float64Array( x ), new Float64Array( x ) ); // $ExpectType boolean - hasSameValues( new Float32Array( x ), new Float32Array( x ) ); // $ExpectType boolean - hasSameValues( new Int32Array( x ), new Int32Array( x ) ); // $ExpectType boolean - hasSameValues( new Int16Array( x ), new Int16Array( x ) ); // $ExpectType boolean - hasSameValues( new Int8Array( x ), new Int8Array( x ) ); // $ExpectType boolean - hasSameValues( new Uint32Array( x ), new Uint32Array( x ) ); // $ExpectType boolean - hasSameValues( new Uint16Array( x ), new Uint16Array( x ) ); // $ExpectType boolean - hasSameValues( new Uint8Array( x ), new Uint8Array( x ) ); // $ExpectType boolean - hasSameValues( new Uint8ClampedArray( x ), new Uint8ClampedArray( x ) ); // $ExpectType boolean - hasSameValues( toAccessorArray( x ), toAccessorArray( x ) ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - hasSameValues( 2, x ); // $ExpectError - hasSameValues( false, x ); // $ExpectError - hasSameValues( true, x ); // $ExpectError - hasSameValues( {}, x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - hasSameValues( x, 2 ); // $ExpectError - hasSameValues( x, false ); // $ExpectError - hasSameValues( x, true ); // $ExpectError - hasSameValues( x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - hasSameValues(); // $ExpectError - hasSameValues( x ); // $ExpectError - hasSameValues( x, x, x ); // $ExpectError -} diff --git a/base/assert/has-same-values/examples/index.js b/base/assert/has-same-values/examples/index.js deleted file mode 100644 index 86f2c51ee..000000000 --- a/base/assert/has-same-values/examples/index.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var Complex128Array = require( './../../../../complex128' ); -var hasSameValues = require( './../lib' ); - -var buf = discreteUniform( 10, 0, 10 ); -// returns - -var x = new Complex128Array( buf ); -// returns - -var y = new Complex128Array( buf ); -// returns - -var out = hasSameValues( x, y ); -// returns true - -console.log( out ); -// => true diff --git a/base/assert/has-same-values/lib/index.js b/base/assert/has-same-values/lib/index.js deleted file mode 100644 index a2821c732..000000000 --- a/base/assert/has-same-values/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Test if two arrays have the same values. -* -* @module @stdlib/array/base/assert/has-same-values -* -* @example -* var hasSameValues = require( '@stdlib/array/base/assert/has-same-values' ); -* -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasSameValues( x, y ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/has-same-values/lib/main.js b/base/assert/has-same-values/lib/main.js deleted file mode 100644 index 41da45371..000000000 --- a/base/assert/has-same-values/lib/main.js +++ /dev/null @@ -1,188 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplex128Array = require( './../../../../base/assert/is-complex128array' ); -var isComplex64Array = require( './../../../../base/assert/is-complex64array' ); -var isBooleanArray = require( './../../../../base/assert/is-booleanarray' ); -var arraylike2object = require( './../../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var isSameValue = require( '@stdlib/assert/is-same-value' ); - - -// FUNCTIONS // - -/** -* Tests if two arrays have the same values. -* -* @private -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @returns {boolean} boolean indicating if both arrays have the same values -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = internal( x, y ); -* // returns true -* -* @example -* var x = [ 0, 0, 0, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = internal( x, y ); -* // returns false -*/ -function internal( x, y ) { - var i; - for ( i = 0; i < x.length; i++ ) { - if ( !isSameValue( x[ i ], y[ i ] ) ) { - return false; - } - } - return true; -} - -/** -* Tests if two arrays have the same values. -* -* @private -* @param {Object} x - first input array object -* @param {Object} y - second input array object -* @returns {boolean} boolean indicating if both arrays have the same values -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* -* var out = accessors( x, y ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) ); -* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) ); -* -* var out = accessors( x, y ); -* // returns false -*/ -function accessors( x, y ) { - var xdata; - var ydata; - var xget; - var yget; - var i; - - xdata = x.data; - ydata = y.data; - - xget = x.accessors[ 0 ]; - yget = y.accessors[ 0 ]; - - for ( i = 0; i < xdata.length; i++ ) { - if ( !isSameValue( xget( xdata, i ), yget( ydata, i ) ) ) { - return false; - } - } - return true; -} - - -// MAIN // - -/** -* Tests if two arrays have the same values. -* -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @returns {boolean} boolean indicating if both arrays have the same values -* -* @example -* var x = [ 0, 0, 1, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasSameValues( x, y ); -* // returns true -* -* @example -* var x = [ 0, 0, 0, 0 ]; -* var y = [ 0, 0, 1, 0 ]; -* -* var out = hasSameValues( x, y ); -* // returns false -*/ -function hasSameValues( x, y ) { - var FLG; - var xo; - var yo; - var xr; - var yr; - - if ( x.length !== y.length ) { - return false; - } - xo = arraylike2object( x ); - yo = arraylike2object( y ); - if ( xo.accessorProtocol || yo.accessorProtocol ) { - FLG = 2; - - // If provided boolean arrays, reinterpret the arrays to avoid using accessors to access array elements... - if ( isBooleanArray( x ) ) { - if ( isBooleanArray( y ) ) { - return internal( reinterpretBoolean( x, 0 ), reinterpretBoolean( y, 0 ) ); - } - return accessors( xo, yo ); - } - // If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components... - if ( isComplex128Array( x ) ) { - xr = reinterpret128( x, 0 ); - FLG -= 1; - } else if ( isComplex64Array( x ) ) { - xr = reinterpret64( x, 0 ); - FLG -= 1; - } - if ( isComplex128Array( y ) ) { - yr = reinterpret128( y, 0 ); - FLG -= 1; - } else if ( isComplex64Array( y ) ) { - yr = reinterpret64( y, 0 ); - FLG -= 1; - } - if ( FLG === 0 ) { - return internal( xr, yr ); - } - return accessors( xo, yo ); - } - return internal( x, y ); -} - - -// EXPORTS // - -module.exports = hasSameValues; diff --git a/base/assert/has-same-values/package.json b/base/assert/has-same-values/package.json deleted file mode 100644 index befde2baf..000000000 --- a/base/assert/has-same-values/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/has-same-values", - "version": "0.0.0", - "description": "Test if two arrays have the same values.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "assert", - "validate", - "same", - "deep", - "equal", - "equality", - "compare", - "comparison" - ] -} diff --git a/base/assert/has-same-values/test/test.js b/base/assert/has-same-values/test/test.js deleted file mode 100644 index 7b870b126..000000000 --- a/base/assert/has-same-values/test/test.js +++ /dev/null @@ -1,453 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../../base/accessor' ); -var Float64Array = require( './../../../../float64' ); -var Complex64Array = require( './../../../../complex64' ); -var Complex128Array = require( './../../../../complex128' ); -var BooleanArray = require( './../../../../bool' ); -var hasSameValues = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof hasSameValues, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided collections of unequal length, the function returns `false`', function test( t ) { - var out; - var x; - var y; - - x = []; - y = [ 1, 2, 3 ]; - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = [ 1, 2 ]; - y = [ 1, 2, 3 ]; - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 1 ] ); - y = []; - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (generic)', function test( t ) { - var out; - var x; - var y; - - x = []; - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = []; - y = []; - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [] ); - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [] ); - y = new Float64Array( [] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (mixed)', function test( t ) { - var out; - var x; - var y; - - x = []; - y = new Float64Array( [] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [] ); - y = []; - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [] ); - y = []; - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = []; - y = new BooleanArray( [] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (boolean array)', function test( t ) { - var out; - var x; - var y; - - x = new BooleanArray( [] ); - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [] ); - y = new BooleanArray( [] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (complex typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Complex64Array( [] ); - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex64Array( [] ); - y = new Complex64Array( [] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [] ); - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [] ); - y = new Complex128Array( [] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided empty collections, the function returns `true` (accessor)', function test( t ) { - var out; - var x; - var y; - - x = new AccessorArray( [] ); - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new AccessorArray( [] ); - y = new AccessorArray( [] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have the same values (generic)', function test( t ) { - var out; - var x; - var y; - - x = [ 1, 0, 3 ]; - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = [ 1, 0, 3 ]; - y = [ 1, 0, 3 ]; - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have the same values (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - y = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have the same values (mixed)', function test( t ) { - var out; - var x; - var y; - - x = [ 0.0, 2.0, 0.0 ]; - y = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - y = [ 0.0, 2.0, 0.0 ]; - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true ] ); - y = [ true, false, true ]; - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = [ true, false, true ]; - y = new BooleanArray( [ true, false, true ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have the same values (boolean array)', function test( t ) { - var out; - var x; - var y; - - x = new BooleanArray( [ true, false, true ] ); - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true ] ); - y = new BooleanArray( [ true, false, true ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have the same values (complex typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Complex64Array( [ 0.0, 2.0, 0.0, 0.0 ] ); - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 2.0, 0.0, 0.0 ] ); - y = new Complex64Array( [ 0.0, 2.0, 0.0, 0.0 ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 0.0, 3.0, 0.0 ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have the same values (accessor)', function test( t ) { - var out; - var x; - var y; - - x = new AccessorArray( [ 0, 2, 3 ] ); - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = new AccessorArray( [ 0, 2, 3 ] ); - y = new AccessorArray( [ 0, 2, 3 ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `true` if both arrays have the same values (array-like object)', function test( t ) { - var out; - var x; - var y; - - x = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - out = hasSameValues( x, x ); - t.strictEqual( out, true, 'returns expected value' ); - - x = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - y = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - out = hasSameValues( x, y ); - t.strictEqual( out, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have the same values (generic)', function test( t ) { - var out; - var x; - var y; - - x = [ 0, 0, 0 ]; - y = [ 0, 1, 0 ]; - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have the same values (real typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Float64Array( [ 0.0, 0.0, 0.0 ] ); - y = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have the same values (mixed)', function test( t ) { - var out; - var x; - var y; - - x = [ 0.0, 0.0, 0.0 ]; - y = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - y = [ 0.0, 0.0, 0.0 ]; - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0 ] ); - y = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have the same values (boolean array)', function test( t ) { - var out; - var x; - var y; - - x = new BooleanArray( [ true, false, false, true ] ); - y = new BooleanArray( [ true, true, false, false ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have the same values (complex typed array)', function test( t ) { - var out; - var x; - var y; - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - y = new Complex64Array( [ 0.0, 0.0, 0.0, 1.0 ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - y = new Complex128Array( [ 1.0, 0.0, 0.0, 0.0 ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have the same values (accessor)', function test( t ) { - var out; - var x; - var y; - - x = new AccessorArray( [ 0, 0, 1 ] ); - y = new AccessorArray( [ 0, 0, 0 ] ); - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `false` if both arrays do not have the same values (array-like object)', function test( t ) { - var out; - var x; - var y; - - x = { - 'length': 3, - '0': 0, - '1': 1, - '2': 0 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - out = hasSameValues( x, y ); - t.strictEqual( out, false, 'returns expected value' ); - - t.end(); -}); diff --git a/base/assert/is-accessor-array/README.md b/base/assert/is-accessor-array/README.md deleted file mode 100644 index 225cc6d06..000000000 --- a/base/assert/is-accessor-array/README.md +++ /dev/null @@ -1,160 +0,0 @@ - - -# isAccessorArray - -> Test if an array-like object supports the accessor (get/set) protocol. - -
- -An accessor array is defined as either an [`Array`][mdn-array], [`Typed Array`][mdn-typed-array], or an array-like [`Object`][mdn-object] (excluding `strings` and `functions`) having `get` and `set` methods for accessing array elements. - -
- - - -
- -## Usage - -```javascript -var isAccessorArray = require( '@stdlib/array/base/assert/is-accessor-array' ); -``` - -#### isAccessorArray( value ) - -Tests if an array-like object supports the accessor (get/set) protocol. - -```javascript -var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -// Create a new complex number array: -var arr = new Complex128Array( 10 ); - -// Retrieve a complex number element: -var z = arr.get( 0 ); -// returns - -// Set a complex number element: -arr.set( new Complex128( 1.0, 1.0 ), 0 ); - -// ... - -// Check whether an array is an accessor array: -var bool = isAccessorArray( arr ); -// returns true -``` - -
- - - -
- -## Examples - - - - - -```javascript -var Int8Array = require( '@stdlib/array/int8' ); -var Uint8Array = require( '@stdlib/array/uint8' ); -var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -var Int16Array = require( '@stdlib/array/int16' ); -var Uint16Array = require( '@stdlib/array/uint16' ); -var Int32Array = require( '@stdlib/array/int32' ); -var Uint32Array = require( '@stdlib/array/uint32' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex64Array = require( '@stdlib/array/complex64' ); -var isAccessorArray = require( '@stdlib/array/base/assert/is-accessor-array' ); - -var bool = isAccessorArray( new Complex128Array( 10 ) ); -// returns true - -bool = isAccessorArray( new Complex64Array( 10 ) ); -// returns true - -bool = isAccessorArray( [] ); -// returns false - -bool = isAccessorArray( new Float64Array( 10 ) ); -// returns false - -bool = isAccessorArray( new Float32Array( 10 ) ); -// returns false - -bool = isAccessorArray( new Int32Array( 10 ) ); -// returns false - -bool = isAccessorArray( new Uint32Array( 10 ) ); -// returns false - -bool = isAccessorArray( new Int16Array( 10 ) ); -// returns false - -bool = isAccessorArray( new Uint16Array( 10 ) ); -// returns false - -bool = isAccessorArray( new Int8Array( 10 ) ); -// returns false - -bool = isAccessorArray( new Uint8Array( 10 ) ); -// returns false - -bool = isAccessorArray( new Uint8ClampedArray( 10 ) ); -// returns false - -bool = isAccessorArray( { 'length': 0 } ); -// returns false -``` - -
- - - - - - - - - - - - - - diff --git a/base/assert/is-accessor-array/benchmark/benchmark.js b/base/assert/is-accessor-array/benchmark/benchmark.js deleted file mode 100644 index 9a2f649be..000000000 --- a/base/assert/is-accessor-array/benchmark/benchmark.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isAccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var bool; - var obj; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = [ i, i+1 ]; - bool = isAccessorArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real_typed_array', function benchmark( b ) { - var values; - var bool; - var obj; - var N; - var i; - - values = [ - new Float64Array( [ 1.0, 2.0 ] ), - new Float64Array( [ 3.0, 4.0 ] ) - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = values[ i%N ]; - bool = isAccessorArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex_typed_array', function benchmark( b ) { - var values; - var bool; - var obj; - var N; - var i; - - values = [ - new Complex128Array( [ 1.0, 2.0 ] ), - new Complex128Array( [ 3.0, 4.0 ] ) - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = values[ i%N ]; - bool = isAccessorArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like_object', function benchmark( b ) { - var bool; - var obj; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = { - 'length': 2, - '0': i, - '1': i + 1 - }; - bool = isAccessorArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-accessor-array/docs/repl.txt b/base/assert/is-accessor-array/docs/repl.txt deleted file mode 100644 index edfd23252..000000000 --- a/base/assert/is-accessor-array/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( value ) - Tests if an array-like object supports the accessor (get/set) protocol. - - An accessor array is defined as an array, typed array, or an array-like - object (excluding strings and functions) having `get` and `set` methods for - accessing array elements. - - Parameters - ---------- - value: ArrayLikeObject - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether a value is an accessor array. - - Examples - -------- - > var bool = {{alias}}( new {{alias:@stdlib/array/complex64}}( 10 ) ) - true - > bool = {{alias}}( [] ) - false - > bool = {{alias}}( { 'length': 0 } ) - false - - See Also - -------- - diff --git a/base/assert/is-accessor-array/docs/types/index.d.ts b/base/assert/is-accessor-array/docs/types/index.d.ts deleted file mode 100644 index 48023d728..000000000 --- a/base/assert/is-accessor-array/docs/types/index.d.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/array'; - -/** -* Interface defining an array-like object supporting the accessor (get/set) protocol. -*/ -interface AccessorArray { - /** - * Number of elements. - */ - length: number; - - /** - * Returns an array element. - * - * @param i - element index - * @returns array element - */ - get( i: number ): any; - - /** - * Sets an array element. - * - * @param value - value(s) - * @param i - element index at which to start writing values (default: 0) - */ - set( value: any, i?: number ): void; -} - -/** -* Tests if an array-like object supports the accessor (get/set) protocol. -* -* @param value - value to test -* @returns boolean indicating whether a value is an accessor array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var arr = new Complex128Array( 10 ); -* var bool = isAccessorArray( arr ); -* // returns true -* -* @example -* var bool = isAccessorArray( [] ); -* // returns false -*/ -declare function isAccessorArray( value: Collection | AccessorArray ): value is AccessorArray; - - -// EXPORTS // - -export = isAccessorArray; diff --git a/base/assert/is-accessor-array/docs/types/test.ts b/base/assert/is-accessor-array/docs/types/test.ts deleted file mode 100644 index 30586b959..000000000 --- a/base/assert/is-accessor-array/docs/types/test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 isAccessorArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isAccessorArray( [] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isAccessorArray(); // $ExpectError - isAccessorArray( [], 123 ); // $ExpectError -} diff --git a/base/assert/is-accessor-array/examples/index.js b/base/assert/is-accessor-array/examples/index.js deleted file mode 100644 index 1be4a05dd..000000000 --- a/base/assert/is-accessor-array/examples/index.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable object-curly-newline */ - -'use strict'; - -var Int8Array = require( './../../../../int8' ); -var Uint8Array = require( './../../../../uint8' ); -var Uint8ClampedArray = require( './../../../../uint8c' ); -var Int16Array = require( './../../../../int16' ); -var Uint16Array = require( './../../../../uint16' ); -var Int32Array = require( './../../../../int32' ); -var Uint32Array = require( './../../../../uint32' ); -var Float32Array = require( './../../../../float32' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var Complex64Array = require( './../../../../complex64' ); -var isAccessorArray = require( './../lib' ); - -console.log( isAccessorArray( new Complex128Array( 10 ) ) ); -// => true - -console.log( isAccessorArray( new Complex64Array( 10 ) ) ); -// => true - -console.log( isAccessorArray( [] ) ); -// => false - -console.log( isAccessorArray( new Float64Array( 10 ) ) ); -// => false - -console.log( isAccessorArray( new Float32Array( 10 ) ) ); -// => false - -console.log( isAccessorArray( new Int32Array( 10 ) ) ); -// => false - -console.log( isAccessorArray( new Uint32Array( 10 ) ) ); -// => false - -console.log( isAccessorArray( new Int16Array( 10 ) ) ); -// => false - -console.log( isAccessorArray( new Uint16Array( 10 ) ) ); -// => false - -console.log( isAccessorArray( new Int8Array( 10 ) ) ); -// => false - -console.log( isAccessorArray( new Uint8Array( 10 ) ) ); -// => false - -console.log( isAccessorArray( new Uint8ClampedArray( 10 ) ) ); -// => false - -console.log( isAccessorArray( { 'length': 0 } ) ); -// => false diff --git a/base/assert/is-accessor-array/lib/index.js b/base/assert/is-accessor-array/lib/index.js deleted file mode 100644 index 6287dae38..000000000 --- a/base/assert/is-accessor-array/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if an array-like object supports the accessor (get/set) protocol. -* -* @module @stdlib/array/base/assert/is-accessor-array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128array' ); -* var isAccessorArray = require( '@stdlib/array/base/assert/is-accessor-array' ); -* -* var bool = isAccessorArray( new Complex128Array( 10 ) ); -* // returns true -* -* bool = isAccessorArray( [] ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-accessor-array/lib/main.js b/base/assert/is-accessor-array/lib/main.js deleted file mode 100644 index 1f866353f..000000000 --- a/base/assert/is-accessor-array/lib/main.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var TYPE = 'function'; - - -// MAIN // - -/** -* Tests if an array-like object supports the accessor (get/set) protocol. -* -* @param {Object} value - value to test -* @returns {boolean} boolean indicating whether a value is an accessor array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var bool = isAccessorArray( new Complex128Array( 10 ) ); -* // returns true -* -* @example -* var bool = isAccessorArray( [] ); -* // returns false -*/ -function isAccessorArray( value ) { - return ( typeof value.get === TYPE && typeof value.set === TYPE ); // eslint-disable-line valid-typeof -} - - -// EXPORTS // - -module.exports = isAccessorArray; diff --git a/base/assert/is-accessor-array/package.json b/base/assert/is-accessor-array/package.json deleted file mode 100644 index 1a1ed7fc2..000000000 --- a/base/assert/is-accessor-array/package.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-accessor-array", - "version": "0.0.0", - "description": "Test if an array-like object supports the accessor (get/set) protocol.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdassert", - "assertion", - "assert", - "utilities", - "utility", - "utils", - "util", - "array", - "typed array", - "collection", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "is", - "isarray", - "accessors", - "type", - "check", - "test", - "valid", - "validate" - ] -} diff --git a/base/assert/is-accessor-array/test/test.js b/base/assert/is-accessor-array/test/test.js deleted file mode 100644 index 2deb61dd7..000000000 --- a/base/assert/is-accessor-array/test/test.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 constructorName = require( '@stdlib/utils/constructor-name' ); -var Int8Array = require( './../../../../int8' ); -var Uint8Array = require( './../../../../uint8' ); -var Uint8ClampedArray = require( './../../../../uint8c' ); -var Int16Array = require( './../../../../int16' ); -var Uint16Array = require( './../../../../uint16' ); -var Int32Array = require( './../../../../int32' ); -var Uint32Array = require( './../../../../uint32' ); -var Float32Array = require( './../../../../float32' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var Complex64Array = require( './../../../../complex64' ); -var allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' ); -var isAccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isAccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array-like object which supports the accessor protocol', function test( t ) { - var values; - var i; - - values = [ - new Complex128Array( 10 ), - new Complex64Array( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isAccessorArray( values[i] ), true, 'returns true when provided '+constructorName( values[i] ) ); - } - t.end(); -}); - -tape( 'the function returns `false` if provided an array-like object which does not support the accessor protocol', function test( t ) { - var values; - var i; - - values = [ - [], - { 'length': 10 }, // eslint-disable-line object-curly-newline - new Float64Array( 10 ), - new Float32Array( 10 ), - new Int32Array( 10 ), - new Uint32Array( 10 ), - new Int16Array( 10 ), - new Uint16Array( 10 ), - new Int8Array( 10 ), - new Uint8Array( 10 ), - new Uint8ClampedArray( 10 ), - allocUnsafe( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isAccessorArray( values[i] ), false, 'returns false when provided '+constructorName( values[i] ) ); - } - t.end(); -}); diff --git a/base/assert/is-boolean-data-type/README.md b/base/assert/is-boolean-data-type/README.md deleted file mode 100644 index 58a3e3c6c..000000000 --- a/base/assert/is-boolean-data-type/README.md +++ /dev/null @@ -1,150 +0,0 @@ - - -# isBooleanDataType - -> Test if an input value is a supported array boolean data type. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isBooleanDataType = require( '@stdlib/array/base/assert/is-boolean-data-type' ); -``` - -#### isBooleanDataType( value ) - -Tests if an input `value` is a supported array boolean data type. - -```javascript -var bool = isBooleanDataType( 'bool' ); -// returns true - -bool = isBooleanDataType( 'uint32' ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var isBooleanDataType = require( '@stdlib/array/base/assert/is-boolean-data-type' ); - -var bool = isBooleanDataType( 'bool' ); -// returns true - -bool = isBooleanDataType( 'complex64' ); -// returns false - -bool = isBooleanDataType( 'complex128' ); -// returns false - -bool = isBooleanDataType( 'float32' ); -// returns false - -bool = isBooleanDataType( 'float64' ); -// returns false - -bool = isBooleanDataType( 'generic' ); -// returns false - -bool = isBooleanDataType( 'int16' ); -// returns false - -bool = isBooleanDataType( 'int32' ); -// returns false - -bool = isBooleanDataType( 'int8' ); -// returns false - -bool = isBooleanDataType( 'uint16' ); -// returns false - -bool = isBooleanDataType( 'uint32' ); -// returns false - -bool = isBooleanDataType( 'uint8' ); -// returns false - -bool = isBooleanDataType( 'uint8c' ); -// returns false - -bool = isBooleanDataType( '' ); -// returns false - -bool = isBooleanDataType( 'foo' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-boolean-data-type/benchmark/benchmark.js b/base/assert/is-boolean-data-type/benchmark/benchmark.js deleted file mode 100644 index 433424754..000000000 --- a/base/assert/is-boolean-data-type/benchmark/benchmark.js +++ /dev/null @@ -1,73 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isBooleanDataType = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - 'binary', - 'bool', - 'complex128', - 'complex64', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'foo', - 'bar', - '', - 'beep', - 'boop' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ]; - out = isBooleanDataType( v ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-boolean-data-type/docs/repl.txt b/base/assert/is-boolean-data-type/docs/repl.txt deleted file mode 100644 index ddd090bdd..000000000 --- a/base/assert/is-boolean-data-type/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( value ) - Tests if an input value is a supported array boolean data type. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input value is a supported array boolean data - type. - - Examples - -------- - > var bool = {{alias}}( 'bool' ) - true - > bool = {{alias}}( 'float64' ) - false - > bool = {{alias}}( 'int16' ) - false - > bool = {{alias}}( 'int32' ) - false - > bool = {{alias}}( 'int8' ) - false - > bool = {{alias}}( 'uint16' ) - false - > bool = {{alias}}( 'uint32' ) - false - > bool = {{alias}}( 'uint8' ) - false - > bool = {{alias}}( 'uint8c' ) - false - > bool = {{alias}}( '' ) - false - > bool = {{alias}}( 'beep' ) - false - - See Also - -------- - diff --git a/base/assert/is-boolean-data-type/docs/types/index.d.ts b/base/assert/is-boolean-data-type/docs/types/index.d.ts deleted file mode 100644 index 0a7eeeebf..000000000 --- a/base/assert/is-boolean-data-type/docs/types/index.d.ts +++ /dev/null @@ -1,75 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests whether an input value is a supported array boolean data type. -* -* @param v - value to test -* @returns boolean indicating whether an input value is a supported array boolean data type -* -* @example -* var bool = isBooleanDataType( 'bool' ); -* // returns true -* -* bool = isBooleanDataType( 'complex64' ); -* // returns false -* -* bool = isBooleanDataType( 'complex128' ); -* // returns false -* -* bool = isBooleanDataType( 'float32' ); -* // returns false -* -* bool = isBooleanDataType( 'float64' ); -* // returns false -* -* bool = isBooleanDataType( 'generic' ); -* // returns false -* -* bool = isBooleanDataType( 'int16' ); -* // returns false -* -* bool = isBooleanDataType( 'int32' ); -* // returns false -* -* bool = isBooleanDataType( 'int8' ); -* // returns false -* -* bool = isBooleanDataType( 'uint16' ); -* // returns false -* -* bool = isBooleanDataType( 'uint32' ); -* // returns false -* -* bool = isBooleanDataType( 'uint8' ); -* // returns false -* -* bool = isBooleanDataType( 'uint8c' ); -* // returns false -* -* bool = isBooleanDataType( 'foo' ); -* // returns false -*/ -declare function isBooleanDataType( v: any ): boolean; - - -// EXPORTS // - -export = isBooleanDataType; diff --git a/base/assert/is-boolean-data-type/docs/types/test.ts b/base/assert/is-boolean-data-type/docs/types/test.ts deleted file mode 100644 index 0805aee7f..000000000 --- a/base/assert/is-boolean-data-type/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import isBooleanDataType = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isBooleanDataType( 'float32' ); // $ExpectType boolean - isBooleanDataType( 'foo' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isBooleanDataType(); // $ExpectError - isBooleanDataType( undefined, 123 ); // $ExpectError -} diff --git a/base/assert/is-boolean-data-type/examples/index.js b/base/assert/is-boolean-data-type/examples/index.js deleted file mode 100644 index ab73e8244..000000000 --- a/base/assert/is-boolean-data-type/examples/index.js +++ /dev/null @@ -1,81 +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. -*/ - -'use strict'; - -var isBooleanDataType = require( './../lib' ); - -var bool = isBooleanDataType( 'bool' ); -console.log( bool ); -// => true - -bool = isBooleanDataType( 'complex128' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'complex64' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'float64' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'float32' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'generic' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'int16' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'int32' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'int8' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'uint16' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'uint32' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'uint8' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'uint8c' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( '' ); -console.log( bool ); -// => false - -bool = isBooleanDataType( 'foo' ); -console.log( bool ); -// => false diff --git a/base/assert/is-boolean-data-type/lib/index.js b/base/assert/is-boolean-data-type/lib/index.js deleted file mode 100644 index f46bc793f..000000000 --- a/base/assert/is-boolean-data-type/lib/index.js +++ /dev/null @@ -1,79 +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. -*/ - -'use strict'; - -/** -* Test whether an input value is a supported array boolean data type. -* -* @module @stdlib/array/base/assert/is-boolean-data-type -* -* @example -* var isBooleanDataType = require( '@stdlib/array/base/assert/is-boolean-data-type' ); -* -* var bool = isBooleanDataType( 'bool' ); -* // returns true -* -* bool = isBooleanDataType( 'complex64' ); -* // returns false -* -* bool = isBooleanDataType( 'complex128' ); -* // returns false -* -* bool = isBooleanDataType( 'float32' ); -* // returns false -* -* bool = isBooleanDataType( 'float64' ); -* // returns false -* -* bool = isBooleanDataType( 'generic' ); -* // returns false -* -* bool = isBooleanDataType( 'int16' ); -* // returns false -* -* bool = isBooleanDataType( 'int32' ); -* // returns false -* -* bool = isBooleanDataType( 'int8' ); -* // returns false -* -* bool = isBooleanDataType( 'uint16' ); -* // returns false -* -* bool = isBooleanDataType( 'uint32' ); -* // returns false -* -* bool = isBooleanDataType( 'uint8' ); -* // returns false -* -* bool = isBooleanDataType( 'uint8c' ); -* // returns false -* -* bool = isBooleanDataType( 'foo' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-boolean-data-type/lib/main.js b/base/assert/is-boolean-data-type/lib/main.js deleted file mode 100644 index 76fb0d21d..000000000 --- a/base/assert/is-boolean-data-type/lib/main.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var contains = require( './../../../../base/assert/contains' ).factory; -var dtypes = require( './../../../../dtypes' ); - - -// MAIN // - -/** -* Tests whether an input value is a supported array boolean data type. -* -* @name isBooleanDataType -* @type {Function} -* @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported array boolean data type -* -* @example -* var bool = isBooleanDataType( 'bool' ); -* // returns true -* -* bool = isBooleanDataType( 'complex64' ); -* // returns false -* -* bool = isBooleanDataType( 'complex128' ); -* // returns false -* -* bool = isBooleanDataType( 'float32' ); -* // returns false -* -* bool = isBooleanDataType( 'float64' ); -* // returns false -* -* bool = isBooleanDataType( 'generic' ); -* // returns false -* -* bool = isBooleanDataType( 'int16' ); -* // returns false -* -* bool = isBooleanDataType( 'int32' ); -* // returns false -* -* bool = isBooleanDataType( 'int8' ); -* // returns false -* -* bool = isBooleanDataType( 'uint16' ); -* // returns false -* -* bool = isBooleanDataType( 'uint32' ); -* // returns false -* -* bool = isBooleanDataType( 'uint8' ); -* // returns false -* -* bool = isBooleanDataType( 'uint8c' ); -* // returns false -* -* bool = isBooleanDataType( 'foo' ); -* // returns false -*/ -var isBooleanDataType = contains( dtypes( 'boolean' ) ); - - -// EXPORTS // - -module.exports = isBooleanDataType; diff --git a/base/assert/is-boolean-data-type/package.json b/base/assert/is-boolean-data-type/package.json deleted file mode 100644 index 25ee1ce7a..000000000 --- a/base/assert/is-boolean-data-type/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-boolean-data-type", - "version": "0.0.0", - "description": "Test if an input value is a supported array boolean data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "dtype", - "data", - "utilities", - "utility", - "utils", - "util", - "assert", - "test", - "check", - "is", - "valid", - "validate", - "validation", - "isvalid" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-boolean-data-type/test/test.js b/base/assert/is-boolean-data-type/test/test.js deleted file mode 100644 index 0efbbf8ab..000000000 --- a/base/assert/is-boolean-data-type/test/test.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isBooleanDataType = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isBooleanDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a supported array boolean data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'bool' - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isBooleanDataType( values[ i ] ); - t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a supported array boolean data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - // Supported dtypes: - 'complex128', - 'complex64', - 'float32', - 'float64', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'int16', - 'int32', - 'int8', - 'generic', - - // Unsupported dtypes: - 'float', - 'int', - 'bin', - '', - 'beep', - 'boop', - 'foo', - 'bar', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isBooleanDataType( values[ i ] ); - t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/base/assert/is-booleanarray/README.md b/base/assert/is-booleanarray/README.md deleted file mode 100644 index 2ebd3464a..000000000 --- a/base/assert/is-booleanarray/README.md +++ /dev/null @@ -1,157 +0,0 @@ - - -# isBooleanArray - -> Test if a value is a [`BooleanArray`][@stdlib/array/bool]. - -
- -
- - - -
- -## Usage - -```javascript -var isBooleanArray = require( '@stdlib/array/base/assert/is-booleanarray' ); -``` - -#### isBooleanArray( value ) - -Tests if a value is a [`BooleanArray`][@stdlib/array/bool]. - -```javascript -var BooleanArray = require( '@stdlib/array/bool' ); - -var arr = new BooleanArray( 10 ); -var bool = isBooleanArray( arr ); -// returns true -``` - -
- - - -
- -## Notes - -- This function is not robust and that is intentional. This function provides a lower cost way to reasonably determine whether an input value is a [`BooleanArray`][@stdlib/array/bool] in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see [`@stdlib/assert/is-booleanarray`][@stdlib/assert/is-booleanarray]. - -
- - - -
- -## Examples - - - - - -```javascript -var Int8Array = require( '@stdlib/array/int8' ); -var Uint8Array = require( '@stdlib/array/uint8' ); -var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -var Int16Array = require( '@stdlib/array/int16' ); -var Uint16Array = require( '@stdlib/array/uint16' ); -var Int32Array = require( '@stdlib/array/int32' ); -var Uint32Array = require( '@stdlib/array/uint32' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex64Array = require( '@stdlib/array/complex64' ); -var BooleanArray = require( '@stdlib/array/bool' ); -var isBooleanArray = require( '@stdlib/array/base/assert/is-booleanarray' ); - -var bool = isBooleanArray( new BooleanArray( 10 ) ); -// returns true - -bool = isBooleanArray( new Complex64Array( 10 ) ); -// returns false - -bool = isBooleanArray( new Complex128Array( 10 ) ); -// returns false - -bool = isBooleanArray( [] ); -// returns false - -bool = isBooleanArray( new Float64Array( 10 ) ); -// returns false - -bool = isBooleanArray( new Float32Array( 10 ) ); -// returns false - -bool = isBooleanArray( new Int32Array( 10 ) ); -// returns false - -bool = isBooleanArray( new Uint32Array( 10 ) ); -// returns false - -bool = isBooleanArray( new Int16Array( 10 ) ); -// returns false - -bool = isBooleanArray( new Uint16Array( 10 ) ); -// returns false - -bool = isBooleanArray( new Int8Array( 10 ) ); -// returns false - -bool = isBooleanArray( new Uint8Array( 10 ) ); -// returns false - -bool = isBooleanArray( new Uint8ClampedArray( 10 ) ); -// returns false - -bool = isBooleanArray( { 'length': 0 } ); -// returns false -``` - -
- - - - - - - - - - - - - - diff --git a/base/assert/is-booleanarray/benchmark/benchmark.js b/base/assert/is-booleanarray/benchmark/benchmark.js deleted file mode 100644 index d562cb4c8..000000000 --- a/base/assert/is-booleanarray/benchmark/benchmark.js +++ /dev/null @@ -1,165 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float32Array = require( './../../../../float32' ); -var Complex64Array = require( './../../../../complex64' ); -var BooleanArray = require( './../../../../bool' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isBooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var bool; - var obj; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = [ i, i+1 ]; - bool = isBooleanArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::boolean_array', function benchmark( b ) { - var values; - var bool; - var obj; - var N; - var i; - - values = [ - new BooleanArray( [ true, false ] ), - new BooleanArray( [ false, true ] ) - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = values[ i%N ]; - bool = isBooleanArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real_typed_array', function benchmark( b ) { - var values; - var bool; - var obj; - var N; - var i; - - values = [ - new Float32Array( [ 1.0, 2.0 ] ), - new Float32Array( [ 3.0, 4.0 ] ) - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = values[ i%N ]; - bool = isBooleanArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex_typed_array', function benchmark( b ) { - var values; - var bool; - var obj; - var N; - var i; - - values = [ - new Complex64Array( [ 1.0, 2.0 ] ), - new Complex64Array( [ 3.0, 4.0 ] ) - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = values[ i%N ]; - bool = isBooleanArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like_object', function benchmark( b ) { - var bool; - var obj; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = { - 'length': 2, - '0': i, - '1': i + 1 - }; - bool = isBooleanArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-booleanarray/docs/repl.txt b/base/assert/is-booleanarray/docs/repl.txt deleted file mode 100644 index 347073291..000000000 --- a/base/assert/is-booleanarray/docs/repl.txt +++ /dev/null @@ -1,26 +0,0 @@ - -{{alias}}( value ) - Tests if a value is a BooleanArray. - - Parameters - ---------- - value: ArrayLikeObject - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether a value is a BooleanArray. - - Examples - -------- - > var bool = {{alias}}( new {{alias:@stdlib/array/bool}}( 10 ) ) - true - > bool = {{alias}}( [] ) - false - > bool = {{alias}}( { 'length': 0 } ) - false - - See Also - -------- - diff --git a/base/assert/is-booleanarray/docs/types/index.d.ts b/base/assert/is-booleanarray/docs/types/index.d.ts deleted file mode 100644 index 5625c7116..000000000 --- a/base/assert/is-booleanarray/docs/types/index.d.ts +++ /dev/null @@ -1,47 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, BooleanArray } from '@stdlib/types/array'; - -/** -* Tests if a value is a `BooleanArray`. -* -* @param value - value to test -* @returns boolean indicating whether a value is a `BooleanArray` -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var arr = new BooleanArray( 10 ); -* var bool = isBooleanArray( arr ); -* // returns true -* -* @example -* var bool = isBooleanArray( [] ); -* // returns false -*/ -declare function isBooleanArray( value: Collection | BooleanArray ): value is BooleanArray; - - -// EXPORTS // - -export = isBooleanArray; diff --git a/base/assert/is-booleanarray/docs/types/test.ts b/base/assert/is-booleanarray/docs/types/test.ts deleted file mode 100644 index dd955f8b2..000000000 --- a/base/assert/is-booleanarray/docs/types/test.ts +++ /dev/null @@ -1,33 +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. -*/ - -import isBooleanArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isBooleanArray( [] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isBooleanArray(); // $ExpectError - isBooleanArray( [], 123 ); // $ExpectError -} diff --git a/base/assert/is-booleanarray/examples/index.js b/base/assert/is-booleanarray/examples/index.js deleted file mode 100644 index c5dc7b79e..000000000 --- a/base/assert/is-booleanarray/examples/index.js +++ /dev/null @@ -1,77 +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. -*/ - -/* eslint-disable object-curly-newline */ - -'use strict'; - -var Int8Array = require( './../../../../int8' ); -var Uint8Array = require( './../../../../uint8' ); -var Uint8ClampedArray = require( './../../../../uint8c' ); -var Int16Array = require( './../../../../int16' ); -var Uint16Array = require( './../../../../uint16' ); -var Int32Array = require( './../../../../int32' ); -var Uint32Array = require( './../../../../uint32' ); -var Float32Array = require( './../../../../float32' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var Complex64Array = require( './../../../../complex64' ); -var BooleanArray = require( './../../../../bool' ); -var isBooleanArray = require( './../lib' ); - -console.log( isBooleanArray( new BooleanArray( 10 ) ) ); -// => true - -console.log( isBooleanArray( new Complex64Array( 10 ) ) ); -// => false - -console.log( isBooleanArray( new Complex128Array( 10 ) ) ); -// => false - -console.log( isBooleanArray( [] ) ); -// => false - -console.log( isBooleanArray( new Float64Array( 10 ) ) ); -// => false - -console.log( isBooleanArray( new Float32Array( 10 ) ) ); -// => false - -console.log( isBooleanArray( new Int32Array( 10 ) ) ); -// => false - -console.log( isBooleanArray( new Uint32Array( 10 ) ) ); -// => false - -console.log( isBooleanArray( new Int16Array( 10 ) ) ); -// => false - -console.log( isBooleanArray( new Uint16Array( 10 ) ) ); -// => false - -console.log( isBooleanArray( new Int8Array( 10 ) ) ); -// => false - -console.log( isBooleanArray( new Uint8Array( 10 ) ) ); -// => false - -console.log( isBooleanArray( new Uint8ClampedArray( 10 ) ) ); -// => false - -console.log( isBooleanArray( { 'length': 0 } ) ); -// => false diff --git a/base/assert/is-booleanarray/lib/index.js b/base/assert/is-booleanarray/lib/index.js deleted file mode 100644 index f1d5519c0..000000000 --- a/base/assert/is-booleanarray/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Test if a value is a `BooleanArray`. -* -* @module @stdlib/array/base/assert/is-booleanarray -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* var isBooleanArray = require( '@stdlib/array/base/assert/is-booleanarray' ); -* -* var bool = isBooleanArray( new BooleanArray( 10 ) ); -* // returns true -* -* bool = isBooleanArray( [] ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-booleanarray/lib/main.js b/base/assert/is-booleanarray/lib/main.js deleted file mode 100644 index 62a6ce6dc..000000000 --- a/base/assert/is-booleanarray/lib/main.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// VARIABLES // - -var BYTES_PER_ELEMENT = 1; // 1 bytes per uint8 - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `BooleanArray`. -* -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `BooleanArray` -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var bool = isBooleanArray( new BooleanArray( 10 ) ); -* // returns true -* -* bool = isBooleanArray( [] ); -* // returns false -*/ -function isBooleanArray( value ) { - // Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `BooleanArray` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-booleanarray`. - return ( - typeof value === 'object' && - value !== null && - value.constructor.name === 'BooleanArray' && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); -} - - -// EXPORTS // - -module.exports = isBooleanArray; diff --git a/base/assert/is-booleanarray/package.json b/base/assert/is-booleanarray/package.json deleted file mode 100644 index 7e8782c54..000000000 --- a/base/assert/is-booleanarray/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-booleanarray", - "version": "0.0.0", - "description": "Test if a value is a BooleanArray.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdassert", - "assertion", - "assert", - "utilities", - "utility", - "utils", - "util", - "base", - "array", - "typed array", - "collection", - "booleanarray", - "is", - "isarray", - "type", - "check", - "test", - "valid", - "validate" - ] -} diff --git a/base/assert/is-booleanarray/test/test.js b/base/assert/is-booleanarray/test/test.js deleted file mode 100644 index 294c35c18..000000000 --- a/base/assert/is-booleanarray/test/test.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var constructorName = require( '@stdlib/utils/constructor-name' ); -var Int8Array = require( './../../../../int8' ); -var Uint8Array = require( './../../../../uint8' ); -var Uint8ClampedArray = require( './../../../../uint8c' ); -var Int16Array = require( './../../../../int16' ); -var Uint16Array = require( './../../../../uint16' ); -var Int32Array = require( './../../../../int32' ); -var Uint32Array = require( './../../../../uint32' ); -var Float32Array = require( './../../../../float32' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var Complex64Array = require( './../../../../complex64' ); -var BooleanArray = require( './../../../../bool' ); -var allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' ); -var isBooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isBooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a BooleanArray', function test( t ) { - var values; - var i; - - values = [ - new BooleanArray( 20 ), - new BooleanArray( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isBooleanArray( values[i] ), true, 'returns expected value when provided '+constructorName( values[i] ) ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a BooleanArray', function test( t ) { - var values; - var i; - - values = [ - void 0, - null, - {}, - [], - { 'length': 10 }, // eslint-disable-line object-curly-newline - new Float64Array( 10 ), - new Float32Array( 10 ), - new Int32Array( 10 ), - new Uint32Array( 10 ), - new Int16Array( 10 ), - new Uint16Array( 10 ), - new Int8Array( 10 ), - new Uint8Array( 10 ), - new Uint8ClampedArray( 10 ), - new Complex128Array( 10 ), - new Complex64Array( 10 ), - allocUnsafe( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isBooleanArray( values[i] ), false, 'returns expected value when provided '+constructorName( values[i] ) ); - } - t.end(); -}); diff --git a/base/assert/is-byte-order/README.md b/base/assert/is-byte-order/README.md deleted file mode 100644 index e7f2bfe14..000000000 --- a/base/assert/is-byte-order/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# isByteOrder - -> Test if an input value is a supported array byte order. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isByteOrder = require( '@stdlib/array/base/assert/is-byte-order' ); -``` - -#### isByteOrder( value ) - -Tests if an input `value` is a supported array byte order. - -```javascript -var bool = isByteOrder( 'little-endian' ); -// returns true - -bool = isByteOrder( 'big-endian' ); -// returns true -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var isByteOrder = require( '@stdlib/array/base/assert/is-byte-order' ); - -var bool = isByteOrder( 'little-endian' ); -// returns true - -bool = isByteOrder( 'big-endian' ); -// returns true - -bool = isByteOrder( '' ); -// returns false - -bool = isByteOrder( 'foo' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-byte-order/benchmark/benchmark.js b/base/assert/is-byte-order/benchmark/benchmark.js deleted file mode 100644 index 56ac0a39b..000000000 --- a/base/assert/is-byte-order/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isByteOrder = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - 'little-endian', - 'big-endian', - 'foo', - 'bar', - '', - 'beep', - 'boop' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ]; - out = isByteOrder( v ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-byte-order/docs/repl.txt b/base/assert/is-byte-order/docs/repl.txt deleted file mode 100644 index 99bfd0ec5..000000000 --- a/base/assert/is-byte-order/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( value ) - Tests if an input value is a supported array byte order. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input value is a supported array byte order. - - Examples - -------- - > var bool = {{alias}}( 'little-endian' ) - true - > bool = {{alias}}( 'big-endian' ) - true - > bool = {{alias}}( '' ) - false - > bool = {{alias}}( 'beep' ) - false - - See Also - -------- - diff --git a/base/assert/is-byte-order/docs/types/index.d.ts b/base/assert/is-byte-order/docs/types/index.d.ts deleted file mode 100644 index 8f4648b29..000000000 --- a/base/assert/is-byte-order/docs/types/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests whether an input value is a supported array byte order. -* -* @param v - value to test -* @returns boolean indicating whether an input value is a supported array byte order -* -* @example -* var bool = isByteOrder( 'little-endian' ); -* // returns true -* -* bool = isByteOrder( 'big-endian' ); -* // returns true -* -* bool = isByteOrder( 'foo' ); -* // returns false -*/ -declare function isByteOrder( v: any ): boolean; - - -// EXPORTS // - -export = isByteOrder; diff --git a/base/assert/is-byte-order/docs/types/test.ts b/base/assert/is-byte-order/docs/types/test.ts deleted file mode 100644 index 791513a03..000000000 --- a/base/assert/is-byte-order/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import isByteOrder = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isByteOrder( 'little-endian' ); // $ExpectType boolean - isByteOrder( 'foo' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isByteOrder(); // $ExpectError - isByteOrder( undefined, 123 ); // $ExpectError -} diff --git a/base/assert/is-byte-order/examples/index.js b/base/assert/is-byte-order/examples/index.js deleted file mode 100644 index c752f4d54..000000000 --- a/base/assert/is-byte-order/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var isByteOrder = require( './../lib' ); - -var bool = isByteOrder( 'little-endian' ); -console.log( bool ); -// => true - -bool = isByteOrder( 'big-endian' ); -console.log( bool ); -// => true - -bool = isByteOrder( '' ); -console.log( bool ); -// => false - -bool = isByteOrder( 'foo' ); -console.log( bool ); -// => false diff --git a/base/assert/is-byte-order/lib/index.js b/base/assert/is-byte-order/lib/index.js deleted file mode 100644 index 43381c393..000000000 --- a/base/assert/is-byte-order/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Test whether an input value is a supported array byte order. -* -* @module @stdlib/array/base/assert/is-byte-order -* -* @example -* var isByteOrder = require( '@stdlib/array/base/assert/is-byte-order' ); -* -* var bool = isByteOrder( 'little-endian' ); -* // returns true -* -* bool = isByteOrder( 'big-endian' ); -* // returns true -* -* bool = isByteOrder( 'foo' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-byte-order/lib/main.js b/base/assert/is-byte-order/lib/main.js deleted file mode 100644 index 0bc17a6e3..000000000 --- a/base/assert/is-byte-order/lib/main.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var contains = require( './../../../../base/assert/contains' ).factory; -var byteOrders = require( './../../../../byte-orders' ); - - -// MAIN // - -/** -* Tests whether an input value is a supported array byte order. -* -* @name isByteOrder -* @type {Function} -* @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported array byte order -* -* @example -* var bool = isByteOrder( 'little-endian' ); -* // returns true -* -* bool = isByteOrder( 'big-endian' ); -* // returns true -* -* bool = isByteOrder( 'foo' ); -* // returns false -*/ -var isByteOrder = contains( byteOrders() ); - - -// EXPORTS // - -module.exports = isByteOrder; diff --git a/base/assert/is-byte-order/package.json b/base/assert/is-byte-order/package.json deleted file mode 100644 index b9e76faf7..000000000 --- a/base/assert/is-byte-order/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-byte-order", - "version": "0.0.0", - "description": "Test if an input value is a supported array byte order.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "order", - "memory", - "endianness", - "endian", - "utilities", - "utility", - "utils", - "util", - "assert", - "test", - "check", - "is", - "valid", - "validate", - "validation", - "isvalid" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-byte-order/test/test.js b/base/assert/is-byte-order/test/test.js deleted file mode 100644 index e2aff3323..000000000 --- a/base/assert/is-byte-order/test/test.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isByteOrder = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isByteOrder, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a supported array byte order', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'little-endian', - 'big-endian' - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isByteOrder( values[ i ] ); - t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a supported array byte order', function test( t ) { - var values; - var bool; - var i; - - values = [ - '', - 'beep', - 'boop', - 'foo', - 'bar', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isByteOrder( values[ i ] ); - t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/base/assert/is-complex-floating-point-data-type/README.md b/base/assert/is-complex-floating-point-data-type/README.md deleted file mode 100644 index 1d5200d2f..000000000 --- a/base/assert/is-complex-floating-point-data-type/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# isComplexFloatingPointDataType - -> Test if an input value is a supported array complex-valued floating-point data type. - - - -
- -
- - - - - -
- -## Usage - - - -```javascript -var isComplexFloatingPointDataType = require( '@stdlib/array/base/assert/is-complex-floating-point-data-type' ); -``` - -#### isComplexFloatingPointDataType( value ) - -Tests if an input `value` is a supported array complex-valued floating-point data type. - - - -```javascript -var bool = isComplexFloatingPointDataType( 'complex128' ); -// returns true - -bool = isComplexFloatingPointDataType( 'uint32' ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - - - -```javascript -var isComplexFloatingPointDataType = require( '@stdlib/array/base/assert/is-complex-floating-point-data-type' ); - -var bool = isComplexFloatingPointDataType( 'complex128' ); -// returns true - -bool = isComplexFloatingPointDataType( 'complex64' ); -// returns true - -bool = isComplexFloatingPointDataType( 'float32' ); -// returns false - -bool = isComplexFloatingPointDataType( 'float64' ); -// returns false - -bool = isComplexFloatingPointDataType( 'generic' ); -// returns false - -bool = isComplexFloatingPointDataType( 'int16' ); -// returns false - -bool = isComplexFloatingPointDataType( 'int32' ); -// returns false - -bool = isComplexFloatingPointDataType( 'int8' ); -// returns false - -bool = isComplexFloatingPointDataType( 'uint16' ); -// returns false - -bool = isComplexFloatingPointDataType( 'uint32' ); -// returns false - -bool = isComplexFloatingPointDataType( 'uint8' ); -// returns false - -bool = isComplexFloatingPointDataType( 'uint8c' ); -// returns false - -bool = isComplexFloatingPointDataType( '' ); -// returns false - -bool = isComplexFloatingPointDataType( 'foo' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-complex-floating-point-data-type/benchmark/benchmark.js b/base/assert/is-complex-floating-point-data-type/benchmark/benchmark.js deleted file mode 100644 index 6622c53da..000000000 --- a/base/assert/is-complex-floating-point-data-type/benchmark/benchmark.js +++ /dev/null @@ -1,72 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isComplexFloatingPointDataType = require( './../lib' ); // eslint-disable-line id-length - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - 'binary', - 'complex128', - 'complex64', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'foo', - 'bar', - '', - 'beep', - 'boop' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ]; - out = isComplexFloatingPointDataType( v ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-complex-floating-point-data-type/docs/repl.txt b/base/assert/is-complex-floating-point-data-type/docs/repl.txt deleted file mode 100644 index 1ec451fc2..000000000 --- a/base/assert/is-complex-floating-point-data-type/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( value ) - Tests if an input value is a supported array complex-valued floating-point - data type. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input value is a supported array complex-valued - floating-point data type. - - Examples - -------- - > var bool = {{alias}}( 'complex64' ) - true - > bool = {{alias}}( 'float64' ) - false - > bool = {{alias}}( 'int16' ) - false - > bool = {{alias}}( 'int32' ) - false - > bool = {{alias}}( 'int8' ) - false - > bool = {{alias}}( 'uint16' ) - false - > bool = {{alias}}( 'uint32' ) - false - > bool = {{alias}}( 'uint8' ) - false - > bool = {{alias}}( 'uint8c' ) - false - > bool = {{alias}}( '' ) - false - > bool = {{alias}}( 'beep' ) - false - - See Also - -------- - diff --git a/base/assert/is-complex-floating-point-data-type/docs/types/index.d.ts b/base/assert/is-complex-floating-point-data-type/docs/types/index.d.ts deleted file mode 100644 index 6f9b853f5..000000000 --- a/base/assert/is-complex-floating-point-data-type/docs/types/index.d.ts +++ /dev/null @@ -1,72 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests whether an input value is a supported array complex-valued floating-point data type. -* -* @param v - value to test -* @returns boolean indicating whether an input value is a supported array complex-valued floating-point data type -* -* @example -* var bool = isComplexFloatingPointDataType( 'complex64' ); -* // returns true -* -* bool = isComplexFloatingPointDataType( 'complex128' ); -* // returns true -* -* bool = isComplexFloatingPointDataType( 'float32' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'float64' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'generic' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'int16' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'int32' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'int8' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint16' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint32' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint8' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint8c' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'foo' ); -* // returns false -*/ -declare function isComplexFloatingPointDataType( v: any ): boolean; - - -// EXPORTS // - -export = isComplexFloatingPointDataType; diff --git a/base/assert/is-complex-floating-point-data-type/docs/types/test.ts b/base/assert/is-complex-floating-point-data-type/docs/types/test.ts deleted file mode 100644 index e85b9d87c..000000000 --- a/base/assert/is-complex-floating-point-data-type/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import isComplexFloatingPointDataType = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isComplexFloatingPointDataType( 'float32' ); // $ExpectType boolean - isComplexFloatingPointDataType( 'foo' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isComplexFloatingPointDataType(); // $ExpectError - isComplexFloatingPointDataType( undefined, 123 ); // $ExpectError -} diff --git a/base/assert/is-complex-floating-point-data-type/examples/index.js b/base/assert/is-complex-floating-point-data-type/examples/index.js deleted file mode 100644 index 68dfa32a8..000000000 --- a/base/assert/is-complex-floating-point-data-type/examples/index.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -var isComplexFloatingPointDataType = require( './../lib' ); // eslint-disable-line id-length - -var bool = isComplexFloatingPointDataType( 'complex128' ); -console.log( bool ); -// => true - -bool = isComplexFloatingPointDataType( 'complex64' ); -console.log( bool ); -// => true - -bool = isComplexFloatingPointDataType( 'float64' ); -console.log( bool ); -// => false - -bool = isComplexFloatingPointDataType( 'float32' ); -console.log( bool ); -// => false - -bool = isComplexFloatingPointDataType( 'generic' ); -console.log( bool ); -// => false - -bool = isComplexFloatingPointDataType( 'int16' ); -console.log( bool ); -// => false - -bool = isComplexFloatingPointDataType( 'int32' ); -console.log( bool ); -// => false - -bool = isComplexFloatingPointDataType( 'int8' ); -console.log( bool ); -// => false - -bool = isComplexFloatingPointDataType( 'uint16' ); -console.log( bool ); -// => false - -bool = isComplexFloatingPointDataType( 'uint32' ); -console.log( bool ); -// => false - -bool = isComplexFloatingPointDataType( 'uint8' ); -console.log( bool ); -// => false - -bool = isComplexFloatingPointDataType( 'uint8c' ); -console.log( bool ); -// => false - -bool = isComplexFloatingPointDataType( '' ); -console.log( bool ); -// => false - -bool = isComplexFloatingPointDataType( 'foo' ); -console.log( bool ); -// => false diff --git a/base/assert/is-complex-floating-point-data-type/lib/index.js b/base/assert/is-complex-floating-point-data-type/lib/index.js deleted file mode 100644 index 4fb4e7955..000000000 --- a/base/assert/is-complex-floating-point-data-type/lib/index.js +++ /dev/null @@ -1,76 +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. -*/ - -'use strict'; - -/** -* Test whether an input value is a supported array complex-valued floating-point data type. -* -* @module @stdlib/array/base/assert/is-complex-floating-point-data-type -* -* @example -* var isComplexFloatingPointDataType = require( '@stdlib/array/base/assert/is-complex-floating-point-data-type' ); -* -* var bool = isComplexFloatingPointDataType( 'complex64' ); -* // returns true -* -* bool = isComplexFloatingPointDataType( 'complex128' ); -* // returns true -* -* bool = isComplexFloatingPointDataType( 'float32' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'float64' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'generic' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'int16' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'int32' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'int8' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint16' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint32' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint8' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint8c' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'foo' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-complex-floating-point-data-type/lib/main.js b/base/assert/is-complex-floating-point-data-type/lib/main.js deleted file mode 100644 index 796d1fbb3..000000000 --- a/base/assert/is-complex-floating-point-data-type/lib/main.js +++ /dev/null @@ -1,82 +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. -*/ - -'use strict'; - -// MODULES // - -var contains = require( './../../../../base/assert/contains' ).factory; -var dtypes = require( './../../../../dtypes' ); - - -// MAIN // - -/** -* Tests whether an input value is a supported array complex-valued floating-point data type. -* -* @name isComplexFloatingPointDataType -* @type {Function} -* @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported array complex-valued floating-point data type -* -* @example -* var bool = isComplexFloatingPointDataType( 'complex64' ); -* // returns true -* -* bool = isComplexFloatingPointDataType( 'complex128' ); -* // returns true -* -* bool = isComplexFloatingPointDataType( 'float32' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'float64' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'generic' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'int16' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'int32' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'int8' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint16' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint32' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint8' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'uint8c' ); -* // returns false -* -* bool = isComplexFloatingPointDataType( 'foo' ); -* // returns false -*/ -var isComplexFloatingPointDataType = contains( dtypes( 'complex_floating_point' ) ); // eslint-disable-line id-length - - -// EXPORTS // - -module.exports = isComplexFloatingPointDataType; diff --git a/base/assert/is-complex-floating-point-data-type/package.json b/base/assert/is-complex-floating-point-data-type/package.json deleted file mode 100644 index 5c87b9640..000000000 --- a/base/assert/is-complex-floating-point-data-type/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-complex-floating-point-data-type", - "version": "0.0.0", - "description": "Test if an input value is a supported array complex-valued floating-point data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "dtype", - "data", - "utilities", - "utility", - "utils", - "util", - "assert", - "test", - "check", - "is", - "valid", - "validate", - "validation", - "isvalid" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-complex-floating-point-data-type/test/test.js b/base/assert/is-complex-floating-point-data-type/test/test.js deleted file mode 100644 index ccc3e0fde..000000000 --- a/base/assert/is-complex-floating-point-data-type/test/test.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isComplexFloatingPointDataType = require( './../lib' ); // eslint-disable-line id-length - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isComplexFloatingPointDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a supported array complex-valued floating-point data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'complex64', - 'complex128' - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isComplexFloatingPointDataType( values[ i ] ); - t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a supported array complex-valued floating-point data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - // Supported dtypes: - 'float32', - 'float64', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'int16', - 'int32', - 'int8', - 'generic', - - // Unsupported dtypes: - 'float', - 'int', - 'bin', - '', - 'beep', - 'boop', - 'foo', - 'bar', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isComplexFloatingPointDataType( values[ i ] ); - t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/base/assert/is-complex-typed-array/README.md b/base/assert/is-complex-typed-array/README.md deleted file mode 100644 index 42b560794..000000000 --- a/base/assert/is-complex-typed-array/README.md +++ /dev/null @@ -1,151 +0,0 @@ - - -# isComplexTypedArray - -> Test if a value is a complex typed array. - -
- -
- - - -
- -## Usage - -```javascript -var isComplexTypedArray = require( '@stdlib/array/base/assert/is-complex-typed-array' ); -``` - -#### isComplexTypedArray( value ) - -Tests if a value is a complex typed array. - -```javascript -var Complex128Array = require( '@stdlib/array/complex128' ); - -var arr = new Complex128Array( 10 ); -var bool = isComplexTypedArray( arr ); -// returns true -``` - -
- - - -
- -## Notes - -- This function is not robust and that is intentional. This function provides a lower cost way to reasonably determine whether an input value is a complex typed array in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see [`@stdlib/assert/is-complex-typed-array`][@stdlib/assert/is-complex-typed-array]. - -
- - - -
- -## Examples - - - - - -```javascript -var Int8Array = require( '@stdlib/array/int8' ); -var Uint8Array = require( '@stdlib/array/uint8' ); -var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -var Int16Array = require( '@stdlib/array/int16' ); -var Uint16Array = require( '@stdlib/array/uint16' ); -var Int32Array = require( '@stdlib/array/int32' ); -var Uint32Array = require( '@stdlib/array/uint32' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex64Array = require( '@stdlib/array/complex64' ); -var isComplexTypedArray = require( '@stdlib/array/base/assert/is-complex-typed-array' ); - -var bool = isComplexTypedArray( new Complex128Array( 10 ) ); -// returns true - -bool = isComplexTypedArray( new Complex64Array( 10 ) ); -// returns true - -bool = isComplexTypedArray( [] ); -// returns false - -bool = isComplexTypedArray( new Float64Array( 10 ) ); -// returns false - -bool = isComplexTypedArray( new Float32Array( 10 ) ); -// returns false - -bool = isComplexTypedArray( new Int32Array( 10 ) ); -// returns false - -bool = isComplexTypedArray( new Uint32Array( 10 ) ); -// returns false - -bool = isComplexTypedArray( new Int16Array( 10 ) ); -// returns false - -bool = isComplexTypedArray( new Uint16Array( 10 ) ); -// returns false - -bool = isComplexTypedArray( new Int8Array( 10 ) ); -// returns false - -bool = isComplexTypedArray( new Uint8Array( 10 ) ); -// returns false - -bool = isComplexTypedArray( new Uint8ClampedArray( 10 ) ); -// returns false - -bool = isComplexTypedArray( { 'length': 0 } ); -// returns false -``` - -
- - - - - - - - - - - - - - diff --git a/base/assert/is-complex-typed-array/benchmark/benchmark.js b/base/assert/is-complex-typed-array/benchmark/benchmark.js deleted file mode 100644 index 6d8fbacd2..000000000 --- a/base/assert/is-complex-typed-array/benchmark/benchmark.js +++ /dev/null @@ -1,136 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var Complex64Array = require( './../../../../complex64' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isComplexTypedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var bool; - var obj; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = [ i, i+1 ]; - bool = isComplexTypedArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real_typed_array', function benchmark( b ) { - var values; - var bool; - var obj; - var N; - var i; - - values = [ - new Float64Array( [ 1.0, 2.0 ] ), - new Float64Array( [ 3.0, 4.0 ] ) - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = values[ i%N ]; - bool = isComplexTypedArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex_typed_array', function benchmark( b ) { - var values; - var bool; - var obj; - var N; - var i; - - values = [ - new Complex128Array( [ 1.0, 2.0 ] ), - new Complex64Array( [ 3.0, 4.0 ] ) - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = values[ i%N ]; - bool = isComplexTypedArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like_object', function benchmark( b ) { - var bool; - var obj; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = { - 'length': 2, - '0': i, - '1': i + 1 - }; - bool = isComplexTypedArray( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-complex-typed-array/docs/repl.txt b/base/assert/is-complex-typed-array/docs/repl.txt deleted file mode 100644 index cbe9b0a00..000000000 --- a/base/assert/is-complex-typed-array/docs/repl.txt +++ /dev/null @@ -1,26 +0,0 @@ - -{{alias}}( value ) - Tests if a value is a complex typed array. - - Parameters - ---------- - value: ArrayLikeObject - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether a value is a complex typed array. - - Examples - -------- - > var bool = {{alias}}( new {{alias:@stdlib/array/complex128}}( 10 ) ) - true - > bool = {{alias}}( [] ) - false - > bool = {{alias}}( { 'length': 0 } ) - false - - See Also - -------- - diff --git a/base/assert/is-complex-typed-array/docs/types/index.d.ts b/base/assert/is-complex-typed-array/docs/types/index.d.ts deleted file mode 100644 index 6df08143f..000000000 --- a/base/assert/is-complex-typed-array/docs/types/index.d.ts +++ /dev/null @@ -1,47 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, ComplexTypedArray } from '@stdlib/types/array'; - -/** -* Tests if a value is a complex typed array. -* -* @param value - value to test -* @returns boolean indicating whether a value is complex typed array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var arr = new Complex128Array( 10 ); -* var bool = isComplexTypedArray( arr ); -* // returns true -* -* @example -* var bool = isComplexTypedArray( [] ); -* // returns false -*/ -declare function isComplexTypedArray( value: Collection | ComplexTypedArray ): value is ComplexTypedArray; - - -// EXPORTS // - -export = isComplexTypedArray; diff --git a/base/assert/is-complex-typed-array/docs/types/test.ts b/base/assert/is-complex-typed-array/docs/types/test.ts deleted file mode 100644 index 97f480f53..000000000 --- a/base/assert/is-complex-typed-array/docs/types/test.ts +++ /dev/null @@ -1,33 +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. -*/ - -import isComplexTypedArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isComplexTypedArray( [] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isComplexTypedArray(); // $ExpectError - isComplexTypedArray( [], 123 ); // $ExpectError -} diff --git a/base/assert/is-complex-typed-array/examples/index.js b/base/assert/is-complex-typed-array/examples/index.js deleted file mode 100644 index ec386a689..000000000 --- a/base/assert/is-complex-typed-array/examples/index.js +++ /dev/null @@ -1,73 +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. -*/ - -/* eslint-disable object-curly-newline */ - -'use strict'; - -var Int8Array = require( './../../../../int8' ); -var Uint8Array = require( './../../../../uint8' ); -var Uint8ClampedArray = require( './../../../../uint8c' ); -var Int16Array = require( './../../../../int16' ); -var Uint16Array = require( './../../../../uint16' ); -var Int32Array = require( './../../../../int32' ); -var Uint32Array = require( './../../../../uint32' ); -var Float32Array = require( './../../../../float32' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var Complex64Array = require( './../../../../complex64' ); -var isComplexTypedArray = require( './../lib' ); - -console.log( isComplexTypedArray( new Complex128Array( 10 ) ) ); -// => true - -console.log( isComplexTypedArray( new Complex64Array( 10 ) ) ); -// => true - -console.log( isComplexTypedArray( [] ) ); -// => false - -console.log( isComplexTypedArray( new Float64Array( 10 ) ) ); -// => false - -console.log( isComplexTypedArray( new Float32Array( 10 ) ) ); -// => false - -console.log( isComplexTypedArray( new Int32Array( 10 ) ) ); -// => false - -console.log( isComplexTypedArray( new Uint32Array( 10 ) ) ); -// => false - -console.log( isComplexTypedArray( new Int16Array( 10 ) ) ); -// => false - -console.log( isComplexTypedArray( new Uint16Array( 10 ) ) ); -// => false - -console.log( isComplexTypedArray( new Int8Array( 10 ) ) ); -// => false - -console.log( isComplexTypedArray( new Uint8Array( 10 ) ) ); -// => false - -console.log( isComplexTypedArray( new Uint8ClampedArray( 10 ) ) ); -// => false - -console.log( isComplexTypedArray( { 'length': 0 } ) ); -// => false diff --git a/base/assert/is-complex-typed-array/lib/index.js b/base/assert/is-complex-typed-array/lib/index.js deleted file mode 100644 index 65f8b4c7c..000000000 --- a/base/assert/is-complex-typed-array/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Test if a value is a complex typed array. -* -* @module @stdlib/array/base/assert/is-complex-typed-array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var isComplexTypedArray = require( '@stdlib/array/base/assert/is-complex-typed-array' ); -* -* var bool = isComplexTypedArray( new Complex128Array( 10 ) ); -* // returns true -* -* bool = isComplexTypedArray( [] ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-complex-typed-array/lib/main.js b/base/assert/is-complex-typed-array/lib/main.js deleted file mode 100644 index 965ee5a44..000000000 --- a/base/assert/is-complex-typed-array/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// MODULES // - -var C64_BYTES_PER_ELEMENT = 8; // 4 bytes per float32 x (1 real + 1 imag component) -var C128_BYTES_PER_ELEMENT = 16; // 8 bytes per float64 x (1 real + 1 imag component) - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a complex typed array. -* -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a complex typed array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var bool = isComplexTypedArray( new Complex128Array( 10 ) ); -* // returns true -* -* bool = isComplexTypedArray( [] ); -* // returns false -*/ -function isComplexTypedArray( value ) { - // Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex128Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex-typed-array`. - return ( - typeof value === 'object' && - value !== null && - ( - ( - value.constructor.name === 'Complex128Array' && - value.BYTES_PER_ELEMENT === C128_BYTES_PER_ELEMENT - ) || - ( - value.constructor.name === 'Complex64Array' && - value.BYTES_PER_ELEMENT === C64_BYTES_PER_ELEMENT - ) - ) - ); -} - - -// EXPORTS // - -module.exports = isComplexTypedArray; diff --git a/base/assert/is-complex-typed-array/package.json b/base/assert/is-complex-typed-array/package.json deleted file mode 100644 index ae4838d08..000000000 --- a/base/assert/is-complex-typed-array/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-complex-typed-array", - "version": "0.0.0", - "description": "Test if a value is a complex typed array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdassert", - "assertion", - "assert", - "utilities", - "utility", - "utils", - "util", - "base", - "array", - "typed array", - "collection", - "complex128array", - "complex64array", - "is", - "isarray", - "type", - "check", - "test", - "valid", - "validate" - ] -} diff --git a/base/assert/is-complex-typed-array/test/test.js b/base/assert/is-complex-typed-array/test/test.js deleted file mode 100644 index a9339dd6f..000000000 --- a/base/assert/is-complex-typed-array/test/test.js +++ /dev/null @@ -1,90 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var constructorName = require( '@stdlib/utils/constructor-name' ); -var Int8Array = require( './../../../../int8' ); -var Uint8Array = require( './../../../../uint8' ); -var Uint8ClampedArray = require( './../../../../uint8c' ); -var Int16Array = require( './../../../../int16' ); -var Uint16Array = require( './../../../../uint16' ); -var Int32Array = require( './../../../../int32' ); -var Uint32Array = require( './../../../../uint32' ); -var Float32Array = require( './../../../../float32' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var Complex64Array = require( './../../../../complex64' ); -var allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' ); -var isComplexTypedArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isComplexTypedArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a complex typed array', function test( t ) { - var values; - var i; - - values = [ - new Complex128Array( 20 ), - new Complex128Array( 10 ), - new Complex64Array( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isComplexTypedArray( values[i] ), true, 'returns expected value when provided '+constructorName( values[i] ) ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a complex typed array', function test( t ) { - var values; - var i; - - values = [ - void 0, - null, - {}, - [], - { 'length': 10 }, // eslint-disable-line object-curly-newline - new Float64Array( 10 ), - new Float32Array( 10 ), - new Int32Array( 10 ), - new Uint32Array( 10 ), - new Int16Array( 10 ), - new Uint16Array( 10 ), - new Int8Array( 10 ), - new Uint8Array( 10 ), - new Uint8ClampedArray( 10 ), - allocUnsafe( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isComplexTypedArray( values[i] ), false, 'returns expected value when provided '+constructorName( values[i] ) ); - } - t.end(); -}); diff --git a/base/assert/is-complex128array/README.md b/base/assert/is-complex128array/README.md deleted file mode 100644 index 6532c37de..000000000 --- a/base/assert/is-complex128array/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# isComplex128Array - -> Test if a value is a [`Complex128Array`][@stdlib/array/complex128]. - -
- -
- - - -
- -## Usage - -```javascript -var isComplex128Array = require( '@stdlib/array/base/assert/is-complex128array' ); -``` - -#### isComplex128Array( value ) - -Tests if a value is a [`Complex128Array`][@stdlib/array/complex128]. - -```javascript -var Complex128Array = require( '@stdlib/array/complex128' ); - -var arr = new Complex128Array( 10 ); -var bool = isComplex128Array( arr ); -// returns true -``` - -
- - - -
- -## Notes - -- This function is not robust and that is intentional. This function provides a lower cost way to reasonably determine whether an input value is a [`Complex128Array`][@stdlib/array/complex128] in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see [`@stdlib/assert/is-complex128array`][@stdlib/assert/is-complex128array]. - -
- - - -
- -## Examples - - - - - -```javascript -var Int8Array = require( '@stdlib/array/int8' ); -var Uint8Array = require( '@stdlib/array/uint8' ); -var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -var Int16Array = require( '@stdlib/array/int16' ); -var Uint16Array = require( '@stdlib/array/uint16' ); -var Int32Array = require( '@stdlib/array/int32' ); -var Uint32Array = require( '@stdlib/array/uint32' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex64Array = require( '@stdlib/array/complex64' ); -var isComplex128Array = require( '@stdlib/array/base/assert/is-complex128array' ); - -var bool = isComplex128Array( new Complex128Array( 10 ) ); -// returns true - -bool = isComplex128Array( new Complex64Array( 10 ) ); -// returns false - -bool = isComplex128Array( [] ); -// returns false - -bool = isComplex128Array( new Float64Array( 10 ) ); -// returns false - -bool = isComplex128Array( new Float32Array( 10 ) ); -// returns false - -bool = isComplex128Array( new Int32Array( 10 ) ); -// returns false - -bool = isComplex128Array( new Uint32Array( 10 ) ); -// returns false - -bool = isComplex128Array( new Int16Array( 10 ) ); -// returns false - -bool = isComplex128Array( new Uint16Array( 10 ) ); -// returns false - -bool = isComplex128Array( new Int8Array( 10 ) ); -// returns false - -bool = isComplex128Array( new Uint8Array( 10 ) ); -// returns false - -bool = isComplex128Array( new Uint8ClampedArray( 10 ) ); -// returns false - -bool = isComplex128Array( { 'length': 0 } ); -// returns false -``` - -
- - - - - - - - - - - - - - diff --git a/base/assert/is-complex128array/benchmark/benchmark.js b/base/assert/is-complex128array/benchmark/benchmark.js deleted file mode 100644 index 9e414eab9..000000000 --- a/base/assert/is-complex128array/benchmark/benchmark.js +++ /dev/null @@ -1,135 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isComplex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var bool; - var obj; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = [ i, i+1 ]; - bool = isComplex128Array( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real_typed_array', function benchmark( b ) { - var values; - var bool; - var obj; - var N; - var i; - - values = [ - new Float64Array( [ 1.0, 2.0 ] ), - new Float64Array( [ 3.0, 4.0 ] ) - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = values[ i%N ]; - bool = isComplex128Array( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex_typed_array', function benchmark( b ) { - var values; - var bool; - var obj; - var N; - var i; - - values = [ - new Complex128Array( [ 1.0, 2.0 ] ), - new Complex128Array( [ 3.0, 4.0 ] ) - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = values[ i%N ]; - bool = isComplex128Array( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like_object', function benchmark( b ) { - var bool; - var obj; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = { - 'length': 2, - '0': i, - '1': i + 1 - }; - bool = isComplex128Array( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-complex128array/docs/repl.txt b/base/assert/is-complex128array/docs/repl.txt deleted file mode 100644 index 905328457..000000000 --- a/base/assert/is-complex128array/docs/repl.txt +++ /dev/null @@ -1,26 +0,0 @@ - -{{alias}}( value ) - Tests if a value is a Complex128Array. - - Parameters - ---------- - value: ArrayLikeObject - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether a value is a Complex128Array. - - Examples - -------- - > var bool = {{alias}}( new {{alias:@stdlib/array/complex128}}( 10 ) ) - true - > bool = {{alias}}( [] ) - false - > bool = {{alias}}( { 'length': 0 } ) - false - - See Also - -------- - diff --git a/base/assert/is-complex128array/docs/types/index.d.ts b/base/assert/is-complex128array/docs/types/index.d.ts deleted file mode 100644 index 89a150d90..000000000 --- a/base/assert/is-complex128array/docs/types/index.d.ts +++ /dev/null @@ -1,47 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex128Array } from '@stdlib/types/array'; - -/** -* Tests if a value is a `Complex128Array`. -* -* @param value - value to test -* @returns boolean indicating whether a value is a `Complex128Array` -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var arr = new Complex128Array( 10 ); -* var bool = isComplex128Array( arr ); -* // returns true -* -* @example -* var bool = isComplex128Array( [] ); -* // returns false -*/ -declare function isComplex128Array( value: Collection | Complex128Array ): value is Complex128Array; - - -// EXPORTS // - -export = isComplex128Array; diff --git a/base/assert/is-complex128array/docs/types/test.ts b/base/assert/is-complex128array/docs/types/test.ts deleted file mode 100644 index 4f25e496e..000000000 --- a/base/assert/is-complex128array/docs/types/test.ts +++ /dev/null @@ -1,33 +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. -*/ - -import isComplex128Array = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isComplex128Array( [] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isComplex128Array(); // $ExpectError - isComplex128Array( [], 123 ); // $ExpectError -} diff --git a/base/assert/is-complex128array/examples/index.js b/base/assert/is-complex128array/examples/index.js deleted file mode 100644 index 07dfb3847..000000000 --- a/base/assert/is-complex128array/examples/index.js +++ /dev/null @@ -1,73 +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. -*/ - -/* eslint-disable object-curly-newline */ - -'use strict'; - -var Int8Array = require( './../../../../int8' ); -var Uint8Array = require( './../../../../uint8' ); -var Uint8ClampedArray = require( './../../../../uint8c' ); -var Int16Array = require( './../../../../int16' ); -var Uint16Array = require( './../../../../uint16' ); -var Int32Array = require( './../../../../int32' ); -var Uint32Array = require( './../../../../uint32' ); -var Float32Array = require( './../../../../float32' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var Complex64Array = require( './../../../../complex64' ); -var isComplex128Array = require( './../lib' ); - -console.log( isComplex128Array( new Complex128Array( 10 ) ) ); -// => true - -console.log( isComplex128Array( new Complex64Array( 10 ) ) ); -// => false - -console.log( isComplex128Array( [] ) ); -// => false - -console.log( isComplex128Array( new Float64Array( 10 ) ) ); -// => false - -console.log( isComplex128Array( new Float32Array( 10 ) ) ); -// => false - -console.log( isComplex128Array( new Int32Array( 10 ) ) ); -// => false - -console.log( isComplex128Array( new Uint32Array( 10 ) ) ); -// => false - -console.log( isComplex128Array( new Int16Array( 10 ) ) ); -// => false - -console.log( isComplex128Array( new Uint16Array( 10 ) ) ); -// => false - -console.log( isComplex128Array( new Int8Array( 10 ) ) ); -// => false - -console.log( isComplex128Array( new Uint8Array( 10 ) ) ); -// => false - -console.log( isComplex128Array( new Uint8ClampedArray( 10 ) ) ); -// => false - -console.log( isComplex128Array( { 'length': 0 } ) ); -// => false diff --git a/base/assert/is-complex128array/lib/index.js b/base/assert/is-complex128array/lib/index.js deleted file mode 100644 index 9bfeab46d..000000000 --- a/base/assert/is-complex128array/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Test if a value is a `Complex128Array`. -* -* @module @stdlib/array/base/assert/is-complex128array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var isComplex128Array = require( '@stdlib/array/base/assert/is-complex128array' ); -* -* var bool = isComplex128Array( new Complex128Array( 10 ) ); -* // returns true -* -* bool = isComplex128Array( [] ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-complex128array/lib/main.js b/base/assert/is-complex128array/lib/main.js deleted file mode 100644 index 7b6852c42..000000000 --- a/base/assert/is-complex128array/lib/main.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// VARIABLES // - -var BYTES_PER_ELEMENT = 16; // 8 bytes per float64 x (1 real + 1 imag component) - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `Complex128Array`. -* -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `Complex128Array` -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var bool = isComplex128Array( new Complex128Array( 10 ) ); -* // returns true -* -* bool = isComplex128Array( [] ); -* // returns false -*/ -function isComplex128Array( value ) { - // Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex128Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex128array`. - return ( - typeof value === 'object' && - value !== null && - value.constructor.name === 'Complex128Array' && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); -} - - -// EXPORTS // - -module.exports = isComplex128Array; diff --git a/base/assert/is-complex128array/package.json b/base/assert/is-complex128array/package.json deleted file mode 100644 index 876400cae..000000000 --- a/base/assert/is-complex128array/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-complex128array", - "version": "0.0.0", - "description": "Test if a value is a Complex128Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdassert", - "assertion", - "assert", - "utilities", - "utility", - "utils", - "util", - "base", - "array", - "typed array", - "collection", - "complex128array", - "is", - "isarray", - "type", - "check", - "test", - "valid", - "validate" - ] -} diff --git a/base/assert/is-complex128array/test/test.js b/base/assert/is-complex128array/test/test.js deleted file mode 100644 index 22dde15d4..000000000 --- a/base/assert/is-complex128array/test/test.js +++ /dev/null @@ -1,90 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var constructorName = require( '@stdlib/utils/constructor-name' ); -var Int8Array = require( './../../../../int8' ); -var Uint8Array = require( './../../../../uint8' ); -var Uint8ClampedArray = require( './../../../../uint8c' ); -var Int16Array = require( './../../../../int16' ); -var Uint16Array = require( './../../../../uint16' ); -var Int32Array = require( './../../../../int32' ); -var Uint32Array = require( './../../../../uint32' ); -var Float32Array = require( './../../../../float32' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var Complex64Array = require( './../../../../complex64' ); -var allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' ); -var isComplex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isComplex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a Complex128Array', function test( t ) { - var values; - var i; - - values = [ - new Complex128Array( 20 ), - new Complex128Array( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isComplex128Array( values[i] ), true, 'returns expected value when provided '+constructorName( values[i] ) ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a Complex128Array', function test( t ) { - var values; - var i; - - values = [ - void 0, - null, - {}, - [], - { 'length': 10 }, // eslint-disable-line object-curly-newline - new Float64Array( 10 ), - new Float32Array( 10 ), - new Int32Array( 10 ), - new Uint32Array( 10 ), - new Int16Array( 10 ), - new Uint16Array( 10 ), - new Int8Array( 10 ), - new Uint8Array( 10 ), - new Uint8ClampedArray( 10 ), - new Complex64Array( 10 ), - allocUnsafe( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isComplex128Array( values[i] ), false, 'returns expected value when provided '+constructorName( values[i] ) ); - } - t.end(); -}); diff --git a/base/assert/is-complex64array/README.md b/base/assert/is-complex64array/README.md deleted file mode 100644 index 71023472e..000000000 --- a/base/assert/is-complex64array/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# isComplex64Array - -> Test if a value is a [`Complex64Array`][@stdlib/array/complex64]. - -
- -
- - - -
- -## Usage - -```javascript -var isComplex64Array = require( '@stdlib/array/base/assert/is-complex64array' ); -``` - -#### isComplex64Array( value ) - -Tests if a value is a [`Complex64Array`][@stdlib/array/complex64]. - -```javascript -var Complex64Array = require( '@stdlib/array/complex64' ); - -var arr = new Complex64Array( 10 ); -var bool = isComplex64Array( arr ); -// returns true -``` - -
- - - -
- -## Notes - -- This function is not robust and that is intentional. This function provides a lower cost way to reasonably determine whether an input value is a [`Complex64Array`][@stdlib/array/complex64] in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see [`@stdlib/assert/is-complex64array`][@stdlib/assert/is-complex64array]. - -
- - - -
- -## Examples - - - - - -```javascript -var Int8Array = require( '@stdlib/array/int8' ); -var Uint8Array = require( '@stdlib/array/uint8' ); -var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -var Int16Array = require( '@stdlib/array/int16' ); -var Uint16Array = require( '@stdlib/array/uint16' ); -var Int32Array = require( '@stdlib/array/int32' ); -var Uint32Array = require( '@stdlib/array/uint32' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex64Array = require( '@stdlib/array/complex64' ); -var isComplex64Array = require( '@stdlib/array/base/assert/is-complex64array' ); - -var bool = isComplex64Array( new Complex64Array( 10 ) ); -// returns true - -bool = isComplex64Array( new Complex128Array( 10 ) ); -// returns false - -bool = isComplex64Array( [] ); -// returns false - -bool = isComplex64Array( new Float64Array( 10 ) ); -// returns false - -bool = isComplex64Array( new Float32Array( 10 ) ); -// returns false - -bool = isComplex64Array( new Int32Array( 10 ) ); -// returns false - -bool = isComplex64Array( new Uint32Array( 10 ) ); -// returns false - -bool = isComplex64Array( new Int16Array( 10 ) ); -// returns false - -bool = isComplex64Array( new Uint16Array( 10 ) ); -// returns false - -bool = isComplex64Array( new Int8Array( 10 ) ); -// returns false - -bool = isComplex64Array( new Uint8Array( 10 ) ); -// returns false - -bool = isComplex64Array( new Uint8ClampedArray( 10 ) ); -// returns false - -bool = isComplex64Array( { 'length': 0 } ); -// returns false -``` - -
- - - - - - - - - - - - - - diff --git a/base/assert/is-complex64array/benchmark/benchmark.js b/base/assert/is-complex64array/benchmark/benchmark.js deleted file mode 100644 index f19683d0b..000000000 --- a/base/assert/is-complex64array/benchmark/benchmark.js +++ /dev/null @@ -1,135 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float32Array = require( './../../../../float32' ); -var Complex64Array = require( './../../../../complex64' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isComplex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var bool; - var obj; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = [ i, i+1 ]; - bool = isComplex64Array( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real_typed_array', function benchmark( b ) { - var values; - var bool; - var obj; - var N; - var i; - - values = [ - new Float32Array( [ 1.0, 2.0 ] ), - new Float32Array( [ 3.0, 4.0 ] ) - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = values[ i%N ]; - bool = isComplex64Array( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex_typed_array', function benchmark( b ) { - var values; - var bool; - var obj; - var N; - var i; - - values = [ - new Complex64Array( [ 1.0, 2.0 ] ), - new Complex64Array( [ 3.0, 4.0 ] ) - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = values[ i%N ]; - bool = isComplex64Array( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like_object', function benchmark( b ) { - var bool; - var obj; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = { - 'length': 2, - '0': i, - '1': i + 1 - }; - bool = isComplex64Array( obj ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-complex64array/docs/repl.txt b/base/assert/is-complex64array/docs/repl.txt deleted file mode 100644 index aa1527027..000000000 --- a/base/assert/is-complex64array/docs/repl.txt +++ /dev/null @@ -1,26 +0,0 @@ - -{{alias}}( value ) - Tests if a value is a Complex64Array. - - Parameters - ---------- - value: ArrayLikeObject - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether a value is a Complex64Array. - - Examples - -------- - > var bool = {{alias}}( new {{alias:@stdlib/array/complex64}}( 10 ) ) - true - > bool = {{alias}}( [] ) - false - > bool = {{alias}}( { 'length': 0 } ) - false - - See Also - -------- - diff --git a/base/assert/is-complex64array/docs/types/index.d.ts b/base/assert/is-complex64array/docs/types/index.d.ts deleted file mode 100644 index dc182a0a7..000000000 --- a/base/assert/is-complex64array/docs/types/index.d.ts +++ /dev/null @@ -1,47 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array } from '@stdlib/types/array'; - -/** -* Tests if a value is a `Complex64Array`. -* -* @param value - value to test -* @returns boolean indicating whether a value is a `Complex64Array` -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var arr = new Complex64Array( 10 ); -* var bool = isComplex64Array( arr ); -* // returns true -* -* @example -* var bool = isComplex64Array( [] ); -* // returns false -*/ -declare function isComplex64Array( value: Collection | Complex64Array ): value is Complex64Array; - - -// EXPORTS // - -export = isComplex64Array; diff --git a/base/assert/is-complex64array/docs/types/test.ts b/base/assert/is-complex64array/docs/types/test.ts deleted file mode 100644 index 53118e35b..000000000 --- a/base/assert/is-complex64array/docs/types/test.ts +++ /dev/null @@ -1,33 +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. -*/ - -import isComplex64Array = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isComplex64Array( [] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isComplex64Array(); // $ExpectError - isComplex64Array( [], 123 ); // $ExpectError -} diff --git a/base/assert/is-complex64array/examples/index.js b/base/assert/is-complex64array/examples/index.js deleted file mode 100644 index ab8fdd74b..000000000 --- a/base/assert/is-complex64array/examples/index.js +++ /dev/null @@ -1,73 +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. -*/ - -/* eslint-disable object-curly-newline */ - -'use strict'; - -var Int8Array = require( './../../../../int8' ); -var Uint8Array = require( './../../../../uint8' ); -var Uint8ClampedArray = require( './../../../../uint8c' ); -var Int16Array = require( './../../../../int16' ); -var Uint16Array = require( './../../../../uint16' ); -var Int32Array = require( './../../../../int32' ); -var Uint32Array = require( './../../../../uint32' ); -var Float32Array = require( './../../../../float32' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var Complex64Array = require( './../../../../complex64' ); -var isComplex64Array = require( './../lib' ); - -console.log( isComplex64Array( new Complex64Array( 10 ) ) ); -// => true - -console.log( isComplex64Array( new Complex128Array( 10 ) ) ); -// => false - -console.log( isComplex64Array( [] ) ); -// => false - -console.log( isComplex64Array( new Float64Array( 10 ) ) ); -// => false - -console.log( isComplex64Array( new Float32Array( 10 ) ) ); -// => false - -console.log( isComplex64Array( new Int32Array( 10 ) ) ); -// => false - -console.log( isComplex64Array( new Uint32Array( 10 ) ) ); -// => false - -console.log( isComplex64Array( new Int16Array( 10 ) ) ); -// => false - -console.log( isComplex64Array( new Uint16Array( 10 ) ) ); -// => false - -console.log( isComplex64Array( new Int8Array( 10 ) ) ); -// => false - -console.log( isComplex64Array( new Uint8Array( 10 ) ) ); -// => false - -console.log( isComplex64Array( new Uint8ClampedArray( 10 ) ) ); -// => false - -console.log( isComplex64Array( { 'length': 0 } ) ); -// => false diff --git a/base/assert/is-complex64array/lib/index.js b/base/assert/is-complex64array/lib/index.js deleted file mode 100644 index fed622e30..000000000 --- a/base/assert/is-complex64array/lib/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -/** -* Test if a value is a `Complex64Array`. -* -* @module @stdlib/array/base/assert/is-complex64array -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* var isComplex64Array = require( '@stdlib/array/base/assert/is-complex64array' ); -* -* var bool = isComplex64Array( new Complex64Array( 10 ) ); -* // returns true -* -* bool = isComplex64Array( [] ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-complex64array/lib/main.js b/base/assert/is-complex64array/lib/main.js deleted file mode 100644 index 7f73ce85a..000000000 --- a/base/assert/is-complex64array/lib/main.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// VARIABLES // - -var BYTES_PER_ELEMENT = 8; // 4 bytes per float32 x (1 real + 1 imag component) - - -// MAIN // - -/** -* Returns a boolean indicating if a value is a `Complex64Array`. -* -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `Complex64Array` -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var bool = isComplex64Array( new Complex64Array( 10 ) ); -* // returns true -* -* bool = isComplex64Array( [] ); -* // returns false -*/ -function isComplex64Array( value ) { - // Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex64Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex64array`. - return ( - typeof value === 'object' && - value !== null && - value.constructor.name === 'Complex64Array' && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); -} - - -// EXPORTS // - -module.exports = isComplex64Array; diff --git a/base/assert/is-complex64array/package.json b/base/assert/is-complex64array/package.json deleted file mode 100644 index cc11a9bd7..000000000 --- a/base/assert/is-complex64array/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-complex64array", - "version": "0.0.0", - "description": "Test if a value is a Complex64Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdassert", - "assertion", - "assert", - "utilities", - "utility", - "utils", - "util", - "base", - "array", - "typed array", - "collection", - "complex64array", - "is", - "isarray", - "type", - "check", - "test", - "valid", - "validate" - ] -} diff --git a/base/assert/is-complex64array/test/test.js b/base/assert/is-complex64array/test/test.js deleted file mode 100644 index 531853592..000000000 --- a/base/assert/is-complex64array/test/test.js +++ /dev/null @@ -1,90 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var constructorName = require( '@stdlib/utils/constructor-name' ); -var Int8Array = require( './../../../../int8' ); -var Uint8Array = require( './../../../../uint8' ); -var Uint8ClampedArray = require( './../../../../uint8c' ); -var Int16Array = require( './../../../../int16' ); -var Uint16Array = require( './../../../../uint16' ); -var Int32Array = require( './../../../../int32' ); -var Uint32Array = require( './../../../../uint32' ); -var Float32Array = require( './../../../../float32' ); -var Float64Array = require( './../../../../float64' ); -var Complex128Array = require( './../../../../complex128' ); -var Complex64Array = require( './../../../../complex64' ); -var allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' ); -var isComplex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isComplex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a Complex64Array', function test( t ) { - var values; - var i; - - values = [ - new Complex64Array( 20 ), - new Complex64Array( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isComplex64Array( values[i] ), true, 'returns expected value when provided '+constructorName( values[i] ) ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a Complex64Array', function test( t ) { - var values; - var i; - - values = [ - void 0, - null, - {}, - [], - { 'length': 10 }, // eslint-disable-line object-curly-newline - new Float64Array( 10 ), - new Float32Array( 10 ), - new Int32Array( 10 ), - new Uint32Array( 10 ), - new Int16Array( 10 ), - new Uint16Array( 10 ), - new Int8Array( 10 ), - new Uint8Array( 10 ), - new Uint8ClampedArray( 10 ), - new Complex128Array( 10 ), - allocUnsafe( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isComplex64Array( values[i] ), false, 'returns expected value when provided '+constructorName( values[i] ) ); - } - t.end(); -}); diff --git a/base/assert/is-data-type/README.md b/base/assert/is-data-type/README.md deleted file mode 100644 index 3545a9048..000000000 --- a/base/assert/is-data-type/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# isDataType - -> Test if an input value is a supported array data type. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isDataType = require( '@stdlib/array/base/assert/is-data-type' ); -``` - -#### isDataType( value ) - -Tests if an input `value` is a supported array data type. - -```javascript -var bool = isDataType( 'float32' ); -// returns true - -bool = isDataType( 'int32' ); -// returns true -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var isDataType = require( '@stdlib/array/base/assert/is-data-type' ); - -var bool = isDataType( 'float32' ); -// returns true - -bool = isDataType( 'float64' ); -// returns true - -bool = isDataType( 'generic' ); -// returns true - -bool = isDataType( 'int16' ); -// returns true - -bool = isDataType( 'int32' ); -// returns true - -bool = isDataType( 'int8' ); -// returns true - -bool = isDataType( 'uint16' ); -// returns true - -bool = isDataType( 'uint32' ); -// returns true - -bool = isDataType( 'uint8' ); -// returns true - -bool = isDataType( 'uint8c' ); -// returns true - -bool = isDataType( '' ); -// returns false - -bool = isDataType( 'foo' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-data-type/benchmark/benchmark.js b/base/assert/is-data-type/benchmark/benchmark.js deleted file mode 100644 index 481b7e977..000000000 --- a/base/assert/is-data-type/benchmark/benchmark.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isDataType = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - 'binary', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'foo', - 'bar', - '', - 'beep', - 'boop' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ]; - out = isDataType( v ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-data-type/docs/repl.txt b/base/assert/is-data-type/docs/repl.txt deleted file mode 100644 index 16533b976..000000000 --- a/base/assert/is-data-type/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( value ) - Tests if an input value is a supported array data type. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input value is a supported array data type. - - Examples - -------- - > var bool = {{alias}}( 'float32' ) - true - > bool = {{alias}}( 'float64' ) - true - > bool = {{alias}}( 'int16' ) - true - > bool = {{alias}}( 'int32' ) - true - > bool = {{alias}}( 'int8' ) - true - > bool = {{alias}}( 'uint16' ) - true - > bool = {{alias}}( 'uint32' ) - true - > bool = {{alias}}( 'uint8' ) - true - > bool = {{alias}}( 'uint8c' ) - true - > bool = {{alias}}( '' ) - false - > bool = {{alias}}( 'beep' ) - false - - See Also - -------- - diff --git a/base/assert/is-data-type/docs/types/index.d.ts b/base/assert/is-data-type/docs/types/index.d.ts deleted file mode 100644 index 2e8980038..000000000 --- a/base/assert/is-data-type/docs/types/index.d.ts +++ /dev/null @@ -1,66 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests whether an input value is a supported array data type. -* -* @param v - value to test -* @returns boolean indicating whether an input value is a supported array data type -* -* @example -* var bool = isDataType( 'float32' ); -* // returns true -* -* bool = isDataType( 'float64' ); -* // returns true -* -* bool = isDataType( 'generic' ); -* // returns true -* -* bool = isDataType( 'int16' ); -* // returns true -* -* bool = isDataType( 'int32' ); -* // returns true -* -* bool = isDataType( 'int8' ); -* // returns true -* -* bool = isDataType( 'uint16' ); -* // returns true -* -* bool = isDataType( 'uint32' ); -* // returns true -* -* bool = isDataType( 'uint8' ); -* // returns true -* -* bool = isDataType( 'uint8c' ); -* // returns true -* -* bool = isDataType( 'foo' ); -* // returns false -*/ -declare function isDataType( v: any ): boolean; - - -// EXPORTS // - -export = isDataType; diff --git a/base/assert/is-data-type/docs/types/test.ts b/base/assert/is-data-type/docs/types/test.ts deleted file mode 100644 index dde448a17..000000000 --- a/base/assert/is-data-type/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import isDataType = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isDataType( 'int8' ); // $ExpectType boolean - isDataType( 'foo' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isDataType(); // $ExpectError - isDataType( undefined, 123 ); // $ExpectError -} diff --git a/base/assert/is-data-type/examples/index.js b/base/assert/is-data-type/examples/index.js deleted file mode 100644 index 2363a0bec..000000000 --- a/base/assert/is-data-type/examples/index.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -var isDataType = require( './../lib' ); - -var bool = isDataType( 'float32' ); -console.log( bool ); -// => true - -bool = isDataType( 'float64' ); -console.log( bool ); -// => true - -bool = isDataType( 'generic' ); -console.log( bool ); -// => true - -bool = isDataType( 'int16' ); -console.log( bool ); -// => true - -bool = isDataType( 'int32' ); -console.log( bool ); -// => true - -bool = isDataType( 'int8' ); -console.log( bool ); -// => true - -bool = isDataType( 'uint16' ); -console.log( bool ); -// => true - -bool = isDataType( 'uint32' ); -console.log( bool ); -// => true - -bool = isDataType( 'uint8' ); -console.log( bool ); -// => true - -bool = isDataType( 'uint8c' ); -console.log( bool ); -// => true - -bool = isDataType( '' ); -console.log( bool ); -// => false - -bool = isDataType( 'foo' ); -console.log( bool ); -// => false diff --git a/base/assert/is-data-type/lib/index.js b/base/assert/is-data-type/lib/index.js deleted file mode 100644 index 13dcaaac5..000000000 --- a/base/assert/is-data-type/lib/index.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -/** -* Test whether an input value is a supported array data type. -* -* @module @stdlib/array/base/assert/is-data-type -* -* @example -* var isDataType = require( '@stdlib/array/base/assert/is-data-type' ); -* -* var bool = isDataType( 'float32' ); -* // returns true -* -* bool = isDataType( 'float64' ); -* // returns true -* -* bool = isDataType( 'generic' ); -* // returns true -* -* bool = isDataType( 'int16' ); -* // returns true -* -* bool = isDataType( 'int32' ); -* // returns true -* -* bool = isDataType( 'int8' ); -* // returns true -* -* bool = isDataType( 'uint16' ); -* // returns true -* -* bool = isDataType( 'uint32' ); -* // returns true -* -* bool = isDataType( 'uint8' ); -* // returns true -* -* bool = isDataType( 'uint8c' ); -* // returns true -* -* bool = isDataType( 'foo' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-data-type/lib/main.js b/base/assert/is-data-type/lib/main.js deleted file mode 100644 index 98a7a7b6c..000000000 --- a/base/assert/is-data-type/lib/main.js +++ /dev/null @@ -1,76 +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. -*/ - -'use strict'; - -// MODULES // - -var contains = require( './../../../../base/assert/contains' ).factory; -var dtypes = require( './../../../../dtypes' ); - - -// MAIN // - -/** -* Tests whether an input value is a supported array data type. -* -* @name isDataType -* @type {Function} -* @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported array data type -* -* @example -* var bool = isDataType( 'float32' ); -* // returns true -* -* bool = isDataType( 'float64' ); -* // returns true -* -* bool = isDataType( 'generic' ); -* // returns true -* -* bool = isDataType( 'int16' ); -* // returns true -* -* bool = isDataType( 'int32' ); -* // returns true -* -* bool = isDataType( 'int8' ); -* // returns true -* -* bool = isDataType( 'uint16' ); -* // returns true -* -* bool = isDataType( 'uint32' ); -* // returns true -* -* bool = isDataType( 'uint8' ); -* // returns true -* -* bool = isDataType( 'uint8c' ); -* // returns true -* -* bool = isDataType( 'foo' ); -* // returns false -*/ -var isDataType = contains( dtypes() ); - - -// EXPORTS // - -module.exports = isDataType; diff --git a/base/assert/is-data-type/package.json b/base/assert/is-data-type/package.json deleted file mode 100644 index 9a0e24a87..000000000 --- a/base/assert/is-data-type/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-data-type", - "version": "0.0.0", - "description": "Test if an input value is a supported array data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "dtype", - "data", - "utilities", - "utility", - "utils", - "util", - "assert", - "test", - "check", - "is", - "valid", - "validate", - "validation", - "isvalid" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-data-type/test/test.js b/base/assert/is-data-type/test/test.js deleted file mode 100644 index 100cf9374..000000000 --- a/base/assert/is-data-type/test/test.js +++ /dev/null @@ -1,90 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isDataType = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a supported array data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'complex64', - 'complex128', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isDataType( values[ i ] ); - t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a supported array data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'float', - 'int', - 'bin', - '', - 'beep', - 'boop', - 'foo', - 'bar', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isDataType( values[ i ] ); - t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/base/assert/is-floating-point-data-type/README.md b/base/assert/is-floating-point-data-type/README.md deleted file mode 100644 index 16dbe7a98..000000000 --- a/base/assert/is-floating-point-data-type/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# isFloatingPointDataType - -> Test if an input value is a supported array floating-point data type. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isFloatingPointDataType = require( '@stdlib/array/base/assert/is-floating-point-data-type' ); -``` - -#### isFloatingPointDataType( value ) - -Tests if an input `value` is a supported array floating-point data type. - -```javascript -var bool = isFloatingPointDataType( 'float32' ); -// returns true - -bool = isFloatingPointDataType( 'uint32' ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var isFloatingPointDataType = require( '@stdlib/array/base/assert/is-floating-point-data-type' ); - -var bool = isFloatingPointDataType( 'float32' ); -// returns true - -bool = isFloatingPointDataType( 'float64' ); -// returns true - -bool = isFloatingPointDataType( 'generic' ); -// returns false - -bool = isFloatingPointDataType( 'int16' ); -// returns false - -bool = isFloatingPointDataType( 'int32' ); -// returns false - -bool = isFloatingPointDataType( 'int8' ); -// returns false - -bool = isFloatingPointDataType( 'uint16' ); -// returns false - -bool = isFloatingPointDataType( 'uint32' ); -// returns false - -bool = isFloatingPointDataType( 'uint8' ); -// returns false - -bool = isFloatingPointDataType( 'uint8c' ); -// returns false - -bool = isFloatingPointDataType( '' ); -// returns false - -bool = isFloatingPointDataType( 'foo' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-floating-point-data-type/benchmark/benchmark.js b/base/assert/is-floating-point-data-type/benchmark/benchmark.js deleted file mode 100644 index 8aee85143..000000000 --- a/base/assert/is-floating-point-data-type/benchmark/benchmark.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isFloatingPointDataType = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - 'binary', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'foo', - 'bar', - '', - 'beep', - 'boop' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ]; - out = isFloatingPointDataType( v ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-floating-point-data-type/docs/repl.txt b/base/assert/is-floating-point-data-type/docs/repl.txt deleted file mode 100644 index e49180542..000000000 --- a/base/assert/is-floating-point-data-type/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( value ) - Tests if an input value is a supported array floating-point data type. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input value is a supported array floating-point - data type. - - Examples - -------- - > var bool = {{alias}}( 'float32' ) - true - > bool = {{alias}}( 'float64' ) - true - > bool = {{alias}}( 'int16' ) - false - > bool = {{alias}}( 'int32' ) - false - > bool = {{alias}}( 'int8' ) - false - > bool = {{alias}}( 'uint16' ) - false - > bool = {{alias}}( 'uint32' ) - false - > bool = {{alias}}( 'uint8' ) - false - > bool = {{alias}}( 'uint8c' ) - false - > bool = {{alias}}( '' ) - false - > bool = {{alias}}( 'beep' ) - false - - See Also - -------- - diff --git a/base/assert/is-floating-point-data-type/docs/types/index.d.ts b/base/assert/is-floating-point-data-type/docs/types/index.d.ts deleted file mode 100644 index 8cb0a74dc..000000000 --- a/base/assert/is-floating-point-data-type/docs/types/index.d.ts +++ /dev/null @@ -1,66 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests whether an input value is a supported array floating-point data type. -* -* @param v - value to test -* @returns boolean indicating whether an input value is a supported array floating-point data type -* -* @example -* var bool = isFloatingPointDataType( 'float32' ); -* // returns true -* -* bool = isFloatingPointDataType( 'float64' ); -* // returns true -* -* bool = isFloatingPointDataType( 'generic' ); -* // returns false -* -* bool = isFloatingPointDataType( 'int16' ); -* // returns false -* -* bool = isFloatingPointDataType( 'int32' ); -* // returns false -* -* bool = isFloatingPointDataType( 'int8' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint16' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint32' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint8' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint8c' ); -* // returns false -* -* bool = isFloatingPointDataType( 'foo' ); -* // returns false -*/ -declare function isFloatingPointDataType( v: any ): boolean; - - -// EXPORTS // - -export = isFloatingPointDataType; diff --git a/base/assert/is-floating-point-data-type/docs/types/test.ts b/base/assert/is-floating-point-data-type/docs/types/test.ts deleted file mode 100644 index 6387e04e6..000000000 --- a/base/assert/is-floating-point-data-type/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import isFloatingPointDataType = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isFloatingPointDataType( 'int8' ); // $ExpectType boolean - isFloatingPointDataType( 'foo' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isFloatingPointDataType(); // $ExpectError - isFloatingPointDataType( 'int8', 123 ); // $ExpectError -} diff --git a/base/assert/is-floating-point-data-type/examples/index.js b/base/assert/is-floating-point-data-type/examples/index.js deleted file mode 100644 index 5c39b9d44..000000000 --- a/base/assert/is-floating-point-data-type/examples/index.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -var isFloatingPointDataType = require( './../lib' ); - -var bool = isFloatingPointDataType( 'float32' ); -console.log( bool ); -// => true - -bool = isFloatingPointDataType( 'float64' ); -console.log( bool ); -// => true - -bool = isFloatingPointDataType( 'generic' ); -console.log( bool ); -// => false - -bool = isFloatingPointDataType( 'int16' ); -console.log( bool ); -// => false - -bool = isFloatingPointDataType( 'int32' ); -console.log( bool ); -// => false - -bool = isFloatingPointDataType( 'int8' ); -console.log( bool ); -// => false - -bool = isFloatingPointDataType( 'uint16' ); -console.log( bool ); -// => false - -bool = isFloatingPointDataType( 'uint32' ); -console.log( bool ); -// => false - -bool = isFloatingPointDataType( 'uint8' ); -console.log( bool ); -// => false - -bool = isFloatingPointDataType( 'uint8c' ); -console.log( bool ); -// => false - -bool = isFloatingPointDataType( '' ); -console.log( bool ); -// => false - -bool = isFloatingPointDataType( 'foo' ); -console.log( bool ); -// => false diff --git a/base/assert/is-floating-point-data-type/lib/index.js b/base/assert/is-floating-point-data-type/lib/index.js deleted file mode 100644 index e498cd4df..000000000 --- a/base/assert/is-floating-point-data-type/lib/index.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -/** -* Test whether an input value is a supported array floating-point data type. -* -* @module @stdlib/array/base/assert/is-floating-point-data-type -* -* @example -* var isFloatingPointDataType = require( '@stdlib/array/base/assert/is-floating-point-data-type' ); -* -* var bool = isFloatingPointDataType( 'float32' ); -* // returns true -* -* bool = isFloatingPointDataType( 'float64' ); -* // returns true -* -* bool = isFloatingPointDataType( 'generic' ); -* // returns false -* -* bool = isFloatingPointDataType( 'int16' ); -* // returns false -* -* bool = isFloatingPointDataType( 'int32' ); -* // returns false -* -* bool = isFloatingPointDataType( 'int8' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint16' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint32' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint8' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint8c' ); -* // returns false -* -* bool = isFloatingPointDataType( 'foo' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-floating-point-data-type/lib/main.js b/base/assert/is-floating-point-data-type/lib/main.js deleted file mode 100644 index 031c8cccb..000000000 --- a/base/assert/is-floating-point-data-type/lib/main.js +++ /dev/null @@ -1,76 +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. -*/ - -'use strict'; - -// MODULES // - -var contains = require( './../../../../base/assert/contains' ).factory; -var dtypes = require( './../../../../dtypes' ); - - -// MAIN // - -/** -* Tests whether an input value is a supported array floating-point data type. -* -* @name isFloatingPointDataType -* @type {Function} -* @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported array floating-point data type -* -* @example -* var bool = isFloatingPointDataType( 'float32' ); -* // returns true -* -* bool = isFloatingPointDataType( 'float64' ); -* // returns true -* -* bool = isFloatingPointDataType( 'generic' ); -* // returns false -* -* bool = isFloatingPointDataType( 'int16' ); -* // returns false -* -* bool = isFloatingPointDataType( 'int32' ); -* // returns false -* -* bool = isFloatingPointDataType( 'int8' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint16' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint32' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint8' ); -* // returns false -* -* bool = isFloatingPointDataType( 'uint8c' ); -* // returns false -* -* bool = isFloatingPointDataType( 'foo' ); -* // returns false -*/ -var isFloatingPointDataType = contains( dtypes( 'floating_point' ) ); - - -// EXPORTS // - -module.exports = isFloatingPointDataType; diff --git a/base/assert/is-floating-point-data-type/package.json b/base/assert/is-floating-point-data-type/package.json deleted file mode 100644 index 03b2cca6d..000000000 --- a/base/assert/is-floating-point-data-type/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-floating-point-data-type", - "version": "0.0.0", - "description": "Test if an input value is a supported array floating-point data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "dtype", - "data", - "utilities", - "utility", - "utils", - "util", - "assert", - "test", - "check", - "is", - "valid", - "validate", - "validation", - "isvalid" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-floating-point-data-type/test/test.js b/base/assert/is-floating-point-data-type/test/test.js deleted file mode 100644 index 54625ec32..000000000 --- a/base/assert/is-floating-point-data-type/test/test.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isFloatingPointDataType = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isFloatingPointDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a supported array floating-point data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'complex64', - 'complex128', - 'float32', - 'float64' - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isFloatingPointDataType( values[ i ] ); - t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a supported array floating-point data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - // Supported types: - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'int16', - 'int32', - 'int8', - 'generic', - - // Unsupported dtypes: - 'float', - 'int', - 'bin', - '', - 'beep', - 'boop', - 'foo', - 'bar', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isFloatingPointDataType( values[ i ] ); - t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/base/assert/is-integer-data-type/README.md b/base/assert/is-integer-data-type/README.md deleted file mode 100644 index cc5173f79..000000000 --- a/base/assert/is-integer-data-type/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# isIntegerDataType - -> Test if an input value is a supported array integer data type. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isIntegerDataType = require( '@stdlib/array/base/assert/is-integer-data-type' ); -``` - -#### isIntegerDataType( value ) - -Tests if an input `value` is a supported array integer (i.e., signed or unsigned integer) data type. - -```javascript -var bool = isIntegerDataType( 'float32' ); -// returns false - -bool = isIntegerDataType( 'uint32' ); -// returns true -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var isIntegerDataType = require( '@stdlib/array/base/assert/is-integer-data-type' ); - -var bool = isIntegerDataType( 'float32' ); -// returns false - -bool = isIntegerDataType( 'float64' ); -// returns false - -bool = isIntegerDataType( 'generic' ); -// returns false - -bool = isIntegerDataType( 'int16' ); -// returns true - -bool = isIntegerDataType( 'int32' ); -// returns true - -bool = isIntegerDataType( 'int8' ); -// returns true - -bool = isIntegerDataType( 'uint16' ); -// returns true - -bool = isIntegerDataType( 'uint32' ); -// returns true - -bool = isIntegerDataType( 'uint8' ); -// returns true - -bool = isIntegerDataType( 'uint8c' ); -// returns true - -bool = isIntegerDataType( '' ); -// returns false - -bool = isIntegerDataType( 'foo' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-integer-data-type/benchmark/benchmark.js b/base/assert/is-integer-data-type/benchmark/benchmark.js deleted file mode 100644 index af4e32633..000000000 --- a/base/assert/is-integer-data-type/benchmark/benchmark.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isIntegerDataType = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - 'binary', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'foo', - 'bar', - '', - 'beep', - 'boop' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ]; - out = isIntegerDataType( v ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-integer-data-type/docs/repl.txt b/base/assert/is-integer-data-type/docs/repl.txt deleted file mode 100644 index 14056b2ce..000000000 --- a/base/assert/is-integer-data-type/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( value ) - Tests if an input value is a supported array integer data type. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input value is a supported array integer data - type. - - Examples - -------- - > var bool = {{alias}}( 'float32' ) - false - > bool = {{alias}}( 'float64' ) - false - > bool = {{alias}}( 'int16' ) - true - > bool = {{alias}}( 'int32' ) - true - > bool = {{alias}}( 'int8' ) - true - > bool = {{alias}}( 'uint16' ) - true - > bool = {{alias}}( 'uint32' ) - true - > bool = {{alias}}( 'uint8' ) - true - > bool = {{alias}}( 'uint8c' ) - true - > bool = {{alias}}( '' ) - false - > bool = {{alias}}( 'beep' ) - false - - See Also - -------- - diff --git a/base/assert/is-integer-data-type/docs/types/index.d.ts b/base/assert/is-integer-data-type/docs/types/index.d.ts deleted file mode 100644 index 2580a0a41..000000000 --- a/base/assert/is-integer-data-type/docs/types/index.d.ts +++ /dev/null @@ -1,66 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests whether an input value is a supported array integer (i.e., signed or unsigned integer) data type. -* -* @param v - value to test -* @returns boolean indicating whether an input value is a supported array integer data type -* -* @example -* var bool = isIntegerDataType( 'float32' ); -* // returns false -* -* bool = isIntegerDataType( 'float64' ); -* // returns false -* -* bool = isIntegerDataType( 'generic' ); -* // returns false -* -* bool = isIntegerDataType( 'int16' ); -* // returns true -* -* bool = isIntegerDataType( 'int32' ); -* // returns true -* -* bool = isIntegerDataType( 'int8' ); -* // returns true -* -* bool = isIntegerDataType( 'uint16' ); -* // returns true -* -* bool = isIntegerDataType( 'uint32' ); -* // returns true -* -* bool = isIntegerDataType( 'uint8' ); -* // returns true -* -* bool = isIntegerDataType( 'uint8c' ); -* // returns true -* -* bool = isIntegerDataType( 'foo' ); -* // returns false -*/ -declare function isIntegerDataType( v: any ): boolean; - - -// EXPORTS // - -export = isIntegerDataType; diff --git a/base/assert/is-integer-data-type/docs/types/test.ts b/base/assert/is-integer-data-type/docs/types/test.ts deleted file mode 100644 index a56659e0d..000000000 --- a/base/assert/is-integer-data-type/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import isIntegerDataType = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isIntegerDataType( 'int8' ); // $ExpectType boolean - isIntegerDataType( 'foo' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isIntegerDataType(); // $ExpectError - isIntegerDataType( 'int8', 123 ); // $ExpectError -} diff --git a/base/assert/is-integer-data-type/examples/index.js b/base/assert/is-integer-data-type/examples/index.js deleted file mode 100644 index 991231382..000000000 --- a/base/assert/is-integer-data-type/examples/index.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -var isIntegerDataType = require( './../lib' ); - -var bool = isIntegerDataType( 'float32' ); -console.log( bool ); -// => false - -bool = isIntegerDataType( 'float64' ); -console.log( bool ); -// => false - -bool = isIntegerDataType( 'generic' ); -console.log( bool ); -// => false - -bool = isIntegerDataType( 'int16' ); -console.log( bool ); -// => true - -bool = isIntegerDataType( 'int32' ); -console.log( bool ); -// => true - -bool = isIntegerDataType( 'int8' ); -console.log( bool ); -// => true - -bool = isIntegerDataType( 'uint16' ); -console.log( bool ); -// => true - -bool = isIntegerDataType( 'uint32' ); -console.log( bool ); -// => true - -bool = isIntegerDataType( 'uint8' ); -console.log( bool ); -// => true - -bool = isIntegerDataType( 'uint8c' ); -console.log( bool ); -// => true - -bool = isIntegerDataType( '' ); -console.log( bool ); -// => false - -bool = isIntegerDataType( 'foo' ); -console.log( bool ); -// => false diff --git a/base/assert/is-integer-data-type/lib/index.js b/base/assert/is-integer-data-type/lib/index.js deleted file mode 100644 index ff67cee21..000000000 --- a/base/assert/is-integer-data-type/lib/index.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -/** -* Test whether an input value is a supported array integer data type. -* -* @module @stdlib/array/base/assert/is-integer-data-type -* -* @example -* var isIntegerDataType = require( '@stdlib/array/base/assert/is-integer-data-type' ); -* -* var bool = isIntegerDataType( 'float32' ); -* // returns false -* -* bool = isIntegerDataType( 'float64' ); -* // returns false -* -* bool = isIntegerDataType( 'generic' ); -* // returns false -* -* bool = isIntegerDataType( 'int16' ); -* // returns true -* -* bool = isIntegerDataType( 'int32' ); -* // returns true -* -* bool = isIntegerDataType( 'int8' ); -* // returns true -* -* bool = isIntegerDataType( 'uint16' ); -* // returns true -* -* bool = isIntegerDataType( 'uint32' ); -* // returns true -* -* bool = isIntegerDataType( 'uint8' ); -* // returns true -* -* bool = isIntegerDataType( 'uint8c' ); -* // returns true -* -* bool = isIntegerDataType( 'foo' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-integer-data-type/lib/main.js b/base/assert/is-integer-data-type/lib/main.js deleted file mode 100644 index 2de398d6d..000000000 --- a/base/assert/is-integer-data-type/lib/main.js +++ /dev/null @@ -1,76 +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. -*/ - -'use strict'; - -// MODULES // - -var contains = require( './../../../../base/assert/contains' ).factory; -var dtypes = require( './../../../../dtypes' ); - - -// MAIN // - -/** -* Tests whether an input value is a supported array integer data type. -* -* @name isIntegerDataType -* @type {Function} -* @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported array integer data type -* -* @example -* var bool = isIntegerDataType( 'float32' ); -* // returns false -* -* bool = isIntegerDataType( 'float64' ); -* // returns false -* -* bool = isIntegerDataType( 'generic' ); -* // returns false -* -* bool = isIntegerDataType( 'int16' ); -* // returns true -* -* bool = isIntegerDataType( 'int32' ); -* // returns true -* -* bool = isIntegerDataType( 'int8' ); -* // returns true -* -* bool = isIntegerDataType( 'uint16' ); -* // returns true -* -* bool = isIntegerDataType( 'uint32' ); -* // returns true -* -* bool = isIntegerDataType( 'uint8' ); -* // returns true -* -* bool = isIntegerDataType( 'uint8c' ); -* // returns true -* -* bool = isIntegerDataType( 'foo' ); -* // returns false -*/ -var isIntegerDataType = contains( dtypes( 'integer' ) ); - - -// EXPORTS // - -module.exports = isIntegerDataType; diff --git a/base/assert/is-integer-data-type/package.json b/base/assert/is-integer-data-type/package.json deleted file mode 100644 index 2090f7b31..000000000 --- a/base/assert/is-integer-data-type/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-integer-data-type", - "version": "0.0.0", - "description": "Test if an input value is a supported array integer data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "dtype", - "data", - "utilities", - "utility", - "utils", - "util", - "assert", - "test", - "check", - "is", - "valid", - "validate", - "validation", - "isvalid" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-integer-data-type/test/test.js b/base/assert/is-integer-data-type/test/test.js deleted file mode 100644 index f4271359f..000000000 --- a/base/assert/is-integer-data-type/test/test.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isIntegerDataType = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isIntegerDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a supported array integer data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'int16', - 'int32', - 'int8' - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isIntegerDataType( values[ i ] ); - t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a supported array integer data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - // Supported dtypes: - 'complex64', - 'complex128', - 'float32', - 'float64', - 'generic', - - // Unsupported dtypes: - 'float', - 'int', - 'bin', - '', - 'beep', - 'boop', - 'foo', - 'bar', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isIntegerDataType( values[ i ] ); - t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/base/assert/is-mostly-safe-data-type-cast/README.md b/base/assert/is-mostly-safe-data-type-cast/README.md deleted file mode 100644 index 6da51578c..000000000 --- a/base/assert/is-mostly-safe-data-type-cast/README.md +++ /dev/null @@ -1,118 +0,0 @@ - - -# isMostlySafeCast - -> Determine whether an array [data type][@stdlib/array/dtypes] can be safely cast or, for floating-point data types, downcast to another array [data type][@stdlib/array/dtypes]. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isMostlySafeCast = require( '@stdlib/array/base/assert/is-mostly-safe-data-type-cast' ); -``` - -#### isMostlySafeCast( from, to ) - -Returns a `boolean` indicating whether an array [data type][@stdlib/array/dtypes] can be safely cast or, for floating-point data types, downcast to another array [data type][@stdlib/array/dtypes]. - -```javascript -var bool = isMostlySafeCast( 'float32', 'float64' ); -// returns true - -bool = isMostlySafeCast( 'float64', 'int32' ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var cartesianSquare = require( '@stdlib/array/base/cartesian-square' ); -var dtypes = require( '@stdlib/array/dtypes' ); -var isMostlySafeCast = require( '@stdlib/array/base/assert/is-mostly-safe-data-type-cast' ); - -// Generate a list of dtype pairs: -var dt = cartesianSquare( dtypes() ); - -// For each data type pair, determine whether one can cast to another data type... -var i; -for ( i = 0; i < dt.length; i++ ) { - console.log( '%s. Can cast? %s.', dt[i].join( ' => ' ), isMostlySafeCast.apply( null, dt[i] ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-mostly-safe-data-type-cast/benchmark/benchmark.js b/base/assert/is-mostly-safe-data-type-cast/benchmark/benchmark.js deleted file mode 100644 index 8e0703b50..000000000 --- a/base/assert/is-mostly-safe-data-type-cast/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var dtypes = require( './../../../../dtypes' ); -var pkg = require( './../package.json' ).name; -var isMostlySafeCast = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var N; - var i; - var j; - var k; - - N = DTYPES.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % N; - k = (i+1) % N; - out = isMostlySafeCast( DTYPES[ j ], DTYPES[ k ] ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-mostly-safe-data-type-cast/docs/repl.txt b/base/assert/is-mostly-safe-data-type-cast/docs/repl.txt deleted file mode 100644 index df66d2194..000000000 --- a/base/assert/is-mostly-safe-data-type-cast/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( from, to ) - Returns a boolean indicating whether a provided array data type can be - safely cast or, for floating-point data types, downcast to another array - data type. - - Parameters - ---------- - from: string - Array data type. - - to: string - Array data type. - - Returns - ------- - bool: boolean - Boolean indicating whether a provided data type can be cast to another - data type. - - Examples - -------- - > var bool = {{alias}}( 'float32', 'float64' ) - true - > bool = {{alias}}( 'float64', 'int32' ) - false - - See Also - -------- - diff --git a/base/assert/is-mostly-safe-data-type-cast/docs/types/index.d.ts b/base/assert/is-mostly-safe-data-type-cast/docs/types/index.d.ts deleted file mode 100644 index 79f419691..000000000 --- a/base/assert/is-mostly-safe-data-type-cast/docs/types/index.d.ts +++ /dev/null @@ -1,40 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a boolean indicating if a provided array data type can be safely cast or, for floating-point data types, downcast to another array data type. -* -* @param from - array data type -* @param to - array data type -* @returns boolean indicating if a data type can be cast to another data type -* -* @example -* var bool = isMostlySafeCast( 'float32', 'float64' ); -* // returns true -* -* bool = isMostlySafeCast( 'float64', 'int32' ); -* // returns false -*/ -declare function isMostlySafeCast( from: string, to: string ): boolean; - - -// EXPORTS // - -export = isMostlySafeCast; diff --git a/base/assert/is-mostly-safe-data-type-cast/docs/types/test.ts b/base/assert/is-mostly-safe-data-type-cast/docs/types/test.ts deleted file mode 100644 index 9e58f768e..000000000 --- a/base/assert/is-mostly-safe-data-type-cast/docs/types/test.ts +++ /dev/null @@ -1,58 +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. -*/ - -import isMostlySafeCast = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isMostlySafeCast( 'float32', 'float64' ); // $ExpectType boolean - isMostlySafeCast( 'float64', 'int32' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - isMostlySafeCast( true, 'int32' ); // $ExpectError - isMostlySafeCast( false, 'int32' ); // $ExpectError - isMostlySafeCast( null, 'int32' ); // $ExpectError - isMostlySafeCast( undefined, 'int32' ); // $ExpectError - isMostlySafeCast( 123, 'int32' ); // $ExpectError - isMostlySafeCast( [], 'int32' ); // $ExpectError - isMostlySafeCast( {}, 'int32' ); // $ExpectError - isMostlySafeCast( ( x: number ): number => x, 'int32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a string... -{ - isMostlySafeCast( 'float64', true ); // $ExpectError - isMostlySafeCast( 'float64', false ); // $ExpectError - isMostlySafeCast( 'float64', null ); // $ExpectError - isMostlySafeCast( 'float64', undefined ); // $ExpectError - isMostlySafeCast( 'float64', 123 ); // $ExpectError - isMostlySafeCast( 'float64', [] ); // $ExpectError - isMostlySafeCast( 'float64', {} ); // $ExpectError - isMostlySafeCast( 'float64', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isMostlySafeCast(); // $ExpectError - isMostlySafeCast( 'float64' ); // $ExpectError -} diff --git a/base/assert/is-mostly-safe-data-type-cast/examples/index.js b/base/assert/is-mostly-safe-data-type-cast/examples/index.js deleted file mode 100644 index 268ee91e2..000000000 --- a/base/assert/is-mostly-safe-data-type-cast/examples/index.js +++ /dev/null @@ -1,32 +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. -*/ - -'use strict'; - -var cartesianSquare = require( './../../../../cartesian-square' ); -var dtypes = require( './../../../../dtypes' ); -var isMostlySafeCast = require( './../lib' ); - -// Generate a list of dtype pairs: -var dt = cartesianSquare( dtypes() ); - -// For each data type pair, determine whether one can cast to another data type... -var i; -for ( i = 0; i < dt.length; i++ ) { - console.log( '%s. Can cast? %s.', dt[i].join( ' => ' ), isMostlySafeCast.apply( null, dt[i] ) ); -} diff --git a/base/assert/is-mostly-safe-data-type-cast/lib/index.js b/base/assert/is-mostly-safe-data-type-cast/lib/index.js deleted file mode 100644 index 2d7fcee99..000000000 --- a/base/assert/is-mostly-safe-data-type-cast/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Determine if an array data type can be safely cast or, for floating-point data types, downcast to another array data type. -* -* @module @stdlib/array/base/assert/is-mostly-safe-data-type-cast -* -* @example -* var isMostlySafeCast = require( '@stdlib/array/base/assert/is-mostly-safe-data-type-cast' ); -* -* var bool = isMostlySafeCast( 'float32', 'float64' ); -* // returns true -* -* bool = isMostlySafeCast( 'float64', 'int32' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-mostly-safe-data-type-cast/lib/main.js b/base/assert/is-mostly-safe-data-type-cast/lib/main.js deleted file mode 100644 index 468e25079..000000000 --- a/base/assert/is-mostly-safe-data-type-cast/lib/main.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -// MODULES // - -var casts = require( './../../../../mostly-safe-casts' ); - - -// VARIABLES // - -var TABLE = casts(); - - -// MAIN // - -/** -* Returns a boolean indicating if a provided array data type can be safely cast or, for floating-point data types, downcast to another array data type. -* -* @param {string} from - array data type -* @param {string} to - array data type -* @returns {boolean} boolean indicating if a data type can be cast to another data type -* -* @example -* var bool = isMostlySafeCast( 'float32', 'float64' ); -* // returns true -* -* bool = isMostlySafeCast( 'float64', 'int32' ); -* // returns false -*/ -function isMostlySafeCast( from, to ) { - if ( from === to ) { - return true; - } - return ( TABLE[ from ][ to ] > 0 ); -} - - -// EXPORTS // - -module.exports = isMostlySafeCast; diff --git a/base/assert/is-mostly-safe-data-type-cast/package.json b/base/assert/is-mostly-safe-data-type-cast/package.json deleted file mode 100644 index a56c6cbd0..000000000 --- a/base/assert/is-mostly-safe-data-type-cast/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-mostly-safe-data-type-cast", - "version": "0.0.0", - "description": "Determine if an array data type can be safely cast or, for floating-point data types, downcast to another array data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "casting", - "safe", - "cast", - "promotion", - "test", - "assert", - "check", - "validate", - "validation", - "valid", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-mostly-safe-data-type-cast/test/test.js b/base/assert/is-mostly-safe-data-type-cast/test/test.js deleted file mode 100644 index 2337330c5..000000000 --- a/base/assert/is-mostly-safe-data-type-cast/test/test.js +++ /dev/null @@ -1,59 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( './../../../../dtypes' ); -var casts = require( './../../../../mostly-safe-casts' ); -var isMostlySafeCast = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var CASTS = casts(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isMostlySafeCast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a boolean indicating if an array data type can be cast to another array data type', function test( t ) { - var expected; - var actual; - var dt; - var i; - var j; - - for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - for ( j = 0; j < DTYPES.length; j++ ) { - expected = ( CASTS[ dt ][ DTYPES[j] ] > 0 ); - actual = isMostlySafeCast( dt, DTYPES[ j ] ); - t.strictEqual( actual, expected, 'returns expected value. from: '+dt+'. to: '+DTYPES[j]+'.' ); - } - } - t.end(); -}); diff --git a/base/assert/is-numeric-data-type/README.md b/base/assert/is-numeric-data-type/README.md deleted file mode 100644 index ca4e07e41..000000000 --- a/base/assert/is-numeric-data-type/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# isNumericDataType - -> Test if an input value is a supported array numeric data type. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isNumericDataType = require( '@stdlib/array/base/assert/is-numeric-data-type' ); -``` - -#### isNumericDataType( value ) - -Tests if an input `value` is a supported array numeric data type. - -```javascript -var bool = isNumericDataType( 'float32' ); -// returns true - -bool = isNumericDataType( 'uint32' ); -// returns true -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var isNumericDataType = require( '@stdlib/array/base/assert/is-numeric-data-type' ); - -var bool = isNumericDataType( 'float32' ); -// returns true - -bool = isNumericDataType( 'float64' ); -// returns true - -bool = isNumericDataType( 'generic' ); -// returns false - -bool = isNumericDataType( 'int16' ); -// returns true - -bool = isNumericDataType( 'int32' ); -// returns true - -bool = isNumericDataType( 'int8' ); -// returns true - -bool = isNumericDataType( 'uint16' ); -// returns true - -bool = isNumericDataType( 'uint32' ); -// returns true - -bool = isNumericDataType( 'uint8' ); -// returns true - -bool = isNumericDataType( 'uint8c' ); -// returns true - -bool = isNumericDataType( '' ); -// returns false - -bool = isNumericDataType( 'foo' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-numeric-data-type/benchmark/benchmark.js b/base/assert/is-numeric-data-type/benchmark/benchmark.js deleted file mode 100644 index e5d2320ab..000000000 --- a/base/assert/is-numeric-data-type/benchmark/benchmark.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isNumericDataType = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - 'binary', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'foo', - 'bar', - '', - 'beep', - 'boop' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ]; - out = isNumericDataType( v ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-numeric-data-type/docs/repl.txt b/base/assert/is-numeric-data-type/docs/repl.txt deleted file mode 100644 index 106bf358c..000000000 --- a/base/assert/is-numeric-data-type/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( value ) - Tests if an input value is a supported array numeric data type. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input value is a supported array numeric data - type. - - Examples - -------- - > var bool = {{alias}}( 'float32' ) - true - > bool = {{alias}}( 'float64' ) - true - > bool = {{alias}}( 'int16' ) - true - > bool = {{alias}}( 'int32' ) - true - > bool = {{alias}}( 'int8' ) - true - > bool = {{alias}}( 'uint16' ) - true - > bool = {{alias}}( 'uint32' ) - true - > bool = {{alias}}( 'uint8' ) - true - > bool = {{alias}}( 'uint8c' ) - true - > bool = {{alias}}( '' ) - false - > bool = {{alias}}( 'beep' ) - false - - See Also - -------- - diff --git a/base/assert/is-numeric-data-type/docs/types/index.d.ts b/base/assert/is-numeric-data-type/docs/types/index.d.ts deleted file mode 100644 index 54d7b0611..000000000 --- a/base/assert/is-numeric-data-type/docs/types/index.d.ts +++ /dev/null @@ -1,66 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests whether an input value is a supported array numeric data type. -* -* @param v - value to test -* @returns boolean indicating whether an input value is a supported array numeric data type -* -* @example -* var bool = isNumericDataType( 'float32' ); -* // returns true -* -* bool = isNumericDataType( 'float64' ); -* // returns true -* -* bool = isNumericDataType( 'generic' ); -* // returns false -* -* bool = isNumericDataType( 'int16' ); -* // returns true -* -* bool = isNumericDataType( 'int32' ); -* // returns true -* -* bool = isNumericDataType( 'int8' ); -* // returns true -* -* bool = isNumericDataType( 'uint16' ); -* // returns true -* -* bool = isNumericDataType( 'uint32' ); -* // returns true -* -* bool = isNumericDataType( 'uint8' ); -* // returns true -* -* bool = isNumericDataType( 'uint8c' ); -* // returns true -* -* bool = isNumericDataType( 'foo' ); -* // returns false -*/ -declare function isNumericDataType( v: any ): boolean; - - -// EXPORTS // - -export = isNumericDataType; diff --git a/base/assert/is-numeric-data-type/docs/types/test.ts b/base/assert/is-numeric-data-type/docs/types/test.ts deleted file mode 100644 index c34882835..000000000 --- a/base/assert/is-numeric-data-type/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import isNumericDataType = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isNumericDataType( 'int8' ); // $ExpectType boolean - isNumericDataType( 'foo' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isNumericDataType(); // $ExpectError - isNumericDataType( 'int8', 123 ); // $ExpectError -} diff --git a/base/assert/is-numeric-data-type/examples/index.js b/base/assert/is-numeric-data-type/examples/index.js deleted file mode 100644 index aded43015..000000000 --- a/base/assert/is-numeric-data-type/examples/index.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -var isNumericDataType = require( './../lib' ); - -var bool = isNumericDataType( 'float32' ); -console.log( bool ); -// => true - -bool = isNumericDataType( 'float64' ); -console.log( bool ); -// => true - -bool = isNumericDataType( 'generic' ); -console.log( bool ); -// => false - -bool = isNumericDataType( 'int16' ); -console.log( bool ); -// => true - -bool = isNumericDataType( 'int32' ); -console.log( bool ); -// => true - -bool = isNumericDataType( 'int8' ); -console.log( bool ); -// => true - -bool = isNumericDataType( 'uint16' ); -console.log( bool ); -// => true - -bool = isNumericDataType( 'uint32' ); -console.log( bool ); -// => true - -bool = isNumericDataType( 'uint8' ); -console.log( bool ); -// => true - -bool = isNumericDataType( 'uint8c' ); -console.log( bool ); -// => true - -bool = isNumericDataType( '' ); -console.log( bool ); -// => false - -bool = isNumericDataType( 'foo' ); -console.log( bool ); -// => false diff --git a/base/assert/is-numeric-data-type/lib/index.js b/base/assert/is-numeric-data-type/lib/index.js deleted file mode 100644 index ae724c784..000000000 --- a/base/assert/is-numeric-data-type/lib/index.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -/** -* Test whether an input value is a supported array numeric data type. -* -* @module @stdlib/array/base/assert/is-numeric-data-type -* -* @example -* var isNumericDataType = require( '@stdlib/array/base/assert/is-numeric-data-type' ); -* -* var bool = isNumericDataType( 'float32' ); -* // returns true -* -* bool = isNumericDataType( 'float64' ); -* // returns true -* -* bool = isNumericDataType( 'generic' ); -* // returns false -* -* bool = isNumericDataType( 'int16' ); -* // returns true -* -* bool = isNumericDataType( 'int32' ); -* // returns true -* -* bool = isNumericDataType( 'int8' ); -* // returns true -* -* bool = isNumericDataType( 'uint16' ); -* // returns true -* -* bool = isNumericDataType( 'uint32' ); -* // returns true -* -* bool = isNumericDataType( 'uint8' ); -* // returns true -* -* bool = isNumericDataType( 'uint8c' ); -* // returns true -* -* bool = isNumericDataType( 'foo' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-numeric-data-type/lib/main.js b/base/assert/is-numeric-data-type/lib/main.js deleted file mode 100644 index 2bf869e5d..000000000 --- a/base/assert/is-numeric-data-type/lib/main.js +++ /dev/null @@ -1,76 +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. -*/ - -'use strict'; - -// MODULES // - -var contains = require( './../../../../base/assert/contains' ).factory; -var dtypes = require( './../../../../dtypes' ); - - -// MAIN // - -/** -* Tests whether an input value is a supported array numeric data type. -* -* @name isNumericDataType -* @type {Function} -* @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported array numeric data type -* -* @example -* var bool = isNumericDataType( 'float32' ); -* // returns true -* -* bool = isNumericDataType( 'float64' ); -* // returns true -* -* bool = isNumericDataType( 'generic' ); -* // returns false -* -* bool = isNumericDataType( 'int16' ); -* // returns true -* -* bool = isNumericDataType( 'int32' ); -* // returns true -* -* bool = isNumericDataType( 'int8' ); -* // returns true -* -* bool = isNumericDataType( 'uint16' ); -* // returns true -* -* bool = isNumericDataType( 'uint32' ); -* // returns true -* -* bool = isNumericDataType( 'uint8' ); -* // returns true -* -* bool = isNumericDataType( 'uint8c' ); -* // returns true -* -* bool = isNumericDataType( 'foo' ); -* // returns false -*/ -var isNumericDataType = contains( dtypes( 'numeric' ) ); - - -// EXPORTS // - -module.exports = isNumericDataType; diff --git a/base/assert/is-numeric-data-type/package.json b/base/assert/is-numeric-data-type/package.json deleted file mode 100644 index 8a316a8af..000000000 --- a/base/assert/is-numeric-data-type/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-numeric-data-type", - "version": "0.0.0", - "description": "Test if an input value is a supported array numeric data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "dtype", - "data", - "utilities", - "utility", - "utils", - "util", - "assert", - "test", - "check", - "is", - "valid", - "validate", - "validation", - "isvalid" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-numeric-data-type/test/test.js b/base/assert/is-numeric-data-type/test/test.js deleted file mode 100644 index 69f10c18d..000000000 --- a/base/assert/is-numeric-data-type/test/test.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isNumericDataType = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isNumericDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a supported array numeric data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'complex64', - 'complex128', - 'float32', - 'float64', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'int16', - 'int32', - 'int8' - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isNumericDataType( values[ i ] ); - t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a supported array numeric data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - // Supported dtypes: - 'generic', - - // Unsupported dtypes: - 'float', - 'int', - 'bin', - '', - 'beep', - 'boop', - 'foo', - 'bar', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isNumericDataType( values[ i ] ); - t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/base/assert/is-real-data-type/README.md b/base/assert/is-real-data-type/README.md deleted file mode 100644 index 72a4a5269..000000000 --- a/base/assert/is-real-data-type/README.md +++ /dev/null @@ -1,144 +0,0 @@ - - -# isRealDataType - -> Test if an input value is a supported array real-valued data type. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isRealDataType = require( '@stdlib/array/base/assert/is-real-data-type' ); -``` - -#### isRealDataType( value ) - -Tests if an input `value` is a supported array real-valued data type. - -```javascript -var bool = isRealDataType( 'float32' ); -// returns true - -bool = isRealDataType( 'uint32' ); -// returns true -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var isRealDataType = require( '@stdlib/array/base/assert/is-real-data-type' ); - -var bool = isRealDataType( 'float32' ); -// returns true - -bool = isRealDataType( 'float64' ); -// returns true - -bool = isRealDataType( 'complex128' ); -// returns false - -bool = isRealDataType( 'generic' ); -// returns false - -bool = isRealDataType( 'int16' ); -// returns true - -bool = isRealDataType( 'int32' ); -// returns true - -bool = isRealDataType( 'int8' ); -// returns true - -bool = isRealDataType( 'uint16' ); -// returns true - -bool = isRealDataType( 'uint32' ); -// returns true - -bool = isRealDataType( 'uint8' ); -// returns true - -bool = isRealDataType( 'uint8c' ); -// returns true - -bool = isRealDataType( '' ); -// returns false - -bool = isRealDataType( 'foo' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-real-data-type/benchmark/benchmark.js b/base/assert/is-real-data-type/benchmark/benchmark.js deleted file mode 100644 index bef07db26..000000000 --- a/base/assert/is-real-data-type/benchmark/benchmark.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isRealDataType = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - 'binary', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'foo', - 'bar', - '', - 'beep', - 'boop' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ]; - out = isRealDataType( v ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-real-data-type/docs/repl.txt b/base/assert/is-real-data-type/docs/repl.txt deleted file mode 100644 index 138367041..000000000 --- a/base/assert/is-real-data-type/docs/repl.txt +++ /dev/null @@ -1,45 +0,0 @@ - -{{alias}}( value ) - Tests if an input value is a supported array real-valued data type. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input value is a supported array real-valued - data type. - - Examples - -------- - > var bool = {{alias}}( 'float32' ) - true - > bool = {{alias}}( 'float64' ) - true - > bool = {{alias}}( 'complex128' ) - false - > bool = {{alias}}( 'int16' ) - true - > bool = {{alias}}( 'int32' ) - true - > bool = {{alias}}( 'int8' ) - true - > bool = {{alias}}( 'uint16' ) - true - > bool = {{alias}}( 'uint32' ) - true - > bool = {{alias}}( 'uint8' ) - true - > bool = {{alias}}( 'uint8c' ) - true - > bool = {{alias}}( '' ) - false - > bool = {{alias}}( 'beep' ) - false - - See Also - -------- - diff --git a/base/assert/is-real-data-type/docs/types/index.d.ts b/base/assert/is-real-data-type/docs/types/index.d.ts deleted file mode 100644 index d3d5fdc54..000000000 --- a/base/assert/is-real-data-type/docs/types/index.d.ts +++ /dev/null @@ -1,69 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests whether an input value is a supported array real-valued data type. -* -* @param v - value to test -* @returns boolean indicating whether an input value is a supported array real-valued data type -* -* @example -* var bool = isRealDataType( 'float32' ); -* // returns true -* -* bool = isRealDataType( 'float64' ); -* // returns true -* -* bool = isRealDataType( 'complex128' ); -* // returns false -* -* bool = isRealDataType( 'generic' ); -* // returns false -* -* bool = isRealDataType( 'int16' ); -* // returns true -* -* bool = isRealDataType( 'int32' ); -* // returns true -* -* bool = isRealDataType( 'int8' ); -* // returns true -* -* bool = isRealDataType( 'uint16' ); -* // returns true -* -* bool = isRealDataType( 'uint32' ); -* // returns true -* -* bool = isRealDataType( 'uint8' ); -* // returns true -* -* bool = isRealDataType( 'uint8c' ); -* // returns true -* -* bool = isRealDataType( 'foo' ); -* // returns false -*/ -declare function isRealDataType( v: any ): boolean; - - -// EXPORTS // - -export = isRealDataType; diff --git a/base/assert/is-real-data-type/docs/types/test.ts b/base/assert/is-real-data-type/docs/types/test.ts deleted file mode 100644 index 4e5288bb7..000000000 --- a/base/assert/is-real-data-type/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import isRealDataType = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isRealDataType( 'int8' ); // $ExpectType boolean - isRealDataType( 'foo' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isRealDataType(); // $ExpectError - isRealDataType( 'int8', 123 ); // $ExpectError -} diff --git a/base/assert/is-real-data-type/examples/index.js b/base/assert/is-real-data-type/examples/index.js deleted file mode 100644 index 54a852a8a..000000000 --- a/base/assert/is-real-data-type/examples/index.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -var isRealDataType = require( './../lib' ); - -var bool = isRealDataType( 'float32' ); -console.log( bool ); -// => true - -bool = isRealDataType( 'float64' ); -console.log( bool ); -// => true - -bool = isRealDataType( 'generic' ); -console.log( bool ); -// => false - -bool = isRealDataType( 'int16' ); -console.log( bool ); -// => true - -bool = isRealDataType( 'int32' ); -console.log( bool ); -// => true - -bool = isRealDataType( 'int8' ); -console.log( bool ); -// => true - -bool = isRealDataType( 'uint16' ); -console.log( bool ); -// => true - -bool = isRealDataType( 'uint32' ); -console.log( bool ); -// => true - -bool = isRealDataType( 'uint8' ); -console.log( bool ); -// => true - -bool = isRealDataType( 'uint8c' ); -console.log( bool ); -// => true - -bool = isRealDataType( '' ); -console.log( bool ); -// => false - -bool = isRealDataType( 'foo' ); -console.log( bool ); -// => false diff --git a/base/assert/is-real-data-type/lib/index.js b/base/assert/is-real-data-type/lib/index.js deleted file mode 100644 index f4c0dbdfb..000000000 --- a/base/assert/is-real-data-type/lib/index.js +++ /dev/null @@ -1,73 +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. -*/ - -'use strict'; - -/** -* Test whether an input value is a supported array real-valued data type. -* -* @module @stdlib/array/base/assert/is-real-data-type -* -* @example -* var isRealDataType = require( '@stdlib/array/base/assert/is-real-data-type' ); -* -* var bool = isRealDataType( 'float32' ); -* // returns true -* -* bool = isRealDataType( 'float64' ); -* // returns true -* -* bool = isRealDataType( 'complex128' ); -* // returns false -* -* bool = isRealDataType( 'generic' ); -* // returns false -* -* bool = isRealDataType( 'int16' ); -* // returns true -* -* bool = isRealDataType( 'int32' ); -* // returns true -* -* bool = isRealDataType( 'int8' ); -* // returns true -* -* bool = isRealDataType( 'uint16' ); -* // returns true -* -* bool = isRealDataType( 'uint32' ); -* // returns true -* -* bool = isRealDataType( 'uint8' ); -* // returns true -* -* bool = isRealDataType( 'uint8c' ); -* // returns true -* -* bool = isRealDataType( 'foo' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-real-data-type/lib/main.js b/base/assert/is-real-data-type/lib/main.js deleted file mode 100644 index b7728bc89..000000000 --- a/base/assert/is-real-data-type/lib/main.js +++ /dev/null @@ -1,79 +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. -*/ - -'use strict'; - -// MODULES // - -var contains = require( './../../../../base/assert/contains' ).factory; -var dtypes = require( './../../../../dtypes' ); - - -// MAIN // - -/** -* Tests whether an input value is a supported array real-valued data type. -* -* @name isRealDataType -* @type {Function} -* @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported array real-valued data type -* -* @example -* var bool = isRealDataType( 'float32' ); -* // returns true -* -* bool = isRealDataType( 'float64' ); -* // returns true -* -* bool = isRealDataType( 'complex128' ); -* // returns false -* -* bool = isRealDataType( 'generic' ); -* // returns false -* -* bool = isRealDataType( 'int16' ); -* // returns true -* -* bool = isRealDataType( 'int32' ); -* // returns true -* -* bool = isRealDataType( 'int8' ); -* // returns true -* -* bool = isRealDataType( 'uint16' ); -* // returns true -* -* bool = isRealDataType( 'uint32' ); -* // returns true -* -* bool = isRealDataType( 'uint8' ); -* // returns true -* -* bool = isRealDataType( 'uint8c' ); -* // returns true -* -* bool = isRealDataType( 'foo' ); -* // returns false -*/ -var isRealDataType = contains( dtypes( 'real' ) ); - - -// EXPORTS // - -module.exports = isRealDataType; diff --git a/base/assert/is-real-data-type/package.json b/base/assert/is-real-data-type/package.json deleted file mode 100644 index 0699fab31..000000000 --- a/base/assert/is-real-data-type/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-real-data-type", - "version": "0.0.0", - "description": "Test if an input value is a supported array real-valued data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "dtype", - "data", - "utilities", - "utility", - "utils", - "util", - "assert", - "test", - "check", - "is", - "valid", - "validate", - "validation", - "isvalid" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-real-data-type/test/test.js b/base/assert/is-real-data-type/test/test.js deleted file mode 100644 index b3a8432c6..000000000 --- a/base/assert/is-real-data-type/test/test.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isRealDataType = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isRealDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a supported array real-valued data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'float32', - 'float64', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'int16', - 'int32', - 'int8' - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isRealDataType( values[ i ] ); - t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a supported array real-valued data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - // Supported dtypes: - 'generic', - 'complex128', - 'complex64', - - // Unsupported dtypes: - 'float', - 'int', - 'bin', - '', - 'beep', - 'boop', - 'foo', - 'bar', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isRealDataType( values[ i ] ); - t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/base/assert/is-real-floating-point-data-type/README.md b/base/assert/is-real-floating-point-data-type/README.md deleted file mode 100644 index 615381240..000000000 --- a/base/assert/is-real-floating-point-data-type/README.md +++ /dev/null @@ -1,147 +0,0 @@ - - -# isRealFloatingPointDataType - -> Test if an input value is a supported array real-valued floating-point data type. - - - -
- -
- - - - - -
- -## Usage - - - -```javascript -var isRealFloatingPointDataType = require( '@stdlib/array/base/assert/is-real-floating-point-data-type' ); -``` - -#### isRealFloatingPointDataType( value ) - -Tests if an input `value` is a supported array real-valued floating-point data type. - - - -```javascript -var bool = isRealFloatingPointDataType( 'float32' ); -// returns true - -bool = isRealFloatingPointDataType( 'uint32' ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - - - -```javascript -var isRealFloatingPointDataType = require( '@stdlib/array/base/assert/is-real-floating-point-data-type' ); - -var bool = isRealFloatingPointDataType( 'float32' ); -// returns true - -bool = isRealFloatingPointDataType( 'float64' ); -// returns true - -bool = isRealFloatingPointDataType( 'generic' ); -// returns false - -bool = isRealFloatingPointDataType( 'int16' ); -// returns false - -bool = isRealFloatingPointDataType( 'int32' ); -// returns false - -bool = isRealFloatingPointDataType( 'int8' ); -// returns false - -bool = isRealFloatingPointDataType( 'uint16' ); -// returns false - -bool = isRealFloatingPointDataType( 'uint32' ); -// returns false - -bool = isRealFloatingPointDataType( 'uint8' ); -// returns false - -bool = isRealFloatingPointDataType( 'uint8c' ); -// returns false - -bool = isRealFloatingPointDataType( '' ); -// returns false - -bool = isRealFloatingPointDataType( 'foo' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-real-floating-point-data-type/benchmark/benchmark.js b/base/assert/is-real-floating-point-data-type/benchmark/benchmark.js deleted file mode 100644 index a2b41ea7a..000000000 --- a/base/assert/is-real-floating-point-data-type/benchmark/benchmark.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isRealFloatingPointDataType = require( './../lib' ); // eslint-disable-line id-length - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - 'binary', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'foo', - 'bar', - '', - 'beep', - 'boop' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ]; - out = isRealFloatingPointDataType( v ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-real-floating-point-data-type/docs/repl.txt b/base/assert/is-real-floating-point-data-type/docs/repl.txt deleted file mode 100644 index 08ba9bbe9..000000000 --- a/base/assert/is-real-floating-point-data-type/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( value ) - Tests if an input value is a supported array real-valued floating-point data - type. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input value is a supported array real-valued - floating-point data type. - - Examples - -------- - > var bool = {{alias}}( 'float32' ) - true - > bool = {{alias}}( 'float64' ) - true - > bool = {{alias}}( 'int16' ) - false - > bool = {{alias}}( 'int32' ) - false - > bool = {{alias}}( 'int8' ) - false - > bool = {{alias}}( 'uint16' ) - false - > bool = {{alias}}( 'uint32' ) - false - > bool = {{alias}}( 'uint8' ) - false - > bool = {{alias}}( 'uint8c' ) - false - > bool = {{alias}}( '' ) - false - > bool = {{alias}}( 'beep' ) - false - - See Also - -------- - diff --git a/base/assert/is-real-floating-point-data-type/docs/types/index.d.ts b/base/assert/is-real-floating-point-data-type/docs/types/index.d.ts deleted file mode 100644 index d978234b1..000000000 --- a/base/assert/is-real-floating-point-data-type/docs/types/index.d.ts +++ /dev/null @@ -1,66 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests whether an input value is a supported array real-valued floating-point data type. -* -* @param v - value to test -* @returns boolean indicating whether an input value is a supported array real-valued floating-point data type -* -* @example -* var bool = isRealFloatingPointDataType( 'float32' ); -* // returns true -* -* bool = isRealFloatingPointDataType( 'float64' ); -* // returns true -* -* bool = isRealFloatingPointDataType( 'generic' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'int16' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'int32' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'int8' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint16' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint32' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint8' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint8c' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'foo' ); -* // returns false -*/ -declare function isRealFloatingPointDataType( v: any ): boolean; - - -// EXPORTS // - -export = isRealFloatingPointDataType; diff --git a/base/assert/is-real-floating-point-data-type/docs/types/test.ts b/base/assert/is-real-floating-point-data-type/docs/types/test.ts deleted file mode 100644 index b22c271d2..000000000 --- a/base/assert/is-real-floating-point-data-type/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import isRealFloatingPointDataType = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isRealFloatingPointDataType( 'float32' ); // $ExpectType boolean - isRealFloatingPointDataType( 'foo' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isRealFloatingPointDataType(); // $ExpectError - isRealFloatingPointDataType( 'float32', 123 ); // $ExpectError -} diff --git a/base/assert/is-real-floating-point-data-type/examples/index.js b/base/assert/is-real-floating-point-data-type/examples/index.js deleted file mode 100644 index c1105f145..000000000 --- a/base/assert/is-real-floating-point-data-type/examples/index.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -var isRealFloatingPointDataType = require( './../lib' ); // eslint-disable-line id-length - -var bool = isRealFloatingPointDataType( 'float32' ); -console.log( bool ); -// => true - -bool = isRealFloatingPointDataType( 'float64' ); -console.log( bool ); -// => true - -bool = isRealFloatingPointDataType( 'generic' ); -console.log( bool ); -// => false - -bool = isRealFloatingPointDataType( 'int16' ); -console.log( bool ); -// => false - -bool = isRealFloatingPointDataType( 'int32' ); -console.log( bool ); -// => false - -bool = isRealFloatingPointDataType( 'int8' ); -console.log( bool ); -// => false - -bool = isRealFloatingPointDataType( 'uint16' ); -console.log( bool ); -// => false - -bool = isRealFloatingPointDataType( 'uint32' ); -console.log( bool ); -// => false - -bool = isRealFloatingPointDataType( 'uint8' ); -console.log( bool ); -// => false - -bool = isRealFloatingPointDataType( 'uint8c' ); -console.log( bool ); -// => false - -bool = isRealFloatingPointDataType( '' ); -console.log( bool ); -// => false - -bool = isRealFloatingPointDataType( 'foo' ); -console.log( bool ); -// => false diff --git a/base/assert/is-real-floating-point-data-type/lib/index.js b/base/assert/is-real-floating-point-data-type/lib/index.js deleted file mode 100644 index c9738aee3..000000000 --- a/base/assert/is-real-floating-point-data-type/lib/index.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -/** -* Test whether an input value is a supported array real-valued floating-point data type. -* -* @module @stdlib/array/base/assert/is-real-floating-point-data-type -* -* @example -* var isRealFloatingPointDataType = require( '@stdlib/array/base/assert/is-real-floating-point-data-type' ); -* -* var bool = isRealFloatingPointDataType( 'float32' ); -* // returns true -* -* bool = isRealFloatingPointDataType( 'float64' ); -* // returns true -* -* bool = isRealFloatingPointDataType( 'generic' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'int16' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'int32' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'int8' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint16' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint32' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint8' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint8c' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'foo' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-real-floating-point-data-type/lib/main.js b/base/assert/is-real-floating-point-data-type/lib/main.js deleted file mode 100644 index 664eb4cb3..000000000 --- a/base/assert/is-real-floating-point-data-type/lib/main.js +++ /dev/null @@ -1,76 +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. -*/ - -'use strict'; - -// MODULES // - -var contains = require( './../../../../base/assert/contains' ).factory; -var dtypes = require( './../../../../dtypes' ); - - -// MAIN // - -/** -* Tests whether an input value is a supported array real-valued floating-point data type. -* -* @name isRealFloatingPointDataType -* @type {Function} -* @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported array real-valued floating-point data type -* -* @example -* var bool = isRealFloatingPointDataType( 'float32' ); -* // returns true -* -* bool = isRealFloatingPointDataType( 'float64' ); -* // returns true -* -* bool = isRealFloatingPointDataType( 'generic' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'int16' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'int32' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'int8' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint16' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint32' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint8' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'uint8c' ); -* // returns false -* -* bool = isRealFloatingPointDataType( 'foo' ); -* // returns false -*/ -var isRealFloatingPointDataType = contains( dtypes( 'real_floating_point' ) ); // eslint-disable-line id-length - - -// EXPORTS // - -module.exports = isRealFloatingPointDataType; diff --git a/base/assert/is-real-floating-point-data-type/package.json b/base/assert/is-real-floating-point-data-type/package.json deleted file mode 100644 index b76743eb2..000000000 --- a/base/assert/is-real-floating-point-data-type/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-real-floating-point-data-type", - "version": "0.0.0", - "description": "Test if an input value is a supported array real-valued floating-point data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "dtype", - "data", - "utilities", - "utility", - "utils", - "util", - "assert", - "test", - "check", - "is", - "valid", - "validate", - "validation", - "isvalid" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-real-floating-point-data-type/test/test.js b/base/assert/is-real-floating-point-data-type/test/test.js deleted file mode 100644 index 20e447d18..000000000 --- a/base/assert/is-real-floating-point-data-type/test/test.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isRealFloatingPointDataType = require( './../lib' ); // eslint-disable-line id-length - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isRealFloatingPointDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a supported array real-valued floating-point data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'float32', - 'float64' - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isRealFloatingPointDataType( values[ i ] ); - t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a supported array real-valued floating-point data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - // Supported dtypes: - 'complex64', - 'complex128', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'int16', - 'int32', - 'int8', - 'generic', - - // Unsupported dtypes: - 'float', - 'int', - 'bin', - '', - 'beep', - 'boop', - 'foo', - 'bar', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isRealFloatingPointDataType( values[ i ] ); - t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/base/assert/is-safe-data-type-cast/README.md b/base/assert/is-safe-data-type-cast/README.md deleted file mode 100644 index ebd68da7d..000000000 --- a/base/assert/is-safe-data-type-cast/README.md +++ /dev/null @@ -1,118 +0,0 @@ - - -# isSafeCast - -> Determine whether an array [data type][@stdlib/array/dtypes] can be safely cast to another array [data type][@stdlib/array/dtypes]. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isSafeCast = require( '@stdlib/array/base/assert/is-safe-data-type-cast' ); -``` - -#### isSafeCast( from, to ) - -Returns a `boolean` indicating whether an array [data type][@stdlib/array/dtypes] can be safely cast to another array [data type][@stdlib/array/dtypes]. - -```javascript -var bool = isSafeCast( 'float32', 'float64' ); -// returns true - -bool = isSafeCast( 'float64', 'int32' ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var cartesianSquare = require( '@stdlib/array/cartesian-square' ); -var dtypes = require( '@stdlib/array/dtypes' ); -var isSafeCast = require( '@stdlib/array/base/assert/is-safe-data-type-cast' ); - -// Generate a list of dtype pairs: -var dt = cartesianSquare( dtypes() ); - -// For each data type pair, determine whether one can safely cast from one data type to another... -var i; -for ( i = 0; i < dt.length; i++ ) { - console.log( '%s. Safe? %s.', dt[i].join( ' => ' ), isSafeCast.apply( null, dt[i] ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-safe-data-type-cast/benchmark/benchmark.js b/base/assert/is-safe-data-type-cast/benchmark/benchmark.js deleted file mode 100644 index b886dcf7c..000000000 --- a/base/assert/is-safe-data-type-cast/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var dtypes = require( './../../../../dtypes' ); -var pkg = require( './../package.json' ).name; -var isSafeCast = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var N; - var i; - var j; - var k; - - N = DTYPES.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % N; - k = (i+1) % N; - out = isSafeCast( DTYPES[ j ], DTYPES[ k ] ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-safe-data-type-cast/docs/repl.txt b/base/assert/is-safe-data-type-cast/docs/repl.txt deleted file mode 100644 index 276ae51b3..000000000 --- a/base/assert/is-safe-data-type-cast/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( from, to ) - Returns a boolean indicating whether a provided array data type can be - safely cast to another array data type. - - Parameters - ---------- - from: string - Array data type. - - to: string - Array data type. - - Returns - ------- - bool: boolean - Boolean indicating whether a provided data type can be safely cast to - another data type. - - Examples - -------- - > var bool = {{alias}}( 'float32', 'float64' ) - true - > bool = {{alias}}( 'float64', 'int32' ) - false - - See Also - -------- - diff --git a/base/assert/is-safe-data-type-cast/docs/types/index.d.ts b/base/assert/is-safe-data-type-cast/docs/types/index.d.ts deleted file mode 100644 index dc861c75d..000000000 --- a/base/assert/is-safe-data-type-cast/docs/types/index.d.ts +++ /dev/null @@ -1,40 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a boolean indicating if a provided array data type can be safely cast to another array data type. -* -* @param from - array data type -* @param to - array data type -* @returns boolean indicating if a data type can be safely cast to another data type -* -* @example -* var bool = isSafeCast( 'float32', 'float64' ); -* // returns true -* -* bool = isSafeCast( 'float64', 'int32' ); -* // returns false -*/ -declare function isSafeCast( from: string, to: string ): boolean; - - -// EXPORTS // - -export = isSafeCast; diff --git a/base/assert/is-safe-data-type-cast/docs/types/test.ts b/base/assert/is-safe-data-type-cast/docs/types/test.ts deleted file mode 100644 index 4791c1a59..000000000 --- a/base/assert/is-safe-data-type-cast/docs/types/test.ts +++ /dev/null @@ -1,58 +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. -*/ - -import isSafeCast = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isSafeCast( 'float32', 'float64' ); // $ExpectType boolean - isSafeCast( 'float64', 'int32' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - isSafeCast( true, 'int32' ); // $ExpectError - isSafeCast( false, 'int32' ); // $ExpectError - isSafeCast( null, 'int32' ); // $ExpectError - isSafeCast( undefined, 'int32' ); // $ExpectError - isSafeCast( 123, 'int32' ); // $ExpectError - isSafeCast( [], 'int32' ); // $ExpectError - isSafeCast( {}, 'int32' ); // $ExpectError - isSafeCast( ( x: number ): number => x, 'int32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a string... -{ - isSafeCast( 'float64', true ); // $ExpectError - isSafeCast( 'float64', false ); // $ExpectError - isSafeCast( 'float64', null ); // $ExpectError - isSafeCast( 'float64', undefined ); // $ExpectError - isSafeCast( 'float64', 123 ); // $ExpectError - isSafeCast( 'float64', [] ); // $ExpectError - isSafeCast( 'float64', {} ); // $ExpectError - isSafeCast( 'float64', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isSafeCast(); // $ExpectError - isSafeCast( 'float64' ); // $ExpectError -} diff --git a/base/assert/is-safe-data-type-cast/examples/index.js b/base/assert/is-safe-data-type-cast/examples/index.js deleted file mode 100644 index 0a4f8f1cc..000000000 --- a/base/assert/is-safe-data-type-cast/examples/index.js +++ /dev/null @@ -1,32 +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. -*/ - -'use strict'; - -var cartesianSquare = require( './../../../../cartesian-square' ); -var dtypes = require( './../../../../dtypes' ); -var isSafeCast = require( './../lib' ); - -// Generate a list of dtype pairs: -var dt = cartesianSquare( dtypes() ); - -// For each data type pair, determine whether one can safely cast from one data type to another... -var i; -for ( i = 0; i < dt.length; i++ ) { - console.log( '%s. Safe? %s.', dt[i].join( ' => ' ), isSafeCast.apply( null, dt[i] ) ); -} diff --git a/base/assert/is-safe-data-type-cast/lib/index.js b/base/assert/is-safe-data-type-cast/lib/index.js deleted file mode 100644 index bd4b98901..000000000 --- a/base/assert/is-safe-data-type-cast/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Determine if an array data type can be safely cast to another array data type. -* -* @module @stdlib/array/base/assert/is-safe-data-type-cast -* -* @example -* var isSafeCast = require( '@stdlib/array/base/assert/is-safe-data-type-cast' ); -* -* var bool = isSafeCast( 'float32', 'float64' ); -* // returns true -* -* bool = isSafeCast( 'float64', 'int32' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-safe-data-type-cast/lib/main.js b/base/assert/is-safe-data-type-cast/lib/main.js deleted file mode 100644 index 6dc63356f..000000000 --- a/base/assert/is-safe-data-type-cast/lib/main.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -// MODULES // - -var safeCasts = require( './../../../../safe-casts' ); - - -// VARIABLES // - -var TABLE = safeCasts(); - - -// MAIN // - -/** -* Returns a boolean indicating if a provided array data type can be safely cast to another array data type. -* -* @param {string} from - array data type -* @param {string} to - array data type -* @returns {boolean} boolean indicating if a data type can be safely cast to another data type -* -* @example -* var bool = isSafeCast( 'float32', 'float64' ); -* // returns true -* -* bool = isSafeCast( 'float64', 'int32' ); -* // returns false -*/ -function isSafeCast( from, to ) { - if ( from === to ) { - return true; - } - return ( TABLE[ from ][ to ] > 0 ); -} - - -// EXPORTS // - -module.exports = isSafeCast; diff --git a/base/assert/is-safe-data-type-cast/package.json b/base/assert/is-safe-data-type-cast/package.json deleted file mode 100644 index b78bbc239..000000000 --- a/base/assert/is-safe-data-type-cast/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-safe-data-type-cast", - "version": "0.0.0", - "description": "Determine if an array data type can be safely cast to another array data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "casting", - "safe", - "cast", - "promotion", - "test", - "assert", - "check", - "validate", - "validation", - "valid", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-safe-data-type-cast/test/test.js b/base/assert/is-safe-data-type-cast/test/test.js deleted file mode 100644 index 20d0d0095..000000000 --- a/base/assert/is-safe-data-type-cast/test/test.js +++ /dev/null @@ -1,59 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( './../../../../dtypes' ); -var safeCasts = require( './../../../../safe-casts' ); -var isSafeCast = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var SAFE_CASTS = safeCasts(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isSafeCast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a boolean indicating if an array data type can be safely cast to another array data type', function test( t ) { - var expected; - var actual; - var dt; - var i; - var j; - - for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - for ( j = 0; j < DTYPES.length; j++ ) { - expected = ( SAFE_CASTS[ dt ][ DTYPES[j] ] > 0 ); - actual = isSafeCast( dt, DTYPES[ j ] ); - t.strictEqual( actual, expected, 'returns expected value. from: '+dt+'. to: '+DTYPES[j]+'.' ); - } - } - t.end(); -}); diff --git a/base/assert/is-same-kind-data-type-cast/README.md b/base/assert/is-same-kind-data-type-cast/README.md deleted file mode 100644 index 286ce5340..000000000 --- a/base/assert/is-same-kind-data-type-cast/README.md +++ /dev/null @@ -1,118 +0,0 @@ - - -# isSameKindCast - -> Determine whether an array [data type][@stdlib/array/dtypes] can be safely cast to, or is of the same "kind" as, another array [data type][@stdlib/array/dtypes]. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isSameKindCast = require( '@stdlib/array/base/assert/is-same-kind-data-type-cast' ); -``` - -#### isSameKindCast( from, to ) - -Returns a `boolean` indicating whether an array [data type][@stdlib/array/dtypes] can be safely cast to, or is of the same "kind" as, another array [data type][@stdlib/array/dtypes] (e.g., casting between signed integers or between floats). - -```javascript -var bool = isSameKindCast( 'float32', 'float64' ); -// returns true - -bool = isSameKindCast( 'uint16', 'int16' ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var cartesianSquare = require( '@stdlib/array/cartesian-square' ); -var dtypes = require( '@stdlib/array/dtypes' ); -var isSameKindCast = require( '@stdlib/array/base/assert/is-same-kind-data-type-cast' ); - -// Generate a list of dtype pairs: -var dt = cartesianSquare( dtypes() ); - -// For each data type pair, determine whether one can cast from one data type to another... -var i; -for ( i = 0; i < dt.length; i++ ) { - console.log( '%s. Allowed cast? %s.', dt[i].join( ' => ' ), isSameKindCast.apply( null, dt[i] ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-same-kind-data-type-cast/benchmark/benchmark.js b/base/assert/is-same-kind-data-type-cast/benchmark/benchmark.js deleted file mode 100644 index 1ad99522c..000000000 --- a/base/assert/is-same-kind-data-type-cast/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var dtypes = require( './../../../../dtypes' ); -var pkg = require( './../package.json' ).name; -var isSameKindCast = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var N; - var i; - var j; - var k; - - N = DTYPES.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % N; - k = (i+1) % N; - out = isSameKindCast( DTYPES[ j ], DTYPES[ k ] ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-same-kind-data-type-cast/docs/repl.txt b/base/assert/is-same-kind-data-type-cast/docs/repl.txt deleted file mode 100644 index f9a044995..000000000 --- a/base/assert/is-same-kind-data-type-cast/docs/repl.txt +++ /dev/null @@ -1,31 +0,0 @@ - -{{alias}}( from, to ) - Returns a boolean indicating whether a provided array data type can be - safely cast to, or is of the same "kind" as, another array data type. - - Parameters - ---------- - from: string - Array data type. - - to: string - Array data type. - - Returns - ------- - bool: boolean - Boolean indicating whether a provided data type can be cast to another - data type. - - Examples - -------- - > var bool = {{alias}}( 'float32', 'float64' ) - true - > bool = {{alias}}( 'uint16', 'int32' ) - true - > bool = {{alias}}( 'uint16', 'int16' ) - false - - See Also - -------- - diff --git a/base/assert/is-same-kind-data-type-cast/docs/types/index.d.ts b/base/assert/is-same-kind-data-type-cast/docs/types/index.d.ts deleted file mode 100644 index fb1574ae8..000000000 --- a/base/assert/is-same-kind-data-type-cast/docs/types/index.d.ts +++ /dev/null @@ -1,40 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a boolean indicating if a provided array data type can be safely cast to, or is of the same "kind" as, another array data type. -* -* @param from - array data type -* @param to - array data type -* @returns boolean indicating if a data type can be cast to another data type -* -* @example -* var bool = isSameKindCast( 'float32', 'float64' ); -* // returns true -* -* bool = isSameKindCast( 'uint16', 'int16' ); -* // returns false -*/ -declare function isSameKindCast( from: string, to: string ): boolean; - - -// EXPORTS // - -export = isSameKindCast; diff --git a/base/assert/is-same-kind-data-type-cast/docs/types/test.ts b/base/assert/is-same-kind-data-type-cast/docs/types/test.ts deleted file mode 100644 index 91facf946..000000000 --- a/base/assert/is-same-kind-data-type-cast/docs/types/test.ts +++ /dev/null @@ -1,58 +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. -*/ - -import isSameKindCast = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isSameKindCast( 'float32', 'float64' ); // $ExpectType boolean - isSameKindCast( 'float64', 'int32' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - isSameKindCast( true, 'int32' ); // $ExpectError - isSameKindCast( false, 'int32' ); // $ExpectError - isSameKindCast( null, 'int32' ); // $ExpectError - isSameKindCast( undefined, 'int32' ); // $ExpectError - isSameKindCast( 123, 'int32' ); // $ExpectError - isSameKindCast( [], 'int32' ); // $ExpectError - isSameKindCast( {}, 'int32' ); // $ExpectError - isSameKindCast( ( x: number ): number => x, 'int32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a string... -{ - isSameKindCast( 'float64', true ); // $ExpectError - isSameKindCast( 'float64', false ); // $ExpectError - isSameKindCast( 'float64', null ); // $ExpectError - isSameKindCast( 'float64', undefined ); // $ExpectError - isSameKindCast( 'float64', 123 ); // $ExpectError - isSameKindCast( 'float64', [] ); // $ExpectError - isSameKindCast( 'float64', {} ); // $ExpectError - isSameKindCast( 'float64', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isSameKindCast(); // $ExpectError - isSameKindCast( 'float64' ); // $ExpectError -} diff --git a/base/assert/is-same-kind-data-type-cast/examples/index.js b/base/assert/is-same-kind-data-type-cast/examples/index.js deleted file mode 100644 index e36b1bc74..000000000 --- a/base/assert/is-same-kind-data-type-cast/examples/index.js +++ /dev/null @@ -1,32 +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. -*/ - -'use strict'; - -var cartesianSquare = require( './../../../../cartesian-square' ); -var dtypes = require( './../../../../dtypes' ); -var isSameKindCast = require( './../lib' ); - -// Generate a list of dtype pairs: -var dt = cartesianSquare( dtypes() ); - -// For each data type pair, determine whether one can cast from one data type to another... -var i; -for ( i = 0; i < dt.length; i++ ) { - console.log( '%s. Allowed cast? %s.', dt[i].join( ' => ' ), isSameKindCast.apply( null, dt[i] ) ); -} diff --git a/base/assert/is-same-kind-data-type-cast/lib/index.js b/base/assert/is-same-kind-data-type-cast/lib/index.js deleted file mode 100644 index 167a98bb2..000000000 --- a/base/assert/is-same-kind-data-type-cast/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Determine if an array data type can be safely cast to, or is of the same "kind" as, another array data type. -* -* @module @stdlib/array/base/assert/is-same-kind-data-type-cast -* -* @example -* var isSameKindCast = require( '@stdlib/array/base/assert/is-same-kind-data-type-cast' ); -* -* var bool = isSameKindCast( 'float32', 'float64' ); -* // returns true -* -* bool = isSameKindCast( 'uint16', 'int16' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-same-kind-data-type-cast/lib/main.js b/base/assert/is-same-kind-data-type-cast/lib/main.js deleted file mode 100644 index c1d3b73da..000000000 --- a/base/assert/is-same-kind-data-type-cast/lib/main.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -// MODULES // - -var sameKindCasts = require( './../../../../same-kind-casts' ); - - -// VARIABLES // - -var TABLE = sameKindCasts(); - - -// MAIN // - -/** -* Returns a boolean indicating if a provided array data type can be safely cast to, or is of the same "kind" as, another array data type. -* -* @param {string} from - array data type -* @param {string} to - array data type -* @returns {boolean} boolean indicating if a data type can be cast to another data type -* -* @example -* var bool = isSameKindCast( 'float32', 'float64' ); -* // returns true -* -* bool = isSameKindCast( 'uint16', 'int16' ); -* // returns false -*/ -function isSameKindCast( from, to ) { - if ( from === to ) { - return true; - } - return ( TABLE[ from ][ to ] > 0 ); -} - - -// EXPORTS // - -module.exports = isSameKindCast; diff --git a/base/assert/is-same-kind-data-type-cast/package.json b/base/assert/is-same-kind-data-type-cast/package.json deleted file mode 100644 index d5b377985..000000000 --- a/base/assert/is-same-kind-data-type-cast/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-same-kind-data-type-cast", - "version": "0.0.0", - "description": "Determine if an array data type can be safely cast to, or is of the same kind as, another array data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "casting", - "safe", - "cast", - "kind", - "promotion", - "test", - "assert", - "check", - "validate", - "validation", - "valid", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-same-kind-data-type-cast/test/test.js b/base/assert/is-same-kind-data-type-cast/test/test.js deleted file mode 100644 index ef31f9a7e..000000000 --- a/base/assert/is-same-kind-data-type-cast/test/test.js +++ /dev/null @@ -1,59 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( './../../../../dtypes' ); -var sameKindCasts = require( './../../../../same-kind-casts' ); -var isSameKindCast = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -var SAME_KIND_CASTS = sameKindCasts(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isSameKindCast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a boolean indicating if an array data type can be cast to another array data type', function test( t ) { - var expected; - var actual; - var dt; - var i; - var j; - - for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - for ( j = 0; j < DTYPES.length; j++ ) { - expected = ( SAME_KIND_CASTS[ dt ][ DTYPES[j] ] > 0 ); - actual = isSameKindCast( dt, DTYPES[ j ] ); - t.strictEqual( actual, expected, 'returns expected value. from: '+dt+'. to: '+DTYPES[j]+'.' ); - } - } - t.end(); -}); diff --git a/base/assert/is-signed-integer-data-type/README.md b/base/assert/is-signed-integer-data-type/README.md deleted file mode 100644 index 2b60ae0ab..000000000 --- a/base/assert/is-signed-integer-data-type/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# isSignedIntegerDataType - -> Test if an input value is a supported array signed integer data type. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isSignedIntegerDataType = require( '@stdlib/array/base/assert/is-signed-integer-data-type' ); -``` - -#### isSignedIntegerDataType( value ) - -Tests if an input `value` is a supported array signed integer data type. - -```javascript -var bool = isSignedIntegerDataType( 'float32' ); -// returns false - -bool = isSignedIntegerDataType( 'int32' ); -// returns true -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var isSignedIntegerDataType = require( '@stdlib/array/base/assert/is-signed-integer-data-type' ); - -var bool = isSignedIntegerDataType( 'float32' ); -// returns false - -bool = isSignedIntegerDataType( 'float64' ); -// returns false - -bool = isSignedIntegerDataType( 'generic' ); -// returns false - -bool = isSignedIntegerDataType( 'int16' ); -// returns true - -bool = isSignedIntegerDataType( 'int32' ); -// returns true - -bool = isSignedIntegerDataType( 'int8' ); -// returns true - -bool = isSignedIntegerDataType( 'uint16' ); -// returns false - -bool = isSignedIntegerDataType( 'uint32' ); -// returns false - -bool = isSignedIntegerDataType( 'uint8' ); -// returns false - -bool = isSignedIntegerDataType( 'uint8c' ); -// returns false - -bool = isSignedIntegerDataType( '' ); -// returns false - -bool = isSignedIntegerDataType( 'foo' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-signed-integer-data-type/benchmark/benchmark.js b/base/assert/is-signed-integer-data-type/benchmark/benchmark.js deleted file mode 100644 index 4daff2aa4..000000000 --- a/base/assert/is-signed-integer-data-type/benchmark/benchmark.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isSignedIntegerDataType = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - 'binary', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'foo', - 'bar', - '', - 'beep', - 'boop' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ]; - out = isSignedIntegerDataType( v ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-signed-integer-data-type/docs/repl.txt b/base/assert/is-signed-integer-data-type/docs/repl.txt deleted file mode 100644 index 34ba617b5..000000000 --- a/base/assert/is-signed-integer-data-type/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( value ) - Tests if an input value is a supported array signed integer data type. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input value is a supported array signed integer - data type. - - Examples - -------- - > var bool = {{alias}}( 'float32' ) - false - > bool = {{alias}}( 'float64' ) - false - > bool = {{alias}}( 'int16' ) - true - > bool = {{alias}}( 'int32' ) - true - > bool = {{alias}}( 'int8' ) - true - > bool = {{alias}}( 'uint16' ) - false - > bool = {{alias}}( 'uint32' ) - false - > bool = {{alias}}( 'uint8' ) - false - > bool = {{alias}}( 'uint8c' ) - false - > bool = {{alias}}( '' ) - false - > bool = {{alias}}( 'beep' ) - false - - See Also - -------- - diff --git a/base/assert/is-signed-integer-data-type/docs/types/index.d.ts b/base/assert/is-signed-integer-data-type/docs/types/index.d.ts deleted file mode 100644 index 96d338c97..000000000 --- a/base/assert/is-signed-integer-data-type/docs/types/index.d.ts +++ /dev/null @@ -1,66 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests whether an input value is a supported array signed integer data type. -* -* @param v - value to test -* @returns boolean indicating whether an input value is a supported array signed integer data type -* -* @example -* var bool = isSignedIntegerDataType( 'float32' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'float64' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'generic' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'int16' ); -* // returns true -* -* bool = isSignedIntegerDataType( 'int32' ); -* // returns true -* -* bool = isSignedIntegerDataType( 'int8' ); -* // returns true -* -* bool = isSignedIntegerDataType( 'uint16' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'uint32' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'uint8' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'uint8c' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'foo' ); -* // returns false -*/ -declare function isSignedIntegerDataType( v: any ): boolean; - - -// EXPORTS // - -export = isSignedIntegerDataType; diff --git a/base/assert/is-signed-integer-data-type/docs/types/test.ts b/base/assert/is-signed-integer-data-type/docs/types/test.ts deleted file mode 100644 index a756c5ab8..000000000 --- a/base/assert/is-signed-integer-data-type/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import isSignedIntegerDataType = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isSignedIntegerDataType( 'int8' ); // $ExpectType boolean - isSignedIntegerDataType( 'foo' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isSignedIntegerDataType(); // $ExpectError - isSignedIntegerDataType( 'int8', 123 ); // $ExpectError -} diff --git a/base/assert/is-signed-integer-data-type/examples/index.js b/base/assert/is-signed-integer-data-type/examples/index.js deleted file mode 100644 index e8ddae75e..000000000 --- a/base/assert/is-signed-integer-data-type/examples/index.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -var isSignedIntegerDataType = require( './../lib' ); - -var bool = isSignedIntegerDataType( 'float32' ); -console.log( bool ); -// => false - -bool = isSignedIntegerDataType( 'float64' ); -console.log( bool ); -// => false - -bool = isSignedIntegerDataType( 'generic' ); -console.log( bool ); -// => false - -bool = isSignedIntegerDataType( 'int16' ); -console.log( bool ); -// => true - -bool = isSignedIntegerDataType( 'int32' ); -console.log( bool ); -// => true - -bool = isSignedIntegerDataType( 'int8' ); -console.log( bool ); -// => true - -bool = isSignedIntegerDataType( 'uint16' ); -console.log( bool ); -// => false - -bool = isSignedIntegerDataType( 'uint32' ); -console.log( bool ); -// => false - -bool = isSignedIntegerDataType( 'uint8' ); -console.log( bool ); -// => false - -bool = isSignedIntegerDataType( 'uint8c' ); -console.log( bool ); -// => false - -bool = isSignedIntegerDataType( '' ); -console.log( bool ); -// => false - -bool = isSignedIntegerDataType( 'foo' ); -console.log( bool ); -// => false diff --git a/base/assert/is-signed-integer-data-type/lib/index.js b/base/assert/is-signed-integer-data-type/lib/index.js deleted file mode 100644 index d644606b8..000000000 --- a/base/assert/is-signed-integer-data-type/lib/index.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -/** -* Test whether an input value is a supported array signed integer data type. -* -* @module @stdlib/array/base/assert/is-signed-integer-data-type -* -* @example -* var isSignedIntegerDataType = require( '@stdlib/array/base/assert/is-signed-integer-data-type' ); -* -* var bool = isSignedIntegerDataType( 'float32' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'float64' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'generic' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'int16' ); -* // returns true -* -* bool = isSignedIntegerDataType( 'int32' ); -* // returns true -* -* bool = isSignedIntegerDataType( 'int8' ); -* // returns true -* -* bool = isSignedIntegerDataType( 'uint16' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'uint32' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'uint8' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'uint8c' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'foo' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-signed-integer-data-type/lib/main.js b/base/assert/is-signed-integer-data-type/lib/main.js deleted file mode 100644 index 5b6d558a3..000000000 --- a/base/assert/is-signed-integer-data-type/lib/main.js +++ /dev/null @@ -1,76 +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. -*/ - -'use strict'; - -// MODULES // - -var contains = require( './../../../../base/assert/contains' ).factory; -var dtypes = require( './../../../../dtypes' ); - - -// MAIN // - -/** -* Tests whether an input value is a supported array signed integer data type. -* -* @name isSignedIntegerDataType -* @type {Function} -* @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported array signed integer data type -* -* @example -* var bool = isSignedIntegerDataType( 'float32' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'float64' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'generic' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'int16' ); -* // returns true -* -* bool = isSignedIntegerDataType( 'int32' ); -* // returns true -* -* bool = isSignedIntegerDataType( 'int8' ); -* // returns true -* -* bool = isSignedIntegerDataType( 'uint16' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'uint32' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'uint8' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'uint8c' ); -* // returns false -* -* bool = isSignedIntegerDataType( 'foo' ); -* // returns false -*/ -var isSignedIntegerDataType = contains( dtypes( 'signed_integer' ) ); - - -// EXPORTS // - -module.exports = isSignedIntegerDataType; diff --git a/base/assert/is-signed-integer-data-type/package.json b/base/assert/is-signed-integer-data-type/package.json deleted file mode 100644 index 5587876ad..000000000 --- a/base/assert/is-signed-integer-data-type/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-signed-integer-data-type", - "version": "0.0.0", - "description": "Test if an input value is a supported array signed integer data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "dtype", - "data", - "utilities", - "utility", - "utils", - "util", - "assert", - "test", - "check", - "is", - "valid", - "validate", - "validation", - "isvalid" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-signed-integer-data-type/test/test.js b/base/assert/is-signed-integer-data-type/test/test.js deleted file mode 100644 index 03f219579..000000000 --- a/base/assert/is-signed-integer-data-type/test/test.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isSignedIntegerDataType = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isSignedIntegerDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a supported array signed integer data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'int16', - 'int32', - 'int8' - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isSignedIntegerDataType( values[ i ] ); - t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a supported array signed integer data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - // Supported dtypes: - 'complex64', - 'complex128', - 'float32', - 'float64', - 'generic', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - - // Unsupported dtypes: - 'float', - 'int', - 'bin', - '', - 'beep', - 'boop', - 'foo', - 'bar', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isSignedIntegerDataType( values[ i ] ); - t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/base/assert/is-sorted-ascending/README.md b/base/assert/is-sorted-ascending/README.md deleted file mode 100644 index 797c484f8..000000000 --- a/base/assert/is-sorted-ascending/README.md +++ /dev/null @@ -1,133 +0,0 @@ - - -# isSortedAscending - -> Test if an array is sorted in ascending order. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isSortedAscending = require( '@stdlib/array/base/assert/is-sorted-ascending' ); -``` - -#### isSortedAscending( x ) - -Tests if an array is sorted in ascending order. - -```javascript -var out = isSortedAscending( [ 1, 2, 3 ] ); -// returns true - -out = isSortedAscending( [ 3, 2, 1 ] ); -// returns false -``` - -If provided an empty array, the function returns `false`. - -```javascript -var out = isSortedAscending( [] ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var AccessorArray = require( '@stdlib/array/base/accessor' ); -var isSortedAscending = require( '@stdlib/array/base/assert/is-sorted-ascending' ); - -var x = new AccessorArray( [ 1, 2, 3, 4 ] ); -var bool = isSortedAscending( x ); -// returns true - -x = new AccessorArray( [ 1, 1, 1, 1 ] ); -bool = isSortedAscending( x ); -// returns true - -x = new AccessorArray( [ 1 ] ); -bool = isSortedAscending( x ); -// returns true - -x = new AccessorArray( [ 1, 3, 2, 4 ] ); -bool = isSortedAscending( x ); -// returns false - -x = new AccessorArray( [ 4, 3, 2, 1 ] ); -bool = isSortedAscending( x ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-sorted-ascending/benchmark/benchmark.accessors.length.js b/base/assert/is-sorted-ascending/benchmark/benchmark.accessors.length.js deleted file mode 100644 index 62570af94..000000000 --- a/base/assert/is-sorted-ascending/benchmark/benchmark.accessors.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var zeroTo = require( './../../../../base/zero-to' ); -var AccessorArray = require( './../../../../base/accessor' ); -var pkg = require( './../package.json' ).name; -var isSortedAscending = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = new AccessorArray( zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = isSortedAscending( x ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+'::accessors:len='+len, f ); - } -} - -main(); diff --git a/base/assert/is-sorted-ascending/benchmark/benchmark.length.js b/base/assert/is-sorted-ascending/benchmark/benchmark.length.js deleted file mode 100644 index 0b64609af..000000000 --- a/base/assert/is-sorted-ascending/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var zeroTo = require( './../../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var isSortedAscending = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = isSortedAscending( x ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/assert/is-sorted-ascending/docs/repl.txt b/base/assert/is-sorted-ascending/docs/repl.txt deleted file mode 100644 index 4a0363b93..000000000 --- a/base/assert/is-sorted-ascending/docs/repl.txt +++ /dev/null @@ -1,26 +0,0 @@ - -{{alias}}( x ) - Tests if an array is sorted in ascending order. - - The function returns `false` if provided an empty array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: boolean - Boolean indicating if an array is sorted in ascending order. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3 ] ) - true - > out = {{alias}}( [ 3, 2, 1 ] ) - false - - See Also - -------- - diff --git a/base/assert/is-sorted-ascending/docs/types/index.d.ts b/base/assert/is-sorted-ascending/docs/types/index.d.ts deleted file mode 100644 index f5bcfeadf..000000000 --- a/base/assert/is-sorted-ascending/docs/types/index.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Tests if an array is sorted in ascending order. -* -* @param x - input array -* @returns boolean indicating if an array is sorted in ascending order -* -* @example -* var out = isSortedAscending( [ 1, 2, 3 ] ); -* // returns true -* -* @example -* var out = isSortedAscending( [ 3, 2, 1 ] ); -* // returns false -* -* @example -* var out = isSortedAscending( [ 3, 3, 3 ] ); -* // returns true -* -* @example -* var out = isSortedAscending( [ 3 ] ); -* // returns true -* -* @example -* var out = isSortedAscending( [] ); -* // returns false -* -* @example -* var out = isSortedAscending( [ 1, 3, 2 ] ); -* // returns false -*/ -declare function isSortedAscending( x: Collection | AccessorArrayLike ): boolean; - - -// EXPORTS // - -export = isSortedAscending; diff --git a/base/assert/is-sorted-ascending/docs/types/test.ts b/base/assert/is-sorted-ascending/docs/types/test.ts deleted file mode 100644 index 65843227b..000000000 --- a/base/assert/is-sorted-ascending/docs/types/test.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isSortedAscending = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isSortedAscending( [ 1, 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - isSortedAscending( 5 ); // $ExpectError - isSortedAscending( true ); // $ExpectError - isSortedAscending( false ); // $ExpectError - isSortedAscending( null ); // $ExpectError - isSortedAscending( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isSortedAscending(); // $ExpectError - isSortedAscending( [ 1, 2, 3 ], {} ); // $ExpectError -} diff --git a/base/assert/is-sorted-ascending/examples/index.js b/base/assert/is-sorted-ascending/examples/index.js deleted file mode 100644 index 2dbf690eb..000000000 --- a/base/assert/is-sorted-ascending/examples/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var AccessorArray = require( './../../../../base/accessor' ); -var isSortedAscending = require( './../lib' ); - -var x = new AccessorArray( [ 1, 2, 3, 4 ] ); -var bool = isSortedAscending( x ); -console.log( bool ); -// => true - -x = new AccessorArray( [ 1, 1, 1, 1 ] ); -bool = isSortedAscending( x ); -console.log( bool ); -// => true - -x = new AccessorArray( [ 1 ] ); -bool = isSortedAscending( x ); -console.log( bool ); -// => true - -x = new AccessorArray( [ 1, 3, 2, 4 ] ); -bool = isSortedAscending( x ); -console.log( bool ); -// => false - -x = new AccessorArray( [ 4, 3, 2, 1 ] ); -bool = isSortedAscending( x ); -console.log( bool ); -// => false diff --git a/base/assert/is-sorted-ascending/lib/index.js b/base/assert/is-sorted-ascending/lib/index.js deleted file mode 100644 index e1b44b005..000000000 --- a/base/assert/is-sorted-ascending/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if an array is sorted in ascending order. -* -* @module @stdlib/array/base/assert/is-sorted-ascending -* -* @example -* var isSortedAscending = require( '@stdlib/array/base/assert/is-sorted-ascending' ); -* -* var out = isSortedAscending( [ 1, 2, 3 ] ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-sorted-ascending/lib/main.js b/base/assert/is-sorted-ascending/lib/main.js deleted file mode 100644 index 1c7c9b189..000000000 --- a/base/assert/is-sorted-ascending/lib/main.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( './../../../../base/assert/is-accessor-array' ); -var accessorGetter = require( './../../../../base/accessor-getter' ); -var getter = require( './../../../../base/getter' ); -var dtype = require( './../../../../dtype' ); - - -// MAIN // - -/** -* Tests if an array is sorted in ascending order. -* -* @param {Collection} x - input array -* @returns {boolean} boolean indicating if an array is sorted in ascending order -* -* @example -* var out = isSortedAscending( [ 1, 2, 3 ] ); -* // returns true -* -* @example -* var out = isSortedAscending( [ 3, 2, 1 ] ); -* // returns false -* -* @example -* var out = isSortedAscending( [ 3, 3, 3 ] ); -* // returns true -* -* @example -* var out = isSortedAscending( [ 3 ] ); -* // returns true -* -* @example -* var out = isSortedAscending( [] ); -* // returns false -* -* @example -* var out = isSortedAscending( [ 1, 3, 2 ] ); -* // returns false -*/ -function isSortedAscending( x ) { - var len; - var get; - var dt; - var v1; - var v2; - var i; - - // Resolve the input array data type: - dt = dtype( x ); - - // Resolve an accessor for retrieving input array elements: - if ( isAccessorArray( x ) ) { - get = accessorGetter( dt ); - } else { - get = getter( dt ); - } - // Get the number of elements over which to iterate: - len = x.length; - - // Check for an empty array: - if ( len === 0 ) { - return false; - } - // Loop over the elements... - v1 = get( x, 0 ); - for ( i = 1; i < len; i++ ) { - v2 = get( x, i ); - if ( v1 > v2 ) { - return false; - } - v1 = v2; - } - return true; -} - - -// EXPORTS // - -module.exports = isSortedAscending; diff --git a/base/assert/is-sorted-ascending/package.json b/base/assert/is-sorted-ascending/package.json deleted file mode 100644 index 7fe5f635b..000000000 --- a/base/assert/is-sorted-ascending/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-sorted-ascending", - "version": "0.0.0", - "description": "Test if an array is sorted in ascending order.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "sorted", - "ascending", - "ordered", - "assert" - ] -} diff --git a/base/assert/is-sorted-ascending/test/test.js b/base/assert/is-sorted-ascending/test/test.js deleted file mode 100644 index d5f169b8e..000000000 --- a/base/assert/is-sorted-ascending/test/test.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../../base/accessor' ); -var isSortedAscending = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isSortedAscending, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function tests whether an array is sorted in ascending order', function test( t ) { - var actual; - var x; - - x = [ 1, 2, 3 ]; - actual = isSortedAscending( x ); - t.strictEqual( actual, true, 'returns expected value' ); - - x = [ 1, 1, 1 ]; - actual = isSortedAscending( x ); - t.strictEqual( actual, true, 'returns expected value' ); - - x = [ 1 ]; - actual = isSortedAscending( x ); - t.strictEqual( actual, true, 'returns expected value' ); - - x = [ 3, 2, 1 ]; - actual = isSortedAscending( x ); - t.strictEqual( actual, false, 'returns expected value' ); - - x = []; - actual = isSortedAscending( x ); - t.strictEqual( actual, false, 'returns expected value' ); - - x = [ 2, 1, 3 ]; - actual = isSortedAscending( x ); - t.strictEqual( actual, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function tests whether an array is sorted in ascending order (accessors)', function test( t ) { - var actual; - var x; - - x = new AccessorArray( [ 1, 2, 3 ] ); - actual = isSortedAscending( x ); - t.strictEqual( actual, true, 'returns expected value' ); - - x = new AccessorArray( [ 1, 1, 1 ] ); - actual = isSortedAscending( x ); - t.strictEqual( actual, true, 'returns expected value' ); - - x = new AccessorArray( [ 1 ] ); - actual = isSortedAscending( x ); - t.strictEqual( actual, true, 'returns expected value' ); - - x = new AccessorArray( [ 3, 2, 1 ] ); - actual = isSortedAscending( x ); - t.strictEqual( actual, false, 'returns expected value' ); - - x = new AccessorArray( [] ); - actual = isSortedAscending( x ); - t.strictEqual( actual, false, 'returns expected value' ); - - x = new AccessorArray( [ 2, 1, 3 ] ); - actual = isSortedAscending( x ); - t.strictEqual( actual, false, 'returns expected value' ); - - t.end(); -}); diff --git a/base/assert/is-unsigned-integer-data-type/README.md b/base/assert/is-unsigned-integer-data-type/README.md deleted file mode 100644 index 5036775c3..000000000 --- a/base/assert/is-unsigned-integer-data-type/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# isUnsignedIntegerDataType - -> Test if an input value is a supported array unsigned integer data type. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var isUnsignedIntegerDataType = require( '@stdlib/array/base/assert/is-unsigned-integer-data-type' ); -``` - -#### isUnsignedIntegerDataType( value ) - -Tests if an input `value` is a supported array unsigned integer data type. - -```javascript -var bool = isUnsignedIntegerDataType( 'float32' ); -// returns false - -bool = isUnsignedIntegerDataType( 'uint32' ); -// returns true -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var isUnsignedIntegerDataType = require( '@stdlib/array/base/assert/is-unsigned-integer-data-type' ); - -var bool = isUnsignedIntegerDataType( 'float32' ); -// returns false - -bool = isUnsignedIntegerDataType( 'float64' ); -// returns false - -bool = isUnsignedIntegerDataType( 'generic' ); -// returns false - -bool = isUnsignedIntegerDataType( 'int16' ); -// returns false - -bool = isUnsignedIntegerDataType( 'int32' ); -// returns false - -bool = isUnsignedIntegerDataType( 'int8' ); -// returns false - -bool = isUnsignedIntegerDataType( 'uint16' ); -// returns true - -bool = isUnsignedIntegerDataType( 'uint32' ); -// returns true - -bool = isUnsignedIntegerDataType( 'uint8' ); -// returns true - -bool = isUnsignedIntegerDataType( 'uint8c' ); -// returns true - -bool = isUnsignedIntegerDataType( '' ); -// returns false - -bool = isUnsignedIntegerDataType( 'foo' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/assert/is-unsigned-integer-data-type/benchmark/benchmark.js b/base/assert/is-unsigned-integer-data-type/benchmark/benchmark.js deleted file mode 100644 index 100660c09..000000000 --- a/base/assert/is-unsigned-integer-data-type/benchmark/benchmark.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnsignedIntegerDataType = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - 'binary', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'foo', - 'bar', - '', - 'beep', - 'boop' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ]; - out = isUnsignedIntegerDataType( v ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/assert/is-unsigned-integer-data-type/docs/repl.txt b/base/assert/is-unsigned-integer-data-type/docs/repl.txt deleted file mode 100644 index 07ab71ab9..000000000 --- a/base/assert/is-unsigned-integer-data-type/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( value ) - Tests if an input value is a supported array unsigned integer data type. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input value is a supported array unsigned - integer data type. - - Examples - -------- - > var bool = {{alias}}( 'float32' ) - false - > bool = {{alias}}( 'float64' ) - false - > bool = {{alias}}( 'int16' ) - false - > bool = {{alias}}( 'int32' ) - false - > bool = {{alias}}( 'int8' ) - false - > bool = {{alias}}( 'uint16' ) - true - > bool = {{alias}}( 'uint32' ) - true - > bool = {{alias}}( 'uint8' ) - true - > bool = {{alias}}( 'uint8c' ) - true - > bool = {{alias}}( '' ) - false - > bool = {{alias}}( 'beep' ) - false - - See Also - -------- - diff --git a/base/assert/is-unsigned-integer-data-type/docs/types/index.d.ts b/base/assert/is-unsigned-integer-data-type/docs/types/index.d.ts deleted file mode 100644 index 806dbcdaa..000000000 --- a/base/assert/is-unsigned-integer-data-type/docs/types/index.d.ts +++ /dev/null @@ -1,66 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests whether an input value is a supported array unsigned integer data type. -* -* @param v - value to test -* @returns boolean indicating whether an input value is a supported array unsigned integer data type -* -* @example -* var bool = isUnsignedIntegerDataType( 'float32' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'float64' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'generic' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'int16' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'int32' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'int8' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'uint16' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'uint32' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'uint8' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'uint8c' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'foo' ); -* // returns false -*/ -declare function isUnsignedIntegerDataType( v: any ): boolean; - - -// EXPORTS // - -export = isUnsignedIntegerDataType; diff --git a/base/assert/is-unsigned-integer-data-type/docs/types/test.ts b/base/assert/is-unsigned-integer-data-type/docs/types/test.ts deleted file mode 100644 index 034c68d17..000000000 --- a/base/assert/is-unsigned-integer-data-type/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import isUnsignedIntegerDataType = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnsignedIntegerDataType( 'uint32' ); // $ExpectType boolean - isUnsignedIntegerDataType( 'foo' ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnsignedIntegerDataType(); // $ExpectError - isUnsignedIntegerDataType( 'uint32', 123 ); // $ExpectError -} diff --git a/base/assert/is-unsigned-integer-data-type/examples/index.js b/base/assert/is-unsigned-integer-data-type/examples/index.js deleted file mode 100644 index 4ea5ea6f4..000000000 --- a/base/assert/is-unsigned-integer-data-type/examples/index.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -var isUnsignedIntegerDataType = require( './../lib' ); - -var bool = isUnsignedIntegerDataType( 'float32' ); -console.log( bool ); -// => false - -bool = isUnsignedIntegerDataType( 'float64' ); -console.log( bool ); -// => false - -bool = isUnsignedIntegerDataType( 'generic' ); -console.log( bool ); -// => false - -bool = isUnsignedIntegerDataType( 'int16' ); -console.log( bool ); -// => false - -bool = isUnsignedIntegerDataType( 'int32' ); -console.log( bool ); -// => false - -bool = isUnsignedIntegerDataType( 'int8' ); -console.log( bool ); -// => false - -bool = isUnsignedIntegerDataType( 'uint16' ); -console.log( bool ); -// => true - -bool = isUnsignedIntegerDataType( 'uint32' ); -console.log( bool ); -// => true - -bool = isUnsignedIntegerDataType( 'uint8' ); -console.log( bool ); -// => true - -bool = isUnsignedIntegerDataType( 'uint8c' ); -console.log( bool ); -// => true - -bool = isUnsignedIntegerDataType( '' ); -console.log( bool ); -// => false - -bool = isUnsignedIntegerDataType( 'foo' ); -console.log( bool ); -// => false diff --git a/base/assert/is-unsigned-integer-data-type/lib/index.js b/base/assert/is-unsigned-integer-data-type/lib/index.js deleted file mode 100644 index 1da558bc6..000000000 --- a/base/assert/is-unsigned-integer-data-type/lib/index.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -/** -* Test whether an input value is a supported array unsigned integer data type. -* -* @module @stdlib/array/base/assert/is-unsigned-integer-data-type -* -* @example -* var isUnsignedIntegerDataType = require( '@stdlib/array/base/assert/is-unsigned-integer-data-type' ); -* -* var bool = isUnsignedIntegerDataType( 'float32' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'float64' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'generic' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'int16' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'int32' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'int8' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'uint16' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'uint32' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'uint8' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'uint8c' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'foo' ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/assert/is-unsigned-integer-data-type/lib/main.js b/base/assert/is-unsigned-integer-data-type/lib/main.js deleted file mode 100644 index b35ce9f5c..000000000 --- a/base/assert/is-unsigned-integer-data-type/lib/main.js +++ /dev/null @@ -1,76 +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. -*/ - -'use strict'; - -// MODULES // - -var contains = require( './../../../../base/assert/contains' ).factory; -var dtypes = require( './../../../../dtypes' ); - - -// MAIN // - -/** -* Tests whether an input value is a supported array unsigned integer data type. -* -* @name isUnsignedIntegerDataType -* @type {Function} -* @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported array unsigned integer data type -* -* @example -* var bool = isUnsignedIntegerDataType( 'float32' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'float64' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'generic' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'int16' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'int32' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'int8' ); -* // returns false -* -* bool = isUnsignedIntegerDataType( 'uint16' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'uint32' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'uint8' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'uint8c' ); -* // returns true -* -* bool = isUnsignedIntegerDataType( 'foo' ); -* // returns false -*/ -var isUnsignedIntegerDataType = contains( dtypes( 'unsigned_integer' ) ); - - -// EXPORTS // - -module.exports = isUnsignedIntegerDataType; diff --git a/base/assert/is-unsigned-integer-data-type/package.json b/base/assert/is-unsigned-integer-data-type/package.json deleted file mode 100644 index c585eb108..000000000 --- a/base/assert/is-unsigned-integer-data-type/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/assert/is-unsigned-integer-data-type", - "version": "0.0.0", - "description": "Test if an input value is a supported array unsigned integer data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "base", - "array", - "dtype", - "data", - "utilities", - "utility", - "utils", - "util", - "assert", - "test", - "check", - "is", - "valid", - "validate", - "validation", - "isvalid" - ], - "__stdlib__": {} -} diff --git a/base/assert/is-unsigned-integer-data-type/test/test.js b/base/assert/is-unsigned-integer-data-type/test/test.js deleted file mode 100644 index 2d37fd4be..000000000 --- a/base/assert/is-unsigned-integer-data-type/test/test.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isUnsignedIntegerDataType = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnsignedIntegerDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided a supported array unsigned integer data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isUnsignedIntegerDataType( values[ i ] ); - t.strictEqual( bool, true, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); - -tape( 'the function returns `false` if not provided a supported array unsigned integer data type', function test( t ) { - var values; - var bool; - var i; - - values = [ - // Supported dtypes: - 'complex64', - 'complex128', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - - // Unsupported dtypes: - 'float', - 'int', - 'bin', - '', - 'beep', - 'boop', - 'foo', - 'bar', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - bool = isUnsignedIntegerDataType( values[ i ] ); - t.strictEqual( bool, false, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/base/assert/lib/index.js b/base/assert/lib/index.js deleted file mode 100644 index 0da6e0a07..000000000 --- a/base/assert/lib/index.js +++ /dev/null @@ -1,267 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name contains -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/contains} -*/ -setReadOnly( ns, 'contains', require( './../../../base/assert/contains' ) ); - -/** -* @name hasAlmostEqualValues -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/has-almost-equal-values} -*/ -setReadOnly( ns, 'hasAlmostEqualValues', require( './../../../base/assert/has-almost-equal-values' ) ); - -/** -* @name hasEqualValues -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/has-equal-values} -*/ -setReadOnly( ns, 'hasEqualValues', require( './../../../base/assert/has-equal-values' ) ); - -/** -* @name hasEqualValuesIndexed -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/has-equal-values-indexed} -*/ -setReadOnly( ns, 'hasEqualValuesIndexed', require( './../../../base/assert/has-equal-values-indexed' ) ); - -/** -* @name hasSameValues -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/has-same-values} -*/ -setReadOnly( ns, 'hasSameValues', require( './../../../base/assert/has-same-values' ) ); - -/** -* @name isAccessorArray -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-accessor-array} -*/ -setReadOnly( ns, 'isAccessorArray', require( './../../../base/assert/is-accessor-array' ) ); - -/** -* @name isBooleanDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-boolean-data-type} -*/ -setReadOnly( ns, 'isBooleanDataType', require( './../../../base/assert/is-boolean-data-type' ) ); - -/** -* @name isBooleanArray -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-booleanarray} -*/ -setReadOnly( ns, 'isBooleanArray', require( './../../../base/assert/is-booleanarray' ) ); - -/** -* @name isByteOrder -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-byte-order} -*/ -setReadOnly( ns, 'isByteOrder', require( './../../../base/assert/is-byte-order' ) ); - -/** -* @name isComplexFloatingPointDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-complex-floating-point-data-type} -*/ -setReadOnly( ns, 'isComplexFloatingPointDataType', require( './../../../base/assert/is-complex-floating-point-data-type' ) ); - -/** -* @name isComplexTypedArray -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-complex-typed-array} -*/ -setReadOnly( ns, 'isComplexTypedArray', require( './../../../base/assert/is-complex-typed-array' ) ); - -/** -* @name isComplex64Array -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-complex64array} -*/ -setReadOnly( ns, 'isComplex64Array', require( './../../../base/assert/is-complex64array' ) ); - -/** -* @name isComplex128Array -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-complex128array} -*/ -setReadOnly( ns, 'isComplex128Array', require( './../../../base/assert/is-complex128array' ) ); - -/** -* @name isDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-data-type} -*/ -setReadOnly( ns, 'isDataType', require( './../../../base/assert/is-data-type' ) ); - -/** -* @name isFloatingPointDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-floating-point-data-type} -*/ -setReadOnly( ns, 'isFloatingPointDataType', require( './../../../base/assert/is-floating-point-data-type' ) ); - -/** -* @name isIntegerDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-integer-data-type} -*/ -setReadOnly( ns, 'isIntegerDataType', require( './../../../base/assert/is-integer-data-type' ) ); - -/** -* @name isMostlySafeDataTypeCast -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-mostly-safe-data-type-cast} -*/ -setReadOnly( ns, 'isMostlySafeDataTypeCast', require( './../../../base/assert/is-mostly-safe-data-type-cast' ) ); - -/** -* @name isNumericDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-numeric-data-type} -*/ -setReadOnly( ns, 'isNumericDataType', require( './../../../base/assert/is-numeric-data-type' ) ); - -/** -* @name isRealDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-real-data-type} -*/ -setReadOnly( ns, 'isRealDataType', require( './../../../base/assert/is-real-data-type' ) ); - -/** -* @name isRealFloatingPointDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-real-floating-point-data-type} -*/ -setReadOnly( ns, 'isRealFloatingPointDataType', require( './../../../base/assert/is-real-floating-point-data-type' ) ); - -/** -* @name isSafeDataTypeCast -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-safe-data-type-cast} -*/ -setReadOnly( ns, 'isSafeDataTypeCast', require( './../../../base/assert/is-safe-data-type-cast' ) ); - -/** -* @name isSameKindDataTypeCast -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-same-kind-data-type-cast} -*/ -setReadOnly( ns, 'isSameKindDataTypeCast', require( './../../../base/assert/is-same-kind-data-type-cast' ) ); - -/** -* @name isSignedIntegerDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-signed-integer-data-type} -*/ -setReadOnly( ns, 'isSignedIntegerDataType', require( './../../../base/assert/is-signed-integer-data-type' ) ); - -/** -* @name isSortedAscending -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-sorted-ascending} -*/ -setReadOnly( ns, 'isSortedAscending', require( './../../../base/assert/is-sorted-ascending' ) ); - -/** -* @name isUnsignedIntegerDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/assert/is-unsigned-integer-data-type} -*/ -setReadOnly( ns, 'isUnsignedIntegerDataType', require( './../../../base/assert/is-unsigned-integer-data-type' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/base/assert/package.json b/base/assert/package.json deleted file mode 100644 index 9fd6f14b0..000000000 --- a/base/assert/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "@stdlib/array/base/assert", - "version": "0.0.0", - "description": "Base array assertion utilities.", - "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/index.js", - "directories": { - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "assert", - "validate", - "test", - "verify", - "check", - "assertion" - ] -} diff --git a/base/assert/test/test.js b/base/assert/test/test.js deleted file mode 100644 index 9931b3a86..000000000 --- a/base/assert/test/test.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/base/at/README.md b/base/at/README.md deleted file mode 100644 index 6ebfe30c6..000000000 --- a/base/at/README.md +++ /dev/null @@ -1,142 +0,0 @@ - - -# at - -> Return an element from an array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var at = require( '@stdlib/array/base/at' ); -``` - -#### at( x, index ) - -Returns an element from an array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = at( x, 0 ); -// returns 1 - -out = at( x, 1 ); -// returns 2 - -out = at( x, -2 ); -// returns 3 -``` - -The function accepts the following arguments: - -- **x**: an input array. -- **index**: element index. - -
- - - - - -
- -## Notes - -- If provided an array-like object having an `at` method, the function defers execution to that method and assumes that the method has the following signature: - - ```text - x.at( index ) - ``` - - If provided an array-like object without an `at` method, the function normalizes a provided index and returns a specified element. - -- Negative indices are resolved relative to the last array element, with the last element corresponding to `-1`. - -- If provided out-of-bounds indices, the function always returns `undefined`. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var at = require( '@stdlib/array/base/at' ); - -// Define an array: -var x = discreteUniform( 10, -100, 100 ); - -// Define an array containing random index values: -var indices = discreteUniform( 100, -x.length, x.length-1 ); - -// Randomly selected values from the input array: -var i; -for ( i = 0; i < indices.length; i++ ) { - console.log( 'x[%d] = %d', indices[ i ], at( x, indices[ i ] ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/at/benchmark/benchmark.js b/base/at/benchmark/benchmark.js deleted file mode 100644 index 5fabb3124..000000000 --- a/base/at/benchmark/benchmark.js +++ /dev/null @@ -1,54 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/array/uniform' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pkg = require( './../package.json' ).name; -var at = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var v; - var i; - var j; - - x = uniform( 100, 0.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = ( i%20 ) - 10; - v = at( x, j ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/at/docs/repl.txt b/base/at/docs/repl.txt deleted file mode 100644 index 192b76511..000000000 --- a/base/at/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( x, index ) - Returns an element from an array. - - Negative indices are resolved relative to the last array element, with the - last element corresponding to `-1`. - - If provided an array-like object having an `at` method , the function defers - execution to that method and assumes that the method has the following - signature: - - x.at( index ) - - If provided an array-like object without an `at` method, the function - normalizes a provided index and returns a specified element. - - If provided an out-of-bounds index, the function always returns `undefined`. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - index: integer - Element index. - - Returns - ------- - out: any - Element value. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > {{alias}}( x, 0 ) - 1 - > {{alias}}( x, -2 ) - 3 - - See Also - -------- - diff --git a/base/at/docs/types/index.d.ts b/base/at/docs/types/index.d.ts deleted file mode 100644 index f75f402eb..000000000 --- a/base/at/docs/types/index.d.ts +++ /dev/null @@ -1,112 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Complex128, Complex64 } from '@stdlib/types/complex'; -import { Collection, AccessorArrayLike, Complex128Array, Complex64Array } from '@stdlib/types/array'; - -/** -* Returns an element from an array. -* -* @param x - input array -* @param index - element index -* @returns array element -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var v = at( x, 0 ); -* // returns -* -* v = at( x, 1 ); -* // returns -* -* v = at( x, -2 ); -* // returns -* -* var re = real( v ); -* // returns 5.0 -* -* var im = imag( v ); -* // returns 6.0 -*/ -declare function at( x: Complex128Array, index: number ): Complex128 | void; - -/** -* Returns an element from an array. -* -* @param x - input array -* @param index - element index -* @returns array element -* -* @example -* var Complex128Array = require( '@stdlib/array/complex64' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var v = at( x, 0 ); -* // returns -* -* v = at( x, 1 ); -* // returns -* -* v = at( x, -2 ); -* // returns -* -* var re = realf( v ); -* // returns 5.0 -* -* var im = imagf( v ); -* // returns 6.0 -*/ -declare function at( x: Complex64Array, index: number ): Complex64 | void; - -/** -* Returns an element from an array. -* -* @param x - input array -* @param index - element index -* @returns array element -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var v = at( x, 0 ); -* // returns 1 -* -* v = at( x, 1 ); -* // returns 2 -* -* v = at( x, -2 ); -* // returns 3 -*/ -declare function at( x: Collection | AccessorArrayLike, index: number ): T | void; - - -// EXPORTS // - -export = at; diff --git a/base/at/docs/types/test.ts b/base/at/docs/types/test.ts deleted file mode 100644 index aec661ba4..000000000 --- a/base/at/docs/types/test.ts +++ /dev/null @@ -1,77 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import at = require( './index' ); - - -// TESTS // - -// The function returns an array element... -{ - at( [ 1, 2, 3, 4 ], 0 ); // $ExpectType number | void - at( new Float64Array( 5 ), 0 ); // $ExpectType number | void - at( new Float32Array( 5 ), 0 ); // $ExpectType number | void - at( new Int32Array( 5 ), 0 ); // $ExpectType number | void - at( new Int16Array( 5 ), 0 ); // $ExpectType number | void - at( new Int8Array( 5 ), 0 ); // $ExpectType number | void - at( new Uint32Array( 5 ), 0 ); // $ExpectType number | void - at( new Uint16Array( 5 ), 0 ); // $ExpectType number | void - at( new Uint8Array( 5 ), 0 ); // $ExpectType number | void - at( new Uint8ClampedArray( 5 ), 0 ); // $ExpectType number | void - at( new Complex128Array( 5 ), 0 ); // $ExpectType void | Complex128 - at( new Complex64Array( 5 ), 0 ); // $ExpectType void | Complex64 - at( toAccessorArray( [ 1, 2, 3, 4 ] ), 0 ); // $ExpectType number | void -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - at( 5, 0 ); // $ExpectError - at( true, 0 ); // $ExpectError - at( false, 0 ); // $ExpectError - at( null, 0 ); // $ExpectError - at( void 0, 0 ); // $ExpectError - at( {}, 0 ); // $ExpectError - at( ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ 1, 2, 3, 4 ]; - - at( x, 'abc' ); // $ExpectError - at( x, true ); // $ExpectError - at( x, false ); // $ExpectError - at( x, null ); // $ExpectError - at( x, void 0 ); // $ExpectError - at( x, [ '1' ] ); // $ExpectError - at( x, {} ); // $ExpectError - at( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4 ]; - - at(); // $ExpectError - at( x ); // $ExpectError - at( x ); // $ExpectError - at( x, 0, 0 ); // $ExpectError -} diff --git a/base/at/examples/index.js b/base/at/examples/index.js deleted file mode 100644 index 6697b5c18..000000000 --- a/base/at/examples/index.js +++ /dev/null @@ -1,34 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var at = require( './../lib' ); - -// Define an array: -var x = discreteUniform( 10, -100, 100 ); - -// Define an array containing random index values: -var indices = discreteUniform( 100, -x.length, x.length-1 ); - -// Randomly selected values from the input array: -var i; -for ( i = 0; i < indices.length; i++ ) { - console.log( 'x[%d] = %d', indices[ i ], at( x, indices[ i ] ) ); -} diff --git a/base/at/lib/index.js b/base/at/lib/index.js deleted file mode 100644 index 83b373bf9..000000000 --- a/base/at/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Return an element from an array. -* -* @module @stdlib/array/base/at -* -* @example -* var at = require( '@stdlib/array/base/at' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var v = at( x, 0 ); -* // returns 1 -* -* v = at( x, 1 ); -* // returns 2 -* -* v = at( x, -2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/at/lib/main.js b/base/at/lib/main.js deleted file mode 100644 index 4f2453d5c..000000000 --- a/base/at/lib/main.js +++ /dev/null @@ -1,90 +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. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'map' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - - -// MAIN // - -/** -* Returns an element from an array. -* -* @param {Collection} x - input array -* @param {integer} index - element index -* @returns {*} array element -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var v = at( x, 0 ); -* // returns 1 -* -* v = at( x, 1 ); -* // returns 2 -* -* v = at( x, -2 ); -* // returns 3 -*/ -function at( x, index ) { - var get; - if ( hasMethod( x, 'at' ) ) { - return x.at( index ); - } - if ( index < 0 ) { - index += x.length; - if ( index < 0 ) { - return; - } - } else if ( index >= x.length ) { - return; - } - get = resolveGetter( x ); - return get( x, index ); -} - - -// EXPORTS // - -module.exports = at; diff --git a/base/at/package.json b/base/at/package.json deleted file mode 100644 index f9beef976..000000000 --- a/base/at/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/at", - "version": "0.0.0", - "description": "Return an element from an array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "typed", - "collection", - "vector", - "at", - "get", - "getter", - "accessor", - "access", - "retrieve" - ], - "__stdlib__": {} -} diff --git a/base/at/test/test.js b/base/at/test/test.js deleted file mode 100644 index 9b0409299..000000000 --- a/base/at/test/test.js +++ /dev/null @@ -1,206 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int32Array = require( './../../../int32' ); -var Complex128Array = require( './../../../complex128' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var isSameComplex128 = require( '@stdlib/assert/is-same-complex128' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var at = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof at, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array element (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 2, 3, 4, 5, 6 ]; - - actual = at( x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = at( x, 4 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = at( x, -1 ); - t.strictEqual( actual, 6, 'returns expected value' ); - - actual = at( x, -x.length ); - t.strictEqual( actual, 1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 2, 3, 4, 5, 6 ]; - - actual = at( x, 10 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, 40 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, -10 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, -40 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array element (typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - - actual = at( x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = at( x, 4 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = at( x, -1 ); - t.strictEqual( actual, 6, 'returns expected value' ); - - actual = at( x, -x.length ); - t.strictEqual( actual, 1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - - actual = at( x, 10 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, 40 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, -10 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, -40 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array element (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - actual = at( x, 1 ); - t.strictEqual( isSameComplex128( actual, new Complex128( 3.0, 4.0 ) ), true, 'returns expected value' ); - - actual = at( x, 3 ); - t.strictEqual( isSameComplex128( actual, new Complex128( 7.0, 8.0 ) ), true, 'returns expected value' ); - - actual = at( x, -1 ); - t.strictEqual( isSameComplex128( actual, new Complex128( 7.0, 8.0 ) ), true, 'returns expected value' ); - - actual = at( x, -x.length ); - t.strictEqual( isSameComplex128( actual, new Complex128( 1.0, 2.0 ) ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - actual = at( x, 10 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, 40 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, -10 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, -40 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array element (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4, 5, 6 ] ); - - actual = at( x, 1 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = at( x, 4 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = at( x, -1 ); - t.strictEqual( actual, 6, 'returns expected value' ); - - actual = at( x, -x.length ); - t.strictEqual( actual, 1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4, 5, 6 ] ); - - actual = at( x, 10 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, 40 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, -10 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - actual = at( x, -40 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - - t.end(); -}); diff --git a/base/at2d/README.md b/base/at2d/README.md deleted file mode 100644 index 6ced92e98..000000000 --- a/base/at2d/README.md +++ /dev/null @@ -1,144 +0,0 @@ - - -# at2d - -> Return an element from a two-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var at2d = require( '@stdlib/array/base/at2d' ); -``` - -#### at2d( x, i0, i1 ) - -Returns an element from a two-dimensional nested array. - -```javascript -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var out = at2d( x, 0, 1 ); -// returns 2 - -out = at2d( x, 1, 0 ); -// returns 3 -``` - -The function accepts the following arguments: - -- **x**: two-dimensional nested input array. -- **i0**: first dimension index. -- **i1**: second dimension index. - -
- - - - - -
- -## Notes - -- Negative indices are resolved relative to the last element along the respective dimension, with the last element corresponding to `-1`. -- If provided out-of-bounds indices, the function always returns `undefined`. - -
- - - - - -
- -## Examples - - - -```javascript -var papply = require( '@stdlib/utils/papply' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var binary2d = require( '@stdlib/array/base/binary2d' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var at2d = require( '@stdlib/array/base/at2d' ); - -var shape = [ 3, 3 ]; - -// Define a nested input array: -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -// Define arrays containing random index values: -var i0 = filled2dBy( shape, discreteUniform( -shape[0], shape[0]-1 ) ); -console.log( i0 ); - -var i1 = filled2dBy( shape, discreteUniform( -shape[1], shape[1]-1 ) ); -console.log( i1 ); - -// Define an output array: -var out = zeros2d( shape ); -console.log( out ); - -// Fill the output array with randomly selected values from the input array: -binary2d( [ i0, i1, out ], shape, papply( at2d, x ) ); -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/at2d/benchmark/benchmark.js b/base/at2d/benchmark/benchmark.js deleted file mode 100644 index e861b3537..000000000 --- a/base/at2d/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pkg = require( './../package.json' ).name; -var at2d = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var v; - var i; - var j; - - x = filled2dBy( [ 10, 10 ], uniform( 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = ( i%20 ) - 10; - v = at2d( x, j, j ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/at2d/docs/repl.txt b/base/at2d/docs/repl.txt deleted file mode 100644 index 512f3ff55..000000000 --- a/base/at2d/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, i0, i1 ) - Returns an element from a two-dimensional nested array. - - Negative indices are resolved relative to the last element along the - respective dimension, with the last element corresponding to `-1`. - - If provided out-of-bounds indices, the function always returns `undefined`. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - i0: integer - First dimension index. - - i1: integer - Second dimension index. - - Returns - ------- - out: any - Element value. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > {{alias}}( x, 0, 1 ) - 2 - > {{alias}}( x, 1, 0 ) - 3 - - See Also - -------- - diff --git a/base/at2d/docs/types/index.d.ts b/base/at2d/docs/types/index.d.ts deleted file mode 100644 index 3ffcf07a9..000000000 --- a/base/at2d/docs/types/index.d.ts +++ /dev/null @@ -1,50 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; - -/** -* Returns an element from a two-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @returns nested array element -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var v = at2d( x, 0, 1 ); -* // returns 2 -* -* v = at2d( x, 1, 0 ); -* // returns 3 -* -* v = at2d( x, -2, -2 ); -* // returns 1 -*/ -declare function at2d( x: Array2D, i0: number, i1: number ): T | void; - - -// EXPORTS // - -export = at2d; diff --git a/base/at2d/docs/types/test.ts b/base/at2d/docs/types/test.ts deleted file mode 100644 index 61d6da8c4..000000000 --- a/base/at2d/docs/types/test.ts +++ /dev/null @@ -1,79 +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. -*/ - -import at2d = require( './index' ); - - -// TESTS // - -// The function returns an array element... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - at2d( x, 0, 0 ); // $ExpectType number | void -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - at2d( 'abc', 0, 0 ); // $ExpectError - at2d( 5, 0, 0 ); // $ExpectError - at2d( true, 0, 0 ); // $ExpectError - at2d( false, 0, 0 ); // $ExpectError - at2d( null, 0, 0 ); // $ExpectError - at2d( void 0, 0, 0 ); // $ExpectError - at2d( {}, 0, 0 ); // $ExpectError - at2d( ( x: number ): number => x, 0, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - at2d( x, 'abc', 0 ); // $ExpectError - at2d( x, true, 0 ); // $ExpectError - at2d( x, false, 0 ); // $ExpectError - at2d( x, null, 0 ); // $ExpectError - at2d( x, void 0, 0 ); // $ExpectError - at2d( x, [ '1' ], 0 ); // $ExpectError - at2d( x, {}, 0 ); // $ExpectError - at2d( x, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - at2d( x, 0, 'abc' ); // $ExpectError - at2d( x, 0, true ); // $ExpectError - at2d( x, 0, false ); // $ExpectError - at2d( x, 0, null ); // $ExpectError - at2d( x, 0, void 0 ); // $ExpectError - at2d( x, 0, [ '1' ] ); // $ExpectError - at2d( x, 0, {} ); // $ExpectError - at2d( x, 0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - at2d(); // $ExpectError - at2d( x ); // $ExpectError - at2d( x, 0 ); // $ExpectError - at2d( x, 0, 0, 0 ); // $ExpectError -} diff --git a/base/at2d/examples/index.js b/base/at2d/examples/index.js deleted file mode 100644 index c1afd7c89..000000000 --- a/base/at2d/examples/index.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -var papply = require( '@stdlib/utils/papply' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var binary2d = require( './../../../base/binary2d' ); -var zeros2d = require( './../../../base/zeros2d' ); -var at2d = require( './../lib' ); - -var shape = [ 3, 3 ]; - -// Define a nested input array: -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -// Define arrays containing random index values: -var i0 = filled2dBy( shape, discreteUniform( -shape[0], shape[0]-1 ) ); -console.log( i0 ); - -var i1 = filled2dBy( shape, discreteUniform( -shape[1], shape[1]-1 ) ); -console.log( i1 ); - -// Define an output array: -var out = zeros2d( shape ); -console.log( out ); - -// Fill the output array with randomly selected values from the input array: -binary2d( [ i0, i1, out ], shape, papply( at2d, x ) ); -console.log( out ); diff --git a/base/at2d/lib/index.js b/base/at2d/lib/index.js deleted file mode 100644 index 4c96bb578..000000000 --- a/base/at2d/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Return an element from a two-dimensional nested array. -* -* @module @stdlib/array/base/at2d -* -* @example -* var at2d = require( '@stdlib/array/base/at2d' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var v = at2d( x, 0, 1 ); -* // returns 2 -* -* v = at2d( x, 1, 0 ); -* // returns 3 -* -* v = at2d( x, -2, -2 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/at2d/lib/main.js b/base/at2d/lib/main.js deleted file mode 100644 index 1d4e46099..000000000 --- a/base/at2d/lib/main.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an element from a two-dimensional nested array. -* -* @param {ArrayLikeObject} x - input array -* @param {integer} i0 - first dimension index -* @param {integer} i1 - second dimension index -* @returns {*} nested array element -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var v = at2d( x, 0, 1 ); -* // returns 2 -* -* v = at2d( x, 1, 0 ); -* // returns 3 -* -* v = at2d( x, -2, -2 ); -* // returns 1 -*/ -function at2d( x, i0, i1 ) { - var x0; - var N; - - N = x.length; - if ( i0 < 0 ) { - i0 += N; - } - if ( i0 < 0 || i0 >= N ) { - return; - } - x0 = x[ i0 ]; - N = x0.length; - if ( i1 < 0 ) { - i1 += N; - } - if ( i1 < 0 || i1 >= N ) { - return; - } - return x0[ i1 ]; -} - - -// EXPORTS // - -module.exports = at2d; diff --git a/base/at2d/package.json b/base/at2d/package.json deleted file mode 100644 index 9d69ad790..000000000 --- a/base/at2d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/at2d", - "version": "0.0.0", - "description": "Return an element from a two-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "at", - "get", - "getter", - "accessor", - "access", - "retrieve" - ], - "__stdlib__": {} -} diff --git a/base/at2d/test/test.js b/base/at2d/test/test.js deleted file mode 100644 index 70df3eb96..000000000 --- a/base/at2d/test/test.js +++ /dev/null @@ -1,142 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var nCartesianProduct = require( './../../../base/n-cartesian-product' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var flatten2d = require( './../../../base/flatten2d' ); -var incrspace = require( './../../../base/incrspace' ); -var at2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof at2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a nested array element (positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var x; - var i; - - shape = [ 5, 5 ]; - x = filled2dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0], 1 ); - i1 = incrspace( 0, shape[1], 1 ); - indices = nCartesianProduct( i0, i1 ); - - expected = flatten2d( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = at2d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var x; - var i; - - shape = [ 5, 5 ]; - x = filled2dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0], 0, 1 ); - i1 = incrspace( -shape[1], 0, 1 ); - indices = nCartesianProduct( i0, i1 ); - - expected = flatten2d( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = at2d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var x; - var i; - - shape = [ 5, 5 ]; - x = filled2dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0]+10, 1 ); - i1 = incrspace( shape[1], shape[1]+10, 1 ); - indices = nCartesianProduct( i0, i1 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = at2d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var x; - var i; - - shape = [ 5, 5 ]; - x = filled2dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0]-10, 0, 1 ); - i1 = incrspace( -shape[1]-10, -shape[1], 1 ); - indices = nCartesianProduct( i0, i1 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = at2d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); diff --git a/base/at3d/README.md b/base/at3d/README.md deleted file mode 100644 index a883f54b5..000000000 --- a/base/at3d/README.md +++ /dev/null @@ -1,148 +0,0 @@ - - -# at3d - -> Return an element from a three-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var at3d = require( '@stdlib/array/base/at3d' ); -``` - -#### at3d( x, i0, i1, i2 ) - -Returns an element from a three-dimensional nested array. - -```javascript -var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - -var out = at3d( x, 0, 0, 1 ); -// returns 2 - -out = at3d( x, 0, 1, 0 ); -// returns 3 -``` - -The function accepts the following arguments: - -- **x**: three-dimensional nested input array. -- **i0**: first dimension index. -- **i1**: second dimension index. -- **i2**: third dimension index. - -
- - - - - -
- -## Notes - -- Negative indices are resolved relative to the last element along the respective dimension, with the last element corresponding to `-1`. -- If provided out-of-bounds indices, the function always returns `undefined`. - -
- - - - - -
- -## Examples - - - -```javascript -var papply = require( '@stdlib/utils/papply' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var ternary3d = require( '@stdlib/array/base/ternary3d' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var at3d = require( '@stdlib/array/base/at3d' ); - -var shape = [ 3, 3, 3 ]; - -// Define a nested input array: -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -// Define arrays containing random index values: -var i0 = filled3dBy( shape, discreteUniform( -shape[0], shape[0]-1 ) ); -console.log( i0 ); - -var i1 = filled3dBy( shape, discreteUniform( -shape[1], shape[1]-1 ) ); -console.log( i1 ); - -var i2 = filled3dBy( shape, discreteUniform( -shape[2], shape[2]-1 ) ); -console.log( i2 ); - -// Define an output array: -var out = zeros3d( shape ); -console.log( out ); - -// Fill the output array with randomly selected values from the input array: -ternary3d( [ i0, i1, i2, out ], shape, papply( at3d, x ) ); -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/at3d/benchmark/benchmark.js b/base/at3d/benchmark/benchmark.js deleted file mode 100644 index 5ea14c0f1..000000000 --- a/base/at3d/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pkg = require( './../package.json' ).name; -var at3d = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var v; - var i; - var j; - - x = filled3dBy( [ 10, 10, 10 ], uniform( 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = ( i%20 ) - 10; - v = at3d( x, j, j, j ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/at3d/docs/repl.txt b/base/at3d/docs/repl.txt deleted file mode 100644 index a31cbc05c..000000000 --- a/base/at3d/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, i0, i1, i2 ) - Returns an element from a three-dimensional nested array. - - Negative indices are resolved relative to the last element along the - respective dimension, with the last element corresponding to `-1`. - - If provided out-of-bounds indices, the function always returns `undefined`. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - i0: integer - First dimension index. - - i1: integer - Second dimension index. - - i2: integer - Third dimension index. - - Returns - ------- - out: any - Element value. - - Examples - -------- - > var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - > {{alias}}( x, 0, 0, 1 ) - 2 - > {{alias}}( x, 0, 1, 0 ) - 3 - - See Also - -------- - diff --git a/base/at3d/docs/types/index.d.ts b/base/at3d/docs/types/index.d.ts deleted file mode 100644 index 42262b8ef..000000000 --- a/base/at3d/docs/types/index.d.ts +++ /dev/null @@ -1,51 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; - -/** -* Returns an element from a three-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @param i2 - third dimension index -* @returns nested array element -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -* -* var v = at3d( x, 0, 0, 1 ); -* // returns 2 -* -* v = at3d( x, 0, 1, 0 ); -* // returns 3 -* -* v = at3d( x, -1, -2, -2 ); -* // returns 1 -*/ -declare function at3d( x: Array3D, i0: number, i1: number, i2: number ): T | void; - - -// EXPORTS // - -export = at3d; diff --git a/base/at3d/docs/types/test.ts b/base/at3d/docs/types/test.ts deleted file mode 100644 index dfb98620a..000000000 --- a/base/at3d/docs/types/test.ts +++ /dev/null @@ -1,94 +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. -*/ - -import at3d = require( './index' ); - - -// TESTS // - -// The function returns an array element... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - at3d( x, 0, 0, 0 ); // $ExpectType number | void -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - at3d( 'abc', 0, 0, 0 ); // $ExpectError - at3d( 5, 0, 0, 0 ); // $ExpectError - at3d( true, 0, 0, 0 ); // $ExpectError - at3d( false, 0, 0, 0 ); // $ExpectError - at3d( null, 0, 0, 0 ); // $ExpectError - at3d( void 0, 0, 0, 0 ); // $ExpectError - at3d( {}, 0, 0, 0 ); // $ExpectError - at3d( ( x: number ): number => x, 0, 0, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - at3d( x, 'abc', 0, 0 ); // $ExpectError - at3d( x, true, 0, 0 ); // $ExpectError - at3d( x, false, 0, 0 ); // $ExpectError - at3d( x, null, 0, 0 ); // $ExpectError - at3d( x, void 0, 0, 0 ); // $ExpectError - at3d( x, [ '1' ], 0, 0 ); // $ExpectError - at3d( x, {}, 0, 0 ); // $ExpectError - at3d( x, ( x: number ): number => x, 0, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - at3d( x, 0, 'abc', 0 ); // $ExpectError - at3d( x, 0, true, 0 ); // $ExpectError - at3d( x, 0, false, 0 ); // $ExpectError - at3d( x, 0, null, 0 ); // $ExpectError - at3d( x, 0, void 0, 0 ); // $ExpectError - at3d( x, 0, [ '1' ], 0 ); // $ExpectError - at3d( x, 0, {}, 0 ); // $ExpectError - at3d( x, 0, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - at3d( x, 0, 0, 'abc' ); // $ExpectError - at3d( x, 0, 0, true ); // $ExpectError - at3d( x, 0, 0, false ); // $ExpectError - at3d( x, 0, 0, null ); // $ExpectError - at3d( x, 0, 0, void 0 ); // $ExpectError - at3d( x, 0, 0, [ '1' ] ); // $ExpectError - at3d( x, 0, 0, {} ); // $ExpectError - at3d( x, 0, 0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - at3d(); // $ExpectError - at3d( x ); // $ExpectError - at3d( x, 0 ); // $ExpectError - at3d( x, 0, 0 ); // $ExpectError - at3d( x, 0, 0, 0, 0 ); // $ExpectError -} diff --git a/base/at3d/examples/index.js b/base/at3d/examples/index.js deleted file mode 100644 index 31d5238a4..000000000 --- a/base/at3d/examples/index.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -var papply = require( '@stdlib/utils/papply' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var ternary3d = require( './../../../base/ternary3d' ); -var zeros3d = require( './../../../base/zeros3d' ); -var at3d = require( './../lib' ); - -var shape = [ 3, 3, 3 ]; - -// Define a nested input array: -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -// Define arrays containing random index values: -var i0 = filled3dBy( shape, discreteUniform( -shape[0], shape[0]-1 ) ); -console.log( i0 ); - -var i1 = filled3dBy( shape, discreteUniform( -shape[1], shape[1]-1 ) ); -console.log( i1 ); - -var i2 = filled3dBy( shape, discreteUniform( -shape[2], shape[2]-1 ) ); -console.log( i2 ); - -// Define an output array: -var out = zeros3d( shape ); -console.log( out ); - -// Fill the output array with randomly selected values from the input array: -ternary3d( [ i0, i1, i2, out ], shape, papply( at3d, x ) ); -console.log( out ); diff --git a/base/at3d/lib/index.js b/base/at3d/lib/index.js deleted file mode 100644 index a9e652167..000000000 --- a/base/at3d/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Return an element from a three-dimensional nested array. -* -* @module @stdlib/array/base/at3d -* -* @example -* var at3d = require( '@stdlib/array/base/at3d' ); -* -* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -* -* var v = at3d( x, 0, 0, 1 ); -* // returns 2 -* -* v = at3d( x, 0, 1, 0 ); -* // returns 3 -* -* v = at3d( x, 0, -2, -2 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/at3d/lib/main.js b/base/at3d/lib/main.js deleted file mode 100644 index df65a6914..000000000 --- a/base/at3d/lib/main.js +++ /dev/null @@ -1,78 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an element from a three-dimensional nested array. -* -* @param {ArrayLikeObject>} x - input array -* @param {integer} i0 - first dimension index -* @param {integer} i1 - second dimension index -* @param {integer} i2 - third dimension index -* @returns {*} nested array element -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -* -* var v = at3d( x, 0, 0, 1 ); -* // returns 2 -* -* v = at3d( x, 0, 1, 0 ); -* // returns 3 -* -* v = at3d( x, 0, -2, -2 ); -* // returns 1 -*/ -function at3d( x, i0, i1, i2 ) { - var x0; - var x1; - var N; - - N = x.length; - if ( i0 < 0 ) { - i0 += N; - } - if ( i0 < 0 || i0 >= N ) { - return; - } - x0 = x[ i0 ]; - N = x0.length; - if ( i1 < 0 ) { - i1 += N; - } - if ( i1 < 0 || i1 >= N ) { - return; - } - x1 = x0[ i1 ]; - N = x1.length; - if ( i2 < 0 ) { - i2 += N; - } - if ( i2 < 0 || i2 >= N ) { - return; - } - return x1[ i2 ]; -} - - -// EXPORTS // - -module.exports = at3d; diff --git a/base/at3d/package.json b/base/at3d/package.json deleted file mode 100644 index 5f81ada72..000000000 --- a/base/at3d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/at3d", - "version": "0.0.0", - "description": "Return an element from a three-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "at", - "get", - "getter", - "accessor", - "access", - "retrieve" - ], - "__stdlib__": {} -} diff --git a/base/at3d/test/test.js b/base/at3d/test/test.js deleted file mode 100644 index a3a23bc8e..000000000 --- a/base/at3d/test/test.js +++ /dev/null @@ -1,150 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var nCartesianProduct = require( './../../../base/n-cartesian-product' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var flatten3d = require( './../../../base/flatten3d' ); -var incrspace = require( './../../../base/incrspace' ); -var at3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof at3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a nested array element (positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var x; - var i; - - shape = [ 3, 3, 3 ]; - x = filled3dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0], 1 ); - i1 = incrspace( 0, shape[1], 1 ); - i2 = incrspace( 0, shape[2], 1 ); - indices = nCartesianProduct( i0, i1, i2 ); - - expected = flatten3d( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = at3d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var x; - var i; - - shape = [ 3, 3, 3 ]; - x = filled3dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0], 0, 1 ); - i1 = incrspace( -shape[1], 0, 1 ); - i2 = incrspace( -shape[2], 0, 1 ); - indices = nCartesianProduct( i0, i1, i2 ); - - expected = flatten3d( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = at3d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var x; - var i; - - shape = [ 3, 3, 3 ]; - x = filled3dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0]+10, 1 ); - i1 = incrspace( 0, shape[1]+10, 1 ); - i2 = incrspace( shape[2], shape[2]+10, 1 ); - indices = nCartesianProduct( i0, i1, i2 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = at3d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var x; - var i; - - shape = [ 3, 3, 3 ]; - x = filled3dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0]-10, 0, 1 ); - i1 = incrspace( -shape[1]-10, 0, 1 ); - i2 = incrspace( -shape[2]-10, -shape[2], 1 ); - indices = nCartesianProduct( i0, i1, i2 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = at3d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); diff --git a/base/at4d/README.md b/base/at4d/README.md deleted file mode 100644 index 6e72bd420..000000000 --- a/base/at4d/README.md +++ /dev/null @@ -1,152 +0,0 @@ - - -# at4d - -> Return an element from a four-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var at4d = require( '@stdlib/array/base/at4d' ); -``` - -#### at4d( x, i0, i1, i2, i3 ) - -Returns an element from a four-dimensional nested array. - -```javascript -var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - -var out = at4d( x, 0, 0, 0, 1 ); -// returns 2 - -out = at4d( x, 0, 0, 1, 0 ); -// returns 3 -``` - -The function accepts the following arguments: - -- **x**: four-dimensional nested input array. -- **i0**: first dimension index. -- **i1**: second dimension index. -- **i2**: third dimension index. -- **i3**: fourth dimension index. - -
- - - - - -
- -## Notes - -- Negative indices are resolved relative to the last element along the respective dimension, with the last element corresponding to `-1`. -- If provided out-of-bounds indices, the function always returns `undefined`. - -
- - - - - -
- -## Examples - - - -```javascript -var papply = require( '@stdlib/utils/papply' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var quaternary4d = require( '@stdlib/array/base/quaternary4d' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var at4d = require( '@stdlib/array/base/at4d' ); - -var shape = [ 2, 2, 4, 4 ]; - -// Define a nested input array: -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -// Define arrays containing random index values: -var i0 = filled4dBy( shape, discreteUniform( -shape[0], shape[0]-1 ) ); -console.log( i0 ); - -var i1 = filled4dBy( shape, discreteUniform( -shape[1], shape[1]-1 ) ); -console.log( i1 ); - -var i2 = filled4dBy( shape, discreteUniform( -shape[2], shape[2]-1 ) ); -console.log( i2 ); - -var i3 = filled4dBy( shape, discreteUniform( -shape[3], shape[3]-1 ) ); -console.log( i3 ); - -// Define an output array: -var out = zeros4d( shape ); -console.log( out ); - -// Fill the output array with randomly selected values from the input array: -quaternary4d( [ i0, i1, i2, i3, out ], shape, papply( at4d, x ) ); -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/at4d/benchmark/benchmark.js b/base/at4d/benchmark/benchmark.js deleted file mode 100644 index bebab6375..000000000 --- a/base/at4d/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pkg = require( './../package.json' ).name; -var at4d = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var v; - var i; - var j; - - x = filled4dBy( [ 10, 10, 10, 10 ], uniform( 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = ( i%20 ) - 10; - v = at4d( x, j, j, j, j ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/at4d/docs/repl.txt b/base/at4d/docs/repl.txt deleted file mode 100644 index d08be5a1f..000000000 --- a/base/at4d/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( x, i0, i1, i2, i3 ) - Returns an element from a four-dimensional nested array. - - Negative indices are resolved relative to the last element along the - respective dimension, with the last element corresponding to `-1`. - - If provided out-of-bounds indices, the function always returns `undefined`. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - i0: integer - First dimension index. - - i1: integer - Second dimension index. - - i2: integer - Third dimension index. - - i3: integer - Fourth dimension index. - - Returns - ------- - out: any - Element value. - - Examples - -------- - > var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - > {{alias}}( x, 0, 0, 0, 1 ) - 2 - > {{alias}}( x, 0, 0, 1, 0 ) - 3 - - See Also - -------- - diff --git a/base/at4d/docs/types/index.d.ts b/base/at4d/docs/types/index.d.ts deleted file mode 100644 index 573b47e2b..000000000 --- a/base/at4d/docs/types/index.d.ts +++ /dev/null @@ -1,52 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; - -/** -* Returns an element from a four-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @param i2 - third dimension index -* @param i3 - fourth dimension index -* @returns nested array element -* -* @example -* var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; -* -* var v = at4d( x, 0, 0, 0, 1 ); -* // returns 2 -* -* v = at4d( x, 0, 0, 1, 0 ); -* // returns 3 -* -* v = at4d( x, -1, -1, -2, -2 ); -* // returns 1 -*/ -declare function at4d( x: Array4D, i0: number, i1: number, i2: number, i3: number ): T | void; - - -// EXPORTS // - -export = at4d; diff --git a/base/at4d/docs/types/test.ts b/base/at4d/docs/types/test.ts deleted file mode 100644 index 46c2a6b9f..000000000 --- a/base/at4d/docs/types/test.ts +++ /dev/null @@ -1,109 +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. -*/ - -import at4d = require( './index' ); - - -// TESTS // - -// The function returns an array element... -{ - const x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - - at4d( x, 0, 0, 0, 0 ); // $ExpectType number | void -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - at4d( 'abc', 0, 0, 0, 0 ); // $ExpectError - at4d( 5, 0, 0, 0, 0 ); // $ExpectError - at4d( true, 0, 0, 0, 0 ); // $ExpectError - at4d( false, 0, 0, 0, 0 ); // $ExpectError - at4d( null, 0, 0, 0, 0 ); // $ExpectError - at4d( void 0, 0, 0, 0, 0 ); // $ExpectError - at4d( {}, 0, 0, 0, 0 ); // $ExpectError - at4d( ( x: number ): number => x, 0, 0, 0, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - - at4d( x, 'abc', 0, 0, 0 ); // $ExpectError - at4d( x, true, 0, 0, 0 ); // $ExpectError - at4d( x, false, 0, 0, 0 ); // $ExpectError - at4d( x, null, 0, 0, 0 ); // $ExpectError - at4d( x, void 0, 0, 0, 0 ); // $ExpectError - at4d( x, [ '1' ], 0, 0, 0 ); // $ExpectError - at4d( x, {}, 0, 0, 0 ); // $ExpectError - at4d( x, ( x: number ): number => x, 0, 0, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - - at4d( x, 0, 'abc', 0, 0 ); // $ExpectError - at4d( x, 0, true, 0, 0 ); // $ExpectError - at4d( x, 0, false, 0, 0 ); // $ExpectError - at4d( x, 0, null, 0, 0 ); // $ExpectError - at4d( x, 0, void 0, 0, 0 ); // $ExpectError - at4d( x, 0, [ '1' ], 0, 0 ); // $ExpectError - at4d( x, 0, {}, 0, 0 ); // $ExpectError - at4d( x, 0, ( x: number ): number => x, 0, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - - at4d( x, 0, 0, 'abc', 0 ); // $ExpectError - at4d( x, 0, 0, true, 0 ); // $ExpectError - at4d( x, 0, 0, false, 0 ); // $ExpectError - at4d( x, 0, 0, null, 0 ); // $ExpectError - at4d( x, 0, 0, void 0, 0 ); // $ExpectError - at4d( x, 0, 0, [ '1' ], 0 ); // $ExpectError - at4d( x, 0, 0, {}, 0 ); // $ExpectError - at4d( x, 0, 0, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - - at4d( x, 0, 0, 0, 'abc' ); // $ExpectError - at4d( x, 0, 0, 0, true ); // $ExpectError - at4d( x, 0, 0, 0, false ); // $ExpectError - at4d( x, 0, 0, 0, null ); // $ExpectError - at4d( x, 0, 0, 0, void 0 ); // $ExpectError - at4d( x, 0, 0, 0, [ '1' ] ); // $ExpectError - at4d( x, 0, 0, 0, {} ); // $ExpectError - at4d( x, 0, 0, 0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - - at4d(); // $ExpectError - at4d( x ); // $ExpectError - at4d( x, 0 ); // $ExpectError - at4d( x, 0, 0 ); // $ExpectError - at4d( x, 0, 0, 0 ); // $ExpectError - at4d( x, 0, 0, 0, 0, 0 ); // $ExpectError -} diff --git a/base/at4d/examples/index.js b/base/at4d/examples/index.js deleted file mode 100644 index e524b3d3c..000000000 --- a/base/at4d/examples/index.js +++ /dev/null @@ -1,53 +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. -*/ - -'use strict'; - -var papply = require( '@stdlib/utils/papply' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var quaternary4d = require( './../../../base/quaternary4d' ); -var zeros4d = require( './../../../base/zeros4d' ); -var at4d = require( './../lib' ); - -var shape = [ 2, 2, 4, 4 ]; - -// Define a nested input array: -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -// Define arrays containing random index values: -var i0 = filled4dBy( shape, discreteUniform( -shape[0], shape[0]-1 ) ); -console.log( i0 ); - -var i1 = filled4dBy( shape, discreteUniform( -shape[1], shape[1]-1 ) ); -console.log( i1 ); - -var i2 = filled4dBy( shape, discreteUniform( -shape[2], shape[2]-1 ) ); -console.log( i2 ); - -var i3 = filled4dBy( shape, discreteUniform( -shape[3], shape[3]-1 ) ); -console.log( i3 ); - -// Define an output array: -var out = zeros4d( shape ); -console.log( out ); - -// Fill the output array with randomly selected values from the input array: -quaternary4d( [ i0, i1, i2, i3, out ], shape, papply( at4d, x ) ); -console.log( out ); diff --git a/base/at4d/lib/index.js b/base/at4d/lib/index.js deleted file mode 100644 index e7457b4cd..000000000 --- a/base/at4d/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Return an element from a four-dimensional nested array. -* -* @module @stdlib/array/base/at4d -* -* @example -* var at4d = require( '@stdlib/array/base/at4d' ); -* -* var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; -* -* var v = at4d( x, 0, 0, 0, 1 ); -* // returns 2 -* -* v = at4d( x, 0, 0, 1, 0 ); -* // returns 3 -* -* v = at4d( x, 0, 0, -2, -2 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/at4d/lib/main.js b/base/at4d/lib/main.js deleted file mode 100644 index 629c1da7f..000000000 --- a/base/at4d/lib/main.js +++ /dev/null @@ -1,71 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an element from a four-dimensional nested array. -* -* @param {ArrayLikeObject>>} x - input array -* @param {integer} i0 - first dimension index -* @param {integer} i1 - second dimension index -* @param {integer} i2 - third dimension index -* @param {integer} i3 - fourth dimension index -* @returns {*} nested array element -* -* @example -* var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; -* -* var v = at4d( x, 0, 0, 0, 1 ); -* // returns 2 -* -* v = at4d( x, 0, 0, 1, 0 ); -* // returns 3 -* -* v = at4d( x, 0, 0, -2, -2 ); -* // returns 1 -*/ -function at4d( x, i0, i1, i2, i3 ) { - var value; - var idx; - var N; - var i; - var j; - - idx = [ i0, i1, i2, i3 ]; - value = x; - for ( i = 0; i < idx.length; i++ ) { - j = idx[ i ]; - N = value.length; - if ( j < 0 ) { - j += N; - } - if ( j < 0 || j >= N ) { - return; - } - value = value[ j ]; - } - return value; -} - - -// EXPORTS // - -module.exports = at4d; diff --git a/base/at4d/package.json b/base/at4d/package.json deleted file mode 100644 index 72e119365..000000000 --- a/base/at4d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/at4d", - "version": "0.0.0", - "description": "Return an element from a four-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "at", - "get", - "getter", - "accessor", - "access", - "retrieve" - ], - "__stdlib__": {} -} diff --git a/base/at4d/test/test.js b/base/at4d/test/test.js deleted file mode 100644 index 484ab25b7..000000000 --- a/base/at4d/test/test.js +++ /dev/null @@ -1,158 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var nCartesianProduct = require( './../../../base/n-cartesian-product' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var flatten4d = require( './../../../base/flatten4d' ); -var incrspace = require( './../../../base/incrspace' ); -var at4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof at4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a nested array element (positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var x; - var i; - - shape = [ 2, 2, 4, 4 ]; - x = filled4dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0], 1 ); - i1 = incrspace( 0, shape[1], 1 ); - i2 = incrspace( 0, shape[2], 1 ); - i3 = incrspace( 0, shape[3], 1 ); - indices = nCartesianProduct( i0, i1, i2, i3 ); - - expected = flatten4d( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = at4d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var x; - var i; - - shape = [ 2, 2, 4, 4 ]; - x = filled4dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0], 0, 1 ); - i1 = incrspace( -shape[1], 0, 1 ); - i2 = incrspace( -shape[2], 0, 1 ); - i3 = incrspace( -shape[3], 0, 1 ); - indices = nCartesianProduct( i0, i1, i2, i3 ); - - expected = flatten4d( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = at4d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var x; - var i; - - shape = [ 2, 2, 4, 4 ]; - x = filled4dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0]+10, 1 ); - i1 = incrspace( 0, shape[1]+10, 1 ); - i2 = incrspace( 0, shape[2]+10, 1 ); - i3 = incrspace( shape[3], shape[3]+10, 1 ); - indices = nCartesianProduct( i0, i1, i2, i3 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = at4d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var x; - var i; - - shape = [ 2, 2, 4, 4 ]; - x = filled4dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0]-10, 0, 1 ); - i1 = incrspace( -shape[1]-10, 0, 1 ); - i2 = incrspace( -shape[2]-10, 0, 1 ); - i3 = incrspace( -shape[3]-10, -shape[3], 1 ); - indices = nCartesianProduct( i0, i1, i2, i3 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = at4d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); diff --git a/base/at5d/README.md b/base/at5d/README.md deleted file mode 100644 index 4e45b6d06..000000000 --- a/base/at5d/README.md +++ /dev/null @@ -1,156 +0,0 @@ - - -# at5d - -> Return an element from a five-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var at5d = require( '@stdlib/array/base/at5d' ); -``` - -#### at5d( x, i0, i1, i2, i3, i4 ) - -Returns an element from a five-dimensional nested array. - -```javascript -var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - -var out = at5d( x, 0, 0, 0, 0, 1 ); -// returns 2 - -out = at5d( x, 0, 0, 0, 1, 0 ); -// returns 3 -``` - -The function accepts the following arguments: - -- **x**: five-dimensional nested input array. -- **i0**: first dimension index. -- **i1**: second dimension index. -- **i2**: third dimension index. -- **i3**: fourth dimension index. -- **i4**: fifth dimension index. - -
- - - - - -
- -## Notes - -- Negative indices are resolved relative to the last element along the respective dimension, with the last element corresponding to `-1`. -- If provided out-of-bounds indices, the function always returns `undefined`. - -
- - - - - -
- -## Examples - - - -```javascript -var papply = require( '@stdlib/utils/papply' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var quinary5d = require( '@stdlib/array/base/quinary5d' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var at5d = require( '@stdlib/array/base/at5d' ); - -var shape = [ 2, 2, 2, 2, 2 ]; - -// Define a nested input array: -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -// Define arrays containing random index values: -var i0 = filled5dBy( shape, discreteUniform( -shape[0], shape[0]-1 ) ); -console.log( i0 ); - -var i1 = filled5dBy( shape, discreteUniform( -shape[1], shape[1]-1 ) ); -console.log( i1 ); - -var i2 = filled5dBy( shape, discreteUniform( -shape[2], shape[2]-1 ) ); -console.log( i2 ); - -var i3 = filled5dBy( shape, discreteUniform( -shape[3], shape[3]-1 ) ); -console.log( i3 ); - -var i4 = filled5dBy( shape, discreteUniform( -shape[4], shape[4]-1 ) ); -console.log( i4 ); - -// Define an output array: -var out = zeros5d( shape ); -console.log( out ); - -// Fill the output array with randomly selected values from the input array: -quinary5d( [ i0, i1, i2, i3, i4, out ], shape, papply( at5d, x ) ); -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/at5d/benchmark/benchmark.js b/base/at5d/benchmark/benchmark.js deleted file mode 100644 index 3be4fb6ba..000000000 --- a/base/at5d/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pkg = require( './../package.json' ).name; -var at5d = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var v; - var i; - var j; - - x = filled5dBy( [ 10, 10, 10, 10, 10 ], uniform( 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = ( i%20 ) - 10; - v = at5d( x, j, j, j, j, j ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/at5d/docs/repl.txt b/base/at5d/docs/repl.txt deleted file mode 100644 index e9701a4e9..000000000 --- a/base/at5d/docs/repl.txt +++ /dev/null @@ -1,45 +0,0 @@ - -{{alias}}( x, i0, i1, i2, i3, i4 ) - Returns an element from a five-dimensional nested array. - - Negative indices are resolved relative to the last element along the - respective dimension, with the last element corresponding to `-1`. - - If provided out-of-bounds indices, the function always returns `undefined`. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - i0: integer - First dimension index. - - i1: integer - Second dimension index. - - i2: integer - Third dimension index. - - i3: integer - Fourth dimension index. - - i4: integer - Fifth dimension index. - - Returns - ------- - out: any - Element value. - - Examples - -------- - > var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - > {{alias}}( x, 0, 0, 0, 0, 1 ) - 2 - > {{alias}}( x, 0, 0, 0, 1, 0 ) - 3 - - See Also - -------- - diff --git a/base/at5d/docs/types/index.d.ts b/base/at5d/docs/types/index.d.ts deleted file mode 100644 index 21c0eb0ac..000000000 --- a/base/at5d/docs/types/index.d.ts +++ /dev/null @@ -1,53 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; - -/** -* Returns an element from a five-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @param i2 - third dimension index -* @param i3 - fourth dimension index -* @param i4 - fifth dimension index -* @returns nested array element -* -* @example -* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; -* -* var v = at5d( x, 0, 0, 0, 0, 1 ); -* // returns 2 -* -* v = at5d( x, 0, 0, 0, 1, 0 ); -* // returns 3 -* -* v = at5d( x, -1, -1, -1, -2, -2 ); -* // returns 1 -*/ -declare function at5d( x: Array5D, i0: number, i1: number, i2: number, i3: number, i4: number ): T | void; - - -// EXPORTS // - -export = at5d; diff --git a/base/at5d/docs/types/test.ts b/base/at5d/docs/types/test.ts deleted file mode 100644 index f70f6a1c3..000000000 --- a/base/at5d/docs/types/test.ts +++ /dev/null @@ -1,124 +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. -*/ - -import at5d = require( './index' ); - - -// TESTS // - -// The function returns an array element... -{ - const x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - - at5d( x, 0, 0, 0, 0, 0 ); // $ExpectType number | void -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - at5d( 'abc', 0, 0, 0, 0, 0 ); // $ExpectError - at5d( 5, 0, 0, 0, 0, 0 ); // $ExpectError - at5d( true, 0, 0, 0, 0, 0 ); // $ExpectError - at5d( false, 0, 0, 0, 0, 0 ); // $ExpectError - at5d( null, 0, 0, 0, 0, 0 ); // $ExpectError - at5d( void 0, 0, 0, 0, 0, 0 ); // $ExpectError - at5d( {}, 0, 0, 0, 0, 0 ); // $ExpectError - at5d( ( x: number ): number => x, 0, 0, 0, 0, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - - at5d( x, 'abc', 0, 0, 0, 0 ); // $ExpectError - at5d( x, true, 0, 0, 0, 0 ); // $ExpectError - at5d( x, false, 0, 0, 0, 0 ); // $ExpectError - at5d( x, null, 0, 0, 0, 0 ); // $ExpectError - at5d( x, void 0, 0, 0, 0, 0 ); // $ExpectError - at5d( x, [ '1' ], 0, 0, 0, 0 ); // $ExpectError - at5d( x, {}, 0, 0, 0, 0 ); // $ExpectError - at5d( x, ( x: number ): number => x, 0, 0, 0, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - - at5d( x, 0, 'abc', 0, 0, 0 ); // $ExpectError - at5d( x, 0, true, 0, 0, 0 ); // $ExpectError - at5d( x, 0, false, 0, 0, 0 ); // $ExpectError - at5d( x, 0, null, 0, 0, 0 ); // $ExpectError - at5d( x, 0, void 0, 0, 0, 0 ); // $ExpectError - at5d( x, 0, [ '1' ], 0, 0, 0 ); // $ExpectError - at5d( x, 0, {}, 0, 0, 0 ); // $ExpectError - at5d( x, 0, ( x: number ): number => x, 0, 0, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - - at5d( x, 0, 0, 'abc', 0, 0 ); // $ExpectError - at5d( x, 0, 0, true, 0, 0 ); // $ExpectError - at5d( x, 0, 0, false, 0, 0 ); // $ExpectError - at5d( x, 0, 0, null, 0, 0 ); // $ExpectError - at5d( x, 0, 0, void 0, 0, 0 ); // $ExpectError - at5d( x, 0, 0, [ '1' ], 0, 0 ); // $ExpectError - at5d( x, 0, 0, {}, 0, 0 ); // $ExpectError - at5d( x, 0, 0, ( x: number ): number => x, 0, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a number... -{ - const x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - - at5d( x, 0, 0, 0, 'abc', 0 ); // $ExpectError - at5d( x, 0, 0, 0, true, 0 ); // $ExpectError - at5d( x, 0, 0, 0, false, 0 ); // $ExpectError - at5d( x, 0, 0, 0, null, 0 ); // $ExpectError - at5d( x, 0, 0, 0, void 0, 0 ); // $ExpectError - at5d( x, 0, 0, 0, [ '1' ], 0 ); // $ExpectError - at5d( x, 0, 0, 0, {}, 0 ); // $ExpectError - at5d( x, 0, 0, 0, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a number... -{ - const x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - - at5d( x, 0, 0, 0, 0, 'abc' ); // $ExpectError - at5d( x, 0, 0, 0, 0, true ); // $ExpectError - at5d( x, 0, 0, 0, 0, false ); // $ExpectError - at5d( x, 0, 0, 0, 0, null ); // $ExpectError - at5d( x, 0, 0, 0, 0, void 0 ); // $ExpectError - at5d( x, 0, 0, 0, 0, [ '1' ] ); // $ExpectError - at5d( x, 0, 0, 0, 0, {} ); // $ExpectError - at5d( x, 0, 0, 0, 0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - - at5d(); // $ExpectError - at5d( x ); // $ExpectError - at5d( x, 0 ); // $ExpectError - at5d( x, 0, 0 ); // $ExpectError - at5d( x, 0, 0, 0 ); // $ExpectError - at5d( x, 0, 0, 0, 0 ); // $ExpectError - at5d( x, 0, 0, 0, 0, 0, 0 ); // $ExpectError -} diff --git a/base/at5d/examples/index.js b/base/at5d/examples/index.js deleted file mode 100644 index 5c6833d9f..000000000 --- a/base/at5d/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var papply = require( '@stdlib/utils/papply' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var quinary5d = require( './../../../base/quinary5d' ); -var zeros5d = require( './../../../base/zeros5d' ); -var at5d = require( './../lib' ); - -var shape = [ 2, 2, 2, 2, 2 ]; - -// Define a nested input array: -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -// Define arrays containing random index values: -var i0 = filled5dBy( shape, discreteUniform( -shape[0], shape[0]-1 ) ); -console.log( i0 ); - -var i1 = filled5dBy( shape, discreteUniform( -shape[1], shape[1]-1 ) ); -console.log( i1 ); - -var i2 = filled5dBy( shape, discreteUniform( -shape[2], shape[2]-1 ) ); -console.log( i2 ); - -var i3 = filled5dBy( shape, discreteUniform( -shape[3], shape[3]-1 ) ); -console.log( i3 ); - -var i4 = filled5dBy( shape, discreteUniform( -shape[4], shape[4]-1 ) ); -console.log( i4 ); - -// Define an output array: -var out = zeros5d( shape ); -console.log( out ); - -// Fill the output array with randomly selected values from the input array: -quinary5d( [ i0, i1, i2, i3, i4, out ], shape, papply( at5d, x ) ); -console.log( out ); diff --git a/base/at5d/lib/index.js b/base/at5d/lib/index.js deleted file mode 100644 index 4c2a646a6..000000000 --- a/base/at5d/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Return an element from a five-dimensional nested array. -* -* @module @stdlib/array/base/at5d -* -* @example -* var at5d = require( '@stdlib/array/base/at5d' ); -* -* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; -* -* var v = at5d( x, 0, 0, 0, 0, 1 ); -* // returns 2 -* -* v = at5d( x, 0, 0, 0, 1, 0 ); -* // returns 3 -* -* v = at5d( x, 0, 0, 0, -2, -2 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/at5d/lib/main.js b/base/at5d/lib/main.js deleted file mode 100644 index 6231d9cd3..000000000 --- a/base/at5d/lib/main.js +++ /dev/null @@ -1,72 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an element from a five-dimensional nested array. -* -* @param {ArrayLikeObject>>>} x - input array -* @param {integer} i0 - first dimension index -* @param {integer} i1 - second dimension index -* @param {integer} i2 - third dimension index -* @param {integer} i3 - fourth dimension index -* @param {integer} i4 - fifth dimension index -* @returns {*} nested array element -* -* @example -* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; -* -* var v = at5d( x, 0, 0, 0, 0, 1 ); -* // returns 2 -* -* v = at5d( x, 0, 0, 0, 1, 0 ); -* // returns 3 -* -* v = at5d( x, 0, 0, 0, -2, -2 ); -* // returns 1 -*/ -function at5d( x, i0, i1, i2, i3, i4 ) { - var value; - var idx; - var N; - var i; - var j; - - idx = [ i0, i1, i2, i3, i4 ]; - value = x; - for ( i = 0; i < idx.length; i++ ) { - j = idx[ i ]; - N = value.length; - if ( j < 0 ) { - j += N; - } - if ( j < 0 || j >= N ) { - return; - } - value = value[ j ]; - } - return value; -} - - -// EXPORTS // - -module.exports = at5d; diff --git a/base/at5d/package.json b/base/at5d/package.json deleted file mode 100644 index 5556154ff..000000000 --- a/base/at5d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/at5d", - "version": "0.0.0", - "description": "Return an element from a five-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "at", - "get", - "getter", - "accessor", - "access", - "retrieve" - ], - "__stdlib__": {} -} diff --git a/base/at5d/test/test.js b/base/at5d/test/test.js deleted file mode 100644 index 66d021c75..000000000 --- a/base/at5d/test/test.js +++ /dev/null @@ -1,166 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var nCartesianProduct = require( './../../../base/n-cartesian-product' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var flatten5d = require( './../../../base/flatten5d' ); -var incrspace = require( './../../../base/incrspace' ); -var at5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof at5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a nested array element (positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var i4; - var x; - var i; - - shape = [ 2, 2, 2, 2, 2 ]; - x = filled5dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0], 1 ); - i1 = incrspace( 0, shape[1], 1 ); - i2 = incrspace( 0, shape[2], 1 ); - i3 = incrspace( 0, shape[3], 1 ); - i4 = incrspace( 0, shape[4], 1 ); - indices = nCartesianProduct( i0, i1, i2, i3, i4 ); - - expected = flatten5d( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = at5d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var i4; - var x; - var i; - - shape = [ 2, 2, 2, 2, 2 ]; - x = filled5dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0], 0, 1 ); - i1 = incrspace( -shape[1], 0, 1 ); - i2 = incrspace( -shape[2], 0, 1 ); - i3 = incrspace( -shape[3], 0, 1 ); - i4 = incrspace( -shape[4], 0, 1 ); - indices = nCartesianProduct( i0, i1, i2, i3, i4 ); - - expected = flatten5d( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = at5d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var i4; - var x; - var i; - - shape = [ 2, 2, 2, 2, 2 ]; - x = filled5dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0]+5, 1 ); - i1 = incrspace( 0, shape[1]+5, 1 ); - i2 = incrspace( 0, shape[2]+5, 1 ); - i3 = incrspace( 0, shape[3]+5, 1 ); - i4 = incrspace( shape[4], shape[4]+5, 1 ); - indices = nCartesianProduct( i0, i1, i2, i3, i4 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = at5d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var i4; - var x; - var i; - - shape = [ 2, 2, 2, 2, 2 ]; - x = filled5dBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0]-5, 0, 1 ); - i1 = incrspace( -shape[1]-5, 0, 1 ); - i2 = incrspace( -shape[2]-5, 0, 1 ); - i3 = incrspace( -shape[3]-5, 0, 1 ); - i4 = incrspace( -shape[4]-5, -shape[4], 1 ); - indices = nCartesianProduct( i0, i1, i2, i3, i4 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = at5d.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); diff --git a/base/atnd/README.md b/base/atnd/README.md deleted file mode 100644 index dd02cc817..000000000 --- a/base/atnd/README.md +++ /dev/null @@ -1,144 +0,0 @@ - - -# atnd - -> Return an element from an n-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var atnd = require( '@stdlib/array/base/atnd' ); -``` - -#### atnd( x, i0\[, ...indices] ) - -Returns an element from an n-dimensional nested array. - -```javascript -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var out = atnd( x, 0, 1 ); -// returns 2 - -out = atnd( x, 1, 0 ); -// returns 3 -``` - -The function accepts the following arguments: - -- **x**: n-dimensional nested input array. -- **i0**: first dimension index. -- **indices**: dimension indices. - -
- - - - - -
- -## Notes - -- Negative indices are resolved relative to the last element along the respective dimension, with the last element corresponding to `-1`. -- If provided out-of-bounds indices, the function always returns `undefined`. - -
- - - - - -
- -## Examples - - - -```javascript -var papply = require( '@stdlib/utils/papply' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var binary2d = require( '@stdlib/array/base/binary2d' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var atnd = require( '@stdlib/array/base/atnd' ); - -var shape = [ 5, 5 ]; - -// Define a nested input array: -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -// Define arrays containing random index values: -var i0 = filled2dBy( shape, discreteUniform( -shape[0], shape[0]-1 ) ); -console.log( i0 ); - -var i1 = filled2dBy( shape, discreteUniform( -shape[1], shape[1]-1 ) ); -console.log( i1 ); - -// Define an output array: -var out = zeros2d( shape ); -console.log( out ); - -// Fill the output array with randomly selected values from the input array: -binary2d( [ i0, i1, out ], shape, papply( atnd, x ) ); -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/atnd/benchmark/benchmark.js b/base/atnd/benchmark/benchmark.js deleted file mode 100644 index 89fb1462a..000000000 --- a/base/atnd/benchmark/benchmark.js +++ /dev/null @@ -1,151 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var filledndBy = require( './../../../base/fillednd-by' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pkg = require( './../package.json' ).name; -var atnd = require( './../lib' ); - - -// MAIN // - -bench( pkg+':ndims=1', function benchmark( b ) { - var x; - var v; - var i; - var j; - - x = filledndBy( [ 10 ], uniform( 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = ( i%20 ) - 10; - v = atnd( x, j ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=2', function benchmark( b ) { - var x; - var v; - var i; - var j; - - x = filledndBy( [ 10, 10 ], uniform( 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = ( i%20 ) - 10; - v = atnd( x, j, j ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=3', function benchmark( b ) { - var x; - var v; - var i; - var j; - - x = filledndBy( [ 10, 10, 10 ], uniform( 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = ( i%20 ) - 10; - v = atnd( x, j, j, j ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=4', function benchmark( b ) { - var x; - var v; - var i; - var j; - - x = filledndBy( [ 10, 10, 10, 10 ], uniform( 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = ( i%20 ) - 10; - v = atnd( x, j, j, j, j ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=5', function benchmark( b ) { - var x; - var v; - var i; - var j; - - x = filledndBy( [ 10, 10, 10, 10, 10 ], uniform( 0.0, 10.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = ( i%20 ) - 10; - v = atnd( x, j, j, j, j, j ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/atnd/docs/repl.txt b/base/atnd/docs/repl.txt deleted file mode 100644 index 2299c9c53..000000000 --- a/base/atnd/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, i0[, ...indices] ) - Returns an element from an n-dimensional nested array. - - Negative indices are resolved relative to the last element along the - respective dimension, with the last element corresponding to `-1`. - - If provided out-of-bounds indices, the function always returns `undefined`. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - i0: integer - First dimension index. - - indices: ...integer (optional) - Dimension indices. - - Returns - ------- - out: any - Element value. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > {{alias}}( x, 0, 1 ) - 2 - > {{alias}}( x, 1, 0 ) - 3 - - See Also - -------- - diff --git a/base/atnd/docs/types/index.d.ts b/base/atnd/docs/types/index.d.ts deleted file mode 100644 index fe8b7951e..000000000 --- a/base/atnd/docs/types/index.d.ts +++ /dev/null @@ -1,305 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D, Array5D, Array6D, Array7D, Array8D, Array9D, Array10D } from '@stdlib/types/array'; - -/** -* Returns an element from a ten-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @param i2 - third dimension index -* @param i3 - fourth dimension index -* @param i4 - fifth dimension index -* @param i5 - sixth dimension index -* @param i6 - seventh dimension index -* @param i7 - eighth dimension index -* @param i8 - ninth dimension index -* @param i9 - tenth dimension index -* @returns nested array element -* -* @example -* var x = [ [ [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ] ] ]; -* -* var v = atnd( x, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2 ); -* // returns 1 -*/ -declare function atnd( x: Array10D, i0: number, i1: number, i2: number, i3: number, i4: number, i5: number, i6: number, i7: number, i8: number, i9: number ): T | void; - -/** -* Returns an element from a nine-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @param i2 - third dimension index -* @param i3 - fourth dimension index -* @param i4 - fifth dimension index -* @param i5 - sixth dimension index -* @param i6 - seventh dimension index -* @param i7 - eighth dimension index -* @param i8 - ninth dimension index -* @returns nested array element -* -* @example -* var x = [ [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ] ]; -* -* var v = atnd( x, 0, 0, 0, 0, 0, 0, 0, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 0, 0, 0, 0, 0, 0, 0, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -1, -1, -1, -1, -1, -1, -1, -2, -2 ); -* // returns 1 -*/ -declare function atnd( x: Array9D, i0: number, i1: number, i2: number, i3: number, i4: number, i5: number, i6: number, i7: number, i8: number ): T | void; - -/** -* Returns an element from an eight-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @param i2 - third dimension index -* @param i3 - fourth dimension index -* @param i4 - fifth dimension index -* @param i5 - sixth dimension index -* @param i6 - seventh dimension index -* @param i7 - eighth dimension index -* @returns nested array element -* -* @example -* var x = [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ]; -* -* var v = atnd( x, 0, 0, 0, 0, 0, 0, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 0, 0, 0, 0, 0, 0, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -1, -1, -1, -1, -1, -1, -2, -2 ); -* // returns 1 -*/ -declare function atnd( x: Array8D, i0: number, i1: number, i2: number, i3: number, i4: number, i5: number, i6: number, i7: number ): T | void; - -/** -* Returns an element from a seven-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @param i2 - third dimension index -* @param i3 - fourth dimension index -* @param i4 - fifth dimension index -* @param i5 - sixth dimension index -* @param i6 - seventh dimension index -* @returns nested array element -* -* @example -* var x = [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ]; -* -* var v = atnd( x, 0, 0, 0, 0, 0, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 0, 0, 0, 0, 0, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -1, -1, -1, -1, -1, -2, -2 ); -* // returns 1 -*/ -declare function atnd( x: Array7D, i0: number, i1: number, i2: number, i3: number, i4: number, i5: number, i6: number ): T | void; - -/** -* Returns an element from a six-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @param i2 - third dimension index -* @param i3 - fourth dimension index -* @param i4 - fifth dimension index -* @param i5 - sixth dimension index -* @returns nested array element -* -* @example -* var x = [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ]; -* -* var v = atnd( x, 0, 0, 0, 0, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 0, 0, 0, 0, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -1, -1, -1, -1, -2, -2 ); -* // returns 1 -*/ -declare function atnd( x: Array6D, i0: number, i1: number, i2: number, i3: number, i4: number, i5: number ): T | void; - -/** -* Returns an element from a five-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @param i2 - third dimension index -* @param i3 - fourth dimension index -* @param i4 - fifth dimension index -* @returns nested array element -* -* @example -* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; -* -* var v = atnd( x, 0, 0, 0, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 0, 0, 0, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -1, -1, -1, -2, -2 ); -* // returns 1 -*/ -declare function atnd( x: Array5D, i0: number, i1: number, i2: number, i3: number, i4: number ): T | void; - -/** -* Returns an element from a four-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @param i2 - third dimension index -* @param i3 - fourth dimension index -* @returns nested array element -* -* @example -* var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; -* -* var v = atnd( x, 0, 0, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 0, 0, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -1, -1, -2, -2 ); -* // returns 1 -*/ -declare function atnd( x: Array4D, i0: number, i1: number, i2: number, i3: number ): T | void; - -/** -* Returns an element from a three-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @param i2 - third dimension index -* @returns nested array element -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -* -* var v = atnd( x, 0, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 0, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -1, -2, -2 ); -* // returns 1 -*/ -declare function atnd( x: Array3D, i0: number, i1: number, i2: number ): T | void; - -/** -* Returns an element from a two-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param i1 - second dimension index -* @returns nested array element -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var v = atnd( x, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -2, -2 ); -* // returns 1 -*/ -declare function atnd( x: Array2D, i0: number, i1: number ): T | void; - -/** -* Returns an element from a one-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @returns nested array element -* -* @example -* var x = [ 1, 2 ]; -* -* var v = atnd( x, 1 ); -* // returns 2 -* -* v = atnd( x, 0 ); -* // returns 1 -* -* v = atnd( x, -2 ); -* // returns 1 -*/ -declare function atnd( x: Array1D, i0: number ): T | void; - -/** -* Returns an element from an n-dimensional nested array. -* -* @param x - input array -* @param i0 - first dimension index -* @param indices - dimension indices -* @returns nested array element -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var v = atnd( x, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -2, -2 ); -* // returns 1 -*/ -declare function atnd( x: Array, i0: number, ...indices: Array ): U | void; - - -// EXPORTS // - -export = atnd; diff --git a/base/atnd/docs/types/test.ts b/base/atnd/docs/types/test.ts deleted file mode 100644 index 406e55717..000000000 --- a/base/atnd/docs/types/test.ts +++ /dev/null @@ -1,115 +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. -*/ - -import atnd = require( './index' ); - - -// TESTS // - -// The function returns an array element... -{ - const x1 = [ 1, 2 ]; - atnd( x1, 0 ); // $ExpectType number | void - - const x2 = [ [ 1, 2 ], [ 3, 4 ] ]; - atnd( x2, 0, 0 ); // $ExpectType number | void - - const x3 = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - atnd( x3, 0, 0, 0 ); // $ExpectType number | void - - const x4 = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - atnd( x4, 0, 0, 0, 0 ); // $ExpectType number | void - - const x5 = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - atnd( x5, 0, 0, 0, 0, 0 ); // $ExpectType number | void -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - atnd( 5, 0 ); // $ExpectError - atnd( true, 0 ); // $ExpectError - atnd( false, 0 ); // $ExpectError - atnd( null, 0 ); // $ExpectError - atnd( void 0, 0 ); // $ExpectError - atnd( {}, 0 ); // $ExpectError - atnd( ( x: number ): number => x, 0 ); // $ExpectError - - atnd( 5, 0, 0 ); // $ExpectError - atnd( true, 0, 0 ); // $ExpectError - atnd( false, 0, 0 ); // $ExpectError - atnd( null, 0, 0 ); // $ExpectError - atnd( void 0, 0, 0 ); // $ExpectError - atnd( {}, 0, 0 ); // $ExpectError - atnd( ( x: number ): number => x, 0, 0 ); // $ExpectError - - atnd( 5, 0, 0, 0 ); // $ExpectError - atnd( true, 0, 0, 0 ); // $ExpectError - atnd( false, 0, 0, 0 ); // $ExpectError - atnd( null, 0, 0, 0 ); // $ExpectError - atnd( void 0, 0, 0, 0 ); // $ExpectError - atnd( {}, 0, 0, 0 ); // $ExpectError - atnd( ( x: number ): number => x, 0, 0, 0 ); // $ExpectError - - atnd( 5, 0, 0, 0, 0 ); // $ExpectError - atnd( true, 0, 0, 0, 0 ); // $ExpectError - atnd( false, 0, 0, 0, 0 ); // $ExpectError - atnd( null, 0, 0, 0, 0 ); // $ExpectError - atnd( void 0, 0, 0, 0, 0 ); // $ExpectError - atnd( {}, 0, 0, 0, 0 ); // $ExpectError - atnd( ( x: number ): number => x, 0, 0, 0, 0 ); // $ExpectError - - atnd( 'abc', 0, 0, 0, 0, 0 ); // $ExpectError - atnd( 5, 0, 0, 0, 0, 0 ); // $ExpectError - atnd( true, 0, 0, 0, 0, 0 ); // $ExpectError - atnd( false, 0, 0, 0, 0, 0 ); // $ExpectError - atnd( null, 0, 0, 0, 0, 0 ); // $ExpectError - atnd( void 0, 0, 0, 0, 0, 0 ); // $ExpectError - atnd( {}, 0, 0, 0, 0, 0 ); // $ExpectError - atnd( ( x: number ): number => x, 0, 0, 0, 0, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an index argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - atnd( x, 'abc', 0 ); // $ExpectError - atnd( x, true, 0 ); // $ExpectError - atnd( x, false, 0 ); // $ExpectError - atnd( x, null, 0 ); // $ExpectError - atnd( x, void 0, 0 ); // $ExpectError - atnd( x, [ '1' ], 0 ); // $ExpectError - atnd( x, {}, 0 ); // $ExpectError - atnd( x, ( x: number ): number => x, 0 ); // $ExpectError - - atnd( x, 0, 'abc' ); // $ExpectError - atnd( x, 0, true ); // $ExpectError - atnd( x, 0, false ); // $ExpectError - atnd( x, 0, null ); // $ExpectError - atnd( x, 0, void 0 ); // $ExpectError - atnd( x, 0, [ '1' ] ); // $ExpectError - atnd( x, 0, {} ); // $ExpectError - atnd( x, 0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - atnd(); // $ExpectError - atnd( x ); // $ExpectError -} diff --git a/base/atnd/examples/index.js b/base/atnd/examples/index.js deleted file mode 100644 index 17cf54dbe..000000000 --- a/base/atnd/examples/index.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -var papply = require( '@stdlib/utils/papply' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var binary2d = require( './../../../base/binary2d' ); -var zeros2d = require( './../../../base/zeros2d' ); -var atnd = require( './../lib' ); - -var shape = [ 5, 5 ]; - -// Define a nested input array: -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -// Define arrays containing random index values: -var i0 = filled2dBy( shape, discreteUniform( -shape[0], shape[0]-1 ) ); -console.log( i0 ); - -var i1 = filled2dBy( shape, discreteUniform( -shape[1], shape[1]-1 ) ); -console.log( i1 ); - -// Define an output array: -var out = zeros2d( shape ); -console.log( out ); - -// Fill the output array with randomly selected values from the input array: -binary2d( [ i0, i1, out ], shape, papply( atnd, x ) ); -console.log( out ); diff --git a/base/atnd/lib/index.js b/base/atnd/lib/index.js deleted file mode 100644 index faf59b865..000000000 --- a/base/atnd/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Return an element from an n-dimensional nested array. -* -* @module @stdlib/array/base/atnd -* -* @example -* var atnd = require( '@stdlib/array/base/atnd' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var v = atnd( x, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -2, -2 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/atnd/lib/main.js b/base/atnd/lib/main.js deleted file mode 100644 index b1528fe26..000000000 --- a/base/atnd/lib/main.js +++ /dev/null @@ -1,72 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an element from an n-dimensional nested array. -* -* @param {ArrayLikeObject} x - input array -* @param {integer} i0 - first dimension index -* @param {...integer} indices - dimension indices -* @returns {*} nested array element -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var v = atnd( x, 0, 1 ); -* // returns 2 -* -* v = atnd( x, 1, 0 ); -* // returns 3 -* -* v = atnd( x, -2, -2 ); -* // returns 1 -*/ -function atnd( x, i0 ) { - var value; - var idx; - var N; - var i; - var j; - - idx = [ i0 ]; - for ( i = 2; i < arguments.length; i++ ) { - idx.push( arguments[ i ] ); - } - value = x; - for ( i = 0; i < idx.length; i++ ) { - j = idx[ i ]; - N = value.length; - if ( j < 0 ) { - j += N; - } - if ( j < 0 || j >= N ) { - return; - } - value = value[ j ]; - } - return value; -} - - -// EXPORTS // - -module.exports = atnd; diff --git a/base/atnd/package.json b/base/atnd/package.json deleted file mode 100644 index 3b4ef4d51..000000000 --- a/base/atnd/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/atnd", - "version": "0.0.0", - "description": "Return an element from an n-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "nd", - "at", - "get", - "getter", - "accessor", - "access", - "retrieve" - ], - "__stdlib__": {} -} diff --git a/base/atnd/test/test.js b/base/atnd/test/test.js deleted file mode 100644 index 62c202db7..000000000 --- a/base/atnd/test/test.js +++ /dev/null @@ -1,592 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var nCartesianProduct = require( './../../../base/n-cartesian-product' ); -var filledndBy = require( './../../../base/fillednd-by' ); -var flatten = require( './../../../base/flatten' ); -var incrspace = require( './../../../base/incrspace' ); -var atnd = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof atnd, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a nested array element (empty)', function test( t ) { - var actual = atnd( [], 0 ); - t.strictEqual( actual, void 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a nested array element (ndims=1, positive indices)', function test( t ) { - var expected; - var actual; - var shape; - var i0; - var x; - var i; - - shape = [ 5 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0], 1 ); - expected = flatten( x, shape ); - - for ( i = 0; i < i0.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( [ i0[ i ] ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+i0[ i ]+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (ndims=1, negative indices)', function test( t ) { - var expected; - var actual; - var shape; - var i0; - var x; - var i; - - shape = [ 5 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0], 0, 1 ); - expected = flatten( x, shape ); - - for ( i = 0; i < i0.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( [ i0[ i ] ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+i0[ i ]+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (ndims=1, positive indices)', function test( t ) { - var expected; - var actual; - var shape; - var i0; - var x; - var i; - - shape = [ 5 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( shape[0], shape[0]+5, 1 ); - expected = void 0; - - for ( i = 0; i < i0.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( [ i0[ i ] ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+i0[ i ]+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (ndims=1, negative indices)', function test( t ) { - var expected; - var actual; - var shape; - var i0; - var x; - var i; - - shape = [ 5 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0]-5, -shape[0], 1 ); - expected = void 0; - - for ( i = 0; i < i0.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( [ i0[ i ] ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+i0[ i ]+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (ndims=2, positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var x; - var i; - - shape = [ 5, 5 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0], 1 ); - i1 = incrspace( 0, shape[1], 1 ); - indices = nCartesianProduct( i0, i1 ); - - expected = flatten( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (ndims=2, negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var x; - var i; - - shape = [ 5, 5 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0], 0, 1 ); - i1 = incrspace( -shape[1], 0, 1 ); - indices = nCartesianProduct( i0, i1 ); - - expected = flatten( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (ndims=2, positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var x; - var i; - - shape = [ 5, 5 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0]+5, 1 ); - i1 = incrspace( shape[1], shape[1]+5, 1 ); - indices = nCartesianProduct( i0, i1 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (ndims=2, negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var x; - var i; - - shape = [ 5, 5 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0]-5, 0, 1 ); - i1 = incrspace( -shape[1]-5, -shape[1], 1 ); - indices = nCartesianProduct( i0, i1 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (ndims=3, positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var x; - var i; - - shape = [ 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0], 1 ); - i1 = incrspace( 0, shape[1], 1 ); - i2 = incrspace( 0, shape[2], 1 ); - indices = nCartesianProduct( i0, i1, i2 ); - - expected = flatten( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (ndims=3, negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var x; - var i; - - shape = [ 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0], 0, 1 ); - i1 = incrspace( -shape[1], 0, 1 ); - i2 = incrspace( -shape[2], 0, 1 ); - indices = nCartesianProduct( i0, i1, i2 ); - - expected = flatten( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (ndims=3, positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var x; - var i; - - shape = [ 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0]+5, 1 ); - i1 = incrspace( 0, shape[1]+5, 1 ); - i2 = incrspace( shape[2], shape[2]+5, 1 ); - indices = nCartesianProduct( i0, i1, i2 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (ndims=3, negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var x; - var i; - - shape = [ 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0]-5, 0, 1 ); - i1 = incrspace( -shape[1]-5, 0, 1 ); - i2 = incrspace( -shape[2]-5, -shape[2], 1 ); - indices = nCartesianProduct( i0, i1, i2 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (ndims=4, positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var x; - var i; - - shape = [ 2, 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0], 1 ); - i1 = incrspace( 0, shape[1], 1 ); - i2 = incrspace( 0, shape[2], 1 ); - i3 = incrspace( 0, shape[3], 1 ); - indices = nCartesianProduct( i0, i1, i2, i3 ); - - expected = flatten( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (ndims=4, negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var x; - var i; - - shape = [ 2, 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0], 0, 1 ); - i1 = incrspace( -shape[1], 0, 1 ); - i2 = incrspace( -shape[2], 0, 1 ); - i3 = incrspace( -shape[3], 0, 1 ); - indices = nCartesianProduct( i0, i1, i2, i3 ); - - expected = flatten( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (ndims=4, positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var x; - var i; - - shape = [ 2, 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0]+5, 1 ); - i1 = incrspace( 0, shape[1]+5, 1 ); - i2 = incrspace( 0, shape[2]+5, 1 ); - i3 = incrspace( shape[3], shape[3]+5, 1 ); - indices = nCartesianProduct( i0, i1, i2, i3 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (ndims=4, negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var x; - var i; - - shape = [ 2, 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0]-5, 0, 1 ); - i1 = incrspace( -shape[1]-5, 0, 1 ); - i2 = incrspace( -shape[2]-5, 0, 1 ); - i3 = incrspace( -shape[3]-5, -shape[3], 1 ); - indices = nCartesianProduct( i0, i1, i2, i3 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (ndims=5, positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var i4; - var x; - var i; - - shape = [ 2, 2, 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0], 1 ); - i1 = incrspace( 0, shape[1], 1 ); - i2 = incrspace( 0, shape[2], 1 ); - i3 = incrspace( 0, shape[3], 1 ); - i4 = incrspace( 0, shape[4], 1 ); - indices = nCartesianProduct( i0, i1, i2, i3, i4 ); - - expected = flatten( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns a nested array element (ndims=5, negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var i4; - var x; - var i; - - shape = [ 2, 2, 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0], 0, 1 ); - i1 = incrspace( -shape[1], 0, 1 ); - i2 = incrspace( -shape[2], 0, 1 ); - i3 = incrspace( -shape[3], 0, 1 ); - i4 = incrspace( -shape[4], 0, 1 ); - indices = nCartesianProduct( i0, i1, i2, i3, i4 ); - - expected = flatten( x, shape ); - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected[ i ], 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (ndims=5, positive indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var i4; - var x; - var i; - - shape = [ 2, 2, 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( 0, shape[0]+5, 1 ); - i1 = incrspace( 0, shape[1]+5, 1 ); - i2 = incrspace( 0, shape[2]+5, 1 ); - i3 = incrspace( 0, shape[3]+5, 1 ); - i4 = incrspace( shape[4], shape[4]+5, 1 ); - indices = nCartesianProduct( i0, i1, i2, i3, i4 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); - -tape( 'the function returns `undefined` if provided an out-of-bounds index (ndims=5, negative indices)', function test( t ) { - var expected; - var indices; - var actual; - var shape; - var i0; - var i1; - var i2; - var i3; - var i4; - var x; - var i; - - shape = [ 2, 2, 2, 2, 2 ]; - x = filledndBy( shape, discreteUniform( 0, 10 ) ); - - i0 = incrspace( -shape[0]-5, 0, 1 ); - i1 = incrspace( -shape[1]-5, 0, 1 ); - i2 = incrspace( -shape[2]-5, 0, 1 ); - i3 = incrspace( -shape[3]-5, 0, 1 ); - i4 = incrspace( -shape[4]-5, -shape[4], 1 ); - indices = nCartesianProduct( i0, i1, i2, i3, i4 ); - - expected = void 0; - - for ( i = 0; i < indices.length; i++ ) { - actual = atnd.apply( null, [ x ].concat( indices[ i ] ) ); - t.strictEqual( actual, expected, 'returns expected value for indices ('+indices[ i ].join( ',' )+')' ); - } - t.end(); -}); diff --git a/base/banded/README.md b/base/banded/README.md deleted file mode 100644 index 1366bf4da..000000000 --- a/base/banded/README.md +++ /dev/null @@ -1,120 +0,0 @@ - - -# Banded Arrays - -> Banded array utilities. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ns = require( '@stdlib/array/base/banded' ); -``` - -#### ns - -Namespace containing banded array utilities. - -```javascript -var o = ns; -// returns {...} -``` - -The namespace exports the following: - - - -
- -- [`filled2dBy( shape, ku, kl, fill, clbk[, thisArg] )`][@stdlib/array/base/banded/filled2d-by]: create a filled two-dimensional banded nested array according to a provided callback function. -- [`toCompact( arr, ku, kl, colexicographic )`][@stdlib/array/base/banded/to-compact]: convert a two-dimensional banded nested array to compact banded storage. - -
- - - -
- - - - - -
- -
- - - - - -
- -## Examples - - - - - -```javascript -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( '@stdlib/array/base/banded' ); - -console.log( objectKeys( ns ) ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/banded/docs/types/index.d.ts b/base/banded/docs/types/index.d.ts deleted file mode 100644 index 58b2bb4c2..000000000 --- a/base/banded/docs/types/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import filled2dBy = require( './../../../../base/banded/filled2d-by' ); - -/** -* Interface describing a namespace. -*/ -interface Namespace { - /** - * TODO - */ - filled2dBy: typeof filled2dBy; -} - -/** -* Banded array utilities. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/base/banded/docs/types/test.ts b/base/banded/docs/types/test.ts deleted file mode 100644 index 1a38cb7de..000000000 --- a/base/banded/docs/types/test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/base/banded/examples/index.js b/base/banded/examples/index.js deleted file mode 100644 index f5349d26c..000000000 --- a/base/banded/examples/index.js +++ /dev/null @@ -1,24 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/base/banded/filled2d-by/README.md b/base/banded/filled2d-by/README.md deleted file mode 100644 index c74fcf9b6..000000000 --- a/base/banded/filled2d-by/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# filled2dBy - -> Create a filled two-dimensional banded nested array according to a provided callback function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled2dBy = require( '@stdlib/array/base/banded/filled2d-by' ); -``` - -#### filled2dBy( shape, ku, kl, fill, clbk\[, thisArg] ) - -Returns a filled two-dimensional banded nested array according to a provided callback function. - -```javascript -function clbk( idx ) { - return idx[ 0 ] + idx[ 1 ]; -} - -var out = filled2dBy( [ 3, 3 ], 1, 1, 0, clbk ); -// returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] -``` - -The function accepts the following arguments: - -- **shape**: array shape. -- **ku**: number of super-diagonals. -- **kl**: number of sub-diagonals. -- **fill**: fill value for elements outside the band. -- **clbk**: callback function. -- **thisArg**: callback function execution context (_optional_). - -When invoked, a callback function is provided a single argument: - -- **indices**: current array element indices. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function clbk() { - this.count += 1; - return 1; -} - -var ctx = { - 'count': 0 -}; - -var out = filled2dBy( [ 2, 2 ], 1, 0, 0, clbk, ctx ); -// returns [ [ 1, 1 ], [ 0, 1 ] ]; - -var cnt = ctx.count; -// returns 3 -``` - -
- - - - - -
- -## Notes - -- As the output array is banded, the callback function is only invoked for the elements residing within the band. - -
- - - - - -
- -## Examples - - - -```javascript -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( '@stdlib/array/base/banded/filled2d-by' ); - -function clbk( indices ) { - return indices[ 0 ] + indices[ 1 ]; -} - -var out = filled2dBy( [ 4, 4 ], 1, 1, 0, clbk ); -// returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ] - -out = filled2dBy( [ 3, 3 ], 1, 0, null, constantFunction( 'beep' ) ); -// returns [ [ 'beep', 'beep', null ], [ null, 'beep', 'beep' ], [ null, null, 'beep' ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/banded/filled2d-by/benchmark/benchmark.size.js b/base/banded/filled2d-by/benchmark/benchmark.size.js deleted file mode 100644 index 20892dac6..000000000 --- a/base/banded/filled2d-by/benchmark/benchmark.size.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filled2dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @param {NonNegativeInteger} ku - number of super-diagonals -* @param {NonNegativeInteger} kl - number of sub-diagonals -* @returns {Function} benchmark function -*/ -function createBenchmark( N, ku, kl ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( N ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled2dBy( [ N, N ], ku, kl, 0, f ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - var k; - - min = 1; // 10^min - max = 6; // 10^max - - k = 1; - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N, k, k ); - bench( pkg+':ku='+k+',kl='+k+',size='+(N*N), f ); - } -} - -main(); diff --git a/base/banded/filled2d-by/docs/repl.txt b/base/banded/filled2d-by/docs/repl.txt deleted file mode 100644 index cc9989b59..000000000 --- a/base/banded/filled2d-by/docs/repl.txt +++ /dev/null @@ -1,46 +0,0 @@ - -{{alias}}( shape, ku, kl, fill, clbk[, thisArg] ) - Returns a filled two-dimensional banded nested array according to a provided - callback function. - - The callback function is provided one argument: - - - indices: current array element indices. - - As the output array is banded, the provided callback is only invoked for - elements within the band. - - Parameters - ---------- - shape: Array - Array shape. - - ku: integer - Number of super-diagonals. - - kl: integer - Number of sub-diagonals. - - fill: any - Fill value for elements outside the band. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function clbk( idx ) { return idx[ 0 ] + idx[ 1 ]; }; - > var out = {{alias}}( [ 3, 3 ], 1, 1, 0, clbk ) - [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] - - See Also - -------- - diff --git a/base/banded/filled2d-by/docs/types/index.d.ts b/base/banded/filled2d-by/docs/types/index.d.ts deleted file mode 100644 index d4c18096d..000000000 --- a/base/banded/filled2d-by/docs/types/index.d.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = ( this: V ) => T; - -/** -* Unary callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Unary = ( this: V, indices: [ number, number ] ) => T; - -/** -* Callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Two-dimensional nested array. -*/ -type Array2D = Array>; - -/** -* Returns a filled two-dimensional banded nested array according to a provided callback function. -* -* @param shape - array shape -* @param ku - number of super-diagonals -* @param kl - number of sub-diagonals -* @param fill - fill value for values outside the band -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns output array -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( [ 3, 3 ], 1, 1, 0, clbk ); -* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] -*/ -declare function filled2dBy( shape: Shape2D, ku: number, kl: number, fill: U, clbk: Callback, thisArg?: ThisParameterType> ): Array2D; - - -// EXPORTS // - -export = filled2dBy; diff --git a/base/banded/filled2d-by/docs/types/test.ts b/base/banded/filled2d-by/docs/types/test.ts deleted file mode 100644 index 11d86ac04..000000000 --- a/base/banded/filled2d-by/docs/types/test.ts +++ /dev/null @@ -1,123 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import filled2dBy = require( './index' ); - -/** -* Callback function. -* -* @param indices - array element indices -* @returns return value -*/ -function clbk( indices: Array ): number { - return indices[ 1 ]; -} - - -// TESTS // - -// The function returns an array... -{ - filled2dBy( [ 3, 3 ], 1, 1, 0, clbk ); // $ExpectType Array2D - filled2dBy( [ 3, 3 ], 1, 1, 0, clbk, {} ); // $ExpectType Array2D - filled2dBy( [ 3, 3 ], 1, 1, null, clbk, {} ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - filled2dBy( 'abc', 1, 1, 0, clbk ); // $ExpectError - filled2dBy( true, 1, 1, 0, clbk ); // $ExpectError - filled2dBy( false, 1, 1, 0, clbk ); // $ExpectError - filled2dBy( null, 1, 1, 0, clbk ); // $ExpectError - filled2dBy( [ '1', 1 ], 1, 1, 0, clbk ); // $ExpectError - filled2dBy( {}, 1, 1, 0, clbk ); // $ExpectError - filled2dBy( ( x: number ): number => x, 1, 1, 0, clbk ); // $ExpectError - - filled2dBy( 'abc', 1, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( true, 1, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( false, 1, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( null, 1, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( [ '1', 1 ], 1, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( {}, 1, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( ( x: number ): number => x, 1, 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - filled2dBy( [ 3, 3 ], 'abc', 1, 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], true, 1, 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], false, 1, 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], null, 1, 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], [ '1', 1 ], 1, 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], {}, 1, 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], ( x: number ): number => x, 1, 0, clbk ); // $ExpectError - - filled2dBy( [ 3, 3 ], 'abc', 1, 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], true, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], false, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], null, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], [ '1', 1 ], 1, 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], {}, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], ( x: number ): number => x, 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - filled2dBy( [ 3, 3 ], 1, 'abc', 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, true, 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, false, 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, null, 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, [ '1', 1 ], 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, {}, 0, clbk ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, ( x: number ): number => x, 0, clbk ); // $ExpectError - - filled2dBy( [ 3, 3 ], 1, 'abc', 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, true, 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, false, 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, null, 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, [ '1', 1 ], 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, {}, 0, clbk, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, ( x: number ): number => x, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a callback... -{ - filled2dBy( [ 3, 3 ], 1, 1, 0, 'abc' ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0, true ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0, false ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0, null ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0, [] ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0, {} ); // $ExpectError - - filled2dBy( [ 3, 3 ], 1, 1, 0, 'abc', {} ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0, true, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0, false, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0, null, {} ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0, [], {} ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled2dBy(); // $ExpectError - filled2dBy( [ 3, 3 ] ); // $ExpectError - filled2dBy( [ 3, 3 ], 1 ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1 ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0 ); // $ExpectError - filled2dBy( [ 3, 3 ], 1, 1, 0, clbk, 2, 2 ); // $ExpectError -} diff --git a/base/banded/filled2d-by/examples/index.js b/base/banded/filled2d-by/examples/index.js deleted file mode 100644 index 02325dcfa..000000000 --- a/base/banded/filled2d-by/examples/index.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( './../lib' ); - -function clbk( indices ) { - return indices[ 0 ] + indices[ 1 ]; -} - -var out = filled2dBy( [ 4, 4 ], 1, 1, 0, clbk ); -console.log( out ); -// => [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ] - -out = filled2dBy( [ 3, 3 ], 1, 0, null, constantFunction( 'beep' ) ); -console.log( out ); -// => [ [ 'beep', 'beep', null ], [ null, 'beep', 'beep' ], [ null, null, 'beep' ] ] diff --git a/base/banded/filled2d-by/lib/index.js b/base/banded/filled2d-by/lib/index.js deleted file mode 100644 index 515658ba6..000000000 --- a/base/banded/filled2d-by/lib/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a filled two-dimensional banded nested array according to a provided callback function. -* -* @module @stdlib/array/base/banded/filled2d-by -* -* @example -* var filled2dBy = require( '@stdlib/array/base/banded/filled2d-by' ); -* -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( [ 3, 3 ], 1, 1, 0, clbk ); -* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] -* -* @example -* var filled2dBy = require( '@stdlib/array/base/banded/filled2d-by' ); -* -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( [ 4, 4 ], 1, 1, 0, clbk ); -* // returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/banded/filled2d-by/lib/main.js b/base/banded/filled2d-by/lib/main.js deleted file mode 100644 index a648175da..000000000 --- a/base/banded/filled2d-by/lib/main.js +++ /dev/null @@ -1,118 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a filled two-dimensional banded nested array according to a provided callback function. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {NonNegativeInteger} ku - number of super-diagonals -* @param {NonNegativeInteger} kl - number of sub-diagonals -* @param {*} fill - fill value for values outside the band -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback function execution context -* @returns {Array} filled array -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( [ 3, 3 ], 1, 1, 0, clbk ); -* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( [ 4, 4 ], 1, 1, 0, clbk ); -* // returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ] -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( [ 4, 4 ], 2, 1, 0, clbk ); -* // returns [ [ 0, 1, 2, 0 ], [ 1, 2, 3, 4 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ] -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( [ 4, 4 ], 0, 2, 0, clbk ); -* // returns [ [ 0, 0, 0, 0 ], [ 1, 2, 0, 0 ], [ 2, 3, 4, 0 ], [ 0, 4, 5, 6 ] ] -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( [ 3, 4 ], 1, 1, 0, clbk ); -* // returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ] ] -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( [ 4, 3 ], 1, 1, 0, clbk ); -* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ], [ 0, 0, 5 ] ] -*/ -function filled2dBy( shape, ku, kl, fill, clbk, thisArg ) { - var arr; - var a0; - var S0; - var S1; - var i0; - var i1; - - S1 = shape[ 0 ]; // rows - S0 = shape[ 1 ]; // columns - - // Manually push elements in order to ensure "fast" elements... - arr = []; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - // Check whether we are within the band... - if ( - ( i0 >= i1 && i0 <= i1+ku ) || // super-diagonals - ( i0 <= i1 && i1 <= i0+kl ) // sub-diagonals - ) { - a0.push( clbk.call( thisArg, [ i1, i0 ] ) ); - } - // Otherwise, we are outside the band... - else { - a0.push( fill ); - } - } - arr.push( a0 ); - } - return arr; -} - - -// EXPORTS // - -module.exports = filled2dBy; diff --git a/base/banded/filled2d-by/package.json b/base/banded/filled2d-by/package.json deleted file mode 100644 index 266559bbe..000000000 --- a/base/banded/filled2d-by/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@stdlib/array/base/banded/filled2d-by", - "version": "0.0.0", - "description": "Create a filled two-dimensional banded nested array according to a provided callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "callback", - "map", - "foreach", - "multidimensional", - "matrix", - "strided", - "ndarray", - "2d", - "banded", - "band" - ] -} diff --git a/base/banded/filled2d-by/test/test.js b/base/banded/filled2d-by/test/test.js deleted file mode 100644 index 9f2a0b689..000000000 --- a/base/banded/filled2d-by/test/test.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled2dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled banded nested array', function test( t ) { - var expected; - var actual; - - expected = [ [ 'beep', 'beep' ], [ 'beep', 'beep' ] ]; - actual = filled2dBy( [ 2, 2 ], 1, 1, null, constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ] ]; - actual = filled2dBy( [ 3, 3 ], 2, 2, -1, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0, 1, -1 ], [ 1, 2, 3 ], [ -1, 3, 4 ] ]; - actual = filled2dBy( [ 3, 3 ], 1, 1, -1, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0, -1, -1 ], [ -1, 2, -1 ], [ -1, -1, 4 ] ]; - actual = filled2dBy( [ 3, 3 ], 0, 0, -1, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0, 1, -1 ], [ -1, 2, 3 ], [ -1, -1, 4 ] ]; - actual = filled2dBy( [ 3, 3 ], 1, 0, -1, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0, -1, -1 ], [ 1, 2, -1 ], [ -1, 3, 4 ] ]; - actual = filled2dBy( [ 3, 3 ], 0, 1, -1, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ], [ -1, 4, 5 ] ]; - actual = filled2dBy( [ 4, 3 ], 2, 2, -1, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0, 1, 2, -1 ], [ 1, 2, 3, 4 ], [ 2, 3, 4, 5 ] ]; - actual = filled2dBy( [ 3, 4 ], 2, 2, -1, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( idx ) { - return idx[ 0 ] + idx[ 1 ]; - } -}); - -tape( 'the function returns an empty outer array if provided a first argument having a first element is equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - actual = filled2dBy( [ 0, 1 ], 1, 1, null, constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = filled2dBy( [ 0, 100 ], 1, 1, null, constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - - ctx = { - 'count': 0 - }; - expected = [ [ 'beep', 'beep' ], [ null, 'beep' ] ]; - actual = filled2dBy( [ 2, 2 ], 1, 0, null, clbk, ctx ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function clbk() { - this.count += 1; // eslint-disable-line no-invalid-this - return 'beep'; - } -}); - -tape( 'the function invokes a provided callback function with one argument', function test( t ) { - var expected; - var actual; - var idx; - - idx = []; - actual = filled2dBy( [ 3, 3 ], 1, 1, '', clbk ); - - expected = [ [ 'beep', 'beep', '' ], [ 'beep', 'beep', 'beep' ], [ '', 'beep', 'beep' ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 0 ], - [ 0, 1 ], - [ 1, 0 ], - [ 1, 1 ], - [ 1, 2 ], - [ 2, 1 ], - [ 2, 2 ] - ]; - t.deepEqual( idx, expected, 'returns expected value' ); - - t.end(); - - function clbk( indices ) { - idx.push( indices ); - return 'beep'; - } -}); diff --git a/base/banded/lib/index.js b/base/banded/lib/index.js deleted file mode 100644 index ac963562a..000000000 --- a/base/banded/lib/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name filled2dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/banded/filled2d-by} -*/ -setReadOnly( ns, 'filled2dBy', require( './../../../base/banded/filled2d-by' ) ); - -/** -* @name toCompact -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/banded/to-compact} -*/ -setReadOnly( ns, 'toCompact', require( './../../../base/banded/to-compact' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/base/banded/package.json b/base/banded/package.json deleted file mode 100644 index ed115173d..000000000 --- a/base/banded/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/banded", - "version": "0.0.0", - "description": "Banded array utilities.", - "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/index.js", - "directories": { - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "array", - "banded", - "nested", - "utils", - "utilities", - "storage", - "compact", - "matrix", - "namespace" - ] -} diff --git a/base/banded/test/test.js b/base/banded/test/test.js deleted file mode 100644 index d1e6eeb40..000000000 --- a/base/banded/test/test.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'returns expected value' ); - t.end(); -}); diff --git a/base/banded/to-compact/README.md b/base/banded/to-compact/README.md deleted file mode 100644 index 702abc64f..000000000 --- a/base/banded/to-compact/README.md +++ /dev/null @@ -1,166 +0,0 @@ - - -# toCompact - -> Convert a two-dimensional banded nested array to compact banded storage. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var toCompact = require( '@stdlib/array/base/banded/to-compact' ); -``` - -#### toCompact( arr, ku, kl, colexicographic ) - -Converts a two-dimensional banded nested array to compact banded storage. - -```javascript -var x = [ [ -1, 2, 0 ], [ 2, -2, 4 ], [ 0, 4, -3 ] ]; - -var out = toCompact( x, 1, 1, false ); -// returns [ [ 0, 2, 4 ], [ -1, -2, -3 ], [ 2, 4, 0 ] ] -``` - -The function accepts the following arguments: - -- **arr**: input two-dimensional nested array. -- **ku**: number of super-diagonals. -- **kl**: number of sub-diagonals. -- **colexicographic**: boolean specifying whether to store diagonals in colexicographic access order. - -
- - - - - -
- -
- - - - - -
- -## Examples - - - - - -```javascript -var toCompact = require( '@stdlib/array/base/banded/to-compact' ); - -// Define a banded matrix: -var A = [ - [ 1, 2, 3, 0, 0 ], - [ -2, 4, 5, 6, 0 ], - [ -3, -5, 7, 8, 9 ], - [ 0, -6, -8, 10, 11 ], - [ 0, 0, -9, -11, 12 ] -]; - -// Convert the matrix to lexicographic compact form: -var AC = toCompact( A, 2, 2, false ); -/* e.g., returns => - [ - [ 0, 0, 3, 6, 9 ], - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ], - [ -2, -5, -8, -11, 0 ], - [ -3, -6, -9, 0, 0 ] - ] -*/ - -AC = toCompact( A, 2, 1, false ); -/* e.g., returns => - [ - [ 0, 0, 3, 6, 9 ], - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ], - [ -2, -5, -8, -11, 0 ] - ] -*/ - -AC = toCompact( A, 1, 2, false ); -/* e.g., returns => - [ - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ], - [ -2, -5, -8, -11, 0 ], - [ -3, -6, -9, 0, 0 ] - ] -*/ - -// Convert the matrix to colexicographic compact form: -AC = toCompact( A, 2, 2, true ); -/* e.g., returns => - [ - [ 0, 0, 1, -2, -3 ], - [ 0, 2, 4, -5, -6 ], - [ 3, 5, 7, -8, -9 ], - [ 6, 8, 10, -11, 0 ], - [ 9, 11, 12, 0, 0 ] - ] -*/ -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/banded/to-compact/benchmark/benchmark.size.js b/base/banded/to-compact/benchmark/benchmark.size.js deleted file mode 100644 index 914271f15..000000000 --- a/base/banded/to-compact/benchmark/benchmark.size.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( './../../../../base/banded/filled2d-by' ); -var format = require( '@stdlib/string/format' ); -var pkg = require( './../package.json' ).name; -var toCompact = require( './../lib' ); - - -// VARIABLES // - -var orders = [ - true, - false -]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @param {boolean} colexicographic - boolean indicating whether to store diagonals in colexicographic access order -* @param {NonNegativeInteger} k - number of super-/sub-diagonals -* @returns {Function} benchmark function -*/ -function createBenchmark( N, colexicographic, k ) { - var x = filled2dBy( [ N, N ], k, k, 0, constantFunction( N ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = toCompact( x, k, k, colexicographic ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - var o; - var k; - - min = 1; // 10^min - max = 6; // 10^max - - k = 1; - for ( o = 0; o < orders.length; o++ ) { - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N, orders[ o ], k ); - bench( format( '%s:colexicographic=%s,ku=%d,kl=%d,size=%d', pkg, orders[ o ], k, k, N*N ), f ); - } - } -} - -main(); diff --git a/base/banded/to-compact/docs/repl.txt b/base/banded/to-compact/docs/repl.txt deleted file mode 100644 index 45971bcb7..000000000 --- a/base/banded/to-compact/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( arr, ku, kl, colexicographic ) - Converts a two-dimensional banded nested array to compact banded storage. - - Parameters - ---------- - arr: Array - Input array. - - ku: integer - Number of super-diagonals. - - kl: integer - Number of sub-diagonals. - - colexicographic: boolean - Specifies whether to store diagonals in colexicographic access order. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ -1, 2, 0 ], [ 2, -3, 4 ], [ 0, 4, -5 ] ]; - > var out = {{alias}}( x, 1, 1, false ) - [ [ 0, 2, 4 ], [ -1, -3, -5 ], [ 2, 4, 0 ] ] - - See Also - -------- - diff --git a/base/banded/to-compact/docs/types/index.d.ts b/base/banded/to-compact/docs/types/index.d.ts deleted file mode 100644 index 429562682..000000000 --- a/base/banded/to-compact/docs/types/index.d.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Two-dimensional nested array. -*/ -type Array2D = Array>; - -/** -* Converts a two-dimensional banded nested array to compact banded storage. -* -* @param arr - input two-dimensional array -* @param ku - number of super-diagonals -* @param kl - number of sub-diagonals -* @param colexicographic - specifies whether to store diagonals in colexicographic access order -* @returns output array -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 3, 12, 4 ], -* [ 0, 5, 13 ] -* ]; -* -* var out = toCompact( M, 1, 1, false ); -* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ], [ 3, 5, 0 ] ] -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 3, 12, 4 ], -* [ 0, 5, 13 ] -* ]; -* -* var out = toCompact( M, 1, 1, true ); -* // returns [ [ 0, 11, 3 ], [ 2, 12, 5 ], [ 4, 13, 0 ] ] -*/ -declare function toCompact( arr: Array2D, ku: number, kl: number, colexicographic: boolean ): Array2D; - - -// EXPORTS // - -export = toCompact; diff --git a/base/banded/to-compact/docs/types/test.ts b/base/banded/to-compact/docs/types/test.ts deleted file mode 100644 index 87a02288a..000000000 --- a/base/banded/to-compact/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import toCompact = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ 1, 2 ], [ 2, 1 ] ]; - - toCompact( x, 1, 1, true ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - toCompact( 'abc', 1, 1, true ); // $ExpectError - toCompact( true, 1, 1, true ); // $ExpectError - toCompact( false, 1, 1, true ); // $ExpectError - toCompact( null, 1, 1, true ); // $ExpectError - toCompact( [ '1', 1 ], 1, 1, true ); // $ExpectError - toCompact( {}, 1, 1, true ); // $ExpectError - toCompact( ( x: number ): number => x, 1, 1, true ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 2, 1 ] ]; - - toCompact( x, 'abc', 1, true ); // $ExpectError - toCompact( x, true, 1, true ); // $ExpectError - toCompact( x, false, 1, true ); // $ExpectError - toCompact( x, null, 1, true ); // $ExpectError - toCompact( x, [ '1', 1 ], 1, true ); // $ExpectError - toCompact( x, {}, 1, true ); // $ExpectError - toCompact( x, ( x: number ): number => x, 1, true ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 2, 1 ] ]; - - toCompact( x, 1, 'abc', true ); // $ExpectError - toCompact( x, 1, true, true ); // $ExpectError - toCompact( x, 1, false, true ); // $ExpectError - toCompact( x, 1, null, true ); // $ExpectError - toCompact( x, 1, [ '1', 1 ], true ); // $ExpectError - toCompact( x, 1, {}, true ); // $ExpectError - toCompact( x, 1, ( x: number ): number => x, true ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a boolean... -{ - const x = [ [ 1, 2 ], [ 2, 1 ] ]; - - toCompact( x, 1, 1, 'abc' ); // $ExpectError - toCompact( x, 1, 1, 5 ); // $ExpectError - toCompact( x, 1, 1, null ); // $ExpectError - toCompact( x, 1, 1, [ '1', 1 ] ); // $ExpectError - toCompact( x, 1, 1, {} ); // $ExpectError - toCompact( x, 1, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 2, 1 ] ]; - - toCompact(); // $ExpectError - toCompact( x ); // $ExpectError - toCompact( x, 1 ); // $ExpectError - toCompact( x, 1, 1 ); // $ExpectError - toCompact( x, 1, 1, true, {} ); // $ExpectError -} diff --git a/base/banded/to-compact/examples/index.js b/base/banded/to-compact/examples/index.js deleted file mode 100644 index d49147c47..000000000 --- a/base/banded/to-compact/examples/index.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-multi-spaces */ - -'use strict'; - -var toCompact = require( './../lib' ); - -// Define a banded matrix: -var A = [ - [ 1, 2, 3, 0, 0 ], - [ -2, 4, 5, 6, 0 ], - [ -3, -5, 7, 8, 9 ], - [ 0, -6, -8, 10, 11 ], - [ 0, 0, -9, -11, 12 ] -]; - -// Convert the matrix to lexicographic compact form: -var AC = toCompact( A, 2, 2, false ); -console.log( AC ); -/* e.g., => - [ - [ 0, 0, 3, 6, 9 ], - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ], - [ -2, -5, -8, -11, 0 ], - [ -3, -6, -9, 0, 0 ] - ] -*/ - -AC = toCompact( A, 2, 1, false ); -console.log( AC ); -/* e.g., => - [ - [ 0, 0, 3, 6, 9 ], - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ], - [ -2, -5, -8, -11, 0 ] - ] -*/ - -AC = toCompact( A, 1, 2, false ); -console.log( AC ); -/* e.g., => - [ - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ], - [ -2, -5, -8, -11, 0 ], - [ -3, -6, -9, 0, 0 ] - ] -*/ - -// Convert the matrix to colexicographic compact form: -AC = toCompact( A, 2, 2, true ); -console.log( AC ); -/* e.g., => - [ - [ 0, 0, 1, -2, -3 ], - [ 0, 2, 4, -5, -6 ], - [ 3, 5, 7, -8, -9 ], - [ 6, 8, 10, -11, 0 ], - [ 9, 11, 12, 0, 0 ] - ] -*/ diff --git a/base/banded/to-compact/lib/index.js b/base/banded/to-compact/lib/index.js deleted file mode 100644 index bf05d1afb..000000000 --- a/base/banded/to-compact/lib/index.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert a two-dimensional banded nested array to compact banded storage. -* -* @module @stdlib/array/base/banded/to-compact -* -* @example -* var toCompact = require( '@stdlib/array/base/banded/to-compact' ); -* -* var M = [ -* [ 11, 2, 0 ], -* [ 3, 12, 4 ], -* [ 0, 5, 13 ] -* ]; -* -* var out = toCompact( M, 1, 1, false ); -* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ], [ 3, 5, 0 ] ] -* -* @example -* var toCompact = require( '@stdlib/array/base/banded/to-compact' ); -* -* var M = [ -* [ 11, 2, 0 ], -* [ 3, 12, 4 ], -* [ 0, 5, 13 ] -* ]; -* -* var out = toCompact( M, 1, 1, true ); -* // returns [ [ 0, 11, 3 ], [ 2, 12, 5 ], [ 4, 13, 0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/banded/to-compact/lib/main.js b/base/banded/to-compact/lib/main.js deleted file mode 100644 index 97b906357..000000000 --- a/base/banded/to-compact/lib/main.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var max = require( '@stdlib/math/base/special/fast/max' ); -var min = require( '@stdlib/math/base/special/fast/min' ); -var zeros2d = require( './../../../../base/zeros2d' ); - - -// MAIN // - -/** -* Converts a two-dimensional banded nested array to compact banded storage. -* -* @param {Array} arr - input two-dimensional array -* @param {NonNegativeInteger} ku - number of super-diagonals -* @param {NonNegativeInteger} kl - number of sub-diagonals -* @param {boolean} colexicographic - specifies whether to store diagonals in colexicographic access order -* @returns {Array} output array -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 3, 12, 4 ], -* [ 0, 5, 13 ] -* ]; -* -* var out = toCompact( M, 1, 1, false ); -* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ], [ 3, 5, 0 ] ] -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 3, 12, 4 ], -* [ 0, 5, 13 ] -* ]; -* -* var out = toCompact( M, 1, 1, true ); -* // returns [ [ 0, 11, 3 ], [ 2, 12, 5 ], [ 4, 13, 0 ] ] -*/ -function toCompact( arr, ku, kl, colexicographic ) { - var out; - var to; - var M; - var N; - var i; - var j; - var k; - - M = arr.length; - N = arr[ 0 ].length; - - // Check whether to store diagonals along the columns... - if ( colexicographic ) { - out = zeros2d( [ N, ku+kl+1 ] ); - for ( j = 0; j < N; j++ ) { - to = out[ j ]; - k = ku - j; - for ( i = max( 0, j-ku ); i < min( M, j+kl+1 ); i++ ) { - to[ k+i ] = arr[ i ][ j ]; - } - } - return out; - } - // Store diagonals along the rows... - out = zeros2d( [ ku+kl+1, N ] ); - for ( j = 0; j < N; j++ ) { - k = ku - j; - for ( i = max( 0, j-ku ); i < min( M, j+kl+1 ); i++ ) { - out[ k+i ][ j ] = arr[ i ][ j ]; - } - } - return out; -} - - -// EXPORTS // - -module.exports = toCompact; diff --git a/base/banded/to-compact/package.json b/base/banded/to-compact/package.json deleted file mode 100644 index 6f7ac8202..000000000 --- a/base/banded/to-compact/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/banded/to-compact", - "version": "0.0.0", - "description": "Convert a two-dimensional banded nested array to compact banded storage.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "multidimensional", - "matrix", - "strided", - "ndarray", - "2d", - "banded", - "band", - "compact", - "storage" - ] -} diff --git a/base/banded/to-compact/test/test.js b/base/banded/to-compact/test/test.js deleted file mode 100644 index 706c9fc93..000000000 --- a/base/banded/to-compact/test/test.js +++ /dev/null @@ -1,137 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-multi-spaces */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toCompact = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof toCompact, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts a banded nested array to compact banded storage (colexicographic=false)', function test( t ) { - var expected; - var actual; - var arr; - - arr = [ - [ 1, 2, 3, 0, 0 ], - [ -2, 4, 5, 6, 0 ], - [ -3, -5, 7, 8, 9 ], - [ 0, -6, -8, 10, 11 ], - [ 0, 0, -9, -11, 12 ] - ]; - - expected = [ - [ 0, 0, 3, 6, 9 ], - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ], - [ -2, -5, -8, -11, 0 ], - [ -3, -6, -9, 0, 0 ] - ]; - actual = toCompact( arr, 2, 2, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 1, 4, 7, 10, 12 ] - ]; - actual = toCompact( arr, 0, 0, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ] - ]; - actual = toCompact( arr, 1, 0, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 1, 4, 7, 10, 12 ], - [ -2, -5, -8, -11, 0 ] - ]; - actual = toCompact( arr, 0, 1, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts a banded nested array to compact banded storage ( colexicographic=true)', function test( t ) { - var expected; - var actual; - var arr; - - arr = [ - [ 1, 2, 3, 0, 0 ], - [ -2, 4, 5, 6, 0 ], - [ -3, -5, 7, 8, 9 ], - [ 0, -6, -8, 10, 11 ], - [ 0, 0, -9, -11, 12 ] - ]; - - expected = [ - [ 0, 0, 1, -2, -3 ], - [ 0, 2, 4, -5, -6 ], - [ 3, 5, 7, -8, -9 ], - [ 6, 8, 10, -11, 0 ], - [ 9, 11, 12, 0, 0 ] - ]; - actual = toCompact( arr, 2, 2, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 1 ], - [ 4 ], - [ 7 ], - [ 10 ], - [ 12 ] - ]; - actual = toCompact( arr, 0, 0, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 1 ], - [ 2, 4 ], - [ 5, 7 ], - [ 8, 10 ], - [ 11, 12 ] - ]; - actual = toCompact( arr, 1, 0, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 1, -2, -3 ], - [ 4, -5, -6 ], - [ 7, -8, -9 ], - [ 10, -11, 0 ], - [ 12, 0, 0 ] - ]; - actual = toCompact( arr, 0, 2, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/bifurcate-entries-by/README.md b/base/bifurcate-entries-by/README.md deleted file mode 100644 index fd538b90a..000000000 --- a/base/bifurcate-entries-by/README.md +++ /dev/null @@ -1,157 +0,0 @@ - - -# bifurcateEntriesBy - -> Split element entries into two groups according to a predicate function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var bifurcateEntriesBy = require( '@stdlib/array/base/bifurcate-entries-by' ); -``` - -#### bifurcateEntriesBy( x, predicate\[, thisArg] ) - -Splits element entries into two groups according to a predicate function. - -```javascript -function predicate( v ) { - return v[ 0 ] === 'b'; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var out = bifurcateEntriesBy( x, predicate ); -// returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] -``` - -A `predicate` function is provided the following arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( v ) { - this.count += 1; - return v[ 0 ] === 'b'; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var context = { - 'count': 0 -}; -var out = bifurcateEntriesBy( x, predicate, context ); -// returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] - -var cnt = context.count; -// returns 4 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var bifurcateEntriesBy = require( '@stdlib/array/base/bifurcate-entries-by' ); - -function predicate( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ] === 'b'; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Split the values: -var out = bifurcateEntriesBy( x, predicate ); -// returns [...] - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/bifurcate-entries-by/benchmark/benchmark.length.js b/base/bifurcate-entries-by/benchmark/benchmark.length.js deleted file mode 100644 index 74a9db2a5..000000000 --- a/base/bifurcate-entries-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var bifurcateEntriesBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = bifurcateEntriesBy( x, predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Predicate function. - * - * @private - * @param {*} value - current array element - * @param {NonNegativeInteger} index - current array element index - * @param {Collection} arr - input array - * @returns {boolean} predicate value - */ - function predicate( value, index ) { - return ( index < len/2 ); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/bifurcate-entries-by/docs/repl.txt b/base/bifurcate-entries-by/docs/repl.txt deleted file mode 100644 index c467932df..000000000 --- a/base/bifurcate-entries-by/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Splits element entries into two groups according to a predicate function. - - When invoked, the predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: input array. - - If a predicate function returns a truthy value, an array value is placed in - the first group; otherwise, an array value is placed in the second group. - - If provided an empty array, the function returns an empty array. - - Parameters - ---------- - x: ArrayLike - Input array. - - predicate: Function - Predicate function specifying which group an element in the input array - belongs to. - - thisArg: any (optional) - Predicate function execution context. - - Returns - ------- - out: Array - Split results. - - Examples - -------- - > function fcn( v ) { return v[ 0 ] === 'b'; }; - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var out = {{alias}}( x, fcn ) - [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] - - See Also - -------- - diff --git a/base/bifurcate-entries-by/docs/types/index.d.ts b/base/bifurcate-entries-by/docs/types/index.d.ts deleted file mode 100644 index e64cd2e6e..000000000 --- a/base/bifurcate-entries-by/docs/types/index.d.ts +++ /dev/null @@ -1,101 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Group results. -*/ -type EntriesResults = [ Array<[ number, T ]>, Array<[ number, T ]> ]; - -/** -* Splits element entries into two groups according to a predicate function. -* -* ## Notes -* -* - If a predicate function returns a truthy value, an array value is placed in the first group; otherwise, an array value is placed in the second group. -* -* @param x - input array -* @param predicate - predicate function specifying which group an element in the input array belongs to -* @param thisArg - predicate function execution context -* @returns group results -* -* @example -* function predicate( v ) { -* return v[ 0 ] === 'b'; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = bifurcateEntriesBy( x, predicate ); -* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] -*/ -declare function bifurcateEntriesBy( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): EntriesResults; - - -// EXPORTS // - -export = bifurcateEntriesBy; diff --git a/base/bifurcate-entries-by/docs/types/test.ts b/base/bifurcate-entries-by/docs/types/test.ts deleted file mode 100644 index 5805f3a26..000000000 --- a/base/bifurcate-entries-by/docs/types/test.ts +++ /dev/null @@ -1,73 +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. -*/ - -import bifurcateEntriesBy = require( './index' ); - -/** -* Predicate function. -* -* @param v - value -* @returns result -*/ -function predicate( v: string ): boolean { - return v[ 0 ] === 'b'; -} - - -// TESTS // - -// The function returns group results... -{ - const x = [ 'foo', 'bar' ]; - - bifurcateEntriesBy( x, predicate ); // $ExpectType EntriesResults -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - bifurcateEntriesBy( 5, predicate ); // $ExpectError - bifurcateEntriesBy( true, predicate ); // $ExpectError - bifurcateEntriesBy( false, predicate ); // $ExpectError - bifurcateEntriesBy( null, predicate ); // $ExpectError - bifurcateEntriesBy( void 0, predicate ); // $ExpectError - bifurcateEntriesBy( {}, predicate ); // $ExpectError - bifurcateEntriesBy( ( x: number ): number => x, predicate ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid function... -{ - const x = [ 'foo', 'bar' ]; - - bifurcateEntriesBy( x, '5' ); // $ExpectError - bifurcateEntriesBy( x, 5 ); // $ExpectError - bifurcateEntriesBy( x, true ); // $ExpectError - bifurcateEntriesBy( x, false ); // $ExpectError - bifurcateEntriesBy( x, null ); // $ExpectError - bifurcateEntriesBy( x, void 0 ); // $ExpectError - bifurcateEntriesBy( x, {} ); // $ExpectError - bifurcateEntriesBy( x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 'foo', 'bar' ]; - - bifurcateEntriesBy(); // $ExpectError - bifurcateEntriesBy( x ); // $ExpectError - bifurcateEntriesBy( x, predicate, {}, {} ); // $ExpectError -} diff --git a/base/bifurcate-entries-by/examples/index.js b/base/bifurcate-entries-by/examples/index.js deleted file mode 100644 index 5d8648ce8..000000000 --- a/base/bifurcate-entries-by/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var bifurcateEntriesBy = require( './../lib' ); - -function predicate( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ] === 'b'; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Split the values: -var out = bifurcateEntriesBy( x, predicate ); -// returns [...] - -console.log( out ); diff --git a/base/bifurcate-entries-by/lib/index.js b/base/bifurcate-entries-by/lib/index.js deleted file mode 100644 index c0beadbe3..000000000 --- a/base/bifurcate-entries-by/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Split element entries into two groups according to a predicate function. -* -* @module @stdlib/array/base/bifurcate-entries-by -* -* @example -* var bifurcateEntriesBy = require( '@stdlib/array/base/bifurcate-entries-by' ); -* -* function predicate( v ) { -* return v[ 0 ] === 'b'; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = bifurcateEntriesBy( x, predicate ); -* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/bifurcate-entries-by/lib/main.js b/base/bifurcate-entries-by/lib/main.js deleted file mode 100644 index 10a6b215c..000000000 --- a/base/bifurcate-entries-by/lib/main.js +++ /dev/null @@ -1,77 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Splits element entries into two groups according to a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function specifying which group an element in the input collection belongs to -* @param {*} [thisArg] - predicate function execution context -* @returns {Object} group results -* -* @example -* function predicate( v ) { -* return v[ 0 ] === 'b'; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = bifurcateEntriesBy( x, predicate ); -* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] -*/ -function bifurcateEntriesBy( x, predicate, thisArg ) { - var get; - var len; - var out; - var v; - var i; - - // Get the number of elements to group: - len = x.length; - if ( len === 0 ) { - return []; - } - // Resolve an accessor for retrieving array elements: - get = resolveGetter( x ); - - // Loop over the elements and assign each to a group... - out = [ [], [] ]; - for ( i = 0; i < len; i++ ) { - v = get( x, i ); - if ( predicate.call( thisArg, v, i, x ) ) { - out[ 0 ].push( [ i, v ] ); - } else { - out[ 1 ].push( [ i, v ] ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = bifurcateEntriesBy; diff --git a/base/bifurcate-entries-by/package.json b/base/bifurcate-entries-by/package.json deleted file mode 100644 index c3e6ed87c..000000000 --- a/base/bifurcate-entries-by/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/bifurcate-entries-by", - "version": "0.0.0", - "description": "Split element entries into two groups according to a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "groupby", - "group-by", - "aggregate", - "summarize", - "partition", - "split", - "entries", - "indices" - ] -} diff --git a/base/bifurcate-entries-by/test/test.js b/base/bifurcate-entries-by/test/test.js deleted file mode 100644 index 6e178c73e..000000000 --- a/base/bifurcate-entries-by/test/test.js +++ /dev/null @@ -1,168 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var bifurcateEntriesBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bifurcateEntriesBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function splits array element entries into two groups according to a predicate function', function test( t ) { - var expected; - var out; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = [ - [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - [ [ 2, 'foo' ] ] - ]; - out = bifurcateEntriesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v[ 0 ] === 'b'; - } -}); - -tape( 'the function splits array element entries into two groups according to a predicate function (typed arrays)', function test( t ) { - var expected; - var out; - var x; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - - expected = [ - [ [ 2, -1.0 ], [ 3, -10.2 ] ], - [ [ 0, 3.14 ], [ 1, 4.2 ] ] - ]; - out = bifurcateEntriesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v, i ) { - return ( i >= 2 ); - } -}); - -tape( 'the function splits array element entries into two groups according to a predicate function (array-like objects)', function test( t ) { - var expected; - var out; - var x; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - - expected = [ - [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - [ [ 2, 'foo' ] ] - ]; - out = bifurcateEntriesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v[ 0 ] === 'b'; - } -}); - -tape( 'the function splits array element entries into two groups according to a predicate function (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - - expected = [ - [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - [ [ 2, 'foo' ] ] - ]; - out = bifurcateEntriesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v[ 0 ] === 'b'; - } -}); - -tape( 'the function returns an empty array if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = []; - actual = bifurcateEntriesBy( [], predicate ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - t.fail( 'should not be called' ); - return v; - } -}); - -tape( 'the function supports specifying a callback execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = [ - [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - [ [ 2, 'foo' ] ] - ]; - ctx = { - 'count': 0 - }; - out = bifurcateEntriesBy( x, predicate, ctx ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v[ 0 ] === 'b'; - } -}); diff --git a/base/bifurcate-entries/README.md b/base/bifurcate-entries/README.md deleted file mode 100644 index a97d93dc9..000000000 --- a/base/bifurcate-entries/README.md +++ /dev/null @@ -1,132 +0,0 @@ - - -# bifurcateEntries - -> Split array element entries into two groups. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var bifurcateEntries = require( '@stdlib/array/base/bifurcate-entries' ); -``` - -#### bifurcateEntries( x, filter ) - -Splits array element entries into two groups. - -```javascript -var x = [ 'beep', 'boop', 'foo', 'bar' ]; -var filter = [ true, true, false, true ]; - -var out = bifurcateEntries( x, filter ); -// returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] -``` - -
- - - - - -
- -## Notes - -- If an element in `filter` is truthy, the corresponding element in the input array `x` belongs to the first group; otherwise, the input array element belongs to the second group. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var bifurcateEntries = require( '@stdlib/array/base/bifurcate-entries' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, 1, { - 'dtype': 'generic' -}); - -// Group the values: -var out = bifurcateEntries( x, groups ); -// returns [...] - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/bifurcate-entries/benchmark/benchmark.length.js b/base/bifurcate-entries/benchmark/benchmark.length.js deleted file mode 100644 index 9b7dc1ad7..000000000 --- a/base/bifurcate-entries/benchmark/benchmark.length.js +++ /dev/null @@ -1,104 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var bifurcateEntries = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var filter; - var x; - - x = zeroTo( len ); - filter = discreteUniform( len, 0, 1, { - 'dtype': 'generic' - }); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = bifurcateEntries( x, filter ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/bifurcate-entries/docs/repl.txt b/base/bifurcate-entries/docs/repl.txt deleted file mode 100644 index b3244cf3d..000000000 --- a/base/bifurcate-entries/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, filter ) - Splits array element entries into two groups. - - If an element in `filter` is truthy, then the corresponding element in the - input array belongs to the first group; otherwise, the array element belongs - to the second group. - - If provided an empty array, the function returns an empty array. - - Parameters - ---------- - x: ArrayLike - Input array. - - filter: ArrayLike - An array indicating which group an element in the input array - belongs to. If an element in `filter` is truthy, the corresponding - element in the input array belongs to the first group; otherwise, the - array element belongs to the second group. - - Returns - ------- - out: Array - Group results. - - Examples - -------- - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var f = [ true, true, false, true ]; - > var out = {{alias}}( x, f ) - [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] - > f = [ 1, 1, 0, 1 ]; - > out = {{alias}}( x, f ) - [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] - - See Also - -------- - diff --git a/base/bifurcate-entries/docs/types/index.d.ts b/base/bifurcate-entries/docs/types/index.d.ts deleted file mode 100644 index 84ec64034..000000000 --- a/base/bifurcate-entries/docs/types/index.d.ts +++ /dev/null @@ -1,49 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Group results. -*/ -type Results = [ Array<[ number, T ]>, Array<[ number, T ]> ]; - -/** -* Splits array element entries into two groups. -* -* @param x - input array -* @param filter - array indicating which group an element in the input array belongs to -* @returns results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var filter = [ true, true, false, true ]; -* -* var out = bifurcateEntries( arr, filter ); -* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] -*/ -declare function bifurcateEntries( x: Collection | AccessorArrayLike, filter: Collection | AccessorArrayLike ): Results; // eslint-disable-line @typescript-eslint/no-explicit-any - - -// EXPORTS // - -export = bifurcateEntries; diff --git a/base/bifurcate-entries/docs/types/test.ts b/base/bifurcate-entries/docs/types/test.ts deleted file mode 100644 index 69e44bac5..000000000 --- a/base/bifurcate-entries/docs/types/test.ts +++ /dev/null @@ -1,66 +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. -*/ - -import bifurcateEntries = require( './index' ); - - -// TESTS // - -// The function returns group results... -{ - const x = [ 1, 2, 3 ]; - const f = [ 0, 1, 0 ]; - - bifurcateEntries( x, f ); // $ExpectType Results -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - const f = [ 0, 1, 0 ]; - - bifurcateEntries( 5, f ); // $ExpectError - bifurcateEntries( true, f ); // $ExpectError - bifurcateEntries( false, f ); // $ExpectError - bifurcateEntries( null, f ); // $ExpectError - bifurcateEntries( void 0, f ); // $ExpectError - bifurcateEntries( {}, f ); // $ExpectError - bifurcateEntries( ( x: number ): number => x, f ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array... -{ - const x = [ 1, 2, 3 ]; - - bifurcateEntries( x, 5 ); // $ExpectError - bifurcateEntries( x, true ); // $ExpectError - bifurcateEntries( x, false ); // $ExpectError - bifurcateEntries( x, null ); // $ExpectError - bifurcateEntries( x, void 0 ); // $ExpectError - bifurcateEntries( x, {} ); // $ExpectError - bifurcateEntries( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - const f = [ 0, 1, 0 ]; - - bifurcateEntries(); // $ExpectError - bifurcateEntries( x ); // $ExpectError - bifurcateEntries( x, f, {} ); // $ExpectError -} diff --git a/base/bifurcate-entries/examples/index.js b/base/bifurcate-entries/examples/index.js deleted file mode 100644 index 05a08df18..000000000 --- a/base/bifurcate-entries/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var bifurcateEntries = require( './../lib' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, 1, { - 'dtype': 'generic' -}); - -// Group the values: -var out = bifurcateEntries( x, groups ); -// returns [...] - -console.log( out ); diff --git a/base/bifurcate-entries/lib/index.js b/base/bifurcate-entries/lib/index.js deleted file mode 100644 index 9ac905e0e..000000000 --- a/base/bifurcate-entries/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Split array element entries into two groups. -* -* @module @stdlib/array/base/bifurcate-entries -* -* @example -* var bifurcateEntries = require( '@stdlib/array/base/bifurcate-entries' ); -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var filter = [ true, true, false, true ]; -* -* var out = bifurcateEntries( x, filter ); -* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/bifurcate-entries/lib/main.js b/base/bifurcate-entries/lib/main.js deleted file mode 100644 index 7763853a5..000000000 --- a/base/bifurcate-entries/lib/main.js +++ /dev/null @@ -1,81 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Splits array element entries into two groups. -* -* @param {Collection} x - input array -* @param {Collection} filter - array indicating which group an element in the input array belongs to -* @throws {RangeError} must provide arrays having the same length -* @returns {ArrayArray} results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var filter = [ true, true, false, true ]; -* -* var out = bifurcateEntries( x, filter ); -* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] -*/ -function bifurcateEntries( x, filter ) { - var xget; - var gget; - var len; - var out; - var g; - var v; - var i; - - // Get the number of elements to group: - len = x.length; - if ( filter.length !== len ) { - throw new RangeError( 'invalid argument. The first and second arguments must have the same length.' ); - } - if ( len === 0 ) { - return []; - } - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - gget = resolveGetter( filter ); - - // Loop over the elements and assign each to a group... - out = [ [], [] ]; - for ( i = 0; i < len; i++ ) { - v = xget( x, i ); - g = gget( filter, i ); - if ( g ) { - out[ 0 ].push( [ i, v ] ); - } else { - out[ 1 ].push( [ i, v ] ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = bifurcateEntries; diff --git a/base/bifurcate-entries/package.json b/base/bifurcate-entries/package.json deleted file mode 100644 index fccb74be8..000000000 --- a/base/bifurcate-entries/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/bifurcate-entries", - "version": "0.0.0", - "description": "Split array element entries into two groups.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "bifurcate", - "bifurcation", - "aggregate", - "partition", - "split", - "entries", - "values", - "indices" - ] -} diff --git a/base/bifurcate-entries/test/test.js b/base/bifurcate-entries/test/test.js deleted file mode 100644 index 34a5829b4..000000000 --- a/base/bifurcate-entries/test/test.js +++ /dev/null @@ -1,162 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var bifurcateEntries = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bifurcateEntries, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first and second argument which do not have the same length', function test( t ) { - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - bifurcateEntries( [ 1, 2, 3 ], [ 0, 0 ] ); - } -}); - -tape( 'the function splits array element entries into two groups', function test( t ) { - var expected; - var out; - var x; - var f; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - f = [ 1, 1, 0, 1 ]; - - expected = [ - [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - [ [ 2, 'foo' ] ] - ]; - out = bifurcateEntries( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array element entries into two groups (array, typed array)', function test( t ) { - var expected; - var out; - var x; - var f; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - f = new Float64Array( [ 1, 1, 0, 1 ] ); - - expected = [ - [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - [ [ 2, 'foo' ] ] - ]; - out = bifurcateEntries( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array element entries into two groups (typed arrays)', function test( t ) { - var expected; - var out; - var x; - var f; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - f = new Float64Array( [ 0, 0, 1, 1 ] ); - - expected = [ - [ [ 2, -1.0 ], [ 3, -10.2 ] ], - [ [ 0, 3.14 ], [ 1, 4.2 ] ] - ]; - out = bifurcateEntries( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array element entries into two groups (array-like objects)', function test( t ) { - var expected; - var out; - var x; - var f; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - f = { - 'length': 4, - '0': 1, - '1': 1, - '2': 0, - '3': 1 - }; - - expected = [ - [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - [ [ 2, 'foo' ] ] - ]; - out = bifurcateEntries( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array element entries into two groups (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - g = toAccessorArray( [ 1, 1, 0, 1 ] ); - - expected = [ - [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - [ [ 2, 'foo' ] ] - ]; - out = bifurcateEntries( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = []; - actual = bifurcateEntries( [], [] ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/bifurcate-indices-by/README.md b/base/bifurcate-indices-by/README.md deleted file mode 100644 index e4433eefa..000000000 --- a/base/bifurcate-indices-by/README.md +++ /dev/null @@ -1,157 +0,0 @@ - - -# bifurcateIndicesBy - -> Split element indices into two groups according to a predicate function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var bifurcateIndicesBy = require( '@stdlib/array/base/bifurcate-indices-by' ); -``` - -#### bifurcateIndicesBy( x, predicate\[, thisArg] ) - -Splits element indices into two groups according to a predicate function. - -```javascript -function predicate( v ) { - return v[ 0 ] === 'b'; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var out = bifurcateIndicesBy( x, predicate ); -// returns [ [ 0, 1, 3 ], [ 2 ] ] -``` - -A `predicate` function is provided the following arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( v ) { - this.count += 1; - return v[ 0 ] === 'b'; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var context = { - 'count': 0 -}; -var out = bifurcateIndicesBy( x, predicate, context ); -// returns [ [ 0, 1, 3 ], [ 2 ] ] - -var cnt = context.count; -// returns 4 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var bifurcateIndicesBy = require( '@stdlib/array/base/bifurcate-indices-by' ); - -function predicate( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ] === 'b'; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Split the values: -var out = bifurcateIndicesBy( x, predicate ); -// returns [...] - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/bifurcate-indices-by/benchmark/benchmark.length.js b/base/bifurcate-indices-by/benchmark/benchmark.length.js deleted file mode 100644 index 6468b8462..000000000 --- a/base/bifurcate-indices-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var bifurcateIndicesBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = bifurcateIndicesBy( x, predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Predicate function. - * - * @private - * @param {*} value - current array element - * @param {NonNegativeInteger} index - current array element index - * @param {Collection} arr - input array - * @returns {boolean} predicate value - */ - function predicate( value, index ) { - return ( index < len/2 ); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/bifurcate-indices-by/docs/repl.txt b/base/bifurcate-indices-by/docs/repl.txt deleted file mode 100644 index b3b35daa3..000000000 --- a/base/bifurcate-indices-by/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Splits element indices into two groups according to a predicate function. - - When invoked, the predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: input array. - - If a predicate function returns a truthy value, an array value is placed in - the first group; otherwise, an array value is placed in the second group. - - If provided an empty array, the function returns an empty object. - - Parameters - ---------- - x: ArrayLike - Input array. - - predicate: Function - Predicate function specifying which group an element in the input array - belongs to. - - thisArg: any (optional) - Predicate function execution context. - - Returns - ------- - out: Object - Split results. - - Examples - -------- - > function fcn( v ) { return v[ 0 ] === 'b'; }; - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var out = {{alias}}( x, fcn ) - [ [ 0, 1, 3 ], [ 2 ] ] - - See Also - -------- - diff --git a/base/bifurcate-indices-by/docs/types/index.d.ts b/base/bifurcate-indices-by/docs/types/index.d.ts deleted file mode 100644 index bd6381606..000000000 --- a/base/bifurcate-indices-by/docs/types/index.d.ts +++ /dev/null @@ -1,101 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Group results. -*/ -type IndicesResults = [ Array, Array ]; - -/** -* Splits element indices into two groups according to a predicate function. -* -* ## Notes -* -* - If a predicate function returns a truthy value, an array value is placed in the first group; otherwise, an array value is placed in the second group. -* -* @param x - input array -* @param predicate - predicate function specifying which group an element in the input array belongs to -* @param thisArg - predicate function execution context -* @returns group results -* -* @example -* function predicate( v ) { -* return v[ 0 ] === 'b'; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = bifurcateIndicesBy( x, predicate ); -* // returns [ [ 0, 1, 3 ], [ 2 ] ] -*/ -declare function bifurcateIndicesBy( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): IndicesResults; - - -// EXPORTS // - -export = bifurcateIndicesBy; diff --git a/base/bifurcate-indices-by/docs/types/test.ts b/base/bifurcate-indices-by/docs/types/test.ts deleted file mode 100644 index bbb1d0e48..000000000 --- a/base/bifurcate-indices-by/docs/types/test.ts +++ /dev/null @@ -1,73 +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. -*/ - -import bifurcateIndicesBy = require( './index' ); - -/** -* Predicate function. -* -* @param v - value -* @returns result -*/ -function predicate( v: string ): boolean { - return v[ 0 ] === 'b'; -} - - -// TESTS // - -// The function returns group results... -{ - const x = [ 'foo', 'bar' ]; - - bifurcateIndicesBy( x, predicate ); // $ExpectType IndicesResults -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - bifurcateIndicesBy( 5, predicate ); // $ExpectError - bifurcateIndicesBy( true, predicate ); // $ExpectError - bifurcateIndicesBy( false, predicate ); // $ExpectError - bifurcateIndicesBy( null, predicate ); // $ExpectError - bifurcateIndicesBy( void 0, predicate ); // $ExpectError - bifurcateIndicesBy( {}, predicate ); // $ExpectError - bifurcateIndicesBy( ( x: number ): number => x, predicate ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid function... -{ - const x = [ 'foo', 'bar' ]; - - bifurcateIndicesBy( x, '5' ); // $ExpectError - bifurcateIndicesBy( x, 5 ); // $ExpectError - bifurcateIndicesBy( x, true ); // $ExpectError - bifurcateIndicesBy( x, false ); // $ExpectError - bifurcateIndicesBy( x, null ); // $ExpectError - bifurcateIndicesBy( x, void 0 ); // $ExpectError - bifurcateIndicesBy( x, {} ); // $ExpectError - bifurcateIndicesBy( x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 'foo', 'bar' ]; - - bifurcateIndicesBy(); // $ExpectError - bifurcateIndicesBy( x ); // $ExpectError - bifurcateIndicesBy( x, predicate, {}, {} ); // $ExpectError -} diff --git a/base/bifurcate-indices-by/examples/index.js b/base/bifurcate-indices-by/examples/index.js deleted file mode 100644 index 41db341b3..000000000 --- a/base/bifurcate-indices-by/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var bifurcateIndicesBy = require( './../lib' ); - -function predicate( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ] === 'b'; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Split the values: -var out = bifurcateIndicesBy( x, predicate ); -// returns [...] - -console.log( out ); diff --git a/base/bifurcate-indices-by/lib/index.js b/base/bifurcate-indices-by/lib/index.js deleted file mode 100644 index 6bddd8434..000000000 --- a/base/bifurcate-indices-by/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Split element indices into two groups according to a predicate function. -* -* @module @stdlib/array/base/bifurcate-indices-by -* -* @example -* var bifurcateIndicesBy = require( '@stdlib/array/base/bifurcate-indices-by' ); -* -* function predicate( v ) { -* return v[ 0 ] === 'b'; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = bifurcateIndicesBy( x, predicate ); -* // returns [ [ 0, 1, 3 ], [ 2 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/bifurcate-indices-by/lib/main.js b/base/bifurcate-indices-by/lib/main.js deleted file mode 100644 index 7bb639825..000000000 --- a/base/bifurcate-indices-by/lib/main.js +++ /dev/null @@ -1,75 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Splits element indices into two groups according to a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function specifying which group an element in the input collection belongs to -* @param {*} [thisArg] - predicate function execution context -* @returns {Object} group results -* -* @example -* function predicate( v ) { -* return v[ 0 ] === 'b'; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = bifurcateIndicesBy( x, predicate ); -* // returns [ [ 0, 1, 3 ], [ 2 ] ] -*/ -function bifurcateIndicesBy( x, predicate, thisArg ) { - var get; - var len; - var out; - var i; - - // Get the number of elements to group: - len = x.length; - if ( len === 0 ) { - return []; - } - // Resolve an accessor for retrieving array elements: - get = resolveGetter( x ); - - // Loop over the elements and assign each to a group... - out = [ [], [] ]; - for ( i = 0; i < len; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - out[ 0 ].push( i ); - } else { - out[ 1 ].push( i ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = bifurcateIndicesBy; diff --git a/base/bifurcate-indices-by/package.json b/base/bifurcate-indices-by/package.json deleted file mode 100644 index edbf92cd9..000000000 --- a/base/bifurcate-indices-by/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/bifurcate-indices-by", - "version": "0.0.0", - "description": "Split element indices into two groups according to a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "groupby", - "group-by", - "aggregate", - "summarize", - "partition", - "split", - "indices" - ] -} diff --git a/base/bifurcate-indices-by/test/test.js b/base/bifurcate-indices-by/test/test.js deleted file mode 100644 index 93b52343d..000000000 --- a/base/bifurcate-indices-by/test/test.js +++ /dev/null @@ -1,168 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var bifurcateIndicesBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bifurcateIndicesBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function splits array element indices into two groups according to a predicate function', function test( t ) { - var expected; - var out; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = [ - [ 0, 1, 3 ], - [ 2 ] - ]; - out = bifurcateIndicesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v[ 0 ] === 'b'; - } -}); - -tape( 'the function splits array element indices into two groups according to a predicate function (typed arrays)', function test( t ) { - var expected; - var out; - var x; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - - expected = [ - [ 2, 3 ], - [ 0, 1 ] - ]; - out = bifurcateIndicesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v, i ) { - return ( i >= 2 ); - } -}); - -tape( 'the function splits array element indices into two groups according to a predicate function (array-like objects)', function test( t ) { - var expected; - var out; - var x; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - - expected = [ - [ 0, 1, 3 ], - [ 2 ] - ]; - out = bifurcateIndicesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v[ 0 ] === 'b'; - } -}); - -tape( 'the function splits array element indices into two groups according to a predicate function (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - - expected = [ - [ 0, 1, 3 ], - [ 2 ] - ]; - out = bifurcateIndicesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v[ 0 ] === 'b'; - } -}); - -tape( 'the function returns an empty array if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = []; - actual = bifurcateIndicesBy( [], predicate ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - t.fail( 'should not be called' ); - return v; - } -}); - -tape( 'the function supports specifying a callback execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = [ - [ 0, 1, 3 ], - [ 2 ] - ]; - ctx = { - 'count': 0 - }; - out = bifurcateIndicesBy( x, predicate, ctx ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v[ 0 ] === 'b'; - } -}); diff --git a/base/bifurcate-indices/README.md b/base/bifurcate-indices/README.md deleted file mode 100644 index e1f85ad2a..000000000 --- a/base/bifurcate-indices/README.md +++ /dev/null @@ -1,132 +0,0 @@ - - -# bifurcateIndices - -> Split array element indices into two groups. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var bifurcateIndices = require( '@stdlib/array/base/bifurcate-indices' ); -``` - -#### bifurcateIndices( x, filter ) - -Splits array element indices into two groups. - -```javascript -var x = [ 'beep', 'boop', 'foo', 'bar' ]; -var filter = [ true, true, false, true ]; - -var out = bifurcateIndices( x, filter ); -// returns [ [ 0, 1, 3 ], [ 2 ] ] -``` - -
- - - - - -
- -## Notes - -- If an element in `filter` is truthy, the corresponding element in the input array `x` belongs to the first group; otherwise, the input array element belongs to the second group. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var bifurcateIndices = require( '@stdlib/array/base/bifurcate-indices' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, 1, { - 'dtype': 'generic' -}); - -// Group the values: -var out = bifurcateIndices( x, groups ); -// returns [...] - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/bifurcate-indices/benchmark/benchmark.length.js b/base/bifurcate-indices/benchmark/benchmark.length.js deleted file mode 100644 index 85c5c4a19..000000000 --- a/base/bifurcate-indices/benchmark/benchmark.length.js +++ /dev/null @@ -1,104 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var bifurcateIndices = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var filter; - var x; - - x = zeroTo( len ); - filter = discreteUniform( len, 0, 1, { - 'dtype': 'generic' - }); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = bifurcateIndices( x, filter ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/bifurcate-indices/docs/repl.txt b/base/bifurcate-indices/docs/repl.txt deleted file mode 100644 index 461458da8..000000000 --- a/base/bifurcate-indices/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, filter ) - Splits array element indices into two groups. - - If an element in `filter` is truthy, then the corresponding element in the - input array belongs to the first group; otherwise, the array element belongs - to the second group. - - If provided an empty array, the function returns an empty array. - - Parameters - ---------- - x: ArrayLike - Input array. - - filter: ArrayLike - An array indicating which group an element in the input array - belongs to. If an element in `filter` is truthy, the corresponding - element in the input array belongs to the first group; otherwise, the - array element belongs to the second group. - - Returns - ------- - out: Array - Group results. - - Examples - -------- - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var f = [ true, true, false, true ]; - > var out = {{alias}}( x, f ) - [ [ 0, 1, 3 ], [ 2 ] ] - > f = [ 1, 1, 0, 1 ]; - > out = {{alias}}( x, f ) - [ [ 0, 1, 3 ], [ 2 ] ] - - See Also - -------- - diff --git a/base/bifurcate-indices/docs/types/index.d.ts b/base/bifurcate-indices/docs/types/index.d.ts deleted file mode 100644 index b98c40067..000000000 --- a/base/bifurcate-indices/docs/types/index.d.ts +++ /dev/null @@ -1,44 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Splits array element indices into two groups. -* -* @param x - input array -* @param filter - array indicating which group an element in the input array belongs to -* @returns results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var filter = [ true, true, false, true ]; -* -* var out = bifurcateIndices( arr, filter ); -* // returns [ [ 0, 1, 3 ], [ 2 ] ] -*/ -declare function bifurcateIndices( x: Collection | AccessorArrayLike, filter: Collection | AccessorArrayLike ): [ Array, Array ]; // eslint-disable-line @typescript-eslint/no-explicit-any - - -// EXPORTS // - -export = bifurcateIndices; diff --git a/base/bifurcate-indices/docs/types/test.ts b/base/bifurcate-indices/docs/types/test.ts deleted file mode 100644 index bfd2d5e9a..000000000 --- a/base/bifurcate-indices/docs/types/test.ts +++ /dev/null @@ -1,66 +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. -*/ - -import bifurcateIndices = require( './index' ); - - -// TESTS // - -// The function returns group results... -{ - const x = [ 1, 2, 3 ]; - const f = [ 0, 1, 0 ]; - - bifurcateIndices( x, f ); // $ExpectType [number[], number[]] -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - const f = [ 0, 1, 0 ]; - - bifurcateIndices( 5, f ); // $ExpectError - bifurcateIndices( true, f ); // $ExpectError - bifurcateIndices( false, f ); // $ExpectError - bifurcateIndices( null, f ); // $ExpectError - bifurcateIndices( void 0, f ); // $ExpectError - bifurcateIndices( {}, f ); // $ExpectError - bifurcateIndices( ( x: number ): number => x, f ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array... -{ - const x = [ 1, 2, 3 ]; - - bifurcateIndices( x, 5 ); // $ExpectError - bifurcateIndices( x, true ); // $ExpectError - bifurcateIndices( x, false ); // $ExpectError - bifurcateIndices( x, null ); // $ExpectError - bifurcateIndices( x, void 0 ); // $ExpectError - bifurcateIndices( x, {} ); // $ExpectError - bifurcateIndices( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - const f = [ 0, 1, 0 ]; - - bifurcateIndices(); // $ExpectError - bifurcateIndices( x ); // $ExpectError - bifurcateIndices( x, f, {} ); // $ExpectError -} diff --git a/base/bifurcate-indices/examples/index.js b/base/bifurcate-indices/examples/index.js deleted file mode 100644 index acc01b9c0..000000000 --- a/base/bifurcate-indices/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var bifurcateIndices = require( './../lib' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, 1, { - 'dtype': 'generic' -}); - -// Group the values: -var out = bifurcateIndices( x, groups ); -// returns [...] - -console.log( out ); diff --git a/base/bifurcate-indices/lib/index.js b/base/bifurcate-indices/lib/index.js deleted file mode 100644 index 1a96ad2ae..000000000 --- a/base/bifurcate-indices/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Split array element indices into two groups. -* -* @module @stdlib/array/base/bifurcate-indices -* -* @example -* var bifurcateIndices = require( '@stdlib/array/base/bifurcate-indices' ); -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var filter = [ true, true, false, true ]; -* -* var out = bifurcateIndices( x, filter ); -* // returns [ [ 0, 1, 3 ], [ 2 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/bifurcate-indices/lib/main.js b/base/bifurcate-indices/lib/main.js deleted file mode 100644 index 2f4cb8722..000000000 --- a/base/bifurcate-indices/lib/main.js +++ /dev/null @@ -1,77 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Splits array element indices into two groups. -* -* @param {Collection} x - input array -* @param {Collection} filter - array indicating which group an element in the input array belongs to -* @throws {RangeError} must provide arrays having the same length -* @returns {ArrayArray} results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var filter = [ true, true, false, true ]; -* -* var out = bifurcateIndices( x, filter ); -* // returns [ [ 0, 1, 3 ], [ 2 ] ] -*/ -function bifurcateIndices( x, filter ) { - var gget; - var len; - var out; - var g; - var i; - - // Get the number of elements to group: - len = x.length; - if ( filter.length !== len ) { - throw new RangeError( 'invalid argument. The first and second arguments must have the same length.' ); - } - if ( len === 0 ) { - return []; - } - // Resolve accessors for retrieving array elements: - gget = resolveGetter( filter ); - - // Loop over the elements and assign each to a group... - out = [ [], [] ]; - for ( i = 0; i < len; i++ ) { - g = gget( filter, i ); - if ( g ) { - out[ 0 ].push( i ); - } else { - out[ 1 ].push( i ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = bifurcateIndices; diff --git a/base/bifurcate-indices/package.json b/base/bifurcate-indices/package.json deleted file mode 100644 index ae93c2007..000000000 --- a/base/bifurcate-indices/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/bifurcate-indices", - "version": "0.0.0", - "description": "Split array element indices into two groups.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "bifurcate", - "bifurcation", - "aggregate", - "partition", - "split", - "indices" - ] -} diff --git a/base/bifurcate-indices/test/test.js b/base/bifurcate-indices/test/test.js deleted file mode 100644 index 79bd267ac..000000000 --- a/base/bifurcate-indices/test/test.js +++ /dev/null @@ -1,162 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var bifurcateIndices = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bifurcateIndices, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first and second argument which do not have the same length', function test( t ) { - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - bifurcateIndices( [ 1, 2, 3 ], [ 0, 0 ] ); - } -}); - -tape( 'the function splits array element indices into two groups', function test( t ) { - var expected; - var out; - var x; - var f; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - f = [ 1, 1, 0, 1 ]; - - expected = [ - [ 0, 1, 3 ], - [ 2 ] - ]; - out = bifurcateIndices( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array element indices into two groups (array, typed array)', function test( t ) { - var expected; - var out; - var x; - var f; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - f = new Float64Array( [ 1, 1, 0, 1 ] ); - - expected = [ - [ 0, 1, 3 ], - [ 2 ] - ]; - out = bifurcateIndices( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array element indices into two groups (typed arrays)', function test( t ) { - var expected; - var out; - var x; - var f; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - f = new Float64Array( [ 0, 0, 1, 1 ] ); - - expected = [ - [ 2, 3 ], - [ 0, 1 ] - ]; - out = bifurcateIndices( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array element indices into two groups (array-like objects)', function test( t ) { - var expected; - var out; - var x; - var f; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - f = { - 'length': 4, - '0': 1, - '1': 1, - '2': 0, - '3': 1 - }; - - expected = [ - [ 0, 1, 3 ], - [ 2 ] - ]; - out = bifurcateIndices( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array element indices into two groups (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - g = toAccessorArray( [ 1, 1, 0, 1 ] ); - - expected = [ - [ 0, 1, 3 ], - [ 2 ] - ]; - out = bifurcateIndices( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = []; - actual = bifurcateIndices( [], [] ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/bifurcate-values-by/README.md b/base/bifurcate-values-by/README.md deleted file mode 100644 index 86ed195ce..000000000 --- a/base/bifurcate-values-by/README.md +++ /dev/null @@ -1,157 +0,0 @@ - - -# bifurcateValuesBy - -> Split element values into two groups according to a predicate function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var bifurcateValuesBy = require( '@stdlib/array/base/bifurcate-values-by' ); -``` - -#### bifurcateValuesBy( x, predicate\[, thisArg] ) - -Splits element values into two groups according to a predicate function. - -```javascript -function predicate( v ) { - return v[ 0 ] === 'b'; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var out = bifurcateValuesBy( x, predicate ); -// returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] -``` - -A `predicate` function is provided the following arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( v ) { - this.count += 1; - return v[ 0 ] === 'b'; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var context = { - 'count': 0 -}; -var out = bifurcateValuesBy( x, predicate, context ); -// returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] - -var cnt = context.count; -// returns 4 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var bifurcateValuesBy = require( '@stdlib/array/base/bifurcate-values-by' ); - -function predicate( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ] === 'b'; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Split the values: -var out = bifurcateValuesBy( x, predicate ); -// returns [...] - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/bifurcate-values-by/benchmark/benchmark.length.js b/base/bifurcate-values-by/benchmark/benchmark.length.js deleted file mode 100644 index 4e4b92150..000000000 --- a/base/bifurcate-values-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var bifurcateValuesBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = bifurcateValuesBy( x, predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Predicate function. - * - * @private - * @param {*} value - current array element - * @param {NonNegativeInteger} index - current array element index - * @param {Collection} arr - input array - * @returns {boolean} predicate value - */ - function predicate( value, index ) { - return ( index < len/2 ); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/bifurcate-values-by/docs/repl.txt b/base/bifurcate-values-by/docs/repl.txt deleted file mode 100644 index 9075f9fc3..000000000 --- a/base/bifurcate-values-by/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Splits element values into two groups according to a predicate function. - - When invoked, the predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: input array. - - If a predicate function returns a truthy value, an array value is placed in - the first group; otherwise, an array value is placed in the second group. - - If provided an empty array, the function returns an empty object. - - Parameters - ---------- - x: ArrayLike - Input array. - - predicate: Function - Predicate function specifying which group an element in the input array - belongs to. - - thisArg: any (optional) - Predicate function execution context. - - Returns - ------- - out: Object - Split results. - - Examples - -------- - > function fcn( v ) { return v[ 0 ] === 'b'; }; - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var out = {{alias}}( x, fcn ) - [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] - - See Also - -------- - diff --git a/base/bifurcate-values-by/docs/types/index.d.ts b/base/bifurcate-values-by/docs/types/index.d.ts deleted file mode 100644 index 38c4124d5..000000000 --- a/base/bifurcate-values-by/docs/types/index.d.ts +++ /dev/null @@ -1,101 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection ) => boolean; - -/** -* Returns a boolean indicating which group an element in an array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element in an array should be placed in the first or second group -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Group results. -*/ -type ValuesResults = [ Array, Array ]; - -/** -* Splits element values into two groups according to a predicate function. -* -* ## Notes -* -* - If a predicate function returns a truthy value, an array value is placed in the first group; otherwise, an array value is placed in the second group. -* -* @param x - input array -* @param predicate - predicate function specifying which group an element in the input array belongs to -* @param thisArg - predicate function execution context -* @returns group results -* -* @example -* function predicate( v ) { -* return v[ 0 ] === 'b'; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = bifurcateValuesBy( x, predicate ); -* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] -*/ -declare function bifurcateValuesBy( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): ValuesResults; - - -// EXPORTS // - -export = bifurcateValuesBy; diff --git a/base/bifurcate-values-by/docs/types/test.ts b/base/bifurcate-values-by/docs/types/test.ts deleted file mode 100644 index a8b2e1895..000000000 --- a/base/bifurcate-values-by/docs/types/test.ts +++ /dev/null @@ -1,73 +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. -*/ - -import bifurcateValuesBy = require( './index' ); - -/** -* Predicate function. -* -* @param v - value -* @returns result -*/ -function predicate( v: string ): boolean { - return v[ 0 ] === 'b'; -} - - -// TESTS // - -// The function returns group results... -{ - const x = [ 'foo', 'bar' ]; - - bifurcateValuesBy( x, predicate ); // $ExpectType ValuesResults -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - bifurcateValuesBy( 5, predicate ); // $ExpectError - bifurcateValuesBy( true, predicate ); // $ExpectError - bifurcateValuesBy( false, predicate ); // $ExpectError - bifurcateValuesBy( null, predicate ); // $ExpectError - bifurcateValuesBy( void 0, predicate ); // $ExpectError - bifurcateValuesBy( {}, predicate ); // $ExpectError - bifurcateValuesBy( ( x: number ): number => x, predicate ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid function... -{ - const x = [ 'foo', 'bar' ]; - - bifurcateValuesBy( x, '5' ); // $ExpectError - bifurcateValuesBy( x, 5 ); // $ExpectError - bifurcateValuesBy( x, true ); // $ExpectError - bifurcateValuesBy( x, false ); // $ExpectError - bifurcateValuesBy( x, null ); // $ExpectError - bifurcateValuesBy( x, void 0 ); // $ExpectError - bifurcateValuesBy( x, {} ); // $ExpectError - bifurcateValuesBy( x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 'foo', 'bar' ]; - - bifurcateValuesBy(); // $ExpectError - bifurcateValuesBy( x ); // $ExpectError - bifurcateValuesBy( x, predicate, {}, {} ); // $ExpectError -} diff --git a/base/bifurcate-values-by/examples/index.js b/base/bifurcate-values-by/examples/index.js deleted file mode 100644 index 00eefb730..000000000 --- a/base/bifurcate-values-by/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var bifurcateValuesBy = require( './../lib' ); - -function predicate( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ] === 'b'; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Split the values: -var out = bifurcateValuesBy( x, predicate ); -// returns [...] - -console.log( out ); diff --git a/base/bifurcate-values-by/lib/index.js b/base/bifurcate-values-by/lib/index.js deleted file mode 100644 index 3956c2fff..000000000 --- a/base/bifurcate-values-by/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Split element values into two groups according to a predicate function. -* -* @module @stdlib/array/base/bifurcate-values-by -* -* @example -* var bifurcateValuesBy = require( '@stdlib/array/base/bifurcate-values-by' ); -* -* function predicate( v ) { -* return v[ 0 ] === 'b'; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = bifurcateValuesBy( x, predicate ); -* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/bifurcate-values-by/lib/main.js b/base/bifurcate-values-by/lib/main.js deleted file mode 100644 index a5fc31bd9..000000000 --- a/base/bifurcate-values-by/lib/main.js +++ /dev/null @@ -1,77 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Splits element values into two groups according to a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function specifying which group an element in the input collection belongs to -* @param {*} [thisArg] - predicate function execution context -* @returns {Object} group results -* -* @example -* function predicate( v ) { -* return v[ 0 ] === 'b'; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = bifurcateValuesBy( x, predicate ); -* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] -*/ -function bifurcateValuesBy( x, predicate, thisArg ) { - var get; - var len; - var out; - var v; - var i; - - // Get the number of elements to group: - len = x.length; - if ( len === 0 ) { - return []; - } - // Resolve an accessor for retrieving array elements: - get = resolveGetter( x ); - - // Loop over the elements and assign each to a group... - out = [ [], [] ]; - for ( i = 0; i < len; i++ ) { - v = get( x, i ); - if ( predicate.call( thisArg, v, i, x ) ) { - out[ 0 ].push( v ); - } else { - out[ 1 ].push( v ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = bifurcateValuesBy; diff --git a/base/bifurcate-values-by/package.json b/base/bifurcate-values-by/package.json deleted file mode 100644 index aef604f41..000000000 --- a/base/bifurcate-values-by/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/bifurcate-values-by", - "version": "0.0.0", - "description": "Split element values into two groups according to a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "groupby", - "group-by", - "aggregate", - "summarize", - "partition", - "split" - ] -} diff --git a/base/bifurcate-values-by/test/test.js b/base/bifurcate-values-by/test/test.js deleted file mode 100644 index c0df09cce..000000000 --- a/base/bifurcate-values-by/test/test.js +++ /dev/null @@ -1,168 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var bifurcateValuesBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bifurcateValuesBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function splits array element values into two groups according to a predicate function', function test( t ) { - var expected; - var out; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = [ - [ 'beep', 'boop', 'bar' ], - [ 'foo' ] - ]; - out = bifurcateValuesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v[ 0 ] === 'b'; - } -}); - -tape( 'the function splits array element values into two groups according to a predicate function (typed arrays)', function test( t ) { - var expected; - var out; - var x; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - - expected = [ - [ -1.0, -10.2 ], - [ 3.14, 4.2 ] - ]; - out = bifurcateValuesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v, i ) { - return ( i >= 2 ); - } -}); - -tape( 'the function splits array element values into two groups according to a predicate function (array-like objects)', function test( t ) { - var expected; - var out; - var x; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - - expected = [ - [ 'beep', 'boop', 'bar' ], - [ 'foo' ] - ]; - out = bifurcateValuesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v[ 0 ] === 'b'; - } -}); - -tape( 'the function splits array element values into two groups according to a predicate function (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - - expected = [ - [ 'beep', 'boop', 'bar' ], - [ 'foo' ] - ]; - out = bifurcateValuesBy( x, predicate ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v[ 0 ] === 'b'; - } -}); - -tape( 'the function returns an empty array if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = []; - actual = bifurcateValuesBy( [], predicate ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - t.fail( 'should not be called' ); - return v; - } -}); - -tape( 'the function supports specifying a callback execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = [ - [ 'beep', 'boop', 'bar' ], - [ 'foo' ] - ]; - ctx = { - 'count': 0 - }; - out = bifurcateValuesBy( x, predicate, ctx ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v[ 0 ] === 'b'; - } -}); diff --git a/base/bifurcate-values/README.md b/base/bifurcate-values/README.md deleted file mode 100644 index c56c4f01e..000000000 --- a/base/bifurcate-values/README.md +++ /dev/null @@ -1,132 +0,0 @@ - - -# bifurcateValues - -> Split array element values into two groups. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var bifurcateValues = require( '@stdlib/array/base/bifurcate-values' ); -``` - -#### bifurcateValues( x, filter ) - -Splits array element values into two groups. - -```javascript -var x = [ 'beep', 'boop', 'foo', 'bar' ]; -var filter = [ true, true, false, true ]; - -var out = bifurcateValues( x, filter ); -// returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] -``` - -
- - - - - -
- -## Notes - -- If an element in `filter` is truthy, the corresponding element in the input array `x` belongs to the first group; otherwise, the input array element belongs to the second group. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var bifurcateValues = require( '@stdlib/array/base/bifurcate-values' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, 1, { - 'dtype': 'generic' -}); - -// Group the values: -var out = bifurcateValues( x, groups ); -// returns [...] - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/bifurcate-values/benchmark/benchmark.length.js b/base/bifurcate-values/benchmark/benchmark.length.js deleted file mode 100644 index 7c998be4f..000000000 --- a/base/bifurcate-values/benchmark/benchmark.length.js +++ /dev/null @@ -1,104 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var bifurcateValues = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var filter; - var x; - - x = zeroTo( len ); - filter = discreteUniform( len, 0, 1, { - 'dtype': 'generic' - }); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = bifurcateValues( x, filter ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/bifurcate-values/docs/repl.txt b/base/bifurcate-values/docs/repl.txt deleted file mode 100644 index 0e95313a7..000000000 --- a/base/bifurcate-values/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, filter ) - Splits array element values into two groups. - - If an element in `filter` is truthy, then the corresponding element in the - input array belongs to the first group; otherwise, the array element belongs - to the second group. - - If provided an empty array, the function returns an empty array. - - Parameters - ---------- - x: ArrayLike - Input array. - - filter: ArrayLike - An array indicating which group an element in the input array - belongs to. If an element in `filter` is truthy, the corresponding - element in the input array belongs to the first group; otherwise, the - array element belongs to the second group. - - Returns - ------- - out: Array - Group results. - - Examples - -------- - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var f = [ true, true, false, true ]; - > var out = {{alias}}( x, f ) - [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] - > f = [ 1, 1, 0, 1 ]; - > out = {{alias}}( x, f ) - [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] - - See Also - -------- - diff --git a/base/bifurcate-values/docs/types/index.d.ts b/base/bifurcate-values/docs/types/index.d.ts deleted file mode 100644 index 06c408bea..000000000 --- a/base/bifurcate-values/docs/types/index.d.ts +++ /dev/null @@ -1,44 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Splits array element values into two groups. -* -* @param x - input array -* @param filter - array indicating which group an element in the input array belongs to -* @returns results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var filter = [ true, true, false, true ]; -* -* var out = bifurcateValues( arr, filter ); -* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] -*/ -declare function bifurcateValues( x: Collection | AccessorArrayLike, filter: Collection | AccessorArrayLike ): [ Array, Array ]; // eslint-disable-line @typescript-eslint/no-explicit-any - - -// EXPORTS // - -export = bifurcateValues; diff --git a/base/bifurcate-values/docs/types/test.ts b/base/bifurcate-values/docs/types/test.ts deleted file mode 100644 index 78e0775c8..000000000 --- a/base/bifurcate-values/docs/types/test.ts +++ /dev/null @@ -1,66 +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. -*/ - -import bifurcateValues = require( './index' ); - - -// TESTS // - -// The function returns group results... -{ - const x = [ 1, 2, 3 ]; - const f = [ 0, 1, 0 ]; - - bifurcateValues( x, f ); // $ExpectType [number[], number[]] -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - const f = [ 0, 1, 0 ]; - - bifurcateValues( 5, f ); // $ExpectError - bifurcateValues( true, f ); // $ExpectError - bifurcateValues( false, f ); // $ExpectError - bifurcateValues( null, f ); // $ExpectError - bifurcateValues( void 0, f ); // $ExpectError - bifurcateValues( {}, f ); // $ExpectError - bifurcateValues( ( x: number ): number => x, f ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array... -{ - const x = [ 1, 2, 3 ]; - - bifurcateValues( x, 5 ); // $ExpectError - bifurcateValues( x, true ); // $ExpectError - bifurcateValues( x, false ); // $ExpectError - bifurcateValues( x, null ); // $ExpectError - bifurcateValues( x, void 0 ); // $ExpectError - bifurcateValues( x, {} ); // $ExpectError - bifurcateValues( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - const f = [ 0, 1, 0 ]; - - bifurcateValues(); // $ExpectError - bifurcateValues( x ); // $ExpectError - bifurcateValues( x, f, {} ); // $ExpectError -} diff --git a/base/bifurcate-values/examples/index.js b/base/bifurcate-values/examples/index.js deleted file mode 100644 index 5bcfddf1a..000000000 --- a/base/bifurcate-values/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var bifurcateValues = require( './../lib' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, 1, { - 'dtype': 'generic' -}); - -// Group the values: -var out = bifurcateValues( x, groups ); -// returns [...] - -console.log( out ); diff --git a/base/bifurcate-values/lib/index.js b/base/bifurcate-values/lib/index.js deleted file mode 100644 index 9f08b007e..000000000 --- a/base/bifurcate-values/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Split array element values into two groups. -* -* @module @stdlib/array/base/bifurcate-values -* -* @example -* var bifurcateValues = require( '@stdlib/array/base/bifurcate-values' ); -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var filter = [ true, true, false, true ]; -* -* var out = bifurcateValues( x, filter ); -* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/bifurcate-values/lib/main.js b/base/bifurcate-values/lib/main.js deleted file mode 100644 index 723104c76..000000000 --- a/base/bifurcate-values/lib/main.js +++ /dev/null @@ -1,81 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Splits array element values into two groups. -* -* @param {Collection} x - input array -* @param {Collection} filter - array indicating which group an element in the input array belongs to -* @throws {RangeError} must provide arrays having the same length -* @returns {ArrayArray} results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var filter = [ true, true, false, true ]; -* -* var out = bifurcateValues( x, filter ); -* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] -*/ -function bifurcateValues( x, filter ) { - var xget; - var gget; - var len; - var out; - var g; - var v; - var i; - - // Get the number of elements to group: - len = x.length; - if ( filter.length !== len ) { - throw new RangeError( 'invalid argument. The first and second arguments must have the same length.' ); - } - if ( len === 0 ) { - return []; - } - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - gget = resolveGetter( filter ); - - // Loop over the elements and assign each to a group... - out = [ [], [] ]; - for ( i = 0; i < len; i++ ) { - v = xget( x, i ); - g = gget( filter, i ); - if ( g ) { - out[ 0 ].push( v ); - } else { - out[ 1 ].push( v ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = bifurcateValues; diff --git a/base/bifurcate-values/package.json b/base/bifurcate-values/package.json deleted file mode 100644 index 5cffe60b2..000000000 --- a/base/bifurcate-values/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/bifurcate-values", - "version": "0.0.0", - "description": "Split array element values into two groups.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "bifurcate", - "bifurcation", - "aggregate", - "partition", - "split" - ] -} diff --git a/base/bifurcate-values/test/test.js b/base/bifurcate-values/test/test.js deleted file mode 100644 index 927ed9100..000000000 --- a/base/bifurcate-values/test/test.js +++ /dev/null @@ -1,162 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var bifurcateValues = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bifurcateValues, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first and second argument which do not have the same length', function test( t ) { - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - bifurcateValues( [ 1, 2, 3 ], [ 0, 0 ] ); - } -}); - -tape( 'the function splits array elements into two groups', function test( t ) { - var expected; - var out; - var x; - var f; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - f = [ 1, 1, 0, 1 ]; - - expected = [ - [ 'beep', 'boop', 'bar' ], - [ 'foo' ] - ]; - out = bifurcateValues( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array elements into two groups (array, typed array)', function test( t ) { - var expected; - var out; - var x; - var f; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - f = new Float64Array( [ 1, 1, 0, 1 ] ); - - expected = [ - [ 'beep', 'boop', 'bar' ], - [ 'foo' ] - ]; - out = bifurcateValues( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array elements into two groups (typed arrays)', function test( t ) { - var expected; - var out; - var x; - var f; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - f = new Float64Array( [ 0, 0, 1, 1 ] ); - - expected = [ - [ -1.0, -10.2 ], - [ 3.14, 4.2 ] - ]; - out = bifurcateValues( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array elements into two groups (array-like objects)', function test( t ) { - var expected; - var out; - var x; - var f; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - f = { - 'length': 4, - '0': 1, - '1': 1, - '2': 0, - '3': 1 - }; - - expected = [ - [ 'beep', 'boop', 'bar' ], - [ 'foo' ] - ]; - out = bifurcateValues( x, f ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function splits array elements into two groups (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - g = toAccessorArray( [ 1, 1, 0, 1 ] ); - - expected = [ - [ 'beep', 'boop', 'bar' ], - [ 'foo' ] - ]; - out = bifurcateValues( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = []; - actual = bifurcateValues( [], [] ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/binary2d/README.md b/base/binary2d/README.md deleted file mode 100644 index 388d6d1b2..000000000 --- a/base/binary2d/README.md +++ /dev/null @@ -1,122 +0,0 @@ - - -# binary2d - -> Apply a binary callback to elements in two two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var binary2d = require( '@stdlib/array/base/binary2d' ); -``` - -#### binary2d( arrays, shape, fcn ) - -Applies a binary callback to elements in two two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); - -var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; -var z = zeros2d( [ 2, 2 ] ); - -var shape = [ 2, 2 ]; - -binary2d( [ x, x, z ], shape, add ); -// z => [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var binary2d = require( '@stdlib/array/base/binary2d' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros2d( shape ); -console.log( z ); - -binary2d( [ x, y, z ], shape, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/binary2d/benchmark/benchmark.js b/base/binary2d/benchmark/benchmark.js deleted file mode 100644 index d233897bf..000000000 --- a/base/binary2d/benchmark/benchmark.js +++ /dev/null @@ -1,118 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var binary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - - x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - z = zeros2d( shape ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - binary2d( arrays, shape, add ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/binary2d/docs/repl.txt b/base/binary2d/docs/repl.txt deleted file mode 100644 index 31ef24dd8..000000000 --- a/base/binary2d/docs/repl.txt +++ /dev/null @@ -1,31 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a binary callback to elements in two two-dimensional nested input - arrays and assigns results to elements in a two-dimensional nested output - array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shape = [ 2, 2 ]; - > {{alias}}( [ x, y, z ], shape, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] - - See Also - -------- - diff --git a/base/binary2d/docs/types/index.d.ts b/base/binary2d/docs/types/index.d.ts deleted file mode 100644 index 437e0fb9c..000000000 --- a/base/binary2d/docs/types/index.d.ts +++ /dev/null @@ -1,67 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Applies a binary callback to elements in two two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = zeros2d( shape ); -* -* binary2d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] -*/ -declare function binary2d( arrays: [ Array2D, Array2D, Array2D ], shape: Shape2D, fcn: Binary ): void; - - -// EXPORTS // - -export = binary2d; diff --git a/base/binary2d/docs/types/test.ts b/base/binary2d/docs/types/test.ts deleted file mode 100644 index 1e99acf59..000000000 --- a/base/binary2d/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import binary2d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - binary2d( [ x, y, z ], [ 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - binary2d( 'abc', [ 2, 2 ], fcn ); // $ExpectError - binary2d( 3.14, [ 2, 2 ], fcn ); // $ExpectError - binary2d( true, [ 2, 2 ], fcn ); // $ExpectError - binary2d( false, [ 2, 2 ], fcn ); // $ExpectError - binary2d( null, [ 2, 2 ], fcn ); // $ExpectError - binary2d( [ '1' ], [ 2, 2 ], fcn ); // $ExpectError - binary2d( {}, [ 2, 2 ], fcn ); // $ExpectError - binary2d( ( x: number ): number => x, [ 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - binary2d( [ x, y, z ], 'abc', fcn ); // $ExpectError - binary2d( [ x, y, z ], 3.14, fcn ); // $ExpectError - binary2d( [ x, y, z ], true, fcn ); // $ExpectError - binary2d( [ x, y, z ], false, fcn ); // $ExpectError - binary2d( [ x, y, z ], null, fcn ); // $ExpectError - binary2d( [ x, y, z ], [ '1' ], fcn ); // $ExpectError - binary2d( [ x, y, z ], {}, fcn ); // $ExpectError - binary2d( [ x, y, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - binary2d( [ x, y, z ], [ 2, 2 ], 'abc' ); // $ExpectError - binary2d( [ x, y, z ], [ 2, 2 ], 3.14 ); // $ExpectError - binary2d( [ x, y, z ], [ 2, 2 ], true ); // $ExpectError - binary2d( [ x, y, z ], [ 2, 2 ], false ); // $ExpectError - binary2d( [ x, y, z ], [ 2, 2 ], null ); // $ExpectError - binary2d( [ x, y, z ], [ 2, 2 ], [ '1' ] ); // $ExpectError - binary2d( [ x, y, z ], [ 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - binary2d(); // $ExpectError - binary2d( [ x, y, z ] ); // $ExpectError - binary2d( [ x, y, z ], [ 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/binary2d/examples/index.js b/base/binary2d/examples/index.js deleted file mode 100644 index 2295ae075..000000000 --- a/base/binary2d/examples/index.js +++ /dev/null @@ -1,39 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var binary2d = require( './../lib' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros2d( shape ); -console.log( z ); - -binary2d( [ x, y, z ], shape, add ); -console.log( z ); diff --git a/base/binary2d/lib/index.js b/base/binary2d/lib/index.js deleted file mode 100644 index 1ea25c069..000000000 --- a/base/binary2d/lib/index.js +++ /dev/null @@ -1,51 +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'; - -/** -* Apply a binary callback to elements in two two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/binary2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var binary2d = require( '@stdlib/array/base/binary2d' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = zeros2d( shape ); -* -* binary2d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/binary2d/lib/main.js b/base/binary2d/lib/main.js deleted file mode 100644 index 093ab445b..000000000 --- a/base/binary2d/lib/main.js +++ /dev/null @@ -1,84 +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'; - -// MAIN // - -/** -* Applies a binary callback to elements in two two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = zeros2d( shape ); -* -* binary2d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] -*/ -function binary2d( arrays, shape, fcn ) { - var S0; - var S1; - var i0; - var i1; - var x0; - var y0; - var z0; - var x; - var y; - var z; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x[ i1 ]; - y0 = y[ i1 ]; - z0 = z[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - z0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] ); - } - } -} - - -// EXPORTS // - -module.exports = binary2d; diff --git a/base/binary2d/package.json b/base/binary2d/package.json deleted file mode 100644 index c1834bbaa..000000000 --- a/base/binary2d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/binary2d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "binary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/binary2d/test/test.js b/base/binary2d/test/test.js deleted file mode 100644 index ccd26c23e..000000000 --- a/base/binary2d/test/test.js +++ /dev/null @@ -1,121 +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 add = require( '@stdlib/number/float64/base/add' ); -var zeros2d = require( './../../../base/zeros2d' ); -var binary2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof binary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = zeros2d( shape ); - - expected = [ - [ 6.0, 8.0 ], - [ 10.0, 12.0 ] - ]; - binary2d( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = zeros2d( shape ); - - expected = zeros2d( shape ); - binary2d( [ x, y, z ], [ 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = zeros2d( shape ); - - expected = zeros2d( shape ); - binary2d( [ x, y, z ], [ 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/binary3d/README.md b/base/binary3d/README.md deleted file mode 100644 index a56dc1912..000000000 --- a/base/binary3d/README.md +++ /dev/null @@ -1,122 +0,0 @@ - - -# binary3d - -> Apply a binary callback to elements in two three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var binary3d = require( '@stdlib/array/base/binary3d' ); -``` - -#### binary3d( arrays, shape, fcn ) - -Applies a binary callback to elements in two three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); - -var x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; -var z = zeros3d( [ 1, 2, 2 ] ); - -var shape = [ 1, 2, 2 ]; - -binary3d( [ x, x, z ], shape, add ); -// z => [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var binary3d = require( '@stdlib/array/base/binary3d' ); - -var shape = [ 2, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros3d( shape ); -console.log( z ); - -binary3d( [ x, y, z ], shape, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/binary3d/benchmark/benchmark.js b/base/binary3d/benchmark/benchmark.js deleted file mode 100644 index 59f467cd1..000000000 --- a/base/binary3d/benchmark/benchmark.js +++ /dev/null @@ -1,121 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var binary3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - - x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - z = zeros3d( shape ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - binary3d( arrays, shape, add ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 2 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 2 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/binary3d/docs/repl.txt b/base/binary3d/docs/repl.txt deleted file mode 100644 index 687fc05ec..000000000 --- a/base/binary3d/docs/repl.txt +++ /dev/null @@ -1,31 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a binary callback to elements in two three-dimensional nested input - arrays and assigns results to elements in a three-dimensional nested output - array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var z = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - > var shape = [ 1, 2, 2 ]; - > {{alias}}( [ x, y, z ], shape, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] - - See Also - -------- - diff --git a/base/binary3d/docs/types/index.d.ts b/base/binary3d/docs/types/index.d.ts deleted file mode 100644 index d195b15b1..000000000 --- a/base/binary3d/docs/types/index.d.ts +++ /dev/null @@ -1,67 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Applies a binary callback to elements in two three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 2, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = zeros3d( shape ); -* -* binary3d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] -*/ -declare function binary3d( arrays: [ Array3D, Array3D, Array3D ], shape: Shape3D, fcn: Binary ): void; - - -// EXPORTS // - -export = binary3d; diff --git a/base/binary3d/docs/types/test.ts b/base/binary3d/docs/types/test.ts deleted file mode 100644 index 74b0f460d..000000000 --- a/base/binary3d/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import binary3d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - binary3d( [ x, y, z ], [ 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - binary3d( 'abc', [ 1, 2, 2 ], fcn ); // $ExpectError - binary3d( 3.14, [ 1, 2, 2 ], fcn ); // $ExpectError - binary3d( true, [ 1, 2, 2 ], fcn ); // $ExpectError - binary3d( false, [ 1, 2, 2 ], fcn ); // $ExpectError - binary3d( null, [ 1, 2, 2 ], fcn ); // $ExpectError - binary3d( [ '1' ], [ 1, 2, 2 ], fcn ); // $ExpectError - binary3d( {}, [ 1, 2, 2 ], fcn ); // $ExpectError - binary3d( ( x: number ): number => x, [ 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - binary3d( [ x, y, z ], 'abc', fcn ); // $ExpectError - binary3d( [ x, y, z ], 3.14, fcn ); // $ExpectError - binary3d( [ x, y, z ], true, fcn ); // $ExpectError - binary3d( [ x, y, z ], false, fcn ); // $ExpectError - binary3d( [ x, y, z ], null, fcn ); // $ExpectError - binary3d( [ x, y, z ], [ '1' ], fcn ); // $ExpectError - binary3d( [ x, y, z ], {}, fcn ); // $ExpectError - binary3d( [ x, y, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - binary3d( [ x, y, z ], [ 1, 2, 2 ], 'abc' ); // $ExpectError - binary3d( [ x, y, z ], [ 1, 2, 2 ], 3.14 ); // $ExpectError - binary3d( [ x, y, z ], [ 1, 2, 2 ], true ); // $ExpectError - binary3d( [ x, y, z ], [ 1, 2, 2 ], false ); // $ExpectError - binary3d( [ x, y, z ], [ 1, 2, 2 ], null ); // $ExpectError - binary3d( [ x, y, z ], [ 1, 2, 2 ], [ '1' ] ); // $ExpectError - binary3d( [ x, y, z ], [ 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - binary3d(); // $ExpectError - binary3d( [ x, y, z ] ); // $ExpectError - binary3d( [ x, y, z ], [ 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/binary3d/examples/index.js b/base/binary3d/examples/index.js deleted file mode 100644 index 0b1d79016..000000000 --- a/base/binary3d/examples/index.js +++ /dev/null @@ -1,39 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var binary3d = require( './../lib' ); - -var shape = [ 2, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros3d( shape ); -console.log( z ); - -binary3d( [ x, y, z ], shape, add ); -console.log( z ); diff --git a/base/binary3d/lib/index.js b/base/binary3d/lib/index.js deleted file mode 100644 index 41866ff76..000000000 --- a/base/binary3d/lib/index.js +++ /dev/null @@ -1,51 +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'; - -/** -* Apply a binary callback to elements in two three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/binary3d -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var binary3d = require( '@stdlib/array/base/binary3d' ); -* -* var shape = [ 2, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = zeros3d( shape ); -* -* binary3d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/binary3d/lib/main.js b/base/binary3d/lib/main.js deleted file mode 100644 index 223b761b5..000000000 --- a/base/binary3d/lib/main.js +++ /dev/null @@ -1,95 +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'; - -// MAIN // - -/** -* Applies a binary callback to elements in two three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 2, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = zeros3d( shape ); -* -* binary3d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] -*/ -function binary3d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var x0; - var x1; - var y0; - var y1; - var z0; - var z1; - var x; - var y; - var z; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x[ i2 ]; - y1 = y[ i2 ]; - z1 = z[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - z0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] ); - } - } - } -} - - -// EXPORTS // - -module.exports = binary3d; diff --git a/base/binary3d/package.json b/base/binary3d/package.json deleted file mode 100644 index b164693f9..000000000 --- a/base/binary3d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/binary3d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "binary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/binary3d/test/test.js b/base/binary3d/test/test.js deleted file mode 100644 index 2ac9efd9b..000000000 --- a/base/binary3d/test/test.js +++ /dev/null @@ -1,204 +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 add = require( '@stdlib/number/float64/base/add' ); -var zeros3d = require( './../../../base/zeros3d' ); -var binary3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof binary3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = zeros3d( shape ); - - expected = [ - [ - [ 6.0, 8.0 ], - [ 10.0, 12.0 ] - ], - [ - [ 6.0, 8.0 ], - [ 10.0, 12.0 ] - ] - ]; - binary3d( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = zeros3d( shape ); - - expected = zeros3d( shape ); - binary3d( [ x, y, z ], [ 0, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = zeros3d( shape ); - - expected = zeros3d( shape ); - binary3d( [ x, y, z ], [ 2, 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = zeros3d( shape ); - - expected = zeros3d( shape ); - binary3d( [ x, y, z ], [ 2, 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/binary4d/README.md b/base/binary4d/README.md deleted file mode 100644 index d994d7d9c..000000000 --- a/base/binary4d/README.md +++ /dev/null @@ -1,122 +0,0 @@ - - -# binary4d - -> Apply a binary callback to elements in two four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var binary4d = require( '@stdlib/array/base/binary4d' ); -``` - -#### binary4d( arrays, shape, fcn ) - -Applies a binary callback to elements in two four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); - -var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; -var z = zeros4d( [ 1, 1, 2, 2 ] ); - -var shape = [ 1, 1, 2, 2 ]; - -binary4d( [ x, x, z ], shape, add ); -// z => [ [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var binary4d = require( '@stdlib/array/base/binary4d' ); - -var shape = [ 2, 2, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros4d( shape ); -console.log( z ); - -binary4d( [ x, y, z ], shape, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/binary4d/benchmark/benchmark.js b/base/binary4d/benchmark/benchmark.js deleted file mode 100644 index 9b5a35f2b..000000000 --- a/base/binary4d/benchmark/benchmark.js +++ /dev/null @@ -1,124 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var binary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - z = zeros4d( shape ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - binary4d( arrays, shape, add ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 2 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 2 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/binary4d/docs/repl.txt b/base/binary4d/docs/repl.txt deleted file mode 100644 index 5aaf28371..000000000 --- a/base/binary4d/docs/repl.txt +++ /dev/null @@ -1,31 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a binary callback to elements in two four-dimensional nested input - arrays and assigns results to elements in a four-dimensional nested output - array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > {{alias}}( [ x, y, z ], shape, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] ] - - See Also - -------- - diff --git a/base/binary4d/docs/types/index.d.ts b/base/binary4d/docs/types/index.d.ts deleted file mode 100644 index d1f0e3af5..000000000 --- a/base/binary4d/docs/types/index.d.ts +++ /dev/null @@ -1,67 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Applies a binary callback to elements in two four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 1, 2, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = zeros4d( shape ); -* -* binary4d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] -*/ -declare function binary4d( arrays: [ Array4D, Array4D, Array4D ], shape: Shape4D, fcn: Binary ): void; - - -// EXPORTS // - -export = binary4d; diff --git a/base/binary4d/docs/types/test.ts b/base/binary4d/docs/types/test.ts deleted file mode 100644 index 238b5c97d..000000000 --- a/base/binary4d/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import binary4d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - binary4d( [ x, y, z ], [ 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - binary4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - binary4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - binary4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - binary4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - binary4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - binary4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - binary4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - binary4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - binary4d( [ x, y, z ], 'abc', fcn ); // $ExpectError - binary4d( [ x, y, z ], 3.14, fcn ); // $ExpectError - binary4d( [ x, y, z ], true, fcn ); // $ExpectError - binary4d( [ x, y, z ], false, fcn ); // $ExpectError - binary4d( [ x, y, z ], null, fcn ); // $ExpectError - binary4d( [ x, y, z ], [ '1' ], fcn ); // $ExpectError - binary4d( [ x, y, z ], {}, fcn ); // $ExpectError - binary4d( [ x, y, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - binary4d( [ x, y, z ], [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - binary4d( [ x, y, z ], [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - binary4d( [ x, y, z ], [ 1, 1, 2, 2 ], true ); // $ExpectError - binary4d( [ x, y, z ], [ 1, 1, 2, 2 ], false ); // $ExpectError - binary4d( [ x, y, z ], [ 1, 1, 2, 2 ], null ); // $ExpectError - binary4d( [ x, y, z ], [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - binary4d( [ x, y, z ], [ 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - binary4d(); // $ExpectError - binary4d( [ x, y, z ] ); // $ExpectError - binary4d( [ x, y, z ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/binary4d/examples/index.js b/base/binary4d/examples/index.js deleted file mode 100644 index 9a5bd512c..000000000 --- a/base/binary4d/examples/index.js +++ /dev/null @@ -1,39 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var binary4d = require( './../lib' ); - -var shape = [ 2, 2, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros4d( shape ); -console.log( z ); - -binary4d( [ x, y, z ], shape, add ); -console.log( z ); diff --git a/base/binary4d/lib/index.js b/base/binary4d/lib/index.js deleted file mode 100644 index f89b9c752..000000000 --- a/base/binary4d/lib/index.js +++ /dev/null @@ -1,51 +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'; - -/** -* Apply a binary callback to elements in two four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/binary4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var binary4d = require( '@stdlib/array/base/binary4d' ); -* -* var shape = [ 1, 2, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = zeros4d( shape ); -* -* binary4d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/binary4d/lib/main.js b/base/binary4d/lib/main.js deleted file mode 100644 index afd6e78f9..000000000 --- a/base/binary4d/lib/main.js +++ /dev/null @@ -1,106 +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'; - -// MAIN // - -/** -* Applies a binary callback to elements in two four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 1, 2, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = zeros4d( shape ); -* -* binary4d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] -*/ -function binary4d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var x1; - var x2; - var y0; - var y1; - var y2; - var z0; - var z1; - var z2; - var x; - var y; - var z; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - z2 = z[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - z1 = z2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - z0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] ); - } - } - } - } -} - - -// EXPORTS // - -module.exports = binary4d; diff --git a/base/binary4d/package.json b/base/binary4d/package.json deleted file mode 100644 index 18985571a..000000000 --- a/base/binary4d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/binary4d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "binary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/binary4d/test/test.js b/base/binary4d/test/test.js deleted file mode 100644 index b4178c74d..000000000 --- a/base/binary4d/test/test.js +++ /dev/null @@ -1,267 +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 add = require( '@stdlib/number/float64/base/add' ); -var zeros4d = require( './../../../base/zeros4d' ); -var binary4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof binary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = zeros4d( shape ); - - expected = [ - [ - [ - [ 6.0, 8.0 ], - [ 10.0, 12.0 ] - ], - [ - [ 6.0, 8.0 ], - [ 10.0, 12.0 ] - ] - ] - ]; - binary4d( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = zeros4d( shape ); - - expected = zeros4d( shape ); - binary4d( [ x, y, z ], [ 0, 2, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = zeros4d( shape ); - - expected = zeros4d( shape ); - binary4d( [ x, y, z ], [ 2, 0, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = zeros4d( shape ); - - expected = zeros4d( shape ); - binary4d( [ x, y, z ], [ 2, 2, 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a four element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = zeros4d( shape ); - - expected = zeros4d( shape ); - binary4d( [ x, y, z ], [ 2, 2, 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/binary5d/README.md b/base/binary5d/README.md deleted file mode 100644 index eec9242cc..000000000 --- a/base/binary5d/README.md +++ /dev/null @@ -1,122 +0,0 @@ - - -# binary5d - -> Apply a binary callback to elements in two five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var binary5d = require( '@stdlib/array/base/binary5d' ); -``` - -#### binary5d( arrays, shape, fcn ) - -Applies a binary callback to elements in two five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); - -var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; -var z = zeros5d( [ 1, 1, 1, 2, 2 ] ); - -var shape = [ 1, 1, 1, 2, 2 ]; - -binary5d( [ x, x, z ], shape, add ); -// z => [ [ [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var binary5d = require( '@stdlib/array/base/binary5d' ); - -var shape = [ 1, 2, 2, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros5d( shape ); -console.log( z ); - -binary5d( [ x, y, z ], shape, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/binary5d/benchmark/benchmark.js b/base/binary5d/benchmark/benchmark.js deleted file mode 100644 index 2ec49c981..000000000 --- a/base/binary5d/benchmark/benchmark.js +++ /dev/null @@ -1,127 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var binary5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - - x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - z = zeros5d( shape ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - binary5d( arrays, shape, add ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 2 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 2 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/binary5d/docs/repl.txt b/base/binary5d/docs/repl.txt deleted file mode 100644 index ac3e08e97..000000000 --- a/base/binary5d/docs/repl.txt +++ /dev/null @@ -1,31 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a binary callback to elements in two five-dimensional nested input - arrays and assigns results to elements in a five-dimensional nested output - array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shape = [ 1, 1, 1, 2, 2 ]; - > {{alias}}( [ x, y, z ], shape, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/binary5d/docs/types/index.d.ts b/base/binary5d/docs/types/index.d.ts deleted file mode 100644 index b3f331d8a..000000000 --- a/base/binary5d/docs/types/index.d.ts +++ /dev/null @@ -1,67 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Applies a binary callback to elements in two five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 1, 1, 2, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = zeros5d( shape ); -* -* binary5d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] -*/ -declare function binary5d( arrays: [ Array5D, Array5D, Array5D ], shape: Shape5D, fcn: Binary ): void; - - -// EXPORTS // - -export = binary5d; diff --git a/base/binary5d/docs/types/test.ts b/base/binary5d/docs/types/test.ts deleted file mode 100644 index 089e1dd25..000000000 --- a/base/binary5d/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import binary5d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - binary5d( [ x, y, z ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - binary5d( 'abc', [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - binary5d( 3.14, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - binary5d( true, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - binary5d( false, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - binary5d( null, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - binary5d( [ '1' ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - binary5d( {}, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - binary5d( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - binary5d( [ x, y, z ], 'abc', fcn ); // $ExpectError - binary5d( [ x, y, z ], 3.14, fcn ); // $ExpectError - binary5d( [ x, y, z ], true, fcn ); // $ExpectError - binary5d( [ x, y, z ], false, fcn ); // $ExpectError - binary5d( [ x, y, z ], null, fcn ); // $ExpectError - binary5d( [ x, y, z ], [ '1' ], fcn ); // $ExpectError - binary5d( [ x, y, z ], {}, fcn ); // $ExpectError - binary5d( [ x, y, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - binary5d( [ x, y, z ], [ 1, 1, 1, 2, 2 ], 'abc' ); // $ExpectError - binary5d( [ x, y, z ], [ 1, 1, 1, 2, 2 ], 3.14 ); // $ExpectError - binary5d( [ x, y, z ], [ 1, 1, 1, 2, 2 ], true ); // $ExpectError - binary5d( [ x, y, z ], [ 1, 1, 1, 2, 2 ], false ); // $ExpectError - binary5d( [ x, y, z ], [ 1, 1, 1, 2, 2 ], null ); // $ExpectError - binary5d( [ x, y, z ], [ 1, 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - binary5d( [ x, y, z ], [ 1, 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - binary5d(); // $ExpectError - binary5d( [ x, y, z ] ); // $ExpectError - binary5d( [ x, y, z ], [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/binary5d/examples/index.js b/base/binary5d/examples/index.js deleted file mode 100644 index d86ff14eb..000000000 --- a/base/binary5d/examples/index.js +++ /dev/null @@ -1,39 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var binary5d = require( './../lib' ); - -var shape = [ 1, 2, 2, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros5d( shape ); -console.log( z ); - -binary5d( [ x, y, z ], shape, add ); -console.log( z ); diff --git a/base/binary5d/lib/index.js b/base/binary5d/lib/index.js deleted file mode 100644 index a2665ed38..000000000 --- a/base/binary5d/lib/index.js +++ /dev/null @@ -1,51 +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'; - -/** -* Apply a binary callback to elements in two five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/binary5d -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var binary5d = require( '@stdlib/array/base/binary5d' ); -* -* var shape = [ 1, 1, 2, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = zeros5d( shape ); -* -* binary5d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/binary5d/lib/main.js b/base/binary5d/lib/main.js deleted file mode 100644 index bf2f7a325..000000000 --- a/base/binary5d/lib/main.js +++ /dev/null @@ -1,117 +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'; - -// MAIN // - -/** -* Applies a binary callback to elements in two five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 1, 1, 2, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = zeros5d( shape ); -* -* binary5d( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] -*/ -function binary5d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var x0; - var x1; - var x2; - var x3; - var y0; - var y1; - var y2; - var y3; - var z0; - var z1; - var z2; - var z3; - var x; - var y; - var z; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - for ( i4 = 0; i4 < S4; i4++ ) { - x3 = x[ i4 ]; - y3 = y[ i4 ]; - z3 = z[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x3[ i3 ]; - y2 = y3[ i3 ]; - z2 = z3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - z1 = z2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - z0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] ); - } - } - } - } - } -} - - -// EXPORTS // - -module.exports = binary5d; diff --git a/base/binary5d/package.json b/base/binary5d/package.json deleted file mode 100644 index 043199d63..000000000 --- a/base/binary5d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/binary5d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "binary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/binary5d/test/test.js b/base/binary5d/test/test.js deleted file mode 100644 index 583df231a..000000000 --- a/base/binary5d/test/test.js +++ /dev/null @@ -1,338 +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 add = require( '@stdlib/number/float64/base/add' ); -var zeros5d = require( './../../../base/zeros5d' ); -var binary5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof binary5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - - expected = [ - [ - [ - [ - [ 6.0, 8.0 ], - [ 10.0, 12.0 ] - ], - [ - [ 6.0, 8.0 ], - [ 10.0, 12.0 ] - ] - ] - ] - ]; - binary5d( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - - expected = zeros5d( shape ); - binary5d( [ x, y, z ], [ 0, 2, 2, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - - expected = zeros5d( shape ); - binary5d( [ x, y, z ], [ 2, 0, 2, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - - expected = zeros5d( shape ); - binary5d( [ x, y, z ], [ 2, 2, 0, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a four element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - - expected = zeros5d( shape ); - binary5d( [ x, y, z ], [ 2, 2, 2, 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - - expected = zeros5d( shape ); - binary5d( [ x, y, z ], [ 2, 2, 2, 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/binarynd/README.md b/base/binarynd/README.md deleted file mode 100644 index cc968654f..000000000 --- a/base/binarynd/README.md +++ /dev/null @@ -1,133 +0,0 @@ - - -# binarynd - -> Apply a binary callback to elements in two n-dimensional nested input arrays and assign results to elements in an n-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var binarynd = require( '@stdlib/array/base/binarynd' ); -``` - -#### binarynd( arrays, shape, fcn ) - -Applies a binary callback to elements in two n-dimensional nested input arrays and assigns results to elements in an n-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); - -var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; -var shape = [ 2, 2 ]; - -binarynd( [ x, x, x ], shape, add ); -// x => [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filledndBy = require( '@stdlib/array/base/fillednd-by' ); -var zerosnd = require( '@stdlib/array/base/zerosnd' ); -var add = require( '@stdlib/number/float64/base/add' ); -var binarynd = require( '@stdlib/array/base/binarynd' ); - -var shape = [ 3, 3 ]; - -var x = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zerosnd( shape ); -console.log( z ); - -binarynd( [ x, y, z ], shape, add ); -console.log( z ); - -shape = [ 3, 3, 3 ]; - -x = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -y = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -z = zerosnd( shape ); -console.log( z ); - -binarynd( [ x, y, z ], shape, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/binarynd/benchmark/benchmark.size.2d.js b/base/binarynd/benchmark/benchmark.size.2d.js deleted file mode 100644 index bcae85d86..000000000 --- a/base/binarynd/benchmark/benchmark.size.2d.js +++ /dev/null @@ -1,118 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filledndBy = require( './../../../base/fillednd-by' ); -var zerosnd = require( './../../../base/zerosnd' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var binarynd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - - x = filledndBy( shape, uniform( -100.0, 100.0 ) ); - y = filledndBy( shape, uniform( -100.0, 100.0 ) ); - z = zerosnd( shape ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - binarynd( arrays, shape, add ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::2d,equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/binarynd/benchmark/benchmark.size.3d.js b/base/binarynd/benchmark/benchmark.size.3d.js deleted file mode 100644 index 485e2e972..000000000 --- a/base/binarynd/benchmark/benchmark.size.3d.js +++ /dev/null @@ -1,121 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filledndBy = require( './../../../base/fillednd-by' ); -var zerosnd = require( './../../../base/zerosnd' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var binarynd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - - x = filledndBy( shape, uniform( -100.0, 100.0 ) ); - y = filledndBy( shape, uniform( -100.0, 100.0 ) ); - z = zerosnd( shape ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - binarynd( arrays, shape, add ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 2 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 2 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::3d,equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/binarynd/benchmark/benchmark.size.4d.js b/base/binarynd/benchmark/benchmark.size.4d.js deleted file mode 100644 index 35e4020cc..000000000 --- a/base/binarynd/benchmark/benchmark.size.4d.js +++ /dev/null @@ -1,124 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filledndBy = require( './../../../base/fillednd-by' ); -var zerosnd = require( './../../../base/zerosnd' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var binarynd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - - x = filledndBy( shape, uniform( -100.0, 100.0 ) ); - y = filledndBy( shape, uniform( -100.0, 100.0 ) ); - z = zerosnd( shape ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - binarynd( arrays, shape, add ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 2 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 2 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::4d,equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/binarynd/benchmark/benchmark.size.5d.js b/base/binarynd/benchmark/benchmark.size.5d.js deleted file mode 100644 index e530bbb4a..000000000 --- a/base/binarynd/benchmark/benchmark.size.5d.js +++ /dev/null @@ -1,127 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filledndBy = require( './../../../base/fillednd-by' ); -var zerosnd = require( './../../../base/zerosnd' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var binarynd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - - x = filledndBy( shape, uniform( -100.0, 100.0 ) ); - y = filledndBy( shape, uniform( -100.0, 100.0 ) ); - z = zerosnd( shape ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - binarynd( arrays, shape, add ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 2 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 2 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::5d,equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/binarynd/docs/repl.txt b/base/binarynd/docs/repl.txt deleted file mode 100644 index dcec15ca5..000000000 --- a/base/binarynd/docs/repl.txt +++ /dev/null @@ -1,31 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a binary callback to elements in two n-dimensional nested input - arrays and assigns results to elements in an n-dimensional nested output - array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shape = [ 2, 2 ]; - > {{alias}}( [ x, y, z ], shape, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] - - See Also - -------- - diff --git a/base/binarynd/docs/types/index.d.ts b/base/binarynd/docs/types/index.d.ts deleted file mode 100644 index 9a6b259ad..000000000 --- a/base/binarynd/docs/types/index.d.ts +++ /dev/null @@ -1,357 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D, Array5D, Array6D, Array7D, Array8D, Array9D, Array10D } from '@stdlib/types/array'; -import { Shape, Shape1D, Shape2D, Shape3D, Shape4D, Shape5D, Shape6D, Shape7D, Shape8D, Shape9D, Shape10D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Applies a binary callback to elements in two one-dimensional nested input arrays and assigns results to elements in a one-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ 2.0, 2.0 ] -*/ -declare function binarynd( arrays: [ Array1D, Array1D, Array1D ], shape: Shape1D, fcn: Binary ): void; - -/** -* Applies a binary callback to elements in two two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] -*/ -declare function binarynd( arrays: [ Array2D, Array2D, Array2D ], shape: Shape2D, fcn: Binary ): void; - -/** -* Applies a binary callback to elements in two three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] -*/ -declare function binarynd( arrays: [ Array3D, Array3D, Array3D ], shape: Shape3D, fcn: Binary ): void; - -/** -* Applies a binary callback to elements in two four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] -*/ -declare function binarynd( arrays: [ Array4D, Array4D, Array4D ], shape: Shape4D, fcn: Binary ): void; - -/** -* Applies a binary callback to elements in two five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] -*/ -declare function binarynd( arrays: [ Array5D, Array5D, Array5D ], shape: Shape5D, fcn: Binary ): void; - -/** -* Applies a binary callback to elements in two six-dimensional nested input arrays and assigns results to elements in a six-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] ] -*/ -declare function binarynd( arrays: [ Array6D, Array6D, Array6D ], shape: Shape6D, fcn: Binary ): void; - -/** -* Applies a binary callback to elements in two seven-dimensional nested input arrays and assigns results to elements in a seven-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 1, 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] ] ] -*/ -declare function binarynd( arrays: [ Array7D, Array7D, Array7D ], shape: Shape7D, fcn: Binary ): void; - -/** -* Applies a binary callback to elements in two eight-dimensional nested input arrays and assigns results to elements in an eight-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 1, 1, 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] ] ] ] -*/ -declare function binarynd( arrays: [ Array8D, Array8D, Array8D ], shape: Shape8D, fcn: Binary ): void; - -/** -* Applies a binary callback to elements in two nine-dimensional nested input arrays and assigns results to elements in a nine-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] ] ] ] ] -*/ -declare function binarynd( arrays: [ Array9D, Array9D, Array9D ], shape: Shape9D, fcn: Binary ): void; - -/** -* Applies a binary callback to elements in two ten-dimensional nested input arrays and assigns results to elements in a ten-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] ] ] ] ] ] -*/ -declare function binarynd( arrays: [ Array10D, Array10D, Array10D ], shape: Shape10D, fcn: Binary ): void; - -/** -* Applies a binary callback to elements in two n-dimensional nested input arrays and assigns results to elements in an n-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ [ [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] ] ] ] ] ] ] -*/ -declare function binarynd( arrays: [ Array, Array, Array ], shape: Shape, fcn: Binary ): void; - - -// EXPORTS // - -export = binarynd; diff --git a/base/binarynd/docs/types/test.ts b/base/binarynd/docs/types/test.ts deleted file mode 100644 index 587a42e26..000000000 --- a/base/binarynd/docs/types/test.ts +++ /dev/null @@ -1,112 +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. -*/ - -import binarynd = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x1 = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y1 = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - binarynd( [ x1, x1, y1 ], [ 2, 2 ], fcn ); // $ExpectType void - - const x2 = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y2 = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - binarynd( [ x2, x2, y2 ], [ 1, 2, 2 ], fcn ); // $ExpectType void - - const x3 = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y3 = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - binarynd( [ x3, x3, y3 ], [ 1, 1, 2, 2 ], fcn ); // $ExpectType void - - const x4 = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y4 = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - binarynd( [ x4, x4, y4 ], [ 1, 1, 2, 2 ], fcn ); // $ExpectType void - - const x5 = [ [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ] ]; - const y5 = [ [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ] ]; - - binarynd( [ x5, x5, y5 ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - binarynd( 'abc', [ 2, 2 ], fcn ); // $ExpectError - binarynd( 3.14, [ 2, 2 ], fcn ); // $ExpectError - binarynd( true, [ 2, 2 ], fcn ); // $ExpectError - binarynd( false, [ 2, 2 ], fcn ); // $ExpectError - binarynd( null, [ 2, 2 ], fcn ); // $ExpectError - binarynd( [ '1' ], [ 2, 2 ], fcn ); // $ExpectError - binarynd( {}, [ 2, 2 ], fcn ); // $ExpectError - binarynd( ( x: number ): number => x, [ 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - binarynd( [ x, x, y ], 'abc', fcn ); // $ExpectError - binarynd( [ x, x, y ], 3.14, fcn ); // $ExpectError - binarynd( [ x, x, y ], true, fcn ); // $ExpectError - binarynd( [ x, x, y ], false, fcn ); // $ExpectError - binarynd( [ x, x, y ], null, fcn ); // $ExpectError - binarynd( [ x, x, y ], [ '1' ], fcn ); // $ExpectError - binarynd( [ x, x, y ], {}, fcn ); // $ExpectError - binarynd( [ x, x, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - binarynd( [ x, x, y ], [ 2, 2 ], 'abc' ); // $ExpectError - binarynd( [ x, x, y ], [ 2, 2 ], 3.14 ); // $ExpectError - binarynd( [ x, x, y ], [ 2, 2 ], true ); // $ExpectError - binarynd( [ x, x, y ], [ 2, 2 ], false ); // $ExpectError - binarynd( [ x, x, y ], [ 2, 2 ], null ); // $ExpectError - binarynd( [ x, x, y ], [ 2, 2 ], [ '1' ] ); // $ExpectError - binarynd( [ x, x, y ], [ 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - binarynd(); // $ExpectError - binarynd( [ x, x, y ] ); // $ExpectError - binarynd( [ x, x, y ], [ 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/binarynd/examples/index.js b/base/binarynd/examples/index.js deleted file mode 100644 index 5b85c840e..000000000 --- a/base/binarynd/examples/index.js +++ /dev/null @@ -1,53 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filledndBy = require( './../../../base/fillednd-by' ); -var zerosnd = require( './../../../base/zerosnd' ); -var add = require( '@stdlib/number/float64/base/add' ); -var binarynd = require( './../lib' ); - -var shape = [ 3, 3 ]; - -var x = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zerosnd( shape ); -console.log( z ); - -binarynd( [ x, y, z ], shape, add ); -console.log( z ); - -shape = [ 3, 3, 3 ]; - -x = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -y = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -z = zerosnd( shape ); -console.log( z ); - -binarynd( [ x, y, z ], shape, add ); -console.log( z ); diff --git a/base/binarynd/lib/index.js b/base/binarynd/lib/index.js deleted file mode 100644 index 6e5080ded..000000000 --- a/base/binarynd/lib/index.js +++ /dev/null @@ -1,51 +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'; - -/** -* Apply a binary callback to elements in an n-dimensional nested input array and assign results to elements in an n-dimensional nested output array. -* -* @module @stdlib/array/base/binarynd -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* var binarynd = require( '@stdlib/array/base/binarynd' ); -* -* var shape = [ 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/binarynd/lib/main.js b/base/binarynd/lib/main.js deleted file mode 100644 index 34a0ec035..000000000 --- a/base/binarynd/lib/main.js +++ /dev/null @@ -1,97 +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'; - -// FUNCTIONS // - -/** -* Recursively applies a binary callback. -* -* @private -* @param {ArrayLikeObject} x - input array -* @param {ArrayLikeObject} y - input array -* @param {ArrayLikeObject} z - output array -* @param {NonNegativeInteger} ndims - number of dimensions -* @param {NonNegativeIntegerArray} shape - array shape -* @param {NonNegativeInteger} dim - dimension index -* @param {Callback} fcn - binary callback -* @returns {void} -*/ -function recurse( x, y, z, ndims, shape, dim, fcn ) { - var S; - var d; - var i; - - S = shape[ dim ]; - - // Check whether we've reached the innermost dimension: - d = dim + 1; - - if ( d === ndims ) { - // Apply the provided callback... - for ( i = 0; i < S; i++ ) { - z[ i ] = fcn( x[ i ], y[ i ] ); - } - return; - } - // Continue recursing into the nested arrays... - for ( i = 0; i < S; i++ ) { - recurse( x[ i ], y[ i ], z[ i ], ndims, shape, d, fcn ); - } -} - - -// MAIN // - -/** -* Applies a binary callback to elements in two n-dimensional nested input arrays and assigns results to elements in an n-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add' ); -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var shape = [ 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = onesnd( shape ); -* var z = zerosnd( shape ); -* -* binarynd( [ x, y, z ], shape, add ); -* -* console.log( z ); -* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] -*/ -function binarynd( arrays, shape, fcn ) { - return recurse( arrays[ 0 ], arrays[ 1 ], arrays[ 2 ], shape.length, shape, 0, fcn ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = binarynd; diff --git a/base/binarynd/package.json b/base/binarynd/package.json deleted file mode 100644 index 90ecac5d4..000000000 --- a/base/binarynd/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/binarynd", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two n-dimensional nested input arrays and assign results to elements in an n-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "cube", - "nd", - "binary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/binarynd/test/test.js b/base/binarynd/test/test.js deleted file mode 100644 index 3871dbe4e..000000000 --- a/base/binarynd/test/test.js +++ /dev/null @@ -1,1272 +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 add = require( '@stdlib/number/float64/base/add' ); -var zerosnd = require( './../../../base/zerosnd' ); -var binarynd = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof binarynd, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array (0d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = []; - x = []; - y = []; - - expected = []; - - z = zerosnd( shape ); - binarynd( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array (1d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2 ]; - x = [ 1.0, 2.0 ]; - y = [ 3.0, 4.0 ]; - - expected = [ 4.0, 6.0 ]; - - z = zerosnd( shape ); - binarynd( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array (2d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - - expected = [ - [ 6.0, 8.0 ], - [ 10.0, 12.0 ] - ]; - - z = zerosnd( shape ); - binarynd( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - - shape = [ 2, 3 ]; - x = [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ]; - y = [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ]; - - expected = [ - [ 2.0, 4.0, 6.0 ], - [ 6.0, 8.0, 10.0 ] - ]; - - z = zerosnd( shape ); - binarynd( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array (3d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - - expected = [ - [ - [ 6.0, 8.0 ], - [ 10.0, 12.0 ] - ], - [ - [ 6.0, 8.0 ], - [ 10.0, 12.0 ] - ] - ]; - - z = zerosnd( shape ); - binarynd( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - - shape = [ 2, 2, 3 ]; - x = [ - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ], - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ] - ]; - y = [ - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ], - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ] - ]; - - expected = [ - [ - [ 2.0, 4.0, 6.0 ], - [ 6.0, 8.0, 10.0 ] - ], - [ - [ 2.0, 4.0, 6.0 ], - [ 6.0, 8.0, 10.0 ] - ] - ]; - - z = zerosnd( shape ); - binarynd( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array (4d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ], - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ] - ], - [ - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ], - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ] - ] - ]; - - z = zerosnd( shape ); - binarynd( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - - shape = [ 1, 2, 2, 3 ]; - x = [ - [ - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ], - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ], - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 2.0, 4.0, 6.0 ], - [ 6.0, 8.0, 10.0 ] - ], - [ - [ 2.0, 4.0, 6.0 ], - [ 6.0, 8.0, 10.0 ] - ] - ] - ]; - - z = zerosnd( shape ); - binarynd( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 1, 1, 1, 1, 3 ]; - x = [ - [ - [ - [ - [ 1.0, 1.0, 1.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 1.0, 1.0, 1.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 2.0, 2.0, 2.0 ] - ] - ] - ] - ]; - - z = zerosnd( shape ); - binarynd( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - - shape = [ 2, 1, 2, 3, 1 ]; - x = [ - [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 2.0 ], - [ 2.0 ], - [ 2.0 ] - ], - [ - [ 2.0 ], - [ 2.0 ], - [ 2.0 ] - ] - ] - ], - [ - [ - [ - [ 2.0 ], - [ 2.0 ], - [ 2.0 ] - ], - [ - [ 2.0 ], - [ 2.0 ], - [ 2.0 ] - ] - ] - ] - ]; - - z = zerosnd( shape ); - binarynd( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - - shape = [ 1, 2, 2, 3, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ], - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ], - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 2.0, 2.0 ], - [ 2.0, 2.0 ], - [ 2.0, 2.0 ] - ], - [ - [ 2.0, 2.0 ], - [ 2.0, 2.0 ], - [ 2.0, 2.0 ] - ] - ], - [ - [ - [ 2.0, 2.0 ], - [ 2.0, 2.0 ], - [ 2.0, 2.0 ] - ], - [ - [ 2.0, 2.0 ], - [ 2.0, 2.0 ], - [ 2.0, 2.0 ] - ] - ] - ] - ]; - - z = zerosnd( shape ); - binarynd( [ x, y, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero (1d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2 ]; - x = [ 1.0, 2.0 ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero (2d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero (2d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero (3d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 0, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero (3d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 2, 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero (3d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 2, 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero (4d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 0, 2, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero (4d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 2, 0, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero (4d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 2, 2, 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero (4d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 2, 2, 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero (5d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 0, 2, 2, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero (5d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 2, 0, 2, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero (5d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 2, 2, 0, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero (5d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 2, 2, 2, 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fifth element equal to zero (5d)', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - - expected = zerosnd( shape ); - - z = zerosnd( shape ); - binarynd( [ x, y, z ], [ 2, 2, 2, 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcast-array/README.md b/base/broadcast-array/README.md deleted file mode 100644 index 68a7cbb32..000000000 --- a/base/broadcast-array/README.md +++ /dev/null @@ -1,173 +0,0 @@ - - -# broadcastArray - -> Broadcast an array to a specified shape. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var broadcastArray = require( '@stdlib/array/base/broadcast-array' ); -``` - -#### broadcastArray( x, inShape, outShape ) - -Broadcasts an array to a specified shape. - -```javascript -var x = [ 1, 2 ]; - -var out = broadcastArray( x, [ 2 ], [ 2, 2 ] ); -// returns {...} - -var shape = out.shape; -// returns [ 2, 2 ] - -var strides = out.strides; -// returns [ 0, 1 ] - -var ref = out.ref; -// returns [ 1, 2 ] - -var bool = ( x === ref ); -// returns true - -var data = out.data; -// returns [ [ 1, 2 ] ] -``` - -The function returns an object having the following properties: - -- **ref**: reference to the original input array. -- **data**: broadcasted array. -- **shape**: broadcasted array shape. -- **strides**: broadcasted array strides. Strides describe how to iterate over broadcasted array dimensions. - -
- - - - - -
- -## Notes - -- The broadcasted array shares the same data as the input array. As more than one element of a broadcasted array may refer to the same memory location, writing to the broadcasted array may affect multiple elements. If you need to write to the broadcasted array, copy the array **before** performing operations which may mutate elements. -- The function throws an error if a provided input shape is [incompatible][@stdlib/ndarray/base/broadcast-shapes] with a provided output shape. - -
- - - - - -
- -## Examples - - - -```javascript -var broadcastArray = require( '@stdlib/array/base/broadcast-array' ); - -// Create a 2x1 array: -var x = [ - [ 1 ], - [ 2 ] -]; - -// Broadcast the array to 3x2x4: -var o = broadcastArray( x, [ 2, 1 ], [ 3, 2, 4 ] ); -// returns {...} - -// Retrieve the shape: -var sh = o.shape; -// returns [ 3, 2, 4 ] - -// Retrieve the array "strides": -var st = o.strides; -// returns [...] - -// Initialize loop indices: -var i0 = 0; -var i1 = 0; -var i2 = 0; - -// Iterate over elements in the broadcasted array... -var i; -var j; -var k; -for ( i = 0; i < sh[ 0 ]; i++ ) { - i1 = 0; - for ( j = 0; j < sh[ 1 ]; j++ ) { - i2 = 0; - for ( k = 0; k < sh[ 2 ]; k++ ) { - console.log( 'y[%s] = %d', [ i, j, k ].join( ',' ), o.data[ i0 ][ i1 ][ i2 ] ); - i2 += st[ 2 ]; - } - i1 += st[ 1 ]; - } - i0 += st[ 0 ]; -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/broadcast-array/benchmark/benchmark.dimensions.js b/base/broadcast-array/benchmark/benchmark.dimensions.js deleted file mode 100644 index dd4aa597c..000000000 --- a/base/broadcast-array/benchmark/benchmark.dimensions.js +++ /dev/null @@ -1,116 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isEven = require( '@stdlib/math/base/assert/is-even' ); -var zerosnd = require( './../../../base/zerosnd' ); -var pkg = require( './../package.json' ).name; -var broadcastArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - number of dimensions -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - var outShape; - var inShape; - var x; - var i; - - outShape = []; - inShape = []; - - // Create an input shape such that half of the dimensions are one (and thus need to be broadcasted) and half of the dimensions are equal to the respective output shape dimensions... - for ( i = 1; i < N+1; i++ ) { - outShape.push( i ); - if ( isEven( i ) ) { - inShape.push( i ); - } else { - inShape.push( 1 ); - } - } - x = zerosnd( inShape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = broadcastArray( x, inShape, outShape ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( - !isArray( out.data ) || - !isArray( out.ref ) || - !isArray( out.shape ) || - !isArray( out.strides ) - ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 10; // 10^max - - for ( i = min; i <= max; i++ ) { - f = createBenchmark( i ); - bench( pkg+':dimensions='+i, f ); - } -} - -main(); diff --git a/base/broadcast-array/docs/repl.txt b/base/broadcast-array/docs/repl.txt deleted file mode 100644 index 709282c02..000000000 --- a/base/broadcast-array/docs/repl.txt +++ /dev/null @@ -1,55 +0,0 @@ - -{{alias}}( x, inShape, outShape ) - Broadcasts an array to a specified shape. - - The broadcasted array shares the same data as the input array. As more than - one element of a broadcasted array may refer to the same memory location, - writing to the broadcasted array may affect multiple elements. If you need - to write to the broadcasted array, copy the array before performing - operations which may mutate elements. - - The function throws an error if a provided input shape is incompatible with - a provided output shape. - - Parameters - ---------- - x: Collection - Input array. - - inShape: Collection - Input array shape. - - outShape: Collection - Output array shape. - - Returns - ------- - out: Object - Broadcast object. - - out.ref: Collection - Reference to original input array. - - out.data: ArrayLikeObject - Broadcasted array. - - out.shape: Array - Broadcasted array shape. - - out.strides: Array - Broadcasted array strides. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3 ], [ 3 ], [ 2, 3 ] ) - {...} - > out.shape - [ 2, 3 ] - > out.strides - [ 0, 1 ] - > out.data - [ [ 1, 2, 3 ] ] - - See Also - -------- - diff --git a/base/broadcast-array/docs/types/index.d.ts b/base/broadcast-array/docs/types/index.d.ts deleted file mode 100644 index d7b2db130..000000000 --- a/base/broadcast-array/docs/types/index.d.ts +++ /dev/null @@ -1,115 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Interface describing a broadcast object. -*/ -interface BroadcastObject { - /** - * Reference to the input array. - */ - ref: Collection; - - /** - * Broadcasted array. - */ - data: any; // FIXME: how to type this, as this can be an arbitrarily nested array, where the number of dimensions is dependent on the length of `inShape`? - - /** - * Broadcasted array shape. - */ - shape: Array; - - /** - * Broadcasted array strides. - */ - strides: Array; -} - -/** -* Broadcasts an array to a specified shape. -* -* ## Notes -* -* - The broadcasted array shares the same data as the input array. As more than one element of a broadcasted array may refer to the same memory location, writing to the broadcasted array may affect multiple elements. If you need to write to the broadcasted array, copy the array before performing operations which may mutate elements. -* - The function throws an error if a provided input shape is incompatible with a provided output shape. -* -* @param x - input array -* @param inShape - input array shape -* @param outShape - output array shape -* @throws input array cannot have more dimensions than the desired shape -* @throws input array dimension sizes must be `1` or equal to the corresponding dimension in the provided output shape -* @returns broadcast object -* -* @example -* var x = [ 1, 2 ]; -* -* var out = broadcastArray( x, [ 2 ], [ 2, 2 ] ); -* // returns {...} -* -* var shape = out.shape; -* // returns [ 2, 2 ] -* -* var strides = out.strides; -* // returns [ 0, 1 ] -* -* var ref = out.ref; -* // returns [ 1, 2 ] -* -* var bool = ( x === ref ); -* // returns true -* -* var data = out.data; -* // returns [ [ 1, 2 ] ] -* -* @example -* var x = [ 1, 2 ]; -* -* var out = broadcastArray( x, [ 2 ], [ 2, 1, 2 ] ); -* // returns {...} -* -* var data = out.data; -* // returns [ [ [ 1, 2 ] ] ] -* -* var strides = out.strides; -* // returns [ 0, 0, 1 ] -* -* @example -* var x = [ [ 1 ], [ 2 ] ]; -* -* var out = broadcastArray( x, [ 2, 1 ], [ 3, 2, 2 ] ); -* // returns {...} -* -* var data = out.data; -* // returns [ [ [ 1 ], [ 2 ] ] ] -* -* var strides = out.strides; -* // returns [ 0, 1, 0 ] -*/ -declare function broadcastArray( x: Collection, inShape: Collection, outShape: Collection ): BroadcastObject; - - -// EXPORTS // - -export = broadcastArray; diff --git a/base/broadcast-array/docs/types/test.ts b/base/broadcast-array/docs/types/test.ts deleted file mode 100644 index 03133e526..000000000 --- a/base/broadcast-array/docs/types/test.ts +++ /dev/null @@ -1,67 +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. -*/ - -import broadcastArray = require( './index' ); - - -// TESTS // - -// The function returns a results object... -{ - broadcastArray( [ 1, 2, 3 ], [ 3 ], [ 2, 3 ] ); // $ExpectType BroadcastObject -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - broadcastArray( 5, [ 3 ], [ 2, 3 ] ); // $ExpectError - broadcastArray( true, [ 3 ], [ 2, 3 ] ); // $ExpectError - broadcastArray( false, [ 3 ], [ 2, 3 ] ); // $ExpectError - broadcastArray( null, [ 3 ], [ 2, 3 ] ); // $ExpectError - broadcastArray( {}, [ 3 ], [ 2, 3 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection of numbers... -{ - broadcastArray( [ 1, 2, 3 ], '5', [ 2, 3 ] ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], 5, [ 2, 3 ] ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], true, [ 2, 3 ] ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], false, [ 2, 3 ] ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], null, [ 2, 3 ] ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], [ '1' ], [ 2, 3 ] ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], {}, [ 2, 3 ] ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], ( x: number ): number => x, [ 2, 3 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a collection of numbers... -{ - broadcastArray( [ 1, 2, 3 ], [ 3 ], '5' ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], [ 3 ], 5 ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], [ 3 ], true ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], [ 3 ], false ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], [ 3 ], null ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], [ 3 ], [ '1' ] ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], [ 3 ], {} ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], [ 3 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - broadcastArray(); // $ExpectError - broadcastArray( [ 1, 2, 3 ], [ 3 ] ); // $ExpectError - broadcastArray( [ 1, 2, 3 ], [ 3 ], [ 2, 3 ], {} ); // $ExpectError -} diff --git a/base/broadcast-array/examples/index.js b/base/broadcast-array/examples/index.js deleted file mode 100644 index d0c9043df..000000000 --- a/base/broadcast-array/examples/index.js +++ /dev/null @@ -1,61 +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'; - -var broadcastArray = require( './../lib' ); - -// Create a 2x1 array: -var x = [ - [ 1 ], - [ 2 ] -]; - -// Broadcast the array to 3x2x4: -var o = broadcastArray( x, [ 2, 1 ], [ 3, 2, 4 ] ); -// returns {...} - -// Retrieve the shape: -var sh = o.shape; -// returns [ 3, 2, 4 ] - -// Retrieve the array "strides": -var st = o.strides; -// returns [...] - -// Initialize loop indices: -var i0 = 0; -var i1 = 0; -var i2 = 0; - -// Iterate over elements in the broadcasted array... -var i; -var j; -var k; -for ( i = 0; i < sh[ 0 ]; i++ ) { - i1 = 0; - for ( j = 0; j < sh[ 1 ]; j++ ) { - i2 = 0; - for ( k = 0; k < sh[ 2 ]; k++ ) { - console.log( 'y[%s] = %d', [ i, j, k ].join( ',' ), o.data[ i0 ][ i1 ][ i2 ] ); - i2 += st[ 2 ]; - } - i1 += st[ 1 ]; - } - i0 += st[ 0 ]; -} diff --git a/base/broadcast-array/lib/index.js b/base/broadcast-array/lib/index.js deleted file mode 100644 index 7c6fd9e56..000000000 --- a/base/broadcast-array/lib/index.js +++ /dev/null @@ -1,57 +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'; - -/** -* Broadcast an array to a specified shape. -* -* @module @stdlib/array/base/broadcast-array -* -* @example -* var broadcastArray = require( '@stdlib/array/base/broadcast-array' ); -* -* var x = [ 1, 2 ]; -* -* var out = broadcastArray( x, [ 2 ], [ 2, 2 ] ); -* // returns {...} -* -* var shape = out.shape; -* // returns [ 2, 2 ] -* -* var strides = out.strides; -* // returns [ 0, 1 ] -* -* var ref = out.ref; -* // returns [ 1, 2 ] -* -* var bool = ( x === ref ); -* // returns true -* -* var data = out.data; -* // returns [ [ 1, 2 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcast-array/lib/main.js b/base/broadcast-array/lib/main.js deleted file mode 100644 index 37235223f..000000000 --- a/base/broadcast-array/lib/main.js +++ /dev/null @@ -1,145 +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 copy = require( './../../../base/copy-indexed' ); -var zeros = require( './../../../base/zeros' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Broadcasts an array to a specified shape. -* -* @param {Collection} x - input array -* @param {NonNegativeIntegerArray} inShape - input array shape -* @param {NonNegativeIntegerArray} outShape - output array shape -* @throws {Error} input array cannot have more dimensions than the desired shape -* @throws {Error} input array dimension sizes must be `1` or equal to the corresponding dimension in the provided output shape -* @throws {Error} input array and desired shape must be broadcast compatible -* @returns {Object} broadcast object -* -* @example -* var x = [ 1, 2 ]; -* -* var out = broadcastArray( x, [ 2 ], [ 2, 2 ] ); -* // returns {...} -* -* var shape = out.shape; -* // returns [ 2, 2 ] -* -* var strides = out.strides; -* // returns [ 0, 1 ] -* -* var ref = out.ref; -* // returns [ 1, 2 ] -* -* var bool = ( x === ref ); -* // returns true -* -* var data = out.data; -* // returns [ [ 1, 2 ] ] -* -* @example -* var x = [ 1, 2 ]; -* -* var out = broadcastArray( x, [ 2 ], [ 2, 1, 2 ] ); -* // returns {...} -* -* var data = out.data; -* // returns [ [ [ 1, 2 ] ] ] -* -* var strides = out.strides; -* // returns [ 0, 0, 1 ] -* -* @example -* var x = [ [ 1 ], [ 2 ] ]; -* -* var out = broadcastArray( x, [ 2, 1 ], [ 3, 2, 2 ] ); -* // returns {...} -* -* var data = out.data; -* // returns [ [ [ 1 ], [ 2 ] ] ] -* -* var strides = out.strides; -* // returns [ 0, 1, 0 ] -*/ -function broadcastArray( x, inShape, outShape ) { - var data; - var dim; - var st; - var N; - var M; - var d; - var i; - var j; - - N = outShape.length; - M = inShape.length; - if ( N < M ) { - throw new Error( 'invalid argument. Cannot broadcast an array to a shape having fewer dimensions. Arrays can only be broadcasted to shapes having the same or more dimensions.' ); - } - // Prepend additional dimensions... - data = x; - for ( i = M; i < N; i++ ) { - data = [ data ]; - } - - // Initialize a strides array: - st = zeros( N ); - - // Determine the output array strides... - for ( i = N-1; i >= 0; i-- ) { - j = M - N + i; - if ( j < 0 ) { - // Prepended singleton dimension; stride is zero... - continue; - } - d = inShape[ j ]; - dim = outShape[ i ]; - if ( dim !== 0 && dim < d ) { - throw new Error( format( 'invalid argument. Input array cannot be broadcast to the specified shape, as the specified shape has a dimension whose size is less than the size of the corresponding dimension in the input array. Array shape: (%s). Desired shape: (%s). Dimension: %u.', copy( inShape ).join( ', ' ), copy( outShape ).join( ', ' ), i ) ); - } - if ( d === dim ) { - // As the dimension sizes are equal, the stride is one, meaning that each element in the array should be iterated over as normal... - st[ i ] = 1; - } else if ( d === 1 ) { - // In order to broadcast a dimension, we set the stride for that dimension to zero... - st[ i ] = 0; - } else { - // At this point, we know that `dim > d` and that `d` does not equal `1` (e.g., `dim=3` and `d=2`); in which case, the shapes are considered incompatible (even for desired shapes which are multiples of array dimensions, as might be desired when "tiling" an array; e.g., `dim=4` and `d=2`)... - throw new Error( format( 'invalid argument. Input array and the specified shape are broadcast incompatible. Array shape: (%s). Desired shape: (%s). Dimension: %u.', copy( inShape ).join( ', ' ), copy( outShape ).join( ', ' ), i ) ); - } - } - // Return broadcast results: - return { - 'ref': x, // reference to the original input array - 'data': data, // broadcasted array - 'shape': copy( outShape ), // copy in order to prevent mutation - 'strides': st - }; -} - - -// EXPORTS // - -module.exports = broadcastArray; diff --git a/base/broadcast-array/package.json b/base/broadcast-array/package.json deleted file mode 100644 index 04f4c6947..000000000 --- a/base/broadcast-array/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcast-array", - "version": "0.0.0", - "description": "Broadcast an array to a specified shape.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utility", - "utils", - "util", - "base", - "array", - "broadcast", - "broadcasting", - "reshape", - "multidimensional", - "ndarray" - ], - "__stdlib__": {} -} diff --git a/base/broadcast-array/test/test.js b/base/broadcast-array/test/test.js deleted file mode 100644 index 8bf17ff6a..000000000 --- a/base/broadcast-array/test/test.js +++ /dev/null @@ -1,323 +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 zeros2d = require( './../../../base/zeros2d' ); -var broadcastArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof broadcastArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an output shape which has fewer dimensions than input array', function test( t ) { - var values; - var x; - var i; - - x = [ [ [ [ [ [ [ [ [ [ ] ] ] ] ] ] ] ] ] ]; - - values = [ - [], - [ 1 ], - [ 1, 1 ], - [ 1, 1, 1 ], - [ 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 1, 1, 1, 1, 1, 1 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided a shape with '+values[ i ].length+' dimension' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - broadcastArray( x, [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a desired shape having a dimension whose size is less than the corresponding dimension in the input array', function test( t ) { - var values; - var x; - var i; - - x = zeros2d( [ 10, 10 ] ); - - values = [ - [ 10, 10, 1 ], - [ 10, 10, 2 ], - [ 10, 10, 9 ], - [ 10, 1, 10 ], - [ 10, 2, 10 ], - [ 10, 9, 10 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided shape ('+values[ i ].join( ',' )+')' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - broadcastArray( x, [ 10, 10 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a desired shape and an input array shape are broadcast-incompatible', function test( t ) { - var values; - var x; - var i; - - x = zeros2d( [ 10, 10 ] ); - - values = [ - [ 10, 20, 10 ], - [ 10, 10, 100 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided shape ('+values[ i ].join( ',' )+')' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - broadcastArray( x, [ 10, 10 ], value ); - }; - } -}); - -tape( 'the function returns a broadcasted array which shares the same data as the input array', function test( t ) { - var x; - var o; - - x = [ 1, 2, 3 ]; - o = broadcastArray( x, [ 3 ], [ 2, 3 ] ); - - t.strictEqual( o.data[ 0 ], x, 'returns expected value' ); - t.end(); -}); - -tape( 'the function broadcasts an input array', function test( t ) { - var expected; - var i0; - var i1; - var x; - var o; - var v; - var i; - var j; - - x = [ 1, 2, 3 ]; - o = broadcastArray( x, [ 3 ], [ 2, 3 ] ); - - expected = [ - [ 1, 2, 3 ], - [ 1, 2, 3 ] - ]; - - t.strictEqual( o.ref, x, 'returns expected value' ); - t.strictEqual( o.data[ 0 ], x, 'returns expected value' ); - - t.deepEqual( o.shape, [ 2, 3 ], 'returns expected value' ); - t.deepEqual( o.strides, [ 0, 1 ], 'returns expected value' ); - - i0 = 0; - for ( i = 0; i < o.shape[ 0 ]; i++ ) { - i1 = 0; - for ( j = 0; j < o.shape[ 1 ]; j++ ) { - v = o.data[ i0 ][ i1 ]; - t.strictEqual( v, expected[ i ][ j ], 'returns expected value ('+i+','+j+')' ); - i1 += o.strides[ 1 ]; - } - i0 += o.strides[ 0 ]; - } - t.end(); -}); - -tape( 'the function broadcasts an input array (same shape)', function test( t ) { - var x; - var o; - - x = [ 1, 2, 3 ]; - o = broadcastArray( x, [ 3 ], [ 3 ] ); - - t.strictEqual( o.ref, x, 'returns expected value' ); - t.strictEqual( o.data, x, 'returns expected value' ); - - t.deepEqual( o.shape, [ 3 ], 'returns expected value' ); - t.deepEqual( o.strides, [ 1 ], 'returns expected value' ); - - t.deepEqual( o.data, [ 1, 2, 3 ], 'returns expected value' ); - - x = [ - [ 1, 2, 3 ], - [ 1, 2, 3 ] - ]; - o = broadcastArray( x, [ 2, 3 ], [ 2, 3 ] ); - - t.strictEqual( o.ref, x, 'returns expected value' ); - t.strictEqual( o.data, x, 'returns expected value' ); - - t.deepEqual( o.shape, [ 2, 3 ], 'returns expected value' ); - t.deepEqual( o.strides, [ 1, 1 ], 'returns expected value' ); - - t.deepEqual( o.data, [ [ 1, 2, 3 ], [ 1, 2, 3 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function broadcasts an input array (same number of dimensions)', function test( t ) { - var expected; - var i0; - var i1; - var x; - var o; - var v; - var i; - var j; - - x = [ [ 1, 2, 3 ] ]; - o = broadcastArray( x, [ 1, 3 ], [ 2, 3 ] ); - - expected = [ - [ 1, 2, 3 ], - [ 1, 2, 3 ] - ]; - - t.strictEqual( o.ref, x, 'returns expected value' ); - t.strictEqual( o.data, x, 'returns expected value' ); - - t.deepEqual( o.shape, [ 2, 3 ], 'returns expected value' ); - t.deepEqual( o.strides, [ 0, 1 ], 'returns expected value' ); - - i0 = 0; - for ( i = 0; i < o.shape[ 0 ]; i++ ) { - i1 = 0; - for ( j = 0; j < o.shape[ 1 ]; j++ ) { - v = o.data[ i0 ][ i1 ]; - t.strictEqual( v, expected[ i ][ j ], 'returns expected value ('+i+','+j+')' ); - i1 += o.strides[ 1 ]; - } - i0 += o.strides[ 0 ]; - } - t.end(); -}); - -tape( 'the function broadcasts an input array (singleton dimension)', function test( t ) { - var expected; - var i0; - var i1; - var i2; - var x; - var o; - var v; - var i; - var j; - var k; - - x = [ [ 1, 2, 3 ] ]; - o = broadcastArray( x, [ 1, 3 ], [ 1, 2, 3 ] ); - - expected = [ - [ - [ 1, 2, 3 ], - [ 1, 2, 3 ] - ] - ]; - - t.strictEqual( o.ref, x, 'returns expected value' ); - t.strictEqual( o.data[ 0 ], x, 'returns expected value' ); - - t.deepEqual( o.shape, [ 1, 2, 3 ], 'returns expected value' ); - t.deepEqual( o.strides, [ 0, 0, 1 ], 'returns expected value' ); - - i0 = 0; - for ( i = 0; i < o.shape[ 0 ]; i++ ) { - i1 = 0; - for ( j = 0; j < o.shape[ 1 ]; j++ ) { - i2 = 0; - for ( k = 0; k < o.shape[ 2 ]; k++ ) { - v = o.data[ i0 ][ i1 ][ i2 ]; - t.strictEqual( v, expected[ i ][ j ][ k ], 'returns expected value ('+i+','+j+','+k+')' ); - i2 += o.strides[ 2 ]; - } - i1 += o.strides[ 1 ]; - } - i0 += o.strides[ 0 ]; - } - t.end(); -}); - -tape( 'the function broadcasts an input array (singleton dimension)', function test( t ) { - var expected; - var i0; - var i1; - var i2; - var x; - var o; - var v; - var i; - var j; - var k; - - x = [ [ 1 ], [ 2 ], [ 3 ] ]; - o = broadcastArray( x, [ 3, 1 ], [ 1, 3, 3 ] ); - - expected = [ - [ - [ 1, 1, 1 ], - [ 2, 2, 2 ], - [ 3, 3, 3 ] - ] - ]; - - t.strictEqual( o.ref, x, 'returns expected value' ); - t.strictEqual( o.data[ 0 ], x, 'returns expected value' ); - - t.deepEqual( o.shape, [ 1, 3, 3 ], 'returns expected value' ); - t.deepEqual( o.strides, [ 0, 1, 0 ], 'returns expected value' ); - - i0 = 0; - for ( i = 0; i < o.shape[ 0 ]; i++ ) { - i1 = 0; - for ( j = 0; j < o.shape[ 1 ]; j++ ) { - i2 = 0; - for ( k = 0; k < o.shape[ 2 ]; k++ ) { - v = o.data[ i0 ][ i1 ][ i2 ]; - t.strictEqual( v, expected[ i ][ j ][ k ], 'returns expected value ('+i+','+j+','+k+')' ); - i2 += o.strides[ 2 ]; - } - i1 += o.strides[ 1 ]; - } - i0 += o.strides[ 0 ]; - } - t.end(); -}); diff --git a/base/broadcasted-binary2d/README.md b/base/broadcasted-binary2d/README.md deleted file mode 100644 index 3b8ada8fd..000000000 --- a/base/broadcasted-binary2d/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# bbinary2d - -> Apply a binary callback to elements in two [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bbinary2d = require( '@stdlib/array/base/broadcasted-binary2d' ); -``` - -#### bbinary2d( arrays, shapes, fcn ) - -Applies a binary callback to elements in two [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assigns results to elements in a two-dimensional nested output array. - -```javascript -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add' ); - -var x = [ [ 1.0, 2.0 ] ]; -var y = [ [ 3.0 ], [ 4.0 ] ]; -var z = zeros2d( [ 2, 2 ] ); - -var shapes = [ - [ 1, 2 ], - [ 2, 1 ], - [ 2, 2 ] -]; - -bbinary2d( [ x, y, z ], shapes, add ); -// z => [ [ 4.0, 5.0 ], [ 5.0, 6.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var bbinary2d = require( '@stdlib/array/base/broadcasted-binary2d' ); - -var shapes = [ - [ 1, 3 ], - [ 3, 1 ], - [ 3, 3 ] -]; - -var x = filled2dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros2d( shapes[ 2 ] ); -console.log( z ); - -bbinary2d( [ x, y, z ], shapes, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-binary2d/benchmark/benchmark.js b/base/broadcasted-binary2d/benchmark/benchmark.js deleted file mode 100644 index 42bded67a..000000000 --- a/base/broadcasted-binary2d/benchmark/benchmark.js +++ /dev/null @@ -1,124 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bbinary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, shape[ 1 ] ], - [ shape[ 0 ], 1 ], - shape - ]; - x = filled2dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled2dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = zeros2d( shapes[ 2 ] ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bbinary2d( arrays, shapes, add ); - i1 = i % shapes[ 1 ][ 0 ]; - i0 = i % shapes[ 1 ][ 1 ]; - if ( isnan( arrays[ 2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shapes[ 1 ][ 0 ]; - i0 = i % shapes[ 1 ][ 1 ]; - if ( isnan( arrays[ 2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-binary2d/docs/repl.txt b/base/broadcasted-binary2d/docs/repl.txt deleted file mode 100644 index 856dfe748..000000000 --- a/base/broadcasted-binary2d/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a binary callback to elements in two broadcasted input arrays and - assigns results to elements in a two-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ 1.0, 2.0 ]; - > var y = [ [ 3.0 ], [ 4.0 ] ]; - > var z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shapes = [ [ 2 ], [ 2, 1 ], [ 2, 2 ] ]; - > {{alias}}( [ x, y, z ], shapes, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ 4.0, 5.0 ], [ 5.0, 6.0 ] ] - - See Also - -------- - diff --git a/base/broadcasted-binary2d/docs/types/index.d.ts b/base/broadcasted-binary2d/docs/types/index.d.ts deleted file mode 100644 index 26ea7a437..000000000 --- a/base/broadcasted-binary2d/docs/types/index.d.ts +++ /dev/null @@ -1,109 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D } from '@stdlib/types/array'; -import { Shape1D, Shape2D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D; - -/** -* Output array. -*/ -type OutputArray = Array2D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape2D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - binary callback -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = zeros2d( shapes[ 2 ] ); -* -* bbinary2d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] -*/ -declare function bbinary2d( arrays: InOutArrays, shapes: InOutShapes, fcn: Binary ): void; - - -// EXPORTS // - -export = bbinary2d; diff --git a/base/broadcasted-binary2d/docs/types/test.ts b/base/broadcasted-binary2d/docs/types/test.ts deleted file mode 100644 index 0f07e33d2..000000000 --- a/base/broadcasted-binary2d/docs/types/test.ts +++ /dev/null @@ -1,105 +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. -*/ - -import bbinary2d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bbinary2d( [ x, y, z ], shapes, fcn ); // $ExpectType void - bbinary2d( [ x[ 0 ], y, z ], [ [ shapes[ 0 ][ 1 ] ], shapes[ 1 ], shapes[ 2 ] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bbinary2d( 'abc', shapes, fcn ); // $ExpectError - bbinary2d( 3.14, shapes, fcn ); // $ExpectError - bbinary2d( true, shapes, fcn ); // $ExpectError - bbinary2d( false, shapes, fcn ); // $ExpectError - bbinary2d( null, shapes, fcn ); // $ExpectError - bbinary2d( [ '1' ], shapes, fcn ); // $ExpectError - bbinary2d( {}, shapes, fcn ); // $ExpectError - bbinary2d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - bbinary2d( [ x, y, z ], 'abc', fcn ); // $ExpectError - bbinary2d( [ x, y, z ], 3.14, fcn ); // $ExpectError - bbinary2d( [ x, y, z ], true, fcn ); // $ExpectError - bbinary2d( [ x, y, z ], false, fcn ); // $ExpectError - bbinary2d( [ x, y, z ], null, fcn ); // $ExpectError - bbinary2d( [ x, y, z ], [ '1' ], fcn ); // $ExpectError - bbinary2d( [ x, y, z ], {}, fcn ); // $ExpectError - bbinary2d( [ x, y, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bbinary2d( [ x, y, z ], shapes, 'abc' ); // $ExpectError - bbinary2d( [ x, y, z ], shapes, 3.14 ); // $ExpectError - bbinary2d( [ x, y, z ], shapes, true ); // $ExpectError - bbinary2d( [ x, y, z ], shapes, false ); // $ExpectError - bbinary2d( [ x, y, z ], shapes, null ); // $ExpectError - bbinary2d( [ x, y, z ], shapes, [ '1' ] ); // $ExpectError - bbinary2d( [ x, y, z ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bbinary2d(); // $ExpectError - bbinary2d( [ x, y, z ] ); // $ExpectError - bbinary2d( [ x, y, z ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-binary2d/examples/index.js b/base/broadcasted-binary2d/examples/index.js deleted file mode 100644 index f55ed3441..000000000 --- a/base/broadcasted-binary2d/examples/index.js +++ /dev/null @@ -1,43 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var bbinary2d = require( './../lib' ); - -var shapes = [ - [ 1, 3 ], - [ 3, 1 ], - [ 3, 3 ] -]; - -var x = filled2dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros2d( shapes[ 2 ] ); -console.log( z ); - -bbinary2d( [ x, y, z ], shapes, add ); -console.log( z ); diff --git a/base/broadcasted-binary2d/lib/index.js b/base/broadcasted-binary2d/lib/index.js deleted file mode 100644 index 1eef3f114..000000000 --- a/base/broadcasted-binary2d/lib/index.js +++ /dev/null @@ -1,55 +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'; - -/** -* Apply a binary callback to elements in two broadcasted input arrays and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-binary2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var bbinary2d = require( '@stdlib/array/base/broadcasted-binary2d' ); -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = zeros2d( shapes[ 2 ] ); -* -* bbinary2d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-binary2d/lib/main.js b/base/broadcasted-binary2d/lib/main.js deleted file mode 100644 index 48df4e791..000000000 --- a/base/broadcasted-binary2d/lib/main.js +++ /dev/null @@ -1,120 +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 broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. -* -* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = zeros2d( shapes[ 2 ] ); -* -* bbinary2d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] -*/ -function bbinary2d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dy0; - var dy1; - var S0; - var S1; - var i0; - var i1; - var j0; - var j1; - var k0; - var k1; - var x0; - var y0; - var z0; - var sh; - var st; - var o; - var x; - var y; - var z; - - sh = shapes[ 2 ]; - S0 = sh[ 1 ]; - S1 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 1 ]; - dx1 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 1 ]; - dy1 = st[ 0 ]; - - z = arrays[ 2 ]; - - j1 = 0; - k1 = 0; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - x0 = x[ j1 ]; - y0 = y[ k1 ]; - z0 = z[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - z0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] ); - j0 += dx0; - k0 += dy0; - } - j1 += dx1; - k1 += dy1; - } -} - - -// EXPORTS // - -module.exports = bbinary2d; diff --git a/base/broadcasted-binary2d/package.json b/base/broadcasted-binary2d/package.json deleted file mode 100644 index f149527b5..000000000 --- a/base/broadcasted-binary2d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-binary2d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two broadcasted input arrays and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "binary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-binary2d/test/test.js b/base/broadcasted-binary2d/test/test.js deleted file mode 100644 index 8bd26830f..000000000 --- a/base/broadcasted-binary2d/test/test.js +++ /dev/null @@ -1,165 +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 add = require( '@stdlib/number/float64/base/add' ); -var zeros2d = require( './../../../base/zeros2d' ); -var bbinary2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bbinary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 2 ], - [ 2, 1 ], - [ 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ 3.0 ], - [ 4.0 ] - ]; - z = zeros2d( shapes[ 2 ] ); - - expected = [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ]; - bbinary2d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - shapes = [ - [ 1, 2 ], - [ 2 ], - [ 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ] - ]; - y = [ 3.0, 4.0 ]; - z = zeros2d( shapes[ 2 ] ); - - expected = [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ]; - bbinary2d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - z = zeros2d( shapes[ 2 ] ); - - expected = [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ]; - bbinary2d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 0, 2 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = x; - z = zeros2d( [ 2, 2 ] ); - - expected = zeros2d( [ 2, 2 ] ); - bbinary2d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 2, 0 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = x; - z = zeros2d( [ 2, 2 ] ); - - expected = zeros2d( [ 2, 2 ] ); - bbinary2d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-binary3d/README.md b/base/broadcasted-binary3d/README.md deleted file mode 100644 index ce5afabbd..000000000 --- a/base/broadcasted-binary3d/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# bbinary3d - -> Apply a binary callback to elements in two [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bbinary3d = require( '@stdlib/array/base/broadcasted-binary3d' ); -``` - -#### bbinary3d( arrays, shapes, fcn ) - -Applies a binary callback to elements in two [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assigns results to elements in a three-dimensional nested output array. - -```javascript -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add' ); - -var x = [ [ 1.0, 2.0 ] ]; -var y = [ [ 3.0 ], [ 4.0 ] ]; -var z = zeros3d( [ 2, 2, 2 ] ); - -var shapes = [ - [ 1, 2 ], - [ 2, 1 ], - [ 2, 2, 2 ] -]; - -bbinary3d( [ x, y, z ], shapes, add ); -// z => [ [ [ 4.0, 5.0 ], [ 5.0, 6.0 ] ], [ [ 4.0, 5.0 ], [ 5.0, 6.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var bbinary3d = require( '@stdlib/array/base/broadcasted-binary3d' ); - -var shapes = [ - [ 1, 1, 3 ], - [ 3, 1, 1 ], - [ 3, 3, 3 ] -]; - -var x = filled3dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros3d( shapes[ 2 ] ); -console.log( z ); - -bbinary3d( [ x, y, z ], shapes, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-binary3d/benchmark/benchmark.js b/base/broadcasted-binary3d/benchmark/benchmark.js deleted file mode 100644 index ba6e5b2be..000000000 --- a/base/broadcasted-binary3d/benchmark/benchmark.js +++ /dev/null @@ -1,127 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bbinary3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, shape[ 2 ] ], - [ shape[ 0 ], 1, 1 ], - shape - ]; - x = filled3dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled3dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = zeros3d( shapes[ 2 ] ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bbinary3d( arrays, shapes, add ); - i2 = i % shapes[ 1 ][ 0 ]; - i1 = i % shapes[ 1 ][ 1 ]; - i0 = i % shapes[ 1 ][ 2 ]; - if ( isnan( arrays[ 2 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shapes[ 1 ][ 0 ]; - i1 = i % shapes[ 1 ][ 1 ]; - i0 = i % shapes[ 1 ][ 2 ]; - if ( isnan( arrays[ 2 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-binary3d/docs/repl.txt b/base/broadcasted-binary3d/docs/repl.txt deleted file mode 100644 index b909bf09d..000000000 --- a/base/broadcasted-binary3d/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a binary callback to elements in two broadcasted input arrays and - assigns results to elements in a three-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ 1.0, 2.0 ]; - > var y = [ [ 3.0 ], [ 4.0 ] ]; - > var z = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - > var shapes = [ [ 2 ], [ 2, 1 ], [ 1, 2, 2 ] ]; - > {{alias}}( [ x, y, z ], shapes, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ [ 4.0, 5.0 ], [ 5.0, 6.0 ] ] ] - - See Also - -------- - diff --git a/base/broadcasted-binary3d/docs/types/index.d.ts b/base/broadcasted-binary3d/docs/types/index.d.ts deleted file mode 100644 index 0ae75f0c3..000000000 --- a/base/broadcasted-binary3d/docs/types/index.d.ts +++ /dev/null @@ -1,109 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D; - -/** -* Output array. -*/ -type OutputArray = Array3D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape3D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - binary callback -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shapes = [ -* [ 1, 1, 2 ], -* [ 2, 1, 1 ], -* [ 2, 2, 2 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = ones3d( shapes[ 1 ] ); -* var z = zeros3d( shapes[ 2 ] ); -* -* bbinary3d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] -*/ -declare function bbinary3d( arrays: InOutArrays, shapes: InOutShapes, fcn: Binary ): void; - - -// EXPORTS // - -export = bbinary3d; diff --git a/base/broadcasted-binary3d/docs/types/test.ts b/base/broadcasted-binary3d/docs/types/test.ts deleted file mode 100644 index 804924eeb..000000000 --- a/base/broadcasted-binary3d/docs/types/test.ts +++ /dev/null @@ -1,105 +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. -*/ - -import bbinary3d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bbinary3d( [ x, y, z ], shapes, fcn ); // $ExpectType void - bbinary3d( [ x[0][0], y, z ], [ [ shapes[0][2] ], shapes[1], shapes[2] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bbinary3d( 'abc', shapes, fcn ); // $ExpectError - bbinary3d( 3.14, shapes, fcn ); // $ExpectError - bbinary3d( true, shapes, fcn ); // $ExpectError - bbinary3d( false, shapes, fcn ); // $ExpectError - bbinary3d( null, shapes, fcn ); // $ExpectError - bbinary3d( [ '1' ], shapes, fcn ); // $ExpectError - bbinary3d( {}, shapes, fcn ); // $ExpectError - bbinary3d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - bbinary3d( [ x, y, z ], 'abc', fcn ); // $ExpectError - bbinary3d( [ x, y, z ], 3.14, fcn ); // $ExpectError - bbinary3d( [ x, y, z ], true, fcn ); // $ExpectError - bbinary3d( [ x, y, z ], false, fcn ); // $ExpectError - bbinary3d( [ x, y, z ], null, fcn ); // $ExpectError - bbinary3d( [ x, y, z ], [ '1' ], fcn ); // $ExpectError - bbinary3d( [ x, y, z ], {}, fcn ); // $ExpectError - bbinary3d( [ x, y, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bbinary3d( [ x, y, z ], shapes, 'abc' ); // $ExpectError - bbinary3d( [ x, y, z ], shapes, 3.14 ); // $ExpectError - bbinary3d( [ x, y, z ], shapes, true ); // $ExpectError - bbinary3d( [ x, y, z ], shapes, false ); // $ExpectError - bbinary3d( [ x, y, z ], shapes, null ); // $ExpectError - bbinary3d( [ x, y, z ], shapes, [ '1' ] ); // $ExpectError - bbinary3d( [ x, y, z ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bbinary3d(); // $ExpectError - bbinary3d( [ x, y, z ] ); // $ExpectError - bbinary3d( [ x, y, z ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-binary3d/examples/index.js b/base/broadcasted-binary3d/examples/index.js deleted file mode 100644 index 29b7dbf31..000000000 --- a/base/broadcasted-binary3d/examples/index.js +++ /dev/null @@ -1,43 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var bbinary3d = require( './../lib' ); - -var shapes = [ - [ 1, 1, 3 ], - [ 3, 1, 1 ], - [ 3, 3, 3 ] -]; - -var x = filled3dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros3d( shapes[ 2 ] ); -console.log( z ); - -bbinary3d( [ x, y, z ], shapes, add ); -console.log( z ); diff --git a/base/broadcasted-binary3d/lib/index.js b/base/broadcasted-binary3d/lib/index.js deleted file mode 100644 index 75f985efa..000000000 --- a/base/broadcasted-binary3d/lib/index.js +++ /dev/null @@ -1,55 +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'; - -/** -* Apply a binary callback to elements in two broadcasted input arrays and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-binary3d -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var bbinary3d = require( '@stdlib/array/base/broadcasted-binary3d' ); -* -* var shapes = [ -* [ 1, 1, 2 ], -* [ 2, 1, 1 ], -* [ 2, 2, 2 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = ones3d( shapes[ 1 ] ); -* var z = zeros3d( shapes[ 2 ] ); -* -* bbinary3d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-binary3d/lib/main.js b/base/broadcasted-binary3d/lib/main.js deleted file mode 100644 index 642c057cb..000000000 --- a/base/broadcasted-binary3d/lib/main.js +++ /dev/null @@ -1,141 +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 broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a three-dimensional nested output array. -* -* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shapes = [ -* [ 1, 1, 2 ], -* [ 2, 1, 1 ], -* [ 2, 2, 2 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = ones3d( shapes[ 1 ] ); -* var z = zeros3d( shapes[ 2 ] ); -* -* bbinary3d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] -*/ -function bbinary3d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dx2; - var dy0; - var dy1; - var dy2; - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var j0; - var j1; - var j2; - var k0; - var k1; - var k2; - var x0; - var x1; - var y0; - var y1; - var z0; - var z1; - var sh; - var st; - var o; - var x; - var y; - var z; - - sh = shapes[ 2 ]; - S0 = sh[ 2 ]; - S1 = sh[ 1 ]; - S2 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 2 ]; - dx1 = st[ 1 ]; - dx2 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 2 ]; - dy1 = st[ 1 ]; - dy2 = st[ 0 ]; - - z = arrays[ 2 ]; - - j2 = 0; - k2 = 0; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - k1 = 0; - x1 = x[ j2 ]; - y1 = y[ k2 ]; - z1 = z[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ k1 ]; - z0 = z1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - z0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] ); - j0 += dx0; - k0 += dy0; - } - j1 += dx1; - k1 += dy1; - } - j2 += dx2; - k2 += dy2; - } -} - - -// EXPORTS // - -module.exports = bbinary3d; diff --git a/base/broadcasted-binary3d/package.json b/base/broadcasted-binary3d/package.json deleted file mode 100644 index 7a5f1a93a..000000000 --- a/base/broadcasted-binary3d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-binary3d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two broadcasted input arrays and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "binary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-binary3d/test/test.js b/base/broadcasted-binary3d/test/test.js deleted file mode 100644 index 355df419c..000000000 --- a/base/broadcasted-binary3d/test/test.js +++ /dev/null @@ -1,231 +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 add = require( '@stdlib/number/float64/base/add' ); -var zeros3d = require( './../../../base/zeros3d' ); -var bbinary3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bbinary3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 2 ], - [ 2, 1 ], - [ 2, 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ 3.0 ], - [ 4.0 ] - ]; - z = zeros3d( shapes[ 2 ] ); - - expected = [ - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ], - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ] - ]; - bbinary3d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - shapes = [ - [ 1, 2 ], - [ 2 ], - [ 2, 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ] - ]; - y = [ 3.0, 4.0 ]; - z = zeros3d( shapes[ 2 ] ); - - expected = [ - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ], - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ] - ]; - bbinary3d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2, 2 ], - [ 2, 2, 2 ], - [ 2, 2, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - z = zeros3d( shapes[ 2 ] ); - - expected = [ - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ], - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ] - ]; - bbinary3d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 0, 2, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = zeros3d( [ 2, 2, 2 ] ); - - expected = zeros3d( [ 2, 2, 2 ] ); - bbinary3d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 0, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = zeros3d( [ 2, 2, 2 ] ); - - expected = zeros3d( [ 2, 2, 2 ] ); - bbinary3d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 2, 0 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = zeros3d( [ 2, 2, 2 ] ); - - expected = zeros3d( [ 2, 2, 2 ] ); - bbinary3d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-binary4d/README.md b/base/broadcasted-binary4d/README.md deleted file mode 100644 index db84e9cd4..000000000 --- a/base/broadcasted-binary4d/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# bbinary4d - -> Apply a binary callback to elements in two [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bbinary4d = require( '@stdlib/array/base/broadcasted-binary4d' ); -``` - -#### bbinary4d( arrays, shapes, fcn ) - -Applies a binary callback to elements in two [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assigns results to elements in a four-dimensional nested output array. - -```javascript -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add' ); - -var x = [ [ 1.0, 2.0 ] ]; -var y = [ [ 3.0 ], [ 4.0 ] ]; -var z = zeros4d( [ 1, 2, 2, 2 ] ); - -var shapes = [ - [ 1, 2 ], - [ 2, 1 ], - [ 1, 2, 2, 2 ] -]; - -bbinary4d( [ x, y, z ], shapes, add ); -// z => [ [ [ [ 4.0, 5.0 ], [ 5.0, 6.0 ] ], [ [ 4.0, 5.0 ], [ 5.0, 6.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var bbinary4d = require( '@stdlib/array/base/broadcasted-binary4d' ); - -var shapes = [ - [ 1, 1, 1, 3 ], - [ 1, 3, 1, 1 ], - [ 1, 3, 3, 3 ] -]; - -var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros4d( shapes[ 2 ] ); -console.log( z ); - -bbinary4d( [ x, y, z ], shapes, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-binary4d/benchmark/benchmark.js b/base/broadcasted-binary4d/benchmark/benchmark.js deleted file mode 100644 index b5662608a..000000000 --- a/base/broadcasted-binary4d/benchmark/benchmark.js +++ /dev/null @@ -1,130 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bbinary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, 1, shape[ 2 ] ], - [ shape[ 0 ], 1, 1, 1 ], - shape - ]; - x = filled4dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled4dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = zeros4d( shapes[ 2 ] ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bbinary4d( arrays, shapes, add ); - i3 = i % shapes[ 1 ][ 0 ]; - i2 = i % shapes[ 1 ][ 1 ]; - i1 = i % shapes[ 1 ][ 2 ]; - i0 = i % shapes[ 1 ][ 3 ]; - if ( isnan( arrays[ 2 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shapes[ 1 ][ 0 ]; - i2 = i % shapes[ 1 ][ 1 ]; - i1 = i % shapes[ 1 ][ 2 ]; - i0 = i % shapes[ 1 ][ 3 ]; - if ( isnan( arrays[ 2 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-binary4d/docs/repl.txt b/base/broadcasted-binary4d/docs/repl.txt deleted file mode 100644 index 791e6d5ec..000000000 --- a/base/broadcasted-binary4d/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a binary callback to elements in two broadcasted input arrays and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ 1.0, 2.0 ]; - > var y = [ [ 3.0 ], [ 4.0 ] ]; - > var z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shapes = [ [ 2 ], [ 2, 1 ], [ 1, 1, 2, 2 ] ]; - > {{alias}}( [ x, y, z ], shapes, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ [ [ 4.0, 5.0 ], [ 5.0, 6.0 ] ] ] ] - - See Also - -------- - diff --git a/base/broadcasted-binary4d/docs/types/index.d.ts b/base/broadcasted-binary4d/docs/types/index.d.ts deleted file mode 100644 index 1259881b3..000000000 --- a/base/broadcasted-binary4d/docs/types/index.d.ts +++ /dev/null @@ -1,109 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D, Shape4D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D | Array4D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D | Shape4D; - -/** -* Output array. -*/ -type OutputArray = Array4D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape4D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - binary callback -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shapes = [ -* [ 1, 1, 1, 2 ], -* [ 1, 2, 1, 1 ], -* [ 1, 2, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = zeros4d( shapes[ 2 ] ); -* -* bbinary4d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] -*/ -declare function bbinary4d( arrays: InOutArrays, shapes: InOutShapes, fcn: Binary ): void; - - -// EXPORTS // - -export = bbinary4d; diff --git a/base/broadcasted-binary4d/docs/types/test.ts b/base/broadcasted-binary4d/docs/types/test.ts deleted file mode 100644 index acdd904ce..000000000 --- a/base/broadcasted-binary4d/docs/types/test.ts +++ /dev/null @@ -1,105 +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. -*/ - -import bbinary4d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bbinary4d( [ x, y, z ], shapes, fcn ); // $ExpectType void - bbinary4d( [ x[0][0][0], y, z ], [ [ shapes[0][3] ], shapes[1], shapes[2] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bbinary4d( 'abc', shapes, fcn ); // $ExpectError - bbinary4d( 3.14, shapes, fcn ); // $ExpectError - bbinary4d( true, shapes, fcn ); // $ExpectError - bbinary4d( false, shapes, fcn ); // $ExpectError - bbinary4d( null, shapes, fcn ); // $ExpectError - bbinary4d( [ '1' ], shapes, fcn ); // $ExpectError - bbinary4d( {}, shapes, fcn ); // $ExpectError - bbinary4d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - bbinary4d( [ x, y, z ], 'abc', fcn ); // $ExpectError - bbinary4d( [ x, y, z ], 3.14, fcn ); // $ExpectError - bbinary4d( [ x, y, z ], true, fcn ); // $ExpectError - bbinary4d( [ x, y, z ], false, fcn ); // $ExpectError - bbinary4d( [ x, y, z ], null, fcn ); // $ExpectError - bbinary4d( [ x, y, z ], [ '1' ], fcn ); // $ExpectError - bbinary4d( [ x, y, z ], {}, fcn ); // $ExpectError - bbinary4d( [ x, y, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bbinary4d( [ x, y, z ], shapes, 'abc' ); // $ExpectError - bbinary4d( [ x, y, z ], shapes, 3.14 ); // $ExpectError - bbinary4d( [ x, y, z ], shapes, true ); // $ExpectError - bbinary4d( [ x, y, z ], shapes, false ); // $ExpectError - bbinary4d( [ x, y, z ], shapes, null ); // $ExpectError - bbinary4d( [ x, y, z ], shapes, [ '1' ] ); // $ExpectError - bbinary4d( [ x, y, z ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bbinary4d(); // $ExpectError - bbinary4d( [ x, y, z ] ); // $ExpectError - bbinary4d( [ x, y, z ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-binary4d/examples/index.js b/base/broadcasted-binary4d/examples/index.js deleted file mode 100644 index 6d3b98952..000000000 --- a/base/broadcasted-binary4d/examples/index.js +++ /dev/null @@ -1,43 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var bbinary4d = require( './../lib' ); - -var shapes = [ - [ 1, 1, 1, 3 ], - [ 1, 3, 1, 1 ], - [ 1, 3, 3, 3 ] -]; - -var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros4d( shapes[ 2 ] ); -console.log( z ); - -bbinary4d( [ x, y, z ], shapes, add ); -console.log( z ); diff --git a/base/broadcasted-binary4d/lib/index.js b/base/broadcasted-binary4d/lib/index.js deleted file mode 100644 index 53ea812ab..000000000 --- a/base/broadcasted-binary4d/lib/index.js +++ /dev/null @@ -1,55 +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'; - -/** -* Apply a binary callback to elements in two broadcasted input arrays and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-binary4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var bbinary4d = require( '@stdlib/array/base/broadcasted-binary4d' ); -* -* var shapes = [ -* [ 1, 1, 1, 2 ], -* [ 1, 2, 1, 1 ], -* [ 1, 2, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = zeros4d( shapes[ 2 ] ); -* -* bbinary4d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-binary4d/lib/main.js b/base/broadcasted-binary4d/lib/main.js deleted file mode 100644 index 873c7081f..000000000 --- a/base/broadcasted-binary4d/lib/main.js +++ /dev/null @@ -1,162 +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 broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. -* -* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shapes = [ -* [ 1, 1, 1, 2 ], -* [ 1, 2, 1, 1 ], -* [ 1, 2, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = zeros4d( shapes[ 2 ] ); -* -* bbinary4d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] -*/ -function bbinary4d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dx2; - var dx3; - var dy0; - var dy1; - var dy2; - var dy3; - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var j0; - var j1; - var j2; - var j3; - var k0; - var k1; - var k2; - var k3; - var x0; - var x1; - var x2; - var y0; - var y1; - var y2; - var z0; - var z1; - var z2; - var sh; - var st; - var o; - var x; - var y; - var z; - - sh = shapes[ 2 ]; - S0 = sh[ 3 ]; - S1 = sh[ 2 ]; - S2 = sh[ 1 ]; - S3 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 3 ]; - dx1 = st[ 2 ]; - dx2 = st[ 1 ]; - dx3 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 3 ]; - dy1 = st[ 2 ]; - dy2 = st[ 1 ]; - dy3 = st[ 0 ]; - - z = arrays[ 2 ]; - - j3 = 0; - k3 = 0; - for ( i3 = 0; i3 < S3; i3++ ) { - j2 = 0; - k2 = 0; - x2 = x[ j3 ]; - y2 = y[ k3 ]; - z2 = z[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - k1 = 0; - x1 = x2[ j2 ]; - y1 = y2[ k2 ]; - z1 = z2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ k1 ]; - z0 = z1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - z0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] ); - j0 += dx0; - k0 += dy0; - } - j1 += dx1; - k1 += dy1; - } - j2 += dx2; - k2 += dy2; - } - j3 += dx3; - k3 += dy3; - } -} - - -// EXPORTS // - -module.exports = bbinary4d; diff --git a/base/broadcasted-binary4d/package.json b/base/broadcasted-binary4d/package.json deleted file mode 100644 index f82dfbbdb..000000000 --- a/base/broadcasted-binary4d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-binary4d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two broadcasted input arrays and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "binary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-binary4d/test/test.js b/base/broadcasted-binary4d/test/test.js deleted file mode 100644 index 49cc8ac64..000000000 --- a/base/broadcasted-binary4d/test/test.js +++ /dev/null @@ -1,331 +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 add = require( '@stdlib/number/float64/base/add' ); -var zeros4d = require( './../../../base/zeros4d' ); -var bbinary4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bbinary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 2 ], - [ 2, 1 ], - [ 2, 2, 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ 3.0 ], - [ 4.0 ] - ]; - z = zeros4d( shapes[ 2 ] ); - - expected = [ - [ - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ], - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ] - ], - [ - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ], - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ] - ] - ]; - bbinary4d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - shapes = [ - [ 1, 2 ], - [ 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ] - ]; - y = [ 3.0, 4.0 ]; - z = zeros4d( shapes[ 2 ] ); - - expected = [ - [ - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ], - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ] - ], - [ - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ], - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ] - ] - ]; - bbinary4d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - z = zeros4d( shapes[ 2 ] ); - - expected = [ - [ - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ], - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ] - ], - [ - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ], - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ] - ] - ]; - bbinary4d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 0, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bbinary4d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 2, 0, 2, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bbinary4d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 2, 2, 0, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bbinary4d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a four element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 2, 2, 2, 0 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bbinary4d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-binary5d/README.md b/base/broadcasted-binary5d/README.md deleted file mode 100644 index 5d1bdb320..000000000 --- a/base/broadcasted-binary5d/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# bbinary5d - -> Apply a binary callback to elements in two [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bbinary5d = require( '@stdlib/array/base/broadcasted-binary5d' ); -``` - -#### bbinary5d( arrays, shapes, fcn ) - -Applies a binary callback to elements in two [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assigns results to elements in a five-dimensional nested output array. - -```javascript -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add' ); - -var x = [ [ 1.0, 2.0 ] ]; -var y = [ [ 3.0 ], [ 4.0 ] ]; -var z = zeros5d( [ 1, 1, 2, 2, 2 ] ); - -var shapes = [ - [ 1, 2 ], - [ 2, 1 ], - [ 1, 1, 2, 2, 2 ] -]; - -bbinary5d( [ x, y, z ], shapes, add ); -// z => [ [ [ [ [ 4.0, 5.0 ], [ 5.0, 6.0 ] ], [ [ 4.0, 5.0 ], [ 5.0, 6.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var bbinary5d = require( '@stdlib/array/base/broadcasted-binary5d' ); - -var shapes = [ - [ 1, 1, 1, 1, 3 ], - [ 1, 1, 3, 1, 1 ], - [ 1, 1, 3, 3, 3 ] -]; - -var x = filled5dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros5d( shapes[ 2 ] ); -console.log( z ); - -bbinary5d( [ x, y, z ], shapes, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-binary5d/benchmark/benchmark.js b/base/broadcasted-binary5d/benchmark/benchmark.js deleted file mode 100644 index 26b80082a..000000000 --- a/base/broadcasted-binary5d/benchmark/benchmark.js +++ /dev/null @@ -1,133 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bbinary5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, 1, 1, shape[ 2 ] ], - [ shape[ 0 ], 1, 1, 1, 1 ], - shape - ]; - x = filled5dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled5dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = zeros5d( shapes[ 2 ] ); - - arrays = [ x, y, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bbinary5d( arrays, shapes, add ); - i4 = i % shapes[ 1 ][ 0 ]; - i3 = i % shapes[ 1 ][ 1 ]; - i2 = i % shapes[ 1 ][ 2 ]; - i1 = i % shapes[ 1 ][ 3 ]; - i0 = i % shapes[ 1 ][ 4 ]; - if ( isnan( arrays[ 2 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shapes[ 1 ][ 0 ]; - i3 = i % shapes[ 1 ][ 1 ]; - i2 = i % shapes[ 1 ][ 2 ]; - i1 = i % shapes[ 1 ][ 3 ]; - i0 = i % shapes[ 1 ][ 4 ]; - if ( isnan( arrays[ 2 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-binary5d/docs/repl.txt b/base/broadcasted-binary5d/docs/repl.txt deleted file mode 100644 index bfbb98935..000000000 --- a/base/broadcasted-binary5d/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a binary callback to elements in two broadcasted input arrays and - assigns results to elements in a five-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ 1.0, 2.0 ]; - > var y = [ [ 3.0 ], [ 4.0 ] ]; - > var z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shapes = [ [ 2 ], [ 2, 1 ], [ 1, 1, 1, 2, 2 ] ]; - > {{alias}}( [ x, y, z ], shapes, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ [ [ [ 4.0, 5.0 ], [ 5.0, 6.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/broadcasted-binary5d/docs/types/index.d.ts b/base/broadcasted-binary5d/docs/types/index.d.ts deleted file mode 100644 index bfc0c20e0..000000000 --- a/base/broadcasted-binary5d/docs/types/index.d.ts +++ /dev/null @@ -1,109 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D, Array5D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D, Shape4D, Shape5D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D | Array4D | Array5D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D | Shape4D | Shape5D; - -/** -* Output array. -*/ -type OutputArray = Array5D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape5D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing two input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - binary callback -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shapes = [ -* [ 1, 1, 1, 1, 2 ], -* [ 1, 1, 2, 1, 1 ], -* [ 1, 1, 2, 2, 2 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = ones5d( shapes[ 1 ] ); -* var z = zeros5d( shapes[ 2 ] ); -* -* bbinary5d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] -*/ -declare function bbinary5d( arrays: InOutArrays, shapes: InOutShapes, fcn: Binary ): void; - - -// EXPORTS // - -export = bbinary5d; diff --git a/base/broadcasted-binary5d/docs/types/test.ts b/base/broadcasted-binary5d/docs/types/test.ts deleted file mode 100644 index d8f457530..000000000 --- a/base/broadcasted-binary5d/docs/types/test.ts +++ /dev/null @@ -1,105 +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. -*/ - -import bbinary5d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bbinary5d( [ x, y, z ], shapes, fcn ); // $ExpectType void - bbinary5d( [ x[0][0][0][0], y, z ], [ [ shapes[0][4] ], shapes[1], shapes[2] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bbinary5d( 'abc', shapes, fcn ); // $ExpectError - bbinary5d( 3.14, shapes, fcn ); // $ExpectError - bbinary5d( true, shapes, fcn ); // $ExpectError - bbinary5d( false, shapes, fcn ); // $ExpectError - bbinary5d( null, shapes, fcn ); // $ExpectError - bbinary5d( [ '1' ], shapes, fcn ); // $ExpectError - bbinary5d( {}, shapes, fcn ); // $ExpectError - bbinary5d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - bbinary5d( [ x, y, z ], 'abc', fcn ); // $ExpectError - bbinary5d( [ x, y, z ], 3.14, fcn ); // $ExpectError - bbinary5d( [ x, y, z ], true, fcn ); // $ExpectError - bbinary5d( [ x, y, z ], false, fcn ); // $ExpectError - bbinary5d( [ x, y, z ], null, fcn ); // $ExpectError - bbinary5d( [ x, y, z ], [ '1' ], fcn ); // $ExpectError - bbinary5d( [ x, y, z ], {}, fcn ); // $ExpectError - bbinary5d( [ x, y, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bbinary5d( [ x, y, z ], shapes, 'abc' ); // $ExpectError - bbinary5d( [ x, y, z ], shapes, 3.14 ); // $ExpectError - bbinary5d( [ x, y, z ], shapes, true ); // $ExpectError - bbinary5d( [ x, y, z ], shapes, false ); // $ExpectError - bbinary5d( [ x, y, z ], shapes, null ); // $ExpectError - bbinary5d( [ x, y, z ], shapes, [ '1' ] ); // $ExpectError - bbinary5d( [ x, y, z ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bbinary5d(); // $ExpectError - bbinary5d( [ x, y, z ] ); // $ExpectError - bbinary5d( [ x, y, z ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-binary5d/examples/index.js b/base/broadcasted-binary5d/examples/index.js deleted file mode 100644 index ba167d3f7..000000000 --- a/base/broadcasted-binary5d/examples/index.js +++ /dev/null @@ -1,43 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var bbinary5d = require( './../lib' ); - -var shapes = [ - [ 1, 1, 1, 1, 3 ], - [ 1, 1, 3, 1, 1 ], - [ 1, 1, 3, 3, 3 ] -]; - -var x = filled5dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = zeros5d( shapes[ 2 ] ); -console.log( z ); - -bbinary5d( [ x, y, z ], shapes, add ); -console.log( z ); diff --git a/base/broadcasted-binary5d/lib/index.js b/base/broadcasted-binary5d/lib/index.js deleted file mode 100644 index acc03a64e..000000000 --- a/base/broadcasted-binary5d/lib/index.js +++ /dev/null @@ -1,55 +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'; - -/** -* Apply a binary callback to elements in two broadcasted input arrays and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-binary5d -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var bbinary5d = require( '@stdlib/array/base/broadcasted-binary5d' ); -* -* var shapes = [ -* [ 1, 1, 1, 1, 2 ], -* [ 1, 1, 2, 1, 1 ], -* [ 1, 1, 2, 2, 2 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = ones5d( shapes[ 1 ] ); -* var z = zeros5d( shapes[ 2 ] ); -* -* bbinary5d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-binary5d/lib/main.js b/base/broadcasted-binary5d/lib/main.js deleted file mode 100644 index e98810350..000000000 --- a/base/broadcasted-binary5d/lib/main.js +++ /dev/null @@ -1,183 +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 broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a five-dimensional nested output array. -* -* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shapes = [ -* [ 1, 1, 1, 1, 2 ], -* [ 1, 1, 2, 1, 1 ], -* [ 1, 1, 2, 2, 2 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = ones5d( shapes[ 1 ] ); -* var z = zeros5d( shapes[ 2 ] ); -* -* bbinary5d( [ x, y, z ], shapes, add ); -* -* console.log( z ); -* // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] -*/ -function bbinary5d( arrays, shapes, fcn ) { // eslint-disable-line max-statements - var dx0; - var dx1; - var dx2; - var dx3; - var dx4; - var dy0; - var dy1; - var dy2; - var dy3; - var dy4; - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var j0; - var j1; - var j2; - var j3; - var j4; - var k0; - var k1; - var k2; - var k3; - var k4; - var x0; - var x1; - var x2; - var x3; - var y0; - var y1; - var y2; - var y3; - var z0; - var z1; - var z2; - var z3; - var sh; - var st; - var o; - var x; - var y; - var z; - - sh = shapes[ 2 ]; - S0 = sh[ 4 ]; - S1 = sh[ 3 ]; - S2 = sh[ 2 ]; - S3 = sh[ 1 ]; - S4 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 4 ]; - dx1 = st[ 3 ]; - dx2 = st[ 2 ]; - dx3 = st[ 1 ]; - dx4 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 4 ]; - dy1 = st[ 3 ]; - dy2 = st[ 2 ]; - dy3 = st[ 1 ]; - dy4 = st[ 0 ]; - - z = arrays[ 2 ]; - - j4 = 0; - k4 = 0; - for ( i4 = 0; i4 < S4; i4++ ) { - j3 = 0; - k3 = 0; - x3 = x[ j4 ]; - y3 = y[ k4 ]; - z3 = z[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - j2 = 0; - k2 = 0; - x2 = x3[ j3 ]; - y2 = y3[ k3 ]; - z2 = z3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - k1 = 0; - x1 = x2[ j2 ]; - y1 = y2[ k2 ]; - z1 = z2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ k1 ]; - z0 = z1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - z0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] ); - j0 += dx0; - k0 += dy0; - } - j1 += dx1; - k1 += dy1; - } - j2 += dx2; - k2 += dy2; - } - j3 += dx3; - k3 += dy3; - } - j4 += dx4; - k4 += dy4; - } -} - - -// EXPORTS // - -module.exports = bbinary5d; diff --git a/base/broadcasted-binary5d/package.json b/base/broadcasted-binary5d/package.json deleted file mode 100644 index ed07c6673..000000000 --- a/base/broadcasted-binary5d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-binary5d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two broadcasted input arrays and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "binary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-binary5d/test/test.js b/base/broadcasted-binary5d/test/test.js deleted file mode 100644 index 6400d7edb..000000000 --- a/base/broadcasted-binary5d/test/test.js +++ /dev/null @@ -1,429 +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 add = require( '@stdlib/number/float64/base/add' ); -var zeros5d = require( './../../../base/zeros5d' ); -var bbinary5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bbinary5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { // eslint-disable-line max-lines-per-function - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 2 ], - [ 2, 1 ], - [ 2, 2, 2, 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ 3.0 ], - [ 4.0 ] - ]; - z = zeros5d( shapes[ 2 ] ); - - expected = [ - [ - [ - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ], - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ] - ], - [ - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ], - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ] - ] - ], - [ - [ - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ], - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ] - ], - [ - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ], - [ - [ 4.0, 5.0 ], - [ 5.0, 6.0 ] - ] - ] - ] - ]; - bbinary5d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - shapes = [ - [ 1, 2 ], - [ 2 ], - [ 2, 2, 2, 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ] - ]; - y = [ 3.0, 4.0 ]; - z = zeros5d( shapes[ 2 ] ); - - expected = [ - [ - [ - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ], - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ] - ], - [ - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ], - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ] - ] - ], - [ - [ - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ], - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ] - ], - [ - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ], - [ - [ 4.0, 6.0 ], - [ 4.0, 6.0 ] - ] - ] - ] - ]; - bbinary5d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 1, 2, 2, 2, 2 ], - [ 1, 2, 2, 2, 2 ], - [ 1, 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - z = zeros5d( shapes[ 2 ] ); - - expected = [ - [ - [ - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ], - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ] - ], - [ - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ], - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ] - ] - ] - ]; - bbinary5d( [ x, y, z ], shapes, add ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 0, 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - z = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bbinary5d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 2, 0, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - z = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bbinary5d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 2, 2, 0, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - z = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bbinary5d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a four element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 2, 2, 2, 0, 2 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - z = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bbinary5d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a fifth element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - - shapes = [ - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 2, 2, 2, 2, 0 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - z = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bbinary5d( [ x, y, z ], shapes, clbk ); - t.deepEqual( z, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-quaternary2d/README.md b/base/broadcasted-quaternary2d/README.md deleted file mode 100644 index de7ed5ae3..000000000 --- a/base/broadcasted-quaternary2d/README.md +++ /dev/null @@ -1,147 +0,0 @@ - - -# bquaternary2d - -> Apply a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bquaternary2d = require( '@stdlib/array/base/broadcasted-quaternary2d' ); -``` - -#### bquaternary2d( arrays, shapes, fcn ) - -Applies a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assigns results to elements in a two-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add4' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); - -var x = [ [ 1.0, 2.0 ] ]; -var y = [ [ 3.0 ], [ 4.0 ] ]; -var z = [ [ 5.0 ] ]; -var w = [ [ 2.0 ] ]; -var out = zeros2d( [ 2, 2 ] ); - -var shapes = [ - [ 1, 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 1, 1 ], - [ 2, 2 ] -]; - -bquaternary2d( [ x, y, z, w, out ], shapes, add ); -// out => [ [ 11.0, 12.0 ], [ 12.0, 13.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing four input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: quaternary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var bquaternary2d = require( '@stdlib/array/base/broadcasted-quaternary2d' ); - -var shapes = [ - [ 1, 3 ], - [ 3, 1 ], - [ 1, 1 ], - [ 3, 3 ], - [ 3, 3 ] -]; - -var x = filled2dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled2dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros2d( shapes[ 4 ] ); -console.log( out ); - -bquaternary2d( [ x, y, z, w, out ], shapes, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-quaternary2d/benchmark/benchmark.js b/base/broadcasted-quaternary2d/benchmark/benchmark.js deleted file mode 100644 index 89f9a04b3..000000000 --- a/base/broadcasted-quaternary2d/benchmark/benchmark.js +++ /dev/null @@ -1,130 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var pkg = require( './../package.json' ).name; -var bquaternary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, shape[ 1 ] ], - [ shape[ 0 ], 1 ], - [ 1, 1 ], - [ shape[ 0 ], shape[ 1 ] ], - shape - ]; - x = filled2dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled2dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = filled2dBy( shapes[ 2 ], uniform( -100.0, 100.0 ) ); - w = filled2dBy( shapes[ 3 ], uniform( -100.0, 100.0 ) ); - out = zeros2d( shapes[ 4 ] ); - - arrays = [ x, y, z, w, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bquaternary2d( arrays, shapes, add ); - i1 = i % shapes[ 1 ][ 0 ]; - i0 = i % shapes[ 1 ][ 1 ]; - if ( isnan( arrays[ 4 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shapes[ 1 ][ 0 ]; - i0 = i % shapes[ 1 ][ 1 ]; - if ( isnan( arrays[ 4 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-quaternary2d/docs/repl.txt b/base/broadcasted-quaternary2d/docs/repl.txt deleted file mode 100644 index 486a23f83..000000000 --- a/base/broadcasted-quaternary2d/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a quaternary callback to elements in four broadcasted input arrays - and assigns results to elements in a two-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing four input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Quaternary callback. - - Examples - -------- - > function fcn( x, y, z, w ) { return x + y + z + w; }; - > var x = [ 1.0, 2.0 ]; - > var y = [ [ 3.0 ], [ 4.0 ] ]; - > var z = [ [ 1.0 ] ]; - > var w = [ 2.0 ]; - > var out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shapes = [ [ 2 ], [ 2, 1 ], [ 1, 1 ], [ 1 ], [ 2, 2 ] ]; - > {{alias}}( [ x, y, z, w, out ], shapes, fcn ); - > out - [ [ 7.0, 8.0 ], [ 8.0, 9.0 ] ] - - See Also - -------- - diff --git a/base/broadcasted-quaternary2d/docs/types/index.d.ts b/base/broadcasted-quaternary2d/docs/types/index.d.ts deleted file mode 100644 index 648cd9b41..000000000 --- a/base/broadcasted-quaternary2d/docs/types/index.d.ts +++ /dev/null @@ -1,119 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D } from '@stdlib/types/array'; -import { Shape1D, Shape2D } from '@stdlib/types/ndarray'; - -/** -* Quaternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @returns result -*/ -type Quaternary = ( v1: T, v2: U, v3: V, v4: W ) => X; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D; - -/** -* Output array. -*/ -type OutputArray = Array2D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape2D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing four input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - quaternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 1, 1 ], -* [ 2, 2 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = ones2d( shapes[ 2 ] ); -* var w = ones2d( shapes[ 3 ] ); -* var out = zeros2d( shapes[ 4 ] ); -* -* bquaternary2d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] -*/ -declare function bquaternary2d( arrays: InOutArrays, shapes: InOutShapes, fcn: Quaternary ): void; - - -// EXPORTS // - -export = bquaternary2d; diff --git a/base/broadcasted-quaternary2d/docs/types/test.ts b/base/broadcasted-quaternary2d/docs/types/test.ts deleted file mode 100644 index e6ca292ad..000000000 --- a/base/broadcasted-quaternary2d/docs/types/test.ts +++ /dev/null @@ -1,115 +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. -*/ - -import bquaternary2d = require( './index' ); - -/** -* Quaternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number ): number { - return x + y + z + w; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bquaternary2d( [ x, y, z, w, out ], shapes, fcn ); // $ExpectType void - bquaternary2d( [ x[ 0 ], y, z, w, out ], [ [ shapes[ 0 ][ 1 ] ], shapes[ 1 ], shapes[ 2 ], shapes[ 3 ], shapes[ 4 ] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bquaternary2d( 'abc', shapes, fcn ); // $ExpectError - bquaternary2d( 3.14, shapes, fcn ); // $ExpectError - bquaternary2d( true, shapes, fcn ); // $ExpectError - bquaternary2d( false, shapes, fcn ); // $ExpectError - bquaternary2d( null, shapes, fcn ); // $ExpectError - bquaternary2d( [ '1' ], shapes, fcn ); // $ExpectError - bquaternary2d( {}, shapes, fcn ); // $ExpectError - bquaternary2d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - bquaternary2d( [ x, y, z, w, out ], 'abc', fcn ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], 3.14, fcn ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], true, fcn ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], false, fcn ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], null, fcn ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], [ '1' ], fcn ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], {}, fcn ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bquaternary2d( [ x, y, z, w, out ], shapes, 'abc' ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], shapes, 3.14 ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], shapes, true ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], shapes, false ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], shapes, null ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], shapes, [ '1' ] ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bquaternary2d(); // $ExpectError - bquaternary2d( [ x, y, z, w, out ] ); // $ExpectError - bquaternary2d( [ x, y, z, w, out ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-quaternary2d/examples/index.js b/base/broadcasted-quaternary2d/examples/index.js deleted file mode 100644 index 53b8b8d1b..000000000 --- a/base/broadcasted-quaternary2d/examples/index.js +++ /dev/null @@ -1,51 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var bquaternary2d = require( './../lib' ); - -var shapes = [ - [ 1, 3 ], - [ 3, 1 ], - [ 1, 1 ], - [ 3, 3 ], - [ 3, 3 ] -]; - -var x = filled2dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled2dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros2d( shapes[ 4 ] ); -console.log( out ); - -bquaternary2d( [ x, y, z, w, out ], shapes, add ); -console.log( out ); diff --git a/base/broadcasted-quaternary2d/lib/index.js b/base/broadcasted-quaternary2d/lib/index.js deleted file mode 100644 index 4e6c8dab9..000000000 --- a/base/broadcasted-quaternary2d/lib/index.js +++ /dev/null @@ -1,59 +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'; - -/** -* Apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-quaternary2d -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var bquaternary2d = require( '@stdlib/array/base/broadcasted-quaternary2d' ); -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 1, 1 ], -* [ 2, 2 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = ones2d( shapes[ 2 ] ); -* var w = ones2d( shapes[ 3 ] ); -* var out = zeros2d( shapes[ 4 ] ); -* -* bquaternary2d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-quaternary2d/lib/main.js b/base/broadcasted-quaternary2d/lib/main.js deleted file mode 100644 index 393efb042..000000000 --- a/base/broadcasted-quaternary2d/lib/main.js +++ /dev/null @@ -1,158 +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 broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. -* -* @param {ArrayLikeObject>} arrays - array-like object containing four input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - quaternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 1, 1 ], -* [ 2, 2 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = ones2d( shapes[ 2 ] ); -* var w = ones2d( shapes[ 3 ] ); -* var out = zeros2d( shapes[ 4 ] ); -* -* bquaternary2d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] -*/ -function bquaternary2d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dy0; - var dy1; - var dz0; - var dz1; - var dw0; - var dw1; - var S0; - var S1; - var i0; - var i1; - var j0; - var j1; - var k0; - var k1; - var m0; - var m1; - var n0; - var n1; - var x0; - var y0; - var z0; - var w0; - var u0; - var sh; - var st; - var o; - var x; - var y; - var z; - var w; - var u; - - sh = shapes[ 4 ]; - S0 = sh[ 1 ]; - S1 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 1 ]; - dx1 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 1 ]; - dy1 = st[ 0 ]; - - o = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh ); - z = o.data; - st = o.strides; - dz0 = st[ 1 ]; - dz1 = st[ 0 ]; - - o = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh ); - w = o.data; - st = o.strides; - dw0 = st[ 1 ]; - dw1 = st[ 0 ]; - - u = arrays[ 4 ]; - - j1 = 0; - k1 = 0; - m1 = 0; - n1 = 0; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - m0 = 0; - n0 = 0; - x0 = x[ j1 ]; - y0 = y[ k1 ]; - z0 = z[ m1 ]; - w0 = w[ n1 ]; - u0 = u[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - u0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] ); - j0 += dx0; - k0 += dy0; - m0 += dz0; - n0 += dw0; - } - j1 += dx1; - k1 += dy1; - m1 += dz1; - n1 += dw1; - } -} - - -// EXPORTS // - -module.exports = bquaternary2d; diff --git a/base/broadcasted-quaternary2d/package.json b/base/broadcasted-quaternary2d/package.json deleted file mode 100644 index 94ec925a2..000000000 --- a/base/broadcasted-quaternary2d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-quaternary2d", - "version": "0.0.0", - "description": "Apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "quaternary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-quaternary2d/test/test.js b/base/broadcasted-quaternary2d/test/test.js deleted file mode 100644 index a2902619c..000000000 --- a/base/broadcasted-quaternary2d/test/test.js +++ /dev/null @@ -1,200 +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 zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var bquaternary2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bquaternary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 1 ], - [ 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ 3.0 ], - [ 4.0 ] - ]; - z = [ [ 5.0 ] ]; - w = [ 1.0 ]; - out = zeros2d( shapes[ 4 ] ); - - expected = [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ]; - bquaternary2d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - shapes = [ - [ 1, 2 ], - [ 2 ], - [ 1 ], - [ 2, 2 ], - [ 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ] - ]; - y = [ 3.0, 4.0 ]; - z = [ 5.0 ]; - w = [ - [ 2.0, 3.0 ], - [ 4.0, 5.0 ] - ]; - out = zeros2d( shapes[ 4 ] ); - - expected = [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ]; - bquaternary2d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - z = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - w = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - out = zeros2d( shapes[ 4 ] ); - - expected = [ - [ 4.0, 8.0 ], - [ 12.0, 16.0 ] - ]; - bquaternary2d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 0, 2 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = x; - z = x; - w = x; - out = zeros2d( [ 2, 2 ] ); - - expected = zeros2d( [ 2, 2 ] ); - bquaternary2d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 0 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = x; - z = x; - w = x; - out = zeros2d( [ 2, 2 ] ); - - expected = zeros2d( [ 2, 2 ] ); - bquaternary2d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-quaternary3d/README.md b/base/broadcasted-quaternary3d/README.md deleted file mode 100644 index c7102c629..000000000 --- a/base/broadcasted-quaternary3d/README.md +++ /dev/null @@ -1,147 +0,0 @@ - - -# bquaternary3d - -> Apply a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bquaternary3d = require( '@stdlib/array/base/broadcasted-quaternary3d' ); -``` - -#### bquaternary3d( arrays, shapes, fcn ) - -Applies a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assigns results to elements in a three-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add4' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); - -var x = [ [ 1.0, 2.0 ] ]; -var y = [ [ 3.0 ], [ 4.0 ] ]; -var z = [ [ 5.0 ] ]; -var w = [ [ 2.0 ] ]; -var out = zeros3d( [ 2, 2, 2 ] ); - -var shapes = [ - [ 1, 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 1, 1 ], - [ 2, 2, 2 ] -]; - -bquaternary3d( [ x, y, z, w, out ], shapes, add ); -// out => [ [ [ 11.0, 12.0 ], [ 12.0, 13.0 ] ], [ [ 11.0, 12.0 ], [ 12.0, 13.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing four input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: quaternary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var bquaternary3d = require( '@stdlib/array/base/broadcasted-quaternary3d' ); - -var shapes = [ - [ 1, 1, 3 ], - [ 3, 1, 1 ], - [ 1, 3, 1 ], - [ 3, 3, 3 ], - [ 3, 3, 3 ] -]; - -var x = filled3dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled3dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled3dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros3d( shapes[ 4 ] ); -console.log( out ); - -bquaternary3d( [ x, y, z, w, out ], shapes, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-quaternary3d/benchmark/benchmark.js b/base/broadcasted-quaternary3d/benchmark/benchmark.js deleted file mode 100644 index c783499bb..000000000 --- a/base/broadcasted-quaternary3d/benchmark/benchmark.js +++ /dev/null @@ -1,133 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bquaternary3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, shape[ 2 ] ], - [ 1, shape[ 1 ], 1 ], - [ shape[ 0 ], 1, 1 ], - [ shape[ 0 ], shape[ 1 ], shape[ 2 ] ], - shape - ]; - x = filled3dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled3dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = filled3dBy( shapes[ 2 ], uniform( -100.0, 100.0 ) ); - w = filled3dBy( shapes[ 3 ], uniform( -100.0, 100.0 ) ); - out = zeros3d( shapes[ 4 ] ); - - arrays = [ x, y, z, w, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bquaternary3d( arrays, shapes, add ); - i2 = i % shapes[ 1 ][ 0 ]; - i1 = i % shapes[ 1 ][ 1 ]; - i0 = i % shapes[ 1 ][ 2 ]; - if ( isnan( arrays[ 4 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shapes[ 1 ][ 0 ]; - i1 = i % shapes[ 1 ][ 1 ]; - i0 = i % shapes[ 1 ][ 2 ]; - if ( isnan( arrays[ 4 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-quaternary3d/docs/repl.txt b/base/broadcasted-quaternary3d/docs/repl.txt deleted file mode 100644 index b7c2cf860..000000000 --- a/base/broadcasted-quaternary3d/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a quaternary callback to elements in four broadcasted input arrays - and assigns results to elements in a three-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing four input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Quaternary callback. - - Examples - -------- - > function fcn( x, y, z, w ) { return x + y + z + w; }; - > var x = [ 1.0, 2.0 ]; - > var y = [ [ 3.0 ], [ 4.0 ] ]; - > var z = [ [ 5.0 ] ]; - > var w = [ 1.0 ]; - > var out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - > var shapes = [ [ 2 ], [ 2, 1 ], [ 1, 1 ], [ 1 ], [ 1, 2, 2 ] ]; - > {{alias}}( [ x, y, z, w, out ], shapes, fcn ); - > out - [ [ [ 10.0, 11.0 ], [ 11.0, 12.0 ] ] ] - - See Also - -------- - diff --git a/base/broadcasted-quaternary3d/docs/types/index.d.ts b/base/broadcasted-quaternary3d/docs/types/index.d.ts deleted file mode 100644 index a327bcf9a..000000000 --- a/base/broadcasted-quaternary3d/docs/types/index.d.ts +++ /dev/null @@ -1,119 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D } from '@stdlib/types/ndarray'; - -/** -* Quaternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @returns result -*/ -type Quaternary = ( v1: T, v2: U, v3: V, v4: W ) => X; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D; - -/** -* Output array. -*/ -type OutputArray = Array3D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape3D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing four input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - quaternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* var shapes = [ -* [ 1, 1, 3 ], -* [ 3, 1, 1 ], -* [ 1, 3, 1 ], -* [ 3, 3, 3 ], -* [ 3, 3, 3 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = ones3d( shapes[ 1 ] ); -* var z = ones3d( shapes[ 2 ] ); -* var w = ones3d( shapes[ 3 ] ); -* var out = zeros3d( shapes[ 4 ] ); -* -* bquaternary3d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] -*/ -declare function bquaternary3d( arrays: InOutArrays, shapes: InOutShapes, fcn: Quaternary ): void; - - -// EXPORTS // - -export = bquaternary3d; diff --git a/base/broadcasted-quaternary3d/docs/types/test.ts b/base/broadcasted-quaternary3d/docs/types/test.ts deleted file mode 100644 index 514b7e74e..000000000 --- a/base/broadcasted-quaternary3d/docs/types/test.ts +++ /dev/null @@ -1,115 +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. -*/ - -import bquaternary3d = require( './index' ); - -/** -* Quaternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number ): number { - return x + y + z + w; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bquaternary3d( [ x, y, z, w, out ], shapes, fcn ); // $ExpectType void - bquaternary3d( [ x[ 0 ], y, z, w, out ], [ [ shapes[ 0 ][ 1 ] ], shapes[ 1 ], shapes[ 2 ], shapes[ 3 ], shapes[ 4 ] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bquaternary3d( 'abc', shapes, fcn ); // $ExpectError - bquaternary3d( 3.14, shapes, fcn ); // $ExpectError - bquaternary3d( true, shapes, fcn ); // $ExpectError - bquaternary3d( false, shapes, fcn ); // $ExpectError - bquaternary3d( null, shapes, fcn ); // $ExpectError - bquaternary3d( [ '1' ], shapes, fcn ); // $ExpectError - bquaternary3d( {}, shapes, fcn ); // $ExpectError - bquaternary3d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - bquaternary3d( [ x, y, z, w, out ], 'abc', fcn ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], 3.14, fcn ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], true, fcn ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], false, fcn ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], null, fcn ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], [ '1' ], fcn ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], {}, fcn ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bquaternary3d( [ x, y, z, w, out ], shapes, 'abc' ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], shapes, 3.14 ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], shapes, true ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], shapes, false ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], shapes, null ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], shapes, [ '1' ] ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bquaternary3d(); // $ExpectError - bquaternary3d( [ x, y, z, w, out ] ); // $ExpectError - bquaternary3d( [ x, y, z, w, out ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-quaternary3d/examples/index.js b/base/broadcasted-quaternary3d/examples/index.js deleted file mode 100644 index 576b4f626..000000000 --- a/base/broadcasted-quaternary3d/examples/index.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var bquaternary3d = require( './../lib' ); - -var shapes = [ - [ 1, 1, 3 ], - [ 3, 1, 1 ], - [ 1, 3, 1 ], - [ 3, 3, 3 ], - [ 3, 3, 3 ] -]; - -var x = filled3dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled3dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled3dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros3d( shapes[ 4 ] ); -console.log( z ); - -bquaternary3d( [ x, y, z, w, out ], shapes, add ); -console.log( out ); diff --git a/base/broadcasted-quaternary3d/lib/index.js b/base/broadcasted-quaternary3d/lib/index.js deleted file mode 100644 index ce3b80882..000000000 --- a/base/broadcasted-quaternary3d/lib/index.js +++ /dev/null @@ -1,59 +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. -*/ - -'use strict'; - -/** -* Apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-quaternary3d -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var bquaternary3d = require( '@stdlib/array/base/broadcasted-quaternary3d' ); -* -* var shapes = [ -* [ 1, 1, 3 ], -* [ 3, 1, 1 ], -* [ 1, 3, 1 ], -* [ 3, 3, 3 ], -* [ 3, 3, 3 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = ones3d( shapes[ 1 ] ); -* var z = ones3d( shapes[ 2 ] ); -* var w = ones3d( shapes[ 3 ] ); -* var out = zeros3d( shapes[ 4 ] ); -* -* bquaternary3d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-quaternary3d/lib/main.js b/base/broadcasted-quaternary3d/lib/main.js deleted file mode 100644 index 786e768da..000000000 --- a/base/broadcasted-quaternary3d/lib/main.js +++ /dev/null @@ -1,193 +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. -*/ - -'use strict'; - -// MODULES // - -var broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a three-dimensional nested output array. -* -* @param {ArrayLikeObject} arrays - array-like object containing four input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - quaternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* var shapes = [ -* [ 1, 1, 3 ], -* [ 3, 1, 1 ], -* [ 1, 3, 1 ], -* [ 3, 3, 3 ], -* [ 3, 3, 3 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = ones3d( shapes[ 1 ] ); -* var z = ones3d( shapes[ 2 ] ); -* var w = ones3d( shapes[ 3 ] ); -* var out = zeros3d( shapes[ 4 ] ); -* -* bquaternary3d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] -*/ -function bquaternary3d( arrays, shapes, fcn ) { // eslint-disable-line max-statements - var dx0; - var dx1; - var dx2; - var dy0; - var dy1; - var dy2; - var dz0; - var dz1; - var dz2; - var dw0; - var dw1; - var dw2; - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var j0; - var j1; - var j2; - var k0; - var k1; - var k2; - var m0; - var m1; - var m2; - var n0; - var n1; - var n2; - var x0; - var x1; - var y0; - var y1; - var z0; - var z1; - var w0; - var w1; - var u0; - var u1; - var sh; - var st; - var o; - var x; - var y; - var z; - var w; - var u; - - sh = shapes[ 4 ]; - S0 = sh[ 2 ]; - S1 = sh[ 1 ]; - S2 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 2 ]; - dx1 = st[ 1 ]; - dx2 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 2 ]; - dy1 = st[ 1 ]; - dy2 = st[ 0 ]; - - o = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh ); - z = o.data; - st = o.strides; - dz0 = st[ 2 ]; - dz1 = st[ 1 ]; - dz2 = st[ 0 ]; - - o = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh ); - w = o.data; - st = o.strides; - dw0 = st[ 2 ]; - dw1 = st[ 1 ]; - dw2 = st[ 0 ]; - - u = arrays[ 4 ]; - - j2 = 0; - k2 = 0; - m2 = 0; - n2 = 0; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - k1 = 0; - m1 = 0; - n1 = 0; - x1 = x[ j2 ]; - y1 = y[ k2 ]; - z1 = z[ m2 ]; - w1 = w[ n2 ]; - u1 = u[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - m0 = 0; - n0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ k1 ]; - z0 = z1[ m1 ]; - w0 = w1[ n1 ]; - u0 = u1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - u0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] ); - j0 += dx0; - k0 += dy0; - m0 += dz0; - n0 += dw0; - } - j1 += dx1; - k1 += dy1; - m1 += dz1; - n1 += dw1; - } - j2 += dx2; - k2 += dy2; - m2 += dz2; - n2 += dw2; - } -} - - -// EXPORTS // - -module.exports = bquaternary3d; diff --git a/base/broadcasted-quaternary3d/package.json b/base/broadcasted-quaternary3d/package.json deleted file mode 100644 index e4d691ffe..000000000 --- a/base/broadcasted-quaternary3d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-quaternary3d", - "version": "0.0.0", - "description": "Apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "quaternary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-quaternary3d/test/test.js b/base/broadcasted-quaternary3d/test/test.js deleted file mode 100644 index 6153b192e..000000000 --- a/base/broadcasted-quaternary3d/test/test.js +++ /dev/null @@ -1,284 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var zeros3d = require( './../../../base/zeros3d' ); -var bquaternary3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bquaternary3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 1 ], - [ 2, 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ 3.0 ], - [ 4.0 ] - ]; - z = [ [ 5.0 ] ]; - w = [ 1.0 ]; - out = zeros3d( shapes[ 4 ] ); - - expected = [ - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ] - ]; - bquaternary3d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - shapes = [ - [ 1, 2 ], - [ 2 ], - [ 1 ], - [ 2, 2 ], - [ 2, 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ] - ]; - y = [ 3.0, 4.0 ]; - z = [ 5.0 ]; - w = [ - [ 2.0, 3.0 ], - [ 4.0, 5.0 ] - ]; - out = zeros3d( shapes[ 4 ] ); - - expected = [ - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ], - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ] - ]; - bquaternary3d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2, 2 ], - [ 2, 2, 2 ], - [ 2, 2, 2 ], - [ 2, 2, 2 ], - [ 2, 2, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - z = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - w = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - out = zeros3d( shapes[ 4 ] ); - - expected = [ - [ - [ 4.0, 8.0 ], - [ 12.0, 16.0 ] - ], - [ - [ 4.0, 8.0 ], - [ 12.0, 16.0 ] - ] - ]; - bquaternary3d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 0, 2, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros3d( [ 2, 2, 2 ] ); - - expected = zeros3d( [ 2, 2, 2 ] ); - bquaternary3d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 0, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros3d( [ 2, 2, 2 ] ); - - expected = zeros3d( [ 2, 2, 2 ] ); - bquaternary3d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 2, 0 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros3d( [ 2, 2, 2 ] ); - - expected = zeros3d( [ 2, 2, 2 ] ); - bquaternary3d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-quaternary4d/README.md b/base/broadcasted-quaternary4d/README.md deleted file mode 100644 index 62342b5cd..000000000 --- a/base/broadcasted-quaternary4d/README.md +++ /dev/null @@ -1,147 +0,0 @@ - - -# bquaternary4d - -> Apply a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bquaternary4d = require( '@stdlib/array/base/broadcasted-quaternary4d' ); -``` - -#### bquaternary4d( arrays, shapes, fcn ) - -Applies a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assigns results to elements in a four-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add4' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); - -var x = [ [ 1.0, 2.0 ] ]; -var y = [ [ 3.0 ], [ 4.0 ] ]; -var z = [ [ 5.0 ] ]; -var w = [ [ 2.0 ] ]; -var out = zeros4d( [ 2, 2, 2, 2 ] ); - -var shapes = [ - [ 1, 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 1, 1 ], - [ 1, 2, 2, 2 ] -]; - -bquaternary4d( [ x, y, z, w, out ], shapes, add ); -// out => [ [ [ [ 11.0, 12.0 ], [ 12.0, 13.0 ] ], [ [ 11.0, 12.0 ], [ 12.0, 13.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing four input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: quaternary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var bquaternary4d = require( '@stdlib/array/base/broadcasted-quaternary4d' ); - -var shapes = [ - [ 1, 1, 3, 1 ], - [ 3, 1, 1, 1 ], - [ 1, 1, 1, 3 ], - [ 1, 3, 1, 1 ], - [ 3, 3, 3, 3 ] -]; - -var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled4dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros4d( shapes[ 4 ] ); -console.log( out ); - -bquaternary4d( [ x, y, z, w, out ], shapes, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-quaternary4d/benchmark/benchmark.js b/base/broadcasted-quaternary4d/benchmark/benchmark.js deleted file mode 100644 index 0219a0353..000000000 --- a/base/broadcasted-quaternary4d/benchmark/benchmark.js +++ /dev/null @@ -1,136 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bquaternary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, 1, shape[ 2 ] ], - [ 1, 1, shape[ 1 ], 1 ], - [ 1, shape[ 0 ], 1, 1 ], - [ 1, shape[ 0 ], shape[ 1 ], shape[ 2 ] ], - shape - ]; - x = filled4dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled4dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = filled4dBy( shapes[ 2 ], uniform( -100.0, 100.0 ) ); - w = filled4dBy( shapes[ 3 ], uniform( -100.0, 100.0 ) ); - out = zeros4d( shapes[ 4 ] ); - - arrays = [ x, y, z, w, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bquaternary4d( arrays, shapes, add ); - i3 = i % shapes[ 1 ][ 0 ]; - i2 = i % shapes[ 1 ][ 1 ]; - i1 = i % shapes[ 1 ][ 2 ]; - i0 = i % shapes[ 1 ][ 3 ]; - if ( isnan( arrays[ 4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shapes[ 1 ][ 0 ]; - i2 = i % shapes[ 1 ][ 1 ]; - i1 = i % shapes[ 1 ][ 2 ]; - i0 = i % shapes[ 1 ][ 3 ]; - if ( isnan( arrays[ 4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-quaternary4d/docs/repl.txt b/base/broadcasted-quaternary4d/docs/repl.txt deleted file mode 100644 index c11c53f79..000000000 --- a/base/broadcasted-quaternary4d/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a quaternary callback to elements in four broadcasted input arrays - and assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing four input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Quaternary callback. - - Examples - -------- - > function fcn( x, y, z, w ) { return x + y + z + w; }; - > var x = [ 1.0, 2.0 ]; - > var y = [ [ 3.0 ], [ 4.0 ] ]; - > var z = [ [ 5.0 ] ]; - > var w = [ 1.0 ]; - > var out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shapes = [ [ 2 ], [ 2, 1 ], [ 1, 1 ], [ 1 ], [ 1, 1, 2, 2 ] ]; - > {{alias}}( [ x, y, z, w, out ], shapes, fcn ); - > out - [ [ [ [ 10.0, 11.0 ], [ 11.0, 12.0 ] ] ] ] - - See Also - -------- diff --git a/base/broadcasted-quaternary4d/docs/types/index.d.ts b/base/broadcasted-quaternary4d/docs/types/index.d.ts deleted file mode 100644 index f6545e991..000000000 --- a/base/broadcasted-quaternary4d/docs/types/index.d.ts +++ /dev/null @@ -1,119 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D, Shape4D } from '@stdlib/types/ndarray'; - -/** -* Quaternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @returns result -*/ -type Quaternary = ( v1: T, v2: U, v3: V, v4: W ) => X; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D | Array4D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D | Shape4D; - -/** -* Output array. -*/ -type OutputArray = Array4D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape4D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing four input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - quaternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* var shapes = [ -* [ 1, 3, 1, 1 ], -* [ 1, 1, 3, 1 ], -* [ 1, 1, 1, 3 ], -* [ 1, 1, 1, 1 ], -* [ 1, 3, 3, 3 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = ones4d( shapes[ 2 ] ); -* var w = ones4d( shapes[ 3 ] ); -* var out = zeros4d( shapes[ 4 ] ); -* -* bquaternary4d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ] -*/ -declare function bquaternary4d( arrays: InOutArrays, shapes: InOutShapes, fcn: Quaternary ): void; - - -// EXPORTS // - -export = bquaternary4d; diff --git a/base/broadcasted-quaternary4d/docs/types/test.ts b/base/broadcasted-quaternary4d/docs/types/test.ts deleted file mode 100644 index 38f120a9a..000000000 --- a/base/broadcasted-quaternary4d/docs/types/test.ts +++ /dev/null @@ -1,115 +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. -*/ - -import bquaternary4d = require( './index' ); - -/** -* Quaternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number ): number { - return x + y + z + w; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bquaternary4d( [ x, y, z, w, out ], shapes, fcn ); // $ExpectType void - bquaternary4d( [ x[ 0 ], y, z, w, out ], [ [ shapes[ 0 ][ 1 ] ], shapes[ 1 ], shapes[ 2 ], shapes[ 3 ], shapes[ 4 ] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bquaternary4d( 'abc', shapes, fcn ); // $ExpectError - bquaternary4d( 3.14, shapes, fcn ); // $ExpectError - bquaternary4d( true, shapes, fcn ); // $ExpectError - bquaternary4d( false, shapes, fcn ); // $ExpectError - bquaternary4d( null, shapes, fcn ); // $ExpectError - bquaternary4d( [ '1' ], shapes, fcn ); // $ExpectError - bquaternary4d( {}, shapes, fcn ); // $ExpectError - bquaternary4d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - bquaternary4d( [ x, y, z, w, out ], 'abc', fcn ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], 3.14, fcn ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], true, fcn ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], false, fcn ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], null, fcn ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], [ '1' ], fcn ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], {}, fcn ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bquaternary4d( [ x, y, z, w, out ], shapes, 'abc' ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], shapes, 3.14 ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], shapes, true ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], shapes, false ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], shapes, null ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], shapes, [ '1' ] ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bquaternary4d(); // $ExpectError - bquaternary4d( [ x, y, z, w, out ] ); // $ExpectError - bquaternary4d( [ x, y, z, w, out ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-quaternary4d/examples/index.js b/base/broadcasted-quaternary4d/examples/index.js deleted file mode 100644 index 25fd22912..000000000 --- a/base/broadcasted-quaternary4d/examples/index.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var bquaternary4d = require( './../lib' ); - -var shapes = [ - [ 1, 1, 3, 1 ], - [ 3, 1, 1, 1 ], - [ 1, 1, 1, 3 ], - [ 1, 3, 1, 1 ], - [ 3, 3, 3, 3 ] -]; - -var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled4dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros4d( shapes[ 4 ] ); -console.log( z ); - -bquaternary4d( [ x, y, z, w, out ], shapes, add ); -console.log( out ); diff --git a/base/broadcasted-quaternary4d/lib/index.js b/base/broadcasted-quaternary4d/lib/index.js deleted file mode 100644 index 52a987136..000000000 --- a/base/broadcasted-quaternary4d/lib/index.js +++ /dev/null @@ -1,59 +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. -*/ - -'use strict'; - -/** -* Apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-quaternary4d -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var bquaternary4d = require( '@stdlib/array/base/broadcasted-quaternary4d' ); -* -* var shapes = [ -* [ 1, 3, 1, 1 ], -* [ 1, 1, 3, 1 ], -* [ 1, 1, 1, 3 ], -* [ 1, 1, 1, 1 ], -* [ 1, 3, 3, 3 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = ones4d( shapes[ 2 ] ); -* var w = ones4d( shapes[ 3 ] ); -* var out = zeros4d( shapes[ 4 ] ); -* -* bquaternary4d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-quaternary4d/lib/main.js b/base/broadcasted-quaternary4d/lib/main.js deleted file mode 100644 index b9603144e..000000000 --- a/base/broadcasted-quaternary4d/lib/main.js +++ /dev/null @@ -1,228 +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. -*/ - -'use strict'; - -// MODULES // - -var broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. -* -* @param {ArrayLikeObject} arrays - array-like object containing four input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - quaternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* var shapes = [ -* [ 1, 3, 1, 1 ], -* [ 1, 1, 3, 1 ], -* [ 1, 1, 1, 3 ], -* [ 1, 1, 1, 1 ], -* [ 1, 3, 3, 3 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = ones4d( shapes[ 2 ] ); -* var w = ones4d( shapes[ 3 ] ); -* var out = zeros4d( shapes[ 4 ] ); -* -* bquaternary4d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ] -*/ -function bquaternary4d( arrays, shapes, fcn ) { // eslint-disable-line max-statements - var dx0; - var dx1; - var dx2; - var dx3; - var dy0; - var dy1; - var dy2; - var dy3; - var dz0; - var dz1; - var dz2; - var dz3; - var dw0; - var dw1; - var dw2; - var dw3; - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var j0; - var j1; - var j2; - var j3; - var k0; - var k1; - var k2; - var k3; - var m0; - var m1; - var m2; - var m3; - var n0; - var n1; - var n2; - var n3; - var x0; - var x1; - var x2; - var y0; - var y1; - var y2; - var z0; - var z1; - var z2; - var w0; - var w1; - var w2; - var u0; - var u1; - var u2; - var sh; - var st; - var o; - var x; - var y; - var z; - var w; - var u; - - sh = shapes[ 4 ]; - S0 = sh[ 3 ]; - S1 = sh[ 2 ]; - S2 = sh[ 1 ]; - S3 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 3 ]; - dx1 = st[ 2 ]; - dx2 = st[ 1 ]; - dx3 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 3 ]; - dy1 = st[ 2 ]; - dy2 = st[ 1 ]; - dy3 = st[ 0 ]; - - o = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh ); - z = o.data; - st = o.strides; - dz0 = st[ 3 ]; - dz1 = st[ 2 ]; - dz2 = st[ 1 ]; - dz3 = st[ 0 ]; - - o = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh ); - w = o.data; - st = o.strides; - dw0 = st[ 3 ]; - dw1 = st[ 2 ]; - dw2 = st[ 1 ]; - dw3 = st[ 0 ]; - - u = arrays[ 4 ]; - - j3 = 0; - k3 = 0; - m3 = 0; - n3 = 0; - for ( i3 = 0; i3 < S3; i3++ ) { - j2 = 0; - k2 = 0; - m2 = 0; - n2 = 0; - x2 = x[ j3 ]; - y2 = y[ k3 ]; - z2 = z[ m3 ]; - w2 = w[ n3 ]; - u2 = u[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - k1 = 0; - m1 = 0; - n1 = 0; - x1 = x2[ j2 ]; - y1 = y2[ k2 ]; - z1 = z2[ m2 ]; - w1 = w2[ n2 ]; - u1 = u2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - m0 = 0; - n0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ k1 ]; - z0 = z1[ m1 ]; - w0 = w1[ n1 ]; - u0 = u1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - u0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] ); - j0 += dx0; - k0 += dy0; - m0 += dz0; - n0 += dw0; - } - j1 += dx1; - k1 += dy1; - m1 += dz1; - n1 += dw1; - } - j2 += dx2; - k2 += dy2; - m2 += dz2; - n2 += dw2; - } - j3 += dx3; - k3 += dy3; - m3 += dz3; - n3 += dw3; - } -} - - -// EXPORTS // - -module.exports = bquaternary4d; diff --git a/base/broadcasted-quaternary4d/package.json b/base/broadcasted-quaternary4d/package.json deleted file mode 100644 index f85c881ca..000000000 --- a/base/broadcasted-quaternary4d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-quaternary4d", - "version": "0.0.0", - "description": "Apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "quaternary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-quaternary4d/test/test.js b/base/broadcasted-quaternary4d/test/test.js deleted file mode 100644 index 930062acd..000000000 --- a/base/broadcasted-quaternary4d/test/test.js +++ /dev/null @@ -1,406 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var zeros4d = require( './../../../base/zeros4d' ); -var bquaternary4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bquaternary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 1 ], - [ 2, 2, 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ 3.0 ], - [ 4.0 ] - ]; - z = [ [ 5.0 ] ]; - w = [ 1.0 ]; - out = zeros4d( shapes[ 4 ] ); - - expected = [ - [ - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ] - ], - [ - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - bquaternary4d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - shapes = [ - [ 1, 2 ], - [ 2 ], - [ 1 ], - [ 2, 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ] - ]; - y = [ 3.0, 4.0 ]; - z = [ 5.0 ]; - w = [ - [ 2.0, 3.0 ], - [ 4.0, 5.0 ] - ]; - out = zeros4d( shapes[ 4 ] ); - - expected = [ - [ - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ], - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ] - ], - [ - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ], - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ] - ] - ]; - bquaternary4d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - out = zeros4d( shapes[ 4 ] ); - - expected = [ - [ - [ - [ 4.0, 8.0 ], - [ 12.0, 16.0 ] - ], - [ - [ 4.0, 8.0 ], - [ 12.0, 16.0 ] - ] - ], - [ - [ - [ 4.0, 8.0 ], - [ 12.0, 16.0 ] - ], - [ - [ 4.0, 8.0 ], - [ 12.0, 16.0 ] - ] - ] - ]; - bquaternary4d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 0, 2, 2, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bquaternary4d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 0, 2, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bquaternary4d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 2, 0, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bquaternary4d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a fourth element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 2, 2, 0 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bquaternary4d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-quaternary5d/README.md b/base/broadcasted-quaternary5d/README.md deleted file mode 100644 index b7814804e..000000000 --- a/base/broadcasted-quaternary5d/README.md +++ /dev/null @@ -1,147 +0,0 @@ - - -# bquaternary5d - -> Apply a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bquaternary5d = require( '@stdlib/array/base/broadcasted-quaternary5d' ); -``` - -#### bquaternary5d( arrays, shapes, fcn ) - -Applies a quaternary callback to elements in four [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assigns results to elements in a five-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add4' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); - -var x = [ [ 1.0, 2.0 ] ]; -var y = [ [ 3.0 ], [ 4.0 ] ]; -var z = [ [ 5.0 ] ]; -var w = [ [ 2.0 ] ]; -var out = zeros5d( [ 1, 1, 2, 2, 2 ] ); - -var shapes = [ - [ 1, 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 1, 1 ], - [ 1, 1, 2, 2, 2 ] -]; - -bquaternary5d( [ x, y, z, w, out ], shapes, add ); -// out => [ [ [ [ [ 11.0, 12.0 ], [ 12.0, 13.0 ] ], [ [ 11.0, 12.0 ], [ 12.0, 13.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing four input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: quaternary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var bquaternary5d = require( '@stdlib/array/base/broadcasted-quaternary5d' ); - -var shapes = [ - [ 1, 1, 1, 3, 1 ], - [ 1, 3, 1, 1, 1 ], - [ 1, 1, 1, 1, 3 ], - [ 1, 1, 3, 1, 1 ], - [ 1, 3, 3, 3, 3 ] -]; - -var x = filled5dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled5dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled5dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros5d( shapes[ 4 ] ); -console.log( out ); - -bquaternary5d( [ x, y, z, w, out ], shapes, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-quaternary5d/benchmark/benchmark.js b/base/broadcasted-quaternary5d/benchmark/benchmark.js deleted file mode 100644 index 4e460eb21..000000000 --- a/base/broadcasted-quaternary5d/benchmark/benchmark.js +++ /dev/null @@ -1,139 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bquaternary5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, 1, 1, shape[ 2 ] ], - [ 1, 1, 1, shape[ 1 ], 1 ], - [ 1, 1, shape[ 0 ], 1, 1 ], - [ 1, 1, shape[ 0 ], shape[ 1 ], shape[ 2 ] ], - shape - ]; - x = filled5dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled5dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = filled5dBy( shapes[ 2 ], uniform( -100.0, 100.0 ) ); - w = filled5dBy( shapes[ 3 ], uniform( -100.0, 100.0 ) ); - out = zeros5d( shapes[ 4 ] ); - - arrays = [ x, y, z, w, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bquaternary5d( arrays, shapes, add ); - i4 = i % shapes[ 1 ][ 0 ]; - i3 = i % shapes[ 1 ][ 1 ]; - i2 = i % shapes[ 1 ][ 2 ]; - i1 = i % shapes[ 1 ][ 3 ]; - i0 = i % shapes[ 1 ][ 4 ]; - if ( isnan( arrays[ 4 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shapes[ 1 ][ 0 ]; - i3 = i % shapes[ 1 ][ 1 ]; - i2 = i % shapes[ 1 ][ 2 ]; - i1 = i % shapes[ 1 ][ 3 ]; - i0 = i % shapes[ 1 ][ 4 ]; - if ( isnan( arrays[ 4 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-quaternary5d/docs/repl.txt b/base/broadcasted-quaternary5d/docs/repl.txt deleted file mode 100644 index e62a5e558..000000000 --- a/base/broadcasted-quaternary5d/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a quaternary callback to elements in four broadcasted input arrays - and assigns results to elements in a five-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing four input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Quaternary callback. - - Examples - -------- - > function fcn( x, y, z, w ) { return x + y + z + w; }; - > var x = [ 1.0, 2.0 ]; - > var y = [ [ 3.0 ], [ 4.0 ] ]; - > var z = [ [ 5.0 ] ]; - > var w = [ 1.0 ]; - > var out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shapes = [ [ 2 ], [ 2, 1 ], [ 1, 1 ], [ 1 ], [ 1, 1, 1, 2, 2 ] ]; - > {{alias}}( [ x, y, z, w, out ], shapes, fcn ); - > out - [ [ [ [ [ 10.0, 11.0 ], [ 11.0, 12.0 ] ] ] ] ] - - See Also - -------- diff --git a/base/broadcasted-quaternary5d/docs/types/index.d.ts b/base/broadcasted-quaternary5d/docs/types/index.d.ts deleted file mode 100644 index 9ec5b7ec7..000000000 --- a/base/broadcasted-quaternary5d/docs/types/index.d.ts +++ /dev/null @@ -1,119 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D, Array5D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D, Shape4D, Shape5D } from '@stdlib/types/ndarray'; - -/** -* Quaternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @returns result -*/ -type Quaternary = ( v1: T, v2: U, v3: V, v4: W ) => X; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D | Array4D | Array5D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D | Shape4D | Shape5D; - -/** -* Output array. -*/ -type OutputArray = Array5D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape5D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing four input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - quaternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* var shapes = [ -* [ 1, 1, 3, 1, 1 ], -* [ 1, 1, 1, 3, 1 ], -* [ 1, 1, 1, 1, 3 ], -* [ 1, 1, 1, 1, 1 ], -* [ 1, 1, 3, 3, 3 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = ones5d( shapes[ 1 ] ); -* var z = ones5d( shapes[ 2 ] ); -* var w = ones5d( shapes[ 3 ] ); -* var out = zeros5d( shapes[ 4 ] ); -* -* bquaternary5d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ] ] -*/ -declare function bquaternary5d( arrays: InOutArrays, shapes: InOutShapes, fcn: Quaternary ): void; - - -// EXPORTS // - -export = bquaternary5d; diff --git a/base/broadcasted-quaternary5d/docs/types/test.ts b/base/broadcasted-quaternary5d/docs/types/test.ts deleted file mode 100644 index ca9e28ffe..000000000 --- a/base/broadcasted-quaternary5d/docs/types/test.ts +++ /dev/null @@ -1,115 +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. -*/ - -import bquaternary5d = require( './index' ); - -/** -* Quaternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number ): number { - return x + y + z + w; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bquaternary5d( [ x, y, z, w, out ], shapes, fcn ); // $ExpectType void - bquaternary5d( [ x[ 0 ], y, z, w, out ], [ [ shapes[ 0 ][ 1 ] ], shapes[ 1 ], shapes[ 2 ], shapes[ 3 ], shapes[ 4 ] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bquaternary5d( 'abc', shapes, fcn ); // $ExpectError - bquaternary5d( 3.14, shapes, fcn ); // $ExpectError - bquaternary5d( true, shapes, fcn ); // $ExpectError - bquaternary5d( false, shapes, fcn ); // $ExpectError - bquaternary5d( null, shapes, fcn ); // $ExpectError - bquaternary5d( [ '1' ], shapes, fcn ); // $ExpectError - bquaternary5d( {}, shapes, fcn ); // $ExpectError - bquaternary5d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - bquaternary5d( [ x, y, z, w, out ], 'abc', fcn ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], 3.14, fcn ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], true, fcn ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], false, fcn ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], null, fcn ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], [ '1' ], fcn ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], {}, fcn ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bquaternary5d( [ x, y, z, w, out ], shapes, 'abc' ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], shapes, 3.14 ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], shapes, true ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], shapes, false ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], shapes, null ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], shapes, [ '1' ] ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array, Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bquaternary5d(); // $ExpectError - bquaternary5d( [ x, y, z, w, out ] ); // $ExpectError - bquaternary5d( [ x, y, z, w, out ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-quaternary5d/examples/index.js b/base/broadcasted-quaternary5d/examples/index.js deleted file mode 100644 index d36a29c5c..000000000 --- a/base/broadcasted-quaternary5d/examples/index.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var bquaternary5d = require( './../lib' ); - -var shapes = [ - [ 1, 1, 1, 3, 1 ], - [ 1, 3, 1, 1, 1 ], - [ 1, 1, 1, 1, 3 ], - [ 1, 1, 3, 1, 1 ], - [ 1, 3, 3, 3, 3 ] -]; - -var x = filled5dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled5dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled5dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros5d( shapes[ 4 ] ); -console.log( z ); - -bquaternary5d( [ x, y, z, w, out ], shapes, add ); -console.log( out ); diff --git a/base/broadcasted-quaternary5d/lib/index.js b/base/broadcasted-quaternary5d/lib/index.js deleted file mode 100644 index 2a205f57c..000000000 --- a/base/broadcasted-quaternary5d/lib/index.js +++ /dev/null @@ -1,59 +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. -*/ - -'use strict'; - -/** -* Apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-quaternary5d -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var bquaternary5d = require( '@stdlib/array/base/broadcasted-quaternary5d' ); -* -* var shapes = [ -* [ 1, 1, 3, 1, 1 ], -* [ 1, 1, 1, 3, 1 ], -* [ 1, 1, 1, 1, 3 ], -* [ 1, 1, 1, 1, 1 ], -* [ 1, 1, 3, 3, 3 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = ones5d( shapes[ 1 ] ); -* var z = ones5d( shapes[ 2 ] ); -* var w = ones5d( shapes[ 3 ] ); -* var out = zeros5d( shapes[ 4 ] ); -* -* bquaternary5d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-quaternary5d/lib/main.js b/base/broadcasted-quaternary5d/lib/main.js deleted file mode 100644 index c23b6be2a..000000000 --- a/base/broadcasted-quaternary5d/lib/main.js +++ /dev/null @@ -1,263 +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. -*/ - -'use strict'; - -// MODULES // - -var broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a five-dimensional nested output array. -* -* @param {ArrayLikeObject} arrays - array-like object containing four input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - quaternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* var shapes = [ -* [ 1, 1, 3, 1, 1 ], -* [ 1, 1, 1, 3, 1 ], -* [ 1, 1, 1, 1, 3 ], -* [ 1, 1, 1, 1, 1 ], -* [ 1, 1, 3, 3, 3 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = ones5d( shapes[ 1 ] ); -* var z = ones5d( shapes[ 2 ] ); -* var w = ones5d( shapes[ 3 ] ); -* var out = zeros5d( shapes[ 4 ] ); -* -* bquaternary5d( [ x, y, z, w, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ] ] -*/ -function bquaternary5d( arrays, shapes, fcn ) { // eslint-disable-line max-statements - var dx0; - var dx1; - var dx2; - var dx3; - var dx4; - var dy0; - var dy1; - var dy2; - var dy3; - var dy4; - var dz0; - var dz1; - var dz2; - var dz3; - var dz4; - var dw0; - var dw1; - var dw2; - var dw3; - var dw4; - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var j0; - var j1; - var j2; - var j3; - var j4; - var k0; - var k1; - var k2; - var k3; - var k4; - var m0; - var m1; - var m2; - var m3; - var m4; - var n0; - var n1; - var n2; - var n3; - var n4; - var x0; - var x1; - var x2; - var x3; - var y0; - var y1; - var y2; - var y3; - var z0; - var z1; - var z2; - var z3; - var w0; - var w1; - var w2; - var w3; - var u0; - var u1; - var u2; - var u3; - var sh; - var st; - var o; - var x; - var y; - var z; - var w; - var u; - - sh = shapes[ 4 ]; - S0 = sh[ 4 ]; - S1 = sh[ 3 ]; - S2 = sh[ 2 ]; - S3 = sh[ 1 ]; - S4 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 4 ]; - dx1 = st[ 3 ]; - dx2 = st[ 2 ]; - dx3 = st[ 1 ]; - dx4 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 4 ]; - dy1 = st[ 3 ]; - dy2 = st[ 2 ]; - dy3 = st[ 1 ]; - dy4 = st[ 0 ]; - - o = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh ); - z = o.data; - st = o.strides; - dz0 = st[ 4 ]; - dz1 = st[ 3 ]; - dz2 = st[ 2 ]; - dz3 = st[ 1 ]; - dz4 = st[ 0 ]; - - o = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh ); - w = o.data; - st = o.strides; - dw0 = st[ 4 ]; - dw1 = st[ 3 ]; - dw2 = st[ 2 ]; - dw3 = st[ 1 ]; - dw4 = st[ 0 ]; - - u = arrays[ 4 ]; - - j4 = 0; - k4 = 0; - m4 = 0; - n4 = 0; - for ( i4 = 0; i4 < S4; i4++ ) { - j3 = 0; - k3 = 0; - m3 = 0; - n3 = 0; - x3 = x[ j4 ]; - y3 = y[ k4 ]; - z3 = z[ m4 ]; - w3 = w[ n4 ]; - u3 = u[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - j2 = 0; - k2 = 0; - m2 = 0; - n2 = 0; - x2 = x3[ j3 ]; - y2 = y3[ k3 ]; - z2 = z3[ m3 ]; - w2 = w3[ n3 ]; - u2 = u3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - k1 = 0; - m1 = 0; - n1 = 0; - x1 = x2[ j2 ]; - y1 = y2[ k2 ]; - z1 = z2[ m2 ]; - w1 = w2[ n2 ]; - u1 = u2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - m0 = 0; - n0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ k1 ]; - z0 = z1[ m1 ]; - w0 = w1[ n1 ]; - u0 = u1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - u0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] ); - j0 += dx0; - k0 += dy0; - m0 += dz0; - n0 += dw0; - } - j1 += dx1; - k1 += dy1; - m1 += dz1; - n1 += dw1; - } - j2 += dx2; - k2 += dy2; - m2 += dz2; - n2 += dw2; - } - j3 += dx3; - k3 += dy3; - m3 += dz3; - n3 += dw3; - } - j4 += dx4; - k4 += dy4; - m4 += dz4; - n4 += dw4; - } -} - - -// EXPORTS // - -module.exports = bquaternary5d; diff --git a/base/broadcasted-quaternary5d/package.json b/base/broadcasted-quaternary5d/package.json deleted file mode 100644 index bf74fa961..000000000 --- a/base/broadcasted-quaternary5d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-quaternary5d", - "version": "0.0.0", - "description": "Apply a quaternary callback to elements in four broadcasted input arrays and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "quaternary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-quaternary5d/test/test.js b/base/broadcasted-quaternary5d/test/test.js deleted file mode 100644 index f20245b32..000000000 --- a/base/broadcasted-quaternary5d/test/test.js +++ /dev/null @@ -1,452 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var zeros5d = require( './../../../base/zeros5d' ); -var bquaternary5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bquaternary5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 1 ], - [ 2, 2, 2, 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ 3.0 ], - [ 4.0 ] - ]; - z = [ [ 5.0 ] ]; - w = [ 1.0 ]; - out = zeros5d( shapes[ 4 ] ); - - expected = [ - [ - [ - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ] - ], - [ - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ] - ] - ], - [ - [ - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ] - ], - [ - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 10.0, 11.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - bquaternary5d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - shapes = [ - [ 1, 2 ], - [ 2 ], - [ 1 ], - [ 2, 2 ], - [ 2, 2, 2, 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ] - ]; - y = [ 3.0, 4.0 ]; - z = [ 5.0 ]; - w = [ - [ 2.0, 3.0 ], - [ 4.0, 5.0 ] - ]; - out = zeros5d( shapes[ 4 ] ); - - expected = [ - [ - [ - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ], - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ] - ], - [ - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ], - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ] - ] - ], - [ - [ - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ], - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ] - ], - [ - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ], - [ - [ 11.0, 14.0 ], - [ 13.0, 16.0 ] - ] - ] - ] - ]; - bquaternary5d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 1, 1, 2, 2, 2 ], - [ 1, 1, 2, 2, 2 ], - [ 1, 1, 2, 2, 2 ], - [ 1, 1, 2, 2, 2 ], - [ 1, 1, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - out = zeros5d( shapes[ 4 ] ); - - expected = [ - [ - [ - [ - [ 4.0, 8.0 ], - [ 12.0, 16.0 ] - ], - [ - [ 4.0, 8.0 ], - [ 12.0, 16.0 ] - ] - ] - ] - ]; - bquaternary5d( [ x, y, z, w, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 0, 2, 2, 2, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bquaternary5d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 0, 2, 2, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bquaternary5d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 2, 0, 2, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bquaternary5d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a fourth element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 2, 2, 0, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bquaternary5d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a fifth element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 2, 2, 2, 0 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = x; - out = zeros5d( [ 2, 2, 2, 2, 0 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 0 ] ); - bquaternary5d( [ x, y, z, w, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-quinary2d/README.md b/base/broadcasted-quinary2d/README.md deleted file mode 100644 index 528277ecc..000000000 --- a/base/broadcasted-quinary2d/README.md +++ /dev/null @@ -1,159 +0,0 @@ - - -# bquinary2d - -> Apply a quinary callback to elements in five [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bquinary2d = require( '@stdlib/array/base/broadcasted-quinary2d' ); -``` - -#### bquinary2d( arrays, shapes, fcn ) - -Applies a quinary callback to elements in five [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assigns results to elements in a two-dimensional nested output array. - -```javascript -var zeros2d = require( '@stdlib/array/base/zeros2d' ); - -function add( x, y, z, w, v ) { - return x + y + z + w + v; -} - -var x = [ [ 1.0, 2.0 ] ]; -var y = [ [ 3.0 ], [ 4.0 ] ]; -var z = [ [ 5.0 ] ]; -var w = [ [ 2.0 ] ]; -var v = [ [ 1.0 ] ]; -var out = zeros2d( [ 2, 2 ] ); - -var shapes = [ - [ 1, 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 1, 1 ], - [ 1, 1 ], - [ 2, 2 ] -]; - -bquinary2d( [ x, y, z, w, v, out ], shapes, add ); -// out => [ [ 12.0, 13.0 ], [ 13.0, 14.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing five input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: quinary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var bquinary2d = require( '@stdlib/array/base/broadcasted-quinary2d' ); - -function add( x, y, z, w, v ) { - return x + y + z + w + v; -} - -var shapes = [ - [ 1, 3 ], - [ 3, 1 ], - [ 1, 1 ], - [ 3, 3 ], - [ 1, 3 ], - [ 3, 3 ] -]; - -var x = filled2dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled2dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled2dBy( shapes[ 4 ], discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros2d( shapes[ 5 ] ); -console.log( out ); - -bquinary2d( [ x, y, z, w, v, out ], shapes, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-quinary2d/benchmark/benchmark.js b/base/broadcasted-quinary2d/benchmark/benchmark.js deleted file mode 100644 index 6c0fdecfd..000000000 --- a/base/broadcasted-quinary2d/benchmark/benchmark.js +++ /dev/null @@ -1,147 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bquinary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns the sum. -* -* @private -* @param {number} x - first value -* @param {number} y - second value -* @param {number} z - third value -* @param {number} w - fourth value -* @param {number} v - fifth value -* @returns {number} sum -*/ -function add( x, y, z, w, v ) { - return x + y + z + w + v; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var out; - var x; - var y; - var z; - var w; - var v; - - shapes = [ - [ 1, shape[ 1 ] ], - [ shape[ 0 ], 1 ], - [ 1, 1 ], - [ shape[ 0 ], shape[ 1 ] ], - [ 1, 1 ], - shape - ]; - x = filled2dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled2dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = filled2dBy( shapes[ 2 ], uniform( -100.0, 100.0 ) ); - w = filled2dBy( shapes[ 3 ], uniform( -100.0, 100.0 ) ); - v = filled2dBy( shapes[ 4 ], uniform( -100.0, 100.0 ) ); - out = zeros2d( shapes[ 5 ] ); - - arrays = [ x, y, z, w, v, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bquinary2d( arrays, shapes, add ); - i1 = i % shapes[ 1 ][ 0 ]; - i0 = i % shapes[ 1 ][ 1 ]; - if ( isnan( arrays[ 5 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shapes[ 1 ][ 0 ]; - i0 = i % shapes[ 1 ][ 1 ]; - if ( isnan( arrays[ 5 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-quinary2d/docs/repl.txt b/base/broadcasted-quinary2d/docs/repl.txt deleted file mode 100644 index 68b8ab6fe..000000000 --- a/base/broadcasted-quinary2d/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a quinary callback to elements in five broadcasted input arrays - and assigns results to elements in a two-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing five input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Quinary callback. - - Examples - -------- - > function fcn( x, y, z, w, v ) { return x + y + z + w + v; }; - > var x = [ 1.0, 2.0 ]; - > var y = [ [ 3.0 ], [ 4.0 ] ]; - > var z = [ [ 1.0 ] ]; - > var w = [ 2.0 ]; - > var v = [ 1.0 ]; - > var out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shapes = [ [ 2 ], [ 2, 1 ], [ 1, 1 ], [ 1 ], [ 1 ], [ 2, 2 ] ]; - > {{alias}}( [ x, y, z, w, v, out ], shapes, fcn ); - > out - [ [ 8.0, 9.0 ], [ 9.0, 10.0 ] ] - - See Also - -------- - diff --git a/base/broadcasted-quinary2d/docs/types/index.d.ts b/base/broadcasted-quinary2d/docs/types/index.d.ts deleted file mode 100644 index 7df256e60..000000000 --- a/base/broadcasted-quinary2d/docs/types/index.d.ts +++ /dev/null @@ -1,127 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D } from '@stdlib/types/array'; -import { Shape1D, Shape2D } from '@stdlib/types/ndarray'; - -/** -* Quinary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @param v5 - element from fifth input array -* @returns result -*/ -type Quinary = ( v1: T, v2: U, v3: V, v4: W, v5: X ) => Y; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D; - -/** -* Output array. -*/ -type OutputArray = Array2D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape2D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - InputArray, - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - InputArrayShape, - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing five input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - quinary callback -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function add( x, y, z, w, v ) { -* return x + y + z + w + v; -* } -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 1, 1 ], -* [ 2, 2 ], -* [ 1, 1 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = ones2d( shapes[ 2 ] ); -* var w = ones2d( shapes[ 3 ] ); -* var v = ones2d( shapes[ 4 ] ); -* var out = zeros2d( shapes[ 5 ] ); -* -* bquinary2d( [ x, y, z, w, v, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] -*/ -declare function bquinary2d( arrays: InOutArrays, shapes: InOutShapes, fcn: Quinary ): void; - - -// EXPORTS // - -export = bquinary2d; diff --git a/base/broadcasted-quinary2d/docs/types/test.ts b/base/broadcasted-quinary2d/docs/types/test.ts deleted file mode 100644 index 7691236ac..000000000 --- a/base/broadcasted-quinary2d/docs/types/test.ts +++ /dev/null @@ -1,125 +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. -*/ - -import bquinary2d = require( './index' ); - -/** -* Quinary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @param v - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number, v: number ): number { - return x + y + z + w + v; -} - -/** -* List of input and output array shapes. -*/ -type InOutShapes = [ Array, Array, Array, Array, Array, Array ]; - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const v = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: InOutShapes = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bquinary2d( [ x, y, z, w, v, out ], shapes, fcn ); // $ExpectType void - bquinary2d( [ x[ 0 ], y, z, w, v, out ], [ [ shapes[ 0 ][ 1 ] ], shapes[ 1 ], shapes[ 2 ], shapes[ 3 ], shapes[ 4 ], shapes[ 5 ] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: InOutShapes = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bquinary2d( 'abc', shapes, fcn ); // $ExpectError - bquinary2d( 3.14, shapes, fcn ); // $ExpectError - bquinary2d( true, shapes, fcn ); // $ExpectError - bquinary2d( false, shapes, fcn ); // $ExpectError - bquinary2d( null, shapes, fcn ); // $ExpectError - bquinary2d( [ '1' ], shapes, fcn ); // $ExpectError - bquinary2d( {}, shapes, fcn ); // $ExpectError - bquinary2d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const v = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - bquinary2d( [ x, y, z, w, v, out ], 'abc', fcn ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], 3.14, fcn ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], true, fcn ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], false, fcn ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], null, fcn ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], [ '1' ], fcn ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], {}, fcn ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const v = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: InOutShapes = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bquinary2d( [ x, y, z, w, v, out ], shapes, 'abc' ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], shapes, 3.14 ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], shapes, true ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], shapes, false ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], shapes, null ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], shapes, [ '1' ] ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const v = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: InOutShapes = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bquinary2d(); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ] ); // $ExpectError - bquinary2d( [ x, y, z, w, v, out ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-quinary2d/examples/index.js b/base/broadcasted-quinary2d/examples/index.js deleted file mode 100644 index 048a3c80e..000000000 --- a/base/broadcasted-quinary2d/examples/index.js +++ /dev/null @@ -1,58 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var bquinary2d = require( './../lib' ); - -function add( x, y, z, w, v ) { - return x + y + z + w + v; -} - -var shapes = [ - [ 1, 3 ], - [ 3, 1 ], - [ 1, 1 ], - [ 3, 3 ], - [ 1, 3 ], - [ 3, 3 ] -]; - -var x = filled2dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled2dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled2dBy( shapes[ 4 ], discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros2d( shapes[ 5 ] ); -console.log( out ); - -bquinary2d( [ x, y, z, w, v, out ], shapes, add ); -console.log( out ); diff --git a/base/broadcasted-quinary2d/lib/index.js b/base/broadcasted-quinary2d/lib/index.js deleted file mode 100644 index 822815519..000000000 --- a/base/broadcasted-quinary2d/lib/index.js +++ /dev/null @@ -1,64 +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'; - -/** -* Apply a quinary callback to elements in five broadcasted input arrays and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-quinary2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var bquinary2d = require( '@stdlib/array/base/broadcasted-quinary2d' ); -* -* function add( x, y, z, w, v ) { -* return x + y + z + w + v; -* } -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 1, 1 ], -* [ 2, 2 ], -* [ 1, 1 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = ones2d( shapes[ 2 ] ); -* var w = ones2d( shapes[ 3 ] ); -* var v = ones2d( shapes[ 4 ] ); -* var out = zeros2d( shapes[ 5 ] ); -* -* bquinary2d( [ x, y, z, w, v, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-quinary2d/lib/main.js b/base/broadcasted-quinary2d/lib/main.js deleted file mode 100644 index 0cfcc901c..000000000 --- a/base/broadcasted-quinary2d/lib/main.js +++ /dev/null @@ -1,180 +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 broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. -* -* @param {ArrayLikeObject>} arrays - array-like object containing five input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - quinary callback -* @returns {void} -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function add( x, y, z, w, v ) { -* return x + y + z + w + v; -* } -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 1, 1 ], -* [ 2, 2 ], -* [ 1, 1 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = ones2d( shapes[ 2 ] ); -* var w = ones2d( shapes[ 3 ] ); -* var v = ones2d( shapes[ 4 ] ); -* var out = zeros2d( shapes[ 5 ] ); -* -* bquinary2d( [ x, y, z, w, v, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] -*/ -function bquinary2d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dy0; - var dy1; - var dz0; - var dz1; - var dw0; - var dw1; - var du0; - var du1; - var S0; - var S1; - var i0; - var i1; - var j0; - var j1; - var k0; - var k1; - var m0; - var m1; - var n0; - var n1; - var p0; - var p1; - var x0; - var y0; - var z0; - var w0; - var u0; - var v0; - var sh; - var st; - var o; - var x; - var y; - var z; - var w; - var u; - var v; - - sh = shapes[ 5 ]; - S0 = sh[ 1 ]; - S1 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 1 ]; - dx1 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 1 ]; - dy1 = st[ 0 ]; - - o = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh ); - z = o.data; - st = o.strides; - dz0 = st[ 1 ]; - dz1 = st[ 0 ]; - - o = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh ); - w = o.data; - st = o.strides; - dw0 = st[ 1 ]; - dw1 = st[ 0 ]; - - o = broadcastArray( arrays[ 4 ], shapes[ 4 ], sh ); - u = o.data; - st = o.strides; - du0 = st[ 1 ]; - du1 = st[ 0 ]; - - v = arrays[ 5 ]; - - j1 = 0; - k1 = 0; - m1 = 0; - n1 = 0; - p1 = 0; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - m0 = 0; - n0 = 0; - p0 = 0; - x0 = x[ j1 ]; - y0 = y[ k1 ]; - z0 = z[ m1 ]; - w0 = w[ n1 ]; - u0 = u[ p1 ]; - v0 = v[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ], u0[ p0 ] ); - j0 += dx0; - k0 += dy0; - m0 += dz0; - n0 += dw0; - p0 += du0; - } - j1 += dx1; - k1 += dy1; - m1 += dz1; - n1 += dw1; - p1 += du1; - } -} - - -// EXPORTS // - -module.exports = bquinary2d; diff --git a/base/broadcasted-quinary2d/package.json b/base/broadcasted-quinary2d/package.json deleted file mode 100644 index 28120497b..000000000 --- a/base/broadcasted-quinary2d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-quinary2d", - "version": "0.0.0", - "description": "Apply a quinary callback to elements in five broadcasted input arrays and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "quinary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-quinary2d/test/test.js b/base/broadcasted-quinary2d/test/test.js deleted file mode 100644 index eae94e59b..000000000 --- a/base/broadcasted-quinary2d/test/test.js +++ /dev/null @@ -1,236 +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 zeros2d = require( './../../../base/zeros2d' ); -var bquinary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns the sum. -* -* @private -* @param {number} x - first value -* @param {number} y - second value -* @param {number} z - third value -* @param {number} w - fourth value -* @param {number} v - fifth value -* @returns {number} sum -*/ -function add( x, y, z, w, v ) { - return x + y + z + w + v; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bquinary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - var u; - - shapes = [ - [ 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 1 ], - [ 1, 2 ], - [ 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ 3.0 ], - [ 4.0 ] - ]; - z = [ [ 5.0 ] ]; - w = [ 1.0 ]; - u = [ [ 1.0, 2.0 ] ]; - out = zeros2d( shapes[ 5 ] ); - - expected = [ - [ 11.0, 13.0 ], - [ 12.0, 14.0 ] - ]; - bquinary2d( [ x, y, z, w, u, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - shapes = [ - [ 1, 2 ], - [ 2 ], - [ 1 ], - [ 2, 2 ], - [ 2, 1 ], - [ 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ] - ]; - y = [ 3.0, 4.0 ]; - z = [ 5.0 ]; - w = [ - [ 2.0, 3.0 ], - [ 4.0, 5.0 ] - ]; - u = [ - [ 1.0 ], - [ 2.0 ] - ]; - out = zeros2d( shapes[ 5 ] ); - - expected = [ - [ 12.0, 15.0 ], - [ 15.0, 18.0 ] - ]; - bquinary2d( [ x, y, z, w, u, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - z = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - w = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - u = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - out = zeros2d( shapes[ 5 ] ); - - expected = [ - [ 5.0, 10.0 ], - [ 15.0, 20.0 ] - ]; - bquinary2d( [ x, y, z, w, u, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - var u; - - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 0, 2 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = x; - z = x; - w = x; - u = x; - out = zeros2d( [ 2, 2 ] ); - - expected = zeros2d( [ 2, 2 ] ); - bquinary2d( [ x, y, z, w, u, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - var u; - - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 0 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = x; - z = x; - w = x; - u = x; - out = zeros2d( [ 2, 2 ] ); - - expected = zeros2d( [ 2, 2 ] ); - bquinary2d( [ x, y, z, w, u, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-quinary4d/README.md b/base/broadcasted-quinary4d/README.md deleted file mode 100644 index 4ff6f3d55..000000000 --- a/base/broadcasted-quinary4d/README.md +++ /dev/null @@ -1,159 +0,0 @@ - - -# bquinary4d - -> Apply a quinary callback to elements in five [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bquinary4d = require( '@stdlib/array/base/broadcasted-quinary4d' ); -``` - -#### bquinary4d( arrays, shapes, fcn ) - -Applies a quinary callback to elements in five [broadcasted][@stdlib/array/base/broadcast-array] input arrays and assigns results to elements in a four-dimensional nested output array. - -```javascript -var zeros4d = require( '@stdlib/array/base/zeros4d' ); - -function add( x, y, z, w, v ) { - return x + y + z + w + v; -} - -var x = [ [ [ [ 1.0, 2.0 ] ] ] ]; -var y = [ [ [ [ 3.0 ], [ 4.0 ] ] ] ]; -var z = [ [ [ [ 5.0 ] ] ] ]; -var w = [ [ [ [ 2.0 ] ] ] ]; -var v = [ [ [ [ 1.0 ] ] ] ]; -var out = zeros4d( [ 2, 2, 2, 2 ] ); - -var shapes = [ - [ 1, 1, 1, 2 ], - [ 1, 1, 2, 1 ], - [ 1, 1, 1, 1 ], - [ 1, 1, 1, 1 ], - [ 1, 1, 1, 1 ], - [ 2, 2, 2, 2 ] -]; - -bquinary4d( [ x, y, z, w, v, out ], shapes, add ); -// out => [ [ [ [ 12.0, 13.0 ], [ 13.0, 14.0 ] ], [ [ 12.0, 13.0 ], [ 13.0, 14.0 ] ] ], [ [ [ 12.0, 13.0 ], [ 13.0, 14.0 ] ], [ [ 12.0, 13.0 ], [ 13.0, 14.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing five input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: quinary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var bquinary4d = require( '@stdlib/array/base/broadcasted-quinary4d' ); - -function add( x, y, z, w, v ) { - return x + y + z + w + v; -} - -var shapes = [ - [ 1, 1, 1, 3 ], - [ 1, 1, 3, 1 ], - [ 1, 1, 3, 3 ], - [ 1, 3, 1, 1 ], - [ 3, 3, 3, 3 ], - [ 3, 3, 3, 3 ] -]; - -var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled4dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled4dBy( shapes[ 4 ], discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros4d( shapes[ 5 ] ); -console.log( out ); - -bquinary4d( [ x, y, z, w, v, out ], shapes, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-quinary4d/benchmark/benchmark.js b/base/broadcasted-quinary4d/benchmark/benchmark.js deleted file mode 100644 index edb2b2f8a..000000000 --- a/base/broadcasted-quinary4d/benchmark/benchmark.js +++ /dev/null @@ -1,153 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bquinary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns the sum. -* -* @private -* @param {number} x - first value -* @param {number} y - second value -* @param {number} z - third value -* @param {number} w - fourth value -* @param {number} v - fifth value -* @returns {number} sum -*/ -function add( x, y, z, w, v ) { - return x + y + z + w + v; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var out; - var x; - var y; - var z; - var w; - var v; - - shapes = [ - [ 1, 1, 1, shape[ 0 ] ], - [ 1, 1, shape[ 1 ], 1 ], - [ 1, 1, shape[ 2 ], shape[ 3 ] ], - [ 1, shape[ 3 ], 1, 1 ], - [ shape[ 0 ], shape[ 1 ], shape[ 2 ], shape[ 3 ] ], - shape - ]; - x = filled4dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled4dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = filled4dBy( shapes[ 2 ], uniform( -100.0, 100.0 ) ); - w = filled4dBy( shapes[ 3 ], uniform( -100.0, 100.0 ) ); - v = filled4dBy( shapes[ 4 ], uniform( -100.0, 100.0 ) ); - out = zeros4d( shapes[ 5 ] ); - - arrays = [ x, y, z, w, v, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bquinary4d( arrays, shapes, add ); - i3 = i % shapes[ 1 ][ 0 ]; - i2 = i % shapes[ 1 ][ 1 ]; - i1 = i % shapes[ 1 ][ 2 ]; - i0 = i % shapes[ 1 ][ 3 ]; - if ( isnan( arrays[ 5 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shapes[ 1 ][ 0 ]; - i2 = i % shapes[ 1 ][ 1 ]; - i1 = i % shapes[ 1 ][ 2 ]; - i0 = i % shapes[ 1 ][ 3 ]; - if ( isnan( arrays[ 5 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-quinary4d/docs/repl.txt b/base/broadcasted-quinary4d/docs/repl.txt deleted file mode 100644 index 29e1145c5..000000000 --- a/base/broadcasted-quinary4d/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a quinary callback to elements in five broadcasted input arrays and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing five input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Quinary callback. - - Examples - -------- - > function fcn( x, y, z, w, v ) { return x + y + z + w + v; }; - > var x = [ 1.0, 2.0 ]; - > var y = [ [ 3.0 ], [ 4.0 ] ]; - > var z = [ 1.0 ]; - > var w = [ 2.0 ]; - > var v = [ 1.0 ]; - > var out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shapes = [ [ 2 ], [ 2, 1 ], [ 1 ], [ 1 ], [ 1 ], [ 1, 1, 2, 2 ] ]; - > {{alias}}( [ x, y, z, w, v, out ], shapes, fcn ); - > out - [ [ [ [ 8.0, 9.0 ], [ 9.0, 10.0 ] ] ] ] - - See Also - -------- - diff --git a/base/broadcasted-quinary4d/docs/types/index.d.ts b/base/broadcasted-quinary4d/docs/types/index.d.ts deleted file mode 100644 index a6fe5246b..000000000 --- a/base/broadcasted-quinary4d/docs/types/index.d.ts +++ /dev/null @@ -1,127 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D, Shape4D } from '@stdlib/types/ndarray'; - -/** -* Quinary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @param v5 - element from fifth input array -* @returns result -*/ -type Quinary = ( v1: T, v2: U, v3: V, v4: W, v5: X ) => Y; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D | Array4D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D | Shape4D; - -/** -* Output array. -*/ -type OutputArray = Array4D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape4D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - InputArray, - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - InputArrayShape, - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing five input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - quinary callback -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function add( x, y, z, w, v ) { -* return x + y + z + w + v; -* } -* -* var shapes = [ -* [ 1, 1, 1, 2 ], -* [ 1, 1, 2, 1 ], -* [ 1, 1, 2, 2 ], -* [ 1, 2, 1, 1 ], -* [ 2, 2, 2, 2 ], -* [ 2, 2, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = ones4d( shapes[ 2 ] ); -* var w = ones4d( shapes[ 3 ] ); -* var v = ones4d( shapes[ 4 ] ); -* var out = zeros4d( shapes[ 5 ] ); -* -* bquinary4d( [ x, y, z, w, v, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ], [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] -*/ -declare function bquinary4d( arrays: InOutArrays, shapes: InOutShapes, fcn: Quinary ): void; - - -// EXPORTS // - -export = bquinary4d; diff --git a/base/broadcasted-quinary4d/docs/types/test.ts b/base/broadcasted-quinary4d/docs/types/test.ts deleted file mode 100644 index 93e235b1e..000000000 --- a/base/broadcasted-quinary4d/docs/types/test.ts +++ /dev/null @@ -1,125 +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. -*/ - -import bquinary4d = require( './index' ); - -/** -* Quinary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @param v - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number, v: number ): number { - return x + y + z + w + v; -} - -/** -* List of input and output array shapes. -*/ -type InOutShapes = [ Array, Array, Array, Array, Array, Array ]; - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const v = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: InOutShapes = [ [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ] ]; - - bquinary4d( [ x, y, z, w, v, out ], shapes, fcn ); // $ExpectType void - bquinary4d( [ x[ 0 ], y, z, w, v, out ], [ [ shapes[ 0 ][ 1 ][ 2 ][ 3 ] ], shapes[ 1 ], shapes[ 2 ], shapes [ 3 ], shapes[ 4 ], shapes[ 5 ] ] , fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: InOutShapes = [ [ 2, 2, 2, 2 ] , [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ] ]; - - bquinary4d( 'abc', shapes, fcn ); // $ExpectError - bquinary4d( 3.14, shapes, fcn ); // $ExpectError - bquinary4d( true, shapes, fcn ); // $ExpectError - bquinary4d( false, shapes, fcn ); // $ExpectError - bquinary4d( null, shapes, fcn ); // $ExpectError - bquinary4d( [ '1' ], shapes, fcn ); // $ExpectError - bquinary4d( {}, shapes, fcn ); // $ExpectError - bquinary4d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const v = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - bquinary4d( [ x, y, z, w, v, out ], 'abc', fcn ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], 3.14, fcn ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], true, fcn ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], false, fcn ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], null, fcn ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], [ '1' ], fcn ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], {}, fcn ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const v = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: InOutShapes = [ [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2 ,2 ] ]; - - bquinary4d( [ x, y, z, w, v, out ], shapes, 'abc' ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], shapes, 3.14 ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], shapes, true ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], shapes, false ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], shapes, null ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], shapes, [ '1' ] ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const v = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: InOutShapes = [ [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2 ,2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ] ]; - - bquinary4d(); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ] ); // $ExpectError - bquinary4d( [ x, y, z, w, v, out ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-quinary4d/examples/index.js b/base/broadcasted-quinary4d/examples/index.js deleted file mode 100644 index 0c43655dd..000000000 --- a/base/broadcasted-quinary4d/examples/index.js +++ /dev/null @@ -1,58 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var bquinary4d = require( './../lib' ); - -function add( x, y, z, w, v ) { - return x + y + z + w + v; -} - -var shapes = [ - [ 1, 1, 1, 3 ], - [ 1, 1, 3, 1 ], - [ 1, 1, 3, 3 ], - [ 1, 3, 1, 1 ], - [ 3, 3, 3, 3 ], - [ 3, 3, 3, 3 ] -]; - -var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled4dBy( shapes[ 3 ], discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled4dBy( shapes[ 4 ], discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros4d( shapes[ 5 ] ); -console.log( out ); - -bquinary4d( [ x, y, z, w, v, out ], shapes, add ); -console.log( out ); diff --git a/base/broadcasted-quinary4d/lib/index.js b/base/broadcasted-quinary4d/lib/index.js deleted file mode 100644 index 0a2001b27..000000000 --- a/base/broadcasted-quinary4d/lib/index.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -/** -* Apply a quinary callback to elements in five broadcasted input arrays and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-quinary4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var bquinary4d = require( '@stdlib/array/base/broadcasted-quinary4d' ); -* -* function add( x, y, z, w, v ) { -* return x + y + z + w + v; -* } -* -* var shapes = [ -* [ 1, 1, 1, 2 ], -* [ 1, 1, 2, 1 ], -* [ 1, 1, 2, 2 ], -* [ 1, 2, 1, 1 ], -* [ 2, 2, 2, 2 ], -* [ 2, 2, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = ones4d( shapes[ 2 ] ); -* var w = ones4d( shapes[ 3 ] ); -* var v = ones4d( shapes[ 4 ] ); -* var out = zeros4d( shapes[ 5 ] ); -* -* bquinary4d( [ x, y, z, w, v, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ], [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-quinary4d/lib/main.js b/base/broadcasted-quinary4d/lib/main.js deleted file mode 100644 index b9eb875c3..000000000 --- a/base/broadcasted-quinary4d/lib/main.js +++ /dev/null @@ -1,264 +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. -*/ - -'use strict'; - -// MODULES // - -var broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. -* -* @param {ArrayLikeObject} arrays - array-like object containing five input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - quinary callback -* @returns {void} -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function add( x, y, z, w, v ) { -* return x + y + z + w + v; -* } -* -* var shapes = [ -* [ 1, 1, 1, 2 ], -* [ 1, 1, 2, 1 ], -* [ 1, 1, 2, 2 ], -* [ 1, 2, 1, 1 ], -* [ 2, 2, 2, 2 ], -* [ 2, 2, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = ones4d( shapes[ 2 ] ); -* var w = ones4d( shapes[ 3 ] ); -* var v = ones4d( shapes[ 4 ] ); -* var out = zeros4d( shapes[ 5 ] ); -* -* bquinary4d( [ x, y, z, w, v, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ], [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] -*/ -function bquinary4d( arrays, shapes, fcn ) { // eslint-disable-line max-statements - var dx0; - var dx1; - var dx2; - var dx3; - var dy0; - var dy1; - var dy2; - var dy3; - var dz0; - var dz1; - var dz2; - var dz3; - var dw0; - var dw1; - var dw2; - var dw3; - var du0; - var du1; - var du2; - var du3; - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var j0; - var j1; - var j2; - var j3; - var k0; - var k1; - var k2; - var k3; - var m0; - var m1; - var m2; - var m3; - var n0; - var n1; - var n2; - var n3; - var p0; - var p1; - var p2; - var p3; - var x0; - var x1; - var x2; - var y0; - var y1; - var y2; - var z0; - var z1; - var z2; - var w0; - var w1; - var w2; - var u0; - var u1; - var u2; - var v0; - var v1; - var v2; - var sh; - var st; - var o; - var x; - var y; - var z; - var w; - var u; - var v; - - sh = shapes[ 5 ]; - S0 = sh[ 3 ]; - S1 = sh[ 2 ]; - S2 = sh[ 1 ]; - S3 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 3 ]; - dx1 = st[ 2 ]; - dx2 = st[ 1 ]; - dx3 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 3 ]; - dy1 = st[ 2 ]; - dy2 = st[ 1 ]; - dy3 = st[ 0 ]; - - o = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh ); - z = o.data; - st = o.strides; - dz0 = st[ 3 ]; - dz1 = st[ 2 ]; - dz2 = st[ 1 ]; - dz3 = st[ 0 ]; - - o = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh ); - w = o.data; - st = o.strides; - dw0 = st[ 3 ]; - dw1 = st[ 2 ]; - dw2 = st[ 1 ]; - dw3 = st[ 0 ]; - - o = broadcastArray( arrays[ 4 ], shapes[ 4 ], sh ); - u = o.data; - st = o.strides; - du0 = st[ 3 ]; - du1 = st[ 2 ]; - du2 = st[ 1 ]; - du3 = st[ 0 ]; - - v = arrays[ 5 ]; - - j3 = 0; - k3 = 0; - m3 = 0; - n3 = 0; - p3 = 0; - for ( i3 = 0; i3 < S3; i3++ ) { - j2 = 0; - k2 = 0; - m2 = 0; - n2 = 0; - p2 = 0; - x2 = x[ j3 ]; - y2 = y[ k3 ]; - z2 = z[ m3 ]; - w2 = w[ n3 ]; - u2 = u[ p3 ]; - v2 = v[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - k1 = 0; - m1 = 0; - n1 = 0; - p1 = 0; - x1 = x2[ j2 ]; - y1 = y2[ k2 ]; - z1 = z2[ m2 ]; - w1 = w2[ n2 ]; - u1 = u2[ p2 ]; - v1 = v2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - m0 = 0; - n0 = 0; - p0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ k1 ]; - z0 = z1[ m1 ]; - w0 = w1[ n1 ]; - u0 = u1[ p1 ]; - v0 = v1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ], u0[ p0 ] ); // eslint-disable-line max-len - j0 += dx0; - k0 += dy0; - m0 += dz0; - n0 += dw0; - p0 += du0; - } - j1 += dx1; - k1 += dy1; - m1 += dz1; - n1 += dw1; - p1 += du1; - } - j2 += dx2; - k2 += dy2; - m2 += dz2; - n2 += dw2; - p2 += du2; - } - j3 += dx3; - k3 += dy3; - m3 += dz3; - n3 += dw3; - p3 += du3; - } -} - - -// EXPORTS // - -module.exports = bquinary4d; diff --git a/base/broadcasted-quinary4d/package.json b/base/broadcasted-quinary4d/package.json deleted file mode 100644 index b3a3f025e..000000000 --- a/base/broadcasted-quinary4d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-quinary4d", - "version": "0.0.0", - "description": "Apply a quinary callback to elements in five broadcasted input arrays and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "quinary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-quinary4d/test/test.js b/base/broadcasted-quinary4d/test/test.js deleted file mode 100644 index 61fae1c8a..000000000 --- a/base/broadcasted-quinary4d/test/test.js +++ /dev/null @@ -1,525 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var zeros4d = require( './../../../base/zeros4d' ); -var bquinary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns the sum. -* -* @private -* @param {number} x - first value -* @param {number} y - second value -* @param {number} z - third value -* @param {number} w - fourth value -* @param {number} v - fifth value -* @returns {number} sum -*/ -function add( x, y, z, w, v ) { - return x + y + z + w + v; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bquinary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - var u; - - shapes = [ - [ 1, 1, 1, 2 ], - [ 1, 1, 2, 1 ], - [ 1, 1, 2, 2 ], - [ 1, 2, 1, 1 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 3.0 ], - [ 4.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - w = [ - [ - [ [ 9.0 ] ], - [ [ 10.0 ] ] - ] - ]; - u = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - out = zeros4d( shapes[ 5 ] ); - - expected = [ - [ - [ - [ 19, 22 ], - [ 24, 27 ] - ], - [ - [ 20, 23 ], - [ 25, 28 ] - ] - ], - [ - [ - [ 19, 22 ], - [ 24, 27 ] - ], - [ - [ 20, 23 ], - [ 25, 28 ] - ] - ] - ]; - bquinary4d( [ x, y, z, w, u, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - u = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - out = zeros4d( shapes[ 5 ] ); - - expected = [ - [ - [ - [ 5.0, 10.0 ], - [ 15.0, 20.0 ] - ], - [ - [ 5.0, 10.0 ], - [ 15.0, 20.0 ] - ] - ], - [ - [ - [ 5.0, 10.0 ], - [ 15.0, 20.0 ] - ], - [ - [ 5.0, 10.0 ], - [ 15.0, 20.0 ] - ] - ] - ]; - bquinary4d( [ x, y, z, w, u, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - var u; - - shapes = [ - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 0, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = x; - w = x; - u = x; - out = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bquinary4d( [ x, y, z, w, u, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - var u; - - shapes = [ - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 0, 2, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = x; - w = x; - u = x; - out = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bquinary4d( [ x, y, z, w, u, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - var u; - - shapes = [ - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 0, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = x; - w = x; - u = x; - out = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bquinary4d( [ x, y, z, w, u, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a fourth element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - var w; - var u; - - shapes = [ - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 0 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = x; - w = x; - u = x; - out = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bquinary4d( [ x, y, z, w, u, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-ternary2d/README.md b/base/broadcasted-ternary2d/README.md deleted file mode 100644 index 923c7f595..000000000 --- a/base/broadcasted-ternary2d/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# bternary2d - -> Apply a ternary callback to elements in three [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bternary2d = require( '@stdlib/array/base/broadcasted-ternary2d' ); -``` - -#### bternary2d( arrays, shapes, fcn ) - -Applies a ternary callback to elements in three [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assigns results to elements in a two-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); - -var x = [ [ 1.0, 2.0 ] ]; -var y = [ [ 3.0 ], [ 4.0 ] ]; -var z = [ [ 5.0 ] ]; -var out = zeros2d( [ 2, 2 ] ); - -var shapes = [ - [ 1, 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 2, 2 ] -]; - -bternary2d( [ x, y, z, out ], shapes, add ); -// out => [ [ 9.0, 10.0 ], [ 10.0, 11.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing three input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: ternary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var bternary2d = require( '@stdlib/array/base/broadcasted-ternary2d' ); - -var shapes = [ - [ 1, 3 ], - [ 3, 1 ], - [ 1, 1 ], - [ 3, 3 ] -]; - -var x = filled2dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros2d( shapes[ 3 ] ); -console.log( out ); - -bternary2d( [ x, y, z, out ], shapes, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-ternary2d/benchmark/benchmark.js b/base/broadcasted-ternary2d/benchmark/benchmark.js deleted file mode 100644 index 303eeb919..000000000 --- a/base/broadcasted-ternary2d/benchmark/benchmark.js +++ /dev/null @@ -1,127 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var pkg = require( './../package.json' ).name; -var bternary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var out; - var x; - var y; - var z; - - shapes = [ - [ 1, shape[ 1 ] ], - [ shape[ 0 ], 1 ], - [ 1, 1 ], - shape - ]; - x = filled2dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled2dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = filled2dBy( shapes[ 2 ], uniform( -100.0, 100.0 ) ); - out = zeros2d( shapes[ 3 ] ); - - arrays = [ x, y, z, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bternary2d( arrays, shapes, add ); - i1 = i % shapes[ 1 ][ 0 ]; - i0 = i % shapes[ 1 ][ 1 ]; - if ( isnan( arrays[ 3 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shapes[ 1 ][ 0 ]; - i0 = i % shapes[ 1 ][ 1 ]; - if ( isnan( arrays[ 3 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-ternary2d/docs/repl.txt b/base/broadcasted-ternary2d/docs/repl.txt deleted file mode 100644 index 7bfca2785..000000000 --- a/base/broadcasted-ternary2d/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a ternary callback to elements in three broadcasted input arrays and - assigns results to elements in a two-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing three input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Ternary callback. - - Examples - -------- - > function fcn( x, y, z ) { return x + y + z }; - > var x = [ 1.0, 2.0 ]; - > var y = [ [ 3.0 ], [ 4.0 ] ]; - > var z = [ [ 1.0 ] ]; - > var out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shapes = [ [ 2 ], [ 2, 1 ], [ 1, 1 ], [ 2, 2 ] ]; - > {{alias}}( [ x, y, z, out ], shapes, fcn ); - > out - [ [ 5.0, 6.0 ], [ 6.0, 7.0 ] ] - - See Also - -------- - diff --git a/base/broadcasted-ternary2d/docs/types/index.d.ts b/base/broadcasted-ternary2d/docs/types/index.d.ts deleted file mode 100644 index 96c2627d1..000000000 --- a/base/broadcasted-ternary2d/docs/types/index.d.ts +++ /dev/null @@ -1,114 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D } from '@stdlib/types/array'; -import { Shape1D, Shape2D } from '@stdlib/types/ndarray'; - -/** -* Ternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @returns result -*/ -type Ternary = ( v1: T, v2: U, v3: V ) => W; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D; - -/** -* Output array. -*/ -type OutputArray = Array2D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape2D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing three input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - ternary callback -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 1, 1 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = ones2d( shapes[ 2 ] ); -* var out = zeros2d( shapes[ 3 ] ); -* -* bternary2d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] -*/ -declare function bternary2d( arrays: InOutArrays, shapes: InOutShapes, fcn: Ternary ): void; - - -// EXPORTS // - -export = bternary2d; diff --git a/base/broadcasted-ternary2d/docs/types/test.ts b/base/broadcasted-ternary2d/docs/types/test.ts deleted file mode 100644 index 4cf359284..000000000 --- a/base/broadcasted-ternary2d/docs/types/test.ts +++ /dev/null @@ -1,110 +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. -*/ - -import bternary2d = require( './index' ); - -/** -* Ternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number ): number { - return x + y + z; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bternary2d( [ x, y, z, out ], shapes, fcn ); // $ExpectType void - bternary2d( [ x[ 0 ], y, z, out ], [ [ shapes[ 0 ][ 1 ] ], shapes[ 1 ], shapes[ 2 ], shapes[ 3 ] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bternary2d( 'abc', shapes, fcn ); // $ExpectError - bternary2d( 3.14, shapes, fcn ); // $ExpectError - bternary2d( true, shapes, fcn ); // $ExpectError - bternary2d( false, shapes, fcn ); // $ExpectError - bternary2d( null, shapes, fcn ); // $ExpectError - bternary2d( [ '1' ], shapes, fcn ); // $ExpectError - bternary2d( {}, shapes, fcn ); // $ExpectError - bternary2d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - bternary2d( [ x, y, z, out ], 'abc', fcn ); // $ExpectError - bternary2d( [ x, y, z, out ], 3.14, fcn ); // $ExpectError - bternary2d( [ x, y, z, out ], true, fcn ); // $ExpectError - bternary2d( [ x, y, z, out ], false, fcn ); // $ExpectError - bternary2d( [ x, y, z, out ], null, fcn ); // $ExpectError - bternary2d( [ x, y, z, out ], [ '1' ], fcn ); // $ExpectError - bternary2d( [ x, y, z, out ], {}, fcn ); // $ExpectError - bternary2d( [ x, y, z, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bternary2d( [ x, y, z, out ], shapes, 'abc' ); // $ExpectError - bternary2d( [ x, y, z, out ], shapes, 3.14 ); // $ExpectError - bternary2d( [ x, y, z, out ], shapes, true ); // $ExpectError - bternary2d( [ x, y, z, out ], shapes, false ); // $ExpectError - bternary2d( [ x, y, z, out ], shapes, null ); // $ExpectError - bternary2d( [ x, y, z, out ], shapes, [ '1' ] ); // $ExpectError - bternary2d( [ x, y, z, out ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2 ], [ 2, 2 ], [ 2, 2 ], [ 2, 2 ] ]; - - bternary2d(); // $ExpectError - bternary2d( [ x, y, z, out ] ); // $ExpectError - bternary2d( [ x, y, z, out ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-ternary2d/examples/index.js b/base/broadcasted-ternary2d/examples/index.js deleted file mode 100644 index cc5f37fd3..000000000 --- a/base/broadcasted-ternary2d/examples/index.js +++ /dev/null @@ -1,47 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var bternary2d = require( './../lib' ); - -var shapes = [ - [ 1, 3 ], - [ 3, 1 ], - [ 1, 1 ], - [ 3, 3 ] -]; - -var x = filled2dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros2d( shapes[ 3 ] ); -console.log( out ); - -bternary2d( [ x, y, z, out ], shapes, add ); -console.log( out ); diff --git a/base/broadcasted-ternary2d/lib/index.js b/base/broadcasted-ternary2d/lib/index.js deleted file mode 100644 index fb9bb1ad6..000000000 --- a/base/broadcasted-ternary2d/lib/index.js +++ /dev/null @@ -1,57 +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'; - -/** -* Apply a ternary callback to elements in three broadcasted input arrays and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-ternary2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); -* var bternary2d = require( '@stdlib/array/base/broadcasted-ternary2d' ); -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 1, 1 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = ones2d( shapes[ 2 ] ); -* var out = zeros2d( shapes[ 3 ] ); -* -* bternary2d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-ternary2d/lib/main.js b/base/broadcasted-ternary2d/lib/main.js deleted file mode 100644 index 87cda7af1..000000000 --- a/base/broadcasted-ternary2d/lib/main.js +++ /dev/null @@ -1,139 +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 broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. -* -* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - ternary callback -* @returns {void} -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 1 ], -* [ 1, 1 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = ones2d( shapes[ 1 ] ); -* var z = ones2d( shapes[ 2 ] ); -* var out = zeros2d( shapes[ 3 ] ); -* -* bternary2d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] -*/ -function bternary2d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dy0; - var dy1; - var dz0; - var dz1; - var S0; - var S1; - var i0; - var i1; - var j0; - var j1; - var k0; - var k1; - var m0; - var m1; - var x0; - var y0; - var z0; - var w0; - var sh; - var st; - var o; - var x; - var y; - var z; - var w; - - sh = shapes[ 3 ]; - S0 = sh[ 1 ]; - S1 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 1 ]; - dx1 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 1 ]; - dy1 = st[ 0 ]; - - o = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh ); - z = o.data; - st = o.strides; - dz0 = st[ 1 ]; - dz1 = st[ 0 ]; - - w = arrays[ 3 ]; - - j1 = 0; - k1 = 0; - m1 = 0; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - m0 = 0; - x0 = x[ j1 ]; - y0 = y[ k1 ]; - z0 = z[ m1 ]; - w0 = w[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - w0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] ); - j0 += dx0; - k0 += dy0; - m0 += dz0; - } - j1 += dx1; - k1 += dy1; - m1 += dz1; - } -} - - -// EXPORTS // - -module.exports = bternary2d; diff --git a/base/broadcasted-ternary2d/package.json b/base/broadcasted-ternary2d/package.json deleted file mode 100644 index 9f775b4f1..000000000 --- a/base/broadcasted-ternary2d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-ternary2d", - "version": "0.0.0", - "description": "Apply a ternary callback to elements in three broadcasted input arrays and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "ternary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-ternary2d/test/test.js b/base/broadcasted-ternary2d/test/test.js deleted file mode 100644 index c423ef044..000000000 --- a/base/broadcasted-ternary2d/test/test.js +++ /dev/null @@ -1,181 +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 zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var bternary2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bternary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - - shapes = [ - [ 2 ], - [ 2, 1 ], - [ 1, 1 ], - [ 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ 3.0 ], - [ 4.0 ] - ]; - z = [ [ 5.0 ] ]; - out = zeros2d( shapes[ 3 ] ); - - expected = [ - [ 9.0, 10.0 ], - [ 10.0, 11.0 ] - ]; - bternary2d( [ x, y, z, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - shapes = [ - [ 1, 2 ], - [ 2 ], - [ 1 ], - [ 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ] - ]; - y = [ 3.0, 4.0 ]; - z = [ 5.0 ]; - out = zeros2d( shapes[ 3 ] ); - - expected = [ - [ 9.0, 11.0 ], - [ 9.0, 11.0 ] - ]; - bternary2d( [ x, y, z, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - z = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - out = zeros2d( shapes[ 3 ] ); - - expected = [ - [ 3.0, 6.0 ], - [ 9.0, 12.0 ] - ]; - bternary2d( [ x, y, z, out ], shapes, add ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 0, 2 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = x; - z = x; - out = zeros2d( [ 2, 2 ] ); - - expected = zeros2d( [ 2, 2 ] ); - bternary2d( [ x, y, z, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var out; - var x; - var y; - var z; - - shapes = [ - [ 2, 2 ], - [ 2, 2 ], - [ 2, 2 ], - [ 2, 0 ] - ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = x; - z = x; - out = zeros2d( [ 2, 2 ] ); - - expected = zeros2d( [ 2, 2 ] ); - bternary2d( [ x, y, z, out ], shapes, clbk ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-ternary3d/README.md b/base/broadcasted-ternary3d/README.md deleted file mode 100644 index 567eb3f14..000000000 --- a/base/broadcasted-ternary3d/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# bternary3d - -> Apply a ternary callback to elements in three [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bternary3d = require( '@stdlib/array/base/broadcasted-ternary3d' ); -``` - -#### bternary3d( arrays, shapes, fcn ) - -Applies a ternary callback to elements in three [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assigns results to elements in a three-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); - -var x = [ [ [ 1.0 ], [ 2.0 ] ] ]; -var y = [ [ [ 3.0 ] ], [ [ 4.0 ] ] ]; -var z = [ [ [ 5.0, 6.0 ] ] ]; -var out = zeros3d( [ 2, 2, 2 ] ); - -var shapes = [ - [ 1, 2, 1 ], - [ 2, 1, 1 ], - [ 1, 1, 2 ], - [ 2, 2, 2 ] -]; - -bternary3d( [ x, y, z, out ], shapes, add ); -// out => [ [ [ 9.0, 10.0 ], [ 10.0, 11.0 ] ], [ [ 10.0, 11.0 ], [ 11.0, 12.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing three input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: ternary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var bternary3d = require( '@stdlib/array/base/broadcasted-ternary3d' ); - -var shapes = [ - [ 1, 3, 1 ], - [ 3, 1, 1 ], - [ 1, 1, 3 ], - [ 3, 3, 3 ] -]; - -var x = filled3dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled3dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros3d( shapes[ 3 ] ); -console.log( out ); - -bternary3d( [ x, y, z, out ], shapes, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-ternary3d/benchmark/benchmark.js b/base/broadcasted-ternary3d/benchmark/benchmark.js deleted file mode 100644 index d090f5bc0..000000000 --- a/base/broadcasted-ternary3d/benchmark/benchmark.js +++ /dev/null @@ -1,130 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bternary3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, shape[ 2 ] ], - [ shape[ 0 ], 1, 1 ], - [ 1, shape[ 1 ], 1 ], - shape - ]; - x = filled3dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled3dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = filled3dBy( shapes[ 2 ], uniform( -100.0, 100.0 ) ); - w = zeros3d( shapes[ 3 ] ); - - arrays = [ x, y, z, w ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bternary3d( arrays, shapes, add ); - i2 = i % shapes[ 1 ][ 0 ]; - i1 = i % shapes[ 1 ][ 1 ]; - i0 = i % shapes[ 1 ][ 2 ]; - if ( isnan( arrays[ 3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shapes[ 1 ][ 0 ]; - i1 = i % shapes[ 1 ][ 1 ]; - i0 = i % shapes[ 1 ][ 2 ]; - if ( isnan( arrays[ 3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0 / 3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg + '::equidimensional:size=' + numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-ternary3d/docs/repl.txt b/base/broadcasted-ternary3d/docs/repl.txt deleted file mode 100644 index f7183ee29..000000000 --- a/base/broadcasted-ternary3d/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a ternary callback to elements in three broadcasted input arrays and - assigns results to elements in a three-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing three input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Ternary callback. - - Examples - -------- - > function fcn( x, y, z ) { return x + y + z }; - > var x = [ 1.0 ]; - > var y = [ [ 2.0 ], [ 3.0 ] ]; - > var z = [ [ [ 4.0 ], [ 6.0 ] ] ]; - > var out = [ [ [ 0.0 ], [ 0.0 ] ], [ [ 0.0 ], [ 0.0 ] ] ]; - > var shapes = [ [ 1 ], [ 2, 1 ], [ 1, 2, 1 ], [ 2, 2, 1 ] ]; - > {{alias}}( [ x, y, z, out ], shapes, fcn ); - > out - [ [ [ 7.0 ], [ 10.0 ] ], [ [ 7.0 ], [ 10.0 ] ] ] - - See Also - -------- - diff --git a/base/broadcasted-ternary3d/docs/types/index.d.ts b/base/broadcasted-ternary3d/docs/types/index.d.ts deleted file mode 100644 index ec605c9c2..000000000 --- a/base/broadcasted-ternary3d/docs/types/index.d.ts +++ /dev/null @@ -1,114 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D } from '@stdlib/types/ndarray'; - -/** -* Ternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @returns result -*/ -type Ternary = ( v1: T, v2: U, v3: V ) => W; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D; - -/** -* Output array. -*/ -type OutputArray = Array3D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape3D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing three input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - ternary callback -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); -* -* var shapes = [ -* [ 1, 2, 1 ], -* [ 2, 1, 1 ], -* [ 1, 1, 2 ], -* [ 2, 2, 2 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = ones3d( shapes[ 1 ] ); -* var z = ones3d( shapes[ 2 ] ); -* var out = zeros3d( shapes[ 3 ] ); -* -* bternary3d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] -*/ -declare function bternary3d( arrays: InOutArrays, shapes: InOutShapes, fcn: Ternary ): void; - - -// EXPORTS // - -export = bternary3d; diff --git a/base/broadcasted-ternary3d/docs/types/test.ts b/base/broadcasted-ternary3d/docs/types/test.ts deleted file mode 100644 index b1177e0f6..000000000 --- a/base/broadcasted-ternary3d/docs/types/test.ts +++ /dev/null @@ -1,110 +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. -*/ - -import bternary3d = require( './index' ); - -/** -* Ternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number ): number { - return x + y + z; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ]; - - bternary3d( [ x, y, z, out ], shapes, fcn ); // $ExpectType void - bternary3d( [ x[ 0 ][ 0 ], y, z, out ], [ [ shapes[ 0 ][ 2 ] ], shapes[ 1 ], shapes[ 2 ] , shapes[ 3 ] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ]; - - bternary3d( 'abc', shapes, fcn ); // $ExpectError - bternary3d( 3.14, shapes, fcn ); // $ExpectError - bternary3d( true, shapes, fcn ); // $ExpectError - bternary3d( false, shapes, fcn ); // $ExpectError - bternary3d( null, shapes, fcn ); // $ExpectError - bternary3d( [ '1' ], shapes, fcn ); // $ExpectError - bternary3d( {}, shapes, fcn ); // $ExpectError - bternary3d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - bternary3d( [ x, y, z, out ], 'abc', fcn ); // $ExpectError - bternary3d( [ x, y, z, out ], 3.14, fcn ); // $ExpectError - bternary3d( [ x, y, z, out ], true, fcn ); // $ExpectError - bternary3d( [ x, y, z, out ], false, fcn ); // $ExpectError - bternary3d( [ x, y, z, out ], null, fcn ); // $ExpectError - bternary3d( [ x, y, z, out ], [ '1' ], fcn ); // $ExpectError - bternary3d( [ x, y, z, out ], {}, fcn ); // $ExpectError - bternary3d( [ x, y, z, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ]; - - bternary3d( [ x, y, z, out ], shapes, 'abc' ); // $ExpectError - bternary3d( [ x, y, z, out ], shapes, 3.14 ); // $ExpectError - bternary3d( [ x, y, z, out ], shapes, true ); // $ExpectError - bternary3d( [ x, y, z, out ], shapes, false ); // $ExpectError - bternary3d( [ x, y, z, out ], shapes, null ); // $ExpectError - bternary3d( [ x, y, z, out ], shapes, [ '1' ] ); // $ExpectError - bternary3d( [ x, y, z, out ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ]; - - bternary3d(); // $ExpectError - bternary3d( [ x, y, z, out ] ); // $ExpectError - bternary3d( [ x, y, z, out ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-ternary3d/examples/index.js b/base/broadcasted-ternary3d/examples/index.js deleted file mode 100644 index 3f8007d8e..000000000 --- a/base/broadcasted-ternary3d/examples/index.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var bternary3d = require( './../lib' ); - -var shapes = [ - [ 1, 3, 1 ], - [ 3, 1, 1 ], - [ 1, 1, 3 ], - [ 3, 3, 3 ] -]; - -var x = filled3dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled3dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros3d( shapes[ 3 ] ); -console.log( out ); - -bternary3d( [ x, y, z, out ], shapes, add ); -console.log( out ); diff --git a/base/broadcasted-ternary3d/lib/index.js b/base/broadcasted-ternary3d/lib/index.js deleted file mode 100644 index 5bd70629b..000000000 --- a/base/broadcasted-ternary3d/lib/index.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -/** -* Apply a ternary callback to elements in three broadcasted input arrays and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-ternary3d -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); -* var bternary3d = require( '@stdlib/array/base/broadcasted-ternary3d' ); -* -* var shapes = [ -* [ 1, 2, 1 ], -* [ 2, 1, 1 ], -* [ 1, 1, 2 ], -* [ 2, 2, 2 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = ones3d( shapes[ 1 ] ); -* var z = ones3d( shapes[ 2 ] ); -* var out = zeros3d( shapes[ 3 ] ); -* -* bternary3d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] , [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-ternary3d/lib/main.js b/base/broadcasted-ternary3d/lib/main.js deleted file mode 100644 index e17a61b8e..000000000 --- a/base/broadcasted-ternary3d/lib/main.js +++ /dev/null @@ -1,166 +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. -*/ - -'use strict'; - -// MODULES // - -var broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a three-dimensional nested output array. -* -* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - ternary callback -* @returns {void} -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); -* -* var shapes = [ -* [ 1, 2, 1 ], -* [ 2, 1, 1 ], -* [ 1, 1, 2 ], -* [ 2, 2, 2 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = ones3d( shapes[ 1 ] ); -* var z = ones3d( shapes[ 2 ] ); -* var out = zeros3d( shapes[ 3 ] ); -* -* bternary3d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] , [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] -*/ -function bternary3d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dx2; - var dy0; - var dy1; - var dy2; - var dz0; - var dz1; - var dz2; - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var j0; - var j1; - var j2; - var k0; - var k1; - var k2; - var m0; - var m1; - var m2; - var x0; - var x1; - var y0; - var y1; - var z0; - var z1; - var sh; - var st; - var w0; - var w1; - var o; - var x; - var y; - var z; - var w; - - sh = shapes[ 3 ]; - S0 = sh[ 2 ]; - S1 = sh[ 1 ]; - S2 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 2 ]; - dx1 = st[ 1 ]; - dx2 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 2 ]; - dy1 = st[ 1 ]; - dy2 = st[ 0 ]; - - o = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh ); - z = o.data; - st = o.strides; - dz0 = st[ 2 ]; - dz1 = st[ 1 ]; - dz2 = st[ 0 ]; - - w = arrays[ 3 ]; - j2 = 0; - k2 = 0; - m2 = 0; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - k1 = 0; - m1 = 0; - x1 = x[ j2 ]; - y1 = y[ k2 ]; - z1 = z[ m2 ]; - w1 = w[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - m0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ k1 ]; - z0 = z1[ m1 ]; - w0 = w1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - w0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] ); - j0 += dx0; - k0 += dy0; - m0 += dz0; - } - j1 += dx1; - k1 += dy1; - m1 += dz1; - } - j2 += dx2; - k2 += dy2; - m2 += dz2; - } -} - - -// EXPORTS // - -module.exports = bternary3d; diff --git a/base/broadcasted-ternary3d/package.json b/base/broadcasted-ternary3d/package.json deleted file mode 100644 index 774888ec2..000000000 --- a/base/broadcasted-ternary3d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-ternary3d", - "version": "0.0.0", - "description": "Apply a ternary callback to elements in three broadcasted input arrays and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "binary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-ternary3d/test/test.js b/base/broadcasted-ternary3d/test/test.js deleted file mode 100644 index c07e967b5..000000000 --- a/base/broadcasted-ternary3d/test/test.js +++ /dev/null @@ -1,266 +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. -*/ -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros3d = require( './../../../base/zeros3d' ); -var bternary3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bternary3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 2 ], - [ 2, 1 ], - [ 2, 1, 2 ], - [ 2, 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ 3.0 ], - [ 4.0 ] - ]; - z = [ - [ - [ 2.0, 3.0 ] - ], - [ - [ 4.0, 4.0 ] - ] - ]; - w = zeros3d( shapes[ 3 ] ); - - expected = [ - [ - [ 6.0, 8.0 ], - [ 7.0, 9.0 ] - ], - [ - [ 8.0, 9.0 ], - [ 9.0, 10.0 ] - ] - ]; - bternary3d( [ x, y, z, w ], shapes, add ); - t.deepEqual( w, expected, 'returns expected value' ); - - shapes = [ - [ 1, 2 ], - [ 2 ], - [ 1, 1, 1 ], - [ 2, 2, 2 ] - ]; - x = [ - [ 1.0, 2.0 ] - ]; - y = [ 3.0, 4.0 ]; - z = [ - [ - [ 5.0 ] - ] - ]; - w = zeros3d( shapes[ 3 ] ); - - expected = [ - [ - [ 9.0, 11.0 ], - [ 9.0, 11.0 ] - ], - [ - [ 9.0, 11.0 ], - [ 9.0, 11.0 ] - ] - ]; - bternary3d( [ x, y, z, w ], shapes, add ); - t.deepEqual( w, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2, 2 ], - [ 2, 2, 2 ], - [ 2, 2, 2 ], - [ 2, 2, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - z = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - w = zeros3d( shapes[ 3 ] ); - - expected = [ - [ - [ 3.0, 6.0 ], - [ 9.0, 12.0 ] - ], - [ - [ 3.0, 6.0 ], - [ 9.0, 12.0 ] - ] - ]; - bternary3d( [ x, y, z, w ], shapes, add ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 0, 2, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = zeros3d( [ 2, 2, 2 ] ); - - expected = zeros3d( [ 2, 2, 2 ] ); - bternary3d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 0, 2 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = zeros3d( [ 2, 2, 2 ] ); - - expected = zeros3d( [ 2, 2, 2 ] ); - bternary3d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 1, 2, 2 ], - [ 2, 2, 0 ] - ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = x; - z = x; - w = zeros3d( [ 2, 2, 2 ] ); - - expected = zeros3d( [ 2, 2, 2 ] ); - bternary3d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-ternary4d/README.md b/base/broadcasted-ternary4d/README.md deleted file mode 100644 index 861a36221..000000000 --- a/base/broadcasted-ternary4d/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# bternary4d - -> Apply a ternary callback to elements in three [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bternary4d = require( '@stdlib/array/base/broadcasted-ternary4d' ); -``` - -#### bternary4d( arrays, shapes, fcn ) - -Applies a ternary callback to elements in three [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assigns results to elements in a four-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); - -var x = [ [ [ 1.0 ] ] ]; -var y = [ [ [ 2.0, 3.0 ] ] ]; -var z = [ [ [ [ 4.0, 5.0 ] ] ] ]; -var out = zeros4d( [ 1, 1, 2, 2 ] ); - -var shapes = [ - [ 1, 1, 1 ], - [ 1, 1, 2 ], - [ 1, 1, 1, 2 ], - [ 1, 1, 2, 2 ] -]; - -bternary4d( [ x, y, z, out ], shapes, add ); -// out => [ [ [ [ 7.0, 9.0 ], [ 7.0, 9.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing three input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: ternary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var bternary4d = require( '@stdlib/array/base/broadcasted-ternary4d' ); - -var shapes = [ - [ 1, 1, 1, 3 ], - [ 1, 1, 3, 1 ], - [ 1, 1, 3 ], - [ 1, 1, 3, 3 ] -]; - -var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros4d( shapes[ 3 ] ); -console.log( out ); - -bternary4d( [ x, y, z, out ], shapes, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-ternary4d/benchmark/benchmark.js b/base/broadcasted-ternary4d/benchmark/benchmark.js deleted file mode 100644 index 3a344c2af..000000000 --- a/base/broadcasted-ternary4d/benchmark/benchmark.js +++ /dev/null @@ -1,133 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bternary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, shape[ 2 ], 1 ], - [ shape[ 0 ], 1, 1, 1 ], - [ 1, shape[ 1 ], 1, 1 ], - shape - ]; - x = filled4dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled4dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = filled4dBy( shapes[ 2 ], uniform(-100.0, 100.0 ) ); - w = zeros4d( shapes[ 3 ] ); - - arrays = [ x, y, z, w ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bternary4d( arrays, shapes, add ); - i3 = i % shapes[ 1 ][ 0 ]; - i2 = i % shapes[ 1 ][ 1 ]; - i1 = i % shapes[ 1 ][ 2 ]; - i0 = i % shapes[ 1 ][ 3 ]; - if ( isnan( arrays[ 3 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shapes[ 1 ][ 0 ]; - i2 = i % shapes[ 1 ][ 1 ]; - i1 = i % shapes[ 1 ][ 2 ]; - i0 = i % shapes[ 1 ][ 3 ]; - if ( isnan( arrays[ 3 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0 / 4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg + '::equidimensional:size=' + numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-ternary4d/docs/repl.txt b/base/broadcasted-ternary4d/docs/repl.txt deleted file mode 100644 index 5b4fdd3fa..000000000 --- a/base/broadcasted-ternary4d/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a ternary callback to elements in three broadcasted input arrays and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing three input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Ternary callback. - - Examples - -------- - > function fcn( x, y, z ) { return x + y + z }; - > var x = [ [ [ 1.0 ] ] ]; - > var y = [ [ [ 2.0, 3.0 ] ] ]; - > var z = [ [ [ [ 4.0, 5.0 ] ] ] ]; - > var out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shapes =[ [ 1, 1, 1 ], [ 1, 1, 2 ], [ 1, 1, 1, 2 ], [ 1, 1, 2, 2 ] ]; - > {{alias}}( [ x, y, z, out ], shapes, fcn ); - > out - [ [ [ [ 7.0, 9.0 ], [ 7.0, 9.0 ] ] ] ] - - See Also - -------- - diff --git a/base/broadcasted-ternary4d/docs/types/index.d.ts b/base/broadcasted-ternary4d/docs/types/index.d.ts deleted file mode 100644 index 011f1805b..000000000 --- a/base/broadcasted-ternary4d/docs/types/index.d.ts +++ /dev/null @@ -1,114 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D, Shape4D } from '@stdlib/types/ndarray'; - -/** -* Ternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @returns result -*/ -type Ternary = ( v1: T, v2: U, v3: V ) => W; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D | Array4D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D | Shape4D; - -/** -* Output array. -*/ -type OutputArray = Array4D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape4D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing three input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - ternary callback -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); -* -* var shapes = [ -* [ 1, 2, 1, 1 ], -* [ 2, 1, 1, 1 ], -* [ 1, 1, 2, 1 ], -* [ 2, 2, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = ones4d( shapes[ 2 ] ); -* var out = zeros4d( shapes[ 3 ] ); -* -* bternary4d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] -*/ -declare function bternary4d( arrays: InOutArrays, shapes: InOutShapes, fcn: Ternary ): void; - - -// EXPORTS // - -export = bternary4d; diff --git a/base/broadcasted-ternary4d/docs/types/test.ts b/base/broadcasted-ternary4d/docs/types/test.ts deleted file mode 100644 index 8300caef7..000000000 --- a/base/broadcasted-ternary4d/docs/types/test.ts +++ /dev/null @@ -1,110 +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. -*/ - -import bternary4d = require( './index' ); - -/** -* Ternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number ): number { - return x + y + z; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ] ]; - - bternary4d( [ x, y, z, out ], shapes, fcn ); // $ExpectType void - bternary4d( [ x[ 0 ][ 0 ][ 0 ], y, z, out ], [ [ shapes[ 0 ][ 2 ] ], shapes[ 1 ], shapes[ 2 ], shapes[ 3 ] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ] ]; - - bternary4d( 'abc', shapes, fcn ); // $ExpectError - bternary4d( 3.14, shapes, fcn ); // $ExpectError - bternary4d( true, shapes, fcn ); // $ExpectError - bternary4d( false, shapes, fcn ); // $ExpectError - bternary4d( null, shapes, fcn ); // $ExpectError - bternary4d( [ '1' ], shapes, fcn ); // $ExpectError - bternary4d( {}, shapes, fcn ); // $ExpectError - bternary4d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - bternary4d( [ x, y, z, out ], 'abc', fcn ); // $ExpectError - bternary4d( [ x, y, z, out ], 3.14, fcn ); // $ExpectError - bternary4d( [ x, y, z, out ], true, fcn ); // $ExpectError - bternary4d( [ x, y, z, out ], false, fcn ); // $ExpectError - bternary4d( [ x, y, z, out ], null, fcn ); // $ExpectError - bternary4d( [ x, y, z, out ], [ '1' ], fcn ); // $ExpectError - bternary4d( [ x, y, z, out ], {}, fcn ); // $ExpectError - bternary4d( [ x, y, z, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ] ]; - - bternary4d( [ x, y, z, out ], shapes, 'abc' ); // $ExpectError - bternary4d( [ x, y, z, out ], shapes, 3.14 ); // $ExpectError - bternary4d( [ x, y, z, out ], shapes, true ); // $ExpectError - bternary4d( [ x, y, z, out ], shapes, false ); // $ExpectError - bternary4d( [ x, y, z, out ], shapes, null ); // $ExpectError - bternary4d( [ x, y, z, out ], shapes, [ '1' ] ); // $ExpectError - bternary4d( [ x, y, z, out ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ], [ 2, 2, 2, 2 ] ]; - - bternary4d(); // $ExpectError - bternary4d( [ x, y, z, out ] ); // $ExpectError - bternary4d( [ x, y, z, out ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-ternary4d/examples/index.js b/base/broadcasted-ternary4d/examples/index.js deleted file mode 100644 index 01ff2d49f..000000000 --- a/base/broadcasted-ternary4d/examples/index.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var bternary4d = require( './../lib' ); - -var shapes = [ - [ 1, 3, 1, 1 ], - [ 3, 1, 1, 3 ], - [ 1, 1, 3, 1 ], - [ 3, 3, 3, 3 ] -]; - -var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros4d( shapes[ 3 ] ); -console.log( out ); - -bternary4d( [ x, y, z, out ], shapes, add ); -console.log( out ); diff --git a/base/broadcasted-ternary4d/lib/index.js b/base/broadcasted-ternary4d/lib/index.js deleted file mode 100644 index 5f5f86927..000000000 --- a/base/broadcasted-ternary4d/lib/index.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -/** -* Apply a ternary callback to elements in three broadcasted input arrays and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-ternary4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); -* var bternary4d = require( '@stdlib/array/base/broadcasted-ternary4d' ); -* -* var shapes = [ -* [ 1, 2, 1, 1 ], -* [ 2, 1, 1, 1 ], -* [ 1, 1, 2, 1 ], -* [ 2, 2, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = ones4d( shapes[ 2 ] ); -* var out = zeros4d( shapes[ 3 ] ); -* -* bternary3d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-ternary4d/lib/main.js b/base/broadcasted-ternary4d/lib/main.js deleted file mode 100644 index 98e8a316b..000000000 --- a/base/broadcasted-ternary4d/lib/main.js +++ /dev/null @@ -1,195 +0,0 @@ -/* eslint-disable max-statements */ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. -* -* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - ternary callback -* @returns {void} -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); -* -* var shapes = [ -* [ 1, 2, 1, 1 ], -* [ 2, 1, 1, 1 ], -* [ 1, 1, 2, 1 ], -* [ 2, 2, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = ones4d( shapes[ 1 ] ); -* var z = ones4d( shapes[ 2 ] ); -* var out = zeros4d( shapes[ 3 ] ); -* -* bternary4d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ], [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] -*/ -function bternary4d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dx2; - var dx3; - var dy0; - var dy1; - var dy2; - var dy3; - var dz0; - var dz1; - var dz2; - var dz3; - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var j0; - var j1; - var j2; - var j3; - var k0; - var k1; - var k2; - var k3; - var m0; - var m1; - var m2; - var m3; - var x0; - var x1; - var x2; - var y0; - var y1; - var y2; - var z0; - var z1; - var z2; - var sh; - var st; - var w0; - var w1; - var w2; - var o; - var x; - var y; - var z; - var w; - - sh = shapes[ 3 ]; - S0 = sh[ 3 ]; - S1 = sh[ 2 ]; - S2 = sh[ 1 ]; - S3 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 3 ]; - dx1 = st[ 2 ]; - dx2 = st[ 1 ]; - dx3 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 3 ]; - dy1 = st[ 2 ]; - dy2 = st[ 1 ]; - dy3 = st[ 0 ]; - - o = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh ); - z = o.data; - st = o.strides; - dz0 = st[ 3 ]; - dz1 = st[ 2 ]; - dz2 = st[ 1 ]; - dz3 = st[ 0 ]; - - w = arrays[ 3 ]; - j3 = 0; - k3 = 0; - m3 = 0; - for ( i3 = 0; i3 < S3; i3++ ) { - j2 = 0; - k2 = 0; - m2 = 0; - x2 = x[ j3 ]; - y2 = y[ k3 ]; - z2 = z[ m3 ]; - w2 = w[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - k1 = 0; - m1 = 0; - x1 = x2[ j2 ]; - y1 = y2[ k2 ]; - z1 = z2[ m2 ]; - w1 = w2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - m0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ k1 ]; - z0 = z1[ m1 ]; - w0 = w1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - w0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] ); - j0 += dx0; - k0 += dy0; - m0 += dz0; - } - j1 += dx1; - k1 += dy1; - m1 += dz1; - } - j2 += dx2; - k2 += dy2; - m2 += dz2; - } - j3 += dx3; - k3 += dy3; - m3 += dz3; - } -} - - -// EXPORTS // - -module.exports = bternary4d; diff --git a/base/broadcasted-ternary4d/package.json b/base/broadcasted-ternary4d/package.json deleted file mode 100644 index 7d7322358..000000000 --- a/base/broadcasted-ternary4d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-ternary4d", - "version": "0.0.0", - "description": "Apply a ternary callback to elements in three broadcasted input arrays and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "binary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-ternary4d/test/test.js b/base/broadcasted-ternary4d/test/test.js deleted file mode 100644 index 9676cb8c0..000000000 --- a/base/broadcasted-ternary4d/test/test.js +++ /dev/null @@ -1,298 +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. -*/ -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros4d = require( './../../../base/zeros4d' ); -var bternary4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bternary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 2 ], - [ 2, 1, 1, 1 ], - [ 2, 1, 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ - [ [ [ 3.0 ] ] ], - [ [ [ 4.0 ] ] ] - ]; - z = [ [ [ 5.0, 6.0 ] ], [ [ 7.0, 8.0 ] ] ]; - w = zeros4d( shapes[ 3 ] ); - - expected = [ - [ - [ [ 9.0, 11.0 ], [ 9.0, 11.0 ] ], - [ [ 11.0, 13.0 ], [ 11.0, 13.0 ] ] - ], - [ - [ [ 10.0, 12.0 ], [ 10.0, 12.0 ] ], - [ [ 12.0, 14.0 ], [ 12.0, 14.0 ] ] - ] - ]; - bternary4d( [ x, y, z, w ], shapes, add ); - t.deepEqual( w, expected, 'returns expected value' ); - - shapes = [ - [ 2 ], - [ 1, 2 ], - [ 2, 1, 1, 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ 1.0, 2.0 ]; - y = [ [ 3.0, 4.0 ] ]; - z = [ [ [ [ 5.0, 6.0 ] ] ], [ [ [ 7.0, 8.0 ] ] ] ]; - w = zeros4d( shapes[ 3 ] ); - - expected = [ - [ - [ [ 9.0, 12.0 ], [ 9.0, 12.0 ] ], - [ [ 9.0, 12.0 ], [ 9.0, 12.0 ] ] - - ], - [ - [ [ 11.0, 14.0 ], [ 11.0, 14.0 ] ], - [ [ 11.0, 14.0 ], [ 11.0, 14.0 ] ] - ] - ]; - bternary4d( [ x, y, z, w ], shapes, add ); - t.deepEqual( w, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ - [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] - ], - [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] - ] - ]; - - y = [ - [ - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ], - [ - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ] - ]; - z = [ - [ - [ [ 9.0, 10.0 ], [ 10.0, 12.0 ] ], - [ [ 9.0, 10.0 ], [ 10.0, 12.0 ] ] - ], - [ - [ [ 9.0, 10.0 ], [ 10.0, 12.0 ] ], - [ [ 9.0, 10.0 ], [ 10.0, 12.0 ] ] - ] - ]; - w = zeros4d( shapes[ 3 ] ); - - expected = [ - [ - [ [ 15.0, 18.0 ], [ 20.0, 24.0 ] ], - [ [ 15.0, 18.0 ], [ 20.0, 24.0 ] ] - ], - [ - [ [ 15.0, 18.0 ], [ 20.0, 24.0 ] ], - [ [ 15.0, 18.0 ], [ 20.0, 24.0 ] ] - ] - ]; - bternary4d( [ x, y, z, w ], shapes, add ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 0, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = x; - w = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bternary4d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 2, 0, 2, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = x; - w = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bternary4d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 2, 2, 0, 2 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = x; - w = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bternary4d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a forth element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 1, 1, 2, 2 ], - [ 2, 2, 2, 0 ] - ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = x; - z = x; - w = zeros4d( [ 2, 2, 2, 2 ] ); - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - bternary4d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-ternary5d/README.md b/base/broadcasted-ternary5d/README.md deleted file mode 100644 index c74e6114a..000000000 --- a/base/broadcasted-ternary5d/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# bternary5d - -> Apply a ternary callback to elements in three [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bternary5d = require( '@stdlib/array/base/broadcasted-ternary5d' ); -``` - -#### bternary5d( arrays, shapes, fcn ) - -Applies a ternary callback to elements in three [broadcasted][@stdlib/array/base/broadcast-array] nested input arrays and assigns results to elements in a five-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); - -var x = [ [ [ 1.0, 2.0 ] ] ]; -var y = [ [ [ 3.0 ], [ 4.0 ] ] ]; -var z = [ [ [ [ 4.0, 5.0 ] ], [ [ 4.0, 5.0 ] ] ] ]; -var out = zeros5d( [ 1, 1, 2, 2 ] ); - -var shapes = [ - [ 1, 1, 2 ], - [ 1, 2, 1 ], - [ 1, 2, 1, 2 ], - [ 1, 1, 2, 2, 2 ] -]; - -bternary5d( [ x, y, z, out ], shapes, add ); -// out => [ [ [ [ [ 8.0, 10.0 ], [ 9.0, 11.0 ] ], [ [ 8.0, 10.0 ], [ 9.0, 11.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing three input nested arrays and one output nested array. -- **shapes**: array shapes. -- **fcn**: ternary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var bternary5d = require( '@stdlib/array/base/broadcasted-ternary5d' ); - -var shapes = [ - [ 1, 1, 1, 1, 3 ], - [ 1, 1, 3, 1, 1 ], - [ 1, 1, 1, 3, 1 ], - [ 1, 1, 3, 3, 3 ] -]; - -var x = filled5dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled5dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros5d( shapes[ 3 ] ); -console.log( out ); - -bternary5d( [ x, y, z, out ], shapes, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-ternary5d/benchmark/benchmark.js b/base/broadcasted-ternary5d/benchmark/benchmark.js deleted file mode 100644 index 7bd7e047c..000000000 --- a/base/broadcasted-ternary5d/benchmark/benchmark.js +++ /dev/null @@ -1,136 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bternary5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ shape[ 0 ], 1, 1, 1, 1 ], - [ 1, 1, 1, 1, shape[ 1 ] ], - [ 1, 1, shape[ 2 ], 1, 1 ], - shape - ]; - x = filled5dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = filled5dBy( shapes[ 1 ], uniform( -100.0, 100.0 ) ); - z = filled5dBy( shapes[ 2 ], uniform( -100.0, 100.0 ) ); - w = zeros5d( shapes[ 3 ] ); - - arrays = [ x, y, z, w ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bternary5d( arrays, shapes, add ); - i4 = i % shapes[ 1 ][ 0 ]; - i3 = i % shapes[ 1 ][ 1 ]; - i2 = i % shapes[ 1 ][ 2 ]; - i1 = i % shapes[ 1 ][ 3 ]; - i0 = i % shapes[ 1 ][ 4 ]; - if ( isnan( arrays[ 3 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shapes[ 1 ][ 0 ]; - i3 = i % shapes[ 1 ][ 1 ]; - i2 = i % shapes[ 1 ][ 2 ]; - i1 = i % shapes[ 1 ][ 3 ]; - i0 = i % shapes[ 1 ][ 4 ]; - if ( isnan(arrays[ 3 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0 / 5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg + '::equidimensional:size=' + numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-ternary5d/docs/repl.txt b/base/broadcasted-ternary5d/docs/repl.txt deleted file mode 100644 index 2e26b1901..000000000 --- a/base/broadcasted-ternary5d/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a ternary callback to elements in three broadcasted input arrays and - assigns results to elements in a five-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing three input nested arrays and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Ternary callback. - - Examples - -------- - > function fcn( x, y, z ) { return x + y + z }; - > var x = [ 1.0 ]; - > var y = [ [ 2.0, 2.0 ], [ 3.0, 3.0 ] ]; - > var z = [ [ [ [ [ 2.0 ], [ 3.0 ] ] ] ] ]; - > var out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shapes = [ [ 1 ], [ 2, 2 ], [ 1, 1, 1, 2, 1 ], [ 1, 1, 1, 2, 2 ] ]; - > {{alias}}( [ x, y, z, out ], shapes, fcn ); - > out - [ [ [ [ [ 5.0, 5.0 ], [ 7.0, 7.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/broadcasted-ternary5d/docs/types/index.d.ts b/base/broadcasted-ternary5d/docs/types/index.d.ts deleted file mode 100644 index e0e301dbc..000000000 --- a/base/broadcasted-ternary5d/docs/types/index.d.ts +++ /dev/null @@ -1,114 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D, Array5D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D, Shape4D, Shape5D } from '@stdlib/types/ndarray'; - -/** -* Ternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @returns result -*/ -type Ternary = ( v1: T, v2: U, v3: V ) => W; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D | Array4D | Array5D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D | Shape4D | Shape5D; - -/** -* Output array. -*/ -type OutputArray = Array5D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape5D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - InputArray, - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - InputArrayShape, - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The input array shapes must be broadcast compatible with the output array shape. -* -* @param arrays - array containing three input nested arrays and one output nested array -* @param shapes - array shapes -* @param fcn - ternary callback -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); -* var bternary5d = require( '@stdlib/array/base/broadcasted-ternary5d' ); -* var shapes = [ -* [ 1, 2, 1, 1, 1 ], -* [ 2, 1, 1, 1, 1 ], -* [ 1, 1, 1, 1, 1 ], -* [ 2, 2, 1, 1, 1 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = ones5d( shapes[ 1 ] ); -* var z = ones5d( shapes[ 2 ] ); -* var out = zeros5d( shapes[ 3 ] ); -* -* bternary5d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 3 ] ] ], [ [ [ 3 ] ] ] ], [ [ [ 3 ] ] ], [ [ [ 3 ] ] ] ] ] -*/ -declare function bternary5d( arrays: InOutArrays, shapes: InOutShapes, fcn: Ternary ): void; - - -// EXPORTS // - -export = bternary5d; diff --git a/base/broadcasted-ternary5d/docs/types/test.ts b/base/broadcasted-ternary5d/docs/types/test.ts deleted file mode 100644 index 823403ac2..000000000 --- a/base/broadcasted-ternary5d/docs/types/test.ts +++ /dev/null @@ -1,110 +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. -*/ - -import bternary5d = require( './index' ); - -/** -* Ternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number ): number { - return x + y + z; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 2, 2, 2, 2, 2 ] ]; - - bternary5d( [ x, y, z, out ], shapes, fcn ); // $ExpectType void - bternary5d( [ x[0][0][0][0], y, z, out ], [ [ shapes[0][4] ], shapes[1], shapes[2], shapes[3] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 2, 2, 2, 2, 2 ] ]; - - bternary5d( 'abc', shapes, fcn ); // $ExpectError - bternary5d( 3.14, shapes, fcn ); // $ExpectError - bternary5d( true, shapes, fcn ); // $ExpectError - bternary5d( false, shapes, fcn ); // $ExpectError - bternary5d( null, shapes, fcn ); // $ExpectError - bternary5d( [ '1' ], shapes, fcn ); // $ExpectError - bternary5d( {}, shapes, fcn ); // $ExpectError - bternary5d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - bternary5d( [x, y, z, out ], 'abc', fcn ); // $ExpectError - bternary5d( [x, y, z, out ], 3.14, fcn ); // $ExpectError - bternary5d( [x, y, z, out ], true, fcn ); // $ExpectError - bternary5d( [x, y, z, out ], false, fcn ); // $ExpectError - bternary5d( [x, y, z, out ], null, fcn ); // $ExpectError - bternary5d( [ x, y, z, out ], [ '1' ], fcn ); // $ExpectError - bternary5d( [ x, y, z, out ], {}, fcn ); // $ExpectError - bternary5d( [ x, y, z, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 2, 2, 2, 2, 2 ] ]; - - bternary5d( [ x, y, z, out ], shapes, 'abc' ); // $ExpectError - bternary5d( [ x, y, z, out ], shapes, 3.14 ); // $ExpectError - bternary5d( [ x, y, z, out ], shapes, true ); // $ExpectError - bternary5d( [ x, y, z, out ], shapes, false ); // $ExpectError - bternary5d( [ x, y, z, out ], shapes, null ); // $ExpectError - bternary5d( [ x, y, z, out ], shapes, [ '1' ] ); // $ExpectError - bternary5d( [ x, y, z, out ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array, Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ], [ 2, 2, 2, 2, 2 ] ]; - - bternary5d(); // $ExpectError - bternary5d( [ x, y, z, out ] ); // $ExpectError - bternary5d( [ x, y, z, out ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-ternary5d/examples/index.js b/base/broadcasted-ternary5d/examples/index.js deleted file mode 100644 index 732f7bf0c..000000000 --- a/base/broadcasted-ternary5d/examples/index.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var bternary5d = require( './../lib' ); - -var shapes = [ - [ 1, 1, 1, 1, 3 ], - [ 1, 1, 3, 1, 1 ], - [ 1, 1, 1, 3, 1 ], - [ 1, 1, 3, 3, 3 ] -]; - -var x = filled5dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shapes[ 1 ], discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled5dBy( shapes[ 2 ], discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros5d( shapes[ 3 ] ); -console.log( out ); - -bternary5d( [ x, y, z, out ], shapes, add ); -console.log( out ); diff --git a/base/broadcasted-ternary5d/lib/index.js b/base/broadcasted-ternary5d/lib/index.js deleted file mode 100644 index 33a2ff3a4..000000000 --- a/base/broadcasted-ternary5d/lib/index.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -/** -* Apply a ternary callback to elements in three broadcasted input arrays and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-ternary5d -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); -* var bternary5d = require( '@stdlib/array/base/broadcasted-ternary5d' ); -* -* var shapes = [ -* [ 1, 2, 1, 1, 1 ], -* [ 2, 1, 1, 1, 1 ], -* [ 1, 1, 1, 1, 1 ], -* [ 2, 2, 1, 1, 1 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = ones5d( shapes[ 1 ] ); -* var z = ones5d( shapes[ 2 ] ); -* var out = zeros5d( shapes[ 3 ] ); -* -* bternary5d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 3.0 ] ] ], [ [ [ 3.0 ] ] ] ], [ [ [ [ 3.0 ] ] ], [ [ [ 3.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-ternary5d/lib/main.js b/base/broadcasted-ternary5d/lib/main.js deleted file mode 100644 index cb95c7afe..000000000 --- a/base/broadcasted-ternary5d/lib/main.js +++ /dev/null @@ -1,224 +0,0 @@ -/* eslint-disable max-statements */ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a five-dimensional nested output array. -* -* @param {ArrayLikeObject} arrays - array-like object containing three input nested arrays and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - ternary callback -* @returns {void} -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add3' ); - -* var shapes = [ -* [ 1, 2, 1, 1, 1 ], -* [ 2, 1, 1, 1, 1 ], -* [ 1, 1, 1, 1, 1 ], -* [ 2, 2, 1, 1, 1 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = ones5d( shapes[ 1 ] ); -* var z = ones5d( shapes[ 2 ] ); -* var out = zeros5d( shapes[ 3 ] ); -* -* bternary5d( [ x, y, z, out ], shapes, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 3.0 ] ] ], [ [ [ 3.0 ] ] ] ], [ [ [ [ 3.0 ] ] ], [ [ [ 3.0 ] ] ] ] ] -*/ -function bternary5d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dx2; - var dx3; - var dx4; - var dy0; - var dy1; - var dy2; - var dy3; - var dy4; - var dz0; - var dz1; - var dz2; - var dz3; - var dz4; - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var j0; - var j1; - var j2; - var j3; - var j4; - var k0; - var k1; - var k2; - var k3; - var k4; - var m0; - var m1; - var m2; - var m3; - var m4; - var x0; - var x1; - var x2; - var x3; - var y0; - var y1; - var y2; - var y3; - var z0; - var z1; - var z2; - var z3; - var sh; - var st; - var w0; - var w1; - var w2; - var w3; - var o; - var x; - var y; - var z; - var w; - - sh = shapes[ 3 ]; - S0 = sh[ 4 ]; - S1 = sh[ 3 ]; - S2 = sh[ 2 ]; - S3 = sh[ 1 ]; - S4 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 4 ]; - dx1 = st[ 3 ]; - dx2 = st[ 2 ]; - dx3 = st[ 1 ]; - dx4 = st[ 0 ]; - - o = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh ); - y = o.data; - st = o.strides; - dy0 = st[ 4 ]; - dy1 = st[ 3 ]; - dy2 = st[ 2 ]; - dy3 = st[ 1 ]; - dy4 = st[ 0 ]; - - o = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh ); - z = o.data; - st = o.strides; - dz0 = st[ 4 ]; - dz1 = st[ 3 ]; - dz2 = st[ 2 ]; - dz3 = st[ 1 ]; - dz4 = st[ 0 ]; - - w = arrays[ 3 ]; - j4 = 0; - k4 = 0; - m4 = 0; - - for ( i4 = 0; i4 < S4; i4++ ) { - j3 = 0; - k3 = 0; - m3 = 0; - x3 = x[ j4 ]; - y3 = y[ k4 ]; - z3 = z[ m4 ]; - w3 = w[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - j2 = 0; - k2 = 0; - m2 = 0; - x2 = x3[ j3 ]; - y2 = y3[ k3 ]; - z2 = z3[ m3 ]; - w2 = w3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - k1 = 0; - m1 = 0; - x1 = x2[ j2 ]; - y1 = y2[ k2 ]; - z1 = z2[ m2 ]; - w1 = w2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - k0 = 0; - m0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ k1 ]; - z0 = z1[ m1 ]; - w0 = w1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - w0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] ); - j0 += dx0; - k0 += dy0; - m0 += dz0; - } - j1 += dx1; - k1 += dy1; - m1 += dz1; - } - j2 += dx2; - k2 += dy2; - m2 += dz2; - } - j3 += dx3; - k3 += dy3; - m3 += dz3; - } - j4 += dx4; - k4 += dy4; - m4 += dz4; - } -} - - -// EXPORTS // - -module.exports = bternary5d; diff --git a/base/broadcasted-ternary5d/package.json b/base/broadcasted-ternary5d/package.json deleted file mode 100644 index 085288ffb..000000000 --- a/base/broadcasted-ternary5d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-ternary5d", - "version": "0.0.0", - "description": "Apply a ternary callback to elements in three broadcasted input arrays and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "binary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-ternary5d/test/test.js b/base/broadcasted-ternary5d/test/test.js deleted file mode 100644 index abedb02dd..000000000 --- a/base/broadcasted-ternary5d/test/test.js +++ /dev/null @@ -1,329 +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. -*/ -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros5d = require( './../../../base/zeros5d' ); -var bternary5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function ', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bternary5d, 'function', 'main export is a function' ); - t.end(); -} ); - -tape( 'the function applies a provided callback to broadcasted input arrays and assigns results to a nested output array ', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 2, 1, 1, 1 ], - [ 2, 1, 1, 2 ], - [ 1, 1, 2, 1 ], - [ 2, 2, 2, 2, 2 ] - ]; - - x = [ [ [ [ [ 1.0 ] ] ], [ [ [ 2.0 ] ] ] ] ]; - y = [ [ [ [ 3.0, 4.0 ] ] ], [ [ [ 4.0, 5.0 ] ] ] ]; - z = [ [ [ [ 6.0 ], [ 7.0 ] ] ] ]; - w = zeros5d( shapes[ 3 ] ); - - expected = [ - [ - [ - [ [ 10.0, 11.0 ], [ 11.0, 12.0 ] ], - [ [ 10.0, 11.0 ], [ 11.0, 12.0 ] ] - ], - [ - [ [ 12.0, 13.0 ], [ 13.0, 14.0 ] ], - [ [ 12.0, 13.0 ], [ 13.0, 14.0 ] ] - ] - ], - [ - [ - [ [ 10.0, 11.0 ], [ 11.0, 12.0 ] ], - [ [ 10.0, 11.0 ], [ 11.0, 12.0 ] ] - ], - [ - [ [ 12.0, 13.0 ], [ 13.0, 14.0 ] ], - [ [ 12.0, 13.0 ], [ 13.0, 14.0 ] ] - ] - ] - ]; - bternary5d( [ x, y, z, w ], shapes, add ); - t.deepEqual( w, expected, 'returns expected value' ); - - shapes = [ - [ 1 ], - [ 2, 1, 1 ], - [ 2, 1, 2, 1, 1 ], - [ 2, 2, 2, 1, 1 ] - ]; - x = [ 1.0 ]; - y = [ [ [ 2.0 ] ], [ [ 3.0 ] ] ]; - z = [ [ [ [ [ 5.0 ] ], [ [ 6.0 ] ] ] ], [ [ [ [ 7.0 ] ], [ [ 8.0 ] ] ] ] ]; - w = zeros5d( shapes[ 3 ] ); - - expected = [ - [ [ [ [ 8.0 ] ], [ [ 10.0 ] ] ], [ [ [ 8.0 ] ], [ [ 10.0 ] ] ] ], - [ [ [ [ 10.0 ] ], [ [ 12.0 ] ] ], [ [ [ 10.0 ] ], [ [ 12.0 ] ] ] ] - ]; - bternary5d( [ x, y, z, w ], shapes, add ); - t.deepEqual( w, expected, 'returns expected value' ); - - // Same shapes: - shapes = [ - [ 2, 2, 2, 1, 1 ], - [ 2, 2, 2, 1, 1 ], - [ 2, 2, 2, 1, 1 ], - [ 2, 2, 2, 1, 1 ] - ]; - x = [ - [ - [ [ [ 1.0 ] ], [ [ 1.0 ] ] ], - [ [ [ 1.0 ] ], [ [ 1.0 ] ] ] - ], - [ - [ [ [ 1.0 ] ], [ [ 1.0 ] ] ], - [ [ [ 1.0 ] ], [ [ 1.0 ] ] ] - ] - ]; - y = x; - z = x; - w = zeros5d( shapes[ 3 ] ); - - expected = [ - [ - [ [ [ 3.0 ] ], [ [ 3.0 ] ] ], - [ [ [ 3.0 ] ], [ [ 3.0 ] ] ] - ], - [ - [ [ [ 3.0 ] ], [ [ 3.0 ] ] ], - [ [ [ 3.0 ] ], [ [ 3.0 ] ] ] - ] - ]; - bternary5d( [ x, y, z, w ], shapes, add ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); -} ); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero ', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 0, 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - z = x; - w = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bternary5d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -} ); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero ', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 2, 0, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - z = x; - w = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bternary5d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -} ); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero ', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 2, 2, 0, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - z = x; - w = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bternary5d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -} ); - -tape( 'the function does not invoke a provided callback if provided an output shape having a fourth element equal to zero ', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 2, 2, 2, 0, 2 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - z = x; - w = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bternary5d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -} ); - -tape( 'the function does not invoke a provided callback if provided an output shape having a fifth element equal to zero ', function test( t ) { - var expected; - var shapes; - var x; - var y; - var z; - var w; - - shapes = [ - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 1, 1, 1, 2, 2 ], - [ 2, 2, 2, 2, 0 ] - ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = x; - z = x; - w = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bternary5d( [ x, y, z, w ], shapes, clbk ); - t.deepEqual( w, expected, 'returns expected value' ); - - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -} ); diff --git a/base/broadcasted-unary2d/README.md b/base/broadcasted-unary2d/README.md deleted file mode 100644 index 8f56869b4..000000000 --- a/base/broadcasted-unary2d/README.md +++ /dev/null @@ -1,130 +0,0 @@ - - -# bunary2d - -> Apply a unary callback to elements in a [broadcasted][@stdlib/array/base/broadcast-array] nested input array and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bunary2d = require( '@stdlib/array/base/broadcasted-unary2d' ); -``` - -#### bunary2d( arrays, shapes, fcn ) - -Applies a unary callback to elements in a [broadcasted][@stdlib/array/base/broadcast-array] nested input array and assigns results to elements in a two-dimensional nested output array. - -```javascript -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ -1.0, -2.0 ] ]; -var y = zeros2d( [ 2, 2 ] ); - -var shapes = [ - [ 1, 2 ], - [ 2, 2 ] -]; - -// Compute the absolute values: -bunary2d( [ x, y ], shapes, abs ); -// y => [ [ 1.0, 2.0 ], [ 1.0, 2.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shapes**: array shapes. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var bunary2d = require( '@stdlib/array/base/broadcasted-unary2d' ); - -var shapes = [ - [ 1, 3 ], - [ 3, 3 ] -]; - -var x = filled2dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros2d( shapes[ 1 ] ); -console.log( y ); - -bunary2d( [ x, y ], shapes, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-unary2d/benchmark/benchmark.js b/base/broadcasted-unary2d/benchmark/benchmark.js deleted file mode 100644 index 2b4df9e05..000000000 --- a/base/broadcasted-unary2d/benchmark/benchmark.js +++ /dev/null @@ -1,121 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bunary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var x; - var y; - - shapes = [ - [ 1, shape[ 1 ] ], - shape - ]; - x = filled2dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = zeros2d( shapes[ 1 ] ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bunary2d( arrays, shapes, identity ); - i1 = i % shapes[ 1 ][ 0 ]; - i0 = i % shapes[ 1 ][ 1 ]; - if ( isnan( arrays[ 1 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shapes[ 1 ][ 0 ]; - i0 = i % shapes[ 1 ][ 1 ]; - if ( isnan( arrays[ 1 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-unary2d/docs/repl.txt b/base/broadcasted-unary2d/docs/repl.txt deleted file mode 100644 index 9f113237d..000000000 --- a/base/broadcasted-unary2d/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a unary callback to elements in a broadcasted nested input array and - assigns results to elements in a two-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ -1.0, -2.0 ]; - > var y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shapes = [ [ 2 ], [ 2, 2 ] ]; - > {{alias}}( [ x, y ], shapes, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ 1.0, 2.0 ], [ 1.0, 2.0 ] ] - - See Also - -------- - diff --git a/base/broadcasted-unary2d/docs/types/index.d.ts b/base/broadcasted-unary2d/docs/types/index.d.ts deleted file mode 100644 index b25c0f539..000000000 --- a/base/broadcasted-unary2d/docs/types/index.d.ts +++ /dev/null @@ -1,107 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D } from '@stdlib/types/array'; -import { Shape1D, Shape2D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D; - -/** -* Output array. -*/ -type OutputArray = Array2D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape2D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The input array shape must be broadcast compatible with the output array shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shapes - array shapes -* @param fcn - unary callback -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = zeros2d( shapes[ 1 ] ); -* -* bunary2d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -*/ -declare function bunary2d( arrays: InOutArrays, shapes: InOutShapes, fcn: Unary ): void; - - -// EXPORTS // - -export = bunary2d; diff --git a/base/broadcasted-unary2d/docs/types/test.ts b/base/broadcasted-unary2d/docs/types/test.ts deleted file mode 100644 index 4bc76af6f..000000000 --- a/base/broadcasted-unary2d/docs/types/test.ts +++ /dev/null @@ -1,100 +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. -*/ - -import bunary2d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array ] = [ [ 2, 2 ], [ 2, 2 ] ]; - - bunary2d( [ x, y ], shapes, fcn ); // $ExpectType void - bunary2d( [ x[ 0 ], y ], [ [ shapes[ 0 ][ 1 ] ], shapes[ 1 ] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array ] = [ [ 2, 2 ], [ 2, 2 ] ]; - - bunary2d( 'abc', shapes, fcn ); // $ExpectError - bunary2d( 3.14, shapes, fcn ); // $ExpectError - bunary2d( true, shapes, fcn ); // $ExpectError - bunary2d( false, shapes, fcn ); // $ExpectError - bunary2d( null, shapes, fcn ); // $ExpectError - bunary2d( [ '1' ], shapes, fcn ); // $ExpectError - bunary2d( {}, shapes, fcn ); // $ExpectError - bunary2d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - bunary2d( [ x, y ], 'abc', fcn ); // $ExpectError - bunary2d( [ x, y ], 3.14, fcn ); // $ExpectError - bunary2d( [ x, y ], true, fcn ); // $ExpectError - bunary2d( [ x, y ], false, fcn ); // $ExpectError - bunary2d( [ x, y ], null, fcn ); // $ExpectError - bunary2d( [ x, y ], [ '1' ], fcn ); // $ExpectError - bunary2d( [ x, y ], {}, fcn ); // $ExpectError - bunary2d( [ x, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array ] = [ [ 2, 2 ], [ 2, 2 ] ]; - - bunary2d( [ x, y ], shapes, 'abc' ); // $ExpectError - bunary2d( [ x, y ], shapes, 3.14 ); // $ExpectError - bunary2d( [ x, y ], shapes, true ); // $ExpectError - bunary2d( [ x, y ], shapes, false ); // $ExpectError - bunary2d( [ x, y ], shapes, null ); // $ExpectError - bunary2d( [ x, y ], shapes, [ '1' ] ); // $ExpectError - bunary2d( [ x, y ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - const shapes: [ Array, Array ] = [ [ 2, 2 ], [ 2, 2 ] ]; - - bunary2d(); // $ExpectError - bunary2d( [ x, y ] ); // $ExpectError - bunary2d( [ x, y ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-unary2d/examples/index.js b/base/broadcasted-unary2d/examples/index.js deleted file mode 100644 index 9ed71dfca..000000000 --- a/base/broadcasted-unary2d/examples/index.js +++ /dev/null @@ -1,39 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var bunary2d = require( './../lib' ); - -var shapes = [ - [ 1, 3 ], - [ 3, 3 ] -]; - -var x = filled2dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros2d( shapes[ 1 ] ); -console.log( y ); - -bunary2d( [ x, y ], shapes, abs ); -console.log( y ); diff --git a/base/broadcasted-unary2d/lib/index.js b/base/broadcasted-unary2d/lib/index.js deleted file mode 100644 index 56393e78e..000000000 --- a/base/broadcasted-unary2d/lib/index.js +++ /dev/null @@ -1,56 +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'; - -/** -* Apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-unary2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var bunary2d = require( '@stdlib/array/base/broadcasted-unary2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = zeros2d( shapes[ 1 ] ); -* -* bunary2d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-unary2d/lib/main.js b/base/broadcasted-unary2d/lib/main.js deleted file mode 100644 index 3865966d6..000000000 --- a/base/broadcasted-unary2d/lib/main.js +++ /dev/null @@ -1,104 +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 broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a two-dimensional nested output array. -* -* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 2 ], -* [ 2, 2 ] -* ]; -* -* var x = ones2d( shapes[ 0 ] ); -* var y = zeros2d( shapes[ 1 ] ); -* -* bunary2d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -*/ -function bunary2d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var S0; - var S1; - var i0; - var i1; - var j0; - var j1; - var x0; - var y0; - var sh; - var st; - var o; - var x; - var y; - - sh = shapes[ 1 ]; - S0 = sh[ 1 ]; - S1 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 1 ]; - dx1 = st[ 0 ]; - - y = arrays[ 1 ]; - - j1 = 0; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - x0 = x[ j1 ]; - y0 = y[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn( x0[ j0 ] ); - j0 += dx0; - } - j1 += dx1; - } -} - - -// EXPORTS // - -module.exports = bunary2d; diff --git a/base/broadcasted-unary2d/package.json b/base/broadcasted-unary2d/package.json deleted file mode 100644 index 8e3477897..000000000 --- a/base/broadcasted-unary2d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-unary2d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "unary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-unary2d/test/test.js b/base/broadcasted-unary2d/test/test.js deleted file mode 100644 index 7272afb37..000000000 --- a/base/broadcasted-unary2d/test/test.js +++ /dev/null @@ -1,156 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros2d = require( './../../../base/zeros2d' ); -var bunary2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bunary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a broadcasted input array and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var x; - var y; - - // 1-dimensional: - shapes = [ - [ 2 ], - [ 2, 2 ] - ]; - x = [ -1.0, -2.0 ]; - - expected = [ - [ 1.0, 2.0 ], - [ 1.0, 2.0 ] - ]; - - y = zeros2d( shapes[ 1 ] ); - bunary2d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 2-dimensional: - shapes = [ - [ 1, 2 ], - [ 2, 2 ] - ]; - x = [ - [ -1.0, -2.0 ] - ]; - - expected = [ - [ 1.0, 2.0 ], - [ 1.0, 2.0 ] - ]; - - y = zeros2d( shapes[ 1 ] ); - bunary2d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 2-dimensional (same shape): - shapes = [ - [ 2, 2 ], - [ 2, 2 ] - ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - - y = zeros2d( shapes[ 1 ] ); - bunary2d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 2, 2 ], - [ 0, 2 ] - ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = zeros2d( [ 2, 2 ] ); - - y = zeros2d( [ 2, 2 ] ); - bunary2d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 2, 2 ], - [ 2, 0 ] - ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = zeros2d( [ 2, 2 ] ); - - y = zeros2d( [ 2, 2 ] ); - bunary2d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-unary3d/README.md b/base/broadcasted-unary3d/README.md deleted file mode 100644 index 2d06cc02d..000000000 --- a/base/broadcasted-unary3d/README.md +++ /dev/null @@ -1,130 +0,0 @@ - - -# bunary3d - -> Apply a unary callback to elements in a [broadcasted][@stdlib/array/base/broadcast-array] nested input array and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bunary3d = require( '@stdlib/array/base/broadcasted-unary3d' ); -``` - -#### bunary3d( arrays, shapes, fcn ) - -Applies a unary callback to elements in a [broadcasted][@stdlib/array/base/broadcast-array] nested input array and assigns results to elements in a three-dimensional nested output array. - -```javascript -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ -1.0, -2.0 ] ] ]; -var y = zeros3d( [ 1, 2, 2 ] ); - -var shapes = [ - [ 1, 1, 2 ], - [ 1, 2, 2 ] -]; - -// Compute the absolute values: -bunary3d( [ x, y ], shapes, abs ); -// y => [ [ [ 1.0, 2.0 ], [ 1.0, 2.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shapes**: array shapes. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var bunary3d = require( '@stdlib/array/base/broadcasted-unary3d' ); - -var shapes = [ - [ 1, 1, 3 ], - [ 3, 1, 3 ] -]; - -var x = filled3dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros3d( shapes[ 1 ] ); -console.log( y ); - -bunary3d( [ x, y ], shapes, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-unary3d/benchmark/benchmark.js b/base/broadcasted-unary3d/benchmark/benchmark.js deleted file mode 100644 index 1960736e5..000000000 --- a/base/broadcasted-unary3d/benchmark/benchmark.js +++ /dev/null @@ -1,124 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bunary3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 1, shape[ 2 ] ], - shape - ]; - x = filled3dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = zeros3d( shapes[ 1 ] ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bunary3d( arrays, shapes, identity ); - i2 = i % shapes[ 1 ][ 0 ]; - i1 = i % shapes[ 1 ][ 1 ]; - i0 = i % shapes[ 1 ][ 2 ]; - if ( isnan( arrays[ 1 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shapes[ 1 ][ 0 ]; - i1 = i % shapes[ 1 ][ 1 ]; - i0 = i % shapes[ 1 ][ 2 ]; - if ( isnan( arrays[ 1 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-unary3d/docs/repl.txt b/base/broadcasted-unary3d/docs/repl.txt deleted file mode 100644 index 6f503c298..000000000 --- a/base/broadcasted-unary3d/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a unary callback to elements in a broadcasted nested input array and - assigns results to elements in a three-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ -1.0, -2.0 ]; - > var y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - > var shapes = [ [ 2 ], [ 1, 2, 2 ] ]; - > {{alias}}( [ x, y ], shapes, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ [ 1.0, 2.0 ], [ 1.0, 2.0 ] ] ] - - See Also - -------- - diff --git a/base/broadcasted-unary3d/docs/types/index.d.ts b/base/broadcasted-unary3d/docs/types/index.d.ts deleted file mode 100644 index bd89c4062..000000000 --- a/base/broadcasted-unary3d/docs/types/index.d.ts +++ /dev/null @@ -1,107 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D; - -/** -* Output array. -*/ -type OutputArray = Array3D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape3D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The input array shape must be broadcast compatible with the output array shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shapes - array shapes -* @param fcn - unary callback -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 1, 2 ], -* [ 1, 2, 2 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = zeros3d( shapes[ 1 ] ); -* -* bunary3d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -*/ -declare function bunary3d( arrays: InOutArrays, shapes: InOutShapes, fcn: Unary ): void; - - -// EXPORTS // - -export = bunary3d; diff --git a/base/broadcasted-unary3d/docs/types/test.ts b/base/broadcasted-unary3d/docs/types/test.ts deleted file mode 100644 index 04d616647..000000000 --- a/base/broadcasted-unary3d/docs/types/test.ts +++ /dev/null @@ -1,100 +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. -*/ - -import bunary3d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bunary3d( [ x, y ], shapes, fcn ); // $ExpectType void - bunary3d( [ x[ 0 ][ 0 ], y ], [ [ shapes[0][2] ], shapes[1] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bunary3d( 'abc', shapes, fcn ); // $ExpectError - bunary3d( 3.14, shapes, fcn ); // $ExpectError - bunary3d( true, shapes, fcn ); // $ExpectError - bunary3d( false, shapes, fcn ); // $ExpectError - bunary3d( null, shapes, fcn ); // $ExpectError - bunary3d( [ '1' ], shapes, fcn ); // $ExpectError - bunary3d( {}, shapes, fcn ); // $ExpectError - bunary3d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - bunary3d( [ x, y ], 'abc', fcn ); // $ExpectError - bunary3d( [ x, y ], 3.14, fcn ); // $ExpectError - bunary3d( [ x, y ], true, fcn ); // $ExpectError - bunary3d( [ x, y ], false, fcn ); // $ExpectError - bunary3d( [ x, y ], null, fcn ); // $ExpectError - bunary3d( [ x, y ], [ '1' ], fcn ); // $ExpectError - bunary3d( [ x, y ], {}, fcn ); // $ExpectError - bunary3d( [ x, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bunary3d( [ x, y ], shapes, 'abc' ); // $ExpectError - bunary3d( [ x, y ], shapes, 3.14 ); // $ExpectError - bunary3d( [ x, y ], shapes, true ); // $ExpectError - bunary3d( [ x, y ], shapes, false ); // $ExpectError - bunary3d( [ x, y ], shapes, null ); // $ExpectError - bunary3d( [ x, y ], shapes, [ '1' ] ); // $ExpectError - bunary3d( [ x, y ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - const shapes: [ Array, Array ] = [ [ 1, 2, 2 ], [ 1, 2, 2 ] ]; - - bunary3d(); // $ExpectError - bunary3d( [ x, y ] ); // $ExpectError - bunary3d( [ x, y ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-unary3d/examples/index.js b/base/broadcasted-unary3d/examples/index.js deleted file mode 100644 index 3bef8e83f..000000000 --- a/base/broadcasted-unary3d/examples/index.js +++ /dev/null @@ -1,39 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var bunary3d = require( './../lib' ); - -var shapes = [ - [ 1, 1, 3 ], - [ 3, 1, 3 ] -]; - -var x = filled3dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros3d( shapes[ 1 ] ); -console.log( y ); - -bunary3d( [ x, y ], shapes, abs ); -console.log( y ); diff --git a/base/broadcasted-unary3d/lib/index.js b/base/broadcasted-unary3d/lib/index.js deleted file mode 100644 index 03ec6314c..000000000 --- a/base/broadcasted-unary3d/lib/index.js +++ /dev/null @@ -1,56 +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'; - -/** -* Apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-unary3d -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var bunary3d = require( '@stdlib/array/base/broadcasted-unary3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 1, 2 ], -* [ 1, 2, 2 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = zeros3d( shapes[ 1 ] ); -* -* bunary3d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-unary3d/lib/main.js b/base/broadcasted-unary3d/lib/main.js deleted file mode 100644 index 913c64b62..000000000 --- a/base/broadcasted-unary3d/lib/main.js +++ /dev/null @@ -1,117 +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 broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a three-dimensional nested output array. -* -* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 1, 2 ], -* [ 1, 2, 2 ] -* ]; -* -* var x = ones3d( shapes[ 0 ] ); -* var y = zeros3d( shapes[ 1 ] ); -* -* bunary3d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -*/ -function bunary3d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dx2; - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var j0; - var j1; - var j2; - var x0; - var x1; - var y0; - var y1; - var sh; - var st; - var o; - var x; - var y; - - sh = shapes[ 1 ]; - S0 = sh[ 2 ]; - S1 = sh[ 1 ]; - S2 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 2 ]; - dx1 = st[ 1 ]; - dx2 = st[ 0 ]; - - y = arrays[ 1 ]; - j2 = 0; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - x1 = x[ j2 ]; - y1 = y[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn( x0[ j0 ] ); - j0 += dx0; - } - j1 += dx1; - } - j2 += dx2; - } -} - - -// EXPORTS // - -module.exports = bunary3d; diff --git a/base/broadcasted-unary3d/package.json b/base/broadcasted-unary3d/package.json deleted file mode 100644 index 247d71461..000000000 --- a/base/broadcasted-unary3d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-unary3d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "unary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-unary3d/test/test.js b/base/broadcasted-unary3d/test/test.js deleted file mode 100644 index 5496b93a4..000000000 --- a/base/broadcasted-unary3d/test/test.js +++ /dev/null @@ -1,246 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros3d = require( './../../../base/zeros3d' ); -var bunary3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bunary3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a broadcasted input array and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var x; - var y; - - // 1-dimensional: - shapes = [ - [ 2 ], - [ 1, 2, 2 ] - ]; - x = [ -1.0, -2.0 ]; - - expected = [ - [ - [ 1.0, 2.0 ], - [ 1.0, 2.0 ] - ] - ]; - - y = zeros3d( shapes[ 1 ] ); - bunary3d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 2-dimensional: - shapes = [ - [ 1, 2 ], - [ 1, 2, 2 ] - ]; - x = [ - [ -1.0, -2.0 ] - ]; - - expected = [ - [ - [ 1.0, 2.0 ], - [ 1.0, 2.0 ] - ] - ]; - - y = zeros3d( shapes[ 1 ] ); - bunary3d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 3-dimensional: - shapes = [ - [ 1, 2, 2 ], - [ 2, 2, 2 ] - ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - - y = zeros3d( shapes[ 1 ] ); - bunary3d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 3-dimensional (same shape): - shapes = [ - [ 2, 2, 2 ], - [ 2, 2, 2 ] - ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - - y = zeros3d( shapes[ 1 ] ); - bunary3d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 2, 2, 2 ], - [ 0, 2, 2 ] - ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( [ 2, 2, 2 ] ); - - y = zeros3d( [ 2, 2, 2 ] ); - bunary3d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 2, 2, 2 ], - [ 2, 0, 2 ] - ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( [ 2, 2, 2 ] ); - - y = zeros3d( [ 2, 2, 2 ] ); - bunary3d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 2, 2, 2 ], - [ 2, 2, 0 ] - ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( [ 2, 2, 2 ] ); - - y = zeros3d( [ 2, 2, 2 ] ); - bunary3d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-unary4d/README.md b/base/broadcasted-unary4d/README.md deleted file mode 100644 index 617b08a51..000000000 --- a/base/broadcasted-unary4d/README.md +++ /dev/null @@ -1,130 +0,0 @@ - - -# bunary4d - -> Apply a unary callback to elements in a [broadcasted][@stdlib/array/base/broadcast-array] nested input array and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bunary4d = require( '@stdlib/array/base/broadcasted-unary4d' ); -``` - -#### bunary4d( arrays, shapes, fcn ) - -Applies a unary callback to elements in a [broadcasted][@stdlib/array/base/broadcast-array] nested input array and assigns results to elements in a four-dimensional nested output array. - -```javascript -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ [ -1.0, -2.0 ] ] ] ]; -var y = zeros4d( [ 1, 1, 2, 2 ] ); - -var shapes = [ - [ 1, 1, 1, 2 ], - [ 1, 1, 2, 2 ] -]; - -// Compute the absolute values: -bunary4d( [ x, y ], shapes, abs ); -// y => [ [ [ [ 1.0, 2.0 ], [ 1.0, 2.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shapes**: array shapes. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var bunary4d = require( '@stdlib/array/base/broadcasted-unary4d' ); - -var shapes = [ - [ 1, 1, 1, 3 ], - [ 2, 3, 1, 3 ] -]; - -var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros4d( shapes[ 1 ] ); -console.log( y ); - -bunary4d( [ x, y ], shapes, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-unary4d/benchmark/benchmark.js b/base/broadcasted-unary4d/benchmark/benchmark.js deleted file mode 100644 index 37bdf7b37..000000000 --- a/base/broadcasted-unary4d/benchmark/benchmark.js +++ /dev/null @@ -1,127 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bunary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 1, 1, shape[ 3 ] ], - shape - ]; - x = filled4dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = zeros4d( shapes[ 1 ] ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bunary4d( arrays, shapes, identity ); - i3 = i % shapes[ 1 ][ 0 ]; - i2 = i % shapes[ 1 ][ 1 ]; - i1 = i % shapes[ 1 ][ 2 ]; - i0 = i % shapes[ 1 ][ 3 ]; - if ( isnan( arrays[ 1 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shapes[ 1 ][ 0 ]; - i2 = i % shapes[ 1 ][ 1 ]; - i1 = i % shapes[ 1 ][ 2 ]; - i0 = i % shapes[ 1 ][ 3 ]; - if ( isnan( arrays[ 1 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-unary4d/docs/repl.txt b/base/broadcasted-unary4d/docs/repl.txt deleted file mode 100644 index 189ad28fc..000000000 --- a/base/broadcasted-unary4d/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a unary callback to elements in a broadcasted nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ -1.0, -2.0 ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shapes = [ [ 2 ], [ 1, 1, 2, 2 ] ]; - > {{alias}}( [ x, y ], shapes, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ [ [ 1.0, 2.0 ], [ 1.0, 2.0 ] ] ] ] - - See Also - -------- - diff --git a/base/broadcasted-unary4d/docs/types/index.d.ts b/base/broadcasted-unary4d/docs/types/index.d.ts deleted file mode 100644 index f476c8ff6..000000000 --- a/base/broadcasted-unary4d/docs/types/index.d.ts +++ /dev/null @@ -1,107 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D, Shape4D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D | Array4D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D | Shape4D; - -/** -* Output array. -*/ -type OutputArray = Array4D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape4D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The input array shape must be broadcast compatible with the output array shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shapes - array shapes -* @param fcn - unary callback -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 1, 1, 2 ], -* [ 1, 1, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = zeros4d( shapes[ 1 ] ); -* -* bunary4d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -declare function bunary4d( arrays: InOutArrays, shapes: InOutShapes, fcn: Unary ): void; - - -// EXPORTS // - -export = bunary4d; diff --git a/base/broadcasted-unary4d/docs/types/test.ts b/base/broadcasted-unary4d/docs/types/test.ts deleted file mode 100644 index aa2422584..000000000 --- a/base/broadcasted-unary4d/docs/types/test.ts +++ /dev/null @@ -1,100 +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. -*/ - -import bunary4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bunary4d( [ x, y ], shapes, fcn ); // $ExpectType void - bunary4d( [ x[ 0 ][ 0 ][ 0 ], y ], [ [ shapes[0][3] ], shapes[1] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bunary4d( 'abc', shapes, fcn ); // $ExpectError - bunary4d( 3.14, shapes, fcn ); // $ExpectError - bunary4d( true, shapes, fcn ); // $ExpectError - bunary4d( false, shapes, fcn ); // $ExpectError - bunary4d( null, shapes, fcn ); // $ExpectError - bunary4d( [ '1' ], shapes, fcn ); // $ExpectError - bunary4d( {}, shapes, fcn ); // $ExpectError - bunary4d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - bunary4d( [ x, y ], 'abc', fcn ); // $ExpectError - bunary4d( [ x, y ], 3.14, fcn ); // $ExpectError - bunary4d( [ x, y ], true, fcn ); // $ExpectError - bunary4d( [ x, y ], false, fcn ); // $ExpectError - bunary4d( [ x, y ], null, fcn ); // $ExpectError - bunary4d( [ x, y ], [ '1' ], fcn ); // $ExpectError - bunary4d( [ x, y ], {}, fcn ); // $ExpectError - bunary4d( [ x, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bunary4d( [ x, y ], shapes, 'abc' ); // $ExpectError - bunary4d( [ x, y ], shapes, 3.14 ); // $ExpectError - bunary4d( [ x, y ], shapes, true ); // $ExpectError - bunary4d( [ x, y ], shapes, false ); // $ExpectError - bunary4d( [ x, y ], shapes, null ); // $ExpectError - bunary4d( [ x, y ], shapes, [ '1' ] ); // $ExpectError - bunary4d( [ x, y ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - const shapes: [ Array, Array ] = [ [ 1, 1, 2, 2 ], [ 1, 1, 2, 2 ] ]; - - bunary4d(); // $ExpectError - bunary4d( [ x, y ] ); // $ExpectError - bunary4d( [ x, y ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-unary4d/examples/index.js b/base/broadcasted-unary4d/examples/index.js deleted file mode 100644 index 5345d3a5c..000000000 --- a/base/broadcasted-unary4d/examples/index.js +++ /dev/null @@ -1,39 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var bunary4d = require( './../lib' ); - -var shapes = [ - [ 1, 1, 1, 3 ], - [ 2, 3, 1, 3 ] -]; - -var x = filled4dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros4d( shapes[ 1 ] ); -console.log( y ); - -bunary4d( [ x, y ], shapes, abs ); -console.log( y ); diff --git a/base/broadcasted-unary4d/lib/index.js b/base/broadcasted-unary4d/lib/index.js deleted file mode 100644 index ff8a24c07..000000000 --- a/base/broadcasted-unary4d/lib/index.js +++ /dev/null @@ -1,56 +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'; - -/** -* Apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-unary4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var bunary4d = require( '@stdlib/array/base/broadcasted-unary4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 1, 1, 2 ], -* [ 1, 1, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = zeros4d( shapes[ 1 ] ); -* -* bunary4d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-unary4d/lib/main.js b/base/broadcasted-unary4d/lib/main.js deleted file mode 100644 index cb2f2c388..000000000 --- a/base/broadcasted-unary4d/lib/main.js +++ /dev/null @@ -1,131 +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 broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a four-dimensional nested output array. -* -* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 1, 1, 2 ], -* [ 1, 1, 2, 2 ] -* ]; -* -* var x = ones4d( shapes[ 0 ] ); -* var y = zeros4d( shapes[ 1 ] ); -* -* bunary4d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function bunary4d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dx2; - var dx3; - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var j0; - var j1; - var j2; - var j3; - var x0; - var x1; - var x2; - var y0; - var y1; - var y2; - var sh; - var st; - var o; - var x; - var y; - - sh = shapes[ 1 ]; - S0 = sh[ 3 ]; - S1 = sh[ 2 ]; - S2 = sh[ 1 ]; - S3 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 3 ]; - dx1 = st[ 2 ]; - dx2 = st[ 1 ]; - dx3 = st[ 0 ]; - - y = arrays[ 1 ]; - j3 = 0; - for ( i3 = 0; i3 < S3; i3++ ) { - j2 = 0; - x2 = x[ j3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - x1 = x2[ j2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn( x0[ j0 ] ); - j0 += dx0; - } - j1 += dx1; - } - j2 += dx2; - } - j3 += dx3; - } -} - - -// EXPORTS // - -module.exports = bunary4d; diff --git a/base/broadcasted-unary4d/package.json b/base/broadcasted-unary4d/package.json deleted file mode 100644 index 9195cdd52..000000000 --- a/base/broadcasted-unary4d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-unary4d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "unary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-unary4d/test/test.js b/base/broadcasted-unary4d/test/test.js deleted file mode 100644 index 24c837659..000000000 --- a/base/broadcasted-unary4d/test/test.js +++ /dev/null @@ -1,370 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros4d = require( './../../../base/zeros4d' ); -var bunary4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bunary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a broadcasted input array and assigns results to a nested output array', function test( t ) { - var expected; - var shapes; - var x; - var y; - - // 1-dimensional: - shapes = [ - [ 2 ], - [ 1, 1, 2, 2 ] - ]; - x = [ -1.0, -2.0 ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 1.0, 2.0 ] - ] - ] - ]; - - y = zeros4d( shapes[ 1 ] ); - bunary4d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 2-dimensional: - shapes = [ - [ 1, 2 ], - [ 1, 1, 2, 2 ] - ]; - x = [ - [ -1.0, -2.0 ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 1.0, 2.0 ] - ] - ] - ]; - - y = zeros4d( shapes[ 1 ] ); - bunary4d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 3-dimensional: - shapes = [ - [ 1, 2, 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shapes[ 1 ] ); - bunary4d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 4-dimensional: - shapes = [ - [ 1, 1, 2, 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shapes[ 1 ] ); - bunary4d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 4-dimensional (same shape): - shapes = [ - [ 2, 2, 2, 2 ], - [ 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shapes[ 1 ] ); - bunary4d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 2, 2, 2 ], - [ 0, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - - y = zeros4d( [ 2, 2, 2, 2 ] ); - bunary4d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 2, 2, 2 ], - [ 2, 0, 2, 2 ] - ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - - y = zeros4d( [ 2, 2, 2, 2 ] ); - bunary4d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 2, 2, 2 ], - [ 2, 2, 0, 2 ] - ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - - y = zeros4d( [ 2, 2, 2, 2 ] ); - bunary4d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a fourth element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 2, 2, 2 ], - [ 2, 2, 2, 0 ] - ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( [ 2, 2, 2, 2 ] ); - - y = zeros4d( [ 2, 2, 2, 2 ] ); - bunary4d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/broadcasted-unary5d/README.md b/base/broadcasted-unary5d/README.md deleted file mode 100644 index 7f3f7d0cd..000000000 --- a/base/broadcasted-unary5d/README.md +++ /dev/null @@ -1,130 +0,0 @@ - - -# bunary5d - -> Apply a unary callback to elements in a [broadcasted][@stdlib/array/base/broadcast-array] nested input array and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var bunary5d = require( '@stdlib/array/base/broadcasted-unary5d' ); -``` - -#### bunary5d( arrays, shapes, fcn ) - -Applies a unary callback to elements in a [broadcasted][@stdlib/array/base/broadcast-array] nested input array and assigns results to elements in a five-dimensional nested output array. - -```javascript -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ [ [ -1.0, -2.0 ] ] ] ] ]; -var y = zeros5d( [ 1, 1, 1, 2, 2 ] ); - -var shapes = [ - [ 1, 1, 1, 1, 2 ], - [ 1, 1, 1, 2, 2 ] -]; - -// Compute the absolute values: -bunary5d( [ x, y ], shapes, abs ); -// y => [ [ [ [ [ 1.0, 2.0 ], [ 1.0, 2.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shapes**: array shapes. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The input and output array shapes must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes]. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var bunary5d = require( '@stdlib/array/base/broadcasted-unary5d' ); - -var shapes = [ - [ 1, 1, 1, 1, 3 ], - [ 2, 2, 3, 1, 3 ] -]; - -var x = filled5dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros5d( shapes[ 1 ] ); -console.log( y ); - -bunary5d( [ x, y ], shapes, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/broadcasted-unary5d/benchmark/benchmark.js b/base/broadcasted-unary5d/benchmark/benchmark.js deleted file mode 100644 index 345ef1fb2..000000000 --- a/base/broadcasted-unary5d/benchmark/benchmark.js +++ /dev/null @@ -1,130 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var bunary5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - output array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 1, 1, 1, shape[ 4 ] ], - shape - ]; - x = filled5dBy( shapes[ 0 ], uniform( -100.0, 100.0 ) ); - y = zeros5d( shapes[ 1 ] ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bunary5d( arrays, shapes, identity ); - i4 = i % shapes[ 1 ][ 0 ]; - i3 = i % shapes[ 1 ][ 1 ]; - i2 = i % shapes[ 1 ][ 2 ]; - i1 = i % shapes[ 1 ][ 3 ]; - i0 = i % shapes[ 1 ][ 4 ]; - if ( isnan( arrays[ 1 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shapes[ 1 ][ 0 ]; - i3 = i % shapes[ 1 ][ 1 ]; - i2 = i % shapes[ 1 ][ 2 ]; - i1 = i % shapes[ 1 ][ 3 ]; - i0 = i % shapes[ 1 ][ 4 ]; - if ( isnan( arrays[ 1 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/broadcasted-unary5d/docs/repl.txt b/base/broadcasted-unary5d/docs/repl.txt deleted file mode 100644 index f7b8070e1..000000000 --- a/base/broadcasted-unary5d/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( arrays, shapes, fcn ) - Applies a unary callback to elements in a broadcasted nested input array and - assigns results to elements in a five-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shapes: Array> - Array shapes. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ -1.0, -2.0 ]; - > var y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shapes = [ [ 2 ], [ 1, 1, 1, 2, 2 ] ]; - > {{alias}}( [ x, y ], shapes, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ [ [ [ 1.0, 2.0 ], [ 1.0, 2.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/broadcasted-unary5d/docs/types/index.d.ts b/base/broadcasted-unary5d/docs/types/index.d.ts deleted file mode 100644 index dc6304e2c..000000000 --- a/base/broadcasted-unary5d/docs/types/index.d.ts +++ /dev/null @@ -1,107 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D, Array5D } from '@stdlib/types/array'; -import { Shape1D, Shape2D, Shape3D, Shape4D, Shape5D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Input array. -*/ -type InputArray = Array1D | Array2D | Array3D | Array4D | Array5D; - -/** -* Input array shape. -*/ -type InputArrayShape = Shape1D | Shape2D | Shape3D | Shape4D | Shape5D; - -/** -* Output array. -*/ -type OutputArray = Array5D; - -/** -* Output array shape. -*/ -type OutputArrayShape = Shape5D; - -/** -* Input and output arrays. -*/ -type InOutArrays = [ - InputArray, - OutputArray -]; - -/** -* Input and output array shapes. -*/ -type InOutShapes = [ - InputArrayShape, - OutputArrayShape -]; - -/** -* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The input array shape must be broadcast compatible with the output array shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shapes - array shapes -* @param fcn - unary callback -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 1, 1, 1, 2 ], -* [ 1, 1, 1, 2, 2 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = zeros5d( shapes[ 1 ] ); -* -* bunary5d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -*/ -declare function bunary5d( arrays: InOutArrays, shapes: InOutShapes, fcn: Unary ): void; - - -// EXPORTS // - -export = bunary5d; diff --git a/base/broadcasted-unary5d/docs/types/test.ts b/base/broadcasted-unary5d/docs/types/test.ts deleted file mode 100644 index d825a8a00..000000000 --- a/base/broadcasted-unary5d/docs/types/test.ts +++ /dev/null @@ -1,100 +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. -*/ - -import bunary5d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bunary5d( [ x, y ], shapes, fcn ); // $ExpectType void - bunary5d( [ x[ 0 ][ 0 ][ 0 ][ 0 ], y ], [ [ shapes[0][4] ], shapes[1] ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - const shapes: [ Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bunary5d( 'abc', shapes, fcn ); // $ExpectError - bunary5d( 3.14, shapes, fcn ); // $ExpectError - bunary5d( true, shapes, fcn ); // $ExpectError - bunary5d( false, shapes, fcn ); // $ExpectError - bunary5d( null, shapes, fcn ); // $ExpectError - bunary5d( [ '1' ], shapes, fcn ); // $ExpectError - bunary5d( {}, shapes, fcn ); // $ExpectError - bunary5d( ( x: number ): number => x, shapes, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of arrays... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - bunary5d( [ x, y ], 'abc', fcn ); // $ExpectError - bunary5d( [ x, y ], 3.14, fcn ); // $ExpectError - bunary5d( [ x, y ], true, fcn ); // $ExpectError - bunary5d( [ x, y ], false, fcn ); // $ExpectError - bunary5d( [ x, y ], null, fcn ); // $ExpectError - bunary5d( [ x, y ], [ '1' ], fcn ); // $ExpectError - bunary5d( [ x, y ], {}, fcn ); // $ExpectError - bunary5d( [ x, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bunary5d( [ x, y ], shapes, 'abc' ); // $ExpectError - bunary5d( [ x, y ], shapes, 3.14 ); // $ExpectError - bunary5d( [ x, y ], shapes, true ); // $ExpectError - bunary5d( [ x, y ], shapes, false ); // $ExpectError - bunary5d( [ x, y ], shapes, null ); // $ExpectError - bunary5d( [ x, y ], shapes, [ '1' ] ); // $ExpectError - bunary5d( [ x, y ], shapes, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - const shapes: [ Array, Array ] = [ [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 2, 2 ] ]; - - bunary5d(); // $ExpectError - bunary5d( [ x, y ] ); // $ExpectError - bunary5d( [ x, y ], shapes, fcn, {} ); // $ExpectError -} diff --git a/base/broadcasted-unary5d/examples/index.js b/base/broadcasted-unary5d/examples/index.js deleted file mode 100644 index fee36b5dd..000000000 --- a/base/broadcasted-unary5d/examples/index.js +++ /dev/null @@ -1,39 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var bunary5d = require( './../lib' ); - -var shapes = [ - [ 1, 1, 1, 1, 3 ], - [ 2, 2, 3, 1, 3 ] -]; - -var x = filled5dBy( shapes[ 0 ], discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros5d( shapes[ 1 ] ); -console.log( y ); - -bunary5d( [ x, y ], shapes, abs ); -console.log( y ); diff --git a/base/broadcasted-unary5d/lib/index.js b/base/broadcasted-unary5d/lib/index.js deleted file mode 100644 index 8455b3e09..000000000 --- a/base/broadcasted-unary5d/lib/index.js +++ /dev/null @@ -1,56 +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'; - -/** -* Apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/broadcasted-unary5d -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var bunary5d = require( '@stdlib/array/base/broadcasted-unary5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 1, 1, 1, 2 ], -* [ 1, 1, 1, 2, 2 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = zeros5d( shapes[ 1 ] ); -* -* bunary5d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/broadcasted-unary5d/lib/main.js b/base/broadcasted-unary5d/lib/main.js deleted file mode 100644 index ada35458d..000000000 --- a/base/broadcasted-unary5d/lib/main.js +++ /dev/null @@ -1,145 +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 broadcastArray = require( './../../../base/broadcast-array' ); - - -// MAIN // - -/** -* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a five-dimensional nested output array. -* -* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array -* @param {ArrayLikeObject} shapes - array shapes -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shapes = [ -* [ 1, 1, 1, 1, 2 ], -* [ 1, 1, 1, 2, 2 ] -* ]; -* -* var x = ones5d( shapes[ 0 ] ); -* var y = zeros5d( shapes[ 1 ] ); -* -* bunary5d( [ x, y ], shapes, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -*/ -function bunary5d( arrays, shapes, fcn ) { - var dx0; - var dx1; - var dx2; - var dx3; - var dx4; - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var j0; - var j1; - var j2; - var j3; - var j4; - var x0; - var x1; - var x2; - var x3; - var y0; - var y1; - var y2; - var y3; - var sh; - var st; - var o; - var x; - var y; - - sh = shapes[ 1 ]; - S0 = sh[ 4 ]; - S1 = sh[ 3 ]; - S2 = sh[ 2 ]; - S3 = sh[ 1 ]; - S4 = sh[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return; - } - o = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh ); - x = o.data; - st = o.strides; - dx0 = st[ 4 ]; - dx1 = st[ 3 ]; - dx2 = st[ 2 ]; - dx3 = st[ 1 ]; - dx4 = st[ 0 ]; - - y = arrays[ 1 ]; - j4 = 0; - for ( i4 = 0; i4 < S4; i4++ ) { - j3 = 0; - x3 = x[ j4 ]; - y3 = y[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - j2 = 0; - x2 = x3[ j3 ]; - y2 = y3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - j1 = 0; - x1 = x2[ j2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - j0 = 0; - x0 = x1[ j1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn( x0[ j0 ] ); - j0 += dx0; - } - j1 += dx1; - } - j2 += dx2; - } - j3 += dx3; - } - j4 += dx4; - } -} - - -// EXPORTS // - -module.exports = bunary5d; diff --git a/base/broadcasted-unary5d/package.json b/base/broadcasted-unary5d/package.json deleted file mode 100644 index e5b683735..000000000 --- a/base/broadcasted-unary5d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/broadcasted-unary5d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a broadcasted nested input array and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "unary", - "apply", - "foreach", - "map", - "transform", - "broadcast" - ], - "__stdlib__": {} -} diff --git a/base/broadcasted-unary5d/test/test.js b/base/broadcasted-unary5d/test/test.js deleted file mode 100644 index 6fe8bf3a3..000000000 --- a/base/broadcasted-unary5d/test/test.js +++ /dev/null @@ -1,540 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros5d = require( './../../../base/zeros5d' ); -var bunary5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof bunary5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a broadcasted input array and assigns results to a nested output array', function test( t ) { // eslint-disable-line max-lines-per-function - var expected; - var shapes; - var x; - var y; - - // 1-dimensional: - shapes = [ - [ 2 ], - [ 1, 1, 1, 2, 2 ] - ]; - x = [ -1.0, -2.0 ]; - - expected = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 1.0, 2.0 ] - ] - ] - ] - ]; - - y = zeros5d( shapes[ 1 ] ); - bunary5d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 2-dimensional: - shapes = [ - [ 1, 2 ], - [ 1, 1, 1, 2, 2 ] - ]; - x = [ - [ -1.0, -2.0 ] - ]; - - expected = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 1.0, 2.0 ] - ] - ] - ] - ]; - - y = zeros5d( shapes[ 1 ] ); - bunary5d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 3-dimensional: - shapes = [ - [ 1, 2, 2 ], - [ 1, 2, 2, 2, 2 ] - ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - - y = zeros5d( shapes[ 1 ] ); - bunary5d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 4-dimensional: - shapes = [ - [ 1, 1, 2, 2 ], - [ 1, 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - - y = zeros5d( shapes[ 1 ] ); - bunary5d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 5-dimensional: - shapes = [ - [ 1, 1, 1, 2, 2 ], - [ 2, 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - - y = zeros5d( shapes[ 1 ] ); - bunary5d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - // 5-dimensional (same shape): - shapes = [ - [ 2, 2, 2, 2, 2 ], - [ 2, 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - - y = zeros5d( shapes[ 1 ] ); - bunary5d( [ x, y ], shapes, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a first element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 1, 2, 2, 2 ], - [ 0, 2, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - y = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bunary5d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a second element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 1, 2, 2, 2 ], - [ 2, 0, 2, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - y = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bunary5d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a third element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 1, 2, 2, 2 ], - [ 2, 2, 0, 2, 2 ] - ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - y = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bunary5d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a fourth element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 1, 2, 2, 2 ], - [ 2, 2, 2, 0, 2 ] - ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - y = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bunary5d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided an output shape having a fifth element equal to zero', function test( t ) { - var expected; - var shapes; - var x; - var y; - - shapes = [ - [ 1, 1, 2, 2, 2 ], - [ 2, 2, 2, 2, 0 ] - ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( [ 2, 2, 2, 2, 2 ] ); - - y = zeros5d( [ 2, 2, 2, 2, 2 ] ); - bunary5d( [ x, y ], shapes, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/cartesian-power/README.md b/base/cartesian-power/README.md deleted file mode 100644 index 9ef5628e7..000000000 --- a/base/cartesian-power/README.md +++ /dev/null @@ -1,122 +0,0 @@ - - -# cartesianPower - -> Return the [Cartesian power][cartesian-product]. - -
- -## Usage - -```javascript -var cartesianPower = require( '@stdlib/array/base/cartesian-power' ); -``` - -#### cartesianPower( x, n ) - -Returns the [Cartesian power][cartesian-product]. - -```javascript -var x = [ 1, 2 ]; - -var out = cartesianPower( x, 2 ); -// returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -``` - -If provided an empty array, the function returns an empty array. - -```javascript -var out = cartesianPower( [], 2 ); -// returns [] -``` - -If `n` is less than or equal to zero, the function returns an empty array. - -```javascript -var out = cartesianPower( [ 1, 2 ], 0 ); -// returns [] -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var linspace = require( '@stdlib/array/base/linspace' ); -var cartesianPower = require( '@stdlib/array/base/cartesian-power' ); - -var x = linspace( 0, 5, 6 ); - -var out = cartesianPower( x, 3 ); -// returns [ [ 0, 0, 0 ], [ 0, 0, 1 ], ..., [ 5, 5, 4 ], [ 5, 5, 5 ] ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/cartesian-power/benchmark/benchmark.js b/base/cartesian-power/benchmark/benchmark.js deleted file mode 100644 index 73552f2cc..000000000 --- a/base/cartesian-power/benchmark/benchmark.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var cartesianPower = require( './../lib' ); - - -// MAIN // - -bench( pkg+':exponent=2,len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianPower( x, 2 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cartesian-power/benchmark/benchmark.length.js b/base/cartesian-power/benchmark/benchmark.length.js deleted file mode 100644 index d3794c0dc..000000000 --- a/base/cartesian-power/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var cartesianPower = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filledBy( len, discreteUniform( 0, 3 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianPower( x, 2 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 2^min - max = 10; // 2^max - - for ( i = min; i <= max; i++ ) { - len = pow( 2, i ); - f = createBenchmark( len ); - bench( pkg+':exponent=2,len='+(len*len), f ); - } -} - -main(); diff --git a/base/cartesian-power/docs/repl.txt b/base/cartesian-power/docs/repl.txt deleted file mode 100644 index 7dc356d67..000000000 --- a/base/cartesian-power/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, n ) - Returns the Cartesian power. - - If provided an empty array, the function returns an empty array. - - If `n` is less than or equal to zero, the function returns an empty array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - n: integer - Power. - - Returns - ------- - out: Array - Cartesian product. - - Examples - -------- - > var x = [ 1, 2 ]; - > var out = {{alias}}( x, 2 ) - [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] - - See Also - -------- - diff --git a/base/cartesian-power/docs/types/index.d.ts b/base/cartesian-power/docs/types/index.d.ts deleted file mode 100644 index 30ad8d65b..000000000 --- a/base/cartesian-power/docs/types/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns the Cartesian power. -* -* ## Notes -* -* - If provided an empty array, the function returns an empty array. -* - If `n` is less than or equal to zero, the function returns an empty array. -* -* @param x - input array -* @param n - power -* @returns Cartesian product -* -* @example -* var x = [ 1, 2 ]; -* -* var out = cartesianPower( x, 2 ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ -declare function cartesianPower( x: Collection | AccessorArrayLike, n: number ): Array>; - - -// EXPORTS // - -export = cartesianPower; diff --git a/base/cartesian-power/docs/types/test.ts b/base/cartesian-power/docs/types/test.ts deleted file mode 100644 index d75d16c8c..000000000 --- a/base/cartesian-power/docs/types/test.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 cartesianPower = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - cartesianPower( [ 1, 2, 3, 4 ], 3 ); // $ExpectType number[][] - cartesianPower( [ 1, 2, 3, 4 ], 3 ); // $ExpectType number[][] - cartesianPower( [ '1', '2', '3', '4' ], 3 ); // $ExpectType string[][] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cartesianPower( 1, 3 ); // $ExpectError - cartesianPower( true, 3 ); // $ExpectError - cartesianPower( false, 3 ); // $ExpectError - cartesianPower( null, 3 ); // $ExpectError - cartesianPower( void 0, 3 ); // $ExpectError - cartesianPower( {}, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - cartesianPower( [ 1, 2 ], '1' ); // $ExpectError - cartesianPower( [ 1, 2 ], true ); // $ExpectError - cartesianPower( [ 1, 2 ], false ); // $ExpectError - cartesianPower( [ 1, 2 ], null ); // $ExpectError - cartesianPower( [ 1, 2 ], void 0 ); // $ExpectError - cartesianPower( [ 1, 2 ], {} ); // $ExpectError - cartesianPower( [ 1, 2 ], [] ); // $ExpectError - cartesianPower( [ 1, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cartesianPower(); // $ExpectError - cartesianPower( [], 2, [] ); // $ExpectError - cartesianPower( [], 2, [], [] ); // $ExpectError -} diff --git a/base/cartesian-power/examples/index.js b/base/cartesian-power/examples/index.js deleted file mode 100644 index 6d8404223..000000000 --- a/base/cartesian-power/examples/index.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 linspace = require( './../../../base/linspace' ); -var cartesianPower = require( './../lib' ); - -var x = linspace( 0, 5, 6 ); - -var out = cartesianPower( x, 3 ); -console.log( out ); -// => [ [ 0, 0, 0 ], [ 0, 0, 1 ], ..., [ 5, 5, 4 ], [ 5, 5, 5 ] ] diff --git a/base/cartesian-power/lib/index.js b/base/cartesian-power/lib/index.js deleted file mode 100644 index 73d21f89a..000000000 --- a/base/cartesian-power/lib/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return the Cartesian power. -* -* @module @stdlib/array/base/cartesian-power -* -* @example -* var cartesianPower = require( '@stdlib/array/base/cartesian-power' ); -* -* var x = [ 1, 2 ]; -* -* var out = cartesianPower( x, 2 ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ - -// MAIN // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cartesian-power/lib/main.js b/base/cartesian-power/lib/main.js deleted file mode 100644 index 713fc8843..000000000 --- a/base/cartesian-power/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); -var pow = require( '@stdlib/math/base/special/pow' ); - - -// MAIN // - -/** -* Returns the Cartesian power. -* -* ## Notes -* -* - The Cartesian power is an n-fold Cartesian product involving a single array. The main insight of this implementation is that the n-fold Cartesian product can be represented as an n-dimensional array stored in row-major order. As such, we can -* -* - Compute the total number of tuples, which is simply the size of the provided array (set) raised to the specified power `n`. For n-dimensional arrays, this is the equivalent of computing the product of array dimensions to determine the total number of elements. -* - Initialize an array for storing indices for indexing into the provided array. For n-dimensional arrays, the index array is equivalent to an array of subscripts for indexing into each dimension. -* - For the outermost loop, treat the loop index as a linear index into an n-dimensional array and resolve the corresponding subscripts. -* - Continue iterating until all tuples have been generated. -* -* @param {Collection} x - input array -* @param {NonNegativeInteger} n - power -* @returns {Array} list of ordered tuples comprising the Cartesian product -* -* @example -* var x = [ 1, 2 ]; -* -* var out = cartesianPower( x, 2 ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ -function cartesianPower( x, n ) { - var get; - var out; - var tmp; - var idx; - var len; - var N; - var s; - var i; - var j; - var k; - - N = x.length; - if ( N <= 0 || n <= 0 ) { - return []; - } - // Resolve an array element accessor: - get = resolveGetter( x ); - - // Compute the total number of ordered tuples: - len = pow( N, n ); - - // Initialize a list of indices for indexing into the array (equivalent to ndarray subscripts): - idx = []; - for ( i = 0; i < n; i++ ) { - idx.push( 0 ); - } - // Compute the n-fold Cartesian product... - out = []; - for ( i = 0; i < len; i++ ) { - // Resolve a linear index to array indices (logic is equivalent to what is found in ndarray/base/ind2sub for an ndarray stored in row-major order; see https://github.com/stdlib-js/stdlib/blob/215ca5355f3404f15996fd0ced58a98e46f22be6/lib/node_modules/%40stdlib/ndarray/base/ind2sub/lib/assign.js)... - k = i; - for ( j = n-1; j >= 0; j-- ) { - s = k % N; - k -= s; - k /= N; - idx[ j ] = s; - } - // Generate the next ordered tuple... - tmp = []; - for ( j = 0; j < n; j++ ) { - tmp.push( get( x, idx[ j ] ) ); - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = cartesianPower; diff --git a/base/cartesian-power/package.json b/base/cartesian-power/package.json deleted file mode 100644 index bde9043ef..000000000 --- a/base/cartesian-power/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/cartesian-power", - "version": "0.0.0", - "description": "Return the Cartesian power.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "cartesian", - "sets", - "math", - "mathematics", - "ordered", - "power" - ] -} diff --git a/base/cartesian-power/test/test.js b/base/cartesian-power/test/test.js deleted file mode 100644 index 0f1b1c1c1..000000000 --- a/base/cartesian-power/test/test.js +++ /dev/null @@ -1,243 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var cartesianPower = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cartesianPower, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the Cartesian power (n=1)', function test( t ) { - var expected; - var actual; - - actual = cartesianPower( [ 1, 2 ], 1 ); - expected = [ [ 1 ], [ 2 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1 ], 1 ); - expected = [ [ 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1, 2, 3 ], 1 ); - expected = [ - [ 1 ], - [ 2 ], - [ 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the Cartesian power (n=2)', function test( t ) { - var expected; - var actual; - - actual = cartesianPower( [ 1, 2 ], 2 ); - expected = [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1 ], 2 ); - expected = [ [ 1, 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1, 2, 3 ], 2 ); - expected = [ - [ 1, 1 ], - [ 1, 2 ], - [ 1, 3 ], - [ 2, 1 ], - [ 2, 2 ], - [ 2, 3 ], - [ 3, 1 ], - [ 3, 2 ], - [ 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the Cartesian power (n=3; indexed)', function test( t ) { - var expected; - var actual; - - actual = cartesianPower( [ 1, 2 ], 3 ); - expected = [ - [ 1, 1, 1 ], - [ 1, 1, 2 ], - [ 1, 2, 1 ], - [ 1, 2, 2 ], - [ 2, 1, 1 ], - [ 2, 1, 2 ], - [ 2, 2, 1 ], - [ 2, 2, 2 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1 ], 3 ); - expected = [ [ 1, 1, 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1, 2, 3 ], 3 ); - expected = [ - [ 1, 1, 1 ], - [ 1, 1, 2 ], - [ 1, 1, 3 ], - [ 1, 2, 1 ], - [ 1, 2, 2 ], - [ 1, 2, 3 ], - [ 1, 3, 1 ], - [ 1, 3, 2 ], - [ 1, 3, 3 ], - [ 2, 1, 1 ], - [ 2, 1, 2 ], - [ 2, 1, 3 ], - [ 2, 2, 1 ], - [ 2, 2, 2 ], - [ 2, 2, 3 ], - [ 2, 3, 1 ], - [ 2, 3, 2 ], - [ 2, 3, 3 ], - [ 3, 1, 1 ], - [ 3, 1, 2 ], - [ 3, 1, 3 ], - [ 3, 2, 1 ], - [ 3, 2, 2 ], - [ 3, 2, 3 ], - [ 3, 3, 1 ], - [ 3, 3, 2 ], - [ 3, 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the Cartesian power (n=3; accessor)', function test( t ) { - var expected; - var actual; - - actual = cartesianPower( toAccessorArray( [ 1, 2 ] ), 3 ); - expected = [ - [ 1, 1, 1 ], - [ 1, 1, 2 ], - [ 1, 2, 1 ], - [ 1, 2, 2 ], - [ 2, 1, 1 ], - [ 2, 1, 2 ], - [ 2, 2, 1 ], - [ 2, 2, 2 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( toAccessorArray( [ 1 ] ), 3 ); - expected = [ [ 1, 1, 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( toAccessorArray( [ 1, 2, 3 ] ), 3 ); - expected = [ - [ 1, 1, 1 ], - [ 1, 1, 2 ], - [ 1, 1, 3 ], - [ 1, 2, 1 ], - [ 1, 2, 2 ], - [ 1, 2, 3 ], - [ 1, 3, 1 ], - [ 1, 3, 2 ], - [ 1, 3, 3 ], - [ 2, 1, 1 ], - [ 2, 1, 2 ], - [ 2, 1, 3 ], - [ 2, 2, 1 ], - [ 2, 2, 2 ], - [ 2, 2, 3 ], - [ 2, 3, 1 ], - [ 2, 3, 2 ], - [ 2, 3, 3 ], - [ 3, 1, 1 ], - [ 3, 1, 2 ], - [ 3, 1, 3 ], - [ 3, 2, 1 ], - [ 3, 2, 2 ], - [ 3, 2, 3 ], - [ 3, 3, 1 ], - [ 3, 3, 2 ], - [ 3, 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty array (indexed)', function test( t ) { - var actual; - - actual = cartesianPower( [], 1 ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianPower( [], 2 ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianPower( [], 3 ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty array (accessors)', function test( t ) { - var actual; - - actual = cartesianPower( toAccessorArray( [] ), 1 ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianPower( toAccessorArray( [] ), 2 ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianPower( toAccessorArray( [] ), 3 ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided a power less than or equal to zero', function test( t ) { - var actual; - - actual = cartesianPower( [ 1, 2 ], 0 ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianPower( [ 1, 2 ], -1 ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianPower( [ 1, 2 ], -2 ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); diff --git a/base/cartesian-product/README.md b/base/cartesian-product/README.md deleted file mode 100644 index 0cca50219..000000000 --- a/base/cartesian-product/README.md +++ /dev/null @@ -1,120 +0,0 @@ - - -# cartesianProduct - -> Return the [Cartesian product][cartesian-product]. - -
- -## Usage - -```javascript -var cartesianProduct = require( '@stdlib/array/base/cartesian-product' ); -``` - -#### cartesianProduct( x1, x2 ) - -Returns the [Cartesian product][cartesian-product]. - -```javascript -var x1 = [ 1, 2, 3 ]; -var x2 = [ 4, 5 ]; - -var out = cartesianProduct( x1, x2 ); -// returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -``` - -If provided one or more empty arrays, the function returns an empty array. - -```javascript -var x1 = [ 1, 2, 3, 4 ]; -var x2 = []; - -var out = cartesianProduct( x1, x2 ); -// returns [] -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var linspace = require( '@stdlib/array/base/linspace' ); -var cartesianProduct = require( '@stdlib/array/base/cartesian-product' ); - -var x1 = linspace( 0, 5, 6 ); -var x2 = linspace( 10, 15, 6 ); - -var out = cartesianProduct( x1, x2 ); -// returns [ [ 0, 10 ], [ 0, 11 ], ..., [ 5, 14 ], [ 5, 15 ] ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/cartesian-product/benchmark/benchmark.js b/base/cartesian-product/benchmark/benchmark.js deleted file mode 100644 index 653909083..000000000 --- a/base/cartesian-product/benchmark/benchmark.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var cartesianProduct = require( './../lib' ); - - -// MAIN // - -bench( pkg+':len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianProduct( x, x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cartesian-product/benchmark/benchmark.length.js b/base/cartesian-product/benchmark/benchmark.length.js deleted file mode 100644 index 6c866b7df..000000000 --- a/base/cartesian-product/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var cartesianProduct = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filledBy( len/2, discreteUniform( 0, 3 ) ); - var y = [ 1, 2 ]; - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianProduct( x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cartesian-product/docs/repl.txt b/base/cartesian-product/docs/repl.txt deleted file mode 100644 index 0ab51ad50..000000000 --- a/base/cartesian-product/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( x1, x2 ) - Returns the Cartesian product. - - If provided one or more empty arrays, the function returns an empty array. - - Parameters - ---------- - x1: ArrayLikeObject - First input array. - - x2: ArrayLikeObject - Second input array. - - Returns - ------- - out: Array - Cartesian product. - - Examples - -------- - > var x1 = [ 1, 2 ]; - > var x2 = [ 3, 4 ]; - > var out = {{alias}}( x1, x2 ) - [ [ 1, 3 ], [ 1, 4 ], [ 2, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/base/cartesian-product/docs/types/index.d.ts b/base/cartesian-product/docs/types/index.d.ts deleted file mode 100644 index c608d83b5..000000000 --- a/base/cartesian-product/docs/types/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns the Cartesian product. -* -* ## Notes -* -* - If provided one or more empty arrays, the function returns an empty array. -* -* @param x1 - first input array -* @param x2 - second input array -* @returns Cartesian product -* -* @example -* var x1 = [ 1, 2, 3 ]; -* var x2 = [ 4, 5 ]; -* -* var out = cartesianProduct( x1, x2 ); -* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -*/ -declare function cartesianProduct( x1: Collection | AccessorArrayLike, x2: Collection | AccessorArrayLike ): Array<[T, U]>; - - -// EXPORTS // - -export = cartesianProduct; diff --git a/base/cartesian-product/docs/types/test.ts b/base/cartesian-product/docs/types/test.ts deleted file mode 100644 index ff98d1cda..000000000 --- a/base/cartesian-product/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 cartesianProduct = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - cartesianProduct( [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType [number, number][] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cartesianProduct( 1, [ 1, 3 ] ); // $ExpectError - cartesianProduct( true, [ 1, 3 ] ); // $ExpectError - cartesianProduct( false, [ 1, 3 ] ); // $ExpectError - cartesianProduct( null, [ 1, 3 ] ); // $ExpectError - cartesianProduct( void 0, [ 1, 3 ] ); // $ExpectError - cartesianProduct( {}, [ 1, 3 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - cartesianProduct( [], 1 ); // $ExpectError - cartesianProduct( [], true ); // $ExpectError - cartesianProduct( [], false ); // $ExpectError - cartesianProduct( [], null ); // $ExpectError - cartesianProduct( [], void 0 ); // $ExpectError - cartesianProduct( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cartesianProduct(); // $ExpectError - cartesianProduct( [] ); // $ExpectError - cartesianProduct( [], [], [] ); // $ExpectError -} diff --git a/base/cartesian-product/examples/index.js b/base/cartesian-product/examples/index.js deleted file mode 100644 index 9c08f679a..000000000 --- a/base/cartesian-product/examples/index.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 linspace = require( './../../../base/linspace' ); -var cartesianProduct = require( './../lib' ); - -var x1 = linspace( 0, 5, 6 ); -var x2 = linspace( 10, 15, 6 ); - -var out = cartesianProduct( x1, x2 ); -console.log( out ); -// => [ [ 0, 10 ], [ 0, 11 ], ..., [ 5, 14 ], [ 5, 15 ] ] diff --git a/base/cartesian-product/lib/index.js b/base/cartesian-product/lib/index.js deleted file mode 100644 index 92fd0e76b..000000000 --- a/base/cartesian-product/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return the Cartesian product. -* -* @module @stdlib/array/base/cartesian-product -* -* @example -* var cartesianProduct = require( '@stdlib/array/base/cartesian-product' ); -* -* var x1 = [ 1, 2, 3 ]; -* var x2 = [ 4, 5 ]; -* -* var out = cartesianProduct( x1, x2 ); -* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -*/ - -// MAIN // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cartesian-product/lib/main.js b/base/cartesian-product/lib/main.js deleted file mode 100644 index a6b654e2c..000000000 --- a/base/cartesian-product/lib/main.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Returns the Cartesian product. -* -* @param {Collection} x1 - first input array -* @param {Collection} x2 - second input array -* @returns {Array} list of ordered tuples comprising the Cartesian product -* -* @example -* var x1 = [ 1, 2, 3 ]; -* var x2 = [ 4, 5 ]; -* -* var out = cartesianProduct( x1, x2 ); -* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -*/ -function cartesianProduct( x1, x2 ) { - var get1; - var get2; - var out; - var M; - var N; - var v; - var i; - var j; - - get1 = resolveGetter( x1 ); - get2 = resolveGetter( x2 ); - - M = x1.length; - N = x2.length; - out = []; - for ( i = 0; i < M; i++ ) { - v = get1( x1, i ); - for ( j = 0; j < N; j++ ) { - out.push( [ v, get2( x2, j ) ] ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = cartesianProduct; diff --git a/base/cartesian-product/package.json b/base/cartesian-product/package.json deleted file mode 100644 index 0a2c18ac7..000000000 --- a/base/cartesian-product/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/cartesian-product", - "version": "0.0.0", - "description": "Return the Cartesian product.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "cartesian", - "sets", - "math", - "mathematics", - "ordered" - ] -} diff --git a/base/cartesian-product/test/test.js b/base/cartesian-product/test/test.js deleted file mode 100644 index 926ea6a44..000000000 --- a/base/cartesian-product/test/test.js +++ /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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cartesianProduct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cartesianProduct, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the Cartesian product (indexed)', function test( t ) { - var expected; - var actual; - - actual = cartesianProduct( [ 1, 2 ], [ 3, 4 ] ); - expected = [ [ 1, 3 ], [ 1, 4 ], [ 2, 3 ], [ 2, 4 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( [ 1 ], [ 3, 4 ] ); - expected = [ [ 1, 3 ], [ 1, 4 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( [ 1, 2 ], [ 3 ] ); - expected = [ [ 1, 3 ], [ 2, 3 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( [ 1, 2 ], [ 3, 4, 5 ] ); - expected = [ [ 1, 3 ], [ 1, 4 ], [ 1, 5 ], [ 2, 3 ], [ 2, 4 ], [ 2, 5 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the Cartesian product (accessors)', function test( t ) { - var expected; - var actual; - - actual = cartesianProduct( toAccessorArray( [ 1, 2 ] ), toAccessorArray( [ 3, 4 ] ) ); - expected = [ [ 1, 3 ], [ 1, 4 ], [ 2, 3 ], [ 2, 4 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( toAccessorArray( [ 1 ] ), toAccessorArray( [ 3, 4 ] ) ); - expected = [ [ 1, 3 ], [ 1, 4 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( toAccessorArray( [ 1, 2 ] ), toAccessorArray( [ 3 ] ) ); - expected = [ [ 1, 3 ], [ 2, 3 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( toAccessorArray( [ 1, 2 ] ), toAccessorArray( [ 3, 4, 5 ] ) ); - expected = [ [ 1, 3 ], [ 1, 4 ], [ 1, 5 ], [ 2, 3 ], [ 2, 4 ], [ 2, 5 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided one or more empty arrays (indexed)', function test( t ) { - var actual; - - actual = cartesianProduct( [], [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianProduct( [ 1, 2 ], [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianProduct( [], [ 3, 4 ] ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided one or more empty arrays (accessors)', function test( t ) { - var actual; - - actual = cartesianProduct( toAccessorArray( [] ), toAccessorArray( [] ) ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianProduct( toAccessorArray( [ 1, 2 ] ), toAccessorArray( [] ) ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianProduct( toAccessorArray( [] ), toAccessorArray( [ 3, 4 ] ) ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); diff --git a/base/cartesian-square/README.md b/base/cartesian-square/README.md deleted file mode 100644 index cfc3ada0c..000000000 --- a/base/cartesian-square/README.md +++ /dev/null @@ -1,115 +0,0 @@ - - -# cartesianSquare - -> Return the [Cartesian square][cartesian-product]. - -
- -## Usage - -```javascript -var cartesianSquare = require( '@stdlib/array/base/cartesian-square' ); -``` - -#### cartesianSquare( x ) - -Returns the [Cartesian square][cartesian-product]. - -```javascript -var x = [ 1, 2 ]; - -var out = cartesianSquare( x ); -// returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -``` - -If provided an empty array, the function returns an empty array. - -```javascript -var out = cartesianSquare( [] ); -// returns [] -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var linspace = require( '@stdlib/array/base/linspace' ); -var cartesianSquare = require( '@stdlib/array/base/cartesian-square' ); - -var x = linspace( 0, 5, 6 ); - -var out = cartesianSquare( x ); -// returns [ [ 0, 0 ], [ 0, 1 ], ..., [ 5, 4 ], [ 5, 5 ] ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/cartesian-square/benchmark/benchmark.js b/base/cartesian-square/benchmark/benchmark.js deleted file mode 100644 index e9a61285b..000000000 --- a/base/cartesian-square/benchmark/benchmark.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var cartesianSquare = require( './../lib' ); - - -// MAIN // - -bench( pkg+':len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianSquare( x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cartesian-square/benchmark/benchmark.length.js b/base/cartesian-square/benchmark/benchmark.length.js deleted file mode 100644 index 9bbeeca17..000000000 --- a/base/cartesian-square/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var cartesianSquare = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filledBy( len, discreteUniform( 0, 3 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianSquare( x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 2^min - max = 10; // 2^max - - for ( i = min; i <= max; i++ ) { - len = pow( 2, i ); - f = createBenchmark( len ); - bench( pkg+':len='+(len*len), f ); - } -} - -main(); diff --git a/base/cartesian-square/docs/repl.txt b/base/cartesian-square/docs/repl.txt deleted file mode 100644 index 73415249b..000000000 --- a/base/cartesian-square/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( x ) - Returns the Cartesian square. - - If provided an empty array, the function returns an empty array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Array - Cartesian product. - - Examples - -------- - > var x = [ 1, 2 ]; - > var out = {{alias}}( x ) - [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] - - See Also - -------- - diff --git a/base/cartesian-square/docs/types/index.d.ts b/base/cartesian-square/docs/types/index.d.ts deleted file mode 100644 index 5d8bd61a3..000000000 --- a/base/cartesian-square/docs/types/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns the Cartesian square. -* -* ## Notes -* -* - If provided an empty array, the function returns an empty array. -* -* @param x - input array -* @returns Cartesian product -* -* @example -* var x = [ 1, 2 ]; -* -* var out = cartesianSquare( x ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ -declare function cartesianSquare( x: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = cartesianSquare; diff --git a/base/cartesian-square/docs/types/test.ts b/base/cartesian-square/docs/types/test.ts deleted file mode 100644 index 6f1d5d8f1..000000000 --- a/base/cartesian-square/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 cartesianSquare = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - cartesianSquare( [ 1, 2, 3, 4 ] ); // $ExpectType number[][] - cartesianSquare( [ 1, 2, 3, 4 ] ); // $ExpectType number[][] - cartesianSquare( [ '1', '2', '3', '4' ] ); // $ExpectType string[][] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cartesianSquare( 1 ); // $ExpectError - cartesianSquare( true ); // $ExpectError - cartesianSquare( false ); // $ExpectError - cartesianSquare( null ); // $ExpectError - cartesianSquare( void 0 ); // $ExpectError - cartesianSquare( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cartesianSquare(); // $ExpectError - cartesianSquare( [], [] ); // $ExpectError - cartesianSquare( [], [], [] ); // $ExpectError -} diff --git a/base/cartesian-square/examples/index.js b/base/cartesian-square/examples/index.js deleted file mode 100644 index 1c7130a7b..000000000 --- a/base/cartesian-square/examples/index.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 linspace = require( './../../../base/linspace' ); -var cartesianSquare = require( './../lib' ); - -var x = linspace( 0, 5, 6 ); - -var out = cartesianSquare( x ); -console.log( out ); -// => [ [ 0, 0 ], [ 0, 1 ], ..., [ 5, 4 ], [ 5, 5 ] ] diff --git a/base/cartesian-square/lib/index.js b/base/cartesian-square/lib/index.js deleted file mode 100644 index 88dec20d4..000000000 --- a/base/cartesian-square/lib/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return the Cartesian square. -* -* @module @stdlib/array/base/cartesian-square -* -* @example -* var cartesianSquare = require( '@stdlib/array/base/cartesian-square' ); -* -* var x = [ 1, 2 ]; -* -* var out = cartesianSquare( x ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ - -// MAIN // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cartesian-square/lib/main.js b/base/cartesian-square/lib/main.js deleted file mode 100644 index 703ecd119..000000000 --- a/base/cartesian-square/lib/main.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Returns the Cartesian square. -* -* @param {Collection} x - input array -* @returns {Array} list of ordered tuples comprising the Cartesian product -* -* @example -* var x = [ 1, 2 ]; -* -* var out = cartesianSquare( x ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ -function cartesianSquare( x ) { - var get; - var out; - var N; - var v; - var i; - var j; - - get = resolveGetter( x ); - N = x.length; - out = []; - for ( i = 0; i < N; i++ ) { - v = get( x, i ); - for ( j = 0; j < N; j++ ) { - out.push( [ v, get( x, j ) ] ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = cartesianSquare; diff --git a/base/cartesian-square/package.json b/base/cartesian-square/package.json deleted file mode 100644 index fc5287695..000000000 --- a/base/cartesian-square/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/cartesian-square", - "version": "0.0.0", - "description": "Return the Cartesian square.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "cartesian", - "sets", - "math", - "mathematics", - "ordered" - ] -} diff --git a/base/cartesian-square/test/test.js b/base/cartesian-square/test/test.js deleted file mode 100644 index de5fdcfba..000000000 --- a/base/cartesian-square/test/test.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var cartesianSquare = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cartesianSquare, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the Cartesian square (indexed)', function test( t ) { - var expected; - var actual; - - actual = cartesianSquare( [ 1, 2 ] ); - expected = [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianSquare( [ 1 ] ); - expected = [ [ 1, 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianSquare( [ 1, 2, 3 ] ); - expected = [ - [ 1, 1 ], - [ 1, 2 ], - [ 1, 3 ], - [ 2, 1 ], - [ 2, 2 ], - [ 2, 3 ], - [ 3, 1 ], - [ 3, 2 ], - [ 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the Cartesian square (accessors)', function test( t ) { - var expected; - var actual; - - actual = cartesianSquare( toAccessorArray( [ 1, 2 ] ) ); - expected = [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianSquare( toAccessorArray( [ 1 ] ) ); - expected = [ [ 1, 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianSquare( toAccessorArray( [ 1, 2, 3 ] ) ); - expected = [ - [ 1, 1 ], - [ 1, 2 ], - [ 1, 3 ], - [ 2, 1 ], - [ 2, 2 ], - [ 2, 3 ], - [ 3, 1 ], - [ 3, 2 ], - [ 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty array (indexed)', function test( t ) { - var actual; - - actual = cartesianSquare( [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty array (accessors)', function test( t ) { - var actual; - - actual = cartesianSquare( toAccessorArray( [] ) ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); diff --git a/base/copy-indexed/README.md b/base/copy-indexed/README.md deleted file mode 100644 index cf018a2de..000000000 --- a/base/copy-indexed/README.md +++ /dev/null @@ -1,129 +0,0 @@ - - -# copyIndexed - -> Copy the elements of an indexed array-like object to a new "generic" array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var copyIndexed = require( '@stdlib/array/base/copy-indexed' ); -``` - -#### copyIndexed( x ) - -Copies the elements of an indexed array-like object to a new "generic" array. - -```javascript -var x = [ 1, 2, 3 ]; - -var out = copyIndexed( x ); -// returns [ 1, 2, 3 ] - -var bool = ( out === x ); -// returns false -``` - -
- - - - - -
- -## Notes - -- An _indexed_ array-like object is a data structure in which one retrieves elements via integer indices using bracket `[]` notation (e.g., `Float64Array`, `Int32Array`, `Array`, etc). This is in contrast to an _accessor_ array-like object in which one retrieves elements using `get` and `set` methods (e.g., [`Complex64Array`][@stdlib/array/complex64] and [`Complex128Array`][@stdlib/array/complex128]). - -
- - - - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/filled-by' ); -var randu = require( '@stdlib/random/base/randu' ); -var copyIndexed = require( '@stdlib/array/base/copy-indexed' ); - -// Create a Float64Array: -var arr = filledBy( 10, 'float64', randu ); - -// Copy elements to a generic array: -var out = copyIndexed( arr ); - -// Retrieve the first element: -var x = out[ 0 ]; -// returns - -console.log( '%d', x ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/copy-indexed/benchmark/benchmark.length.js b/base/copy-indexed/benchmark/benchmark.length.js deleted file mode 100644 index 0b4bcbf96..000000000 --- a/base/copy-indexed/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var copy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = copy( x ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/copy-indexed/docs/repl.txt b/base/copy-indexed/docs/repl.txt deleted file mode 100644 index 4c539f090..000000000 --- a/base/copy-indexed/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Copies the elements of an indexed array-like object to a new "generic" - array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - - See Also - -------- - diff --git a/base/copy-indexed/docs/types/index.d.ts b/base/copy-indexed/docs/types/index.d.ts deleted file mode 100644 index 49b271118..000000000 --- a/base/copy-indexed/docs/types/index.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/array'; - -/** -* Copies the elements of an indexed array-like object to a new "generic" array. -* -* @param x - input array -* @returns output array -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = copy( x ); -* // returns [ 1, 2, 3 ] -*/ -declare function copy( x: Collection ): Array; - - -// EXPORTS // - -export = copy; diff --git a/base/copy-indexed/docs/types/test.ts b/base/copy-indexed/docs/types/test.ts deleted file mode 100644 index 880b7627b..000000000 --- a/base/copy-indexed/docs/types/test.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 copy = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - copy( [ 1, 2, 3 ] ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided an argument which is not a collection... -{ - copy( 5 ); // $ExpectError - copy( true ); // $ExpectError - copy( false ); // $ExpectError - copy( null ); // $ExpectError - copy( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - copy(); // $ExpectError - copy( [ 1, 2, 3 ], 2 ); // $ExpectError -} diff --git a/base/copy-indexed/examples/index.js b/base/copy-indexed/examples/index.js deleted file mode 100644 index 578ed31bd..000000000 --- a/base/copy-indexed/examples/index.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 filledBy = require( './../../../filled-by' ); -var randu = require( '@stdlib/random/base/randu' ); -var copy = require( './../lib' ); - -// Create a Float64Array: -var arr = filledBy( 10, 'float64', randu ); - -// Copy elements to a generic array: -var out = copy( arr ); - -// Retrieve the first element: -var x = out[ 0 ]; -// returns - -console.log( '%d', x ); diff --git a/base/copy-indexed/lib/index.js b/base/copy-indexed/lib/index.js deleted file mode 100644 index b2b7dd943..000000000 --- a/base/copy-indexed/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Copy the elements of an indexed array-like object to a new "generic" array. -* -* @module @stdlib/array/base/copy-indexed -* -* @example -* var copy = require( '@stdlib/array/base/copy-indexed' ); -* -* var out = copy( [ 1, 2, 3 ] ); -* // returns [ 1, 2, 3 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/copy-indexed/lib/main.js b/base/copy-indexed/lib/main.js deleted file mode 100644 index 3703e9d67..000000000 --- a/base/copy-indexed/lib/main.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Copies the elements of an indexed array-like object to a new "generic" array. -* -* @param {Collection} x - input array -* @returns {Array} output array -* -* @example -* var out = copy( [ 1, 2, 3 ] ); -* // returns [ 1, 2, 3 ] -*/ -function copy( x ) { - var out; - var len; - var i; - - len = x.length; - out = []; - for ( i = 0; i < len; i++ ) { - out.push( x[ i ] ); // use `Array#push` to ensure "fast" elements - } - return out; -} - - -// EXPORTS // - -module.exports = copy; diff --git a/base/copy-indexed/package.json b/base/copy-indexed/package.json deleted file mode 100644 index 143ce6a14..000000000 --- a/base/copy-indexed/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/copy-indexed", - "version": "0.0.0", - "description": "Copy the elements of an indexed array-like object to a new generic array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "copy" - ] -} diff --git a/base/copy-indexed/test/test.js b/base/copy-indexed/test/test.js deleted file mode 100644 index 30c074c8d..000000000 --- a/base/copy-indexed/test/test.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 copy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof copy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function copies an array-like object', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - expected = [ 1, 2, 3 ]; - actual = copy( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of length `0`', function test( t ) { - var expected; - var actual; - - expected = []; - actual = copy( [] ); - - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/copy/README.md b/base/copy/README.md deleted file mode 100644 index 74ca12a82..000000000 --- a/base/copy/README.md +++ /dev/null @@ -1,129 +0,0 @@ - - -# copy - -> Copy the elements of an array-like object to a new "generic" array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var copy = require( '@stdlib/array/base/copy' ); -``` - -#### copy( x ) - -Copies the elements of an array-like object to a new "generic" array. - -```javascript -var x = [ 1, 2, 3 ]; - -var out = copy( x ); -// returns [ 1, 2, 3 ] - -var bool = ( out === x ); -// returns false -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var Complex64Array = require( '@stdlib/array/complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var copy = require( '@stdlib/array/base/copy' ); - -// Create a complex number array: -var arr = new Complex64Array( 10 ); - -// Copy elements to a generic array: -var out = copy( arr ); - -// Retrieve the first element: -var z = out[ 0 ]; -// returns - -var re = realf( z ); -// returns 0.0 - -var im = imagf( z ); -// returns 0.0 - -console.log( '%d + %di', re, im ); -// => '0 + 0i' -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/copy/benchmark/benchmark.length.js b/base/copy/benchmark/benchmark.length.js deleted file mode 100644 index 0b4bcbf96..000000000 --- a/base/copy/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var copy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = copy( x ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/copy/docs/repl.txt b/base/copy/docs/repl.txt deleted file mode 100644 index 328337424..000000000 --- a/base/copy/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( x ) - Copies the elements of an array-like object to a new "generic" array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3 ] ) - [ 1, 2, 3 ] - - See Also - -------- - diff --git a/base/copy/docs/types/index.d.ts b/base/copy/docs/types/index.d.ts deleted file mode 100644 index 336826585..000000000 --- a/base/copy/docs/types/index.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Copies the elements of an array-like object to a new "generic" array. -* -* @param x - input array -* @returns output array -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = copy( x ); -* // returns [ 1, 2, 3 ] -*/ -declare function copy( x: Collection | AccessorArrayLike ): Array; - - -// EXPORTS // - -export = copy; diff --git a/base/copy/docs/types/test.ts b/base/copy/docs/types/test.ts deleted file mode 100644 index 880b7627b..000000000 --- a/base/copy/docs/types/test.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 copy = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - copy( [ 1, 2, 3 ] ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided an argument which is not a collection... -{ - copy( 5 ); // $ExpectError - copy( true ); // $ExpectError - copy( false ); // $ExpectError - copy( null ); // $ExpectError - copy( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - copy(); // $ExpectError - copy( [ 1, 2, 3 ], 2 ); // $ExpectError -} diff --git a/base/copy/examples/index.js b/base/copy/examples/index.js deleted file mode 100644 index 587e4e62a..000000000 --- a/base/copy/examples/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( './../../../complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var copy = require( './../lib' ); - -// Create a complex number array: -var arr = new Complex64Array( 10 ); - -// Copy elements to a generic array: -var out = copy( arr ); - -// Retrieve the first element: -var z = out[ 0 ]; -// returns - -var re = realf( z ); -// returns 0.0 - -var im = imagf( z ); -// returns 0.0 - -console.log( '%d + %di', re, im ); -// => '0 + 0i' diff --git a/base/copy/lib/index.js b/base/copy/lib/index.js deleted file mode 100644 index 4f4b3ae84..000000000 --- a/base/copy/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Copy the elements of an array-like object to a new "generic" array. -* -* @module @stdlib/array/base/copy -* -* @example -* var copy = require( '@stdlib/array/base/copy' ); -* -* var out = copy( [ 1, 2, 3 ] ); -* // returns [ 1, 2, 3 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/copy/lib/main.js b/base/copy/lib/main.js deleted file mode 100644 index 88549f052..000000000 --- a/base/copy/lib/main.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Copies the elements of an array-like object to a new "generic" array. -* -* @param {Collection} x - input array -* @returns {Array} output array -* -* @example -* var out = copy( [ 1, 2, 3 ] ); -* // returns [ 1, 2, 3 ] -*/ -function copy( x ) { - var out; - var len; - var get; - var i; - - // Resolve an accessor for retrieving input array elements: - get = resolveGetter( x ); - - // Get the number of elements to copy: - len = x.length; - - // Loop over the elements... - out = []; - for ( i = 0; i < len; i++ ) { - out.push( get( x, i ) ); // ensure "fast" elements - } - return out; -} - - -// EXPORTS // - -module.exports = copy; diff --git a/base/copy/package.json b/base/copy/package.json deleted file mode 100644 index 987f74fc2..000000000 --- a/base/copy/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/copy", - "version": "0.0.0", - "description": "Copy the elements of an array-like object to a new generic array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "copy" - ] -} diff --git a/base/copy/test/test.js b/base/copy/test/test.js deleted file mode 100644 index 5d224ec83..000000000 --- a/base/copy/test/test.js +++ /dev/null @@ -1,85 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64Array = require( './../../../complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var copy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof copy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function copies an array-like object', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - expected = [ 1, 2, 3 ]; - actual = copy( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies an array-like object (accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - actual = copy( x ); - - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < x.length; i++ ) { - v = actual[ i ]; - expected = x.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of length `0`', function test( t ) { - var expected; - var actual; - - expected = []; - actual = copy( [] ); - - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/count-falsy/README.md b/base/count-falsy/README.md deleted file mode 100644 index a831e9fcc..000000000 --- a/base/count-falsy/README.md +++ /dev/null @@ -1,113 +0,0 @@ - - -# countFalsy - -> Count the number of falsy elements in an array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var countFalsy = require( '@stdlib/array/base/count-falsy' ); -``` - -#### countFalsy( x ) - -Counts the number of falsy elements in an array. - -```javascript -var x = [ 0, 1, 0, 1, 2 ]; - -var out = countFalsy( x ); -// returns 2 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var countFalsy = require( '@stdlib/array/base/count-falsy' ); - -var x = bernoulli( 100, 0.5, { - 'dtype': 'generic' -}); -console.log( x ); - -var n = countFalsy( x ); -console.log( n ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/count-falsy/benchmark/benchmark.length.js b/base/count-falsy/benchmark/benchmark.length.js deleted file mode 100644 index ef2ef5ce0..000000000 --- a/base/count-falsy/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var pkg = require( './../package.json' ).name; -var countFalsy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countFalsy( x ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/count-falsy/docs/repl.txt b/base/count-falsy/docs/repl.txt deleted file mode 100644 index 38e161ff6..000000000 --- a/base/count-falsy/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( x ) - Counts the number of falsy values in an array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: integer - Number of falsy values. - - Examples - -------- - > var out = {{alias}}( [ 0, 1, 1 ] ) - 1 - - See Also - -------- - diff --git a/base/count-falsy/docs/types/index.d.ts b/base/count-falsy/docs/types/index.d.ts deleted file mode 100644 index 43b7c2185..000000000 --- a/base/count-falsy/docs/types/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Counts the number of falsy values in an array. -* -* @param x - input array -* @returns number of falsy values -* -* @example -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var out = countFalsy( x ); -* // returns 2 -*/ -declare function countFalsy( x: Collection ): number; - - -// EXPORTS // - -export = countFalsy; diff --git a/base/count-falsy/docs/types/test.ts b/base/count-falsy/docs/types/test.ts deleted file mode 100644 index 99f4f7ed9..000000000 --- a/base/count-falsy/docs/types/test.ts +++ /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. -*/ - -import countFalsy = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - countFalsy( [ 1, 2, 3 ] ); // $ExpectType number -} - -// The compiler throws an error if the function is provided an argument which is not a collection... -{ - countFalsy( 5 ); // $ExpectError - countFalsy( true ); // $ExpectError - countFalsy( false ); // $ExpectError - countFalsy( null ); // $ExpectError - countFalsy( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countFalsy(); // $ExpectError - countFalsy( [ 1, 2, 3 ], 2 ); // $ExpectError -} diff --git a/base/count-falsy/examples/index.js b/base/count-falsy/examples/index.js deleted file mode 100644 index d99a7fbb8..000000000 --- a/base/count-falsy/examples/index.js +++ /dev/null @@ -1,30 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var countFalsy = require( './../lib' ); - -var x = bernoulli( 100, 0.5, { - 'dtype': 'generic' -}); -console.log( x ); - -var n = countFalsy( x ); -console.log( n ); diff --git a/base/count-falsy/lib/index.js b/base/count-falsy/lib/index.js deleted file mode 100644 index f76288aaa..000000000 --- a/base/count-falsy/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Count the number of falsy values in an array. -* -* @module @stdlib/array/base/count-falsy -* -* @example -* var countFalsy = require( '@stdlib/array/base/count-falsy' ); -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countFalsy( x ); -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/count-falsy/lib/main.js b/base/count-falsy/lib/main.js deleted file mode 100644 index 203f8f690..000000000 --- a/base/count-falsy/lib/main.js +++ /dev/null @@ -1,152 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexTypedArray = require( './../../../base/assert/is-complex-typed-array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var reinterpretComplex = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Counts the number of falsy values in an indexed array. -* -* @private -* @param {Collection} x - input array -* @returns {NonNegativeInteger} number of falsy values -* -* @example -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x ); -* // returns 2 -*/ -function indexed( x ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( !x[ i ] ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of falsy values in an accessor array. -* -* @private -* @param {Collection} x - input array -* @returns {NonNegativeInteger} number of falsy values -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x ); -* // returns 2 -*/ -function accessors( x ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( !get( x, i ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of falsy values in a complex array. -* -* @private -* @param {Collection} x - input array -* @returns {NonNegativeInteger} number of falsy values -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 5.0, 6.0 ] ); -* -* var n = complex( x ); -* // returns 2 -*/ -function complex( x ) { - var view; - var n; - var i; - - view = reinterpretComplex( x, 0 ); - - n = 0; - for ( i = 0; i < view.length; i += 2 ) { - if ( view[ i ] === 0.0 && view[ i+1 ] === 0.0 ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of falsy values in an array. -* -* @param {Collection} x - input array -* @returns {NonNegativeInteger} number of falsy values -* -* @example -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countFalsy( x ); -* // returns 2 -*/ -function countFalsy( x ) { - if ( isAccessorArray( x ) ) { - if ( isBooleanArray( x ) ) { - return indexed( reinterpretBoolean( x, 0 ) ); - } - if ( isComplexTypedArray( x ) ) { - return complex( x ); - } - return accessors( x ); - } - return indexed( x ); -} - - -// EXPORTS // - -module.exports = countFalsy; diff --git a/base/count-falsy/package.json b/base/count-falsy/package.json deleted file mode 100644 index 92641bdfa..000000000 --- a/base/count-falsy/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/count-falsy", - "version": "0.0.0", - "description": "Count the number of falsy elements in an array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "count", - "sum", - "summation", - "countif", - "total", - "falsy" - ] -} diff --git a/base/count-falsy/test/test.js b/base/count-falsy/test/test.js deleted file mode 100644 index 4a4a6072f..000000000 --- a/base/count-falsy/test/test.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var BooleanArray = require( './../../../bool' ); -var Int32Array = require( './../../../int32' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var countFalsy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countFalsy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of falsy values (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - expected = 2; - actual = countFalsy( x ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of falsy values (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - expected = 2; - actual = countFalsy( x ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of falsy values (real typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - expected = 2; - actual = countFalsy( x ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of falsy values (complex typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - expected = 1; - actual = countFalsy( x ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of falsy values (boolean typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new BooleanArray( [ 0, 1, 0, 1, 1 ] ); - expected = 2; - actual = countFalsy( x ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns zero if provided an array of length `0`', function test( t ) { - var expected; - var actual; - var x; - - expected = 0; - - x = []; - actual = countFalsy( x ); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countFalsy( x ); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countFalsy( x ); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countFalsy( x ); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [] ); - actual = countFalsy( x ); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/count-if/README.md b/base/count-if/README.md deleted file mode 100644 index 67ce59793..000000000 --- a/base/count-if/README.md +++ /dev/null @@ -1,149 +0,0 @@ - - -# countIf - -> Count the number of elements in an array which pass a test implemented by a predicate function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var countIf = require( '@stdlib/array/base/count-if' ); -``` - -#### countIf( x, predicate\[, thisArg] ) - -Counts the number of elements in an array which pass a test implemented by a predicate function. - -```javascript -function predicate( value ) { - return ( value > 0 ); -} - -var x = [ 0, 1, 0, 1, 2 ]; - -var out = countIf( x, predicate ); -// returns 3 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( value ) { - this.count += 1; - return ( value > 0 ); -} - -var x = [ 0, 1, 0, 1, 2 ]; - -var context = { - 'count': 0 -}; - -var out = countIf( x, predicate, context ); -// returns 3 - -var cnt = context.count; -// returns 5 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var countIf = require( '@stdlib/array/base/count-if' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/count-if/benchmark/benchmark.length.js b/base/count-if/benchmark/benchmark.length.js deleted file mode 100644 index aefe7cffe..000000000 --- a/base/count-if/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var pkg = require( './../package.json' ).name; -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate( v ) { - return v > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIf( x, predicate ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/count-if/docs/repl.txt b/base/count-if/docs/repl.txt deleted file mode 100644 index 0767c7804..000000000 --- a/base/count-if/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Counts the number of elements in an array which pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f ) - 2 - - See Also - -------- - diff --git a/base/count-if/docs/types/index.d.ts b/base/count-if/docs/types/index.d.ts deleted file mode 100644 index 1310c1a01..000000000 --- a/base/count-if/docs/types/index.d.ts +++ /dev/null @@ -1,92 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns result -* -* @example -* function predicate( v ) { -* return v > 0; -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; - - -// EXPORTS // - -export = countIf; diff --git a/base/count-if/docs/types/test.ts b/base/count-if/docs/types/test.ts deleted file mode 100644 index c7b1efa77..000000000 --- a/base/count-if/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import countIf = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - countIf( [ 1, 2, 3 ], isPositive ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number - - countIf( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number - countIf( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number - countIf( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIf( 2, isPositive ); // $ExpectError - countIf( false, isPositive ); // $ExpectError - countIf( true, isPositive ); // $ExpectError - countIf( {}, isPositive ); // $ExpectError - - countIf( 2, isPositive, {} ); // $ExpectError - countIf( false, isPositive, {} ); // $ExpectError - countIf( true, isPositive, {} ); // $ExpectError - countIf( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - countIf( [ 1, 2, 3 ], 'abc' ); // $ExpectError - countIf( [ 1, 2, 3 ], 2 ); // $ExpectError - countIf( [ 1, 2, 3 ], false ); // $ExpectError - countIf( [ 1, 2, 3 ], true ); // $ExpectError - countIf( [ 1, 2, 3 ], null ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0 ); // $ExpectError - countIf( [ 1, 2, 3 ], {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [] ); // $ExpectError - - countIf( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - countIf( [ 1, 2, 3 ], 2, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], false, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], true, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], null, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], {}, {} ); // $ExpectError - countIf( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countIf(); // $ExpectError - countIf( [ 1, 2, 3 ] ); // $ExpectError - countIf( [ 1, 2, 3 ], isPositive, {}, {} ); // $ExpectError -} diff --git a/base/count-if/examples/index.js b/base/count-if/examples/index.js deleted file mode 100644 index f51511b60..000000000 --- a/base/count-if/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var countIf = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = countIf( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/count-if/lib/index.js b/base/count-if/lib/index.js deleted file mode 100644 index 876d9d45c..000000000 --- a/base/count-if/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Count the number of elements in an array which pass a test implemented by a predicate function. -* -* @module @stdlib/array/base/count-if -* -* @example -* var countIf = require( '@stdlib/array/base/count-if' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 2 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/count-if/lib/main.js b/base/count-if/lib/main.js deleted file mode 100644 index 41e1c01df..000000000 --- a/base/count-if/lib/main.js +++ /dev/null @@ -1,129 +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. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, predicate, {} ); -* // returns 3 -*/ -function indexed( x, predicate, thisArg ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} thisArg - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, predicate, {} ); -* // returns 3 -*/ -function accessors( x, predicate, thisArg ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, get( x, i ), i, x ) ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function evaluation context -* @returns {NonNegativeInteger} result -* -* @example -* function predicate( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIf( x, predicate ); -* // returns 3 -*/ -function countIf( x, predicate, thisArg ) { - if ( isAccessorArray( x ) ) { - return accessors( x, predicate, thisArg ); - } - return indexed( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = countIf; diff --git a/base/count-if/package.json b/base/count-if/package.json deleted file mode 100644 index ec18b4b3d..000000000 --- a/base/count-if/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/count-if", - "version": "0.0.0", - "description": "Count the number of elements in an array which pass a test implemented by a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "count", - "sum", - "summation", - "countif", - "total", - "truthy" - ] -} diff --git a/base/count-if/test/test.js b/base/count-if/test/test.js deleted file mode 100644 index 00a8d2e19..000000000 --- a/base/count-if/test/test.js +++ /dev/null @@ -1,212 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Int32Array = require( './../../../int32' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var countIf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - value -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (real typed array)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements which pass a test implemented by a predicate function (complex typed array)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); - - function predicate( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } -}); - -tape( 'the function returns `0` if provided an array having zero elements', function test( t ) { - var actual; - var x; - - x = []; - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countIf( x, predicate ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 0, 0, 0, 0 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 1, 1 ]; - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) { - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = countIf( x, predicate ); - - t.strictEqual( actual, x.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a custom execution context (generic)', function test( t ) { - var context; - var actual; - var x; - - x = [ 0, 1, 0, 1, 1 ]; - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'the function supports providing a custom execution context (accessors)', function test( t ) { - var context; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); - context = { - 'count': 0 - }; - actual = countIf( x, predicate, context ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.strictEqual( context.count, x.length, 'returns expected value' ); - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); diff --git a/base/count-ifs/README.md b/base/count-ifs/README.md deleted file mode 100644 index 9ecdd4907..000000000 --- a/base/count-ifs/README.md +++ /dev/null @@ -1,157 +0,0 @@ - - -# countIfs - -> Perform element-wise evaluation of one or more input arrays according to provided predicate functions and count the number of elements for which all predicates respectively return `true`. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var countIfs = require( '@stdlib/array/base/count-ifs' ); -``` - -#### countIfs( x0, predicate0\[, x1, predicate1\[, x2, predicate2\[, ...args]]] ) - -Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`. - -```javascript -function predicate0( value ) { - return ( value > 0 ); -} - -function predicate1( value ) { - return ( value < 3 ); -} - -var x0 = [ 0, 1, 0, 1, 2 ]; -var x1 = [ 2, 3, 1, 2, 5 ]; - -var out = countIfs( x0, predicate0, x1, predicate1 ); -// returns 1 -``` - -The function has the following parameters: - -- **x0**: first input array. -- **predicate0**: first predicate function. -- **x1**: second input array (_optional_). -- **predicate1**: second predicate function (_optional_). -- **x2**: third input array (_optional_). -- **predicate2**: third predicate function (_optional_). -- **args**: additional input arrays and corresponding predicate functions (_optional_). - -Each predicate function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the corresponding input array. - -
- - - - - -
- -## Notes - -- The function assumes that all input arrays have the same length. -- The function supports array-like objects supporting the accessor protocol (e.g., [`Complex128Array`][@stdlib/array/complex128], [`Complex64Array`][@stdlib/array/complex64], etc). - -
- - - - - -
- -## Examples - - - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var isNegativeInteger = require( '@stdlib/assert/is-negative-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var countIfs = require( '@stdlib/array/base/count-ifs' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -console.log( x ); - -var y = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -console.log( y ); - -var out = countIfs( x, naryFunction( isPositiveInteger, 1 ), y, naryFunction( isNegativeInteger, 1 ) ); -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/count-ifs/benchmark/benchmark.length.js b/base/count-ifs/benchmark/benchmark.length.js deleted file mode 100644 index 13d9b2027..000000000 --- a/base/count-ifs/benchmark/benchmark.length.js +++ /dev/null @@ -1,123 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var uniform = require( '@stdlib/random/array/uniform' ); -var pkg = require( './../package.json' ).name; -var countIfs = require( './../lib' ); - - -// FUNCTIONS // - -/** -* First predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate0( v ) { - return v > 0.0; -} - -/** -* Second predicate function. -* -* @private -* @param {number} v - value -* @returns {boolean} result -*/ -function predicate1( v ) { - return v < 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x0 = uniform( len, -1.0, 1.0, { - 'dype': 'generic' - }); - var x1 = uniform( len, -1.0, 1.0, { - 'dype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countIfs( x0, predicate0, x1, predicate1 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,predicates=2,len='+len, f ); - } -} - -main(); diff --git a/base/count-ifs/docs/repl.txt b/base/count-ifs/docs/repl.txt deleted file mode 100644 index 8a579394f..000000000 --- a/base/count-ifs/docs/repl.txt +++ /dev/null @@ -1,50 +0,0 @@ - -{{alias}}( x0, predicate0[, x1, predicate1[, x2, predicate2[, ...args]] ) - Performs element-wise evaluation of one or more input arrays according to - provided predicate functions and counts the number of elements for which all - predicates respectively return `true`. - - Each predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the corresponding input array. - - Parameters - ---------- - x0: ArrayLikeObject - First input array. - - predicate0: Function - First predicate function. - - x1: ArrayLikeObject (optional) - Second input array. - - predicate1: Function (optional) - Second predicate function. - - x2: ArrayLikeObject (optional) - Third input array. - - predicate2: Function (optional) - Third predicate function. - - ...args: ArrayLikeObject|Function (optional) - Additional input arrays and corresponding predicate functions. - - Returns - ------- - out: integer - Result. - - Examples - -------- - > function f1( v ) { return ( v > 0 ); }; - > function f2( v ) { return ( v < 0 ); }; - > var out = {{alias}}( [ 0, 1, 1 ], f1, [ 1, -1, -1 ], f2 ) - 2 - - See Also - -------- - diff --git a/base/count-ifs/docs/types/index.d.ts b/base/count-ifs/docs/types/index.d.ts deleted file mode 100644 index e940e3022..000000000 --- a/base/count-ifs/docs/types/index.d.ts +++ /dev/null @@ -1,243 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Input array. -*/ -type InputArray = Collection | AccessorArrayLike; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = () => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( value: T, index: number, arr: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`. -* -* @param x0 - input array -* @param predicate0 - predicate function -* @returns result -* -* @example -* function predicate0( v ) { -* return v > 0; -* } -* -* var x0 = [ 0, 1, 0, 1, 1 ]; -* -* var n = countIfs( x0, predicate0 ); -* // returns 3 -*/ -declare function countIfs = InputArray>( x0: U, predicate0: Predicate ): number; - -/** -* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`. -* -* @param x0 - first input array -* @param predicate0 - first predicate function -* @param x1 - second input array -* @param predicate1 - second predicate function -* @returns result -* -* @example -* function predicate0( v ) { -* return v > 0; -* } -* -* function predicate1( v ) { -* return v < 0; -* } -* -* var x0 = [ 0, 1, 0, 1, 1 ]; -* var x1 = [ -1, 2, 4, -5, -8 ]; -* -* var n = countIfs( x0, predicate0, x1, predicate1 ); -* // returns 2 -*/ -declare function countIfs = InputArray>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate ): number; - -/** -* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`. -* -* @param x0 - first input array -* @param predicate0 - first predicate function -* @param x1 - second input array -* @param predicate1 - second predicate function -* @param x2 - third input array -* @param predicate2 - third predicate function -* @returns result -* -* @example -* function predicate0( v ) { -* return v > 0; -* } -* -* function predicate1( v ) { -* return v < 0; -* } -* -* function predicate2( v ) { -* return v % 2 === 0; -* } -* -* var x0 = [ 0, 1, 0, 1, 1 ]; -* var x1 = [ -1, -2, 4, 5, -8 ]; -* var x2 = [ 0, 4, 3, 2, 12 ]; -* -* var n = countIfs( x0, predicate0, x1, predicate1, x2, predicate2 ); -* // returns 2 -*/ -declare function countIfs = InputArray>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate ): number; - -/** -* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`. -* -* @param x0 - first input array -* @param predicate0 - first predicate function -* @param x1 - second input array -* @param predicate1 - second predicate function -* @param x2 - third input array -* @param predicate2 - third predicate function -* @param x3 - fourth input array -* @param predicate3 - fourth predicate function -* @returns result -* -* @example -* function predicate0( v ) { -* return v > 0; -* } -* -* function predicate1( v ) { -* return v < 0; -* } -* -* function predicate2( v ) { -* return v % 2 === 0; -* } -* -* function predicate3( v ) { -* return v % 2 !== 0; -* } -* -* var x0 = [ 0, 1, 0, 1, 1 ]; -* var x1 = [ -1, -2, 4, 5, -8 ]; -* var x2 = [ 0, 4, 3, 2, 12 ]; -* var x3 = [ 2, 9, 3, 6, 5 ]; -* -* var n = countIfs( x0, predicate0, x1, predicate1, x3, predicate3 ); -* // returns 2 -*/ -declare function countIfs = InputArray>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate ): number; - -/** -* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`. -* -* @param x0 - first input array -* @param predicate0 - first predicate function -* @param x1 - second input array -* @param predicate1 - second predicate function -* @param x2 - third input array -* @param predicate2 - third predicate function -* @param x3 - fourth input array -* @param predicate3 - fourth predicate function -* @param x4 - fifth input array -* @param predicate4 - fifth predicate function -* @param args - additional input arrays and predicate functions -* @returns result -* -* @example -* function predicate0( v ) { -* return v > 0; -* } -* -* function predicate1( v ) { -* return v < 0; -* } -* -* function predicate2( v ) { -* return v % 2 === 0; -* } -* -* function predicate3( v ) { -* return v % 2 !== 0; -* } -* -* function predicate4( v ) { -* return v === true; -* } -* -* var x0 = [ 0, 1, 0, 1, 1 ]; -* var x1 = [ -1, -2, 4, 5, -8 ]; -* var x2 = [ 0, 4, 3, 2, 12 ]; -* var x3 = [ 2, 9, 3, 6, 5 ]; -* var x4 = [ false, true, false, true, true ]; -* -* var n = countIfs( x0, predicate0, x1, predicate1, x3, predicate3, x4, predicate4 ); -* // returns 2 -*/ -declare function countIfs = InputArray>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate, x4: U, predicate4: Predicate, ...args: Array> ): number; - - -// EXPORTS // - -export = countIfs; diff --git a/base/count-ifs/docs/types/test.ts b/base/count-ifs/docs/types/test.ts deleted file mode 100644 index 64dd65ce0..000000000 --- a/base/count-ifs/docs/types/test.ts +++ /dev/null @@ -1,194 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import countIfs = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - -/** -* Tests whether a value is negative. -* -* @param value - input value -* @returns boolean indicating whether an element is negative -*/ -function isNegative( value: number ): boolean { - return ( value < 0 ); -} - - -// TESTS // - -// The function returns a number... -{ - const x = [ 1, 2, 3 ]; - const y = [ -1, -2, -3 ]; - - countIfs( x, isPositive ); // $ExpectType number - countIfs( x, isPositive, y, isNegative ); // $ExpectType number - countIfs( x, isPositive, x, isPositive, y, isNegative ); // $ExpectType number - countIfs( x, isPositive, x, isPositive, x, isPositive, y, isNegative ); // $ExpectType number - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, y, isNegative ); // $ExpectType number - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, isPositive, y, isNegative ); // $ExpectType number - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, isPositive, y, isNegative ); // $ExpectType number - - countIfs( new Float64Array( x ), isPositive, new Float64Array( y ), isNegative ); // $ExpectType number - countIfs( new Float32Array( x ), isPositive, new Float32Array( y ), isNegative ); // $ExpectType number - countIfs( new Int32Array( x ), isPositive, new Int32Array( y ), isNegative ); // $ExpectType number - countIfs( new Int16Array( x ), isPositive, new Int16Array( y ), isNegative ); // $ExpectType number - countIfs( new Int8Array( x ), isPositive, new Int8Array( y ), isNegative ); // $ExpectType number - countIfs( new Uint32Array( x ), isPositive, new Uint32Array( y ), isNegative ); // $ExpectType number - countIfs( new Uint16Array( x ), isPositive, new Uint16Array( y ), isNegative ); // $ExpectType number - countIfs( new Uint8Array( x ), isPositive, new Uint8Array( y ), isNegative ); // $ExpectType number - countIfs( new Uint8ClampedArray( x ), isPositive, new Uint8ClampedArray( y ), isNegative ); // $ExpectType number - countIfs( toAccessorArray( x ), isPositive, toAccessorArray( y ), isNegative ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - countIfs( 2, isPositive ); // $ExpectError - countIfs( false, isPositive ); // $ExpectError - countIfs( true, isPositive ); // $ExpectError - countIfs( {}, isPositive ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - const x = [ 1, 2, 3 ]; - - countIfs( x, 'abc' ); // $ExpectError - countIfs( x, 2 ); // $ExpectError - countIfs( x, false ); // $ExpectError - countIfs( x, true ); // $ExpectError - countIfs( x, null ); // $ExpectError - countIfs( x, void 0 ); // $ExpectError - countIfs( x, {} ); // $ExpectError - countIfs( x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - countIfs( x, isPositive, 2, isNegative ); // $ExpectError - countIfs( x, isPositive, false, isNegative ); // $ExpectError - countIfs( x, isPositive, true, isNegative ); // $ExpectError - countIfs( x, isPositive, {}, isNegative ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a function... -{ - const x = [ 1, 2, 3 ]; - - countIfs( x, isPositive, x, 'abc' ); // $ExpectError - countIfs( x, isPositive, x, 2 ); // $ExpectError - countIfs( x, isPositive, x, false ); // $ExpectError - countIfs( x, isPositive, x, true ); // $ExpectError - countIfs( x, isPositive, x, null ); // $ExpectError - countIfs( x, isPositive, x, void 0 ); // $ExpectError - countIfs( x, isPositive, x, {} ); // $ExpectError - countIfs( x, isPositive, x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - countIfs( x, isPositive, x, isPositive, 2, isNegative ); // $ExpectError - countIfs( x, isPositive, x, isPositive, false, isNegative ); // $ExpectError - countIfs( x, isPositive, x, isPositive, true, isNegative ); // $ExpectError - countIfs( x, isPositive, x, isPositive, {}, isNegative ); // $ExpectError -} - -// The compiler throws an error if the function is provided a sixth argument which is not a function... -{ - const x = [ 1, 2, 3 ]; - - countIfs( x, isPositive, x, isPositive, x, 'abc' ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, 2 ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, false ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, true ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, null ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, void 0 ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, {} ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a seventh argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - countIfs( x, isPositive, x, isPositive, x, isPositive, 2, isNegative ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, false, isNegative ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, true, isNegative ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, {}, isNegative ); // $ExpectError -} - -// The compiler throws an error if the function is provided an eighth argument which is not a function... -{ - const x = [ 1, 2, 3 ]; - - countIfs( x, isPositive, x, isPositive, x, isPositive, x, 'abc' ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, 2 ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, false ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, true ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, null ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, void 0 ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, {} ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a ninth argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, 2, isNegative ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, false, isNegative ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, true, isNegative ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, {}, isNegative ); // $ExpectError -} - -// The compiler throws an error if the function is provided a tenth argument which is not a function... -{ - const x = [ 1, 2, 3 ]; - - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, 'abc' ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, 2 ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, false ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, true ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, null ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, void 0 ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, {} ); // $ExpectError - countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - countIfs(); // $ExpectError - countIfs( x ); // $ExpectError -} diff --git a/base/count-ifs/examples/index.js b/base/count-ifs/examples/index.js deleted file mode 100644 index 3b148e70f..000000000 --- a/base/count-ifs/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var isNegativeInteger = require( '@stdlib/assert/is-negative-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var countIfs = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -console.log( x ); - -var y = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -console.log( y ); - -var out = countIfs( x, naryFunction( isPositiveInteger, 1 ), y, naryFunction( isNegativeInteger, 1 ) ); // eslint-disable-line max-len -console.log( out ); diff --git a/base/count-ifs/lib/index.js b/base/count-ifs/lib/index.js deleted file mode 100644 index 3b8632f51..000000000 --- a/base/count-ifs/lib/index.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Perform element-wise evaluation of one or more input arrays according to provided predicate functions and count the number of elements for which all predicates respectively return `true`. -* -* @module @stdlib/array/base/count-ifs -* -* @example -* var countIfs = require( '@stdlib/array/base/count-ifs' ); -* -* function predicate0( value ) { -* return ( value > 0 ); -* } -* -* function predicate1( value ) { -* return ( value < 3 ); -* } -* -* var x0 = [ 0, 1, 0, 1, 2 ]; -* var x1 = [ 2, 3, 1, 2, 5 ]; -* -* var n = countIfs( x0, predicate0, x1, predicate1 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/count-ifs/lib/main.js b/base/count-ifs/lib/main.js deleted file mode 100644 index 61e906562..000000000 --- a/base/count-ifs/lib/main.js +++ /dev/null @@ -1,175 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); -var zeroTo = require( './../../../base/zero-to' ); - - -// FUNCTIONS // - -/** -* Returns an array of indices corresponding to the elements of an input array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Array} idx - list of indices -* @param {Function} predicate - predicate function -* @returns {Array} updated list of indices -* -* @example -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var zeroTo = require( '@stdlib/array/base/zero-to' ); -* -* function predicate( v ) { -* return ( v > 0 ); -* } -* -* var x = arraylike2object( toAccessorArray( [ -1, 2, 3, -4, 5 ] ) ); -* var idx = zeroTo( 5 ); -* -* var out = accessors( x, idx, predicate ); -* // returns [ 1, 2, 4 ] -*/ -function accessors( x, idx, predicate ) { - var buf; - var get; - var i; - var j; - var k; - - buf = x.data; - get = x.accessors[ 0 ]; - - k = 0; - for ( i = 0; i < idx.length; i++ ) { - j = idx[ i ]; - if ( predicate( get( buf, j ), j, buf ) ) { - idx[ k ] = j; - k += 1; - } - } - idx.length = k; - return idx; -} - -/** -* Returns an array of indices corresponding to the elements of an input array which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Array} idx - list of indices -* @param {Function} predicate - predicate function -* @returns {Array} updated list of indices -* -* @example -* var zeroTo = require( '@stdlib/array/base/zero-to' ); -* -* function predicate( v ) { -* return ( v > 0 ); -* } -* -* var x = [ -1, 2, 3, -4, 5 ]; -* var idx = zeroTo( 5 ); -* -* var out = indexed( x, idx, predicate ); -* // returns [ 1, 2, 4 ] -*/ -function indexed( x, idx, predicate ) { - var i; - var j; - var k; - - k = 0; - for ( i = 0; i < idx.length; i++ ) { - j = idx[ i ]; - if ( predicate( x[ j ], j, x ) ) { - idx[ k ] = j; - k += 1; - } - } - idx.length = k; - return idx; -} - - -// MAIN // - -/** -* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`. -* -* @param {Collection} x0 - first input array -* @param {Function} predicate0 - first predicate function -* @param {Collection} [x1] - second input array -* @param {Function} [predicate1] - second predicate function -* @param {Collection} [x2] - third input array -* @param {Function} [predicate2] - third predicate function -* @param {...(Collection|Function)} [args] - additional input arrays and predicate functions -* @returns {NonNegativeInteger} result -* -* @example -* function predicate0( value ) { -* return ( value > 0 ); -* } -* -* function predicate1( value ) { -* return ( value < 3 ); -* } -* -* var x0 = [ 0, 1, 0, 1, 2 ]; -* var x1 = [ 2, 3, 1, 2, 5 ]; -* -* var n = countIfs( x0, predicate0, x1, predicate1 ); -* // returns 1 -*/ -function countIfs() { - var predicates; - var arrays; - var len; - var idx; - var x; - var i; - - arrays = []; - predicates = []; - for ( i = 0; i < arguments.length; i += 2 ) { - arrays.push( arraylike2object( arguments[ i ] ) ); - predicates.push( arguments[ i+1 ] ); - } - - len = arguments[ 0 ].length; - idx = zeroTo( len ); - for ( i = 0; i < arrays.length; i++ ) { - x = arrays[ i ]; - if ( x.accessorProtocol ) { - idx = accessors( x, idx, predicates[ i ] ); - } else { - idx = indexed( x.data, idx, predicates[ i ] ); - } - } - return idx.length; -} - - -// EXPORTS // - -module.exports = countIfs; diff --git a/base/count-ifs/package.json b/base/count-ifs/package.json deleted file mode 100644 index d09fedd5e..000000000 --- a/base/count-ifs/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/count-ifs", - "version": "0.0.0", - "description": "Perform element-wise evaluation of one or more input arrays according to provided predicate functions and count the number of elements for which all predicates respectively return `true`.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "array", - "count", - "sum", - "summation", - "countif", - "countifs", - "range", - "total", - "truthy" - ] -} diff --git a/base/count-ifs/test/test.js b/base/count-ifs/test/test.js deleted file mode 100644 index d7ae9259f..000000000 --- a/base/count-ifs/test/test.js +++ /dev/null @@ -1,222 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Int32Array = require( './../../../int32' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var countIfs = require( './../lib' ); - - -// FUNCTIONS // - -function predicate0( value ) { - return value > 0; -} - -function predicate1( value ) { - return value < 0; -} - -function predicate2( value ) { - return value < 3; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countIfs, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of elements in the input arrays which simultaneously pass tests implemented by predicate functions (narrays=1,generic)', function test( t ) { - var actual; - var x0; - - x0 = [ 0, 1, 0, 1, 2 ]; - actual = countIfs( x0, predicate0 ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements in the input arrays which simultaneously pass tests implemented by predicate functions (narrays=1,accessors)', function test( t ) { - var actual; - var x0; - - x0 = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - actual = countIfs( x0, predicate0 ); - - t.strictEqual( actual, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements in the input arrays which simultaneously pass tests implemented by predicate functions (narrays=2,generic)', function test( t ) { - var actual; - var x0; - var x1; - - x0 = [ 0, 1, 0, 1, 2 ]; - x1 = [ 3, -4, -1, 2, -8 ]; - actual = countIfs( x0, predicate0, x1, predicate1 ); - - t.strictEqual( actual, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements in the input arrays which simultaneously pass tests implemented by predicate functions (narrays=2,accessors)', function test( t ) { - var actual; - var x0; - var x1; - - x0 = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - x1 = toAccessorArray( [ 3, -4, -1, 2, -8 ] ); - actual = countIfs( x0, predicate0, x1, predicate1 ); - - t.strictEqual( actual, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements in the input arrays which simultaneously pass tests implemented by predicate functions (narrays=2,real typed array)', function test( t ) { - var actual; - var x0; - var x1; - - x0 = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - x1 = new Int32Array( [ 3, -4, -1, 2, -8 ] ); - actual = countIfs( x0, predicate0, x1, predicate1 ); - - t.strictEqual( actual, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements in the input arrays which simultaneously pass tests implemented by predicate functions (narrays=2,complex typed array)', function test( t ) { - var actual; - var x0; - var x1; - - x0 = new Complex128Array( [ 3.0, 1.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - x1 = new Complex128Array( [ -2.0, -5.0, -3.0, 1.0, -5.0, -1.0, 0.0, 4.0 ] ); - actual = countIfs( x0, predicate0, x1, predicate1 ); - - t.strictEqual( actual, 2, 'returns expected value' ); - t.end(); - - function predicate0( value ) { - return ( - real( value ) > 0 && - imag( value ) > 0 - ); - } - function predicate1( value ) { - return ( - real( value ) < 0 && - imag( value ) < 0 - ); - } -}); - -tape( 'the function counts the number of elements in the input arrays which simultaneously pass tests implemented by predicate functions (narrays=3,generic)', function test( t ) { - var actual; - var x0; - var x1; - var x2; - - x0 = [ 0, 1, 0, 1, 2 ]; - x1 = [ 3, -4, -1, 2, -8 ]; - x2 = [ 1, 2, 3, 4, 5 ]; - actual = countIfs( x0, predicate0, x1, predicate1, x2, predicate2 ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of elements in the input arrays which simultaneously pass tests implemented by predicate functions (narrays=3,accessors)', function test( t ) { - var actual; - var x0; - var x1; - var x2; - - x0 = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - x1 = toAccessorArray( [ 3, -4, -1, 2, -8 ] ); - x2 = toAccessorArray( [ 1, 2, 3, 4, 5 ] ); - actual = countIfs( x0, predicate0, x1, predicate1, x2, predicate2 ); - - t.strictEqual( actual, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements at the same indices pass tests implemented by predicate functions (generic)', function test( t ) { - var actual; - var x0; - var x1; - - x0 = [ -3, -2, -5, -1 ]; - x1 = [ 2, 4, 5, 8 ]; - actual = countIfs( x0, predicate0, x1, predicate1 ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `0` if no elements at the same indices pass tests implemented by predicate functions (accessors)', function test( t ) { - var actual; - var x0; - var x1; - - x0 = toAccessorArray( [ -3, -2, -5, -1 ] ); - x1 = toAccessorArray( [ 2, 4, 5, 8 ] ); - actual = countIfs( x0, predicate0, x1, predicate1 ); - - t.strictEqual( actual, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements if all elements in every input array pass tests implemented by predicate functions (generic)', function test( t ) { - var actual; - var x0; - var x1; - - x0 = [ 1, 1, 1, 1 ]; - x1 = [ -1, -1, -1, -1 ]; - actual = countIfs( x0, predicate0, x1, predicate1 ); - - t.strictEqual( actual, x0.length, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the number of elements if all elements in every input array pass tests implemented by predicate functions (accessors)', function test( t ) { - var actual; - var x0; - var x1; - - x0 = toAccessorArray( [ 1, 1, 1, 1 ] ); - x1 = toAccessorArray( [ -1, -1, -1, -1 ] ); - actual = countIfs( x0, predicate0, x1, predicate1 ); - - t.strictEqual( actual, x0.length, 'returns expected value' ); - t.end(); -}); diff --git a/base/count-same-value-zero/README.md b/base/count-same-value-zero/README.md deleted file mode 100644 index b63c863bf..000000000 --- a/base/count-same-value-zero/README.md +++ /dev/null @@ -1,133 +0,0 @@ - - -# countSameValueZero - -> Count the number of elements in an array that are equal to a specified value. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ); -``` - -#### countSameValueZero( x, value ) - -Counts the number of elements in an array that are equal to a specified value. - -```javascript -var x = [ 0, 1, 0, 1, 2 ]; - -var out = countSameValueZero( x, 1 ); -// returns 2 -``` - -In contrast to an implementation using the strict equality operator `===`, the function treats `NaNs` as the same value. - -```javascript -var x = [ NaN, NaN, NaN ]; - -var out = countSameValueZero( x, NaN ); -// returns 3 -``` - -In contrast to an implementation using the [SameValue Algorithm][@stdlib/array/base/count-same-value] (as specified in ECMAScript 5), the function does not distinguish between `+0` and `-0`. - -```javascript -var x = [ 0.0, -0.0, 0.0 ]; - -var out = countSameValueZero( x, 0.0 ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ); - -var x = bernoulli( 10, 0.5, { - 'dtype': 'generic' -}); -console.log( x ); - -var n = countSameValueZero( x, 1 ); -console.log( n ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/count-same-value-zero/benchmark/benchmark.length.js b/base/count-same-value-zero/benchmark/benchmark.length.js deleted file mode 100644 index 3fbcff2a3..000000000 --- a/base/count-same-value-zero/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var countSameValueZero = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countSameValueZero( x, 1 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/count-same-value-zero/docs/repl.txt b/base/count-same-value-zero/docs/repl.txt deleted file mode 100644 index f74b77f67..000000000 --- a/base/count-same-value-zero/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( x, value ) - Counts the number of elements in an array that are equal to a specified - value. - - The function treats `NaN` values as the same value. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - value: any - Input value. - - Returns - ------- - out: integer - Number of elements that are equal to a specified value. - - Examples - -------- - > var out = {{alias}}( [ 0, 1, 1 ], 1 ) - 2 - - See Also - -------- - diff --git a/base/count-same-value-zero/docs/types/index.d.ts b/base/count-same-value-zero/docs/types/index.d.ts deleted file mode 100644 index 4ba495962..000000000 --- a/base/count-same-value-zero/docs/types/index.d.ts +++ /dev/null @@ -1,47 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Counts the number of elements in an array that are equal to a specified value. -* -* ## Notes -* -* - In contrast to an implementation based on the strict equality operator `===`, the function treats `NaNs` as the same value. -* -* @param x - input array -* @param value - search value -* @returns number of elements that are equal to a specified value -* -* @example -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var out = countSameValueZero( x, 1 ); -* // returns 3 -*/ -declare function countSameValueZero( x: Collection, value: any ): number; - - -// EXPORTS // - -export = countSameValueZero; diff --git a/base/count-same-value-zero/docs/types/test.ts b/base/count-same-value-zero/docs/types/test.ts deleted file mode 100644 index e385f56bd..000000000 --- a/base/count-same-value-zero/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import countSameValueZero = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - countSameValueZero( [ 1, 2, 3 ], 1 ); // $ExpectType number -} - -// The compiler throws an error if the first argument is not a collection... -{ - countSameValueZero( 5, 1 ); // $ExpectError - countSameValueZero( true, 1 ); // $ExpectError - countSameValueZero( false, 1 ); // $ExpectError - countSameValueZero( null, 1 ); // $ExpectError - countSameValueZero( {}, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countSameValueZero(); // $ExpectError - countSameValueZero( [ 1, 2, 3 ] ); // $ExpectError - countSameValueZero( [ 1, 2, 3 ], 2, 3 ); // $ExpectError -} diff --git a/base/count-same-value-zero/examples/index.js b/base/count-same-value-zero/examples/index.js deleted file mode 100644 index 27e165dc2..000000000 --- a/base/count-same-value-zero/examples/index.js +++ /dev/null @@ -1,30 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var countSameValueZero = require( './../lib' ); - -var x = bernoulli( 10, 0.5, { - 'dtype': 'generic' -}); -console.log( x ); - -var n = countSameValueZero( x, 1 ); -console.log( n ); diff --git a/base/count-same-value-zero/lib/index.js b/base/count-same-value-zero/lib/index.js deleted file mode 100644 index a115d7736..000000000 --- a/base/count-same-value-zero/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Count the number of elements in an array that are equal to a specified value. -* -* @module @stdlib/array/base/count-same-value-zero -* -* @example -* var countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ); -* -* var x = [ 0, 0, 1, 0, 1 ]; -* -* var n = countSameValueZero( x, 1 ); -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/count-same-value-zero/lib/main.js b/base/count-same-value-zero/lib/main.js deleted file mode 100644 index b95d963f9..000000000 --- a/base/count-same-value-zero/lib/main.js +++ /dev/null @@ -1,214 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexTypedArray = require( './../../../base/assert/is-complex-typed-array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var isSameValueZero = require( '@stdlib/assert/is-same-value-zero' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an indexed array that are equal to a specified value. -* -* @private -* @param {Collection} x - input array -* @param {*} value - search value -* @returns {NonNegativeInteger} number of elements that are equal to a specified value -* -* @example -* var x = [ 0, 0, 1, 0, 1 ]; -* -* var n = indexed( x, 0 ); -* // returns 3 -*/ -function indexed( x, value ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( isSameValueZero( x[ i ], value ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array that are equal to a specified value. -* -* @private -* @param {Collection} x - input array -* @param {*} value - search value -* @returns {NonNegativeInteger} number of elements that are equal to a specified value -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 0, 0, 1, 0, 1 ] ); -* -* var n = accessors( x, 0 ); -* // returns 3 -*/ -function accessors( x, value ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( isSameValueZero( get( x, i ), value ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in a complex array that are equal to a specified value. -* -* @private -* @param {Collection} x - input array -* @param {*} value - search value -* @returns {NonNegativeInteger} number of elements that are equal to a specified value -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] ); -* -* var n = complex( x, new Complex128( 1.0, 2.0 ) ); -* // returns 1 -*/ -function complex( x, value ) { - var view; - var re; - var im; - var n; - var i; - - if ( !isComplexLike( value ) ) { - return 0; - } - re = real( value ); - im = imag( value ); - - view = reinterpret( x, 0 ); - - n = 0; - for ( i = 0; i < view.length; i += 2 ) { - if ( isSameValueZero( view[ i ], re ) && isSameValueZero( view[ i+1 ], im ) ) { // eslint-disable-line max-len - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in a boolean array that are equal to a specified value. -* -* @private -* @param {Collection} x - input array -* @param {*} value - search value -* @returns {NonNegativeInteger} number of elements that are equal to a specified value -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var x = new BooleanArray( [ true, false, true, false, true ] ); -* -* var n = boolean( x, true ); -* // returns 3 -*/ -function boolean( x, value ) { - var view; - var n; - var v; - var i; - - if ( !isBoolean( value ) ) { - return 0; - } - view = reinterpretBoolean( x, 0 ); - - v = ( value ) ? 1 : 0; - n = 0; - for ( i = 0; i < view.length; i++ ) { - if ( view[ i ] === v ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array that are equal to a specified value. -* -* ## Notes -* -* - The function uses the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016. -* - In contrast to an implementation based on the strict equality operator `===`, the function treats `NaNs` as the same value. -* -* @param {Collection} x - input array -* @param {*} value - search value -* @returns {NonNegativeInteger} number of elements that are equal to a specified value -* -* @example -* var countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ); -* -* var x = [ 0, 0, 1, 0, 1 ]; -* -* var n = countSameValueZero( x, 1 ); -* // returns 2 -*/ -function countSameValueZero( x, value ) { - if ( isAccessorArray( x ) ) { - if ( isComplexTypedArray( x ) ) { - return complex( x, value ); - } - if ( isBooleanArray( x ) ) { - return boolean( x, value ); - } - return accessors( x, value ); - } - return indexed( x, value ); -} - - -// EXPORTS // - -module.exports = countSameValueZero; diff --git a/base/count-same-value-zero/package.json b/base/count-same-value-zero/package.json deleted file mode 100644 index 7ac01393e..000000000 --- a/base/count-same-value-zero/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/count-same-value-zero", - "version": "0.0.0", - "description": "Count the number of elements in an array that are equal to a specified value.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "count", - "sum", - "summation", - "countif", - "total", - "same", - "equal" - ] -} diff --git a/base/count-same-value-zero/test/test.js b/base/count-same-value-zero/test/test.js deleted file mode 100644 index 68565490f..000000000 --- a/base/count-same-value-zero/test/test.js +++ /dev/null @@ -1,225 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex128Array = require( './../../../complex128' ); -var BooleanArray = require( './../../../bool' ); -var Int32Array = require( './../../../int32' ); -var Float32Array = require( './../../../float32' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var countSameValueZero = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countSameValueZero, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of same values (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - expected = 2; - actual = countSameValueZero( x, 1 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function considers positive and negative zeros to be identical (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ]; - expected = 5; - actual = countSameValueZero( x, 0.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function considers all NaN values to be identical (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ]; - expected = 4; - actual = countSameValueZero( x, NaN ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of same values (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - expected = 2; - actual = countSameValueZero( x, 1 ); - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function considers positive and negative zeros to be identical (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ] ); - expected = 5; - actual = countSameValueZero( x, 0.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function considers all NaN values to be identical (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ] ); - expected = 4; - actual = countSameValueZero( x, NaN ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of same values (real typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - expected = 2; - actual = countSameValueZero( x, 1 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function considers positive and negative zeros to be identical (real typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float32Array( [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ] ); - expected = 5; - actual = countSameValueZero( x, 0.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function considers all NaN values to be identical (real typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float32Array( [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ] ); - expected = 4; - actual = countSameValueZero( x, NaN ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of same values (boolean array)', function test( t ) { - var expected; - var actual; - var x; - - x = new BooleanArray( [ true, false, true, false, true ] ); - expected = 3; - actual = countSameValueZero( x, true ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true, false, true ] ); - expected = 2; - actual = countSameValueZero( x, false ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true, false, true ] ); - expected = 0; - actual = countSameValueZero( x, 'beep' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of same values (complex typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - expected = 1; - actual = countSameValueZero( x, new Complex128( 3.0, 4.0 ) ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - expected = 0; - actual = countSameValueZero( x, 0.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function considers positive and negative zeros to be identical (complex typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 0.0, -0.0, 0.0, -0.0, 0.0, 0.0, -0.0, -0.0, -0.0, 0.0 ] ); // eslint-disable-line max-len - expected = 5; - actual = countSameValueZero( x, new Complex128( 0.0, -0.0 ) ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function considers all NaN values to be identical (complex typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ NaN, NaN, NaN, 2.0, NaN, 9.0, NaN, NaN ] ); - expected = 2; - actual = countSameValueZero( x, new Complex128( NaN, NaN ) ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/count-same-value/README.md b/base/count-same-value/README.md deleted file mode 100644 index 33ca402bd..000000000 --- a/base/count-same-value/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# countSameValue - -> Count the number of elements in an array that are equal to a specified value. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var countSameValue = require( '@stdlib/array/base/count-same-value' ); -``` - -#### countSameValue( x, value ) - -Counts the number of elements in an array that are equal to a specified value. - -```javascript -var x = [ 0, 1, 0, 1, 2 ]; - -var out = countSameValue( x, 1 ); -// returns 2 -``` - -In contrast to an implementation using the strict equality operator `===`, the function distinguishes between `+0` and `-0` and treats `NaNs` as the same value. - -```javascript -var x = [ NaN, NaN, NaN ]; - -var out = countSameValue( x, NaN ); -// returns 3 -``` - -
- - - - - -
- -## Notes - -- The function uses the [SameValue Algorithm][@stdlib/assert/is-same-value] as specified in ECMAScript 5. - -
- - - - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var countSameValue = require( '@stdlib/array/base/count-same-value' ); - -var x = bernoulli( 10, 0.5, { - 'dtype': 'generic' -}); -console.log( x ); - -var n = countSameValue( x, 1 ); -console.log( n ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/count-same-value/benchmark/benchmark.length.js b/base/count-same-value/benchmark/benchmark.length.js deleted file mode 100644 index 8cc24d234..000000000 --- a/base/count-same-value/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var countSameValue = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countSameValue( x, 1 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/count-same-value/docs/repl.txt b/base/count-same-value/docs/repl.txt deleted file mode 100644 index 5fdd65f6d..000000000 --- a/base/count-same-value/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( x, value ) - Counts the number of elements in an array that are equal to a specified - value. - - The function treats `-0` and `+0` as distinct and `NaNs` as the same. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - value: any - Input value. - - Returns - ------- - out: integer - Number of elements that are equal to the specified value. - - Examples - -------- - > var out = {{alias}}( [ 0, 1, 1 ], 1 ) - 2 - - See Also - -------- - diff --git a/base/count-same-value/docs/types/index.d.ts b/base/count-same-value/docs/types/index.d.ts deleted file mode 100644 index 24ccc5ab2..000000000 --- a/base/count-same-value/docs/types/index.d.ts +++ /dev/null @@ -1,50 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Counts the number of elements in an array that are equal to a specified value. -* -* ## Notes -* -* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. -* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. -* -* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 -* -* @param x - input array -* @param value - search value -* @returns number of elements that are equal to a specified value -* -* @example -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var out = countSameValue( x, 1 ); -* // returns 3 -*/ -declare function countSameValue( x: Collection, value: any ): number; - - -// EXPORTS // - -export = countSameValue; diff --git a/base/count-same-value/docs/types/test.ts b/base/count-same-value/docs/types/test.ts deleted file mode 100644 index 0e1329455..000000000 --- a/base/count-same-value/docs/types/test.ts +++ /dev/null @@ -1,43 +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. -*/ - -import countSameValue = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - countSameValue( [ 1, 2, 3 ], 1 ); // $ExpectType number -} - -// The compiler throws an error if the first argument is not a collection... -{ - countSameValue( 5, 1 ); // $ExpectError - countSameValue( true, 1 ); // $ExpectError - countSameValue( false, 1 ); // $ExpectError - countSameValue( null, 1 ); // $ExpectError - countSameValue( {}, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countSameValue(); // $ExpectError - countSameValue( [ 1, 2, 3 ] ); // $ExpectError - countSameValue( [ 1, 2, 3 ], 2, 3 ); // $ExpectError -} diff --git a/base/count-same-value/examples/index.js b/base/count-same-value/examples/index.js deleted file mode 100644 index 7306f2b03..000000000 --- a/base/count-same-value/examples/index.js +++ /dev/null @@ -1,30 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var countSameValue = require( './../lib' ); - -var x = bernoulli( 10, 0.5, { - 'dtype': 'generic' -}); -console.log( x ); - -var n = countSameValue( x, 1 ); -console.log( n ); diff --git a/base/count-same-value/lib/index.js b/base/count-same-value/lib/index.js deleted file mode 100644 index 9e28a14dd..000000000 --- a/base/count-same-value/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Count the number of elements in an array that are equal to a specified value. -* -* @module @stdlib/array/base/count-same-value -* -* @example -* var countSameValue = require( '@stdlib/array/base/count-same-value' ); -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countSameValue( x, 1 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/count-same-value/lib/main.js b/base/count-same-value/lib/main.js deleted file mode 100644 index cadd72ecb..000000000 --- a/base/count-same-value/lib/main.js +++ /dev/null @@ -1,214 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var isComplexTypedArray = require( './../../../base/assert/is-complex-typed-array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var isSameValue = require( '@stdlib/assert/is-same-value' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - - -// FUNCTIONS // - -/** -* Counts the number of elements in an array that are equal to a specified value. -* -* @private -* @param {Collection} x - input array -* @param {*} value - search value -* @returns {NonNegativeInteger} number of elements that are equal to a specified value -* -* @example -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = indexed( x, 1 ); -* // returns 3 -*/ -function indexed( x, value ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( isSameValue( x[ i ], value ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in an accessor array that are equal to a specified value. -* -* @private -* @param {Collection} x - input array -* @param {*} value - search value -* @returns {NonNegativeInteger} number of elements that are equal to a provided value -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] ); -* -* var n = accessors( x, 1 ); -* // returns 3 -*/ -function accessors( x, value ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( isSameValue( get( x, i ), value ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in a complex array that are equal to a specified value. -* -* @private -* @param {Collection} x - input array -* @param {*} value - search value -* @returns {NonNegativeInteger} number of elements that are equal to a specified value -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] ); -* -* var n = complex( x, new Complex128( 1.0, 2.0 ) ); -* // returns 1 -*/ -function complex( x, value ) { - var view; - var re; - var im; - var n; - var i; - - if ( !isComplexLike( value ) ) { - return 0; - } - re = real( value ); - im = imag( value ); - - view = reinterpret( x, 0 ); - - n = 0; - for ( i = 0; i < view.length; i += 2 ) { - if ( isSameValue( view[ i ], re ) && isSameValue( view[ i+1 ], im ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of elements in a boolean array that are equal to a specified value. -* -* @private -* @param {Collection} x - input array -* @param {*} value - search value -* @returns {NonNegativeInteger} number of elements that are equal to a specified value -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var x = new BooleanArray( [ true, false, true, false, true ] ); -* -* var n = boolean( x, true ); -* // returns 3 -*/ -function boolean( x, value ) { - var view; - var n; - var v; - var i; - - if ( !isBoolean( value ) ) { - return 0; - } - view = reinterpretBoolean( x, 0 ); - - v = ( value ) ? 1 : 0; - n = 0; - for ( i = 0; i < view.length; i++ ) { - if ( view[ i ] === v ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of elements in an array that are equal to a specified value. -* -* ## Notes -* -* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. -* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. -* -* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 -* -* @param {Collection} x - input array -* @param {*} value - search value -* @returns {NonNegativeInteger} number of elements that are equal to a specified value -* -* @example -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countSameValue( x, 1 ); -* // returns 3 -*/ -function countSameValue( x, value ) { - if ( isAccessorArray( x ) ) { - if ( isComplexTypedArray( x ) ) { - return complex( x, value ); - } - if ( isBooleanArray( x ) ) { - return boolean( x, value ); - } - return accessors( x, value ); - } - return indexed( x, value ); -} - - -// EXPORTS // - -module.exports = countSameValue; diff --git a/base/count-same-value/package.json b/base/count-same-value/package.json deleted file mode 100644 index 731e0336c..000000000 --- a/base/count-same-value/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/count-same-value", - "version": "0.0.0", - "description": "Count the number of elements in an array that are equal to a specified value.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "count", - "sum", - "summation", - "countif", - "total", - "same", - "equal" - ] -} diff --git a/base/count-same-value/test/test.js b/base/count-same-value/test/test.js deleted file mode 100644 index 5debea405..000000000 --- a/base/count-same-value/test/test.js +++ /dev/null @@ -1,241 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex128Array = require( './../../../complex128' ); -var BooleanArray = require( './../../../bool' ); -var Int32Array = require( './../../../int32' ); -var Float32Array = require( './../../../float32' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var countSameValue = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countSameValue, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of same values (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - expected = 2; - actual = countSameValue( x, 1 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function distinguishes between positive and negative zeros (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ]; - - expected = 3; - actual = countSameValue( x, 0.0 ); - t.strictEqual( actual, expected, 'returns expected value' ); - - expected = 2; - actual = countSameValue( x, -0.0 ); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function considers all NaN values to be identical (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ]; - expected = 4; - actual = countSameValue( x, NaN ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of same values (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - expected = 2; - actual = countSameValue( x, 1 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function distinguishes between positive and negative zeros (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ] ); - - expected = 3; - actual = countSameValue( x, 0.0 ); - t.strictEqual( actual, expected, 'returns expected value' ); - - expected = 2; - actual = countSameValue( x, -0.0 ); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function considers all NaN values to be identical (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ] ); - expected = 4; - actual = countSameValue( x, NaN ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of same values (real typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - expected = 2; - actual = countSameValue( x, 1 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function distinguishes between positive and negative zeros (real typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float32Array( [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ] ); - - expected = 3; - actual = countSameValue( x, 0.0 ); - t.strictEqual( actual, expected, 'returns expected value' ); - - expected = 2; - actual = countSameValue( x, -0.0 ); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function considers all NaN values to be identical (real typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float32Array( [ NaN, 0.0, NaN, 2.0, NaN, 9.0, NaN ] ); - expected = 4; - actual = countSameValue( x, NaN ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of same values (boolean array)', function test( t ) { - var expected; - var actual; - var x; - - x = new BooleanArray( [ true, false, true, false, true ] ); - expected = 3; - actual = countSameValue( x, true ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true, false, true ] ); - expected = 2; - actual = countSameValue( x, false ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true, false, true ] ); - expected = 0; - actual = countSameValue( x, 'beep' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of same values (complex typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - expected = 1; - actual = countSameValue( x, new Complex128( 3.0, 4.0 ) ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - expected = 0; - actual = countSameValue( x, 0.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function distinguishes between positive and negative zeros (complex typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 0.0, -0.0, 0.0, -0.0, 0.0, 0.0, -0.0, -0.0, -0.0, 0.0 ] ); // eslint-disable-line max-len - expected = 2; - actual = countSameValue( x, new Complex128( 0.0, -0.0 ) ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function considers all NaN values to be identical (complex typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ NaN, NaN, NaN, 2.0, NaN, 9.0, NaN, NaN ] ); - expected = 2; - actual = countSameValue( x, new Complex128( NaN, NaN ) ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/count-truthy/README.md b/base/count-truthy/README.md deleted file mode 100644 index 77e075d46..000000000 --- a/base/count-truthy/README.md +++ /dev/null @@ -1,113 +0,0 @@ - - -# countTruthy - -> Count the number of truthy elements in an array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var countTruthy = require( '@stdlib/array/base/count-truthy' ); -``` - -#### countTruthy( x ) - -Counts the number of truthy elements in an array. - -```javascript -var x = [ 0, 1, 0, 1, 2 ]; - -var out = countTruthy( x ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var countTruthy = require( '@stdlib/array/base/count-truthy' ); - -var x = bernoulli( 100, 0.5, { - 'dtype': 'generic' -}); -console.log( x ); - -var n = countTruthy( x ); -console.log( n ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/count-truthy/benchmark/benchmark.length.js b/base/count-truthy/benchmark/benchmark.length.js deleted file mode 100644 index 18ab265eb..000000000 --- a/base/count-truthy/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var pkg = require( './../package.json' ).name; -var countTruthy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = bernoulli( len, 0.5, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = countTruthy( x ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( out ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/count-truthy/docs/repl.txt b/base/count-truthy/docs/repl.txt deleted file mode 100644 index 5c73febaf..000000000 --- a/base/count-truthy/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( x ) - Counts the number of truthy values in an array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: integer - Number of truthy values. - - Examples - -------- - > var out = {{alias}}( [ 0, 1, 1 ] ) - 2 - - See Also - -------- - diff --git a/base/count-truthy/docs/types/index.d.ts b/base/count-truthy/docs/types/index.d.ts deleted file mode 100644 index eaf1537f4..000000000 --- a/base/count-truthy/docs/types/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Counts the number of truthy values in an array. -* -* @param x - input array -* @returns number of truthy values -* -* @example -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var out = countTruthy( x ); -* // returns 3 -*/ -declare function countTruthy( x: Collection ): number; - - -// EXPORTS // - -export = countTruthy; diff --git a/base/count-truthy/docs/types/test.ts b/base/count-truthy/docs/types/test.ts deleted file mode 100644 index 78c86aa70..000000000 --- a/base/count-truthy/docs/types/test.ts +++ /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. -*/ - -import countTruthy = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - countTruthy( [ 1, 2, 3 ] ); // $ExpectType number -} - -// The compiler throws an error if the function is provided an argument which is not a collection... -{ - countTruthy( 5 ); // $ExpectError - countTruthy( true ); // $ExpectError - countTruthy( false ); // $ExpectError - countTruthy( null ); // $ExpectError - countTruthy( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - countTruthy(); // $ExpectError - countTruthy( [ 1, 2, 3 ], 2 ); // $ExpectError -} diff --git a/base/count-truthy/examples/index.js b/base/count-truthy/examples/index.js deleted file mode 100644 index 4ca60900e..000000000 --- a/base/count-truthy/examples/index.js +++ /dev/null @@ -1,30 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var countTruthy = require( './../lib' ); - -var x = bernoulli( 100, 0.5, { - 'dtype': 'generic' -}); -console.log( x ); - -var n = countTruthy( x ); -console.log( n ); diff --git a/base/count-truthy/lib/index.js b/base/count-truthy/lib/index.js deleted file mode 100644 index 576381a13..000000000 --- a/base/count-truthy/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Count the number of truthy values in an array. -* -* @module @stdlib/array/base/count-truthy -* -* @example -* var countTruthy = require( '@stdlib/array/base/count-truthy' ); -* -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countTruthy( x ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/count-truthy/lib/main.js b/base/count-truthy/lib/main.js deleted file mode 100644 index 8d818b56a..000000000 --- a/base/count-truthy/lib/main.js +++ /dev/null @@ -1,152 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexTypedArray = require( './../../../base/assert/is-complex-typed-array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var reinterpretComplex = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Counts the number of truthy values in an indexed array. -* -* @private -* @param {Collection} x - input array -* @returns {NonNegativeInteger} number of truthy values -* -* @example -* var x = [ 0, 1, 0, 1 ]; -* -* var n = indexed( x ); -* // returns 2 -*/ -function indexed( x ) { - var n; - var i; - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( x[ i ] ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of truthy values in an accessor array. -* -* @private -* @param {Collection} x - input array -* @returns {NonNegativeInteger} number of truthy values -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var n = accessors( x ); -* // returns 2 -*/ -function accessors( x ) { - var get; - var n; - var i; - - get = resolveGetter( x ); - - n = 0; - for ( i = 0; i < x.length; i++ ) { - if ( get( x, i ) ) { - n += 1; - } - } - return n; -} - -/** -* Counts the number of truthy values in a complex array. -* -* @private -* @param {Collection} x - input array -* @returns {NonNegativeInteger} number of truthy values -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] ); -* -* var n = complex( x ); -* // returns 2 -*/ -function complex( x ) { - var view; - var n; - var i; - - view = reinterpretComplex( x, 0 ); - - n = 0; - for ( i = 0; i < view.length; i += 2 ) { - if ( view[ i ] || view[ i+1 ] ) { - n += 1; - } - } - return n; -} - - -// MAIN // - -/** -* Counts the number of truthy values in an array. -* -* @param {Collection} x - input array -* @returns {NonNegativeInteger} number of truthy values -* -* @example -* var x = [ 0, 1, 0, 1, 1 ]; -* -* var n = countTruthy( x ); -* // returns 3 -*/ -function countTruthy( x ) { - if ( isAccessorArray( x ) ) { - if ( isBooleanArray( x ) ) { - return indexed( reinterpretBoolean( x, 0 ) ); - } - if ( isComplexTypedArray( x ) ) { - return complex( x ); - } - return accessors( x ); - } - return indexed( x ); -} - - -// EXPORTS // - -module.exports = countTruthy; diff --git a/base/count-truthy/package.json b/base/count-truthy/package.json deleted file mode 100644 index d081e487d..000000000 --- a/base/count-truthy/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/count-truthy", - "version": "0.0.0", - "description": "Count the number of truthy elements in an array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "count", - "sum", - "summation", - "countif", - "total", - "truthy" - ] -} diff --git a/base/count-truthy/test/test.js b/base/count-truthy/test/test.js deleted file mode 100644 index e3298ccbf..000000000 --- a/base/count-truthy/test/test.js +++ /dev/null @@ -1,132 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var BooleanArray = require( './../../../bool' ); -var Int32Array = require( './../../../int32' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var countTruthy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof countTruthy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 0, 1, 0, 1, 2 ]; - expected = 3; - actual = countTruthy( x ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); - expected = 3; - actual = countTruthy( x ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values (real typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); - expected = 3; - actual = countTruthy( x ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values (complex typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); - expected = 3; - actual = countTruthy( x ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function counts the number of truthy values (boolean typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new BooleanArray( [ true, true, false, true ] ); - expected = 3; - actual = countTruthy( x ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns zero if provided an array of length `0`', function test( t ) { - var expected; - var actual; - var x; - - expected = 0; - - x = []; - actual = countTruthy( x ); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - actual = countTruthy( x ); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [] ); - actual = countTruthy( x ); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [] ); - actual = countTruthy( x ); - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [] ); - actual = countTruthy( x ); - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/cuany-by-right/README.md b/base/cuany-by-right/README.md deleted file mode 100644 index e17d5b78c..000000000 --- a/base/cuany-by-right/README.md +++ /dev/null @@ -1,152 +0,0 @@ - - -# cuanyByRight - -> Cumulatively test whether at least one element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left. - -
- -## Usage - -```javascript -var cuanyByRight = require( '@stdlib/array/base/cuany-by-right' ); -``` - -#### cuanyByRight( x, predicate\[, thisArg] ) - -Cumulatively tests whether at least one element in a provided array passes a test implemented by a `predicate` function, while iterating from right-to-left. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 0, 0, 0, 1, 0 ]; - -var y = cuanyByRight( x, isPositive ); -// returns [ false, true, true, true, true ] -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function isPositive( value ) { - this.count += 1; - return ( value > 0 ); -} - -var x = [ 0, 1, 0, 0, 0 ]; - -var context = { - 'count': 0 -}; - -var out = cuanyByRight( x, isPositive, context ); -// returns [ false, false, false, true, true ] - -var cnt = context.count; -// returns 4 -``` - -#### cuanyByRight.assign( x, out, stride, offset, predicate\[, thisArg] ) - -Cumulatively tests whether at least one element in a provided array passes a test implemented by a `predicate` function, while iterating from right-to-left, and assigns results to a provided output array. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 0, 1, 0, 0, 0 ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cuanyByRight.assign( x, y, 2, 0, isPositive ); -// returns [ false, null, false, null, false, null, true, null, true, null ] - -var bool = ( out === y ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. -- **predicate**: test function. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cuanyByRight = require( '@stdlib/array/base/cuany-by-right' ); - -function isPositive( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -var out = cuanyByRight( x, isPositive ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cuany-by-right/benchmark/benchmark.assign.length.js b/base/cuany-by-right/benchmark/benchmark.assign.length.js deleted file mode 100644 index 8a5f7298d..000000000 --- a/base/cuany-by-right/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cuanyByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( false, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuanyByRight.assign( x, y, 1, 0, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cuany-by-right/benchmark/benchmark.js b/base/cuany-by-right/benchmark/benchmark.js deleted file mode 100644 index e6515d804..000000000 --- a/base/cuany-by-right/benchmark/benchmark.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var cuanyByRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var i; - var v; - - x = [ 1, 1, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuanyByRight( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cuany-by-right/benchmark/benchmark.length.js b/base/cuany-by-right/benchmark/benchmark.length.js deleted file mode 100644 index 339bcf3d8..000000000 --- a/base/cuany-by-right/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cuanyByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 0, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuanyByRight( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cuany-by-right/docs/repl.txt b/base/cuany-by-right/docs/repl.txt deleted file mode 100644 index 9aa9cc72b..000000000 --- a/base/cuany-by-right/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Cumulatively tests whether at least one array element in a provided array - passes a test implemented by a predicate function, while iterating from - right-to-left. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function predicate( v ) { return ( v > 0 ); }; - > var x = [ 1, 1, 0, 0, 0 ]; - > var y = {{alias}}( x, predicate ) - [ false, false, false, true, true ] - - -{{alias}}.assign( x, out, stride, offset, predicate[, thisArg] ) - Cumulatively tests whether at least one array element in a provided array - passes a test implemented by a predicate function, while iterating from - right-to-left, and assigns the results to the provided output array. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ 1, 1, 0, 0 ]; - > var out = [ false, null, false, null, false, null, false, null ]; - > function predicate( v ) { return ( v > 0 ); }; - > var arr = {{alias}}.assign( x, out, 2, 0, predicate ) - [ false, null, ..., true, null ] - > var bool = ( arr === out ) - true - - See Also - -------- diff --git a/base/cuany-by-right/docs/types/index.d.ts b/base/cuany-by-right/docs/types/index.d.ts deleted file mode 100644 index 2257b4f8c..000000000 --- a/base/cuany-by-right/docs/types/index.d.ts +++ /dev/null @@ -1,197 +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. -*/ - -/// - -import { Collection, AccessorArrayLike, TypedArray, BooleanArray } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `cuanyByRight`. -*/ -interface CuanyByRight { - /** - * Cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left. - * - * @param x - input array - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * var x = [ 0, 1, 1, 0, 0 ]; - * - * var y = cuanyByRight( x, isPositive ); - * // returns [ false, false, true, true, true ] - */ - ( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * var x = [ 1, 1, 0, 0, 0 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cuanyByRight.assign( x, y, 2, 0, isPositive ); - * // returns [ false, null, false, null, false, null, true, null, true, null ] - */ - assign( x: Collection | AccessorArrayLike, out: Array, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * var BooleanArray = require( './../../../../bool' ); - * - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = new BooleanArray( [ false, false, false, false, false, false, false, false, false, false ] ); - * - * var arr = cuanyByRight.assign( x, y, 2, 0, isPositive ); - * // returns - * - * var v = arr.get( 6 ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, out: U, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): U; - - /** - * Cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cuanyByRight.assign( x, y, 2, 0, isPositive ); - * // returns [ false, null, false, null, false, null, true, null, true, null ] - */ - assign( x: Collection | AccessorArrayLike, out: Collection | AccessorArrayLike, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Collection | AccessorArrayLike; -} - -/** -* Cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left. -* -* @param x - input array -* @param predicate - test function -* @param thisArg - execution context -* @returns output array -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var result = cuanyByRight( x, isPositive ); -* // returns [ false, false, false, true, true ] -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* var x = [ 0, 1, 1, 0, 0 ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cuanyByRight.assign( x, y, 2, 0, isPositive ); -* // returns [ false, null, false, null, false, null, true, null, true, null ] -*/ -declare var cuanyByRight: CuanyByRight; - - -// EXPORTS // - -export = cuanyByRight; diff --git a/base/cuany-by-right/docs/types/test.ts b/base/cuany-by-right/docs/types/test.ts deleted file mode 100644 index d8aeccfb0..000000000 --- a/base/cuany-by-right/docs/types/test.ts +++ /dev/null @@ -1,234 +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. -*/ - -import cuanyByRight = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns an array... -{ - cuanyByRight( [ 1, 2, 3 ], isPositive ); // $ExpectType boolean[] - cuanyByRight( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyByRight( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyByRight( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyByRight( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyByRight( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyByRight( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyByRight( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyByRight( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyByRight( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - - cuanyByRight( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType boolean[] - cuanyByRight( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyByRight( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyByRight( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyByRight( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyByRight( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyByRight( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyByRight( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyByRight( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyByRight( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cuanyByRight( 1, isPositive ); // $ExpectError - cuanyByRight( true, isPositive ); // $ExpectError - cuanyByRight( false, isPositive ); // $ExpectError - cuanyByRight( null, isPositive ); // $ExpectError - cuanyByRight( void 0, isPositive ); // $ExpectError - cuanyByRight( {}, isPositive ); // $ExpectError - - cuanyByRight( 1, isPositive, {} ); // $ExpectError - cuanyByRight( true, isPositive, {} ); // $ExpectError - cuanyByRight( false, isPositive, {} ); // $ExpectError - cuanyByRight( null, isPositive, {} ); // $ExpectError - cuanyByRight( void 0, isPositive, {} ); // $ExpectError - cuanyByRight( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not function... -{ - const x = [ 1, 2, 3, 4 ]; - - cuanyByRight( x, null ); // $ExpectError - cuanyByRight( x, {} ); // $ExpectError - cuanyByRight( x, [] ); // $ExpectError - cuanyByRight( x, '' ); // $ExpectError - cuanyByRight( x, undefined ); // $ExpectError - - cuanyByRight( x, null, {} ); // $ExpectError - cuanyByRight( x, {}, {} ); // $ExpectError - cuanyByRight( x, [], {} ); // $ExpectError - cuanyByRight( x, '', {} ); // $ExpectError - cuanyByRight( x, undefined, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cuanyByRight(); // $ExpectError - cuanyByRight( [] ); // $ExpectError - cuanyByRight( [ 1, 2 ], isPositive, {}, '' ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 0, 0, 0, 1, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuanyByRight.assign( x, y, 2, 0, isPositive ); // $ExpectType (boolean | null)[] - cuanyByRight.assign( x, y, 2, 0, isPositive, {} ); // $ExpectType (boolean | null)[] - cuanyByRight.assign( x, new Float64Array( 4 ), 1, 0, isPositive ); // $ExpectType Float64Array - cuanyByRight.assign( x, new Float32Array( 4 ), 1, 0, isPositive ); // $ExpectType Float32Array - cuanyByRight.assign( x, new Int32Array( 4 ), 1, 0, isPositive ); // $ExpectType Int32Array - cuanyByRight.assign( x, new Int16Array( 4 ), 1, 0, isPositive ); // $ExpectType Int16Array - cuanyByRight.assign( x, new Int8Array( 4 ), 1, 0, isPositive ); // $ExpectType Int8Array - cuanyByRight.assign( x, new Uint32Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint32Array - cuanyByRight.assign( x, new Uint16Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint16Array - cuanyByRight.assign( x, new Uint8Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint8Array - cuanyByRight.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive ); // $ExpectType Uint8ClampedArray - - cuanyByRight.assign( x, [ 0, 0, 0, 0 ], 1, 0, isPositive, {} ); // $ExpectType (number | boolean)[] - cuanyByRight.assign( x, new Float64Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float64Array - cuanyByRight.assign( x, new Float32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float32Array - cuanyByRight.assign( x, new Int32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int32Array - cuanyByRight.assign( x, new Int16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int16Array - cuanyByRight.assign( x, new Int8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int8Array - cuanyByRight.assign( x, new Uint32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint32Array - cuanyByRight.assign( x, new Uint16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint16Array - cuanyByRight.assign( x, new Uint8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8Array - cuanyByRight.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8ClampedArray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const x = [ false, false, true, false, false ]; - - cuanyByRight.assign( 1, x, 2, 0, isPositive ); // $ExpectError - cuanyByRight.assign( true, x, 2, 0, isPositive ); // $ExpectError - cuanyByRight.assign( false, x, 2, 0, isPositive ); // $ExpectError - cuanyByRight.assign( null, x, 2, 0, isPositive ); // $ExpectError - cuanyByRight.assign( void 0, x, 2, 0, isPositive ); // $ExpectError - cuanyByRight.assign( {}, x, 2, 0, isPositive ); // $ExpectError - - cuanyByRight.assign( 1, x, 2, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( true, x, 2, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( false, x, 2, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( null, x, 2, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( void 0, x, 2, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( {}, x, 2, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ false, false, true, false, false ]; - - cuanyByRight.assign( x, 1, 2, 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, true, 2, 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, false, 2, 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, null, 2, 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, void 0, 2, 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, {}, 2, 0, isPositive ); // $ExpectError - - cuanyByRight.assign( x, 1, 2, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, true, 2, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, false, 2, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, null, 2, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, void 0, 2, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, {}, 2, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuanyByRight.assign( x, y , '1', 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, y , true, 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, y , false, 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, y , null, 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, y , void 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, y , {}, 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, y , [], 0, isPositive ); // $ExpectError - - cuanyByRight.assign( x, y , '1', 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y , true, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y , false, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y , null, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y , void 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y , {}, 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y , [], 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuanyByRight.assign( x, y, 1, '1', isPositive ); // $ExpectError - cuanyByRight.assign( x, y, 1, true, isPositive ); // $ExpectError - cuanyByRight.assign( x, y, 1, false, isPositive ); // $ExpectError - cuanyByRight.assign( x, y, 1, null, isPositive ); // $ExpectError - cuanyByRight.assign( x, y, 1, void 0, isPositive ); // $ExpectError - cuanyByRight.assign( x, y, 1, {}, isPositive ); // $ExpectError - cuanyByRight.assign( x, y, 1, [], isPositive ); // $ExpectError - - cuanyByRight.assign( x, y, 1, '1', isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y, 1, true, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y, 1, false, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y, 1, null, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y, 1, void 0, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y, 1, {}, isPositive, {} ); // $ExpectError - cuanyByRight.assign( x, y, 1, [], isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not like a function... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuanyByRight.assign( x, y, 1, 2, {} ); // $ExpectError - cuanyByRight.assign( x, y, 1, 2, void 0 ); // $ExpectError - cuanyByRight.assign( x, y, 1, 1, [] ); // $ExpectError - cuanyByRight.assign( x, y, 1, 1, '' ); // $ExpectError - - cuanyByRight.assign( x, y, 1, 2, {}, {} ); // $ExpectError - cuanyByRight.assign( x, y, 1, 2, void 0, {} ); // $ExpectError - cuanyByRight.assign( x, y, 1, 1, [], {} ); // $ExpectError - cuanyByRight.assign( x, y, 1, 1, '', {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cuanyByRight.assign(); // $ExpectError - cuanyByRight.assign( [] ); // $ExpectError - cuanyByRight.assign( [], [] ); // $ExpectError - cuanyByRight.assign( [], [], 2 ); // $ExpectError - cuanyByRight.assign( [], [], 1, 1, isPositive, [], {} ); // $ExpectError -} diff --git a/base/cuany-by-right/examples/index.js b/base/cuany-by-right/examples/index.js deleted file mode 100644 index 07c56c9cd..000000000 --- a/base/cuany-by-right/examples/index.js +++ /dev/null @@ -1,34 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cuanyByRight = require( './../lib' ); - -function isPositive( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -// Cumulatively test whether at least one array element passes a test, while iterating from right-to-left: -var out = cuanyByRight( x, isPositive ); -console.log( out ); diff --git a/base/cuany-by-right/lib/assign.js b/base/cuany-by-right/lib/assign.js deleted file mode 100644 index 21c271c43..000000000 --- a/base/cuany-by-right/lib/assign.js +++ /dev/null @@ -1,171 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the provided output array. -* -* @private -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 0, 0 ]; -* -* var out = [ false, false, false, false, false ]; -* var y = indexed( x, out, 1, 0, isPositive ); -* // returns [ false, false, false, true, true ] -*/ -function indexed( x, y, stride, offset, predicate, thisArg ) { - var flg; - var io; - var i; - - flg = false; - io = offset; - for ( i = x.length - 1; i >= 0; i-- ) { - if ( !flg && predicate.call( thisArg, x[ i ], i, x ) ) { - flg = true; - } - y[ io ] = flg; - io += stride; - } - return y; -} - -/** -* Cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 0, 1, 0, 0, 0 ] ); -* -* var out = toAccessorArray( [ false, false, false, false, false ] ); -* var y = accessors( arraylike2object( x ), arraylike2object( out ), 1, 0, isPositive ); -* -* var v = out.get( 4 ); -* // returns true -*/ -function accessors( x, y, stride, offset, predicate, thisArg ) { - var xdata; - var ydata; - var xget; - var yset; - var flg; - var io; - var i; - - xdata = x.data; - ydata = y.data; - - xget = x.accessors[ 0 ]; - yset = y.accessors[ 1 ]; - - flg = false; - io = offset; - for ( i = xdata.length - 1; i >= 0; i-- ) { - if ( !flg && predicate.call( thisArg, xget( xdata, i ), i, x ) ) { - flg = true; - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - - -// MAIN // - -/** -* Cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the output array. -* -* @param {Collection} x - input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 0 ]; -* -* var y = [ false, null, false, null, false, null, false, null ]; -* var out = assign( x, y, 2, 0, isPositive ); -* // returns [ false, null, ..., true, null ] -* -* var bool = ( y === out ); -* // returns true -*/ -function assign( x, out, stride, offset, predicate, thisArg ) { - var xo; - var oo; - - xo = arraylike2object( x ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - oo.accessorProtocol - ) { - accessors( xo, oo, stride, offset, predicate, thisArg ); - return out; - } - indexed( x, out, stride, offset, predicate, thisArg ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cuany-by-right/lib/index.js b/base/cuany-by-right/lib/index.js deleted file mode 100644 index 43e6fa6e9..000000000 --- a/base/cuany-by-right/lib/index.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left. -* -* @module @stdlib/array/base/cuany-by-right -* -* @example -* var cuanyByRight = require( '@stdlib/array/base/cuany-by-right' ); -* -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 0, 0 ]; -* -* var y = cuanyByRight( x, isPositive ); -* // returns [ false, false, false, true, true ] -* -* @example -* var cuanyByRight = require( '@stdlib/array/base/cuany-by-right' ); -* -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 0, 0 ]; -* -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* var out = cuanyByRight.assign( x, y, 2, 0, isPositive ); -* // returns [ false, null, false, null, false, null, true, null, true, null ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cuany-by-right/lib/main.js b/base/cuany-by-right/lib/main.js deleted file mode 100644 index 0b9303fc8..000000000 --- a/base/cuany-by-right/lib/main.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Array} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 1, 0, 0, 0 ]; -* -* var y = cuanyByRight( x, isPositive ); -* // returns [ false, false, false, true, true ] -*/ -function cuanyByRight( x, predicate, thisArg ) { - var out = filled( false, x.length ); - return assign( x, out, 1, 0, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = cuanyByRight; diff --git a/base/cuany-by-right/package.json b/base/cuany-by-right/package.json deleted file mode 100644 index b9ae4cf3a..000000000 --- a/base/cuany-by-right/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/cuany-by-right", - "version": "0.0.0", - "description": "Cumulatively test whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "generic", - "array", - "cumulative", - "data", - "structure", - "test", - "predicate", - "any", - "some", - "array.some", - "array-like", - "validate" - ] -} diff --git a/base/cuany-by-right/test/test.assign.js b/base/cuany-by-right/test/test.assign.js deleted file mode 100644 index dc7b223ee..000000000 --- a/base/cuany-by-right/test/test.assign.js +++ /dev/null @@ -1,247 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cuanyByRight = require( './../lib/assign.js' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return v > 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuanyByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to a provided output array (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 0, 0, 1, 1, 0 ]; - y = [ false, true, false, true, false ]; - - actual = cuanyByRight( x, y, 1, 0, isPositive ); - expected = [ false, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 0, 0 ]; - y = [ false, null, false, null, false, null, false, null ]; - - actual = cuanyByRight( x, y, 2, 0, isPositive ); - expected = [ false, null, false, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 0, 0, 0 ]; - y = [ true, false, false, true, true, true ]; - - actual = cuanyByRight( x, y, 1, 1, isPositive ); - expected = [ true, false, false, false, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cuanyByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0 ]; - y = [ false, false ]; - - actual = cuanyByRight( x, y, 1, 1, isPositive ); - expected = [ false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to a provided output array (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cuanyByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null ]; - - actual = cuanyByRight( x, y, 2, 0, isPositive ); - expected = [ false, null, false, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 1.0, 0.0, 0.0 ] ); - y = [ true, false, false, true, true, true ]; - - actual = cuanyByRight( x, y, 1, 1, isPositive ); - expected = [ true, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cuanyByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0 ] ); - y = [ false, false ]; - - actual = cuanyByRight( x, y, 1, 1, isPositive ); - expected = [ false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to a provided output array (accessor)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ 1, 0, 0, 0, 0 ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cuanyByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 1, 0 ] ); - ybuf = [ false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cuanyByRight( x, y, 2, 0, isPositive ); - expected = [ false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 1, 0, 0 ] ); - ybuf = [ true, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuanyByRight( x, y, 1, 1, isPositive ); - expected = [ true, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 0, 0, 1 ] ); - ybuf = [ true, true, true, true, true ]; - y = toAccessorArray( ybuf ); - - actual = cuanyByRight( x, y, 1, 0, isPositive ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuanyByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0 ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuanyByRight( x, y, 1, 1, isPositive ); - expected = [ false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - var x; - var y; - - ctx = { - 'count': 0 - }; - - x = [ 0, 1, 0, 0, 0 ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuanyByRight( x, y, 2, 0, predicate, ctx ); - expected = [ false, null, false, null, false, null, true, null, true, null ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cuany-by-right/test/test.js b/base/cuany-by-right/test/test.js deleted file mode 100644 index 6a65e1ab2..000000000 --- a/base/cuany-by-right/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cuanyByRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuanyByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cuanyByRight, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cuanyByRight, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cuany-by-right/test/test.main.js b/base/cuany-by-right/test/test.main.js deleted file mode 100644 index 968ef0aa3..000000000 --- a/base/cuany-by-right/test/test.main.js +++ /dev/null @@ -1,161 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cuanyByRight = require( './../lib' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return v > 0; -} - -function isNotNull( v ) { - return v !== null; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuanyByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 1, 0, 0, 0 ]; - - actual = cuanyByRight( x, isPositive ); - expected = [ false, false, false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0.0, 0.0, 0.0, 1.0, 1.0 ]; - actual = cuanyByRight( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ {}, {}, null ]; - actual = cuanyByRight( x, isNotNull ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left (typed)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0 ] ); - actual = cuanyByRight( x, isPositive ); - expected = [ false, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuanyByRight( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cuanyByRight( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 0.0 ] ); - actual = cuanyByRight( x, isPositive ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0 ] ); - actual = cuanyByRight( x, isPositive ); - expected = [ false, false, false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left (accessor)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 0, 0, 0 ] ); - - actual = cuanyByRight( x, isPositive ); - expected = [ false, false, false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); - actual = cuanyByRight( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 1, 1, 1 ] ); - actual = cuanyByRight( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 1 ] ); - actual = cuanyByRight( x, isPositive ); - expected = [ true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 0, 0, 0, 0 ] ); - actual = cuanyByRight( x, isPositive ); - expected = [ false, false, false, false, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - ctx = { - 'count': 0 - }; - - x = [ 1, -2, 0, -1 ]; - - out = cuanyByRight( x, predicate, ctx ); - expected = [ false, false, false, true ]; - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cuany-by/README.md b/base/cuany-by/README.md deleted file mode 100644 index 22f29a37f..000000000 --- a/base/cuany-by/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# cuanyBy - -> Cumulatively test whether at least one element in a provided array passes a test implemented by a predicate function. - -
- -## Usage - -```javascript -var cuanyBy = require( '@stdlib/array/base/cuany-by' ); -``` - -#### cuanyBy( x, predicate\[, thisArg] ) - -Cumulatively tests whether at least one element in a provided array passes a test implemented by a `predicate` function. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 0, 0, 0, 1, 0 ]; - -var y = cuanyBy( x, isPositive ); -// returns [ false, false, false, true, true ] -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function isPositive( value ) { - this.count += 1; - return ( value > 0 ); -} - -var x = [ 0, 0, 0, 1, 0 ]; - -var context = { - 'count': 0 -}; - -var out = cuanyBy( x, isPositive, context ); -// returns [ false, false, false, true, true ] - -var cnt = context.count; -// returns 4 -``` - -#### cuanyBy.assign( x, out, stride, offset, predicate\[, thisArg] ) - -Cumulatively tests whether at least one element in a provided array passes a test implemented by a `predicate` function and assigns results to a provided output array. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 0, 0, 0, 1, 0 ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cuanyBy.assign( x, y, 2, 0, isPositive ); -// returns [ false, null, false, null, false, null, true, null, true, null ] - -var bool = ( out === y ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. -- **predicate**: test function. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cuanyBy = require( '@stdlib/array/base/cuany-by' ); - -function isPositive( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -// Cumulatively determine whether at least one element is positive: -var out = cuanyBy( x, isPositive ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cuany-by/benchmark/benchmark.assign.length.js b/base/cuany-by/benchmark/benchmark.assign.length.js deleted file mode 100644 index 373ef05c2..000000000 --- a/base/cuany-by/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled = require( './../../../base/filled' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var cuanyBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 0, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( false, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuanyBy.assign( x, y, 1, 0, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cuany-by/benchmark/benchmark.js b/base/cuany-by/benchmark/benchmark.js deleted file mode 100644 index 424e55a38..000000000 --- a/base/cuany-by/benchmark/benchmark.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var cuanyBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var i; - var v; - - x = [ 0, 0, 1, 0, 1 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuanyBy( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cuany-by/benchmark/benchmark.length.js b/base/cuany-by/benchmark/benchmark.length.js deleted file mode 100644 index 5aeaefd12..000000000 --- a/base/cuany-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled = require( './../../../base/filled' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var cuanyBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 0, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuanyBy( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cuany-by/docs/repl.txt b/base/cuany-by/docs/repl.txt deleted file mode 100644 index 0d5fa1d17..000000000 --- a/base/cuany-by/docs/repl.txt +++ /dev/null @@ -1,76 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Cumulatively tests whether at least one element in a provided array - passes a test implemented by a predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 0, 1, 0 ]; - > var out = {{alias}}( x, f ) - [ false, false, false, true, true ] - - -{{alias}}.assign( x, y, stride, offset, predicate[, thisArg] ) - Cumulatively tests whether at least one element in a provided array - passes a test implemented by a predicate function and assigns results - to a provided output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - y: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - y: ArrayLikeObject - Output array. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 0, 1, 0 ]; - > var y = [ false, null, false, null, false, null, false, null, false ]; - > var result = {{alias}}.assign( x, y, 2, 0, f ) - [ false, null, false, null, false, null, true, null, true ] - - See Also - -------- - diff --git a/base/cuany-by/docs/types/index.d.ts b/base/cuany-by/docs/types/index.d.ts deleted file mode 100644 index b325f98a9..000000000 --- a/base/cuany-by/docs/types/index.d.ts +++ /dev/null @@ -1,202 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, BooleanArray } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `cuanyBy`. -*/ -interface CuAnyBy { - /** - * Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function. - * - * @param x - input array - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * - * var x = [ 0, 0, 0, 1, 0 ]; - * - * var y = cuanyBy( x, isPositive ); - * // returns [ false, false, false, true, true ]; - */ - ( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function and assigns the results to a provided output array. - * - * @param x - input array - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = [ false, null, false, null, false, null, true, null, true, null ]; - * - * var arr = cuanyBy.assign( x, y, 2, 0, isPositive ); - * // returns [ false, null, false, null, false, null, true, null, true, null ]; - */ - assign( x: Collection | AccessorArrayLike, out: Array, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function and assigns the results to the provided output array. - * - * @param x - input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * var BooleanArray = require( './../../../../bool' ); - * - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 1, 0, 1, 0 ]; - * var y = new BooleanArray( [ false, false, false, false, false, false, false, false, false, false ] ); - * - * var arr = cuanyBy.assign( x, y, 2, 0, isPositive ); - * // returns - * - * var v = arr.get( 4 ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, out: U, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): U; - - /** - * Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function and assigns the results to a provided output array. - * - * @param x - input array - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = [ false, null, false, null, false, null, true, null, true, null ]; - * - * var arr = cuanyBy.assign( x, y, 2, 0, isPositive ); - * // returns [ false, null, false, null, false, null, true, null, true, null ]; - */ - assign( x: Collection | AccessorArrayLike, out: Collection | AccessorArrayLike, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Collection | AccessorArrayLike; -} - -/** -* Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function. -* -* @param x - input array -* @returns output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 0, 1, 0 ]; -* -* var y = cuanyBy( x, isPositive ); -* // returns [ false, false, false, true, true ] -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 0, 1, 0 ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cuanyBy.assign( x, y, 2, 0, isPositive ); -* // returns [ false, null, false, null, false, null, true, null, true, null ] -*/ -declare var cuanyBy: CuAnyBy; - - -// EXPORTS // - -export = cuanyBy; diff --git a/base/cuany-by/docs/types/test.ts b/base/cuany-by/docs/types/test.ts deleted file mode 100644 index 511328402..000000000 --- a/base/cuany-by/docs/types/test.ts +++ /dev/null @@ -1,234 +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. -*/ - -import cuanyBy = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns an array... -{ - cuanyBy( [ 1, 2, 3 ], isPositive ); // $ExpectType boolean[] - cuanyBy( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyBy( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyBy( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyBy( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyBy( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyBy( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyBy( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyBy( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - cuanyBy( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean[] - - cuanyBy( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType boolean[] - cuanyBy( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyBy( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyBy( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyBy( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyBy( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyBy( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyBy( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyBy( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] - cuanyBy( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cuanyBy( 1, isPositive ); // $ExpectError - cuanyBy( true, isPositive ); // $ExpectError - cuanyBy( false, isPositive ); // $ExpectError - cuanyBy( null, isPositive ); // $ExpectError - cuanyBy( void 0, isPositive ); // $ExpectError - cuanyBy( {}, isPositive ); // $ExpectError - - cuanyBy( 1, isPositive, {} ); // $ExpectError - cuanyBy( true, isPositive, {} ); // $ExpectError - cuanyBy( false, isPositive, {} ); // $ExpectError - cuanyBy( null, isPositive, {} ); // $ExpectError - cuanyBy( void 0, isPositive, {} ); // $ExpectError - cuanyBy( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not function... -{ - const x = [ 1, 2, 3, 4 ]; - - cuanyBy( x, null ); // $ExpectError - cuanyBy( x, {} ); // $ExpectError - cuanyBy( x, [] ); // $ExpectError - cuanyBy( x, '' ); // $ExpectError - cuanyBy( x, undefined ); // $ExpectError - - cuanyBy( x, null, {} ); // $ExpectError - cuanyBy( x, {}, {} ); // $ExpectError - cuanyBy( x, [], {} ); // $ExpectError - cuanyBy( x, '', {} ); // $ExpectError - cuanyBy( x, undefined, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cuanyBy(); // $ExpectError - cuanyBy( [] ); // $ExpectError - cuanyBy( [ 1, 2 ], isPositive, {}, '' ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 0, 0, 0, 1, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuanyBy.assign( x, y, 2, 0, isPositive ); // $ExpectType (boolean | null)[] - cuanyBy.assign( x, y, 2, 0, isPositive, {} ); // $ExpectType (boolean | null)[] - cuanyBy.assign( x, new Float64Array( 4 ), 1, 0, isPositive ); // $ExpectType Float64Array - cuanyBy.assign( x, new Float32Array( 4 ), 1, 0, isPositive ); // $ExpectType Float32Array - cuanyBy.assign( x, new Int32Array( 4 ), 1, 0, isPositive ); // $ExpectType Int32Array - cuanyBy.assign( x, new Int16Array( 4 ), 1, 0, isPositive ); // $ExpectType Int16Array - cuanyBy.assign( x, new Int8Array( 4 ), 1, 0, isPositive ); // $ExpectType Int8Array - cuanyBy.assign( x, new Uint32Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint32Array - cuanyBy.assign( x, new Uint16Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint16Array - cuanyBy.assign( x, new Uint8Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint8Array - cuanyBy.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive ); // $ExpectType Uint8ClampedArray - - cuanyBy.assign( x, [ 0, 0, 0, 0 ], 1, 0, isPositive, {} ); // $ExpectType (number | boolean)[] - cuanyBy.assign( x, new Float64Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float64Array - cuanyBy.assign( x, new Float32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float32Array - cuanyBy.assign( x, new Int32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int32Array - cuanyBy.assign( x, new Int16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int16Array - cuanyBy.assign( x, new Int8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int8Array - cuanyBy.assign( x, new Uint32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint32Array - cuanyBy.assign( x, new Uint16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint16Array - cuanyBy.assign( x, new Uint8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8Array - cuanyBy.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8ClampedArray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const x = [ false, false, true, false, false ]; - - cuanyBy.assign( 1, x, 2, 0, isPositive ); // $ExpectError - cuanyBy.assign( true, x, 2, 0, isPositive ); // $ExpectError - cuanyBy.assign( false, x, 2, 0, isPositive ); // $ExpectError - cuanyBy.assign( null, x, 2, 0, isPositive ); // $ExpectError - cuanyBy.assign( void 0, x, 2, 0, isPositive ); // $ExpectError - cuanyBy.assign( {}, x, 2, 0, isPositive ); // $ExpectError - - cuanyBy.assign( 1, x, 2, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( true, x, 2, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( false, x, 2, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( null, x, 2, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( void 0, x, 2, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( {}, x, 2, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ false, false, true, false, false ]; - - cuanyBy.assign( x, 1, 2, 0, isPositive ); // $ExpectError - cuanyBy.assign( x, true, 2, 0, isPositive ); // $ExpectError - cuanyBy.assign( x, false, 2, 0, isPositive ); // $ExpectError - cuanyBy.assign( x, null, 2, 0, isPositive ); // $ExpectError - cuanyBy.assign( x, void 0, 2, 0, isPositive ); // $ExpectError - cuanyBy.assign( x, {}, 2, 0, isPositive ); // $ExpectError - - cuanyBy.assign( x, 1, 2, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, true, 2, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, false, 2, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, null, 2, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, void 0, 2, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, {}, 2, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuanyBy.assign( x, y , '1', 0, isPositive ); // $ExpectError - cuanyBy.assign( x, y , true, 0, isPositive ); // $ExpectError - cuanyBy.assign( x, y , false, 0, isPositive ); // $ExpectError - cuanyBy.assign( x, y , null, 0, isPositive ); // $ExpectError - cuanyBy.assign( x, y , void 0, isPositive ); // $ExpectError - cuanyBy.assign( x, y , {}, 0, isPositive ); // $ExpectError - cuanyBy.assign( x, y , [], 0, isPositive ); // $ExpectError - - cuanyBy.assign( x, y , '1', 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y , true, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y , false, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y , null, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y , void 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y , {}, 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y , [], 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuanyBy.assign( x, y, 1, '1', isPositive ); // $ExpectError - cuanyBy.assign( x, y, 1, true, isPositive ); // $ExpectError - cuanyBy.assign( x, y, 1, false, isPositive ); // $ExpectError - cuanyBy.assign( x, y, 1, null, isPositive ); // $ExpectError - cuanyBy.assign( x, y, 1, void 0, isPositive ); // $ExpectError - cuanyBy.assign( x, y, 1, {}, isPositive ); // $ExpectError - cuanyBy.assign( x, y, 1, [], isPositive ); // $ExpectError - - cuanyBy.assign( x, y, 1, '1', isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y, 1, true, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y, 1, false, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y, 1, null, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y, 1, void 0, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y, 1, {}, isPositive, {} ); // $ExpectError - cuanyBy.assign( x, y, 1, [], isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not like a function... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuanyBy.assign( x, y, 1, 2, {} ); // $ExpectError - cuanyBy.assign( x, y, 1, 2, void 0 ); // $ExpectError - cuanyBy.assign( x, y, 1, 1, [] ); // $ExpectError - cuanyBy.assign( x, y, 1, 1, '' ); // $ExpectError - - cuanyBy.assign( x, y, 1, 2, {}, {} ); // $ExpectError - cuanyBy.assign( x, y, 1, 2, void 0, {} ); // $ExpectError - cuanyBy.assign( x, y, 1, 1, [], {} ); // $ExpectError - cuanyBy.assign( x, y, 1, 1, '', {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cuanyBy.assign(); // $ExpectError - cuanyBy.assign( [] ); // $ExpectError - cuanyBy.assign( [], [] ); // $ExpectError - cuanyBy.assign( [], [], 2 ); // $ExpectError - cuanyBy.assign( [], [], 1, 1, isPositive, [], {} ); // $ExpectError -} diff --git a/base/cuany-by/examples/index.js b/base/cuany-by/examples/index.js deleted file mode 100644 index 564c89092..000000000 --- a/base/cuany-by/examples/index.js +++ /dev/null @@ -1,34 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cuanyBy = require( './../lib' ); - -function isPositive( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -// Cumulatively determine whether at least one element is positive: -var out = cuanyBy( x, isPositive ); -console.log( out ); diff --git a/base/cuany-by/lib/assign.js b/base/cuany-by/lib/assign.js deleted file mode 100644 index 904bcd719..000000000 --- a/base/cuany-by/lib/assign.js +++ /dev/null @@ -1,180 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ false, false, false, true, false ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var out = indexed( x, y, 2, 0, isPositive ); -* // returns [ false, null, false, null, false, null, true, null, true, null ] -*/ -function indexed( x, y, stride, offset, predicate, thisArg ) { - var flg; - var io; - var i; - - flg = false; - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( !flg && predicate.call(thisArg, x[ i ], i, x ) ) { - flg = true; - } - y[ io ] = flg; - io += stride; - } - return y; -} - -/** -* Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function. -* -* @private -* @param {Object} x - input array object -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = toAccessorArray( [ false, false, false, true, false ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] ); -* -* var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0, isPositive ); -* -* var v = y.get( 0 ); -* // returns false -* -* v = y.get( 2 ); -* // returns false -* -* v = y.get( 4 ); -* // returns false -* -* v = y.get( 6 ); -* // returns true -* -* v = y.get( 8 ); -* // returns true -*/ -function accessors( x, y, stride, offset, predicate, thisArg ) { - var xdata; - var ydata; - var xget; - var yset; - var flg; - var io; - var i; - - xdata = x.data; - ydata = y.data; - - xget = x.accessors[ 0 ]; - yset = y.accessors[ 1 ]; - - flg = false; - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( !flg && predicate.call( thisArg, xget( xdata, i ), i, x ) ) { - flg = true; - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - - -// MAIN // - -/** -* Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function and assigns results to a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 1, 0 ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var out = assign( x, y, 2, 0, isPositive ); -// returns [ false, null, false, null, false, null, true, null, true, null ] -* -* var bool = ( y === out ); -* // returns true -*/ -function assign( x, y, stride, offset, predicate, thisArg ) { - var xo = arraylike2object( x ); - var yo = arraylike2object( y ); - - if ( - xo.accessorProtocol || - yo.accessorProtocol - ) { - return accessors( xo, yo, stride, offset, predicate, thisArg ); - } - indexed( x, y, stride, offset, predicate, thisArg ); - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cuany-by/lib/index.js b/base/cuany-by/lib/index.js deleted file mode 100644 index 38b0b7bd9..000000000 --- a/base/cuany-by/lib/index.js +++ /dev/null @@ -1,66 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether at least one element in a provided array passes a test implemented by a predicate function. -* -* @module @stdlib/array/base/cuany-by -* -* @example -* var cuanyBy = require( '@stdlib/array/base/cuany-by' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 1, 0 ]; -* -* var y = cuanyBy( x, isPositive ); -* // returns [ false, false, false, true, true ] -* -* @example -* var cuanyBy = require( '@stdlib/array/base/cuany-by' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 1, 0 ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cuanyBy.assign( x, y, 2, 0, isPositive ); -* // returns [ false, null, false, null, false, null, true, null, true, null ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cuany-by/lib/main.js b/base/cuany-by/lib/main.js deleted file mode 100644 index d533f2202..000000000 --- a/base/cuany-by/lib/main.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Array} output array -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 1, 0 ]; -* -* var y = cuanyBy( x, isPositive ); -* // returns [ false, false, false, true, true ] -*/ -function cuanyBy( x, predicate, thisArg ) { - var y = filled( false, x.length ); - return assign( x, y, 1, 0, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = cuanyBy; diff --git a/base/cuany-by/package.json b/base/cuany-by/package.json deleted file mode 100644 index cbb4cd62b..000000000 --- a/base/cuany-by/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/cuany-by", - "version": "0.0.0", - "description": "Cumulatively test whether at least one element in a provided array passes a test implemented by a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "utils", - "generic", - "array", - "cuany", - "cumulative", - "test", - "some", - "array.some", - "validate" - ] -} diff --git a/base/cuany-by/test/test.assign.js b/base/cuany-by/test/test.assign.js deleted file mode 100644 index a79a031e6..000000000 --- a/base/cuany-by/test/test.assign.js +++ /dev/null @@ -1,302 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cuanyBy = require( './../lib/assign.js' ); - - -// FUNCTIONS // - -function isPositive( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuanyBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ true, false, true, false, true ]; - y = [ false, true, false, true, false ]; - - actual = cuanyBy( x, y, 1, 0, isPositive ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false, false, true, false, false ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuanyBy( x, y, 2, 0, isPositive ); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false, false, true, false, false ]; - y = [ false, false, false, true, true, true ]; - - actual = cuanyBy( x, y, 1, 1, isPositive ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cuanyBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true ]; - y = [ false, false ]; - - actual = cuanyBy( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cuanyBy( x, y, 1, 0, isPositive ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuanyBy( x, y, 2, 0, isPositive ); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, false, false, true, true, true ]; - - actual = cuanyBy( x, y, 1, 1, isPositive ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cuanyBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - y = [ false, false ]; - - actual = cuanyBy( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function (boolean)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new BooleanArray( [ true, true, true, true, true ] ); - y = [ false, true, false, true, false ]; - - actual = cuanyBy( x, y, 1, 0, isPositive ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, true, false, false ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuanyBy( x, y, 2, 0, isPositive ); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, true, false, false ] ); - y = [ false, false, false, true, true, true ]; - - actual = cuanyBy( x, y, 1, 1, isPositive ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [] ); - y = [ false, false, false, false, false ]; - - actual = cuanyBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true ] ); - y = [ false, false ]; - - actual = cuanyBy( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function (accessor)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ true, false, true, false, true ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cuanyBy( x, y, 1, 0, isPositive ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, true, false, false ] ); - ybuf = [ false, null, false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cuanyBy( x, y, 2, 0, isPositive ); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, true, false, false ] ); - ybuf = [ false, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuanyBy( x, y, 1, 1, isPositive ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, false, false, false, false ] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuanyBy( x, y, 1, 0, isPositive ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuanyBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ true ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuanyBy( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - var x; - var y; - - ctx = { - 'count': 0 - }; - - x = [ 0, 0, 1, 0, 1 ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuanyBy( x, y, 2, 0, predicate, ctx); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cuany-by/test/test.js b/base/cuany-by/test/test.js deleted file mode 100644 index 21a2aeb99..000000000 --- a/base/cuany-by/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cuanyBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuanyBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cuanyBy, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cuanyBy, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cuany-by/test/test.main.js b/base/cuany-by/test/test.main.js deleted file mode 100644 index af8acdce0..000000000 --- a/base/cuany-by/test/test.main.js +++ /dev/null @@ -1,201 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cuanyBy = require( './../lib' ); - - -// FUNCTIONS // - -function isPositive( value ) { - return value; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuanyBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ false, false, true, false, false ]; - actual = cuanyBy( x, isPositive ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; - actual = cuanyBy( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, true, true, true, true ]; - actual = cuanyBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ null, {}, null ]; - actual = cuanyBy( x, isPositive ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, false, false, false, false ]; - actual = cuanyBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function (typed)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - actual = cuanyBy( x, isPositive ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuanyBy( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cuanyBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 0.0 ] ); - actual = cuanyBy( x, isPositive ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuanyBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function (boolean)', function test( t ) { - var expected; - var actual; - var x; - - x = new BooleanArray( [ false, false, true, false, false ] ); - actual = cuanyBy( x, isPositive ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, false, false, false ] ); - actual = cuanyBy( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, true, true, true, true ] ); - actual = cuanyBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, true, true ] ); - actual = cuanyBy( x, isPositive ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true, false, false ] ); - actual = cuanyBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ false, false, true, false, false ] ); - - actual = cuanyBy( x, isPositive ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, false, false, false ] ); - actual = cuanyBy( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, true, true, true, true ] ); - actual = cuanyBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, true, false ] ); - actual = cuanyBy( x, isPositive ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, false, false, false, false ] ); - actual = cuanyBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - ctx = { - 'count': 0 - }; - - x = [ 0, 2, 0, 4 ]; - - out = cuanyBy( x, predicate, ctx ); - expected = [ false, true, true, true ]; - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cuany/README.md b/base/cuany/README.md deleted file mode 100644 index f372a2d6e..000000000 --- a/base/cuany/README.md +++ /dev/null @@ -1,113 +0,0 @@ - - -# cuany - -> Cumulatively test whether at least one element in a provided array is truthy. - -
- -## Usage - -```javascript -var cuany = require( '@stdlib/array/base/cuany' ); -``` - -#### cuany( x ) - -Cumulatively tests whether at least one element in a provided array is truthy. - -```javascript -var x = [ false, false, true, false, false ]; - -var y = cuany( x ); -// returns [ false, false, true, true, true ]; -``` - -#### cuany.assign( x, out, stride, offset ) - -Cumulatively tests whether at least one element in a provided array is truthy and assigns results to a provided output array. - -```javascript -var x = [ false, false, true, false, false ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cuany.assign( x, y, 2, 0 ); -// returns [ false, null, false, null, true, null, true, null, true, null ] - -var bool = ( out === y ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cuany = require( '@stdlib/array/base/cuany' ); - -// Create an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -// Cumulatively determine whether values are truthy: -var out = cuany( x ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cuany/benchmark/benchmark.assign.length.js b/base/cuany/benchmark/benchmark.assign.length.js deleted file mode 100644 index faa2a45ba..000000000 --- a/base/cuany/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cuany = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( false, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuany.assign( x, y, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cuany/benchmark/benchmark.js b/base/cuany/benchmark/benchmark.js deleted file mode 100644 index f0ba84437..000000000 --- a/base/cuany/benchmark/benchmark.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var cuany = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var i; - var v; - - x = [ false, false, true, false, false ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuany( x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cuany/benchmark/benchmark.length.js b/base/cuany/benchmark/benchmark.length.js deleted file mode 100644 index dd168d786..000000000 --- a/base/cuany/benchmark/benchmark.length.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cuany = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuany( x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cuany/docs/repl.txt b/base/cuany/docs/repl.txt deleted file mode 100644 index 53db026c7..000000000 --- a/base/cuany/docs/repl.txt +++ /dev/null @@ -1,55 +0,0 @@ - -{{alias}}( x ) - Cumulatively tests whether at least one element in a provided array is - truthy. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ false, false, true, false, false ]; - > var y = {{alias}}( x ) - [ false, false, true, true, true ] - - -{{alias}}.assign( x, y, stride, offset ) - Cumulatively tests whether at least one element in an array is truthy and - assigns results to a provided output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - y: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - Returns - ------- - y: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ false, false, true, false, false ]; - > var y = [ false, null, false, null, false, null, false, null, false ]; - > var result = {{alias}}.assign( x, y, 2, 0 ) - [ false, null, false, null, true, null, true, null, true ] - - See Also - -------- - diff --git a/base/cuany/docs/types/index.d.ts b/base/cuany/docs/types/index.d.ts deleted file mode 100644 index 067fcd9ed..000000000 --- a/base/cuany/docs/types/index.d.ts +++ /dev/null @@ -1,86 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Interface describing `cuany`. -*/ -interface CuAny { - /** - * Cumulatively tests whether at least one element in a provided array is truthy. - * - * @param x - input array - * @returns output array - * - * @example - * var x = [ false, false , true, false , false ]; - * - * var y = cuany( x ); - * // returns [ false, false, true, true, true ]; - */ - ( x: Collection | AccessorArrayLike ): Array; - - /** - * Cumulatively tests whether at least one element in an array is truthy and assigns the results to a provided output array. - * - * @param x - input array - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ false, false, true, false, false ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cuany.assign( x, y, 2, 0 ); - * // returns [ false, null, false, null, true, null, true, null, true, null ]; - */ - assign | AccessorArrayLike>( x: Collection | AccessorArrayLike, y: U, stride: number, offset: number ): U; -} - -/** -* Cumulatively tests whether at least one element in a provided array is truthy. -* -* @param x - input array -* @returns output array -* -* @example -* var x = [ false, false, true, false, false ]; -* -* var result = cuany( x ); -* // returns [ false, false, true, true, true ] -* -* @example -* var x = [ false, false, true, false, false ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cuany.assign( x, y, 2, 0 ); -* // returns [ false, null, false, null, true, null, true, null, true, null ] -*/ -declare var cuany: CuAny; - - -// EXPORTS // - -export = cuany; diff --git a/base/cuany/docs/types/test.ts b/base/cuany/docs/types/test.ts deleted file mode 100644 index 7faad7c2c..000000000 --- a/base/cuany/docs/types/test.ts +++ /dev/null @@ -1,114 +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. -*/ - - -import cuany = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - cuany( [ false, false, true, false, false ] ); // $ExpectType boolean[] - cuany( [ false, false, true, false, false ] ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cuany( 1 ); // $ExpectError - cuany( true ); // $ExpectError - cuany( false ); // $ExpectError - cuany( null ); // $ExpectError - cuany( void 0 ); // $ExpectError - cuany( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cuany(); // $ExpectError - cuany( [], [] ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuany.assign( x, y, 2, 0 ); // $ExpectType (boolean | null)[] -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const x = [ false, false, true, false, false ]; - - cuany.assign( 1, x, 2, 0 ); // $ExpectError - cuany.assign( true, x, 2, 0 ); // $ExpectError - cuany.assign( false, x, 2, 0 ); // $ExpectError - cuany.assign( null, x, 2, 0 ); // $ExpectError - cuany.assign( void 0, x, 2, 0 ); // $ExpectError - cuany.assign( {}, x, 2, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ false, false, true, false, false ]; - - cuany.assign( x, 1, 2, 0 ); // $ExpectError - cuany.assign( x, true, 2, 0 ); // $ExpectError - cuany.assign( x, false, 2, 0 ); // $ExpectError - cuany.assign( x, null, 2, 0 ); // $ExpectError - cuany.assign( x, void 0, 2, 0 ); // $ExpectError - cuany.assign( x, {}, 2, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuany.assign( x, y , '1', 0 ); // $ExpectError - cuany.assign( x, y , true, 0 ); // $ExpectError - cuany.assign( x, y , false, 0 ); // $ExpectError - cuany.assign( x, y , null, 0 ); // $ExpectError - cuany.assign( x, y , void 0, 0 ); // $ExpectError - cuany.assign( x, y , {}, 0 ); // $ExpectError - cuany.assign( x, y , [], 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuany.assign( x, y, 1, '1' ); // $ExpectError - cuany.assign( x, y, 1, true ); // $ExpectError - cuany.assign( x, y, 1, false ); // $ExpectError - cuany.assign( x, y, 1, null ); // $ExpectError - cuany.assign( x, y, 1, void 0 ); // $ExpectError - cuany.assign( x, y, 1, {} ); // $ExpectError - cuany.assign( x, y, 1, [] ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cuany.assign(); // $ExpectError - cuany.assign( [] ); // $ExpectError - cuany.assign( [], [] ); // $ExpectError - cuany.assign( [], [], 2 ); // $ExpectError - cuany.assign( [], [], 1, 1, {} ); // $ExpectError -} diff --git a/base/cuany/examples/index.js b/base/cuany/examples/index.js deleted file mode 100644 index 5d7b31e6c..000000000 --- a/base/cuany/examples/index.js +++ /dev/null @@ -1,30 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cuany = require( './../lib' ); - -// Create an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -// Cumulatively determine whether values are truthy: -var out = cuany( x ); -console.log( out ); diff --git a/base/cuany/lib/assign.js b/base/cuany/lib/assign.js deleted file mode 100644 index 539953d92..000000000 --- a/base/cuany/lib/assign.js +++ /dev/null @@ -1,291 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplex128Array = require( './../../../base/assert/is-complex128array' ); -var isComplex64Array = require( './../../../base/assert/is-complex64array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether at least one element in an indexed array is truthy. -* -* @private -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ false, false, true, false, false ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var out = indexed( x, y, 2, 0 ); -* // returns [ false, null, false, null, true, null, true, null, true, null ] -*/ -function indexed( x, y, stride, offset ) { - var flg; - var io; - var i; - - flg = false; - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( flg === false && x[ i ] ) { - flg = true; - } - y[ io ] = flg; - io += stride; - } - return y; -} - -/** -* Cumulatively tests whether at least one element in a provided accessor array is truthy. -* -* @private -* @param {Object} x - input array object -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ false, false, true, false, false ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] ); -* -* var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns false -* -* v = y.get( 2 ); -* // returns false -* -* v = y.get( 4 ); -* // returns true -* -* v = y.get( 6 ); -* // returns true -* -* v = y.get( 8 ); -* // returns true -*/ -function accessors( x, y, stride, offset ) { - var xdata; - var ydata; - var xget; - var yset; - var flg; - var io; - var i; - - xdata = x.data; - ydata = y.data; - - xget = x.accessors[ 0 ]; - yset = y.accessors[ 1 ]; - - flg = false; - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( flg === false && xget( xdata, i ) ) { - flg = true; - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - -/** -* Cumulatively tests whether at least one element in a provided complex number array is truthy. -* -* @private -* @param {Collection} x - array containing interleaved real and imaginary components -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0 ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] ); -* -* var arr = complex( x, arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns false -* -* v = y.get( 2 ); -* // returns false -* -* v = y.get( 4 ); -* // returns true -* -* v = y.get( 6 ); -* // returns true -* -* v = y.get( 8 ); -* // returns true -*/ -function complex( x, y, stride, offset ) { - var ydata; - var yset; - var flg; - var io; - var i; - - yset = y.accessors[ 1 ]; - ydata = y.data; - - flg = false; - io = offset; - for ( i = 0; i < x.length; i += 2 ) { - if ( flg === false && ( x[ i ] || x[ i+1 ] ) ) { - flg = true; - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - -/** -* Cumulatively tests whether at least one element in a provided boolean array is truthy. -* -* @private -* @param {Collection} x - input array -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Uint8Array( [ 0, 0, 1, 1, 0 ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] ); -* -* var arr = boolean( x, arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns false -* -* v = y.get( 2 ); -* // returns false -* -* v = y.get( 4 ); -* // returns true -* -* v = y.get( 6 ); -* // returns true -* -* v = y.get( 8 ); -* // returns true -*/ -function boolean( x, y, stride, offset ) { - var ydata; - var yset; - var flg; - var io; - var i; - - yset = y.accessors[ 1 ]; - ydata = y.data; - - flg = false; - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( flg === false && x[ i ] ) { - flg = true; - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - - -// MAIN // - -/** -* Cumulatively tests whether at least one element in an array is truthy and assigns results to a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ false, false, true, false, false ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var out = assign( x, y, 2, 0 ); -* // returns [ false, null, false, null, true, null, true, null, true, null ] -* -* var bool = ( y === out ); -* // returns true -*/ -function assign( x, y, stride, offset ) { - var xo = arraylike2object( x ); - var yo = arraylike2object( y ); - if ( - xo.accessorProtocol || - yo.accessorProtocol - ) { - // If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero... - if ( isComplex128Array( x ) ) { - complex( reinterpret128( x, 0 ), yo, stride, offset ); - } else if ( isComplex64Array( x ) ) { - complex( reinterpret64( x, 0 ), yo, stride, offset ); - } else if ( isBooleanArray( x ) ) { - boolean( reinterpretBoolean( x, 0 ), yo, stride, offset ); - } else { - accessors( xo, yo, stride, offset ); - } - return y; - } - indexed( x, y, stride, offset ); - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cuany/lib/index.js b/base/cuany/lib/index.js deleted file mode 100644 index 9f4be74a4..000000000 --- a/base/cuany/lib/index.js +++ /dev/null @@ -1,58 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether at least one element in a provided array is truthy. -* -* @module @stdlib/array/base/cuany -* -* @example -* var cuany = require( '@stdlib/array/base/cuany' ); -* -* var x = [ false, false, true, false, false ]; -* -* var y = cuany( x ); -* // returns [ false, false, true, true, true ] -* -* @example -* var cuany = require( '@stdlib/array/base/cuany' ); -* -* var x = [ false, false, true, false, false ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cuany.assign( x, y, 2, 0 ); -* // returns [ false, null, false, null, true, null, true, null, true, null ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cuany/lib/main.js b/base/cuany/lib/main.js deleted file mode 100644 index cf5a8f3ab..000000000 --- a/base/cuany/lib/main.js +++ /dev/null @@ -1,49 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether at least one element in a provided array is truthy. -* -* @param {Collection} x - input array -* @returns {Array} output array -* -* @example -* var x = [ false, false, true, false, false ]; -* -* var y = cuany( x ); -* // returns [ false, false, true, true, true ] -*/ -function cuany( x ) { - var y = filled( false, x.length ); - return assign( x, y, 1, 0 ); -} - - -// EXPORTS // - -module.exports = cuany; diff --git a/base/cuany/package.json b/base/cuany/package.json deleted file mode 100644 index ecb5e3624..000000000 --- a/base/cuany/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/cuany", - "version": "0.0.0", - "description": "Cumulatively test whether at least one element in a provided array is truthy.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "utils", - "generic", - "array", - "cuany", - "cumulative", - "test", - "some", - "array.some", - "validate" - ] -} diff --git a/base/cuany/test/test.assign.js b/base/cuany/test/test.assign.js deleted file mode 100644 index 2ce922728..000000000 --- a/base/cuany/test/test.assign.js +++ /dev/null @@ -1,378 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cuany = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuany, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element is truthy (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ true, false, true, false, true ]; - y = [ false, true, false, true, false ]; - - actual = cuany( x, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false, false, true, false, false ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuany( x, y, 2, 0 ); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false, false, true, false, false ]; - y = [ false, false, false, true, true, true ]; - - actual = cuany( x, y, 1, 1 ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cuany( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true ]; - y = [ false, false ]; - - actual = cuany( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element is truthy (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cuany( x, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuany( x, y, 2, 0 ); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, false, false, true, true, true ]; - - actual = cuany( x, y, 1, 1 ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cuany( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - y = [ false, false ]; - - actual = cuany( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element is truthy (boolean)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new BooleanArray( [ true, true, true, true, true ] ); - y = [ false, true, false, true, false ]; - - actual = cuany( x, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, true, false, false ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuany( x, y, 2, 0 ); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, true, false, false ] ); - y = [ false, false, false, true, true, true ]; - - actual = cuany( x, y, 1, 1 ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [] ); - y = [ false, false, false, false, false ]; - - actual = cuany( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true ] ); - y = [ false, false ]; - - actual = cuany( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element is truthy (complex128)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Complex128Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cuany( x, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuany( x, y, 2, 0 ); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, false, false, true, true, true ]; - - actual = cuany( x, y, 1, 1 ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cuany( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 1.0 ] ); - y = [ false, false ]; - - actual = cuany( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element is truthy (complex64)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Complex64Array( [ 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cuany( x, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuany( x, y, 2, 0 ); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, false, false, true, true, true ]; - - actual = cuany( x, y, 1, 1 ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cuany( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 1.0 ] ); - y = [ false, false ]; - - actual = cuany( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element is truthy (accessor)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ true, false, true, false, true ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cuany( x, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, true, false, false ] ); - ybuf = [ false, null, false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cuany( x, y, 2, 0 ); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, true, false, false ] ); - ybuf = [ false, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuany( x, y, 1, 1 ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, false, false, false, false ] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuany( x, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuany( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ true ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuany( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/cuany/test/test.js b/base/cuany/test/test.js deleted file mode 100644 index a52ecece8..000000000 --- a/base/cuany/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cuany = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuany, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cuany, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cuany, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cuany/test/test.main.js b/base/cuany/test/test.main.js deleted file mode 100644 index 41b895583..000000000 --- a/base/cuany/test/test.main.js +++ /dev/null @@ -1,237 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cuany = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuany, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element is truthy (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ false, false, true, false, false ]; - actual = cuany( x ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; - actual = cuany( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, true, true, true, true ]; - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ null, {}, null ]; - actual = cuany( x ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, false, false, false, false ]; - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element is truthy (typed)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - actual = cuany( x ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuany( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 0.0 ] ); - actual = cuany( x ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element is truthy (boolean)', function test( t ) { - var expected; - var actual; - var x; - - x = new BooleanArray( [ false, false, true, false, false ] ); - actual = cuany( x ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, false, false, false ] ); - actual = cuany( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, true, true, true, true ] ); - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, true, true ] ); - actual = cuany( x ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true, false, false ] ); - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element is truthy (complex128)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuany( x ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuany( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 0.0 ] ); - actual = cuany( x ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element is truthy (complex64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuany( x ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuany( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] ); - actual = cuany( x ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least one element of an accessor array is truthy (accessor)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ false, false, true, false, false ] ); - - actual = cuany( x ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, false, false, false ] ); - actual = cuany( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, true, true, true, true ] ); - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, true, false ] ); - actual = cuany( x ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, false, false, false, false ] ); - actual = cuany( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/cuevery-by-right/README.md b/base/cuevery-by-right/README.md deleted file mode 100644 index d0a0268f9..000000000 --- a/base/cuevery-by-right/README.md +++ /dev/null @@ -1,145 +0,0 @@ - - -# cueveryByRight - -> Cumulatively test whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left. - -
- -## Usage - -```javascript -var cueveryByRight = require( '@stdlib/array/base/cuevery-by-right' ); -``` - -#### cueveryByRight( x, predicate\[, thisArg ] ) - -Cumulatively tests whether every array element in a provided array passes a test implemented by a `predicate` function, while iterating from right-to-left. - -```javascript -function fcn( value ) { - return value > 0; -} - -var x = [ 0, 0, 1, 1, 1 ]; - -var y = cueveryByRight( x, fcn ); -// returns [ true, true, true, false, false ]; -``` - -#### cueveryByRight.assign( x, out, stride, offset, predicate\[, thisArg ] ) - -Cumulatively tests whether every array element in a provided array passes a test implemented by a `predicate` function, while iterating from right-to-left, and assigns the results to the elements in the output array. - -```javascript -function fcn( v ) { - return v > 0; -} - -var x = [ 0, 0, 1, 1, 1 ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cueveryByRight.assign( x, y, 2, 0, fcn ); -// returns [ true, null, true, null, true, null, false, null, false, null ] - -var bool = ( out === y ); -// returns true -``` - -The invoked `predicate` function is provided three arguments: - -- **value**: collection element. -- **index**: collection index. -- **collection**: input collection. - -To set the function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return ( v > 0 ); -} - -var x = [ 0, 0, 1, 1, 1 ]; - -var context = { - 'count': 0 -}; - -var bool = cueveryByRight( x, fcn, context ); -// returns [ true, true, true, false, false ] - -var count = context.count; -// returns 4 -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var cueveryByRight = require( '@stdlib/array/base/cuevery-by-right' ); - -function isPositive( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = discreteUniform( 10, -10, 10 ); -console.log( x ); - -// Cumulatively test whether every array element passes a test, while iterating from right-to-left: -var out = cueveryByRight( x, isPositive ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cuevery-by-right/benchmark/benchmark.assign.length.js b/base/cuevery-by-right/benchmark/benchmark.assign.length.js deleted file mode 100644 index 8fcb82504..000000000 --- a/base/cuevery-by-right/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cueveryByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( false, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cueveryByRight.assign( x, y, 1, 0, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cuevery-by-right/benchmark/benchmark.js b/base/cuevery-by-right/benchmark/benchmark.js deleted file mode 100644 index b6a25be3d..000000000 --- a/base/cuevery-by-right/benchmark/benchmark.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var cueveryByRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var i; - var v; - - x = [ 0, 0, 1, 1, 1 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cueveryByRight( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cuevery-by-right/benchmark/benchmark.length.js b/base/cuevery-by-right/benchmark/benchmark.length.js deleted file mode 100644 index b31c73a4f..000000000 --- a/base/cuevery-by-right/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cueveryByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cueveryByRight( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg + ':len=' + len, f ); - } -} - -main(); diff --git a/base/cuevery-by-right/docs/repl.txt b/base/cuevery-by-right/docs/repl.txt deleted file mode 100644 index 53e71ce4d..000000000 --- a/base/cuevery-by-right/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ -{{alias}}( x, predicate[, thisArg] ) - Cumulatively tests whether every array element in a provided array - passes a test implemented by a predicate function, while iterating from - right-to-left. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 1, 1, 1 ]; - > var y = {{alias}}( x, fcn ) - [ true, true, true, false, false ] - - -{{alias}}.assign( x, out, stride, offset, predicate[, thisArg] ) - Cumulatively tests whether every array element in a provided array passes a - test implemented by a predicate function, while iterating from right-to- - left, and assigns the results to the provided output array. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 1, 1 ]; - > var out = [ false, null, false, null, false, null, false, null ]; - > var arr = {{alias}}.assign( x, out, 2, 0, fcn ) - [ true, null, true, null, false, null, false, null ] - > var bool = ( arr === out ) - true - - See Also - -------- diff --git a/base/cuevery-by-right/docs/types/index.d.ts b/base/cuevery-by-right/docs/types/index.d.ts deleted file mode 100644 index c663a85d7..000000000 --- a/base/cuevery-by-right/docs/types/index.d.ts +++ /dev/null @@ -1,199 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, BooleanArray } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `cueveryByRight`. -*/ -interface CueveryByRight { - /** - * Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left. - * - * @param x - input array - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * var x = [ 1, 0, 0, 1, 1 ]; - * - * var y = cueveryByRight( x, isPositive ); - * // returns [ true, true, false, false, false ]; - */ - ( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * var x = [ 0, 0, 1, 1, 1 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cueveryByRight.assign( x, y, 2, 0, isPositive ); - * // returns [ true, null, true, null, true, null, false, null, false, null ]; - */ - assign( x: Collection | AccessorArrayLike, out: Array, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * var BooleanArray = require( './../../../../bool' ); - * - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = new BooleanArray( [ false, false, false, false, false, false, false, false, false, false ] ); - * - * var arr = cueveryByRight.assign( x, y, 2, 0, isPositive ); - * // returns - * - * var v = arr.get( 4 ); - * // returns false - */ - assign( x: Collection | AccessorArrayLike, out: U, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): U; - - /** - * Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * var x = [ 0, 0, 1, 1, 1 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cueveryByRight.assign( x, y, 2, 0, isPositive ); - * // returns [ true, null, true, null, true, null, false, null, false, null ]; - */ - assign( x: Collection | AccessorArrayLike, out: Collection | AccessorArrayLike, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Collection | AccessorArrayLike; -} - -/** -* Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left. -* -* @param x - input array -* @param predicate - test function -* @param thisArg - execution context -* @returns output array -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* var x = [ 0, 0, 1, 1, 1 ]; -* -* var result = cueveryByRight( x, isPositive ); -* // returns [ true, true, true, false, false ] -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* var x = [ 1, 0, 0, 1, 1 ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cueveryByRight.assign( x, y, 2, 0, isPositive ); -* // returns [ true, null, true, null, false, null, false, null, false, null ] -*/ -declare var cueveryByRight: CueveryByRight; - - -// EXPORTS // - -export = cueveryByRight; diff --git a/base/cuevery-by-right/docs/types/test.ts b/base/cuevery-by-right/docs/types/test.ts deleted file mode 100644 index 6bbfc7f27..000000000 --- a/base/cuevery-by-right/docs/types/test.ts +++ /dev/null @@ -1,209 +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. -*/ - - -import cueveryByRight = require( './index' ); - -const isPositive = ( v: number ): boolean => { - return ( v > 0 ); -}; - -// TESTS // - -// The function returns an array... -{ - cueveryByRight( [ 0, 1, 1 ], isPositive ); // $ExpectType boolean[] - cueveryByRight( [ -1, 0, 1, 2 ], isPositive ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cueveryByRight( 1 ); // $ExpectError - cueveryByRight( true ); // $ExpectError - cueveryByRight( false ); // $ExpectError - cueveryByRight( null ); // $ExpectError - cueveryByRight( void 0 ); // $ExpectError - cueveryByRight( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - const x = [ 0, 0, 1, 1, 1 ]; - - cueveryByRight( x, '1' ); // $ExpectError - cueveryByRight( x, true ); // $ExpectError - cueveryByRight( x, false ); // $ExpectError - cueveryByRight( x, 'abc' ); // $ExpectError - cueveryByRight( x, void 0 ); // $ExpectError - cueveryByRight( x, {} ); // $ExpectError - cueveryByRight( x, [] ); // $ExpectError - - cueveryByRight( x, '1', {} ); // $ExpectError - cueveryByRight( x, true, {} ); // $ExpectError - cueveryByRight( x, false, {} ); // $ExpectError - cueveryByRight( x, 'abc', {} ); // $ExpectError - cueveryByRight( x, void 0, {} ); // $ExpectError - cueveryByRight( x, {}, {} ); // $ExpectError - cueveryByRight( x, [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cueveryByRight(); // $ExpectError - cueveryByRight( [] ); // $ExpectError - cueveryByRight( [], [], [], [] ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 1, 2, 3, 4 ]; - cueveryByRight.assign( x, [ 0, 0, 0, 0 ], 1, 0, isPositive ); // $ExpectType (number | boolean)[] - cueveryByRight.assign( x, new Float64Array( 4 ), 1, 0, isPositive ); // $ExpectType Float64Array - cueveryByRight.assign( x, new Float32Array( 4 ), 1, 0, isPositive ); // $ExpectType Float32Array - cueveryByRight.assign( x, new Int32Array( 4 ), 1, 0, isPositive ); // $ExpectType Int32Array - cueveryByRight.assign( x, new Int16Array( 4 ), 1, 0, isPositive ); // $ExpectType Int16Array - cueveryByRight.assign( x, new Int8Array( 4 ), 1, 0, isPositive ); // $ExpectType Int8Array - cueveryByRight.assign( x, new Uint32Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint32Array - cueveryByRight.assign( x, new Uint16Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint16Array - cueveryByRight.assign( x, new Uint8Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint8Array - cueveryByRight.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive ); // $ExpectType Uint8ClampedArray - - cueveryByRight.assign( x, [ 0, 0, 0, 0 ], 1, 0, isPositive, {} ); // $ExpectType (number | boolean)[] - cueveryByRight.assign( x, new Float64Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float64Array - cueveryByRight.assign( x, new Float32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float32Array - cueveryByRight.assign( x, new Int32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int32Array - cueveryByRight.assign( x, new Int16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int16Array - cueveryByRight.assign( x, new Int8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int8Array - cueveryByRight.assign( x, new Uint32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint32Array - cueveryByRight.assign( x, new Uint16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint16Array - cueveryByRight.assign( x, new Uint8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8Array - cueveryByRight.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8ClampedArray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const x = [ 0, 0, 1, 1, 1 ]; - - cueveryByRight.assign( 1, x, 2, 0, isPositive ); // $ExpectError - cueveryByRight.assign( true, x, 2, 0, isPositive ); // $ExpectError - cueveryByRight.assign( false, x, 2, 0, isPositive ); // $ExpectError - cueveryByRight.assign( null, x, 2, 0, isPositive ); // $ExpectError - cueveryByRight.assign( void 0, x, 2, 0, isPositive ); // $ExpectError - cueveryByRight.assign( {}, x, 2, 0, isPositive ); // $ExpectError - - cueveryByRight.assign( 1, x, 2, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( true, x, 2, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( false, x, 2, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( null, x, 2, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( void 0, x, 2, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( {}, x, 2, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ 0, 0, 1, 1, 1 ]; - - cueveryByRight.assign( x, true, 1, 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, false, 1, 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, null, 1, 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, void 0, 1, 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, {}, 1, 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, 1, 1, 0, isPositive ); // $ExpectError - - cueveryByRight.assign( x, true, 1, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, false, 1, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, null, 1, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, void 0, 1, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, {}, 1, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, 1, 1, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a number... -{ - const x = [ 0, 0, 1, 1, 1 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cueveryByRight.assign( x, y, '1', 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, y, true, 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, y, false, 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, y, null, 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, y, void 0, 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, y, {}, 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, y, [], 0, isPositive ); // $ExpectError - - cueveryByRight.assign( x, y, '1', 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, true, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, false, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, null, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, void 0, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, {}, 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, [], 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 0, 0, 1, 1, 1 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cueveryByRight.assign( x, y, 1, '1', isPositive ); // $ExpectError - cueveryByRight.assign( x, y, 1, true, isPositive ); // $ExpectError - cueveryByRight.assign( x, y, 1, false, isPositive ); // $ExpectError - cueveryByRight.assign( x, y, 1, null, isPositive ); // $ExpectError - cueveryByRight.assign( x, y, 1, void 0, isPositive ); // $ExpectError - cueveryByRight.assign( x, y, 1, {}, isPositive ); // $ExpectError - cueveryByRight.assign( x, y, 1, [], isPositive ); // $ExpectError - - cueveryByRight.assign( x, y, 1, '1', isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, true, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, false, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, null, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, void 0, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, {}, isPositive, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, [], isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a function... -{ - const x = [ 0, 0, 1, 1, 1 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cueveryByRight.assign( x, y, 1, 0, 2 ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, false ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, true ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, 'abc' ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, void 0 ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, [] ); // $ExpectError - - cueveryByRight.assign( x, y, 1, 0, 2, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, false, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, true, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, 'abc', {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, void 0, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, {}, {} ); // $ExpectError - cueveryByRight.assign( x, y, 1, 0, [], {} ); // $ExpectError -} -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cueveryByRight.assign(); // $ExpectError - cueveryByRight.assign( [] ); // $ExpectError - cueveryByRight.assign( [], [] ); // $ExpectError - cueveryByRight.assign( [], [], 2 ); // $ExpectError - cueveryByRight.assign( [], [], 2, {} ); // $ExpectError - cueveryByRight.assign( [], [], 1, 1, {}, [], {} ); // $ExpectError -} diff --git a/base/cuevery-by-right/examples/index.js b/base/cuevery-by-right/examples/index.js deleted file mode 100644 index 134f3e0a8..000000000 --- a/base/cuevery-by-right/examples/index.js +++ /dev/null @@ -1,34 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var cueveryByRight = require( './../lib' ); - -function isPositive( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = discreteUniform( 10, -10, 10 ); -console.log( x ); - -// Cumulatively test whether every array element passes a test, while iterating from right-to-left: -var out = cueveryByRight( x, isPositive ); -console.log( out ); diff --git a/base/cuevery-by-right/lib/assign.js b/base/cuevery-by-right/lib/assign.js deleted file mode 100644 index 9cfb47794..000000000 --- a/base/cuevery-by-right/lib/assign.js +++ /dev/null @@ -1,171 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the provided output array. -* -* @private -* @param {Collection} x - input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 1, 1, 1 ]; -* -* var out = [ 0, 0, 0, 0, 0 ]; -* var arr = indexed( x, out, 1, 0, fcn ); -* // returns [ true, true, true, false, false ] -*/ -function indexed( x, out, stride, offset, predicate, thisArg ) { - var flg; - var io; - var i; - - flg = true; - io = offset; - for ( i = x.length - 1; i >= 0; i-- ) { - if ( flg && !predicate.call( thisArg, x[ i ], i, x ) ) { - flg = false; - } - out[ io ] = flg; - io += stride; - } - return out; -} - -/** -* Cumulatively tests whether every array element in a provided accessor array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 0, 0, 1, 1, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( out ), 1, 0, fcn ); -* -* var v = arr.get( 4 ); -* // returns false -*/ -function accessors( x, out, stride, offset, predicate, thisArg ) { - var xdata; - var odata; - var xget; - var oset; - var flg; - var io; - var i; - - xdata = x.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - flg = true; - for ( i = xdata.length - 1; i >= 0; i-- ) { - if ( flg && !predicate.call( thisArg, xget( xdata, i ), i, xdata ) ) { - flg = false; - } - oset( odata, io, flg ); - io += stride; - } - return odata; -} - - -// MAIN // - -/** -* Cumulatively tests whether every element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the output array. -* -* @param {Collection} x - input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Collection} output array -* -* @example -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 1, 1 ]; -* -* var y = [ false, null, false, null, false, null, false, null ]; -* var out = assign( x, y, 2, 0, fcn ); -* // returns [ true, null, true, null, false, null, false, null ] -* -* var bool = ( y === out ); -* // returns true -*/ -function assign( x, out, stride, offset, predicate, thisArg ) { - var xo; - var oo; - - xo = arraylike2object( x ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - oo.accessorProtocol - ) { - accessors( xo, oo, stride, offset, predicate, thisArg ); - return out; - } - indexed( x, out, stride, offset, predicate, thisArg ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cuevery-by-right/lib/index.js b/base/cuevery-by-right/lib/index.js deleted file mode 100644 index 21b47c374..000000000 --- a/base/cuevery-by-right/lib/index.js +++ /dev/null @@ -1,72 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether every element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left. -* -* @module @stdlib/array/base/cuevery-by-right -* -* @example -* var cueveryByRight = require( '@stdlib/array/base/cuevery-by-right' ); -* -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 1, 1, 1 ]; -* -* var y = cueveryByRight( x, fcn ); -* //returns [ true, true, true, false, false ] -* -* @example -* var cueveryByRight = require( '@stdlib/array/base/cuevery-by-right' ); -* -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 1, 1, 1 ]; -* -* var y1 = cueveryByRight( x, fcn ); -* // returns [ true, true, true, false, false ] -* -* var y2 = [ false, null, false, null, false, null, false, null, false, null ]; -* var out = cueveryByRight.assign( x, y2, 2, 0, fcn ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -* -* var bool = ( out === y2 ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cuevery-by-right/lib/main.js b/base/cuevery-by-right/lib/main.js deleted file mode 100644 index 531b47234..000000000 --- a/base/cuevery-by-right/lib/main.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Array} output array -* -* @example -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 1, 1, 1 ]; -* -* var y = cueveryByRight( x, fcn ); -* // returns [ true, true, true, false, false ] -*/ -function cueveryByRight( x, predicate, thisArg ) { - var out = filled( true, x.length ); - return assign( x, out, 1, 0, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = cueveryByRight; diff --git a/base/cuevery-by-right/package.json b/base/cuevery-by-right/package.json deleted file mode 100644 index cb812e490..000000000 --- a/base/cuevery-by-right/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/cuevery-by-right", - "version": "0.0.0", - "description": "Cumulatively test whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "generic", - "array", - "cumulative", - "data", - "structure", - "test", - "predicate", - "all", - "every", - "array.every", - "array-like", - "validate" - ] -} diff --git a/base/cuevery-by-right/test/test.assign.js b/base/cuevery-by-right/test/test.assign.js deleted file mode 100644 index 5e61c6816..000000000 --- a/base/cuevery-by-right/test/test.assign.js +++ /dev/null @@ -1,220 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cueveryByRight = require( './../lib/assign.js' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return v > 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cueveryByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to a provided output array (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 1, 1, 0, 0, 1 ]; - y = [ false, true, false, true, false ]; - - actual = cueveryByRight( x, y, 1, 0, isPositive ); - expected = [ true, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0, 0, 1, 1 ]; - y = [ false, null, false, null, false, null, false, null ]; - - actual = cueveryByRight( x, y, 2, 0, isPositive ); - expected = [ true, null, true, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0, 0, 1, 1, 1 ]; - y = [ false, false, false, true, true, true ]; - - actual = cueveryByRight( x, y, 1, 1, isPositive ); - expected = [ false, true, true, true, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cueveryByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1 ]; - y = [ false, false ]; - - actual = cueveryByRight( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to a provided output array (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 0.0, 1.0, 0.0, 1.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cueveryByRight( x, y, 1, 0, isPositive ); - expected = [ true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 1.0 ] ); - y = [ false, null, false, null, false, null, false, null ]; - - actual = cueveryByRight( x, y, 2, 0, isPositive ); - expected = [ true, null, true, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 0.0, 0.0, 1.0, 1.0 ] ); - y = [ true, false, false, true, true, true ]; - - actual = cueveryByRight( x, y, 1, 1, isPositive ); - expected = [ true, true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cueveryByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - y = [ false, false ]; - - actual = cueveryByRight( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to a provided output array ( accessor )', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ 0, 1, 1, 1, 1 ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cueveryByRight( x, y, 1, 0, isPositive ); - expected = [ true, true, true, true, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 0, 0, 1 ] ); - ybuf = [ false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cueveryByRight( x, y, 2, 0, isPositive ); - expected = [ true, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 0, 0, 1, 1 ] ); - ybuf = [ true, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cueveryByRight( x, y, 1, 1, isPositive ); - expected = [ true, true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 1, 1, 0 ] ); - ybuf = [ true, true, true, true, true ]; - y = toAccessorArray( ybuf ); - - actual = cueveryByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cueveryByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1 ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cueveryByRight( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/cuevery-by-right/test/test.js b/base/cuevery-by-right/test/test.js deleted file mode 100644 index 38c6c1621..000000000 --- a/base/cuevery-by-right/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cueveryByRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cueveryByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cueveryByRight, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cueveryByRight, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cuevery-by-right/test/test.main.js b/base/cuevery-by-right/test/test.main.js deleted file mode 100644 index 5328fc08a..000000000 --- a/base/cuevery-by-right/test/test.main.js +++ /dev/null @@ -1,141 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cueveryByRight = require( './../lib' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return v > 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cueveryByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left (generic)', function test( t ) { - var expected; - var actual; - var x; - - function isNotNull( v ) { - return v !== null; - } - x = [ 0, 0, 1, 1, 1 ]; - - actual = cueveryByRight( x, isPositive ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1.0, 1.0, 1.0, 0.0, 0.0 ]; - actual = cueveryByRight( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false, true, true, true, true ]; - actual = cueveryByRight( x, isPositive ); - expected = [ true, true, true, true, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ null, {}, {} ]; - actual = cueveryByRight( x, isNotNull ); - expected = [ true, true, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left (typed)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 1.0 ] ); - actual = cueveryByRight(x, isPositive); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cueveryByRight( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cueveryByRight( x, isPositive ); - expected = [ true, true, true, true, true ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 0.0, 1.0 ] ); - actual = cueveryByRight( x, isPositive ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 0.0, 1.0, 1.0, 1.0 ] ); - actual = cueveryByRight( x, isPositive ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left (accessor)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 1, 1, 1 ] ); - - actual = cueveryByRight( x, isPositive ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 1, 1, 1 ] ); - actual = cueveryByRight( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); - actual = cueveryByRight( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 0 ] ); - actual = cueveryByRight( x, isPositive ); - expected = [ false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 1, 1, 1 ] ); - actual = cueveryByRight( x, isPositive ); - expected = [ true, true, true, true, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/cuevery-by/README.md b/base/cuevery-by/README.md deleted file mode 100644 index 346246a63..000000000 --- a/base/cuevery-by/README.md +++ /dev/null @@ -1,145 +0,0 @@ - - -# cueveryBy - -> Cumulatively test whether every array element in a provided array passes a test implemented by a predicate function. - -
- -## Usage - -```javascript -var cueveryBy = require( '@stdlib/array/base/cuevery-by' ); -``` - -#### cueveryBy( x, predicate\[, thisArg ] ) - -Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function. - -```javascript -function fcn( value) { - return ( value > 0 ); -} - -var x = [ 1, 1, 0, 0, 0 ]; - -var y = cueveryBy( x, fcn ); -// returns [ true, true, false, false, false ] -``` - -The invoked `predicate` function is provided three arguments: - -- **value**: collection element. -- **index**: collection index. -- **collection**: input collection. - -To set the function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return ( v > 0 ); -} - -var x = [ 1, 1, 0, 0, 0 ]; - -var context = { - 'count': 0 -}; - -var bool = cueveryBy( x, fcn, context ); -// returns [ true, true, false, false, false ] - -var count = context.count; -// returns 3 -``` - -#### cueveryBy.assign( x, out, stride, offset, predicate\[, thisArg ] ) - -Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function and assigns the results to a provided output array. - -```javascript -function fcn( v ) { - return ( v > 0 ); -} - -var x = [ 1, 1, 0, 0, 0 ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cueveryBy.assign( x, y, 2, 0, fcn ); -// returns [ true, null, true, null, false, null, false, null, false, null ] - -var bool = ( out === y ); -// returns true -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cueveryBy = require( '@stdlib/array/base/cuevery-by' ); - -function fcn( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = bernoulli( 10, 0.8 ); -console.log( x ); - -// Cumulatively tests whether every array element passes a test: -var y = cueveryBy( x, fcn ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cuevery-by/benchmark/benchmark.assign.length.js b/base/cuevery-by/benchmark/benchmark.assign.length.js deleted file mode 100644 index 36d68b375..000000000 --- a/base/cuevery-by/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cueveryBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( false, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cueveryBy.assign( x, y, 1, 0, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cuevery-by/benchmark/benchmark.js b/base/cuevery-by/benchmark/benchmark.js deleted file mode 100644 index 04b082237..000000000 --- a/base/cuevery-by/benchmark/benchmark.js +++ /dev/null @@ -1,53 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var cueveryBy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cueveryBy( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cuevery-by/benchmark/benchmark.length.js b/base/cuevery-by/benchmark/benchmark.length.js deleted file mode 100644 index d38234a4d..000000000 --- a/base/cuevery-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cueveryBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cueveryBy( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cuevery-by/docs/repl.txt b/base/cuevery-by/docs/repl.txt deleted file mode 100644 index 4afd732fa..000000000 --- a/base/cuevery-by/docs/repl.txt +++ /dev/null @@ -1,77 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Cumulatively tests whether every array element in a provided array passes a - test implemented by a predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 1, 1, 0, 0, 0 ]; - > var y = {{alias}}( x, fcn ) - [ true, true, false, false, false ] - - -{{alias}}.assign( x, out, stride, offset, predicate[, thisArg] ) - Cumulatively tests whether every array element in a provided array passes a - test implemented by a predicate function and assigns the values to elements - in a provided output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 1, 1, 0, 0 ]; - > var out = [ false, null, false, null, false, null, false, null ]; - > var arr = {{alias}}.assign( x, out, 2, 0, fcn ) - [ true, null, true, null, false, null, false, null ] - > var bool = ( arr === out ) - true - - See Also - -------- diff --git a/base/cuevery-by/docs/types/index.d.ts b/base/cuevery-by/docs/types/index.d.ts deleted file mode 100644 index 6ce4075fd..000000000 --- a/base/cuevery-by/docs/types/index.d.ts +++ /dev/null @@ -1,199 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, BooleanArray } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `cueveryBy`. -*/ -interface CuEveryBy { - /** - * Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function. - * - * @param x - input array - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 1, 1, 1, 0, 0 ]; - * - * var y = cueveryBy( x, isPositive ); - * // returns [ true, true, true, false, false ]; - */ - ( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function and assigns the results to the provided output array. - * - * @param x - input array - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 1, 1, 0, 0, 0 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cueveryBy.assign( x, y, 2, 0, isPositive ); - * // returns [ true, null, true, null, false, null, false, null, false, null ]; - */ - assign( x: Collection | AccessorArrayLike, out: Array, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function and assigns the results to the provided output array. - * - * @param x - input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * var BooleanArray = require( './../../../../bool' ); - * - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = new BooleanArray( [ false, false, false, false, false, false, false, false, false, false ] ); - * - * var arr = cueveryBy.assign( x, y, 2, 0, isPositive ); - * // returns - * - * var v = arr.get( 4 ); - * // returns false - */ - assign( x: Collection | AccessorArrayLike, out: U, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): U; - - /** - * Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function and assigns the results to the provided output array. - * - * @param x - input array - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 1, 1, 0, 0, 0 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cueveryBy.assign( x, y, 2, 0, isPositive ); - * // returns [ true, null, true, null, false, null, false, null, false, null ]; - */ - assign( x: Collection | AccessorArrayLike, out: Collection | AccessorArrayLike, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Collection | AccessorArrayLike; -} - -/** -* Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - test function -* @param thisArg - execution context -* @returns output array -* -* @example -* function isPositive( v ) { -* return ( v > 0 ); -* } -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var result = cueveryBy( x, isPositive ); -* // returns [ true, true, false, false, false ] -* -* @example -* function isPositive( v ) { -* return ( v > 0 ); -* } -* var x = [ 1, 1, 0, 0, 0 ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cueveryBy.assign( x, y, 2, 0, isPositive ); -* // returns [ true, null, true, null, false, null, false, null, false, null ]; -*/ -declare var cueveryBy: CuEveryBy; - - -// EXPORTS // - -export = cueveryBy; diff --git a/base/cuevery-by/docs/types/test.ts b/base/cuevery-by/docs/types/test.ts deleted file mode 100644 index aa86fad56..000000000 --- a/base/cuevery-by/docs/types/test.ts +++ /dev/null @@ -1,206 +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. -*/ - -import cueveryBy = require( './index' ); - -const isPositive = ( v: number ): boolean => { - return ( v > 0 ); -}; - - -// TESTS // - -// The function returns an array... -{ - cueveryBy( [ 1, 2, 3, 4 ], isPositive ); // $ExpectType boolean[] - cueveryBy( [ 1, 2, 3, 4 ], isPositive ); // $ExpectType boolean[] - - cueveryBy( [ 1, 2, 3, 4 ], isPositive, {} ); // $ExpectType boolean[] - cueveryBy( [ 1, 2, 3, 4 ], isPositive, {} ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cueveryBy( 1, isPositive ); // $ExpectError - cueveryBy( true, isPositive ); // $ExpectError - cueveryBy( false, isPositive ); // $ExpectError - cueveryBy( null, isPositive ); // $ExpectError - cueveryBy( void 0, isPositive ); // $ExpectError - cueveryBy( {}, isPositive ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not function... -{ - cueveryBy( [ 1, 2, 3, 4 ], 1 ); // $ExpectError - cueveryBy( [], 1 ); // $ExpectError - cueveryBy( [], true ); // $ExpectError - cueveryBy( [], false ); // $ExpectError - cueveryBy( [], null ); // $ExpectError - cueveryBy( [], void 0 ); // $ExpectError - cueveryBy( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cueveryBy(); // $ExpectError - cueveryBy( [] ); // $ExpectError - cueveryBy( [], [], 'throw', {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 1, 2, 3, 4 ]; - - cueveryBy.assign( x, [ 0, 0, 0, 0 ], 1, 0, isPositive ); // $ExpectType (number | boolean)[] - cueveryBy.assign( x, new Float64Array( 4 ), 1, 0, isPositive ); // $ExpectType Float64Array - cueveryBy.assign( x, new Float32Array( 4 ), 1, 0, isPositive ); // $ExpectType Float32Array - cueveryBy.assign( x, new Int32Array( 4 ), 1, 0, isPositive ); // $ExpectType Int32Array - cueveryBy.assign( x, new Int16Array( 4 ), 1, 0, isPositive ); // $ExpectType Int16Array - cueveryBy.assign( x, new Int8Array( 4 ), 1, 0, isPositive ); // $ExpectType Int8Array - cueveryBy.assign( x, new Uint32Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint32Array - cueveryBy.assign( x, new Uint16Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint16Array - cueveryBy.assign( x, new Uint8Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint8Array - cueveryBy.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive ); // $ExpectType Uint8ClampedArray - - cueveryBy.assign( x, [ 0, 0, 0, 0 ], 1, 0, isPositive, {} ); // $ExpectType (number | boolean)[] - cueveryBy.assign( x, new Float64Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float64Array - cueveryBy.assign( x, new Float32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float32Array - cueveryBy.assign( x, new Int32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int32Array - cueveryBy.assign( x, new Int16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int16Array - cueveryBy.assign( x, new Int8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int8Array - cueveryBy.assign( x, new Uint32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint32Array - cueveryBy.assign( x, new Uint16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint16Array - cueveryBy.assign( x, new Uint8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8Array - cueveryBy.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8ClampedArray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cueveryBy.assign( 1, x, 2, 0, isPositive ); // $ExpectError - cueveryBy.assign( true, x, 2, 0, isPositive ); // $ExpectError - cueveryBy.assign( false, x, 2, 0, isPositive ); // $ExpectError - cueveryBy.assign( null, x, 2, 0, isPositive ); // $ExpectError - cueveryBy.assign( void 0, x, 2, 0, isPositive ); // $ExpectError - cueveryBy.assign( {}, x, 2, 0, isPositive ); // $ExpectError - - cueveryBy.assign( 1, x, 2, 0, isPositive, {} ); // $ExpectError - cueveryBy.assign( true, x, 2, 0, isPositive, {} ); // $ExpectError - cueveryBy.assign( false, x, 2, 0, isPositive, {} ); // $ExpectError - cueveryBy.assign( null, x, 2, 0, isPositive, {} ); // $ExpectError - cueveryBy.assign( void 0, x, 2, 0, isPositive, {} ); // $ExpectError - cueveryBy.assign( {}, x, 2, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cueveryBy.assign( x, 1, 1, 0, isPositive ); // $ExpectError - cueveryBy.assign( x, true, 1, 0, isPositive ); // $ExpectError - cueveryBy.assign( x, false, 1, 0, isPositive ); // $ExpectError - cueveryBy.assign( x, null, 1, 0, isPositive ); // $ExpectError - cueveryBy.assign( x, void 0, 1, 0, isPositive ); // $ExpectError - cueveryBy.assign( x, {}, 1, 0, isPositive ); // $ExpectError - - cueveryBy.assign( x, 1, 1, 0, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, true, 1, 0, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, false, 1, 0, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, null, 1, 0, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, void 0, 1, 0, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, {}, 1, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a valid index... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cueveryBy.assign( x, y, '1', 1, isPositive ); // $ExpectError - cueveryBy.assign( x, y, true, 1, isPositive ); // $ExpectError - cueveryBy.assign( x, y, false, 1, isPositive ); // $ExpectError - cueveryBy.assign( x, y, null, 1, isPositive ); // $ExpectError - cueveryBy.assign( x, y, void 0, 1, isPositive ); // $ExpectError - cueveryBy.assign( x, y, {}, 1, isPositive ); // $ExpectError - cueveryBy.assign( x, y, [], 1, isPositive ); // $ExpectError - cueveryBy.assign( x, y, ( x: number ): number => x, 1, isPositive ); // $ExpectError - - cueveryBy.assign( x, y, '1', 1, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, true, 1, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, false, 1, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, null, 1, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, void 0, 1, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, {}, 1, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, [], 1, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, ( x: number ): number => x, 1, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cueveryBy.assign( x, y, 0, '1', isPositive ); // $ExpectError - cueveryBy.assign( x, y, 0, true, isPositive ); // $ExpectError - cueveryBy.assign( x, y, 0, false, isPositive ); // $ExpectError - cueveryBy.assign( x, y, 0, null, isPositive ); // $ExpectError - cueveryBy.assign( x, y, 0, void 0, isPositive ); // $ExpectError - cueveryBy.assign( x, y, 0, {}, isPositive ); // $ExpectError - cueveryBy.assign( x, y, 0, [], isPositive ); // $ExpectError - - cueveryBy.assign( x, y, 0, '1', isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, true, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, false, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, null, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, void 0, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, {}, isPositive, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, [], isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a function... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cueveryBy.assign( x, y, 0, 1, '1' ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, true ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, false ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, null ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, void 0 ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, [] ); // $ExpectError - - cueveryBy.assign( x, y, 0, 1, '1', {} ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, true, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, false, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, null, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, void 0, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, {}, {} ); // $ExpectError - cueveryBy.assign( x, y, 0, 1, [], {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cueveryBy.assign(); // $ExpectError - cueveryBy.assign( [] ); // $ExpectError - cueveryBy.assign( [], [] ); // $ExpectError - cueveryBy.assign( [], [], 'throw' ); // $ExpectError - cueveryBy.assign( [], [], 'throw', [] ); // $ExpectError - cueveryBy.assign( [], [], 'throw', [], 1, 0, {} ); // $ExpectError -} diff --git a/base/cuevery-by/examples/index.js b/base/cuevery-by/examples/index.js deleted file mode 100644 index 4f66c3816..000000000 --- a/base/cuevery-by/examples/index.js +++ /dev/null @@ -1,34 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cueveryBy = require( './../lib' ); - -function fcn( value ) { - return ( value > 0 ); -} - -// Generate an array of random values: -var x = bernoulli( 10, 0.8 ); -console.log( x ); - -// Cumulatively tests whether every array element passes a test: -var y = cueveryBy( x, fcn ); -console.log( y ); diff --git a/base/cuevery-by/lib/assign.js b/base/cuevery-by/lib/assign.js deleted file mode 100644 index 163a09ce2..000000000 --- a/base/cuevery-by/lib/assign.js +++ /dev/null @@ -1,178 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var out = [ 0, 0, 0, 0, 0 ]; -* var arr = indexed( x, out, 1, 0, isPositive ); -* // returns [ true, true, false, false, false ] -*/ -function indexed( x, out, stride, offset, predicate, thisArg ) { - var flg; - var io; - var i; - - flg = true; - io = offset; - for ( i = 0; i <= x.length - 1; i++ ) { - if ( !flg ) { - out[ io ] = flg; - io += stride; - continue; - } - if ( !predicate.call( thisArg, x[ i ], i, x ) ) { - flg = false; - } - out[ io ] = flg; - io += stride; - } - return out; -} - -/** -* Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function. -* -* @private -* @param {Object} x - input array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 1, 1, 0, 0, 0 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( out ), 1, 0, isPositive ); -* -* var v = arr.get( 4 ); -* // returns false -*/ -function accessors( x, out, stride, offset, predicate, thisArg ) { - var xdata; - var odata; - var xget; - var oset; - var flg; - var io; - var i; - - xdata = x.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - flg = true; - for ( i = 0; i <= xdata.length - 1; i++ ) { - if ( !flg ) { - oset( odata, io, flg ); - io += stride; - continue; - } - if ( !predicate.call( thisArg, xget( xdata, i ), i, xdata ) ) { - flg = false; - } - oset( odata, io, flg ); - io += stride; - } - return odata; -} - - -// MAIN // - -/** -* Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 1, 0, 1 ]; -* -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* var out = assign( x, y, 2, 0, isPositive ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -* -* var bool = ( y === out ); -* // returns true -*/ -function assign( x, out, stride, offset, predicate, thisArg ) { - var xo; - var oo; - - xo = arraylike2object( x ); - oo = arraylike2object( out ); - if ( xo.accessorProtocol || oo.accessorProtocol ) { - accessors( xo, oo, stride, offset, predicate, thisArg ); - return out; - } - indexed( x, out, stride, offset, predicate, thisArg ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cuevery-by/lib/index.js b/base/cuevery-by/lib/index.js deleted file mode 100644 index a294acf89..000000000 --- a/base/cuevery-by/lib/index.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether every array element in a provided array passes a test implemented by a predicate function. -* -* @module @stdlib/array/base/cuevery-by -* -* @example -* var cueveryBy = require( '@stdlib/array/base/cuevery-by' ); -* -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 1, 0, 1 ]; -* var y = cueveryBy( x, isPositive ); -* // returns [ true, true, true, false, false ] -* -* @example -* var cueveryBy = require( '@stdlib/array/base/cuevery-by' ); -* -* var x = [ 1, 1, 1, 0, 1 ]; -* -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* var out = cueveryBy.assign( x, y, 2, 0, isPositive ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cuevery-by/lib/main.js b/base/cuevery-by/lib/main.js deleted file mode 100644 index 035270773..000000000 --- a/base/cuevery-by/lib/main.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function. -* -* @param {Collection} x - input collection -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Array} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 1, 0, 1 ]; -* -* var y = cueveryBy( x, isPositive ); -* // returns [ true, true, true, false, false ] -*/ -function cueveryBy( x, predicate, thisArg ) { - var out = filled( true, x.length ); - return assign( x, out, 1, 0, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = cueveryBy; diff --git a/base/cuevery-by/package.json b/base/cuevery-by/package.json deleted file mode 100644 index d772df514..000000000 --- a/base/cuevery-by/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/cuevery-by", - "version": "0.0.0", - "description": "Cumulatively test whether every array element in a provided array passes a test implemented by a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "utils", - "generic", - "array", - "cuevery-by", - "cumulative", - "test", - "every", - "array.every", - "validate" - ] -} diff --git a/base/cuevery-by/test/test.assign.js b/base/cuevery-by/test/test.assign.js deleted file mode 100644 index 7b4a7982d..000000000 --- a/base/cuevery-by/test/test.assign.js +++ /dev/null @@ -1,244 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cueveryBy = require( './../lib/assign.js' ); - - -// TESTS // - -function isPositive( v ) { - return ( v > 0 ); -} - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cueveryBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 1, 1, 1, 0, 1 ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cueveryBy( x, y, 2, 0, isPositive); - expected = [ true, null, true, null, true, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 0, 0 ]; - y = [ false, null, false, null, false, null, false, null ]; - - actual = cueveryBy( x, y, 2, 0, isPositive ); - expected = [ true, null, true, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0, 0, 1, 0, 1 ]; - y = [ false, false, false, true, true, true ]; - - actual = cueveryBy( x, y, 1, 1, isPositive ); - expected = [ false, false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cueveryBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1 ]; - y = [ false, false ]; - - actual = cueveryBy( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cueveryBy( x, y, 1, 0, isPositive ); - expected = [ true, true, true, true, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null ]; - - actual = cueveryBy( x, y, 2, 0, isPositive ); - expected = [ true, null, true, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 1.0, 0.0, 0.0 ] ); - y = [ true, false, false, true, true, true ]; - - actual = cueveryBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cueveryBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - y = [ false, false ]; - - actual = cueveryBy( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function (accessor)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ 1, 0, 0, 0, 1 ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cueveryBy( x, y, 1, 0, isPositive ); - expected = [ true, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 1, 0 ] ); - ybuf = [ false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cueveryBy( x, y, 2, 0, isPositive ); - expected = [ false, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 1, 0, 0 ] ); - ybuf = [ true, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cueveryBy( x, y, 1, 1, isPositive ); - expected = [ true, true, true, true, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 0, 0, 0, 1 ] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cueveryBy( x, y, 1, 0, isPositive ); - expected = [ true, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cueveryBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1 ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cueveryBy( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - var x; - var y; - - ctx = { - 'count': 0 - }; - - x = [ 1, 1, 1, 0, 1 ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cueveryBy( x, y, 2, 0, predicate, ctx); - expected = [ true, null, true, null, true, null, false, null, false, null ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cuevery-by/test/test.js b/base/cuevery-by/test/test.js deleted file mode 100644 index d49635ce2..000000000 --- a/base/cuevery-by/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cueveryBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cueveryBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cueveryBy, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cueveryBy, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cuevery-by/test/test.main.js b/base/cuevery-by/test/test.main.js deleted file mode 100644 index 0c1f23e90..000000000 --- a/base/cuevery-by/test/test.main.js +++ /dev/null @@ -1,172 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var cueveryBy = require( './../lib' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return ( v > 0 ); -} - -function isNotNull( v ) { - return v !== null; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual(typeof cueveryBy, 'function', 'main export is a function'); - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 0, 4 ]; - - actual = cueveryBy( x, isPositive ); - expected = [true, true, false, false]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0.0, 0.0, 0.0, 1.0, 1.0 ]; - actual = cueveryBy( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, true, true, true, true ]; - actual = cueveryBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ {}, null, {} ]; - actual = cueveryBy( x, isNotNull ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function (typed)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 1.0, 1.0, 0.0, 1.0 ] ); - actual = cueveryBy( x, isPositive ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cueveryBy( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual =cueveryBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 0.0 ] ); - actual = cueveryBy( x, isPositive ); - expected = [ true, true, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, -2.0, 3.0, 0.0, 1.0 ] ); - actual = cueveryBy( x, isPositive ); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function (accessor array)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 0, 0, 0 ] ); - - actual = cueveryBy( x, isPositive ); - expected = [true, true, false, false, false]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); - actual = cueveryBy( x, isPositive ); - expected = [false, false, false, false, false]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 1, 1, 1 ] ); - actual = cueveryBy( x, isPositive ); - expected = [true, true, true, true, true]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 0 ] ); - actual = cueveryBy( x, isPositive ); - expected = [ false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 0, 0, 0, 0 ] ); - actual = cueveryBy( x, isPositive ); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array as a first argument', function test( t ) { - var x = []; - t.deepEqual( cueveryBy( x, isPositive ), [], 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - ctx = { - 'count': 0 - }; - - x = [ 1, 2, 0, 4 ]; - - out = cueveryBy( x, predicate, ctx ); - expected = [ true, true, false, false ]; - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cuevery/README.md b/base/cuevery/README.md deleted file mode 100644 index 5ce4595c8..000000000 --- a/base/cuevery/README.md +++ /dev/null @@ -1,113 +0,0 @@ - - -# cuevery - -> Cumulatively test whether every element in a provided array is truthy. - -
- -## Usage - -```javascript -var cuevery = require( '@stdlib/array/base/cuevery' ); -``` - -#### cuevery( x ) - -Cumulatively tests whether every element in a provided array is truthy. - -```javascript -var x = [ true, true, true, false, true ]; - -var y = cuevery( x ); -// returns [ true, true, true, false, false ]; -``` - -#### cuevery.assign( x, out, stride, offset ) - -Cumulatively tests whether every element in a provided array is truthy and assigns results to a provided output array. - -```javascript -var x = [ true, true, true, false, true ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cuevery.assign( x, y, 2, 0 ); -// returns [ true, null, true, null, true, null, false, null, false, null ] - -var bool = ( out === y ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cuevery = require( '@stdlib/array/base/cuevery' ); - -// Create an array of random values: -var x = bernoulli( 10, 0.9 ); -console.log( x ); - -// Cumulatively determine whether values are truthy: -var out = cuevery( x ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cuevery/benchmark/benchmark.assign.length.js b/base/cuevery/benchmark/benchmark.assign.length.js deleted file mode 100644 index fd7b69888..000000000 --- a/base/cuevery/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cuevery = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( false, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuevery.assign( x, y, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cuevery/benchmark/benchmark.js b/base/cuevery/benchmark/benchmark.js deleted file mode 100644 index 094007db5..000000000 --- a/base/cuevery/benchmark/benchmark.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var cuevery = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var i; - var v; - - x = [ false, false, true, false, false ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuevery( x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cuevery/benchmark/benchmark.length.js b/base/cuevery/benchmark/benchmark.length.js deleted file mode 100644 index 9877eacdf..000000000 --- a/base/cuevery/benchmark/benchmark.length.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cuevery = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cuevery( x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cuevery/docs/repl.txt b/base/cuevery/docs/repl.txt deleted file mode 100644 index 99195b8a6..000000000 --- a/base/cuevery/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Cumulatively tests whether every element in a provided array is truthy. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ true, true, true, false, true ]; - > var y = {{alias}}( x ) - [ true, true, true, false, false ]; - - -{{alias}}.assign( x, y, stride, offset ) - Cumulatively tests whether every element in an array is truthy and assigns - results to a provided output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - y: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - Returns - ------- - y: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ true, true, true, false, true ]; - > var y = [ false, null, false, null, false, null, false, null, false ]; - > var result = {{alias}}.assign( x, y, 2, 0 ) - [ true, null, true, null, true, null, false, null, false ] - - See Also - -------- - diff --git a/base/cuevery/docs/types/index.d.ts b/base/cuevery/docs/types/index.d.ts deleted file mode 100644 index 170b3ee97..000000000 --- a/base/cuevery/docs/types/index.d.ts +++ /dev/null @@ -1,86 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Interface describing `cuevery`. -*/ -interface CuEvery { - /** - * Cumulatively tests whether every element in a provided array is truthy. - * - * @param x - input array - * @returns output array - * - * @example - * var x = [ true, true, true, false, true ]; - * - * var y = cuevery( x ); - * // returns [ true, true, true, false, false ]; - */ - ( x: Collection | AccessorArrayLike ): Array; - - /** - * Cumulatively tests whether every element in an array is truthy and assigns the results to a provided output array. - * - * @param x - input array - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ true, true, true, false, false ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cuevery.assign( x, y, 2, 0 ); - * // returns [ true, null, true, null, true, null, false, null, false, null ]; - */ - assign | AccessorArrayLike>( x: Collection | AccessorArrayLike, y: U, stride: number, offset: number ): U; -} - -/** -* Cumulatively tests whether every element in a provided array is truthy. -* -* @param x - input array -* @returns output array -* -* @example -* var x = [ true, true, true, false, true ]; -* -* var result = cuevery( x ); -* // returns [ true, true, true, false, false ]; -* -* @example -* var x = [ true, true, true, false, true ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cuevery.assign( x, y, 2, 0 ); -* // returns [ true, null, true, null, true, null, false, null, false, null ]; -*/ -declare var cuevery: CuEvery; - - -// EXPORTS // - -export = cuevery; diff --git a/base/cuevery/docs/types/test.ts b/base/cuevery/docs/types/test.ts deleted file mode 100644 index 8fa67c985..000000000 --- a/base/cuevery/docs/types/test.ts +++ /dev/null @@ -1,114 +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. -*/ - - -import cuevery = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - cuevery( [ false, false, true, false, false ] ); // $ExpectType boolean[] - cuevery( [ false, false, true, false, false ] ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cuevery( 1 ); // $ExpectError - cuevery( true ); // $ExpectError - cuevery( false ); // $ExpectError - cuevery( null ); // $ExpectError - cuevery( void 0 ); // $ExpectError - cuevery( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cuevery(); // $ExpectError - cuevery( [], [] ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuevery.assign( x, y, 2, 0 ); // $ExpectType (boolean | null)[] -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const x = [ false, false, true, false, false ]; - - cuevery.assign( 1, x, 2, 0 ); // $ExpectError - cuevery.assign( true, x, 2, 0 ); // $ExpectError - cuevery.assign( false, x, 2, 0 ); // $ExpectError - cuevery.assign( null, x, 2, 0 ); // $ExpectError - cuevery.assign( void 0, x, 2, 0 ); // $ExpectError - cuevery.assign( {}, x, 2, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ false, false, true, false, false ]; - - cuevery.assign( x, 1, 2, 0 ); // $ExpectError - cuevery.assign( x, true, 2, 0 ); // $ExpectError - cuevery.assign( x, false, 2, 0 ); // $ExpectError - cuevery.assign( x, null, 2, 0 ); // $ExpectError - cuevery.assign( x, void 0, 2, 0 ); // $ExpectError - cuevery.assign( x, {}, 2, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuevery.assign( x, y , '1', 0 ); // $ExpectError - cuevery.assign( x, y , true, 0 ); // $ExpectError - cuevery.assign( x, y , false, 0 ); // $ExpectError - cuevery.assign( x, y , null, 0 ); // $ExpectError - cuevery.assign( x, y , void 0, 0 ); // $ExpectError - cuevery.assign( x, y , {}, 0 ); // $ExpectError - cuevery.assign( x, y , [], 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cuevery.assign( x, y, 1, '1' ); // $ExpectError - cuevery.assign( x, y, 1, true ); // $ExpectError - cuevery.assign( x, y, 1, false ); // $ExpectError - cuevery.assign( x, y, 1, null ); // $ExpectError - cuevery.assign( x, y, 1, void 0 ); // $ExpectError - cuevery.assign( x, y, 1, {} ); // $ExpectError - cuevery.assign( x, y, 1, [] ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cuevery.assign(); // $ExpectError - cuevery.assign( [] ); // $ExpectError - cuevery.assign( [], [] ); // $ExpectError - cuevery.assign( [], [], 2 ); // $ExpectError - cuevery.assign( [], [], 1, 1, {} ); // $ExpectError -} diff --git a/base/cuevery/examples/index.js b/base/cuevery/examples/index.js deleted file mode 100644 index 6e47b7136..000000000 --- a/base/cuevery/examples/index.js +++ /dev/null @@ -1,30 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cuevery = require( './../lib' ); - -// Create an array of random values: -var x = bernoulli( 10, 0.9 ); -console.log( x ); - -// Cumulatively determine whether values are truthy: -var out = cuevery( x ); -console.log( out ); diff --git a/base/cuevery/lib/assign.js b/base/cuevery/lib/assign.js deleted file mode 100644 index cb8e8bd1a..000000000 --- a/base/cuevery/lib/assign.js +++ /dev/null @@ -1,291 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplex128Array = require( './../../../base/assert/is-complex128array' ); -var isComplex64Array = require( './../../../base/assert/is-complex64array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether every element in an indexed array is truthy. -* -* @private -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ true, true, true, false, true ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var out = indexed( x, y, 2, 0 ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -*/ -function indexed( x, y, stride, offset ) { - var flg; - var io; - var i; - - flg = true; - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( flg === true && !x[ i ] ) { - flg = false; - } - y[ io ] = flg; - io += stride; - } - return y; -} - -/** -* Cumulatively tests whether every element in a provided accessor array is truthy. -* -* @private -* @param {Object} x - input array object -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ true, true, true, false, true ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] ); -* -* var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns true -* -* v = y.get( 2 ); -* // returns true -* -* v = y.get( 4 ); -* // returns true -* -* v = y.get( 6 ); -* // returns false -* -* v = y.get( 8 ); -* // returns false -*/ -function accessors( x, y, stride, offset ) { - var xdata; - var ydata; - var xget; - var yset; - var flg; - var io; - var i; - - xdata = x.data; - ydata = y.data; - - xget = x.accessors[ 0 ]; - yset = y.accessors[ 1 ]; - - flg = true; - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( flg === true && !xget( xdata, i ) ) { - flg = false; - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - -/** -* Cumulatively tests whether every element in a provided complex number array is truthy. -* -* @private -* @param {Collection} x - array containing interleaved real and imaginary components -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0 ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] ); -* -* var arr = complex( x, arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns true -* -* v = y.get( 2 ); -* // returns true -* -* v = y.get( 4 ); -* // returns true -* -* v = y.get( 6 ); -* // returns false -* -* v = y.get( 8 ); -* // returns false -*/ -function complex( x, y, stride, offset ) { - var ydata; - var yset; - var flg; - var io; - var i; - - yset = y.accessors[ 1 ]; - ydata = y.data; - - flg = true; - io = offset; - for ( i = 0; i < x.length; i += 2 ) { - if ( flg === true && !( x[ i ] || x[ i+1 ] ) ) { - flg = false; - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - -/** -* Cumulatively tests whether every element in a provided boolean array is truthy. -* -* @private -* @param {Collection} x - input array -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 1, 1, 0, 1 ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] ); -* -* var arr = boolean( x, arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns true -* -* v = y.get( 2 ); -* // returns true -* -* v = y.get( 4 ); -* // returns true -* -* v = y.get( 6 ); -* // returns false -* -* v = y.get( 8 ); -* // returns false -*/ -function boolean( x, y, stride, offset ) { - var ydata; - var yset; - var flg; - var io; - var i; - - yset = y.accessors[ 1 ]; - ydata = y.data; - - flg = true; - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( flg === true && !x[ i ] ) { - flg = false; - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - - -// MAIN // - -/** -* Cumulatively tests whether every element in an array is truthy and assigns results to a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ true, true, true, false, true ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var out = assign( x, y, 2, 0 ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -* -* var bool = ( y === out ); -* // returns true -*/ -function assign( x, y, stride, offset ) { - var xo = arraylike2object( x ); - var yo = arraylike2object( y ); - if ( - xo.accessorProtocol || - yo.accessorProtocol - ) { - // If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero... - if ( isComplex128Array( x ) ) { - complex( reinterpret128( x, 0 ), yo, stride, offset ); - } else if ( isComplex64Array( x ) ) { - complex( reinterpret64( x, 0 ), yo, stride, offset ); - } else if ( isBooleanArray( x ) ) { - boolean( reinterpretBoolean( x, 0 ), yo, stride, offset ); - } else { - accessors( xo, yo, stride, offset ); - } - return y; - } - indexed( x, y, stride, offset ); - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cuevery/lib/index.js b/base/cuevery/lib/index.js deleted file mode 100644 index 4ad1e24c9..000000000 --- a/base/cuevery/lib/index.js +++ /dev/null @@ -1,58 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether every element in a provided array is truthy. -* -* @module @stdlib/array/base/cuevery -* -* @example -* var cuevery = require( '@stdlib/array/base/cuevery' ); -* -* var x = [ true, true, true, false, true ] -* -* var y = cuevery( x ); -* // returns [ true, true, true, false, false ] -* -* @example -* var cuevery = require( '@stdlib/array/base/cuevery' ); -* -* var x = [ true, true, true, false, true ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cuevery.assign( x, y, 2, 0 ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cuevery/lib/main.js b/base/cuevery/lib/main.js deleted file mode 100644 index 1c339af00..000000000 --- a/base/cuevery/lib/main.js +++ /dev/null @@ -1,49 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether every element in a provided array is truthy. -* -* @param {Collection} x - input array -* @returns {Array} output array -* -* @example -* var x = [ true, true, true, false, true ]; -* -* var y = cuevery( x ); -* // returns [ true, true, true, false, false ]; -*/ -function cuevery( x ) { - var y = filled( true, x.length ); - return assign( x, y, 1, 0 ); -} - - -// EXPORTS // - -module.exports = cuevery; diff --git a/base/cuevery/package.json b/base/cuevery/package.json deleted file mode 100644 index d07bd30e9..000000000 --- a/base/cuevery/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/cuevery", - "version": "0.0.0", - "description": "Cumulatively test whether every element in a provided array is truthy.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "utils", - "generic", - "array", - "cuevery", - "cumulative", - "test", - "every", - "array.every", - "validate" - ] -} diff --git a/base/cuevery/test/test.assign.js b/base/cuevery/test/test.assign.js deleted file mode 100644 index d87f777f5..000000000 --- a/base/cuevery/test/test.assign.js +++ /dev/null @@ -1,378 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cuevery = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuevery, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is truthy (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ true, false, true, false, true ]; - y = [ false, true, false, true, false ]; - - actual = cuevery( x, y, 1, 0 ); - expected = [ true, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false, false, true, false, false ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuevery( x, y, 2, 0 ); - expected = [ false, null, false, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false, false, true, false, false ]; - y = [ false, false, false, true, true, true ]; - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cuevery( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true ]; - y = [ false, false ]; - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is truthy (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cuevery( x, y, 1, 0 ); - expected = [ true, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuevery( x, y, 2, 0 ); - expected = [ false, null, false, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, false, false, true, true, true ]; - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cuevery( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - y = [ false, false ]; - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is truthy (boolean)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new BooleanArray( [ true, true, true, true, true ] ); - y = [ false, true, false, true, false ]; - - actual = cuevery( x, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, true, false, false ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuevery( x, y, 2, 0 ); - expected = [ false, null, false, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, true, false, false ] ); - y = [ false, false, false, true, true, true ]; - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [] ); - y = [ false, false, false, false, false ]; - - actual = cuevery( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true ] ); - y = [ false, false ]; - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is truthy (complex128)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Complex128Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cuevery( x, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuevery( x, y, 2, 0 ); - expected = [ false, null, false, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, false, false, true, true, true ]; - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cuevery( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 1.0 ] ); - y = [ false, false ]; - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is truthy (complex64)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Complex64Array( [ 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cuevery( x, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cuevery( x, y, 2, 0 ); - expected = [ false, null, false, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, false, false, true, true, true ]; - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cuevery( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 1.0 ] ); - y = [ false, false ]; - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is truthy (accessor)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ true, false, true, false, true ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cuevery( x, y, 1, 0 ); - expected = [ true, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, true, false, false ] ); - ybuf = [ false, null, false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cuevery( x, y, 2, 0 ); - expected = [ false, null, false, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, true, false, false ] ); - ybuf = [ false, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, false, false, false, false ] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuevery( x, y, 1, 0 ); - expected = [ true, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuevery( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ true ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cuevery( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/cuevery/test/test.js b/base/cuevery/test/test.js deleted file mode 100644 index 7bb2a5df5..000000000 --- a/base/cuevery/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cuevery = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuevery, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cuevery, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cuevery, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cuevery/test/test.main.js b/base/cuevery/test/test.main.js deleted file mode 100644 index 1b314d101..000000000 --- a/base/cuevery/test/test.main.js +++ /dev/null @@ -1,237 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cuevery = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cuevery, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is truthy (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ true, true, true, false, true ]; - actual = cuevery( x ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; - actual = cuevery( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, true, true, true, true ]; - actual = cuevery( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ null, {}, null ]; - actual = cuevery( x ); - expected = [ false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, false, false, true, false ]; - actual = cuevery( x ); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is truthy (typed)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cuevery( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is truthy (complex128)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cuevery( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is truthy (boolean)', function test( t ) { - var expected; - var actual; - var x; - - x = new BooleanArray( [ false, false, true, false, false ] ); - actual = cuevery( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, false, false, false ] ); - actual = cuevery( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, true, true, true, true ] ); - actual = cuevery( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, true, true ] ); - actual = cuevery( x ); - expected = [ false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true, false, false ] ); - actual = cuevery( x ); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is truthy (complex64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cuevery( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cuevery( x ); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element of an accessor array is truthy (accessor)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ false, false, true, false, false ] ); - - actual = cuevery( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, false, false, false ] ); - actual = cuevery( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, true, true, true, true ] ); - actual = cuevery( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, true, false ] ); - actual = cuevery( x ); - expected = [ false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, false, false, false, false ] ); - actual = cuevery( x ); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/cunone-by-right/README.md b/base/cunone-by-right/README.md deleted file mode 100644 index 4c2920358..000000000 --- a/base/cunone-by-right/README.md +++ /dev/null @@ -1,145 +0,0 @@ - - -# cunoneByRight - -> Cumulatively test whether every array element in a provided array fails a test implemented by a predicate function, while iterating from right-to-left. - -
- -## Usage - -```javascript -var cunoneByRight = require( '@stdlib/array/base/cunone-by-right' ); -``` - -#### cunoneByRight( x, predicate\[, thisArg ] ) - -Cumulatively tests whether every array element in a provided array fails a test implemented by a `predicate` function, while iterating from right-to-left. - -```javascript -function fcn( value ) { - return value > 0; -} - -var x = [ 1, 1, 0, 0, 0 ]; - -var y = cunoneByRight( x, fcn ); -// returns [ true, true, true, false, false ]; -``` - -The invoked `predicate` function is provided three arguments: - -- **value**: collection element. -- **index**: collection index. -- **collection**: input collection. - -To set the function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return ( v > 0 ); -} - -var x = [ 1, 1, 0, 0, 0 ]; - -var context = { - 'count': 0 -}; - -var bool = cunoneByRight( x, fcn, context ); -// returns [ true, true, true, false, false ] - -var count = context.count; -// returns 4 -``` - -#### cunoneByRight.assign( x, out, stride, offset, predicate\[, thisArg ] ) - -Cumulatively test whether every array element in a provided array fails a test implemented by a `predicate` function, while iterating from right-to-left, and assigns the results to the elements in the output array. - -```javascript -function fcn( v ) { - return v > 0; -} - -var x = [ 1, 1, 0, 0, 0 ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cunoneByRight.assign( x, y, 2, 0, fcn ); -// returns [ true, null, true, null, true, null, false, null, false, null ] - -var bool = ( out === y ); -// returns true -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cunoneByRight = require( '@stdlib/array/base/cunone-by-right' ); - -function fcn( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -// Cumulatively test whether no array element passes a test, while iterating from right-to-left: -var out = cunoneByRight( x, fcn ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cunone-by-right/benchmark/benchmark.assign.length.js b/base/cunone-by-right/benchmark/benchmark.assign.length.js deleted file mode 100644 index 1aee003cd..000000000 --- a/base/cunone-by-right/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cunoneByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( false, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cunoneByRight.assign( x, y, 1, 0, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cunone-by-right/benchmark/benchmark.js b/base/cunone-by-right/benchmark/benchmark.js deleted file mode 100644 index 220af4a97..000000000 --- a/base/cunone-by-right/benchmark/benchmark.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var cunoneByRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var i; - var v; - - x = [ 1, 1, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cunoneByRight( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cunone-by-right/benchmark/benchmark.length.js b/base/cunone-by-right/benchmark/benchmark.length.js deleted file mode 100644 index 2b91415c8..000000000 --- a/base/cunone-by-right/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cunoneByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 0, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cunoneByRight( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cunone-by-right/docs/repl.txt b/base/cunone-by-right/docs/repl.txt deleted file mode 100644 index 533a7ef43..000000000 --- a/base/cunone-by-right/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Cumulatively tests whether every array element in a provided array fails a - test implemented by a predicate function, while iterating from right-to- - left. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 1, 1, 0, 0, 0 ]; - > var y = {{alias}}( x, fcn ) - [ true, true, true, false, false ] - - -{{alias}}.assign( x, out, stride, offset, predicate[, thisArg] ) - Cumulatively tests whether every array element in a provided array fails a - test implemented by a predicate function, while iterating from right-to- - left, and assigns the results to the provided output array. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 1, 1, 0, 0 ]; - > var out = [ false, null, false, null, false, null, false, null ]; - > var arr = {{alias}}.assign( x, out, 2, 0, fcn ) - [ true, null, true, null, false, null, false, null ] - > var bool = ( arr === out ) - true - - See Also - -------- diff --git a/base/cunone-by-right/docs/types/index.d.ts b/base/cunone-by-right/docs/types/index.d.ts deleted file mode 100644 index 099c90e33..000000000 --- a/base/cunone-by-right/docs/types/index.d.ts +++ /dev/null @@ -1,199 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, BooleanArray } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `cunoneByRight`. -*/ -interface CunoneByRight { - /** - * Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function, while iterating from right-to-left. - * - * @param x - input array - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function fcn( v ) { - * return v > 0; - * } - * var x = [ 0, 1, 1, 0, 0 ]; - * - * var y = cunoneByRight( x, fcn ); - * // returns [ true, true, false, false, false ]; - */ - ( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function fcn( v ) { - * return v > 0; - * } - * var x = [ 1, 1, 0, 0, 0 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cunoneByRight.assign( x, y, 2, 0, fcn ); - * // returns [ true, null, true, null, true, null, false, null, false, null ]; - */ - assign( x: Collection | AccessorArrayLike, out: Array, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * var BooleanArray = require( './../../../../bool' ); - * - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = new BooleanArray( [ false, false, false, false, false, false, false, false, false, false ] ); - * - * var arr = cunoneByRight.assign( x, y, 2, 0, isPositive ); - * // returns - * - * var v = arr.get( 4 ); - * // returns false - */ - assign( x: Collection | AccessorArrayLike, out: U, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): U; - - /** - * Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cunoneBy.assign( x, y, 2, 0, isPositive ); - * // returns [ true, null, false, null, false, null, false, null, false, null ] - */ - assign( x: Collection | AccessorArrayLike, out: Collection | AccessorArrayLike, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Collection | AccessorArrayLike; -} - -/** -* Cumulatively tests whether no array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left. -* -* @param x - input array -* @param predicate - test function -* @param thisArg - execution context -* @returns output array -* -* @example -* function fcn( v ) { -* return v > 0; -* } -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var result = cunoneByright( x, fcn ); -* // returns [ true, true, true, false, false ] -* -* @example -* function fcn( v ) { -* return v > 0; -* } -* var x = [ 0, 1, 1, 0, 0 ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cunoneByRight.assign( x, 2, y, 2, 0, fcn ); -* // returns [ true, null, true, null, false, null, false, null, false, null ] -*/ -declare var cunoneByRight: CunoneByRight; - - -// EXPORTS // - -export = cunoneByRight; diff --git a/base/cunone-by-right/docs/types/test.ts b/base/cunone-by-right/docs/types/test.ts deleted file mode 100644 index 9f597246a..000000000 --- a/base/cunone-by-right/docs/types/test.ts +++ /dev/null @@ -1,166 +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. -*/ - - -import cunoneByRight = require( './index' ); - -const isPositive = ( v: number ): boolean => { - return ( v > 0 ); -}; - -// TESTS // - -// The function returns an array... -{ - cunoneByRight( [ 0, 1, 1 ], isPositive ); // $ExpectType boolean[] - cunoneByRight( [ -1, 0, 1, 2 ], isPositive ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cunoneByRight( 1 ); // $ExpectError - cunoneByRight( true ); // $ExpectError - cunoneByRight( false ); // $ExpectError - cunoneByRight( null ); // $ExpectError - cunoneByRight( void 0 ); // $ExpectError - cunoneByRight( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cunoneByRight( x, '1' ); // $ExpectError - cunoneByRight( x, true ); // $ExpectError - cunoneByRight( x, false ); // $ExpectError - cunoneByRight( x, 'abc' ); // $ExpectError - cunoneByRight( x, void 0 ); // $ExpectError - cunoneByRight( x, {} ); // $ExpectError - cunoneByRight( x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cunoneByRight(); // $ExpectError - cunoneByRight( [] ); // $ExpectError - cunoneByRight( [], [], [], [] ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cunoneByRight.assign( x, y, 2, 0, isPositive ); // $ExpectType (boolean | null)[] - cunoneByRight.assign( x, [ 0, 0, 0, 0 ], 1, 0, isPositive ); // $ExpectType (number | boolean)[] - cunoneByRight.assign( x, new Float64Array( 4 ), 1, 0, isPositive ); // $ExpectType Float64Array - cunoneByRight.assign( x, new Float32Array( 4 ), 1, 0, isPositive ); // $ExpectType Float32Array - cunoneByRight.assign( x, new Int32Array( 4 ), 1, 0, isPositive ); // $ExpectType Int32Array - cunoneByRight.assign( x, new Int16Array( 4 ), 1, 0, isPositive ); // $ExpectType Int16Array - cunoneByRight.assign( x, new Int8Array( 4 ), 1, 0, isPositive ); // $ExpectType Int8Array - cunoneByRight.assign( x, new Uint32Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint32Array - cunoneByRight.assign( x, new Uint16Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint16Array - cunoneByRight.assign( x, new Uint8Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint8Array - cunoneByRight.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive ); // $ExpectType Uint8ClampedArray - - cunoneByRight.assign( x, [ 0, 0, 0, 0 ], 1, 0, isPositive, {} ); // $ExpectType (number | boolean)[] - cunoneByRight.assign( x, new Float64Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float64Array - cunoneByRight.assign( x, new Float32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float32Array - cunoneByRight.assign( x, new Int32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int32Array - cunoneByRight.assign( x, new Int16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int16Array - cunoneByRight.assign( x, new Int8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int8Array - cunoneByRight.assign( x, new Uint32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint32Array - cunoneByRight.assign( x, new Uint16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint16Array - cunoneByRight.assign( x, new Uint8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8Array - cunoneByRight.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8ClampedArray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cunoneByRight.assign( 1, x, 2, 0, isPositive ); // $ExpectError - cunoneByRight.assign( true, x, 2, 0, isPositive ); // $ExpectError - cunoneByRight.assign( false, x, 2, 0, isPositive ); // $ExpectError - cunoneByRight.assign( null, x, 2, 0, isPositive ); // $ExpectError - cunoneByRight.assign( void 0, x, 2, 0, isPositive ); // $ExpectError - cunoneByRight.assign( {}, x, 2, 0, isPositive ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cunoneByRight.assign( x, true, 1, 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, false, 1, 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, null, 1, 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, void 0, 1, 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, {}, 1, 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, 1, 1, 0, isPositive ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a number... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cunoneByRight.assign( x, y, '1', 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, y, true, 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, y, false, 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, y, null, 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, y, void 0, 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, y, {}, 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, y, [], 0, isPositive ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cunoneByRight.assign( x, y, 1, '1', isPositive ); // $ExpectError - cunoneByRight.assign( x, y, 1, true, isPositive ); // $ExpectError - cunoneByRight.assign( x, y, 1, false, isPositive ); // $ExpectError - cunoneByRight.assign( x, y, 1, null, isPositive ); // $ExpectError - cunoneByRight.assign( x, y, 1, void 0, isPositive ); // $ExpectError - cunoneByRight.assign( x, y, 1, {}, isPositive ); // $ExpectError - cunoneByRight.assign( x, y, 1, [], isPositive ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a function... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cunoneByRight.assign( x, y, 1, 0, 2 ); // $ExpectError - cunoneByRight.assign( x, y, 1, 0, false ); // $ExpectError - cunoneByRight.assign( x, y, 1, 0, true ); // $ExpectError - cunoneByRight.assign( x, y, 1, 0, 'abc' ); // $ExpectError - cunoneByRight.assign( x, y, 1, 0, void 0 ); // $ExpectError - cunoneByRight.assign( x, y, 1, 0, {} ); // $ExpectError - cunoneByRight.assign( x, y, 1, 0, [] ); // $ExpectError -} -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cunoneByRight.assign(); // $ExpectError - cunoneByRight.assign( [] ); // $ExpectError - cunoneByRight.assign( [], [] ); // $ExpectError - cunoneByRight.assign( [], [], 2 ); // $ExpectError - cunoneByRight.assign( [], [], 2, {} ); // $ExpectError - cunoneByRight.assign( [], [], 1, 1, {}, [], {} ); // $ExpectError -} diff --git a/base/cunone-by-right/examples/index.js b/base/cunone-by-right/examples/index.js deleted file mode 100644 index 77ba25457..000000000 --- a/base/cunone-by-right/examples/index.js +++ /dev/null @@ -1,34 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cunoneByRight = require( './../lib' ); - -function fcn( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -// Cumulatively test whether no array element passes a test, while iterating from right-to-left: -var out = cunoneByRight( x, fcn ); -console.log( out ); diff --git a/base/cunone-by-right/lib/assign.js b/base/cunone-by-right/lib/assign.js deleted file mode 100644 index d8dda1529..000000000 --- a/base/cunone-by-right/lib/assign.js +++ /dev/null @@ -1,171 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the provided output array. -* -* @private -* @param {Collection} x - input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var out = [ 0, 0, 0, 0, 0 ]; -* var arr = indexed( x, out, 1, 0, fcn ); -* // returns [ true, true, true, false, false ] -*/ -function indexed( x, out, stride, offset, predicate, thisArg ) { - var flg; - var io; - var i; - - flg = true; - io = offset; - for ( i = x.length - 1; i >= 0; i-- ) { - if ( flg && predicate.call( thisArg, x[ i ], i, x ) ) { - flg = false; - } - out[ io ] = flg; - io += stride; - } - return out; -} - -/** -* Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 1, 0, 0, 0 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( out ), 1, 0, fcn ); -* -* var v = arr.get( 4 ); -* // returns false -*/ -function accessors( x, out, stride, offset, predicate, thisArg ) { - var xdata; - var odata; - var xget; - var oset; - var flg; - var io; - var i; - - xdata = x.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - flg = true; - for ( i = xdata.length - 1; i >= 0; i-- ) { - if ( flg && predicate.call( thisArg, xget( xdata, i ), i, xdata ) ) { - flg = false; - } - oset( odata, io, flg ); - io += stride; - } - return odata; -} - - -// MAIN // - -/** -* Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the output array. -* -* @param {Collection} x - input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Collection} output array -* -* @example -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 0, 0 ]; -* -* var y = [ false, null, false, null, false, null, false, null ]; -* var out = assign( x, y, 2, 0, fcn ); -* // returns [ true, null, true, null, false, null, false, null ] -* -* var bool = ( y === out ); -* // returns true -*/ -function assign( x, out, stride, offset, predicate, thisArg ) { - var xo; - var oo; - - xo = arraylike2object( x ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - oo.accessorProtocol - ) { - accessors( xo, oo, stride, offset, predicate, thisArg ); - return out; - } - indexed( x, out, stride, offset, predicate, thisArg ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cunone-by-right/lib/index.js b/base/cunone-by-right/lib/index.js deleted file mode 100644 index 38175a526..000000000 --- a/base/cunone-by-right/lib/index.js +++ /dev/null @@ -1,72 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether every array element in a provided array fails a test implemented by a predicate function, while iterating from right-to-left. -* -* @module @stdlib/array/base/cunone-by-right -* -* @example -* var cunoneByRight = require( '@stdlib/array/base/cunone-by-right' ); -* -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var y = cunoneByRight( x, fcn ); -* //returns [ true, true, true, false, false ] -* -* @example -* var cunoneByRight = require( '@stdlib/array/base/cunone-by-right' ); -* -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var y1 = cunoneByRight( x, fcn ); -* // returns [ true, true, true, false, false ] -* -* var y2 = [ false, null, false, null, false, null, false, null, false, null ]; -* var out = cunoneByRight.assign( x, y2, 2, 0, fcn ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -* -* var bool = ( out === y2 ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cunone-by-right/lib/main.js b/base/cunone-by-right/lib/main.js deleted file mode 100644 index 508aeffa9..000000000 --- a/base/cunone-by-right/lib/main.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function, while iterating from right-to-left. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Array} output array -* -* @example -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var y = cunoneByRight( x, fcn ); -* // returns [ true, true, true, false, false ] -*/ -function cunoneByRight( x, predicate, thisArg ) { - var out = filled( true, x.length ); - return assign( x, out, 1, 0, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = cunoneByRight; diff --git a/base/cunone-by-right/package.json b/base/cunone-by-right/package.json deleted file mode 100644 index 4c57a3ba1..000000000 --- a/base/cunone-by-right/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/cunone-by-right", - "version": "0.0.0", - "description": "Cumulatively test whether every array element in a provided array fails a test implemented by a predicate function, while iterating from right-to-left.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "generic", - "array", - "cumulative", - "data", - "structure", - "test", - "predicate", - "none", - "all", - "every", - "array.every", - "array-like", - "validate" - ] -} diff --git a/base/cunone-by-right/test/test.assign.js b/base/cunone-by-right/test/test.assign.js deleted file mode 100644 index 346b973b9..000000000 --- a/base/cunone-by-right/test/test.assign.js +++ /dev/null @@ -1,247 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cunoneByRight = require( './../lib/assign.js' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return v > 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cunoneByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether no element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to a provided output array (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 0, 0, 1, 1, 0 ]; - y = [ false, true, false, true, false ]; - - actual = cunoneByRight( x, y, 1, 0, isPositive ); - expected = [ true, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 0, 0 ]; - y = [ false, null, false, null, false, null, false, null ]; - - actual = cunoneByRight( x, y, 2, 0, isPositive ); - expected = [ true, null, true, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 0, 0, 0 ]; - y = [ false, false, false, true, true, true ]; - - actual = cunoneByRight( x, y, 1, 1, isPositive ); - expected = [ false, true, true, true, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cunoneByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0 ]; - y = [ false, false ]; - - actual = cunoneByRight( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether no element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to a provided output array (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cunoneByRight( x, y, 1, 0, isPositive ); - expected = [ true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null ]; - - actual = cunoneByRight( x, y, 2, 0, isPositive ); - expected = [ true, null, true, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 1.0, 0.0, 0.0 ] ); - y = [ true, false, false, true, true, true ]; - - actual = cunoneByRight( x, y, 1, 1, isPositive ); - expected = [ true, true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cunoneByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0 ] ); - y = [ false, false ]; - - actual = cunoneByRight( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether no element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to a provided output array (accessor)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ 1, 0, 0, 0, 0 ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cunoneByRight( x, y, 1, 0, isPositive ); - expected = [ true, true, true, true, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 1, 0 ] ); - ybuf = [ false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cunoneByRight( x, y, 2, 0, isPositive ); - expected = [ true, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 1, 0, 0 ] ); - ybuf = [ true, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cunoneByRight( x, y, 1, 1, isPositive ); - expected = [ true, true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 0, 0, 1 ] ); - ybuf = [ true, true, true, true, true ]; - y = toAccessorArray( ybuf ); - - actual = cunoneByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cunoneByRight( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0 ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cunoneByRight( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - var x; - var y; - - ctx = { - 'count': 0 - }; - - x = [ 0, 1, 0, 0, 0 ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cunoneByRight( x, y, 2, 0, predicate, ctx ); - expected = [ true, null, true, null, true, null, false, null, false, null ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cunone-by-right/test/test.js b/base/cunone-by-right/test/test.js deleted file mode 100644 index facbe4c4b..000000000 --- a/base/cunone-by-right/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cunoneByRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cunoneByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cunoneByRight, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cunoneByRight, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cunone-by-right/test/test.main.js b/base/cunone-by-right/test/test.main.js deleted file mode 100644 index 58701597b..000000000 --- a/base/cunone-by-right/test/test.main.js +++ /dev/null @@ -1,166 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cunoneByRight = require( './../lib' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return v > 0; -} - -function isNotNull( v ) { - return v !== null; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cunoneByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether no array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 1, 0, 0, 0 ]; - - actual = cunoneByRight( x, isPositive ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0.0, 0.0, 0.0, 1.0, 1.0 ]; - actual = cunoneByRight( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, false, false, false, false ]; - actual = cunoneByRight( x, isPositive ); - expected = [ true, true, true, true, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ {}, {}, null ]; - actual = cunoneByRight( x, isNotNull ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether no array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left (typed)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0 ] ); - actual = cunoneByRight( x, isPositive ); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cunoneByRight( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cunoneByRight( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 0.0 ] ); - actual = cunoneByRight( x, isPositive ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, 0.0 ] ); - actual = cunoneByRight( x, isPositive ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether no array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left (accessor)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 0, 0, 0 ] ); - - actual = cunoneByRight( x, isPositive ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); - actual = cunoneByRight( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 1, 1, 1 ] ); - actual = cunoneByRight( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 1 ] ); - actual = cunoneByRight( x, isPositive ); - expected = [ false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 0, 0, 0, 0 ] ); - actual = cunoneByRight( x, isPositive ); - expected = [ true, true, true, true, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - ctx = { - 'count': 0 - }; - - x = [ 1, -2, 0, -1 ]; - - out = cunoneByRight( x, predicate, ctx ); - expected = [ true, true, true, false ]; - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cunone-by/README.md b/base/cunone-by/README.md deleted file mode 100644 index ca46473b1..000000000 --- a/base/cunone-by/README.md +++ /dev/null @@ -1,145 +0,0 @@ - - -# cunoneBy - -> Cumulatively test whether every array element in a provided array fails a test implemented by a predicate function. - -
- -## Usage - -```javascript -var cunoneBy = require( '@stdlib/array/base/cunone-by' ); -``` - -#### cunoneBy( x, predicate\[, thisArg ] ) - -Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function. - -```javascript -function fcn( value) { - return ( value > 0 ); -} - -var x = [ 0, 0, 0, 1, 0 ]; - -var y = cunoneBy( x, fcn ); -// returns [ true, true, true, false, false ] -``` - -The invoked `predicate` function is provided three arguments: - -- **value**: collection element. -- **index**: collection index. -- **collection**: input collection. - -To set the function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return ( v > 0 ); -} - -var x = [ 0, 0, 1, 0, 0 ]; - -var context = { - 'count': 0 -}; - -var bool = cunoneBy( x, fcn, context ); -// returns [ true, true, false, false, false ] - -var count = context.count; -// returns 3 -``` - -#### cunoneBy.assign( x, out, stride, offset, predicate\[, thisArg ] ) - -Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function and assigns the values to elements in a provided output array. - -```javascript -function fcn( v ) { - return ( v > 0 ); -} - -var x = [ 0, 0, 0, 1, 0 ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cunoneBy.assign( x, y, 2, 0, fcn ); -// returns [ true, null, true, null, true, null, false, null, false, null ] - -var bool = ( out === y ); -// returns true -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cunoneBy = require( '@stdlib/array/base/cunone-by' ); - -function fcn( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -// Cumulatively tests whether every array element fails a test: -var y = cunoneBy( x, fcn ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cunone-by/benchmark/benchmark.assign.length.js b/base/cunone-by/benchmark/benchmark.assign.length.js deleted file mode 100644 index 5eb46d489..000000000 --- a/base/cunone-by/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cunoneBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 0, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( false, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cunoneBy.assign( x, y, 1, 0, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cunone-by/benchmark/benchmark.js b/base/cunone-by/benchmark/benchmark.js deleted file mode 100644 index b13995814..000000000 --- a/base/cunone-by/benchmark/benchmark.js +++ /dev/null @@ -1,53 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var cunoneBy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cunoneBy( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cunone-by/benchmark/benchmark.length.js b/base/cunone-by/benchmark/benchmark.length.js deleted file mode 100644 index 7fd222ea1..000000000 --- a/base/cunone-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cunoneBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 0, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cunoneBy( x, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cunone-by/docs/repl.txt b/base/cunone-by/docs/repl.txt deleted file mode 100644 index 1d565b986..000000000 --- a/base/cunone-by/docs/repl.txt +++ /dev/null @@ -1,77 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Cumulatively tests whether every array element in a provided array fails a - test implemented by a predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 0, 1, 0 ]; - > var y = {{alias}}( x, fcn ) - [ true, true, true, false, false ] - - -{{alias}}.assign( x, out, stride, offset, predicate[, thisArg]) - Cumulatively tests whether every array element in a provided array fails a - test implemented by a predicate function and assigns the values to elements - in a provided output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 1, 0 ]; - > var out = [ false, null, false, null, false, null, false, null ]; - > var arr = {{alias}}.assign( x, out, 2, 0, fcn ) - [ true, null, true, null, false, null, false, null ] - > var bool = ( arr === out ) - true - - See Also - -------- diff --git a/base/cunone-by/docs/types/index.d.ts b/base/cunone-by/docs/types/index.d.ts deleted file mode 100644 index 07dceb6c2..000000000 --- a/base/cunone-by/docs/types/index.d.ts +++ /dev/null @@ -1,199 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, BooleanArray } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `cunoneBy`. -*/ -interface CuNoneBy { - /** - * Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function. - * - * @param x - input array - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 0 ]; - * - * var y = cunoneBy( x, isPositive ); - * // returns [ true, true, true, false, false ] - */ - ( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function and assigns the results to the provided output array. - * - * @param x - input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cunoneBy.assign( x, y, 2, 0, isPositive ); - * // returns [ true, null, true, null, true, null, false, null, false, null ] - */ - assign( x: Collection | AccessorArrayLike, out: Array, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function and assigns the results to the provided output array. - * - * @param x - input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * var BooleanArray = require( './../../../../bool' ); - * - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = new BooleanArray( [ false, false, false, false, false, false, false, false, false, false ] ); - * - * var arr = cunoneBy.assign( x, y, 2, 0, isPositive ); - * // returns - * - * var v = arr.get( 4 ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, out: U, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): U; - - /** - * Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function and assigns the results to the provided output array. - * - * @param x - input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cunoneBy.assign( x, y, 2, 0, isPositive ); - * // returns [ true, null, true, null, true, null, false, null, false, null ] - */ - assign( x: Collection | AccessorArrayLike, out: Collection | AccessorArrayLike, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Collection | AccessorArrayLike; -} - -/** -* Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - test function -* @param thisArg - execution context -* @returns output array -* -* @example -* function isPositive( v ) { -* return ( v > 0 ); -* } -* var x = [ 0, 0, 0, 1, 0 ]; -* -* var result = cunoneBy( x, isPositive ); -* // returns [ true, true, true, false, false ] -* -* @example -* function isPositive( v ) { -* return ( v > 0 ); -* } -* var x = [ 0, 0, 0, 1, 0 ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cunoneBy.assign( x, y, 2, 0, isPositive ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -*/ -declare var cunoneBy: CuNoneBy; - - -// EXPORTS // - -export = cunoneBy; diff --git a/base/cunone-by/docs/types/test.ts b/base/cunone-by/docs/types/test.ts deleted file mode 100644 index c170e7de9..000000000 --- a/base/cunone-by/docs/types/test.ts +++ /dev/null @@ -1,218 +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. -*/ - -import cunoneBy = require( './index' ); - -var isPositive = ( v: number ): boolean => { - return ( v > 0 ); -}; - -// TESTS // - -// The function returns an array... -{ - cunoneBy( [ 1, 2, 3, 4 ], isPositive ); // $ExpectType boolean[] - cunoneBy( [ 1, 2, 3, 4 ], isPositive ); // $ExpectType boolean[] - - cunoneBy( [ 1, 2, 3, 4 ], isPositive, {} ); // $ExpectType boolean[] - cunoneBy( [ 1, 2, 3, 4 ], isPositive, {} ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cunoneBy( 1, isPositive ); // $ExpectError - cunoneBy( true, isPositive ); // $ExpectError - cunoneBy( false, isPositive ); // $ExpectError - cunoneBy( null, isPositive ); // $ExpectError - cunoneBy( void 0, isPositive ); // $ExpectError - cunoneBy( {}, isPositive ); // $ExpectError - - cunoneBy( 1, isPositive, {} ); // $ExpectError - cunoneBy( true, isPositive, {} ); // $ExpectError - cunoneBy( false, isPositive, {} ); // $ExpectError - cunoneBy( null, isPositive, {} ); // $ExpectError - cunoneBy( void 0, isPositive, {} ); // $ExpectError - cunoneBy( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - cunoneBy( [], 1 ); // $ExpectError - cunoneBy( [], true ); // $ExpectError - cunoneBy( [], false ); // $ExpectError - cunoneBy( [], null ); // $ExpectError - cunoneBy( [], void 0 ); // $ExpectError - cunoneBy( [], {} ); // $ExpectError - - cunoneBy( [], 1, {} ); // $ExpectError - cunoneBy( [], true, {} ); // $ExpectError - cunoneBy( [], false, {} ); // $ExpectError - cunoneBy( [], null, {} ); // $ExpectError - cunoneBy( [], void 0, {} ); // $ExpectError - cunoneBy( [], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cunoneBy(); // $ExpectError - cunoneBy( [] ); // $ExpectError - cunoneBy( [], [], {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 1, 2, 3, 4 ]; - - cunoneBy.assign( x, [ 0, 0, 0, 0 ], 1, 0, isPositive ); // $ExpectType (number | boolean)[] - cunoneBy.assign( x, new Float64Array( 4 ), 1, 0, isPositive ); // $ExpectType Float64Array - cunoneBy.assign( x, new Float32Array( 4 ), 1, 0, isPositive ); // $ExpectType Float32Array - cunoneBy.assign( x, new Int32Array( 4 ), 1, 0, isPositive ); // $ExpectType Int32Array - cunoneBy.assign( x, new Int16Array( 4 ), 1, 0, isPositive ); // $ExpectType Int16Array - cunoneBy.assign( x, new Int8Array( 4 ), 1, 0, isPositive ); // $ExpectType Int8Array - cunoneBy.assign( x, new Uint32Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint32Array - cunoneBy.assign( x, new Uint16Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint16Array - cunoneBy.assign( x, new Uint8Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint8Array - cunoneBy.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive ); // $ExpectType Uint8ClampedArray - - cunoneBy.assign( x, [ 0, 0, 0, 0 ], 1, 0, isPositive, {} ); // $ExpectType (number | boolean)[] - cunoneBy.assign( x, new Float64Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float64Array - cunoneBy.assign( x, new Float32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float32Array - cunoneBy.assign( x, new Int32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int32Array - cunoneBy.assign( x, new Int16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int16Array - cunoneBy.assign( x, new Int8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int8Array - cunoneBy.assign( x, new Uint32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint32Array - cunoneBy.assign( x, new Uint16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint16Array - cunoneBy.assign( x, new Uint8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8Array - cunoneBy.assign( x, new Uint8ClampedArray( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8ClampedArray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cunoneBy.assign( 1, x, 2, 0, isPositive ); // $ExpectError - cunoneBy.assign( true, x, 2, 0, isPositive ); // $ExpectError - cunoneBy.assign( false, x, 2, 0, isPositive ); // $ExpectError - cunoneBy.assign( null, x, 2, 0, isPositive ); // $ExpectError - cunoneBy.assign( void 0, x, 2, 0, isPositive ); // $ExpectError - cunoneBy.assign( {}, x, 2, 0, isPositive ); // $ExpectError - - cunoneBy.assign( 1, x, 2, 0, isPositive, {} ); // $ExpectError - cunoneBy.assign( true, x, 2, 0, isPositive, {} ); // $ExpectError - cunoneBy.assign( false, x, 2, 0, isPositive, {} ); // $ExpectError - cunoneBy.assign( null, x, 2, 0, isPositive, {} ); // $ExpectError - cunoneBy.assign( void 0, x, 2, 0, isPositive, {} ); // $ExpectError - cunoneBy.assign( {}, x, 2, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cunoneBy.assign( x, 1, 1, 0, isPositive ); // $ExpectError - cunoneBy.assign( x, true, 1, 0, isPositive ); // $ExpectError - cunoneBy.assign( x, false, 1, 0, isPositive ); // $ExpectError - cunoneBy.assign( x, null, 1, 0, isPositive ); // $ExpectError - cunoneBy.assign( x, void 0, 1, 0, isPositive ); // $ExpectError - cunoneBy.assign( x, {}, 1, 0, isPositive ); // $ExpectError - - cunoneBy.assign( x, 1, 1, 0, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, true, 1, 0, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, false, 1, 0, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, null, 1, 0, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, void 0, 1, 0, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, {}, 1, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a number... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cunoneBy.assign( x, y, '1', 1, isPositive ); // $ExpectError - cunoneBy.assign( x, y, true, 1, isPositive ); // $ExpectError - cunoneBy.assign( x, y, false, 1, isPositive ); // $ExpectError - cunoneBy.assign( x, y, null, 1, isPositive ); // $ExpectError - cunoneBy.assign( x, y, void 0, 1, isPositive ); // $ExpectError - cunoneBy.assign( x, y, {}, 1, isPositive ); // $ExpectError - cunoneBy.assign( x, y, [], 1, isPositive ); // $ExpectError - cunoneBy.assign( x, y, ( x: number ): number => x, 1, isPositive ); // $ExpectError - - cunoneBy.assign( x, y, '1', 1, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, true, 1, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, false, 1, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, null, 1, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, void 0, 1, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, {}, 1, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, [], 1, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, ( x: number ): number => x, 1, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cunoneBy.assign( x, y, 0, '1', isPositive ); // $ExpectError - cunoneBy.assign( x, y, 0, true, isPositive ); // $ExpectError - cunoneBy.assign( x, y, 0, false, isPositive ); // $ExpectError - cunoneBy.assign( x, y, 0, null, isPositive ); // $ExpectError - cunoneBy.assign( x, y, 0, void 0, isPositive ); // $ExpectError - cunoneBy.assign( x, y, 0, {}, isPositive ); // $ExpectError - cunoneBy.assign( x, y, 0, [], isPositive ); // $ExpectError - - cunoneBy.assign( x, y, 0, '1', isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, true, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, false, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, null, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, void 0, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, {}, isPositive, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, [], isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a function... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cunoneBy.assign( x, y, 0, 1, '1' ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, true ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, false ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, null ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, void 0 ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, [] ); // $ExpectError - - cunoneBy.assign( x, y, 0, 1, '1', {} ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, true, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, false, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, null, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, void 0, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, {}, {} ); // $ExpectError - cunoneBy.assign( x, y, 0, 1, [], {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cunoneBy.assign(); // $ExpectError - cunoneBy.assign( [] ); // $ExpectError - cunoneBy.assign( [], [] ); // $ExpectError - cunoneBy.assign( [], [], 1 ); // $ExpectError - cunoneBy.assign( [], [], 1, 0 ); // $ExpectError - cunoneBy.assign( [], [], 1, 0, isPositive, {}, {} ); // $ExpectError -} diff --git a/base/cunone-by/examples/index.js b/base/cunone-by/examples/index.js deleted file mode 100644 index fe864829a..000000000 --- a/base/cunone-by/examples/index.js +++ /dev/null @@ -1,34 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cunoneBy = require( './../lib' ); - -function fcn( value ) { - return ( value > 0 ); -} - -// Generate an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -// Cumulatively tests whether every array element fails a test: -var y = cunoneBy( x, fcn ); -console.log( y ); diff --git a/base/cunone-by/lib/assign.js b/base/cunone-by/lib/assign.js deleted file mode 100644 index 35650dbb5..000000000 --- a/base/cunone-by/lib/assign.js +++ /dev/null @@ -1,168 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 0, 1, 0 ]; -* -* var out = [ false, null, false, null, false, null, false, null, false, null ]; -* var arr = indexed( x, out, 2, 0, isPositive ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -*/ -function indexed( x, out, stride, offset, predicate, thisArg ) { - var flg; - var io; - var i; - - flg = true; - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( flg && predicate.call( thisArg, x[ i ], i, x ) ) { - flg = false; - } - out[ io ] = flg; - io += stride; - } - return out; -} - -/** -* Cumulatively tests whether every array element in a provided accessor array fails a test implemented by a predicate function. -* -* @private -* @param {Object} x - input array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {everynNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 0, 0, 0, 1, 0 ] ); -* -* var out = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( out ), 2, 0, isPositive ); -* -* var v = arr.get( 4 ); -* // returns true -*/ -function accessors( x, out, stride, offset, predicate, thisArg ) { - var xdata; - var odata; - var xget; - var oset; - var flg; - var io; - var i; - - xdata = x.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - flg = true; - for ( i = 0; i < xdata.length; i++ ) { - if ( flg && predicate.call( thisArg, xget( xdata, i ), i, xdata ) ) { - flg = false; - } - oset( odata, io, flg ); - io += stride; - } - return odata; -} - - -// MAIN // - -/** -* Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 0, 1, 0 ]; -* -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* var out = assign( x, y, 2, 0, isPositive ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -* -* var bool = ( y === out ); -* // returns true -*/ -function assign( x, out, stride, offset, predicate, thisArg ) { - var xo; - var oo; - - xo = arraylike2object( x ); - oo = arraylike2object( out ); - if ( xo.accessorProtocol || oo.accessorProtocol ) { - accessors( xo, oo, stride, offset, predicate, thisArg ); - return out; - } - indexed( x, out, stride, offset, predicate, thisArg ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cunone-by/lib/index.js b/base/cunone-by/lib/index.js deleted file mode 100644 index 2855c3e2f..000000000 --- a/base/cunone-by/lib/index.js +++ /dev/null @@ -1,66 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether every array element in a provided array fails a test implemented by a predicate function. -* -* @module @stdlib/array/base/cunone-by -* -* @example -* var cunoneBy = require( '@stdlib/array/base/cunone-by' ); -* -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 0, 1, 0 ]; -* -* var y = cunoneBy( x, isPositive ); -* // returns [ true, true, true, false, false ] -* -* @example -* var cunoneBy = require( '@stdlib/array/base/cunone-by' ); -* -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 0, 1, 0 ]; -* var out = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var y = cunoneBy.assign( x, out, 2, 0, isPositive ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly(main, 'assign', assign); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cunone-by/lib/main.js b/base/cunone-by/lib/main.js deleted file mode 100644 index caa038eba..000000000 --- a/base/cunone-by/lib/main.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - execution context -* @returns {Array} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 0, 1, 0 ]; -* -* var y = cunoneBy( x, isPositive ); -* // returns [ true, true, true, false, false ] -*/ -function cunoneBy( x, predicate, thisArg ) { - var out = filled( true, x.length ); - return assign( x, out, 1, 0, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = cunoneBy; diff --git a/base/cunone-by/package.json b/base/cunone-by/package.json deleted file mode 100644 index 70986c13f..000000000 --- a/base/cunone-by/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/cunone-by", - "version": "0.0.0", - "description": "Cumulatively test whether every element in a provided array fails a test implemented by a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "cunone", - "none", - "cumulative", - "test" - ] -} diff --git a/base/cunone-by/test/test.assign.js b/base/cunone-by/test/test.assign.js deleted file mode 100644 index 38b3366f9..000000000 --- a/base/cunone-by/test/test.assign.js +++ /dev/null @@ -1,247 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cunoneBy = require( './../lib/assign.js' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return ( v > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cunoneBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 0, 0, 0, 1, 0 ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cunoneBy( x, y, 2, 0, isPositive ); - expected = [ true, null, true, null, true, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0, 0, 1, 1 ]; - y = [ false, null, false, null, false, null, false, null ]; - - actual = cunoneBy( x, y, 2, 0, isPositive ); - expected = [ true, null, true, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0, 0, 1, 0, 1 ]; - y = [ false, false, false, true, true, true ]; - - actual = cunoneBy( x, y, 1, 1, isPositive ); - expected = [ false, true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cunoneBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0 ]; - y = [ false, false ]; - - actual = cunoneBy( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 0.0, -2.0, 3.0, 4.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cunoneBy( x, y, 1, 0, isPositive ); - expected = [ true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 1.0 ] ); - y = [ false, null, false, null, false, null, false, null ]; - - actual = cunoneBy( x, y, 2, 0, isPositive ); - expected = [ true, null, true, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 1.0, 0.0, 0.0 ] ); - y = [ true, false, false, true, true, true ]; - - actual = cunoneBy( x, y, 1, 0, isPositive ); - expected = [ true, false, false, false, false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cunoneBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0 ] ); - y = [ false, false ]; - - actual = cunoneBy( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function (accessor)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ 0, 1, 1, 1, 0 ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cunoneBy( x, y, 1, 0, isPositive ); - expected = [ true, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 0, 0 ] ); - ybuf = [ false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cunoneBy( x, y, 2, 0, isPositive ); - expected = [ false, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 0, 1, 1 ] ); - ybuf = [ true, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cunoneBy( x, y, 1, 1, isPositive ); - expected = [ true, true, true, true, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 0, 0, 0, 1 ] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cunoneBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cunoneBy( x, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ -1 ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cunoneBy( x, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - var x; - var y; - - ctx = { - 'count': 0 - }; - - x = [ 0, 0, 0, 1, 0 ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cunoneBy( x, y, 2, 0, predicate, ctx ); - expected = [ true, null, true, null, true, null, false, null, false, null ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cunone-by/test/test.js b/base/cunone-by/test/test.js deleted file mode 100644 index fbd5fcb5d..000000000 --- a/base/cunone-by/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cunoneBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cunoneBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cunoneBy, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cunoneBy, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cunone-by/test/test.main.js b/base/cunone-by/test/test.main.js deleted file mode 100644 index 17c43178c..000000000 --- a/base/cunone-by/test/test.main.js +++ /dev/null @@ -1,172 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var cunoneBy = require( './../lib' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return ( v > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cunoneBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ -1, -2, 0, 4 ]; - - actual = cunoneBy( x, isPositive ); - expected = [ true, true, true, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ -1.0, -2.0, 0.0, 1.0, 1.0 ]; - actual = cunoneBy( x, isPositive ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, true, true, true, true ]; - actual = cunoneBy( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ {}, null, {} ]; - actual = cunoneBy( x, isNull ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function isNull( v ) { - return v === null; - } -}); - -tape( 'the function cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function (typed) ', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ -1.0, -1.0, -1.0, 1.0, 1.0 ] ); - actual = cunoneBy( x, isPositive ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cunoneBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual =cunoneBy( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0 ] ); - actual = cunoneBy( x, isPositive ); - expected = [ true, true, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ -1.0, -2.0, 3.0, 0.0, 1.0 ] ); - actual = cunoneBy( x, isPositive ); - expected = [ true, true, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every array element in a provided array fails a test implemented by a predicate function (accessor)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 0, 0, 1, 1, 0 ] ); - - actual = cunoneBy( x, isPositive ); - expected = [ true, true, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); - actual = cunoneBy( x, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 1, 1, 1 ] ); - actual = cunoneBy( x, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 0 ] ); - actual = cunoneBy( x, isPositive ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 0, 0, 0 ] ); - actual = cunoneBy( x, isPositive ); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array as a first argument', function test( t ) { - var x = []; - t.deepEqual( cunoneBy( x, isPositive ), [], 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - ctx = { - 'count': 0 - }; - - x = [ -1, -2, 0, 4 ]; - - out = cunoneBy( x, predicate, ctx ); - expected = [ true, true, true, false ]; - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cunone/README.md b/base/cunone/README.md deleted file mode 100644 index 8a9677340..000000000 --- a/base/cunone/README.md +++ /dev/null @@ -1,113 +0,0 @@ - - -# cunone - -> Cumulatively test whether every element in a provided array is falsy. - -
- -## Usage - -```javascript -var cunone = require( '@stdlib/array/base/cunone' ); -``` - -#### cunone( x ) - -Cumulatively tests whether every element in a provided array is falsy. - -```javascript -var x = [ false, false, false, true, false ]; - -var y = cunone( x ); -// returns [ true, true, true, false, false ]; -``` - -#### cunone.assign( x, out, stride, offset ) - -Cumulatively tests whether every element in a provided array is falsy and assigns results to a provided output array. - -```javascript -var x = [ false, false, false, true, false ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cunone.assign( x, y, 2, 0 ); -// returns [ true, null, true, null, true, null, false, null, false, null ] - -var bool = ( out === y ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cunone = require( '@stdlib/array/base/cunone' ); - -// Create an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -// Cumulatively determine whether values are falsy: -var out = cunone( x ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cunone/benchmark/benchmark.assign.length.js b/base/cunone/benchmark/benchmark.assign.length.js deleted file mode 100644 index 98b2afdd1..000000000 --- a/base/cunone/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cunone = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( true, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cunone.assign( x, y, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cunone/benchmark/benchmark.js b/base/cunone/benchmark/benchmark.js deleted file mode 100644 index 49f3f751f..000000000 --- a/base/cunone/benchmark/benchmark.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var cunone = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var i; - var v; - - x = [ false, false, true, false, false ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cunone( x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cunone/benchmark/benchmark.length.js b/base/cunone/benchmark/benchmark.length.js deleted file mode 100644 index 43474bf40..000000000 --- a/base/cunone/benchmark/benchmark.length.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cunone = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cunone( x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cunone/docs/repl.txt b/base/cunone/docs/repl.txt deleted file mode 100644 index a26937162..000000000 --- a/base/cunone/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Cumulatively tests whether every element in a provided array is falsy. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ false, false, false, true, false ]; - > var y = {{alias}}( x ) - [ true, true, true, false, false ]; - - -{{alias}}.assign( x, y, stride, offset ) - Cumulatively tests whether every element in an array is falsy and assigns - results to a provided output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - y: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - Returns - ------- - y: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ false, false, false, true, false ]; - > var y = [ false, null, false, null, false, null, false, null, false ]; - > var result = {{alias}}.assign( x, y, 2, 0 ) - [ true, null, true, null, true, null, false, null, false ] - - See Also - -------- - diff --git a/base/cunone/docs/types/index.d.ts b/base/cunone/docs/types/index.d.ts deleted file mode 100644 index 3979378aa..000000000 --- a/base/cunone/docs/types/index.d.ts +++ /dev/null @@ -1,86 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Interface describing `cunone`. -*/ -interface cunone { - /** - * Cumulatively tests whether every element in a provided array is falsy. - * - * @param x - input array - * @returns output array - * - * @example - * var x = [ false, false, false, true, false ]; - * - * var y = cunone( x ); - * // returns [ true, true, true, false, false ]; - */ - ( x: Collection | AccessorArrayLike ): Array; - - /** - * Cumulatively tests whether every element in an array is falsy and assigns the results to a provided output array. - * - * @param x - input array - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ false, false, false, true, false ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cunone.assign( x, y, 2, 0 ); - * // returns [ true, null, true, null, true, null, false, null, false, null ]; - */ - assign | AccessorArrayLike>( x: Collection | AccessorArrayLike, y: U, stride: number, offset: number ): U; -} - -/** -* Cumulatively tests whether every element in a provided array is falsy. -* -* @param x - input array -* @returns output array -* -* @example -* var x = [ false, false, false, true, false ]; -* -* var result = cunone( x ); -* // returns [ true, true, true, false, false ]; -* -* @example -* var x = [ false, false, false, true, false ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cunone.assign( x, y, 2, 0 ); -* // returns [ true, null, true, null, true, null, false, null, false, null ]; -*/ -declare var cunone: cunone; - - -// EXPORTS // - -export = cunone; diff --git a/base/cunone/docs/types/test.ts b/base/cunone/docs/types/test.ts deleted file mode 100644 index 44dfde5e1..000000000 --- a/base/cunone/docs/types/test.ts +++ /dev/null @@ -1,114 +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. -*/ - - -import cunone = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - cunone( [ false, false, true, false, false ] ); // $ExpectType boolean[] - cunone( [ false, false, true, false, false ] ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cunone( 1 ); // $ExpectError - cunone( true ); // $ExpectError - cunone( false ); // $ExpectError - cunone( null ); // $ExpectError - cunone( void 0 ); // $ExpectError - cunone( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cunone(); // $ExpectError - cunone( [], [] ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cunone.assign( x, y, 2, 0 ); // $ExpectType (boolean | null)[] -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const x = [ false, false, true, false, false ]; - - cunone.assign( 1, x, 2, 0 ); // $ExpectError - cunone.assign( true, x, 2, 0 ); // $ExpectError - cunone.assign( false, x, 2, 0 ); // $ExpectError - cunone.assign( null, x, 2, 0 ); // $ExpectError - cunone.assign( void 0, x, 2, 0 ); // $ExpectError - cunone.assign( {}, x, 2, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ false, false, true, false, false ]; - - cunone.assign( x, 1, 2, 0 ); // $ExpectError - cunone.assign( x, true, 2, 0 ); // $ExpectError - cunone.assign( x, false, 2, 0 ); // $ExpectError - cunone.assign( x, null, 2, 0 ); // $ExpectError - cunone.assign( x, void 0, 2, 0 ); // $ExpectError - cunone.assign( x, {}, 2, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cunone.assign( x, y , '1', 0 ); // $ExpectError - cunone.assign( x, y , true, 0 ); // $ExpectError - cunone.assign( x, y , false, 0 ); // $ExpectError - cunone.assign( x, y , null, 0 ); // $ExpectError - cunone.assign( x, y , void 0, 0 ); // $ExpectError - cunone.assign( x, y , {}, 0 ); // $ExpectError - cunone.assign( x, y , [], 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cunone.assign( x, y, 1, '1' ); // $ExpectError - cunone.assign( x, y, 1, true ); // $ExpectError - cunone.assign( x, y, 1, false ); // $ExpectError - cunone.assign( x, y, 1, null ); // $ExpectError - cunone.assign( x, y, 1, void 0 ); // $ExpectError - cunone.assign( x, y, 1, {} ); // $ExpectError - cunone.assign( x, y, 1, [] ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cunone.assign(); // $ExpectError - cunone.assign( [] ); // $ExpectError - cunone.assign( [], [] ); // $ExpectError - cunone.assign( [], [], 2 ); // $ExpectError - cunone.assign( [], [], 1, 1, {} ); // $ExpectError -} diff --git a/base/cunone/examples/index.js b/base/cunone/examples/index.js deleted file mode 100644 index 2083bb3b6..000000000 --- a/base/cunone/examples/index.js +++ /dev/null @@ -1,30 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cunone = require( './../lib' ); - -// Create an array of random values: -var x = bernoulli( 10, 0.1 ); -console.log( x ); - -// Cumulatively determine whether values are falsy: -var out = cunone( x ); -console.log( out ); diff --git a/base/cunone/lib/assign.js b/base/cunone/lib/assign.js deleted file mode 100644 index ca887b0ac..000000000 --- a/base/cunone/lib/assign.js +++ /dev/null @@ -1,291 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplex128Array = require( './../../../base/assert/is-complex128array' ); -var isComplex64Array = require( './../../../base/assert/is-complex64array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether every element in an indexed array is falsy. -* -* @private -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ false, false, false, true, false ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var out = indexed( x, y, 2, 0 ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -*/ -function indexed( x, y, stride, offset ) { - var flg; - var io; - var i; - - flg = true; - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( flg === true && x[ i ] ) { - flg = false; - } - y[ io ] = flg; - io += stride; - } - return y; -} - -/** -* Cumulatively tests whether every element in a provided accessor array is falsy. -* -* @private -* @param {Object} x - input array object -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ false, false, false, true, false ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] ); -* -* var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns true -* -* v = y.get( 2 ); -* // returns true -* -* v = y.get( 4 ); -* // returns true -* -* v = y.get( 6 ); -* // returns false -* -* v = y.get( 8 ); -* // returns false -*/ -function accessors( x, y, stride, offset ) { - var xdata; - var ydata; - var xget; - var yset; - var flg; - var io; - var i; - - xdata = x.data; - ydata = y.data; - - xget = x.accessors[ 0 ]; - yset = y.accessors[ 1 ]; - - flg = true; - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( flg === true && xget( xdata, i ) ) { - flg = false; - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - -/** -* Cumulatively tests whether every element in a provided complex number array is falsy. -* -* @private -* @param {Collection} x - array containing interleaved real and imaginary components -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] ); -* -* var arr = complex( x, arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns true -* -* v = y.get( 2 ); -* // returns true -* -* v = y.get( 4 ); -* // returns true -* -* v = y.get( 6 ); -* // returns false -* -* v = y.get( 8 ); -* // returns false -*/ -function complex( x, y, stride, offset ) { - var ydata; - var yset; - var flg; - var io; - var i; - - yset = y.accessors[ 1 ]; - ydata = y.data; - - flg = true; - io = offset; - for ( i = 0; i < x.length; i += 2 ) { - if ( flg === true && ( x[ i ] || x[ i+1 ] ) ) { - flg = false; - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - -/** -* Cumulatively tests whether every element in a provided boolean array is falsy. -* -* @private -* @param {Collection} x - input array -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Uint8Array( [ 0, 0, 0, 1, 0 ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] ); -* -* var arr = boolean( x, arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns true -* -* v = y.get( 2 ); -* // returns true -* -* v = y.get( 4 ); -* // returns true -* -* v = y.get( 6 ); -* // returns false -* -* v = y.get( 8 ); -* // returns false -*/ -function boolean( x, y, stride, offset ) { - var ydata; - var yset; - var flg; - var io; - var i; - - yset = y.accessors[ 1 ]; - ydata = y.data; - - flg = true; - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( flg === true && x[ i ] ) { - flg = false; - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - - -// MAIN // - -/** -* Cumulatively tests whether every element in an array is falsy and assigns results to a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ false, false, false, true, false ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var out = assign( x, y, 2, 0 ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -* -* var bool = ( y === out ); -* // returns true -*/ -function assign( x, y, stride, offset ) { - var xo = arraylike2object( x ); - var yo = arraylike2object( y ); - if ( - xo.accessorProtocol || - yo.accessorProtocol - ) { - // If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero... - if ( isComplex128Array( x ) ) { - complex( reinterpret128( x, 0 ), yo, stride, offset ); - } else if ( isComplex64Array( x ) ) { - complex( reinterpret64( x, 0 ), yo, stride, offset ); - } else if ( isBooleanArray( x ) ) { - boolean( reinterpretBoolean( x, 0 ), yo, stride, offset ); - } else { - accessors( xo, yo, stride, offset ); - } - return y; - } - indexed( x, y, stride, offset ); - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cunone/lib/index.js b/base/cunone/lib/index.js deleted file mode 100644 index 4d841d758..000000000 --- a/base/cunone/lib/index.js +++ /dev/null @@ -1,58 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether every element in a provided array is falsy. -* -* @module @stdlib/array/base/cunone -* -* @example -* var cunone = require( '@stdlib/array/base/cunone' ); -* -* var x = [ false, false, false, true, false ] -* -* var y = cunone( x ); -* // returns [ true, true, true, false, false ] -* -* @example -* var cunone = require( '@stdlib/array/base/cunone' ); -* -* var x = [ false, false, false, true, false ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cunone.assign( x, y, 2, 0 ); -* // returns [ true, null, true, null, true, null, false, null, false, null ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cunone/lib/main.js b/base/cunone/lib/main.js deleted file mode 100644 index e24e82246..000000000 --- a/base/cunone/lib/main.js +++ /dev/null @@ -1,49 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether every element in a provided array is falsy. -* -* @param {Collection} x - input array -* @returns {Array} output array -* -* @example -* var x = [ false, false, false, true, false ]; -* -* var y = cunone( x ); -* // returns [ true, true, true, false, false ] -*/ -function cunone( x ) { - var y = filled( true, x.length ); - return assign( x, y, 1, 0 ); -} - - -// EXPORTS // - -module.exports = cunone; diff --git a/base/cunone/package.json b/base/cunone/package.json deleted file mode 100644 index 53c5f8808..000000000 --- a/base/cunone/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/cunone", - "version": "0.0.0", - "description": "Cumulatively test whether every element in a provided array is falsy.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "utils", - "generic", - "array", - "cunone", - "cumulative", - "test", - "every", - "array.every", - "validate" - ] -} diff --git a/base/cunone/test/test.assign.js b/base/cunone/test/test.assign.js deleted file mode 100644 index a5ed9554b..000000000 --- a/base/cunone/test/test.assign.js +++ /dev/null @@ -1,378 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cunone = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cunone, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is falsy (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ false, false, false, true, false ]; - y = [ false, true, false, true, false ]; - - actual = cunone( x, y, 1, 0 ); - expected = [ true, true, true, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false, false, true, false, false ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cunone( x, y, 2, 0 ); - expected = [ true, null, true, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false, false, true, false, false ]; - y = [ false, false, false, true, true, true ]; - - actual = cunone( x, y, 1, 1 ); - expected = [ false, true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false ]; - y = [ false, false ]; - - actual = cunone( x, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is falsy (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cunone( x, y, 2, 0 ); - expected = [ true, null, true, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, false, false, true, true, true ]; - - actual = cunone( x, y, 1, 1 ); - expected = [ false, true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - y = [ false, false ]; - - actual = cunone( x, y, 1, 1 ); - expected = [ false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is falsy (boolean)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new BooleanArray( [ true, true, true, true, true ] ); - y = [ false, true, false, true, false ]; - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, true, false, false ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cunone( x, y, 2, 0 ); - expected = [ true, null, true, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, true, false, false ] ); - y = [ false, false, false, true, true, true ]; - - actual = cunone( x, y, 1, 1 ); - expected = [ false, true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [] ); - y = [ false, false, false, false, false ]; - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true ] ); - y = [ false, false ]; - - actual = cunone( x, y, 1, 1 ); - expected = [ false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is falsy (complex128)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Complex128Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cunone( x, y, 2, 0 ); - expected = [ true, null, true, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, false, false, true, true, true ]; - - actual = cunone( x, y, 1, 1 ); - expected = [ false, true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 1.0 ] ); - y = [ false, false ]; - - actual = cunone( x, y, 1, 1 ); - expected = [ false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is falsy (complex64)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Complex64Array( [ 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cunone( x, y, 2, 0 ); - expected = [ true, null, true, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - y = [ false, false, false, true, true, true ]; - - actual = cunone( x, y, 1, 1 ); - expected = [ false, true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 1.0 ] ); - y = [ false, false ]; - - actual = cunone( x, y, 1, 1 ); - expected = [ false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is falsy (accessor)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ true, false, true, false, true ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, true, false, false ] ); - ybuf = [ false, null, false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cunone( x, y, 2, 0 ); - expected = [ true, null, true, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, true, false, false ] ); - ybuf = [ false, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cunone( x, y, 1, 1 ); - expected = [ false, true, true, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, false, false, false, false ] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cunone( x, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ true ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cunone( x, y, 1, 1 ); - expected = [ false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/cunone/test/test.js b/base/cunone/test/test.js deleted file mode 100644 index 675f84f77..000000000 --- a/base/cunone/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cunone = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cunone, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cunone, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cunone, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cunone/test/test.main.js b/base/cunone/test/test.main.js deleted file mode 100644 index 63592618a..000000000 --- a/base/cunone/test/test.main.js +++ /dev/null @@ -1,237 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cunone = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cunone, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is falsy (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ false, false, false, true, false ]; - actual = cunone( x ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; - actual = cunone( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, true, true, true, true ]; - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ null, {}, null ]; - actual = cunone( x ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, false, false, true, false ]; - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is falsy (typed)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - actual = cunone( x ); - expected = [ true, true, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 1.0, 0.0, 0.0 ] ); - actual = cunone( x ); - expected = [ true, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 0.0 ] ); - actual = cunone( x ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is falsy (complex128)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cunone( x ); - expected = [ true, true, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cunone( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 0.0 ] ); - actual = cunone( x ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is falsy (boolean)', function test( t ) { - var expected; - var actual; - var x; - - x = new BooleanArray( [ false, false, true, false, false ] ); - actual = cunone( x ); - expected = [ true, true, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, false, false, false ] ); - actual = cunone( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, true, true, true, true ] ); - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, true, true ] ); - actual = cunone( x ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true, false, false ] ); - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element is falsy (complex64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cunone( x ); - expected = [ true, true, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cunone( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] ); - actual = cunone( x ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether every element of an accessor array is falsy (accessor)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ false, false, false, true, true ] ); - - actual = cunone( x ); - expected = [ true, true, true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, false, false, false ] ); - actual = cunone( x ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, true, true, true, true ] ); - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, true, false ] ); - actual = cunone( x ); - expected = [ true, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, false, false, false, false ] ); - actual = cunone( x ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/cusome-by-right/README.md b/base/cusome-by-right/README.md deleted file mode 100644 index 4480a1158..000000000 --- a/base/cusome-by-right/README.md +++ /dev/null @@ -1,148 +0,0 @@ - - -# cusomeByRight - -> Cumulatively test whether at least `n` elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left. - -
- -## Usage - -```javascript -var cusomeByRight = require( '@stdlib/array/base/cusome-by-right' ); -``` - -#### cusomeByRight( x, n, predicate\[, thisArg ] ) - -Cumulatively tests whether at least `n` elements in a provided array pass a test implemented by a `predicate` function, while iterating from right-to-left. - -```javascript -function fcn( value ) { - return value > 0; -} - -var x = [ 1, 1, 0, 0, 0 ]; - -var y = cusomeByRight( x, 2, fcn ); -// returns [ false, false, false, false, true ]; -``` - -The invoked `predicate` function is provided three arguments: - -- **value**: collection element. -- **index**: collection index. -- **collection**: input collection. - -To set the function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return ( v > 0 ); -} - -var x = [ 1, 1, 0, 0, 0 ]; - -var context = { - 'count': 0 -}; - -var bool = cusomeByRight( x, 2, fcn, context ); -// returns [ false, false, false, false, true ] - -var count = context.count; -// returns 5 -``` - -#### cusomeByRight.assign( x, n, out, stride, offset, predicate\[, thisArg ] ) - -Cumulatively tests whether at least `n` elements in a provided array pass a test implemented by a `predicate` function, while iterating from right-to-left, and assigns the results to the elements in the output array. - -```javascript -function fcn( v ) { - return v > 0; -} - -var x = [ 1, 1, 0, 0, 0 ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cusomeByRight.assign( x, 2, y, 2, 0, fcn ); -// returns [ false, null, false, null, false, null, false, null, true, null ] - -var bool = ( out === y ); -// returns true -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cusomeByRight = require( '@stdlib/array/base/cusome-by-right' ); - -function fcn( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = bernoulli( 10, 0.3 ); -console.log( x ); - -// Minimum number of required positive array elements: -var n = 2; - -// Cumulatively test whether at least `n` array elements pass a test, while iterating from right-to-left: -var out = cusomeByRight( x, n, fcn ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cusome-by-right/benchmark/benchmark.assign.length.js b/base/cusome-by-right/benchmark/benchmark.assign.length.js deleted file mode 100644 index 4ad058ca9..000000000 --- a/base/cusome-by-right/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cusomeByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 0.0, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( false, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cusomeByRight.assign( x, len, y, 1, 0, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cusome-by-right/benchmark/benchmark.js b/base/cusome-by-right/benchmark/benchmark.js deleted file mode 100644 index bc9c0f603..000000000 --- a/base/cusome-by-right/benchmark/benchmark.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var cusomeByRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var i; - var v; - - x = [ 1, 1, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cusomeByRight( x, 2, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cusome-by-right/benchmark/benchmark.length.js b/base/cusome-by-right/benchmark/benchmark.length.js deleted file mode 100644 index 91e836087..000000000 --- a/base/cusome-by-right/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cusomeByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 0.0, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cusomeByRight( x, len, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cusome-by-right/docs/repl.txt b/base/cusome-by-right/docs/repl.txt deleted file mode 100644 index 24c274afd..000000000 --- a/base/cusome-by-right/docs/repl.txt +++ /dev/null @@ -1,90 +0,0 @@ - -{{alias}}( x, n, predicate[, thisArg] ) - Cumulatively tests whether at least `n` elements in a provided array pass a - test implemented by a predicate function, while iterating from - right-to-left. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - n: number - Minimum number of successful elements. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 1, 1, 0, 0, 0 ]; - > var y = {{alias}}( x, 2, fcn ) - [ false, false, false, false, true ] - - -{{alias}}.assign( x, n, out, stride, offset, predicate[, thisArg] ) - Cumulatively tests whether at least `n` elements in a provided array pass a - test implemented by a predicate function, while iterating from - right-to-left, and assigns the results to the provided output array. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - n: number - Minimum number of successful elements. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 1, 1, 0, 0 ]; - > var out = [ false, null, false, null, false, null, false, null ]; - > var arr = {{alias}}.assign( x, 2, out, 2, 0, fcn ) - [ false, null, false, null, false, null, true, null ] - > var bool = ( arr === out ) - true - - See Also - -------- diff --git a/base/cusome-by-right/docs/types/index.d.ts b/base/cusome-by-right/docs/types/index.d.ts deleted file mode 100644 index 76370f885..000000000 --- a/base/cusome-by-right/docs/types/index.d.ts +++ /dev/null @@ -1,204 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, BooleanArray } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `cusomeByRight`. -*/ -interface CusomeByRight { - /** - * Cumulatively tests whether at least `n` elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left. - * - * @param x - input array - * @param n - number of elements - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function fcn( v ) { - * return v > 0; - * } - * var x = [ 0, 1, 1, 0, 0 ]; - * - * var y = cusomeByRight( x, 2, fcn ); - * // returns [ false, false, false, true, true ]; - */ - ( x: Collection | AccessorArrayLike, n: number, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether at least `n` elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param n - number of elements - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function fcn( v ) { - * return v > 0; - * } - * var x = [ 1, 1, 0, 0, 0 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cusomeByRight.assign( x, 2, y, 2, 0, fcn ); - * // returns [ false, null, false, null, false, null, false, null, true, null ]; - */ - assign( x: Collection | AccessorArrayLike, n: number, out: Array, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether at least `n` elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param n - number of elements - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * var BooleanArray = require( './../../../../bool' ); - * - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 0 ]; - * var y = new BooleanArray( [ false, false, false, false, false, false, false, false, false, false ] ); - * - * var arr = cusomeByRight.assign( x, 2, y, 2, 0, isPositive ); - * // returns - * - * var v = arr.get( 4 ); - * // returns false - */ - assign( x: Collection | AccessorArrayLike, n: number, out: U, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): U; - - /** - * Cumulatively tests whether at least `n` elements in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to the provided output array. - * - * @param x - input array - * @param n - number of elements - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function fcn( v ) { - * return v > 0; - * } - * var x = [ 1, 1, 0, 0, 0 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cusomeByRight.assign( x, 2, y, 2, 0, fcn ); - * // returns [ false, null, false, null, false, null, false, null, true, null ]; - */ - assign( x: Collection | AccessorArrayLike, n: number, out: Collection | AccessorArrayLike, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Collection | AccessorArrayLike; -} - -/** -* Cumulatively test whether at least `n` elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left. -* -* @param x - input array -* @param n - number of elements -* @param predicate - test function -* @param thisArg - execution context -* @returns output array -* -* @example -* function fcn( v ) { -* return v > 0; -* } -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var result = cusomeByright( x, 2, fcn ); -* // returns [ false, false, false, false, true ] -* -* @example -* function fcn( v ) { -* return v > 0; -* } -* var x = [ 0, 1, 1, 0, 0 ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cusomeByRight.assign( x, 2, y, 2, 0, fcn ); -* // returns [ false, null, false, null, false, null, true, null, true, null ] -*/ -declare var cusomeByRight: CusomeByRight; - - -// EXPORTS // - -export = cusomeByRight; diff --git a/base/cusome-by-right/docs/types/test.ts b/base/cusome-by-right/docs/types/test.ts deleted file mode 100644 index b63505cea..000000000 --- a/base/cusome-by-right/docs/types/test.ts +++ /dev/null @@ -1,195 +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. -*/ - - -import cusomeByRight = require( './index' ); - -const isPositive = ( v: number ): boolean => { - return ( v > 0 ); -}; - -// TESTS // - -// The function returns an array... -{ - cusomeByRight( [ 0, 1, 1 ], 2, isPositive ); // $ExpectType boolean[] - cusomeByRight( [ -1, 0, 1, 2 ], 3, isPositive ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cusomeByRight( 1 ); // $ExpectError - cusomeByRight( true ); // $ExpectError - cusomeByRight( false ); // $ExpectError - cusomeByRight( null ); // $ExpectError - cusomeByRight( void 0 ); // $ExpectError - cusomeByRight( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cusomeByRight( x, '1', isPositive ); // $ExpectError - cusomeByRight( x, true, isPositive ); // $ExpectError - cusomeByRight( x, false, isPositive ); // $ExpectError - cusomeByRight( x, null, isPositive ); // $ExpectError - cusomeByRight( x, void 0, isPositive ); // $ExpectError - cusomeByRight( x, {}, isPositive ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cusomeByRight( x, 2, '1' ); // $ExpectError - cusomeByRight( x, 2, true ); // $ExpectError - cusomeByRight( x, 2, false ); // $ExpectError - cusomeByRight( x, 2, 'abc' ); // $ExpectError - cusomeByRight( x, 2, void 0 ); // $ExpectError - cusomeByRight( x, 2, {} ); // $ExpectError - cusomeByRight( x, 2, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cusomeByRight(); // $ExpectError - cusomeByRight( [] ); // $ExpectError - cusomeByRight( [], [] ); // $ExpectError - cusomeByRight( [], [], [], [], [] ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cusomeByRight.assign( x, 2, y, 2, 0, isPositive ); // $ExpectType (boolean | null)[] - cusomeByRight.assign( x, 2, [ 0, 0, 0, 0 ], 1, 0, isPositive ); // $ExpectType (number | boolean)[] - cusomeByRight.assign( x, 2, new Float64Array( 4 ), 1, 0, isPositive ); // $ExpectType Float64Array - cusomeByRight.assign( x, 2, new Float32Array( 4 ), 1, 0, isPositive ); // $ExpectType Float32Array - cusomeByRight.assign( x, 2, new Int32Array( 4 ), 1, 0, isPositive ); // $ExpectType Int32Array - cusomeByRight.assign( x, 2, new Int16Array( 4 ), 1, 0, isPositive ); // $ExpectType Int16Array - cusomeByRight.assign( x, 2, new Int8Array( 4 ), 1, 0, isPositive ); // $ExpectType Int8Array - cusomeByRight.assign( x, 2, new Uint32Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint32Array - cusomeByRight.assign( x, 2, new Uint16Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint16Array - cusomeByRight.assign( x, 2, new Uint8Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint8Array - cusomeByRight.assign( x, 2, new Uint8ClampedArray( 4 ), 1, 0, isPositive ); // $ExpectType Uint8ClampedArray - - cusomeByRight.assign( x, 2, [ 0, 0, 0, 0 ], 1, 0, isPositive, {} ); // $ExpectType (number | boolean)[] - cusomeByRight.assign( x, 2, new Float64Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float64Array - cusomeByRight.assign( x, 2, new Float32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float32Array - cusomeByRight.assign( x, 2, new Int32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int32Array - cusomeByRight.assign( x, 2, new Int16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int16Array - cusomeByRight.assign( x, 2, new Int8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int8Array - cusomeByRight.assign( x, 2, new Uint32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint32Array - cusomeByRight.assign( x, 2, new Uint16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint16Array - cusomeByRight.assign( x, 2, new Uint8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8Array - cusomeByRight.assign( x, 2, new Uint8ClampedArray( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8ClampedArray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cusomeByRight.assign( 1, 2, x, 2, 0, isPositive ); // $ExpectError - cusomeByRight.assign( true, 2, x, 2, 0, isPositive ); // $ExpectError - cusomeByRight.assign( false, 2, x, 2, 0, isPositive ); // $ExpectError - cusomeByRight.assign( null, 2, x, 2, 0, isPositive ); // $ExpectError - cusomeByRight.assign( void 0, 2, x, 2, 0, isPositive ); // $ExpectError - cusomeByRight.assign( {}, 2, x, 2, 0, isPositive ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a number... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cusomeByRight.assign( x, '1', y, 1, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, true, y, 1, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, false, y, 1, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, null, y, 1, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, void 0, y, 1, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, {}, y, 1, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, [], y, 1, 0, isPositive ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cusomeByRight.assign( x, 2, true, 1, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 2, false, 1, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 2, null, 1, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 2, void 0, 1, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 2, {}, 1, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 2, 1, 1, 0, isPositive ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cusomeByRight.assign( x, 1, y, '1', 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, true, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, false, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, null, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, void 0, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, {}, 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, [], 0, isPositive ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cusomeByRight.assign( x, 1, y, 1, '1', isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, true, isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, false, isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, null, isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, void 0, isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, {}, isPositive ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, [], isPositive ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a function... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cusomeByRight.assign( x, 1, y, 1, 0, 2 ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, 0, false ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, 0, true ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, 0, 'abc' ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, 0, void 0 ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, 0, {} ); // $ExpectError - cusomeByRight.assign( x, 1, y, 1, 0, [] ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cusomeByRight.assign(); // $ExpectError - cusomeByRight.assign( [] ); // $ExpectError - cusomeByRight.assign( [], [] ); // $ExpectError - cusomeByRight.assign( [], [], 2 ); // $ExpectError - cusomeByRight.assign( [], [], 2, {} ); // $ExpectError - cusomeByRight.assign( [], [], 1, 1, {} ); // $ExpectError - cusomeByRight.assign( [], [], 1, 1, {}, 1, {}, {} ); // $ExpectError -} diff --git a/base/cusome-by-right/examples/index.js b/base/cusome-by-right/examples/index.js deleted file mode 100644 index fe402ef1b..000000000 --- a/base/cusome-by-right/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cusomeByRight = require( './../lib' ); - -function fcn( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = bernoulli( 10, 0.3 ); -console.log( x ); - -// Minimum number of required positive array elements: -var n = 2; - -// Cumulatively test whether at least `n` array elements pass a test, while iterating from right-to-left: -var out = cusomeByRight( x, n, fcn ); -console.log( out ); diff --git a/base/cusome-by-right/lib/assign.js b/base/cusome-by-right/lib/assign.js deleted file mode 100644 index 4666c2886..000000000 --- a/base/cusome-by-right/lib/assign.js +++ /dev/null @@ -1,185 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether at least `n` elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left, and assign the results to elements in the provided output array. -* -* @private -* @param {Collection} x - input array -* @param {PositiveInteger} n - number of elements -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var out = [ 0, 0, 0, 0, 0 ]; -* var arr = indexed( x, 2, out, 1, 0, fcn ); -* // returns [ false, false, false, false, true ] -*/ -function indexed( x, n, out, stride, offset, predicate, thisArg ) { - var count; - var flg; - var io; - var i; - - flg = false; - count = 0; - io = offset; - for ( i = x.length - 1; i >= 0; i-- ) { - if ( flg === false && predicate.call( thisArg, x[ i ], i, x ) ) { - count += 1; - if ( count >= n ) { - flg = true; - } - } - out[ io ] = flg; - io += stride; - } - return out; -} - -/** -* Cumulatively tests whether at least `n` elements in a provided accessor array pass a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {PositiveInteger} n - number of elements -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ 1, 1, 0, 0, 0 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), 2, arraylike2object( out ), 1, 0, fcn ); -* -* var v = arr.get( 4 ); -* // returns true -*/ -function accessors( x, n, out, stride, offset, predicate, thisArg ) { - var count; - var xdata; - var odata; - var xget; - var oset; - var flg; - var io; - var i; - - xdata = x.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - flg = false; - count = 0; - for ( i = xdata.length - 1; i >= 0; i-- ) { - if ( flg === false && - predicate.call( thisArg, xget( xdata, i ), i, xdata ) ) { - count += 1; - if ( count >= n ) { - flg = true; - } - } - oset( odata, io, flg ); - io += stride; - } - return odata; -} - - -// MAIN // - -/** -* Cumulatively tests whether at least `n` elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the output array. -* -* @param {Collection} x - input array -* @param {PositiveInteger} n - number of elements -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Collection} output array -* -* @example -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 0, 0 ]; -* -* var y = [ false, null, false, null, false, null, false, null ]; -* var out = assign( x, 2, y, 2, 0, fcn ); -* // returns [ false, null, false, null, false, null, true, null ] -* -* var bool = ( y === out ); -* // returns true -*/ -function assign( x, n, out, stride, offset, predicate, thisArg ) { - var xo; - var oo; - - xo = arraylike2object( x ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - oo.accessorProtocol - ) { - accessors( xo, n, oo, stride, offset, predicate, thisArg ); - return out; - } - indexed( x, n, out, stride, offset, predicate, thisArg ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cusome-by-right/lib/index.js b/base/cusome-by-right/lib/index.js deleted file mode 100644 index e6fb3441c..000000000 --- a/base/cusome-by-right/lib/index.js +++ /dev/null @@ -1,72 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether at least `n` elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left. -* -* @module @stdlib/array/base/cusome-by-right -* -* @example -* var cusomeByRight = require( '@stdlib/array/base/cusome-by-right' ); -* -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var y = cusomeByRight( x, 2, fcn ); -* //returns [ false, false, false, false, true ] -* -* @example -* var cusomeByRight = require( '@stdlib/array/base/cusome-by-right' ); -* -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var y1 = cusomeByRight( x, 2, fcn ); -* // returns [ false, false, false, false, true ] -* -* var y2 = [ false, null, false, null, false, null, false, null, false, null ]; -* var out = cusomeByRight.assign( x, 2, y2, 2, 0, fcn ); -* // returns [ false, null, false, null, false, null, false, null, true, null ] -* -* var bool = ( out === y2 ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cusome-by-right/lib/main.js b/base/cusome-by-right/lib/main.js deleted file mode 100644 index 8a8f16692..000000000 --- a/base/cusome-by-right/lib/main.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether at least `n` elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left. -* -* @param {Collection} x - input array -* @param {PositiveInteger} n - number of elements -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Array} output array -* -* @example -* function fcn( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 1, 1, 0, 0, 0 ]; -* -* var y = cusomeByRight( x, 2, fcn ); -* // returns [ false, false, false, false, true ] -*/ -function cusomeByRight( x, n, predicate, thisArg ) { - var out = filled( false, x.length ); - return assign( x, n, out, 1, 0, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = cusomeByRight; diff --git a/base/cusome-by-right/package.json b/base/cusome-by-right/package.json deleted file mode 100644 index 25ce77daa..000000000 --- a/base/cusome-by-right/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/cusome-by-right", - "version": "0.0.0", - "description": "Cumulatively test whether at least `n` elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "generic", - "array", - "cumulative", - "cusome-by-right", - "test", - "predicate", - "array.some", - "iterate", - "array-like", - "validate" - ] -} diff --git a/base/cusome-by-right/test/test.assign.js b/base/cusome-by-right/test/test.assign.js deleted file mode 100644 index 8f4e7706a..000000000 --- a/base/cusome-by-right/test/test.assign.js +++ /dev/null @@ -1,220 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cusomeByRight = require( './../lib/assign.js' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return v > 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cusomeByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least n elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left and assigns the results to a provided output array (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 1, 1, 0, 0, 1 ]; - y = [ false, true, false, true, false ]; - - actual = cusomeByRight( x, 2, y, 1, 0, isPositive ); - expected = [ false, false, false, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 0, 0 ]; - y = [ false, null, false, null, false, null, false, null ]; - - actual = cusomeByRight( x, 2, y, 2, 0, isPositive ); - expected = [ false, null, false, null, false, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0, 0, 1, 0, 1 ]; - y = [ false, false, false, true, true, true ]; - - actual = cusomeByRight( x, 2, y, 1, 1, isPositive ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cusomeByRight( x, 1, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1 ]; - y = [ false, false ]; - - actual = cusomeByRight( x, 1, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least n elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left and assigns the results to a provided output array (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cusomeByRight( x, 2, y, 1, 0, isPositive ); - expected = [ false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null ]; - - actual = cusomeByRight( x, 2, y, 2, 0, isPositive ); - expected = [ false, null, false, null, false, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 1.0, 0.0, 0.0 ] ); - y = [ true, false, false, true, true, true ]; - - actual = cusomeByRight( x, 2, y, 1, 1, isPositive ); - expected = [ true, false, false, false, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cusomeByRight( x, 1, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - y = [ false, false ]; - - actual = cusomeByRight( x, 1, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least n elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left and assigns the results to a provided output array (accessor)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ 1, 0, 0, 0, 1 ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cusomeByRight( x, 2, y, 1, 0, isPositive ); - expected = [ false, false, false, false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 1, 0 ] ); - ybuf = [ false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cusomeByRight( x, 2, y, 2, 0, isPositive ); - expected = [ false, null, false, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 1, 0, 0 ] ); - ybuf = [ true, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusomeByRight( x, 2, y, 1, 1, isPositive ); - expected = [ true, false, false, false, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 0, 0, 1 ] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusomeByRight( x, 1, y, 1, 0, isPositive ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusomeByRight( x, 1, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1 ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusomeByRight( x, 0, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/cusome-by-right/test/test.js b/base/cusome-by-right/test/test.js deleted file mode 100644 index 2dac8653f..000000000 --- a/base/cusome-by-right/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cusomeByRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cusomeByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cusomeByRight, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cusomeByRight, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cusome-by-right/test/test.main.js b/base/cusome-by-right/test/test.main.js deleted file mode 100644 index 264f9fc62..000000000 --- a/base/cusome-by-right/test/test.main.js +++ /dev/null @@ -1,141 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cusomeByRight = require( './../lib' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return v > 0; -} - -function isNotNull( v ) { - return v !== null; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cusomeByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least n array elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 1, 0, 0, 0 ]; - - actual = cusomeByRight( x, 2, isPositive ); - expected = [ false, false, false, false, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0.0, 0.0, 0.0, 1.0, 1.0 ]; - actual = cusomeByRight( x, 2, isPositive ); - expected = [ false, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, true, true, true, true ]; - actual = cusomeByRight( x, 4, isPositive ); - expected = [ false, false, false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ {}, null, {} ]; - actual = cusomeByRight( x, 2, isNotNull ); - expected = [ false, false, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least n elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left (typed)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 0.0 ] ); - actual = cusomeByRight( x, 2, isPositive ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cusomeByRight( x, 2, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cusomeByRight( x, 2, isPositive ); - expected = [ false, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 0.0 ] ); - actual = cusomeByRight( x, 1, isPositive ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0 ] ); - actual = cusomeByRight( x, 1, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least n elements in a provided array pass a test implemented by a predicate function, while iterating from right-to-left (accessor)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 0, 0, 0 ] ); - - actual = cusomeByRight( x, 2, isPositive ); - expected = [ false, false, false, false, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); - actual = cusomeByRight( x, 1, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 1, 1, 1 ] ); - actual = cusomeByRight( x, 1, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 1 ] ); - actual = cusomeByRight( x, 1, isPositive ); - expected = [ true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 0, 0, 0, 0 ] ); - actual = cusomeByRight( x, 1, isPositive ); - expected = [ false, false, false, false, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/cusome-by/README.md b/base/cusome-by/README.md deleted file mode 100644 index 1aec67359..000000000 --- a/base/cusome-by/README.md +++ /dev/null @@ -1,145 +0,0 @@ - - -# cusomeBy - -> Cumulatively test whether at least `n` array elements in a provided array pass a test implemented by a predicate function. - -
- -## Usage - -```javascript -var cusomeBy = require( '@stdlib/array/base/cusome-by' ); -``` - -#### cusomeBy( x, n, predicate\[, thisArg ] ) - -Cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function. - -```javascript -function fcn( value) { - return ( value > 0 ); -} - -var x = [ 0, 0, 0, 1, 1 ]; - -var y = cusomeBy( x, 2, fcn ); -// returns [ false, false, false, false, true ] -``` - -The invoked `predicate` function is provided three arguments: - -- **value**: collection element. -- **index**: collection index. -- **collection**: input collection. - -To set the function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return ( v > 0 ); -} - -var x = [ 0, 0, 0, 1, 1 ]; - -var context = { - 'count': 0 -}; - -var bool = cusomeBy( x, 1, fcn, context ); -// returns [ false, false, false, true, true ] - -var count = context.count; -// returns 4 -``` - -#### cusomeBy.assign( x, n, out, stride, offset, predicate\[, thisArg ] ) - -Cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function and assigns the results to a provided output array. - -```javascript -function fcn( v ) { - return ( v > 0 ); -} - -var x = [ 0, 0, 0, 1, 1 ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cusomeBy.assign( x, 2, y, 2, 0, fcn ); -// returns [ false, null, false, null, false, null, false, null, true, null ] - -var bool = ( out === y ); -// returns true -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cusomeBy = require( '@stdlib/array/base/cusome-by' ); - -function fcn( value ) { - return ( value > 0 ); -} - -// Create an array of random values: -var x = bernoulli( 10, 0.8 ); -console.log( x ); - -// Cumulatively test whether at least three array elements are positive: -var y = cusomeBy( x, 3, fcn ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cusome-by/benchmark/benchmark.assign.length.js b/base/cusome-by/benchmark/benchmark.assign.length.js deleted file mode 100644 index 82a5ef999..000000000 --- a/base/cusome-by/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cusomeBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( false, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cusomeBy.assign( x, 2, y, 1, 0, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cusome-by/benchmark/benchmark.js b/base/cusome-by/benchmark/benchmark.js deleted file mode 100644 index 79edc781c..000000000 --- a/base/cusome-by/benchmark/benchmark.js +++ /dev/null @@ -1,53 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var cusomeBy = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cusomeBy( x, 50, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cusome-by/benchmark/benchmark.length.js b/base/cusome-by/benchmark/benchmark.length.js deleted file mode 100644 index 2ad06392b..000000000 --- a/base/cusome-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ); -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cusomeBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 1.5, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cusomeBy( x, 2, isPositiveInteger ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cusome-by/docs/repl.txt b/base/cusome-by/docs/repl.txt deleted file mode 100644 index 6d723e8c6..000000000 --- a/base/cusome-by/docs/repl.txt +++ /dev/null @@ -1,83 +0,0 @@ - -{{alias}}( x, n, predicate[, thisArg] ) - Cumulatively tests whether at least n array elements in a provided array - pass a test implemented by a predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - n: integer - Number of elements. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 0, 1, 1 ]; - > var y = {{alias}}( x, 2, fcn ) - [ false, false, false, false, true ] - - -{{alias}}.assign( x, n, out, stride, offset, predicate[, thisArg] ) - Cumulatively tests whether at least n elements in a provided array pass a - test implemented by a predicate function and assigns the values to elements - in a provided output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - n: Integer - Number of Elements. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > function fcn( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 1, 1 ]; - > var out = [ false, null, false, null, false, null, false, null ]; - > var arr = {{alias}}.assign( x, 2, out, 2, 0, fcn ) - [ false, null, false, null, false, null, true, null ]; - > var bool = ( arr === out ) - true - - See Also - -------- diff --git a/base/cusome-by/docs/types/index.d.ts b/base/cusome-by/docs/types/index.d.ts deleted file mode 100644 index adc8f2516..000000000 --- a/base/cusome-by/docs/types/index.d.ts +++ /dev/null @@ -1,204 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, BooleanArray } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `cusomeBy`. -*/ -interface CuSomeBy { - /** - * Cumulatively tests whether at least `n` array elements in a provided array passes a test implemented by a predicate function. - * - * @param x - input array - * @param n - number of elements - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 1 ]; - * - * var y = cusomeBy( x, 2, isPositive ); - * // returns [ false, false, false, false, true ]; - */ - ( x: Collection | AccessorArrayLike, n: number, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function and assigns the results to the provided output array. - * - * @param x - input array - * @param n - number of elements - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 1,]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cusomeBy.assign( x, 2, y, 2, 0, isPositive ); - * // returns [ false, null, false, null, false, null, false, null, true, null ]; - */ - assign( x: Collection | AccessorArrayLike, n: number, out: Array, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Array; - - /** - * Cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function and assigns the results to the provided output array. - * - * @param x - input array - * @param n - number of elements - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * var BooleanArray = require( './../../../../bool' ); - * - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 1 ]; - * var y = new BooleanArray( [ false, false, false, false, false, false, false, false, false, false ] ); - * - * var arr = cusomeBy.assign( x, 2, y, 2, 0, isPositive ); - * // returns - * - * var v = arr.get( 8 ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, n: number, out: U, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): U; - - /** - * Cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function and assigns the results to the provided output array. - * - * @param x - input array - * @param n - number of elements - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @param predicate - test function - * @param thisArg - execution context - * @returns output array - * - * @example - * function isPositive( v ) { - * return ( v > 0 ); - * } - * var x = [ 0, 0, 0, 1, 1 ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cusomeBy.assign( x, 2, y, 2, 0, isPositive ); - * // returns [ false, null, false, null, false, null, false, null, true, null ]; - */ - assign( x: Collection | AccessorArrayLike, n: number, out: Collection | AccessorArrayLike, stride: number, offset: number, predicate: Predicate, thisArg?: ThisParameterType> ): Collection | AccessorArrayLike; -} - -/** -* Cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function. -* -* @param x - input array -* @param n - number of elements -* @param predicate - test function -* @param thisArg - execution context -* @returns output array -* -* @example -* function isPositive( v ) { -* return ( v > 0 ); -* } -* var x = [ 0, 0, 0, 1, 1 ]; -* -* var result = cusomeBy( x, 2, isPositive ); -* // returns [ false, false, false, false, true ] -* -* @example -* function isPositive( v ) { -* return ( v > 0 ); -* } -* var x = [ 0, 0, 0, 1, 1 ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cusomeBy.assign( x, 2, y, 2, 0, isPositive ); -* //returns [ false, null, false, null, false, null, false, null, true, null ]; -*/ -declare var cusomeBy: CuSomeBy; - - -// EXPORTS // - -export = cusomeBy; diff --git a/base/cusome-by/docs/types/test.ts b/base/cusome-by/docs/types/test.ts deleted file mode 100644 index 0320b68d0..000000000 --- a/base/cusome-by/docs/types/test.ts +++ /dev/null @@ -1,234 +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. -*/ - -import cusomeBy = require( './index' ); - -const isPositive = ( v: number ): boolean => { - return ( v > 0 ); -}; - - -// TESTS // - -// The function returns an array... -{ - cusomeBy( [ 1, 2, 3, 4 ], 2, isPositive ); // $ExpectType boolean[] - cusomeBy( [ 1, 2, 3, 4 ], 2, isPositive ); // $ExpectType boolean[] - - cusomeBy( [ 1, 2, 3, 4 ], 2, isPositive, {} ); // $ExpectType boolean[] - cusomeBy( [ 1, 2, 3, 4 ], 2, isPositive, {} ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cusomeBy( 1, 2, isPositive ); // $ExpectError - cusomeBy( true, 2, isPositive ); // $ExpectError - cusomeBy( false, 2, isPositive ); // $ExpectError - cusomeBy( null, 2, isPositive ); // $ExpectError - cusomeBy( void 0, 2, isPositive ); // $ExpectError - cusomeBy( {}, 2, isPositive ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is a number... -{ - cusomeBy( [], true, isPositive ); // $ExpectError - cusomeBy( [], false, isPositive ); // $ExpectError - cusomeBy( [], null, isPositive ); // $ExpectError - cusomeBy( [], void 0, isPositive ); // $ExpectError - cusomeBy( [], {}, isPositive ); // $ExpectError - cusomeBy( [], undefined, isPositive ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - cusomeBy( [], 2, 1 ); // $ExpectError - cusomeBy( [], 2, true ); // $ExpectError - cusomeBy( [], 2, false ); // $ExpectError - cusomeBy( [], 2, null ); // $ExpectError - cusomeBy( [], 2, void 0 ); // $ExpectError - cusomeBy( [], 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cusomeBy(); // $ExpectError - cusomeBy( [] ); // $ExpectError - cusomeBy( [], 2, 'throw', {} , null ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 1, 2, 3, 4 ]; - - cusomeBy.assign( x, 2, [ 0, 0, 0, 0 ], 1, 0, isPositive ); // $ExpectType (number | boolean)[] - cusomeBy.assign( x, 2, new Float64Array( 4 ), 1, 0, isPositive ); // $ExpectType Float64Array - cusomeBy.assign( x, 2, new Float32Array( 4 ), 1, 0, isPositive ); // $ExpectType Float32Array - cusomeBy.assign( x, 2, new Int32Array( 4 ), 1, 0, isPositive ); // $ExpectType Int32Array - cusomeBy.assign( x, 2, new Int16Array( 4 ), 1, 0, isPositive ); // $ExpectType Int16Array - cusomeBy.assign( x, 2, new Int8Array( 4 ), 1, 0, isPositive ); // $ExpectType Int8Array - cusomeBy.assign( x, 2, new Uint32Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint32Array - cusomeBy.assign( x, 2, new Uint16Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint16Array - cusomeBy.assign( x, 2, new Uint8Array( 4 ), 1, 0, isPositive ); // $ExpectType Uint8Array - cusomeBy.assign( x, 2, new Uint8ClampedArray( 4 ), 1, 0, isPositive ); // $ExpectType Uint8ClampedArray - - cusomeBy.assign( x, 2, [ 0, 0, 0, 0 ], 1, 0, isPositive, {} ); // $ExpectType (number | boolean)[] - cusomeBy.assign( x, 2, new Float64Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float64Array - cusomeBy.assign( x, 2, new Float32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Float32Array - cusomeBy.assign( x, 2, new Int32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int32Array - cusomeBy.assign( x, 2, new Int16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int16Array - cusomeBy.assign( x, 2, new Int8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Int8Array - cusomeBy.assign( x, 2, new Uint32Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint32Array - cusomeBy.assign( x, 2, new Uint16Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint16Array - cusomeBy.assign( x, 2, new Uint8Array( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8Array - cusomeBy.assign( x, 2, new Uint8ClampedArray( 4 ), 1, 0, isPositive, {} ); // $ExpectType Uint8ClampedArray -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cusomeBy.assign( 1, 2, x, 2, 0, isPositive ); // $ExpectError - cusomeBy.assign( true, 2, x, 2, 0, isPositive ); // $ExpectError - cusomeBy.assign( false, 2, x, 2, 0, isPositive ); // $ExpectError - cusomeBy.assign( null, 2, x, 2, 0, isPositive ); // $ExpectError - cusomeBy.assign( void 0, 2, x, 2, 0, isPositive ); // $ExpectError - cusomeBy.assign( {}, 2, x, 2, 0, isPositive ); // $ExpectError - - cusomeBy.assign( 1, 2, x, 2, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( true, 2, x, 2, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( false, 2, x, 2, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( null, 2, x, 2, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( void 0, 2, x, 2, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( {}, 2, x, 2, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a number.. -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cusomeBy.assign( x, [], x, 1, 0, isPositive ); // $ExpectError - cusomeBy.assign( x, true, x, 1, 0, isPositive ); // $ExpectError - cusomeBy.assign( x, false, x, 1, 0, isPositive ); // $ExpectError - cusomeBy.assign( x, null, x, 1, 0, isPositive ); // $ExpectError - cusomeBy.assign( x, void 0, x, 1, 0, isPositive ); // $ExpectError - cusomeBy.assign( x, {}, x, 1, 0, isPositive ); // $ExpectError - - cusomeBy.assign( x, [], x, 1, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, true, x, 1, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, false, x, 1, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, null, x, 1, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, void 0, x, 1, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, {}, x, 1, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object containing numbers... -{ - const x = [ 1, 1, 0, 0, 0 ]; - - cusomeBy.assign( x, 2, 1, 1, 0, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, true, 1, 0, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, false, 1, 0, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, null, 1, 0, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, void 0, 1, 0, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, {}, 1, 0, isPositive ); // $ExpectError - - cusomeBy.assign( x, 2, 1, 1, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, true, 1, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, false, 1, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, null, 1, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, void 0, 1, 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, {}, 1, 0, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid index... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cusomeBy.assign( x, 2, y, '1', 1, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, true, 1, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, false, 1, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, null, 1, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, void 0, 1, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, {}, 1, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, [], 1, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, ( x: number ): number => x, 1, isPositive ); // $ExpectError - - cusomeBy.assign( x, 2, y, '1', 1, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, true, 1, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, false, 1, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, null, 1, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, void 0, 1, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, {}, 1, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, [], 1, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, ( x: number ): number => x, 1, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cusomeBy.assign( x, 2, y, 0, '1', isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, true, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, false, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, null, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, void 0, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, {}, isPositive ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, [], isPositive ); // $ExpectError - - cusomeBy.assign( x, 2, y, 0, '1', isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, true, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, false, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, null, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, void 0, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, {}, isPositive, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, [], isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a function... -{ - const x = [ 1, 1, 0, 0, 0 ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cusomeBy.assign( x, 2, y, 0, 1, '1' ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, true ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, false ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, null ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, void 0 ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, [] ); // $ExpectError - - cusomeBy.assign( x, 2, y, 0, 1, '1', {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, true, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, false, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, null, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, void 0, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, {}, {} ); // $ExpectError - cusomeBy.assign( x, 2, y, 0, 1, [], {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cusomeBy.assign(); // $ExpectError - cusomeBy.assign( [] ); // $ExpectError - cusomeBy.assign( [], [] ); // $ExpectError - cusomeBy.assign( [], [], 'throw' ); // $ExpectError - cusomeBy.assign( [], [], 'throw', [] ); // $ExpectError - cusomeBy.assign( [], [], [], 'throw', [], 1, 0, {} ); // $ExpectError -} diff --git a/base/cusome-by/examples/index.js b/base/cusome-by/examples/index.js deleted file mode 100644 index 08f06cd8a..000000000 --- a/base/cusome-by/examples/index.js +++ /dev/null @@ -1,34 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cusomeBy = require( './../lib' ); - -function fcn( value ) { - return ( value > 0 ); -} - -// Generate an array of random values: -var x = bernoulli( 10, 0.8 ); -console.log( x ); - -// Cumulatively test whether at least three array elements are positive: -var y = cusomeBy( x, 3, fcn ); -console.log( y ); diff --git a/base/cusome-by/lib/assign.js b/base/cusome-by/lib/assign.js deleted file mode 100644 index 1be2e3a1c..000000000 --- a/base/cusome-by/lib/assign.js +++ /dev/null @@ -1,178 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function and assigns the results to elements in the provided output array. -* -* @private -* @param {Collection} x - input array -* @param {integer} n - number of elements -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ false, false, false, true, true ]; -* -* var out = [ false, null, false, null, false, null, false, null, false, null ]; -* var arr = indexed( x, 2, out, 2, 0, isPositive ); -* // returns [ false, null, false, null, false, null, false, null, true, null ] -*/ -function indexed( x, n, out, stride, offset, predicate, thisArg ) { - var flg; - var io; - var i; - - flg = false; - io = offset; - for ( i = 0; i <= x.length - 1; i++ ) { - if ( !flg && predicate.call( thisArg, x[ i ], i, x ) ) { - n -= 1; - if ( n <= 0 ) { - flg = true; - } - } - out[ io ] = flg; - io += stride; - } - return out; -} - -/** -* Cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function and assigns the results to elements in the provided output array. -* -* @private -* @param {Object} x - input array object -* @param {integer} n - number of elements -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = toAccessorArray( [ false, false, false, true, true ] ); -* -* var out = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] ); -* var arr = accessors( arraylike2object( x ), 2, arraylike2object( out ), 2, 0, isPositive ); -* -* var v = arr.get( 8 ); -* // returns true -*/ -function accessors( x, n, out, stride, offset, predicate, thisArg ) { - var xdata; - var odata; - var xget; - var oset; - var flg; - var io; - var i; - - xdata = x.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - flg = false; - for ( i = 0; i <= xdata.length - 1; i++ ) { - if ( !flg && predicate.call( thisArg, xget( xdata, i ), i, xdata ) ) { - n -= 1; - if ( n <= 0 ) { - flg = true; - } - } - - oset( odata, io, flg ); - io += stride; - } - return odata; -} - - -// MAIN // - -/** -* Cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function and assigns the results to elements in the provided output array. -* -* @param {Collection} x - input array -* @param {integer} n - number of elements -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ false, false, false, true, true ]; -* -* var out = [ false, null, false, null, false, null, false, null, false, null ]; -* var arr = indexed( x, 2, out, 2, 0, isPositive ); -* // returns [ false, null, false, null, false, null, false, null, true, null ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, n, out, stride, offset, predicate, thisArg ) { - var xo; - var oo; - - xo = arraylike2object( x ); - oo = arraylike2object( out ); - if ( xo.accessorProtocol || oo.accessorProtocol ) { - accessors( xo, n, oo, stride, offset, predicate, thisArg ); - return out; - } - indexed( x, n, out, stride, offset, predicate, thisArg ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cusome-by/lib/index.js b/base/cusome-by/lib/index.js deleted file mode 100644 index 6c5c66261..000000000 --- a/base/cusome-by/lib/index.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether at least `n` array elements in a provided array pass a test implemented by a predicate function. -* -* @module @stdlib/array/base/cusome-by -* -* @example -* var cusomeBy = require( '@stdlib/array/base/cusome-by' ); -* -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 0, 1, 1 ]; -* var y = cusomeBy( x, 2, isPositive ); -* // returns [ false, false, false, false, true ] -* -* @example -* var cusomeBy = require( '@stdlib/array/base/cusome-by' ); -* -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 0, 1, 1 ]; -* -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* var out = cusomeBy.assign( x, 2, y, 2, 0, isPositive ); -* // returns [ false, null, false, null, false, null, false, null, true, null ]; -* -* var bool = ( y === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cusome-by/lib/main.js b/base/cusome-by/lib/main.js deleted file mode 100644 index ae5b7d040..000000000 --- a/base/cusome-by/lib/main.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function. -* -* @param {Collection} x - input collection -* @param {integer} n - number of elements -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Array} output array -* -* @example -* function isPositive( value ) { -* return ( value > 0 ); -* } -* -* var x = [ 0, 0, 0, 1, 1 ]; -* -* var y = cusomeBy( x, 2, isPositive ); -* // returns [ false, false, false, false, true ] -*/ -function cusomeBy( x, n, predicate, thisArg ) { - var out = filled( false, x.length ); - return assign( x, n, out, 1, 0, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = cusomeBy; diff --git a/base/cusome-by/package.json b/base/cusome-by/package.json deleted file mode 100644 index aec14ef20..000000000 --- a/base/cusome-by/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/cusome-by", - "version": "0.0.0", - "description": "Cumulatively test whether at least `n` array elements in a provided array pass a test implemented by a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "utils", - "generic", - "array", - "cusome-by", - "cumulative", - "test", - "every", - "array.every", - "validate" - ] -} diff --git a/base/cusome-by/test/test.assign.js b/base/cusome-by/test/test.assign.js deleted file mode 100644 index a24c44f50..000000000 --- a/base/cusome-by/test/test.assign.js +++ /dev/null @@ -1,247 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cusomeBy = require( './../lib/assign.js' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return ( v > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cusomeBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 1, 1, 1, 0, 1 ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cusomeBy( x, 3, y, 2, 0, isPositive); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 0, 0 ]; - y = [ false, null, false, null, false, null, false, null ]; - - actual = cusomeBy( x, 3, y, 2, 0, isPositive ); - expected = [ false, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0, 0, 1, 0, 1 ]; - y = [ false, false, false, true, true, true ]; - - actual = cusomeBy( x, 1, y, 1, 1, isPositive ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cusomeBy( x, 2, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1 ]; - y = [ false, false ]; - - actual = cusomeBy( x, 1, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cusomeBy( x, 3, y, 1, 0, isPositive ); - expected = [ false, false, true, true, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null ]; - - actual = cusomeBy( x, 2, y, 2, 0, isPositive ); - expected = [ false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 1.0, 0.0, 0.0 ] ); - y = [ true, false, false, true, true, true ]; - - actual = cusomeBy( x, 2, y, 1, 0, isPositive ); - expected = [ false, false, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cusomeBy( x, 1, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - y = [ false, false ]; - - actual = cusomeBy( x, 3, y, 1, 1, isPositive ); - expected = [ false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements in a provided array pass a test implemented by a predicate function (accessor)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ 1, 0, 0, 0, 1 ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cusomeBy( x, 2, y, 1, 0, isPositive ); - expected = [ false, false, false, false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 1, 0 ] ); - ybuf = [ false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cusomeBy( x, 1, y, 2, 0, isPositive ); - expected = [ false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 1, 0, 0 ] ); - ybuf = [ true, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusomeBy( x, 2, y, 1, 1, isPositive ); - expected = [ true, false, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 0, 0, 0, 1 ] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusomeBy( x, 2, y, 1, 0, isPositive ); - expected = [ false, false, false, false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusomeBy( x, 0, y, 1, 0, isPositive ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1 ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusomeBy( x, 1, y, 1, 1, isPositive ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - var x; - var y; - - ctx = { - 'count': 0 - }; - - x = [ 1, 1, 1, 0, 1 ]; - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cusomeBy( x, 3, y, 2, 0, predicate, ctx); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cusome-by/test/test.js b/base/cusome-by/test/test.js deleted file mode 100644 index ae402bfb8..000000000 --- a/base/cusome-by/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cusomeBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cusomeBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cusomeBy, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cusomeBy, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cusome-by/test/test.main.js b/base/cusome-by/test/test.main.js deleted file mode 100644 index 45d4b2390..000000000 --- a/base/cusome-by/test/test.main.js +++ /dev/null @@ -1,158 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var cusomeBy = require( './../lib' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return ( v > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual(typeof cusomeBy, 'function', 'main export is a function'); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` elements in a provided array pass a test implemented by a predicate function (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 0, 0, 0, 1, 1 ]; - - actual = cusomeBy( x, 2, isPositive ); - expected = [ false, false, false, false, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0.0, 0.0, 0.0, 1.0, 1.0 ]; - actual = cusomeBy( x, 1, isPositive ); - expected = [ false, false, false, true, true]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, true, true, true, true ]; - actual = cusomeBy( x, 3, isPositive ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, null, 1 ]; - actual = cusomeBy( x, 2, isPositive ); - expected = [ false, false, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` elements in a provided array pass a test implemented by a predicate function (typed)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 1.0, 1.0, 0.0, 1.0 ] ); - actual = cusomeBy( x, 3, isPositive ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cusomeBy( x, 2, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual =cusomeBy( x, 1, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` elements in a provided array pass a test implemented by a predicate function (accessor array)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 1, 1, 0, 0, 0 ] ); - - actual = cusomeBy( x, 2, isPositive ); - expected = [ false, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); - actual = cusomeBy( x, 2, isPositive ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 1, 1, 1, 1 ] ); - actual = cusomeBy( x, 4, isPositive ); - expected = [ false, false, false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 0, 1, 0 ] ); - actual = cusomeBy( x, 1, isPositive ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 0, 0, 0, 0 ] ); - actual = cusomeBy( x, 0, isPositive ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array as first argument', function test( t ) { - var x = []; - t.deepEqual( cusomeBy( x, 1, isPositive ), [], 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - ctx = { - 'count': 0 - }; - - x = [ 0, 0, 0, 1, 1 ]; - - out = cusomeBy( x, 1, predicate, ctx ); - expected = [ false, false, false, true, true ]; - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v > 0 ); - } -}); diff --git a/base/cusome/README.md b/base/cusome/README.md deleted file mode 100644 index cbc394963..000000000 --- a/base/cusome/README.md +++ /dev/null @@ -1,114 +0,0 @@ - - -# cusome - -> Cumulatively test whether at least `n` array elements in a provided array are truthy. - -
- -## Usage - -```javascript -var cusome = require( '@stdlib/array/base/cusome' ); -``` - -#### cusome( x, n ) - -Cumulatively tests whether at least `n` array elements in a provided array are truthy. - -```javascript -var x = [ false, false, false, true, true ]; - -var y = cusome( x, 2 ); -// returns [ false, false, false, false, true ]; -``` - -#### cusome.assign( x, n, y, stride, offset ) - -Cumulatively tests whether at least `n` array elements in a provided array are truthy and assigns results to a provided output array. - -```javascript -var x = [ false, false, false, true, true ]; -var y = [ false, null, false, null, false, null, false, null, false, null ]; - -var out = cusome.assign( x, 2, y, 2, 0 ); -// returns [ false, null, false, null, false, null, false, null, true, null ] - -var bool = ( out === y ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **n**: number of elements. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cusome = require( '@stdlib/array/base/cusome' ); - -// Create an array of random values: -var x = bernoulli( 10, 0.3 ); -console.log( x ); - -// Cumulatively test whether at least two array elements are truthy: -var out = cusome( x, 2 ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/cusome/benchmark/benchmark.assign.length.js b/base/cusome/benchmark/benchmark.assign.length.js deleted file mode 100644 index ad4ded101..000000000 --- a/base/cusome/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cusome = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 0, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var y; - var v; - var i; - - y = filled( true, len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cusome.assign( x, 2, y, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/cusome/benchmark/benchmark.js b/base/cusome/benchmark/benchmark.js deleted file mode 100644 index 416e48061..000000000 --- a/base/cusome/benchmark/benchmark.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var cusome = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x; - var i; - var v; - - x = [ false, false, true, false, false ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cusome( x, 2 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/cusome/benchmark/benchmark.length.js b/base/cusome/benchmark/benchmark.length.js deleted file mode 100644 index 76f38d2aa..000000000 --- a/base/cusome/benchmark/benchmark.length.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled = require( './../../../base/filled' ); -var pkg = require( './../package.json' ).name; -var cusome = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filled( 0, len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cusome( x, 2 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/cusome/docs/repl.txt b/base/cusome/docs/repl.txt deleted file mode 100644 index 559d267ed..000000000 --- a/base/cusome/docs/repl.txt +++ /dev/null @@ -1,61 +0,0 @@ - -{{alias}}( x, n ) - Cumulatively tests whether at least `n` array elements in a provided array - are truthy. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - n: integer - Number of elements. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ false, false, false, true, true ]; - > var y = {{alias}}( x, 2 ) - [ false, false, false, false, true ]; - - -{{alias}}.assign( x, n, y, stride, offset ) - Cumulatively tests whether at least `n` array elements in a provided array - are truthy and assigns results to a provided output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - n: integer - Number of elements. - - y: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - Returns - ------- - y: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ false, false, false, true, true ]; - > var y = [ false, null, false, null, false, null, true, null, false ]; - > var result = {{alias}}.assign( x, 2, y, 2, 0 ) - [ false, null, false, null, false, null, false, null, true ]; - - See Also - -------- - diff --git a/base/cusome/docs/types/index.d.ts b/base/cusome/docs/types/index.d.ts deleted file mode 100644 index e498dd06f..000000000 --- a/base/cusome/docs/types/index.d.ts +++ /dev/null @@ -1,89 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Interface describing `cusome`. -*/ -interface cusome { - /** - * Cumulatively tests whether at least `n` array elements in a provided array are truthy. - * - * @param x - input array - * @param n - number of elements - * @returns output array - * - * @example - * var x = [ false, false, false, true, true ]; - * - * var y = cusome( x, 2 ); - * // returns [ false, false, false, false, true ]; - */ - ( x: Collection | AccessorArrayLike, n: number ): Array; - - /** - * Cumulatively tests whether at least `n` array elements in a provided array are truthy and assigns the results to a provided output array. - * - * @param x - input array - * @param n - number of elements - * @param y - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ false, false, false, true, true ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = cusome.assign( x, 2, y, 2, 0 ); - * // returns [ false, null, false, null, false, null, false, null, true, null ]; - */ - assign | AccessorArrayLike>( x: Collection | AccessorArrayLike, n: number, y: U, stride: number, offset: number ): U; -} - -/** -* Cumulatively tests whether at least `n` array elements in a provided array are truthy. -* -* @param x - input array -* @param n - number of elements -* @returns output array -* -* @example -* var x = [ false, false, false, true, true ]; -* -* var result = cusome( x, 2 ); -* // returns [ false, false, false, false, true ]; -* -* @example -* var x = [ false, false, false, true, true ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cusome.assign( x, y, 2, 0 ); -* // returns [ false, null, false, null, false, null, false, null, true, null ]; -*/ -declare var cusome: cusome; - - -// EXPORTS // - -export = cusome; diff --git a/base/cusome/docs/types/test.ts b/base/cusome/docs/types/test.ts deleted file mode 100644 index 45d3da570..000000000 --- a/base/cusome/docs/types/test.ts +++ /dev/null @@ -1,137 +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. -*/ - - -import cusome = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - cusome( [false, false, true, false, false], 2 ); // $ExpectType boolean[] - cusome( [ false, false, true, false, false ], 1 ); // $ExpectType boolean[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cusome( 1, 2 ); // $ExpectError - cusome( true, 2 ); // $ExpectError - cusome( false, 2 ); // $ExpectError - cusome( null, 2 ); // $ExpectError - cusome( void 0, 2 ); // $ExpectError - cusome( {}, 2 ); // $ExpectError - cusome( undefined, 2 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - cusome( [ true, false, true ], true ); // $ExpectError - cusome( [ true, false, true ], false ); // $ExpectError - cusome( [ true, false, true ], null ); // $ExpectError - cusome( [ true, false, true ], [] ); // $ExpectError - cusome( [ true, false, true ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cusome(); // $ExpectError - cusome( [] ); // $ExpectError - cusome( [], [], [] ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cusome.assign( x, 2, y, 2, 0 ); // $ExpectType (boolean | null)[] -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const y = [ false, false, true, false, false ]; - - cusome.assign( 1, 2, y, 2, 0 ); // $ExpectError - cusome.assign( true, 2, y, 2, 0 ); // $ExpectError - cusome.assign( false, 2, y, 2, 0 ); // $ExpectError - cusome.assign( null, 2, y, 2, 0 ); // $ExpectError - cusome.assign( void 0, 2, y, 2, 0 ); // $ExpectError - cusome.assign( {}, 2, y, 2, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an number... -{ - const x = [ false, false, true, false, false ]; - const y = [false, false, true, false, false]; - - cusome.assign( x, undefined, y, 2, 0 ); // $ExpectError - cusome.assign( x, true, y, 2, 0 ); // $ExpectError - cusome.assign( x, false, y, 2, 0 ); // $ExpectError - cusome.assign( x, null, y, 2, 0 ); // $ExpectError - cusome.assign( x, void 0, y, 2, 0 ); // $ExpectError - cusome.assign( x, {}, y, 2, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const x = [ false, false, true, false, false ]; - - cusome.assign( x, 2, true, 2, 0 ); // $ExpectError - cusome.assign( x, 2, false, 2, 0 ); // $ExpectError - cusome.assign( x, 2, null, 2, 0 ); // $ExpectError - cusome.assign( x, 2, void 0, 2, 0 ); // $ExpectError - cusome.assign( x, 2, {}, 2, 0 ); // $ExpectError - cusome.assign( x, 2, undefined, 2, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cusome.assign( x, 2, y, true, 2 ); // $ExpectError - cusome.assign( x, 2, y, false, 2 ); // $ExpectError - cusome.assign( x, 2, y, null, 2 ); // $ExpectError - cusome.assign( x, 2, y, void 0, 2 ); // $ExpectError - cusome.assign( x, 2, y, {}, 2 ); // $ExpectError - cusome.assign( x, 2, y, undefined, 2 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ false, false, true, false, false ]; - const y = [ false, null, false, null, false, null, false, null, false, null ]; - - cusome.assign( x, 2, y, 1, '1' ); // $ExpectError - cusome.assign( x, 1, y, 1, true ); // $ExpectError - cusome.assign( x, 2, y, 1, false ); // $ExpectError - cusome.assign( x, 1, y, 1, null ); // $ExpectError - cusome.assign( x, 2, y, 1, void 0 ); // $ExpectError - cusome.assign( x, 1, y, 1, {} ); // $ExpectError - cusome.assign( x, 2, y, 1, [] ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - cusome.assign(); // $ExpectError - cusome.assign( [] ); // $ExpectError - cusome.assign( [], [] ); // $ExpectError - cusome.assign( [], [], 2 ); // $ExpectError - cusome.assign( [], [], 1, 1, {}, {} ); // $ExpectError -} diff --git a/base/cusome/examples/index.js b/base/cusome/examples/index.js deleted file mode 100644 index 50680580d..000000000 --- a/base/cusome/examples/index.js +++ /dev/null @@ -1,30 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var cusome = require( './../lib' ); - -// Create an array of random values: -var x = bernoulli( 10, 0.3 ); -console.log( x ); - -// Cumulatively test whether at least two array elements are truthy: -var out = cusome( x, 2 ); -console.log( out ); diff --git a/base/cusome/lib/assign.js b/base/cusome/lib/assign.js deleted file mode 100644 index a20d7f662..000000000 --- a/base/cusome/lib/assign.js +++ /dev/null @@ -1,308 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplex128Array = require( './../../../base/assert/is-complex128array' ); -var isComplex64Array = require( './../../../base/assert/is-complex64array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Cumulatively tests whether at least `n` array elements in a provided array are truthy. -* -* @private -* @param {Collection} x - input array -* @param {integer} n - number of elements -* @param {Collection} y - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ false, false, false, true, true ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var out = indexed( x, 2, y, 2, 0 ); -* // returns [ false, null, false, null, false, null, false, null, true, null ] -*/ -function indexed( x, n, y, stride, offset ) { - var flg; - var io; - var i; - - flg = false; - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( !flg && x[ i ] ) { - n -= 1; - if ( n <= 0 ) { - flg = true; - } - } - y[ io ] = flg; - io += stride; - } - return y; -} - -/** -* Cumulatively tests whether at least `n` array elements in an accessor array are truthy. -* -* @private -* @param {Object} x - input array object -* @param {integer} n - number of elements -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ false, false, false, true, true ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] ); -* -* var arr = accessors( arraylike2object( x ), 2, arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns false -* -* v = y.get( 2 ); -* // returns false -* -* v = y.get( 4 ); -* // returns false -* -* v = y.get( 6 ); -* // returns false -* -* v = y.get( 8 ); -* // returns true -*/ -function accessors( x, n, y, stride, offset ) { - var xdata; - var ydata; - var xget; - var yset; - var flg; - var io; - var i; - - xdata = x.data; - ydata = y.data; - - xget = x.accessors[ 0 ]; - yset = y.accessors[ 1 ]; - - flg = false; - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( !flg && xget( xdata, i ) ) { - n -= 1; - if ( n <= 0 ) { - flg = true; - } - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - -/** -* Cumulatively tests whether at least `n` array elements in a provided complex number array are truthy. -* -* @private -* @param {Collection} x - array containing interleaved real and imaginary components -* @param {integer} n - number of elements -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] ); -* -* var arr = complex( x, 2, arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns false -* -* v = y.get( 2 ); -* // returns false -* -* v = y.get( 4 ); -* // returns false -* -* v = y.get( 6 ); -* // returns false -* -* v = y.get( 8 ); -* // returns false -*/ -function complex( x, n, y, stride, offset ) { - var ydata; - var yset; - var flg; - var io; - var i; - - yset = y.accessors[ 1 ]; - ydata = y.data; - - flg = false; - io = offset; - for ( i = 0; i < x.length; i += 2 ) { - if ( !flg && ( x[ i ] || x[ i+1 ] ) ) { - n -= 1; - if ( n <= 0 ) { - flg = true; - } - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - -/** -* Cumulatively tests whether at least `n` array elements in a provided array are truthy. -* -* @private -* @param {Collection} x - input array -* @param {integer} n - number of elements -* @param {Object} y - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Uint8Array( [ 0, 0, 0, 1, 0 ] ); -* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] ); -* -* var arr = boolean( x, 2, arraylike2object( y ), 2, 0 ); -* -* var v = y.get( 0 ); -* // returns false -* -* v = y.get( 2 ); -* // returns false -* -* v = y.get( 4 ); -* // returns false -* -* v = y.get( 6 ); -* // returns false -* -* v = y.get( 8 ); -* // returns false -*/ -function boolean( x, n, y, stride, offset ) { - var ydata; - var yset; - var flg; - var io; - var i; - - yset = y.accessors[ 1 ]; - ydata = y.data; - - flg = false; - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( !flg && x[ i ] ) { - n -= 1; - if ( n <= 0 ) { - flg = true; - } - } - yset( ydata, io, flg ); - io += stride; - } - return ydata; -} - - -// MAIN // - -/** -* Cumulatively tests whether at least `n` array elements in a provided array are truthy and assigns results to a provided output array. -* -* @param {Collection} x - input array -* @param {integer} n - number of elements -* @param {Collection} y - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ false, false, false, true, true ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var out = assign( x, 2, y, 2, 0 ); -* // returns [ false, null, false, null, false, null, false, null, true, null ] -* -* var bool = ( y === out ); -* // returns true -*/ -function assign( x, n, y, stride, offset ) { - var xo = arraylike2object( x ); - var yo = arraylike2object( y ); - if ( - xo.accessorProtocol || - yo.accessorProtocol - ) { - // If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero... - if ( isComplex128Array( x ) ) { - return complex( reinterpret128( x, 0 ), n, yo, stride, offset ); - } - if ( isComplex64Array( x ) ) { - return complex( reinterpret64( x, 0 ), n, yo, stride, offset ); - } - if ( isBooleanArray( x ) ) { - return boolean( reinterpretBoolean( x, 0 ), n, yo, stride, offset ); - } - return accessors( xo, n, yo, stride, offset ); - } - indexed( x, n, y, stride, offset ); - return y; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/cusome/lib/index.js b/base/cusome/lib/index.js deleted file mode 100644 index 43203f529..000000000 --- a/base/cusome/lib/index.js +++ /dev/null @@ -1,58 +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. -*/ - -'use strict'; - -/** -* Cumulatively test whether at least `n` array elements in a provided array are truthy. -* -* @module @stdlib/array/base/cusome -* -* @example -* var cusome = require( '@stdlib/array/base/cusome' ); -* -* var x = [ false, false, false, true, true ]; -* -* var y = cusome( x, 2 ); -* // returns [ false, false, false, false, true ] -* -* @example -* var cusome = require( '@stdlib/array/base/cusome' ); -* -* var x = [ false, false, false, true, true ]; -* var y = [ false, null, false, null, false, null, false, null, false, null ]; -* -* var arr = cusome.assign( x, 2, y, 2, 0 ); -* // returns [ false, null, false, null, false, null, false, null, true, null ] -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/cusome/lib/main.js b/base/cusome/lib/main.js deleted file mode 100644 index b2bb924e7..000000000 --- a/base/cusome/lib/main.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Cumulatively tests whether at least `n` array elements in a provided array are truthy. -* -* @param {Collection} x - input array -* @param {integer} n - number of elements -* @returns {Array} output array -* -* @example -* var x = [ false, false, false, true, true ]; -* -* var y = cusome( x, 2 ); -* // returns [ false, false, false, false, true ] -*/ -function cusome( x, n ) { - var y = filled( false, x.length ); - return assign( x, n, y, 1, 0 ); -} - - -// EXPORTS // - -module.exports = cusome; diff --git a/base/cusome/package.json b/base/cusome/package.json deleted file mode 100644 index 69a917f90..000000000 --- a/base/cusome/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/cusome", - "version": "0.0.0", - "description": "Cumulatively test whether at least `n` array elements in a provided array are truthy.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "utils", - "generic", - "array", - "cusome", - "cumulative", - "test", - "every", - "array.every", - "validate" - ] -} diff --git a/base/cusome/test/test.assign.js b/base/cusome/test/test.assign.js deleted file mode 100644 index 5ad0e966e..000000000 --- a/base/cusome/test/test.assign.js +++ /dev/null @@ -1,396 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cusome = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cusome, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ false, false, false, true, false ]; - y = [ false, true, false, true, false ]; - - actual = cusome( x, 1, y, 1, 0 ); - expected = [ false, false, false, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false, false, true, false, false ]; - y = [ false, null, false, null, true, null, true, null, true, null ]; - - actual = cusome( x, 1, y, 2, 0 ); - expected = [ false, null, false, null, true, null, true, null, true, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false, false, true, false, false ]; - y = [ false, false, false, true, true, true ]; - - actual = cusome( x, 2, y, 1, 1 ); - expected = [ false, false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = [ false, false, false, false, false ]; - - actual = cusome( x, 2, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ false ]; - y = [ false, false ]; - - actual = cusome( x, 1, y, 1, 1 ); - expected = [ false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0 ] ); - y = [ false, true, false, true, false ]; - - actual = cusome( x, 1, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cusome( x, 2, y, 2, 0 ); - expected = [ - false, null, false, null, false, null, false, null, false, null - ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - y = [ false, false, false, true, true, true ]; - - actual = cusome( x, 1, y, 1, 1 ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cusome( x, 2, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - y = [ false, false ]; - - actual = cusome( x, 1, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (boolean)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new BooleanArray( [ true, true, true, true, true ] ); - y = [ false, true, false, true, false ]; - - actual = cusome( x, 1, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, true, false, false ] ); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cusome( x, 2, y, 2, 0 ); - expected = [ false, null, false, null, false, null, false, null, false, null ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, true, false, false ] ); - y = [ false, false, false, true, true, true ]; - - actual = cusome( x, 1, y, 1, 1 ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [] ); - y = [ false, false, false, false, false ]; - - actual = cusome( x, 1, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true ] ); - y = [ false, false ]; - - actual = cusome( x, 1, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (complex128)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Complex128Array([ 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0 ]); - y = [ false, true, false, true, false ]; - - actual = cusome( x, 1, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array([ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cusome( x, 2, y, 2, 0 ); - expected = [ - false, null, false, null, false, null, false, null, false, null - ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array([ - 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 - ]); - y = [ false, false, false, true, true, true ]; - - actual = cusome( x, 1, y, 1, 1 ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cusome( x, 2, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 1.0 ] ); - y = [ false, false ]; - - actual = cusome( x, 1, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (complex64)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Complex64Array([ - 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0 - ]); - y = [ false, true, false, true, false ]; - - actual = cusome( x, 1, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array([ - 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 - ]); - y = [ false, null, false, null, false, null, false, null, false, null ]; - - actual = cusome( x, 2, y, 2, 0 ); - expected = [ - false, null, false, null, false, null, false, null, false, null - ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array([ - 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 - ]); - y = [ false, false, false, true, true, true ]; - - actual = cusome( x, 1, y, 1, 1 ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [] ); - y = [ false, false, false, false, false ]; - - actual = cusome( x, 1, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 1.0 ] ); - y = [ false, false ]; - - actual = cusome( x, 1, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (accessor)', function test( t ) { - var expected; - var actual; - var ybuf; - var x; - var y; - - x = toAccessorArray( [ true, false, true, false, true ] ); - ybuf = [ false, true, false, true, false ]; - y = toAccessorArray( ybuf ); - - actual = cusome( x, 1, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, true, false, false ] ); - ybuf = [ false, null, false, null, false, null, false, null, false, null ]; - y = toAccessorArray( ybuf ); - - actual = cusome( x, 2, y, 2, 0 ); - expected = [ - false, null, false, null, false, null, false, null, false, null - ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ false, false, true, false, false ] ); - ybuf = [ false, false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusome( x, 1, y, 1, 1 ); - expected = [ false, false, false, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ true, false, false, false, false ] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusome( x, 1, y, 1, 0 ); - expected = [ true, true, true, true, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [] ); - ybuf = [ false, false, false, false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusome( x, 2, y, 1, 0 ); - expected = [ false, false, false, false, false ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - x = toAccessorArray( [ true ] ); - ybuf = [ false, false ]; - y = toAccessorArray( ybuf ); - - actual = cusome( x, 1, y, 1, 1 ); - expected = [ false, true ]; - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/cusome/test/test.js b/base/cusome/test/test.js deleted file mode 100644 index 2924a728b..000000000 --- a/base/cusome/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var cusome = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cusome, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( cusome, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( cusome, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/cusome/test/test.main.js b/base/cusome/test/test.main.js deleted file mode 100644 index ed706c917..000000000 --- a/base/cusome/test/test.main.js +++ /dev/null @@ -1,252 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var cusome = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cusome, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ false, false, false, true, false ]; - actual = cusome( x, 2 ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; - actual = cusome( x, 1 ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, true, true, true, true ]; - actual = cusome( x, 2 ); - expected = [ false, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ null, {}, null ]; - actual = cusome( x, 1 ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, false, false, true, false ]; - actual = cusome( x, 1); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (typed)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 0.0 ] ); - actual = cusome( x, 1 ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 1.0, 0.0, 0.0 ] ); - actual = cusome( x, 1 ); - expected = [ false, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - actual = cusome( x, 1 ); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 0.0, 1.0, 0.0 ] ); - actual = cusome( x, 1 ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = cusome( x, 1); - expected = [ true, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (boolean)', function test( t ) { - var expected; - var actual; - var x; - - x = new BooleanArray( [ false, false, true, false, false ] ); - actual = cusome( x, 2 ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, false, false, false, false ] ); - actual = cusome( x, 1); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, true, true, true, true ] ); - actual = cusome( x, 2 ); - expected = [ false, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ false, true, true ] ); - actual = cusome( x, 1 ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true, false, false ] ); - actual = cusome( x, 2); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (complex128)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array([ - 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 - ]); - actual = cusome( x, 1 ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array([ - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 - ]); - actual = cusome( x, 1 ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array([ - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 - ]); - actual = cusome( x, 2 ); - expected = [ false, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 0.0 ] ); - actual = cusome( x, 1); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array([ - 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 - ]); - actual = cusome( x, 2); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (complex64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex64Array([ - 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 - ]); - actual = cusome( x, 1 ); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array([ - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 - ]); - actual = cusome( x, 1 ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array([ - 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 - ]); - actual = cusome( x, 2 ); - expected = [ false, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 0.0 ] ); - actual = cusome( x, 1); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array([ - 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 - ]); - actual = cusome( x, 2); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function cumulatively tests whether at least `n` array elements are truthy (accessor)', function test( t ) { - var expected; - var actual; - var x; - - x = new toAccessorArray( [ false, false, true, false, false ] ); - actual = cusome( x, 2 ); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new toAccessorArray( [ false, false, false, false, false ] ); - actual = cusome( x, 1); - expected = [ false, false, false, false, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new toAccessorArray( [ true, true, true, true, true ] ); - actual = cusome( x, 2 ); - expected = [ false, true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new toAccessorArray( [ false, true, true ] ); - actual = cusome( x, 1 ); - expected = [ false, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new toAccessorArray( [ true, false, true, false, false ] ); - actual = cusome( x, 2); - expected = [ false, false, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/dedupe/README.md b/base/dedupe/README.md deleted file mode 100644 index b25a7de5a..000000000 --- a/base/dedupe/README.md +++ /dev/null @@ -1,145 +0,0 @@ - - -# dedupe - -> Remove consecutive duplicated values. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var dedupe = require( '@stdlib/array/base/dedupe' ); -``` - -#### dedupe( x, limit, equalNaNs ) - -Removes consecutive duplicated values. - -```javascript -var x = [ 1, 1, 2, 3, 3 ]; - -var y = dedupe( x, 1, false ); -// returns [ 1, 2, 3 ] - -var bool = ( x === y ); -// returns true -``` - -When `equalNaNs` is `false`, `NaN` values are considered distinct, and, when `equalNaNs` is `true`, `NaN` values are considered equal. - -```javascript -var x = [ NaN, NaN, 2, NaN, NaN ]; - -var y1 = dedupe( x, 1, false ); -// returns [ NaN, NaN, 2, NaN, NaN ] - -var y2 = dedupe( x, 1, true ); -// returns [ NaN, 2, NaN ] -``` - -To allow consecutive duplicate values up to a specified limit, provide a `limit` argument greater than one. - -```javascript -var x = [ 1, 1, 1, 2, 2, 3, 3, 3 ]; - -var y = dedupe( x, 2, false ); -// returns [ 1, 1, 2, 2, 3, 3 ] -``` - -
- - - - - -
- -## Notes - -- The function mutates the input array. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var dedupe = require( '@stdlib/array/base/dedupe' ); - -// Create an array of random numbers: -var x = discreteUniform( 30, 0, 5, { - 'dtype': 'generic' -}); -// returns [...] - -// Remove consecutive duplicates: -var y = dedupe( x, 1, false ); -// returns [...] - -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/dedupe/benchmark/benchmark.length.js b/base/dedupe/benchmark/benchmark.length.js deleted file mode 100644 index 2554ffc31..000000000 --- a/base/dedupe/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var dedupe = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); // Note: this corresponds to the scenario where all values are unique - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dedupe( x, 1, false ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/dedupe/docs/repl.txt b/base/dedupe/docs/repl.txt deleted file mode 100644 index 2e913b4f3..000000000 --- a/base/dedupe/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( x, limit, equalNaNs ) - Removes consecutive duplicated values. - - The function mutates the input array. - - Parameters - ---------- - x: Array - Input array. - - limit: integer - Number of allowed consecutive duplicates. - - equalNaNs: boolean - Boolean indicating whether NaNs should be considered equal. - - Returns - ------- - out: Array - Input array. - - Examples - -------- - > var x = [ 1, 1, 2, 3, 3 ]; - > var out = {{alias}}( x, 1, false ) - [ 1, 2, 3 ] - > var bool = ( out === x ) - true - - See Also - -------- - diff --git a/base/dedupe/docs/types/index.d.ts b/base/dedupe/docs/types/index.d.ts deleted file mode 100644 index fdc40440c..000000000 --- a/base/dedupe/docs/types/index.d.ts +++ /dev/null @@ -1,56 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Removes consecutive duplicated values. -* -* ## Notes -* -* - The function mutates the input array. -* -* @param x - input array -* @param limit - number of allowed consecutive duplicates -* @param equalNaNs - boolean indicating whether NaNs should be considered equal -* @returns input array -* -* @example -* var x = [ 1, 1, 2, 3, 3 ]; -* -* var y = dedupe( x, 1, false ); -* // returns [ 1, 2, 3 ] -* -* var bool = ( x === y ); -* // returns true -* -* @example -* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ]; -* -* var y = dedupe( x, 2, false ); -* // returns [ 1, 1, 2, 1, 1, 3, 3 ] -* -* var bool = ( x === y ); -* // returns true -*/ -declare function dedupe( x: Array, limit: number, equalNaNs: boolean ): Array; - - -// EXPORTS // - -export = dedupe; diff --git a/base/dedupe/docs/types/test.ts b/base/dedupe/docs/types/test.ts deleted file mode 100644 index af9a2d3ba..000000000 --- a/base/dedupe/docs/types/test.ts +++ /dev/null @@ -1,76 +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. -*/ - -import dedupe = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - dedupe( [ 1, 2, 3 ], 1, false ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - dedupe( '5', 1, false ); // $ExpectError - dedupe( 5, 1, false ); // $ExpectError - dedupe( true, 1, false ); // $ExpectError - dedupe( false, 1, false ); // $ExpectError - dedupe( null, 1, false ); // $ExpectError - dedupe( void 0, 1, false ); // $ExpectError - dedupe( {}, 1, false ); // $ExpectError - dedupe( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - dedupe( x, '5', false ); // $ExpectError - dedupe( x, true, false ); // $ExpectError - dedupe( x, false, false ); // $ExpectError - dedupe( x, null, false ); // $ExpectError - dedupe( x, void 0, false ); // $ExpectError - dedupe( x, {}, false ); // $ExpectError - dedupe( x, [], false ); // $ExpectError - dedupe( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ 1, 2, 3 ]; - - dedupe( x, 1, '5' ); // $ExpectError - dedupe( x, 1, 5 ); // $ExpectError - dedupe( x, 1, null ); // $ExpectError - dedupe( x, 1, void 0 ); // $ExpectError - dedupe( x, 1, {} ); // $ExpectError - dedupe( x, 1, [] ); // $ExpectError - dedupe( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - dedupe(); // $ExpectError - dedupe( x ); // $ExpectError - dedupe( x, 1 ); // $ExpectError - dedupe( x, 1, false, {} ); // $ExpectError -} diff --git a/base/dedupe/examples/index.js b/base/dedupe/examples/index.js deleted file mode 100644 index 8db9998d9..000000000 --- a/base/dedupe/examples/index.js +++ /dev/null @@ -1,34 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var dedupe = require( './../lib' ); - -// Create an array of random numbers: -var x = discreteUniform( 30, 0, 5, { - 'dtype': 'generic' -}); -// returns [...] - -// Remove consecutive duplicates: -var y = dedupe( x, 1, false ); -// returns [...] - -console.log( y ); diff --git a/base/dedupe/lib/index.js b/base/dedupe/lib/index.js deleted file mode 100644 index f17a30c8b..000000000 --- a/base/dedupe/lib/index.js +++ /dev/null @@ -1,45 +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'; - -/** -* Remove consecutive duplicated values. -* -* @module @stdlib/array/base/dedupe -* -* @example -* var dedupe = require( '@stdlib/array/base/dedupe' ); -* -* var x = [ 1, 1, 2, 3, 3 ]; -* -* var y = dedupe( x, 1, false ); -* // returns [ 1, 2, 3 ] -* -* var bool = ( x === y ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/dedupe/lib/main.js b/base/dedupe/lib/main.js deleted file mode 100644 index 322580c90..000000000 --- a/base/dedupe/lib/main.js +++ /dev/null @@ -1,196 +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 isnan = require( '@stdlib/math/base/assert/is-nan' ); - - -// FUNCTIONS // - -/** -* De-duplicates values in-place. -* -* @private -* @param {Array} x - input array -* @param {PositiveInteger} limit - number of allowed consecutive duplicates -* @returns {Array} input array -* -* @example -* var x = [ 1, 1, 2, 3, 3 ]; -* -* var y = dedupeInPlace( x, 1 ); -* // returns [ 1, 2, 3 ] -* -* var bool = ( x === y ); -* // returns true -* -* @example -* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ]; -* -* var y = dedupeInPlace( x, 2 ); -* // returns [ 1, 1, 2, 1, 1, 3, 3 ] -* -* var bool = ( x === y ); -* // returns true -*/ -function dedupeInPlace( x, limit ) { - var count; - var prev; - var len; - var ptr; - var v; - var i; - - len = x.length; - if ( len === 0 ) { - return x; - } - prev = x[ 0 ]; - count = 1; - ptr = 1; - for ( i = 1; i < len; i++ ) { - v = x[ i ]; - if ( v === prev ) { - count += 1; - if ( count <= limit ) { - x[ ptr ] = prev; - ptr += 1; - } - } else { - prev = v; - count = 1; - x[ ptr ] = prev; - ptr += 1; - } - } - x.length = ptr; - return x; -} - -/** -* De-duplicates values in-place, treating `NaN` values as equal. -* -* @private -* @param {Array} x - input array -* @param {PositiveInteger} limit - number of allowed consecutive duplicates -* @returns {Array} input array -* -* @example -* var x = [ 1, 1, 2, NaN, NaN, 3, 3 ]; -* -* var y = dedupeEqualNaNs( x, 1 ); -* // returns [ 1, 2, NaN, 3 ] -* -* var bool = ( x === y ); -* // returns true -* -* @example -* var x = [ 1, 1, 1, 2, 1, 1, NaN, NaN, NaN, 3, 3 ]; -* -* var y = dedupeEqualNaNs( x, 2 ); -* // returns [ 1, 1, 2, 1, 1, NaN, NaN, 3, 3 ] -* -* var bool = ( x === y ); -* // returns true -*/ -function dedupeEqualNaNs( x, limit ) { - var count; - var prev; - var len; - var ptr; - var FLG; - var v; - var i; - - len = x.length; - if ( len === 0 ) { - return x; - } - FLG = false; - prev = x[ 0 ]; - if ( isnan( prev ) ) { - FLG = true; - } - count = 1; - ptr = 1; - for ( i = 1; i < len; i++ ) { - v = x[ i ]; - if ( v === prev || ( FLG && isnan( v ) ) ) { - count += 1; - if ( count <= limit ) { - x[ ptr ] = prev; - ptr += 1; - } - } else { - prev = v; - count = 1; - x[ ptr ] = prev; - ptr += 1; - FLG = false; - if ( isnan( prev ) ) { - FLG = true; - } - } - } - x.length = ptr; - return x; -} - - -// MAIN // - -/** -* Removes consecutive duplicated values. -* -* @param {Array} x - input array -* @param {PositiveInteger} limit - number of allowed consecutive duplicates -* @param {boolean} equalNaNs - boolean indicating whether NaNs should be considered equal -* @returns {Array} de-duplicated values -* -* @example -* var x = [ 1, 1, 2, 3, 3 ]; -* -* var y = dedupe( x, 1, false ); -* // returns [ 1, 2, 3 ] -* -* var bool = ( x === y ); -* // returns true -* -* @example -* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ]; -* -* var y = dedupe( x, 2, false ); -* // returns [ 1, 1, 2, 1, 1, 3, 3 ] -* -* var bool = ( x === y ); -* // returns true -*/ -function dedupe( x, limit, equalNaNs ) { - if ( equalNaNs ) { - return dedupeEqualNaNs( x, limit ); - } - return dedupeInPlace( x, limit ); -} - - -// EXPORTS // - -module.exports = dedupe; diff --git a/base/dedupe/package.json b/base/dedupe/package.json deleted file mode 100644 index e00edee82..000000000 --- a/base/dedupe/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/dedupe", - "version": "0.0.0", - "description": "Remove consecutive duplicated values.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "dedupe", - "deduplicate", - "deduplication", - "duplicate", - "compress", - "unique", - "uniq" - ] -} diff --git a/base/dedupe/test/test.js b/base/dedupe/test/test.js deleted file mode 100644 index 1ba01b109..000000000 --- a/base/dedupe/test/test.js +++ /dev/null @@ -1,177 +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 isnan = require( '@stdlib/math/base/assert/is-nan' ); -var dedupe = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dedupe, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function removes consecutive duplicated values', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 1, 2, 3, 3 ]; - expected = [ 1, 2, 3 ]; - actual = dedupe( x, 1, false ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports considering NaN values as distinct', function test( t ) { - var expected; - var actual; - var x; - var i; - - x = [ NaN, NaN, 2, NaN, NaN, 3, 3 ]; - expected = [ NaN, NaN, 2, NaN, NaN, 3 ]; - actual = dedupe( x, 1, false ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - - for ( i = 0; i < expected.length; i++ ) { - if ( isnan( expected[ i ] ) ) { - t.strictEqual( isnan( actual[ i ] ), true, 'returns expected value' ); - } else { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function supports considering NaN values as equal', function test( t ) { - var expected; - var actual; - var x; - var i; - - x = [ NaN, NaN, 2, NaN, NaN, 3, 3 ]; - expected = [ NaN, 2, NaN, 3 ]; - actual = dedupe( x, 1, true ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - - for ( i = 0; i < expected.length; i++ ) { - if ( isnan( expected[ i ] ) ) { - t.strictEqual( isnan( actual[ i ] ), true, 'returns expected value' ); - } else { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function supports specifying a maximum number of consecutive duplicates', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 1, 1, 1, 2, 2, 3, 3, 3 ]; - expected = [ 1, 1, 2, 2, 3, 3 ]; - actual = dedupe( x, 2, false ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying a maximum number of consecutive duplicates (distinct NaNs)', function test( t ) { - var expected; - var actual; - var x; - var i; - - x = [ NaN, NaN, NaN, NaN, 2, 2, NaN, NaN, NaN, 3, 3, 3 ]; - expected = [ NaN, NaN, NaN, NaN, 2, 2, NaN, NaN, NaN, 3, 3 ]; - actual = dedupe( x, 2, false ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - - for ( i = 0; i < expected.length; i++ ) { - if ( isnan( expected[ i ] ) ) { - t.strictEqual( isnan( actual[ i ] ), true, 'returns expected value' ); - } else { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function supports specifying a maximum number of consecutive duplicates (equal NaNs)', function test( t ) { - var expected; - var actual; - var x; - var i; - - x = [ NaN, NaN, NaN, NaN, NaN, NaN, NaN, 2, 2, NaN, NaN, NaN, 3, 3, 3 ]; - expected = [ NaN, NaN, NaN, 2, 2, NaN, NaN, NaN, 3, 3, 3 ]; - actual = dedupe( x, 3, true ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - - for ( i = 0; i < expected.length; i++ ) { - if ( isnan( expected[ i ] ) ) { - t.strictEqual( isnan( actual[ i ] ), true, 'returns expected value' ); - } else { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of length `0`', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = dedupe( [], 1, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = dedupe( [], 1, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = dedupe( [], 2, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = dedupe( [], 2, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/docs/types/index.d.ts b/base/docs/types/index.d.ts deleted file mode 100644 index ed7f2a342..000000000 --- a/base/docs/types/index.d.ts +++ /dev/null @@ -1,5301 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable max-lines */ - -import AccessorArray = require( './../../../base/accessor' ); -import accessorGetter = require( './../../../base/accessor-getter' ); -import accessorSetter = require( './../../../base/accessor-setter' ); -import accessors = require( './../../../base/accessors' ); -import any = require( './../../../base/any' ); -import anyBy = require( './../../../base/any-by' ); -import anyByRight = require( './../../../base/any-by-right' ); -import arraylike2object = require( './../../../base/arraylike2object' ); -import assert = require( './../../../base/assert' ); -import at = require( './../../../base/at' ); -import at2d = require( './../../../base/at2d' ); -import at3d = require( './../../../base/at3d' ); -import at4d = require( './../../../base/at4d' ); -import at5d = require( './../../../base/at5d' ); -import atnd = require( './../../../base/atnd' ); -import bifurcateEntries = require( './../../../base/bifurcate-entries' ); -import bifurcateEntriesBy = require( './../../../base/bifurcate-entries-by' ); -import bifurcateIndices = require( './../../../base/bifurcate-indices' ); -import bifurcateIndicesBy = require( './../../../base/bifurcate-indices-by' ); -import bifurcateValues = require( './../../../base/bifurcate-values' ); -import bifurcateValuesBy = require( './../../../base/bifurcate-values-by' ); -import binary2d = require( './../../../base/binary2d' ); -import binary3d = require( './../../../base/binary3d' ); -import binary4d = require( './../../../base/binary4d' ); -import binary5d = require( './../../../base/binary5d' ); -import binarynd = require( './../../../base/binarynd' ); -import broadcastArray = require( './../../../base/broadcast-array' ); -import bbinary2d = require( './../../../base/broadcasted-binary2d' ); -import bbinary3d = require( './../../../base/broadcasted-binary3d' ); -import bbinary4d = require( './../../../base/broadcasted-binary4d' ); -import bbinary5d = require( './../../../base/broadcasted-binary5d' ); -import bquaternary2d = require( './../../../base/broadcasted-quaternary2d' ); -import bquaternary3d = require( './../../../base/broadcasted-quaternary3d' ); -import bquaternary4d = require( './../../../base/broadcasted-quaternary4d' ); -import bquaternary5d = require( './../../../base/broadcasted-quaternary5d' ); -import bquinary2d = require( './../../../base/broadcasted-quinary2d' ); -import bquinary4d = require( './../../../base/broadcasted-quinary4d' ); -import bternary2d = require( './../../../base/broadcasted-ternary2d' ); -import bternary3d = require( './../../../base/broadcasted-ternary3d' ); -import bternary4d = require( './../../../base/broadcasted-ternary4d' ); -import bternary5d = require( './../../../base/broadcasted-ternary5d' ); -import bunary2d = require( './../../../base/broadcasted-unary2d' ); -import bunary3d = require( './../../../base/broadcasted-unary3d' ); -import bunary4d = require( './../../../base/broadcasted-unary4d' ); -import bunary5d = require( './../../../base/broadcasted-unary5d' ); -import cartesianPower = require( './../../../base/cartesian-power' ); -import cartesianProduct = require( './../../../base/cartesian-product' ); -import cartesianSquare = require( './../../../base/cartesian-square' ); -import copy = require( './../../../base/copy' ); -import copyIndexed = require( './../../../base/copy-indexed' ); -import countFalsy = require( './../../../base/count-falsy' ); -import countIf = require( './../../../base/count-if' ); -import countSameValue = require( './../../../base/count-same-value' ); -import countSameValueZero = require( './../../../base/count-same-value-zero' ); -import countTruthy = require( './../../../base/count-truthy' ); -import cuany = require( './../../../base/cuany' ); -import cuevery = require( './../../../base/cuevery' ); -import cunone = require( './../../../base/cunone' ); -import dedupe = require( './../../../base/dedupe' ); -import every = require( './../../../base/every' ); -import everyBy = require( './../../../base/every-by' ); -import everyByRight = require( './../../../base/every-by-right' ); -import fancySlice = require( './../../../base/fancy-slice' ); -import fancySliceAssign = require( './../../../base/fancy-slice-assign' ); -import fill = require( './../../../base/fill' ); -import fillBy = require( './../../../base/fill-by' ); -import filled = require( './../../../base/filled' ); -import filledBy = require( './../../../base/filled-by' ); -import filled2d = require( './../../../base/filled2d' ); -import filled2dBy = require( './../../../base/filled2d-by' ); -import filled3d = require( './../../../base/filled3d' ); -import filled3dBy = require( './../../../base/filled3d-by' ); -import filled4d = require( './../../../base/filled4d' ); -import filled4dBy = require( './../../../base/filled4d-by' ); -import filled5d = require( './../../../base/filled5d' ); -import filled5dBy = require( './../../../base/filled5d-by' ); -import fillednd = require( './../../../base/fillednd' ); -import filledndBy = require( './../../../base/fillednd-by' ); -import filter = require( './../../../base/filter' ); -import first = require( './../../../base/first' ); -import flatten = require( './../../../base/flatten' ); -import flattenBy = require( './../../../base/flatten-by' ); -import flatten2d = require( './../../../base/flatten2d' ); -import flatten2dBy = require( './../../../base/flatten2d-by' ); -import flatten3d = require( './../../../base/flatten3d' ); -import flatten3dBy = require( './../../../base/flatten3d-by' ); -import flatten4d = require( './../../../base/flatten4d' ); -import flatten4dBy = require( './../../../base/flatten4d-by' ); -import flatten5d = require( './../../../base/flatten5d' ); -import flatten5dBy = require( './../../../base/flatten5d-by' ); -import fliplr2d = require( './../../../base/fliplr2d' ); -import fliplr3d = require( './../../../base/fliplr3d' ); -import fliplr4d = require( './../../../base/fliplr4d' ); -import fliplr5d = require( './../../../base/fliplr5d' ); -import flipud2d = require( './../../../base/flipud2d' ); -import flipud3d = require( './../../../base/flipud3d' ); -import flipud4d = require( './../../../base/flipud4d' ); -import flipud5d = require( './../../../base/flipud5d' ); -import strided2array = require( './../../../base/from-strided' ); -import getter = require( './../../../base/getter' ); -import groupEntries = require( './../../../base/group-entries' ); -import groupEntriesBy = require( './../../../base/group-entries-by' ); -import groupIndices = require( './../../../base/group-indices' ); -import groupIndicesBy = require( './../../../base/group-indices-by' ); -import groupValues = require( './../../../base/group-values' ); -import groupValuesBy = require( './../../../base/group-values-by' ); -import incrspace = require( './../../../base/incrspace' ); -import indexOf = require( './../../../base/index-of' ); -import indexOfSameValue = require( './../../../base/index-of-same-value' ); -import indicesComplement = require( './../../../base/indices-complement' ); -import join = require( './../../../base/join' ); -import last = require( './../../../base/last' ); -import lastIndexOf = require( './../../../base/last-index-of' ); -import lastIndexOfSameValue = require( './../../../base/last-index-of-same-value' ); -import linspace = require( './../../../base/linspace' ); -import logspace = require( './../../../base/logspace' ); -import map2d = require( './../../../base/map2d' ); -import map3d = require( './../../../base/map3d' ); -import map4d = require( './../../../base/map4d' ); -import map5d = require( './../../../base/map5d' ); -import minSignedIntegerDataType = require( './../../../base/min-signed-integer-dtype' ); -import minUnsignedIntegerDataType = require( './../../../base/min-unsigned-integer-dtype' ); -import mskbinary2d = require( './../../../base/mskbinary2d' ); -import mskbinary3d = require( './../../../base/mskbinary3d' ); -import mskbinary4d = require( './../../../base/mskbinary4d' ); -import mskbinary5d = require( './../../../base/mskbinary5d' ); -import mskfilter = require( './../../../base/mskfilter' ); -import mskfilterMap = require( './../../../base/mskfilter-map' ); -import mskfilter2 = require( './../../../base/mskfilter2' ); -import mskfiltern = require( './../../../base/mskfiltern' ); -import mskput = require( './../../../base/mskput' ); -import mskreject = require( './../../../base/mskreject' ); -import mskunary2d = require( './../../../base/mskunary2d' ); -import mskunary3d = require( './../../../base/mskunary3d' ); -import mskunary4d = require( './../../../base/mskunary4d' ); -import mskunary5d = require( './../../../base/mskunary5d' ); -import nCartesianProduct = require( './../../../base/n-cartesian-product' ); -import none = require( './../../../base/none' ); -import noneBy = require( './../../../base/none-by' ); -import noneByRight = require( './../../../base/none-by-right' ); -import nulls = require( './../../../base/nulls' ); -import oneTo = require( './../../../base/one-to' ); -import ones = require( './../../../base/ones' ); -import ones2d = require( './../../../base/ones2d' ); -import ones3d = require( './../../../base/ones3d' ); -import ones4d = require( './../../../base/ones4d' ); -import ones5d = require( './../../../base/ones5d' ); -import onesnd = require( './../../../base/onesnd' ); -import place = require( './../../../base/place' ); -import put = require( './../../../base/put' ); -import quaternary2d = require( './../../../base/quaternary2d' ); -import quaternary3d = require( './../../../base/quaternary3d' ); -import quaternary4d = require( './../../../base/quaternary4d' ); -import quaternary5d = require( './../../../base/quaternary5d' ); -import quinary2d = require( './../../../base/quinary2d' ); -import quinary3d = require( './../../../base/quinary3d' ); -import quinary4d = require( './../../../base/quinary4d' ); -import quinary5d = require( './../../../base/quinary5d' ); -import reject = require( './../../../base/reject' ); -import removeAt = require( './../../../base/remove-at' ); -import resolveGetter = require( './../../../base/resolve-getter' ); -import resolveSetter = require( './../../../base/resolve-setter' ); -import reverse = require( './../../../base/reverse' ); -import scatterFilled = require( './../../../base/scatter-filled' ); -import scattered = require( './../../../base/scattered' ); -import setter = require( './../../../base/setter' ); -import slice = require( './../../../base/slice' ); -import strided2array2d = require( './../../../base/strided2array2d' ); -import strided2array3d = require( './../../../base/strided2array3d' ); -import strided2array4d = require( './../../../base/strided2array4d' ); -import strided2array5d = require( './../../../base/strided2array5d' ); -import take = require( './../../../base/take' ); -import takeIndexed = require( './../../../base/take-indexed' ); -import takeIndexed2 = require( './../../../base/take-indexed2' ); -import take2d = require( './../../../base/take2d' ); -import take3d = require( './../../../base/take3d' ); -import ternary2d = require( './../../../base/ternary2d' ); -import ternary3d = require( './../../../base/ternary3d' ); -import ternary4d = require( './../../../base/ternary4d' ); -import ternary5d = require( './../../../base/ternary5d' ); -import toAccessorArray = require( './../../../base/to-accessor-array' ); -import toDeduped = require( './../../../base/to-deduped' ); -import toReversed = require( './../../../base/to-reversed' ); -import unary2d = require( './../../../base/unary2d' ); -import unary2dBy = require( './../../../base/unary2d-by' ); -import unary3d = require( './../../../base/unary3d' ); -import unary3dBy = require( './../../../base/unary3d-by' ); -import unary4d = require( './../../../base/unary4d' ); -import unary4dBy = require( './../../../base/unary4d-by' ); -import unary5d = require( './../../../base/unary5d' ); -import unary5dBy = require( './../../../base/unary5d-by' ); -import unarynd = require( './../../../base/unarynd' ); -import unitspace = require( './../../../base/unitspace' ); -import where = require( './../../../base/where' ); -import arrayWith = require( './../../../base/with' ); -import without = require( './../../../base/without' ); -import zeroTo = require( './../../../base/zero-to' ); -import zeros = require( './../../../base/zeros' ); -import zeros2d = require( './../../../base/zeros2d' ); -import zeros3d = require( './../../../base/zeros3d' ); -import zeros4d = require( './../../../base/zeros4d' ); -import zeros5d = require( './../../../base/zeros5d' ); -import zerosnd = require( './../../../base/zerosnd' ); - -/** -* Interface describing the `base` namespace. -*/ -interface Namespace { - /** - * Accessor array constructor. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = new ns.AccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - */ - AccessorArray: typeof AccessorArray; - - /** - * Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol. - * - * @param dtype - data type - * @returns accessor function - * - * @example - * var arr = [ 1, 2, 3, 4 ]; - * - * function aget( idx ) { - * return arr[ idx ]; - * } - * - * function aset( value, idx ) { - * arr[ idx ] = value; - * } - * - * arr.get = aget; - * arr.set = aset; - * - * var get = ns.accessorGetter( 'foo' ); - * var v = get( arr, 2 ); - * // returns 3 - */ - accessorGetter: typeof accessorGetter; - - /** - * Returns an accessor function for setting an element in an array-like object supporting the get/set protocol. - * - * @param dtype - data type - * @returns accessor function - * - * @example - * var arr = [ 1, 2, 3, 4 ]; - * - * function aget( idx ) { - * return arr[ idx ]; - * } - * - * function aset( value, idx ) { - * arr[ idx ] = value; - * } - * - * arr.get = aget; - * arr.set = aset; - * - * var set = ns.accessorSetter( 'foo' ); - * set( arr, 2, 10 ); - * - * var v = arr.get( 2 ); - * // returns 3 - */ - accessorSetter: typeof accessorSetter; - - /** - * Returns element accessors for a provided array-like object. - * - * ## Notes - * - * - The intent of this function is to provide a minimal abstraction over how elements are accessed when operating on indexed (i.e., array-like objects supporting element accesss via integer indices using bracket `[]` syntax) and accessor (i.e., array-like objects supporting the get/set protocol in which explicit `get` and `set` methods are used for element access) array-like objects. - * - * @param x - input array - * @returns object containing accessor data - * - * @example - * var x = { - * '0': 1, - * '1': 2, - * '2': 3, - * '4': 4, - * 'length': 4 - * }; - * var obj = ns.accessors( x ); - * // returns {...} - * - * var bool = obj.accessorProtocol; - * // returns false - * - * var fcns = obj.ns.accessors; - * // returns [ , ] - * - * var v = fcns[ 0 ]( x, 2 ); - * // returns 3 - */ - accessors: typeof accessors; - - /** - * Tests whether at least one element in an array is truthy. - * - * ## Notes - * - * - The function immediately returns upon encountering a truthy value. - * - If provided an empty collection, the function returns `false`. - * - * @param x - input array - * @returns boolean indicating whether at least one element is truthy - * - * @example - * var x = [ 0, 0, 1, 0 ]; - * - * var out = ns.any( x ); - * // returns true - */ - any: typeof any; - - /** - * Tests whether at least one element in an array passes a test implemented by a predicate function. - * - * ## Notes - * - * - The function immediately returns upon encountering a truthy return value. - * - If provided an empty collection, the function returns `false`. - * - * @param x - input array - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether all elements pass a test - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * - * var x = [ 0, 0, 1, 0 ]; - * - * var out = ns.anyBy( x, isPositive ); - * // returns true - */ - anyBy: typeof anyBy; - - /** - * Tests whether at least one element in an array passes a test implemented by a predicate function, while iterating from right to left. - * - * ## Notes - * - * - The function immediately returns upon encountering a truthy return value. - * - If provided an empty collection, the function returns `false`. - * - * @param x - input array - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether all elements pass a test - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * - * var x = [ 0, 0, 1, 0 ]; - * - * var out = ns.anyByRight( x, isPositive ); - * // returns true - */ - anyByRight: typeof anyByRight; - - /** - * Converts a one-dimensional array-like object to an object likely to have the same "shape". - * - * ## Notes - * - * - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". - * - * @param x - input array - * @returns object containing array data - * - * @example - * var x = { - * '0': 1, - * '1': 2, - * '2': 3, - * '4': 4, - * 'length': 4 - * }; - * var obj = ns.arraylike2object( x ); - * // returns {...} - * - * var bool = obj.accessorProtocol; - * // returns false - * - * var fcns = obj.accessors; - * // returns [ , ] - * - * var v = fcns[ 0 ]( x.data, 2 ); - * // returns 3 - */ - arraylike2object: typeof arraylike2object; - - /** - * Base array assertion utilities. - */ - assert: typeof assert; - - /** - * Returns an element from an array. - * - * @param x - input array - * @param index - element index - * @returns array element - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var v = ns.at( x, 0 ); - * // returns 1 - * - * v = ns.at( x, 1 ); - * // returns 2 - * - * v = ns.at( x, -2 ); - * // returns 3 - */ - at: typeof at; - - /** - * Returns an element from a two-dimensional nested array. - * - * @param x - input array - * @param i0 - first dimension index - * @param i1 - second dimension index - * @returns nested array element - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var v = ns.at2d( x, 0, 1 ); - * // returns 2 - * - * v = ns.at2d( x, 1, 0 ); - * // returns 3 - * - * v = ns.at2d( x, -2, -2 ); - * // returns 1 - */ - at2d: typeof at2d; - - /** - * Returns an element from a three-dimensional nested array. - * - * @param x - input array - * @param i0 - first dimension index - * @param i1 - second dimension index - * @param i2 - third dimension index - * @returns nested array element - * - * @example - * var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - * - * var v = ns.at3d( x, 0, 0, 1 ); - * // returns 2 - * - * v = ns.at3d( x, 0, 1, 0 ); - * // returns 3 - * - * v = ns.at3d( x, -1, -2, -2 ); - * // returns 1 - */ - at3d: typeof at3d; - - /** - * Returns an element from a four-dimensional nested array. - * - * @param x - input array - * @param i0 - first dimension index - * @param i1 - second dimension index - * @param i2 - third dimension index - * @param i3 - fourth dimension index - * @returns nested array element - * - * @example - * var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - * - * var v = ns.at4d( x, 0, 0, 0, 1 ); - * // returns 2 - * - * v = ns.at4d( x, 0, 0, 1, 0 ); - * // returns 3 - * - * v = ns.at4d( x, -1, -1, -2, -2 ); - * // returns 1 - */ - at4d: typeof at4d; - - /** - * Returns an element from a five-dimensional nested array. - * - * @param x - input array - * @param i0 - first dimension index - * @param i1 - second dimension index - * @param i2 - third dimension index - * @param i3 - fourth dimension index - * @param i4 - fifth dimension index - * @returns nested array element - * - * @example - * var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - * - * var v = ns.at5d( x, 0, 0, 0, 0, 1 ); - * // returns 2 - * - * v = ns.at5d( x, 0, 0, 0, 1, 0 ); - * // returns 3 - * - * v = ns.at5d( x, -1, -1, -1, -2, -2 ); - * // returns 1 - */ - at5d: typeof at5d; - - /** - * Returns an element from an n-dimensional nested array. - * - * @param x - input array - * @param i0 - first dimension index - * @param indices - dimension indices - * @returns nested array element - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var v = ns.atnd( x, 0, 1 ); - * // returns 2 - * - * v = ns.atnd( x, 1, 0 ); - * // returns 3 - * - * v = ns.atnd( x, -2, -2 ); - * // returns 1 - */ - atnd: typeof atnd; - - /** - * Splits array element entries into two groups. - * - * @param x - input array - * @param filter - array indicating which group an element in the input array belongs to - * @returns results - * - * @example - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * var filter = [ true, true, false, true ]; - * - * var out = ns.bifurcateEntries( arr, filter ); - * // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] - */ - bifurcateEntries: typeof bifurcateEntries; - - /** - * Splits element entries into two groups according to a predicate function. - * - * ## Notes - * - * - If a predicate function returns a truthy value, an array value is placed in the first group; otherwise, an array value is placed in the second group. - * - * @param x - input array - * @param predicate - predicate function specifying which group an element in the input array belongs to - * @param thisArg - predicate function execution context - * @returns group results - * - * @example - * function predicate( v ) { - * return v[ 0 ] === 'b'; - * } - * - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * - * var out = ns.bifurcateEntriesBy( x, predicate ); - * // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ] - */ - bifurcateEntriesBy: typeof bifurcateEntriesBy; - - /** - * Splits array element indices into two groups. - * - * @param x - input array - * @param filter - array indicating which group an element in the input array belongs to - * @returns results - * - * @example - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * var filter = [ true, true, false, true ]; - * - * var out = ns.bifurcateIndices( arr, filter ); - * // returns [ [ 0, 1, 3 ], [ 2 ] ] - */ - bifurcateIndices: typeof bifurcateIndices; - - /** - * Splits element indices into two groups according to a predicate function. - * - * ## Notes - * - * - If a predicate function returns a truthy value, an array value is placed in the first group; otherwise, an array value is placed in the second group. - * - * @param x - input array - * @param predicate - predicate function specifying which group an element in the input array belongs to - * @param thisArg - predicate function execution context - * @returns group results - * - * @example - * function predicate( v ) { - * return v[ 0 ] === 'b'; - * } - * - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * - * var out = ns.bifurcateIndicesBy( x, predicate ); - * // returns [ [ 0, 1, 3 ], [ 2 ] ] - */ - bifurcateIndicesBy: typeof bifurcateIndicesBy; - - /** - * Splits array element values into two groups. - * - * @param x - input array - * @param filter - array indicating which group an element in the input array belongs to - * @returns results - * - * @example - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * var filter = [ true, true, false, true ]; - * - * var out = ns.bifurcateValues( arr, filter ); - * // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] - */ - bifurcateValues: typeof bifurcateValues; - - /** - * Splits element values into two groups according to a predicate function. - * - * ## Notes - * - * - If a predicate function returns a truthy value, an array value is placed in the first group; otherwise, an array value is placed in the second group. - * - * @param x - input array - * @param predicate - predicate function specifying which group an element in the input array belongs to - * @param thisArg - predicate function execution context - * @returns group results - * - * @example - * function predicate( v ) { - * return v[ 0 ] === 'b'; - * } - * - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * - * var out = ns.bifurcateValuesBy( x, predicate ); - * // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ] - */ - bifurcateValuesBy: typeof bifurcateValuesBy; - - /** - * Applies a binary callback to elements in two two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing two input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - binary callback - * - * @example - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = ones2d( shape ); - * var z = zeros2d( shape ); - * - * ns.binary2d( [ x, y, z ], shape, add ); - * - * console.log( z ); - * // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] - */ - binary2d: typeof binary2d; - - /** - * Applies a binary callback to elements in two three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing two input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - binary callback - * - * @example - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shape = [ 2, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = ones3d( shape ); - * var z = zeros3d( shape ); - * - * ns.binary3d( [ x, y, z ], shape, add ); - * - * console.log( z ); - * // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] - */ - binary3d: typeof binary3d; - - /** - * Applies a binary callback to elements in two four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing two input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - binary callback - * - * @example - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shape = [ 1, 2, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = ones4d( shape ); - * var z = zeros4d( shape ); - * - * ns.binary4d( [ x, y, z ], shape, add ); - * - * console.log( z ); - * // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] - */ - binary4d: typeof binary4d; - - /** - * Applies a binary callback to elements in two five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing two input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - binary callback - * - * @example - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shape = [ 1, 1, 2, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = ones5d( shape ); - * var z = zeros5d( shape ); - * - * ns.binary5d( [ x, y, z ], shape, add ); - * - * console.log( z ); - * // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] - */ - binary5d: typeof binary5d; - - /** - * Applies a binary callback to elements in two n-dimensional nested input arrays and assigns results to elements in an n-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing two input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - binary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add' ); - * var onesnd = require( './../../../base/onesnd' ); - * var zerosnd = require( './../../../base/zerosnd' ); - * - * var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; - * - * var x = onesnd( shape ); - * var y = onesnd( shape ); - * var z = zerosnd( shape ); - * - * ns.binarynd( [ x, y, z ], shape, add ); - * - * console.log( z ); - * // => [ [ [ [ [ [ [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] ] ] ] ] ] ] - */ - binarynd: typeof binarynd; - - /** - * Broadcasts an array to a specified shape. - * - * ## Notes - * - * - The broadcasted array shares the same data as the input array. As more than one element of a broadcasted array may refer to the same memory location, writing to the broadcasted array may affect multiple elements. If you need to write to the broadcasted array, copy the array before performing operations which may mutate elements. - * - The function throws an error if a provided input shape is incompatible with a provided output shape. - * - * @param x - input array - * @param inShape - input array shape - * @param outShape - output array shape - * @throws input array cannot have more dimensions than the desired shape - * @throws input array dimension sizes must be `1` or equal to the corresponding dimension in the provided output shape - * @returns broadcast object - * - * @example - * var x = [ 1, 2 ]; - * - * var out = ns.broadcastArray( x, [ 2 ], [ 2, 2 ] ); - * // returns {...} - * - * var shape = out.shape; - * // returns [ 2, 2 ] - * - * var strides = out.strides; - * // returns [ 0, 1 ] - * - * var ref = out.ref; - * // returns [ 1, 2 ] - * - * var bool = ( x === ref ); - * // returns true - * - * var data = out.data; - * // returns [ [ 1, 2 ] ] - * - * @example - * var x = [ 1, 2 ]; - * - * var out = ns.broadcastArray( x, [ 2 ], [ 2, 1, 2 ] ); - * // returns {...} - * - * var data = out.data; - * // returns [ [ [ 1, 2 ] ] ] - * - * var strides = out.strides; - * // returns [ 0, 0, 1 ] - * - * @example - * var x = [ [ 1 ], [ 2 ] ]; - * - * var out = ns.broadcastArray( x, [ 2, 1 ], [ 3, 2, 2 ] ); - * // returns {...} - * - * var data = out.data; - * // returns [ [ [ 1 ], [ 2 ] ] ] - * - * var strides = out.strides; - * // returns [ 0, 1, 0 ] - */ - broadcastArray: typeof broadcastArray; - - /** - * Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing two input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - binary callback - * - * @example - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shapes = [ - * [ 1, 2 ], - * [ 2, 1 ], - * [ 2, 2 ] - * ]; - * - * var x = ones2d( shapes[ 0 ] ); - * var y = ones2d( shapes[ 1 ] ); - * var z = zeros2d( shapes[ 2 ] ); - * - * ns.bbinary2d( [ x, y, z ], shapes, add ); - * - * console.log( z ); - * // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] - */ - bbinary2d: typeof bbinary2d; - - /** - * Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing two input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - binary callback - * - * @example - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shapes = [ - * [ 1, 1, 2 ], - * [ 2, 1, 1 ], - * [ 2, 2, 2 ] - * ]; - * - * var x = ones3d( shapes[ 0 ] ); - * var y = ones3d( shapes[ 1 ] ); - * var z = zeros3d( shapes[ 2 ] ); - * - * ns.bbinary3d( [ x, y, z ], shapes, add ); - * - * console.log( z ); - * // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] - */ - bbinary3d: typeof bbinary3d; - - /** - * Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing two input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - binary callback - * - * @example - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shapes = [ - * [ 1, 1, 1, 2 ], - * [ 1, 2, 1, 1 ], - * [ 1, 2, 2, 2 ] - * ]; - * - * var x = ones4d( shapes[ 0 ] ); - * var y = ones4d( shapes[ 1 ] ); - * var z = zeros4d( shapes[ 2 ] ); - * - * ns.bbinary4d( [ x, y, z ], shapes, add ); - * - * console.log( z ); - * // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] - */ - bbinary4d: typeof bbinary4d; - - /** - * Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing two input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - binary callback - * - * @example - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shapes = [ - * [ 1, 1, 1, 1, 2 ], - * [ 1, 1, 2, 1, 1 ], - * [ 1, 1, 2, 2, 2 ] - * ]; - * - * var x = ones5d( shapes[ 0 ] ); - * var y = ones5d( shapes[ 1 ] ); - * var z = zeros5d( shapes[ 2 ] ); - * - * ns.bbinary5d( [ x, y, z ], shapes, add ); - * - * console.log( z ); - * // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ] - */ - bbinary5d: typeof bbinary5d; - - /** - * Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing four input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - quaternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add4' ); - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * - * var shapes = [ - * [ 1, 2 ], - * [ 2, 1 ], - * [ 1, 1 ], - * [ 2, 2 ], - * [ 2, 2 ] - * ]; - * - * var x = ones2d( shapes[ 0 ] ); - * var y = ones2d( shapes[ 1 ] ); - * var z = ones2d( shapes[ 2 ] ); - * var w = ones2d( shapes[ 3 ] ); - * var out = zeros2d( shapes[ 4 ] ); - * - * ns.bquaternary2d( [ x, y, z, w, out ], shapes, add ); - * - * console.log( out ); - * // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] - */ - bquaternary2d: typeof bquaternary2d; - - /** - * Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing four input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - quaternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add4' ); - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * - * var shapes = [ - * [ 1, 1, 3 ], - * [ 3, 1, 1 ], - * [ 1, 3, 1 ], - * [ 3, 3, 3 ], - * [ 3, 3, 3 ] - * ]; - * - * var x = ones3d( shapes[ 0 ] ); - * var y = ones3d( shapes[ 1 ] ); - * var z = ones3d( shapes[ 2 ] ); - * var w = ones3d( shapes[ 3 ] ); - * var out = zeros3d( shapes[ 4 ] ); - * - * ns.bquaternary3d( [ x, y, z, w, out ], shapes, add ); - * - * console.log( out ); - * // => [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] - */ - bquaternary3d: typeof bquaternary3d; - - /** - * Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing four input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - quaternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add4' ); - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * - * var shapes = [ - * [ 1, 3, 1, 1 ], - * [ 1, 1, 3, 1 ], - * [ 1, 1, 1, 3 ], - * [ 1, 1, 1, 1 ], - * [ 1, 3, 3, 3 ] - * ]; - * - * var x = ones4d( shapes[ 0 ] ); - * var y = ones4d( shapes[ 1 ] ); - * var z = ones4d( shapes[ 2 ] ); - * var w = ones4d( shapes[ 3 ] ); - * var out = zeros4d( shapes[ 4 ] ); - * - * ns.bquaternary4d( [ x, y, z, w, out ], shapes, add ); - * - * console.log( out ); - * // => [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ] - */ - bquaternary4d: typeof bquaternary4d; - - /** - * Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing four input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - quaternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add4' ); - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * - * var shapes = [ - * [ 1, 1, 3, 1, 1 ], - * [ 1, 1, 1, 3, 1 ], - * [ 1, 1, 1, 1, 3 ], - * [ 1, 1, 1, 1, 1 ], - * [ 1, 1, 3, 3, 3 ] - * ]; - * - * var x = ones5d( shapes[ 0 ] ); - * var y = ones5d( shapes[ 1 ] ); - * var z = ones5d( shapes[ 2 ] ); - * var w = ones5d( shapes[ 3 ] ); - * var out = zeros5d( shapes[ 4 ] ); - * - * ns.bquaternary5d( [ x, y, z, w, out ], shapes, add ); - * - * console.log( out ); - * // => [ [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ] ] - */ - bquaternary5d: typeof bquaternary5d; - - /** - * Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing five input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - quinary callback - * - * @example - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * - * function add( x, y, z, w, v ) { - * return x + y + z + w + v; - * } - * - * var shapes = [ - * [ 1, 2 ], - * [ 2, 1 ], - * [ 1, 1 ], - * [ 2, 2 ], - * [ 1, 1 ], - * [ 2, 2 ] - * ]; - * - * var x = ones2d( shapes[ 0 ] ); - * var y = ones2d( shapes[ 1 ] ); - * var z = ones2d( shapes[ 2 ] ); - * var w = ones2d( shapes[ 3 ] ); - * var v = ones2d( shapes[ 4 ] ); - * var out = zeros2d( shapes[ 5 ] ); - * - * ns.bquinary2d( [ x, y, z, w, v, out ], shapes, add ); - * - * console.log( out ); - * // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] - */ - bquinary2d: typeof bquinary2d; - - /** - * Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing five input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - quinary callback - * - * @example - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * - * function add( x, y, z, w, v ) { - * return x + y + z + w + v; - * } - * - * var shapes = [ - * [ 1, 1, 1, 2 ], - * [ 1, 1, 2, 1 ], - * [ 1, 1, 2, 2 ], - * [ 1, 2, 1, 1 ], - * [ 2, 2, 2, 2 ], - * [ 2, 2, 2, 2 ] - * ]; - * - * var x = ones4d( shapes[ 0 ] ); - * var y = ones4d( shapes[ 1 ] ); - * var z = ones4d( shapes[ 2 ] ); - * var w = ones4d( shapes[ 3 ] ); - * var v = ones4d( shapes[ 4 ] ); - * var out = zeros4d( shapes[ 5 ] ); - * - * ns.bquinary4d( [ x, y, z, w, v, out ], shapes, add ); - * - * console.log( out ); - * // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ], [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] - */ - bquinary4d: typeof bquinary4d; - - /** - * Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing three input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - ternary callback - * - * @example - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * var add = require( '@stdlib/number/float64/base/add3' ); - * - * var shapes = [ - * [ 1, 2 ], - * [ 2, 1 ], - * [ 1, 1 ], - * [ 2, 2 ] - * ]; - * - * var x = ones2d( shapes[ 0 ] ); - * var y = ones2d( shapes[ 1 ] ); - * var z = ones2d( shapes[ 2 ] ); - * var out = zeros2d( shapes[ 3 ] ); - * - * ns.bternary2d( [ x, y, z, out ], shapes, add ); - * - * console.log( out ); - * // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] - */ - bternary2d: typeof bternary2d; - - /** - * Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing three input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - ternary callback - * - * @example - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * var add = require( '@stdlib/number/float64/base/add3' ); - * - * var shapes = [ - * [ 1, 2, 1 ], - * [ 2, 1, 1 ], - * [ 1, 1, 2 ], - * [ 2, 2, 2 ] - * ]; - * - * var x = ones3d( shapes[ 0 ] ); - * var y = ones3d( shapes[ 1 ] ); - * var z = ones3d( shapes[ 2 ] ); - * var out = zeros3d( shapes[ 3 ] ); - * - * ns.bternary3d( [ x, y, z, out ], shapes, add ); - * - * console.log( out ); - * // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] - */ - bternary3d: typeof bternary3d; - - /** - * Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing three input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - ternary callback - * - * @example - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * var add = require( '@stdlib/number/float64/base/add3' ); - * - * var shapes = [ - * [ 1, 2, 1, 1 ], - * [ 2, 1, 1, 1 ], - * [ 1, 1, 2, 1 ], - * [ 2, 2, 2, 2 ] - * ]; - * - * var x = ones4d( shapes[ 0 ] ); - * var y = ones4d( shapes[ 1 ] ); - * var z = ones4d( shapes[ 2 ] ); - * var out = zeros4d( shapes[ 3 ] ); - * - * ns.bternary4d( [ x, y, z, out ], shapes, add ); - * - * console.log( out ); - * // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] - */ - bternary4d: typeof bternary4d; - - /** - * Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The input array shapes must be broadcast compatible with the output array shape. - * - * @param arrays - array containing three input nested arrays and one output nested array - * @param shapes - array shapes - * @param fcn - ternary callback - * - * @example - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * var add = require( '@stdlib/number/float64/base/add3' ); - * var ns.bternary5d = require( './../../../base/broadcasted-ternary5d' ); - * var shapes = [ - * [ 1, 2, 1, 1, 1 ], - * [ 2, 1, 1, 1, 1 ], - * [ 1, 1, 1, 1, 1 ], - * [ 2, 2, 1, 1, 1 ] - * ]; - * - * var x = ones5d( shapes[ 0 ] ); - * var y = ones5d( shapes[ 1 ] ); - * var z = ones5d( shapes[ 2 ] ); - * var out = zeros5d( shapes[ 3 ] ); - * - * ns.bternary5d( [ x, y, z, out ], shapes, add ); - * - * console.log( out ); - * // => [ [ [ [ [ 3 ] ] ], [ [ [ 3 ] ] ] ], [ [ [ 3 ] ] ], [ [ [ 3 ] ] ] ] ] - */ - bternary5d: typeof bternary5d; - - /** - * Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The input array shape must be broadcast compatible with the output array shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shapes - array shapes - * @param fcn - unary callback - * - * @example - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shapes = [ - * [ 1, 2 ], - * [ 2, 2 ] - * ]; - * - * var x = ones2d( shapes[ 0 ] ); - * var y = zeros2d( shapes[ 1 ] ); - * - * ns.bunary2d( [ x, y ], shapes, scale ); - * - * console.log( y ); - * // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] - */ - bunary2d: typeof bunary2d; - - /** - * Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The input array shape must be broadcast compatible with the output array shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shapes - array shapes - * @param fcn - unary callback - * - * @example - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shapes = [ - * [ 1, 1, 2 ], - * [ 1, 2, 2 ] - * ]; - * - * var x = ones3d( shapes[ 0 ] ); - * var y = zeros3d( shapes[ 1 ] ); - * - * ns.bunary3d( [ x, y ], shapes, scale ); - * - * console.log( y ); - * // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] - */ - bunary3d: typeof bunary3d; - - /** - * Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The input array shape must be broadcast compatible with the output array shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shapes - array shapes - * @param fcn - unary callback - * - * @example - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shapes = [ - * [ 1, 1, 1, 2 ], - * [ 1, 1, 2, 2 ] - * ]; - * - * var x = ones4d( shapes[ 0 ] ); - * var y = zeros4d( shapes[ 1 ] ); - * - * ns.bunary4d( [ x, y ], shapes, scale ); - * - * console.log( y ); - * // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - bunary4d: typeof bunary4d; - - /** - * Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The input array shape must be broadcast compatible with the output array shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shapes - array shapes - * @param fcn - unary callback - * - * @example - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shapes = [ - * [ 1, 1, 1, 1, 2 ], - * [ 1, 1, 1, 2, 2 ] - * ]; - * - * var x = ones5d( shapes[ 0 ] ); - * var y = zeros5d( shapes[ 1 ] ); - * - * ns.bunary5d( [ x, y ], shapes, scale ); - * - * console.log( y ); - * // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] - */ - bunary5d: typeof bunary5d; - - /** - * Returns the Cartesian power. - * - * ## Notes - * - * - If provided an empty array, the function returns an empty array. - * - If `n` is less than or equal to zero, the function returns an empty array. - * - * @param x - input array - * @param n - power - * @returns Cartesian product - * - * @example - * var x = [ 1, 2 ]; - * - * var out = ns.cartesianPower( x, 2 ); - * // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] - */ - cartesianPower: typeof cartesianPower; - - /** - * Returns the Cartesian product. - * - * ## Notes - * - * - If provided one or more empty arrays, the function returns an empty array. - * - * @param x1 - first input array - * @param x2 - second input array - * @returns Cartesian product - * - * @example - * var x1 = [ 1, 2, 3 ]; - * var x2 = [ 4, 5 ]; - * - * var out = ns.cartesianProduct( x1, x2 ); - * // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] - */ - cartesianProduct: typeof cartesianProduct; - - /** - * Returns the Cartesian square. - * - * ## Notes - * - * - If provided an empty array, the function returns an empty array. - * - * @param x - input array - * @returns Cartesian product - * - * @example - * var x = [ 1, 2 ]; - * - * var out = ns.cartesianSquare( x ); - * // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] - */ - cartesianSquare: typeof cartesianSquare; - - /** - * Copies the elements of an array-like object to a new "generic" array. - * - * @param x - input array - * @returns output array - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = ns.copy( x ); - * // returns [ 1, 2, 3 ] - */ - copy: typeof copy; - - /** - * Copies the elements of an indexed array-like object to a new "generic" array. - * - * @param x - input array - * @returns output array - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = ns.copyIndexed( x ); - * // returns [ 1, 2, 3 ] - */ - copyIndexed: typeof copyIndexed; - - /** - * Counts the number of falsy values in an array. - * - * @param x - input array - * @returns number of falsy values - * - * @example - * var x = [ 0, 1, 0, 1, 1 ]; - * - * var out = ns.countFalsy( x ); - * // returns 2 - */ - countFalsy: typeof countFalsy; - - /** - * Counts the number of elements in an array which pass a test implemented by a predicate function. - * - * @param x - input array - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns result - * - * @example - * function predicate( v ) { - * return v > 0; - * } - * - * var x = [ 0, 1, 0, 1, 1 ]; - * - * var n = ns.countIf( x, predicate ); - * // returns 3 - */ - countIf: typeof countIf; - - /** - * Counts the number of elements in an array that are equal to a specified value. - * - * ## Notes - * - * - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. - * - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. - * - * [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 - * - * @param x - input array - * @param value - search value - * @returns number of elements that are equal to a specified value - * - * @example - * var x = [ 0, 1, 0, 1, 1 ]; - * - * var out = ns.countSameValue( x, 1 ); - * // returns 3 - */ - countSameValue: typeof countSameValue; - - /** - * Counts the number of elements in an array that are equal to a specified value. - * - * ## Notes - * - * - In contrast to an implementation based on the strict equality operator `===`, the function treats `NaNs` as the same value. - * - * @param x - input array - * @param value - search value - * @returns number of elements that are equal to a specified value - * - * @example - * var x = [ 0, 1, 0, 1, 1 ]; - * - * var out = ns.countSameValueZero( x, 1 ); - * // returns 3 - */ - countSameValueZero: typeof countSameValueZero; - - /** - * Counts the number of truthy values in an array. - * - * @param x - input array - * @returns number of truthy values - * - * @example - * var x = [ 0, 1, 0, 1, 1 ]; - * - * var out = ns.countTruthy( x ); - * // returns 3 - */ - countTruthy: typeof countTruthy; - - /** - * Cumulatively tests whether at least one element in a provided array is truthy. - * - * @param x - input array - * @returns output array - * - * @example - * var x = [ false, false, true, false, false ]; - * - * var result = ns.cuany( x ); - * // returns [ false, false, true, true, true ] - * - * @example - * var x = [ false, false, true, false, false ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = ns.cuany.assign( x, y, 2, 0 ); - * // returns [ false, null, false, null, true, null, true, null, true, null ] - */ - cuany: typeof cuany; - - /** - * Cumulatively tests whether every element in a provided array is truthy. - * - * @param x - input array - * @returns output array - * - * @example - * var x = [ true, true, true, false, true ]; - * - * var result = ns.cuevery( x ); - * // returns [ true, true, true, false, false ]; - * - * @example - * var x = [ true, true, true, false, true ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = ns.cuevery.assign( x, y, 2, 0 ); - * // returns [ true, null, true, null, true, null, false, null, false, null ]; - */ - cuevery: typeof cuevery; - - /** - * Cumulatively tests whether every element in a provided array is falsy. - * - * @param x - input array - * @returns output array - * - * @example - * var x = [ false, false, false, true, false ]; - * - * var result = ns.cunone( x ); - * // returns [ true, true, true, false, false ]; - * - * @example - * var x = [ false, false, false, true, false ]; - * var y = [ false, null, false, null, false, null, false, null, false, null ]; - * - * var arr = ns.cunone.assign( x, y, 2, 0 ); - * // returns [ true, null, true, null, true, null, false, null, false, null ]; - */ - cunone: typeof cunone; - - /** - * Removes consecutive duplicated values. - * - * ## Notes - * - * - The function mutates the input array. - * - * @param x - input array - * @param limit - number of allowed consecutive duplicates - * @param equalNaNs - boolean indicating whether NaNs should be considered equal - * @returns input array - * - * @example - * var x = [ 1, 1, 2, 3, 3 ]; - * - * var y = ns.dedupe( x, 1, false ); - * // returns [ 1, 2, 3 ] - * - * var bool = ( x === y ); - * // returns true - * - * @example - * var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ]; - * - * var y = ns.dedupe( x, 2, false ); - * // returns [ 1, 1, 2, 1, 1, 3, 3 ] - * - * var bool = ( x === y ); - * // returns true - */ - dedupe: typeof dedupe; - - /** - * Tests whether all elements in an array are truthy. - * - * ## Notes - * - * - The function immediately returns upon encountering a non-truthy value. - * - If provided an empty collection, the function returns `true`. - * - * @param x - input array - * @returns boolean indicating whether all elements are truthy - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var out = ns.every( x ); - * // returns true - */ - every: typeof every; - - /** - * Tests whether all elements in an array pass a test implemented by a predicate function. - * - * ## Notes - * - * - The function immediately returns upon encountering a non-truthy return value. - * - If provided an empty collection, the function returns `true`. - * - * @param x - input array - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether all elements pass a test - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * - * var x = [ 1, 2, 3, 4 ]; - * - * var out = ns.everyBy( x, isPositive ); - * // returns true - */ - everyBy: typeof everyBy; - - /** - * Tests whether all elements in an array pass a test implemented by a predicate function, iterating from right to left. - * - * ## Notes - * - * - The function immediately returns upon encountering a non-truthy return value. - * - If provided an empty collection, the function returns `true`. - * - * @param x - input array - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether all elements pass a test - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * - * var x = [ 1, 2, 3, 4 ]; - * - * var out = ns.everyByRight( x, isPositive ); - * // returns true - */ - everyByRight: typeof everyByRight; - - /** - * Returns a shallow copy of a portion of an array. - * - * @param x - input array - * @param s - slice object - * @param strict - boolean indicating whether to enforce strict bounds checking - * @returns output array - * - * @example - * var Slice = require( '@stdlib/ns.fancySlice/ctor' ); - * - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var out = ns.fancySlice( x, new Slice( null, null, -1 ), false ); - * // returns [ 6, 5, 4, 3, 2, 1 ] - */ - fancySlice: typeof fancySlice; - - /** - * Assigns element values from a broadcasted input array to corresponding elements in an output array. - * - * ## Notes - * - * - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). - * - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). - * - * @param x - input array - * @param y - output array - * @param s - slice object - * @param strict - boolean indicating whether to enforce strict bounds checking - * @returns output array - * - * @example - * var Slice = require( '@stdlib/slice/ctor' ); - * - * var x = [ 1, 2, 3, 4 ]; - * var y = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - * - * var s = new Slice( null, null, 2 ); - * // returns - * - * var out = ns.fancySliceAssign( x, y, s, false ); - * // returns [ 1, 0, 2, 0, 3, 0, 4, 0 ] - * - * var bool = ( out === y ); - * // returns true - */ - fancySliceAssign: typeof fancySliceAssign; - - /** - * Fills all elements within a portion of an array with a specified value. - * - * @param x - input array - * @param value - fill value - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @returns modified input array - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = ns.fill( x, 4, 0, 3 ); - * // returns [ 4, 4, 4 ] - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var out = ns.fill( x, 8, 0, 3 ); - * // returns [ 8, 8, 8, 4, 5, 6 ] - */ - fill: typeof fill; - - /** - * Fills all elements within a portion of an array according to a provided callback function. - * - * @param x - input array - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @param fcn - callback function - * @param thisArg - callback function execution context - * @returns modified input array - * - * @example - * function fcn() { - * return 4; - * } - * - * var x = [ 1, 2, 3 ]; - * - * var out = ns.fillBy( x, 4, 0, 3 ); - * // returns [ 4, 4, 4 ] - * - * @example - * function fcn() { - * return 8; - * } - * - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var out = ns.fillBy( x, 8, 0, 3 ); - * // returns [ 8, 8, 8, 4, 5, 6 ] - */ - fillBy: typeof fillBy; - - /** - * Returns a filled "generic" array. - * - * @param value - fill value, - * @param len - array length - * @returns output array - * - * @example - * var out = ns.filled( 0.0, 3 ); - * // returns [ 0.0, 0.0, 0.0 ] - * - * @example - * var out = ns.filled( 'beep', 3 ); - * // returns [ 'beep', 'beep', 'beep' ] - */ - filled: typeof filled; - - /** - * Returns a filled "generic" array according to a provided callback function. - * - * @param len - array length - * @param clbk - callback function - * @param thisArg - callback function execution context - * @returns output array - * - * @example - * var constantFunction = require( '@stdlib/utils/constant-function' ); - * - * var arr = ns.filledBy( 5, constantFunction( 1.0 ) ); - * // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - */ - filledBy: typeof filledBy; - - /** - * Returns a filled two-dimensional nested array. - * - * @param value - fill value - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.filled2d( 0.0, [ 1, 3 ] ); - * // returns [ [ 0.0, 0.0, 0.0 ] ] - * - * @example - * var out = ns.filled2d( 'beep', [ 1, 3 ] ); - * // returns [ [ 'beep', 'beep', 'beep' ] ] - */ - filled2d: typeof filled2d; - - /** - * Returns a filled two-dimensional nested array according to a provided callback function. - * - * @param shape - array shape - * @param clbk - callback function - * @param thisArg - callback function execution context - * @returns output array - * - * @example - * var constantFunction = require( '@stdlib/utils/constant-function' ); - * - * var arr = ns.filled2dBy( [ 1, 5 ], constantFunction( 1.0 ) ); - * // returns [ [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ] - */ - filled2dBy: typeof filled2dBy; - - /** - * Returns a filled three-dimensional nested array. - * - * @param value - fill value - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.filled3d( 0.0, [ 1, 1, 3 ] ); - * // returns [ [ [ 0.0, 0.0, 0.0 ] ] ] - * - * @example - * var out = ns.filled3d( 'beep', [ 1, 1, 3 ] ); - * // returns [ [ [ 'beep', 'beep', 'beep' ] ] ] - */ - filled3d: typeof filled3d; - - /** - * Returns a filled three-dimensional nested array according to a provided callback function. - * - * @param shape - array shape - * @param clbk - callback function - * @param thisArg - callback function execution context - * @returns output array - * - * @example - * var constantFunction = require( '@stdlib/utils/constant-function' ); - * - * var arr = ns.filled3dBy( [ 1, 1, 5 ], constantFunction( 1.0 ) ); - * // returns [ [ [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ] ] - */ - filled3dBy: typeof filled3dBy; - - /** - * Returns a filled four-dimensional nested array. - * - * @param value - fill value - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.filled4d( 0.0, [ 1, 1, 1, 3 ] ); - * // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] - * - * @example - * var out = ns.filled4d( 'beep', [ 1, 1, 1, 3 ] ); - * // returns [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] - */ - filled4d: typeof filled4d; - - /** - * Returns a filled four-dimensional nested array according to a provided callback function. - * - * @param shape - array shape - * @param clbk - callback function - * @param thisArg - callback function execution context - * @returns output array - * - * @example - * var constantFunction = require( '@stdlib/utils/constant-function' ); - * - * var arr = ns.filled4dBy( [ 1, 1, 1, 5 ], constantFunction( 1.0 ) ); - * // returns [ [ [ [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ] ] ] - */ - filled4dBy: typeof filled4dBy; - - /** - * Returns a filled five-dimensional nested array. - * - * @param value - fill value - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.filled5d( 0.0, [ 1, 1, 1, 1, 3 ] ); - * // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] - * - * @example - * var out = ns.filled5d( 'beep', [ 1, 1, 1, 1, 3 ] ); - * // returns [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] - */ - filled5d: typeof filled5d; - - /** - * Returns a filled five-dimensional nested array according to a provided callback function. - * - * @param shape - array shape - * @param clbk - callback function - * @param thisArg - callback function execution context - * @returns output array - * - * @example - * var constantFunction = require( '@stdlib/utils/constant-function' ); - * - * var arr = ns.filled5dBy( [ 1, 1, 1, 1, 5 ], constantFunction( 1.0 ) ); - * // returns [ [ [ [ [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ] ] ] ] - */ - filled5dBy: typeof filled5dBy; - - /** - * Returns a filled n-dimensional nested array. - * - * @param value - fill value - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.fillednd( 0.0, [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); - * // returns [ [ [ [ [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] ] ] ] - * - * @example - * var out = ns.fillednd( 'beep', [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); - * // returns [ [ [ [ [ [ [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] ] ] ] ] ] - */ - fillednd: typeof fillednd; - - /** - * Creates a filled n-dimensional nested array according to a provided callback function. - * - * @param shape - array shape - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var constantFunction = require( '@stdlib/utils/constant-function' ); - * - * var out = ns.filledndBy( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ], constantFunction( 1.0 ) ); - * // returns [ [ [ [ [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] ] ] ] - */ - filledndBy: typeof filledndBy; - - /** - * Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. - * - * @param x - input array - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns output array - * - * @example - * var x = [ 1, -2, -3, 4 ]; - * - * var out = ns.filter( x, isPositiveNumber ); - * // returns [ 1, 4 ] - */ - filter: typeof filter; - - /** - * Returns the first element of an array-like object. - * - * @param arr - input array - * @returns first element - * - * @example - * var arr = [ 1, 2, 3 ]; - * - * var out = ns.first( x ); - * // returns 1 - */ - first: typeof first; - - /** - * Flattens an n-dimensional nested array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @returns flattened array - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = ns.flatten( x, [ 2, 2 ], false ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = ns.flatten( x, [ 2, 2 ], true ); - * // returns [ 1, 3, 2, 4 ] - */ - flatten: typeof flatten; - - /** - * Flattens an n-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = ns.flattenBy( x, [ 2, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = ns.flattenBy( x, [ 2, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - flattenBy: typeof flattenBy; - - /** - * Flattens a two-dimensional nested array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @returns flattened array - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = ns.flatten2d( x, [ 2, 2 ], false ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = ns.flatten2d( x, [ 2, 2 ], true ); - * // returns [ 1, 3, 2, 4 ] - */ - flatten2d: typeof flatten2d; - - /** - * Flattens a two-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = ns.flatten2dBy( x, [ 2, 2 ], false, scale ); - * // returns [ 2, 4, 6, 8 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = ns.flatten2dBy( x, [ 2, 2 ], true, scale ); - * // returns [ 2, 6, 4, 8 ] - */ - flatten2dBy: typeof flatten2dBy; - - /** - * Flattens a three-dimensional nested array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @returns flattened array - * - * @example - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * var out = ns.flatten3d( x, [ 2, 1, 2 ], false ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * var out = ns.flatten3d( x, [ 2, 1, 2 ], true ); - * // returns [ 1, 3, 2, 4 ] - */ - flatten3d: typeof flatten3d; - - /** - * Flattens a three-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * function scale( v ) { - * return v * 2; - * } - * - * var out = ns.flatten3dBy( x, [ 2, 1, 2 ], false, scale ); - * // returns [ 2, 4, 6, 8 ] - * - * @example - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * function scale( v ) { - * return v * 2; - * } - * - * var out = ns.flatten3dBy( x, [ 2, 1, 2 ], true, scale ); - * // returns [ 2, 6, 4, 8 ] - */ - flatten3dBy: typeof flatten3dBy; - - /** - * Flattens a four-dimensional nested array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @returns flattened array - * - * @example - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = ns.flatten4d( x, [ 2, 1, 1, 2 ], false ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = ns.flatten4d( x, [ 2, 1, 1, 2 ], true ); - * // returns [ 1, 3, 2, 4 ] - */ - flatten4d: typeof flatten4d; - - /** - * Flattens a four-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = ns.flatten4dBy( x, [ 2, 1, 1, 2 ], false, scale ); - * // returns [ 2, 4, 6, 8 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = ns.flatten4dBy( x, [ 2, 1, 1, 2 ], true, scale ); - * // returns [ 2, 6, 4, 8 ] - */ - flatten4dBy: typeof flatten4dBy; - - /** - * Flattens a five-dimensional nested array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @returns flattened array - * - * @example - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = ns.flatten5d( x, [ 2, 1, 1, 1, 2 ], false ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = ns.flatten5d( x, [ 2, 1, 1, 1, 2 ], true ); - * // returns [ 1, 3, 2, 4 ] - */ - flatten5d: typeof flatten5d; - - /** - * Flattens a five-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = ns.flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = ns.flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - flatten5dBy: typeof flatten5dBy; - - /** - * Reverses the order of elements along the last dimension of a two-dimensional nested input array. - * - * ## Notes - * - * - The function does **not** perform a deep copy of nested array elements. - * - * @param x - input nested array - * @returns output array - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; - * - * var out = ns.fliplr2d( x ); - * // returns [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] - */ - fliplr2d: typeof fliplr2d; - - /** - * Reverses the order of elements along the last dimension of a three-dimensional nested input array. - * - * ## Notes - * - * - The function does **not** perform a deep copy of nested array elements. - * - * @param x - input nested array - * @returns output array - * - * @example - * var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]; - * - * var out = ns.fliplr3d( x ); - * // returns [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] - */ - fliplr3d: typeof fliplr3d; - - /** - * Reverses the order of elements along the last dimension of a four-dimensional nested input array. - * - * ## Notes - * - * - The function does **not** perform a deep copy of nested array elements. - * - * @param x - input nested array - * @returns output array - * - * @example - * var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ]; - * - * var out = ns.fliplr4d( x ); - * // returns [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ] - */ - fliplr4d: typeof fliplr4d; - - /** - * Reverses the order of elements along the last dimension of a five-dimensional nested input array. - * - * ## Notes - * - * - The function does **not** perform a deep copy of nested array elements. - * - * @param x - input nested array - * @returns output array - * - * @example - * var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ]; - * - * var out = ns.fliplr5d( x ); - * // returns [ [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ] ] - */ - fliplr5d: typeof fliplr5d; - - /** - * Reverses the order of elements along the first dimension of a two-dimensional nested input array. - * - * ## Notes - * - * - The function does **not** perform a deep copy of nested array elements. - * - * @param x - input nested array - * @returns output array - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; - * - * var out = ns.flipud2d( x ); - * // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] - */ - flipud2d: typeof flipud2d; - - /** - * Reverses the order of elements along the second-to-last dimension of a three-dimensional nested input array. - * - * ## Notes - * - * - The function does **not** perform a deep copy of nested array elements. - * - * @param x - input nested array - * @returns output array - * - * @example - * var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]; - * - * var out = ns.flipud3d( x ); - * // returns [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] - */ - flipud3d: typeof flipud3d; - - /** - * Reverses the order of elements along the second-to-last dimension of a four-dimensional nested input array. - * - * ## Notes - * - * - The function does **not** perform a deep copy of nested array elements. - * - * @param x - input nested array - * @returns output array - * - * @example - * var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ]; - * - * var out = ns.flipud4d( x ); - * // returns [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ] - */ - flipud4d: typeof flipud4d; - - /** - * Reverses the order of elements along the second-to-last dimension of a five-dimensional nested input array. - * - * ## Notes - * - * - The function does **not** perform a deep copy of nested array elements. - * - * @param x - input nested array - * @returns output array - * - * @example - * var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ]; - * - * var out = ns.flipud5d( x ); - * // returns [ [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ] ] - */ - flipud5d: typeof flipud5d; - - /** - * Converts a strided array to a non-strided generic array. - * - * ## Notes - * - * - The function assumes that the input array is compatible with the specified number of elements, index stride, and index offset. - * - * @param N - number of indexed elements - * @param x - input array - * @param stride - index stride - * @param offset - index of the first indexed value in the input array - * @returns two-dimensional nested array - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var arr = ns.strided2array( 3, x, 2, 0 ); - * // returns [ 1, 3, 5 ] - */ - strided2array: typeof strided2array; - - /** - * Returns an accessor function for retrieving an element from an indexed array-like object. - * - * @param dtype - data type - * @returns accessor function - * - * @example - * var dtype = require( './../../../dtype' ); - * - * var arr = [ 1, 2, 3, 4 ]; - * - * var get = ns.getter( dtype( arr ) ); - * var v = get( arr, 2 ); - * // returns 3 - */ - getter: typeof getter; - - /** - * Groups element entries as arrays associated with distinct keys. - * - * @param x - input array - * @param groups - array defining which group an element in the input array belongs to - * @returns group results - * - * @example - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * var groups = [ 'b', 'b', 'f', 'b' ]; - * - * var out = ns.groupEntries( x, groups ); - * // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } - */ - groupEntries: typeof groupEntries; - - /** - * Groups element entries according to an indicator function. - * - * @param x - input array - * @param indicator - indicator function specifying which group an element in the input array belongs to - * @param thisArg - indicator function execution context - * @returns group results - * - * @example - * function indicator( v ) { - * return v[ 0 ]; - * } - * - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * - * var out = ns.groupEntriesBy( x, indicator ); - * // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } - */ - groupEntriesBy: typeof groupEntriesBy; - - /** - * Groups element indices as arrays associated with distinct keys. - * - * @param x - input array - * @param groups - array defining which group an element in the input array belongs to - * @returns group results - * - * @example - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * var groups = [ 'b', 'b', 'f', 'b' ]; - * - * var out = ns.groupIndices( x, groups ); - * // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } - */ - groupIndices: typeof groupIndices; - - /** - * Groups element indices according to an indicator function. - * - * @param x - input array - * @param indicator - indicator function specifying which group an element in the input array belongs to - * @param thisArg - indicator function execution context - * @returns group results - * - * @example - * function indicator( v ) { - * return v[ 0 ]; - * } - * - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * - * var out = ns.groupIndicesBy( x, indicator ); - * // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } - */ - groupIndicesBy: typeof groupIndicesBy; - - /** - * Groups elements as arrays associated with distinct keys. - * - * @param x - input array - * @param groups - array defining which group an element in the input array belongs to - * @returns group results - * - * @example - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * var groups = [ 'b', 'b', 'f', 'b' ]; - * - * var out = ns.groupValues( x, groups ); - * // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } - */ - groupValues: typeof groupValues; - - /** - * Groups element values according to an indicator function. - * - * @param x - input array - * @param indicator - indicator function specifying which group an element in the input array belongs to - * @param thisArg - indicator function execution context - * @returns group results - * - * @example - * function indicator( v ) { - * return v[ 0 ]; - * } - * - * var x = [ 'beep', 'boop', 'foo', 'bar' ]; - * - * var out = ns.groupValuesBy( x, indicator ); - * // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } - */ - groupValuesBy: typeof groupValuesBy; - - /** - * Generates a linearly spaced numeric array according to a provided increment. - * - * @param x1 - first array value - * @param x2 - array element bound - * @param increment - increment - * @returns linearly spaced numeric array - * - * @example - * var arr = ns.incrspace( 0, 11, 2 ); - * // returns [ 0, 2, 4, 6, 8, 10 ] - */ - incrspace: typeof incrspace; - - /** - * Returns the index of the first element which equals a provided search element. - * - * ## Notes - * - * - If unable to find an element which equals a provided search element, the function returns `-1`. - * - If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. - * - * @param x - input array - * @param searchElement - search element - * @param fromIndex - starting index (inclusive) - * @returns index - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var idx = ns.indexOf( x, 2, 0 ); - * // returns 1 - * - * @example - * var Int32Array = require( './../../../int32' ); - * - * var x = new Int32Array( [ 1, 2, 3, 4 ] ); - * - * var idx = ns.indexOf( x, 2, 0 ); - * // returns 1 - */ - indexOf: typeof indexOf; - - /** - * Returns the index of the first element which equals a provided search element according to the same value algorithm. - * - * ## Notes - * - * - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. - * - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. - * - If unable to find an element which equals a provided search element, the function returns `-1`. - * - If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. - * - * [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 - * - * @param x - input array - * @param searchElement - search element - * @param fromIndex - starting index (inclusive) - * @returns index - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var idx = ns.indexOfSameValue( x, 2, 0 ); - * // returns 1 - * - * @example - * var Int32Array = require( './../../../int32' ); - * - * var x = new Int32Array( [ 1, 2, 3, 4 ] ); - * - * var idx = ns.indexOfSameValue( x, 2, 0 ); - * // returns 1 - */ - indexOfSameValue: typeof indexOfSameValue; - - /** - * Returns the complement of a list of array indices. - * - * @param N - array length - * @param indices - list of indices - * @returns indices complement - * - * @example - * var idx = ns.indicesComplement( 5, [ 1, 3 ] ); - * // returns [ 0, 2, 4 ] - */ - indicesComplement: typeof indicesComplement; - - /** - * Returns a string created by joining array elements using a specified separator. - * - * @param x - input array - * @param separator - separator element - * @returns string - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = ns.join( x, ',' ); - * // returns '1,2,3' - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var out = ns.join( x, '-' ); - * // returns '1-2-3-4-5-6' - * - * @example - * var Float64Array = require( './../../../float64' ); - * - * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = ns.join( x, ',' ); - * // returns '1,2,3' - * - * @example - * var Complex128Array = require( './../../../complex128' ); - * - * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - * - * var out = ns.join( x, ',' ); - * // returns '1 + 2i,3 + 4i,5 + 6i' - */ - join: typeof join; - - /** - * Returns the last element of an array-like object. - * - * @param arr - input array - * @returns last element - * - * @example - * var arr = [ 1, 2, 3 ]; - * - * var out = ns.last( x ); - * // returns 3 - */ - last: typeof last; - - /** - * Returns the index of the last element which equals a provided search element. - * - * ## Notes - * - * - The function scans an input array from the starting index to the beginning of the array (i.e., backward). - * - If unable to find an element which equals a provided search element, the function returns `-1`. - * - If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. - * - * @param x - input array - * @param searchElement - search element - * @param fromIndex - starting index (inclusive) - * @returns index - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var idx = ns.lastIndexOf( x, 2, 3 ); - * // returns 1 - * - * @example - * var Int32Array = require( './../../../int32' ); - * - * var x = new Int32Array( [ 1, 2, 3, 4 ] ); - * - * var idx = ns.lastIndexOf( x, 2, 3 ); - * // returns 1 - */ - lastIndexOf: typeof lastIndexOf; - - /** - * Returns the index of the last element which equals a provided search element according to the same value algorithm. - * - * ## Notes - * - * - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. - * - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. - * - The function scans an input array from the starting index to the beginning of the array (i.e., backward). - * - If unable to find an element which equals a provided search element, the function returns `-1`. - * - If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. - * - * [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 - * - * @param x - input array - * @param searchElement - search element - * @param fromIndex - starting index (inclusive) - * @returns index - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var idx = ns.lastIndexOfSameValue( x, 2, 3 ); - * // returns 1 - * - * @example - * var Int32Array = require( './../../../int32' ); - * - * var x = new Int32Array( [ 1, 2, 3, 4 ] ); - * - * var idx = ns.lastIndexOfSameValue( x, 2, 3 ); - * // returns 1 - */ - lastIndexOfSameValue: typeof lastIndexOfSameValue; - - /** - * Generates a linearly spaced numeric array. - * - * @param x1 - first array value - * @param x2 - last array value - * @param len - length of output array - * @returns linearly spaced numeric array - * - * @example - * var arr = ns.linspace( 0, 100, 6 ); - * // returns [ 0, 20, 40, 60, 80, 100 ] - */ - linspace: typeof linspace; - - /** - * Generates a logarithmically spaced numeric array. - * - * @param a - exponent of start value - * @param b - exponent of end value - * @param len - length of output array - * @returns logarithmically spaced numeric array - * - * @example - * var arr = ns.logspace( 0, 2, 6 ); - * // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] - */ - logspace: typeof logspace; - - /** - * Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a new two-dimensional nested output array. - * - * ## Notes - * - * - The applied function is provided the following arguments: - * - * - **value**: array element. - * - **indices**: current array element indices. - * -- **array**: input nested array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones2d = require( './../../../base/ones2d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = ns.map2d( x, shape, scale ); - * // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] - * - * @example - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = zeros2d( shape ); - * - * var out = ns.map2d.assign( x, y, shape, scale ); - * // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] - * - * var bool = ( out === y ); - * // returns true - */ - map2d: typeof map2d; - - /** - * Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a new three-dimensional nested output array. - * - * ## Notes - * - * - The applied function is provided the following arguments: - * - * - **value**: array element. - * - **indices**: current array element indices. - * -- **array**: input nested array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones3d = require( './../../../base/ones3d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = ns.map3d( x, shape, scale ); - * // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] - * - * @example - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = zeros3d( shape ); - * - * var out = ns.map3d.assign( x, y, shape, scale ); - * // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - map3d: typeof map3d; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * ## Notes - * - * - The applied function is provided the following arguments: - * - * - **value**: array element. - * - **indices**: current array element indices. - * -- **array**: input nested array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( './../../../base/ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = ns.map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * @example - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = ns.map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - map4d: typeof map4d; - - /** - * Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a new five-dimensional nested output array. - * - * ## Notes - * - * - The applied function is provided the following arguments: - * - * - **value**: array element. - * - **indices**: current array element indices. - * -- **array**: input nested array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones5d = require( './../../../base/ones5d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 1, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = ns.map5d( x, shape, scale ); - * // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] - * - * @example - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 1, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = zeros5d( shape ); - * - * var out = ns.map5d.assign( x, y, shape, scale ); - * // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - map5d: typeof map5d; - - /** - * Returns the minimum array data type for storing a provided signed integer value. - * - * @param value - scalar value - * @returns array data type - * - * @example - * var dt = ns.minSignedIntegerDataType( 1280 ); - * // returns 'int16' - * - * @example - * var dt = ns.minSignedIntegerDataType( 3 ); - * // returns 'int8' - */ - minSignedIntegerDataType: typeof minSignedIntegerDataType; - - /** - * Returns the minimum array data type for storing a provided unsigned integer value. - * - * @param value - scalar value - * @returns array data type - * - * @example - * var dt = ns.minUnsignedIntegerDataType( 1280 ); - * // returns 'uint16' - * - * @example - * var dt = ns.minUnsignedIntegerDataType( 3 ); - * // returns 'uint8' - */ - minUnsignedIntegerDataType: typeof minUnsignedIntegerDataType; - - /** - * Applies a binary callback to elements in two two-dimensional nested input arrays according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - * - * @param arrays - array containing two input nested arrays, an input nested mask array, and one output nested array - * @param shape - array shape - * @param fcn - binary callback - * - * @example - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = ones2d( shape ); - * var z = zeros2d( shape ); - * - * var mask = [ [ 0, 1 ], [ 0, 0 ] ]; - * - * ns.mskbinary2d( [ x, y, mask, z ], shape, add ); - * - * console.log( z ); - * // => [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] - */ - mskbinary2d: typeof mskbinary2d; - - /** - * Applies a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - * - * @param arrays - array containing two input nested arrays, an input nested mask array, and one output nested array - * @param shape - array shape - * @param fcn - binary callback - * - * @example - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shape = [ 2, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = ones3d( shape ); - * var z = zeros3d( shape ); - * - * var mask = [ - * [ [ 0, 1 ], [ 0, 0 ] ], - * [ [ 1, 0 ], [ 0, 1 ] ] - * ]; - * - * ns.mskbinary3d( [ x, y, mask, z ], shape, add ); - * - * console.log( z ); - * // => [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ], [ [ 0.0, 2.0 ], [ 2.0, 0.0 ] ] ] - */ - mskbinary3d: typeof mskbinary3d; - - /** - * Applies a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - * - * @param arrays - array containing two input nested arrays, an input nested mask array, and one output nested array - * @param shape - array shape - * @param fcn - binary callback - * - * @example - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = ones4d( shape ); - * var z = zeros4d( shape ); - * - * var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - * - * mskbinary2d( [ x, y, mask, z ], shape, add ); - * - * console.log( z ); - * // => [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ] - */ - mskbinary4d: typeof mskbinary4d; - - /** - * Applies a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - * - * @param arrays - array containing two input nested arrays, an input nested mask array, and one output nested array - * @param shape - array shape - * @param fcn - binary callback - * - * @example - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * var add = require( '@stdlib/number/float64/base/add' ); - * - * var shape = [ 1, 1, 1, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = ones5d( shape ); - * var z = zeros5d( shape ); - * - * var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - * - * ns.mskbinary5d( [ x, y, mask, z ], shape, add ); - * - * console.log( z ); - * // => [ [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ] ] - */ - mskbinary5d: typeof mskbinary5d; - - /** - * Returns a new array by applying a mask to a provided input array. - * - * @param x - input array - * @param mask - mask array - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = ns.mskfilter( x, [ 0, 1, 0, 1 ] ); - * // returns [ 2, 4 ] - */ - mskfilter: typeof mskfilter; - - /** - * Returns a new array after applying a mask and a callback function to a provided input array. - * - * @param x - input array - * @param mask - mask array - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * function scale( val ) { - * return 10 * val; - * } - * - * var y = ns.mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); - * // returns [ 20, 40 ] - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var mask = [ 0, 1, 0, 1 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * - * function scale( x ) { - * return x * 10; - * } - * - * var arr = ns.mskfilterMap.assign( x, mask, out, 1, 0, scale ); - * // returns [ 20, 40, 0, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - mskfilterMap: typeof mskfilterMap; - - /** - * Returns new arrays by applying a mask to two provided input arrays in a single pass. - * - * @param x - first input array - * @param y - second input array - * @param mask - mask array - * @returns output arrays - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var y = [ 5, 6, 7, 8 ]; - * var mask = [ 0, 1, 0, 1 ]; - * - * var out = ns.mskfilter2( x, y, mask ); - * // returns [ [ 2, 4 ], [ 6, 8 ] ] - */ - mskfilter2: typeof mskfilter2; - - /** - * Returns new arrays by applying a mask to one or more provided input arrays in a single pass. - * - * @param x - first input array - * @param y - second input array (or mask) - * @param arrays - additional input arrays and mask - * @returns output arrays - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var y = [ 5, 6, 7, 8 ]; - * var mask = [ 0, 1, 0, 1 ]; - * - * var out = ns.mskfiltern( x, y, mask ); - * // returns [ [ 2, 4 ], [ 6, 8 ] ] - */ - mskfiltern: typeof mskfiltern; - - /** - * Replaces elements of an array with provided values according to a provided mask array. - * - * @param x - input array - * @param mask - mask array - * @param values - values to set - * @param mode - string specifying behavior when the number of values does not equal the number of falsy values in the mask array - * @returns input array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var mask = [ 1, 0, 0, 1 ]; - * var values = [ 20, 30 ]; - * - * var out = ns.mskput( x, mask, values, 'strict' ); - * // returns [ 1, 20, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var out = ns.mskput( x, [ 1, 0, 0, 1 ], [ 30 ], 'strict_broadcast' ); - * // returns [ 1, 30, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - */ - mskput: typeof mskput; - - /** - * Returns a new array by applying a mask to a provided input array. - * - * @param x - input array - * @param mask - mask array - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = ns.mskreject( x, [ 0, 1, 0, 1 ] ); - * // returns [ 1, 3 ] - */ - mskreject: typeof mskreject; - - /** - * Applies a unary callback to elements in a two-dimensional nested input array according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - * - * @param arrays - array containing one input nested array, an input nested mask array, and one output nested array - * @param shape - array shape - * @param fcn - unary callback - * - * @example - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = zeros2d( shape ); - * - * var mask = [ [ 0, 1 ], [ 0, 0 ] ]; - * - * ns.mskunary2d( [ x, mask, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] - */ - mskunary2d: typeof mskunary2d; - - /** - * Applies a unary callback to elements in a three-dimensional nested input array according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - * - * @param arrays - array containing one input nested array, an input nested mask array, and one output nested array - * @param shape - array shape - * @param fcn - unary callback - * - * @example - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = zeros3d( shape ); - * - * var mask = [ [ [ 0, 1 ], [ 0, 0 ] ] ]; - * - * ns.mskunary3d( [ x, mask, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] - */ - mskunary3d: typeof mskunary3d; - - /** - * Applies a unary callback to elements in a four-dimensional nested input array according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - * - * @param arrays - array containing one input nested array, an input nested mask array, and one output nested array - * @param shape - array shape - * @param fcn - unary callback - * - * @example - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - * - * ns.mskunary4d( [ x, mask, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ] - */ - mskunary4d: typeof mskunary4d; - - /** - * Applies a unary callback to elements in a five-dimensional nested input array according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - * - * @param arrays - array containing one input nested array, an input nested mask array, and one output nested array - * @param shape - array shape - * @param fcn - unary callback - * - * @example - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 1, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = zeros5d( shape ); - * - * var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - * - * ns.mskunary5d( [ x, mask, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ] ] - */ - mskunary5d: typeof mskunary5d; - - /** - * Returns the n-fold Cartesian product. - * - * ## Notes - * - * - If provided one or more empty arrays, the function returns an empty array. - * - * @param x1 - first input array - * @param x2 - second input array - * @param xN - additional input arrays - * @returns Cartesian product - * - * @example - * var x1 = [ 1, 2, 3 ]; - * var x2 = [ 4, 5 ]; - * - * var out = ns.nCartesianProduct( x1, x2 ); - * // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] - */ - nCartesianProduct: typeof nCartesianProduct; - - /** - * Tests whether all elements in an array are falsy. - * - * ## Notes - * - * - The function immediately returns upon encountering a truthy value. - * - If provided an empty collection, the function returns `true`. - * - * @param x - input array - * @returns boolean indicating whether all elements are falsy - * - * @example - * var x = [ 0, 0, 0, 0 ]; - * - * var out = ns.none( x ); - * // returns true - */ - none: typeof none; - - /** - * Tests whether all elements in an array fail a test implemented by a predicate function. - * - * ## Notes - * - * - The function immediately returns upon encountering a truthy return value. - * - If provided an empty collection, the function returns `true`. - * - * @param x - input array - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether all elements fail a test - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * - * var x = [ 0, 0, 0, 0 ]; - * - * var out = ns.noneBy( x, isPositive ); - * // returns true - */ - noneBy: typeof noneBy; - - /** - * Tests whether all elements in an array fail a test implemented by a predicate function, iterating from right to left. - * - * ## Notes - * - * - The function immediately returns upon encountering a truthy return value. - * - If provided an empty collection, the function returns `true`. - * - * @param x - input array - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether all elements fail a test - * - * @example - * function isPositive( v ) { - * return v > 0; - * } - * - * var x = [ 0, 0, 0, 0 ]; - * - * var out = ns.noneByRight( x, isPositive ); - * // returns true - */ - noneByRight: typeof noneByRight; - - /** - * Returns a "generic" array filled with nulls. - * - * @param len - array length - * @returns output array - * - * @example - * var out = ns.nulls( 3 ); - * // returns [ null, null, null ] - */ - nulls: typeof nulls; - - /** - * Generates a linearly spaced numeric array whose elements increment by 1 starting from one. - * - * @param n - number of elements - * @returns linearly spaced numeric array - * - * @example - * var arr = ns.oneTo( 6 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = ns.oneTo.assign( out, 1, 0 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = ns.oneTo.assign( out, -1, out.length-1 ); - * // returns [ 6, 5, 4, 3, 2, 1 ] - */ - oneTo: typeof oneTo; - - /** - * Returns a "generic" array filled with ones. - * - * @param len - array length - * @returns output array - * - * @example - * var out = ns.ones( 3 ); - * // returns [ 1.0, 1.0, 1.0 ] - */ - ones: typeof ones; - - /** - * Returns a two-dimensional nested array filled with ones. - * - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.ones2d( [ 1, 3 ] ); - * // returns [ [ 1.0, 1.0, 1.0 ] ] - */ - ones2d: typeof ones2d; - - /** - * Returns a three-dimensional nested array filled with ones. - * - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.ones3d( [ 1, 1, 3 ] ); - * // returns [ [ [ 1.0, 1.0, 1.0 ] ] ] - */ - ones3d: typeof ones3d; - - /** - * Returns a four-dimensional nested array filled with ones. - * - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.ones4d( [ 1, 1, 1, 3 ] ); - * // returns [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] - */ - ones4d: typeof ones4d; - - /** - * Returns a five-dimensional nested array filled with ones. - * - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.ones5d( [ 1, 1, 1, 1, 3 ] ); - * // returns [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] - */ - ones5d: typeof ones5d; - - /** - * Returns an n-dimensional nested array filled with ones. - * - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.onesnd( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); - * // returns [ [ [ [ [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] ] ] ] - */ - onesnd: typeof onesnd; - - /** - * Replaces elements of an array with provided values according to a provided mask array. - * - * @param x - input array - * @param mask - mask array - * @param values - values to set - * @param mode - string specifying behavior when the number of values does not equal the number of truthy values in the mask array - * @returns input array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var mask = [ 0, 1, 1, 0 ]; - * var values = [ 20, 30 ]; - * - * var out = ns.place( x, mask, values, 'strict' ); - * // returns [ 1, 20, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var out = ns.place( x, [ 0, 1, 1, 0 ], [ 30 ], 'strict_broadcast' ); - * // returns [ 1, 30, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - */ - place: typeof place; - - /** - * Replaces specified elements of an array with provided values. - * - * @param x - input array - * @param indices - list of element indices - * @param values - values to set - * @param mode - index mode - * @returns input array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var indices = [ 1, 2 ]; - * var values = [ 20, 30 ]; - * - * var out = ns.put( x, indices, values, 'throw' ); - * // returns [ 1, 20, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var out = ns.put( x, [ 1, 2 ], [ 30 ], 'throw' ); - * // returns [ 1, 30, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - */ - put: typeof put; - - /** - * Applies a quaternary callback to elements in four two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing four input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - quaternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add4' ); - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = ones2d( shape ); - * var z = ones2d( shape ); - * var w = ones2d( shape ); - * var out = zeros2d( shape ); - * - * ns.quaternary2d( [ x, y, z, w, out ], shape, add ); - * - * console.log( out ); - * // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] - */ - quaternary2d: typeof quaternary2d; - - /** - * Applies a quaternary callback to elements in four three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing four input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - quaternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add4' ); - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * - * var shape = [ 1, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = ones3d( shape ); - * var z = ones3d( shape ); - * var w = ones3d( shape ); - * var out = zeros3d( shape ); - * - * ns.quaternary3d( [ x, y, z, w, out ], shape, add ); - * - * console.log( out ); - * // => [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] - */ - quaternary3d: typeof quaternary3d; - - /** - * Applies a quaternary callback to elements in four four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing four input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - quaternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add4' ); - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = ones4d( shape ); - * var z = ones4d( shape ); - * var w = ones4d( shape ); - * var out = zeros4d( shape ); - * - * ns.quaternary4d( [ x, y, z, w, out ], shape, add ); - * - * console.log( out ); - * // => [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ] - */ - quaternary4d: typeof quaternary4d; - - /** - * Applies a quaternary callback to elements in four five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing four input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - quaternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add4' ); - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * - * var shape = [ 1, 1, 1, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = ones5d( shape ); - * var z = ones5d( shape ); - * var w = ones5d( shape ); - * var out = zeros5d( shape ); - * - * ns.quaternary5d( [ x, y, z, w, out ], shape, add ); - * - * console.log( out ); - * // => [ [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ] ] - */ - quaternary5d: typeof quaternary5d; - - /** - * Applies a quinary callback to elements in five two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing five input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - quinary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add5' ); - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = ones2d( shape ); - * var z = ones2d( shape ); - * var w = ones2d( shape ); - * var v = ones2d( shape ); - * var out = zeros2d( shape ); - * - * ns.quinary2d( [ x, y, z, w, v, out ], shape, add ); - * - * console.log( out ); - * // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] - */ - quinary2d: typeof quinary2d; - - /** - * Applies a quinary callback to elements in five three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing five input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - quinary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add5' ); - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * - * var shape = [ 1, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = ones3d( shape ); - * var z = ones3d( shape ); - * var w = ones3d( shape ); - * var v = ones3d( shape ); - * var out = zeros3d( shape ); - * - * ns.quinary3d( [ x, y, z, w, v, out ], shape, add ); - * - * console.log( out ); - * // => [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] - */ - quinary3d: typeof quinary3d; - - /** - * Applies a quinary callback to elements in five four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing five input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - quinary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add5' ); - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = ones4d( shape ); - * var z = ones4d( shape ); - * var w = ones4d( shape ); - * var v = ones4d( shape ); - * var out = zeros4d( shape ); - * - * ns.quinary4d( [ x, y, z, w, v, out ], shape, add ); - * - * console.log( out ); - * // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] - */ - quinary4d: typeof quinary4d; - - /** - * Applies a quinary callback to elements in five five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing five input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - quinary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add5' ); - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * - * var shape = [ 1, 1, 1, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = ones5d( shape ); - * var z = ones5d( shape ); - * var w = ones5d( shape ); - * var v = ones5d( shape ); - * var out = zeros5d( shape ); - * - * ns.quinary5d( [ x, y, z, w, v, out ], shape, add ); - * - * console.log( out ); - * // => [ [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] ] - */ - quinary5d: typeof quinary5d; - - /** - * Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. - * - * @param x - input array - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns output array - * - * @example - * var x = [ 1, -2, -3, 4 ]; - * - * var out = ns.reject( x, isPositiveNumber ); - * // returns [ -2, -3 ] - */ - reject: typeof reject; - - /** - * Removes an element from an array. - * - * ## Notes - * - * - The function mutates the input array. - * - * @param x - input array - * @param index - element index - * @returns input array - * - * @example - * var x = [ 1, 1, 2, 3, 3 ]; - * - * var y = ns.removeAt( x, -2 ); - * // returns [ 1, 1, 3, 3 ] - * - * var bool = ( x === y ); - * // returns true - */ - removeAt: typeof removeAt; - - /** - * Returns an accessor function for retrieving an element from an indexed array-like object. - * - * @param x - input array - * @returns accessor function - * - * @example - * var arr = [ 1, 2, 3, 4 ]; - * - * var get = ns.resolveGetter( arr ); - * var v = get( arr, 2 ); - * // returns 3 - */ - resolveGetter: typeof resolveGetter; - - /** - * Returns an accessor function for setting an element in an indexed array-like object. - * - * @param x - input array - * @returns accessor function - * - * @example - * var resolveGetter = require( './../../../base/resolve-getter' ); - * - * var arr = [ 1, 2, 3, 4 ]; - * - * var set = ns.resolveSetter( arr ); - * set( arr, 2, 10 ); - * - * var get = resolveGetter( arr ); - * var v = get( arr, 2 ); - * // returns 10 - */ - resolveSetter: typeof resolveSetter; - - /** - * Reverses an array in-place. - * - * @param x - input array - * @returns input array - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = ns.reverse( x ); - * // returns [ 3, 2, 1 ] - */ - reverse: typeof reverse; - - /** - * Scatters a list of provided values to specified indices in a new filled "generic" array. - * - * @param fill - fill value - * @param len - output array length - * @param indices - list of element indices - * @param values - values to scatter - * @param mode - index mode - * @returns output array - * - * @example - * var indices = [ 1, 2 ]; - * var values = [ 20, 30 ]; - * - * var out = ns.scatterFilled( null, 4, indices, values, 'throw' ); - * // returns [ null, 20, 30, null ] - * - * @example - * var out = ns.scatterFilled( null, 4, [ 1, 2 ], [ 30 ], 'throw' ); - * // returns [ null, 30, 30, null ] - */ - scatterFilled: typeof scatterFilled; - - /** - * Scatters a list of provided values to specified indices in a new zero-filled "generic" array. - * - * @param len - output array length - * @param indices - list of element indices - * @param values - values to scatter - * @param mode - index mode - * @returns output array - * - * @example - * var indices = [ 1, 2 ]; - * var values = [ 20, 30 ]; - * - * var out = ns.scattered( 4, indices, values, 'throw' ); - * // returns [ 0, 20, 30, 0 ] - * - * @example - * var out = ns.scattered( 4, [ 1, 2 ], [ 30 ], 'throw' ); - * // returns [ 0, 30, 30, 0 ] - */ - scattered: typeof scattered; - - /** - * Returns an accessor function for setting an element in an indexed array-like object. - * - * @param dtype - data type - * @returns accessor function - * - * @example - * var dtype = require( './../../../dtype' ); - * - * var arr = [ 0, 0, 0, 0 ]; - * - * var set = ns.setter( dtype( arr ) ); - * set( arr, 2, 3 ); - * - * var v = arr[ 2 ]; - * // returns 3 - */ - setter: typeof setter; - - /** - * Returns a shallow copy of a portion of an array. - * - * @param x - input array - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @returns output array - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = ns.slice( x, 0, 3 ); - * // returns [ 1, 2, 3 ] - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var out = ns.slice( x, 0, 3 ); - * // returns [ 1, 2, 3 ] - */ - slice: typeof slice; - - /** - * Converts a strided array to a two-dimensional nested array. - * - * ## Notes - * - * - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. - * - * @param x - input array - * @param shape - array shape - * @param strides - dimension strides - * @param offset - index of the first indexed value in the input array - * @returns two-dimensional nested array - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var arr = ns.strided2array2d( x, [ 3, 2 ], [ 2, 1 ], 0 ); - * // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var arr = ns.strided2array2d( x, [ 3, 2 ], [ 1, 3 ], 0 ); - * // returns [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - */ - strided2array2d: typeof strided2array2d; - - /** - * Converts a strided array to a three-dimensional nested array. - * - * ## Notes - * - * - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. - * - * @param x - input array - * @param shape - array shape - * @param strides - dimension strides - * @param offset - index of the first indexed value in the input array - * @returns three-dimensional nested array - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var arr = ns.strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 ); - * // returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var arr = ns.strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 ); - * // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] - */ - strided2array3d: typeof strided2array3d; - - /** - * Converts a strided array to a four-dimensional nested array. - * - * ## Notes - * - * - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. - * - * @param x - input array - * @param shape - array shape - * @param strides - dimension strides - * @param offset - index of the first indexed value in the input array - * @returns four-dimensional nested array - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var arr = ns.strided2array4d( x, [ 1, 1, 3, 2 ], [ 6, 6, 2, 1 ], 0 ); - * // returns [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var arr = ns.strided2array4d( x, [ 1, 1, 3, 2 ], [ 1, 1, 1, 3 ], 0 ); - * // returns [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] - */ - strided2array4d: typeof strided2array4d; - - /** - * Converts a strided array to a five-dimensional nested array. - * - * ## Notes - * - * - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. - * - * @param x - input array - * @param shape - array shape - * @param strides - dimension strides - * @param offset - index of the first indexed value in the input array - * @returns five-dimensional nested array - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var arr = ns.strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 6, 6, 6, 2, 1 ], 0 ); - * // returns [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ] - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var arr = ns.strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 1, 1, 1, 1, 3 ], 0 ); - * // returns [ [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] ] - */ - strided2array5d: typeof strided2array5d; - - /** - * Takes elements from an array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = ns.take( x, [ 1, 3 ], 'throw' ); - * // returns [ 2, 4 ] - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var out = [ 0, 0, 0, 0 ]; - * - * var arr = ns.take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2, 0, 4, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - take: typeof take; - - /** - * Takes elements from an indexed array. - * - * ## Notes - * - * - The function does **not** perform bounds checking. If an index is less than zero or greater than the maximum index of `x`, the value of the corresponding element in the output array is undefined. - * - * @param x - input array - * @param indices - list of element indices - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = ns.takeIndexed( x, [ 1, 3 ] ); - * // returns [ 2, 4 ] - */ - takeIndexed: typeof takeIndexed; - - /** - * Takes elements from two indexed arrays in a single pass. - * - * ## Notes - * - * - The function does **not** perform bounds checking. If an index is less than zero or greater than the maximum index of `x` or `y`, the value of the corresponding element in the respective output array is undefined. - * - * @param x - first input array - * @param y - second input array - * @param indices - list of element indices - * @returns output arrays - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var y = [ 5, 6, 7, 8 ]; - * var indices = [ 3, 1, 2, 0 ]; - * - * var out = ns.takeIndexed2( x, y, indices ); - * // returns [ [ 4, 2, 3, 1 ], [ 8, 6, 7, 5 ] ] - */ - takeIndexed2: typeof takeIndexed2; - - /** - * Takes elements from a two-dimensional nested array. - * - * ## Notes - * - * - The function does **not** deep copy nested array elements. - * - * @param x - input nested array - * @param indices - list of indices - * @param dimension - dimension along which to take elements - * @param mode - index mode specifying how to handle an index which is out-of-bounds - * @returns output array - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * var indices = [ 1, 1, 0, 0, -1, -1 ]; - * - * var y = ns.take2d( x, indices, 1, 'normalize' ); - * // returns [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] - */ - take2d: typeof take2d; - - /** - * Takes elements from a three-dimensional nested array. - * - * ## Notes - * - * - The function does **not** deep copy nested array elements. - * - * @param x - input nested array - * @param indices - list of indices - * @param dimension - dimension along which to take elements - * @param mode - index mode specifying how to handle an index which is out-of-bounds - * @returns output array - * - * @example - * var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - * var indices = [ 1, 1, 0, 0, -1, -1 ]; - * - * var y = ns.take3d( x, indices, 2, 'normalize' ); - * // returns [ [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] ] - */ - take3d: typeof take3d; - - /** - * Applies a ternary callback to elements in three two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing three input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - ternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add3' ); - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = ones2d( shape ); - * var z = ones2d( shape ); - * var out = zeros2d( shape ); - * - * ns.ternary2d( [ x, y, z, out ], shape, add ); - * - * console.log( out ); - * // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] - */ - ternary2d: typeof ternary2d; - - /** - * Applies a ternary callback to elements in three three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing three input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - ternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add3' ); - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * - * var shape = [ 1, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = ones3d( shape ); - * var z = ones3d( shape ); - * var out = zeros3d( shape ); - * - * ns.ternary3d( [ x, y, z, out ], shape, add ); - * - * console.log( out ); - * // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] - */ - ternary3d: typeof ternary3d; - - /** - * Applies a ternary callback to elements in three four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing three input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - ternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add3' ); - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = ones4d( shape ); - * var z = ones4d( shape ); - * var out = zeros4d( shape ); - * - * ns.ternary4d( [ x, y, z, out ], shape, add ); - * - * console.log( out ); - * // => [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] - */ - ternary4d: typeof ternary4d; - - /** - * Applies a ternary callback to elements in three five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing three input nested arrays and one output nested array - * @param shape - array shape - * @param fcn - ternary callback - * - * @example - * var add = require( '@stdlib/number/float64/base/add3' ); - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * - * var shape = [ 1, 1, 1, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = ones5d( shape ); - * var z = ones5d( shape ); - * var out = zeros5d( shape ); - * - * ns.ternary5d( [ x, y, z, out ], shape, add ); - * - * console.log( out ); - * // => [ [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] ] - */ - ternary5d: typeof ternary5d; - - /** - * Converts an array-like object to a minimal array-like object supporting the accessor protocol. - * - * ## Notes - * - * - If a provided array-like object already supports the accessor protocol, the function returns the provided array-like object; otherwise, the function wraps the provided value in a object which uses accessors for getting and setting elements. - * - * @param arr - input array - * @returns accessor array - * - * @example - * var arr = ns.toAccessorArray( [ 1, 2, 3 ] ); - * // returns - * - * var v = arr.get( 0 ); - * // returns 1 - * - * @example - * var Complex128Array = require( './../../../complex128' ); - * - * var arr = ns.toAccessorArray( new Complex128Array( 10 ) ); - * // returns - */ - toAccessorArray: typeof toAccessorArray; - - /** - * Copies elements to a new "generic" array after removing consecutive duplicated values. - * - * @param x - input array - * @param limit - number of allowed consecutive duplicates - * @param equalNaNs - boolean indicating whether NaNs should be considered equal - * @returns output array - * - * @example - * var x = [ 1, 1, 2, 3, 3 ]; - * - * var y = ns.toDeduped( x, 1, false ); - * // returns [ 1, 2, 3 ] - * - * var bool = ( x === y ); - * // returns false - * - * @example - * var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ]; - * - * var y = ns.toDeduped( x, 2, false ); - * // returns [ 1, 1, 2, 1, 1, 3, 3 ] - * - * var bool = ( x === y ); - * // returns false - */ - toDeduped: typeof toDeduped; - - /** - * Returns a new array with elements in reverse order. - * - * @param x - input array - * @returns output array - * - * @example - * var toAccessorArray = require( './../../../base/to-accessor-array' ); - * - * var x = toAccessorArray( [ 1, 2, 3 ] ); - * - * var v = x.get( 0 ); - * // returns 1 - * - * var out = ns.toReversed( x ); - * // returns [ 3, 2, 1 ] - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = ns.toReversed( x ); - * // returns [ 3, 2, 1 ] - */ - toReversed: typeof toReversed; - - /** - * Applies a unary callback to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shape - array shape - * @param fcn - unary callback - * - * @example - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = zeros2d( shape ); - * - * ns.unary2d( [ x, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] - */ - unary2d: typeof unary2d; - - /** - * Applies a unary function to each element retrieved from a two-dimensional nested input array according to a callback function and assigns results to elements in a two-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shape - array shape - * @param fcn - unary function to apply to callback return values - * @param clbk - callback function - * @param thisArg - callback execution context - * - * @example - * var ones2d = require( './../../../base/ones2d' ); - * var zeros2d = require( './../../../base/zeros2d' ); - * - * function accessor( v ) { - * return v - 2.0; - * } - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = zeros2d( shape ); - * - * ns.unary2dBy( [ x, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] - */ - unary2dBy: typeof unary2dBy; - - /** - * Applies a unary callback to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shape - array shape - * @param fcn - unary callback - * - * @example - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = zeros3d( shape ); - * - * ns.unary3d( [ x, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] - */ - unary3d: typeof unary3d; - - /** - * Applies a unary function to each element retrieved from a three-dimensional nested input array according to a callback function and assigns results to elements in a three-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shape - array shape - * @param fcn - unary function to apply to callback return values - * @param clbk - callback function - * @param thisArg - callback execution context - * - * @example - * var ones3d = require( './../../../base/ones3d' ); - * var zeros3d = require( './../../../base/zeros3d' ); - * - * function accessor( v ) { - * return v - 2.0; - * } - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = zeros3d( shape ); - * - * ns.unary3dBy( [ x, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] - */ - unary3dBy: typeof unary3dBy; - - /** - * Applies a unary callback to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shape - array shape - * @param fcn - unary callback - * - * @example - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * ns.unary4d( [ x, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - unary4d: typeof unary4d; - - /** - * Applies a unary function to each element retrieved from a four-dimensional nested input array according to a callback function and assigns results to elements in a four-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shape - array shape - * @param fcn - unary function to apply to callback return values - * @param clbk - callback function - * @param thisArg - callback execution context - * - * @example - * var ones4d = require( './../../../base/ones4d' ); - * var zeros4d = require( './../../../base/zeros4d' ); - * - * function accessor( v ) { - * return v - 2.0; - * } - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * ns.unary4dBy( [ x, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ] - */ - unary4dBy: typeof unary4dBy; - - /** - * Applies a unary callback to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shape - array shape - * @param fcn - unary callback - * - * @example - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 1, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = zeros5d( shape ); - * - * ns.unary5d( [ x, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] - */ - unary5d: typeof unary5d; - - /** - * Applies a unary function to each element retrieved from a five-dimensional nested input array according to a callback function and assigns results to elements in a five-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shape - array shape - * @param fcn - unary function to apply to callback return values - * @param clbk - callback function - * @param thisArg - callback execution context - * - * @example - * var ones5d = require( './../../../base/ones5d' ); - * var zeros5d = require( './../../../base/zeros5d' ); - * - * function accessor( v ) { - * return v - 2.0; - * } - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 1, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = zeros5d( shape ); - * - * unary2dBy( [ x, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ] ] - */ - unary5dBy: typeof unary5dBy; - - /** - * Applies a unary callback to elements in an n-dimensional nested input array and assigns results to elements in an n-dimensional nested output array. - * - * ## Notes - * - * - The function assumes that the input and output arrays have the same shape. - * - * @param arrays - array containing one input nested array and one output nested array - * @param shape - array shape - * @param fcn - unary callback - * - * @example - * var onesnd = require( './../../../base/onesnd' ); - * var zerosnd = require( './../../../base/zerosnd' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; - * - * var x = onesnd( shape ); - * var y = zerosnd( shape ); - * - * ns.unarynd( [ x, y ], shape, scale ); - * - * console.log( y ); - * // => [ [ [ [ [ [ [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] ] ] ] ] ] ] - */ - unarynd: typeof unarynd; - - /** - * Generates a linearly spaced numeric array whose elements increment by 1. - * - * @param x1 - first array value - * @param x2 - array element bound - * @returns linearly spaced numeric array - * - * @example - * var arr = ns.unitspace( 0, 6 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - */ - unitspace: typeof unitspace; - - /** - * Takes elements from either one of two arrays depending on a condition. - * - * @param condition - array containing indicator values - * @param x - first input array - * @param y - second input array - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var y = [ 5, 6, 7, 8 ]; - * - * var condition = [ true, false, true, false ]; - * - * var z = ns.where( condition, x, y ); - * // returns [ 1, 6, 3, 8 ] - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var y = [ 5, 6, 7, 8 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * var condition = [ true, false, true, false ]; - * - * var arr = assign( condition, x, y, out, 1, 0 ); - * // returns [ 1, 6, 3, 8 ] - * - * var bool = ( arr === out ); - * // returns true - */ - where: typeof where; - - /** - * Returns a new array with the element at the specified index replaced with a provided value. - * - * @param x - input array - * @param index - index at which to set a provided value - * @param value - replacement value - * @returns output array - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = ns.arrayWith( x, 0, 7 ); - * // returns [ 7, 2, 3 ] - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var out = ns.arrayWith( x, 1, 8 ); - * // returns [ 1, 8, 3, 4, 5, 6 ] - * - * @example - * var Float64Array = require( './../../../float64' ); - * - * var x = [ 1, 2, 3, 4 ]; - * - * var out = new Float64Array( [ 0, 0, 0, 0 ] ); - * var arr = ns.arrayWith.assign( x, 0, 5, out, 1, 0 ); - * // returns [ 5, 2, 3, 4 ] - * - * var bool = ( arr === out ); - * // returns true - */ - arrayWith: typeof arrayWith; - - /** - * Returns a new array containing every element from an input array, except for the element at a specified index. - * - * @param x - input array - * @param index - index of the element to exclude - * @returns output array - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = ns.without( x, 0 ); - * // returns [ 2, 3 ] - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var out = ns.without( x, 1 ); - * // returns [ 1, 3, 4, 5, 6 ] - * - * @example - * var Float64Array = require( './../../../float64' ); - * - * var x = [ 1, 2, 3, 4 ]; - * - * var out = new Float64Array( [ 0, 0, 0 ] ); - * var arr = ns.without.assign( x, 0, out, 1, 0 ); - * // returns [ 2, 3, 4 ] - * - * var bool = ( arr === out ); - * // returns true - */ - without: typeof without; - - /** - * Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. - * - * @param n - number of elements - * @returns linearly spaced numeric array - * - * @example - * var arr = ns.zeroTo( 6 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = ns.zeroTo.assign( out, 1, 0 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = ns.zeroTo.assign( out, -1, out.length-1 ); - * // returns [ 5, 4, 3, 2, 1, 0 ] - */ - zeroTo: typeof zeroTo; - - /** - * Returns a zero-filled "generic" array. - * - * @param len - array length - * @returns output array - * - * @example - * var out = ns.zeros( 3 ); - * // returns [ 0.0, 0.0, 0.0 ] - */ - zeros: typeof zeros; - - /** - * Returns a zero-filled two-dimensional nested array. - * - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.zeros2d( [ 1, 3 ] ); - * // returns [ [ 0.0, 0.0, 0.0 ] ] - */ - zeros2d: typeof zeros2d; - - /** - * Returns a zero-filled three-dimensional nested array. - * - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.zeros3d( [ 1, 1, 3 ] ); - * // returns [ [ [ 0.0, 0.0, 0.0 ] ] ] - */ - zeros3d: typeof zeros3d; - - /** - * Returns a zero-filled four-dimensional nested array. - * - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.zeros4d( [ 1, 1, 1, 3 ] ); - * // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] - */ - zeros4d: typeof zeros4d; - - /** - * Returns a zero-filled five-dimensional nested array. - * - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.zeros5d( [ 1, 1, 1, 1, 3 ] ); - * // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] - */ - zeros5d: typeof zeros5d; - - /** - * Returns a zero-filled n-dimensional nested array. - * - * @param shape - array shape - * @returns output array - * - * @example - * var out = ns.zerosnd( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); - * // returns [ [ [ [ [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] ] ] ] - */ - zerosnd: typeof zerosnd; -} - -/** -* Base (i.e., lower-level) array utilities. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/base/docs/types/test.ts b/base/docs/types/test.ts deleted file mode 100644 index c2dd14ec1..000000000 --- a/base/docs/types/test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/base/entries2objects/README.md b/base/entries2objects/README.md deleted file mode 100644 index 0885e8b04..000000000 --- a/base/entries2objects/README.md +++ /dev/null @@ -1,98 +0,0 @@ - - -# entries2objects - -> Convert array entries to an array of objects. - -
- -## Usage - -```javascript -var entries2objects = require( '@stdlib/array/base/entries2objects' ); -``` - -#### entries2objects( arr, fields ) - -Converts array entries to an array of objects. - -```javascript -var x = [ 1, 2 ]; - -var fields = [ 'x', 'y' ]; - -var out = entries2objects( x, fields ); -// returns [ { 'x': 0, 'y': 1 }, { 'x': 1, 'y': 2 } ] -``` - -The function supports the following parameters: - -- **arr**: input array. -- **fields**: list of field names. - -
- - - -
- -- The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var entries2objects = require( '@stdlib/array/base/entries2objects' ); - -var x = discreteUniform( 10, -100, 100 ); -var fields = [ 'x', 'y' ]; - -var out = entries2objects( x, fields ); -// returns [...] -``` - -
- - - - - - - - - - - - - - diff --git a/base/entries2objects/benchmark/benchmark.js b/base/entries2objects/benchmark/benchmark.js deleted file mode 100644 index 64665e1ef..000000000 --- a/base/entries2objects/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var entries2objects = require( './../lib' ); - - -// MAIN // - -bench( pkg+':len=10', function benchmark( b ) { - var labels; - var x; - var i; - var v; - - labels = [ 'x', 'y' ]; - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = entries2objects( x, labels ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/entries2objects/benchmark/benchmark.length.js b/base/entries2objects/benchmark/benchmark.length.js deleted file mode 100644 index f0bb63e7f..000000000 --- a/base/entries2objects/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var entries2objects = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var labels = [ 'x', 'y' ]; - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = entries2objects( x, labels ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/entries2objects/docs/repl.txt b/base/entries2objects/docs/repl.txt deleted file mode 100644 index c291807ef..000000000 --- a/base/entries2objects/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( arr, fields ) - Converts array entries to an array of objects. - - The list of field names should be a two-element array where the first - element corresponds to the field name of input array element index and the - second element corresponds to the field name of the input array element - value. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2 ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ) - [ { 'x': 0, 'y': 1 }, { 'x': 1, 'y': 2 } ] - - See Also - -------- - diff --git a/base/entries2objects/docs/types/index.d.ts b/base/entries2objects/docs/types/index.d.ts deleted file mode 100644 index 59ce419a6..000000000 --- a/base/entries2objects/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts array entries to an array of objects. -* -* ## Notes -* -* - The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ 1, 2, 3 ]; -* var fields = [ 'x', 'y' ]; -* -* var out = entries2objects( x, fields ); -* // returns [ { 'x': 0, 'y': 1 }, { 'x': 1, 'y': 2 }, { 'x': 2, 'y': 3 } ] -*/ -declare function entries2objects( arr: Collection | AccessorArrayLike, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = entries2objects; diff --git a/base/entries2objects/docs/types/test.ts b/base/entries2objects/docs/types/test.ts deleted file mode 100644 index e5a7b1113..000000000 --- a/base/entries2objects/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import entries2objects = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - entries2objects( [ 1, 2, 3 ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - entries2objects( 1, [ 'x', 'y' ] ); // $ExpectError - entries2objects( true, [ 'x', 'y' ] ); // $ExpectError - entries2objects( false, [ 'x', 'y' ] ); // $ExpectError - entries2objects( null, [ 'x', 'y' ] ); // $ExpectError - entries2objects( void 0, [ 'x', 'y' ] ); // $ExpectError - entries2objects( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - entries2objects( [], 1 ); // $ExpectError - entries2objects( [], true ); // $ExpectError - entries2objects( [], false ); // $ExpectError - entries2objects( [], null ); // $ExpectError - entries2objects( [], void 0 ); // $ExpectError - entries2objects( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - entries2objects(); // $ExpectError - entries2objects( [] ); // $ExpectError - entries2objects( [], [], [] ); // $ExpectError -} diff --git a/base/entries2objects/examples/index.js b/base/entries2objects/examples/index.js deleted file mode 100644 index 8eca985bd..000000000 --- a/base/entries2objects/examples/index.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var entries2objects = require( './../lib' ); - -var x = discreteUniform( 10, -100, 100 ); -var fields = [ 'x', 'y' ]; - -var out = entries2objects( x, fields ); -console.log( out ); -// => [...] diff --git a/base/entries2objects/lib/index.js b/base/entries2objects/lib/index.js deleted file mode 100644 index f55d6828d..000000000 --- a/base/entries2objects/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert array entries to an array of objects. -* -* @module @stdlib/array/base/entries2objects -* -* @example -* var entries2objects = require( '@stdlib/array/base/entries2objects' ); -* -* var x = [ 1, 2, 3 ]; -* var fields = [ 'x', 'y' ]; -* -* var out = entries2objects( x, fields ); -* // returns [ { 'x': 0, 'y': 1 }, { 'x': 1, 'y': 2 }, { 'x': 2, 'y': 3 } ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/entries2objects/lib/main.js b/base/entries2objects/lib/main.js deleted file mode 100644 index 6cd514265..000000000 --- a/base/entries2objects/lib/main.js +++ /dev/null @@ -1,77 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Convert array entries to an array of objects. -* -* ## Notes -* -* - The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3 ]; -* var fields = [ 'x', 'y' ]; -* -* var out = entries2objects( x, fields ); -* // returns [ { 'x': 0, 'y': 1 }, { 'x': 1, 'y': 2 }, { 'x': 2, 'y': 3 } ] -*/ -function entries2objects( arr, fields ) { - var get; - var out; - var obj; - var N; - var i; - var k; - var v; - - N = arr.length; - if ( N < 1 ) { - return []; - } - get = resolveGetter( fields ); - k = get( fields, 0 ); - v = get( fields, 1 ); - - get = resolveGetter( arr ); - out = []; - for ( i = 0; i < N; i++ ) { - obj = {}; - obj[ k ] = i; - obj[ v ] = get( arr, i ); - out.push( obj ); - } - return out; -} - - -// EXPORTS // - -module.exports = entries2objects; diff --git a/base/entries2objects/package.json b/base/entries2objects/package.json deleted file mode 100644 index 172f553b2..000000000 --- a/base/entries2objects/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/entries2objects", - "version": "0.0.0", - "description": "Convert array entries to an array of objects.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "entries", - "object", - "tidy" - ] -} diff --git a/base/entries2objects/test/test.js b/base/entries2objects/test/test.js deleted file mode 100644 index 1d28ccb6a..000000000 --- a/base/entries2objects/test/test.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var entries2objects = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof entries2objects, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = entries2objects( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts array entries to an array of objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ 1, 2 ]; - - actual = entries2objects( x, fields ); - expected = [ - { - 'x': 0, - 'y': 1 - }, - { - 'x': 1, - 'y': 2 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts array entries to an array of objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = toAccessorArray( [ 1, 2 ] ); - - actual = entries2objects( x, toAccessorArray( fields ) ); - expected = [ - { - 'x': 0, - 'y': 1 - }, - { - 'x': 1, - 'y': 2 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/entries2views/README.md b/base/entries2views/README.md deleted file mode 100644 index eeef3a02d..000000000 --- a/base/entries2views/README.md +++ /dev/null @@ -1,125 +0,0 @@ - - -# entries2views - -> Convert array entries to an array of composite views. - -
- -## Usage - -```javascript -var entries2views = require( '@stdlib/array/base/entries2views' ); -``` - -#### entries2views( arr, fields ) - -Converts array entries to an array of composite views. - -```javascript -var x = [ 1, 2, 3 ]; -var fields = [ 'x', 'y' ]; - -var out = entries2views( x, fields ); -// returns [ , , ] - -var v0 = out[ 0 ].toJSON(); -// returns { 'x': 0, 'y': 1 } - -var v1 = out[ 1 ].toJSON(); -// returns { 'x': 1, 'y': 2 } - -var v2 = out[ 2 ].toJSON(); -// returns { 'x': 2, 'y': 3 } - -// Mutate the input array: -x[ 0 ] = 5; - -v0 = out[ 0 ].toJSON(); -// returns { 'x': 0, 'y': 5 } - -// Set a view property: -out[ 1 ].y = 'beep'; - -v1 = out[ 1 ].toJSON(); -// returns { 'x': 1, 'y': 'beep' } - -var y = x.slice(); -// returns [ 5, 'beep', 3 ] -``` - -The function supports the following parameters: - -- **arr**: input array. -- **fields**: list of field names. - -Each element in the returned array is a class instance having prototype properties corresponding to the list of field names. As demonstrated in the example above, to convert an element to a regular object, invoke an element's `toJSON` method. Note, however, that the object returned by an element's `toJSON` method no longer shares the same memory as the provided input array. - - - - - -
- -- The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value. -- For each element of the returned array, the index view field is read-only and cannot be mutated. -- Each view in the returned array shares the same memory as the corresponding element in the input array. Accordingly, mutation of either the input array or a view will mutate the other. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var entries2views = require( '@stdlib/array/base/entries2views' ); - -var x = discreteUniform( 10, -100, 100 ); -var fields = [ 'x', 'y' ]; - -var out = entries2views( x, fields ); -// returns [...] -``` - -
- - - - - - - - - - - - - - diff --git a/base/entries2views/benchmark/benchmark.js b/base/entries2views/benchmark/benchmark.js deleted file mode 100644 index 4593bb417..000000000 --- a/base/entries2views/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var entries2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':len=10', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = entries2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/entries2views/benchmark/benchmark.length.js b/base/entries2views/benchmark/benchmark.length.js deleted file mode 100644 index 8dd3251a5..000000000 --- a/base/entries2views/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var entries2views = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var fields = [ 'x', 'y' ]; - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = entries2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/entries2views/docs/repl.txt b/base/entries2views/docs/repl.txt deleted file mode 100644 index 35e0b91cb..000000000 --- a/base/entries2views/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( arr, fields ) - Converts array entries to an array of composite views. - - The list of field names should be a two-element array where the first - element corresponds to the field name of input array element index and the - second element corresponds to the field name of the input array element - value. - - For each element of the returned array, the index view field is read-only - and cannot be mutated. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2 ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 0, 'y': 1 } - > v = out[ 1 ].toJSON() - { 'x': 1, 'y': 2 } - - See Also - -------- - diff --git a/base/entries2views/docs/types/index.d.ts b/base/entries2views/docs/types/index.d.ts deleted file mode 100644 index 0183d27e9..000000000 --- a/base/entries2views/docs/types/index.d.ts +++ /dev/null @@ -1,78 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts array entries to an array of composite views. -* -* ## Notes -* -* - The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value. -* - For each element of the returned array, the index view field is read-only and cannot be mutated. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ 1, 2, 3 ]; -* var fields = [ 'x', 'y' ]; -* -* var out = entries2views( x, fields ); -* // returns [ , , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 0, 'y': 1 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v2 = out[ 2 ].toJSON(); -* // returns { 'x': 2, 'y': 3 } -* -* // Mutate the input array: -* x[ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 0, 'y': 5 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 1, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ 5, 'beep', 3 ] -*/ -declare function entries2views( arr: Collection | AccessorArrayLike, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = entries2views; diff --git a/base/entries2views/docs/types/test.ts b/base/entries2views/docs/types/test.ts deleted file mode 100644 index d8d2b467e..000000000 --- a/base/entries2views/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import entries2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - entries2views( [ 1, 2, 3 ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - entries2views( 1, [ 'x', 'y' ] ); // $ExpectError - entries2views( true, [ 'x', 'y' ] ); // $ExpectError - entries2views( false, [ 'x', 'y' ] ); // $ExpectError - entries2views( null, [ 'x', 'y' ] ); // $ExpectError - entries2views( void 0, [ 'x', 'y' ] ); // $ExpectError - entries2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - entries2views( [], 1 ); // $ExpectError - entries2views( [], true ); // $ExpectError - entries2views( [], false ); // $ExpectError - entries2views( [], null ); // $ExpectError - entries2views( [], void 0 ); // $ExpectError - entries2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - entries2views(); // $ExpectError - entries2views( [] ); // $ExpectError - entries2views( [], [], [] ); // $ExpectError -} diff --git a/base/entries2views/examples/index.js b/base/entries2views/examples/index.js deleted file mode 100644 index 5eac35e77..000000000 --- a/base/entries2views/examples/index.js +++ /dev/null @@ -1,29 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var entries2views = require( './../lib' ); - -var x = discreteUniform( 10, -100, 100 ); -var fields = [ 'x', 'y' ]; - -var out = entries2views( x, fields ); -console.log( out ); -// => [...] diff --git a/base/entries2views/lib/index.js b/base/entries2views/lib/index.js deleted file mode 100644 index 76e6628f3..000000000 --- a/base/entries2views/lib/index.js +++ /dev/null @@ -1,67 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert array entries to an array of composite views. -* -* @module @stdlib/array/base/entries2views -* -* @example -* var entries2views = require( '@stdlib/array/base/entries2views' ); -* -* var x = [ 1, 2, 3 ]; -* var fields = [ 'x', 'y' ]; -* -* var out = entries2views( x, fields ); -* // returns [ , , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 0, 'y': 1 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v2 = out[ 2 ].toJSON(); -* // returns { 'x': 2, 'y': 3 } -* -* // Mutate the input array: -* x[ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 0, 'y': 5 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 1, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ 5, 'beep', 3 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/entries2views/lib/main.js b/base/entries2views/lib/main.js deleted file mode 100644 index cdc8428dc..000000000 --- a/base/entries2views/lib/main.js +++ /dev/null @@ -1,179 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils/define-read-only-accessor' ); -var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var accessors = require( './../../../base/accessors' ); - - -// MAIN // - -/** -* Converts array entries to an array of composite views. -* -* ## Notes -* -* - The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value. -* - For each element of the returned array, the index view field is read-only and cannot be mutated. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3 ]; -* var fields = [ 'x', 'y' ]; -* -* var out = entries2views( x, fields ); -* // returns [ , , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 0, 'y': 1 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v2 = out[ 2 ].toJSON(); -* // returns { 'x': 2, 'y': 3 } -* -* // Mutate the input array: -* x[ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 0, 'y': 5 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 1, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ 5, 'beep', 3 ] -*/ -function entries2views( arr, fields ) { - var fget; - var get; - var set; - var acc; - var out; - var N; - var k; - var v; - var i; - - N = arr.length; - if ( N < 1 ) { - return []; - } - // Resolve element accessors: - acc = accessors( arr ).accessors; - get = acc[ 0 ]; - set = acc[ 1 ]; - - // Cache field names: - fget = resolveGetter( fields ); - k = fget( fields, 0 ); - v = fget( fields, 1 ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( i ) { - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field: - setReadOnlyAccessor( Datum.prototype, k, getIndex ); - setReadWriteAccessor( Datum.prototype, v, getValue, setValue ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < N; i++ ) { - out.push( new Datum( i ) ); - } - return out; - - /** - * Returns the entry index. - * - * @private - * @returns {*} result - */ - function getIndex() { - return this._i; - } - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function getValue() { - return get( arr, this._i ); - } - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function setValue( value ) { - set( arr, this._i, value ); - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - - out = {}; - out[ k ] = this[ k ]; - out[ v ] = this[ v ]; - return out; - } -} - - -// EXPORTS // - -module.exports = entries2views; diff --git a/base/entries2views/package.json b/base/entries2views/package.json deleted file mode 100644 index 53d18fbb7..000000000 --- a/base/entries2views/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/entries2views", - "version": "0.0.0", - "description": "Convert array entries to an array of composite views.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "entries", - "object", - "tidy" - ] -} diff --git a/base/entries2views/test/test.js b/base/entries2views/test/test.js deleted file mode 100644 index 4968e3a71..000000000 --- a/base/entries2views/test/test.js +++ /dev/null @@ -1,213 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var entries2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof entries2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = entries2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts array entries to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ 1, 2 ]; - - actual = entries2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 0, - 'y': 1 - }, - { - 'x': 1, - 'y': 2 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts array entries to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ 1, 2 ]; - - actual = entries2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 0, - 'y': 1 - }, - { - 'x': 1, - 'y': 2 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ 1, 2 ]; - - actual = entries2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 0, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 1, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].y = 99; - - t.strictEqual( actual[ 0 ].x, 0, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 99, 'returns expected value' ); - - expected = [ -99, 99 ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ 1, 2 ]; - - actual = entries2views( toAccessorArray( x ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 0, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 1, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].y = 99; - - t.strictEqual( actual[ 0 ].x, 0, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 99, 'returns expected value' ); - - expected = [ -99, 99 ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views which throw an error when attempting to mutate the field corresponding to the element index (indexed)', function test( t ) { - var fields; - var out; - var x; - - fields = [ 'x', 'y' ]; - x = [ 1, 2 ]; - - out = entries2views( x, fields ); - t.throws( badOperation, Error, 'throws an error' ); - - t.end(); - - function badOperation() { - out[ 0 ].x = 10; - } -}); - -tape( 'the function returns views which throw an error when attempting to mutate the field corresponding to the element index (accessors)', function test( t ) { - var fields; - var out; - var x; - - fields = [ 'x', 'y' ]; - x = [ 1, 2 ]; - - out = entries2views( toAccessorArray( x ), toAccessorArray( fields ) ); - t.throws( badOperation, Error, 'throws an error' ); - - t.end(); - - function badOperation() { - out[ 0 ].x = 10; - } -}); diff --git a/base/every-by-right/README.md b/base/every-by-right/README.md deleted file mode 100644 index 373056069..000000000 --- a/base/every-by-right/README.md +++ /dev/null @@ -1,166 +0,0 @@ - - -# everyByRight - -> Test whether all elements in an array pass a test implemented by a predicate function, iterating from right to left. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var everyByRight = require( '@stdlib/array/base/every-by-right' ); -``` - -#### everyByRight( x, predicate\[, thisArg] ) - -Tests whether all elements in an array pass a test implemented by a `predicate` function, iterating from right to left. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 1, 2, 3, 4 ]; - -var bool = everyByRight( x, isPositive ); -// returns true -``` - -If a `predicate` function returns a non-truthy value, the function **immediately** returns `false`. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 1, -2, 3, 4 ]; - -var bool = everyByRight( x, isPositive ); -// returns false -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( value ) { - this.count += 1; - return ( value > 0 ); -} - -var x = [ 1, -2, 3, 4 ]; - -var context = { - 'count': 0 -}; - -var bool = everyByRight( x, predicate, context ); -// returns false - -var cnt = context.count; -// returns 3 -``` - -
- - - - - -
- -## Notes - -- The function performs a linear scan and returns immediately upon encountering a non-truthy return value. Unlike [`Array.prototype.every`][mdn-array-every], when performing a linear scan, the function does **not** skip `undefined` elements. -- If provided an empty array, the function returns `true`. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var everyByRight = require( '@stdlib/array/base/every-by-right' ); - -var x = discreteUniform( 10, 0, 10, { - 'dtype': 'int32' -}); -// returns - -var out = everyByRight( x, naryFunction( isPositiveInteger, 1 ) ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/every-by-right/benchmark/benchmark.length.js b/base/every-by-right/benchmark/benchmark.length.js deleted file mode 100644 index 422155e77..000000000 --- a/base/every-by-right/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var everyByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = everyByRight( x, isNonNegativeInteger ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/every-by-right/docs/repl.txt b/base/every-by-right/docs/repl.txt deleted file mode 100644 index a5b41c646..000000000 --- a/base/every-by-right/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Tests whether all elements in an array pass a test implemented by a - predicate function, iterating right to left. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - The function performs a linear scan and returns immediately upon - encountering a non-truthy return value. - - If provided an empty array, the function returns `true`. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - bool: boolean - The function returns `true` if the predicate function returns a truthy - value for all elements; otherwise, the function returns `false`. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x, f ) - true - - See Also - -------- - diff --git a/base/every-by-right/docs/types/index.d.ts b/base/every-by-right/docs/types/index.d.ts deleted file mode 100644 index 6eb73e976..000000000 --- a/base/every-by-right/docs/types/index.d.ts +++ /dev/null @@ -1,97 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function, iterating from right to left. -* -* ## Notes -* -* - The function immediately returns upon encountering a non-truthy return value. -* - If provided an empty collection, the function returns `true`. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns boolean indicating whether all elements pass a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = everyByRight( x, isPositive ); -* // returns true -*/ -declare function everyByRight( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - -// EXPORTS // - -export = everyByRight; diff --git a/base/every-by-right/docs/types/test.ts b/base/every-by-right/docs/types/test.ts deleted file mode 100644 index 9835432a2..000000000 --- a/base/every-by-right/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import everyByRight = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a boolean... -{ - everyByRight( [ 1, 2, 3 ], isPositive ); // $ExpectType boolean - everyByRight( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyByRight( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyByRight( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyByRight( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyByRight( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyByRight( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyByRight( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyByRight( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyByRight( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyByRight( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - - everyByRight( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType boolean - everyByRight( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyByRight( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyByRight( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyByRight( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyByRight( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyByRight( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyByRight( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyByRight( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyByRight( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyByRight( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - everyByRight( 2, isPositive ); // $ExpectError - everyByRight( false, isPositive ); // $ExpectError - everyByRight( true, isPositive ); // $ExpectError - everyByRight( {}, isPositive ); // $ExpectError - - everyByRight( 2, isPositive, {} ); // $ExpectError - everyByRight( false, isPositive, {} ); // $ExpectError - everyByRight( true, isPositive, {} ); // $ExpectError - everyByRight( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - everyByRight( [ 1, 2, 3 ], 'abc' ); // $ExpectError - everyByRight( [ 1, 2, 3 ], 2 ); // $ExpectError - everyByRight( [ 1, 2, 3 ], false ); // $ExpectError - everyByRight( [ 1, 2, 3 ], true ); // $ExpectError - everyByRight( [ 1, 2, 3 ], null ); // $ExpectError - everyByRight( [ 1, 2, 3 ], void 0 ); // $ExpectError - everyByRight( [ 1, 2, 3 ], {} ); // $ExpectError - everyByRight( [ 1, 2, 3 ], [] ); // $ExpectError - - everyByRight( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - everyByRight( [ 1, 2, 3 ], 2, {} ); // $ExpectError - everyByRight( [ 1, 2, 3 ], false, {} ); // $ExpectError - everyByRight( [ 1, 2, 3 ], true, {} ); // $ExpectError - everyByRight( [ 1, 2, 3 ], null, {} ); // $ExpectError - everyByRight( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - everyByRight( [ 1, 2, 3 ], {}, {} ); // $ExpectError - everyByRight( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - everyByRight(); // $ExpectError - everyByRight( [ 1, 2, 3 ] ); // $ExpectError - everyByRight( [ 1, 2, 3 ], isPositive, {}, 3 ); // $ExpectError -} diff --git a/base/every-by-right/examples/index.js b/base/every-by-right/examples/index.js deleted file mode 100644 index 73a0d1ac8..000000000 --- a/base/every-by-right/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var everyByRight = require( './../lib' ); - -var x = discreteUniform( 10, 0, 10, { - 'dtype': 'int32' -}); -// returns - -var out = everyByRight( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/every-by-right/lib/index.js b/base/every-by-right/lib/index.js deleted file mode 100644 index d379be03a..000000000 --- a/base/every-by-right/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Test whether all elements in an array pass a test implemented by a predicate function, iterating from right to left. -* -* @module @stdlib/array/base/every-by-right -* -* @example -* var everyByRight = require( '@stdlib/array/base/every-by-right' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = everyByRight( x, isPositive ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/every-by-right/lib/main.js b/base/every-by-right/lib/main.js deleted file mode 100644 index 486f749a6..000000000 --- a/base/every-by-right/lib/main.js +++ /dev/null @@ -1,127 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = internal( x, isPositive ); -* // returns true -*/ -function internal( x, predicate, thisArg ) { - var i; - for ( i = x.length-1; i >= 0; i-- ) { - if ( !predicate.call( thisArg, x[ i ], i, x ) ) { - return false; - } - } - return true; -} - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @private -* @param {Object} x - input array object -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) ); -* -* var out = accessors( x, isPositive ); -* // returns true -*/ -function accessors( x, predicate, thisArg ) { - var data; - var get; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - for ( i = data.length-1; i >= 0; i-- ) { - if ( !predicate.call( thisArg, get( data, i ), i, data ) ) { - return false; - } - } - return true; -} - - -// MAIN // - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function, iterating from right to left. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = everyByRight( x, isPositive ); -* // returns true -*/ -function everyByRight( x, predicate, thisArg ) { - var obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, predicate, thisArg ); - } - return internal( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = everyByRight; diff --git a/base/every-by-right/package.json b/base/every-by-right/package.json deleted file mode 100644 index dbd694f0b..000000000 --- a/base/every-by-right/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/every-by-right", - "version": "0.0.0", - "description": "Test whether all elements in an array pass a test implemented by a predicate function, iterating from right to left.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "predicate", - "every", - "all", - "array.every", - "validate" - ] -} diff --git a/base/every-by-right/test/test.js b/base/every-by-right/test/test.js deleted file mode 100644 index 629a6e69f..000000000 --- a/base/every-by-right/test/test.js +++ /dev/null @@ -1,252 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var everyByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Tests whether a value is positive. -* -* @private -* @param {number} value - input value -* @returns {boolean} boolean indicating if a value is positive -*/ -function isPositive( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof everyByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (generic)', function test( t ) { - var out; - var arr; - - arr = []; - out = everyByRight( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `true` (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [] ); - out = everyByRight( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `true` (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [] ); - out = everyByRight( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the function returns `true` if all elements pass a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, 2, 3 ]; - out = everyByRight( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements pass a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = everyByRight( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements pass a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 1, 2, 3 ] ); - out = everyByRight( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements pass a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - out = everyByRight( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements fail a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, -2, 3 ]; - out = everyByRight( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements fail a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 1.0, -2.0, 3.0 ] ); - out = everyByRight( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements fail a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 1, -2, 3 ] ); - out = everyByRight( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements fail a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': -2, - '2': 3 - }; - out = everyByRight( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var out; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = [ 1, 2, 3 ]; - out = everyByRight( arr, predicate, ctx ); - - t.strictEqual( out, true, 'returns expected value' ); - t.strictEqual( ctx.count, arr.length, 'returns expected value' ); - - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (generic)', function test( t ) { - var expected; - var out; - var arr; - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = everyByRight( arr, predicate ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return true; - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (accessor)', function test( t ) { - var expected; - var out; - var arr; - - arr = new AccessorArray( [ 1, , , 4 ] ); // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = everyByRight( arr, predicate ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return true; - } -}); diff --git a/base/every-by/README.md b/base/every-by/README.md deleted file mode 100644 index f39acb591..000000000 --- a/base/every-by/README.md +++ /dev/null @@ -1,173 +0,0 @@ - - -# everyBy - -> Test whether all elements in an array pass a test implemented by a predicate function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var everyBy = require( '@stdlib/array/base/every-by' ); -``` - -#### everyBy( x, predicate\[, thisArg] ) - -Tests whether all elements in an array pass a test implemented by a `predicate` function. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 1, 2, 3, 4 ]; - -var bool = everyBy( x, isPositive ); -// returns true -``` - -If a `predicate` function returns a non-truthy value, the function **immediately** returns `false`. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 1, -2, 3, 4 ]; - -var bool = everyBy( x, isPositive ); -// returns false -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( value ) { - this.count += 1; - return ( value > 0 ); -} - -var x = [ 1, 2, -3, 4 ]; - -var context = { - 'count': 0 -}; - -var bool = everyBy( x, predicate, context ); -// returns false - -var cnt = context.count; -// returns 3 -``` - -
- - - - - -
- -## Notes - -- If provided an array-like object having an `every` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.every( predicate, thisArg ) - ``` - -- If provided an array-like object without an `every` method, the function performs a linear scan and returns immediately upon encountering a non-truthy return value. Unlike [`Array.prototype.every`][mdn-array-every], when performing a linear scan, the function does **not** skip `undefined` elements. - -- If provided an empty array, the function returns `true`. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var everyBy = require( '@stdlib/array/base/every-by' ); - -var x = discreteUniform( 10, 0, 10, { - 'dtype': 'int32' -}); -// returns - -var out = everyBy( x, naryFunction( isPositiveInteger, 1 ) ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/every-by/benchmark/benchmark.length.js b/base/every-by/benchmark/benchmark.length.js deleted file mode 100644 index 9f7cb2ba5..000000000 --- a/base/every-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var everyBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = everyBy( x, isNonNegativeInteger ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/every-by/docs/repl.txt b/base/every-by/docs/repl.txt deleted file mode 100644 index 0b7f3a179..000000000 --- a/base/every-by/docs/repl.txt +++ /dev/null @@ -1,50 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Tests whether all elements in an array pass a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - If provided an array-like object having an `every` method , the function - defers execution to that method and assumes that the method has the - following signature: - - x.every( predicate, thisArg ) - - If provided an array-like object without an `every` method, the function - performs a linear scan and returns immediately upon encountering a - non-truthy return value. - - If provided an empty array, the function returns `true`. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - bool: boolean - The function returns `true` if the predicate function returns a truthy - value for all elements; otherwise, the function returns `false`. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x, f ) - true - - See Also - -------- - diff --git a/base/every-by/docs/types/index.d.ts b/base/every-by/docs/types/index.d.ts deleted file mode 100644 index 785109982..000000000 --- a/base/every-by/docs/types/index.d.ts +++ /dev/null @@ -1,97 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* ## Notes -* -* - The function immediately returns upon encountering a non-truthy return value. -* - If provided an empty collection, the function returns `true`. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns boolean indicating whether all elements pass a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = everyBy( x, isPositive ); -* // returns true -*/ -declare function everyBy( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - -// EXPORTS // - -export = everyBy; diff --git a/base/every-by/docs/types/test.ts b/base/every-by/docs/types/test.ts deleted file mode 100644 index d8870aa31..000000000 --- a/base/every-by/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import everyBy = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a boolean... -{ - everyBy( [ 1, 2, 3 ], isPositive ); // $ExpectType boolean - everyBy( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyBy( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyBy( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyBy( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyBy( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyBy( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyBy( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyBy( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyBy( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - everyBy( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - - everyBy( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType boolean - everyBy( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyBy( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyBy( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyBy( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyBy( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyBy( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyBy( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyBy( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyBy( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - everyBy( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - everyBy( 2, isPositive ); // $ExpectError - everyBy( false, isPositive ); // $ExpectError - everyBy( true, isPositive ); // $ExpectError - everyBy( {}, isPositive ); // $ExpectError - - everyBy( 2, isPositive, {} ); // $ExpectError - everyBy( false, isPositive, {} ); // $ExpectError - everyBy( true, isPositive, {} ); // $ExpectError - everyBy( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - everyBy( [ 1, 2, 3 ], 'abc' ); // $ExpectError - everyBy( [ 1, 2, 3 ], 2 ); // $ExpectError - everyBy( [ 1, 2, 3 ], false ); // $ExpectError - everyBy( [ 1, 2, 3 ], true ); // $ExpectError - everyBy( [ 1, 2, 3 ], null ); // $ExpectError - everyBy( [ 1, 2, 3 ], void 0 ); // $ExpectError - everyBy( [ 1, 2, 3 ], {} ); // $ExpectError - everyBy( [ 1, 2, 3 ], [] ); // $ExpectError - - everyBy( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - everyBy( [ 1, 2, 3 ], 2, {} ); // $ExpectError - everyBy( [ 1, 2, 3 ], false, {} ); // $ExpectError - everyBy( [ 1, 2, 3 ], true, {} ); // $ExpectError - everyBy( [ 1, 2, 3 ], null, {} ); // $ExpectError - everyBy( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - everyBy( [ 1, 2, 3 ], {}, {} ); // $ExpectError - everyBy( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - everyBy(); // $ExpectError - everyBy( [ 1, 2, 3 ] ); // $ExpectError - everyBy( [ 1, 2, 3 ], isPositive, {}, 3 ); // $ExpectError -} diff --git a/base/every-by/examples/index.js b/base/every-by/examples/index.js deleted file mode 100644 index ad64857c1..000000000 --- a/base/every-by/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var everyBy = require( './../lib' ); - -var x = discreteUniform( 10, 0, 10, { - 'dtype': 'int32' -}); -// returns - -var out = everyBy( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/every-by/lib/index.js b/base/every-by/lib/index.js deleted file mode 100644 index 23798a3c5..000000000 --- a/base/every-by/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Test whether all elements in an array pass a test implemented by a predicate function. -* -* @module @stdlib/array/base/every-by -* -* @example -* var everyBy = require( '@stdlib/array/base/every-by' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = everyBy( x, isPositive ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/every-by/lib/main.js b/base/every-by/lib/main.js deleted file mode 100644 index daa0104fe..000000000 --- a/base/every-by/lib/main.js +++ /dev/null @@ -1,151 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'every' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = internal( x, isPositive ); -* // returns true -*/ -function internal( x, predicate, thisArg ) { - var i; - for ( i = 0; i < x.length; i++ ) { - if ( !predicate.call( thisArg, x[ i ], i, x ) ) { - return false; - } - } - return true; -} - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @private -* @param {Object} x - input array object -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) ); -* -* var out = accessors( x, isPositive ); -* // returns true -*/ -function accessors( x, predicate, thisArg ) { - var data; - var get; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - for ( i = 0; i < data.length; i++ ) { - if ( !predicate.call( thisArg, get( data, i ), i, data ) ) { - return false; - } - } - return true; -} - - -// MAIN // - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = everyBy( x, isPositive ); -* // returns true -*/ -function everyBy( x, predicate, thisArg ) { - var obj; - if ( hasMethod( x, 'every' ) ) { - return x.every( predicate, thisArg ); - } - obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, predicate, thisArg ); - } - return internal( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = everyBy; diff --git a/base/every-by/package.json b/base/every-by/package.json deleted file mode 100644 index 169c0016a..000000000 --- a/base/every-by/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/every-by", - "version": "0.0.0", - "description": "Test whether all elements in an array pass a test implemented by a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "predicate", - "every", - "all", - "array.every", - "validate" - ] -} diff --git a/base/every-by/test/test.js b/base/every-by/test/test.js deleted file mode 100644 index 711a0b0e7..000000000 --- a/base/every-by/test/test.js +++ /dev/null @@ -1,252 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var everyBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Tests whether a value is positive. -* -* @private -* @param {number} value - input value -* @returns {boolean} boolean indicating if a value is positive -*/ -function isPositive( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof everyBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (generic)', function test( t ) { - var out; - var arr; - - arr = []; - out = everyBy( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `true` (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [] ); - out = everyBy( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `true` (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [] ); - out = everyBy( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the function returns `true` if all elements pass a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, 2, 3 ]; - out = everyBy( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements pass a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = everyBy( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements pass a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 1, 2, 3 ] ); - out = everyBy( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements pass a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - out = everyBy( arr, isPositive ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements fail a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, -2, 3 ]; - out = everyBy( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements fail a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 1.0, -2.0, 3.0 ] ); - out = everyBy( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements fail a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 1, -2, 3 ] ); - out = everyBy( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements fail a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': -2, - '2': 3 - }; - out = everyBy( arr, isPositive ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var out; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = [ 1, 2, 3 ]; - out = everyBy( arr, predicate, ctx ); - - t.strictEqual( out, true, 'returns expected value' ); - t.strictEqual( ctx.count, arr.length, 'returns expected value' ); - - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (generic)', function test( t ) { - var expected; - var out; - var arr; - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = everyBy( arr, predicate ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return true; - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (accessor)', function test( t ) { - var expected; - var out; - var arr; - - arr = new AccessorArray( [ 1, , , 4 ] ); // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = everyBy( arr, predicate ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return true; - } -}); diff --git a/base/every/README.md b/base/every/README.md deleted file mode 100644 index 183aeff7a..000000000 --- a/base/every/README.md +++ /dev/null @@ -1,118 +0,0 @@ - - -# every - -> Test whether all elements in an array are truthy. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var every = require( '@stdlib/array/base/every' ); -``` - -#### every( x ) - -Tests whether all elements in an array are truthy. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var bool = every( x ); -// returns true -``` - -
- - - - - -
- -## Notes - -- If provided an empty array, the function returns `true`. -- The function does **not** skip `undefined` elements and is thus not optimized for sparse arrays. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var every = require( '@stdlib/array/base/every' ); - -var x = discreteUniform( 10, 0, 10, { - 'dtype': 'int32' -}); -// returns - -var out = every( x ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/every/benchmark/benchmark.length.js b/base/every/benchmark/benchmark.length.js deleted file mode 100644 index 22fd6ba0a..000000000 --- a/base/every/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var oneTo = require( './../../../base/one-to' ); -var pkg = require( './../package.json' ).name; -var every = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = oneTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = every( x ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/every/docs/repl.txt b/base/every/docs/repl.txt deleted file mode 100644 index 6a6d0a38b..000000000 --- a/base/every/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( x ) - Tests whether all elements in an array are truthy. - - The function returns immediately upon encountering a non-truthy value. - - If provided an empty array, the function returns `true`. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - Returns - ------- - bool: boolean - The function returns `true` if all elements are truthy; otherwise, the - function returns `false`. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ) - true - - See Also - -------- - diff --git a/base/every/docs/types/index.d.ts b/base/every/docs/types/index.d.ts deleted file mode 100644 index 4c5da577f..000000000 --- a/base/every/docs/types/index.d.ts +++ /dev/null @@ -1,47 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Tests whether all elements in an array are truthy. -* -* ## Notes -* -* - The function immediately returns upon encountering a non-truthy value. -* - If provided an empty collection, the function returns `true`. -* -* @param x - input array -* @returns boolean indicating whether all elements are truthy -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = every( x ); -* // returns true -*/ -declare function every( x: Collection | AccessorArrayLike ): boolean; - - -// EXPORTS // - -export = every; diff --git a/base/every/docs/types/test.ts b/base/every/docs/types/test.ts deleted file mode 100644 index fa0b1d49b..000000000 --- a/base/every/docs/types/test.ts +++ /dev/null @@ -1,52 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import every = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - every( [ 1, 2, 3 ] ); // $ExpectType boolean - every( new Float64Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - every( new Float32Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - every( new Int32Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - every( new Int16Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - every( new Int8Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - every( new Uint32Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - every( new Uint16Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - every( new Uint8Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - every( new Uint8ClampedArray( [ 1, 2, 3 ] ) ); // $ExpectType boolean - every( toAccessorArray( [ 1, 2, 3 ] ) ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - every( 2 ); // $ExpectError - every( false ); // $ExpectError - every( true ); // $ExpectError - every( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - every(); // $ExpectError - every( [ 1, 2, 3 ], {}, 3 ); // $ExpectError -} diff --git a/base/every/examples/index.js b/base/every/examples/index.js deleted file mode 100644 index a455a388d..000000000 --- a/base/every/examples/index.js +++ /dev/null @@ -1,33 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var every = require( './../lib' ); - -var x = discreteUniform( 10, 0, 10, { - 'dtype': 'int32' -}); -// returns - -var out = every( x ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/every/lib/index.js b/base/every/lib/index.js deleted file mode 100644 index b93543631..000000000 --- a/base/every/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Test whether all elements in an array are truthy. -* -* @module @stdlib/array/base/every -* -* @example -* var every = require( '@stdlib/array/base/every' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = every( x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/every/lib/main.js b/base/every/lib/main.js deleted file mode 100644 index b65c31ea8..000000000 --- a/base/every/lib/main.js +++ /dev/null @@ -1,182 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplex128Array = require( './../../../base/assert/is-complex128array' ); -var isComplex64Array = require( './../../../base/assert/is-complex64array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Tests whether all elements in an array are truthy. -* -* @private -* @param {Collection} x - input array -* @returns {boolean} boolean indicating whether all elements are truthy -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = internal( x ); -* // returns true -* -* @example -* var x = [ 1, 2, 0, 4 ]; -* -* var out = internal( x ); -* // returns false -*/ -function internal( x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - if ( !x[ i ] ) { - return false; - } - } - return true; -} - -/** -* Tests whether all elements in a complex number array are truthy. -* -* @private -* @param {Collection} x - underlying data buffer -* @returns {boolean} boolean indicating whether all elements are truthy -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = internalComplex( x ); -* // returns true -* -* @example -* var x = [ 1, 2, 0, 4 ]; -* -* var out = internalComplex( x ); -* // returns true -* -* @example -* var x = [ 1, 2, 0, 0 ]; -* -* var out = internalComplex( x ); -* // returns false -*/ -function internalComplex( x ) { - var i; - for ( i = 0; i < x.length; i += 2 ) { - if ( !( x[ i ] || x[ i+1 ] ) ) { - return false; - } - } - return true; -} - -/** -* Tests whether all elements in an array are truthy. -* -* @private -* @param {Object} x - input array object -* @returns {boolean} boolean indicating whether all elements are truthy -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) ); -* -* var out = accessors( x ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 1, 2, 0, 4 ] ) ); -* -* var out = accessors( x ); -* // returns false -*/ -function accessors( x ) { - var data; - var get; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - for ( i = 0; i < data.length; i++ ) { - if ( !get( data, i ) ) { - return false; - } - } - return true; -} - - -// MAIN // - -/** -* Tests whether all elements in an array are truthy. -* -* @param {Collection} x - input array -* @returns {boolean} boolean indicating whether all elements are truthy -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = every( x ); -* // returns true -* -* @example -* var x = [ 1, 2, 0, 4 ]; -* -* var out = every( x ); -* // returns false -*/ -function every( x ) { - var obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - // If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero... - if ( isComplex128Array( x ) ) { - return internalComplex( reinterpret128( x, 0 ) ); - } - if ( isComplex64Array( x ) ) { - return internalComplex( reinterpret64( x, 0 ) ); - } - // If provided a boolean array, reinterpret as a typed array and test each element... - if ( isBooleanArray( x ) ) { - return internal( reinterpretBoolean( x, 0 ) ); - } - return accessors( obj ); - } - return internal( x ); -} - - -// EXPORTS // - -module.exports = every; diff --git a/base/every/package.json b/base/every/package.json deleted file mode 100644 index d41ec59d0..000000000 --- a/base/every/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/every", - "version": "0.0.0", - "description": "Test whether all elements in an array are truthy.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "every", - "all", - "array.every", - "validate" - ] -} diff --git a/base/every/test/test.js b/base/every/test/test.js deleted file mode 100644 index b433bca76..000000000 --- a/base/every/test/test.js +++ /dev/null @@ -1,272 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Complex64Array = require( './../../../complex64' ); -var Complex128Array = require( './../../../complex128' ); -var BooleanArray = require( './../../../bool' ); -var every = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof every, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (generic)', function test( t ) { - var out; - var arr; - - arr = []; - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (real typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [] ); - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (complex typed array)', function test( t ) { - var out; - var arr; - - arr = new Complex64Array( [] ); - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - - arr = new Complex128Array( [] ); - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (boolean array)', function test( t ) { - var out; - var arr; - - arr = new BooleanArray( [] ); - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [] ); - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are truthy (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, 2, 3 ]; - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are truthy (real typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are truthy (complex typed array)', function test( t ) { - var out; - var arr; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are truthy (boolean array)', function test( t ) { - var out; - var arr; - - arr = new BooleanArray( [ true, true, true, true ] ); - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are truthy (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 1, 2, 3 ] ); - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are truthy (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - out = every( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are falsy (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, 0, 3 ]; - out = every( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are falsy (real typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 1.0, 0.0, 3.0 ] ); - out = every( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are falsy (complex typed array)', function test( t ) { - var out; - var arr; - - arr = new Complex64Array( [ 1.0, 2.0, 0.0, 0.0 ] ); - out = every( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - - arr = new Complex128Array( [ 0.0, 0.0, 3.0, 4.0 ] ); - out = every( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are falsy (boolean array)', function test( t ) { - var out; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - out = every( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are falsy (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 1, 0, 3 ] ); - out = every( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are falsy (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': 0, - '2': 3 - }; - out = every( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - out = every( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 1, , , 4 ] ); // eslint-disable-line no-sparse-arrays - out = every( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); diff --git a/base/examples/index.js b/base/examples/index.js deleted file mode 100644 index 8f80e7617..000000000 --- a/base/examples/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var ns = require( './../lib' ); - -// Create a zero-filled array: -var zeros = ns.zeros( 5 ); -console.log( zeros ); -// => [ 0, 0, 0, 0, 0 ] - -// Create an array filled with a specific value: -var filled = ns.filled( 7, 4 ); -console.log( filled ); -// => [ 7, 7, 7, 7 ] - -// Create a linearly spaced array: -var linear = ns.linspace( 0, 1, 5 ); -console.log( linear ); -// => [ 0, 0.25, 0.5, 0.75, 1 ] - -// Create a two-dimensional array: -var arr2d = ns.ones2d( [ 2, 3 ] ); -console.log( arr2d ); -// => [ [ 1, 1, 1 ], [ 1, 1, 1 ] ] - -// Map a function over a 2D array: -var squared = ns.map2d( arr2d, [ 2, 3 ], randu ); -console.log( squared ); -// e.g., => [ [ ~0.123, ~0.789, ~0.456 ], [ ~0.321, ~0.654, ~0.987 ] ] diff --git a/base/fancy-slice-assign/README.md b/base/fancy-slice-assign/README.md deleted file mode 100644 index 99b8d8c82..000000000 --- a/base/fancy-slice-assign/README.md +++ /dev/null @@ -1,202 +0,0 @@ - - -# sliceAssign - -> Assign element values from a broadcasted input array to corresponding elements in an output array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var sliceAssign = require( '@stdlib/array/base/fancy-slice-assign' ); -``` - -#### slice( x, y, s, strict ) - -Assigns element values from a broadcasted input array to corresponding elements in an output array. - -```javascript -var Slice = require( '@stdlib/slice/ctor' ); - -var x = [ 1, 2, 3, 4 ]; -var y = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - -var s = new Slice( null, null, -2 ); -// returns - -var out = sliceAssign( x, y, s, false ); -// returns [ 0, 4, 0, 3, 0, 2, 0, 1 ] - -var bool = ( out === y ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **y**: output array. -- **s**: [slice][@stdlib/slice/ctor] object specifying the output array slice. -- **strict**: boolean indicating whether to enforce strict bounds checking. - -
- - - - - -
- -## Notes - -- The input array **must** be broadcast compatible with the output array slice (i.e., contain only one element or the same number of elements as in the slice). -- The input array must have a [data type][@stdlib/array/dtypes] which can be [safely cast][@stdlib/array/safe-casts] to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the [same kind][@stdlib/array/same-kind-casts] (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). - -
- - - - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/zero-to' ); -var zeros = require( '@stdlib/array/zeros' ); -var Slice = require( '@stdlib/slice/ctor' ); -var sliceAssign = require( '@stdlib/array/base/fancy-slice-assign' ); - -var x = zeroTo( 10, 'generic' ); -// returns [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -var y = zeros( 10, 'generic' ); -// returns [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] - -var s = new Slice(); -var out = sliceAssign( x, y, s, false ); -// returns [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -x = zeroTo( 5, 'generic' ); -// returns [ 0, 1, 2, 3, 4 ] - -y = zeros( 10, 'generic' ); -s = new Slice( null, null, -2 ); -out = sliceAssign( x, y, s, false ); -// returns [ 0, 4, 0, 3, 0, 2, 0, 1, 0, 0 ] - -x = zeroTo( 5, 'generic' ); -// returns [ 0, 1, 2, 3, 4 ] - -y = zeros( 10, 'generic' ); -s = new Slice( -2, null, -2 ); -out = sliceAssign( x, y, s, false ); -// returns [ 4, 0, 3, 0, 2, 0, 1, 0, 0, 0 ] - -x = zeroTo( 6, 'generic' ); -// returns [ 0, 1, 2, 3, 4, 5 ] - -y = zeros( 10, 'generic' ); -s = new Slice( 2, -2 ); -out = sliceAssign( x, y, s, false ); -// returns [ 0, 0, 0, 1, 2, 3, 4, 5, 0, 0 ] - -x = zeroTo( 3, 'generic' ); -// returns [ 0, 1, 2 ] - -y = zeros( 10, 'generic' ); -s = new Slice( 2, 5 ); -out = sliceAssign( x, y, s, false ); -// returns [ 0, 0, 0, 1, 2, 0, 0, 0, 0, 0 ] - -x = zeroTo( 3, 'generic' ); -// returns [ 0, 1, 2 ] - -y = zeros( 10, 'generic' ); -s = new Slice( 4, 1, -1 ); -out = sliceAssign( x, y, s, false ); -// returns [ 0, 0, 2, 1, 0, 0, 0, 0, 0, 0 ] - -x = zeroTo( 5, 'generic' ); -// returns [ 0, 1, 2, 3, 4 ] - -y = zeros( 10, 'generic' ); -s = new Slice( 5 ); -out = sliceAssign( x, y, s, false ); -// returns [ 0, 1, 2, 3, 4, 0, 0, 0, 0, 0 ] - -x = zeroTo( 5, 'generic' ); -// returns [ 0, 1, 2, 3, 4 ] - -y = zeros( 10, 'generic' ); -s = new Slice( 5, null ); -out = sliceAssign( x, y, s, false ); -// returns [ 0, 0, 0, 0, 0, 0, 1, 2, 3, 4 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/fancy-slice-assign/benchmark/benchmark.float64.js b/base/fancy-slice-assign/benchmark/benchmark.float64.js deleted file mode 100644 index def1ee7fa..000000000 --- a/base/fancy-slice-assign/benchmark/benchmark.float64.js +++ /dev/null @@ -1,108 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isnan = require( '@stdlib/assert/is-nan' ).isPrimitive; -var zeroTo = require( './../../../zero-to' ); -var zeros = require( './../../../zeros' ); -var Slice = require( '@stdlib/slice/ctor' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len, 'float64' ); - var y = zeros( len, 'float64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - new Slice(), - new Slice(), - new Slice() - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = sliceAssign( x, y, values[ i%values.length ], false ); - v = out[ i%len ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( out[ i%len ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/base/fancy-slice-assign/benchmark/benchmark.generic.js b/base/fancy-slice-assign/benchmark/benchmark.generic.js deleted file mode 100644 index 18fafea91..000000000 --- a/base/fancy-slice-assign/benchmark/benchmark.generic.js +++ /dev/null @@ -1,108 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isnan = require( '@stdlib/assert/is-nan' ).isPrimitive; -var zeroTo = require( './../../../zero-to' ); -var zeros = require( './../../../zeros' ); -var Slice = require( '@stdlib/slice/ctor' ); -var pkg = require( './../package.json' ).name; -var sliceAssign = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len, 'generic' ); - var y = zeros( len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var v; - var i; - - values = [ - new Slice(), - new Slice(), - new Slice() - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = sliceAssign( x, y, values[ i%values.length ], false ); - v = out[ i%len ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( out[ i%len ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/fancy-slice-assign/docs/repl.txt b/base/fancy-slice-assign/docs/repl.txt deleted file mode 100644 index c2586e35b..000000000 --- a/base/fancy-slice-assign/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( x, y, s, strict ) - Assigns element values from a broadcasted input array to corresponding - elements in an output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. The input array must be broadcast compatible with the - output array and must have a data type which can be safely cast to the - output array data type. Floating-point data types (both real and - complex) are allowed to downcast to a lower precision data type of the - same kind (e.g., element values from a 'float64' input array can be - assigned to corresponding elements in a 'float32' output array). - - y: ArrayLikeObject - Output array. - - s: Slice - Slice object. - - strict: boolean - Boolean indicating whether to enforce strict bounds checking. - - Returns - ------- - out: Array|TypedArray|Object - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - > var s = new {{alias:@stdlib/slice/ctor}}( null, null, 2 ); - > var out = {{alias}}( x, y, s, false ) - [ 1, 0, 2, 0, 3, 0, 4, 0 ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/base/fancy-slice-assign/docs/types/index.d.ts b/base/fancy-slice-assign/docs/types/index.d.ts deleted file mode 100644 index dd0149a7c..000000000 --- a/base/fancy-slice-assign/docs/types/index.d.ts +++ /dev/null @@ -1,475 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex128Array, Complex64Array, ComplexTypedArray, AccessorArrayLike } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; -import { Slice } from '@stdlib/types/slice'; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* var y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0.0, 4.0, 0.0, 3.0, 0.0, 2.0, 0.0, 1.0 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection | AccessorArrayLike, y: Float64Array, s: Slice, strict: boolean ): Float64Array; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* var y = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0.0, 4.0, 0.0, 3.0, 0.0, 2.0, 0.0, 1.0 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection | AccessorArrayLike, y: Float32Array, s: Slice, strict: boolean ): Float32Array; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var y = new Int32Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0, 4, 0, 3, 0, 2, 0, 1 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection | AccessorArrayLike, y: Int32Array, s: Slice, strict: boolean ): Int32Array; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var y = new Int16Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0, 4, 0, 3, 0, 2, 0, 1 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection | AccessorArrayLike, y: Int16Array, s: Slice, strict: boolean ): Int16Array; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var y = new Int8Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0, 4, 0, 3, 0, 2, 0, 1 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection | AccessorArrayLike, y: Int8Array, s: Slice, strict: boolean ): Int8Array; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var y = new Uint32Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0, 4, 0, 3, 0, 2, 0, 1 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection | AccessorArrayLike, y: Uint32Array, s: Slice, strict: boolean ): Uint32Array; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var y = new Uint16Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0, 4, 0, 3, 0, 2, 0, 1 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection | AccessorArrayLike, y: Uint16Array, s: Slice, strict: boolean ): Uint16Array; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var y = new Uint8Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0, 4, 0, 3, 0, 2, 0, 1 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection | AccessorArrayLike, y: Uint8Array, s: Slice, strict: boolean ): Uint8Array; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var y = new Uint8ClampedArray( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0, 4, 0, 3, 0, 2, 0, 1 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection | AccessorArrayLike, y: Uint8ClampedArray, s: Slice, strict: boolean ): Uint8ClampedArray; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* var y = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -* -* var s = new Slice( null, null, 2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ComplexTypedArray | AccessorArrayLike, y: Complex128Array, s: Slice, strict: boolean ): Complex128Array; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* var y = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -* -* var s = new Slice( null, null, 2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: ComplexTypedArray | AccessorArrayLike, y: Complex64Array, s: Slice, strict: boolean ): Complex64Array; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; -* -* var s = new Slice( null, null, 2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 1, 0, 2, 0, 3, 0, 4, 0 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection, y: Array, s: Slice, strict: boolean ): Array; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var Slice = require( '@stdlib/slice/ctor' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var y = toAccessorArray( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); -* -* var s = new Slice( null, null, 2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection | AccessorArrayLike, y: AccessorArrayLike, s: Slice, strict: boolean ): AccessorArrayLike; - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* ## Notes -* -* - The input array must be broadcast compatible with the output array slice to which elements will be assigned (i.e., contain only one element or the same number of elements as in the slice). -* - The input array must have a data type which can be safely cast to the output array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the same kind (e.g., element values from a `'float64'` input array can be assigned to corresponding elements in a `'float32'` output array). -* -* @param x - input array -* @param y - output array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; -* -* var s = new Slice( null, null, 2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 1, 0, 2, 0, 3, 0, 4, 0 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare function sliceAssign( x: Collection, y: Collection, s: Slice, strict: boolean ): Collection; - - -// EXPORTS // - -export = sliceAssign; diff --git a/base/fancy-slice-assign/docs/types/test.ts b/base/fancy-slice-assign/docs/types/test.ts deleted file mode 100644 index 7aeeebabf..000000000 --- a/base/fancy-slice-assign/docs/types/test.ts +++ /dev/null @@ -1,102 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import Slice = require( '@stdlib/slice/ctor' ); -import sliceAssign = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - sliceAssign( [ 1, 2, 3 ], [ 1, 2, 3 ], new Slice(), false ); // $ExpectType number[] - sliceAssign( new Float64Array( [ 1, 2, 3 ] ), new Float64Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Float64Array - sliceAssign( new Float32Array( [ 1, 2, 3 ] ), new Float32Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Float32Array - sliceAssign( new Int32Array( [ 1, 2, 3 ] ), new Int32Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Int32Array - sliceAssign( new Int16Array( [ 1, 2, 3 ] ), new Int16Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Int16Array - sliceAssign( new Int8Array( [ 1, 2, 3 ] ), new Int8Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Int8Array - sliceAssign( new Uint32Array( [ 1, 2, 3 ] ), new Uint32Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Uint32Array - sliceAssign( new Uint16Array( [ 1, 2, 3 ] ), new Uint16Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Uint16Array - sliceAssign( new Uint8Array( [ 1, 2, 3 ] ), new Uint8Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Uint8Array - sliceAssign( new Uint8ClampedArray( [ 1, 2, 3 ] ), new Uint8ClampedArray( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Uint8ClampedArray - sliceAssign( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), new Slice(), false ); // $ExpectType Complex128Array - sliceAssign( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), new Slice(), false ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - sliceAssign( 5, [ 1, 2, 3 ], new Slice(), false ); // $ExpectError - sliceAssign( true, [ 1, 2, 3 ], new Slice(), false ); // $ExpectError - sliceAssign( false, [ 1, 2, 3 ], new Slice(), false ); // $ExpectError - sliceAssign( null, [ 1, 2, 3 ], new Slice(), false ); // $ExpectError - sliceAssign( void 0, [ 1, 2, 3 ], new Slice(), false ); // $ExpectError - sliceAssign( {}, [ 1, 2, 3 ], new Slice(), false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - sliceAssign( x, 5, new Slice(), false ); // $ExpectError - sliceAssign( x, true, new Slice(), false ); // $ExpectError - sliceAssign( x, false, new Slice(), false ); // $ExpectError - sliceAssign( x, null, new Slice(), false ); // $ExpectError - sliceAssign( x, void 0, new Slice(), false ); // $ExpectError - sliceAssign( x, {}, new Slice(), false ); // $ExpectError - sliceAssign( x, ( x: number ): number => x, new Slice(), false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a slice object... -{ - const x = [ 1, 2, 3 ]; - - sliceAssign( x, x, '5', false ); // $ExpectError - sliceAssign( x, x, true, false ); // $ExpectError - sliceAssign( x, x, false, false ); // $ExpectError - sliceAssign( x, x, null, false ); // $ExpectError - sliceAssign( x, x, void 0, false ); // $ExpectError - sliceAssign( x, x, {}, false ); // $ExpectError - sliceAssign( x, x, [], false ); // $ExpectError - sliceAssign( x, x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a boolean... -{ - const x = [ 1, 2, 3 ]; - - sliceAssign( x, x, new Slice(), '5' ); // $ExpectError - sliceAssign( x, x, new Slice(), 5 ); // $ExpectError - sliceAssign( x, x, new Slice(), null ); // $ExpectError - sliceAssign( x, x, new Slice(), void 0 ); // $ExpectError - sliceAssign( x, x, new Slice(), {} ); // $ExpectError - sliceAssign( x, x, new Slice(), [] ); // $ExpectError - sliceAssign( x, x, new Slice(), ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - sliceAssign(); // $ExpectError - sliceAssign( x ); // $ExpectError - sliceAssign( x, x ); // $ExpectError - sliceAssign( x, x, new Slice() ); // $ExpectError - sliceAssign( x, x, new Slice(), false, {} ); // $ExpectError -} diff --git a/base/fancy-slice-assign/examples/index.js b/base/fancy-slice-assign/examples/index.js deleted file mode 100644 index 712b99ec5..000000000 --- a/base/fancy-slice-assign/examples/index.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -var zeroTo = require( './../../../zero-to' ); -var zeros = require( './../../../zeros' ); -var Slice = require( '@stdlib/slice/ctor' ); -var sliceAssign = require( './../lib' ); - -var x = zeroTo( 10, 'generic' ); -// returns [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -var y = zeros( 10, 'generic' ); -// returns [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] - -var s = new Slice(); -var out = sliceAssign( x, y, s, false ); -console.log( out ); -// => [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -x = zeroTo( 5, 'generic' ); -// returns [ 0, 1, 2, 3, 4 ] - -y = zeros( 10, 'generic' ); -s = new Slice( null, null, -2 ); -out = sliceAssign( x, y, s, false ); -console.log( out ); -// => [ 0, 4, 0, 3, 0, 2, 0, 1, 0, 0 ] - -x = zeroTo( 5, 'generic' ); -// returns [ 0, 1, 2, 3, 4 ] - -y = zeros( 10, 'generic' ); -s = new Slice( -2, null, -2 ); -out = sliceAssign( x, y, s, false ); -console.log( out ); -// => [ 4, 0, 3, 0, 2, 0, 1, 0, 0, 0 ] - -x = zeroTo( 6, 'generic' ); -// returns [ 0, 1, 2, 3, 4, 5 ] - -y = zeros( 10, 'generic' ); -s = new Slice( 2, -2 ); -out = sliceAssign( x, y, s, false ); -console.log( out ); -// => [ 0, 0, 0, 1, 2, 3, 4, 5, 0, 0 ] - -x = zeroTo( 3, 'generic' ); -// returns [ 0, 1, 2 ] - -y = zeros( 10, 'generic' ); -s = new Slice( 2, 5 ); -out = sliceAssign( x, y, s, false ); -console.log( out ); -// => [ 0, 0, 0, 1, 2, 0, 0, 0, 0, 0 ] - -x = zeroTo( 3, 'generic' ); -// returns [ 0, 1, 2 ] - -y = zeros( 10, 'generic' ); -s = new Slice( 4, 1, -1 ); -out = sliceAssign( x, y, s, false ); -console.log( out ); -// => [ 0, 0, 2, 1, 0, 0, 0, 0, 0, 0 ] - -x = zeroTo( 5, 'generic' ); -// returns [ 0, 1, 2, 3, 4 ] - -y = zeros( 10, 'generic' ); -s = new Slice( 5 ); -out = sliceAssign( x, y, s, false ); -console.log( out ); -// => [ 0, 1, 2, 3, 4, 0, 0, 0, 0, 0 ] - -x = zeroTo( 5, 'generic' ); -// returns [ 0, 1, 2, 3, 4 ] - -y = zeros( 10, 'generic' ); -s = new Slice( 5, null ); -out = sliceAssign( x, y, s, false ); -console.log( out ); -// => [ 0, 0, 0, 0, 0, 0, 1, 2, 3, 4 ] diff --git a/base/fancy-slice-assign/lib/index.js b/base/fancy-slice-assign/lib/index.js deleted file mode 100644 index b02b99985..000000000 --- a/base/fancy-slice-assign/lib/index.js +++ /dev/null @@ -1,67 +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. -*/ - -'use strict'; - -/** -* Assign element values from a broadcasted input array to corresponding elements in an output array. -* -* @module @stdlib/array/base/fancy-slice-assign -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var sliceAssign = require( '@stdlib/array/base/fancy-slice-assign' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0, 4, 0, 3, 0, 2, 0, 1 ] -* -* var bool = ( out === y ); -* // returns true -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* var Slice = require( '@stdlib/slice/ctor' ); -* var sliceAssign = require( '@stdlib/array/base/fancy-slice-assign' ); -* -* var x = new Int32Array( [ 5 ] ); -* var y = new Int32Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0, 5, 0, 5, 0, 5, 0, 5 ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/fancy-slice-assign/lib/main.js b/base/fancy-slice-assign/lib/main.js deleted file mode 100644 index 96a4709af..000000000 --- a/base/fancy-slice-assign/lib/main.js +++ /dev/null @@ -1,133 +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. -*/ - -'use strict'; - -// MODULES // - -var isMostlySafeCast = require( './../../../base/assert/is-mostly-safe-data-type-cast' ); -var isRealDataType = require( './../../../base/assert/is-real-data-type' ); -var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var normalizeSlice = require( '@stdlib/slice/base/normalize-slice' ); -var sliceLength = require( '@stdlib/slice/base/length' ); -var dtype = require( './../../../dtype' ); -var convert = require( './../../../convert' ); -var gcopy = require( '@stdlib/blas/base/gcopy' ).ndarray; -var format = require( '@stdlib/string/format' ); - - -// MODULES // - -/** -* Assigns element values from a broadcasted input array to corresponding elements in an output array. -* -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {Slice} s - slice object -* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} input array must be broadcast compatible with an output array view -* @throws {TypeError} input array cannot be safely cast to the output array data type -* @returns {Collection} output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0, 4, 0, 3, 0, 2, 0, 1 ] -* -* var bool = ( out === y ); -* // returns true -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* var Slice = require( '@stdlib/slice/ctor' ); -* -* var x = new Int32Array( [ 5 ] ); -* var y = new Int32Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var out = sliceAssign( x, y, s, false ); -* // returns [ 0, 5, 0, 5, 0, 5, 0, 5 ] -* -* var bool = ( out === y ); -* // returns true -*/ -function sliceAssign( x, y, s, strict ) { - var xlen; - var ylen; - var xdt; - var ydt; - var ns; - var xs; - var N; - - xdt = dtype( x ) || 'generic'; - ydt = dtype( y ) || 'generic'; - - xlen = x.length; - ylen = y.length; - - // Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the output data type is floating-point... - if ( !isMostlySafeCast( xdt, ydt ) ) { - throw new TypeError( format( 'invalid argument. Input array values cannot be safely cast to the output array data type. Data types: [%s, %s].', xdt, ydt ) ); - } - // When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array... - if ( isComplexDataType( ydt ) && isRealDataType( xdt ) ) { - x = convert( x, ydt ); - } - // Normalize the slice object base on the output array length: - ns = normalizeSlice( s, ylen, true ); - - // Check whether the slice exceeds the array bounds... - if ( ns.code ) { - if ( strict ) { - throw new RangeError( format( 'invalid argument. Slice exceeds array bounds. Array length: %d.', ylen ) ); - } - // Normalize again, this time allowing for out-of-bounds indices: - ns = normalizeSlice( s, ylen, false ); - } - // Compute the slice length: - N = sliceLength( ns ); - - // Broadcast the input array: - if ( xlen === 1 ) { - xs = 0; - } else if ( xlen === N ) { - xs = 1; - } else { - throw new Error( format( 'invalid argument. Input array and the output array slice are broadcast incompatible. Array length: %u. Desired length: %u.', xlen, N ) ); - } - // Copy elements to the output array: - gcopy( N, x, xs, 0, y, ns.step, ns.start ); - - return y; -} - - -// EXPORTS // - -module.exports = sliceAssign; diff --git a/base/fancy-slice-assign/package.json b/base/fancy-slice-assign/package.json deleted file mode 100644 index 433503d97..000000000 --- a/base/fancy-slice-assign/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/fancy-slice-assign", - "version": "0.0.0", - "description": "Assign element values from a broadcasted input array to corresponding elements in an output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "copy", - "slice", - "shallow", - "fancy", - "subsequence", - "subseq", - "assign", - "assignment" - ] -} diff --git a/base/fancy-slice-assign/test/test.js b/base/fancy-slice-assign/test/test.js deleted file mode 100644 index e3c1fc29f..000000000 --- a/base/fancy-slice-assign/test/test.js +++ /dev/null @@ -1,840 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Float32Array = require( './../../../float32' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var Int32Array = require( './../../../int32' ); -var zeros = require( './../../../zeros' ); -var Slice = require( '@stdlib/slice/ctor' ); -var sliceAssign = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sliceAssign, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an input array which cannot be safely cast to the output array data type', function test( t ) { - var values; - var x; - var i; - - x = zeros( 5, 'float64' ); - - values = [ - zeros( 5, 'uint8' ), - zeros( 5, 'int8' ), - zeros( 5, 'int16' ), - zeros( 5, 'uint16' ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, value, new Slice(), false ); - }; - } -}); - -tape( 'the function throws an error if provided an input array which is not broadcast compatible with the output array slice', function test( t ) { - var values; - var y; - var i; - - y = zeros( 5, 'float64' ); - - values = [ - zeros( 2, 'float64' ), - zeros( 3, 'float64' ), - zeros( 4, 'float64' ), - zeros( 10, 'float64' ), - zeros( 0, 'float64' ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( value, y, new Slice(), false ); - }; - } -}); - -tape( 'when `strict` is `true`, the function throws an error if provided a slice which is out-of-bounds', function test( t ) { - var values; - var x; - var i; - - x = zeros( 5, 'generic' ); - - values = [ - new Slice( 10, 20 ), - new Slice( -20, -10 ), - new Slice( 0, 100 ), - new Slice( 0, -100 ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sliceAssign( x, x, value, true ); - }; - } -}); - -tape( 'when `strict` is `false`, the function returns the output array unchanged if provided a slice which is out-of-bounds', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 1 ]; - y = zeros( x.length, 'generic' ); - actual = sliceAssign( x, y, new Slice( 10, 20 ), false ); - - expected = zeros( x.length, 'generic' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1 ] ); - y = zeros( x.length, 'int32' ); - actual = sliceAssign( x, y, new Slice( -20, -10 ), false ); - - expected = zeros( x.length, 'int32' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 1 ] ); - y = zeros( x.length, 'generic' ); - actual = sliceAssign( x, y, new Slice( 0, -100 ), false ); - - expected = zeros( x.length, 'generic' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - y = zeros( x.length, 'generic' ); - actual = sliceAssign( x, y, new Slice( -10, -20 ), false ); - - expected = zeros( x.length, 'float64' ); - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function performs slice assignment with support for broadcasting (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 1, 2, 3 ]; - y = zeros( 3, 'generic' ); - - expected = [ 1, 2, 3 ]; - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - y = zeros( 3, 'generic' ); - - expected = [ 3, 2, 1 ]; - actual = sliceAssign( x, y, new Slice( null, null, -1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 3 ]; - y = zeros( 3, 'generic' ); - - expected = [ 3, 0, 1 ]; - actual = sliceAssign( x, y, new Slice( null, null, -2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 3 ]; - y = zeros( 3, 'generic' ); - - expected = [ 1, 0, 3 ]; - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 2, 3 ]; - y = zeros( 3, 'generic' ); - - expected = [ 0, 2, 3 ]; - actual = sliceAssign( x, y, new Slice( 1, null ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 2 ]; - y = zeros( 3, 'generic' ); - - expected = [ 0, 2, 0 ]; - actual = sliceAssign( x, y, new Slice( 1, y.length-1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1 ]; - y = zeros( 3, 'generic' ); - - expected = [ 0, 0, 0 ]; - actual = sliceAssign( x, y, new Slice( 1, 1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Broadcasting: - x = [ 1 ]; - y = zeros( 3, 'generic' ); - - expected = [ 1, 1, 1 ]; - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 3 ]; - y = zeros( 3, 'generic' ); - - expected = [ 3, 0, 3 ]; - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function performs slice assignment with support for broadcasting (float64)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - y = zeros( 3, 'float64' ); - - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - y = zeros( 3, 'float32' ); // downcast - - expected = new Float32Array( [ 3.0, 2.0, 1.0 ] ); - actual = sliceAssign( x, y, new Slice( null, null, -1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 3.0 ] ); - y = zeros( 3, 'float64' ); - - expected = new Float64Array( [ 3.0, 0.0, 1.0 ] ); - actual = sliceAssign( x, y, new Slice( null, null, -2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 3.0 ] ); - y = zeros( 3, 'float32' ); // downcast - - expected = new Float32Array( [ 1.0, 0.0, 3.0 ] ); - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 2.0, 3.0 ] ); - y = zeros( 3, 'float64' ); - - expected = new Float64Array( [ 0.0, 2.0, 3.0 ] ); - actual = sliceAssign( x, y, new Slice( 1, null ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 2.0 ] ); - y = zeros( 3, 'float64' ); - - expected = new Float64Array( [ 0.0, 2.0, 0.0 ] ); - actual = sliceAssign( x, y, new Slice( 1, y.length-1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - y = zeros( 3, 'float64' ); - - expected = new Float64Array( [ 0.0, 0.0, 0.0 ] ); - actual = sliceAssign( x, y, new Slice( 1, 1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Broadcasting: - x = new Float64Array( [ 1.0 ] ); - y = zeros( 3, 'float64' ); - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 3.0 ] ); - y = zeros( 3, 'float64' ); - - expected = new Float64Array( [ 3.0, 0.0, 3.0 ] ); - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Upcasting: - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - y = zeros( 3, 'complex128' ); - - expected = new Complex128Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function performs slice assignment with support for broadcasting (complex128)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = zeros( 3, 'complex128' ); - - expected = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - y = zeros( 3, 'complex128' ); - - expected = new Complex128Array( [ 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] ); - actual = sliceAssign( x, y, new Slice( null, null, -1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = zeros( 3, 'complex64' ); // downcast - - expected = new Complex64Array( [ 3.0, 4.0, 0.0, 0.0, 1.0, 2.0 ] ); - actual = sliceAssign( x, y, new Slice( null, null, -2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = zeros( 3, 'complex128' ); - - expected = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0 ] ); - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = zeros( 3, 'complex128' ); - - expected = new Complex128Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); - actual = sliceAssign( x, y, new Slice( 1, null ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 2.0 ] ); - y = zeros( 3, 'complex64' ); // downcast - - expected = new Complex64Array( [ 0.0, 0.0, 1.0, 2.0, 0.0, 0.0 ] ); - actual = sliceAssign( x, y, new Slice( 1, y.length-1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 2.0 ] ); - y = zeros( 3, 'complex128' ); - - expected = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - actual = sliceAssign( x, y, new Slice( 1, 1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - // Broadcasting: - x = new Complex128Array( [ 1.0, 2.0 ] ); - y = zeros( 3, 'complex128' ); - - expected = new Complex128Array( [ 1.0, 2.0, 1.0, 2.0, 1.0, 2.0 ] ); - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 3.0, 4.0 ] ); - y = zeros( 3, 'complex64' ); // downcast - - expected = new Complex64Array( [ 3.0, 4.0, 0.0, 0.0, 3.0, 4.0 ] ); - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function performs slice assignment with support for broadcasting (int32)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3 ] ); - y = zeros( 3, 'int32' ); - - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - y = zeros( 3, 'int32' ); - - expected = new Int32Array( [ 3, 2, 1 ] ); - actual = sliceAssign( x, y, new Slice( null, null, -1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 3 ] ); - y = zeros( 3, 'int32' ); - - expected = new Int32Array( [ 3, 0, 1 ] ); - actual = sliceAssign( x, y, new Slice( null, null, -2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 3 ] ); - y = zeros( 3, 'int32' ); - - expected = new Int32Array( [ 1, 0, 3 ] ); - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 2, 3 ] ); - y = zeros( 3, 'int32' ); - - expected = new Int32Array( [ 0, 2, 3 ] ); - actual = sliceAssign( x, y, new Slice( 1, null ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 2 ] ); - y = zeros( 3, 'int32' ); - - expected = new Int32Array( [ 0, 2, 0 ] ); - actual = sliceAssign( x, y, new Slice( 1, y.length-1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1 ] ); - y = zeros( 3, 'int32' ); - - expected = new Int32Array( [ 0, 0, 0 ] ); - actual = sliceAssign( x, y, new Slice( 1, 1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Broadcasting: - x = new Int32Array( [ 1 ] ); - y = zeros( 3, 'int32' ); - - expected = new Int32Array( [ 1, 1, 1 ] ); - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 3 ] ); - y = zeros( 3, 'int32' ); - - expected = new Int32Array( [ 3, 0, 3 ] ); - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function performs slice assignment with support for broadcasting (accessors)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new AccessorArray( [ 1, 2, 3 ] ); - y = zeros( 3, 'generic' ); - - expected = [ 1, 2, 3 ]; - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 1, 2, 3 ] ); - y = zeros( 3, 'generic' ); - - expected = [ 3, 2, 1 ]; - actual = sliceAssign( x, y, new Slice( null, null, -1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 1, 3 ] ); - y = zeros( 3, 'generic' ); - - expected = [ 3, 0, 1 ]; - actual = sliceAssign( x, y, new Slice( null, null, -2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 1, 3 ] ); - y = zeros( 3, 'generic' ); - - expected = [ 1, 0, 3 ]; - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 2, 3 ] ); - y = zeros( 3, 'generic' ); - - expected = [ 0, 2, 3 ]; - actual = sliceAssign( x, y, new Slice( 1, null ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 2 ] ); - y = zeros( 3, 'generic' ); - - expected = [ 0, 2, 0 ]; - actual = sliceAssign( x, y, new Slice( 1, y.length-1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 1 ] ); - y = zeros( 3, 'generic' ); - - expected = [ 0, 0, 0 ]; - actual = sliceAssign( x, y, new Slice( 1, 1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Broadcasting: - x = new AccessorArray( [ 1 ] ); - y = zeros( 3, 'generic' ); - - expected = [ 1, 1, 1 ]; - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 3 ] ); - y = zeros( 3, 'generic' ); - - expected = [ 3, 0, 3 ]; - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function performs slice assignment with support for broadcasting (array-like)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - - expected = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - - expected = { - 'length': 3, - '0': 3, - '1': 2, - '2': 1 - }; - actual = sliceAssign( x, y, new Slice( null, null, -1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 2, - '0': 1, - '1': 3 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - - expected = { - 'length': 3, - '0': 3, - '1': 0, - '2': 1 - }; - actual = sliceAssign( x, y, new Slice( null, null, -2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 2, - '0': 1, - '1': 3 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - - expected = { - 'length': 3, - '0': 1, - '1': 0, - '2': 3 - }; - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 2, - '0': 2, - '1': 3 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - - expected = { - 'length': 3, - '0': 0, - '1': 2, - '2': 3 - }; - actual = sliceAssign( x, y, new Slice( 1, null ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 1, - '0': 2 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - - expected = { - 'length': 3, - '0': 0, - '1': 2, - '2': 0 - }; - actual = sliceAssign( x, y, new Slice( 1, y.length-1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 1, - '0': 1 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - - expected = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - actual = sliceAssign( x, y, new Slice( 1, 1 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Broadcasting: - x = { - 'length': 1, - '0': 1 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - - expected = { - 'length': 3, - '0': 1, - '1': 1, - '2': 1 - }; - actual = sliceAssign( x, y, new Slice(), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 1, - '0': 3 - }; - y = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - - expected = { - 'length': 3, - '0': 3, - '1': 0, - '2': 3 - }; - actual = sliceAssign( x, y, new Slice( null, null, 2 ), false ); - - t.strictEqual( actual, y, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/fancy-slice/README.md b/base/fancy-slice/README.md deleted file mode 100644 index c336a8f36..000000000 --- a/base/fancy-slice/README.md +++ /dev/null @@ -1,161 +0,0 @@ - - -# slice - -> Return a shallow copy of a portion of an array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var slice = require( '@stdlib/array/base/fancy-slice' ); -``` - -#### slice( x, s, strict ) - -Returns a shallow copy of a portion of an array. - -```javascript -var Slice = require( '@stdlib/slice/ctor' ); - -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var s = new Slice( 1, 4 ); -var out = slice( x, s, false ); -// returns [ 2, 3, 4 ] - -var bool = ( out === x ); -// returns false -``` - -The function supports the following parameters: - -- **x**: input array. -- **s**: [slice][@stdlib/slice/ctor] object. -- **strict**: boolean indicating whether to enforce strict bounds checking. - -
- - - - - -
- -## Notes - -- If provided an array-like object having an unknown [data type][@stdlib/array/dtype], the function copies input array elements to a new generic array. - -
- - - - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/zero-to' ); -var Slice = require( '@stdlib/slice/ctor' ); -var slice = require( '@stdlib/array/base/fancy-slice' ); - -var x = zeroTo( 10, 'generic' ); -// returns [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -var s = new Slice(); -var y = slice( x, s, false ); -// returns [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -s = new Slice( null, null, -2 ); -y = slice( x, s, false ); -// returns [ 9, 7, 5, 3, 1 ] - -s = new Slice( -2, null, -2 ); -y = slice( x, s, false ); -// returns [ 8, 6, 4, 2, 0 ] - -s = new Slice( 2, -2 ); -y = slice( x, s, false ); -// returns [ 2, 3, 4, 5, 6, 7 ] - -s = new Slice( 2, 5 ); -y = slice( x, s, false ); -// returns [ 2, 3, 4 ] - -s = new Slice( 4, 1, -1 ); -y = slice( x, s, false ); -// returns [ 4, 3, 2 ] - -s = new Slice( 5 ); -y = slice( x, s, false ); -// returns [ 0, 1, 2, 3, 4 ] - -s = new Slice( 5, null ); -y = slice( x, s, false ); -// returns [ 5, 6, 7, 8, 9 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/fancy-slice/benchmark/benchmark.float64.js b/base/fancy-slice/benchmark/benchmark.float64.js deleted file mode 100644 index 04217ae23..000000000 --- a/base/fancy-slice/benchmark/benchmark.float64.js +++ /dev/null @@ -1,104 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var zeroTo = require( './../../../zero-to' ); -var Slice = require( '@stdlib/slice/ctor' ); -var pkg = require( './../package.json' ).name; -var slice = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len, 'float64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Slice(), - new Slice(), - new Slice() - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = slice( x, values[ i%values.length ], false ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/base/fancy-slice/benchmark/benchmark.generic.js b/base/fancy-slice/benchmark/benchmark.generic.js deleted file mode 100644 index 90ca5128b..000000000 --- a/base/fancy-slice/benchmark/benchmark.generic.js +++ /dev/null @@ -1,104 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var zeroTo = require( './../../../zero-to' ); -var Slice = require( '@stdlib/slice/ctor' ); -var pkg = require( './../package.json' ).name; -var slice = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Slice(), - new Slice(), - new Slice() - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = slice( x, values[ i%values.length ], false ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/fancy-slice/docs/repl.txt b/base/fancy-slice/docs/repl.txt deleted file mode 100644 index 69d27957e..000000000 --- a/base/fancy-slice/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( x, s, strict ) - Returns a shallow copy of a portion of an array. - - If provided an array-like object having an unknown data type, the function - copies input array elements to a new generic array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - s: Slice - Slice object. - - strict: boolean - Boolean indicating whether to enforce strict bounds checking. - - Returns - ------- - out: Array|TypedArray|Object - Output array. - - Examples - -------- - > var s = new {{alias:@stdlib/slice/ctor}}( 1, 3 ); - > var out = {{alias}}( [ 1, 2, 3, 4 ], s, false ) - [ 2, 3 ] - - See Also - -------- - diff --git a/base/fancy-slice/docs/types/index.d.ts b/base/fancy-slice/docs/types/index.d.ts deleted file mode 100644 index b6e6b3343..000000000 --- a/base/fancy-slice/docs/types/index.d.ts +++ /dev/null @@ -1,256 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex128Array, Complex64Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Slice } from '@stdlib/types/slice'; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 3.0, 2.0, 1.0 ] -*/ -declare function slice( x: Float64Array, s: Slice, strict: boolean ): Float64Array; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 3.0, 2.0, 1.0 ] -*/ -declare function slice( x: Float32Array, s: Slice, strict: boolean ): Float32Array; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3 ] ); -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 3, 2, 1 ] -*/ -declare function slice( x: Int32Array, s: Slice, strict: boolean ): Int32Array; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var x = new Int16Array( [ 1, 2, 3 ] ); -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 3, 2, 1 ] -*/ -declare function slice( x: Int16Array, s: Slice, strict: boolean ): Int16Array; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var x = new Int8Array( [ 1, 2, 3 ] ); -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 3, 2, 1 ] -*/ -declare function slice( x: Int8Array, s: Slice, strict: boolean ): Int8Array; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3 ] ); -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 3, 2, 1 ] -*/ -declare function slice( x: Uint32Array, s: Slice, strict: boolean ): Uint32Array; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3 ] ); -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 3, 2, 1 ] -*/ -declare function slice( x: Uint16Array, s: Slice, strict: boolean ): Uint16Array; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3 ] ); -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 3, 2, 1 ] -*/ -declare function slice( x: Uint8Array, s: Slice, strict: boolean ): Uint8Array; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3 ] ); -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 3, 2, 1 ] -*/ -declare function slice( x: Uint8ClampedArray, s: Slice, strict: boolean ): Uint8ClampedArray; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] -*/ -declare function slice( x: Complex128Array, s: Slice, strict: boolean ): Complex128Array; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] -*/ -declare function slice( x: Complex64Array, s: Slice, strict: boolean ): Complex64Array; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param s - slice object -* @param strict - boolean indicating whether to enforce strict bounds checking -* @returns output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var out = slice( x, new Slice( null, null, -1 ), false ); -* // returns [ 6, 5, 4, 3, 2, 1 ] -*/ -declare function slice( x: Collection | AccessorArrayLike, s: Slice, strict: boolean ): Array; - - -// EXPORTS // - -export = slice; diff --git a/base/fancy-slice/docs/types/test.ts b/base/fancy-slice/docs/types/test.ts deleted file mode 100644 index 0026474ca..000000000 --- a/base/fancy-slice/docs/types/test.ts +++ /dev/null @@ -1,99 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import Slice = require( '@stdlib/slice/ctor' ); -import slice = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - slice( [ 1, 2, 3 ], new Slice(), false ); // $ExpectType number[] - slice( new Float64Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Float64Array - slice( new Float32Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Float32Array - slice( new Int32Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Int32Array - slice( new Int16Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Int16Array - slice( new Int8Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Int8Array - slice( new Uint32Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Uint32Array - slice( new Uint16Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Uint16Array - slice( new Uint8Array( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Uint8Array - slice( new Uint8ClampedArray( [ 1, 2, 3 ] ), new Slice(), false ); // $ExpectType Uint8ClampedArray - slice( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), new Slice(), false ); // $ExpectType Complex128Array - slice( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), new Slice(), false ); // $ExpectType Complex64Array - - slice( [ 1, 2, 3 ], new Slice(), true ); // $ExpectType number[] - slice( new Float64Array( [ 1, 2, 3 ] ), new Slice(), true ); // $ExpectType Float64Array - slice( new Float32Array( [ 1, 2, 3 ] ), new Slice(), true ); // $ExpectType Float32Array - slice( new Int32Array( [ 1, 2, 3 ] ), new Slice(), true ); // $ExpectType Int32Array - slice( new Int16Array( [ 1, 2, 3 ] ), new Slice(), true ); // $ExpectType Int16Array - slice( new Int8Array( [ 1, 2, 3 ] ), new Slice(), true ); // $ExpectType Int8Array - slice( new Uint32Array( [ 1, 2, 3 ] ), new Slice(), true ); // $ExpectType Uint32Array - slice( new Uint16Array( [ 1, 2, 3 ] ), new Slice(), true ); // $ExpectType Uint16Array - slice( new Uint8Array( [ 1, 2, 3 ] ), new Slice(), true ); // $ExpectType Uint8Array - slice( new Uint8ClampedArray( [ 1, 2, 3 ] ), new Slice(), true ); // $ExpectType Uint8ClampedArray - slice( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), new Slice(), true ); // $ExpectType Complex128Array - slice( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), new Slice(), true ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - slice( 5, new Slice(), false ); // $ExpectError - slice( true, new Slice(), false ); // $ExpectError - slice( false, new Slice(), false ); // $ExpectError - slice( null, new Slice(), false ); // $ExpectError - slice( void 0, new Slice(), false ); // $ExpectError - slice( {}, new Slice(), false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a slice object... -{ - const x = [ 1, 2, 3 ]; - - slice( x, '5', false ); // $ExpectError - slice( x, true, false ); // $ExpectError - slice( x, false, false ); // $ExpectError - slice( x, null, false ); // $ExpectError - slice( x, void 0, false ); // $ExpectError - slice( x, {}, false ); // $ExpectError - slice( x, [], false ); // $ExpectError - slice( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ 1, 2, 3 ]; - - slice( x, new Slice(), '5' ); // $ExpectError - slice( x, new Slice(), 5 ); // $ExpectError - slice( x, new Slice(), null ); // $ExpectError - slice( x, new Slice(), void 0 ); // $ExpectError - slice( x, new Slice(), {} ); // $ExpectError - slice( x, new Slice(), [] ); // $ExpectError - slice( x, new Slice(), ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - slice(); // $ExpectError - slice( [ 1, 2, 3 ] ); // $ExpectError - slice( [ 1, 2, 3 ], new Slice() ); // $ExpectError - slice( [ 1, 2, 3 ], new Slice(), false, {} ); // $ExpectError -} diff --git a/base/fancy-slice/examples/index.js b/base/fancy-slice/examples/index.js deleted file mode 100644 index 8ddee02b5..000000000 --- a/base/fancy-slice/examples/index.js +++ /dev/null @@ -1,66 +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. -*/ - -'use strict'; - -var zeroTo = require( './../../../zero-to' ); -var Slice = require( '@stdlib/slice/ctor' ); -var slice = require( './../lib' ); - -var x = zeroTo( 10, 'generic' ); -// returns [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -var s = new Slice(); -var y = slice( x, s, false ); -console.log( y ); -// => [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] - -s = new Slice( null, null, -2 ); -y = slice( x, s, false ); -console.log( y ); -// => [ 9, 7, 5, 3, 1 ] - -s = new Slice( -2, null, -2 ); -y = slice( x, s, false ); -console.log( y ); -// => [ 8, 6, 4, 2, 0 ] - -s = new Slice( 2, -2 ); -y = slice( x, s, false ); -console.log( y ); -// => [ 2, 3, 4, 5, 6, 7 ] - -s = new Slice( 2, 5 ); -y = slice( x, s, false ); -console.log( y ); -// => [ 2, 3, 4 ] - -s = new Slice( 4, 1, -1 ); -y = slice( x, s, false ); -console.log( y ); -// => [ 4, 3, 2 ] - -s = new Slice( 5 ); -y = slice( x, s, false ); -console.log( y ); -// => [ 0, 1, 2, 3, 4 ] - -s = new Slice( 5, null ); -y = slice( x, s, false ); -console.log( y ); -// => [ 5, 6, 7, 8, 9 ] diff --git a/base/fancy-slice/lib/index.js b/base/fancy-slice/lib/index.js deleted file mode 100644 index e2d570d99..000000000 --- a/base/fancy-slice/lib/index.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -/** -* Return a shallow copy of a portion of an array. -* -* @module @stdlib/array/base/fancy-slice -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* var slice = require( '@stdlib/array/base/fancy-slice' ); -* -* var x = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var y = slice( x, s, false ); -* // returns [ 8, 6, 4, 2 ] -* -* var out = ( y === x ); -* // returns false -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* var Slice = require( '@stdlib/slice/ctor' ); -* var slice = require( '@stdlib/array/base/fancy-slice' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var y = slice( x, s, false ); -* // returns [ 8, 6, 4, 2 ] -* -* var out = ( y === x ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/fancy-slice/lib/main.js b/base/fancy-slice/lib/main.js deleted file mode 100644 index dd0cefb28..000000000 --- a/base/fancy-slice/lib/main.js +++ /dev/null @@ -1,112 +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. -*/ - -'use strict'; - -// MODULES // - -var normalizeSlice = require( '@stdlib/slice/base/normalize-slice' ); -var sliceLength = require( '@stdlib/slice/base/length' ); -var zeros = require( './../../../base/zeros' ); -var dtype = require( './../../../dtype' ); -var gcopy = require( '@stdlib/blas/base/gcopy' ).ndarray; -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns a shallow copy of a portion of an array. -* -* @param {Collection} x - input array -* @param {Slice} s - slice object -* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking -* @throws {RangeError} slice exceeds array bounds -* @returns {Collection} output array -* -* @example -* var Slice = require( '@stdlib/slice/ctor' ); -* -* var x = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var y = slice( x, s, false ); -* // returns [ 8, 6, 4, 2 ] -* -* var out = ( y === x ); -* // returns false -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* var Slice = require( '@stdlib/slice/ctor' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); -* -* var s = new Slice( null, null, -2 ); -* // returns -* -* var y = slice( x, s, false ); -* // returns [ 8, 6, 4, 2 ] -* -* var out = ( y === x ); -* // returns false -*/ -function slice( x, s, strict ) { - var out; - var len; - var ns; - var dt; - var N; - - len = x.length; - - // Normalize the slice object base on the array length: - ns = normalizeSlice( s, len, true ); - - // Check whether the slice exceeds the array bounds... - if ( ns.code ) { - if ( strict ) { - throw new RangeError( format( 'invalid argument. Slice exceeds array bounds. Array length: %d.', len ) ); - } - // Normalize again, this time allowing for out-of-bounds indices: - ns = normalizeSlice( s, len, false ); - } - // Compute the slice length: - N = sliceLength( ns ); - - // Resolve the input array data type: - dt = dtype( x ); - - // Allocate an output array: - if ( dt === 'generic' || dt === null ) { // note: if we were provided an "exotic" array object, fallback to always returning a "generic" array - out = zeros( N ); - } else { - out = new x.constructor( N ); // note: this should accommodate array species which inherit from built-in/known constructors and we assume that all constructors support providing a length argument - } - // Copy elements to the output array: - gcopy( N, x, ns.step, ns.start, out, 1, 0 ); - - return out; -} - - -// EXPORTS // - -module.exports = slice; diff --git a/base/fancy-slice/package.json b/base/fancy-slice/package.json deleted file mode 100644 index 56485656b..000000000 --- a/base/fancy-slice/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/fancy-slice", - "version": "0.0.0", - "description": "Return a shallow copy of a portion of an array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "copy", - "slice", - "shallow", - "fancy", - "subsequence", - "subseq" - ] -} diff --git a/base/fancy-slice/test/test.js b/base/fancy-slice/test/test.js deleted file mode 100644 index e7f732dc4..000000000 --- a/base/fancy-slice/test/test.js +++ /dev/null @@ -1,420 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var Slice = require( '@stdlib/slice/ctor' ); -var slice = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof slice, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'when `strict` is `true`, the function throws an error if provided a slice which is out-of-bounds', function test( t ) { - var values; - var i; - - values = [ - new Slice( 10, 20 ), - new Slice( -20, -10 ), - new Slice( 0, 100 ), - new Slice( 0, -100 ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - slice( [ 1, 2, 3, 4 ], value, true ); - }; - } -}); - -tape( 'when `strict` is `false`, the function returns an empty array if provided a slice which is out-of-bounds', function test( t ) { - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - actual = slice( x, new Slice( 10, 20 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, [], 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = slice( x, new Slice( -20, -10 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, new Int32Array( 0 ), 'returns expected value' ); - - x = new AccessorArray( [ 1, 2, 3, 4 ] ); - actual = slice( x, new Slice( 0, -100 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, [], 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - actual = slice( x, new Slice( -10, -20 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, new Float64Array( 0 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - - expected = [ 1, 2, 3 ]; - actual = slice( x, new Slice(), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 3, 2, 1 ]; - actual = slice( x, new Slice( null, null, -1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 3, 1 ]; - actual = slice( x, new Slice( null, null, -2 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 3 ]; - actual = slice( x, new Slice( null, null, 2 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 3 ]; - actual = slice( x, new Slice( 1, null ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2 ]; - actual = slice( x, new Slice( 1, x.length-1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = slice( x, new Slice( 1, 1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (float64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = slice( x, new Slice( null ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 3.0, 2.0, 1.0 ] ); - actual = slice( x, new Slice( x.length-1, null, -1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 3.0, 1.0 ] ); - actual = slice( x, new Slice( x.length-1, null, -2 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1.0, 3.0 ] ); - actual = slice( x, new Slice( 0, null, 2 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 2.0, 3.0 ] ); - actual = slice( x, new Slice( 1, x.length ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 2.0 ] ); - actual = slice( x, new Slice( 1, -1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - actual = slice( x, new Slice( 1, 1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (int32)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = slice( x, new Slice( null, null ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1, 3 ] ); - actual = slice( x, new Slice( null, null, 2 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 2 ] ); - actual = slice( x, new Slice( x.length-2, null, -2 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1, 2 ] ); - actual = slice( x, new Slice( x.length-1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1 ] ); - actual = slice( x, new Slice( x.length-2 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [] ); - actual = slice( x, new Slice( 0, x.length-3 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = new AccessorArray( [ 1, 2, 3, 4 ] ); - - expected = [ 1, 2, 3, 4 ]; - actual = slice( x, new Slice(), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 4, 3, 2, 1 ]; - actual = slice( x, new Slice( null, null, -1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 3, 1 ]; - actual = slice( x, new Slice( x.length-2, null, -2 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 4 ]; - actual = slice( x, new Slice( 1, null, 2 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3 ]; - actual = slice( x, new Slice( null, x.length-1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 3 ]; - actual = slice( x, new Slice( 1, x.length-1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 3 ]; - actual = slice( x, new Slice( 2, x.length-1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = slice( x, new Slice( 3, x.length-1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (array-like)', function test( t ) { - var expected; - var actual; - var x; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - - expected = [ 1, 2, 3, 4 ]; - actual = slice( x, new Slice( 0, x.length ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 4, 3, 2 ]; - actual = slice( x, new Slice( x.length-1, 0, -1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 4, 2 ]; - actual = slice( x, new Slice( x.length-1, 0, -2 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3 ]; - actual = slice( x, new Slice( 0, x.length-1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 3 ]; - actual = slice( x, new Slice( 1, x.length-1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 3 ]; - actual = slice( x, new Slice( 2, x.length-1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = slice( x, new Slice( 3, x.length-1 ), false ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of length `0`', function test( t ) { - var expected; - var actual; - - expected = []; - actual = slice( [], new Slice(), false ); - - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = slice( new Float64Array( 0 ), new Slice(), false ); - - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = slice( new AccessorArray( [] ), new Slice(), false ); - - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/fill-by/README.md b/base/fill-by/README.md deleted file mode 100644 index c3f9559ad..000000000 --- a/base/fill-by/README.md +++ /dev/null @@ -1,165 +0,0 @@ - - -# fillBy - -> Fill all elements within a portion of an array according to a callback function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var fillBy = require( '@stdlib/array/base/fill-by' ); -``` - -#### fillBy( x, start, end, fcn\[, thisArg] ) - -Fills all elements within a portion of an array from an inclusive `start` index to an exclusive `end` index according to a provided callback function. - -```javascript -function fcn() { - return 10; -} - -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var out = fillBy( x, 1, 4, fcn ); -// returns [ 1, 10, 10, 10, 5, 6 ] - -var bool = ( out === x ); -// returns true -``` - -The callback function is provided the following arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn() { - this.count += 1; - return 10; -} - -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var ctx = { - 'count': 0 -}; -var out = fillBy( x, 1, 4, fcn, ctx ); -// returns [ 1, 10, 10, 10, 5, 6 ] - -var bool = ( out === x ); -// returns true - -var cnt = ctx.count; -// returns 3 -``` - -
- - - - - -
- -## Notes - -- Negative `start` and `end` indices are resolved to positive indices by counting from the end of the array with `-1` corresponding to the last indexed element. -- The function **mutates** the input array. - -
- - - - - -
- -## Examples - - - -```javascript -var constantFunction = require( '@stdlib/utils/constant-function' ); -var Float64Array = require( '@stdlib/array/float64' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var fillBy = require( '@stdlib/array/base/fill-by' ); - -var x = new Float64Array( zeroTo( 6 ) ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -var y = fillBy( x, 0, 6, constantFunction( 10.0 ) ); -// returns [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ] - -y = fillBy( x, 0, 4, constantFunction( 0.0 ) ); -// returns [ 0.0, 0.0, 0.0, 0.0, 10.0, 10.0 ] - -y = fillBy( x, 2, 6, constantFunction( 20.0 ) ); -// returns [ 0.0, 0.0, 20.0, 20.0, 20.0, 20.0 ] - -y = fillBy( x, 2, 4, constantFunction( 30.0 ) ); -// returns [ 0.0, 0.0, 30.0, 30.0, 20.0, 20.0 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/fill-by/benchmark/benchmark.length.js b/base/fill-by/benchmark/benchmark.length.js deleted file mode 100644 index f8c49c69a..000000000 --- a/base/fill-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var fillBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Callback function. -* -* @private -* @param {*} value - current array element -* @param {NonNegativeInteger} idx - current array element index -* @param {Collection} arr - input array -* @returns {*} fill value -*/ -function fcn( value, idx ) { - return value + idx; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fillBy( x, 0, len, fcn ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/fill-by/docs/repl.txt b/base/fill-by/docs/repl.txt deleted file mode 100644 index bc4bd29db..000000000 --- a/base/fill-by/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( x, start, end, fcn[, thisArg] ) - Fills all elements within a portion of an array according to a provided - callback function. - - This function mutates the input array. - - Negative `start` and `end` indices are resolved to positive indices by - counting from the end of the array with `-1` corresponding to the last - indexed element. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - start: integer - Starting index (inclusive). - - end: integer - Ending index (exclusive). - - fcn: Function - Callback function. - - thisArg: any (optional) - Callback function execution context. - - Returns - ------- - out: ArrayLikeObject - Modified input array. - - Examples - -------- - > function fcn() { return 5; }; - > var out = {{alias}}( [ 1, 2, 3, 4 ], 1, 3, fcn ) - [ 1, 5, 5, 4 ] - - See Also - -------- - diff --git a/base/fill-by/docs/types/index.d.ts b/base/fill-by/docs/types/index.d.ts deleted file mode 100644 index d4815023e..000000000 --- a/base/fill-by/docs/types/index.d.ts +++ /dev/null @@ -1,246 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; - -/** -* Callback invoked for each array element. -* -* @returns fill value -*/ -type Nullary = ( this: ThisArg ) => V; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -* @returns fill value -*/ -type Unary = ( this: ThisArg, value: T ) => V; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -* @param index - current array element index -* @returns fill value -*/ -type Binary = ( this: ThisArg, value: T, index: number ) => V; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns fill value -*/ -type Ternary = ( this: ThisArg, value: T, index: number, arr: U ) => V; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns fill value -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Fills all elements within a portion of an array according to a provided callback function. -* -* @param x - input array -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @param fcn - callback function -* @param thisArg - callback function execution context -* @returns modified input array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function fcn() { -* return 4.0; -* } -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = fillBy( x, 0, 3, fcn ); -* // returns [ 4.0, 4.0, 4.0 ] -*/ -declare function fillBy( x: U, start: number, end: number, fcn: Callback, thisArg?: ThisParameterType> ): U; - -/** -* Fills all elements within a portion of an array according to a provided callback function. -* -* @param x - input array -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @param fcn - callback function -* @param thisArg - callback function execution context -* @returns modified input array -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* function fcn() { -* return true; -* } -* -* var x = new BooleanArray( [ false, false, false ] ); -* -* var out = fillBy( x, 0, 3, fcn ); -* // returns [ true, true, true ] -*/ -declare function fillBy( x: U, start: number, end: number, fcn: Callback, thisArg?: ThisParameterType> ): U; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Fills all elements within a portion of an array according to a provided callback function. -* -* @param x - input array -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @param fcn - callback function -* @param thisArg - callback function execution context -* @returns modified input array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* function fcn() { -* return new Complex128( 7.0, 8.0 ); -* } -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* var out = fillBy( x, 0, 3, fcn ); -* // returns [ 7.0, 8.0, 7.0, 8.0, 7.0, 8.0 ] -*/ -declare function fillBy( x: U, start: number, end: number, fcn: Callback, thisArg?: ThisParameterType> ): U; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Fills all elements within a portion of an array according to a provided callback function. -* -* @param x - input array -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @param fcn - callback function -* @param thisArg - callback function execution context -* @returns modified input array -* -* @example -* function fcn() { -* return 4; -* } -* -* var x = [ 1, 2, 3 ]; -* -* var out = fillBy( x, 0, 3, fcn ); -* // returns [ 4, 4, 4 ] -* -* @example -* function fcn() { -* return 8; -* } -* -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var out = fillBy( x, 0, 3, fcn ); -* // returns [ 8, 8, 8, 4, 5, 6 ] -*/ -declare function fillBy( x: Array, start: number, end: number, fcn: Callback, V, ThisArg>, thisArg?: ThisParameterType, V, ThisArg>> ): Array; - -/** -* Fills all elements within a portion of an array according to a provided callback function. -* -* @param x - input array -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @param fcn - callback function -* @param thisArg - callback function execution context -* @returns modified input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* function fcn() { -* return 4; -* } -* -* var x = [ 1, 2, 3 ]; -* -* var out = fillBy( toAccessorArray( x ), 0, 3, fcn ); -* // returns [ 4, 4, 4 ] -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* function fcn() { -* return 8; -* } -* -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var out = fillBy( toAccessorArray( x ), 0, 3, fcn ); -* // returns [ 8, 8, 8, 4, 5, 6 ] -*/ -declare function fillBy( x: AccessorArrayLike, start: number, end: number, fcn: Callback, V, ThisArg>, thisArg?: ThisParameterType, V, ThisArg>> ): AccessorArrayLike; - -/** -* Fills all elements within a portion of an array according to a provided callback function. -* -* @param x - input array -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @param fcn - callback function -* @param thisArg - callback function execution context -* @returns modified input array -* -* @example -* function fcn() { -* return 4; -* } -* -* var x = [ 1, 2, 3 ]; -* -* var out = fillBy( x, 0, 3, fcn ); -* // returns [ 4, 4, 4 ] -* -* @example -* function fcn() { -* return 8; -* } -* -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var out = fillBy( x, 0, 3, fcn ); -* // returns [ 8, 8, 8, 4, 5, 6 ] -*/ -declare function fillBy( x: Collection, start: number, end: number, fcn: Callback, V, ThisArg>, thisArg?: ThisParameterType, V, ThisArg>> ): Collection; - - -// EXPORTS // - -export = fillBy; diff --git a/base/fill-by/docs/types/test.ts b/base/fill-by/docs/types/test.ts deleted file mode 100644 index 0f28a5807..000000000 --- a/base/fill-by/docs/types/test.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import BooleanArray = require( './../../../../bool' ); -import fillBy = require( './index' ); - -/** -* Callback function. -* -* @param value - current array element -* @returns fill value -*/ -function fcn( value: T ): T { - return value; -} - - -// TESTS // - -// The function returns an array... -{ - fillBy( [ 1, 2, 3 ], 0, 3, fcn ); // $ExpectType number[] - fillBy( new Float64Array( [ 1, 2, 3 ] ), 0, 3, fcn ); // $ExpectType Float64Array - fillBy( new Float32Array( [ 1, 2, 3 ] ), 0, 3, fcn ); // $ExpectType Float32Array - fillBy( new Int32Array( [ 1, 2, 3 ] ), 0, 3, fcn ); // $ExpectType Int32Array - fillBy( new Int16Array( [ 1, 2, 3 ] ), 0, 3, fcn ); // $ExpectType Int16Array - fillBy( new Int8Array( [ 1, 2, 3 ] ), 0, 3, fcn ); // $ExpectType Int8Array - fillBy( new Uint32Array( [ 1, 2, 3 ] ), 0, 3, fcn ); // $ExpectType Uint32Array - fillBy( new Uint16Array( [ 1, 2, 3 ] ), 0, 3, fcn ); // $ExpectType Uint16Array - fillBy( new Uint8Array( [ 1, 2, 3 ] ), 0, 3, fcn ); // $ExpectType Uint8Array - fillBy( new Uint8ClampedArray( [ 1, 2, 3 ] ), 0, 3, fcn ); // $ExpectType Uint8ClampedArray - fillBy( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3, fcn ); // $ExpectType Complex128Array - fillBy( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3, fcn ); // $ExpectType Complex64Array - fillBy( new BooleanArray( [ true, false, true, false ] ), 0, 3, fcn ); // $ExpectType BooleanArray - - fillBy( [ 1, 2, 3 ], 0, 3, fcn, {} ); // $ExpectType number[] - fillBy( new Float64Array( [ 1, 2, 3 ] ), 0, 3, fcn, {} ); // $ExpectType Float64Array - fillBy( new Float32Array( [ 1, 2, 3 ] ), 0, 3, fcn, {} ); // $ExpectType Float32Array - fillBy( new Int32Array( [ 1, 2, 3 ] ), 0, 3, fcn, {} ); // $ExpectType Int32Array - fillBy( new Int16Array( [ 1, 2, 3 ] ), 0, 3, fcn, {} ); // $ExpectType Int16Array - fillBy( new Int8Array( [ 1, 2, 3 ] ), 0, 3, fcn, {} ); // $ExpectType Int8Array - fillBy( new Uint32Array( [ 1, 2, 3 ] ), 0, 3, fcn, {} ); // $ExpectType Uint32Array - fillBy( new Uint16Array( [ 1, 2, 3 ] ), 0, 3, fcn, {} ); // $ExpectType Uint16Array - fillBy( new Uint8Array( [ 1, 2, 3 ] ), 0, 3, fcn, {} ); // $ExpectType Uint8Array - fillBy( new Uint8ClampedArray( [ 1, 2, 3 ] ), 0, 3, fcn, {} ); // $ExpectType Uint8ClampedArray - fillBy( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3, fcn, {} ); // $ExpectType Complex128Array - fillBy( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3, fcn, {} ); // $ExpectType Complex64Array - fillBy( new BooleanArray( [ true, false, true, false ] ), 0, 3, fcn, {} ); // $ExpectType BooleanArray -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - fillBy( 5, 0, 3, fcn ); // $ExpectError - fillBy( true, 0, 3, fcn ); // $ExpectError - fillBy( false, 0, 3, fcn ); // $ExpectError - fillBy( null, 0, 3, fcn ); // $ExpectError - fillBy( void 0, 0, 3, fcn ); // $ExpectError - fillBy( {}, 0, 3, fcn ); // $ExpectError - - fillBy( 5, 0, 3, fcn, {} ); // $ExpectError - fillBy( true, 0, 3, fcn, {} ); // $ExpectError - fillBy( false, 0, 3, fcn, {} ); // $ExpectError - fillBy( null, 0, 3, fcn, {} ); // $ExpectError - fillBy( void 0, 0, 3, fcn, {} ); // $ExpectError - fillBy( {}, 0, 3, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - fillBy( x, '5', 3, fcn ); // $ExpectError - fillBy( x, true, 3, fcn ); // $ExpectError - fillBy( x, false, 3, fcn ); // $ExpectError - fillBy( x, null, 3, fcn ); // $ExpectError - fillBy( x, void 0, 3, fcn ); // $ExpectError - fillBy( x, {}, 3, fcn ); // $ExpectError - fillBy( x, ( x: number ): number => x, 3, fcn ); // $ExpectError - - fillBy( x, '5', 3, fcn, {} ); // $ExpectError - fillBy( x, true, 3, fcn, {} ); // $ExpectError - fillBy( x, false, 3, fcn, {} ); // $ExpectError - fillBy( x, null, 3, fcn, {} ); // $ExpectError - fillBy( x, void 0, 3, fcn, {} ); // $ExpectError - fillBy( x, {}, 3, fcn, {} ); // $ExpectError - fillBy( x, ( x: number ): number => x, 3, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - fillBy( x, 0, '5', fcn ); // $ExpectError - fillBy( x, 0, true, fcn ); // $ExpectError - fillBy( x, 0, false, fcn ); // $ExpectError - fillBy( x, 0, null, fcn ); // $ExpectError - fillBy( x, 0, void 0, fcn ); // $ExpectError - fillBy( x, 0, {}, fcn ); // $ExpectError - fillBy( x, 0, ( x: number ): number => x, fcn ); // $ExpectError - - fillBy( x, 0, '5', fcn, {} ); // $ExpectError - fillBy( x, 0, true, fcn, {} ); // $ExpectError - fillBy( x, 0, false, fcn, {} ); // $ExpectError - fillBy( x, 0, null, fcn, {} ); // $ExpectError - fillBy( x, 0, void 0, fcn, {} ); // $ExpectError - fillBy( x, 0, {}, fcn, {} ); // $ExpectError - fillBy( x, 0, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a function... -{ - const x = [ 1, 2, 3 ]; - - fillBy( x, 0, 3, '5' ); // $ExpectError - fillBy( x, 0, 3, true ); // $ExpectError - fillBy( x, 0, 3, false ); // $ExpectError - fillBy( x, 0, 3, null ); // $ExpectError - fillBy( x, 0, 3, void 0 ); // $ExpectError - fillBy( x, 0, 3, {} ); // $ExpectError - fillBy( x, 0, 3, [] ); // $ExpectError - - fillBy( x, 0, 3, '5', {} ); // $ExpectError - fillBy( x, 0, 3, true, {} ); // $ExpectError - fillBy( x, 0, 3, false, {} ); // $ExpectError - fillBy( x, 0, 3, null, {} ); // $ExpectError - fillBy( x, 0, 3, void 0, {} ); // $ExpectError - fillBy( x, 0, 3, {}, {} ); // $ExpectError - fillBy( x, 0, 3, [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - fillBy(); // $ExpectError - fillBy( [ 1, 2, 3 ] ); // $ExpectError - fillBy( [ 1, 2, 3 ], 0 ); // $ExpectError - fillBy( [ 1, 2, 3 ], 0, 1 ); // $ExpectError - fillBy( [ 1, 2, 3 ], 0, 1, fcn, {}, {} ); // $ExpectError -} diff --git a/base/fill-by/examples/index.js b/base/fill-by/examples/index.js deleted file mode 100644 index d4bd1792d..000000000 --- a/base/fill-by/examples/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var constantFunction = require( '@stdlib/utils/constant-function' ); -var Float64Array = require( './../../../float64' ); -var zeroTo = require( './../../../base/zero-to' ); -var fillBy = require( './../lib' ); - -var x = new Float64Array( zeroTo( 6 ) ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -var y = fillBy( x, 0, 6, constantFunction( 10.0 ) ); -console.log( y ); -// => [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ] - -y = fillBy( x, 0, 4, constantFunction( 0.0 ) ); -console.log( y ); -// => [ 0.0, 0.0, 0.0, 0.0, 10.0, 10.0 ] - -y = fillBy( x, 2, 6, constantFunction( 20.0 ) ); -console.log( y ); -// => [ 0.0, 0.0, 20.0, 20.0, 20.0, 20.0 ] - -y = fillBy( x, 2, 4, constantFunction( 30.0 ) ); -console.log( y ); -// => [ 0.0, 0.0, 30.0, 30.0, 20.0, 20.0 ] diff --git a/base/fill-by/lib/index.js b/base/fill-by/lib/index.js deleted file mode 100644 index d3ccd849d..000000000 --- a/base/fill-by/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill all elements within a portion of an array according to a callback function. -* -* @module @stdlib/array/base/fill-by -* -* @example -* var fillBy = require( '@stdlib/array/base/fill-by' ); -* -* function fcn() { -* return 5; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = fillBy( x, 1, 3, fcn ); -* // returns [ 1, 5, 5, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/fill-by/lib/main.js b/base/fill-by/lib/main.js deleted file mode 100644 index e6286cb72..000000000 --- a/base/fill-by/lib/main.js +++ /dev/null @@ -1,173 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Fills all elements within a portion of an indexed array according to a callback function. -* -* @private -* @param {Collection} x - input array -* @param {integer} start - starting index (inclusive) -* @param {integer} end - ending index (exclusive) -* @param {Function} fcn - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} output array -* -* @example -* function fcn() { -* return 5; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = indexed( x, 1, 3, fcn, {} ); -* // returns [ 1, 5, 5, 4 ] -*/ -function indexed( x, start, end, fcn, thisArg ) { - var i; - for ( i = start; i < end; i++ ) { - x[ i ] = fcn.call( thisArg, x[ i ], i, x ); - } - return x; -} - -/** -* Fills all elements within a portion of an accessor array according to a callback function. -* -* @private -* @param {Object} x - input array object -* @param {integer} start - starting index (inclusive) -* @param {integer} end - ending index (exclusive) -* @param {Function} fcn - callback function -* @param {*} thisArg - callback function execution context -* @returns {AccessorArray} modified input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function fcn() { -* return 5; -* } -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* -* var out = accessors( obj, 1, 3, fcn, {} ); -* // returns -* -* var v = x.get( 0 ); -* // returns 1 -* -* v = x.get( 1 ); -* // returns 5 -* -* v = x.get( 2 ); -* // returns 5 -* -* v = x.get( 3 ); -* // returns 4 -*/ -function accessors( x, start, end, fcn, thisArg ) { - var data; - var get; - var set; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - set = x.accessors[ 1 ]; - for ( i = start; i < end; i++ ) { - set( data, i, fcn.call( thisArg, get( data, i ), i, data ) ); - } - return data; -} - - -// MAIN // - -/** -* Fills all elements within a portion of an array according to a callback function. -* -* @param {Collection} x - input array -* @param {integer} start - starting index (inclusive) -* @param {integer} end - ending index (exclusive) -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback function execution context -* @returns {Collection} output array -* -* @example -* function fcn() { -* return 5; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = fillBy( x, 1, 3, fcn ); -* // returns [ 1, 5, 5, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* function fcn() { -* return 5; -* } -* -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var out = fillBy( x, 1, 3, fcn ); -* // returns [ 1, 5, 5, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -function fillBy( x, start, end, fcn, thisArg ) { - var obj; - if ( start < 0 ) { - start += x.length; - if ( start < 0 ) { - start = 0; - } - } - if ( end < 0 ) { - end += x.length; // if `end` is still negative, that is fine, as `x` will be returned un-mutated - } else if ( end > x.length ) { - end = x.length; - } - obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, start, end, fcn, thisArg ); - } - return indexed( x, start, end, fcn, thisArg ); -} - - -// EXPORTS // - -module.exports = fillBy; diff --git a/base/fill-by/package.json b/base/fill-by/package.json deleted file mode 100644 index 52f865e12..000000000 --- a/base/fill-by/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/fill-by", - "version": "0.0.0", - "description": "Fill all elements within a portion of an array according to a callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "typed", - "accessor", - "fill", - "set", - "map", - "transform" - ] -} diff --git a/base/fill-by/test/test.js b/base/fill-by/test/test.js deleted file mode 100644 index 8874db4be..000000000 --- a/base/fill-by/test/test.js +++ /dev/null @@ -1,550 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var fillBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof fillBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function fills an array-like object (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - expected = [ 4, 4, 4 ]; - actual = fillBy( x, 0, x.length, constantFunction( 4 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 5, 5 ]; - actual = fillBy( x, 1, x.length, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 5, 5 ]; - actual = fillBy( x, 1, x.length+10, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 5, 3 ]; - actual = fillBy( x, 1, x.length-1, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 5, 3 ]; - actual = fillBy( x, 1, -1, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 2, 3 ]; - actual = fillBy( x, 1, 1, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 5, 3 ]; - actual = fillBy( x, -2, -1, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 2, 3 ]; - actual = fillBy( x, 10, x.length, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 2, 3 ]; - actual = fillBy( x, 1, -10, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array-like object (float64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 5.0, 5.0, 5.0 ] ); - actual = fillBy( x, 0, x.length, constantFunction( 5.0 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 5.0, 5.0 ] ); - actual = fillBy( x, 1, x.length, constantFunction( 5.0 ) ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 5.0, 5.0 ] ); - actual = fillBy( x, 1, x.length+10, constantFunction( 5.0 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 5.0, 3.0 ] ); - actual = fillBy( x, -2, -1, constantFunction( 5.0 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = fillBy( x, 1, 1, constantFunction( 5.0 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = fillBy( x, 10, x.length, constantFunction( 5.0 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = fillBy( x, 0, -10, constantFunction( 5.0 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array-like object (int32)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 5, 5 ] ); - actual = fillBy( x, 0, x.length, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 5, 5 ] ); - actual = fillBy( x, 0, x.length+10, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 5, 3 ] ); - actual = fillBy( x, 0, x.length-1, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 5, 3 ] ); - actual = fillBy( x, -3, -1, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 2, 3 ] ); - actual = fillBy( x, 0, x.length-2, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = fillBy( x, 0, x.length-3, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = fillBy( x, 10, x.length, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = fillBy( x, 0, -10, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array-like object (accessors)', function test( t ) { - var expected; - var actual; - var obj; - var x; - - x = [ 1, 2, 3, 4 ]; - expected = [ 5, 5, 5, 5 ]; - - obj = new AccessorArray( x ); - actual = fillBy( obj, 0, x.length, constantFunction( 5 ) ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 5, 5, 5, 5 ]; - - obj = new AccessorArray( x ); - actual = fillBy( obj, 0, x.length+10, constantFunction( 5 ) ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 5, 5, 5, 4 ]; - - obj = new AccessorArray( x ); - actual = fillBy( obj, 0, x.length-1, constantFunction( 5 ) ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 5, 5, 4 ]; - - obj = new AccessorArray( x ); - actual = fillBy( obj, 1, x.length-1, constantFunction( 5 ) ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 5, 5, 4 ]; - - obj = new AccessorArray( x ); - actual = fillBy( obj, 1, -1, constantFunction( 5 ) ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 2, 5, 4 ]; - - obj = new AccessorArray( x ); - actual = fillBy( obj, 2, x.length-1, constantFunction( 5 ) ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 2, 3, 4 ]; - - obj = new AccessorArray( x ); - actual = fillBy( obj, 3, x.length-1, constantFunction( 5 ) ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 2, 3, 4 ]; - - obj = new AccessorArray( x ); - actual = fillBy( obj, 10, x.length, constantFunction( 5 ) ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 2, 3, 4 ]; - - obj = new AccessorArray( x ); - actual = fillBy( obj, 0, -10, constantFunction( 5 ) ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array-like object (array-like)', function test( t ) { - var expected; - var actual; - var x; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 5, - '1': 5, - '2': 5, - '3': 5 - }; - actual = fillBy( x, 0, x.length, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 5, - '1': 5, - '2': 5, - '3': 5 - }; - actual = fillBy( x, 0, x.length+10, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 5, - '1': 5, - '2': 5, - '3': 4 - }; - actual = fillBy( x, 0, x.length-1, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 5, - '1': 5, - '2': 5, - '3': 4 - }; - actual = fillBy( x, -4, -1, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 1, - '1': 5, - '2': 5, - '3': 4 - }; - actual = fillBy( x, 1, x.length-1, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 5, - '3': 4 - }; - actual = fillBy( x, 2, x.length-1, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - actual = fillBy( x, 3, x.length-1, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - actual = fillBy( x, 10, x.length, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - actual = fillBy( x, 0, -10, constantFunction( 5 ) ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of length `0`', function test( t ) { - var expected; - var actual; - - expected = []; - actual = fillBy( [], 0, 0, constantFunction( 5 ) ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var actual; - var ctx; - var x; - - x = [ 1, 2, 3, 4 ]; - ctx = { - 'count': 2 - }; - - values = []; - indices = []; - arrays = []; - actual = fillBy( x, 1, 3, fcn, ctx ); - - t.strictEqual( actual, x, 'returns expected value' ); - - expected = [ 1, 20, 30, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 3 ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ x, x ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, index, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - values.push( value ); - indices.push( index ); - arrays.push( arr ); - return value * 10; - } -}); diff --git a/base/fill/README.md b/base/fill/README.md deleted file mode 100644 index cae4db0c3..000000000 --- a/base/fill/README.md +++ /dev/null @@ -1,138 +0,0 @@ - - -# fill - -> Fill all elements within a portion of an array with a specified value. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var fill = require( '@stdlib/array/base/fill' ); -``` - -#### fill( x, value, start, end ) - -Fills all elements within a portion of an array from an inclusive `start` index to an exclusive `end` index with a specified `value`. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var out = fill( x, 10, 1, 4 ); -// returns [ 1, 10, 10, 10, 5, 6 ] - -var bool = ( out === x ); -// returns true -``` - -
- - - - - -
- -## Notes - -- If provided an array-like object having a `fill` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.fill( value, start, end ) - ``` - -- If provided an array-like object without a `fill` method, the function manually sets input array elements to a provided fill value. - -- Negative `start` and `end` indices are resolved to positive indices by counting from the end of the array with `-1` corresponding to the last indexed element. - -- The function **mutates** the input array. - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var fill = require( '@stdlib/array/base/fill' ); - -var x = new Float64Array( zeroTo( 6 ) ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -var y = fill( x, 10.0, 0, 6 ); -// returns [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ] - -y = fill( x, 0.0, 0, 4 ); -// returns [ 0.0, 0.0, 0.0, 0.0, 10.0, 10.0 ] - -y = fill( x, 20.0, 2, 6 ); -// returns [ 0.0, 0.0, 20.0, 20.0, 20.0, 20.0 ] - -y = fill( x, 30.0, 2, 4 ); -// returns [ 0.0, 0.0, 30.0, 30.0, 20.0, 20.0 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/fill/benchmark/benchmark.length.js b/base/fill/benchmark/benchmark.length.js deleted file mode 100644 index 7027f159b..000000000 --- a/base/fill/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var fill = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fill( x, i, 0, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/fill/docs/repl.txt b/base/fill/docs/repl.txt deleted file mode 100644 index ab6f2fcce..000000000 --- a/base/fill/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( x, value, start, end ) - Fills all elements within a portion of an array with a specified value. - - If provided an array-like object having a `fill` method, the function - defers execution to that method and assumes that the method has the - following signature: - - x.fill( value, start, end ) - - If provided an array-like object without a `fill` method, the function - manually sets input array elements to the specified value. - - Negative `start` and `end` indices are resolved to positive indices by - counting from the end of the array with `-1` corresponding to the last - indexed element. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - value: any - Fill value. - - start: integer - Starting index (inclusive). - - end: integer - Ending index (exclusive). - - Returns - ------- - out: ArrayLikeObject - Modified input array. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ], 5, 1, 3 ) - [ 1, 5, 5, 4 ] - - See Also - -------- - diff --git a/base/fill/docs/types/index.d.ts b/base/fill/docs/types/index.d.ts deleted file mode 100644 index f9027b5d1..000000000 --- a/base/fill/docs/types/index.d.ts +++ /dev/null @@ -1,133 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; - -/** -* Fills all elements within a portion of an array with a specified value. -* -* @param x - input array -* @param value - fill value -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @returns modified input array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = fill( x, 4.0, 0, 3 ); -* // returns [ 4.0, 4.0, 4.0 ] -*/ -declare function fill( x: T, value: number, start: number, end: number ): T; - -/** -* Fills all elements within a portion of an array with a specified value. -* -* @param x - input array -* @param value - fill value -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @returns modified input array -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var x = new BooleanArray( [ false, false, false ] ); -* -* var out = fill( x, true, 0, 3 ); -* // returns [ true, true, true ] -*/ -declare function fill( x: T, value: boolean, start: number, end: number ): T; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Fills all elements within a portion of an array with a specified value. -* -* @param x - input array -* @param value - fill value -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @returns modified input array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* var out = fill( x, new Complex128( 7.0, 8.0 ), 0, 3 ); -* // returns [ 7.0, 8.0, 7.0, 8.0, 7.0, 8.0 ] -*/ -declare function fill( x: T, value: ComplexLike, start: number, end: number ): T; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Fills all elements within a portion of an array with a specified value. -* -* @param x - input array -* @param value - fill value -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @returns modified input array -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = fill( x, 4, 0, 3 ); -* // returns [ 4, 4, 4 ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var out = fill( x, 8, 0, 3 ); -* // returns [ 8, 8, 8, 4, 5, 6 ] -*/ -declare function fill( x: Array, value: U, start: number, end: number ): Array; - -/** -* Fills all elements within a portion of an array with a specified value. -* -* @param x - input array -* @param value - fill value -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @returns modified input array -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = fill( x, 4, 0, 3 ); -* // returns [ 4, 4, 4 ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var out = fill( x, 8, 0, 3 ); -* // returns [ 8, 8, 8, 4, 5, 6 ] -*/ -declare function fill( x: Collection, value: U, start: number, end: number ): Collection; - - -// EXPORTS // - -export = fill; diff --git a/base/fill/docs/types/test.ts b/base/fill/docs/types/test.ts deleted file mode 100644 index 54457fff8..000000000 --- a/base/fill/docs/types/test.ts +++ /dev/null @@ -1,90 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import BooleanArray = require( './../../../../bool' ); -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import fill = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const z = new Complex128( 3.0, 5.0 ); - - fill( [ 1, 2, 3 ], 5, 0, 3 ); // $ExpectType number[] - fill( new Float64Array( [ 1, 2, 3 ] ), 5, 0, 3 ); // $ExpectType Float64Array - fill( new Float32Array( [ 1, 2, 3 ] ), 5, 0, 3 ); // $ExpectType Float32Array - fill( new Int32Array( [ 1, 2, 3 ] ), 5, 0, 3 ); // $ExpectType Int32Array - fill( new Int16Array( [ 1, 2, 3 ] ), 5, 0, 3 ); // $ExpectType Int16Array - fill( new Int8Array( [ 1, 2, 3 ] ), 5, 0, 3 ); // $ExpectType Int8Array - fill( new Uint32Array( [ 1, 2, 3 ] ), 5, 0, 3 ); // $ExpectType Uint32Array - fill( new Uint16Array( [ 1, 2, 3 ] ), 5, 0, 3 ); // $ExpectType Uint16Array - fill( new Uint8Array( [ 1, 2, 3 ] ), 5, 0, 3 ); // $ExpectType Uint8Array - fill( new Uint8ClampedArray( [ 1, 2, 3 ] ), 5, 0, 3 ); // $ExpectType Uint8ClampedArray - fill( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), z, 0, 3 ); // $ExpectType Complex128Array - fill( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), z, 0, 3 ); // $ExpectType Complex64Array - fill( new BooleanArray( [ true, false, true, false ] ), false, 0, 3 ); // $ExpectType BooleanArray -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - fill( 5, 5, 0, 3 ); // $ExpectError - fill( true, 5, 0, 3 ); // $ExpectError - fill( false, 5, 0, 3 ); // $ExpectError - fill( null, 5, 0, 3 ); // $ExpectError - fill( void 0, 5, 0, 3 ); // $ExpectError - fill( {}, 5, 0, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - fill( x, 5, '5', 3 ); // $ExpectError - fill( x, 5, true, 3 ); // $ExpectError - fill( x, 5, false, 3 ); // $ExpectError - fill( x, 5, null, 3 ); // $ExpectError - fill( x, 5, void 0, 3 ); // $ExpectError - fill( x, 5, {}, 3 ); // $ExpectError - fill( x, 5, ( x: number ): number => x, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - fill( x, 0, 1, '5' ); // $ExpectError - fill( x, 0, 1, true ); // $ExpectError - fill( x, 0, 1, false ); // $ExpectError - fill( x, 0, 1, null ); // $ExpectError - fill( x, 0, 1, void 0 ); // $ExpectError - fill( x, 0, 1, {} ); // $ExpectError - fill( x, 0, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - fill(); // $ExpectError - fill( [ 1, 2, 3 ] ); // $ExpectError - fill( [ 1, 2, 3 ], 0 ); // $ExpectError - fill( [ 1, 2, 3 ], 0, 1 ); // $ExpectError - fill( [ 1, 2, 3 ], 0, 1, 3, {} ); // $ExpectError -} diff --git a/base/fill/examples/index.js b/base/fill/examples/index.js deleted file mode 100644 index 5a134632a..000000000 --- a/base/fill/examples/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( './../../../float64' ); -var zeroTo = require( './../../../base/zero-to' ); -var fill = require( './../lib' ); - -var x = new Float64Array( zeroTo( 6 ) ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -var y = fill( x, 10.0, 0, 6 ); -console.log( y ); -// => [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ] - -y = fill( x, 0.0, 0, 4 ); -console.log( y ); -// => [ 0.0, 0.0, 0.0, 0.0, 10.0, 10.0 ] - -y = fill( x, 20.0, 2, 6 ); -console.log( y ); -// => [ 0.0, 0.0, 20.0, 20.0, 20.0, 20.0 ] - -y = fill( x, 30.0, 2, 4 ); -console.log( y ); -// => [ 0.0, 0.0, 30.0, 30.0, 20.0, 20.0 ] diff --git a/base/fill/lib/index.js b/base/fill/lib/index.js deleted file mode 100644 index 930b285d0..000000000 --- a/base/fill/lib/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Fill all elements within a portion of an array with a specified value. -* -* @module @stdlib/array/base/fill -* -* @example -* var fill = require( '@stdlib/array/base/fill' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = fill( x, 5, 1, 3 ); -* // returns [ 1, 5, 5, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/fill/lib/main.js b/base/fill/lib/main.js deleted file mode 100644 index c7c950742..000000000 --- a/base/fill/lib/main.js +++ /dev/null @@ -1,175 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'fill' ); -* // e.g., returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - -/** -* Fills all elements within a portion of an indexed array with a specified value. -* -* @private -* @param {Collection} x - input array -* @param {*} value - fill value -* @param {integer} start - starting index (inclusive) -* @param {integer} end - ending index (exclusive) -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = indexed( x, 5, 1, 3 ); -* // returns [ 1, 5, 5, 4 ] -*/ -function indexed( x, value, start, end ) { - var i; - for ( i = start; i < end; i++ ) { - x[ i ] = value; - } - return x; -} - -/** -* Fills all elements within a portion of an accessor array with a specified value. -* -* @private -* @param {Object} x - input array object -* @param {*} value - fill value -* @param {integer} start - starting index (inclusive) -* @param {integer} end - ending index (exclusive) -* @returns {AccessorArray} modified input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* -* var out = accessors( obj, 5, 1, 3 ); -* // returns -* -* var v = x.get( 0 ); -* // returns 1 -* -* v = x.get( 1 ); -* // returns 5 -* -* v = x.get( 2 ); -* // returns 5 -* -* v = x.get( 3 ); -* // returns 4 -*/ -function accessors( x, value, start, end ) { - var data; - var set; - var i; - - data = x.data; - set = x.accessors[ 1 ]; - for ( i = start; i < end; i++ ) { - set( data, i, value ); - } - return data; -} - - -// MAIN // - -/** -* Fills all elements within a portion of an array with a specified value. -* -* @param {Collection} x - input array -* @param {*} value - fill value -* @param {integer} start - starting index (inclusive) -* @param {integer} end - ending index (exclusive) -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = fill( x, 5, 1, 3 ); -* // returns [ 1, 5, 5, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var out = fill( x, 5, 1, 3 ); -* // returns [ 1, 5, 5, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -function fill( x, value, start, end ) { - var obj; - if ( hasMethod( x, 'fill' ) ) { - return x.fill( value, start, end ); - } - if ( start < 0 ) { - start += x.length; - if ( start < 0 ) { - start = 0; - } - } - if ( end < 0 ) { - end += x.length; // if `end` is still negative, that is fine, as `x` will be returned un-mutated - } else if ( end > x.length ) { - end = x.length; - } - obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, value, start, end ); - } - return indexed( x, value, start, end ); -} - - -// EXPORTS // - -module.exports = fill; diff --git a/base/fill/package.json b/base/fill/package.json deleted file mode 100644 index a53b72b52..000000000 --- a/base/fill/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/fill", - "version": "0.0.0", - "description": "Fill all elements within a portion of an array with a specified value.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "typed", - "accessor", - "fill", - "set" - ] -} diff --git a/base/fill/test/test.js b/base/fill/test/test.js deleted file mode 100644 index 4c5edc544..000000000 --- a/base/fill/test/test.js +++ /dev/null @@ -1,515 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var fill = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof fill, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function fills an array-like object (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - expected = [ 4, 4, 4 ]; - actual = fill( x, 4, 0, x.length ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 4, 4, 4 ]; - actual = fill( x, 4, 0, x.length+10 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 4, 4, 4 ]; - actual = fill( x, 4, -10, x.length ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 5, 5 ]; - actual = fill( x, 5, 1, x.length ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 5, 5, 3 ]; - actual = fill( x, 5, -3, -1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 5, 3 ]; - actual = fill( x, 5, 1, x.length-1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 2, 3 ]; - actual = fill( x, 5, 1, 1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 2, 3 ]; - actual = fill( x, 5, 10, 3 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - expected = [ 1, 2, 3 ]; - actual = fill( x, 5, 0, -10 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array-like object (float64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 5.0, 5.0, 5.0 ] ); - actual = fill( x, 5.0, 0, x.length ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 5.0, 5.0, 5.0 ] ); - actual = fill( x, 5.0, 0, x.length+10 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 5.0, 5.0 ] ); - actual = fill( x, 5.0, 1, x.length ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 5.0, 3.0 ] ); - actual = fill( x, 5.0, -2, -1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = fill( x, 5.0, 1, 1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = fill( x, 5.0, 10, x.length ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = fill( x, 5.0, 0, -10 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array-like object (int32)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 5, 5 ] ); - actual = fill( x, 5, 0, x.length ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 5, 5 ] ); - actual = fill( x, 5, 0, x.length+10 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 5, 3 ] ); - actual = fill( x, 5, 0, x.length-1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 5, 3 ] ); - actual = fill( x, 5, -3, -1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 2, 3 ] ); - actual = fill( x, 5, 0, x.length-2 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = fill( x, 5, 0, x.length-3 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = fill( x, 5, 0, -10 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = fill( x, 5, 10, x.length ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = fill( x, 5, 0, -10 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array-like object (accessors)', function test( t ) { - var expected; - var actual; - var obj; - var x; - - x = [ 1, 2, 3, 4 ]; - expected = [ 5, 5, 5, 5 ]; - - obj = new AccessorArray( x ); - actual = fill( obj, 5, 0, x.length ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 5, 5, 5, 5 ]; - - obj = new AccessorArray( x ); - actual = fill( obj, 5, 0, x.length+10 ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 5, 5, 5, 4 ]; - - obj = new AccessorArray( x ); - actual = fill( obj, 5, 0, x.length-1 ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 5, 5, 4 ]; - - obj = new AccessorArray( x ); - actual = fill( obj, 5, 1, x.length-1 ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 5, 5, 4 ]; - - obj = new AccessorArray( x ); - actual = fill( obj, 5, -3, -1 ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 2, 5, 4 ]; - - obj = new AccessorArray( x ); - actual = fill( obj, 5, 2, x.length-1 ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 2, 3, 4 ]; - - obj = new AccessorArray( x ); - actual = fill( obj, 5, 3, x.length-1 ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 2, 3, 4 ]; - - obj = new AccessorArray( x ); - actual = fill( obj, 5, 10, x.length ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - expected = [ 1, 2, 3, 4 ]; - - obj = new AccessorArray( x ); - actual = fill( obj, 5, 0, -10 ); - - t.strictEqual( actual, obj, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array-like object (array-like)', function test( t ) { - var expected; - var actual; - var x; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 5, - '1': 5, - '2': 5, - '3': 5 - }; - actual = fill( x, 5, 0, x.length ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 5, - '1': 5, - '2': 5, - '3': 5 - }; - actual = fill( x, 5, 0, x.length+10 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 5, - '1': 5, - '2': 5, - '3': 4 - }; - actual = fill( x, 5, 0, x.length-1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 5, - '1': 5, - '2': 5, - '3': 4 - }; - actual = fill( x, 5, -4, -1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 1, - '1': 5, - '2': 5, - '3': 4 - }; - actual = fill( x, 5, 1, x.length-1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 5, - '3': 4 - }; - actual = fill( x, 5, 2, x.length-1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - actual = fill( x, 5, 3, x.length-1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - actual = fill( x, 5, 10, x.length ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - actual = fill( x, 5, 0, -10 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of length `0`', function test( t ) { - var expected; - var actual; - - expected = []; - actual = fill( [], 5, 0, 0 ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/filled-by/README.md b/base/filled-by/README.md deleted file mode 100644 index 54b04b9c7..000000000 --- a/base/filled-by/README.md +++ /dev/null @@ -1,159 +0,0 @@ - - -# filledBy - -> Create a filled "generic" array according to a provided callback function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -``` - -#### filledBy( len, clbk\[, thisArg] ) - -Returns a filled "generic" array according to a provided callback function. - -```javascript -function clbk( i ) { - return i; -} - -var out = filledBy( 3, clbk ); -// returns [ 0, 1, 2 ] -``` - -When invoked, a callback function is provided a single argument: - -- **index**: the current array index. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function clbk( i ) { - this.count += 1; - return i; -} - -var ctx = { - 'count': 0 -}; - -var out = filledBy( 3, clbk, ctx ); -// returns [ 0, 1, 2 ]; - -var cnt = ctx.count; -// returns 3 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filledBy = require( '@stdlib/array/base/filled-by' ); - -var out = filledBy( 3, constantFunction( 0.0 ) ); -// returns [ 0.0, 0.0, 0.0 ] - -out = filledBy( 3, constantFunction( 'beep' ) ); -// returns [ 'beep', 'beep', 'beep' ] - -out = filledBy( 3, constantFunction( null ) ); -// returns [ null, null, null ] - -out = filledBy( 3, constantFunction( true ) ); -// returns [ true, true, true ] - -out = filledBy( 3, constantFunction( void 0 ) ); -// returns [ undefined, undefined, undefined ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/filled-by/benchmark/benchmark.length.js b/base/filled-by/benchmark/benchmark.length.js deleted file mode 100644 index 8d6189e7a..000000000 --- a/base/filled-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( len ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filledBy( len, f ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/filled-by/docs/repl.txt b/base/filled-by/docs/repl.txt deleted file mode 100644 index 8fa24c535..000000000 --- a/base/filled-by/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( len, clbk[, thisArg] ) - Returns a filled "generic" array according to a provided callback function. - - Parameters - ---------- - len: integer - Array length. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var out = {{alias}}( 3, clbk ) - [ 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/base/filled-by/docs/types/index.d.ts b/base/filled-by/docs/types/index.d.ts deleted file mode 100644 index 168011800..000000000 --- a/base/filled-by/docs/types/index.d.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = ( this: U ) => T; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( this: U, i: number ) => T; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Returns a filled "generic" array according to a provided callback function. -* -* @param len - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var arr = filledBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledBy( len: number, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - -// EXPORTS // - -export = filledBy; diff --git a/base/filled-by/docs/types/test.ts b/base/filled-by/docs/types/test.ts deleted file mode 100644 index 9e64f4b43..000000000 --- a/base/filled-by/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 filledBy = require( './index' ); - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array... -{ - filledBy( 3, clbk ); // $ExpectType number[] - filledBy( 3, clbk, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not a number... -{ - filledBy( 'abc', clbk ); // $ExpectError - filledBy( true, clbk ); // $ExpectError - filledBy( false, clbk ); // $ExpectError - filledBy( null, clbk ); // $ExpectError - filledBy( [], clbk ); // $ExpectError - filledBy( {}, clbk ); // $ExpectError - filledBy( ( x: number ): number => x, clbk ); // $ExpectError - - filledBy( 'abc', clbk, {} ); // $ExpectError - filledBy( true, clbk, {} ); // $ExpectError - filledBy( false, clbk, {} ); // $ExpectError - filledBy( null, clbk, {} ); // $ExpectError - filledBy( [], clbk, {} ); // $ExpectError - filledBy( {}, clbk, {} ); // $ExpectError - filledBy( ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a callback... -{ - filledBy( 3, 'abc' ); // $ExpectError - filledBy( 3, true ); // $ExpectError - filledBy( 3, false ); // $ExpectError - filledBy( 3, null ); // $ExpectError - filledBy( 3, [] ); // $ExpectError - filledBy( 3, {} ); // $ExpectError - - filledBy( 3, 'abc', {} ); // $ExpectError - filledBy( 3, true, {} ); // $ExpectError - filledBy( 3, false, {} ); // $ExpectError - filledBy( 3, null, {} ); // $ExpectError - filledBy( 3, [], {} ); // $ExpectError - filledBy( 3, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filledBy(); // $ExpectError - filledBy( 3 ); // $ExpectError - filledBy( 3, clbk, 2, 2 ); // $ExpectError -} diff --git a/base/filled-by/examples/index.js b/base/filled-by/examples/index.js deleted file mode 100644 index 519080c5e..000000000 --- a/base/filled-by/examples/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 constantFunction = require( '@stdlib/utils/constant-function' ); -var filledBy = require( './../lib' ); - -var out = filledBy( 3, constantFunction( 0.0 ) ); -console.log( out ); -// => [ 0.0, 0.0, 0.0 ] - -out = filledBy( 3, constantFunction( 'beep' ) ); -console.log( out ); -// => [ 'beep', 'beep', 'beep' ] - -out = filledBy( 3, constantFunction( null ) ); -console.log( out ); -// => [ null, null, null ] - -out = filledBy( 3, constantFunction( true ) ); -console.log( out ); -// => [ true, true, true ] - -out = filledBy( 3, constantFunction( void 0 ) ); -console.log( out ); -// => [ undefined, undefined, undefined ] diff --git a/base/filled-by/lib/index.js b/base/filled-by/lib/index.js deleted file mode 100644 index 6d678be89..000000000 --- a/base/filled-by/lib/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a filled "generic" array according to a provided callback function. -* -* @module @stdlib/array/base/filled-by -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var filledBy = require( '@stdlib/array/base/filled-by' ); -* -* var out = filledBy( 3, constantFunction( 'beep' ) ); -* // returns [ 'beep', 'beep', 'beep' ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/filled-by/lib/main.js b/base/filled-by/lib/main.js deleted file mode 100644 index 9bf280dc9..000000000 --- a/base/filled-by/lib/main.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a filled "generic" array according to a provided callback function. -* -* @param {NonNegativeInteger} len - array length -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback function execution context -* @returns {Array} filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledBy( 3, constantFunction( 'beep' ) ); -* // returns [ 'beep', 'beep', 'beep' ] -*/ -function filledBy( len, clbk, thisArg ) { - var arr; - var i; - - // Manually push elements in order to ensure "fast" elements... - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - - -// EXPORTS // - -module.exports = filledBy; diff --git a/base/filled-by/package.json b/base/filled-by/package.json deleted file mode 100644 index 666818415..000000000 --- a/base/filled-by/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/filled-by", - "version": "0.0.0", - "description": "Create a filled generic array according to a provided callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "callback", - "map", - "foreach" - ] -} diff --git a/base/filled-by/test/test.js b/base/filled-by/test/test.js deleted file mode 100644 index 3fb375ba9..000000000 --- a/base/filled-by/test/test.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 constantFunction = require( '@stdlib/utils/constant-function' ); -var filledBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled "generic" array', function test( t ) { - var expected; - var actual; - - expected = [ 'beep', 'beep', 'beep' ]; - actual = filledBy( 3, constantFunction( 'beep' ) ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a length of `0`', function test( t ) { - var expected; - var actual; - - expected = []; - actual = filledBy( 0, constantFunction( 'beep' ) ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - - ctx = { - 'count': 0 - }; - expected = [ 'beep', 'beep', 'beep' ]; - actual = filledBy( 3, clbk, ctx ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function clbk() { - this.count += 1; // eslint-disable-line no-invalid-this - return 'beep'; - } -}); - -tape( 'the function invokes a provided callback function with one argument', function test( t ) { - var expected; - var actual; - var idx; - - idx = []; - actual = filledBy( 3, clbk ); - - expected = [ 'beep', 'beep', 'beep' ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.deepEqual( idx, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - idx.push( i ); - return 'beep'; - } -}); diff --git a/base/filled/README.md b/base/filled/README.md deleted file mode 100644 index b3f546215..000000000 --- a/base/filled/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# filled - -> Create a filled "generic" array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled = require( '@stdlib/array/base/filled' ); -``` - -#### filled( value, len ) - -Returns a filled "generic" array. - -```javascript -var out = filled( 0.0, 3 ); -// returns [ 0.0, 0.0, 0.0 ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var filled = require( '@stdlib/array/base/filled' ); - -var out = filled( 0.0, 3 ); -// returns [ 0.0, 0.0, 0.0 ] - -out = filled( 'beep', 3 ); -// returns [ 'beep', 'beep', 'beep' ] - -out = filled( null, 3 ); -// returns [ null, null, null ] - -out = filled( true, 3 ); -// returns [ true, true, true ] - -out = filled( void 0, 3 ); -// returns [ undefined, undefined, undefined ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/filled/benchmark/benchmark.length.js b/base/filled/benchmark/benchmark.length.js deleted file mode 100644 index d004af28a..000000000 --- a/base/filled/benchmark/benchmark.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var filled = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled( i, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/filled/docs/repl.txt b/base/filled/docs/repl.txt deleted file mode 100644 index e0894984f..000000000 --- a/base/filled/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( value, len ) - Returns a filled "generic" array. - - Parameters - ---------- - value: any - Fill value. - - len: integer - Array length. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( 0.0, 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/base/filled/docs/types/index.d.ts b/base/filled/docs/types/index.d.ts deleted file mode 100644 index 594041394..000000000 --- a/base/filled/docs/types/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a filled "generic" array. -* -* @param value - fill value, -* @param len - array length -* @returns output array -* -* @example -* var out = filled( 0.0, 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -* -* @example -* var out = filled( 'beep', 3 ); -* // returns [ 'beep', 'beep', 'beep' ] -*/ -declare function filled( value: T, len: number ): Array; - - -// EXPORTS // - -export = filled; diff --git a/base/filled/docs/types/test.ts b/base/filled/docs/types/test.ts deleted file mode 100644 index 91d1017e4..000000000 --- a/base/filled/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 filled = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - filled( 0.0, 3 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - filled( 0.0, 'abc' ); // $ExpectError - filled( 0.0, true ); // $ExpectError - filled( 0.0, false ); // $ExpectError - filled( 0.0, null ); // $ExpectError - filled( 0.0, [] ); // $ExpectError - filled( 0.0, {} ); // $ExpectError - filled( 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled(); // $ExpectError - filled( 0.0 ); // $ExpectError - filled( 0.0, 3, 2 ); // $ExpectError -} diff --git a/base/filled/examples/index.js b/base/filled/examples/index.js deleted file mode 100644 index f7c26890a..000000000 --- a/base/filled/examples/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 filled = require( './../lib' ); - -var out = filled( 0.0, 3 ); -console.log( out ); -// => [ 0.0, 0.0, 0.0 ] - -out = filled( 'beep', 3 ); -console.log( out ); -// => [ 'beep', 'beep', 'beep' ] - -out = filled( null, 3 ); -console.log( out ); -// => [ null, null, null ] - -out = filled( true, 3 ); -console.log( out ); -// => [ true, true, true ] - -out = filled( void 0, 3 ); -console.log( out ); -// => [ undefined, undefined, undefined ] diff --git a/base/filled/lib/index.js b/base/filled/lib/index.js deleted file mode 100644 index c78999419..000000000 --- a/base/filled/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a filled "generic" array. -* -* @module @stdlib/array/base/filled -* -* @example -* var filled = require( '@stdlib/array/base/filled' ); -* -* var out = filled( 0.0, 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -* -* @example -* var filled = require( '@stdlib/array/base/filled' ); -* -* var out = filled( 'beep', 3 ); -* // returns [ 'beep', 'beep', 'beep' ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/filled/lib/main.js b/base/filled/lib/main.js deleted file mode 100644 index 83f3d49a7..000000000 --- a/base/filled/lib/main.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a filled "generic" array. -* -* @param {*} value - fill value -* @param {NonNegativeInteger} len - array length -* @returns {Array} filled array -* -* @example -* var out = filled( 0.0, 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -* -* @example -* var out = filled( 'beep', 3 ); -* // returns [ 'beep', 'beep', 'beep' ] -*/ -function filled( value, len ) { - var arr; - var i; - - // Manually push elements in order to ensure "fast" elements... - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( value ); - } - return arr; -} - - -// EXPORTS // - -module.exports = filled; diff --git a/base/filled/package.json b/base/filled/package.json deleted file mode 100644 index 4cd884c45..000000000 --- a/base/filled/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/filled", - "version": "0.0.0", - "description": "Create a filled generic array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled" - ] -} diff --git a/base/filled/test/test.js b/base/filled/test/test.js deleted file mode 100644 index 644464d44..000000000 --- a/base/filled/test/test.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 filled = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled "generic" array', function test( t ) { - var expected; - var actual; - - expected = [ 'beep', 'beep', 'beep' ]; - actual = filled( 'beep', 3 ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a length of `0`', function test( t ) { - var expected; - var actual; - - expected = []; - actual = filled( 'beep', 0 ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/filled2d-by/README.md b/base/filled2d-by/README.md deleted file mode 100644 index b5b9cf448..000000000 --- a/base/filled2d-by/README.md +++ /dev/null @@ -1,159 +0,0 @@ - - -# filled2dBy - -> Create a filled two-dimensional nested array according to a provided callback function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -``` - -#### filled2dBy( shape, clbk\[, thisArg] ) - -Returns a filled two-dimensional nested array according to a provided callback function. - -```javascript -function clbk() { - return 1.0; -} - -var out = filled2dBy( [ 1, 3 ], clbk ); -// returns [ [ 1.0, 1.0, 1.0 ] ] -``` - -When invoked, a callback function is provided a single argument: - -- **indices**: current array element indices. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function clbk() { - this.count += 1; - return 1.0; -} - -var ctx = { - 'count': 0 -}; - -var out = filled2dBy( [ 2, 3 ], clbk, ctx ); -// returns [ [ 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0 ] ]; - -var cnt = ctx.count; -// returns 6 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); - -var out = filled2dBy( [ 1, 3 ], constantFunction( 0.0 ) ); -// returns [ [ 0.0, 0.0, 0.0 ] ] - -out = filled2dBy( [ 3, 1 ], constantFunction( 'beep' ) ); -// returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] - -out = filled2dBy( [ 1, 3 ], constantFunction( null ) ); -// returns [ [ null, null, null ] ] - -out = filled2dBy( [ 3, 1 ], constantFunction( true ) ); -// returns [ [ true ], [ true ], [ true ] ] - -out = filled2dBy( [ 1, 3 ], constantFunction( void 0 ) ); -// returns [ [ undefined, undefined, undefined ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/filled2d-by/benchmark/benchmark.size.js b/base/filled2d-by/benchmark/benchmark.size.js deleted file mode 100644 index 5b3ed427e..000000000 --- a/base/filled2d-by/benchmark/benchmark.size.js +++ /dev/null @@ -1,100 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filled2dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( N ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled2dBy( [ N, N ], f ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::square_matrix:size='+(N*N), f ); - } -} - -main(); diff --git a/base/filled2d-by/docs/repl.txt b/base/filled2d-by/docs/repl.txt deleted file mode 100644 index 9ca61ef63..000000000 --- a/base/filled2d-by/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( shape, clbk[, thisArg] ) - Returns a filled two-dimensional nested array according to a provided - callback function. - - The callback function is provided one argument: - - - indices: current array element indices. - - Parameters - ---------- - shape: Array - Array shape. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var out = {{alias}}( [ 1, 3 ], clbk ) - [ [ 1.0, 1.0, 1.0 ] ] - - See Also - -------- - diff --git a/base/filled2d-by/docs/types/index.d.ts b/base/filled2d-by/docs/types/index.d.ts deleted file mode 100644 index 932d4885b..000000000 --- a/base/filled2d-by/docs/types/index.d.ts +++ /dev/null @@ -1,72 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = ( this: V ) => T; - -/** -* Unary callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Unary = ( this: V, indices: Array ) => T; - -/** -* Callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Two-dimensional nested array. -*/ -type Array2D = Array>; - -/** -* Returns a filled two-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var arr = filled2dBy( [ 1, 5 ], constantFunction( 1.0 ) ); -* // returns [ [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ] -*/ -declare function filled2dBy( shape: Shape2D, clbk: Callback, thisArg?: ThisParameterType> ): Array2D; - - -// EXPORTS // - -export = filled2dBy; diff --git a/base/filled2d-by/docs/types/test.ts b/base/filled2d-by/docs/types/test.ts deleted file mode 100644 index 5f85d8eea..000000000 --- a/base/filled2d-by/docs/types/test.ts +++ /dev/null @@ -1,81 +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. -*/ - -import filled2dBy = require( './index' ); - -/** -* Callback function. -* -* @param indices - array element indices -* @returns return value -*/ -function clbk( indices: Array ): number { - return indices[ 1 ]; -} - - -// TESTS // - -// The function returns an array... -{ - filled2dBy( [ 1, 3 ], clbk ); // $ExpectType Array2D - filled2dBy( [ 1, 3 ], clbk, {} ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - filled2dBy( 'abc', clbk ); // $ExpectError - filled2dBy( true, clbk ); // $ExpectError - filled2dBy( false, clbk ); // $ExpectError - filled2dBy( null, clbk ); // $ExpectError - filled2dBy( [ '1', 1 ], clbk ); // $ExpectError - filled2dBy( {}, clbk ); // $ExpectError - filled2dBy( ( x: number ): number => x, clbk ); // $ExpectError - - filled2dBy( 'abc', clbk, {} ); // $ExpectError - filled2dBy( true, clbk, {} ); // $ExpectError - filled2dBy( false, clbk, {} ); // $ExpectError - filled2dBy( null, clbk, {} ); // $ExpectError - filled2dBy( [ '1', 1 ], clbk, {} ); // $ExpectError - filled2dBy( {}, clbk, {} ); // $ExpectError - filled2dBy( ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a callback... -{ - filled2dBy( [ 1, 3 ], 'abc' ); // $ExpectError - filled2dBy( [ 1, 3 ], true ); // $ExpectError - filled2dBy( [ 1, 3 ], false ); // $ExpectError - filled2dBy( [ 1, 3 ], null ); // $ExpectError - filled2dBy( [ 1, 3 ], [] ); // $ExpectError - filled2dBy( [ 1, 3 ], {} ); // $ExpectError - - filled2dBy( [ 1, 3 ], 'abc', {} ); // $ExpectError - filled2dBy( [ 1, 3 ], true, {} ); // $ExpectError - filled2dBy( [ 1, 3 ], false, {} ); // $ExpectError - filled2dBy( [ 1, 3 ], null, {} ); // $ExpectError - filled2dBy( [ 1, 3 ], [], {} ); // $ExpectError - filled2dBy( [ 1, 3 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled2dBy(); // $ExpectError - filled2dBy( [ 1, 3 ] ); // $ExpectError - filled2dBy( [ 1, 3 ], clbk, 2, 2 ); // $ExpectError -} diff --git a/base/filled2d-by/examples/index.js b/base/filled2d-by/examples/index.js deleted file mode 100644 index a4475ed3b..000000000 --- a/base/filled2d-by/examples/index.js +++ /dev/null @@ -1,42 +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'; - -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( './../lib' ); - -var out = filled2dBy( [ 1, 3 ], constantFunction( 0.0 ) ); -console.log( out ); -// => [ [ 0.0, 0.0, 0.0 ] ] - -out = filled2dBy( [ 3, 1 ], constantFunction( 'beep' ) ); -console.log( out ); -// => [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] - -out = filled2dBy( [ 1, 3 ], constantFunction( null ) ); -console.log( out ); -// => [ [ null, null, null ] ] - -out = filled2dBy( [ 3, 1 ], constantFunction( true ) ); -console.log( out ); -// => [ [ true ], [ true ], [ true ] ] - -out = filled2dBy( [ 1, 3 ], constantFunction( void 0 ) ); -console.log( out ); -// => [ [ undefined, undefined, undefined ] ] diff --git a/base/filled2d-by/lib/index.js b/base/filled2d-by/lib/index.js deleted file mode 100644 index a615c62bf..000000000 --- a/base/filled2d-by/lib/index.js +++ /dev/null @@ -1,41 +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'; - -/** -* Create a filled two-dimensional nested array according to a provided callback function. -* -* @module @stdlib/array/base/filled2d-by -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -* -* var out = filled2dBy( [ 1, 3 ], constantFunction( 'beep' ) ); -* // returns [ [ 'beep', 'beep', 'beep' ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/filled2d-by/lib/main.js b/base/filled2d-by/lib/main.js deleted file mode 100644 index 984b71b9b..000000000 --- a/base/filled2d-by/lib/main.js +++ /dev/null @@ -1,63 +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'; - -// MAIN // - -/** -* Returns a filled two-dimensional nested array according to a provided callback function. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback function execution context -* @returns {Array} filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filled2dBy( [ 1, 3 ], constantFunction( 'beep' ) ); -* // returns [ [ 'beep', 'beep', 'beep' ] ] -*/ -function filled2dBy( shape, clbk, thisArg ) { - var arr; - var a0; - var S0; - var S1; - var i; - var j; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - - // Manually push elements in order to ensure "fast" elements... - arr = []; - for ( i = 0; i < S1; i++ ) { - a0 = []; - for ( j = 0; j < S0; j++ ) { - a0.push( clbk.call( thisArg, [ i, j ] ) ); - } - arr.push( a0 ); - } - return arr; -} - - -// EXPORTS // - -module.exports = filled2dBy; diff --git a/base/filled2d-by/package.json b/base/filled2d-by/package.json deleted file mode 100644 index bae118e83..000000000 --- a/base/filled2d-by/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/array/base/filled2d-by", - "version": "0.0.0", - "description": "Create a filled two-dimensional nested array according to a provided callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "callback", - "map", - "foreach", - "multidimensional", - "matrix", - "strided", - "ndarray", - "2d" - ] -} diff --git a/base/filled2d-by/test/test.js b/base/filled2d-by/test/test.js deleted file mode 100644 index b62218d2a..000000000 --- a/base/filled2d-by/test/test.js +++ /dev/null @@ -1,142 +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 constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled2dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ [ 'beep', 'beep', 'beep' ] ]; - actual = filled2dBy( [ 1, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ]; - actual = filled2dBy( [ 3, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1, 1, 1 ], [ 1, 1, 1 ] ]; - actual = filled2dBy( [ 2, 3 ], constantFunction( 1 ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - actual = filled2dBy( [ 0, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = filled2dBy( [ 0, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = filled2dBy( [ 0, 100 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filled2dBy( [ 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filled2dBy( [ 2, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filled2dBy( [ 3, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - - ctx = { - 'count': 0 - }; - expected = [ [ 'beep', 'beep', 'beep' ], [ 'beep', 'beep', 'beep' ] ]; - actual = filled2dBy( [ 2, 3 ], clbk, ctx ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - - t.end(); - - function clbk() { - this.count += 1; // eslint-disable-line no-invalid-this - return 'beep'; - } -}); - -tape( 'the function invokes a provided callback function with one argument', function test( t ) { - var expected; - var actual; - var idx; - - idx = []; - actual = filled2dBy( [ 2, 3 ], clbk ); - - expected = [ [ 'beep', 'beep', 'beep' ], [ 'beep', 'beep', 'beep' ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 0 ], - [ 0, 1 ], - [ 0, 2 ], - [ 1, 0 ], - [ 1, 1 ], - [ 1, 2 ] - ]; - t.deepEqual( idx, expected, 'returns expected value' ); - - t.end(); - - function clbk( indices ) { - idx.push( indices ); - return 'beep'; - } -}); diff --git a/base/filled2d/README.md b/base/filled2d/README.md deleted file mode 100644 index 41b8f0ae0..000000000 --- a/base/filled2d/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# filled2d - -> Create a filled two-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled2d = require( '@stdlib/array/base/filled2d' ); -``` - -#### filled2d( value, shape ) - -Returns a filled two-dimensional nested array. - -```javascript -var out = filled2d( 0.0, [ 2, 3 ] ); -// returns [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var filled2d = require( '@stdlib/array/base/filled2d' ); - -var out = filled2d( 0.0, [ 1, 3 ] ); -// returns [ [ 0.0, 0.0, 0.0 ] ] - -out = filled2d( 'beep', [ 3, 1 ] ); -// returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] - -out = filled2d( null, [ 1, 3 ] ); -// returns [ [ null, null, null ] ] - -out = filled2d( true, [ 3, 1 ] ); -// returns [ [ true ], [ true ], [ true ] ] - -out = filled2d( void 0, [ 1, 3 ] ); -// returns [ [ undefined, undefined, undefined ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/filled2d/benchmark/benchmark.size.js b/base/filled2d/benchmark/benchmark.size.js deleted file mode 100644 index bb7c5ab9d..000000000 --- a/base/filled2d/benchmark/benchmark.size.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var filled2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled2d( i, [ N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::square_matrix:size='+(N*N), f ); - } -} - -main(); diff --git a/base/filled2d/docs/repl.txt b/base/filled2d/docs/repl.txt deleted file mode 100644 index 97ff7ded3..000000000 --- a/base/filled2d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( value, shape ) - Returns a filled two-dimensional nested array. - - Parameters - ---------- - value: any - Fill value. - - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( 0.0, [ 1, 3 ] ) - [ [ 0.0, 0.0, 0.0 ] ] - - See Also - -------- - diff --git a/base/filled2d/docs/types/index.d.ts b/base/filled2d/docs/types/index.d.ts deleted file mode 100644 index 826c4c2ac..000000000 --- a/base/filled2d/docs/types/index.d.ts +++ /dev/null @@ -1,50 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Two-dimensional nested array. -*/ -type Array2D = Array>; - -/** -* Returns a filled two-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = filled2d( 0.0, [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -* -* @example -* var out = filled2d( 'beep', [ 1, 3 ] ); -* // returns [ [ 'beep', 'beep', 'beep' ] ] -*/ -declare function filled2d( value: T, shape: Shape2D ): Array2D; - - -// EXPORTS // - -export = filled2d; diff --git a/base/filled2d/docs/types/test.ts b/base/filled2d/docs/types/test.ts deleted file mode 100644 index 847e7d209..000000000 --- a/base/filled2d/docs/types/test.ts +++ /dev/null @@ -1,45 +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. -*/ - -import filled2d = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - filled2d( 0.0, [ 1, 3 ] ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - filled2d( 0.0, 'abc' ); // $ExpectError - filled2d( 0.0, true ); // $ExpectError - filled2d( 0.0, false ); // $ExpectError - filled2d( 0.0, null ); // $ExpectError - filled2d( 0.0, [ '1' ] ); // $ExpectError - filled2d( 0.0, {} ); // $ExpectError - filled2d( 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled2d(); // $ExpectError - filled2d( 0.0 ); // $ExpectError - filled2d( 0.0, [ 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/filled2d/examples/index.js b/base/filled2d/examples/index.js deleted file mode 100644 index 2b1112ec5..000000000 --- a/base/filled2d/examples/index.js +++ /dev/null @@ -1,41 +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'; - -var filled2d = require( './../lib' ); - -var out = filled2d( 0.0, [ 1, 3 ] ); -console.log( out ); -// => [ [ 0.0, 0.0, 0.0 ] ] - -out = filled2d( 'beep', [ 3, 1 ] ); -console.log( out ); -// => [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] - -out = filled2d( null, [ 1, 3 ] ); -console.log( out ); -// => [ [ null, null, null ] ] - -out = filled2d( true, [ 3, 1 ] ); -console.log( out ); -// => [ [ true ], [ true ], [ true ] ] - -out = filled2d( void 0, [ 1, 3 ] ); -console.log( out ); -// => [ [ undefined, undefined, undefined ] ] diff --git a/base/filled2d/lib/index.js b/base/filled2d/lib/index.js deleted file mode 100644 index b3a34eaeb..000000000 --- a/base/filled2d/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Create a filled two-dimensional nested array. -* -* @module @stdlib/array/base/filled2d -* -* @example -* var filled2d = require( '@stdlib/array/base/filled2d' ); -* -* var out = filled2d( 0.0, [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -* -* @example -* var filled2d = require( '@stdlib/array/base/filled2d' ); -* -* var out = filled2d( 'beep', [ 3, 1 ] ); -* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/filled2d/lib/main.js b/base/filled2d/lib/main.js deleted file mode 100644 index 5c326c84d..000000000 --- a/base/filled2d/lib/main.js +++ /dev/null @@ -1,63 +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 filled = require( './../../../base/filled' ); - - -// MAIN // - -/** -* Returns a filled two-dimensional nested array. -* -* @param {*} value - fill value -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = filled2d( 0.0, [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -* -* @example -* var out = filled2d( 'beep', [ 3, 1 ] ); -* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] -*/ -function filled2d( value, shape ) { - var arr; - var S0; - var S1; - var i; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - - // Manually push elements in order to ensure "fast" elements... - arr = []; - for ( i = 0; i < S1; i++ ) { - arr.push( filled( value, S0 ) ); - } - return arr; -} - - -// EXPORTS // - -module.exports = filled2d; diff --git a/base/filled2d/package.json b/base/filled2d/package.json deleted file mode 100644 index 2f2645c9f..000000000 --- a/base/filled2d/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/filled2d", - "version": "0.0.0", - "description": "Create a filled two-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "strided", - "ndarray", - "2d" - ] -} diff --git a/base/filled2d/test/test.js b/base/filled2d/test/test.js deleted file mode 100644 index d1b8f7f58..000000000 --- a/base/filled2d/test/test.js +++ /dev/null @@ -1,89 +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 filled2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ [ 'beep', 'beep', 'beep' ] ]; - actual = filled2d( 'beep', [ 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ]; - actual = filled2d( 'beep', [ 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 'beep', 'beep' ], [ 'beep', 'beep' ], [ 'beep', 'beep' ] ]; - actual = filled2d( 'beep', [ 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = filled2d( 'beep', [ 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filled2d( 'beep', [ 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filled2d( 'beep', [ 0, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filled2d( 'beep', [ 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filled2d( 'beep', [ 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filled2d( 'beep', [ 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/filled3d-by/README.md b/base/filled3d-by/README.md deleted file mode 100644 index 2aa534825..000000000 --- a/base/filled3d-by/README.md +++ /dev/null @@ -1,159 +0,0 @@ - - -# filled3dBy - -> Create a filled three-dimensional nested array according to a provided callback function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -``` - -#### filled3dBy( shape, clbk\[, thisArg] ) - -Returns a filled three-dimensional nested array according to a provided callback function. - -```javascript -function clbk() { - return 1.0; -} - -var out = filled3dBy( [ 2, 1, 3 ], clbk ); -// returns [ [ [ 1.0, 1.0, 1.0 ] ], [ [ 1.0, 1.0, 1.0 ] ] ] -``` - -When invoked, a callback function is provided a single argument: - -- **indices**: current array element indices. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function clbk() { - this.count += 1; - return 1.0; -} - -var ctx = { - 'count': 0 -}; - -var out = filled3dBy( [ 1, 2, 3 ], clbk, ctx ); -// returns [ [ [ 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0 ] ] ]; - -var cnt = ctx.count; -// returns 6 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); - -var out = filled3dBy( [ 1, 1, 3 ], constantFunction( 0.0 ) ); -// returns [ [ [ 0.0, 0.0, 0.0 ] ] ] - -out = filled3dBy( [ 1, 3, 1 ], constantFunction( 'beep' ) ); -// returns [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] - -out = filled3dBy( [ 1, 1, 3 ], constantFunction( null ) ); -// returns [ [ [ null, null, null ] ] ] - -out = filled3dBy( [ 1, 3, 1 ], constantFunction( true ) ); -// returns [ [ [ true ], [ true ], [ true ] ] ] - -out = filled3dBy( [ 1, 1, 3 ], constantFunction( void 0 ) ); -// returns [ [ [ undefined, undefined, undefined ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/filled3d-by/benchmark/benchmark.size.js b/base/filled3d-by/benchmark/benchmark.size.js deleted file mode 100644 index 129d88d22..000000000 --- a/base/filled3d-by/benchmark/benchmark.size.js +++ /dev/null @@ -1,100 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var cbrt = require( '@stdlib/math/base/special/cbrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filled3dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( N ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled3dBy( [ N, N, N ], f ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( cbrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N), f ); - } -} - -main(); diff --git a/base/filled3d-by/docs/repl.txt b/base/filled3d-by/docs/repl.txt deleted file mode 100644 index de09a2607..000000000 --- a/base/filled3d-by/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( shape, clbk[, thisArg] ) - Returns a filled three-dimensional nested array according to a provided - callback function. - - The callback function is provided one argument: - - - indices: current array element indices. - - Parameters - ---------- - shape: Array - Array shape. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var out = {{alias}}( [ 1, 1, 3 ], clbk ) - [ [ [ 1.0, 1.0, 1.0 ] ] ] - - See Also - -------- - diff --git a/base/filled3d-by/docs/types/index.d.ts b/base/filled3d-by/docs/types/index.d.ts deleted file mode 100644 index 4877dd967..000000000 --- a/base/filled3d-by/docs/types/index.d.ts +++ /dev/null @@ -1,72 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = ( this: V ) => T; - -/** -* Unary callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Unary = ( this: V, indices: Array ) => T; - -/** -* Callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Three-dimensional nested array. -*/ -type Array3D = Array>>; - -/** -* Returns a filled three-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var arr = filled3dBy( [ 1, 1, 5 ], constantFunction( 1.0 ) ); -* // returns [ [ [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ] ] -*/ -declare function filled3dBy( shape: Shape3D, clbk: Callback, thisArg?: ThisParameterType> ): Array3D; - - -// EXPORTS // - -export = filled3dBy; diff --git a/base/filled3d-by/docs/types/test.ts b/base/filled3d-by/docs/types/test.ts deleted file mode 100644 index 1afb137ea..000000000 --- a/base/filled3d-by/docs/types/test.ts +++ /dev/null @@ -1,81 +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. -*/ - -import filled3dBy = require( './index' ); - -/** -* Callback function. -* -* @param indices - array element indices -* @returns return value -*/ -function clbk( indices: Array ): number { - return indices[ 1 ]; -} - - -// TESTS // - -// The function returns an array... -{ - filled3dBy( [ 1, 1, 3 ], clbk ); // $ExpectType Array3D - filled3dBy( [ 1, 1, 3 ], clbk, {} ); // $ExpectType Array3D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - filled3dBy( 'abc', clbk ); // $ExpectError - filled3dBy( true, clbk ); // $ExpectError - filled3dBy( false, clbk ); // $ExpectError - filled3dBy( null, clbk ); // $ExpectError - filled3dBy( [ '1', 1 ], clbk ); // $ExpectError - filled3dBy( {}, clbk ); // $ExpectError - filled3dBy( ( x: number ): number => x, clbk ); // $ExpectError - - filled3dBy( 'abc', clbk, {} ); // $ExpectError - filled3dBy( true, clbk, {} ); // $ExpectError - filled3dBy( false, clbk, {} ); // $ExpectError - filled3dBy( null, clbk, {} ); // $ExpectError - filled3dBy( [ '1', 1 ], clbk, {} ); // $ExpectError - filled3dBy( {}, clbk, {} ); // $ExpectError - filled3dBy( ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a callback... -{ - filled3dBy( [ 1, 1, 3 ], 'abc' ); // $ExpectError - filled3dBy( [ 1, 1, 3 ], true ); // $ExpectError - filled3dBy( [ 1, 1, 3 ], false ); // $ExpectError - filled3dBy( [ 1, 1, 3 ], null ); // $ExpectError - filled3dBy( [ 1, 1, 3 ], [] ); // $ExpectError - filled3dBy( [ 1, 1, 3 ], {} ); // $ExpectError - - filled3dBy( [ 1, 1, 3 ], 'abc', {} ); // $ExpectError - filled3dBy( [ 1, 1, 3 ], true, {} ); // $ExpectError - filled3dBy( [ 1, 1, 3 ], false, {} ); // $ExpectError - filled3dBy( [ 1, 1, 3 ], null, {} ); // $ExpectError - filled3dBy( [ 1, 1, 3 ], [], {} ); // $ExpectError - filled3dBy( [ 1, 1, 3 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled3dBy(); // $ExpectError - filled3dBy( [ 1, 1, 3 ] ); // $ExpectError - filled3dBy( [ 1, 1, 3 ], clbk, 2, 2 ); // $ExpectError -} diff --git a/base/filled3d-by/examples/index.js b/base/filled3d-by/examples/index.js deleted file mode 100644 index e4d85b5cc..000000000 --- a/base/filled3d-by/examples/index.js +++ /dev/null @@ -1,42 +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'; - -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled3dBy = require( './../lib' ); - -var out = filled3dBy( [ 1, 1, 3 ], constantFunction( 0.0 ) ); -console.log( out ); -// => [ [ [ 0.0, 0.0, 0.0 ] ] ] - -out = filled3dBy( [ 1, 3, 1 ], constantFunction( 'beep' ) ); -console.log( out ); -// => [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] - -out = filled3dBy( [ 1, 1, 3 ], constantFunction( null ) ); -console.log( out ); -// => [ [ [ null, null, null ] ] ] - -out = filled3dBy( [ 1, 3, 1 ], constantFunction( true ) ); -console.log( out ); -// => [ [ [ true ], [ true ], [ true ] ] ] - -out = filled3dBy( [ 1, 1, 3 ], constantFunction( void 0 ) ); -console.log( out ); -// => [ [ [ undefined, undefined, undefined ] ] ] diff --git a/base/filled3d-by/lib/index.js b/base/filled3d-by/lib/index.js deleted file mode 100644 index c2f580a43..000000000 --- a/base/filled3d-by/lib/index.js +++ /dev/null @@ -1,41 +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'; - -/** -* Create a filled three-dimensional nested array according to a provided callback function. -* -* @module @stdlib/array/base/filled3d-by -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -* -* var out = filled3dBy( [ 1, 1, 3 ], constantFunction( 'beep' ) ); -* // returns [ [ [ 'beep', 'beep', 'beep' ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/filled3d-by/lib/main.js b/base/filled3d-by/lib/main.js deleted file mode 100644 index 6413a568d..000000000 --- a/base/filled3d-by/lib/main.js +++ /dev/null @@ -1,71 +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'; - -// MAIN // - -/** -* Returns a filled three-dimensional nested array according to a provided callback function. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback function execution context -* @returns {Array} filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filled3dBy( [ 1, 1, 3 ], constantFunction( 'beep' ) ); -* // returns [ [ [ 'beep', 'beep', 'beep' ] ] ] -*/ -function filled3dBy( shape, clbk, thisArg ) { - var arr; - var a0; - var a1; - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - - // Manually push elements in order to ensure "fast" elements... - arr = []; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - a0.push( clbk.call( thisArg, [ i2, i1, i0 ] ) ); - } - a1.push( a0 ); - } - arr.push( a1 ); - } - return arr; -} - - -// EXPORTS // - -module.exports = filled3dBy; diff --git a/base/filled3d-by/package.json b/base/filled3d-by/package.json deleted file mode 100644 index ed7790161..000000000 --- a/base/filled3d-by/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/array/base/filled3d-by", - "version": "0.0.0", - "description": "Create a filled three-dimensional nested array according to a provided callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "callback", - "map", - "foreach", - "multidimensional", - "matrix", - "strided", - "ndarray", - "3d" - ] -} diff --git a/base/filled3d-by/test/test.js b/base/filled3d-by/test/test.js deleted file mode 100644 index 44f2f3aea..000000000 --- a/base/filled3d-by/test/test.js +++ /dev/null @@ -1,209 +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 constantFunction = require( '@stdlib/utils/constant-function' ); -var filled3dBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled3dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ]; - actual = filled3dBy( [ 1, 1, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ]; - actual = filled3dBy( [ 1, 3, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ], - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ] - ]; - actual = filled3dBy( [ 2, 2, 3 ], constantFunction( 1 ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - actual = filled3dBy( [ 0, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = filled3dBy( [ 0, 0, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = filled3dBy( [ 0, 100, 100 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filled3dBy( [ 1, 0, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filled3dBy( [ 2, 0, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filled3dBy( [ 3, 0, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ [] ] - ]; - actual = filled3dBy( [ 1, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [] - ], - [ - [] - ] - ]; - actual = filled3dBy( [ 2, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [] - ], - [ - [] - ], - [ - [] - ] - ]; - actual = filled3dBy( [ 3, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - - ctx = { - 'count': 0 - }; - expected = [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ]; - actual = filled3dBy( [ 1, 2, 3 ], clbk, ctx ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - - t.end(); - - function clbk() { - this.count += 1; // eslint-disable-line no-invalid-this - return 'beep'; - } -}); - -tape( 'the function invokes a provided callback function with one argument', function test( t ) { - var expected; - var actual; - var idx; - - idx = []; - actual = filled3dBy( [ 1, 2, 3 ], clbk ); - - expected = [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 0, 0, 1 ], - [ 0, 0, 2 ], - [ 0, 1, 0 ], - [ 0, 1, 1 ], - [ 0, 1, 2 ] - ]; - t.deepEqual( idx, expected, 'returns expected value' ); - - t.end(); - - function clbk( indices ) { - idx.push( indices ); - return 'beep'; - } -}); diff --git a/base/filled3d/README.md b/base/filled3d/README.md deleted file mode 100644 index b9de5bcb7..000000000 --- a/base/filled3d/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# filled3d - -> Create a filled three-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled3d = require( '@stdlib/array/base/filled3d' ); -``` - -#### filled3d( value, shape ) - -Returns a filled three-dimensional nested array. - -```javascript -var out = filled3d( 0.0, [ 1, 2, 3 ] ); -// returns [ [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var filled3d = require( '@stdlib/array/base/filled3d' ); - -var out = filled3d( 0.0, [ 1, 1, 3 ] ); -// returns [ [ [ 0.0, 0.0, 0.0 ] ] ] - -out = filled3d( 'beep', [ 1, 3, 1 ] ); -// returns [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] - -out = filled3d( null, [ 1, 1, 3 ] ); -// returns [ [ [ null, null, null ] ] ] - -out = filled3d( true, [ 1, 3, 1 ] ); -// returns [ [ [ true ], [ true ], [ true ] ] ] - -out = filled3d( void 0, [ 1, 1, 3 ] ); -// returns [ [ [ undefined, undefined, undefined ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/filled3d/benchmark/benchmark.size.js b/base/filled3d/benchmark/benchmark.size.js deleted file mode 100644 index 1df2a181b..000000000 --- a/base/filled3d/benchmark/benchmark.size.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var cbrt = require( '@stdlib/math/base/special/cbrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var filled3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled3d( i, [ N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( cbrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N), f ); - } -} - -main(); diff --git a/base/filled3d/docs/repl.txt b/base/filled3d/docs/repl.txt deleted file mode 100644 index 83858ae45..000000000 --- a/base/filled3d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( value, shape ) - Returns a filled three-dimensional nested array. - - Parameters - ---------- - value: any - Fill value. - - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( 0.0, [ 1, 1, 3 ] ) - [ [ [ 0.0, 0.0, 0.0 ] ] ] - - See Also - -------- - diff --git a/base/filled3d/docs/types/index.d.ts b/base/filled3d/docs/types/index.d.ts deleted file mode 100644 index 5d9b97c69..000000000 --- a/base/filled3d/docs/types/index.d.ts +++ /dev/null @@ -1,50 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Three-dimensional nested array. -*/ -type Array3D = Array>>; - -/** -* Returns a filled three-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = filled3d( 0.0, [ 1, 1, 3 ] ); -* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ] -* -* @example -* var out = filled3d( 'beep', [ 1, 1, 3 ] ); -* // returns [ [ [ 'beep', 'beep', 'beep' ] ] ] -*/ -declare function filled3d( value: T, shape: Shape3D ): Array3D; - - -// EXPORTS // - -export = filled3d; diff --git a/base/filled3d/docs/types/test.ts b/base/filled3d/docs/types/test.ts deleted file mode 100644 index f1923f8e7..000000000 --- a/base/filled3d/docs/types/test.ts +++ /dev/null @@ -1,45 +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. -*/ - -import filled3d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - filled3d( 0.0, [ 1, 1, 3 ] ); // $ExpectType Array3D -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - filled3d( 0.0, 'abc' ); // $ExpectError - filled3d( 0.0, true ); // $ExpectError - filled3d( 0.0, false ); // $ExpectError - filled3d( 0.0, null ); // $ExpectError - filled3d( 0.0, [ '1' ] ); // $ExpectError - filled3d( 0.0, {} ); // $ExpectError - filled3d( 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled3d(); // $ExpectError - filled3d( 0.0 ); // $ExpectError - filled3d( 0.0, [ 1, 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/filled3d/examples/index.js b/base/filled3d/examples/index.js deleted file mode 100644 index ccc1f32be..000000000 --- a/base/filled3d/examples/index.js +++ /dev/null @@ -1,41 +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'; - -var filled3d = require( './../lib' ); - -var out = filled3d( 0.0, [ 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ 0.0, 0.0, 0.0 ] ] ] - -out = filled3d( 'beep', [ 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] - -out = filled3d( null, [ 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ null, null, null ] ] ] - -out = filled3d( true, [ 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ true ], [ true ], [ true ] ] ] - -out = filled3d( void 0, [ 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ undefined, undefined, undefined ] ] ] diff --git a/base/filled3d/lib/index.js b/base/filled3d/lib/index.js deleted file mode 100644 index 32d174def..000000000 --- a/base/filled3d/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Create a filled three-dimensional nested array. -* -* @module @stdlib/array/base/filled3d -* -* @example -* var filled3d = require( '@stdlib/array/base/filled3d' ); -* -* var out = filled3d( 0.0, [ 1, 1, 3 ] ); -* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ] -* -* @example -* var filled3d = require( '@stdlib/array/base/filled3d' ); -* -* var out = filled3d( 'beep', [ 1, 3, 1 ] ); -* // returns [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/filled3d/lib/main.js b/base/filled3d/lib/main.js deleted file mode 100644 index a653092e4..000000000 --- a/base/filled3d/lib/main.js +++ /dev/null @@ -1,71 +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 filled = require( './../../../base/filled' ); - - -// MAIN // - -/** -* Returns a filled three-dimensional nested array. -* -* @param {*} value - fill value -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = filled3d( 0.0, [ 1, 1, 3 ] ); -* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ] -* -* @example -* var out = filled3d( 'beep', [ 1, 3, 1 ] ); -* // returns [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] -*/ -function filled3d( value, shape ) { - var out; - var a1; - var S0; - var S1; - var S2; - var i2; - var i1; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - - // Manually push elements in order to ensure "fast" elements... - out = []; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - a1.push( filled( value, S0 ) ); - } - out.push( a1 ); - } - return out; -} - - -// EXPORTS // - -module.exports = filled3d; diff --git a/base/filled3d/package.json b/base/filled3d/package.json deleted file mode 100644 index 3296d3f4a..000000000 --- a/base/filled3d/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/filled3d", - "version": "0.0.0", - "description": "Create a filled three-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "3d" - ] -} diff --git a/base/filled3d/test/test.js b/base/filled3d/test/test.js deleted file mode 100644 index 8f684b355..000000000 --- a/base/filled3d/test/test.js +++ /dev/null @@ -1,134 +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 filled3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ]; - actual = filled3d( 'beep', [ 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ]; - actual = filled3d( 'beep', [ 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ]; - actual = filled3d( 'beep', [ 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = filled3d( 'beep', [ 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filled3d( 'beep', [ 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filled3d( 'beep', [ 0, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filled3d( 'beep', [ 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filled3d( 'beep', [ 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filled3d( 'beep', [ 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [ [] ] ]; - actual = filled3d( 'beep', [ 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [] ] ]; - actual = filled3d( 'beep', [ 1, 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [], [] ] ]; - actual = filled3d( 'beep', [ 1, 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/filled4d-by/README.md b/base/filled4d-by/README.md deleted file mode 100644 index 2413c354d..000000000 --- a/base/filled4d-by/README.md +++ /dev/null @@ -1,159 +0,0 @@ - - -# filled4dBy - -> Create a filled four-dimensional nested array according to a provided callback function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -``` - -#### filled4dBy( shape, clbk\[, thisArg] ) - -Returns a filled four-dimensional nested array according to a provided callback function. - -```javascript -function clbk() { - return 1.0; -} - -var out = filled4dBy( [ 1, 2, 1, 3 ], clbk ); -// returns [ [ [ [ 1.0, 1.0, 1.0 ] ], [ [ 1.0, 1.0, 1.0 ] ] ] ] -``` - -When invoked, a callback function is provided a single argument: - -- **indices**: current array element indices. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function clbk() { - this.count += 1; - return 1.0; -} - -var ctx = { - 'count': 0 -}; - -var out = filled4dBy( [ 1, 1, 2, 3 ], clbk, ctx ); -// returns [ [ [ [ 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0 ] ] ] ] - -var cnt = ctx.count; -// returns 6 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); - -var out = filled4dBy( [ 1, 1, 1, 3 ], constantFunction( 0.0 ) ); -// returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] - -out = filled4dBy( [ 1, 1, 3, 1 ], constantFunction( 'beep' ) ); -// returns [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] - -out = filled4dBy( [ 1, 1, 1, 3 ], constantFunction( null ) ); -// returns [ [ [ [ null, null, null ] ] ] ] - -out = filled4dBy( [ 1, 1, 3, 1 ], constantFunction( true ) ); -// returns [ [ [ [ true ], [ true ], [ true ] ] ] ] - -out = filled4dBy( [ 1, 1, 1, 3 ], constantFunction( void 0 ) ); -// returns [ [ [ [ undefined, undefined, undefined ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/filled4d-by/benchmark/benchmark.size.js b/base/filled4d-by/benchmark/benchmark.size.js deleted file mode 100644 index bd6fd526c..000000000 --- a/base/filled4d-by/benchmark/benchmark.size.js +++ /dev/null @@ -1,99 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filled4dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( N ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled4dBy( [ N, N, N, N ], f ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N*N), f ); - } -} - -main(); diff --git a/base/filled4d-by/docs/repl.txt b/base/filled4d-by/docs/repl.txt deleted file mode 100644 index d067047aa..000000000 --- a/base/filled4d-by/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( shape, clbk[, thisArg] ) - Returns a filled four-dimensional nested array according to a provided - callback function. - - The callback function is provided one argument: - - - indices: current array element indices. - - Parameters - ---------- - shape: Array - Array shape. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var out = {{alias}}( [ 1, 1, 1, 3 ], clbk ) - [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] - - See Also - -------- - diff --git a/base/filled4d-by/docs/types/index.d.ts b/base/filled4d-by/docs/types/index.d.ts deleted file mode 100644 index 926feab91..000000000 --- a/base/filled4d-by/docs/types/index.d.ts +++ /dev/null @@ -1,72 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = ( this: V ) => T; - -/** -* Unary callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Unary = ( this: V, indices: Array ) => T; - -/** -* Callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Four-dimensional nested array. -*/ -type Array4D = Array>>>; - -/** -* Returns a filled four-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var arr = filled4dBy( [ 1, 1, 1, 5 ], constantFunction( 1.0 ) ); -* // returns [ [ [ [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ] ] ] -*/ -declare function filled4dBy( shape: Shape4D, clbk: Callback, thisArg?: ThisParameterType> ): Array4D; - - -// EXPORTS // - -export = filled4dBy; diff --git a/base/filled4d-by/docs/types/test.ts b/base/filled4d-by/docs/types/test.ts deleted file mode 100644 index 0698ef6a1..000000000 --- a/base/filled4d-by/docs/types/test.ts +++ /dev/null @@ -1,81 +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. -*/ - -import filled4dBy = require( './index' ); - -/** -* Callback function. -* -* @param indices - array element indices -* @returns return value -*/ -function clbk( indices: Array ): number { - return indices[ 1 ]; -} - - -// TESTS // - -// The function returns an array... -{ - filled4dBy( [ 1, 1, 1, 3 ], clbk ); // $ExpectType Array4D - filled4dBy( [ 1, 1, 1, 3 ], clbk, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - filled4dBy( 'abc', clbk ); // $ExpectError - filled4dBy( true, clbk ); // $ExpectError - filled4dBy( false, clbk ); // $ExpectError - filled4dBy( null, clbk ); // $ExpectError - filled4dBy( [ '1', 1 ], clbk ); // $ExpectError - filled4dBy( {}, clbk ); // $ExpectError - filled4dBy( ( x: number ): number => x, clbk ); // $ExpectError - - filled4dBy( 'abc', clbk, {} ); // $ExpectError - filled4dBy( true, clbk, {} ); // $ExpectError - filled4dBy( false, clbk, {} ); // $ExpectError - filled4dBy( null, clbk, {} ); // $ExpectError - filled4dBy( [ '1', 1 ], clbk, {} ); // $ExpectError - filled4dBy( {}, clbk, {} ); // $ExpectError - filled4dBy( ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a callback... -{ - filled4dBy( [ 1, 1, 1, 3 ], 'abc' ); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ], true ); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ], false ); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ], null ); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ], [] ); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ], {} ); // $ExpectError - - filled4dBy( [ 1, 1, 1, 3 ], 'abc', {} ); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ], true, {} ); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ], false, {} ); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ], null, {} ); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ], [], {} ); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled4dBy(); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ] ); // $ExpectError - filled4dBy( [ 1, 1, 1, 3 ], clbk, 2, 2 ); // $ExpectError -} diff --git a/base/filled4d-by/examples/index.js b/base/filled4d-by/examples/index.js deleted file mode 100644 index 1372a7fe1..000000000 --- a/base/filled4d-by/examples/index.js +++ /dev/null @@ -1,42 +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'; - -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled4dBy = require( './../lib' ); - -var out = filled4dBy( [ 1, 1, 1, 3 ], constantFunction( 0.0 ) ); -console.log( out ); -// => [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] - -out = filled4dBy( [ 1, 1, 3, 1 ], constantFunction( 'beep' ) ); -console.log( out ); -// => [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] - -out = filled4dBy( [ 1, 1, 1, 3 ], constantFunction( null ) ); -console.log( out ); -// => [ [ [ [ null, null, null ] ] ] ] - -out = filled4dBy( [ 1, 1, 3, 1 ], constantFunction( true ) ); -console.log( out ); -// => [ [ [ [ true ], [ true ], [ true ] ] ] ] - -out = filled4dBy( [ 1, 1, 1, 3 ], constantFunction( void 0 ) ); -console.log( out ); -// => [ [ [ [ undefined, undefined, undefined ] ] ] ] diff --git a/base/filled4d-by/lib/index.js b/base/filled4d-by/lib/index.js deleted file mode 100644 index 3cd7ac75d..000000000 --- a/base/filled4d-by/lib/index.js +++ /dev/null @@ -1,41 +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'; - -/** -* Create a filled four-dimensional nested array according to a provided callback function. -* -* @module @stdlib/array/base/filled4d-by -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -* -* var out = filled4dBy( [ 1, 1, 1, 3 ], constantFunction( 'beep' ) ); -* // returns [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/filled4d-by/lib/main.js b/base/filled4d-by/lib/main.js deleted file mode 100644 index d5928db9a..000000000 --- a/base/filled4d-by/lib/main.js +++ /dev/null @@ -1,79 +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'; - -// MAIN // - -/** -* Returns a filled four-dimensional nested array according to a provided callback function. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback function execution context -* @returns {Array} filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filled4dBy( [ 1, 1, 1, 3 ], constantFunction( 'beep' ) ); -* // returns [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] -*/ -function filled4dBy( shape, clbk, thisArg ) { - var arr; - var a0; - var a1; - var a2; - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - - // Manually push elements in order to ensure "fast" elements... - arr = []; - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - a0.push( clbk.call( thisArg, [ i3, i2, i1, i0 ] ) ); - } - a1.push( a0 ); - } - a2.push( a1 ); - } - arr.push( a2 ); - } - return arr; -} - - -// EXPORTS // - -module.exports = filled4dBy; diff --git a/base/filled4d-by/package.json b/base/filled4d-by/package.json deleted file mode 100644 index d2e7f1fa1..000000000 --- a/base/filled4d-by/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/array/base/filled4d-by", - "version": "0.0.0", - "description": "Create a filled four-dimensional nested array according to a provided callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "callback", - "map", - "foreach", - "multidimensional", - "matrix", - "strided", - "ndarray", - "4d" - ] -} diff --git a/base/filled4d-by/test/test.js b/base/filled4d-by/test/test.js deleted file mode 100644 index 3da2ad9c2..000000000 --- a/base/filled4d-by/test/test.js +++ /dev/null @@ -1,281 +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 constantFunction = require( '@stdlib/utils/constant-function' ); -var filled4dBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled4dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ] - ]; - actual = filled4dBy( [ 1, 1, 1, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ]; - actual = filled4dBy( [ 1, 1, 3, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ], - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ] - ], - [ - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ], - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ] - ] - ]; - actual = filled4dBy( [ 2, 2, 2, 3 ], constantFunction( 1 ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - actual = filled4dBy( [ 0, 1, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = filled4dBy( [ 0, 0, 0, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = filled4dBy( [ 0, 100, 100, 100 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filled4dBy( [ 1, 0, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filled4dBy( [ 2, 0, 2, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filled4dBy( [ 3, 0, 3, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ [] ] - ]; - actual = filled4dBy( [ 1, 1, 0, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [] - ], - [ - [] - ] - ]; - actual = filled4dBy( [ 2, 1, 0, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [] - ], - [ - [] - ], - [ - [] - ] - ]; - actual = filled4dBy( [ 3, 1, 0, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = filled4dBy( [ 1, 1, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ] - ], - [ - [ [] ] - ] - ]; - actual = filled4dBy( [ 2, 1, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ] - ], - [ - [ [] ] - ], - [ - [ [] ] - ] - ]; - actual = filled4dBy( [ 3, 1, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - - ctx = { - 'count': 0 - }; - expected = [ - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ] - ]; - actual = filled4dBy( [ 1, 1, 2, 3 ], clbk, ctx ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - - t.end(); - - function clbk() { - this.count += 1; // eslint-disable-line no-invalid-this - return 'beep'; - } -}); - -tape( 'the function invokes a provided callback function with one argument', function test( t ) { - var expected; - var actual; - var idx; - - idx = []; - actual = filled4dBy( [ 2, 1, 2, 3 ], clbk ); - - expected = [ - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ], - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 0, 2 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ], - [ 0, 0, 1, 2 ], - [ 1, 0, 0, 0 ], - [ 1, 0, 0, 1 ], - [ 1, 0, 0, 2 ], - [ 1, 0, 1, 0 ], - [ 1, 0, 1, 1 ], - [ 1, 0, 1, 2 ] - ]; - t.deepEqual( idx, expected, 'returns expected value' ); - - t.end(); - - function clbk( indices ) { - idx.push( indices ); - return 'beep'; - } -}); diff --git a/base/filled4d/README.md b/base/filled4d/README.md deleted file mode 100644 index 98742fa70..000000000 --- a/base/filled4d/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# filled4d - -> Create a filled four-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled4d = require( '@stdlib/array/base/filled4d' ); -``` - -#### filled4d( value, shape ) - -Returns a filled four-dimensional nested array. - -```javascript -var out = filled4d( 0.0, [ 1, 1, 2, 3 ] ); -// returns [ [ [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var filled4d = require( '@stdlib/array/base/filled4d' ); - -var out = filled4d( 0.0, [ 1, 1, 1, 3 ] ); -// returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] - -out = filled4d( 'beep', [ 1, 1, 3, 1 ] ); -// returns [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] - -out = filled4d( null, [ 1, 1, 1, 3 ] ); -// returns [ [ [ [ null, null, null ] ] ] ] - -out = filled4d( true, [ 1, 1, 3, 1 ] ); -// returns [ [ [ [ true ], [ true ], [ true ] ] ] ] - -out = filled4d( void 0, [ 1, 1, 1, 3 ] ); -// returns [ [ [ [ undefined, undefined, undefined ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/filled4d/benchmark/benchmark.size.js b/base/filled4d/benchmark/benchmark.size.js deleted file mode 100644 index 4f7f9bfa7..000000000 --- a/base/filled4d/benchmark/benchmark.size.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var filled4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled4d( i, [ N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N*N), f ); - } -} - -main(); diff --git a/base/filled4d/docs/repl.txt b/base/filled4d/docs/repl.txt deleted file mode 100644 index 6d72425cf..000000000 --- a/base/filled4d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( value, shape ) - Returns a filled four-dimensional nested array. - - Parameters - ---------- - value: any - Fill value. - - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( 0.0, [ 1, 1, 1, 3 ] ) - [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] - - See Also - -------- - diff --git a/base/filled4d/docs/types/index.d.ts b/base/filled4d/docs/types/index.d.ts deleted file mode 100644 index e21dfc43f..000000000 --- a/base/filled4d/docs/types/index.d.ts +++ /dev/null @@ -1,50 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Four-dimensional nested array. -*/ -type Array4D = Array>>>; - -/** -* Returns a filled four-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = filled4d( 0.0, [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] -* -* @example -* var out = filled4d( 'beep', [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] -*/ -declare function filled4d( value: T, shape: Shape4D ): Array4D; - - -// EXPORTS // - -export = filled4d; diff --git a/base/filled4d/docs/types/test.ts b/base/filled4d/docs/types/test.ts deleted file mode 100644 index 9992ee322..000000000 --- a/base/filled4d/docs/types/test.ts +++ /dev/null @@ -1,45 +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. -*/ - -import filled4d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - filled4d( 0.0, [ 1, 1, 1, 3 ] ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - filled4d( 0.0, 'abc' ); // $ExpectError - filled4d( 0.0, true ); // $ExpectError - filled4d( 0.0, false ); // $ExpectError - filled4d( 0.0, null ); // $ExpectError - filled4d( 0.0, [ '1' ] ); // $ExpectError - filled4d( 0.0, {} ); // $ExpectError - filled4d( 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled4d(); // $ExpectError - filled4d( 0.0 ); // $ExpectError - filled4d( 0.0, [ 1, 1, 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/filled4d/examples/index.js b/base/filled4d/examples/index.js deleted file mode 100644 index 8c5b86355..000000000 --- a/base/filled4d/examples/index.js +++ /dev/null @@ -1,41 +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'; - -var filled4d = require( './../lib' ); - -var out = filled4d( 0.0, [ 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] - -out = filled4d( 'beep', [ 1, 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] - -out = filled4d( null, [ 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ null, null, null ] ] ] ] - -out = filled4d( true, [ 1, 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ [ true ], [ true ], [ true ] ] ] ] - -out = filled4d( void 0, [ 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ undefined, undefined, undefined ] ] ] ] diff --git a/base/filled4d/lib/index.js b/base/filled4d/lib/index.js deleted file mode 100644 index 4282454f6..000000000 --- a/base/filled4d/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Create a filled four-dimensional nested array. -* -* @module @stdlib/array/base/filled4d -* -* @example -* var filled4d = require( '@stdlib/array/base/filled4d' ); -* -* var out = filled4d( 0.0, [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] -* -* @example -* var filled4d = require( '@stdlib/array/base/filled4d' ); -* -* var out = filled4d( 'beep', [ 1, 1, 3, 1 ] ); -* // returns [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/filled4d/lib/main.js b/base/filled4d/lib/main.js deleted file mode 100644 index e3e1dcf87..000000000 --- a/base/filled4d/lib/main.js +++ /dev/null @@ -1,79 +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 filled = require( './../../../base/filled' ); - - -// MAIN // - -/** -* Returns a filled four-dimensional nested array. -* -* @param {*} value - fill value -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = filled4d( 0.0, [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] -* -* @example -* var out = filled4d( 'beep', [ 1, 1, 3, 1 ] ); -* // returns [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] -*/ -function filled4d( value, shape ) { - var out; - var a1; - var a2; - var S0; - var S1; - var S2; - var S3; - var i1; - var i2; - var i3; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - - // Manually push elements in order to ensure "fast" elements... - out = []; - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - a1.push( filled( value, S0 ) ); - } - a2.push( a1 ); - } - out.push( a2 ); - } - return out; -} - - -// EXPORTS // - -module.exports = filled4d; diff --git a/base/filled4d/package.json b/base/filled4d/package.json deleted file mode 100644 index 1c7b3a065..000000000 --- a/base/filled4d/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/filled4d", - "version": "0.0.0", - "description": "Create a filled four-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "4d" - ] -} diff --git a/base/filled4d/test/test.js b/base/filled4d/test/test.js deleted file mode 100644 index 19aca3089..000000000 --- a/base/filled4d/test/test.js +++ /dev/null @@ -1,201 +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 filled4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ] - ]; - actual = filled4d( 'beep', [ 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ]; - actual = filled4d( 'beep', [ 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ], - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ] - ]; - actual = filled4d( 'beep', [ 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = filled4d( 'beep', [ 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filled4d( 'beep', [ 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filled4d( 'beep', [ 0, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filled4d( 'beep', [ 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filled4d( 'beep', [ 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filled4d( 'beep', [ 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = filled4d( 'beep', [ 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = filled4d( 'beep', [ 1, 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = filled4d( 'beep', [ 1, 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = filled4d( 'beep', [ 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = filled4d( 'beep', [ 1, 2, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = filled4d( 'beep', [ 1, 3, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/filled5d-by/README.md b/base/filled5d-by/README.md deleted file mode 100644 index 247a36006..000000000 --- a/base/filled5d-by/README.md +++ /dev/null @@ -1,159 +0,0 @@ - - -# filled5dBy - -> Create a filled five-dimensional nested array according to a provided callback function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -``` - -#### filled5dBy( shape, clbk\[, thisArg] ) - -Returns a filled five-dimensional nested array according to a provided callback function. - -```javascript -function clbk() { - return 1.0; -} - -var out = filled5dBy( [ 1, 1, 2, 1, 3 ], clbk ); -// returns [ [ [ [ [ 1.0, 1.0, 1.0 ] ], [ [ 1.0, 1.0, 1.0 ] ] ] ] ] -``` - -When invoked, a callback function is provided a single argument: - -- **indices**: current array element indices. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function clbk() { - this.count += 1; - return 1.0; -} - -var ctx = { - 'count': 0 -}; - -var out = filled5dBy( [ 1, 1, 1, 2, 3 ], clbk, ctx ); -// returns [ [ [ [ [ 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0 ] ] ] ] ]; - -var cnt = ctx.count; -// returns 6 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); - -var out = filled5dBy( [ 1, 1, 1, 1, 3 ], constantFunction( 0.0 ) ); -// returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] - -out = filled5dBy( [ 1, 1, 1, 3, 1 ], constantFunction( 'beep' ) ); -// returns [ [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] ] - -out = filled5dBy( [ 1, 1, 1, 1, 3 ], constantFunction( null ) ); -// returns [ [ [ [ [ null, null, null ] ] ] ] ] - -out = filled5dBy( [ 1, 1, 1, 3, 1 ], constantFunction( true ) ); -// returns [ [ [ [ [ true ], [ true ], [ true ] ] ] ] ] - -out = filled5dBy( [ 1, 1, 1, 1, 3 ], constantFunction( void 0 ) ); -// returns [ [ [ [ [ undefined, undefined, undefined ] ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/filled5d-by/benchmark/benchmark.size.js b/base/filled5d-by/benchmark/benchmark.size.js deleted file mode 100644 index 5f4b46f43..000000000 --- a/base/filled5d-by/benchmark/benchmark.size.js +++ /dev/null @@ -1,99 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filled5dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( N ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled5dBy( [ N, N, N, N, N ], f ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N*N*N), f ); - } -} - -main(); diff --git a/base/filled5d-by/docs/repl.txt b/base/filled5d-by/docs/repl.txt deleted file mode 100644 index 06f2256f9..000000000 --- a/base/filled5d-by/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( shape, clbk[, thisArg] ) - Returns a filled five-dimensional nested array according to a provided - callback function. - - The callback function is provided one argument: - - - indices: current array element indices. - - Parameters - ---------- - shape: Array - Array shape. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var out = {{alias}}( [ 1, 1, 1, 1, 3 ], clbk ) - [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/filled5d-by/docs/types/index.d.ts b/base/filled5d-by/docs/types/index.d.ts deleted file mode 100644 index 1850dbe74..000000000 --- a/base/filled5d-by/docs/types/index.d.ts +++ /dev/null @@ -1,72 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = ( this: V ) => T; - -/** -* Unary callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Unary = ( this: V, indices: Array ) => T; - -/** -* Callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Five-dimensional nested array. -*/ -type Array5D = Array>>>>; - -/** -* Returns a filled five-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var arr = filled5dBy( [ 1, 1, 1, 1, 5 ], constantFunction( 1.0 ) ); -* // returns [ [ [ [ [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ] ] ] ] -*/ -declare function filled5dBy( shape: Shape5D, clbk: Callback, thisArg?: ThisParameterType> ): Array5D; - - -// EXPORTS // - -export = filled5dBy; diff --git a/base/filled5d-by/docs/types/test.ts b/base/filled5d-by/docs/types/test.ts deleted file mode 100644 index 1e9c1969e..000000000 --- a/base/filled5d-by/docs/types/test.ts +++ /dev/null @@ -1,81 +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. -*/ - -import filled5dBy = require( './index' ); - -/** -* Callback function. -* -* @param indices - array element indices -* @returns return value -*/ -function clbk( indices: Array ): number { - return indices[ 1 ]; -} - - -// TESTS // - -// The function returns an array... -{ - filled5dBy( [ 1, 1, 1, 1, 3 ], clbk ); // $ExpectType Array5D - filled5dBy( [ 1, 1, 1, 1, 3 ], clbk, {} ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - filled5dBy( 'abc', clbk ); // $ExpectError - filled5dBy( true, clbk ); // $ExpectError - filled5dBy( false, clbk ); // $ExpectError - filled5dBy( null, clbk ); // $ExpectError - filled5dBy( [ '1', 1 ], clbk ); // $ExpectError - filled5dBy( {}, clbk ); // $ExpectError - filled5dBy( ( x: number ): number => x, clbk ); // $ExpectError - - filled5dBy( 'abc', clbk, {} ); // $ExpectError - filled5dBy( true, clbk, {} ); // $ExpectError - filled5dBy( false, clbk, {} ); // $ExpectError - filled5dBy( null, clbk, {} ); // $ExpectError - filled5dBy( [ '1', 1 ], clbk, {} ); // $ExpectError - filled5dBy( {}, clbk, {} ); // $ExpectError - filled5dBy( ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a callback... -{ - filled5dBy( [ 1, 1, 1, 1, 3 ], 'abc' ); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ], true ); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ], false ); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ], null ); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ], [] ); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ], {} ); // $ExpectError - - filled5dBy( [ 1, 1, 1, 1, 3 ], 'abc', {} ); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ], true, {} ); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ], false, {} ); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ], null, {} ); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ], [], {} ); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled5dBy(); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ] ); // $ExpectError - filled5dBy( [ 1, 1, 1, 1, 3 ], clbk, 2, 2 ); // $ExpectError -} diff --git a/base/filled5d-by/examples/index.js b/base/filled5d-by/examples/index.js deleted file mode 100644 index 78e7d40f3..000000000 --- a/base/filled5d-by/examples/index.js +++ /dev/null @@ -1,42 +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'; - -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled5dBy = require( './../lib' ); - -var out = filled5dBy( [ 1, 1, 1, 1, 3 ], constantFunction( 0.0 ) ); -console.log( out ); -// => [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] - -out = filled5dBy( [ 1, 1, 1, 3, 1 ], constantFunction( 'beep' ) ); -console.log( out ); -// => [ [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] ] - -out = filled5dBy( [ 1, 1, 1, 1, 3 ], constantFunction( null ) ); -console.log( out ); -// => [ [ [ [ [ null, null, null ] ] ] ] ] - -out = filled5dBy( [ 1, 1, 1, 3, 1 ], constantFunction( true ) ); -console.log( out ); -// => [ [ [ [ [ true ], [ true ], [ true ] ] ] ] ] - -out = filled5dBy( [ 1, 1, 1, 1, 3 ], constantFunction( void 0 ) ); -console.log( out ); -// => [ [ [ [ [ undefined, undefined, undefined ] ] ] ] ] diff --git a/base/filled5d-by/lib/index.js b/base/filled5d-by/lib/index.js deleted file mode 100644 index 7e1ff9a22..000000000 --- a/base/filled5d-by/lib/index.js +++ /dev/null @@ -1,41 +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'; - -/** -* Create a filled five-dimensional nested array according to a provided callback function. -* -* @module @stdlib/array/base/filled5d-by -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -* -* var out = filled5dBy( [ 1, 1, 1, 1, 3 ], constantFunction( 'beep' ) ); -* // returns [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/filled5d-by/lib/main.js b/base/filled5d-by/lib/main.js deleted file mode 100644 index f617b91ad..000000000 --- a/base/filled5d-by/lib/main.js +++ /dev/null @@ -1,87 +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'; - -// MAIN // - -/** -* Returns a filled five-dimensional nested array according to a provided callback function. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback function execution context -* @returns {Array} filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filled5dBy( [ 1, 1, 1, 1, 3 ], constantFunction( 'beep' ) ); -* // returns [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] -*/ -function filled5dBy( shape, clbk, thisArg ) { - var arr; - var a0; - var a1; - var a2; - var a3; - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - - // Manually push elements in order to ensure "fast" elements... - arr = []; - for ( i4 = 0; i4 < S4; i4++ ) { - a3 = []; - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - a0.push( clbk.call( thisArg, [ i4, i3, i2, i1, i0 ] ) ); - } - a1.push( a0 ); - } - a2.push( a1 ); - } - a3.push( a2 ); - } - arr.push( a3 ); - } - return arr; -} - - -// EXPORTS // - -module.exports = filled5dBy; diff --git a/base/filled5d-by/package.json b/base/filled5d-by/package.json deleted file mode 100644 index e0b4f48c7..000000000 --- a/base/filled5d-by/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/array/base/filled5d-by", - "version": "0.0.0", - "description": "Create a filled five-dimensional nested array according to a provided callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "callback", - "map", - "foreach", - "multidimensional", - "matrix", - "strided", - "ndarray", - "5d" - ] -} diff --git a/base/filled5d-by/test/test.js b/base/filled5d-by/test/test.js deleted file mode 100644 index 7aa4c91ff..000000000 --- a/base/filled5d-by/test/test.js +++ /dev/null @@ -1,400 +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 constantFunction = require( '@stdlib/utils/constant-function' ); -var filled5dBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled5dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ] - ] - ]; - actual = filled5dBy( [ 1, 1, 1, 1, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ], - [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ] - ]; - actual = filled5dBy( [ 2, 1, 1, 3, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ], - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ] - ], - [ - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ], - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ] - ] - ], - [ - [ - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ], - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ] - ], - [ - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ], - [ - [ 1, 1, 1 ], - [ 1, 1, 1 ] - ] - ] - ] - ]; - actual = filled5dBy( [ 2, 2, 2, 2, 3 ], constantFunction( 1 ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - actual = filled5dBy( [ 0, 1, 1, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = filled5dBy( [ 0, 0, 0, 0, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = filled5dBy( [ 0, 100, 100, 100, 100 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filled5dBy( [ 1, 0, 1, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filled5dBy( [ 2, 0, 2, 2, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filled5dBy( [ 3, 0, 3, 3, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ [] ] - ]; - actual = filled5dBy( [ 1, 1, 0, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [] - ], - [ - [] - ] - ]; - actual = filled5dBy( [ 2, 1, 0, 2, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [] - ], - [ - [] - ], - [ - [] - ] - ]; - actual = filled5dBy( [ 3, 1, 0, 3, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = filled5dBy( [ 1, 1, 1, 0, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ] - ], - [ - [ [] ] - ] - ]; - actual = filled5dBy( [ 2, 1, 1, 0, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ] - ], - [ - [ [] ] - ], - [ - [ [] ] - ] - ]; - actual = filled5dBy( [ 3, 1, 1, 0, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ [] ] - ] - ] - ]; - actual = filled5dBy( [ 1, 1, 1, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ [], [] ] - ] - ], - [ - [ - [ [], [] ] - ] - ] - ]; - actual = filled5dBy( [ 2, 1, 1, 2, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ [], [] ] - ] - ], - [ - [ - [ [], [] ] - ] - ], - [ - [ - [ [], [] ] - ] - ] - ]; - actual = filled5dBy( [ 3, 1, 1, 2, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - - ctx = { - 'count': 0 - }; - expected = [ - [ - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ] - ] - ]; - actual = filled5dBy( [ 1, 1, 1, 2, 3 ], clbk, ctx ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - - t.end(); - - function clbk() { - this.count += 1; // eslint-disable-line no-invalid-this - return 'beep'; - } -}); - -tape( 'the function invokes a provided callback function with one argument', function test( t ) { - var expected; - var actual; - var idx; - - idx = []; - actual = filled5dBy( [ 2, 2, 1, 2, 3 ], clbk ); - - expected = [ - [ - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ], - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ] - ], - [ - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ], - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0, 0 ], - [ 0, 0, 0, 0, 1 ], - [ 0, 0, 0, 0, 2 ], - [ 0, 0, 0, 1, 0 ], - [ 0, 0, 0, 1, 1 ], - [ 0, 0, 0, 1, 2 ], - [ 0, 1, 0, 0, 0 ], - [ 0, 1, 0, 0, 1 ], - [ 0, 1, 0, 0, 2 ], - [ 0, 1, 0, 1, 0 ], - [ 0, 1, 0, 1, 1 ], - [ 0, 1, 0, 1, 2 ], - [ 1, 0, 0, 0, 0 ], - [ 1, 0, 0, 0, 1 ], - [ 1, 0, 0, 0, 2 ], - [ 1, 0, 0, 1, 0 ], - [ 1, 0, 0, 1, 1 ], - [ 1, 0, 0, 1, 2 ], - [ 1, 1, 0, 0, 0 ], - [ 1, 1, 0, 0, 1 ], - [ 1, 1, 0, 0, 2 ], - [ 1, 1, 0, 1, 0 ], - [ 1, 1, 0, 1, 1 ], - [ 1, 1, 0, 1, 2 ] - ]; - t.deepEqual( idx, expected, 'returns expected value' ); - - t.end(); - - function clbk( indices ) { - idx.push( indices ); - return 'beep'; - } -}); diff --git a/base/filled5d/README.md b/base/filled5d/README.md deleted file mode 100644 index c996bae2b..000000000 --- a/base/filled5d/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# filled5d - -> Create a filled five-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled5d = require( '@stdlib/array/base/filled5d' ); -``` - -#### filled5d( value, shape ) - -Returns a filled five-dimensional nested array. - -```javascript -var out = filled5d( 0.0, [ 1, 1, 1, 2, 3 ] ); -// returns [ [ [ [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var filled5d = require( '@stdlib/array/base/filled5d' ); - -var out = filled5d( 0.0, [ 1, 1, 1, 1, 3 ] ); -// returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] - -out = filled5d( 'beep', [ 1, 1, 1, 3, 1 ] ); -// returns [ [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] ] - -out = filled5d( null, [ 1, 1, 1, 1, 3 ] ); -// returns [ [ [ [ [ null, null, null ] ] ] ] ] - -out = filled5d( true, [ 1, 1, 1, 3, 1 ] ); -// returns [ [ [ [ [ true ], [ true ], [ true ] ] ] ] ] - -out = filled5d( void 0, [ 1, 1, 1, 1, 3 ] ); -// returns [ [ [ [ [ undefined, undefined, undefined ] ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/filled5d/benchmark/benchmark.size.js b/base/filled5d/benchmark/benchmark.size.js deleted file mode 100644 index 70996bbd7..000000000 --- a/base/filled5d/benchmark/benchmark.size.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var filled5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled5d( i, [ N, N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N*N*N), f ); - } -} - -main(); diff --git a/base/filled5d/docs/repl.txt b/base/filled5d/docs/repl.txt deleted file mode 100644 index 7bb2a8b0d..000000000 --- a/base/filled5d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( value, shape ) - Returns a filled five-dimensional nested array. - - Parameters - ---------- - value: any - Fill value. - - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( 0.0, [ 1, 1, 1, 1, 3 ] ) - [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/filled5d/docs/types/index.d.ts b/base/filled5d/docs/types/index.d.ts deleted file mode 100644 index 865386ffe..000000000 --- a/base/filled5d/docs/types/index.d.ts +++ /dev/null @@ -1,50 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Five-dimensional nested array. -*/ -type Array5D = Array>>>>; - -/** -* Returns a filled five-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = filled5d( 0.0, [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] -* -* @example -* var out = filled5d( 'beep', [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] -*/ -declare function filled5d( value: T, shape: Shape5D ): Array5D; - - -// EXPORTS // - -export = filled5d; diff --git a/base/filled5d/docs/types/test.ts b/base/filled5d/docs/types/test.ts deleted file mode 100644 index 90a7a9e1a..000000000 --- a/base/filled5d/docs/types/test.ts +++ /dev/null @@ -1,45 +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. -*/ - -import filled5d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - filled5d( 0.0, [ 1, 1, 1, 1, 3 ] ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - filled5d( 0.0, 'abc' ); // $ExpectError - filled5d( 0.0, true ); // $ExpectError - filled5d( 0.0, false ); // $ExpectError - filled5d( 0.0, null ); // $ExpectError - filled5d( 0.0, [ '1' ] ); // $ExpectError - filled5d( 0.0, {} ); // $ExpectError - filled5d( 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled5d(); // $ExpectError - filled5d( 0.0 ); // $ExpectError - filled5d( 0.0, [ 1, 1, 1, 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/filled5d/examples/index.js b/base/filled5d/examples/index.js deleted file mode 100644 index 015027769..000000000 --- a/base/filled5d/examples/index.js +++ /dev/null @@ -1,41 +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'; - -var filled5d = require( './../lib' ); - -var out = filled5d( 0.0, [ 1, 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] - -out = filled5d( 'beep', [ 1, 1, 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] ] - -out = filled5d( null, [ 1, 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ [ null, null, null ] ] ] ] ] - -out = filled5d( true, [ 1, 1, 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ [ [ true ], [ true ], [ true ] ] ] ] ] - -out = filled5d( void 0, [ 1, 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ [ undefined, undefined, undefined ] ] ] ] ] diff --git a/base/filled5d/lib/index.js b/base/filled5d/lib/index.js deleted file mode 100644 index 56ee3c97b..000000000 --- a/base/filled5d/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Create a filled five-dimensional nested array. -* -* @module @stdlib/array/base/filled5d -* -* @example -* var filled5d = require( '@stdlib/array/base/filled5d' ); -* -* var out = filled5d( 0.0, [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] -* -* @example -* var filled5d = require( '@stdlib/array/base/filled5d' ); -* -* var out = filled5d( 'beep', [ 1, 1, 1, 3, 1 ] ); -* // returns [ [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/filled5d/lib/main.js b/base/filled5d/lib/main.js deleted file mode 100644 index 2d07e5e0c..000000000 --- a/base/filled5d/lib/main.js +++ /dev/null @@ -1,87 +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 filled = require( './../../../base/filled' ); - - -// MAIN // - -/** -* Returns a filled five-dimensional nested array. -* -* @param {*} value - fill value -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = filled5d( 0.0, [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] -* -* @example -* var out = filled5d( 'beep', [ 1, 1, 1, 3, 1 ] ); -* // returns [ [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] ] -*/ -function filled5d( value, shape ) { - var out; - var a1; - var a2; - var a3; - var S0; - var S1; - var S2; - var S3; - var S4; - var i1; - var i2; - var i3; - var i4; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - - // Manually push elements in order to ensure "fast" elements... - out = []; - for ( i4 = 0; i4 < S4; i4++ ) { - a3 = []; - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - a1.push( filled( value, S0 ) ); - } - a2.push( a1 ); - } - a3.push( a2 ); - } - out.push( a3 ); - } - return out; -} - - -// EXPORTS // - -module.exports = filled5d; diff --git a/base/filled5d/package.json b/base/filled5d/package.json deleted file mode 100644 index 2ebf05acc..000000000 --- a/base/filled5d/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/filled5d", - "version": "0.0.0", - "description": "Create a filled five-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "5d" - ] -} diff --git a/base/filled5d/test/test.js b/base/filled5d/test/test.js deleted file mode 100644 index 9e0fb6d80..000000000 --- a/base/filled5d/test/test.js +++ /dev/null @@ -1,257 +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 filled5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ] - ] - ]; - actual = filled5d( 'beep', [ 1, 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ], - [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ] - ]; - actual = filled5d( 'beep', [ 2, 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ], - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ] - ] - ]; - actual = filled5d( 'beep', [ 1, 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = filled5d( 'beep', [ 0, 1, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filled5d( 'beep', [ 0, 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filled5d( 'beep', [ 0, 100, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filled5d( 'beep', [ 1, 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filled5d( 'beep', [ 2, 0, 2, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filled5d( 'beep', [ 3, 0, 3, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = filled5d( 'beep', [ 1, 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = filled5d( 'beep', [ 1, 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = filled5d( 'beep', [ 1, 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = filled5d( 'beep', [ 1, 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = filled5d( 'beep', [ 1, 2, 1, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = filled5d( 'beep', [ 1, 3, 1, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ [] ] - ] - ] - ]; - actual = filled5d( 'beep', [ 1, 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = filled5d( 'beep', [ 1, 2, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = filled5d( 'beep', [ 1, 3, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/fillednd-by/README.md b/base/fillednd-by/README.md deleted file mode 100644 index d22abc37f..000000000 --- a/base/fillednd-by/README.md +++ /dev/null @@ -1,159 +0,0 @@ - - -# filledndBy - -> Create a filled n-dimensional nested array according to a provided callback function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filledndBy = require( '@stdlib/array/base/fillednd-by' ); -``` - -#### filledndBy( shape, clbk\[, thisArg] ) - -Returns a filled n-dimensional nested array according to a provided callback function. - -```javascript -function clbk() { - return 1.0; -} - -var out = filledndBy( [ 2, 3 ], clbk ); -// returns [ [ 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0 ] ] -``` - -When invoked, a callback function is provided a single argument: - -- **indices**: current array element indices. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function clbk() { - this.count += 1; - return 1.0; -} - -var ctx = { - 'count': 0 -}; - -var out = filledndBy( [ 1, 1, 1, 2, 3 ], clbk, ctx ); -// returns [ [ [ [ [ 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0 ] ] ] ] ] - -var cnt = ctx.count; -// returns 6 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filledndBy = require( '@stdlib/array/base/fillednd-by' ); - -var out = filledndBy( [ 1, 3 ], constantFunction( 0.0 ) ); -// returns [ [ 0.0, 0.0, 0.0 ] ] - -out = filledndBy( [ 3, 1 ], constantFunction( 'beep' ) ); -// returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] - -out = filledndBy( [ 1, 1, 3 ], constantFunction( null ) ); -// returns [ [ [ null, null, null ] ] ] - -out = filledndBy( [ 1, 3, 1 ], constantFunction( true ) ); -// returns [ [ [ true ], [ true ], [ true ] ] ] - -out = filledndBy( [ 1, 1, 1, 3 ], constantFunction( void 0 ) ); -// returns [ [ [ [ undefined, undefined, undefined ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/fillednd-by/benchmark/benchmark.size.2d.js b/base/fillednd-by/benchmark/benchmark.size.2d.js deleted file mode 100644 index e2647d27c..000000000 --- a/base/fillednd-by/benchmark/benchmark.size.2d.js +++ /dev/null @@ -1,100 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledndBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( N ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filledndBy( [ N, N ], f ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::2d,equidimensional:size='+(N*N), f ); - } -} - -main(); diff --git a/base/fillednd-by/benchmark/benchmark.size.3d.js b/base/fillednd-by/benchmark/benchmark.size.3d.js deleted file mode 100644 index 3a35b2b52..000000000 --- a/base/fillednd-by/benchmark/benchmark.size.3d.js +++ /dev/null @@ -1,100 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var cbrt = require( '@stdlib/math/base/special/cbrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledndBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( N ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filledndBy( [ N, N, N ], f ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( cbrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::3d,equidimensional:size='+(N*N*N), f ); - } -} - -main(); diff --git a/base/fillednd-by/benchmark/benchmark.size.4d.js b/base/fillednd-by/benchmark/benchmark.size.4d.js deleted file mode 100644 index 1dbe72b14..000000000 --- a/base/fillednd-by/benchmark/benchmark.size.4d.js +++ /dev/null @@ -1,99 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledndBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( N ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filledndBy( [ N, N, N, N ], f ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::4d,equidimensional:size='+(N*N*N*N), f ); - } -} - -main(); diff --git a/base/fillednd-by/benchmark/benchmark.size.5d.js b/base/fillednd-by/benchmark/benchmark.size.5d.js deleted file mode 100644 index a2994dfce..000000000 --- a/base/fillednd-by/benchmark/benchmark.size.5d.js +++ /dev/null @@ -1,99 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledndBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( N ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filledndBy( [ N, N, N, N, N ], f ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::5d,equidimensional:size='+(N*N*N*N*N), f ); - } -} - -main(); diff --git a/base/fillednd-by/docs/repl.txt b/base/fillednd-by/docs/repl.txt deleted file mode 100644 index f24ba5f3f..000000000 --- a/base/fillednd-by/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( shape, clbk[, thisArg] ) - Returns a filled n-dimensional nested array according to a callback - function. - - The callback function is provided one argument: - - - indices: current array element indices. - - Parameters - ---------- - shape: Array - Array shape. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var out = {{alias}}( [ 1, 3 ], clbk ) - [ [ 1.0, 1.0, 1.0 ] ] - - See Also - -------- - diff --git a/base/fillednd-by/docs/types/index.d.ts b/base/fillednd-by/docs/types/index.d.ts deleted file mode 100644 index 1306bc2b5..000000000 --- a/base/fillednd-by/docs/types/index.d.ts +++ /dev/null @@ -1,325 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape } from '@stdlib/types/ndarray'; - -/** -* One-dimensional array. -*/ -type Array1D = Array; - -/** -* One-dimensional array shape. -*/ -type Shape1D = [ number ]; - -/** -* Two-dimensional array. -*/ -type Array2D = Array>; - -/** -* Two-dimensional array shape. -*/ -type Shape2D = [ number, number ]; - -/** -* Three-dimensional array. -*/ -type Array3D = Array>; - -/** -* Three-dimensional array shape. -*/ -type Shape3D = [ number, number, number ]; - -/** -* Four-dimensional array. -*/ -type Array4D = Array>; - -/** -* Four-dimensional array shape. -*/ -type Shape4D = [ number, number, number, number ]; - -/** -* Five-dimensional array. -*/ -type Array5D = Array>; - -/** -* Five-dimensional array shape. -*/ -type Shape5D = [ number, number, number, number, number ]; - -/** -* Six-dimensional array. -*/ -type Array6D = Array>; - -/** -* Six-dimensional array shape. -*/ -type Shape6D = [ number, number, number, number, number, number ]; - -/** -* Seven-dimensional array. -*/ -type Array7D = Array>; - -/** -* Seven-dimensional array shape. -*/ -type Shape7D = [ number, number, number, number, number, number, number ]; - -/** -* Eight-dimensional array. -*/ -type Array8D = Array>; - -/** -* Eight-dimensional array shape. -*/ -type Shape8D = [ number, number, number, number, number, number, number, number ]; - -/** -* Nine-dimensional array. -*/ -type Array9D = Array>; - -/** -* Nine-dimensional array shape. -*/ -type Shape9D = [ number, number, number, number, number, number, number, number, number ]; - -/** -* Ten-dimensional array. -*/ -type Array10D = Array>; // WARNING: arbitrarily limited to 10 dimensions, which should be fine for most practical purposes - -/** -* Ten-dimensional array shape. -*/ -type Shape10D = [ number, number, number, number, number, number, number, number, number, number ]; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = ( this: V ) => T; - -/** -* Unary callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Unary = ( this: V, indices: Array ) => T; - -/** -* Callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled one-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 3 ], constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledndBy( shape: Shape1D, clbk: Callback, thisArg?: ThisParameterType> ): Array1D; -/** -* Creates a filled two-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 1, 3 ], constantFunction( 1.0 ) ); -* // returns [ [ 1.0, 1.0, 1.0 ] ] -*/ -declare function filledndBy( shape: Shape2D, clbk: Callback, thisArg?: ThisParameterType> ): Array2D; -/** -* Creates a filled three-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 1, 1, 3 ], constantFunction( 1.0 ) ); -* // returns [ [ [ 1.0, 1.0, 1.0 ] ] ] -*/ -declare function filledndBy( shape: Shape3D, clbk: Callback, thisArg?: ThisParameterType> ): Array3D; - -/** -* Creates a filled four-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 1, 1, 1, 3 ], constantFunction( 1.0 ) ); -* // returns [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] -*/ -declare function filledndBy( shape: Shape4D, clbk: Callback, thisArg?: ThisParameterType> ): Array4D; - -/** -* Creates a filled five-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 1, 1, 1, 1, 3 ], constantFunction( 1.0 ) ); -* // returns [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] -*/ -declare function filledndBy( shape: Shape5D, clbk: Callback, thisArg?: ThisParameterType> ): Array5D; - -/** -* Creates a filled six-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 1, 1, 1, 1, 1, 3 ], constantFunction( 1.0 ) ); -* // returns [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] -*/ -declare function filledndBy( shape: Shape6D, clbk: Callback, thisArg?: ThisParameterType> ): Array6D; - -/** -* Creates a filled seven-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 1, 1, 1, 1, 1, 1, 3 ], constantFunction( 1.0 ) ); -* // returns [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] -*/ -declare function filledndBy( shape: Shape7D, clbk: Callback, thisArg?: ThisParameterType> ): Array7D; - -/** -* Creates a filled eight-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 1, 1, 1, 1, 1, 1, 1, 3 ], constantFunction( 1.0 ) ); -* // returns [ [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] ] -*/ -declare function filledndBy( shape: Shape8D, clbk: Callback, thisArg?: ThisParameterType> ): Array8D; - -/** -* Creates a filled nine-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 1, 1, 1, 1, 1, 1, 1, 1, 3 ], constantFunction( 1.0 ) ); -* // returns [ [ [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] ] ] -*/ -declare function filledndBy( shape: Shape9D, clbk: Callback, thisArg?: ThisParameterType> ): Array9D; - -/** -* Creates a filled ten-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ], constantFunction( 1.0 ) ); -* // returns [ [ [ [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] ] ] ] -*/ -declare function filledndBy( shape: Shape10D, clbk: Callback, thisArg?: ThisParameterType> ): Array10D; - -/** -* Creates a filled n-dimensional nested array according to a provided callback function. -* -* @param shape - array shape -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ], constantFunction( 1.0 ) ); -* // returns [ [ [ [ [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] ] ] ] -*/ -declare function filledndBy( shape: Shape, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - -// EXPORTS // - -export = filledndBy; diff --git a/base/fillednd-by/docs/types/test.ts b/base/fillednd-by/docs/types/test.ts deleted file mode 100644 index 83533f165..000000000 --- a/base/fillednd-by/docs/types/test.ts +++ /dev/null @@ -1,92 +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. -*/ - -import filledndBy = require( './index' ); - -/** -* Callback function. -* -* @param indices - array element indices -* @returns return value -*/ -function clbk( indices: Array ): number { - return indices[ 1 ]; -} - - -// TESTS // - -// The function returns a nested array... -{ - filledndBy( [ 3 ], clbk ); // $ExpectType Array1D - filledndBy( [ 1, 3 ], clbk ); // $ExpectType Array2D - filledndBy( [ 1, 1, 3 ], clbk ); // $ExpectType Array3D - filledndBy( [ 1, 1, 1, 3 ], clbk ); // $ExpectType Array4D - filledndBy( [ 1, 1, 1, 1, 3 ], clbk ); // $ExpectType Array5D - - filledndBy( [ 3 ], clbk, {} ); // $ExpectType Array1D - filledndBy( [ 1, 3 ], clbk, {} ); // $ExpectType Array2D - filledndBy( [ 1, 1, 3 ], clbk, {} ); // $ExpectType Array3D - filledndBy( [ 1, 1, 1, 3 ], clbk, {} ); // $ExpectType Array4D - filledndBy( [ 1, 1, 1, 1, 3 ], clbk, {} ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - filledndBy( 'abc', clbk ); // $ExpectError - filledndBy( true, clbk ); // $ExpectError - filledndBy( false, clbk ); // $ExpectError - filledndBy( null, clbk ); // $ExpectError - filledndBy( [ '1' ], clbk ); // $ExpectError - filledndBy( {}, clbk ); // $ExpectError - filledndBy( ( x: number ): number => x, clbk ); // $ExpectError - - filledndBy( 'abc', clbk, {} ); // $ExpectError - filledndBy( true, clbk, {} ); // $ExpectError - filledndBy( false, clbk, {} ); // $ExpectError - filledndBy( null, clbk, {} ); // $ExpectError - filledndBy( [ '1' ], clbk, {} ); // $ExpectError - filledndBy( {}, clbk, {} ); // $ExpectError - filledndBy( ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid function... -{ - filledndBy( [ 2, 2 ], 'abc' ); // $ExpectError - filledndBy( [ 2, 2 ], 1.0 ); // $ExpectError - filledndBy( [ 2, 2 ], true ); // $ExpectError - filledndBy( [ 2, 2 ], false ); // $ExpectError - filledndBy( [ 2, 2 ], null ); // $ExpectError - filledndBy( [ 2, 2 ], [ '1' ] ); // $ExpectError - filledndBy( [ 2, 2 ], {} ); // $ExpectError - - filledndBy( [ 2, 2 ], 'abc', {} ); // $ExpectError - filledndBy( [ 2, 2 ], 1.0, {} ); // $ExpectError - filledndBy( [ 2, 2 ], true, {} ); // $ExpectError - filledndBy( [ 2, 2 ], false, {} ); // $ExpectError - filledndBy( [ 2, 2 ], null, {} ); // $ExpectError - filledndBy( [ 2, 2 ], [ '1' ], {} ); // $ExpectError - filledndBy( [ 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filledndBy(); // $ExpectError - filledndBy( [ 1, 3 ] ); // $ExpectError - filledndBy( [ 1, 3 ], clbk, {}, 2 ); // $ExpectError -} diff --git a/base/fillednd-by/examples/index.js b/base/fillednd-by/examples/index.js deleted file mode 100644 index b2e90bbd4..000000000 --- a/base/fillednd-by/examples/index.js +++ /dev/null @@ -1,42 +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'; - -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filledndBy = require( './../lib' ); - -var out = filledndBy( [ 1, 3 ], constantFunction( 0.0 ) ); -console.log( out ); -// => [ [ 0.0, 0.0, 0.0 ] ] - -out = filledndBy( [ 3, 1 ], constantFunction( 'beep' ) ); -console.log( out ); -// => [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] - -out = filledndBy( [ 1, 1, 3 ], constantFunction( null ) ); -console.log( out ); -// => [ [ [ null, null, null ] ] ] - -out = filledndBy( [ 1, 3, 1 ], constantFunction( true ) ); -console.log( out ); -// => [ [ [ true ], [ true ], [ true ] ] ] - -out = filledndBy( [ 1, 1, 1, 3 ], constantFunction( void 0 ) ); -console.log( out ); -// => [ [ [ [ undefined, undefined, undefined ] ] ] ] diff --git a/base/fillednd-by/lib/index.js b/base/fillednd-by/lib/index.js deleted file mode 100644 index 0c0c77ee0..000000000 --- a/base/fillednd-by/lib/index.js +++ /dev/null @@ -1,41 +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'; - -/** -* Create a filled n-dimensional nested array according to a callback function. -* -* @module @stdlib/array/base/fillednd-by -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var filledndBy = require( '@stdlib/array/base/fillednd-by' ); -* -* var out = filledndBy( [ 3, 1 ], constantFunction( 'beep' ) ); -* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/fillednd-by/lib/main.js b/base/fillednd-by/lib/main.js deleted file mode 100644 index aec44baa2..000000000 --- a/base/fillednd-by/lib/main.js +++ /dev/null @@ -1,84 +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'; - -// FUNCTIONS // - -/** -* Recursive fills an array. -* -* @private -* @param {NonNegativeInteger} ndims - number of dimensions -* @param {NonNegativeIntegerArray} shape - array shape -* @param {NonNegativeInteger} dim - dimension index -* @param {NonNegativeIntegerArray} indices - outer array element indices -* @param {Array} out - output array -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Array} output array -*/ -function recurse( ndims, shape, dim, indices, out, clbk, thisArg ) { - var idx; - var FLG; - var S; - var d; - var i; - - // Check whether we're filling the last dimension: - d = dim + 1; - FLG = ( d === ndims ); - - S = shape[ dim ]; - for ( i = 0; i < S; i++ ) { - idx = indices.slice(); // we explicitly copy in order to avoid potential mutation when calling `clbk` - idx.push( i ); - if ( FLG ) { - out.push( clbk.call( thisArg, idx ) ); - } else { - out.push( recurse( ndims, shape, d, idx, [], clbk, thisArg ) ); - } - } - return out; -} - - -// MAIN // - -/** -* Returns a filled two-dimensional nested array according to a provided callback function. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Array} filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var out = filledndBy( [ 3, 1 ], constantFunction( 'beep' ) ); -* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] -*/ -function filledndBy( shape, clbk, thisArg ) { - return recurse( shape.length, shape, 0, [], [], clbk, thisArg ); -} - - -// EXPORTS // - -module.exports = filledndBy; diff --git a/base/fillednd-by/package.json b/base/fillednd-by/package.json deleted file mode 100644 index f166e64b9..000000000 --- a/base/fillednd-by/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/array/base/fillednd-by", - "version": "0.0.0", - "description": "Create a filled n-dimensional nested array according to a provided callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "callback", - "map", - "foreach" - ] -} diff --git a/base/fillednd-by/test/test.js b/base/fillednd-by/test/test.js deleted file mode 100644 index 571da2231..000000000 --- a/base/fillednd-by/test/test.js +++ /dev/null @@ -1,724 +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 constantFunction = require( '@stdlib/utils/constant-function' ); -var filledndBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledndBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array (0d)', function test( t ) { - var expected; - var actual; - - expected = []; - actual = filledndBy( [], constantFunction( 'beep' ), constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (1d)', function test( t ) { - var expected; - var actual; - - expected = [ 'beep', 'beep', 'beep' ]; - actual = filledndBy( [ 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (2d)', function test( t ) { - var expected; - var actual; - - expected = [ [ 'beep', 'beep', 'beep' ] ]; - actual = filledndBy( [ 1, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ]; - actual = filledndBy( [ 3, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 'beep', 'beep' ], [ 'beep', 'beep' ], [ 'beep', 'beep' ] ]; - actual = filledndBy( [ 3, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (3d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ]; - actual = filledndBy( [ 1, 1, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ]; - actual = filledndBy( [ 2, 3, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ]; - actual = filledndBy( [ 2, 3, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ] - ]; - actual = filledndBy( [ 1, 1, 1, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ]; - actual = filledndBy( [ 1, 2, 3, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ], - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ] - ]; - actual = filledndBy( [ 2, 2, 3, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ] - ] - ]; - actual = filledndBy( [ 1, 1, 1, 1, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ], - [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ] - ]; - actual = filledndBy( [ 2, 1, 2, 3, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ], - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ] - ] - ]; - actual = filledndBy( [ 1, 2, 2, 3, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided a shape having a first element equal to zero (1d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = filledndBy( [ 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (2d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = filledndBy( [ 0, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filledndBy( [ 0, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filledndBy( [ 0, 100 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (2d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filledndBy( [ 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filledndBy( [ 2, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filledndBy( [ 3, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = filledndBy( [ 0, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filledndBy( [ 0, 0, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filledndBy( [ 0, 100, 100 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filledndBy( [ 1, 0, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filledndBy( [ 2, 0, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filledndBy( [ 3, 0, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = [ [ [] ] ]; - actual = filledndBy( [ 1, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [] ] ]; - actual = filledndBy( [ 1, 2, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [], [] ] ]; - actual = filledndBy( [ 1, 3, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = filledndBy( [ 0, 1, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filledndBy( [ 0, 0, 0, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filledndBy( [ 0, 100, 100, 100 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filledndBy( [ 1, 0, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filledndBy( [ 2, 0, 2, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filledndBy( [ 3, 0, 3, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = filledndBy( [ 1, 1, 0, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = filledndBy( [ 1, 2, 0, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = filledndBy( [ 1, 3, 0, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = filledndBy( [ 1, 1, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = filledndBy( [ 1, 2, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = filledndBy( [ 1, 3, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = filledndBy( [ 0, 1, 1, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filledndBy( [ 0, 0, 0, 0, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = filledndBy( [ 0, 100, 100, 100, 100 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = filledndBy( [ 1, 0, 1, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = filledndBy( [ 2, 0, 2, 2, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = filledndBy( [ 3, 0, 3, 3, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = filledndBy( [ 1, 1, 0, 1, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = filledndBy( [ 1, 2, 0, 2, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = filledndBy( [ 1, 3, 0, 3, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = filledndBy( [ 1, 1, 1, 0, 1 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = filledndBy( [ 1, 2, 1, 0, 2 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = filledndBy( [ 1, 3, 1, 0, 3 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fifth element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ [] ] - ] - ] - ]; - actual = filledndBy( [ 1, 1, 1, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = filledndBy( [ 1, 2, 1, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = filledndBy( [ 1, 3, 1, 1, 0 ], constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - - ctx = { - 'count': 0 - }; - expected = [ - [ - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ] - ] - ]; - actual = filledndBy( [ 1, 1, 1, 2, 3 ], clbk, ctx ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - - t.end(); - - function clbk() { - this.count += 1; // eslint-disable-line no-invalid-this - return 'beep'; - } -}); - -tape( 'the function invokes a provided callback function with one argument', function test( t ) { - var expected; - var actual; - var idx; - - idx = []; - actual = filledndBy( [ 2, 2, 1, 2, 3 ], clbk ); - - expected = [ - [ - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ], - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ] - ], - [ - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ], - [ - [ - [ 'beep', 'beep', 'beep' ], - [ 'beep', 'beep', 'beep' ] - ] - ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0, 0 ], - [ 0, 0, 0, 0, 1 ], - [ 0, 0, 0, 0, 2 ], - [ 0, 0, 0, 1, 0 ], - [ 0, 0, 0, 1, 1 ], - [ 0, 0, 0, 1, 2 ], - [ 0, 1, 0, 0, 0 ], - [ 0, 1, 0, 0, 1 ], - [ 0, 1, 0, 0, 2 ], - [ 0, 1, 0, 1, 0 ], - [ 0, 1, 0, 1, 1 ], - [ 0, 1, 0, 1, 2 ], - [ 1, 0, 0, 0, 0 ], - [ 1, 0, 0, 0, 1 ], - [ 1, 0, 0, 0, 2 ], - [ 1, 0, 0, 1, 0 ], - [ 1, 0, 0, 1, 1 ], - [ 1, 0, 0, 1, 2 ], - [ 1, 1, 0, 0, 0 ], - [ 1, 1, 0, 0, 1 ], - [ 1, 1, 0, 0, 2 ], - [ 1, 1, 0, 1, 0 ], - [ 1, 1, 0, 1, 1 ], - [ 1, 1, 0, 1, 2 ] - ]; - t.deepEqual( idx, expected, 'returns expected value' ); - - t.end(); - - function clbk( indices ) { - idx.push( indices ); - return 'beep'; - } -}); diff --git a/base/fillednd/README.md b/base/fillednd/README.md deleted file mode 100644 index f1b9e1471..000000000 --- a/base/fillednd/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# fillednd - -> Create a filled n-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var fillednd = require( '@stdlib/array/base/fillednd' ); -``` - -#### fillednd( value, shape ) - -Returns a filled n-dimensional nested array. - -```javascript -var out = fillednd( 0.0, [ 2, 3 ] ); -// returns [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var fillednd = require( '@stdlib/array/base/fillednd' ); - -var out = fillednd( 0.0, [ 1, 3 ] ); -// returns [ [ 0.0, 0.0, 0.0 ] ] - -out = fillednd( 'beep', [ 3, 1 ] ); -// returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] - -out = fillednd( null, [ 1, 1, 3 ] ); -// returns [ [ [ null, null, null ] ] ] - -out = fillednd( true, [ 1, 3, 1 ] ); -// returns [ [ [ true ], [ true ], [ true ] ] ] - -out = fillednd( void 0, [ 1, 1, 1, 3 ] ); -// returns [ [ [ [ undefined, undefined, undefined ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/fillednd/benchmark/benchmark.size.2d.js b/base/fillednd/benchmark/benchmark.size.2d.js deleted file mode 100644 index 9251be205..000000000 --- a/base/fillednd/benchmark/benchmark.size.2d.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var fillednd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fillednd( i, [ N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::2d,equidimensional:size='+(N*N), f ); - } -} - -main(); diff --git a/base/fillednd/benchmark/benchmark.size.3d.js b/base/fillednd/benchmark/benchmark.size.3d.js deleted file mode 100644 index 69e75344b..000000000 --- a/base/fillednd/benchmark/benchmark.size.3d.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var cbrt = require( '@stdlib/math/base/special/cbrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var fillednd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fillednd( i, [ N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( cbrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::3d,equidimensional:size='+(N*N*N), f ); - } -} - -main(); diff --git a/base/fillednd/benchmark/benchmark.size.4d.js b/base/fillednd/benchmark/benchmark.size.4d.js deleted file mode 100644 index 198ba412c..000000000 --- a/base/fillednd/benchmark/benchmark.size.4d.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var fillednd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fillednd( i, [ N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::4d,equidimensional:size='+(N*N*N*N), f ); - } -} - -main(); diff --git a/base/fillednd/benchmark/benchmark.size.5d.js b/base/fillednd/benchmark/benchmark.size.5d.js deleted file mode 100644 index 4c588b926..000000000 --- a/base/fillednd/benchmark/benchmark.size.5d.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var fillednd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fillednd( i, [ N, N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::5d,equidimensional:size='+(N*N*N*N*N), f ); - } -} - -main(); diff --git a/base/fillednd/docs/repl.txt b/base/fillednd/docs/repl.txt deleted file mode 100644 index 833384a5c..000000000 --- a/base/fillednd/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( value, shape ) - Returns a filled n-dimensional nested array. - - Parameters - ---------- - value: any - Fill value. - - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( 0.0, [ 1, 3 ] ) - [ [ 0.0, 0.0, 0.0 ] ] - - See Also - -------- - diff --git a/base/fillednd/docs/types/index.d.ts b/base/fillednd/docs/types/index.d.ts deleted file mode 100644 index 1e24c7a56..000000000 --- a/base/fillednd/docs/types/index.d.ts +++ /dev/null @@ -1,313 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape } from '@stdlib/types/ndarray'; - -/** -* One-dimensional array. -*/ -type Array1D = Array; - -/** -* One-dimensional array shape. -*/ -type Shape1D = [ number ]; - -/** -* Two-dimensional array. -*/ -type Array2D = Array>; - -/** -* Two-dimensional array shape. -*/ -type Shape2D = [ number, number ]; - -/** -* Three-dimensional array. -*/ -type Array3D = Array>; - -/** -* Three-dimensional array shape. -*/ -type Shape3D = [ number, number, number ]; - -/** -* Four-dimensional array. -*/ -type Array4D = Array>; - -/** -* Four-dimensional array shape. -*/ -type Shape4D = [ number, number, number, number ]; - -/** -* Five-dimensional array. -*/ -type Array5D = Array>; - -/** -* Five-dimensional array shape. -*/ -type Shape5D = [ number, number, number, number, number ]; - -/** -* Six-dimensional array. -*/ -type Array6D = Array>; - -/** -* Six-dimensional array shape. -*/ -type Shape6D = [ number, number, number, number, number, number ]; - -/** -* Seven-dimensional array. -*/ -type Array7D = Array>; - -/** -* Seven-dimensional array shape. -*/ -type Shape7D = [ number, number, number, number, number, number, number ]; - -/** -* Eight-dimensional array. -*/ -type Array8D = Array>; - -/** -* Eight-dimensional array shape. -*/ -type Shape8D = [ number, number, number, number, number, number, number, number ]; - -/** -* Nine-dimensional array. -*/ -type Array9D = Array>; - -/** -* Nine-dimensional array shape. -*/ -type Shape9D = [ number, number, number, number, number, number, number, number, number ]; - -/** -* Ten-dimensional array. -*/ -type Array10D = Array>; // WARNING: arbitrarily limited to 10 dimensions, which should be fine for most practical purposes - -/** -* Ten-dimensional array shape. -*/ -type Shape10D = [ number, number, number, number, number, number, number, number, number, number ]; - -/** -* Returns a filled one-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = fillednd( 0.0, [ 3 ] ); -* // returns [ 0.0, 0.0, 0.0 ] -* -* @example -* var out = fillednd( 'beep', [ 3 ] ); -* // returns [ 'beep', 'beep', 'beep' ] -*/ -declare function fillednd( value: T, shape: Shape1D ): Array1D; -/** -* Returns a filled two-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = fillednd( 0.0, [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -* -* @example -* var out = fillednd( 'beep', [ 1, 3 ] ); -* // returns [ [ 'beep', 'beep', 'beep' ] ] -*/ -declare function fillednd( value: T, shape: Shape2D ): Array2D; -/** -* Returns a filled three-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = fillednd( 0.0, [ 1, 1, 3 ] ); -* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ] -* -* @example -* var out = fillednd( 'beep', [ 1, 1, 3 ] ); -* // returns [ [ [ 'beep', 'beep', 'beep' ] ] ] -*/ -declare function fillednd( value: T, shape: Shape3D ): Array3D; - -/** -* Returns a filled four-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = fillednd( 0.0, [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] -* -* @example -* var out = fillednd( 'beep', [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] -*/ -declare function fillednd( value: T, shape: Shape4D ): Array4D; - -/** -* Returns a filled five-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = fillednd( 0.0, [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] -* -* @example -* var out = fillednd( 'beep', [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] -*/ -declare function fillednd( value: T, shape: Shape5D ): Array5D; - -/** -* Returns a filled six-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = fillednd( 0.0, [ 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] -* -* @example -* var out = fillednd( 'beep', [ 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] ] -*/ -declare function fillednd( value: T, shape: Shape6D ): Array6D; - -/** -* Returns a filled seven-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = fillednd( 0.0, [ 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] -* -* @example -* var out = fillednd( 'beep', [ 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] ] ] -*/ -declare function fillednd( value: T, shape: Shape7D ): Array7D; - -/** -* Returns a filled eight-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = fillednd( 0.0, [ 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] ] -* -* @example -* var out = fillednd( 'beep', [ 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] ] ] ] -*/ -declare function fillednd( value: T, shape: Shape8D ): Array8D; - -/** -* Returns a filled nine-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = fillednd( 0.0, [ 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] ] ] -* -* @example -* var out = fillednd( 'beep', [ 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] ] ] ] ] -*/ -declare function fillednd( value: T, shape: Shape9D ): Array9D; - -/** -* Returns a filled ten-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = fillednd( 0.0, [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] ] ] ] -* -* @example -* var out = fillednd( 'beep', [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] ] ] ] ] ] -*/ -declare function fillednd( value: T, shape: Shape10D ): Array10D; - -/** -* Returns a filled n-dimensional nested array. -* -* @param value - fill value -* @param shape - array shape -* @returns output array -* -* @example -* var out = fillednd( 0.0, [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] ] ] ] -* -* @example -* var out = fillednd( 'beep', [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ] ] ] ] ] ] -*/ -declare function fillednd( value: T, shape: Shape ): Array; - - -// EXPORTS // - -export = fillednd; diff --git a/base/fillednd/docs/types/test.ts b/base/fillednd/docs/types/test.ts deleted file mode 100644 index 1d3334ef0..000000000 --- a/base/fillednd/docs/types/test.ts +++ /dev/null @@ -1,49 +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. -*/ - -import fillednd = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - fillednd( 0.0, [ 3 ] ); // $ExpectType Array1D - fillednd( 0.0, [ 1, 3 ] ); // $ExpectType Array2D - fillednd( 0.0, [ 1, 1, 3 ] ); // $ExpectType Array3D - fillednd( 0.0, [ 1, 1, 1, 3 ] ); // $ExpectType Array4D - fillednd( 0.0, [ 1, 1, 1, 1, 3 ] ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - fillednd( 0.0, 'abc' ); // $ExpectError - fillednd( 0.0, true ); // $ExpectError - fillednd( 0.0, false ); // $ExpectError - fillednd( 0.0, null ); // $ExpectError - fillednd( 0.0, [ '1' ] ); // $ExpectError - fillednd( 0.0, {} ); // $ExpectError - fillednd( 0.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - fillednd(); // $ExpectError - fillednd( 0.0 ); // $ExpectError - fillednd( 0.0, [ 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/fillednd/examples/index.js b/base/fillednd/examples/index.js deleted file mode 100644 index 2977aab8d..000000000 --- a/base/fillednd/examples/index.js +++ /dev/null @@ -1,41 +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'; - -var fillednd = require( './../lib' ); - -var out = fillednd( 0.0, [ 1, 3 ] ); -console.log( out ); -// => [ [ 0.0, 0.0, 0.0 ] ] - -out = fillednd( 'beep', [ 3, 1 ] ); -console.log( out ); -// => [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] - -out = fillednd( null, [ 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ null, null, null ] ] ] - -out = fillednd( true, [ 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ true ], [ true ], [ true ] ] ] - -out = fillednd( void 0, [ 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ undefined, undefined, undefined ] ] ] ] diff --git a/base/fillednd/lib/index.js b/base/fillednd/lib/index.js deleted file mode 100644 index 64feaf2d0..000000000 --- a/base/fillednd/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Create a filled n-dimensional nested array. -* -* @module @stdlib/array/base/fillednd -* -* @example -* var fillednd = require( '@stdlib/array/base/fillednd' ); -* -* var out = fillednd( 0.0, [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -* -* @example -* var fillednd = require( '@stdlib/array/base/fillednd' ); -* -* var out = fillednd( 'beep', [ 3, 1 ] ); -* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/fillednd/lib/main.js b/base/fillednd/lib/main.js deleted file mode 100644 index bf5710808..000000000 --- a/base/fillednd/lib/main.js +++ /dev/null @@ -1,88 +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 filled = require( './../../../base/filled' ); - - -// FUNCTIONS // - -/** -* Recursive fills an array. -* -* @private -* @param {*} value - fill value -* @param {NonNegativeInteger} ndims - number of dimensions -* @param {NonNegativeIntegerArray} shape - array shape -* @param {NonNegativeInteger} dim - dimension index -* @param {Array} out - output array -* @returns {Array} output array -*/ -function recurse( value, ndims, shape, dim, out ) { - var S; - var d; - var i; - - S = shape[ dim ]; - - // Check whether we're filling the last dimension: - d = dim + 1; - if ( d === ndims ) { - return filled( value, S ); - } - - // Fill nested dimensions... - for ( i = 0; i < S; i++ ) { - out.push( recurse( value, ndims, shape, d, [] ) ); - } - return out; -} - - -// MAIN // - -/** -* Returns a filled n-dimensional nested array. -* -* @param {*} value - fill value -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = fillednd( 0.0, [ 3 ] ); -* // returns [ 0.0, 0.0, 0.0 ] -* -* @example -* var out = fillednd( 0.0, [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -* -* @example -* var out = fillednd( 'beep', [ 3, 1 ] ); -* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] -*/ -function fillednd( value, shape ) { - return recurse( value, shape.length, shape, 0, [] ); -} - - -// EXPORTS // - -module.exports = fillednd; diff --git a/base/fillednd/package.json b/base/fillednd/package.json deleted file mode 100644 index 92c8dff1d..000000000 --- a/base/fillednd/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/fillednd", - "version": "0.0.0", - "description": "Create a filled n-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray" - ] -} diff --git a/base/fillednd/test/test.js b/base/fillednd/test/test.js deleted file mode 100644 index 519cd1711..000000000 --- a/base/fillednd/test/test.js +++ /dev/null @@ -1,616 +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 fillednd = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof fillednd, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array (0d)', function test( t ) { - var expected; - var actual; - - expected = []; - actual = fillednd( 'beep', [] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (1d)', function test( t ) { - var expected; - var actual; - - expected = [ 'beep', 'beep', 'beep' ]; - actual = fillednd( 'beep', [ 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (2d)', function test( t ) { - var expected; - var actual; - - expected = [ [ 'beep', 'beep', 'beep' ] ]; - actual = fillednd( 'beep', [ 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ]; - actual = fillednd( 'beep', [ 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 'beep', 'beep' ], [ 'beep', 'beep' ], [ 'beep', 'beep' ] ]; - actual = fillednd( 'beep', [ 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (3d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ]; - actual = fillednd( 'beep', [ 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ]; - actual = fillednd( 'beep', [ 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ]; - actual = fillednd( 'beep', [ 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ] - ]; - actual = fillednd( 'beep', [ 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ]; - actual = fillednd( 'beep', [ 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ], - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ] - ]; - actual = fillednd( 'beep', [ 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ - [ 'beep', 'beep', 'beep' ] - ] - ] - ] - ]; - actual = fillednd( 'beep', [ 1, 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ], - [ - [ - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ], - [ - [ 'beep' ], - [ 'beep' ], - [ 'beep' ] - ] - ] - ] - ]; - actual = fillednd( 'beep', [ 2, 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ], - [ - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ], - [ - [ 'beep', 'beep' ], - [ 'beep', 'beep' ], - [ 'beep', 'beep' ] - ] - ] - ] - ]; - actual = fillednd( 'beep', [ 1, 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided a shape having a first element equal to zero (1d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = fillednd( 'beep', [ 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (2d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = fillednd( 'beep', [ 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = fillednd( 'beep', [ 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = fillednd( 'beep', [ 0, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (2d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = fillednd( 'beep', [ 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = fillednd( 'beep', [ 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = fillednd( 'beep', [ 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = fillednd( 'beep', [ 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = fillednd( 'beep', [ 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = fillednd( 'beep', [ 0, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = fillednd( 'beep', [ 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = fillednd( 'beep', [ 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = fillednd( 'beep', [ 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = [ [ [] ] ]; - actual = fillednd( 'beep', [ 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [] ] ]; - actual = fillednd( 'beep', [ 1, 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [], [] ] ]; - actual = fillednd( 'beep', [ 1, 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = fillednd( 'beep', [ 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = fillednd( 'beep', [ 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = fillednd( 'beep', [ 0, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = fillednd( 'beep', [ 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = fillednd( 'beep', [ 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = fillednd( 'beep', [ 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = fillednd( 'beep', [ 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = fillednd( 'beep', [ 1, 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = fillednd( 'beep', [ 1, 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = fillednd( 'beep', [ 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = fillednd( 'beep', [ 1, 2, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = fillednd( 'beep', [ 1, 3, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = fillednd( 'beep', [ 0, 1, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = fillednd( 'beep', [ 0, 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = fillednd( 'beep', [ 0, 100, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = fillednd( 'beep', [ 1, 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = fillednd( 'beep', [ 2, 0, 2, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = fillednd( 'beep', [ 3, 0, 3, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = fillednd( 'beep', [ 1, 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = fillednd( 'beep', [ 1, 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = fillednd( 'beep', [ 1, 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = fillednd( 'beep', [ 1, 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = fillednd( 'beep', [ 1, 2, 1, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = fillednd( 'beep', [ 1, 3, 1, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fifth element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ [] ] - ] - ] - ]; - actual = fillednd( 'beep', [ 1, 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = fillednd( 'beep', [ 1, 2, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = fillednd( 'beep', [ 1, 3, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/filter/README.md b/base/filter/README.md deleted file mode 100644 index c9bd7ded2..000000000 --- a/base/filter/README.md +++ /dev/null @@ -1,156 +0,0 @@ - - -# filter - -> Return a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filter = require( '@stdlib/array/base/filter' ); -``` - -#### filter( x, predicate\[, thisArg] ) - -Returns a shallow copy of an array containing only those elements which pass a test implemented by a `predicate` function. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 1, -2, -3, 4 ]; - -var out = filter( x, isPositive ); -// returns [ 1, 4 ] -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( value ) { - this.count += 1; - return ( value > 0 ); -} - -var x = [ 1, 2, -3, 4 ]; - -var context = { - 'count': 0 -}; - -var out = filter( x, predicate, context ); -// returns [ 1, 2, 4 ] - -var cnt = context.count; -// returns 4 -``` - -
- - - - - -
- -## Notes - -- If provided an array-like object having a `filter` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.filter( predicate, thisArg ) - ``` - -- If provided an array-like object without a `filter` method, the function performs a linear scan and **always** returns a generic array. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var filter = require( '@stdlib/array/base/filter' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = filter( x, naryFunction( isPositiveInteger, 1 ) ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/filter/benchmark/benchmark.length.js b/base/filter/benchmark/benchmark.length.js deleted file mode 100644 index 6c5a62355..000000000 --- a/base/filter/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var filter = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filter( x, isNonNegativeInteger ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/filter/docs/repl.txt b/base/filter/docs/repl.txt deleted file mode 100644 index bb2b17a4f..000000000 --- a/base/filter/docs/repl.txt +++ /dev/null @@ -1,46 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Returns a shallow copy of an array containing only those elements which pass - a test implemented by a predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - If provided an array-like object having a `filter` method , the function - defers execution to that method and assumes that the method has the - following signature: - - x.filter( predicate, thisArg ) - - If provided an array-like object without a `filter` method, the function - performs a linear scan and always returns a generic array. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: Array|TypedArray|Object - Output array. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var x = [ 1, -2, -3, 4 ]; - > var out = {{alias}}( x, f ) - [ 1, 4 ] - - See Also - -------- - diff --git a/base/filter/docs/types/index.d.ts b/base/filter/docs/types/index.d.ts deleted file mode 100644 index b2b8b06e9..000000000 --- a/base/filter/docs/types/index.d.ts +++ /dev/null @@ -1,348 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, Complex128Array, Complex64Array } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: V ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, -2.0, -3.0, 4.0 ] ); -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1.0, 4.0 ] -*/ -declare function filter( x: Float64Array, predicate: Predicate, thisArg?: ThisParameterType> ): Float64Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var x = new Float32Array( [ 1.0, -2.0, -3.0, 4.0 ] ); -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1.0, 4.0 ] -*/ -declare function filter( x: Float32Array, predicate: Predicate, thisArg?: ThisParameterType> ): Float32Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, -2, -3, 4 ] ); -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1, 4 ] -*/ -declare function filter( x: Int32Array, predicate: Predicate, thisArg?: ThisParameterType> ): Int32Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var x = new Int16Array( [ 1, -2, -3, 4 ] ); -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1, 4 ] -*/ -declare function filter( x: Int16Array, predicate: Predicate, thisArg?: ThisParameterType> ): Int16Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var x = new Int8Array( [ 1, -2, -3, 4 ] ); -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1, 4 ] -*/ -declare function filter( x: Int8Array, predicate: Predicate, thisArg?: ThisParameterType> ): Int8Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function filter( x: Uint32Array, predicate: Predicate, thisArg?: ThisParameterType> ): Uint32Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function filter( x: Uint16Array, predicate: Predicate, thisArg?: ThisParameterType> ): Uint16Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function filter( x: Uint8Array, predicate: Predicate, thisArg?: ThisParameterType> ): Uint8Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function filter( x: Uint8ClampedArray, predicate: Predicate, thisArg?: ThisParameterType> ): Uint8ClampedArray; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* function predicate( v ) { -* return ( isPositiveNumber( real( v ) ) && isPositiveNumber( imag( v ) ) ); -* } -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* var out = filter( x, predicate ); -* // returns -*/ -declare function filter( x: Complex128Array, predicate: Predicate, thisArg?: ThisParameterType> ): Complex128Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* function predicate( v ) { -* return ( isPositiveNumber( realf( v ) ) && isPositiveNumber( imagf( v ) ) ); -* } -* -* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* var out = filter( x, predicate ); -* // returns -*/ -declare function filter( x: Complex64Array, predicate: Predicate, thisArg?: ThisParameterType> ): Complex64Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* -* var x = [ 1, -2, -3, 4 ]; -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1, 4 ] -*/ -declare function filter( x: Array, predicate: Predicate>, thisArg?: ThisParameterType>> ): Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, -2, -3, 4 ] ); -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1, 4 ] -*/ -declare function filter( x: AccessorArrayLike, predicate: Predicate>, thisArg?: ThisParameterType>> ): Array; - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* -* var x = [ 1, -2, -3, 4 ]; -* -* var out = filter( x, isPositiveNumber ); -* // returns [ 1, 4 ] -*/ -declare function filter( x: Collection, predicate: Predicate>, thisArg?: ThisParameterType>> ): Array; - - -// EXPORTS // - -export = filter; diff --git a/base/filter/docs/types/test.ts b/base/filter/docs/types/test.ts deleted file mode 100644 index 52a8ac7f2..000000000 --- a/base/filter/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import filter = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a collection... -{ - filter( [ 1, 2, 3 ], isPositive ); // $ExpectType number[] - filter( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Float64Array - filter( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Float32Array - filter( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Int32Array - filter( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Int16Array - filter( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Int8Array - filter( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Uint32Array - filter( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Uint16Array - filter( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Uint8Array - filter( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Uint8ClampedArray - filter( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number[] - - filter( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number[] - filter( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Float64Array - filter( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Float32Array - filter( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Int32Array - filter( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Int16Array - filter( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Int8Array - filter( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Uint32Array - filter( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Uint16Array - filter( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Uint8Array - filter( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Uint8ClampedArray - filter( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - filter( 2, isPositive ); // $ExpectError - filter( false, isPositive ); // $ExpectError - filter( true, isPositive ); // $ExpectError - filter( {}, isPositive ); // $ExpectError - - filter( 2, isPositive, {} ); // $ExpectError - filter( false, isPositive, {} ); // $ExpectError - filter( true, isPositive, {} ); // $ExpectError - filter( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - filter( [ 1, 2, 3 ], 'abc' ); // $ExpectError - filter( [ 1, 2, 3 ], 2 ); // $ExpectError - filter( [ 1, 2, 3 ], false ); // $ExpectError - filter( [ 1, 2, 3 ], true ); // $ExpectError - filter( [ 1, 2, 3 ], null ); // $ExpectError - filter( [ 1, 2, 3 ], void 0 ); // $ExpectError - filter( [ 1, 2, 3 ], {} ); // $ExpectError - filter( [ 1, 2, 3 ], [] ); // $ExpectError - - filter( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - filter( [ 1, 2, 3 ], 2, {} ); // $ExpectError - filter( [ 1, 2, 3 ], false, {} ); // $ExpectError - filter( [ 1, 2, 3 ], true, {} ); // $ExpectError - filter( [ 1, 2, 3 ], null, {} ); // $ExpectError - filter( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - filter( [ 1, 2, 3 ], {}, {} ); // $ExpectError - filter( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filter(); // $ExpectError - filter( [ 1, 2, 3 ] ); // $ExpectError - filter( [ 1, 2, 3 ], isPositive, {}, 3 ); // $ExpectError -} diff --git a/base/filter/examples/index.js b/base/filter/examples/index.js deleted file mode 100644 index e5c3346f6..000000000 --- a/base/filter/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var filter = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = filter( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/filter/lib/index.js b/base/filter/lib/index.js deleted file mode 100644 index 4962d0a52..000000000 --- a/base/filter/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Return a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @module @stdlib/array/base/filter -* -* @example -* var filter = require( '@stdlib/array/base/filter' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, -2, -3, 4 ]; -* -* var out = filter( x, isPositive ); -* // returns [ 1, 4 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/filter/lib/main.js b/base/filter/lib/main.js deleted file mode 100644 index 0d579e71f..000000000 --- a/base/filter/lib/main.js +++ /dev/null @@ -1,160 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'filter' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Array} output array -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, -2, -3, 4 ]; -* -* var out = internal( x, isPositive ); -* // returns [ 1, 4 ] -*/ -function internal( x, predicate, thisArg ) { - var out; - var v; - var i; - - out = []; - for ( i = 0; i < x.length; i++ ) { - v = x[ i ]; - if ( predicate.call( thisArg, v, i, x ) ) { - out.push( v ); - } - } - return out; -} - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @private -* @param {Object} x - input array object -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Array} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = arraylike2object( toAccessorArray( [ 1, -2, -3, 4 ] ) ); -* -* var out = accessors( x, isPositive ); -* // returns [ 1, 4 ] -*/ -function accessors( x, predicate, thisArg ) { - var data; - var get; - var out; - var v; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - out = []; - for ( i = 0; i < data.length; i++ ) { - v = get( data, i ); - if ( predicate.call( thisArg, v, i, data ) ) { - out.push( v ); - } - } - return out; -} - - -// MAIN // - -/** -* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, -2, -3, 4 ]; -* -* var out = filter( x, isPositive ); -* // returns [ 1, 4 ] -*/ -function filter( x, predicate, thisArg ) { - var obj; - if ( hasMethod( x, 'filter' ) ) { - return x.filter( predicate, thisArg ); - } - obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, predicate, thisArg ); - } - return internal( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = filter; diff --git a/base/filter/package.json b/base/filter/package.json deleted file mode 100644 index 08289cec5..000000000 --- a/base/filter/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/filter", - "version": "0.0.0", - "description": "Return a shallow copy of an array containing only those elements which pass a test implemented by a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "predicate", - "filter", - "reject", - "array.filter", - "copy" - ] -} diff --git a/base/filter/test/test.js b/base/filter/test/test.js deleted file mode 100644 index a83b764b7..000000000 --- a/base/filter/test/test.js +++ /dev/null @@ -1,251 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var filter = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Tests whether a value is positive. -* -* @private -* @param {number} value - input value -* @returns {boolean} boolean indicating if a value is positive -*/ -function isPositive( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns an empty collection (generic)', function test( t ) { - var expected; - var actual; - var arr; - - arr = []; - expected = []; - actual = filter( arr, foo ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns an empty collection (typed array)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float64Array( [] ); - expected = new Float64Array( [] ); - actual = filter( arr, foo ); - - t.strictEqual( instanceOf( actual, Float64Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns an empty collection (accessor)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new AccessorArray( [] ); - expected = []; - actual = filter( arr, foo ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the function filters a provided collection (generic)', function test( t ) { - var expected; - var actual; - var arr; - - arr = [ 1, -2, 3 ]; - expected = [ 1, 3 ]; - actual = filter( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function filters a provided collection (typed array)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float64Array( [ -1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 2.0, 3.0 ] ); - actual = filter( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Float64Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function filters a provided collection (accessor)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new AccessorArray( [ 1, -2, -3 ] ); - expected = [ 1 ]; - actual = filter( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function filters a provided collection (array-like object)', function test( t ) { - var expected; - var actual; - var arr; - - arr = { - 'length': 3, - '0': -1, - '1': -2, - '2': 3 - }; - expected = [ 3 ]; - actual = filter( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function an empty collection if all elements fail a test (generic)', function test( t ) { - var expected; - var actual; - var arr; - - arr = [ -1, -2, -3 ]; - expected = []; - actual = filter( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function an empty collection if all elements fail a test (typed array)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float64Array( [ -1.0, -2.0, -3.0 ] ); - expected = new Float64Array( [] ); - actual = filter( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Float64Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function an empty collection if all elements fail a test (accessor)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new AccessorArray( [ -1, -2, -3 ] ); - expected = []; - actual = filter( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function an empty collection if all elements fail a test (array-like object)', function test( t ) { - var expected; - var actual; - var arr; - - arr = { - 'length': 3, - '0': -1, - '1': -2, - '2': -3 - }; - expected = []; - actual = filter( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = [ 1, 2, 3 ]; - expected = [ 1, 2, 3 ]; - actual = filter( arr, predicate, ctx ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, arr.length, 'returns expected value' ); - - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); diff --git a/base/first/README.md b/base/first/README.md deleted file mode 100644 index db35be7b8..000000000 --- a/base/first/README.md +++ /dev/null @@ -1,123 +0,0 @@ - - -# first - -> Return the first element of an array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var first = require( '@stdlib/array/base/first' ); -``` - -#### first( x ) - -Returns the first element of an array-like object. - -```javascript -var x = [ 1, 2, 3 ]; - -var out = first( x ); -// returns 1 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var Complex64Array = require( '@stdlib/array/complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var first = require( '@stdlib/array/base/first' ); - -// Create a complex number array: -var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - -// Return the first element: -var out = first( arr ); -// returns - -var re = realf( out ); -// returns 1.0 - -var im = imagf( out ); -// returns 2.0 - -console.log( '%d + %di', re, im ); -// => '1 + 2i' -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/first/benchmark/benchmark.js b/base/first/benchmark/benchmark.js deleted file mode 100644 index a2dd6d468..000000000 --- a/base/first/benchmark/benchmark.js +++ /dev/null @@ -1,102 +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 bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var pow = require( '@stdlib/math/base/special/pow' ); -var filledBy = require( './../../../filled-by' ); -var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var pkg = require( './../package.json' ).name; -var first = require( './../lib' ); - - -// VARIABLES // - -var rand = discreteUniform( 0, 127 ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = filledBy( len, 'float32', rand ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = first( arr ); - if ( isnanf( out ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnanf( out ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/first/docs/repl.txt b/base/first/docs/repl.txt deleted file mode 100644 index a3f6cd20c..000000000 --- a/base/first/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( arr ) - Returns the first element of an array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: any - First element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3 ] ) - 1 - - See Also - -------- - diff --git a/base/first/docs/types/index.d.ts b/base/first/docs/types/index.d.ts deleted file mode 100644 index a57dcf884..000000000 --- a/base/first/docs/types/index.d.ts +++ /dev/null @@ -1,42 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Returns the first element of an array-like object. -* -* @param arr - input array -* @returns first element -* -* @example -* var arr = [ 1, 2, 3 ]; -* -* var out = first( x ); -* // returns 1 -*/ -declare function first( arr: Collection ): T; - - -// EXPORTS // - -export = first; diff --git a/base/first/docs/types/test.ts b/base/first/docs/types/test.ts deleted file mode 100644 index 7a0f49d1d..000000000 --- a/base/first/docs/types/test.ts +++ /dev/null @@ -1,42 +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. -*/ - -import first = require( './index' ); - - -// TESTS // - -// The function returns an array element... -{ - first( [ 1, 2, 3 ] ); // $ExpectType number -} - -// The compiler throws an error if the function is provided an argument which is not a collection... -{ - first( 5 ); // $ExpectError - first( true ); // $ExpectError - first( false ); // $ExpectError - first( null ); // $ExpectError - first( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - first(); // $ExpectError - first( [ 1, 2, 3 ], 2 ); // $ExpectError -} diff --git a/base/first/examples/index.js b/base/first/examples/index.js deleted file mode 100644 index a8ffb900c..000000000 --- a/base/first/examples/index.js +++ /dev/null @@ -1,40 +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'; - -var Complex64Array = require( './../../../complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var first = require( './../lib' ); - -// Create a complex number array: -var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - -// Return the first element: -var out = first( arr ); -// returns - -var re = realf( out ); -// returns 1.0 - -var im = imagf( out ); -// returns 2.0 - -console.log( '%d + %di', re, im ); -// => '1 + 2i' diff --git a/base/first/lib/index.js b/base/first/lib/index.js deleted file mode 100644 index 9e20f350b..000000000 --- a/base/first/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Return the first element of an array-like object. -* -* @module @stdlib/array/base/first -* -* @example -* var first = require( '@stdlib/array/base/first' ); -* -* var out = first( [ 1, 2, 3 ] ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/first/lib/main.js b/base/first/lib/main.js deleted file mode 100644 index 32c155074..000000000 --- a/base/first/lib/main.js +++ /dev/null @@ -1,54 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Returns the first element of an array-like object. -* -* @param {Collection} arr - input array -* @returns {*} - first element -* -* @example -* var out = first( [ 1, 2, 3 ] ); -* // returns 1 -*/ -function first( arr ) { - var get; - - if ( arr.length === 0 ) { - return; - } - // Resolve an accessor for retrieving input array elements: - get = resolveGetter( arr ); - - // Return the first element: - return get( arr, 0 ); -} - - -// EXPORTS // - -module.exports = first; diff --git a/base/first/package.json b/base/first/package.json deleted file mode 100644 index 684101939..000000000 --- a/base/first/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/first", - "version": "0.0.0", - "description": "Return the first element of an array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "generic", - "first" - ] -} diff --git a/base/first/test/test.js b/base/first/test/test.js deleted file mode 100644 index 13c6120d5..000000000 --- a/base/first/test/test.js +++ /dev/null @@ -1,74 +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 Complex64Array = require( './../../../complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var first = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof first, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the first element of an array-like object', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - expected = 1; - actual = first( x ); - - t.equal( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the first element of an array-like object (accessors)', function test( t ) { - var actual; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - actual = first( x ); - - t.strictEqual( realf( actual ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( actual ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `undefined` if provided an empty array', function test( t ) { - var actual = first( [] ); - t.strictEqual( actual, void 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `undefined` if provided an empty array (accessors)', function test( t ) { - var actual = first( new Complex64Array( 0 ) ); - t.strictEqual( actual, void 0, 'returns expected value' ); - t.end(); -}); diff --git a/base/flatten-by/README.md b/base/flatten-by/README.md deleted file mode 100644 index 393746f8d..000000000 --- a/base/flatten-by/README.md +++ /dev/null @@ -1,225 +0,0 @@ - - - - -# flattenBy - -> Flatten an n-dimensional nested array according to a callback function. - -
- -## Usage - -```javascript -var flattenBy = require( '@stdlib/array/base/flatten-by' ); -``` - -#### flattenBy( x, shape, colexicographic, clbk\[, thisArg] ) - -Flattens an n-dimensional nested array according to a callback function. - -```javascript -function scale( v ) { - return v * 2; -} - -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var out = flattenBy( x, [ 2, 2 ], false, scale ); -// returns [ 2, 4, 6, 8 ] -``` - -To flatten in colexicographic order, provide a third argument equal to `true`. - -```javascript -function scale( v ) { - return v * 2; -} - -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var out = flattenBy( x, [ 2, 2 ], true, scale ); -// returns [ 2, 6, 4, 8 ] -``` - -To set the callback execution context, provide a `thisArg` argument. - - - -```javascript -function scale( v ) { - this.count += 1; - return v * 2; -} - -var x = [ [ 1, 2 ], [ 3, 4 ] ]; -var ctx = { - 'count': 0 -}; - -var out = flattenBy( x, [ 2, 2 ], false, scale, ctx ); -// returns [ 2, 4, 6, 8 ] - -var count = ctx.count; -// returns 4 -``` - -#### flattenBy.assign( x, shape, colexicographic, out, stride, offset, clbk\[, thisArg] ) - -Flattens an n-dimensional nested array according to a callback function and assigns elements to a provided output array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -function scale( v ) { - return v * 2; -} - -var x = [ [ 1, 2 ], [ 3, 4 ] ]; -var out = new Float64Array( 4 ); - -var y = flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, scale ); -// returns [ 2, 4, 6, 8 ] - -var bool = ( y === out ); -// returns true - -y = flattenBy.assign( x, [ 2, 2 ], true, out, 1, 0, scale ); -// returns [ 2, 6, 4, 8 ] -``` - -
- - - -
- -## Notes - -- A callback function is provided the following arguments: - - - **value**: nested array element. - - **indices**: element indices (in lexicographic order). - - **arr**: the input array. - -- Both functions assume that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - -
- - - -
- -## Examples - - - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flattenBy = require( '@stdlib/array/base/flatten-by' ); - -var fcn = naryFunction( abs, 1 ); - -// Define a 2x2x1x2x2 array: -var x = [ - [ - [ - [ - [ -1, -2 ], [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], [ -15, -16 ] - ] - ] - ] -]; - -var out = flattenBy( x, [ 0, 0, 0, 0, 0 ], false, fcn ); -// returns [] - -out = flattenBy( x, [ 0, 0, 0, 0, 0 ], true, fcn ); -// returns [] - -out = flattenBy( x, [ 1, 1, 1, 1, 1 ], false, fcn ); -// returns [ 1 ] - -out = flattenBy( x, [ 1, 1, 1, 1, 1 ], true, fcn ); -// returns [ 1 ] - -out = flattenBy( x, [ 1, 2, 1, 2, 2 ], false, fcn ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flattenBy( x, [ 1, 2, 1, 2, 2 ], true, fcn ); -// returns [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flattenBy( x, [ 2, 2, 1, 2, 2 ], false, fcn ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flattenBy( x, [ 2, 2, 1, 2, 2 ], true, fcn ); -// returns [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/flatten-by/benchmark/benchmark.js b/base/flatten-by/benchmark/benchmark.js deleted file mode 100644 index 5e1eed8f5..000000000 --- a/base/flatten-by/benchmark/benchmark.js +++ /dev/null @@ -1,419 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var zeroTo = require( './../../../base/zero-to' ); -var filled = require( './../../../base/filled' ); -var Float64Array = require( './../../../float64' ); -var pkg = require( './../package.json' ).name; -var flattenBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Scales an input value. -* -* @private -* @param {number} v - input value -* @returns {number} output value -* -* @example -* var v = scale( 2.0 ); -* // returns 4.0 -*/ -function scale( v ) { - return v * 2.0; -} - - -// MAIN // - -bench( pkg+':ndims=2,size=100,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy( x, [ 10, 10 ], false, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=2,size=100,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy( x, [ 10, 10 ], true, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=2,size=100,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 100 ); - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy.assign( x, [ 10, 10 ], false, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=2,size=100,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 100 ); - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy.assign( x, [ 10, 10 ], true, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=3,size=125,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy( x, [ 5, 5, 5 ], false, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=3,size=125,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy( x, [ 5, 5, 5 ], true, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=3,size=125,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 125 ); - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy.assign( x, [ 5, 5, 5 ], false, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=3,size=125,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 125 ); - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy.assign( x, [ 5, 5, 5 ], true, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=4,size=144,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy( x, [ 4, 3, 4, 3 ], false, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=4,size=144,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy( x, [ 4, 3, 4, 3 ], true, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=4,size=144,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 144 ); - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy.assign( x, [ 4, 3, 4, 3 ], false, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=4,size=144,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 144 ); - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy.assign( x, [ 4, 3, 4, 3 ], true, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=5,size=108,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy( x, [ 2, 2, 3, 3, 3 ], false, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=5,size=108,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy( x, [ 2, 2, 3, 3, 3 ], true, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=5,size=108,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 108 ); - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy.assign( x, [ 2, 2, 3, 3, 3 ], false, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=5,size=108,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 108 ); - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flattenBy.assign( x, [ 2, 2, 3, 3, 3 ], true, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/flatten-by/docs/repl.txt b/base/flatten-by/docs/repl.txt deleted file mode 100644 index dc9b6784f..000000000 --- a/base/flatten-by/docs/repl.txt +++ /dev/null @@ -1,106 +0,0 @@ - -{{alias}}( x, shape, colex, clbk[, thisArg] ) - Flattens an n-dimensional nested array according to a callback function. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - The callback function is provided the following arguments: - - - value: nested array element. - - indices: element indices (in lexicographic order). - - arr: the input array. - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colex: boolean - Specifies whether to flatten array values in colexicographic order. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Flattened array. - - Examples - -------- - > function fcn( v ) { return v * 2; }; - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var out = {{alias}}( x, [ 2, 2 ], false, fcn ) - [ 2, 4, 6, 8 ] - > out = {{alias}}( x, [ 2, 2 ], true, fcn ) - [ 2, 6, 4, 8 ] - - -{{alias}}.assign( x, shape, colex, out, stride, offset, clbk[, thisArg] ) - Flattens an n-dimensional nested array according to a callback function and - assigns elements to a provided output array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - The callback function is provided the following arguments: - - - value: nested array element. - - indices: element indices (in lexicographic order). - - arr: the input array. - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colex: boolean - Specifies whether to flatten array values in colexicographic order. - - out: Collection - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function fcn( v ) { return v * 2; }; - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var out = [ 0, 0, 0, 0 ]; - > var v = {{alias}}.assign( x, [ 2, 2 ], false, out, 1, 0, fcn ) - [ 2, 4, 6, 8 ] - > var bool = ( v === out ) - true - > out = [ 0, 0, 0, 0 ]; - > {{alias}}.assign( x, [ 2, 2 ], true, out, 1, 0, fcn ); - > out - [ 2, 6, 4, 8 ] - - See Also - -------- - diff --git a/base/flatten-by/docs/types/index.d.ts b/base/flatten-by/docs/types/index.d.ts deleted file mode 100644 index 86a7965f1..000000000 --- a/base/flatten-by/docs/types/index.d.ts +++ /dev/null @@ -1,1127 +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. -*/ - -/* eslint-disable max-lines */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Array1D, Array2D, Array3D, Array4D, Array5D, Array6D, Array7D, Array8D, Array9D, Array10D } from '@stdlib/types/array'; - -/** -* One-dimensional array shape. -*/ -type Shape1D = [ number ]; - -/** -* Two-dimensional array shape. -*/ -type Shape2D = [ number, number ]; - -/** -* Three-dimensional array shape. -*/ -type Shape3D = [ number, number, number ]; - -/** -* Four-dimensional array shape. -*/ -type Shape4D = [ number, number, number, number ]; - -/** -* Five-dimensional array shape. -*/ -type Shape5D = [ number, number, number, number, number ]; - -/** -* Six-dimensional array shape. -*/ -type Shape6D = [ number, number, number, number, number, number ]; - -/** -* Seven-dimensional array shape. -*/ -type Shape7D = [ number, number, number, number, number, number, number ]; - -/** -* Eight-dimensional array shape. -*/ -type Shape8D = [ number, number, number, number, number, number, number, number ]; - -/** -* Nine-dimensional array shape. -*/ -type Shape9D = [ number, number, number, number, number, number, number, number, number ]; - -/** -* Ten-dimensional array shape. -*/ -type Shape10D = [ number, number, number, number, number, number, number, number, number, number ]; - -/** -* Nullary callback function. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Unary callback function. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Binary callback function. -* -* @param value - array element -* @param indices - element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Array ) => U; // TODO: could consider whether to make indices a tuple of fixed length, but would require Binary1D, Binary2D, etc, etc. - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary1D = ( this: V, value: T, indices: Array, arr: Array1D ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary2D = ( this: V, value: T, indices: Array, arr: Array2D ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary3D = ( this: V, value: T, indices: Array, arr: Array3D ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary4D = ( this: V, value: T, indices: Array, arr: Array4D ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary5D = ( this: V, value: T, indices: Array, arr: Array5D ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary6D = ( this: V, value: T, indices: Array, arr: Array6D ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary7D = ( this: V, value: T, indices: Array, arr: Array7D ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary8D = ( this: V, value: T, indices: Array, arr: Array8D ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary9D = ( this: V, value: T, indices: Array, arr: Array9D ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary10D = ( this: V, value: T, indices: Array, arr: Array10D ) => U; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback1D = Nullary | Unary | Binary | Ternary1D; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback2D = Nullary | Unary | Binary | Ternary2D; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback3D = Nullary | Unary | Binary | Ternary3D; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback4D = Nullary | Unary | Binary | Ternary4D; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback5D = Nullary | Unary | Binary | Ternary5D; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback6D = Nullary | Unary | Binary | Ternary6D; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback7D = Nullary | Unary | Binary | Ternary7D; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback8D = Nullary | Unary | Binary | Ternary8D; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback9D = Nullary | Unary | Binary | Ternary9D; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback10D = Nullary | Unary | Binary | Ternary10D; - -/** -* Interface describing `flattenBy`. -*/ -interface FlattenBy { - /** - * Flattens a one-dimensional nested array according to a callback function. - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ 1, 2 ]; - * - * var out = flattenBy( x, [ 2 ], false, scale ); - * // returns [ 2, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ 1, 2 ]; - * - * var out = flattenBy( x, [ 2 ], true, scale ); - * // returns [ 2, 4 ] - */ - ( x: Array1D, shape: Shape1D, colexicographic: boolean, clbk: Callback1D, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a two-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flattenBy( x, [ 2, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flattenBy( x, [ 2, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array2D, shape: Shape2D, colexicographic: boolean, clbk: Callback2D, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a three-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - * - * var out = flattenBy( x, [ 1, 2, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - * - * var out = flattenBy( x, [ 1, 2, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array3D, shape: Shape3D, colexicographic: boolean, clbk: Callback3D, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a four-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 2, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 2, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array4D, shape: Shape4D, colexicographic: boolean, clbk: Callback4D, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a five-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 2, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 2, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array5D, shape: Shape5D, colexicographic: boolean, clbk: Callback5D, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a six-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 1, 2, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 1, 2, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array6D, shape: Shape6D, colexicographic: boolean, clbk: Callback6D, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a seven-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 1, 1, 2, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 1, 1, 2, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array7D, shape: Shape7D, colexicographic: boolean, clbk: Callback7D, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens an eight-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 1, 1, 1, 2, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 1, 1, 1, 2, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array8D, shape: Shape8D, colexicographic: boolean, clbk: Callback8D, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a nine-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array9D, shape: Shape9D, colexicographic: boolean, clbk: Callback9D, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a ten-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ] ] ]; - * - * var out = flattenBy( x, [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array10D, shape: Shape10D, colexicographic: boolean, clbk: Callback10D, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a one-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ 1, 2 ]; - * - * var out = flattenBy.assign( x, [ 2 ], false, new Float64Array( 2 ), 1, 0, scale ); - * // returns [ 2, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ 1, 2 ]; - * - * var out = flattenBy.assign( x, [ 2 ], true, new Float64Array( 2 ), 1, 0, scale ); - * // returns [ 2, 4 ] - */ - assign( x: Array1D, shape: Shape1D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback1D, thisArg?: ThisParameterType> ): Collection; - - /** - * Flattens a two-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flattenBy.assign( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flattenBy.assign( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array2D, shape: Shape2D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback2D, thisArg?: ThisParameterType> ): Collection; - - /** - * Flattens a three-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array3D, shape: Shape3D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback3D, thisArg?: ThisParameterType> ): Collection; - - /** - * Flattens a four-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array4D, shape: Shape4D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback4D, thisArg?: ThisParameterType> ): Collection; - - /** - * Flattens a five-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array5D, shape: Shape5D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback5D, thisArg?: ThisParameterType> ): Collection; - - /** - * Flattens a six-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 1, 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 1, 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array6D, shape: Shape6D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback6D, thisArg?: ThisParameterType> ): Collection; - - /** - * Flattens a seven-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 1, 1, 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 1, 1, 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array7D, shape: Shape7D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback7D, thisArg?: ThisParameterType> ): Collection; - - /** - * Flattens an eight-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 1, 1, 1, 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 1, 1, 1, 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array8D, shape: Shape8D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback8D, thisArg?: ThisParameterType> ): Collection; - - /** - * Flattens a nine-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array9D, shape: Shape9D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback9D, thisArg?: ThisParameterType> ): Collection; - - /** - * Flattens a ten-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ] ] ] ] ]; - * - * var out = flattenBy.assign( x, [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array10D, shape: Shape10D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback10D, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Flattens an n-dimensional nested array according to a callback function. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param x - input array -* @param shape - array shape -* @param colexicographic - specifies whether to flatten array values in colexicographic order -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns flattened array -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flattenBy( x, [ 2, 2 ], false, scale ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flattenBy( x, [ 2, 2 ], true, scale ); -* // returns [ 1, 3, 2, 4 ] -*/ -declare var flattenBy: FlattenBy; - - -// EXPORTS // - -export = flattenBy; diff --git a/base/flatten-by/docs/types/test.ts b/base/flatten-by/docs/types/test.ts deleted file mode 100644 index fe3bccd14..000000000 --- a/base/flatten-by/docs/types/test.ts +++ /dev/null @@ -1,340 +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. -*/ - -import flattenBy = require( './index' ); - -/** -* Identity function. -* -* @param value - input value -* @returns input value -*/ -function identity( value: T ): T { - return value; -} - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flattenBy( x, [ 2, 2 ], false, identity ); // $ExpectType number[] - flattenBy( x, [ 2, 2 ], true, identity ); // $ExpectType number[] - - flattenBy( x, [ 2, 2 ], false, identity, {} ); // $ExpectType number[] - flattenBy( x, [ 2, 2 ], true, identity, {} ); // $ExpectType number[] - - flattenBy( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false, identity ); // $ExpectType string[] - flattenBy( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true, identity ); // $ExpectType string[] - - flattenBy( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false, identity, {} ); // $ExpectType string[] - flattenBy( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true, identity, {} ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - flattenBy( 1, [ 2, 2 ], false, identity ); // $ExpectError - flattenBy( true, [ 2, 2 ], false, identity ); // $ExpectError - flattenBy( false, [ 2, 2 ], false, identity ); // $ExpectError - flattenBy( null, [ 2, 2 ], false, identity ); // $ExpectError - flattenBy( void 0, [ 2, 2 ], false, identity ); // $ExpectError - flattenBy( {}, [ 2, 2 ], false, identity ); // $ExpectError - - flattenBy( 1, [ 2, 2 ], false, identity, {} ); // $ExpectError - flattenBy( true, [ 2, 2 ], false, identity, {} ); // $ExpectError - flattenBy( false, [ 2, 2 ], false, identity, {} ); // $ExpectError - flattenBy( null, [ 2, 2 ], false, identity, {} ); // $ExpectError - flattenBy( void 0, [ 2, 2 ], false, identity, {} ); // $ExpectError - flattenBy( {}, [ 2, 2 ], false, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flattenBy( x, '', false, identity ); // $ExpectError - flattenBy( x, 1, false, identity ); // $ExpectError - flattenBy( x, true, false, identity ); // $ExpectError - flattenBy( x, false, false, identity ); // $ExpectError - flattenBy( x, null, false, identity ); // $ExpectError - flattenBy( x, void 0, false, identity ); // $ExpectError - flattenBy( x, {}, false, identity ); // $ExpectError - flattenBy( x, [ 1, '2', 3 ], false, identity ); // $ExpectError - flattenBy( x, ( x: number ): number => x, false, identity ); // $ExpectError - - flattenBy( x, '', false, identity, {} ); // $ExpectError - flattenBy( x, 1, false, identity, {} ); // $ExpectError - flattenBy( x, true, false, identity, {} ); // $ExpectError - flattenBy( x, false, false, identity, {} ); // $ExpectError - flattenBy( x, null, false, identity, {} ); // $ExpectError - flattenBy( x, void 0, false, identity, {} ); // $ExpectError - flattenBy( x, {}, false, identity, {} ); // $ExpectError - flattenBy( x, [ 1, '2', 3 ], false, identity, {} ); // $ExpectError - flattenBy( x, ( x: number ): number => x, false, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flattenBy( x, [ 2, 2 ], '', identity ); // $ExpectError - flattenBy( x, [ 2, 2 ], 1, identity ); // $ExpectError - flattenBy( x, [ 2, 2 ], null, identity ); // $ExpectError - flattenBy( x, [ 2, 2 ], void 0, identity ); // $ExpectError - flattenBy( x, [ 2, 2 ], {}, identity ); // $ExpectError - flattenBy( x, [ 2, 2 ], [], identity ); // $ExpectError - flattenBy( x, [ 2, 2 ], ( x: number ): number => x, identity ); // $ExpectError - - flattenBy( x, [ 2, 2 ], '', identity, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], 1, identity, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], null, identity, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], void 0, identity, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], {}, identity, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], [], identity, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], ( x: number ): number => x, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a function... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flattenBy( x, [ 2, 2 ], false, '' ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, 1 ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, true ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, false ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, null ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, void 0 ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, [] ); // $ExpectError - - flattenBy( x, [ 2, 2 ], false, '', {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, 1, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, true, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, false, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, null, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, void 0, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, {}, {} ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flattenBy(); // $ExpectError - flattenBy( x ); // $ExpectError - flattenBy( x, [ 2, 2 ] ); // $ExpectError - flattenBy( x, [ 2, 2 ], false ); // $ExpectError - flattenBy( x, [ 2, 2 ], false, identity, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - const out1 = [ 0, 0, 0, 0 ]; - - flattenBy.assign( x, [ 2, 2 ], false, out1, 1, 0, identity ); // $ExpectType Collection - flattenBy.assign( x, [ 2, 2 ], true, out1, 1, 0, identity ); // $ExpectType Collection - - flattenBy.assign( x, [ 2, 2 ], false, out1, 1, 0, identity, {} ); // $ExpectType Collection - flattenBy.assign( x, [ 2, 2 ], true, out1, 1, 0, identity, {} ); // $ExpectType Collection - - const out2 = [ '', '', '', '' ]; - - flattenBy.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false, out2, 1, 0, identity ); // $ExpectType Collection - flattenBy.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true, out2, 1, 0, identity ); // $ExpectType Collection - - flattenBy.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false, out2, 1, 0, identity, {} ); // $ExpectType Collection - flattenBy.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true, out2, 1, 0, identity, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - flattenBy.assign( 1, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( true, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( false, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( null, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( void 0, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( {}, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - - flattenBy.assign( 1, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( true, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( false, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( null, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( void 0, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( {}, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flattenBy.assign( x, '', false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, 1, false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, true, false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, false, false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, null, false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, void 0, false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, {}, false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 1, '2', 3 ], false, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, ( x: number ): number => x, false, out, 1, 0, identity ); // $ExpectError - - flattenBy.assign( x, '', false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, 1, false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, true, false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, false, false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, null, false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, void 0, false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, {}, false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 1, '2', 3 ], false, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, ( x: number ): number => x, false, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a boolean... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flattenBy.assign( x, [ 2, 2 ], '', out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], 1, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], null, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], void 0, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], {}, out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], [], out, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], ( x: number ): number => x, out, 1, 0, identity ); // $ExpectError - - flattenBy.assign( x, [ 2, 2 ], '', out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], 1, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], null, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], void 0, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], {}, out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], [], out, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], ( x: number ): number => x, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flattenBy.assign( x, [ 2, 2 ], false, 1, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, true, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, false, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, null, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, void 0, 1, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, {}, 1, 0, identity ); // $ExpectError - - flattenBy.assign( x, [ 2, 2 ], false, 1, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, true, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, false, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, null, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, void 0, 1, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, {}, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flattenBy.assign( x, [ 2, 2 ], false, out, '1', 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, true, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, false, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, null, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, void 0, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, {}, 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, [], 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, ( x: number ): number => x, 0, identity ); // $ExpectError - - flattenBy.assign( x, [ 2, 2 ], false, out, '1', 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, true, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, false, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, null, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, void 0, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, {}, 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, [], 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, ( x: number ): number => x, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flattenBy.assign( x, [ 2, 2 ], false, out, 1, '1', identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, true, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, false, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, null, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, void 0, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, {}, identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, [], identity ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, ( x: number ): number => x, identity ); // $ExpectError - - flattenBy.assign( x, [ 2, 2 ], false, out, 1, '1', identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, true, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, false, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, null, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, void 0, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, {}, identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, [], identity, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, ( x: number ): number => x, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a seventh argument which is not a function... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, '1' ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, 1 ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, true ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, false ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, null ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, void 0 ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, [] ); // $ExpectError - - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, '1', {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, 1, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, true, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, false, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, null, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, void 0, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, {}, {} ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, [], {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flattenBy.assign(); // $ExpectError - flattenBy.assign( x ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ] ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1 ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flattenBy.assign( x, [ 2, 2 ], false, out, 1, 0, identity, {}, {} ); // $ExpectError -} diff --git a/base/flatten-by/examples/index.js b/base/flatten-by/examples/index.js deleted file mode 100644 index a668b2861..000000000 --- a/base/flatten-by/examples/index.js +++ /dev/null @@ -1,85 +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'; - -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flattenBy = require( './../lib' ); - -var fcn = naryFunction( abs, 1 ); - -// Define a 2x2x1x2x2 array: -var x = [ - [ - [ - [ - [ -1, -2 ], [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], [ -15, -16 ] - ] - ] - ] -]; - -var out = flattenBy( x, [ 0, 0, 0, 0, 0 ], false, fcn ); -console.log( out ); -// => [] - -out = flattenBy( x, [ 0, 0, 0, 0, 0 ], true, fcn ); -console.log( out ); -// => [] - -out = flattenBy( x, [ 1, 1, 1, 1, 1 ], false, fcn ); -console.log( out ); -// => [ 1 ] - -out = flattenBy( x, [ 1, 1, 1, 1, 1 ], true, fcn ); -console.log( out ); -// => [ 1 ] - -out = flattenBy( x, [ 1, 2, 1, 2, 2 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flattenBy( x, [ 1, 2, 1, 2, 2 ], true, fcn ); -console.log( out ); -// => [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flattenBy( x, [ 2, 2, 1, 2, 2 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flattenBy( x, [ 2, 2, 1, 2, 2 ], true, fcn ); -console.log( out ); -// => [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] diff --git a/base/flatten-by/lib/assign.js b/base/flatten-by/lib/assign.js deleted file mode 100644 index c60c49cad..000000000 --- a/base/flatten-by/lib/assign.js +++ /dev/null @@ -1,230 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var vind2bind = require( '@stdlib/ndarray/base/vind2bind' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var grev = require( '@stdlib/blas/ext/base/grev' ); -var zeros = require( './../../../base/zeros' ); -var copy = require( './../../../base/copy-indexed' ); - - -// VARIABLES // - -var MODE = 'throw'; - - -// FUNCTIONS // - -/** -* Copies a specified number of array elements to a provided array according to a callback function. -* -* @private -* @param {Array} x - input array -* @param {NonNegativeInteger} N - number of elements to copy -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = [ 0, 0, 0 ]; -* copyBy( x, 3, out, 1, 0, scale ); -* -* var o = out; -* // returns [ 2, 4, 6 ] -*/ -function copyBy( x, N, out, stride, offset, clbk, thisArg ) { - var i; - for ( i = 0; i < N; i++ ) { - out[ offset ] = clbk.call( thisArg, x[ i ], [ i ], x ); - offset += stride; - } -} - -/** -* Recursively flattens an array in lexicographic order. -* -* @private -* @param {Array} orig - original input array -* @param {Array} x - array to flatten -* @param {NonNegativeInteger} ndims - number of dimensions in the input array -* @param {NonNegativeIntegerArray} shape - shape of the input array -* @param {NonNegativeInteger} dim - dimension index -* @param {NonNegativeIntegerArray} indices - outer array element indices -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {NonNegativeInteger} offset for next output array element -*/ -function recurseLexicographic( orig, x, ndims, shape, dim, indices, out, stride, offset, clbk, thisArg ) { // eslint-disable-line max-params - var FLG; - var idx; - var S; - var d; - var i; - - // Check whether we've reached the last dimension: - d = dim + 1; - FLG = ( d === ndims ); - - S = shape[ dim ]; - for ( i = 0; i < S; i++ ) { - idx = indices.slice(); // we explicitly copy in order to avoid potential mutation when calling `clbk` - idx.push( i ); - if ( FLG ) { - out[ offset ] = clbk.call( thisArg, x[ i ], idx, orig ); - offset += stride; - } else { - offset = recurseLexicographic( orig, x[ i ], ndims, shape, d, idx, out, stride, offset, clbk, thisArg ); - } - } - return offset; -} - -/** -* Flattens an array in colexicographic order. -* -* @private -* @param {Array} x - array to flatten -* @param {NonNegativeInteger} ndims - number of dimensions in the input array -* @param {NonNegativeIntegerArray} shape - shape of the input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -*/ -function flattenColexicographic( x, ndims, shape, out, stride, offset, clbk, thisArg ) { - var len; - var tmp; - var ord; - var sh; - var sx; - var j; - var i; - - // Note that, in contrast to lexicographic iteration, we cannot readily define a straightforward recursive definition for colexicographic iteration. Accordingly, we have to perform a workaround in which we first flatten in lexicographic order and then perform an out-of-place transposition to return an array in colexicographic order. - - // Determine how many elements will be in the output array: - len = numel( shape ); - - // For input arrays having an arbitrary number of dimensions, first flatten in lexicographic order: - tmp = zeros( len ); - recurseLexicographic( x, x, ndims, shape, 0, [], tmp, 1, 0, clbk, thisArg ); - - // Define the memory layout: - ord = 'row-major'; - - // Generate a stride array for lexicographic order: - sx = shape2strides( shape, ord ); - - // Reverse the dimensions and strides (i.e., define the shape and strides of the transpose): - sh = copy( shape ); - grev( ndims, sh, 1 ); - grev( ndims, sx, 1 ); - - // Iterate over each element based on the linear **view** index (note: this has negative performance implications due to lack of data locality)... - for ( i = 0; i < len; i++ ) { - j = vind2bind( sh, sx, 0, ord, i, MODE ); - out[ offset ] = tmp[ j ]; - offset += stride; - } -} - - -// MAIN // - -/** -* Flattens an n-dimensional nested array according to a callback function and assigns elements to a provided output array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flattenBy( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flattenBy( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -function flattenBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) { - var ndims = shape.length; - if ( ndims === 0 ) { // 0-dimensional array - return out; - } - if ( ndims === 1 ) { // 1-dimensional array - // For 1-dimensional arrays, we can perform simple iteration: - copyBy( x, shape[ 0 ], out, stride, offset, clbk, thisArg ); - return out; - } - if ( colexicographic ) { - flattenColexicographic( x, ndims, shape, out, stride, offset, clbk, thisArg ); - return out; - } - recurseLexicographic( x, x, ndims, shape, 0, [], out, stride, offset, clbk, thisArg ); - return out; -} - - -// EXPORTS // - -module.exports = flattenBy; diff --git a/base/flatten-by/lib/index.js b/base/flatten-by/lib/index.js deleted file mode 100644 index 2b89c7bed..000000000 --- a/base/flatten-by/lib/index.js +++ /dev/null @@ -1,82 +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'; - -/** -* Flatten an n-dimensional nested array according to a callback function. -* -* @module @stdlib/array/base/flatten-by -* -* @example -* var flattenBy = require( '@stdlib/array/base/flatten-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flattenBy( x, [ 2, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* var flattenBy = require( '@stdlib/array/base/flatten-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flattenBy( x, [ 2, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var flattenBy = require( '@stdlib/array/base/flatten-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = new Float64Array( 4 ); -* var y = flattenBy.assign( x, [ 2, 2 ], true, out, 1, 0, scale ); -* // returns [ 2, 6, 4, 8 ] -* -* var bool = ( y === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flatten-by/lib/main.js b/base/flatten-by/lib/main.js deleted file mode 100644 index e7a553ef9..000000000 --- a/base/flatten-by/lib/main.js +++ /dev/null @@ -1,72 +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 numel = require( '@stdlib/ndarray/base/numel' ); -var zeros = require( './../../../base/zeros' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Flattens an n-dimensional nested array according to a callback function. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Array} flattened array -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flattenBy( x, [ 2, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flattenBy( x, [ 2, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -function flattenBy( x, shape, colexicographic, clbk, thisArg ) { - var out = zeros( numel( shape ) ); - return assign( x, shape, colexicographic, out, 1, 0, clbk, thisArg ); -} - - -// EXPORTS // - -module.exports = flattenBy; diff --git a/base/flatten-by/package.json b/base/flatten-by/package.json deleted file mode 100644 index f565e54fc..000000000 --- a/base/flatten-by/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/flatten-by", - "version": "0.0.0", - "description": "Flatten an n-dimensional nested array according to a callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flatten", - "flat", - "tensor", - "matrix", - "strided", - "ndarray", - "multidimensional", - "foreach", - "map", - "transform", - "callback", - "accessor" - ] -} diff --git a/base/flatten-by/test/test.assign.js b/base/flatten-by/test/test.assign.js deleted file mode 100644 index fd56e1963..000000000 --- a/base/flatten-by/test/test.assign.js +++ /dev/null @@ -1,1103 +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 naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var Float64Array = require( './../../../float64' ); -var flattenBy = require( './../lib/assign.js' ); - - -// VARIABLES // - -var clbk = naryFunction( abs, 1 ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flattenBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens an array (0d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ -1, -2, -3, -4 ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens an array (1d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ -1, -2, -3, -4 ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 4 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 4 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 2d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2, -3, -4 ], - [ -5, -6, -7, -8 ], - [ -9, -10, -11, -12 ], - [ -13, -14, -15, -16 ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 1 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 1, 0 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flattenBy( x, [ 1, 1 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 1, 2 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 2, 1 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 2, 2 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 5, 6, 7 ] ); - out = new Float64Array( 6 ); - actual = flattenBy( x, [ 2, 3 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ] ); - out = new Float64Array( 9 ); - actual = flattenBy( x, [ 3, 3 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 4, 1 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 4, 2 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flattenBy( x, [ 4, 4 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 2d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2, -3, -4 ], - [ -5, -6, -7, -8 ], - [ -9, -10, -11, -12 ], - [ -13, -14, -15, -16 ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 1 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 1, 0 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flattenBy( x, [ 1, 1 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 1, 2 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 2, 1 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 2, 2 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6, 3, 7 ] ); - out = new Float64Array( 6 ); - actual = flattenBy( x, [ 2, 3 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ] ); - out = new Float64Array( 9 ); - actual = flattenBy( x, [ 3, 3 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 4, 1 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 4, 2 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flattenBy( x, [ 4, 4 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 3d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ], - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 1, 0, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flattenBy( x, [ 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 1, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 2, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 2, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] ); - out = new Float64Array( 12 ); - actual = flattenBy( x, [ 3, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 4, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 4, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flattenBy( x, [ 4, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 3d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ], - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 1, 0, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flattenBy( x, [ 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 1, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 2, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 2, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ] ); - out = new Float64Array( 12 ); - actual = flattenBy( x, [ 3, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 4, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 4, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flattenBy( x, [ 4, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 4d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ], - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 0, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 1, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 1, 0, 0, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flattenBy( x, [ 1, 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 1, 1, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 2, 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 1, 2, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 1, 2, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 2, 2, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 2, 2, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flattenBy( x, [ 2, 2, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 4d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ], - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 0, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 1, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 1, 0, 0, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flattenBy( x, [ 1, 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 1, 1, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 2, 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 1, 2, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 3, 7, 2, 6, 4, 8 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 1, 2, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 2, 2, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 2, 10, 6, 14 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 2, 2, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flattenBy( x, [ 2, 2, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 5d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 0, 0, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 1, 0, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 1, 0, 0, 1, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flattenBy( x, [ 1, 1, 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 1, 1, 1, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 2, 1, 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 1, 2, 1, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 1, 2, 1, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 2, 2, 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 2, 2, 1, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flattenBy( x, [ 2, 2, 1, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 5d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 0, 0, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 0, 0, 1, 0, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flattenBy( x, [ 1, 0, 0, 1, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flattenBy( x, [ 1, 1, 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 1, 1, 1, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flattenBy( x, [ 2, 1, 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 1, 2, 1, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 3, 7, 2, 6, 4, 8 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 1, 2, 1, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13 ] ); - out = new Float64Array( 4 ); - actual = flattenBy( x, [ 2, 2, 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 2, 10, 6, 14 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 2, 2, 1, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flattenBy( x, [ 2, 2, 1, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (lexicographic; 1d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ -1, -2, -3, -4 ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 4 ], false, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (colexicographic; 1d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ -1, -2, -3, -4 ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 4 ], true, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (lexicographic; >1d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 2, 2 ], false, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (colexicographic; >1d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 1, 0, 3, 0, 2, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 2, 2 ], true, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (lexicographic; 1d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ -1, -2, -3, -4 ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 4 ], false, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (colexicographic; 1d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ -1, -2, -3, -4 ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 4 ], true, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (lexicographic; >1d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 2, 2 ], false, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (colexicographic; >1d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 3, 2, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 2, 2 ], true, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 3, 0, 2, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 2, 2 ], false, out, -2, 7, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 2, 0, 3, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flattenBy( x, [ 2, 2 ], true, out, -2, 7, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports setting the callback execution context (lexicographic; 1d)', function test( t ) { - var ctx; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flattenBy( x, [ 4 ], false, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 1, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic; 1d)', function test( t ) { - var ctx; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flattenBy( x, [ 4 ], true, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 1, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (lexicographic; >1d)', function test( t ) { - var ctx; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flattenBy( x, [ 2, 2 ], false, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 2, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic; >1d)', function test( t ) { - var ctx; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flattenBy( x, [ 2, 2 ], true, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 2, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); diff --git a/base/flatten-by/test/test.js b/base/flatten-by/test/test.js deleted file mode 100644 index cb32fec73..000000000 --- a/base/flatten-by/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var flattenBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flattenBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( flattenBy, 'assign' ), true, 'has property' ); - t.strictEqual( typeof flattenBy.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/flatten-by/test/test.main.js b/base/flatten-by/test/test.main.js deleted file mode 100644 index 2b3e88995..000000000 --- a/base/flatten-by/test/test.main.js +++ /dev/null @@ -1,774 +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 naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flattenBy = require( './../lib/main.js' ); - - -// VARIABLES // - -var clbk = naryFunction( abs, 1 ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flattenBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens an array (0d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ -1, -2, -3, -4 ]; - - expected = []; - actual = flattenBy( x, [], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens an array (1d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ -1, -2, -3, -4 ]; - - expected = []; - actual = flattenBy( x, [ 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flattenBy( x, [ 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - actual = flattenBy( x, [ 4 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flattenBy( x, [ 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - actual = flattenBy( x, [ 4 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 2d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ -1, -2, -3, -4 ], - [ -5, -6, -7, -8 ], - [ -9, -10, -11, -12 ], - [ -13, -14, -15, -16 ] - ]; - - expected = []; - actual = flattenBy( x, [ 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 0, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 1, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flattenBy( x, [ 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flattenBy( x, [ 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flattenBy( x, [ 2, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flattenBy( x, [ 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 5, 6, 7 ]; - actual = flattenBy( x, [ 2, 3 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ]; - actual = flattenBy( x, [ 3, 3 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flattenBy( x, [ 4, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flattenBy( x, [ 4, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flattenBy( x, [ 4, 4 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 2d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ -1, -2, -3, -4 ], - [ -5, -6, -7, -8 ], - [ -9, -10, -11, -12 ], - [ -13, -14, -15, -16 ] - ]; - - expected = []; - actual = flattenBy( x, [ 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 0, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 1, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flattenBy( x, [ 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flattenBy( x, [ 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flattenBy( x, [ 2, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flattenBy( x, [ 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6, 3, 7 ]; - actual = flattenBy( x, [ 2, 3 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ]; - actual = flattenBy( x, [ 3, 3 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flattenBy( x, [ 4, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14 ]; - actual = flattenBy( x, [ 4, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ]; - actual = flattenBy( x, [ 4, 4 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 3d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ], - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ]; - - expected = []; - actual = flattenBy( x, [ 0, 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 0, 0, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 1, 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flattenBy( x, [ 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flattenBy( x, [ 1, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flattenBy( x, [ 2, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flattenBy( x, [ 2, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]; - actual = flattenBy( x, [ 3, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flattenBy( x, [ 4, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flattenBy( x, [ 4, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flattenBy( x, [ 4, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 3d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ], - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ]; - - expected = []; - actual = flattenBy( x, [ 0, 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 0, 0, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 1, 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flattenBy( x, [ 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flattenBy( x, [ 1, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flattenBy( x, [ 2, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flattenBy( x, [ 2, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ]; - actual = flattenBy( x, [ 3, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flattenBy( x, [ 4, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14 ]; - actual = flattenBy( x, [ 4, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ]; - actual = flattenBy( x, [ 4, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 4d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ], - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ]; - - expected = []; - actual = flattenBy( x, [ 0, 0, 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 0, 0, 1, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 1, 0, 0, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flattenBy( x, [ 1, 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flattenBy( x, [ 1, 1, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flattenBy( x, [ 2, 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flattenBy( x, [ 1, 2, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = flattenBy( x, [ 1, 2, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flattenBy( x, [ 2, 2, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flattenBy( x, [ 2, 2, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flattenBy( x, [ 2, 2, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 4d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ], - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ]; - - expected = []; - actual = flattenBy( x, [ 0, 0, 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 0, 0, 1, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 1, 0, 0, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flattenBy( x, [ 1, 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flattenBy( x, [ 1, 1, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flattenBy( x, [ 2, 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flattenBy( x, [ 1, 2, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 3, 7, 2, 6, 4, 8 ]; - actual = flattenBy( x, [ 1, 2, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13 ]; - actual = flattenBy( x, [ 2, 2, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 2, 10, 6, 14 ]; - actual = flattenBy( x, [ 2, 2, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ]; - actual = flattenBy( x, [ 2, 2, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 5d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ] - ]; - - expected = []; - actual = flattenBy( x, [ 0, 0, 0, 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 0, 0, 1, 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 1, 0, 0, 1, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flattenBy( x, [ 1, 1, 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flattenBy( x, [ 1, 1, 1, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flattenBy( x, [ 2, 1, 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flattenBy( x, [ 1, 2, 1, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = flattenBy( x, [ 1, 2, 1, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flattenBy( x, [ 2, 2, 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flattenBy( x, [ 2, 2, 1, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flattenBy( x, [ 2, 2, 1, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 5d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ] - ]; - - expected = []; - actual = flattenBy( x, [ 0, 0, 0, 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 0, 0, 1, 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flattenBy( x, [ 1, 0, 0, 1, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flattenBy( x, [ 1, 1, 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flattenBy( x, [ 1, 1, 1, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flattenBy( x, [ 2, 1, 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flattenBy( x, [ 1, 2, 1, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 3, 7, 2, 6, 4, 8 ]; - actual = flattenBy( x, [ 1, 2, 1, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13 ]; - actual = flattenBy( x, [ 2, 2, 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 2, 10, 6, 14 ]; - actual = flattenBy( x, [ 2, 2, 1, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ]; - actual = flattenBy( x, [ 2, 2, 1, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports setting the callback execution context (lexicographic; 1d)', function test( t ) { - var ctx; - var x; - - x = [ 1, 2, 3, 4 ]; - - ctx = { - 'count': 0 - }; - - flattenBy( x, [ 4 ], false, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 1, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic; 1d)', function test( t ) { - var ctx; - var x; - - x = [ 1, 2, 3, 4 ]; - - ctx = { - 'count': 0 - }; - - flattenBy( x, [ 4 ], true, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 1, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (lexicographic; >1d)', function test( t ) { - var ctx; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - ctx = { - 'count': 0 - }; - - flattenBy( x, [ 2, 2 ], false, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 2, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic; >1d)', function test( t ) { - var ctx; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - ctx = { - 'count': 0 - }; - - flattenBy( x, [ 2, 2 ], true, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 2, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); diff --git a/base/flatten/README.md b/base/flatten/README.md deleted file mode 100644 index efe2ff26a..000000000 --- a/base/flatten/README.md +++ /dev/null @@ -1,179 +0,0 @@ - - -# flatten - -> Flatten an n-dimensional nested array. - -
- -## Usage - -```javascript -var flatten = require( '@stdlib/array/base/flatten' ); -``` - -#### flatten( x, shape, colexicographic ) - -Flattens an n-dimensional nested array. - -```javascript -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var out = flatten( x, [ 2, 2 ], false ); -// returns [ 1, 2, 3, 4 ] -``` - -To flatten in colexicographic order, provide a third argument equal to `true`. - -```javascript -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var out = flatten( x, [ 2, 2 ], true ); -// returns [ 1, 3, 2, 4 ] -``` - -#### flatten.assign( x, shape, colexicographic, out, stride, offset ) - -Flattens an n-dimensional nested array and assigns elements to a provided output array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var x = [ [ 1, 2 ], [ 3, 4 ] ]; -var out = new Float64Array( 4 ); - -var y = flatten.assign( x, [ 2, 2 ], false, out, 1, 0 ); -// returns [ 1, 2, 3, 4 ] - -var bool = ( y === out ); -// returns true - -y = flatten.assign( x, [ 2, 2 ], true, out, 1, 0 ); -// returns [ 1, 3, 2, 4 ] -``` - -
- - - -
- -## Notes - -- Both functions assume that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - -
- - - -
- -## Examples - - - -```javascript -var flatten = require( '@stdlib/array/base/flatten' ); - -// Define a 2x2x1x2x2 array: -var x = [ - [ - [ - [ - [ 1, 2 ], [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], [ 15, 16 ] - ] - ] - ] -]; - -var out = flatten( x, [ 0, 0, 0, 0, 0 ], false ); -// returns [] - -out = flatten( x, [ 0, 0, 0, 0, 0 ], true ); -// returns [] - -out = flatten( x, [ 1, 1, 1, 1, 1 ], false ); -// returns [ 1 ] - -out = flatten( x, [ 1, 1, 1, 1, 1 ], true ); -// returns [ 1 ] - -out = flatten( x, [ 1, 2, 1, 2, 2 ], false ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten( x, [ 1, 2, 1, 2, 2 ], true ); -// returns [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten( x, [ 2, 2, 1, 2, 2 ], false ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten( x, [ 2, 2, 1, 2, 2 ], true ); -// returns [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/flatten/benchmark/benchmark.js b/base/flatten/benchmark/benchmark.js deleted file mode 100644 index 69f56151c..000000000 --- a/base/flatten/benchmark/benchmark.js +++ /dev/null @@ -1,401 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var zeroTo = require( './../../../base/zero-to' ); -var filled = require( './../../../base/filled' ); -var Float64Array = require( './../../../float64' ); -var pkg = require( './../package.json' ).name; -var flatten = require( './../lib' ); - - -// MAIN // - -bench( pkg+':ndims=2,size=100,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten( x, [ 10, 10 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=2,size=100,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten( x, [ 10, 10 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=2,size=100,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 100 ); - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten.assign( x, [ 10, 10 ], false, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=2,size=100,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 100 ); - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten.assign( x, [ 10, 10 ], true, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=3,size=125,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten( x, [ 5, 5, 5 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=3,size=125,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten( x, [ 5, 5, 5 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=3,size=125,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 125 ); - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten.assign( x, [ 5, 5, 5 ], false, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=3,size=125,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 125 ); - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten.assign( x, [ 5, 5, 5 ], true, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=4,size=144,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten( x, [ 4, 3, 4, 3 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=4,size=144,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten( x, [ 4, 3, 4, 3 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=4,size=144,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 144 ); - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten.assign( x, [ 4, 3, 4, 3 ], false, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=4,size=144,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 144 ); - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten.assign( x, [ 4, 3, 4, 3 ], true, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=5,size=108,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten( x, [ 2, 2, 3, 3, 3 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=5,size=108,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten( x, [ 2, 2, 3, 3, 3 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=5,size=108,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 108 ); - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten.assign( x, [ 2, 2, 3, 3, 3 ], false, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:ndims=5,size=108,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 108 ); - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten.assign( x, [ 2, 2, 3, 3, 3 ], true, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/flatten/docs/repl.txt b/base/flatten/docs/repl.txt deleted file mode 100644 index 5a284fb7c..000000000 --- a/base/flatten/docs/repl.txt +++ /dev/null @@ -1,80 +0,0 @@ - -{{alias}}( x, shape, colexicographic ) - Flattens an n-dimensional nested array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colexicographic: boolean - Specifies whether to flatten array values in colexicographic order. - - Returns - ------- - out: Array - Flattened array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var out = {{alias}}( x, [ 2, 2 ], false ) - [ 1, 2, 3, 4 ] - > out = {{alias}}( x, [ 2, 2 ], true ) - [ 1, 3, 2, 4 ] - - -{{alias}}.assign( x, shape, colexicographic, out, stride, offset ) - Flattens an n-dimensional nested array and assigns elements to a provided - output array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colexicographic: boolean - Specifies whether to flatten array values in colexicographic order. - - out: Collection - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var out = [ 0, 0, 0, 0 ]; - > var v = {{alias}}.assign( x, [ 2, 2 ], false, out, 1, 0 ) - [ 1, 2, 3, 4 ] - > var bool = ( v === out ) - true - > out = [ 0, 0, 0, 0 ]; - > {{alias}}.assign( x, [ 2, 2 ], true, out, 1, 0 ); - > out - [ 1, 3, 2, 4 ] - - See Also - -------- - diff --git a/base/flatten/docs/types/index.d.ts b/base/flatten/docs/types/index.d.ts deleted file mode 100644 index f1c3c07fb..000000000 --- a/base/flatten/docs/types/index.d.ts +++ /dev/null @@ -1,124 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Array1D, Array2D, Array3D, Array4D, Array5D, Array6D, Array7D, Array8D, Array9D, Array10D } from '@stdlib/types/array'; -import { Shape } from '@stdlib/types/ndarray'; - -/** -* n-dimensional nested array. -*/ -type ArrayND = Array1D | Array2D | Array3D | Array4D | Array5D | Array6D | Array7D | Array8D | Array9D | Array10D; // WARNING: arbitrarily limited to 10 dimensions, which should be fine for most practical purposes - -/** -* Interface describing `flatten`. -*/ -interface Flatten { - /** - * Flattens an n-dimensional nested array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @returns flattened array - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten( x, [ 2, 2 ], false ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten( x, [ 2, 2 ], true ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: ArrayND, shape: Shape, colexicographic: boolean ): Array; - - /** - * Flattens an n-dimensional nested array and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten.assign( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0 ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten.assign( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0 ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: ArrayND, shape: Shape, colexicographic: boolean, out: Collection, stride: number, offset: number ): Collection; -} - -/** -* Flattens an n-dimensional nested array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param x - input array -* @param shape - array shape -* @param colexicographic - specifies whether to flatten array values in colexicographic order -* @returns flattened array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten( x, [ 2, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten( x, [ 2, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -*/ -declare var flatten: Flatten; - - -// EXPORTS // - -export = flatten; diff --git a/base/flatten/docs/types/test.ts b/base/flatten/docs/types/test.ts deleted file mode 100644 index 0e13bd41a..000000000 --- a/base/flatten/docs/types/test.ts +++ /dev/null @@ -1,194 +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. -*/ - -import flatten = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten( x, [ 2, 2 ], false ); // $ExpectType number[] - flatten( x, [ 2, 2 ], true ); // $ExpectType number[] - - flatten( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false ); // $ExpectType string[] - flatten( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - flatten( 1, [ 2, 2 ], false ); // $ExpectError - flatten( true, [ 2, 2 ], false ); // $ExpectError - flatten( false, [ 2, 2 ], false ); // $ExpectError - flatten( null, [ 2, 2 ], false ); // $ExpectError - flatten( void 0, [ 2, 2 ], false ); // $ExpectError - flatten( {}, [ 2, 2 ], false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten( x, '', false ); // $ExpectError - flatten( x, 1, false ); // $ExpectError - flatten( x, true, false ); // $ExpectError - flatten( x, false, false ); // $ExpectError - flatten( x, null, false ); // $ExpectError - flatten( x, void 0, false ); // $ExpectError - flatten( x, {}, false ); // $ExpectError - flatten( x, [ 1, '2', 3 ], false ); // $ExpectError - flatten( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten( x, [ 2, 2 ], '' ); // $ExpectError - flatten( x, [ 2, 2 ], 1 ); // $ExpectError - flatten( x, [ 2, 2 ], null ); // $ExpectError - flatten( x, [ 2, 2 ], void 0 ); // $ExpectError - flatten( x, [ 2, 2 ], {} ); // $ExpectError - flatten( x, [ 2, 2 ], [] ); // $ExpectError - flatten( x, [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten(); // $ExpectError - flatten( x ); // $ExpectError - flatten( x, [ 2, 2 ] ); // $ExpectError - flatten( x, [ 2, 2 ], false, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - const out1 = [ 0, 0, 0, 0 ]; - - flatten.assign( x, [ 2, 2 ], false, out1, 1, 0 ); // $ExpectType Collection - flatten.assign( x, [ 2, 2 ], true, out1, 1, 0 ); // $ExpectType Collection - - const out2 = [ '', '', '', '' ]; - - flatten.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false, out2, 1, 0 ); // $ExpectType Collection - flatten.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true, out2, 1, 0 ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - flatten.assign( 1, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flatten.assign( true, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flatten.assign( false, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flatten.assign( null, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flatten.assign( void 0, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flatten.assign( {}, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten.assign( x, '', false, out, 1, 0 ); // $ExpectError - flatten.assign( x, 1, false, out, 1, 0 ); // $ExpectError - flatten.assign( x, true, false, out, 1, 0 ); // $ExpectError - flatten.assign( x, false, false, out, 1, 0 ); // $ExpectError - flatten.assign( x, null, false, out, 1, 0 ); // $ExpectError - flatten.assign( x, void 0, false, out, 1, 0 ); // $ExpectError - flatten.assign( x, {}, false, out, 1, 0 ); // $ExpectError - flatten.assign( x, [ 1, '2', 3 ], false, out, 1, 0 ); // $ExpectError - flatten.assign( x, ( x: number ): number => x, false, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a boolean... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten.assign( x, [ 2, 2 ], '', out, 1, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], 1, out, 1, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], null, out, 1, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], void 0, out, 1, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], {}, out, 1, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], [], out, 1, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], ( x: number ): number => x, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten.assign( x, [ 2, 2 ], false, 1, 1, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, true, 1, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, false, 1, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, null, 1, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, void 0, 1, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten.assign( x, [ 2, 2 ], false, out, '1', 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, true, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, false, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, null, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, void 0, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, {}, 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, [], 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten.assign( x, [ 2, 2 ], false, out, 1, '1' ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, 1, true ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, 1, false ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, 1, null ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, 1, void 0 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, 1, {} ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, 1, [] ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten.assign(); // $ExpectError - flatten.assign( x ); // $ExpectError - flatten.assign( x, [ 2, 2 ] ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, 1 ); // $ExpectError - flatten.assign( x, [ 2, 2 ], false, out, 1, 0, {} ); // $ExpectError -} diff --git a/base/flatten/examples/index.js b/base/flatten/examples/index.js deleted file mode 100644 index 2d5a953fc..000000000 --- a/base/flatten/examples/index.js +++ /dev/null @@ -1,81 +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'; - -var flatten = require( './../lib' ); - -// Define a 2x2x1x2x2 array: -var x = [ - [ - [ - [ - [ 1, 2 ], [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], [ 15, 16 ] - ] - ] - ] -]; - -var out = flatten( x, [ 0, 0, 0, 0, 0 ], false ); -console.log( out ); -// => [] - -out = flatten( x, [ 0, 0, 0, 0, 0 ], true ); -console.log( out ); -// => [] - -out = flatten( x, [ 1, 1, 1, 1, 1 ], false ); -console.log( out ); -// => [ 1 ] - -out = flatten( x, [ 1, 1, 1, 1, 1 ], true ); -console.log( out ); -// => [ 1 ] - -out = flatten( x, [ 1, 2, 1, 2, 2 ], false ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten( x, [ 1, 2, 1, 2, 2 ], true ); -console.log( out ); -// => [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten( x, [ 2, 2, 1, 2, 2 ], false ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten( x, [ 2, 2, 1, 2, 2 ], true ); -console.log( out ); -// => [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] diff --git a/base/flatten/lib/assign.js b/base/flatten/lib/assign.js deleted file mode 100644 index af14f7617..000000000 --- a/base/flatten/lib/assign.js +++ /dev/null @@ -1,203 +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 shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var vind2bind = require( '@stdlib/ndarray/base/vind2bind' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var grev = require( '@stdlib/blas/ext/base/grev' ); -var zeros = require( './../../../base/zeros' ); - - -// VARIABLES // - -var MODE = 'throw'; - - -// FUNCTIONS // - -/** -* Copies a specified number of array elements to a provided array. -* -* @private -* @param {Array} x - input array -* @param {NonNegativeInteger} N - number of elements to copy -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = [ 0, 0, 0 ]; -* copy( x, 3, out, 1, 0 ); -* -* var o = out; -* // returns [ 1, 2, 3 ] -*/ -function copy( x, N, out, stride, offset ) { - var i; - for ( i = 0; i < N; i++ ) { - out[ offset ] = x[ i ]; - offset += stride; - } -} - -/** -* Recursively flattens an array in lexicographic order. -* -* @private -* @param {Array} x - array to flatten -* @param {NonNegativeInteger} ndims - number of dimensions in the input array -* @param {NonNegativeIntegerArray} shape - shape of the input array -* @param {NonNegativeInteger} dim - dimension index -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {NonNegativeInteger} offset for next output array element -*/ -function recurseLexicographic( x, ndims, shape, dim, out, stride, offset ) { - var FLG; - var S; - var d; - var i; - - // Check whether we've reached the last dimension: - d = dim + 1; - FLG = ( d === ndims ); - - S = shape[ dim ]; - for ( i = 0; i < S; i++ ) { - if ( FLG ) { - out[ offset ] = x[ i ]; - offset += stride; - } else { - offset = recurseLexicographic( x[ i ], ndims, shape, d, out, stride, offset ); // eslint-disable-line max-len - } - } - return offset; -} - -/** -* Flattens an array in colexicographic order. -* -* @private -* @param {Array} x - array to flatten -* @param {NonNegativeInteger} ndims - number of dimensions in the input array -* @param {NonNegativeIntegerArray} shape - shape of the input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -*/ -function flattenColexicographic( x, ndims, shape, out, stride, offset ) { - var len; - var tmp; - var ord; - var sh; - var sx; - var j; - var i; - - // Note that, in contrast to lexicographic iteration, we cannot readily define a straightforward recursive definition for colexicographic iteration. Accordingly, we have to perform a workaround in which we first flatten in lexicographic order and then perform an out-of-place transposition to return an array in colexicographic order. - - // Determine how many elements will be in the output array: - len = numel( shape ); - - // For input arrays having an arbitrary number of dimensions, first flatten in lexicographic order: - tmp = zeros( len ); - recurseLexicographic( x, ndims, shape, 0, tmp, 1, 0 ); - - // Define the memory layout: - ord = 'row-major'; - - // Generate a stride array for lexicographic order: - sx = shape2strides( shape, ord ); - - // Reverse the dimensions and strides (i.e., define the shape and strides of the transpose): - sh = zeros( ndims ); - copy( shape, ndims, sh, 1, 0 ); - grev( ndims, sh, 1 ); - grev( ndims, sx, 1 ); - - // Iterate over each element based on the linear **view** index (note: this has negative performance implications due to lack of data locality)... - for ( i = 0; i < len; i++ ) { - j = vind2bind( sh, sx, 0, ord, i, MODE ); - out[ offset ] = tmp[ j ]; - offset += stride; - } -} - - -// MAIN // - -/** -* Flattens an n-dimensional nested array and assigns elements to a provided output array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0 ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0 ); -* // returns [ 1, 3, 2, 4 ] -*/ -function flatten( x, shape, colexicographic, out, stride, offset ) { - var ndims = shape.length; - if ( ndims === 0 ) { // 0-dimensional array - return out; - } - if ( ndims === 1 ) { // 1-dimensional array - // For 1-dimensional arrays, we can perform a simple copy: - copy( x, shape[ 0 ], out, stride, offset ); - return out; - } - if ( colexicographic ) { - flattenColexicographic( x, ndims, shape, out, stride, offset ); - return out; - } - recurseLexicographic( x, ndims, shape, 0, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/base/flatten/lib/index.js b/base/flatten/lib/index.js deleted file mode 100644 index 12f41b860..000000000 --- a/base/flatten/lib/index.js +++ /dev/null @@ -1,70 +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'; - -/** -* Flatten an n-dimensional nested array. -* -* @module @stdlib/array/base/flatten -* -* @example -* var flatten = require( '@stdlib/array/base/flatten' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten( x, [ 2, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var flatten = require( '@stdlib/array/base/flatten' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten( x, [ 2, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var flatten = require( '@stdlib/array/base/flatten' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = new Float64Array( 4 ); -* var y = flatten.assign( x, [ 2, 2 ], true, out, 1, 0 ); -* // returns [ 1, 3, 2, 4 ] -* -* var bool = ( y === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flatten/lib/main.js b/base/flatten/lib/main.js deleted file mode 100644 index 5e2e216d9..000000000 --- a/base/flatten/lib/main.js +++ /dev/null @@ -1,62 +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 numel = require( '@stdlib/ndarray/base/numel' ); -var zeros = require( './../../../base/zeros' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Flattens an n-dimensional nested array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @returns {Array} flattened array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten( x, [ 2, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten( x, [ 2, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -*/ -function flatten( x, shape, colexicographic ) { - var out = zeros( numel( shape ) ); - return assign( x, shape, colexicographic, out, 1, 0 ); -} - - -// EXPORTS // - -module.exports = flatten; diff --git a/base/flatten/package.json b/base/flatten/package.json deleted file mode 100644 index 76345db6f..000000000 --- a/base/flatten/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/flatten", - "version": "0.0.0", - "description": "Flatten an n-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flatten", - "flat", - "tensor", - "matrix", - "strided", - "ndarray", - "multidimensional" - ] -} diff --git a/base/flatten/test/test.assign.js b/base/flatten/test/test.assign.js deleted file mode 100644 index 6e32050bc..000000000 --- a/base/flatten/test/test.assign.js +++ /dev/null @@ -1,898 +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 Float64Array = require( './../../../float64' ); -var flatten = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens an array (0d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens an array (1d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 4 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 4 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 2d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ], - [ 13, 14, 15, 16 ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 1, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten( x, [ 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 2, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 5, 6, 7 ] ); - out = new Float64Array( 6 ); - actual = flatten( x, [ 2, 3 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ] ); - out = new Float64Array( 9 ); - actual = flatten( x, [ 3, 3 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 4, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 4, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten( x, [ 4, 4 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 2d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ], - [ 13, 14, 15, 16 ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 1, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten( x, [ 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 2, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6, 3, 7 ] ); - out = new Float64Array( 6 ); - actual = flatten( x, [ 2, 3 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ] ); - out = new Float64Array( 9 ); - actual = flatten( x, [ 3, 3 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 4, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 4, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten( x, [ 4, 4 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 3d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ], - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 1, 0, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten( x, [ 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 1, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 2, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 2, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] ); - out = new Float64Array( 12 ); - actual = flatten( x, [ 3, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 4, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 4, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten( x, [ 4, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 3d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ], - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 1, 0, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten( x, [ 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 1, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 2, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 2, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ] ); - out = new Float64Array( 12 ); - actual = flatten( x, [ 3, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 4, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 4, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten( x, [ 4, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 4d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ], - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 0, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 1, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 1, 0, 0, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten( x, [ 1, 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 1, 1, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 2, 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 1, 2, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 1, 2, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 2, 2, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 2, 2, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten( x, [ 2, 2, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 4d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ], - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 0, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 1, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 1, 0, 0, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten( x, [ 1, 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 1, 1, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 2, 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 1, 2, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 3, 7, 2, 6, 4, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 1, 2, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 2, 2, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 2, 10, 6, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 2, 2, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten( x, [ 2, 2, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 5d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 0, 0, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 1, 0, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 1, 0, 0, 1, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten( x, [ 1, 1, 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 1, 1, 1, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 2, 1, 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 1, 2, 1, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 1, 2, 1, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 2, 2, 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 2, 2, 1, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten( x, [ 2, 2, 1, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 5d)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 0, 0, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 0, 0, 1, 0, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten( x, [ 1, 0, 0, 1, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten( x, [ 1, 1, 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 1, 1, 1, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten( x, [ 2, 1, 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 1, 2, 1, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 3, 7, 2, 6, 4, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 1, 2, 1, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten( x, [ 2, 2, 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 2, 10, 6, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 2, 2, 1, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten( x, [ 2, 2, 1, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 2, 2 ], false, out, 2, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 1, 0, 3, 0, 2, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 2, 2 ], true, out, 2, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 2, 2 ], false, out, 1, 2 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 3, 2, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 2, 2 ], true, out, 1, 2 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 3, 0, 2, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 2, 2 ], false, out, -2, 7 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 2, 0, 3, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten( x, [ 2, 2 ], true, out, -2, 7 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flatten/test/test.js b/base/flatten/test/test.js deleted file mode 100644 index 3e282560e..000000000 --- a/base/flatten/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var flatten = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( flatten, 'assign' ), true, 'has property' ); - t.strictEqual( typeof flatten.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/flatten/test/test.main.js b/base/flatten/test/test.main.js deleted file mode 100644 index 89f8c016d..000000000 --- a/base/flatten/test/test.main.js +++ /dev/null @@ -1,669 +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 flatten = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens an array (0d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - expected = []; - actual = flatten( x, [], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens an array (1d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - expected = []; - actual = flatten( x, [ 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten( x, [ 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - actual = flatten( x, [ 4 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten( x, [ 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - actual = flatten( x, [ 4 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 2d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ], - [ 13, 14, 15, 16 ] - ]; - - expected = []; - actual = flatten( x, [ 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 0, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 1, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten( x, [ 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten( x, [ 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten( x, [ 2, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten( x, [ 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 5, 6, 7 ]; - actual = flatten( x, [ 2, 3 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ]; - actual = flatten( x, [ 3, 3 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten( x, [ 4, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten( x, [ 4, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten( x, [ 4, 4 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 2d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ], - [ 13, 14, 15, 16 ] - ]; - - expected = []; - actual = flatten( x, [ 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 0, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 1, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten( x, [ 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten( x, [ 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten( x, [ 2, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten( x, [ 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6, 3, 7 ]; - actual = flatten( x, [ 2, 3 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ]; - actual = flatten( x, [ 3, 3 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten( x, [ 4, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14 ]; - actual = flatten( x, [ 4, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ]; - actual = flatten( x, [ 4, 4 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 3d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ], - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ]; - - expected = []; - actual = flatten( x, [ 0, 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 0, 0, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 1, 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten( x, [ 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten( x, [ 1, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten( x, [ 2, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten( x, [ 2, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]; - actual = flatten( x, [ 3, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten( x, [ 4, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten( x, [ 4, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten( x, [ 4, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 3d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ], - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ]; - - expected = []; - actual = flatten( x, [ 0, 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 0, 0, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 1, 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten( x, [ 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten( x, [ 1, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten( x, [ 2, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten( x, [ 2, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ]; - actual = flatten( x, [ 3, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten( x, [ 4, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14 ]; - actual = flatten( x, [ 4, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ]; - actual = flatten( x, [ 4, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 4d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ], - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ]; - - expected = []; - actual = flatten( x, [ 0, 0, 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 0, 0, 1, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 1, 0, 0, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten( x, [ 1, 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten( x, [ 1, 1, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten( x, [ 2, 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten( x, [ 1, 2, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = flatten( x, [ 1, 2, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten( x, [ 2, 2, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten( x, [ 2, 2, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten( x, [ 2, 2, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 4d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ], - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ]; - - expected = []; - actual = flatten( x, [ 0, 0, 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 0, 0, 1, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 1, 0, 0, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten( x, [ 1, 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten( x, [ 1, 1, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten( x, [ 2, 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten( x, [ 1, 2, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 3, 7, 2, 6, 4, 8 ]; - actual = flatten( x, [ 1, 2, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13 ]; - actual = flatten( x, [ 2, 2, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 2, 10, 6, 14 ]; - actual = flatten( x, [ 2, 2, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ]; - actual = flatten( x, [ 2, 2, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic; 5d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ] - ]; - - expected = []; - actual = flatten( x, [ 0, 0, 0, 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 0, 0, 1, 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 1, 0, 0, 1, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten( x, [ 1, 1, 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten( x, [ 1, 1, 1, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten( x, [ 2, 1, 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten( x, [ 1, 2, 1, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = flatten( x, [ 1, 2, 1, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten( x, [ 2, 2, 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten( x, [ 2, 2, 1, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten( x, [ 2, 2, 1, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic; 5d)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ] - ]; - - expected = []; - actual = flatten( x, [ 0, 0, 0, 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 0, 0, 1, 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten( x, [ 1, 0, 0, 1, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten( x, [ 1, 1, 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten( x, [ 1, 1, 1, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten( x, [ 2, 1, 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten( x, [ 1, 2, 1, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 3, 7, 2, 6, 4, 8 ]; - actual = flatten( x, [ 1, 2, 1, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13 ]; - actual = flatten( x, [ 2, 2, 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 2, 10, 6, 14 ]; - actual = flatten( x, [ 2, 2, 1, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ]; - actual = flatten( x, [ 2, 2, 1, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flatten2d-by/README.md b/base/flatten2d-by/README.md deleted file mode 100644 index fac46cb39..000000000 --- a/base/flatten2d-by/README.md +++ /dev/null @@ -1,210 +0,0 @@ - - - - -# flatten2dBy - -> Flatten a two-dimensional nested array according to a callback function. - -
- -## Usage - -```javascript -var flatten2dBy = require( '@stdlib/array/base/flatten2d-by' ); -``` - -#### flatten2dBy( x, shape, colexicographic, clbk\[, thisArg] ) - -Flattens a two-dimensional nested array according to a callback function. - -```javascript -function scale( v ) { - return v * 2; -} - -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var out = flatten2dBy( x, [ 2, 2 ], false, scale ); -// returns [ 2, 4, 6, 8 ] -``` - -To flatten in colexicographic order, provide a third argument equal to `true`. - -```javascript -function scale( v ) { - return v * 2; -} - -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var out = flatten2dBy( x, [ 2, 2 ], true, scale ); -// returns [ 2, 6, 4, 8 ] -``` - -To set the callback execution context, provide a `thisArg` argument. - - - -```javascript -function scale( v ) { - this.count += 1; - return v * 2; -} - -var x = [ [ 1, 2 ], [ 3, 4 ] ]; -var ctx = { - 'count': 0 -}; - -var out = flatten2dBy( x, [ 2, 2 ], false, scale, ctx ); -// returns [ 2, 4, 6, 8 ] - -var count = ctx.count; -// returns 4 -``` - -#### flatten2dBy.assign( x, shape, colexicographic, out, stride, offset, clbk\[, thisArg] ) - -Flattens a two-dimensional nested array according to a callback function and assigns elements to a provided output array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -function scale( v ) { - return v * 2; -} - -var x = [ [ 1, 2 ], [ 3, 4 ] ]; -var out = new Float64Array( 4 ); - -var y = flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, scale ); -// returns [ 2, 4, 6, 8 ] - -var bool = ( y === out ); -// returns true - -y = flatten2dBy.assign( x, [ 2, 2 ], true, out, 1, 0, scale ); -// returns [ 2, 6, 4, 8 ] -``` - -
- - - -
- -## Notes - -- A callback function is provided the following arguments: - - - **value**: nested array element. - - **indices**: element indices (in lexicographic order). - - **arr**: the input array. - -- Both functions assume that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - -
- - - -
- -## Examples - - - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten2dBy = require( '@stdlib/array/base/flatten2d-by' ); - -var fcn = naryFunction( abs, 1 ); - -var x = [ - [ -1, -2, -3, -4 ], - [ -5, -6, -7, -8 ], - [ -9, -10, -11, -12 ], - [ -13, -14, -15, -16 ] -]; - -var out = flatten2dBy( x, [ 0, 0 ], false, fcn ); -// returns [] - -out = flatten2dBy( x, [ 0, 0 ], true, fcn ); -// returns [] - -out = flatten2dBy( x, [ 1, 1 ], false, fcn ); -// returns [ 1 ] - -out = flatten2dBy( x, [ 1, 1 ], true, fcn ); -// returns [ 1 ] - -out = flatten2dBy( x, [ 2, 2 ], false, fcn ); -// returns [ 1, 2, 5, 6 ] - -out = flatten2dBy( x, [ 2, 2 ], true, fcn ); -// returns [ 1, 5, 2, 6 ] - -out = flatten2dBy( x, [ 3, 3 ], false, fcn ); -// returns [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ] - -out = flatten2dBy( x, [ 3, 3 ], true, fcn ); -// returns [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ] - -out = flatten2dBy( x, [ 4, 4 ], false, fcn ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten2dBy( x, [ 4, 4 ], true, fcn ); -// returns [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/flatten2d-by/benchmark/benchmark.js b/base/flatten2d-by/benchmark/benchmark.js deleted file mode 100644 index 0b3dbc7fa..000000000 --- a/base/flatten2d-by/benchmark/benchmark.js +++ /dev/null @@ -1,143 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var zeroTo = require( './../../../base/zero-to' ); -var filled = require( './../../../base/filled' ); -var Float64Array = require( './../../../float64' ); -var pkg = require( './../package.json' ).name; -var flatten2dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Scales an input value. -* -* @private -* @param {number} v - input value -* @returns {number} output value -* -* @example -* var v = scale( 2.0 ); -* // returns 4.0 -*/ -function scale( v ) { - return v * 2.0; -} - - -// MAIN // - -bench( pkg+':size=100,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten2dBy( x, [ 10, 10 ], false, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':size=100,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten2dBy( x, [ 10, 10 ], true, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=100,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 100 ); - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten2dBy.assign( x, [ 10, 10 ], false, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=100,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 100 ); - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten2dBy.assign( x, [ 10, 10 ], true, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/flatten2d-by/docs/repl.txt b/base/flatten2d-by/docs/repl.txt deleted file mode 100644 index a46014b9d..000000000 --- a/base/flatten2d-by/docs/repl.txt +++ /dev/null @@ -1,106 +0,0 @@ - -{{alias}}( x, shape, colex, clbk[, thisArg] ) - Flattens a two-dimensional nested array according to a callback function. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - The callback function is provided the following arguments: - - - value: nested array element. - - indices: element indices (in lexicographic order). - - arr: the input array. - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colex: boolean - Specifies whether to flatten array values in colexicographic order. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Flattened array. - - Examples - -------- - > function fcn( v ) { return v * 2; }; - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var out = {{alias}}( x, [ 2, 2 ], false, fcn ) - [ 2, 4, 6, 8 ] - > out = {{alias}}( x, [ 2, 2 ], true, fcn ) - [ 2, 6, 4, 8 ] - - -{{alias}}.assign( x, shape, colex, out, stride, offset, clbk[, thisArg] ) - Flattens a two-dimensional nested array according to a callback function - and assigns elements to a provided output array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - The callback function is provided the following arguments: - - - value: nested array element. - - indices: element indices (in lexicographic order). - - arr: the input array. - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colex: boolean - Specifies whether to flatten array values in colexicographic order. - - out: Collection - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function fcn( v ) { return v * 2; }; - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var out = [ 0, 0, 0, 0 ]; - > var v = {{alias}}.assign( x, [ 2, 2 ], false, out, 1, 0, fcn ) - [ 2, 4, 6, 8 ] - > var bool = ( v === out ) - true - > out = [ 0, 0, 0, 0 ]; - > {{alias}}.assign( x, [ 2, 2 ], true, out, 1, 0, fcn ); - > out - [ 2, 6, 4, 8 ] - - See Also - -------- - diff --git a/base/flatten2d-by/docs/types/index.d.ts b/base/flatten2d-by/docs/types/index.d.ts deleted file mode 100644 index 8f6e5302b..000000000 --- a/base/flatten2d-by/docs/types/index.d.ts +++ /dev/null @@ -1,194 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Array2D } from '@stdlib/types/array'; -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Nullary callback function. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Unary callback function. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Binary callback function. -* -* @param value - array element -* @param indices - element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Array ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Array, arr: Array2D ) => U; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `flatten2dBy`. -*/ -interface Flatten2dBy { - /** - * Flattens a two-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten2dBy( x, [ 2, 2 ], false, scale ); - * // returns [ 2, 4, 6, 8 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten2dBy( x, [ 2, 2 ], true, scale ); - * // returns [ 2, 6, 4, 8 ] - */ - ( x: Array2D, shape: Shape2D, colexicographic: boolean, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - - /** - * Flattens a two-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten2dBy.assign( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 2, 4, 6, 8 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten2dBy.assign( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 2, 6, 4, 8 ] - */ - assign( x: Array2D, shape: Shape2D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Flattens a two-dimensional nested array according to a callback function. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param x - input array -* @param shape - array shape -* @param colexicographic - specifies whether to flatten array values in colexicographic order -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns flattened array -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2dBy( x, [ 2, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2dBy( x, [ 2, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -declare var flatten2dBy: Flatten2dBy; - - -// EXPORTS // - -export = flatten2dBy; diff --git a/base/flatten2d-by/docs/types/test.ts b/base/flatten2d-by/docs/types/test.ts deleted file mode 100644 index 1d4e2b937..000000000 --- a/base/flatten2d-by/docs/types/test.ts +++ /dev/null @@ -1,340 +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. -*/ - -import flatten2dBy = require( './index' ); - -/** -* Identity function. -* -* @param value - input value -* @returns input value -*/ -function identity( value: T ): T { - return value; -} - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten2dBy( x, [ 2, 2 ], false, identity ); // $ExpectType number[] - flatten2dBy( x, [ 2, 2 ], true, identity ); // $ExpectType number[] - - flatten2dBy( x, [ 2, 2 ], false, identity, {} ); // $ExpectType number[] - flatten2dBy( x, [ 2, 2 ], true, identity, {} ); // $ExpectType number[] - - flatten2dBy( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false, identity ); // $ExpectType string[] - flatten2dBy( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true, identity ); // $ExpectType string[] - - flatten2dBy( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false, identity, {} ); // $ExpectType string[] - flatten2dBy( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true, identity, {} ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - flatten2dBy( 1, [ 2, 2 ], false, identity ); // $ExpectError - flatten2dBy( true, [ 2, 2 ], false, identity ); // $ExpectError - flatten2dBy( false, [ 2, 2 ], false, identity ); // $ExpectError - flatten2dBy( null, [ 2, 2 ], false, identity ); // $ExpectError - flatten2dBy( void 0, [ 2, 2 ], false, identity ); // $ExpectError - flatten2dBy( {}, [ 2, 2 ], false, identity ); // $ExpectError - - flatten2dBy( 1, [ 2, 2 ], false, identity, {} ); // $ExpectError - flatten2dBy( true, [ 2, 2 ], false, identity, {} ); // $ExpectError - flatten2dBy( false, [ 2, 2 ], false, identity, {} ); // $ExpectError - flatten2dBy( null, [ 2, 2 ], false, identity, {} ); // $ExpectError - flatten2dBy( void 0, [ 2, 2 ], false, identity, {} ); // $ExpectError - flatten2dBy( {}, [ 2, 2 ], false, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten2dBy( x, '', false, identity ); // $ExpectError - flatten2dBy( x, 1, false, identity ); // $ExpectError - flatten2dBy( x, true, false, identity ); // $ExpectError - flatten2dBy( x, false, false, identity ); // $ExpectError - flatten2dBy( x, null, false, identity ); // $ExpectError - flatten2dBy( x, void 0, false, identity ); // $ExpectError - flatten2dBy( x, {}, false, identity ); // $ExpectError - flatten2dBy( x, [ 1, '2', 3 ], false, identity ); // $ExpectError - flatten2dBy( x, ( x: number ): number => x, false, identity ); // $ExpectError - - flatten2dBy( x, '', false, identity, {} ); // $ExpectError - flatten2dBy( x, 1, false, identity, {} ); // $ExpectError - flatten2dBy( x, true, false, identity, {} ); // $ExpectError - flatten2dBy( x, false, false, identity, {} ); // $ExpectError - flatten2dBy( x, null, false, identity, {} ); // $ExpectError - flatten2dBy( x, void 0, false, identity, {} ); // $ExpectError - flatten2dBy( x, {}, false, identity, {} ); // $ExpectError - flatten2dBy( x, [ 1, '2', 3 ], false, identity, {} ); // $ExpectError - flatten2dBy( x, ( x: number ): number => x, false, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten2dBy( x, [ 2, 2 ], '', identity ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], 1, identity ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], null, identity ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], void 0, identity ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], {}, identity ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], [], identity ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], ( x: number ): number => x, identity ); // $ExpectError - - flatten2dBy( x, [ 2, 2 ], '', identity, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], 1, identity, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], null, identity, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], void 0, identity, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], {}, identity, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], [], identity, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], ( x: number ): number => x, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a function... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten2dBy( x, [ 2, 2 ], false, '' ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, 1 ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, true ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, false ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, null ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, void 0 ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, [] ); // $ExpectError - - flatten2dBy( x, [ 2, 2 ], false, '', {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, 1, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, true, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, false, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, null, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, void 0, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, {}, {} ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten2dBy(); // $ExpectError - flatten2dBy( x ); // $ExpectError - flatten2dBy( x, [ 2, 2 ] ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false ); // $ExpectError - flatten2dBy( x, [ 2, 2 ], false, identity, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - const out1 = [ 0, 0, 0, 0 ]; - - flatten2dBy.assign( x, [ 2, 2 ], false, out1, 1, 0, identity ); // $ExpectType Collection - flatten2dBy.assign( x, [ 2, 2 ], true, out1, 1, 0, identity ); // $ExpectType Collection - - flatten2dBy.assign( x, [ 2, 2 ], false, out1, 1, 0, identity, {} ); // $ExpectType Collection - flatten2dBy.assign( x, [ 2, 2 ], true, out1, 1, 0, identity, {} ); // $ExpectType Collection - - const out2 = [ '', '', '', '' ]; - - flatten2dBy.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false, out2, 1, 0, identity ); // $ExpectType Collection - flatten2dBy.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true, out2, 1, 0, identity ); // $ExpectType Collection - - flatten2dBy.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false, out2, 1, 0, identity, {} ); // $ExpectType Collection - flatten2dBy.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true, out2, 1, 0, identity, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - flatten2dBy.assign( 1, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( true, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( false, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( null, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( void 0, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( {}, [ 2, 2 ], false, out, 1, 0, identity ); // $ExpectError - - flatten2dBy.assign( 1, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( true, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( false, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( null, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( void 0, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( {}, [ 2, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten2dBy.assign( x, '', false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, 1, false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, true, false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, false, false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, null, false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, void 0, false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, {}, false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 1, '2', 3 ], false, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, ( x: number ): number => x, false, out, 1, 0, identity ); // $ExpectError - - flatten2dBy.assign( x, '', false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, 1, false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, true, false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, false, false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, null, false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, void 0, false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, {}, false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 1, '2', 3 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, ( x: number ): number => x, false, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a boolean... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten2dBy.assign( x, [ 2, 2 ], '', out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], 1, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], null, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], void 0, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], {}, out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], [], out, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], ( x: number ): number => x, out, 1, 0, identity ); // $ExpectError - - flatten2dBy.assign( x, [ 2, 2 ], '', out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], 1, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], null, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], void 0, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], {}, out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], [], out, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], ( x: number ): number => x, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten2dBy.assign( x, [ 2, 2 ], false, 1, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, true, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, false, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, null, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, void 0, 1, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, {}, 1, 0, identity ); // $ExpectError - - flatten2dBy.assign( x, [ 2, 2 ], false, 1, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, true, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, false, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, null, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, void 0, 1, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, {}, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten2dBy.assign( x, [ 2, 2 ], false, out, '1', 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, true, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, false, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, null, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, void 0, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, {}, 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, [], 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, ( x: number ): number => x, 0, identity ); // $ExpectError - - flatten2dBy.assign( x, [ 2, 2 ], false, out, '1', 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, true, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, false, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, null, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, void 0, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, {}, 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, [], 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, ( x: number ): number => x, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, '1', identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, true, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, false, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, null, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, void 0, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, {}, identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, [], identity ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, ( x: number ): number => x, identity ); // $ExpectError - - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, '1', identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, true, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, false, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, null, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, void 0, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, {}, identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, [], identity, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, ( x: number ): number => x, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a seventh argument which is not a function... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, '1' ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, 1 ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, true ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, false ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, null ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, void 0 ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, [] ); // $ExpectError - - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, '1', {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, 1, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, true, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, false, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, null, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, void 0, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, {}, {} ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, [], {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten2dBy.assign(); // $ExpectError - flatten2dBy.assign( x ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ] ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1 ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flatten2dBy.assign( x, [ 2, 2 ], false, out, 1, 0, identity, {}, {} ); // $ExpectError -} diff --git a/base/flatten2d-by/examples/index.js b/base/flatten2d-by/examples/index.js deleted file mode 100644 index 472b5f508..000000000 --- a/base/flatten2d-by/examples/index.js +++ /dev/null @@ -1,72 +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'; - -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten2dBy = require( './../lib' ); - -var fcn = naryFunction( abs, 1 ); - -var x = [ - [ -1, -2, -3, -4 ], - [ -5, -6, -7, -8 ], - [ -9, -10, -11, -12 ], - [ -13, -14, -15, -16 ] -]; - -var out = flatten2dBy( x, [ 0, 0 ], false, fcn ); -console.log( out ); -// => [] - -out = flatten2dBy( x, [ 0, 0 ], true, fcn ); -console.log( out ); -// => [] - -out = flatten2dBy( x, [ 1, 1 ], false, fcn ); -console.log( out ); -// => [ 1 ] - -out = flatten2dBy( x, [ 1, 1 ], true, fcn ); -console.log( out ); -// => [ 1 ] - -out = flatten2dBy( x, [ 2, 2 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 5, 6 ] - -out = flatten2dBy( x, [ 2, 2 ], true, fcn ); -console.log( out ); -// => [ 1, 5, 2, 6 ] - -out = flatten2dBy( x, [ 3, 3 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ] - -out = flatten2dBy( x, [ 3, 3 ], true, fcn ); -console.log( out ); -// => [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ] - -out = flatten2dBy( x, [ 4, 4 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten2dBy( x, [ 4, 4 ], true, fcn ); -console.log( out ); -// => [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ] diff --git a/base/flatten2d-by/lib/assign.js b/base/flatten2d-by/lib/assign.js deleted file mode 100644 index 96a13a62f..000000000 --- a/base/flatten2d-by/lib/assign.js +++ /dev/null @@ -1,100 +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'; - -// MAIN // - -/** -* Flattens a two-dimensional nested array according to a callback function and assigns elements to a provided output array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2dBy( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2dBy( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -function flatten2dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) { // eslint-disable-line max-len - var S0; - var S1; - var i0; - var i1; - var a0; - var io; - - // Extract loop variables: - S0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 0 ]; - - // Iterate over the array dimensions... - io = offset; - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - out[ io ] = clbk.call( thisArg, x[ i1 ][ i0 ], [ i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order - io += stride; - } - } - return out; - } - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = x[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = clbk.call( thisArg, a0[ i0 ], [ i1, i0 ], x ); // equivalent to storing in row-major (C-style) order - io += stride; - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten2dBy; diff --git a/base/flatten2d-by/lib/index.js b/base/flatten2d-by/lib/index.js deleted file mode 100644 index 7b1930663..000000000 --- a/base/flatten2d-by/lib/index.js +++ /dev/null @@ -1,82 +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'; - -/** -* Flatten a two-dimensional nested array according to a callback function. -* -* @module @stdlib/array/base/flatten2d-by -* -* @example -* var flatten2dBy = require( '@stdlib/array/base/flatten2d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2dBy( x, [ 2, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* var flatten2dBy = require( '@stdlib/array/base/flatten2d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2dBy( x, [ 2, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var flatten2dBy = require( '@stdlib/array/base/flatten2d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = new Float64Array( 4 ); -* var y = flatten2dBy( x, [ 2, 2 ], true, out, 1, 0, scale ); -* // returns [ 2, 6, 4, 8 ] -* -* var bool = ( y === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flatten2d-by/lib/main.js b/base/flatten2d-by/lib/main.js deleted file mode 100644 index 044ba56ac..000000000 --- a/base/flatten2d-by/lib/main.js +++ /dev/null @@ -1,93 +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'; - -// MAIN // - -/** -* Flattens a two-dimensional nested array according to a callback function. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Array} flattened array -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2dBy( x, [ 2, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2dBy( x, [ 2, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -function flatten2dBy( x, shape, colexicographic, clbk, thisArg ) { - var out; - var S0; - var S1; - var i0; - var i1; - var a0; - - // Extract loop variables: - S0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 0 ]; - - // Initialize an output array: - out = []; - - // Iterate over the array dimensions... - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - out.push( clbk.call( thisArg, x[ i1 ][ i0 ], [ i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order - } - } - return out; - } - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = x[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out.push( clbk.call( thisArg, a0[ i0 ], [ i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten2dBy; diff --git a/base/flatten2d-by/package.json b/base/flatten2d-by/package.json deleted file mode 100644 index 6caa9938f..000000000 --- a/base/flatten2d-by/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/flatten2d-by", - "version": "0.0.0", - "description": "Flatten a two-dimensional nested array according to a callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flatten", - "flat", - "2d", - "matrix", - "strided", - "ndarray", - "multidimensional", - "foreach", - "map", - "transform", - "callback", - "accessor" - ] -} diff --git a/base/flatten2d-by/test/test.assign.js b/base/flatten2d-by/test/test.assign.js deleted file mode 100644 index df44a4e5b..000000000 --- a/base/flatten2d-by/test/test.assign.js +++ /dev/null @@ -1,393 +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 naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var Float64Array = require( './../../../float64' ); -var flatten2dBy = require( './../lib/assign.js' ); - - -// VARIABLES // - -var clbk = naryFunction( abs, 1 ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten2dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2, -3, -4 ], - [ -5, -6, -7, -8 ], - [ -9, -10, -11, -12 ], - [ -13, -14, -15, -16 ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2dBy( x, [ 0, 0 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2dBy( x, [ 0, 1 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2dBy( x, [ 1, 0 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten2dBy( x, [ 1, 1 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten2dBy( x, [ 1, 2 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten2dBy( x, [ 2, 1 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten2dBy( x, [ 2, 2 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 5, 6, 7 ] ); - out = new Float64Array( 6 ); - actual = flatten2dBy( x, [ 2, 3 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ] ); - out = new Float64Array( 9 ); - actual = flatten2dBy( x, [ 3, 3 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten2dBy( x, [ 4, 1 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten2dBy( x, [ 4, 2 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten2dBy( x, [ 4, 4 ], false, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2, -3, -4 ], - [ -5, -6, -7, -8 ], - [ -9, -10, -11, -12 ], - [ -13, -14, -15, -16 ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2dBy( x, [ 0, 0 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2dBy( x, [ 0, 1 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2dBy( x, [ 1, 0 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten2dBy( x, [ 1, 1 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten2dBy( x, [ 1, 2 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten2dBy( x, [ 2, 1 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten2dBy( x, [ 2, 2 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6, 3, 7 ] ); - out = new Float64Array( 6 ); - actual = flatten2dBy( x, [ 2, 3 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ] ); - out = new Float64Array( 9 ); - actual = flatten2dBy( x, [ 3, 3 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten2dBy( x, [ 4, 1 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten2dBy( x, [ 4, 2 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten2dBy( x, [ 4, 4 ], true, out, 1, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten2dBy( x, [ 2, 2 ], false, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 1, 0, 3, 0, 2, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten2dBy( x, [ 2, 2 ], true, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten2dBy( x, [ 2, 2 ], false, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 3, 2, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten2dBy( x, [ 2, 2 ], true, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 3, 0, 2, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten2dBy( x, [ 2, 2 ], false, out, -2, 7, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ -1, -2 ], - [ -3, -4 ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 2, 0, 3, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten2dBy( x, [ 2, 2 ], true, out, -2, 7, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports setting the callback execution context (lexicographic)', function test( t ) { - var ctx; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flatten2dBy( x, [ 2, 2 ], false, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 2, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic)', function test( t ) { - var ctx; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flatten2dBy( x, [ 2, 2 ], true, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 2, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); diff --git a/base/flatten2d-by/test/test.js b/base/flatten2d-by/test/test.js deleted file mode 100644 index 58896dadd..000000000 --- a/base/flatten2d-by/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var flatten2dBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten2dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( flatten2dBy, 'assign' ), true, 'has property' ); - t.strictEqual( typeof flatten2dBy.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/flatten2d-by/test/test.main.js b/base/flatten2d-by/test/test.main.js deleted file mode 100644 index b80689336..000000000 --- a/base/flatten2d-by/test/test.main.js +++ /dev/null @@ -1,218 +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 naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten2dBy = require( './../lib/main.js' ); - - -// VARIABLES // - -var clbk = naryFunction( abs, 1 ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten2dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ -1, -2, -3, -4 ], - [ -5, -6, -7, -8 ], - [ -9, -10, -11, -12 ], - [ -13, -14, -15, -16 ] - ]; - - expected = []; - actual = flatten2dBy( x, [ 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten2dBy( x, [ 0, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten2dBy( x, [ 1, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten2dBy( x, [ 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten2dBy( x, [ 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten2dBy( x, [ 2, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten2dBy( x, [ 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 5, 6, 7 ]; - actual = flatten2dBy( x, [ 2, 3 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ]; - actual = flatten2dBy( x, [ 3, 3 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten2dBy( x, [ 4, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten2dBy( x, [ 4, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten2dBy( x, [ 4, 4 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ -1, -2, -3, -4 ], - [ -5, -6, -7, -8 ], - [ -9, -10, -11, -12 ], - [ -13, -14, -15, -16 ] - ]; - - expected = []; - actual = flatten2dBy( x, [ 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten2dBy( x, [ 0, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten2dBy( x, [ 1, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten2dBy( x, [ 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten2dBy( x, [ 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten2dBy( x, [ 2, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten2dBy( x, [ 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6, 3, 7 ]; - actual = flatten2dBy( x, [ 2, 3 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ]; - actual = flatten2dBy( x, [ 3, 3 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten2dBy( x, [ 4, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14 ]; - actual = flatten2dBy( x, [ 4, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ]; - actual = flatten2dBy( x, [ 4, 4 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports setting the callback execution context (lexicographic)', function test( t ) { - var ctx; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - ctx = { - 'count': 0 - }; - - flatten2dBy( x, [ 2, 2 ], false, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 2, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic)', function test( t ) { - var ctx; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - ctx = { - 'count': 0 - }; - - flatten2dBy( x, [ 2, 2 ], true, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 2, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); diff --git a/base/flatten2d/README.md b/base/flatten2d/README.md deleted file mode 100644 index b588f1d64..000000000 --- a/base/flatten2d/README.md +++ /dev/null @@ -1,164 +0,0 @@ - - -# flatten2d - -> Flatten a two-dimensional nested array. - -
- -## Usage - -```javascript -var flatten2d = require( '@stdlib/array/base/flatten2d' ); -``` - -#### flatten2d( x, shape, colexicographic ) - -Flattens a two-dimensional nested array. - -```javascript -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var out = flatten2d( x, [ 2, 2 ], false ); -// returns [ 1, 2, 3, 4 ] -``` - -To flatten in colexicographic order, provide a third argument equal to `true`. - -```javascript -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var out = flatten2d( x, [ 2, 2 ], true ); -// returns [ 1, 3, 2, 4 ] -``` - -#### flatten2d.assign( x, shape, colexicographic, out, stride, offset ) - -Flattens a two-dimensional nested array and assigns elements to a provided output array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var x = [ [ 1, 2 ], [ 3, 4 ] ]; -var out = new Float64Array( 4 ); - -var y = flatten2d.assign( x, [ 2, 2 ], false, out, 1, 0 ); -// returns [ 1, 2, 3, 4 ] - -var bool = ( y === out ); -// returns true - -y = flatten2d.assign( x, [ 2, 2 ], true, out, 1, 0 ); -// returns [ 1, 3, 2, 4 ] -``` - -
- - - -
- -## Notes - -- Both functions assume that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - -
- - - -
- -## Examples - - - -```javascript -var flatten2d = require( '@stdlib/array/base/flatten2d' ); - -var x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ], - [ 13, 14, 15, 16 ] -]; - -var out = flatten2d( x, [ 0, 0 ], false ); -// returns [] - -out = flatten2d( x, [ 0, 0 ], true ); -// returns [] - -out = flatten2d( x, [ 1, 1 ], false ); -// returns [ 1 ] - -out = flatten2d( x, [ 1, 1 ], true ); -// returns [ 1 ] - -out = flatten2d( x, [ 2, 2 ], false ); -// returns [ 1, 2, 5, 6 ] - -out = flatten2d( x, [ 2, 2 ], true ); -// returns [ 1, 5, 2, 6 ] - -out = flatten2d( x, [ 3, 3 ], false ); -// returns [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ] - -out = flatten2d( x, [ 3, 3 ], true ); -// returns [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ] - -out = flatten2d( x, [ 4, 4 ], false ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten2d( x, [ 4, 4 ], true ); -// returns [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/flatten2d/benchmark/benchmark.js b/base/flatten2d/benchmark/benchmark.js deleted file mode 100644 index 04a2e2155..000000000 --- a/base/flatten2d/benchmark/benchmark.js +++ /dev/null @@ -1,125 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var zeroTo = require( './../../../base/zero-to' ); -var filled = require( './../../../base/filled' ); -var Float64Array = require( './../../../float64' ); -var pkg = require( './../package.json' ).name; -var flatten2d = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten2d( x, [ 10, 10 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':size=100,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten2d( x, [ 10, 10 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=100,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 100 ); - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten2d.assign( x, [ 10, 10 ], false, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=100,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 100 ); - x = filled( zeroTo( 10 ), 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten2d.assign( x, [ 10, 10 ], true, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/flatten2d/docs/repl.txt b/base/flatten2d/docs/repl.txt deleted file mode 100644 index e85f09c97..000000000 --- a/base/flatten2d/docs/repl.txt +++ /dev/null @@ -1,80 +0,0 @@ - -{{alias}}( x, shape, colexicographic ) - Flattens a two-dimensional nested array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colexicographic: boolean - Specifies whether to flatten array values in colexicographic order. - - Returns - ------- - out: Array - Flattened array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var out = {{alias}}( x, [ 2, 2 ], false ) - [ 1, 2, 3, 4 ] - > out = {{alias}}( x, [ 2, 2 ], true ) - [ 1, 3, 2, 4 ] - - -{{alias}}.assign( x, shape, colexicographic, out, stride, offset ) - Flattens a two-dimensional nested array and assigns elements to a provided - output array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colexicographic: boolean - Specifies whether to flatten array values in colexicographic order. - - out: Collection - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var out = [ 0, 0, 0, 0 ]; - > var v = {{alias}}.assign( x, [ 2, 2 ], false, out, 1, 0 ) - [ 1, 2, 3, 4 ] - > var bool = ( v === out ) - true - > out = [ 0, 0, 0, 0 ]; - > {{alias}}.assign( x, [ 2, 2 ], true, out, 1, 0 ); - > out - [ 1, 3, 2, 4 ] - - See Also - -------- - diff --git a/base/flatten2d/docs/types/index.d.ts b/base/flatten2d/docs/types/index.d.ts deleted file mode 100644 index 68e04e70c..000000000 --- a/base/flatten2d/docs/types/index.d.ts +++ /dev/null @@ -1,119 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Array2D } from '@stdlib/types/array'; -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Interface describing `flatten2d`. -*/ -interface Flatten2d { - /** - * Flattens a two-dimensional nested array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @returns flattened array - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten2d( x, [ 2, 2 ], false ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten2d( x, [ 2, 2 ], true ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array2D, shape: Shape2D, colexicographic: boolean ): Array; - - /** - * Flattens a two-dimensional nested array and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten2d.assign( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0 ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ [ 1, 2 ], [ 3, 4 ] ]; - * - * var out = flatten2d.assign( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0 ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array2D, shape: Shape2D, colexicographic: boolean, out: Collection, stride: number, offset: number ): Collection; -} - -/** -* Flattens a two-dimensional nested array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param x - input array -* @param shape - array shape -* @param colexicographic - specifies whether to flatten array values in colexicographic order -* @returns flattened array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2d( x, [ 2, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2d( x, [ 2, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -*/ -declare var flatten2d: Flatten2d; - - -// EXPORTS // - -export = flatten2d; diff --git a/base/flatten2d/docs/types/test.ts b/base/flatten2d/docs/types/test.ts deleted file mode 100644 index 8f816187b..000000000 --- a/base/flatten2d/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -import flatten2d = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten2d( x, [ 2, 2 ], false ); // $ExpectType number[] - flatten2d( x, [ 2, 2 ], true ); // $ExpectType number[] - - flatten2d( x, [ 2, 2 ], false ); // $ExpectType number[] - flatten2d( x, [ 2, 2 ], true ); // $ExpectType number[] - - flatten2d( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false ); // $ExpectType string[] - flatten2d( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - flatten2d( 1, [ 2, 2 ], false ); // $ExpectError - flatten2d( true, [ 2, 2 ], false ); // $ExpectError - flatten2d( false, [ 2, 2 ], false ); // $ExpectError - flatten2d( null, [ 2, 2 ], false ); // $ExpectError - flatten2d( void 0, [ 2, 2 ], false ); // $ExpectError - flatten2d( {}, [ 2, 2 ], false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten2d( x, '', false ); // $ExpectError - flatten2d( x, 1, false ); // $ExpectError - flatten2d( x, true, false ); // $ExpectError - flatten2d( x, false, false ); // $ExpectError - flatten2d( x, null, false ); // $ExpectError - flatten2d( x, void 0, false ); // $ExpectError - flatten2d( x, {}, false ); // $ExpectError - flatten2d( x, [ 1, '2', 3 ], false ); // $ExpectError - flatten2d( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten2d( x, [ 2, 2 ], '' ); // $ExpectError - flatten2d( x, [ 2, 2 ], 1 ); // $ExpectError - flatten2d( x, [ 2, 2 ], null ); // $ExpectError - flatten2d( x, [ 2, 2 ], void 0 ); // $ExpectError - flatten2d( x, [ 2, 2 ], {} ); // $ExpectError - flatten2d( x, [ 2, 2 ], [] ); // $ExpectError - flatten2d( x, [ 2, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten2d(); // $ExpectError - flatten2d( x ); // $ExpectError - flatten2d( x, [ 2, 2 ] ); // $ExpectError - flatten2d( x, [ 2, 2 ], false, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - const out1 = [ 0, 0, 0, 0 ]; - - flatten2d.assign( x, [ 2, 2 ], false, out1, 1, 0 ); // $ExpectType Collection - flatten2d.assign( x, [ 2, 2 ], true, out1, 1, 0 ); // $ExpectType Collection - - flatten2d.assign( x, [ 2, 2 ], false, out1, 1, 0 ); // $ExpectType Collection - flatten2d.assign( x, [ 2, 2 ], true, out1, 1, 0 ); // $ExpectType Collection - - const out2 = [ '', '', '', '' ]; - - flatten2d.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], false, out2, 1, 0 ); // $ExpectType Collection - flatten2d.assign( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], true, out2, 1, 0 ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - flatten2d.assign( 1, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flatten2d.assign( true, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flatten2d.assign( false, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flatten2d.assign( null, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flatten2d.assign( void 0, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError - flatten2d.assign( {}, [ 2, 2 ], false, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten2d.assign( x, '', false, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, 1, false, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, true, false, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, false, false, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, null, false, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, void 0, false, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, {}, false, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 1, '2', 3 ], false, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, ( x: number ): number => x, false, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a boolean... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten2d.assign( x, [ 2, 2 ], '', out, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], 1, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], null, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], void 0, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], {}, out, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], [], out, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], ( x: number ): number => x, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flatten2d.assign( x, [ 2, 2 ], false, 1, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, true, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, false, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, null, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, void 0, 1, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten2d.assign( x, [ 2, 2 ], false, out, '1', 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, true, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, false, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, null, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, void 0, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, {}, 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, [], 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten2d.assign( x, [ 2, 2 ], false, out, 1, '1' ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, 1, true ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, 1, false ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, 1, null ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, 1, void 0 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, 1, {} ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, 1, [] ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten2d.assign(); // $ExpectError - flatten2d.assign( x ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ] ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, 1 ); // $ExpectError - flatten2d.assign( x, [ 2, 2 ], false, out, 1, 0, {} ); // $ExpectError -} diff --git a/base/flatten2d/examples/index.js b/base/flatten2d/examples/index.js deleted file mode 100644 index 4066af1c6..000000000 --- a/base/flatten2d/examples/index.js +++ /dev/null @@ -1,68 +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'; - -var flatten2d = require( './../lib' ); - -var x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ], - [ 13, 14, 15, 16 ] -]; - -var out = flatten2d( x, [ 0, 0 ], false ); -console.log( out ); -// => [] - -out = flatten2d( x, [ 0, 0 ], true ); -console.log( out ); -// => [] - -out = flatten2d( x, [ 1, 1 ], false ); -console.log( out ); -// => [ 1 ] - -out = flatten2d( x, [ 1, 1 ], true ); -console.log( out ); -// => [ 1 ] - -out = flatten2d( x, [ 2, 2 ], false ); -console.log( out ); -// => [ 1, 2, 5, 6 ] - -out = flatten2d( x, [ 2, 2 ], true ); -console.log( out ); -// => [ 1, 5, 2, 6 ] - -out = flatten2d( x, [ 3, 3 ], false ); -console.log( out ); -// => [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ] - -out = flatten2d( x, [ 3, 3 ], true ); -console.log( out ); -// => [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ] - -out = flatten2d( x, [ 4, 4 ], false ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten2d( x, [ 4, 4 ], true ); -console.log( out ); -// => [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ] diff --git a/base/flatten2d/lib/assign.js b/base/flatten2d/lib/assign.js deleted file mode 100644 index b7298ab40..000000000 --- a/base/flatten2d/lib/assign.js +++ /dev/null @@ -1,90 +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'; - -// MAIN // - -/** -* Flattens a two-dimensional nested array and assigns elements to a provided output array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2d( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0 ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2d( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0 ); -* // returns [ 1, 3, 2, 4 ] -*/ -function flatten2d( x, shape, colexicographic, out, stride, offset ) { - var S0; - var S1; - var i0; - var i1; - var a0; - var io; - - // Extract loop variables: - S0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 0 ]; - - // Iterate over the array dimensions... - io = offset; - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - out[ io ] = x[ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order - io += stride; - } - } - return out; - } - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = x[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order - io += stride; - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten2d; diff --git a/base/flatten2d/lib/index.js b/base/flatten2d/lib/index.js deleted file mode 100644 index f423438f6..000000000 --- a/base/flatten2d/lib/index.js +++ /dev/null @@ -1,70 +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'; - -/** -* Flatten a two-dimensional nested array. -* -* @module @stdlib/array/base/flatten2d -* -* @example -* var flatten2d = require( '@stdlib/array/base/flatten2d' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2d( x, [ 2, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var flatten2d = require( '@stdlib/array/base/flatten2d' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2d( x, [ 2, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var flatten2d = require( '@stdlib/array/base/flatten2d' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = new Float64Array( 4 ); -* var y = flatten2d.assign( x, [ 2, 2 ], true, out, 1, 0 ); -* // returns [ 1, 3, 2, 4 ] -* -* var bool = ( y === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flatten2d/lib/main.js b/base/flatten2d/lib/main.js deleted file mode 100644 index 1d8ff6b2a..000000000 --- a/base/flatten2d/lib/main.js +++ /dev/null @@ -1,83 +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'; - -// MAIN // - -/** -* Flattens a two-dimensional nested array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @returns {Array} flattened array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2d( x, [ 2, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* -* var out = flatten2d( x, [ 2, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -*/ -function flatten2d( x, shape, colexicographic ) { - var out; - var S0; - var S1; - var i0; - var i1; - var a0; - - // Extract loop variables: - S0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 0 ]; - - // Initialize an output array: - out = []; - - // Iterate over the array dimensions... - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - out.push( x[ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order - } - } - return out; - } - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = x[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten2d; diff --git a/base/flatten2d/package.json b/base/flatten2d/package.json deleted file mode 100644 index a5f58c095..000000000 --- a/base/flatten2d/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/flatten2d", - "version": "0.0.0", - "description": "Flatten a two-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flatten", - "flat", - "2d", - "matrix", - "strided", - "ndarray", - "multidimensional" - ] -} diff --git a/base/flatten2d/test/test.assign.js b/base/flatten2d/test/test.assign.js deleted file mode 100644 index 2b4e48727..000000000 --- a/base/flatten2d/test/test.assign.js +++ /dev/null @@ -1,330 +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 Float64Array = require( './../../../float64' ); -var flatten2d = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ], - [ 13, 14, 15, 16 ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2d( x, [ 0, 0 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2d( x, [ 0, 1 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2d( x, [ 1, 0 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten2d( x, [ 1, 1 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten2d( x, [ 1, 2 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten2d( x, [ 2, 1 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten2d( x, [ 2, 2 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 5, 6, 7 ] ); - out = new Float64Array( 6 ); - actual = flatten2d( x, [ 2, 3 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ] ); - out = new Float64Array( 9 ); - actual = flatten2d( x, [ 3, 3 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten2d( x, [ 4, 1 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten2d( x, [ 4, 2 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten2d( x, [ 4, 4 ], false, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ], - [ 13, 14, 15, 16 ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2d( x, [ 0, 0 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2d( x, [ 0, 1 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten2d( x, [ 1, 0 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten2d( x, [ 1, 1 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten2d( x, [ 1, 2 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten2d( x, [ 2, 1 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten2d( x, [ 2, 2 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6, 3, 7 ] ); - out = new Float64Array( 6 ); - actual = flatten2d( x, [ 2, 3 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ] ); - out = new Float64Array( 9 ); - actual = flatten2d( x, [ 3, 3 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten2d( x, [ 4, 1 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten2d( x, [ 4, 2 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten2d( x, [ 4, 4 ], true, out, 1, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten2d( x, [ 2, 2 ], false, out, 2, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 1, 0, 3, 0, 2, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten2d( x, [ 2, 2 ], true, out, 2, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten2d( x, [ 2, 2 ], false, out, 1, 2 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 3, 2, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten2d( x, [ 2, 2 ], true, out, 1, 2 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 3, 0, 2, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten2d( x, [ 2, 2 ], false, out, -2, 7 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 2, 0, 3, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten2d( x, [ 2, 2 ], true, out, -2, 7 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flatten2d/test/test.js b/base/flatten2d/test/test.js deleted file mode 100644 index 88d1f6adc..000000000 --- a/base/flatten2d/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var flatten2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( flatten2d, 'assign' ), true, 'has property' ); - t.strictEqual( typeof flatten2d.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/flatten2d/test/test.main.js b/base/flatten2d/test/test.main.js deleted file mode 100644 index 2a3bb92f5..000000000 --- a/base/flatten2d/test/test.main.js +++ /dev/null @@ -1,159 +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 flatten2d = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ], - [ 13, 14, 15, 16 ] - ]; - - expected = []; - actual = flatten2d( x, [ 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten2d( x, [ 0, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten2d( x, [ 1, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten2d( x, [ 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten2d( x, [ 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten2d( x, [ 2, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten2d( x, [ 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 5, 6, 7 ]; - actual = flatten2d( x, [ 2, 3 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 5, 6, 7, 9, 10, 11 ]; - actual = flatten2d( x, [ 3, 3 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten2d( x, [ 4, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten2d( x, [ 4, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten2d( x, [ 4, 4 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ], - [ 13, 14, 15, 16 ] - ]; - - expected = []; - actual = flatten2d( x, [ 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten2d( x, [ 0, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten2d( x, [ 1, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten2d( x, [ 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten2d( x, [ 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten2d( x, [ 2, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten2d( x, [ 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6, 3, 7 ]; - actual = flatten2d( x, [ 2, 3 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 2, 6, 10, 3, 7, 11 ]; - actual = flatten2d( x, [ 3, 3 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten2d( x, [ 4, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14 ]; - actual = flatten2d( x, [ 4, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ]; - actual = flatten2d( x, [ 4, 4 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flatten3d-by/README.md b/base/flatten3d-by/README.md deleted file mode 100644 index 9969a618a..000000000 --- a/base/flatten3d-by/README.md +++ /dev/null @@ -1,210 +0,0 @@ - - - - -# flatten3dBy - -> Flatten a three-dimensional nested array according to a callback function. - -
- -## Usage - -```javascript -var flatten3dBy = require( '@stdlib/array/base/flatten3d-by' ); -``` - -#### flatten3dBy( x, shape, colexicographic, clbk\[, thisArg] ) - -Flattens a three-dimensional nested array according to a callback function. - -```javascript -function scale( v ) { - return v * 2; -} - -var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - -var out = flatten3dBy( x, [ 2, 1, 2 ], false, scale ); -// returns [ 2, 4, 6, 8 ] -``` - -To flatten in colexicographic order, provide a third argument equal to `true`. - -```javascript -function scale( v ) { - return v * 2; -} - -var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - -var out = flatten3dBy( x, [ 2, 1, 2 ], true, scale ); -// returns [ 2, 6, 4, 8 ] -``` - -To set the callback execution context, provide a `thisArg` argument. - - - -```javascript -function scale( v ) { - this.count += 1; - return v * 2; -} - -var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -var ctx = { - 'count': 0 -}; - -var out = flatten3dBy( x, [ 1, 2, 2 ], false, scale, ctx ); -// returns [ 2, 4, 6, 8 ] - -var count = ctx.count; -// returns 4 -``` - -#### flatten3dBy.assign( x, shape, colexicographic, out, stride, offset, clbk\[, thisArg] ) - -Flattens a three-dimensional nested array according to a callback function and assigns elements to a provided output array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -function scale( v ) { - return v * 2; -} - -var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -var out = new Float64Array( 4 ); - -var y = flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, scale ); -// returns [ 1, 2, 3, 4 ] - -var bool = ( y === out ); -// returns true - -y = flatten3dBy.assign( x, [ 2, 1, 2 ], true, out, 1, 0, scale ); -// returns [ 1, 3, 2, 4 ] -``` - -
- - - -
- -## Notes - -- A callback function is provided the following arguments: - - - **value**: nested array element. - - **indices**: element indices (in lexicographic order). - - **arr**: the input array. - -- Both functions assume that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - -
- - - -
- -## Examples - - - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten3dBy = require( '@stdlib/array/base/flatten3d-by' ); - -var fcn = naryFunction( abs, 1 ); - -var x = [ - [ [ -1, -2 ], [ -3, -4 ] ], - [ [ -5, -6 ], [ -7, -8 ] ], - [ [ -9, -10 ], [ -11, -12 ] ], - [ [ -13, -14 ], [ -15, -16 ] ] -]; - -var out = flatten3dBy( x, [ 0, 0, 0 ], false, fcn ); -// returns [] - -out = flatten3dBy( x, [ 0, 0, 0 ], true, fcn ); -// returns [] - -out = flatten3dBy( x, [ 1, 1, 1 ], false, fcn ); -// returns [ 1 ] - -out = flatten3dBy( x, [ 1, 1, 1 ], true, fcn ); -// returns [ 1 ] - -out = flatten3dBy( x, [ 2, 2, 2 ], false, fcn ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten3dBy( x, [ 2, 2, 2 ], true, fcn ); -// returns [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten3dBy( x, [ 3, 2, 2 ], false, fcn ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] - -out = flatten3dBy( x, [ 3, 2, 2 ], true, fcn ); -// returns [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ] - -out = flatten3dBy( x, [ 4, 2, 2 ], false, fcn ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten3dBy( x, [ 4, 2, 2 ], true, fcn ); -// returns [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/flatten3d-by/benchmark/benchmark.js b/base/flatten3d-by/benchmark/benchmark.js deleted file mode 100644 index db25ad600..000000000 --- a/base/flatten3d-by/benchmark/benchmark.js +++ /dev/null @@ -1,143 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var zeroTo = require( './../../../base/zero-to' ); -var filled = require( './../../../base/filled' ); -var Float64Array = require( './../../../float64' ); -var pkg = require( './../package.json' ).name; -var flatten3dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Scales an input value. -* -* @private -* @param {number} v - input value -* @returns {number} output value -* -* @example -* var v = scale( 2.0 ); -* // returns 4.0 -*/ -function scale( v ) { - return v * 2.0; -} - - -// MAIN // - -bench( pkg+':size=125,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten3dBy( x, [ 5, 5, 5 ], false, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':size=125,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten3dBy( x, [ 5, 5, 5 ], true, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=125,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 125 ); - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten3dBy.assign( x, [ 5, 5, 5 ], false, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=125,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 125 ); - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten3dBy.assign( x, [ 5, 5, 5 ], true, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/flatten3d-by/docs/repl.txt b/base/flatten3d-by/docs/repl.txt deleted file mode 100644 index 2217752e7..000000000 --- a/base/flatten3d-by/docs/repl.txt +++ /dev/null @@ -1,106 +0,0 @@ - -{{alias}}( x, shape, colex, clbk[, thisArg] ) - Flattens a three-dimensional nested array according to a callback function. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - The callback function is provided the following arguments: - - - value: nested array element. - - indices: element indices (in lexicographic order). - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - shape: Array - Array shape. - - colex: boolean - Specifies whether to flatten array values in colexicographic order. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Flattened array. - - Examples - -------- - > function fcn( v ) { return v * 2; }; - > var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - > var out = {{alias}}( x, [ 2, 1, 2 ], false, fcn ) - [ 2, 4, 6, 8 ] - > out = {{alias}}( x, [ 2, 1, 2 ], true, fcn ) - [ 2, 6, 4, 8 ] - - -{{alias}}.assign( x, shape, colex, out, stride, offset, clbk[, thisArg] ) - Flattens a three-dimensional nested array according to a callback function - and assigns elements to a provided output array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - The callback function is provided the following arguments: - - - value: nested array element. - - indices: element indices (in lexicographic order). - - arr: the input array. - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colex: boolean - Specifies whether to flatten array values in colexicographic order. - - out: Collection - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function fcn( v ) { return v * 2; }; - > var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - > var out = [ 0, 0, 0, 0 ]; - > var v = {{alias}}.assign( x, [ 2, 1, 2 ], false, out, 1, 0, fcn ) - [ 2, 4, 6, 8 ] - > var bool = ( v === out ) - true - > out = [ 0, 0, 0, 0 ]; - > {{alias}}.assign( x, [ 2, 1, 2 ], true, out, 1, 0, fcn ); - > out - [ 2, 6, 4, 8 ] - - See Also - -------- - diff --git a/base/flatten3d-by/docs/types/index.d.ts b/base/flatten3d-by/docs/types/index.d.ts deleted file mode 100644 index 207d526da..000000000 --- a/base/flatten3d-by/docs/types/index.d.ts +++ /dev/null @@ -1,193 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Array3D } from '@stdlib/types/array'; -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Nullary callback function. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Unary callback function. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Binary callback function. -* -* @param value - array element -* @param indices - element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Array ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Array, arr: Array3D ) => U; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `flatten3dBy`. -*/ -interface Flatten3dBy { - /** - * Flattens a three-dimensional nested array according to a callback function.. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * var out = flatten3dBy( x, [ 2, 1, 2 ], false, scale ); - * // returns [ 2, 4, 6, 8 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * var out = flatten3dBy( x, [ 2, 1, 2 ], true, scale ); - * // returns [ 2, 6, 4, 8 ] - */ - ( x: Array3D, shape: Shape3D, colexicographic: boolean, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a three-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * var out = flatten3dBy.assign( x, [ 2, 1, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 2, 4, 6, 8 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * var out = flatten3dBy.assign( x, [ 2, 1, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 2, 6, 4, 8 ] - */ - assign( x: Array3D, shape: Shape3D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Flattens a three-dimensional nested array according to a callback function. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param x - input array -* @param shape - array shape -* @param colexicographic - specifies whether to flatten array values in colexicographic order -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns flattened array -* -* @example -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* function scale( v ) { -* return v * 2; -* } -* -* var out = flatten3dBy( x, [ 2, 1, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* function scale( v ) { -* return v * 2; -* } -* -* var out = flatten3dBy( x, [ 2, 1, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -declare var flatten3dBy: Flatten3dBy; - - -// EXPORTS // - -export = flatten3dBy; diff --git a/base/flatten3d-by/docs/types/test.ts b/base/flatten3d-by/docs/types/test.ts deleted file mode 100644 index 968601de6..000000000 --- a/base/flatten3d-by/docs/types/test.ts +++ /dev/null @@ -1,340 +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. -*/ - -import flatten3dBy = require( './index' ); - -/** -* Identity function. -* -* @param value - input value -* @returns input value -*/ -function identity( value: T ): T { - return value; -} - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - flatten3dBy( x, [ 2, 1, 2 ], false, identity ); // $ExpectType number[] - flatten3dBy( x, [ 2, 1, 2 ], true, identity ); // $ExpectType number[] - - flatten3dBy( x, [ 2, 1, 2 ], false, identity, {} ); // $ExpectType number[] - flatten3dBy( x, [ 2, 1, 2 ], true, identity, {} ); // $ExpectType number[] - - flatten3dBy( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], false, identity ); // $ExpectType string[] - flatten3dBy( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], true, identity ); // $ExpectType string[] - - flatten3dBy( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], false, identity, {} ); // $ExpectType string[] - flatten3dBy( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], true, identity, {} ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - flatten3dBy( 1, [ 2, 1, 2 ], false, identity ); // $ExpectError - flatten3dBy( true, [ 2, 1, 2 ], false, identity ); // $ExpectError - flatten3dBy( false, [ 2, 1, 2 ], false, identity ); // $ExpectError - flatten3dBy( null, [ 2, 1, 2 ], false, identity ); // $ExpectError - flatten3dBy( void 0, [ 2, 1, 2 ], false, identity ); // $ExpectError - flatten3dBy( {}, [ 2, 1, 2 ], false, identity ); // $ExpectError - - flatten3dBy( 1, [ 2, 1, 2 ], false, identity, {} ); // $ExpectError - flatten3dBy( true, [ 2, 1, 2 ], false, identity, {} ); // $ExpectError - flatten3dBy( false, [ 2, 1, 2 ], false, identity, {} ); // $ExpectError - flatten3dBy( null, [ 2, 1, 2 ], false, identity, {} ); // $ExpectError - flatten3dBy( void 0, [ 2, 1, 2 ], false, identity, {} ); // $ExpectError - flatten3dBy( {}, [ 2, 1, 2 ], false, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - flatten3dBy( x, '', false, identity ); // $ExpectError - flatten3dBy( x, 1, false, identity ); // $ExpectError - flatten3dBy( x, true, false, identity ); // $ExpectError - flatten3dBy( x, false, false, identity ); // $ExpectError - flatten3dBy( x, null, false, identity ); // $ExpectError - flatten3dBy( x, void 0, false, identity ); // $ExpectError - flatten3dBy( x, {}, false, identity ); // $ExpectError - flatten3dBy( x, [ 1, '2', 3 ], false, identity ); // $ExpectError - flatten3dBy( x, ( x: number ): number => x, false, identity ); // $ExpectError - - flatten3dBy( x, '', false, identity, {} ); // $ExpectError - flatten3dBy( x, 1, false, identity, {} ); // $ExpectError - flatten3dBy( x, true, false, identity, {} ); // $ExpectError - flatten3dBy( x, false, false, identity, {} ); // $ExpectError - flatten3dBy( x, null, false, identity, {} ); // $ExpectError - flatten3dBy( x, void 0, false, identity, {} ); // $ExpectError - flatten3dBy( x, {}, false, identity, {} ); // $ExpectError - flatten3dBy( x, [ 1, '2', 3 ], false, identity, {} ); // $ExpectError - flatten3dBy( x, ( x: number ): number => x, false, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - flatten3dBy( x, [ 2, 1, 2 ], '', identity ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], 1, identity ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], null, identity ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], void 0, identity ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], {}, identity ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], [], identity ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], ( x: number ): number => x, identity ); // $ExpectError - - flatten3dBy( x, [ 2, 1, 2 ], '', identity, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], 1, identity, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], null, identity, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], void 0, identity, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], {}, identity, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], [], identity, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], ( x: number ): number => x, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a function... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - flatten3dBy( x, [ 2, 1, 2 ], false, '' ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, 1 ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, true ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, false ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, null ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, void 0 ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, [] ); // $ExpectError - - flatten3dBy( x, [ 2, 1, 2 ], false, '', {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, 1, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, true, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, false, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, null, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, void 0, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, {}, {} ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - flatten3dBy(); // $ExpectError - flatten3dBy( x ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ] ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false ); // $ExpectError - flatten3dBy( x, [ 2, 1, 2 ], false, identity, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - const out1 = [ 0, 0, 0, 0 ]; - - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out1, 1, 0, identity ); // $ExpectType Collection - flatten3dBy.assign( x, [ 2, 1, 2 ], true, out1, 1, 0, identity ); // $ExpectType Collection - - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out1, 1, 0, identity, {} ); // $ExpectType Collection - flatten3dBy.assign( x, [ 2, 1, 2 ], true, out1, 1, 0, identity, {} ); // $ExpectType Collection - - const out2 = [ '', '', '', '' ]; - - flatten3dBy.assign( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], false, out2, 1, 0, identity ); // $ExpectType Collection - flatten3dBy.assign( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], true, out2, 1, 0, identity ); // $ExpectType Collection - - flatten3dBy.assign( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], false, out2, 1, 0, identity, {} ); // $ExpectType Collection - flatten3dBy.assign( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], true, out2, 1, 0, identity, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - flatten3dBy.assign( 1, [ 2, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( true, [ 2, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( false, [ 2, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( null, [ 2, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( void 0, [ 2, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( {}, [ 2, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - - flatten3dBy.assign( 1, [ 2, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( true, [ 2, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( false, [ 2, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( null, [ 2, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( void 0, [ 2, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( {}, [ 2, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten3dBy.assign( x, '', false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, 1, false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, true, false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, false, false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, null, false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, void 0, false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, {}, false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 1, '2', 3 ], false, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, ( x: number ): number => x, false, out, 1, 0, identity ); // $ExpectError - - flatten3dBy.assign( x, '', false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, 1, false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, true, false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, false, false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, null, false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, void 0, false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, {}, false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 1, '2', 3 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, ( x: number ): number => x, false, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a boolean... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten3dBy.assign( x, [ 2, 1, 2 ], '', out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], 1, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], null, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], void 0, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], {}, out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], [], out, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], ( x: number ): number => x, out, 1, 0, identity ); // $ExpectError - - flatten3dBy.assign( x, [ 2, 1, 2 ], '', out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], 1, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], null, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], void 0, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], {}, out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], [], out, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], ( x: number ): number => x, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - flatten3dBy.assign( x, [ 2, 1, 2 ], false, 1, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, true, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, false, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, null, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, void 0, 1, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, {}, 1, 0, identity ); // $ExpectError - - flatten3dBy.assign( x, [ 2, 1, 2 ], false, 1, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, true, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, false, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, null, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, void 0, 1, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, {}, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, '1', 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, true, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, false, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, null, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, void 0, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, {}, 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, [], 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, ( x: number ): number => x, 0, identity ); // $ExpectError - - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, '1', 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, true, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, false, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, null, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, void 0, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, {}, 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, [], 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, ( x: number ): number => x, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, '1', identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, true, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, false, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, null, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, void 0, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, {}, identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, [], identity ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, ( x: number ): number => x, identity ); // $ExpectError - - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, '1', identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, true, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, false, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, null, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, void 0, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, {}, identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, [], identity, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, ( x: number ): number => x, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a seventh argument which is not a function... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, '1' ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, 1 ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, true ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, false ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, null ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, void 0 ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, [] ); // $ExpectError - - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, '1', {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, 1, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, true, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, false, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, null, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, void 0, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, {}, {} ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, [], {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten3dBy.assign(); // $ExpectError - flatten3dBy.assign( x ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ] ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1 ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten3dBy.assign( x, [ 2, 1, 2 ], false, out, 1, 0, identity, {}, {} ); // $ExpectError -} diff --git a/base/flatten3d-by/examples/index.js b/base/flatten3d-by/examples/index.js deleted file mode 100644 index 0ecbe47e1..000000000 --- a/base/flatten3d-by/examples/index.js +++ /dev/null @@ -1,72 +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'; - -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten3dBy = require( './../lib' ); - -var fcn = naryFunction( abs, 1 ); - -var x = [ - [ [ -1, -2 ], [ -3, -4 ] ], - [ [ -5, -6 ], [ -7, -8 ] ], - [ [ -9, -10 ], [ -11, -12 ] ], - [ [ -13, -14 ], [ -15, -16 ] ] -]; - -var out = flatten3dBy( x, [ 0, 0, 0 ], false, fcn ); -console.log( out ); -// => [] - -out = flatten3dBy( x, [ 0, 0, 0 ], true, fcn ); -console.log( out ); -// => [] - -out = flatten3dBy( x, [ 1, 1, 1 ], false, fcn ); -console.log( out ); -// => [ 1 ] - -out = flatten3dBy( x, [ 1, 1, 1 ], true, fcn ); -console.log( out ); -// => [ 1 ] - -out = flatten3dBy( x, [ 2, 2, 2 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten3dBy( x, [ 2, 2, 2 ], true, fcn ); -console.log( out ); -// => [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten3dBy( x, [ 3, 2, 2 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] - -out = flatten3dBy( x, [ 3, 2, 2 ], true, fcn ); -console.log( out ); -// => [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ] - -out = flatten3dBy( x, [ 4, 2, 2 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten3dBy( x, [ 4, 2, 2 ], true, fcn ); -console.log( out ); -// => [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ] diff --git a/base/flatten3d-by/lib/assign.js b/base/flatten3d-by/lib/assign.js deleted file mode 100644 index d011edf51..000000000 --- a/base/flatten3d-by/lib/assign.js +++ /dev/null @@ -1,111 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MAIN // - -/** -* Flattens a three-dimensional nested array according to a callback function and assigns elements to a provided output array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3dBy( x, [ 2, 1, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3dBy( x, [ 2, 1, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -function flatten3dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) { - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var a0; - var a1; - var io; - - // Extract loop variables: - S0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - - // Iterate over the array dimensions... - io = offset; - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - out[ io ] = clbk.call( thisArg, x[ i2 ][ i1 ][ i0 ], [ i2, i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order - io += stride; - } - } - } - return out; - } - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = x[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = clbk.call( thisArg, a0[ i0 ], [ i2, i1, i0 ], x ); // equivalent to storing in row-major (C-style) order - io += stride; - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten3dBy; diff --git a/base/flatten3d-by/lib/index.js b/base/flatten3d-by/lib/index.js deleted file mode 100644 index 533dad005..000000000 --- a/base/flatten3d-by/lib/index.js +++ /dev/null @@ -1,81 +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'; - -/** -* Flatten a three-dimensional nested array according to a callback function. -* -* @module @stdlib/array/base/flatten3d-by -* -* @example -* var flatten3dBy = require( '@stdlib/array/base/flatten3d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3dBy( x, [ 2, 1, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* var flatten3dBy = require( '@stdlib/array/base/flatten3d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3dBy( x, [ 2, 1, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var flatten3dBy = require( '@stdlib/array/base/flatten3d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = new Float64Array( 4 ); -* var y = flatten3dBy.assign( x, [ 2, 1, 2 ], true, out, 1, 0, scale ); -* // returns [ 2, 6, 4, 8 ] -* -* var bool = ( y === out ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flatten3d-by/lib/main.js b/base/flatten3d-by/lib/main.js deleted file mode 100644 index 96424c266..000000000 --- a/base/flatten3d-by/lib/main.js +++ /dev/null @@ -1,104 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MAIN // - -/** -* Flattens a three-dimensional nested array according to a callback function. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Array} flattened array -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3dBy( x, [ 2, 1, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3dBy( x, [ 2, 1, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -function flatten3dBy( x, shape, colexicographic, clbk, thisArg ) { - var out; - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var a0; - var a1; - - // Extract loop variables: - S0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - - // Initialize an output array: - out = []; - - // Iterate over the array dimensions... - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - out.push( clbk.call( thisArg, x[ i2 ][ i1 ][ i0 ], [ i2, i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order - } - } - } - return out; - } - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = x[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out.push( clbk.call( thisArg, a0[ i0 ], [ i2, i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten3dBy; diff --git a/base/flatten3d-by/package.json b/base/flatten3d-by/package.json deleted file mode 100644 index c7b48dc0b..000000000 --- a/base/flatten3d-by/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/flatten3d-by", - "version": "0.0.0", - "description": "Flatten a three-dimensional nested array according to a callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flatten", - "flat", - "3d", - "tensor", - "strided", - "ndarray", - "multidimensional", - "foreach", - "map", - "transform", - "callback", - "accessor" - ] -} diff --git a/base/flatten3d-by/test/test.assign.js b/base/flatten3d-by/test/test.assign.js deleted file mode 100644 index fffe7f0d9..000000000 --- a/base/flatten3d-by/test/test.assign.js +++ /dev/null @@ -1,399 +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 naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var Float64Array = require( './../../../float64' ); -var flatten3dBy = require( './../lib/assign.js' ); - - -// VARIABLES // - -var clbk = naryFunction( abs, 1 ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten3dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ], - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3dBy( x, [ 0, 0, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3dBy( x, [ 0, 0, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3dBy( x, [ 1, 0, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten3dBy( x, [ 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten3dBy( x, [ 1, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten3dBy( x, [ 2, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten3dBy( x, [ 2, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] ); - out = new Float64Array( 12 ); - actual = flatten3dBy( x, [ 3, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten3dBy( x, [ 4, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten3dBy( x, [ 4, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten3dBy( x, [ 4, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ], - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3dBy( x, [ 0, 0, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3dBy( x, [ 0, 0, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3dBy( x, [ 1, 0, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten3dBy( x, [ 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten3dBy( x, [ 1, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten3dBy( x, [ 2, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten3dBy( x, [ 2, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ] ); - out = new Float64Array( 12 ); - actual = flatten3dBy( x, [ 3, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten3dBy( x, [ 4, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten3dBy( x, [ 4, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten3dBy( x, [ 4, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten3dBy( x, [ 1, 2, 2 ], false, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 3, 0, 2, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten3dBy( x, [ 1, 2, 2 ], true, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten3dBy( x, [ 1, 2, 2 ], false, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 3, 2, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten3dBy( x, [ 1, 2, 2 ], true, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 3, 0, 2, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten3dBy( x, [ 1, 2, 2 ], false, out, -2, 7, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 2, 0, 3, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten3dBy( x, [ 1, 2, 2 ], true, out, -2, 7, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports setting the callback execution context (lexicographic)', function test( t ) { - var ctx; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flatten3dBy( x, [ 1, 2, 2 ], false, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 3, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic)', function test( t ) { - var ctx; - var out; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flatten3dBy( x, [ 1, 2, 2 ], true, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 3, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); diff --git a/base/flatten3d-by/test/test.js b/base/flatten3d-by/test/test.js deleted file mode 100644 index 61622e126..000000000 --- a/base/flatten3d-by/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var flatten3dBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten3dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( flatten3dBy, 'assign' ), true, 'has property' ); - t.strictEqual( typeof flatten3dBy.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/flatten3d-by/test/test.main.js b/base/flatten3d-by/test/test.main.js deleted file mode 100644 index 60887abf0..000000000 --- a/base/flatten3d-by/test/test.main.js +++ /dev/null @@ -1,238 +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 naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten3dBy = require( './../lib/main.js' ); - - -// VARIABLES // - -var clbk = naryFunction( abs, 1 ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten3dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ], - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ]; - - expected = []; - actual = flatten3dBy( x, [ 0, 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten3dBy( x, [ 0, 0, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten3dBy( x, [ 1, 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten3dBy( x, [ 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten3dBy( x, [ 1, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten3dBy( x, [ 2, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten3dBy( x, [ 2, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]; - actual = flatten3dBy( x, [ 3, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten3dBy( x, [ 4, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten3dBy( x, [ 4, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten3dBy( x, [ 4, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ], - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ]; - - expected = []; - actual = flatten3dBy( x, [ 0, 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten3dBy( x, [ 0, 0, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten3dBy( x, [ 1, 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten3dBy( x, [ 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten3dBy( x, [ 1, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten3dBy( x, [ 2, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten3dBy( x, [ 2, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ]; - actual = flatten3dBy( x, [ 3, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten3dBy( x, [ 4, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14 ]; - actual = flatten3dBy( x, [ 4, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ]; - actual = flatten3dBy( x, [ 4, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports setting the callback execution context (lexicographic)', function test( t ) { - var ctx; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - ctx = { - 'count': 0 - }; - - flatten3dBy( x, [ 1, 2, 2 ], false, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 3, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic)', function test( t ) { - var ctx; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - ctx = { - 'count': 0 - }; - - flatten3dBy( x, [ 1, 2, 2 ], true, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 3, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); diff --git a/base/flatten3d/README.md b/base/flatten3d/README.md deleted file mode 100644 index b204b3509..000000000 --- a/base/flatten3d/README.md +++ /dev/null @@ -1,164 +0,0 @@ - - -# flatten3d - -> Flatten a three-dimensional nested array. - -
- -## Usage - -```javascript -var flatten3d = require( '@stdlib/array/base/flatten3d' ); -``` - -#### flatten3d( x, shape, colexicographic ) - -Flattens a three-dimensional nested array. - -```javascript -var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - -var out = flatten3d( x, [ 2, 1, 2 ], false ); -// returns [ 1, 2, 3, 4 ] -``` - -To flatten in colexicographic order, provide a third argument equal to `true`. - -```javascript -var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - -var out = flatten3d( x, [ 2, 1, 2 ], true ); -// returns [ 1, 3, 2, 4 ] -``` - -#### flatten3d.assign( x, shape, colexicographic, out, stride, offset ) - -Flattens a three-dimensional nested array and assigns elements to a provided output array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -var out = new Float64Array( 4 ); - -var y = flatten3d.assign( x, [ 2, 1, 2 ], false, out, 1, 0 ); -// returns [ 1, 2, 3, 4 ] - -var bool = ( y === out ); -// returns true - -y = flatten3d.assign( x, [ 2, 1, 2 ], true, out, 1, 0 ); -// returns [ 1, 3, 2, 4 ] -``` - -
- - - -
- -## Notes - -- Both functions assume that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - -
- - - -
- -## Examples - - - -```javascript -var flatten3d = require( '@stdlib/array/base/flatten3d' ); - -var x = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ], - [ [ 9, 10 ], [ 11, 12 ] ], - [ [ 13, 14 ], [ 15, 16 ] ] -]; - -var out = flatten3d( x, [ 0, 0, 0 ], false ); -// returns [] - -out = flatten3d( x, [ 0, 0, 0 ], true ); -// returns [] - -out = flatten3d( x, [ 1, 1, 1 ], false ); -// returns [ 1 ] - -out = flatten3d( x, [ 1, 1, 1 ], true ); -// returns [ 1 ] - -out = flatten3d( x, [ 2, 2, 2 ], false ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten3d( x, [ 2, 2, 2 ], true ); -// returns [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten3d( x, [ 3, 2, 2 ], false ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] - -out = flatten3d( x, [ 3, 2, 2 ], true ); -// returns [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ] - -out = flatten3d( x, [ 4, 2, 2 ], false ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten3d( x, [ 4, 2, 2 ], true ); -// returns [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/flatten3d/benchmark/benchmark.js b/base/flatten3d/benchmark/benchmark.js deleted file mode 100644 index 3c8da1d51..000000000 --- a/base/flatten3d/benchmark/benchmark.js +++ /dev/null @@ -1,125 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var zeroTo = require( './../../../base/zero-to' ); -var filled = require( './../../../base/filled' ); -var Float64Array = require( './../../../float64' ); -var pkg = require( './../package.json' ).name; -var flatten3d = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=125,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten3d( x, [ 5, 5, 5 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':size=125,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten3d( x, [ 5, 5, 5 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=125,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 125 ); - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten3d.assign( x, [ 5, 5, 5 ], false, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=125,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 125 ); - x = filled( filled( zeroTo( 5 ), 5 ), 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten3d.assign( x, [ 5, 5, 5 ], true, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/flatten3d/docs/repl.txt b/base/flatten3d/docs/repl.txt deleted file mode 100644 index 8a5b10b58..000000000 --- a/base/flatten3d/docs/repl.txt +++ /dev/null @@ -1,80 +0,0 @@ - -{{alias}}( x, shape, colexicographic ) - Flattens a three-dimensional nested array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - shape: Array - Array shape. - - colexicographic: boolean - Specifies whether to flatten array values in colexicographic order. - - Returns - ------- - out: Array - Flattened array. - - Examples - -------- - > var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - > var out = {{alias}}( x, [ 2, 1, 2 ], false ) - [ 1, 2, 3, 4 ] - > out = {{alias}}( x, [ 2, 1, 2 ], true ) - [ 1, 3, 2, 4 ] - - -{{alias}}.assign( x, shape, colexicographic, out, stride, offset ) - Flattens a three-dimensional nested array and assigns elements to a provided - output array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colexicographic: boolean - Specifies whether to flatten array values in colexicographic order. - - out: Collection - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - > var out = [ 0, 0, 0, 0 ]; - > var v = {{alias}}.assign( x, [ 2, 1, 2 ], false, out, 1, 0 ) - [ 1, 2, 3, 4 ] - > var bool = ( v === out ) - true - > out = [ 0, 0, 0, 0 ]; - > {{alias}}.assign( x, [ 2, 1, 2 ], true, out, 1, 0 ); - > out - [ 1, 3, 2, 4 ] - - See Also - -------- - diff --git a/base/flatten3d/docs/types/index.d.ts b/base/flatten3d/docs/types/index.d.ts deleted file mode 100644 index 96b74e8ff..000000000 --- a/base/flatten3d/docs/types/index.d.ts +++ /dev/null @@ -1,119 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Array3D } from '@stdlib/types/array'; -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Interface describing `flatten3d`. -*/ -interface Flatten3d { - /** - * Flattens a three-dimensional nested array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @returns flattened array - * - * @example - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * var out = flatten3d( x, [ 2, 1, 2 ], false ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * var out = flatten3d( x, [ 2, 1, 2 ], true ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array3D, shape: Shape3D, colexicographic: boolean ): Array; - - /** - * Flattens a three-dimensional nested array and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * var out = flatten3d.assign( x, [ 2, 1, 2 ], false, new Float64Array( 4 ), 1, 0 ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - * - * var out = flatten3d.assign( x, [ 2, 1, 2 ], true, new Float64Array( 4 ), 1, 0 ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array3D, shape: Shape3D, colexicographic: boolean, out: Collection, stride: number, offset: number ): Collection; -} - -/** -* Flattens a three-dimensional nested array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param x - input array -* @param shape - array shape -* @param colexicographic - specifies whether to flatten array values in colexicographic order -* @returns flattened array -* -* @example -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3d( x, [ 2, 1, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3d( x, [ 2, 1, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -*/ -declare var flatten3d: Flatten3d; - - -// EXPORTS // - -export = flatten3d; diff --git a/base/flatten3d/docs/types/test.ts b/base/flatten3d/docs/types/test.ts deleted file mode 100644 index 018e8a4da..000000000 --- a/base/flatten3d/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -import flatten3d = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - flatten3d( x, [ 2, 1, 2 ], false ); // $ExpectType number[] - flatten3d( x, [ 2, 1, 2 ], true ); // $ExpectType number[] - - flatten3d( x, [ 2, 1, 2 ], false ); // $ExpectType number[] - flatten3d( x, [ 2, 1, 2 ], true ); // $ExpectType number[] - - flatten3d( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], false ); // $ExpectType string[] - flatten3d( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], true ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - flatten3d( 1, [ 2, 1, 2 ], false ); // $ExpectError - flatten3d( true, [ 2, 1, 2 ], false ); // $ExpectError - flatten3d( false, [ 2, 1, 2 ], false ); // $ExpectError - flatten3d( null, [ 2, 1, 2 ], false ); // $ExpectError - flatten3d( void 0, [ 2, 1, 2 ], false ); // $ExpectError - flatten3d( {}, [ 2, 1, 2 ], false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - flatten3d( x, '', false ); // $ExpectError - flatten3d( x, 1, false ); // $ExpectError - flatten3d( x, true, false ); // $ExpectError - flatten3d( x, false, false ); // $ExpectError - flatten3d( x, null, false ); // $ExpectError - flatten3d( x, void 0, false ); // $ExpectError - flatten3d( x, {}, false ); // $ExpectError - flatten3d( x, [ 1, '2', 3 ], false ); // $ExpectError - flatten3d( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - flatten3d( x, [ 2, 1, 2 ], '' ); // $ExpectError - flatten3d( x, [ 2, 1, 2 ], 1 ); // $ExpectError - flatten3d( x, [ 2, 1, 2 ], null ); // $ExpectError - flatten3d( x, [ 2, 1, 2 ], void 0 ); // $ExpectError - flatten3d( x, [ 2, 1, 2 ], {} ); // $ExpectError - flatten3d( x, [ 2, 1, 2 ], [] ); // $ExpectError - flatten3d( x, [ 2, 1, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - flatten3d(); // $ExpectError - flatten3d( x ); // $ExpectError - flatten3d( x, [ 2, 1, 2 ] ); // $ExpectError - flatten3d( x, [ 2, 1, 2 ], false, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - const out1 = [ 0, 0, 0, 0 ]; - - flatten3d.assign( x, [ 2, 1, 2 ], false, out1, 1, 0 ); // $ExpectType Collection - flatten3d.assign( x, [ 2, 1, 2 ], true, out1, 1, 0 ); // $ExpectType Collection - - flatten3d.assign( x, [ 2, 1, 2 ], false, out1, 1, 0 ); // $ExpectType Collection - flatten3d.assign( x, [ 2, 1, 2 ], true, out1, 1, 0 ); // $ExpectType Collection - - const out2 = [ '', '', '', '' ]; - - flatten3d.assign( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], false, out2, 1, 0 ); // $ExpectType Collection - flatten3d.assign( [ [ [ '1', '2' ] ], [ [ '3', '4' ] ] ], [ 2, 1, 2 ], true, out2, 1, 0 ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - flatten3d.assign( 1, [ 2, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten3d.assign( true, [ 2, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten3d.assign( false, [ 2, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten3d.assign( null, [ 2, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten3d.assign( void 0, [ 2, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten3d.assign( {}, [ 2, 1, 2 ], false, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten3d.assign( x, '', false, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, 1, false, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, true, false, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, false, false, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, null, false, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, void 0, false, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, {}, false, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 1, '2', 3 ], false, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, ( x: number ): number => x, false, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a boolean... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten3d.assign( x, [ 2, 1, 2 ], '', out, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], 1, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], null, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], void 0, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], {}, out, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], [], out, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], ( x: number ): number => x, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - - flatten3d.assign( x, [ 2, 1, 2 ], false, 1, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, true, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, false, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, null, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, void 0, 1, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten3d.assign( x, [ 2, 1, 2 ], false, out, '1', 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, true, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, false, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, null, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, void 0, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, {}, 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, [], 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten3d.assign( x, [ 2, 1, 2 ], false, out, 1, '1' ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, 1, true ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, 1, false ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, 1, null ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, 1, void 0 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, 1, {} ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, 1, [] ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten3d.assign(); // $ExpectError - flatten3d.assign( x ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ] ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, 1 ); // $ExpectError - flatten3d.assign( x, [ 2, 1, 2 ], false, out, 1, 0, {} ); // $ExpectError -} diff --git a/base/flatten3d/examples/index.js b/base/flatten3d/examples/index.js deleted file mode 100644 index 968cd61f0..000000000 --- a/base/flatten3d/examples/index.js +++ /dev/null @@ -1,68 +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'; - -var flatten3d = require( './../lib' ); - -var x = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ], - [ [ 9, 10 ], [ 11, 12 ] ], - [ [ 13, 14 ], [ 15, 16 ] ] -]; - -var out = flatten3d( x, [ 0, 0, 0 ], false ); -console.log( out ); -// => [] - -out = flatten3d( x, [ 0, 0, 0 ], true ); -console.log( out ); -// => [] - -out = flatten3d( x, [ 1, 1, 1 ], false ); -console.log( out ); -// => [ 1 ] - -out = flatten3d( x, [ 1, 1, 1 ], true ); -console.log( out ); -// => [ 1 ] - -out = flatten3d( x, [ 2, 2, 2 ], false ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten3d( x, [ 2, 2, 2 ], true ); -console.log( out ); -// => [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten3d( x, [ 3, 2, 2 ], false ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] - -out = flatten3d( x, [ 3, 2, 2 ], true ); -console.log( out ); -// => [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ] - -out = flatten3d( x, [ 4, 2, 2 ], false ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten3d( x, [ 4, 2, 2 ], true ); -console.log( out ); -// => [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ] diff --git a/base/flatten3d/lib/assign.js b/base/flatten3d/lib/assign.js deleted file mode 100644 index 3f55022a6..000000000 --- a/base/flatten3d/lib/assign.js +++ /dev/null @@ -1,99 +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'; - -// MAIN // - -/** -* Flattens a three-dimensional nested array and assigns elements to a provided output array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3d( x, [ 2, 1, 2 ], false, new Float64Array( 4 ), 1, 0 ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3d( x, [ 2, 1, 2 ], true, new Float64Array( 4 ), 1, 0 ); -* // returns [ 1, 3, 2, 4 ] -*/ -function flatten3d( x, shape, colexicographic, out, stride, offset ) { - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var a0; - var a1; - var io; - - // Extract loop variables: - S0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - - // Iterate over the array dimensions... - io = offset; - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - out[ io ] = x[ i2 ][ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order - io += stride; - } - } - } - return out; - } - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = x[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order - io += stride; - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten3d; diff --git a/base/flatten3d/lib/index.js b/base/flatten3d/lib/index.js deleted file mode 100644 index d209ddd1e..000000000 --- a/base/flatten3d/lib/index.js +++ /dev/null @@ -1,69 +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'; - -/** -* Flatten a three-dimensional nested array. -* -* @module @stdlib/array/base/flatten3d -* -* @example -* var flatten3d = require( '@stdlib/array/base/flatten3d' ); -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3d( x, [ 2, 1, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var flatten3d = require( '@stdlib/array/base/flatten3d' ); -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3d( x, [ 2, 1, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var flatten3d = require( '@stdlib/array/base/flatten3d' ); -* -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = new Float64Array( 4 ); -* var y = flatten3d.assign( x, [ 2, 1, 2 ], true, out, 1, 0 ); -* // returns [ 1, 3, 2, 4 ] -* -* var bool = ( y === out ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flatten3d/lib/main.js b/base/flatten3d/lib/main.js deleted file mode 100644 index 4b4ba790e..000000000 --- a/base/flatten3d/lib/main.js +++ /dev/null @@ -1,92 +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'; - -// MAIN // - -/** -* Flattens a three-dimensional nested array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @returns {Array} flattened array -* -* @example -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3d( x, [ 2, 1, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ]; -* -* var out = flatten3d( x, [ 2, 1, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -*/ -function flatten3d( x, shape, colexicographic ) { - var out; - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var a0; - var a1; - - // Extract loop variables: - S0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - - // Initialize an output array: - out = []; - - // Iterate over the array dimensions... - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - out.push( x[ i2 ][ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order - } - } - } - return out; - } - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = x[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten3d; diff --git a/base/flatten3d/package.json b/base/flatten3d/package.json deleted file mode 100644 index 09feb26c3..000000000 --- a/base/flatten3d/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/flatten3d", - "version": "0.0.0", - "description": "Flatten a three-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flatten", - "flat", - "3d", - "tensor", - "strided", - "ndarray", - "multidimensional" - ] -} diff --git a/base/flatten3d/test/test.assign.js b/base/flatten3d/test/test.assign.js deleted file mode 100644 index 6508bfbd9..000000000 --- a/base/flatten3d/test/test.assign.js +++ /dev/null @@ -1,332 +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 Float64Array = require( './../../../float64' ); -var flatten3d = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ], - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3d( x, [ 0, 0, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3d( x, [ 0, 0, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3d( x, [ 1, 0, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten3d( x, [ 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten3d( x, [ 1, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten3d( x, [ 2, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten3d( x, [ 2, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] ); - out = new Float64Array( 12 ); - actual = flatten3d( x, [ 3, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten3d( x, [ 4, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten3d( x, [ 4, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten3d( x, [ 4, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ], - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3d( x, [ 0, 0, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3d( x, [ 0, 0, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten3d( x, [ 1, 0, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten3d( x, [ 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten3d( x, [ 1, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5 ] ); - out = new Float64Array( 2 ); - actual = flatten3d( x, [ 2, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten3d( x, [ 2, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ] ); - out = new Float64Array( 12 ); - actual = flatten3d( x, [ 3, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten3d( x, [ 4, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 2, 6, 10, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten3d( x, [ 4, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten3d( x, [ 4, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten3d( x, [ 1, 2, 2 ], false, out, 2, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 3, 0, 2, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten3d( x, [ 1, 2, 2 ], true, out, 2, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten3d( x, [ 1, 2, 2 ], false, out, 1, 2 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 3, 2, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten3d( x, [ 1, 2, 2 ], true, out, 1, 2 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 3, 0, 2, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten3d( x, [ 1, 2, 2 ], false, out, -2, 7 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 2, 0, 3, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten3d( x, [ 1, 2, 2 ], true, out, -2, 7 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flatten3d/test/test.js b/base/flatten3d/test/test.js deleted file mode 100644 index ce3ccd025..000000000 --- a/base/flatten3d/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var flatten3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( flatten3d, 'assign' ), true, 'has property' ); - t.strictEqual( typeof flatten3d.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/flatten3d/test/test.main.js b/base/flatten3d/test/test.main.js deleted file mode 100644 index 326678a14..000000000 --- a/base/flatten3d/test/test.main.js +++ /dev/null @@ -1,175 +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 flatten3d = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ], - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ]; - - expected = []; - actual = flatten3d( x, [ 0, 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten3d( x, [ 0, 0, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten3d( x, [ 1, 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten3d( x, [ 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten3d( x, [ 1, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten3d( x, [ 2, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten3d( x, [ 2, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]; - actual = flatten3d( x, [ 3, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten3d( x, [ 4, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten3d( x, [ 4, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten3d( x, [ 4, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ], - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ]; - - expected = []; - actual = flatten3d( x, [ 0, 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten3d( x, [ 0, 0, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten3d( x, [ 1, 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten3d( x, [ 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten3d( x, [ 1, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5 ]; - actual = flatten3d( x, [ 2, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten3d( x, [ 2, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 3, 7, 11, 2, 6, 10, 4, 8, 12 ]; - actual = flatten3d( x, [ 3, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten3d( x, [ 4, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 2, 6, 10, 14 ]; - actual = flatten3d( x, [ 4, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13, 3, 7, 11, 15, 2, 6, 10, 14, 4, 8, 12, 16 ]; - actual = flatten3d( x, [ 4, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flatten4d-by/README.md b/base/flatten4d-by/README.md deleted file mode 100644 index 4a32d57ac..000000000 --- a/base/flatten4d-by/README.md +++ /dev/null @@ -1,209 +0,0 @@ - - - - -# flatten4dBy - -> Flatten a four-dimensional nested array according to a callback function. - -
- -## Usage - -```javascript -var flatten4dBy = require( '@stdlib/array/base/flatten4d-by' ); -``` - -#### flatten4dBy( x, shape, colexicographic, clbk\[, thisArg] ) - -Flattens a four-dimensional nested array according to a callback function. - -```javascript -function scale( v ) { - return v * 2; -} - -var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - -var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, scale ); -// returns [ 2, 4, 6, 8 ] -``` - -To flatten in colexicographic order, provide a third argument equal to `true`. - -```javascript -function scale( v ) { - return v * 2; -} - -var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - -var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, scale ); -// returns [ 2, 6, 4, 8 ] -``` - -To set the callback execution context, provide a `thisArg` argument. - - - -```javascript -function scale( v ) { - this.count += 1; - return v * 2; -} - -var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -var ctx = { - 'count': 0 -}; - -var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, scale, ctx ); -// returns [ 2, 4, 6, 8 ] - -var count = ctx.count; -// returns 4 -``` - -#### flatten4dBy.assign( x, shape, colexicographic, out, stride, offset, clbk\[, thisArg] ) - -Flattens a four-dimensional nested array according to a callback function and assigns elements to a provided output array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -function scale( v ) { - return v * 2; -} - -var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -var out = new Float64Array( 4 ); - -var y = flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, scale ); -// returns [ 2, 4, 6, 8 ] - -var bool = ( y === out ); -// returns true - -y = flatten4dBy.assign( x, [ 2, 1, 1, 2 ], true, out, 1, 0, scale ); -// returns [ 2, 6, 4, 8 ] -``` - -
- - - -
- -## Notes - -- A callback function is provided the following arguments: - - - **value**: nested array element. - - **indices**: element indices (in lexicographic order). - - **arr**: the input array. - -- Both functions assume that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - -
- - - -
- -## Examples - - - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten4dBy = require( '@stdlib/array/base/flatten4d-by' ); - -var fcn = naryFunction( abs, 1 ); - -// Define a 2x2x2x2 array: -var x = [ - [ - [ [ -1, -2 ], [ -3, -4 ] ], - [ [ -5, -6 ], [ -7, -8 ] ] - ], - [ - [ [ -9, -10 ], [ -11, -12 ] ], - [ [ -13, -14 ], [ -15, -16 ] ] - ] -]; - -var out = flatten4dBy( x, [ 0, 0, 0, 0 ], false, fcn ); -// returns [] - -out = flatten4dBy( x, [ 0, 0, 0, 0 ], true, fcn ); -// returns [] - -out = flatten4dBy( x, [ 1, 1, 1, 1 ], false, fcn ); -// returns [ 1 ] - -out = flatten4dBy( x, [ 1, 1, 1, 1 ], true, fcn ); -// returns [ 1 ] - -out = flatten4dBy( x, [ 1, 2, 2, 2 ], false, fcn ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten4dBy( x, [ 1, 2, 2, 2 ], true, fcn ); -// returns [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten4dBy( x, [ 2, 2, 2, 2 ], false, fcn ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten4dBy( x, [ 2, 2, 2, 2 ], true, fcn ); -// returns [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/flatten4d-by/benchmark/benchmark.js b/base/flatten4d-by/benchmark/benchmark.js deleted file mode 100644 index eabcfb417..000000000 --- a/base/flatten4d-by/benchmark/benchmark.js +++ /dev/null @@ -1,143 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var zeroTo = require( './../../../base/zero-to' ); -var filled = require( './../../../base/filled' ); -var Float64Array = require( './../../../float64' ); -var pkg = require( './../package.json' ).name; -var flatten4dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Scales an input value. -* -* @private -* @param {number} v - input value -* @returns {number} output value -* -* @example -* var v = scale( 2.0 ); -* // returns 4.0 -*/ -function scale( v ) { - return v * 2.0; -} - - -// MAIN // - -bench( pkg+':size=144,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten4dBy( x, [ 4, 3, 4, 3 ], false, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':size=144,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten4dBy( x, [ 4, 3, 4, 3 ], true, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=144,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 144 ); - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten4dBy.assign( x, [ 4, 3, 4, 3 ], false, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=144,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 144 ); - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten4dBy.assign( x, [ 4, 3, 4, 3 ], true, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/flatten4d-by/docs/repl.txt b/base/flatten4d-by/docs/repl.txt deleted file mode 100644 index 18ce60bf3..000000000 --- a/base/flatten4d-by/docs/repl.txt +++ /dev/null @@ -1,100 +0,0 @@ - -{{alias}}( x, shape, colex, clbk[, thisArg] ) - Flattens a four-dimensional nested array according to a callback function. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - shape: Array - Array shape. - - colex: boolean - Specifies whether to flatten array values in colexicographic order. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Flattened array. - - Examples - -------- - > function fcn( v ) { return v * 2; }; - > var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - > var out = {{alias}}( x, [ 2, 1, 1, 2 ], false, fcn ) - [ 2, 4, 6, 8 ] - > out = {{alias}}( x, [ 2, 1, 1, 2 ], true, fcn ) - [ 2, 6, 4, 8 ] - - -{{alias}}.assign( x, shape, colex, out, stride, offset, clbk[, thisArg] ) - Flattens a four-dimensional nested array according to a callback function - and assigns elements to a provided output array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - The callback function is provided the following arguments: - - - value: nested array element. - - indices: element indices (in lexicographic order). - - arr: the input array. - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colex: boolean - Specifies whether to flatten array values in colexicographic order. - - out: Collection - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function fcn( v ) { return v * 2; }; - > var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - > var out = [ 0, 0, 0, 0 ]; - > var v = {{alias}}.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, fcn ) - [ 2, 4, 6, 8 ] - > var bool = ( v === out ) - true - > out = [ 0, 0, 0, 0 ]; - > {{alias}}.assign( x, [ 2, 1, 1, 2 ], true, out, 1, 0, fcn ); - > out - [ 2, 6, 4, 8 ] - - See Also - -------- - diff --git a/base/flatten4d-by/docs/types/index.d.ts b/base/flatten4d-by/docs/types/index.d.ts deleted file mode 100644 index 43b4349b4..000000000 --- a/base/flatten4d-by/docs/types/index.d.ts +++ /dev/null @@ -1,191 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Nullary callback function. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Unary callback function. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Binary callback function. -* -* @param value - array element -* @param indices - element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Array ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Array, arr: Array4D ) => U; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `flatten4dBy`. -*/ -interface Flatten4dBy { - /** - * Flattens a four-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, scale ); - * // returns [ 2, 4, 6, 8 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, scale ); - * // returns [ 2, 6, 4, 8 ] - */ - ( x: Array4D, shape: Shape4D, colexicographic: boolean, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a four-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = flatten4dBy.assign( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 2, 4, 6, 8 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = flatten4dBy.assign( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 2, 6, 4, 8 ] - */ - assign( x: Array4D, shape: Shape4D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Flattens a four-dimensional nested array according to a callback function. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param x - input array -* @param shape - array shape -* @param colexicographic - specifies whether to flatten array values in colexicographic order -* @returns flattened array -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -declare var flatten4dBy: Flatten4dBy; - - -// EXPORTS // - -export = flatten4dBy; diff --git a/base/flatten4d-by/docs/types/test.ts b/base/flatten4d-by/docs/types/test.ts deleted file mode 100644 index 3161da12d..000000000 --- a/base/flatten4d-by/docs/types/test.ts +++ /dev/null @@ -1,340 +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. -*/ - -import flatten4dBy = require( './index' ); - -/** -* Identity function. -* -* @param value - input value -* @returns input value -*/ -function identity( value: T ): T { - return value; -} - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - flatten4dBy( x, [ 2, 1, 1, 2 ], false, identity ); // $ExpectType number[] - flatten4dBy( x, [ 2, 1, 1, 2 ], true, identity ); // $ExpectType number[] - - flatten4dBy( x, [ 2, 1, 1, 2 ], false, identity, {} ); // $ExpectType number[] - flatten4dBy( x, [ 2, 1, 1, 2 ], true, identity, {} ); // $ExpectType number[] - - flatten4dBy( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], false, identity ); // $ExpectType string[] - flatten4dBy( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], true, identity ); // $ExpectType string[] - - flatten4dBy( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], false, identity, {} ); // $ExpectType string[] - flatten4dBy( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], true, identity, {} ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - flatten4dBy( 1, [ 2, 1, 1, 2 ], false, identity ); // $ExpectError - flatten4dBy( true, [ 2, 1, 1, 2 ], false, identity ); // $ExpectError - flatten4dBy( false, [ 2, 1, 1, 2 ], false, identity ); // $ExpectError - flatten4dBy( null, [ 2, 1, 1, 2 ], false, identity ); // $ExpectError - flatten4dBy( void 0, [ 2, 1, 1, 2 ], false, identity ); // $ExpectError - flatten4dBy( {}, [ 2, 1, 1, 2 ], false, identity ); // $ExpectError - - flatten4dBy( 1, [ 2, 1, 1, 2 ], false, identity, {} ); // $ExpectError - flatten4dBy( true, [ 2, 1, 1, 2 ], false, identity, {} ); // $ExpectError - flatten4dBy( false, [ 2, 1, 1, 2 ], false, identity, {} ); // $ExpectError - flatten4dBy( null, [ 2, 1, 1, 2 ], false, identity, {} ); // $ExpectError - flatten4dBy( void 0, [ 2, 1, 1, 2 ], false, identity, {} ); // $ExpectError - flatten4dBy( {}, [ 2, 1, 1, 2 ], false, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - flatten4dBy( x, '', false, identity ); // $ExpectError - flatten4dBy( x, 1, false, identity ); // $ExpectError - flatten4dBy( x, true, false, identity ); // $ExpectError - flatten4dBy( x, false, false, identity ); // $ExpectError - flatten4dBy( x, null, false, identity ); // $ExpectError - flatten4dBy( x, void 0, false, identity ); // $ExpectError - flatten4dBy( x, {}, false, identity ); // $ExpectError - flatten4dBy( x, [ 1, '2', 3 ], false, identity ); // $ExpectError - flatten4dBy( x, ( x: number ): number => x, false, identity ); // $ExpectError - - flatten4dBy( x, '', false, identity, {} ); // $ExpectError - flatten4dBy( x, 1, false, identity, {} ); // $ExpectError - flatten4dBy( x, true, false, identity, {} ); // $ExpectError - flatten4dBy( x, false, false, identity, {} ); // $ExpectError - flatten4dBy( x, null, false, identity, {} ); // $ExpectError - flatten4dBy( x, void 0, false, identity, {} ); // $ExpectError - flatten4dBy( x, {}, false, identity, {} ); // $ExpectError - flatten4dBy( x, [ 1, '2', 3 ], false, identity, {} ); // $ExpectError - flatten4dBy( x, ( x: number ): number => x, false, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - flatten4dBy( x, [ 2, 1, 1, 2 ], '', identity ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], 1, identity ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], null, identity ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], void 0, identity ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], {}, identity ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], [], identity ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], ( x: number ): number => x, identity ); // $ExpectError - - flatten4dBy( x, [ 2, 1, 1, 2 ], '', identity, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], 1, identity, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], null, identity, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], void 0, identity, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], {}, identity, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], [], identity, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], ( x: number ): number => x, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a function... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - flatten4dBy( x, [ 2, 1, 1, 2 ], false, '' ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, 1 ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, true ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, false ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, null ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, void 0 ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, [] ); // $ExpectError - - flatten4dBy( x, [ 2, 1, 1, 2 ], false, '', {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, 1, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, true, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, false, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, null, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, void 0, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, {}, {} ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - flatten4dBy(); // $ExpectError - flatten4dBy( x ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ] ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false ); // $ExpectError - flatten4dBy( x, [ 2, 1, 1, 2 ], false, identity, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - const out1 = [ 0, 0, 0, 0 ]; - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out1, 1, 0, identity ); // $ExpectType Collection - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], true, out1, 1, 0, identity ); // $ExpectType Collection - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out1, 1, 0, identity, {} ); // $ExpectType Collection - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], true, out1, 1, 0, identity, {} ); // $ExpectType Collection - - const out2 = [ '', '', '', '' ]; - - flatten4dBy.assign( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], false, out2, 1, 0, identity ); // $ExpectType Collection - flatten4dBy.assign( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], true, out2, 1, 0, identity ); // $ExpectType Collection - - flatten4dBy.assign( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], false, out2, 1, 0, identity, {} ); // $ExpectType Collection - flatten4dBy.assign( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], true, out2, 1, 0, identity, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - flatten4dBy.assign( 1, [ 2, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( true, [ 2, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( false, [ 2, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( null, [ 2, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( void 0, [ 2, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( {}, [ 2, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - - flatten4dBy.assign( 1, [ 2, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( true, [ 2, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( false, [ 2, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( null, [ 2, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( void 0, [ 2, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( {}, [ 2, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten4dBy.assign( x, '', false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, 1, false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, true, false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, false, false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, null, false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, void 0, false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, {}, false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 1, '2', 3 ], false, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, ( x: number ): number => x, false, out, 1, 0, identity ); // $ExpectError - - flatten4dBy.assign( x, '', false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, 1, false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, true, false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, false, false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, null, false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, void 0, false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, {}, false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 1, '2', 3 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, ( x: number ): number => x, false, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a boolean... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], '', out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], 1, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], null, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], void 0, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], {}, out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], [], out, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], ( x: number ): number => x, out, 1, 0, identity ); // $ExpectError - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], '', out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], 1, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], null, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], void 0, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], {}, out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], [], out, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], ( x: number ): number => x, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, 1, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, true, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, false, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, null, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, void 0, 1, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, {}, 1, 0, identity ); // $ExpectError - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, 1, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, true, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, false, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, null, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, void 0, 1, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, {}, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, '1', 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, true, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, false, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, null, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, void 0, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, {}, 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, [], 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, ( x: number ): number => x, 0, identity ); // $ExpectError - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, '1', 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, true, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, false, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, null, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, void 0, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, {}, 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, [], 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, ( x: number ): number => x, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, '1', identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, true, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, false, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, null, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, void 0, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, {}, identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, [], identity ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, ( x: number ): number => x, identity ); // $ExpectError - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, '1', identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, true, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, false, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, null, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, void 0, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, {}, identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, [], identity, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, ( x: number ): number => x, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a seventh argument which is not a function... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, '1' ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, 1 ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, true ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, false ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, null ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, void 0 ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, [] ); // $ExpectError - - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, '1', {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, 1, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, true, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, false, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, null, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, void 0, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, {}, {} ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, [], {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten4dBy.assign(); // $ExpectError - flatten4dBy.assign( x ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ] ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1 ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten4dBy.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, identity, {}, {} ); // $ExpectError -} diff --git a/base/flatten4d-by/examples/index.js b/base/flatten4d-by/examples/index.js deleted file mode 100644 index eb5f6a341..000000000 --- a/base/flatten4d-by/examples/index.js +++ /dev/null @@ -1,69 +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'; - -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten4dBy = require( './../lib' ); - -var fcn = naryFunction( abs, 1 ); - -// Define a 2x2x2x2 array: -var x = [ - [ - [ [ -1, -2 ], [ -3, -4 ] ], - [ [ -5, -6 ], [ -7, -8 ] ] - ], - [ - [ [ -9, -10 ], [ -11, -12 ] ], - [ [ -13, -14 ], [ -15, -16 ] ] - ] -]; - -var out = flatten4dBy( x, [ 0, 0, 0, 0 ], false, fcn ); -console.log( out ); -// => [] - -out = flatten4dBy( x, [ 0, 0, 0, 0 ], true, fcn ); -console.log( out ); -// => [] - -out = flatten4dBy( x, [ 1, 1, 1, 1 ], false, fcn ); -console.log( out ); -// => [ 1 ] - -out = flatten4dBy( x, [ 1, 1, 1, 1 ], true, fcn ); -console.log( out ); -// => [ 1 ] - -out = flatten4dBy( x, [ 1, 2, 2, 2 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten4dBy( x, [ 1, 2, 2, 2 ], true, fcn ); -console.log( out ); -// => [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten4dBy( x, [ 2, 2, 2, 2 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten4dBy( x, [ 2, 2, 2, 2 ], true, fcn ); -console.log( out ); -// => [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] diff --git a/base/flatten4d-by/lib/assign.js b/base/flatten4d-by/lib/assign.js deleted file mode 100644 index cc8749f31..000000000 --- a/base/flatten4d-by/lib/assign.js +++ /dev/null @@ -1,120 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MAIN // - -/** -* Flattens a four-dimensional nested array according to a callback function and assigns elements to a provided output array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -function flatten4dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var a0; - var a1; - var a2; - var io; - - // Extract loop variables: - S0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - - // Iterate over the array dimensions... - io = offset; - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - for ( i3 = 0; i3 < S3; i3++ ) { - out[ io ] = clbk.call( thisArg, x[ i3 ][ i2 ][ i1 ][ i0 ], [ i3, i2, i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order - io += stride; - } - } - } - } - return out; - } - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = x[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = a2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = clbk.call( thisArg, a0[ i0 ], [ i3, i2, i1, i0 ], x ); // equivalent to storing in row-major (C-style) order - io += stride; - } - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten4dBy; diff --git a/base/flatten4d-by/lib/index.js b/base/flatten4d-by/lib/index.js deleted file mode 100644 index 1a8648cde..000000000 --- a/base/flatten4d-by/lib/index.js +++ /dev/null @@ -1,82 +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'; - -/** -* Flatten a four-dimensional nested array according to a callback function. -* -* @module @stdlib/array/base/flatten4d-by -* -* @example -* var flatten4dBy = require( '@stdlib/array/base/flatten4d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* var flatten4dBy = require( '@stdlib/array/base/flatten4d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var flatten4dBy = require( '@stdlib/array/base/flatten4d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = new Float64Array( 4 ); -* var y = flatten4dBy.assign( x, [ 2, 1, 1, 2 ], true, out, 1, 0, scale ); -* // returns [ 2, 6, 4, 8 ] -* -* var bool = ( y === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flatten4d-by/lib/main.js b/base/flatten4d-by/lib/main.js deleted file mode 100644 index bdc56faa3..000000000 --- a/base/flatten4d-by/lib/main.js +++ /dev/null @@ -1,113 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MAIN // - -/** -* Flattens a four-dimensional nested array according to a callback function. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Array} flattened array -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -function flatten4dBy( x, shape, colexicographic, clbk, thisArg ) { - var out; - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var a0; - var a1; - var a2; - - // Extract loop variables: - S0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - - // Initialize an output array: - out = []; - - // Iterate over the array dimensions... - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - for ( i3 = 0; i3 < S3; i3++ ) { - out.push( clbk.call( thisArg, x[ i3 ][ i2 ][ i1 ][ i0 ], [ i3, i2, i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order - } - } - } - } - return out; - } - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = x[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = a2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out.push( clbk.call( thisArg, a0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order - } - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten4dBy; diff --git a/base/flatten4d-by/package.json b/base/flatten4d-by/package.json deleted file mode 100644 index fc4282ccc..000000000 --- a/base/flatten4d-by/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/flatten4d-by", - "version": "0.0.0", - "description": "Flatten a four-dimensional nested array according to a callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flatten", - "flat", - "4d", - "tensor", - "strided", - "ndarray", - "multidimensional", - "foreach", - "map", - "transform", - "callback", - "accessor" - ] -} diff --git a/base/flatten4d-by/test/test.assign.js b/base/flatten4d-by/test/test.assign.js deleted file mode 100644 index 9a409bbf0..000000000 --- a/base/flatten4d-by/test/test.assign.js +++ /dev/null @@ -1,423 +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 naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var Float64Array = require( './../../../float64' ); -var flatten4dBy = require( './../lib/assign.js' ); - - -// VARIABLES // - -var clbk = naryFunction( abs, 1 ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten4dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ], - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4dBy( x, [ 0, 0, 0, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4dBy( x, [ 0, 0, 1, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4dBy( x, [ 1, 0, 0, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten4dBy( x, [ 1, 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten4dBy( x, [ 1, 1, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten4dBy( x, [ 2, 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten4dBy( x, [ 1, 2, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten4dBy( x, [ 1, 2, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten4dBy( x, [ 2, 2, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten4dBy( x, [ 2, 2, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten4dBy( x, [ 2, 2, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ], - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4dBy( x, [ 0, 0, 0, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4dBy( x, [ 0, 0, 1, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4dBy( x, [ 1, 0, 0, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten4dBy( x, [ 1, 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten4dBy( x, [ 1, 1, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten4dBy( x, [ 2, 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten4dBy( x, [ 1, 2, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 3, 7, 2, 6, 4, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten4dBy( x, [ 1, 2, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten4dBy( x, [ 2, 2, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 2, 10, 6, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten4dBy( x, [ 2, 2, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten4dBy( x, [ 2, 2, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten4dBy( x, [ 1, 1, 2, 2 ], false, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 3, 0, 2, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten4dBy( x, [ 1, 1, 2, 2 ], true, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten4dBy( x, [ 1, 1, 2, 2 ], false, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 3, 2, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten4dBy( x, [ 1, 1, 2, 2 ], true, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 3, 0, 2, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten4dBy( x, [ 1, 1, 2, 2 ], false, out, -2, 7, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 2, 0, 3, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten4dBy( x, [ 1, 1, 2, 2 ], true, out, -2, 7, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports setting the callback execution context (lexicographic)', function test( t ) { - var ctx; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flatten4dBy( x, [ 1, 1, 2, 2 ], false, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 4, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ][ indices[3] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic)', function test( t ) { - var ctx; - var out; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flatten4dBy( x, [ 1, 1, 2, 2 ], true, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 4, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ][ indices[3] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); diff --git a/base/flatten4d-by/test/test.js b/base/flatten4d-by/test/test.js deleted file mode 100644 index 0f7ef980f..000000000 --- a/base/flatten4d-by/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var flatten4dBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten4dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( flatten4dBy, 'assign' ), true, 'has property' ); - t.strictEqual( typeof flatten4dBy.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/flatten4d-by/test/test.main.js b/base/flatten4d-by/test/test.main.js deleted file mode 100644 index 9172f224d..000000000 --- a/base/flatten4d-by/test/test.main.js +++ /dev/null @@ -1,250 +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 naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten4dBy = require( './../lib/main.js' ); - - -// VARIABLES // - -var clbk = naryFunction( abs, 1 ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten4dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ], - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ]; - - expected = []; - actual = flatten4dBy( x, [ 0, 0, 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten4dBy( x, [ 0, 0, 1, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten4dBy( x, [ 1, 0, 0, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten4dBy( x, [ 1, 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten4dBy( x, [ 1, 1, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten4dBy( x, [ 2, 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten4dBy( x, [ 1, 2, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = flatten4dBy( x, [ 1, 2, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten4dBy( x, [ 2, 2, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten4dBy( x, [ 2, 2, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten4dBy( x, [ 2, 2, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ], - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ], - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ], - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ]; - - expected = []; - actual = flatten4dBy( x, [ 0, 0, 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten4dBy( x, [ 0, 0, 1, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten4dBy( x, [ 1, 0, 0, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten4dBy( x, [ 1, 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten4dBy( x, [ 1, 1, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten4dBy( x, [ 2, 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten4dBy( x, [ 1, 2, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 3, 7, 2, 6, 4, 8 ]; - actual = flatten4dBy( x, [ 1, 2, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13 ]; - actual = flatten4dBy( x, [ 2, 2, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 2, 10, 6, 14 ]; - actual = flatten4dBy( x, [ 2, 2, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ]; - actual = flatten4dBy( x, [ 2, 2, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports setting the callback execution context (lexicographic)', function test( t ) { - var ctx; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - - flatten4dBy( x, [ 1, 1, 2, 2 ], false, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 4, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ][ indices[3] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic)', function test( t ) { - var ctx; - var x; - - x = [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - - flatten4dBy( x, [ 1, 1, 2, 2 ], true, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 4, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ][ indices[3] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); diff --git a/base/flatten4d/README.md b/base/flatten4d/README.md deleted file mode 100644 index 41245eabf..000000000 --- a/base/flatten4d/README.md +++ /dev/null @@ -1,163 +0,0 @@ - - -# flatten4d - -> Flatten a four-dimensional nested array. - -
- -## Usage - -```javascript -var flatten4d = require( '@stdlib/array/base/flatten4d' ); -``` - -#### flatten4d( x, shape, colexicographic ) - -Flattens a four-dimensional nested array. - -```javascript -var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - -var out = flatten4d( x, [ 2, 1, 1, 2 ], false ); -// returns [ 1, 2, 3, 4 ] -``` - -To flatten in colexicographic order, provide a third argument equal to `true`. - -```javascript -var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - -var out = flatten4d( x, [ 2, 1, 1, 2 ], true ); -// returns [ 1, 3, 2, 4 ] -``` - -#### flatten4d.assign( x, shape, colexicographic, out, stride, offset ) - -Flattens a four-dimensional nested array and assigns elements to a provided output array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -var out = new Float64Array( 4 ); - -var y = flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0 ); -// returns [ 1, 2, 3, 4 ] - -var bool = ( y === out ); -// returns true - -y = flatten4d.assign( x, [ 2, 1, 1, 2 ], true, out, 1, 0 ); -// returns [ 1, 3, 2, 4 ] -``` - -
- - - -
- -## Notes - -- Both functions assume that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - -
- - - -
- -## Examples - - - -```javascript -var flatten4d = require( '@stdlib/array/base/flatten4d' ); - -// Define a 2x2x2x2 array: -var x = [ - [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ], - [ - [ [ 9, 10 ], [ 11, 12 ] ], - [ [ 13, 14 ], [ 15, 16 ] ] - ] -]; - -var out = flatten4d( x, [ 0, 0, 0, 0 ], false ); -// returns [] - -out = flatten4d( x, [ 0, 0, 0, 0 ], true ); -// returns [] - -out = flatten4d( x, [ 1, 1, 1, 1 ], false ); -// returns [ 1 ] - -out = flatten4d( x, [ 1, 1, 1, 1 ], true ); -// returns [ 1 ] - -out = flatten4d( x, [ 1, 2, 2, 2 ], false ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten4d( x, [ 1, 2, 2, 2 ], true ); -// returns [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten4d( x, [ 2, 2, 2, 2 ], false ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten4d( x, [ 2, 2, 2, 2 ], true ); -// returns [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/flatten4d/benchmark/benchmark.js b/base/flatten4d/benchmark/benchmark.js deleted file mode 100644 index 68ad45d0a..000000000 --- a/base/flatten4d/benchmark/benchmark.js +++ /dev/null @@ -1,125 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var zeroTo = require( './../../../base/zero-to' ); -var filled = require( './../../../base/filled' ); -var Float64Array = require( './../../../float64' ); -var pkg = require( './../package.json' ).name; -var flatten4d = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=144,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten4d( x, [ 4, 3, 4, 3 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':size=144,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten4d( x, [ 4, 3, 4, 3 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=144,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 144 ); - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten4d.assign( x, [ 4, 3, 4, 3 ], false, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=144,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 144 ); - x = filled( filled( filled( zeroTo( 3 ), 4 ), 3 ), 4 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten4d.assign( x, [ 4, 3, 4, 3 ], true, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/flatten4d/docs/repl.txt b/base/flatten4d/docs/repl.txt deleted file mode 100644 index 144dfaaae..000000000 --- a/base/flatten4d/docs/repl.txt +++ /dev/null @@ -1,80 +0,0 @@ - -{{alias}}( x, shape, colexicographic ) - Flattens a four-dimensional nested array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - shape: Array - Array shape. - - colexicographic: boolean - Specifies whether to flatten array values in colexicographic order. - - Returns - ------- - out: Array - Flattened array. - - Examples - -------- - > var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - > var out = {{alias}}( x, [ 2, 1, 1, 2 ], false ) - [ 1, 2, 3, 4 ] - > out = {{alias}}( x, [ 2, 1, 1, 2 ], true ) - [ 1, 3, 2, 4 ] - - -{{alias}}.assign( x, shape, colexicographic, out, stride, offset ) - Flattens a four-dimensional nested array and assigns elements to a provided - output array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colexicographic: boolean - Specifies whether to flatten array values in colexicographic order. - - out: Collection - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - > var out = [ 0, 0, 0, 0 ]; - > var v = {{alias}}.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0 ) - [ 1, 2, 3, 4 ] - > var bool = ( v === out ) - true - > out = [ 0, 0, 0, 0 ]; - > {{alias}}.assign( x, [ 2, 1, 1, 2 ], true, out, 1, 0 ); - > out - [ 1, 3, 2, 4 ] - - See Also - -------- - diff --git a/base/flatten4d/docs/types/index.d.ts b/base/flatten4d/docs/types/index.d.ts deleted file mode 100644 index 183a572bc..000000000 --- a/base/flatten4d/docs/types/index.d.ts +++ /dev/null @@ -1,119 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Interface describing `flatten4d`. -*/ -interface Flatten4d { - /** - * Flattens a four-dimensional nested array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @returns flattened array - * - * @example - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = flatten4d( x, [ 2, 1, 1, 2 ], false ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = flatten4d( x, [ 2, 1, 1, 2 ], true ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array4D, shape: Shape4D, colexicographic: boolean ): Array; - - /** - * Flattens a four-dimensional nested array and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = flatten4d.assign( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0 ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - * - * var out = flatten4d.assign( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0 ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array4D, shape: Shape4D, colexicographic: boolean, out: Collection, stride: number, offset: number ): Collection; -} - -/** -* Flattens a four-dimensional nested array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param x - input array -* @param shape - array shape -* @param colexicographic - specifies whether to flatten array values in colexicographic order -* @returns flattened array -* -* @example -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4d( x, [ 2, 1, 1, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4d( x, [ 2, 1, 1, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -*/ -declare var flatten4d: Flatten4d; - - -// EXPORTS // - -export = flatten4d; diff --git a/base/flatten4d/docs/types/test.ts b/base/flatten4d/docs/types/test.ts deleted file mode 100644 index a9643ba2e..000000000 --- a/base/flatten4d/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -import flatten4d = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - flatten4d( x, [ 2, 1, 1, 2 ], false ); // $ExpectType number[] - flatten4d( x, [ 2, 1, 1, 2 ], true ); // $ExpectType number[] - - flatten4d( x, [ 2, 1, 1, 2 ], false ); // $ExpectType number[] - flatten4d( x, [ 2, 1, 1, 2 ], true ); // $ExpectType number[] - - flatten4d( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], false ); // $ExpectType string[] - flatten4d( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], true ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - flatten4d( 1, [ 2, 1, 1, 2 ], false ); // $ExpectError - flatten4d( true, [ 2, 1, 1, 2 ], false ); // $ExpectError - flatten4d( false, [ 2, 1, 1, 2 ], false ); // $ExpectError - flatten4d( null, [ 2, 1, 1, 2 ], false ); // $ExpectError - flatten4d( void 0, [ 2, 1, 1, 2 ], false ); // $ExpectError - flatten4d( {}, [ 2, 1, 1, 2 ], false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - flatten4d( x, '', false ); // $ExpectError - flatten4d( x, 1, false ); // $ExpectError - flatten4d( x, true, false ); // $ExpectError - flatten4d( x, false, false ); // $ExpectError - flatten4d( x, null, false ); // $ExpectError - flatten4d( x, void 0, false ); // $ExpectError - flatten4d( x, {}, false ); // $ExpectError - flatten4d( x, [ 1, '2', 3 ], false ); // $ExpectError - flatten4d( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - flatten4d( x, [ 2, 1, 1, 2 ], '' ); // $ExpectError - flatten4d( x, [ 2, 1, 1, 2 ], 1 ); // $ExpectError - flatten4d( x, [ 2, 1, 1, 2 ], null ); // $ExpectError - flatten4d( x, [ 2, 1, 1, 2 ], void 0 ); // $ExpectError - flatten4d( x, [ 2, 1, 1, 2 ], {} ); // $ExpectError - flatten4d( x, [ 2, 1, 1, 2 ], [] ); // $ExpectError - flatten4d( x, [ 2, 1, 1, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - flatten4d(); // $ExpectError - flatten4d( x ); // $ExpectError - flatten4d( x, [ 2, 1, 1, 2 ] ); // $ExpectError - flatten4d( x, [ 2, 1, 1, 2 ], false, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - const out1 = [ 0, 0, 0, 0 ]; - - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out1, 1, 0 ); // $ExpectType Collection - flatten4d.assign( x, [ 2, 1, 1, 2 ], true, out1, 1, 0 ); // $ExpectType Collection - - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out1, 1, 0 ); // $ExpectType Collection - flatten4d.assign( x, [ 2, 1, 1, 2 ], true, out1, 1, 0 ); // $ExpectType Collection - - const out2 = [ '', '', '', '' ]; - - flatten4d.assign( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], false, out2, 1, 0 ); // $ExpectType Collection - flatten4d.assign( [ [ [ [ '1', '2' ] ] ], [ [ [ '3', '4' ] ] ] ], [ 2, 1, 1, 2 ], true, out2, 1, 0 ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - flatten4d.assign( 1, [ 2, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten4d.assign( true, [ 2, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten4d.assign( false, [ 2, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten4d.assign( null, [ 2, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten4d.assign( void 0, [ 2, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten4d.assign( {}, [ 2, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten4d.assign( x, '', false, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, 1, false, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, true, false, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, false, false, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, null, false, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, void 0, false, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, {}, false, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 1, '2', 3 ], false, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, ( x: number ): number => x, false, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a boolean... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten4d.assign( x, [ 2, 1, 1, 2 ], '', out, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], 1, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], null, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], void 0, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], {}, out, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], [], out, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], ( x: number ): number => x, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, 1, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, true, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, false, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, null, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, void 0, 1, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, '1', 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, true, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, false, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, null, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, void 0, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, {}, 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, [], 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, 1, '1' ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, 1, true ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, 1, false ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, 1, null ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, 1, void 0 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, 1, {} ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, 1, [] ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten4d.assign(); // $ExpectError - flatten4d.assign( x ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ] ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, 1 ); // $ExpectError - flatten4d.assign( x, [ 2, 1, 1, 2 ], false, out, 1, 0, {} ); // $ExpectError -} diff --git a/base/flatten4d/examples/index.js b/base/flatten4d/examples/index.js deleted file mode 100644 index 2749f3e61..000000000 --- a/base/flatten4d/examples/index.js +++ /dev/null @@ -1,65 +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'; - -var flatten4d = require( './../lib' ); - -// Define a 2x2x2x2 array: -var x = [ - [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ], - [ - [ [ 9, 10 ], [ 11, 12 ] ], - [ [ 13, 14 ], [ 15, 16 ] ] - ] -]; - -var out = flatten4d( x, [ 0, 0, 0, 0 ], false ); -console.log( out ); -// => [] - -out = flatten4d( x, [ 0, 0, 0, 0 ], true ); -console.log( out ); -// => [] - -out = flatten4d( x, [ 1, 1, 1, 1 ], false ); -console.log( out ); -// => [ 1 ] - -out = flatten4d( x, [ 1, 1, 1, 1 ], true ); -console.log( out ); -// => [ 1 ] - -out = flatten4d( x, [ 1, 2, 2, 2 ], false ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten4d( x, [ 1, 2, 2, 2 ], true ); -console.log( out ); -// => [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten4d( x, [ 2, 2, 2, 2 ], false ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten4d( x, [ 2, 2, 2, 2 ], true ); -console.log( out ); -// => [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] diff --git a/base/flatten4d/lib/assign.js b/base/flatten4d/lib/assign.js deleted file mode 100644 index 71960e50f..000000000 --- a/base/flatten4d/lib/assign.js +++ /dev/null @@ -1,108 +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'; - -// MAIN // - -/** -* Flattens a four-dimensional nested array and assigns elements to a provided output array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4d( x, [ 2, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0 ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4d( x, [ 2, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0 ); -* // returns [ 1, 3, 2, 4 ] -*/ -function flatten4d( x, shape, colexicographic, out, stride, offset ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var a0; - var a1; - var a2; - var io; - - // Extract loop variables: - S0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - - // Iterate over the array dimensions... - io = offset; - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - for ( i3 = 0; i3 < S3; i3++ ) { - out[ io ] = x[ i3 ][ i2 ][ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order - io += stride; - } - } - } - } - return out; - } - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = x[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = a2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order - io += stride; - } - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten4d; diff --git a/base/flatten4d/lib/index.js b/base/flatten4d/lib/index.js deleted file mode 100644 index 8c294976d..000000000 --- a/base/flatten4d/lib/index.js +++ /dev/null @@ -1,70 +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'; - -/** -* Flatten a four-dimensional nested array. -* -* @module @stdlib/array/base/flatten4d -* -* @example -* var flatten4d = require( '@stdlib/array/base/flatten4d' ); -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4d( x, [ 2, 1, 1, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var flatten4d = require( '@stdlib/array/base/flatten4d' ); -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4d( x, [ 2, 1, 1, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var flatten4d = require( '@stdlib/array/base/flatten4d' ); -* -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = new Float64Array( 4 ); -* var y = flatten4d.assign( x, [ 2, 1, 1, 2 ], true, out, 1, 0 ); -* // returns [ 1, 3, 2, 4 ] -* -* var bool = ( y === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flatten4d/lib/main.js b/base/flatten4d/lib/main.js deleted file mode 100644 index e56c57a82..000000000 --- a/base/flatten4d/lib/main.js +++ /dev/null @@ -1,101 +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'; - -// MAIN // - -/** -* Flattens a four-dimensional nested array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @returns {Array} flattened array -* -* @example -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4d( x, [ 2, 1, 1, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ]; -* -* var out = flatten4d( x, [ 2, 1, 1, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -*/ -function flatten4d( x, shape, colexicographic ) { - var out; - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var a0; - var a1; - var a2; - - // Extract loop variables: - S0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - - // Initialize an output array: - out = []; - - // Iterate over the array dimensions... - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - for ( i3 = 0; i3 < S3; i3++ ) { - out.push( x[ i3 ][ i2 ][ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order - } - } - } - } - return out; - } - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = x[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = a2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order - } - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten4d; diff --git a/base/flatten4d/package.json b/base/flatten4d/package.json deleted file mode 100644 index 64d5afbed..000000000 --- a/base/flatten4d/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/flatten4d", - "version": "0.0.0", - "description": "Flatten a four-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flatten", - "flat", - "4d", - "tensor", - "strided", - "ndarray", - "multidimensional" - ] -} diff --git a/base/flatten4d/test/test.assign.js b/base/flatten4d/test/test.assign.js deleted file mode 100644 index 9b0ba8d25..000000000 --- a/base/flatten4d/test/test.assign.js +++ /dev/null @@ -1,352 +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 Float64Array = require( './../../../float64' ); -var flatten4d = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ], - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4d( x, [ 0, 0, 0, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4d( x, [ 0, 0, 1, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4d( x, [ 1, 0, 0, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten4d( x, [ 1, 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten4d( x, [ 1, 1, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten4d( x, [ 2, 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten4d( x, [ 1, 2, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten4d( x, [ 1, 2, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten4d( x, [ 2, 2, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten4d( x, [ 2, 2, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten4d( x, [ 2, 2, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ], - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4d( x, [ 0, 0, 0, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4d( x, [ 0, 0, 1, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten4d( x, [ 1, 0, 0, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten4d( x, [ 1, 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten4d( x, [ 1, 1, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten4d( x, [ 2, 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten4d( x, [ 1, 2, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 3, 7, 2, 6, 4, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten4d( x, [ 1, 2, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten4d( x, [ 2, 2, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 2, 10, 6, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten4d( x, [ 2, 2, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten4d( x, [ 2, 2, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten4d( x, [ 1, 1, 2, 2 ], false, out, 2, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 3, 0, 2, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten4d( x, [ 1, 1, 2, 2 ], true, out, 2, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten4d( x, [ 1, 1, 2, 2 ], false, out, 1, 2 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 3, 2, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten4d( x, [ 1, 1, 2, 2 ], true, out, 1, 2 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 3, 0, 2, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten4d( x, [ 1, 1, 2, 2 ], false, out, -2, 7 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 2, 0, 3, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten4d( x, [ 1, 1, 2, 2 ], true, out, -2, 7 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flatten4d/test/test.js b/base/flatten4d/test/test.js deleted file mode 100644 index 64f7cc109..000000000 --- a/base/flatten4d/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var flatten4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( flatten4d, 'assign' ), true, 'has property' ); - t.strictEqual( typeof flatten4d.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/flatten4d/test/test.main.js b/base/flatten4d/test/test.main.js deleted file mode 100644 index 9a902e875..000000000 --- a/base/flatten4d/test/test.main.js +++ /dev/null @@ -1,183 +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 flatten4d = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ], - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ]; - - expected = []; - actual = flatten4d( x, [ 0, 0, 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten4d( x, [ 0, 0, 1, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten4d( x, [ 1, 0, 0, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten4d( x, [ 1, 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten4d( x, [ 1, 1, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten4d( x, [ 2, 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten4d( x, [ 1, 2, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = flatten4d( x, [ 1, 2, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten4d( x, [ 2, 2, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten4d( x, [ 2, 2, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten4d( x, [ 2, 2, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ], - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ]; - - expected = []; - actual = flatten4d( x, [ 0, 0, 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten4d( x, [ 0, 0, 1, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten4d( x, [ 1, 0, 0, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten4d( x, [ 1, 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten4d( x, [ 1, 1, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten4d( x, [ 2, 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten4d( x, [ 1, 2, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 3, 7, 2, 6, 4, 8 ]; - actual = flatten4d( x, [ 1, 2, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13 ]; - actual = flatten4d( x, [ 2, 2, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 2, 10, 6, 14 ]; - actual = flatten4d( x, [ 2, 2, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ]; - actual = flatten4d( x, [ 2, 2, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flatten5d-by/README.md b/base/flatten5d-by/README.md deleted file mode 100644 index 33d40e6aa..000000000 --- a/base/flatten5d-by/README.md +++ /dev/null @@ -1,225 +0,0 @@ - - - - -# flatten5dBy - -> Flatten a five-dimensional nested array according to a callback function. - -
- -## Usage - -```javascript -var flatten5dBy = require( '@stdlib/array/base/flatten5d-by' ); -``` - -#### flatten5dBy( x, shape, colexicographic, clbk\[, thisArg] ) - -Flattens a five-dimensional nested array according to a callback function. - -```javascript -function scale( v ) { - return v * 2; -} - -var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - -var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, scale ); -// returns [ 2, 4, 6, 8 ] -``` - -To flatten in colexicographic order, provide a third argument equal to `true`. - -```javascript -function scale( v ) { - return v * 2; -} - -var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - -var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, scale ); -// returns [ 2, 6, 4, 8 ] -``` - -To set the callback execution context, provide a `thisArg` argument. - - - -```javascript -function scale( v ) { - this.count += 1; - return v * 2; -} - -var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -var ctx = { - 'count': 0 -}; - -var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, scale, ctx ); -// returns [ 2, 4, 6, 8 ] - -var count = ctx.count; -// returns 4 -``` - -#### flatten5dBy.assign( x, shape, colexicographic, out, stride, offset, clbk\[, thisArg] ) - -Flattens a five-dimensional nested array according to a callback function and assigns elements to a provided output array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -function scale( v ) { - return v * 2; -} - -var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -var out = new Float64Array( 4 ); - -var y = flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, scale ); -// returns [ 2, 4, 6, 8 ] - -var bool = ( y === out ); -// returns true - -y = flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], true, out, 1, 0, scale ); -// returns [ 2, 6, 4, 8 ] -``` - -
- - - -
- -## Notes - -- A callback function is provided the following arguments: - - - **value**: nested array element. - - **indices**: element indices (in lexicographic order). - - **arr**: the input array. - -- Both functions assume that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - -
- - - -
- -## Examples - - - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten5dBy = require( '@stdlib/array/base/flatten5d-by' ); - -var fcn = naryFunction( abs, 1 ); - -// Define a 2x2x1x2x2 array: -var x = [ - [ - [ - [ - [ -1, -2 ], [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], [ -15, -16 ] - ] - ] - ] -]; - -var out = flatten5dBy( x, [ 0, 0, 0, 0, 0 ], false, fcn ); -// returns [] - -out = flatten5dBy( x, [ 0, 0, 0, 0, 0 ], true, fcn ); -// returns [] - -out = flatten5dBy( x, [ 1, 1, 1, 1, 1 ], false, fcn ); -// returns [ 1 ] - -out = flatten5dBy( x, [ 1, 1, 1, 1, 1 ], true, fcn ); -// returns [ 1 ] - -out = flatten5dBy( x, [ 1, 2, 1, 2, 2 ], false, fcn ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten5dBy( x, [ 1, 2, 1, 2, 2 ], true, fcn ); -// returns [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten5dBy( x, [ 2, 2, 1, 2, 2 ], false, fcn ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten5dBy( x, [ 2, 2, 1, 2, 2 ], true, fcn ); -// returns [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/flatten5d-by/benchmark/benchmark.js b/base/flatten5d-by/benchmark/benchmark.js deleted file mode 100644 index 4df5693fe..000000000 --- a/base/flatten5d-by/benchmark/benchmark.js +++ /dev/null @@ -1,143 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var zeroTo = require( './../../../base/zero-to' ); -var filled = require( './../../../base/filled' ); -var Float64Array = require( './../../../float64' ); -var pkg = require( './../package.json' ).name; -var flatten5dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Scales an input value. -* -* @private -* @param {number} v - input value -* @returns {number} output value -* -* @example -* var v = scale( 2.0 ); -* // returns 4.0 -*/ -function scale( v ) { - return v * 2.0; -} - - -// MAIN // - -bench( pkg+':size=108,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten5dBy( x, [ 2, 2, 3, 3, 3 ], false, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':size=108,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten5dBy( x, [ 2, 2, 3, 3, 3 ], true, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=108,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 108 ); - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten5dBy.assign( x, [ 2, 2, 3, 3, 3 ], false, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=108,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 108 ); - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten5dBy.assign( x, [ 2, 2, 3, 3, 3 ], true, out, 1, 0, scale ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/flatten5d-by/docs/repl.txt b/base/flatten5d-by/docs/repl.txt deleted file mode 100644 index 7b7b08c05..000000000 --- a/base/flatten5d-by/docs/repl.txt +++ /dev/null @@ -1,106 +0,0 @@ - -{{alias}}( x, shape, colex, clbk[, thisArg] ) - Flattens a five-dimensional nested array according to a callback function. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - The callback function is provided the following arguments: - - - value: nested array element. - - indices: element indices (in lexicographic order). - - arr: the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - shape: Array - Array shape. - - colex: boolean - Specifies whether to flatten array values in colexicographic order. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Flattened array. - - Examples - -------- - > function fcn( v ) { return v * 2; }; - > var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - > var out = {{alias}}( x, [ 2, 1, 1, 1, 2 ], false, fcn ) - [ 2, 4, 6, 8 ] - > out = {{alias}}( x, [ 2, 1, 1, 1, 2 ], true, fcn ) - [ 2, 6, 4, 8 ] - - -{{alias}}.assign( x, shape, colex, out, stride, offset, clbk[, thisArg] ) - Flattens a five-dimensional nested array according to a callback function - and assigns elements to a provided output array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - The callback function is provided the following arguments: - - - value: nested array element. - - indices: element indices (in lexicographic order). - - arr: the input array. - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colex: boolean - Specifies whether to flatten array values in colexicographic order. - - out: Collection - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function fcn( v ) { return v * 2; }; - > var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - > var out = [ 0, 0, 0, 0 ]; - > var v = {{alias}}.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, fcn ) - [ 2, 4, 6, 8 ] - > var bool = ( v === out ) - true - > out = [ 0, 0, 0, 0 ]; - > {{alias}}.assign( x, [ 2, 1, 1, 1, 2 ], true, out, 1, 0, fcn ); - > out - [ 2, 6, 4, 8 ] - - See Also - -------- - diff --git a/base/flatten5d-by/docs/types/index.d.ts b/base/flatten5d-by/docs/types/index.d.ts deleted file mode 100644 index 413b5ceac..000000000 --- a/base/flatten5d-by/docs/types/index.d.ts +++ /dev/null @@ -1,193 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Array5D } from '@stdlib/types/array'; -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Nullary callback function. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Unary callback function. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Binary callback function. -* -* @param value - array element -* @param indices - element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Array ) => U; - -/** -* Ternary callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Array, arr: Array5D ) => U; - -/** -* Callback function. -* -* @param value - array element -* @param indices - element indices -* @param arr - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing `flatten5dBy`. -*/ -interface Flatten5dBy { - /** - * Flattens a five-dimensional nested array according to a callback function. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns flattened array - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array5D, shape: Shape5D, colexicographic: boolean, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - /** - * Flattens a five-dimensional nested array according to a callback function and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = flatten5dBy.assign( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * function scale( v ) { - * return v * 2; - * } - * - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = flatten5dBy.assign( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array5D, shape: Shape5D, colexicographic: boolean, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Flattens a five-dimensional nested array according to a callback function. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param x - input array -* @param shape - array shape -* @param colexicographic - specifies whether to flatten array values in colexicographic order -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns flattened array -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, scale ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, scale ); -* // returns [ 1, 3, 2, 4 ] -*/ -declare var flatten5dBy: Flatten5dBy; - - -// EXPORTS // - -export = flatten5dBy; diff --git a/base/flatten5d-by/docs/types/test.ts b/base/flatten5d-by/docs/types/test.ts deleted file mode 100644 index d7fc9785d..000000000 --- a/base/flatten5d-by/docs/types/test.ts +++ /dev/null @@ -1,340 +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. -*/ - -import flatten5dBy = require( './index' ); - -/** -* Identity function. -* -* @param value - input value -* @returns input value -*/ -function identity( value: T ): T { - return value; -} - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, identity ); // $ExpectType number[] - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, identity ); // $ExpectType number[] - - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, identity, {} ); // $ExpectType number[] - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, identity, {} ); // $ExpectType number[] - - flatten5dBy( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], false, identity ); // $ExpectType string[] - flatten5dBy( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], true, identity ); // $ExpectType string[] - - flatten5dBy( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], false, identity, {} ); // $ExpectType string[] - flatten5dBy( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], true, identity, {} ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - flatten5dBy( 1, [ 2, 1, 1, 1, 2 ], false, identity ); // $ExpectError - flatten5dBy( true, [ 2, 1, 1, 1, 2 ], false, identity ); // $ExpectError - flatten5dBy( false, [ 2, 1, 1, 1, 2 ], false, identity ); // $ExpectError - flatten5dBy( null, [ 2, 1, 1, 1, 2 ], false, identity ); // $ExpectError - flatten5dBy( void 0, [ 2, 1, 1, 1, 2 ], false, identity ); // $ExpectError - flatten5dBy( {}, [ 2, 1, 1, 1, 2 ], false, identity ); // $ExpectError - - flatten5dBy( 1, [ 2, 1, 1, 1, 2 ], false, identity, {} ); // $ExpectError - flatten5dBy( true, [ 2, 1, 1, 1, 2 ], false, identity, {} ); // $ExpectError - flatten5dBy( false, [ 2, 1, 1, 1, 2 ], false, identity, {} ); // $ExpectError - flatten5dBy( null, [ 2, 1, 1, 1, 2 ], false, identity, {} ); // $ExpectError - flatten5dBy( void 0, [ 2, 1, 1, 1, 2 ], false, identity, {} ); // $ExpectError - flatten5dBy( {}, [ 2, 1, 1, 1, 2 ], false, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - flatten5dBy( x, '', false, identity ); // $ExpectError - flatten5dBy( x, 1, false, identity ); // $ExpectError - flatten5dBy( x, true, false, identity ); // $ExpectError - flatten5dBy( x, false, false, identity ); // $ExpectError - flatten5dBy( x, null, false, identity ); // $ExpectError - flatten5dBy( x, void 0, false, identity ); // $ExpectError - flatten5dBy( x, {}, false, identity ); // $ExpectError - flatten5dBy( x, [ 1, '2', 3 ], false, identity ); // $ExpectError - flatten5dBy( x, ( x: number ): number => x, false, identity ); // $ExpectError - - flatten5dBy( x, '', false, identity, {} ); // $ExpectError - flatten5dBy( x, 1, false, identity, {} ); // $ExpectError - flatten5dBy( x, true, false, identity, {} ); // $ExpectError - flatten5dBy( x, false, false, identity, {} ); // $ExpectError - flatten5dBy( x, null, false, identity, {} ); // $ExpectError - flatten5dBy( x, void 0, false, identity, {} ); // $ExpectError - flatten5dBy( x, {}, false, identity, {} ); // $ExpectError - flatten5dBy( x, [ 1, '2', 3 ], false, identity, {} ); // $ExpectError - flatten5dBy( x, ( x: number ): number => x, false, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], '', identity ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], 1, identity ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], null, identity ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], void 0, identity ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], {}, identity ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], [], identity ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], ( x: number ): number => x, identity ); // $ExpectError - - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], '', identity, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], 1, identity, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], null, identity, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], void 0, identity, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], {}, identity, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], [], identity, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], ( x: number ): number => x, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a function... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, '' ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, 1 ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, true ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, false ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, null ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, void 0 ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, [] ); // $ExpectError - - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, '', {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, 1, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, true, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, false, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, null, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, void 0, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, {}, {} ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - flatten5dBy(); // $ExpectError - flatten5dBy( x ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ] ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false ); // $ExpectError - flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, identity, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - const out1 = [ 0, 0, 0, 0 ]; - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out1, 1, 0, identity ); // $ExpectType Collection - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], true, out1, 1, 0, identity ); // $ExpectType Collection - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out1, 1, 0, identity, {} ); // $ExpectType Collection - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], true, out1, 1, 0, identity, {} ); // $ExpectType Collection - - const out2 = [ '', '', '', '' ]; - - flatten5dBy.assign( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], false, out2, 1, 0, identity ); // $ExpectType Collection - flatten5dBy.assign( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], true, out2, 1, 0, identity ); // $ExpectType Collection - - flatten5dBy.assign( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], false, out2, 1, 0, identity, {} ); // $ExpectType Collection - flatten5dBy.assign( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], true, out2, 1, 0, identity, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - flatten5dBy.assign( 1, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( true, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( false, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( null, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( void 0, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( {}, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity ); // $ExpectError - - flatten5dBy.assign( 1, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( true, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( false, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( null, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( void 0, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( {}, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten5dBy.assign( x, '', false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, 1, false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, true, false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, false, false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, null, false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, void 0, false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, {}, false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 1, '2', 3 ], false, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, ( x: number ): number => x, false, out, 1, 0, identity ); // $ExpectError - - flatten5dBy.assign( x, '', false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, 1, false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, true, false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, false, false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, null, false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, void 0, false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, {}, false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 1, '2', 3 ], false, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, ( x: number ): number => x, false, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a boolean... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], '', out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], 1, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], null, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], void 0, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], {}, out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], [], out, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], ( x: number ): number => x, out, 1, 0, identity ); // $ExpectError - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], '', out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], 1, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], null, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], void 0, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], {}, out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], [], out, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], ( x: number ): number => x, out, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, 1, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, true, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, false, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, null, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, void 0, 1, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, {}, 1, 0, identity ); // $ExpectError - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, 1, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, true, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, false, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, null, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, void 0, 1, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, {}, 1, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, '1', 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, true, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, false, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, null, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, void 0, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, {}, 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, [], 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, ( x: number ): number => x, 0, identity ); // $ExpectError - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, '1', 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, true, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, false, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, null, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, void 0, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, {}, 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, [], 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, ( x: number ): number => x, 0, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, '1', identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, true, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, false, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, null, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, void 0, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, {}, identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, [], identity ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, ( x: number ): number => x, identity ); // $ExpectError - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, '1', identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, true, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, false, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, null, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, void 0, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, {}, identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, [], identity, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, ( x: number ): number => x, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a seventh argument which is not a function... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, '1' ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, 1 ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, true ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, false ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, null ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, void 0 ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, [] ); // $ExpectError - - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, '1', {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, 1, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, true, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, false, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, null, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, void 0, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, {}, {} ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, [], {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten5dBy.assign(); // $ExpectError - flatten5dBy.assign( x ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ] ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1 ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, identity, {}, {} ); // $ExpectError -} diff --git a/base/flatten5d-by/examples/index.js b/base/flatten5d-by/examples/index.js deleted file mode 100644 index 5d6b41298..000000000 --- a/base/flatten5d-by/examples/index.js +++ /dev/null @@ -1,85 +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'; - -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten5dBy = require( './../lib' ); - -var fcn = naryFunction( abs, 1 ); - -// Define a 2x2x1x2x2 array: -var x = [ - [ - [ - [ - [ -1, -2 ], [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], [ -15, -16 ] - ] - ] - ] -]; - -var out = flatten5dBy( x, [ 0, 0, 0, 0, 0 ], false, fcn ); -console.log( out ); -// => [] - -out = flatten5dBy( x, [ 0, 0, 0, 0, 0 ], true, fcn ); -console.log( out ); -// => [] - -out = flatten5dBy( x, [ 1, 1, 1, 1, 1 ], false, fcn ); -console.log( out ); -// => [ 1 ] - -out = flatten5dBy( x, [ 1, 1, 1, 1, 1 ], true, fcn ); -console.log( out ); -// => [ 1 ] - -out = flatten5dBy( x, [ 1, 2, 1, 2, 2 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten5dBy( x, [ 1, 2, 1, 2, 2 ], true, fcn ); -console.log( out ); -// => [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten5dBy( x, [ 2, 2, 1, 2, 2 ], false, fcn ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten5dBy( x, [ 2, 2, 1, 2, 2 ], true, fcn ); -console.log( out ); -// => [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] diff --git a/base/flatten5d-by/lib/assign.js b/base/flatten5d-by/lib/assign.js deleted file mode 100644 index f0eb6375a..000000000 --- a/base/flatten5d-by/lib/assign.js +++ /dev/null @@ -1,129 +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. -*/ - -/* eslint-disable max-depth, max-len */ - -'use strict'; - -// MAIN // - -/** -* Flattens a five-dimensional nested array according to a callback function and assigns elements to a provided output array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>>>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -function flatten5dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var a0; - var a1; - var a2; - var a3; - var io; - - // Extract loop variables: - S0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - - // Iterate over the array dimensions... - io = offset; - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - for ( i3 = 0; i3 < S3; i3++ ) { - for ( i4 = 0; i4 < S4; i4++ ) { - out[ io ] = clbk.call( thisArg, x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ], [ i4, i3, i2, i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order - io += stride; - } - } - } - } - } - return out; - } - for ( i4 = 0; i4 < S4; i4++ ) { - a3 = x[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = a3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = a2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = clbk.call( thisArg, a0[ i0 ], [ i4, i3, i2, i1, i0 ], x ); // equivalent to storing in row-major (C-style) order - io += stride; - } - } - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten5dBy; diff --git a/base/flatten5d-by/lib/index.js b/base/flatten5d-by/lib/index.js deleted file mode 100644 index 4404ac439..000000000 --- a/base/flatten5d-by/lib/index.js +++ /dev/null @@ -1,82 +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'; - -/** -* Flatten a five-dimensional nested array according to a callback function. -* -* @module @stdlib/array/base/flatten5d-by -* -* @example -* var flatten5dBy = require( '@stdlib/array/base/flatten5d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* var flatten5dBy = require( '@stdlib/array/base/flatten5d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var flatten5dBy = require( '@stdlib/array/base/flatten5d-by' ); -* -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = new Float64Array( 4 ); -* var y = flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], true, out, 1, 0, scale ); -* // returns [ 2, 6, 4, 8 ] -* -* var bool = ( y === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flatten5d-by/lib/main.js b/base/flatten5d-by/lib/main.js deleted file mode 100644 index 6e857b8f8..000000000 --- a/base/flatten5d-by/lib/main.js +++ /dev/null @@ -1,122 +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. -*/ - -/* eslint-disable max-depth, max-len */ - -'use strict'; - -// MAIN // - -/** -* Flattens a five-dimensional nested array according to a callback function. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>>>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Array} flattened array -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, scale ); -* // returns [ 2, 4, 6, 8 ] -* -* @example -* function scale( v ) { -* return v * 2; -* } -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, scale ); -* // returns [ 2, 6, 4, 8 ] -*/ -function flatten5dBy( x, shape, colexicographic, clbk, thisArg ) { - var out; - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var a0; - var a1; - var a2; - var a3; - - // Extract loop variables: - S0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - - // Initialize an output array: - out = []; - - // Iterate over the array dimensions... - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - for ( i3 = 0; i3 < S3; i3++ ) { - for ( i4 = 0; i4 < S4; i4++ ) { - out.push( clbk.call( thisArg, x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ], [ i4, i3, i2, i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order - } - } - } - } - } - return out; - } - for ( i4 = 0; i4 < S4; i4++ ) { - a3 = x[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = a3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = a2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out.push( clbk.call( thisArg, a0[ i0 ], [ i4, i3, i2, i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order - } - } - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten5dBy; diff --git a/base/flatten5d-by/package.json b/base/flatten5d-by/package.json deleted file mode 100644 index 4ab8a578d..000000000 --- a/base/flatten5d-by/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/flatten5d-by", - "version": "0.0.0", - "description": "Flatten a five-dimensional nested array according to a callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flatten", - "flat", - "5d", - "tensor", - "strided", - "ndarray", - "multidimensional", - "foreach", - "map", - "transform", - "callback", - "accessor" - ] -} diff --git a/base/flatten5d-by/test/test.assign.js b/base/flatten5d-by/test/test.assign.js deleted file mode 100644 index cbeb1d2b6..000000000 --- a/base/flatten5d-by/test/test.assign.js +++ /dev/null @@ -1,455 +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 naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var Float64Array = require( './../../../float64' ); -var flatten5dBy = require( './../lib/assign.js' ); - - -// VARIABLES // - -var clbk = naryFunction( abs, 1 ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten5dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5dBy( x, [ 0, 0, 0, 0, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5dBy( x, [ 0, 0, 1, 0, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5dBy( x, [ 1, 0, 0, 1, 0 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten5dBy( x, [ 1, 1, 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten5dBy( x, [ 1, 1, 1, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten5dBy( x, [ 2, 1, 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten5dBy( x, [ 1, 2, 1, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten5dBy( x, [ 1, 2, 1, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten5dBy( x, [ 2, 2, 1, 1, 1 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten5dBy( x, [ 2, 2, 1, 1, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten5dBy( x, [ 2, 2, 1, 2, 2 ], false, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5dBy( x, [ 0, 0, 0, 0, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5dBy( x, [ 0, 0, 1, 0, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5dBy( x, [ 1, 0, 0, 1, 0 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten5dBy( x, [ 1, 1, 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten5dBy( x, [ 1, 1, 1, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten5dBy( x, [ 2, 1, 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten5dBy( x, [ 1, 2, 1, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 3, 7, 2, 6, 4, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten5dBy( x, [ 1, 2, 1, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten5dBy( x, [ 2, 2, 1, 1, 1 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 2, 10, 6, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten5dBy( x, [ 2, 2, 1, 1, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten5dBy( x, [ 2, 2, 1, 2, 2 ], true, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten5dBy( x, [ 1, 1, 1, 2, 2 ], false, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 3, 0, 2, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten5dBy( x, [ 1, 1, 1, 2, 2 ], true, out, 2, 0, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten5dBy( x, [ 1, 1, 1, 2, 2 ], false, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 3, 2, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten5dBy( x, [ 1, 1, 1, 2, 2 ], true, out, 1, 2, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 3, 0, 2, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten5dBy( x, [ 1, 1, 1, 2, 2 ], false, out, -2, 7, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 2, 0, 3, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten5dBy( x, [ 1, 1, 1, 2, 2 ], true, out, -2, 7, clbk ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports setting the callback execution context (lexicographic)', function test( t ) { - var ctx; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flatten5dBy( x, [ 1, 1, 1, 2, 2 ], false, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 5, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ][ indices[3] ][ indices[4] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic)', function test( t ) { - var ctx; - var out; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - - out = new Float64Array( 4 ); - flatten5dBy( x, [ 1, 1, 1, 2, 2 ], true, out, 1, 0, fcn, ctx ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 5, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ][ indices[3] ][ indices[4] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); diff --git a/base/flatten5d-by/test/test.js b/base/flatten5d-by/test/test.js deleted file mode 100644 index ea4bed4c4..000000000 --- a/base/flatten5d-by/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var flatten5dBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten5dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( flatten5dBy, 'assign' ), true, 'has property' ); - t.strictEqual( typeof flatten5dBy.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/flatten5d-by/test/test.main.js b/base/flatten5d-by/test/test.main.js deleted file mode 100644 index 57e338614..000000000 --- a/base/flatten5d-by/test/test.main.js +++ /dev/null @@ -1,310 +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 naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var flatten5dBy = require( './../lib/main.js' ); - - -// VARIABLES // - -var clbk = naryFunction( abs, 1 ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten5dBy, 'function', 'main export is a function', clbk ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ] - ]; - - expected = []; - actual = flatten5dBy( x, [ 0, 0, 0, 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten5dBy( x, [ 0, 0, 1, 0, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten5dBy( x, [ 1, 0, 0, 1, 0 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten5dBy( x, [ 1, 1, 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten5dBy( x, [ 1, 1, 1, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten5dBy( x, [ 2, 1, 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten5dBy( x, [ 1, 2, 1, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = flatten5dBy( x, [ 1, 2, 1, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten5dBy( x, [ 2, 2, 1, 1, 1 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten5dBy( x, [ 2, 2, 1, 1, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten5dBy( x, [ 2, 2, 1, 2, 2 ], false, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ] - ]; - - expected = []; - actual = flatten5dBy( x, [ 0, 0, 0, 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten5dBy( x, [ 0, 0, 1, 0, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten5dBy( x, [ 1, 0, 0, 1, 0 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten5dBy( x, [ 1, 1, 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten5dBy( x, [ 1, 1, 1, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten5dBy( x, [ 2, 1, 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten5dBy( x, [ 1, 2, 1, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 3, 7, 2, 6, 4, 8 ]; - actual = flatten5dBy( x, [ 1, 2, 1, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13 ]; - actual = flatten5dBy( x, [ 2, 2, 1, 1, 1 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 2, 10, 6, 14 ]; - actual = flatten5dBy( x, [ 2, 2, 1, 1, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ]; - actual = flatten5dBy( x, [ 2, 2, 1, 2, 2 ], true, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports setting the callback execution context (lexicographic)', function test( t ) { - var ctx; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - - flatten5dBy( x, [ 2, 2, 1, 2, 2 ], false, fcn, ctx ); - t.strictEqual( ctx.count, 16, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 5, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ][ indices[3] ][ indices[4] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); - -tape( 'the function supports setting the callback execution context (colexicographic)', function test( t ) { - var ctx; - var x; - - x = [ - [ - [ - [ - [ -1, -2 ], - [ -3, -4 ] - ] - ], - [ - [ - [ -5, -6 ], - [ -7, -8 ] - ] - ] - ], - [ - [ - [ - [ -9, -10 ], - [ -11, -12 ] - ] - ], - [ - [ - [ -13, -14 ], - [ -15, -16 ] - ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - - flatten5dBy( x, [ 2, 2, 1, 2, 2 ], true, fcn, ctx ); - t.strictEqual( ctx.count, 16, 'returns expected value' ); - - t.end(); - - function fcn( value, indices, arr ) { - this.count += 1; // eslint-disable-line no-invalid-this - t.strictEqual( indices.length, 5, 'returns expected value' ); - t.strictEqual( value, arr[ indices[0] ][ indices[1] ][ indices[2] ][ indices[3] ][ indices[4] ], 'returns expected value' ); - t.strictEqual( arr, x, 'returns expected value' ); - } -}); diff --git a/base/flatten5d/README.md b/base/flatten5d/README.md deleted file mode 100644 index 75632609d..000000000 --- a/base/flatten5d/README.md +++ /dev/null @@ -1,179 +0,0 @@ - - -# flatten5d - -> Flatten a five-dimensional nested array. - -
- -## Usage - -```javascript -var flatten5d = require( '@stdlib/array/base/flatten5d' ); -``` - -#### flatten5d( x, shape, colexicographic ) - -Flattens a five-dimensional nested array. - -```javascript -var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - -var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false ); -// returns [ 1, 2, 3, 4 ] -``` - -To flatten in colexicographic order, provide a third argument equal to `true`. - -```javascript -var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - -var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true ); -// returns [ 1, 3, 2, 4 ] -``` - -#### flatten5d.assign( x, shape, colexicographic, out, stride, offset ) - -Flattens a five-dimensional nested array and assigns elements to a provided output array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -var out = new Float64Array( 4 ); - -var y = flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0 ); -// returns [ 1, 2, 3, 4 ] - -var bool = ( y === out ); -// returns true - -y = flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], true, out, 1, 0 ); -// returns [ 1, 3, 2, 4 ] -``` - -
- - - -
- -## Notes - -- Both functions assume that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - -
- - - -
- -## Examples - - - -```javascript -var flatten5d = require( '@stdlib/array/base/flatten5d' ); - -// Define a 2x2x1x2x2 array: -var x = [ - [ - [ - [ - [ 1, 2 ], [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], [ 15, 16 ] - ] - ] - ] -]; - -var out = flatten5d( x, [ 0, 0, 0, 0, 0 ], false ); -// returns [] - -out = flatten5d( x, [ 0, 0, 0, 0, 0 ], true ); -// returns [] - -out = flatten5d( x, [ 1, 1, 1, 1, 1 ], false ); -// returns [ 1 ] - -out = flatten5d( x, [ 1, 1, 1, 1, 1 ], true ); -// returns [ 1 ] - -out = flatten5d( x, [ 1, 2, 1, 2, 2 ], false ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten5d( x, [ 1, 2, 1, 2, 2 ], true ); -// returns [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten5d( x, [ 2, 2, 1, 2, 2 ], false ); -// returns [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten5d( x, [ 2, 2, 1, 2, 2 ], true ); -// returns [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/flatten5d/benchmark/benchmark.js b/base/flatten5d/benchmark/benchmark.js deleted file mode 100644 index 52be22f39..000000000 --- a/base/flatten5d/benchmark/benchmark.js +++ /dev/null @@ -1,125 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var zeroTo = require( './../../../base/zero-to' ); -var filled = require( './../../../base/filled' ); -var Float64Array = require( './../../../float64' ); -var pkg = require( './../package.json' ).name; -var flatten5d = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=108,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten5d( x, [ 2, 2, 3, 3, 3 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':size=108,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten5d( x, [ 2, 2, 3, 3, 3 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=108,lexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 108 ); - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten5d.assign( x, [ 2, 2, 3, 3, 3 ], false, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign:size=108,colexicographic', function benchmark( b ) { - var out; - var x; - var i; - var v; - - out = new Float64Array( 108 ); - x = filled( filled( filled( filled( zeroTo( 3 ), 3 ), 3 ), 2 ), 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = flatten5d.assign( x, [ 2, 2, 3, 3, 3 ], true, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return a Float64Array' ); - } - } - b.toc(); - if ( !isFloat64Array( v ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/flatten5d/docs/repl.txt b/base/flatten5d/docs/repl.txt deleted file mode 100644 index d4031595b..000000000 --- a/base/flatten5d/docs/repl.txt +++ /dev/null @@ -1,80 +0,0 @@ - -{{alias}}( x, shape, colexicographic ) - Flattens a five-dimensional nested array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - shape: Array - Array shape. - - colexicographic: boolean - Specifies whether to flatten array values in colexicographic order. - - Returns - ------- - out: Array - Flattened array. - - Examples - -------- - > var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - > var out = {{alias}}( x, [ 2, 1, 1, 1, 2 ], false ) - [ 1, 2, 3, 4 ] - > out = {{alias}}( x, [ 2, 1, 1, 1, 2 ], true ) - [ 1, 3, 2, 4 ] - - -{{alias}}.assign( x, shape, colexicographic, out, stride, offset ) - Flattens a five-dimensional nested array and assigns elements to a provided - output array. - - The function assumes that all nested arrays have the same length (i.e., the - input array is *not* a ragged array). - - Parameters - ---------- - x: Array - Input array. - - shape: Array - Array shape. - - colexicographic: boolean - Specifies whether to flatten array values in colexicographic order. - - out: Collection - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - > var out = [ 0, 0, 0, 0 ]; - > var v = {{alias}}.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0 ) - [ 1, 2, 3, 4 ] - > var bool = ( v === out ) - true - > out = [ 0, 0, 0, 0 ]; - > {{alias}}.assign( x, [ 2, 1, 1, 1, 2 ], true, out, 1, 0 ); - > out - [ 1, 3, 2, 4 ] - - See Also - -------- - diff --git a/base/flatten5d/docs/types/index.d.ts b/base/flatten5d/docs/types/index.d.ts deleted file mode 100644 index d442e5ec6..000000000 --- a/base/flatten5d/docs/types/index.d.ts +++ /dev/null @@ -1,119 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Array5D } from '@stdlib/types/array'; -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Interface describing `flatten5d`. -*/ -interface Flatten5d { - /** - * Flattens a five-dimensional nested array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @returns flattened array - * - * @example - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true ); - * // returns [ 1, 3, 2, 4 ] - */ - ( x: Array5D, shape: Shape5D, colexicographic: boolean ): Array; - - /** - * Flattens a five-dimensional nested array and assigns elements to a provided output array. - * - * ## Notes - * - * - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). - * - * @param x - input array - * @param shape - array shape - * @param colexicographic - specifies whether to flatten array values in colexicographic order - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = flatten5d.assign( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0 ); - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - * - * var out = flatten5d.assign( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0 ); - * // returns [ 1, 3, 2, 4 ] - */ - assign( x: Array5D, shape: Shape5D, colexicographic: boolean, out: Collection, stride: number, offset: number ): Collection; -} - -/** -* Flattens a five-dimensional nested array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param x - input array -* @param shape - array shape -* @param colexicographic - specifies whether to flatten array values in colexicographic order -* @returns flattened array -* -* @example -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -*/ -declare var flatten5d: Flatten5d; - - -// EXPORTS // - -export = flatten5d; diff --git a/base/flatten5d/docs/types/test.ts b/base/flatten5d/docs/types/test.ts deleted file mode 100644 index 856a92ad6..000000000 --- a/base/flatten5d/docs/types/test.ts +++ /dev/null @@ -1,200 +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. -*/ - -import flatten5d = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - flatten5d( x, [ 2, 1, 1, 1, 2 ], false ); // $ExpectType number[] - flatten5d( x, [ 2, 1, 1, 1, 2 ], true ); // $ExpectType number[] - - flatten5d( x, [ 2, 1, 1, 1, 2 ], false ); // $ExpectType number[] - flatten5d( x, [ 2, 1, 1, 1, 2 ], true ); // $ExpectType number[] - - flatten5d( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], false ); // $ExpectType string[] - flatten5d( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], true ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - flatten5d( 1, [ 2, 1, 1, 1, 2 ], false ); // $ExpectError - flatten5d( true, [ 2, 1, 1, 1, 2 ], false ); // $ExpectError - flatten5d( false, [ 2, 1, 1, 1, 2 ], false ); // $ExpectError - flatten5d( null, [ 2, 1, 1, 1, 2 ], false ); // $ExpectError - flatten5d( void 0, [ 2, 1, 1, 1, 2 ], false ); // $ExpectError - flatten5d( {}, [ 2, 1, 1, 1, 2 ], false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - flatten5d( x, '', false ); // $ExpectError - flatten5d( x, 1, false ); // $ExpectError - flatten5d( x, true, false ); // $ExpectError - flatten5d( x, false, false ); // $ExpectError - flatten5d( x, null, false ); // $ExpectError - flatten5d( x, void 0, false ); // $ExpectError - flatten5d( x, {}, false ); // $ExpectError - flatten5d( x, [ 1, '2', 3 ], false ); // $ExpectError - flatten5d( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - flatten5d( x, [ 2, 1, 1, 1, 2 ], '' ); // $ExpectError - flatten5d( x, [ 2, 1, 1, 1, 2 ], 1 ); // $ExpectError - flatten5d( x, [ 2, 1, 1, 1, 2 ], null ); // $ExpectError - flatten5d( x, [ 2, 1, 1, 1, 2 ], void 0 ); // $ExpectError - flatten5d( x, [ 2, 1, 1, 1, 2 ], {} ); // $ExpectError - flatten5d( x, [ 2, 1, 1, 1, 2 ], [] ); // $ExpectError - flatten5d( x, [ 2, 1, 1, 1, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - flatten5d(); // $ExpectError - flatten5d( x ); // $ExpectError - flatten5d( x, [ 2, 1, 1, 1, 2 ] ); // $ExpectError - flatten5d( x, [ 2, 1, 1, 1, 2 ], false, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - const out1 = [ 0, 0, 0, 0 ]; - - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out1, 1, 0 ); // $ExpectType Collection - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], true, out1, 1, 0 ); // $ExpectType Collection - - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out1, 1, 0 ); // $ExpectType Collection - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], true, out1, 1, 0 ); // $ExpectType Collection - - const out2 = [ '', '', '', '' ]; - - flatten5d.assign( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], false, out2, 1, 0 ); // $ExpectType Collection - flatten5d.assign( [ [ [ [ [ '1', '2' ] ] ] ], [ [ [ [ '3', '4' ] ] ] ] ], [ 2, 1, 1, 1, 2 ], true, out2, 1, 0 ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - flatten5d.assign( 1, [ 2, 1, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten5d.assign( true, [ 2, 1, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten5d.assign( false, [ 2, 1, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten5d.assign( null, [ 2, 1, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten5d.assign( void 0, [ 2, 1, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError - flatten5d.assign( {}, [ 2, 1, 1, 1, 2 ], false, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten5d.assign( x, '', false, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, 1, false, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, true, false, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, false, false, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, null, false, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, void 0, false, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, {}, false, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 1, '2', 3 ], false, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, ( x: number ): number => x, false, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a boolean... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], '', out, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], 1, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], null, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], void 0, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], {}, out, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], [], out, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], ( x: number ): number => x, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, 1, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, true, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, false, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, null, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, void 0, 1, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, '1', 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, true, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, false, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, null, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, void 0, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, {}, 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, [], 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, '1' ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, true ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, false ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, null ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, void 0 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, {} ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, [] ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; - const out = [ 0, 0, 0, 0 ]; - - flatten5d.assign(); // $ExpectError - flatten5d.assign( x ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ] ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1 ); // $ExpectError - flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], false, out, 1, 0, {} ); // $ExpectError -} diff --git a/base/flatten5d/examples/index.js b/base/flatten5d/examples/index.js deleted file mode 100644 index 0adb7ed41..000000000 --- a/base/flatten5d/examples/index.js +++ /dev/null @@ -1,81 +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'; - -var flatten5d = require( './../lib' ); - -// Define a 2x2x1x2x2 array: -var x = [ - [ - [ - [ - [ 1, 2 ], [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], [ 15, 16 ] - ] - ] - ] -]; - -var out = flatten5d( x, [ 0, 0, 0, 0, 0 ], false ); -console.log( out ); -// => [] - -out = flatten5d( x, [ 0, 0, 0, 0, 0 ], true ); -console.log( out ); -// => [] - -out = flatten5d( x, [ 1, 1, 1, 1, 1 ], false ); -console.log( out ); -// => [ 1 ] - -out = flatten5d( x, [ 1, 1, 1, 1, 1 ], true ); -console.log( out ); -// => [ 1 ] - -out = flatten5d( x, [ 1, 2, 1, 2, 2 ], false ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8 ] - -out = flatten5d( x, [ 1, 2, 1, 2, 2 ], true ); -console.log( out ); -// => [ 1, 5, 3, 7, 2, 6, 4, 8 ] - -out = flatten5d( x, [ 2, 2, 1, 2, 2 ], false ); -console.log( out ); -// => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] - -out = flatten5d( x, [ 2, 2, 1, 2, 2 ], true ); -console.log( out ); -// => [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] diff --git a/base/flatten5d/lib/assign.js b/base/flatten5d/lib/assign.js deleted file mode 100644 index e8afa070e..000000000 --- a/base/flatten5d/lib/assign.js +++ /dev/null @@ -1,119 +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. -*/ - -/* eslint-disable max-depth */ - -'use strict'; - -// MAIN // - -/** -* Flattens a five-dimensional nested array and assigns elements to a provided output array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>>>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0 ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0 ); -* // returns [ 1, 3, 2, 4 ] -*/ -function flatten5d( x, shape, colexicographic, out, stride, offset ) { - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var a0; - var a1; - var a2; - var a3; - var io; - - // Extract loop variables: - S0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - - // Iterate over the array dimensions... - io = offset; - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - for ( i3 = 0; i3 < S3; i3++ ) { - for ( i4 = 0; i4 < S4; i4++ ) { - out[ io ] = x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order - io += stride; - } - } - } - } - } - return out; - } - for ( i4 = 0; i4 < S4; i4++ ) { - a3 = x[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = a3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = a2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order - io += stride; - } - } - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten5d; diff --git a/base/flatten5d/lib/index.js b/base/flatten5d/lib/index.js deleted file mode 100644 index 25ba15c77..000000000 --- a/base/flatten5d/lib/index.js +++ /dev/null @@ -1,70 +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'; - -/** -* Flatten a five-dimensional nested array. -* -* @module @stdlib/array/base/flatten5d -* -* @example -* var flatten5d = require( '@stdlib/array/base/flatten5d' ); -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var flatten5d = require( '@stdlib/array/base/flatten5d' ); -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var flatten5d = require( '@stdlib/array/base/flatten5d' ); -* -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = new Float64Array( 4 ); -* var y = flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], true, out, 1, 0 ); -* // returns [ 1, 3, 2, 4 ] -* -* var bool = ( y === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flatten5d/lib/main.js b/base/flatten5d/lib/main.js deleted file mode 100644 index f5e66797e..000000000 --- a/base/flatten5d/lib/main.js +++ /dev/null @@ -1,112 +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. -*/ - -/* eslint-disable max-depth */ - -'use strict'; - -// MAIN // - -/** -* Flattens a five-dimensional nested array. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array). -* -* @param {Array>>>} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order -* @returns {Array} flattened array -* -* @example -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false ); -* // returns [ 1, 2, 3, 4 ] -* -* @example -* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ]; -* -* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true ); -* // returns [ 1, 3, 2, 4 ] -*/ -function flatten5d( x, shape, colexicographic ) { - var out; - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var a0; - var a1; - var a2; - var a3; - - // Extract loop variables: - S0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - - // Initialize an output array: - out = []; - - // Iterate over the array dimensions... - if ( colexicographic ) { - for ( i0 = 0; i0 < S0; i0++ ) { - for ( i1 = 0; i1 < S1; i1++ ) { - for ( i2 = 0; i2 < S2; i2++ ) { - for ( i3 = 0; i3 < S3; i3++ ) { - for ( i4 = 0; i4 < S4; i4++ ) { - out.push( x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order - } - } - } - } - } - return out; - } - for ( i4 = 0; i4 < S4; i4++ ) { - a3 = x[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - a2 = a3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - a1 = a2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - a0 = a1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - out.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order - } - } - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = flatten5d; diff --git a/base/flatten5d/package.json b/base/flatten5d/package.json deleted file mode 100644 index 753bb6e1c..000000000 --- a/base/flatten5d/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/flatten5d", - "version": "0.0.0", - "description": "Flatten a five-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flatten", - "flat", - "5d", - "tensor", - "strided", - "ndarray", - "multidimensional" - ] -} diff --git a/base/flatten5d/test/test.assign.js b/base/flatten5d/test/test.assign.js deleted file mode 100644 index e6c445874..000000000 --- a/base/flatten5d/test/test.assign.js +++ /dev/null @@ -1,380 +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 Float64Array = require( './../../../float64' ); -var flatten5d = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5d( x, [ 0, 0, 0, 0, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5d( x, [ 0, 0, 1, 0, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5d( x, [ 1, 0, 0, 1, 0 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten5d( x, [ 1, 1, 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten5d( x, [ 1, 1, 1, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten5d( x, [ 2, 1, 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten5d( x, [ 1, 2, 1, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten5d( x, [ 1, 2, 1, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 9, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten5d( x, [ 2, 2, 1, 1, 1 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 5, 6, 9, 10, 13, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten5d( x, [ 2, 2, 1, 1, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten5d( x, [ 2, 2, 1, 2, 2 ], false, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ] - ]; - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5d( x, [ 0, 0, 0, 0, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5d( x, [ 0, 0, 1, 0, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - out = new Float64Array( 0 ); - actual = flatten5d( x, [ 1, 0, 0, 1, 0 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1 ] ); - out = new Float64Array( 1 ); - actual = flatten5d( x, [ 1, 1, 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 2 ] ); - out = new Float64Array( 2 ); - actual = flatten5d( x, [ 1, 1, 1, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9 ] ); - out = new Float64Array( 2 ); - actual = flatten5d( x, [ 2, 1, 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 2, 6 ] ); - out = new Float64Array( 4 ); - actual = flatten5d( x, [ 1, 2, 1, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 5, 3, 7, 2, 6, 4, 8 ] ); - out = new Float64Array( 8 ); - actual = flatten5d( x, [ 1, 2, 1, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13 ] ); - out = new Float64Array( 4 ); - actual = flatten5d( x, [ 2, 2, 1, 1, 1 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 2, 10, 6, 14 ] ); - out = new Float64Array( 8 ); - actual = flatten5d( x, [ 2, 2, 1, 1, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ] ); // eslint-disable-line max-len - out = new Float64Array( 16 ); - actual = flatten5d( x, [ 2, 2, 1, 2, 2 ], true, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten5d( x, [ 1, 1, 1, 2, 2 ], false, out, 2, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing a stride (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 1, 0, 3, 0, 2, 0, 4, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten5d( x, [ 1, 1, 1, 2, 2 ], true, out, 2, 0 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 2, 3, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten5d( x, [ 1, 1, 1, 2, 2 ], false, out, 1, 2 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an offset (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 0, 1, 3, 2, 4, 0, 0 ] ); - out = new Float64Array( 8 ); - actual = flatten5d( x, [ 1, 1, 1, 2, 2 ], true, out, 1, 2 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (lexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 3, 0, 2, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten5d( x, [ 1, 1, 1, 2, 2 ], false, out, -2, 7 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports complex access patterns (colexicographic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ] - ]; - - expected = new Float64Array( [ 0, 4, 0, 2, 0, 3, 0, 1 ] ); - out = new Float64Array( 8 ); - actual = flatten5d( x, [ 1, 1, 1, 2, 2 ], true, out, -2, 7 ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flatten5d/test/test.js b/base/flatten5d/test/test.js deleted file mode 100644 index a99d0582c..000000000 --- a/base/flatten5d/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var flatten5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( flatten5d, 'assign' ), true, 'has property' ); - t.strictEqual( typeof flatten5d.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/flatten5d/test/test.main.js b/base/flatten5d/test/test.main.js deleted file mode 100644 index c581adfd5..000000000 --- a/base/flatten5d/test/test.main.js +++ /dev/null @@ -1,199 +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 flatten5d = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flatten5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function flattens a nested array (lexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ] - ]; - - expected = []; - actual = flatten5d( x, [ 0, 0, 0, 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten5d( x, [ 0, 0, 1, 0, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten5d( x, [ 1, 0, 0, 1, 0 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten5d( x, [ 1, 1, 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten5d( x, [ 1, 1, 1, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten5d( x, [ 2, 1, 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6 ]; - actual = flatten5d( x, [ 1, 2, 1, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = flatten5d( x, [ 1, 2, 1, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 9, 13 ]; - actual = flatten5d( x, [ 2, 2, 1, 1, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5, 6, 9, 10, 13, 14 ]; - actual = flatten5d( x, [ 2, 2, 1, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - actual = flatten5d( x, [ 2, 2, 1, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function flattens a nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ] - ], - [ - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ] - ]; - - expected = []; - actual = flatten5d( x, [ 0, 0, 0, 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten5d( x, [ 0, 0, 1, 0, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = flatten5d( x, [ 1, 0, 0, 1, 0 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1 ]; - actual = flatten5d( x, [ 1, 1, 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = flatten5d( x, [ 1, 1, 1, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9 ]; - actual = flatten5d( x, [ 2, 1, 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 2, 6 ]; - actual = flatten5d( x, [ 1, 2, 1, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 3, 7, 2, 6, 4, 8 ]; - actual = flatten5d( x, [ 1, 2, 1, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13 ]; - actual = flatten5d( x, [ 2, 2, 1, 1, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 2, 10, 6, 14 ]; - actual = flatten5d( x, [ 2, 2, 1, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8, 16 ]; - actual = flatten5d( x, [ 2, 2, 1, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/fliplr2d/README.md b/base/fliplr2d/README.md deleted file mode 100644 index c68e731ac..000000000 --- a/base/fliplr2d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# fliplr2d - -> Reverse the order of elements along the last dimension of a two-dimensional nested input array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var fliplr2d = require( '@stdlib/array/base/fliplr2d' ); -``` - -#### fliplr2d( x ) - -Reverses the order of elements along the last dimension of a two-dimensional nested input array. - -```javascript -var out = fliplr2d( [ [ 1, 2 ], [ 3, 4 ] ] ); -// returns [ [ 2, 1 ], [ 4, 3 ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var fliplr2d = require( '@stdlib/array/base/fliplr2d' ); - -var x = filled2dBy( [ 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = fliplr2d( x ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/fliplr2d/benchmark/benchmark.size.js b/base/fliplr2d/benchmark/benchmark.size.js deleted file mode 100644 index c1bbcca6c..000000000 --- a/base/fliplr2d/benchmark/benchmark.size.js +++ /dev/null @@ -1,107 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var fliplr2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fliplr2d( x ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( out[ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( out[ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/fliplr2d/docs/repl.txt b/base/fliplr2d/docs/repl.txt deleted file mode 100644 index e16467166..000000000 --- a/base/fliplr2d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( x ) - Reverses the order of elements along the last dimension of a two-dimensional - nested input array. - - The function does *not* perform a deep copy of nested array elements. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - [ [ 2, 1 ], [ 4, 3 ] ] - - See Also - -------- - diff --git a/base/fliplr2d/docs/types/index.d.ts b/base/fliplr2d/docs/types/index.d.ts deleted file mode 100644 index 36318618a..000000000 --- a/base/fliplr2d/docs/types/index.d.ts +++ /dev/null @@ -1,46 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; - -/** -* Reverses the order of elements along the last dimension of a two-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param x - input nested array -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; -* -* var out = fliplr2d( x ); -* // returns [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] -*/ -declare function fliplr2d( x: Array2D ): Array2D; - - -// EXPORTS // - -export = fliplr2d; diff --git a/base/fliplr2d/docs/types/test.ts b/base/fliplr2d/docs/types/test.ts deleted file mode 100644 index 6bba93cbb..000000000 --- a/base/fliplr2d/docs/types/test.ts +++ /dev/null @@ -1,48 +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. -*/ - -import fliplr2d = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - fliplr2d( x ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - fliplr2d( 'abc' ); // $ExpectError - fliplr2d( 1 ); // $ExpectError - fliplr2d( true ); // $ExpectError - fliplr2d( false ); // $ExpectError - fliplr2d( null ); // $ExpectError - fliplr2d( {} ); // $ExpectError - fliplr2d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - fliplr2d(); // $ExpectError - fliplr2d( x, 2 ); // $ExpectError -} diff --git a/base/fliplr2d/examples/index.js b/base/fliplr2d/examples/index.js deleted file mode 100644 index 32698f286..000000000 --- a/base/fliplr2d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var fliplr2d = require( './../lib' ); - -var x = filled2dBy( [ 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = fliplr2d( x ); -console.log( y ); diff --git a/base/fliplr2d/lib/index.js b/base/fliplr2d/lib/index.js deleted file mode 100644 index ecc0494d7..000000000 --- a/base/fliplr2d/lib/index.js +++ /dev/null @@ -1,42 +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'; - -/** -* Reverse the order of elements along the last dimension of a two-dimensional nested input array. -* -* @module @stdlib/array/base/fliplr2d -* -* @example -* var fliplr = require( '@stdlib/array/base/fliplr2d' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; -* -* var out = fliplr2d( x ); -* // returns [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/fliplr2d/lib/main.js b/base/fliplr2d/lib/main.js deleted file mode 100644 index 8570bb441..000000000 --- a/base/fliplr2d/lib/main.js +++ /dev/null @@ -1,61 +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'; - -// MAIN // - -/** -* Reverses the order of elements along the last dimension of a two-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param {ArrayLikeObject} x - nested input array -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; -* -* var out = fliplr2d( x ); -* // returns [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] -*/ -function fliplr2d( x ) { - var out; - var x0; - var y0; - var i1; - var i0; - - out = []; - for ( i1 = 0; i1 < x.length; i1++ ) { - x0 = x[ i1 ]; - y0 = []; - for ( i0 = x0.length-1; i0 >= 0; i0-- ) { - y0.push( x0[ i0 ] ); - } - out.push( y0 ); - } - return out; -} - - -// EXPORTS // - -module.exports = fliplr2d; diff --git a/base/fliplr2d/package.json b/base/fliplr2d/package.json deleted file mode 100644 index 02f810491..000000000 --- a/base/fliplr2d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/fliplr2d", - "version": "0.0.0", - "description": "Reverse the order of elements along the last dimension of a two-dimensional nested input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flip", - "reverse", - "transform", - "rotate", - "2d", - "matrix", - "ndarray", - "multidimensional" - ] -} diff --git a/base/fliplr2d/test/test.js b/base/fliplr2d/test/test.js deleted file mode 100644 index 4aec46f7a..000000000 --- a/base/fliplr2d/test/test.js +++ /dev/null @@ -1,117 +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 fliplr2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof fliplr2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function reverses the order of elements along the last dimension', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - expected = [ - [ 2, 1 ], - [ 4, 3 ] - ]; - actual = fliplr2d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ] - ]; - expected = [ - [ 4, 3, 2, 1 ], - [ 8, 7, 6, 5 ], - [ 12, 11, 10, 9 ] - ]; - actual = fliplr2d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ]; - expected = [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ]; - actual = fliplr2d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose first dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = []; - - x = []; - actual = fliplr2d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose second dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = [ - [], - [] - ]; - - x = [ - [], - [] - ]; - actual = fliplr2d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/fliplr3d/README.md b/base/fliplr3d/README.md deleted file mode 100644 index e9c6897d2..000000000 --- a/base/fliplr3d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# fliplr3d - -> Reverse the order of elements along the last dimension of a three-dimensional nested input array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var fliplr3d = require( '@stdlib/array/base/fliplr3d' ); -``` - -#### fliplr3d( x ) - -Reverses the order of elements along the last dimension of a three-dimensional nested input array. - -```javascript -var out = fliplr3d( [ [ [ 1, 2 ], [ 3, 4 ] ] ] ); -// returns [ [ [ 2, 1 ], [ 4, 3 ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var fliplr3d = require( '@stdlib/array/base/fliplr3d' ); - -var x = filled3dBy( [ 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = fliplr3d( x ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/fliplr3d/benchmark/benchmark.size.js b/base/fliplr3d/benchmark/benchmark.size.js deleted file mode 100644 index 603fd4baa..000000000 --- a/base/fliplr3d/benchmark/benchmark.size.js +++ /dev/null @@ -1,110 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var fliplr3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fliplr3d( x ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( out[ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( out[ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/fliplr3d/docs/repl.txt b/base/fliplr3d/docs/repl.txt deleted file mode 100644 index 37875f4d5..000000000 --- a/base/fliplr3d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( x ) - Reverses the order of elements along the last dimension of a three- - dimensional nested input array. - - The function does *not* perform a deep copy of nested array elements. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ [ [ 1, 2 ], [ 3, 4 ] ] ] ) - [ [ [ 2, 1 ], [ 4, 3 ] ] ] - - See Also - -------- - diff --git a/base/fliplr3d/docs/types/index.d.ts b/base/fliplr3d/docs/types/index.d.ts deleted file mode 100644 index b8ba7fc33..000000000 --- a/base/fliplr3d/docs/types/index.d.ts +++ /dev/null @@ -1,46 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; - -/** -* Reverses the order of elements along the last dimension of a three-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param x - input nested array -* @returns output array -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]; -* -* var out = fliplr3d( x ); -* // returns [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] -*/ -declare function fliplr3d( x: Array3D ): Array3D; - - -// EXPORTS // - -export = fliplr3d; diff --git a/base/fliplr3d/docs/types/test.ts b/base/fliplr3d/docs/types/test.ts deleted file mode 100644 index b67df3152..000000000 --- a/base/fliplr3d/docs/types/test.ts +++ /dev/null @@ -1,48 +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. -*/ - -import fliplr3d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - fliplr3d( x ); // $ExpectType Array3D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - fliplr3d( 'abc' ); // $ExpectError - fliplr3d( 1 ); // $ExpectError - fliplr3d( true ); // $ExpectError - fliplr3d( false ); // $ExpectError - fliplr3d( null ); // $ExpectError - fliplr3d( {} ); // $ExpectError - fliplr3d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - fliplr3d(); // $ExpectError - fliplr3d( x, 2 ); // $ExpectError -} diff --git a/base/fliplr3d/examples/index.js b/base/fliplr3d/examples/index.js deleted file mode 100644 index eef0837fd..000000000 --- a/base/fliplr3d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var fliplr3d = require( './../lib' ); - -var x = filled3dBy( [ 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = fliplr3d( x ); -console.log( y ); diff --git a/base/fliplr3d/lib/index.js b/base/fliplr3d/lib/index.js deleted file mode 100644 index 92d507804..000000000 --- a/base/fliplr3d/lib/index.js +++ /dev/null @@ -1,42 +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'; - -/** -* Reverse the order of elements along the last dimension of a three-dimensional nested input array. -* -* @module @stdlib/array/base/fliplr3d -* -* @example -* var fliplr = require( '@stdlib/array/base/fliplr3d' ); -* -* var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]; -* -* var out = fliplr3d( x ); -* // returns [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/fliplr3d/lib/main.js b/base/fliplr3d/lib/main.js deleted file mode 100644 index 25ed3cf39..000000000 --- a/base/fliplr3d/lib/main.js +++ /dev/null @@ -1,58 +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 fliplr2d = require( './../../../base/fliplr2d' ); - - -// MAIN // - -/** -* Reverses the order of elements along the last dimension of a three-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param {ArrayLikeObject>} x - nested input array -* @returns {Array>} output array -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]; -* -* var out = fliplr3d( x ); -* // returns [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] -*/ -function fliplr3d( x ) { - var out; - var i; - - out = []; - for ( i = 0; i < x.length; i++ ) { - out.push( fliplr2d( x[ i ] ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fliplr3d; diff --git a/base/fliplr3d/package.json b/base/fliplr3d/package.json deleted file mode 100644 index f77e5c9fa..000000000 --- a/base/fliplr3d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/fliplr3d", - "version": "0.0.0", - "description": "Reverse the order of elements along the last dimension of a three-dimensional nested input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flip", - "reverse", - "transform", - "rotate", - "3d", - "matrix", - "ndarray", - "multidimensional" - ] -} diff --git a/base/fliplr3d/test/test.js b/base/fliplr3d/test/test.js deleted file mode 100644 index 9bb7d2897..000000000 --- a/base/fliplr3d/test/test.js +++ /dev/null @@ -1,161 +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 fliplr3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof fliplr3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function reverses the order of elements along the last dimension', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - expected = [ - [ - [ 2, 1 ], - [ 4, 3 ] - ], - [ - [ 2, 1 ], - [ 4, 3 ] - ] - ]; - actual = fliplr3d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ] - ] - ]; - expected = [ - [ - [ 4, 3, 2, 1 ], - [ 8, 7, 6, 5 ], - [ 12, 11, 10, 9 ] - ] - ]; - actual = fliplr3d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ] - ]; - expected = [ - [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ] - ]; - actual = fliplr3d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose first dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = []; - - expected = []; - actual = fliplr3d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose second dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [], - [] - ]; - - expected = [ - [], - [] - ]; - actual = fliplr3d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose third dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [], - [] - ] - ]; - - expected = [ - [ - [], - [] - ] - ]; - actual = fliplr3d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/fliplr4d/README.md b/base/fliplr4d/README.md deleted file mode 100644 index 1ac5bb0ff..000000000 --- a/base/fliplr4d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# fliplr4d - -> Reverse the order of elements along the last dimension of a four-dimensional nested input array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var fliplr4d = require( '@stdlib/array/base/fliplr4d' ); -``` - -#### fliplr4d( x ) - -Reverses the order of elements along the last dimension of a four-dimensional nested input array. - -```javascript -var out = fliplr4d( [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ); -// returns [ [ [ [ 2, 1 ], [ 4, 3 ] ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var fliplr4d = require( '@stdlib/array/base/fliplr4d' ); - -var x = filled4dBy( [ 1, 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = fliplr4d( x ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/fliplr4d/benchmark/benchmark.size.js b/base/fliplr4d/benchmark/benchmark.size.js deleted file mode 100644 index 5345e873d..000000000 --- a/base/fliplr4d/benchmark/benchmark.size.js +++ /dev/null @@ -1,113 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var fliplr4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fliplr4d( x ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/fliplr4d/docs/repl.txt b/base/fliplr4d/docs/repl.txt deleted file mode 100644 index 06548e7cc..000000000 --- a/base/fliplr4d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( x ) - Reverses the order of elements along the last dimension of a four- - dimensional nested input array. - - The function does *not* perform a deep copy of nested array elements. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ) - [ [ [ [ 2, 1 ], [ 4, 3 ] ] ] ] - - See Also - -------- - diff --git a/base/fliplr4d/docs/types/index.d.ts b/base/fliplr4d/docs/types/index.d.ts deleted file mode 100644 index 6ab09078f..000000000 --- a/base/fliplr4d/docs/types/index.d.ts +++ /dev/null @@ -1,46 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; - -/** -* Reverses the order of elements along the last dimension of a four-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param x - input nested array -* @returns output array -* -* @example -* var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ]; -* -* var out = fliplr4d( x ); -* // returns [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ] -*/ -declare function fliplr4d( x: Array4D ): Array4D; - - -// EXPORTS // - -export = fliplr4d; diff --git a/base/fliplr4d/docs/types/test.ts b/base/fliplr4d/docs/types/test.ts deleted file mode 100644 index d3b7d3315..000000000 --- a/base/fliplr4d/docs/types/test.ts +++ /dev/null @@ -1,48 +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. -*/ - -import fliplr4d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - - fliplr4d( x ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - fliplr4d( 'abc' ); // $ExpectError - fliplr4d( 1 ); // $ExpectError - fliplr4d( true ); // $ExpectError - fliplr4d( false ); // $ExpectError - fliplr4d( null ); // $ExpectError - fliplr4d( {} ); // $ExpectError - fliplr4d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - - fliplr4d(); // $ExpectError - fliplr4d( x, 2 ); // $ExpectError -} diff --git a/base/fliplr4d/examples/index.js b/base/fliplr4d/examples/index.js deleted file mode 100644 index 83fb8a6fb..000000000 --- a/base/fliplr4d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var fliplr4d = require( './../lib' ); - -var x = filled4dBy( [ 1, 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = fliplr4d( x ); -console.log( y ); diff --git a/base/fliplr4d/lib/index.js b/base/fliplr4d/lib/index.js deleted file mode 100644 index 0a27c07a5..000000000 --- a/base/fliplr4d/lib/index.js +++ /dev/null @@ -1,42 +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'; - -/** -* Reverse the order of elements along the last dimension of a four-dimensional nested input array. -* -* @module @stdlib/array/base/fliplr4d -* -* @example -* var fliplr4d = require( '@stdlib/array/base/fliplr4d' ); -* -* var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ]; -* -* var out = fliplr4d( x ); -* // returns [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/fliplr4d/lib/main.js b/base/fliplr4d/lib/main.js deleted file mode 100644 index 2ed34a575..000000000 --- a/base/fliplr4d/lib/main.js +++ /dev/null @@ -1,58 +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 fliplr3d = require( './../../../base/fliplr3d' ); - - -// MAIN // - -/** -* Reverses the order of elements along the last dimension of a four-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param {ArrayLikeObject>>} x - nested input array -* @returns {Array>>} output array -* -* @example -* var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ]; -* -* var out = fliplr4d( x ); -* // returns [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ] -*/ -function fliplr4d( x ) { - var out; - var i; - - out = []; - for ( i = 0; i < x.length; i++ ) { - out.push( fliplr3d( x[ i ] ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fliplr4d; diff --git a/base/fliplr4d/package.json b/base/fliplr4d/package.json deleted file mode 100644 index fb7b000c0..000000000 --- a/base/fliplr4d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/fliplr4d", - "version": "0.0.0", - "description": "Reverse the order of elements along the last dimension of a four-dimensional nested input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flip", - "reverse", - "transform", - "rotate", - "4d", - "matrix", - "ndarray", - "multidimensional" - ] -} diff --git a/base/fliplr4d/test/test.js b/base/fliplr4d/test/test.js deleted file mode 100644 index b80ee79ce..000000000 --- a/base/fliplr4d/test/test.js +++ /dev/null @@ -1,225 +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 fliplr4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof fliplr4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function reverses the order of elements along the last dimension', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ]; - expected = [ - [ - [ - [ 2, 1 ], - [ 4, 3 ] - ], - [ - [ 2, 1 ], - [ 4, 3 ] - ] - ], - [ - [ - [ 2, 1 ], - [ 4, 3 ] - ], - [ - [ 2, 1 ], - [ 4, 3 ] - ] - ] - ]; - actual = fliplr4d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ] - ] - ] - ]; - expected = [ - [ - [ - [ 4, 3, 2, 1 ], - [ 8, 7, 6, 5 ], - [ 12, 11, 10, 9 ] - ] - ] - ]; - actual = fliplr4d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ] - ] - ]; - expected = [ - [ - [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ] - ] - ]; - actual = fliplr4d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose first dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = []; - - expected = []; - actual = fliplr4d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose second dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [], - [] - ]; - - expected = [ - [], - [] - ]; - actual = fliplr4d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose third dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [], - [] - ] - ]; - - expected = [ - [ - [], - [] - ] - ]; - actual = fliplr4d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose fourth dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [] - ], - [ - [] - ] - ] - ]; - - expected = [ - [ - [ - [] - ], - [ - [] - ] - ] - ]; - actual = fliplr4d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/fliplr5d/README.md b/base/fliplr5d/README.md deleted file mode 100644 index 352ec484b..000000000 --- a/base/fliplr5d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# fliplr5d - -> Reverse the order of elements along the last dimension of a five-dimensional nested input array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var fliplr5d = require( '@stdlib/array/base/fliplr5d' ); -``` - -#### fliplr5d( x ) - -Reverses the order of elements along the last dimension of a five-dimensional nested input array. - -```javascript -var out = fliplr5d( [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ); -// returns [ [ [ [ [ 2, 1 ], [ 4, 3 ] ] ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var fliplr5d = require( '@stdlib/array/base/fliplr5d' ); - -var x = filled5dBy( [ 1, 1, 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = fliplr5d( x ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/fliplr5d/benchmark/benchmark.size.js b/base/fliplr5d/benchmark/benchmark.size.js deleted file mode 100644 index c4699f04d..000000000 --- a/base/fliplr5d/benchmark/benchmark.size.js +++ /dev/null @@ -1,116 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var fliplr5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fliplr5d( x ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( out[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( out[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/fliplr5d/docs/repl.txt b/base/fliplr5d/docs/repl.txt deleted file mode 100644 index 04da0df43..000000000 --- a/base/fliplr5d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( x ) - Reverses the order of elements along the last dimension of a five- - dimensional nested input array. - - The function does *not* perform a deep copy of nested array elements. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ) - [ [ [ [ [ 2, 1 ], [ 4, 3 ] ] ] ] ] - - See Also - -------- - diff --git a/base/fliplr5d/docs/types/index.d.ts b/base/fliplr5d/docs/types/index.d.ts deleted file mode 100644 index 07d823c6c..000000000 --- a/base/fliplr5d/docs/types/index.d.ts +++ /dev/null @@ -1,46 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; - -/** -* Reverses the order of elements along the last dimension of a five-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param x - input nested array -* @returns output array -* -* @example -* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ]; -* -* var out = fliplr5d( x ); -* // returns [ [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ] ] -*/ -declare function fliplr5d( x: Array5D ): Array5D; - - -// EXPORTS // - -export = fliplr5d; diff --git a/base/fliplr5d/docs/types/test.ts b/base/fliplr5d/docs/types/test.ts deleted file mode 100644 index af4d0f00d..000000000 --- a/base/fliplr5d/docs/types/test.ts +++ /dev/null @@ -1,48 +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. -*/ - -import fliplr5d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - - fliplr5d( x ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - fliplr5d( 'abc' ); // $ExpectError - fliplr5d( 1 ); // $ExpectError - fliplr5d( true ); // $ExpectError - fliplr5d( false ); // $ExpectError - fliplr5d( null ); // $ExpectError - fliplr5d( {} ); // $ExpectError - fliplr5d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - - fliplr5d(); // $ExpectError - fliplr5d( x, 2 ); // $ExpectError -} diff --git a/base/fliplr5d/examples/index.js b/base/fliplr5d/examples/index.js deleted file mode 100644 index 5f8eea8fe..000000000 --- a/base/fliplr5d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var fliplr5d = require( './../lib' ); - -var x = filled5dBy( [ 1, 1, 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = fliplr5d( x ); -console.log( y ); diff --git a/base/fliplr5d/lib/index.js b/base/fliplr5d/lib/index.js deleted file mode 100644 index 0bcff03ad..000000000 --- a/base/fliplr5d/lib/index.js +++ /dev/null @@ -1,42 +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'; - -/** -* Reverse the order of elements along the last dimension of a five-dimensional nested input array. -* -* @module @stdlib/array/base/fliplr5d -* -* @example -* var fliplr5d = require( '@stdlib/array/base/fliplr5d' ); -* -* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ]; -* -* var out = fliplr5d( x ); -* // returns [ [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/fliplr5d/lib/main.js b/base/fliplr5d/lib/main.js deleted file mode 100644 index 7a4e26cc6..000000000 --- a/base/fliplr5d/lib/main.js +++ /dev/null @@ -1,58 +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 fliplr4d = require( './../../../base/fliplr4d' ); - - -// MAIN // - -/** -* Reverses the order of elements along the last dimension of a five-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param {ArrayLikeObject>>>} x - nested input array -* @returns {Array>>>} output array -* -* @example -* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ]; -* -* var out = fliplr5d( x ); -* // returns [ [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ] ] -*/ -function fliplr5d( x ) { - var out; - var i; - - out = []; - for ( i = 0; i < x.length; i++ ) { - out.push( fliplr4d( x[ i ] ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fliplr5d; diff --git a/base/fliplr5d/package.json b/base/fliplr5d/package.json deleted file mode 100644 index 9ab68dad8..000000000 --- a/base/fliplr5d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/fliplr5d", - "version": "0.0.0", - "description": "Reverse the order of elements along the last dimension of a five-dimensional nested input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flip", - "reverse", - "transform", - "rotate", - "5d", - "matrix", - "ndarray", - "multidimensional" - ] -} diff --git a/base/fliplr5d/test/test.js b/base/fliplr5d/test/test.js deleted file mode 100644 index d4bcee77a..000000000 --- a/base/fliplr5d/test/test.js +++ /dev/null @@ -1,317 +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 fliplr5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof fliplr5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function reverses the order of elements along the last dimension', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ], - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ] - ]; - expected = [ - [ - [ - [ - [ 2, 1 ], - [ 4, 3 ] - ], - [ - [ 2, 1 ], - [ 4, 3 ] - ] - ], - [ - [ - [ 2, 1 ], - [ 4, 3 ] - ], - [ - [ 2, 1 ], - [ 4, 3 ] - ] - ] - ], - [ - [ - [ - [ 2, 1 ], - [ 4, 3 ] - ], - [ - [ 2, 1 ], - [ 4, 3 ] - ] - ], - [ - [ - [ 2, 1 ], - [ 4, 3 ] - ], - [ - [ 2, 1 ], - [ 4, 3 ] - ] - ] - ] - ]; - actual = fliplr5d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ - [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ] - ] - ] - ] - ]; - expected = [ - [ - [ - [ - [ 4, 3, 2, 1 ], - [ 8, 7, 6, 5 ], - [ 12, 11, 10, 9 ] - ] - ] - ] - ]; - actual = fliplr5d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ - [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ] - ] - ] - ]; - expected = [ - [ - [ - [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ] - ] - ] - ]; - actual = fliplr5d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose first dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = []; - - expected = []; - actual = fliplr5d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose second dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [], - [] - ]; - - expected = [ - [], - [] - ]; - actual = fliplr5d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose third dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [], - [] - ] - ]; - - expected = [ - [ - [], - [] - ] - ]; - actual = fliplr5d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose fourth dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [] - ], - [ - [] - ] - ] - ]; - - expected = [ - [ - [ - [] - ], - [ - [] - ] - ] - ]; - actual = fliplr5d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose fifth dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ - [] - ], - [ - [] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [] - ], - [ - [] - ] - ] - ] - ]; - actual = fliplr5d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flipud2d/README.md b/base/flipud2d/README.md deleted file mode 100644 index 54e703206..000000000 --- a/base/flipud2d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# flipud2d - -> Reverse the order of elements along the first dimension of a two-dimensional nested input array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var flipud2d = require( '@stdlib/array/base/flipud2d' ); -``` - -#### flipud2d( x ) - -Reverses the order of elements along the first dimension of a two-dimensional nested input array. - -```javascript -var out = flipud2d( [ [ 1, 2 ], [ 3, 4 ] ] ); -// returns [ [ 3, 4 ], [ 1, 2 ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var flipud2d = require( '@stdlib/array/base/flipud2d' ); - -var x = filled2dBy( [ 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = flipud2d( x ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/flipud2d/benchmark/benchmark.size.js b/base/flipud2d/benchmark/benchmark.size.js deleted file mode 100644 index 820378a60..000000000 --- a/base/flipud2d/benchmark/benchmark.size.js +++ /dev/null @@ -1,107 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var flipud2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = flipud2d( x ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( out[ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( out[ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/flipud2d/docs/repl.txt b/base/flipud2d/docs/repl.txt deleted file mode 100644 index dc8fe20b3..000000000 --- a/base/flipud2d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( x ) - Reverses the order of elements along the first dimension of a two- - dimensional nested input array. - - The function does *not* perform a deep copy of nested array elements. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - [ [ 3, 4 ], [ 1, 2 ] ] - - See Also - -------- - diff --git a/base/flipud2d/docs/types/index.d.ts b/base/flipud2d/docs/types/index.d.ts deleted file mode 100644 index 35a5c6235..000000000 --- a/base/flipud2d/docs/types/index.d.ts +++ /dev/null @@ -1,46 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; - -/** -* Reverses the order of elements along the first dimension of a two-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param x - input nested array -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; -* -* var out = flipud2d( x ); -* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] -*/ -declare function flipud2d( x: Array2D ): Array2D; - - -// EXPORTS // - -export = flipud2d; diff --git a/base/flipud2d/docs/types/test.ts b/base/flipud2d/docs/types/test.ts deleted file mode 100644 index 14c5409d3..000000000 --- a/base/flipud2d/docs/types/test.ts +++ /dev/null @@ -1,48 +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. -*/ - -import flipud2d = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flipud2d( x ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - flipud2d( 'abc' ); // $ExpectError - flipud2d( 1 ); // $ExpectError - flipud2d( true ); // $ExpectError - flipud2d( false ); // $ExpectError - flipud2d( null ); // $ExpectError - flipud2d( {} ); // $ExpectError - flipud2d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - flipud2d(); // $ExpectError - flipud2d( x, 2 ); // $ExpectError -} diff --git a/base/flipud2d/examples/index.js b/base/flipud2d/examples/index.js deleted file mode 100644 index 0e015fc23..000000000 --- a/base/flipud2d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var flipud2d = require( './../lib' ); - -var x = filled2dBy( [ 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = flipud2d( x ); -console.log( y ); diff --git a/base/flipud2d/lib/index.js b/base/flipud2d/lib/index.js deleted file mode 100644 index a10f99245..000000000 --- a/base/flipud2d/lib/index.js +++ /dev/null @@ -1,42 +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'; - -/** -* Reverse the order of elements along the first dimension of a two-dimensional nested input array. -* -* @module @stdlib/array/base/flipud2d -* -* @example -* var flipud2d = require( '@stdlib/array/base/flipud2d' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; -* -* var out = flipud2d( x ); -* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flipud2d/lib/main.js b/base/flipud2d/lib/main.js deleted file mode 100644 index a1f5bbb03..000000000 --- a/base/flipud2d/lib/main.js +++ /dev/null @@ -1,53 +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'; - -// MAIN // - -/** -* Reverses the order of elements along the first dimension of a two-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param {ArrayLikeObject} x - nested input array -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; -* -* var out = flipud2d( x ); -* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] -*/ -function flipud2d( x ) { - var out; - var i; - - out = []; - for ( i = x.length-1; i >= 0; i-- ) { - out.push( x[ i ] ); - } - return out; -} - - -// EXPORTS // - -module.exports = flipud2d; diff --git a/base/flipud2d/package.json b/base/flipud2d/package.json deleted file mode 100644 index 174be1835..000000000 --- a/base/flipud2d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/flipud2d", - "version": "0.0.0", - "description": "Reverse the order of elements along the first dimension of a two-dimensional nested input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flip", - "reverse", - "transform", - "rotate", - "2d", - "matrix", - "ndarray", - "multidimensional" - ] -} diff --git a/base/flipud2d/test/test.js b/base/flipud2d/test/test.js deleted file mode 100644 index 2a953d73c..000000000 --- a/base/flipud2d/test/test.js +++ /dev/null @@ -1,117 +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 flipud2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flipud2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function reverses the order of elements along the second-to-last dimension', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - expected = [ - [ 3, 4 ], - [ 1, 2 ] - ]; - actual = flipud2d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ] - ]; - expected = [ - [ 9, 10, 11, 12 ], - [ 5, 6, 7, 8 ], - [ 1, 2, 3, 4 ] - ]; - actual = flipud2d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ]; - expected = [ - [ 4 ], - [ 3 ], - [ 2 ], - [ 1 ] - ]; - actual = flipud2d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose first dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = []; - - x = []; - actual = flipud2d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose second dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = [ - [], - [] - ]; - - x = [ - [], - [] - ]; - actual = flipud2d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flipud3d/README.md b/base/flipud3d/README.md deleted file mode 100644 index aae9bea5c..000000000 --- a/base/flipud3d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# flipud3d - -> Reverse the order of elements along the second-to-last dimension of a three-dimensional nested input array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var flipud3d = require( '@stdlib/array/base/flipud3d' ); -``` - -#### flipud3d( x ) - -Reverses the order of elements along the second-to-last dimension of a three-dimensional nested input array. - -```javascript -var out = flipud3d( [ [ [ 1, 2 ], [ 3, 4 ] ] ] ); -// returns [ [ [ 3, 4 ], [ 1, 2 ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var flipud3d = require( '@stdlib/array/base/flipud3d' ); - -var x = filled3dBy( [ 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = flipud3d( x ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/flipud3d/benchmark/benchmark.size.js b/base/flipud3d/benchmark/benchmark.size.js deleted file mode 100644 index 6c5612610..000000000 --- a/base/flipud3d/benchmark/benchmark.size.js +++ /dev/null @@ -1,110 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var flipud3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = flipud3d( x ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( out[ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( out[ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/flipud3d/docs/repl.txt b/base/flipud3d/docs/repl.txt deleted file mode 100644 index dc7f36ca6..000000000 --- a/base/flipud3d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( x ) - Reverses the order of elements along the second-to-last dimension of a - three-dimensional nested input array. - - The function does *not* perform a deep copy of nested array elements. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ [ [ 1, 2 ], [ 3, 4 ] ] ] ) - [ [ [ 3, 4 ], [ 1, 2 ] ] ] - - See Also - -------- - diff --git a/base/flipud3d/docs/types/index.d.ts b/base/flipud3d/docs/types/index.d.ts deleted file mode 100644 index 4449210c4..000000000 --- a/base/flipud3d/docs/types/index.d.ts +++ /dev/null @@ -1,46 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; - -/** -* Reverses the order of elements along the second-to-last dimension of a three-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param x - input nested array -* @returns output array -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]; -* -* var out = flipud3d( x ); -* // returns [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] -*/ -declare function flipud3d( x: Array3D ): Array3D; - - -// EXPORTS // - -export = flipud3d; diff --git a/base/flipud3d/docs/types/test.ts b/base/flipud3d/docs/types/test.ts deleted file mode 100644 index 3acc220e8..000000000 --- a/base/flipud3d/docs/types/test.ts +++ /dev/null @@ -1,48 +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. -*/ - -import flipud3d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - flipud3d( x ); // $ExpectType Array3D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - flipud3d( 'abc' ); // $ExpectError - flipud3d( 1 ); // $ExpectError - flipud3d( true ); // $ExpectError - flipud3d( false ); // $ExpectError - flipud3d( null ); // $ExpectError - flipud3d( {} ); // $ExpectError - flipud3d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - flipud3d(); // $ExpectError - flipud3d( x, 2 ); // $ExpectError -} diff --git a/base/flipud3d/examples/index.js b/base/flipud3d/examples/index.js deleted file mode 100644 index 3c2dd04cb..000000000 --- a/base/flipud3d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var flipud3d = require( './../lib' ); - -var x = filled3dBy( [ 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = flipud3d( x ); -console.log( y ); diff --git a/base/flipud3d/lib/index.js b/base/flipud3d/lib/index.js deleted file mode 100644 index 441b0a2f4..000000000 --- a/base/flipud3d/lib/index.js +++ /dev/null @@ -1,42 +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'; - -/** -* Reverse the order of elements along the second-to-last dimension of a three-dimensional nested input array. -* -* @module @stdlib/array/base/flipud3d -* -* @example -* var flipud3d = require( '@stdlib/array/base/flipud3d' ); -* -* var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]; -* -* var out = flipud3d( x ); -* // returns [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flipud3d/lib/main.js b/base/flipud3d/lib/main.js deleted file mode 100644 index 8967d6be1..000000000 --- a/base/flipud3d/lib/main.js +++ /dev/null @@ -1,58 +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 flipud2d = require( './../../../base/flipud2d' ); - - -// MAIN // - -/** -* Reverses the order of elements along the second-to-last dimension of a three-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param {ArrayLikeObject>} x - nested input array -* @returns {Array>} output array -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]; -* -* var out = flipud3d( x ); -* // returns [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] -*/ -function flipud3d( x ) { - var out; - var i; - - out = []; - for ( i = 0; i < x.length; i++ ) { - out.push( flipud2d( x[ i ] ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = flipud3d; diff --git a/base/flipud3d/package.json b/base/flipud3d/package.json deleted file mode 100644 index fe5c68528..000000000 --- a/base/flipud3d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/flipud3d", - "version": "0.0.0", - "description": "Reverse the order of elements along the second-to-last dimension of a three-dimensional nested input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flip", - "reverse", - "transform", - "rotate", - "3d", - "matrix", - "ndarray", - "multidimensional" - ] -} diff --git a/base/flipud3d/test/test.js b/base/flipud3d/test/test.js deleted file mode 100644 index 40b81c2de..000000000 --- a/base/flipud3d/test/test.js +++ /dev/null @@ -1,161 +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 flipud3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flipud3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function reverses the order of elements along the second-to-last dimension', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - expected = [ - [ - [ 3, 4 ], - [ 1, 2 ] - ], - [ - [ 3, 4 ], - [ 1, 2 ] - ] - ]; - actual = flipud3d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ] - ] - ]; - expected = [ - [ - [ 9, 10, 11, 12 ], - [ 5, 6, 7, 8 ], - [ 1, 2, 3, 4 ] - ] - ]; - actual = flipud3d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ] - ]; - expected = [ - [ - [ 4 ], - [ 3 ], - [ 2 ], - [ 1 ] - ] - ]; - actual = flipud3d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose first dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = []; - - x = []; - actual = flipud3d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose second dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = [ - [], - [] - ]; - - x = [ - [], - [] - ]; - actual = flipud3d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose third dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = [ - [ - [], - [] - ] - ]; - - x = [ - [ - [], - [] - ] - ]; - actual = flipud3d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flipud4d/README.md b/base/flipud4d/README.md deleted file mode 100644 index 08f69e6a4..000000000 --- a/base/flipud4d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# flipud4d - -> Reverse the order of elements along the second-to-last dimension of a four-dimensional nested input array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var flipud4d = require( '@stdlib/array/base/flipud4d' ); -``` - -#### flipud4d( x ) - -Reverses the order of elements along the second-to-last dimension of a four-dimensional nested input array. - -```javascript -var out = flipud4d( [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ); -// returns [ [ [ [ 3, 4 ], [ 1, 2 ] ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var flipud4d = require( '@stdlib/array/base/flipud4d' ); - -var x = filled4dBy( [ 2, 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = flipud4d( x ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/flipud4d/benchmark/benchmark.size.js b/base/flipud4d/benchmark/benchmark.size.js deleted file mode 100644 index 1feb6f0ce..000000000 --- a/base/flipud4d/benchmark/benchmark.size.js +++ /dev/null @@ -1,113 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var flipud4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = flipud4d( x ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/flipud4d/docs/repl.txt b/base/flipud4d/docs/repl.txt deleted file mode 100644 index b9ba8d89b..000000000 --- a/base/flipud4d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( x ) - Reverses the order of elements along the second-to-last dimension of a four- - dimensional nested input array. - - The function does *not* perform a deep copy of nested array elements. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ) - [ [ [ [ 3, 4 ], [ 1, 2 ] ] ] ] - - See Also - -------- - diff --git a/base/flipud4d/docs/types/index.d.ts b/base/flipud4d/docs/types/index.d.ts deleted file mode 100644 index 0162f87d1..000000000 --- a/base/flipud4d/docs/types/index.d.ts +++ /dev/null @@ -1,46 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; - -/** -* Reverses the order of elements along the second-to-last dimension of a four-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param x - input nested array -* @returns output array -* -* @example -* var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ]; -* -* var out = flipud4d( x ); -* // returns [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ] -*/ -declare function flipud4d( x: Array4D ): Array4D; - - -// EXPORTS // - -export = flipud4d; diff --git a/base/flipud4d/docs/types/test.ts b/base/flipud4d/docs/types/test.ts deleted file mode 100644 index 4e88ae79d..000000000 --- a/base/flipud4d/docs/types/test.ts +++ /dev/null @@ -1,48 +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. -*/ - -import flipud4d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - - flipud4d( x ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - flipud4d( 'abc' ); // $ExpectError - flipud4d( 1 ); // $ExpectError - flipud4d( true ); // $ExpectError - flipud4d( false ); // $ExpectError - flipud4d( null ); // $ExpectError - flipud4d( {} ); // $ExpectError - flipud4d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ]; - - flipud4d(); // $ExpectError - flipud4d( x, 2 ); // $ExpectError -} diff --git a/base/flipud4d/examples/index.js b/base/flipud4d/examples/index.js deleted file mode 100644 index c78c60bbc..000000000 --- a/base/flipud4d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var flipud4d = require( './../lib' ); - -var x = filled4dBy( [ 2, 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = flipud4d( x ); -console.log( y ); diff --git a/base/flipud4d/lib/index.js b/base/flipud4d/lib/index.js deleted file mode 100644 index 62a6d0b6b..000000000 --- a/base/flipud4d/lib/index.js +++ /dev/null @@ -1,42 +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'; - -/** -* Reverse the order of elements along the second-to-last dimension of a four-dimensional nested input array. -* -* @module @stdlib/array/base/flipud4d -* -* @example -* var flipud4d = require( '@stdlib/array/base/flipud4d' ); -* -* var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ]; -* -* var out = flipud4d( x ); -* // returns [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flipud4d/lib/main.js b/base/flipud4d/lib/main.js deleted file mode 100644 index 5e7511c78..000000000 --- a/base/flipud4d/lib/main.js +++ /dev/null @@ -1,58 +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 flipud3d = require( './../../../base/flipud3d' ); - - -// MAIN // - -/** -* Reverses the order of elements along the second-to-last dimension of a four-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param {ArrayLikeObject>>} x - nested input array -* @returns {Array>>} output array -* -* @example -* var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ]; -* -* var out = flipud4d( x ); -* // returns [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ] -*/ -function flipud4d( x ) { - var out; - var i; - - out = []; - for ( i = 0; i < x.length; i++ ) { - out.push( flipud3d( x[ i ] ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = flipud4d; diff --git a/base/flipud4d/package.json b/base/flipud4d/package.json deleted file mode 100644 index b2a48313e..000000000 --- a/base/flipud4d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/flipud4d", - "version": "0.0.0", - "description": "Reverse the order of elements along the second-to-last dimension of a four-dimensional nested input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flip", - "reverse", - "transform", - "rotate", - "4d", - "matrix", - "ndarray", - "multidimensional" - ] -} diff --git a/base/flipud4d/test/test.js b/base/flipud4d/test/test.js deleted file mode 100644 index 1d048466e..000000000 --- a/base/flipud4d/test/test.js +++ /dev/null @@ -1,221 +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 flipud4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flipud4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function reverses the order of elements along the second-to-last dimension', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ]; - expected = [ - [ - [ - [ 3, 4 ], - [ 1, 2 ] - ], - [ - [ 3, 4 ], - [ 1, 2 ] - ] - ], - [ - [ - [ 3, 4 ], - [ 1, 2 ] - ], - [ - [ 3, 4 ], - [ 1, 2 ] - ] - ] - ]; - actual = flipud4d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ] - ] - ] - ]; - expected = [ - [ - [ - [ 9, 10, 11, 12 ], - [ 5, 6, 7, 8 ], - [ 1, 2, 3, 4 ] - ] - ] - ]; - actual = flipud4d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ] - ] - ]; - expected = [ - [ - [ - [ 4 ], - [ 3 ], - [ 2 ], - [ 1 ] - ] - ] - ]; - actual = flipud4d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose first dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = []; - - x = []; - actual = flipud4d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose second dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = [ - [], - [] - ]; - - x = [ - [], - [] - ]; - actual = flipud4d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose third dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = [ - [ - [], - [] - ] - ]; - - x = [ - [ - [], - [] - ] - ]; - actual = flipud4d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose fourth dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - x = [ - [ - [ - [], - [] - ] - ] - ]; - actual = flipud4d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/flipud5d/README.md b/base/flipud5d/README.md deleted file mode 100644 index 92634e93a..000000000 --- a/base/flipud5d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# flipud5d - -> Reverse the order of elements along the second-to-last dimension of a five-dimensional nested input array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var flipud5d = require( '@stdlib/array/base/flipud5d' ); -``` - -#### flipud5d( x ) - -Reverses the order of elements along the second-to-last dimension of a five-dimensional nested input array. - -```javascript -var out = flipud5d( [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ); -// returns [ [ [ [ [ 3, 4 ], [ 1, 2 ] ] ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var flipud5d = require( '@stdlib/array/base/flipud5d' ); - -var x = filled5dBy( [ 1, 2, 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = flipud5d( x ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/flipud5d/benchmark/benchmark.size.js b/base/flipud5d/benchmark/benchmark.size.js deleted file mode 100644 index e1a34db0d..000000000 --- a/base/flipud5d/benchmark/benchmark.size.js +++ /dev/null @@ -1,116 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var flipud5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = flipud5d( x ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( out[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( out[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/flipud5d/docs/repl.txt b/base/flipud5d/docs/repl.txt deleted file mode 100644 index 54275410d..000000000 --- a/base/flipud5d/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( x ) - Reverses the order of elements along the second-to-last dimension of a five- - dimensional nested input array. - - The function does *not* perform a deep copy of nested array elements. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ] ) - [ [ [ [ [ 3, 4 ], [ 1, 2 ] ] ] ] ] - - See Also - -------- - diff --git a/base/flipud5d/docs/types/index.d.ts b/base/flipud5d/docs/types/index.d.ts deleted file mode 100644 index ee3379750..000000000 --- a/base/flipud5d/docs/types/index.d.ts +++ /dev/null @@ -1,46 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; - -/** -* Reverses the order of elements along the second-to-last dimension of a five-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param x - input nested array -* @returns output array -* -* @example -* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ]; -* -* var out = flipud5d( x ); -* // returns [ [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ] ] -*/ -declare function flipud5d( x: Array5D ): Array5D; - - -// EXPORTS // - -export = flipud5d; diff --git a/base/flipud5d/docs/types/test.ts b/base/flipud5d/docs/types/test.ts deleted file mode 100644 index 168ec6f07..000000000 --- a/base/flipud5d/docs/types/test.ts +++ /dev/null @@ -1,48 +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. -*/ - -import flipud5d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - - flipud5d( x ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - flipud5d( 'abc' ); // $ExpectError - flipud5d( 1 ); // $ExpectError - flipud5d( true ); // $ExpectError - flipud5d( false ); // $ExpectError - flipud5d( null ); // $ExpectError - flipud5d( {} ); // $ExpectError - flipud5d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ]; - - flipud5d(); // $ExpectError - flipud5d( x, 2 ); // $ExpectError -} diff --git a/base/flipud5d/examples/index.js b/base/flipud5d/examples/index.js deleted file mode 100644 index 040fc0a34..000000000 --- a/base/flipud5d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var flipud5d = require( './../lib' ); - -var x = filled5dBy( [ 1, 2, 3, 3, 3 ], discreteUniform( -50, 50 ) ); -console.log( x ); - -var y = flipud5d( x ); -console.log( y ); diff --git a/base/flipud5d/lib/index.js b/base/flipud5d/lib/index.js deleted file mode 100644 index 8818da01f..000000000 --- a/base/flipud5d/lib/index.js +++ /dev/null @@ -1,42 +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'; - -/** -* Reverse the order of elements along the second-to-last dimension of a five-dimensional nested input array. -* -* @module @stdlib/array/base/flipud5d -* -* @example -* var flipud5d = require( '@stdlib/array/base/flipud5d' ); -* -* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ]; -* -* var out = flipud5d( x ); -* // returns [ [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/flipud5d/lib/main.js b/base/flipud5d/lib/main.js deleted file mode 100644 index 9c7f13835..000000000 --- a/base/flipud5d/lib/main.js +++ /dev/null @@ -1,58 +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 flipud4d = require( './../../../base/flipud4d' ); - - -// MAIN // - -/** -* Reverses the order of elements along the second-to-last dimension of a five-dimensional nested input array. -* -* ## Notes -* -* - The function does **not** perform a deep copy of nested array elements. -* -* @param {ArrayLikeObject>>>} x - nested input array -* @returns {Array>>>} output array -* -* @example -* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ]; -* -* var out = flipud5d( x ); -* // returns [ [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ] ] -*/ -function flipud5d( x ) { - var out; - var i; - - out = []; - for ( i = 0; i < x.length; i++ ) { - out.push( flipud4d( x[ i ] ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = flipud5d; diff --git a/base/flipud5d/package.json b/base/flipud5d/package.json deleted file mode 100644 index a374342c4..000000000 --- a/base/flipud5d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/flipud5d", - "version": "0.0.0", - "description": "Reverse the order of elements along the second-to-last dimension of a five-dimensional nested input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flip", - "reverse", - "transform", - "rotate", - "5d", - "matrix", - "ndarray", - "multidimensional" - ] -} diff --git a/base/flipud5d/test/test.js b/base/flipud5d/test/test.js deleted file mode 100644 index 9285a2e02..000000000 --- a/base/flipud5d/test/test.js +++ /dev/null @@ -1,309 +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 flipud5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof flipud5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function reverses the order of elements along the second-to-last dimension', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ], - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ] - ] - ]; - expected = [ - [ - [ - [ - [ 3, 4 ], - [ 1, 2 ] - ], - [ - [ 3, 4 ], - [ 1, 2 ] - ] - ], - [ - [ - [ 3, 4 ], - [ 1, 2 ] - ], - [ - [ 3, 4 ], - [ 1, 2 ] - ] - ] - ], - [ - [ - [ - [ 3, 4 ], - [ 1, 2 ] - ], - [ - [ 3, 4 ], - [ 1, 2 ] - ] - ], - [ - [ - [ 3, 4 ], - [ 1, 2 ] - ], - [ - [ 3, 4 ], - [ 1, 2 ] - ] - ] - ] - ]; - actual = flipud5d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ - [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ] - ] - ] - ] - ]; - expected = [ - [ - [ - [ - [ 9, 10, 11, 12 ], - [ 5, 6, 7, 8 ], - [ 1, 2, 3, 4 ] - ] - ] - ] - ]; - actual = flipud5d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ - [ - [ - [ - [ 1 ], - [ 2 ], - [ 3 ], - [ 4 ] - ] - ] - ] - ]; - expected = [ - [ - [ - [ - [ 4 ], - [ 3 ], - [ 2 ], - [ 1 ] - ] - ] - ] - ]; - actual = flipud5d( x ); - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose first dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = []; - - x = []; - actual = flipud5d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose second dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = [ - [], - [] - ]; - - x = [ - [], - [] - ]; - actual = flipud5d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose third dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = [ - [ - [], - [] - ] - ]; - - x = [ - [ - [], - [] - ] - ]; - actual = flipud5d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose fourth dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - x = [ - [ - [ - [], - [] - ] - ] - ]; - actual = flipud5d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided an array whose fifth dimension has a length equal to zero', function test( t ) { - var expected; - var actual; - var x; - - expected = [ - [ - [ - [ - [], - [] - ] - ] - ] - ]; - - x = [ - [ - [ - [ - [], - [] - ] - ] - ] - ]; - actual = flipud5d( x ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/for-each/README.md b/base/for-each/README.md deleted file mode 100644 index 5ed9b4cb3..000000000 --- a/base/for-each/README.md +++ /dev/null @@ -1,159 +0,0 @@ - - -# forEach - -> Invoke a callback function once for each array element. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var forEach = require( '@stdlib/array/base/for-each' ); -``` - -#### forEach( x, fcn\[, thisArg] ) - -Invokes a callback function once for each array element. - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var log = require( '@stdlib/console/log' ); - -var x = [ 1, 2, 3, 4 ]; - -forEach( x, naryFunction( log, 1 ) ); -``` - -The function accepts the following arguments: - -- **x**: input array. -- **fcn**: callback to apply. -- **thisArg**: callback execution context _(optional)_. - -To set the callback function execution context, provide a `thisArg`. - - - -```javascript -function accumulate( z ) { - this.sum += z; -} - -var x = [ 1, 2, 3, 4 ]; - -var ctx = { - 'sum': 0 -}; - -forEach( x, accumulate, ctx ); -var sum = ctx.sum; -// returns 10 -``` - -The callback function is provided the following arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the input array. - -
- - - - - -
- -## Notes - -- If provided an array-like object having a `forEach` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.forEach( fcn, thisArg ) - ``` - -- The function support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var log = require( '@stdlib/console/log' ); -var forEach = require( '@stdlib/array/base/for-each' ); - -var x = discreteUniform( 10, 0, 10, { - 'dtype': 'float64' -}); - -forEach( x, naryFunction( log, 1 ) ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/for-each/benchmark/benchmark.length.js b/base/for-each/benchmark/benchmark.length.js deleted file mode 100644 index 2c8876a49..000000000 --- a/base/for-each/benchmark/benchmark.length.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var forEach = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Callback invoked for each ndarray element. -* -* @private -* @param {number} value - array element -* @throws {Error} unexpected error -*/ -function clbk( value ) { - if ( isnan( value ) ) { - throw new Error( 'unexpected error' ); - } -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - forEach( x, clbk ); - if ( isnan( x[ i%len ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( x[ i%len ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/for-each/docs/repl.txt b/base/for-each/docs/repl.txt deleted file mode 100644 index 0ae0bc7b2..000000000 --- a/base/for-each/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, fcn[, thisArg] ) - Invoke a callback function once for each array element. - - The callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - If provided an array-like object having a `forEach` method , the function - defers execution to that method and assumes that the method has the - following signature: - - x.forEach( clbk, thisArg ) - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - fcn: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > function f( v ) { if ( v !== v ) { throw new Error( '...' ); } }; - > {{alias}}( x, f ); - - See Also - -------- - diff --git a/base/for-each/docs/types/index.d.ts b/base/for-each/docs/types/index.d.ts deleted file mode 100644 index 5eb2f0997..000000000 --- a/base/for-each/docs/types/index.d.ts +++ /dev/null @@ -1,103 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Callback invoked for each array element. -*/ -type Nullary = ( this: V ) => void; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -*/ -type Unary = ( this: V, value: T ) => void; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -* @param index - current array element index -*/ -type Binary = ( this: V, value: T, index: number ) => void; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -*/ -type Ternary = ( this: V, value: T, index: number, arr: U ) => void; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Invokes a callback function once for each array element. -* -* @param x - input array -* @param fcn - callback function -* @param thisArg - callback execution context -* -* @example -* var naryFunction = require( '@stdlib/utils/nary-function' ); -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var log = require( '@stdlib/console/log' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4] ); -* -* // Apply the callback function: -* forEach( x, naryFunction( log, 1 ) ); -*/ -declare function forEach( x: AccessorArrayLike, fcn: Callback, V>, thisArg?: ThisParameterType, V>> ): void; - -/** -* Invokes a callback function once for each array element. -* -* @param x - input array -* @param fcn - callback function -* @param thisArg - callback execution context -* -* @example -* var naryFunction = require( '@stdlib/utils/nary-function' ); -* var log = require( '@stdlib/console/log' ); -* -* var x = [ 1, 2, 3, 4]; -* -* // Apply the callback function: -* forEach( x, naryFunction( log, 1 ) ); -*/ -declare function forEach( x: Collection, fcn: Callback, V>, thisArg?: ThisParameterType, V>> ): void; - - -// EXPORTS // - -export = forEach; diff --git a/base/for-each/docs/types/test.ts b/base/for-each/docs/types/test.ts deleted file mode 100644 index 59ce89d93..000000000 --- a/base/for-each/docs/types/test.ts +++ /dev/null @@ -1,102 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import forEach = require( './index' ); - -/** -* Callback function. -* -* @param v - array element -* @throws unexpected error -*/ -function clbk( v: any ): void { - if ( v !== v ) { - throw new Error( 'unexpected error' ); - } -} - -// TESTS // - -// The function returns undefined... -{ - forEach( [ 1, 2, 3 ], clbk ); // $ExpectType void - forEach( new Float64Array( [ 1, 2, 3 ] ), clbk ); // $ExpectType void - forEach( new Float32Array( [ 1, 2, 3 ] ), clbk ); // $ExpectType void - forEach( new Int32Array( [ 1, 2, 3 ] ), clbk ); // $ExpectType void - forEach( new Int16Array( [ 1, 2, 3 ] ), clbk ); // $ExpectType void - forEach( new Int8Array( [ 1, 2, 3 ] ), clbk ); // $ExpectType void - forEach( new Uint32Array( [ 1, 2, 3 ] ), clbk ); // $ExpectType void - forEach( new Uint16Array( [ 1, 2, 3 ] ), clbk ); // $ExpectType void - forEach( new Uint8Array( [ 1, 2, 3 ] ), clbk ); // $ExpectType void - forEach( new Uint8ClampedArray( [ 1, 2, 3 ] ), clbk ); // $ExpectType void - forEach( toAccessorArray( [ 1, 2, 3 ] ), clbk ); // $ExpectType void - - forEach( [ 1, 2, 3 ], clbk, {} ); // $ExpectType void - forEach( new Float64Array( [ 1, 2, 3 ] ), clbk, {} ); // $ExpectType void - forEach( new Float32Array( [ 1, 2, 3 ] ), clbk, {} ); // $ExpectType void - forEach( new Int32Array( [ 1, 2, 3 ] ), clbk, {} ); // $ExpectType void - forEach( new Int16Array( [ 1, 2, 3 ] ), clbk, {} ); // $ExpectType void - forEach( new Int8Array( [ 1, 2, 3 ] ), clbk, {} ); // $ExpectType void - forEach( new Uint32Array( [ 1, 2, 3 ] ), clbk, {} ); // $ExpectType void - forEach( new Uint16Array( [ 1, 2, 3 ] ), clbk, {} ); // $ExpectType void - forEach( new Uint8Array( [ 1, 2, 3 ] ), clbk, {} ); // $ExpectType void - forEach( new Uint8ClampedArray( [ 1, 2, 3 ] ), clbk, {} ); // $ExpectType void - forEach( toAccessorArray( [ 1, 2, 3 ] ), clbk, {} ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - forEach( 2, clbk ); // $ExpectError - forEach( false, clbk ); // $ExpectError - forEach( true, clbk ); // $ExpectError - forEach( {}, clbk ); // $ExpectError - - forEach( 2, clbk, {} ); // $ExpectError - forEach( false, clbk, {} ); // $ExpectError - forEach( true, clbk, {} ); // $ExpectError - forEach( {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - forEach( [ 1, 2, 3 ], 'abc' ); // $ExpectError - forEach( [ 1, 2, 3 ], 2 ); // $ExpectError - forEach( [ 1, 2, 3 ], false ); // $ExpectError - forEach( [ 1, 2, 3 ], true ); // $ExpectError - forEach( [ 1, 2, 3 ], null ); // $ExpectError - forEach( [ 1, 2, 3 ], void 0 ); // $ExpectError - forEach( [ 1, 2, 3 ], {} ); // $ExpectError - forEach( [ 1, 2, 3 ], [] ); // $ExpectError - - forEach( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - forEach( [ 1, 2, 3 ], 2, {} ); // $ExpectError - forEach( [ 1, 2, 3 ], false, {} ); // $ExpectError - forEach( [ 1, 2, 3 ], true, {} ); // $ExpectError - forEach( [ 1, 2, 3 ], null, {} ); // $ExpectError - forEach( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - forEach( [ 1, 2, 3 ], {}, {} ); // $ExpectError - forEach( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - forEach(); // $ExpectError - forEach( [ 1, 2, 3 ] ); // $ExpectError - forEach( [ 1, 2, 3 ], clbk, {}, 3 ); // $ExpectError -} diff --git a/base/for-each/examples/index.js b/base/for-each/examples/index.js deleted file mode 100644 index 155086133..000000000 --- a/base/for-each/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var log = require( '@stdlib/console/log' ); -var forEach = require( './../lib' ); - -var x = discreteUniform( 10, 0, 10, { - 'dtype': 'float64' -}); - -forEach( x, naryFunction( log, 1 ) ); diff --git a/base/for-each/lib/index.js b/base/for-each/lib/index.js deleted file mode 100644 index 7dd6ce1a7..000000000 --- a/base/for-each/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a callback function once for each array element. -* -* @module @stdlib/array/base/for-each -* -* @example -* var naryFunction = require( '@stdlib/utils/nary-function' ); -* var log = require( '@stdlib/console/log' ); -* var forEach = require( '@stdlib/array/base/for-each' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* forEach( x, naryFunction( log, 1 ) ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/for-each/lib/main.js b/base/for-each/lib/main.js deleted file mode 100644 index 5ce27bad7..000000000 --- a/base/for-each/lib/main.js +++ /dev/null @@ -1,139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'forEach' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - -/** -* Invokes a callback function once for each array element. -* -* @private -* @param {Collection} x - input array -* @param {Function} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {void} -* -* @example -* var naryFunction = require( '@stdlib/utils/nary-function' ); -* var log = require( '@stdlib/console/log' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* forEach( x, naryFunction( log, 1 ) ); -*/ -function internal( x, clbk, thisArg ) { - var i; - for ( i = 0; i < x.length; i++ ) { - clbk.call( thisArg, x[ i ], i, x ); - } -} - -/** -* Invokes a callback function once for each array element. -* -* @private -* @param {Collection} x - input array -* @param {Function} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {void} -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* var naryFunction = require( '@stdlib/utils/nary-function' ); -* var log = require( '@stdlib/console/log' ); -* -* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) ); -* -* accessors( x, naryFunction( log, 1 ) ); -*/ -function accessors( x, clbk, thisArg ) { - var data; - var get; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - for ( i = 0; i < data.length; i++ ) { - clbk.call( thisArg, get( data, i ), i, data ); - } -} - - -// MAIN // - -/** -* Invokes a callback function once for each array element. -* -* @private -* @param {Collection} x - input array -* @param {Function} clbk - callback function -* @param {*} thisArg - callback execution context -* @returns {void} -* -* @example -* var naryFunction = require( '@stdlib/utils/nary-function' ); -* var log = require( '@stdlib/console/log' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* forEach( x, naryFunction( log, 1 ) ); -*/ -function forEach( x, clbk, thisArg ) { - var obj; - if ( hasMethod( x, 'forEach' ) ) { - return x.forEach( clbk, thisArg ); - } - obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, clbk, thisArg ); - } - return internal( x, clbk, thisArg ); -} - - -// EXPORTS // - -module.exports = forEach; diff --git a/base/for-each/package.json b/base/for-each/package.json deleted file mode 100644 index a2201fc94..000000000 --- a/base/for-each/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/for-each", - "version": "0.0.0", - "description": "Invoke a callback function once for each array element.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "callback", - "foreach", - "for-each", - "map" - ] -} diff --git a/base/for-each/test/test.js b/base/for-each/test/test.js deleted file mode 100644 index d69e83ea6..000000000 --- a/base/for-each/test/test.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var forEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof forEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a callback to each indexed element in an input array (generic)', function test( t ) { - var sum; - var x; - - x = [ 1, 2, 3, 4 ]; - sum = 0; - - forEach( x, clbk ); - - t.strictEqual( sum, 10, 'returns expected value' ); - t.end(); - - function clbk( v ) { - sum += v; - } -}); - -tape( 'the function applies a callback to each indexed element in an input array (typed array)', function test( t ) { - var sum; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - sum = 0.0; - - forEach( x, clbk ); - - t.strictEqual( sum, 10.0, 'returns expected value' ); - t.end(); - - function clbk( v ) { - sum += v; - } -}); - -tape( 'the function applies a callback to each indexed element in an input array (accessors)', function test( t ) { - var sum; - var x; - - x = new AccessorArray( [ 1.0, 2.0, 3.0, 4.0 ] ); - sum = 0.0; - - forEach( x, clbk ); - - t.strictEqual( sum, 10.0, 'returns expected value' ); - t.end(); - - function clbk( v ) { - sum += v; - } -}); - -tape( 'the function applies a callback to each indexed element in an input array (array-like object)', function test( t ) { - var sum; - var x; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - sum = 0; - - forEach( x, clbk ); - - t.strictEqual( sum, 10, 'returns expected value' ); - t.end(); - - function clbk( v ) { - sum += v; - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var x; - - ctx = { - 'sum': 0 - }; - x = [ 1, 2, 3, 4 ]; - - forEach( x, clbk, ctx ); - - t.strictEqual( ctx.sum, 10, 'returns expected value' ); - t.end(); - - function clbk( v ) { - this.sum += v; // eslint-disable-line no-invalid-this - } -}); diff --git a/base/from-strided/README.md b/base/from-strided/README.md deleted file mode 100644 index 1bb0498bd..000000000 --- a/base/from-strided/README.md +++ /dev/null @@ -1,106 +0,0 @@ - - -# strided2array - -> Convert a strided array to a non-strided generic array. - -
- -
- - - -
- -## Usage - -```javascript -var strided2array = require( '@stdlib/array/base/from-strided' ); -``` - -#### strided2array( N, x, stride, offset ) - -Converts a strided array to a non-strided generic array. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var arr = strided2array( 3, x, 2, 0 ); -// returns [ 1, 3, 5 ] -``` - -The function accepts the following arguments: - -- **N**: number of indexed elements. -- **x**: input array. -- **stride**: index stride. -- **offset**: index of the first indexed value in the input array. - -
- - - -
- -## Notes - -- The function assumes that the input array is compatible with the specified number of elements, index stride, and index offset. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var strided2array = require( '@stdlib/array/base/from-strided' ); - -var x = zeroTo( 10 ); -console.log( x ); - -var y = strided2array( 5, x, -2, x.length-1 ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/from-strided/benchmark/benchmark.js b/base/from-strided/benchmark/benchmark.js deleted file mode 100644 index 385e6f1a2..000000000 --- a/base/from-strided/benchmark/benchmark.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var strided2array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - number of elements -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - var x = zeroTo( N ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = strided2array( N, x, 1, 0 ); - if ( isnan( out[ i%N ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - if ( isnan( out[ i%N ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = pow( 10, i ); - f = createBenchmark( N ); - bench( pkg+':len='+N, f ); - } -} - -main(); diff --git a/base/from-strided/docs/repl.txt b/base/from-strided/docs/repl.txt deleted file mode 100644 index cfc39c6e1..000000000 --- a/base/from-strided/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( N, x, stride, offset ) - Converts a strided array to a non-strided generic array. - - The function assumes that the input array is compatible with the specified - number of elements, index stride, and index offset. - - Parameters - ---------- - N: integer - Number of indexed elements. - - x: ArrayLikeObject - Input array. - - stride: integer - Index stride. - - offset: integer - Index of the first indexed value in the input array. - - Examples - -------- - > var x = [ 1.0, 2.0, 3.0, 4.0 ]; - > var y = {{alias}}( 2, x, 2, 0 ) - [ 1.0, 3.0 ] - - See Also - -------- - diff --git a/base/from-strided/docs/types/index.d.ts b/base/from-strided/docs/types/index.d.ts deleted file mode 100644 index a01f7855a..000000000 --- a/base/from-strided/docs/types/index.d.ts +++ /dev/null @@ -1,49 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Converts a strided array to a non-strided generic array. -* -* ## Notes -* -* - The function assumes that the input array is compatible with the specified number of elements, index stride, and index offset. -* -* @param N - number of indexed elements -* @param x - input array -* @param stride - index stride -* @param offset - index of the first indexed value in the input array -* @returns two-dimensional nested array -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array( 3, x, 2, 0 ); -* // returns [ 1, 3, 5 ] -*/ -declare function strided2array( N: number, x: Collection, stride: number, offset: number ): Array; - - -// EXPORTS // - -export = strided2array; diff --git a/base/from-strided/docs/types/test.ts b/base/from-strided/docs/types/test.ts deleted file mode 100644 index 01541c16e..000000000 --- a/base/from-strided/docs/types/test.ts +++ /dev/null @@ -1,89 +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. -*/ - -import strided2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array( x.length, x, 1, 0 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array( 'abc', x, 1, 0 ); // $ExpectError - strided2array( true, x, 1, 0 ); // $ExpectError - strided2array( false, x, 1, 0 ); // $ExpectError - strided2array( null, x, 1, 0 ); // $ExpectError - strided2array( [ '1' ], x, 1, 0 ); // $ExpectError - strided2array( {}, x, 1, 0 ); // $ExpectError - strided2array( ( x: number ): number => x, x, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array... -{ - strided2array( 10, 3.14, 1, 0 ); // $ExpectError - strided2array( 10, true, 1, 0 ); // $ExpectError - strided2array( 10, false, 1, 0 ); // $ExpectError - strided2array( 10, null, 1, 0 ); // $ExpectError - strided2array( 10, {}, 1, 0 ); // $ExpectError - strided2array( 10, ( x: number ): number => x, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array( x.length, x, 'abc', 0 ); // $ExpectError - strided2array( x.length, x, true, 0 ); // $ExpectError - strided2array( x.length, x, false, 0 ); // $ExpectError - strided2array( x.length, x, null, 0 ); // $ExpectError - strided2array( x.length, x, [ '1' ], 0 ); // $ExpectError - strided2array( x.length, x, {}, 0 ); // $ExpectError - strided2array( x.length, x, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array( x.length, x, 1, 'abc' ); // $ExpectError - strided2array( x.length, x, 1, true ); // $ExpectError - strided2array( x.length, x, 1, false ); // $ExpectError - strided2array( x.length, x, 1, null ); // $ExpectError - strided2array( x.length, x, 1, [ '1' ] ); // $ExpectError - strided2array( x.length, x, 1, {} ); // $ExpectError - strided2array( x.length, x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array(); // $ExpectError - strided2array( x.length ); // $ExpectError - strided2array( x.length, x ); // $ExpectError - strided2array( x.length, x, 1 ); // $ExpectError - strided2array( x.length, x, 1, 0, {} ); // $ExpectError -} diff --git a/base/from-strided/examples/index.js b/base/from-strided/examples/index.js deleted file mode 100644 index de879f4f5..000000000 --- a/base/from-strided/examples/index.js +++ /dev/null @@ -1,28 +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'; - -var zeroTo = require( './../../../base/zero-to' ); -var strided2array = require( './../lib' ); - -var x = zeroTo( 10 ); -console.log( x ); - -var y = strided2array( 5, x, -2, x.length-1 ); -console.log( y ); diff --git a/base/from-strided/lib/index.js b/base/from-strided/lib/index.js deleted file mode 100644 index fe0a41920..000000000 --- a/base/from-strided/lib/index.js +++ /dev/null @@ -1,42 +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'; - -/** -* Convert a strided array to a non-strided generic array. -* -* @module @stdlib/array/base/from-strided -* -* @example -* var strided2array = require( '@stdlib/array/base/from-strided' ); -* -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array( 3, x, 2, 0 ); -* // returns [ 1, 3, 5 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/from-strided/lib/main.js b/base/from-strided/lib/main.js deleted file mode 100644 index 0ff96d089..000000000 --- a/base/from-strided/lib/main.js +++ /dev/null @@ -1,69 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Converts a strided array to a non-strided generic array. -* -* ## Notes -* -* - The function assumes that the input array is compatible with the specified number of elements, index stride, and index offset. -* -* @param {NonNegativeInteger} N - number of indexed elements -* @param {Collection} x - input array -* @param {integer} stride - index stride -* @param {NonNegativeInteger} offset - index of the first indexed value in the input array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array( 3, x, 2, 0 ); -* // returns [ 1, 3, 5 ] -*/ -function strided2array( N, x, stride, offset ) { - var out; - var get; - var ix; - var i; - - // Resolve an accessor function for retrieving array elements: - get = resolveGetter( x ); - - // Copy strided elements to a dense non-strided array... - ix = offset; - out = []; - for ( i = 0; i < N; i++ ) { - out.push( get( x, ix ) ); - ix += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = strided2array; diff --git a/base/from-strided/package.json b/base/from-strided/package.json deleted file mode 100644 index d19fb0c87..000000000 --- a/base/from-strided/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/from-strided", - "version": "0.0.0", - "description": "Convert a strided array to a non-strided generic array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "flat", - "linear", - "strided", - "ndarray", - "multidimensional" - ] -} diff --git a/base/from-strided/test/test.js b/base/from-strided/test/test.js deleted file mode 100644 index 248dafea3..000000000 --- a/base/from-strided/test/test.js +++ /dev/null @@ -1,79 +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 isArray = require( '@stdlib/assert/is-array' ); -var strided2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof strided2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts a strided array to generic array', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = strided2array( x.length, x, 1, 0 ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 3, 5, 7 ]; - actual = strided2array( 4, x, 2, 0 ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 4, 6, 8 ]; - actual = strided2array( 4, x, 2, 1 ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 3, 4, 5 ]; - actual = strided2array( 3, x, 1, 2 ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 8, 7, 6, 5, 4, 3, 2, 1 ]; - actual = strided2array( x.length, x, -1, x.length-1 ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 7, 5, 3 ]; - actual = strided2array( 3, x, -2, x.length-2 ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 5, 4, 3 ]; - actual = strided2array( 3, x, -1, x.length-4 ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/getter/README.md b/base/getter/README.md deleted file mode 100644 index c0222086e..000000000 --- a/base/getter/README.md +++ /dev/null @@ -1,157 +0,0 @@ - - -# getter - -> Return an accessor function for retrieving an element from an indexed array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var getter = require( '@stdlib/array/base/getter' ); -``` - -#### getter( dtype ) - -Returns an accessor function for retrieving an element from an indexed array-like object. - -```javascript -var arr = [ 1, 2, 3, 4 ]; - -var get = getter( 'generic' ); -var v = get( arr, 2 ); -// returns 3 -``` - -The returned accessor function accepts the following arguments: - -- **arr**: input array. -- **idx**: element index. - -
- - - - - -
- -## Notes - -- If provided an unsupported [`dtype`][@stdlib/array/dtypes], the function returns a default accessor function for accessing elements from any indexed array-like object; otherwise, the function returns an accessor function which should **only** be provided an array instance corresponding to `dtype` (e.g., if `dtype` is `'float64'`, the returned accessor function should only be provided instances of `Float64Array`). -- Accessor functions do **not** verify that provided input arrays are array instances corresponding to `dtype`, as doing so would introduce performance overhead. If array instances corresponding to other data types are provided to an accessor function, JavaScript runtimes will consider the function polymorphic, potentially triggering de-optimization. In order to ensure maximum performance, **always** ensure that an accessor function is monomorphic. -- Accessor functions do **not** perform bounds checking. -- An _indexed_ array-like object is a data structure in which one retrieves elements via integer indices using bracket `[]` notation (e.g., `Float64Array`, `Int32Array`, `Array`, etc). This is in contrast to an _accessor_ array-like object in which one retrieves elements using `get` and `set` methods (e.g., `Complex64Array` and `Complex128Array`). - -
- - - - - -
- -## Examples - - - -```javascript -var filled = require( '@stdlib/array/filled' ); -var dtype = require( '@stdlib/array/dtype' ); -var getter = require( '@stdlib/array/base/getter' ); - -var arr = filled( 1.0, 10, 'float64' ); -var v = getter( dtype( arr ) )( arr, 2 ); -// returns 1.0 - -arr = filled( 2.0, 10, 'float32' ); -v = getter( dtype( arr ) )( arr, 2 ); -// returns 2.0 - -arr = filled( 3, 10, 'int32' ); -v = getter( dtype( arr ) )( arr, 2 ); -// returns 3 - -arr = filled( 4, 10, 'int16' ); -v = getter( dtype( arr ) )( arr, 2 ); -// returns 4 - -arr = filled( 5, 10, 'int8' ); -v = getter( dtype( arr ) )( arr, 2 ); -// returns 5 - -arr = filled( 6, 10, 'uint32' ); -v = getter( dtype( arr ) )( arr, 2 ); -// returns 6 - -arr = filled( 7, 10, 'uint16' ); -v = getter( dtype( arr ) )( arr, 2 ); -// returns 7 - -arr = filled( 8, 10, 'uint8' ); -v = getter( dtype( arr ) )( arr, 2 ); -// returns 8 - -arr = filled( 9, 10, 'uint8c' ); -v = getter( dtype( arr ) )( arr, 2 ); -// returns 9 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/getter/benchmark/benchmark.js b/base/getter/benchmark/benchmark.js deleted file mode 100644 index 6c8da30c3..000000000 --- a/base/getter/benchmark/benchmark.js +++ /dev/null @@ -1,301 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isFunction = require( '@stdlib/assert/is-function' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var filledBy = require( './../../../filled-by' ); -var dtype = require( './../../../dtype' ); -var dtypes = require( './../../../dtypes' ); -var pkg = require( './../package.json' ).name; -var getter = require( './../lib' ); - - -// VARIABLES // - -var rand = discreteUniform( 0, 127 ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var get; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - get = getter( dt[ i%dt.length ] ); - if ( typeof get !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( get ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'generic', rand ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'float64', rand ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'float32', rand ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'int32', rand ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'int16', rand ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'int8', rand ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'uint32', rand ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'uint16', rand ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'uint8', rand ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'uint8c', rand ); - get = getter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/getter/docs/repl.txt b/base/getter/docs/repl.txt deleted file mode 100644 index 163b05ff3..000000000 --- a/base/getter/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( dtype ) - Returns an accessor function for retrieving an element from an indexed - array-like object. - - An accessor function accepts the following arguments: - - - arr: input array. - - idx: element index. - - If provided an unsupported `dtype`, the function returns a default accessor - function for accessing elements from any indexed array-like object. - - Otherwise, the function returns an accessor function which should *only* be - provided an array instance corresponding to `dtype` (e.g., if `dtype` is - 'float64', the returned accessor function should only be provided instances - of Float64Array). - - Accessor functions do *not* verify that provided input arrays are array - instances corresponding to `dtype`, as doing so would introduce performance - overhead. If array instances corresponding to other data types are provided - to an accessor function, JavaScript runtimes will consider the function - polymorphic, potentially triggering de-optimization. In order to ensure - maximum performance, *always* ensure that an accessor function is - monomorphic. - - Accessor functions do *not* perform bounds checking. - - Parameters - ---------- - dtype: string - Array data type. - - Returns - ------- - f: Function - Accessor function. - - Examples - -------- - > var f = {{alias}}( 'generic' ); - > var v = f( [ 1, 2, 3, 4 ], 2 ) - 3 - - See Also - -------- - diff --git a/base/getter/docs/types/index.d.ts b/base/getter/docs/types/index.d.ts deleted file mode 100644 index 905bcde5f..000000000 --- a/base/getter/docs/types/index.d.ts +++ /dev/null @@ -1,312 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/array'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an accessor function for retrieving an element from a `Float64Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var arr = new Float64Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( 'float64' ); -* var v = get( arr, 2 ); -* // returns 3.0 -*/ -declare function getter( dtype: 'float64' ): GetFloat64; - -/** -* Returns an accessor function for retrieving an element from a `Float32Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var arr = new Float32Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( 'float32' ); -* var v = get( arr, 2 ); -* // returns 3.0 -*/ -declare function getter( dtype: 'float32' ): GetFloat32; - -/** -* Returns an accessor function for retrieving an element from an `Int32Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var arr = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( 'int32' ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function getter( dtype: 'int32' ): GetInt32; - -/** -* Returns an accessor function for retrieving an element from an `Int16Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var arr = new Int16Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( 'int16' ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function getter( dtype: 'int16' ): GetInt16; - -/** -* Returns an accessor function for retrieving an element from an `Int8Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var arr = new Int8Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( 'int8' ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function getter( dtype: 'int8' ): GetInt8; - -/** -* Returns an accessor function for retrieving an element from a `Uint32Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var arr = new Uint32Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( 'uint32' ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function getter( dtype: 'uint32' ): GetUint32; - -/** -* Returns an accessor function for retrieving an element from a `Uint16Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var arr = new Uint16Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( 'uint16' ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function getter( dtype: 'uint16' ): GetUint16; - -/** -* Returns an accessor function for retrieving an element from a `Uint8Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var arr = new Uint8Array( [ 1, 2, 3, 4 ] ); -* -* var get = getter( 'uint8' ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function getter( dtype: 'uint8' ): GetUint8; - -/** -* Returns an accessor function for retrieving an element from a `Uint8ClampedArray`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var arr = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* -* var get = getter( 'uint8c' ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function getter( dtype: 'uint8c' ): GetUint8c; - -/** -* Returns an accessor function for retrieving an element from a "generic" array. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* var get = getter( 'generic' ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function getter( dtype: 'generic' ): GetGeneric; - -/** -* Returns an accessor function for retrieving an element from an indexed array-like object. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var dtype = require( '@stdlib/array/dtype' ); -* -* var arr = [ 1, 2, 3, 4 ]; -* -* var get = getter( dtype( arr ) ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function getter( dtype: string ): GetArrayLike; - - -// EXPORTS // - -export = getter; diff --git a/base/getter/docs/types/test.ts b/base/getter/docs/types/test.ts deleted file mode 100644 index 8e8efc881..000000000 --- a/base/getter/docs/types/test.ts +++ /dev/null @@ -1,319 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 getter = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - getter( 'float64' ); // $ExpectType GetFloat64 - getter( 'float32' ); // $ExpectType GetFloat32 - getter( 'int32' ); // $ExpectType GetInt32 - getter( 'int16' ); // $ExpectType GetInt16 - getter( 'int8' ); // $ExpectType GetInt8 - getter( 'uint32' ); // $ExpectType GetUint32 - getter( 'uint16' ); // $ExpectType GetUint16 - getter( 'uint8' ); // $ExpectType GetUint8 - getter( 'uint8c' ); // $ExpectType GetUint8c - getter( 'generic' ); // $ExpectType GetGeneric - getter( 'foo' ); // $ExpectType GetArrayLike -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - getter( 5 ); // $ExpectError - getter( true ); // $ExpectError - getter( false ); // $ExpectError - getter( null ); // $ExpectError - getter( {} ); // $ExpectError - getter( [] ); // $ExpectError - getter( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - getter(); // $ExpectError - getter( 'float64', {} ); // $ExpectError -} - -// The function returns a function which returns an array element... -{ - const get1 = getter( 'generic' ); - const x1 = [ 1, 2, 3, 4 ]; - get1( x1, 2 ); // $ExpectType number | void - - const get2 = getter( 'float64' ); - const x2 = new Float64Array( [ 1, 2, 3, 4 ] ); - get2( x2, 2 ); // $ExpectType number | void - - const get3 = getter( 'float32' ); - const x3 = new Float32Array( [ 1, 2, 3, 4 ] ); - get3( x3, 2 ); // $ExpectType number | void - - const get4 = getter( 'int32' ); - const x4 = new Int32Array( [ 1, 2, 3, 4 ] ); - get4( x4, 2 ); // $ExpectType number | void - - const get5 = getter( 'int16' ); - const x5 = new Int16Array( [ 1, 2, 3, 4 ] ); - get5( x5, 2 ); // $ExpectType number | void - - const get6 = getter( 'int8' ); - const x6 = new Int8Array( [ 1, 2, 3, 4 ] ); - get6( x6, 2 ); // $ExpectType number | void - - const get7 = getter( 'uint32' ); - const x7 = new Uint32Array( [ 1, 2, 3, 4 ] ); - get7( x7, 2 ); // $ExpectType number | void - - const get8 = getter( 'uint16' ); - const x8 = new Uint16Array( [ 1, 2, 3, 4 ] ); - get8( x8, 2 ); // $ExpectType number | void - - const get9 = getter( 'uint8' ); - const x9 = new Uint8Array( [ 1, 2, 3, 4 ] ); - get9( x9, 2 ); // $ExpectType number | void - - const get10 = getter( 'uint8c' ); - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); - get10( x10, 2 ); // $ExpectType number | void - - const get11 = getter( 'foo' ); - const x11 = [ 1, 2, 3, 4 ]; - get11( x11, 2 ); // $ExpectType unknown -} - -// The compiler throws an error if the returned function is provided a first argument which is not a collection... -{ - const get1 = getter( 'generic' ); - get1( 5, 2 ); // $ExpectError - get1( true, 2 ); // $ExpectError - get1( false, 2 ); // $ExpectError - get1( null, 2 ); // $ExpectError - get1( {}, 2 ); // $ExpectError - - const get2 = getter( 'float64' ); - get2( 5, 2 ); // $ExpectError - get2( true, 2 ); // $ExpectError - get2( false, 2 ); // $ExpectError - get2( null, 2 ); // $ExpectError - get2( {}, 2 ); // $ExpectError - - const get3 = getter( 'float32' ); - get3( 5, 2 ); // $ExpectError - get3( true, 2 ); // $ExpectError - get3( false, 2 ); // $ExpectError - get3( null, 2 ); // $ExpectError - get3( {}, 2 ); // $ExpectError - - const get4 = getter( 'int32' ); - get4( 5, 2 ); // $ExpectError - get4( true, 2 ); // $ExpectError - get4( false, 2 ); // $ExpectError - get4( null, 2 ); // $ExpectError - get4( {}, 2 ); // $ExpectError - - const get5 = getter( 'int16' ); - get5( 5, 2 ); // $ExpectError - get5( true, 2 ); // $ExpectError - get5( false, 2 ); // $ExpectError - get5( null, 2 ); // $ExpectError - get5( {}, 2 ); // $ExpectError - - const get6 = getter( 'int8' ); - get6( 5, 2 ); // $ExpectError - get6( true, 2 ); // $ExpectError - get6( false, 2 ); // $ExpectError - get6( null, 2 ); // $ExpectError - get6( {}, 2 ); // $ExpectError - - const get7 = getter( 'uint32' ); - get7( 5, 2 ); // $ExpectError - get7( true, 2 ); // $ExpectError - get7( false, 2 ); // $ExpectError - get7( null, 2 ); // $ExpectError - get7( {}, 2 ); // $ExpectError - - const get8 = getter( 'uint16' ); - get8( 5, 2 ); // $ExpectError - get8( true, 2 ); // $ExpectError - get8( false, 2 ); // $ExpectError - get8( null, 2 ); // $ExpectError - get8( {}, 2 ); // $ExpectError - - const get9 = getter( 'uint8' ); - get9( 5, 2 ); // $ExpectError - get9( true, 2 ); // $ExpectError - get9( false, 2 ); // $ExpectError - get9( null, 2 ); // $ExpectError - get9( {}, 2 ); // $ExpectError - - const get10 = getter( 'uint8c' ); - get10( 5, 2 ); // $ExpectError - get10( true, 2 ); // $ExpectError - get10( false, 2 ); // $ExpectError - get10( null, 2 ); // $ExpectError - get10( {}, 2 ); // $ExpectError - - const get11 = getter( 'foo' ); - get11( 5, 2 ); // $ExpectError - get11( true, 2 ); // $ExpectError - get11( false, 2 ); // $ExpectError - get11( null, 2 ); // $ExpectError - get11( {}, 2 ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided a second argument which is not a number... -{ - const get1 = getter( 'generic' ); - get1( [ 1, 2, 3, 4 ], '5' ); // $ExpectError - get1( [ 1, 2, 3, 4 ], true ); // $ExpectError - get1( [ 1, 2, 3, 4 ], false ); // $ExpectError - get1( [ 1, 2, 3, 4 ], null ); // $ExpectError - get1( [ 1, 2, 3, 4 ], {} ); // $ExpectError - - const get2 = getter( 'float64' ); - get2( new Float64Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get2( new Float64Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get2( new Float64Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get2( new Float64Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get2( new Float64Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get3 = getter( 'float32' ); - get3( new Float32Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get3( new Float32Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get3( new Float32Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get3( new Float32Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get3( new Float32Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get4 = getter( 'int32' ); - get4( new Int32Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get4( new Int32Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get4( new Int32Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get4( new Int32Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get4( new Int32Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get5 = getter( 'int16' ); - get5( new Int16Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get5( new Int16Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get5( new Int16Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get5( new Int16Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get5( new Int16Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get6 = getter( 'int8' ); - get6( new Int8Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get6( new Int8Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get6( new Int8Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get6( new Int8Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get6( new Int8Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get7 = getter( 'uint32' ); - get7( new Uint32Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get7( new Uint32Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get7( new Uint32Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get7( new Uint32Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get7( new Uint32Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get8 = getter( 'uint16' ); - get8( new Uint16Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get8( new Uint16Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get8( new Uint16Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get8( new Uint16Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get8( new Uint16Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get9 = getter( 'uint8' ); - get9( new Uint8Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get9( new Uint8Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get9( new Uint8Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get9( new Uint8Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get9( new Uint8Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get10 = getter( 'uint8c' ); - get10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get11 = getter( 'foo' ); - get11( [ 1, 2, 3, 4 ], '5' ); // $ExpectError - get11( [ 1, 2, 3, 4 ], true ); // $ExpectError - get11( [ 1, 2, 3, 4 ], false ); // $ExpectError - get11( [ 1, 2, 3, 4 ], null ); // $ExpectError - get11( [ 1, 2, 3, 4 ], {} ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided an unsupported number of arguments... -{ - const get1 = getter( 'generic' ); - get1(); // $ExpectError - get1( [] ); // $ExpectError - get1( [], 1, 2 ); // $ExpectError - - const get2 = getter( 'float64' ); - get2(); // $ExpectError - get2( new Float64Array( [] ) ); // $ExpectError - get2( new Float64Array( [] ), 1, 2 ); // $ExpectError - - const get3 = getter( 'float32' ); - get3(); // $ExpectError - get3( new Float32Array( [] ) ); // $ExpectError - get3( new Float32Array( [] ), 1, 2 ); // $ExpectError - - const get4 = getter( 'int32' ); - get4(); // $ExpectError - get4( new Int32Array( [] ) ); // $ExpectError - get4( new Int32Array( [] ), 1, 2 ); // $ExpectError - - const get5 = getter( 'int16' ); - get5(); // $ExpectError - get5( new Int16Array( [] ) ); // $ExpectError - get5( new Int16Array( [] ), 1, 2 ); // $ExpectError - - const get6 = getter( 'int8' ); - get6(); // $ExpectError - get6( new Int8Array( [] ) ); // $ExpectError - get6( new Int8Array( [] ), 1, 2 ); // $ExpectError - - const get7 = getter( 'uint32' ); - get7(); // $ExpectError - get7( new Uint32Array( [] ) ); // $ExpectError - get7( new Uint32Array( [] ), 1, 2 ); // $ExpectError - - const get8 = getter( 'uint16' ); - get8(); // $ExpectError - get8( new Uint16Array( [] ) ); // $ExpectError - get8( new Uint16Array( [] ), 1, 2 ); // $ExpectError - - const get9 = getter( 'uint8' ); - get9(); // $ExpectError - get9( new Uint8Array( [] ) ); // $ExpectError - get9( new Uint8Array( [] ), 1, 2 ); // $ExpectError - - const get10 = getter( 'uint8c' ); - get10(); // $ExpectError - get10( new Uint8ClampedArray( [] ) ); // $ExpectError - get10( new Uint8ClampedArray( [] ), 1, 2 ); // $ExpectError - - const get11 = getter( 'foo' ); - get11(); // $ExpectError - get11( [] ); // $ExpectError - get11( [], 1, 2 ); // $ExpectError -} diff --git a/base/getter/examples/index.js b/base/getter/examples/index.js deleted file mode 100644 index d00dd16f6..000000000 --- a/base/getter/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 filled = require( './../../../filled' ); -var dtype = require( './../../../dtype' ); -var getter = require( './../lib' ); - -var arr = filled( 1.0, 10, 'float64' ); -var v = getter( dtype( arr ) )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 2.0, 10, 'float32' ); -v = getter( dtype( arr ) )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 3, 10, 'int32' ); -v = getter( dtype( arr ) )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 4, 10, 'int16' ); -v = getter( dtype( arr ) )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 5, 10, 'int8' ); -v = getter( dtype( arr ) )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 6, 10, 'uint32' ); -v = getter( dtype( arr ) )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 7, 10, 'uint16' ); -v = getter( dtype( arr ) )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 8, 10, 'uint8' ); -v = getter( dtype( arr ) )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 9, 10, 'uint8c' ); -v = getter( dtype( arr ) )( arr, 2 ); -console.log( 'v: %d', v ); diff --git a/base/getter/lib/index.js b/base/getter/lib/index.js deleted file mode 100644 index db876e417..000000000 --- a/base/getter/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an accessor function for retrieving an element from an indexed array-like object. -* -* @module @stdlib/array/base/getter -* -* @example -* var dtype = require( '@stdlib/array/dtype' ); -* var getter = require( '@stdlib/array/base/getter' ); -* -* var arr = [ 1, 2, 3, 4 ]; -* -* var get = getter( dtype( arr ) ); -* var v = get( arr, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/getter/lib/main.js b/base/getter/lib/main.js deleted file mode 100644 index be33074da..000000000 --- a/base/getter/lib/main.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var GETTERS = { - 'float64': getFloat64, - 'float32': getFloat32, - 'int32': getInt32, - 'int16': getInt16, - 'int8': getInt8, - 'uint32': getUint32, - 'uint16': getUint16, - 'uint8': getUint8, - 'uint8c': getUint8c, - 'generic': getGeneric, - 'default': getArrayLike -}; - - -// FUNCTIONS // - -/** -* Returns an element from a `Float64Array`. -* -* @private -* @param {Float64Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {number} element value -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var arr = new Float64Array( [ 1, 2, 3, 4 ] ); -* -* var v = getFloat64( arr, 2 ); -* // returns 3.0 -*/ -function getFloat64( arr, idx ) { - return arr[ idx ]; -} - -/** -* Returns an element from a `Float32Array`. -* -* @private -* @param {Float32Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {number} element value -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var arr = new Float32Array( [ 1, 2, 3, 4 ] ); -* -* var v = getFloat32( arr, 2 ); -* // returns 3.0 -*/ -function getFloat32( arr, idx ) { - return arr[ idx ]; -} - -/** -* Returns an element from an `Int32Array`. -* -* @private -* @param {Int32Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {number} element value -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var arr = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var v = getInt32( arr, 2 ); -* // returns 3 -*/ -function getInt32( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point - return arr[ idx ]; -} - -/** -* Returns an element from an `Int16Array`. -* -* @private -* @param {Int16Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {number} element value -* -* @example -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var arr = new Int16Array( [ 1, 2, 3, 4 ] ); -* -* var v = getInt16( arr, 2 ); -* // returns 3 -*/ -function getInt16( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point - return arr[ idx ]; -} - -/** -* Returns an element from an `Int8Array`. -* -* @private -* @param {Int8Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {number} element value -* -* @example -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var arr = new Int8Array( [ 1, 2, 3, 4 ] ); -* -* var v = getInt8( arr, 2 ); -* // returns 3 -*/ -function getInt8( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point - return arr[ idx ]; -} - -/** -* Returns an element from a `Uint32Array`. -* -* @private -* @param {Uint32Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {number} element value -* -* @example -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var arr = new Uint32Array( [ 1, 2, 3, 4 ] ); -* -* var v = getUint32( arr, 2 ); -* // returns 3 -*/ -function getUint32( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point - return arr[ idx ]; -} - -/** -* Returns an element from a `Uint16Array`. -* -* @private -* @param {Uint16Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {number} element value -* -* @example -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var arr = new Uint16Array( [ 1, 2, 3, 4 ] ); -* -* var v = getUint16( arr, 2 ); -* // returns 3 -*/ -function getUint16( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point - return arr[ idx ]; -} - -/** -* Returns an element from a `Uint8Array`. -* -* @private -* @param {Uint8Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {number} element value -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var arr = new Uint8Array( [ 1, 2, 3, 4 ] ); -* -* var v = getUint8( arr, 2 ); -* // returns 3 -*/ -function getUint8( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point - return arr[ idx ]; -} - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @private -* @param {Uint8ClampedArray} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {number} element value -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var arr = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* -* var v = getUint8c( arr, 2 ); -* // returns 3 -*/ -function getUint8c( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point - return arr[ idx ]; -} - -/** -* Returns an element from a generic `Array`. -* -* @private -* @param {Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element value -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* var v = getGeneric( arr, 2 ); -* // returns 3 -*/ -function getGeneric( arr, idx ) { - return arr[ idx ]; -} - -/** -* Returns an element from an indexed array-like object. -* -* @private -* @param {Collection} arr - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element value -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* var v = getArrayLike( arr, 2 ); -* // returns 3 -*/ -function getArrayLike( arr, idx ) { - return arr[ idx ]; -} - - -// MAIN // - -/** -* Returns an accessor function for retrieving an element from an indexed array-like object. -* -* @param {string} dtype - array dtype -* @returns {Function} accessor -* -* @example -* var dtype = require( '@stdlib/array/dtype' ); -* -* var arr = [ 1, 2, 3, 4 ]; -* -* var get = getter( dtype( arr ) ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -function getter( dtype ) { - var f = GETTERS[ dtype ]; - if ( typeof f === 'function' ) { - return f; - } - return GETTERS.default; -} - - -// EXPORTS // - -module.exports = getter; diff --git a/base/getter/package.json b/base/getter/package.json deleted file mode 100644 index e146bf219..000000000 --- a/base/getter/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/getter", - "version": "0.0.0", - "description": "Return an accessor function for retrieving an element from an indexed array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "array", - "generic", - "get", - "accessor", - "access", - "retrieve", - "getter" - ] -} diff --git a/base/getter/test/test.js b/base/getter/test/test.js deleted file mode 100644 index c4f3dafd6..000000000 --- a/base/getter/test/test.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 filled = require( './../../../filled' ); -var dtypes = require( './../../../typed-real-dtypes' ); -var getter = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -DTYPES.push( 'generic' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof getter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function for returning an array element', function test( t ) { - var arr; - var get; - var dt; - var v; - var i; - - for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - get = getter( dt ); - arr = filled( i+1, 10, dt ); - v = get( arr, 2 ); - t.strictEqual( v, i+1, 'returns expected value for dtype: '+dt ); - } - t.end(); -}); - -tape( 'the function returns a function for returning an array element (unrecognized dtype)', function test( t ) { - var arr; - var get; - var v; - - get = getter( 'foo' ); - arr = filled( 2, 10, 'generic' ); - v = get( arr, 2 ); - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned function does not perform bounds checks', function test( t ) { - var arr; - var get; - var dt; - var v; - var i; - - for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - get = getter( dt ); - arr = filled( i+1, 10, dt ); - v = get( arr, arr.length+10 ); - t.strictEqual( v, void 0, 'returns expected value for dtype: '+dt ); - } - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (unrecognized dtype)', function test( t ) { - var arr; - var get; - var v; - - get = getter( 'foo' ); - arr = filled( 2, 10, 'generic' ); - v = get( arr, arr.length+10 ); - t.strictEqual( v, void 0, 'returns expected value' ); - - t.end(); -}); diff --git a/base/group-entries-by/README.md b/base/group-entries-by/README.md deleted file mode 100644 index 3ea2b7e11..000000000 --- a/base/group-entries-by/README.md +++ /dev/null @@ -1,173 +0,0 @@ - - -# groupEntriesBy - -> Group element entries according to an indicator function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var groupEntriesBy = require( '@stdlib/array/base/group-entries-by' ); -``` - -#### groupEntriesBy( x, indicator\[, thisArg] ) - -Groups element entries according to an indicator function. - -```javascript -function indicator( v ) { - return v[ 0 ]; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var out = groupEntriesBy( x, indicator ); -// returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } -``` - -An `indicator` function is provided the following arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `indicator` function execution context, provide a `thisArg`. - -```javascript -function indicator( v ) { - this.count += 1; - return v[ 0 ]; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var context = { - 'count': 0 -}; -var out = groupEntriesBy( x, indicator, context ); -// returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } - -var cnt = context.count; -// returns 4 -``` - -
- - - - - -
- -## Notes - -- The value returned by an `indicator` function should be a value which can be serialized as an object key. As a counterexample, - - ```javascript - function indicator( v ) { - return {}; - } - var x = [ 'beep', 'boop', 'foo', 'bar' ]; - - var out = groupEntriesBy( x, indicator ); - // returns { '[object Object]': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 2, 'foo' ], [ 3, 'bar' ] ] } - ``` - - while each group identifier is unique, all input array elements resolve to the same group because each group identifier serializes to the same string. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var groupEntriesBy = require( '@stdlib/array/base/group-entries-by' ); - -function indicator( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ]; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Group the values: -var out = groupEntriesBy( x, indicator ); -// returns {...} - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/group-entries-by/benchmark/benchmark.length.js b/base/group-entries-by/benchmark/benchmark.length.js deleted file mode 100644 index 821f12a4a..000000000 --- a/base/group-entries-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var groupEntriesBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Indicator function. -* -* @private -* @param {*} value - current array element -* @param {NonNegativeInteger} index - current array element index -* @param {Collection} arr - input array -* @returns {*} indicator value -*/ -function indicator( value, index ) { - return index; // note: this corresponds to the extreme case where every element is in a distinct group -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = groupEntriesBy( x, indicator ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len+',num_groups='+len, f ); - } -} - -main(); diff --git a/base/group-entries-by/docs/repl.txt b/base/group-entries-by/docs/repl.txt deleted file mode 100644 index b5a927ec6..000000000 --- a/base/group-entries-by/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( x, indicator[, thisArg] ) - Groups element entries according to an indicator function. - - When invoked, the indicator function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: input array. - - The value returned by an indicator function should be a value which can be - serialized as an object key. - - If provided an empty array, the function returns an empty object. - - Parameters - ---------- - x: ArrayLike - Input array. - - indicator: Function - Indicator function specifying which group an element in the input array - belongs to. - - thisArg: any (optional) - Indicator function execution context. - - Returns - ------- - out: Object - Group results. - - Examples - -------- - > function fcn( v ) { return v[ 0 ]; }; - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var out = {{alias}}( x, fcn ) - { 'b': [ [0,'beep'], [1,'boop'], [3,'bar'] ], 'f': [ [2,'foo'] ] } - - See Also - -------- - diff --git a/base/group-entries-by/docs/types/index.d.ts b/base/group-entries-by/docs/types/index.d.ts deleted file mode 100644 index 8a019d8a7..000000000 --- a/base/group-entries-by/docs/types/index.d.ts +++ /dev/null @@ -1,107 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Object key. -*/ -type Key = string | symbol | number; - -/** -* Specifies which group an element in the input array belongs to. -* -* @returns object key -*/ -type Nullary = ( this: U ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @returns object key -*/ -type Unary = ( this: U, value: T ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @returns object key -*/ -type Binary = ( this: U, value: T, index: number ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns object key -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns object key -*/ -type Indicator = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing returned group results. -*/ -interface EntriesResults { - /** - * Object properties. - */ - [key: Key]: Array<[ number, T ]>; -} - -/** -* Groups element entries according to an indicator function. -* -* @param x - input array -* @param indicator - indicator function specifying which group an element in the input array belongs to -* @param thisArg - indicator function execution context -* @returns group results -* -* @example -* function indicator( v ) { -* return v[ 0 ]; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = groupEntriesBy( x, indicator ); -* // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } -*/ -declare function groupEntriesBy( x: Collection | AccessorArrayLike, indicator: Indicator, thisArg?: ThisParameterType> ): EntriesResults; - - -// EXPORTS // - -export = groupEntriesBy; diff --git a/base/group-entries-by/docs/types/test.ts b/base/group-entries-by/docs/types/test.ts deleted file mode 100644 index 1af75b36a..000000000 --- a/base/group-entries-by/docs/types/test.ts +++ /dev/null @@ -1,73 +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. -*/ - -import groupEntriesBy = require( './index' ); - -/** -* Indicator function. -* -* @param v - value -* @returns result -*/ -function indicator( v: string ): string { - return v[ 0 ]; -} - - -// TESTS // - -// The function returns group results... -{ - const x = [ 'foo', 'bar' ]; - - groupEntriesBy( x, indicator ); // $ExpectType EntriesResults -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - groupEntriesBy( 5, indicator ); // $ExpectError - groupEntriesBy( true, indicator ); // $ExpectError - groupEntriesBy( false, indicator ); // $ExpectError - groupEntriesBy( null, indicator ); // $ExpectError - groupEntriesBy( void 0, indicator ); // $ExpectError - groupEntriesBy( {}, indicator ); // $ExpectError - groupEntriesBy( ( x: number ): number => x, indicator ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid function... -{ - const x = [ 'foo', 'bar' ]; - - groupEntriesBy( x, '5' ); // $ExpectError - groupEntriesBy( x, 5 ); // $ExpectError - groupEntriesBy( x, true ); // $ExpectError - groupEntriesBy( x, false ); // $ExpectError - groupEntriesBy( x, null ); // $ExpectError - groupEntriesBy( x, void 0 ); // $ExpectError - groupEntriesBy( x, {} ); // $ExpectError - groupEntriesBy( x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 'foo', 'bar' ]; - - groupEntriesBy(); // $ExpectError - groupEntriesBy( x ); // $ExpectError - groupEntriesBy( x, indicator, {}, {} ); // $ExpectError -} diff --git a/base/group-entries-by/examples/index.js b/base/group-entries-by/examples/index.js deleted file mode 100644 index a81cfeca1..000000000 --- a/base/group-entries-by/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var groupEntriesBy = require( './../lib' ); - -function indicator( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ]; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Group the values: -var out = groupEntriesBy( x, indicator ); -// returns {...} - -console.log( out ); diff --git a/base/group-entries-by/lib/index.js b/base/group-entries-by/lib/index.js deleted file mode 100644 index 823283258..000000000 --- a/base/group-entries-by/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Group element entries according to an indicator function. -* -* @module @stdlib/array/base/group-entries-by -* -* @example -* var groupEntriesBy = require( '@stdlib/array/base/group-entries-by' ); -* -* function indicator( v ) { -* return v[ 0 ]; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = groupEntriesBy( x, indicator ); -* // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/group-entries-by/lib/main.js b/base/group-entries-by/lib/main.js deleted file mode 100644 index 2301a9287..000000000 --- a/base/group-entries-by/lib/main.js +++ /dev/null @@ -1,80 +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 isArray = require( '@stdlib/assert/is-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Groups element entries according to an indicator function. -* -* @param {Collection} x - input array -* @param {Function} indicator - indicator function specifying which group an element in the input collection belongs to -* @param {*} [thisArg] - indicator function execution context -* @returns {Object} group results -* -* @example -* function indicator( v ) { -* return v[ 0 ]; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = groupEntriesBy( x, indicator ); -* // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } -*/ -function groupEntriesBy( x, indicator, thisArg ) { - var get; - var len; - var out; - var g; - var o; - var v; - var i; - - // Get the number of elements to group: - len = x.length; - - // Resolve an accessor for retrieving array elements: - get = resolveGetter( x ); - - // Loop over the elements and assign each to a group... - out = {}; - for ( i = 0; i < len; i++ ) { - v = get( x, i ); - g = indicator.call( thisArg, v, i, x ); - o = out[ g ]; - if ( isArray( o ) ) { - o.push( [ i, v ] ); - } else { - out[ g ] = [ [ i, v ] ]; - } - } - return out; -} - - -// EXPORTS // - -module.exports = groupEntriesBy; diff --git a/base/group-entries-by/package.json b/base/group-entries-by/package.json deleted file mode 100644 index 14bc856a5..000000000 --- a/base/group-entries-by/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/group-entries-by", - "version": "0.0.0", - "description": "Group element entries according to an indicator function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "groupby", - "group-by", - "aggregate", - "summarize", - "partition", - "split", - "entries", - "indices" - ] -} diff --git a/base/group-entries-by/test/test.js b/base/group-entries-by/test/test.js deleted file mode 100644 index fc66304ef..000000000 --- a/base/group-entries-by/test/test.js +++ /dev/null @@ -1,193 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var groupEntriesBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof groupEntriesBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function groups array element entries according to an indicator function', function test( t ) { - var expected; - var out; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = { - 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - 'f': [ [ 2, 'foo' ] ] - }; - out = groupEntriesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - return v[ 0 ]; - } -}); - -tape( 'the function groups array element entries according to an indicator function (typed arrays)', function test( t ) { - var expected; - var out; - var x; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - - expected = { - '1': [ [ 2, -1.0 ], [ 3, -10.2 ] ], - '2': [ [ 0, 3.14 ], [ 1, 4.2 ] ] - }; - out = groupEntriesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v, i ) { - if ( i < 2 ) { - return 2; - } - return 1; - } -}); - -tape( 'the function groups array element entries according to an indicator function (array-like objects)', function test( t ) { - var expected; - var out; - var x; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - - expected = { - 'be': [ [ 0, 'beep' ] ], - 'bo': [ [ 1, 'boop' ] ], - 'fo': [ [ 2, 'foo' ] ], - 'ba': [ [ 3, 'bar' ] ] - }; - out = groupEntriesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - return v.slice( 0, 2 ); - } -}); - -tape( 'the function groups array element entries according to an indicator function (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - - expected = { - 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - 'f': [ [ 2, 'foo' ] ] - }; - out = groupEntriesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - return v[ 0 ]; - } -}); - -tape( 'the function groups array element entries according to an indicator function (string serialization)', function test( t ) { - var expected; - var out; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = { - '[object Object]': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 2, 'foo' ], [ 3, 'bar' ] ] - }; - out = groupEntriesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected groups' ); - t.end(); - - function indicator() { - return {}; - } -}); - -tape( 'the function returns an empty object if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = {}; - actual = groupEntriesBy( [], indicator ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - t.fail( 'should not be called' ); - return v; - } -}); - -tape( 'the function supports specifying a callback execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = { - 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - 'f': [ [ 2, 'foo' ] ] - }; - ctx = { - 'count': 0 - }; - out = groupEntriesBy( x, indicator, ctx ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, x.length, 'returns expected value' ); - t.end(); - - function indicator( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v[ 0 ]; - } -}); diff --git a/base/group-entries/README.md b/base/group-entries/README.md deleted file mode 100644 index a96910f4c..000000000 --- a/base/group-entries/README.md +++ /dev/null @@ -1,142 +0,0 @@ - - -# groupEntries - -> Group element entries as arrays associated with distinct keys. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var groupEntries = require( '@stdlib/array/base/group-entries' ); -``` - -#### groupEntries( x, groups ) - -Groups element entries as arrays associated with distinct keys. - -```javascript -var x = [ 'beep', 'boop', 'foo', 'bar' ]; -var groups = [ 'b', 'b', 'f', 'b' ]; - -var out = groupEntries( x, groups ); -// returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } -``` - -
- - - - - -
- -## Notes - -- Each value in `groups` should resolve to a value which can be serialized as an object key. As a counterexample, - - ```javascript - var x = [ 'beep', 'boop', 'foo', 'bar' ]; - var groups = [ {}, {}, {}, {} ]; - - var out = groupEntries( x, groups ); - // returns { '[object Object]': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 2, 'foo' ], [ 3, 'bar' ] ] } - ``` - - while each "group" is unique, all input array elements resolve to the same group because each group identifier serializes to the same string. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var groupEntries = require( '@stdlib/array/base/group-entries' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, values.length, { - 'dtype': 'generic' -}); - -// Group the values: -var out = groupEntries( x, groups ); -// returns {...} - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/group-entries/benchmark/benchmark.length.js b/base/group-entries/benchmark/benchmark.length.js deleted file mode 100644 index 9d9a0e733..000000000 --- a/base/group-entries/benchmark/benchmark.length.js +++ /dev/null @@ -1,101 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var groupEntries = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var groups; - var x; - - x = zeroTo( len ); - groups = zeroTo( len ); // note: this corresponds to the extreme case where every element is in a distinct group - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = groupEntries( x, groups ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len+',num_groups='+len, f ); - } -} - -main(); diff --git a/base/group-entries/docs/repl.txt b/base/group-entries/docs/repl.txt deleted file mode 100644 index bf366588b..000000000 --- a/base/group-entries/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( x, groups ) - Groups element entries as arrays associated with distinct keys. - - If provided an empty array, the function returns an empty object. - - Parameters - ---------- - x: ArrayLike - Input array. - - groups: ArrayLike - An array defining which group an element in the input array belongs to. - Each value in `groups` should resolve to a value which can be serialized - as an object key. - - Returns - ------- - out: Object - Group results. - - Examples - -------- - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var g = [ 'b', 'b', 'f', 'b' ]; - > var out = {{alias}}( x, g ) - { 'b': [ [0,'beep'], [1,'boop'], [3,'bar'] ], 'f': [ [2,'foo'] ] } - > g = [ 1, 1, 2, 1 ]; - > out = {{alias}}( x, g ) - { '1': [ [0,'beep'], [1,'boop'], [3,'bar'] ], '2': [ [2,'foo'] ] } - - See Also - -------- - diff --git a/base/group-entries/docs/types/index.d.ts b/base/group-entries/docs/types/index.d.ts deleted file mode 100644 index 08ca886fd..000000000 --- a/base/group-entries/docs/types/index.d.ts +++ /dev/null @@ -1,59 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Object key. -*/ -type Key = string | symbol | number; - -/** -* Interface describing returned group results. -*/ -interface EntriesResults { - /** - * Object properties. - */ - [key: Key]: Array<[ number, T ]>; -} - -/** -* Groups element entries as arrays associated with distinct keys. -* -* @param x - input array -* @param groups - array defining which group an element in the input array belongs to -* @returns group results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var groups = [ 'b', 'b', 'f', 'b' ]; -* -* var out = groupEntries( x, groups ); -* // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } -*/ -declare function groupEntries( x: Collection | AccessorArrayLike, groups: Collection | AccessorArrayLike ): EntriesResults; - - -// EXPORTS // - -export = groupEntries; diff --git a/base/group-entries/docs/types/test.ts b/base/group-entries/docs/types/test.ts deleted file mode 100644 index 3b7fec61d..000000000 --- a/base/group-entries/docs/types/test.ts +++ /dev/null @@ -1,66 +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. -*/ - -import groupEntries = require( './index' ); - - -// TESTS // - -// The function returns group results... -{ - const x = [ 1, 2, 3 ]; - const g = [ 0, 0, 0 ]; - - groupEntries( x, g ); // $ExpectType EntriesResults -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - const g = [ 0, 0, 0 ]; - - groupEntries( 5, g ); // $ExpectError - groupEntries( true, g ); // $ExpectError - groupEntries( false, g ); // $ExpectError - groupEntries( null, g ); // $ExpectError - groupEntries( void 0, g ); // $ExpectError - groupEntries( {}, g ); // $ExpectError - groupEntries( ( x: number ): number => x, g ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array... -{ - const x = [ 1, 2, 3 ]; - - groupEntries( x, 5 ); // $ExpectError - groupEntries( x, true ); // $ExpectError - groupEntries( x, false ); // $ExpectError - groupEntries( x, null ); // $ExpectError - groupEntries( x, void 0 ); // $ExpectError - groupEntries( x, {} ); // $ExpectError - groupEntries( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - const g = [ 0, 0, 0 ]; - - groupEntries(); // $ExpectError - groupEntries( x ); // $ExpectError - groupEntries( x, g, {} ); // $ExpectError -} diff --git a/base/group-entries/examples/index.js b/base/group-entries/examples/index.js deleted file mode 100644 index 652ab4598..000000000 --- a/base/group-entries/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var groupEntries = require( './../lib' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, values.length, { - 'dtype': 'generic' -}); - -// Group the values: -var out = groupEntries( x, groups ); -// returns {...} - -console.log( out ); diff --git a/base/group-entries/lib/index.js b/base/group-entries/lib/index.js deleted file mode 100644 index cbb662740..000000000 --- a/base/group-entries/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Group element entries as arrays associated with distinct keys. -* -* @module @stdlib/array/base/group-entries -* -* @example -* var groupEntries = require( '@stdlib/array/base/group-entries' ); -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var groups = [ 'b', 'b', 'f', 'b' ]; -* -* var out = groupEntries( x, groups ); -* // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/group-entries/lib/main.js b/base/group-entries/lib/main.js deleted file mode 100644 index ea8d3250e..000000000 --- a/base/group-entries/lib/main.js +++ /dev/null @@ -1,81 +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 isArray = require( '@stdlib/assert/is-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Groups element entries as arrays associated with distinct keys. -* -* @param {Collection} x - input array -* @param {Collection} groups - array defining which group an element in the input array belongs to -* @throws {RangeError} must provide arrays having the same length -* @returns {Object} group results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var groups = [ 'b', 'b', 'f', 'b' ]; -* -* var out = groupEntries( x, groups ); -* // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] } -*/ -function groupEntries( x, groups ) { - var xget; - var gget; - var len; - var out; - var g; - var o; - var v; - var i; - - // Get the number of elements to group: - len = x.length; - if ( groups.length !== len ) { - throw new RangeError( 'invalid argument. The first and second arguments must have the same length.' ); - } - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - gget = resolveGetter( groups ); - - // Loop over the elements and assign each to a group... - out = {}; - for ( i = 0; i < len; i++ ) { - v = xget( x, i ); - g = gget( groups, i ).toString(); - o = out[ g ]; - if ( isArray( o ) ) { - o.push( [ i, v ] ); - } else { - out[ g ] = [ [ i, v ] ]; - } - } - return out; -} - - -// EXPORTS // - -module.exports = groupEntries; diff --git a/base/group-entries/package.json b/base/group-entries/package.json deleted file mode 100644 index 9db0db682..000000000 --- a/base/group-entries/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/group-entries", - "version": "0.0.0", - "description": "Group element entries as arrays associated with distinct keys.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "groupby", - "group-by", - "aggregate", - "summarize", - "partition", - "split", - "entries" - ] -} diff --git a/base/group-entries/test/test.js b/base/group-entries/test/test.js deleted file mode 100644 index 9985ac3a2..000000000 --- a/base/group-entries/test/test.js +++ /dev/null @@ -1,182 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var groupEntries = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof groupEntries, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first and second argument which do not have the same length', function test( t ) { - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - groupEntries( [ 1, 2, 3 ], [ 0, 0 ] ); - } -}); - -tape( 'the function groups array element entries as arrays associated with distinct keys', function test( t ) { - var expected; - var out; - var x; - var g; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - g = [ 'b', 'b', 'f', 'b' ]; - - expected = { - 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - 'f': [ [ 2, 'foo' ] ] - }; - out = groupEntries( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array element entries as arrays associated with distinct keys (array, typed array)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - g = new Float64Array( [ 1, 1, 2, 1 ] ); - - expected = { - '1': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - '2': [ [ 2, 'foo' ] ] - }; - out = groupEntries( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array element entries as arrays associated with distinct keys (typed arrays)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - g = new Float64Array( [ 2, 2, 1, 1 ] ); - - expected = { - '1': [ [ 2, -1.0 ], [ 3, -10.2 ] ], - '2': [ [ 0, 3.14 ], [ 1, 4.2 ] ] - }; - out = groupEntries( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array element entries as arrays associated with distinct keys (array-like objects)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - g = { - 'length': 4, - '0': 'be', - '1': 'bo', - '2': 'fo', - '3': 'ba' - }; - - expected = { - 'be': [ [ 0, 'beep' ] ], - 'bo': [ [ 1, 'boop' ] ], - 'fo': [ [ 2, 'foo' ] ], - 'ba': [ [ 3, 'bar' ] ] - }; - out = groupEntries( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array element entries as arrays associated with distinct keys (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - g = toAccessorArray( [ 'b', 'b', 'f', 'b' ] ); - - expected = { - 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], - 'f': [ [ 2, 'foo' ] ] - }; - out = groupEntries( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array element entries as arrays associated with distinct keys (string serialization)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - g = [ {}, {}, {}, {} ]; - - expected = { - '[object Object]': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 2, 'foo' ], [ 3, 'bar' ] ] - }; - out = groupEntries( x, g ); - - t.deepEqual( out, expected, 'returns expected groups' ); - t.end(); -}); - -tape( 'the function returns an empty object if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = {}; - actual = groupEntries( [], [] ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/group-indices-by/README.md b/base/group-indices-by/README.md deleted file mode 100644 index 2cbad4ce8..000000000 --- a/base/group-indices-by/README.md +++ /dev/null @@ -1,173 +0,0 @@ - - -# groupIndicesBy - -> Group element indices according to an indicator function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var groupIndicesBy = require( '@stdlib/array/base/group-indices-by' ); -``` - -#### groupIndicesBy( x, indicator\[, thisArg] ) - -Groups element indices according to an indicator function. - -```javascript -function indicator( v ) { - return v[ 0 ]; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var out = groupIndicesBy( x, indicator ); -// returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } -``` - -An `indicator` function is provided the following arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `indicator` function execution context, provide a `thisArg`. - -```javascript -function indicator( v ) { - this.count += 1; - return v[ 0 ]; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var context = { - 'count': 0 -}; -var out = groupIndicesBy( x, indicator, context ); -// returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } - -var cnt = context.count; -// returns 4 -``` - -
- - - - - -
- -## Notes - -- The value returned by an `indicator` function should be a value which can be serialized as an object key. As a counterexample, - - ```javascript - function indicator( v ) { - return {}; - } - var x = [ 'beep', 'boop', 'foo', 'bar' ]; - - var out = groupIndicesBy( x, indicator ); - // returns { '[object Object]': [ 0, 1, 2, 3 ] } - ``` - - while each group identifier is unique, all input array elements resolve to the same group because each group identifier serializes to the same string. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var groupIndicesBy = require( '@stdlib/array/base/group-indices-by' ); - -function indicator( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ]; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Group the values: -var out = groupIndicesBy( x, indicator ); -// returns {...} - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/group-indices-by/benchmark/benchmark.length.js b/base/group-indices-by/benchmark/benchmark.length.js deleted file mode 100644 index 430d28b02..000000000 --- a/base/group-indices-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var groupIndicesBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Indicator function. -* -* @private -* @param {*} value - current array element -* @param {NonNegativeInteger} index - current array element index -* @param {Collection} arr - input array -* @returns {*} indicator value -*/ -function indicator( value, index ) { - return index; // note: this corresponds to the extreme case where every element is in a distinct group -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = groupIndicesBy( x, indicator ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len+',num_groups='+len, f ); - } -} - -main(); diff --git a/base/group-indices-by/docs/repl.txt b/base/group-indices-by/docs/repl.txt deleted file mode 100644 index c1a8051b9..000000000 --- a/base/group-indices-by/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( x, indicator[, thisArg] ) - Groups element indices according to an indicator function. - - When invoked, the indicator function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: input array. - - The value returned by an indicator function should be a value which can be - serialized as an object key. - - If provided an empty array, the function returns an empty object. - - Parameters - ---------- - x: ArrayLike - Input array. - - indicator: Function - Indicator function specifying which group an element in the input array - belongs to. - - thisArg: any (optional) - Indicator function execution context. - - Returns - ------- - out: Object - Group results. - - Examples - -------- - > function fcn( v ) { return v[ 0 ]; }; - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var out = {{alias}}( x, fcn ) - { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } - - See Also - -------- - diff --git a/base/group-indices-by/docs/types/index.d.ts b/base/group-indices-by/docs/types/index.d.ts deleted file mode 100644 index 42405cbfd..000000000 --- a/base/group-indices-by/docs/types/index.d.ts +++ /dev/null @@ -1,107 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Object key. -*/ -type Key = string | symbol | number; - -/** -* Specifies which group an element in the input array belongs to. -* -* @returns object key -*/ -type Nullary = ( this: U ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @returns object key -*/ -type Unary = ( this: U, value: T ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @returns object key -*/ -type Binary = ( this: U, value: T, index: number ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns object key -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns object key -*/ -type Indicator = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing returned group results. -*/ -interface IndicesResults { - /** - * Object properties. - */ - [key: Key]: Array; -} - -/** -* Groups element indices according to an indicator function. -* -* @param x - input array -* @param indicator - indicator function specifying which group an element in the input array belongs to -* @param thisArg - indicator function execution context -* @returns group results -* -* @example -* function indicator( v ) { -* return v[ 0 ]; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = groupIndicesBy( x, indicator ); -* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } -*/ -declare function groupIndicesBy( x: Collection | AccessorArrayLike, indicator: Indicator, thisArg?: ThisParameterType> ): IndicesResults; - - -// EXPORTS // - -export = groupIndicesBy; diff --git a/base/group-indices-by/docs/types/test.ts b/base/group-indices-by/docs/types/test.ts deleted file mode 100644 index d0805ceb4..000000000 --- a/base/group-indices-by/docs/types/test.ts +++ /dev/null @@ -1,73 +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. -*/ - -import groupIndicesBy = require( './index' ); - -/** -* Indicator function. -* -* @param v - value -* @returns result -*/ -function indicator( v: string ): string { - return v[ 0 ]; -} - - -// TESTS // - -// The function returns group results... -{ - const x = [ 'foo', 'bar' ]; - - groupIndicesBy( x, indicator ); // $ExpectType IndicesResults -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - groupIndicesBy( 5, indicator ); // $ExpectError - groupIndicesBy( true, indicator ); // $ExpectError - groupIndicesBy( false, indicator ); // $ExpectError - groupIndicesBy( null, indicator ); // $ExpectError - groupIndicesBy( void 0, indicator ); // $ExpectError - groupIndicesBy( {}, indicator ); // $ExpectError - groupIndicesBy( ( x: number ): number => x, indicator ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid function... -{ - const x = [ 'foo', 'bar' ]; - - groupIndicesBy( x, '5' ); // $ExpectError - groupIndicesBy( x, 5 ); // $ExpectError - groupIndicesBy( x, true ); // $ExpectError - groupIndicesBy( x, false ); // $ExpectError - groupIndicesBy( x, null ); // $ExpectError - groupIndicesBy( x, void 0 ); // $ExpectError - groupIndicesBy( x, {} ); // $ExpectError - groupIndicesBy( x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 'foo', 'bar' ]; - - groupIndicesBy(); // $ExpectError - groupIndicesBy( x ); // $ExpectError - groupIndicesBy( x, indicator, {}, {} ); // $ExpectError -} diff --git a/base/group-indices-by/examples/index.js b/base/group-indices-by/examples/index.js deleted file mode 100644 index ab07de395..000000000 --- a/base/group-indices-by/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var groupIndicesBy = require( './../lib' ); - -function indicator( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ]; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Group the values: -var out = groupIndicesBy( x, indicator ); -// returns {...} - -console.log( out ); diff --git a/base/group-indices-by/lib/index.js b/base/group-indices-by/lib/index.js deleted file mode 100644 index 94d6e2e0d..000000000 --- a/base/group-indices-by/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Group element indices according to an indicator function. -* -* @module @stdlib/array/base/group-indices-by -* -* @example -* var groupIndicesBy = require( '@stdlib/array/base/group-indices-by' ); -* -* function indicator( v ) { -* return v[ 0 ]; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = groupIndicesBy( x, indicator ); -* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/group-indices-by/lib/main.js b/base/group-indices-by/lib/main.js deleted file mode 100644 index 33b962e1d..000000000 --- a/base/group-indices-by/lib/main.js +++ /dev/null @@ -1,78 +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 isArray = require( '@stdlib/assert/is-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Groups element indices according to an indicator function. -* -* @param {Collection} x - input array -* @param {Function} indicator - indicator function specifying which group an element in the input collection belongs to -* @param {*} [thisArg] - indicator function execution context -* @returns {Object} group results -* -* @example -* function indicator( v ) { -* return v[ 0 ]; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = groupIndicesBy( x, indicator ); -* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } -*/ -function groupIndicesBy( x, indicator, thisArg ) { - var get; - var len; - var out; - var g; - var o; - var i; - - // Get the number of elements to group: - len = x.length; - - // Resolve an accessor for retrieving array elements: - get = resolveGetter( x ); - - // Loop over the elements and assign each to a group... - out = {}; - for ( i = 0; i < len; i++ ) { - g = indicator.call( thisArg, get( x, i ), i, x ); - o = out[ g ]; - if ( isArray( o ) ) { - o.push( i ); - } else { - out[ g ] = [ i ]; - } - } - return out; -} - - -// EXPORTS // - -module.exports = groupIndicesBy; diff --git a/base/group-indices-by/package.json b/base/group-indices-by/package.json deleted file mode 100644 index de66d245d..000000000 --- a/base/group-indices-by/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/group-indices-by", - "version": "0.0.0", - "description": "Group element indices according to an indicator function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "groupby", - "group-by", - "aggregate", - "summarize", - "partition", - "split", - "indices" - ] -} diff --git a/base/group-indices-by/test/test.js b/base/group-indices-by/test/test.js deleted file mode 100644 index fda0c009b..000000000 --- a/base/group-indices-by/test/test.js +++ /dev/null @@ -1,193 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var groupIndicesBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof groupIndicesBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function groups array element indices according to an indicator function', function test( t ) { - var expected; - var out; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = { - 'b': [ 0, 1, 3 ], - 'f': [ 2 ] - }; - out = groupIndicesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - return v[ 0 ]; - } -}); - -tape( 'the function groups array element indices according to an indicator function (typed arrays)', function test( t ) { - var expected; - var out; - var x; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - - expected = { - '1': [ 2, 3 ], - '2': [ 0, 1 ] - }; - out = groupIndicesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v, i ) { - if ( i < 2 ) { - return 2; - } - return 1; - } -}); - -tape( 'the function groups array element indices according to an indicator function (array-like objects)', function test( t ) { - var expected; - var out; - var x; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - - expected = { - 'be': [ 0 ], - 'bo': [ 1 ], - 'fo': [ 2 ], - 'ba': [ 3 ] - }; - out = groupIndicesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - return v.slice( 0, 2 ); - } -}); - -tape( 'the function groups array element indices according to an indicator function (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - - expected = { - 'b': [ 0, 1, 3 ], - 'f': [ 2 ] - }; - out = groupIndicesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - return v[ 0 ]; - } -}); - -tape( 'the function groups array element indices according to an indicator function (string serialization)', function test( t ) { - var expected; - var out; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = { - '[object Object]': [ 0, 1, 2, 3 ] - }; - out = groupIndicesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected groups' ); - t.end(); - - function indicator() { - return {}; - } -}); - -tape( 'the function returns an empty object if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = {}; - actual = groupIndicesBy( [], indicator ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - t.fail( 'should not be called' ); - return v; - } -}); - -tape( 'the function supports specifying a callback execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = { - 'b': [ 0, 1, 3 ], - 'f': [ 2 ] - }; - ctx = { - 'count': 0 - }; - out = groupIndicesBy( x, indicator, ctx ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, x.length, 'returns expected value' ); - t.end(); - - function indicator( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v[ 0 ]; - } -}); diff --git a/base/group-indices/README.md b/base/group-indices/README.md deleted file mode 100644 index 187037460..000000000 --- a/base/group-indices/README.md +++ /dev/null @@ -1,142 +0,0 @@ - - -# groupIndices - -> Group element indices as arrays associated with distinct keys. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var groupIndices = require( '@stdlib/array/base/group-indices' ); -``` - -#### groupIndices( x, groups ) - -Groups element indices as arrays associated with distinct keys. - -```javascript -var x = [ 'beep', 'boop', 'foo', 'bar' ]; -var groups = [ 'b', 'b', 'f', 'b' ]; - -var out = groupIndices( x, groups ); -// returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } -``` - -
- - - - - -
- -## Notes - -- Each value in `groups` should resolve to a value which can be serialized as an object key. As a counterexample, - - ```javascript - var x = [ 'beep', 'boop', 'foo', 'bar' ]; - var groups = [ {}, {}, {}, {} ]; - - var out = groupIndices( x, groups ); - // returns { '[object Object]': [ 0, 1, 2, 3 ] } - ``` - - while each "group" is unique, all input array elements resolve to the same group because each group identifier serializes to the same string. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var groupIndices = require( '@stdlib/array/base/group-indices' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, values.length, { - 'dtype': 'generic' -}); - -// Group the values: -var out = groupIndices( x, groups ); -// returns {...} - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/group-indices/benchmark/benchmark.length.js b/base/group-indices/benchmark/benchmark.length.js deleted file mode 100644 index 9ed361a74..000000000 --- a/base/group-indices/benchmark/benchmark.length.js +++ /dev/null @@ -1,101 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var groupIndices = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var groups; - var x; - - x = zeroTo( len ); - groups = zeroTo( len ); // note: this corresponds to the extreme case where every element is in a distinct group - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = groupIndices( x, groups ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len+',num_groups='+len, f ); - } -} - -main(); diff --git a/base/group-indices/docs/repl.txt b/base/group-indices/docs/repl.txt deleted file mode 100644 index 48d2baef0..000000000 --- a/base/group-indices/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( x, groups ) - Groups element indices as arrays associated with distinct keys. - - If provided an empty array, the function returns an empty object. - - Parameters - ---------- - x: ArrayLike - Input array. - - groups: ArrayLike - An array defining which group an element in the input array belongs to. - Each value in `groups` should resolve to a value which can be serialized - as an object key. - - Returns - ------- - out: Object - Group results. - - Examples - -------- - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var g = [ 'b', 'b', 'f', 'b' ]; - > var out = {{alias}}( x, g ) - { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } - > g = [ 1, 1, 2, 1 ]; - > out = {{alias}}( x, g ) - { '1': [ 0, 1, 3 ], '2': [ 2 ] } - - See Also - -------- - diff --git a/base/group-indices/docs/types/index.d.ts b/base/group-indices/docs/types/index.d.ts deleted file mode 100644 index 2b1a25dad..000000000 --- a/base/group-indices/docs/types/index.d.ts +++ /dev/null @@ -1,59 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Object key. -*/ -type Key = string | symbol | number; - -/** -* Interface describing returned group results. -*/ -interface IndicesResults { - /** - * Object properties. - */ - [key: Key]: Array; -} - -/** -* Groups element indices as arrays associated with distinct keys. -* -* @param x - input array -* @param groups - array defining which group an element in the input array belongs to -* @returns group results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var groups = [ 'b', 'b', 'f', 'b' ]; -* -* var out = groupIndices( x, groups ); -* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } -*/ -declare function groupIndices( x: Collection | AccessorArrayLike, groups: Collection | AccessorArrayLike ): IndicesResults; - - -// EXPORTS // - -export = groupIndices; diff --git a/base/group-indices/docs/types/test.ts b/base/group-indices/docs/types/test.ts deleted file mode 100644 index 58242ac56..000000000 --- a/base/group-indices/docs/types/test.ts +++ /dev/null @@ -1,66 +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. -*/ - -import groupIndices = require( './index' ); - - -// TESTS // - -// The function returns group results... -{ - const x = [ 1, 2, 3 ]; - const g = [ 0, 0, 0 ]; - - groupIndices( x, g ); // $ExpectType IndicesResults -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - const g = [ 0, 0, 0 ]; - - groupIndices( 5, g ); // $ExpectError - groupIndices( true, g ); // $ExpectError - groupIndices( false, g ); // $ExpectError - groupIndices( null, g ); // $ExpectError - groupIndices( void 0, g ); // $ExpectError - groupIndices( {}, g ); // $ExpectError - groupIndices( ( x: number ): number => x, g ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array... -{ - const x = [ 1, 2, 3 ]; - - groupIndices( x, 5 ); // $ExpectError - groupIndices( x, true ); // $ExpectError - groupIndices( x, false ); // $ExpectError - groupIndices( x, null ); // $ExpectError - groupIndices( x, void 0 ); // $ExpectError - groupIndices( x, {} ); // $ExpectError - groupIndices( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - const g = [ 0, 0, 0 ]; - - groupIndices(); // $ExpectError - groupIndices( x ); // $ExpectError - groupIndices( x, g, {} ); // $ExpectError -} diff --git a/base/group-indices/examples/index.js b/base/group-indices/examples/index.js deleted file mode 100644 index 372173616..000000000 --- a/base/group-indices/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var groupIndices = require( './../lib' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, values.length, { - 'dtype': 'generic' -}); - -// Group the values: -var out = groupIndices( x, groups ); -// returns {...} - -console.log( out ); diff --git a/base/group-indices/lib/index.js b/base/group-indices/lib/index.js deleted file mode 100644 index 2150529c7..000000000 --- a/base/group-indices/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Group element indices as arrays associated with distinct keys. -* -* @module @stdlib/array/base/group-indices -* -* @example -* var groupIndices = require( '@stdlib/array/base/group-indices' ); -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var groups = [ 'b', 'b', 'f', 'b' ]; -* -* var out = groupIndices( x, groups ); -* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/group-indices/lib/main.js b/base/group-indices/lib/main.js deleted file mode 100644 index 1343253cd..000000000 --- a/base/group-indices/lib/main.js +++ /dev/null @@ -1,77 +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 isArray = require( '@stdlib/assert/is-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Groups element indices as arrays associated with distinct keys. -* -* @param {Collection} x - input array -* @param {Collection} groups - array defining which group an element in the input array belongs to -* @throws {RangeError} must provide arrays having the same length -* @returns {Object} group results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var groups = [ 'b', 'b', 'f', 'b' ]; -* -* var out = groupIndices( x, groups ); -* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] } -*/ -function groupIndices( x, groups ) { - var gget; - var len; - var out; - var g; - var o; - var i; - - // Get the number of elements to group: - len = x.length; - if ( groups.length !== len ) { - throw new RangeError( 'invalid argument. The first and second arguments must have the same length.' ); - } - // Resolve accessors for retrieving array elements: - gget = resolveGetter( groups ); - - // Loop over the elements and assign each to a group... - out = {}; - for ( i = 0; i < len; i++ ) { - g = gget( groups, i ).toString(); - o = out[ g ]; - if ( isArray( o ) ) { - o.push( i ); - } else { - out[ g ] = [ i ]; - } - } - return out; -} - - -// EXPORTS // - -module.exports = groupIndices; diff --git a/base/group-indices/package.json b/base/group-indices/package.json deleted file mode 100644 index 6ddb3ddbd..000000000 --- a/base/group-indices/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/group-indices", - "version": "0.0.0", - "description": "Group element indices as arrays associated with distinct keys.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "groupby", - "group-by", - "aggregate", - "summarize", - "partition", - "split", - "indices" - ] -} diff --git a/base/group-indices/test/test.js b/base/group-indices/test/test.js deleted file mode 100644 index 8d5c5ef95..000000000 --- a/base/group-indices/test/test.js +++ /dev/null @@ -1,182 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var groupIndices = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof groupIndices, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first and second argument which do not have the same length', function test( t ) { - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - groupIndices( [ 1, 2, 3 ], [ 0, 0 ] ); - } -}); - -tape( 'the function groups array element indices as arrays associated with distinct keys', function test( t ) { - var expected; - var out; - var x; - var g; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - g = [ 'b', 'b', 'f', 'b' ]; - - expected = { - 'b': [ 0, 1, 3 ], - 'f': [ 2 ] - }; - out = groupIndices( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array element indices as arrays associated with distinct keys (array, typed array)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - g = new Float64Array( [ 1, 1, 2, 1 ] ); - - expected = { - '1': [ 0, 1, 3 ], - '2': [ 2 ] - }; - out = groupIndices( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array element indices as arrays associated with distinct keys (typed arrays)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - g = new Float64Array( [ 2, 2, 1, 1 ] ); - - expected = { - '1': [ 2, 3 ], - '2': [ 0, 1 ] - }; - out = groupIndices( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array element indices as arrays associated with distinct keys (array-like objects)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - g = { - 'length': 4, - '0': 'be', - '1': 'bo', - '2': 'fo', - '3': 'ba' - }; - - expected = { - 'be': [ 0 ], - 'bo': [ 1 ], - 'fo': [ 2 ], - 'ba': [ 3 ] - }; - out = groupIndices( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array element indices as arrays associated with distinct keys (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - g = toAccessorArray( [ 'b', 'b', 'f', 'b' ] ); - - expected = { - 'b': [ 0, 1, 3 ], - 'f': [ 2 ] - }; - out = groupIndices( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array element indices as arrays associated with distinct keys (string serialization)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - g = [ {}, {}, {}, {} ]; - - expected = { - '[object Object]': [ 0, 1, 2, 3 ] - }; - out = groupIndices( x, g ); - - t.deepEqual( out, expected, 'returns expected groups' ); - t.end(); -}); - -tape( 'the function returns an empty object if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = {}; - actual = groupIndices( [], [] ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/group-values-by/README.md b/base/group-values-by/README.md deleted file mode 100644 index ee14a57bc..000000000 --- a/base/group-values-by/README.md +++ /dev/null @@ -1,173 +0,0 @@ - - -# groupValuesBy - -> Group element values according to an indicator function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var groupValuesBy = require( '@stdlib/array/base/group-values-by' ); -``` - -#### groupValuesBy( x, indicator\[, thisArg] ) - -Groups element values according to an indicator function. - -```javascript -function indicator( v ) { - return v[ 0 ]; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var out = groupValuesBy( x, indicator ); -// returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } -``` - -An `indicator` function is provided the following arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `indicator` function execution context, provide a `thisArg`. - -```javascript -function indicator( v ) { - this.count += 1; - return v[ 0 ]; -} - -var x = [ 'beep', 'boop', 'foo', 'bar' ]; - -var context = { - 'count': 0 -}; -var out = groupValuesBy( x, indicator, context ); -// returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } - -var cnt = context.count; -// returns 4 -``` - -
- - - - - -
- -## Notes - -- The value returned by an `indicator` function should be a value which can be serialized as an object key. As a counterexample, - - ```javascript - function indicator( v ) { - return {}; - } - var x = [ 'beep', 'boop', 'foo', 'bar' ]; - - var out = groupValuesBy( x, indicator ); - // returns { '[object Object]': [ 'beep', 'boop', 'foo', 'bar' ] } - ``` - - while each group identifier is unique, all input array elements resolve to the same group because each group identifier serializes to the same string. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var groupValuesBy = require( '@stdlib/array/base/group-values-by' ); - -function indicator( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ]; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Group the values: -var out = groupValuesBy( x, indicator ); -// returns {...} - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/group-values-by/benchmark/benchmark.length.js b/base/group-values-by/benchmark/benchmark.length.js deleted file mode 100644 index 9b6d43054..000000000 --- a/base/group-values-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,109 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var groupValuesBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Indicator function. -* -* @private -* @param {*} value - current array element -* @param {NonNegativeInteger} index - current array element index -* @param {Collection} arr - input array -* @returns {*} indicator value -*/ -function indicator( value, index ) { - return index; // note: this corresponds to the extreme case where every element is in a distinct group -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = groupValuesBy( x, indicator ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len+',num_groups='+len, f ); - } -} - -main(); diff --git a/base/group-values-by/docs/repl.txt b/base/group-values-by/docs/repl.txt deleted file mode 100644 index 232f2fa51..000000000 --- a/base/group-values-by/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( x, indicator[, thisArg] ) - Groups element values according to an indicator function. - - When invoked, the indicator function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: input array. - - The value returned by an indicator function should be a value which can be - serialized as an object key. - - If provided an empty array, the function returns an empty object. - - Parameters - ---------- - x: ArrayLike - Input array. - - indicator: Function - Indicator function specifying which group an element in the input array - belongs to. - - thisArg: any (optional) - Indicator function execution context. - - Returns - ------- - out: Object - Group results. - - Examples - -------- - > function fcn( v ) { return v[ 0 ]; }; - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var out = {{alias}}( x, fcn ) - { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } - - See Also - -------- - diff --git a/base/group-values-by/docs/types/index.d.ts b/base/group-values-by/docs/types/index.d.ts deleted file mode 100644 index 95dd9e95b..000000000 --- a/base/group-values-by/docs/types/index.d.ts +++ /dev/null @@ -1,107 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Object key. -*/ -type Key = string | symbol | number; - -/** -* Specifies which group an element in the input array belongs to. -* -* @returns object key -*/ -type Nullary = ( this: U ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @returns object key -*/ -type Unary = ( this: U, value: T ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @returns object key -*/ -type Binary = ( this: U, value: T, index: number ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns object key -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection ) => Key; - -/** -* Specifies which group an element in the input array belongs to. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns object key -*/ -type Indicator = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing returned group results. -*/ -interface ValuesResults { - /** - * Object properties. - */ - [key: Key]: Array; -} - -/** -* Groups element values according to an indicator function. -* -* @param x - input array -* @param indicator - indicator function specifying which group an element in the input array belongs to -* @param thisArg - indicator function execution context -* @returns group results -* -* @example -* function indicator( v ) { -* return v[ 0 ]; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = groupValuesBy( x, indicator ); -* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } -*/ -declare function groupValuesBy( x: Collection | AccessorArrayLike, indicator: Indicator, thisArg?: ThisParameterType> ): ValuesResults; - - -// EXPORTS // - -export = groupValuesBy; diff --git a/base/group-values-by/docs/types/test.ts b/base/group-values-by/docs/types/test.ts deleted file mode 100644 index 1c8e613c9..000000000 --- a/base/group-values-by/docs/types/test.ts +++ /dev/null @@ -1,73 +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. -*/ - -import groupValuesBy = require( './index' ); - -/** -* Indicator function. -* -* @param v - value -* @returns result -*/ -function indicator( v: string ): string { - return v[ 0 ]; -} - - -// TESTS // - -// The function returns group results... -{ - const x = [ 'foo', 'bar' ]; - - groupValuesBy( x, indicator ); // $ExpectType ValuesResults -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - groupValuesBy( 5, indicator ); // $ExpectError - groupValuesBy( true, indicator ); // $ExpectError - groupValuesBy( false, indicator ); // $ExpectError - groupValuesBy( null, indicator ); // $ExpectError - groupValuesBy( void 0, indicator ); // $ExpectError - groupValuesBy( {}, indicator ); // $ExpectError - groupValuesBy( ( x: number ): number => x, indicator ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid function... -{ - const x = [ 'foo', 'bar' ]; - - groupValuesBy( x, '5' ); // $ExpectError - groupValuesBy( x, 5 ); // $ExpectError - groupValuesBy( x, true ); // $ExpectError - groupValuesBy( x, false ); // $ExpectError - groupValuesBy( x, null ); // $ExpectError - groupValuesBy( x, void 0 ); // $ExpectError - groupValuesBy( x, {} ); // $ExpectError - groupValuesBy( x, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 'foo', 'bar' ]; - - groupValuesBy(); // $ExpectError - groupValuesBy( x ); // $ExpectError - groupValuesBy( x, indicator, {}, {} ); // $ExpectError -} diff --git a/base/group-values-by/examples/index.js b/base/group-values-by/examples/index.js deleted file mode 100644 index 56ec38e7f..000000000 --- a/base/group-values-by/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var groupValuesBy = require( './../lib' ); - -function indicator( v ) { - // Use the first letter of each element to define groups: - return v[ 0 ]; -} - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Group the values: -var out = groupValuesBy( x, indicator ); -// returns {...} - -console.log( out ); diff --git a/base/group-values-by/lib/index.js b/base/group-values-by/lib/index.js deleted file mode 100644 index 54147f327..000000000 --- a/base/group-values-by/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Group element values according to an indicator function. -* -* @module @stdlib/array/base/group-values-by -* -* @example -* var groupValuesBy = require( '@stdlib/array/base/group-values-by' ); -* -* function indicator( v ) { -* return v[ 0 ]; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = groupValuesBy( x, indicator ); -* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/group-values-by/lib/main.js b/base/group-values-by/lib/main.js deleted file mode 100644 index dc511259c..000000000 --- a/base/group-values-by/lib/main.js +++ /dev/null @@ -1,80 +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 isArray = require( '@stdlib/assert/is-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Groups element values according to an indicator function. -* -* @param {Collection} x - input array -* @param {Function} indicator - indicator function specifying which group an element in the input collection belongs to -* @param {*} [thisArg] - indicator function execution context -* @returns {Object} group results -* -* @example -* function indicator( v ) { -* return v[ 0 ]; -* } -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* -* var out = groupValuesBy( x, indicator ); -* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } -*/ -function groupValuesBy( x, indicator, thisArg ) { - var get; - var len; - var out; - var g; - var o; - var v; - var i; - - // Get the number of elements to group: - len = x.length; - - // Resolve an accessor for retrieving array elements: - get = resolveGetter( x ); - - // Loop over the elements and assign each to a group... - out = {}; - for ( i = 0; i < len; i++ ) { - v = get( x, i ); - g = indicator.call( thisArg, v, i, x ); - o = out[ g ]; - if ( isArray( o ) ) { - o.push( v ); - } else { - out[ g ] = [ v ]; - } - } - return out; -} - - -// EXPORTS // - -module.exports = groupValuesBy; diff --git a/base/group-values-by/package.json b/base/group-values-by/package.json deleted file mode 100644 index acbb053c4..000000000 --- a/base/group-values-by/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/group-values-by", - "version": "0.0.0", - "description": "Group element values according to an indicator function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "groupby", - "group-by", - "aggregate", - "summarize", - "partition", - "split" - ] -} diff --git a/base/group-values-by/test/test.js b/base/group-values-by/test/test.js deleted file mode 100644 index 8039ae75d..000000000 --- a/base/group-values-by/test/test.js +++ /dev/null @@ -1,193 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var groupValuesBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof groupValuesBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function groups array element values according to an indicator function', function test( t ) { - var expected; - var out; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = { - 'b': [ 'beep', 'boop', 'bar' ], - 'f': [ 'foo' ] - }; - out = groupValuesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - return v[ 0 ]; - } -}); - -tape( 'the function groups array element values according to an indicator function (typed arrays)', function test( t ) { - var expected; - var out; - var x; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - - expected = { - '1': [ -1.0, -10.2 ], - '2': [ 3.14, 4.2 ] - }; - out = groupValuesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v, i ) { - if ( i < 2 ) { - return 2; - } - return 1; - } -}); - -tape( 'the function groups array element values according to an indicator function (array-like objects)', function test( t ) { - var expected; - var out; - var x; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - - expected = { - 'be': [ 'beep' ], - 'bo': [ 'boop' ], - 'fo': [ 'foo' ], - 'ba': [ 'bar' ] - }; - out = groupValuesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - return v.slice( 0, 2 ); - } -}); - -tape( 'the function groups array element values according to an indicator function (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - - expected = { - 'b': [ 'beep', 'boop', 'bar' ], - 'f': [ 'foo' ] - }; - out = groupValuesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - return v[ 0 ]; - } -}); - -tape( 'the function groups array element values according to an indicator function (string serialization)', function test( t ) { - var expected; - var out; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = { - '[object Object]': [ 'beep', 'boop', 'foo', 'bar' ] - }; - out = groupValuesBy( x, indicator ); - - t.deepEqual( out, expected, 'returns expected groups' ); - t.end(); - - function indicator() { - return {}; - } -}); - -tape( 'the function returns an empty object if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = {}; - actual = groupValuesBy( [], indicator ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function indicator( v ) { - t.fail( 'should not be called' ); - return v; - } -}); - -tape( 'the function supports specifying a callback execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - - expected = { - 'b': [ 'beep', 'boop', 'bar' ], - 'f': [ 'foo' ] - }; - ctx = { - 'count': 0 - }; - out = groupValuesBy( x, indicator, ctx ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, x.length, 'returns expected value' ); - t.end(); - - function indicator( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v[ 0 ]; - } -}); diff --git a/base/group-values-on-key/README.md b/base/group-values-on-key/README.md deleted file mode 100644 index 9b8cdf861..000000000 --- a/base/group-values-on-key/README.md +++ /dev/null @@ -1,160 +0,0 @@ - - -# groupValuesOnKey - -> Group the elements of an array according to a specified property name. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var groupValuesOnKey = require( '@stdlib/array/base/group-values-on-key' ); -``` - -#### groupValuesOnKey( x, key ) - -Groups the elements of an array according to a specified property name. - -```javascript -var x = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 1, - 'y': 3 - } -]; - -var out = groupValuesOnKey( x, 'y' ); -// returns { '2': [ { 'x': 1, 'y': 2 } ], '3': [ { 'x': 1, 'y': 3 } ] } -``` - -The function supports the following parameters: - -- **x**: input array. -- **key**: property name whose values are used to determine groups. - -
- - - - - -
- -## Notes - -- Each value associated with a specified `key` should resolve to a value which can be serialized as an object key. As a counterexample, - - ```javascript - var x = [ - { - 'x': 1, - 'y': {} - }, - { - 'x': 1, - 'y': {} - } - ]; - - var out = groupValuesOnKey( x, 'y' ); - // returns { '[object Object]': [ { 'x': 1, 'y': {} }, { 'x': 1, 'y': {} } ] } - ``` - - while each "group" is unique, all input array elements resolve to the same group because each group identifier serializes to the same string. - -- If provided an empty array, the function returns an empty object. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( '@stdlib/array/base/filled-by' ); -var groupValuesOnKey = require( '@stdlib/array/base/group-values-on-key' ); - -function clbk( idx ) { - return { - 'x': idx, - 'y': discreteUniform( 0, 10 ) - }; -} - -// Create an array of random objects: -var values = filledBy( 100, clbk ); - -// Group elements according to the values of `y`: -var out = groupValuesOnKey( values, 'y' ); -// returns {...} - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/group-values-on-key/benchmark/benchmark.length.js b/base/group-values-on-key/benchmark/benchmark.length.js deleted file mode 100644 index 73905c1c5..000000000 --- a/base/group-values-on-key/benchmark/benchmark.length.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var filledBy = require( './../../../base/filled-by' ); -var pkg = require( './../package.json' ).name; -var groupValuesOnKey = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns an object. -* -* @private -* @param {NonNegativeInteger} idx - element index -* @returns {Object} object -*/ -function clbk( idx ) { - return { - 'x': idx, - 'y': idx - }; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filledBy( len, clbk ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = groupValuesOnKey( x, 'y' ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len+',num_groups='+len, f ); - } -} - -main(); diff --git a/base/group-values-on-key/docs/repl.txt b/base/group-values-on-key/docs/repl.txt deleted file mode 100644 index d381a3ea2..000000000 --- a/base/group-values-on-key/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, key ) - Groups the elements of an array according to a specified property name. - - If provided an empty array, the function returns an empty object. - - Parameters - ---------- - x: ArrayLike - Input array. - - key: string|number|symbol - Property name whose values are used to determine groups. Each value - associated with a specified `key` should resolve to a value which can be - serialized as an object key. - - Returns - ------- - out: Object - Group results. - - Examples - -------- - > var x = [ { 'x': 1, 'y': 2 }, { 'x': 1, 'y': 3 } ]; - > var out = {{alias}}( x, 'y' ) - { '2': [ { 'x': 1, 'y': 2 } ], '3': [ { 'x': 1, 'y': 3 } ] } - - See Also - -------- - diff --git a/base/group-values-on-key/docs/types/index.d.ts b/base/group-values-on-key/docs/types/index.d.ts deleted file mode 100644 index e24637641..000000000 --- a/base/group-values-on-key/docs/types/index.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Object key. -*/ -type Key = string | symbol | number; - -/** -* Groups the elements of an array according to a specified property name. -* -* @param x - input array -* @param key - property name whose values are used to determine groups -* @returns group results -* -* @example -* var x = [ -* { -* 'x': 1, -* 'y': 2 -* }, -* { -* 'x': 1, -* 'y': 3 -* } -* ]; -* -* var out = groupValuesOnKey( x, 'y' ); -* // returns { '2': [ { 'x': 1, 'y': 2 } ], '3': [ { 'x': 1, 'y': 3 } ] } -*/ -declare function groupValuesOnKey, K extends keyof T>( x: Collection | AccessorArrayLike, key: K ): Record>; - - -// EXPORTS // - -export = groupValuesOnKey; diff --git a/base/group-values-on-key/docs/types/test.ts b/base/group-values-on-key/docs/types/test.ts deleted file mode 100644 index 1e86db292..000000000 --- a/base/group-values-on-key/docs/types/test.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import groupValuesOnKey = require( './index' ); - - -// TESTS // - -// The function returns group results... -{ - const x = [ - { - 'x': 1, - 'y': 2 - } - ]; - - groupValuesOnKey( x, 'y' ); // $ExpectType Record -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - groupValuesOnKey( 5, 'y' ); // $ExpectError - groupValuesOnKey( true, 'y' ); // $ExpectError - groupValuesOnKey( false, 'y' ); // $ExpectError - groupValuesOnKey( null, 'y' ); // $ExpectError - groupValuesOnKey( void 0, 'y' ); // $ExpectError - groupValuesOnKey( {}, 'y' ); // $ExpectError - groupValuesOnKey( ( x: number ): number => x, 'y' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a valid key... -{ - const x = [ - { - 'x': 1, - 'y': 2 - } - ]; - - groupValuesOnKey( x, true ); // $ExpectError - groupValuesOnKey( x, false ); // $ExpectError - groupValuesOnKey( x, null ); // $ExpectError - groupValuesOnKey( x, void 0 ); // $ExpectError - groupValuesOnKey( x, {} ); // $ExpectError - groupValuesOnKey( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ - { - 'x': 1, - 'y': 2 - } - ]; - - groupValuesOnKey(); // $ExpectError - groupValuesOnKey( x ); // $ExpectError - groupValuesOnKey( x, 'y', {} ); // $ExpectError -} diff --git a/base/group-values-on-key/examples/index.js b/base/group-values-on-key/examples/index.js deleted file mode 100644 index 441b1bec8..000000000 --- a/base/group-values-on-key/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( './../../../base/filled-by' ); -var groupValuesOnKey = require( './../lib' ); - -function clbk( idx ) { - return { - 'x': idx, - 'y': discreteUniform( 0, 10 ) - }; -} - -// Create an array of random objects: -var values = filledBy( 100, clbk ); - -// Group elements according to the values of `y`: -var out = groupValuesOnKey( values, 'y' ); -// returns {...} - -console.log( out ); diff --git a/base/group-values-on-key/lib/index.js b/base/group-values-on-key/lib/index.js deleted file mode 100644 index ad02faeb4..000000000 --- a/base/group-values-on-key/lib/index.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Group the elements of an array according to a specified property name. -* -* @module @stdlib/array/base/group-values-on-key -* -* @example -* var groupValuesOnKey = require( '@stdlib/array/base/group-values-on-key' ); -* -* var x = [ -* { -* 'x': 1, -* 'y': 2 -* }, -* { -* 'x': 1, -* 'y': 3 -* } -* ]; -* -* var out = groupValuesOnKey( x, 'y' ); -* // returns { '2': [ { 'x': 1, 'y': 2 } ], '3': [ { 'x': 1, 'y': 3 } ] } -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/group-values-on-key/lib/main.js b/base/group-values-on-key/lib/main.js deleted file mode 100644 index 72e782751..000000000 --- a/base/group-values-on-key/lib/main.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert/is-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Groups the elements of an array according to a specified property name. -* -* @param {Collection} x - input array -* @param {(string|symbol|number)} key - property name whose values are used to determine groups -* @returns {Object} group results -* -* @example -* var x = [ -* { -* 'x': 1, -* 'y': 2 -* }, -* { -* 'x': 1, -* 'y': 3 -* } -* ]; -* -* var out = groupValuesOnKey( x, 'y' ); -* // returns { '2': [ { 'x': 1, 'y': 2 } ], '3': [ { 'x': 1, 'y': 3 } ] } -*/ -function groupValuesOnKey( x, key ) { - var get; - var out; - var o; - var v; - var i; - var k; - - // Resolve an accessor for retrieving array elements: - get = resolveGetter( x ); - - // Loop over the elements and assign each to a group... - out = {}; - for ( i = 0; i < x.length; i++ ) { - v = get( x, i ); - k = v[ key ]; - o = out[ k ]; - if ( isArray( o ) ) { - o.push( v ); - } else { - out[ k ] = [ v ]; - } - } - return out; -} - - -// EXPORTS // - -module.exports = groupValuesOnKey; diff --git a/base/group-values-on-key/package.json b/base/group-values-on-key/package.json deleted file mode 100644 index f45617147..000000000 --- a/base/group-values-on-key/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/group-values-on-key", - "version": "0.0.0", - "description": "Group the elements of an array according to a specified property name.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "groupby", - "group-by", - "aggregate", - "summarize", - "partition", - "split" - ] -} diff --git a/base/group-values-on-key/test/test.js b/base/group-values-on-key/test/test.js deleted file mode 100644 index 906177715..000000000 --- a/base/group-values-on-key/test/test.js +++ /dev/null @@ -1,220 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var groupValuesOnKey = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof groupValuesOnKey, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function groups array elements', function test( t ) { - var expected; - var out; - var x; - - x = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 1, - 'y': 3 - }, - { - 'x': 1, - 'y': 2 - } - ]; - - expected = { - '2': [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 1, - 'y': 2 - } - ], - '3': [ - { - 'x': 1, - 'y': 3 - } - ] - }; - out = groupValuesOnKey( x, 'y' ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array elements (array-like objects)', function test( t ) { - var expected; - var out; - var x; - - x = { - 'length': 3, - '0': { - 'x': 1, - 'y': 2 - }, - '1': { - 'x': 1, - 'y': 3 - }, - '2': { - 'x': 1, - 'y': 2 - } - }; - - expected = { - '2': [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 1, - 'y': 2 - } - ], - '3': [ - { - 'x': 1, - 'y': 3 - } - ] - }; - out = groupValuesOnKey( x, 'y' ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array elements (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - - x = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 1, - 'y': 3 - }, - { - 'x': 1, - 'y': 2 - } - ]; - - expected = { - '2': [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 1, - 'y': 2 - } - ], - '3': [ - { - 'x': 1, - 'y': 3 - } - ] - }; - out = groupValuesOnKey( toAccessorArray( x ), 'y' ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array elements (string serialization)', function test( t ) { - var expected; - var out; - var x; - - x = [ - { - 'x': 1, - 'y': {} - }, - { - 'x': 1, - 'y': {} - }, - { - 'x': 1, - 'y': {} - } - ]; - - expected = { - '[object Object]': [ - { - 'x': 1, - 'y': {} - }, - { - 'x': 1, - 'y': {} - }, - { - 'x': 1, - 'y': {} - } - ] - }; - out = groupValuesOnKey( x, 'y' ); - - t.deepEqual( out, expected, 'returns expected groups' ); - t.end(); -}); - -tape( 'the function returns an empty object if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = {}; - actual = groupValuesOnKey( [], 'y' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/group-values/README.md b/base/group-values/README.md deleted file mode 100644 index bd228e1a9..000000000 --- a/base/group-values/README.md +++ /dev/null @@ -1,142 +0,0 @@ - - -# groupValues - -> Group elements as arrays associated with distinct keys. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var groupValues = require( '@stdlib/array/base/group-values' ); -``` - -#### groupValues( x, groups ) - -Groups elements as arrays associated with distinct keys. - -```javascript -var x = [ 'beep', 'boop', 'foo', 'bar' ]; -var groups = [ 'b', 'b', 'f', 'b' ]; - -var out = groupValues( x, groups ); -// returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } -``` - -
- - - - - -
- -## Notes - -- Each value in `groups` should resolve to a value which can be serialized as an object key. As a counterexample, - - ```javascript - var x = [ 'beep', 'boop', 'foo', 'bar' ]; - var groups = [ {}, {}, {}, {} ]; - - var out = groupValues( x, groups ); - // returns { '[object Object]': [ 'beep', 'boop', 'foo', 'bar' ] } - ``` - - while each "group" is unique, all input array elements resolve to the same group because each group identifier serializes to the same string. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( '@stdlib/array/base/take-indexed' ); -var groupValues = require( '@stdlib/array/base/group-values' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, values.length, { - 'dtype': 'generic' -}); - -// Group the values: -var out = groupValues( x, groups ); -// returns {...} - -console.log( out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/group-values/benchmark/benchmark.length.js b/base/group-values/benchmark/benchmark.length.js deleted file mode 100644 index 368a0644e..000000000 --- a/base/group-values/benchmark/benchmark.length.js +++ /dev/null @@ -1,101 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var groupValues = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var groups; - var x; - - x = zeroTo( len ); - groups = zeroTo( len ); // note: this corresponds to the extreme case where every element is in a distinct group - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = groupValues( x, groups ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( out ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len+',num_groups='+len, f ); - } -} - -main(); diff --git a/base/group-values/docs/repl.txt b/base/group-values/docs/repl.txt deleted file mode 100644 index b0d5c0b3c..000000000 --- a/base/group-values/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( x, groups ) - Groups elements as arrays associated with distinct keys. - - If provided an empty array, the function returns an empty object. - - Parameters - ---------- - x: ArrayLike - Input array. - - groups: ArrayLike - An array defining which group an element in the input array belongs to. - Each value in `groups` should resolve to a value which can be serialized - as an object key. - - Returns - ------- - out: Object - Group results. - - Examples - -------- - > var x = [ 'beep', 'boop', 'foo', 'bar' ]; - > var g = [ 'b', 'b', 'f', 'b' ]; - > var out = {{alias}}( x, g ) - { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } - > g = [ 1, 1, 2, 1 ]; - > out = {{alias}}( x, g ) - { '1': [ 'beep', 'boop', 'bar' ], '2': [ 'foo' ] } - - See Also - -------- - diff --git a/base/group-values/docs/types/index.d.ts b/base/group-values/docs/types/index.d.ts deleted file mode 100644 index 30e54f915..000000000 --- a/base/group-values/docs/types/index.d.ts +++ /dev/null @@ -1,59 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Object key. -*/ -type Key = string | symbol | number; - -/** -* Interface describing returned group results. -*/ -interface ValuesResults { - /** - * Object properties. - */ - [key: Key]: Array; -} - -/** -* Groups elements as arrays associated with distinct keys. -* -* @param x - input array -* @param groups - array defining which group an element in the input array belongs to -* @returns group results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var groups = [ 'b', 'b', 'f', 'b' ]; -* -* var out = groupValues( x, groups ); -* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } -*/ -declare function groupValues( x: Collection | AccessorArrayLike, groups: Collection | AccessorArrayLike ): ValuesResults; - - -// EXPORTS // - -export = groupValues; diff --git a/base/group-values/docs/types/test.ts b/base/group-values/docs/types/test.ts deleted file mode 100644 index 6746fbcc3..000000000 --- a/base/group-values/docs/types/test.ts +++ /dev/null @@ -1,66 +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. -*/ - -import groupValues = require( './index' ); - - -// TESTS // - -// The function returns group results... -{ - const x = [ 1, 2, 3 ]; - const g = [ 0, 0, 0 ]; - - groupValues( x, g ); // $ExpectType ValuesResults -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - const g = [ 0, 0, 0 ]; - - groupValues( 5, g ); // $ExpectError - groupValues( true, g ); // $ExpectError - groupValues( false, g ); // $ExpectError - groupValues( null, g ); // $ExpectError - groupValues( void 0, g ); // $ExpectError - groupValues( {}, g ); // $ExpectError - groupValues( ( x: number ): number => x, g ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array... -{ - const x = [ 1, 2, 3 ]; - - groupValues( x, 5 ); // $ExpectError - groupValues( x, true ); // $ExpectError - groupValues( x, false ); // $ExpectError - groupValues( x, null ); // $ExpectError - groupValues( x, void 0 ); // $ExpectError - groupValues( x, {} ); // $ExpectError - groupValues( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - const g = [ 0, 0, 0 ]; - - groupValues(); // $ExpectError - groupValues( x ); // $ExpectError - groupValues( x, g, {} ); // $ExpectError -} diff --git a/base/group-values/examples/index.js b/base/group-values/examples/index.js deleted file mode 100644 index 2775b3e15..000000000 --- a/base/group-values/examples/index.js +++ /dev/null @@ -1,44 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var take = require( './../../../base/take-indexed' ); -var groupValues = require( './../lib' ); - -// Define an initial array of values: -var values = [ 'beep', 'boop', 'foo', 'bar', 'woot', 'woot' ]; - -// Sample from the initial array to generate a random collection: -var indices = discreteUniform( 100, 0, values.length-1, { - 'dtype': 'generic' -}); -var x = take( values, indices ); -// returns [...] - -// Randomly assign collection values to groups: -var groups = discreteUniform( x.length, 0, values.length, { - 'dtype': 'generic' -}); - -// Group the values: -var out = groupValues( x, groups ); -// returns {...} - -console.log( out ); diff --git a/base/group-values/lib/index.js b/base/group-values/lib/index.js deleted file mode 100644 index 47a3519b0..000000000 --- a/base/group-values/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Group elements as arrays associated with distinct keys. -* -* @module @stdlib/array/base/group-values -* -* @example -* var groupValues = require( '@stdlib/array/base/group-values' ); -* -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var groups = [ 'b', 'b', 'f', 'b' ]; -* -* var out = groupValues( x, groups ); -* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/group-values/lib/main.js b/base/group-values/lib/main.js deleted file mode 100644 index 8384ab90c..000000000 --- a/base/group-values/lib/main.js +++ /dev/null @@ -1,81 +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 isArray = require( '@stdlib/assert/is-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Groups elements as arrays associated with distinct keys. -* -* @param {Collection} x - input array -* @param {Collection} groups - array defining which group an element in the input array belongs to -* @throws {RangeError} must provide arrays having the same length -* @returns {Object} group results -* -* @example -* var x = [ 'beep', 'boop', 'foo', 'bar' ]; -* var groups = [ 'b', 'b', 'f', 'b' ]; -* -* var out = groupValues( x, groups ); -* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] } -*/ -function groupValues( x, groups ) { - var xget; - var gget; - var len; - var out; - var g; - var o; - var v; - var i; - - // Get the number of elements to group: - len = x.length; - if ( groups.length !== len ) { - throw new RangeError( 'invalid argument. The first and second arguments must have the same length.' ); - } - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - gget = resolveGetter( groups ); - - // Loop over the elements and assign each to a group... - out = {}; - for ( i = 0; i < len; i++ ) { - v = xget( x, i ); - g = gget( groups, i ).toString(); - o = out[ g ]; - if ( isArray( o ) ) { - o.push( v ); - } else { - out[ g ] = [ v ]; - } - } - return out; -} - - -// EXPORTS // - -module.exports = groupValues; diff --git a/base/group-values/package.json b/base/group-values/package.json deleted file mode 100644 index c49ec1d0f..000000000 --- a/base/group-values/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/group-values", - "version": "0.0.0", - "description": "Group elements as arrays associated with distinct keys.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "group", - "groupby", - "group-by", - "aggregate", - "summarize", - "partition", - "split" - ] -} diff --git a/base/group-values/test/test.js b/base/group-values/test/test.js deleted file mode 100644 index 04b3e22ba..000000000 --- a/base/group-values/test/test.js +++ /dev/null @@ -1,182 +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 toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var groupValues = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof groupValues, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first and second argument which do not have the same length', function test( t ) { - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - groupValues( [ 1, 2, 3 ], [ 0, 0 ] ); - } -}); - -tape( 'the function groups array elements as arrays associated with distinct keys', function test( t ) { - var expected; - var out; - var x; - var g; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - g = [ 'b', 'b', 'f', 'b' ]; - - expected = { - 'b': [ 'beep', 'boop', 'bar' ], - 'f': [ 'foo' ] - }; - out = groupValues( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array elements as arrays associated with distinct keys (array, typed array)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - g = new Float64Array( [ 1, 1, 2, 1 ] ); - - expected = { - '1': [ 'beep', 'boop', 'bar' ], - '2': [ 'foo' ] - }; - out = groupValues( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array elements as arrays associated with distinct keys (typed arrays)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = new Float64Array( [ 3.14, 4.2, -1.0, -10.2 ] ); - g = new Float64Array( [ 2, 2, 1, 1 ] ); - - expected = { - '1': [ -1.0, -10.2 ], - '2': [ 3.14, 4.2 ] - }; - out = groupValues( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array elements as arrays associated with distinct keys (array-like objects)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = { - 'length': 4, - '0': 'beep', - '1': 'boop', - '2': 'foo', - '3': 'bar' - }; - g = { - 'length': 4, - '0': 'be', - '1': 'bo', - '2': 'fo', - '3': 'ba' - }; - - expected = { - 'be': [ 'beep' ], - 'bo': [ 'boop' ], - 'fo': [ 'foo' ], - 'ba': [ 'bar' ] - }; - out = groupValues( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array elements as arrays associated with distinct keys (accessor arrays)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = toAccessorArray( [ 'beep', 'boop', 'foo', 'bar' ] ); - g = toAccessorArray( [ 'b', 'b', 'f', 'b' ] ); - - expected = { - 'b': [ 'beep', 'boop', 'bar' ], - 'f': [ 'foo' ] - }; - out = groupValues( x, g ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function groups array elements as arrays associated with distinct keys (string serialization)', function test( t ) { - var expected; - var out; - var x; - var g; - - x = [ 'beep', 'boop', 'foo', 'bar' ]; - g = [ {}, {}, {}, {} ]; - - expected = { - '[object Object]': [ 'beep', 'boop', 'foo', 'bar' ] - }; - out = groupValues( x, g ); - - t.deepEqual( out, expected, 'returns expected groups' ); - t.end(); -}); - -tape( 'the function returns an empty object if provided an empty array', function test( t ) { - var expected; - var actual; - - expected = {}; - actual = groupValues( [], [] ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/incrspace/README.md b/base/incrspace/README.md deleted file mode 100644 index 58ab90dcf..000000000 --- a/base/incrspace/README.md +++ /dev/null @@ -1,123 +0,0 @@ - - -# incrspace - -> Generate a linearly spaced numeric array according to a provided increment. - -
- -## Usage - -```javascript -var incrspace = require( '@stdlib/array/base/incrspace' ); -``` - -#### incrspace( start, stop, increment ) - -Generates a linearly spaced numeric `array` according to a provided `increment`. - -```javascript -var arr = incrspace( 0, 11, 2 ); -// returns [ 0, 2, 4, 6, 8, 10 ] -``` - -
- - - -
- -### Notes - -- The output `array` is guaranteed to include the `start` value but does **not** include the `stop` value. Beware that values subsequent to the `start` value are subject to floating-point errors. Hence, - - ```javascript - var arr = incrspace( 0.1, 0.5, 0.2 ); - // returns [ 0.1, ~0.3 ] - ``` - - where `arr[1]` is only guaranteed to be approximately equal to `0.3`. - - If you desire more control over element precision, consider using [roundn][@stdlib/math/base/special/roundn]: - - ```javascript - var roundn = require( '@stdlib/math/base/special/roundn' ); - - // Create an array subject to floating-point errors: - var arr = incrspace( 0, 1.01, 0.02 ); - - // Round each value to the nearest hundredth: - var i; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = roundn( arr[ i ], -2 ); - } - - console.log( arr.join( '\n' ) ); - ``` - -
- - - -
- -## Examples - - - -```javascript -var incrspace = require( '@stdlib/array/base/incrspace' ); - -var out = incrspace( 0, 10, 2 ); -console.log( out.join( '\n' ) ); - -out = incrspace( 0, 11, 2 ); -console.log( out.join( '\n' ) ); - -out = incrspace( 0, 1.01, 0.02 ); -console.log( out.join( '\n' ) ); - -// Create an array using a negative increment: -out = incrspace( 10, 0, -2 ); -console.log( out.join( '\n' ) ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/incrspace/benchmark/benchmark.js b/base/incrspace/benchmark/benchmark.js deleted file mode 100644 index 509767417..000000000 --- a/base/incrspace/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var incrspace = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - var v; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = incrspace( i, i+100, 1 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/incrspace/benchmark/benchmark.length.js b/base/incrspace/benchmark/benchmark.length.js deleted file mode 100644 index 5bd5e5a69..000000000 --- a/base/incrspace/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var incrspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = incrspace( i, i+len, 1 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/incrspace/docs/repl.txt b/base/incrspace/docs/repl.txt deleted file mode 100644 index 265661488..000000000 --- a/base/incrspace/docs/repl.txt +++ /dev/null @@ -1,31 +0,0 @@ - -{{alias}}( start, stop, increment ) - Generates a linearly spaced numeric array according to a provided increment. - - The output array is guaranteed to include the `start` value but does not - include the `stop` value. - - Parameters - ---------- - start: number - First array value. - - stop: number - Array element bound. - - increment: number - Increment. - - Returns - ------- - out: Array - Linearly spaced numeric array. - - Examples - -------- - > var arr = {{alias}}( 0, 11, 2 ) - [ 0, 2, 4, 6, 8, 10 ] - - See Also - -------- - diff --git a/base/incrspace/docs/types/index.d.ts b/base/incrspace/docs/types/index.d.ts deleted file mode 100644 index e8dd6111c..000000000 --- a/base/incrspace/docs/types/index.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Generates a linearly spaced numeric array according to a provided increment. -* -* @param x1 - first array value -* @param x2 - array element bound -* @param increment - increment -* @returns linearly spaced numeric array -* -* @example -* var arr = incrspace( 0, 11, 2 ); -* // returns [ 0, 2, 4, 6, 8, 10 ] -*/ -declare function incrspace( x1: number, x2: number, increment: number ): Array; - - -// EXPORTS // - -export = incrspace; diff --git a/base/incrspace/docs/types/test.ts b/base/incrspace/docs/types/test.ts deleted file mode 100644 index aa55b287e..000000000 --- a/base/incrspace/docs/types/test.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 incrspace = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - incrspace( 0, 11, 2 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided values other than two numbers for the first two parameters... -{ - incrspace( true, 10, 1 ); // $ExpectError - incrspace( false, 10, 1 ); // $ExpectError - incrspace( '5', 10, 1 ); // $ExpectError - incrspace( [], 10, 1 ); // $ExpectError - incrspace( {}, 20, 1 ); // $ExpectError - incrspace( ( x: number ): number => x, 20, 1 ); // $ExpectError - - incrspace( 9, true, 1 ); // $ExpectError - incrspace( 9, false, 1 ); // $ExpectError - incrspace( 5, '5', 1 ); // $ExpectError - incrspace( 8, [], 1 ); // $ExpectError - incrspace( 9, {}, 1 ); // $ExpectError - incrspace( 8, ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a value other than a number for the third parameter... -{ - incrspace( 3, 20, true ); // $ExpectError - incrspace( 4, 20, false ); // $ExpectError - incrspace( 2, 20, '5' ); // $ExpectError - incrspace( 2, 20, [] ); // $ExpectError - incrspace( 2, 20, {} ); // $ExpectError - incrspace( 9, 20, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - incrspace(); // $ExpectError - incrspace( 3 ); // $ExpectError - incrspace( 3, 4 ); // $ExpectError -} diff --git a/base/incrspace/examples/index.js b/base/incrspace/examples/index.js deleted file mode 100644 index 06e0a9453..000000000 --- a/base/incrspace/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 incrspace = require( './../lib' ); - -console.log( '\nIncrement 2:' ); -var out = incrspace( 0, 10, 2 ); -console.log( out.join( '\n' ) ); - -console.log( '\nIncrement 2:' ); -out = incrspace( 0, 11, 2 ); -console.log( out.join( '\n' ) ); - -console.log( '\nIncrement 0.02:' ); -out = incrspace( 0, 1.01, 0.02 ); -console.log( out.join( '\n' ) ); - -// Create an array using a negative increment: -console.log( '\nDecremented values:' ); -out = incrspace( 10, 0, -2 ); -console.log( out.join( '\n' ) ); diff --git a/base/incrspace/lib/index.js b/base/incrspace/lib/index.js deleted file mode 100644 index ebb774fd3..000000000 --- a/base/incrspace/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Generate a linearly spaced numeric array according to a provided increment. -* -* @module @stdlib/array/base/incrspace -* -* @example -* var incrspace = require( '@stdlib/array/base/incrspace' ); -* -* var arr = incrspace( 0, 11, 2 ); -* // returns [ 0, 2, 4, 6, 8, 10 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/incrspace/lib/main.js b/base/incrspace/lib/main.js deleted file mode 100644 index cadd0c76c..000000000 --- a/base/incrspace/lib/main.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var ceil = require( '@stdlib/math/base/special/ceil' ); - - -// MAIN // - -/** -* Generates a linearly spaced numeric array according to a provided increment. -* -* @param {number} x1 - first array value -* @param {number} x2 - array element bound -* @param {number} increment - increment -* @returns {Array} linearly spaced numeric array -* -* @example -* var arr = incrspace( 0, 11, 2 ); -* // returns [ 0, 2, 4, 6, 8, 10 ] -*/ -function incrspace( x1, x2, increment ) { - var arr; - var len; - var i; - - len = ceil( ( x2-x1 ) / increment ); - if ( len <= 1 ) { - return [ x1 ]; - } - arr = [ x1 ]; - for ( i = 1; i < len; i++ ) { - arr.push( x1 + (increment*i) ); - } - return arr; -} - - -// EXPORTS // - -module.exports = incrspace; diff --git a/base/incrspace/package.json b/base/incrspace/package.json deleted file mode 100644 index 6d7759713..000000000 --- a/base/incrspace/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/incrspace", - "version": "0.0.0", - "description": "Generate a linearly spaced numeric array according to a provided increment.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "matlab", - "linear", - "linspace", - "sequence", - "increment" - ] -} diff --git a/base/incrspace/test/test.js b/base/incrspace/test/test.js deleted file mode 100644 index eaf424bf2..000000000 --- a/base/incrspace/test/test.js +++ /dev/null @@ -1,68 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 incrspace = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof incrspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a linearly spaced array', function test( t ) { - var expected; - var actual; - var start; - var stop; - - start = 0; - stop = 10; - - actual = incrspace( start, stop, 2 ); - expected = [ 0, 2, 4, 6, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = incrspace( start, 11, 2 ); - expected = [ 0, 2, 4, 6, 8, 10 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - // Decrement: - actual = incrspace( stop, start, -2 ); - expected = [ 10, 8, 6, 4, 2 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - // Large array: - actual = incrspace( start, 1e6, 1 ); - t.equal( actual.length, 1e6, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a single element array for incompatible increments', function test( t ) { - t.deepEqual( incrspace( 0, 10, -1 ), [ 0 ], 'returns expected value' ); - t.deepEqual( incrspace( 0, 10, 11 ), [ 0 ], 'returns expected value' ); - t.end(); -}); diff --git a/base/index-of-same-value/README.md b/base/index-of-same-value/README.md deleted file mode 100644 index dd4a3d4d5..000000000 --- a/base/index-of-same-value/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# indexOfSameValue - -> Return the index of the first element which equals a provided search element according to the [SameValue Algorithm][@stdlib/assert/is-same-value]. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var indexOfSameValue = require( '@stdlib/array/base/index-of-same-value' ); -``` - -#### indexOfSameValue( x, searchElement, fromIndex ) - -Returns the index of the first element which equals a provided search element according to the [SameValue Algorithm][@stdlib/assert/is-same-value]. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var idx = indexOfSameValue( x, 3, 0 ); -// returns 2 -``` - -If the function is unable to find an element which equals a provided search element, the function returns `-1`. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var idx = indexOfSameValue( x, 7, 0 ); -// returns -1 -``` - -To begin searching from specific index, provide a non-zero `fromIndex` argument. - -```javascript -var x = [ 1, 1, 2, 1, 2, 3, 3 ]; - -var idx = indexOfSameValue( x, 2, 3 ); -// returns 4 -``` - -If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. - -```javascript -var x = [ 1, 1, 2, 1, 2, 3, 3 ]; - -var idx = indexOfSameValue( x, 2, -4 ); -// returns 4 -``` - -
- - - - - -
- -## Notes - -- The function performs a linear scan and returns immediately upon finding a match. -- When searching for a search element, the function checks for equality using the [SameValue Algorithm][@stdlib/assert/is-same-value] as specified in ECMAScript 5. As a consequence, `NaN` values are considered equal, and `-0` and `+0` are considered distinct. - -
- - - - - -
- -## Examples - - - -```javascript -var indexOfSameValue = require( '@stdlib/array/base/index-of-same-value' ); - -var x = [ 'foo', 'bar', 'beep', 'boop', 'foo', 'bar' ]; - -var idx = indexOfSameValue( x, 'beep', 0 ); -// returns 2 - -idx = indexOfSameValue( x, 'bop', 0 ); -// returns -1 - -idx = indexOfSameValue( x, 'foo', 1 ); -// returns 4 - -idx = indexOfSameValue( x, 'foo', -4 ); -// returns 4 - -idx = indexOfSameValue( x, 'foo', 5 ); -// returns -1 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/index-of-same-value/benchmark/benchmark.length.js b/base/index-of-same-value/benchmark/benchmark.length.js deleted file mode 100644 index 19cafc4d4..000000000 --- a/base/index-of-same-value/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var indexOfSameValue = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = indexOfSameValue( x, -2, 0 ); - if ( out !== out ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) || out >= 0 ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/index-of-same-value/docs/repl.txt b/base/index-of-same-value/docs/repl.txt deleted file mode 100644 index c146e8087..000000000 --- a/base/index-of-same-value/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, searchElement, fromIndex ) - Returns the index of the first element which equals a provided search - element according to the same value algorithm. - - The function performs a linear scan and returns immediately upon finding a - match. - - If unable to find an element which equals a provided search element, the - function returns -1. - - The function treats `-0` and `+0` as distinct and `NaNs` as the same. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - searchElement: any - Search element. - - fromIndex: integer - Starting index (inclusive). If less than zero, the starting index is - resolved relative to the last array element, with the last array element - corresponding to `fromIndex = -1`. - - Returns - ------- - out: integer - Index or -1. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ], 3, 0 ) - 2 - - See Also - -------- - diff --git a/base/index-of-same-value/docs/types/index.d.ts b/base/index-of-same-value/docs/types/index.d.ts deleted file mode 100644 index c2150ff6c..000000000 --- a/base/index-of-same-value/docs/types/index.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns the index of the first element which equals a provided search element according to the same value algorithm. -* -* ## Notes -* -* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. -* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. -* - If unable to find an element which equals a provided search element, the function returns `-1`. -* - If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. -* -* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 -* -* @param x - input array -* @param searchElement - search element -* @param fromIndex - starting index (inclusive) -* @returns index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = indexOfSameValue( x, 2, 0 ); -* // returns 1 -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var idx = indexOfSameValue( x, 2, 0 ); -* // returns 1 -*/ -declare function indexOfSameValue( x: Collection | AccessorArrayLike, searchElement: unknown, fromIndex: number ): number; - - -// EXPORTS // - -export = indexOfSameValue; diff --git a/base/index-of-same-value/docs/types/test.ts b/base/index-of-same-value/docs/types/test.ts deleted file mode 100644 index b66e76af1..000000000 --- a/base/index-of-same-value/docs/types/test.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import indexOfSameValue = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - indexOfSameValue( [ 1, 2, 3 ], 0, 3 ); // $ExpectType number - indexOfSameValue( new Float64Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOfSameValue( new Float32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOfSameValue( new Int32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOfSameValue( new Int16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOfSameValue( new Int8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOfSameValue( new Uint32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOfSameValue( new Uint16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOfSameValue( new Uint8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOfSameValue( new Uint8ClampedArray( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOfSameValue( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType number - indexOfSameValue( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - indexOfSameValue( 5, 0, 3 ); // $ExpectError - indexOfSameValue( true, 0, 3 ); // $ExpectError - indexOfSameValue( false, 0, 3 ); // $ExpectError - indexOfSameValue( null, 0, 3 ); // $ExpectError - indexOfSameValue( void 0, 0, 3 ); // $ExpectError - indexOfSameValue( {}, 0, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - indexOfSameValue( x, 0, '5' ); // $ExpectError - indexOfSameValue( x, 0, true ); // $ExpectError - indexOfSameValue( x, 0, false ); // $ExpectError - indexOfSameValue( x, 0, null ); // $ExpectError - indexOfSameValue( x, 0, void 0 ); // $ExpectError - indexOfSameValue( x, 0, [] ); // $ExpectError - indexOfSameValue( x, 0, {} ); // $ExpectError - indexOfSameValue( x, 0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - indexOfSameValue(); // $ExpectError - indexOfSameValue( [ 1, 2, 3 ] ); // $ExpectError - indexOfSameValue( [ 1, 2, 3 ], 0 ); // $ExpectError - indexOfSameValue( [ 1, 2, 3 ], 0, 3, false ); // $ExpectError -} diff --git a/base/index-of-same-value/examples/index.js b/base/index-of-same-value/examples/index.js deleted file mode 100644 index 2429c23a0..000000000 --- a/base/index-of-same-value/examples/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var indexOfSameValue = require( './../lib' ); - -var x = [ 'foo', 'bar', 'beep', 'boop', 'foo', 'bar' ]; - -var idx = indexOfSameValue( x, 'beep', 0 ); -console.log( idx ); -// => 2 - -idx = indexOfSameValue( x, 'bop', 0 ); -console.log( idx ); -// => -1 - -idx = indexOfSameValue( x, 'foo', 1 ); -console.log( idx ); -// => 4 - -idx = indexOfSameValue( x, 'foo', -4 ); -console.log( idx ); -// => 4 - -idx = indexOfSameValue( x, 'foo', 5 ); -console.log( idx ); -// => -1 diff --git a/base/index-of-same-value/lib/index.js b/base/index-of-same-value/lib/index.js deleted file mode 100644 index dac04af1b..000000000 --- a/base/index-of-same-value/lib/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return the index of the first element which equals a provided search element according to the same value algorithm. -* -* @module @stdlib/array/base/index-of-same-value -* -* @example -* var indexOfSameValue = require( '@stdlib/array/base/index-of-same-value' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = indexOfSameValue( x, 2, 0 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/index-of-same-value/lib/main.js b/base/index-of-same-value/lib/main.js deleted file mode 100644 index 95620fc2f..000000000 --- a/base/index-of-same-value/lib/main.js +++ /dev/null @@ -1,219 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/assert/is-accessor-array' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var isComplexTypedArray = require( './../../../base/assert/is-complex-typed-array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var isSameValue = require( '@stdlib/assert/is-same-value' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - - -// FUNCTIONS // - -/** -* Returns the index of the first element which equals a provided search element according to the same value algorithm. -* -* @private -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = indexed( x, 2, 0 ); -* // returns 1 -*/ -function indexed( x, searchElement, fromIndex ) { - var i; - for ( i = fromIndex; i < x.length; i++ ) { - if ( isSameValue( searchElement, x[ i ] ) ) { - return i; - } - } - return -1; -} - -/** -* Returns the index of the first element which equals a provided search element according to the same value algorithm. -* -* @private -* @param {Collection} x - input array object -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var idx = accessors( x, 2, 0 ); -* // returns 1 -*/ -function accessors( x, searchElement, fromIndex ) { - var get; - var i; - - get = resolveGetter( x ); - for ( i = fromIndex; i < x.length; i++ ) { - if ( isSameValue( searchElement, get( x, i ) ) ) { - return i; - } - } - return -1; -} - -/** -* Returns the index of the first element which equals a provided search element according to the same value algorithm. -* -* @private -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] ); -* -* var idx = complex( x, new Complex128( 3.0, 4.0 ), 1 ); -* // returns 2 -*/ -function complex( x, searchElement, fromIndex ) { - var view; - var re; - var im; - var i; - if ( !isComplexLike( searchElement ) ) { - return -1; - } - view = reinterpret( x, 0 ); - re = real( searchElement ); - im = imag( searchElement ); - for ( i = fromIndex*2; i < view.length; i += 2 ) { - if ( isSameValue( view[ i ], re ) && isSameValue( view[ i+1 ], im ) ) { - return i / 2; - } - } - return -1; -} - -/** -* Returns the index of the first element which equals a provided search element according to the same value algorithm. -* -* @private -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var x = new BooleanArray( [ true, false, true, false, true ] ); -* -* var idx = boolean( x, true, 1 ); -* // returns 2 -*/ -function boolean( x, searchElement, fromIndex ) { - var view; - var v; - var i; - if ( !isBoolean( searchElement ) ) { - return -1; - } - view = reinterpretBoolean( x, 0 ); - v = ( searchElement ) ? 1 : 0; - for ( i = fromIndex; i < view.length; i++ ) { - if ( view[ i ] === v ) { - return i; - } - } - return -1; -} - - -// MAIN // - -/** -* Returns the index of the first element which equals a provided search element according to the same value algorithm. -* -* ## Notes -* -* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. -* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. -* - If unable to find an element which equals a provided search element, the function returns `-1`. -* -* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 -* -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {integer} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = indexOfSameValue( x, 2, 0 ); -* // returns 1 -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var idx = indexOfSameValue( x, 2, 0 ); -* // returns 1 -*/ -function indexOfSameValue( x, searchElement, fromIndex ) { - if ( fromIndex < 0 ) { - fromIndex += x.length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - if ( isAccessorArray( x ) ) { - if ( isComplexTypedArray( x ) ) { - return complex( x, searchElement, fromIndex ); - } - if ( isBooleanArray( x ) ) { - return boolean( x, searchElement, fromIndex ); - } - return accessors( x, searchElement, fromIndex ); - } - return indexed( x, searchElement, fromIndex ); -} - - -// EXPORTS // - -module.exports = indexOfSameValue; diff --git a/base/index-of-same-value/package.json b/base/index-of-same-value/package.json deleted file mode 100644 index 2dd5f9717..000000000 --- a/base/index-of-same-value/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/index-of-same-value", - "version": "0.0.0", - "description": "Return the index of the first element which equals a provided search element according to the same value algorithm.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "search", - "find", - "scan", - "locate", - "index", - "same" - ] -} diff --git a/base/index-of-same-value/test/test.js b/base/index-of-same-value/test/test.js deleted file mode 100644 index 2da72c980..000000000 --- a/base/index-of-same-value/test/test.js +++ /dev/null @@ -1,478 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Complex128Array = require( './../../../complex128' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var indexOfSameValue = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof indexOfSameValue, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 2, 2, 3, 3 ]; - - actual = indexOfSameValue( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOfSameValue( x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOfSameValue( x, 1, -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, -10 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOfSameValue( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (float64)', function test( t ) { - var actual; - var x; - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - - actual = indexOfSameValue( x, 1.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, 2.0, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOfSameValue( x, 3.0, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOfSameValue( x, 1.0, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, 2.0, 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, 3.0, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOfSameValue( x, 1.0, -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, 3.0, -10 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOfSameValue( x, 1.0, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, 2.0, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, 3.0, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (complex128)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0 ] ); // eslint-disable-line max-len - - actual = indexOfSameValue( x, new Complex128( 1.0, 1.0 ), 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, new Complex128( 2.0, 2.0 ), 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOfSameValue( x, new Complex128( 3.0, 3.0 ), 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOfSameValue( x, new Complex128( 2.0, 2.0 ), 4 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOfSameValue( x, new Complex128( 1.0, 1.0 ), 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, new Complex128( 2.0, 2.0 ), 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, new Complex128( 3.0, 3.0 ), 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOfSameValue( x, new Complex128( 1.0, 1.0 ), -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, new Complex128( 3.0, 3.0 ), -10 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOfSameValue( x, new Complex128( 1.0, 1.0 ), -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, new Complex128( 2.0, 2.0 ), -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, new Complex128( 3.0, 3.0 ), -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Non-complex values: - actual = indexOfSameValue( x, 1.0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (bool)', function test( t ) { - var actual; - var x; - - x = new BooleanArray( [ true, true, false, false, true, true ] ); - - actual = indexOfSameValue( x, true, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, false, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOfSameValue( x, false, 4 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOfSameValue( x, true, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, false, 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, true, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOfSameValue( x, true, -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, true, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, false, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, true, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Non-boolean values: - actual = indexOfSameValue( x, 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (int32)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 1, 1, 2, 2, 3, 3 ] ); - - actual = indexOfSameValue( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOfSameValue( x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOfSameValue( x, 1, -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, -10 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOfSameValue( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (accessors)', function test( t ) { - var actual; - var x; - - x = new AccessorArray( [ 1, 1, 2, 2, 3, 3 ] ); - - actual = indexOfSameValue( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOfSameValue( x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOfSameValue( x, 1, -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, -10 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOfSameValue( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (array-like)', function test( t ) { - var actual; - var x; - - x = { - 'length': 6, - '0': 1, - '1': 1, - '2': 2, - '3': 2, - '4': 3, - '5': 3 - }; - - actual = indexOfSameValue( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOfSameValue( x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOfSameValue( x, 1, -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, -10 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOfSameValue( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOfSameValue( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOfSameValue( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `-1` if provided an empty array', function test( t ) { - var actual; - var x; - - actual = indexOfSameValue( [], 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOfSameValue( new Float64Array( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOfSameValue( new Int32Array( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOfSameValue( new AccessorArray( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 0 - }; - actual = indexOfSameValue( x, 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports NaN equality', function test( t ) { - var actual; - var x; - - actual = indexOfSameValue( [ NaN ], NaN, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( new Float64Array( [ NaN ] ), NaN, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( new AccessorArray( [ NaN ] ), NaN, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = { - 'length': 1, - '0': NaN - }; - actual = indexOfSameValue( x, NaN, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports signed zero equality', function test( t ) { - var actual; - var x; - - actual = indexOfSameValue( [ -0.0 ], -0.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( new Float64Array( [ -0.0 ] ), -0.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( new AccessorArray( [ -0.0 ] ), -0.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = { - 'length': 1, - '0': -0.0 - }; - actual = indexOfSameValue( x, -0.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOfSameValue( [ -0.0 ], 0.0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOfSameValue( new Float64Array( [ -0.0 ] ), 0.0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOfSameValue( new AccessorArray( [ -0.0 ] ), 0.0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 1, - '0': -0.0 - }; - actual = indexOfSameValue( x, 0.0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `-1` if provided a starting index which exceeds the maximum array index', function test( t ) { - var actual; - var x; - - actual = indexOfSameValue( [ 1, 2, 3 ], 0, 20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOfSameValue( new Float64Array( [ 1.0, 2.0, 3.0 ] ), 0, 20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOfSameValue( new Int32Array( [ 1, 2, 3 ] ), 0, 20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOfSameValue( new AccessorArray( [ 1, 2, 3 ] ), 0, 20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 0, - '0': 1, - '1': 2, - '2': 3 - }; - actual = indexOfSameValue( x, 0, 20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); diff --git a/base/index-of/README.md b/base/index-of/README.md deleted file mode 100644 index 06e74edfb..000000000 --- a/base/index-of/README.md +++ /dev/null @@ -1,160 +0,0 @@ - - -# indexOf - -> Return the index of the first element which equals a provided search element. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var indexOf = require( '@stdlib/array/base/index-of' ); -``` - -#### indexOf( x, searchElement, fromIndex ) - -Returns the index of the first element which equals a provided search element. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var idx = indexOf( x, 3, 0 ); -// returns 2 -``` - -If the function is unable to find an element which equals a provided search element, the function returns `-1`. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var idx = indexOf( x, 7, 0 ); -// returns -1 -``` - -To begin searching from specific index, provide a non-zero `fromIndex` argument. - -```javascript -var x = [ 1, 1, 2, 1, 2, 3, 3 ]; - -var idx = indexOf( x, 2, 3 ); -// returns 4 -``` - -If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. - -```javascript -var x = [ 1, 1, 2, 1, 2, 3, 3 ]; - -var idx = indexOf( x, 2, -4 ); -// returns 4 -``` - -
- - - - - -
- -## Notes - -- If provided an array-like object having an `indexOf` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.indexOf( searchElement, fromIndex ) - ``` - -- If provided an array-like object without an `indexOf` method, the function performs a linear scan and returns immediately upon finding a match. - -- When searching for a search element, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same. - -
- - - - - -
- -## Examples - - - -```javascript -var indexOf = require( '@stdlib/array/base/index-of' ); - -var x = [ 'foo', 'bar', 'beep', 'boop', 'foo', 'bar' ]; - -var idx = indexOf( x, 'beep', 0 ); -// returns 2 - -idx = indexOf( x, 'bop', 0 ); -// returns -1 - -idx = indexOf( x, 'foo', 1 ); -// returns 4 - -idx = indexOf( x, 'foo', -4 ); -// returns 4 - -idx = indexOf( x, 'foo', 5 ); -// returns -1 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/index-of/benchmark/benchmark.length.js b/base/index-of/benchmark/benchmark.length.js deleted file mode 100644 index e5e57fef2..000000000 --- a/base/index-of/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var indexOf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = indexOf( x, -2, 0 ); - if ( out !== out ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) || out >= 0 ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/index-of/docs/repl.txt b/base/index-of/docs/repl.txt deleted file mode 100644 index 534383286..000000000 --- a/base/index-of/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( x, searchElement, fromIndex ) - Returns the index of the first element which equals a provided search - element. - - If provided an array-like object having an `indexOf` method, the function - defers execution to that method and assumes that the method has the - following signature: - - x.indexOf( searchElement, fromIndex ) - - If provided an array-like object without an `indexOf` method, the function - performs a linear scan and returns immediately upon finding a match. - - If unable to find an element which equals a provided search element, the - function returns -1. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - searchElement: any - Search element. - - fromIndex: integer - Starting index (inclusive). If less than zero, the starting index is - resolved relative to the last array element, with the last array element - corresponding to `fromIndex = -1`. - - Returns - ------- - out: integer - Index or -1. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ], 3, 0 ) - 2 - - See Also - -------- - diff --git a/base/index-of/docs/types/index.d.ts b/base/index-of/docs/types/index.d.ts deleted file mode 100644 index f4b9e4fe6..000000000 --- a/base/index-of/docs/types/index.d.ts +++ /dev/null @@ -1,57 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns the index of the first element which equals a provided search element. -* -* ## Notes -* -* - If unable to find an element which equals a provided search element, the function returns `-1`. -* - If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. -* -* @param x - input array -* @param searchElement - search element -* @param fromIndex - starting index (inclusive) -* @returns index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = indexOf( x, 2, 0 ); -* // returns 1 -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var idx = indexOf( x, 2, 0 ); -* // returns 1 -*/ -declare function indexOf( x: Collection | AccessorArrayLike, searchElement: unknown, fromIndex: number ): number; - - -// EXPORTS // - -export = indexOf; diff --git a/base/index-of/docs/types/test.ts b/base/index-of/docs/types/test.ts deleted file mode 100644 index c96928ae2..000000000 --- a/base/index-of/docs/types/test.ts +++ /dev/null @@ -1,72 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import indexOf = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - indexOf( [ 1, 2, 3 ], 0, 3 ); // $ExpectType number - indexOf( new Float64Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOf( new Float32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOf( new Int32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOf( new Int16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOf( new Int8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOf( new Uint32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOf( new Uint16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOf( new Uint8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOf( new Uint8ClampedArray( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - indexOf( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType number - indexOf( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - indexOf( 5, 0, 3 ); // $ExpectError - indexOf( true, 0, 3 ); // $ExpectError - indexOf( false, 0, 3 ); // $ExpectError - indexOf( null, 0, 3 ); // $ExpectError - indexOf( void 0, 0, 3 ); // $ExpectError - indexOf( {}, 0, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - indexOf( x, 0, '5' ); // $ExpectError - indexOf( x, 0, true ); // $ExpectError - indexOf( x, 0, false ); // $ExpectError - indexOf( x, 0, null ); // $ExpectError - indexOf( x, 0, void 0 ); // $ExpectError - indexOf( x, 0, [] ); // $ExpectError - indexOf( x, 0, {} ); // $ExpectError - indexOf( x, 0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - indexOf(); // $ExpectError - indexOf( [ 1, 2, 3 ] ); // $ExpectError - indexOf( [ 1, 2, 3 ], 0 ); // $ExpectError - indexOf( [ 1, 2, 3 ], 0, 3, false ); // $ExpectError -} diff --git a/base/index-of/examples/index.js b/base/index-of/examples/index.js deleted file mode 100644 index a23cbee5f..000000000 --- a/base/index-of/examples/index.js +++ /dev/null @@ -1,43 +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'; - -var indexOf = require( './../lib' ); - -var x = [ 'foo', 'bar', 'beep', 'boop', 'foo', 'bar' ]; - -var idx = indexOf( x, 'beep', 0 ); -console.log( idx ); -// => 2 - -idx = indexOf( x, 'bop', 0 ); -console.log( idx ); -// => -1 - -idx = indexOf( x, 'foo', 1 ); -console.log( idx ); -// => 4 - -idx = indexOf( x, 'foo', -4 ); -console.log( idx ); -// => 4 - -idx = indexOf( x, 'foo', 5 ); -console.log( idx ); -// => -1 diff --git a/base/index-of/lib/index.js b/base/index-of/lib/index.js deleted file mode 100644 index 6252e06e1..000000000 --- a/base/index-of/lib/index.js +++ /dev/null @@ -1,42 +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'; - -/** -* Return the index of the first element which equals a provided search element. -* -* @module @stdlib/array/base/index-of -* -* @example -* var indexOf = require( '@stdlib/array/base/index-of' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = indexOf( x, 2, 0 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/index-of/lib/main.js b/base/index-of/lib/main.js deleted file mode 100644 index 04662781b..000000000 --- a/base/index-of/lib/main.js +++ /dev/null @@ -1,152 +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 isAccessorArray = require( '@stdlib/assert/is-accessor-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'indexOf' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - -/** -* Returns the index of the first element which equals a provided search element. -* -* @private -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = internal( x, 2, 0 ); -* // returns 1 -*/ -function internal( x, searchElement, fromIndex ) { - var i; - for ( i = fromIndex; i < x.length; i++ ) { - if ( searchElement === x[ i ] ) { - return i; - } - } - return -1; -} - -/** -* Returns the index of the first element which equals a provided search element. -* -* @private -* @param {Object} x - input array object -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var idx = accessors( x, 2, 0 ); -* // returns 1 -*/ -function accessors( x, searchElement, fromIndex ) { - var get; - var i; - - get = resolveGetter( x ); - for ( i = fromIndex; i < x.length; i++ ) { - if ( searchElement === get( x, i ) ) { - return i; - } - } - return -1; -} - - -// MAIN // - -/** -* Returns the index of the first element which equals a provided search element. -* -* ## Notes -* -* - If unable to find an element which equals a provided search element, the function returns `-1`. -* -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {integer} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = indexOf( x, 2, 0 ); -* // returns 1 -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var idx = indexOf( x, 2, 0 ); -* // returns 1 -*/ -function indexOf( x, searchElement, fromIndex ) { - if ( hasMethod( x, 'indexOf' ) ) { - return x.indexOf( searchElement, fromIndex ); - } - if ( fromIndex < 0 ) { - fromIndex += x.length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - if ( isAccessorArray( x ) ) { - return accessors( x, searchElement, fromIndex ); - } - return internal( x, searchElement, fromIndex ); -} - - -// EXPORTS // - -module.exports = indexOf; diff --git a/base/index-of/package.json b/base/index-of/package.json deleted file mode 100644 index 3f7f93b5a..000000000 --- a/base/index-of/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/index-of", - "version": "0.0.0", - "description": "Return the index of the first element which equals a provided search element.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "search", - "find", - "scan", - "locate", - "index" - ] -} diff --git a/base/index-of/test/test.js b/base/index-of/test/test.js deleted file mode 100644 index 0e2a69232..000000000 --- a/base/index-of/test/test.js +++ /dev/null @@ -1,340 +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 AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var indexOf = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof indexOf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 2, 2, 3, 3 ]; - - actual = indexOf( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOf( x, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOf( x, 3, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOf( x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOf( x, 2, 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOf( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOf( x, 1, -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOf( x, 3, -10 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOf( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOf( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOf( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (float64)', function test( t ) { - var actual; - var x; - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - - actual = indexOf( x, 1.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOf( x, 2.0, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOf( x, 3.0, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOf( x, 1.0, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOf( x, 2.0, 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOf( x, 3.0, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOf( x, 1.0, -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOf( x, 3.0, -10 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOf( x, 1.0, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOf( x, 2.0, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOf( x, 3.0, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (int32)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 1, 1, 2, 2, 3, 3 ] ); - - actual = indexOf( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOf( x, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOf( x, 3, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOf( x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOf( x, 2, 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOf( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOf( x, 1, -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOf( x, 3, -10 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOf( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOf( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOf( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (accessors)', function test( t ) { - var actual; - var x; - - x = new AccessorArray( [ 1, 1, 2, 2, 3, 3 ] ); - - actual = indexOf( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOf( x, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOf( x, 3, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOf( x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOf( x, 2, 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOf( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOf( x, 1, -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOf( x, 3, -10 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOf( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOf( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOf( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the first index of an element which equals a provided search element (array-like)', function test( t ) { - var actual; - var x; - - x = { - 'length': 6, - '0': 1, - '1': 1, - '2': 2, - '3': 2, - '4': 3, - '5': 3 - }; - - actual = indexOf( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOf( x, 2, 0 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = indexOf( x, 3, 0 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - // Nonnegative starting index... - actual = indexOf( x, 1, 1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOf( x, 2, 3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOf( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = indexOf( x, 1, -10 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = indexOf( x, 3, -10 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = indexOf( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = indexOf( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = indexOf( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `-1` if provided an empty array', function test( t ) { - var actual; - var x; - - actual = indexOf( [], 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOf( new Float64Array( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOf( new Int32Array( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOf( new AccessorArray( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 0 - }; - actual = indexOf( x, 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { - var actual; - var x; - - actual = indexOf( [ NaN ], NaN, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOf( new Float64Array( [ NaN ] ), NaN, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOf( new AccessorArray( [ NaN ] ), NaN, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 1, - '0': NaN - }; - actual = indexOf( x, NaN, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `-1` if provided a starting index which exceeds the maximum array index', function test( t ) { - var actual; - var x; - - actual = indexOf( [ 1, 2, 3 ], 0, 20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOf( new Float64Array( [ 1.0, 2.0, 3.0 ] ), 0, 20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOf( new Int32Array( [ 1, 2, 3 ] ), 0, 20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = indexOf( new AccessorArray( [ 1, 2, 3 ] ), 0, 20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 0, - '0': 1, - '1': 2, - '2': 3 - }; - actual = indexOf( x, 0, 20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); diff --git a/base/indices-complement/README.md b/base/indices-complement/README.md deleted file mode 100644 index 4707b4ed3..000000000 --- a/base/indices-complement/README.md +++ /dev/null @@ -1,126 +0,0 @@ - - -# indicesComplement - -> Return the complement of a list of array indices. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var indicesComplement = require( '@stdlib/array/base/indices-complement' ); -``` - -#### indicesComplement( N, indices ) - -Returns the complement of a list of array indices. - -```javascript -var idx = indicesComplement( 5, [ 1, 2 ] ); -// returns [ 0, 3, 4 ] -``` - -The function accepts the following arguments: - -- **N**: array length. -- **indices**: list of indices from which to derive the complement. - -
- - - - - -
- -## Notes - -- The function **always** returns a new "generic" array. - -
- - - - - -
- -## Examples - - - -```javascript -var indicesComplement = require( '@stdlib/array/base/indices-complement' ); - -var out = indicesComplement( 5, [ 1, 3, 4 ] ); -// returns [ 0, 2 ] - -out = indicesComplement( 5, [ 0, 1 ] ); -// returns [ 2, 3, 4 ] - -out = indicesComplement( 5, [ 0 ] ); -// returns [ 1, 2, 3, 4 ] - -out = indicesComplement( 5, [] ); -// returns [ 0, 1, 2, 3, 4 ] - -out = indicesComplement( 5, [ 0, 1, 2, 3, 4 ] ); -// returns [] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/indices-complement/benchmark/benchmark.js b/base/indices-complement/benchmark/benchmark.js deleted file mode 100644 index 621c8fa4c..000000000 --- a/base/indices-complement/benchmark/benchmark.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isNonNegativeIntegerArray = require( '@stdlib/assert/is-nonnegative-integer-array' ).primitives; -var pkg = require( './../package.json' ).name; -var indicesComplement = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - [ 0, 1 ], - [ 0, 1, 2, 3 ], - [ 0 ], - [], - [ 3, 4 ], - [ 1, 3, 4 ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = indicesComplement( 5, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isNonNegativeIntegerArray( out ) ) { - b.fail( 'should return an array of nonnegative integers' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/indices-complement/docs/repl.txt b/base/indices-complement/docs/repl.txt deleted file mode 100644 index 473054b50..000000000 --- a/base/indices-complement/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( N, indices ) - Returns the complement of a list of array indices. - - Parameters - ---------- - N: integer - Array length. - - indices: Collection - List of indices from which to derive the complement. - - Returns - ------- - out: Array - Indices complement. - - Examples - -------- - > var idx = {{alias}}( 5, [ 1, 3 ] ) - [ 0, 2, 4 ] - - See Also - -------- - diff --git a/base/indices-complement/docs/types/index.d.ts b/base/indices-complement/docs/types/index.d.ts deleted file mode 100644 index 72facd9cb..000000000 --- a/base/indices-complement/docs/types/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Returns the complement of a list of array indices. -* -* @param N - array length -* @param indices - list of indices -* @returns indices complement -* -* @example -* var idx = indicesComplement( 5, [ 1, 3 ] ); -* // returns [ 0, 2, 4 ] -*/ -declare function indicesComplement( N: number, indices: Collection ): Array; - - -// EXPORTS // - -export = indicesComplement; diff --git a/base/indices-complement/docs/types/test.ts b/base/indices-complement/docs/types/test.ts deleted file mode 100644 index 83338158b..000000000 --- a/base/indices-complement/docs/types/test.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import indicesComplement = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - indicesComplement( 5, [ 0, 1 ] ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided invalid values... -{ - indicesComplement( true, [ 0, 1 ] ); // $ExpectError - indicesComplement( false, [ 0, 1 ] ); // $ExpectError - indicesComplement( '5', [ 0, 1 ] ); // $ExpectError - indicesComplement( [ '5' ], [ 0, 1 ] ); // $ExpectError - indicesComplement( {}, [ 0, 1 ] ); // $ExpectError - indicesComplement( ( x: number ): number => x, [ 0, 1 ] ); // $ExpectError - - indicesComplement( 5, true ); // $ExpectError - indicesComplement( 5, false ); // $ExpectError - indicesComplement( 5, '5' ); // $ExpectError - indicesComplement( 5, 5 ); // $ExpectError - indicesComplement( 5, {} ); // $ExpectError - indicesComplement( 5, ( x: number ): number => x ); // $ExpectError - - indicesComplement( [], true ); // $ExpectError - indicesComplement( {}, false ); // $ExpectError - indicesComplement( false, '5' ); // $ExpectError - indicesComplement( {}, [] ); // $ExpectError - indicesComplement( '5', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - indicesComplement(); // $ExpectError - indicesComplement( 5 ); // $ExpectError -} diff --git a/base/indices-complement/examples/index.js b/base/indices-complement/examples/index.js deleted file mode 100644 index fc6c316f0..000000000 --- a/base/indices-complement/examples/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var indicesComplement = require( './../lib' ); - -var out = indicesComplement( 5, [ 1, 3, 4 ] ); -console.log( out ); -// => [ 0, 2 ] - -out = indicesComplement( 5, [ 0, 1 ] ); -console.log( out ); -// => [ 2, 3, 4 ] - -out = indicesComplement( 5, [ 0 ] ); -console.log( out ); -// => [ 1, 2, 3, 4 ] - -out = indicesComplement( 5, [] ); -console.log( out ); -// => [ 0, 1, 2, 3, 4 ] - -out = indicesComplement( 5, [ 0, 1, 2, 3, 4 ] ); -console.log( out ); -// => [] diff --git a/base/indices-complement/lib/index.js b/base/indices-complement/lib/index.js deleted file mode 100644 index 41e1087ce..000000000 --- a/base/indices-complement/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return the complement of a list of array indices. -* -* @module @stdlib/array/base/indices-complement -* -* @example -* var indicesComplement = require( '@stdlib/array/base/indices-complement' ); -* -* var idx = indicesComplement( 5, [ 1, 2 ] ); -* // returns [ 0, 3, 4 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/indices-complement/lib/main.js b/base/indices-complement/lib/main.js deleted file mode 100644 index b8ad6da91..000000000 --- a/base/indices-complement/lib/main.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns the complement of a list of array indices. -* -* @param {NonNegativeInteger} N - array length -* @param {NonNegativeIntegerArray} indices - list of indices -* @returns {NonNegativeIntegerArray} indices complement -* -* @example -* var idx = indicesComplement( 5, [ 1, 2 ] ); -* // returns [ 0, 3, 4 ] -*/ -function indicesComplement( N, indices ) { - var hash; - var out; - var i; - - hash = {}; - for ( i = 0; i < indices.length; i++ ) { - hash[ indices[ i ] ] = true; - } - out = []; - for ( i = 0; i < N; i++ ) { - if ( hash[ i ] === void 0 ) { - out.push( i ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = indicesComplement; diff --git a/base/indices-complement/package.json b/base/indices-complement/package.json deleted file mode 100644 index cae90e96d..000000000 --- a/base/indices-complement/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/indices-complement", - "version": "0.0.0", - "description": "Return the complement of a list of array indices.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "indices", - "index", - "idx", - "ind", - "complement", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/base/indices-complement/test/test.js b/base/indices-complement/test/test.js deleted file mode 100644 index 5ec88a8cc..000000000 --- a/base/indices-complement/test/test.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert/is-array' ); -var indicesComplement = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof indicesComplement, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the complement of a list of indices', function test( t ) { - var expected; - var actual; - var idx; - - idx = [ 0, 2, 3 ]; - expected = [ 1, 4 ]; - - actual = indicesComplement( 5, idx ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, idx, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = [ 0, 2, 3 ]; - expected = [ 1, 4, 5, 6, 7, 8, 9 ]; - - actual = indicesComplement( 10, idx ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, idx, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = [ 0, 1, 2, 3, 4 ]; - expected = []; - - actual = indicesComplement( 5, idx ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, idx, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = []; - expected = [ 0, 1, 2, 3, 4 ]; - - actual = indicesComplement( 5, idx ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, idx, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/join/README.md b/base/join/README.md deleted file mode 100644 index 4396cac0d..000000000 --- a/base/join/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# join - -> Return a string created by joining array elements using a specified separator. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var join = require( '@stdlib/array/base/join' ); -``` - -#### join( x, separator ) - -Returns a string created by joining array elements using a specified separator. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var out = join( x, ',' ); -// returns '1,2,3,4,5,6' -``` - -
- - - - - -
- -## Notes - -- If provided an array-like object having a `join` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.join( separator ) - ``` - -- If provided an array-like object without a `join` method, the function manually constructs the output string. - -- If an array element is either `null` or `undefined`, the function will serialize the element as an empty string. - -
- - - - - -
- -## Examples - - - -```javascript -var Complex128Array = require( '@stdlib/array/complex128' ); -var Complex64Array = require( '@stdlib/array/complex64' ); -var AccessorArray = require( '@stdlib/array/base/accessor' ); -var Float64Array = require( '@stdlib/array/float64' ); -var join = require( '@stdlib/array/base/join' ); - -var x = [ 0, 1, 2, 3, 4, 5 ]; -var s = join( x, ',' ); -// returns '0,1,2,3,4,5' - -x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -s = join( x, ',' ); -// returns '0,1,2,3,4,5' - -s = join( x, '-' ); -// returns '0-1-2-3-4-5' - -x = new AccessorArray( [ 1, 2, 3, 4 ] ); -s = join( x, ',' ); -// returns '1,2,3,4' - -x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -s = join( x, ',' ); -// returns '1 + 2i,3 + 4i,5 + 6i' - -x = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); -s = join( x, ',' ); -// returns '1 - 1i,2 - 2i' -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/join/benchmark/benchmark.length.js b/base/join/benchmark/benchmark.length.js deleted file mode 100644 index 51b886121..000000000 --- a/base/join/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var join = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var s; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = join( x, ',' ); - if ( !isString( s ) ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( s ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/join/docs/repl.txt b/base/join/docs/repl.txt deleted file mode 100644 index 2ce6f92f8..000000000 --- a/base/join/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( x, separator ) - Return a string created by joining array elements using a specified - separator. - - If provided an array-like object having a `join` method, the function defers - execution to that method and assumes that the method has the following - signature: - - x.join( separator ) - - If provided an array-like object without a `join` method, the function - manually constructs the output string. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - separator: string - Separator. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ], ',' ) - '1,2,3,4' - - See Also - -------- - diff --git a/base/join/docs/types/index.d.ts b/base/join/docs/types/index.d.ts deleted file mode 100644 index fc0675df9..000000000 --- a/base/join/docs/types/index.d.ts +++ /dev/null @@ -1,65 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a string created by joining array elements using a specified separator. -* -* @param x - input array -* @param separator - separator element -* @returns string -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = join( x, ',' ); -* // returns '1,2,3' -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var out = join( x, '-' ); -* // returns '1-2-3-4-5-6' -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = join( x, ',' ); -* // returns '1,2,3' -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* var out = join( x, ',' ); -* // returns '1 + 2i,3 + 4i,5 + 6i' -*/ -declare function join( x: Collection | AccessorArrayLike, separator: string ): string; - - -// EXPORTS // - -export = join; diff --git a/base/join/docs/types/test.ts b/base/join/docs/types/test.ts deleted file mode 100644 index 9d4fc36ac..000000000 --- a/base/join/docs/types/test.ts +++ /dev/null @@ -1,69 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import join = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - join( [ 1, 2, 3 ], ',' ); // $ExpectType string - join( new Float64Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string - join( new Float32Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string - join( new Int32Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string - join( new Int16Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string - join( new Int8Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string - join( new Uint32Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string - join( new Uint16Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string - join( new Uint8Array( [ 1, 2, 3 ] ), ',' ); // $ExpectType string - join( new Uint8ClampedArray( [ 1, 2, 3 ] ), ',' ); // $ExpectType string - join( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), ',' ); // $ExpectType string - join( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), ',' ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - join( 5, ',' ); // $ExpectError - join( true, ',' ); // $ExpectError - join( false, ',' ); // $ExpectError - join( null, ',' ); // $ExpectError - join( void 0, ',' ); // $ExpectError - join( {}, ',' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a string... -{ - const x = [ 1, 2, 3 ]; - - join( x, 5 ); // $ExpectError - join( x, true ); // $ExpectError - join( x, false ); // $ExpectError - join( x, null ); // $ExpectError - join( x, {} ); // $ExpectError - join( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - join(); // $ExpectError - join( [ 1, 2, 3 ] ); // $ExpectError - join( [ 1, 2, 3 ], ',', {} ); // $ExpectError -} diff --git a/base/join/examples/index.js b/base/join/examples/index.js deleted file mode 100644 index 9322dd672..000000000 --- a/base/join/examples/index.js +++ /dev/null @@ -1,54 +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. -*/ - -'use strict'; - -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var Float64Array = require( './../../../float64' ); -var AccessorArray = require( './../../../base/accessor' ); -var join = require( './../lib' ); - -var x = [ 0, 1, 2, 3, 4, 5 ]; -var s = join( x, ',' ); -console.log( s ); -// => '0,1,2,3,4,5' - -x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -s = join( x, ',' ); -console.log( s ); -// => '0,1,2,3,4,5' - -s = join( x, '-' ); -console.log( s ); -// => '0-1-2-3-4-5' - -x = new AccessorArray( [ 1, 2, 3, 4 ] ); -s = join( x, ',' ); -console.log( s ); -// => '1,2,3,4' - -x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -s = join( x, ',' ); -console.log( s ); -// => '1 + 2i,3 + 4i,5 + 6i' - -x = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); -s = join( x, ',' ); -console.log( s ); -// => '1 - 1i,2 - 2i' diff --git a/base/join/lib/index.js b/base/join/lib/index.js deleted file mode 100644 index 7480632b5..000000000 --- a/base/join/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Return a string created by joining array elements using a specified separator. -* -* @module @stdlib/array/base/join -* -* @example -* var join = require( '@stdlib/array/base/join' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = join( x, ',' ); -* // returns '1,2,3,4' -*/ - - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/join/lib/main.js b/base/join/lib/main.js deleted file mode 100644 index bf5633b96..000000000 --- a/base/join/lib/main.js +++ /dev/null @@ -1,162 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); -var isUndefinedOrNull = require( '@stdlib/assert/is-undefined-or-null' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'join' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - -/** -* Returns a string created by joining elements in an accessor array using a specified separator. -* -* @private -* @param {Object} x - input array object -* @param {integer} separator - separator -* @returns {string} output string -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) ); -* -* var out = accessors( x, ',' ); -* // returns '1,2,3,4' -*/ -function accessors( x, separator ) { - var data; - var out; - var get; - var N; - var v; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - N = data.length - 1; - out = ''; - for ( i = 0; i <= N; i++ ) { - v = get( data, i ); - if ( !isUndefinedOrNull( v ) ) { - out += String( v ); - } - if ( i < N ) { - out += separator; - } - } - return out; -} - -/** -* Returns a string created by manually joining array elements using a specified separator. -* -* @private -* @param {Object} x - input array object -* @param {integer} separator - separator -* @returns {string} output string -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = indexed( x, ',' ); -* // returns '1,2,3,4' -*/ -function indexed( x, separator ) { - var out; - var N; - var v; - var i; - - N = x.length - 1; - out = ''; - for ( i = 0; i <= N; i++ ) { - v = x[ i ]; - if ( !isUndefinedOrNull( v ) ) { - out += String( v ); - } - if ( i < N ) { - out += separator; - } - } - return out; -} - - -// MAIN // - -/** -* Returns a string created by joining array elements using a specified separator. -* -* @param {Collection} x - input array -* @param {integer} separator - separator -* @returns {string} output string -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = join( x, ',' ); -* // returns '1,2,3,4' -* -* @example -* var x = [ 1, 2, 3, null, undefined, 4 ]; -* -* var out = join( x, '-' ); -* // returns '1-2-3---4' -*/ -function join( x, separator ) { - var obj; - if ( hasMethod( x, 'join' ) ) { - return x.join( separator ); - } - obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, separator ); - } - return indexed( x, separator ); -} - - -// EXPORTS // - -module.exports = join; diff --git a/base/join/package.json b/base/join/package.json deleted file mode 100644 index 829703a66..000000000 --- a/base/join/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/join", - "version": "0.0.0", - "description": "Return a string created by joining array elements using a specified separator.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "join", - "concat", - "concatenate", - "serialize", - "tostring" - ] -} diff --git a/base/join/test/test.js b/base/join/test/test.js deleted file mode 100644 index 06735030c..000000000 --- a/base/join/test/test.js +++ /dev/null @@ -1,313 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Complex128Array = require( './../../../complex128' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var join = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof join, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function joins an array-like object (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3, null ]; - - expected = '1,2,3,'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - expected = '1-2-3-'; - actual = join( x, '-' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = [ null ]; - - expected = ''; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = []; - - expected = ''; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = [ 'hello', '', void 0, null, NaN, void 0 ]; - - expected = 'hello,,,,NaN,'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = [ null, void 0, null, void 0 ]; - - expected = ',,,'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = [ null, 1, 2, 'testString', void 0 ]; - - expected = ',1,2,testString,'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = [ null, 1, 2, NaN, void 0 ]; - - expected = ',1,2,NaN,'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = [ 1 ]; - - expected = '1'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function joins an array-like object (float64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - - expected = '1,2,3'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0 ] ); - - expected = '1'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - - expected = ''; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function joins an array-like object (int32)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - - expected = '1,2,3'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [] ); - - expected = ''; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1 ] ); - - expected = '1'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function joins an array-like object (complex128)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - - expected = '1 - 1i,2 - 2i'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, -1.0 ] ); - - expected = '1 - 1i'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [] ); - - expected = ''; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function joins an array-like object (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = new AccessorArray( [ 1, 2, 3, 4 ] ); - - expected = '1,2,3,4'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 1, 2, 3, null, void 0, 4 ] ); - - expected = '1,2,3,,,4'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 1 ] ); - - expected = '1'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ null, void 0, NaN ] ); - - expected = ',,NaN'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [] ); - - expected = ''; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function joins an array-like object (array-like)', function test( t ) { - var expected; - var actual; - var x; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - - expected = '1,2,3,4'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 6, - '0': 1, - '1': 2, - '2': 3, - '3': null, - '4': void 0, - '5': 4 - }; - - expected = '1,2,3,,,4'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 1, - '0': 1 - }; - - expected = '1'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 1, - '0': null - }; - - expected = ''; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 3, - '0': null, - '1': void 0, - '2': NaN - }; - - expected = ',,NaN'; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 0 - }; - - expected = ''; - actual = join( x, ',' ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/last-index-of-same-value/README.md b/base/last-index-of-same-value/README.md deleted file mode 100644 index 8e9f47d4e..000000000 --- a/base/last-index-of-same-value/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# lastIndexOfSameValue - -> Return the index of the last element which equals a provided search element according to the [SameValue Algorithm][@stdlib/assert/is-same-value]. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var lastIndexOfSameValue = require( '@stdlib/array/base/last-index-of-same-value' ); -``` - -#### lastIndexOfSameValue( x, searchElement, fromIndex ) - -Returns the index of the last element which equals a provided search element according to the [SameValue Algorithm][@stdlib/assert/is-same-value]. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var idx = lastIndexOfSameValue( x, 3, 5 ); -// returns 2 -``` - -If the function is unable to find an element which equals a provided search element, the function returns `-1`. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var idx = lastIndexOfSameValue( x, 7, 5 ); -// returns -1 -``` - -To begin searching from a specific index, provide a corresponding `fromIndex` argument. - -```javascript -var x = [ 1, 1, 2, 1, 2, 3, 3 ]; - -var idx = lastIndexOfSameValue( x, 2, 3 ); -// returns 2 -``` - -If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. - -```javascript -var x = [ 1, 1, 2, 1, 2, 3, 3 ]; - -var idx = lastIndexOfSameValue( x, 2, -4 ); -// returns 2 -``` - -
- - - - - -
- -## Notes - -- The function scans an input array from the starting index to the beginning of the array (i.e., backward). -- When searching for a search element, the function checks for equality using the [SameValue Algorithm][@stdlib/assert/is-same-value] as specified in ECMAScript 5. As a consequence, `NaN` values are considered equal, and `-0` and `+0` are considered distinct. - -
- - - - - -
- -## Examples - - - -```javascript -var lastIndexOfSameValue = require( '@stdlib/array/base/last-index-of-same-value' ); - -var x = [ 'foo', 'bar', 'beep', 'boop', 'foo', 'bar' ]; - -var idx = lastIndexOfSameValue( x, 'beep', 5 ); -// returns 2 - -idx = lastIndexOfSameValue( x, 'bop', 5 ); -// returns -1 - -idx = lastIndexOfSameValue( x, 'foo', 5 ); -// returns 4 - -idx = lastIndexOfSameValue( x, 'foo', -3 ); -// returns 0 - -idx = lastIndexOfSameValue( x, 'foo', -50 ); -// returns -1 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/last-index-of-same-value/benchmark/benchmark.length.js b/base/last-index-of-same-value/benchmark/benchmark.length.js deleted file mode 100644 index 172820af6..000000000 --- a/base/last-index-of-same-value/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var lastIndexOfSameValue = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = lastIndexOfSameValue( x, -2, len-1 ); - if ( out !== out ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) || out >= 0 ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/last-index-of-same-value/docs/repl.txt b/base/last-index-of-same-value/docs/repl.txt deleted file mode 100644 index 43e510a33..000000000 --- a/base/last-index-of-same-value/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( x, searchElement, fromIndex ) - Returns the index of the last element which equals a provided search - element according to the same value algorithm. - - The function performs a linear scan and returns immediately upon finding a - match. - - If unable to find an element which equals a provided search element, the - function returns -1. - - The function scans an input array from the starting index to the beginning - of the array (i.e., backward). - - The function treats `-0` and `+0` as distinct and `NaNs` as the same. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - searchElement: any - Search element. - - fromIndex: integer - Starting index (inclusive). If less than zero, the starting index is - resolved relative to the last array element, with the last array element - corresponding to `fromIndex = -1`. - - Returns - ------- - out: integer - Index or -1. - - Examples - -------- - > var out = {{alias}}( [ 1, 3, 3, 4 ], 3, 3 ) - 2 - - See Also - -------- - diff --git a/base/last-index-of-same-value/docs/types/index.d.ts b/base/last-index-of-same-value/docs/types/index.d.ts deleted file mode 100644 index 6c08c11f1..000000000 --- a/base/last-index-of-same-value/docs/types/index.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns the index of the last element which equals a provided search element according to the same value algorithm. -* -* ## Notes -* -* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. -* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. -* - The function scans an input array from the starting index to the beginning of the array (i.e., backward). -* - If unable to find an element which equals a provided search element, the function returns `-1`. -* - If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. -* -* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 -* -* @param x - input array -* @param searchElement - search element -* @param fromIndex - starting index (inclusive) -* @returns index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = lastIndexOfSameValue( x, 2, 3 ); -* // returns 1 -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var idx = lastIndexOfSameValue( x, 2, 3 ); -* // returns 1 -*/ -declare function lastIndexOfSameValue( x: Collection | AccessorArrayLike, searchElement: unknown, fromIndex: number ): number; - - -// EXPORTS // - -export = lastIndexOfSameValue; diff --git a/base/last-index-of-same-value/docs/types/test.ts b/base/last-index-of-same-value/docs/types/test.ts deleted file mode 100644 index 4155ed982..000000000 --- a/base/last-index-of-same-value/docs/types/test.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import lastIndexOfSameValue = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - lastIndexOfSameValue( [ 1, 2, 3 ], 0, 3 ); // $ExpectType number - lastIndexOfSameValue( new Float64Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOfSameValue( new Float32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOfSameValue( new Int32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOfSameValue( new Int16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOfSameValue( new Int8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOfSameValue( new Uint32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOfSameValue( new Uint16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOfSameValue( new Uint8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOfSameValue( new Uint8ClampedArray( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOfSameValue( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType number - lastIndexOfSameValue( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - lastIndexOfSameValue( 5, 0, 3 ); // $ExpectError - lastIndexOfSameValue( true, 0, 3 ); // $ExpectError - lastIndexOfSameValue( false, 0, 3 ); // $ExpectError - lastIndexOfSameValue( null, 0, 3 ); // $ExpectError - lastIndexOfSameValue( void 0, 0, 3 ); // $ExpectError - lastIndexOfSameValue( {}, 0, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - lastIndexOfSameValue( x, 0, '5' ); // $ExpectError - lastIndexOfSameValue( x, 0, true ); // $ExpectError - lastIndexOfSameValue( x, 0, false ); // $ExpectError - lastIndexOfSameValue( x, 0, null ); // $ExpectError - lastIndexOfSameValue( x, 0, void 0 ); // $ExpectError - lastIndexOfSameValue( x, 0, [] ); // $ExpectError - lastIndexOfSameValue( x, 0, {} ); // $ExpectError - lastIndexOfSameValue( x, 0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - lastIndexOfSameValue(); // $ExpectError - lastIndexOfSameValue( [ 1, 2, 3 ] ); // $ExpectError - lastIndexOfSameValue( [ 1, 2, 3 ], 0 ); // $ExpectError - lastIndexOfSameValue( [ 1, 2, 3 ], 0, 3, false ); // $ExpectError -} diff --git a/base/last-index-of-same-value/examples/index.js b/base/last-index-of-same-value/examples/index.js deleted file mode 100644 index 19a359350..000000000 --- a/base/last-index-of-same-value/examples/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var lastIndexOfSameValue = require( './../lib' ); - -var x = [ 'foo', 'bar', 'beep', 'boop', 'foo', 'bar' ]; - -var idx = lastIndexOfSameValue( x, 'beep', 5 ); -console.log( idx ); -// => 2 - -idx = lastIndexOfSameValue( x, 'bop', 5 ); -console.log( idx ); -// => -1 - -idx = lastIndexOfSameValue( x, 'foo', 5 ); -console.log( idx ); -// => 4 - -idx = lastIndexOfSameValue( x, 'foo', -3 ); -console.log( idx ); -// => 0 - -idx = lastIndexOfSameValue( x, 'foo', -50 ); -console.log( idx ); -// => -1 diff --git a/base/last-index-of-same-value/lib/index.js b/base/last-index-of-same-value/lib/index.js deleted file mode 100644 index 249e3410c..000000000 --- a/base/last-index-of-same-value/lib/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return the index of the last element which equals a provided search element according to the same value algorithm. -* -* @module @stdlib/array/base/last-index-of-same-value -* -* @example -* var lastIndexOfSameValue = require( '@stdlib/array/base/last-index-of-same-value' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = lastIndexOfSameValue( x, 2, 3 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/last-index-of-same-value/lib/main.js b/base/last-index-of-same-value/lib/main.js deleted file mode 100644 index d21046479..000000000 --- a/base/last-index-of-same-value/lib/main.js +++ /dev/null @@ -1,221 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/assert/is-accessor-array' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var isComplexTypedArray = require( './../../../base/assert/is-complex-typed-array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var isSameValue = require( '@stdlib/assert/is-same-value' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - - -// FUNCTIONS // - -/** -* Returns the index of the last element which equals a provided search element according to the same value algorithm. -* -* @private -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = indexed( x, 2, 3 ); -* // returns 1 -*/ -function indexed( x, searchElement, fromIndex ) { - var i; - for ( i = fromIndex; i >= 0; i-- ) { - if ( isSameValue( searchElement, x[ i ] ) ) { - return i; - } - } - return -1; -} - -/** -* Returns the index of the last element which equals a provided search element according to the same value algorithm. -* -* @private -* @param {Object} x - input array object -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var idx = accessors( x, 2, 3 ); -* // returns 1 -*/ -function accessors( x, searchElement, fromIndex ) { - var get; - var i; - - get = resolveGetter( x ); - for ( i = fromIndex; i >= 0; i-- ) { - if ( isSameValue( searchElement, get( x, i ) ) ) { - return i; - } - } - return -1; -} - -/** -* Returns the index of the last element which equals a provided search element according to the same value algorithm. -* -* @private -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] ); -* -* var idx = complex( x, new Complex128( 3.0, 4.0 ), 3 ); -* // returns 2 -*/ -function complex( x, searchElement, fromIndex ) { - var view; - var re; - var im; - var i; - if ( !isComplexLike( searchElement ) ) { - return -1; - } - view = reinterpret( x, 0 ); - re = real( searchElement ); - im = imag( searchElement ); - for ( i = fromIndex*2; i >= 0; i -= 2 ) { - if ( isSameValue( view[ i ], re ) && isSameValue( view[ i+1 ], im ) ) { - return i / 2; - } - } - return -1; -} - -/** -* Returns the index of the last element which equals a provided search element according to the same value algorithm. -* -* @private -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var x = new BooleanArray( [ true, false, true, false, true ] ); -* -* var idx = boolean( x, true, 3 ); -* // returns 2 -*/ -function boolean( x, searchElement, fromIndex ) { - var view; - var v; - var i; - if ( !isBoolean( searchElement ) ) { - return -1; - } - view = reinterpretBoolean( x, 0 ); - v = ( searchElement ) ? 1 : 0; - for ( i = fromIndex; i >= 0; i-- ) { - if ( view[ i ] === v ) { - return i; - } - } - return -1; -} - - -// MAIN // - -/** -* Returns the index of the last element which equals a provided search element according to the same value algorithm. -* -* ## Notes -* -* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5. -* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same. -* - If unable to find an element which equals a provided search element, the function returns `-1`. -* -* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12 -* -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {integer} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = lastIndexOfSameValue( x, 2, 3 ); -* // returns 1 -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var idx = lastIndexOfSameValue( x, 2, 3 ); -* // returns 1 -*/ -function lastIndexOfSameValue( x, searchElement, fromIndex ) { - if ( fromIndex < 0 ) { - fromIndex += x.length; - if ( fromIndex < 0 ) { - return -1; - } - } else if ( fromIndex > x.length ) { - fromIndex = x.length - 1; - } - if ( isAccessorArray( x ) ) { - if ( isComplexTypedArray( x ) ) { - return complex( x, searchElement, fromIndex ); - } - if ( isBooleanArray( x ) ) { - return boolean( x, searchElement, fromIndex ); - } - return accessors( x, searchElement, fromIndex ); - } - return indexed( x, searchElement, fromIndex ); -} - - -// EXPORTS // - -module.exports = lastIndexOfSameValue; diff --git a/base/last-index-of-same-value/package.json b/base/last-index-of-same-value/package.json deleted file mode 100644 index 5d6e7769c..000000000 --- a/base/last-index-of-same-value/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/last-index-of-same-value", - "version": "0.0.0", - "description": "Return the index of the last element which equals a provided search element according to the same value algorithm.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "search", - "find", - "scan", - "locate", - "index", - "same" - ] -} diff --git a/base/last-index-of-same-value/test/test.js b/base/last-index-of-same-value/test/test.js deleted file mode 100644 index 03816289d..000000000 --- a/base/last-index-of-same-value/test/test.js +++ /dev/null @@ -1,493 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Complex128Array = require( './../../../complex128' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var lastIndexOfSameValue = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof lastIndexOfSameValue, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 2, 2, 3, 3 ]; - - actual = lastIndexOfSameValue( x, 1, 5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, 5 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOfSameValue( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 100 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOfSameValue( x, 1, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, -2 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (float64)', function test( t ) { - var actual; - var x; - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - - actual = lastIndexOfSameValue( x, 1.0, 5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2.0, 5 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3.0, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOfSameValue( x, 1.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2.0, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3.0, 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3.0, 100 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOfSameValue( x, 1.0, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3.0, -2 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 1.0, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2.0, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3.0, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (complex128)', function test( t ) { - var actual; - var x; - - x = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0 ] ); // eslint-disable-line max-len - - actual = lastIndexOfSameValue( x, new Complex128( 1.0, 1.0 ), 5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, new Complex128( 2.0, 2.0 ), 5 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, new Complex128( 3.0, 3.0 ), 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, new Complex128( 2.0, 2.0 ), 1 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOfSameValue( x, new Complex128( 1.0, 1.0 ), 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, new Complex128( 2.0, 2.0 ), 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, new Complex128( 3.0, 3.0 ), 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, new Complex128( 3.0, 3.0 ), 100 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOfSameValue( x, new Complex128( 1.0, 1.0 ), -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, new Complex128( 3.0, 3.0 ), -2 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, new Complex128( 1.0, 1.0 ), -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, new Complex128( 2.0, 2.0 ), -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, new Complex128( 3.0, 3.0 ), -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Non-complex values: - actual = lastIndexOfSameValue( x, 1.0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (bool)', function test( t ) { - var actual; - var x; - - x = new BooleanArray( [ true, true, false, false, true, true ] ); - - actual = lastIndexOfSameValue( x, true, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, false, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOfSameValue( x, true, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, false, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, true, 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOfSameValue( x, true, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, true, -3 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, false, -5 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, false, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - // Non-boolean values: - actual = lastIndexOfSameValue( x, 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (int32)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 1, 1, 2, 2, 3, 3 ] ); - - actual = lastIndexOfSameValue( x, 1, 5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, 5 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOfSameValue( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 100 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOfSameValue( x, 1, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, -2 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (accessors)', function test( t ) { - var actual; - var x; - - x = new AccessorArray( [ 1, 1, 2, 2, 3, 3 ] ); - - actual = lastIndexOfSameValue( x, 1, 5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, 5 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOfSameValue( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 100 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOfSameValue( x, 1, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, -2 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (array-like)', function test( t ) { - var actual; - var x; - - x = { - 'length': 6, - '0': 1, - '1': 1, - '2': 2, - '3': 2, - '4': 3, - '5': 3 - }; - - actual = lastIndexOfSameValue( x, 1, 5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, 5 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOfSameValue( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, 100 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOfSameValue( x, 1, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, -2 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOfSameValue( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `-1` if provided an empty array', function test( t ) { - var actual; - var x; - - actual = lastIndexOfSameValue( [], 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOfSameValue( new Float64Array( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOfSameValue( new Int32Array( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOfSameValue( new AccessorArray( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 0 - }; - actual = lastIndexOfSameValue( x, 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports NaN equality', function test( t ) { - var actual; - var x; - - actual = lastIndexOfSameValue( [ NaN ], NaN, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( new Float64Array( [ NaN ] ), NaN, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( new AccessorArray( [ NaN ] ), NaN, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = { - 'length': 1, - '0': NaN - }; - actual = lastIndexOfSameValue( x, NaN, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports signed zero equality', function test( t ) { - var actual; - var x; - - actual = lastIndexOfSameValue( [ -0.0 ], -0.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( new Float64Array( [ -0.0 ] ), -0.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( new AccessorArray( [ -0.0 ] ), -0.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - x = { - 'length': 1, - '0': -0.0 - }; - actual = lastIndexOfSameValue( x, -0.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOfSameValue( [ -0.0 ], 0.0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOfSameValue( new Float64Array( [ -0.0 ] ), 0.0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOfSameValue( new AccessorArray( [ -0.0 ] ), 0.0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 1, - '0': -0.0 - }; - actual = lastIndexOfSameValue( x, 0.0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `-1` if provided a starting index which exceeds the minimum array index', function test( t ) { - var actual; - var x; - - actual = lastIndexOfSameValue( [ 1, 2, 3 ], 0, -20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOfSameValue( new Float64Array( [ 1.0, 2.0, 3.0 ] ), 0, -20 ); // eslint-disable-line max-len - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOfSameValue( new Int32Array( [ 1, 2, 3 ] ), 0, -20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOfSameValue( new AccessorArray( [ 1, 2, 3 ] ), 0, -20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 0, - '0': 1, - '1': 2, - '2': 3 - }; - actual = lastIndexOfSameValue( x, 0, -20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); diff --git a/base/last-index-of/README.md b/base/last-index-of/README.md deleted file mode 100644 index cdafe2861..000000000 --- a/base/last-index-of/README.md +++ /dev/null @@ -1,162 +0,0 @@ - - -# lastIndexOf - -> Return the index of the last element which equals a provided search element. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var lastIndexOf = require( '@stdlib/array/base/last-index-of' ); -``` - -#### lastIndexOf( x, searchElement, fromIndex ) - -Returns the index of the last element which equals a provided search element. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var idx = lastIndexOf( x, 3, 5 ); -// returns 2 -``` - -If the function is unable to find an element which equals a provided search element, the function returns `-1`. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var idx = lastIndexOf( x, 7, 5 ); -// returns -1 -``` - -To begin searching from a specific index, provide a corresponding `fromIndex` argument. - -```javascript -var x = [ 1, 1, 2, 1, 2, 3, 3 ]; - -var idx = lastIndexOf( x, 2, 3 ); -// returns 2 -``` - -If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. - -```javascript -var x = [ 1, 1, 2, 1, 2, 3, 3 ]; - -var idx = lastIndexOf( x, 2, -4 ); -// returns 2 -``` - -
- - - - - -
- -## Notes - -- The function scans an input array from the starting index to the beginning of the array (i.e., backward). - -- If provided an array-like object having a `lastIndexOf` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.lastIndexOf( searchElement, fromIndex ) - ``` - -- If provided an array-like object without a `lastIndexOf` method, the function performs a linear scan and returns immediately upon finding a match. - -- When searching for a search element, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same. - -
- - - - - -
- -## Examples - - - -```javascript -var lastIndexOf = require( '@stdlib/array/base/last-index-of' ); - -var x = [ 'foo', 'bar', 'beep', 'boop', 'foo', 'bar' ]; - -var idx = lastIndexOf( x, 'beep', 5 ); -// returns 2 - -idx = lastIndexOf( x, 'bop', 5 ); -// returns -1 - -idx = lastIndexOf( x, 'foo', 5 ); -// returns 4 - -idx = lastIndexOf( x, 'foo', -3 ); -// returns 0 - -idx = lastIndexOf( x, 'foo', -50 ); -// returns -1 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/last-index-of/benchmark/benchmark.length.js b/base/last-index-of/benchmark/benchmark.length.js deleted file mode 100644 index 74f9854dc..000000000 --- a/base/last-index-of/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var lastIndexOf = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = lastIndexOf( x, -2, len-1 ); - if ( out !== out ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) || out >= 0 ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/last-index-of/docs/repl.txt b/base/last-index-of/docs/repl.txt deleted file mode 100644 index 8c1014320..000000000 --- a/base/last-index-of/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( x, searchElement, fromIndex ) - Returns the index of the last element which equals a provided search - element. - - If provided an array-like object having a `lastIndexOf` method, the function - defers execution to that method and assumes that the method has the - following signature: - - x.lastIndexOf( searchElement, fromIndex ) - - If provided an array-like object without a `lastIndexOf` method, the - function performs a linear scan and returns immediately upon finding a - match. - - If unable to find an element which equals a provided search element, the - function returns -1. - - The function scans an input array from the starting index to the beginning - of the array (i.e., backward). - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - searchElement: any - Search element. - - fromIndex: integer - Starting index (inclusive). If less than zero, the starting index is - resolved relative to the last array element, with the last array element - corresponding to `fromIndex = -1`. - - Returns - ------- - out: integer - Index or -1. - - Examples - -------- - > var out = {{alias}}( [ 1, 3, 3, 4 ], 3, 3 ) - 2 - - See Also - -------- - diff --git a/base/last-index-of/docs/types/index.d.ts b/base/last-index-of/docs/types/index.d.ts deleted file mode 100644 index b622d53ce..000000000 --- a/base/last-index-of/docs/types/index.d.ts +++ /dev/null @@ -1,58 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns the index of the last element which equals a provided search element. -* -* ## Notes -* -* - The function scans an input array from the starting index to the beginning of the array (i.e., backward). -* - If unable to find an element which equals a provided search element, the function returns `-1`. -* - If `fromIndex` is less than zero, the starting index is resolved relative to the last array element, with the last array element corresponding to `fromIndex = -1`. -* -* @param x - input array -* @param searchElement - search element -* @param fromIndex - starting index (inclusive) -* @returns index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = lastIndexOf( x, 2, 3 ); -* // returns 1 -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var idx = lastIndexOf( x, 2, 3 ); -* // returns 1 -*/ -declare function lastIndexOf( x: Collection | AccessorArrayLike, searchElement: unknown, fromIndex: number ): number; - - -// EXPORTS // - -export = lastIndexOf; diff --git a/base/last-index-of/docs/types/test.ts b/base/last-index-of/docs/types/test.ts deleted file mode 100644 index fc6a3253f..000000000 --- a/base/last-index-of/docs/types/test.ts +++ /dev/null @@ -1,72 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import lastIndexOf = require( './index' ); - - -// TESTS // - -// The function returns a number... -{ - lastIndexOf( [ 1, 2, 3 ], 0, 3 ); // $ExpectType number - lastIndexOf( new Float64Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOf( new Float32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOf( new Int32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOf( new Int16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOf( new Int8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOf( new Uint32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOf( new Uint16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOf( new Uint8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOf( new Uint8ClampedArray( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType number - lastIndexOf( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType number - lastIndexOf( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType number -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - lastIndexOf( 5, 0, 3 ); // $ExpectError - lastIndexOf( true, 0, 3 ); // $ExpectError - lastIndexOf( false, 0, 3 ); // $ExpectError - lastIndexOf( null, 0, 3 ); // $ExpectError - lastIndexOf( void 0, 0, 3 ); // $ExpectError - lastIndexOf( {}, 0, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - lastIndexOf( x, 0, '5' ); // $ExpectError - lastIndexOf( x, 0, true ); // $ExpectError - lastIndexOf( x, 0, false ); // $ExpectError - lastIndexOf( x, 0, null ); // $ExpectError - lastIndexOf( x, 0, void 0 ); // $ExpectError - lastIndexOf( x, 0, [] ); // $ExpectError - lastIndexOf( x, 0, {} ); // $ExpectError - lastIndexOf( x, 0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - lastIndexOf(); // $ExpectError - lastIndexOf( [ 1, 2, 3 ] ); // $ExpectError - lastIndexOf( [ 1, 2, 3 ], 0 ); // $ExpectError - lastIndexOf( [ 1, 2, 3 ], 0, 3, false ); // $ExpectError -} diff --git a/base/last-index-of/examples/index.js b/base/last-index-of/examples/index.js deleted file mode 100644 index a21d50b0c..000000000 --- a/base/last-index-of/examples/index.js +++ /dev/null @@ -1,43 +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'; - -var lastIndexOf = require( './../lib' ); - -var x = [ 'foo', 'bar', 'beep', 'boop', 'foo', 'bar' ]; - -var idx = lastIndexOf( x, 'beep', 5 ); -console.log( idx ); -// => 2 - -idx = lastIndexOf( x, 'bop', 5 ); -console.log( idx ); -// => -1 - -idx = lastIndexOf( x, 'foo', 5 ); -console.log( idx ); -// => 4 - -idx = lastIndexOf( x, 'foo', -3 ); -console.log( idx ); -// => 0 - -idx = lastIndexOf( x, 'foo', -50 ); -console.log( idx ); -// => -1 diff --git a/base/last-index-of/lib/index.js b/base/last-index-of/lib/index.js deleted file mode 100644 index 574a9b6f2..000000000 --- a/base/last-index-of/lib/index.js +++ /dev/null @@ -1,42 +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'; - -/** -* Return the index of the last element which equals a provided search element. -* -* @module @stdlib/array/base/last-index-of -* -* @example -* var lastIndexOf = require( '@stdlib/array/base/last-index-of' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = lastIndexOf( x, 2, 3 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/last-index-of/lib/main.js b/base/last-index-of/lib/main.js deleted file mode 100644 index 32fc4f2f8..000000000 --- a/base/last-index-of/lib/main.js +++ /dev/null @@ -1,154 +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 isAccessorArray = require( '@stdlib/assert/is-accessor-array' ); -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'lastIndexOf' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - -/** -* Returns the index of the last element which equals a provided search element. -* -* @private -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = internal( x, 2, 3 ); -* // returns 1 -*/ -function internal( x, searchElement, fromIndex ) { - var i; - for ( i = fromIndex; i >= 0; i-- ) { - if ( searchElement === x[ i ] ) { - return i; - } - } - return -1; -} - -/** -* Returns the index of the last element which equals a provided search element. -* -* @private -* @param {Object} x - input array object -* @param {*} searchElement - search element -* @param {NonNegativeInteger} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var idx = accessors( x, 2, 3 ); -* // returns 1 -*/ -function accessors( x, searchElement, fromIndex ) { - var get; - var i; - - get = resolveGetter( x ); - for ( i = fromIndex; i >= 0; i-- ) { - if ( searchElement === get( x, i ) ) { - return i; - } - } - return -1; -} - - -// MAIN // - -/** -* Returns the index of the last element which equals a provided search element. -* -* ## Notes -* -* - If unable to find an element which equals a provided search element, the function returns `-1`. -* -* @param {Collection} x - input array -* @param {*} searchElement - search element -* @param {integer} fromIndex - starting index (inclusive) -* @returns {integer} index -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var idx = lastIndexOf( x, 2, 3 ); -* // returns 1 -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var idx = lastIndexOf( x, 2, 3 ); -* // returns 1 -*/ -function lastIndexOf( x, searchElement, fromIndex ) { - if ( hasMethod( x, 'lastIndexOf' ) ) { - return x.lastIndexOf( searchElement, fromIndex ); - } - if ( fromIndex < 0 ) { - fromIndex += x.length; - if ( fromIndex < 0 ) { - return -1; - } - } else if ( fromIndex > x.length ) { - fromIndex = x.length - 1; - } - if ( isAccessorArray( x ) ) { - return accessors( x, searchElement, fromIndex ); - } - return internal( x, searchElement, fromIndex ); -} - - -// EXPORTS // - -module.exports = lastIndexOf; diff --git a/base/last-index-of/package.json b/base/last-index-of/package.json deleted file mode 100644 index ed7f450db..000000000 --- a/base/last-index-of/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/last-index-of", - "version": "0.0.0", - "description": "Return the index of the last element which equals a provided search element.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "search", - "find", - "scan", - "locate", - "index" - ] -} diff --git a/base/last-index-of/test/test.js b/base/last-index-of/test/test.js deleted file mode 100644 index 5d6bd22af..000000000 --- a/base/last-index-of/test/test.js +++ /dev/null @@ -1,355 +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 AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var lastIndexOf = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof lastIndexOf, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (generic)', function test( t ) { - var actual; - var x; - - x = [ 1, 1, 2, 2, 3, 3 ]; - - actual = lastIndexOf( x, 1, 5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 2, 5 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOf( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOf( x, 2, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 100 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOf( x, 1, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 3, -2 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOf( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOf( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (float64)', function test( t ) { - var actual; - var x; - - x = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - - actual = lastIndexOf( x, 1.0, 5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 2.0, 5 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOf( x, 3.0, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOf( x, 1.0, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOf( x, 2.0, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOf( x, 3.0, 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOf( x, 3.0, 100 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOf( x, 1.0, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 3.0, -2 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOf( x, 1.0, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 2.0, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOf( x, 3.0, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (int32)', function test( t ) { - var actual; - var x; - - x = new Int32Array( [ 1, 1, 2, 2, 3, 3 ] ); - - actual = lastIndexOf( x, 1, 5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 2, 5 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOf( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOf( x, 2, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 100 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOf( x, 1, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 3, -2 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOf( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOf( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (accessors)', function test( t ) { - var actual; - var x; - - x = new AccessorArray( [ 1, 1, 2, 2, 3, 3 ] ); - - actual = lastIndexOf( x, 1, 5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 2, 5 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOf( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOf( x, 2, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 100 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOf( x, 1, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 3, -2 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOf( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOf( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the last index of an element which equals a provided search element (array-like)', function test( t ) { - var actual; - var x; - - x = { - 'length': 6, - '0': 1, - '1': 1, - '2': 2, - '3': 2, - '4': 3, - '5': 3 - }; - - actual = lastIndexOf( x, 1, 5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 2, 5 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 5 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Nonnegative starting index... - actual = lastIndexOf( x, 1, 0 ); - t.strictEqual( actual, 0, 'returns expected value' ); - - actual = lastIndexOf( x, 2, 2 ); - t.strictEqual( actual, 2, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 4 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOf( x, 3, 100 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - // Negative starting index... - actual = lastIndexOf( x, 1, -1 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 3, -2 ); - t.strictEqual( actual, 4, 'returns expected value' ); - - actual = lastIndexOf( x, 1, -5 ); - t.strictEqual( actual, 1, 'returns expected value' ); - - actual = lastIndexOf( x, 2, -3 ); - t.strictEqual( actual, 3, 'returns expected value' ); - - actual = lastIndexOf( x, 3, -1 ); - t.strictEqual( actual, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `-1` if provided an empty array', function test( t ) { - var actual; - var x; - - actual = lastIndexOf( [], 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOf( new Float64Array( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOf( new Int32Array( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOf( new AccessorArray( [] ), 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 0 - }; - actual = lastIndexOf( x, 0, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `-1` if provided a search element equal to `NaN`', function test( t ) { - var actual; - var x; - - actual = lastIndexOf( [ NaN ], NaN, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOf( new Float64Array( [ NaN ] ), NaN, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOf( new AccessorArray( [ NaN ] ), NaN, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 1, - '0': NaN - }; - actual = lastIndexOf( x, NaN, 0 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `-1` if provided a starting index which exceeds the minimum array index', function test( t ) { - var actual; - var x; - - actual = lastIndexOf( [ 1, 2, 3 ], 0, -20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOf( new Float64Array( [ 1.0, 2.0, 3.0 ] ), 0, -20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOf( new Int32Array( [ 1, 2, 3 ] ), 0, -20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - actual = lastIndexOf( new AccessorArray( [ 1, 2, 3 ] ), 0, -20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - x = { - 'length': 0, - '0': 1, - '1': 2, - '2': 3 - }; - actual = lastIndexOf( x, 0, -20 ); - t.strictEqual( actual, -1, 'returns expected value' ); - - t.end(); -}); diff --git a/base/last/README.md b/base/last/README.md deleted file mode 100644 index e1e89b8ab..000000000 --- a/base/last/README.md +++ /dev/null @@ -1,123 +0,0 @@ - - -# last - -> Return the last element of an array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var last = require( '@stdlib/array/base/last' ); -``` - -#### last( x ) - -Returns the last element of an array-like object. - -```javascript -var x = [ 1, 2, 3 ]; - -var out = last( x ); -// returns 3 -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var Complex64Array = require( '@stdlib/array/complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var last = require( '@stdlib/array/base/last' ); - -// Create a complex number array: -var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - -// Return the last element: -var out = last( arr ); -// returns - -var re = realf( out ); -// returns 5.0 - -var im = imagf( out ); -// returns 6.0 - -console.log( '%d + %di', re, im ); -// => '5 + 6i' -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/last/benchmark/benchmark.js b/base/last/benchmark/benchmark.js deleted file mode 100644 index 846b217ce..000000000 --- a/base/last/benchmark/benchmark.js +++ /dev/null @@ -1,102 +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 bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var pow = require( '@stdlib/math/base/special/pow' ); -var filledBy = require( './../../../filled-by' ); -var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var pkg = require( './../package.json' ).name; -var last = require( './../lib' ); - - -// VARIABLES // - -var rand = discreteUniform( 0, 127 ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = filledBy( len, 'float32', rand ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = last( arr ); - if ( isnanf( out ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnanf( out ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/last/docs/repl.txt b/base/last/docs/repl.txt deleted file mode 100644 index 644b256ec..000000000 --- a/base/last/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( arr ) - Returns the last element of an array-like object. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: any - Last element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3 ] ) - 3 - - See Also - -------- - diff --git a/base/last/docs/types/index.d.ts b/base/last/docs/types/index.d.ts deleted file mode 100644 index 778b0103b..000000000 --- a/base/last/docs/types/index.d.ts +++ /dev/null @@ -1,42 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Returns the last element of an array-like object. -* -* @param arr - input array -* @returns last element -* -* @example -* var arr = [ 1, 2, 3 ]; -* -* var out = last( x ); -* // returns 3 -*/ -declare function last( arr: Collection ): T; - - -// EXPORTS // - -export = last; diff --git a/base/last/docs/types/test.ts b/base/last/docs/types/test.ts deleted file mode 100644 index 8decb99ed..000000000 --- a/base/last/docs/types/test.ts +++ /dev/null @@ -1,42 +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. -*/ - -import last = require( './index' ); - - -// TESTS // - -// The function returns the last element in array... -{ - last( [ 1, 2, 3 ] ); // $ExpectType number -} - -// The compiler throws an error if the function is provided an argument which is not a collection... -{ - last( 5 ); // $ExpectError - last( true ); // $ExpectError - last( false ); // $ExpectError - last( null ); // $ExpectError - last( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - last(); // $ExpectError - last( [ 1, 2, 3 ], 2 ); // $ExpectError -} diff --git a/base/last/examples/index.js b/base/last/examples/index.js deleted file mode 100644 index a08e883e9..000000000 --- a/base/last/examples/index.js +++ /dev/null @@ -1,40 +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'; - -var Complex64Array = require( './../../../complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var last = require( './../lib' ); - -// Create a complex number array: -var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - -// Return the last element: -var out = last( arr ); -// returns - -var re = realf( out ); -// returns 5.0 - -var im = imagf( out ); -// returns 6.0 - -console.log( '%d + %di', re, im ); -// => '5 + 6i' diff --git a/base/last/lib/index.js b/base/last/lib/index.js deleted file mode 100644 index c8321ec11..000000000 --- a/base/last/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Return the last element of an array-like object. -* -* @module @stdlib/array/base/last -* -* @example -* var last = require( '@stdlib/array/base/last' ); -* -* var out = last( [ 1, 2, 3 ] ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/last/lib/main.js b/base/last/lib/main.js deleted file mode 100644 index 9f42cf9d2..000000000 --- a/base/last/lib/main.js +++ /dev/null @@ -1,58 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Returns the last element of an array-like object. -* -* @param {Collection} arr - input array -* @returns {*} - last element -* -* @example -* var out = last( [ 1, 2, 3 ] ); -* // returns 3 -*/ -function last( arr ) { - var get; - var idx; - - // Resolve an accessor for retrieving input array elements: - get = resolveGetter( arr ); - - // Resolve the last index: - idx = arr.length - 1; - - // Return the last element: - if ( idx < 0 ) { - return; - } - return get( arr, idx ); -} - - -// EXPORTS // - -module.exports = last; diff --git a/base/last/package.json b/base/last/package.json deleted file mode 100644 index d27e73257..000000000 --- a/base/last/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/last", - "version": "0.0.0", - "description": "Return the last element of an array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "base", - "generic", - "last" - ] -} diff --git a/base/last/test/test.js b/base/last/test/test.js deleted file mode 100644 index dde64cae6..000000000 --- a/base/last/test/test.js +++ /dev/null @@ -1,74 +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 Complex64Array = require( './../../../complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var last = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof last, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the last element of an array-like object', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - expected = 3; - actual = last( x ); - - t.equal( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the last element of an array-like object (accessors)', function test( t ) { - var actual; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - actual = last( x ); - - t.strictEqual( realf( actual ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( actual ), 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns `undefined` if provided an empty array', function test( t ) { - var actual = last( [] ); - t.strictEqual( actual, void 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `undefined` if provided an empty array (accessors)', function test( t ) { - var actual = last( new Complex64Array( 0 ) ); - t.strictEqual( actual, void 0, 'returns expected value' ); - t.end(); -}); diff --git a/base/lib/index.js b/base/lib/index.js deleted file mode 100644 index c31f1cf62..000000000 --- a/base/lib/index.js +++ /dev/null @@ -1,2058 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name AccessorArray -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/accessor} -*/ -setReadOnly( ns, 'AccessorArray', require( './../../base/accessor' ) ); - -/** -* @name accessorGetter -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/accessor-getter} -*/ -setReadOnly( ns, 'accessorGetter', require( './../../base/accessor-getter' ) ); - -/** -* @name accessorSetter -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/accessor-setter} -*/ -setReadOnly( ns, 'accessorSetter', require( './../../base/accessor-setter' ) ); - -/** -* @name accessors -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/accessors} -*/ -setReadOnly( ns, 'accessors', require( './../../base/accessors' ) ); - -/** -* @name any -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/any} -*/ -setReadOnly( ns, 'any', require( './../../base/any' ) ); - -/** -* @name anyBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/any-by} -*/ -setReadOnly( ns, 'anyBy', require( './../../base/any-by' ) ); - -/** -* @name anyByRight -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/any-by-right} -*/ -setReadOnly( ns, 'anyByRight', require( './../../base/any-by-right' ) ); - -/** -* @name anyHasOwnProp -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/any-has-own-property} -*/ -setReadOnly( ns, 'anyHasOwnProp', require( './../../base/any-has-own-property' ) ); - -/** -* @name anyHasProp -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/any-has-property} -*/ -setReadOnly( ns, 'anyHasProp', require( './../../base/any-has-property' ) ); - -/** -* @name anyIsEntry -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/any-is-entry} -*/ -setReadOnly( ns, 'anyIsEntry', require( './../../base/any-is-entry' ) ); - -/** -* @name anyIsEntryIn -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/any-is-entry-in} -*/ -setReadOnly( ns, 'anyIsEntryIn', require( './../../base/any-is-entry-in' ) ); - -/** -* @name arraylike2object -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/arraylike2object} -*/ -setReadOnly( ns, 'arraylike2object', require( './../../base/arraylike2object' ) ); - -/** -* @name assert -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/array/base/assert} -*/ -setReadOnly( ns, 'assert', require( './../../base/assert' ) ); - -/** -* @name at -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/at} -*/ -setReadOnly( ns, 'at', require( './../../base/at' ) ); - -/** -* @name at2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/at2d} -*/ -setReadOnly( ns, 'at2d', require( './../../base/at2d' ) ); - -/** -* @name at3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/at3d} -*/ -setReadOnly( ns, 'at3d', require( './../../base/at3d' ) ); - -/** -* @name at4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/at4d} -*/ -setReadOnly( ns, 'at4d', require( './../../base/at4d' ) ); - -/** -* @name at5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/at5d} -*/ -setReadOnly( ns, 'at5d', require( './../../base/at5d' ) ); - -/** -* @name atnd -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/atnd} -*/ -setReadOnly( ns, 'atnd', require( './../../base/atnd' ) ); - -/** -* @name banded -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/array/base/banded} -*/ -setReadOnly( ns, 'banded', require( './../../base/banded' ) ); - -/** -* @name bifurcateEntries -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/array/base/bifurcate-entries} -*/ -setReadOnly( ns, 'bifurcateEntries', require( './../../base/bifurcate-entries' ) ); - -/** -* @name bifurcateEntriesBy -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/array/base/bifurcate-entries-by} -*/ -setReadOnly( ns, 'bifurcateEntriesBy', require( './../../base/bifurcate-entries-by' ) ); - -/** -* @name bifurcateIndices -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/array/base/bifurcate-indices} -*/ -setReadOnly( ns, 'bifurcateIndices', require( './../../base/bifurcate-indices' ) ); - -/** -* @name bifurcateIndicesBy -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/array/base/bifurcate-indices-by} -*/ -setReadOnly( ns, 'bifurcateIndicesBy', require( './../../base/bifurcate-indices-by' ) ); - -/** -* @name bifurcateValues -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/array/base/bifurcate-values} -*/ -setReadOnly( ns, 'bifurcateValues', require( './../../base/bifurcate-values' ) ); - -/** -* @name bifurcateValuesBy -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/array/base/bifurcate-values-by} -*/ -setReadOnly( ns, 'bifurcateValuesBy', require( './../../base/bifurcate-values-by' ) ); - -/** -* @name binary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/binary2d} -*/ -setReadOnly( ns, 'binary2d', require( './../../base/binary2d' ) ); - -/** -* @name binary3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/binary3d} -*/ -setReadOnly( ns, 'binary3d', require( './../../base/binary3d' ) ); - -/** -* @name binary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/binary4d} -*/ -setReadOnly( ns, 'binary4d', require( './../../base/binary4d' ) ); - -/** -* @name binary5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/binary5d} -*/ -setReadOnly( ns, 'binary5d', require( './../../base/binary5d' ) ); - -/** -* @name binarynd -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/binarynd} -*/ -setReadOnly( ns, 'binarynd', require( './../../base/binarynd' ) ); - -/** -* @name broadcastArray -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcast-array} -*/ -setReadOnly( ns, 'broadcastArray', require( './../../base/broadcast-array' ) ); - -/** -* @name bbinary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-binary2d} -*/ -setReadOnly( ns, 'bbinary2d', require( './../../base/broadcasted-binary2d' ) ); - -/** -* @name bbinary3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-binary3d} -*/ -setReadOnly( ns, 'bbinary3d', require( './../../base/broadcasted-binary3d' ) ); - -/** -* @name bbinary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-binary4d} -*/ -setReadOnly( ns, 'bbinary4d', require( './../../base/broadcasted-binary4d' ) ); - -/** -* @name bbinary5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-binary5d} -*/ -setReadOnly( ns, 'bbinary5d', require( './../../base/broadcasted-binary5d' ) ); - -/** -* @name bquaternary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-quaternary2d} -*/ -setReadOnly( ns, 'bquaternary2d', require( './../../base/broadcasted-quaternary2d' ) ); - -/** -* @name bquaternary3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-quaternary3d} -*/ -setReadOnly( ns, 'bquaternary3d', require( './../../base/broadcasted-quaternary3d' ) ); - -/** -* @name bquaternary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-quaternary4d} -*/ -setReadOnly( ns, 'bquaternary4d', require( './../../base/broadcasted-quaternary4d' ) ); - -/** -* @name bquaternary5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-quaternary5d} -*/ -setReadOnly( ns, 'bquaternary5d', require( './../../base/broadcasted-quaternary5d' ) ); - -/** -* @name bquinary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-quinary2d} -*/ -setReadOnly( ns, 'bquinary2d', require( './../../base/broadcasted-quinary2d' ) ); - -/** -* @name bquinary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-quinary4d} -*/ -setReadOnly( ns, 'bquinary4d', require( './../../base/broadcasted-quinary4d' ) ); - -/** -* @name bternary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-ternary2d} -*/ -setReadOnly( ns, 'bternary2d', require( './../../base/broadcasted-ternary2d' ) ); - -/** -* @name bternary3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-ternary3d} -*/ -setReadOnly( ns, 'bternary3d', require( './../../base/broadcasted-ternary3d' ) ); - -/** -* @name bternary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-ternary4d} -*/ -setReadOnly( ns, 'bternary4d', require( './../../base/broadcasted-ternary4d' ) ); - -/** -* @name bternary5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-ternary5d} -*/ -setReadOnly( ns, 'bternary5d', require( './../../base/broadcasted-ternary5d' ) ); - -/** -* @name bunary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-unary2d} -*/ -setReadOnly( ns, 'bunary2d', require( './../../base/broadcasted-unary2d' ) ); - -/** -* @name bunary3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-unary3d} -*/ -setReadOnly( ns, 'bunary3d', require( './../../base/broadcasted-unary3d' ) ); - -/** -* @name bunary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-unary4d} -*/ -setReadOnly( ns, 'bunary4d', require( './../../base/broadcasted-unary4d' ) ); - -/** -* @name bunary5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/broadcasted-unary5d} -*/ -setReadOnly( ns, 'bunary5d', require( './../../base/broadcasted-unary5d' ) ); - -/** -* @name cartesianPower -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/cartesian-power} -*/ -setReadOnly( ns, 'cartesianPower', require( './../../base/cartesian-power' ) ); - -/** -* @name cartesianProduct -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/cartesian-product} -*/ -setReadOnly( ns, 'cartesianProduct', require( './../../base/cartesian-product' ) ); - -/** -* @name cartesianSquare -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/cartesian-square} -*/ -setReadOnly( ns, 'cartesianSquare', require( './../../base/cartesian-square' ) ); - -/** -* @name copy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/copy} -*/ -setReadOnly( ns, 'copy', require( './../../base/copy' ) ); - -/** -* @name copyIndexed -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/copy-indexed} -*/ -setReadOnly( ns, 'copyIndexed', require( './../../base/copy-indexed' ) ); - -/** -* @name countFalsy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/count-falsy} -*/ -setReadOnly( ns, 'countFalsy', require( './../../base/count-falsy' ) ); - -/** -* @name countIf -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/count-if} -*/ -setReadOnly( ns, 'countIf', require( './../../base/count-if' ) ); - -/** -* @name countIfs -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/count-ifs} -*/ -setReadOnly( ns, 'countIfs', require( './../../base/count-ifs' ) ); - -/** -* @name countSameValue -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/count-same-value} -*/ -setReadOnly( ns, 'countSameValue', require( './../../base/count-same-value' ) ); - -/** -* @name countSameValueZero -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/count-same-value-zero} -*/ -setReadOnly( ns, 'countSameValueZero', require( './../../base/count-same-value-zero' ) ); - -/** -* @name countTruthy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/count-truthy} -*/ -setReadOnly( ns, 'countTruthy', require( './../../base/count-truthy' ) ); - -/** -* @name cuany -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/cuany} -*/ -setReadOnly( ns, 'cuany', require( './../../base/cuany' ) ); - -/** -* @name cuevery -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/cuevery} -*/ -setReadOnly( ns, 'cuevery', require( './../../base/cuevery' ) ); - -/** -* @name cunone -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/cunone} -*/ -setReadOnly( ns, 'cunone', require( './../../base/cunone' ) ); - -/** -* @name dedupe -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/dedupe} -*/ -setReadOnly( ns, 'dedupe', require( './../../base/dedupe' ) ); - -/** -* @name entries2objects -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/entries2objects} -*/ -setReadOnly( ns, 'entries2objects', require( './../../base/entries2objects' ) ); - -/** -* @name entries2views -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/entries2views} -*/ -setReadOnly( ns, 'entries2views', require( './../../base/entries2views' ) ); - -/** -* @name every -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/every} -*/ -setReadOnly( ns, 'every', require( './../../base/every' ) ); - -/** -* @name everyBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/every-by} -*/ -setReadOnly( ns, 'everyBy', require( './../../base/every-by' ) ); - -/** -* @name everyByRight -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/every-by-right} -*/ -setReadOnly( ns, 'everyByRight', require( './../../base/every-by-right' ) ); - -/** -* @name fancySlice -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/fancy-slice} -*/ -setReadOnly( ns, 'fancySlice', require( './../../base/fancy-slice' ) ); - -/** -* @name fancySliceAssign -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/fancy-slice-assign} -*/ -setReadOnly( ns, 'fancySliceAssign', require( './../../base/fancy-slice-assign' ) ); - -/** -* @name fill -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/fill} -*/ -setReadOnly( ns, 'fill', require( './../../base/fill' ) ); - -/** -* @name fillBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/fill-by} -*/ -setReadOnly( ns, 'fillBy', require( './../../base/fill-by' ) ); - -/** -* @name filled -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/filled} -*/ -setReadOnly( ns, 'filled', require( './../../base/filled' ) ); - -/** -* @name filledBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/filled-by} -*/ -setReadOnly( ns, 'filledBy', require( './../../base/filled-by' ) ); - -/** -* @name filled2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/filled2d} -*/ -setReadOnly( ns, 'filled2d', require( './../../base/filled2d' ) ); - -/** -* @name filled2dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/filled2d-by} -*/ -setReadOnly( ns, 'filled2dBy', require( './../../base/filled2d-by' ) ); - -/** -* @name filled3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/filled3d} -*/ -setReadOnly( ns, 'filled3d', require( './../../base/filled3d' ) ); - -/** -* @name filled3dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/filled3d-by} -*/ -setReadOnly( ns, 'filled3dBy', require( './../../base/filled3d-by' ) ); - -/** -* @name filled4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/filled4d} -*/ -setReadOnly( ns, 'filled4d', require( './../../base/filled4d' ) ); - -/** -* @name filled4dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/filled4d-by} -*/ -setReadOnly( ns, 'filled4dBy', require( './../../base/filled4d-by' ) ); - -/** -* @name filled5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/filled5d} -*/ -setReadOnly( ns, 'filled5d', require( './../../base/filled5d' ) ); - -/** -* @name filled5dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/filled5d-by} -*/ -setReadOnly( ns, 'filled5dBy', require( './../../base/filled5d-by' ) ); - -/** -* @name fillednd -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/fillednd} -*/ -setReadOnly( ns, 'fillednd', require( './../../base/fillednd' ) ); - -/** -* @name filledndBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/fillednd-by} -*/ -setReadOnly( ns, 'filledndBy', require( './../../base/fillednd-by' ) ); - -/** -* @name filter -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/filter} -*/ -setReadOnly( ns, 'filter', require( './../../base/filter' ) ); - -/** -* @name first -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/first} -*/ -setReadOnly( ns, 'first', require( './../../base/first' ) ); - -/** -* @name flatten -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flatten} -*/ -setReadOnly( ns, 'flatten', require( './../../base/flatten' ) ); - -/** -* @name flattenBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flatten-by} -*/ -setReadOnly( ns, 'flattenBy', require( './../../base/flatten-by' ) ); - -/** -* @name flatten2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flatten2d} -*/ -setReadOnly( ns, 'flatten2d', require( './../../base/flatten2d' ) ); - -/** -* @name flatten2dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flatten2d-by} -*/ -setReadOnly( ns, 'flatten2dBy', require( './../../base/flatten2d-by' ) ); - -/** -* @name flatten3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flatten3d} -*/ -setReadOnly( ns, 'flatten3d', require( './../../base/flatten3d' ) ); - -/** -* @name flatten3dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flatten3d-by} -*/ -setReadOnly( ns, 'flatten3dBy', require( './../../base/flatten3d-by' ) ); - -/** -* @name flatten4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flatten4d} -*/ -setReadOnly( ns, 'flatten4d', require( './../../base/flatten4d' ) ); - -/** -* @name flatten4dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flatten4d-by} -*/ -setReadOnly( ns, 'flatten4dBy', require( './../../base/flatten4d-by' ) ); - -/** -* @name flatten5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flatten5d} -*/ -setReadOnly( ns, 'flatten5d', require( './../../base/flatten5d' ) ); - -/** -* @name flatten5dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flatten5d-by} -*/ -setReadOnly( ns, 'flatten5dBy', require( './../../base/flatten5d-by' ) ); - -/** -* @name fliplr2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/fliplr2d} -*/ -setReadOnly( ns, 'fliplr2d', require( './../../base/fliplr2d' ) ); - -/** -* @name fliplr3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/fliplr3d} -*/ -setReadOnly( ns, 'fliplr3d', require( './../../base/fliplr3d' ) ); - -/** -* @name fliplr4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/fliplr4d} -*/ -setReadOnly( ns, 'fliplr4d', require( './../../base/fliplr4d' ) ); - -/** -* @name fliplr5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/fliplr5d} -*/ -setReadOnly( ns, 'fliplr5d', require( './../../base/fliplr5d' ) ); - -/** -* @name flipud2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flipud2d} -*/ -setReadOnly( ns, 'flipud2d', require( './../../base/flipud2d' ) ); - -/** -* @name flipud3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flipud3d} -*/ -setReadOnly( ns, 'flipud3d', require( './../../base/flipud3d' ) ); - -/** -* @name flipud4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flipud4d} -*/ -setReadOnly( ns, 'flipud4d', require( './../../base/flipud4d' ) ); - -/** -* @name flipud5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/flipud5d} -*/ -setReadOnly( ns, 'flipud5d', require( './../../base/flipud5d' ) ); - -/** -* @name strided2array -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/from-strided} -*/ -setReadOnly( ns, 'strided2array', require( './../../base/from-strided' ) ); - -/** -* @name getter -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/getter} -*/ -setReadOnly( ns, 'getter', require( './../../base/getter' ) ); - -/** -* @name groupEntries -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/group-entries} -*/ -setReadOnly( ns, 'groupEntries', require( './../../base/group-entries' ) ); - -/** -* @name groupEntriesBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/group-entries-by} -*/ -setReadOnly( ns, 'groupEntriesBy', require( './../../base/group-entries-by' ) ); - -/** -* @name groupIndices -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/group-indices} -*/ -setReadOnly( ns, 'groupIndices', require( './../../base/group-indices' ) ); - -/** -* @name groupIndicesBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/group-indices-by} -*/ -setReadOnly( ns, 'groupIndicesBy', require( './../../base/group-indices-by' ) ); - -/** -* @name groupValues -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/group-values} -*/ -setReadOnly( ns, 'groupValues', require( './../../base/group-values' ) ); - -/** -* @name groupValuesBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/group-values-by} -*/ -setReadOnly( ns, 'groupValuesBy', require( './../../base/group-values-by' ) ); - -/** -* @name groupValuesOnKey -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/group-values-on-key} -*/ -setReadOnly( ns, 'groupValuesOnKey', require( './../../base/group-values-on-key' ) ); - -/** -* @name incrspace -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/incrspace} -*/ -setReadOnly( ns, 'incrspace', require( './../../base/incrspace' ) ); - -/** -* @name indexOf -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/index-of} -*/ -setReadOnly( ns, 'indexOf', require( './../../base/index-of' ) ); - -/** -* @name indexOfSameValue -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/index-of-same-value} -*/ -setReadOnly( ns, 'indexOfSameValue', require( './../../base/index-of-same-value' ) ); - -/** -* @name indicesComplement -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/indices-complement} -*/ -setReadOnly( ns, 'indicesComplement', require( './../../base/indices-complement' ) ); - -/** -* @name join -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/join} -*/ -setReadOnly( ns, 'join', require( './../../base/join' ) ); - -/** -* @name last -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/last} -*/ -setReadOnly( ns, 'last', require( './../../base/last' ) ); - -/** -* @name lastIndexOf -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/last-index-of} -*/ -setReadOnly( ns, 'lastIndexOf', require( './../../base/last-index-of' ) ); - -/** -* @name lastIndexOfSameValue -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/last-index-of-same-value} -*/ -setReadOnly( ns, 'lastIndexOfSameValue', require( './../../base/last-index-of-same-value' ) ); - -/** -* @name linspace -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/linspace} -*/ -setReadOnly( ns, 'linspace', require( './../../base/linspace' ) ); - -/** -* @name linspace2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/linspace2d} -*/ -setReadOnly( ns, 'linspace2d', require( './../../base/linspace2d' ) ); - -/** -* @name logspace -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/logspace} -*/ -setReadOnly( ns, 'logspace', require( './../../base/logspace' ) ); - -/** -* @name map2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/map2d} -*/ -setReadOnly( ns, 'map2d', require( './../../base/map2d' ) ); - -/** -* @name map3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/map3d} -*/ -setReadOnly( ns, 'map3d', require( './../../base/map3d' ) ); - -/** -* @name map4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/map4d} -*/ -setReadOnly( ns, 'map4d', require( './../../base/map4d' ) ); - -/** -* @name map5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/map5d} -*/ -setReadOnly( ns, 'map5d', require( './../../base/map5d' ) ); - -/** -* @name minSignedIntegerDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/min-signed-integer-dtype} -*/ -setReadOnly( ns, 'minSignedIntegerDataType', require( './../../base/min-signed-integer-dtype' ) ); - -/** -* @name minUnsignedIntegerDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/min-unsigned-integer-dtype} -*/ -setReadOnly( ns, 'minUnsignedIntegerDataType', require( './../../base/min-unsigned-integer-dtype' ) ); - -/** -* @name mskbinary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskbinary2d} -*/ -setReadOnly( ns, 'mskbinary2d', require( './../../base/mskbinary2d' ) ); - -/** -* @name mskbinary3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskbinary3d} -*/ -setReadOnly( ns, 'mskbinary3d', require( './../../base/mskbinary3d' ) ); - -/** -* @name mskbinary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskbinary4d} -*/ -setReadOnly( ns, 'mskbinary4d', require( './../../base/mskbinary4d' ) ); - -/** -* @name mskbinary5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskbinary5d} -*/ -setReadOnly( ns, 'mskbinary5d', require( './../../base/mskbinary5d' ) ); - -/** -* @name mskfilter -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskfilter} -*/ -setReadOnly( ns, 'mskfilter', require( './../../base/mskfilter' ) ); - -/** -* @name mskfilterMap -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskfilter-map} -*/ -setReadOnly( ns, 'mskfilterMap', require( './../../base/mskfilter-map' ) ); - -/** -* @name mskfilter2 -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskfilter2} -*/ -setReadOnly( ns, 'mskfilter2', require( './../../base/mskfilter2' ) ); - -/** -* @name mskfiltern -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskfiltern} -*/ -setReadOnly( ns, 'mskfiltern', require( './../../base/mskfiltern' ) ); - -/** -* @name mskput -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskput} -*/ -setReadOnly( ns, 'mskput', require( './../../base/mskput' ) ); - -/** -* @name mskreject -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskreject} -*/ -setReadOnly( ns, 'mskreject', require( './../../base/mskreject' ) ); - -/** -* @name mskunary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskunary2d} -*/ -setReadOnly( ns, 'mskunary2d', require( './../../base/mskunary2d' ) ); - -/** -* @name mskunary3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskunary3d} -*/ -setReadOnly( ns, 'mskunary3d', require( './../../base/mskunary3d' ) ); - -/** -* @name mskunary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskunary4d} -*/ -setReadOnly( ns, 'mskunary4d', require( './../../base/mskunary4d' ) ); - -/** -* @name mskunary5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/mskunary5d} -*/ -setReadOnly( ns, 'mskunary5d', require( './../../base/mskunary5d' ) ); - -/** -* @name nCartesianProduct -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/n-cartesian-product} -*/ -setReadOnly( ns, 'nCartesianProduct', require( './../../base/n-cartesian-product' ) ); - -/** -* @name nested2objects -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/nested2objects} -*/ -setReadOnly( ns, 'nested2objects', require( './../../base/nested2objects' ) ); - -/** -* @name nested2views -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/nested2views} -*/ -setReadOnly( ns, 'nested2views', require( './../../base/nested2views' ) ); - -/** -* @name none -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/none} -*/ -setReadOnly( ns, 'none', require( './../../base/none' ) ); - -/** -* @name noneBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/none-by} -*/ -setReadOnly( ns, 'noneBy', require( './../../base/none-by' ) ); - -/** -* @name noneByRight -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/none-by-right} -*/ -setReadOnly( ns, 'noneByRight', require( './../../base/none-by-right' ) ); - -/** -* @name nulls -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/nulls} -*/ -setReadOnly( ns, 'nulls', require( './../../base/nulls' ) ); - -/** -* @name oneTo -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/one-to} -*/ -setReadOnly( ns, 'oneTo', require( './../../base/one-to' ) ); - -/** -* @name ones -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/ones} -*/ -setReadOnly( ns, 'ones', require( './../../base/ones' ) ); - -/** -* @name ones2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/ones2d} -*/ -setReadOnly( ns, 'ones2d', require( './../../base/ones2d' ) ); - -/** -* @name ones3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/ones3d} -*/ -setReadOnly( ns, 'ones3d', require( './../../base/ones3d' ) ); - -/** -* @name ones4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/ones4d} -*/ -setReadOnly( ns, 'ones4d', require( './../../base/ones4d' ) ); - -/** -* @name ones5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/ones5d} -*/ -setReadOnly( ns, 'ones5d', require( './../../base/ones5d' ) ); - -/** -* @name onesnd -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/onesnd} -*/ -setReadOnly( ns, 'onesnd', require( './../../base/onesnd' ) ); - -/** -* @name place -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/place} -*/ -setReadOnly( ns, 'place', require( './../../base/place' ) ); - -/** -* @name put -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/put} -*/ -setReadOnly( ns, 'put', require( './../../base/put' ) ); - -/** -* @name quaternary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/quaternary2d} -*/ -setReadOnly( ns, 'quaternary2d', require( './../../base/quaternary2d' ) ); - -/** -* @name quaternary3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/quaternary3d} -*/ -setReadOnly( ns, 'quaternary3d', require( './../../base/quaternary3d' ) ); - -/** -* @name quaternary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/quaternary4d} -*/ -setReadOnly( ns, 'quaternary4d', require( './../../base/quaternary4d' ) ); - -/** -* @name quaternary5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/quaternary5d} -*/ -setReadOnly( ns, 'quaternary5d', require( './../../base/quaternary5d' ) ); - -/** -* @name quinary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/quinary2d} -*/ -setReadOnly( ns, 'quinary2d', require( './../../base/quinary2d' ) ); - -/** -* @name quinary3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/quinary3d} -*/ -setReadOnly( ns, 'quinary3d', require( './../../base/quinary3d' ) ); - -/** -* @name quinary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/quinary4d} -*/ -setReadOnly( ns, 'quinary4d', require( './../../base/quinary4d' ) ); - -/** -* @name quinary5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/quinary5d} -*/ -setReadOnly( ns, 'quinary5d', require( './../../base/quinary5d' ) ); - -/** -* @name reject -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/reject} -*/ -setReadOnly( ns, 'reject', require( './../../base/reject' ) ); - -/** -* @name rekey -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/rekey} -*/ -setReadOnly( ns, 'rekey', require( './../../base/rekey' ) ); - -/** -* @name rekeyViews -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/rekey-views} -*/ -setReadOnly( ns, 'rekeyViews', require( './../../base/rekey-views' ) ); - -/** -* @name removeAt -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/remove-at} -*/ -setReadOnly( ns, 'removeAt', require( './../../base/remove-at' ) ); - -/** -* @name reshape -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/reshape} -*/ -setReadOnly( ns, 'reshape', require( './../../base/reshape' ) ); - -/** -* @name resolveGetter -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/resolve-getter} -*/ -setReadOnly( ns, 'resolveGetter', require( './../../base/resolve-getter' ) ); - -/** -* @name resolveSetter -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/resolve-setter} -*/ -setReadOnly( ns, 'resolveSetter', require( './../../base/resolve-setter' ) ); - -/** -* @name reverse -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/reverse} -*/ -setReadOnly( ns, 'reverse', require( './../../base/reverse' ) ); - -/** -* @name scatterFilled -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/scatter-filled} -*/ -setReadOnly( ns, 'scatterFilled', require( './../../base/scatter-filled' ) ); - -/** -* @name scattered -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/scattered} -*/ -setReadOnly( ns, 'scattered', require( './../../base/scattered' ) ); - -/** -* @name setter -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/setter} -*/ -setReadOnly( ns, 'setter', require( './../../base/setter' ) ); - -/** -* @name slice -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/slice} -*/ -setReadOnly( ns, 'slice', require( './../../base/slice' ) ); - -/** -* @name strided2array2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/strided2array2d} -*/ -setReadOnly( ns, 'strided2array2d', require( './../../base/strided2array2d' ) ); - -/** -* @name strided2array3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/strided2array3d} -*/ -setReadOnly( ns, 'strided2array3d', require( './../../base/strided2array3d' ) ); - -/** -* @name strided2array4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/strided2array4d} -*/ -setReadOnly( ns, 'strided2array4d', require( './../../base/strided2array4d' ) ); - -/** -* @name strided2array5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/strided2array5d} -*/ -setReadOnly( ns, 'strided2array5d', require( './../../base/strided2array5d' ) ); - -/** -* @name symmetric -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/array/base/symmetric} -*/ -setReadOnly( ns, 'symmetric', require( './../../base/symmetric' ) ); - -/** -* @name symmetricBanded -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/array/base/symmetric-banded} -*/ -setReadOnly( ns, 'symmetricBanded', require( './../../base/symmetric-banded' ) ); - -/** -* @name take -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/take} -*/ -setReadOnly( ns, 'take', require( './../../base/take' ) ); - -/** -* @name takeIndexed -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/take-indexed} -*/ -setReadOnly( ns, 'takeIndexed', require( './../../base/take-indexed' ) ); - -/** -* @name takeIndexed2 -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/take-indexed2} -*/ -setReadOnly( ns, 'takeIndexed2', require( './../../base/take-indexed2' ) ); - -/** -* @name take2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/take2d} -*/ -setReadOnly( ns, 'take2d', require( './../../base/take2d' ) ); - -/** -* @name take3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/take3d} -*/ -setReadOnly( ns, 'take3d', require( './../../base/take3d' ) ); - -/** -* @name ternary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/ternary2d} -*/ -setReadOnly( ns, 'ternary2d', require( './../../base/ternary2d' ) ); - -/** -* @name ternary3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/ternary3d} -*/ -setReadOnly( ns, 'ternary3d', require( './../../base/ternary3d' ) ); - -/** -* @name ternary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/ternary4d} -*/ -setReadOnly( ns, 'ternary4d', require( './../../base/ternary4d' ) ); - -/** -* @name ternary5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/ternary5d} -*/ -setReadOnly( ns, 'ternary5d', require( './../../base/ternary5d' ) ); - -/** -* @name toAccessorArray -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/to-accessor-array} -*/ -setReadOnly( ns, 'toAccessorArray', require( './../../base/to-accessor-array' ) ); - -/** -* @name toDeduped -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/to-deduped} -*/ -setReadOnly( ns, 'toDeduped', require( './../../base/to-deduped' ) ); - -/** -* @name toReversed -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/to-reversed} -*/ -setReadOnly( ns, 'toReversed', require( './../../base/to-reversed' ) ); - -/** -* @name unary2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/unary2d} -*/ -setReadOnly( ns, 'unary2d', require( './../../base/unary2d' ) ); - -/** -* @name unary2dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/unary2d-by} -*/ -setReadOnly( ns, 'unary2dBy', require( './../../base/unary2d-by' ) ); - -/** -* @name unary3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/unary3d} -*/ -setReadOnly( ns, 'unary3d', require( './../../base/unary3d' ) ); - -/** -* @name unary3dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/unary3d-by} -*/ -setReadOnly( ns, 'unary3dBy', require( './../../base/unary3d-by' ) ); - -/** -* @name unary4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/unary4d} -*/ -setReadOnly( ns, 'unary4d', require( './../../base/unary4d' ) ); - -/** -* @name unary4dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/unary4d-by} -*/ -setReadOnly( ns, 'unary4dBy', require( './../../base/unary4d-by' ) ); - -/** -* @name unary5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/unary5d} -*/ -setReadOnly( ns, 'unary5d', require( './../../base/unary5d' ) ); - -/** -* @name unary5dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/unary5d-by} -*/ -setReadOnly( ns, 'unary5dBy', require( './../../base/unary5d-by' ) ); - -/** -* @name unarynd -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/unarynd} -*/ -setReadOnly( ns, 'unarynd', require( './../../base/unarynd' ) ); - -/** -* @name unitspace -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/unitspace} -*/ -setReadOnly( ns, 'unitspace', require( './../../base/unitspace' ) ); - -/** -* @name where -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/where} -*/ -setReadOnly( ns, 'where', require( './../../base/where' ) ); - -/** -* @name arrayWith -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/with} -*/ -setReadOnly( ns, 'arrayWith', require( './../../base/with' ) ); - -/** -* @name without -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/without} -*/ -setReadOnly( ns, 'without', require( './../../base/without' ) ); - -/** -* @name zeroTo -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/zero-to} -*/ -setReadOnly( ns, 'zeroTo', require( './../../base/zero-to' ) ); - -/** -* @name zeros -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/zeros} -*/ -setReadOnly( ns, 'zeros', require( './../../base/zeros' ) ); - -/** -* @name zeros2d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/zeros2d} -*/ -setReadOnly( ns, 'zeros2d', require( './../../base/zeros2d' ) ); - -/** -* @name zeros3d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/zeros3d} -*/ -setReadOnly( ns, 'zeros3d', require( './../../base/zeros3d' ) ); - -/** -* @name zeros4d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/zeros4d} -*/ -setReadOnly( ns, 'zeros4d', require( './../../base/zeros4d' ) ); - -/** -* @name zeros5d -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/zeros5d} -*/ -setReadOnly( ns, 'zeros5d', require( './../../base/zeros5d' ) ); - -/** -* @name zerosnd -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/zerosnd} -*/ -setReadOnly( ns, 'zerosnd', require( './../../base/zerosnd' ) ); - -/** -* @name zip -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/zip} -*/ -setReadOnly( ns, 'zip', require( './../../base/zip' ) ); - -/** -* @name zip2object -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/zip2object} -*/ -setReadOnly( ns, 'zip2object', require( './../../base/zip2object' ) ); - -/** -* @name zip2objects -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/zip2objects} -*/ -setReadOnly( ns, 'zip2objects', require( './../../base/zip2objects' ) ); - -/** -* @name zip2views -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/zip2views} -*/ -setReadOnly( ns, 'zip2views', require( './../../base/zip2views' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/base/linspace/README.md b/base/linspace/README.md deleted file mode 100644 index 5fa6484a4..000000000 --- a/base/linspace/README.md +++ /dev/null @@ -1,123 +0,0 @@ - - -# linspace - -> Generate a linearly spaced numeric array. - -
- -## Usage - -```javascript -var linspace = require( '@stdlib/array/base/linspace' ); -``` - -#### linspace( start, stop, length ) - -Generates a linearly spaced numeric `array`. - -```javascript -var arr = linspace( 0, 100, 6 ); -// returns [ 0, 20, 40, 60, 80, 100 ] -``` - -
- - - -
- -## Notes - -- The function assumes that `length` is greater than or equal to `2`. - -- The output `array` is guaranteed to include the `start` and `stop` values. Beware, however, that values between `start` and `stop` are subject to floating-point rounding errors. Hence, - - ```javascript - var arr = linspace( 0, 1, 3 ); - // returns [ 0, ~0.5, 1 ] - ``` - - where `arr[1]` is only guaranteed to be approximately equal to `0.5`. If you desire more control over element precision, consider using [`roundn`][@stdlib/math/base/special/roundn]: - - ```javascript - var roundn = require( '@stdlib/math/base/special/roundn' ); - - // Create an array subject to floating-point rounding errors: - var arr = linspace( 0, 1, 21 ); - - // Round each value to the nearest hundredth: - var i; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = roundn( arr[ i ], -2 ); - } - console.log( arr.join( '\n' ) ); - ``` - -
- - - -
- -## Examples - - - -```javascript -var linspace = require( '@stdlib/array/base/linspace' ); - -// Create arrays of varying lengths: -var out = linspace( 0, 10, 10 ); -console.log( out ); - -out = linspace( 0, 10, 11 ); -console.log( out ); - -out = linspace( 0, 10, 21 ); -console.log( out ); - -// Create an array with decremented values: -out = linspace( 10, 0, 11 ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/linspace/benchmark/benchmark.js b/base/linspace/benchmark/benchmark.js deleted file mode 100644 index 939974cd5..000000000 --- a/base/linspace/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - var v; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 100 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/linspace/benchmark/benchmark.length.js b/base/linspace/benchmark/benchmark.length.js deleted file mode 100644 index f9120de22..000000000 --- a/base/linspace/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/linspace/docs/repl.txt b/base/linspace/docs/repl.txt deleted file mode 100644 index 63618caba..000000000 --- a/base/linspace/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( start, stop, length ) - Generates a linearly spaced numeric array. - - The output array is guaranteed to include the `start` and `stop` values. - - Parameters - ---------- - start: number - First array value. - - stop: number - Last array value. - - length: integer - Length of output array. - - Returns - ------- - arr: Array - Linearly spaced numeric array. - - Examples - -------- - > var arr = {{alias}}( 0, 100, 6 ) - [ 0, 20, 40, 60, 80, 100 ] - - See Also - -------- - diff --git a/base/linspace/docs/types/index.d.ts b/base/linspace/docs/types/index.d.ts deleted file mode 100644 index 5092b0d09..000000000 --- a/base/linspace/docs/types/index.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Generates a linearly spaced numeric array. -* -* @param x1 - first array value -* @param x2 - last array value -* @param len - length of output array -* @returns linearly spaced numeric array -* -* @example -* var arr = linspace( 0, 100, 6 ); -* // returns [ 0, 20, 40, 60, 80, 100 ] -*/ -declare function linspace( x1: number, x2: number, len: number ): Array; - - -// EXPORTS // - -export = linspace; diff --git a/base/linspace/docs/types/test.ts b/base/linspace/docs/types/test.ts deleted file mode 100644 index d72dff317..000000000 --- a/base/linspace/docs/types/test.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 linspace = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - linspace( 0, 11, 20 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided values other than two numbers for the first two parameters... -{ - linspace( true, 10 ); // $ExpectError - linspace( false, 10 ); // $ExpectError - linspace( '5', 10 ); // $ExpectError - linspace( [], 10 ); // $ExpectError - linspace( {}, 10 ); // $ExpectError - linspace( ( x: number ): number => x, 10 ); // $ExpectError - - linspace( 9, true ); // $ExpectError - linspace( 9, false ); // $ExpectError - linspace( 5, '5' ); // $ExpectError - linspace( 8, [] ); // $ExpectError - linspace( 9, {} ); // $ExpectError - linspace( 8, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a value other than a number for the third parameter... -{ - linspace( 3, 20, true ); // $ExpectError - linspace( 4, 20, false ); // $ExpectError - linspace( 2, 20, '5' ); // $ExpectError - linspace( 2, 20, [] ); // $ExpectError - linspace( 9, 20, {} ); // $ExpectError - linspace( 9, 20, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - linspace(); // $ExpectError - linspace( 3 ); // $ExpectError -} diff --git a/base/linspace/examples/index.js b/base/linspace/examples/index.js deleted file mode 100644 index d6231b324..000000000 --- a/base/linspace/examples/index.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 linspace = require( './../lib' ); - -// Create arrays of varying lengths: -var out = linspace( 0, 10, 10 ); -console.log( out ); - -out = linspace( 0, 10, 11 ); -console.log( out ); - -out = linspace( 0, 1, 21 ); -console.log( out ); - -// Create an array with decremented values: -out = linspace( 10, 0, 11 ); -console.log( out ); diff --git a/base/linspace/lib/index.js b/base/linspace/lib/index.js deleted file mode 100644 index 020405db7..000000000 --- a/base/linspace/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Generate a linearly spaced numeric array. -* -* @module @stdlib/array/base/linspace -* -* @example -* var linspace = require( '@stdlib/array/base/linspace' ); -* -* var arr = linspace( 0, 100, 6 ); -* // returns [ 0, 20, 40, 60, 80, 100 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/linspace/lib/main.js b/base/linspace/lib/main.js deleted file mode 100644 index f7f700456..000000000 --- a/base/linspace/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Generates a linearly spaced numeric array. -* -* @param {number} x1 - first array value -* @param {number} x2 - last array value -* @param {NonNegativeInteger} len - length of output array -* @returns {Array} linearly spaced numeric array -* -* @example -* var arr = linspace( 0, 100, 6 ); -* // returns [ 0, 20, 40, 60, 80, 100 ] -*/ -function linspace( x1, x2, len ) { - var arr; - var N; - var d; - var i; - - if ( len === 0 ) { - return []; - } - // Calculate the increment: - N = len - 1; - d = ( x2-x1 ) / N; - - // Build the output array... - arr = [ x1 ]; - for ( i = 1; i < N; i++ ) { - arr.push( x1 + (d*i) ); - } - arr.push( x2 ); - return arr; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/base/linspace/package.json b/base/linspace/package.json deleted file mode 100644 index 7c678cc23..000000000 --- a/base/linspace/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/linspace", - "version": "0.0.0", - "description": "Generate a linearly spaced numeric array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdmath", - "utilities", - "utils", - "mathematics", - "math", - "generic", - "array", - "matlab", - "linear", - "linspace" - ] -} diff --git a/base/linspace/test/test.js b/base/linspace/test/test.js deleted file mode 100644 index 5b6d6eef6..000000000 --- a/base/linspace/test/test.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 linspace = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof linspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a linearly spaced array', function test( t ) { - var expected; - var actual; - var start; - var stop; - - start = 0; - stop = 10; - - actual = linspace( start, stop, 10 ); - - // Verify correct length: - t.strictEqual( actual.length, 10, 'returns expected value' ); - - // Verify that the returned array includes the start and stop values: - t.strictEqual( actual[0], start, 'returns expected value' ); - t.strictEqual( actual[actual.length-1], 10, 'returns expected value' ); - - // Verify correct values: - actual = linspace( start, stop, 11 ); - expected = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - // Decrement: - actual = linspace( stop, start, 11 ); - expected = [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided a length equal to `0`', function test( t ) { - t.deepEqual( linspace( 0, 10, 0 ), [], 'returns expected value' ); - t.end(); -}); diff --git a/base/linspace2d/README.md b/base/linspace2d/README.md deleted file mode 100644 index 2a0cebf5b..000000000 --- a/base/linspace2d/README.md +++ /dev/null @@ -1,132 +0,0 @@ - - -# linspace2d - -> Generate a linearly spaced two-dimensional nested numeric array. - -
- -## Usage - -```javascript -var linspace2d = require( '@stdlib/array/base/linspace2d' ); -``` - -#### linspace2d( start, stop, shape, colexicographic ) - -Generates a linearly spaced two-dimensional nested numeric array. - -```javascript -var x = linspace2d( 0, 100, [ 2, 3 ], false ); -// returns [ [ 0, 20, 40 ], [ 60, 80, 100 ] ] - -x = linspace2d( 0, 100, [ 2, 3 ], true ); -// returns [ [ 0, 40, 80 ], [ 20, 60, 100 ] ] -``` - -The function accepts the following arguments: - -- **start**: first array value. -- **stop**: last array value. -- **shape**: array shape. -- **colexicographic**: specifies whether generated array values should be stored in colexicographic order. - -
- - - -
- -## Notes - -- The output array is guaranteed to include the `start` and `stop` values. Beware, however, that values between `start` and `stop` are subject to floating-point rounding errors. Hence, - - ```javascript - var arr = linspace2d( 0, 1, [ 1, 3 ], false ); - // returns [ [ 0, ~0.5, 1 ] ] - ``` - - where `arr[0][1]` is only guaranteed to be approximately equal to `0.5`. If you desire more control over element precision, consider using [`roundn`][@stdlib/math/base/special/roundn]: - - ```javascript - var roundn = require( '@stdlib/math/base/special/roundn' ); - var map2d = require( '@stdlib/array/base/map2d' ); - - var arr = linspace2d( 0, 1, [ 1, 3 ], false ); - // returns [ [ 0, ~0.5, 1 ] ] - - // Round each value to the nearest tenth: - var out = map2d( arr, [ 1, 3 ], clbk ); - // returns [ [ 0, 0.5, 1 ] ] - - function clbk( v ) { - return roundn( v, -1 ); - } - ``` - -
- - - -
- -## Examples - - - -```javascript -var linspace2d = require( '@stdlib/array/base/linspace2d' ); - -var out = linspace2d( 0, 10, [ 2, 5 ], false ); -console.log( out ); - -out = linspace2d( 0, 10, [ 2, 3 ], true ); -console.log( out ); - -out = linspace2d( 0, 10, [ 4, 2 ], true ); -console.log( out ); - -// Create an array of arrays with decremented values: -out = linspace2d( 10, 0, [ 2, 5 ], false ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/linspace2d/benchmark/benchmark.js b/base/linspace2d/benchmark/benchmark.js deleted file mode 100644 index 809b638de..000000000 --- a/base/linspace2d/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var linspace2d = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - var v; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace2d( 0.0, 100.0, [ 2, 3 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/linspace2d/benchmark/benchmark.size.js b/base/linspace2d/benchmark/benchmark.size.js deleted file mode 100644 index 997c4ac02..000000000 --- a/base/linspace2d/benchmark/benchmark.size.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var linspace2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace2d( 0.0, 100.0, [ N, N ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - f = createBenchmark( N ); - bench( pkg+'::square_matrix:size='+(N*N), f ); - } -} - -main(); diff --git a/base/linspace2d/docs/repl.txt b/base/linspace2d/docs/repl.txt deleted file mode 100644 index 5a8182902..000000000 --- a/base/linspace2d/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( start, stop, shape, colexicographic ) - Generates a linearly spaced two-dimensional nested numeric array. - - The output array is guaranteed to include the `start` and `stop` values. - - Parameters - ---------- - start: number - First array value. - - stop: number - Last array value. - - shape: Array - Array shape. - - colexicographic: boolean - Specifies whether generated array values should be stored in - colexicographic order. - - Returns - ------- - out: Array - Linearly spaced two-dimensional nested numeric array. - - Examples - -------- - > var arr = {{alias}}( 0, 10, [ 2, 3 ], false ) - [ [ 0, 2, 4 ], [ 6, 8, 10 ] ] - - See Also - -------- diff --git a/base/linspace2d/docs/types/index.d.ts b/base/linspace2d/docs/types/index.d.ts deleted file mode 100644 index 7d7589090..000000000 --- a/base/linspace2d/docs/types/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Two-dimensional nested array. -*/ -type Array2D = Array>; - -/** -* Generates a linearly spaced two-dimensional nested numeric array. -* -* @param start - first array value -* @param stop - last array value -* @param shape - array shape -* @param colexicographic - specifies whether generated array values should be stored in colexicographic order -* @returns linearly spaced two-dimensional nested numeric array -* -* @example -* var x = linspace2d( 0, 100, [ 2, 3 ], false ); -* // returns [ [ 0, 20, 40 ], [ 60, 80, 100 ] ] -* -* x = linspace2d( 0, 100, [ 2, 3 ], true ); -* // returns [ [ 0, 40, 80 ], [ 20, 60, 100 ] ] -*/ -declare function linspace2d( start: number, stop: number, shape: Shape2D, colexicographic: boolean ): Array2D; - - -// EXPORTS // - -export = linspace2d; diff --git a/base/linspace2d/docs/types/test.ts b/base/linspace2d/docs/types/test.ts deleted file mode 100644 index 03545e0a5..000000000 --- a/base/linspace2d/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import linspace2d = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - linspace2d( 0, 11, [ 2, 3 ], false ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided values other than two numbers for the first two parameters... -{ - linspace2d( true, 10, [ 2, 3 ], false ); // $ExpectError - linspace2d( false, 10, [ 2, 3 ], false ); // $ExpectError - linspace2d( '5', 10, [ 2, 3 ], false ); // $ExpectError - linspace2d( [], 10, [ 2, 3 ], false ); // $ExpectError - linspace2d( {}, 10, [ 2, 3 ], false ); // $ExpectError - linspace2d( ( x: number ): number => x, 10, [ 2, 3 ], false ); // $ExpectError - - linspace2d( 9, true, [ 2, 3 ], false ); // $ExpectError - linspace2d( 9, false, [ 2, 3 ], false ); // $ExpectError - linspace2d( 5, '5', [ 2, 3 ], false ); // $ExpectError - linspace2d( 8, [], [ 2, 3 ], false ); // $ExpectError - linspace2d( 9, {}, [ 2, 3 ], false ); // $ExpectError - linspace2d( 8, ( x: number ): number => x, [ 2, 3 ], false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a value other than an array of numbers for the third parameter... -{ - linspace2d( 3, 20, true, false ); // $ExpectError - linspace2d( 4, 20, false, false ); // $ExpectError - linspace2d( 2, 20, '5', false ); // $ExpectError - linspace2d( 2, 20, [], false ); // $ExpectError - linspace2d( 9, 20, {}, false ); // $ExpectError - linspace2d( 9, 20, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a value other than a boolean for the fourth parameter... -{ - linspace2d( 3, 20, [ 2, 3 ], false, '5' ); // $ExpectError - linspace2d( 4, 20, [ 2, 3 ], false, 2 ); // $ExpectError - linspace2d( 2, 20, [ 2, 3 ], false, [] ); // $ExpectError - linspace2d( 2, 20, [ 2, 3 ], false, {} ); // $ExpectError - linspace2d( 9, 20, [ 2, 3 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - linspace2d(); // $ExpectError - linspace2d( 3, 20 ); // $ExpectError - linspace2d( 3, 20, [ 2, 3 ] ); // $ExpectError - linspace2d( 3, 20, [ 2, 3 ], false, {} ); // $ExpectError -} diff --git a/base/linspace2d/examples/index.js b/base/linspace2d/examples/index.js deleted file mode 100644 index a4f07ee8f..000000000 --- a/base/linspace2d/examples/index.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var linspace2d = require( './../lib' ); - -var out = linspace2d( 0, 10, [ 2, 5 ], false ); -console.log( out ); - -out = linspace2d( 0, 10, [ 2, 3 ], true ); -console.log( out ); - -out = linspace2d( 0, 10, [ 4, 2 ], true ); -console.log( out ); - -// Create an array with decremented values: -out = linspace2d( 10, 0, [ 2, 5 ], false ); -console.log( out ); diff --git a/base/linspace2d/lib/index.js b/base/linspace2d/lib/index.js deleted file mode 100644 index e7ea25532..000000000 --- a/base/linspace2d/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Generate a linearly spaced two-dimensional nested numeric array. -* -* @module @stdlib/array/base/linspace2d -* -* @example -* var linspace2d = require( '@stdlib/array/base/linspace2d' ); -* -* var x = linspace2d( 0, 100, [ 2, 3 ], false ); -* // returns [ [ 0, 20, 40 ], [ 60, 80, 100 ] ] -* -* x = linspace2d( 0, 100, [ 2, 3 ], true ); -* // returns [ [ 0, 40, 80 ], [ 20, 60, 100 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/linspace2d/lib/main.js b/base/linspace2d/lib/main.js deleted file mode 100644 index a0e8c73fd..000000000 --- a/base/linspace2d/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Generates a linearly spaced two-dimensional nested numeric array. -* -* @param {number} start - first array value -* @param {number} stop - last array value -* @param {NonNegativeIntegerArray} shape - array shape -* @param {boolean} colexicographic - specifies whether generated array values should be stored in colexicographic order -* @returns {Array} linearly spaced two-dimensional nested numeric array -* -* @example -* var x = linspace2d( 0, 100, [ 2, 3 ], false ); -* // returns [ [ 0, 20, 40 ], [ 60, 80, 100 ] ] -* -* x = linspace2d( 0, 100, [ 2, 3 ], true ); -* // returns [ [ 0, 40, 80 ], [ 20, 60, 100 ] ] -*/ -function linspace2d( start, stop, shape, colexicographic ) { - var inc0; - var inc1; - var out; - var tmp; - var idx; - var s0; - var i0; - var s1; - var i1; - var d; - var n; - - s0 = shape[ 1 ]; - s1 = shape[ 0 ]; - - n = s0 * s1; - if ( n === 0 ) { - return []; - } - d = ( stop - start ) / ( n - 1 ); - if ( colexicographic ) { - inc0 = s1; // index increment for the innermost loop - inc1 = 1 - ( s0 * inc0 ); // index increment for the outermost loop - } else { - inc0 = 1; // index increment for the innermost loop - inc1 = 0; // index increment for the outermost loop - } - out = []; - idx = 0; - for ( i1 = 0; i1 < s1; i1++ ) { - tmp = []; - for ( i0 = 0; i0 < s0; i0++ ) { - tmp.push( start + ( idx * d ) ); - idx += inc0; - } - out.push( tmp ); - idx += inc1; - } - return out; -} - - -// EXPORTS // - -module.exports = linspace2d; diff --git a/base/linspace2d/package.json b/base/linspace2d/package.json deleted file mode 100644 index 42d31cfc8..000000000 --- a/base/linspace2d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/linspace2d", - "version": "0.0.0", - "description": "Generate a linearly spaced two-dimensional nested numeric array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdmath", - "utilities", - "utils", - "mathematics", - "math", - "generic", - "array", - "array2d", - "matlab", - "linear", - "linspace", - "linspace2d", - "nested" - ] -} diff --git a/base/linspace2d/test/test.js b/base/linspace2d/test/test.js deleted file mode 100644 index 9e82fc8a9..000000000 --- a/base/linspace2d/test/test.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var linspace2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof linspace2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a linearly spaced two-dimensional nested array', function test( t ) { - var expected; - var actual; - var start; - var stop; - var sh; - - start = 0; - stop = 10; - sh = [ 2, 3 ]; - - actual = linspace2d( start, stop, sh, false ); - - // Verify that the output is a nested array: - t.strictEqual( isArrayArray( actual ), true, 'returns expected value' ); - - // Verify that the returned array includes the start and stop values: - t.strictEqual( actual[0][0], start, 'returns expected value' ); - t.strictEqual( actual[actual.length-1][2], 10, 'returns expected value' ); - - // Verify correct values: - actual = linspace2d( 0, 100, sh, false ); - expected = [ [ 0, 20, 40 ], [ 60, 80, 100 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - // Decrement: - actual = linspace2d( 100, 0, sh, false ); - expected = [ [ 100, 80, 60 ], [ 40, 20, 0 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced two-dimensional nested array (colexicographic)', function test( t ) { - var expected; - var actual; - var start; - var stop; - var sh; - - start = 0; - stop = 10; - sh = [ 2, 3 ]; - - actual = linspace2d( start, stop, sh, true ); - - // Verify that the output is a nested array: - t.strictEqual( isArrayArray( actual ), true, 'returns expected value' ); - - // Verify that the returned array includes the start and stop values: - t.strictEqual( actual[0][0], start, 'returns expected value' ); - t.strictEqual( actual[actual.length-1][2], 10, 'returns expected value' ); - - // Verify correct values: - actual = linspace2d( 0, 100, sh, true ); - expected = [ [ 0, 40, 80 ], [ 20, 60, 100 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - // Decrement: - actual = linspace2d( 100, 0, sh, true ); - expected = [ [ 100, 60, 20 ], [ 80, 40, 0 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if the product of the number of rows and columns is `0`', function test( t ) { - t.deepEqual( linspace2d( 0, 10, [ 2, 0 ], false ), [], 'returns expected value' ); - t.end(); -}); diff --git a/base/logspace/README.md b/base/logspace/README.md deleted file mode 100644 index 9b3f9de33..000000000 --- a/base/logspace/README.md +++ /dev/null @@ -1,91 +0,0 @@ - - -# logspace - -> Generate a logarithmically spaced numeric array. - -
- -## Usage - -```javascript -var logspace = require( '@stdlib/array/base/logspace' ); -``` - -#### logspace( a, b, length ) - -Generates a logarithmically spaced numeric `array` between `10^a` and `10^b`. - -```javascript -var arr = logspace( 0, 2, 6 ); -// returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] -``` - -
- - - -
- -## Notes - -- The output `array` includes the values `10^a` and `10^b`. **Beware** of floating point errors, including for the first and last `array` elements. - -
- - - -
- -## Examples - - - -```javascript -var logspace = require( '@stdlib/array/base/logspace' ); - -var out = logspace( 0, 3, 100 ); -console.log( out.join( '\n' ) ); - -// Create an array with decremented values: -out = logspace( 3, 0, 10 ); -console.log( out.join( '\n' ) ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/logspace/benchmark/benchmark.js b/base/logspace/benchmark/benchmark.js deleted file mode 100644 index 6126eb27e..000000000 --- a/base/logspace/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var logspace = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = logspace( 0.0, 100.0, 10 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/logspace/benchmark/benchmark.length.js b/base/logspace/benchmark/benchmark.length.js deleted file mode 100644 index b157c093b..000000000 --- a/base/logspace/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var logspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = logspace( 0.0, 10.0, len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/logspace/docs/repl.txt b/base/logspace/docs/repl.txt deleted file mode 100644 index cc0bc9638..000000000 --- a/base/logspace/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( a, b, length ) - Generates a logarithmically spaced numeric array between `10^a` and `10^b`. - - The output array includes the values `10^a` and `10^b`. - - Parameters - ---------- - a: number - Exponent of start value. - - b: number - Exponent of end value. - - length: integer - Length of output array. - - Returns - ------- - out: Array - Logarithmically spaced numeric array. - - Examples - -------- - > var arr = {{alias}}( 0, 2, 6 ) - [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] - - See Also - -------- - diff --git a/base/logspace/docs/types/index.d.ts b/base/logspace/docs/types/index.d.ts deleted file mode 100644 index bc3fbd6b1..000000000 --- a/base/logspace/docs/types/index.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Generates a logarithmically spaced numeric array. -* -* @param a - exponent of start value -* @param b - exponent of end value -* @param len - length of output array -* @returns logarithmically spaced numeric array -* -* @example -* var arr = logspace( 0, 2, 6 ); -* // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] -*/ -declare function logspace( a: number, b: number, len: number ): Array; - - -// EXPORTS // - -export = logspace; diff --git a/base/logspace/docs/types/test.ts b/base/logspace/docs/types/test.ts deleted file mode 100644 index b0542f4bf..000000000 --- a/base/logspace/docs/types/test.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 logspace = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - logspace( 0, 11, 20 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided values other than two numbers for the first two parameters... -{ - logspace( true, 10, 10 ); // $ExpectError - logspace( false, 10, 10 ); // $ExpectError - logspace( '5', 10, 10 ); // $ExpectError - logspace( [], 10, 10 ); // $ExpectError - logspace( {}, 10, 10 ); // $ExpectError - logspace( ( x: number ): number => x, 10, 10 ); // $ExpectError - - logspace( 9, true, 10 ); // $ExpectError - logspace( 9, false, 10 ); // $ExpectError - logspace( 5, '5', 10 ); // $ExpectError - logspace( 8, [], 10 ); // $ExpectError - logspace( 9, {}, 10 ); // $ExpectError - logspace( 8, ( x: number ): number => x, 10 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a value other than a number for the third parameter... -{ - logspace( 3, 20, true ); // $ExpectError - logspace( 4, 20, false ); // $ExpectError - logspace( 2, 20, '5' ); // $ExpectError - logspace( 2, 20, [] ); // $ExpectError - logspace( 2, 20, {} ); // $ExpectError - logspace( 9, 20, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - logspace(); // $ExpectError - logspace( 3 ); // $ExpectError - logspace( 3, 10 ); // $ExpectError -} diff --git a/base/logspace/examples/index.js b/base/logspace/examples/index.js deleted file mode 100644 index 4d3b61f33..000000000 --- a/base/logspace/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 logspace = require( './../lib' ); - -console.log( '\nLength 100:' ); -var out = logspace( 0, 3, 100 ); -console.log( out.join( '\n' ) ); - -// Create an array with decremented values: -console.log( '\nDecremented:' ); -out = logspace( 3, 0, 10 ); -console.log( out.join( '\n' ) ); diff --git a/base/logspace/lib/index.js b/base/logspace/lib/index.js deleted file mode 100644 index 23850ef7d..000000000 --- a/base/logspace/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Generate a logarithmically spaced numeric array. -* -* @module @stdlib/array/base/logspace -* -* @example -* var logspace = require( '@stdlib/array/base/logspace' ); -* -* var arr = logspace( 0, 2, 6 ); -* // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/logspace/lib/main.js b/base/logspace/lib/main.js deleted file mode 100644 index d684a5cb3..000000000 --- a/base/logspace/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var pow = require( '@stdlib/math/base/special/pow' ); - - -// MAIN // - -/** -* Generates a logarithmically spaced numeric array. -* -* @param {number} a - exponent of start value -* @param {number} b - exponent of end value -* @param {NonNegativeInteger} len - length of output array -* @returns {Array} logarithmically spaced numeric array -* -* @example -* var arr = logspace( 0, 2, 6 ); -* // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] -*/ -function logspace( a, b, len ) { - var arr; - var N; - var d; - var i; - - if ( len === 0 ) { - return []; - } - // Calculate the increment: - N = len - 1; - d = ( b-a ) / N; - - // Build the output array... - arr = [ pow( 10, a ) ]; - for ( i = 1; i < N; i++ ) { - arr.push( pow( 10, a+(d*i) ) ); - } - arr.push( pow( 10, b ) ); - return arr; -} - - -// EXPORTS // - -module.exports = logspace; diff --git a/base/logspace/package.json b/base/logspace/package.json deleted file mode 100644 index 344a1f560..000000000 --- a/base/logspace/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/logspace", - "version": "0.0.0", - "description": "Generate a logarithmically spaced numeric array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "matlab", - "linear", - "log", - "logarithmic" - ] -} diff --git a/base/logspace/test/test.js b/base/logspace/test/test.js deleted file mode 100644 index a3a118a24..000000000 --- a/base/logspace/test/test.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 logspace = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof logspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a logarithmically spaced array', function test( t ) { - var expected; - var actual; - var a; - var b; - - a = 0; - b = 3; - - actual = logspace( a, b, 10 ); - - // Verify the correct length: - t.strictEqual( actual.length, 10, 'returns expected value' ); - - // Verify that the array includes start and stop values: - t.strictEqual( actual[ 0 ], 1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 1000, 'returns expected value' ); - - // Verify correct values: - actual = logspace( a, b, 4 ); - expected = [ 1, 10, 100, 1000 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - // Decrement: - actual = logspace( b, a, 4 ); - expected = [ 1000, 100, 10, 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if the provided length is `0`', function test( t ) { - t.deepEqual( logspace( 0, 10, 0 ), [], 'returns expected value' ); - t.end(); -}); diff --git a/base/map/README.md b/base/map/README.md deleted file mode 100644 index 2aba1ec0b..000000000 --- a/base/map/README.md +++ /dev/null @@ -1,191 +0,0 @@ - - -# map - -> Apply a callback function to elements in an input array and assign results to elements in a new output array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var map = require( '@stdlib/array/base/map' ); -``` - -#### map( x, fcn\[, thisArg] ) - -Applies a callback function to elements in an input array and assigns results to elements in a new output array. - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ -1.0, -2.0, -3.0, -4.0 ]; - -var y = map( x, naryFunction( abs, 1 ) ); -// returns [ 1.0, 2.0, 3.0, 4.0 ] -``` - -The function accepts the following arguments: - -- **x**: input array. -- **fcn**: callback function. -- **thisArg**: callback execution context (_optional_). - -To set the callback function's execution context, provide a `thisArg`. - - - -```javascript -function count( x ) { - this.count += 1; - return x; -} - -var x = [ 1.0, 2.0, 3.0, 4.0 ]; - -var ctx = { - 'count': 0 -}; - -var y = map( x, count, ctx ); -// returns [ 1.0, 2.0, 3.0, 4.0 ] - -var v = ctx.count; -// returns 4 -``` - -The callback function is provided the following arguments: - -- **value**: current array element. -- **index**: current element index. -- **arr**: input array. - -#### map.assign( x, y, stride, offset, fcn\[, thisArg] ) - -Applies a callback function to elements in an input array and assigns results to elements in an output array. - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var zeros = require( '@stdlib/array/base/zeros' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ -1.0, -2.0, -3.0, -4.0 ]; - -var y = zeros( x.length ); - -var out = map.assign( x, y, 1, 0, naryFunction( abs, 1 ) ); -// returns [ 1.0, 2.0, 3.0, 4.0 ] - -var bool = ( out === y ); -// returns true -``` - -The function accepts the following arguments: - -- **x**: input array. -- **y**: output array. -- **stride**: stride length for output array. -- **offset**: starting index for output array. -- **fcn**: callback function. -- **thisArg**: callback execution context (_optional_). - -
- - - - - -
- -## Notes - -- If provided an array-like object having a `map` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.map( fcn, thisArg ) - ``` - -- The function supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var map = require( '@stdlib/array/base/map' ); - -var x = discreteUniform( 10, -10, 10, { - 'dtype': 'float64' -}); - -var y = map( x, naryFunction( abs, 1 ) ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/map/benchmark/benchmark.assign.js b/base/map/benchmark/benchmark.assign.js deleted file mode 100644 index b95699c54..000000000 --- a/base/map/benchmark/benchmark.assign.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var uniform = require( '@stdlib/random/array/uniform' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var map = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var y; - - x = uniform( len, -100.0, 100.0, { - 'dtype': 'generic' - }); - y = zeros( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map( x, y, 1, 0, identity ); - if ( isnan( out[ i%len ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - if ( isnan( out[ i % len ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':assign:dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/map/benchmark/benchmark.js b/base/map/benchmark/benchmark.js deleted file mode 100644 index c57bee8ba..000000000 --- a/base/map/benchmark/benchmark.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var uniform = require( '@stdlib/random/array/uniform' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var pkg = require( './../package.json' ).name; -var map = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = uniform( len, -100.0, 100.0, { - 'dtype': 'generic' - }); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map( x, identity ); - if ( isnan( out[ i%len ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - if ( isnan( out[ i % len ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/map/docs/repl.txt b/base/map/docs/repl.txt deleted file mode 100644 index 980ebde95..000000000 --- a/base/map/docs/repl.txt +++ /dev/null @@ -1,80 +0,0 @@ - -{{alias}}( x, fcn[, thisArg] ) - Applies a callback function to elements in an input array and assigns - results to elements in a new output array. - - The callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - If provided an array-like object having a `map` method, the function defers - execution to that method and assumes that the method has the following - signature: - - x.map( fcn, thisArg ) - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - fcn: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array|TypedArray|Object - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var y = {{alias}}( x, {{alias:@stdlib/math/base/special/abs}} ) - [ 1, 2, 3, 4 ] - - -{{alias}}.assign( x, y, stride, offset, fcn[, thisArg] ) - Applies a callback function to elements in an input array and assigns - results to elements in an output array. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - y: Array|TypedArray|Object - Output array. - - stride: integer - Stride length for output array. - - offset: integer - Starting index for output array. - - fcn: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array|TypedArray|Object - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var y = [ 0, 0, 0, 0 ]; - > var out = {{alias}}.assign( x, y, 1, 0, {{alias:@stdlib/math/base/special/abs}} ) - [ 1, 2, 3, 4 ] - > var bool = ( out === y ) - true - - See Also - -------- diff --git a/base/map/docs/types/index.d.ts b/base/map/docs/types/index.d.ts deleted file mode 100644 index 3aafce3ca..000000000 --- a/base/map/docs/types/index.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray } from '@stdlib/types/array'; - -/** -* Input array. -*/ -type InputArray = Collection | AccessorArrayLike; - -/** -* Output array. -*/ -type OutputArray = Collection | AccessorArrayLike; - -/** -* Interface for an object having a `map` method. -*/ -interface ObjectWithMap { - /** - * Invokes a callback for each element in an array and assigns results to a new output array. - * - * @param clbk - callback to apply - * @param thisArg - callback execution context - * @returns output array - */ - map( clbk: Callback, V, unknown>, thisArg?: unknown ): ObjectWithMap; -} - -/** -* An array having a `map` method. -*/ -type ArrayWithMap = InputArray & ObjectWithMap; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: ThisArg ) => V; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -* @returns result -*/ -type Unary = ( this: ThisArg, value: T ) => V; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -* @param index - current array element index -* @returns result -*/ -type Binary = ( this: ThisArg, value: T, index: number ) => V; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns result -*/ -type Ternary = ( this: ThisArg, value: T, index: number, arr: U ) => V; - -/** -* Callback invoked for each array element. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a callback function to elements in an input array and assigns results to elements in a new output array. - * - * @param x - input array object - * @param fcn - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var ones = require( './../../../../base/ones' ); - * - * function scale( v ) { - * return v * 10; - * } - * - * var x = ones( 4 ); - * // returns [ 0, 0, 0, 0 ] - * - * var y = map( x, scale ); - * // returns [ 10, 10, 10, 10 ] - */ - = Array, V = unknown, W extends Array = Array, ThisArg = unknown>( x: U, fcn: Callback, thisArg?: ThisParameterType> ): W; - - /** - * Applies a callback function to elements in an input array and assigns results to elements in a new output array. - * - * @param x - input array object - * @param fcn - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var ones = require( './../../../../ones' ); - * - * function scale( v ) { - * return v * 10; - * } - * - * var x = ones( 4, 'int32' ); - * // returns [ 0, 0, 0, 0 ] - * - * var y = map( x, scale ); - * // returns [ 10, 10, 10, 10 ] - */ - ( x: U, fcn: Callback, thisArg?: ThisParameterType> ): U; - - /** - * Applies a callback function to elements in an input array and assigns results to elements in a new output array. - * - * ## Notes - * - * - We assume that an input array having a `map` method returns an array of the same class, and, thus, the output array should also have a `map` method. - * - * @param x - input array object - * @param fcn - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var ones = require( './../../../../base/ones' ); - * - * function scale( v ) { - * return v * 10; - * } - * - * var x = ones( 4 ); - * // returns [ 0, 0, 0, 0 ] - * - * var y = map( x, scale ); - * // returns [ 10, 10, 10, 10 ] - */ - = ArrayWithMap, V = unknown, W extends ArrayWithMap = ArrayWithMap, ThisArg = unknown>( x: U, fcn: Callback, thisArg?: ThisParameterType> ): W; - - /** - * Applies a callback function to elements in an input array and assigns results to elements in a new output array. - * - * ## Notes - * - * - When an input array does not have a `map` method, we always return a new "generic" array. - * - * @param x - input array object - * @param fcn - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var toAccessorArray = require( './../../../../to-accessor-array' ); - * var ones = require( './../../../../base/ones' ); - * - * function scale( v ) { - * return v * 10; - * } - * - * var x = ones( 4 ); - * // returns [ 0, 0, 0, 0 ] - * - * var y = map( toAccessorArray( x ), scale ); - * // returns [ 10, 10, 10, 10 ] - */ - = InputArray, V = unknown, ThisArg = unknown>( x: U, fcn: Callback, thisArg?: ThisParameterType> ): Array; - - /** - * Applies a callback function to elements in an input array and assigns results to elements in an output array. - * - * @param x - input array object - * @param y - output array object - * @param stride - stride length for output array - * @param offset - starting index for output array - * @param fcn - callback function - * @param thisArg - callback execution context - * @returns output array object - * - * @example - * var ones = require( './../../../../base/ones' ); - * var zeros = require( './../../../../base/zeros' ); - * - * function scale( v ) { - * return v * 10; - * } - * var x = ones( 4 ); - * var y = zeros( x.length ); - * - * var out = map.assign( x, y, 1, 0, scale ); - * // returns [ 10, 10, 10, 10 ] - * - * var bool = ( out === y ); - * // returns true - * - * @example - * var toAccessorArray = require( './../../../../to-accessor-array' ); - * var ones = require( './../../../../base/ones' ); - * var zeros = require( './../../../../base/zeros' ); - * - * function scale( v ) { - * return v * 10; - * } - * var x = ones( 4 ); - * var y = zeros( x.length ); - * - * var out = map.assign( toAccessorArray( x ), toAccessorArray( y ), 1, 0 scale ); - * // y => [ 10, 10, 10, 10 ] - */ - assign = InputArray, V = unknown, W extends OutputArray = OutputArray, ThisArg = unknown>( x: U, y: W, stride: number, offset: number, fcn: Callback, thisArg?: ThisParameterType> ): W; -} - -/** -* Applies a callback function to elements in an input array and assigns results to elements in a new output array. -* -* @param x - input array -* @param fcn - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var ones = require( '@stdlib/array/base/ones' ); -* -* function scale( v ) { -* return v * 10; -* } -* -* var x = ones( 4 ); -* var y = map( x, scale ); -* // returns [ 10, 10, 10, 10 ] -* -* @example -* var ones = require( '@stdlib/array/base/ones' ); -* var zeros = require( '@stdlib/array/base/zeros' ); -* -* function scale( v ) { -* return v * 10; -* } -* -* var x = ones( 4 ); -* var y = zeros( x.length ); -* -* var out = map.assign( x, y, 1, 0, scale ); -* // y => [ 10, 10, 10, 10 ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map: Routine; - - -// EXPORTS // - -export = map; diff --git a/base/map/docs/types/test.ts b/base/map/docs/types/test.ts deleted file mode 100644 index 06cc24320..000000000 --- a/base/map/docs/types/test.ts +++ /dev/null @@ -1,263 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import map = require( './index' ); - -/** -* Callback function. -* -* @param v - input value -* @returns output value -*/ -function fcn( v: number ): number { - return v * 2; -} - - -// TESTS // - -// The function returns an array... -{ - const x = [ 1, 2, 3 ]; - - map( x, fcn ); // $ExpectType number[] - map( new Float64Array( x ), fcn ); // $ExpectType Float64Array - map( new Float32Array( x ), fcn ); // $ExpectType Float32Array - map( new Int32Array( x ), fcn ); // $ExpectType Int32Array - map( new Int16Array( x ), fcn ); // $ExpectType Int16Array - map( new Int8Array( x ), fcn ); // $ExpectType Int8Array - map( new Uint32Array( x ), fcn ); // $ExpectType Uint32Array - map( new Uint16Array( x ), fcn ); // $ExpectType Uint16Array - map( new Uint8Array( x ), fcn ); // $ExpectType Uint8Array - map( new Uint8ClampedArray( x ), fcn ); // $ExpectType Uint8ClampedArray - map( toAccessorArray( x ), fcn ); // $ExpectType number[] - - map( x, fcn, {} ); // $ExpectType number[] - map( new Float64Array( x ), fcn, {} ); // $ExpectType Float64Array - map( new Float32Array( x ), fcn, {} ); // $ExpectType Float32Array - map( new Int32Array( x ), fcn, {} ); // $ExpectType Int32Array - map( new Int16Array( x ), fcn, {} ); // $ExpectType Int16Array - map( new Int8Array( x ), fcn, {} ); // $ExpectType Int8Array - map( new Uint32Array( x ), fcn, {} ); // $ExpectType Uint32Array - map( new Uint16Array( x ), fcn, {} ); // $ExpectType Uint16Array - map( new Uint8Array( x ), fcn, {} ); // $ExpectType Uint8Array - map( new Uint8ClampedArray( x ), fcn, {} ); // $ExpectType Uint8ClampedArray - map( toAccessorArray( x ), fcn, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - map( 'abc', fcn ); // $ExpectError - map( 3.14, fcn ); // $ExpectError - map( true, fcn ); // $ExpectError - map( false, fcn ); // $ExpectError - map( null, fcn ); // $ExpectError - map( {}, fcn ); // $ExpectError - map( ( x: number ): number => x, fcn ); // $ExpectError - - map( 'abc', fcn, {} ); // $ExpectError - map( 3.14, fcn, {} ); // $ExpectError - map( true, fcn, {} ); // $ExpectError - map( false, fcn, {} ); // $ExpectError - map( null, fcn, {} ); // $ExpectError - map( {}, fcn, {} ); // $ExpectError - map( ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - map( [ 1, 2, 3 ], 'abc' ); // $ExpectError - map( [ 1, 2, 3 ], 2 ); // $ExpectError - map( [ 1, 2, 3 ], false ); // $ExpectError - map( [ 1, 2, 3 ], true ); // $ExpectError - map( [ 1, 2, 3 ], null ); // $ExpectError - map( [ 1, 2, 3 ], void 0 ); // $ExpectError - map( [ 1, 2, 3 ], {} ); // $ExpectError - map( [ 1, 2, 3 ], [] ); // $ExpectError - - map( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - map( [ 1, 2, 3 ], 2, {} ); // $ExpectError - map( [ 1, 2, 3 ], false, {} ); // $ExpectError - map( [ 1, 2, 3 ], true, {} ); // $ExpectError - map( [ 1, 2, 3 ], null, {} ); // $ExpectError - map( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - map( [ 1, 2, 3 ], {}, {} ); // $ExpectError - map( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - map(); // $ExpectError - map( [ 1, 2, 3 ] ); // $ExpectError - map( [ 1, 2, 3 ], fcn, {}, 3 ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 1, 2, 3 ]; - const y = [ 0, 0, 0 ]; - - map.assign( x, y, 1, 0, fcn ); // $ExpectType number[] - map.assign( new Float64Array( x ), new Float64Array( y ), 1, 0, fcn ); // $ExpectType Float64Array - map.assign( new Float32Array( x ), new Float32Array( y ), 1, 0, fcn ); // $ExpectType Float32Array - map.assign( new Int32Array( x ), new Int32Array( y ), 1, 0, fcn ); // $ExpectType Int32Array - map.assign( new Int16Array( x ), new Int16Array( y ), 1, 0, fcn ); // $ExpectType Int16Array - map.assign( new Int8Array( x ), new Int8Array( y ), 1, 0, fcn ); // $ExpectType Int8Array - map.assign( new Uint32Array( x ), new Uint32Array( y ), 1, 0, fcn ); // $ExpectType Uint32Array - map.assign( new Uint16Array( x ), new Uint16Array( y ), 1, 0, fcn ); // $ExpectType Uint16Array - map.assign( new Uint8Array( x ), new Uint8Array( y ), 1, 0, fcn ); // $ExpectType Uint8Array - map.assign( new Uint8ClampedArray( x ), new Uint8ClampedArray( y ), 1, 0, fcn ); // $ExpectType Uint8ClampedArray - map.assign( toAccessorArray( x ), y, 1, 0, fcn ); // $ExpectType number[] - map.assign( toAccessorArray( x ), toAccessorArray( y ), 1, 0, fcn ); // $ExpectType AccessorArrayLike - - map.assign( x, y, 1, 0, fcn, {} ); // $ExpectType number[] - map.assign( new Float64Array( x ), new Float64Array( y ), 1, 0, fcn, {} ); // $ExpectType Float64Array - map.assign( new Float32Array( x ), new Float32Array( y ), 1, 0, fcn, {} ); // $ExpectType Float32Array - map.assign( new Int32Array( x ), new Int32Array( y ), 1, 0, fcn, {} ); // $ExpectType Int32Array - map.assign( new Int16Array( x ), new Int16Array( y ), 1, 0, fcn, {} ); // $ExpectType Int16Array - map.assign( new Int8Array( x ), new Int8Array( y ), 1, 0, fcn, {} ); // $ExpectType Int8Array - map.assign( new Uint32Array( x ), new Uint32Array( y ), 1, 0, fcn, {} ); // $ExpectType Uint32Array - map.assign( new Uint16Array( x ), new Uint16Array( y ), 1, 0, fcn, {} ); // $ExpectType Uint16Array - map.assign( new Uint8Array( x ), new Uint8Array( y ), 1, 0, fcn, {} ); // $ExpectType Uint8Array - map.assign( new Uint8ClampedArray( x ), new Uint8ClampedArray( y ), 1, 0, fcn, {} ); // $ExpectType Uint8ClampedArray - map.assign( toAccessorArray( x ), y, 1, 0, fcn, {} ); // $ExpectType number[] - map.assign( toAccessorArray( x ), toAccessorArray( y ), 1, 0, fcn, {} ); // $ExpectType AccessorArrayLike -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a collection... -{ - const y = [ 0, 0, 0 ]; - - map.assign( 2, y, 1, 0, fcn ); // $ExpectError - map.assign( false, y, 1, 0, fcn ); // $ExpectError - map.assign( true, y, 1, 0, fcn ); // $ExpectError - map.assign( null, y, 1, 0, fcn ); // $ExpectError - map.assign( void 0, y, 1, 0, fcn ); // $ExpectError - map.assign( {}, y, 1, 0, fcn ); // $ExpectError - - map.assign( 2, y, 1, 0, fcn, {} ); // $ExpectError - map.assign( false, y, 1, 0, fcn, {} ); // $ExpectError - map.assign( true, y, 1, 0, fcn, {} ); // $ExpectError - map.assign( null, y, 1, 0, fcn, {} ); // $ExpectError - map.assign( void 0, y, 1, 0, fcn, {} ); // $ExpectError - map.assign( {}, y, 1, 0, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a collection... -{ - const x = [ 1, 2, 3 ]; - - map.assign( x, 2, 1, 0, fcn ); // $ExpectError - map.assign( x, false, 1, 0, fcn ); // $ExpectError - map.assign( x, true, 1, 0, fcn ); // $ExpectError - map.assign( x, null, 1, 0, fcn ); // $ExpectError - map.assign( x, void 0, 1, 0, fcn ); // $ExpectError - map.assign( x, {}, 1, 0, fcn ); // $ExpectError - - map.assign( x, 2, 1, 0, fcn, {} ); // $ExpectError - map.assign( x, false, 1, 0, fcn, {} ); // $ExpectError - map.assign( x, true, 1, 0, fcn, {} ); // $ExpectError - map.assign( x, null, 1, 0, fcn, {} ); // $ExpectError - map.assign( x, void 0, 1, 0, fcn, {} ); // $ExpectError - map.assign( x, {}, 1, 0, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - const y = [ 0, 0, 0 ]; - - map.assign( x, y, '5', 0, fcn ); // $ExpectError - map.assign( x, y, false, 0, fcn ); // $ExpectError - map.assign( x, y, true, 0, fcn ); // $ExpectError - map.assign( x, y, null, 0, fcn ); // $ExpectError - map.assign( x, y, void 0, 0, fcn ); // $ExpectError - map.assign( x, y, {}, 0, fcn ); // $ExpectError - map.assign( x, y, [], 0, fcn ); // $ExpectError - map.assign( x, y, ( x: number ): number => x, 0, fcn ); // $ExpectError - - map.assign( x, y, '5', 0, fcn, {} ); // $ExpectError - map.assign( x, y, false, 0, fcn, {} ); // $ExpectError - map.assign( x, y, true, 0, fcn, {} ); // $ExpectError - map.assign( x, y, null, 0, fcn, {} ); // $ExpectError - map.assign( x, y, void 0, 0, fcn, {} ); // $ExpectError - map.assign( x, y, {}, 0, fcn, {} ); // $ExpectError - map.assign( x, y, [], 0, fcn, {} ); // $ExpectError - map.assign( x, y, ( x: number ): number => x, 0, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - const y = [ 0, 0, 0 ]; - - map.assign( x, y, 1, '5', fcn ); // $ExpectError - map.assign( x, y, 1, false, fcn ); // $ExpectError - map.assign( x, y, 1, true, fcn ); // $ExpectError - map.assign( x, y, 1, null, fcn ); // $ExpectError - map.assign( x, y, 1, void 0, fcn ); // $ExpectError - map.assign( x, y, 1, {}, fcn ); // $ExpectError - map.assign( x, y, 1, [], fcn ); // $ExpectError - map.assign( x, y, 1, ( x: number ): number => x, fcn ); // $ExpectError - - map.assign( x, y, 1, '5', fcn, {} ); // $ExpectError - map.assign( x, y, 1, false, fcn, {} ); // $ExpectError - map.assign( x, y, 1, true, fcn, {} ); // $ExpectError - map.assign( x, y, 1, null, fcn, {} ); // $ExpectError - map.assign( x, y, 1, void 0, fcn, {} ); // $ExpectError - map.assign( x, y, 1, {}, fcn, {} ); // $ExpectError - map.assign( x, y, 1, [], fcn, {} ); // $ExpectError - map.assign( x, y, 1, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a function... -{ - const x = [ 1, 2, 3 ]; - const y = [ 0, 0, 0 ]; - - map.assign( x, y, 1, 0, '5' ); // $ExpectError - map.assign( x, y, 1, 0, 5 ); // $ExpectError - map.assign( x, y, 1, 0, false ); // $ExpectError - map.assign( x, y, 1, 0, true ); // $ExpectError - map.assign( x, y, 1, 0, null ); // $ExpectError - map.assign( x, y, 1, 0, void 0 ); // $ExpectError - map.assign( x, y, 1, 0, {} ); // $ExpectError - map.assign( x, y, 1, 0, [] ); // $ExpectError - - map.assign( x, y, 1, 0, '5', {} ); // $ExpectError - map.assign( x, y, 1, 0, 5, {} ); // $ExpectError - map.assign( x, y, 1, 0, false, {} ); // $ExpectError - map.assign( x, y, 1, 0, true, {} ); // $ExpectError - map.assign( x, y, 1, 0, null, {} ); // $ExpectError - map.assign( x, y, 1, 0, void 0, {} ); // $ExpectError - map.assign( x, y, 1, 0, {}, {} ); // $ExpectError - map.assign( x, y, 1, 0, [], {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - const y = [ 0, 0, 0 ]; - - map.assign(); // $ExpectError - map.assign( x ); // $ExpectError - map.assign( x, y ); // $ExpectError - map.assign( x, y, 1, 0 ); // $ExpectError - map.assign( x, y, 1, 0, fcn, {}, {} ); // $ExpectError -} diff --git a/base/map/examples/index.js b/base/map/examples/index.js deleted file mode 100644 index 43971acdc..000000000 --- a/base/map/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var map = require( './../lib' ); - -var x = discreteUniform( 10, -10, 10, { - 'dtype': 'float64' -}); -console.log( x ); - -var y = map( x, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/base/map/lib/assign.js b/base/map/lib/assign.js deleted file mode 100644 index 3b28e967f..000000000 --- a/base/map/lib/assign.js +++ /dev/null @@ -1,164 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Applies a callback function to elements in an input array and assigns results to elements in an output array. -* -* @private -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {integer} stride - stride length for output array -* @param {NonNegativeInteger} offset - starting index for output array -* @param {Function} fcn - callback function -* @param {*} thisArg - callback execution context -* @returns {Collection} output array -* -* @example -* var ones = require( '@stdlib/array/base/ones' ); -* var zeros = require( '@stdlib/array/base/zeros' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var x = ones( 4 ); -* var y = zeros( x.length ); -* var out = internal( x, y, 1, 0, scale ); -* // returns [ 10.0, 10.0, 10.0, 10.0 ] -* -* var bool = ( out === y ); -* // returns true -*/ -function internal( x, y, stride, offset, fcn, thisArg ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - y[ io ] = fcn.call( thisArg, x[ i ], i, x ); - io += stride; - } - return y; -} - -/** -* Applies a callback function to elements in an input array and assigns results to elements in an output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} y - output array object -* @param {integer} stride - stride length for output array -* @param {NonNegativeInteger} offset - starting index for output array -* @param {Function} fcn - callback function -* @param {*} thisArg - callback execution context -* @returns {Object} output array object -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* var ones = require( '@stdlib/array/base/ones' ); -* var zeros = require( '@stdlib/array/base/zeros' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var x = ones( 4 ); -* var y = zeros( x.length ); -* -* var out = accessors( arraylike2object( toAccessorArray( x ) ), arraylike2object( toAccessorArray( y ) ), 1, 0, scale ); -* // y => [ 10.0, 10.0, 10.0, 10.0 ] -*/ -function accessors( x, y, stride, offset, fcn, thisArg ) { - var xdata; - var ydata; - var xget; - var yset; - var io; - var i; - - xdata = x.data; - ydata = y.data; - xget = x.accessors[ 0 ]; - yset = y.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - yset( ydata, io, fcn.call( thisArg, xget( xdata, i ), i, xdata ) ); - io += stride; - } - return y; -} - - -// MAIN // - -/** -* Applies a callback function to elements in an input array and assigns results to elements in an output array. -* -* @param {Collection} x - input array -* @param {Collection} y - output array -* @param {integer} stride - stride length for output array -* @param {NonNegativeInteger} offset - starting index for output array -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Collection} output array -* -* @example -* var ones = require( '@stdlib/array/base/ones' ); -* var zeros = require( '@stdlib/array/base/zeros' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var x = ones( 4 ); -* var y = zeros( x.length ); -* -* var out = assign( x, y, 1, 0, scale ); -* // returns [ 10.0, 10.0, 10.0, 10.0 ] -* -* var bool = ( out === y ); -* // returns true -*/ -function assign( x, y, stride, offset, fcn, thisArg ) { - var xobj; - var yobj; - - xobj = arraylike2object( x ); - yobj = arraylike2object( y ); - if ( xobj.accessorProtocol || yobj.accessorProtocol ) { - accessors( xobj, yobj, stride, offset, fcn, thisArg ); - return y; - } - return internal( x, y, stride, offset, fcn, thisArg ); -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/map/lib/index.js b/base/map/lib/index.js deleted file mode 100644 index 2ed13b947..000000000 --- a/base/map/lib/index.js +++ /dev/null @@ -1,73 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a callback function to elements in an input array and assign results to elements in a new output array. -* -* @module @stdlib/array/base/map -* -* @example -* var ones = require( '@stdlib/array/base/ones' ); -* var map = require( '@stdlib/array/base/map' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var x = ones( 4 ); -* var y = map( x, scale ); -* // returns [ 10.0, 10.0, 10.0, 10.0 ] -* -* @example -* var ones = require( '@stdlib/array/base/ones' ); -* var zeros = require( '@stdlib/array/base/zeros' ); -* var map = require( '@stdlib/array/base/map' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var x = ones( 4 ); -* var y = zeros( x.length ); -* -* var out = map.assign( x, y, scale ); -* // returns [ 10.0, 10.0, 10.0, 10.0 ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; - -// exports: { "assign": "main.assign" } diff --git a/base/map/lib/main.js b/base/map/lib/main.js deleted file mode 100644 index 525d41f97..000000000 --- a/base/map/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var zeros = require( './../../../base/zeros' ); -var assign = require( './assign.js' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'map' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - - -// MAIN // - -/** -* Applies a callback function to elements in an input array and assigns results to elements in a new output array. -* -* @param {Collection} x - input array -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Collection} output array -* -* @example -* var ones = require( '@stdlib/array/base/ones' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var x = ones( 4 ); -* var y = map( x, scale ); -* // returns [ 10.0, 10.0, 10.0, 10.0 ] -*/ -function map( x, fcn, thisArg ) { - if ( hasMethod( x, 'map' ) ) { - return x.map( fcn, thisArg ); - } - return assign( x, zeros( x.length ), 1, 0, fcn, thisArg ); -} - - -// EXPORTS // - -module.exports = map; diff --git a/base/map/package.json b/base/map/package.json deleted file mode 100644 index 07a44c573..000000000 --- a/base/map/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/map", - "version": "0.0.0", - "description": "Apply a callback function to elements in an input array and assign results to elements in a new output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "foreach", - "for-each", - "generic", - "callback", - "map", - "array.map" - ] -} diff --git a/base/map/test/test.assign.js b/base/map/test/test.assign.js deleted file mode 100644 index 322cb7d9b..000000000 --- a/base/map/test/test.assign.js +++ /dev/null @@ -1,433 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var zeros = require( './../../../base/zeros' ); -var map = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to elements in an input array and assigns results to elements in an output array (generic)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = zeros( x.length ); - expected = [ 10, 20, 30, 40 ]; - - out = map( x, y, 1, 0, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function applies a provided callback to elements in an input array and assigns results to elements in an output array (typed array)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( x.length ); - expected = new Float64Array( [ 10.0, 20.0, 30.0, 40.0 ] ); - - out = map( x, y, 1, 0, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'the function applies a provided callback to elements in an input array and assigns results to elements in an output array (accessors)', function test( t ) { - var expected; - var ybuf; - var out; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - ybuf = zeros( x.length ); - y = toAccessorArray( ybuf ); - - expected = [ 10, 20, 30, 40 ]; - - out = map( toAccessorArray( x ), y, 1, 0, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function applies a provided callback to elements in an input array and assigns results to elements in an output array (array-like object)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - y = zeros( x.length ); - expected = [ 10, 20, 30, 40 ]; - - out = map( x, y, 1, 0, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var out; - var ctx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = zeros( x.length ); - ctx = { - 'factor': 10 - }; - expected = [ 10, 20, 30, 40 ]; - - out = map( x, y, 1, 0, scale, ctx ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * this.factor; // eslint-disable-line no-invalid-this - } -}); - -tape( 'the function supports providing a `stride` parameter (generic)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = zeros( x.length * 2 ); - expected = [ 10, 0, 20, 0, 30, 0, 40, 0 ]; - - out = map( x, y, 2, 0, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function supports providing a `stride` parameter (typed array)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( x.length * 2 ); - expected = new Float64Array( [ 10.0, 0.0, 20.0, 0.0, 30.0, 0.0, 40.0, 0.0 ] ); // eslint-disable-line max-len - - out = map( x, y, 2, 0, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'the function supports providing a `stride` parameter (accessors)', function test( t ) { - var expected; - var ybuf; - var out; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - ybuf = zeros( x.length * 2 ); - y = toAccessorArray( ybuf ); - - expected = [ 10, 0, 20, 0, 30, 0, 40, 0 ]; - - out = map( toAccessorArray( x ), y, 2, 0, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function supports providing a `stride` parameter (array-like object)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - y = zeros( x.length * 2 ); - expected = [ 10, 0, 20, 0, 30, 0, 40, 0 ]; - - out = map( x, y, 2, 0, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function supports providing a negative `stride` parameter (generic)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = zeros( x.length ); - expected = [ 40, 30, 20, 10 ]; - - out = map( x, y, -1, 3, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function supports providing a negative `stride` parameter (typed array)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( x.length ); - expected = new Float64Array( [ 40, 30, 20, 10 ] ); - - out = map( x, y, -1, 3, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'the function supports providing a negative `stride` parameter (accessors)', function test( t ) { - var expected; - var ybuf; - var out; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - ybuf = zeros( x.length ); - y = toAccessorArray( ybuf ); - - expected = [ 40, 30, 20, 10 ]; - - out = map( toAccessorArray( x ), y, -1, 3, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function supports providing a negative `stride` parameter (array-like object)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - y = zeros( x.length ); - expected = [ 40, 30, 20, 10 ]; - - out = map( x, y, -1, 3, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function supports providing an `offset` parameter (generic)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = zeros( x.length * 2 ); - expected = [ 0, 10, 0, 20, 0, 30, 0, 40 ]; - - out = map( x, y, 2, 1, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function supports providing an `offset` parameter (typed array)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - y = new Float64Array( x.length * 2 ); - expected = new Float64Array( [ 0.0, 10.0, 0.0, 20.0, 0.0, 30.0, 0.0, 40.0 ] ); // eslint-disable-line max-len - - out = map( x, y, 2, 1, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'the function supports providing an `offset` parameter (accessors)', function test( t ) { - var expected; - var ybuf; - var out; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - ybuf = zeros( x.length * 2 ); - y = toAccessorArray( ybuf ); - - expected = [ 0, 10, 0, 20, 0, 30, 0, 40 ]; - - out = map( toAccessorArray( x ), y, 2, 1, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( ybuf, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function supports providing an `offset` parameter (array-like object)', function test( t ) { - var expected; - var out; - var x; - var y; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - y = zeros( x.length * 2 ); - expected = [ 0, 10, 0, 20, 0, 30, 0, 40 ]; - - out = map( x, y, 2, 1, scale ); - - t.strictEqual( out, y, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); diff --git a/base/map/test/test.js b/base/map/test/test.js deleted file mode 100644 index 654cd9c5c..000000000 --- a/base/map/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var map = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/base/map/test/test.main.js b/base/map/test/test.main.js deleted file mode 100644 index 4c09189b1..000000000 --- a/base/map/test/test.main.js +++ /dev/null @@ -1,142 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Float64Array = require( './../../../float64' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var map = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to elements in an input array and assigns results to elements in a new output array (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - expected = [ 10, 20, 30, 40 ]; - - actual = map( x, scale ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function applies a provided callback to elements in an input array and assigns results to elements in a new output array (typed array)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = new Float64Array( [ 10.0, 20.0, 30.0, 40.0 ] ); - - actual = map( x, scale ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'the function applies a provided callback to elements in an input array and assigns results to elements in a new output array (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - expected = [ 10, 20, 30, 40 ]; - - actual = map( toAccessorArray( x ), scale ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function applies a provided callback to elements in an input array and assigns results to elements in a new output array (array-like object)', function test( t ) { - var expected; - var actual; - var x; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = [ 10, 20, 30, 40 ]; - - actual = map( x, scale ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * 10; - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - var x; - - x = [ 1, 2, 3, 4 ]; - ctx = { - 'factor': 10 - }; - expected = [ 10, 20, 30, 40 ]; - - actual = map( x, scale, ctx ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return v * this.factor; // eslint-disable-line no-invalid-this - } -}); diff --git a/base/map2d/README.md b/base/map2d/README.md deleted file mode 100644 index 692a63724..000000000 --- a/base/map2d/README.md +++ /dev/null @@ -1,166 +0,0 @@ - - -# map2d - -> Apply a function to elements in a two-dimensional nested input array and assign results to elements in a new two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var map2d = require( '@stdlib/array/base/map2d' ); -``` - -#### map2d( x, shape, fcn\[, thisArg] ) - -Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a new two-dimensional nested output array. - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; -var shape = [ 2, 2 ]; - -var y = map2d( x, shape, naryFunction( abs, 1 ) ); -// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] -``` - -The function accepts the following arguments: - -- **x**: input nested array. -- **shape**: array shape. -- **fcn**: function to apply. -- **thisArg**: applied function execution context (_optional_). - -To set the applied function's execution context, provide a `thisArg`. - - - -```javascript -function fcn( x ) { - this.count += 1; - return x; -} - -var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; -var shape = [ 2, 2 ]; - -var ctx = { - 'count': 0 -}; - -var y = map2d( x, shape, fcn, ctx ); -// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] - -var v = ctx.count; -// returns 4 -``` - -#### map2d.assign( x, y, shape, fcn\[, thisArg] ) - -Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array. - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; -var shape = [ 2, 2 ]; - -var y = zeros2d( shape ); - -var out = map2d.assign( x, y, shape, naryFunction( abs, 1 ) ); -// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] - -var bool = ( out === y ); -// returns true -``` - -The function accepts the following arguments: - -- **x**: input nested array. -- **y**: output nested array. -- **shape**: array shape. -- **fcn**: function to apply. -- **thisArg**: applied function execution context (_optional_). - -The function assumes that the input and output arrays have the same shape. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var map2d = require( '@stdlib/array/base/map2d' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map2d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/map2d/benchmark/benchmark.assign.js b/base/map2d/benchmark/benchmark.assign.js deleted file mode 100644 index b38d233be..000000000 --- a/base/map2d/benchmark/benchmark.assign.js +++ /dev/null @@ -1,114 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var map2d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros2d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map2d( x, y, shape, identity ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( out[ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( out[ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/map2d/benchmark/benchmark.js b/base/map2d/benchmark/benchmark.js deleted file mode 100644 index e657445a1..000000000 --- a/base/map2d/benchmark/benchmark.js +++ /dev/null @@ -1,108 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var map2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map2d( x, shape, identity ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( out[ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( out[ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/map2d/docs/repl.txt b/base/map2d/docs/repl.txt deleted file mode 100644 index d12dbd85b..000000000 --- a/base/map2d/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a two-dimensional nested input array and - assigns results to elements in a new two-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; - > var shape = [ 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a two-dimensional nested input array and - assigns results to elements in a two-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; - > var y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shape = [ 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/base/map2d/docs/types/index.d.ts b/base/map2d/docs/types/index.d.ts deleted file mode 100644 index f09177ac2..000000000 --- a/base/map2d/docs/types/index.d.ts +++ /dev/null @@ -1,186 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array2D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a new two-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones2d = require( './../../../../base/ones2d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = map2d( x, shape, scale ); - * // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] - */ - ( x: Array2D, shape: Shape2D, fcn: Callback, thisArg?: ThisParameterType> ): Array2D; - - /** - * Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones2d = require( './../../../../base/ones2d' ); - * var zeros2d = require( './../../../../base/zeros2d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 2, 2 ]; - * - * var x = ones2d( shape ); - * var y = zeros2d( shape ); - * - * var out = map2d.assign( x, y, shape, scale ); - * // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array2D, y: Array2D, shape: Shape2D, fcn: Callback, thisArg?: ThisParameterType> ): Array2D; -} - -/** -* Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a new two-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = map2d( x, shape, scale ); -* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* var out = map2d.assign( x, y, shape, scale ); -* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map2d: Routine; - - -// EXPORTS // - -export = map2d; diff --git a/base/map2d/docs/types/test.ts b/base/map2d/docs/types/test.ts deleted file mode 100644 index 16b92faac..000000000 --- a/base/map2d/docs/types/test.ts +++ /dev/null @@ -1,227 +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. -*/ - -import map2d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - - map2d( x, [ 2, 2 ], fcn ); // $ExpectType Array2D - map2d( x, [ 2, 2 ], fcn, {} ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map2d( 'abc', [ 2, 2 ], fcn ); // $ExpectError - map2d( 3.14, [ 2, 2 ], fcn ); // $ExpectError - map2d( true, [ 2, 2 ], fcn ); // $ExpectError - map2d( false, [ 2, 2 ], fcn ); // $ExpectError - map2d( null, [ 2, 2 ], fcn ); // $ExpectError - map2d( [ '1' ], [ 2, 2 ], fcn ); // $ExpectError - map2d( {}, [ 2, 2 ], fcn ); // $ExpectError - map2d( ( x: number ): number => x, [ 2, 2 ], fcn ); // $ExpectError - - map2d( 'abc', [ 2, 2 ], fcn, {} ); // $ExpectError - map2d( 3.14, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d( true, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d( false, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d( null, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d( [ '1' ], [ 2, 2 ], fcn, {} ); // $ExpectError - map2d( {}, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d( ( x: number ): number => x, [ 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - - map2d( x, 'abc', fcn ); // $ExpectError - map2d( x, 3.14, fcn ); // $ExpectError - map2d( x, true, fcn ); // $ExpectError - map2d( x, false, fcn ); // $ExpectError - map2d( x, null, fcn ); // $ExpectError - map2d( x, [ '1' ], fcn ); // $ExpectError - map2d( x, {}, fcn ); // $ExpectError - map2d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map2d( x, 'abc', fcn, {} ); // $ExpectError - map2d( x, 3.14, fcn, {} ); // $ExpectError - map2d( x, true, fcn, {} ); // $ExpectError - map2d( x, false, fcn, {} ); // $ExpectError - map2d( x, null, fcn, {} ); // $ExpectError - map2d( x, [ '1' ], fcn, {} ); // $ExpectError - map2d( x, {}, fcn, {} ); // $ExpectError - map2d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - - map2d( x, [ 2, 2 ], 'abc' ); // $ExpectError - map2d( x, [ 2, 2 ], 3.14 ); // $ExpectError - map2d( x, [ 2, 2 ], true ); // $ExpectError - map2d( x, [ 2, 2 ], false ); // $ExpectError - map2d( x, [ 2, 2 ], null ); // $ExpectError - map2d( x, [ 2, 2 ], [ '1' ] ); // $ExpectError - map2d( x, [ 2, 2 ], {} ); // $ExpectError - - map2d( x, [ 2, 2 ], 'abc', {} ); // $ExpectError - map2d( x, [ 2, 2 ], 3.14, {} ); // $ExpectError - map2d( x, [ 2, 2 ], true, {} ); // $ExpectError - map2d( x, [ 2, 2 ], false, {} ); // $ExpectError - map2d( x, [ 2, 2 ], null, {} ); // $ExpectError - map2d( x, [ 2, 2 ], [ '1' ], {} ); // $ExpectError - map2d( x, [ 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - - map2d(); // $ExpectError - map2d( x ); // $ExpectError - map2d( x, [ 2, 2 ] ); // $ExpectError - map2d( x, [ 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - map2d.assign( x, y, [ 2, 2 ], fcn ); // $ExpectType Array2D - map2d.assign( x, y, [ 2, 2 ], fcn, {} ); // $ExpectType Array2D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - map2d.assign( 'abc', y, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( 3.14, y, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( true, y, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( false, y, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( null, y, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( [ '1' ], y, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( {}, y, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( ( x: number ): number => x, y, [ 2, 2 ], fcn ); // $ExpectError - - map2d.assign( 'abc', y, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( 3.14, y, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( true, y, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( false, y, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( null, y, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( [ '1' ], y, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( {}, y, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( ( x: number ): number => x, y, [ 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - - map2d.assign( x, 'abc', [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( x, 3.14, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( x, true, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( x, false, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( x, null, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( x, [ '1' ], [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( x, {}, [ 2, 2 ], fcn ); // $ExpectError - map2d.assign( x, ( x: number ): number => x, [ 2, 2 ], fcn ); // $ExpectError - - map2d.assign( x, 'abc', [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( x, 3.14, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( x, true, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( x, false, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( x, null, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( x, [ '1' ], [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( x, {}, [ 2, 2 ], fcn, {} ); // $ExpectError - map2d.assign( x, ( x: number ): number => x, [ 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - map2d.assign( x, y, 'abc', fcn ); // $ExpectError - map2d.assign( x, y, 3.14, fcn ); // $ExpectError - map2d.assign( x, y, true, fcn ); // $ExpectError - map2d.assign( x, y, false, fcn ); // $ExpectError - map2d.assign( x, y, null, fcn ); // $ExpectError - map2d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map2d.assign( x, y, {}, fcn ); // $ExpectError - map2d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map2d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map2d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map2d.assign( x, y, true, fcn, {} ); // $ExpectError - map2d.assign( x, y, false, fcn, {} ); // $ExpectError - map2d.assign( x, y, null, fcn, {} ); // $ExpectError - map2d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map2d.assign( x, y, {}, fcn, {} ); // $ExpectError - map2d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - map2d.assign( x, y, [ 2, 2 ], 'abc' ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], 3.14 ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], true ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], false ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], null ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], [ '1' ] ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], {} ); // $ExpectError - - map2d.assign( x, y, [ 2, 2 ], 'abc', {} ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], 3.14, {} ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], true, {} ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], false, {} ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], null, {} ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], [ '1' ], {} ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - map2d.assign(); // $ExpectError - map2d.assign( x, y ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ] ); // $ExpectError - map2d.assign( x, y, [ 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/base/map2d/examples/index.js b/base/map2d/examples/index.js deleted file mode 100644 index a9241355f..000000000 --- a/base/map2d/examples/index.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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var map2d = require( './../lib' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map2d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/base/map2d/lib/assign.js b/base/map2d/lib/assign.js deleted file mode 100644 index 59bfc7fd2..000000000 --- a/base/map2d/lib/assign.js +++ /dev/null @@ -1,82 +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'; - -// MAIN // - -/** -* Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* var out = map2d( x, y, shape, scale ); -* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map2d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var i0; - var i1; - var x0; - var y0; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return y; - } - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x[ i1 ]; - y0 = y[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i1, i0 ], x ); - } - } - return y; -} - - -// EXPORTS // - -module.exports = map2d; diff --git a/base/map2d/lib/index.js b/base/map2d/lib/index.js deleted file mode 100644 index 12baa3984..000000000 --- a/base/map2d/lib/index.js +++ /dev/null @@ -1,75 +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'; - -/** -* Apply a function to elements in a two-dimensional nested input array and assign results to elements in a new two-dimensional nested output array. -* -* @module @stdlib/array/base/map2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var map2d = require( '@stdlib/array/base/map2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = map2d( x, shape, scale ); -* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var map2d = require( '@stdlib/array/base/map2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* var out = map2d.assign( x, y, shape, scale ); -* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/map2d/lib/main.js b/base/map2d/lib/main.js deleted file mode 100644 index 427a61780..000000000 --- a/base/map2d/lib/main.js +++ /dev/null @@ -1,71 +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'; - -// MAIN // - -/** -* Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a new two-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = map2d( x, shape, scale ); -* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -*/ -function map2d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var i0; - var i1; - var x0; - var y0; - var y; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - y = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i1, i0 ], x ) ); - } - y.push( y0 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map2d; diff --git a/base/map2d/package.json b/base/map2d/package.json deleted file mode 100644 index 7c2bb1df7..000000000 --- a/base/map2d/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/map2d", - "version": "0.0.0", - "description": "Apply a function to elements in a two-dimensional nested input array and assign results to elements in a new two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/map2d/test/test.assign.js b/base/map2d/test/test.assign.js deleted file mode 100644 index a41c2ac33..000000000 --- a/base/map2d/test/test.assign.js +++ /dev/null @@ -1,186 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var map2d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - - y = zeros2d( shape ); - out = map2d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = zeros2d( shape ); - - y = zeros2d( shape ); - out = map2d( x, y, [ 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = zeros2d( shape ); - - y = zeros2d( shape ); - out = map2d( x, y, [ 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros2d( shape ); - out = map2d( x, y, shape, fcn, ctx ); - - expected = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0 ], - [ 0, 1 ], - [ 1, 0 ], - [ 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/base/map2d/test/test.js b/base/map2d/test/test.js deleted file mode 100644 index 4ed096f95..000000000 --- a/base/map2d/test/test.js +++ /dev/null @@ -1,38 +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 map2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map2d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/base/map2d/test/test.main.js b/base/map2d/test/test.main.js deleted file mode 100644 index e1afd6285..000000000 --- a/base/map2d/test/test.main.js +++ /dev/null @@ -1,172 +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 abs = require( '@stdlib/math/base/special/abs' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var map2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - - out = map2d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = []; - - out = map2d( x, [ 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = [ - [], - [] - ]; - - out = map2d( x, [ 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - - ctx = { - 'count': 0 - }; - out = map2d( x, shape, fcn, ctx ); - - expected = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0 ], - [ 0, 1 ], - [ 1, 0 ], - [ 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/base/map3d/README.md b/base/map3d/README.md deleted file mode 100644 index 8075cea37..000000000 --- a/base/map3d/README.md +++ /dev/null @@ -1,166 +0,0 @@ - - -# map3d - -> Apply a function to elements in a three-dimensional nested input array and assign results to elements in a new three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var map3d = require( '@stdlib/array/base/map3d' ); -``` - -#### map3d( x, shape, fcn\[, thisArg] ) - -Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a new three-dimensional nested output array. - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; -var shape = [ 1, 2, 2 ]; - -var y = map3d( x, shape, naryFunction( abs, 1 ) ); -// returns [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] -``` - -The function accepts the following arguments: - -- **x**: input nested array. -- **shape**: array shape. -- **fcn**: function to apply. -- **thisArg**: applied function execution context (_optional_). - -To set the applied function's execution context, provide a `thisArg`. - - - -```javascript -function fcn( x ) { - this.count += 1; - return x; -} - -var x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; -var shape = [ 1, 2, 2 ]; - -var ctx = { - 'count': 0 -}; - -var y = map3d( x, shape, fcn, ctx ); -// returns [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] - -var v = ctx.count; -// returns 4 -``` - -#### map3d.assign( x, y, shape, fcn\[, thisArg] ) - -Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array. - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; -var shape = [ 1, 2, 2 ]; - -var y = zeros3d( shape ); - -var out = map3d.assign( x, y, shape, naryFunction( abs, 1 ) ); -// returns [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] - -var bool = ( out === y ); -// returns true -``` - -The function accepts the following arguments: - -- **x**: input nested array. -- **y**: output nested array. -- **shape**: array shape. -- **fcn**: function to apply. -- **thisArg**: applied function execution context (_optional_). - -The function assumes that the input and output arrays have the same shape. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var map3d = require( '@stdlib/array/base/map3d' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map3d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/map3d/benchmark/benchmark.assign.js b/base/map3d/benchmark/benchmark.assign.js deleted file mode 100644 index 4ca23d00a..000000000 --- a/base/map3d/benchmark/benchmark.assign.js +++ /dev/null @@ -1,117 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var map3d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros3d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map3d( x, y, shape, identity ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( out[ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( out[ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/map3d/benchmark/benchmark.js b/base/map3d/benchmark/benchmark.js deleted file mode 100644 index 23b05c818..000000000 --- a/base/map3d/benchmark/benchmark.js +++ /dev/null @@ -1,111 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var map3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map3d( x, shape, identity ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( out[ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( out[ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/map3d/docs/repl.txt b/base/map3d/docs/repl.txt deleted file mode 100644 index 8812b2d60..000000000 --- a/base/map3d/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a three-dimensional nested input array and - assigns results to elements in a new three-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; - > var shape = [ 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a three-dimensional nested input array and - assigns results to elements in a three-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; - > var y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - > var shape = [ 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/base/map3d/docs/types/index.d.ts b/base/map3d/docs/types/index.d.ts deleted file mode 100644 index fcfbe9aeb..000000000 --- a/base/map3d/docs/types/index.d.ts +++ /dev/null @@ -1,186 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array3D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a new three-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones3d = require( './../../../../base/ones3d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = map3d( x, shape, scale ); - * // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] - */ - ( x: Array3D, shape: Shape3D, fcn: Callback, thisArg?: ThisParameterType> ): Array3D; - - /** - * Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones3d = require( './../../../../base/ones3d' ); - * var zeros3d = require( './../../../../base/zeros3d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 2, 2 ]; - * - * var x = ones3d( shape ); - * var y = zeros3d( shape ); - * - * var out = map3d.assign( x, y, shape, scale ); - * // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array3D, y: Array3D, shape: Shape3D, fcn: Callback, thisArg?: ThisParameterType> ): Array3D; -} - -/** -* Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a new three-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = map3d( x, shape, scale ); -* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* var out = map3d.assign( x, y, shape, scale ); -* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map3d: Routine; - - -// EXPORTS // - -export = map3d; diff --git a/base/map3d/docs/types/test.ts b/base/map3d/docs/types/test.ts deleted file mode 100644 index 8f898c983..000000000 --- a/base/map3d/docs/types/test.ts +++ /dev/null @@ -1,227 +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. -*/ - -import map3d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - - map3d( x, [ 1, 2, 2 ], fcn ); // $ExpectType Array3D - map3d( x, [ 1, 2, 2 ], fcn, {} ); // $ExpectType Array3D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map3d( 'abc', [ 1, 2, 2 ], fcn ); // $ExpectError - map3d( 3.14, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d( true, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d( false, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d( null, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d( [ '1' ], [ 1, 2, 2 ], fcn ); // $ExpectError - map3d( {}, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d( ( x: number ): number => x, [ 1, 2, 2 ], fcn ); // $ExpectError - - map3d( 'abc', [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d( 3.14, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d( true, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d( false, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d( null, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d( [ '1' ], [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d( {}, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d( ( x: number ): number => x, [ 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - - map3d( x, 'abc', fcn ); // $ExpectError - map3d( x, 3.14, fcn ); // $ExpectError - map3d( x, true, fcn ); // $ExpectError - map3d( x, false, fcn ); // $ExpectError - map3d( x, null, fcn ); // $ExpectError - map3d( x, [ '1' ], fcn ); // $ExpectError - map3d( x, {}, fcn ); // $ExpectError - map3d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map3d( x, 'abc', fcn, {} ); // $ExpectError - map3d( x, 3.14, fcn, {} ); // $ExpectError - map3d( x, true, fcn, {} ); // $ExpectError - map3d( x, false, fcn, {} ); // $ExpectError - map3d( x, null, fcn, {} ); // $ExpectError - map3d( x, [ '1' ], fcn, {} ); // $ExpectError - map3d( x, {}, fcn, {} ); // $ExpectError - map3d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - - map3d( x, [ 1, 2, 2 ], 'abc' ); // $ExpectError - map3d( x, [ 1, 2, 2 ], 3.14 ); // $ExpectError - map3d( x, [ 1, 2, 2 ], true ); // $ExpectError - map3d( x, [ 1, 2, 2 ], false ); // $ExpectError - map3d( x, [ 1, 2, 2 ], null ); // $ExpectError - map3d( x, [ 1, 2, 2 ], [ '1' ] ); // $ExpectError - map3d( x, [ 1, 2, 2 ], {} ); // $ExpectError - - map3d( x, [ 1, 2, 2 ], 'abc', {} ); // $ExpectError - map3d( x, [ 1, 2, 2 ], 3.14, {} ); // $ExpectError - map3d( x, [ 1, 2, 2 ], true, {} ); // $ExpectError - map3d( x, [ 1, 2, 2 ], false, {} ); // $ExpectError - map3d( x, [ 1, 2, 2 ], null, {} ); // $ExpectError - map3d( x, [ 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map3d( x, [ 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - - map3d(); // $ExpectError - map3d( x ); // $ExpectError - map3d( x, [ 1, 2, 2 ] ); // $ExpectError - map3d( x, [ 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - map3d.assign( x, y, [ 1, 2, 2 ], fcn ); // $ExpectType Array3D - map3d.assign( x, y, [ 1, 2, 2 ], fcn, {} ); // $ExpectType Array3D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - map3d.assign( 'abc', y, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( 3.14, y, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( true, y, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( false, y, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( null, y, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( [ '1' ], y, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( {}, y, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( ( x: number ): number => x, y, [ 1, 2, 2 ], fcn ); // $ExpectError - - map3d.assign( 'abc', y, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( 3.14, y, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( true, y, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( false, y, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( null, y, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( [ '1' ], y, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( {}, y, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( ( x: number ): number => x, y, [ 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - - map3d.assign( x, 'abc', [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( x, 3.14, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( x, true, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( x, false, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( x, null, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( x, [ '1' ], [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( x, {}, [ 1, 2, 2 ], fcn ); // $ExpectError - map3d.assign( x, ( x: number ): number => x, [ 1, 2, 2 ], fcn ); // $ExpectError - - map3d.assign( x, 'abc', [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( x, 3.14, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( x, true, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( x, false, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( x, null, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( x, [ '1' ], [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( x, {}, [ 1, 2, 2 ], fcn, {} ); // $ExpectError - map3d.assign( x, ( x: number ): number => x, [ 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - map3d.assign( x, y, 'abc', fcn ); // $ExpectError - map3d.assign( x, y, 3.14, fcn ); // $ExpectError - map3d.assign( x, y, true, fcn ); // $ExpectError - map3d.assign( x, y, false, fcn ); // $ExpectError - map3d.assign( x, y, null, fcn ); // $ExpectError - map3d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map3d.assign( x, y, {}, fcn ); // $ExpectError - map3d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map3d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map3d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map3d.assign( x, y, true, fcn, {} ); // $ExpectError - map3d.assign( x, y, false, fcn, {} ); // $ExpectError - map3d.assign( x, y, null, fcn, {} ); // $ExpectError - map3d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map3d.assign( x, y, {}, fcn, {} ); // $ExpectError - map3d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - map3d.assign( x, y, [ 1, 2, 2 ], 'abc' ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], 3.14 ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], true ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], false ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], null ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], [ '1' ] ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], {} ); // $ExpectError - - map3d.assign( x, y, [ 1, 2, 2 ], 'abc', {} ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], 3.14, {} ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], true, {} ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], false, {} ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], null, {} ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - map3d.assign(); // $ExpectError - map3d.assign( x, y ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ] ); // $ExpectError - map3d.assign( x, y, [ 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/base/map3d/examples/index.js b/base/map3d/examples/index.js deleted file mode 100644 index 56f6323e4..000000000 --- a/base/map3d/examples/index.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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var map3d = require( './../lib' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map3d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/base/map3d/lib/assign.js b/base/map3d/lib/assign.js deleted file mode 100644 index c6ff28c22..000000000 --- a/base/map3d/lib/assign.js +++ /dev/null @@ -1,91 +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'; - -// MAIN // - -/** -* Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* var out = map3d( x, y, shape, scale ); -* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map3d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var x0; - var y0; - var x1; - var y1; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return y; - } - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x[ i2 ]; - y1 = y[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i2, i1, i0 ], x ); - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map3d; diff --git a/base/map3d/lib/index.js b/base/map3d/lib/index.js deleted file mode 100644 index 0031a04df..000000000 --- a/base/map3d/lib/index.js +++ /dev/null @@ -1,75 +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'; - -/** -* Apply a function to elements in a three-dimensional nested input array and assign results to elements in a new three-dimensional nested output array. -* -* @module @stdlib/array/base/map3d -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var map3d = require( '@stdlib/array/base/map3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = map3d( x, shape, scale ); -* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var map3d = require( '@stdlib/array/base/map3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* var out = map3d.assign( x, y, shape, scale ); -* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/map3d/lib/main.js b/base/map3d/lib/main.js deleted file mode 100644 index 86505fe3b..000000000 --- a/base/map3d/lib/main.js +++ /dev/null @@ -1,81 +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'; - -// MAIN // - -/** -* Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a new three-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = map3d( x, shape, scale ); -* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -*/ -function map3d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var x0; - var y0; - var x1; - var y1; - var y; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - y = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i2, i1, i0 ], x ) ); - } - y1.push( y0 ); - } - y.push( y1 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map3d; diff --git a/base/map3d/package.json b/base/map3d/package.json deleted file mode 100644 index 7bbf0fb1e..000000000 --- a/base/map3d/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/map3d", - "version": "0.0.0", - "description": "Apply a function to elements in a three-dimensional nested input array and assign results to elements in a new three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/map3d/test/test.assign.js b/base/map3d/test/test.assign.js deleted file mode 100644 index e8f1aa2ff..000000000 --- a/base/map3d/test/test.assign.js +++ /dev/null @@ -1,227 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var map3d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - - y = zeros3d( shape ); - out = map3d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - out = map3d( x, y, [ 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - out = map3d( x, y, [ 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - out = map3d( x, y, [ 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros3d( shape ); - out = map3d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 0, 0, 1 ], - [ 0, 1, 0 ], - [ 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/base/map3d/test/test.js b/base/map3d/test/test.js deleted file mode 100644 index c73f2ef97..000000000 --- a/base/map3d/test/test.js +++ /dev/null @@ -1,38 +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 map3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map3d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/base/map3d/test/test.main.js b/base/map3d/test/test.main.js deleted file mode 100644 index f918eb59e..000000000 --- a/base/map3d/test/test.main.js +++ /dev/null @@ -1,212 +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 abs = require( '@stdlib/math/base/special/abs' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var map3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - - out = map3d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = []; - - out = map3d( x, [ 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = [ - [] - ]; - - out = map3d( x, [ 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = [ - [ - [], - [] - ] - ]; - - out = map3d( x, [ 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map3d( x, shape, fcn, ctx ); - - expected = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 0, 0, 1 ], - [ 0, 1, 0 ], - [ 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/base/map4d/README.md b/base/map4d/README.md deleted file mode 100644 index b6b90dd50..000000000 --- a/base/map4d/README.md +++ /dev/null @@ -1,166 +0,0 @@ - - -# map4d - -> Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var map4d = require( '@stdlib/array/base/map4d' ); -``` - -#### map4d( x, shape, fcn\[, thisArg] ) - -Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; -var shape = [ 1, 1, 2, 2 ]; - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -// returns [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **x**: input nested array. -- **shape**: array shape. -- **fcn**: function to apply. -- **thisArg**: applied function execution context (_optional_). - -To set the applied function's execution context, provide a `thisArg`. - - - -```javascript -function fcn( x ) { - this.count += 1; - return x; -} - -var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; -var shape = [ 1, 1, 2, 2 ]; - -var ctx = { - 'count': 0 -}; - -var y = map4d( x, shape, fcn, ctx ); -// returns [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - -var v = ctx.count; -// returns 4 -``` - -#### map4d.assign( x, y, shape, fcn\[, thisArg] ) - -Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; -var shape = [ 1, 1, 2, 2 ]; - -var y = zeros4d( shape ); - -var out = map4d.assign( x, y, shape, naryFunction( abs, 1 ) ); -// returns [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - -var bool = ( out === y ); -// returns true -``` - -The function accepts the following arguments: - -- **x**: input nested array. -- **y**: output nested array. -- **shape**: array shape. -- **fcn**: function to apply. -- **thisArg**: applied function execution context (_optional_). - -The function assumes that the input and output arrays have the same shape. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var map4d = require( '@stdlib/array/base/map4d' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/map4d/benchmark/benchmark.assign.js b/base/map4d/benchmark/benchmark.assign.js deleted file mode 100644 index 5d3734139..000000000 --- a/base/map4d/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/map4d/benchmark/benchmark.js b/base/map4d/benchmark/benchmark.js deleted file mode 100644 index 126574f52..000000000 --- a/base/map4d/benchmark/benchmark.js +++ /dev/null @@ -1,114 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/map4d/docs/repl.txt b/base/map4d/docs/repl.txt deleted file mode 100644 index 9f8d2b2b1..000000000 --- a/base/map4d/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/base/map4d/docs/types/index.d.ts b/base/map4d/docs/types/index.d.ts deleted file mode 100644 index d1d4d4d00..000000000 --- a/base/map4d/docs/types/index.d.ts +++ /dev/null @@ -1,186 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( './../../../../base/ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( './../../../../base/ones4d' ); - * var zeros4d = require( './../../../../base/zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/base/map4d/docs/types/test.ts b/base/map4d/docs/types/test.ts deleted file mode 100644 index 93454e9b7..000000000 --- a/base/map4d/docs/types/test.ts +++ /dev/null @@ -1,227 +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. -*/ - -import map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/base/map4d/examples/index.js b/base/map4d/examples/index.js deleted file mode 100644 index 06018302f..000000000 --- a/base/map4d/examples/index.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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/base/map4d/lib/assign.js b/base/map4d/lib/assign.js deleted file mode 100644 index 0c4576d7f..000000000 --- a/base/map4d/lib/assign.js +++ /dev/null @@ -1,100 +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'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/base/map4d/lib/index.js b/base/map4d/lib/index.js deleted file mode 100644 index 7e1d1bf8a..000000000 --- a/base/map4d/lib/index.js +++ /dev/null @@ -1,75 +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'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array/base/map4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var map4d = require( '@stdlib/array/base/map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var map4d = require( '@stdlib/array/base/map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/map4d/lib/main.js b/base/map4d/lib/main.js deleted file mode 100644 index 311eb020a..000000000 --- a/base/map4d/lib/main.js +++ /dev/null @@ -1,91 +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'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/base/map4d/package.json b/base/map4d/package.json deleted file mode 100644 index b877d3444..000000000 --- a/base/map4d/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/map4d", - "version": "0.0.0", - "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/map4d/test/test.assign.js b/base/map4d/test/test.assign.js deleted file mode 100644 index e9db83067..000000000 --- a/base/map4d/test/test.assign.js +++ /dev/null @@ -1,272 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/base/map4d/test/test.js b/base/map4d/test/test.js deleted file mode 100644 index b278bac6d..000000000 --- a/base/map4d/test/test.js +++ /dev/null @@ -1,38 +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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/base/map4d/test/test.main.js b/base/map4d/test/test.main.js deleted file mode 100644 index 47fa72e2c..000000000 --- a/base/map4d/test/test.main.js +++ /dev/null @@ -1,258 +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 abs = require( '@stdlib/math/base/special/abs' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/base/map5d/README.md b/base/map5d/README.md deleted file mode 100644 index 7f27c3cc4..000000000 --- a/base/map5d/README.md +++ /dev/null @@ -1,166 +0,0 @@ - - -# map5d - -> Apply a function to elements in a five-dimensional nested input array and assign results to elements in a new five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var map5d = require( '@stdlib/array/base/map5d' ); -``` - -#### map5d( x, shape, fcn\[, thisArg] ) - -Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a new five-dimensional nested output array. - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; -var shape = [ 1, 1, 1, 2, 2 ]; - -var y = map5d( x, shape, naryFunction( abs, 1 ) ); -// returns [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **x**: input nested array. -- **shape**: array shape. -- **fcn**: function to apply. -- **thisArg**: applied function execution context (_optional_). - -To set the applied function's execution context, provide a `thisArg`. - - - -```javascript -function fcn( x ) { - this.count += 1; - return x; -} - -var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; -var shape = [ 1, 1, 1, 2, 2 ]; - -var ctx = { - 'count': 0 -}; - -var y = map5d( x, shape, fcn, ctx ); -// returns [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ] - -var v = ctx.count; -// returns 4 -``` - -#### map5d.assign( x, y, shape, fcn\[, thisArg] ) - -Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array. - -```javascript -var naryFunction = require( '@stdlib/utils/nary-function' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; -var shape = [ 1, 1, 1, 2, 2 ]; - -var y = zeros5d( shape ); - -var out = map5d.assign( x, y, shape, naryFunction( abs, 1 ) ); -// returns [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ] - -var bool = ( out === y ); -// returns true -``` - -The function accepts the following arguments: - -- **x**: input nested array. -- **y**: output nested array. -- **shape**: array shape. -- **fcn**: function to apply. -- **thisArg**: applied function execution context (_optional_). - -The function assumes that the input and output arrays have the same shape. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var map5d = require( '@stdlib/array/base/map5d' ); - -var shape = [ 1, 1, 3, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map5d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/map5d/benchmark/benchmark.assign.js b/base/map5d/benchmark/benchmark.assign.js deleted file mode 100644 index 1bbe7f418..000000000 --- a/base/map5d/benchmark/benchmark.assign.js +++ /dev/null @@ -1,123 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var map5d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros5d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map5d( x, y, shape, identity ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( out[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( out[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/map5d/benchmark/benchmark.js b/base/map5d/benchmark/benchmark.js deleted file mode 100644 index b8d568797..000000000 --- a/base/map5d/benchmark/benchmark.js +++ /dev/null @@ -1,117 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var map5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map5d( x, shape, identity ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( out[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( out[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/map5d/docs/repl.txt b/base/map5d/docs/repl.txt deleted file mode 100644 index f9a067932..000000000 --- a/base/map5d/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a five-dimensional nested input array and - assigns results to elements in a new five-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; - > var shape = [ 1, 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a five-dimensional nested input array and - assigns results to elements in a five-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; - > var y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shape = [ 1, 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/base/map5d/docs/types/index.d.ts b/base/map5d/docs/types/index.d.ts deleted file mode 100644 index caa533012..000000000 --- a/base/map5d/docs/types/index.d.ts +++ /dev/null @@ -1,186 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array5D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a new five-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones5d = require( './../../../../base/ones5d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 1, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = map5d( x, shape, scale ); - * // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] - */ - ( x: Array5D, shape: Shape5D, fcn: Callback, thisArg?: ThisParameterType> ): Array5D; - - /** - * Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones5d = require( './../../../../base/ones5d' ); - * var zeros5d = require( './../../../../base/zeros5d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 1, 2, 2 ]; - * - * var x = ones5d( shape ); - * var y = zeros5d( shape ); - * - * var out = map5d.assign( x, y, shape, scale ); - * // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array5D, y: Array5D, shape: Shape5D, fcn: Callback, thisArg?: ThisParameterType> ): Array5D; -} - -/** -* Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a new five-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* - **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = map5d( x, shape, scale ); -* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* var out = map5d.assign( x, y, shape, scale ); -* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map5d: Routine; - - -// EXPORTS // - -export = map5d; diff --git a/base/map5d/docs/types/test.ts b/base/map5d/docs/types/test.ts deleted file mode 100644 index 69996ee0e..000000000 --- a/base/map5d/docs/types/test.ts +++ /dev/null @@ -1,227 +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. -*/ - -import map5d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - - map5d( x, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectType Array5D - map5d( x, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map5d( 'abc', [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d( 3.14, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d( true, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d( false, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d( null, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d( [ '1' ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d( {}, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - - map5d( 'abc', [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d( 3.14, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d( true, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d( false, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d( null, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d( [ '1' ], [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d( {}, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - - map5d( x, 'abc', fcn ); // $ExpectError - map5d( x, 3.14, fcn ); // $ExpectError - map5d( x, true, fcn ); // $ExpectError - map5d( x, false, fcn ); // $ExpectError - map5d( x, null, fcn ); // $ExpectError - map5d( x, [ '1' ], fcn ); // $ExpectError - map5d( x, {}, fcn ); // $ExpectError - map5d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map5d( x, 'abc', fcn, {} ); // $ExpectError - map5d( x, 3.14, fcn, {} ); // $ExpectError - map5d( x, true, fcn, {} ); // $ExpectError - map5d( x, false, fcn, {} ); // $ExpectError - map5d( x, null, fcn, {} ); // $ExpectError - map5d( x, [ '1' ], fcn, {} ); // $ExpectError - map5d( x, {}, fcn, {} ); // $ExpectError - map5d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - - map5d( x, [ 1, 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], true ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], false ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], null ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], {} ); // $ExpectError - - map5d( x, [ 1, 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], true, {} ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], false, {} ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], null, {} ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - - map5d(); // $ExpectError - map5d( x ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ] ); // $ExpectError - map5d( x, [ 1, 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectType Array5D - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array5D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - map5d.assign( 'abc', y, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( 3.14, y, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( true, y, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( false, y, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( null, y, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( [ '1' ], y, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( {}, y, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( ( x: number ): number => x, y, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - - map5d.assign( 'abc', y, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( 3.14, y, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( true, y, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( false, y, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( null, y, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( [ '1' ], y, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( {}, y, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( ( x: number ): number => x, y, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - - map5d.assign( x, 'abc', [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( x, 3.14, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( x, true, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( x, false, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( x, null, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( x, [ '1' ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( x, {}, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - map5d.assign( x, ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - - map5d.assign( x, 'abc', [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( x, 3.14, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( x, true, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( x, false, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( x, null, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( x, [ '1' ], [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( x, {}, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map5d.assign( x, ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - map5d.assign( x, y, 'abc', fcn ); // $ExpectError - map5d.assign( x, y, 3.14, fcn ); // $ExpectError - map5d.assign( x, y, true, fcn ); // $ExpectError - map5d.assign( x, y, false, fcn ); // $ExpectError - map5d.assign( x, y, null, fcn ); // $ExpectError - map5d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map5d.assign( x, y, {}, fcn ); // $ExpectError - map5d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map5d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map5d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map5d.assign( x, y, true, fcn, {} ); // $ExpectError - map5d.assign( x, y, false, fcn, {} ); // $ExpectError - map5d.assign( x, y, null, fcn, {} ); // $ExpectError - map5d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map5d.assign( x, y, {}, fcn, {} ); // $ExpectError - map5d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], true ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], false ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], null ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], {} ); // $ExpectError - - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], true, {} ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], false, {} ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], null, {} ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - map5d.assign(); // $ExpectError - map5d.assign( x, y ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ] ); // $ExpectError - map5d.assign( x, y, [ 1, 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/base/map5d/examples/index.js b/base/map5d/examples/index.js deleted file mode 100644 index 644639ac5..000000000 --- a/base/map5d/examples/index.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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var map5d = require( './../lib' ); - -var shape = [ 1, 1, 3, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map5d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/base/map5d/lib/assign.js b/base/map5d/lib/assign.js deleted file mode 100644 index 7f94a0aa6..000000000 --- a/base/map5d/lib/assign.js +++ /dev/null @@ -1,109 +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'; - -// MAIN // - -/** -* Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* var out = map5d( x, y, shape, scale ); -* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map5d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var x3; - var y3; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return y; - } - for ( i4 = 0; i4 < S4; i4++ ) { - x3 = x[ i4 ]; - y3 = y[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x3[ i3 ]; - y2 = y3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i4, i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map5d; diff --git a/base/map5d/lib/index.js b/base/map5d/lib/index.js deleted file mode 100644 index 9fab18bd1..000000000 --- a/base/map5d/lib/index.js +++ /dev/null @@ -1,75 +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'; - -/** -* Apply a function to elements in a five-dimensional nested input array and assign results to elements in a new five-dimensional nested output array. -* -* @module @stdlib/array/base/map5d -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var map5d = require( '@stdlib/array/base/map5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = map5d( x, shape, scale ); -* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var map5d = require( '@stdlib/array/base/map5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* var out = map5d.assign( x, y, shape, scale ); -* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/map5d/lib/main.js b/base/map5d/lib/main.js deleted file mode 100644 index b90d7796f..000000000 --- a/base/map5d/lib/main.js +++ /dev/null @@ -1,101 +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'; - -// MAIN // - -/** -* Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a new five-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = map5d( x, shape, scale ); -* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -*/ -function map5d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var x3; - var y3; - var y; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - y = []; - for ( i4 = 0; i4 < S4; i4++ ) { - x3 = x[ i4 ]; - y3 = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x3[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i4, i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y3.push( y2 ); - } - y.push( y3 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map5d; diff --git a/base/map5d/package.json b/base/map5d/package.json deleted file mode 100644 index 9108ec7c5..000000000 --- a/base/map5d/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/map5d", - "version": "0.0.0", - "description": "Apply a function to elements in a five-dimensional nested input array and assign results to elements in a new five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/map5d/test/test.assign.js b/base/map5d/test/test.assign.js deleted file mode 100644 index ee639f7da..000000000 --- a/base/map5d/test/test.assign.js +++ /dev/null @@ -1,321 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var map5d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - - y = zeros5d( shape ); - out = map5d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - out = map5d( x, y, [ 0, 1, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - out = map5d( x, y, [ 1, 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - out = map5d( x, y, [ 1, 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - out = map5d( x, y, [ 1, 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - out = map5d( x, y, [ 1, 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros5d( shape ); - out = map5d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0, 0 ], - [ 0, 0, 0, 0, 1 ], - [ 0, 0, 0, 1, 0 ], - [ 0, 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/base/map5d/test/test.js b/base/map5d/test/test.js deleted file mode 100644 index d646d1ba7..000000000 --- a/base/map5d/test/test.js +++ /dev/null @@ -1,38 +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 map5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map5d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/base/map5d/test/test.main.js b/base/map5d/test/test.main.js deleted file mode 100644 index db996f7cc..000000000 --- a/base/map5d/test/test.main.js +++ /dev/null @@ -1,310 +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 abs = require( '@stdlib/math/base/special/abs' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var map5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - - out = map5d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = []; - - out = map5d( x, [ 0, 1, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map5d( x, [ 1, 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map5d( x, [ 1, 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [] - ] - ] - ]; - - out = map5d( x, [ 1, 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [], - [] - ] - ] - ] - ]; - - out = map5d( x, [ 1, 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map5d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0, 0 ], - [ 0, 0, 0, 0, 1 ], - [ 0, 0, 0, 1, 0 ], - [ 0, 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/base/min-signed-integer-dtype/README.md b/base/min-signed-integer-dtype/README.md deleted file mode 100644 index 4918899a1..000000000 --- a/base/min-signed-integer-dtype/README.md +++ /dev/null @@ -1,132 +0,0 @@ - - -# Minimum Data Type - -> Determine the minimum array [data type][@stdlib/array/dtypes] for storing a provided signed integer value. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var minSignedIntegerDataType = require( '@stdlib/array/base/min-signed-integer-dtype' ); -``` - -#### minSignedIntegerDataType( value ) - -Returns the minimum array [data type][@stdlib/array/dtypes] for storing a provided signed integer value. - -```javascript -var dt = minSignedIntegerDataType( 9999 ); -// returns 'int16' - -dt = minSignedIntegerDataType( -3 ); -// returns 'int8' - -dt = minSignedIntegerDataType( 3 ); -// returns 'int8' - -dt = minSignedIntegerDataType( 1e100 ); -// returns 'float64' -``` - -
- - - - - -
- -## Notes - -- Once a provided integer value exceeds the maximum values of all supported signed integer [data types][@stdlib/array/dtypes], the function defaults to returning `'float64'`. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var exp2 = require( '@stdlib/math/base/special/exp2' ); -var minSignedIntegerDataType = require( '@stdlib/array/base/min-signed-integer-dtype' ); - -// Generate random powers: -var exp = discreteUniform( 100, 0, 40, { - 'dtype': 'generic' -}); - -// Determine the minimum data type for each generated value... -var v; -var i; -for ( i = 0; i < exp.length; i++ ) { - v = exp2( exp[ i ] ); - console.log( 'min(%d) => %s', v, minSignedIntegerDataType( v ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/min-signed-integer-dtype/benchmark/benchmark.js b/base/min-signed-integer-dtype/benchmark/benchmark.js deleted file mode 100644 index 43982d07c..000000000 --- a/base/min-signed-integer-dtype/benchmark/benchmark.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var minSignedIntegerDataType = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var N; - var i; - - values = [ - 0, - 1, - -128, - 128, - 99999, - -99999, - 1.0e100, - -1.0e100, - -1234567890, - 1234567890 - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = minSignedIntegerDataType( values[ i%N ] ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/min-signed-integer-dtype/docs/repl.txt b/base/min-signed-integer-dtype/docs/repl.txt deleted file mode 100644 index 1c463a4c3..000000000 --- a/base/min-signed-integer-dtype/docs/repl.txt +++ /dev/null @@ -1,27 +0,0 @@ - -{{alias}}( value ) - Returns the minimum array data type for storing a provided signed integer - value. - - Parameters - ---------- - value: number - Signed integer value. - - Returns - ------- - dt: string - Array data type. - - Examples - -------- - > var dt = {{alias}}( 3 ) - 'int8' - > dt = {{alias}}( -3 ) - 'int8' - > dt = {{alias}}( 1280 ) - 'int16' - - See Also - -------- - diff --git a/base/min-signed-integer-dtype/docs/types/index.d.ts b/base/min-signed-integer-dtype/docs/types/index.d.ts deleted file mode 100644 index eb313ca7a..000000000 --- a/base/min-signed-integer-dtype/docs/types/index.d.ts +++ /dev/null @@ -1,49 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { SignedIntegerDataType } from '@stdlib/types/array'; - -/** -* Output data type. -*/ -type DataType = SignedIntegerDataType | 'float64'; - -/** -* Returns the minimum array data type for storing a provided signed integer value. -* -* @param value - scalar value -* @returns array data type -* -* @example -* var dt = minSignedIntegerDataType( 1280 ); -* // returns 'int16' -* -* @example -* var dt = minSignedIntegerDataType( 3 ); -* // returns 'int8' -*/ -declare function minSignedIntegerDataType( value: number ): DataType; - - -// EXPORTS // - -export = minSignedIntegerDataType; diff --git a/base/min-signed-integer-dtype/docs/types/test.ts b/base/min-signed-integer-dtype/docs/types/test.ts deleted file mode 100644 index fef0fb29c..000000000 --- a/base/min-signed-integer-dtype/docs/types/test.ts +++ /dev/null @@ -1,33 +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. -*/ - -import minSignedIntegerDataType = require( './index' ); - - -// TESTS // - -// The function returns a data type... -{ - minSignedIntegerDataType( 2 ); // $ExpectType DataType -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - minSignedIntegerDataType(); // $ExpectError - minSignedIntegerDataType( 3, 3 ); // $ExpectError -} diff --git a/base/min-signed-integer-dtype/examples/index.js b/base/min-signed-integer-dtype/examples/index.js deleted file mode 100644 index 67c18fed3..000000000 --- a/base/min-signed-integer-dtype/examples/index.js +++ /dev/null @@ -1,36 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var exp2 = require( '@stdlib/math/base/special/exp2' ); -var minSignedIntegerDataType = require( './../lib' ); - -// Generate random powers: -var exp = discreteUniform( 100, 0, 40, { - 'dtype': 'generic' -}); - -// Determine the minimum data type for each generated value... -var v; -var i; -for ( i = 0; i < exp.length; i++ ) { - v = exp2( exp[ i ] ); - console.log( 'min(%d) => %s', v, minSignedIntegerDataType( v ) ); -} diff --git a/base/min-signed-integer-dtype/lib/index.js b/base/min-signed-integer-dtype/lib/index.js deleted file mode 100644 index 2ce663009..000000000 --- a/base/min-signed-integer-dtype/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Determine the minimum array data type for storing a provided signed integer value. -* -* @module @stdlib/array/base/min-signed-integer-dtype -* -* @example -* var minSignedIntegerDataType = require( '@stdlib/array/base/min-signed-integer-dtype' ); -* -* var dt = minSignedIntegerDataType( 1280 ); -* // returns 'int16' -* -* dt = minSignedIntegerDataType( 3 ); -* // returns 'int8' -*/ - -// MODULES // - -var minSignedIntegerDataType = require( './main.js' ); - - -// EXPORTS // - -module.exports = minSignedIntegerDataType; diff --git a/base/min-signed-integer-dtype/lib/main.js b/base/min-signed-integer-dtype/lib/main.js deleted file mode 100644 index 4710f6edd..000000000 --- a/base/min-signed-integer-dtype/lib/main.js +++ /dev/null @@ -1,75 +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. -*/ - -'use strict'; - -// MODULES // - -var INT8_MIN = require( '@stdlib/constants/int8/min' ); -var INT16_MIN = require( '@stdlib/constants/int16/min' ); -var INT32_MIN = require( '@stdlib/constants/int32/min' ); -var INT8_MAX = require( '@stdlib/constants/int8/max' ); -var INT16_MAX = require( '@stdlib/constants/int16/max' ); -var INT32_MAX = require( '@stdlib/constants/int32/max' ); - - -// MAIN // - -/** -* Returns the minimum array data type for storing a provided signed integer value. -* -* @param {integer} value - scalar value -* @returns {string} array data type -* -* @example -* var dt = minSignedIntegerDataType( 9999 ); -* // returns 'int16' -* -* @example -* var dt = minSignedIntegerDataType( 3 ); -* // returns 'int8' -*/ -function minSignedIntegerDataType( value ) { - if ( value < 0 ) { - if ( value >= INT8_MIN ) { - return 'int8'; - } - if ( value >= INT16_MIN ) { - return 'int16'; - } - if ( value >= INT32_MIN ) { - return 'int32'; - } - return 'float64'; - } - if ( value <= INT8_MAX ) { - return 'int8'; - } - if ( value <= INT16_MAX ) { - return 'int16'; - } - if ( value <= INT32_MAX ) { - return 'int32'; - } - return 'float64'; -} - - -// EXPORTS // - -module.exports = minSignedIntegerDataType; diff --git a/base/min-signed-integer-dtype/package.json b/base/min-signed-integer-dtype/package.json deleted file mode 100644 index 8e80d1c33..000000000 --- a/base/min-signed-integer-dtype/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/array/base/min-signed-integer-dtype", - "version": "0.0.0", - "description": "Determine the minimum array data type for storing a provided signed integer value.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "base", - "scalar", - "type", - "memory", - "minimum", - "integer", - "int", - "signed", - "dtype", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/base/min-signed-integer-dtype/test/test.js b/base/min-signed-integer-dtype/test/test.js deleted file mode 100644 index 416bf8807..000000000 --- a/base/min-signed-integer-dtype/test/test.js +++ /dev/null @@ -1,75 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var minSignedIntegerDataType = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minSignedIntegerDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the minimum array data type for storing a provided signed integer value', function test( t ) { - var expected; - var actual; - var values; - var i; - - values = [ - 0, - 1, - -1, - 127, - -128, - 300, // >2**8 - -300, - 65537, // >2**16 - -65537, - 99999999, - 4294967297, // >2**32 - -4294967297 - ]; - expected = [ - 'int8', - 'int8', - 'int8', - 'int8', - 'int8', - 'int16', - 'int16', - 'int32', - 'int32', - 'int32', - 'float64', - 'float64' - - ]; - for ( i = 0; i < values.length; i++ ) { - actual = minSignedIntegerDataType( values[i] ); - t.strictEqual( actual, expected[ i ], 'returns expected value when provided '+values[i] ); - } - t.end(); -}); diff --git a/base/min-unsigned-integer-dtype/README.md b/base/min-unsigned-integer-dtype/README.md deleted file mode 100644 index 665bed778..000000000 --- a/base/min-unsigned-integer-dtype/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# Minimum Data Type - -> Determine the minimum array [data type][@stdlib/array/dtypes] for storing a provided unsigned integer value. - - - -
- -
- - - - - -
- -## Usage - - - -```javascript -var minUnsignedIntegerDataType = require( '@stdlib/array/base/min-unsigned-integer-dtype' ); -``` - -#### minUnsignedIntegerDataType( value ) - -Returns the minimum array [data type][@stdlib/array/dtypes] for storing a provided unsigned integer value. - - - -```javascript -var dt = minUnsignedIntegerDataType( 9999 ); -// returns 'uint16' - -dt = minUnsignedIntegerDataType( 3 ); -// returns 'uint8' - -dt = minUnsignedIntegerDataType( 1e100 ); -// returns 'float64' -``` - -
- - - - - -
- -## Notes - -- Once a provided integer value exceeds the maximum values of all supported unsigned integer [data types][@stdlib/array/dtypes], the function defaults to returning `'float64'`. - -
- - - - - -
- -## Examples - - - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var exp2 = require( '@stdlib/math/base/special/exp2' ); -var minUnsignedIntegerDataType = require( '@stdlib/array/base/min-unsigned-integer-dtype' ); - -// Generate random powers: -var exp = discreteUniform( 100, 0, 40, { - 'dtype': 'generic' -}); - -// Determine the minimum data type for each generated value... -var v; -var i; -for ( i = 0; i < exp.length; i++ ) { - v = exp2( exp[ i ] ); - console.log( 'min(%d) => %s', v, minUnsignedIntegerDataType( v ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/min-unsigned-integer-dtype/benchmark/benchmark.js b/base/min-unsigned-integer-dtype/benchmark/benchmark.js deleted file mode 100644 index 018daad9d..000000000 --- a/base/min-unsigned-integer-dtype/benchmark/benchmark.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var minUnsignedIntegerDataType = require( './../lib' ); // eslint-disable-line id-length - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var N; - var i; - - values = [ - 0, - 1, - 128, - 99999, - 1.0e100, - 1234567890 - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = minUnsignedIntegerDataType( values[ i%N ] ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/min-unsigned-integer-dtype/docs/repl.txt b/base/min-unsigned-integer-dtype/docs/repl.txt deleted file mode 100644 index 0d6ee3e6c..000000000 --- a/base/min-unsigned-integer-dtype/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( value ) - Returns the minimum array data type for storing a provided unsigned integer - value. - - Parameters - ---------- - value: number - Unsigned integer value. - - Returns - ------- - dt: string - Array data type. - - Examples - -------- - > var dt = {{alias}}( 3 ) - 'uint8' - > dt = {{alias}}( 1280 ) - 'uint16' - - See Also - -------- - diff --git a/base/min-unsigned-integer-dtype/docs/types/index.d.ts b/base/min-unsigned-integer-dtype/docs/types/index.d.ts deleted file mode 100644 index 5bee452db..000000000 --- a/base/min-unsigned-integer-dtype/docs/types/index.d.ts +++ /dev/null @@ -1,49 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { UnsignedIntegerDataType } from '@stdlib/types/array'; - -/** -* Output data type. -*/ -type DataType = UnsignedIntegerDataType | 'float64'; - -/** -* Returns the minimum array data type for storing a provided unsigned integer value. -* -* @param value - scalar value -* @returns array data type -* -* @example -* var dt = minUnsignedIntegerDataType( 1280 ); -* // returns 'uint16' -* -* @example -* var dt = minUnsignedIntegerDataType( 3 ); -* // returns 'uint8' -*/ -declare function minUnsignedIntegerDataType( value: number ): DataType; - - -// EXPORTS // - -export = minUnsignedIntegerDataType; diff --git a/base/min-unsigned-integer-dtype/docs/types/test.ts b/base/min-unsigned-integer-dtype/docs/types/test.ts deleted file mode 100644 index 74edbce97..000000000 --- a/base/min-unsigned-integer-dtype/docs/types/test.ts +++ /dev/null @@ -1,33 +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. -*/ - -import minUnsignedIntegerDataType = require( './index' ); - - -// TESTS // - -// The function returns a data type... -{ - minUnsignedIntegerDataType( 2 ); // $ExpectType DataType -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - minUnsignedIntegerDataType(); // $ExpectError - minUnsignedIntegerDataType( 3, 3 ); // $ExpectError -} diff --git a/base/min-unsigned-integer-dtype/examples/index.js b/base/min-unsigned-integer-dtype/examples/index.js deleted file mode 100644 index f20f66c80..000000000 --- a/base/min-unsigned-integer-dtype/examples/index.js +++ /dev/null @@ -1,36 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var exp2 = require( '@stdlib/math/base/special/exp2' ); -var minUnsignedIntegerDataType = require( './../lib' ); // eslint-disable-line id-length - -// Generate random powers: -var exp = discreteUniform( 100, 0, 40, { - 'dtype': 'generic' -}); - -// Determine the minimum data type for each generated value... -var v; -var i; -for ( i = 0; i < exp.length; i++ ) { - v = exp2( exp[ i ] ); - console.log( 'min(%d) => %s', v, minUnsignedIntegerDataType( v ) ); -} diff --git a/base/min-unsigned-integer-dtype/lib/index.js b/base/min-unsigned-integer-dtype/lib/index.js deleted file mode 100644 index b3b8598d1..000000000 --- a/base/min-unsigned-integer-dtype/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Determine the minimum array data type for storing a provided unsigned integer value. -* -* @module @stdlib/array/base/min-unsigned-integer-dtype -* -* @example -* var minUnsignedIntegerDataType = require( '@stdlib/array/base/min-unsigned-integer-dtype' ); -* -* var dt = minUnsignedIntegerDataType( 1280 ); -* // returns 'uint16' -* -* dt = minUnsignedIntegerDataType( 3 ); -* // returns 'uint8' -*/ - -// MODULES // - -var minUnsignedIntegerDataType = require( './main.js' ); // eslint-disable-line id-length - - -// EXPORTS // - -module.exports = minUnsignedIntegerDataType; diff --git a/base/min-unsigned-integer-dtype/lib/main.js b/base/min-unsigned-integer-dtype/lib/main.js deleted file mode 100644 index 9660f7c4f..000000000 --- a/base/min-unsigned-integer-dtype/lib/main.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var UINT8_MAX = require( '@stdlib/constants/uint8/max' ); -var UINT16_MAX = require( '@stdlib/constants/uint16/max' ); -var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); - - -// MAIN // - -/** -* Returns the minimum array data type for storing a provided unsigned integer value. -* -* @param {uinteger} value - scalar value -* @returns {string} array data type -* -* @example -* var dt = minUnsignedIntegerDataType( 9999 ); -* // returns 'uint16' -* -* @example -* var dt = minUnsignedIntegerDataType( 3 ); -* // returns 'uint8' -*/ -function minUnsignedIntegerDataType( value ) { // eslint-disable-line id-length - if ( value <= UINT8_MAX ) { - return 'uint8'; - } - if ( value <= UINT16_MAX ) { - return 'uint16'; - } - if ( value <= UINT32_MAX ) { - return 'uint32'; - } - return 'float64'; -} - - -// EXPORTS // - -module.exports = minUnsignedIntegerDataType; diff --git a/base/min-unsigned-integer-dtype/package.json b/base/min-unsigned-integer-dtype/package.json deleted file mode 100644 index 08490f622..000000000 --- a/base/min-unsigned-integer-dtype/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/array/base/min-unsigned-integer-dtype", - "version": "0.0.0", - "description": "Determine the minimum array data type for storing a provided unsigned integer value.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "base", - "scalar", - "type", - "memory", - "minimum", - "integer", - "int", - "uint", - "unsigned", - "dtype", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/base/min-unsigned-integer-dtype/test/test.js b/base/min-unsigned-integer-dtype/test/test.js deleted file mode 100644 index a2408a411..000000000 --- a/base/min-unsigned-integer-dtype/test/test.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var minUnsignedIntegerDataType = require( './../lib' ); // eslint-disable-line id-length - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minUnsignedIntegerDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the minimum array data type for storing a provided unsigned integer value', function test( t ) { - var expected; - var actual; - var values; - var i; - - values = [ - 0, - 1, - 128, - 300, // >2**8 - 65537, // >2**16 - 99999999, - 4294967297 // >2**32 - ]; - expected = [ - 'uint8', - 'uint8', - 'uint8', - 'uint16', - 'uint32', - 'uint32', - 'float64' - - ]; - for ( i = 0; i < values.length; i++ ) { - actual = minUnsignedIntegerDataType( values[i] ); - t.strictEqual( actual, expected[ i ], 'returns expected value when provided '+values[i] ); - } - t.end(); -}); diff --git a/base/mskbinary2d/README.md b/base/mskbinary2d/README.md deleted file mode 100644 index 7526587aa..000000000 --- a/base/mskbinary2d/README.md +++ /dev/null @@ -1,129 +0,0 @@ - - -# mskbinary2d - -> Apply a binary callback to elements in two two-dimensional nested input arrays according to elements in a two-dimensional nested mask array and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var mskbinary2d = require( '@stdlib/array/base/mskbinary2d' ); -``` - -#### mskbinary2d( arrays, shape, fcn ) - -Applies a binary callback to elements in two two-dimensional nested input arrays according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); - -var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; -var z = zeros2d( [ 2, 2 ] ); - -var mask = [ [ 0, 1 ], [ 0, 0 ] ]; - -var shape = [ 2, 2 ]; - -mskbinary2d( [ x, x, mask, z ], shape, add ); -// z => [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays, an input nested mask array, and one output nested array. -- **shape**: array shape. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. -- An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var mskbinary2d = require( '@stdlib/array/base/mskbinary2d' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var mask = filled2dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var z = zeros2d( shape ); -console.log( z ); - -mskbinary2d( [ x, y, mask, z ], shape, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskbinary2d/benchmark/benchmark.js b/base/mskbinary2d/benchmark/benchmark.js deleted file mode 100644 index b708789d1..000000000 --- a/base/mskbinary2d/benchmark/benchmark.js +++ /dev/null @@ -1,121 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var mskbinary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - var m; - - x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - m = filled2dBy( shape, bernoulli( 0.5 ) ); - z = zeros2d( shape ); - - arrays = [ x, y, m, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - mskbinary2d( arrays, shape, add ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 3 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 3 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/mskbinary2d/docs/repl.txt b/base/mskbinary2d/docs/repl.txt deleted file mode 100644 index 523a84dd0..000000000 --- a/base/mskbinary2d/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a binary callback to elements in two two-dimensional nested input - arrays according to elements in a two-dimensional nested mask array and - assigns results to elements in a two-dimensional nested output array. - - An element in an input array is "masked" if the corresponding element in the - mask array is non-zero. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays, an input nested - mask array, and one output nested array. - - shape: Array - Array shape. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var m = [ [ 0, 1 ], [ 0, 0 ] ]; - > var z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shape = [ 2, 2 ]; - > {{alias}}( [ x, y, m, z ], shape, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ] - - See Also - -------- - diff --git a/base/mskbinary2d/docs/types/index.d.ts b/base/mskbinary2d/docs/types/index.d.ts deleted file mode 100644 index d104ca37c..000000000 --- a/base/mskbinary2d/docs/types/index.d.ts +++ /dev/null @@ -1,70 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Applies a binary callback to elements in two two-dimensional nested input arrays according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. -* -* @param arrays - array containing two input nested arrays, an input nested mask array, and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = zeros2d( shape ); -* -* var mask = [ [ 0, 1 ], [ 0, 0 ] ]; -* -* mskbinary2d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] -*/ -declare function mskbinary2d( arrays: [ Array2D, Array2D, Array2D, Array2D ], shape: Shape2D, fcn: Binary ): void; - - -// EXPORTS // - -export = mskbinary2d; diff --git a/base/mskbinary2d/docs/types/test.ts b/base/mskbinary2d/docs/types/test.ts deleted file mode 100644 index c992a3a88..000000000 --- a/base/mskbinary2d/docs/types/test.ts +++ /dev/null @@ -1,100 +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. -*/ - -import mskbinary2d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const m = [ [ 0, 1 ], [ 0, 0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - mskbinary2d( [ x, y, m, z ], [ 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - mskbinary2d( 'abc', [ 2, 2 ], fcn ); // $ExpectError - mskbinary2d( 3.14, [ 2, 2 ], fcn ); // $ExpectError - mskbinary2d( true, [ 2, 2 ], fcn ); // $ExpectError - mskbinary2d( false, [ 2, 2 ], fcn ); // $ExpectError - mskbinary2d( null, [ 2, 2 ], fcn ); // $ExpectError - mskbinary2d( [ '1' ], [ 2, 2 ], fcn ); // $ExpectError - mskbinary2d( {}, [ 2, 2 ], fcn ); // $ExpectError - mskbinary2d( ( x: number ): number => x, [ 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const m = [ [ 0, 1 ], [ 0, 0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - mskbinary2d( [ x, y, m, z ], 'abc', fcn ); // $ExpectError - mskbinary2d( [ x, y, m, z ], 3.14, fcn ); // $ExpectError - mskbinary2d( [ x, y, m, z ], true, fcn ); // $ExpectError - mskbinary2d( [ x, y, m, z ], false, fcn ); // $ExpectError - mskbinary2d( [ x, y, m, z ], null, fcn ); // $ExpectError - mskbinary2d( [ x, y, m, z ], [ '1' ], fcn ); // $ExpectError - mskbinary2d( [ x, y, m, z ], {}, fcn ); // $ExpectError - mskbinary2d( [ x, y, m, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const m = [ [ 0, 1 ], [ 0, 0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - mskbinary2d( [ x, y, m, z ], [ 2, 2 ], 'abc' ); // $ExpectError - mskbinary2d( [ x, y, m, z ], [ 2, 2 ], 3.14 ); // $ExpectError - mskbinary2d( [ x, y, m, z ], [ 2, 2 ], true ); // $ExpectError - mskbinary2d( [ x, y, m, z ], [ 2, 2 ], false ); // $ExpectError - mskbinary2d( [ x, y, m, z ], [ 2, 2 ], null ); // $ExpectError - mskbinary2d( [ x, y, m, z ], [ 2, 2 ], [ '1' ] ); // $ExpectError - mskbinary2d( [ x, y, m, z ], [ 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const m = [ [ 0, 1 ], [ 0, 0 ] ]; - const z = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - mskbinary2d(); // $ExpectError - mskbinary2d( [ x, y, m, z ] ); // $ExpectError - mskbinary2d( [ x, y, m, z ], [ 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/mskbinary2d/examples/index.js b/base/mskbinary2d/examples/index.js deleted file mode 100644 index e1a337a58..000000000 --- a/base/mskbinary2d/examples/index.js +++ /dev/null @@ -1,43 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var mskbinary2d = require( './../lib' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var mask = filled2dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var z = zeros2d( shape ); -console.log( z ); - -mskbinary2d( [ x, y, mask, z ], shape, add ); -console.log( z ); diff --git a/base/mskbinary2d/lib/index.js b/base/mskbinary2d/lib/index.js deleted file mode 100644 index 3f457458a..000000000 --- a/base/mskbinary2d/lib/index.js +++ /dev/null @@ -1,53 +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'; - -/** -* Apply a binary callback to elements in two two-dimensional nested input arrays according to elements in a two-dimensional nested mask array and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/mskbinary2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var mskbinary2d = require( '@stdlib/array/base/mskbinary2d' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = zeros2d( shape ); -* -* var mask = [ [ 0, 1 ], [ 0, 0 ] ]; -* -* mskbinary2d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskbinary2d/lib/main.js b/base/mskbinary2d/lib/main.js deleted file mode 100644 index 32f8fa92c..000000000 --- a/base/mskbinary2d/lib/main.js +++ /dev/null @@ -1,92 +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'; - -// MAIN // - -/** -* Applies a binary callback to elements in two two-dimensional nested input arrays according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = zeros2d( shape ); -* -* var mask = [ [ 0, 1 ], [ 0, 0 ] ]; -* -* mskbinary2d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] -*/ -function mskbinary2d( arrays, shape, fcn ) { - var S0; - var S1; - var i0; - var i1; - var x0; - var y0; - var z0; - var m0; - var x; - var y; - var z; - var m; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 3 ]; - m = arrays[ 2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x[ i1 ]; - y0 = y[ i1 ]; - z0 = z[ i1 ]; - m0 = m[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - if ( m0[ i0 ] === 0 ) { - z0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] ); - } - } - } -} - - -// EXPORTS // - -module.exports = mskbinary2d; diff --git a/base/mskbinary2d/package.json b/base/mskbinary2d/package.json deleted file mode 100644 index 50ac7ce33..000000000 --- a/base/mskbinary2d/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/mskbinary2d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two two-dimensional nested input arrays according to elements in a two-dimensional nested mask array and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "binary", - "apply", - "foreach", - "map", - "transform", - "masked", - "mask", - "skip", - "skipped", - "missing", - "missing values", - "na" - ], - "__stdlib__": {} -} diff --git a/base/mskbinary2d/test/test.js b/base/mskbinary2d/test/test.js deleted file mode 100644 index b76364847..000000000 --- a/base/mskbinary2d/test/test.js +++ /dev/null @@ -1,159 +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 add = require( '@stdlib/number/float64/base/add' ); -var zeros2d = require( './../../../base/zeros2d' ); -var mskbinary2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskbinary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = zeros2d( shape ); - m = [ - [ 0, 1 ], - [ 0, 0 ] - ]; - - expected = [ - [ 6.0, 0.0 ], - [ 10.0, 12.0 ] - ]; - mskbinary2d( [ x, y, m, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = zeros2d( shape ); - m = [ - [ 1, 0 ], - [ 1, 0 ] - ]; - - expected = [ - [ 0.0, 8.0 ], - [ 0.0, 12.0 ] - ]; - mskbinary2d( [ x, y, m, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = zeros2d( shape ); - m = [ - [ 0, 1 ], - [ 0, 0 ] - ]; - - expected = zeros2d( shape ); - mskbinary2d( [ x, y, m, z ], [ 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = zeros2d( shape ); - m = [ - [ 0, 1 ], - [ 0, 0 ] - ]; - - expected = zeros2d( shape ); - mskbinary2d( [ x, y, m, z ], [ 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/mskbinary3d/README.md b/base/mskbinary3d/README.md deleted file mode 100644 index f3fd976f9..000000000 --- a/base/mskbinary3d/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# mskbinary3d - -> Apply a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var mskbinary3d = require( '@stdlib/array/base/mskbinary3d' ); -``` - -#### mskbinary3d( arrays, shape, fcn ) - -Applies a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); - -var x = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] -]; -var z = zeros3d( [ 2, 2, 2 ] ); - -var mask = [ - [ [ 0, 1 ], [ 0, 0 ] ], - [ [ 1, 0 ], [ 0, 1 ] ] -]; - -var shape = [ 2, 2, 2 ]; - -mskbinary3d( [ x, x, mask, z ], shape, add ); -// z => [ [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ], [ [ 0.0, 12.0 ], [ 14.0, 0.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays, an input nested mask array, and one output nested array. -- **shape**: array shape. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. -- An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var mskbinary3d = require( '@stdlib/array/base/mskbinary3d' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var mask = filled3dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var z = zeros3d( shape ); -console.log( z ); - -mskbinary3d( [ x, y, mask, z ], shape, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskbinary3d/benchmark/benchmark.js b/base/mskbinary3d/benchmark/benchmark.js deleted file mode 100644 index 6e92f6c96..000000000 --- a/base/mskbinary3d/benchmark/benchmark.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var mskbinary3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - var m; - - x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - m = filled3dBy( shape, bernoulli( 0.5 ) ); - z = zeros3d( shape ); - - arrays = [ x, y, m, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - mskbinary3d( arrays, shape, add ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/mskbinary3d/docs/repl.txt b/base/mskbinary3d/docs/repl.txt deleted file mode 100644 index 9d01e4637..000000000 --- a/base/mskbinary3d/docs/repl.txt +++ /dev/null @@ -1,46 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a binary callback to elements in two three-dimensional nested input - arrays according to elements in a three-dimensional nested mask array and - assigns results to elements in a three-dimensional nested output array. - - An element in an input array is "masked" if the corresponding element in the - mask array is non-zero. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays, an input nested - mask array, and one output nested array. - - shape: Array - Array shape. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ - ... [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - ... [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ... ]; - > var y = [ - ... [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - ... [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ... ]; - > var m = [ - ... [ [ 0, 1 ], [ 0, 0 ] ], - ... [ [ 1, 0 ], [ 0, 1 ] ] - ... ]; - > var z = [ - ... [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], - ... [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] - ... ]; - > var shape = [ 2, 2, 2 ]; - > {{alias}}( [ x, y, m, z ], shape, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ], [ [ 0.0, 12.0 ], [ 14.0, 0.0 ] ] ] - - See Also - -------- diff --git a/base/mskbinary3d/docs/types/index.d.ts b/base/mskbinary3d/docs/types/index.d.ts deleted file mode 100644 index 8de82edad..000000000 --- a/base/mskbinary3d/docs/types/index.d.ts +++ /dev/null @@ -1,73 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Applies a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. -* -* @param arrays - array containing two input nested arrays, an input nested mask array, and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 2, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = zeros3d( shape ); -* -* var mask = [ -* [ [ 0, 1 ], [ 0, 0 ] ], -* [ [ 1, 0 ], [ 0, 1 ] ] -* ]; -* -* mskbinary3d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ], [ [ 0.0, 2.0 ], [ 2.0, 0.0 ] ] ] -*/ -declare function mskbinary3d( arrays: [ Array3D, Array3D, Array3D, Array3D ], shape: Shape3D, fcn: Binary ): void; - - -// EXPORTS // - -export = mskbinary3d; diff --git a/base/mskbinary3d/docs/types/test.ts b/base/mskbinary3d/docs/types/test.ts deleted file mode 100644 index b6057973d..000000000 --- a/base/mskbinary3d/docs/types/test.ts +++ /dev/null @@ -1,148 +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. -*/ - -import mskbinary3d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - const y = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - const m = [ - [ [ 0, 1 ], [ 0, 0 ] ], - [ [ 1, 0 ], [ 0, 1 ] ] - ]; - const z = [ - [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], - [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] - ]; - - mskbinary3d( [ x, y, m, z ], [ 2, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - mskbinary3d( 'abc', [ 2, 2, 2 ], fcn ); // $ExpectError - mskbinary3d( 3.14, [ 2, 2, 2 ], fcn ); // $ExpectError - mskbinary3d( true, [ 2, 2, 2 ], fcn ); // $ExpectError - mskbinary3d( false, [ 2, 2, 2 ], fcn ); // $ExpectError - mskbinary3d( null, [ 2, 2, 2 ], fcn ); // $ExpectError - mskbinary3d( [ '1' ], [ 2, 2, 2 ], fcn ); // $ExpectError - mskbinary3d( {}, [ 2, 2, 2 ], fcn ); // $ExpectError - mskbinary3d( ( x: number ): number => x, [ 2, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - const y = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - const m = [ - [ [ 0, 1 ], [ 0, 0 ] ], - [ [ 1, 0 ], [ 0, 1 ] ] - ]; - const z = [ - [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], - [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] - ]; - - mskbinary3d( [ x, y, m, z ], 'abc', fcn ); // $ExpectError - mskbinary3d( [ x, y, m, z ], 3.14, fcn ); // $ExpectError - mskbinary3d( [ x, y, m, z ], true, fcn ); // $ExpectError - mskbinary3d( [ x, y, m, z ], false, fcn ); // $ExpectError - mskbinary3d( [ x, y, m, z ], null, fcn ); // $ExpectError - mskbinary3d( [ x, y, m, z ], [ '1' ], fcn ); // $ExpectError - mskbinary3d( [ x, y, m, z ], {}, fcn ); // $ExpectError - mskbinary3d( [ x, y, m, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - const y = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - const m = [ - [ [ 0, 1 ], [ 0, 0 ] ], - [ [ 1, 0 ], [ 0, 1 ] ] - ]; - const z = [ - [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], - [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] - ]; - - mskbinary3d( [ x, y, m, z ], [ 2, 2, 2 ], 'abc' ); // $ExpectError - mskbinary3d( [ x, y, m, z ], [ 2, 2, 2 ], 3.14 ); // $ExpectError - mskbinary3d( [ x, y, m, z ], [ 2, 2, 2 ], true ); // $ExpectError - mskbinary3d( [ x, y, m, z ], [ 2, 2, 2 ], false ); // $ExpectError - mskbinary3d( [ x, y, m, z ], [ 2, 2, 2 ], null ); // $ExpectError - mskbinary3d( [ x, y, m, z ], [ 2, 2, 2 ], [ '1' ] ); // $ExpectError - mskbinary3d( [ x, y, m, z ], [ 2, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - const y = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - const m = [ - [ [ 0, 1 ], [ 0, 0 ] ], - [ [ 1, 0 ], [ 0, 1 ] ] - ]; - const z = [ - [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ], - [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] - ]; - - mskbinary3d(); // $ExpectError - mskbinary3d( [ x, y, m, z ] ); // $ExpectError - mskbinary3d( [ x, y, m, z ], [ 2, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/mskbinary3d/examples/index.js b/base/mskbinary3d/examples/index.js deleted file mode 100644 index a3696616a..000000000 --- a/base/mskbinary3d/examples/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var mskbinary3d = require( './../lib' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var mask = filled3dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var z = zeros3d( shape ); -console.log( z ); - -mskbinary3d( [ x, y, mask, z ], shape, add ); -console.log( z ); diff --git a/base/mskbinary3d/lib/index.js b/base/mskbinary3d/lib/index.js deleted file mode 100644 index 3aaa168ce..000000000 --- a/base/mskbinary3d/lib/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -/** -* Apply a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/mskbinary3d -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var mskbinary3d = require( '@stdlib/array/base/mskbinary3d' ); -* -* var shape = [ 2, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = zeros3d( shape ); -* -* var mask = [ -* [ [ 0, 1 ], [ 0, 0 ] ], -* [ [ 1, 0 ], [ 0, 1 ] ] -* ]; -* -* mskbinary3d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ], [ [ 0.0, 2.0 ], [ 2.0, 0.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskbinary3d/lib/main.js b/base/mskbinary3d/lib/main.js deleted file mode 100644 index 48c6c76d5..000000000 --- a/base/mskbinary3d/lib/main.js +++ /dev/null @@ -1,108 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 2, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = zeros3d( shape ); -* -* var mask = [ -* [ [ 0, 1 ], [ 0, 0 ] ], -* [ [ 1, 0 ], [ 0, 1 ] ] -* ]; -* -* mskbinary3d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ], [ [ 0.0, 2.0 ], [ 2.0, 0.0 ] ] ] -*/ -function mskbinary3d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var x0; - var y0; - var z0; - var m0; - var x1; - var y1; - var z1; - var m1; - var x; - var y; - var z; - var m; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 3 ]; - m = arrays[ 2 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x[ i2 ]; - y1 = y[ i2 ]; - z1 = z[ i2 ]; - m1 = m[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - m0 = m1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - if ( m0[ i0 ] === 0 ) { - z0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] ); - } - } - } - } -} - - -// EXPORTS // - -module.exports = mskbinary3d; diff --git a/base/mskbinary3d/package.json b/base/mskbinary3d/package.json deleted file mode 100644 index b709b68e2..000000000 --- a/base/mskbinary3d/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/mskbinary3d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "binary", - "apply", - "foreach", - "map", - "transform", - "masked", - "mask", - "skip", - "skipped", - "missing", - "missing values", - "na" - ], - "__stdlib__": {} -} diff --git a/base/mskbinary3d/test/test.js b/base/mskbinary3d/test/test.js deleted file mode 100644 index c71b6f87a..000000000 --- a/base/mskbinary3d/test/test.js +++ /dev/null @@ -1,170 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/number/float64/base/add' ); -var zeros3d = require( './../../../base/zeros3d' ); -var mskbinary3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskbinary3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 2, 2, 2 ]; - x = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - y = [ - [ [ 10.0, 20.0 ], [ 30.0, 40.0 ] ], - [ [ 50.0, 60.0 ], [ 70.0, 80.0 ] ] - ]; - z = zeros3d( shape ); - m = [ - [ [ 0, 1 ], [ 0, 0 ] ], - [ [ 1, 0 ], [ 0, 1 ] ] - ]; - - expected = [ - [ [ 11.0, 0.0 ], [ 33.0, 44.0 ] ], - [ [ 0.0, 66.0 ], [ 77.0, 0.0 ] ] - ]; - mskbinary3d( [ x, y, m, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 2, 2, 2 ]; - x = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - y = [ - [ [ 10.0, 20.0 ], [ 30.0, 40.0 ] ], - [ [ 50.0, 60.0 ], [ 70.0, 80.0 ] ] - ]; - z = zeros3d( shape ); - m = [ - [ [ 0, 1 ], [ 0, 0 ] ], - [ [ 1, 0 ], [ 0, 1 ] ] - ]; - - expected = zeros3d( shape ); - mskbinary3d( [ x, y, m, z ], [ 0, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 2, 2, 2 ]; - x = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - y = [ - [ [ 10.0, 20.0 ], [ 30.0, 40.0 ] ], - [ [ 50.0, 60.0 ], [ 70.0, 80.0 ] ] - ]; - z = zeros3d( shape ); - m = [ - [ [ 0, 1 ], [ 0, 0 ] ], - [ [ 1, 0 ], [ 0, 1 ] ] - ]; - - expected = zeros3d( shape ); - mskbinary3d( [ x, y, m, z ], [ 2, 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 2, 2, 2 ]; - x = [ - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ], - [ [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] - ]; - y = [ - [ [ 10.0, 20.0 ], [ 30.0, 40.0 ] ], - [ [ 50.0, 60.0 ], [ 70.0, 80.0 ] ] - ]; - z = zeros3d( shape ); - m = [ - [ [ 0, 1 ], [ 0, 0 ] ], - [ [ 1, 0 ], [ 0, 1 ] ] - ]; - - expected = zeros3d( shape ); - mskbinary3d( [ x, y, m, z ], [ 2, 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/mskbinary4d/README.md b/base/mskbinary4d/README.md deleted file mode 100644 index e07287293..000000000 --- a/base/mskbinary4d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# mskbinary4d - -> Apply a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var mskbinary4d = require( '@stdlib/array/base/mskbinary4d' ); -``` - -#### mskbinary4d( arrays, shape, fcn ) - -Applies a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); - -var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; -var z = zeros4d( [ 1, 1, 2, 2 ] ); - -var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - -var shape = [ 1, 1, 2, 2 ]; - -mskbinary4d( [ x, x, mask, z ], shape, add ); -// z => [ [ [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays, an input nested mask array, and one output nested array. -- **shape**: array shape. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var mskbinary4d = require( '@stdlib/array/base/mskbinary4d' ); - -var shape = [ 2, 1, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var mask = filled4dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var z = zeros4d( shape ); -console.log( z ); - -mskbinary4d( [ x, y, mask, z ], shape, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskbinary4d/benchmark/benchmark.js b/base/mskbinary4d/benchmark/benchmark.js deleted file mode 100644 index e95e5dcba..000000000 --- a/base/mskbinary4d/benchmark/benchmark.js +++ /dev/null @@ -1,127 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var mskbinary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - var m; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - m = filled4dBy( shape, bernoulli( 0.5 ) ); - z = zeros4d( shape ); - - arrays = [ x, y, m, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - mskbinary4d( arrays, shape, add ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 3 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 3 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/mskbinary4d/docs/repl.txt b/base/mskbinary4d/docs/repl.txt deleted file mode 100644 index b3bfb5849..000000000 --- a/base/mskbinary4d/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a binary callback to elements in two four-dimensional nested input - arrays according to elements in a four-dimensional nested mask array and - assigns results to elements in a four-dimensional nested output array. - - An element in an input array is "masked" if the corresponding element in the - mask array is non-zero. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays, an input nested - mask array, and one output nested array. - - shape: Array - Array shape. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var m = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - > var z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > {{alias}}( [ x, y, m, z ], shape, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ] ] ] - - See Also - -------- - diff --git a/base/mskbinary4d/docs/types/index.d.ts b/base/mskbinary4d/docs/types/index.d.ts deleted file mode 100644 index c4132a4ba..000000000 --- a/base/mskbinary4d/docs/types/index.d.ts +++ /dev/null @@ -1,70 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Applies a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. -* -* @param arrays - array containing two input nested arrays, an input nested mask array, and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = zeros4d( shape ); -* -* var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; -* -* mskbinary2d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ] -*/ -declare function mskbinary4d( arrays: [ Array4D, Array4D, Array4D, Array4D ], shape: Shape4D, fcn: Binary ): void; - - -// EXPORTS // - -export = mskbinary4d; diff --git a/base/mskbinary4d/docs/types/test.ts b/base/mskbinary4d/docs/types/test.ts deleted file mode 100644 index 7917dc6ea..000000000 --- a/base/mskbinary4d/docs/types/test.ts +++ /dev/null @@ -1,100 +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. -*/ - -import mskbinary4d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const m = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - mskbinary4d( [ x, y, m, z ], [ 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - mskbinary4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const m = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - mskbinary4d( [ x, y, m, z ], 'abc', fcn ); // $ExpectError - mskbinary4d( [ x, y, m, z ], 3.14, fcn ); // $ExpectError - mskbinary4d( [ x, y, m, z ], true, fcn ); // $ExpectError - mskbinary4d( [ x, y, m, z ], false, fcn ); // $ExpectError - mskbinary4d( [ x, y, m, z ], null, fcn ); // $ExpectError - mskbinary4d( [ x, y, m, z ], [ '1' ], fcn ); // $ExpectError - mskbinary4d( [ x, y, m, z ], {}, fcn ); // $ExpectError - mskbinary4d( [ x, y, m, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const m = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - mskbinary4d( [ x, y, m, z ], [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - mskbinary4d( [ x, y, m, z ], [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - mskbinary4d( [ x, y, m, z ], [ 1, 1, 2, 2 ], true ); // $ExpectError - mskbinary4d( [ x, y, m, z ], [ 1, 1, 2, 2 ], false ); // $ExpectError - mskbinary4d( [ x, y, m, z ], [ 1, 1, 2, 2 ], null ); // $ExpectError - mskbinary4d( [ x, y, m, z ], [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - mskbinary4d( [ x, y, m, z ], [ 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const m = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - const z = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - mskbinary4d(); // $ExpectError - mskbinary4d( [ x, y, m, z ] ); // $ExpectError - mskbinary4d( [ x, y, m, z ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/mskbinary4d/examples/index.js b/base/mskbinary4d/examples/index.js deleted file mode 100644 index e26f85a44..000000000 --- a/base/mskbinary4d/examples/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var mskbinary4d = require( './../lib' ); - -var shape = [ 2, 1, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var mask = filled4dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var z = zeros4d( shape ); -console.log( z ); - -mskbinary4d( [ x, y, mask, z ], shape, add ); -console.log( z ); diff --git a/base/mskbinary4d/lib/index.js b/base/mskbinary4d/lib/index.js deleted file mode 100644 index b705d8cc3..000000000 --- a/base/mskbinary4d/lib/index.js +++ /dev/null @@ -1,53 +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. -*/ - -'use strict'; - -/** -* Apply a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/mskbinary4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var mskbinary4d = require( '@stdlib/array/base/mskbinary4d' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = zeros4d( shape ); -* -* var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; -* -* mskbinary4d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskbinary4d/lib/main.js b/base/mskbinary4d/lib/main.js deleted file mode 100644 index 3cff337b3..000000000 --- a/base/mskbinary4d/lib/main.js +++ /dev/null @@ -1,118 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = zeros4d( shape ); -* -* var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; -* -* mskbinary4d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ] -*/ -function mskbinary4d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var x1; - var x2; - var y0; - var y1; - var y2; - var z0; - var z1; - var z2; - var m0; - var m1; - var m2; - var x; - var y; - var z; - var m; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - m = arrays[ 2 ]; - z = arrays[ 3 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - z2 = z[ i3 ]; - m2 = m[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - z1 = z2[ i2 ]; - m1 = m2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - m0 = m1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - if ( m0[ i0 ] === 0 ) { - z0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] ); - } - } - } - } - } -} - - -// EXPORTS // - -module.exports = mskbinary4d; diff --git a/base/mskbinary4d/package.json b/base/mskbinary4d/package.json deleted file mode 100644 index 6bd215c29..000000000 --- a/base/mskbinary4d/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/mskbinary4d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "binary", - "apply", - "foreach", - "map", - "transform", - "masked", - "mask", - "skip", - "skipped", - "missing", - "missing values", - "na" - ], - "__stdlib__": {} -} diff --git a/base/mskbinary4d/test/test.js b/base/mskbinary4d/test/test.js deleted file mode 100644 index fb6f6b44b..000000000 --- a/base/mskbinary4d/test/test.js +++ /dev/null @@ -1,306 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/number/float64/base/add' ); -var zeros4d = require( './../../../base/zeros4d' ); -var mskbinary4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskbinary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = zeros4d( shape ); - m = [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 6.0, 0.0 ], - [ 10.0, 12.0 ] - ] - ] - ]; - mskbinary4d( [ x, y, m, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = zeros4d( shape ); - m = [ - [ - [ - [ 1, 0 ], - [ 1, 0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 0.0, 8.0 ], - [ 0.0, 12.0 ] - ] - ] - ]; - mskbinary4d( [ x, y, m, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = zeros4d( shape ); - m = [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - mskbinary4d( [ x, y, m, z ], [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = zeros4d( shape ); - m = [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - mskbinary4d( [ x, y, m, z ], [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = zeros4d( shape ); - m = [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - mskbinary4d( [ x, y, m, z ], [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = zeros4d( shape ); - m = [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - mskbinary4d( [ x, y, m, z ], [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/mskbinary5d/README.md b/base/mskbinary5d/README.md deleted file mode 100644 index 0df427a1e..000000000 --- a/base/mskbinary5d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# mskbinary5d - -> Apply a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var mskbinary5d = require( '@stdlib/array/base/mskbinary5d' ); -``` - -#### mskbinary5d( arrays, shape, fcn ) - -Applies a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); - -var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; -var z = zeros5d( [ 1, 1, 1, 2, 2 ] ); - -var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - -var shape = [ 1, 1, 1, 2, 2 ]; - -mskbinary5d( [ x, x, mask, z ], shape, add ); -// z => [ [ [ [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing two input nested arrays, an input nested mask array, and one output nested array. -- **shape**: array shape. -- **fcn**: binary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var mskbinary5d = require( '@stdlib/array/base/mskbinary5d' ); - -var shape = [ 1, 2, 1, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var mask = filled5dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var z = zeros5d( shape ); -console.log( z ); - -mskbinary5d( [ x, y, mask, z ], shape, add ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskbinary5d/benchmark/benchmark.js b/base/mskbinary5d/benchmark/benchmark.js deleted file mode 100644 index 17046ff7b..000000000 --- a/base/mskbinary5d/benchmark/benchmark.js +++ /dev/null @@ -1,130 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var add = require( '@stdlib/number/float64/base/add' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var mskbinary5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - var z; - var m; - - x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - m = filled5dBy( shape, bernoulli( 0.5 ) ); - z = zeros5d( shape ); - - arrays = [ x, y, m, z ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - mskbinary5d( arrays, shape, add ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 3 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 3 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/mskbinary5d/docs/repl.txt b/base/mskbinary5d/docs/repl.txt deleted file mode 100644 index 49c776733..000000000 --- a/base/mskbinary5d/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a binary callback to elements in two five-dimensional nested input - arrays according to elements in a five-dimensional nested mask array and - assigns results to elements in a five-dimensional nested output array. - - An element in an input array is "masked" if the corresponding element in the - mask array is non-zero. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing two input nested arrays, an input nested - mask array, and one output nested array. - - shape: Array - Array shape. - - fcn: Function - Binary callback. - - Examples - -------- - > var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var m = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - > var z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shape = [ 1, 1, 1, 2, 2 ]; - > {{alias}}( [ x, y, m, z ], shape, {{alias:@stdlib/number/float64/base/add}} ); - > z - [ [ [ [ [ 2.0, 0.0 ], [ 6.0, 8.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/mskbinary5d/docs/types/index.d.ts b/base/mskbinary5d/docs/types/index.d.ts deleted file mode 100644 index a88173a09..000000000 --- a/base/mskbinary5d/docs/types/index.d.ts +++ /dev/null @@ -1,70 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Binary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @returns result -*/ -type Binary = ( v1: T, v2: U ) => V; - -/** -* Applies a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. -* -* @param arrays - array containing two input nested arrays, an input nested mask array, and one output nested array -* @param shape - array shape -* @param fcn - binary callback -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = zeros5d( shape ); -* -* var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; -* -* mskbinary5d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ] ] -*/ -declare function mskbinary5d( arrays: [ Array5D, Array5D, Array5D, Array5D ], shape: Shape5D, fcn: Binary ): void; - - -// EXPORTS // - -export = mskbinary5d; diff --git a/base/mskbinary5d/docs/types/test.ts b/base/mskbinary5d/docs/types/test.ts deleted file mode 100644 index 309e75c0e..000000000 --- a/base/mskbinary5d/docs/types/test.ts +++ /dev/null @@ -1,100 +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. -*/ - -import mskbinary5d = require( './index' ); - -/** -* Binary function. -* -* @param x - input value -* @param y - input value -* @returns result -*/ -function fcn( x: number, y: number ): number { - return x + y; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const m = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - mskbinary5d( [ x, y, m, z ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - mskbinary5d( 'abc', [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary5d( 3.14, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary5d( true, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary5d( false, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary5d( null, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary5d( [ '1' ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary5d( {}, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskbinary5d( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const m = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - mskbinary5d( [ x, y, m, z ], 'abc', fcn ); // $ExpectError - mskbinary5d( [ x, y, m, z ], 3.14, fcn ); // $ExpectError - mskbinary5d( [ x, y, m, z ], true, fcn ); // $ExpectError - mskbinary5d( [ x, y, m, z ], false, fcn ); // $ExpectError - mskbinary5d( [ x, y, m, z ], null, fcn ); // $ExpectError - mskbinary5d( [ x, y, m, z ], [ '1' ], fcn ); // $ExpectError - mskbinary5d( [ x, y, m, z ], {}, fcn ); // $ExpectError - mskbinary5d( [ x, y, m, z ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const m = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - mskbinary5d( [ x, y, m, z ], [ 1, 1, 1, 2, 2 ], 'abc' ); // $ExpectError - mskbinary5d( [ x, y, m, z ], [ 1, 1, 1, 2, 2 ], 3.14 ); // $ExpectError - mskbinary5d( [ x, y, m, z ], [ 1, 1, 1, 2, 2 ], true ); // $ExpectError - mskbinary5d( [ x, y, m, z ], [ 1, 1, 1, 2, 2 ], false ); // $ExpectError - mskbinary5d( [ x, y, m, z ], [ 1, 1, 1, 2, 2 ], null ); // $ExpectError - mskbinary5d( [ x, y, m, z ], [ 1, 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - mskbinary5d( [ x, y, m, z ], [ 1, 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const m = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - const z = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - mskbinary5d(); // $ExpectError - mskbinary5d( [ x, y, m, z ] ); // $ExpectError - mskbinary5d( [ x, y, m, z ], [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/mskbinary5d/examples/index.js b/base/mskbinary5d/examples/index.js deleted file mode 100644 index e26e80dde..000000000 --- a/base/mskbinary5d/examples/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add' ); -var mskbinary5d = require( './../../../base/mskbinary5d/lib' ); - -var shape = [ 1, 2, 1, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var mask = filled5dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var z = zeros5d( shape ); -console.log( z ); - -mskbinary5d( [ x, y, mask, z ], shape, add ); -console.log( z ); diff --git a/base/mskbinary5d/lib/index.js b/base/mskbinary5d/lib/index.js deleted file mode 100644 index 6f8b1112e..000000000 --- a/base/mskbinary5d/lib/index.js +++ /dev/null @@ -1,53 +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. -*/ - -'use strict'; - -/** -* Apply a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/mskbinary5d -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* var mskbinary5d = require( '@stdlib/array/base/mskbinary5d' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = zeros5d( shape ); -* -* var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; -* -* mskbinary5d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskbinary5d/lib/main.js b/base/mskbinary5d/lib/main.js deleted file mode 100644 index 22d929e22..000000000 --- a/base/mskbinary5d/lib/main.js +++ /dev/null @@ -1,133 +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. -*/ - -/* eslint-disable max-depth */ - -'use strict'; - -// MAIN // - -/** -* Applies a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - binary callback -* @returns {void} -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = zeros5d( shape ); -* -* var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; -* -* mskbinary5d( [ x, y, mask, z ], shape, add ); -* -* console.log( z ); -* // => [ [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ] ] -*/ -function mskbinary5d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var x0; - var x1; - var x2; - var x3; - var y0; - var y1; - var y2; - var y3; - var z0; - var z1; - var z2; - var z3; - var m0; - var m1; - var m2; - var m3; - var x; - var y; - var z; - var m; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - m = arrays[ 2 ]; - z = arrays[ 3 ]; - for ( i4 = 0; i4 < S4; i4++ ) { - x3 = x[ i4 ]; - y3 = y[ i4 ]; - z3 = z[ i4 ]; - m3 = m[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x3[ i3 ]; - y2 = y3[ i3 ]; - z2 = z3[ i3 ]; - m2 = m3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - z1 = z2[ i2 ]; - m1 = m2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - m0 = m1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - if ( m0[ i0 ] === 0 ) { - z0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] ); - } - } - } - } - } - } -} - - -// EXPORTS // - -module.exports = mskbinary5d; diff --git a/base/mskbinary5d/package.json b/base/mskbinary5d/package.json deleted file mode 100644 index e230e4e07..000000000 --- a/base/mskbinary5d/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/mskbinary5d", - "version": "0.0.0", - "description": "Apply a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "binary", - "apply", - "foreach", - "map", - "transform", - "masked", - "mask", - "skip", - "skipped", - "missing", - "missing values", - "na" - ], - "__stdlib__": {} -} diff --git a/base/mskbinary5d/test/test.js b/base/mskbinary5d/test/test.js deleted file mode 100644 index 35ab78ce6..000000000 --- a/base/mskbinary5d/test/test.js +++ /dev/null @@ -1,397 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/number/float64/base/add' ); -var zeros5d = require( './../../../base/zeros5d' ); -var mskbinary5d = require( './../../../base/mskbinary5d/lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskbinary5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 6.0, 0.0 ], - [ 10.0, 12.0 ] - ] - ] - ] - ]; - mskbinary5d( [ x, y, m, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - m = [ - [ - [ - [ - [ 1, 0 ], - [ 1, 0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 0.0, 8.0 ], - [ 0.0, 12.0 ] - ] - ] - ] - ]; - mskbinary5d( [ x, y, m, z ], shape, add ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - mskbinary5d( [ x, y, m, z ], [ 0, 1, 1, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - mskbinary5d( [ x, y, m, z ], [ 1, 0, 1, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - mskbinary5d( [ x, y, m, z ], [ 1, 1, 0, 2, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - mskbinary5d( [ x, y, m, z ], [ 1, 1, 2, 0, 2 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); -tape( 'the function does not invoke a provided callback if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var z; - var m; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = zeros5d( shape ); - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - mskbinary5d( [ x, y, m, z ], [ 1, 1, 2, 2, 0 ], clbk ); - - t.deepEqual( z, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/mskfilter-map/README.md b/base/mskfilter-map/README.md deleted file mode 100644 index a617ee2cd..000000000 --- a/base/mskfilter-map/README.md +++ /dev/null @@ -1,171 +0,0 @@ - - -# mskfilterMap - -> Apply a mask and a callback function to a provided input array. - -
- -## Usage - -```javascript -var mskfilterMap = require( '@stdlib/array/base/mskfilter-map' ); -``` - -#### mskfilterMap( x, mask, clbk\[, thisArg] ) - -Returns a new array after applying a mask and a callback function to a provided input array. - -```javascript -function clbk( value ) { - return value * 2; -} - -var x = [ 1, 2, 3, 4 ]; -var m = [ 0, 1, 0, 1 ]; - -var y = mskfilterMap( x, m, clbk ); -// returns [ 4, 8 ] -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. -- **clbk**: callback to apply. -- **thisArg**: callback execution context (_optional_). - -To set the execution context of the callback function, provide a `thisArg`. - - - -```javascript -function clbk( x ) { - this.count += 1; - return x; -} - -var x = [ 1, 2, 3, 4 ]; -var m = [ 1, 1, 0, 1 ]; - -var ctx = { - 'count': 0 -}; - -var y = mskfilterMap( x, m, clbk, ctx ); -// returns [ 1, 2, 4 ] - -var v = ctx.count; -// returns 3 -``` - -The function **always** returns a new "generic" array. - -#### mskfilterMap.assign( x, mask, out, stride, offset, clbk\[, thisArg] ) - -Applies a mask and a callback function to a provided input array and assigns results to elements in a provided output array. - -```javascript -function clbk( value ) { - return value * 2; -} - -var x = [ 1, 2, 3, 4 ]; -var m = [ 0, 1, 0, 1 ]; - -var out = [ 0, 0, 0, 0 ]; -var arr = mskfilterMap.assign( x, m, out, -2, out.length-1, clbk ); -// returns [ 0, 8, 0, 4 ] - -var bool = ( arr === out ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. -- **clbk**: callback function. -- **thisArg**: callback execution context (_optional_). - -
- - - -
- -## Notes - -- If a `mask` array element is truthy, the corresponding element in `x` is **included** in the output array; otherwise, the corresponding element in `x` is "masked" and thus **excluded** from the output array. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var abs2 = require( '@stdlib/math/base/special/abs2' ); -var mskfilterMap = require( '@stdlib/array/base/mskfilter-map' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilterMap( x, mask, abs2 ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskfilter-map/benchmark/benchmark.assign.length.js b/base/mskfilter-map/benchmark/benchmark.assign.length.js deleted file mode 100644 index f622cee5a..000000000 --- a/base/mskfilter-map/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,106 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var zeros = require( './../../../zeros' ); -var ones = require( './../../../ones' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isnan = require( '@stdlib/assert/is-nan' ).isPrimitive; -var identity = require( '@stdlib/utils/identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var mask; - var out; - var x; - - x = zeroTo( len, 'generic' ); - mask = ones( len, 'generic' ); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap.assign( x, mask, out, 1, 0, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) || isnan( v[ i%len ] ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/mskfilter-map/benchmark/benchmark.js b/base/mskfilter-map/benchmark/benchmark.js deleted file mode 100644 index 4f2d53e5c..000000000 --- a/base/mskfilter-map/benchmark/benchmark.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var ones = require( './../../../base/ones' ); -var identity = require( '@stdlib/utils/identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/mskfilter-map/benchmark/benchmark.length.js b/base/mskfilter-map/benchmark/benchmark.length.js deleted file mode 100644 index a31f02029..000000000 --- a/base/mskfilter-map/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var ones = require( './../../../base/ones' ); -var isArray = require( '@stdlib/assert/is-array' ); -var identity = require( '@stdlib/utils/identity-function' ); -var pkg = require( './../package.json' ).name; -var mskfilterMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilterMap( x, y, identity ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/mskfilter-map/docs/repl.txt b/base/mskfilter-map/docs/repl.txt deleted file mode 100644 index 34e90a68e..000000000 --- a/base/mskfilter-map/docs/repl.txt +++ /dev/null @@ -1,84 +0,0 @@ - -{{alias}}( x, mask, clbk[, thisArg] ) - Returns a new array after applying a mask and a callback function to a - provided input array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` - is "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - clbk: Function - Function to apply. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, -2, -3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ], {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset, clbk[, thisArg] ) - Applies a mask and a callback function to a provided input array and assigns - results to elements in a provided output array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` - is "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - clbk: Function - Function to apply. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var m = [ 0, 1, 0, 1 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, m, out, 2, 0, {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 0, 4, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/base/mskfilter-map/docs/types/index.d.ts b/base/mskfilter-map/docs/types/index.d.ts deleted file mode 100644 index 708c4f8a5..000000000 --- a/base/mskfilter-map/docs/types/index.d.ts +++ /dev/null @@ -1,166 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @returns result -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, index: number, array: Collection ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param index - current array element index -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Returns a new array after applying a mask and a callback function to a provided input array. - * - * @param x - input array - * @param mask - mask array - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * function scale( val ) { - * return 10 * val; - * } - * - * var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); - * // returns [ 20, 40 ] - */ - ( x: Collection, mask: Collection, clbk: Callback, thisArg?: ThisParameterType> ): Array; - - /** - * Applies a mask and a callback function to an input array and assigns results to elements in an output array. - * - * @param x - input array - * @param mask - mask array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param clbk - callback function - * @param thisArg - callback execution context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var mask = [ 0, 1, 0, 1 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * - * function scale( x ) { - * return x * 10; - * } - * - * var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); - * // returns [ 20, 40, 0, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection, mask: Collection, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: ThisParameterType> ): Collection; -} - -/** -* Returns a new array after applying a mask and a callback function to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @param clbk - callback function -* @param thisArg - callback execution context -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function scale( val ) { -* return 10 * val; -* } -* -* var y = mskfilterMap( x, [ 0, 1, 0, 1 ], scale ); -* // returns [ 20, 40 ] -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* function scale( x ) { -* return x * 10; -* } -* -* var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); -* // returns [ 20, 40, 0, 0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var mskfilterMap: Routine; - - -// EXPORTS // - -export = mskfilterMap; - diff --git a/base/mskfilter-map/docs/types/test.ts b/base/mskfilter-map/docs/types/test.ts deleted file mode 100644 index 45029b41f..000000000 --- a/base/mskfilter-map/docs/types/test.ts +++ /dev/null @@ -1,260 +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. -*/ - -import mskfilterMap = require( './index' ); - -/** -* Callback function. -* -* @param value - input value -* @returns result -*/ -function clbk( value: number ): number { - return value; -} - -// TESTS // - -// The function returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk ); // $ExpectType number[] - mskfilterMap( x, [ 1, 1, 1, 1 ], clbk, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilterMap( 1, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk ); // $ExpectError - - mskfilterMap( 1, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( true, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( false, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( null, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( void 0, [ 0, 0 ], clbk, {} ); // $ExpectError - mskfilterMap( {}, [ 0, 0 ], clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilterMap( [], 1, clbk ); // $ExpectError - mskfilterMap( [], true, clbk ); // $ExpectError - mskfilterMap( [], false, clbk ); // $ExpectError - mskfilterMap( [], null, clbk ); // $ExpectError - mskfilterMap( [], void 0, clbk ); // $ExpectError - mskfilterMap( [], {}, clbk ); // $ExpectError - - mskfilterMap( [], 1, clbk, {} ); // $ExpectError - mskfilterMap( [], true, clbk, {} ); // $ExpectError - mskfilterMap( [], false, clbk, {} ); // $ExpectError - mskfilterMap( [], null, clbk, {} ); // $ExpectError - mskfilterMap( [], void 0, clbk, {} ); // $ExpectError - mskfilterMap( [], {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [1, 2]; - - mskfilterMap( x, [ 1, 1 ], 'abc' ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14 ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ] ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {} ); // $ExpectError - - mskfilterMap( x, [ 1, 1 ], 'abc', {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], 3.14, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], true, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], false, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], null, {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], [ '1' ], {} ); // $ExpectError - mskfilterMap( x, [ 1, 1 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0 ]; - - mskfilterMap(); // $ExpectError - mskfilterMap( x ); // $ExpectError - mskfilterMap( x, [ 0, 1 ] ); // $ExpectError - mskfilterMap( x, [ 0, 1 ], clbk, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns an array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const out = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk ); // $ExpectType Collection - mskfilterMap.assign( x, [ 1, 0, 1, 0 ], out, 1, 0, clbk, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const mask = [ 0, 0, 0, 0 ]; - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( 'abc', mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( 3.14, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( true, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( false, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( null, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( [ '1' ], mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( {}, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( ( x: number ): number => x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, 3.14, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, true, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, false, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, null, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, {}, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, ( x: number ): number => x, [ 0, 0, 0, 0 ], 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, 3.14, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, true, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, false, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, null, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, {}, 1, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, ( x: number ): number => x, 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 'abc', 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ 1 ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], true, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], false, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], null, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], [ '1' ], 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], {}, 0, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], ( x: number ): number => x, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 'abc', clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ 1 ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, true, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, false, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, null, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, [ '1' ], clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, {}, clbk, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a valid callback... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc' ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {} ); // $ExpectError - - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 'abc', {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, 3.14, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, true, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, false, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, null, {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, [ '1' ], {} ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const mask = [ 0.0, 0.0, 0.0, 0.0 ]; - - mskfilterMap.assign(); // $ExpectError - mskfilterMap.assign( x ); // $ExpectError - mskfilterMap.assign( x, mask ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ] ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectError - mskfilterMap.assign( x, mask, [ 0, 0, 0, 0 ], 1, 0, clbk, {}, {} ); // $ExpectError -} - diff --git a/base/mskfilter-map/examples/index.js b/base/mskfilter-map/examples/index.js deleted file mode 100644 index a4beb4421..000000000 --- a/base/mskfilter-map/examples/index.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -var zeroTo = require( './../../../base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var abs2 = require( '@stdlib/math/base/special/abs2' ); -var mskfilterMap = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilterMap( x, mask, abs2 ); -console.log( y ); diff --git a/base/mskfilter-map/lib/assign.js b/base/mskfilter-map/lib/assign.js deleted file mode 100644 index 8ec944fee..000000000 --- a/base/mskfilter-map/lib/assign.js +++ /dev/null @@ -1,182 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Applies a mask and a callback function to an indexed array and assigns results to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} clbk - function to apply -* @param {*} [thisArg] - callback execution context -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* function scale( x ) { -* return x * 10; -* } -* -* var arr = indexed( x, mask, out, 1, 0, scale ); -* // returns [ 20, 40, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset, clbk, thisArg ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = clbk.call( thisArg, x[ i ], i, x ); - io += stride; - } - } - return out; -} - -/** -* Applies a mask and a callback function to an input accessor array and assigns results to elements in an output accessor array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} clbk - function to apply -* @param {*} [thisArg] - callback execution context -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* function scale( x ) { -* return x * 10; -* } -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0, scale ); -* -* var v = arr.get( 0 ); -* // returns 20 -* -* v = arr.get( 1 ); -* // returns 40 -*/ -function accessors( x, mask, out, stride, offset, clbk, thisArg ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, clbk.call( thisArg, xget( xdata, i ), i, xdata ) ); - io += stride; - } - } - return odata; -} - - -// MAIN // - -/** -* Applies a mask and a callback function to a provided input array and assigns results to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} clbk - function to apply -* @param {*} [thisArg] - callback execution context -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* function scale( x ) { -* return x * 10; -* } -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0, scale ); -* // returns [ 20, 40 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset, clbk, thisArg ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - accessors( xo, mo, oo, stride, offset, clbk, thisArg ); - return out; - } - indexed( x, mask, out, stride, offset, clbk, thisArg ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/mskfilter-map/lib/index.js b/base/mskfilter-map/lib/index.js deleted file mode 100644 index f9f77206a..000000000 --- a/base/mskfilter-map/lib/index.js +++ /dev/null @@ -1,71 +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. -*/ - -'use strict'; - -/** -* Apply a mask and a callback function to a provided input array. -* -* @module @stdlib/array/base/mskfilter-map -* -* @example -* var mskfilterMap = require( '@stdlib/array/base/mskfilter-map' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* function scale( val ) { -* return 10 * val; -* } -* -* var y = mskfilterMap( x, mask, scale ); -* // returns [ 20, 40 ] -* -* @example -* var mskfilterMap = require( '@stdlib/array/base/mskfilter-map' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* function scale( val ) { -* return 10 * val; -* } -* -* var out = [ 0, 0 ]; -* var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale ); -* // returns [ 20, 40 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskfilter-map/lib/main.js b/base/mskfilter-map/lib/main.js deleted file mode 100644 index 322351a88..000000000 --- a/base/mskfilter-map/lib/main.js +++ /dev/null @@ -1,71 +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. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array after applying a mask and a callback function to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Function} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* function scale( val ) { -* return 10 * val; -* } -* -* var y = mskfilterMap( x, mask, scale ); -* // returns [ 20, 40 ] -*/ -function mskfilterMap( x, mask, clbk, thisArg ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( clbk.call( thisArg, xget( x, i ), i, x ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilterMap; diff --git a/base/mskfilter-map/package.json b/base/mskfilter-map/package.json deleted file mode 100644 index a9d9574c4..000000000 --- a/base/mskfilter-map/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/mskfilter-map", - "version": "0.0.0", - "description": "Apply a mask and a callback function to a provided input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index", - "mask", - "map", - "filter", - "reject" - ] -} diff --git a/base/mskfilter-map/test/test.assign.js b/base/mskfilter-map/test/test.assign.js deleted file mode 100644 index 6822c3b96..000000000 --- a/base/mskfilter-map/test/test.assign.js +++ /dev/null @@ -1,311 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var Complex64Array = require( './../../../complex64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Int32Array = require( './../../../int32' ); -var zeros = require( './../../../zeros' ); -var mskfilterMap = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 4, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Int32Array( [ 1, 4, 9, 16 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Int32Array( [ 0, 16, 0, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - mask = [ 1, 0 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 0 ]; - out = zeros( 3, 'complex64' ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 2, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilterMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 16, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function clbk( v ) { - return v * v; - } - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument having all elements equal to zero ', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - mask = [ 0, 0, 0, 0 ]; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0 ]; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = mskfilterMap( x, mask, out, 1, 0, clbk ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); diff --git a/base/mskfilter-map/test/test.js b/base/mskfilter-map/test/test.js deleted file mode 100644 index 028b9f7e5..000000000 --- a/base/mskfilter-map/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilterMap, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/mskfilter-map/test/test.main.js b/base/mskfilter-map/test/test.main.js deleted file mode 100644 index 6c7e7ebe5..000000000 --- a/base/mskfilter-map/test/test.main.js +++ /dev/null @@ -1,158 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var isSameComplex64 = require( '@stdlib/assert/is-same-complex64' ); -var isArray = require( '@stdlib/assert/is-array' ); -var mskfilterMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilterMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 4, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ 1, 4, 9, 16 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilterMap( x, mask, clbk ); - expected = [ x.get( 1 ), x.get( 3 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value' ); - } - t.end(); - - function clbk( v ) { - return v; - } -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilterMap( [], [], clbk ), [], 'returns expected value' ); - t.end(); - - function clbk( v ) { - return v * v; - } -}); - -tape( 'the function supports providing a callback execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var mask; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - x = [ 1.0, 2.0, 3.0, 4.0 ]; - mask = [ 1, 1, 1, 1 ]; - - ctx = { - 'count': 0 - }; - out = mskfilterMap( x, mask, clbk, ctx ); - - expected = [ 1.0, 2.0, 3.0, 4.0]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - expected = [ 1.0, 2.0, 3.0, 4.0 ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3 ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ x, x, x, x ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/base/mskfilter/README.md b/base/mskfilter/README.md deleted file mode 100644 index 38d44af37..000000000 --- a/base/mskfilter/README.md +++ /dev/null @@ -1,134 +0,0 @@ - - -# mskfilter - -> Apply a mask to a provided input array. - -
- -## Usage - -```javascript -var mskfilter = require( '@stdlib/array/base/mskfilter' ); -``` - -#### mskfilter( x, mask ) - -Returns a new array by applying a mask to a provided input array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -// returns [ 2, 4 ] -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. - -The function **always** returns a new "generic" array. - -#### mskfilter.assign( x, mask, out, stride, offset ) - -Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var mask = [ 0, 1, 0, 1 ]; - -var out = [ 0, 0, 0, 0 ]; - -var arr = mskfilter.assign( x, mask, out, -2, out.length-1 ); -// returns [ 0, 4, 0, 2 ] - -var bool = ( arr === out ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. - -
- - - -
- -## Notes - -- If a `mask` array element is truthy, the corresponding element in `x` is **included** in the output array; otherwise, the corresponding element in `x` is "masked" and thus **excluded** from the output array. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskfilter = require( '@stdlib/array/base/mskfilter' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilter( x, mask ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskfilter/benchmark/benchmark.assign.length.js b/base/mskfilter/benchmark/benchmark.assign.length.js deleted file mode 100644 index 7646ae137..000000000 --- a/base/mskfilter/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,105 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var zeros = require( './../../../zeros' ); -var ones = require( './../../../ones' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isnan = require( '@stdlib/assert/is-nan' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var mskfilter = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var mask; - var out; - var x; - - x = zeroTo( len, 'generic' ); - mask = ones( len, 'generic' ); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilter.assign( x, mask, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) || isnan( v[ i%len ] ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/mskfilter/benchmark/benchmark.js b/base/mskfilter/benchmark/benchmark.js deleted file mode 100644 index 136db956f..000000000 --- a/base/mskfilter/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var mskfilter = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilter( x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/mskfilter/benchmark/benchmark.length.js b/base/mskfilter/benchmark/benchmark.length.js deleted file mode 100644 index a0eb6cede..000000000 --- a/base/mskfilter/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var ones = require( './../../../base/ones' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var mskfilter = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilter( x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/mskfilter/docs/repl.txt b/base/mskfilter/docs/repl.txt deleted file mode 100644 index 5ec073fc4..000000000 --- a/base/mskfilter/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` is - "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values to - elements in a provided output array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` is - "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var m = [ 0, 1, 0, 1 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, m, out, 2, 0 ) - [ 2, 0, 4, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/base/mskfilter/docs/types/index.d.ts b/base/mskfilter/docs/types/index.d.ts deleted file mode 100644 index a654b807a..000000000 --- a/base/mskfilter/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskfilter; diff --git a/base/mskfilter/docs/types/test.ts b/base/mskfilter/docs/types/test.ts deleted file mode 100644 index b00a181e8..000000000 --- a/base/mskfilter/docs/types/test.ts +++ /dev/null @@ -1,57 +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. -*/ - -import mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType any[] - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType number[] - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/base/mskfilter/examples/index.js b/base/mskfilter/examples/index.js deleted file mode 100644 index fe715282f..000000000 --- a/base/mskfilter/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var zeroTo = require( './../../../base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskfilter = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilter( x, mask ); -console.log( y ); diff --git a/base/mskfilter/lib/assign.js b/base/mskfilter/lib/assign.js deleted file mode 100644 index e76d884b3..000000000 --- a/base/mskfilter/lib/assign.js +++ /dev/null @@ -1,272 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var isBooleanDataType = require( './../../../base/assert/is-boolean-data-type' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 2, 4, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 4 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - -/** -* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array. -* -* @private -* @param {Collection} x - boolean input array view -* @param {Object} mask - mask array object -* @param {Collection} out - boolean output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Uint8Array( 4 ); -* -* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 0, 1, 0, 0 ] -*/ -function boolean( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - io = offset; - for ( i = 0; i < mdata.length; i++ ) { - if ( mget( mdata, i ) ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/mskfilter/lib/index.js b/base/mskfilter/lib/index.js deleted file mode 100644 index 4ed176800..000000000 --- a/base/mskfilter/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array/base/mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array/base/mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var mskfilter = require( '@stdlib/array/base/mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskfilter.assign( x, mask, out, 1, 0 ); -* // returns [ 2, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskfilter/lib/main.js b/base/mskfilter/lib/main.js deleted file mode 100644 index 6e7a822d9..000000000 --- a/base/mskfilter/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/base/mskfilter/package.json b/base/mskfilter/package.json deleted file mode 100644 index 03b0c5c66..000000000 --- a/base/mskfilter/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/mskfilter", - "version": "0.0.0", - "description": "Apply a mask to a provided input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index", - "mask", - "filter", - "reject" - ] -} diff --git a/base/mskfilter/test/test.assign.js b/base/mskfilter/test/test.assign.js deleted file mode 100644 index 63da4a15d..000000000 --- a/base/mskfilter/test/test.assign.js +++ /dev/null @@ -1,349 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Int32Array = require( './../../../int32' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); -var zeros = require( './../../../zeros' ); -var mskfilter = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'generic' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'int32' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 2, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 0, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = zeros( 1, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = zeros( 4, 'complex64' ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (boolean array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new BooleanArray( [ true, false, false, true ] ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 2 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = new BooleanArray( 0 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - out = new BooleanArray( 1 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true, false, false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 1, 0, 1 ]; - out = new BooleanArray( 4 ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = new BooleanArray( [ false, true, false, false ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 2, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskfilter( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - mask = [ 0, 0, 0, 0 ]; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - out = new BooleanArray( [ false, false, false, false ] ); - expected = new BooleanArray( [ false, false, false, false ] ); - actual = mskfilter( x, mask, out, 1, 0 ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/base/mskfilter/test/test.js b/base/mskfilter/test/test.js deleted file mode 100644 index db8fe120a..000000000 --- a/base/mskfilter/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskfilter, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskfilter, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/mskfilter/test/test.main.js b/base/mskfilter/test/test.main.js deleted file mode 100644 index ec7598e57..000000000 --- a/base/mskfilter/test/test.main.js +++ /dev/null @@ -1,113 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var isSameComplex64 = require( '@stdlib/assert/is-same-complex64' ); -var isArray = require( '@stdlib/assert/is-array' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - expected = [ 2, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilter( x, mask ); - expected = [ 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - expected = [ x.get( 1 ), x.get( 3 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value' ); - } - - x = new BooleanArray( [ true, false, false, true ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - expected = [ x.get( 1 ), x.get( 3 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.end(); -}); diff --git a/base/mskfilter2/README.md b/base/mskfilter2/README.md deleted file mode 100644 index 2a2996f67..000000000 --- a/base/mskfilter2/README.md +++ /dev/null @@ -1,114 +0,0 @@ - - -# mskfilter2 - -> Apply a mask to two provided input arrays in a single pass. - -
- -## Usage - -```javascript -var mskfilter2 = require( '@stdlib/array/base/mskfilter2' ); -``` - -#### mskfilter2( x, y, mask ) - -Returns new arrays by applying a mask to two provided input arrays in a single pass. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var y = [ 0, 1, 2, 3 ]; - -var out = mskfilter2( x, y, [ 0, 1, 0, 1 ] ); -// returns [ [ 2, 4 ], [ 1, 3 ] ] -``` - -The function supports the following parameters: - -- **x**: first input array. -- **y**: second input array. -- **mask**: mask array. - -The function **always** returns new "generic" arrays. - -
- - - -
- -## Notes - -- If a `mask` array element is truthy, the corresponding elements in the input arrays are **included** in the respective output arrays; otherwise, the corresponding elements in the input arrays are "masked" and thus **excluded** from the respective output arrays. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskfilter2 = require( '@stdlib/array/base/mskfilter2' ); - -// Generate linearly spaced arrays: -var x = zeroTo( 20 ); -console.log( x ); - -var y = zeroTo( x.length ); -console.log( y ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter both arrays using the mask: -var out = mskfilter2( x, y, mask ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskfilter2/benchmark/benchmark.js b/base/mskfilter2/benchmark/benchmark.js deleted file mode 100644 index 4478bc717..000000000 --- a/base/mskfilter2/benchmark/benchmark.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var mskfilter2 = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilter2( x, x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/mskfilter2/benchmark/benchmark.length.js b/base/mskfilter2/benchmark/benchmark.length.js deleted file mode 100644 index f78fd438a..000000000 --- a/base/mskfilter2/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var ones = require( './../../../base/ones' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var mskfilter2 = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilter2( x, x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/mskfilter2/docs/repl.txt b/base/mskfilter2/docs/repl.txt deleted file mode 100644 index da35ee919..000000000 --- a/base/mskfilter2/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, y, mask ) - Returns new arrays by applying a mask to two provided input arrays in a - single pass. - - If a mask array element is truthy, the corresponding elements in the input - arrays are included in the respective output arrays; otherwise, the - corresponding elements in the input arrays are "masked" and thus excluded - from the output arrays. - - Parameters - ---------- - x: ArrayLikeObject - First input array. - - y: ArrayLikeObject - Second input array. - - mask: ArrayLikeObject - Mask array. - - Returns - ------- - out: Array - Output arrays. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = [ 0, 1, 2, 3 ]; - > var out = {{alias}}( x, y, [ 0, 1, 0, 1 ] ) - [ [ 2, 4 ], [ 1, 3 ] ] - - See Also - -------- - diff --git a/base/mskfilter2/docs/types/index.d.ts b/base/mskfilter2/docs/types/index.d.ts deleted file mode 100644 index f5621cdb5..000000000 --- a/base/mskfilter2/docs/types/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Returns new arrays by applying a mask to two provided input arrays in a single pass. -* -* @param x - first input array -* @param y - second input array -* @param mask - mask array -* @returns output arrays -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = mskfilter2( x, y, mask ); -* // returns [ [ 2, 4 ], [ 6, 8 ] ] -*/ -declare function mskfilter2( x: Collection, y: Collection, mask: Collection ): [ Array, Array ]; - - -// EXPORTS // - -export = mskfilter2; diff --git a/base/mskfilter2/docs/types/test.ts b/base/mskfilter2/docs/types/test.ts deleted file mode 100644 index aadb9e8f0..000000000 --- a/base/mskfilter2/docs/types/test.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import mskfilter2 = require( './index' ); - - -// TESTS // - -// The function returns two arrays... -{ - mskfilter2( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType [number[], number[]] - mskfilter2( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType [any[], any[]] - mskfilter2( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType [number[], number[]] - mskfilter2( [ '1', '2', '3', '4' ], [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType [string[], string[]] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter2( 1, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError - mskfilter2( true, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError - mskfilter2( false, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError - mskfilter2( null, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError - mskfilter2( void 0, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError - mskfilter2( {}, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfilter2( [ 1, 2, 3, 4 ], 1, [ 0, 0 ] ); // $ExpectError - mskfilter2( [ 1, 2, 3, 4 ], true, [ 0, 0 ] ); // $ExpectError - mskfilter2( [ 1, 2, 3, 4 ], false, [ 0, 0 ] ); // $ExpectError - mskfilter2( [ 1, 2, 3, 4 ], null, [ 0, 0 ] ); // $ExpectError - mskfilter2( [ 1, 2, 3, 4 ], void 0, [ 0, 0 ] ); // $ExpectError - mskfilter2( [ 1, 2, 3, 4 ], {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object... -{ - mskfilter2( [], [], 1 ); // $ExpectError - mskfilter2( [], [], true ); // $ExpectError - mskfilter2( [], [], false ); // $ExpectError - mskfilter2( [], [], null ); // $ExpectError - mskfilter2( [], [], void 0 ); // $ExpectError - mskfilter2( [], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter2(); // $ExpectError - mskfilter2( [] ); // $ExpectError - mskfilter2( [], [] ); // $ExpectError - mskfilter2( [], [], [], [] ); // $ExpectError -} diff --git a/base/mskfilter2/examples/index.js b/base/mskfilter2/examples/index.js deleted file mode 100644 index 3546fdfc9..000000000 --- a/base/mskfilter2/examples/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var zeroTo = require( './../../../base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskfilter2 = require( './../lib' ); - -// Generate linearly spaced arrays: -var x = zeroTo( 20 ); -console.log( x ); - -var y = zeroTo( x.length ); -console.log( y ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter both arrays using the mask: -var out = mskfilter2( x, y, mask ); -console.log( out ); diff --git a/base/mskfilter2/lib/index.js b/base/mskfilter2/lib/index.js deleted file mode 100644 index a0eb1f642..000000000 --- a/base/mskfilter2/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a mask to two provided input arrays in a single pass. -* -* @module @stdlib/array/base/mskfilter2 -* -* @example -* var mskfilter2 = require( '@stdlib/array/base/mskfilter2' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = mskfilter2( x, y, mask ); -* // returns [ [ 2, 4 ], [ 6, 8 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskfilter2/lib/main.js b/base/mskfilter2/lib/main.js deleted file mode 100644 index cc33f430c..000000000 --- a/base/mskfilter2/lib/main.js +++ /dev/null @@ -1,72 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Returns new arrays by applying a mask to two provided input arrays in a single pass. -* -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @param {Collection} mask - mask array -* @returns {Array} output arrays -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = mskfilter2( x, y, mask ); -* // returns [ [ 2, 4 ], [ 6, 8 ] ] -*/ -function mskfilter2( x, y, mask ) { - var xget; - var yget; - var mget; - var o1; - var o2; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - yget = resolveGetter( y ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided arrays... - o1 = []; - o2 = []; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mask, i ) ) { - o1.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - o2.push( yget( y, i ) ); - } - } - return [ o1, o2 ]; -} - - -// EXPORTS // - -module.exports = mskfilter2; diff --git a/base/mskfilter2/package.json b/base/mskfilter2/package.json deleted file mode 100644 index a235eef84..000000000 --- a/base/mskfilter2/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/mskfilter2", - "version": "0.0.0", - "description": "Apply a mask to two provided input arrays in a single pass.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index", - "mask", - "filter", - "reject" - ] -} diff --git a/base/mskfilter2/test/test.js b/base/mskfilter2/test/test.js deleted file mode 100644 index b346e0768..000000000 --- a/base/mskfilter2/test/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var mskfilter2 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter2, 'function', 'main export is a function' ); - t.end(); -}); diff --git a/base/mskfilter2/test/test.main.js b/base/mskfilter2/test/test.main.js deleted file mode 100644 index bb389bcb7..000000000 --- a/base/mskfilter2/test/test.main.js +++ /dev/null @@ -1,164 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var isSameComplex64 = require( '@stdlib/assert/is-same-complex64' ); -var isArray = require( '@stdlib/assert/is-array' ); -var mskfilter2 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter2, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements', function test( t ) { - var expected; - var actual; - var mask; - var y; - var x; - - x = [ 1, 2, 3, 4 ]; - y = [ 0, 1, 2, 3 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter2( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = [ 2, 4 ]; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - expected = [ 1, 3 ]; - t.notEqual( actual[ 1 ], y, 'returns expected value' ); - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilter2( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = []; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - expected = []; - t.notEqual( actual[ 1 ], y, 'returns expected value' ); - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilter2( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = [ 4 ]; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - expected = [ 3 ]; - t.notEqual( actual[ 1 ], y, 'returns expected value' ); - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilter2( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3 ]; - t.notEqual( actual[ 1 ], y, 'returns expected value' ); - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var y; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - y = [ 0, 1, 2, 3 ]; - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter2( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = [ x.get( 1 ), x.get( 3 ) ]; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ 0 ][ i ], expected[ i ] ), true, 'returns expected value' ); - } - expected = [ 1, 3 ]; - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - y = [ 0, 1, 2, 3 ]; - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter2( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = [ x.get( 1 ), x.get( 3 ) ]; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual[ 0 ][ i ], expected[ i ], 'returns expected value' ); - } - expected = [ 1, 3 ]; - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter2( [], [], [] ), [ [], [] ], 'returns expected value' ); - t.end(); -}); diff --git a/base/mskfiltern/README.md b/base/mskfiltern/README.md deleted file mode 100644 index 95739451c..000000000 --- a/base/mskfiltern/README.md +++ /dev/null @@ -1,114 +0,0 @@ - - -# mskfiltern - -> Apply a mask to one or more provided input arrays in a single pass. - -
- -## Usage - -```javascript -var mskfiltern = require( '@stdlib/array/base/mskfiltern' ); -``` - -#### mskfiltern( x, \[...arrays,] mask ) - -Returns new arrays by applying a mask to one or more provided input arrays in a single pass. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var y = [ 0, 1, 2, 3 ]; - -var out = mskfiltern( x, y, [ 0, 1, 0, 1 ] ); -// returns [ [ 2, 4 ], [ 1, 3 ] ] -``` - -The function supports the following parameters: - -- **x**: first input array. -- **...arrays**: additional input arrays. -- **mask**: mask array. - -The function **always** returns new "generic" arrays. - -
- - - -
- -## Notes - -- If a `mask` array element is truthy, the corresponding elements in the input arrays are **included** in the respective output arrays; otherwise, the corresponding elements in the input arrays are "masked" and thus **excluded** from the respective output arrays. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskfiltern = require( '@stdlib/array/base/mskfiltern' ); - -// Generate linearly spaced arrays: -var x = zeroTo( 20 ); -console.log( x ); - -var y = zeroTo( x.length ); -console.log( y ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter both arrays using the mask: -var out = mskfiltern( x, y, mask ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskfiltern/benchmark/benchmark.js b/base/mskfiltern/benchmark/benchmark.js deleted file mode 100644 index e5dbb7a80..000000000 --- a/base/mskfiltern/benchmark/benchmark.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var mskfiltern = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:num_arrays=2,len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfiltern( x, x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/mskfiltern/benchmark/benchmark.length.js b/base/mskfiltern/benchmark/benchmark.length.js deleted file mode 100644 index 7bc2d69bf..000000000 --- a/base/mskfiltern/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var ones = require( './../../../base/ones' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var mskfiltern = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfiltern( x, x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':num_arrays=2,len='+len, f ); - } -} - -main(); diff --git a/base/mskfiltern/docs/repl.txt b/base/mskfiltern/docs/repl.txt deleted file mode 100644 index f5d52bc17..000000000 --- a/base/mskfiltern/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x[, ...arrays], mask ) - Returns new arrays by applying a mask to one or more provided input arrays - in a single pass. - - If a mask array element is truthy, the corresponding elements in the input - arrays are included in the respective output arrays; otherwise, the - corresponding elements in the input arrays are "masked" and thus excluded - from the output arrays. - - Parameters - ---------- - x: ArrayLikeObject - First input array. - - arrays: ...ArrayLikeObject (optional) - Additional input arrays. - - mask: ArrayLikeObject - Mask array. - - Returns - ------- - out: Array - Output arrays. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = [ 0, 1, 2, 3 ]; - > var out = {{alias}}( x, y, [ 0, 1, 0, 1 ] ) - [ [ 2, 4 ], [ 1, 3 ] ] - - See Also - -------- - diff --git a/base/mskfiltern/docs/types/index.d.ts b/base/mskfiltern/docs/types/index.d.ts deleted file mode 100644 index 765273477..000000000 --- a/base/mskfiltern/docs/types/index.d.ts +++ /dev/null @@ -1,146 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Returns new arrays by applying a mask to a provided input array in a single pass. -* -* @param x - first input array -* @param mask - mask array -* @returns output arrays -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = mskfiltern( x, mask ); -* // returns [ [ 2, 4 ] ] -*/ -declare function mskfiltern( x: Collection, mask: Collection ): [ Array ]; - -/** -* Returns new arrays by applying a mask to two provided input arrays in a single pass. -* -* @param x - first input array -* @param y - second input array -* @param mask - mask array -* @returns output arrays -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = mskfiltern( x, y, mask ); -* // returns [ [ 2, 4 ], [ 6, 8 ] ] -*/ -declare function mskfiltern( x: Collection, y: Collection, mask: Collection ): [ Array, Array ]; - -/** -* Returns new arrays by applying a mask to three provided input arrays in a single pass. -* -* @param x - first input array -* @param y - second input array -* @param z - third input array -* @param mask - mask array -* @returns output arrays -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var z = [ 1, 1, 1, 1 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = mskfiltern( x, y, z, mask ); -* // returns [ [ 2, 4 ], [ 6, 8 ], [ 1, 1 ] ] -*/ -declare function mskfiltern( x: Collection, y: Collection, z: Collection, mask: Collection ): [ Array, Array, Array ]; - -/** -* Returns new arrays by applying a mask to four provided input arrays in a single pass. -* -* @param x - first input array -* @param y - second input array -* @param z - third input array -* @param u - fourth input array -* @param mask - mask array -* @returns output arrays -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var z = [ 1, 1, 1, 1 ]; -* var u = [ 0, 0, 0, 0 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = mskfiltern( x, y, z, u, mask ); -* // returns [ [ 2, 4 ], [ 6, 8 ], [ 1, 1 ], [ 0, 0 ] ] -*/ -declare function mskfiltern( x: Collection, y: Collection, z: Collection, u: Collection, mask: Collection ): [ Array, Array, Array, Array ]; - -/** -* Returns new arrays by applying a mask to five provided input arrays in a single pass. -* -* @param x - first input array -* @param y - second input array -* @param z - third input array -* @param u - fourth input array -* @param v - fifth input array -* @param mask - mask array -* @returns output arrays -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var z = [ 1, 1, 1, 1 ]; -* var u = [ 0, 0, 0, 0 ]; -* var v = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = mskfiltern( x, y, z, u, v, mask ); -* // returns [ [ 2, 4 ], [ 6, 8 ], [ 1, 1 ], [ 0, 0 ], [ 2, 4 ] ] -*/ -declare function mskfiltern( x: Collection, y: Collection, z: Collection, u: Collection, v: Collection, mask: Collection ): [ Array, Array, Array, Array, Array ]; - -/** -* Returns new arrays by applying a mask to one or more provided input arrays in a single pass. -* -* @param x - first input array -* @param y - second input array (or mask) -* @param arrays - additional input arrays and mask -* @returns output arrays -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = mskfiltern( x, y, mask ); -* // returns [ [ 2, 4 ], [ 6, 8 ] ] -*/ -declare function mskfiltern( x: Collection, y: Collection, ...arrays: Array ): Array>; - - -// EXPORTS // - -export = mskfiltern; diff --git a/base/mskfiltern/docs/types/test.ts b/base/mskfiltern/docs/types/test.ts deleted file mode 100644 index 2a4553c9e..000000000 --- a/base/mskfiltern/docs/types/test.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import mskfiltern = require( './index' ); - - -// TESTS // - -// The function returns one or more arrays... -{ - mskfiltern( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType [number[]] - mskfiltern( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType [number[], number[]] - mskfiltern( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType [number[], number[], number[]] - mskfiltern( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType [number[], number[], number[], number[]] - mskfiltern( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType [number[], number[], number[], number[], number[]] - - mskfiltern( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType [any[], any[]] - mskfiltern( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType [number[], number[]] - mskfiltern( [ '1', '2', '3', '4' ], [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType [string[], string[]] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfiltern( 1, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError - mskfiltern( true, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError - mskfiltern( false, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError - mskfiltern( null, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError - mskfiltern( void 0, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError - mskfiltern( {}, [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskfiltern( [ 1, 2, 3, 4 ], 1, [ 0, 0 ] ); // $ExpectError - mskfiltern( [ 1, 2, 3, 4 ], true, [ 0, 0 ] ); // $ExpectError - mskfiltern( [ 1, 2, 3, 4 ], false, [ 0, 0 ] ); // $ExpectError - mskfiltern( [ 1, 2, 3, 4 ], null, [ 0, 0 ] ); // $ExpectError - mskfiltern( [ 1, 2, 3, 4 ], void 0, [ 0, 0 ] ); // $ExpectError - mskfiltern( [ 1, 2, 3, 4 ], {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfiltern(); // $ExpectError - mskfiltern( [] ); // $ExpectError -} diff --git a/base/mskfiltern/examples/index.js b/base/mskfiltern/examples/index.js deleted file mode 100644 index 5e64015d1..000000000 --- a/base/mskfiltern/examples/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var zeroTo = require( './../../../base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskfiltern = require( './../lib' ); - -// Generate linearly spaced arrays: -var x = zeroTo( 20 ); -console.log( x ); - -var y = zeroTo( x.length ); -console.log( y ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter both arrays using the mask: -var out = mskfiltern( x, y, mask ); -console.log( out ); diff --git a/base/mskfiltern/lib/index.js b/base/mskfiltern/lib/index.js deleted file mode 100644 index 94a5399dc..000000000 --- a/base/mskfiltern/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a mask to one or more provided input arrays in a single pass. -* -* @module @stdlib/array/base/mskfiltern -* -* @example -* var mskfiltern = require( '@stdlib/array/base/mskfiltern' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = mskfiltern( x, y, mask ); -* // returns [ [ 2, 4 ], [ 6, 8 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskfiltern/lib/main.js b/base/mskfiltern/lib/main.js deleted file mode 100644 index f3ef03be6..000000000 --- a/base/mskfiltern/lib/main.js +++ /dev/null @@ -1,84 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Returns new arrays by applying a mask to one or more provided input arrays in a single pass. -* -* @param {Collection} x - first input array -* @param {Collection} [...arrays] - additional input arrays -* @param {Collection} mask - mask array -* @returns {Array} output arrays -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = mskfiltern( x, y, mask ); -* // returns [ [ 2, 4 ], [ 6, 8 ] ] -*/ -function mskfiltern() { - var getters; - var arrays; - var nargs; - var mget; - var mask; - var out; - var i; - var j; - - nargs = arguments.length; - nargs -= 1; - - // Resolve the mask array and its associated accessor: - mask = arguments[ nargs ]; - mget = resolveGetter( mask ); - - // Resolve accessors for retrieving array elements and initialize the output arrays... - getters = []; - arrays = []; - out = []; - for ( i = 0; i < nargs; i++ ) { - arrays.push( arguments[ i ] ); - getters.push( resolveGetter( arrays[ i ] ) ); - out.push( [] ); - } - // Extract each desired element from the provided arrays... - for ( i = 0; i < mask.length; i++ ) { - if ( mget( mask, i ) ) { - for ( j = 0; j < nargs; j++ ) { - out[ j ].push( getters[ j ]( arrays[ j ], i ) ); // use `Array#push` to ensure "fast" elements - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskfiltern; diff --git a/base/mskfiltern/package.json b/base/mskfiltern/package.json deleted file mode 100644 index e6a7666b6..000000000 --- a/base/mskfiltern/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/mskfiltern", - "version": "0.0.0", - "description": "Apply a mask to one or more provided input arrays in a single pass.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index", - "mask", - "filter", - "reject" - ] -} diff --git a/base/mskfiltern/test/test.js b/base/mskfiltern/test/test.js deleted file mode 100644 index dc1236c6e..000000000 --- a/base/mskfiltern/test/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var mskfiltern = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfiltern, 'function', 'main export is a function' ); - t.end(); -}); diff --git a/base/mskfiltern/test/test.main.js b/base/mskfiltern/test/test.main.js deleted file mode 100644 index e8551159f..000000000 --- a/base/mskfiltern/test/test.main.js +++ /dev/null @@ -1,257 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var isSameComplex64 = require( '@stdlib/assert/is-same-complex64' ); -var isArray = require( '@stdlib/assert/is-array' ); -var mskfiltern = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfiltern, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function filters array elements (1 array)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfiltern( x, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 1, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - - expected = [ 2, 4 ]; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfiltern( x, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 1, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - - expected = []; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfiltern( x, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 1, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - - expected = [ 4 ]; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfiltern( x, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 1, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (2 arrays)', function test( t ) { - var expected; - var actual; - var mask; - var y; - var x; - - x = [ 1, 2, 3, 4 ]; - y = [ 0, 1, 2, 3 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfiltern( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = [ 2, 4 ]; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - expected = [ 1, 3 ]; - t.notEqual( actual[ 1 ], y, 'returns expected value' ); - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfiltern( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = []; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - expected = []; - t.notEqual( actual[ 1 ], y, 'returns expected value' ); - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfiltern( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = [ 4 ]; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - expected = [ 3 ]; - t.notEqual( actual[ 1 ], y, 'returns expected value' ); - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfiltern( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3 ]; - t.notEqual( actual[ 1 ], y, 'returns expected value' ); - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (3 arrays)', function test( t ) { - var expected; - var actual; - var mask; - var x; - var y; - var z; - - x = [ 1, 2, 3, 4 ]; - y = [ 0, 1, 2, 3 ]; - z = [ 5, 6, 7, 8 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfiltern( x, y, z, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 3, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 2 ] ), true, 'returns expected value' ); - - expected = [ 2, 4 ]; - t.notEqual( actual[ 0 ], x, 'returns expected value' ); - t.deepEqual( actual[ 0 ], expected, 'returns expected value' ); - - expected = [ 1, 3 ]; - t.notEqual( actual[ 1 ], y, 'returns expected value' ); - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - expected = [ 6, 8 ]; - t.notEqual( actual[ 2 ], z, 'returns expected value' ); - t.deepEqual( actual[ 2 ], expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (2 arrays; accessors)', function test( t ) { - var expected; - var actual; - var mask; - var y; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - y = [ 0, 1, 2, 3 ]; - mask = [ 0, 1, 0, 1 ]; - actual = mskfiltern( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = [ x.get( 1 ), x.get( 3 ) ]; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ 0 ][ i ], expected[ i ] ), true, 'returns expected value' ); - } - expected = [ 1, 3 ]; - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - y = [ 0, 1, 2, 3 ]; - mask = [ 0, 1, 0, 1 ]; - actual = mskfiltern( x, y, mask ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( isArray( actual[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isArray( actual[ 1 ] ), true, 'returns expected value' ); - - expected = [ x.get( 1 ), x.get( 3 ) ]; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual[ 0 ][ i ], expected[ i ], 'returns expected value' ); - } - expected = [ 1, 3 ]; - t.deepEqual( actual[ 1 ], expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided empty arrays', function test( t ) { - t.deepEqual( mskfiltern( [], [] ), [ [] ], 'returns expected value' ); - t.deepEqual( mskfiltern( [], [], [] ), [ [], [] ], 'returns expected value' ); - t.deepEqual( mskfiltern( [], [], [], [] ), [ [], [], [] ], 'returns expected value' ); - t.end(); -}); diff --git a/base/mskput/README.md b/base/mskput/README.md deleted file mode 100644 index c291825ed..000000000 --- a/base/mskput/README.md +++ /dev/null @@ -1,150 +0,0 @@ - - -# mskput - -> Replace elements of an array with provided values according to a provided mask array. - -
- -## Usage - -```javascript -var mskput = require( '@stdlib/array/base/mskput' ); -``` - -#### mskput( x, mask, values, mode ) - -Replaces elements of an array with provided values according to a provided mask array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = mskput( x, [ 1, 0, 1, 0 ], [ 20, 40 ], 'strict' ); -// returns [ 1, 20, 3, 40 ] - -var bool = ( out === x ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. -- **values**: values to set. -- **mode**: string specifying behavior when the number of `values` does not equal the number of falsy `mask` values. - -The function supports the following modes: - -- `'strict'`: specifies that the function must raise an exception when the number of `values` does not **exactly** equal the number of falsy `mask` values. -- `'non_strict'`: specifies that the function must raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -- `'strict_broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the number of `values` does not **exactly** equal the number of falsy `mask` values. -- `'broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -- `'repeat'`: specifies that the function must reuse provided `values` when replacing elements in `x` in order to satisfy the `mask` array. - -In broadcasting modes, the function supports broadcasting a `values` array containing a single element against the number of falsy values in the `mask` array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = mskput( x, [ 1, 0, 1, 0 ], [ 20 ], 'strict_broadcast' ); -// returns [ 1, 20, 3, 20 ] - -var bool = ( out === x ); -// returns true -``` - -In repeat mode, the function supports recycling elements in a `values` array to satisfy the number of falsy values in the `mask` array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = mskput( x, [ 0, 0, 1, 0 ], [ 20, 40 ], 'repeat' ); -// returns [ 20, 40, 3, 20 ] - -var bool = ( out === x ); -// returns true -``` - -
- - - -
- -## Notes - -- The function mutates the input array `x`. -- If a `mask` array element is falsy, the corresponding element in `x` is **replaced**; otherwise, the corresponding element in `x` is "masked" and thus left unchanged. - -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var linspace = require( '@stdlib/array/base/linspace' ); -var mskput = require( '@stdlib/array/base/mskput' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate a random mask array: -var N = discreteUniform( 5, 15 ); -var mask = filledBy( N, bernoulli.factory( 0.3 ) ); -console.log( mask ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = mskput( x, mask, values, 'non_strict' ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskput/benchmark/benchmark.js b/base/mskput/benchmark/benchmark.js deleted file mode 100644 index d2b281159..000000000 --- a/base/mskput/benchmark/benchmark.js +++ /dev/null @@ -1,79 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var mskput = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::no_broadcasting:len=100', function benchmark( b ) { - var mask; - var x; - var i; - var v; - - x = zeroTo( 100 ); - mask = zeros( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskput( x, mask, x, 'strict' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::broadcasting:len=100', function benchmark( b ) { - var mask; - var x; - var i; - var v; - - x = zeroTo( 100 ); - mask = zeros( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskput( x, mask, [ i ], 'strict_broadcast' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/mskput/benchmark/benchmark.length.js b/base/mskput/benchmark/benchmark.length.js deleted file mode 100644 index 065ba5db4..000000000 --- a/base/mskput/benchmark/benchmark.length.js +++ /dev/null @@ -1,113 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeros = require( './../../../base/zeros' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var mskput = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'dtype': 'generic' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var mask; - var x; - - x = discreteUniform( len, 0, 10, opts ); - mask = zeros( len ); - values = [ - discreteUniform( len, -10, 0, opts ), - discreteUniform( len, 0, 10, opts ) - ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskput( x, mask, values[ i%values.length ], 'strict' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/mskput/docs/repl.txt b/base/mskput/docs/repl.txt deleted file mode 100644 index 4f542322e..000000000 --- a/base/mskput/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( x, mask, values, mode ) - Replaces elements of an array with provided values according to a provided - mask array. - - In broadcasting modes, the function supports broadcasting a values array - containing a single element against the number of falsy values in the mask - array. - - In repeat mode, the function supports recycling elements in a values array - to satisfy the number of falsy values in the mask array. - - The function mutates the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. If a mask array element is falsy, the corresponding element - in `x` is *replaced*; otherwise, the corresponding element in `x` is - "masked" and thus left unchanged. - - values: ArrayLikeObject - Values to set. - - mode: string - String specifying behavior when the number of values to set does not - equal the number of falsy mask values. The function supports the - following modes: - - - 'strict': specifies that the function must raise an exception when the - number of values does not *exactly* equal the number of falsy mask - values. - - 'non_strict': specifies that the function must raise an exception when - the function is provided insufficient values to satisfy the mask array. - - 'strict_broadcast': specifies that the function must broadcast a - single-element values array and otherwise raise an exception when the - number of values does not **exactly** equal the number of falsy mask - values. - - 'broadcast': specifies that the function must broadcast a single- - element values array and otherwise raise an exception when the function - is provided insufficient values to satisfy the mask array. - - 'repeat': specifies that the function must reuse provided values when - replacing elements in `x` in order to satisfy the mask array. - - Returns - ------- - out: ArrayLikeObject - Input array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x, [ 1, 0, 1, 0 ], [ 20, 40 ], 'strict' ) - [ 1, 20, 3, 40 ] - > var bool = ( out === x ) - true - - See Also - -------- - diff --git a/base/mskput/docs/types/index.d.ts b/base/mskput/docs/types/index.d.ts deleted file mode 100644 index 6b717d6c6..000000000 --- a/base/mskput/docs/types/index.d.ts +++ /dev/null @@ -1,227 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; - -/** -* Mask array. -*/ -type MaskArray = Collection | AccessorArrayLike; - -/** -* Values array. -*/ -type ValuesArray = Collection | AccessorArrayLike; - -/** -* Mode specifying behavior when the number of values to set does not equal the number of falsy values in the mask array. -* -* ## Notes -* -* - The function supports the following modes: -* -* - `'strict'`: specifies that the function must raise an exception when the number of `values` does not **exactly** equal the number of falsy `mask` values. -* - `'non_strict'`: specifies that the function must raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -* - `'strict_broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the number of `values` does not **exactly** equal the number of falsy `mask` values. -* - `'broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -* - `'repeat'`: specifies that the function must reuse provided `values` when replacing elements in `x` in order to satisfy the `mask` array. -*/ -type Mode = 'strict' | 'non_strict' | 'strict_broadcast' | 'broadcast' | 'repeat'; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param mode - string specifying behavior when the number of values does not equal the number of falsy values in the mask array -* @returns input array -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values, 'strict' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var out = mskput( x, [ 1, 0, 0, 1 ], [ 30 ], 'strict_broadcast' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function mskput( x: T, mask: MaskArray, values: ValuesArray, mode: Mode ): T; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param mode - string specifying behavior when the number of values does not equal the number of falsy values in the mask array -* @returns input array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = new Complex128Array( [ 20.0, 30.0, 40, 5.0 ] ); -* -* var out = mskput( x, mask, values, 'strict' ); -* // returns -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = new Complex128Array( [ 20.0, 30.0 ] ); -* -* var out = mskput( x, mask, values, 'strict_broadcast' ); -* // returns -* -* var bool = ( out === x ); -* // returns true -*/ -declare function mskput( x: T, mask: MaskArray, values: ValuesArray, mode: Mode ): T; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param mode - string specifying behavior when the number of values does not equal the number of falsy values in the mask array -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values, 'strict' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = mskput( x, [ 1, 0, 0, 1 ], [ 30 ], 'strict_broadcast' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function mskput( x: Array, mask: MaskArray, values: ValuesArray, mode: Mode ): Array; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param mode - string specifying behavior when the number of values does not equal the number of falsy values in the mask array -* @returns input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values, 'strict' ); -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var out = mskput( x, [ 1, 0, 0, 1 ], [ 30 ], 'strict_broadcast' ); -* -* var bool = ( out === x ); -* // returns true -*/ -declare function mskput( x: AccessorArrayLike, mask: MaskArray, values: ValuesArray, mode: Mode ): AccessorArrayLike; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param mode - string specifying behavior when the number of values does not equal the number of falsy values in the mask array -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values, 'strict' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = mskput( x, [ 1, 0, 0, 1 ], [ 30 ], 'strict_broadcast' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function mskput( x: Collection, mask: MaskArray, values: ValuesArray, mode: Mode ): Collection; - - -// EXPORTS // - -export = mskput; diff --git a/base/mskput/docs/types/test.ts b/base/mskput/docs/types/test.ts deleted file mode 100644 index d60f0d0d3..000000000 --- a/base/mskput/docs/types/test.ts +++ /dev/null @@ -1,92 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import AccessorArray = require( './../../../../base/accessor' ); -import mskput = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskput( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectType number[] - mskput( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ], 'non_strict' ); // $ExpectType number[] - mskput( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict_broadcast' ); // $ExpectType number[] - mskput( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ], 'broadcast' ); // $ExpectType number[] - mskput( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ], 'repeat' ); // $ExpectType number[] - - mskput( new Int32Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectType Int32Array - mskput( new Complex128Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ], 'strict' ); // $ExpectType Complex128Array - mskput( new Complex64Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ], 'strict' ); // $ExpectType Complex64Array - mskput( new AccessorArray( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], new AccessorArray( [ 20, 30 ] ), 'strict' ); // $ExpectType AccessorArrayLike -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskput( 1, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError - mskput( true, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError - mskput( false, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError - mskput( null, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError - mskput( void 0, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError - mskput( {}, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskput( [], 1, [ 20, 30 ], 'strict' ); // $ExpectError - mskput( [], true, [ 20, 30 ], 'strict' ); // $ExpectError - mskput( [], false, [ 20, 30 ], 'strict' ); // $ExpectError - mskput( [], null, [ 20, 30 ], 'strict' ); // $ExpectError - mskput( [], void 0, [ 20, 30 ], 'strict' ); // $ExpectError - mskput( [], {}, [ 20, 30 ], 'strict' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object... -{ - mskput( [], [ 1, 0, 0, 1 ], 1, 'strict' ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], true, 'strict' ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], false, 'strict' ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], null, 'strict' ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], void 0, 'strict' ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], {}, 'strict' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a valid mode... -{ - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], '1' ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], 1 ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], true ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], false ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], null ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], void 0 ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], {} ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], [] ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskput(); // $ExpectError - mskput( [] ); // $ExpectError - mskput( [], [] ); // $ExpectError - mskput( [], [], [] ); // $ExpectError - mskput( [], [], [], 'strict', {} ); // $ExpectError -} diff --git a/base/mskput/examples/index.js b/base/mskput/examples/index.js deleted file mode 100644 index feafd49fd..000000000 --- a/base/mskput/examples/index.js +++ /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. -*/ - -'use strict'; - -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var linspace = require( './../../../base/linspace' ); -var mskput = require( './../lib' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate a random mask array: -var N = discreteUniform( 5, 15 ); -var mask = filledBy( N, bernoulli.factory( 0.3 ) ); -console.log( mask ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = mskput( x, mask, values, 'non_strict' ); -console.log( out ); diff --git a/base/mskput/lib/index.js b/base/mskput/lib/index.js deleted file mode 100644 index 3d52b1550..000000000 --- a/base/mskput/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Replace elements of an array with provided values according to a provided mask array. -* -* @module @stdlib/array/base/mskput -* -* @example -* var mskput = require( '@stdlib/array/base/mskput' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values, 'strict' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskput/lib/main.js b/base/mskput/lib/main.js deleted file mode 100644 index 1b6200cbd..000000000 --- a/base/mskput/lib/main.js +++ /dev/null @@ -1,309 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var isBooleanDataType = require( './../../../base/assert/is-boolean-data-type' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpretComplex = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var countFalsy = require( './../../../base/count-falsy' ); - - -// FUNCTIONS // - -/** -* Replaces elements in an indexed array with provided values. -* -* @private -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} values - values to set -* @returns {Collection} input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = indexed( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -*/ -function indexed( x, mask, values ) { - var iv; - var N; - var i; - - N = values.length; - iv = 0; - for ( i = 0; i < x.length; i++ ) { - if ( !mask[ i ] ) { - x[ i ] = values[ iv ]; - iv = ( iv+1 ) % N; - } - } - return x; -} - -/** -* Replaces elements of an accessor array with provided values. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} values - values object -* @returns {Collection} input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var mask = toAccessorArray( [ 1, 0, 0, 1 ] ); -* var values = toAccessorArray( [ 20, 30 ] ); -* -* var out = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( values ) ); -* -* var v = x.get( 0 ); -* // returns 1 -* -* v = x.get( 1 ); -* // returns 20 -*/ -function accessors( x, mask, values ) { - var xdata; - var mdata; - var vdata; - var xset; - var mget; - var vget; - var iv; - var N; - var i; - - xdata = x.data; - mdata = mask.data; - vdata = values.data; - - xset = x.accessors[ 1 ]; - mget = mask.accessors[ 0 ]; - vget = values.accessors[ 0 ]; - - N = vdata.length; - iv = 0; - for ( i = 0; i < xdata.length; i++ ) { - if ( !mget( mdata, i ) ) { - xset( xdata, i, vget( vdata, iv ) ); - iv = ( iv+1 ) % N; - } - } - return xdata; -} - -/** -* Replaces elements in a complex array with provided values. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} values - real-valued floating-point values array view -* @returns {Collection} input array view -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var mask = [ 0, 1, 0, 1 ]; -* var values = new Float64Array( [ 10.0, 20.0, 50.0, 60.0 ] ); -* -* var out = complex( x, arraylike2object( mask ), values ); -* // returns [ 10.0, 20.0, 3.0, 4.0, 50.0, 60.0, 7.0, 8.0 ] -*/ -function complex( x, mask, values ) { - var mdata; - var mget; - var iv; - var N; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - N = values.length; - iv = 0; - for ( i = 0; i < x.length; i += 2 ) { - if ( !mget( mdata, i/2 ) ) { - x[ i ] = values[ iv ]; - x[ i+1 ] = values[ iv+1 ]; - iv = ( iv+2 ) % N; - } - } - return x; -} - -/** -* Replaces elements in a boolean array with provided values. -* -* @private -* @param {Uint8Array} x - input array -* @param {Object} mask - mask array object -* @param {Uint8Array} values - values to set -* @returns {Uint8Array} input array -* -* @example -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = new Uint8Array( [ 1, 1 ] ); -* -* var out = boolean( x, arraylike2object( mask ), values ); -* // returns [ 1, 1, 1, 1 ] -*/ -function boolean( x, mask, values ) { - var mdata; - var mget; - var iv; - var N; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - N = values.length; - iv = 0; - for ( i = 0; i < x.length; i++ ) { - if ( !mget( mdata, i ) ) { - x[ i ] = values[ iv ]; - iv = ( i+1 ) % N; - } - } - return x; -} - - -// MAIN // - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} values - values to set -* @param {string} mode - string specifying behavior when the number of values does not equal the number of falsy mask values -* @throws {Error} insufficient values to satisfy mask array -* @throws {Error} number of values does not equal the number of falsy mask values -* @returns {Collection} input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values, 'strict' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 30 ]; -* -* var out = mskput( x, mask, values, 'strict_broadcast' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 0, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values, 'repeat' ); -* // returns [ 20, 30, 3, 20 ] -* -* var bool = ( out === x ); -* // returns true -*/ -function mskput( x, mask, values, mode ) { - var xo; - var mo; - var vo; - var M; - - M = values.length; - if ( mode === 'strict' ) { - if ( countFalsy( mask ) !== M ) { - throw new Error( 'invalid arguments. Number of values does not equal the number of falsy values in the mask array.' ); - } - } else if ( mode === 'broadcast' ) { - if ( M !== 1 && countFalsy( mask ) > M ) { - throw new Error( 'invalid arguments. Insufficient values to satisfy mask array.' ); - } - } else if ( mode === 'strict_broadcast' ) { - if ( M !== 1 && countFalsy( mask ) !== M ) { - throw new Error( 'invalid arguments. Number of values does not equal the number of falsy values in the mask array.' ); - } - } else if ( mode === 'non_strict' ) { - if ( countFalsy( mask ) > M ) { - throw new Error( 'invalid arguments. Insufficient values to satisfy mask array.' ); - } - } - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - vo = arraylike2object( values ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - vo.accessorProtocol - ) { - // Note: we only explicitly support select dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( isComplexDataType( xo.dtype ) && isComplexDataType( vo.dtype ) ) { - complex( reinterpretComplex( x, 0 ), mo, reinterpretComplex( values, 0 ) ); // eslint-disable-line max-len - return x; - } - if ( isBooleanDataType( xo.dtype ) && isBooleanDataType( vo.dtype ) ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( values, 0 ) ); // eslint-disable-line max-len - return x; - } - accessors( xo, mo, vo ); - return x; - } - indexed( x, mask, values ); - return x; -} - - -// EXPORTS // - -module.exports = mskput; diff --git a/base/mskput/package.json b/base/mskput/package.json deleted file mode 100644 index 884f37077..000000000 --- a/base/mskput/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/mskput", - "version": "0.0.0", - "description": "Replace elements of an array with provided values according to a provided mask array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "set", - "replace", - "put", - "update", - "mask", - "missing", - "na" - ] -} diff --git a/base/mskput/test/test.js b/base/mskput/test/test.js deleted file mode 100644 index 3b09f1d34..000000000 --- a/base/mskput/test/test.js +++ /dev/null @@ -1,436 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var Int32Array = require( './../../../int32' ); -var BooleanArray = require( './../../../bool' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var mskput = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskput, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function replaces elements in an array (generic)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 0, 1, 0 ]; - actual = mskput( x, mask, [ 20, 40 ], 'strict' ); - expected = [ 1, 20, 3, 40 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, [ 20, 30, 40, 50 ], 'strict' ); - expected = [ 20, 30, 40, 50 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - actual = mskput( x, mask, [ 20, 30, 40, 50 ], 'non_strict' ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (generic, broadcasting)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 0, 1, 0 ]; - actual = mskput( x, mask, [ 20 ], 'strict_broadcast' ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, [ 20 ], 'broadcast' ); - expected = [ 20, 20, 20, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - actual = mskput( x, mask, [ 20 ], 'strict_broadcast' ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, [ 100, 200 ], 'repeat' ); - expected = [ 100, 200, 100, 200 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (typed)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 0, 1, 0 ]; - actual = mskput( x, mask, new Int32Array( [ 20, 40 ] ), 'strict' ); - expected = new Int32Array( [ 1, 20, 3, 40 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, new Int32Array( [ 20, 30, 40, 50 ] ), 'strict' ); - expected = new Int32Array( [ 20, 30, 40, 50 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 1, 1, 1 ]; - actual = mskput( x, mask, new Int32Array( [ 20, 30, 40, 50 ] ), 'non_strict' ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (typed, broadcasting)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 0, 1, 0 ]; - actual = mskput( x, mask, [ 20 ], 'strict_broadcast' ); - expected = new Int32Array( [ 1, 20, 3, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, [ 20 ], 'broadcast' ); - expected = new Int32Array( [ 20, 20, 20, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 1, 1, 1 ]; - actual = mskput( x, mask, [ 20 ], 'strict_broadcast' ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, [ 100, 200 ], 'repeat' ); - expected = new Int32Array( [ 100, 200, 100, 200 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - values = [ - new Complex64( 30.0, 40.0 ), - new Complex64( 70.0, 80.0 ) - ]; - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 30.0, 40.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 70.0, 80.0 ) - ]; - actual = mskput( x, mask, values, 'strict' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, broadcasting)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - values = [ - new Complex64( 100.0, 200.0 ) - ]; - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 100.0, 200.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 100.0, 200.0 ) - ]; - actual = mskput( x, mask, values, 'strict_broadcast' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - values = new Complex64Array( [ 30.0, 40.0, 70.0, 80.0 ] ); - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 30.0, 40.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 70.0, 80.0 ) - ]; - actual = mskput( x, mask, values, 'strict' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex, broadcasting)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - values = new Complex64Array( [ 100.0, 200.0 ] ); - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 100.0, 200.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 100.0, 200.0 ) - ]; - actual = mskput( x, mask, values, 'strict_broadcast' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - values = new BooleanArray( [ true, false ] ); - expected = [ true, true, false, true ]; - actual = mskput( x, mask, values, 'strict' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean, broadcasting)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - mask = toAccessorArray( [ 1, 0, 0, 1 ] ); - values = [ true ]; - expected = [ true, true, true, true ]; - actual = mskput( x, mask, values, 'strict_broadcast' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'when the "mode" is "strict", the function throws an error if provided insufficient values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200 ], 'strict' ); - } -}); - -tape( 'when the "mode" is "strict", the function throws an error if provided too many values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200, 300, 400, 500, 600 ], 'strict' ); - } -}); - -tape( 'when the "mode" is "non_strict", the function throws an error if provided insufficient values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200 ], 'non_strict' ); - } -}); - -tape( 'when the "mode" is "strict_broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of falsy values in a mask array (insufficient)', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200, 400 ], 'strict_broadcast' ); - } -}); - -tape( 'when the "mode" is "strict_broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of falsy values in a mask array (too many)', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200, 400, 500, 600, 700 ], 'strict_broadcast' ); - } -}); - -tape( 'when the "mode" is "broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of falsy values in a mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200, 400 ], 'broadcast' ); - } -}); diff --git a/base/mskreject-map/README.md b/base/mskreject-map/README.md deleted file mode 100644 index ececbf936..000000000 --- a/base/mskreject-map/README.md +++ /dev/null @@ -1,174 +0,0 @@ - - -# mskrejectMap - -> Apply a mask to a provided input array and map the unmasked values according to a callback function. - -
- -## Usage - -```javascript -var mskrejectMap = require( '@stdlib/array/base/mskreject-map' ); -``` - -#### mskrejectMap( x, mask, clbk\[, thisArg ] ) - -Returns a new array by applying a mask and mapping the unmasked values according to a callback function. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -function clbk( val ) { - return val * 2; -} - -var y = mskrejectMap( x, [ 0, 1, 0, 1 ], clbk ); -// returns [ 2, 6 ] -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. -- **clbk**: function to apply. -- **thisArg**: applied function execution context (_optional_). - -The `clbk` function is provided three arguments: - -- **value**: current unmasked array element. -- **index**: current unmasked array element index. -- **arr**: input array. - -To set the `clbk` function execution context, provide a `thisArg`. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var mask = [ 0, 1, 0, 1 ]; - -var increase = 3; - -function clbk( value ) { - return value + this; -} - -var out = mskrejectMap( x, mask, clbk, increase ); -// returns [ 4, 6 ] -``` - -The function **always** returns a new "generic" array. - -#### mskrejectMap.assign( x, mask, out, stride, offset, clbk\[, thisArg ] ) - -Applies a mask to a provided input array, maps the unmasked values according to a callback function, and assigns to elements in a provided output array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var mask = [ 1, 0, 1, 0 ]; - -var out = [ 0, 0, 0, 0 ]; - -function clbk( val ) { - return val * 2; -} - -var arr = mskrejectMap.assign( x, mask, out, -2, out.length-1, clbk ); -// returns [ 0, 8, 0, 4 ] - -var bool = ( arr === out ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. -- **clbk**: function to apply. -- **thisArg**: applied function execution context (_optional_). - -
- - - -
- -## Notes - -- If a `mask` array element is falsy, the corresponding element in `x` is **mapped** in the output array; otherwise, the corresponding element in `x` is "masked" and thus **excluded** from the output array. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskrejectMap = require( '@stdlib/array/base/mskreject-map' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -function clbk( val ) { - return val * 2; -} - -// Filter an array using the mask: -var y = mskrejectMap( x, mask, clbk ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskreject-map/benchmark/benchmark.assign.length.js b/base/mskreject-map/benchmark/benchmark.assign.length.js deleted file mode 100644 index 732ca5eef..000000000 --- a/base/mskreject-map/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,106 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var zeros = require( './../../../zeros' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isnan = require( '@stdlib/assert/is-nan' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var mskrejectMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var mask; - var out; - var x; - - x = zeroTo( len, 'generic' ); - mask = zeros( len, 'generic' ); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskrejectMap.assign( x, mask, out, 1, 0, function clbk( val ) { - return val * 2; - } ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) || isnan( v[ i%len ] ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/mskreject-map/benchmark/benchmark.js b/base/mskreject-map/benchmark/benchmark.js deleted file mode 100644 index b52a738cd..000000000 --- a/base/mskreject-map/benchmark/benchmark.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var mskrejectMap = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = zeros( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskrejectMap( x, y, function clbk( val ) { - return val * 2; - } ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/mskreject-map/benchmark/benchmark.length.js b/base/mskreject-map/benchmark/benchmark.length.js deleted file mode 100644 index b51c7c01a..000000000 --- a/base/mskreject-map/benchmark/benchmark.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var zeros = require( './../../../base/zeros' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var mskrejectMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskrejectMap( x, y, function clbk( val ) { - return val * 2; - } ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/mskreject-map/docs/repl.txt b/base/mskreject-map/docs/repl.txt deleted file mode 100644 index a55f0d5d9..000000000 --- a/base/mskreject-map/docs/repl.txt +++ /dev/null @@ -1,87 +0,0 @@ - -{{alias}}( x, mask, clbk[, thisArg] ) - Returns a new array by applying a mask to a provided input array - and mapping the unmasked values according to a callback function. - - If a mask array element is falsy, the corresponding element in `x` is - mapped in the output array; otherwise, the corresponding element in `x` is - "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - clbk: Function - Mapping function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > function clbk( val ) { return val * 2; } - > var y = {{alias}}( x, [ 0, 1, 0, 1 ], clbk ) - [ 2, 6 ] - - -{{alias}}.assign( x, mask, out, stride, offset, clbk[, thisArg] ) - Applies a mask to a provided input array, maps the unmasked values - according to a callback function, and assigns the unmasked values - to elements in a provided output array. - - If a mask array element is falsy, the corresponding element in `x` is - mapped and included in the output array; otherwise, the corresponding - element in `x` is "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - clbk: Function - Mapping function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var m = [ 0, 1, 0, 1 ]; - > var out = [ 0, 0, 0, 0 ]; - > var scale = 5; - > function clbk( val ) { return val * this; } - > var arr = {{alias}}.assign( x, m, out, 2, 0, clbk, scale ) - [ 5, 0, 15, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- diff --git a/base/mskreject-map/docs/types/index.d.ts b/base/mskreject-map/docs/types/index.d.ts deleted file mode 100644 index b5d77563b..000000000 --- a/base/mskreject-map/docs/types/index.d.ts +++ /dev/null @@ -1,152 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a transformed element. -* -* @param value - current array element -* @returns transformed array element -*/ -type Unary = ( this: U, value: T ) => V; - -/** -* Returns a transformed element. -* -* @param value - current array element -* @param index - current array element index -* @returns transformed array element -*/ -type Binary = ( this: U, value: T, index: number ) => V; - -/** -* Returns a transformed element. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns transformed array element -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => V; - -/** -* Returns a transformed element. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns transformed array element -*/ -type Callback = Unary | Binary | Ternary; - -/** -* Interface describing `mskrejectMap`. -*/ -interface MskrejectMap { - /** - * Returns a new array by applying a mask and mapping the unmasked values according to a callback function. - * - * @param x - input array - * @param mask - mask array - * @param clbk - mapping function - * @param thisArg - function context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = mskrejectMap( x, [ 0, 1, 0, 1 ], function( val ) { - * return val * 2; - * } ); - * // returns [ 2, 6 ] - */ - ( x: Collection | AccessorArrayLike, mask: Collection, clbk: Callback, thisArg?: U ): Array; - - /** - * Applies a mask to a provided input array, maps the unmasked values according to a callback function, and assigns to elements in a provided output array. - * - * @param x - input array - * @param mask - mask array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @param clbk - mapping function - * @param thisArg - function context - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var mask = [ 1, 0, 1, 0 ]; - * var out = [ 0, 0, 0, 0 ]; - * - * function clbk( val ) { - * return val * 2; - * } - * - * var arr = mskrejectMap.assign( x, mask, out, -2, out.length-1, clbk ); - * // returns [ 0, 8, 0, 4 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, mask: Collection, out: Collection, stride: number, offset: number, clbk: Callback, thisArg?: U ): Collection; -} - -/** -* Returns a new array by applying a mask and mapping the unmasked values according to a callback function. -* -* @param x - input array -* @param mask - mask array -* @param clbk - mapping function -* @param thisArg - function context -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskrejectMap( x, [ 0, 1, 0, 1 ], function( val ) { -* return val * 2; -* } ); -* // returns [ 2, 6 ] -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 1, 0, 1, 0 ]; -* var out = [ 0, 0, 0, 0 ]; -* -* function clbk( val ) { -* return val * 2; -* } -* -* var arr = mskrejectMap.assign( x, mask, out, -2, out.length-1, clbk ); -* // returns [ 0, 8, 0, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var mskrejectMap: MskrejectMap; - - -// EXPORTS // - -export = mskrejectMap; diff --git a/base/mskreject-map/docs/types/test.ts b/base/mskreject-map/docs/types/test.ts deleted file mode 100644 index 9a8b61047..000000000 --- a/base/mskreject-map/docs/types/test.ts +++ /dev/null @@ -1,80 +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. -*/ - -import mskrejectMap = require( './index' ); - - -// FUNCTIONS // - -/** -* Multiplies a value by two. -* -* @param val - input value -* @returns result -*/ -function timesTwo( val: number ): number { - return val * 2; -} - -/** -* Identity function. -* -* @param val - input value -* @returns input value -*/ -function identity( val: string ): string { - return val; -} - - -// TESTS // - -// The function returns an array... -{ - mskrejectMap( [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ], timesTwo ); // $ExpectType number[] - mskrejectMap( [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ], timesTwo ); // $ExpectType any[] - mskrejectMap( [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ], timesTwo ); // $ExpectType number[] - mskrejectMap( [ '1', '2', '3', '4' ], [ 0, 0, 0, 0 ], identity ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskrejectMap( 1, [ 0, 0 ] ); // $ExpectError - mskrejectMap( true, [ 0, 0 ] ); // $ExpectError - mskrejectMap( false, [ 0, 0 ] ); // $ExpectError - mskrejectMap( null, [ 0, 0 ] ); // $ExpectError - mskrejectMap( void 0, [ 0, 0 ] ); // $ExpectError - mskrejectMap( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskrejectMap( [], 1 ); // $ExpectError - mskrejectMap( [], true ); // $ExpectError - mskrejectMap( [], false ); // $ExpectError - mskrejectMap( [], null ); // $ExpectError - mskrejectMap( [], void 0 ); // $ExpectError - mskrejectMap( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskrejectMap(); // $ExpectError - mskrejectMap( [] ); // $ExpectError - mskrejectMap( [], [], [] ); // $ExpectError -} diff --git a/base/mskreject-map/examples/index.js b/base/mskreject-map/examples/index.js deleted file mode 100644 index 6d03159b2..000000000 --- a/base/mskreject-map/examples/index.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -var zeroTo = require( './../../../base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskrejectMap = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -function clbk( val ) { - return val * 2; -} - -// Filter an array using the mask: -var y = mskrejectMap( x, mask, clbk ); -console.log( y ); diff --git a/base/mskreject-map/lib/assign.js b/base/mskreject-map/lib/assign.js deleted file mode 100644 index 8f1015767..000000000 --- a/base/mskreject-map/lib/assign.js +++ /dev/null @@ -1,237 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array, maps the unmasked values according to a callback function, and assigns to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} clbk - function to apply -* @param {*} [thisArg] - function context -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0, function( val ) { -* return val * 2; -* } ); -* // returns [ 2, 6, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset, clbk, thisArg ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( !mask[ i ] ) { - out[ io ] = clbk.call(thisArg, x[ i ], i, x ); - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array, maps the unmasked values according to a callback function, and assigns to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} clbk - function to apply -* @param {*} [thisArg] - function context -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0, function( val ) { -* return val * 2; -* } ); -* -* var v = arr.get( 0 ); -* // returns 2 -* -* v = arr.get( 1 ); -* // returns 6 -*/ -function accessors( x, mask, out, stride, offset, clbk, thisArg ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( !mget( mdata, i ) ) { - oset( odata, io, clbk.call( thisArg, xget( xdata, i ), i, xdata ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array, maps the unmasked values according to a callback function, and assigns to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} clbk - function to apply -* @param {*} [thisArg] - function context -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0, function( val ) { -* return val * 2; -* } ); -* // returns [ 2.0, 4.0, 10.0, 12.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset, clbk, thisArg ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( !mget( mdata, i ) ) { - j = i * 2; - out[ io ] = clbk.call( thisArg, x[ j ], j, x ); - out[ io+1 ] = clbk.call( thisArg, x[ j+1 ], j+1, x ); - io += so; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array, maps the unmasked values according to a callback function, and assigns to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} clbk - function to apply -* @param {*} [thisArg] - function context -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0, function( val ) { -* return val * 2; -* } ); -* // returns [ 2, 6 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset, clbk, thisArg ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset, clbk, thisArg ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset, clbk, thisArg ); - return out; - } - indexed( x, mask, out, stride, offset, clbk, thisArg ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/mskreject-map/lib/index.js b/base/mskreject-map/lib/index.js deleted file mode 100644 index 6d7da2187..000000000 --- a/base/mskreject-map/lib/index.js +++ /dev/null @@ -1,67 +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. -*/ - -'use strict'; - -/** -* Apply a mask to a provided input array and map the unmasked values according to a callback function. -* -* @module @stdlib/array/base/mskreject-map -* -* @example -* var mskrejectMap = require( '@stdlib/array/base/mskreject-map' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskrejectMap( x, mask, function( val ) { -* return val * 2; -* } ); -* // returns [ 2, 6 ] -* -* @example -* var mskrejectMap = require( '@stdlib/array/base/mskreject-map' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskrejectMap.assign( x, mask, out, 1, 0, function( val ) { -* return val + this; -* }, 5 ); -* // returns [ 6, 8 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskreject-map/lib/main.js b/base/mskreject-map/lib/main.js deleted file mode 100644 index e8e56c161..000000000 --- a/base/mskreject-map/lib/main.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array and mapping the unmasked values according to a callback function. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Function} clbk - function to apply -* @param {*} [thisArg] - function context -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskrejectMap( x, mask, function( val ) { -* return val * 2; -* } ); -* // returns [ 2, 6 ] -*/ -function mskrejectMap( x, mask, clbk, thisArg ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( !mget( mask, i ) ) { - out.push( clbk.call( thisArg, xget( x, i ), i, x ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskrejectMap; diff --git a/base/mskreject-map/package.json b/base/mskreject-map/package.json deleted file mode 100644 index 1a1f7650b..000000000 --- a/base/mskreject-map/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/mskreject-map", - "version": "0.0.0", - "description": "Apply a mask to a provided input array and map the unmasked values according to a callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index", - "mask", - "reject", - "filter" - ] -} diff --git a/base/mskreject-map/test/test.assign.js b/base/mskreject-map/test/test.assign.js deleted file mode 100644 index 387e162e5..000000000 --- a/base/mskreject-map/test/test.assign.js +++ /dev/null @@ -1,311 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Int32Array = require( './../../../int32' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var zeros = require( './../../../zeros' ); -var mskrejectMap = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskrejectMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function rejects array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - function clbk( val ) { - return val * 2; - } - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 2, 'generic' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 8 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 0, 'generic' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 0 ]; - out = zeros( 1, 'generic' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - expected = [ 8 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 4, 'generic' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - expected = [ 2, 4, 6, 8 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 4, 'generic' ); - actual = mskrejectMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 8, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function rejects array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var inc = 5; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - function clbk( val ) { - return val + this; // eslint-disable-line no-invalid-this - } - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 2, 'int32' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk, inc ); - expected = new Int32Array( [ 7, 9 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 0, 'int32' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk, inc ); - expected = new Int32Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 0 ]; - out = zeros( 1, 'int32' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk, inc ); - expected = new Int32Array( [ 9 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 4, 'int32' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk, inc ); - expected = new Int32Array( [ 6, 7, 8, 9 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 4, 'int32' ); - actual = mskrejectMap( x, mask, out, -2, out.length-1, clbk, inc ); - expected = new Int32Array( [ 0, 9, 0, 7 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function rejects array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var scale = 5; - var mask; - var out; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - function clbk( val ) { - return val * this; // eslint-disable-line no-invalid-this - } - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 2, 'complex64' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk, scale ); - expected = new Complex64Array( [ scale * 3.0, scale * 4.0, scale * 7.0, scale * 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 0, 'complex64' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk, scale ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 0 ]; - out = zeros( 1, 'complex64' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk, scale ); - expected = new Complex64Array( [ scale * 7.0, scale * 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 4, 'complex64' ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk, scale ); - expected = new Complex64Array( [ scale * 1.0, scale * 2.0, scale * 3.0, scale * 4.0, scale * 5.0, scale * 6.0, scale * 7.0, scale * 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 4, 'complex64' ); - actual = mskrejectMap( x, mask, out, -2, out.length-1, clbk, scale ); - expected = new Complex64Array( [ 0.0, 0.0, scale * 7.0, scale * 8.0, 0.0, 0.0, scale * 3.0, scale * 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function rejects array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - function clbk( val ) { - return val * 2; - } - - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - out = toAccessorArray( zeros( 2, 'generic' ) ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - expected = [ 4, 8 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 0 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - expected = [ 8 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - expected = [ 2, 4, 6, 8 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskrejectMap( x, mask, out, -2, out.length-1, clbk ); - expected = [ 0, 8, 0, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - mask = [ 1, 1, 1, 1 ]; - - function clbk( val ) { - return val * 2; - } - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = mskrejectMap( x, mask, out, 1, 0, clbk ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/base/mskreject-map/test/test.js b/base/mskreject-map/test/test.js deleted file mode 100644 index e746a0254..000000000 --- a/base/mskreject-map/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var mskrejectMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskrejectMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskrejectMap, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskrejectMap, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/mskreject-map/test/test.main.js b/base/mskreject-map/test/test.main.js deleted file mode 100644 index 6e0289a66..000000000 --- a/base/mskreject-map/test/test.main.js +++ /dev/null @@ -1,114 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert/is-array' ); -var mskrejectMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskrejectMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function rejects array elements', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - function clbk( val ) { - return val * 2; - } - - mask = [ 0, 1, 0, 1 ]; - actual = mskrejectMap( x, mask, clbk ); - expected = [ 2, 6 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskrejectMap( x, mask, clbk ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskrejectMap( x, mask, clbk ); - expected = [ 2, 4, 6 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - function clbk( val ) { - return val * 2; - } - t.deepEqual( mskrejectMap( [], [], clbk ), [], 'returns expected value' ); - t.end(); -}); - -tape( 'the function applies a mask to a provided input array and maps the unmasked values according to different callback functions', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - function clbk1( val ) { - return val * 2; - } - - function clbk2( val ) { - return val * val; - } - - mask = [ 0, 1, 0, 1 ]; - actual = mskrejectMap( x, mask, clbk1 ); - expected = [ 2, 6 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = mskrejectMap( x, mask, clbk2 ); - expected = [ 1, 9 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - function clbk( val ) { - return val * 2; - } - t.deepEqual( mskrejectMap( [], [], clbk ), [], 'returns expected value' ); - t.end(); -}); diff --git a/base/mskreject/README.md b/base/mskreject/README.md deleted file mode 100644 index 6f2d9e40d..000000000 --- a/base/mskreject/README.md +++ /dev/null @@ -1,134 +0,0 @@ - - -# mskreject - -> Apply a mask to a provided input array. - -
- -## Usage - -```javascript -var mskreject = require( '@stdlib/array/base/mskreject' ); -``` - -#### mskreject( x, mask ) - -Returns a new array by applying a mask to a provided input array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var y = mskreject( x, [ 0, 1, 0, 1 ] ); -// returns [ 1, 3 ] -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. - -The function **always** returns a new "generic" array. - -#### mskreject.assign( x, mask, out, stride, offset ) - -Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var mask = [ 1, 0, 1, 0 ]; - -var out = [ 0, 0, 0, 0 ]; - -var arr = mskreject.assign( x, mask, out, -2, out.length-1 ); -// returns [ 0, 4, 0, 2 ] - -var bool = ( arr === out ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. - -
- - - -
- -## Notes - -- If a `mask` array element is falsy, the corresponding element in `x` is **included** in the output array; otherwise, the corresponding element in `x` is "masked" and thus **excluded** from the output array. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskreject = require( '@stdlib/array/base/mskreject' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskreject( x, mask ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskreject/benchmark/benchmark.assign.length.js b/base/mskreject/benchmark/benchmark.assign.length.js deleted file mode 100644 index b62341ab8..000000000 --- a/base/mskreject/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,104 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var zeros = require( './../../../zeros' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isnan = require( '@stdlib/assert/is-nan' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var mskreject = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var mask; - var out; - var x; - - x = zeroTo( len, 'generic' ); - mask = zeros( len, 'generic' ); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskreject.assign( x, mask, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) || isnan( v[ i%len ] ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/mskreject/benchmark/benchmark.js b/base/mskreject/benchmark/benchmark.js deleted file mode 100644 index f79715d15..000000000 --- a/base/mskreject/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var mskreject = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = zeros( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskreject( x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/mskreject/benchmark/benchmark.length.js b/base/mskreject/benchmark/benchmark.length.js deleted file mode 100644 index 52f964e41..000000000 --- a/base/mskreject/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var zeros = require( './../../../base/zeros' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var mskreject = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskreject( x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/mskreject/docs/repl.txt b/base/mskreject/docs/repl.txt deleted file mode 100644 index 2c6eac243..000000000 --- a/base/mskreject/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input array. - - If a mask array element is falsy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` is - "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 1, 3 ] - - -{{alias}}.assign( x, mask, out, stride, offset ) - Applies a mask to a provided input array and assigns unmasked values to - elements in a provided output array. - - If a mask array element is falsy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` is - "masked" and thus excluded from the output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var m = [ 0, 1, 0, 1 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, m, out, 2, 0 ) - [ 1, 0, 3, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/base/mskreject/docs/types/index.d.ts b/base/mskreject/docs/types/index.d.ts deleted file mode 100644 index 2a14e0d69..000000000 --- a/base/mskreject/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskreject( x, [ 0, 1, 0, 1 ] ); -* // returns [ 1, 3 ] -*/ -declare function mskreject( x: Collection, mask: Collection ): Array; - - -// EXPORTS // - -export = mskreject; diff --git a/base/mskreject/docs/types/test.ts b/base/mskreject/docs/types/test.ts deleted file mode 100644 index dc6498141..000000000 --- a/base/mskreject/docs/types/test.ts +++ /dev/null @@ -1,57 +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. -*/ - -import mskreject = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskreject( [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ] ); // $ExpectType number[] - mskreject( [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ] ); // $ExpectType any[] - mskreject( [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ] ); // $ExpectType number[] - mskreject( [ '1', '2', '3', '4' ], [ 0, 0, 0, 0 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskreject( 1, [ 0, 0 ] ); // $ExpectError - mskreject( true, [ 0, 0 ] ); // $ExpectError - mskreject( false, [ 0, 0 ] ); // $ExpectError - mskreject( null, [ 0, 0 ] ); // $ExpectError - mskreject( void 0, [ 0, 0 ] ); // $ExpectError - mskreject( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskreject( [], 1 ); // $ExpectError - mskreject( [], true ); // $ExpectError - mskreject( [], false ); // $ExpectError - mskreject( [], null ); // $ExpectError - mskreject( [], void 0 ); // $ExpectError - mskreject( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskreject(); // $ExpectError - mskreject( [] ); // $ExpectError - mskreject( [], [], [] ); // $ExpectError -} diff --git a/base/mskreject/examples/index.js b/base/mskreject/examples/index.js deleted file mode 100644 index b9af6a267..000000000 --- a/base/mskreject/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var zeroTo = require( './../../../base/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskreject = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20 ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskreject( x, mask ); -console.log( y ); diff --git a/base/mskreject/lib/assign.js b/base/mskreject/lib/assign.js deleted file mode 100644 index 384b2e917..000000000 --- a/base/mskreject/lib/assign.js +++ /dev/null @@ -1,272 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var isBooleanDataType = require( './../../../base/assert/is-boolean-data-type' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, mask, out, 1, 0 ); -* // returns [ 1, 3, 0, 0 ] -*/ -function indexed( x, mask, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( !mask[ i ] ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - -/** -* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var mask = toAccessorArray( [ 0, 1, 0, 1 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 1 -* -* v = arr.get( 1 ); -* // returns 3 -*/ -function accessors( x, mask, out, stride, offset ) { - var xdata; - var mdata; - var odata; - var xget; - var mget; - var oset; - var io; - var i; - - xdata = x.data; - mdata = mask.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - mget = mask.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( !mget( mdata, i ) ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - } - return odata; -} - -/** -* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 1.0, 2.0, 5.0, 6.0, 0.0, 0.0, 0.0, 0.0 ] -*/ -function complex( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var so; - var i; - var j; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < mdata.length; i++ ) { - if ( !mget( mdata, i ) ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - } - return out; -} - -/** -* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array. -* -* @private -* @param {Collection} x - boolean input array view -* @param {Object} mask - mask array object -* @param {Collection} out - boolean output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = new Uint8Array( 4 ); -* -* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 ); -* // returns [ 1, 0, 0, 0 ] -*/ -function boolean( x, mask, out, stride, offset ) { - var mdata; - var mget; - var io; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - io = offset; - for ( i = 0; i < mdata.length; i++ ) { - if ( !mget( mdata, i ) ) { - out[ io ] = x[ i ]; - io += stride; - } - } - return out; -} - - -// MAIN // - -/** -* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = assign( x, mask, out, 1, 0 ); -* // returns [ 1, 3 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, mask, out, stride, offset ) { - var xo; - var mo; - var oo; - - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, mo, oo, stride, offset ); - return out; - } - indexed( x, mask, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/mskreject/lib/index.js b/base/mskreject/lib/index.js deleted file mode 100644 index 02eed372a..000000000 --- a/base/mskreject/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array/base/mskreject -* -* @example -* var mskreject = require( '@stdlib/array/base/mskreject' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskreject( x, mask ); -* // returns [ 1, 3 ] -* -* @example -* var mskreject = require( '@stdlib/array/base/mskreject' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var out = [ 0, 0 ]; -* var arr = mskreject.assign( x, mask, out, 1, 0 ); -* // returns [ 1, 3 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskreject/lib/main.js b/base/mskreject/lib/main.js deleted file mode 100644 index 2db38f2d0..000000000 --- a/base/mskreject/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskreject( x, mask ); -* // returns [ 1, 3 ] -*/ -function mskreject( x, mask ) { - var xget; - var mget; - var out; - var i; - - // Resolve accessors for retrieving array elements: - xget = resolveGetter( x ); - mget = resolveGetter( mask ); - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < x.length; i++ ) { - if ( !mget( mask, i ) ) { - out.push( xget( x, i ) ); // use `Array#push` to ensure "fast" elements - } - } - return out; -} - - -// EXPORTS // - -module.exports = mskreject; diff --git a/base/mskreject/package.json b/base/mskreject/package.json deleted file mode 100644 index 1c85a8a23..000000000 --- a/base/mskreject/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/mskreject", - "version": "0.0.0", - "description": "Apply a mask to a provided input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index", - "mask", - "reject", - "filter" - ] -} diff --git a/base/mskreject/test/test.assign.js b/base/mskreject/test/test.assign.js deleted file mode 100644 index 5db91eeff..000000000 --- a/base/mskreject/test/test.assign.js +++ /dev/null @@ -1,349 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Int32Array = require( './../../../int32' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); -var zeros = require( './../../../zeros' ); -var mskreject = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskreject, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function rejects array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 2, 'generic' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 0, 'generic' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 0 ]; - out = zeros( 1, 'generic' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 4, 'generic' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 4, 'generic' ); - actual = mskreject( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function rejects array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 2, 'int32' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 2, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 0, 'int32' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new Int32Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 0 ]; - out = zeros( 1, 'int32' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 4, 'int32' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 4, 'int32' ); - actual = mskreject( x, mask, out, -2, out.length-1 ); - expected = new Int32Array( [ 0, 4, 0, 2 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function rejects array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 2, 'complex64' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = zeros( 0, 'complex64' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new Complex64Array( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 0 ]; - out = zeros( 1, 'complex64' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = zeros( 4, 'complex64' ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 0, 1, 0 ]; - out = zeros( 4, 'complex64' ); - actual = mskreject( x, mask, out, -2, out.length-1 ); - expected = new Complex64Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function rejects array elements (boolean array)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = new BooleanArray( [ true, false, false, true ] ); - - mask = [ 1, 0, 1, 0 ]; - out = new BooleanArray( 2 ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - out = new BooleanArray( 0 ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new BooleanArray( [] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 0 ]; - out = new BooleanArray( 1 ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - out = new BooleanArray( 4 ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = new BooleanArray( [ true, false, false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 0, 1, 0 ]; - out = new BooleanArray( 4 ); - actual = mskreject( x, mask, out, -2, out.length-1 ); - expected = new BooleanArray( [ false, true, false, false ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function rejects array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - out = toAccessorArray( zeros( 2, 'generic' ) ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( 0, 'generic' ) ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = []; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 1, 1, 0 ] ); - out = toAccessorArray( zeros( 1, 'generic' ) ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = [ 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskreject( x, mask, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - out = toAccessorArray( zeros( 4, 'generic' ) ); - actual = mskreject( x, mask, out, -2, out.length-1 ); - expected = [ 0, 4, 0, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which masks all input array values', function test( t ) { - var expected; - var actual; - var mask; - var out; - var x; - - mask = [ 1, 1, 1, 1 ]; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskreject( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskreject( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = mskreject( x, mask, out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = mskreject( x, mask, out, 1, 0 ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - out = new BooleanArray( [ false, false, false, false ] ); - expected = new BooleanArray( [ false, false, false, false ] ); - actual = mskreject( x, mask, out, 1, 0 ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/base/mskreject/test/test.js b/base/mskreject/test/test.js deleted file mode 100644 index 5d39f33ce..000000000 --- a/base/mskreject/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var mskreject = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskreject, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( mskreject, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( mskreject, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/mskreject/test/test.main.js b/base/mskreject/test/test.main.js deleted file mode 100644 index ad9aaec18..000000000 --- a/base/mskreject/test/test.main.js +++ /dev/null @@ -1,113 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var isSameComplex64 = require( '@stdlib/assert/is-same-complex64' ); -var isArray = require( '@stdlib/assert/is-array' ); -var mskreject = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskreject, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function rejects array elements', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskreject( x, mask ); - expected = [ 1, 3 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskreject( x, mask ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskreject( x, mask ); - expected = [ 1, 2, 3 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskreject( x, mask ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function rejects array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskreject( x, mask ); - expected = [ x.get( 0 ), x.get( 2 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value' ); - } - - x = new BooleanArray( [ true, false, false, true ] ); - mask = [ 0, 1, 0, 1 ]; - actual = mskreject( x, mask ); - expected = [ x.get( 0 ), x.get( 2 ) ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskreject( [], [] ), [], 'returns expected value' ); - t.end(); -}); diff --git a/base/mskunary2d/README.md b/base/mskunary2d/README.md deleted file mode 100644 index 2d1305a2c..000000000 --- a/base/mskunary2d/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# mskunary2d - -> Apply a unary callback to elements in a two-dimensional nested input array according to elements in a two-dimensional nested mask array and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var mskunary2d = require( '@stdlib/array/base/mskunary2d' ); -``` - -#### mskunary2d( arrays, shape, fcn ) - -Applies a unary callback to elements in a two-dimensional nested input array according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; -var mask = [ [ 0, 1 ], [ 0, 0 ] ]; - -var shape = [ 2, 2 ]; - -// Compute the absolute values in-place: -mskunary2d( [ x, mask, x ], shape, abs ); -// x => [ [ 1.0, -2.0 ], [ 3.0, 4.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array, an input nested mask array, and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. -- An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var mskunary2d = require( '@stdlib/array/base/mskunary2d' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var mask = filled2dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var y = zeros2d( shape ); -console.log( y ); - -mskunary2d( [ x, mask, y ], shape, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskunary2d/benchmark/benchmark.js b/base/mskunary2d/benchmark/benchmark.js deleted file mode 100644 index a75738ef8..000000000 --- a/base/mskunary2d/benchmark/benchmark.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var mskunary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var m; - var y; - - x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - m = filled2dBy( shape, bernoulli( 0.5 ) ); - y = zeros2d( shape ); - - arrays = [ x, m, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - mskunary2d( arrays, shape, identity ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/mskunary2d/docs/repl.txt b/base/mskunary2d/docs/repl.txt deleted file mode 100644 index d7522cc57..000000000 --- a/base/mskunary2d/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a unary callback to elements in a two-dimensional nested input array - according to elements in a two-dimensional nested mask array and assigns - results to elements in a two-dimensional nested output array. - - An element in an input array is "masked" if the corresponding element in the - mask array is non-zero. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array, an input nested - mask array, and one output nested array. - - shape: Array - Array shape. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; - > var m = [ [ 0, 1 ], [ 0, 0 ] ]; - > var y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shape = [ 2, 2 ]; - > {{alias}}( [ x, m, y ], shape, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ 1.0, 0.0 ], [ 3.0, 4.0 ] ] - - See Also - -------- - diff --git a/base/mskunary2d/docs/types/index.d.ts b/base/mskunary2d/docs/types/index.d.ts deleted file mode 100644 index 3d960bc06..000000000 --- a/base/mskunary2d/docs/types/index.d.ts +++ /dev/null @@ -1,71 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Applies a unary callback to elements in a two-dimensional nested input array according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. -* -* @param arrays - array containing one input nested array, an input nested mask array, and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* var mask = [ [ 0, 1 ], [ 0, 0 ] ]; -* -* mskunary2d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] -*/ -declare function mskunary2d( arrays: [ Array2D, Array2D, Array2D ], shape: Shape2D, fcn: Unary ): void; - - -// EXPORTS // - -export = mskunary2d; diff --git a/base/mskunary2d/docs/types/test.ts b/base/mskunary2d/docs/types/test.ts deleted file mode 100644 index e48e48004..000000000 --- a/base/mskunary2d/docs/types/test.ts +++ /dev/null @@ -1,95 +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. -*/ - -import mskunary2d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const m = [ [ 0, 1 ], [ 0, 0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - mskunary2d( [ x, m, y ], [ 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - mskunary2d( 'abc', [ 2, 2 ], fcn ); // $ExpectError - mskunary2d( 3.14, [ 2, 2 ], fcn ); // $ExpectError - mskunary2d( true, [ 2, 2 ], fcn ); // $ExpectError - mskunary2d( false, [ 2, 2 ], fcn ); // $ExpectError - mskunary2d( null, [ 2, 2 ], fcn ); // $ExpectError - mskunary2d( [ '1' ], [ 2, 2 ], fcn ); // $ExpectError - mskunary2d( {}, [ 2, 2 ], fcn ); // $ExpectError - mskunary2d( ( x: number ): number => x, [ 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const m = [ [ 0, 1 ], [ 0, 0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - mskunary2d( [ x, m, y ], 'abc', fcn ); // $ExpectError - mskunary2d( [ x, m, y ], 3.14, fcn ); // $ExpectError - mskunary2d( [ x, m, y ], true, fcn ); // $ExpectError - mskunary2d( [ x, m, y ], false, fcn ); // $ExpectError - mskunary2d( [ x, m, y ], null, fcn ); // $ExpectError - mskunary2d( [ x, m, y ], [ '1' ], fcn ); // $ExpectError - mskunary2d( [ x, m, y ], {}, fcn ); // $ExpectError - mskunary2d( [ x, m, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const m = [ [ 0, 1 ], [ 0, 0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - mskunary2d( [ x, m, y ], [ 2, 2 ], 'abc' ); // $ExpectError - mskunary2d( [ x, m, y ], [ 2, 2 ], 3.14 ); // $ExpectError - mskunary2d( [ x, m, y ], [ 2, 2 ], true ); // $ExpectError - mskunary2d( [ x, m, y ], [ 2, 2 ], false ); // $ExpectError - mskunary2d( [ x, m, y ], [ 2, 2 ], null ); // $ExpectError - mskunary2d( [ x, m, y ], [ 2, 2 ], [ '1' ] ); // $ExpectError - mskunary2d( [ x, m, y ], [ 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const m = [ [ 0, 1 ], [ 0, 0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - mskunary2d(); // $ExpectError - mskunary2d( [ x, m, y ] ); // $ExpectError - mskunary2d( [ x, m, y ], [ 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/mskunary2d/examples/index.js b/base/mskunary2d/examples/index.js deleted file mode 100644 index d07fd623f..000000000 --- a/base/mskunary2d/examples/index.js +++ /dev/null @@ -1,40 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var mskunary2d = require( './../lib' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var mask = filled2dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var y = zeros2d( shape ); -console.log( y ); - -mskunary2d( [ x, mask, y ], shape, abs ); -console.log( y ); diff --git a/base/mskunary2d/lib/index.js b/base/mskunary2d/lib/index.js deleted file mode 100644 index 517fe6c1a..000000000 --- a/base/mskunary2d/lib/index.js +++ /dev/null @@ -1,55 +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'; - -/** -* Apply a unary callback to elements in a two-dimensional nested input array according to elements in a two-dimensional nested mask array and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/mskunary2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var mskunary2d = require( '@stdlib/array/base/mskunary2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* var mask = [ [ 0, 1 ], [ 0, 0 ] ]; -* -* mskunary2d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskunary2d/lib/main.js b/base/mskunary2d/lib/main.js deleted file mode 100644 index d9c56b914..000000000 --- a/base/mskunary2d/lib/main.js +++ /dev/null @@ -1,90 +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'; - -// MAIN // - -/** -* Applies a unary callback to elements in a two-dimensional nested input array according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* var mask = [ [ 0, 1 ], [ 0, 0 ] ]; -* -* mskunary2d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] -*/ -function mskunary2d( arrays, shape, fcn ) { - var S0; - var S1; - var i0; - var i1; - var x0; - var y0; - var m0; - var x; - var y; - var m; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 2 ]; - m = arrays[ 1 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x[ i1 ]; - y0 = y[ i1 ]; - m0 = m[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - if ( m0[ i0 ] === 0 ) { - y0[ i0 ] = fcn( x0[ i0 ] ); - } - } - } -} - - -// EXPORTS // - -module.exports = mskunary2d; diff --git a/base/mskunary2d/package.json b/base/mskunary2d/package.json deleted file mode 100644 index dddd74044..000000000 --- a/base/mskunary2d/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/mskunary2d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a two-dimensional nested input array according to elements in a two-dimensional nested mask array and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "unary", - "apply", - "foreach", - "map", - "transform", - "masked", - "mask", - "skip", - "skipped", - "missing", - "missing values", - "na" - ], - "__stdlib__": {} -} diff --git a/base/mskunary2d/test/test.js b/base/mskunary2d/test/test.js deleted file mode 100644 index 16c571147..000000000 --- a/base/mskunary2d/test/test.js +++ /dev/null @@ -1,144 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros2d = require( './../../../base/zeros2d' ); -var mskunary2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskunary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - m = [ - [ 0, 1 ], - [ 0, 0 ] - ]; - - expected = [ - [ 1.0, 0.0 ], - [ 3.0, 4.0 ] - ]; - - y = zeros2d( shape ); - mskunary2d( [ x, m, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - m = [ - [ 1, 0 ], - [ 1, 0 ] - ]; - - expected = [ - [ 0.0, 2.0 ], - [ 0.0, 4.0 ] - ]; - - y = zeros2d( shape ); - mskunary2d( [ x, m, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - m = [ - [ 0, 1 ], - [ 0, 0 ] - ]; - - expected = zeros2d( shape ); - - y = zeros2d( shape ); - mskunary2d( [ x, m, y ], [ 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - m = [ - [ 0, 1 ], - [ 0, 0 ] - ]; - - expected = zeros2d( shape ); - - y = zeros2d( shape ); - mskunary2d( [ x, m, y ], [ 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/mskunary3d/README.md b/base/mskunary3d/README.md deleted file mode 100644 index 4448cbba1..000000000 --- a/base/mskunary3d/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# mskunary3d - -> Apply a unary callback to elements in a three-dimensional nested input array according to elements in a three-dimensional nested mask array and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var mskunary3d = require( '@stdlib/array/base/mskunary3d' ); -``` - -#### mskunary3d( arrays, shape, fcn ) - -Applies a unary callback to elements in a three-dimensional nested input array according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; -var mask = [ [ [ 0, 1 ], [ 0, 0 ] ] ]; - -var shape = [ 1, 2, 2 ]; - -// Compute the absolute values in-place: -mskunary3d( [ x, mask, x ], shape, abs ); -// x => [ [ [ 1.0, -2.0 ], [ 3.0, 4.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array, an input nested mask array, and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. -- An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var mskunary3d = require( '@stdlib/array/base/mskunary3d' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var mask = filled3dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var y = zeros3d( shape ); -console.log( y ); - -mskunary3d( [ x, mask, y ], shape, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskunary3d/benchmark/benchmark.js b/base/mskunary3d/benchmark/benchmark.js deleted file mode 100644 index 2fdd04d7d..000000000 --- a/base/mskunary3d/benchmark/benchmark.js +++ /dev/null @@ -1,122 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var mskunary3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var m; - var y; - - x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - m = filled3dBy( shape, bernoulli( 0.5 ) ); - y = zeros3d( shape ); - - arrays = [ x, m, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - mskunary3d( arrays, shape, identity ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 2 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 2 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/mskunary3d/docs/repl.txt b/base/mskunary3d/docs/repl.txt deleted file mode 100644 index 2c1b2a794..000000000 --- a/base/mskunary3d/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a unary callback to elements in a three-dimensional nested input - array according to elements in a three-dimensional nested mask array and - assigns results to elements in a three-dimensional nested output array. - - An element in an input array is "masked" if the corresponding element in the - mask array is non-zero. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array, an input nested - mask array, and one output nested array. - - shape: Array - Array shape. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; - > var m = [ [ [ 0, 1 ], [ 0, 0 ] ] ]; - > var y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - > var shape = [ 1, 2, 2 ]; - > {{alias}}( [ x, m, y ], shape, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ [ 1.0, 0.0 ], [ 3.0, 4.0 ] ] ] - - See Also - -------- - diff --git a/base/mskunary3d/docs/types/index.d.ts b/base/mskunary3d/docs/types/index.d.ts deleted file mode 100644 index a31c8fa6f..000000000 --- a/base/mskunary3d/docs/types/index.d.ts +++ /dev/null @@ -1,71 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Applies a unary callback to elements in a three-dimensional nested input array according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. -* -* @param arrays - array containing one input nested array, an input nested mask array, and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* var mask = [ [ [ 0, 1 ], [ 0, 0 ] ] ]; -* -* mskunary3d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] -*/ -declare function mskunary3d( arrays: [ Array3D, Array3D, Array3D ], shape: Shape3D, fcn: Unary ): void; - - -// EXPORTS // - -export = mskunary3d; diff --git a/base/mskunary3d/docs/types/test.ts b/base/mskunary3d/docs/types/test.ts deleted file mode 100644 index 4533362c8..000000000 --- a/base/mskunary3d/docs/types/test.ts +++ /dev/null @@ -1,95 +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. -*/ - -import mskunary3d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const m = [ [ [ 0, 1 ], [ 0, 0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - mskunary3d( [ x, m, y ], [ 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - mskunary3d( 'abc', [ 1, 2, 2 ], fcn ); // $ExpectError - mskunary3d( 3.14, [ 1, 2, 2 ], fcn ); // $ExpectError - mskunary3d( true, [ 1, 2, 2 ], fcn ); // $ExpectError - mskunary3d( false, [ 1, 2, 2 ], fcn ); // $ExpectError - mskunary3d( null, [ 1, 2, 2 ], fcn ); // $ExpectError - mskunary3d( [ '1' ], [ 1, 2, 2 ], fcn ); // $ExpectError - mskunary3d( {}, [ 1, 2, 2 ], fcn ); // $ExpectError - mskunary3d( ( x: number ): number => x, [ 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const m = [ [ [ 0, 1 ], [ 0, 0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - mskunary3d( [ x, m, y ], 'abc', fcn ); // $ExpectError - mskunary3d( [ x, m, y ], 3.14, fcn ); // $ExpectError - mskunary3d( [ x, m, y ], true, fcn ); // $ExpectError - mskunary3d( [ x, m, y ], false, fcn ); // $ExpectError - mskunary3d( [ x, m, y ], null, fcn ); // $ExpectError - mskunary3d( [ x, m, y ], [ '1' ], fcn ); // $ExpectError - mskunary3d( [ x, m, y ], {}, fcn ); // $ExpectError - mskunary3d( [ x, m, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const m = [ [ [ 0, 1 ], [ 0, 0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - mskunary3d( [ x, m, y ], [ 1, 2, 2 ], 'abc' ); // $ExpectError - mskunary3d( [ x, m, y ], [ 1, 2, 2 ], 3.14 ); // $ExpectError - mskunary3d( [ x, m, y ], [ 1, 2, 2 ], true ); // $ExpectError - mskunary3d( [ x, m, y ], [ 1, 2, 2 ], false ); // $ExpectError - mskunary3d( [ x, m, y ], [ 1, 2, 2 ], null ); // $ExpectError - mskunary3d( [ x, m, y ], [ 1, 2, 2 ], [ '1' ] ); // $ExpectError - mskunary3d( [ x, m, y ], [ 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const m = [ [ [ 0, 1 ], [ 0, 0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - mskunary3d(); // $ExpectError - mskunary3d( [ x, m, y ] ); // $ExpectError - mskunary3d( [ x, m, y ], [ 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/mskunary3d/examples/index.js b/base/mskunary3d/examples/index.js deleted file mode 100644 index c8733800b..000000000 --- a/base/mskunary3d/examples/index.js +++ /dev/null @@ -1,40 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var mskunary3d = require( './../lib' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var mask = filled3dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var y = zeros3d( shape ); -console.log( y ); - -mskunary3d( [ x, mask, y ], shape, abs ); -console.log( y ); diff --git a/base/mskunary3d/lib/index.js b/base/mskunary3d/lib/index.js deleted file mode 100644 index bf45d1f19..000000000 --- a/base/mskunary3d/lib/index.js +++ /dev/null @@ -1,55 +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'; - -/** -* Apply a unary callback to elements in a three-dimensional nested input array according to elements in a three-dimensional nested mask array and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/mskunary3d -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var mskunary3d = require( '@stdlib/array/base/mskunary3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* var mask = [ [ [ 0, 1 ], [ 0, 0 ] ] ]; -* -* mskunary3d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskunary3d/lib/main.js b/base/mskunary3d/lib/main.js deleted file mode 100644 index 624604e09..000000000 --- a/base/mskunary3d/lib/main.js +++ /dev/null @@ -1,101 +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'; - -// MAIN // - -/** -* Applies a unary callback to elements in a three-dimensional nested input array according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* var mask = [ [ [ 0, 1 ], [ 0, 0 ] ] ]; -* -* mskunary3d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] -*/ -function mskunary3d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var x0; - var x1; - var y0; - var y1; - var m0; - var m1; - var x; - var y; - var m; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 2 ]; - m = arrays[ 1 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x[ i2 ]; - y1 = y[ i2 ]; - m1 = m[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - m0 = m1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - if ( m0[ i0 ] === 0 ) { - y0[ i0 ] = fcn( x0[ i0 ] ); - } - } - } - } -} - - -// EXPORTS // - -module.exports = mskunary3d; diff --git a/base/mskunary3d/package.json b/base/mskunary3d/package.json deleted file mode 100644 index b0d43f0e4..000000000 --- a/base/mskunary3d/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/mskunary3d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a three-dimensional nested input array according to elements in a three-dimensional nested mask array and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "unary", - "apply", - "foreach", - "map", - "transform", - "masked", - "mask", - "skip", - "skipped", - "missing", - "missing values", - "na" - ], - "__stdlib__": {} -} diff --git a/base/mskunary3d/test/test.js b/base/mskunary3d/test/test.js deleted file mode 100644 index f188e6aba..000000000 --- a/base/mskunary3d/test/test.js +++ /dev/null @@ -1,210 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros3d = require( './../../../base/zeros3d' ); -var mskunary3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskunary3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - m = [ - [ - [ 0, 1 ], - [ 0, 0 ] - ], - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ]; - - expected = [ - [ - [ 1.0, 0.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 0.0 ], - [ 3.0, 4.0 ] - ] - ]; - - y = zeros3d( shape ); - mskunary3d( [ x, m, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - m = [ - [ - [ 1, 0 ], - [ 1, 0 ] - ] - ]; - - expected = [ - [ - [ 0.0, 2.0 ], - [ 0.0, 4.0 ] - ] - ]; - - y = zeros3d( shape ); - mskunary3d( [ x, m, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - m = [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - mskunary3d( [ x, m, y ], [ 0, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - m = [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - mskunary3d( [ x, m, y ], [ 1, 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - m = [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - mskunary3d( [ x, m, y ], [ 1, 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/mskunary4d/README.md b/base/mskunary4d/README.md deleted file mode 100644 index 5ab9cc0fc..000000000 --- a/base/mskunary4d/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# mskunary4d - -> Apply a unary callback to elements in a four-dimensional nested input array according to elements in a four-dimensional nested mask array and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var mskunary4d = require( '@stdlib/array/base/mskunary4d' ); -``` - -#### mskunary4d( arrays, shape, fcn ) - -Applies a unary callback to elements in a four-dimensional nested input array according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; -var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - -var shape = [ 1, 1, 2, 2 ]; - -// Compute the absolute values in-place: -mskunary4d( [ x, mask, x ], shape, abs ); -// x => [ [ [ [ 1.0, -2.0 ], [ 3.0, 4.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array, an input nested mask array, and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. -- An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var mskunary4d = require( '@stdlib/array/base/mskunary4d' ); - -var shape = [ 2, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var mask = filled4dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var y = zeros4d( shape ); -console.log( y ); - -mskunary4d( [ x, mask, y ], shape, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskunary4d/benchmark/benchmark.js b/base/mskunary4d/benchmark/benchmark.js deleted file mode 100644 index 3792bc11f..000000000 --- a/base/mskunary4d/benchmark/benchmark.js +++ /dev/null @@ -1,125 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var mskunary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var m; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - m = filled4dBy( shape, bernoulli( 0.5 ) ); - y = zeros4d( shape ); - - arrays = [ x, m, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - mskunary4d( arrays, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 2 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 2 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/mskunary4d/docs/repl.txt b/base/mskunary4d/docs/repl.txt deleted file mode 100644 index 6ec4e5525..000000000 --- a/base/mskunary4d/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a unary callback to elements in a four-dimensional nested input - array according to elements in a four-dimensional nested mask array and - assigns results to elements in a four-dimensional nested output array. - - An element in an input array is "masked" if the corresponding element in the - mask array is non-zero. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array, an input nested - mask array, and one output nested array. - - shape: Array - Array shape. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var m = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > {{alias}}( [ x, m, y ], shape, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ [ [ 1.0, 0.0 ], [ 3.0, 4.0 ] ] ] ] - - See Also - -------- - diff --git a/base/mskunary4d/docs/types/index.d.ts b/base/mskunary4d/docs/types/index.d.ts deleted file mode 100644 index 031306e46..000000000 --- a/base/mskunary4d/docs/types/index.d.ts +++ /dev/null @@ -1,71 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Applies a unary callback to elements in a four-dimensional nested input array according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. -* -* @param arrays - array containing one input nested array, an input nested mask array, and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; -* -* mskunary4d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -declare function mskunary4d( arrays: [ Array4D, Array4D, Array4D ], shape: Shape4D, fcn: Unary ): void; - - -// EXPORTS // - -export = mskunary4d; diff --git a/base/mskunary4d/docs/types/test.ts b/base/mskunary4d/docs/types/test.ts deleted file mode 100644 index 5f427ac7a..000000000 --- a/base/mskunary4d/docs/types/test.ts +++ /dev/null @@ -1,95 +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. -*/ - -import mskunary4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const m = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - mskunary4d( [ x, m, y ], [ 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - mskunary4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const m = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - mskunary4d( [ x, m, y ], 'abc', fcn ); // $ExpectError - mskunary4d( [ x, m, y ], 3.14, fcn ); // $ExpectError - mskunary4d( [ x, m, y ], true, fcn ); // $ExpectError - mskunary4d( [ x, m, y ], false, fcn ); // $ExpectError - mskunary4d( [ x, m, y ], null, fcn ); // $ExpectError - mskunary4d( [ x, m, y ], [ '1' ], fcn ); // $ExpectError - mskunary4d( [ x, m, y ], {}, fcn ); // $ExpectError - mskunary4d( [ x, m, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const m = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - mskunary4d( [ x, m, y ], [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - mskunary4d( [ x, m, y ], [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - mskunary4d( [ x, m, y ], [ 1, 1, 2, 2 ], true ); // $ExpectError - mskunary4d( [ x, m, y ], [ 1, 1, 2, 2 ], false ); // $ExpectError - mskunary4d( [ x, m, y ], [ 1, 1, 2, 2 ], null ); // $ExpectError - mskunary4d( [ x, m, y ], [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - mskunary4d( [ x, m, y ], [ 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const m = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - mskunary4d(); // $ExpectError - mskunary4d( [ x, m, y ] ); // $ExpectError - mskunary4d( [ x, m, y ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/mskunary4d/examples/index.js b/base/mskunary4d/examples/index.js deleted file mode 100644 index 3eefefaa9..000000000 --- a/base/mskunary4d/examples/index.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var mskunary4d = require( './../lib' ); - -var shape = [ 2, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var mask = filled4dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var y = zeros4d( shape ); -console.log( y ); - -mskunary4d( [ x, mask, y ], shape, abs ); -console.log( y ); diff --git a/base/mskunary4d/lib/index.js b/base/mskunary4d/lib/index.js deleted file mode 100644 index 19e50b608..000000000 --- a/base/mskunary4d/lib/index.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -/** -* Apply a unary callback to elements in a four-dimensional nested input array according to elements in a four-dimensional nested mask array and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/mskunary4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var mskunary4d = require( '@stdlib/array/base/mskunary4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; -* -* mskunary4d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskunary4d/lib/main.js b/base/mskunary4d/lib/main.js deleted file mode 100644 index 057b1fc92..000000000 --- a/base/mskunary4d/lib/main.js +++ /dev/null @@ -1,112 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a unary callback to elements in a four-dimensional nested input array according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ]; -* -* mskunary4d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function mskunary4d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var x1; - var x2; - var y0; - var y1; - var y2; - var m0; - var m1; - var m2; - var x; - var y; - var m; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 2 ]; - m = arrays[ 1 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - m2 = m[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - m1 = m2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - m0 = m1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - if ( m0[ i0 ] === 0 ) { - y0[ i0 ] = fcn( x0[ i0 ] ); - } - } - } - } - } -} - - -// EXPORTS // - -module.exports = mskunary4d; diff --git a/base/mskunary4d/package.json b/base/mskunary4d/package.json deleted file mode 100644 index b7b671b3d..000000000 --- a/base/mskunary4d/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/mskunary4d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a four-dimensional nested input array according to elements in a four-dimensional nested mask array and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "unary", - "apply", - "foreach", - "map", - "transform", - "masked", - "mask", - "skip", - "skipped", - "missing", - "missing values", - "na" - ], - "__stdlib__": {} -} diff --git a/base/mskunary4d/test/test.js b/base/mskunary4d/test/test.js deleted file mode 100644 index e85e96365..000000000 --- a/base/mskunary4d/test/test.js +++ /dev/null @@ -1,277 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var zeros4d = require( './../../../base/zeros4d' ); -var mskunary4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskunary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 2, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - m = [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ], - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 0.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 0.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - mskunary4d( [ x, m, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - m = [ - [ - [ - [ 1, 0 ], - [ 1, 0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 0.0, 2.0 ], - [ 0.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - mskunary4d( [ x, m, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - m = [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - mskunary4d( [ x, m, y ], [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - m = [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - mskunary4d( [ x, m, y ], [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - m = [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - mskunary4d( [ x, m, y ], [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - m = [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - mskunary4d( [ x, m, y ], [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/mskunary5d/README.md b/base/mskunary5d/README.md deleted file mode 100644 index f84ca9a42..000000000 --- a/base/mskunary5d/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# mskunary5d - -> Apply a unary callback to elements in a five-dimensional nested input array according to elements in a five-dimensional nested mask array and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var mskunary5d = require( '@stdlib/array/base/mskunary5d' ); -``` - -#### mskunary5d( arrays, shape, fcn ) - -Applies a unary callback to elements in a five-dimensional nested input array according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; -var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - -var shape = [ 1, 1, 1, 2, 2 ]; - -// Compute the absolute values in-place: -mskunary5d( [ x, mask, x ], shape, abs ); -// x => [ [ [ [ [ 1.0, -2.0 ], [ 3.0, 4.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array, an input nested mask array, and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. -- An element in an input array is "masked" if the corresponding element in the mask array is non-zero. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var mskunary5d = require( '@stdlib/array/base/mskunary5d' ); - -var shape = [ 1, 2, 2, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var mask = filled5dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var y = zeros5d( shape ); -console.log( y ); - -mskunary5d( [ x, mask, y ], shape, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/mskunary5d/benchmark/benchmark.js b/base/mskunary5d/benchmark/benchmark.js deleted file mode 100644 index 015bf81dd..000000000 --- a/base/mskunary5d/benchmark/benchmark.js +++ /dev/null @@ -1,128 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var mskunary5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var m; - var y; - - x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - m = filled5dBy( shape, bernoulli( 0.5 ) ); - y = zeros5d( shape ); - - arrays = [ x, m, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - mskunary5d( arrays, shape, identity ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 2 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 2 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/mskunary5d/docs/repl.txt b/base/mskunary5d/docs/repl.txt deleted file mode 100644 index 2f50bfc9e..000000000 --- a/base/mskunary5d/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a unary callback to elements in a five-dimensional nested input - array according to elements in a five-dimensional nested mask array and - assigns results to elements in a five-dimensional nested output array. - - An element in an input array is "masked" if the corresponding element in the - mask array is non-zero. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array, an input nested - mask array, and one output nested array. - - shape: Array - Array shape. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; - > var m = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - > var y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shape = [ 1, 1, 1, 2, 2 ]; - > {{alias}}( [ x, m, y ], shape, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ [ [ [ 1.0, 0.0 ], [ 3.0, 4.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/mskunary5d/docs/types/index.d.ts b/base/mskunary5d/docs/types/index.d.ts deleted file mode 100644 index ef1e48f39..000000000 --- a/base/mskunary5d/docs/types/index.d.ts +++ /dev/null @@ -1,71 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Applies a unary callback to elements in a five-dimensional nested input array according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* - An element in an input array is "masked" if the corresponding element in the mask array is non-zero. -* -* @param arrays - array containing one input nested array, an input nested mask array, and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; -* -* mskunary5d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ] ] -*/ -declare function mskunary5d( arrays: [ Array5D, Array5D, Array5D ], shape: Shape5D, fcn: Unary ): void; - - -// EXPORTS // - -export = mskunary5d; diff --git a/base/mskunary5d/docs/types/test.ts b/base/mskunary5d/docs/types/test.ts deleted file mode 100644 index 5649cefde..000000000 --- a/base/mskunary5d/docs/types/test.ts +++ /dev/null @@ -1,95 +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. -*/ - -import mskunary5d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const m = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - mskunary5d( [ x, m, y ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - mskunary5d( 'abc', [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary5d( 3.14, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary5d( true, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary5d( false, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary5d( null, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary5d( [ '1' ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary5d( {}, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - mskunary5d( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const m = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - mskunary5d( [ x, m, y ], 'abc', fcn ); // $ExpectError - mskunary5d( [ x, m, y ], 3.14, fcn ); // $ExpectError - mskunary5d( [ x, m, y ], true, fcn ); // $ExpectError - mskunary5d( [ x, m, y ], false, fcn ); // $ExpectError - mskunary5d( [ x, m, y ], null, fcn ); // $ExpectError - mskunary5d( [ x, m, y ], [ '1' ], fcn ); // $ExpectError - mskunary5d( [ x, m, y ], {}, fcn ); // $ExpectError - mskunary5d( [ x, m, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const m = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - mskunary5d( [ x, m, y ], [ 1, 1, 1, 2, 2 ], 'abc' ); // $ExpectError - mskunary5d( [ x, m, y ], [ 1, 1, 1, 2, 2 ], 3.14 ); // $ExpectError - mskunary5d( [ x, m, y ], [ 1, 1, 1, 2, 2 ], true ); // $ExpectError - mskunary5d( [ x, m, y ], [ 1, 1, 1, 2, 2 ], false ); // $ExpectError - mskunary5d( [ x, m, y ], [ 1, 1, 1, 2, 2 ], null ); // $ExpectError - mskunary5d( [ x, m, y ], [ 1, 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - mskunary5d( [ x, m, y ], [ 1, 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const m = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - mskunary5d(); // $ExpectError - mskunary5d( [ x, m, y ] ); // $ExpectError - mskunary5d( [ x, m, y ], [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/mskunary5d/examples/index.js b/base/mskunary5d/examples/index.js deleted file mode 100644 index 108e527fe..000000000 --- a/base/mskunary5d/examples/index.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var mskunary5d = require( './../lib' ); - -var shape = [ 1, 2, 1, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var mask = filled5dBy( shape, bernoulli( 0.5 ) ); -console.log( mask ); - -var y = zeros5d( shape ); -console.log( y ); - -mskunary5d( [ x, mask, y ], shape, abs ); -console.log( y ); diff --git a/base/mskunary5d/lib/index.js b/base/mskunary5d/lib/index.js deleted file mode 100644 index 1d7dc2ced..000000000 --- a/base/mskunary5d/lib/index.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -/** -* Apply a unary callback to elements in a five-dimensional nested input array according to elements in a five-dimensional nested mask array and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/mskunary5d -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var mskunary5d = require( '@stdlib/array/base/mskunary5d' ); - -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; -* -* mskunary5d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/mskunary5d/lib/main.js b/base/mskunary5d/lib/main.js deleted file mode 100644 index 104b892d9..000000000 --- a/base/mskunary5d/lib/main.js +++ /dev/null @@ -1,125 +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. -*/ - -/* eslint-disable max-depth */ - -'use strict'; - -// MAIN // - -/** -* Applies a unary callback to elements in a five-dimensional nested input array according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); - -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ]; -* -* mskunary5d( [ x, mask, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ] ] -*/ -function mskunary5d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var x0; - var x1; - var x2; - var x3; - var y0; - var y1; - var y2; - var y3; - var m0; - var m1; - var m2; - var m3; - var x; - var y; - var m; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 2 ]; - m = arrays[ 1 ]; - for ( i4 = 0; i4 < S4; i4++ ) { - x3 = x[ i4 ]; - y3 = y[ i4 ]; - m3 = m[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x3[ i3 ]; - y2 = y3[ i3 ]; - m2 = m3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - m1 = m2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - m0 = m1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - if ( m0[ i0 ] === 0 ) { - y0[ i0 ] = fcn( x0[ i0 ] ); - } - } - } - } - } - } -} - - -// EXPORTS // - -module.exports = mskunary5d; diff --git a/base/mskunary5d/package.json b/base/mskunary5d/package.json deleted file mode 100644 index 6f4355669..000000000 --- a/base/mskunary5d/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/mskunary5d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a five-dimensional nested input array according to elements in a five-dimensional nested mask array and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "unary", - "apply", - "foreach", - "map", - "transform", - "masked", - "mask", - "skip", - "skipped", - "missing", - "missing values", - "na" - ], - "__stdlib__": {} -} diff --git a/base/mskunary5d/test/test.js b/base/mskunary5d/test/test.js deleted file mode 100644 index 26049d94f..000000000 --- a/base/mskunary5d/test/test.js +++ /dev/null @@ -1,407 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var zeros5d = require( './../../../base/zeros5d' ); -var mskunary5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskunary5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -4, -4 ], [ -1, -6 ] - ], - [ - [ -4, -4 ], [ -1, -6 ] - ] - ], - [ - [ - [ -4, -4 ], [ -1, -6 ] - ], - [ - [ -4, -4 ], [ -1, -6 ] - ] - ] - ], - [ - [ - [ - [ -4, -4 ], [ -1, -6 ] - ], - [ - [ -4, -4 ], [ -1, -6 ] - ] - ], - [ - [ - [ -4, -4 ], [ -1, -6 ] - ], - [ - [ -4, -4 ], [ -1, -6 ] - ] - ] - ] - ]; - m = [ - [ - [ - [ - [ 1, 0 ], [ 0, 0 ] - ], - [ - [ 0, 1 ], [ 0, 0 ] - ] - ], - [ - [ - [ 0, 0 ], [ 0, 0 ] - ], - [ - [ 0, 1 ], [ 1, 0 ] - ] - ] - ], - [ - [ - [ - [ 0, 0 ], [ 0, 0 ] - ], - [ - [ 0, 1 ], [ 0, 0 ] - ] - ], - [ - [ - [ 0, 0 ], [ 1, 0 ] - ], - [ - [ 0, 1 ], [ 1, 0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 0.0, 4.0 ], [ 1.0, 6.0 ] - ], - [ - [ 4.0, 0.0 ], [ 1.0, 6.0 ] - ] - ], - [ - [ - [ 4.0, 4.0 ], [ 1.0, 6.0 ] - ], - [ - [ 4.0, 0.0 ], [ 0.0, 6.0 ] - ] - ] - ], - [ - [ - [ - [ 4.0, 4.0 ], [ 1.0, 6.0 ] - ], - [ - [ 4.0, 0.0 ], [ 1.0, 6.0 ] - ] - ], - [ - [ - [ 4.0, 4.0 ], [ 0.0, 6.0 ] - ], - [ - [ 4.0, 0.0 ], [ 0.0, 6.0 ] - ] - ] - ] - ]; - - y = zeros5d( shape ); - mskunary5d( [ x, m, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - expected = [ - [ - [ - [ - [ 1.0, 0.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = zeros5d( shape ); - mskunary5d( [ x, m, y ], shape, abs ); - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - y = zeros5d( shape ); - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - mskunary5d( [ x, m, y ], [ 0, 1, 1, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - y = zeros5d( shape ); - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - mskunary5d( [ x, m, y ], [ 1, 0, 1, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = zeros5d( shape ); - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - mskunary5d( [ x, m, y ], [ 1, 1, 0, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - var m; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = zeros5d( shape ); - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - mskunary5d( [ x, m, y ], [ 1, 1, 2, 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - var m; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = zeros5d( shape ); - m = [ - [ - [ - [ - [ 0, 1 ], - [ 0, 0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - mskunary5d( [ x, m, y ], [ 1, 1, 2, 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/n-cartesian-product/README.md b/base/n-cartesian-product/README.md deleted file mode 100644 index 869271027..000000000 --- a/base/n-cartesian-product/README.md +++ /dev/null @@ -1,103 +0,0 @@ - - -# nCartesianProduct - -> Return the n-fold [Cartesian product][cartesian-product]. - -
- -## Usage - -```javascript -var nCartesianProduct = require( '@stdlib/array/base/n-cartesian-product' ); -``` - -#### nCartesianProduct( x1, x2\[, ...xN] ) - -Returns the n-fold [Cartesian product][cartesian-product]. - -```javascript -var x1 = [ 1, 2, 3 ]; -var x2 = [ 4, 5 ]; - -var out = nCartesianProduct( x1, x2 ); -// returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -``` - -If provided one or more empty arrays, the function returns an empty array. - -```javascript -var x1 = [ 1, 2, 3, 4 ]; -var x2 = []; - -var out = nCartesianProduct( x1, x2 ); -// returns [] -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var linspace = require( '@stdlib/array/base/linspace' ); -var nCartesianProduct = require( '@stdlib/array/base/n-cartesian-product' ); - -var x1 = linspace( 0, 5, 6 ); -var x2 = linspace( 10, 15, 6 ); -var x3 = linspace( 20, 25, 6 ); - -var out = nCartesianProduct( x1, x2, x3 ); -// returns [ [ 0, 10, 20 ], [ 0, 10, 21 ], ... ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/n-cartesian-product/benchmark/benchmark.js b/base/n-cartesian-product/benchmark/benchmark.js deleted file mode 100644 index 69abfb50b..000000000 --- a/base/n-cartesian-product/benchmark/benchmark.js +++ /dev/null @@ -1,244 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var nCartesianProduct = require( './../lib' ); - - -// MAIN // - -bench( pkg+':narrays=2,len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nCartesianProduct( x, x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':narrays=3,len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 10 ); - y = [ 1 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nCartesianProduct( x, x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':narrays=4,len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 10 ); - y = [ 1 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nCartesianProduct( x, x, y, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':narrays=5,len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 10 ); - y = [ 1 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nCartesianProduct( x, x, y, y, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':narrays=6,len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 10 ); - y = [ 1 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nCartesianProduct( x, x, y, y, y, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':narrays=7,len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 10 ); - y = [ 1 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nCartesianProduct( x, x, y, y, y, y, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':narrays=8,len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 10 ); - y = [ 1 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nCartesianProduct( x, x, y, y, y, y, y, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':narrays=9,len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 10 ); - y = [ 1 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nCartesianProduct( x, x, y, y, y, y, y, y, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':narrays=10,len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 10 ); - y = [ 1 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nCartesianProduct( x, x, y, y, y, y, y, y, y, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/n-cartesian-product/benchmark/benchmark.length.js b/base/n-cartesian-product/benchmark/benchmark.length.js deleted file mode 100644 index 89c530ca7..000000000 --- a/base/n-cartesian-product/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var nCartesianProduct = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = filledBy( len/2, discreteUniform( 0, 3 ) ); - var y = [ 1, 2 ]; - var z = [ 1 ]; - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nCartesianProduct( x, y, z ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':narrays=3,len='+len, f ); - } -} - -main(); diff --git a/base/n-cartesian-product/docs/repl.txt b/base/n-cartesian-product/docs/repl.txt deleted file mode 100644 index 2fecd0d46..000000000 --- a/base/n-cartesian-product/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( x1, x2[, ...xN] ) - Returns the n-fold Cartesian product. - - If provided one or more empty arrays, the function returns an empty array. - - Parameters - ---------- - x1: ArrayLikeObject - First input array. - - x2: ArrayLikeObject - Second input array. - - xN: ...ArrayLikeObject (optional) - Additional input arrays. - - Returns - ------- - out: Array - Cartesian product. - - Examples - -------- - > var x1 = [ 1, 2 ]; - > var x2 = [ 3, 4 ]; - > var out = {{alias}}( x1, x2 ) - [ [ 1, 3 ], [ 1, 4 ], [ 2, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/base/n-cartesian-product/docs/types/index.d.ts b/base/n-cartesian-product/docs/types/index.d.ts deleted file mode 100644 index 46fbe5a03..000000000 --- a/base/n-cartesian-product/docs/types/index.d.ts +++ /dev/null @@ -1,91 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/array'; - -/** -* Returns the n-fold Cartesian product. -* -* ## Notes -* -* - If provided one or more empty arrays, the function returns an empty array. -* -* @param x1 - first input array -* @param x2 - second input array -* @returns Cartesian product -* -* @example -* var x1 = [ 1, 2, 3 ]; -* var x2 = [ 4, 5 ]; -* -* var out = nCartesianProduct( x1, x2 ); -* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -*/ -declare function nCartesianProduct( x1: Collection, x2: Collection ): Array<[T, U]>; - -/** -* Returns the n-fold Cartesian product. -* -* ## Notes -* -* - If provided one or more empty arrays, the function returns an empty array. -* -* @param x1 - first input array -* @param x2 - second input array -* @param x3 - third input array -* @returns Cartesian product -* -* @example -* var x1 = [ 1, 2, 3 ]; -* var x2 = [ 4, 5 ]; -* var x3 = [ 6 ]; -* -* var out = nCartesianProduct( x1, x2, x3 ); -* // returns [ [ 1, 4, 6 ], [ 1, 5, 6 ], [ 2, 4, 6 ], [ 2, 5, 6 ], [ 3, 4, 6 ], [ 3, 5, 6 ] ] -*/ -declare function nCartesianProduct( x1: Collection, x2: Collection, x3: Collection ): Array<[T, U, V]>; - -/** -* Returns the n-fold Cartesian product. -* -* ## Notes -* -* - If provided one or more empty arrays, the function returns an empty array. -* -* @param x1 - first input array -* @param x2 - second input array -* @param xN - additional input arrays -* @returns Cartesian product -* -* @example -* var x1 = [ 1, 2, 3 ]; -* var x2 = [ 4, 5 ]; -* -* var out = nCartesianProduct( x1, x2 ); -* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -*/ -declare function nCartesianProduct( x1: Collection, x2: Collection, ...xN: Array> ): Array>; - - -// EXPORTS // - -export = nCartesianProduct; diff --git a/base/n-cartesian-product/docs/types/test.ts b/base/n-cartesian-product/docs/types/test.ts deleted file mode 100644 index 8b2268d84..000000000 --- a/base/n-cartesian-product/docs/types/test.ts +++ /dev/null @@ -1,85 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 nCartesianProduct = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - nCartesianProduct( [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType [number, number][] - nCartesianProduct( [ 1, 2, 3, 4 ], [ 1, 3 ], [ 6 ] ); // $ExpectType [number, number, number][] - nCartesianProduct( [ 1, 2, 3, 4 ], [ 1, 3 ], [ 6 ], [ 7 ] ); // $ExpectType number[][] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nCartesianProduct( 1, [ 1, 3 ] ); // $ExpectError - nCartesianProduct( true, [ 1, 3 ] ); // $ExpectError - nCartesianProduct( false, [ 1, 3 ] ); // $ExpectError - nCartesianProduct( null, [ 1, 3 ] ); // $ExpectError - nCartesianProduct( void 0, [ 1, 3 ] ); // $ExpectError - nCartesianProduct( {}, [ 1, 3 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nCartesianProduct( [], 1 ); // $ExpectError - nCartesianProduct( [], true ); // $ExpectError - nCartesianProduct( [], false ); // $ExpectError - nCartesianProduct( [], null ); // $ExpectError - nCartesianProduct( [], void 0 ); // $ExpectError - nCartesianProduct( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object... -{ - nCartesianProduct( [], [], 1 ); // $ExpectError - nCartesianProduct( [], [], true ); // $ExpectError - nCartesianProduct( [], [], false ); // $ExpectError - nCartesianProduct( [], [], null ); // $ExpectError - nCartesianProduct( [], [], void 0 ); // $ExpectError - nCartesianProduct( [], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object... -{ - nCartesianProduct( [], [], [], 1 ); // $ExpectError - nCartesianProduct( [], [], [], true ); // $ExpectError - nCartesianProduct( [], [], [], false ); // $ExpectError - nCartesianProduct( [], [], [], null ); // $ExpectError - nCartesianProduct( [], [], [], void 0 ); // $ExpectError - nCartesianProduct( [], [], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not an array-like object... -{ - nCartesianProduct( [], [], [], [], 1 ); // $ExpectError - nCartesianProduct( [], [], [], [], true ); // $ExpectError - nCartesianProduct( [], [], [], [], false ); // $ExpectError - nCartesianProduct( [], [], [], [], null ); // $ExpectError - nCartesianProduct( [], [], [], [], void 0 ); // $ExpectError - nCartesianProduct( [], [], [], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nCartesianProduct(); // $ExpectError - nCartesianProduct( [] ); // $ExpectError -} diff --git a/base/n-cartesian-product/examples/index.js b/base/n-cartesian-product/examples/index.js deleted file mode 100644 index f93c2dd30..000000000 --- a/base/n-cartesian-product/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 linspace = require( './../../../base/linspace' ); -var nCartesianProduct = require( './../lib' ); - -var x1 = linspace( 0, 5, 6 ); -var x2 = linspace( 10, 15, 6 ); -var x3 = linspace( 20, 25, 6 ); - -var out = nCartesianProduct( x1, x2, x3 ); -console.log( out ); -// => [ [ 0, 10, 20 ], [ 0, 10, 21 ], ... ] diff --git a/base/n-cartesian-product/lib/index.js b/base/n-cartesian-product/lib/index.js deleted file mode 100644 index 4032709d5..000000000 --- a/base/n-cartesian-product/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return the n-fold Cartesian product. -* -* @module @stdlib/array/base/n-cartesian-product -* -* @example -* var nCartesianProduct = require( '@stdlib/array/base/n-cartesian-product' ); -* -* var x1 = [ 1, 2, 3 ]; -* var x2 = [ 4, 5 ]; -* -* var out = nCartesianProduct( x1, x2 ); -* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -*/ - -// MAIN // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/n-cartesian-product/lib/main.js b/base/n-cartesian-product/lib/main.js deleted file mode 100644 index 98e86c1de..000000000 --- a/base/n-cartesian-product/lib/main.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns the n-fold Cartesian product. -* -* ## Notes -* -* - The main insight of this implementation is that the n-fold Cartesian product can be presented as an n-dimensional array stored in row-major order. As such, we can -* -* - Compute the total number of tuples, which is simply the product of the size of each provided array (set). For n-dimensional arrays, this is the equivalent of computing the product of array dimensions to determine the total number of elements. -* - Initialize an array for storing indices for indexing into each provided array. For n-dimensional arrays, the index array is equivalent to an array of subscripts for indexing into each dimension. -* - For the outermost loop, treat the loop index as a linear index into an n-dimensional array and resolve the corresponding subscripts. -* - Continue iterating until all tuples have been generated. -* -* @param {ArrayLikeObject} x1 - first input array -* @param {ArrayLikeObject} x2 - second input array -* @param {ArrayLikeObject} [...args] - additional input arrays -* @returns {Array} list of ordered tuples comprising the n-fold Cartesian product -* -* @example -* var x1 = [ 1, 2, 3 ]; -* var x2 = [ 4, 5 ]; -* -* var out = nCartesianProduct( x1, x2 ); -* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -*/ -function nCartesianProduct( x1, x2 ) { - var nargs; - var dims; - var arr; - var out; - var tmp; - var arg; - var idx; - var N; - var s; - var i; - var j; - var k; - - nargs = arguments.length; - - // Initialize the list of arrays: - arr = [ x1, x2 ]; - - // Initialize the list of array dimensions (equivalent to ndarray shape): - dims = [ x1.length, x2.length ]; - - // Initialize a list of indices for indexing into each array (equivalent to ndarray subscripts): - idx = [ 0, 0 ]; - - // Compute the total number of ordered tuples: - N = dims[ 0 ] * dims[ 1 ]; - - // Update loop variables for any additional arrays... - for ( i = 2; i < nargs; i++ ) { - arg = arguments[ i ]; - arr.push( arg ); - dims.push( arg.length ); - idx.push( 0 ); - N *= dims[ i ]; - } - // Compute the n-fold Cartesian product... - out = []; - for ( i = 0; i < N; i++ ) { - // Resolve a linear index to array indices (logic is equivalent to what is found in ndarray/base/ind2sub for an ndarray stored in row-major order; see https://github.com/stdlib-js/stdlib/blob/215ca5355f3404f15996fd0ced58a98e46f22be6/lib/node_modules/%40stdlib/ndarray/base/ind2sub/lib/assign.js)... - k = i; - for ( j = nargs-1; j >= 0; j-- ) { - s = k % dims[ j ]; - k -= s; - k /= dims[ j ]; - idx[ j ] = s; - } - // Generate the next ordered tuple... - tmp = []; - for ( j = 0; j < nargs; j++ ) { - tmp.push( arr[ j ][ idx[ j ] ] ); - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = nCartesianProduct; diff --git a/base/n-cartesian-product/package.json b/base/n-cartesian-product/package.json deleted file mode 100644 index fd1e3ab5e..000000000 --- a/base/n-cartesian-product/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/n-cartesian-product", - "version": "0.0.0", - "description": "Return the n-fold Cartesian product.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "cartesian", - "sets", - "math", - "mathematics", - "n-fold", - "n-ary", - "ordered" - ] -} diff --git a/base/n-cartesian-product/test/test.js b/base/n-cartesian-product/test/test.js deleted file mode 100644 index 3a2a89d4f..000000000 --- a/base/n-cartesian-product/test/test.js +++ /dev/null @@ -1,152 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 nCartesianProduct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nCartesianProduct, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the Cartesian product (2 arrays)', function test( t ) { - var expected; - var actual; - - actual = nCartesianProduct( [ 1, 2 ], [ 3, 4 ] ); - expected = [ [ 1, 3 ], [ 1, 4 ], [ 2, 3 ], [ 2, 4 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = nCartesianProduct( [ 1 ], [ 3, 4 ] ); - expected = [ [ 1, 3 ], [ 1, 4 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = nCartesianProduct( [ 1, 2 ], [ 3 ] ); - expected = [ [ 1, 3 ], [ 2, 3 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = nCartesianProduct( [ 1, 2 ], [ 3, 4, 5 ] ); - expected = [ [ 1, 3 ], [ 1, 4 ], [ 1, 5 ], [ 2, 3 ], [ 2, 4 ], [ 2, 5 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the Cartesian product (3 arrays)', function test( t ) { - var expected; - var actual; - - actual = nCartesianProduct( [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ); - expected = [ - [ 1, 3, 5 ], - [ 1, 3, 6 ], - [ 1, 4, 5 ], - [ 1, 4, 6 ], - [ 2, 3, 5 ], - [ 2, 3, 6 ], - [ 2, 4, 5 ], - [ 2, 4, 6 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = nCartesianProduct( [ 1 ], [ 3, 4 ], [ 5, 6 ] ); - expected = [ - [ 1, 3, 5 ], - [ 1, 3, 6 ], - [ 1, 4, 5 ], - [ 1, 4, 6 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = nCartesianProduct( [ 1, 2 ], [ 3 ], [ 5, 6 ] ); - expected = [ - [ 1, 3, 5 ], - [ 1, 3, 6 ], - [ 2, 3, 5 ], - [ 2, 3, 6 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = nCartesianProduct( [ 1, 2 ], [ 3, 4 ], [ 6 ] ); - expected = [ - [ 1, 3, 6 ], - [ 1, 4, 6 ], - [ 2, 3, 6 ], - [ 2, 4, 6 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = nCartesianProduct( [ 1, 2, 3, 4 ], [ 5 ], [ 6, 7 ] ); - expected = [ - [ 1, 5, 6 ], - [ 1, 5, 7 ], - [ 2, 5, 6 ], - [ 2, 5, 7 ], - [ 3, 5, 6 ], - [ 3, 5, 7 ], - [ 4, 5, 6 ], - [ 4, 5, 7 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided one or more empty arrays', function test( t ) { - var actual; - - actual = nCartesianProduct( [], [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = nCartesianProduct( [ 1, 2 ], [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = nCartesianProduct( [], [ 3, 4 ] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = nCartesianProduct( [], [], [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = nCartesianProduct( [ 1, 2 ], [], [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = nCartesianProduct( [], [ 3, 4 ], [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = nCartesianProduct( [], [], [ 5, 6 ] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = nCartesianProduct( [ 1, 2 ], [ 3, 4 ], [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = nCartesianProduct( [ 1, 2 ], [], [ 5, 6 ] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = nCartesianProduct( [], [ 3, 4 ], [ 5, 6 ] ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); diff --git a/base/nested2objects/README.md b/base/nested2objects/README.md deleted file mode 100644 index d5046f80a..000000000 --- a/base/nested2objects/README.md +++ /dev/null @@ -1,100 +0,0 @@ - - -# nested2objects - -> Convert nested arrays to objects. - -
- -## Usage - -```javascript -var nested2objects = require( '@stdlib/array/base/nested2objects' ); -``` - -#### nested2objects( arr, fields ) - -Converts each nested array to an object. - -```javascript -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var fields = [ 'x', 'y' ]; - -var out = nested2objects( x, fields ); -// returns [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ] -``` - -The function supports the following parameters: - -- **arr**: input array containing nested arrays. -- **fields**: list of field names. - -
- - - -
- -- The function assumes that all nested arrays have the same length. -- The number of provided array labels should equal the length of each nested array. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var nested2objects = require( '@stdlib/array/base/nested2objects' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2objects( x, fields ); -// returns [...] -``` - -
- - - - - - - - - - - - - - diff --git a/base/nested2objects/benchmark/benchmark.js b/base/nested2objects/benchmark/benchmark.js deleted file mode 100644 index fca1c1220..000000000 --- a/base/nested2objects/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled2d = require( './../../../base/filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2objects = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2objects( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/nested2objects/docs/repl.txt b/base/nested2objects/docs/repl.txt deleted file mode 100644 index efe2bd1df..000000000 --- a/base/nested2objects/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to an object. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ) - [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ] - - See Also - -------- - diff --git a/base/nested2objects/docs/types/index.d.ts b/base/nested2objects/docs/types/index.d.ts deleted file mode 100644 index 3e01b3f39..000000000 --- a/base/nested2objects/docs/types/index.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to an object. -* -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2objects( x, fields ); -* // returns [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ] -*/ -declare function nested2objects( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2objects; diff --git a/base/nested2objects/docs/types/test.ts b/base/nested2objects/docs/types/test.ts deleted file mode 100644 index f3e91e826..000000000 --- a/base/nested2objects/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2objects = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2objects( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2objects( 1, [ 'x', 'y' ] ); // $ExpectError - nested2objects( true, [ 'x', 'y' ] ); // $ExpectError - nested2objects( false, [ 'x', 'y' ] ); // $ExpectError - nested2objects( null, [ 'x', 'y' ] ); // $ExpectError - nested2objects( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2objects( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2objects( [], 1 ); // $ExpectError - nested2objects( [], true ); // $ExpectError - nested2objects( [], false ); // $ExpectError - nested2objects( [], null ); // $ExpectError - nested2objects( [], void 0 ); // $ExpectError - nested2objects( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2objects(); // $ExpectError - nested2objects( [] ); // $ExpectError - nested2objects( [], [], [] ); // $ExpectError -} diff --git a/base/nested2objects/examples/index.js b/base/nested2objects/examples/index.js deleted file mode 100644 index 227648fe6..000000000 --- a/base/nested2objects/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var nested2objects = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2objects( x, fields ); -console.log( out ); -// => [...] diff --git a/base/nested2objects/lib/index.js b/base/nested2objects/lib/index.js deleted file mode 100644 index 7f1a67191..000000000 --- a/base/nested2objects/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to objects. -* -* @module @stdlib/array/base/nested2objects -* -* @example -* var nested2objects = require( '@stdlib/array/base/nested2objects' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2objects( x, fields ); -* // returns [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/nested2objects/lib/main.js b/base/nested2objects/lib/main.js deleted file mode 100644 index 35828e3a6..000000000 --- a/base/nested2objects/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); -var copy = require( './../../../base/copy' ); - - -// MAIN // - -/** -* Converts each nested array to an object. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2objects( x, fields ); -* // returns [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ] -*/ -function nested2objects( arr, fields ) { - var names; - var oget; - var get; - var out; - var obj; - var tmp; - var M; - var N; - var i; - var j; - - M = arr.length; - if ( M < 1 ) { - return []; - } - // Resolve the accessor for the outer array: - oget = resolveGetter( arr ); - - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Copy the list of fields to an indexed array to avoid repeated accessor calls: - names = copy( fields ); - - out = []; - for ( i = 0; i < M; i++ ) { - tmp = oget( arr, i ); - get = resolveGetter( tmp ); - obj = {}; - for ( j = 0; j < N; j++ ) { - obj[ names[ j ] ] = get( tmp, j ); - } - out.push( obj ); - } - return out; -} - - -// EXPORTS // - -module.exports = nested2objects; diff --git a/base/nested2objects/package.json b/base/nested2objects/package.json deleted file mode 100644 index c9828c4e7..000000000 --- a/base/nested2objects/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/nested2objects", - "version": "0.0.0", - "description": "Convert nested arrays to objects.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "nested", - "object", - "tidy" - ] -} diff --git a/base/nested2objects/test/test.js b/base/nested2objects/test/test.js deleted file mode 100644 index 94a2a1fe1..000000000 --- a/base/nested2objects/test/test.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var nested2objects = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2objects, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (index)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2objects( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2objects( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2objects( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2objects( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2objects( x, fields ); - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = toAccessorArray( [ toAccessorArray( [ 1, 2 ] ), toAccessorArray( [ 3, 4 ] ) ] ); // eslint-disable-line max-len - - actual = nested2objects( x, toAccessorArray( fields ) ); - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/nested2views/README.md b/base/nested2views/README.md deleted file mode 100644 index a00724450..000000000 --- a/base/nested2views/README.md +++ /dev/null @@ -1,123 +0,0 @@ - - -# nested2views - -> Convert nested arrays to composite views. - -
- -## Usage - -```javascript -var nested2views = require( '@stdlib/array/base/nested2views' ); -``` - -#### nested2views( arr, fields ) - -Converts each nested array to a composite view. - -```javascript -var x = [ [ 1, 2 ], [ 3, 4 ] ]; -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -// returns [ , ] - -var v0 = out[ 0 ].toJSON(); -// returns { 'x': 1, 'y': 2 } - -var v1 = out[ 1 ].toJSON(); -// returns { 'x': 3, 'y': 4 } - -// Mutate the first nested array: -x[ 0 ][ 0 ] = 5; - -v0 = out[ 0 ].toJSON(); -// returns { 'x': 5, 'y': 2 } - -// Set a view property: -out[ 1 ].y = 'beep'; - -v1 = out[ 1 ].toJSON(); -// returns { 'x': 3, 'y': 'beep' } - -var y = x.slice(); -// returns [ [ 5, 2 ], [ 3, 'beep' ] ] -``` - -The function supports the following parameters: - -- **arr**: input array. -- **fields**: list of field names. - -Each element in the returned array is a class instance having prototype properties corresponding to the list of field names. As demonstrated in the example above, to convert an element to a regular object, invoke an element's `toJSON` method. Note, however, that the object returned by an element's `toJSON` method no longer shares the same memory as the provided input array. - - - - - -
- -- The function assumes that all nested arrays have the same length. -- The number of provided array labels should equal the length of each nested array. -- Each view in the returned array shares the same memory as the corresponding element in the input array. Accordingly, mutation of either a nested array or a view will mutate the other. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var nested2views = require( '@stdlib/array/base/nested2views' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -// returns [...] -``` - -
- - - - - - - - - - - - - - diff --git a/base/nested2views/benchmark/benchmark.js b/base/nested2views/benchmark/benchmark.js deleted file mode 100644 index dd58bf30e..000000000 --- a/base/nested2views/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filled2d = require( './../../../base/filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/nested2views/docs/repl.txt b/base/nested2views/docs/repl.txt deleted file mode 100644 index 26f62b4a7..000000000 --- a/base/nested2views/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/base/nested2views/docs/types/index.d.ts b/base/nested2views/docs/types/index.d.ts deleted file mode 100644 index 0bc6408a1..000000000 --- a/base/nested2views/docs/types/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/base/nested2views/docs/types/test.ts b/base/nested2views/docs/types/test.ts deleted file mode 100644 index 0679a7d90..000000000 --- a/base/nested2views/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/base/nested2views/examples/index.js b/base/nested2views/examples/index.js deleted file mode 100644 index 0118d3225..000000000 --- a/base/nested2views/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/base/nested2views/lib/index.js b/base/nested2views/lib/index.js deleted file mode 100644 index c41485381..000000000 --- a/base/nested2views/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array/base/nested2views -* -* @example -* var nested2views = require( '@stdlib/array/base/nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/nested2views/lib/main.js b/base/nested2views/lib/main.js deleted file mode 100644 index 378a007f8..000000000 --- a/base/nested2views/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var accessors = require( './../../../base/accessors' ); -var copy = require( './../../../base/copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/base/nested2views/package.json b/base/nested2views/package.json deleted file mode 100644 index 743db7791..000000000 --- a/base/nested2views/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/nested2views", - "version": "0.0.0", - "description": "Convert nested arrays to composite views.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "nested", - "object", - "tidy" - ] -} diff --git a/base/nested2views/test/test.js b/base/nested2views/test/test.js deleted file mode 100644 index 6e4e2e82a..000000000 --- a/base/nested2views/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); diff --git a/base/none-by-right/README.md b/base/none-by-right/README.md deleted file mode 100644 index 375137769..000000000 --- a/base/none-by-right/README.md +++ /dev/null @@ -1,166 +0,0 @@ - - -# noneByRight - -> Test whether all elements in an array fail a test implemented by a predicate function, iterating from right to left. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var noneByRight = require( '@stdlib/array/base/none-by-right' ); -``` - -#### noneByRight( x, predicate\[, thisArg] ) - -Tests whether all elements in an array fail a test implemented by a `predicate` function, iterating from right to left. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 0, 0, 0, 0 ]; - -var bool = noneByRight( x, isPositive ); -// returns true -``` - -If a `predicate` function returns a truthy value, the function **immediately** returns `false`. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ -1, -2, 3, -4 ]; - -var bool = noneByRight( x, isPositive ); -// returns false -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( value ) { - this.count += 1; - return ( value < 0 ); -} - -var x = [ 1, 2, -3, 4 ]; - -var context = { - 'count': 0 -}; - -var bool = noneByRight( x, predicate, context ); -// returns false - -var cnt = context.count; -// returns 2 -``` - -
- - - - - -
- -## Notes - -- The function performs a linear scan and returns immediately upon encountering a truthy return value. Unlike [`Array.prototype.every`][mdn-array-every], when performing a linear scan, the function does **not** skip `undefined` elements. -- If provided an empty array, the function returns `true`. - -
- - - - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var noneByRight = require( '@stdlib/array/base/none-by-right' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = noneByRight( x, naryFunction( isPositiveInteger, 1 ) ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/none-by-right/benchmark/benchmark.length.js b/base/none-by-right/benchmark/benchmark.length.js deleted file mode 100644 index 939a00e8b..000000000 --- a/base/none-by-right/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var noneByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = noneByRight( x, isPositiveInteger ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/none-by-right/docs/repl.txt b/base/none-by-right/docs/repl.txt deleted file mode 100644 index 8e7f206fb..000000000 --- a/base/none-by-right/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Tests whether all elements in an array fail a test implemented by a - predicate function, iterating from right to left. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - The function performs a linear scan and returns immediately upon - encountering a truthy return value. - - If provided an empty array, the function returns `true`. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - bool: boolean - The function returns `true` if the predicate function returns a falsy - value for all elements; otherwise, the function returns `false`. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 0, 0 ]; - > var out = {{alias}}( x, f ) - true - - See Also - -------- - diff --git a/base/none-by-right/docs/types/index.d.ts b/base/none-by-right/docs/types/index.d.ts deleted file mode 100644 index 13f393d22..000000000 --- a/base/none-by-right/docs/types/index.d.ts +++ /dev/null @@ -1,97 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Tests whether all elements in an array fail a test implemented by a predicate function, iterating from right to left. -* -* ## Notes -* -* - The function immediately returns upon encountering a truthy return value. -* - If provided an empty collection, the function returns `true`. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns boolean indicating whether all elements fail a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 0 ]; -* -* var out = noneByRight( x, isPositive ); -* // returns true -*/ -declare function noneByRight( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - -// EXPORTS // - -export = noneByRight; diff --git a/base/none-by-right/docs/types/test.ts b/base/none-by-right/docs/types/test.ts deleted file mode 100644 index d404bd64a..000000000 --- a/base/none-by-right/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import noneByRight = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a boolean... -{ - noneByRight( [ 1, 2, 3 ], isPositive ); // $ExpectType boolean - noneByRight( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneByRight( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneByRight( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneByRight( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneByRight( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneByRight( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneByRight( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneByRight( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneByRight( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneByRight( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - - noneByRight( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType boolean - noneByRight( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneByRight( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneByRight( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneByRight( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneByRight( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneByRight( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneByRight( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneByRight( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneByRight( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneByRight( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - noneByRight( 2, isPositive ); // $ExpectError - noneByRight( false, isPositive ); // $ExpectError - noneByRight( true, isPositive ); // $ExpectError - noneByRight( {}, isPositive ); // $ExpectError - - noneByRight( 2, isPositive, {} ); // $ExpectError - noneByRight( false, isPositive, {} ); // $ExpectError - noneByRight( true, isPositive, {} ); // $ExpectError - noneByRight( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - noneByRight( [ 1, 2, 3 ], 'abc' ); // $ExpectError - noneByRight( [ 1, 2, 3 ], 2 ); // $ExpectError - noneByRight( [ 1, 2, 3 ], false ); // $ExpectError - noneByRight( [ 1, 2, 3 ], true ); // $ExpectError - noneByRight( [ 1, 2, 3 ], null ); // $ExpectError - noneByRight( [ 1, 2, 3 ], void 0 ); // $ExpectError - noneByRight( [ 1, 2, 3 ], {} ); // $ExpectError - noneByRight( [ 1, 2, 3 ], [] ); // $ExpectError - - noneByRight( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - noneByRight( [ 1, 2, 3 ], 2, {} ); // $ExpectError - noneByRight( [ 1, 2, 3 ], false, {} ); // $ExpectError - noneByRight( [ 1, 2, 3 ], true, {} ); // $ExpectError - noneByRight( [ 1, 2, 3 ], null, {} ); // $ExpectError - noneByRight( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - noneByRight( [ 1, 2, 3 ], {}, {} ); // $ExpectError - noneByRight( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - noneByRight(); // $ExpectError - noneByRight( [ 1, 2, 3 ] ); // $ExpectError - noneByRight( [ 1, 2, 3 ], isPositive, {}, 3 ); // $ExpectError -} diff --git a/base/none-by-right/examples/index.js b/base/none-by-right/examples/index.js deleted file mode 100644 index 3a63329f8..000000000 --- a/base/none-by-right/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var noneByRight = require( './../lib' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = noneByRight( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/none-by-right/lib/index.js b/base/none-by-right/lib/index.js deleted file mode 100644 index f6c270a52..000000000 --- a/base/none-by-right/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Test whether all elements in an array fail a test implemented by a predicate function, iterating from right to left. -* -* @module @stdlib/array/base/none-by-right -* -* @example -* var noneByRight = require( '@stdlib/array/base/none-by-right' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 0 ]; -* -* var out = noneByRight( x, isPositive ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/none-by-right/lib/main.js b/base/none-by-right/lib/main.js deleted file mode 100644 index fe1569c74..000000000 --- a/base/none-by-right/lib/main.js +++ /dev/null @@ -1,127 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Tests whether all elements in an array fail a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether all elements fail a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 0 ]; -* -* var out = internal( x, isPositive ); -* // returns true -*/ -function internal( x, predicate, thisArg ) { - var i; - for ( i = x.length-1; i >= 0; i-- ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - return false; - } - } - return true; -} - -/** -* Tests whether all elements in an array fail a test implemented by a predicate function. -* -* @private -* @param {Object} x - input array object -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether all elements fail a test -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) ); -* -* var out = accessors( x, isPositive ); -* // returns true -*/ -function accessors( x, predicate, thisArg ) { - var data; - var get; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - for ( i = data.length-1; i >= 0; i-- ) { - if ( predicate.call( thisArg, get( data, i ), i, data ) ) { - return false; - } - } - return true; -} - - -// MAIN // - -/** -* Tests whether all elements in an array fail a test implemented by a predicate function, iterating from right to left. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {boolean} boolean indicating whether all elements fail a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 0 ]; -* -* var out = noneByRight( x, isPositive ); -* // returns true -*/ -function noneByRight( x, predicate, thisArg ) { - var obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, predicate, thisArg ); - } - return internal( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = noneByRight; diff --git a/base/none-by-right/package.json b/base/none-by-right/package.json deleted file mode 100644 index 959222bfc..000000000 --- a/base/none-by-right/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/none-by-right", - "version": "0.0.0", - "description": "Test whether all elements in an array fail a test implemented by a predicate function, iterating from right to left.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "predicate", - "every", - "none", - "all", - "array.every", - "validate" - ] -} diff --git a/base/none-by-right/test/test.js b/base/none-by-right/test/test.js deleted file mode 100644 index 81ae3dceb..000000000 --- a/base/none-by-right/test/test.js +++ /dev/null @@ -1,252 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var noneByRight = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Tests whether a value is negative. -* -* @private -* @param {number} value - input value -* @returns {boolean} boolean indicating if a value is negative -*/ -function isNegative( value ) { - return ( value < 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof noneByRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (generic)', function test( t ) { - var out; - var arr; - - arr = []; - out = noneByRight( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `true` (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [] ); - out = noneByRight( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `true` (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [] ); - out = noneByRight( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the function returns `true` if all elements fail a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, 2, 3 ]; - out = noneByRight( arr, isNegative ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements fail a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = noneByRight( arr, isNegative ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements fail a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 1, 2, 3 ] ); - out = noneByRight( arr, isNegative ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements fail a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - out = noneByRight( arr, isNegative ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements pass a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, -2, 3 ]; - out = noneByRight( arr, isNegative ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements pass a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ -1.0, -2.0, 3.0 ] ); - out = noneByRight( arr, isNegative ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements pass a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ -1, -2, 3 ] ); - out = noneByRight( arr, isNegative ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements pass a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': -2, - '2': -3 - }; - out = noneByRight( arr, isNegative ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var out; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = [ 1, 2, 3 ]; - out = noneByRight( arr, predicate, ctx ); - - t.strictEqual( out, true, 'returns expected value' ); - t.strictEqual( ctx.count, arr.length, 'returns expected value' ); - - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value < 0 ); - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (generic)', function test( t ) { - var expected; - var out; - var arr; - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = noneByRight( arr, predicate ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return false; - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (accessor)', function test( t ) { - var expected; - var out; - var arr; - - arr = new AccessorArray( [ 1, , , 4 ] ); // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = noneByRight( arr, predicate ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return false; - } -}); diff --git a/base/none-by/README.md b/base/none-by/README.md deleted file mode 100644 index c598f78fb..000000000 --- a/base/none-by/README.md +++ /dev/null @@ -1,166 +0,0 @@ - - -# noneBy - -> Test whether all elements in an array fail a test implemented by a predicate function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var noneBy = require( '@stdlib/array/base/none-by' ); -``` - -#### noneBy( x, predicate\[, thisArg] ) - -Tests whether all elements in an array fail a test implemented by a `predicate` function. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 0, 0, 0, 0 ]; - -var bool = noneBy( x, isPositive ); -// returns true -``` - -If a `predicate` function returns a truthy value, the function **immediately** returns `false`. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ -1, -2, 3, -4 ]; - -var bool = noneBy( x, isPositive ); -// returns false -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( value ) { - this.count += 1; - return ( value < 0 ); -} - -var x = [ 1, 2, -3, 4 ]; - -var context = { - 'count': 0 -}; - -var bool = noneBy( x, predicate, context ); -// returns false - -var cnt = context.count; -// returns 3 -``` - -
- - - - - -
- -## Notes - -- The function performs a linear scan and returns immediately upon encountering a truthy return value. Unlike [`Array.prototype.every`][mdn-array-every], when performing a linear scan, the function does **not** skip `undefined` elements. -- If provided an empty array, the function returns `true`. - -
- - - - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var noneBy = require( '@stdlib/array/base/none-by' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = noneBy( x, naryFunction( isPositiveInteger, 1 ) ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/none-by/benchmark/benchmark.length.js b/base/none-by/benchmark/benchmark.length.js deleted file mode 100644 index 30c484a70..000000000 --- a/base/none-by/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var noneBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = noneBy( x, isPositiveInteger ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/none-by/docs/repl.txt b/base/none-by/docs/repl.txt deleted file mode 100644 index 8dbeb3fa6..000000000 --- a/base/none-by/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Tests whether all elements in an array fail a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - The function performs a linear scan and returns immediately upon - encountering a truthy return value. - - If provided an empty array, the function returns `true`. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - bool: boolean - The function returns `true` if the predicate function returns a falsy - value for all elements; otherwise, the function returns `false`. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var x = [ 0, 0, 0, 0 ]; - > var out = {{alias}}( x, f ) - true - - See Also - -------- - diff --git a/base/none-by/docs/types/index.d.ts b/base/none-by/docs/types/index.d.ts deleted file mode 100644 index d5dd9cf88..000000000 --- a/base/none-by/docs/types/index.d.ts +++ /dev/null @@ -1,97 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Tests whether all elements in an array fail a test implemented by a predicate function. -* -* ## Notes -* -* - The function immediately returns upon encountering a truthy return value. -* - If provided an empty collection, the function returns `true`. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns boolean indicating whether all elements fail a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 0 ]; -* -* var out = noneBy( x, isPositive ); -* // returns true -*/ -declare function noneBy( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - -// EXPORTS // - -export = noneBy; diff --git a/base/none-by/docs/types/test.ts b/base/none-by/docs/types/test.ts deleted file mode 100644 index 4f732f361..000000000 --- a/base/none-by/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import noneBy = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a boolean... -{ - noneBy( [ 1, 2, 3 ], isPositive ); // $ExpectType boolean - noneBy( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneBy( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneBy( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneBy( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneBy( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneBy( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneBy( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneBy( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneBy( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - noneBy( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType boolean - - noneBy( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType boolean - noneBy( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneBy( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneBy( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneBy( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneBy( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneBy( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneBy( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneBy( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneBy( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean - noneBy( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - noneBy( 2, isPositive ); // $ExpectError - noneBy( false, isPositive ); // $ExpectError - noneBy( true, isPositive ); // $ExpectError - noneBy( {}, isPositive ); // $ExpectError - - noneBy( 2, isPositive, {} ); // $ExpectError - noneBy( false, isPositive, {} ); // $ExpectError - noneBy( true, isPositive, {} ); // $ExpectError - noneBy( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - noneBy( [ 1, 2, 3 ], 'abc' ); // $ExpectError - noneBy( [ 1, 2, 3 ], 2 ); // $ExpectError - noneBy( [ 1, 2, 3 ], false ); // $ExpectError - noneBy( [ 1, 2, 3 ], true ); // $ExpectError - noneBy( [ 1, 2, 3 ], null ); // $ExpectError - noneBy( [ 1, 2, 3 ], void 0 ); // $ExpectError - noneBy( [ 1, 2, 3 ], {} ); // $ExpectError - noneBy( [ 1, 2, 3 ], [] ); // $ExpectError - - noneBy( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - noneBy( [ 1, 2, 3 ], 2, {} ); // $ExpectError - noneBy( [ 1, 2, 3 ], false, {} ); // $ExpectError - noneBy( [ 1, 2, 3 ], true, {} ); // $ExpectError - noneBy( [ 1, 2, 3 ], null, {} ); // $ExpectError - noneBy( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - noneBy( [ 1, 2, 3 ], {}, {} ); // $ExpectError - noneBy( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - noneBy(); // $ExpectError - noneBy( [ 1, 2, 3 ] ); // $ExpectError - noneBy( [ 1, 2, 3 ], isPositive, {}, 3 ); // $ExpectError -} diff --git a/base/none-by/examples/index.js b/base/none-by/examples/index.js deleted file mode 100644 index b0a204626..000000000 --- a/base/none-by/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var noneBy = require( './../lib' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = noneBy( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/none-by/lib/index.js b/base/none-by/lib/index.js deleted file mode 100644 index 6feb69bfc..000000000 --- a/base/none-by/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Test whether all elements in an array fail a test implemented by a predicate function. -* -* @module @stdlib/array/base/none-by -* -* @example -* var noneBy = require( '@stdlib/array/base/none-by' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 0 ]; -* -* var out = noneBy( x, isPositive ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/none-by/lib/main.js b/base/none-by/lib/main.js deleted file mode 100644 index ad8a92ba0..000000000 --- a/base/none-by/lib/main.js +++ /dev/null @@ -1,127 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Tests whether all elements in an array fail a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether all elements fail a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 0 ]; -* -* var out = internal( x, isPositive ); -* // returns true -*/ -function internal( x, predicate, thisArg ) { - var i; - for ( i = 0; i < x.length; i++ ) { - if ( predicate.call( thisArg, x[ i ], i, x ) ) { - return false; - } - } - return true; -} - -/** -* Tests whether all elements in an array fail a test implemented by a predicate function. -* -* @private -* @param {Object} x - input array object -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {boolean} boolean indicating whether all elements fail a test -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) ); -* -* var out = accessors( x, isPositive ); -* // returns true -*/ -function accessors( x, predicate, thisArg ) { - var data; - var get; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - for ( i = 0; i < data.length; i++ ) { - if ( predicate.call( thisArg, get( data, i ), i, data ) ) { - return false; - } - } - return true; -} - - -// MAIN // - -/** -* Tests whether all elements in an array fail a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {boolean} boolean indicating whether all elements fail a test -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 0, 0, 0, 0 ]; -* -* var out = noneBy( x, isPositive ); -* // returns true -*/ -function noneBy( x, predicate, thisArg ) { - var obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, predicate, thisArg ); - } - return internal( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = noneBy; diff --git a/base/none-by/package.json b/base/none-by/package.json deleted file mode 100644 index bdad6bd33..000000000 --- a/base/none-by/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/none-by", - "version": "0.0.0", - "description": "Test whether all elements in an array fail a test implemented by a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "predicate", - "every", - "none", - "all", - "array.every", - "validate" - ] -} diff --git a/base/none-by/test/test.js b/base/none-by/test/test.js deleted file mode 100644 index a2fd727c9..000000000 --- a/base/none-by/test/test.js +++ /dev/null @@ -1,252 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var noneBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Tests whether a value is negative. -* -* @private -* @param {number} value - input value -* @returns {boolean} boolean indicating if a value is negative -*/ -function isNegative( value ) { - return ( value < 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof noneBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (generic)', function test( t ) { - var out; - var arr; - - arr = []; - out = noneBy( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `true` (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [] ); - out = noneBy( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns `true` (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [] ); - out = noneBy( arr, foo ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the function returns `true` if all elements fail a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, 2, 3 ]; - out = noneBy( arr, isNegative ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements fail a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = noneBy( arr, isNegative ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements fail a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 1, 2, 3 ] ); - out = noneBy( arr, isNegative ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements fail a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - out = noneBy( arr, isNegative ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements pass a test (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, -2, 3 ]; - out = noneBy( arr, isNegative ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements pass a test (typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ -1.0, -2.0, 3.0 ] ); - out = noneBy( arr, isNegative ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements pass a test (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ -1, -2, 3 ] ); - out = noneBy( arr, isNegative ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements pass a test (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': -2, - '2': -3 - }; - out = noneBy( arr, isNegative ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var out; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = [ 1, 2, 3 ]; - out = noneBy( arr, predicate, ctx ); - - t.strictEqual( out, true, 'returns expected value' ); - t.strictEqual( ctx.count, arr.length, 'returns expected value' ); - - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value < 0 ); - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (generic)', function test( t ) { - var expected; - var out; - var arr; - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = noneBy( arr, predicate ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return false; - } -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (accessor)', function test( t ) { - var expected; - var out; - var arr; - - arr = new AccessorArray( [ 1, , , 4 ] ); // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - out = noneBy( arr, predicate ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'returns expected value' ); - return false; - } -}); diff --git a/base/none/README.md b/base/none/README.md deleted file mode 100644 index fc79b7c11..000000000 --- a/base/none/README.md +++ /dev/null @@ -1,118 +0,0 @@ - - -# none - -> Test whether all elements in an array are falsy. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var none = require( '@stdlib/array/base/none' ); -``` - -#### none( x ) - -Tests whether all elements in an array are falsy. - -```javascript -var x = [ 0, 0, 0, 0 ]; - -var bool = none( x ); -// returns true -``` - -
- - - - - -
- -## Notes - -- If provided an empty array, the function returns `true`. -- The function does **not** skip `undefined` elements and is thus not optimized for sparse arrays. - -
- - - - - -
- -## Examples - - - -```javascript -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var none = require( '@stdlib/array/base/none' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = none( x ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/none/benchmark/benchmark.length.js b/base/none/benchmark/benchmark.length.js deleted file mode 100644 index 83de91689..000000000 --- a/base/none/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var none = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = none( x ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( out ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/none/docs/repl.txt b/base/none/docs/repl.txt deleted file mode 100644 index c677b95d0..000000000 --- a/base/none/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( x ) - Tests whether all elements in an array are falsy. - - The function returns immediately upon encountering a truthy value. - - If provided an empty array, the function returns `true`. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - Returns - ------- - bool: boolean - The function returns `true` if all elements are falsy; otherwise, the - function returns `false`. - - Examples - -------- - > var x = [ 0, 0, 0, 0 ]; - > var out = {{alias}}( x ) - true - - See Also - -------- - diff --git a/base/none/docs/types/index.d.ts b/base/none/docs/types/index.d.ts deleted file mode 100644 index 1134444b1..000000000 --- a/base/none/docs/types/index.d.ts +++ /dev/null @@ -1,47 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Tests whether all elements in an array are falsy. -* -* ## Notes -* -* - The function immediately returns upon encountering a truthy value. -* - If provided an empty collection, the function returns `true`. -* -* @param x - input array -* @returns boolean indicating whether all elements are falsy -* -* @example -* var x = [ 0, 0, 0, 0 ]; -* -* var out = none( x ); -* // returns true -*/ -declare function none( x: Collection | AccessorArrayLike ): boolean; - - -// EXPORTS // - -export = none; diff --git a/base/none/docs/types/test.ts b/base/none/docs/types/test.ts deleted file mode 100644 index 9c530edaa..000000000 --- a/base/none/docs/types/test.ts +++ /dev/null @@ -1,52 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import none = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - none( [ 1, 2, 3 ] ); // $ExpectType boolean - none( new Float64Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - none( new Float32Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - none( new Int32Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - none( new Int16Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - none( new Int8Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - none( new Uint32Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - none( new Uint16Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - none( new Uint8Array( [ 1, 2, 3 ] ) ); // $ExpectType boolean - none( new Uint8ClampedArray( [ 1, 2, 3 ] ) ); // $ExpectType boolean - none( toAccessorArray( [ 1, 2, 3 ] ) ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - none( 2 ); // $ExpectError - none( false ); // $ExpectError - none( true ); // $ExpectError - none( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - none(); // $ExpectError - none( [ 1, 2, 3 ], {}, 3 ); // $ExpectError -} diff --git a/base/none/examples/index.js b/base/none/examples/index.js deleted file mode 100644 index 50cff4722..000000000 --- a/base/none/examples/index.js +++ /dev/null @@ -1,33 +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. -*/ - -'use strict'; - -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var none = require( './../lib' ); - -var x = bernoulli( 10, 0.1, { - 'dtype': 'int8' -}); -// returns - -var out = none( x ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/none/lib/index.js b/base/none/lib/index.js deleted file mode 100644 index a04d48fd1..000000000 --- a/base/none/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Test whether all elements in an array are falsy. -* -* @module @stdlib/array/base/none -* -* @example -* var none = require( '@stdlib/array/base/none' ); -* -* var x = [ 0, 0, 0, 0 ]; -* -* var out = none( x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/none/lib/main.js b/base/none/lib/main.js deleted file mode 100644 index 9574d77a5..000000000 --- a/base/none/lib/main.js +++ /dev/null @@ -1,147 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplex128Array = require( './../../../base/assert/is-complex128array' ); -var isComplex64Array = require( './../../../base/assert/is-complex64array' ); -var isBooleanArray = require( './../../../base/assert/is-booleanarray' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); - - -// FUNCTIONS // - -/** -* Tests whether all elements in an array are falsy. -* -* @private -* @param {Collection} x - input array -* @returns {boolean} boolean indicating whether all elements are falsy -* -* @example -* var x = [ 0, 0, 0, 0 ]; -* -* var out = internal( x ); -* // returns true -* -* @example -* var x = [ 1, 2, 0, 4 ]; -* -* var out = internal( x ); -* // returns false -*/ -function internal( x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - if ( x[ i ] ) { - return false; - } - } - return true; -} - -/** -* Tests whether all elements in an array are falsy. -* -* @private -* @param {Object} x - input array object -* @returns {boolean} boolean indicating whether all elements are falsy -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) ); -* -* var out = accessors( x ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 1, 2, 0, 4 ] ) ); -* -* var out = accessors( x ); -* // returns false -*/ -function accessors( x ) { - var data; - var get; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - for ( i = 0; i < data.length; i++ ) { - if ( get( data, i ) ) { - return false; - } - } - return true; -} - - -// MAIN // - -/** -* Tests whether all elements in an array are falsy. -* -* @param {Collection} x - input array -* @returns {boolean} boolean indicating whether all elements are falsy -* -* @example -* var x = [ 0, 0, 0, 0 ]; -* -* var out = none( x ); -* // returns true -* -* @example -* var x = [ 1, 2, 0, 4 ]; -* -* var out = none( x ); -* // returns false -*/ -function none( x ) { - var obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - // If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be falsy if both components are zero... - if ( isComplex128Array( x ) ) { - return internal( reinterpret128( x, 0 ) ); - } - if ( isComplex64Array( x ) ) { - return internal( reinterpret64( x, 0 ) ); - } - // If provided a boolean array, reinterpret as a typed array and test whether all elements are false... - if ( isBooleanArray( x ) ) { - return internal( reinterpretBoolean( x, 0 ) ); - } - return accessors( obj ); - } - return internal( x ); -} - - -// EXPORTS // - -module.exports = none; diff --git a/base/none/package.json b/base/none/package.json deleted file mode 100644 index 5e85e8ea7..000000000 --- a/base/none/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/none", - "version": "0.0.0", - "description": "Test whether all elements in an array are falsy.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "none", - "every", - "all", - "validate" - ] -} diff --git a/base/none/test/test.js b/base/none/test/test.js deleted file mode 100644 index aca9bbb38..000000000 --- a/base/none/test/test.js +++ /dev/null @@ -1,272 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Complex64Array = require( './../../../complex64' ); -var Complex128Array = require( './../../../complex128' ); -var BooleanArray = require( './../../../bool' ); -var none = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof none, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (generic)', function test( t ) { - var out; - var arr; - - arr = []; - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (real typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [] ); - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (complex typed array)', function test( t ) { - var out; - var arr; - - arr = new Complex64Array( [] ); - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - - arr = new Complex128Array( [] ); - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (boolean array)', function test( t ) { - var out; - var arr; - - arr = new BooleanArray( [] ); - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns `true` (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [] ); - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are falsy (generic)', function test( t ) { - var out; - var arr; - - arr = [ 0, 0, 0 ]; - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are falsy (real typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 0.0, 0.0, 0.0 ] ); - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are falsy (complex typed array)', function test( t ) { - var out; - var arr; - - arr = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - - arr = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are falsy (boolean array)', function test( t ) { - var out; - var arr; - - arr = new BooleanArray( [ false, false, false, false ] ); - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are falsy (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 0, 0, 0 ] ); - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `true` if all elements are falsy (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - out = none( arr ); - - t.strictEqual( out, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are truthy (generic)', function test( t ) { - var out; - var arr; - - arr = [ 1, 0, 3 ]; - out = none( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are truthy (real typed array)', function test( t ) { - var out; - var arr; - - arr = new Float64Array( [ 0.0, 0.0, 3.0 ] ); - out = none( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are truthy (complex typed array)', function test( t ) { - var out; - var arr; - - arr = new Complex64Array( [ 1.0, 0.0, 0.0, 0.0 ] ); - out = none( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - - arr = new Complex128Array( [ 0.0, 0.0, 0.0, 4.0 ] ); - out = none( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are truthy (boolean array)', function test( t ) { - var out; - var arr; - - arr = new BooleanArray( [ false, true, false, false ] ); - out = none( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are truthy (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 0, 0, 3 ] ); - out = none( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more elements are truthy (array-like object)', function test( t ) { - var out; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': 0, - '2': 0 - }; - out = none( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (generic)', function test( t ) { - var out; - var arr; - - arr = [ 0, , , 4 ]; // eslint-disable-line no-sparse-arrays - out = none( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when performing a linear scan, the function does not skip empty elements (accessor)', function test( t ) { - var out; - var arr; - - arr = new AccessorArray( [ 0, , , 4 ] ); // eslint-disable-line no-sparse-arrays - out = none( arr ); - - t.strictEqual( out, false, 'returns expected value' ); - t.end(); -}); diff --git a/base/nulls/README.md b/base/nulls/README.md deleted file mode 100644 index 0659f9c0c..000000000 --- a/base/nulls/README.md +++ /dev/null @@ -1,108 +0,0 @@ - - -# nulls - -> Create a "generic" array filled with null values. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var nulls = require( '@stdlib/array/base/nulls' ); -``` - -#### nulls( len ) - -Returns a "generic" array filled with `null` values. - -```javascript -var out = nulls( 3 ); -// returns [ null, null, null ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var nulls = require( '@stdlib/array/base/nulls' ); - -// Create a null value array: -var arr = nulls( 10 ); - -console.log( arr ); -// => [ null, null, null, null, null, null, null, null, null, null ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/nulls/benchmark/benchmark.length.js b/base/nulls/benchmark/benchmark.length.js deleted file mode 100644 index 2b8c68504..000000000 --- a/base/nulls/benchmark/benchmark.length.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var nulls = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = nulls( len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/nulls/docs/repl.txt b/base/nulls/docs/repl.txt deleted file mode 100644 index fdaf39cb3..000000000 --- a/base/nulls/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( len ) - Returns a "generic" array filled with null values. - - Parameters - ---------- - len: integer - Array length. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( 3 ) - [ null, null, null ] - - See Also - -------- - diff --git a/base/nulls/docs/types/index.d.ts b/base/nulls/docs/types/index.d.ts deleted file mode 100644 index 487ab3cc9..000000000 --- a/base/nulls/docs/types/index.d.ts +++ /dev/null @@ -1,36 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a "generic" array filled with nulls. -* -* @param len - array length -* @returns output array -* -* @example -* var out = nulls( 3 ); -* // returns [ null, null, null ] -*/ -declare function nulls( len: number ): Array; - - -// EXPORTS // - -export = nulls; diff --git a/base/nulls/docs/types/test.ts b/base/nulls/docs/types/test.ts deleted file mode 100644 index 34fbde488..000000000 --- a/base/nulls/docs/types/test.ts +++ /dev/null @@ -1,44 +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. -*/ - -import nulls = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - nulls( 3 ); // $ExpectType null[] -} - -// The compiler throws an error if the function is provided an argument which is not a number... -{ - nulls( 'abc' ); // $ExpectError - nulls( true ); // $ExpectError - nulls( false ); // $ExpectError - nulls( null ); // $ExpectError - nulls( [] ); // $ExpectError - nulls( {} ); // $ExpectError - nulls( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nulls(); // $ExpectError - nulls( 3, 2 ); // $ExpectError -} diff --git a/base/nulls/examples/index.js b/base/nulls/examples/index.js deleted file mode 100644 index cc7ba529a..000000000 --- a/base/nulls/examples/index.js +++ /dev/null @@ -1,27 +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. -*/ - -'use strict'; - -var nulls = require( './../lib' ); - -// Create a null value array: -var arr = nulls( 10 ); - -console.log( arr ); -// => [ null, null, null, null, null, null, null, null, null, null ] diff --git a/base/nulls/lib/index.js b/base/nulls/lib/index.js deleted file mode 100644 index e30573f64..000000000 --- a/base/nulls/lib/index.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -/** -* Create a "generic" array filled with null values. -* -* @module @stdlib/array/base/nulls -* -* @example -* var nulls = require( '@stdlib/array/base/nulls' ); -* -* var out = nulls( 3 ); -* // returns [ null, null, null ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/nulls/lib/main.js b/base/nulls/lib/main.js deleted file mode 100644 index 3737a2028..000000000 --- a/base/nulls/lib/main.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); - - -// MAIN // - -/** -* Returns a "generic" array filled with null values. -* -* @param {NonNegativeInteger} len - array length -* @returns {Array} output array -* -* @example -* var out = nulls( 3 ); -* // returns [ null, null, null ] -*/ -function nulls( len ) { - return filled( null, len ); -} - - -// EXPORTS // - -module.exports = nulls; diff --git a/base/nulls/package.json b/base/nulls/package.json deleted file mode 100644 index 41b9d6842..000000000 --- a/base/nulls/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/nulls", - "version": "0.0.0", - "description": "Create a generic array filled with null values.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "null" - ] -} diff --git a/base/nulls/test/test.js b/base/nulls/test/test.js deleted file mode 100644 index e67dc0028..000000000 --- a/base/nulls/test/test.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var nulls = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nulls, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a "generic" array filled with null values', function test( t ) { - var expected; - var actual; - - expected = [ null, null, null ]; - actual = nulls( 3 ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a length of `0`', function test( t ) { - var expected; - var actual; - - expected = []; - actual = nulls( 0 ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/one-to/README.md b/base/one-to/README.md deleted file mode 100644 index 6de9938e2..000000000 --- a/base/one-to/README.md +++ /dev/null @@ -1,144 +0,0 @@ - - -# oneTo - -> Generate a linearly spaced numeric array whose elements increment by 1 starting from one. - -
- -## Usage - -```javascript -var oneTo = require( '@stdlib/array/base/one-to' ); -``` - -#### oneTo( n ) - -Generates a linearly spaced numeric array whose elements increment by `1` starting from one. - -```javascript -var arr = oneTo( 6 ); -// returns [ 1, 2, 3, 4, 5, 6 ] -``` - -If `n <= 0`, the function returns an empty array. - -```javascript -var arr = oneTo( 0 ); -// returns [] - -arr = oneTo( -1 ); -// returns [] -``` - -If `n` is a non-integer value greater than zero, the function returns an array having `ceil(n)` elements. - -```javascript -var arr = oneTo( 5.1 ); -// returns [ 1, 2, 3, 4, 5, 6 ] -``` - -#### oneTo.assign( out, stride, offset ) - -Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - -```javascript -var out = [ 0, 0, 0, 0, 0, 0 ]; - -var arr = oneTo.assign( out, -1, out.length-1 ); -// returns [ 6, 5, 4, 3, 2, 1 ] - -var bool = ( arr === out ); -// returns true -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var filledBy = require( '@stdlib/array/base/filled-by' ); -var randu = require( '@stdlib/random/base/randu' ); -var oneTo = require( '@stdlib/array/base/one-to' ); - -// Generate an array of random numbers: -var x = filledBy( 10, randu ); - -// Generate a linearly-spaced array: -var y = oneTo( x.length ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort `y` according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, y, 1 ); - -console.log( x ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/one-to/benchmark/benchmark.assign.length.js b/base/one-to/benchmark/benchmark.assign.length.js deleted file mode 100644 index b95cce45f..000000000 --- a/base/one-to/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = oneTo.assign( out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/one-to/benchmark/benchmark.js b/base/one-to/benchmark/benchmark.js deleted file mode 100644 index aca6a53eb..000000000 --- a/base/one-to/benchmark/benchmark.js +++ /dev/null @@ -1,71 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - var v; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = oneTo( 100 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign', function benchmark( b ) { - var out; - var i; - var v; - - out = zeros( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = oneTo.assign( out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/one-to/benchmark/benchmark.length.js b/base/one-to/benchmark/benchmark.length.js deleted file mode 100644 index c067a680e..000000000 --- a/base/one-to/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = oneTo( len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/one-to/docs/repl.txt b/base/one-to/docs/repl.txt deleted file mode 100644 index 06ac99472..000000000 --- a/base/one-to/docs/repl.txt +++ /dev/null @@ -1,56 +0,0 @@ - -{{alias}}( n ) - Generates a linearly spaced numeric array whose elements increment by 1 - starting from one. - - If `n` is a non-integer value greater than zero, the function returns an - array having `ceil(n)` elements. - - If `n` is less than or equal to zero, the function returns an empty array. - - Parameters - ---------- - n: number - Number of elements. - - Returns - ------- - out: Array - Linearly spaced numeric array. - - Examples - -------- - > var arr = {{alias}}( 6 ) - [ 1, 2, 3, 4, 5, 6 ] - - -{{alias}}.assign( out, stride, offset ) - Fills an array with linearly spaced numeric elements which increment by 1 - starting from one. - - Parameters - ---------- - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var out = [ 0, 0, 0, 0, 0, 0 ]; - > {{alias}}.assign( out, -1, out.length-1 ); - > out - [ 6, 5, 4, 3, 2, 1 ] - - See Also - -------- - diff --git a/base/one-to/docs/types/index.d.ts b/base/one-to/docs/types/index.d.ts deleted file mode 100644 index 1cfa1f2a9..000000000 --- a/base/one-to/docs/types/index.d.ts +++ /dev/null @@ -1,361 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, Complex128Array, Complex64Array } from '@stdlib/types/array'; - -/** -* Interface describing `oneTo`. -*/ -interface ZeroTo { - /** - * Generates a linearly spaced numeric array whose elements increment by 1 starting from one. - * - * @param n - number of elements - * @returns linearly spaced numeric array - * - * @example - * var arr = oneTo( 6 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - */ - ( n: number ): Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var out = new Float64Array( 6 ); - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] - */ - assign( out: Float64Array, stride: number, offset: number ): Float64Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Float32Array = require( './../../../../float32' ); - * - * var out = new Float32Array( 6 ); - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] - */ - assign( out: Float32Array, stride: number, offset: number ): Float32Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Int32Array = require( './../../../../int32' ); - * - * var out = new Int32Array( 6 ); - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - */ - assign( out: Int32Array, stride: number, offset: number ): Int32Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Int16Array = require( './../../../../int16' ); - * - * var out = new Int16Array( 6 ); - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - */ - assign( out: Int16Array, stride: number, offset: number ): Int16Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Int8Array = require( './../../../../int8' ); - * - * var out = new Int8Array( 6 ); - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - */ - assign( out: Int8Array, stride: number, offset: number ): Int8Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Uint32Array = require( './../../../../uint32' ); - * - * var out = new Uint32Array( 6 ); - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - */ - assign( out: Uint32Array, stride: number, offset: number ): Uint32Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Uint16Array = require( './../../../../uint16' ); - * - * var out = new Uint16Array( 6 ); - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - */ - assign( out: Uint16Array, stride: number, offset: number ): Uint16Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Uint8Array = require( './../../../../uint8' ); - * - * var out = new Uint8Array( 6 ); - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - */ - assign( out: Uint8Array, stride: number, offset: number ): Uint8Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Uint8ClampedArray = require( './../../../../uint8c' ); - * - * var out = new Uint8ClampedArray( 6 ); - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - */ - assign( out: Uint8ClampedArray, stride: number, offset: number ): Uint8ClampedArray; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Complex128Array = require( './../../../../complex128' ); - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * var out = new Complex128Array( 6 ); - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns - * - * var bool = ( arr === out ); - * // returns true - * - * var v = out.get( out.length-1 ); - * // returns - * - * var re = real( v ); - * // returns 6.0 - * - * var im = imag( v ); - * // returns 0.0 - */ - assign( out: Complex128Array, stride: number, offset: number ): Complex128Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Complex64Array = require( './../../../../complex64' ); - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * var out = new Complex64Array( 6 ); - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns - * - * var bool = ( arr === out ); - * // returns true - * - * var v = out.get( out.length-1 ); - * // returns - * - * var re = realf( v ); - * // returns 6.0 - * - * var im = imagf( v ); - * // returns 0.0 - */ - assign( out: Complex64Array, stride: number, offset: number ): Complex64Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var toAccessorArray = require( './../../../../base/to-accessor-array' ); - * - * var out = toAccessorArray( [ 0, 0, 0, 0, 0, 0 ] ); - * var arr = oneTo.assign( out, 1, 0 ); - * - * var bool = ( arr === out ); - * // returns true - * - * var v = out.get( out.length-1 ); - * // returns 6 - */ - assign( out: AccessorArrayLike, stride: number, offset: number ): AccessorArrayLike; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = oneTo.assign( out, -1, out.length-1 ); - * // returns [ 6, 5, 4, 3, 2, 1 ] - */ - assign( out: Array, stride: number, offset: number ): Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from one. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = oneTo.assign( out, 1, 0 ); - * // returns [ 1, 2, 3, 4, 5, 6 ] - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = oneTo.assign( out, -1, out.length-1 ); - * // returns [ 6, 5, 4, 3, 2, 1 ] - */ - assign( out: Collection, stride: number, offset: number ): Collection; -} - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 6 ); -* // returns [ 1, 2, 3, 4, 5, 6 ] -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = oneTo.assign( out, 1, 0 ); -* // returns [ 1, 2, 3, 4, 5, 6 ] -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = oneTo.assign( out, -1, out.length-1 ); -* // returns [ 6, 5, 4, 3, 2, 1 ] -*/ -declare var oneTo: ZeroTo; - - -// EXPORTS // - -export = oneTo; diff --git a/base/one-to/docs/types/test.ts b/base/one-to/docs/types/test.ts deleted file mode 100644 index e7e49f522..000000000 --- a/base/one-to/docs/types/test.ts +++ /dev/null @@ -1,110 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import oneTo = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - oneTo( 11 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is not provided a number... -{ - oneTo( true ); // $ExpectError - oneTo( false ); // $ExpectError - oneTo( '5' ); // $ExpectError - oneTo( [] ); // $ExpectError - oneTo( {} ); // $ExpectError - oneTo( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - oneTo(); // $ExpectError - oneTo( 3, 4 ); // $ExpectError - oneTo( 3, 4, 1 ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - oneTo.assign( [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectType number[] - oneTo.assign( new Float64Array( 4 ), 1, 0 ); // $ExpectType Float64Array - oneTo.assign( new Float32Array( 4 ), 1, 0 ); // $ExpectType Float32Array - oneTo.assign( new Int32Array( 4 ), 1, 0 ); // $ExpectType Int32Array - oneTo.assign( new Int16Array( 4 ), 1, 0 ); // $ExpectType Int16Array - oneTo.assign( new Int8Array( 4 ), 1, 0 ); // $ExpectType Int8Array - oneTo.assign( new Uint32Array( 4 ), 1, 0 ); // $ExpectType Uint32Array - oneTo.assign( new Uint16Array( 4 ), 1, 0 ); // $ExpectType Uint16Array - oneTo.assign( new Uint8Array( 4 ), 1, 0 ); // $ExpectType Uint8Array - oneTo.assign( new Uint8ClampedArray( 4 ), 1, 0 ); // $ExpectType Uint8ClampedArray - oneTo.assign( new Complex128Array( 4 ), 1, 0 ); // $ExpectType Complex128Array - oneTo.assign( new Complex64Array( 4 ), 1, 0 ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - oneTo.assign( 1, 1, 0 ); // $ExpectError - oneTo.assign( true, 1, 0 ); // $ExpectError - oneTo.assign( false, 1, 0 ); // $ExpectError - oneTo.assign( null, 1, 0 ); // $ExpectError - oneTo.assign( void 0, 1, 0 ); // $ExpectError - oneTo.assign( {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a number... -{ - const out = [ 0, 0, 0, 0 ]; - - oneTo.assign( out, '1', 0 ); // $ExpectError - oneTo.assign( out, true, 0 ); // $ExpectError - oneTo.assign( out, false, 0 ); // $ExpectError - oneTo.assign( out, null, 0 ); // $ExpectError - oneTo.assign( out, void 0, 0 ); // $ExpectError - oneTo.assign( out, {}, 0 ); // $ExpectError - oneTo.assign( out, [], 0 ); // $ExpectError - oneTo.assign( out, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a number... -{ - const out = [ 0, 0, 0, 0 ]; - - oneTo.assign( out, 1, '1' ); // $ExpectError - oneTo.assign( out, 1, true ); // $ExpectError - oneTo.assign( out, 1, false ); // $ExpectError - oneTo.assign( out, 1, null ); // $ExpectError - oneTo.assign( out, 1, void 0 ); // $ExpectError - oneTo.assign( out, 1, {} ); // $ExpectError - oneTo.assign( out, 1, [] ); // $ExpectError - oneTo.assign( out, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const out = [ 0, 0, 0, 0 ]; - - oneTo.assign(); // $ExpectError - oneTo.assign( out ); // $ExpectError - oneTo.assign( out, 1 ); // $ExpectError - oneTo.assign( out, 1, 0, {} ); // $ExpectError -} diff --git a/base/one-to/examples/index.js b/base/one-to/examples/index.js deleted file mode 100644 index 5c0689ce6..000000000 --- a/base/one-to/examples/index.js +++ /dev/null @@ -1,39 +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'; - -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var filledBy = require( './../../../base/filled-by' ); -var randu = require( '@stdlib/random/base/randu' ); -var oneTo = require( './../lib' ); - -// Generate an array of random numbers: -var x = filledBy( 10, randu ); - -// Generate a linearly-spaced array: -var y = oneTo( x.length ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort `y` according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, y, 1 ); - -console.log( x ); -console.log( y ); diff --git a/base/one-to/lib/assign.js b/base/one-to/lib/assign.js deleted file mode 100644 index a7e0f0a29..000000000 --- a/base/one-to/lib/assign.js +++ /dev/null @@ -1,198 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplex128Array = require( './../../../base/assert/is-complex128array' ); -var isComplex64Array = require( './../../../base/assert/is-complex64array' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); - - -// FUNCTIONS // - -/** -* Fills an indexed array with linearly spaced numeric elements which increment by 1 starting from one. -* -* @private -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {Collection} output array -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = indexed( out, 1, 0 ); -* // returns [ 1, 2, 3, 4, 5, 6 ] -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = indexed( out, -1, out.length-1 ); -* // returns [ 6, 5, 4, 3, 2, 1 ] -*/ -function indexed( out, stride, offset ) { - var v; - var i; - - i = offset; - v = 1; - while ( i >= 0 && i < out.length ) { - out[ i ] = v; - i += stride; - v += 1; - } - return out; -} - -/** -* Fills a complex number array with linearly spaced numeric elements which increment by 1 starting from one. -* -* @private -* @param {(Complex128Array|Complex64Array)} out - output complex number array -* @param {(Float64Array|Float32Array)} data - output array data -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {(Complex128Array|Complex64Array)} output array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -* -* var out = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -* // returns -* -* var data = reinterpret128( out, 0 ); -* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] -* -* var arr = complex( out, data, 1, 0 ); -* // returns -* -* var bool = ( arr === out ); -* // returns true -* -* data = reinterpret128( out, 0 ); -* returns [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] -*/ -function complex( out, data, stride, offset ) { - var v; - var s; - var i; - - s = stride * 2; - i = offset * 2; - v = 1.0; - while ( i >= 0 && i < data.length ) { - data[ i ] = v; // real component - data[ i+1 ] = 0.0; // imaginary component - i += s; - v += 1.0; - } - return out; -} - -/** -* Fills an accessor array with linearly spaced numeric elements which increment by 1 starting from one. -* -* @private -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); - -* var out = toAccessorArray( [ 0, 0, 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( out ), 1, 0 ); -* -* var bool = ( arr === out ); -* // returns true -* -* var v = out.get( 0 ); -* // returns 1 -* -* v = out.get( out.length-1 ); -* // returns 6 -*/ -function accessors( out, stride, offset ) { - var data; - var set; - var v; - var i; - - data = out.data; - set = out.accessors[ 1 ]; - - i = offset; - v = 1; - while ( i >= 0 && i < data.length ) { - set( data, i, v ); - i += stride; - v += 1; - } - return data; -} - - -// MAIN // - -/** -* Fills an array with linearly spaced numeric elements which increment by 1 starting from one. -* -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {Collection} output array -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = assign( out, 1, 0 ); -* // returns [ 1, 2, 3, 4, 5, 6 ] -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = assign( out, -1, out.length-1 ); -* // returns [ 6, 5, 4, 3, 2, 1 ] -*/ -function assign( out, stride, offset ) { - var obj = arraylike2object( out ); - if ( obj.accessorProtocol ) { - // If provided a complex number array, reinterpret as a real typed array and only set the real components... - if ( isComplex128Array( out ) ) { - return complex( out, reinterpret128( out, 0 ), stride, offset ); - } - if ( isComplex64Array( out ) ) { - return complex( out, reinterpret64( out, 0 ), stride, offset ); - } - return accessors( obj, stride, offset ); - } - return indexed( out, stride, offset ); -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/one-to/lib/index.js b/base/one-to/lib/index.js deleted file mode 100644 index c805e4b74..000000000 --- a/base/one-to/lib/index.js +++ /dev/null @@ -1,57 +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'; - -/** -* Generate a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @module @stdlib/array/base/one-to -* -* @example -* var oneTo = require( '@stdlib/array/base/one-to' ); -* -* var arr = oneTo( 6 ); -* // returns [ 1, 2, 3, 4, 5, 6 ] -* -* @example -* var oneTo = require( '@stdlib/array/base/one-to' ); -* -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* var arr = oneTo.assign( out, 1, 0 ); -* // returns [ 1, 2, 3, 4, 5, 6 ] -* -* var bool = ( out === arr ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/one-to/lib/main.js b/base/one-to/lib/main.js deleted file mode 100644 index d1c25c957..000000000 --- a/base/one-to/lib/main.js +++ /dev/null @@ -1,50 +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'; - -// MAIN // - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param {number} n - number of elements -* @returns {Array} linearly spaced numeric array -* -* @example -* var arr = oneTo( 6 ); -* // returns [ 1, 2, 3, 4, 5, 6 ] -*/ -function oneTo( n ) { - var arr; - var i; - - arr = []; - if ( n <= 0 ) { - return arr; - } - for ( i = 1; i < n+1; i++ ) { - arr.push( i ); - } - return arr; -} - - -// EXPORTS // - -module.exports = oneTo; diff --git a/base/one-to/package.json b/base/one-to/package.json deleted file mode 100644 index 72ef9271f..000000000 --- a/base/one-to/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/one-to", - "version": "0.0.0", - "description": "Generate a linearly spaced numeric array whose elements increment by 1 starting from one.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "matlab", - "linear", - "linspace", - "sequence", - "increment", - "unitspace" - ] -} diff --git a/base/one-to/test/test.assign.js b/base/one-to/test/test.assign.js deleted file mode 100644 index e3c8ab7c2..000000000 --- a/base/one-to/test/test.assign.js +++ /dev/null @@ -1,211 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var oneTo = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof oneTo, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function fills an array with linearly spaced numbers (generic)', function test( t ) { - var expected; - var actual; - var out; - - out = [ 0, 0, 0, 0, 0 ]; - actual = oneTo( out, 1, 0 ); - expected = [ 1, 2, 3, 4, 5 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = [ 0, 0, 0 ]; - actual = oneTo( out, -1, out.length-1 ); - expected = [ 3, 2, 1 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = [ -1, -1, -1, -1, -1 ]; - actual = oneTo( out, 2, 1 ); - expected = [ -1, 1, -1, 2, -1 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = [ -1, -1, -1, -1, -1, -1 ]; - actual = oneTo( out, -2, out.length-2 ); - expected = [ 3, -1, 2, -1, 1, -1 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array with linearly spaced numbers (real typed array)', function test( t ) { - var expected; - var actual; - var out; - - out = new Float64Array( [ 0, 0, 0, 0, 0 ] ); - actual = oneTo( out, 1, 0 ); - expected = new Float64Array( [ 1, 2, 3, 4, 5 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( actual, expected ), true, 'returns expected value' ); - - out = new Float64Array( [ 0, 0, 0 ] ); - actual = oneTo( out, -1, out.length-1 ); - expected = new Float64Array( [ 3, 2, 1 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( actual, expected ), true, 'returns expected value' ); - - out = new Float64Array( [ -1, -1, -1, -1, -1 ] ); - actual = oneTo( out, 2, 1 ); - expected = new Float64Array( [ -1, 1, -1, 2, -1 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( actual, expected ), true, 'returns expected value' ); - - out = new Float64Array( [ -1, -1, -1, -1, -1, -1 ] ); - actual = oneTo( out, -2, out.length-2 ); - expected = new Float64Array( [ 3, -1, 2, -1, 1, -1 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array with linearly spaced numbers (complex typed array)', function test( t ) { - var expected; - var actual; - var out; - - out = new Complex128Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ); - actual = oneTo( out, 1, 0 ); - expected = new Complex128Array( [ 1, 0, 2, 0, 3, 0, 4, 0, 5, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex128Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ); - actual = oneTo( out, -1, out.length-1 ); - expected = new Complex128Array( [ 5, 0, 4, 0, 3, 0, 2, 0, 1, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex128Array( [ -1, -1, -1, -1, -1, -1, -1, -1 ] ); - actual = oneTo( out, 2, 1 ); - expected = new Complex128Array( [ -1, -1, 1, 0, -1, -1, 2, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ); - actual = oneTo( out, 1, 0 ); - expected = new Complex64Array( [ 1, 0, 2, 0, 3, 0, 4, 0, 5, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ); - actual = oneTo( out, -1, out.length-1 ); - expected = new Complex64Array( [ 5, 0, 4, 0, 3, 0, 2, 0, 1, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( [ -1, -1, -1, -1, -1, -1, -1, -1 ] ); - actual = oneTo( out, 2, 1 ); - expected = new Complex64Array( [ -1, -1, 1, 0, -1, -1, 2, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array with linearly spaced numbers (accessor)', function test( t ) { - var expected; - var actual; - var out; - - out = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); - actual = oneTo( out, 1, 0 ); - expected = [ 1, 2, 3, 4, 5 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = toAccessorArray( [ 0, 0, 0 ] ); - actual = oneTo( out, -1, out.length-1 ); - expected = [ 3, 2, 1 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = toAccessorArray( [ -1, -1, -1, -1, -1 ] ); - actual = oneTo( out, 2, 1 ); - expected = [ -1, 1, -1, 2, -1 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = toAccessorArray( [ -1, -1, -1, -1, -1, -1 ] ); - actual = oneTo( out, -2, out.length-2 ); - expected = [ 3, -1, 2, -1, 1, -1 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns an empty array if provided an empty array', function test( t ) { - t.deepEqual( oneTo( [], 1, 0 ), [], 'returns expected value' ); - t.deepEqual( oneTo( [], 1, 0 ), [], 'returns expected value' ); - t.end(); -}); diff --git a/base/one-to/test/test.js b/base/one-to/test/test.js deleted file mode 100644 index fd2b6ab6c..000000000 --- a/base/one-to/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var oneTo = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof oneTo, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( oneTo, 'assign' ), true, 'has property' ); - t.strictEqual( typeof oneTo.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/one-to/test/test.main.js b/base/one-to/test/test.main.js deleted file mode 100644 index 99113941c..000000000 --- a/base/one-to/test/test.main.js +++ /dev/null @@ -1,69 +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 oneTo = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof oneTo, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a linearly spaced array', function test( t ) { - var expected; - var actual; - - actual = oneTo( 10 ); - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = oneTo( 5 ); - expected = [ 1, 2, 3, 4, 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (fractional argument)', function test( t ) { - var expected; - var actual; - - actual = oneTo( 10.5 ); - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = oneTo( 5.0000001 ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided a value which is less than or equal to zero', function test( t ) { - t.deepEqual( oneTo( -1 ), [], 'returns expected value' ); - t.deepEqual( oneTo( 0 ), [], 'returns expected value' ); - t.end(); -}); diff --git a/base/ones/README.md b/base/ones/README.md deleted file mode 100644 index fec7af4c6..000000000 --- a/base/ones/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# ones - -> Create a "generic" array filled with ones. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ones = require( '@stdlib/array/base/ones' ); -``` - -#### ones( len ) - -Returns a "generic" array filled with ones. - -```javascript -var out = ones( 3 ); -// returns [ 1.0, 1.0, 1.0 ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var gscal = require( '@stdlib/blas/base/gscal' ).ndarray; -var ones = require( '@stdlib/array/base/ones' ); - -// Create a ones array: -var arr = ones( 10 ); - -// Scale element pairs... -gscal( 2, 2.0, arr, 1, 0 ); -gscal( 2, 3.0, arr, 1, 2 ); -gscal( 2, 4.0, arr, 1, 4 ); -gscal( 2, 5.0, arr, 1, 6 ); -gscal( 2, 6.0, arr, 1, 8 ); - -console.log( arr ); -// => [ 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/ones/benchmark/benchmark.length.js b/base/ones/benchmark/benchmark.length.js deleted file mode 100644 index a5cffb68f..000000000 --- a/base/ones/benchmark/benchmark.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ones( len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/ones/docs/repl.txt b/base/ones/docs/repl.txt deleted file mode 100644 index 0711193ba..000000000 --- a/base/ones/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( len ) - Returns a "generic" array filled with ones. - - Parameters - ---------- - len: integer - Array length. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( 3 ) - [ 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/base/ones/docs/types/index.d.ts b/base/ones/docs/types/index.d.ts deleted file mode 100644 index 4df95ba9a..000000000 --- a/base/ones/docs/types/index.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a "generic" array filled with ones. -* -* @param len - array length -* @returns output array -* -* @example -* var out = ones( 3 ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function ones( len: number ): Array; - - -// EXPORTS // - -export = ones; diff --git a/base/ones/docs/types/test.ts b/base/ones/docs/types/test.ts deleted file mode 100644 index 7c21c7d76..000000000 --- a/base/ones/docs/types/test.ts +++ /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. -*/ - -import ones = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ones( 3 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided an argument which is not a number... -{ - ones( 'abc' ); // $ExpectError - ones( true ); // $ExpectError - ones( false ); // $ExpectError - ones( null ); // $ExpectError - ones( [] ); // $ExpectError - ones( {} ); // $ExpectError - ones( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ones(); // $ExpectError - ones( 3, 2 ); // $ExpectError -} diff --git a/base/ones/examples/index.js b/base/ones/examples/index.js deleted file mode 100644 index 87d1a21e0..000000000 --- a/base/ones/examples/index.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 gscal = require( '@stdlib/blas/base/gscal' ).ndarray; -var ones = require( './../lib' ); - -// Create a ones array: -var arr = ones( 10 ); - -// Scale element pairs... -gscal( 2, 2.0, arr, 1, 0 ); -gscal( 2, 3.0, arr, 1, 2 ); -gscal( 2, 4.0, arr, 1, 4 ); -gscal( 2, 5.0, arr, 1, 6 ); -gscal( 2, 6.0, arr, 1, 8 ); - -console.log( arr ); -// => [ 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0, 6.0, 6.0 ] diff --git a/base/ones/lib/index.js b/base/ones/lib/index.js deleted file mode 100644 index 6938f143e..000000000 --- a/base/ones/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a "generic" array filled with ones. -* -* @module @stdlib/array/base/ones -* -* @example -* var ones = require( '@stdlib/array/base/ones' ); -* -* var out = ones( 3 ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/ones/lib/main.js b/base/ones/lib/main.js deleted file mode 100644 index 8f8b70def..000000000 --- a/base/ones/lib/main.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); - - -// MAIN // - -/** -* Returns a "generic" array filled with ones. -* -* @param {NonNegativeInteger} len - array length -* @returns {Array} output array -* -* @example -* var out = ones( 3 ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -function ones( len ) { - return filled( 1.0, len ); -} - - -// EXPORTS // - -module.exports = ones; diff --git a/base/ones/package.json b/base/ones/package.json deleted file mode 100644 index d0d225164..000000000 --- a/base/ones/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/ones", - "version": "0.0.0", - "description": "Create a generic array filled with ones.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "ones" - ] -} diff --git a/base/ones/test/test.js b/base/ones/test/test.js deleted file mode 100644 index 5e2afe48e..000000000 --- a/base/ones/test/test.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ones = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ones, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a "generic" array filled with ones', function test( t ) { - var expected; - var actual; - - expected = [ 1.0, 1.0, 1.0 ]; - actual = ones( 3 ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a length of `0`', function test( t ) { - var expected; - var actual; - - expected = []; - actual = ones( 0 ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/ones2d/README.md b/base/ones2d/README.md deleted file mode 100644 index 2097931de..000000000 --- a/base/ones2d/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# ones2d - -> Create a two-dimensional nested array filled with ones. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ones2d = require( '@stdlib/array/base/ones2d' ); -``` - -#### ones2d( shape ) - -Returns a two-dimensional nested array filled with ones. - -```javascript -var out = ones2d( [ 2, 3 ] ); -// returns [ [ 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0 ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var gscal = require( '@stdlib/blas/base/gscal' ); -var ones2d = require( '@stdlib/array/base/ones2d' ); - -// Create a ones-filled array: -var arr = ones2d( [ 5, 10 ] ); - -// Scale element values... -gscal( arr[ 0 ].length, 2.0, arr[ 0 ], 1 ); -gscal( arr[ 1 ].length, 3.0, arr[ 1 ], 1 ); -gscal( arr[ 2 ].length, 4.0, arr[ 2 ], 1 ); -gscal( arr[ 3 ].length, 5.0, arr[ 3 ], 1 ); -gscal( arr[ 4 ].length, 6.0, arr[ 4 ], 1 ); - -console.log( arr ); -// => [ [ 2.0, 2.0, ... ], [ 3.0, 3.0, ... ], [ 4.0, 4.0, ... ], [ 5.0, 5.0, ... ], [ 6.0, 6.0, ... ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/ones2d/benchmark/benchmark.size.js b/base/ones2d/benchmark/benchmark.size.js deleted file mode 100644 index 3a29a1684..000000000 --- a/base/ones2d/benchmark/benchmark.size.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var ones2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ones2d( [ N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::square_matrix:size='+(N*N), f ); - } -} - -main(); diff --git a/base/ones2d/docs/repl.txt b/base/ones2d/docs/repl.txt deleted file mode 100644 index 31ed962ca..000000000 --- a/base/ones2d/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( shape ) - Returns a two-dimensional nested array filled with ones. - - Parameters - ---------- - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 3 ] ) - [ [ 1.0, 1.0, 1.0 ] ] - - See Also - -------- - diff --git a/base/ones2d/docs/types/index.d.ts b/base/ones2d/docs/types/index.d.ts deleted file mode 100644 index 611493383..000000000 --- a/base/ones2d/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Two-dimensional nested array. -*/ -type Array2D = Array>; - -/** -* Returns a two-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = ones2d( [ 1, 3 ] ); -* // returns [ [ 1.0, 1.0, 1.0 ] ] -*/ -declare function ones2d( shape: Shape2D ): Array2D; - - -// EXPORTS // - -export = ones2d; diff --git a/base/ones2d/docs/types/test.ts b/base/ones2d/docs/types/test.ts deleted file mode 100644 index 5875002ab..000000000 --- a/base/ones2d/docs/types/test.ts +++ /dev/null @@ -1,44 +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. -*/ - -import ones2d = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - ones2d( [ 1, 3 ] ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - ones2d( 'abc' ); // $ExpectError - ones2d( true ); // $ExpectError - ones2d( false ); // $ExpectError - ones2d( null ); // $ExpectError - ones2d( [ '1' ] ); // $ExpectError - ones2d( {} ); // $ExpectError - ones2d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ones2d(); // $ExpectError - ones2d( [ 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/ones2d/examples/index.js b/base/ones2d/examples/index.js deleted file mode 100644 index 1f665c00c..000000000 --- a/base/ones2d/examples/index.js +++ /dev/null @@ -1,35 +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'; - -var gscal = require( '@stdlib/blas/base/gscal' ); -var ones2d = require( './../lib' ); - -// Create a ones-filled array: -var arr = ones2d( [ 5, 10 ] ); - -// Scale element values... -gscal( arr[ 0 ].length, 2.0, arr[ 0 ], 1 ); -gscal( arr[ 1 ].length, 3.0, arr[ 1 ], 1 ); -gscal( arr[ 2 ].length, 4.0, arr[ 2 ], 1 ); -gscal( arr[ 3 ].length, 5.0, arr[ 3 ], 1 ); -gscal( arr[ 4 ].length, 6.0, arr[ 4 ], 1 ); - -console.log( arr ); -// => [ [ 2.0, 2.0, ... ], [ 3.0, 3.0, ... ], [ 4.0, 4.0, ... ], [ 5.0, 5.0, ... ], [ 6.0, 6.0, ... ] ] diff --git a/base/ones2d/lib/index.js b/base/ones2d/lib/index.js deleted file mode 100644 index 12391910d..000000000 --- a/base/ones2d/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Create a two-dimensional nested array filled with ones. -* -* @module @stdlib/array/base/ones2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* -* var out = ones2d( [ 1, 3 ] ); -* // returns [ [ 1.0, 1.0, 1.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/ones2d/lib/main.js b/base/ones2d/lib/main.js deleted file mode 100644 index 94effdc5d..000000000 --- a/base/ones2d/lib/main.js +++ /dev/null @@ -1,45 +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 filled2d = require( './../../../base/filled2d' ); - - -// MAIN // - -/** -* Returns a two-dimensional nested array filled with ones. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {ArrayArray} filled array -* -* @example -* var out = ones2d( [ 1, 3 ] ); -* // returns [ [ 1.0, 1.0, 1.0 ] ] -*/ -function ones2d( shape ) { - return filled2d( 1.0, shape ); -} - - -// EXPORTS // - -module.exports = ones2d; diff --git a/base/ones2d/package.json b/base/ones2d/package.json deleted file mode 100644 index 9035c2a7a..000000000 --- a/base/ones2d/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/ones2d", - "version": "0.0.0", - "description": "Create a two-dimensional nested array filled with ones.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "ones", - "multidimensional", - "matrix", - "strided", - "ndarray", - "2d" - ] -} diff --git a/base/ones2d/test/test.js b/base/ones2d/test/test.js deleted file mode 100644 index e8b2edb94..000000000 --- a/base/ones2d/test/test.js +++ /dev/null @@ -1,89 +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 ones2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ones2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ [ 1.0, 1.0, 1.0 ] ]; - actual = ones2d( [ 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ]; - actual = ones2d( [ 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1.0, 1.0 ], [ 1.0, 1.0 ], [ 1.0, 1.0 ] ]; - actual = ones2d( [ 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = ones2d( [ 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = ones2d( [ 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = ones2d( [ 0, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = ones2d( [ 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = ones2d( [ 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = ones2d( [ 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/ones3d/README.md b/base/ones3d/README.md deleted file mode 100644 index 17efe01fa..000000000 --- a/base/ones3d/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# ones3d - -> Create a three-dimensional nested array filled with ones. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ones3d = require( '@stdlib/array/base/ones3d' ); -``` - -#### ones3d( shape ) - -Returns a three-dimensional nested array filled with ones. - -```javascript -var out = ones3d( [ 1, 2, 3 ] ); -// returns [ [ [ 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0 ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var ones3d = require( '@stdlib/array/base/ones3d' ); - -var out = ones3d( [ 1, 1, 3 ] ); -// returns [ [ [ 1.0, 1.0, 1.0 ] ] ] - -out = ones3d( [ 1, 3, 1 ] ); -// returns [ [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/ones3d/benchmark/benchmark.size.js b/base/ones3d/benchmark/benchmark.size.js deleted file mode 100644 index 44d8c457e..000000000 --- a/base/ones3d/benchmark/benchmark.size.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var cbrt = require( '@stdlib/math/base/special/cbrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var ones3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ones3d( [ N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( cbrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N), f ); - } -} - -main(); diff --git a/base/ones3d/docs/repl.txt b/base/ones3d/docs/repl.txt deleted file mode 100644 index f609a0f42..000000000 --- a/base/ones3d/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( shape ) - Returns a three-dimensional nested array filled with ones. - - Parameters - ---------- - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 1, 3 ] ) - [ [ [ 1.0, 1.0, 1.0 ] ] ] - - See Also - -------- - diff --git a/base/ones3d/docs/types/index.d.ts b/base/ones3d/docs/types/index.d.ts deleted file mode 100644 index f89982ef6..000000000 --- a/base/ones3d/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Three-dimensional nested array. -*/ -type Array3D = Array>>; - -/** -* Returns a three-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = ones3d( [ 1, 1, 3 ] ); -* // returns [ [ [ 1.0, 1.0, 1.0 ] ] ] -*/ -declare function ones3d( shape: Shape3D ): Array3D; - - -// EXPORTS // - -export = ones3d; diff --git a/base/ones3d/docs/types/test.ts b/base/ones3d/docs/types/test.ts deleted file mode 100644 index 0659a37a9..000000000 --- a/base/ones3d/docs/types/test.ts +++ /dev/null @@ -1,44 +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. -*/ - -import ones3d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - ones3d( [ 1, 1, 3 ] ); // $ExpectType Array3D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - ones3d( 'abc' ); // $ExpectError - ones3d( true ); // $ExpectError - ones3d( false ); // $ExpectError - ones3d( null ); // $ExpectError - ones3d( [ '1' ] ); // $ExpectError - ones3d( {} ); // $ExpectError - ones3d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ones3d(); // $ExpectError - ones3d( [ 1, 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/ones3d/examples/index.js b/base/ones3d/examples/index.js deleted file mode 100644 index 4311f766b..000000000 --- a/base/ones3d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var ones3d = require( './../lib' ); - -var out = ones3d( [ 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ 1.0, 1.0, 1.0 ] ] ] - -out = ones3d( [ 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ] ] diff --git a/base/ones3d/lib/index.js b/base/ones3d/lib/index.js deleted file mode 100644 index d38b50510..000000000 --- a/base/ones3d/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Create a three-dimensional nested array filled with ones. -* -* @module @stdlib/array/base/ones3d -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* -* var out = ones3d( [ 1, 1, 3 ] ); -* // returns [ [ [ 1.0, 1.0, 1.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/ones3d/lib/main.js b/base/ones3d/lib/main.js deleted file mode 100644 index 05d781745..000000000 --- a/base/ones3d/lib/main.js +++ /dev/null @@ -1,45 +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 filled3d = require( './../../../base/filled3d' ); - - -// MAIN // - -/** -* Returns a three-dimensional nested array filled with ones. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = ones3d( [ 1, 1, 3 ] ); -* // returns [ [ [ 1.0, 1.0, 1.0 ] ] ] -*/ -function ones3d( shape ) { - return filled3d( 1.0, shape ); -} - - -// EXPORTS // - -module.exports = ones3d; diff --git a/base/ones3d/package.json b/base/ones3d/package.json deleted file mode 100644 index 018fab384..000000000 --- a/base/ones3d/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/array/base/ones3d", - "version": "0.0.0", - "description": "Create a three-dimensional nested array filled with ones.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "3d", - "ones" - ] -} diff --git a/base/ones3d/test/test.js b/base/ones3d/test/test.js deleted file mode 100644 index d42a1ecd0..000000000 --- a/base/ones3d/test/test.js +++ /dev/null @@ -1,134 +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 ones3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ones3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ 1.0, 1.0, 1.0 ] - ] - ]; - actual = ones3d( [ 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ]; - actual = ones3d( [ 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ]; - actual = ones3d( [ 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = ones3d( [ 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = ones3d( [ 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = ones3d( [ 0, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = ones3d( [ 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = ones3d( [ 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = ones3d( [ 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [ [] ] ]; - actual = ones3d( [ 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [] ] ]; - actual = ones3d( [ 1, 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [], [] ] ]; - actual = ones3d( [ 1, 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/ones4d/README.md b/base/ones4d/README.md deleted file mode 100644 index 467f066b1..000000000 --- a/base/ones4d/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# ones4d - -> Create a four-dimensional nested array filled with ones. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ones4d = require( '@stdlib/array/base/ones4d' ); -``` - -#### ones4d( shape ) - -Returns a four-dimensional nested array filled with ones. - -```javascript -var out = ones4d( [ 1, 1, 2, 3 ] ); -// returns [ [ [ [ 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0 ] ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var ones4d = require( '@stdlib/array/base/ones4d' ); - -var out = ones4d( [ 1, 1, 1, 3 ] ); -// returns [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] - -out = ones4d( [ 1, 1, 3, 1 ] ); -// returns [ [ [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/ones4d/benchmark/benchmark.size.js b/base/ones4d/benchmark/benchmark.size.js deleted file mode 100644 index 2e295e0c0..000000000 --- a/base/ones4d/benchmark/benchmark.size.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var ones4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ones4d( [ N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N*N), f ); - } -} - -main(); diff --git a/base/ones4d/docs/repl.txt b/base/ones4d/docs/repl.txt deleted file mode 100644 index 7c2e1fdf4..000000000 --- a/base/ones4d/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( shape ) - Returns a four-dimensional nested array filled with ones. - - Parameters - ---------- - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 1, 1, 3 ] ) - [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] - - See Also - -------- - diff --git a/base/ones4d/docs/types/index.d.ts b/base/ones4d/docs/types/index.d.ts deleted file mode 100644 index a87a0ab02..000000000 --- a/base/ones4d/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Four-dimensional nested array. -*/ -type Array4D = Array>>>; - -/** -* Returns a four-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = ones4d( [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] -*/ -declare function ones4d( shape: Shape4D ): Array4D; - - -// EXPORTS // - -export = ones4d; diff --git a/base/ones4d/docs/types/test.ts b/base/ones4d/docs/types/test.ts deleted file mode 100644 index 9df533907..000000000 --- a/base/ones4d/docs/types/test.ts +++ /dev/null @@ -1,44 +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. -*/ - -import ones4d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - ones4d( [ 1, 1, 1, 3 ] ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - ones4d( 'abc' ); // $ExpectError - ones4d( true ); // $ExpectError - ones4d( false ); // $ExpectError - ones4d( null ); // $ExpectError - ones4d( [ '1' ] ); // $ExpectError - ones4d( {} ); // $ExpectError - ones4d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ones4d(); // $ExpectError - ones4d( [ 1, 1, 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/ones4d/examples/index.js b/base/ones4d/examples/index.js deleted file mode 100644 index 1201e67f6..000000000 --- a/base/ones4d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var ones4d = require( './../lib' ); - -var out = ones4d( [ 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] - -out = ones4d( [ 1, 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ] ] ] diff --git a/base/ones4d/lib/index.js b/base/ones4d/lib/index.js deleted file mode 100644 index 9d4e74bba..000000000 --- a/base/ones4d/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Create a four-dimensional nested array filled with ones. -* -* @module @stdlib/array/base/ones4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* -* var out = ones4d( [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/ones4d/lib/main.js b/base/ones4d/lib/main.js deleted file mode 100644 index 73e6186b8..000000000 --- a/base/ones4d/lib/main.js +++ /dev/null @@ -1,45 +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 filled4d = require( './../../../base/filled4d' ); - - -// MAIN // - -/** -* Returns a four-dimensional nested array filled with ones. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = ones4d( [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] -*/ -function ones4d( shape ) { - return filled4d( 1.0, shape ); -} - - -// EXPORTS // - -module.exports = ones4d; diff --git a/base/ones4d/package.json b/base/ones4d/package.json deleted file mode 100644 index c3293dc50..000000000 --- a/base/ones4d/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/array/base/ones4d", - "version": "1.0.0", - "description": "Create a four-dimensional nested array filled with ones.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.11.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "4d", - "ones" - ] -} diff --git a/base/ones4d/test/test.js b/base/ones4d/test/test.js deleted file mode 100644 index 3a8a56a1c..000000000 --- a/base/ones4d/test/test.js +++ /dev/null @@ -1,201 +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 ones4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ones4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ 1.0, 1.0, 1.0 ] - ] - ] - ]; - actual = ones4d( [ 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ]; - actual = ones4d( [ 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ], - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ] - ]; - actual = ones4d( [ 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = ones4d( [ 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = ones4d( [ 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = ones4d( [ 0, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = ones4d( [ 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = ones4d( [ 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = ones4d( [ 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = ones4d( [ 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = ones4d( [ 1, 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = ones4d( [ 1, 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = ones4d( [ 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = ones4d( [ 1, 2, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = ones4d( [ 1, 3, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/ones5d/README.md b/base/ones5d/README.md deleted file mode 100644 index 9ade5369d..000000000 --- a/base/ones5d/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# ones5d - -> Create a five-dimensional nested array filled with ones. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ones5d = require( '@stdlib/array/base/ones5d' ); -``` - -#### ones5d( shape ) - -Returns a five-dimensional nested array filled with ones. - -```javascript -var out = ones5d( [ 1, 1, 1, 2, 3 ] ); -// returns [ [ [ [ [ 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0 ] ] ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var ones5d = require( '@stdlib/array/base/ones5d' ); - -var out = ones5d( [ 1, 1, 1, 1, 3 ] ); -// returns [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] - -out = ones5d( [ 1, 1, 1, 3, 1 ] ); -// returns [ [ [ [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/ones5d/benchmark/benchmark.size.js b/base/ones5d/benchmark/benchmark.size.js deleted file mode 100644 index abd217a73..000000000 --- a/base/ones5d/benchmark/benchmark.size.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var ones5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ones5d( [ N, N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N*N*N), f ); - } -} - -main(); diff --git a/base/ones5d/docs/repl.txt b/base/ones5d/docs/repl.txt deleted file mode 100644 index 4fe60859c..000000000 --- a/base/ones5d/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( shape ) - Returns a five-dimensional nested array filled with ones. - - Parameters - ---------- - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 1, 1, 1, 3 ] ) - [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/ones5d/docs/types/index.d.ts b/base/ones5d/docs/types/index.d.ts deleted file mode 100644 index 03f56f61b..000000000 --- a/base/ones5d/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Five-dimensional nested array. -*/ -type Array5D = Array>>>>; - -/** -* Returns a five-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = ones5d( [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] -*/ -declare function ones5d( shape: Shape5D ): Array5D; - - -// EXPORTS // - -export = ones5d; diff --git a/base/ones5d/docs/types/test.ts b/base/ones5d/docs/types/test.ts deleted file mode 100644 index 517b82487..000000000 --- a/base/ones5d/docs/types/test.ts +++ /dev/null @@ -1,44 +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. -*/ - -import ones5d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - ones5d( [ 1, 1, 1, 1, 3 ] ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - ones5d( 'abc' ); // $ExpectError - ones5d( true ); // $ExpectError - ones5d( false ); // $ExpectError - ones5d( null ); // $ExpectError - ones5d( [ '1' ] ); // $ExpectError - ones5d( {} ); // $ExpectError - ones5d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ones5d(); // $ExpectError - ones5d( [ 1, 1, 1, 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/ones5d/examples/index.js b/base/ones5d/examples/index.js deleted file mode 100644 index fe8ce8852..000000000 --- a/base/ones5d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var ones5d = require( './../lib' ); - -var out = ones5d( [ 1, 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] - -out = ones5d( [ 1, 1, 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ] ] ] ] diff --git a/base/ones5d/lib/index.js b/base/ones5d/lib/index.js deleted file mode 100644 index 338d13669..000000000 --- a/base/ones5d/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Create a five-dimensional nested array filled with ones. -* -* @module @stdlib/array/base/ones5d -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* -* var out = ones5d( [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/ones5d/lib/main.js b/base/ones5d/lib/main.js deleted file mode 100644 index c34d402d2..000000000 --- a/base/ones5d/lib/main.js +++ /dev/null @@ -1,45 +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 filled5d = require( './../../../base/filled5d' ); - - -// MAIN // - -/** -* Returns a five-dimensional nested array filled with ones. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = ones5d( [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] -*/ -function ones5d( shape ) { - return filled5d( 1.0, shape ); -} - - -// EXPORTS // - -module.exports = ones5d; diff --git a/base/ones5d/package.json b/base/ones5d/package.json deleted file mode 100644 index 4356c18ba..000000000 --- a/base/ones5d/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/array/base/ones5d", - "version": "1.0.0", - "description": "Create a five-dimensional nested array filled with ones.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.11.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "5d", - "ones" - ] -} diff --git a/base/ones5d/test/test.js b/base/ones5d/test/test.js deleted file mode 100644 index 471306f3d..000000000 --- a/base/ones5d/test/test.js +++ /dev/null @@ -1,257 +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 ones5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ones5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ - [ 1.0, 1.0, 1.0 ] - ] - ] - ] - ]; - actual = ones5d( [ 1, 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ] - ]; - actual = ones5d( [ 2, 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ], - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ] - ] - ]; - actual = ones5d( [ 1, 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = ones5d( [ 0, 1, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = ones5d( [ 0, 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = ones5d( [ 0, 100, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = ones5d( [ 1, 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = ones5d( [ 2, 0, 2, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = ones5d( [ 3, 0, 3, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = ones5d( [ 1, 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = ones5d( [ 1, 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = ones5d( [ 1, 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = ones5d( [ 1, 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = ones5d( [ 1, 2, 1, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = ones5d( [ 1, 3, 1, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ [] ] - ] - ] - ]; - actual = ones5d( [ 1, 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = ones5d( [ 1, 2, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = ones5d( [ 1, 3, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/onesnd/README.md b/base/onesnd/README.md deleted file mode 100644 index efe4fc5f1..000000000 --- a/base/onesnd/README.md +++ /dev/null @@ -1,144 +0,0 @@ - - -# onesnd - -> Create an n-dimensional nested array filled with ones. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var onesnd = require( '@stdlib/array/base/onesnd' ); -``` - -#### onesnd( shape ) - -Returns an n-dimensional nested array filled with ones. - -```javascript -var out = onesnd( [ 2, 3 ] ); -// returns [ [ 1.0, 1.0, 1.0 ], [ 1.0, 1.0, 1.0 ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var onesnd = require( '@stdlib/array/base/onesnd' ); - -var out = onesnd( [ 1, 3 ] ); -// returns [ [ 1.0, 1.0, 1.0 ] ] - -out = onesnd( [ 3, 1 ] ); -// returns [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ] - -out = onesnd( [ 1, 1, 3 ] ); -// returns [ [ [ 1.0, 1.0, 1.0 ] ] ] - -out = onesnd( [ 1, 3, 1 ] ); -// returns [ [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ] ] - -out = onesnd( [ 1, 1, 1, 3 ] ); -// returns [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/onesnd/benchmark/benchmark.size.2d.js b/base/onesnd/benchmark/benchmark.size.2d.js deleted file mode 100644 index 7021ad5f1..000000000 --- a/base/onesnd/benchmark/benchmark.size.2d.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var onesnd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = onesnd( [ N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::2d,equidimensional:size='+(N*N), f ); - } -} - -main(); diff --git a/base/onesnd/benchmark/benchmark.size.3d.js b/base/onesnd/benchmark/benchmark.size.3d.js deleted file mode 100644 index d93c7a72c..000000000 --- a/base/onesnd/benchmark/benchmark.size.3d.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var cbrt = require( '@stdlib/math/base/special/cbrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var onesnd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = onesnd( [ N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( cbrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::3d,equidimensional:size='+(N*N*N), f ); - } -} - -main(); diff --git a/base/onesnd/benchmark/benchmark.size.4d.js b/base/onesnd/benchmark/benchmark.size.4d.js deleted file mode 100644 index 179456af9..000000000 --- a/base/onesnd/benchmark/benchmark.size.4d.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var onesnd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = onesnd( [ N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::4d,equidimensional:size='+(N*N*N*N), f ); - } -} - -main(); diff --git a/base/onesnd/benchmark/benchmark.size.5d.js b/base/onesnd/benchmark/benchmark.size.5d.js deleted file mode 100644 index 42936f826..000000000 --- a/base/onesnd/benchmark/benchmark.size.5d.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var onesnd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = onesnd( [ N, N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::5d,equidimensional:size='+(N*N*N*N*N), f ); - } -} - -main(); diff --git a/base/onesnd/docs/repl.txt b/base/onesnd/docs/repl.txt deleted file mode 100644 index 71743bd7a..000000000 --- a/base/onesnd/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( shape ) - Returns an n-dimensional nested array filled with ones. - - Parameters - ---------- - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 3 ] ) - [ [ 1.0, 1.0, 1.0 ] ] - - See Also - -------- - diff --git a/base/onesnd/docs/types/index.d.ts b/base/onesnd/docs/types/index.d.ts deleted file mode 100644 index cb88b110e..000000000 --- a/base/onesnd/docs/types/index.d.ts +++ /dev/null @@ -1,258 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* One-dimensional array. -*/ -type Array1D = Array; - -/** -* One-dimensional array shape. -*/ -type Shape1D = [ number ]; - -/** -* Two-dimensional array. -*/ -type Array2D = Array>; - -/** -* Two-dimensional array shape. -*/ -type Shape2D = [ number, number ]; - -/** -* Three-dimensional array. -*/ -type Array3D = Array>; - -/** -* Three-dimensional array shape. -*/ -type Shape3D = [ number, number, number ]; - -/** -* Four-dimensional array. -*/ -type Array4D = Array>; - -/** -* Four-dimensional array shape. -*/ -type Shape4D = [ number, number, number, number ]; - -/** -* Five-dimensional array. -*/ -type Array5D = Array>; - -/** -* Five-dimensional array shape. -*/ -type Shape5D = [ number, number, number, number, number ]; - -/** -* Six-dimensional array. -*/ -type Array6D = Array>; - -/** -* Six-dimensional array shape. -*/ -type Shape6D = [ number, number, number, number, number, number ]; - -/** -* Seven-dimensional array. -*/ -type Array7D = Array>; - -/** -* Seven-dimensional array shape. -*/ -type Shape7D = [ number, number, number, number, number, number, number ]; - -/** -* Eight-dimensional array. -*/ -type Array8D = Array>; - -/** -* Eight-dimensional array shape. -*/ -type Shape8D = [ number, number, number, number, number, number, number, number ]; - -/** -* Nine-dimensional array. -*/ -type Array9D = Array>; - -/** -* Nine-dimensional array shape. -*/ -type Shape9D = [ number, number, number, number, number, number, number, number, number ]; - -/** -* Ten-dimensional array. -*/ -type Array10D = Array>; // WARNING: arbitrarily limited to 10 dimensions, which should be fine for most practical purposes - -/** -* Ten-dimensional array shape. -*/ -type Shape10D = [ number, number, number, number, number, number, number, number, number, number ]; - -/** -* Returns a one-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = onesnd( [ 3 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function onesnd( shape: Shape1D ): Array1D; -/** -* Returns a two-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = onesnd( [ 1, 3 ] ); -* // returns [ [ 1.0, 1.0, 1.0 ] ] -*/ -declare function onesnd( shape: Shape2D ): Array2D; -/** -* Returns a three-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = onesnd( [ 1, 1, 3 ] ); -* // returns [ [ [ 1.0, 1.0, 1.0 ] ] ] -*/ -declare function onesnd( shape: Shape3D ): Array3D; - -/** -* Returns a four-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = onesnd( [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] -*/ -declare function onesnd( shape: Shape4D ): Array4D; - -/** -* Returns a five-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = onesnd( [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] -*/ -declare function onesnd( shape: Shape5D ): Array5D; - -/** -* Returns a six-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = onesnd( [ 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] -*/ -declare function onesnd( shape: Shape6D ): Array6D; - -/** -* Returns a seven-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = onesnd( [ 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] -*/ -declare function onesnd( shape: Shape7D ): Array7D; - -/** -* Returns an eight-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = onesnd( [ 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] ] -*/ -declare function onesnd( shape: Shape8D ): Array8D; - -/** -* Returns a nine-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = onesnd( [ 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] ] ] -*/ -declare function onesnd( shape: Shape9D ): Array9D; - -/** -* Returns a ten-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = onesnd( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] ] ] ] -*/ -declare function onesnd( shape: Shape10D ): Array10D; - -/** -* Returns an n-dimensional nested array filled with ones. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = onesnd( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ] ] ] ] ] ] -*/ -declare function onesnd( shape: Collection ): Array; - - -// EXPORTS // - -export = onesnd; diff --git a/base/onesnd/docs/types/test.ts b/base/onesnd/docs/types/test.ts deleted file mode 100644 index 2aa6f4ef8..000000000 --- a/base/onesnd/docs/types/test.ts +++ /dev/null @@ -1,48 +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. -*/ - -import onesnd = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - onesnd( [ 3 ] ); // $ExpectType Array1D - onesnd( [ 1, 3 ] ); // $ExpectType Array2D - onesnd( [ 1, 1, 3 ] ); // $ExpectType Array3D - onesnd( [ 1, 1, 1, 3 ] ); // $ExpectType Array4D - onesnd( [ 1, 1, 1, 1, 3 ] ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - onesnd( 'abc' ); // $ExpectError - onesnd( true ); // $ExpectError - onesnd( false ); // $ExpectError - onesnd( null ); // $ExpectError - onesnd( [ '1' ] ); // $ExpectError - onesnd( {} ); // $ExpectError - onesnd( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - onesnd(); // $ExpectError - onesnd( [ 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/onesnd/examples/index.js b/base/onesnd/examples/index.js deleted file mode 100644 index 6b6b91f3e..000000000 --- a/base/onesnd/examples/index.js +++ /dev/null @@ -1,41 +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'; - -var onesnd = require( './../lib' ); - -var out = onesnd( [ 1, 3 ] ); -console.log( out ); -// => [ [ 1.0, 1.0, 1.0 ] ] - -out = onesnd( [ 3, 1 ] ); -console.log( out ); -// => [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ] - -out = onesnd( [ 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ 1.0, 1.0, 1.0 ] ] ] - -out = onesnd( [ 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ] ] - -out = onesnd( [ 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] diff --git a/base/onesnd/lib/index.js b/base/onesnd/lib/index.js deleted file mode 100644 index 7f6ea3ba3..000000000 --- a/base/onesnd/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Create an n-dimensional nested array filled with ones. -* -* @module @stdlib/array/base/onesnd -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* -* var out = onesnd( [ 1, 3 ] ); -* // returns [ [ 1.0, 1.0, 1.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/onesnd/lib/main.js b/base/onesnd/lib/main.js deleted file mode 100644 index 1ca749b63..000000000 --- a/base/onesnd/lib/main.js +++ /dev/null @@ -1,49 +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 fillednd = require( './../../../base/fillednd' ); - - -// MAIN // - -/** -* Returns an n-dimensional nested array filled with ones. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = onesnd( [ 3 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var out = onesnd( [ 1, 3 ] ); -* // returns [ [ 1.0, 1.0, 1.0 ] ] -*/ -function onesnd( shape ) { - return fillednd( 1.0, shape ); -} - - -// EXPORTS // - -module.exports = onesnd; diff --git a/base/onesnd/package.json b/base/onesnd/package.json deleted file mode 100644 index 78cd5c2ad..000000000 --- a/base/onesnd/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/onesnd", - "version": "0.0.0", - "description": "Create an n-dimensional nested array filled with ones.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "ones" - ] -} diff --git a/base/onesnd/test/test.js b/base/onesnd/test/test.js deleted file mode 100644 index bd82b6e12..000000000 --- a/base/onesnd/test/test.js +++ /dev/null @@ -1,616 +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 onesnd = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof onesnd, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array (0d)', function test( t ) { - var expected; - var actual; - - expected = []; - actual = onesnd( [] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (1d)', function test( t ) { - var expected; - var actual; - - expected = [ 1.0, 1.0, 1.0 ]; - actual = onesnd( [ 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (2d)', function test( t ) { - var expected; - var actual; - - expected = [ [ 1.0, 1.0, 1.0 ] ]; - actual = onesnd( [ 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1.0 ], [ 1.0 ], [ 1.0 ] ]; - actual = onesnd( [ 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1.0, 1.0 ], [ 1.0, 1.0 ], [ 1.0, 1.0 ] ]; - actual = onesnd( [ 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (3d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ 1.0, 1.0, 1.0 ] - ] - ]; - actual = onesnd( [ 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ]; - actual = onesnd( [ 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ]; - actual = onesnd( [ 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ 1.0, 1.0, 1.0 ] - ] - ] - ]; - actual = onesnd( [ 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ]; - actual = onesnd( [ 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ], - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ] - ]; - actual = onesnd( [ 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ - [ 1.0, 1.0, 1.0 ] - ] - ] - ] - ]; - actual = onesnd( [ 1, 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ] - ]; - actual = onesnd( [ 2, 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ], - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ] - ] - ]; - actual = onesnd( [ 1, 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided a shape having a first element equal to zero (1d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = onesnd( [ 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (2d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = onesnd( [ 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = onesnd( [ 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = onesnd( [ 0, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (2d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = onesnd( [ 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = onesnd( [ 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = onesnd( [ 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = onesnd( [ 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = onesnd( [ 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = onesnd( [ 0, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = onesnd( [ 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = onesnd( [ 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = onesnd( [ 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = [ [ [] ] ]; - actual = onesnd( [ 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [] ] ]; - actual = onesnd( [ 1, 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [], [] ] ]; - actual = onesnd( [ 1, 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = onesnd( [ 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = onesnd( [ 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = onesnd( [ 0, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = onesnd( [ 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = onesnd( [ 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = onesnd( [ 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = onesnd( [ 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = onesnd( [ 1, 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = onesnd( [ 1, 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = onesnd( [ 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = onesnd( [ 1, 2, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = onesnd( [ 1, 3, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = onesnd( [ 0, 1, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = onesnd( [ 0, 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = onesnd( [ 0, 100, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = onesnd( [ 1, 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = onesnd( [ 2, 0, 2, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = onesnd( [ 3, 0, 3, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = onesnd( [ 1, 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = onesnd( [ 1, 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = onesnd( [ 1, 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = onesnd( [ 1, 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = onesnd( [ 1, 2, 1, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = onesnd( [ 1, 3, 1, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fifth element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ [] ] - ] - ] - ]; - actual = onesnd( [ 1, 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = onesnd( [ 1, 2, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = onesnd( [ 1, 3, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/package.json b/base/package.json deleted file mode 100644 index d5a5d6e48..000000000 --- a/base/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base", - "version": "0.0.0", - "description": "Base (i.e., lower-level) array utilities.", - "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/index.js", - "directories": { - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structures", - "typed", - "arrays", - "array", - "typed-array", - "typed array", - "vector", - "matrix", - "ndarray", - "buffer", - "namespace", - "ns" - ] -} diff --git a/base/place/README.md b/base/place/README.md deleted file mode 100644 index 713469bc3..000000000 --- a/base/place/README.md +++ /dev/null @@ -1,150 +0,0 @@ - - -# place - -> Replace elements of an array with provided values according to a provided mask array. - -
- -## Usage - -```javascript -var place = require( '@stdlib/array/base/place' ); -``` - -#### place( x, mask, values, mode ) - -Replaces elements of an array with provided values according to a provided mask array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = place( x, [ 0, 1, 0, 1 ], [ 20, 40 ], 'strict' ); -// returns [ 1, 20, 3, 40 ] - -var bool = ( out === x ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. -- **values**: values to set. -- **mode**: string specifying behavior when the number of `values` does not equal the number of truthy `mask` values. - -The function supports the following modes: - -- `'strict'`: specifies that the function must raise an exception when the number of `values` does not **exactly** equal the number of truthy `mask` values. -- `'non_strict'`: specifies that the function must raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -- `'strict_broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the number of `values` does not **exactly** equal the number of truthy `mask` values. -- `'broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -- `'repeat'`: specifies that the function must reuse provided `values` when replacing elements in `x` in order to satisfy the `mask` array. - -In broadcasting modes, the function supports broadcasting a `values` array containing a single element against the number of truthy values in the `mask` array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = place( x, [ 0, 1, 0, 1 ], [ 20 ], 'strict_broadcast' ); -// returns [ 1, 20, 3, 20 ] - -var bool = ( out === x ); -// returns true -``` - -In repeat mode, the function supports recycling elements in a `values` array to satisfy the number of truthy values in the `mask` array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = place( x, [ 1, 1, 0, 1 ], [ 20, 40 ], 'repeat' ); -// returns [ 20, 40, 3, 20 ] - -var bool = ( out === x ); -// returns true -``` - -
- - - -
- -## Notes - -- The function mutates the input array `x`. -- If a `mask` array element is truthy, the corresponding element in `x` is **replaced**; otherwise, the corresponding element in `x` is "masked" and thus left unchanged. - -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var linspace = require( '@stdlib/array/base/linspace' ); -var place = require( '@stdlib/array/base/place' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate a random mask array: -var N = discreteUniform( 5, 15 ); -var mask = filledBy( N, bernoulli.factory( 0.3 ) ); -console.log( mask ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = place( x, mask, values, 'non_strict' ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/place/benchmark/benchmark.js b/base/place/benchmark/benchmark.js deleted file mode 100644 index dee3b2c1c..000000000 --- a/base/place/benchmark/benchmark.js +++ /dev/null @@ -1,79 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var place = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::no_broadcasting:len=100', function benchmark( b ) { - var mask; - var x; - var i; - var v; - - x = zeroTo( 100 ); - mask = ones( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = place( x, mask, x, 'strict' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::broadcasting:len=100', function benchmark( b ) { - var mask; - var x; - var i; - var v; - - x = zeroTo( 100 ); - mask = ones( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = place( x, mask, [ i ], 'strict_broadcast' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/place/benchmark/benchmark.length.js b/base/place/benchmark/benchmark.length.js deleted file mode 100644 index 189e0f8b3..000000000 --- a/base/place/benchmark/benchmark.length.js +++ /dev/null @@ -1,113 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var ones = require( './../../../base/ones' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var place = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'dtype': 'generic' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var mask; - var x; - - x = discreteUniform( len, 0, 10, opts ); - mask = ones( len ); - values = [ - discreteUniform( len, -10, 0, opts ), - discreteUniform( len, 0, 10, opts ) - ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = place( x, mask, values[ i%values.length ], 'strict' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/place/docs/repl.txt b/base/place/docs/repl.txt deleted file mode 100644 index 4d21bf01c..000000000 --- a/base/place/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( x, mask, values, mode ) - Replaces elements of an array with provided values according to a provided - mask array. - - In broadcasting modes, the function supports broadcasting a values array - containing a single element against the number of truthy values in the mask - array. - - In repeat mode, the function supports recycling elements in a values array - to satisfy the number of truthy values in the mask array. - - The function mutates the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. If a mask array element is truthy, the corresponding element - in `x` is *replaced*; otherwise, the corresponding element in `x` is - "masked" and thus left unchanged. - - values: ArrayLikeObject - Values to set. - - mode: string - String specifying behavior when the number of values to set does not - equal the number of truthy mask values. The function supports the - following modes: - - - 'strict': specifies that the function must raise an exception when the - number of values does not *exactly* equal the number of truthy mask - values. - - 'non_strict': specifies that the function must raise an exception when - the function is provided insufficient values to satisfy the mask array. - - 'strict_broadcast': specifies that the function must broadcast a - single-element values array and otherwise raise an exception when the - number of values does not **exactly** equal the number of truthy mask - values. - - 'broadcast': specifies that the function must broadcast a single- - element values array and otherwise raise an exception when the function - is provided insufficient values to satisfy the mask array. - - 'repeat': specifies that the function must reuse provided values when - replacing elements in `x` in order to satisfy the mask array. - - Returns - ------- - out: ArrayLikeObject - Input array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x, [ 0, 1, 0, 1 ], [ 20, 40 ], 'strict' ) - [ 1, 20, 3, 40 ] - > var bool = ( out === x ) - true - - See Also - -------- - diff --git a/base/place/docs/types/index.d.ts b/base/place/docs/types/index.d.ts deleted file mode 100644 index 66eaac75a..000000000 --- a/base/place/docs/types/index.d.ts +++ /dev/null @@ -1,227 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; - -/** -* Mask array. -*/ -type MaskArray = Collection | AccessorArrayLike; - -/** -* Values array. -*/ -type ValuesArray = Collection | AccessorArrayLike; - -/** -* Mode specifying behavior when the number of values to set does not equal the number of truthy values in the mask array. -* -* ## Notes -* -* - The function supports the following modes: -* -* - `'strict'`: specifies that the function must raise an exception when the number of `values` does not **exactly** equal the number of truthy `mask` values. -* - `'non_strict'`: specifies that the function must raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -* - `'strict_broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the number of `values` does not **exactly** equal the number of truthy `mask` values. -* - `'broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -* - `'repeat'`: specifies that the function must reuse provided `values` when replacing elements in `x` in order to satisfy the `mask` array. -*/ -type Mode = 'strict' | 'non_strict' | 'strict_broadcast' | 'broadcast' | 'repeat'; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param mode - string specifying behavior when the number of values does not equal the number of truthy values in the mask array -* @returns input array -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values, 'strict' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var out = place( x, [ 0, 1, 1, 0 ], [ 30 ], 'strict_broadcast' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function place( x: T, mask: MaskArray, values: ValuesArray, mode: Mode ): T; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param mode - string specifying behavior when the number of values does not equal the number of truthy values in the mask array -* @returns input array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = new Complex128Array( [ 20.0, 30.0, 40, 5.0 ] ); -* -* var out = place( x, mask, values, 'strict' ); -* // returns -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = new Complex128Array( [ 20.0, 30.0 ] ); -* -* var out = place( x, mask, values, 'strict_broadcast' ); -* // returns -* -* var bool = ( out === x ); -* // returns true -*/ -declare function place( x: T, mask: MaskArray, values: ValuesArray, mode: Mode ): T; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param mode - string specifying behavior when the number of values does not equal the number of truthy values in the mask array -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values, 'strict' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = place( x, [ 0, 1, 1, 0 ], [ 30 ], 'strict_broadcast' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function place( x: Array, mask: MaskArray, values: ValuesArray, mode: Mode ): Array; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param mode - string specifying behavior when the number of values does not equal the number of truthy values in the mask array -* @returns input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values, 'strict' ); -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var out = place( x, [ 0, 1, 1, 0 ], [ 30 ], 'strict_broadcast' ); -* -* var bool = ( out === x ); -* // returns true -*/ -declare function place( x: AccessorArrayLike, mask: MaskArray, values: ValuesArray, mode: Mode ): AccessorArrayLike; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param mode - string specifying behavior when the number of values does not equal the number of truthy values in the mask array -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values, 'strict' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = place( x, [ 0, 1, 1, 0 ], [ 30 ], 'strict_broadcast' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function place( x: Collection, mask: MaskArray, values: ValuesArray, mode: Mode ): Collection; - - -// EXPORTS // - -export = place; diff --git a/base/place/docs/types/test.ts b/base/place/docs/types/test.ts deleted file mode 100644 index acb6fa725..000000000 --- a/base/place/docs/types/test.ts +++ /dev/null @@ -1,92 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import AccessorArray = require( './../../../../base/accessor' ); -import place = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - place( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectType number[] - place( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ], 'non_strict' ); // $ExpectType number[] - place( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict_broadcast' ); // $ExpectType number[] - place( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ], 'broadcast' ); // $ExpectType number[] - place( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ], 'repeat' ); // $ExpectType number[] - - place( new Int32Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectType Int32Array - place( new Complex128Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ], 'strict' ); // $ExpectType Complex128Array - place( new Complex64Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ], 'strict' ); // $ExpectType Complex64Array - place( new AccessorArray( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], new AccessorArray( [ 20, 30 ] ), 'strict' ); // $ExpectType AccessorArrayLike -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - place( 1, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError - place( true, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError - place( false, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError - place( null, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError - place( void 0, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError - place( {}, [ 1, 0, 0, 1 ], [ 20, 30 ], 'strict' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - place( [], 1, [ 20, 30 ], 'strict' ); // $ExpectError - place( [], true, [ 20, 30 ], 'strict' ); // $ExpectError - place( [], false, [ 20, 30 ], 'strict' ); // $ExpectError - place( [], null, [ 20, 30 ], 'strict' ); // $ExpectError - place( [], void 0, [ 20, 30 ], 'strict' ); // $ExpectError - place( [], {}, [ 20, 30 ], 'strict' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object... -{ - place( [], [ 1, 0, 0, 1 ], 1, 'strict' ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], true, 'strict' ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], false, 'strict' ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], null, 'strict' ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], void 0, 'strict' ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], {}, 'strict' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a valid mode... -{ - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], '1' ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], 1 ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], true ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], false ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], null ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], void 0 ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], {} ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], [] ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - place(); // $ExpectError - place( [] ); // $ExpectError - place( [], [] ); // $ExpectError - place( [], [], [] ); // $ExpectError - place( [], [], [], 'strict', {} ); // $ExpectError -} diff --git a/base/place/examples/index.js b/base/place/examples/index.js deleted file mode 100644 index 5c37273e1..000000000 --- a/base/place/examples/index.js +++ /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. -*/ - -'use strict'; - -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var linspace = require( './../../../base/linspace' ); -var place = require( './../lib' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate a random mask array: -var N = discreteUniform( 5, 15 ); -var mask = filledBy( N, bernoulli.factory( 0.3 ) ); -console.log( mask ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = place( x, mask, values, 'non_strict' ); -console.log( out ); diff --git a/base/place/lib/index.js b/base/place/lib/index.js deleted file mode 100644 index f8d8a4fa6..000000000 --- a/base/place/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Replace elements of an array with provided values according to a provided mask array. -* -* @module @stdlib/array/base/place -* -* @example -* var place = require( '@stdlib/array/base/place' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values, 'strict' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/place/lib/main.js b/base/place/lib/main.js deleted file mode 100644 index d2d9bf69d..000000000 --- a/base/place/lib/main.js +++ /dev/null @@ -1,309 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var isBooleanDataType = require( './../../../base/assert/is-boolean-data-type' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpretComplex = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var countTruthy = require( './../../../base/count-truthy' ); - - -// FUNCTIONS // - -/** -* Replaces elements in an indexed array with provided values. -* -* @private -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} values - values to set -* @returns {Collection} input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = indexed( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -*/ -function indexed( x, mask, values ) { - var iv; - var N; - var i; - - N = values.length; - iv = 0; - for ( i = 0; i < x.length; i++ ) { - if ( mask[ i ] ) { - x[ i ] = values[ iv ]; - iv = ( iv+1 ) % N; - } - } - return x; -} - -/** -* Replaces elements of an accessor array with provided values. -* -* @private -* @param {Object} x - input array object -* @param {Object} mask - mask array object -* @param {Object} values - values object -* @returns {Collection} input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var mask = toAccessorArray( [ 0, 1, 1, 0 ] ); -* var values = toAccessorArray( [ 20, 30 ] ); -* -* var out = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( values ) ); -* -* var v = x.get( 0 ); -* // returns 1 -* -* v = x.get( 1 ); -* // returns 20 -*/ -function accessors( x, mask, values ) { - var xdata; - var mdata; - var vdata; - var xset; - var mget; - var vget; - var iv; - var N; - var i; - - xdata = x.data; - mdata = mask.data; - vdata = values.data; - - xset = x.accessors[ 1 ]; - mget = mask.accessors[ 0 ]; - vget = values.accessors[ 0 ]; - - N = vdata.length; - iv = 0; - for ( i = 0; i < xdata.length; i++ ) { - if ( mget( mdata, i ) ) { - xset( xdata, i, vget( vdata, iv ) ); - iv = ( iv+1 ) % N; - } - } - return xdata; -} - -/** -* Replaces elements in a complex array with provided values. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} mask - mask array object -* @param {Collection} values - real-valued floating-point values array view -* @returns {Collection} input array view -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var mask = [ 1, 0, 1, 0 ]; -* var values = new Float64Array( [ 10.0, 20.0, 50.0, 60.0 ] ); -* -* var out = complex( x, arraylike2object( mask ), values ); -* // returns [ 10.0, 20.0, 3.0, 4.0, 50.0, 60.0, 7.0, 8.0 ] -*/ -function complex( x, mask, values ) { - var mdata; - var mget; - var iv; - var N; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - N = values.length; - iv = 0; - for ( i = 0; i < x.length; i += 2 ) { - if ( mget( mdata, i/2 ) ) { - x[ i ] = values[ iv ]; - x[ i+1 ] = values[ iv+1 ]; - iv = ( iv+2 ) % N; - } - } - return x; -} - -/** -* Replaces elements in a boolean array with provided values. -* -* @private -* @param {Uint8Array} x - input array -* @param {Object} mask - mask array object -* @param {Uint8Array} values - values to set -* @returns {Uint8Array} input array -* -* @example -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 0, 1, 1, 0 ] ); -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = new Uint8Array( [ 1, 1 ] ); -* -* var out = boolean( x, arraylike2object( mask ), values ); -* // returns [ 1, 1, 1, 1 ] -*/ -function boolean( x, mask, values ) { - var mdata; - var mget; - var iv; - var N; - var i; - - mdata = mask.data; - mget = mask.accessors[ 0 ]; - - N = values.length; - iv = 0; - for ( i = 0; i < x.length; i++ ) { - if ( mget( mdata, i ) ) { - x[ i ] = values[ iv ]; - iv = ( i+1 ) % N; - } - } - return x; -} - - -// MAIN // - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} values - values to set -* @param {string} mode - string specifying behavior when the number of values does not equal the number of truthy mask values -* @throws {Error} insufficient values to satisfy mask array -* @throws {Error} number of values does not equal the number of truthy mask values -* @returns {Collection} input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values, 'strict' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 30 ]; -* -* var out = place( x, mask, values, 'strict_broadcast' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 1, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values, 'repeat' ); -* // returns [ 20, 30, 3, 20 ] -* -* var bool = ( out === x ); -* // returns true -*/ -function place( x, mask, values, mode ) { - var xo; - var mo; - var vo; - var M; - - M = values.length; - if ( mode === 'strict' ) { - if ( countTruthy( mask ) !== M ) { - throw new Error( 'invalid arguments. Number of values does not equal the number of truthy values in the mask array.' ); - } - } else if ( mode === 'broadcast' ) { - if ( M !== 1 && countTruthy( mask ) > M ) { - throw new Error( 'invalid arguments. Insufficient values to satisfy mask array.' ); - } - } else if ( mode === 'strict_broadcast' ) { - if ( M !== 1 && countTruthy( mask ) !== M ) { - throw new Error( 'invalid arguments. Number of values does not equal the number of truthy values in the mask array.' ); - } - } else if ( mode === 'non_strict' ) { - if ( countTruthy( mask ) > M ) { - throw new Error( 'invalid arguments. Insufficient values to satisfy mask array.' ); - } - } - xo = arraylike2object( x ); - mo = arraylike2object( mask ); - vo = arraylike2object( values ); - if ( - xo.accessorProtocol || - mo.accessorProtocol || - vo.accessorProtocol - ) { - // Note: we only explicitly support select dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( isComplexDataType( xo.dtype ) && isComplexDataType( vo.dtype ) ) { - complex( reinterpretComplex( x, 0 ), mo, reinterpretComplex( values, 0 ) ); // eslint-disable-line max-len - return x; - } - if ( isBooleanDataType( xo.dtype ) && isBooleanDataType( vo.dtype ) ) { - boolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( values, 0 ) ); // eslint-disable-line max-len - return x; - } - accessors( xo, mo, vo ); - return x; - } - indexed( x, mask, values ); - return x; -} - - -// EXPORTS // - -module.exports = place; diff --git a/base/place/package.json b/base/place/package.json deleted file mode 100644 index f333adf21..000000000 --- a/base/place/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/place", - "version": "0.0.0", - "description": "Replace elements of an array with provided values according to a provided mask array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "set", - "replace", - "put", - "update", - "mask", - "missing", - "na" - ] -} diff --git a/base/place/test/test.js b/base/place/test/test.js deleted file mode 100644 index 164169227..000000000 --- a/base/place/test/test.js +++ /dev/null @@ -1,436 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var Int32Array = require( './../../../int32' ); -var BooleanArray = require( './../../../bool' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var place = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof place, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function replaces elements in an array (generic)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 1, 0, 1 ]; - actual = place( x, mask, [ 20, 40 ], 'strict' ); - expected = [ 1, 20, 3, 40 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, [ 20, 30, 40, 50 ], 'strict' ); - expected = [ 20, 30, 40, 50 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - actual = place( x, mask, [ 20, 30, 40, 50 ], 'non_strict' ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (generic, broadcasting)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 1, 0, 1 ]; - actual = place( x, mask, [ 20 ], 'strict_broadcast' ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, [ 20 ], 'broadcast' ); - expected = [ 20, 20, 20, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - actual = place( x, mask, [ 20 ], 'strict_broadcast' ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, [ 100, 200 ], 'repeat' ); - expected = [ 100, 200, 100, 200 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (typed)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = place( x, mask, new Int32Array( [ 20, 40 ] ), 'strict' ); - expected = new Int32Array( [ 1, 20, 3, 40 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, new Int32Array( [ 20, 30, 40, 50 ] ), 'strict' ); - expected = new Int32Array( [ 20, 30, 40, 50 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 0, 0, 0 ]; - actual = place( x, mask, new Int32Array( [ 20, 30, 40, 50 ] ), 'non_strict' ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (typed, broadcasting)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = place( x, mask, [ 20 ], 'strict_broadcast' ); - expected = new Int32Array( [ 1, 20, 3, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, [ 20 ], 'broadcast' ); - expected = new Int32Array( [ 20, 20, 20, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 0, 0, 0 ]; - actual = place( x, mask, [ 20 ], 'strict_broadcast' ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, [ 100, 200 ], 'repeat' ); - expected = new Int32Array( [ 100, 200, 100, 200 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - values = [ - new Complex64( 30.0, 40.0 ), - new Complex64( 70.0, 80.0 ) - ]; - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 30.0, 40.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 70.0, 80.0 ) - ]; - actual = place( x, mask, values, 'strict' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, broadcasting)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - values = [ - new Complex64( 100.0, 200.0 ) - ]; - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 100.0, 200.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 100.0, 200.0 ) - ]; - actual = place( x, mask, values, 'strict_broadcast' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - values = new Complex64Array( [ 30.0, 40.0, 70.0, 80.0 ] ); - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 30.0, 40.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 70.0, 80.0 ) - ]; - actual = place( x, mask, values, 'strict' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex, broadcasting)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - values = new Complex64Array( [ 100.0, 200.0 ] ); - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 100.0, 200.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 100.0, 200.0 ) - ]; - actual = place( x, mask, values, 'strict_broadcast' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - values = new BooleanArray( [ true, false ] ); - expected = [ true, true, false, true ]; - actual = place( x, mask, values, 'strict' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean, broadcasting)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - mask = toAccessorArray( [ 0, 1, 1, 0 ] ); - values = [ true ]; - expected = [ true, true, true, true ]; - actual = place( x, mask, values, 'strict_broadcast' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'when the "mode" is "strict", the function throws an error if provided insufficient values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200 ], 'strict' ); - } -}); - -tape( 'when the "mode" is "strict", the function throws an error if provided too many values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200, 300, 400, 500, 600 ], 'strict' ); - } -}); - -tape( 'when the "mode" is "non_strict", the function throws an error if provided insufficient values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200 ], 'non_strict' ); - } -}); - -tape( 'when the "mode" is "strict_broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of truthy values in a mask array (insufficient)', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200, 400 ], 'strict_broadcast' ); - } -}); - -tape( 'when the "mode" is "strict_broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of truthy values in a mask array (too many)', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200, 400, 500, 600, 700 ], 'strict_broadcast' ); - } -}); - -tape( 'when the "mode" is "broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of truthy values in a mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200, 400 ], 'broadcast' ); - } -}); diff --git a/base/put/README.md b/base/put/README.md deleted file mode 100644 index 01a30cea5..000000000 --- a/base/put/README.md +++ /dev/null @@ -1,142 +0,0 @@ - - -# put - -> Replace specified elements of an array with provided values. - -
- -## Usage - -```javascript -var put = require( '@stdlib/array/base/put' ); -``` - -#### put( x, indices, values, mode ) - -Replaces specified elements of an array with provided values. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = put( x, [ 1, 3 ], [ 20, 40 ], 'throw' ); -// returns [ 1, 20, 3, 40 ] - -var bool = ( out === x ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **indices**: list of indices. -- **values**: values to set. When `indices` contains one or more elements, `values` must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes] with `indices` (i.e., must have either one element or the same number of elements as `indices`). -- **mode**: index [mode][@stdlib/ndarray/base/ind]. - -If `indices` is an empty array, the function returns the input array unchanged. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = put( x, [], [ 20, 40 ], 'throw' ); -// returns [ 1, 2, 3, 4 ] -``` - -The function supports broadcasting a `values` array containing a single element against an `indices` array containing one or more elements. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = put( x, [ 1, 3 ], [ 20 ], 'throw' ); -// returns [ 1, 20, 3, 20 ] - -var bool = ( out === x ); -// returns true -``` - -
- - - -
- -## Notes - -- The function mutates the input array `x`. -- Because each index is only validated at the time of replacing a particular element, mutation may occur even when one or more indices are out-of-bounds, including when the index [mode][@stdlib/ndarray/base/ind] indicates to raise an exception. - -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( '@stdlib/array/base/linspace' ); -var put = require( '@stdlib/array/base/put' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); -console.log( indices ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = put( x, indices, values, 'throw' ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/put/benchmark/benchmark.js b/base/put/benchmark/benchmark.js deleted file mode 100644 index 36134c637..000000000 --- a/base/put/benchmark/benchmark.js +++ /dev/null @@ -1,78 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var put = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::no_broadcasting:len=100', function benchmark( b ) { - var idx; - var x; - var i; - var v; - - x = zeroTo( 100 ); - idx = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = put( x, idx, x, 'throw' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::broadcasting:len=100', function benchmark( b ) { - var idx; - var x; - var i; - var v; - - x = zeroTo( 100 ); - idx = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = put( x, idx, [ i ], 'throw' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/put/benchmark/benchmark.length.js b/base/put/benchmark/benchmark.length.js deleted file mode 100644 index c0cce12dd..000000000 --- a/base/put/benchmark/benchmark.length.js +++ /dev/null @@ -1,113 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../../../base/zero-to' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var put = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'dtype': 'generic' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var idx; - var x; - - x = discreteUniform( len, 0, 10, opts ); - idx = zeroTo( len ); - values = [ - discreteUniform( len, -10, 0, opts ), - discreteUniform( len, 0, 10, opts ) - ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = put( x, idx, values[ i%values.length ], 'throw' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/put/docs/repl.txt b/base/put/docs/repl.txt deleted file mode 100644 index 2cebb7d26..000000000 --- a/base/put/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x, indices, values, mode ) - Replaces specified elements of an array with provided values. - - The function supports broadcasting a `values` array containing a single - element against an `indices` array containing one or more elements. - - The function mutates the input array. - - Because each index is only validated at the time of replacing a particular - element, mutation may occur even when one or more indices are out-of-bounds, - including when the index mode indicates to raise an exception. - - If `indices` is an empty array, the function returns the input array - unchanged. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - indices: ArrayLikeObject - List of element indices. - - values: ArrayLikeObject - Values to set. When `indices` contains one or more elements, `values` - must be broadcast compatible with `indices` (i.e., must have either one - element or the same number of elements as `indices`). - - mode: string - Specifies how to handle an index outside the interval [0, max], where - `max` is the maximum possible array index. If equal to 'throw', the - function throws an error. If equal to 'normalize', the function throws - an error if provided an out-of-bounds normalized index. If equal to - 'wrap', the function wraps around an index using modulo arithmetic. If - equal to 'clamp', the function sets an index to either 0 (minimum index) - or the maximum index. - - Returns - ------- - out: ArrayLikeObject - Input array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x, [ 1, 3 ], [ 20, 40 ], 'throw' ) - [ 1, 20, 3, 40 ] - > var bool = ( out === x ) - true - - See Also - -------- - diff --git a/base/put/docs/types/index.d.ts b/base/put/docs/types/index.d.ts deleted file mode 100644 index c28944357..000000000 --- a/base/put/docs/types/index.d.ts +++ /dev/null @@ -1,213 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; -import { Mode } from '@stdlib/types/ndarray'; - -/** -* Index array. -*/ -type IndexArray = Collection | AccessorArrayLike; - -/** -* Values array. -*/ -type ValuesArray = Collection | AccessorArrayLike; - -/** -* Replaces specified elements of an array with provided values. -* -* @param x - input array -* @param indices - list of element indices -* @param values - values to set -* @param mode - index mode -* @returns input array -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values, 'throw' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var out = put( x, [ 1, 2 ], [ 30 ], 'throw' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function put( x: T, indices: IndexArray, values: ValuesArray, mode: Mode ): T; - -/** -* Replaces specified elements of an array with provided values. -* -* @param x - input array -* @param indices - list of element indices -* @param values - values to set -* @param mode - index mode -* @returns input array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var indices = [ 1, 2 ]; -* var values = new Complex128Array( [ 20.0, 30.0, 40.0, 5.0 ] ); -* -* var out = put( x, indices, values, 'throw' ); -* // returns -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var indices = [ 1, 2 ]; -* var values = new Complex128Array( [ 20.0, 30.0 ] ); -* -* var out = put( x, indices, values, 'throw' ); -* // returns -* -* var bool = ( out === x ); -* // returns true -*/ -declare function put( x: T, indices: IndexArray, values: ValuesArray, mode: Mode ): T; - -/** -* Replaces specified elements of an array with provided values. -* -* @param x - input array -* @param indices - list of element indices -* @param values - values to set -* @param mode - index mode -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values, 'throw' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = put( x, [ 1, 2 ], [ 30 ], 'throw' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function put( x: Array, indices: IndexArray, values: ValuesArray, mode: Mode ): Array; - -/** -* Replaces specified elements of an array with provided values. -* -* @param x - input array -* @param indices - list of element indices -* @param values - values to set -* @param mode - index mode -* @returns input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values, 'throw' ); -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var out = put( x, [ 1, 2 ], [ 30 ], 'throw' ); -* -* var bool = ( out === x ); -* // returns true -*/ -declare function put( x: AccessorArrayLike, indices: IndexArray, values: ValuesArray, mode: Mode ): AccessorArrayLike; - -/** -* Replaces specified elements of an array with provided values. -* -* @param x - input array -* @param indices - list of element indices -* @param values - values to set -* @param mode - index mode -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values, 'throw' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = put( x, [ 1, 2 ], [ 30 ], 'throw' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function put( x: Collection, indices: IndexArray, values: ValuesArray, mode: Mode ): Collection; - - -// EXPORTS // - -export = put; diff --git a/base/put/docs/types/test.ts b/base/put/docs/types/test.ts deleted file mode 100644 index 4360adbe2..000000000 --- a/base/put/docs/types/test.ts +++ /dev/null @@ -1,91 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import AccessorArray = require( './../../../../base/accessor' ); -import put = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - put( [ 1, 2, 3, 4 ], [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectType number[] - put( [ 1, 2, 3, 4 ], [ 1, 3 ], [ 20, 30 ], 'clamp' ); // $ExpectType number[] - put( [ '1', '2', '3', '4' ], [ 1, 3 ], [ 20, 30 ], 'wrap' ); // $ExpectType (string | number)[] - put( [ 1, 2, 3, 4 ], [ 1, 3 ], [ true, true ], 'normalize' ); // $ExpectType (number | boolean)[] - - put( new Int32Array( [ 1, 2, 3, 4 ] ), [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectType Int32Array - put( new Complex128Array( [ 1, 2, 3, 4 ] ), [ 1, 3 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ], 'throw' ); // $ExpectType Complex128Array - put( new Complex64Array( [ 1, 2, 3, 4 ] ), [ 1, 3 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ], 'throw' ); // $ExpectType Complex64Array - put( new AccessorArray( [ 1, 2, 3, 4 ] ), [ 1, 3 ], new AccessorArray( [ 20, 30 ] ), 'throw' ); // $ExpectType AccessorArrayLike -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - put( 1, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - put( true, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - put( false, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - put( null, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - put( void 0, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - put( {}, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - put( [], 1, [ 20, 30 ], 'throw' ); // $ExpectError - put( [], true, [ 20, 30 ], 'throw' ); // $ExpectError - put( [], false, [ 20, 30 ], 'throw' ); // $ExpectError - put( [], null, [ 20, 30 ], 'throw' ); // $ExpectError - put( [], void 0, [ 20, 30 ], 'throw' ); // $ExpectError - put( [], {}, [ 20, 30 ], 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object... -{ - put( [], [ 1, 3 ], 1, 'throw' ); // $ExpectError - put( [], [ 1, 3 ], true, 'throw' ); // $ExpectError - put( [], [ 1, 3 ], false, 'throw' ); // $ExpectError - put( [], [ 1, 3 ], null, 'throw' ); // $ExpectError - put( [], [ 1, 3 ], void 0, 'throw' ); // $ExpectError - put( [], [ 1, 3 ], {}, 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a valid index mode... -{ - put( [], [ 1, 3 ], [ 20, 30 ], '1' ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], 1 ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], true ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], false ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], null ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], void 0 ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], {} ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], [] ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - put(); // $ExpectError - put( [] ); // $ExpectError - put( [], [] ); // $ExpectError - put( [], [], [] ); // $ExpectError - put( [], [], [], 'throw', {} ); // $ExpectError -} diff --git a/base/put/examples/index.js b/base/put/examples/index.js deleted file mode 100644 index bd85bfc70..000000000 --- a/base/put/examples/index.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( './../../../base/linspace' ); -var put = require( './../lib' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); -console.log( indices ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = put( x, indices, values, 'throw' ); -console.log( out ); diff --git a/base/put/lib/index.js b/base/put/lib/index.js deleted file mode 100644 index 5703e17d1..000000000 --- a/base/put/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Replace specified elements of an array with provided values. -* -* @module @stdlib/array/base/put -* -* @example -* var put = require( '@stdlib/array/base/put' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values, 'throw' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/put/lib/main.js b/base/put/lib/main.js deleted file mode 100644 index 9b30c1833..000000000 --- a/base/put/lib/main.js +++ /dev/null @@ -1,319 +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 isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var isBooleanDataType = require( './../../../base/assert/is-boolean-data-type' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpretComplex = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var ind = require( '@stdlib/ndarray/base/ind' ).factory; -var format = require( '@stdlib/string/format' ); - - -// FUNCTIONS // - -/** -* Replaces elements in an indexed array with provided values. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} indices - list of indices -* @param {Collection} values - values to set -* @param {NonNegativeInteger} stride - index stride for accessing elements in `values` -* @param {Function} getIndex - function for resolving an array index -* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive) -* @returns {Collection} input array -* -* @example -* var ind = require( '@stdlib/ndarray/base/ind' ).factory; -* -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 3, 1, 2, 0 ]; -* var values = [ 5, 6, 7, 8 ]; -* -* var getIndex = ind( 'throw' ); -* -* var out = indexed( x, indices, values, 1, getIndex, x.length-1 ); -* // returns [ 8, 6, 7, 5 ] -*/ -function indexed( x, indices, values, stride, getIndex, maxIndex ) { - var iv; - var i; - var j; - - iv = 0; - for ( i = 0; i < indices.length; i++ ) { - j = getIndex( indices[ i ], maxIndex ); - x[ j ] = values[ iv ]; - iv += stride; - } - return x; -} - -/** -* Replaces specified elements of an accessor array with provided values. -* -* @private -* @param {Object} x - input array object -* @param {Object} indices - index object -* @param {Object} values - values object -* @param {NonNegativeInteger} stride - index stride for accessing elements in `values` -* @param {Function} getIndex - function for resolving an array index -* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive) -* @returns {Collection} input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* var ind = require( '@stdlib/ndarray/base/ind' ).factory; -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var indices = toAccessorArray( [ 1, 2 ] ); -* var values = toAccessorArray( [ 20, 30 ] ); -* -* var getIndex = ind( 'throw' ); -* -* var out = accessors( arraylike2object( x ), arraylike2object( indices ), arraylike2object( values ), 1, getIndex, x.length-1 ); -* -* var v = x.get( 0 ); -* // returns 1 -* -* v = x.get( 1 ); -* // returns 20 -*/ -function accessors( x, indices, values, stride, getIndex, maxIndex ) { - var xdata; - var idata; - var vdata; - var xset; - var iget; - var vget; - var iv; - var i; - var j; - - xdata = x.data; - idata = indices.data; - vdata = values.data; - - xset = x.accessors[ 1 ]; - iget = indices.accessors[ 0 ]; - vget = values.accessors[ 0 ]; - - iv = 0; - for ( i = 0; i < idata.length; i++ ) { - j = getIndex( iget( idata, i ), maxIndex ); - xset( xdata, j, vget( vdata, iv ) ); - iv += stride; - } - return xdata; -} - -/** -* Replaces elements in a complex array with provided values. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} indices - index array object -* @param {Collection} values - real-valued floating-point values array view -* @param {NonNegativeInteger} stride - index stride for accessing elements in `values` -* @param {Function} getIndex - function for resolving an array index -* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive) -* @returns {Collection} input array view -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* var ind = require( '@stdlib/ndarray/base/ind' ).factory; -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var indices = [ 0, 2 ]; -* var values = new Float64Array( [ 10.0, 20.0, 50.0, 60.0 ] ); -* -* var getIndex = ind( 'throw' ); -* -* var out = complex( x, arraylike2object( indices ), values, 1, getIndex, x.length-1 ); -* // returns [ 10.0, 20.0, 3.0, 4.0, 50.0, 60.0, 7.0, 8.0 ] -*/ -function complex( x, indices, values, stride, getIndex, maxIndex ) { - var idata; - var iget; - var iv; - var sv; - var i; - var j; - var k; - - idata = indices.data; - iget = indices.accessors[ 0 ]; - - sv = stride * 2; // note: multiply by 2, as real-valued values array consists of interleaved real and imaginary components - iv = 0; - for ( i = 0; i < idata.length; i++ ) { - j = getIndex( iget( idata, i ), maxIndex ); - k = j * 2; - x[ k ] = values[ iv ]; - x[ k+1 ] = values[ iv+1 ]; - iv += sv; - } - return x; -} - -/** -* Replaces elements in a boolean array with provided values. -* -* @private -* @param {Uint8Array} x - input array -* @param {Object} indices - index array object -* @param {Uint8Array} values - values to set -* @param {NonNegativeInteger} stride - index stride for accessing elements in `values` -* @param {Function} getIndex - function for resolving an array index -* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive) -* @returns {Uint8Array} input array -* -* @example -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* var Uint8Array = require( '@stdlib/array/uint8' ); -* var ind = require( '@stdlib/ndarray/base/ind' ).factory; -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* -* var indices = [ 3, 1, 2, 0 ]; -* var values = new Uint8Array( [ 0, 1, 1, 0 ] ); -* -* var getIndex = ind( 'throw' ); -* -* var out = boolean( x, arraylike2object( indices ), values, 1, getIndex, x.length-1 ); -* // returns [ 0, 1, 1, 0 ] -*/ -function boolean( x, indices, values, stride, getIndex, maxIndex ) { - var idata; - var iget; - var iv; - var i; - var j; - - idata = indices.data; - iget = indices.accessors[ 0 ]; - - iv = 0; - for ( i = 0; i < idata.length; i++ ) { - j = getIndex( iget( idata, i ), maxIndex ); - x[ j ] = values[ iv ]; - iv += stride; - } - return x; -} - - -// MAIN // - -/** -* Replaces specified elements of an array with provided values. -* -* @param {Collection} x - input array -* @param {IntegerArray} indices - list of indices -* @param {Collection} values - values to set -* @param {string} mode - index mode -* @throws {Error} third argument must be broadcast compatible with the second argument -* @returns {Collection} input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values, 'throw' ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 1, 2 ]; -* var values = [ 30 ]; -* -* var out = put( x, indices, values, 'throw' ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -function put( x, indices, values, mode ) { - var getIndex; - var stride; - var max; - var xo; - var io; - var vo; - - // Broadcast the `values` array... - if ( indices.length > 0 ) { // note: this allows `indices` to be empty and `values` to be non-empty (and not broadcast compatible with `indices`) to allow the potential use case where having an empty `indices` array is expected behavior and you don't want to trigger an exception simply because `values` has elements - // Note that this effectively in-lines logic from `@stdlib/array/base/broadcast-array` in order to avoid unnecessary object creation... - if ( values.length === indices.length ) { - stride = 1; - } else if ( values.length === 1 ) { - stride = 0; - } else { - throw new Error( format( 'invalid argument. The third argument must be broadcast compatible with the second argument. Array shape: (%d). Desired shape: (%d).', values.length, indices.length ) ); - } - } - // Resolve a function for returning an index according to the specified index mode: - getIndex = ind( mode ); - - // Resolve the maximum index: - max = x.length - 1; - - xo = arraylike2object( x ); - io = arraylike2object( indices ); - vo = arraylike2object( values ); - if ( - xo.accessorProtocol || - io.accessorProtocol || - vo.accessorProtocol - ) { - // Note: we only explicitly support select dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( isComplexDataType( xo.dtype ) && isComplexDataType( vo.dtype ) ) { - complex( reinterpretComplex( x, 0 ), io, reinterpretComplex( values, 0 ), stride, getIndex, max ); // eslint-disable-line max-len - return x; - } - if ( isBooleanDataType( xo.dtype ) && isBooleanDataType( vo.dtype ) ) { - boolean( reinterpretBoolean( x, 0 ), io, reinterpretBoolean( values, 0 ), stride, getIndex, max ); // eslint-disable-line max-len - return x; - } - accessors( xo, io, vo, stride, getIndex, max ); - return x; - } - indexed( x, indices, values, stride, getIndex, max ); - return x; -} - - -// EXPORTS // - -module.exports = put; diff --git a/base/put/package.json b/base/put/package.json deleted file mode 100644 index 318e4413e..000000000 --- a/base/put/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/put", - "version": "0.0.0", - "description": "Replace specified elements of an array with provided values.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "set", - "replace", - "put", - "update" - ] -} diff --git a/base/put/test/test.js b/base/put/test/test.js deleted file mode 100644 index 7ce9941e4..000000000 --- a/base/put/test/test.js +++ /dev/null @@ -1,528 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var Int32Array = require( './../../../int32' ); -var BooleanArray = require( './../../../bool' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var put = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof put, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a third argument which is not broadcast compatible with the second argument (generic)', function test( t ) { - var values; - var i; - - values = [ - [], - [ 1, 2, 3 ], - [ 1, 2, 3, 4 ], - [ 1, 2, 3, 4, 5 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided an array of length ' + values[ i ].length ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( [ 1, 2, 3, 4 ], [ 1, 2 ], value, 'throw' ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not broadcast compatible with the second argument (typed)', function test( t ) { - var values; - var i; - - values = [ - [], - [ 1, 2, 3 ], - [ 1, 2, 3, 4 ], - [ 1, 2, 3, 4, 5 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided an array of length ' + values[ i ].length ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( new Int32Array( [ 1, 2, 3, 4 ] ), [ 1, 2 ], value, 'throw' ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not broadcast compatible with the second argument (accessors)', function test( t ) { - var values; - var i; - - values = [ - [], - [ 1, 2, 3 ], - [ 1, 2, 3, 4 ], - [ 1, 2, 3, 4, 5 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided an array of length ' + values[ i ].length ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( toAccessorArray( [ 1, 2, 3, 4 ] ), toAccessorArray( [ 1, 2 ] ), toAccessorArray( value ), 'throw' ); - }; - } -}); - -tape( 'the function replaces elements in an array (generic)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 3 ]; - actual = put( x, indices, [ 20, 40 ], 'throw' ); - expected = [ 1, 20, 3, 40 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 1, 3, 3 ]; - actual = put( x, indices, [ 20, 30, 40, 50 ], 'throw' ); - expected = [ 1, 30, 3, 50 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 3, 2, 1, 0 ]; - actual = put( x, indices, [ 20, 30, 40, 50 ], 'throw' ); - expected = [ 50, 40, 30, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = put( x, indices, [ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ], 'throw' ); - expected = [ 1, 100, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (generic, broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 3 ]; - actual = put( x, indices, [ 20 ], 'throw' ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 1, 3, 3 ]; - actual = put( x, indices, [ 20 ], 'throw' ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 3, 2, 1, 0 ]; - actual = put( x, indices, [ 20 ], 'throw' ); - expected = [ 20, 20, 20, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = put( x, indices, [ 100 ], 'throw' ); - expected = [ 1, 100, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (typed)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 3 ]; - actual = put( x, indices, [ 20, 40 ], 'throw' ); - expected = new Int32Array( [ 1, 20, 3, 40 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 1, 3, 3 ]; - actual = put( x, indices, [ 20, 30, 40, 50 ], 'throw' ); - expected = new Int32Array( [ 1, 30, 3, 50 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 3, 2, 1, 0 ]; - actual = put( x, indices, [ 20, 30, 40, 50 ], 'throw' ); - expected = new Int32Array( [ 50, 40, 30, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = put( x, indices, [ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ], 'throw' ); - expected = new Int32Array( [ 1, 100, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (typed, broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 3 ]; - actual = put( x, indices, [ 20 ], 'throw' ); - expected = new Int32Array( [ 1, 20, 3, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 1, 3, 3 ]; - actual = put( x, indices, [ 20 ], 'throw' ); - expected = new Int32Array( [ 1, 20, 3, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 3, 2, 1, 0 ]; - actual = put( x, indices, [ 20 ], 'throw' ); - expected = new Int32Array( [ 20, 20, 20, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = put( x, indices, [ 100 ], 'throw' ); - expected = new Int32Array( [ 1, 100, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors)', function test( t ) { - var expected; - var indices; - var actual; - var values; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = [ - new Complex64( 10.0, 20.0 ), - new Complex64( 30.0, 40.0 ), - new Complex64( 50.0, 60.0 ), - new Complex64( 70.0, 80.0 ) - ]; - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 30.0, 40.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 70.0, 80.0 ) - ]; - actual = put( x, indices, values, 'throw' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < indices.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - var values; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = [ - new Complex64( 100.0, 200.0 ) - ]; - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 100.0, 200.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 100.0, 200.0 ) - ]; - actual = put( x, indices, values, 'throw' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < indices.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex)', function test( t ) { - var expected; - var indices; - var actual; - var values; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = new Complex64Array( [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0 ] ); - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 30.0, 40.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 70.0, 80.0 ) - ]; - actual = put( x, indices, values, 'throw' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < indices.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex, broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - var values; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = new Complex64Array( [ 100.0, 200.0 ] ); - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 100.0, 200.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 100.0, 200.0 ) - ]; - actual = put( x, indices, values, 'throw' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < indices.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean)', function test( t ) { - var expected; - var indices; - var actual; - var values; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = new BooleanArray( [ false, true, false, true ] ); - expected = [ true, true, false, true ]; - actual = put( x, indices, values, 'throw' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < indices.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean, broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - var values; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = [ true ]; - expected = [ true, true, false, true ]; - actual = put( x, indices, values, 'throw' ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < indices.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns the input array unchanged if provided a second argument which is empty', function test( t ) { - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - actual = put( x, [], [ 5, 6, 7, 8 ], 'throw' ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, [ 1, 2, 3, 4 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 4, 5, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - put( x, indices, [ 200 ], 'throw' ); - } -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -1, -2, -3, -4 ]; - actual = put( x, indices, [ 5, 6, 7, 8 ], 'normalize' ); - expected = [ 8, 7, 6, 5 ]; - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 2, 50, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - put( x, indices, [ 100 ], 'normalize' ); - } -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -10, 10, -5, 5 ]; - actual = put( x, indices, [ 100, 200, 300, 400 ], 'clamp' ); - expected = [ 300, 2, 3, 400 ]; - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -10, 10, -5, 5 ]; - actual = put( x, indices, [ 100, 200, 300, 400 ], 'wrap' ); - expected = [ 1, 400, 200, 300 ]; - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/quaternary2d/README.md b/base/quaternary2d/README.md deleted file mode 100644 index e2d15b7e1..000000000 --- a/base/quaternary2d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# quaternary2d - -> Apply a quaternary callback to elements in four two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var quaternary2d = require( '@stdlib/array/base/quaternary2d' ); -``` - -#### quaternary2d( arrays, shape, fcn ) - -Applies a quaternary callback to elements in four two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add4' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); - -var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; -var out = zeros2d( [ 2, 2 ] ); - -var shape = [ 2, 2 ]; - -quaternary2d( [ x, x, x, x, out ], shape, add ); -// out => [ [ 4.0, 8.0 ], [ 12.0, 16.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing four input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: quaternary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary2d = require( '@stdlib/array/base/quaternary2d' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros2d( shape ); -console.log( out ); - -quaternary2d( [ x, y, z, w, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/quaternary2d/benchmark/benchmark.js b/base/quaternary2d/benchmark/benchmark.js deleted file mode 100644 index 3dd4e9020..000000000 --- a/base/quaternary2d/benchmark/benchmark.js +++ /dev/null @@ -1,122 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var pkg = require( './../package.json' ).name; -var quaternary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - var w; - - x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - w = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros2d( shape ); - - arrays = [ x, y, z, w, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - quaternary2d( arrays, shape, add ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 4 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 4 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/quaternary2d/docs/repl.txt b/base/quaternary2d/docs/repl.txt deleted file mode 100644 index c39493b07..000000000 --- a/base/quaternary2d/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a quaternary callback to elements in four two-dimensional nested - input arrays and assigns results to elements in a two-dimensional nested - output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing four input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Quaternary callback. - - Examples - -------- - > function fcn( x, y, z, w ) { return x + y + z + w; }; - > var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shape = [ 2, 2 ]; - > {{alias}}( [ x, y, z, w, out ], shape, fcn ); - > out - [ [ 4.0, 8.0 ], [ 12.0, 16.0 ] ] - - See Also - -------- - diff --git a/base/quaternary2d/docs/types/index.d.ts b/base/quaternary2d/docs/types/index.d.ts deleted file mode 100644 index fa0a1d174..000000000 --- a/base/quaternary2d/docs/types/index.d.ts +++ /dev/null @@ -1,71 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Quaternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @returns result -*/ -type Quaternary = ( v1: T, v2: U, v3: V, v4: W ) => X; - -/** -* Applies a quaternary callback to elements in four two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing four input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - quaternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = ones2d( shape ); -* var w = ones2d( shape ); -* var out = zeros2d( shape ); -* -* quaternary2d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] -*/ -declare function quaternary2d( arrays: [ Array2D, Array2D, Array2D, Array2D, Array2D ], shape: Shape2D, fcn: Quaternary ): void; - - -// EXPORTS // - -export = quaternary2d; diff --git a/base/quaternary2d/docs/types/test.ts b/base/quaternary2d/docs/types/test.ts deleted file mode 100644 index 8bec160c2..000000000 --- a/base/quaternary2d/docs/types/test.ts +++ /dev/null @@ -1,106 +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. -*/ - -import quaternary2d = require( './index' ); - -/** -* Quaternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number ): number { - return x + y + z + w; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - quaternary2d( [ x, y, z, w, out ], [ 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - quaternary2d( 'abc', [ 2, 2 ], fcn ); // $ExpectError - quaternary2d( 3.14, [ 2, 2 ], fcn ); // $ExpectError - quaternary2d( true, [ 2, 2 ], fcn ); // $ExpectError - quaternary2d( false, [ 2, 2 ], fcn ); // $ExpectError - quaternary2d( null, [ 2, 2 ], fcn ); // $ExpectError - quaternary2d( [ '1' ], [ 2, 2 ], fcn ); // $ExpectError - quaternary2d( {}, [ 2, 2 ], fcn ); // $ExpectError - quaternary2d( ( x: number ): number => x, [ 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - quaternary2d( [ x, y, z, w, out ], 'abc', fcn ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], 3.14, fcn ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], true, fcn ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], false, fcn ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], null, fcn ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], [ '1' ], fcn ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], {}, fcn ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - quaternary2d( [ x, y, z, w, out ], [ 2, 2 ], 'abc' ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], [ 2, 2 ], 3.14 ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], [ 2, 2 ], true ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], [ 2, 2 ], false ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], [ 2, 2 ], null ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], [ 2, 2 ], [ '1' ] ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], [ 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - quaternary2d(); // $ExpectError - quaternary2d( [ x, y, z, w, out ] ); // $ExpectError - quaternary2d( [ x, y, z, w, out ], [ 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/quaternary2d/examples/index.js b/base/quaternary2d/examples/index.js deleted file mode 100644 index 47d5689b7..000000000 --- a/base/quaternary2d/examples/index.js +++ /dev/null @@ -1,45 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary2d = require( './../lib' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros2d( shape ); -console.log( out ); - -quaternary2d( [ x, y, z, w, out ], shape, add ); -console.log( out ); diff --git a/base/quaternary2d/lib/index.js b/base/quaternary2d/lib/index.js deleted file mode 100644 index 61e538415..000000000 --- a/base/quaternary2d/lib/index.js +++ /dev/null @@ -1,53 +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'; - -/** -* Apply a quaternary callback to elements in four two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/quaternary2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add4' ); -* var quaternary2d = require( '@stdlib/array/base/quaternary2d' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = ones2d( shape ); -* var w = ones2d( shape ); -* var out = zeros2d( shape ); -* -* quaternary2d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/quaternary2d/lib/main.js b/base/quaternary2d/lib/main.js deleted file mode 100644 index bb7ae8fd2..000000000 --- a/base/quaternary2d/lib/main.js +++ /dev/null @@ -1,94 +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'; - -// MAIN // - -/** -* Applies a quaternary callback to elements in four two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing four input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - quaternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = ones2d( shape ); -* var w = ones2d( shape ); -* var out = zeros2d( shape ); -* -* quaternary2d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] -*/ -function quaternary2d( arrays, shape, fcn ) { - var S0; - var S1; - var i0; - var i1; - var x0; - var y0; - var z0; - var w0; - var v0; - var x; - var y; - var z; - var w; - var v; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - v = arrays[ 4 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x[ i1 ]; - y0 = y[ i1 ]; - z0 = z[ i1 ]; - w0 = w[ i1 ]; - v0 = v[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] ); - } - } -} - - -// EXPORTS // - -module.exports = quaternary2d; diff --git a/base/quaternary2d/package.json b/base/quaternary2d/package.json deleted file mode 100644 index 22d0a4c0d..000000000 --- a/base/quaternary2d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/quaternary2d", - "version": "0.0.0", - "description": "Apply a quaternary callback to elements in four two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "quaternary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/quaternary2d/test/test.js b/base/quaternary2d/test/test.js deleted file mode 100644 index c22516dce..000000000 --- a/base/quaternary2d/test/test.js +++ /dev/null @@ -1,151 +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 zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof quaternary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ]; - w = [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ]; - out = zeros2d( shape ); - - expected = [ - [ 28.0, 32.0 ], - [ 36.0, 40.0 ] - ]; - quaternary2d( [ x, y, z, w, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ]; - w = [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ]; - out = zeros2d( shape ); - - expected = zeros2d( shape ); - quaternary2d( [ x, y, z, w, out ], [ 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ]; - w = [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ]; - out = zeros2d( shape ); - - expected = zeros2d( shape ); - quaternary2d( [ x, y, z, w, out ], [ 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/quaternary3d/README.md b/base/quaternary3d/README.md deleted file mode 100644 index 31c38f678..000000000 --- a/base/quaternary3d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# quaternary3d - -> Apply a quaternary callback to elements in four three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var quaternary3d = require( '@stdlib/array/base/quaternary3d' ); -``` - -#### quaternary3d( arrays, shape, fcn ) - -Applies a quaternary callback to elements in four three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add4' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); - -var x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; -var out = zeros3d( [ 1, 2, 2 ] ); - -var shape = [ 1, 2, 2 ]; - -quaternary3d( [ x, x, x, x, out ], shape, add ); -// out => [ [ [ 4.0, 8.0 ], [ 12.0, 16.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing four input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: quaternary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary3d = require( '@stdlib/array/base/quaternary3d' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros3d( shape ); -console.log( out ); - -quaternary3d( [ x, y, z, w, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/quaternary3d/benchmark/benchmark.js b/base/quaternary3d/benchmark/benchmark.js deleted file mode 100644 index 1847c22ea..000000000 --- a/base/quaternary3d/benchmark/benchmark.js +++ /dev/null @@ -1,125 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var pkg = require( './../package.json' ).name; -var quaternary3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - var w; - - x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - w = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros3d( shape ); - - arrays = [ x, y, z, w, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - quaternary3d( arrays, shape, add ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 4 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 4 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/quaternary3d/docs/repl.txt b/base/quaternary3d/docs/repl.txt deleted file mode 100644 index a4bf89ec6..000000000 --- a/base/quaternary3d/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a quaternary callback to elements in four three-dimensional nested - input arrays and assigns results to elements in a three-dimensional nested - output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing four input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Quaternary callback. - - Examples - -------- - > function fcn( x, y, z, w ) { return x + y + z + w; }; - > var x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - > var shape = [ 1, 2, 2 ]; - > {{alias}}( [ x, y, z, w, out ], shape, fcn ); - > out - [ [ [ 4.0, 8.0 ], [ 12.0, 16.0 ] ] ] - - See Also - -------- - diff --git a/base/quaternary3d/docs/types/index.d.ts b/base/quaternary3d/docs/types/index.d.ts deleted file mode 100644 index ed771d8ab..000000000 --- a/base/quaternary3d/docs/types/index.d.ts +++ /dev/null @@ -1,71 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Quaternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @returns result -*/ -type Quaternary = ( v1: T, v2: U, v3: V, v4: W ) => X; - -/** -* Applies a quaternary callback to elements in four three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing four input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - quaternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = ones3d( shape ); -* var w = ones3d( shape ); -* var out = zeros3d( shape ); -* -* quaternary3d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] -*/ -declare function quaternary3d( arrays: [ Array3D, Array3D, Array3D, Array3D, Array3D ], shape: Shape3D, fcn: Quaternary ): void; - - -// EXPORTS // - -export = quaternary3d; diff --git a/base/quaternary3d/docs/types/test.ts b/base/quaternary3d/docs/types/test.ts deleted file mode 100644 index 4386b5328..000000000 --- a/base/quaternary3d/docs/types/test.ts +++ /dev/null @@ -1,106 +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. -*/ - -import quaternary3d = require( './index' ); - -/** -* Quaternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number ): number { - return x + y + z + w; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - quaternary3d( [ x, y, z, w, out ], [ 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - quaternary3d( 'abc', [ 1, 2, 2 ], fcn ); // $ExpectError - quaternary3d( 3.14, [ 1, 2, 2 ], fcn ); // $ExpectError - quaternary3d( true, [ 1, 2, 2 ], fcn ); // $ExpectError - quaternary3d( false, [ 1, 2, 2 ], fcn ); // $ExpectError - quaternary3d( null, [ 1, 2, 2 ], fcn ); // $ExpectError - quaternary3d( [ '1' ], [ 1, 2, 2 ], fcn ); // $ExpectError - quaternary3d( {}, [ 1, 2, 2 ], fcn ); // $ExpectError - quaternary3d( ( x: number ): number => x, [ 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - quaternary3d( [ x, y, z, w, out ], 'abc', fcn ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], 3.14, fcn ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], true, fcn ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], false, fcn ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], null, fcn ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], [ '1' ], fcn ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], {}, fcn ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - quaternary3d( [ x, y, z, w, out ], [ 1, 2, 2 ], 'abc' ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], [ 1, 2, 2 ], 3.14 ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], [ 1, 2, 2 ], true ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], [ 1, 2, 2 ], false ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], [ 1, 2, 2 ], null ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], [ 1, 2, 2 ], [ '1' ] ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], [ 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - quaternary3d(); // $ExpectError - quaternary3d( [ x, y, z, w, out ] ); // $ExpectError - quaternary3d( [ x, y, z, w, out ], [ 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/quaternary3d/examples/index.js b/base/quaternary3d/examples/index.js deleted file mode 100644 index a98390bb5..000000000 --- a/base/quaternary3d/examples/index.js +++ /dev/null @@ -1,45 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary3d = require( './../lib' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros3d( shape ); -console.log( out ); - -quaternary3d( [ x, y, z, w, out ], shape, add ); -console.log( out ); diff --git a/base/quaternary3d/lib/index.js b/base/quaternary3d/lib/index.js deleted file mode 100644 index 27574518a..000000000 --- a/base/quaternary3d/lib/index.js +++ /dev/null @@ -1,53 +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'; - -/** -* Apply a quaternary callback to elements in four three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/quaternary3d -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add4' ); -* var quaternary3d = require( '@stdlib/array/base/quaternary3d' ); -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = ones3d( shape ); -* var w = ones3d( shape ); -* var out = zeros3d( shape ); -* -* quaternary3d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/quaternary3d/lib/main.js b/base/quaternary3d/lib/main.js deleted file mode 100644 index 04e678dbc..000000000 --- a/base/quaternary3d/lib/main.js +++ /dev/null @@ -1,109 +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'; - -// MAIN // - -/** -* Applies a quaternary callback to elements in four three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>} arrays - array-like object containing four input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - quaternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = ones3d( shape ); -* var w = ones3d( shape ); -* var out = zeros3d( shape ); -* -* quaternary3d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] -*/ -function quaternary3d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var x0; - var y0; - var z0; - var w0; - var v0; - var x1; - var y1; - var z1; - var w1; - var v1; - var x; - var y; - var z; - var w; - var v; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - v = arrays[ 4 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x[ i2 ]; - y1 = y[ i2 ]; - z1 = z[ i2 ]; - w1 = w[ i2 ]; - v1 = v[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - w0 = w1[ i1 ]; - v0 = v1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] ); - } - } - } -} - - -// EXPORTS // - -module.exports = quaternary3d; diff --git a/base/quaternary3d/package.json b/base/quaternary3d/package.json deleted file mode 100644 index 37fb2dfbd..000000000 --- a/base/quaternary3d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/quaternary3d", - "version": "0.0.0", - "description": "Apply a quaternary callback to elements in four three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "quaternary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/quaternary3d/test/test.js b/base/quaternary3d/test/test.js deleted file mode 100644 index 19f39ba23..000000000 --- a/base/quaternary3d/test/test.js +++ /dev/null @@ -1,224 +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 zeros3d = require( './../../../base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof quaternary3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - w = [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = [ - [ - [ 28.0, 32.0 ], - [ 36.0, 40.0 ] - ] - ]; - quaternary3d( [ x, y, z, w, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - w = [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = zeros3d( shape ); - quaternary3d( [ x, y, z, w, out ], [ 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - w = [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = zeros3d( shape ); - quaternary3d( [ x, y, z, w, out ], [ 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - w = [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = zeros3d( shape ); - quaternary3d( [ x, y, z, w, out ], [ 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/quaternary4d/README.md b/base/quaternary4d/README.md deleted file mode 100644 index e4453e8a9..000000000 --- a/base/quaternary4d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# quaternary4d - -> Apply a quaternary callback to elements in four four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var quaternary4d = require( '@stdlib/array/base/quaternary4d' ); -``` - -#### quaternary4d( arrays, shape, fcn ) - -Applies a quaternary callback to elements in four four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add4' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); - -var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; -var out = zeros4d( [ 1, 1, 2, 2 ] ); - -var shape = [ 1, 1, 2, 2 ]; - -quaternary4d( [ x, x, x, x, out ], shape, add ); -// out => [ [ [ [ 4.0, 8.0 ], [ 12.0, 16.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing four input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: quaternary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary4d = require( '@stdlib/array/base/quaternary4d' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros4d( shape ); -console.log( out ); - -quaternary4d( [ x, y, z, w, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/quaternary4d/benchmark/benchmark.js b/base/quaternary4d/benchmark/benchmark.js deleted file mode 100644 index bfbc399bb..000000000 --- a/base/quaternary4d/benchmark/benchmark.js +++ /dev/null @@ -1,128 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var pkg = require( './../package.json' ).name; -var quaternary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - var w; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - w = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros4d( shape ); - - arrays = [ x, y, z, w, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - quaternary4d( arrays, shape, add ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/quaternary4d/docs/repl.txt b/base/quaternary4d/docs/repl.txt deleted file mode 100644 index 72d95dd5a..000000000 --- a/base/quaternary4d/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a quaternary callback to elements in four four-dimensional nested - input arrays and assigns results to elements in a four-dimensional nested - output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing four input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Quaternary callback. - - Examples - -------- - > function fcn( x, y, z, w ) { return x + y + z + w; }; - > var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > {{alias}}( [ x, y, z, w, out ], shape, fcn ); - > out - [ [ [ [ 4.0, 8.0 ], [ 12.0, 16.0 ] ] ] ] - - See Also - -------- - diff --git a/base/quaternary4d/docs/types/index.d.ts b/base/quaternary4d/docs/types/index.d.ts deleted file mode 100644 index 82a8bfe68..000000000 --- a/base/quaternary4d/docs/types/index.d.ts +++ /dev/null @@ -1,71 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Quaternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @returns result -*/ -type Quaternary = ( v1: T, v2: U, v3: V, v4: W ) => X; - -/** -* Applies a quaternary callback to elements in four four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing four input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - quaternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = ones4d( shape ); -* var w = ones4d( shape ); -* var out = zeros4d( shape ); -* -* quaternary4d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ] -*/ -declare function quaternary4d( arrays: [ Array4D, Array4D, Array4D, Array4D, Array4D ], shape: Shape4D, fcn: Quaternary ): void; - - -// EXPORTS // - -export = quaternary4d; diff --git a/base/quaternary4d/docs/types/test.ts b/base/quaternary4d/docs/types/test.ts deleted file mode 100644 index 5ea2197a8..000000000 --- a/base/quaternary4d/docs/types/test.ts +++ /dev/null @@ -1,106 +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. -*/ - -import quaternary4d = require( './index' ); - -/** -* Quaternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number ): number { - return x + y + z + w; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - quaternary4d( [ x, y, z, w, out ], [ 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - quaternary4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - quaternary4d( [ x, y, z, w, out ], 'abc', fcn ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], 3.14, fcn ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], true, fcn ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], false, fcn ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], null, fcn ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], [ '1' ], fcn ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], {}, fcn ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - quaternary4d( [ x, y, z, w, out ], [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], [ 1, 1, 2, 2 ], true ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], [ 1, 1, 2, 2 ], false ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], [ 1, 1, 2, 2 ], null ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], [ 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - quaternary4d(); // $ExpectError - quaternary4d( [ x, y, z, w, out ] ); // $ExpectError - quaternary4d( [ x, y, z, w, out ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/quaternary4d/examples/index.js b/base/quaternary4d/examples/index.js deleted file mode 100644 index a2366f6ce..000000000 --- a/base/quaternary4d/examples/index.js +++ /dev/null @@ -1,45 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros4d( shape ); -console.log( out ); - -quaternary4d( [ x, y, z, w, out ], shape, add ); -console.log( out ); diff --git a/base/quaternary4d/lib/index.js b/base/quaternary4d/lib/index.js deleted file mode 100644 index 515ea87a6..000000000 --- a/base/quaternary4d/lib/index.js +++ /dev/null @@ -1,53 +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'; - -/** -* Apply a quaternary callback to elements in four four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/quaternary4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add4' ); -* var quaternary4d = require( '@stdlib/array/base/quaternary4d' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = ones4d( shape ); -* var w = ones4d( shape ); -* var out = zeros4d( shape ); -* -* quaternary4d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/quaternary4d/lib/main.js b/base/quaternary4d/lib/main.js deleted file mode 100644 index 68fb3b487..000000000 --- a/base/quaternary4d/lib/main.js +++ /dev/null @@ -1,124 +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'; - -// MAIN // - -/** -* Applies a quaternary callback to elements in four four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>>} arrays - array-like object containing four input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - quaternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = ones4d( shape ); -* var w = ones4d( shape ); -* var out = zeros4d( shape ); -* -* quaternary4d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ] -*/ -function quaternary4d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var z0; - var w0; - var v0; - var x1; - var y1; - var z1; - var w1; - var v1; - var x2; - var y2; - var z2; - var w2; - var v2; - var x; - var y; - var z; - var w; - var v; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - v = arrays[ 4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - z2 = z[ i3 ]; - w2 = w[ i3 ]; - v2 = v[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - z1 = z2[ i2 ]; - w1 = w2[ i2 ]; - v1 = v2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - w0 = w1[ i1 ]; - v0 = v1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] ); - } - } - } - } -} - - -// EXPORTS // - -module.exports = quaternary4d; diff --git a/base/quaternary4d/package.json b/base/quaternary4d/package.json deleted file mode 100644 index 1a4274b5f..000000000 --- a/base/quaternary4d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/quaternary4d", - "version": "0.0.0", - "description": "Apply a quaternary callback to elements in four four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "quaternary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/quaternary4d/test/test.js b/base/quaternary4d/test/test.js deleted file mode 100644 index 3cef7180f..000000000 --- a/base/quaternary4d/test/test.js +++ /dev/null @@ -1,313 +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 zeros4d = require( './../../../base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof quaternary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = [ - [ - [ - [ 28.0, 32.0 ], - [ 36.0, 40.0 ] - ] - ] - ]; - quaternary4d( [ x, y, z, w, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - quaternary4d( [ x, y, z, w, out ], [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - quaternary4d( [ x, y, z, w, out ], [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - quaternary4d( [ x, y, z, w, out ], [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - quaternary4d( [ x, y, z, w, out ], [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/quaternary5d/README.md b/base/quaternary5d/README.md deleted file mode 100644 index ec12b0284..000000000 --- a/base/quaternary5d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# quaternary5d - -> Apply a quaternary callback to elements in four five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var quaternary5d = require( '@stdlib/array/base/quaternary5d' ); -``` - -#### quaternary5d( arrays, shape, fcn ) - -Applies a quaternary callback to elements in four five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add4' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); - -var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; -var out = zeros5d( [ 1, 1, 1, 2, 2 ] ); - -var shape = [ 1, 1, 1, 2, 2 ]; - -quaternary5d( [ x, x, x, x, out ], shape, add ); -// out => [ [ [ [ [ 4.0, 8.0 ], [ 12.0, 16.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing four input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: quaternary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary5d = require( '@stdlib/array/base/quaternary5d' ); - -var shape = [ 1, 1, 3, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros5d( shape ); -console.log( out ); - -quaternary5d( [ x, y, z, w, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/quaternary5d/benchmark/benchmark.js b/base/quaternary5d/benchmark/benchmark.js deleted file mode 100644 index 3d1bf66d2..000000000 --- a/base/quaternary5d/benchmark/benchmark.js +++ /dev/null @@ -1,131 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var pkg = require( './../package.json' ).name; -var quaternary5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - var w; - - x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - w = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros5d( shape ); - - arrays = [ x, y, z, w, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - quaternary5d( arrays, shape, add ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 4 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/quaternary5d/docs/repl.txt b/base/quaternary5d/docs/repl.txt deleted file mode 100644 index 620c368be..000000000 --- a/base/quaternary5d/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a quaternary callback to elements in four five-dimensional nested - input arrays and assigns results to elements in a five-dimensional nested - output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing four input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Quaternary callback. - - Examples - -------- - > function fcn( x, y, z, w ) { return x + y + z + w; }; - > var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shape = [ 1, 1, 1, 2, 2 ]; - > {{alias}}( [ x, y, z, w, out ], shape, fcn ); - > out - [ [ [ [ [ 4.0, 8.0 ], [ 12.0, 16.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/quaternary5d/docs/types/index.d.ts b/base/quaternary5d/docs/types/index.d.ts deleted file mode 100644 index 6b56cdef7..000000000 --- a/base/quaternary5d/docs/types/index.d.ts +++ /dev/null @@ -1,71 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Quaternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @returns result -*/ -type Quaternary = ( v1: T, v2: U, v3: V, v4: W ) => X; - -/** -* Applies a quaternary callback to elements in four five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing four input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - quaternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = ones5d( shape ); -* var w = ones5d( shape ); -* var out = zeros5d( shape ); -* -* quaternary5d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ] ] -*/ -declare function quaternary5d( arrays: [ Array5D, Array5D, Array5D, Array5D, Array5D ], shape: Shape5D, fcn: Quaternary ): void; - - -// EXPORTS // - -export = quaternary5d; diff --git a/base/quaternary5d/docs/types/test.ts b/base/quaternary5d/docs/types/test.ts deleted file mode 100644 index 58613d37a..000000000 --- a/base/quaternary5d/docs/types/test.ts +++ /dev/null @@ -1,106 +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. -*/ - -import quaternary5d = require( './index' ); - -/** -* Quaternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number ): number { - return x + y + z + w; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - quaternary5d( 'abc', [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary5d( 3.14, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary5d( true, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary5d( false, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary5d( null, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary5d( [ '1' ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary5d( {}, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quaternary5d( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - quaternary5d( [ x, y, z, w, out ], 'abc', fcn ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], 3.14, fcn ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], true, fcn ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], false, fcn ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], null, fcn ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], [ '1' ], fcn ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], {}, fcn ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 1, 2, 2 ], 'abc' ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 1, 2, 2 ], 3.14 ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 1, 2, 2 ], true ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 1, 2, 2 ], false ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 1, 2, 2 ], null ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - quaternary5d(); // $ExpectError - quaternary5d( [ x, y, z, w, out ] ); // $ExpectError - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/quaternary5d/examples/index.js b/base/quaternary5d/examples/index.js deleted file mode 100644 index bfab69c98..000000000 --- a/base/quaternary5d/examples/index.js +++ /dev/null @@ -1,45 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary5d = require( './../lib' ); - -var shape = [ 1, 1, 3, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var out = zeros5d( shape ); -console.log( out ); - -quaternary5d( [ x, y, z, w, out ], shape, add ); -console.log( out ); diff --git a/base/quaternary5d/lib/index.js b/base/quaternary5d/lib/index.js deleted file mode 100644 index 1d2526b5c..000000000 --- a/base/quaternary5d/lib/index.js +++ /dev/null @@ -1,53 +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'; - -/** -* Apply a quaternary callback to elements in four five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/quaternary5d -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add4' ); -* var quaternary5d = require( '@stdlib/array/base/quaternary5d' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = ones5d( shape ); -* var w = ones5d( shape ); -* var out = zeros5d( shape ); -* -* quaternary5d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/quaternary5d/lib/main.js b/base/quaternary5d/lib/main.js deleted file mode 100644 index d1f0f70a9..000000000 --- a/base/quaternary5d/lib/main.js +++ /dev/null @@ -1,139 +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'; - -// MAIN // - -/** -* Applies a quaternary callback to elements in four five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>>} arrays - array-like object containing four input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - quaternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add4' ); -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = ones5d( shape ); -* var w = ones5d( shape ); -* var out = zeros5d( shape ); -* -* quaternary5d( [ x, y, z, w, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ] ] -*/ -function quaternary5d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var x0; - var y0; - var z0; - var w0; - var v0; - var x1; - var y1; - var z1; - var w1; - var v1; - var x2; - var y2; - var z2; - var w2; - var v2; - var x3; - var y3; - var z3; - var w3; - var v3; - var x; - var y; - var z; - var w; - var v; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - v = arrays[ 4 ]; - for ( i4 = 0; i4 < S4; i4++ ) { - x3 = x[ i4 ]; - y3 = y[ i4 ]; - z3 = z[ i4 ]; - w3 = w[ i4 ]; - v3 = v[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x3[ i3 ]; - y2 = y3[ i3 ]; - z2 = z3[ i3 ]; - w2 = w3[ i3 ]; - v2 = v3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - z1 = z2[ i2 ]; - w1 = w2[ i2 ]; - v1 = v2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - w0 = w1[ i1 ]; - v0 = v1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] ); // eslint-disable-line max-len - } - } - } - } - } -} - - -// EXPORTS // - -module.exports = quaternary5d; diff --git a/base/quaternary5d/package.json b/base/quaternary5d/package.json deleted file mode 100644 index 0a37c98fa..000000000 --- a/base/quaternary5d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/quaternary5d", - "version": "0.0.0", - "description": "Apply a quaternary callback to elements in four five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "quaternary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/quaternary5d/test/test.js b/base/quaternary5d/test/test.js deleted file mode 100644 index 261ae0e52..000000000 --- a/base/quaternary5d/test/test.js +++ /dev/null @@ -1,418 +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 zeros5d = require( './../../../base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add4' ); -var quaternary5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof quaternary5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = [ - [ - [ - [ - [ 28.0, 32.0 ], - [ 36.0, 40.0 ] - ] - ] - ] - ]; - quaternary5d( [ x, y, z, w, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - quaternary5d( [ x, y, z, w, out ], [ 0, 1, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - quaternary5d( [ x, y, z, w, out ], [ 1, 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - quaternary5d( [ x, y, z, w, out ], [ 1, 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/quinary2d/README.md b/base/quinary2d/README.md deleted file mode 100644 index 3419350f5..000000000 --- a/base/quinary2d/README.md +++ /dev/null @@ -1,131 +0,0 @@ - - -# quinary2d - -> Apply a quinary callback to elements in five two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var quinary2d = require( '@stdlib/array/base/quinary2d' ); -``` - -#### quinary2d( arrays, shape, fcn ) - -Applies a quinary callback to elements in five two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add5' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); - -var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; -var out = zeros2d( [ 2, 2 ] ); - -var shape = [ 2, 2 ]; - -quinary2d( [ x, x, x, x, x, out ], shape, add ); -// out => [ [ 5.0, 10.0 ], [ 15.0, 20.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing five input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: quinary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary2d = require( '@stdlib/array/base/quinary2d' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros2d( shape ); -console.log( out ); - -quinary2d( [ x, y, z, w, v, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/quinary2d/benchmark/benchmark.js b/base/quinary2d/benchmark/benchmark.js deleted file mode 100644 index 8bafae788..000000000 --- a/base/quinary2d/benchmark/benchmark.js +++ /dev/null @@ -1,124 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var pkg = require( './../package.json' ).name; -var quinary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - var w; - var v; - - x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - w = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - v = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros2d( shape ); - - arrays = [ x, y, z, w, v, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - quinary2d( arrays, shape, add ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 5 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 5 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/quinary2d/docs/repl.txt b/base/quinary2d/docs/repl.txt deleted file mode 100644 index 2a8033224..000000000 --- a/base/quinary2d/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a quinary callback to elements in five two-dimensional nested - input arrays and assigns results to elements in a two-dimensional nested - output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing five input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Quinary callback. - - Examples - -------- - > function fcn( x, y, z, w, v ) { return x + y + z + w + v; }; - > var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var v = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shape = [ 2, 2 ]; - > {{alias}}( [ x, y, z, w, v, out ], shape, fcn ); - > out - [ [ 5.0, 10.0 ], [ 15.0, 20.0 ] ] - - See Also - -------- - diff --git a/base/quinary2d/docs/types/index.d.ts b/base/quinary2d/docs/types/index.d.ts deleted file mode 100644 index 7bfa16171..000000000 --- a/base/quinary2d/docs/types/index.d.ts +++ /dev/null @@ -1,73 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Quinary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @param v5 - element from fifth input array -* @returns result -*/ -type Quinary = ( v1: T, v2: U, v3: V, v4: W, v5: X ) => Y; - -/** -* Applies a quinary callback to elements in five two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing five input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - quinary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add5' ); -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = ones2d( shape ); -* var w = ones2d( shape ); -* var v = ones2d( shape ); -* var out = zeros2d( shape ); -* -* quinary2d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] -*/ -declare function quinary2d( arrays: [ Array2D, Array2D, Array2D, Array2D, Array2D, Array2D ], shape: Shape2D, fcn: Quinary ): void; - - -// EXPORTS // - -export = quinary2d; diff --git a/base/quinary2d/docs/types/test.ts b/base/quinary2d/docs/types/test.ts deleted file mode 100644 index f830a8820..000000000 --- a/base/quinary2d/docs/types/test.ts +++ /dev/null @@ -1,111 +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. -*/ - -import quinary2d = require( './index' ); - -/** -* Quinary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @param v - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number, v: number ): number { - return x + y + z + w + v; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const v = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - quinary2d( [ x, y, z, w, v, out ], [ 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - quinary2d( 'abc', [ 2, 2 ], fcn ); // $ExpectError - quinary2d( 3.14, [ 2, 2 ], fcn ); // $ExpectError - quinary2d( true, [ 2, 2 ], fcn ); // $ExpectError - quinary2d( false, [ 2, 2 ], fcn ); // $ExpectError - quinary2d( null, [ 2, 2 ], fcn ); // $ExpectError - quinary2d( [ '1' ], [ 2, 2 ], fcn ); // $ExpectError - quinary2d( {}, [ 2, 2 ], fcn ); // $ExpectError - quinary2d( ( x: number ): number => x, [ 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const v = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - quinary2d( [ x, y, z, w, v, out ], 'abc', fcn ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], 3.14, fcn ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], true, fcn ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], false, fcn ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], null, fcn ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], [ '1' ], fcn ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], {}, fcn ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const v = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - quinary2d( [ x, y, z, w, v, out ], [ 2, 2 ], 'abc' ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], [ 2, 2 ], 3.14 ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], [ 2, 2 ], true ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], [ 2, 2 ], false ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], [ 2, 2 ], null ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], [ 2, 2 ], [ '1' ] ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], [ 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const w = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const v = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - quinary2d(); // $ExpectError - quinary2d( [ x, y, z, w, v, out ] ); // $ExpectError - quinary2d( [ x, y, z, w, v, out ], [ 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/quinary2d/examples/index.js b/base/quinary2d/examples/index.js deleted file mode 100644 index 9d0908b45..000000000 --- a/base/quinary2d/examples/index.js +++ /dev/null @@ -1,48 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary2d = require( './../lib' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros2d( shape ); -console.log( out ); - -quinary2d( [ x, y, z, w, v, out ], shape, add ); -console.log( out ); diff --git a/base/quinary2d/lib/index.js b/base/quinary2d/lib/index.js deleted file mode 100644 index 713241b24..000000000 --- a/base/quinary2d/lib/index.js +++ /dev/null @@ -1,54 +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'; - -/** -* Apply a quinary callback to elements in five two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/quinary2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add5' ); -* var quinary2d = require( '@stdlib/array/base/quinary2d' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = ones2d( shape ); -* var w = ones2d( shape ); -* var v = ones2d( shape ); -* var out = zeros2d( shape ); -* -* quinary2d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/quinary2d/lib/main.js b/base/quinary2d/lib/main.js deleted file mode 100644 index 31683944a..000000000 --- a/base/quinary2d/lib/main.js +++ /dev/null @@ -1,99 +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'; - -// MAIN // - -/** -* Applies a quinary callback to elements in five two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing five input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - quinary callback -* @returns {void} -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var add = require( '@stdlib/number/float64/base/add5' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = ones2d( shape ); -* var w = ones2d( shape ); -* var v = ones2d( shape ); -* var out = zeros2d( shape ); -* -* quinary2d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] -*/ -function quinary2d( arrays, shape, fcn ) { - var S0; - var S1; - var i0; - var i1; - var x0; - var y0; - var z0; - var w0; - var u0; - var v0; - var x; - var y; - var z; - var w; - var u; - var v; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - u = arrays[ 4 ]; - v = arrays[ 5 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x[ i1 ]; - y0 = y[ i1 ]; - z0 = z[ i1 ]; - w0 = w[ i1 ]; - u0 = u[ i1 ]; - v0 = v[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] ); - } - } -} - - -// EXPORTS // - -module.exports = quinary2d; diff --git a/base/quinary2d/package.json b/base/quinary2d/package.json deleted file mode 100644 index 455de4588..000000000 --- a/base/quinary2d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/quinary2d", - "version": "0.0.0", - "description": "Apply a quinary callback to elements in five two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "quinary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/quinary2d/test/test.js b/base/quinary2d/test/test.js deleted file mode 100644 index 3f7c5f2d8..000000000 --- a/base/quinary2d/test/test.js +++ /dev/null @@ -1,166 +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 zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof quinary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ]; - w = [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ]; - v = [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ]; - out = zeros2d( shape ); - - expected = [ - [ 45.0, 50.0 ], - [ 55.0, 60.0 ] - ]; - quinary2d( [ x, y, z, w, v, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ]; - w = [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ]; - v = [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ]; - out = zeros2d( shape ); - - expected = zeros2d( shape ); - quinary2d( [ x, y, z, w, v, out ], [ 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ]; - w = [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ]; - v = [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ]; - out = zeros2d( shape ); - - expected = zeros2d( shape ); - quinary2d( [ x, y, z, w, v, out ], [ 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/quinary3d/README.md b/base/quinary3d/README.md deleted file mode 100644 index c91e53d82..000000000 --- a/base/quinary3d/README.md +++ /dev/null @@ -1,131 +0,0 @@ - - -# quinary3d - -> Apply a quinary callback to elements in five three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var quinary3d = require( '@stdlib/array/base/quinary3d' ); -``` - -#### quinary3d( arrays, shape, fcn ) - -Applies a quinary callback to elements in five three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add5' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); - -var x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; -var out = zeros3d( [ 1, 2, 2 ] ); - -var shape = [ 1, 2, 2 ]; - -quinary3d( [ x, x, x, x, x, out ], shape, add ); -// out => [ [ [ 5.0, 10.0 ], [ 15.0, 20.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing five input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: quinary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary3d = require( '@stdlib/array/base/quinary3d' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros3d( shape ); -console.log( out ); - -quinary3d( [ x, y, z, w, v, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/quinary3d/benchmark/benchmark.js b/base/quinary3d/benchmark/benchmark.js deleted file mode 100644 index 9f52d5b7a..000000000 --- a/base/quinary3d/benchmark/benchmark.js +++ /dev/null @@ -1,127 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var pkg = require( './../package.json' ).name; -var quinary3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - var w; - var v; - - x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - w = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - v = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros3d( shape ); - - arrays = [ x, y, z, w, v, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - quinary3d( arrays, shape, add ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 5 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 5 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/quinary3d/docs/repl.txt b/base/quinary3d/docs/repl.txt deleted file mode 100644 index 56f84137f..000000000 --- a/base/quinary3d/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a quinary callback to elements in five three-dimensional nested - input arrays and assigns results to elements in a three-dimensional nested - output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing five input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Quinary callback. - - Examples - -------- - > function fcn( x, y, z, w, v ) { return x + y + z + w + v; }; - > var x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var v = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - > var shape = [ 1, 2, 2 ]; - > {{alias}}( [ x, y, z, w, v, out ], shape, fcn ); - > out - [ [ [ 5.0, 10.0 ], [ 15.0, 20.0 ] ] ] - - See Also - -------- - diff --git a/base/quinary3d/docs/types/index.d.ts b/base/quinary3d/docs/types/index.d.ts deleted file mode 100644 index 55d1c5fd5..000000000 --- a/base/quinary3d/docs/types/index.d.ts +++ /dev/null @@ -1,73 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Quinary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @param v5 - element from fifth input array -* @returns result -*/ -type Quinary = ( v1: T, v2: U, v3: V, v4: W, v5: X ) => Y; - -/** -* Applies a quinary callback to elements in five three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing five input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - quinary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add5' ); -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = ones3d( shape ); -* var w = ones3d( shape ); -* var v = ones3d( shape ); -* var out = zeros3d( shape ); -* -* quinary3d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] -*/ -declare function quinary3d( arrays: [ Array3D, Array3D, Array3D, Array3D, Array3D, Array3D ], shape: Shape3D, fcn: Quinary ): void; - - -// EXPORTS // - -export = quinary3d; diff --git a/base/quinary3d/docs/types/test.ts b/base/quinary3d/docs/types/test.ts deleted file mode 100644 index 0f7e80d4c..000000000 --- a/base/quinary3d/docs/types/test.ts +++ /dev/null @@ -1,111 +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. -*/ - -import quinary3d = require( './index' ); - -/** -* Quinary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @param v - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number, v: number ): number { - return x + y + z + w + v; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const v = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - quinary3d( [ x, y, z, w, v, out ], [ 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - quinary3d( 'abc', [ 1, 2, 2 ], fcn ); // $ExpectError - quinary3d( 3.14, [ 1, 2, 2 ], fcn ); // $ExpectError - quinary3d( true, [ 1, 2, 2 ], fcn ); // $ExpectError - quinary3d( false, [ 1, 2, 2 ], fcn ); // $ExpectError - quinary3d( null, [ 1, 2, 2 ], fcn ); // $ExpectError - quinary3d( [ '1' ], [ 1, 2, 2 ], fcn ); // $ExpectError - quinary3d( {}, [ 1, 2, 2 ], fcn ); // $ExpectError - quinary3d( ( x: number ): number => x, [ 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const v = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - quinary3d( [ x, y, z, w, v, out ], 'abc', fcn ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], 3.14, fcn ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], true, fcn ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], false, fcn ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], null, fcn ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], [ '1' ], fcn ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], {}, fcn ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const v = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - quinary3d( [ x, y, z, w, v, out ], [ 1, 2, 2 ], 'abc' ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], [ 1, 2, 2 ], 3.14 ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], [ 1, 2, 2 ], true ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], [ 1, 2, 2 ], false ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], [ 1, 2, 2 ], null ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], [ 1, 2, 2 ], [ '1' ] ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], [ 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const w = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const v = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - quinary3d(); // $ExpectError - quinary3d( [ x, y, z, w, v, out ] ); // $ExpectError - quinary3d( [ x, y, z, w, v, out ], [ 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/quinary3d/examples/index.js b/base/quinary3d/examples/index.js deleted file mode 100644 index beb897e32..000000000 --- a/base/quinary3d/examples/index.js +++ /dev/null @@ -1,48 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary3d = require( './../lib' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros3d( shape ); -console.log( out ); - -quinary3d( [ x, y, z, w, v, out ], shape, add ); -console.log( out ); diff --git a/base/quinary3d/lib/index.js b/base/quinary3d/lib/index.js deleted file mode 100644 index 7412ccd58..000000000 --- a/base/quinary3d/lib/index.js +++ /dev/null @@ -1,54 +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'; - -/** -* Apply a quinary callback to elements in five three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/quinary3d -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add5' ); -* var quinary3d = require( '@stdlib/array/base/quinary3d' ); -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = ones3d( shape ); -* var w = ones3d( shape ); -* var v = ones3d( shape ); -* var out = zeros3d( shape ); -* -* quinary3d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/quinary3d/lib/main.js b/base/quinary3d/lib/main.js deleted file mode 100644 index e5a07897e..000000000 --- a/base/quinary3d/lib/main.js +++ /dev/null @@ -1,116 +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'; - -// MAIN // - -/** -* Applies a quinary callback to elements in five three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>} arrays - array-like object containing five input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - quinary callback -* @returns {void} -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var add = require( '@stdlib/number/float64/base/add5' ); -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = ones3d( shape ); -* var w = ones3d( shape ); -* var v = ones3d( shape ); -* var out = zeros3d( shape ); -* -* quinary3d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] -*/ -function quinary3d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var x0; - var y0; - var z0; - var w0; - var u0; - var v0; - var x1; - var y1; - var z1; - var w1; - var u1; - var v1; - var x; - var y; - var z; - var w; - var u; - var v; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - u = arrays[ 4 ]; - v = arrays[ 5 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x[ i2 ]; - y1 = y[ i2 ]; - z1 = z[ i2 ]; - w1 = w[ i2 ]; - u1 = u[ i2 ]; - v1 = v[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - w0 = w1[ i1 ]; - u0 = u1[ i1 ]; - v0 = v1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] ); // eslint-disable-line max-len - } - } - } -} - - -// EXPORTS // - -module.exports = quinary3d; diff --git a/base/quinary3d/package.json b/base/quinary3d/package.json deleted file mode 100644 index 15357eb93..000000000 --- a/base/quinary3d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/quinary3d", - "version": "0.0.0", - "description": "Apply a quinary callback to elements in five three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "quinary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/quinary3d/test/test.js b/base/quinary3d/test/test.js deleted file mode 100644 index 6f84ec5f2..000000000 --- a/base/quinary3d/test/test.js +++ /dev/null @@ -1,252 +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 zeros3d = require( './../../../base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof quinary3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - w = [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ]; - v = [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = [ - [ - [ 45.0, 50.0 ], - [ 55.0, 60.0 ] - ] - ]; - quinary3d( [ x, y, z, w, v, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - w = [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ]; - v = [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = zeros3d( shape ); - quinary3d( [ x, y, z, w, v, out ], [ 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - w = [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ]; - v = [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = zeros3d( shape ); - quinary3d( [ x, y, z, w, v, out ], [ 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - w = [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ]; - v = [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = zeros3d( shape ); - quinary3d( [ x, y, z, w, v, out ], [ 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/quinary4d/README.md b/base/quinary4d/README.md deleted file mode 100644 index 4532e2495..000000000 --- a/base/quinary4d/README.md +++ /dev/null @@ -1,131 +0,0 @@ - - -# quinary4d - -> Apply a quinary callback to elements in five four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var quinary4d = require( '@stdlib/array/base/quinary4d' ); -``` - -#### quinary4d( arrays, shape, fcn ) - -Applies a quinary callback to elements in five four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add5' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); - -var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; -var out = zeros4d( [ 1, 1, 2, 2 ] ); - -var shape = [ 1, 1, 2, 2 ]; - -quinary4d( [ x, x, x, x, x, out ], shape, add ); -// out => [ [ [ [ 5.0, 10.0 ], [ 15.0, 20.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing five input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: quinary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary4d = require( '@stdlib/array/base/quinary4d' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros4d( shape ); -console.log( out ); - -quinary4d( [ x, y, z, w, v, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/quinary4d/benchmark/benchmark.js b/base/quinary4d/benchmark/benchmark.js deleted file mode 100644 index 2e43b9237..000000000 --- a/base/quinary4d/benchmark/benchmark.js +++ /dev/null @@ -1,130 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var pkg = require( './../package.json' ).name; -var quinary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - var w; - var v; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - w = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - v = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros4d( shape ); - - arrays = [ x, y, z, w, v, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - quinary4d( arrays, shape, add ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 5 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 5 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/quinary4d/docs/repl.txt b/base/quinary4d/docs/repl.txt deleted file mode 100644 index c48982a5b..000000000 --- a/base/quinary4d/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a quinary callback to elements in five four-dimensional nested input - arrays and assigns results to elements in a four-dimensional nested output - array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing five input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Quinary callback. - - Examples - -------- - > function fcn( x, y, z, w, v ) { return x + y + z + w + v; }; - > var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var v = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > {{alias}}( [ x, y, z, w, v, out ], shape, fcn ); - > out - [ [ [ [ 5.0, 10.0 ], [ 15.0, 20.0 ] ] ] ] - - See Also - -------- - diff --git a/base/quinary4d/docs/types/index.d.ts b/base/quinary4d/docs/types/index.d.ts deleted file mode 100644 index 1392fdd17..000000000 --- a/base/quinary4d/docs/types/index.d.ts +++ /dev/null @@ -1,73 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Quinary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @param v5 - element from fifth input array -* @returns result -*/ -type Quinary = ( v1: T, v2: U, v3: V, v4: W, v5: X ) => Y; - -/** -* Applies a quinary callback to elements in five four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing five input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - quinary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add5' ); -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = ones4d( shape ); -* var w = ones4d( shape ); -* var v = ones4d( shape ); -* var out = zeros4d( shape ); -* -* quinary4d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] -*/ -declare function quinary4d( arrays: [ Array4D, Array4D, Array4D, Array4D, Array4D, Array4D ], shape: Shape4D, fcn: Quinary ): void; - - -// EXPORTS // - -export = quinary4d; diff --git a/base/quinary4d/docs/types/test.ts b/base/quinary4d/docs/types/test.ts deleted file mode 100644 index fc557984a..000000000 --- a/base/quinary4d/docs/types/test.ts +++ /dev/null @@ -1,111 +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. -*/ - -import quinary4d = require( './index' ); - -/** -* Quinary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @param v - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number, v: number ): number { - return x + y + z + w + v; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const v = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - quinary4d( [ x, y, z, w, v, out ], [ 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - quinary4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const v = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - quinary4d( [ x, y, z, w, v, out ], 'abc', fcn ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], 3.14, fcn ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], true, fcn ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], false, fcn ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], null, fcn ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], [ '1' ], fcn ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], {}, fcn ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const v = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - quinary4d( [ x, y, z, w, v, out ], [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], [ 1, 1, 2, 2 ], true ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], [ 1, 1, 2, 2 ], false ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], [ 1, 1, 2, 2 ], null ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], [ 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const w = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const v = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - quinary4d(); // $ExpectError - quinary4d( [ x, y, z, w, v, out ] ); // $ExpectError - quinary4d( [ x, y, z, w, v, out ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/quinary4d/examples/index.js b/base/quinary4d/examples/index.js deleted file mode 100644 index 9e741a26e..000000000 --- a/base/quinary4d/examples/index.js +++ /dev/null @@ -1,48 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros4d( shape ); -console.log( out ); - -quinary4d( [ x, y, z, w, v, out ], shape, add ); -console.log( out ); diff --git a/base/quinary4d/lib/index.js b/base/quinary4d/lib/index.js deleted file mode 100644 index 25f84de26..000000000 --- a/base/quinary4d/lib/index.js +++ /dev/null @@ -1,54 +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'; - -/** -* Apply a quinary callback to elements in five four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/quinary4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add5' ); -* var quinary4d = require( '@stdlib/array/base/quinary4d' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = ones4d( shape ); -* var w = ones4d( shape ); -* var v = ones4d( shape ); -* var out = zeros4d( shape ); -* -* quinary4d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/quinary4d/lib/main.js b/base/quinary4d/lib/main.js deleted file mode 100644 index cadc4d90e..000000000 --- a/base/quinary4d/lib/main.js +++ /dev/null @@ -1,133 +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'; - -// MAIN // - -/** -* Applies a quinary callback to elements in five four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>>} arrays - array-like object containing five input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - quinary callback -* @returns {void} -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var add = require( '@stdlib/number/float64/base/add5' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = ones4d( shape ); -* var w = ones4d( shape ); -* var v = ones4d( shape ); -* var out = zeros4d( shape ); -* -* quinary4d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] -*/ -function quinary4d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var z0; - var w0; - var u0; - var v0; - var x1; - var y1; - var z1; - var w1; - var u1; - var v1; - var x2; - var y2; - var z2; - var w2; - var u2; - var v2; - var x; - var y; - var z; - var w; - var u; - var v; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - u = arrays[ 4 ]; - v = arrays[ 5 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - z2 = z[ i3 ]; - w2 = w[ i3 ]; - u2 = u[ i3 ]; - v2 = v[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - z1 = z2[ i2 ]; - w1 = w2[ i2 ]; - u1 = u2[ i2 ]; - v1 = v2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - w0 = w1[ i1 ]; - u0 = u1[ i1 ]; - v0 = v1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] ); // eslint-disable-line max-len - } - } - } - } -} - - -// EXPORTS // - -module.exports = quinary4d; diff --git a/base/quinary4d/package.json b/base/quinary4d/package.json deleted file mode 100644 index 2db0f1556..000000000 --- a/base/quinary4d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/quinary4d", - "version": "0.0.0", - "description": "Apply a quinary callback to elements in five four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "quinary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/quinary4d/test/test.js b/base/quinary4d/test/test.js deleted file mode 100644 index 4c6220b90..000000000 --- a/base/quinary4d/test/test.js +++ /dev/null @@ -1,358 +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 zeros4d = require( './../../../base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof quinary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ]; - v = [ - [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = [ - [ - [ - [ 45.0, 50.0 ], - [ 55.0, 60.0 ] - ] - ] - ]; - quinary4d( [ x, y, z, w, v, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ]; - v = [ - [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - quinary4d( [ x, y, z, w, v, out ], [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ]; - v = [ - [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - quinary4d( [ x, y, z, w, v, out ], [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ]; - v = [ - [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - quinary4d( [ x, y, z, w, v, out ], [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - w = [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ]; - v = [ - [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - quinary4d( [ x, y, z, w, v, out ], [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/quinary5d/README.md b/base/quinary5d/README.md deleted file mode 100644 index b06200918..000000000 --- a/base/quinary5d/README.md +++ /dev/null @@ -1,131 +0,0 @@ - - -# quinary5d - -> Apply a quinary callback to elements in five five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var quinary5d = require( '@stdlib/array/base/quinary5d' ); -``` - -#### quinary5d( arrays, shape, fcn ) - -Applies a quinary callback to elements in five five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add5' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); - -var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; -var out = zeros5d( [ 1, 1, 1, 2, 2 ] ); - -var shape = [ 1, 1, 1, 2, 2 ]; - -quinary5d( [ x, x, x, x, x, out ], shape, add ); -// out => [ [ [ [ [ 5.0, 10.0 ], [ 15.0, 20.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing five input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: quinary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary5d = require( '@stdlib/array/base/quinary5d' ); - -var shape = [ 1, 1, 3, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros5d( shape ); -console.log( out ); - -quinary5d( [ x, y, z, w, v, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/quinary5d/benchmark/benchmark.js b/base/quinary5d/benchmark/benchmark.js deleted file mode 100644 index d07e024a9..000000000 --- a/base/quinary5d/benchmark/benchmark.js +++ /dev/null @@ -1,133 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var pkg = require( './../package.json' ).name; -var quinary5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - var w; - var v; - - x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - w = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - v = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros5d( shape ); - - arrays = [ x, y, z, w, v, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - quinary5d( arrays, shape, add ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 5 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 5 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/quinary5d/docs/repl.txt b/base/quinary5d/docs/repl.txt deleted file mode 100644 index c841e3cd3..000000000 --- a/base/quinary5d/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a quinary callback to elements in five five-dimensional nested input - arrays and assigns results to elements in a five-dimensional nested output - array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing five input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Quinary callback. - - Examples - -------- - > function fcn( x, y, z, w, v ) { return x + y + z + w + v; }; - > var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var v = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shape = [ 1, 1, 1, 2, 2 ]; - > {{alias}}( [ x, y, z, w, v, out ], shape, fcn ); - > out - [ [ [ [ [ 5.0, 10.0 ], [ 15.0, 20.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/quinary5d/docs/types/index.d.ts b/base/quinary5d/docs/types/index.d.ts deleted file mode 100644 index b36402226..000000000 --- a/base/quinary5d/docs/types/index.d.ts +++ /dev/null @@ -1,73 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Quinary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @param v4 - element from fourth input array -* @param v5 - element from fifth input array -* @returns result -*/ -type Quinary = ( v1: T, v2: U, v3: V, v4: W, v5: X ) => Y; - -/** -* Applies a quinary callback to elements in five five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing five input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - quinary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add5' ); -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = ones5d( shape ); -* var w = ones5d( shape ); -* var v = ones5d( shape ); -* var out = zeros5d( shape ); -* -* quinary5d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] ] -*/ -declare function quinary5d( arrays: [ Array5D, Array5D, Array5D, Array5D, Array5D, Array5D ], shape: Shape5D, fcn: Quinary ): void; - - -// EXPORTS // - -export = quinary5d; diff --git a/base/quinary5d/docs/types/test.ts b/base/quinary5d/docs/types/test.ts deleted file mode 100644 index 3e56966cc..000000000 --- a/base/quinary5d/docs/types/test.ts +++ /dev/null @@ -1,111 +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. -*/ - -import quinary5d = require( './index' ); - -/** -* Quinary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @param w - input value -* @param v - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number, w: number, v: number ): number { - return x + y + z + w + v; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const v = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - quinary5d( 'abc', [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary5d( 3.14, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary5d( true, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary5d( false, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary5d( null, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary5d( [ '1' ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary5d( {}, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - quinary5d( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const v = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - quinary5d( [ x, y, z, w, v, out ], 'abc', fcn ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], 3.14, fcn ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], true, fcn ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], false, fcn ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], null, fcn ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], [ '1' ], fcn ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], {}, fcn ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const v = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 1, 2, 2 ], 'abc' ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 1, 2, 2 ], 3.14 ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 1, 2, 2 ], true ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 1, 2, 2 ], false ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 1, 2, 2 ], null ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const w = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const v = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - quinary5d(); // $ExpectError - quinary5d( [ x, y, z, w, v, out ] ); // $ExpectError - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/quinary5d/examples/index.js b/base/quinary5d/examples/index.js deleted file mode 100644 index 5a2759901..000000000 --- a/base/quinary5d/examples/index.js +++ /dev/null @@ -1,48 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary5d = require( './../lib' ); - -var shape = [ 1, 1, 3, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var w = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( w ); - -var v = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( v ); - -var out = zeros5d( shape ); -console.log( out ); - -quinary5d( [ x, y, z, w, v, out ], shape, add ); -console.log( out ); diff --git a/base/quinary5d/lib/index.js b/base/quinary5d/lib/index.js deleted file mode 100644 index 88384f66c..000000000 --- a/base/quinary5d/lib/index.js +++ /dev/null @@ -1,54 +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'; - -/** -* Apply a quinary callback to elements in five five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/quinary5d -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add5' ); -* var quinary5d = require( '@stdlib/array/base/quinary5d' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = ones5d( shape ); -* var w = ones5d( shape ); -* var v = ones5d( shape ); -* var out = zeros5d( shape ); -* -* quinary5d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/quinary5d/lib/main.js b/base/quinary5d/lib/main.js deleted file mode 100644 index 7e7daa340..000000000 --- a/base/quinary5d/lib/main.js +++ /dev/null @@ -1,150 +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'; - -// MAIN // - -/** -* Applies a quinary callback to elements in five five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>>>} arrays - array-like object containing five input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - quinary callback -* @returns {void} -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var add = require( '@stdlib/number/float64/base/add5' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = ones5d( shape ); -* var w = ones5d( shape ); -* var v = ones5d( shape ); -* var out = zeros5d( shape ); -* -* quinary5d( [ x, y, z, w, v, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] ] -*/ -function quinary5d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var x0; - var y0; - var z0; - var w0; - var u0; - var v0; - var x1; - var y1; - var z1; - var w1; - var u1; - var v1; - var x2; - var y2; - var z2; - var w2; - var u2; - var v2; - var x3; - var y3; - var z3; - var w3; - var u3; - var v3; - var x; - var y; - var z; - var w; - var u; - var v; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - u = arrays[ 4 ]; - v = arrays[ 5 ]; - for ( i4 = 0; i4 < S4; i4++ ) { - x3 = x[ i4 ]; - y3 = y[ i4 ]; - z3 = z[ i4 ]; - w3 = w[ i4 ]; - u3 = u[ i4 ]; - v3 = v[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x3[ i3 ]; - y2 = y3[ i3 ]; - z2 = z3[ i3 ]; - w2 = w3[ i3 ]; - u2 = u3[ i3 ]; - v2 = v3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - z1 = z2[ i2 ]; - w1 = w2[ i2 ]; - u1 = u2[ i2 ]; - v1 = v2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - w0 = w1[ i1 ]; - u0 = u1[ i1 ]; - v0 = v1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] ); // eslint-disable-line max-len - } - } - } - } - } -} - - -// EXPORTS // - -module.exports = quinary5d; diff --git a/base/quinary5d/package.json b/base/quinary5d/package.json deleted file mode 100644 index 620cc2bf5..000000000 --- a/base/quinary5d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/quinary5d", - "version": "0.0.0", - "description": "Apply a quinary callback to elements in five five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "quinary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/quinary5d/test/test.js b/base/quinary5d/test/test.js deleted file mode 100644 index 91cad85c3..000000000 --- a/base/quinary5d/test/test.js +++ /dev/null @@ -1,484 +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 zeros5d = require( './../../../base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add5' ); -var quinary5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof quinary5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - v = [ - [ - [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = [ - [ - [ - [ - [ 45.0, 50.0 ], - [ 55.0, 60.0 ] - ] - ] - ] - ]; - quinary5d( [ x, y, z, w, v, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - v = [ - [ - [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - quinary5d( [ x, y, z, w, v, out ], [ 0, 1, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - v = [ - [ - [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - quinary5d( [ x, y, z, w, v, out ], [ 1, 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - v = [ - [ - [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - v = [ - [ - [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - var w; - var v; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - w = [ - [ - [ - [ - [ 13.0, 14.0 ], - [ 15.0, 16.0 ] - ] - ] - ] - ]; - v = [ - [ - [ - [ - [ 17.0, 18.0 ], - [ 19.0, 20.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - quinary5d( [ x, y, z, w, v, out ], [ 1, 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/reject/README.md b/base/reject/README.md deleted file mode 100644 index a94c2488c..000000000 --- a/base/reject/README.md +++ /dev/null @@ -1,150 +0,0 @@ - - -# reject - -> Return a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var reject = require( '@stdlib/array/base/reject' ); -``` - -#### reject( x, predicate\[, thisArg] ) - -Returns a shallow copy of an array containing only those elements which fail a test implemented by a `predicate` function. - -```javascript -function isPositive( value ) { - return ( value > 0 ); -} - -var x = [ 1, -2, -3, 4 ]; - -var out = reject( x, isPositive ); -// returns [ -2, -3 ] -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: input array. - -To set the `predicate` function execution context, provide a `thisArg`. - -```javascript -function predicate( value ) { - this.count += 1; - return ( value > 0 ); -} - -var x = [ 1, 2, -3, 4 ]; - -var context = { - 'count': 0 -}; - -var out = reject( x, predicate, context ); -// returns [ -3 ] - -var cnt = context.count; -// returns 4 -``` - -
- - - - - -
- -## Notes - -- The function performs a linear scan and **always** returns a generic array. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var reject = require( '@stdlib/array/base/reject' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = reject( x, naryFunction( isPositiveInteger, 1 ) ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/reject/benchmark/benchmark.length.js b/base/reject/benchmark/benchmark.length.js deleted file mode 100644 index c98051a8d..000000000 --- a/base/reject/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isNegativeInteger = require( '@stdlib/assert/is-negative-integer' ).isPrimitive; -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var reject = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = reject( x, isNegativeInteger ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/reject/docs/repl.txt b/base/reject/docs/repl.txt deleted file mode 100644 index b4ef0bf41..000000000 --- a/base/reject/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, predicate[, thisArg] ) - Returns a shallow copy of an array containing only those elements which fail - a test implemented by a predicate function. - - The predicate function is provided three arguments: - - - value: current array element. - - index: current array element index. - - arr: the input array. - - The function performs a linear scan and always returns a generic array. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - predicate: Function - Predicate function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: Array|TypedArray|Object - Output array. - - Examples - -------- - > function f( v ) { return ( v > 0 ); }; - > var x = [ 1, -2, -3, 4 ]; - > var out = {{alias}}( x, f ) - [ -2, -3 ] - - See Also - -------- - diff --git a/base/reject/docs/types/index.d.ts b/base/reject/docs/types/index.d.ts deleted file mode 100644 index eb2d6e829..000000000 --- a/base/reject/docs/types/index.d.ts +++ /dev/null @@ -1,343 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, Complex128Array, Complex64Array } from '@stdlib/types/array'; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @returns boolean indicating whether an element passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element passes a test -*/ -type Binary = ( this: U, value: T, index: number ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Ternary = ( this: U, value: T, index: number, arr: V ) => boolean; - -/** -* Returns a boolean indicating whether an element passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - input array -* @returns boolean indicating whether an element passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, -2.0, -3.0, 4.0 ] ); -* -* var out = reject( x, isPositiveNumber ); -* // returns [ -2.0, -3.0 ] -*/ -declare function reject( x: Float64Array, predicate: Predicate, thisArg?: ThisParameterType> ): Float64Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var x = new Float32Array( [ 1.0, -2.0, -3.0, 4.0 ] ); -* -* var out = reject( x, isPositiveNumber ); -* // returns [ -2.0, -3.0 ] -*/ -declare function reject( x: Float32Array, predicate: Predicate, thisArg?: ThisParameterType> ): Float32Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, -2, -3, 4 ] ); -* -* var out = reject( x, isPositiveNumber ); -* // returns [ -2, -3 ] -*/ -declare function reject( x: Int32Array, predicate: Predicate, thisArg?: ThisParameterType> ): Int32Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var x = new Int16Array( [ 1, -2, -3, 4 ] ); -* -* var out = reject( x, isPositiveNumber ); -* // returns [ -2, -3 ] -*/ -declare function reject( x: Int16Array, predicate: Predicate, thisArg?: ThisParameterType> ): Int16Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var x = new Int8Array( [ 1, -2, -3, 4 ] ); -* -* var out = reject( x, isPositiveNumber ); -* // returns [ -2, -3 ] -*/ -declare function reject( x: Int8Array, predicate: Predicate, thisArg?: ThisParameterType> ): Int8Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var x = new Uint32Array( [ 0, 1, 2, 3, 4 ] ); -* -* var out = reject( x, isPositiveNumber ); -* // returns [ 0 ] -*/ -declare function reject( x: Uint32Array, predicate: Predicate, thisArg?: ThisParameterType> ): Uint32Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var x = new Uint16Array( [ 0, 1, 2, 3, 4 ] ); -* -* var out = reject( x, isPositiveNumber ); -* // returns [ 0 ] -*/ -declare function reject( x: Uint16Array, predicate: Predicate, thisArg?: ThisParameterType> ): Uint16Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 0, 1, 2, 3, 4 ] ); -* -* var out = reject( x, isPositiveNumber ); -* // returns [ 0 ] -*/ -declare function reject( x: Uint8Array, predicate: Predicate, thisArg?: ThisParameterType> ): Uint8Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var x = new Uint8ClampedArray( [ 0, 1, 2, 3, 4 ] ); -* -* var out = reject( x, isPositiveNumber ); -* // returns [ 0 ] -*/ -declare function reject( x: Uint8ClampedArray, predicate: Predicate, thisArg?: ThisParameterType> ): Uint8ClampedArray; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* function predicate( v ) { -* return ( isPositiveNumber( real( v ) ) && isPositiveNumber( imag( v ) ) ); -* } -* -* var x = new Complex128Array( [ 1.0, -2.0, 3.0, 4.0 ] ); -* -* var out = reject( x, predicate ); -* // returns -*/ -declare function reject( x: Complex128Array, predicate: Predicate, thisArg?: ThisParameterType> ): Complex128Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive; -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* function predicate( v ) { -* return ( isPositiveNumber( realf( v ) ) && isPositiveNumber( imagf( v ) ) ); -* } -* -* var x = new Complex64Array( [ 1.0, -2.0, 3.0, 4.0 ] ); -* -* var out = reject( x, predicate ); -* // returns -*/ -declare function reject( x: Complex64Array, predicate: Predicate, thisArg?: ThisParameterType> ): Complex64Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var x = [ 1, -2, -3, 4 ]; -* -* var out = reject( x, isPositiveNumber ); -* // returns [ -2, -3 ] -*/ -declare function reject( x: Array, predicate: Predicate>, thisArg?: ThisParameterType>> ): Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, -2, -3, 4 ] ); -* -* var out = reject( x, isPositiveNumber ); -* // returns [ -2, -3 ] -*/ -declare function reject( x: AccessorArrayLike, predicate: Predicate>, thisArg?: ThisParameterType>> ): Array; - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param x - input array -* @param predicate - predicate function -* @param thisArg - predicate function execution context -* @returns output array -* -* @example -* var x = [ 1, -2, -3, 4 ]; -* -* var out = reject( x, isPositiveNumber ); -* // returns [ -2, -3 ] -*/ -declare function reject( x: Collection, predicate: Predicate>, thisArg?: ThisParameterType>> ): Array; - - -// EXPORTS // - -export = reject; diff --git a/base/reject/docs/types/test.ts b/base/reject/docs/types/test.ts deleted file mode 100644 index 222d3e867..000000000 --- a/base/reject/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import reject = require( './index' ); - -/** -* Tests whether a value is positive. -* -* @param value - input value -* @returns boolean indicating whether an element is positive -*/ -function isPositive( value: number ): boolean { - return ( value > 0 ); -} - - -// TESTS // - -// The function returns a collection... -{ - reject( [ 1, 2, 3 ], isPositive ); // $ExpectType number[] - reject( new Float64Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Float64Array - reject( new Float32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Float32Array - reject( new Int32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Int32Array - reject( new Int16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Int16Array - reject( new Int8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Int8Array - reject( new Uint32Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Uint32Array - reject( new Uint16Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Uint16Array - reject( new Uint8Array( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Uint8Array - reject( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType Uint8ClampedArray - reject( toAccessorArray( [ 1, 2, 3 ] ), isPositive ); // $ExpectType number[] - - reject( [ 1, 2, 3 ], isPositive, {} ); // $ExpectType number[] - reject( new Float64Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Float64Array - reject( new Float32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Float32Array - reject( new Int32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Int32Array - reject( new Int16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Int16Array - reject( new Int8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Int8Array - reject( new Uint32Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Uint32Array - reject( new Uint16Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Uint16Array - reject( new Uint8Array( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Uint8Array - reject( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType Uint8ClampedArray - reject( toAccessorArray( [ 1, 2, 3 ] ), isPositive, {} ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - reject( 2, isPositive ); // $ExpectError - reject( false, isPositive ); // $ExpectError - reject( true, isPositive ); // $ExpectError - reject( {}, isPositive ); // $ExpectError - - reject( 2, isPositive, {} ); // $ExpectError - reject( false, isPositive, {} ); // $ExpectError - reject( true, isPositive, {} ); // $ExpectError - reject( {}, isPositive, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - reject( [ 1, 2, 3 ], 'abc' ); // $ExpectError - reject( [ 1, 2, 3 ], 2 ); // $ExpectError - reject( [ 1, 2, 3 ], false ); // $ExpectError - reject( [ 1, 2, 3 ], true ); // $ExpectError - reject( [ 1, 2, 3 ], null ); // $ExpectError - reject( [ 1, 2, 3 ], void 0 ); // $ExpectError - reject( [ 1, 2, 3 ], {} ); // $ExpectError - reject( [ 1, 2, 3 ], [] ); // $ExpectError - - reject( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError - reject( [ 1, 2, 3 ], 2, {} ); // $ExpectError - reject( [ 1, 2, 3 ], false, {} ); // $ExpectError - reject( [ 1, 2, 3 ], true, {} ); // $ExpectError - reject( [ 1, 2, 3 ], null, {} ); // $ExpectError - reject( [ 1, 2, 3 ], void 0, {} ); // $ExpectError - reject( [ 1, 2, 3 ], {}, {} ); // $ExpectError - reject( [ 1, 2, 3 ], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - reject(); // $ExpectError - reject( [ 1, 2, 3 ] ); // $ExpectError - reject( [ 1, 2, 3 ], isPositive, {}, 3 ); // $ExpectError -} diff --git a/base/reject/examples/index.js b/base/reject/examples/index.js deleted file mode 100644 index 6f4c32cea..000000000 --- a/base/reject/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive; -var naryFunction = require( '@stdlib/utils/nary-function' ); -var reject = require( './../lib' ); - -var x = discreteUniform( 10, -5, 5, { - 'dtype': 'int32' -}); -// returns - -var out = reject( x, naryFunction( isPositiveInteger, 1 ) ); -// returns - -console.log( x ); -console.log( out ); diff --git a/base/reject/lib/index.js b/base/reject/lib/index.js deleted file mode 100644 index ffa6ea50b..000000000 --- a/base/reject/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Return a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @module @stdlib/array/base/reject -* -* @example -* var reject = require( '@stdlib/array/base/reject' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, -2, -3, 4 ]; -* -* var out = reject( x, isPositive ); -* // returns [ -2, -3 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/reject/lib/main.js b/base/reject/lib/main.js deleted file mode 100644 index fb53adfe1..000000000 --- a/base/reject/lib/main.js +++ /dev/null @@ -1,136 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @private -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Array} output array -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, -2, -3, 4 ]; -* -* var out = internal( x, isPositive ); -* // returns [ -2, -3 ] -*/ -function internal( x, predicate, thisArg ) { - var out; - var v; - var i; - - out = []; - for ( i = 0; i < x.length; i++ ) { - v = x[ i ]; - if ( !predicate.call( thisArg, v, i, x ) ) { - out.push( v ); - } - } - return out; -} - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @private -* @param {Object} x - input array object -* @param {Function} predicate - test function -* @param {*} thisArg - execution context -* @returns {Array} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = arraylike2object( toAccessorArray( [ 1, -2, -3, 4 ] ) ); -* -* var out = accessors( x, isPositive ); -* // returns [ -2, -3 ] -*/ -function accessors( x, predicate, thisArg ) { - var data; - var get; - var out; - var v; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - out = []; - for ( i = 0; i < data.length; i++ ) { - v = get( data, i ); - if ( !predicate.call( thisArg, v, i, data ) ) { - out.push( v ); - } - } - return out; -} - - -// MAIN // - -/** -* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function. -* -* @param {Collection} x - input array -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @returns {Collection} output array -* -* @example -* function isPositive( v ) { -* return v > 0; -* } -* -* var x = [ 1, -2, -3, 4 ]; -* -* var out = reject( x, isPositive ); -* // returns [ -2, -3 ] -*/ -function reject( x, predicate, thisArg ) { - var obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, predicate, thisArg ); - } - return internal( x, predicate, thisArg ); -} - - -// EXPORTS // - -module.exports = reject; diff --git a/base/reject/package.json b/base/reject/package.json deleted file mode 100644 index 9b11792f3..000000000 --- a/base/reject/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/reject", - "version": "0.0.0", - "description": "Return a shallow copy of an array containing only those elements which fail a test implemented by a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "test", - "predicate", - "reject", - "filter", - "array.filter", - "copy" - ] -} diff --git a/base/reject/test/test.js b/base/reject/test/test.js deleted file mode 100644 index 571b5e4a2..000000000 --- a/base/reject/test/test.js +++ /dev/null @@ -1,251 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var reject = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Tests whether a value is positive. -* -* @private -* @param {number} value - input value -* @returns {boolean} boolean indicating if a value is positive -*/ -function isPositive( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof reject, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided an empty collection, the function returns an empty collection (generic)', function test( t ) { - var expected; - var actual; - var arr; - - arr = []; - expected = []; - actual = reject( arr, foo ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns an empty collection (typed array)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float64Array( [] ); - expected = new Float64Array( [] ); - actual = reject( arr, foo ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'if provided an empty collection, the function returns an empty collection (accessor)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new AccessorArray( [] ); - expected = []; - actual = reject( arr, foo ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function foo() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the function filters a provided collection (generic)', function test( t ) { - var expected; - var actual; - var arr; - - arr = [ 1, -2, 3 ]; - expected = [ -2 ]; - actual = reject( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function filters a provided collection (typed array)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float64Array( [ -1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ -1.0 ] ); - actual = reject( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function filters a provided collection (accessor)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new AccessorArray( [ 1, -2, -3 ] ); - expected = [ -2, -3 ]; - actual = reject( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function filters a provided collection (array-like object)', function test( t ) { - var expected; - var actual; - var arr; - - arr = { - 'length': 3, - '0': -1, - '1': -2, - '2': 3 - }; - expected = [ -1, -2 ]; - actual = reject( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function an empty collection if all elements pass a test (generic)', function test( t ) { - var expected; - var actual; - var arr; - - arr = [ 1, 2, 3 ]; - expected = []; - actual = reject( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function an empty collection if all elements pass a test (typed array)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [] ); - actual = reject( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function an empty collection if all elements pass a test (accessor)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new AccessorArray( [ 1, 2, 3 ] ); - expected = []; - actual = reject( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function an empty collection if all elements pass a test (array-like object)', function test( t ) { - var expected; - var actual; - var arr; - - arr = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - expected = []; - actual = reject( arr, isPositive ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = [ 1, -2, 3 ]; - expected = [ -2 ]; - actual = reject( arr, predicate, ctx ); - - t.strictEqual( instanceOf( actual, Array ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, arr.length, 'returns expected value' ); - - t.end(); - - function predicate( value ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( value > 0 ); - } -}); diff --git a/base/rekey-views/README.md b/base/rekey-views/README.md deleted file mode 100644 index e784bcaba..000000000 --- a/base/rekey-views/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# rekeyViews - -> Create an array containing views with renamed keys for every element in a provided array. - -
- -## Usage - -```javascript -var rekeyViews = require( '@stdlib/array/base/rekey-views' ); -``` - -#### rekeyViews( arr, mapping ) - -Returns an array containing views with renamed keys for every element in a provided array. - -```javascript -var x = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } -]; -var mapping = { - 'x': 'a', - 'y': 'b' -}; - -var out = rekeyViews( x, mapping ); -// returns [ , ] - -var v0 = out[ 0 ].toJSON(); -// returns { 'a': 1, 'b': 2 } - -var v1 = out[ 1 ].toJSON(); -// returns { 'a': 3, 'b': 4 } - -// Mutate the first element in the input array: -x[ 0 ].x = 5; - -v0 = out[ 0 ].toJSON(); -// returns { 'a': 5, 'b': 2 } - -// Set a view property: -out[ 1 ].b = 'beep'; - -v1 = out[ 1 ].toJSON(); -// returns { 'a': 3, 'b': 'beep' } - -var y = x.slice(); -// returns [ { 'x': 5, 'y': 2 }, { 'x': 3, 'y': 'beep' } ] -``` - -The function has the following parameters: - -- **arr**: input array. -- **mapping**: object mapping existing keys to new key names. - - - - - -
- -- The function returns views having **only** those keys which are present in a provided mapping object. Any keys which are **not** present in the provided mapping object, but are present in the original objects, are **omitted** during view creation. -- The function assumes that each object has the keys specified in a provided mapping object. -- Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either an array element or a view will mutate the other. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( '@stdlib/array/base/filled-by' ); -var rekeyViews = require( '@stdlib/array/base/rekey-views' ); - -function clbk( idx ) { - return { - 'x': idx, - 'y': discreteUniform( 0, 10 ) - }; -} - -var x = filledBy( 10, clbk ); -var mapping = { - 'x': 'a', - 'y': 'b' -}; - -var out = rekeyViews( x, mapping ); -// returns [...] -``` - -
- - - - - - - - - - - - - - diff --git a/base/rekey-views/benchmark/benchmark.js b/base/rekey-views/benchmark/benchmark.js deleted file mode 100644 index 0ba4bce26..000000000 --- a/base/rekey-views/benchmark/benchmark.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filledBy = require( './../../../base/filled-by' ); -var pkg = require( './../package.json' ).name; -var rekeyViews = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns an object. -* -* @private -* @param {NonNegativeInteger} idx - element index -* @returns {Object} object -*/ -function clbk( idx ) { - return { - 'x': idx, - 'y': idx - }; -} - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var mapping; - var x; - var i; - var v; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - x = filledBy( 100, clbk ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = rekeyViews( x, mapping ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/rekey-views/docs/repl.txt b/base/rekey-views/docs/repl.txt deleted file mode 100644 index 94abc73dd..000000000 --- a/base/rekey-views/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( arr, mapping ) - Returns an array containing views with renamed keys for every element in a - provided array. - - The function returns views having only those keys which are present in a - provided mapping object. Any keys which are not present in the provided - mapping object, but are present in the original objects, are omitted during - view creation. - - The function assumes that each object has the keys specified in a provided - mapping object. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either an array - element or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - mapping: Object - Object mapping existing keys to new key names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ]; - > var m = { 'x': 'a', 'y': 'b' }; - > var out = {{alias}}( x, m ); - > var v = out[ 0 ].toJSON() - { 'a': 1, 'b': 2 } - > v = out[ 1 ].toJSON() - { 'a': 3, 'b': 4 } - - See Also - -------- - diff --git a/base/rekey-views/docs/types/index.d.ts b/base/rekey-views/docs/types/index.d.ts deleted file mode 100644 index b98db5b36..000000000 --- a/base/rekey-views/docs/types/index.d.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Returns an array containing views with renamed keys for every element in a provided array. -* -* ## Notes -* -* - The function returns views having only those keys which are present in a provided mapping object. Any keys which are not present in the provided mapping object, but are present in the original objects, are omitted during view creation. -* - The function assumes that each object has the keys specified in a provided mapping object. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either an array element or a view will mutate the other. -* -* @param arr - input array -* @param mapping - object mapping existing keys to new key names -* @returns output array -* -* @example -* var x = [ -* { -* 'x': 1, -* 'y': 2 -* }, -* { -* 'x': 3, -* 'y': 4 -* } -* ]; -* var mapping = { -* 'x': 'a', -* 'y': 'b' -* }; -* -* var out = rekeyViews( x, mapping ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'a': 1, 'b': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'a': 3, 'b': 4 } -* -* // Mutate the first element in the input array: -* x[ 0 ].x = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'a': 5, 'b': 2 } -* -* // Set a view property: -* out[ 1 ].b = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'a': 3, 'b': 'beep' } -* -* var y = x.slice(); -* // returns [ { 'x': 5, 'y': 2 }, { 'x': 3, 'y': 'beep' } ] -*/ -declare function rekeyViews, OldKey extends keyof T, Mapping extends Record>( arr: Collection | AccessorArrayLike, mapping: Mapping ): Array<{ [ K in OldKey as Mapping[K] ]: T[K] }>; - - -// EXPORTS // - -export = rekeyViews; diff --git a/base/rekey-views/docs/types/test.ts b/base/rekey-views/docs/types/test.ts deleted file mode 100644 index b71873fff..000000000 --- a/base/rekey-views/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import rekeyViews = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - const x = [ - { - 'x': 1, - 'y': 2 - } - ]; - const mapping = { - 'x': 'a', - 'y': 'b' - }; - - rekeyViews( x, mapping ); // $ExpectType { [x: string]: number; }[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - const mapping = { - 'x': 'a', - 'y': 'b' - }; - - rekeyViews( 1, mapping ); // $ExpectError - rekeyViews( true, mapping ); // $ExpectError - rekeyViews( false, mapping ); // $ExpectError - rekeyViews( null, mapping ); // $ExpectError - rekeyViews( void 0, mapping ); // $ExpectError - rekeyViews( {}, mapping ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - rekeyViews( [], 1 ); // $ExpectError - rekeyViews( [], true ); // $ExpectError - rekeyViews( [], false ); // $ExpectError - rekeyViews( [], null ); // $ExpectError - rekeyViews( [], void 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - rekeyViews(); // $ExpectError - rekeyViews( [] ); // $ExpectError - rekeyViews( [], {}, [] ); // $ExpectError -} diff --git a/base/rekey-views/examples/index.js b/base/rekey-views/examples/index.js deleted file mode 100644 index 413f22ab8..000000000 --- a/base/rekey-views/examples/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( './../../../base/filled-by' ); -var rekeyViews = require( './../lib' ); - -function clbk( idx ) { - return { - 'x': idx, - 'y': discreteUniform( 0, 10 ) - }; -} - -var x = filledBy( 10, clbk ); -var mapping = { - 'x': 'a', - 'y': 'b' -}; - -var out = rekeyViews( x, mapping ); -console.log( out ); -// => [...] diff --git a/base/rekey-views/lib/index.js b/base/rekey-views/lib/index.js deleted file mode 100644 index eba2b7b37..000000000 --- a/base/rekey-views/lib/index.js +++ /dev/null @@ -1,76 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an array containing views with renamed keys for every element in a provided array. -* -* @module @stdlib/array/base/rekey-views -* -* @example -* var rekeyViews = require( '@stdlib/array/base/rekey-views' ); -* -* var x = [ -* { -* 'x': 1, -* 'y': 2 -* }, -* { -* 'x': 3, -* 'y': 4 -* } -* ]; -* var mapping = { -* 'x': 'a', -* 'y': 'b' -* }; -* -* var out = rekeyViews( x, mapping ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'a': 1, 'b': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'a': 3, 'b': 4 } -* -* // Mutate the first element in the input array: -* x[ 0 ].x = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'a': 5, 'b': 2 } -* -* // Set a view property: -* out[ 1 ].b = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'a': 3, 'b': 'beep' } -* -* var y = x.slice(); -* // returns [ { 'x': 5, 'y': 2 }, { 'x': 3, 'y': 'beep' } ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/rekey-views/lib/main.js b/base/rekey-views/lib/main.js deleted file mode 100644 index d92d34382..000000000 --- a/base/rekey-views/lib/main.js +++ /dev/null @@ -1,205 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var objectKeys = require( '@stdlib/utils/keys' ); - - -// MAIN // - -/** -* Returns an array containing views with renamed keys for every element in a provided array. -* -* ## Notes -* -* - The function returns views having only those keys which are present in a provided mapping object. Any keys which are not present in the provided mapping object, but are present in the original objects, are omitted during view creation. -* - The function assumes that each object has the keys specified in a provided mapping object. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either an array element or a view will mutate the other. -* -* @param {ArrayLikeObject} arr - input array -* @param {Object} mapping - object mapping existing keys to new key names -* @returns {Array} output array -* -* @example -* var x = [ -* { -* 'x': 1, -* 'y': 2 -* }, -* { -* 'x': 3, -* 'y': 4 -* } -* ]; -* var mapping = { -* 'x': 'a', -* 'y': 'b' -* }; -* -* var out = rekeyViews( x, mapping ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'a': 1, 'b': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'a': 3, 'b': 4 } -* -* // Mutate the first element in the input array: -* x[ 0 ].x = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'a': 5, 'b': 2 } -* -* // Set a view property: -* out[ 1 ].b = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'a': 3, 'b': 'beep' } -* -* var y = x.slice(); -* // returns [ { 'x': 5, 'y': 2 }, { 'x': 3, 'y': 'beep' } ] -*/ -function rekeyViews( arr, mapping ) { - var getter; - var okeys; - var nkeys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - // Resolve the list of old key names: - okeys = objectKeys( mapping ); - N = okeys.length; - - // Resolve the list of new key names: - nkeys = []; - for ( i = 0; i < N; i++ ) { - nkeys.push( mapping[ okeys[ i ] ] ); - } - // Resolve the accessor for the input array: - getter = resolveGetter( arr ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( i ) { - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, nkeys[ i ], getValue( okeys[ i ] ), setValue( okeys[ i ] ) ); // eslint-disable-line max-len - } - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( i ) ); - } - return out; - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {string} key - field name - * @returns {Function} accessor - */ - function getValue( key ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - return getter( arr, this._i )[ key ]; - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {string} key - field name - * @returns {Function} accessor - */ - function setValue( key ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - getter( arr, this._i )[ key ] = value; - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = nkeys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = rekeyViews; diff --git a/base/rekey-views/package.json b/base/rekey-views/package.json deleted file mode 100644 index 0458f12d8..000000000 --- a/base/rekey-views/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/rekey-views", - "version": "0.0.0", - "description": "Create an array containing views with renamed keys for every element in a provided array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "pick", - "partial", - "object", - "tidy" - ] -} diff --git a/base/rekey-views/test/test.js b/base/rekey-views/test/test.js deleted file mode 100644 index 9b2c8ef5d..000000000 --- a/base/rekey-views/test/test.js +++ /dev/null @@ -1,419 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var rekeyViews = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof rekeyViews, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (index)', function test( t ) { - var expected; - var mapping; - var actual; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - actual = rekeyViews( [], mapping ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var mapping; - var actual; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - actual = rekeyViews( toAccessorArray( [] ), mapping ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function creates object views for each element in an array (indexed)', function test( t ) { - var expected; - var mapping; - var actual; - var x; - var i; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - x = [ - { - 'x': 1, - 'y': 2, - 'z': 999 - }, - { - 'x': 3, - 'y': 4, - 'foo': 'bar' - } - ]; - - actual = rekeyViews( x, mapping ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'a': 1, - 'b': 2 - }, - { - 'a': 3, - 'b': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function creates object views for each element in an array (accessors)', function test( t ) { - var expected; - var mapping; - var actual; - var x; - var i; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - x = [ - { - 'x': 1, - 'y': 2, - 'z': 999 - }, - { - 'x': 3, - 'y': 4, - 'foo': 'bar' - } - ]; - - actual = rekeyViews( toAccessorArray( x ), mapping ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'a': 1, - 'b': 2 - }, - { - 'a': 3, - 'b': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var mapping; - var actual; - var x; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - x = [ - { - 'x': 1, - 'y': 2, - 'z': 999 - }, - { - 'x': 3, - 'y': 4, - 'foo': 'bar' - } - ]; - - actual = rekeyViews( x, mapping ); - - t.strictEqual( actual[ 0 ].a, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].b, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].a, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].b, 4, 'returns expected value' ); - - actual[ 0 ].b = -99; - actual[ 1 ].a = 99; - - t.strictEqual( actual[ 0 ].a, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].b, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].a, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].b, 4, 'returns expected value' ); - - expected = [ - { - 'x': 1, - 'y': -99, - 'z': 999 - }, - { - 'x': 99, - 'y': 4, - 'foo': 'bar' - } - ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var mapping; - var actual; - var x; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - x = [ - { - 'x': 1, - 'y': 2, - 'z': 999 - }, - { - 'x': 3, - 'y': 4, - 'foo': 'bar' - } - ]; - - actual = rekeyViews( toAccessorArray( x ), mapping ); - - t.strictEqual( actual[ 0 ].a, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].b, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].a, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].b, 4, 'returns expected value' ); - - actual[ 0 ].b = -99; - actual[ 1 ].a = 99; - - t.strictEqual( actual[ 0 ].a, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].b, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].a, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].b, 4, 'returns expected value' ); - - expected = [ - { - 'x': 1, - 'y': -99, - 'z': 999 - }, - { - 'x': 99, - 'y': 4, - 'foo': 'bar' - } - ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var mapping; - var actual; - var tmp; - var x; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - x = [ - { - 'x': 1, - 'y': 2, - 'z': 999 - }, - { - 'x': 3, - 'y': 4, - 'foo': 'bar' - } - ]; - - actual = rekeyViews( x, mapping ); - - t.strictEqual( actual[ 0 ].a, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].b, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].a, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].b, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].a, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].b, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].a, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].b, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var mapping; - var actual; - var tmp; - var x; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - x = [ - { - 'x': 1, - 'y': 2, - 'z': 999 - }, - { - 'x': 3, - 'y': 4, - 'foo': 'bar' - } - ]; - - actual = rekeyViews( toAccessorArray( x ), mapping ); - - t.strictEqual( actual[ 0 ].a, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].b, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].a, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].b, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].a, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].b, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].a, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].b, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a `toJSON` method which includes all fields in a specified mapping object', function test( t ) { - var expected; - var mapping; - var actual; - var x; - - mapping = { - 'x': 'a', - 'y': 'b', - 'z': 'c', - 'w': 'd', - 'v': 'e' - }; - - x = [ - { - 'x': 1, - 'y': 2, - 'z': 3, - 'w': 4, - 'v': 5 - }, - { - 'x': 6, - 'y': 7, - 'z': 8, - 'w': 9, - 'v': 10 - } - ]; - - actual = rekeyViews( x, mapping ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); diff --git a/base/rekey/README.md b/base/rekey/README.md deleted file mode 100644 index 44ab5f536..000000000 --- a/base/rekey/README.md +++ /dev/null @@ -1,122 +0,0 @@ - - -# rekey - -> Copy and rename specified keys for every element in a provided array. - -
- -## Usage - -```javascript -var rekey = require( '@stdlib/array/base/rekey' ); -``` - -#### rekey( arr, mapping ) - -Copies and renames specified keys for every element in a provided array. - -```javascript -var x = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } -]; -var mapping = { - 'x': 'a', - 'y': 'b' -}; - -var out = rekey( x, mapping ); -// returns [ { 'a': 1, 'b': 2 }, { 'a': 3, 'b': 4 } ] -``` - -The function has the following parameters: - -- **arr**: input array. -- **mapping**: object mapping existing keys to new key names. - -
- - - -
- -- The function **only** copies and renames those keys which are present in a provided mapping object. Any keys which are **not** present in the provided mapping object, but are present in the original objects, are **omitted** during object creation. -- The function assumes that each object has the keys specified in a provided mapping object. -- The function performs **shallow** copies of key values. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( '@stdlib/array/base/filled-by' ); -var rekey = require( '@stdlib/array/base/rekey' ); - -function clbk( idx ) { - return { - 'x': idx, - 'y': discreteUniform( 0, 10 ) - }; -} - -var x = filledBy( 10, clbk ); -var mapping = { - 'x': 'a', - 'y': 'b' -}; - -var out = rekey( x, mapping ); -// returns [...] -``` - -
- - - - - - - - - - - - - - diff --git a/base/rekey/benchmark/benchmark.js b/base/rekey/benchmark/benchmark.js deleted file mode 100644 index 6975e121c..000000000 --- a/base/rekey/benchmark/benchmark.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var filledBy = require( './../../../base/filled-by' ); -var pkg = require( './../package.json' ).name; -var rekey = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns an object. -* -* @private -* @param {NonNegativeInteger} idx - element index -* @returns {Object} object -*/ -function clbk( idx ) { - return { - 'x': idx, - 'y': idx - }; -} - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var mapping; - var x; - var i; - var v; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - x = filledBy( 100, clbk ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = rekey( x, mapping ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/rekey/docs/repl.txt b/base/rekey/docs/repl.txt deleted file mode 100644 index 614c27b6e..000000000 --- a/base/rekey/docs/repl.txt +++ /dev/null @@ -1,37 +0,0 @@ - -{{alias}}( arr, mapping ) - Copies and renames specified keys for every element in a provided array. - - The function only copies and renames those keys which are present in a - provided mapping object. Any keys which are not present in the provided - mapping object, but are present in the original objects, are omitted during - object creation. - - The function assumes that each object has the keys specified in a provided - mapping object. - - The function performs shallow copies of key values. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - mapping: Object - Object mapping existing keys to new key names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ]; - > var m = { 'x': 'a', 'y': 'b' }; - > var out = {{alias}}( x, m ) - [ { 'a': 1, 'b': 2 }, { 'a': 3, 'b': 4 } ] - - See Also - -------- - diff --git a/base/rekey/docs/types/index.d.ts b/base/rekey/docs/types/index.d.ts deleted file mode 100644 index 2372a1c36..000000000 --- a/base/rekey/docs/types/index.d.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Copies and renames specified keys for every element in a provided array. -* -* ## Notes -* -* - The function only copies and renames those keys which are present in a provided mapping object. Any keys which are not present in the provided mapping object, but are present in the original objects, are omitted during object creation. -* - The function assumes that each object has the keys specified in a provided mapping object. -* - The function performs shallow copies of key values. -* -* @param arr - input array -* @param mapping - object mapping existing keys to new key names -* @returns output array -* -* @example -* var x = [ -* { -* 'x': 1, -* 'y': 2 -* }, -* { -* 'x': 3, -* 'y': 4 -* } -* ]; -* var mapping = { -* 'x': 'a', -* 'y': 'b' -* }; -* -* var out = rekey( x, mapping ); -* // returns [ { 'a': 1, 'b': 2 }, { 'a': 3, 'b': 4 } ] -*/ -declare function rekey, OldKey extends keyof T, Mapping extends Record>( arr: Collection | AccessorArrayLike, mapping: Mapping ): Array<{ [ K in OldKey as Mapping[K] ]: T[K] }>; - - -// EXPORTS // - -export = rekey; diff --git a/base/rekey/docs/types/test.ts b/base/rekey/docs/types/test.ts deleted file mode 100644 index db3be7d30..000000000 --- a/base/rekey/docs/types/test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import rekey = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - const x = [ - { - 'x': 1, - 'y': 2 - } - ]; - const mapping = { - 'x': 'a', - 'y': 'b' - }; - - rekey( x, mapping ); // $ExpectType { [x: string]: number; }[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - const mapping = { - 'x': 'a', - 'y': 'b' - }; - - rekey( 1, mapping ); // $ExpectError - rekey( true, mapping ); // $ExpectError - rekey( false, mapping ); // $ExpectError - rekey( null, mapping ); // $ExpectError - rekey( void 0, mapping ); // $ExpectError - rekey( {}, mapping ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - rekey( [], 1 ); // $ExpectError - rekey( [], true ); // $ExpectError - rekey( [], false ); // $ExpectError - rekey( [], null ); // $ExpectError - rekey( [], void 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - rekey(); // $ExpectError - rekey( [] ); // $ExpectError - rekey( [], {}, [] ); // $ExpectError -} diff --git a/base/rekey/examples/index.js b/base/rekey/examples/index.js deleted file mode 100644 index f95085779..000000000 --- a/base/rekey/examples/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var filledBy = require( './../../../base/filled-by' ); -var rekey = require( './../lib' ); - -function clbk( idx ) { - return { - 'x': idx, - 'y': discreteUniform( 0, 10 ) - }; -} - -var x = filledBy( 10, clbk ); -var mapping = { - 'x': 'a', - 'y': 'b' -}; - -var out = rekey( x, mapping ); -console.log( out ); -// => [...] diff --git a/base/rekey/lib/index.js b/base/rekey/lib/index.js deleted file mode 100644 index 60d71f711..000000000 --- a/base/rekey/lib/index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Copy and rename specified keys for every element in a provided array. -* -* @module @stdlib/array/base/rekey -* -* @example -* var rekey = require( '@stdlib/array/base/rekey' ); -* -* var x = [ -* { -* 'x': 1, -* 'y': 2 -* }, -* { -* 'x': 3, -* 'y': 4 -* } -* ]; -* var mapping = { -* 'x': 'a', -* 'y': 'b' -* }; -* -* var out = rekey( x, mapping ); -* // returns [ { 'a': 1, 'b': 2 }, { 'a': 3, 'b': 4 } ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/rekey/lib/main.js b/base/rekey/lib/main.js deleted file mode 100644 index 6ad0d3678..000000000 --- a/base/rekey/lib/main.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var objectKeys = require( '@stdlib/utils/keys' ); -var resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Copies and renames specified keys for every element in a provided array. -* -* ## Notes -* -* - The function only copies and renames those keys which are present in a provided mapping object. Any keys which are not present in the provided mapping object, but are present in the original objects, are omitted during object creation. -* - The function assumes that each object has the keys specified in a provided mapping object. -* - The function performs shallow copies of key values. -* -* @param {ArrayLikeObject} arr - input array -* @param {Object} mapping - object mapping existing keys to new key names -* @returns {Array} output array -* -* @example -* var x = [ -* { -* 'x': 1, -* 'y': 2 -* }, -* { -* 'x': 3, -* 'y': 4 -* } -* ]; -* var mapping = { -* 'x': 'a', -* 'y': 'b' -* }; -* -* var out = rekey( x, mapping ); -* // returns [ { 'a': 1, 'b': 2 }, { 'a': 3, 'b': 4 } ] -*/ -function rekey( arr, mapping ) { - var okeys; - var nkeys; - var get; - var out; - var obj; - var tmp; - var M; - var N; - var i; - var j; - - M = arr.length; - if ( M < 1 ) { - return []; - } - // Resolve the list of old key names: - okeys = objectKeys( mapping ); - N = okeys.length; - - // Resolve the list of new key names: - nkeys = []; - for ( i = 0; i < N; i++ ) { - nkeys.push( mapping[ okeys[ i ] ] ); - } - - get = resolveGetter( arr ); - out = []; - for ( i = 0; i < M; i++ ) { - tmp = get( arr, i ); - obj = {}; - for ( j = 0; j < N; j++ ) { - obj[ nkeys[ j ] ] = tmp[ okeys[ j ] ]; - } - out.push( obj ); - } - return out; -} - - -// EXPORTS // - -module.exports = rekey; diff --git a/base/rekey/package.json b/base/rekey/package.json deleted file mode 100644 index 3d963d579..000000000 --- a/base/rekey/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/rekey", - "version": "0.0.0", - "description": "Copy and rename specified keys for every element in a provided array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "pick", - "partial", - "object", - "tidy" - ] -} diff --git a/base/rekey/test/test.js b/base/rekey/test/test.js deleted file mode 100644 index 0aaf16340..000000000 --- a/base/rekey/test/test.js +++ /dev/null @@ -1,148 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var rekey = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof rekey, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (index)', function test( t ) { - var expected; - var mapping; - var actual; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - actual = rekey( [], mapping ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var mapping; - var actual; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - actual = rekey( toAccessorArray( [] ), mapping ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies and renames specified keys for each element in an array (indexed)', function test( t ) { - var expected; - var mapping; - var actual; - var x; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - x = [ - { - 'x': 1, - 'y': 2, - 'z': 999 - }, - { - 'x': 3, - 'y': 4, - 'foo': 'bar' - } - ]; - - actual = rekey( x, mapping ); - expected = [ - { - 'a': 1, - 'b': 2 - }, - { - 'a': 3, - 'b': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies and renames specified keys for each element in an array (accessors)', function test( t ) { - var expected; - var mapping; - var actual; - var x; - - mapping = { - 'x': 'a', - 'y': 'b' - }; - - x = [ - { - 'x': 1, - 'y': 2, - 'z': 999 - }, - { - 'x': 3, - 'y': 4, - 'foo': 'bar' - } - ]; - - actual = rekey( toAccessorArray( x ), mapping ); - expected = [ - { - 'a': 1, - 'b': 2 - }, - { - 'a': 3, - 'b': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/remove-at/README.md b/base/remove-at/README.md deleted file mode 100644 index bb711daff..000000000 --- a/base/remove-at/README.md +++ /dev/null @@ -1,133 +0,0 @@ - - -# removeAt - -> Remove an element from an array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var removeAt = require( '@stdlib/array/base/remove-at' ); -``` - -#### removeAt( x, index ) - -Removes an element from an array. - -```javascript -var x = [ 1, 1, 2, 3, 3 ]; - -var y = removeAt( x, -3 ); -// returns [ 1, 1, 3, 3 ] - -var bool = ( x === y ); -// returns true -``` - -The function accepts the following arguments: - -- **x**: an input array. -- **index**: element index. - -
- - - - - -
- -## Notes - -- Negative indices are resolved relative to the last array element, with the last element corresponding to `-1`. -- If provided out-of-bounds indices, the function returns the input array unchanged; otherwise, the function mutates the input array. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var randi = require( '@stdlib/random/base/discrete-uniform' ); -var removeAt = require( '@stdlib/array/base/remove-at' ); - -// Create an array of random numbers: -var x = discreteUniform( 10, 0, 5, { - 'dtype': 'generic' -}); -// returns [...] - -console.log( x ); - -// Remove a random element: -var y = removeAt( x, randi( 0, x.length-1 ) ); -// returns [...] - -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/remove-at/benchmark/benchmark.js b/base/remove-at/benchmark/benchmark.js deleted file mode 100644 index abd53a830..000000000 --- a/base/remove-at/benchmark/benchmark.js +++ /dev/null @@ -1,78 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/array/uniform' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var removeAt = require( './../lib' ); - - -// MAIN // - -bench( pkg+':index=-1', function benchmark( b ) { - var out; - var x; - var i; - - x = uniform( b.iterations+1, 0.0, 10.0, { - 'dtype': 'generic' - }); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeAt( x, -1 ); - if ( out.length === 0 ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':index=0', function benchmark( b ) { - var out; - var x; - var i; - - x = uniform( b.iterations+1, 0.0, 10.0, { - 'dtype': 'generic' - }); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeAt( x, 0 ); - if ( out.length === 0 ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/remove-at/docs/repl.txt b/base/remove-at/docs/repl.txt deleted file mode 100644 index 521f893bd..000000000 --- a/base/remove-at/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( x, index ) - Removes an element from an array. - - Negative indices are resolved relative to the last array element, with the - last element corresponding to `-1`. - - If provided an out-of-bounds index, the function returns the input array - unchanged; otherwise, the function mutates the input array. - - Parameters - ---------- - x: Array - Input array. - - index: integer - Element index. - - Returns - ------- - out: Array - Input array. - - Examples - -------- - > var x = [ 1, 1, 2, 3, 3 ]; - > var out = {{alias}}( x, -3 ) - [ 1, 1, 3, 3 ] - > var bool = ( out === x ) - true - - See Also - -------- - diff --git a/base/remove-at/docs/types/index.d.ts b/base/remove-at/docs/types/index.d.ts deleted file mode 100644 index 4828c2123..000000000 --- a/base/remove-at/docs/types/index.d.ts +++ /dev/null @@ -1,46 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Removes an element from an array. -* -* ## Notes -* -* - The function mutates the input array. -* -* @param x - input array -* @param index - element index -* @returns input array -* -* @example -* var x = [ 1, 1, 2, 3, 3 ]; -* -* var y = removeAt( x, -2 ); -* // returns [ 1, 1, 3, 3 ] -* -* var bool = ( x === y ); -* // returns true -*/ -declare function removeAt( x: Array, index: number ): Array; - - -// EXPORTS // - -export = removeAt; diff --git a/base/remove-at/docs/types/test.ts b/base/remove-at/docs/types/test.ts deleted file mode 100644 index 9568e0c75..000000000 --- a/base/remove-at/docs/types/test.ts +++ /dev/null @@ -1,62 +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. -*/ - -import removeAt = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - removeAt( [ 1, 2, 3 ], -1 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - removeAt( '5', -1 ); // $ExpectError - removeAt( 5, -1 ); // $ExpectError - removeAt( true, -1 ); // $ExpectError - removeAt( false, -1 ); // $ExpectError - removeAt( null, -1 ); // $ExpectError - removeAt( void 0, -1 ); // $ExpectError - removeAt( {}, -1 ); // $ExpectError - removeAt( ( x: number ): number => x, -1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - removeAt( x, '5' ); // $ExpectError - removeAt( x, true ); // $ExpectError - removeAt( x, false ); // $ExpectError - removeAt( x, null ); // $ExpectError - removeAt( x, void 0 ); // $ExpectError - removeAt( x, {} ); // $ExpectError - removeAt( x, [] ); // $ExpectError - removeAt( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - removeAt(); // $ExpectError - removeAt( x ); // $ExpectError - removeAt( x, -1, {} ); // $ExpectError -} diff --git a/base/remove-at/examples/index.js b/base/remove-at/examples/index.js deleted file mode 100644 index ee4fc7c1f..000000000 --- a/base/remove-at/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var randi = require( '@stdlib/random/base/discrete-uniform' ); -var removeAt = require( './../lib' ); - -// Create an array of random numbers: -var x = discreteUniform( 10, 0, 5, { - 'dtype': 'generic' -}); -// returns [...] - -console.log( x ); - -// Remove a random element: -var y = removeAt( x, randi( 0, x.length-1 ) ); -// returns [...] - -console.log( y ); diff --git a/base/remove-at/lib/index.js b/base/remove-at/lib/index.js deleted file mode 100644 index 197488f19..000000000 --- a/base/remove-at/lib/index.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -/** -* Remove an element from an array. -* -* @module @stdlib/array/base/remove-at -* -* @example -* var removeAt = require( '@stdlib/array/base/remove-at' ); -* -* var x = [ 1, 1, 2, 3, 3 ]; -* -* var y = removeAt( x, -3 ); -* // returns [ 1, 1, 3, 3 ] -* -* var bool = ( x === y ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/remove-at/lib/main.js b/base/remove-at/lib/main.js deleted file mode 100644 index b22d9fadc..000000000 --- a/base/remove-at/lib/main.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Removes an element from an array. -* -* @param {Array} x - input array -* @param {integer} index - element index -* @returns {Array} mutated input array -* -* @example -* var x = [ 1, 1, 2, 3, 3 ]; -* -* var y = removeAt( x, -3 ); -* // returns [ 1, 1, 3, 3 ] -* -* var bool = ( x === y ); -* // returns true -*/ -function removeAt( x, index ) { - var len; - var i; - var j; - - len = x.length; - if ( index < 0 ) { - index += len; - if ( index < 0 ) { - return x; - } - } else if ( index >= len ) { - return x; - } - j = index; - for ( i = index+1; i < len; i++ ) { - x[ j ] = x[ i ]; - j += 1; - } - x.length = j; - return x; -} - - -// EXPORTS // - -module.exports = removeAt; diff --git a/base/remove-at/package.json b/base/remove-at/package.json deleted file mode 100644 index 38374df54..000000000 --- a/base/remove-at/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/remove-at", - "version": "0.0.0", - "description": "Remove an element from an array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "remove", - "delete", - "del", - "compress", - "compact" - ] -} diff --git a/base/remove-at/test/test.js b/base/remove-at/test/test.js deleted file mode 100644 index 99d0a2604..000000000 --- a/base/remove-at/test/test.js +++ /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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeAt = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeAt, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function removes an element from an array', function test( t ) { - var expected; - var actual; - var len; - var x; - - x = [ 1, 1, 2, 3, 3 ]; - len = x.length; - expected = [ 1, 1, 3, 3 ]; - actual = removeAt( x, 2 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, len-1, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 2, 3, 3 ]; - len = x.length; - expected = [ 1, 1, 3, 3 ]; - actual = removeAt( x, -3 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, len-1, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 2, 3, 3 ]; - len = x.length; - expected = [ 1, 1, 2, 3 ]; - actual = removeAt( x, x.length-1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, len-1, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 2, 3, 3 ]; - len = x.length; - expected = [ 1, 1, 2, 3 ]; - actual = removeAt( x, -1 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, len-1, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 2, 3, 3 ]; - len = x.length; - expected = [ 1, 2, 3, 3 ]; - actual = removeAt( x, 0 ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, len-1, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 1, 2, 3, 3 ]; - len = x.length; - expected = [ 1, 2, 3, 3 ]; - actual = removeAt( x, -x.length ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, len-1, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an input unchanged if provided an out-of-bounds index', function test( t ) { - var expected; - var actual; - var len; - var x; - - x = [ 1, 2, 3, 4, 5, 6 ]; - len = x.length; - expected = x.slice(); - - actual = removeAt( x, 10 ); - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, len, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = removeAt( x, 40 ); - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, len, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = removeAt( x, -10 ); - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, len, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = removeAt( x, -40 ); - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, len, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of length `0`', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = removeAt( [], 0 ); - t.strictEqual( actual.length, 0, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = removeAt( [], -1 ); - t.strictEqual( actual.length, 0, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/reshape/README.md b/base/reshape/README.md deleted file mode 100644 index e747f6cc0..000000000 --- a/base/reshape/README.md +++ /dev/null @@ -1,122 +0,0 @@ - - -# reshape - -> Reshape a nested array into another nested array having a desired shape. - -
- -## Usage - -```javascript -var reshape = require( '@stdlib/array/base/reshape' ); -``` - -#### reshape( x, fromShape, toShape, colexicographic ) - -Reshapes a nested array into another nested array having a desired shape. - -```javascript -var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; - -var out = reshape( x, [ 2, 3 ], [ 3, 2 ], false ); -// returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -``` - -- **x**: input array. -- **fromShape**: input array shape. -- **toShape**: output array shape. -- **colexicographic**: boolean indicating whether to reshape the array in colexicographic order. - -To reshape in colexicographic order, set the `colexicographic` argument to `true`. - -```javascript -var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; - -var out = reshape( x, [ 2, 3 ], [ 3, 2 ], true ); -// [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] -``` - -
- - - -
- -## Notes - -- The function assumes that `fromShape` and `toShape` describe arrays having the same number of elements. - -
- - - -
- -## Examples - - - -```javascript -var reshape = require( '@stdlib/array/base/reshape' ); - -var x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ] -]; - -var out = reshape( x, [ 3, 4 ], [ 4, 3 ], false ); -// returns [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ], [ 10, 11, 12 ] ] - -out = reshape( x, [ 3, 4 ], [ 6, 2 ], false ); -// returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ], [ 9, 10 ], [ 11, 12 ] ] - -out = reshape( x, [ 3, 4 ], [ 1, 12 ], false ); -// returns [ [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] ] - -out = reshape( x, [ 3, 4 ], [ 12, 1 ], false ); -// returns [ [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ], [ 11 ], [ 12 ] ] -``` - -
- - - - - - - - - - - - - - diff --git a/base/reshape/benchmark/benchmark.js b/base/reshape/benchmark/benchmark.js deleted file mode 100644 index a876fa811..000000000 --- a/base/reshape/benchmark/benchmark.js +++ /dev/null @@ -1,206 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var onesnd = require( './../../../base/onesnd' ); -var pkg = require( './../package.json' ).name; -var reshape = require( './../lib' ); - - -// MAIN // - -bench( pkg+':ndims=2,size=100,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = onesnd( [ 10, 10 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = reshape( x, [ 10, 10 ], [ 1, 100 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=2,size=100,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = onesnd( [ 10, 10 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = reshape( x, [ 10, 10 ], [ 1, 100 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=3,size=100,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = onesnd( [ 4, 5, 5 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = reshape( x, [ 4, 5, 5 ], [ 1, 1, 100 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=3,size=100,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = onesnd( [ 4, 5, 5 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = reshape( x, [ 4, 5, 5 ], [ 1, 1, 100 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=4,size=100,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = onesnd( [ 5, 2, 5, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = reshape( x, [ 5, 2, 5, 2 ], [ 1, 1, 1, 100 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=4,size=100,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = onesnd( [ 5, 2, 5, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = reshape( x, [ 5, 2, 5, 2 ], [ 1, 1, 1, 100 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=5,size=100,lexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = onesnd( [ 5, 2, 1, 5, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = reshape( x, [ 5, 2, 1, 5, 2 ], [ 1, 1, 1, 1, 100 ], false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':ndims=5,size=100,colexicographic', function benchmark( b ) { - var x; - var i; - var v; - - x = onesnd( [ 5, 2, 1, 5, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = reshape( x, [ 5, 2, 1, 5, 2 ], [ 1, 1, 1, 1, 100 ], true ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/reshape/docs/repl.txt b/base/reshape/docs/repl.txt deleted file mode 100644 index a01bac3a5..000000000 --- a/base/reshape/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( x, fromShape, toShape, colexicographic ) - Reshapes a nested array into another nested array having a desired shape. - - Parameters - ---------- - x: Array - Input n-dimensional nested array. - - fromShape: Array - Input array shape. - - toShape: Array - Output array shape. - - colexicographic: boolean - Specifies whether to reshape the array in colexicographic order. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var out = {{alias}}( x, [ 2, 2 ], [ 4, 1 ], false ) - [ [ 1 ], [ 2 ], [ 3 ], [ 4 ] ] - - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var out = {{alias}}( x, [ 2, 2 ], [ 4, 1 ], true ) - [ [ 1 ], [ 3 ], [ 2 ], [ 4 ] ] - - See Also - -------- diff --git a/base/reshape/docs/types/index.d.ts b/base/reshape/docs/types/index.d.ts deleted file mode 100644 index 40bf2afd0..000000000 --- a/base/reshape/docs/types/index.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D, Array5D, Array6D, Array7D, Array8D, Array9D, Array10D } from '@stdlib/types/array'; -import { Shape } from '@stdlib/types/ndarray'; - -/** -* Nested array. -*/ -type ArrayND = Array1D | Array2D | Array3D | Array4D | Array5D | Array6D | Array7D | Array8D | Array9D | Array10D; // WARNING: arbitrarily limited to 10 dimensions, which should be fine for most practical purposes - -/** -* Reshape a nested array into another nested array having a desired shape. -* -* ## Notes -* -* - The function assumes that `fromShape` and `toShape` describe arrays have same the number of elements. -* -* @param x - input nested array -* @param fromShape - shape of the input array -* @param toShape - shape of the output array -* @param colexicographic - specifies whether to reshape the array in colexicographic order -* @returns output nested array -* -* @example -* var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; -* -* var out = reshape( x, [ 2, 3 ], [ 3, 2 ], false ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -*/ -declare function reshape( x: ArrayND, fromShape: Shape, toShape: Shape, colexicographic: boolean ): ArrayND; - - -// EXPORTS // - -export = reshape; diff --git a/base/reshape/docs/types/test.ts b/base/reshape/docs/types/test.ts deleted file mode 100644 index 099c56515..000000000 --- a/base/reshape/docs/types/test.ts +++ /dev/null @@ -1,97 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import reshape = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - reshape( x, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectType ArrayND - reshape( x, [ 2, 2 ], [ 4, 1 ], true ); // $ExpectType ArrayND - - reshape( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], [ 4, 1 ], false ); // $ExpectType ArrayND - reshape( [ [ '1', '2' ], [ '3', '4' ] ], [ 2, 2 ], [ 4, 1 ], true ); // $ExpectType ArrayND -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - reshape( 1, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError - reshape( true, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError - reshape( false, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError - reshape( null, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError - reshape( void 0, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError - reshape( {}, [ 2, 2 ], [ 4, 1 ], false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - reshape( x, '', [ 4, 1 ], false ); // $ExpectError - reshape( x, 1, [ 4, 1 ], false ); // $ExpectError - reshape( x, true, [ 4, 1 ], false ); // $ExpectError - reshape( x, false, [ 4, 1 ], false ); // $ExpectError - reshape( x, null, [ 4, 1 ], false ); // $ExpectError - reshape( x, void 0, [ 4, 1 ], false ); // $ExpectError - reshape( x, {}, [ 4, 1 ], false ); // $ExpectError - reshape( x, [ 1, '2', 3 ], [ 4, 1 ], false ); // $ExpectError - reshape( x, ( x: number ): number => x, [ 4, 1 ], false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - reshape( x, [ 2, 2 ], '', false ); // $ExpectError - reshape( x, [ 2, 2 ], 1, false ); // $ExpectError - reshape( x, [ 2, 2 ], true, false ); // $ExpectError - reshape( x, [ 2, 2 ], false, false ); // $ExpectError - reshape( x, [ 2, 2 ], null, false ); // $ExpectError - reshape( x, [ 2, 2 ], void 0, false ); // $ExpectError - reshape( x, [ 2, 2 ], {}, false ); // $ExpectError - reshape( x, [ 2, 2 ], [ 4, '1' ], false ); // $ExpectError - reshape( x, [ 2, 2 ], ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a boolean... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - reshape( x, [ 2, 2 ], [ 4, 1 ], '' ); // $ExpectError - reshape( x, [ 2, 2 ], [ 4, 1], 1 ); // $ExpectError - reshape( x, [ 2, 2 ], [ 4, 1], null ); // $ExpectError - reshape( x, [ 2, 2 ], [ 4, 1], void 0 ); // $ExpectError - reshape( x, [ 2, 2 ], [ 4, 1], {} ); // $ExpectError - reshape( x, [ 2, 2 ], [ 4, 1], [] ); // $ExpectError - reshape( x, [ 2, 2 ], [ 4, 1], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - reshape(); // $ExpectError - reshape( x ); // $ExpectError - reshape( x, [ 2, 2 ] ); // $ExpectError - reshape( x, [ 2, 2 ], [ 4, 1 ] ); // $ExpectError - reshape( x, [ 2, 2 ], [ 4, 1 ], false, {} ); // $ExpectError -} diff --git a/base/reshape/examples/index.js b/base/reshape/examples/index.js deleted file mode 100644 index af5b88494..000000000 --- a/base/reshape/examples/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var reshape = require( './../lib' ); - -var x = [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ], - [ 9, 10, 11, 12 ] -]; - -var out = reshape( x, [ 3, 4 ], [ 4, 3 ], false ); -console.log( out ); -// => [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ], [ 10, 11, 12 ] ] - -out = reshape( x, [ 3, 4 ], [ 6, 2 ], false ); -console.log( out ); -// => [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ], [ 9, 10 ], [ 11, 12 ] ] - -out = reshape( x, [ 3, 4 ], [ 1, 12 ], false ); -console.log( out ); -// => [ [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] ] - -out = reshape( x, [ 3, 4 ], [ 12, 1 ], false ); -console.log( out ); -// => [ [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ], [ 11 ], [ 12 ] ] diff --git a/base/reshape/lib/index.js b/base/reshape/lib/index.js deleted file mode 100644 index 8b01ceb84..000000000 --- a/base/reshape/lib/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Reshape a nested array into another nested array having a desired shape. -* -* @module @stdlib/array/base/reshape -* -* @example -* var reshape = require( '@stdlib/array/base/reshape' ); -* -* var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; -* -* var out = reshape( x, [ 2, 3 ], [ 3, 2 ], false ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/reshape/lib/main.js b/base/reshape/lib/main.js deleted file mode 100644 index c52c3763e..000000000 --- a/base/reshape/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var flatten = require( './../../../base/flatten' ); -var slice = require( './../../../base/slice' ); - - -// FUNCTIONS // - -/** -* Recursive reshapes an array. -* -* @private -* @param {Array} array - input n-dimensional nested array -* @param {NonNegativeInteger} ndims - number of dimensions -* @param {NonNegativeIntegerArray} shape - array shape -* @param {NonNegativeInteger} dim - dimension index -* @param {NonNegativeInteger} index - sub-array index -* @returns {Array} output m-dimensional nested array -*/ -function recurse( array, ndims, shape, dim, index ) { - var stepSize; - var subArray; - var out; - var d; - var S; - var i; - - S = shape[ dim ]; - if ( dim === ndims - 1 ) { - return slice( array, index, index + S ); - } - - d = dim + 1; - stepSize = 1; - for ( i = d; i < shape.length; i++ ) { - stepSize *= shape[ i ]; - } - - out = []; - for ( i = 0; i < S; i++ ) { - subArray = recurse( array, ndims, shape, d, index ); - out.push( subArray ); - index += stepSize; - } - return out; -} - - -// MAIN // - -/** -* Reshape a nested array into another nested array having a desired shape. -* -* @param {Array} x - input nested array -* @param {NonNegativeIntegerArray} fromShape - shape of the input array -* @param {NonNegativeIntegerArray} toShape - shape of the output array -* @param {boolean} colexicographic - specifies whether to reshape the array in colexicographic order -* @returns {Array} output nested array -* -* @example -* var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; -* -* var out = reshape( x, [ 2, 3 ], [ 3, 2 ], false ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -*/ -function reshape( x, fromShape, toShape, colexicographic ) { - var f = flatten( x, fromShape, colexicographic ); - return recurse( f, toShape.length, toShape, 0, 0 ); -} - - -// EXPORTS // - -module.exports = reshape; diff --git a/base/reshape/package.json b/base/reshape/package.json deleted file mode 100644 index 5f754287b..000000000 --- a/base/reshape/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/reshape", - "version": "0.0.0", - "description": "Reshape a nested array into another nested array having a desired shape.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "reshape", - "nested", - "transform", - "shape" - ] -} diff --git a/base/reshape/test/test.js b/base/reshape/test/test.js deleted file mode 100644 index aeafec235..000000000 --- a/base/reshape/test/test.js +++ /dev/null @@ -1,457 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var reshape = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof reshape, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a reshaped nested array (2d, lexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; - - expected = [ 1, 2, 3, 4, 5, 6 ]; - actual = reshape( x, [ 2, 3 ], [ 6 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]; - actual = reshape( x, [ 2, 3 ], [ 3, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1, 2, 3, 4, 5, 6 ] ]; - actual = reshape( x, [ 2, 3 ], [ 1, 6 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]; - actual = reshape( x, [ 2, 3 ], [ 1, 3, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [ [ 1, 2 ] ], [ [ 3, 4 ] ], [ [ 5, 6 ] ] ] ]; - actual = reshape( x, [ 2, 3 ], [ 1, 3, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a reshaped nested array (3d, lexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ]; - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = reshape( x, [ 2, 2, 2 ], [ 8 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ] ]; - actual = reshape( x, [ 2, 2, 2 ], [ 4, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1, 2 ] - ], - [ - [ 3, 4 ] - ], - [ - [ 5, 6 ] - ], - [ - [ 7, 8 ] - ] - ]; - actual = reshape( x, [ 2, 2, 2 ], [ 4, 1, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1, 2, 3, 4 ] - ], - [ - [ 5, 6, 7, 8 ] - ] - ]; - actual = reshape( x, [ 2, 2, 2 ], [ 2, 1, 4 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ], - [ 7, 8 ] - ] - ]; - actual = reshape( x, [ 2, 2, 2 ], [ 1, 4, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ]; - actual = reshape( x, [ 2, 2, 2 ], [ 1, 1, 4, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (4d, lexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ 1, 2, 3, 4 ] - ], - [ - [ 5, 6, 7, 8 ] - ] - ] - ]; - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 8 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ] ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 4 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1, 2, 3, 4 ], - [ 5, 6, 7, 8 ] - ] - ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 1, 2, 4 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 1, 2, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ], - [ - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 1, 2, 2 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1 ], - [ 2 ] - ], - [ - [ 3 ], - [ 4 ] - ] - ], - [ - [ - [ 5 ], - [ 6 ] - ], - [ - [ 7 ], - [ 8 ] - ] - ] - ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 2, 2, 1 ], false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a reshaped nested array (2d, colexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ]; - - expected = [ 1, 4, 2, 5, 3, 6 ]; - actual = reshape( x, [ 2, 3 ], [ 6 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]; - actual = reshape( x, [ 2, 3 ], [ 3, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1, 4, 2, 5, 3, 6 ] ]; - actual = reshape( x, [ 2, 3 ], [ 1, 6 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1, 4, 2 ], - [ 5, 3, 6 ] - ] - ]; - actual = reshape( x, [ 2, 3 ], [ 1, 2, 3 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1, 4, 2 ] - ], - [ - [ 5, 3, 6 ] - ] - ] - ]; - actual = reshape( x, [ 2, 3 ], [ 1, 2, 1, 3 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a reshaped nested array (3d, colexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ]; - - expected = [ 1, 5, 3, 7, 2, 6, 4, 8]; - actual = reshape( x, [ 2, 2, 2 ], [ 8 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1, 5, 3, 7 ], [ 2, 6, 4, 8 ] ]; - actual = reshape( x, [ 2, 2, 2 ], [ 2, 4 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1, 5 ] - ], - [ - [ 3, 7 ] - ], - [ - [ 2, 6 ] - ], - [ - [ 4, 8 ] - ] - ]; - actual = reshape( x, [ 2, 2, 2 ], [ 4, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1, 5, 3, 7 ] - ], - [ - [ 2, 6, 4, 8 ] - ] - ]; - actual = reshape( x, [ 2, 2, 2 ], [ 2, 1, 4 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1, 5 ], - [ 3, 7 ], - [ 2, 6 ], - [ 4, 8 ] - ] - ]; - actual = reshape( x, [ 2, 2, 2 ], [ 1, 4, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1, 5 ] - ], - [ - [ 3, 7 ] - ], - [ - [ 2, 6 ] - ], - [ - [ 4, 8 ] - ] - ] - ]; - actual = reshape( x, [ 2, 2, 2 ], [ 1, 4, 1, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (4d, colexicographic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ - [ - [ - [ 1, 2, 3, 4 ] - ], - [ - [ 5, 6, 7, 8 ] - ] - ] - ]; - - expected = [ 1, 5, 2, 6, 3, 7, 4, 8 ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 8 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 1, 5, 2, 6 ], [ 3, 7, 4, 8 ] ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 4 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 1, 5, 2, 6 ], - [ 3, 7, 4, 8 ] - ] - ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 1, 2, 4 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1, 5 ], - [ 2, 6 ] - ], - [ - [ 3, 7 ], - [ 4, 8 ] - ] - ] - ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 1, 2, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1, 5 ], - [ 2, 6 ] - ] - ], - [ - [ - [ 3, 7 ], - [ 4, 8 ] - ] - ] - ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 1, 2, 2 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 1 ], - [ 5 ] - ], - [ - [ 2 ], - [ 6 ] - ] - ], - [ - [ - [ 3 ], - [ 7 ] - ], - [ - [ 4 ], - [ 8 ] - ] - ] - ]; - actual = reshape( x, [ 1, 2, 1, 4 ], [ 2, 2, 2, 1 ], true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/resolve-getter/README.md b/base/resolve-getter/README.md deleted file mode 100644 index 7aae84026..000000000 --- a/base/resolve-getter/README.md +++ /dev/null @@ -1,157 +0,0 @@ - - -# resolveGetter - -> Return an accessor function for retrieving an element from an array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -``` - -#### resolveGetter( x ) - -Returns an accessor function for retrieving an element from an array-like object. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var get = resolveGetter( x ); -var v = get( x, 2 ); -// returns 3 -``` - -The returned accessor function accepts the following arguments: - -- **arr**: input array. -- **idx**: element index. - -
- - - - - -
- -## Notes - -- If provided an array-like object having an unsupported [data type][@stdlib/array/dtypes], the function returns a default accessor function for accessing elements from any array-like object; otherwise, the function returns an accessor function which should **only** be provided an array instance having the same data type (e.g., if provided a `Float64Array`, the returned accessor function should only be provided instances of `Float64Array`). -- Accessor functions do **not** verify that provided input arrays are array instances having a specific data type, as doing so would introduce performance overhead. If array instances corresponding to other data types are provided to an accessor function, JavaScript runtimes will consider the function polymorphic, potentially triggering de-optimization. In order to ensure maximum performance, **always** ensure that an accessor function is monomorphic. -- Accessor functions do **not** perform bounds checking. -- Accessor functions do **not** verify that provided input arrays implement the get/set protocol. -- An _indexed_ array-like object is a data structure in which one retrieves elements via integer indices using bracket `[]` notation (e.g., `Float64Array`, `Int32Array`, `Array`, etc). This is in contrast to an _accessor_ array-like object in which one retrieves elements using `get` and `set` methods (e.g., `Complex64Array` and `Complex128Array`). - -
- - - - - -
- -## Examples - - - -```javascript -var filled = require( '@stdlib/array/filled' ); -var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); - -var arr = filled( 1.0, 10, 'float64' ); -var v = resolveGetter( arr )( arr, 2 ); -// returns 1.0 - -arr = filled( 2.0, 10, 'float32' ); -v = resolveGetter( arr )( arr, 2 ); -// returns 2.0 - -arr = filled( 3, 10, 'int32' ); -v = resolveGetter( arr )( arr, 2 ); -// returns 3 - -arr = filled( 4, 10, 'int16' ); -v = resolveGetter( arr )( arr, 2 ); -// returns 4 - -arr = filled( 5, 10, 'int8' ); -v = resolveGetter( arr )( arr, 2 ); -// returns 5 - -arr = filled( 6, 10, 'uint32' ); -v = resolveGetter( arr )( arr, 2 ); -// returns 6 - -arr = filled( 7, 10, 'uint16' ); -v = resolveGetter( arr )( arr, 2 ); -// returns 7 - -arr = filled( 8, 10, 'uint8' ); -v = resolveGetter( arr )( arr, 2 ); -// returns 8 - -arr = filled( 9, 10, 'uint8c' ); -v = resolveGetter( arr )( arr, 2 ); -// returns 9 -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/resolve-getter/benchmark/benchmark.js b/base/resolve-getter/benchmark/benchmark.js deleted file mode 100644 index 78d84a0d3..000000000 --- a/base/resolve-getter/benchmark/benchmark.js +++ /dev/null @@ -1,305 +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 bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isFunction = require( '@stdlib/assert/is-function' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var filledBy = require( './../../../filled-by' ); -var pkg = require( './../package.json' ).name; -var resolveGetter = require( './../lib' ); - - -// VARIABLES // - -var rand = discreteUniform( 0, 127 ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var get; - var i; - - values = [ - filledBy( 10, 'generic', rand ), - filledBy( 10, 'float64', rand ), - filledBy( 10, 'float32', rand ), - filledBy( 10, 'int32', rand ), - filledBy( 10, 'uint32', rand ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - get = resolveGetter( values[ i%values.length ] ); - if ( typeof get !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( get ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'generic', rand ); - get = resolveGetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'float64', rand ); - get = resolveGetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'float32', rand ); - get = resolveGetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'int32', rand ); - get = resolveGetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'int16', rand ); - get = resolveGetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'int8', rand ); - get = resolveGetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'uint32', rand ); - get = resolveGetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'uint16', rand ); - get = resolveGetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'uint8', rand ); - get = resolveGetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var get; - var i; - var v; - - arr = filledBy( 100, 'uint8c', rand ); - get = resolveGetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = get( arr, i%arr.length ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/resolve-getter/docs/repl.txt b/base/resolve-getter/docs/repl.txt deleted file mode 100644 index fc93602fa..000000000 --- a/base/resolve-getter/docs/repl.txt +++ /dev/null @@ -1,51 +0,0 @@ - -{{alias}}( x ) - Returns an accessor function for retrieving an element from an array-like - object. - - An accessor function accepts the following arguments: - - - arr: input array. - - idx: element index. - - If provided an array-like object having an unsupported data type, the - function returns a default accessor function for accessing elements from - any indexed array-like object. - - Otherwise, the function returns an accessor function which should *only* be - provided an array instance having the same data type (e.g., if provided a - Float64Array, the returned accessor function should only be provided - instances of Float64Array). - - Accessor functions do *not* verify that provided input arrays are array - instances having a specific data type, as doing so would introduce - performance overhead. If array instances corresponding to other data types - are provided to an accessor function, JavaScript runtimes will consider the - function polymorphic, potentially triggering de-optimization. In order to - ensure maximum performance, *always* ensure that an accessor function is - monomorphic. - - Accessor functions do *not* perform bounds checking. - - Accessor functions do *not* verify that provided input arrays implement the - get/set protocol. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - f: Function - Accessor function. - - Examples - -------- - > var f = {{alias}}( [ 5, 6, 7, 8 ] ); - > var v = f( [ 1, 2, 3, 4 ], 2 ) - 3 - - See Also - -------- - diff --git a/base/resolve-getter/docs/types/index.d.ts b/base/resolve-getter/docs/types/index.d.ts deleted file mode 100644 index 9e3e06572..000000000 --- a/base/resolve-getter/docs/types/index.d.ts +++ /dev/null @@ -1,414 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Complex64, Complex128 } from '@stdlib/types/complex'; -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T; - -/** -* Returns an accessor function for retrieving an element from a `Float64Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var arr = new Float64Array( [ 1, 2, 3, 4 ] ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3.0 -*/ -declare function resolveGetter( x: Float64Array ): GetFloat64; - -/** -* Returns an accessor function for retrieving an element from a `Float32Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var arr = new Float32Array( [ 1, 2, 3, 4 ] ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3.0 -*/ -declare function resolveGetter( x: Float32Array ): GetFloat32; - -/** -* Returns an accessor function for retrieving an element from a `Complex128Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var real = require( '@stdlib/array/real' ); -* var imag = require( '@stdlib/array/imag' ); -* -* var arr = new Complex128Array( [ 1, 2, 3, 4 ] ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 1 ); -* // returns -* -* var re = real( v ); -* // returns 3.0 -* -* var im = imag( v ); -* // returns 4.0 -*/ -declare function resolveGetter( x: Complex128Array ): GetComplex128; - -/** -* Returns an accessor function for retrieving an element from a `Complex64Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* var realf = require( '@stdlib/array/realf' ); -* var imagf = require( '@stdlib/array/imagf' ); -* -* var arr = new Complex64Array( [ 1, 2, 3, 4 ] ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 1 ); -* // returns -* -* var re = realf( v ); -* // returns 3.0 -* -* var im = imagf( v ); -* // returns 4.0 -*/ -declare function resolveGetter( x: Complex64Array ): GetComplex64; - -/** -* Returns an accessor function for retrieving an element from an `Int32Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var arr = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function resolveGetter( x: Int32Array ): GetInt32; - -/** -* Returns an accessor function for retrieving an element from an `Int16Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var arr = new Int16Array( [ 1, 2, 3, 4 ] ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function resolveGetter( x: Int16Array ): GetInt16; - -/** -* Returns an accessor function for retrieving an element from an `Int8Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var arr = new Int8Array( [ 1, 2, 3, 4 ] ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function resolveGetter( x: Int8Array ): GetInt8; - -/** -* Returns an accessor function for retrieving an element from a `Uint32Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var arr = new Uint32Array( [ 1, 2, 3, 4 ] ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function resolveGetter( x: Uint32Array ): GetUint32; - -/** -* Returns an accessor function for retrieving an element from a `Uint16Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var arr = new Uint16Array( [ 1, 2, 3, 4 ] ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function resolveGetter( x: Uint16Array ): GetUint16; - -/** -* Returns an accessor function for retrieving an element from a `Uint8Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var arr = new Uint8Array( [ 1, 2, 3, 4 ] ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function resolveGetter( x: Uint8Array ): GetUint8; - -/** -* Returns an accessor function for retrieving an element from a `Uint8ClampedArray`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var arr = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function resolveGetter( x: Uint8ClampedArray ): GetUint8c; - -/** -* Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol. -* -* @param x - input array -* @returns accessor function -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* function aget( idx ) { -* return arr[ idx ]; -* } -* -* function aset( value, idx ) { -* arr[ idx ] = value; -* } -* -* arr.get = aget; -* arr.set = aset; -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function resolveGetter( x: AccessorArrayLike ): GetAccessorArrayLike; - -/** -* Returns an accessor function for retrieving an element from a "generic" array. -* -* @param x - input array -* @returns accessor function -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function resolveGetter( x: Array ): GetGeneric; - -/** -* Returns an accessor function for retrieving an element from an indexed array-like object. -* -* @param x - input array -* @returns accessor function -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -declare function resolveGetter( x: Collection ): GetArrayLike; - - -// EXPORTS // - -export = resolveGetter; diff --git a/base/resolve-getter/docs/types/test.ts b/base/resolve-getter/docs/types/test.ts deleted file mode 100644 index 1a7f373db..000000000 --- a/base/resolve-getter/docs/types/test.ts +++ /dev/null @@ -1,370 +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. -*/ - -import AccessorArray = require( './../../../../base/accessor' ); -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import resolveGetter = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - resolveGetter( new Float64Array( 0 ) ); // $ExpectType GetFloat64 - resolveGetter( new Float32Array( 0 ) ); // $ExpectType GetFloat32 - resolveGetter( new Int32Array( 0 ) ); // $ExpectType GetInt32 - resolveGetter( new Int16Array( 0 ) ); // $ExpectType GetInt16 - resolveGetter( new Int8Array( 0 ) ); // $ExpectType GetInt8 - resolveGetter( new Uint32Array( 0 ) ); // $ExpectType GetUint32 - resolveGetter( new Uint16Array( 0 ) ); // $ExpectType GetUint16 - resolveGetter( new Uint8Array( 0 ) ); // $ExpectType GetUint8 - resolveGetter( new Uint8ClampedArray( 0 ) ); // $ExpectType GetUint8c - resolveGetter( new Complex128Array( 0 ) ); // $ExpectType GetComplex128 - resolveGetter( new Complex64Array( 0 ) ); // $ExpectType GetComplex64 - resolveGetter( new AccessorArray( [ 1, 2, 3 ] ) ); // $ExpectType GetAccessorArrayLike - resolveGetter( [] ); // $ExpectType GetGeneric - resolveGetter( [] ); // $ExpectType GetGeneric -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - resolveGetter( 5 ); // $ExpectError - resolveGetter( true ); // $ExpectError - resolveGetter( false ); // $ExpectError - resolveGetter( null ); // $ExpectError - resolveGetter( {} ); // $ExpectError - resolveGetter( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - resolveGetter(); // $ExpectError - resolveGetter( [ 1, 2, 3 ], {} ); // $ExpectError -} - -// The function returns a function which returns an array element... -{ - const x1 = [ 1, 2, 3, 4 ]; - const get1 = resolveGetter( x1 ); - get1( x1, 2 ); // $ExpectType number | void - - const x2 = new Float64Array( [ 1, 2, 3, 4 ] ); - const get2 = resolveGetter( x2 ); - get2( x2, 2 ); // $ExpectType number | void - - const x3 = new Float32Array( [ 1, 2, 3, 4 ] ); - const get3 = resolveGetter( x3 ); - get3( x3, 2 ); // $ExpectType number | void - - const x4 = new Int32Array( [ 1, 2, 3, 4 ] ); - const get4 = resolveGetter( x4 ); - get4( x4, 2 ); // $ExpectType number | void - - const x5 = new Int16Array( [ 1, 2, 3, 4 ] ); - const get5 = resolveGetter( x5 ); - get5( x5, 2 ); // $ExpectType number | void - - const x6 = new Int8Array( [ 1, 2, 3, 4 ] ); - const get6 = resolveGetter( x6 ); - get6( x6, 2 ); // $ExpectType number | void - - const x7 = new Uint32Array( [ 1, 2, 3, 4 ] ); - const get7 = resolveGetter( x7 ); - get7( x7, 2 ); // $ExpectType number | void - - const x8 = new Uint16Array( [ 1, 2, 3, 4 ] ); - const get8 = resolveGetter( x8 ); - get8( x8, 2 ); // $ExpectType number | void - - const x9 = new Uint8Array( [ 1, 2, 3, 4 ] ); - const get9 = resolveGetter( x9 ); - get9( x9, 2 ); // $ExpectType number | void - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); - const get10 = resolveGetter( x10 ); - get10( x10, 2 ); // $ExpectType number | void - - const x11 = new Complex128Array( [ 1, 2, 3, 4 ] ); - const get11 = resolveGetter( x11 ); - get11( x11, 0 ); // $ExpectType void | Complex128 - - const x12 = new Complex64Array( [ 1, 2, 3, 4 ] ); - const get12 = resolveGetter( x12 ); - get12( x12, 0 ); // $ExpectType void | Complex64 - - const x13 = new AccessorArray( [ 1, 2, 3, 4 ] ); - const get13 = resolveGetter( x13 ); - get13( x13, 0 ); // $ExpectType number -} - -// The compiler throws an error if the returned function is provided a first argument which is not a collection... -{ - const get1 = resolveGetter( [ 1, 2, 3, 4 ] ); - get1( 5, 2 ); // $ExpectError - get1( true, 2 ); // $ExpectError - get1( false, 2 ); // $ExpectError - get1( null, 2 ); // $ExpectError - get1( {}, 2 ); // $ExpectError - - const get2 = resolveGetter( new Float64Array( 0 ) ); - get2( 5, 2 ); // $ExpectError - get2( true, 2 ); // $ExpectError - get2( false, 2 ); // $ExpectError - get2( null, 2 ); // $ExpectError - get2( {}, 2 ); // $ExpectError - - const get3 = resolveGetter( new Float32Array( 0 ) ); - get3( 5, 2 ); // $ExpectError - get3( true, 2 ); // $ExpectError - get3( false, 2 ); // $ExpectError - get3( null, 2 ); // $ExpectError - get3( {}, 2 ); // $ExpectError - - const get4 = resolveGetter( new Int32Array( 0 ) ); - get4( 5, 2 ); // $ExpectError - get4( true, 2 ); // $ExpectError - get4( false, 2 ); // $ExpectError - get4( null, 2 ); // $ExpectError - get4( {}, 2 ); // $ExpectError - - const get5 = resolveGetter( new Int16Array( 0 ) ); - get5( 5, 2 ); // $ExpectError - get5( true, 2 ); // $ExpectError - get5( false, 2 ); // $ExpectError - get5( null, 2 ); // $ExpectError - get5( {}, 2 ); // $ExpectError - - const get6 = resolveGetter( new Int8Array( 0 ) ); - get6( 5, 2 ); // $ExpectError - get6( true, 2 ); // $ExpectError - get6( false, 2 ); // $ExpectError - get6( null, 2 ); // $ExpectError - get6( {}, 2 ); // $ExpectError - - const get7 = resolveGetter( new Uint32Array( 0 ) ); - get7( 5, 2 ); // $ExpectError - get7( true, 2 ); // $ExpectError - get7( false, 2 ); // $ExpectError - get7( null, 2 ); // $ExpectError - get7( {}, 2 ); // $ExpectError - - const get8 = resolveGetter( new Uint16Array( 0 ) ); - get8( 5, 2 ); // $ExpectError - get8( true, 2 ); // $ExpectError - get8( false, 2 ); // $ExpectError - get8( null, 2 ); // $ExpectError - get8( {}, 2 ); // $ExpectError - - const get9 = resolveGetter( new Uint8Array( 0 ) ); - get9( 5, 2 ); // $ExpectError - get9( true, 2 ); // $ExpectError - get9( false, 2 ); // $ExpectError - get9( null, 2 ); // $ExpectError - get9( {}, 2 ); // $ExpectError - - const get10 = resolveGetter( new Uint8ClampedArray( 0 ) ); - get10( 5, 2 ); // $ExpectError - get10( true, 2 ); // $ExpectError - get10( false, 2 ); // $ExpectError - get10( null, 2 ); // $ExpectError - get10( {}, 2 ); // $ExpectError - - const get11 = resolveGetter( new Complex128Array( 0 ) ); - get11( 5, 2 ); // $ExpectError - get11( true, 2 ); // $ExpectError - get11( false, 2 ); // $ExpectError - get11( null, 2 ); // $ExpectError - get11( {}, 2 ); // $ExpectError - - const get12 = resolveGetter( new Complex64Array( 0 ) ); - get12( 5, 2 ); // $ExpectError - get12( true, 2 ); // $ExpectError - get12( false, 2 ); // $ExpectError - get12( null, 2 ); // $ExpectError - get12( {}, 2 ); // $ExpectError - - const get13 = resolveGetter( new AccessorArray( [ 1, 2, 3, 4 ] ) ); - get13( 5, 2 ); // $ExpectError - get13( true, 2 ); // $ExpectError - get13( false, 2 ); // $ExpectError - get13( null, 2 ); // $ExpectError - get13( {}, 2 ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided a second argument which is not a number... -{ - const get1 = resolveGetter( [ 0, 1, 2, 3, 4 ] ); - get1( [ 1, 2, 3, 4 ], '5' ); // $ExpectError - get1( [ 1, 2, 3, 4 ], true ); // $ExpectError - get1( [ 1, 2, 3, 4 ], false ); // $ExpectError - get1( [ 1, 2, 3, 4 ], null ); // $ExpectError - get1( [ 1, 2, 3, 4 ], {} ); // $ExpectError - - const get2 = resolveGetter( new Float64Array( 0 ) ); - get2( new Float64Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get2( new Float64Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get2( new Float64Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get2( new Float64Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get2( new Float64Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get3 = resolveGetter( new Float32Array( 0 ) ); - get3( new Float32Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get3( new Float32Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get3( new Float32Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get3( new Float32Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get3( new Float32Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get4 = resolveGetter( new Int32Array( 0 ) ); - get4( new Int32Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get4( new Int32Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get4( new Int32Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get4( new Int32Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get4( new Int32Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get5 = resolveGetter( new Int16Array( 0 ) ); - get5( new Int16Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get5( new Int16Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get5( new Int16Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get5( new Int16Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get5( new Int16Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get6 = resolveGetter( new Int8Array( 0 ) ); - get6( new Int8Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get6( new Int8Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get6( new Int8Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get6( new Int8Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get6( new Int8Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get7 = resolveGetter( new Uint32Array( 0 ) ); - get7( new Uint32Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get7( new Uint32Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get7( new Uint32Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get7( new Uint32Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get7( new Uint32Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get8 = resolveGetter( new Uint16Array( 0 ) ); - get8( new Uint16Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get8( new Uint16Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get8( new Uint16Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get8( new Uint16Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get8( new Uint16Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get9 = resolveGetter( new Uint8Array( 0 ) ); - get9( new Uint8Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get9( new Uint8Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get9( new Uint8Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get9( new Uint8Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get9( new Uint8Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get10 = resolveGetter( new Uint8ClampedArray( 0 ) ); - get10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get11 = resolveGetter( new Complex128Array( 0 ) ); - get11( new Complex128Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get11( new Complex128Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get11( new Complex128Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get11( new Complex128Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get11( new Complex128Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get12 = resolveGetter( new Complex64Array( 0 ) ); - get12( new Complex64Array( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get12( new Complex64Array( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get12( new Complex64Array( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get12( new Complex64Array( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get12( new Complex64Array( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError - - const get13 = resolveGetter( new AccessorArray( [ 1, 2, 3, 4 ] ) ); - get13( new AccessorArray( [ 1, 2, 3, 4 ] ), '5' ); // $ExpectError - get13( new AccessorArray( [ 1, 2, 3, 4 ] ), true ); // $ExpectError - get13( new AccessorArray( [ 1, 2, 3, 4 ] ), false ); // $ExpectError - get13( new AccessorArray( [ 1, 2, 3, 4 ] ), null ); // $ExpectError - get13( new AccessorArray( [ 1, 2, 3, 4 ] ), {} ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided an unsupported number of arguments... -{ - const get1 = resolveGetter( [] ); - get1(); // $ExpectError - get1( [] ); // $ExpectError - get1( [], 1, 2 ); // $ExpectError - - const get2 = resolveGetter( new Float64Array( 0 ) ); - get2(); // $ExpectError - get2( new Float64Array( [] ) ); // $ExpectError - get2( new Float64Array( [] ), 1, 2 ); // $ExpectError - - const get3 = resolveGetter( new Float32Array( 0 ) ); - get3(); // $ExpectError - get3( new Float32Array( [] ) ); // $ExpectError - get3( new Float32Array( [] ), 1, 2 ); // $ExpectError - - const get4 = resolveGetter( new Int32Array( 0 ) ); - get4(); // $ExpectError - get4( new Int32Array( [] ) ); // $ExpectError - get4( new Int32Array( [] ), 1, 2 ); // $ExpectError - - const get5 = resolveGetter( new Int16Array( 0 ) ); - get5(); // $ExpectError - get5( new Int16Array( [] ) ); // $ExpectError - get5( new Int16Array( [] ), 1, 2 ); // $ExpectError - - const get6 = resolveGetter( new Int8Array( 0 ) ); - get6(); // $ExpectError - get6( new Int8Array( [] ) ); // $ExpectError - get6( new Int8Array( [] ), 1, 2 ); // $ExpectError - - const get7 = resolveGetter( new Uint32Array( 0 ) ); - get7(); // $ExpectError - get7( new Uint32Array( [] ) ); // $ExpectError - get7( new Uint32Array( [] ), 1, 2 ); // $ExpectError - - const get8 = resolveGetter( new Uint16Array( 0 ) ); - get8(); // $ExpectError - get8( new Uint16Array( [] ) ); // $ExpectError - get8( new Uint16Array( [] ), 1, 2 ); // $ExpectError - - const get9 = resolveGetter( new Uint8Array( 0 ) ); - get9(); // $ExpectError - get9( new Uint8Array( [] ) ); // $ExpectError - get9( new Uint8Array( [] ), 1, 2 ); // $ExpectError - - const get10 = resolveGetter( new Uint8ClampedArray( 0 ) ); - get10(); // $ExpectError - get10( new Uint8ClampedArray( [] ) ); // $ExpectError - get10( new Uint8ClampedArray( [] ), 1, 2 ); // $ExpectError - - const get11 = resolveGetter( new Complex128Array( 0 ) ); - get11(); // $ExpectError - get11( new Complex128Array( 0 ) ); // $ExpectError - get11( new Complex128Array( 0 ), 1, 2 ); // $ExpectError - - const get12 = resolveGetter( new Complex64Array( 0 ) ); - get12(); // $ExpectError - get12( new Complex64Array( 0 ) ); // $ExpectError - get12( new Complex64Array( 0 ), 1, 2 ); // $ExpectError - - const get13 = resolveGetter( new AccessorArray( [ 1, 2, 3, 4 ] ) ); - get13(); // $ExpectError - get13( new AccessorArray( [ 1, 2, 3, 4 ] ) ); // $ExpectError - get13( new AccessorArray( [ 1, 2, 3, 4 ] ), 1, 2 ); // $ExpectError -} diff --git a/base/resolve-getter/examples/index.js b/base/resolve-getter/examples/index.js deleted file mode 100644 index 037c8b2ec..000000000 --- a/base/resolve-getter/examples/index.js +++ /dev/null @@ -1,58 +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'; - -var filled = require( './../../../filled' ); -var resolveGetter = require( './../lib' ); - -var arr = filled( 1.0, 10, 'float64' ); -var v = resolveGetter( arr )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 2.0, 10, 'float32' ); -v = resolveGetter( arr )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 3, 10, 'int32' ); -v = resolveGetter( arr )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 4, 10, 'int16' ); -v = resolveGetter( arr )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 5, 10, 'int8' ); -v = resolveGetter( arr )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 6, 10, 'uint32' ); -v = resolveGetter( arr )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 7, 10, 'uint16' ); -v = resolveGetter( arr )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 8, 10, 'uint8' ); -v = resolveGetter( arr )( arr, 2 ); -console.log( 'v: %d', v ); - -arr = filled( 9, 10, 'uint8c' ); -v = resolveGetter( arr )( arr, 2 ); -console.log( 'v: %d', v ); diff --git a/base/resolve-getter/lib/index.js b/base/resolve-getter/lib/index.js deleted file mode 100644 index 0125f3ba1..000000000 --- a/base/resolve-getter/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Return an accessor function for retrieving an element from an array-like object. -* -* @module @stdlib/array/base/resolve-getter -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* -* var arr = [ 1, 2, 3, 4 ]; -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/resolve-getter/lib/main.js b/base/resolve-getter/lib/main.js deleted file mode 100644 index 2bca5b8e5..000000000 --- a/base/resolve-getter/lib/main.js +++ /dev/null @@ -1,55 +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 isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var accessorGetter = require( './../../../base/accessor-getter' ); -var getter = require( './../../../base/getter' ); -var dtype = require( './../../../dtype' ); - - -// MAIN // - -/** -* Returns an accessor function for retrieving an element from an array-like object. -* -* @param {Collection} x - input array -* @returns {Function} accessor -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 3 -*/ -function resolveGetter( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return accessorGetter( dt ); - } - return getter( dt ); -} - - -// EXPORTS // - -module.exports = resolveGetter; diff --git a/base/resolve-getter/package.json b/base/resolve-getter/package.json deleted file mode 100644 index a51ea63d4..000000000 --- a/base/resolve-getter/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/resolve-getter", - "version": "0.0.0", - "description": "Return an accessor function for retrieving an element from an array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "array", - "generic", - "get", - "accessor", - "access", - "retrieve", - "getter", - "resolve" - ] -} diff --git a/base/resolve-getter/test/test.js b/base/resolve-getter/test/test.js deleted file mode 100644 index 456eb5148..000000000 --- a/base/resolve-getter/test/test.js +++ /dev/null @@ -1,173 +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 filled = require( './../../../filled' ); -var accessorArray = require( './../../../base/accessor' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var zeroTo = require( './../../../base/zero-to' ); -var dtypes = require( './../../../typed-real-dtypes' ); -var resolveGetter = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -DTYPES.push( 'generic' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof resolveGetter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function for returning an array element (indexed)', function test( t ) { - var arr; - var get; - var dt; - var v; - var i; - - for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - arr = filled( i+1, 10, dt ); - get = resolveGetter( arr ); - v = get( arr, 2 ); - t.strictEqual( v, i+1, 'returns expected value for dtype: '+dt ); - } - t.end(); -}); - -tape( 'the function returns a function for returning an array element (accessor)', function test( t ) { - var arr; - var get; - var v; - - arr = new Complex128Array( zeroTo( 10 ) ); - get = resolveGetter( arr ); - v = get( arr, 2 ); - t.strictEqual( real( v ), 4.0, 'returns expected value' ); - t.strictEqual( imag( v ), 5.0, 'returns expected value' ); - - arr = new Complex64Array( zeroTo( 10 ) ); - get = resolveGetter( arr ); - v = get( arr, 2 ); - t.strictEqual( realf( v ), 4.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 5.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function for returning an array element (indexed; unrecognized dtype)', function test( t ) { - var arr; - var get; - var v; - - arr = filled( 2, 10, 'generic' ); - get = resolveGetter( 'beep boop' ); - v = get( arr, 2 ); - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function for returning an array element (accessor; unrecognized dtype)', function test( t ) { - var arr; - var get; - var v; - - arr = accessorArray( [ 1, 2, 3, 4 ] ); - get = resolveGetter( arr ); - v = get( arr, 2 ); - t.strictEqual( v, 3, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (indexed)', function test( t ) { - var arr; - var get; - var dt; - var v; - var i; - - for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - arr = filled( i+1, 10, dt ); - get = resolveGetter( arr ); - v = get( arr, arr.length+10 ); - t.strictEqual( v, void 0, 'returns expected value for dtype: '+dt ); - } - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (accessor)', function test( t ) { - var arr; - var get; - var v; - - arr = new Complex128Array( zeroTo( 10 ) ); - get = resolveGetter( arr ); - v = get( arr, arr.length+10 ); - t.strictEqual( v, void 0, 'returns expected value' ); - - arr = new Complex64Array( zeroTo( 10 ) ); - get = resolveGetter( arr ); - v = get( arr, arr.length+10 ); - t.strictEqual( v, void 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (indexed; unrecognized dtype)', function test( t ) { - var arr; - var get; - var v; - - get = resolveGetter( 'beep boop' ); - arr = filled( 2, 10, 'generic' ); - v = get( arr, arr.length+10 ); - t.strictEqual( v, void 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (accessor; unrecognized dtype)', function test( t ) { - var arr; - var get; - var v; - - arr = accessorArray( [] ); - get = resolveGetter( arr ); - v = get( arr, arr.length+10 ); - t.strictEqual( v, void 0, 'returns expected value' ); - - t.end(); -}); diff --git a/base/resolve-setter/README.md b/base/resolve-setter/README.md deleted file mode 100644 index bc8844dbe..000000000 --- a/base/resolve-setter/README.md +++ /dev/null @@ -1,162 +0,0 @@ - - -# resolveSetter - -> Return an accessor function for setting an element in an array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var resolveSetter = require( '@stdlib/array/base/resolve-setter' ); -``` - -#### resolveSetter( x ) - -Returns an accessor function for setting an element in an array-like object. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var set = resolveSetter( x ); -// returns - -set( x, 2, 10 ); - -var v = x[ 2 ]; -// returns 10 -``` - -The returned accessor function accepts the following arguments: - -- **arr**: input array. -- **idx**: element index. -- **value**: value to set. - -
- - - - - -
- -## Notes - -- If provided an array-like object having an unsupported [data type][@stdlib/array/dtypes], the function returns a default accessor function for accessing elements in any array-like object; otherwise, the function returns an accessor function which should **only** be provided an array instance having the same data type (e.g., if provided a `Float64Array`, the returned accessor function should only be provided instances of `Float64Array`). -- Accessor functions do **not** verify that provided input arrays are array instances having a specific data type, as doing so would introduce performance overhead. If array instances corresponding to other data types are provided to an accessor function, JavaScript runtimes will consider the function polymorphic, potentially triggering de-optimization. In order to ensure maximum performance, **always** ensure that an accessor function is monomorphic. -- Accessor functions do **not** perform bounds checking. -- Accessor functions do **not** verify that provided input arrays implement the get/set protocol. -- An _indexed_ array-like object is a data structure in which one retrieves elements via integer indices using bracket `[]` notation (e.g., `Float64Array`, `Int32Array`, `Array`, etc). This is in contrast to an _accessor_ array-like object in which one retrieves elements using `get` and `set` methods (e.g., `Complex64Array` and `Complex128Array`). - -
- - - - - -
- -## Examples - - - -```javascript -var filled = require( '@stdlib/array/filled' ); -var resolveSetter = require( '@stdlib/array/base/resolve-setter' ); - -var arr = filled( 1.0, 10, 'float64' ); -resolveSetter( arr )( arr, 2, 100.0 ); -console.log( arr ); - -arr = filled( 2.0, 10, 'float32' ); -resolveSetter( arr )( arr, 2, 100.0 ); -console.log( arr ); - -arr = filled( 3, 10, 'int32' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 4, 10, 'int16' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 5, 10, 'int8' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 6, 10, 'uint32' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 7, 10, 'uint16' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 8, 10, 'uint8' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 9, 10, 'uint8c' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/resolve-setter/benchmark/benchmark.js b/base/resolve-setter/benchmark/benchmark.js deleted file mode 100644 index 7954dff8c..000000000 --- a/base/resolve-setter/benchmark/benchmark.js +++ /dev/null @@ -1,335 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isFunction = require( '@stdlib/assert/is-function' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var filledBy = require( './../../../filled-by' ); -var pkg = require( './../package.json' ).name; -var resolveSetter = require( './../lib' ); - - -// VARIABLES // - -var rand = discreteUniform( 0, 127 ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var set; - var i; - - values = [ - filledBy( 10, 'generic', rand ), - filledBy( 10, 'float64', rand ), - filledBy( 10, 'float32', rand ), - filledBy( 10, 'int32', rand ), - filledBy( 10, 'uint32', rand ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - set = resolveSetter( values[ i%values.length ] ); - if ( typeof set !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( set ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'generic', rand ); - set = resolveSetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'float64', rand ); - set = resolveSetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'float32', rand ); - set = resolveSetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'int32', rand ); - set = resolveSetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'int16', rand ); - set = resolveSetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'int8', rand ); - set = resolveSetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'uint32', rand ); - set = resolveSetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'uint16', rand ); - set = resolveSetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'uint8', rand ); - set = resolveSetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'uint8c', rand ); - set = resolveSetter( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/resolve-setter/docs/repl.txt b/base/resolve-setter/docs/repl.txt deleted file mode 100644 index 5465b6039..000000000 --- a/base/resolve-setter/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( x ) - Returns an accessor function for setting an element in an array-like object. - - An accessor function accepts the following arguments: - - - arr: input array. - - idx: element index. - - value: value to set. - - If provided an array-like object having an unsupported data type, the - function returns a default accessor function for accessing elements in any - indexed array-like object. - - Otherwise, the function returns an accessor function which should *only* be - provided an array instance having the same data type (e.g., if provided a - Float64Array, the returned accessor function should only be provided - instances of Float64Array). - - Accessor functions do *not* verify that provided input arrays are array - instances having a specific data type, as doing so would introduce - performance overhead. If array instances corresponding to other data types - are provided to an accessor function, JavaScript runtimes will consider the - function polymorphic, potentially triggering de-optimization. In order to - ensure maximum performance, *always* ensure that an accessor function is - monomorphic. - - Accessor functions do *not* perform bounds checking. - - Accessor functions do *not* verify that provided input arrays implement the - get/set protocol. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - f: Function - Accessor function. - - Examples - -------- - > var f = {{alias}}( [ 5, 6, 7, 8 ] ); - > var x = [ 1, 2, 3, 4 ]; - > f( x, 2, 10 ); - > x - [ 1, 2, 10, 4 ] - - See Also - -------- - diff --git a/base/resolve-setter/docs/types/index.d.ts b/base/resolve-setter/docs/types/index.d.ts deleted file mode 100644 index 4134ba538..000000000 --- a/base/resolve-setter/docs/types/index.d.ts +++ /dev/null @@ -1,475 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ComplexLike } from '@stdlib/types/complex'; -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Returns an accessor function for setting an element in a `Float64Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10.0 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10.0 -*/ -declare function resolveSetter( x: Float64Array ): SetFloat64; - -/** -* Returns an accessor function for setting an element in a `Float32Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10.0 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10.0 -*/ -declare function resolveSetter( x: Float32Array ): SetFloat32; - -/** -* Returns an accessor function for setting an element in a `Complex128Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/array/real' ); -* var imag = require( '@stdlib/array/imag' ); -* -* var arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* var set = resolveSetter( arr ); -* set( arr, 1, new Complex128( 10.0, 11.0 ) ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns -* -* var re = real( v ); -* // returns 10.0 -* -* var im = imag( v ); -* // returns 11.0 -*/ -declare function resolveSetter( x: Complex128Array ): SetComplex128; - -/** -* Returns an accessor function for setting an element in a `Complex64Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var Complex64Array = require( '@stdlib/array/complex64' ); -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/array/realf' ); -* var imagf = require( '@stdlib/array/imagf' ); -* -* var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* var set = resolveSetter( arr ); -* set( arr, 1, new Complex64( 10.0, 11.0 ) ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns -* -* var re = realf( v ); -* // returns 10.0 -* -* var im = imagf( v ); -* // returns 11.0 -*/ -declare function resolveSetter( x: Complex64Array ): SetComplex64; - -/** -* Returns an accessor function for setting an element in an `Int32Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var arr = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10 -*/ -declare function resolveSetter( x: Int32Array ): SetInt32; - -/** -* Returns an accessor function for setting an element in an `Int16Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var arr = new Int16Array( [ 1, 2, 3, 4 ] ); -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10 -*/ -declare function resolveSetter( x: Int16Array ): SetInt16; - -/** -* Returns an accessor function for setting an element in an `Int8Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var arr = new Int8Array( [ 1, 2, 3, 4 ] ); -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10 -*/ -declare function resolveSetter( x: Int8Array ): SetInt8; - -/** -* Returns an accessor function for setting an element in a `Uint32Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var arr = new Uint32Array( [ 1, 2, 3, 4 ] ); -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10 -*/ -declare function resolveSetter( x: Uint32Array ): SetUint32; - -/** -* Returns an accessor function for setting an element in a `Uint16Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var arr = new Uint16Array( [ 1, 2, 3, 4 ] ); -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10 -*/ -declare function resolveSetter( x: Uint16Array ): SetUint16; - -/** -* Returns an accessor function for setting an element in a `Uint8Array`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var arr = new Uint8Array( [ 1, 2, 3, 4 ] ); -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10 -*/ -declare function resolveSetter( x: Uint8Array ): SetUint8; - -/** -* Returns an accessor function for setting an element in a `Uint8ClampedArray`. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var arr = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10 -*/ -declare function resolveSetter( x: Uint8ClampedArray ): SetUint8c; - -/** -* Returns an accessor function for setting an element in an array-like object supporting the get/set protocol. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* -* var arr = [ 1, 2, 3, 4 ]; -* -* function aget( idx ) { -* return arr[ idx ]; -* } -* -* function aset( value, idx ) { -* arr[ idx ] = value; -* } -* -* arr.get = aget; -* arr.set = aset; -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10 -*/ -declare function resolveSetter( x: AccessorArrayLike ): SetAccessorArrayLike; - -/** -* Returns an accessor function for setting an element in a "generic" array. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* -* var arr = [ 1, 2, 3, 4 ]; -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10 -*/ -declare function resolveSetter( x: Array ): SetGeneric; - -/** -* Returns an accessor function for setting an element in an indexed array-like object. -* -* @param x - input array -* @returns accessor function -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* -* var arr = [ 1, 2, 3, 4 ]; -* -* var set = resolveSetter( arr ); -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* var v = get( arr, 2 ); -* // returns 10 -*/ -declare function resolveSetter( x: Collection ): SetArrayLike; - - -// EXPORTS // - -export = resolveSetter; diff --git a/base/resolve-setter/docs/types/test.ts b/base/resolve-setter/docs/types/test.ts deleted file mode 100644 index 0e2f6cc21..000000000 --- a/base/resolve-setter/docs/types/test.ts +++ /dev/null @@ -1,466 +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. -*/ - -import AccessorArray = require( './../../../../base/accessor' ); -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import Complex64 = require( '@stdlib/complex/float32/ctor' ); -import resolveSetter = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - resolveSetter( new Float64Array( 0 ) ); // $ExpectType SetFloat64 - resolveSetter( new Float32Array( 0 ) ); // $ExpectType SetFloat32 - resolveSetter( new Int32Array( 0 ) ); // $ExpectType SetInt32 - resolveSetter( new Int16Array( 0 ) ); // $ExpectType SetInt16 - resolveSetter( new Int8Array( 0 ) ); // $ExpectType SetInt8 - resolveSetter( new Uint32Array( 0 ) ); // $ExpectType SetUint32 - resolveSetter( new Uint16Array( 0 ) ); // $ExpectType SetUint16 - resolveSetter( new Uint8Array( 0 ) ); // $ExpectType SetUint8 - resolveSetter( new Uint8ClampedArray( 0 ) ); // $ExpectType SetUint8c - resolveSetter( new Complex128Array( 0 ) ); // $ExpectType SetComplex128 - resolveSetter( new Complex64Array( 0 ) ); // $ExpectType SetComplex64 - resolveSetter( new AccessorArray( [ 1, 2, 3 ] ) ); // $ExpectType SetAccessorArrayLike - resolveSetter( [] ); // $ExpectType SetGeneric - resolveSetter( [] ); // $ExpectType SetGeneric -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - resolveSetter( 5 ); // $ExpectError - resolveSetter( true ); // $ExpectError - resolveSetter( false ); // $ExpectError - resolveSetter( null ); // $ExpectError - resolveSetter( {} ); // $ExpectError - resolveSetter( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - resolveSetter(); // $ExpectError - resolveSetter( [ 1, 2, 3 ], {} ); // $ExpectError -} - -// The function returns a function which sets an array element... -{ - const x1 = [ 1, 2, 3, 4 ]; - const set1 = resolveSetter( x1 ); - set1( x1, 2, 10 ); // $ExpectType void - - const x2 = new Float64Array( [ 1, 2, 3, 4 ] ); - const set2 = resolveSetter( x2 ); - set2( x2, 2, 10 ); // $ExpectType void - - const x3 = new Float32Array( [ 1, 2, 3, 4 ] ); - const set3 = resolveSetter( x3 ); - set3( x3, 2, 10 ); // $ExpectType void - - const x4 = new Int32Array( [ 1, 2, 3, 4 ] ); - const set4 = resolveSetter( x4 ); - set4( x4, 2, 10 ); // $ExpectType void - - const x5 = new Int16Array( [ 1, 2, 3, 4 ] ); - const set5 = resolveSetter( x5 ); - set5( x5, 2, 10 ); // $ExpectType void - - const x6 = new Int8Array( [ 1, 2, 3, 4 ] ); - const set6 = resolveSetter( x6 ); - set6( x6, 2, 10 ); // $ExpectType void - - const x7 = new Uint32Array( [ 1, 2, 3, 4 ] ); - const set7 = resolveSetter( x7 ); - set7( x7, 2, 10 ); // $ExpectType void - - const x8 = new Uint16Array( [ 1, 2, 3, 4 ] ); - const set8 = resolveSetter( x8 ); - set8( x8, 2, 10 ); // $ExpectType void - - const x9 = new Uint8Array( [ 1, 2, 3, 4 ] ); - const set9 = resolveSetter( x9 ); - set9( x9, 2, 10 ); // $ExpectType void - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); - const set10 = resolveSetter( x10 ); - set10( x10, 2, 10 ); // $ExpectType void - - const x11 = new Complex128Array( [ 1, 2, 3, 4 ] ); - const set11 = resolveSetter( x11 ); - set11( x11, 0, new Complex128( 5, 6 ) ); // $ExpectType void - - const x12 = new Complex64Array( [ 1, 2, 3, 4 ] ); - const set12 = resolveSetter( x12 ); - set12( x12, 0, new Complex64( 5, 6 ) ); // $ExpectType void - - const x13 = new AccessorArray( [ 1, 2, 3, 4 ] ); - const set13 = resolveSetter( x13 ); - set13( x13, 2, 10 ); // $ExpectType void -} - -// The compiler throws an error if the returned function is provided a first argument which is not a collection... -{ - const set1 = resolveSetter( [ 1, 2, 3, 4 ] ); - set1( 5, 2, 10 ); // $ExpectError - set1( true, 2, 10 ); // $ExpectError - set1( false, 2, 10 ); // $ExpectError - set1( null, 2, 10 ); // $ExpectError - set1( {}, 2, 10 ); // $ExpectError - - const set2 = resolveSetter( new Float64Array( 0 ) ); - set2( 5, 2, 10 ); // $ExpectError - set2( true, 2, 10 ); // $ExpectError - set2( false, 2, 10 ); // $ExpectError - set2( null, 2, 10 ); // $ExpectError - set2( {}, 2, 10 ); // $ExpectError - - const set3 = resolveSetter( new Float32Array( 0 ) ); - set3( 5, 2, 10 ); // $ExpectError - set3( true, 2, 10 ); // $ExpectError - set3( false, 2, 10 ); // $ExpectError - set3( null, 2, 10 ); // $ExpectError - set3( {}, 2, 10 ); // $ExpectError - - const set4 = resolveSetter( new Int32Array( 0 ) ); - set4( 5, 2, 10 ); // $ExpectError - set4( true, 2, 10 ); // $ExpectError - set4( false, 2, 10 ); // $ExpectError - set4( null, 2, 10 ); // $ExpectError - set4( {}, 2, 10 ); // $ExpectError - - const set5 = resolveSetter( new Int16Array( 0 ) ); - set5( 5, 2, 10 ); // $ExpectError - set5( true, 2, 10 ); // $ExpectError - set5( false, 2, 10 ); // $ExpectError - set5( null, 2, 10 ); // $ExpectError - set5( {}, 2, 10 ); // $ExpectError - - const set6 = resolveSetter( new Int8Array( 0 ) ); - set6( 5, 2, 10 ); // $ExpectError - set6( true, 2, 10 ); // $ExpectError - set6( false, 2, 10 ); // $ExpectError - set6( null, 2, 10 ); // $ExpectError - set6( {}, 2, 10 ); // $ExpectError - - const set7 = resolveSetter( new Uint32Array( 0 ) ); - set7( 5, 2, 10 ); // $ExpectError - set7( true, 2, 10 ); // $ExpectError - set7( false, 2, 10 ); // $ExpectError - set7( null, 2, 10 ); // $ExpectError - set7( {}, 2, 10 ); // $ExpectError - - const set8 = resolveSetter( new Uint16Array( 0 ) ); - set8( 5, 2, 10 ); // $ExpectError - set8( true, 2, 10 ); // $ExpectError - set8( false, 2, 10 ); // $ExpectError - set8( null, 2, 10 ); // $ExpectError - set8( {}, 2, 10 ); // $ExpectError - - const set9 = resolveSetter( new Uint8Array( 0 ) ); - set9( 5, 2, 10 ); // $ExpectError - set9( true, 2, 10 ); // $ExpectError - set9( false, 2, 10 ); // $ExpectError - set9( null, 2, 10 ); // $ExpectError - set9( {}, 2, 10 ); // $ExpectError - - const set10 = resolveSetter( new Uint8ClampedArray( 0 ) ); - set10( 5, 2, 10 ); // $ExpectError - set10( true, 2, 10 ); // $ExpectError - set10( false, 2, 10 ); // $ExpectError - set10( null, 2, 10 ); // $ExpectError - set10( {}, 2, 10 ); // $ExpectError - - const set11 = resolveSetter( new Complex128Array( 0 ) ); - set11( 5, 2, new Complex128( 0, 0 ) ); // $ExpectError - set11( true, 2, new Complex128( 0, 0 ) ); // $ExpectError - set11( false, 2, new Complex128( 0, 0 ) ); // $ExpectError - set11( null, 2, new Complex128( 0, 0 ) ); // $ExpectError - set11( {}, 2, new Complex128( 0, 0 ) ); // $ExpectError - - const set12 = resolveSetter( new Complex64Array( 0 ) ); - set12( 5, 2, new Complex64( 0, 0 ) ); // $ExpectError - set12( true, 2, new Complex64( 0, 0 ) ); // $ExpectError - set12( false, 2, new Complex64( 0, 0 ) ); // $ExpectError - set12( null, 2, new Complex64( 0, 0 ) ); // $ExpectError - set12( {}, 2, new Complex64( 0, 0 ) ); // $ExpectError - - const set13 = resolveSetter( new AccessorArray( [ 1, 2, 3, 4 ] ) ); - set13( 5, 2, 10 ); // $ExpectError - set13( true, 2, 10 ); // $ExpectError - set13( false, 2, 10 ); // $ExpectError - set13( null, 2, 10 ); // $ExpectError - set13( {}, 2, 10 ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided a second argument which is not a number... -{ - const set1 = resolveSetter( [ 0, 1, 2, 3, 4 ] ); - set1( [ 1, 2, 3, 4 ], '5', 10 ); // $ExpectError - set1( [ 1, 2, 3, 4 ], true, 10 ); // $ExpectError - set1( [ 1, 2, 3, 4 ], false, 10 ); // $ExpectError - set1( [ 1, 2, 3, 4 ], null, 10 ); // $ExpectError - set1( [ 1, 2, 3, 4 ], {}, 10 ); // $ExpectError - - const set2 = resolveSetter( new Float64Array( 0 ) ); - set2( new Float64Array( [ 1, 2, 3, 4 ] ), '5', 10 ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), true, 10 ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), false, 10 ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), null, 10 ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), {}, 10 ); // $ExpectError - - const set3 = resolveSetter( new Float32Array( 0 ) ); - set3( new Float32Array( [ 1, 2, 3, 4 ] ), '5', 10 ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), true, 10 ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), false, 10 ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), null, 10 ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), {}, 10 ); // $ExpectError - - const set4 = resolveSetter( new Int32Array( 0 ) ); - set4( new Int32Array( [ 1, 2, 3, 4 ] ), '5', 10 ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), true, 10 ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), false, 10 ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), null, 10 ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), {}, 10 ); // $ExpectError - - const set5 = resolveSetter( new Int16Array( 0 ) ); - set5( new Int16Array( [ 1, 2, 3, 4 ] ), '5', 10 ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), true, 10 ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), false, 10 ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), null, 10 ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), {}, 10 ); // $ExpectError - - const set6 = resolveSetter( new Int8Array( 0 ) ); - set6( new Int8Array( [ 1, 2, 3, 4 ] ), '5', 10 ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), true, 10 ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), false, 10 ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), null, 10 ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), {}, 10 ); // $ExpectError - - const set7 = resolveSetter( new Uint32Array( 0 ) ); - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), '5', 10 ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), true, 10 ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), false, 10 ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), null, 10 ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), {}, 10 ); // $ExpectError - - const set8 = resolveSetter( new Uint16Array( 0 ) ); - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), '5', 10 ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), true, 10 ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), false, 10 ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), null, 10 ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), {}, 10 ); // $ExpectError - - const set9 = resolveSetter( new Uint8Array( 0 ) ); - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), '5', 10 ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), true, 10 ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), false, 10 ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), null, 10 ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), {}, 10 ); // $ExpectError - - const set10 = resolveSetter( new Uint8ClampedArray( 0 ) ); - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), '5', 10 ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), true, 10 ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), false, 10 ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), null, 10 ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), {}, 10 ); // $ExpectError - - const set11 = resolveSetter( new Complex128Array( 0 ) ); - set11( new Complex128Array( [ 1, 2, 3, 4 ] ), '5', new Complex128( 0, 0 ) ); // $ExpectError - set11( new Complex128Array( [ 1, 2, 3, 4 ] ), true, new Complex128( 0, 0 ) ); // $ExpectError - set11( new Complex128Array( [ 1, 2, 3, 4 ] ), false, new Complex128( 0, 0 ) ); // $ExpectError - set11( new Complex128Array( [ 1, 2, 3, 4 ] ), null, new Complex128( 0, 0 ) ); // $ExpectError - set11( new Complex128Array( [ 1, 2, 3, 4 ] ), {}, new Complex128( 0, 0 ) ); // $ExpectError - - const set12 = resolveSetter( new Complex64Array( 0 ) ); - set12( new Complex64Array( [ 1, 2, 3, 4 ] ), '5', new Complex64( 0, 0 ) ); // $ExpectError - set12( new Complex64Array( [ 1, 2, 3, 4 ] ), true, new Complex64( 0, 0 ) ); // $ExpectError - set12( new Complex64Array( [ 1, 2, 3, 4 ] ), false, new Complex64( 0, 0 ) ); // $ExpectError - set12( new Complex64Array( [ 1, 2, 3, 4 ] ), null, new Complex64( 0, 0 ) ); // $ExpectError - set12( new Complex64Array( [ 1, 2, 3, 4 ] ), {}, new Complex64( 0, 0 ) ); // $ExpectError - - const set13 = resolveSetter( new AccessorArray( [ 1, 2, 3, 4 ] ) ); - set13( new AccessorArray( [ 1, 2, 3, 4 ] ), '5', 10 ); // $ExpectError - set13( new AccessorArray( [ 1, 2, 3, 4 ] ), true, 10 ); // $ExpectError - set13( new AccessorArray( [ 1, 2, 3, 4 ] ), false, 10 ); // $ExpectError - set13( new AccessorArray( [ 1, 2, 3, 4 ] ), null, 10 ); // $ExpectError - set13( new AccessorArray( [ 1, 2, 3, 4 ] ), {}, 10 ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided a third argument which is not a valid value... -{ - const set1 = resolveSetter( [ 0, 1, 2, 3, 4 ] ); - set1( [ 1, 2, 3, 4 ], 2, '5' ); // $ExpectError - set1( [ 1, 2, 3, 4 ], 2, true ); // $ExpectError - set1( [ 1, 2, 3, 4 ], 2, false ); // $ExpectError - set1( [ 1, 2, 3, 4 ], 2, null ); // $ExpectError - set1( [ 1, 2, 3, 4 ], 2, {} ); // $ExpectError - - const set2 = resolveSetter( new Float64Array( 0 ) ); - set2( new Float64Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set3 = resolveSetter( new Float32Array( 0 ) ); - set3( new Float32Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set4 = resolveSetter( new Int32Array( 0 ) ); - set4( new Int32Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set5 = resolveSetter( new Int16Array( 0 ) ); - set5( new Int16Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set6 = resolveSetter( new Int8Array( 0 ) ); - set6( new Int8Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set7 = resolveSetter( new Uint32Array( 0 ) ); - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set8 = resolveSetter( new Uint16Array( 0 ) ); - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set9 = resolveSetter( new Uint8Array( 0 ) ); - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set10 = resolveSetter( new Uint8ClampedArray( 0 ) ); - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set11 = resolveSetter( new Complex128Array( 0 ) ); - set11( new Complex128Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set11( new Complex128Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set11( new Complex128Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set11( new Complex128Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set11( new Complex128Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set12 = resolveSetter( new Complex64Array( 0 ) ); - set12( new Complex64Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set12( new Complex64Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set12( new Complex64Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set12( new Complex64Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set12( new Complex64Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set13 = resolveSetter( new AccessorArray( [ 1, 2, 3, 4 ] ) ); - set13( new AccessorArray( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set13( new AccessorArray( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set13( new AccessorArray( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set13( new AccessorArray( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set13( new AccessorArray( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided an unsupported number of arguments... -{ - const set1 = resolveSetter( [] ); - set1(); // $ExpectError - set1( [] ); // $ExpectError - set1( [], 1, 2, 10 ); // $ExpectError - - const set2 = resolveSetter( new Float64Array( 0 ) ); - set2(); // $ExpectError - set2( new Float64Array( [] ) ); // $ExpectError - set2( new Float64Array( [] ), 1, 2, 10 ); // $ExpectError - - const set3 = resolveSetter( new Float32Array( 0 ) ); - set3(); // $ExpectError - set3( new Float32Array( [] ) ); // $ExpectError - set3( new Float32Array( [] ), 1, 2, 10 ); // $ExpectError - - const set4 = resolveSetter( new Int32Array( 0 ) ); - set4(); // $ExpectError - set4( new Int32Array( [] ) ); // $ExpectError - set4( new Int32Array( [] ), 1, 2, 10 ); // $ExpectError - - const set5 = resolveSetter( new Int16Array( 0 ) ); - set5(); // $ExpectError - set5( new Int16Array( [] ) ); // $ExpectError - set5( new Int16Array( [] ), 1, 2, 10 ); // $ExpectError - - const set6 = resolveSetter( new Int8Array( 0 ) ); - set6(); // $ExpectError - set6( new Int8Array( [] ) ); // $ExpectError - set6( new Int8Array( [] ), 1, 2, 10 ); // $ExpectError - - const set7 = resolveSetter( new Uint32Array( 0 ) ); - set7(); // $ExpectError - set7( new Uint32Array( [] ) ); // $ExpectError - set7( new Uint32Array( [] ), 1, 2, 10 ); // $ExpectError - - const set8 = resolveSetter( new Uint16Array( 0 ) ); - set8(); // $ExpectError - set8( new Uint16Array( [] ) ); // $ExpectError - set8( new Uint16Array( [] ), 1, 2, 10 ); // $ExpectError - - const set9 = resolveSetter( new Uint8Array( 0 ) ); - set9(); // $ExpectError - set9( new Uint8Array( [] ) ); // $ExpectError - set9( new Uint8Array( [] ), 1, 2, 10 ); // $ExpectError - - const set10 = resolveSetter( new Uint8ClampedArray( 0 ) ); - set10(); // $ExpectError - set10( new Uint8ClampedArray( [] ) ); // $ExpectError - set10( new Uint8ClampedArray( [] ), 1, 2, 10 ); // $ExpectError - - const set11 = resolveSetter( new Complex128Array( 0 ) ); - set11(); // $ExpectError - set11( new Complex128Array( 0 ) ); // $ExpectError - set11( new Complex128Array( 0 ), 1, new Complex128( 0, 0 ), 10 ); // $ExpectError - - const set12 = resolveSetter( new Complex64Array( 0 ) ); - set12(); // $ExpectError - set12( new Complex64Array( 0 ) ); // $ExpectError - set12( new Complex64Array( 0 ), 1, new Complex64( 0, 0 ), 10 ); // $ExpectError - - const set13 = resolveSetter( new AccessorArray( [ 1, 2, 3, 4 ] ) ); - set13(); // $ExpectError - set13( new AccessorArray( [ 1, 2, 3, 4 ] ) ); // $ExpectError - set13( new AccessorArray( [ 1, 2, 3, 4 ] ), 1, 2, 10 ); // $ExpectError -} diff --git a/base/resolve-setter/examples/index.js b/base/resolve-setter/examples/index.js deleted file mode 100644 index efa558fbf..000000000 --- a/base/resolve-setter/examples/index.js +++ /dev/null @@ -1,58 +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. -*/ - -'use strict'; - -var filled = require( './../../../filled' ); -var resolveSetter = require( './../lib' ); - -var arr = filled( 1.0, 10, 'float64' ); -resolveSetter( arr )( arr, 2, 100.0 ); -console.log( arr ); - -arr = filled( 2.0, 10, 'float32' ); -resolveSetter( arr )( arr, 2, 100.0 ); -console.log( arr ); - -arr = filled( 3, 10, 'int32' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 4, 10, 'int16' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 5, 10, 'int8' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 6, 10, 'uint32' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 7, 10, 'uint16' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 8, 10, 'uint8' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 9, 10, 'uint8c' ); -resolveSetter( arr )( arr, 2, 100 ); -console.log( arr ); diff --git a/base/resolve-setter/lib/index.js b/base/resolve-setter/lib/index.js deleted file mode 100644 index 5d04d4121..000000000 --- a/base/resolve-setter/lib/index.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -/** -* Return an accessor function for setting an element in an array-like object. -* -* @module @stdlib/array/base/resolve-setter -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* var resolveSetter = require( '@stdlib/array/base/resolve-setter' ); -* -* var arr = [ 1, 2, 3, 4 ]; -* -* var set = resolveSetter( arr ); -* // returns -* -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* // returns -* -* var v = get( arr, 2 ); -* // returns 10 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/resolve-setter/lib/main.js b/base/resolve-setter/lib/main.js deleted file mode 100644 index 33978d0a7..000000000 --- a/base/resolve-setter/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var accessorSetter = require( './../../../base/accessor-setter' ); -var setter = require( './../../../base/setter' ); -var dtype = require( './../../../dtype' ); - - -// MAIN // - -/** -* Returns an accessor function for setting an element in an array-like object. -* -* @param {Collection} x - input array -* @returns {Function} accessor -* -* @example -* var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); -* -* var arr = [ 1, 2, 3, 4 ]; -* -* var set = resolveSetter( arr ); -* // returns -* -* set( arr, 2, 10 ); -* -* var get = resolveGetter( arr ); -* // returns -* -* var v = get( arr, 2 ); -* // returns 10 -*/ -function resolveSetter( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return accessorSetter( dt ); - } - return setter( dt ); -} - - -// EXPORTS // - -module.exports = resolveSetter; diff --git a/base/resolve-setter/package.json b/base/resolve-setter/package.json deleted file mode 100644 index b07982c93..000000000 --- a/base/resolve-setter/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "@stdlib/array/base/resolve-setter", - "version": "0.0.0", - "description": "Return an accessor function for setting an element in an array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "array", - "generic", - "set", - "accessor", - "access", - "setter" - ] -} diff --git a/base/resolve-setter/test/test.js b/base/resolve-setter/test/test.js deleted file mode 100644 index 429adf266..000000000 --- a/base/resolve-setter/test/test.js +++ /dev/null @@ -1,220 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var filled = require( './../../../filled' ); -var accessorArray = require( './../../../base/accessor' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var dtypes = require( './../../../dtypes' ); -var resolveGetter = require( './../../../base/resolve-getter' ); -var resolveSetter = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes( 'real_and_generic' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof resolveSetter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function for setting an array element (indexed)', function test( t ) { - var arr; - var get; - var set; - var dt; - var v; - var i; - - for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - arr = filled( i+1, 10, dt ); - - set = resolveSetter( arr ); - set( arr, 2, i+100 ); - - get = resolveGetter( arr ); - v = get( arr, 2 ); - - t.strictEqual( v, i+100, 'returns expected value for dtype: '+dt ); - } - t.end(); -}); - -tape( 'the function returns a function for setting an array element (accessor)', function test( t ) { - var arr; - var get; - var set; - var v; - - arr = new Complex128Array( 10 ); - - set = resolveSetter( arr ); - set( arr, 2, new Complex128( 4.0, 5.0 ) ); - - get = resolveGetter( arr ); - v = get( arr, 2 ); - - t.strictEqual( real( v ), 4.0, 'returns expected value' ); - t.strictEqual( imag( v ), 5.0, 'returns expected value' ); - - arr = new Complex64Array( 10 ); - - set = resolveSetter( arr ); - set( arr, 2, new Complex64( 4.0, 5.0 ) ); - - get = resolveGetter( arr ); - v = get( arr, 2 ); - - t.strictEqual( realf( v ), 4.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 5.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a function for setting an array element (indexed; unrecognized dtype)', function test( t ) { - var arr; - var get; - var set; - var v; - - arr = filled( 2, 10, 'generic' ); - - set = resolveSetter( 'beep boop' ); - set( arr, 2, 10 ); - - get = resolveGetter( arr ); - v = get( arr, 2 ); - - t.strictEqual( v, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a function for setting an array element (accessor; unrecognized dtype)', function test( t ) { - var arr; - var get; - var set; - var v; - - arr = accessorArray( [ 1, 2, 3, 4 ] ); - - set = resolveSetter( arr ); - set( arr, 2, 10 ); - - get = resolveGetter( arr ); - v = get( arr, 2 ); - - t.strictEqual( v, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (indexed)', function test( t ) { - var arr; - var get; - var set; - var v; - var i; - - arr = [ 1, 2, 3, 4 ]; - i = arr.length + 10; - - set = resolveSetter( arr ); - set( arr, i, 10 ); - - get = resolveGetter( arr ); - v = get( arr, i ); - - t.strictEqual( v, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (accessor)', function test( t ) { - var arr; - var get; - var set; - var v; - var i; - - arr = accessorArray( [ 1, 2, 3, 4 ] ); - i = arr.length + 10; - - set = resolveSetter( arr ); - set( arr, i, 10 ); - - get = resolveGetter( arr ); - v = get( arr, i ); - - t.strictEqual( v, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (indexed; unrecognized dtype)', function test( t ) { - var arr; - var get; - var set; - var v; - var i; - - arr = filled( 2, 10, 'generic' ); - i = arr.length + 10; - - set = resolveSetter( 'beep boop' ); - set( arr, i, 10 ); - - get = resolveGetter( arr ); - v = get( arr, i ); - - t.strictEqual( v, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (accessor; unrecognized dtype)', function test( t ) { - var arr; - var get; - var set; - var v; - var i; - - arr = accessorArray( [] ); - i = arr.length + 10; - - set = resolveSetter( arr ); - set( arr, i, 10 ); - - get = resolveGetter( arr ); - v = get( arr, i ); - - t.strictEqual( v, 10, 'returns expected value' ); - t.end(); -}); diff --git a/base/reverse/README.md b/base/reverse/README.md deleted file mode 100644 index 7cf2c6e6f..000000000 --- a/base/reverse/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# reverse - -> Reverse an array in-place. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var reverse = require( '@stdlib/array/base/reverse' ); -``` - -#### reverse( x ) - -Reverses an array in-place. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var out = reverse( x ); -// returns [ 6, 5, 4, 3, 2, 1 ] - -var bool = ( out === x ); -// returns true -``` - -
- - - - - -
- -## Notes - -- If provided an array-like object having a `reverse` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.reverse() - ``` - -- If provided an array-like object without a `reverse` method, the function manually reverses elements and mutates the input array. - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var reverse = require( '@stdlib/array/base/reverse' ); - -var x = new Float64Array( zeroTo( 6 ) ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -var y = reverse( x ); -// returns [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ] - -var z = reverse( y ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/reverse/benchmark/benchmark.length.js b/base/reverse/benchmark/benchmark.length.js deleted file mode 100644 index 176a0f7a2..000000000 --- a/base/reverse/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var reverse = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = reverse( x ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/reverse/docs/repl.txt b/base/reverse/docs/repl.txt deleted file mode 100644 index 4b680883c..000000000 --- a/base/reverse/docs/repl.txt +++ /dev/null @@ -1,31 +0,0 @@ - -{{alias}}( x ) - Reverses an array in-place. - - If provided an array-like object having a `reverse` method, the function - defers execution to that method and assumes that the method has the - following signature: - - x.reverse() - - If provided an array-like object without a `reverse` method, the function - manually reverses elements and mutates the input array in-place. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: ArrayLikeObject - Input array. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - [ 4, 3, 2, 1 ] - - See Also - -------- - diff --git a/base/reverse/docs/types/index.d.ts b/base/reverse/docs/types/index.d.ts deleted file mode 100644 index f4b688f6a..000000000 --- a/base/reverse/docs/types/index.d.ts +++ /dev/null @@ -1,253 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex128Array, Complex64Array, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = reverse( x ); -* // returns [ 3.0, 2.0, 1.0 ] -*/ -declare function reverse( x: Float64Array ): Float64Array; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = reverse( x ); -* // returns [ 3.0, 2.0, 1.0 ] -*/ -declare function reverse( x: Float32Array ): Float32Array; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3 ] ); -* -* var out = reverse( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function reverse( x: Int32Array ): Int32Array; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var x = new Int16Array( [ 1, 2, 3 ] ); -* -* var out = reverse( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function reverse( x: Int16Array ): Int16Array; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var x = new Int8Array( [ 1, 2, 3 ] ); -* -* var out = reverse( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function reverse( x: Int8Array ): Int8Array; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3 ] ); -* -* var out = reverse( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function reverse( x: Uint32Array ): Uint32Array; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3 ] ); -* -* var out = reverse( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function reverse( x: Uint16Array ): Uint16Array; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3 ] ); -* -* var out = reverse( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function reverse( x: Uint8Array ): Uint8Array; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3 ] ); -* -* var out = reverse( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function reverse( x: Uint8ClampedArray ): Uint8ClampedArray; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* var out = reverse( x ); -* // returns [ 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] -*/ -declare function reverse( x: Complex128Array ): Complex128Array; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* var out = reverse( x ); -* // returns [ 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] -*/ -declare function reverse( x: Complex64Array ): Complex64Array; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3 ] ); -* -* var v = x.get( 0 ); -* // returns 1 -* -* var out = reverse( x ); -* -* v = out.get( 0 ); -* // returns 3 -*/ -declare function reverse( x: AccessorArrayLike ): AccessorArrayLike; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = reverse( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function reverse( x: Array ): Array; - -/** -* Reverses an array in-place. -* -* @param x - input array -* @returns input array -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = reverse( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function reverse( x: Collection ): Collection; - - -// EXPORTS // - -export = reverse; diff --git a/base/reverse/docs/types/test.ts b/base/reverse/docs/types/test.ts deleted file mode 100644 index 36727d21a..000000000 --- a/base/reverse/docs/types/test.ts +++ /dev/null @@ -1,56 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import reverse = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - reverse( [ 1, 2, 3 ] ); // $ExpectType number[] - reverse( new Float64Array( [ 1, 2, 3 ] ) ); // $ExpectType Float64Array - reverse( new Float32Array( [ 1, 2, 3 ] ) ); // $ExpectType Float32Array - reverse( new Int32Array( [ 1, 2, 3 ] ) ); // $ExpectType Int32Array - reverse( new Int16Array( [ 1, 2, 3 ] ) ); // $ExpectType Int16Array - reverse( new Int8Array( [ 1, 2, 3 ] ) ); // $ExpectType Int8Array - reverse( new Uint32Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint32Array - reverse( new Uint16Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint16Array - reverse( new Uint8Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint8Array - reverse( new Uint8ClampedArray( [ 1, 2, 3 ] ) ); // $ExpectType Uint8ClampedArray - reverse( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ) ); // $ExpectType Complex128Array - reverse( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ) ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - reverse( 5 ); // $ExpectError - reverse( true ); // $ExpectError - reverse( false ); // $ExpectError - reverse( null ); // $ExpectError - reverse( void 0 ); // $ExpectError - reverse( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - reverse(); // $ExpectError - reverse( [ 1, 2, 3 ], {} ); // $ExpectError -} diff --git a/base/reverse/examples/index.js b/base/reverse/examples/index.js deleted file mode 100644 index cccb1e637..000000000 --- a/base/reverse/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var Float64Array = require( './../../../float64' ); -var zeroTo = require( './../../../base/zero-to' ); -var reverse = require( './../lib' ); - -var x = new Float64Array( zeroTo( 6 ) ); -console.log( x ); -// => [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -var y = reverse( x ); -console.log( y ); -// => [ 5.0, 4.0, 3.0, 2.0, 1.0, 0.0 ] - -var z = reverse( y ); -console.log( z ); -// => [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] diff --git a/base/reverse/lib/index.js b/base/reverse/lib/index.js deleted file mode 100644 index 0b26b8dae..000000000 --- a/base/reverse/lib/index.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -/** -* Reverse an array in-place. -* -* @module @stdlib/array/base/reverse -* -* @example -* var reverse = require( '@stdlib/array/base/reverse' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = reverse( x ); -* // returns [ 4, 3, 2, 1 ] -* -* var bool = ( out === x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/reverse/lib/main.js b/base/reverse/lib/main.js deleted file mode 100644 index 58ad60056..000000000 --- a/base/reverse/lib/main.js +++ /dev/null @@ -1,170 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); -var floor = require( '@stdlib/math/base/special/floor' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'reverse' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - -/** -* Reverses an array in-place. -* -* @private -* @param {Collection} x - input array -* @returns {Collection} input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = internal( x ); -* // returns [ 4, 3, 2, 1 ] -*/ -function internal( x ) { - var tmp; - var N; - var M; - var i; - var j; - - N = floor( x.length/2 ); - M = x.length - 1; - for ( i = 0; i < N; i++ ) { - j = M - i; - tmp = x[ i ]; - x[ i ] = x[ j ]; - x[ j ] = tmp; - } - return x; -} - -/** -* Reverses an array in-place. -* -* @private -* @param {Object} x - input array object -* @returns {Collection} input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var v = x.get( 0 ); -* // returns 1 -* -* var out = accessors( arraylike2object( x ) ); -* -* v = x.get( 0 ); -* // returns 4 -*/ -function accessors( x ) { - var data; - var get; - var set; - var tmp; - var N; - var M; - var i; - var j; - - data = x.data; - get = x.accessors[ 0 ]; - set = x.accessors[ 1 ]; - - N = floor( data.length/2 ); - M = data.length - 1; - for ( i = 0; i < N; i++ ) { - j = M - i; - tmp = get( data, i ); - set( data, i, get( data, j ) ); - set( data, j, tmp ); - } - return data; -} - - -// MAIN // - -/** -* Reverses an array in-place. -* -* @param {Collection} x - input array -* @returns {Collection} input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = reverse( x ); -* // returns [ 4, 3, 2, 1 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var out = reverse( x ); -* // returns [ 4, 3, 2, 1 ] -* -* var bool = ( out === x ); -* // returns true -*/ -function reverse( x ) { - var obj; - if ( hasMethod( x, 'reverse' ) ) { - return x.reverse(); - } - obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj ); - } - return internal( x ); -} - - -// EXPORTS // - -module.exports = reverse; diff --git a/base/reverse/package.json b/base/reverse/package.json deleted file mode 100644 index 90aec9866..000000000 --- a/base/reverse/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/reverse", - "version": "0.0.0", - "description": "Reverse an array in-place.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "reverse", - "rev", - "swap" - ] -} diff --git a/base/reverse/test/test.js b/base/reverse/test/test.js deleted file mode 100644 index 0bfee0aae..000000000 --- a/base/reverse/test/test.js +++ /dev/null @@ -1,298 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var reverse = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof reverse, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function reverses an array-like object (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - expected = [ 3, 2, 1 ]; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 2, 3 ]; - expected = [ 3, 2 ]; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 2 ]; - expected = [ 2 ]; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - expected = []; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function reverses an array-like object (float64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 3.0, 2.0, 1.0 ] ); - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 2.0, 3.0 ] ); - expected = new Float64Array( [ 3.0, 2.0 ] ); - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 2.0 ] ); - expected = new Float64Array( [ 2.0 ] ); - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - expected = new Float64Array( [] ); - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function reverses an array-like object (int32)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 3, 2, 1 ] ); - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2 ] ); - expected = new Int32Array( [ 2, 1 ] ); - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1 ] ); - expected = new Int32Array( [ 1 ] ); - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [] ); - expected = new Int32Array( [] ); - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function reverses an array-like object (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = new AccessorArray( [ 1, 2, 3, 4 ] ); - expected = [ 4, 3, 2, 1 ]; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - deepEqual( actual, expected ); - - x = new AccessorArray( [ 1, 2, 3 ] ); - expected = [ 3, 2, 1 ]; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - deepEqual( actual, expected ); - - x = new AccessorArray( [ 2, 3 ] ); - expected = [ 3, 2 ]; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - deepEqual( actual, expected ); - - x = new AccessorArray( [ 3 ] ); - expected = [ 3 ]; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - deepEqual( actual, expected ); - - x = new AccessorArray( [] ); - expected = []; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - deepEqual( actual, expected ); - - t.end(); - - function deepEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value for element ' + i ); - } - } -}); - -tape( 'the function reverses an array-like object (array-like)', function test( t ) { - var expected; - var actual; - var x; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = { - 'length': 4, - '0': 4, - '1': 3, - '2': 2, - '3': 1 - }; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - expected = { - 'length': 3, - '0': 3, - '1': 2, - '2': 1 - }; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 2, - '0': 1, - '1': 2 - }; - expected = { - 'length': 2, - '0': 2, - '1': 1 - }; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 1, - '0': 1 - }; - expected = { - 'length': 1, - '0': 1 - }; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 0 - }; - expected = { - 'length': 0 - }; - actual = reverse( x ); - - t.strictEqual( actual, x, 'returns same reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/scatter-filled/README.md b/base/scatter-filled/README.md deleted file mode 100644 index 4ad984b48..000000000 --- a/base/scatter-filled/README.md +++ /dev/null @@ -1,121 +0,0 @@ - - -# scatterFilled - -> Scatter a list of provided values to specified indices in a new filled "generic" array. - -
- -## Usage - -```javascript -var scatterFilled = require( '@stdlib/array/base/scatter-filled' ); -``` - -#### scatterFilled( fill, len, indices, values, mode ) - -Scatters a list of provided values to specified indices in a new filled "generic" array. - -```javascript -var out = scatterFilled( null, 4, [ 1, 3 ], [ 20, 40 ], 'throw' ); -// returns [ null, 20, null, 40 ] -``` - -The function supports the following parameters: - -- **fill**: fill value. -- **len**: output array length. -- **indices**: list of indices. -- **values**: values to scatter. When `indices` contains one or more elements, `values` must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes] with `indices` (i.e., must have either one element or the same number of elements as `indices`). -- **mode**: index [mode][@stdlib/ndarray/base/ind]. - -If `indices` is an empty array, the function returns a filled array. - -```javascript -var out = scatterFilled( null, 4, [], [ 20, 40 ], 'throw' ); -// returns [ null, null, null, null ] -``` - -The function supports broadcasting a `values` array containing a single element against an `indices` array containing one or more elements. - -```javascript -var out = scatterFilled( null, 4, [ 1, 3 ], [ 20 ], 'throw' ); -// returns [ null, 20, null, 20 ] -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var scatterFilled = require( '@stdlib/array/base/scatter-filled' ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, 10 ) ); -console.log( indices ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2025 ) ); -console.log( values ); - -// Scatter a random sample of elements to a new array: -var out = scatterFilled( null, 11, indices, values, 'throw' ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/scatter-filled/benchmark/benchmark.js b/base/scatter-filled/benchmark/benchmark.js deleted file mode 100644 index 661551c61..000000000 --- a/base/scatter-filled/benchmark/benchmark.js +++ /dev/null @@ -1,76 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var scatterFilled = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::no_broadcasting:len=100', function benchmark( b ) { - var idx; - var x; - var i; - var v; - - x = zeroTo( 100 ); - idx = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scatterFilled( -1, x.length, idx, x, 'throw' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::broadcasting:len=100', function benchmark( b ) { - var idx; - var i; - var v; - - idx = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scatterFilled( -1, 100, idx, [ i ], 'throw' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/scatter-filled/benchmark/benchmark.length.js b/base/scatter-filled/benchmark/benchmark.length.js deleted file mode 100644 index 688f4f671..000000000 --- a/base/scatter-filled/benchmark/benchmark.length.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../../../base/zero-to' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var scatterFilled = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'dtype': 'generic' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var idx; - - idx = zeroTo( len ); - values = [ - discreteUniform( len, -10, 0, opts ), - discreteUniform( len, 0, 10, opts ) - ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scatterFilled( -999, len, idx, values[ i%values.length ], 'throw' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/scatter-filled/docs/repl.txt b/base/scatter-filled/docs/repl.txt deleted file mode 100644 index fc95f32cc..000000000 --- a/base/scatter-filled/docs/repl.txt +++ /dev/null @@ -1,48 +0,0 @@ - -{{alias}}( fill, len, indices, values, mode ) - Scatters a list of provided values to specified indices in a new filled - "generic" array. - - The function supports broadcasting a `values` array containing a single - element against an `indices` array containing one or more elements. - - If `indices` is an empty array, the function returns a filled array. - - Parameters - ---------- - fill: any - Fill value. - - len: integer - Output array length. - - indices: ArrayLikeObject - List of element indices. - - values: ArrayLikeObject - Values to scatter. When `indices` contains one or more elements, - `values` must be broadcast compatible with `indices` (i.e., must have - either one element or the same number of elements as `indices`). - - mode: string - Specifies how to handle an index outside the interval [0, max], where - `max` is the maximum possible array index. If equal to 'throw', the - function throws an error. If equal to 'normalize', the function throws - an error if provided an out-of-bounds normalized index. If equal to - 'wrap', the function wraps around an index using modulo arithmetic. If - equal to 'clamp', the function sets an index to either 0 (minimum index) - or the maximum index. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( null, 4, [ 1, 3 ], [ 20, 40 ], 'throw' ) - [ null, 20, null, 40 ] - - See Also - -------- - diff --git a/base/scatter-filled/docs/types/index.d.ts b/base/scatter-filled/docs/types/index.d.ts deleted file mode 100644 index f6d9d77e9..000000000 --- a/base/scatter-filled/docs/types/index.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import { Mode } from '@stdlib/types/ndarray'; - -/** -* Index array. -*/ -type IndexArray = Collection | AccessorArrayLike; - -/** -* Values array. -*/ -type ValuesArray = Collection | AccessorArrayLike; - -/** -* Scatters a list of provided values to specified indices in a new filled "generic" array. -* -* @param fill - fill value -* @param len - output array length -* @param indices - list of element indices -* @param values - values to scatter -* @param mode - index mode -* @returns output array -* -* @example -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = scatterFilled( null, 4, indices, values, 'throw' ); -* // returns [ null, 20, 30, null ] -* -* @example -* var out = scatterFilled( null, 4, [ 1, 2 ], [ 30 ], 'throw' ); -* // returns [ null, 30, 30, null ] -*/ -declare function scatterFilled( fill: T, len: number, indices: IndexArray, values: ValuesArray, mode: Mode ): Array; - - -// EXPORTS // - -export = scatterFilled; diff --git a/base/scatter-filled/docs/types/test.ts b/base/scatter-filled/docs/types/test.ts deleted file mode 100644 index 7c418ebee..000000000 --- a/base/scatter-filled/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import AccessorArray = require( './../../../../base/accessor' ); -import scatterFilled = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const z = new Complex128( 3.0, 4.0 ); - - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectType (number | null)[] - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], 'clamp' ); // $ExpectType (number | null)[] - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], 'wrap' ); // $ExpectType (number | null)[] - scatterFilled( null, 4, [ 1, 3 ], [ true, true ], 'normalize' ); // $ExpectType (boolean | null)[] - - scatterFilled( null, 4, [ 1, 3 ], [ z, z ], 'throw' ); // $ExpectType (Complex128 | null)[] - scatterFilled( null, 4, [ 1, 3 ], [ z, z ], 'throw' ); // $ExpectType (Complex128 | null)[] - scatterFilled( null, 4, [ 1, 3 ], new AccessorArray( [ 20, 30 ] ), 'throw' ); // $ExpectType (number | null)[] -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - scatterFilled( null, '1', [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scatterFilled( null, true, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scatterFilled( null, false, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scatterFilled( null, null, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scatterFilled( null, void 0, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scatterFilled( null, [], [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scatterFilled( null, {}, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - scatterFilled( null, 4, 1, [ 20, 30 ], 'throw' ); // $ExpectError - scatterFilled( null, 4, true, [ 20, 30 ], 'throw' ); // $ExpectError - scatterFilled( null, 4, false, [ 20, 30 ], 'throw' ); // $ExpectError - scatterFilled( null, 4, null, [ 20, 30 ], 'throw' ); // $ExpectError - scatterFilled( null, 4, void 0, [ 20, 30 ], 'throw' ); // $ExpectError - scatterFilled( null, 4, {}, [ 20, 30 ], 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an array-like object... -{ - scatterFilled( null, 4, [ 1, 3 ], 1, 'throw' ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], true, 'throw' ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], false, 'throw' ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], null, 'throw' ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], void 0, 'throw' ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], {}, 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a valid index mode... -{ - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], '1' ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], 1 ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], true ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], false ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], null ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], void 0 ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], {} ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], [] ); // $ExpectError - scatterFilled( null, 4, [ 1, 3 ], [ 20, 30 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - scatterFilled(); // $ExpectError - scatterFilled( null ); // $ExpectError - scatterFilled( null, 4 ); // $ExpectError - scatterFilled( null, 4, [] ); // $ExpectError - scatterFilled( null, 4, [], [] ); // $ExpectError - scatterFilled( null, 4, [], [], 'throw', {} ); // $ExpectError -} diff --git a/base/scatter-filled/examples/index.js b/base/scatter-filled/examples/index.js deleted file mode 100644 index ead46b3b3..000000000 --- a/base/scatter-filled/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var scatterFilled = require( './../lib' ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, 10 ) ); -console.log( indices ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2025 ) ); -console.log( values ); - -// Scatter a random sample of elements to a new array: -var out = scatterFilled( null, 11, indices, values, 'throw' ); -console.log( out ); diff --git a/base/scatter-filled/lib/index.js b/base/scatter-filled/lib/index.js deleted file mode 100644 index dc54ffcef..000000000 --- a/base/scatter-filled/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Scatter a list of provided values to specified indices in a new filled "generic" array. -* -* @module @stdlib/array/base/scatter-filled -* -* @example -* var scatterFilled = require( '@stdlib/array/base/scatter-filled' ); -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = scatterFilled( null, 4, indices, values, 'throw' ); -* // returns [ null, 20, 30, null ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/scatter-filled/lib/main.js b/base/scatter-filled/lib/main.js deleted file mode 100644 index 96a9b1647..000000000 --- a/base/scatter-filled/lib/main.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); -var put = require( './../../../base/put' ); - - -// MAIN // - -/** -* Scatters a list of provided values to specified indices in a new filled "generic" array. -* -* @param {*} fill - fill value -* @param {NonNegativeInteger} len - output array length -* @param {IntegerArray} indices - list of indices -* @param {Collection} values - values to scatter -* @param {string} mode - index mode -* @throws {Error} third argument must be broadcast compatible with the second argument -* @returns {Array} output array -* -* @example -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = scatterFilled( null, 4, indices, values, 'throw' ); -* // returns [ null, 20, 30, null ] -* -* @example -* var indices = [ 1, 2 ]; -* var values = [ 30 ]; -* -* var out = scatterFilled( null, 4, indices, values, 'throw' ); -* // returns [ null, 30, 30, null ] -*/ -function scatterFilled( fill, len, indices, values, mode ) { - return put( filled( fill, len ), indices, values, mode ); -} - - -// EXPORTS // - -module.exports = scatterFilled; diff --git a/base/scatter-filled/package.json b/base/scatter-filled/package.json deleted file mode 100644 index 21fbd5e27..000000000 --- a/base/scatter-filled/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/scatter-filled", - "version": "0.0.0", - "description": "Scatter a list of provided values to specified indices in a new filled \"generic\" array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "set", - "scatter", - "filled", - "fill" - ] -} diff --git a/base/scatter-filled/test/test.js b/base/scatter-filled/test/test.js deleted file mode 100644 index 4de7827ed..000000000 --- a/base/scatter-filled/test/test.js +++ /dev/null @@ -1,203 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert/is-array' ); -var scatterFilled = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof scatterFilled, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a fourth argument which is not broadcast compatible with the second argument', function test( t ) { - var values; - var i; - - values = [ - [], - [ 1, 2, 3 ], - [ 1, 2, 3, 4 ], - [ 1, 2, 3, 4, 5 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided an array of length ' + values[ i ].length ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - scatterFilled( null, 4, [ 1, 2 ], value, 'throw' ); - }; - } -}); - -tape( 'the function scatters elements to a new array', function test( t ) { - var expected; - var indices; - var actual; - - indices = [ 1, 3 ]; - actual = scatterFilled( null, 4, indices, [ 20, 40 ], 'throw' ); - expected = [ null, 20, null, 40 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - actual = scatterFilled( null, 4, indices, [ 20, 30, 40, 50 ], 'throw' ); - expected = [ null, 30, null, 50 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - actual = scatterFilled( null, 4, indices, [ 20, 30, 40, 50 ], 'throw' ); - expected = [ 50, 40, 30, 20 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = scatterFilled( null, 4, indices, [ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ], 'throw' ); - expected = [ null, 100, null, null ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function scatters elements to a new array (broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - - indices = [ 1, 3 ]; - actual = scatterFilled( null, 4, indices, [ 20 ], 'throw' ); - expected = [ null, 20, null, 20 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - actual = scatterFilled( null, 4, indices, [ 20 ], 'throw' ); - expected = [ null, 20, null, 20 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - actual = scatterFilled( null, 4, indices, [ 20 ], 'throw' ); - expected = [ 20, 20, 20, 20 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = scatterFilled( null, 4, indices, [ 100 ], 'throw' ); - expected = [ null, 100, null, null ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array if provided a second argument which is empty', function test( t ) { - var actual; - - actual = scatterFilled( null, 4, [], [ 5, 6, 7, 8 ], 'throw' ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, [ null, null, null, null ], 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - - indices = [ 4, 5, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - scatterFilled( null, 4, indices, [ 200 ], 'throw' ); - } -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices', function test( t ) { - var expected; - var indices; - var actual; - - indices = [ -1, -2, -3, -4 ]; - actual = scatterFilled( null, 4, indices, [ 5, 6, 7, 8 ], 'normalize' ); - expected = [ 8, 7, 6, 5 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - - indices = [ 2, 50, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - scatterFilled( null, 4, indices, [ 100 ], 'normalize' ); - } -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - - indices = [ -10, 10, -5, 5 ]; - actual = scatterFilled( null, 4, indices, [ 100, 200, 300, 400 ], 'clamp' ); - expected = [ 300, null, null, 400 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - - indices = [ -10, 10, -5, 5 ]; - actual = scatterFilled( null, 4, indices, [ 100, 200, 300, 400 ], 'wrap' ); - expected = [ null, 400, 200, 300 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/scattered/README.md b/base/scattered/README.md deleted file mode 100644 index 66dbcdedf..000000000 --- a/base/scattered/README.md +++ /dev/null @@ -1,120 +0,0 @@ - - -# scattered - -> Scatter a list of provided values to specified indices in a new zero-filled "generic" array. - -
- -## Usage - -```javascript -var scattered = require( '@stdlib/array/base/scattered' ); -``` - -#### scattered( len, indices, values, mode ) - -Scatters a list of provided values to specified indices in a new zero-filled "generic" array. - -```javascript -var out = scattered( 4, [ 1, 3 ], [ 20, 40 ], 'throw' ); -// returns [ 0, 20, 0, 40 ] -``` - -The function supports the following parameters: - -- **len**: output array length. -- **indices**: list of indices. -- **values**: values to scatter. When `indices` contains one or more elements, `values` must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes] with `indices` (i.e., must have either one element or the same number of elements as `indices`). -- **mode**: index [mode][@stdlib/ndarray/base/ind]. - -If `indices` is an empty array, the function returns a zero-filled array. - -```javascript -var out = scattered( 4, [], [ 20, 40 ], 'throw' ); -// returns [ 0, 0, 0, 0 ] -``` - -The function supports broadcasting a `values` array containing a single element against an `indices` array containing one or more elements. - -```javascript -var out = scattered( 4, [ 1, 3 ], [ 20 ], 'throw' ); -// returns [ 0, 20, 0, 20 ] -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var scattered = require( '@stdlib/array/base/scattered' ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, 10 ) ); -console.log( indices ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2025 ) ); -console.log( values ); - -// Scatter a random sample of elements to a new array: -var out = scattered( 11, indices, values, 'throw' ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/scattered/benchmark/benchmark.js b/base/scattered/benchmark/benchmark.js deleted file mode 100644 index fb430f552..000000000 --- a/base/scattered/benchmark/benchmark.js +++ /dev/null @@ -1,76 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var scattered = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::no_broadcasting:len=100', function benchmark( b ) { - var idx; - var x; - var i; - var v; - - x = zeroTo( 100 ); - idx = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scattered( x.length, idx, x, 'throw' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::broadcasting:len=100', function benchmark( b ) { - var idx; - var i; - var v; - - idx = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scattered( 100, idx, [ i ], 'throw' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/scattered/benchmark/benchmark.length.js b/base/scattered/benchmark/benchmark.length.js deleted file mode 100644 index 0838f7c6f..000000000 --- a/base/scattered/benchmark/benchmark.length.js +++ /dev/null @@ -1,111 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../../../base/zero-to' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var scattered = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'dtype': 'generic' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var idx; - - idx = zeroTo( len ); - values = [ - discreteUniform( len, -10, 0, opts ), - discreteUniform( len, 0, 10, opts ) - ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scattered( len, idx, values[ i%values.length ], 'throw' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/scattered/docs/repl.txt b/base/scattered/docs/repl.txt deleted file mode 100644 index 06be220cf..000000000 --- a/base/scattered/docs/repl.txt +++ /dev/null @@ -1,45 +0,0 @@ - -{{alias}}( len, indices, values, mode ) - Scatters a list of provided values to specified indices in a new zero-filled - "generic" array. - - The function supports broadcasting a `values` array containing a single - element against an `indices` array containing one or more elements. - - If `indices` is an empty array, the function returns a zero-filled array. - - Parameters - ---------- - len: integer - Output array length. - - indices: ArrayLikeObject - List of element indices. - - values: ArrayLikeObject - Values to scatter. When `indices` contains one or more elements, - `values` must be broadcast compatible with `indices` (i.e., must have - either one element or the same number of elements as `indices`). - - mode: string - Specifies how to handle an index outside the interval [0, max], where - `max` is the maximum possible array index. If equal to 'throw', the - function throws an error. If equal to 'normalize', the function throws - an error if provided an out-of-bounds normalized index. If equal to - 'wrap', the function wraps around an index using modulo arithmetic. If - equal to 'clamp', the function sets an index to either 0 (minimum index) - or the maximum index. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( 4, [ 1, 3 ], [ 20, 40 ], 'throw' ) - [ 0, 20, 0, 40 ] - - See Also - -------- - diff --git a/base/scattered/docs/types/index.d.ts b/base/scattered/docs/types/index.d.ts deleted file mode 100644 index b52a2fe1e..000000000 --- a/base/scattered/docs/types/index.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import { Mode } from '@stdlib/types/ndarray'; - -/** -* Index array. -*/ -type IndexArray = Collection | AccessorArrayLike; - -/** -* Values array. -*/ -type ValuesArray = Collection | AccessorArrayLike; - -/** -* Scatters a list of provided values to specified indices in a new zero-filled "generic" array. -* -* @param len - output array length -* @param indices - list of element indices -* @param values - values to scatter -* @param mode - index mode -* @returns output array -* -* @example -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = scattered( 4, indices, values, 'throw' ); -* // returns [ 0, 20, 30, 0 ] -* -* @example -* var out = scattered( 4, [ 1, 2 ], [ 30 ], 'throw' ); -* // returns [ 0, 30, 30, 0 ] -*/ -declare function scattered( len: number, indices: IndexArray, values: ValuesArray, mode: Mode ): Array; - - -// EXPORTS // - -export = scattered; diff --git a/base/scattered/docs/types/test.ts b/base/scattered/docs/types/test.ts deleted file mode 100644 index bbbcefc3b..000000000 --- a/base/scattered/docs/types/test.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import AccessorArray = require( './../../../../base/accessor' ); -import scattered = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const z = new Complex128( 3.0, 4.0 ); - - scattered( 4, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectType number[] - scattered( 4, [ 1, 3 ], [ 20, 30 ], 'clamp' ); // $ExpectType number[] - scattered( 4, [ 1, 3 ], [ 20, 30 ], 'wrap' ); // $ExpectType number[] - scattered( 4, [ 1, 3 ], [ true, true ], 'normalize' ); // $ExpectType (number | boolean)[] - - scattered( 4, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectType number[] - scattered( 4, [ 1, 3 ], [ z, z ], 'throw' ); // $ExpectType (number | Complex128)[] - scattered( 4, [ 1, 3 ], [ z, z ], 'throw' ); // $ExpectType (number | Complex128)[] - scattered( 4, [ 1, 3 ], new AccessorArray( [ 20, 30 ] ), 'throw' ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not a number... -{ - scattered( '1', [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scattered( true, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scattered( false, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scattered( null, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scattered( void 0, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scattered( [], [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError - scattered( {}, [ 1, 3 ], [ 20, 30 ], 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - scattered( 4, 1, [ 20, 30 ], 'throw' ); // $ExpectError - scattered( 4, true, [ 20, 30 ], 'throw' ); // $ExpectError - scattered( 4, false, [ 20, 30 ], 'throw' ); // $ExpectError - scattered( 4, null, [ 20, 30 ], 'throw' ); // $ExpectError - scattered( 4, void 0, [ 20, 30 ], 'throw' ); // $ExpectError - scattered( 4, {}, [ 20, 30 ], 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object... -{ - scattered( 4, [ 1, 3 ], 1, 'throw' ); // $ExpectError - scattered( 4, [ 1, 3 ], true, 'throw' ); // $ExpectError - scattered( 4, [ 1, 3 ], false, 'throw' ); // $ExpectError - scattered( 4, [ 1, 3 ], null, 'throw' ); // $ExpectError - scattered( 4, [ 1, 3 ], void 0, 'throw' ); // $ExpectError - scattered( 4, [ 1, 3 ], {}, 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a valid index mode... -{ - scattered( 4, [ 1, 3 ], [ 20, 30 ], '1' ); // $ExpectError - scattered( 4, [ 1, 3 ], [ 20, 30 ], 1 ); // $ExpectError - scattered( 4, [ 1, 3 ], [ 20, 30 ], true ); // $ExpectError - scattered( 4, [ 1, 3 ], [ 20, 30 ], false ); // $ExpectError - scattered( 4, [ 1, 3 ], [ 20, 30 ], null ); // $ExpectError - scattered( 4, [ 1, 3 ], [ 20, 30 ], void 0 ); // $ExpectError - scattered( 4, [ 1, 3 ], [ 20, 30 ], {} ); // $ExpectError - scattered( 4, [ 1, 3 ], [ 20, 30 ], [] ); // $ExpectError - scattered( 4, [ 1, 3 ], [ 20, 30 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - scattered(); // $ExpectError - scattered( 4 ); // $ExpectError - scattered( 4, [] ); // $ExpectError - scattered( 4, [], [] ); // $ExpectError - scattered( 4, [], [], 'throw', {} ); // $ExpectError -} diff --git a/base/scattered/examples/index.js b/base/scattered/examples/index.js deleted file mode 100644 index 9f78b868d..000000000 --- a/base/scattered/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var scattered = require( './../lib' ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, 10 ) ); -console.log( indices ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2025 ) ); -console.log( values ); - -// Scatter a random sample of elements to a new array: -var out = scattered( 11, indices, values, 'throw' ); -console.log( out ); diff --git a/base/scattered/lib/index.js b/base/scattered/lib/index.js deleted file mode 100644 index b65788472..000000000 --- a/base/scattered/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Scatter a list of provided values to specified indices in a new zero-filled "generic" array. -* -* @module @stdlib/array/base/scattered -* -* @example -* var scattered = require( '@stdlib/array/base/scattered' ); -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = scattered( 4, indices, values, 'throw' ); -* // returns [ 0, 20, 30, 0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/scattered/lib/main.js b/base/scattered/lib/main.js deleted file mode 100644 index c8b37796d..000000000 --- a/base/scattered/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var zeros = require( './../../../base/zeros' ); -var put = require( './../../../base/put' ); - - -// MAIN // - -/** -* Scatters a list of provided values to specified indices in a new zero-filled "generic" array. -* -* @param {NonNegativeInteger} len - output array length -* @param {IntegerArray} indices - list of indices -* @param {Collection} values - values to scatter -* @param {string} mode - index mode -* @throws {Error} third argument must be broadcast compatible with the second argument -* @returns {Array} output array -* -* @example -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = scattered( 4, indices, values, 'throw' ); -* // returns [ 0, 20, 30, 0 ] -* -* @example -* var indices = [ 1, 2 ]; -* var values = [ 30 ]; -* -* var out = scattered( 4, indices, values, 'throw' ); -* // returns [ 0, 30, 30, 0 ] -*/ -function scattered( len, indices, values, mode ) { - return put( zeros( len ), indices, values, mode ); -} - - -// EXPORTS // - -module.exports = scattered; diff --git a/base/scattered/package.json b/base/scattered/package.json deleted file mode 100644 index 098221dca..000000000 --- a/base/scattered/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/scattered", - "version": "0.0.0", - "description": "Scatter a list of provided values to specified indices in a new zero-filled \"generic\" array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "set", - "scatter", - "filled", - "fill" - ] -} diff --git a/base/scattered/test/test.js b/base/scattered/test/test.js deleted file mode 100644 index b9a27d3b3..000000000 --- a/base/scattered/test/test.js +++ /dev/null @@ -1,203 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert/is-array' ); -var scattered = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof scattered, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a third argument which is not broadcast compatible with the second argument', function test( t ) { - var values; - var i; - - values = [ - [], - [ 1, 2, 3 ], - [ 1, 2, 3, 4 ], - [ 1, 2, 3, 4, 5 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided an array of length ' + values[ i ].length ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - scattered( 4, [ 1, 2 ], value, 'throw' ); - }; - } -}); - -tape( 'the function scatters elements to a new array', function test( t ) { - var expected; - var indices; - var actual; - - indices = [ 1, 3 ]; - actual = scattered( 4, indices, [ 20, 40 ], 'throw' ); - expected = [ 0, 20, 0, 40 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - actual = scattered( 4, indices, [ 20, 30, 40, 50 ], 'throw' ); - expected = [ 0, 30, 0, 50 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - actual = scattered( 4, indices, [ 20, 30, 40, 50 ], 'throw' ); - expected = [ 50, 40, 30, 20 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = scattered( 4, indices, [ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ], 'throw' ); - expected = [ 0, 100, 0, 0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function scatters elements to a new array (broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - - indices = [ 1, 3 ]; - actual = scattered( 4, indices, [ 20 ], 'throw' ); - expected = [ 0, 20, 0, 20 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - actual = scattered( 4, indices, [ 20 ], 'throw' ); - expected = [ 0, 20, 0, 20 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - actual = scattered( 4, indices, [ 20 ], 'throw' ); - expected = [ 20, 20, 20, 20 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = scattered( 4, indices, [ 100 ], 'throw' ); - expected = [ 0, 100, 0, 0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array if provided a second argument which is empty', function test( t ) { - var actual; - - actual = scattered( 4, [], [ 5, 6, 7, 8 ], 'throw' ); - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, [ 0, 0, 0, 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - - indices = [ 4, 5, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - scattered( 4, indices, [ 200 ], 'throw' ); - } -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices', function test( t ) { - var expected; - var indices; - var actual; - - indices = [ -1, -2, -3, -4 ]; - actual = scattered( 4, indices, [ 5, 6, 7, 8 ], 'normalize' ); - expected = [ 8, 7, 6, 5 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - - indices = [ 2, 50, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - scattered( 4, indices, [ 100 ], 'normalize' ); - } -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - - indices = [ -10, 10, -5, 5 ]; - actual = scattered( 4, indices, [ 100, 200, 300, 400 ], 'clamp' ); - expected = [ 300, 0, 0, 400 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - - indices = [ -10, 10, -5, 5 ]; - actual = scattered( 4, indices, [ 100, 200, 300, 400 ], 'wrap' ); - expected = [ 0, 400, 200, 300 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/setter/README.md b/base/setter/README.md deleted file mode 100644 index 1f6462586..000000000 --- a/base/setter/README.md +++ /dev/null @@ -1,161 +0,0 @@ - - -# setter - -> Return an accessor function for setting an element in an indexed array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var setter = require( '@stdlib/array/base/setter' ); -``` - -#### setter( dtype ) - -Returns an accessor function for setting an element in an indexed array-like object. - -```javascript -var arr = [ 1, 2, 3, 4 ]; - -var set = setter( 'generic' ); -set( arr, 2, 10 ); - -var v = arr[ 2 ]; -// returns 10 -``` - -The returned accessor function accepts the following arguments: - -- **arr**: input array. -- **idx**: element index. -- **value**: value to set. - -
- - - - - -
- -## Notes - -- If provided an unsupported [`dtype`][@stdlib/array/dtypes], the function returns a default accessor function for accessing elements in any indexed array-like object; otherwise, the function returns an accessor function which should **only** be provided an array instance corresponding to `dtype` (e.g., if `dtype` is `'float64'`, the returned accessor function should only be provided instances of `Float64Array`). -- Accessor functions do **not** verify that provided input arrays are array instances corresponding to `dtype`, as doing so would introduce performance overhead. If array instances corresponding to other data types are provided to an accessor function, JavaScript runtimes will consider the function polymorphic, potentially triggering de-optimization. In order to ensure maximum performance, **always** ensure that an accessor function is monomorphic. -- Accessor functions do **not** perform bounds checking. -- Accessor functions do **not** validate input values. -- An _indexed_ array-like object is a data structure in which one accesses elements via integer indices using bracket `[]` notation (e.g., `Float64Array`, `Int32Array`, `Array`, etc). This is in contrast to an _accessor_ array-like object in which one accesses elements using `get` and `set` methods (e.g., `Complex64Array` and `Complex128Array`). - -
- - - - - -
- -## Examples - - - -```javascript -var filled = require( '@stdlib/array/filled' ); -var dtype = require( '@stdlib/array/dtype' ); -var setter = require( '@stdlib/array/base/setter' ); - -var arr = filled( 1.0, 10, 'float64' ); -setter( dtype( arr ) )( arr, 2, 100.0 ); -console.log( arr ); - -arr = filled( 2.0, 10, 'float32' ); -setter( dtype( arr ) )( arr, 2, 100.0 ); -console.log( arr ); - -arr = filled( 3, 10, 'int32' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 4, 10, 'int16' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 5, 10, 'int8' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 6, 10, 'uint32' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 7, 10, 'uint16' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 8, 10, 'uint8' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 9, 10, 'uint8c' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/setter/benchmark/benchmark.js b/base/setter/benchmark/benchmark.js deleted file mode 100644 index a39ca5d15..000000000 --- a/base/setter/benchmark/benchmark.js +++ /dev/null @@ -1,331 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isFunction = require( '@stdlib/assert/is-function' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var filledBy = require( './../../../filled-by' ); -var dtype = require( './../../../dtype' ); -var dtypes = require( './../../../dtypes' ); -var pkg = require( './../package.json' ).name; -var setter = require( './../lib' ); - - -// VARIABLES // - -var rand = discreteUniform( 0, 127 ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var set; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - set = setter( dt[ i%dt.length ] ); - if ( typeof set !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( set ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'generic', rand ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'float64', rand ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'float32', rand ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'int32', rand ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'int16', rand ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'int8', rand ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'uint32', rand ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'uint16', rand ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'uint8', rand ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var set; - var i; - var j; - var v; - - arr = filledBy( 100, 'uint8c', rand ); - set = setter( dtype( arr ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % arr.length; - set( arr, j, i%128 ); - v = arr[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/setter/docs/repl.txt b/base/setter/docs/repl.txt deleted file mode 100644 index e41d7c700..000000000 --- a/base/setter/docs/repl.txt +++ /dev/null @@ -1,52 +0,0 @@ - -{{alias}}( dtype ) - Returns an accessor function for setting an element in an indexed array-like - object. - - An accessor function accepts the following arguments: - - - arr: input array. - - idx: element index. - - value: value to set. - - If provided an unsupported `dtype`, the function returns a default accessor - function for accessing elements in any indexed array-like object. - - Otherwise, the function returns an accessor function which should *only* be - provided an array instance corresponding to `dtype` (e.g., if `dtype` is - 'float64', the returned accessor function should only be provided instances - of Float64Array). - - Accessor functions do *not* verify that provided input arrays are array - instances corresponding to `dtype`, as doing so would introduce performance - overhead. If array instances corresponding to other data types are provided - to an accessor function, JavaScript runtimes will consider the function - polymorphic, potentially triggering de-optimization. In order to ensure - maximum performance, *always* ensure that an accessor function is - monomorphic. - - Accessor functions do *not* perform bounds checking. - - Accessor functions do *not* validate input values. - - Parameters - ---------- - dtype: string - Array data type. - - Returns - ------- - f: Function - Accessor function. - - Examples - -------- - > var f = {{alias}}( 'generic' ); - > var x = [ 1, 2, 3, 4 ]; - > f( x, 2, 10 ); - > x - [ 1, 2, 10, 4 ] - - See Also - -------- - diff --git a/base/setter/docs/types/index.d.ts b/base/setter/docs/types/index.d.ts deleted file mode 100644 index b151d5183..000000000 --- a/base/setter/docs/types/index.d.ts +++ /dev/null @@ -1,334 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/array'; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Returns an accessor function for setting an element in a `Float64Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var arr = new Float64Array( 4 ); -* -* var get = setter( 'float64' ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3.0 -*/ -declare function setter( dtype: 'float64' ): SetFloat64; - -/** -* Returns an accessor function for setting an element in a `Float32Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var arr = new Float32Array( 4 ); -* -* var set = setter( 'float32' ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3.0 -*/ -declare function setter( dtype: 'float32' ): SetFloat32; - -/** -* Returns an accessor function for setting an element in an `Int32Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var arr = new Int32Array( 4 ); -* -* var set = setter( 'int32' ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -declare function setter( dtype: 'int32' ): SetInt32; - -/** -* Returns an accessor function for setting an element in an `Int16Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var arr = new Int16Array( 4 ); -* -* var set = setter( 'int16' ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -declare function setter( dtype: 'int16' ): SetInt16; - -/** -* Returns an accessor function for setting an element in an `Int8Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var arr = new Int8Array( 4 ); -* -* var set = setter( 'int8' ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -declare function setter( dtype: 'int8' ): SetInt8; - -/** -* Returns an accessor function for setting an element in a `Uint32Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var arr = new Uint32Array( 4 ); -* -* var set = setter( 'uint32' ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -declare function setter( dtype: 'uint32' ): SetUint32; - -/** -* Returns an accessor function for setting an element in a `Uint16Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var arr = new Uint16Array( 4 ); -* -* var set = setter( 'uint16' ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -declare function setter( dtype: 'uint16' ): SetUint16; - -/** -* Returns an accessor function for setting an element in a `Uint8Array`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var arr = new Uint8Array( 4 ); -* -* var set = setter( 'uint8' ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -declare function setter( dtype: 'uint8' ): SetUint8; - -/** -* Returns an accessor function for setting an element in a `Uint8ClampedArray`. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var arr = new Uint8ClampedArray( 4 ); -* -* var set = setter( 'uint8c' ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -declare function setter( dtype: 'uint8c' ): SetUint8c; - -/** -* Returns an accessor function for setting an element in a "generic" array. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var arr = [ 0, 0, 0, 0 ]; -* -* var set = setter( 'generic' ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -declare function setter( dtype: 'generic' ): SetGeneric; - -/** -* Returns an accessor function for setting an element in an indexed array-like object. -* -* @param dtype - data type -* @returns accessor function -* -* @example -* var dtype = require( '@stdlib/array/dtype' ); -* -* var arr = [ 0, 0, 0, 0 ]; -* -* var set = setter( dtype( arr ) ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -declare function setter( dtype: string ): SetArrayLike; - - -// EXPORTS // - -export = setter; diff --git a/base/setter/docs/types/test.ts b/base/setter/docs/types/test.ts deleted file mode 100644 index 56fb4f82f..000000000 --- a/base/setter/docs/types/test.ts +++ /dev/null @@ -1,396 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 setter = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - setter( 'float64' ); // $ExpectType SetFloat64 - setter( 'float32' ); // $ExpectType SetFloat32 - setter( 'int32' ); // $ExpectType SetInt32 - setter( 'int16' ); // $ExpectType SetInt16 - setter( 'int8' ); // $ExpectType SetInt8 - setter( 'uint32' ); // $ExpectType SetUint32 - setter( 'uint16' ); // $ExpectType SetUint16 - setter( 'uint8' ); // $ExpectType SetUint8 - setter( 'uint8c' ); // $ExpectType SetUint8c - setter( 'generic' ); // $ExpectType SetGeneric - setter( 'foo' ); // $ExpectType SetArrayLike -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - setter( 5 ); // $ExpectError - setter( true ); // $ExpectError - setter( false ); // $ExpectError - setter( null ); // $ExpectError - setter( {} ); // $ExpectError - setter( [] ); // $ExpectError - setter( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - setter(); // $ExpectError - setter( 'float64', {} ); // $ExpectError -} - -// The function returns a function which sets an array element... -{ - const set1 = setter( 'generic' ); - const x1 = [ 1, 2, 3, 4 ]; - set1( x1, 2, 3 ); // $ExpectType void - - const set2 = setter( 'float64' ); - const x2 = new Float64Array( [ 1, 2, 3, 4 ] ); - set2( x2, 2, 3 ); // $ExpectType void - - const set3 = setter( 'float32' ); - const x3 = new Float32Array( [ 1, 2, 3, 4 ] ); - set3( x3, 2, 3 ); // $ExpectType void - - const set4 = setter( 'int32' ); - const x4 = new Int32Array( [ 1, 2, 3, 4 ] ); - set4( x4, 2, 3 ); // $ExpectType void - - const set5 = setter( 'int16' ); - const x5 = new Int16Array( [ 1, 2, 3, 4 ] ); - set5( x5, 2, 3 ); // $ExpectType void - - const set6 = setter( 'int8' ); - const x6 = new Int8Array( [ 1, 2, 3, 4 ] ); - set6( x6, 2, 3 ); // $ExpectType void - - const set7 = setter( 'uint32' ); - const x7 = new Uint32Array( [ 1, 2, 3, 4 ] ); - set7( x7, 2, 3 ); // $ExpectType void - - const set8 = setter( 'uint16' ); - const x8 = new Uint16Array( [ 1, 2, 3, 4 ] ); - set8( x8, 2, 3 ); // $ExpectType void - - const set9 = setter( 'uint8' ); - const x9 = new Uint8Array( [ 1, 2, 3, 4 ] ); - set9( x9, 2, 3 ); // $ExpectType void - - const set10 = setter( 'uint8c' ); - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); - set10( x10, 2, 3 ); // $ExpectType void - - const set11 = setter( 'foo' ); - const x11 = [ 1, 2, 3, 4 ]; - set11( x11, 2, 3 ); // $ExpectType void -} - -// The compiler throws an error if the returned function is provided a first argument which is not a collection... -{ - const set1 = setter( 'generic' ); - set1( 5, 2, 3 ); // $ExpectError - set1( true, 2, 3 ); // $ExpectError - set1( false, 2, 3 ); // $ExpectError - set1( null, 2, 3 ); // $ExpectError - set1( {}, 2, 3 ); // $ExpectError - - const set2 = setter( 'float64' ); - set2( 5, 2, 3 ); // $ExpectError - set2( true, 2, 3 ); // $ExpectError - set2( false, 2, 3 ); // $ExpectError - set2( null, 2, 3 ); // $ExpectError - set2( {}, 2, 3 ); // $ExpectError - - const set3 = setter( 'float32' ); - set3( 5, 2, 3 ); // $ExpectError - set3( true, 2, 3 ); // $ExpectError - set3( false, 2, 3 ); // $ExpectError - set3( null, 2, 3 ); // $ExpectError - set3( {}, 2, 3 ); // $ExpectError - - const set4 = setter( 'int32' ); - set4( 5, 2, 3 ); // $ExpectError - set4( true, 2, 3 ); // $ExpectError - set4( false, 2, 3 ); // $ExpectError - set4( null, 2, 3 ); // $ExpectError - set4( {}, 2, 3 ); // $ExpectError - - const set5 = setter( 'int16' ); - set5( 5, 2, 3 ); // $ExpectError - set5( true, 2, 3 ); // $ExpectError - set5( false, 2, 3 ); // $ExpectError - set5( null, 2, 3 ); // $ExpectError - set5( {}, 2, 3 ); // $ExpectError - - const set6 = setter( 'int8' ); - set6( 5, 2, 3 ); // $ExpectError - set6( true, 2, 3 ); // $ExpectError - set6( false, 2, 3 ); // $ExpectError - set6( null, 2, 3 ); // $ExpectError - set6( {}, 2, 3 ); // $ExpectError - - const set7 = setter( 'uint32' ); - set7( 5, 2, 3 ); // $ExpectError - set7( true, 2, 3 ); // $ExpectError - set7( false, 2, 3 ); // $ExpectError - set7( null, 2, 3 ); // $ExpectError - set7( {}, 2, 3 ); // $ExpectError - - const set8 = setter( 'uint16' ); - set8( 5, 2, 3 ); // $ExpectError - set8( true, 2, 3 ); // $ExpectError - set8( false, 2, 3 ); // $ExpectError - set8( null, 2, 3 ); // $ExpectError - set8( {}, 2, 3 ); // $ExpectError - - const set9 = setter( 'uint8' ); - set9( 5, 2, 3 ); // $ExpectError - set9( true, 2, 3 ); // $ExpectError - set9( false, 2, 3 ); // $ExpectError - set9( null, 2, 3 ); // $ExpectError - set9( {}, 2, 3 ); // $ExpectError - - const set10 = setter( 'uint8c' ); - set10( 5, 2, 3 ); // $ExpectError - set10( true, 2, 3 ); // $ExpectError - set10( false, 2, 3 ); // $ExpectError - set10( null, 2, 3 ); // $ExpectError - set10( {}, 2, 3 ); // $ExpectError - - const set11 = setter( 'foo' ); - set11( 5, 2, 3 ); // $ExpectError - set11( true, 2, 3 ); // $ExpectError - set11( false, 2, 3 ); // $ExpectError - set11( null, 2, 3 ); // $ExpectError - set11( {}, 2, 3 ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided a second argument which is not a number... -{ - const set1 = setter( 'generic' ); - set1( [ 1, 2, 3, 4 ], '5', 3 ); // $ExpectError - set1( [ 1, 2, 3, 4 ], true, 3 ); // $ExpectError - set1( [ 1, 2, 3, 4 ], false, 3 ); // $ExpectError - set1( [ 1, 2, 3, 4 ], null, 3 ); // $ExpectError - set1( [ 1, 2, 3, 4 ], {}, 3 ); // $ExpectError - - const set2 = setter( 'float64' ); - set2( new Float64Array( [ 1, 2, 3, 4 ] ), '5', 3 ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), true, 3 ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), false, 3 ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), null, 3 ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), {}, 3 ); // $ExpectError - - const set3 = setter( 'float32' ); - set3( new Float32Array( [ 1, 2, 3, 4 ] ), '5', 3 ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), true, 3 ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), false, 3 ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), null, 3 ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), {}, 3 ); // $ExpectError - - const set4 = setter( 'int32' ); - set4( new Int32Array( [ 1, 2, 3, 4 ] ), '5', 3 ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), true, 3 ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), false, 3 ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), null, 3 ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), {}, 3 ); // $ExpectError - - const set5 = setter( 'int16' ); - set5( new Int16Array( [ 1, 2, 3, 4 ] ), '5', 3 ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), true, 3 ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), false, 3 ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), null, 3 ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), {}, 3 ); // $ExpectError - - const set6 = setter( 'int8' ); - set6( new Int8Array( [ 1, 2, 3, 4 ] ), '5', 3 ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), true, 3 ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), false, 3 ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), null, 3 ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), {}, 3 ); // $ExpectError - - const set7 = setter( 'uint32' ); - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), '5', 3 ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), true, 3 ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), false, 3 ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), null, 3 ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), {}, 3 ); // $ExpectError - - const set8 = setter( 'uint16' ); - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), '5', 3 ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), true, 3 ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), false, 3 ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), null, 3 ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), {}, 3 ); // $ExpectError - - const set9 = setter( 'uint8' ); - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), '5', 3 ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), true, 3 ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), false, 3 ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), null, 3 ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), {}, 3 ); // $ExpectError - - const set10 = setter( 'uint8c' ); - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), '5', 3 ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), true, 3 ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), false, 3 ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), null, 3 ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), {}, 3 ); // $ExpectError - - const set11 = setter( 'foo' ); - set11( [ 1, 2, 3, 4 ], '5', 3 ); // $ExpectError - set11( [ 1, 2, 3, 4 ], true, 3 ); // $ExpectError - set11( [ 1, 2, 3, 4 ], false, 3 ); // $ExpectError - set11( [ 1, 2, 3, 4 ], null, 3 ); // $ExpectError - set11( [ 1, 2, 3, 4 ], {}, 3 ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided a third argument which is not a valid value... -{ - const set2 = setter( 'float64' ); - set2( new Float64Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set2( new Float64Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set3 = setter( 'float32' ); - set3( new Float32Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set3( new Float32Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set4 = setter( 'int32' ); - set4( new Int32Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set4( new Int32Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set5 = setter( 'int16' ); - set5( new Int16Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set5( new Int16Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set6 = setter( 'int8' ); - set6( new Int8Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set6( new Int8Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set7 = setter( 'uint32' ); - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set7( new Uint32Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set8 = setter( 'uint16' ); - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set8( new Uint16Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set9 = setter( 'uint8' ); - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set9( new Uint8Array( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError - - const set10 = setter( 'uint8c' ); - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), 2, '5' ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), 2, true ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), 2, false ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), 2, null ); // $ExpectError - set10( new Uint8ClampedArray( [ 1, 2, 3, 4 ] ), 2, {} ); // $ExpectError -} - -// The compiler throws an error if the returned function is provided an unsupported number of arguments... -{ - const set1 = setter( 'generic' ); - set1(); // $ExpectError - set1( [] ); // $ExpectError - set1( [], 1 ); // $ExpectError - set1( [], 1, 2, 2 ); // $ExpectError - - const set2 = setter( 'float64' ); - set2(); // $ExpectError - set2( new Float64Array( [] ) ); // $ExpectError - set2( new Float64Array( [] ), 1 ); // $ExpectError - set2( new Float64Array( [] ), 1, 2, 2 ); // $ExpectError - - const set3 = setter( 'float32' ); - set3(); // $ExpectError - set3( new Float32Array( [] ) ); // $ExpectError - set3( new Float32Array( [] ), 1 ); // $ExpectError - set3( new Float32Array( [] ), 1, 2, 2 ); // $ExpectError - - const set4 = setter( 'int32' ); - set4(); // $ExpectError - set4( new Int32Array( [] ) ); // $ExpectError - set4( new Int32Array( [] ), 1 ); // $ExpectError - set4( new Int32Array( [] ), 1, 2, 2 ); // $ExpectError - - const set5 = setter( 'int16' ); - set5(); // $ExpectError - set5( new Int16Array( [] ) ); // $ExpectError - set5( new Int16Array( [] ), 1 ); // $ExpectError - set5( new Int16Array( [] ), 1, 2, 2 ); // $ExpectError - - const set6 = setter( 'int8' ); - set6(); // $ExpectError - set6( new Int8Array( [] ) ); // $ExpectError - set6( new Int8Array( [] ), 1 ); // $ExpectError - set6( new Int8Array( [] ), 1, 2, 2 ); // $ExpectError - - const set7 = setter( 'uint32' ); - set7(); // $ExpectError - set7( new Uint32Array( [] ) ); // $ExpectError - set7( new Uint32Array( [] ), 1 ); // $ExpectError - set7( new Uint32Array( [] ), 1, 2, 2 ); // $ExpectError - - const set8 = setter( 'uint16' ); - set8(); // $ExpectError - set8( new Uint16Array( [] ) ); // $ExpectError - set8( new Uint16Array( [] ), 1 ); // $ExpectError - set8( new Uint16Array( [] ), 1, 2, 2 ); // $ExpectError - - const set9 = setter( 'uint8' ); - set9(); // $ExpectError - set9( new Uint8Array( [] ) ); // $ExpectError - set9( new Uint8Array( [] ), 1 ); // $ExpectError - set9( new Uint8Array( [] ), 1, 2, 2 ); // $ExpectError - - const set10 = setter( 'uint8c' ); - set10(); // $ExpectError - set10( new Uint8ClampedArray( [] ) ); // $ExpectError - set10( new Uint8ClampedArray( [] ), 1 ); // $ExpectError - set10( new Uint8ClampedArray( [] ), 1, 2, 2 ); // $ExpectError - - const set11 = setter( 'foo' ); - set11(); // $ExpectError - set11( [] ); // $ExpectError - set11( [], 1 ); // $ExpectError - set11( [], 1, 2, 2 ); // $ExpectError -} diff --git a/base/setter/examples/index.js b/base/setter/examples/index.js deleted file mode 100644 index bb3352baf..000000000 --- a/base/setter/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 filled = require( './../../../filled' ); -var dtype = require( './../../../dtype' ); -var setter = require( './../lib' ); - -var arr = filled( 1.0, 10, 'float64' ); -setter( dtype( arr ) )( arr, 2, 100.0 ); -console.log( arr ); - -arr = filled( 2.0, 10, 'float32' ); -setter( dtype( arr ) )( arr, 2, 100.0 ); -console.log( arr ); - -arr = filled( 3, 10, 'int32' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 4, 10, 'int16' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 5, 10, 'int8' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 6, 10, 'uint32' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 7, 10, 'uint16' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 8, 10, 'uint8' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); - -arr = filled( 9, 10, 'uint8c' ); -setter( dtype( arr ) )( arr, 2, 100 ); -console.log( arr ); diff --git a/base/setter/lib/index.js b/base/setter/lib/index.js deleted file mode 100644 index 4dad9b391..000000000 --- a/base/setter/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an accessor function for setting an element in an indexed array-like object. -* -* @module @stdlib/array/base/setter -* -* @example -* var dtype = require( '@stdlib/array/dtype' ); -* var set = require( '@stdlib/array/base/setter' ); -* -* var arr = [ 1, 2, 3, 4 ]; -* -* var set = setter( dtype( arr ) ); -* set( arr, 2, 10 ); -* -* var v = arr[ 2 ]; -* // returns 10 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/setter/lib/main.js b/base/setter/lib/main.js deleted file mode 100644 index b238a65d8..000000000 --- a/base/setter/lib/main.js +++ /dev/null @@ -1,309 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var SETTERS = { - 'float64': setFloat64, - 'float32': setFloat32, - 'int32': setInt32, - 'int16': setInt16, - 'int8': setInt8, - 'uint32': setUint32, - 'uint16': setUint16, - 'uint8': setUint8, - 'uint8c': setUint8c, - 'generic': setGeneric, - 'default': setArrayLike -}; - - -// FUNCTIONS // - -/** -* Sets an element in a `Float64Array`. -* -* @private -* @param {Float64Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {number} value - value to set -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var arr = new Float64Array( 4 ); -* -* setFloat64( arr, 2, 3.0 ); -* -* var v = arr[ 2 ]; -* // returns 3.0 -*/ -function setFloat64( arr, idx, value ) { - arr[ idx ] = value; -} - -/** -* Sets an element in a `Float32Array`. -* -* @private -* @param {Float32Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {number} value - value to set -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var arr = new Float32Array( 4 ); -* -* setFloat32( arr, 2, 3.0 ); -* -* var v = arr[ 2 ]; -* // returns 3.0 -*/ -function setFloat32( arr, idx, value ) { - arr[ idx ] = value; -} - -/** -* Sets an element in an `Int32Array`. -* -* @private -* @param {Int32Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {number} value - value to set -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var arr = new Int32Array( 4 ); -* -* setInt32( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -function setInt32( arr, idx, value ) { - arr[ idx ] = value; -} - -/** -* Sets an element in an `Int16Array`. -* -* @private -* @param {Int16Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {number} value - value to set -* -* @example -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var arr = new Int16Array( 4 ); -* -* setInt16( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -function setInt16( arr, idx, value ) { - arr[ idx ] = value; -} - -/** -* Sets an element in an `Int8Array`. -* -* @private -* @param {Int8Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {number} value - value to set -* -* @example -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var arr = new Int8Array( 4 ); -* -* setInt8( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -function setInt8( arr, idx, value ) { - arr[ idx ] = value; -} - -/** -* Sets an element in a `Uint32Array`. -* -* @private -* @param {Uint32Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {number} value - value to set -* -* @example -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var arr = new Uint32Array( 4 ); -* -* setUint32( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -function setUint32( arr, idx, value ) { - arr[ idx ] = value; -} - -/** -* Sets an element in a `Uint16Array`. -* -* @private -* @param {Uint16Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {number} value - value to set -* -* @example -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var arr = new Uint16Array( 4 ); -* -* setUint16( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -function setUint16( arr, idx, value ) { - arr[ idx ] = value; -} - -/** -* Sets an element in a `Uint8Array`. -* -* @private -* @param {Uint8Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {number} value - value to set -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var arr = new Uint8Array( 4 ); -* -* setUint8( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -function setUint8( arr, idx, value ) { - arr[ idx ] = value; -} - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @private -* @param {Uint8ClampedArray} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {number} value - value to set -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var arr = new Uint8ClampedArray( 4 ); -* -* setUint8c( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -function setUint8c( arr, idx, value ) { - arr[ idx ] = value; -} - -/** -* Sets an element in a generic `Array`. -* -* @private -* @param {Array} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* setGeneric( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -function setGeneric( arr, idx, value ) { - arr[ idx ] = value; -} - -/** -* Sets an element in an indexed array-like object. -* -* @private -* @param {Collection} arr - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -* -* @example -* var arr = [ 1, 2, 3, 4 ]; -* -* setArrayLike( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -function setArrayLike( arr, idx, value ) { - arr[ idx ] = value; -} - - -// MAIN // - -/** -* Returns an accessor function for setting an element in an indexed array-like object. -* -* @param {string} dtype - array dtype -* @returns {Function} accessor -* -* @example -* var dtype = require( '@stdlib/array/dtype' ); -* -* var arr = [ 1, 2, 3, 4 ]; -* -* var set = setter( dtype( arr ) ); -* set( arr, 2, 3 ); -* -* var v = arr[ 2 ]; -* // returns 3 -*/ -function setter( dtype ) { - var f = SETTERS[ dtype ]; - if ( typeof f === 'function' ) { - return f; - } - return SETTERS.default; -} - - -// EXPORTS // - -module.exports = setter; diff --git a/base/setter/package.json b/base/setter/package.json deleted file mode 100644 index 1abad49b8..000000000 --- a/base/setter/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "@stdlib/array/base/setter", - "version": "0.0.0", - "description": "Return an accessor function for setting an element in an indexed array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "array", - "generic", - "set", - "accessor", - "access", - "setter" - ] -} diff --git a/base/setter/test/test.js b/base/setter/test/test.js deleted file mode 100644 index 50c8563d4..000000000 --- a/base/setter/test/test.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 filled = require( './../../../filled' ); -var dtypes = require( './../../../typed-real-dtypes' ); -var setter = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); -DTYPES.push( 'generic' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof setter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function for setting an array element', function test( t ) { - var arr; - var set; - var dt; - var v; - var i; - - for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - set = setter( dt ); - arr = filled( 0, 10, dt ); - set( arr, 2, i+1 ); - v = arr[ 2 ]; - t.strictEqual( v, i+1, 'returns expected value for dtype: '+dt ); - } - t.end(); -}); - -tape( 'the function returns a function for setting an array element (unrecognized dtype)', function test( t ) { - var arr; - var set; - var v; - - set = setter( 'foo' ); - arr = filled( 2, 10, 'generic' ); - set( arr, 2, 100 ); - v = arr[ 2 ]; - t.strictEqual( v, 100, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned function does not perform bounds checks', function test( t ) { - var arr; - var set; - var dt; - var v; - var i; - - for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - set = setter( dt ); - arr = filled( 0, 10, dt ); - set( arr, 20, i+1 ); - v = arr[ 20 ]; - if ( dt === 'generic' ) { - t.strictEqual( v, i+1, 'returns expected value for dtype: '+dt ); - } else { - t.strictEqual( v, void 0, 'returns expected value for dtype: '+dt ); - } - } - t.end(); -}); - -tape( 'the returned function does not perform bounds checks (unrecognized dtype)', function test( t ) { - var arr; - var set; - var v; - - set = setter( 'foo' ); - arr = filled( 0, 10, 'generic' ); - set( arr, 20, 100 ); - v = arr[ 20 ]; - t.strictEqual( v, 100, 'returns expected value' ); - - t.end(); -}); diff --git a/base/slice/README.md b/base/slice/README.md deleted file mode 100644 index afd13b19c..000000000 --- a/base/slice/README.md +++ /dev/null @@ -1,134 +0,0 @@ - - -# slice - -> Return a shallow copy of a portion of an array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var slice = require( '@stdlib/array/base/slice' ); -``` - -#### slice( x, start, end ) - -Returns a shallow copy of a portion of an array from an inclusive `start` index to an exclusive `end` index. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var out = slice( x, 1, 4 ); -// returns [ 2, 3, 4 ] - -var bool = ( out === x ); -// returns false -``` - -
- - - - - -
- -## Notes - -- If provided an array-like object having a `slice` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.slice( start, end ) - ``` - -- If provided an array-like object without a `slice` method, the function copies input array elements to a new generic array. - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var slice = require( '@stdlib/array/base/slice' ); - -var x = new Float64Array( zeroTo( 6 ) ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -var s = slice( x, 0, 6 ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -s = slice( x, 0, 4 ); -// returns [ 0.0, 1.0, 2.0, 3.0 ] - -s = slice( x, 2, 6 ); -// returns [ 2.0, 3.0, 4.0, 5.0 ] - -s = slice( x, 2, 4 ); -// returns [ 2.0, 3.0 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/slice/benchmark/benchmark.length.js b/base/slice/benchmark/benchmark.length.js deleted file mode 100644 index 3dd04b649..000000000 --- a/base/slice/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var slice = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = slice( x, 0, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/slice/docs/repl.txt b/base/slice/docs/repl.txt deleted file mode 100644 index 410a8c4e9..000000000 --- a/base/slice/docs/repl.txt +++ /dev/null @@ -1,37 +0,0 @@ - -{{alias}}( x, start, end ) - Returns a shallow copy of a portion of an array. - - If provided an array-like object having a `slice` method, the function - defers execution to that method and assumes that the method has the - following signature: - - x.slice( start, end ) - - If provided an array-like object without a `slice` method, the function - copies input array elements to a new generic array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - start: integer - Starting index (inclusive). - - end: integer - Ending index (exclusive). - - Returns - ------- - out: Array|TypedArray - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ], 1, 3 ) - [ 2, 3 ] - - See Also - -------- - diff --git a/base/slice/docs/types/index.d.ts b/base/slice/docs/types/index.d.ts deleted file mode 100644 index 748041306..000000000 --- a/base/slice/docs/types/index.d.ts +++ /dev/null @@ -1,76 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = slice( x, 0, 3 ); -* // returns [ 1.0, 2.0, 3.0 ] -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* var out = slice( x, 0, 3 ); -* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] -*/ -declare function slice( x: T, start: number, end: number ): T; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @returns output array -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = slice( x, 0, 3 ); -* // returns [ 1, 2, 3 ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var out = slice( x, 0, 3 ); -* // returns [ 1, 2, 3 ] -*/ -declare function slice( x: Collection, start: number, end: number ): Array; - - -// EXPORTS // - -export = slice; diff --git a/base/slice/docs/types/test.ts b/base/slice/docs/types/test.ts deleted file mode 100644 index a0779e97a..000000000 --- a/base/slice/docs/types/test.ts +++ /dev/null @@ -1,86 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import BooleanArray = require( './../../../../bool' ); -import slice = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - slice( [ 1, 2, 3 ], 0, 3 ); // $ExpectType number[] - slice( new Float64Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Float64Array - slice( new Float32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Float32Array - slice( new Int32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Int32Array - slice( new Int16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Int16Array - slice( new Int8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Int8Array - slice( new Uint32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Uint32Array - slice( new Uint16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Uint16Array - slice( new Uint8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Uint8Array - slice( new Uint8ClampedArray( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Uint8ClampedArray - slice( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType Complex128Array - slice( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType Complex64Array - slice( new BooleanArray( [ true, false, true, false ] ), 0, 3 ); // $ExpectType BooleanArray -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - slice( 5, 0, 3 ); // $ExpectError - slice( true, 0, 3 ); // $ExpectError - slice( false, 0, 3 ); // $ExpectError - slice( null, 0, 3 ); // $ExpectError - slice( void 0, 0, 3 ); // $ExpectError - slice( {}, 0, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - slice( x, '5', 3 ); // $ExpectError - slice( x, true, 3 ); // $ExpectError - slice( x, false, 3 ); // $ExpectError - slice( x, null, 3 ); // $ExpectError - slice( x, void 0, 3 ); // $ExpectError - slice( x, {}, 3 ); // $ExpectError - slice( x, ( x: number ): number => x, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - slice( x, 0, '5' ); // $ExpectError - slice( x, 0, true ); // $ExpectError - slice( x, 0, false ); // $ExpectError - slice( x, 0, null ); // $ExpectError - slice( x, 0, void 0 ); // $ExpectError - slice( x, 0, {} ); // $ExpectError - slice( x, 0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - slice(); // $ExpectError - slice( [ 1, 2, 3 ] ); // $ExpectError - slice( [ 1, 2, 3 ], 0 ); // $ExpectError - slice( [ 1, 2, 3 ], 0, 3, {} ); // $ExpectError -} diff --git a/base/slice/examples/index.js b/base/slice/examples/index.js deleted file mode 100644 index 0ce5a51cf..000000000 --- a/base/slice/examples/index.js +++ /dev/null @@ -1,42 +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'; - -var Float64Array = require( './../../../float64' ); -var zeroTo = require( './../../../base/zero-to' ); -var slice = require( './../lib' ); - -var x = new Float64Array( zeroTo( 6 ) ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -var s = slice( x, 0, 6 ); -console.log( s ); -// => [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -s = slice( x, 0, 4 ); -console.log( s ); -// => [ 0.0, 1.0, 2.0, 3.0 ] - -s = slice( x, 2, 6 ); -console.log( s ); -// => [ 2.0, 3.0, 4.0, 5.0 ] - -s = slice( x, 2, 4 ); -console.log( s ); -// => [ 2.0, 3.0 ] diff --git a/base/slice/lib/index.js b/base/slice/lib/index.js deleted file mode 100644 index cffab8d59..000000000 --- a/base/slice/lib/index.js +++ /dev/null @@ -1,45 +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'; - -/** -* Return a shallow copy of a portion of an array. -* -* @module @stdlib/array/base/slice -* -* @example -* var slice = require( '@stdlib/array/base/slice' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = slice( x, 1, 3 ); -* // returns [ 2, 3 ] -* -* var bool = ( out === x ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/slice/lib/main.js b/base/slice/lib/main.js deleted file mode 100644 index 0faf15d1a..000000000 --- a/base/slice/lib/main.js +++ /dev/null @@ -1,152 +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 arraylike2object = require( './../../../base/arraylike2object' ); - - -// VARIABLES // - -var arraySlice = Array.prototype.slice; - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'slice' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - -/** -* Returns a shallow copy of a portion of an array using the `Array#slice` built-in. -* -* @private -* @param {Collection} x - input array -* @param {integer} start - starting index (inclusive) -* @param {integer} end - ending index (exclusive) -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = builtin( x, 1, 3 ); -* // returns [ 2, 3 ] -*/ -function builtin( x, start, end ) { - return arraySlice.call( x, start, end ); -} - -/** -* Returns a shallow copy of a portion of an accessor array. -* -* @private -* @param {Object} x - input array object -* @param {integer} start - starting index (inclusive) -* @param {integer} end - ending index (exclusive) -* @returns {Array} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) ); -* -* var out = accessors( x, 1, 3 ); -* // returns [ 2, 3 ] -*/ -function accessors( x, start, end ) { - var data; - var get; - var out; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - out = []; - for ( i = start; i < end; i++ ) { - out.push( get( data, i ) ); - } - return out; -} - - -// MAIN // - -/** -* Returns a shallow copy of a portion of an array. -* -* @param {Collection} x - input array -* @param {integer} start - starting index (inclusive) -* @param {integer} end - ending index (exclusive) -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = slice( x, 1, 3 ); -* // returns [ 2, 3 ] -* -* var bool = ( out === x ); -* // returns false -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var out = slice( x, 1, 3 ); -* // returns [ 2, 3 ] -* -* var bool = ( out === x ); -* // returns false -*/ -function slice( x, start, end ) { - var obj; - if ( hasMethod( x, 'slice' ) ) { - return x.slice( start, end ); - } - obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj, start, end ); - } - // Assume we can use the built-in `Array#slice` method to copy elements to a generic array: - return builtin( x, start, end ); -} - - -// EXPORTS // - -module.exports = slice; diff --git a/base/slice/package.json b/base/slice/package.json deleted file mode 100644 index 21ea768dd..000000000 --- a/base/slice/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/slice", - "version": "0.0.0", - "description": "Return a shallow copy of a portion of an array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "copy", - "slice", - "shallow" - ] -} diff --git a/base/slice/test/test.js b/base/slice/test/test.js deleted file mode 100644 index 7b1a6cb03..000000000 --- a/base/slice/test/test.js +++ /dev/null @@ -1,260 +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 AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var slice = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof slice, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function slices an array-like object (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - - expected = [ 1, 2, 3 ]; - actual = slice( x, 0, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 3 ]; - actual = slice( x, 1, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2 ]; - actual = slice( x, 1, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = slice( x, 1, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (float64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = slice( x, 0, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 2.0, 3.0 ] ); - actual = slice( x, 1, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 2.0 ] ); - actual = slice( x, 1, -1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - actual = slice( x, 1, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (int32)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = slice( x, 0, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1, 2 ] ); - actual = slice( x, 0, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1 ] ); - actual = slice( x, 0, x.length-2 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [] ); - actual = slice( x, 0, x.length-3 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = new AccessorArray( [ 1, 2, 3, 4 ] ); - - expected = [ 1, 2, 3, 4 ]; - actual = slice( x, 0, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3 ]; - actual = slice( x, 0, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 3 ]; - actual = slice( x, 1, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 3 ]; - actual = slice( x, 2, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = slice( x, 3, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (array-like)', function test( t ) { - var expected; - var actual; - var x; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - - expected = [ 1, 2, 3, 4 ]; - actual = slice( x, 0, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3 ]; - actual = slice( x, 0, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 3 ]; - actual = slice( x, 1, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 3 ]; - actual = slice( x, 2, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = slice( x, 3, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of length `0`', function test( t ) { - var expected; - var actual; - - expected = []; - actual = slice( [], 0, 0 ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/strided2array2d/README.md b/base/strided2array2d/README.md deleted file mode 100644 index 1fac20433..000000000 --- a/base/strided2array2d/README.md +++ /dev/null @@ -1,118 +0,0 @@ - - -# strided2array2d - -> Convert a strided array to a two-dimensional nested array. - -
- -
- - - -
- -## Usage - -```javascript -var strided2array2d = require( '@stdlib/array/base/strided2array2d' ); -``` - -#### strided2array2d( x, shape, strides, offset ) - -Converts a strided array to a two-dimensional nested array. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var arr = strided2array2d( x, [ 3, 2 ], [ 2, 1 ], 0 ); -// returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] - -arr = strided2array2d( x, [ 3, 2 ], [ 1, 3 ], 0 ); -// returns [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] -``` - -The function accepts the following arguments: - -- **x**: input array. -- **shape**: array shape. -- **strides**: dimension strides. -- **offset**: index of the first indexed value in the input array. - -
- - - -
- -## Notes - -- The function assumes that the input array is [compatible][@stdlib/ndarray/base/assert/is-buffer-length-compatible] with the specified array shape, dimension strides, and index offset. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array2d = require( '@stdlib/array/base/strided2array2d' ); - -var shape = [ 3, 3 ]; - -var x = zeroTo( numel( shape ) ); -console.log( x ); - -var y = strided2array2d( x, shape, shape2strides( shape, 'row-major' ), 0 ); -console.log( y ); - -y = strided2array2d( x, shape, shape2strides( shape, 'column-major' ), 0 ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/strided2array2d/benchmark/benchmark.js b/base/strided2array2d/benchmark/benchmark.js deleted file mode 100644 index 240635ab0..000000000 --- a/base/strided2array2d/benchmark/benchmark.js +++ /dev/null @@ -1,120 +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 bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var zeroTo = require( './../../../base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var orders = require( '@stdlib/ndarray/orders' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var pkg = require( './../package.json' ).name; -var strided2array2d = require( './../lib' ); - - -// VARIABLES // - -var ORDERS = orders(); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @param {string} order - memory layout order -* @returns {Function} benchmark function -*/ -function createBenchmark( shape, order ) { - var strides = shape2strides( shape, order ); - var x = zeroTo( numel( shape ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = strided2array2d( x, shape, strides, 0 ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( out[ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( out[ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var ord; - var sh; - var N; - var f; - var i; - var j; - - min = 1; // 10^min - max = 6; // 10^max - - for ( j = 0; j < ORDERS.length; j++ ) { - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - ord = ORDERS[ j ]; - f = createBenchmark( sh, ord ); - bench( pkg+'::square_matrix:size='+numel( sh )+',order='+ord, f ); - } - } -} - -main(); diff --git a/base/strided2array2d/docs/repl.txt b/base/strided2array2d/docs/repl.txt deleted file mode 100644 index d60461d8a..000000000 --- a/base/strided2array2d/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, shape, strides, offset ) - Converts a strided array to a two-dimensional nested array. - - The function assumes that the input array is compatible with the specified - array shape, dimension strides, and index offset. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - shape: Array - Array shape. - - strides: Array - Dimension strides. - - offset: integer - Index of the first indexed value in the input array. - - Examples - -------- - > var x = [ 1.0, 2.0, 3.0, 4.0 ]; - > var y = {{alias}}( x, [ 2, 2 ], [ 2, 1 ], 0 ) - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] - - See Also - -------- - diff --git a/base/strided2array2d/docs/types/index.d.ts b/base/strided2array2d/docs/types/index.d.ts deleted file mode 100644 index 31a4dd69e..000000000 --- a/base/strided2array2d/docs/types/index.d.ts +++ /dev/null @@ -1,56 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D, ArrayLike } from '@stdlib/types/array'; -import { Shape2D, Strides2D } from '@stdlib/types/ndarray'; - -/** -* Converts a strided array to a two-dimensional nested array. -* -* ## Notes -* -* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. -* -* @param x - input array -* @param shape - array shape -* @param strides - dimension strides -* @param offset - index of the first indexed value in the input array -* @returns two-dimensional nested array -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array2d( x, [ 3, 2 ], [ 2, 1 ], 0 ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array2d( x, [ 3, 2 ], [ 1, 3 ], 0 ); -* // returns [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] -*/ -declare function strided2array2d( x: ArrayLike, shape: Shape2D, strides: Strides2D, offset: number ): Array2D; - - -// EXPORTS // - -export = strided2array2d; diff --git a/base/strided2array2d/docs/types/test.ts b/base/strided2array2d/docs/types/test.ts deleted file mode 100644 index c108a3ba2..000000000 --- a/base/strided2array2d/docs/types/test.ts +++ /dev/null @@ -1,92 +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. -*/ - -import strided2array2d = require( './index' ); - - -// TESTS // - -// The function returns a two-dimensional nested array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array2d( x, [ 2, 2 ], [ 2, 1 ], 0 ); // $ExpectType Array2D - strided2array2d( x, [ 2, 2 ], [ 1, 2 ], 0 ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - strided2array2d( 3.14, [ 2, 2 ], [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( true, [ 2, 2 ], [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( false, [ 2, 2 ], [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( null, [ 2, 2 ], [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( {}, [ 2, 2 ], [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( ( x: number ): number => x, [ 2, 2 ], [ 2, 1 ], 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array2d( x, 'abc', [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( x, 3.14, [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( x, true, [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( x, false, [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( x, null, [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( x, [ '1' ], [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( x, {}, [ 2, 1 ], 0 ); // $ExpectError - strided2array2d( x, ( x: number ): number => x, [ 2, 1 ], 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array of numbers... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array2d( x, [ 2, 2 ], 'abc', 0 ); // $ExpectError - strided2array2d( x, [ 2, 2 ], 3.14, 0 ); // $ExpectError - strided2array2d( x, [ 2, 2 ], true, 0 ); // $ExpectError - strided2array2d( x, [ 2, 2 ], false, 0 ); // $ExpectError - strided2array2d( x, [ 2, 2 ], null, 0 ); // $ExpectError - strided2array2d( x, [ 2, 2 ], [ '1' ], 0 ); // $ExpectError - strided2array2d( x, [ 2, 2 ], {}, 0 ); // $ExpectError - strided2array2d( x, [ 2, 2 ], ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array2d( x, [ 2, 2 ], [ 2, 1 ], 'abc' ); // $ExpectError - strided2array2d( x, [ 2, 2 ], [ 2, 1 ], true ); // $ExpectError - strided2array2d( x, [ 2, 2 ], [ 2, 1 ], false ); // $ExpectError - strided2array2d( x, [ 2, 2 ], [ 2, 1 ], null ); // $ExpectError - strided2array2d( x, [ 2, 2 ], [ 2, 1 ], [ '1' ] ); // $ExpectError - strided2array2d( x, [ 2, 2 ], [ 2, 1 ], {} ); // $ExpectError - strided2array2d( x, [ 2, 2 ], [ 2, 1 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array2d(); // $ExpectError - strided2array2d( x ); // $ExpectError - strided2array2d( x, [ 2, 2 ] ); // $ExpectError - strided2array2d( x, [ 2, 2 ], [ 2, 1 ] ); // $ExpectError - strided2array2d( x, [ 2, 2 ], [ 2, 1 ], 0, {} ); // $ExpectError -} diff --git a/base/strided2array2d/examples/index.js b/base/strided2array2d/examples/index.js deleted file mode 100644 index ea5f2d49b..000000000 --- a/base/strided2array2d/examples/index.js +++ /dev/null @@ -1,35 +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'; - -var zeroTo = require( './../../../base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array2d = require( './../lib' ); - -var shape = [ 3, 3 ]; - -var x = zeroTo( numel( shape ) ); -console.log( x ); - -var y = strided2array2d( x, shape, shape2strides( shape, 'row-major' ), 0 ); -console.log( y ); - -y = strided2array2d( x, shape, shape2strides( shape, 'column-major' ), 0 ); -console.log( y ); diff --git a/base/strided2array2d/lib/index.js b/base/strided2array2d/lib/index.js deleted file mode 100644 index d226f7808..000000000 --- a/base/strided2array2d/lib/index.js +++ /dev/null @@ -1,45 +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'; - -/** -* Convert a strided array to a two-dimensional nested array. -* -* @module @stdlib/array/base/strided2array2d -* -* @example -* var strided2array2d = require( '@stdlib/array/base/strided2array2d' ); -* -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array2d( x, [ 3, 2 ], [ 2, 1 ], 0 ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* arr = strided2array2d( x, [ 3, 2 ], [ 1, 3 ], 0 ); -* // returns [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/strided2array2d/lib/main.js b/base/strided2array2d/lib/main.js deleted file mode 100644 index a9e75ee8c..000000000 --- a/base/strided2array2d/lib/main.js +++ /dev/null @@ -1,89 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Converts a strided array to a two-dimensional nested array. -* -* ## Notes -* -* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. -* -* @param {Collection} x - input array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - dimension strides -* @param {NonNegativeInteger} offset - index of the first indexed value in the input array -* @returns {Array} two-dimensional nested array -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array2d( x, [ 3, 2 ], [ 2, 1 ], 0 ); -* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array2d( x, [ 3, 2 ], [ 1, 3 ], 0 ); -* // returns [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] -*/ -function strided2array2d( x, shape, strides, offset ) { - var get; - var out; - var tmp; - var dx0; - var dx1; - var S0; - var S1; - var i0; - var i1; - var ix; - - get = resolveGetter( x ); - - S1 = shape[ 0 ]; - S0 = shape[ 1 ]; - - dx1 = strides[ 0 ]; - dx0 = strides[ 1 ]; - - out = []; - for ( i1 = 0; i1 < S1; i1++ ) { - tmp = []; - ix = offset + ( dx1*i1 ); - for ( i0 = 0; i0 < S0; i0++ ) { - tmp.push( get( x, ix ) ); - ix += dx0; - } - out.push( tmp ); - } - return out; -} - - -// EXPORTS // - -module.exports = strided2array2d; diff --git a/base/strided2array2d/package.json b/base/strided2array2d/package.json deleted file mode 100644 index 9aae9af99..000000000 --- a/base/strided2array2d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/strided2array2d", - "version": "0.0.0", - "description": "Convert a strided array to a two-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "nested", - "flat", - "linear", - "2d", - "matrix", - "strided", - "ndarray", - "multidimensional" - ] -} diff --git a/base/strided2array2d/test/test.js b/base/strided2array2d/test/test.js deleted file mode 100644 index 2e2923ea8..000000000 --- a/base/strided2array2d/test/test.js +++ /dev/null @@ -1,142 +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 shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof strided2array2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts a strided array to a nested array (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var shape; - var x; - - x = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 4, 2 ]; - strides = shape2strides( shape, 'row-major' ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ], - [ 7, 8 ] - ]; - actual = strided2array2d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2 ]; - strides = [ 4, 2 ]; - - expected = [ - [ 1, 3 ], - [ 5, 7 ] - ]; - actual = strided2array2d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2 ]; - strides = [ -4, -2 ]; - - expected = [ - [ 8, 6 ], - [ 4, 2 ] - ]; - actual = strided2array2d( x, shape, strides, x.length-1 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2 ]; - strides = [ -4, 1 ]; - - expected = [ - [ 7, 8 ], - [ 3, 4 ] - ]; - actual = strided2array2d( x, shape, strides, x.length-2 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts a strided array to a nested array (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var shape; - var x; - - x = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 4, 2 ]; - strides = shape2strides( shape, 'column-major' ); - - expected = [ - [ 1, 5 ], - [ 2, 6 ], - [ 3, 7 ], - [ 4, 8 ] - ]; - actual = strided2array2d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2 ]; - strides = [ 2, 4 ]; - - expected = [ - [ 1, 5 ], - [ 3, 7 ] - ]; - actual = strided2array2d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2 ]; - strides = [ -2, -4 ]; - - expected = [ - [ 8, 4 ], - [ 6, 2 ] - ]; - actual = strided2array2d( x, shape, strides, x.length-1 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2 ]; - strides = [ 1, -4 ]; - - expected = [ - [ 7, 3 ], - [ 8, 4 ] - ]; - actual = strided2array2d( x, shape, strides, x.length-2 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/strided2array3d/README.md b/base/strided2array3d/README.md deleted file mode 100644 index d13453582..000000000 --- a/base/strided2array3d/README.md +++ /dev/null @@ -1,118 +0,0 @@ - - -# strided2array3d - -> Convert a strided array to a three-dimensional nested array. - -
- -
- - - -
- -## Usage - -```javascript -var strided2array3d = require( '@stdlib/array/base/strided2array3d' ); -``` - -#### strided2array3d( x, shape, strides, offset ) - -Converts a strided array to a three-dimensional nested array. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var arr = strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 ); -// returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] - -arr = strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 ); -// returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] -``` - -The function accepts the following arguments: - -- **x**: input array. -- **shape**: array shape. -- **strides**: dimension strides. -- **offset**: index of the first indexed value in the input array. - -
- - - -
- -## Notes - -- The function assumes that the input array is [compatible][@stdlib/ndarray/base/assert/is-buffer-length-compatible] with the specified array shape, dimension strides, and index offset. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array3d = require( '@stdlib/array/base/strided2array3d' ); - -var shape = [ 3, 3, 3 ]; - -var x = zeroTo( numel( shape ) ); -console.log( x ); - -var y = strided2array3d( x, shape, shape2strides( shape, 'row-major' ), 0 ); -console.log( y ); - -y = strided2array3d( x, shape, shape2strides( shape, 'column-major' ), 0 ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/strided2array3d/benchmark/benchmark.js b/base/strided2array3d/benchmark/benchmark.js deleted file mode 100644 index d2a43e7bc..000000000 --- a/base/strided2array3d/benchmark/benchmark.js +++ /dev/null @@ -1,123 +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 bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var zeroTo = require( './../../../base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var orders = require( '@stdlib/ndarray/orders' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var pkg = require( './../package.json' ).name; -var strided2array3d = require( './../lib' ); - - -// VARIABLES // - -var ORDERS = orders(); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @param {string} order - memory layout order -* @returns {Function} benchmark function -*/ -function createBenchmark( shape, order ) { - var strides = shape2strides( shape, order ); - var x = zeroTo( numel( shape ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = strided2array3d( x, shape, strides, 0 ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( out[ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( out[ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var ord; - var sh; - var N; - var f; - var i; - var j; - - min = 1; // 10^min - max = 6; // 10^max - - for ( j = 0; j < ORDERS.length; j++ ) { - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - ord = ORDERS[ j ]; - f = createBenchmark( sh, ord ); - bench( pkg+'::equidimensional:size='+numel( sh )+',order='+ord, f ); - } - } -} - -main(); diff --git a/base/strided2array3d/docs/repl.txt b/base/strided2array3d/docs/repl.txt deleted file mode 100644 index a29bde5e2..000000000 --- a/base/strided2array3d/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, shape, strides, offset ) - Converts a strided array to a three-dimensional nested array. - - The function assumes that the input array is compatible with the specified - array shape, dimension strides, and index offset. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - shape: Array - Array shape. - - strides: Array - Dimension strides. - - offset: integer - Index of the first indexed value in the input array. - - Examples - -------- - > var x = [ 1.0, 2.0, 3.0, 4.0 ]; - > var y = {{alias}}( x, [ 1, 2, 2 ], [ 4, 2, 1 ], 0 ) - [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] - - See Also - -------- - diff --git a/base/strided2array3d/docs/types/index.d.ts b/base/strided2array3d/docs/types/index.d.ts deleted file mode 100644 index 9a2d51f77..000000000 --- a/base/strided2array3d/docs/types/index.d.ts +++ /dev/null @@ -1,56 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D, ArrayLike } from '@stdlib/types/array'; -import { Shape3D, Strides3D } from '@stdlib/types/ndarray'; - -/** -* Converts a strided array to a three-dimensional nested array. -* -* ## Notes -* -* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. -* -* @param x - input array -* @param shape - array shape -* @param strides - dimension strides -* @param offset - index of the first indexed value in the input array -* @returns three-dimensional nested array -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 ); -* // returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 ); -* // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] -*/ -declare function strided2array3d( x: ArrayLike, shape: Shape3D, strides: Strides3D, offset: number ): Array3D; - - -// EXPORTS // - -export = strided2array3d; diff --git a/base/strided2array3d/docs/types/test.ts b/base/strided2array3d/docs/types/test.ts deleted file mode 100644 index 8236c288c..000000000 --- a/base/strided2array3d/docs/types/test.ts +++ /dev/null @@ -1,92 +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. -*/ - -import strided2array3d = require( './index' ); - - -// TESTS // - -// The function returns a three-dimensional nested array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array3d( x, [ 1, 2, 2 ], [ 4, 2, 1 ], 0 ); // $ExpectType Array3D - strided2array3d( x, [ 1, 2, 2 ], [ 1, 1, 2 ], 0 ); // $ExpectType Array3D -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - strided2array3d( 3.14, [ 1, 2, 2 ], [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( true, [ 1, 2, 2 ], [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( false, [ 1, 2, 2 ], [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( null, [ 1, 2, 2 ], [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( {}, [ 1, 2, 2 ], [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( ( x: number ): number => x, [ 1, 2, 2 ], [ 4, 2, 1 ], 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array3d( x, 'abc', [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( x, 3.14, [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( x, true, [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( x, false, [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( x, null, [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( x, [ '1' ], [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( x, {}, [ 4, 2, 1 ], 0 ); // $ExpectError - strided2array3d( x, ( x: number ): number => x, [ 4, 2, 1 ], 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array of numbers... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array3d( x, [ 1, 2, 2 ], 'abc', 0 ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], 3.14, 0 ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], true, 0 ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], false, 0 ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], null, 0 ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], [ '1' ], 0 ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], {}, 0 ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array3d( x, [ 1, 2, 2 ], [ 4, 2, 1 ], 'abc' ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], [ 4, 2, 1 ], true ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], [ 4, 2, 1 ], false ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], [ 4, 2, 1 ], null ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], [ 4, 2, 1 ], [ '1' ] ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], [ 4, 2, 1 ], {} ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], [ 4, 2, 1 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array3d(); // $ExpectError - strided2array3d( x ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ] ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], [ 4, 2, 1 ] ); // $ExpectError - strided2array3d( x, [ 1, 2, 2 ], [ 4, 2, 1 ], 0, {} ); // $ExpectError -} diff --git a/base/strided2array3d/examples/index.js b/base/strided2array3d/examples/index.js deleted file mode 100644 index 349b6c8bc..000000000 --- a/base/strided2array3d/examples/index.js +++ /dev/null @@ -1,35 +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'; - -var zeroTo = require( './../../../base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array3d = require( './../lib' ); - -var shape = [ 3, 3, 3 ]; - -var x = zeroTo( numel( shape ) ); -console.log( x ); - -var y = strided2array3d( x, shape, shape2strides( shape, 'row-major' ), 0 ); -console.log( y ); - -y = strided2array3d( x, shape, shape2strides( shape, 'column-major' ), 0 ); -console.log( y ); diff --git a/base/strided2array3d/lib/index.js b/base/strided2array3d/lib/index.js deleted file mode 100644 index 048b4b4fb..000000000 --- a/base/strided2array3d/lib/index.js +++ /dev/null @@ -1,45 +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'; - -/** -* Convert a strided array to a three-dimensional nested array. -* -* @module @stdlib/array/base/strided2array3d -* -* @example -* var strided2array3d = require( '@stdlib/array/base/strided2array3d' ); -* -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 ); -* // returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] -* -* arr = strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 ); -* // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/strided2array3d/lib/main.js b/base/strided2array3d/lib/main.js deleted file mode 100644 index ec2cb5e21..000000000 --- a/base/strided2array3d/lib/main.js +++ /dev/null @@ -1,101 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Converts a strided array to a three-dimensional nested array. -* -* ## Notes -* -* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. -* -* @param {Collection} x - input array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - dimension strides -* @param {NonNegativeInteger} offset - index of the first indexed value in the input array -* @returns {Array>} three-dimensional nested array -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 ); -* // returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 ); -* // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] -*/ -function strided2array3d( x, shape, strides, offset ) { - var get; - var out; - var dx0; - var dx1; - var dx2; - var ix1; - var ix0; - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var t2; - var t1; - - get = resolveGetter( x ); - - S2 = shape[ 0 ]; - S1 = shape[ 1 ]; - S0 = shape[ 2 ]; - - dx2 = strides[ 0 ]; - dx1 = strides[ 1 ]; - dx0 = strides[ 2 ]; - - out = []; - for ( i2 = 0; i2 < S2; i2++ ) { - t2 = []; - ix1 = offset + ( dx2*i2 ); - for ( i1 = 0; i1 < S1; i1++ ) { - t1 = []; - ix0 = ix1 + ( dx1*i1 ); - for ( i0 = 0; i0 < S0; i0++ ) { - t1.push( get( x, ix0 ) ); - ix0 += dx0; - } - t2.push( t1 ); - } - out.push( t2 ); - } - return out; -} - - -// EXPORTS // - -module.exports = strided2array3d; diff --git a/base/strided2array3d/package.json b/base/strided2array3d/package.json deleted file mode 100644 index 4e40418de..000000000 --- a/base/strided2array3d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/strided2array3d", - "version": "0.0.0", - "description": "Convert a strided array to a three-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "nested", - "flat", - "linear", - "3d", - "matrix", - "strided", - "tensor", - "ndarray", - "multidimensional" - ] -} diff --git a/base/strided2array3d/test/test.js b/base/strided2array3d/test/test.js deleted file mode 100644 index 8974ee992..000000000 --- a/base/strided2array3d/test/test.js +++ /dev/null @@ -1,186 +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 shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof strided2array3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts a strided array to a nested array (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var shape; - var x; - - x = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - - shape = [ 2, 2, 2 ]; - strides = shape2strides( shape, 'row-major' ); - - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ]; - actual = strided2array3d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2, 2 ]; - strides = [ 8, 4, 2 ]; - - expected = [ - [ - [ 1, 3 ], - [ 5, 7 ] - ], - [ - [ 9, 11 ], - [ 13, 15 ] - ] - ]; - actual = strided2array3d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2, 2 ]; - strides = [ -8, -4, -2 ]; - - expected = [ - [ - [ 16, 14 ], - [ 12, 10 ] - ], - [ - [ 8, 6 ], - [ 4, 2 ] - ] - ]; - actual = strided2array3d( x, shape, strides, x.length-1 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2, 2 ]; - strides = [ -8, -4, 1 ]; - - expected = [ - [ - [ 15, 16 ], - [ 11, 12 ] - ], - [ - [ 7, 8 ], - [ 3, 4 ] - ] - ]; - actual = strided2array3d( x, shape, strides, x.length-2 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts a strided array to a nested array (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var shape; - var x; - - x = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - - shape = [ 2, 2, 2 ]; - strides = shape2strides( shape, 'column-major' ); - - expected = [ - [ - [ 1, 5 ], - [ 3, 7 ] - ], - [ - [ 2, 6 ], - [ 4, 8 ] - ] - ]; - actual = strided2array3d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2, 2 ]; - strides = [ 2, 4, 8 ]; - - expected = [ - [ - [ 1, 9 ], - [ 5, 13 ] - ], - [ - [ 3, 11 ], - [ 7, 15 ] - ] - ]; - actual = strided2array3d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2, 2 ]; - strides = [ -2, -4, -8 ]; - - expected = [ - [ - [ 16, 8 ], - [ 12, 4 ] - ], - [ - [ 14, 6 ], - [ 10, 2 ] - ] - ]; - actual = strided2array3d( x, shape, strides, x.length-1 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2, 2 ]; - strides = [ 1, -4, -8 ]; - - expected = [ - [ - [ 15, 7 ], - [ 11, 3 ] - ], - [ - [ 16, 8 ], - [ 12, 4 ] - ] - ]; - actual = strided2array3d( x, shape, strides, x.length-2 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/strided2array4d/README.md b/base/strided2array4d/README.md deleted file mode 100644 index 93fbc7cf1..000000000 --- a/base/strided2array4d/README.md +++ /dev/null @@ -1,118 +0,0 @@ - - -# strided2array4d - -> Convert a strided array to a four-dimensional nested array. - -
- -
- - - -
- -## Usage - -```javascript -var strided2array4d = require( '@stdlib/array/base/strided2array4d' ); -``` - -#### strided2array4d( x, shape, strides, offset ) - -Converts a strided array to a four-dimensional nested array. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 6, 6, 2, 1 ], 0 ); -// returns [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] - -arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 1, 1, 1, 3 ], 0 ); -// returns [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] -``` - -The function accepts the following arguments: - -- **x**: input array. -- **shape**: array shape. -- **strides**: dimension strides. -- **offset**: index of the first indexed value in the input array. - -
- - - -
- -## Notes - -- The function assumes that the input array is [compatible][@stdlib/ndarray/base/assert/is-buffer-length-compatible] with the specified array shape, dimension strides, and index offset. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array4d = require( '@stdlib/array/base/strided2array4d' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = zeroTo( numel( shape ) ); -console.log( x ); - -var y = strided2array4d( x, shape, shape2strides( shape, 'row-major' ), 0 ); -console.log( y ); - -y = strided2array4d( x, shape, shape2strides( shape, 'column-major' ), 0 ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/strided2array4d/benchmark/benchmark.js b/base/strided2array4d/benchmark/benchmark.js deleted file mode 100644 index 27be84391..000000000 --- a/base/strided2array4d/benchmark/benchmark.js +++ /dev/null @@ -1,126 +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 bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var zeroTo = require( './../../../base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var orders = require( '@stdlib/ndarray/orders' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var pkg = require( './../package.json' ).name; -var strided2array4d = require( './../lib' ); - - -// VARIABLES // - -var ORDERS = orders(); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @param {string} order - memory layout order -* @returns {Function} benchmark function -*/ -function createBenchmark( shape, order ) { - var strides = shape2strides( shape, order ); - var x = zeroTo( numel( shape ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = strided2array4d( x, shape, strides, 0 ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var ord; - var sh; - var N; - var f; - var i; - var j; - - min = 1; // 10^min - max = 6; // 10^max - - for ( j = 0; j < ORDERS.length; j++ ) { - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - ord = ORDERS[ j ]; - f = createBenchmark( sh, ord ); - bench( pkg+'::equidimensional:size='+numel( sh )+',order='+ord, f ); - } - } -} - -main(); diff --git a/base/strided2array4d/docs/repl.txt b/base/strided2array4d/docs/repl.txt deleted file mode 100644 index c1aed7ed4..000000000 --- a/base/strided2array4d/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, shape, strides, offset ) - Converts a strided array to a four-dimensional nested array. - - The function assumes that the input array is compatible with the specified - array shape, dimension strides, and index offset. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - shape: Array - Array shape. - - strides: Array - Dimension strides. - - offset: integer - Index of the first indexed value in the input array. - - Examples - -------- - > var x = [ 1.0, 2.0, 3.0, 4.0 ]; - > var y = {{alias}}( x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], 0 ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - See Also - -------- - diff --git a/base/strided2array4d/docs/types/index.d.ts b/base/strided2array4d/docs/types/index.d.ts deleted file mode 100644 index e5f0ddcb9..000000000 --- a/base/strided2array4d/docs/types/index.d.ts +++ /dev/null @@ -1,56 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D, ArrayLike } from '@stdlib/types/array'; -import { Shape4D, Strides4D } from '@stdlib/types/ndarray'; - -/** -* Converts a strided array to a four-dimensional nested array. -* -* ## Notes -* -* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. -* -* @param x - input array -* @param shape - array shape -* @param strides - dimension strides -* @param offset - index of the first indexed value in the input array -* @returns four-dimensional nested array -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 6, 6, 2, 1 ], 0 ); -* // returns [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 1, 1, 1, 3 ], 0 ); -* // returns [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] -*/ -declare function strided2array4d( x: ArrayLike, shape: Shape4D, strides: Strides4D, offset: number ): Array4D; - - -// EXPORTS // - -export = strided2array4d; diff --git a/base/strided2array4d/docs/types/test.ts b/base/strided2array4d/docs/types/test.ts deleted file mode 100644 index 15c5a233b..000000000 --- a/base/strided2array4d/docs/types/test.ts +++ /dev/null @@ -1,92 +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. -*/ - -import strided2array4d = require( './index' ); - - -// TESTS // - -// The function returns a four-dimensional nested array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array4d( x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], 0 ); // $ExpectType Array4D - strided2array4d( x, [ 1, 1, 2, 2 ], [ 1, 1, 1, 2 ], 0 ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - strided2array4d( 3.14, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( true, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( false, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( null, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( {}, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array4d( x, 'abc', [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( x, 3.14, [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( x, true, [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( x, false, [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( x, null, [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( x, [ '1' ], [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( x, {}, [ 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array4d( x, ( x: number ): number => x, [ 4, 4, 2, 1 ], 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array of numbers... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array4d( x, [ 1, 1, 2, 2 ], 'abc', 0 ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], 3.14, 0 ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], true, 0 ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], false, 0 ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], null, 0 ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], [ '1' ], 0 ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], {}, 0 ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array4d( x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], 'abc' ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], true ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], false ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], null ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], [ '1' ] ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], {} ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array4d(); // $ExpectError - strided2array4d( x ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ] ); // $ExpectError - strided2array4d( x, [ 1, 1, 2, 2 ], [ 4, 4, 2, 1 ], 0, {} ); // $ExpectError -} diff --git a/base/strided2array4d/examples/index.js b/base/strided2array4d/examples/index.js deleted file mode 100644 index 91d1f6930..000000000 --- a/base/strided2array4d/examples/index.js +++ /dev/null @@ -1,35 +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'; - -var zeroTo = require( './../../../base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = zeroTo( numel( shape ) ); -console.log( x ); - -var y = strided2array4d( x, shape, shape2strides( shape, 'row-major' ), 0 ); -console.log( y ); - -y = strided2array4d( x, shape, shape2strides( shape, 'column-major' ), 0 ); -console.log( y ); diff --git a/base/strided2array4d/lib/index.js b/base/strided2array4d/lib/index.js deleted file mode 100644 index 40a492ad1..000000000 --- a/base/strided2array4d/lib/index.js +++ /dev/null @@ -1,45 +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'; - -/** -* Convert a strided array to a four-dimensional nested array. -* -* @module @stdlib/array/base/strided2array4d -* -* @example -* var strided2array4d = require( '@stdlib/array/base/strided2array4d' ); -* -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 6, 6, 2, 1 ], 0 ); -* // returns [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] -* -* arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 1, 1, 1, 3 ], 0 ); -* // returns [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/strided2array4d/lib/main.js b/base/strided2array4d/lib/main.js deleted file mode 100644 index 84e222308..000000000 --- a/base/strided2array4d/lib/main.js +++ /dev/null @@ -1,113 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Converts a strided array to a four-dimensional nested array. -* -* ## Notes -* -* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. -* -* @param {Collection} x - input array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - dimension strides -* @param {NonNegativeInteger} offset - index of the first indexed value in the input array -* @returns {Array>>} four-dimensional nested array -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 6, 6, 2, 1 ], 0 ); -* // returns [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 1, 1, 1, 3 ], 0 ); -* // returns [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] -*/ -function strided2array4d( x, shape, strides, offset ) { - var get; - var out; - var dx0; - var dx1; - var dx2; - var dx3; - var ix2; - var ix1; - var ix0; - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var t3; - var t2; - var t1; - - get = resolveGetter( x ); - - S3 = shape[ 0 ]; - S2 = shape[ 1 ]; - S1 = shape[ 2 ]; - S0 = shape[ 3 ]; - - dx3 = strides[ 0 ]; - dx2 = strides[ 1 ]; - dx1 = strides[ 2 ]; - dx0 = strides[ 3 ]; - - out = []; - for ( i3 = 0; i3 < S3; i3++ ) { - t3 = []; - ix2 = offset + ( dx3*i3 ); - for ( i2 = 0; i2 < S2; i2++ ) { - t2 = []; - ix1 = ix2 + ( dx2*i2 ); - for ( i1 = 0; i1 < S1; i1++ ) { - t1 = []; - ix0 = ix1 + ( dx1*i1 ); - for ( i0 = 0; i0 < S0; i0++ ) { - t1.push( get( x, ix0 ) ); - ix0 += dx0; - } - t2.push( t1 ); - } - t3.push( t2 ); - } - out.push( t3 ); - } - return out; -} - - -// EXPORTS // - -module.exports = strided2array4d; diff --git a/base/strided2array4d/package.json b/base/strided2array4d/package.json deleted file mode 100644 index 6ea14a5e5..000000000 --- a/base/strided2array4d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/strided2array4d", - "version": "0.0.0", - "description": "Convert a strided array to a four-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "nested", - "flat", - "linear", - "4d", - "matrix", - "strided", - "tensor", - "ndarray", - "multidimensional" - ] -} diff --git a/base/strided2array4d/test/test.js b/base/strided2array4d/test/test.js deleted file mode 100644 index 1755611a2..000000000 --- a/base/strided2array4d/test/test.js +++ /dev/null @@ -1,222 +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 shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof strided2array4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts a strided array to a nested array (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var shape; - var x; - - x = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - - shape = [ 1, 2, 2, 2 ]; - strides = shape2strides( shape, 'row-major' ); - - expected = [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ]; - actual = strided2array4d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 1, 2, 2, 2 ]; - strides = [ 16, 8, 4, 2 ]; - - expected = [ - [ - [ - [ 1, 3 ], - [ 5, 7 ] - ], - [ - [ 9, 11 ], - [ 13, 15 ] - ] - ] - ]; - actual = strided2array4d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 1, 2, 2, 2 ]; - strides = [ -16, -8, -4, -2 ]; - - expected = [ - [ - [ - [ 16, 14 ], - [ 12, 10 ] - ], - [ - [ 8, 6 ], - [ 4, 2 ] - ] - ] - ]; - actual = strided2array4d( x, shape, strides, x.length-1 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2, 2, 2 ]; - strides = [ -8, -4, -2, 1 ]; - - expected = [ - [ - [ - [ 15, 16 ], - [ 13, 14 ] - ], - [ - [ 11, 12 ], - [ 9, 10 ] - ] - ], - [ - [ - [ 7, 8 ], - [ 5, 6 ] - ], - [ - [ 3, 4 ], - [ 1, 2 ] - ] - ] - ]; - actual = strided2array4d( x, shape, strides, x.length-2 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts a strided array to a nested array (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var shape; - var x; - - x = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - - shape = [ 1, 2, 2, 2 ]; - strides = shape2strides( shape, 'column-major' ); - - expected = [ - [ - [ - [ 1, 5 ], - [ 3, 7 ] - ], - [ - [ 2, 6 ], - [ 4, 8 ] - ] - ] - ]; - actual = strided2array4d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 1, 2, 2, 2 ]; - strides = [ 1, 2, 4, 8 ]; - - expected = [ - [ - [ - [ 1, 9 ], - [ 5, 13 ] - ], - [ - [ 3, 11 ], - [ 7, 15 ] - ] - ] - ]; - actual = strided2array4d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 1, 2, 2, 2 ]; - strides = [ -1, -2, -4, -8 ]; - - expected = [ - [ - [ - [ 16, 8 ], - [ 12, 4 ] - ], - [ - [ 14, 6 ], - [ 10, 2 ] - ] - ] - ]; - actual = strided2array4d( x, shape, strides, x.length-1 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 2, 2, 2 ]; - strides = [ 1, -2, -4, -8 ]; - - expected = [ - [ - [ - [ 15, 7 ], - [ 11, 3 ] - ], - [ - [ 13, 5 ], - [ 9, 1 ] - ] - ], - [ - [ - [ 16, 8 ], - [ 12, 4 ] - ], - [ - [ 14, 6 ], - [ 10, 2 ] - ] - ] - ]; - actual = strided2array4d( x, shape, strides, x.length-2 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/strided2array5d/README.md b/base/strided2array5d/README.md deleted file mode 100644 index 448bde80a..000000000 --- a/base/strided2array5d/README.md +++ /dev/null @@ -1,118 +0,0 @@ - - -# strided2array5d - -> Convert a strided array to a five-dimensional nested array. - -
- -
- - - -
- -## Usage - -```javascript -var strided2array5d = require( '@stdlib/array/base/strided2array5d' ); -``` - -#### strided2array5d( x, shape, strides, offset ) - -Converts a strided array to a five-dimensional nested array. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 6, 6, 6, 2, 1 ], 0 ); -// returns [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ] - -arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 1, 1, 1, 1, 3 ], 0 ); -// returns [ [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **x**: input array. -- **shape**: array shape. -- **strides**: dimension strides. -- **offset**: index of the first indexed value in the input array. - -
- - - -
- -## Notes - -- The function assumes that the input array is [compatible][@stdlib/ndarray/base/assert/is-buffer-length-compatible] with the specified array shape, dimension strides, and index offset. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array5d = require( '@stdlib/array/base/strided2array5d' ); - -var shape = [ 1, 1, 3, 3, 3 ]; - -var x = zeroTo( numel( shape ) ); -console.log( x ); - -var y = strided2array5d( x, shape, shape2strides( shape, 'row-major' ), 0 ); -console.log( y ); - -y = strided2array5d( x, shape, shape2strides( shape, 'column-major' ), 0 ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/strided2array5d/benchmark/benchmark.js b/base/strided2array5d/benchmark/benchmark.js deleted file mode 100644 index 6a4344290..000000000 --- a/base/strided2array5d/benchmark/benchmark.js +++ /dev/null @@ -1,129 +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 bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var zeroTo = require( './../../../base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var orders = require( '@stdlib/ndarray/orders' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var pkg = require( './../package.json' ).name; -var strided2array5d = require( './../lib' ); - - -// VARIABLES // - -var ORDERS = orders(); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @param {string} order - memory layout order -* @returns {Function} benchmark function -*/ -function createBenchmark( shape, order ) { - var strides = shape2strides( shape, order ); - var x = zeroTo( numel( shape ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = strided2array5d( x, shape, strides, 0 ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( out[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( out[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var ord; - var sh; - var N; - var f; - var i; - var j; - - min = 1; // 10^min - max = 6; // 10^max - - for ( j = 0; j < ORDERS.length; j++ ) { - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - ord = ORDERS[ j ]; - f = createBenchmark( sh, ord ); - bench( pkg+'::equidimensional:size='+numel( sh )+',order='+ord, f ); - } - } -} - -main(); diff --git a/base/strided2array5d/docs/repl.txt b/base/strided2array5d/docs/repl.txt deleted file mode 100644 index 4e116f234..000000000 --- a/base/strided2array5d/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, shape, strides, offset ) - Converts a strided array to a five-dimensional nested array. - - The function assumes that the input array is compatible with the specified - array shape, dimension strides, and index offset. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - shape: Array - Array shape. - - strides: Array - Dimension strides. - - offset: integer - Index of the first indexed value in the input array. - - Examples - -------- - > var x = [ 1.0, 2.0, 3.0, 4.0 ]; - > var y = {{alias}}( x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], 0 ) - [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/strided2array5d/docs/types/index.d.ts b/base/strided2array5d/docs/types/index.d.ts deleted file mode 100644 index 7a32beaf8..000000000 --- a/base/strided2array5d/docs/types/index.d.ts +++ /dev/null @@ -1,56 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D, ArrayLike } from '@stdlib/types/array'; -import { Shape5D, Strides5D } from '@stdlib/types/ndarray'; - -/** -* Converts a strided array to a five-dimensional nested array. -* -* ## Notes -* -* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. -* -* @param x - input array -* @param shape - array shape -* @param strides - dimension strides -* @param offset - index of the first indexed value in the input array -* @returns five-dimensional nested array -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 6, 6, 6, 2, 1 ], 0 ); -* // returns [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 1, 1, 1, 1, 3 ], 0 ); -* // returns [ [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] ] -*/ -declare function strided2array5d( x: ArrayLike, shape: Shape5D, strides: Strides5D, offset: number ): Array5D; - - -// EXPORTS // - -export = strided2array5d; diff --git a/base/strided2array5d/docs/types/test.ts b/base/strided2array5d/docs/types/test.ts deleted file mode 100644 index a8c069e5b..000000000 --- a/base/strided2array5d/docs/types/test.ts +++ /dev/null @@ -1,92 +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. -*/ - -import strided2array5d = require( './index' ); - - -// TESTS // - -// The function returns a five-dimensional nested array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectType Array5D - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ 1, 1, 1, 1, 2 ], 0 ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - strided2array5d( 3.14, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( true, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( false, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( null, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( {}, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array5d( x, 'abc', [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( x, 3.14, [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( x, true, [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( x, false, [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( x, null, [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( x, [ '1' ], [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( x, {}, [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError - strided2array5d( x, ( x: number ): number => x, [ 4, 4, 4, 2, 1 ], 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array of numbers... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array5d( x, [ 1, 1, 1, 2, 2 ], 'abc', 0 ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], 3.14, 0 ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], true, 0 ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], false, 0 ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], null, 0 ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ '1' ], 0 ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], {}, 0 ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], 'abc' ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], true ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], false ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], null ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], [ '1' ] ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], {} ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - strided2array5d(); // $ExpectError - strided2array5d( x ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ] ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ] ); // $ExpectError - strided2array5d( x, [ 1, 1, 1, 2, 2 ], [ 4, 4, 4, 2, 1 ], 0, {} ); // $ExpectError -} diff --git a/base/strided2array5d/examples/index.js b/base/strided2array5d/examples/index.js deleted file mode 100644 index 0e066a263..000000000 --- a/base/strided2array5d/examples/index.js +++ /dev/null @@ -1,35 +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'; - -var zeroTo = require( './../../../base/zero-to' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array5d = require( './../lib' ); - -var shape = [ 1, 1, 3, 3, 3 ]; - -var x = zeroTo( numel( shape ) ); -console.log( x ); - -var y = strided2array5d( x, shape, shape2strides( shape, 'row-major' ), 0 ); -console.log( y ); - -y = strided2array5d( x, shape, shape2strides( shape, 'column-major' ), 0 ); -console.log( y ); diff --git a/base/strided2array5d/lib/index.js b/base/strided2array5d/lib/index.js deleted file mode 100644 index 248dc4c95..000000000 --- a/base/strided2array5d/lib/index.js +++ /dev/null @@ -1,45 +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'; - -/** -* Convert a strided array to a five-dimensional nested array. -* -* @module @stdlib/array/base/strided2array5d -* -* @example -* var strided2array5d = require( '@stdlib/array/base/strided2array5d' ); -* -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 6, 6, 6, 2, 1 ], 0 ); -* // returns [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ] -* -* arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 1, 1, 1, 1, 3 ], 0 ); -* // returns [ [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/strided2array5d/lib/main.js b/base/strided2array5d/lib/main.js deleted file mode 100644 index a6de9b198..000000000 --- a/base/strided2array5d/lib/main.js +++ /dev/null @@ -1,125 +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 resolveGetter = require( './../../../base/resolve-getter' ); - - -// MAIN // - -/** -* Converts a strided array to a five-dimensional nested array. -* -* ## Notes -* -* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. -* -* @param {Collection} x - input array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - dimension strides -* @param {NonNegativeInteger} offset - index of the first indexed value in the input array -* @returns {Array>>>} five-dimensional nested array -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 6, 6, 6, 2, 1 ], 0 ); -* // returns [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 1, 1, 1, 1, 3 ], 0 ); -* // returns [ [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] ] -*/ -function strided2array5d( x, shape, strides, offset ) { - var get; - var out; - var dx0; - var dx1; - var dx2; - var dx3; - var dx4; - var ix3; - var ix2; - var ix1; - var ix0; - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var t4; - var t3; - var t2; - var t1; - - get = resolveGetter( x ); - - S4 = shape[ 0 ]; - S3 = shape[ 1 ]; - S2 = shape[ 2 ]; - S1 = shape[ 3 ]; - S0 = shape[ 4 ]; - - dx4 = strides[ 0 ]; - dx3 = strides[ 1 ]; - dx2 = strides[ 2 ]; - dx1 = strides[ 3 ]; - dx0 = strides[ 4 ]; - - out = []; - for ( i4 = 0; i4 < S4; i4++ ) { - t4 = []; - ix3 = offset + ( dx4*i4 ); - for ( i3 = 0; i3 < S3; i3++ ) { - t3 = []; - ix2 = ix3 + ( dx3*i3 ); - for ( i2 = 0; i2 < S2; i2++ ) { - t2 = []; - ix1 = ix2 + ( dx2*i2 ); - for ( i1 = 0; i1 < S1; i1++ ) { - t1 = []; - ix0 = ix1 + ( dx1*i1 ); - for ( i0 = 0; i0 < S0; i0++ ) { - t1.push( get( x, ix0 ) ); - ix0 += dx0; - } - t2.push( t1 ); - } - t3.push( t2 ); - } - t4.push( t3 ); - } - out.push( t4 ); - } - return out; -} - - -// EXPORTS // - -module.exports = strided2array5d; diff --git a/base/strided2array5d/package.json b/base/strided2array5d/package.json deleted file mode 100644 index 6310e0869..000000000 --- a/base/strided2array5d/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/strided2array5d", - "version": "0.0.0", - "description": "Convert a strided array to a five-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "nested", - "flat", - "linear", - "5d", - "matrix", - "strided", - "tensor", - "ndarray", - "multidimensional" - ] -} diff --git a/base/strided2array5d/test/test.js b/base/strided2array5d/test/test.js deleted file mode 100644 index 2a176f283..000000000 --- a/base/strided2array5d/test/test.js +++ /dev/null @@ -1,266 +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 shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); -var strided2array5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof strided2array5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts a strided array to a nested array (row-major)', function test( t ) { - var expected; - var strides; - var actual; - var shape; - var x; - - x = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - - shape = [ 2, 1, 2, 2, 2 ]; - strides = shape2strides( shape, 'row-major' ); - - expected = [ - [ - [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 5, 6 ], - [ 7, 8 ] - ] - ] - ], - [ - [ - [ - [ 9, 10 ], - [ 11, 12 ] - ], - [ - [ 13, 14 ], - [ 15, 16 ] - ] - ] - ] - ]; - actual = strided2array5d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 1, 1, 2, 2, 2 ]; - strides = [ 16, 16, 8, 4, 2 ]; - - expected = [ - [ - [ - [ - [ 1, 3 ], - [ 5, 7 ] - ], - [ - [ 9, 11 ], - [ 13, 15 ] - ] - ] - ] - ]; - actual = strided2array5d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 1, 1, 2, 2, 2 ]; - strides = [ -16, -16, -8, -4, -2 ]; - - expected = [ - [ - [ - [ - [ 16, 14 ], - [ 12, 10 ] - ], - [ - [ 8, 6 ], - [ 4, 2 ] - ] - ] - ] - ]; - actual = strided2array5d( x, shape, strides, x.length-1 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 1, 2, 2, 2 ]; - strides = [ -8, -8, -4, -2, 1 ]; - - expected = [ - [ - [ - [ - [ 15, 16 ], - [ 13, 14 ] - ], - [ - [ 11, 12 ], - [ 9, 10 ] - ] - ] - ], - [ - [ - [ - [ 7, 8 ], - [ 5, 6 ] - ], - [ - [ 3, 4 ], - [ 1, 2 ] - ] - ] - ] - ]; - actual = strided2array5d( x, shape, strides, x.length-2 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts a strided array to a nested array (column-major)', function test( t ) { - var expected; - var strides; - var actual; - var shape; - var x; - - x = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]; - - shape = [ 2, 1, 2, 2, 2 ]; - strides = shape2strides( shape, 'column-major' ); - - expected = [ - [ - [ - [ - [ 1, 9 ], - [ 5, 13 ] - ], - [ - [ 3, 11 ], - [ 7, 15 ] - ] - ] - ], - [ - [ - [ - [ 2, 10 ], - [ 6, 14 ] - ], - [ - [ 4, 12 ], - [ 8, 16 ] - ] - ] - ] - ]; - actual = strided2array5d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 1, 1, 2, 2, 2 ]; - strides = [ 1, 1, 2, 4, 8 ]; - - expected = [ - [ - [ - [ - [ 1, 9 ], - [ 5, 13 ] - ], - [ - [ 3, 11 ], - [ 7, 15 ] - ] - ] - ] - ]; - actual = strided2array5d( x, shape, strides, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 1, 1, 2, 2, 2 ]; - strides = [ -1, -1, -2, -4, -8 ]; - - expected = [ - [ - [ - [ - [ 16, 8 ], - [ 12, 4 ] - ], - [ - [ 14, 6 ], - [ 10, 2 ] - ] - ] - ] - ]; - actual = strided2array5d( x, shape, strides, x.length-1 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - shape = [ 2, 1, 2, 2, 2 ]; - strides = [ 1, 2, -2, -4, -8 ]; - - expected = [ - [ - [ - [ - [ 15, 7 ], - [ 11, 3 ] - ], - [ - [ 13, 5 ], - [ 9, 1 ] - ] - ] - ], - [ - [ - [ - [ 16, 8 ], - [ 12, 4 ] - ], - [ - [ 14, 6 ], - [ 10, 2 ] - ] - ] - ] - ]; - actual = strided2array5d( x, shape, strides, x.length-2 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/symmetric-banded/README.md b/base/symmetric-banded/README.md deleted file mode 100644 index 18f86d9ac..000000000 --- a/base/symmetric-banded/README.md +++ /dev/null @@ -1,120 +0,0 @@ - - -# Symmetric Banded Arrays - -> Symmetric banded array utilities. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ns = require( '@stdlib/array/base/symmetric-banded' ); -``` - -#### ns - -Namespace containing symmetric banded array utilities. - -```javascript -var o = ns; -// returns {...} -``` - -The namespace exports the following: - - - -
- -- [`filled2dBy( N, k, fill, clbk[, thisArg] )`][@stdlib/array/base/symmetric-banded/filled2d-by]: create a filled two-dimensional symmetric banded nested array according to a provided callback function. -- [`toCompact( uplo, arr, k, colexicographic )`][@stdlib/array/base/symmetric-banded/to-compact]: convert a two-dimensional symmetric banded nested array to compact banded storage. - -
- - - -
- - - - - -
- -
- - - - - -
- -## Examples - - - - - -```javascript -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( '@stdlib/array/base/symmetric-banded' ); - -console.log( objectKeys( ns ) ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/symmetric-banded/docs/types/index.d.ts b/base/symmetric-banded/docs/types/index.d.ts deleted file mode 100644 index 035cc3d9f..000000000 --- a/base/symmetric-banded/docs/types/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import filled2dBy = require( './../../../../base/symmetric-banded/filled2d-by' ); - -/** -* Interface describing a namespace. -*/ -interface Namespace { - /** - * TODO - */ - filled2dBy: typeof filled2dBy; -} - -/** -* Symmetric banded array utilities. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/base/symmetric-banded/docs/types/test.ts b/base/symmetric-banded/docs/types/test.ts deleted file mode 100644 index 1a38cb7de..000000000 --- a/base/symmetric-banded/docs/types/test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/base/symmetric-banded/examples/index.js b/base/symmetric-banded/examples/index.js deleted file mode 100644 index f5349d26c..000000000 --- a/base/symmetric-banded/examples/index.js +++ /dev/null @@ -1,24 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/base/symmetric-banded/filled2d-by/README.md b/base/symmetric-banded/filled2d-by/README.md deleted file mode 100644 index 0958934ee..000000000 --- a/base/symmetric-banded/filled2d-by/README.md +++ /dev/null @@ -1,154 +0,0 @@ - - -# filled2dBy - -> Create a filled two-dimensional symmetric banded nested array according to a provided callback function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled2dBy = require( '@stdlib/array/base/symmetric-banded/filled2d-by' ); -``` - -#### filled2dBy( N, k, fill, clbk\[, thisArg] ) - -Returns a filled two-dimensional symmetric banded nested array according to a provided callback function. - -```javascript -function clbk( idx ) { - return idx[ 0 ] + idx[ 1 ]; -} - -var out = filled2dBy( 3, 1, 0, clbk ); -// returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] -``` - -The function accepts the following arguments: - -- **N**: number of rows and columns. -- **k**: number of super-/sub-diagonals. -- **fill**: fill value for elements outside the band. -- **clbk**: callback function. -- **thisArg**: callback function execution context (_optional_). - -When invoked, a callback function is provided a single argument: - -- **indices**: current array element indices. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function clbk() { - this.count += 1; - return 1; -} - -var ctx = { - 'count': 0 -}; - -var out = filled2dBy( 2, 1, 0, clbk, ctx ); -// returns [ [ 1, 1 ], [ 1, 1 ] ]; - -var cnt = ctx.count; -// returns 3 -``` - -
- - - - - -
- -## Notes - -- As the output array is symmetric and banded, the callback function is only invoked for the elements residing within the band in the upper triangle of the output array. - -
- - - - - -
- -## Examples - - - -```javascript -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( '@stdlib/array/base/symmetric-banded/filled2d-by' ); - -function clbk( indices ) { - return indices[ 0 ] + indices[ 1 ]; -} - -var out = filled2dBy( 3, 1, 0, clbk ); -// returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] - -out = filled2dBy( 3, 1, null, constantFunction( 'beep' ) ); -// returns [ [ 'beep', 'beep', null ], [ 'beep', 'beep', 'beep' ], [ null, 'beep', 'beep' ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/symmetric-banded/filled2d-by/benchmark/benchmark.size.js b/base/symmetric-banded/filled2d-by/benchmark/benchmark.size.js deleted file mode 100644 index a25fee769..000000000 --- a/base/symmetric-banded/filled2d-by/benchmark/benchmark.size.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filled2dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @param {NonNegativeInteger} k - number of super-/sub-diagonals -* @returns {Function} benchmark function -*/ -function createBenchmark( N, k ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( N ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled2dBy( N, k, 0, f ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - var k; - - min = 1; // 10^min - max = 6; // 10^max - - k = 2; - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N, k ); - bench( pkg+':k='+k+',size='+(N*N), f ); - } -} - -main(); diff --git a/base/symmetric-banded/filled2d-by/docs/repl.txt b/base/symmetric-banded/filled2d-by/docs/repl.txt deleted file mode 100644 index 182d5cd95..000000000 --- a/base/symmetric-banded/filled2d-by/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( N, k, fill, clbk[, thisArg] ) - Returns a filled two-dimensional symmetric banded nested array according to - a provided callback function. - - The callback function is provided one argument: - - - indices: current array element indices. - - As the output array is banded and symmetric, the provided callback is only - invoked for elements within the band in the upper triangle. - - Parameters - ---------- - N: integer - Number of rows and columns. - - k: integer - Number of super-/sub-diagonals. - - fill: any - Fill value for elements outside the band. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function clbk( idx ) { return idx[ 0 ] + idx[ 1 ]; }; - > var out = {{alias}}( 3, 1, 0, clbk ) - [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] - - See Also - -------- - diff --git a/base/symmetric-banded/filled2d-by/docs/types/index.d.ts b/base/symmetric-banded/filled2d-by/docs/types/index.d.ts deleted file mode 100644 index b95e67516..000000000 --- a/base/symmetric-banded/filled2d-by/docs/types/index.d.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = ( this: V ) => T; - -/** -* Unary callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Unary = ( this: V, indices: [ number, number ] ) => T; - -/** -* Callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Two-dimensional nested array. -*/ -type Array2D = Array>; - -/** -* Returns a filled two-dimensional symmetric banded nested array according to a provided callback function. -* -* @param N - number of rows and columns -* @param k - number of super-/sub-diagonals -* @param fill - fill value for values outside the band -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns output array -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( 3, 1, 0, clbk ); -* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] -*/ -declare function filled2dBy( N: number, k: number, fill: U, clbk: Callback, thisArg?: ThisParameterType> ): Array2D; - - -// EXPORTS // - -export = filled2dBy; diff --git a/base/symmetric-banded/filled2d-by/docs/types/test.ts b/base/symmetric-banded/filled2d-by/docs/types/test.ts deleted file mode 100644 index d38577118..000000000 --- a/base/symmetric-banded/filled2d-by/docs/types/test.ts +++ /dev/null @@ -1,103 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import filled2dBy = require( './index' ); - -/** -* Callback function. -* -* @param indices - array element indices -* @returns return value -*/ -function clbk( indices: Array ): number { - return indices[ 1 ]; -} - - -// TESTS // - -// The function returns an array... -{ - filled2dBy( 5, 1, 0, clbk ); // $ExpectType Array2D - filled2dBy( 5, 1, 0, clbk, {} ); // $ExpectType Array2D - filled2dBy( 5, 1, null, clbk, {} ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a first argument which is not a number... -{ - filled2dBy( 'abc', 1, 0, clbk ); // $ExpectError - filled2dBy( true, 1, 0, clbk ); // $ExpectError - filled2dBy( false, 1, 0, clbk ); // $ExpectError - filled2dBy( null, 1, 0, clbk ); // $ExpectError - filled2dBy( [ '1', 1 ], 1, 0, clbk ); // $ExpectError - filled2dBy( {}, 1, 0, clbk ); // $ExpectError - filled2dBy( ( x: number ): number => x, 1, 0, clbk ); // $ExpectError - - filled2dBy( 'abc', 1, 0, clbk, {} ); // $ExpectError - filled2dBy( true, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( false, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( null, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( [ '1', 1 ], 1, 0, clbk, {} ); // $ExpectError - filled2dBy( {}, 1, 0, clbk, {} ); // $ExpectError - filled2dBy( ( x: number ): number => x, 1, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - filled2dBy( 5, 'abc', 0, clbk ); // $ExpectError - filled2dBy( 5, true, 0, clbk ); // $ExpectError - filled2dBy( 5, false, 0, clbk ); // $ExpectError - filled2dBy( 5, null, 0, clbk ); // $ExpectError - filled2dBy( 5, [ '1', 1 ], 0, clbk ); // $ExpectError - filled2dBy( 5, {}, 0, clbk ); // $ExpectError - filled2dBy( 5, ( x: number ): number => x, 0, clbk ); // $ExpectError - - filled2dBy( 5, 'abc', 0, clbk, {} ); // $ExpectError - filled2dBy( 5, true, 0, clbk, {} ); // $ExpectError - filled2dBy( 5, false, 0, clbk, {} ); // $ExpectError - filled2dBy( 5, null, 0, clbk, {} ); // $ExpectError - filled2dBy( 5, [ '1', 1 ], 0, clbk, {} ); // $ExpectError - filled2dBy( 5, {}, 0, clbk, {} ); // $ExpectError - filled2dBy( 5, ( x: number ): number => x, 0, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a callback... -{ - filled2dBy( 5, 1, 0, 'abc' ); // $ExpectError - filled2dBy( 5, 1, 0, true ); // $ExpectError - filled2dBy( 5, 1, 0, false ); // $ExpectError - filled2dBy( 5, 1, 0, null ); // $ExpectError - filled2dBy( 5, 1, 0, [] ); // $ExpectError - filled2dBy( 5, 1, 0, {} ); // $ExpectError - - filled2dBy( 5, 1, 0, 'abc', {} ); // $ExpectError - filled2dBy( 5, 1, 0, true, {} ); // $ExpectError - filled2dBy( 5, 1, 0, false, {} ); // $ExpectError - filled2dBy( 5, 1, 0, null, {} ); // $ExpectError - filled2dBy( 5, 1, 0, [], {} ); // $ExpectError - filled2dBy( 5, 1, 0, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled2dBy(); // $ExpectError - filled2dBy( 5 ); // $ExpectError - filled2dBy( 5, 1 ); // $ExpectError - filled2dBy( 5, 1, 0 ); // $ExpectError - filled2dBy( 5, 1, 0, clbk, 2, 2 ); // $ExpectError -} diff --git a/base/symmetric-banded/filled2d-by/examples/index.js b/base/symmetric-banded/filled2d-by/examples/index.js deleted file mode 100644 index 7ed2df0cf..000000000 --- a/base/symmetric-banded/filled2d-by/examples/index.js +++ /dev/null @@ -1,34 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( './../lib' ); - -function clbk( indices ) { - return indices[ 0 ] + indices[ 1 ]; -} - -var out = filled2dBy( 3, 1, 0, clbk ); -console.log( out ); -// => [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] - -out = filled2dBy( 3, 1, null, constantFunction( 'beep' ) ); -console.log( out ); -// => [ [ 'beep', 'beep', null ], [ 'beep', 'beep', 'beep' ], [ null, 'beep', 'beep' ] ] diff --git a/base/symmetric-banded/filled2d-by/lib/index.js b/base/symmetric-banded/filled2d-by/lib/index.js deleted file mode 100644 index d141329cb..000000000 --- a/base/symmetric-banded/filled2d-by/lib/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a filled two-dimensional symmetric banded nested array according to a provided callback function. -* -* @module @stdlib/array/base/symmetric-banded/filled2d-by -* -* @example -* var filled2dBy = require( '@stdlib/array/base/symmetric-banded/filled2d-by' ); -* -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( 3, 1, 0, clbk ); -* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] -* -* @example -* var filled2dBy = require( '@stdlib/array/base/symmetric-banded/filled2d-by' ); -* -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( 4, 1, 0, clbk ); -* // returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/symmetric-banded/filled2d-by/lib/main.js b/base/symmetric-banded/filled2d-by/lib/main.js deleted file mode 100644 index a8e2d396d..000000000 --- a/base/symmetric-banded/filled2d-by/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a filled two-dimensional symmetric banded nested array according to a provided callback function. -* -* @param {NonNegativeInteger} N - number of rows and columns -* @param {NonNegativeInteger} k - number of super-/sub-diagonals -* @param {*} fill - fill value for values outside the band -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback function execution context -* @returns {Array} filled array -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( 3, 1, 0, clbk ); -* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ] -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( 4, 1, 0, clbk ); -* // returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ] -*/ -function filled2dBy( N, k, fill, clbk, thisArg ) { - var arr; - var a0; - var i; - var j; - - // Manually push elements in order to ensure "fast" elements... - arr = []; - for ( i = 0; i < N; i++ ) { - a0 = []; - for ( j = 0; j < N; j++ ) { - // Check whether we are within the band in the upper triangle... - if ( j >= i && j <= i+k ) { - a0.push( clbk.call( thisArg, [ i, j ] ) ); - } - // Check whether we can take advantage of symmetry... - else if ( j < i ) { - a0.push( arr[ j ][ i ] ); - } - // Otherwise, we are outside the band in the upper triangle... - else { - a0.push( fill ); - } - } - arr.push( a0 ); - } - return arr; -} - - -// EXPORTS // - -module.exports = filled2dBy; diff --git a/base/symmetric-banded/filled2d-by/package.json b/base/symmetric-banded/filled2d-by/package.json deleted file mode 100644 index 22bbb49de..000000000 --- a/base/symmetric-banded/filled2d-by/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "@stdlib/array/base/symmetric-banded/filled2d-by", - "version": "0.0.0", - "description": "Create a filled two-dimensional symmetric banded nested array according to a provided callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "callback", - "map", - "foreach", - "multidimensional", - "matrix", - "strided", - "ndarray", - "2d", - "symmetric", - "banded", - "band" - ] -} diff --git a/base/symmetric-banded/filled2d-by/test/test.js b/base/symmetric-banded/filled2d-by/test/test.js deleted file mode 100644 index 2beacfc3b..000000000 --- a/base/symmetric-banded/filled2d-by/test/test.js +++ /dev/null @@ -1,122 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled2dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled symmetric banded nested array', function test( t ) { - var expected; - var actual; - - expected = [ [ 'beep', 'beep' ], [ 'beep', 'beep' ] ]; - actual = filled2dBy( 2, 1, null, constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ] ]; - actual = filled2dBy( 3, 2, -1, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0, 1, -1 ], [ 1, 2, 3 ], [ -1, 3, 4 ] ]; - actual = filled2dBy( 3, 1, -1, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0, -1, -1 ], [ -1, 2, -1 ], [ -1, -1, 4 ] ]; - actual = filled2dBy( 3, 0, -1, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( idx ) { - return idx[ 0 ] + idx[ 1 ]; - } -}); - -tape( 'the function returns an empty outer array if provided a first argument equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - actual = filled2dBy( 0, 1, null, constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - - ctx = { - 'count': 0 - }; - expected = [ [ 'beep', 'beep' ], [ 'beep', 'beep' ] ]; - actual = filled2dBy( 2, 1, null, clbk, ctx ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function clbk() { - this.count += 1; // eslint-disable-line no-invalid-this - return 'beep'; - } -}); - -tape( 'the function invokes a provided callback function with one argument', function test( t ) { - var expected; - var actual; - var idx; - - idx = []; - actual = filled2dBy( 3, 1, '', clbk ); - - expected = [ [ 'beep', 'beep', '' ], [ 'beep', 'beep', 'beep' ], [ '', 'beep', 'beep' ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 0 ], - [ 0, 1 ], - [ 1, 1 ], - [ 1, 2 ], - [ 2, 2 ] - ]; - t.deepEqual( idx, expected, 'returns expected value' ); - - t.end(); - - function clbk( indices ) { - idx.push( indices ); - return 'beep'; - } -}); diff --git a/base/symmetric-banded/lib/index.js b/base/symmetric-banded/lib/index.js deleted file mode 100644 index a4e17ffc2..000000000 --- a/base/symmetric-banded/lib/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name filled2dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/symmetric-banded/filled2d-by} -*/ -setReadOnly( ns, 'filled2dBy', require( './../../../base/symmetric-banded/filled2d-by' ) ); - -/** -* @name toCompact -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/symmetric-banded/to-compact} -*/ -setReadOnly( ns, 'toCompact', require( './../../../base/symmetric-banded/to-compact' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/base/symmetric-banded/package.json b/base/symmetric-banded/package.json deleted file mode 100644 index aea4b897f..000000000 --- a/base/symmetric-banded/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/symmetric-banded", - "version": "0.0.0", - "description": "Symmetric banded array utilities.", - "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/index.js", - "directories": { - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "array", - "symmetric", - "nested", - "utils", - "utilities", - "storage", - "banded", - "compact", - "matrix", - "namespace" - ] -} diff --git a/base/symmetric-banded/test/test.js b/base/symmetric-banded/test/test.js deleted file mode 100644 index d1e6eeb40..000000000 --- a/base/symmetric-banded/test/test.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'returns expected value' ); - t.end(); -}); diff --git a/base/symmetric-banded/to-compact/README.md b/base/symmetric-banded/to-compact/README.md deleted file mode 100644 index e689aa3cf..000000000 --- a/base/symmetric-banded/to-compact/README.md +++ /dev/null @@ -1,166 +0,0 @@ - - -# toCompact - -> Convert a two-dimensional symmetric banded nested array to compact banded storage. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var toCompact = require( '@stdlib/array/base/symmetric-banded/to-compact' ); -``` - -#### toCompact( uplo, arr, k, colexicographic ) - -Converts a two-dimensional symmetric banded nested array to compact banded storage. - -```javascript -var x = [ [ -1, 2, 0 ], [ 2, -2, 4 ], [ 0, 4, -3 ] ]; - -var out = toCompact( 'upper', x, 1, false ); -// returns [ [ 0, 2, 4 ], [ -1, -2, -3 ] ] -``` - -The function accepts the following arguments: - -- **uplo**: specifies whether to reference the upper or lower triangular part of the input array. -- **arr**: input two-dimensional nested array. -- **k**: number of super-/sub-diagonals. -- **colexicographic**: boolean specifying whether to store diagonals in colexicographic access order. - -
- - - - - -
- -
- - - - - -
- -## Examples - - - - - -```javascript -var toCompact = require( '@stdlib/array/base/symmetric-banded/to-compact' ); - -// Define a symmetric banded matrix: -var A = [ - [ 1, 2, 3, 0, 0 ], - [ 2, 4, 5, 6, 0 ], - [ 3, 5, 7, 8, 9 ], - [ 0, 6, 8, 10, 11 ], - [ 0, 0, 9, 11, 12 ] -]; - -// Convert the upper triangle to lexicographic compact form: -var AC = toCompact( 'upper', A, 2, false ); -/* e.g., returns => - [ - [ 0, 0, 3, 6, 9 ], - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ] - ] -*/ - -// Convert the lower triangle to lexicographic compact form: -AC = toCompact( 'lower', A, 2, false ); -/* e.g., returns => - [ - [ 1, 4, 7, 10, 12 ], - [ 2, 5, 8, 11, 0 ], - [ 3, 6, 9, 0, 0 ] - ] -*/ - -// Convert the upper triangle to colexicographic compact form: -AC = toCompact( 'upper', A, 2, true ); -/* e.g., returns => - [ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8, 9 ], - [ 10, 11, 0 ], - [ 12, 0, 0 ] - ] -*/ - -// Convert the lower triangle to colexicographic compact form: -AC = toCompact( 'lower', A, 2, true ); -/* e.g., returns => - [ - [ 0, 0, 1 ], - [ 0, 2, 4 ], - [ 3, 5, 7 ], - [ 6, 8, 10 ], - [ 9, 11, 12 ] - ] -*/ -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/symmetric-banded/to-compact/benchmark/benchmark.size.js b/base/symmetric-banded/to-compact/benchmark/benchmark.size.js deleted file mode 100644 index e0f6580c1..000000000 --- a/base/symmetric-banded/to-compact/benchmark/benchmark.size.js +++ /dev/null @@ -1,123 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( './../../../../base/symmetric-banded/filled2d-by' ); -var format = require( '@stdlib/string/format' ); -var pkg = require( './../package.json' ).name; -var toCompact = require( './../lib' ); - - -// VARIABLES // - -var orders = [ - true, - false -]; -var uplo = [ - 'upper', - 'lower' -]; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @param {string} uplo - specifies whether to reference to upper or lower triangle -* @param {boolean} colexicographic - boolean indicating whether to store diagonals in colexicographic access order -* @param {NonNegativeInteger} k - number of super-/sub-diagonals -* @returns {Function} benchmark function -*/ -function createBenchmark( N, uplo, colexicographic, k ) { - var x = filled2dBy( N, k, 0, constantFunction( N ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = toCompact( uplo, x, k, colexicographic ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - var o; - var u; - var k; - - min = 1; // 10^min - max = 6; // 10^max - - k = 2; - for ( u = 0; u < uplo.length; u++ ) { - for ( o = 0; o < orders.length; o++ ) { - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N, uplo[ u ], orders[ o ], k ); - bench( format( '%s:colexicographic=%s,uplo=%s,k=%d,size=%d', pkg, orders[ o ], uplo[ u ], k, N*N ), f ); - } - } - } -} - -main(); diff --git a/base/symmetric-banded/to-compact/docs/repl.txt b/base/symmetric-banded/to-compact/docs/repl.txt deleted file mode 100644 index 456a6a840..000000000 --- a/base/symmetric-banded/to-compact/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( uplo, arr, k, colexicographic ) - Converts a two-dimensional symmetric banded nested array to compact banded - storage. - - Parameters - ---------- - uplo: string - Specifies whether to reference to the upper or lower triangular part of - the input array. Must be either 'upper' or 'lower'. - - arr: Array - Input array. - - k: integer - Number of super-/sub-diagonals. - - colexicographic: boolean - Specifies whether to store diagonals in colexicographic access order. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ -1, 2, 0 ], [ 2, -3, 4 ], [ 0, 4, -5 ] ]; - > var out = {{alias}}( 'upper', x, 1, false ) - [ [ 0, 2, 4 ], [ -1, -3, -5 ] ] - - See Also - -------- - diff --git a/base/symmetric-banded/to-compact/docs/types/index.d.ts b/base/symmetric-banded/to-compact/docs/types/index.d.ts deleted file mode 100644 index ee3cfdabb..000000000 --- a/base/symmetric-banded/to-compact/docs/types/index.d.ts +++ /dev/null @@ -1,85 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; -import { MatrixTriangle } from '@stdlib/types/blas'; - -/** -* Two-dimensional nested array. -*/ -type Array2D = Array>; - -/** -* Converts a two-dimensional symmetric banded nested array to compact banded storage. -* -* @param uplo - specifies whether to reference the upper or lower triangular part of the input array -* @param arr - input two-dimensional array -* @param k - number of super-/sub-diagonals -* @param colexicographic - specifies whether to store diagonals in colexicographic access order -* @returns output array -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'upper', M, 1, false ); -* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ] ] -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'lower', M, 1, false ); -* // returns [ [ 11, 12, 13 ], [ 2, 4, 0 ] ] -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'upper', M, 1, true ); -* // returns [ [ 11, 2 ], [ 12, 4 ], [ 13, 0 ] ] -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'lower', M, 1, true ); -* // returns [ [ 0, 11 ], [ 2, 12 ], [ 4, 13 ] ] -*/ -declare function toCompact( uplo: MatrixTriangle, arr: Array2D, k: number, colexicographic: boolean ): Array2D; - - -// EXPORTS // - -export = toCompact; diff --git a/base/symmetric-banded/to-compact/docs/types/test.ts b/base/symmetric-banded/to-compact/docs/types/test.ts deleted file mode 100644 index a9e8daab7..000000000 --- a/base/symmetric-banded/to-compact/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import toCompact = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - const x = [ [ 1, 2 ], [ 2, 1 ] ]; - - toCompact( 'upper', x, 1, true ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided an invalid first argument... -{ - const x = [ [ 1, 2 ], [ 2, 1 ] ]; - - toCompact( 'abc', x, 1, true ); // $ExpectError - toCompact( true, x, 1, true ); // $ExpectError - toCompact( false, x, 1, true ); // $ExpectError - toCompact( null, x, 1, true ); // $ExpectError - toCompact( [], x, 1, true ); // $ExpectError - toCompact( {}, x, 1, true ); // $ExpectError - toCompact( ( x: number ): number => x, x, 1, true ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a nested array... -{ - toCompact( 'upper', 'abc', 1, true ); // $ExpectError - toCompact( 'upper', true, 1, true ); // $ExpectError - toCompact( 'upper', false, 1, true ); // $ExpectError - toCompact( 'upper', null, 1, true ); // $ExpectError - toCompact( 'upper', [ '1', 1 ], 1, true ); // $ExpectError - toCompact( 'upper', {}, 1, true ); // $ExpectError - toCompact( 'upper', ( x: number ): number => x, 1, true ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 2, 1 ] ]; - - toCompact( 'upper', x, 'abc', true ); // $ExpectError - toCompact( 'upper', x, true, true ); // $ExpectError - toCompact( 'upper', x, false, true ); // $ExpectError - toCompact( 'upper', x, null, true ); // $ExpectError - toCompact( 'upper', x, [ '1', 1 ], true ); // $ExpectError - toCompact( 'upper', x, {}, true ); // $ExpectError - toCompact( 'upper', x, ( x: number ): number => x, true ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a boolean... -{ - const x = [ [ 1, 2 ], [ 2, 1 ] ]; - - toCompact( 'upper', x, 1, 'abc' ); // $ExpectError - toCompact( 'upper', x, 1, 5 ); // $ExpectError - toCompact( 'upper', x, 1, null ); // $ExpectError - toCompact( 'upper', x, 1, [ '1', 1 ] ); // $ExpectError - toCompact( 'upper', x, 1, {} ); // $ExpectError - toCompact( 'upper', x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 2, 1 ] ]; - - toCompact(); // $ExpectError - toCompact( 'upper' ); // $ExpectError - toCompact( 'upper', x ); // $ExpectError - toCompact( 'upper', x, 1 ); // $ExpectError - toCompact( 'upper', x, 1, true, {} ); // $ExpectError -} diff --git a/base/symmetric-banded/to-compact/examples/index.js b/base/symmetric-banded/to-compact/examples/index.js deleted file mode 100644 index eae413859..000000000 --- a/base/symmetric-banded/to-compact/examples/index.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-multi-spaces */ - -'use strict'; - -var toCompact = require( './../lib' ); - -// Define a symmetric banded matrix: -var A = [ - [ 1, 2, 3, 0, 0 ], - [ 2, 4, 5, 6, 0 ], - [ 3, 5, 7, 8, 9 ], - [ 0, 6, 8, 10, 11 ], - [ 0, 0, 9, 11, 12 ] -]; - -// Convert the upper triangle to lexicographic compact form: -var AC = toCompact( 'upper', A, 2, false ); -console.log( AC ); -/* e.g., => - [ - [ 0, 0, 3, 6, 9 ], - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ] - ] -*/ - -// Convert the lower triangle to lexicographic compact form: -AC = toCompact( 'lower', A, 2, false ); -console.log( AC ); -/* e.g., => - [ - [ 1, 4, 7, 10, 12 ], - [ 2, 5, 8, 11, 0 ], - [ 3, 6, 9, 0, 0 ] - ] -*/ - -// Convert the upper triangle to colexicographic compact form: -AC = toCompact( 'upper', A, 2, true ); -console.log( AC ); -/* e.g., => - [ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8, 9 ], - [ 10, 11, 0 ], - [ 12, 0, 0 ] - ] -*/ - -// Convert the lower triangle to colexicographic compact form: -AC = toCompact( 'lower', A, 2, true ); -console.log( AC ); -/* e.g., => - [ - [ 0, 0, 1 ], - [ 0, 2, 4 ], - [ 3, 5, 7 ], - [ 6, 8, 10 ], - [ 9, 11, 12 ] - ] -*/ diff --git a/base/symmetric-banded/to-compact/lib/index.js b/base/symmetric-banded/to-compact/lib/index.js deleted file mode 100644 index d2619b7dc..000000000 --- a/base/symmetric-banded/to-compact/lib/index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert a two-dimensional symmetric banded nested array to compact banded storage. -* -* @module @stdlib/array/base/symmetric-banded/to-compact -* -* @example -* var toCompact = require( '@stdlib/array/base/symmetric-banded/to-compact' ); -* -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'upper', M, 1, false ); -* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ] ] -* -* @example -* var toCompact = require( '@stdlib/array/base/symmetric-banded/to-compact' ); -* -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'lower', M, 1, false ); -* // returns [ [ 11, 12, 13 ], [ 2, 4, 0 ] ] -* -* @example -* var toCompact = require( '@stdlib/array/base/symmetric-banded/to-compact' ); -* -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'upper', M, 1, true ); -* // returns [ [ 11, 2 ], [ 12, 4 ], [ 13, 0 ] ] -* -* @example -* var toCompact = require( '@stdlib/array/base/symmetric-banded/to-compact' ); -* -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'lower', M, 1, true ); -* // returns [ [ 0, 11 ], [ 2, 12 ], [ 4, 13 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/symmetric-banded/to-compact/lib/main.js b/base/symmetric-banded/to-compact/lib/main.js deleted file mode 100644 index d9ef69fb9..000000000 --- a/base/symmetric-banded/to-compact/lib/main.js +++ /dev/null @@ -1,139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var max = require( '@stdlib/math/base/special/fast/max' ); -var min = require( '@stdlib/math/base/special/fast/min' ); -var zeros2d = require( './../../../../base/zeros2d' ); - - -// MAIN // - -/** -* Converts a two-dimensional symmetric banded nested array to compact banded storage. -* -* @param {string} uplo - specifies whether to reference the upper or lower triangular part of the input array -* @param {Array} arr - input two-dimensional array -* @param {NonNegativeInteger} k - number of super-/sub-diagonals -* @param {boolean} colexicographic - specifies whether to store diagonals in colexicographic access order -* @returns {Array} output array -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'upper', M, 1, false ); -* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ] ] -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'lower', M, 1, false ); -* // returns [ [ 11, 12, 13 ], [ 2, 4, 0 ] ] -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'upper', M, 1, true ); -* // returns [ [ 11, 2 ], [ 12, 4 ], [ 13, 0 ] ] -* -* @example -* var M = [ -* [ 11, 2, 0 ], -* [ 2, 12, 4 ], -* [ 0, 4, 13 ] -* ]; -* -* var out = toCompact( 'lower', M, 1, true ); -* // returns [ [ 0, 11 ], [ 2, 12 ], [ 4, 13 ] ] -*/ -function toCompact( uplo, arr, k, colexicographic ) { - var out; - var to; - var ta; - var m; - var i; - var j; - var o; - - m = arr.length; - - // Check whether to store diagonals along the columns... - if ( colexicographic ) { - out = zeros2d( [ m, k+1 ] ); - if ( uplo === 'upper' ) { - for ( i = 0; i < m; i++ ) { - to = out[ i ]; - ta = arr[ i ]; - for ( j = i; j < min( m, i+k+1 ); j++ ) { - to[ j-i ] = ta[ j ]; - } - } - return out; - } - // uplo === 'lower' - for ( i = 0; i < m; i++ ) { - to = out[ i ]; - ta = arr[ i ]; - o = max( 0, k-i ); - for ( j = max( 0, i-k ); j <= i; j++ ) { - to[ o ] = ta[ j ]; - o += 1; - } - } - return out; - } - // Store diagonals along the rows... - out = zeros2d( [ k+1, m ] ); - if ( uplo === 'upper' ) { - for ( j = 0; j < m; j++ ) { - o = k - j; - for ( i = max( 0, j-k ); i <= j; i++ ) { - out[ o+i ][ j ] = arr[ i ][ j ]; - } - } - return out; - } - // uplo === 'lower' - for ( j = 0; j < m; j++ ) { - o = -j; - for ( i = j; i < min( m, j+k+1 ); i++ ) { - out[ o+i ][ j ] = arr[ i ][ j ]; - } - } - return out; -} - - -// EXPORTS // - -module.exports = toCompact; diff --git a/base/symmetric-banded/to-compact/package.json b/base/symmetric-banded/to-compact/package.json deleted file mode 100644 index 5cd8fef6c..000000000 --- a/base/symmetric-banded/to-compact/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/symmetric-banded/to-compact", - "version": "0.0.0", - "description": "Convert a two-dimensional symmetric banded nested array to compact banded storage.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "multidimensional", - "matrix", - "strided", - "ndarray", - "2d", - "symmetric", - "banded", - "band", - "compact", - "storage" - ] -} diff --git a/base/symmetric-banded/to-compact/test/test.js b/base/symmetric-banded/to-compact/test/test.js deleted file mode 100644 index 5f18e2dfe..000000000 --- a/base/symmetric-banded/to-compact/test/test.js +++ /dev/null @@ -1,201 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-multi-spaces */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toCompact = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof toCompact, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts a symmetric banded nested array to compact banded storage (uplo=upper, colexicographic=false)', function test( t ) { - var expected; - var actual; - var arr; - - arr = [ - [ 1, 2, 3, 0, 0 ], - [ 2, 4, 5, 6, 0 ], - [ 3, 5, 7, 8, 9 ], - [ 0, 6, 8, 10, 11 ], - [ 0, 0, 9, 11, 12 ] - ]; - - expected = [ - [ 0, 0, 3, 6, 9 ], - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ] - ]; - actual = toCompact( 'upper', arr, 2, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 1, 4, 7, 10, 12 ] - ]; - actual = toCompact( 'upper', arr, 0, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 2, 5, 8, 11 ], - [ 1, 4, 7, 10, 12 ] - ]; - actual = toCompact( 'upper', arr, 1, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts a symmetric banded nested array to compact banded storage (uplo=lower, colexicographic=false)', function test( t ) { - var expected; - var actual; - var arr; - - arr = [ - [ 1, 2, 3, 0, 0 ], - [ 2, 4, 5, 6, 0 ], - [ 3, 5, 7, 8, 9 ], - [ 0, 6, 8, 10, 11 ], - [ 0, 0, 9, 11, 12 ] - ]; - - expected = [ - [ 1, 4, 7, 10, 12 ], - [ 2, 5, 8, 11, 0 ], - [ 3, 6, 9, 0, 0 ] - ]; - actual = toCompact( 'lower', arr, 2, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 1, 4, 7, 10, 12 ] - ]; - actual = toCompact( 'lower', arr, 0, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 1, 4, 7, 10, 12 ], - [ 2, 5, 8, 11, 0 ] - ]; - actual = toCompact( 'lower', arr, 1, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts a symmetric banded nested array to compact banded storage (uplo=upper, colexicographic=true)', function test( t ) { - var expected; - var actual; - var arr; - - arr = [ - [ 1, 2, 3, 0, 0 ], - [ 2, 4, 5, 6, 0 ], - [ 3, 5, 7, 8, 9 ], - [ 0, 6, 8, 10, 11 ], - [ 0, 0, 9, 11, 12 ] - ]; - - expected = [ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8, 9 ], - [ 10, 11, 0 ], - [ 12, 0, 0 ] - ]; - actual = toCompact( 'upper', arr, 2, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 1 ], - [ 4 ], - [ 7 ], - [ 10 ], - [ 12 ] - ]; - actual = toCompact( 'upper', arr, 0, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 1, 2 ], - [ 4, 5 ], - [ 7, 8 ], - [ 10, 11 ], - [ 12, 0 ] - ]; - actual = toCompact( 'upper', arr, 1, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts a symmetric banded nested array to compact banded storage (uplo=lower, colexicographic=true)', function test( t ) { - var expected; - var actual; - var arr; - - arr = [ - [ 1, 2, 3, 0, 0 ], - [ 2, 4, 5, 6, 0 ], - [ 3, 5, 7, 8, 9 ], - [ 0, 6, 8, 10, 11 ], - [ 0, 0, 9, 11, 12 ] - ]; - - expected = [ - [ 0, 0, 1 ], - [ 0, 2, 4 ], - [ 3, 5, 7 ], - [ 6, 8, 10 ], - [ 9, 11, 12 ] - ]; - actual = toCompact( 'lower', arr, 2, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 1 ], - [ 4 ], - [ 7 ], - [ 10 ], - [ 12 ] - ]; - actual = toCompact( 'lower', arr, 0, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 1 ], - [ 2, 4 ], - [ 5, 7 ], - [ 8, 10 ], - [ 11, 12 ] - ]; - actual = toCompact( 'lower', arr, 1, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/symmetric/README.md b/base/symmetric/README.md deleted file mode 100644 index 26418f6c2..000000000 --- a/base/symmetric/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# Symmetric Arrays - -> Symmetric array utilities. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ns = require( '@stdlib/array/base/symmetric' ); -``` - -#### ns - -Namespace containing symmetric array utilities. - -```javascript -var o = ns; -// returns {...} -``` - -The namespace exports the following: - - - -
- -- [`filled2dBy( N, clbk[, thisArg] )`][@stdlib/array/base/symmetric/filled2d-by]: create a filled two-dimensional symmetric nested array according to a provided callback function. - -
- - - -
- - - - - -
- -
- - - - - -
- -## Examples - - - - - -```javascript -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( '@stdlib/array/base/symmetric' ); - -console.log( objectKeys( ns ) ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/symmetric/docs/types/index.d.ts b/base/symmetric/docs/types/index.d.ts deleted file mode 100644 index b7a61e1e7..000000000 --- a/base/symmetric/docs/types/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/* eslint-disable max-lines */ - -import filled2dBy = require( './../../../../base/symmetric/filled2d-by' ); - -/** -* Interface describing a namespace. -*/ -interface Namespace { - /** - * TODO - */ - filled2dBy: typeof filled2dBy; -} - -/** -* Symmetric array utilities. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/base/symmetric/docs/types/test.ts b/base/symmetric/docs/types/test.ts deleted file mode 100644 index 1a38cb7de..000000000 --- a/base/symmetric/docs/types/test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/base/symmetric/examples/index.js b/base/symmetric/examples/index.js deleted file mode 100644 index f5349d26c..000000000 --- a/base/symmetric/examples/index.js +++ /dev/null @@ -1,24 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/base/symmetric/filled2d-by/README.md b/base/symmetric/filled2d-by/README.md deleted file mode 100644 index 068ff7077..000000000 --- a/base/symmetric/filled2d-by/README.md +++ /dev/null @@ -1,160 +0,0 @@ - - -# filled2dBy - -> Create a filled two-dimensional symmetric nested array according to a provided callback function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filled2dBy = require( '@stdlib/array/base/symmetric/filled2d-by' ); -``` - -#### filled2dBy( N, clbk\[, thisArg] ) - -Returns a filled two-dimensional symmetric nested array according to a provided callback function. - -```javascript -function clbk( idx ) { - return idx[ 0 ] + idx[ 1 ]; -} - -var out = filled2dBy( 2, clbk ); -// returns [ [ 0, 1 ], [ 1, 2 ] ] -``` - -The function accepts the following arguments: - -- **N**: number of rows and columns. -- **clbk**: callback function. -- **thisArg**: callback function execution context (_optional_). - -When invoked, a callback function is provided a single argument: - -- **indices**: current array element indices. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function clbk() { - this.count += 1; - return 1; -} - -var ctx = { - 'count': 0 -}; - -var out = filled2dBy( 2, clbk, ctx ); -// returns [ [ 1, 1 ], [ 1, 1 ] ]; - -var cnt = ctx.count; -// returns 3 -``` - -
- - - - - -
- -## Notes - -- As the output array is symmetric, the callback function is only invoked for the elements residing in the upper triangle of the output array (i.e., `indices[1] >= indices[0]`). - -
- - - - - -
- -## Examples - - - -```javascript -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( '@stdlib/array/base/symmetric/filled2d-by' ); - -var out = filled2dBy( 2, constantFunction( 0.0 ) ); -// returns [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] - -out = filled2dBy( 2, constantFunction( 'beep' ) ); -// returns [ [ 'beep', 'beep' ], [ 'beep', 'beep' ] ] - -out = filled2dBy( 2, constantFunction( null ) ); -// returns [ [ null, null ], [ null, null ] ] - -out = filled2dBy( 2, constantFunction( true ) ); -// returns [ [ true, true ], [ true, true ] ] - -function clbk( indices ) { - return indices[ 0 ] + indices[ 1 ]; -} -out = filled2dBy( 3, clbk ); -// returns [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/symmetric/filled2d-by/benchmark/benchmark.size.js b/base/symmetric/filled2d-by/benchmark/benchmark.size.js deleted file mode 100644 index e5c00e04e..000000000 --- a/base/symmetric/filled2d-by/benchmark/benchmark.size.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filled2dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var f; - var i; - - f = constantFunction( N ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = filled2dBy( N, f ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+':size='+(N*N), f ); - } -} - -main(); diff --git a/base/symmetric/filled2d-by/docs/repl.txt b/base/symmetric/filled2d-by/docs/repl.txt deleted file mode 100644 index 54a3e868b..000000000 --- a/base/symmetric/filled2d-by/docs/repl.txt +++ /dev/null @@ -1,37 +0,0 @@ - -{{alias}}( N, clbk[, thisArg] ) - Returns a filled two-dimensional symmetric nested array according to a - provided callback function. - - The callback function is provided one argument: - - - indices: current array element indices. - - As the output array is symmetric, the provided callback is only invoked for - elements in the upper triangle (i.e., indices[1] >= indices[0]). - - Parameters - ---------- - N: integer - Number of rows and columns. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > function clbk( idx ) { return idx[ 0 ] + idx[ 1 ]; }; - > var out = {{alias}}( 2, clbk ) - [ [ 0, 1 ], [ 1, 2 ] ] - - See Also - -------- - diff --git a/base/symmetric/filled2d-by/docs/types/index.d.ts b/base/symmetric/filled2d-by/docs/types/index.d.ts deleted file mode 100644 index 8da10d72b..000000000 --- a/base/symmetric/filled2d-by/docs/types/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = ( this: V ) => T; - -/** -* Unary callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Unary = ( this: V, indices: [ number, number ] ) => T; - -/** -* Callback function. -* -* @param indices - current array element indices -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Two-dimensional nested array. -*/ -type Array2D = Array>; - -/** -* Returns a filled two-dimensional symmetric nested array according to a provided callback function. -* -* @param N - number of rows and columns -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns output array -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( 3, clbk ); -* // returns [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ] ] -*/ -declare function filled2dBy( N: number, clbk: Callback, thisArg?: ThisParameterType> ): Array2D; - - -// EXPORTS // - -export = filled2dBy; diff --git a/base/symmetric/filled2d-by/docs/types/test.ts b/base/symmetric/filled2d-by/docs/types/test.ts deleted file mode 100644 index a9144c7bc..000000000 --- a/base/symmetric/filled2d-by/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import filled2dBy = require( './index' ); - -/** -* Callback function. -* -* @param indices - array element indices -* @returns return value -*/ -function clbk( indices: Array ): number { - return indices[ 1 ]; -} - - -// TESTS // - -// The function returns an array... -{ - filled2dBy( 5, clbk ); // $ExpectType Array2D - filled2dBy( 5, clbk, {} ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a first argument which is not a number... -{ - filled2dBy( 'abc', clbk ); // $ExpectError - filled2dBy( true, clbk ); // $ExpectError - filled2dBy( false, clbk ); // $ExpectError - filled2dBy( null, clbk ); // $ExpectError - filled2dBy( [ '1', 1 ], clbk ); // $ExpectError - filled2dBy( {}, clbk ); // $ExpectError - filled2dBy( ( x: number ): number => x, clbk ); // $ExpectError - - filled2dBy( 'abc', clbk, {} ); // $ExpectError - filled2dBy( true, clbk, {} ); // $ExpectError - filled2dBy( false, clbk, {} ); // $ExpectError - filled2dBy( null, clbk, {} ); // $ExpectError - filled2dBy( [ '1', 1 ], clbk, {} ); // $ExpectError - filled2dBy( {}, clbk, {} ); // $ExpectError - filled2dBy( ( x: number ): number => x, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a callback... -{ - filled2dBy( 5, 'abc' ); // $ExpectError - filled2dBy( 5, true ); // $ExpectError - filled2dBy( 5, false ); // $ExpectError - filled2dBy( 5, null ); // $ExpectError - filled2dBy( 5, [] ); // $ExpectError - filled2dBy( 5, {} ); // $ExpectError - - filled2dBy( 5, 'abc', {} ); // $ExpectError - filled2dBy( 5, true, {} ); // $ExpectError - filled2dBy( 5, false, {} ); // $ExpectError - filled2dBy( 5, null, {} ); // $ExpectError - filled2dBy( 5, [], {} ); // $ExpectError - filled2dBy( 5, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - filled2dBy(); // $ExpectError - filled2dBy( 5 ); // $ExpectError - filled2dBy( 5, clbk, 2, 2 ); // $ExpectError -} diff --git a/base/symmetric/filled2d-by/examples/index.js b/base/symmetric/filled2d-by/examples/index.js deleted file mode 100644 index fadf52afa..000000000 --- a/base/symmetric/filled2d-by/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( './../lib' ); - -var out = filled2dBy( 2, constantFunction( 0.0 ) ); -console.log( out ); -// => [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] - -out = filled2dBy( 2, constantFunction( 'beep' ) ); -console.log( out ); -// => [ [ 'beep', 'beep' ], [ 'beep', 'beep' ] ] - -out = filled2dBy( 2, constantFunction( null ) ); -console.log( out ); -// => [ [ null, null ], [ null, null ] ] - -out = filled2dBy( 2, constantFunction( true ) ); -console.log( out ); -// => [ [ true, true ], [ true, true ] ] - -function clbk( indices ) { - return indices[ 0 ] + indices[ 1 ]; -} -out = filled2dBy( 3, clbk ); -console.log( out ); -// => [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ] ] diff --git a/base/symmetric/filled2d-by/lib/index.js b/base/symmetric/filled2d-by/lib/index.js deleted file mode 100644 index 3666a9101..000000000 --- a/base/symmetric/filled2d-by/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a filled two-dimensional symmetric nested array according to a provided callback function. -* -* @module @stdlib/array/base/symmetric/filled2d-by -* -* @example -* var filled2dBy = require( '@stdlib/array/base/symmetric/filled2d-by' ); -* -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( 3, clbk ); -* // returns [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/symmetric/filled2d-by/lib/main.js b/base/symmetric/filled2d-by/lib/main.js deleted file mode 100644 index 58ec683db..000000000 --- a/base/symmetric/filled2d-by/lib/main.js +++ /dev/null @@ -1,72 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a filled two-dimensional symmetric nested array according to a provided callback function. -* -* @param {NonNegativeInteger} N - number of rows and columns -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback function execution context -* @returns {Array} filled array -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( 3, clbk ); -* // returns [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ] ] -* -* @example -* function clbk( indices ) { -* return indices[ 0 ] + indices[ 1 ]; -* } -* -* var out = filled2dBy( 4, clbk ); -* // returns [ [ 0, 1, 2, 3 ], [ 1, 2, 3, 4 ], [ 2, 3, 4, 5 ], [ 3, 4, 5, 6 ] ] -*/ -function filled2dBy( N, clbk, thisArg ) { - var arr; - var a0; - var i; - var j; - - // Manually push elements in order to ensure "fast" elements... - arr = []; - for ( i = 0; i < N; i++ ) { - a0 = []; - for ( j = 0; j < N; j++ ) { - if ( i > j ) { - a0.push( arr[ j ][ i ] ); - } else { - a0.push( clbk.call( thisArg, [ i, j ] ) ); - } - } - arr.push( a0 ); - } - return arr; -} - - -// EXPORTS // - -module.exports = filled2dBy; diff --git a/base/symmetric/filled2d-by/package.json b/base/symmetric/filled2d-by/package.json deleted file mode 100644 index 88f7ea7f5..000000000 --- a/base/symmetric/filled2d-by/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/base/symmetric/filled2d-by", - "version": "0.0.0", - "description": "Create a filled two-dimensional symmetric nested array according to a provided callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "callback", - "map", - "foreach", - "multidimensional", - "matrix", - "strided", - "ndarray", - "2d", - "symmetric" - ] -} diff --git a/base/symmetric/filled2d-by/test/test.js b/base/symmetric/filled2d-by/test/test.js deleted file mode 100644 index 57cded949..000000000 --- a/base/symmetric/filled2d-by/test/test.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var filled2dBy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filled2dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled symmetric nested array', function test( t ) { - var expected; - var actual; - - expected = [ [ 'beep', 'beep' ], [ 'beep', 'beep' ] ]; - actual = filled2dBy( 2, constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ] ]; - actual = filled2dBy( 3, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function clbk( idx ) { - return idx[ 0 ] + idx[ 1 ]; - } -}); - -tape( 'the function returns an empty outer array if provided a first argument equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - actual = filled2dBy( 0, constantFunction( 'beep' ) ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctx; - - ctx = { - 'count': 0 - }; - expected = [ [ 'beep', 'beep' ], [ 'beep', 'beep' ] ]; - actual = filled2dBy( 2, clbk, ctx ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function clbk() { - this.count += 1; // eslint-disable-line no-invalid-this - return 'beep'; - } -}); - -tape( 'the function invokes a provided callback function with one argument', function test( t ) { - var expected; - var actual; - var idx; - - idx = []; - actual = filled2dBy( 3, clbk ); - - expected = [ [ 'beep', 'beep', 'beep' ], [ 'beep', 'beep', 'beep' ], [ 'beep', 'beep', 'beep' ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ 0, 0 ], - [ 0, 1 ], - [ 0, 2 ], - [ 1, 1 ], - [ 1, 2 ], - [ 2, 2 ] - ]; - t.deepEqual( idx, expected, 'returns expected value' ); - - t.end(); - - function clbk( indices ) { - idx.push( indices ); - return 'beep'; - } -}); diff --git a/base/symmetric/lib/index.js b/base/symmetric/lib/index.js deleted file mode 100644 index 2cd14dd86..000000000 --- a/base/symmetric/lib/index.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name filled2dBy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/base/symmetric/filled2d-by} -*/ -setReadOnly( ns, 'filled2dBy', require( './../../../base/symmetric/filled2d-by' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/base/symmetric/package.json b/base/symmetric/package.json deleted file mode 100644 index 3f99d3217..000000000 --- a/base/symmetric/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/symmetric", - "version": "0.0.0", - "description": "Symmetric array utilities.", - "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/index.js", - "directories": { - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "array", - "symmetric", - "nested", - "utils", - "utilities", - "storage", - "matrix", - "namespace" - ] -} diff --git a/base/symmetric/test/test.js b/base/symmetric/test/test.js deleted file mode 100644 index d1e6eeb40..000000000 --- a/base/symmetric/test/test.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'returns expected value' ); - t.end(); -}); diff --git a/base/take-indexed/README.md b/base/take-indexed/README.md deleted file mode 100644 index 90450f918..000000000 --- a/base/take-indexed/README.md +++ /dev/null @@ -1,113 +0,0 @@ - - -# takeIndexed - -> Take elements from an indexed array. - -
- -## Usage - -```javascript -var takeIndexed = require( '@stdlib/array/base/take-indexed' ); -``` - -#### takeIndexed( x, indices ) - -Takes elements from an indexed array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var y = takeIndexed( x, [ 1, 3 ] ); -// returns [ 2, 4 ] -``` - -If `indices` is an empty array, the function returns an empty array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var y = takeIndexed( x, [] ); -// returns [] -``` - -
- - - -
- -## Notes - -- The function does **not** perform bounds checking. If an index is less than zero or greater than the maximum index of `x`, the value of the corresponding element in the output array is undefined. -- An _indexed_ array-like object is a data structure in which one retrieves elements via integer indices using bracket `[]` notation (e.g., `Float64Array`, `Int32Array`, `Array`, etc). This is in contrast to an _accessor_ array-like object in which one retrieves elements using `get` and `set` methods (e.g., `Complex64Array` and `Complex128Array`). - -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( '@stdlib/array/base/linspace' ); -var takeIndexed = require( '@stdlib/array/base/take-indexed' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); - -// Take a random sample of elements from `x`: -var y = takeIndexed( x, indices ); - -console.log( x ); -console.log( indices ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/take-indexed/benchmark/benchmark.js b/base/take-indexed/benchmark/benchmark.js deleted file mode 100644 index 990efea00..000000000 --- a/base/take-indexed/benchmark/benchmark.js +++ /dev/null @@ -1,52 +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 bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var take = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = take( x, x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/take-indexed/benchmark/benchmark.length.js b/base/take-indexed/benchmark/benchmark.length.js deleted file mode 100644 index 6e25f2dd5..000000000 --- a/base/take-indexed/benchmark/benchmark.length.js +++ /dev/null @@ -1,99 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var take = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var idx = filledBy( len, discreteUniform( 0, 3 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x; - var v; - var i; - - x = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = take( x, idx ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/take-indexed/docs/repl.txt b/base/take-indexed/docs/repl.txt deleted file mode 100644 index bd3a17358..000000000 --- a/base/take-indexed/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( x, indices ) - Takes elements from an indexed array. - - If `indices` is an empty array, the function returns an empty array. - - The function does *not* perform bounds checking. If an index is less than - zero or greater than the maximum index of `x`, the value of the - corresponding element in the output array is undefined. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - indices: ArrayLikeObject - List of element indices. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 1, 3 ] ) - [ 2, 4 ] - - See Also - -------- - diff --git a/base/take-indexed/docs/types/index.d.ts b/base/take-indexed/docs/types/index.d.ts deleted file mode 100644 index c8a47d8ac..000000000 --- a/base/take-indexed/docs/types/index.d.ts +++ /dev/null @@ -1,47 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Takes elements from an indexed array. -* -* ## Notes -* -* - The function does **not** perform bounds checking. If an index is less than zero or greater than the maximum index of `x`, the value of the corresponding element in the output array is undefined. -* -* @param x - input array -* @param indices - list of element indices -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = take( x, [ 1, 3 ] ); -* // returns [ 2, 4 ] -*/ -declare function take( x: Collection, indices: Collection ): Array; - - -// EXPORTS // - -export = take; diff --git a/base/take-indexed/docs/types/test.ts b/base/take-indexed/docs/types/test.ts deleted file mode 100644 index cb81e6c68..000000000 --- a/base/take-indexed/docs/types/test.ts +++ /dev/null @@ -1,57 +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. -*/ - -import take = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - take( [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType number[] - take( [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType any[] - take( [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType number[] - take( [ '1', '2', '3', '4' ], [ 1, 3 ] ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - take( 1, [ 1, 3 ] ); // $ExpectError - take( true, [ 1, 3 ] ); // $ExpectError - take( false, [ 1, 3 ] ); // $ExpectError - take( null, [ 1, 3 ] ); // $ExpectError - take( void 0, [ 1, 3 ] ); // $ExpectError - take( {}, [ 1, 3 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - take( [], 1 ); // $ExpectError - take( [], true ); // $ExpectError - take( [], false ); // $ExpectError - take( [], null ); // $ExpectError - take( [], void 0 ); // $ExpectError - take( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - take(); // $ExpectError - take( [] ); // $ExpectError - take( [], [], [] ); // $ExpectError -} diff --git a/base/take-indexed/examples/index.js b/base/take-indexed/examples/index.js deleted file mode 100644 index 0ec09342a..000000000 --- a/base/take-indexed/examples/index.js +++ /dev/null @@ -1,38 +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'; - -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( './../../../base/linspace' ); -var take = require( './../lib' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); - -// Take a random sample of elements from `x`: -var y = take( x, indices ); - -console.log( x ); -console.log( indices ); -console.log( y ); diff --git a/base/take-indexed/lib/index.js b/base/take-indexed/lib/index.js deleted file mode 100644 index 4c23c78c3..000000000 --- a/base/take-indexed/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Take elements from an indexed array. -* -* @module @stdlib/array/base/take-indexed -* -* @example -* var take = require( '@stdlib/array/base/take-indexed' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 0, 0, 1, 1, 3, 3 ]; -* var y = take( x, indices ); -* // returns [ 1, 1, 2, 2, 4, 4 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/take-indexed/lib/main.js b/base/take-indexed/lib/main.js deleted file mode 100644 index ac7dcb1f7..000000000 --- a/base/take-indexed/lib/main.js +++ /dev/null @@ -1,51 +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'; - -// MAIN // - -/** -* Takes elements from an indexed array. -* -* @param {Collection} x - input array -* @param {NonNegativeIntegerArray} indices - list of indices -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var indices = [ 3, 1, 2, 0 ]; -* -* var y = take( x, indices ); -* // returns [ 4, 2, 3, 1 ] -*/ -function take( x, indices ) { - var out; - var i; - - out = []; - for ( i = 0; i < indices.length; i++ ) { - out.push( x[ indices[ i ] ] ); // use `Array#push` to ensure "fast" elements - } - return out; -} - - -// EXPORTS // - -module.exports = take; diff --git a/base/take-indexed/package.json b/base/take-indexed/package.json deleted file mode 100644 index d74288304..000000000 --- a/base/take-indexed/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/take-indexed", - "version": "0.0.0", - "description": "Take elements from an indexed array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index" - ] -} diff --git a/base/take-indexed/test/test.js b/base/take-indexed/test/test.js deleted file mode 100644 index 05ecd9548..000000000 --- a/base/take-indexed/test/test.js +++ /dev/null @@ -1,86 +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 take = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof take, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function takes elements from an array', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ 1, 3 ]; - actual = take( x, indices ); - expected = [ 2, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - actual = take( x, indices ); - expected = [ 2, 2, 4, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - actual = take( x, indices ); - expected = [ 4, 3, 2, 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = take( x, indices ); - expected = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not perform bounds checking', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ 4, 5, 1, 2 ]; - actual = take( x, indices ); - expected = [ void 0, void 0, 2, 3 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided a second argument which is empty', function test( t ) { - var x = [ 1, 2, 3, 4 ]; - t.deepEqual( take( x, [] ), [], 'returns expected value' ); - t.end(); -}); diff --git a/base/take-indexed2/README.md b/base/take-indexed2/README.md deleted file mode 100644 index 2b1592521..000000000 --- a/base/take-indexed2/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# takeIndexed2 - -> Take elements from two indexed arrays in a single pass. - -
- -## Usage - -```javascript -var takeIndexed2 = require( '@stdlib/array/base/take-indexed2' ); -``` - -#### takeIndexed2( x, y, indices ) - -Takes elements from two indexed arrays in a single pass. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var y = [ 5, 6, 7, 8 ]; - -var out = takeIndexed2( x, y, [ 1, 3 ] ); -// returns [ [ 2, 4 ], [ 6, 8 ] ] -``` - -If `indices` is an empty array, the function returns empty arrays. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var y = [ 5, 6, 7, 8 ]; - -var out = takeIndexed2( x, y, [] ); -// returns [ [], [] ] -``` - -
- - - -
- -## Notes - -- The function does **not** perform bounds checking. If an index is less than zero or greater than the maximum index of `x` or `y`, the value of the corresponding element in the respective output array is undefined. -- An _indexed_ array-like object is a data structure in which one retrieves elements via integer indices using bracket `[]` notation (e.g., `Float64Array`, `Int32Array`, `Array`, etc). This is in contrast to an _accessor_ array-like object in which one retrieves elements using `get` and `set` methods (e.g., `Complex64Array` and `Complex128Array`). - -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( '@stdlib/array/base/linspace' ); -var takeIndexed2 = require( '@stdlib/array/base/take-indexed2' ); - -// Generate linearly spaced arrays: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -var y = linspace( 100, 200, 11 ); -console.log( y ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); -console.log( indices ); - -// Take a random sample of elements from `x` and `y`: -var out = takeIndexed2( x, y, indices ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/take-indexed2/benchmark/benchmark.js b/base/take-indexed2/benchmark/benchmark.js deleted file mode 100644 index f13aa0269..000000000 --- a/base/take-indexed2/benchmark/benchmark.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var take2 = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = take2( x, x, x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/take-indexed2/benchmark/benchmark.length.js b/base/take-indexed2/benchmark/benchmark.length.js deleted file mode 100644 index 3b90abb6c..000000000 --- a/base/take-indexed2/benchmark/benchmark.length.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var take2 = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var idx = filledBy( len, discreteUniform( 0, 3 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x; - var v; - var i; - - x = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = take2( x, x, idx ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/take-indexed2/docs/repl.txt b/base/take-indexed2/docs/repl.txt deleted file mode 100644 index 540c0f4a4..000000000 --- a/base/take-indexed2/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( x, y, indices ) - Takes elements from two indexed arrays in a single pass. - - If `indices` is an empty array, the function returns empty arrays. - - The function does *not* perform bounds checking. If an index is less than - zero or greater than the maximum index of `x` or `y`, the value of the - corresponding element in the respective output array is undefined. - - Parameters - ---------- - x: ArrayLikeObject - First input array. - - y: ArrayLikeObject - Second input array. - - indices: ArrayLikeObject - List of element indices. - - Returns - ------- - out: Array - Output arrays. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = [ 5, 6, 7, 8 ]; - > var out = {{alias}}( x, y, [ 1, 3 ] ) - [ [ 2, 4 ], [ 6, 8 ] ] - - See Also - -------- - diff --git a/base/take-indexed2/docs/types/index.d.ts b/base/take-indexed2/docs/types/index.d.ts deleted file mode 100644 index b25eeeeca..000000000 --- a/base/take-indexed2/docs/types/index.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Takes elements from two indexed arrays in a single pass. -* -* ## Notes -* -* - The function does **not** perform bounds checking. If an index is less than zero or greater than the maximum index of `x` or `y`, the value of the corresponding element in the respective output array is undefined. -* -* @param x - first input array -* @param y - second input array -* @param indices - list of element indices -* @returns output arrays -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var indices = [ 3, 1, 2, 0 ]; -* -* var out = take2( x, y, indices ); -* // returns [ [ 4, 2, 3, 1 ], [ 8, 6, 7, 5 ] ] -*/ -declare function take2( x: Collection, y: Collection, indices: Collection ): [ Array, Array ]; - - -// EXPORTS // - -export = take2; diff --git a/base/take-indexed2/docs/types/test.ts b/base/take-indexed2/docs/types/test.ts deleted file mode 100644 index 7e41a191b..000000000 --- a/base/take-indexed2/docs/types/test.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import take2 = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - take2( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType [number[], number[]] - take2( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType [any[], any[]] - take2( [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType [number[], number[]] - take2( [ '1', '2', '3', '4' ], [ '1', '2', '3', '4' ], [ 1, 3 ] ); // $ExpectType [string[], string[]] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - take2( 1, [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectError - take2( true, [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectError - take2( false, [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectError - take2( null, [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectError - take2( void 0, [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectError - take2( {}, [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - take2( [ 1, 2, 3, 4 ], 1, [ 1, 3 ] ); // $ExpectError - take2( [ 1, 2, 3, 4 ], true, [ 1, 3 ] ); // $ExpectError - take2( [ 1, 2, 3, 4 ], false, [ 1, 3 ] ); // $ExpectError - take2( [ 1, 2, 3, 4 ], null, [ 1, 3 ] ); // $ExpectError - take2( [ 1, 2, 3, 4 ], void 0, [ 1, 3 ] ); // $ExpectError - take2( [ 1, 2, 3, 4 ], {}, [ 1, 3 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - take2( [], [], 1 ); // $ExpectError - take2( [], [], true ); // $ExpectError - take2( [], [], false ); // $ExpectError - take2( [], [], null ); // $ExpectError - take2( [], [], void 0 ); // $ExpectError - take2( [], [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - take2(); // $ExpectError - take2( [] ); // $ExpectError - take2( [], [] ); // $ExpectError - take2( [], [], [], [] ); // $ExpectError -} diff --git a/base/take-indexed2/examples/index.js b/base/take-indexed2/examples/index.js deleted file mode 100644 index b48d816b5..000000000 --- a/base/take-indexed2/examples/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( './../../../base/linspace' ); -var take2 = require( './../lib' ); - -// Generate linearly spaced arrays: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -var y = linspace( 100, 200, 11 ); -console.log( y ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); -console.log( indices ); - -// Take a random sample of elements from `x` and `y`: -var out = take2( x, y, indices ); -console.log( out ); diff --git a/base/take-indexed2/lib/index.js b/base/take-indexed2/lib/index.js deleted file mode 100644 index 4abb5e96c..000000000 --- a/base/take-indexed2/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Take elements from two indexed arrays in a single pass. -* -* @module @stdlib/array/base/take-indexed2 -* -* @example -* var take2 = require( '@stdlib/array/base/take-indexed2' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var indices = [ 3, 1, 2, 0 ]; -* -* var out = take2( x, y, indices ); -* // returns [ [ 4, 2, 3, 1 ], [ 8, 6, 7, 5 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/take-indexed2/lib/main.js b/base/take-indexed2/lib/main.js deleted file mode 100644 index 5fb5b2121..000000000 --- a/base/take-indexed2/lib/main.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Takes elements from two indexed arrays in a single pass. -* -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @param {NonNegativeIntegerArray} indices - list of indices -* @returns {Array} output arrays -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* var indices = [ 3, 1, 2, 0 ]; -* -* var out = take2( x, y, indices ); -* // returns [ [ 4, 2, 3, 1 ], [ 8, 6, 7, 5 ] ] -*/ -function take2( x, y, indices ) { - var o1; - var o2; - var i; - - o1 = []; - o2 = []; - for ( i = 0; i < indices.length; i++ ) { - o1.push( x[ indices[ i ] ] ); // use `Array#push` to ensure "fast" elements - o2.push( y[ indices[ i ] ] ); - } - return [ o1, o2 ]; -} - - -// EXPORTS // - -module.exports = take2; diff --git a/base/take-indexed2/package.json b/base/take-indexed2/package.json deleted file mode 100644 index 1cd899570..000000000 --- a/base/take-indexed2/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/take-indexed2", - "version": "0.0.0", - "description": "Take elements from two indexed arrays in a single pass.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index" - ] -} diff --git a/base/take-indexed2/test/test.js b/base/take-indexed2/test/test.js deleted file mode 100644 index 6502bb07f..000000000 --- a/base/take-indexed2/test/test.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var take2 = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof take2, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function takes elements from two arrays', function test( t ) { - var expected; - var indices; - var actual; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = [ 5, 6, 7, 8 ]; - - indices = [ 1, 3 ]; - actual = take2( x, y, indices ); - expected = [ - [ 2, 4 ], - [ 6, 8 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - actual = take2( x, y, indices ); - expected = [ - [ 2, 2, 4, 4 ], - [ 6, 6, 8, 8 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - actual = take2( x, y, indices ); - expected = [ - [ 4, 3, 2, 1 ], - [ 8, 7, 6, 5 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = take2( x, y, indices ); - expected = [ - [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ], - [ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not perform bounds checking', function test( t ) { - var expected; - var indices; - var actual; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = [ 5, 6, 7, 8 ]; - - indices = [ 4, 5, 1, 2 ]; - actual = take2( x, y, indices ); - expected = [ - [ void 0, void 0, 2, 3 ], - [ void 0, void 0, 6, 7 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided a third argument which is empty', function test( t ) { - var x = [ 1, 2, 3, 4 ]; - t.deepEqual( take2( x, x, [] ), [ [], [] ], 'returns expected value' ); - t.end(); -}); diff --git a/base/take-map/README.md b/base/take-map/README.md deleted file mode 100644 index 441c79be0..000000000 --- a/base/take-map/README.md +++ /dev/null @@ -1,147 +0,0 @@ - - -# takeMap - -> Take elements from an array and return a new array after applying a mapping function. - -
- -## Usage - -```javascript -var takeMap = require( '@stdlib/array/base/take-map' ); -``` - -### takeMap( x, indices, mode, clbk ) - -Takes elements from an array and returns a new array after applying a mapping function. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -function customMapping( value ) { - return value * 2; -} - -var y = takeMap( x, [ 1, 3 ], 'throw', customMapping ); -// returns [ 4, 8 ] -``` - -The function supports the following parameters: - -- **x**: input array. -- **indices**: list of indices. -- **mode**: index [mode][@stdlib/ndarray/base/ind]. -- **clbk**: function to apply. - -### takeMap.assign( x, indices, mode, out, stride, offset, clbk ) - -> Takes elements from an array and assigns the values to elements in a provided output array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = [ 0, 0, 0, 0, 0, 0 ]; -var indices = [ 0, 0, 1, 1, 3, 3 ]; - -function clbk( val ) { - return val * 2; -} - -var arr = takeMap.assign( x, indices, 'throw', out, -1, out.length-1, clbk ); -// returns [ 8, 8, 4, 4, 2, 2 ] - -var bool = ( arr === out ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **indices**: list of indices. -- **mode**: index [mode][@stdlib/ndarray/base/ind]. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. -- **clbk**: callback function. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( '@stdlib/array/base/linspace' ); -var takeMap = require( '@stdlib/array/base/take-map' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); -console.log( indices ); - -// Define a mapping function (e.g., square the value): -function square( val ) { - return val * val; -} - -// Take a random sample of elements from `x` and apply the mapping function: -var y = takeMap( x, indices, 'throw', square ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/take-map/benchmark/benchmark.assign.length.js b/base/take-map/benchmark/benchmark.assign.length.js deleted file mode 100644 index 807b8a5f8..000000000 --- a/base/take-map/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,109 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeros = require( './../../../zeros' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var takeMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out; - var idx; - - idx = discreteUniform( len, 0, 3, { - 'dtype': 'generic' - }); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x; - var v; - var i; - - x = [ 1, 2, 3, 4 ]; - function clbk( val ) { - return val; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = takeMap.assign( x, idx, 'throw', out, 1, 0, clbk ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/take-map/benchmark/benchmark.js b/base/take-map/benchmark/benchmark.js deleted file mode 100644 index b5ebc0125..000000000 --- a/base/take-map/benchmark/benchmark.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var takeMap = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 100 ); - - function clbk( val ) { - return val; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = takeMap( x, x, 'throw', clbk ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/take-map/benchmark/benchmark.length.js b/base/take-map/benchmark/benchmark.length.js deleted file mode 100644 index df46e8bd4..000000000 --- a/base/take-map/benchmark/benchmark.length.js +++ /dev/null @@ -1,102 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var takeMap = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var idx = discreteUniform( len, 0, 3 ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x; - var v; - var i; - - x = [ 1, 2, 3, 4 ]; - - function clbk( val ) { - return val; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = takeMap( x, idx, 'throw', clbk ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/take-map/docs/repl.txt b/base/take-map/docs/repl.txt deleted file mode 100644 index 50ca76703..000000000 --- a/base/take-map/docs/repl.txt +++ /dev/null @@ -1,89 +0,0 @@ - -{{alias}}( x, indices, mode, callback ) - Takes elements from an array and returns a new array after applying a - mapping function. - - If `indices` is an empty array, the function returns an empty array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - indices: ArrayLikeObject - List of element indices. - - mode: string - Specifies how to handle an index outside the interval [0, max], where - `max` is the maximum possible array index. If equal to 'throw', the - function throws an error. If equal to 'normalize', the function throws - an error if provided an out-of-bounds normalized index. If equal to - 'wrap', the function wraps around an index using modulo arithmetic. If - equal to 'clamp', the function sets an index to either 0 (minimum index) - or the maximum index. - - callback : function - Map function to apply to selected elements of `x`. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var y = {{alias}}( x, [ 1, 3 ], 'throw', {{alias:@stdlib/math/base/special/abs}} ) - [ 2, 4 ] - - -{{alias}}.assign( x, indices, mode, out, stride, offset, callback ) - Takes elements from an array, applies a mapping function, and assigns the - values to elements in a provided output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - indices: ArrayLikeObject - List of element indices. - - mode: string - Specifies how to handle an index outside the interval [0, max], where - `max` is the maximum possible array index. If equal to 'throw', the - function throws an error. If equal to 'normalize', the function throws - an error if provided an out-of-bounds normalized index. If equal to - 'wrap', the function wraps around an index using modulo arithmetic. If - equal to 'clamp', the function sets an index to either 0 (minimum index) - or the maximum index. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - callback : function - Map function to apply to selected elements of `x`. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ -1, -2, -3, -4 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ,{{alias:@stdlib/math/base/special/abs}} ) - [ 2, 0, 4, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/base/take-map/docs/types/index.d.ts b/base/take-map/docs/types/index.d.ts deleted file mode 100644 index 083df93b5..000000000 --- a/base/take-map/docs/types/index.d.ts +++ /dev/null @@ -1,206 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; -import { Mode } from '@stdlib/types/ndarray'; - -/** -* Index array. -*/ -type IndexArray = Collection | AccessorArrayLike; - -/** -* Callback function invoked for each indexed element. -*/ -type Callback = ( value: T, index: number ) => U; - -/** -* Interface describing `takeMap`. -*/ -interface TakeMap { - /** - * Takes elements from an array based on an index array and applies a callback function to each element. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param clbk - callback function - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * function transform( v ) { - * return v * 2; - * } - * - * var y = takeMap( x, [ 1, 3 ], 'throw', transform ); - * // returns [ 4, 8 ] - */ - ( x: Collection, indices: IndexArray, mode: Mode, clbk: Callback ): Array; - - /** - * Takes elements from an array based on an index array and applies a callback function to each element. The function assigns the transformed values to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param clbk - callback function - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - * - * function transform( v ) { - * return v * 2; - * } - * - * var arr = takeMap.assign( x, [ 1, 3 ], 'throw', transform, out, 2, 0 ); - * // returns [ 4.0, 0.0, 8.0, 0.0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, clbk: Callback, out: Collection, stride: number, offset: number ): Collection; - - /** - * Takes elements from an array based on an index array and applies a callback function to each element. The function assigns the transformed values to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param clbk - callback function - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Float32Array = require( './../../../../float32' ); - * - * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * var out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - * - * function transform( v ) { - * return v * 2; - * } - * - * var arr = takeMap.assign( x, [ 1, 3 ], 'throw', transform, out, 2, 0 ); - * // returns [ 4.0, 0.0, 8.0, 0.0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, clbk: Callback, out: AccessorArrayLike, stride: number, offset: number ): AccessorArrayLike; - - /** - * Takes elements from an array based on an index array and applies a callback function to each element. The function assigns the transformed values to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param clbk - callback function - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Complex128Array = require( './../../../../float64' ); - * - * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - * var out = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - * - * function transform( v ) { - * return v * 2; - * } - * - * var arr = takeMap.assign( x, [ 1, 3 ], 'throw', transform, out, 2, 0 ); - * // returns [ 4.0, 0.0, 8.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, clbk: Callback, out: Collection, stride: number, offset: number ): Collection; -} - -/** -* Takes elements from an array based on an index array and applies a callback function to each element. -* -* @param x - input array -* @param indices - list of element indices -* @param mode - index mode -* @param clbk - callback function -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function transform( v ) { -* return v * 2; -* } -* -* var y = takeMap( x, [ 1, 3 ], 'throw', transform ); -* // returns [ 4, 8 ] -*/ -declare function takeMap( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, clbk: Callback ): Collection; - -/** -* Takes elements from an array based on an index array and applies a callback function to each element. The function assigns the transformed values to elements in a provided output array. -* -* @param x - input array -* @param indices - list of element indices -* @param mode - index mode -* @param clbk - callback function -* @param out - output array -* @param stride - output array stride -* @param offset - output array offset -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); -* -* function transform( v ) { -* return v * 2; -* } -* -* var arr = takeMap.assign( x, [ 1, 3 ], 'throw', transform, out, 2, 0 ); -* // returns [ 4.0, 0.0, 8.0, 0.0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare function takeMapAssign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, clbk: Callback, out: Collection, stride: number, offset: number ): Collection; - - -// EXPORTS // - -export = takeMap; diff --git a/base/take-map/docs/types/test.ts b/base/take-map/docs/types/test.ts deleted file mode 100644 index 2eaef25ff..000000000 --- a/base/take-map/docs/types/test.ts +++ /dev/null @@ -1,85 +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. -*/ - -import takeMap = require( './index' ); - -// TESTS // - -// The function returns an array... -{ - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type - const transform = ( v: number ) => v * 2; - - takeMap( [ 1, 2, 3, 4 ], [ 1, 3 ], 'throw', transform ); // $ExpectType number[] - takeMap( [ 1, 2, 3, 4 ], [ 1, 3 ], 'normalize', transform ); // $ExpectType any[] - takeMap( [ 1, 2, 3, 4 ], [ 1, 3 ], 'clamp', transform ); // $ExpectType number[] - takeMap( [ '1', '2', '3', '4' ], [ 1, 3 ], 'wrap', transform ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type - const transform = ( v: number ) => v * 2; - - takeMap( 1, [ 1, 3 ], 'throw', transform ); // $ExpectError - takeMap( true, [ 1, 3 ], 'throw', transform ); // $ExpectError - takeMap( false, [ 1, 3 ], 'throw', transform ); // $ExpectError - takeMap( null, [ 1, 3 ], 'throw', transform ); // $ExpectError - takeMap( void 0, [ 1, 3 ], 'throw', transform ); // $ExpectError - takeMap( {}, [ 1, 3 ], 'throw', transform ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type - const transform = ( v: number ) => v * 2; - - takeMap( [], 1, 'throw', transform ); // $ExpectError - takeMap( [], true, 'throw', transform ); // $ExpectError - takeMap( [], false, 'throw', transform ); // $ExpectError - takeMap( [], null, 'throw', transform ); // $ExpectError - takeMap( [], void 0, 'throw', transform ); // $ExpectError - takeMap( [], {}, 'throw', transform ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid index mode... -{ - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type - const transform = ( v: number ) => v * 2; - - takeMap( [], [ 1, 3 ], '1', transform ); // $ExpectError - takeMap( [], [ 1, 3 ], 1, transform ); // $ExpectError - takeMap( [], [ 1, 3 ], true, transform ); // $ExpectError - takeMap( [], [ 1, 3 ], false, transform ); // $ExpectError - takeMap( [], [ 1, 3 ], null, transform ); // $ExpectError - takeMap( [], [ 1, 3 ], void 0, transform ); // $ExpectError - takeMap( [], [ 1, 3 ], {}, transform ); // $ExpectError - takeMap( [], [ 1, 3 ], [], transform ); // $ExpectError - takeMap( [], [ 1, 3 ], ( x: number ): number => x, transform ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type - const transform = ( v: number ) => v * 2; - - takeMap(); // $ExpectError - takeMap( [], [] ); // $ExpectError - takeMap( [], [], 'throw' ); // $ExpectError - takeMap( [], [], 'throw', transform, {} ); // $ExpectError -} diff --git a/base/take-map/examples/index.js b/base/take-map/examples/index.js deleted file mode 100644 index 61ae90291..000000000 --- a/base/take-map/examples/index.js +++ /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. -*/ - -'use strict'; - -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( './../../../base/linspace' ); -var takeMap = require( './../lib' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); -console.log( indices ); - -// Define a mapping function (e.g., square the value): -function square( val ) { - return val * val; -} - -// Take a random sample of elements from `x` and apply the mapping function: -var y = takeMap( x, indices, 'throw', square ); -console.log( y ); diff --git a/base/take-map/lib/assign.js b/base/take-map/lib/assign.js deleted file mode 100644 index e84f6cb80..000000000 --- a/base/take-map/lib/assign.js +++ /dev/null @@ -1,277 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); -var ind = require( '@stdlib/ndarray/base/ind' ).factory; - - -// FUNCTIONS // - -/** -* Takes elements from an indexed array and assigns the values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array. -* @param {IntegerArray} indices - list of indices. -* @param {string} mode - index mode. -* @param {Collection} out - output array. -* @param {integer} stride - output array stride. -* @param {NonNegativeInteger} offset - output array offset. -* @param {Function} clbk - callback function applied to each selected element. -* @returns {Collection} output array. -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var indices = [ 3, 1, 2, 0 ]; -* var out = [ 0, 0, 0, 0 ]; -* -* function clbk( val ){ -* return val; -* } -* -* var arr = takeMapIndexed( x, indices, 'throw', out, 1, 0, clbk ); -* // returns [ 4, 2, 3, 1 ] -*/ -function takeMapIndexed( x, indices, mode, out, stride, offset, clbk ) { - var getIndex; - var max; - var io; - var i; - var j; - - // Resolve a function for returning an index according to the specified index mode: - getIndex = ind( mode ); - - // Resolve the maximum index: - max = x.length - 1; - - // Extract each desired element from the provided array... - io = offset; - for ( i = 0; i < indices.length; i++ ) { - j = getIndex( indices[ i ], max ); - out[ io ] = x[ j ]; - io += stride; - } - for ( i = 0; i < out.length; i++ ) { - // eslint-disable-next-line no-useless-call - out[i] = clbk.call( null, out[i], i ); - } - return out; -} - -/** -* Takes elements from an accessor array and assigns the values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object. -* @param {Object} indices - index array object. -* @param {string} mode - index mode. -* @param {Object} out - output array object. -* @param {integer} stride - output array stride. -* @param {NonNegativeInteger} offset - Output array offset. -* @param {Function} clbk - callback function applied to each selected element. -* @returns {Collection} output array. -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var indices = toAccessorArray( [ 3, 1, 2, 0 ] ); -* -* function clbk(val){ - return val+1; -} -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessorsMap( arraylike2object( x ), arraylike2object( indices ), 'throw', arraylike2object( out ), 1, 0, clbk ); -* // [ 4, 2, 3, 1 ] -*/ -function accessorsMap( x, indices, mode, out, stride, offset, clbk ) { - var getIndex; - var xdata; - var idata; - var odata; - var xget; - var iget; - var oset; - var max; - var io; - var i; - var j; - - xdata = x.data; - idata = indices.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - iget = indices.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - // Resolve a function for returning an index according to the specified index mode: - getIndex = ind( mode ); - - // Resolve the maximum index: - max = xdata.length - 1; - - // Extract each desired element from the provided array... - io = offset; - for ( i = 0; i < idata.length; i++ ) { - j = getIndex( iget( idata, i ), max ); - - // eslint-disable-next-line no-useless-call - oset( odata, io, clbk.call( null, xget( xdata, j ), j ) ); - io += stride; - } - return odata; -} - -/** -* Takes elements from a complex array and assigns the values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} indices - index array object -* @param {string} mode - index mode -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @param {Function} clbk - callback function applied to each selected element -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* var indices = [ 0, 0, 1, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* function clbk(val){ - return val; -} -* -* var arr = complexMap( x, arraylike2object( indices ), 'throw', out, 1, 0, clbk ); -* // returns [ 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ] -*/ -function complexMap( x, indices, mode, out, stride, offset, clbk ) { - var getIndex; - var idata; - var iget; - var max; - var io; - var so; - var i; - var j; - var k; - - idata = indices.data; - iget = indices.accessors[ 0 ]; - - // Resolve a function for returning an index according to the specified index mode: - getIndex = ind( mode ); - - // Resolve the maximum index: - max = ( x.length/2 ) - 1; // resolve the length of the original complex array - - // Extract each desired element from the provided array... - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < idata.length; i++ ) { - j = getIndex( iget( idata, i ), max ); - k = j * 2; - - // eslint-disable-next-line no-useless-call - out[ io ] = clbk.call( null, x[ k ], k ); - - // eslint-disable-next-line no-useless-call - out[ io+1 ] = clbk.call( null, x[ k+1 ], k+1 ); - io += so; - } - return out; -} - - -// MAIN // - -/** -* Takes elements from an array and assigns the values to elements in a provided output array. -* -* @param {Collection} x - input array. -* @param {IntegerArray} indices - list of indices. -* @param {string} mode - index mode. -* @param {Collection} out - output array. -* @param {integer} stride - output array stride. -* @param {NonNegativeInteger} offset - output array offset. -* @param {Function} clbk - callback function applied to each selected element. -* @returns {Collection} output array. -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var indices = [ 3, 1, 2, 0 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* function clbk( val ){ - return val; -} -* var arr = assignMap( x, indices, 'throw', out, 1, 0, clbk ); -* // arr is [ 4, 2, 3, 1 ] -* -* var bool = ( arr === out ); -* // bool is true -*/ -function assignMap( x, indices, mode, out, stride, offset, clbk ) { - var xo; - var io; - var oo; - - xo = arraylike2object( x ); - io = arraylike2object( indices ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - io.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support complex-to-complex, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complexMap( reinterpret( x, 0 ), io, mode, reinterpret( out, 0 ), stride, offset, clbk ); // eslint-disable-line max-len - return out; - } - accessorsMap( xo, io, mode, oo, stride, offset, clbk ); - return out; - } - takeMapIndexed( x, indices, mode, out, stride, offset, clbk ); - return out; -} - - -// EXPORTS // - -module.exports = assignMap; diff --git a/base/take-map/lib/index.js b/base/take-map/lib/index.js deleted file mode 100644 index 43784039d..000000000 --- a/base/take-map/lib/index.js +++ /dev/null @@ -1,72 +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. -*/ - -'use strict'; - -/** -* Take elements from an array and apply a provided function to map values. -* -* @module @stdlib/array/base/take-map -* -* @example -* var takeMap = require( '@stdlib/array/base/take-map' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* function mapFunction( val ) { -* return val; -* } -* -* var indices = [ 0, 0, 1, 1, 3, 3 ]; -* var y = takeMap( x, indices, 'throw', mapFunction ); -* // returns [ 1, 1, 2, 2, 4, 4 ] -* -* @example -* var takeMap = require( '@stdlib/array/base/take-map' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* var indices = [ 0, 0, 1, 1, 3, 3 ]; -* -* function clbk( val ) { -* return val; -* } -* -* var arr = takeMap.assign( x, indices, 'throw', out, 1, 0, mapFunction ); -* // returns [ 1, 1, 2, 2, 4, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/take-map/lib/main.js b/base/take-map/lib/main.js deleted file mode 100644 index 969bb7934..000000000 --- a/base/take-map/lib/main.js +++ /dev/null @@ -1,82 +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. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); -var ind = require( '@stdlib/ndarray/base/ind' ).factory; - - -// MAIN // - -/** -* Takes elements from an array, applies a mapping function using a callback, and returns a new array. -* -* @param {Collection} x - input array -* @param {IntegerArray} indices - list of indices -* @param {string} mode - index mode -* @param {Function} clbk - callback to invoke -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var indices = [ 3, 1, 2, 0 ]; -* -* function clbk(val){ - return 2 * val; -} -* -* var y = takeMap( x, indices, 'throw' ,clbk ); -* // returns [ 8, 4, 6, 2 ] -*/ -function takeMap( x, indices, mode, clbk ) { - var getIndex; - var xget; - var iget; - var out; - var max; - var i; - var j; - - // Resolve an accessor for retrieving array elements: - xget = resolveGetter( x ); - iget = resolveGetter( indices ); - - // Resolve a function for returning an index according to the specified index mode: - getIndex = ind( mode ); - - // Resolve the maximum index: - max = x.length - 1; - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < indices.length; i++ ) { - j = getIndex( iget( indices, i ), max ); - - // eslint-disable-next-line no-useless-call - out.push( clbk.call( null, xget( x, j ), j ) ); // use `Array#push` to ensure "fast" elements - } - return out; -} - - -// EXPORTS // - -module.exports = takeMap; diff --git a/base/take-map/package.json b/base/take-map/package.json deleted file mode 100644 index b64bac738..000000000 --- a/base/take-map/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/take-map", - "version": "0.0.0", - "description": "Take elements from an array and return a new array after applying a mapping function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index" - ] -} diff --git a/base/take-map/test/test.assign.js b/base/take-map/test/test.assign.js deleted file mode 100644 index a4d148a99..000000000 --- a/base/take-map/test/test.assign.js +++ /dev/null @@ -1,707 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var zeros = require( './../../../zeros' ); -var takeMap = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof takeMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function takes elements from an array (generic)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val * val; - } - - x = [ 1, 2, 3, 4 ]; - - indices = [ 1, 3 ]; - out = zeros( indices.length, 'generic' ); - actual = takeMap( x, indices, 'throw', out, 1, 0, clbk ); - expected = [ 4, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - out = zeros( indices.length*2, 'generic' ); - actual = takeMap( x, indices, 'throw', out, 2, 0, clbk ); - expected = [ 4, 0, 4, 0, 16, 0, 16, 0 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - out = zeros( indices.length, 'generic' ); - actual = takeMap( x, indices, 'throw', out, -1, out.length-1, clbk ); - expected = [ 1, 4, 9, 16 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - out = zeros( indices.length+1, 'generic' ); - actual = takeMap( x, indices, 'throw', out, 1, 1, clbk ); - expected = [ 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes and maps elements from an array (real typed array)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val * 2; - } - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - indices = [ 1, 3 ]; - out = zeros( indices.length, 'float64' ); - actual = takeMap( x, indices, 'throw', out, 1, 0, clbk ); - expected = new Float64Array( [ 4.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - out = zeros( indices.length*2, 'float64' ); - actual = takeMap( x, indices, 'throw', out, 2, 0, clbk ); - expected = new Float64Array( [ 4.0, 0.0, 4.0, 0.0, 8.0, 0.0, 8.0, 0.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - out = zeros( indices.length, 'float64' ); - actual = takeMap( x, indices, 'throw', out, -1, out.length-1, clbk ); - expected = new Float64Array( [ 2.0, 4.0, 6.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - out = zeros( indices.length+1, 'float64' ); - actual = takeMap( x, indices, 'throw', out, 1, 1, clbk ); - expected = new Float64Array( [ 0.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0, 4.0 ] ); // eslint-disable-line max-len - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes and maps elements from an array (complex typed array)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - indices = [ 1, 3 ]; - out = zeros( indices.length, 'complex128' ); - actual = takeMap( x, indices, 'throw', out, 1, 0, clbk ); - expected = new Complex128Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - out = zeros( indices.length*2, 'complex64' ); - actual = takeMap( x, indices, 'throw', out, 2, 0, clbk ); - expected = new Complex64Array( [ 3.0, 4.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 7.0, 8.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - indices = [ 3, 2, 1, 0 ]; - out = zeros( indices.length, 'complex128' ); - actual = takeMap( x, indices, 'throw', out, -1, out.length-1, clbk ); - expected = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); // eslint-disable-line max-len - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - indices = [ 1, 1, 1, 1 ]; - out = zeros( indices.length+1, 'complex64' ); - actual = takeMap( x, indices, 'throw', out, 1, 1, clbk ); - expected = new Complex64Array( [ 0.0, 0.0, 3.0, 4.0, 3.0, 4.0, 3.0, 4.0, 3.0, 4.0 ] ); // eslint-disable-line max-len - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes and maps elements from an array (accessors)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val + 1; - } - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - indices = toAccessorArray( [ 1, 3 ] ); - out = toAccessorArray( zeros( indices.length, 'generic' ) ); - actual = takeMap( x, indices, 'throw', out, 1, 0, clbk ); - expected = [ 3, 5 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - out = toAccessorArray( zeros( indices.length*2, 'generic' ) ); - actual = takeMap( x, indices, 'throw', out, 2, 0, clbk ); - expected = [ 3, 0, 3, 0, 5, 0, 5, 0 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - indices = toAccessorArray( [ 3, 2, 1, 0 ] ); - out = toAccessorArray( zeros( indices.length, 'generic' ) ); - actual = takeMap( x, indices, 'throw', out, -1, out.length-1, clbk ); - expected = [ 2, 3, 4, 5 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - indices = toAccessorArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( indices.length+1, 'generic' ) ); - actual = takeMap( x, indices, 'throw', out, 1, 1, clbk ); - expected = [ 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns an output array unchanged if provided a second argument which is empty', function test( t ) { - var expected; - var actual; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = takeMap( x, [], 'throw', out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = takeMap( x, [], 'throw', out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = takeMap( x, [], 'throw', out, 1, 0, clbk ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = takeMap( x, [], 'throw', out, 1, 0, clbk ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index (generic)', function test( t ) { - var indices; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = [ 1, 2, 3, 4 ]; - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'generic' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - takeMap( x, indices, 'throw', out, 1, 0, clbk ); - } -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index (accessors)', function test( t ) { - var indices; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - indices = toAccessorArray( [ 4, 5, 1, 2 ] ); - out = toAccessorArray( zeros( x.length, 'generic' ) ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - takeMap( x, indices, 'throw', out, 1, 0, clbk ); - } -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index (real typed)', function test( t ) { - var indices; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'float64' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - takeMap( x, indices, 'throw', out, 1, 0, clbk ); - } -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index (complex typed)', function test( t ) { - var indices; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'complex128' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - takeMap( x, indices, 'throw', out, 1, 0, clbk ); - } -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices (generic)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val * 2; - } - - x = [ 1, 2, 3, 4 ]; - indices = [ -1, -2, -3, -4 ]; - out = zeros( x.length, 'generic' ); - - actual = takeMap( x, indices, 'normalize', out, 1, 0, clbk ); - expected = [ 8, 6, 4, 2 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices (accessors)', function test( t ) { - var expected; - var indices; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - indices = toAccessorArray( [ -1, -2, -3, -4 ] ); - out = zeros( x.length, 'generic' ); - - takeMap( x, indices, 'normalize', toAccessorArray( out ), 1, 0, clbk ); - expected = [ 4, 3, 2, 1 ]; - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices (real typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ -1, -2, -3, -4 ]; - out = zeros( x.length, 'float64' ); - - actual = takeMap( x, indices, 'normalize', out, 1, 0, clbk ); - expected = new Float64Array( [ 4.0, 3.0, 2.0, 1.0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices (complex typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ -1, -2 ]; - out = zeros( x.length, 'complex128' ); - - actual = takeMap( x, indices, 'normalize', out, 1, 0, clbk ); - expected = new Complex128Array( [ 3.0, 4.0, 1.0, 2.0 ] ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index (generic)', function test( t ) { - var indices; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = [ 1, 2, 3, 4 ]; - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'generic' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - takeMap( x, indices, 'normalize', out, 1, 0, clbk ); - } -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index (accessors)', function test( t ) { - var indices; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - indices = toAccessorArray( [ 4, 5, 1, 2 ] ); - out = toAccessorArray( zeros( x.length, 'generic' ) ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - takeMap( x, indices, 'normalize', out, 1, 0, clbk ); - } -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index (real typed)', function test( t ) { - var indices; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'float64' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - takeMap( x, indices, 'normalize', out, 1, 0, clbk ); - } -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index (complex typed)', function test( t ) { - var indices; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'complex128' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - takeMap( x, indices, 'normalize', out, 1, 0, clbk ); - } -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices (generic)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = [ 1, 2, 3, 4 ]; - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'generic' ); - - actual = takeMap( x, indices, 'clamp', out, 1, 0, clbk ); - expected = [ 1, 4, 1, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices (accessors)', function test( t ) { - var expected; - var indices; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - indices = toAccessorArray( [ -10, 10, -5, 5 ] ); - out = zeros( x.length, 'generic' ); - - takeMap( x, indices, 'clamp', toAccessorArray( out ), 1, 0, clbk ); - expected = [ 1, 4, 1, 4 ]; - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices (real typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'float64' ); - - actual = takeMap( x, indices, 'clamp', out, 1, 0, clbk ); - expected = new Float64Array( [ 1.0, 4.0, 1.0, 4.0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices (complex typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'complex128' ); - - actual = takeMap( x, indices, 'clamp', out, 1, 0, clbk ); - expected = new Complex128Array( [ 1.0, 2.0, 7.0, 8.0, 1.0, 2.0, 7.0, 8.0 ] ); // eslint-disable-line max-len - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices (generic)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = [ 1, 2, 3, 4 ]; - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'generic' ); - - actual = takeMap( x, indices, 'wrap', out, 1, 0, clbk ); - expected = [ 3, 3, 4, 2 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices (accessors)', function test( t ) { - var expected; - var indices; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - indices = toAccessorArray( [ -10, 10, -5, 5 ] ); - out = zeros( x.length, 'generic' ); - - takeMap( x, indices, 'wrap', toAccessorArray( out ), 1, 0, clbk ); - expected = [ 3, 3, 4, 2 ]; - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices (real typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'float64' ); - - actual = takeMap( x, indices, 'wrap', out, 1, 0, clbk ); - expected = new Float64Array( [ 3.0, 3.0, 4.0, 2.0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices (complex typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - function clbk( val ) { - return val; - } - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'complex128' ); - - actual = takeMap( x, indices, 'wrap', out, 1, 0, clbk ); - expected = new Complex128Array( [ 5.0, 6.0, 5.0, 6.0, 7.0, 8.0, 3.0, 4.0 ] ); // eslint-disable-line max-len - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/base/take-map/test/test.js b/base/take-map/test/test.js deleted file mode 100644 index a03afc0f6..000000000 --- a/base/take-map/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var takeMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof takeMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( takeMap, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( takeMap, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/take-map/test/test.main.js b/base/take-map/test/test.main.js deleted file mode 100644 index a9752db92..000000000 --- a/base/take-map/test/test.main.js +++ /dev/null @@ -1,212 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var takeMap = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof takeMap, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof takeMap.assign, 'function', 'assign method is a function' ); - t.end(); -}); - -tape( 'the function takes elements from an array', function test( t ) { - var expected; - var indices; - var actual; - var x; - - function clbk( v ) { - return v*v; - } - - x = [ 1, 2, 3, 4 ]; - - indices = [ 1, 3 ]; - actual = takeMap( x, indices, 'throw', clbk ); - expected = [ 4, 16 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - actual = takeMap( x, indices, 'throw', clbk ); - expected = [ 4, 4, 16, 16 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - actual = takeMap( x, indices, 'throw', clbk ); - expected = [ 16, 9, 4, 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = takeMap( x, indices, 'throw', clbk ); - expected = [ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from an array (accessors)', function test( t ) { - var expected; - var indices; - var actual; - var x; - var v; - var i; - - function clbk( v ) { - return v; - } - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - actual = takeMap( x, indices, 'throw', clbk ); - - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < indices.length; i++ ) { - v = actual[ i ]; - expected = x.get( indices.get( i ) ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an empty array if provided a second argument which is empty', function test( t ) { - var x = [ 1, 2, 3, 4 ]; - function clbk( v ) { - return v; - } - t.deepEqual( takeMap( x, [], 'throw' ), [], 'returns expected value', clbk ); - t.end(); -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - function clbk( v ) { - return v; - } - - x = [ 1, 2, 3, 4 ]; - indices = [ 4, 5, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - takeMap( x, indices, 'throw', clbk ); - } -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - function clbk( v ) { - return v*2; - } - - x = [ 1, 2, 3, 4 ]; - - indices = [ -1, -2, -3, -4 ]; - actual = takeMap( x, indices, 'normalize', clbk ); - expected = [ 8, 6, 4, 2 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - function clbk( v ) { - return v; - } - - x = [ 1, 2, 3, 4 ]; - indices = [ 2, 50, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - takeMap( x, indices, 'normalize', clbk ); - } -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - function clbk( v ) { - return v; - } - - x = [ 1, 2, 3, 4 ]; - - indices = [ -10, 10, -5, 5 ]; - actual = takeMap( x, indices, 'clamp', clbk ); - expected = [ 1, 4, 1, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - function clbk( v ) { - return v; - } - - x = [ 1, 2, 3, 4 ]; - - indices = [ -10, 10, -5, 5 ]; - actual = takeMap( x, indices, 'wrap', clbk ); - expected = [ 3, 3, 4, 2 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/take/README.md b/base/take/README.md deleted file mode 100644 index 1ab41d326..000000000 --- a/base/take/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# take - -> Take elements from an array. - -
- -## Usage - -```javascript -var take = require( '@stdlib/array/base/take' ); -``` - -#### take( x, indices, mode ) - -Takes elements from an array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var y = take( x, [ 1, 3 ], 'throw' ); -// returns [ 2, 4 ] -``` - -The function supports the following parameters: - -- **x**: input array. -- **indices**: list of indices. -- **mode**: index [mode][@stdlib/ndarray/base/ind]. - -If `indices` is an empty array, the function returns an empty array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var y = take( x, [], 'throw' ); -// returns [] -``` - -#### take.assign( x, indices, mode, out, stride, offset ) - -Takes elements from an array and assigns the values to elements in a provided output array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = [ 0, 0, 0, 0, 0, 0 ]; -var indices = [ 0, 0, 1, 1, 3, 3 ]; - -var arr = take.assign( x, indices, 'throw', out, -1, out.length-1 ); -// returns [ 4, 4, 2, 2, 1, 1 ] - -var bool = ( arr === out ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **indices**: list of indices. -- **mode**: index [mode][@stdlib/ndarray/base/ind]. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( '@stdlib/array/base/linspace' ); -var take = require( '@stdlib/array/base/take' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); -console.log( indices ); - -// Take a random sample of elements from `x`: -var y = take( x, indices, 'throw' ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/take/benchmark/benchmark.assign.length.js b/base/take/benchmark/benchmark.assign.length.js deleted file mode 100644 index 330c1c462..000000000 --- a/base/take/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeros = require( './../../../zeros' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var take = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out; - var idx; - - idx = discreteUniform( len, 0, 3, { - 'dtype': 'generic' - }); - out = zeros( len, 'generic' ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x; - var v; - var i; - - x = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = take.assign( x, idx, 'throw', out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/take/benchmark/benchmark.js b/base/take/benchmark/benchmark.js deleted file mode 100644 index fdd872ce1..000000000 --- a/base/take/benchmark/benchmark.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var take = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = take( x, x, 'throw' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/take/benchmark/benchmark.length.js b/base/take/benchmark/benchmark.length.js deleted file mode 100644 index 1ac63bf0f..000000000 --- a/base/take/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var take = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var idx = discreteUniform( len, 0, 3 ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x; - var v; - var i; - - x = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = take( x, idx, 'throw' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/take/docs/repl.txt b/base/take/docs/repl.txt deleted file mode 100644 index 429279ba8..000000000 --- a/base/take/docs/repl.txt +++ /dev/null @@ -1,82 +0,0 @@ - -{{alias}}( x, indices, mode ) - Takes elements from an array. - - If `indices` is an empty array, the function returns an empty array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - indices: ArrayLikeObject - List of element indices. - - mode: string - Specifies how to handle an index outside the interval [0, max], where - `max` is the maximum possible array index. If equal to 'throw', the - function throws an error. If equal to 'normalize', the function throws - an error if provided an out-of-bounds normalized index. If equal to - 'wrap', the function wraps around an index using modulo arithmetic. If - equal to 'clamp', the function sets an index to either 0 (minimum index) - or the maximum index. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 1, 3 ], 'throw' ) - [ 2, 4 ] - - -{{alias}}.assign( x, indices, mode, out, stride, offset ) - Takes elements from an array and assigns the values to elements in a - provided output array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - indices: ArrayLikeObject - List of element indices. - - mode: string - Specifies how to handle an index outside the interval [0, max], where - `max` is the maximum possible array index. If equal to 'throw', the - function throws an error. If equal to 'normalize', the function throws - an error if provided an out-of-bounds normalized index. If equal to - 'wrap', the function wraps around an index using modulo arithmetic. If - equal to 'clamp', the function sets an index to either 0 (minimum index) - or the maximum index. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ) - [ 2, 0, 4, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/base/take/docs/types/index.d.ts b/base/take/docs/types/index.d.ts deleted file mode 100644 index 181a90c63..000000000 --- a/base/take/docs/types/index.d.ts +++ /dev/null @@ -1,429 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection, AccessorArrayLike, Complex128Array, Complex64Array } from '@stdlib/types/array'; -import { Mode } from '@stdlib/types/ndarray'; - -/** -* Index array. -*/ -type IndexArray = Collection | AccessorArrayLike; - -/** -* Interface describing `take`. -*/ -interface Take { - /** - * Takes elements from an array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = take( x, [ 1, 3 ], 'throw' ); - * // returns [ 2, 4 ] - */ - ( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode ): Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2.0, 0.0, 4.0, 0.0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Float64Array, stride: number, offset: number ): Float64Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Float32Array = require( './../../../../float32' ); - * - * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * var out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2.0, 0.0, 4.0, 0.0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Float32Array, stride: number, offset: number ): Float32Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Complex128Array = require( './../../../../float64' ); - * - * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - * var out = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 3.0, 4.0, 0.0, 0.0, 7.0, 8.0, 0.0, 0.0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Complex128Array, stride: number, offset: number ): Complex128Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Complex64Array = require( './../../../../float64' ); - * - * var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - * var out = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 3.0, 4.0, 0.0, 0.0, 7.0, 8.0, 0.0, 0.0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Complex64Array, stride: number, offset: number ): Complex64Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Int32Array = require( './../../../../int32' ); - * - * var x = new Int32Array( [ 1, 2, 3, 4 ] ); - * var out = new Int32Array( [ 0, 0, 0, 0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2, 0, 4, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Int32Array, stride: number, offset: number ): Int32Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Int16Array = require( './../../../../int16' ); - * - * var x = new Int16Array( [ 1, 2, 3, 4 ] ); - * var out = new Int16Array( [ 0, 0, 0, 0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2, 0, 4, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Int16Array, stride: number, offset: number ): Int16Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Int8Array = require( './../../../../int8' ); - * - * var x = new Int8Array( [ 1, 2, 3, 4 ] ); - * var out = new Int8Array( [ 0, 0, 0, 0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2, 0, 4, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Int8Array, stride: number, offset: number ): Int8Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Uint32Array = require( './../../../../uint32' ); - * - * var x = new Uint32Array( [ 1, 2, 3, 4 ] ); - * var out = new Uint32Array( [ 0, 0, 0, 0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2, 0, 4, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Uint32Array, stride: number, offset: number ): Uint32Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Uint16Array = require( './../../../../uint16' ); - * - * var x = new Uint16Array( [ 1, 2, 3, 4 ] ); - * var out = new Uint16Array( [ 0, 0, 0, 0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2, 0, 4, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Uint16Array, stride: number, offset: number ): Uint16Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Uint8Array = require( './../../../../uint8' ); - * - * var x = new Uint8Array( [ 1, 2, 3, 4 ] ); - * var out = new Uint8Array( [ 0, 0, 0, 0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2, 0, 4, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Uint8Array, stride: number, offset: number ): Uint8Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Uint8ClampedArray = require( './../../../../uint8c' ); - * - * var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); - * var out = new Uint8ClampedArray( [ 0, 0, 0, 0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2, 0, 4, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Uint8ClampedArray, stride: number, offset: number ): Uint8ClampedArray; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var out = [ 0, 0, 0, 0 ]; - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2, 0, 4, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Array, stride: number, offset: number ): Array; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var toAccessorArray = require( './../../../../base/to-accessor-array' ); - * - * var x = [ 1, 2, 3, 4 ]; - * var out = toAccessorArray( [ 0, 0, 0, 0 ] ); - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * - * var bool = ( arr === out ); - * // returns true - * - * var v = arr.get( 0 ); - * // returns 2 - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: AccessorArrayLike, stride: number, offset: number ): AccessorArrayLike; - - /** - * Takes elements from an array and assigns the value to elements in a provided output array. - * - * @param x - input array - * @param indices - list of element indices - * @param mode - index mode - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var out = [ 0, 0, 0, 0 ]; - * - * var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); - * // returns [ 2, 0, 4, 0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, indices: IndexArray, mode: Mode, out: Collection, stride: number, offset: number ): Collection; -} - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param mode - index mode -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = take( x, [ 1, 3 ], 'throw' ); -* // returns [ 2, 4 ] -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = take.assign( x, [ 1, 3 ], 'throw', out, 2, 0 ); -* // returns [ 2, 0, 4, 0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var take: Take; - - -// EXPORTS // - -export = take; diff --git a/base/take/docs/types/test.ts b/base/take/docs/types/test.ts deleted file mode 100644 index 5ff071ae2..000000000 --- a/base/take/docs/types/test.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import take = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - take( [ 1, 2, 3, 4 ], [ 1, 3 ], 'throw' ); // $ExpectType number[] - take( [ 1, 2, 3, 4 ], [ 1, 3 ], 'normalize' ); // $ExpectType any[] - take( [ 1, 2, 3, 4 ], [ 1, 3 ], 'clamp' ); // $ExpectType number[] - take( [ '1', '2', '3', '4' ], [ 1, 3 ], 'wrap' ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - take( 1, [ 1, 3 ], 'throw' ); // $ExpectError - take( true, [ 1, 3 ], 'throw' ); // $ExpectError - take( false, [ 1, 3 ], 'throw' ); // $ExpectError - take( null, [ 1, 3 ], 'throw' ); // $ExpectError - take( void 0, [ 1, 3 ], 'throw' ); // $ExpectError - take( {}, [ 1, 3 ], 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - take( [], 1, 'throw' ); // $ExpectError - take( [], true, 'throw' ); // $ExpectError - take( [], false, 'throw' ); // $ExpectError - take( [], null, 'throw' ); // $ExpectError - take( [], void 0, 'throw' ); // $ExpectError - take( [], {}, 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid index mode... -{ - take( [], [ 1, 3 ], '1' ); // $ExpectError - take( [], [ 1, 3 ], 1 ); // $ExpectError - take( [], [ 1, 3 ], true ); // $ExpectError - take( [], [ 1, 3 ], false ); // $ExpectError - take( [], [ 1, 3 ], null ); // $ExpectError - take( [], [ 1, 3 ], void 0 ); // $ExpectError - take( [], [ 1, 3 ], {} ); // $ExpectError - take( [], [ 1, 3 ], [] ); // $ExpectError - take( [], [ 1, 3 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - take(); // $ExpectError - take( [] ); // $ExpectError - take( [], [] ); // $ExpectError - take( [], [], 'throw', {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 1, 2, 3, 4 ]; - const y = new Complex128Array( 4 ); - - take.assign( x, [ 1, 3 ], 'throw', [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectType number[] - take.assign( x, [ 1, 3 ], 'throw', new Float64Array( 4 ), 1, 0 ); // $ExpectType Float64Array - take.assign( x, [ 1, 3 ], 'throw', new Float32Array( 4 ), 1, 0 ); // $ExpectType Float32Array - take.assign( x, [ 1, 3 ], 'throw', new Int32Array( 4 ), 1, 0 ); // $ExpectType Int32Array - take.assign( x, [ 1, 3 ], 'throw', new Int16Array( 4 ), 1, 0 ); // $ExpectType Int16Array - take.assign( x, [ 1, 3 ], 'throw', new Int8Array( 4 ), 1, 0 ); // $ExpectType Int8Array - take.assign( x, [ 1, 3 ], 'throw', new Uint32Array( 4 ), 1, 0 ); // $ExpectType Uint32Array - take.assign( x, [ 1, 3 ], 'throw', new Uint16Array( 4 ), 1, 0 ); // $ExpectType Uint16Array - take.assign( x, [ 1, 3 ], 'throw', new Uint8Array( 4 ), 1, 0 ); // $ExpectType Uint8Array - take.assign( x, [ 1, 3 ], 'throw', new Uint8ClampedArray( 4 ), 1, 0 ); // $ExpectType Uint8ClampedArray - take.assign( y, [ 1, 3 ], 'throw', new Complex128Array( 4 ), 1, 0 ); // $ExpectType Complex128Array - take.assign( y, [ 1, 3 ], 'throw', new Complex64Array( 4 ), 1, 0 ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - take.assign( 1, [ 1, 3 ], 'throw', out, 1, 0 ); // $ExpectError - take.assign( true, [ 1, 3 ], 'throw', out, 1, 0 ); // $ExpectError - take.assign( false, [ 1, 3 ], 'throw', out, 1, 0 ); // $ExpectError - take.assign( null, [ 1, 3 ], 'throw', out, 1, 0 ); // $ExpectError - take.assign( void 0, [ 1, 3 ], 'throw', out, 1, 0 ); // $ExpectError - take.assign( {}, [ 1, 3 ], 'throw', out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object containing numbers... -{ - const out = [ 0, 0, 0, 0 ]; - - take.assign( [], 1, 'throw', out, 1, 0 ); // $ExpectError - take.assign( [], true, 'throw', out, 1, 0 ); // $ExpectError - take.assign( [], false, 'throw', out, 1, 0 ); // $ExpectError - take.assign( [], null, 'throw', out, 1, 0 ); // $ExpectError - take.assign( [], void 0, 'throw', out, 1, 0 ); // $ExpectError - take.assign( [], {}, 'throw', out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a valid index mode... -{ - const out = [ 0, 0, 0, 0 ]; - - take.assign( [], [ 1, 3 ], '1', out, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 1, out, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], true, out, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], false, out, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], null, out, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], void 0, out, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], {}, out, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], [], out, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], ( x: number ): number => x, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - take.assign( [], [ 1, 3 ], 'throw', 1, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', true, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', false, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', null, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', void 0, 1, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const out = [ 0, 0, 0, 0 ]; - - take.assign( [], [ 1, 3 ], 'throw', out, '1', 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, true, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, false, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, null, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, void 0, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, {}, 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, [], 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const out = [ 0, 0, 0, 0 ]; - - take.assign( [], [ 1, 3 ], 'throw', out, 1, '1' ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, 1, true ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, 1, false ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, 1, null ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, 1, void 0 ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, 1, {} ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, 1, [] ); // $ExpectError - take.assign( [], [ 1, 3 ], 'throw', out, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - take.assign(); // $ExpectError - take.assign( [] ); // $ExpectError - take.assign( [], [] ); // $ExpectError - take.assign( [], [], 'throw' ); // $ExpectError - take.assign( [], [], 'throw', [] ); // $ExpectError - take.assign( [], [], 'throw', [], 1 ); // $ExpectError - take.assign( [], [], 'throw', [], 1, 0, {} ); // $ExpectError -} diff --git a/base/take/examples/index.js b/base/take/examples/index.js deleted file mode 100644 index 46698935d..000000000 --- a/base/take/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( './../../../base/linspace' ); -var take = require( './../lib' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); -console.log( indices ); - -// Take a random sample of elements from `x`: -var y = take( x, indices, 'throw' ); -console.log( y ); diff --git a/base/take/lib/assign.js b/base/take/lib/assign.js deleted file mode 100644 index 8dce6431e..000000000 --- a/base/take/lib/assign.js +++ /dev/null @@ -1,311 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var isBooleanDataType = require( './../../../base/assert/is-boolean-data-type' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var ind = require( '@stdlib/ndarray/base/ind' ).factory; - - -// FUNCTIONS // - -/** -* Takes elements from an indexed array and assigns the values to elements in an indexed output array. -* -* @private -* @param {Collection} x - input array -* @param {IntegerArray} indices - list of indices -* @param {string} mode - index mode -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var indices = [ 3, 1, 2, 0 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* -* var arr = indexed( x, indices, 'throw', out, 1, 0 ); -* // returns [ 4, 2, 3, 1 ] -*/ -function indexed( x, indices, mode, out, stride, offset ) { - var getIndex; - var max; - var io; - var i; - var j; - - // Resolve a function for returning an index according to the specified index mode: - getIndex = ind( mode ); - - // Resolve the maximum index: - max = x.length - 1; - - // Extract each desired element from the provided array... - io = offset; - for ( i = 0; i < indices.length; i++ ) { - j = getIndex( indices[ i ], max ); - out[ io ] = x[ j ]; - io += stride; - } - return out; -} - -/** -* Takes elements from an accessor array and assigns the values to elements in an accessor output array. -* -* @private -* @param {Object} x - input array object -* @param {Object} indices - index array object -* @param {string} mode - index mode -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var indices = toAccessorArray( [ 3, 1, 2, 0 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), arraylike2object( indices ), 'throw', arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 4 -*/ -function accessors( x, indices, mode, out, stride, offset ) { - var getIndex; - var xdata; - var idata; - var odata; - var xget; - var iget; - var oset; - var max; - var io; - var i; - var j; - - xdata = x.data; - idata = indices.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - iget = indices.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - // Resolve a function for returning an index according to the specified index mode: - getIndex = ind( mode ); - - // Resolve the maximum index: - max = xdata.length - 1; - - // Extract each desired element from the provided array... - io = offset; - for ( i = 0; i < idata.length; i++ ) { - j = getIndex( iget( idata, i ), max ); - oset( odata, io, xget( xdata, j ) ); - io += stride; - } - return odata; -} - -/** -* Takes elements from a complex array and assigns the values to elements in a complex output array. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {Object} indices - index array object -* @param {string} mode - index mode -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* var indices = [ 0, 0, 1, 1 ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( x, arraylike2object( indices ), 'throw', out, 1, 0 ); -* // returns [ 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ] -*/ -function complex( x, indices, mode, out, stride, offset ) { - var getIndex; - var idata; - var iget; - var max; - var io; - var so; - var i; - var j; - var k; - - idata = indices.data; - iget = indices.accessors[ 0 ]; - - // Resolve a function for returning an index according to the specified index mode: - getIndex = ind( mode ); - - // Resolve the maximum index: - max = ( x.length/2 ) - 1; // resolve the length of the original complex array - - // Extract each desired element from the provided array... - so = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < idata.length; i++ ) { - j = getIndex( iget( idata, i ), max ); - k = j * 2; - out[ io ] = x[ k ]; - out[ io+1 ] = x[ k+1 ]; - io += so; - } - return out; -} - -/** -* Takes elements from a boolean array and assigns the values to elements in a boolean output array. -* -* @private -* @param {Collection} x - boolean value input array view -* @param {Object} indices - index array object -* @param {string} mode - index mode -* @param {Collection} out - boolean value output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Uint8Array( [ 1, 0, 0, 1 ] ); -* var indices = [ 0, 0, 1, 1 ]; -* -* var out = new Uint8Array( 4 ); -* -* var arr = boolean( x, arraylike2object( indices ), 'throw', out, 1, 0 ); -* // returns [ 1, 1, 0, 0 ] -*/ -function boolean( x, indices, mode, out, stride, offset ) { - var getIndex; - var idata; - var iget; - var max; - var io; - var i; - var j; - - idata = indices.data; - iget = indices.accessors[ 0 ]; - - // Resolve a function for returning an index according to the specified index mode: - getIndex = ind( mode ); - - // Resolve the maximum index: - max = x.length - 1; - - // Extract each desired element from the provided array... - io = offset; - for ( i = 0; i < idata.length; i++ ) { - j = getIndex( iget( idata, i ), max ); - out[ io ] = x[ j ]; - io += stride; - } - return out; -} - - -// MAIN // - -/** -* Takes elements from an array and assigns the values to elements in a provided output array. -* -* @param {Collection} x - input array -* @param {IntegerArray} indices - list of indices -* @param {string} mode - index mode -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var indices = [ 3, 1, 2, 0 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* var arr = assign( x, indices, 'throw', out, 1, 0 ); -* // returns [ 4, 2, 3, 1 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, indices, mode, out, stride, offset ) { - var xo; - var io; - var oo; - - xo = arraylike2object( x ); - io = arraylike2object( indices ); - oo = arraylike2object( out ); - if ( - xo.accessorProtocol || - io.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), io, mode, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - boolean( reinterpretBoolean( x, 0 ), io, mode, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, io, mode, oo, stride, offset ); - return out; - } - indexed( x, indices, mode, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/take/lib/index.js b/base/take/lib/index.js deleted file mode 100644 index 6709f4b7f..000000000 --- a/base/take/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Take elements from an array. -* -* @module @stdlib/array/base/take -* -* @example -* var take = require( '@stdlib/array/base/take' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 0, 0, 1, 1, 3, 3 ]; -* var y = take( x, indices, 'throw' ); -* // returns [ 1, 1, 2, 2, 4, 4 ] -* -* @example -* var take = require( '@stdlib/array/base/take' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* var indices = [ 0, 0, 1, 1, 3, 3 ]; -* -* var arr = take.assign( x, indices, 'throw', out, 1, 0 ); -* // returns [ 1, 1, 2, 2, 4, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/take/lib/main.js b/base/take/lib/main.js deleted file mode 100644 index 33d0762a6..000000000 --- a/base/take/lib/main.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); -var ind = require( '@stdlib/ndarray/base/ind' ).factory; - - -// MAIN // - -/** -* Takes elements from an array. -* -* @param {Collection} x - input array -* @param {IntegerArray} indices - list of indices -* @param {string} mode - index mode -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var indices = [ 3, 1, 2, 0 ]; -* -* var y = take( x, indices, 'throw' ); -* // returns [ 4, 2, 3, 1 ] -*/ -function take( x, indices, mode ) { - var getIndex; - var xget; - var iget; - var out; - var max; - var i; - var j; - - // Resolve an accessor for retrieving array elements: - xget = resolveGetter( x ); - iget = resolveGetter( indices ); - - // Resolve a function for returning an index according to the specified index mode: - getIndex = ind( mode ); - - // Resolve the maximum index: - max = x.length - 1; - - // Extract each desired element from the provided array... - out = []; - for ( i = 0; i < indices.length; i++ ) { - j = getIndex( iget( indices, i ), max ); - out.push( xget( x, j ) ); // use `Array#push` to ensure "fast" elements - } - return out; -} - - -// EXPORTS // - -module.exports = take; diff --git a/base/take/package.json b/base/take/package.json deleted file mode 100644 index 49cfa7981..000000000 --- a/base/take/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/base/take", - "version": "0.0.0", - "description": "Take elements from an array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index" - ] -} diff --git a/base/take/test/test.assign.js b/base/take/test/test.assign.js deleted file mode 100644 index 294cd496f..000000000 --- a/base/take/test/test.assign.js +++ /dev/null @@ -1,676 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); -var zeros = require( './../../../zeros' ); -var take = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof take, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function takes elements from an array (generic)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ 1, 3 ]; - out = zeros( indices.length, 'generic' ); - actual = take( x, indices, 'throw', out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - out = zeros( indices.length*2, 'generic' ); - actual = take( x, indices, 'throw', out, 2, 0 ); - expected = [ 2, 0, 2, 0, 4, 0, 4, 0 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - out = zeros( indices.length, 'generic' ); - actual = take( x, indices, 'throw', out, -1, out.length-1 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - out = zeros( indices.length+1, 'generic' ); - actual = take( x, indices, 'throw', out, 1, 1 ); - expected = [ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from an array (real typed array)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - indices = [ 1, 3 ]; - out = zeros( indices.length, 'float64' ); - actual = take( x, indices, 'throw', out, 1, 0 ); - expected = new Float64Array( [ 2.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - out = zeros( indices.length*2, 'float64' ); - actual = take( x, indices, 'throw', out, 2, 0 ); - expected = new Float64Array( [ 2.0, 0.0, 2.0, 0.0, 4.0, 0.0, 4.0, 0.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - out = zeros( indices.length, 'float64' ); - actual = take( x, indices, 'throw', out, -1, out.length-1 ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - out = zeros( indices.length+1, 'float64' ); - actual = take( x, indices, 'throw', out, 1, 1 ); - expected = new Float64Array( [ 0.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ] ); // eslint-disable-line max-len - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from an array (complex typed array)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - indices = [ 1, 3 ]; - out = zeros( indices.length, 'complex128' ); - actual = take( x, indices, 'throw', out, 1, 0 ); - expected = new Complex128Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - out = zeros( indices.length*2, 'complex64' ); - actual = take( x, indices, 'throw', out, 2, 0 ); - expected = new Complex64Array( [ 3.0, 4.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 7.0, 8.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - indices = [ 3, 2, 1, 0 ]; - out = zeros( indices.length, 'complex128' ); - actual = take( x, indices, 'throw', out, -1, out.length-1 ); - expected = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); // eslint-disable-line max-len - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - indices = [ 1, 1, 1, 1 ]; - out = zeros( indices.length+1, 'complex64' ); - actual = take( x, indices, 'throw', out, 1, 1 ); - expected = new Complex64Array( [ 0.0, 0.0, 3.0, 4.0, 3.0, 4.0, 3.0, 4.0, 3.0, 4.0 ] ); // eslint-disable-line max-len - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from an array (boolean array)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = new BooleanArray( [ true, false, false, true ] ); - - indices = [ 1, 3 ]; - out = new BooleanArray( indices.length ); - actual = take( x, indices, 'throw', out, 1, 0 ); - expected = new BooleanArray( [ false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - out = new BooleanArray( indices.length*2 ); - actual = take( x, indices, 'throw', out, 2, 0 ); - expected = new BooleanArray( [ false, false, false, false, true, false, true, false ] ); // eslint-disable-line max-len - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - out = new BooleanArray( indices.length ); - actual = take( x, indices, 'throw', out, -1, out.length-1 ); - expected = new BooleanArray( [ true, false, false, true ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - indices = [ 1, 1, 1, 1 ]; - out = new BooleanArray( indices.length+1 ); - actual = take( x, indices, 'throw', out, 1, 1 ); - expected = new BooleanArray( [ false, false, false, false, false ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from an array (accessors)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - indices = toAccessorArray( [ 1, 3 ] ); - out = toAccessorArray( zeros( indices.length, 'generic' ) ); - actual = take( x, indices, 'throw', out, 1, 0 ); - expected = [ 2, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - out = toAccessorArray( zeros( indices.length*2, 'generic' ) ); - actual = take( x, indices, 'throw', out, 2, 0 ); - expected = [ 2, 0, 2, 0, 4, 0, 4, 0 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - indices = toAccessorArray( [ 3, 2, 1, 0 ] ); - out = toAccessorArray( zeros( indices.length, 'generic' ) ); - actual = take( x, indices, 'throw', out, -1, out.length-1 ); - expected = [ 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - indices = toAccessorArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - out = toAccessorArray( zeros( indices.length+1, 'generic' ) ); - actual = take( x, indices, 'throw', out, 1, 1 ); - expected = [ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns leaves an output array unchanged if provided a second argument which is empty', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = take( x, [], 'throw', out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = take( x, [], 'throw', out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = [ 0, 0, 0, 0 ]; - expected = [ 0, 0, 0, 0 ]; - actual = take( x, [], 'throw', out, 1, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - actual = take( x, [], 'throw', out, 1, 0 ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - x = new BooleanArray( [ true, false, false, true ] ); - out = new BooleanArray( [ false, false, false, false ] ); - expected = new BooleanArray( [ false, false, false, false ] ); - actual = take( x, [], 'throw', out, 1, 0 ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index (generic)', function test( t ) { - var indices; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'generic' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, 'throw', out, 1, 0 ); - } -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index (accessors)', function test( t ) { - var indices; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - indices = toAccessorArray( [ 4, 5, 1, 2 ] ); - out = toAccessorArray( zeros( x.length, 'generic' ) ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, 'throw', out, 1, 0 ); - } -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index (real typed)', function test( t ) { - var indices; - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'float64' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, 'throw', out, 1, 0 ); - } -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index (complex typed)', function test( t ) { - var indices; - var out; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'complex128' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, 'throw', out, 1, 0 ); - } -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index (boolean)', function test( t ) { - var indices; - var out; - var x; - - x = new BooleanArray( [ true, false ] ); - indices = [ 4, 5, 1, 2 ]; - out = new BooleanArray( x.length ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, 'throw', out, 1, 0 ); - } -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices (generic)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ -1, -2, -3, -4 ]; - out = zeros( x.length, 'generic' ); - - actual = take( x, indices, 'normalize', out, 1, 0 ); - expected = [ 4, 3, 2, 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices (accessors)', function test( t ) { - var expected; - var indices; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - indices = toAccessorArray( [ -1, -2, -3, -4 ] ); - out = zeros( x.length, 'generic' ); - - take( x, indices, 'normalize', toAccessorArray( out ), 1, 0 ); - expected = [ 4, 3, 2, 1 ]; - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices (real typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ -1, -2, -3, -4 ]; - out = zeros( x.length, 'float64' ); - - actual = take( x, indices, 'normalize', out, 1, 0 ); - expected = new Float64Array( [ 4.0, 3.0, 2.0, 1.0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices (complex typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ -1, -2 ]; - out = zeros( x.length, 'complex128' ); - - actual = take( x, indices, 'normalize', out, 1, 0 ); - expected = new Complex128Array( [ 3.0, 4.0, 1.0, 2.0 ] ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index (generic)', function test( t ) { - var indices; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'generic' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, 'normalize', out, 1, 0 ); - } -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index (accessors)', function test( t ) { - var indices; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - indices = toAccessorArray( [ 4, 5, 1, 2 ] ); - out = toAccessorArray( zeros( x.length, 'generic' ) ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, 'normalize', out, 1, 0 ); - } -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index (real typed)', function test( t ) { - var indices; - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'float64' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, 'normalize', out, 1, 0 ); - } -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index (complex typed)', function test( t ) { - var indices; - var out; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 4, 5, 1, 2 ]; - out = zeros( x.length, 'complex128' ); - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, 'normalize', out, 1, 0 ); - } -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices (generic)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'generic' ); - - actual = take( x, indices, 'clamp', out, 1, 0 ); - expected = [ 1, 4, 1, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices (accessors)', function test( t ) { - var expected; - var indices; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - indices = toAccessorArray( [ -10, 10, -5, 5 ] ); - out = zeros( x.length, 'generic' ); - - take( x, indices, 'clamp', toAccessorArray( out ), 1, 0 ); - expected = [ 1, 4, 1, 4 ]; - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices (real typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'float64' ); - - actual = take( x, indices, 'clamp', out, 1, 0 ); - expected = new Float64Array( [ 1.0, 4.0, 1.0, 4.0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices (complex typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'complex128' ); - - actual = take( x, indices, 'clamp', out, 1, 0 ); - expected = new Complex128Array( [ 1.0, 2.0, 7.0, 8.0, 1.0, 2.0, 7.0, 8.0 ] ); // eslint-disable-line max-len - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices (generic)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'generic' ); - - actual = take( x, indices, 'wrap', out, 1, 0 ); - expected = [ 3, 3, 4, 2 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices (accessors)', function test( t ) { - var expected; - var indices; - var out; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - indices = toAccessorArray( [ -10, 10, -5, 5 ] ); - out = zeros( x.length, 'generic' ); - - take( x, indices, 'wrap', toAccessorArray( out ), 1, 0 ); - expected = [ 3, 3, 4, 2 ]; - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices (real typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'float64' ); - - actual = take( x, indices, 'wrap', out, 1, 0 ); - expected = new Float64Array( [ 3.0, 3.0, 4.0, 2.0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices (complex typed)', function test( t ) { - var expected; - var indices; - var actual; - var out; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = [ -10, 10, -5, 5 ]; - out = zeros( x.length, 'complex128' ); - - actual = take( x, indices, 'wrap', out, 1, 0 ); - expected = new Complex128Array( [ 5.0, 6.0, 5.0, 6.0, 7.0, 8.0, 3.0, 4.0 ] ); // eslint-disable-line max-len - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); diff --git a/base/take/test/test.js b/base/take/test/test.js deleted file mode 100644 index 969f2cbe6..000000000 --- a/base/take/test/test.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var take = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof take, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( take, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( take, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/take/test/test.main.js b/base/take/test/test.main.js deleted file mode 100644 index 6f819f59d..000000000 --- a/base/take/test/test.main.js +++ /dev/null @@ -1,189 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../../complex64' ); -var BooleanArray = require( './../../../bool' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var take = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof take, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function takes elements from an array', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ 1, 3 ]; - actual = take( x, indices, 'throw' ); - expected = [ 2, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - actual = take( x, indices, 'throw' ); - expected = [ 2, 2, 4, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - actual = take( x, indices, 'throw' ); - expected = [ 4, 3, 2, 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = take( x, indices, 'throw' ); - expected = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from an array (accessors)', function test( t ) { - var expected; - var indices; - var actual; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - actual = take( x, indices, 'throw' ); - - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < indices.length; i++ ) { - v = actual[ i ]; - expected = x.get( indices.get( i ) ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected ), 'returns expected value' ); - } - - x = new BooleanArray( [ true, false, false, true ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - actual = take( x, indices, 'throw' ); - - t.notEqual( actual, x, 'returns different reference' ); - for ( i = 0; i < indices.length; i++ ) { - v = actual[ i ]; - expected = x.get( indices.get( i ) ); - t.strictEqual( v, expected, 'returns expected value' ); - } - - t.end(); -}); - -tape( 'the function returns an empty array if provided a second argument which is empty', function test( t ) { - var x = [ 1, 2, 3, 4 ]; - t.deepEqual( take( x, [], 'throw' ), [], 'returns expected value' ); - t.end(); -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 4, 5, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, 'throw' ); - } -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -1, -2, -3, -4 ]; - actual = take( x, indices, 'normalize' ); - expected = [ 4, 3, 2, 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 2, 50, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, 'normalize' ); - } -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -10, 10, -5, 5 ]; - actual = take( x, indices, 'clamp' ); - expected = [ 1, 4, 1, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -10, 10, -5, 5 ]; - actual = take( x, indices, 'wrap' ); - expected = [ 3, 3, 4, 2 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/take2d/README.md b/base/take2d/README.md deleted file mode 100644 index 7bc891a5d..000000000 --- a/base/take2d/README.md +++ /dev/null @@ -1,125 +0,0 @@ - - -# take2d - -> Take elements from a two-dimensional nested array. - -
- -## Usage - -```javascript -var take2d = require( '@stdlib/array/base/take2d' ); -``` - -#### take2d( x, indices, dimension, mode ) - -Takes elements along a specified `dimension` from a two-dimensional nested array according to a specified [index `mode`][@stdlib/ndarray/index-modes]. - -```javascript -var x = [ [ 1, 2 ], [ 3, 4 ] ]; -var indices = [ 1, 1, 0, 0, -1, -1 ]; - -var y = take2d( x, indices, 1, 'normalize' ); -// returns [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] -``` - -The function accepts the following arguments: - -- **x**: input nested array. -- **indices**: list of indices. -- **dimension**: dimension along which to take elements. If provided a negative integer, the dimension is resolved relative to the last dimension, with the last dimension being `-1`. -- **mode**: [index mode][@stdlib/ndarray/index-modes] specifying how to handle an index which is out-of-bounds. - -If `indices` is an empty array, the function returns empty arrays along the specified `dimension`. - -```javascript -var x = [ [ 1, 2 ], [ 3, 4 ] ]; - -var y = take2d( x, [], 1, 'throw' ); -// returns [ [], [] ] - -var z = take2d( x, [], 0, 'throw' ); -// returns [] -``` - -
- - - -
- -## Notes - -- The function does **not** deep copy nested array elements. - -
- - - -
- -## Examples - - - -```javascript -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var take2d = require( '@stdlib/array/base/take2d' ); - -// Generate a random array: -var shape = [ 5, 5 ]; -var x = filled2dBy( shape, discreteUniform.factory( 0, 100 ) ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, shape[1]-1 ) ); -console.log( indices ); - -// Take a random sample of elements from `x`: -var y = take2d( x, indices, 1, 'throw' ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/take2d/benchmark/benchmark.js b/base/take2d/benchmark/benchmark.js deleted file mode 100644 index 1186e760a..000000000 --- a/base/take2d/benchmark/benchmark.js +++ /dev/null @@ -1,111 +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 bench = require( '@stdlib/bench' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var take2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var dim; - var idx; - var S; - var x; - - dim = shape.length - 1; - S = shape[ dim ]; - - x = filled2dBy( shape, discreteUniform( -50, 50 ) ); - idx = filledBy( S, discreteUniform( -S, S-1 ) ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = take2d( x, idx, dim, 'normalize' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var shape; - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - shape = [ N, N ]; - f = createBenchmark( shape ); - bench( pkg+'::square_matrix,unsorted_indices:size='+numel(shape)+',num_indices='+N, f ); - } -} - -main(); diff --git a/base/take2d/docs/repl.txt b/base/take2d/docs/repl.txt deleted file mode 100644 index 6e8917354..000000000 --- a/base/take2d/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( x, indices, dimension, mode ) - Takes elements from a two-dimensional nested array. - - If `indices` is an empty array, the function returns empty arrays along the - specified dimension. - - The function does *not* deep copy nested array elements. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - indices: ArrayLikeObject - List of indices. - - dimension: integer - Dimension along which to take elements. If provided a negative integer, - the dimension is resolved relative to the last dimension, with the last - dimension being -1. - - mode: string - Specifies how to handle an index which exceeds array dimensions. If - equal to 'throw', the function throws an error when an index exceeds - array dimensions. If equal to 'normalize', the function normalizes - negative indices and throws an error when an index exceeds array - dimensions. If equal to 'wrap', the function wraps around an index - exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', the function sets an index exceeding array dimensions to - either 0 (minimum index) or the maximum index. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var idx = [ 1, 1, 0, 0, -1, -1 ]; - > var y = {{alias}}( x, idx, 1, 'normalize' ) - [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] - - See Also - -------- - diff --git a/base/take2d/docs/types/index.d.ts b/base/take2d/docs/types/index.d.ts deleted file mode 100644 index db9ef1dae..000000000 --- a/base/take2d/docs/types/index.d.ts +++ /dev/null @@ -1,110 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, Collection } from '@stdlib/types/array'; -import { Mode } from '@stdlib/types/ndarray'; - -/** -* Input nested array. -*/ -type NestedArray = ArrayLike>; - -/** -* Output array when operating along the first dimension. -*/ -type OutputArrayDim0 = Array>; - -/** -* Output array when operating along the second dimension. -*/ -type OutputArrayDim1 = Array>; - -/** -* Takes elements from a two-dimensional nested array. -* -* ## Notes -* -* - The function does **not** deep copy nested array elements. -* -* @param x - input nested array -* @param indices - list of indices -* @param dimension - dimension along which to take elements -* @param mode - index mode specifying how to handle an index which is out-of-bounds -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var indices = [ 1, -2 ]; -* -* var y = take2d( x, indices, 0, 'normalize' ); -* // returns [ [ 3, 4 ], [ 1, 2 ] ] -*/ -declare function take2d( x: NestedArray, indices: Collection, dimension: 0, mode: Mode ): OutputArrayDim0; - -/** -* Takes elements from a two-dimensional nested array. -* -* ## Notes -* -* - The function does **not** deep copy nested array elements. -* -* @param x - input nested array -* @param indices - list of indices -* @param dimension - dimension along which to take elements -* @param mode - index mode specifying how to handle an index which is out-of-bounds -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var indices = [ 1, 1, 0, 0, -1, -1 ]; -* -* var y = take2d( x, indices, 1, 'normalize' ); -* // returns [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] -*/ -declare function take2d( x: NestedArray, indices: Collection, dimension: 1, mode: Mode ): OutputArrayDim1; - -/** -* Takes elements from a two-dimensional nested array. -* -* ## Notes -* -* - The function does **not** deep copy nested array elements. -* -* @param x - input nested array -* @param indices - list of indices -* @param dimension - dimension along which to take elements -* @param mode - index mode specifying how to handle an index which is out-of-bounds -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var indices = [ 1, 1, 0, 0, -1, -1 ]; -* -* var y = take2d( x, indices, 1, 'normalize' ); -* // returns [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] -*/ -declare function take2d( x: NestedArray, indices: Collection, dimension: number, mode: Mode ): NestedArray; - - -// EXPORTS // - -export = take2d; diff --git a/base/take2d/docs/types/test.ts b/base/take2d/docs/types/test.ts deleted file mode 100644 index 47ca9774b..000000000 --- a/base/take2d/docs/types/test.ts +++ /dev/null @@ -1,93 +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. -*/ - -import take2d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - take2d( x, [ 0, 1 ], 0, 'throw' ); // $ExpectType OutputArrayDim0 - take2d( x, [ 0, 1 ], 1, 'throw' ); // $ExpectType OutputArrayDim1 -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - take2d( 1, [ 0, 1 ], 1, 'throw' ); // $ExpectError - take2d( true, [ 0, 1 ], 1, 'throw' ); // $ExpectError - take2d( false, [ 0, 1 ], 1, 'throw' ); // $ExpectError - take2d( null, [ 0, 1 ], 1, 'throw' ); // $ExpectError - take2d( void 0, [ 0, 1 ], 1, 'throw' ); // $ExpectError - take2d( {}, [ 0, 1 ], 1, 'throw' ); // $ExpectError - take2d( ( x: number ): number => x, [ 0, 1 ], 1, 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - take2d( x, '5', 1, 'throw' ); // $ExpectError - take2d( x, 1, 1, 'throw' ); // $ExpectError - take2d( x, true, 1, 'throw' ); // $ExpectError - take2d( x, false, 1, 'throw' ); // $ExpectError - take2d( x, null, 1, 'throw' ); // $ExpectError - take2d( x, void 0, 1, 'throw' ); // $ExpectError - take2d( x, {}, 1, 'throw' ); // $ExpectError - take2d( x, ( x: number ): number => x, 1, 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - take2d( x, [ 0, 1 ], '5', 'throw' ); // $ExpectError - take2d( x, [ 0, 1 ], true, 'throw' ); // $ExpectError - take2d( x, [ 0, 1 ], false, 'throw' ); // $ExpectError - take2d( x, [ 0, 1 ], null, 'throw' ); // $ExpectError - take2d( x, [ 0, 1 ], void 0, 'throw' ); // $ExpectError - take2d( x, [ 0, 1 ], {}, 'throw' ); // $ExpectError - take2d( x, [ 0, 1 ], ( x: number ): number => x, 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a recognized index mode... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - take2d( x, [ 0, 1 ], 1, '5' ); // $ExpectError - take2d( x, [ 0, 1 ], 1, 1 ); // $ExpectError - take2d( x, [ 0, 1 ], 1, true ); // $ExpectError - take2d( x, [ 0, 1 ], 1, false ); // $ExpectError - take2d( x, [ 0, 1 ], 1, null ); // $ExpectError - take2d( x, [ 0, 1 ], 1, void 0 ); // $ExpectError - take2d( x, [ 0, 1 ], 1, {} ); // $ExpectError - take2d( x, [ 0, 1 ], 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1, 2 ], [ 3, 4 ] ]; - - take2d(); // $ExpectError - take2d( x ); // $ExpectError - take2d( x, [ 0, 1 ] ); // $ExpectError - take2d( x, [ 0, 1 ], 1 ); // $ExpectError - take2d( x, [ 0, 1 ], 1, 'throw', {} ); // $ExpectError -} diff --git a/base/take2d/examples/index.js b/base/take2d/examples/index.js deleted file mode 100644 index 18666dbec..000000000 --- a/base/take2d/examples/index.js +++ /dev/null @@ -1,38 +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'; - -var filled2dBy = require( './../../../base/filled2d-by' ); -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var take2d = require( './../lib' ); - -// Generate a random array: -var shape = [ 5, 5 ]; -var x = filled2dBy( shape, discreteUniform.factory( 0, 100 ) ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, shape[1]-1 ) ); -console.log( indices ); - -// Take a random sample of elements from `x`: -var y = take2d( x, indices, 1, 'throw' ); -console.log( y ); diff --git a/base/take2d/lib/index.js b/base/take2d/lib/index.js deleted file mode 100644 index f62cc8148..000000000 --- a/base/take2d/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Take elements from a two-dimensional nested array. -* -* @module @stdlib/array/base/take2d -* -* @example -* var take2d = require( '@stdlib/array/base/take2d' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var indices = [ 1, 1, 0, 0, -1, -1 ]; -* -* var y = take2d( x, indices, 1, 'normalize' ); -* // returns [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/take2d/lib/main.js b/base/take2d/lib/main.js deleted file mode 100644 index 84e9b87f6..000000000 --- a/base/take2d/lib/main.js +++ /dev/null @@ -1,99 +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 normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); -var indexFunction = require( '@stdlib/ndarray/base/ind' ).factory; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var NDIMS = 2; - - -// MAIN // - -/** -* Takes elements from a two-dimensional nested array. -* -* ## Notes -* -* - The function does **not** deep copy nested array elements. -* -* @param {ArrayLikeObject} x - input array -* @param {NonNegativeIntegerArray} indices - list of indices -* @param {integer} dimension - dimension along which to take elements -* @param {string} mode - index mode specifying how to handle an index which is out-of-bounds -* @throws {RangeError} third argument exceeds the number of dimensions -* @throws {TypeError} fourth argument must be a recognized index mode -* @returns {(Array|Array)} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var indices = [ 1, 1, 0, 0, -1, -1 ]; -* -* var y = take2d( x, indices, 1, 'normalize' ); -* // returns [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] -*/ -function take2d( x, indices, dimension, mode ) { - var lastIndex; - var out; - var dim; - var ind; - var idx; - var i0; - var i1; - var x0; - var y0; - - dim = normalizeIndex( dimension, NDIMS-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Third argument exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', NDIMS, dimension ) ); - } - ind = indexFunction( mode ); - out = []; - if ( dim === 0 ) { - lastIndex = x.length - 1; - for ( i1 = 0; i1 < indices.length; i1++ ) { - idx = ind( indices[ i1 ], lastIndex ); - out.push( x[ idx ] ); - } - return out; - } - // Case: dim === 1 - for ( i1 = 0; i1 < x.length; i1++ ) { - x0 = x[ i1 ]; - y0 = []; - lastIndex = x0.length - 1; - for ( i0 = 0; i0 < indices.length; i0++ ) { - idx = ind( indices[ i0 ], lastIndex ); - y0.push( x0[ idx ] ); - } - out.push( y0 ); - } - return out; -} - - -// EXPORTS // - -module.exports = take2d; diff --git a/base/take2d/package.json b/base/take2d/package.json deleted file mode 100644 index 000477dd4..000000000 --- a/base/take2d/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/take2d", - "version": "0.0.0", - "description": "Take elements from a two-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index", - "nested", - "multidimensional", - "ndarray", - "matrix", - "tensor", - "2d" - ] -} diff --git a/base/take2d/test/test.js b/base/take2d/test/test.js deleted file mode 100644 index 142dedf69..000000000 --- a/base/take2d/test/test.js +++ /dev/null @@ -1,465 +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 zeros2d = require( './../../../base/zeros2d' ); -var take2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof take2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a dimension which is out-of-bounds', function test( t ) { - var values; - var i; - - values = [ - 99, - 999, - 9999, - 99999 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - take2d( zeros2d( [ 3, 3 ] ), [ 0, 1 ], value, 'throw' ); - }; - } -}); - -tape( 'the function takes elements from a nested array (dim=0,mode=throw)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - indices = [ 0, 1 ]; - actual = take2d( x, indices, 0, 'throw' ); - expected = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take2d( x, indices, 0, 'throw' ); - expected = [ - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 0, 0 ]; - actual = take2d( x, indices, 0, 'throw' ); - expected = [ - [ 1, 2 ], - [ 1, 2 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1 ]; - actual = take2d( x, indices, 0, 'throw' ); - expected = [ - [ 3, 4 ], - [ 3, 4 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=1,mode=throw)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - indices = [ 0, 1 ]; - actual = take2d( x, indices, 1, 'throw' ); - expected = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take2d( x, indices, 1, 'throw' ); - expected = [ - [ 2 ], - [ 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 0, 0 ]; - actual = take2d( x, indices, 1, 'throw' ); - expected = [ - [ 1, 1 ], - [ 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1 ]; - actual = take2d( x, indices, 1, 'throw' ); - expected = [ - [ 2, 2, 2 ], - [ 4, 4, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=0,mode=normalize)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - indices = [ 0, -1 ]; - actual = take2d( x, indices, 0, 'normalize' ); - expected = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take2d( x, indices, 0, 'normalize' ); - expected = [ - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ -2, 0 ]; - actual = take2d( x, indices, 0, 'normalize' ); - expected = [ - [ 1, 2 ], - [ 1, 2 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, -1, 1 ]; - actual = take2d( x, indices, 0, 'normalize' ); - expected = [ - [ 3, 4 ], - [ 3, 4 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=1,mode=normalize)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - indices = [ 0, -1 ]; - actual = take2d( x, indices, 1, 'normalize' ); - expected = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take2d( x, indices, 1, 'normalize' ); - expected = [ - [ 2 ], - [ 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ -2, 0 ]; - actual = take2d( x, indices, 1, 'normalize' ); - expected = [ - [ 1, 1 ], - [ 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, -1, 1 ]; - actual = take2d( x, indices, 1, 'normalize' ); - expected = [ - [ 2, 2, 2 ], - [ 4, 4, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=0,mode=clamp)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - indices = [ 0, 10 ]; - actual = take2d( x, indices, 0, 'clamp' ); - expected = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take2d( x, indices, 0, 'clamp' ); - expected = [ - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ -10, 0 ]; - actual = take2d( x, indices, 0, 'clamp' ); - expected = [ - [ 1, 2 ], - [ 1, 2 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 100 ]; - actual = take2d( x, indices, 0, 'clamp' ); - expected = [ - [ 3, 4 ], - [ 3, 4 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=1,mode=clamp)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - indices = [ 0, 10 ]; - actual = take2d( x, indices, 1, 'clamp' ); - expected = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take2d( x, indices, 1, 'clamp' ); - expected = [ - [ 2 ], - [ 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ -10, 0 ]; - actual = take2d( x, indices, 1, 'clamp' ); - expected = [ - [ 1, 1 ], - [ 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 100 ]; - actual = take2d( x, indices, 1, 'clamp' ); - expected = [ - [ 2, 2, 2 ], - [ 4, 4, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=0,mode=wrap)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - indices = [ 0, 3 ]; - actual = take2d( x, indices, 0, 'wrap' ); - expected = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take2d( x, indices, 0, 'wrap' ); - expected = [ - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 0, 4 ]; - actual = take2d( x, indices, 0, 'wrap' ); - expected = [ - [ 1, 2 ], - [ 1, 2 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, -3, 1 ]; - actual = take2d( x, indices, 0, 'wrap' ); - expected = [ - [ 3, 4 ], - [ 3, 4 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=1,mode=wrap)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - indices = [ 0, 3 ]; - actual = take2d( x, indices, 1, 'wrap' ); - expected = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take2d( x, indices, 1, 'wrap' ); - expected = [ - [ 2 ], - [ 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 0, 4 ]; - actual = take2d( x, indices, 1, 'wrap' ); - expected = [ - [ 1, 1 ], - [ 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, -3, 1 ]; - actual = take2d( x, indices, 1, 'wrap' ); - expected = [ - [ 2, 2, 2 ], - [ 4, 4, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided a second argument which is empty (dim=0)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - indices = []; - actual = take2d( x, indices, 0, 'throw' ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided a second argument which is empty (dim=1)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ 1, 2 ], - [ 3, 4 ] - ]; - - indices = []; - actual = take2d( x, indices, 1, 'throw' ); - expected = [ - [], - [] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/take3d/README.md b/base/take3d/README.md deleted file mode 100644 index 742d4c043..000000000 --- a/base/take3d/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# take3d - -> Take elements from a three-dimensional nested array. - -
- -## Usage - -```javascript -var take3d = require( '@stdlib/array/base/take3d' ); -``` - -#### take3d( x, indices, dimension, mode ) - -Takes elements along a specified `dimension` from a three-dimensional nested array according to a specified [index `mode`][@stdlib/ndarray/index-modes]. - -```javascript -var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -var indices = [ 1, 1, 0, 0, -1, -1 ]; - -var y = take3d( x, indices, 2, 'normalize' ); -// returns [ [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] ] -``` - -The function accepts the following arguments: - -- **x**: input nested array. -- **indices**: list of indices. -- **dimension**: dimension along which to take elements. If provided a negative integer, the dimension is resolved relative to the last dimension, with the last dimension being `-1`. -- **mode**: [index mode][@stdlib/ndarray/index-modes] specifying how to handle an index which is out-of-bounds. - -If `indices` is an empty array, the function returns empty arrays along the specified `dimension`. - -```javascript -var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - -var y = take3d( x, [], 0, 'throw' ); -// returns [] - -var z = take3d( x, [], 1, 'throw' ); -// returns [ [] ] - -var w = take3d( x, [], 2, 'throw' ); -// returns [ [ [], [] ] ] -``` - -
- - - -
- -## Notes - -- The function does **not** deep copy nested array elements. - -
- - - -
- -## Examples - - - -```javascript -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var take3d = require( '@stdlib/array/base/take3d' ); - -// Generate a random array: -var shape = [ 3, 3, 3 ]; -var x = filled3dBy( shape, discreteUniform.factory( 0, 100 ) ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 1, 5 ); -var indices = filledBy( N, discreteUniform.factory( 0, shape[2]-1 ) ); -console.log( indices ); - -// Take a random sample of elements from `x`: -var y = take3d( x, indices, 2, 'throw' ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/take3d/benchmark/benchmark.js b/base/take3d/benchmark/benchmark.js deleted file mode 100644 index 6e18f72a8..000000000 --- a/base/take3d/benchmark/benchmark.js +++ /dev/null @@ -1,111 +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 bench = require( '@stdlib/bench' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var take3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var dim; - var idx; - var S; - var x; - - dim = shape.length - 1; - S = shape[ dim ]; - - x = filled3dBy( shape, discreteUniform( -50, 50 ) ); - idx = filledBy( S, discreteUniform( -S, S-1 ) ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = take3d( x, idx, dim, 'normalize' ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var shape; - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - shape = [ N, N, N ]; - f = createBenchmark( shape ); - bench( pkg+'::equidimensional,unsorted_indices:size='+numel(shape)+',num_indices='+N, f ); - } -} - -main(); diff --git a/base/take3d/docs/repl.txt b/base/take3d/docs/repl.txt deleted file mode 100644 index 50ab65544..000000000 --- a/base/take3d/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( x, indices, dimension, mode ) - Takes elements from a three-dimensional nested array. - - If `indices` is an empty array, the function returns empty arrays along the - specified dimension. - - The function does *not* deep copy nested array elements. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - indices: ArrayLikeObject - List of indices. - - dimension: integer - Dimension along which to take elements. If provided a negative integer, - the dimension is resolved relative to the last dimension, with the last - dimension being -1. - - mode: string - Specifies how to handle an index which exceeds array dimensions. If - equal to 'throw', the function throws an error when an index exceeds - array dimensions. If equal to 'normalize', the function normalizes - negative indices and throws an error when an index exceeds array - dimensions. If equal to 'wrap', the function wraps around an index - exceeding array dimensions using modulo arithmetic. If equal to - 'clamp', the function sets an index exceeding array dimensions to - either 0 (minimum index) or the maximum index. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - > var idx = [ 1, 1, 0, 0, -1, -1 ]; - > var y = {{alias}}( x, idx, 2, 'normalize' ) - [ [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] ] - - See Also - -------- - diff --git a/base/take3d/docs/types/index.d.ts b/base/take3d/docs/types/index.d.ts deleted file mode 100644 index b6ceb8159..000000000 --- a/base/take3d/docs/types/index.d.ts +++ /dev/null @@ -1,137 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, Collection } from '@stdlib/types/array'; -import { Mode } from '@stdlib/types/ndarray'; - -/** -* Input nested array. -*/ -type NestedArray = ArrayLike>>; - -/** -* Output array when operating along the first dimension. -*/ -type OutputArrayDim0 = Array>>; - -/** -* Output array when operating along the second dimension. -*/ -type OutputArrayDim1 = Array>>; - -/** -* Output array when operating along the third dimension. -*/ -type OutputArrayDim2 = Array>>; - -/** -* Takes elements from a three-dimensional nested array. -* -* ## Notes -* -* - The function does **not** deep copy nested array elements. -* -* @param x - input nested array -* @param indices - list of indices -* @param dimension - dimension along which to take elements -* @param mode - index mode specifying how to handle an index which is out-of-bounds -* @returns output array -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -* var indices = [ 0, 0 ]; -* -* var y = take3d( x, indices, 0, 'normalize' ); -* // returns [ [ [ 1, 2 ], [ 3, 4 ] ], [ [ 1, 2 ], [ 3, 4 ] ] ] -*/ -declare function take3d( x: NestedArray, indices: Collection, dimension: 0, mode: Mode ): OutputArrayDim0; - -/** -* Takes elements from a three-dimensional nested array. -* -* ## Notes -* -* - The function does **not** deep copy nested array elements. -* -* @param x - input nested array -* @param indices - list of indices -* @param dimension - dimension along which to take elements -* @param mode - index mode specifying how to handle an index which is out-of-bounds -* @returns output array -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -* var indices = [ 1, -2 ]; -* -* var y = take3d( x, indices, 1, 'normalize' ); -* // returns [ [ [ 3, 4 ], [ 1, 2 ] ] ] -*/ -declare function take3d( x: NestedArray, indices: Collection, dimension: 1, mode: Mode ): OutputArrayDim1; - -/** -* Takes elements from a three-dimensional nested array. -* -* ## Notes -* -* - The function does **not** deep copy nested array elements. -* -* @param x - input nested array -* @param indices - list of indices -* @param dimension - dimension along which to take elements -* @param mode - index mode specifying how to handle an index which is out-of-bounds -* @returns output array -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -* var indices = [ 1, 1, 0, 0, -1, -1 ]; -* -* var y = take3d( x, indices, 2, 'normalize' ); -* // returns [ [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] ] -*/ -declare function take3d( x: NestedArray, indices: Collection, dimension: 2, mode: Mode ): OutputArrayDim2; - -/** -* Takes elements from a three-dimensional nested array. -* -* ## Notes -* -* - The function does **not** deep copy nested array elements. -* -* @param x - input nested array -* @param indices - list of indices -* @param dimension - dimension along which to take elements -* @param mode - index mode specifying how to handle an index which is out-of-bounds -* @returns output array -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -* var indices = [ 1, 1, 0, 0, -1, -1 ]; -* -* var y = take3d( x, indices, 2, 'normalize' ); -* // returns [ [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] ] -*/ -declare function take3d( x: NestedArray, indices: Collection, dimension: number, mode: Mode ): NestedArray; - - -// EXPORTS // - -export = take3d; diff --git a/base/take3d/docs/types/test.ts b/base/take3d/docs/types/test.ts deleted file mode 100644 index 73f043af4..000000000 --- a/base/take3d/docs/types/test.ts +++ /dev/null @@ -1,94 +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. -*/ - -import take3d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - take3d( x, [ 0, 0 ], 0, 'throw' ); // $ExpectType OutputArrayDim0 - take3d( x, [ 0, 0 ], 1, 'throw' ); // $ExpectType OutputArrayDim1 - take3d( x, [ 0, 0 ], 2, 'throw' ); // $ExpectType OutputArrayDim2 -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - take3d( 1, [ 0, 0 ], 1, 'throw' ); // $ExpectError - take3d( true, [ 0, 0 ], 1, 'throw' ); // $ExpectError - take3d( false, [ 0, 0 ], 1, 'throw' ); // $ExpectError - take3d( null, [ 0, 0 ], 1, 'throw' ); // $ExpectError - take3d( void 0, [ 0, 0 ], 1, 'throw' ); // $ExpectError - take3d( {}, [ 0, 0 ], 1, 'throw' ); // $ExpectError - take3d( ( x: number ): number => x, [ 0, 0 ], 1, 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - take3d( x, '5', 1, 'throw' ); // $ExpectError - take3d( x, 1, 1, 'throw' ); // $ExpectError - take3d( x, true, 1, 'throw' ); // $ExpectError - take3d( x, false, 1, 'throw' ); // $ExpectError - take3d( x, null, 1, 'throw' ); // $ExpectError - take3d( x, void 0, 0, 'throw' ); // $ExpectError - take3d( x, {}, 1, 'throw' ); // $ExpectError - take3d( x, ( x: number ): number => x, 1, 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - take3d( x, [ 0, 0 ], '5', 'throw' ); // $ExpectError - take3d( x, [ 0, 0 ], true, 'throw' ); // $ExpectError - take3d( x, [ 0, 0 ], false, 'throw' ); // $ExpectError - take3d( x, [ 0, 0 ], null, 'throw' ); // $ExpectError - take3d( x, [ 0, 0 ], void 0, 'throw' ); // $ExpectError - take3d( x, [ 0, 0 ], {}, 'throw' ); // $ExpectError - take3d( x, [ 0, 0 ], ( x: number ): number => x, 'throw' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a recognized index mode... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - take3d( x, [ 0, 0 ], 1, '5' ); // $ExpectError - take3d( x, [ 0, 0 ], 1, 1 ); // $ExpectError - take3d( x, [ 0, 0 ], 1, true ); // $ExpectError - take3d( x, [ 0, 0 ], 1, false ); // $ExpectError - take3d( x, [ 0, 0 ], 1, null ); // $ExpectError - take3d( x, [ 0, 0 ], 1, void 0 ); // $ExpectError - take3d( x, [ 0, 0 ], 1, {} ); // $ExpectError - take3d( x, [ 0, 0 ], 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; - - take3d(); // $ExpectError - take3d( x ); // $ExpectError - take3d( x, [ 0, 0 ] ); // $ExpectError - take3d( x, [ 0, 0 ], 1 ); // $ExpectError - take3d( x, [ 0, 0 ], 1, 'throw', {} ); // $ExpectError -} diff --git a/base/take3d/examples/index.js b/base/take3d/examples/index.js deleted file mode 100644 index d5a77cab5..000000000 --- a/base/take3d/examples/index.js +++ /dev/null @@ -1,38 +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'; - -var filled3dBy = require( './../../../base/filled3d-by' ); -var filledBy = require( './../../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var take3d = require( './../lib' ); - -// Generate a random array: -var shape = [ 3, 3, 3 ]; -var x = filled3dBy( shape, discreteUniform.factory( 0, 100 ) ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 1, 5 ); -var indices = filledBy( N, discreteUniform.factory( 0, shape[2]-1 ) ); -console.log( indices ); - -// Take a random sample of elements from `x`: -var y = take3d( x, indices, 2, 'throw' ); -console.log( y ); diff --git a/base/take3d/lib/index.js b/base/take3d/lib/index.js deleted file mode 100644 index ad5098a53..000000000 --- a/base/take3d/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Take elements from a three-dimensional nested array. -* -* @module @stdlib/array/base/take3d -* -* @example -* var take3d = require( '@stdlib/array/base/take3d' ); -* -* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -* var indices = [ 1, 1, 0, 0, -1, -1 ]; -* -* var y = take3d( x, indices, 2, 'normalize' ); -* // returns [ [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/take3d/lib/main.js b/base/take3d/lib/main.js deleted file mode 100644 index 7a0d28ab9..000000000 --- a/base/take3d/lib/main.js +++ /dev/null @@ -1,91 +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 normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); -var indexFunction = require( '@stdlib/ndarray/base/ind' ).factory; -var take2d = require( './../../../base/take2d' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var NDIMS = 3; - - -// MAIN // - -/** -* Takes elements from a three-dimensional nested array. -* -* ## Notes -* -* - The function does **not** deep copy nested array elements. -* -* @param {ArrayLikeObject} x - input array -* @param {NonNegativeIntegerArray} indices - list of indices -* @param {integer} dimension - dimension along which to take elements -* @param {string} mode - index mode specifying how to handle an index which is out-of-bounds -* @throws {RangeError} third argument exceeds the number of dimensions -* @throws {TypeError} fourth argument must be a recognized index mode -* @returns {(Array|Array)} output array -* -* @example -* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ]; -* var indices = [ 1, 1, 0, 0, -1, -1 ]; -* -* var y = take3d( x, indices, 2, 'normalize' ); -* // returns [ [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] ] -*/ -function take3d( x, indices, dimension, mode ) { - var lastIndex; - var out; - var dim; - var ind; - var idx; - var i; - - dim = normalizeIndex( dimension, NDIMS-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Third argument exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', NDIMS, dimension ) ); - } - out = []; - if ( dim === 0 ) { - ind = indexFunction( mode ); - lastIndex = x.length - 1; - for ( i = 0; i < indices.length; i++ ) { - idx = ind( indices[ i ], lastIndex ); - out.push( x[ idx ] ); - } - return out; - } - // Case: dim > 0 - dim = dimension - 1; - for ( i = 0; i < x.length; i++ ) { - out.push( take2d( x[ i ], indices, dim, mode ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = take3d; diff --git a/base/take3d/package.json b/base/take3d/package.json deleted file mode 100644 index d65e10b71..000000000 --- a/base/take3d/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/take3d", - "version": "0.0.0", - "description": "Take elements from a three-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index", - "nested", - "multidimensional", - "ndarray", - "matrix", - "tensor", - "3d" - ] -} diff --git a/base/take3d/test/test.js b/base/take3d/test/test.js deleted file mode 100644 index 4388861d0..000000000 --- a/base/take3d/test/test.js +++ /dev/null @@ -1,734 +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 zeros3d = require( './../../../base/zeros3d' ); -var take3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof take3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a dimension which is out-of-bounds', function test( t ) { - var values; - var i; - - values = [ - 99, - 999, - 9999, - 99999 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - take3d( zeros3d( [ 3, 3, 3 ] ), [ 0, 1 ], value, 'throw' ); - }; - } -}); - -tape( 'the function takes elements from a nested array (dim=0,mode=throw)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, 0 ]; - actual = take3d( x, indices, 0, 'throw' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 0 ]; - actual = take3d( x, indices, 0, 'throw' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=1,mode=throw)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, 1 ]; - actual = take3d( x, indices, 1, 'throw' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take3d( x, indices, 1, 'throw' ); - expected = [ - [ - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 0, 0 ]; - actual = take3d( x, indices, 1, 'throw' ); - expected = [ - [ - [ 1, 2 ], - [ 1, 2 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1 ]; - actual = take3d( x, indices, 1, 'throw' ); - expected = [ - [ - [ 3, 4 ], - [ 3, 4 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=2,mode=throw)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, 1 ]; - actual = take3d( x, indices, 2, 'throw' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take3d( x, indices, 2, 'throw' ); - expected = [ - [ - [ 2 ], - [ 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 0, 0 ]; - actual = take3d( x, indices, 2, 'throw' ); - expected = [ - [ - [ 1, 1 ], - [ 3, 3 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1 ]; - actual = take3d( x, indices, 2, 'throw' ); - expected = [ - [ - [ 2, 2, 2 ], - [ 4, 4, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=0,mode=normalize)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, -1 ]; - actual = take3d( x, indices, 0, 'normalize' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ -1 ]; - actual = take3d( x, indices, 0, 'normalize' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=1,mode=normalize)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, -1 ]; - actual = take3d( x, indices, 1, 'normalize' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take3d( x, indices, 1, 'normalize' ); - expected = [ - [ - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ -2, 0 ]; - actual = take3d( x, indices, 1, 'normalize' ); - expected = [ - [ - [ 1, 2 ], - [ 1, 2 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, -1, 1 ]; - actual = take3d( x, indices, 1, 'normalize' ); - expected = [ - [ - [ 3, 4 ], - [ 3, 4 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=2,mode=normalize)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, -1 ]; - actual = take3d( x, indices, 2, 'normalize' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take3d( x, indices, 2, 'normalize' ); - expected = [ - [ - [ 2 ], - [ 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ -2, 0 ]; - actual = take3d( x, indices, 2, 'normalize' ); - expected = [ - [ - [ 1, 1 ], - [ 3, 3 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, -1, 1 ]; - actual = take3d( x, indices, 2, 'normalize' ); - expected = [ - [ - [ 2, 2, 2 ], - [ 4, 4, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=0,mode=clamp)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, 10 ]; - actual = take3d( x, indices, 0, 'clamp' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 100 ]; - actual = take3d( x, indices, 0, 'clamp' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=1,mode=clamp)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, 10 ]; - actual = take3d( x, indices, 1, 'clamp' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take3d( x, indices, 1, 'clamp' ); - expected = [ - [ - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ -10, 0 ]; - actual = take3d( x, indices, 1, 'clamp' ); - expected = [ - [ - [ 1, 2 ], - [ 1, 2 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 100 ]; - actual = take3d( x, indices, 1, 'clamp' ); - expected = [ - [ - [ 3, 4 ], - [ 3, 4 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=2,mode=clamp)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, 10 ]; - actual = take3d( x, indices, 2, 'clamp' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take3d( x, indices, 2, 'clamp' ); - expected = [ - [ - [ 2 ], - [ 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ -10, 0 ]; - actual = take3d( x, indices, 2, 'clamp' ); - expected = [ - [ - [ 1, 1 ], - [ 3, 3 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 100 ]; - actual = take3d( x, indices, 2, 'clamp' ); - expected = [ - [ - [ 2, 2, 2 ], - [ 4, 4, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=0,mode=wrap)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, 3 ]; - actual = take3d( x, indices, 0, 'wrap' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ], - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 10 ]; - actual = take3d( x, indices, 0, 'wrap' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=1,mode=wrap)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, 3 ]; - actual = take3d( x, indices, 1, 'wrap' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take3d( x, indices, 1, 'wrap' ); - expected = [ - [ - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 0, 4 ]; - actual = take3d( x, indices, 1, 'wrap' ); - expected = [ - [ - [ 1, 2 ], - [ 1, 2 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, -3, 1 ]; - actual = take3d( x, indices, 1, 'wrap' ); - expected = [ - [ - [ 3, 4 ], - [ 3, 4 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from a nested array (dim=2,mode=wrap)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = [ 0, 3 ]; - actual = take3d( x, indices, 2, 'wrap' ); - expected = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1 ]; - actual = take3d( x, indices, 2, 'wrap' ); - expected = [ - [ - [ 2 ], - [ 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 0, 4 ]; - actual = take3d( x, indices, 2, 'wrap' ); - expected = [ - [ - [ 1, 1 ], - [ 3, 3 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, -3, 1 ]; - actual = take3d( x, indices, 2, 'wrap' ); - expected = [ - [ - [ 2, 2, 2 ], - [ 4, 4, 4 ] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided a second argument which is empty (dim=0)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = []; - actual = take3d( x, indices, 0, 'throw' ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided a second argument which is empty (dim=1)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = []; - actual = take3d( x, indices, 1, 'throw' ); - expected = [ - [] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty arrays if provided a second argument which is empty (dim=2)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ - [ - [ 1, 2 ], - [ 3, 4 ] - ] - ]; - - indices = []; - actual = take3d( x, indices, 2, 'throw' ); - expected = [ - [ - [], - [] - ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/ternary2d/README.md b/base/ternary2d/README.md deleted file mode 100644 index 7eeb1bcce..000000000 --- a/base/ternary2d/README.md +++ /dev/null @@ -1,125 +0,0 @@ - - -# ternary2d - -> Apply a ternary callback to elements in three two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var ternary2d = require( '@stdlib/array/base/ternary2d' ); -``` - -#### ternary2d( arrays, shape, fcn ) - -Applies a ternary callback to elements in three two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); - -var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; -var out = zeros2d( [ 2, 2 ] ); - -var shape = [ 2, 2 ]; - -ternary2d( [ x, x, x, out ], shape, add ); -// out => [ [ 3.0, 6.0 ], [ 9.0, 12.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing three input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: ternary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var ternary2d = require( '@stdlib/array/base/ternary2d' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros2d( shape ); -console.log( out ); - -ternary2d( [ x, y, z, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/ternary2d/benchmark/benchmark.js b/base/ternary2d/benchmark/benchmark.js deleted file mode 100644 index fa72c3df5..000000000 --- a/base/ternary2d/benchmark/benchmark.js +++ /dev/null @@ -1,120 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var pkg = require( './../package.json' ).name; -var ternary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - - x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros2d( shape ); - - arrays = [ x, y, z, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ternary2d( arrays, shape, add ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 3 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 3 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/ternary2d/docs/repl.txt b/base/ternary2d/docs/repl.txt deleted file mode 100644 index 8cd7d1677..000000000 --- a/base/ternary2d/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a ternary callback to elements in three two-dimensional nested input - arrays and assigns results to elements in a two-dimensional nested output - array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing three input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Ternary callback. - - Examples - -------- - > function fcn( x, y, z ) { return x + y + z }; - > var x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - > var out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shape = [ 2, 2 ]; - > {{alias}}( [ x, y, z, out ], shape, fcn ); - > out - [ [ 3.0, 6.0 ], [ 9.0, 12.0 ] ] - - See Also - -------- - diff --git a/base/ternary2d/docs/types/index.d.ts b/base/ternary2d/docs/types/index.d.ts deleted file mode 100644 index 15f2148d5..000000000 --- a/base/ternary2d/docs/types/index.d.ts +++ /dev/null @@ -1,69 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Ternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @returns result -*/ -type Ternary = ( v1: T, v2: U, v3: V ) => W; - -/** -* Applies a ternary callback to elements in three two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing three input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - ternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = ones2d( shape ); -* var out = zeros2d( shape ); -* -* ternary2d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] -*/ -declare function ternary2d( arrays: [ Array2D, Array2D, Array2D, Array2D ], shape: Shape2D, fcn: Ternary ): void; - - -// EXPORTS // - -export = ternary2d; diff --git a/base/ternary2d/docs/types/test.ts b/base/ternary2d/docs/types/test.ts deleted file mode 100644 index 33d34d910..000000000 --- a/base/ternary2d/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import ternary2d = require( './index' ); - -/** -* Ternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number ): number { - return x + y + z; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - ternary2d( [ x, y, z, out ], [ 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - ternary2d( 'abc', [ 2, 2 ], fcn ); // $ExpectError - ternary2d( 3.14, [ 2, 2 ], fcn ); // $ExpectError - ternary2d( true, [ 2, 2 ], fcn ); // $ExpectError - ternary2d( false, [ 2, 2 ], fcn ); // $ExpectError - ternary2d( null, [ 2, 2 ], fcn ); // $ExpectError - ternary2d( [ '1' ], [ 2, 2 ], fcn ); // $ExpectError - ternary2d( {}, [ 2, 2 ], fcn ); // $ExpectError - ternary2d( ( x: number ): number => x, [ 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - ternary2d( [ x, y, z, out ], 'abc', fcn ); // $ExpectError - ternary2d( [ x, y, z, out ], 3.14, fcn ); // $ExpectError - ternary2d( [ x, y, z, out ], true, fcn ); // $ExpectError - ternary2d( [ x, y, z, out ], false, fcn ); // $ExpectError - ternary2d( [ x, y, z, out ], null, fcn ); // $ExpectError - ternary2d( [ x, y, z, out ], [ '1' ], fcn ); // $ExpectError - ternary2d( [ x, y, z, out ], {}, fcn ); // $ExpectError - ternary2d( [ x, y, z, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - ternary2d( [ x, y, z, out ], [ 2, 2 ], 'abc' ); // $ExpectError - ternary2d( [ x, y, z, out ], [ 2, 2 ], 3.14 ); // $ExpectError - ternary2d( [ x, y, z, out ], [ 2, 2 ], true ); // $ExpectError - ternary2d( [ x, y, z, out ], [ 2, 2 ], false ); // $ExpectError - ternary2d( [ x, y, z, out ], [ 2, 2 ], null ); // $ExpectError - ternary2d( [ x, y, z, out ], [ 2, 2 ], [ '1' ] ); // $ExpectError - ternary2d( [ x, y, z, out ], [ 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const z = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const out = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - ternary2d(); // $ExpectError - ternary2d( [ x, y, z, out ] ); // $ExpectError - ternary2d( [ x, y, z, out ], [ 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/ternary2d/examples/index.js b/base/ternary2d/examples/index.js deleted file mode 100644 index a27cc95f9..000000000 --- a/base/ternary2d/examples/index.js +++ /dev/null @@ -1,42 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var ternary2d = require( './../lib' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros2d( shape ); -console.log( out ); - -ternary2d( [ x, y, z, out ], shape, add ); -console.log( out ); diff --git a/base/ternary2d/lib/index.js b/base/ternary2d/lib/index.js deleted file mode 100644 index 6c536d4a4..000000000 --- a/base/ternary2d/lib/index.js +++ /dev/null @@ -1,52 +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'; - -/** -* Apply a ternary callback to elements in three two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/ternary2d -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var ternary2d = require( '@stdlib/array/base/ternary2d' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = ones2d( shape ); -* var out = zeros2d( shape ); -* -* ternary2d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/ternary2d/lib/main.js b/base/ternary2d/lib/main.js deleted file mode 100644 index e67e04f27..000000000 --- a/base/ternary2d/lib/main.js +++ /dev/null @@ -1,89 +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'; - -// MAIN // - -/** -* Applies a ternary callback to elements in three two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - ternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = ones2d( shape ); -* var z = ones2d( shape ); -* var out = zeros2d( shape ); -* -* ternary2d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] -*/ -function ternary2d( arrays, shape, fcn ) { - var S0; - var S1; - var i0; - var i1; - var x0; - var y0; - var z0; - var w0; - var x; - var y; - var z; - var w; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x[ i1 ]; - y0 = y[ i1 ]; - z0 = z[ i1 ]; - w0 = w[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - w0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] ); - } - } -} - - -// EXPORTS // - -module.exports = ternary2d; diff --git a/base/ternary2d/package.json b/base/ternary2d/package.json deleted file mode 100644 index 47455baef..000000000 --- a/base/ternary2d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/ternary2d", - "version": "0.0.0", - "description": "Apply a ternary callback to elements in three two-dimensional nested input arrays and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "ternary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/ternary2d/test/test.js b/base/ternary2d/test/test.js deleted file mode 100644 index 8a7a4ae51..000000000 --- a/base/ternary2d/test/test.js +++ /dev/null @@ -1,136 +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 zeros2d = require( './../../../base/zeros2d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var ternary2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ternary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ]; - out = zeros2d( shape ); - - expected = [ - [ 15.0, 18.0 ], - [ 21.0, 24.0 ] - ]; - ternary2d( [ x, y, z, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ]; - out = zeros2d( shape ); - - expected = zeros2d( shape ); - ternary2d( [ x, y, z, out ], [ 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 2, 2 ]; - x = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - y = [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ]; - z = [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ]; - out = zeros2d( shape ); - - expected = zeros2d( shape ); - ternary2d( [ x, y, z, out ], [ 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/ternary3d/README.md b/base/ternary3d/README.md deleted file mode 100644 index cb7247459..000000000 --- a/base/ternary3d/README.md +++ /dev/null @@ -1,125 +0,0 @@ - - -# ternary3d - -> Apply a ternary callback to elements in three three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var ternary3d = require( '@stdlib/array/base/ternary3d' ); -``` - -#### ternary3d( arrays, shape, fcn ) - -Applies a ternary callback to elements in three three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); - -var x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; -var out = zeros3d( [ 1, 2, 2 ] ); - -var shape = [ 1, 2, 2 ]; - -ternary3d( [ x, x, x, out ], shape, add ); -// out => [ [ [ 3.0, 6.0 ], [ 9.0, 12.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing three input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: ternary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var ternary3d = require( '@stdlib/array/base/ternary3d' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros3d( shape ); -console.log( out ); - -ternary3d( [ x, y, z, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/ternary3d/benchmark/benchmark.js b/base/ternary3d/benchmark/benchmark.js deleted file mode 100644 index 01e8f36c5..000000000 --- a/base/ternary3d/benchmark/benchmark.js +++ /dev/null @@ -1,123 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var pkg = require( './../package.json' ).name; -var ternary3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - - x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros3d( shape ); - - arrays = [ x, y, z, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ternary3d( arrays, shape, add ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/ternary3d/docs/repl.txt b/base/ternary3d/docs/repl.txt deleted file mode 100644 index f438be7b3..000000000 --- a/base/ternary3d/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a ternary callback to elements in three three-dimensional nested - input arrays and assigns results to elements in a three-dimensional nested - output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing three input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Ternary callback. - - Examples - -------- - > function fcn( x, y, z ) { return x + y + z }; - > var x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - > var out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - > var shape = [ 1, 2, 2 ]; - > {{alias}}( [ x, y, z, out ], shape, fcn ); - > out - [ [ [ 3.0, 6.0 ], [ 9.0, 12.0 ] ] ] - - See Also - -------- - diff --git a/base/ternary3d/docs/types/index.d.ts b/base/ternary3d/docs/types/index.d.ts deleted file mode 100644 index 5ba882719..000000000 --- a/base/ternary3d/docs/types/index.d.ts +++ /dev/null @@ -1,69 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Ternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @returns result -*/ -type Ternary = ( v1: T, v2: U, v3: V ) => W; - -/** -* Applies a ternary callback to elements in three three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing three input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - ternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = ones3d( shape ); -* var out = zeros3d( shape ); -* -* ternary3d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] -*/ -declare function ternary3d( arrays: [ Array3D, Array3D, Array3D, Array3D ], shape: Shape3D, fcn: Ternary ): void; - - -// EXPORTS // - -export = ternary3d; diff --git a/base/ternary3d/docs/types/test.ts b/base/ternary3d/docs/types/test.ts deleted file mode 100644 index 6dc20b5fa..000000000 --- a/base/ternary3d/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import ternary3d = require( './index' ); - -/** -* Ternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number ): number { - return x + y + z; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - ternary3d( [ x, y, z, out ], [ 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - ternary3d( 'abc', [ 1, 2, 2 ], fcn ); // $ExpectError - ternary3d( 3.14, [ 1, 2, 2 ], fcn ); // $ExpectError - ternary3d( true, [ 1, 2, 2 ], fcn ); // $ExpectError - ternary3d( false, [ 1, 2, 2 ], fcn ); // $ExpectError - ternary3d( null, [ 1, 2, 2 ], fcn ); // $ExpectError - ternary3d( [ '1' ], [ 1, 2, 2 ], fcn ); // $ExpectError - ternary3d( {}, [ 1, 2, 2 ], fcn ); // $ExpectError - ternary3d( ( x: number ): number => x, [ 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - ternary3d( [ x, y, z, out ], 'abc', fcn ); // $ExpectError - ternary3d( [ x, y, z, out ], 3.14, fcn ); // $ExpectError - ternary3d( [ x, y, z, out ], true, fcn ); // $ExpectError - ternary3d( [ x, y, z, out ], false, fcn ); // $ExpectError - ternary3d( [ x, y, z, out ], null, fcn ); // $ExpectError - ternary3d( [ x, y, z, out ], [ '1' ], fcn ); // $ExpectError - ternary3d( [ x, y, z, out ], {}, fcn ); // $ExpectError - ternary3d( [ x, y, z, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - ternary3d( [ x, y, z, out ], [ 1, 2, 2 ], 'abc' ); // $ExpectError - ternary3d( [ x, y, z, out ], [ 1, 2, 2 ], 3.14 ); // $ExpectError - ternary3d( [ x, y, z, out ], [ 1, 2, 2 ], true ); // $ExpectError - ternary3d( [ x, y, z, out ], [ 1, 2, 2 ], false ); // $ExpectError - ternary3d( [ x, y, z, out ], [ 1, 2, 2 ], null ); // $ExpectError - ternary3d( [ x, y, z, out ], [ 1, 2, 2 ], [ '1' ] ); // $ExpectError - ternary3d( [ x, y, z, out ], [ 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const z = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const out = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - ternary3d(); // $ExpectError - ternary3d( [ x, y, z, out ] ); // $ExpectError - ternary3d( [ x, y, z, out ], [ 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/ternary3d/examples/index.js b/base/ternary3d/examples/index.js deleted file mode 100644 index 75f7615a3..000000000 --- a/base/ternary3d/examples/index.js +++ /dev/null @@ -1,42 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var ternary3d = require( './../lib' ); - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros3d( shape ); -console.log( out ); - -ternary3d( [ x, y, z, out ], shape, add ); -console.log( out ); diff --git a/base/ternary3d/lib/index.js b/base/ternary3d/lib/index.js deleted file mode 100644 index 7b7802504..000000000 --- a/base/ternary3d/lib/index.js +++ /dev/null @@ -1,52 +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'; - -/** -* Apply a ternary callback to elements in three three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/ternary3d -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var ternary3d = require( '@stdlib/array/base/ternary3d' ); -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = ones3d( shape ); -* var out = zeros3d( shape ); -* -* ternary3d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/ternary3d/lib/main.js b/base/ternary3d/lib/main.js deleted file mode 100644 index d0b7e0f1c..000000000 --- a/base/ternary3d/lib/main.js +++ /dev/null @@ -1,102 +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'; - -// MAIN // - -/** -* Applies a ternary callback to elements in three three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>} arrays - array-like object containing three input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - ternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = ones3d( shape ); -* var z = ones3d( shape ); -* var out = zeros3d( shape ); -* -* ternary3d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] -*/ -function ternary3d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var x0; - var y0; - var z0; - var w0; - var x1; - var y1; - var z1; - var w1; - var x; - var y; - var z; - var w; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x[ i2 ]; - y1 = y[ i2 ]; - z1 = z[ i2 ]; - w1 = w[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - w0 = w1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - w0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] ); - } - } - } -} - - -// EXPORTS // - -module.exports = ternary3d; diff --git a/base/ternary3d/package.json b/base/ternary3d/package.json deleted file mode 100644 index 90734e41d..000000000 --- a/base/ternary3d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/ternary3d", - "version": "0.0.0", - "description": "Apply a ternary callback to elements in three three-dimensional nested input arrays and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "ternary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/ternary3d/test/test.js b/base/ternary3d/test/test.js deleted file mode 100644 index 9bc84bae1..000000000 --- a/base/ternary3d/test/test.js +++ /dev/null @@ -1,248 +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 add = require( '@stdlib/number/float64/base/add3' ); -var zeros3d = require( './../../../base/zeros3d' ); -var ternary3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ternary3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = [ - [ - [ 15.0, 18.0 ], - [ 21.0, 24.0 ] - ], - [ - [ 15.0, 18.0 ], - [ 21.0, 24.0 ] - ] - ]; - ternary3d( [ x, y, z, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = zeros3d( shape ); - ternary3d( [ x, y, z, out ], [ 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = zeros3d( shape ); - ternary3d( [ x, y, z, out ], [ 2, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - y = [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ]; - z = [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ]; - out = zeros3d( shape ); - - expected = zeros3d( shape ); - ternary3d( [ x, y, z, out ], [ 2, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/ternary4d/README.md b/base/ternary4d/README.md deleted file mode 100644 index 18ce96f99..000000000 --- a/base/ternary4d/README.md +++ /dev/null @@ -1,125 +0,0 @@ - - -# ternary4d - -> Apply a ternary callback to elements in three four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var ternary4d = require( '@stdlib/array/base/ternary4d' ); -``` - -#### ternary4d( arrays, shape, fcn ) - -Applies a ternary callback to elements in three four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); - -var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; -var out = zeros4d( [ 1, 1, 2, 2 ] ); - -var shape = [ 1, 1, 2, 2 ]; - -ternary4d( [ x, x, x, out ], shape, add ); -// out => [ [ [ [ 3.0, 6.0 ], [ 9.0, 12.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing three input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: ternary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var ternary4d = require( '@stdlib/array/base/ternary4d' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros4d( shape ); -console.log( out ); - -ternary4d( [ x, y, z, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/ternary4d/benchmark/benchmark.js b/base/ternary4d/benchmark/benchmark.js deleted file mode 100644 index 196120957..000000000 --- a/base/ternary4d/benchmark/benchmark.js +++ /dev/null @@ -1,126 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var pkg = require( './../package.json' ).name; -var ternary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros4d( shape ); - - arrays = [ x, y, z, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ternary4d( arrays, shape, add ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 3 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 3 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/ternary4d/docs/repl.txt b/base/ternary4d/docs/repl.txt deleted file mode 100644 index 629a2ddc2..000000000 --- a/base/ternary4d/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a ternary callback to elements in three four-dimensional nested - input arrays and assigns results to elements in a four-dimensional nested - output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing three input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Ternary callback. - - Examples - -------- - > function fcn( x, y, z ) { return x + y + z }; - > var x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - > var out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > {{alias}}( [ x, y, z, out ], shape, fcn ); - > out - [ [ [ [ 3.0, 6.0 ], [ 9.0, 12.0 ] ] ] ] - - See Also - -------- - diff --git a/base/ternary4d/docs/types/index.d.ts b/base/ternary4d/docs/types/index.d.ts deleted file mode 100644 index 02f347220..000000000 --- a/base/ternary4d/docs/types/index.d.ts +++ /dev/null @@ -1,69 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Ternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @returns result -*/ -type Ternary = ( v1: T, v2: U, v3: V ) => W; - -/** -* Applies a ternary callback to elements in three four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing three input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - ternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = ones4d( shape ); -* var out = zeros4d( shape ); -* -* ternary4d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] -*/ -declare function ternary4d( arrays: [ Array4D, Array4D, Array4D, Array4D ], shape: Shape4D, fcn: Ternary ): void; - - -// EXPORTS // - -export = ternary4d; diff --git a/base/ternary4d/docs/types/test.ts b/base/ternary4d/docs/types/test.ts deleted file mode 100644 index 36b401668..000000000 --- a/base/ternary4d/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import ternary4d = require( './index' ); - -/** -* Ternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number ): number { - return x + y + z; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - ternary4d( [ x, y, z, out ], [ 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - ternary4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - ternary4d( [ x, y, z, out ], 'abc', fcn ); // $ExpectError - ternary4d( [ x, y, z, out ], 3.14, fcn ); // $ExpectError - ternary4d( [ x, y, z, out ], true, fcn ); // $ExpectError - ternary4d( [ x, y, z, out ], false, fcn ); // $ExpectError - ternary4d( [ x, y, z, out ], null, fcn ); // $ExpectError - ternary4d( [ x, y, z, out ], [ '1' ], fcn ); // $ExpectError - ternary4d( [ x, y, z, out ], {}, fcn ); // $ExpectError - ternary4d( [ x, y, z, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - ternary4d( [ x, y, z, out ], [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - ternary4d( [ x, y, z, out ], [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - ternary4d( [ x, y, z, out ], [ 1, 1, 2, 2 ], true ); // $ExpectError - ternary4d( [ x, y, z, out ], [ 1, 1, 2, 2 ], false ); // $ExpectError - ternary4d( [ x, y, z, out ], [ 1, 1, 2, 2 ], null ); // $ExpectError - ternary4d( [ x, y, z, out ], [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - ternary4d( [ x, y, z, out ], [ 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const z = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const out = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - ternary4d(); // $ExpectError - ternary4d( [ x, y, z, out ] ); // $ExpectError - ternary4d( [ x, y, z, out ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/ternary4d/examples/index.js b/base/ternary4d/examples/index.js deleted file mode 100644 index 1230e48d3..000000000 --- a/base/ternary4d/examples/index.js +++ /dev/null @@ -1,42 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var ternary4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros4d( shape ); -console.log( out ); - -ternary4d( [ x, y, z, out ], shape, add ); -console.log( out ); diff --git a/base/ternary4d/lib/index.js b/base/ternary4d/lib/index.js deleted file mode 100644 index 31891cbeb..000000000 --- a/base/ternary4d/lib/index.js +++ /dev/null @@ -1,52 +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'; - -/** -* Apply a ternary callback to elements in three four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/ternary4d -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var ternary4d = require( '@stdlib/array/base/ternary4d' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = ones4d( shape ); -* var out = zeros4d( shape ); -* -* ternary4d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/ternary4d/lib/main.js b/base/ternary4d/lib/main.js deleted file mode 100644 index 23385ac28..000000000 --- a/base/ternary4d/lib/main.js +++ /dev/null @@ -1,115 +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'; - -// MAIN // - -/** -* Applies a ternary callback to elements in three four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>>} arrays - array-like object containing three input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - ternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = ones4d( shape ); -* var z = ones4d( shape ); -* var out = zeros4d( shape ); -* -* ternary4d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] -*/ -function ternary4d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var z0; - var w0; - var x1; - var y1; - var z1; - var w1; - var x2; - var y2; - var z2; - var w2; - var x; - var y; - var z; - var w; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - z2 = z[ i3 ]; - w2 = w[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - z1 = z2[ i2 ]; - w1 = w2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - w0 = w1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - w0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] ); - } - } - } - } -} - - -// EXPORTS // - -module.exports = ternary4d; diff --git a/base/ternary4d/package.json b/base/ternary4d/package.json deleted file mode 100644 index caf8f082d..000000000 --- a/base/ternary4d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/ternary4d", - "version": "0.0.0", - "description": "Apply a ternary callback to elements in three four-dimensional nested input arrays and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "ternary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/ternary4d/test/test.js b/base/ternary4d/test/test.js deleted file mode 100644 index 796f69f9a..000000000 --- a/base/ternary4d/test/test.js +++ /dev/null @@ -1,332 +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 add = require( '@stdlib/number/float64/base/add3' ); -var zeros4d = require( './../../../base/zeros4d' ); -var ternary4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ternary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 1, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = [ - [ - [ - [ 15.0, 18.0 ], - [ 21.0, 24.0 ] - ], - [ - [ 15.0, 18.0 ], - [ 21.0, 24.0 ] - ] - ] - ]; - ternary4d( [ x, y, z, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 1, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - ternary4d( [ x, y, z, out ], [ 0, 2, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 1, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - ternary4d( [ x, y, z, out ], [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 1, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - ternary4d( [ x, y, z, out ], [ 1, 2, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 1, 2, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - y = [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ]; - z = [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ]; - out = zeros4d( shape ); - - expected = zeros4d( shape ); - ternary4d( [ x, y, z, out ], [ 1, 2, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/ternary5d/README.md b/base/ternary5d/README.md deleted file mode 100644 index 20e617e78..000000000 --- a/base/ternary5d/README.md +++ /dev/null @@ -1,125 +0,0 @@ - - -# ternary5d - -> Apply a ternary callback to elements in three five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var ternary5d = require( '@stdlib/array/base/ternary5d' ); -``` - -#### ternary5d( arrays, shape, fcn ) - -Applies a ternary callback to elements in three five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. - -```javascript -var add = require( '@stdlib/number/float64/base/add3' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); - -var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; -var out = zeros5d( [ 1, 1, 1, 2, 2 ] ); - -var shape = [ 1, 1, 1, 2, 2 ]; - -ternary5d( [ x, x, x, out ], shape, add ); -// out => [ [ [ [ [ 3.0, 6.0 ], [ 9.0, 12.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing three input nested arrays and one output nested array. -- **shape**: array shape. -- **fcn**: ternary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var ternary5d = require( '@stdlib/array/base/ternary5d' ); - -var shape = [ 1, 1, 3, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros5d( shape ); -console.log( out ); - -ternary5d( [ x, y, z, out ], shape, add ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/ternary5d/benchmark/benchmark.js b/base/ternary5d/benchmark/benchmark.js deleted file mode 100644 index 852eabb50..000000000 --- a/base/ternary5d/benchmark/benchmark.js +++ /dev/null @@ -1,129 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var pkg = require( './../package.json' ).name; -var ternary5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var out; - var x; - var y; - var z; - - x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - y = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - z = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - out = zeros5d( shape ); - - arrays = [ x, y, z, out ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ternary5d( arrays, shape, add ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 3 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 3 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/ternary5d/docs/repl.txt b/base/ternary5d/docs/repl.txt deleted file mode 100644 index 691b9c4dc..000000000 --- a/base/ternary5d/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a ternary callback to elements in three five-dimensional nested - input arrays and assigns results to elements in a five-dimensional nested - output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing three input nested arrays and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Ternary callback. - - Examples - -------- - > function fcn( x, y, z ) { return x + y + z }; - > var x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - > var out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shape = [ 1, 1, 1, 2, 2 ]; - > {{alias}}( [ x, y, z, out ], shape, fcn ); - > out - [ [ [ [ [ 3.0, 6.0 ], [ 9.0, 12.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/ternary5d/docs/types/index.d.ts b/base/ternary5d/docs/types/index.d.ts deleted file mode 100644 index 161e3394e..000000000 --- a/base/ternary5d/docs/types/index.d.ts +++ /dev/null @@ -1,69 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Ternary callback. -* -* @param v1 - element from first input array -* @param v2 - element from second input array -* @param v3 - element from third input array -* @returns result -*/ -type Ternary = ( v1: T, v2: U, v3: V ) => W; - -/** -* Applies a ternary callback to elements in three five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing three input nested arrays and one output nested array -* @param shape - array shape -* @param fcn - ternary callback -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = ones5d( shape ); -* var out = zeros5d( shape ); -* -* ternary5d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] ] -*/ -declare function ternary5d( arrays: [ Array5D, Array5D, Array5D, Array5D ], shape: Shape5D, fcn: Ternary ): void; - - -// EXPORTS // - -export = ternary5d; diff --git a/base/ternary5d/docs/types/test.ts b/base/ternary5d/docs/types/test.ts deleted file mode 100644 index da4870073..000000000 --- a/base/ternary5d/docs/types/test.ts +++ /dev/null @@ -1,101 +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. -*/ - -import ternary5d = require( './index' ); - -/** -* Ternary function. -* -* @param x - input value -* @param y - input value -* @param z - input value -* @returns result -*/ -function fcn( x: number, y: number, z: number ): number { - return x + y + z; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - ternary5d( [ x, y, z, out ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - ternary5d( 'abc', [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary5d( 3.14, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary5d( true, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary5d( false, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary5d( null, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary5d( [ '1' ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary5d( {}, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - ternary5d( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - ternary5d( [ x, y, z, out ], 'abc', fcn ); // $ExpectError - ternary5d( [ x, y, z, out ], 3.14, fcn ); // $ExpectError - ternary5d( [ x, y, z, out ], true, fcn ); // $ExpectError - ternary5d( [ x, y, z, out ], false, fcn ); // $ExpectError - ternary5d( [ x, y, z, out ], null, fcn ); // $ExpectError - ternary5d( [ x, y, z, out ], [ '1' ], fcn ); // $ExpectError - ternary5d( [ x, y, z, out ], {}, fcn ); // $ExpectError - ternary5d( [ x, y, z, out ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - ternary5d( [ x, y, z, out ], [ 1, 1, 1, 2, 2 ], 'abc' ); // $ExpectError - ternary5d( [ x, y, z, out ], [ 1, 1, 1, 2, 2 ], 3.14 ); // $ExpectError - ternary5d( [ x, y, z, out ], [ 1, 1, 1, 2, 2 ], true ); // $ExpectError - ternary5d( [ x, y, z, out ], [ 1, 1, 1, 2, 2 ], false ); // $ExpectError - ternary5d( [ x, y, z, out ], [ 1, 1, 1, 2, 2 ], null ); // $ExpectError - ternary5d( [ x, y, z, out ], [ 1, 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - ternary5d( [ x, y, z, out ], [ 1, 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const z = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const out = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - ternary5d(); // $ExpectError - ternary5d( [ x, y, z, out ] ); // $ExpectError - ternary5d( [ x, y, z, out ], [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/ternary5d/examples/index.js b/base/ternary5d/examples/index.js deleted file mode 100644 index 3c4be9eba..000000000 --- a/base/ternary5d/examples/index.js +++ /dev/null @@ -1,42 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var add = require( '@stdlib/number/float64/base/add3' ); -var ternary5d = require( './../lib' ); - -var shape = [ 1, 1, 3, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( y ); - -var z = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( z ); - -var out = zeros5d( shape ); -console.log( out ); - -ternary5d( [ x, y, z, out ], shape, add ); -console.log( out ); diff --git a/base/ternary5d/lib/index.js b/base/ternary5d/lib/index.js deleted file mode 100644 index 2e1ff3565..000000000 --- a/base/ternary5d/lib/index.js +++ /dev/null @@ -1,52 +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'; - -/** -* Apply a ternary callback to elements in three five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/ternary5d -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var ternary5d = require( '@stdlib/array/base/ternary5d' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = ones5d( shape ); -* var out = zeros5d( shape ); -* -* ternary5d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/ternary5d/lib/main.js b/base/ternary5d/lib/main.js deleted file mode 100644 index c4b5e286e..000000000 --- a/base/ternary5d/lib/main.js +++ /dev/null @@ -1,128 +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'; - -// MAIN // - -/** -* Applies a ternary callback to elements in three five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>>>} arrays - array-like object containing three input nested arrays and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - ternary callback -* @returns {void} -* -* @example -* var add = require( '@stdlib/number/float64/base/add3' ); -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = ones5d( shape ); -* var z = ones5d( shape ); -* var out = zeros5d( shape ); -* -* ternary5d( [ x, y, z, out ], shape, add ); -* -* console.log( out ); -* // => [ [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] ] -*/ -function ternary5d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var x0; - var y0; - var z0; - var w0; - var x1; - var y1; - var z1; - var w1; - var x2; - var y2; - var z2; - var w2; - var x3; - var y3; - var z3; - var w3; - var x; - var y; - var z; - var w; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - z = arrays[ 2 ]; - w = arrays[ 3 ]; - for ( i4 = 0; i4 < S4; i4++ ) { - x3 = x[ i4 ]; - y3 = y[ i4 ]; - z3 = z[ i4 ]; - w3 = w[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x3[ i3 ]; - y2 = y3[ i3 ]; - z2 = z3[ i3 ]; - w2 = w3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - z1 = z2[ i2 ]; - w1 = w2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - z0 = z1[ i1 ]; - w0 = w1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - w0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] ); - } - } - } - } - } -} - - -// EXPORTS // - -module.exports = ternary5d; diff --git a/base/ternary5d/package.json b/base/ternary5d/package.json deleted file mode 100644 index 2e9ed0980..000000000 --- a/base/ternary5d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/ternary5d", - "version": "0.0.0", - "description": "Apply a ternary callback to elements in three five-dimensional nested input arrays and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "ternary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/ternary5d/test/test.js b/base/ternary5d/test/test.js deleted file mode 100644 index 81444ba2b..000000000 --- a/base/ternary5d/test/test.js +++ /dev/null @@ -1,428 +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 add = require( '@stdlib/number/float64/base/add3' ); -var zeros5d = require( './../../../base/zeros5d' ); -var ternary5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ternary5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to nested input arrays and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = [ - [ - [ - [ - [ 15.0, 18.0 ], - [ 21.0, 24.0 ] - ], - [ - [ 15.0, 18.0 ], - [ 21.0, 24.0 ] - ] - ] - ] - ]; - ternary5d( [ x, y, z, out ], shape, add ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - ternary5d( [ x, y, z, out ], [ 0, 2, 2, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - ternary5d( [ x, y, z, out ], [ 1, 0, 2, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - ternary5d( [ x, y, z, out ], [ 1, 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - ternary5d( [ x, y, z, out ], [ 1, 1, 2, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - var z; - - shape = [ 1, 1, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - y = [ - [ - [ - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ], - [ - [ 5.0, 6.0 ], - [ 7.0, 8.0 ] - ] - ] - ] - ]; - z = [ - [ - [ - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ], - [ - [ 9.0, 10.0 ], - [ 11.0, 12.0 ] - ] - ] - ] - ]; - out = zeros5d( shape ); - - expected = zeros5d( shape ); - ternary5d( [ x, y, z, out ], [ 1, 1, 2, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/test/test.js b/base/test/test.js deleted file mode 100644 index 4703875b1..000000000 --- a/base/test/test.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/base/to-accessor-array/README.md b/base/to-accessor-array/README.md deleted file mode 100644 index 7eb1b55db..000000000 --- a/base/to-accessor-array/README.md +++ /dev/null @@ -1,151 +0,0 @@ - - -# toAccessorArray - -> Convert an array-like object to a minimal array-like object supporting the accessor protocol. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -``` - -#### toAccessorArray( arr ) - -Converts an array-like object to a minimal array-like object supporting the accessor protocol. - -```javascript -var arr1 = [ 1, 2, 3 ]; - -var arr2 = toAccessorArray( arr1 ); -// returns - -var v = arr2.get( 1 ); -// returns 2 - -var bool = ( arr2 === arr1 ); -// returns false -``` - -If the provided array-like object already supports the accessor protocol, the function returns the input array unchanged. - -```javascript -var Complex128Array = require( '@stdlib/array/complex128' ); - -var arr1 = new Complex128Array( 10 ); -// returns - -var arr2 = toAccessorArray( arr1 ); -// returns - -var bool = ( arr2 === arr1 ); -// returns true -``` - -
- - - - - -
- -
- - - - - -
- -* * * - -## Examples - - - -```javascript -var Complex128Array = require( '@stdlib/array/complex128' ); -var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %s', name, i, x.get( i ).toString() ); - } -} - -// Create an array of complex numbers: -var buf = [ 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0 ]; -var cmplx = new Complex128Array( buf ); - -// Create an array of the real components: -var real = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Ensure the arrays support the accessor protocol to allow for uniform iteration: -cmplx = toAccessorArray( cmplx ); -real = toAccessorArray( real ); - -// Print the contents of each array: -printArray( 'complx', cmplx ); -printArray( 'real', real ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/to-accessor-array/benchmark/benchmark.js b/base/to-accessor-array/benchmark/benchmark.js deleted file mode 100644 index 4ba2e7a31..000000000 --- a/base/to-accessor-array/benchmark/benchmark.js +++ /dev/null @@ -1,83 +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 bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../../float64' ); -var Complex128Array = require( './../../../complex128' ); -var isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var pkg = require( './../package.json' ).name; -var toAccessorArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::no_accessor_protocol', function benchmark( b ) { - var values; - var o; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - [ 1, 2, 3 ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = toAccessorArray( values[ i%values.length ] ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isAccessorArray( o ) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::accessor_protocol', function benchmark( b ) { - var values; - var o; - var i; - - values = [ - new Complex128Array( 10 ), - new Complex128Array( 10 ), - new Complex128Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - o = toAccessorArray( values[ i%values.length ] ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isAccessorArray( o ) ) { - b.fail( 'should return an accessor array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/to-accessor-array/docs/repl.txt b/base/to-accessor-array/docs/repl.txt deleted file mode 100644 index cdfcf8ee5..000000000 --- a/base/to-accessor-array/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( arr ) - Converts an array-like object to a minimal array-like object supporting the - accessor protocol. - - If a provided array-like object already supports the accessor protocol, the - function returns the provided array-like object; otherwise, the function - wraps the provided value in a object which uses accessors for getting and - setting elements. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Accessor array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x ); - > var v = out.get( 1 ) - 2 - > var len = out.length - 4 - > out.set( 5, 0 ); - > v = out.get( 0 ) - 5 - - See Also - -------- - diff --git a/base/to-accessor-array/docs/types/index.d.ts b/base/to-accessor-array/docs/types/index.d.ts deleted file mode 100644 index 24bc7cab4..000000000 --- a/base/to-accessor-array/docs/types/index.d.ts +++ /dev/null @@ -1,53 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Converts an array-like object to a minimal array-like object supporting the accessor protocol. -* -* ## Notes -* -* - If a provided array-like object already supports the accessor protocol, the function returns the provided array-like object; otherwise, the function wraps the provided value in a object which uses accessors for getting and setting elements. -* -* @param arr - input array -* @returns accessor array -* -* @example -* var arr = toAccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = arr.get( 0 ); -* // returns 1 -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var arr = toAccessorArray( new Complex128Array( 10 ) ); -* // returns -*/ -declare function toAccessorArray( arr: Collection ): AccessorArrayLike; - - -// EXPORTS // - -export = toAccessorArray; diff --git a/base/to-accessor-array/docs/types/test.ts b/base/to-accessor-array/docs/types/test.ts deleted file mode 100644 index 2cca4e9f1..000000000 --- a/base/to-accessor-array/docs/types/test.ts +++ /dev/null @@ -1,47 +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. -*/ - -import toAccessorArray = require( './index' ); - - -// TESTS // - -// The function returns an accessor array... -{ - const arr = [ 1, 2, 3 ]; - - toAccessorArray( arr ); // $ExpectType AccessorArrayLike - toAccessorArray( arr ); // $ExpectType AccessorArrayLike -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - toAccessorArray( 123 ); // $ExpectError - toAccessorArray( true ); // $ExpectError - toAccessorArray( false ); // $ExpectError - toAccessorArray( null ); // $ExpectError - toAccessorArray( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - - toAccessorArray(); // $ExpectError - toAccessorArray( x, 5 ); // $ExpectError -} diff --git a/base/to-accessor-array/examples/index.js b/base/to-accessor-array/examples/index.js deleted file mode 100644 index 48b8deda3..000000000 --- a/base/to-accessor-array/examples/index.js +++ /dev/null @@ -1,45 +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'; - -var Complex128Array = require( './../../../complex128' ); -var toAccessorArray = require( './../lib' ); - -// Define a function for printing the contents of an array and which assumes accessor protocol support: -function printArray( name, x ) { - var i; - for ( i = 0; i < x.length; i++ ) { - console.log( '%s[%d] = %s', name, i, x.get( i ).toString() ); - } -} - -// Create an array of complex numbers: -var buf = [ 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0 ]; -var cmplx = new Complex128Array( buf ); - -// Create an array of the real components: -var real = [ 0, 0, 1, 2, 0, 0, 0, 0, 3, 0 ]; - -// Ensure the arrays support the accessor protocol to allow for uniform iteration: -cmplx = toAccessorArray( cmplx ); -real = toAccessorArray( real ); - -// Print the contents of each array: -printArray( 'complx', cmplx ); -printArray( 'real', real ); diff --git a/base/to-accessor-array/lib/index.js b/base/to-accessor-array/lib/index.js deleted file mode 100644 index 2b73befc6..000000000 --- a/base/to-accessor-array/lib/index.js +++ /dev/null @@ -1,43 +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'; - -/** -* Convert an array-like object to a minimal array-like object supporting the accessor protocol. -* -* @module @stdlib/array/base/to-accessor-array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var o = toAccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = o.get( 0 ); -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/to-accessor-array/lib/main.js b/base/to-accessor-array/lib/main.js deleted file mode 100644 index c1b9b8a95..000000000 --- a/base/to-accessor-array/lib/main.js +++ /dev/null @@ -1,57 +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 isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var AccessorArray = require( './../../../base/accessor' ); - - -// MAIN // - -/** -* Converts an array-like object to a minimal array-like object supporting the accessor protocol. -* -* ## Notes -* -* - If a provided array-like object already supports the accessor protocol, the function returns the provided array-like object; otherwise, the function wraps the provided value in a object which uses accessors for getting and setting elements. -* -* @param {Collection} arr - input array -* @throws {TypeError} must provide an array-like object -* @returns {(Collection|AccessorArray)} array-like object supporting the accessor protocol -* -* @example -* var o = toAccessorArray( [ 1, 2, 3 ] ); -* // returns -* -* var v = o.get( 0 ); -* // returns 1 -*/ -function toAccessorArray( arr ) { - if ( arr && typeof arr === 'object' && isAccessorArray( arr ) ) { - return arr; - } - return new AccessorArray( arr ); -} - - -// EXPORTS // - -module.exports = toAccessorArray; diff --git a/base/to-accessor-array/package.json b/base/to-accessor-array/package.json deleted file mode 100644 index 5372f400b..000000000 --- a/base/to-accessor-array/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/to-accessor-array", - "version": "0.0.0", - "description": "Convert an array-like object to a minimal array-like object supporting the accessor protocol.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "array-like", - "object", - "accessor", - "accessors", - "protocol", - "convert", - "wrap", - "wrapper" - ] -} diff --git a/base/to-accessor-array/test/test.js b/base/to-accessor-array/test/test.js deleted file mode 100644 index 465c75f6a..000000000 --- a/base/to-accessor-array/test/test.js +++ /dev/null @@ -1,79 +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 isAccessorArray = require( './../../../base/assert/is-accessor-array' ); -var Complex128Array = require( './../../../complex128' ); -var toAccessorArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof toAccessorArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return toAccessorArray( value ); - }; - } -}); - -tape( 'if provided an array-like not supporting the accessor protocol, the function returns an array-like object supporting the accessor protocol', function test( t ) { - var arr1 = [ 1, 2, 3 ]; - var arr2 = toAccessorArray( arr1 ); - t.strictEqual( isAccessorArray( arr2 ), true, 'returns expected value' ); - t.notEqual( arr1, arr2, 'returns new object' ); - t.end(); -}); - -tape( 'if provided an array-like object already supporting the accessor protocol, the function returns the input value', function test( t ) { - var arr1 = new Complex128Array( 10 ); - var arr2 = toAccessorArray( arr1 ); - t.strictEqual( isAccessorArray( arr2 ), true, 'returns expected value' ); - t.strictEqual( arr1, arr2, 'returns expected value' ); - t.end(); -}); diff --git a/base/to-deduped/README.md b/base/to-deduped/README.md deleted file mode 100644 index 73c76aa8f..000000000 --- a/base/to-deduped/README.md +++ /dev/null @@ -1,146 +0,0 @@ - - -# toDeduped - -> Copy elements to a new "generic" array after removing consecutive duplicated values. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var toDeduped = require( '@stdlib/array/base/to-deduped' ); -``` - -#### toDeduped( x, limit, equalNaNs ) - -Copies elements to a new "generic" array after removing consecutive duplicated values. - -```javascript -var x = [ 1, 1, 2, 3, 3 ]; - -var y = toDeduped( x, 1, false ); -// returns [ 1, 2, 3 ] - -var bool = ( x === y ); -// returns false -``` - -When `equalNaNs` is `false`, `NaN` values are considered distinct, and, when `equalNaNs` is `true`, `NaN` values are considered equal. - -```javascript -var x = [ NaN, NaN, 2, NaN, NaN ]; - -var y1 = toDeduped( x, 1, false ); -// returns [ NaN, NaN, 2, NaN, NaN ] - -var y2 = toDeduped( x, 1, true ); -// returns [ NaN, 2, NaN ] -``` - -To allow consecutive duplicate values up to a specified limit, provide a `limit` argument greater than one. - -```javascript -var x = [ 1, 1, 1, 2, 2, 3, 3, 3 ]; - -var y = toDeduped( x, 2, false ); -// returns [ 1, 1, 2, 2, 3, 3 ] -``` - -
- - - - - -
- -## Notes - -- The function **always** returns a new "generic" array. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var toDeduped = require( '@stdlib/array/base/to-deduped' ); - -// Create an array of random numbers: -var x = discreteUniform( 30, 0, 5, { - 'dtype': 'generic' -}); -// returns [...] - -// Remove consecutive duplicates: -var y = toDeduped( x, 1, false ); -// returns [...] - -console.log( x ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/to-deduped/benchmark/benchmark.length.js b/base/to-deduped/benchmark/benchmark.length.js deleted file mode 100644 index 68c99737e..000000000 --- a/base/to-deduped/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var toDeduped = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); // Note: this corresponds to the scenario where all values are unique - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = toDeduped( x, 1, false ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/to-deduped/docs/repl.txt b/base/to-deduped/docs/repl.txt deleted file mode 100644 index 2deb89e69..000000000 --- a/base/to-deduped/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( x, limit, equalNaNs ) - Copies elements to a new "generic" array after removing consecutive - duplicated values. - - Parameters - ---------- - x: Array - Input array. - - limit: integer - Number of allowed consecutive duplicates. - - equalNaNs: boolean - Boolean indicating whether NaNs should be considered equal. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 1, 2, 3, 3 ]; - > var out = {{alias}}( x, 1, false ) - [ 1, 2, 3 ] - > var bool = ( out === x ) - false - - See Also - -------- - diff --git a/base/to-deduped/docs/types/index.d.ts b/base/to-deduped/docs/types/index.d.ts deleted file mode 100644 index abe820ccd..000000000 --- a/base/to-deduped/docs/types/index.d.ts +++ /dev/null @@ -1,52 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Copies elements to a new "generic" array after removing consecutive duplicated values. -* -* @param x - input array -* @param limit - number of allowed consecutive duplicates -* @param equalNaNs - boolean indicating whether NaNs should be considered equal -* @returns output array -* -* @example -* var x = [ 1, 1, 2, 3, 3 ]; -* -* var y = dedupe( x, 1, false ); -* // returns [ 1, 2, 3 ] -* -* var bool = ( x === y ); -* // returns false -* -* @example -* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ]; -* -* var y = dedupe( x, 2, false ); -* // returns [ 1, 1, 2, 1, 1, 3, 3 ] -* -* var bool = ( x === y ); -* // returns false -*/ -declare function dedupe( x: Array, limit: number, equalNaNs: boolean ): Array; - - -// EXPORTS // - -export = dedupe; diff --git a/base/to-deduped/docs/types/test.ts b/base/to-deduped/docs/types/test.ts deleted file mode 100644 index bc533147e..000000000 --- a/base/to-deduped/docs/types/test.ts +++ /dev/null @@ -1,76 +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. -*/ - -import toDeduped = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - toDeduped( [ 1, 2, 3 ], 1, false ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array... -{ - toDeduped( '5', 1, false ); // $ExpectError - toDeduped( 5, 1, false ); // $ExpectError - toDeduped( true, 1, false ); // $ExpectError - toDeduped( false, 1, false ); // $ExpectError - toDeduped( null, 1, false ); // $ExpectError - toDeduped( void 0, 1, false ); // $ExpectError - toDeduped( {}, 1, false ); // $ExpectError - toDeduped( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - toDeduped( x, '5', false ); // $ExpectError - toDeduped( x, true, false ); // $ExpectError - toDeduped( x, false, false ); // $ExpectError - toDeduped( x, null, false ); // $ExpectError - toDeduped( x, void 0, false ); // $ExpectError - toDeduped( x, {}, false ); // $ExpectError - toDeduped( x, [], false ); // $ExpectError - toDeduped( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = [ 1, 2, 3 ]; - - toDeduped( x, 1, '5' ); // $ExpectError - toDeduped( x, 1, 5 ); // $ExpectError - toDeduped( x, 1, null ); // $ExpectError - toDeduped( x, 1, void 0 ); // $ExpectError - toDeduped( x, 1, {} ); // $ExpectError - toDeduped( x, 1, [] ); // $ExpectError - toDeduped( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3 ]; - - toDeduped(); // $ExpectError - toDeduped( x ); // $ExpectError - toDeduped( x, 1 ); // $ExpectError - toDeduped( x, 1, false, {} ); // $ExpectError -} diff --git a/base/to-deduped/examples/index.js b/base/to-deduped/examples/index.js deleted file mode 100644 index a1728193c..000000000 --- a/base/to-deduped/examples/index.js +++ /dev/null @@ -1,35 +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'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var toDeduped = require( './../lib' ); - -// Create an array of random numbers: -var x = discreteUniform( 30, 0, 5, { - 'dtype': 'generic' -}); -// returns [...] - -// Remove consecutive duplicates: -var y = toDeduped( x, 1, false ); -// returns [...] - -console.log( x ); -console.log( y ); diff --git a/base/to-deduped/lib/index.js b/base/to-deduped/lib/index.js deleted file mode 100644 index 1d8708b73..000000000 --- a/base/to-deduped/lib/index.js +++ /dev/null @@ -1,45 +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'; - -/** -* Copy elements to a new "generic" array after removing consecutive duplicated values. -* -* @module @stdlib/array/base/to-deduped -* -* @example -* var toDeduped = require( '@stdlib/array/base/to-deduped' ); -* -* var x = [ 1, 1, 2, 3, 3 ]; -* -* var y = toDeduped( x, 1, false ); -* // returns [ 1, 2, 3 ] -* -* var bool = ( x === y ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/to-deduped/lib/main.js b/base/to-deduped/lib/main.js deleted file mode 100644 index 7578e6745..000000000 --- a/base/to-deduped/lib/main.js +++ /dev/null @@ -1,187 +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 isnan = require( '@stdlib/math/base/assert/is-nan' ); - - -// FUNCTIONS // - -/** -* Copies de-duplicated values to a new array. -* -* @private -* @param {Array} x - input array -* @param {PositiveInteger} limit - number of allowed consecutive duplicates -* @returns {Array} output array -* -* @example -* var x = [ 1, 1, 2, 3, 3 ]; -* -* var y = dedupeCopy( x, 1 ); -* // returns [ 1, 2, 3 ] -* -* var bool = ( x === y ); -* // returns false -* -* @example -* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ]; -* -* var y = dedupeCopy( x, 2 ); -* // returns [ 1, 1, 2, 1, 1, 3, 3 ] -* -* var bool = ( x === y ); -* // returns false -*/ -function dedupeCopy( x, limit ) { - var count; - var prev; - var len; - var out; - var v; - var i; - - out = []; - len = x.length; - if ( len === 0 ) { - return out; - } - prev = NaN; // we leverage the fact that `NaN` is not equal to anything, including itself, to handle the initial condition - count = 0; - for ( i = 0; i < len; i++ ) { - v = x[ i ]; - if ( v === prev ) { - count += 1; - if ( count <= limit ) { - out.push( prev ); - } - } else { - prev = v; - count = 1; - out.push( prev ); - } - } - return out; -} - -/** -* Copies de-duplicated values to a new array, treating `NaN` values as equal. -* -* @private -* @param {Array} x - input array -* @param {PositiveInteger} limit - number of allowed consecutive duplicates -* @returns {Array} output array -* -* @example -* var x = [ 1, 1, 2, NaN, NaN, 3, 3 ]; -* -* var y = dedupeEqualNaNs( x, 1 ); -* // returns [ 1, 2, NaN, 3 ] -* -* var bool = ( x === y ); -* // returns false -* -* @example -* var x = [ 1, 1, 1, 2, 1, 1, NaN, NaN, NaN, 3, 3 ]; -* -* var y = dedupeEqualNaNs( x, 2 ); -* // returns [ 1, 1, 2, 1, 1, NaN, NaN, 3, 3 ] -* -* var bool = ( x === y ); -* // returns false -*/ -function dedupeEqualNaNs( x, limit ) { - var count; - var prev; - var len; - var out; - var FLG; - var v; - var i; - - out = []; - len = x.length; - if ( len === 0 ) { - return out; - } - FLG = false; - prev = NaN; // we leverage the fact that `NaN` is not equal to anything, including itself, to handle the initial condition - count = 0; - for ( i = 0; i < len; i++ ) { - v = x[ i ]; - if ( v === prev || ( FLG && isnan( v ) ) ) { - count += 1; - if ( count <= limit ) { - out.push( prev ); - } - } else { - prev = v; - count = 1; - out.push( prev ); - FLG = false; - if ( isnan( prev ) ) { - FLG = true; - } - } - } - return out; -} - - -// MAIN // - -/** -* Copies elements to a new "generic" array after removing consecutive duplicated values. -* -* @param {Array} x - input array -* @param {PositiveInteger} limit - number of allowed consecutive duplicates -* @param {boolean} equalNaNs - boolean indicating whether NaNs should be considered equal -* @returns {Array} de-duplicated values -* -* @example -* var x = [ 1, 1, 2, 3, 3 ]; -* -* var y = dedupe( x, 1, false ); -* // returns [ 1, 2, 3 ] -* -* var bool = ( x === y ); -* // returns false -* -* @example -* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ]; -* -* var y = dedupe( x, 2, false ); -* // returns [ 1, 1, 2, 1, 1, 3, 3 ] -* -* var bool = ( x === y ); -* // returns false -*/ -function dedupe( x, limit, equalNaNs ) { - if ( equalNaNs ) { - return dedupeEqualNaNs( x, limit ); - } - return dedupeCopy( x, limit ); -} - - -// EXPORTS // - -module.exports = dedupe; diff --git a/base/to-deduped/package.json b/base/to-deduped/package.json deleted file mode 100644 index 0e7bca809..000000000 --- a/base/to-deduped/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/base/to-deduped", - "version": "0.0.0", - "description": "Copy elements to a new generic array after removing consecutive duplicated values.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "dedupe", - "deduplicate", - "deduplication", - "duplicate", - "compress", - "unique", - "uniq", - "copy" - ] -} diff --git a/base/to-deduped/test/test.js b/base/to-deduped/test/test.js deleted file mode 100644 index a357fbd48..000000000 --- a/base/to-deduped/test/test.js +++ /dev/null @@ -1,177 +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 isnan = require( '@stdlib/math/base/assert/is-nan' ); -var toDeduped = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof toDeduped, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function copies values to a new "generic" array after removing consecutive duplicated values', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 1, 2, 3, 3 ]; - expected = [ 1, 2, 3 ]; - actual = toDeduped( x, 1, false ); - - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports considering NaN values as distinct', function test( t ) { - var expected; - var actual; - var x; - var i; - - x = [ NaN, NaN, 2, NaN, NaN, 3, 3 ]; - expected = [ NaN, NaN, 2, NaN, NaN, 3 ]; - actual = toDeduped( x, 1, false ); - - t.notEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - - for ( i = 0; i < expected.length; i++ ) { - if ( isnan( expected[ i ] ) ) { - t.strictEqual( isnan( actual[ i ] ), true, 'returns expected value' ); - } else { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function supports considering NaN values as equal', function test( t ) { - var expected; - var actual; - var x; - var i; - - x = [ NaN, NaN, 2, NaN, NaN, 3, 3 ]; - expected = [ NaN, 2, NaN, 3 ]; - actual = toDeduped( x, 1, true ); - - t.notEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - - for ( i = 0; i < expected.length; i++ ) { - if ( isnan( expected[ i ] ) ) { - t.strictEqual( isnan( actual[ i ] ), true, 'returns expected value' ); - } else { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function supports specifying a maximum number of consecutive duplicates', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 1, 1, 1, 2, 2, 3, 3, 3 ]; - expected = [ 1, 1, 2, 2, 3, 3 ]; - actual = toDeduped( x, 2, false ); - - t.notEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports specifying a maximum number of consecutive duplicates (distinct NaNs)', function test( t ) { - var expected; - var actual; - var x; - var i; - - x = [ NaN, NaN, NaN, NaN, 2, 2, NaN, NaN, NaN, 3, 3, 3 ]; - expected = [ NaN, NaN, NaN, NaN, 2, 2, NaN, NaN, NaN, 3, 3 ]; - actual = toDeduped( x, 2, false ); - - t.notEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - - for ( i = 0; i < expected.length; i++ ) { - if ( isnan( expected[ i ] ) ) { - t.strictEqual( isnan( actual[ i ] ), true, 'returns expected value' ); - } else { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function supports specifying a maximum number of consecutive duplicates (equal NaNs)', function test( t ) { - var expected; - var actual; - var x; - var i; - - x = [ NaN, NaN, NaN, NaN, NaN, NaN, NaN, 2, 2, NaN, NaN, NaN, 3, 3, 3 ]; - expected = [ NaN, NaN, NaN, 2, 2, NaN, NaN, NaN, 3, 3, 3 ]; - actual = toDeduped( x, 3, true ); - - t.notEqual( actual, x, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - - for ( i = 0; i < expected.length; i++ ) { - if ( isnan( expected[ i ] ) ) { - t.strictEqual( isnan( actual[ i ] ), true, 'returns expected value' ); - } else { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - } - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of length `0`', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = toDeduped( [], 1, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = toDeduped( [], 1, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = toDeduped( [], 2, false ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = toDeduped( [], 2, true ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/to-reversed/README.md b/base/to-reversed/README.md deleted file mode 100644 index fcd880314..000000000 --- a/base/to-reversed/README.md +++ /dev/null @@ -1,127 +0,0 @@ - - -# toReversed - -> Return a new array with elements in reverse order. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var toReversed = require( '@stdlib/array/base/to-reversed' ); -``` - -#### toReversed( x ) - -Returns a new array with elements in reverse order. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var out = toReversed( x ); -// returns [ 6, 5, 4, 3, 2, 1 ] - -var bool = ( out === x ); -// returns false -``` - -
- - - - - -
- -## Notes - -- If provided an array-like object having a `toReversed` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.toReversed() - ``` - -- If provided an array-like object without a `toReversed` method, the function manually reverses elements and copies to a new generic array. - -
- - - - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var toReversed = require( '@stdlib/array/base/to-reversed' ); - -var x = zeroTo( 6 ); -// returns [ 0, 1, 2, 3, 4, 5 ] - -var y = toReversed( x ); -// returns [ 5, 4, 3, 2, 1, 0 ] - -var z = toReversed( y ); -// returns [ 0, 1, 2, 3, 4, 5 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/to-reversed/benchmark/benchmark.length.js b/base/to-reversed/benchmark/benchmark.length.js deleted file mode 100644 index 6f7a8af1a..000000000 --- a/base/to-reversed/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var toReversed = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = toReversed( x ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/to-reversed/docs/repl.txt b/base/to-reversed/docs/repl.txt deleted file mode 100644 index f1822b25a..000000000 --- a/base/to-reversed/docs/repl.txt +++ /dev/null @@ -1,31 +0,0 @@ - -{{alias}}( x ) - Returns a new array with elements in reverse order. - - If provided an array-like object having a `toReversed` method, the function - defers execution to that method and assumes that the method has the - following signature: - - x.toReversed() - - If provided an array-like object without a `toReversed` method, the function - manually reverses elements and copies to a new generic array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: ArrayLikeObject - Input array. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - [ 4, 3, 2, 1 ] - - See Also - -------- - diff --git a/base/to-reversed/docs/types/index.d.ts b/base/to-reversed/docs/types/index.d.ts deleted file mode 100644 index 488c52220..000000000 --- a/base/to-reversed/docs/types/index.d.ts +++ /dev/null @@ -1,229 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex128Array, Complex64Array, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = toReversed( x ); -* // returns [ 3.0, 2.0, 1.0 ] -*/ -declare function toReversed( x: Float64Array ): Float64Array; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = toReversed( x ); -* // returns [ 3.0, 2.0, 1.0 ] -*/ -declare function toReversed( x: Float32Array ): Float32Array; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3 ] ); -* -* var out = toReversed( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function toReversed( x: Int32Array ): Int32Array; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var x = new Int16Array( [ 1, 2, 3 ] ); -* -* var out = toReversed( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function toReversed( x: Int16Array ): Int16Array; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var x = new Int8Array( [ 1, 2, 3 ] ); -* -* var out = toReversed( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function toReversed( x: Int8Array ): Int8Array; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3 ] ); -* -* var out = toReversed( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function toReversed( x: Uint32Array ): Uint32Array; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3 ] ); -* -* var out = toReversed( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function toReversed( x: Uint16Array ): Uint16Array; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3 ] ); -* -* var out = toReversed( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function toReversed( x: Uint8Array ): Uint8Array; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3 ] ); -* -* var out = toReversed( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function toReversed( x: Uint8ClampedArray ): Uint8ClampedArray; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* var out = toReversed( x ); -* // returns [ 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] -*/ -declare function toReversed( x: Complex128Array ): Complex128Array; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* var out = toReversed( x ); -* // returns [ 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] -*/ -declare function toReversed( x: Complex64Array ): Complex64Array; - -/** -* Returns a new array with elements in reverse order. -* -* @param x - input array -* @returns output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3 ] ); -* -* var v = x.get( 0 ); -* // returns 1 -* -* var out = toReversed( x ); -* // returns [ 3, 2, 1 ] -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = toReversed( x ); -* // returns [ 3, 2, 1 ] -*/ -declare function toReversed( x: Collection | AccessorArrayLike ): Array; - - -// EXPORTS // - -export = toReversed; diff --git a/base/to-reversed/docs/types/test.ts b/base/to-reversed/docs/types/test.ts deleted file mode 100644 index 8771f7adb..000000000 --- a/base/to-reversed/docs/types/test.ts +++ /dev/null @@ -1,56 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import toReversed = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - toReversed( [ 1, 2, 3 ] ); // $ExpectType number[] - toReversed( new Float64Array( [ 1, 2, 3 ] ) ); // $ExpectType Float64Array - toReversed( new Float32Array( [ 1, 2, 3 ] ) ); // $ExpectType Float32Array - toReversed( new Int32Array( [ 1, 2, 3 ] ) ); // $ExpectType Int32Array - toReversed( new Int16Array( [ 1, 2, 3 ] ) ); // $ExpectType Int16Array - toReversed( new Int8Array( [ 1, 2, 3 ] ) ); // $ExpectType Int8Array - toReversed( new Uint32Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint32Array - toReversed( new Uint16Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint16Array - toReversed( new Uint8Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint8Array - toReversed( new Uint8ClampedArray( [ 1, 2, 3 ] ) ); // $ExpectType Uint8ClampedArray - toReversed( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ) ); // $ExpectType Complex128Array - toReversed( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ) ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - toReversed( 5 ); // $ExpectError - toReversed( true ); // $ExpectError - toReversed( false ); // $ExpectError - toReversed( null ); // $ExpectError - toReversed( void 0 ); // $ExpectError - toReversed( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - toReversed(); // $ExpectError - toReversed( [ 1, 2, 3 ], {} ); // $ExpectError -} diff --git a/base/to-reversed/examples/index.js b/base/to-reversed/examples/index.js deleted file mode 100644 index 031d8bc35..000000000 --- a/base/to-reversed/examples/index.js +++ /dev/null @@ -1,34 +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. -*/ - -'use strict'; - -var zeroTo = require( './../../../base/zero-to' ); -var toReversed = require( './../lib' ); - -var x = zeroTo( 6 ); -console.log( x ); -// => [ 0, 1, 2, 3, 4, 5 ] - -var y = toReversed( x ); -console.log( y ); -// => [ 5, 4, 3, 2, 1, 0 ] - -var z = toReversed( y ); -console.log( z ); -// => [ 0, 1, 2, 3, 4, 5 ] diff --git a/base/to-reversed/lib/index.js b/base/to-reversed/lib/index.js deleted file mode 100644 index c4cb1a03e..000000000 --- a/base/to-reversed/lib/index.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -/** -* Return a new array with elements in reverse order. -* -* @module @stdlib/array/base/to-reversed -* -* @example -* var toReversed = require( '@stdlib/array/base/to-reversed' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = toReversed( x ); -* // returns [ 4, 3, 2, 1 ] -* -* var bool = ( out === x ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/to-reversed/lib/main.js b/base/to-reversed/lib/main.js deleted file mode 100644 index 999b67d1c..000000000 --- a/base/to-reversed/lib/main.js +++ /dev/null @@ -1,136 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - -/** -* Returns a new array with elements in reverse order. -* -* @private -* @param {Collection} x - input array -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = internal( x ); -* // returns [ 4, 3, 2, 1 ] -*/ -function internal( x ) { - var out; - var i; - - out = []; - for ( i = x.length-1; i >= 0; i-- ) { - out.push( x[ i ] ); - } - return out; -} - -/** -* Returns a new array with elements in reverse order. -* -* @private -* @param {Object} x - input array object -* @returns {Array} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var v = x.get( 0 ); -* // returns 1 -* -* var out = accessors( arraylike2object( x ) ); -* // returns [ 4, 3, 2, 1 ] -*/ -function accessors( x ) { - var data; - var get; - var out; - var i; - - data = x.data; - get = x.accessors[ 0 ]; - - out = []; - for ( i = data.length-1; i >= 0; i-- ) { - out.push( get( data, i ) ); - } - return out; -} - - -// MAIN // - -/** -* Returns a new array with elements in reverse order. -* -* @param {Collection} x - input array -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = toReversed( x ); -* // returns [ 4, 3, 2, 1 ] -* -* var bool = ( out === x ); -* // returns false -*/ -function toReversed( x ) { - var obj; - if ( hasMethod( x, 'toReversed' ) ) { - return x.toReversed(); - } - obj = arraylike2object( x ); - if ( obj.accessorProtocol ) { - return accessors( obj ); - } - return internal( x ); -} - - -// EXPORTS // - -module.exports = toReversed; diff --git a/base/to-reversed/package.json b/base/to-reversed/package.json deleted file mode 100644 index 00b811702..000000000 --- a/base/to-reversed/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/to-reversed", - "version": "0.0.0", - "description": "Return a new array with elements in reverse order.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "reverse", - "rev", - "swap" - ] -} diff --git a/base/to-reversed/test/test.js b/base/to-reversed/test/test.js deleted file mode 100644 index 2f1afadfc..000000000 --- a/base/to-reversed/test/test.js +++ /dev/null @@ -1,265 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../../base/accessor' ); -var Float64Array = require( './../../../float64' ); -var Int32Array = require( './../../../int32' ); -var isArray = require( '@stdlib/assert/is-array' ); -var toReversed = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof toReversed, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function reverses an array-like object (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - expected = [ 3, 2, 1 ]; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 2, 3 ]; - expected = [ 3, 2 ]; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 2 ]; - expected = [ 2 ]; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - expected = []; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function reverses an array-like object (float64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - expected = new Float64Array( [ 3.0, 2.0, 1.0 ] ); - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 2.0, 3.0 ] ); - expected = new Float64Array( [ 3.0, 2.0 ] ); - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 2.0 ] ); - expected = new Float64Array( [ 2.0 ] ); - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [] ); - expected = new Float64Array( [] ); - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function reverses an array-like object (int32)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - expected = new Int32Array( [ 3, 2, 1 ] ); - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2 ] ); - expected = new Int32Array( [ 2, 1 ] ); - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1 ] ); - expected = new Int32Array( [ 1 ] ); - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [] ); - expected = new Int32Array( [] ); - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function reverses an array-like object (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = new AccessorArray( [ 1, 2, 3, 4 ] ); - expected = [ 4, 3, 2, 1 ]; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 1, 2, 3 ] ); - expected = [ 3, 2, 1 ]; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 2, 3 ] ); - expected = [ 3, 2 ]; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [ 3 ] ); - expected = [ 3 ]; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new AccessorArray( [] ); - expected = []; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function reverses an array-like object (array-like)', function test( t ) { - var expected; - var actual; - var x; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = [ 4, 3, 2, 1 ]; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - expected = [ 3, 2, 1 ]; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 2, - '0': 1, - '1': 2 - }; - expected = [ 2, 1 ]; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 1, - '0': 1 - }; - expected = [ 1 ]; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = { - 'length': 0 - }; - expected = []; - actual = toReversed( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/unary2d-by/README.md b/base/unary2d-by/README.md deleted file mode 100644 index e6e3dba55..000000000 --- a/base/unary2d-by/README.md +++ /dev/null @@ -1,180 +0,0 @@ - - -# unary2dBy - -> Apply a unary function to each element retrieved from a two-dimensional nested input array according to a callback function and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var unary2dBy = require( '@stdlib/array/base/unary2d-by' ); -``` - -#### unary2dBy( arrays, shape, fcn, clbk\[, thisArg] ) - -Applies a unary function to each element retrieved from a two-dimensional nested input array according to a callback function and assigns results to elements in a two-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -function accessor( v ) { - return v * 2.0; -} - -var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; -var shape = [ 2, 2 ]; - -unary2dBy( [ x, x ], shape, abs, accessor ); -// x => [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply to callback return values. -- **clbk**: callback function. -- **thisArg**: callback function execution context (optional). - -The invoked callback function is provided the following arguments: - -- **value**: array element. -- **indices**: current array element indices. -- **arrays**: input and output arrays. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -function accessor( v ) { - this.count += 1; - return v * 2.0; -} - -var context = { - 'count': 0 -}; - -var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; -var y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - -var shape = [ 2, 2 ]; - -unary2dBy( [ x, y ], shape, abs, accessor, context ); -// y => [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] - -var cnt = context.count; -// returns 4 -``` - -
- - - -
- -## Notes - -- If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is **ignored**. - - ```javascript - var abs = require( '@stdlib/math/base/special/abs' ); - - function accessor() { - // No-op... - } - - var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; - var y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - var shape = [ 2, 2 ]; - - unary2dBy( [ x, y ], shape, abs, accessor ); - // y => [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] - ``` - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary2dBy = require( '@stdlib/array/base/unary2d-by' ); - -function accessor( v ) { - // Randomly determine whether a value should be considered "missing": - return ( bernoulli( 0.5 ) > 0 ) ? v : void 0; -} - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros2d( shape ); -console.log( y ); - -unary2dBy( [ x, y ], shape, abs, accessor ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/unary2d-by/benchmark/benchmark.js b/base/unary2d-by/benchmark/benchmark.js deleted file mode 100644 index cb0bef9ea..000000000 --- a/base/unary2d-by/benchmark/benchmark.js +++ /dev/null @@ -1,127 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unary2dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Accessor function. -* -* @private -* @param {number} value - array element -* @returns {number} accessed value -*/ -function accessor( value ) { - return value; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros2d( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unary2dBy( arrays, shape, identity, accessor ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 1 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 1 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unary2d-by/docs/repl.txt b/base/unary2d-by/docs/repl.txt deleted file mode 100644 index f53543c8b..000000000 --- a/base/unary2d-by/docs/repl.txt +++ /dev/null @@ -1,46 +0,0 @@ - -{{alias}}( arrays, shape, fcn, clbk[, thisArg] ) - Applies a unary function to each element retrieved from a two-dimensional - nested input array according to a callback function and assigns results to - elements in a two-dimensional nested output array. - - The callback function is provided the following arguments: - - - value: array element. - - indices: current array element indices. - - arrays: input and output arrays. - - If the callback function does not return any value (or equivalently, - explicitly returns `undefined`), the value is ignored. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Unary function to apply to callback return values. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Examples - -------- - > var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; - > var y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shape = [ 2, 2 ]; - > function clbk( v ) { return v * 2.0; }; - > {{alias}}( [ x, y ], shape, {{alias:@stdlib/math/base/special/abs}}, clbk ); - > y - [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] - - See Also - -------- - diff --git a/base/unary2d-by/docs/types/index.d.ts b/base/unary2d-by/docs/types/index.d.ts deleted file mode 100644 index 49b3f880f..000000000 --- a/base/unary2d-by/docs/types/index.d.ts +++ /dev/null @@ -1,117 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Returns the accessed value. -* -* @returns accessed value -*/ -type NullaryCallback = ( this: W ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @returns accessed value -*/ -type UnaryCallback = ( this: W, value: T ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @returns accessed value -*/ -type BinaryCallback = ( this: W, value: T, indices: Array ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @returns accessed value -*/ -type TernaryCallback = ( this: W, value: T, indices: Array, arrays: [ Array2D, Array2D ] ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @param arrays - input and output arrays -* @returns accessed value -*/ -type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; - -/** -* Callback invoked for each nested array element retrieved via a callback function. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: U ) => V; - -/** -* Applies a unary function to each element retrieved from a two-dimensional nested input array according to a callback function and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary function to apply to callback return values -* @param clbk - callback function -* @param thisArg - callback execution context -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* unary2dBy( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] -*/ -declare function unary2dBy( arrays: [ Array2D, Array2D ], shape: Shape2D, fcn: Unary, clbk: Callback, thisArg?: ThisParameterType> ): void; - - -// EXPORTS // - -export = unary2dBy; diff --git a/base/unary2d-by/docs/types/test.ts b/base/unary2d-by/docs/types/test.ts deleted file mode 100644 index 0bcb4cfc4..000000000 --- a/base/unary2d-by/docs/types/test.ts +++ /dev/null @@ -1,142 +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. -*/ - -import unary2dBy = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function identity( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unary2dBy( [ x, y ], [ 2, 2 ], identity, identity ); // $ExpectType void - unary2dBy( [ x, y ], [ 2, 2 ], identity, identity, {} ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - unary2dBy( 'abc', [ 2, 2 ], identity, identity ); // $ExpectError - unary2dBy( 3.14, [ 2, 2 ], identity, identity ); // $ExpectError - unary2dBy( true, [ 2, 2 ], identity, identity ); // $ExpectError - unary2dBy( false, [ 2, 2 ], identity, identity ); // $ExpectError - unary2dBy( null, [ 2, 2 ], identity, identity ); // $ExpectError - unary2dBy( [ '1' ], [ 2, 2 ], identity, identity ); // $ExpectError - unary2dBy( {}, [ 2, 2 ], identity, identity ); // $ExpectError - unary2dBy( ( x: number ): number => x, [ 2, 2 ], identity, identity ); // $ExpectError - - unary2dBy( 'abc', [ 2, 2 ], identity, identity, {} ); // $ExpectError - unary2dBy( 3.14, [ 2, 2 ], identity, identity, {} ); // $ExpectError - unary2dBy( true, [ 2, 2 ], identity, identity, {} ); // $ExpectError - unary2dBy( false, [ 2, 2 ], identity, identity, {} ); // $ExpectError - unary2dBy( null, [ 2, 2 ], identity, identity, {} ); // $ExpectError - unary2dBy( [ '1' ], [ 2, 2 ], identity, identity, {} ); // $ExpectError - unary2dBy( {}, [ 2, 2 ], identity, identity, {} ); // $ExpectError - unary2dBy( ( x: number ): number => x, [ 2, 2 ], identity, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unary2dBy( [ x, y ], 'abc', identity, identity ); // $ExpectError - unary2dBy( [ x, y ], 3.14, identity, identity ); // $ExpectError - unary2dBy( [ x, y ], true, identity, identity ); // $ExpectError - unary2dBy( [ x, y ], false, identity, identity ); // $ExpectError - unary2dBy( [ x, y ], null, identity, identity ); // $ExpectError - unary2dBy( [ x, y ], [ '1' ], identity, identity ); // $ExpectError - unary2dBy( [ x, y ], {}, identity, identity ); // $ExpectError - unary2dBy( [ x, y ], ( x: number ): number => x, identity, identity ); // $ExpectError - - unary2dBy( [ x, y ], 'abc', identity, identity, {} ); // $ExpectError - unary2dBy( [ x, y ], 3.14, identity, identity, {} ); // $ExpectError - unary2dBy( [ x, y ], true, identity, identity, {} ); // $ExpectError - unary2dBy( [ x, y ], false, identity, identity, {} ); // $ExpectError - unary2dBy( [ x, y ], null, identity, identity, {} ); // $ExpectError - unary2dBy( [ x, y ], [ '1' ], identity, identity, {} ); // $ExpectError - unary2dBy( [ x, y ], {}, identity, identity, {} ); // $ExpectError - unary2dBy( [ x, y ], ( x: number ): number => x, identity, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid function... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unary2dBy( [ x, y ], [ 2, 2 ], 'abc', identity ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], 3.14, identity ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], true, identity ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], false, identity ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], null, identity ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], [ '1' ], identity ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], {}, identity ); // $ExpectError - - unary2dBy( [ x, y ], [ 2, 2 ], 'abc', identity, {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], 3.14, identity, {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], true, identity, {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], false, identity, {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], null, identity, {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], [ '1' ], identity, {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], {}, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a valid function... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unary2dBy( [ x, y ], [ 2, 2 ], identity, 'abc' ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, 3.14 ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, true ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, false ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, null ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, [ '1' ] ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, {} ); // $ExpectError - - unary2dBy( [ x, y ], [ 2, 2 ], identity, 'abc', {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, 3.14, {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, true, {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, false, {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, null, {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, [ '1' ], {} ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unary2dBy(); // $ExpectError - unary2dBy( [ x, y ] ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ] ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity ); // $ExpectError - unary2dBy( [ x, y ], [ 2, 2 ], identity, identity, {}, {} ); // $ExpectError -} diff --git a/base/unary2d-by/examples/index.js b/base/unary2d-by/examples/index.js deleted file mode 100644 index a0d0974e5..000000000 --- a/base/unary2d-by/examples/index.js +++ /dev/null @@ -1,42 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary2dBy = require( './../lib' ); - -function accessor( v ) { - // Randomly determine whether a value should be considered "missing": - return ( bernoulli( 0.5 ) > 0 ) ? v : void 0; -} - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros2d( shape ); -console.log( y ); - -unary2dBy( [ x, y ], shape, abs, accessor ); -console.log( y ); diff --git a/base/unary2d-by/lib/index.js b/base/unary2d-by/lib/index.js deleted file mode 100644 index d61e49dc9..000000000 --- a/base/unary2d-by/lib/index.js +++ /dev/null @@ -1,57 +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'; - -/** -* Apply a unary function to each element retrieved from a two-dimensional nested input array according to a callback function and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/unary2d-by -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var unary2dBy = require( '@stdlib/array/base/unary2d-by' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* unary2dBy( [ x, y ], shape, scale, accessor ); -* -* console.log( y ); -* // => [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/unary2d-by/lib/main.js b/base/unary2d-by/lib/main.js deleted file mode 100644 index 0d1f27396..000000000 --- a/base/unary2d-by/lib/main.js +++ /dev/null @@ -1,96 +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'; - -// MAIN // - -/** -* Applies a unary function to each element retrieved from a two-dimensional nested input array according to a callback function and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - unary function to apply to callback return values -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {void} -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* unary2dBy( [ x, y ], shape, scale, accessor ); -* -* console.log( y ); -* // => [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] -*/ -function unary2dBy( arrays, shape, fcn, clbk ) { - var thisArg; - var S0; - var S1; - var i0; - var i1; - var x0; - var y0; - var x; - var y; - var v; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - if ( arguments.length > 4 ) { - thisArg = arguments[ 4 ]; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x[ i1 ]; - y0 = y[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v = clbk.call( thisArg, x0[ i0 ], [ i1, i0 ], [ x, y ] ); - if ( v !== void 0 ) { - y0[ i0 ] = fcn( v ); - } - } - } -} - - -// EXPORTS // - -module.exports = unary2dBy; diff --git a/base/unary2d-by/package.json b/base/unary2d-by/package.json deleted file mode 100644 index 9b5301ae0..000000000 --- a/base/unary2d-by/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/unary2d-by", - "version": "0.0.0", - "description": "Apply a unary function to each element retrieved from a two-dimensional nested input array according to a callback function and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "unary", - "apply", - "foreach", - "map", - "transform", - "accessor", - "callback", - "clbk" - ], - "__stdlib__": {} -} diff --git a/base/unary2d-by/test/test.js b/base/unary2d-by/test/test.js deleted file mode 100644 index 019c6792c..000000000 --- a/base/unary2d-by/test/test.js +++ /dev/null @@ -1,220 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var unary2dBy = require( './../lib' ); - - -// FUNCTIONS // - -function accessor( v ) { - if ( v === void 0 ) { - return; - } - return v * 2.0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof unary2dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a function to each nested input array element according to a callback function and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ]; - - y = zeros2d( shape ); - unary2dBy( [ x, y ], shape, abs, accessor ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 2, 2 ]; - x = [ - [ -1.0, void 0 ], - [ void 0, -4.0 ] - ]; - - expected = [ - [ 2.0, 0.0 ], - [ 0.0, 8.0 ] - ]; - - y = zeros2d( shape ); - unary2dBy( [ x, y ], shape, abs, accessor ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke provided functions if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = zeros2d( shape ); - - y = zeros2d( shape ); - unary2dBy( [ x, y ], [ 0, 2 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function does not invoke provided functions if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = zeros2d( shape ); - - y = zeros2d( shape ); - unary2dBy( [ x, y ], [ 2, 0 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function invokes the callback with three arguments', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - y = zeros2d( shape ); - - values = []; - indices = []; - arrays = []; - unary2dBy( [ x, y ], shape, abs, clbk ); - - expected = [ - -1.0, - -2.0, - -3.0, - -4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0 ], - [ 0, 1 ], - [ 1, 0 ], - [ 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - [ x, y ], - [ x, y ], - [ x, y ], - [ x, y ] - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( v, idx, arr ) { - values.push( v ); - indices.push( idx ); - arrays.push( arr ); - return v * 2.0; - } -}); - -tape( 'the function supports providing a callback execution context', function test( t ) { - var shape; - var ctx; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - y = zeros2d( shape ); - - ctx = { - 'count': 0 - }; - unary2dBy( [ x, y ], shape, abs, clbk, ctx ); - - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - t.end(); - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * 2.0; - } -}); diff --git a/base/unary2d/README.md b/base/unary2d/README.md deleted file mode 100644 index e2e31c71e..000000000 --- a/base/unary2d/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# unary2d - -> Apply a unary callback to elements in a two-dimensional nested input array and assign results to elements in a two-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var unary2d = require( '@stdlib/array/base/unary2d' ); -``` - -#### unary2d( arrays, shape, fcn ) - -Applies a unary callback to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; -var shape = [ 2, 2 ]; - -// Compute the absolute values in-place: -unary2d( [ x, x ], shape, abs ); -// x => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array/base/filled2d-by' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary2d = require( '@stdlib/array/base/unary2d' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros2d( shape ); -console.log( y ); - -unary2d( [ x, y ], shape, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/unary2d/benchmark/benchmark.js b/base/unary2d/benchmark/benchmark.js deleted file mode 100644 index 7c58bce5e..000000000 --- a/base/unary2d/benchmark/benchmark.js +++ /dev/null @@ -1,116 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unary2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filled2dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros2d( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unary2d( arrays, shape, identity ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 1 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 1 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::square_matrix:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unary2d/docs/repl.txt b/base/unary2d/docs/repl.txt deleted file mode 100644 index 3d514afad..000000000 --- a/base/unary2d/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a unary callback to elements in a two-dimensional nested input array - and assigns results to elements in a two-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; - > var y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shape = [ 2, 2 ]; - > {{alias}}( [ x, y ], shape, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] - - See Also - -------- - diff --git a/base/unary2d/docs/types/index.d.ts b/base/unary2d/docs/types/index.d.ts deleted file mode 100644 index 64f20a7b1..000000000 --- a/base/unary2d/docs/types/index.d.ts +++ /dev/null @@ -1,68 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array2D } from '@stdlib/types/array'; -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Applies a unary callback to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* unary2d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -*/ -declare function unary2d( arrays: [ Array2D, Array2D ], shape: Shape2D, fcn: Unary ): void; - - -// EXPORTS // - -export = unary2d; diff --git a/base/unary2d/docs/types/test.ts b/base/unary2d/docs/types/test.ts deleted file mode 100644 index 367f4c026..000000000 --- a/base/unary2d/docs/types/test.ts +++ /dev/null @@ -1,91 +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. -*/ - -import unary2d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unary2d( [ x, y ], [ 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - unary2d( 'abc', [ 2, 2 ], fcn ); // $ExpectError - unary2d( 3.14, [ 2, 2 ], fcn ); // $ExpectError - unary2d( true, [ 2, 2 ], fcn ); // $ExpectError - unary2d( false, [ 2, 2 ], fcn ); // $ExpectError - unary2d( null, [ 2, 2 ], fcn ); // $ExpectError - unary2d( [ '1' ], [ 2, 2 ], fcn ); // $ExpectError - unary2d( {}, [ 2, 2 ], fcn ); // $ExpectError - unary2d( ( x: number ): number => x, [ 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unary2d( [ x, y ], 'abc', fcn ); // $ExpectError - unary2d( [ x, y ], 3.14, fcn ); // $ExpectError - unary2d( [ x, y ], true, fcn ); // $ExpectError - unary2d( [ x, y ], false, fcn ); // $ExpectError - unary2d( [ x, y ], null, fcn ); // $ExpectError - unary2d( [ x, y ], [ '1' ], fcn ); // $ExpectError - unary2d( [ x, y ], {}, fcn ); // $ExpectError - unary2d( [ x, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unary2d( [ x, y ], [ 2, 2 ], 'abc' ); // $ExpectError - unary2d( [ x, y ], [ 2, 2 ], 3.14 ); // $ExpectError - unary2d( [ x, y ], [ 2, 2 ], true ); // $ExpectError - unary2d( [ x, y ], [ 2, 2 ], false ); // $ExpectError - unary2d( [ x, y ], [ 2, 2 ], null ); // $ExpectError - unary2d( [ x, y ], [ 2, 2 ], [ '1' ] ); // $ExpectError - unary2d( [ x, y ], [ 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unary2d(); // $ExpectError - unary2d( [ x, y ] ); // $ExpectError - unary2d( [ x, y ], [ 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/unary2d/examples/index.js b/base/unary2d/examples/index.js deleted file mode 100644 index b37ce6436..000000000 --- a/base/unary2d/examples/index.js +++ /dev/null @@ -1,36 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled2dBy = require( './../../../base/filled2d-by' ); -var zeros2d = require( './../../../base/zeros2d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary2d = require( './../lib' ); - -var shape = [ 3, 3 ]; - -var x = filled2dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros2d( shape ); -console.log( y ); - -unary2d( [ x, y ], shape, abs ); -console.log( y ); diff --git a/base/unary2d/lib/index.js b/base/unary2d/lib/index.js deleted file mode 100644 index 93b132c1d..000000000 --- a/base/unary2d/lib/index.js +++ /dev/null @@ -1,53 +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'; - -/** -* Apply a unary callback to elements in a two-dimensional nested input array and assign results to elements in a two-dimensional nested output array. -* -* @module @stdlib/array/base/unary2d -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* var unary2d = require( '@stdlib/array/base/unary2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* unary2d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/unary2d/lib/main.js b/base/unary2d/lib/main.js deleted file mode 100644 index 6f7745149..000000000 --- a/base/unary2d/lib/main.js +++ /dev/null @@ -1,82 +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'; - -// MAIN // - -/** -* Applies a unary callback to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones2d = require( '@stdlib/array/base/ones2d' ); -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = ones2d( shape ); -* var y = zeros2d( shape ); -* -* unary2d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -*/ -function unary2d( arrays, shape, fcn ) { - var S0; - var S1; - var i0; - var i1; - var x0; - var y0; - var x; - var y; - - S0 = shape[ 1 ]; - S1 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x[ i1 ]; - y0 = y[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn( x0[ i0 ] ); - } - } -} - - -// EXPORTS // - -module.exports = unary2d; diff --git a/base/unary2d/package.json b/base/unary2d/package.json deleted file mode 100644 index eec9ae297..000000000 --- a/base/unary2d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/unary2d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a two-dimensional nested input array and assign results to elements in a two-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "2d", - "unary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/unary2d/test/test.js b/base/unary2d/test/test.js deleted file mode 100644 index c431be426..000000000 --- a/base/unary2d/test/test.js +++ /dev/null @@ -1,109 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros2d = require( './../../../base/zeros2d' ); -var unary2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof unary2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - - y = zeros2d( shape ); - unary2d( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = zeros2d( shape ); - - y = zeros2d( shape ); - unary2d( [ x, y ], [ 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = zeros2d( shape ); - - y = zeros2d( shape ); - unary2d( [ x, y ], [ 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/unary3d-by/README.md b/base/unary3d-by/README.md deleted file mode 100644 index 081c246f2..000000000 --- a/base/unary3d-by/README.md +++ /dev/null @@ -1,180 +0,0 @@ - - -# unary3dBy - -> Apply a unary function to each element retrieved from a three-dimensional nested input array according to a callback function and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var unary3dBy = require( '@stdlib/array/base/unary3d-by' ); -``` - -#### unary3dBy( arrays, shape, fcn, clbk\[, thisArg] ) - -Applies a unary function to each element retrieved from a three-dimensional nested input array according to a callback function and assigns results to elements in a three-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -function accessor( v ) { - return v * 2.0; -} - -var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; -var shape = [ 1, 2, 2 ]; - -unary3dBy( [ x, x ], shape, abs, accessor ); -// x => [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply to callback return values. -- **clbk**: callback function. -- **thisArg**: callback function execution context (optional). - -The invoked callback function is provided the following arguments: - -- **value**: array element. -- **indices**: current array element indices. -- **arrays**: input and output arrays. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -function accessor( v ) { - this.count += 1; - return v * 2.0; -} - -var context = { - 'count': 0 -}; - -var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; -var y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - -var shape = [ 1, 2, 2 ]; - -unary3dBy( [ x, y ], shape, abs, accessor, context ); -// y => [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] - -var cnt = context.count; -// returns 4 -``` - -
- - - -
- -## Notes - -- If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is **ignored**. - - ```javascript - var abs = require( '@stdlib/math/base/special/abs' ); - - function accessor() { - // No-op... - } - - var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; - var y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - var shape = [ 1, 2, 2 ]; - - unary3dBy( [ x, y ], shape, abs, accessor ); - // y => [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] - ``` - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary3dBy = require( '@stdlib/array/base/unary3d-by' ); - -function accessor( v ) { - // Randomly determine whether a value should be considered "missing": - return ( bernoulli( 0.5 ) > 0 ) ? v : void 0; -} - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros3d( shape ); -console.log( y ); - -unary3dBy( [ x, y ], shape, abs, accessor ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/unary3d-by/benchmark/benchmark.js b/base/unary3d-by/benchmark/benchmark.js deleted file mode 100644 index 2701b3b88..000000000 --- a/base/unary3d-by/benchmark/benchmark.js +++ /dev/null @@ -1,130 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unary3dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Accessor function. -* -* @private -* @param {number} value - array element -* @returns {number} accessed value -*/ -function accessor( value ) { - return value; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros3d( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unary3dBy( arrays, shape, identity, accessor ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 1 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 1 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unary3d-by/docs/repl.txt b/base/unary3d-by/docs/repl.txt deleted file mode 100644 index e79350c21..000000000 --- a/base/unary3d-by/docs/repl.txt +++ /dev/null @@ -1,46 +0,0 @@ - -{{alias}}( arrays, shape, fcn, clbk[, thisArg] ) - Applies a unary function to each element retrieved from a three-dimensional - nested input array according to a callback function and assigns results to - elements in a three-dimensional nested output array. - - The callback function is provided the following arguments: - - - value: array element. - - indices: current array element indices. - - arrays: input and output arrays. - - If the callback function does not return any value (or equivalently, - explicitly returns `undefined`), the value is ignored. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Unary function to apply to callback return values. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Examples - -------- - > var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; - > var y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - > var shape = [ 1, 2, 2 ]; - > function clbk( v ) { return v * 2.0; }; - > {{alias}}( [ x, y ], shape, {{alias:@stdlib/math/base/special/abs}}, clbk ); - > y - [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] - - See Also - -------- - diff --git a/base/unary3d-by/docs/types/index.d.ts b/base/unary3d-by/docs/types/index.d.ts deleted file mode 100644 index 7738b3fa3..000000000 --- a/base/unary3d-by/docs/types/index.d.ts +++ /dev/null @@ -1,117 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Returns the accessed value. -* -* @returns accessed value -*/ -type NullaryCallback = ( this: W ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @returns accessed value -*/ -type UnaryCallback = ( this: W, value: T ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @returns accessed value -*/ -type BinaryCallback = ( this: W, value: T, indices: Array ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @returns accessed value -*/ -type TernaryCallback = ( this: W, value: T, indices: Array, arrays: [ Array3D, Array3D ] ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @param arrays - input and output arrays -* @returns accessed value -*/ -type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; - -/** -* Callback invoked for each nested array element retrieved via a callback function. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: U ) => V; - -/** -* Applies a unary function to each element retrieved from a three-dimensional nested input array according to a callback function and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary function to apply to callback return values -* @param clbk - callback function -* @param thisArg - callback execution context -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* unary3dBy( [ x, y ], shape, scale, accessor ); -* -* console.log( y ); -* // => [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] -*/ -declare function unary3dBy( arrays: [ Array3D, Array3D ], shape: Shape3D, fcn: Unary, clbk: Callback, thisArg?: ThisParameterType> ): void; - - -// EXPORTS // - -export = unary3dBy; diff --git a/base/unary3d-by/docs/types/test.ts b/base/unary3d-by/docs/types/test.ts deleted file mode 100644 index f9607b313..000000000 --- a/base/unary3d-by/docs/types/test.ts +++ /dev/null @@ -1,142 +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. -*/ - -import unary3dBy = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function identity( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, identity ); // $ExpectType void - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, identity, {} ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - unary3dBy( 'abc', [ 1, 2, 2 ], identity, identity ); // $ExpectError - unary3dBy( 3.14, [ 1, 2, 2 ], identity, identity ); // $ExpectError - unary3dBy( true, [ 1, 2, 2 ], identity, identity ); // $ExpectError - unary3dBy( false, [ 1, 2, 2 ], identity, identity ); // $ExpectError - unary3dBy( null, [ 1, 2, 2 ], identity, identity ); // $ExpectError - unary3dBy( [ '1' ], [ 1, 2, 2 ], identity, identity ); // $ExpectError - unary3dBy( {}, [ 1, 2, 2 ], identity, identity ); // $ExpectError - unary3dBy( ( x: number ): number => x, [ 1, 2, 2 ], identity, identity ); // $ExpectError - - unary3dBy( 'abc', [ 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary3dBy( 3.14, [ 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary3dBy( true, [ 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary3dBy( false, [ 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary3dBy( null, [ 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary3dBy( [ '1' ], [ 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary3dBy( {}, [ 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary3dBy( ( x: number ): number => x, [ 1, 2, 2 ], identity, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - unary3dBy( [ x, y ], 'abc', identity, identity ); // $ExpectError - unary3dBy( [ x, y ], 3.14, identity, identity ); // $ExpectError - unary3dBy( [ x, y ], true, identity, identity ); // $ExpectError - unary3dBy( [ x, y ], false, identity, identity ); // $ExpectError - unary3dBy( [ x, y ], null, identity, identity ); // $ExpectError - unary3dBy( [ x, y ], [ '1' ], identity, identity ); // $ExpectError - unary3dBy( [ x, y ], {}, identity, identity ); // $ExpectError - unary3dBy( [ x, y ], ( x: number ): number => x, identity, identity ); // $ExpectError - - unary3dBy( [ x, y ], 'abc', identity, identity, {} ); // $ExpectError - unary3dBy( [ x, y ], 3.14, identity, identity, {} ); // $ExpectError - unary3dBy( [ x, y ], true, identity, identity, {} ); // $ExpectError - unary3dBy( [ x, y ], false, identity, identity, {} ); // $ExpectError - unary3dBy( [ x, y ], null, identity, identity, {} ); // $ExpectError - unary3dBy( [ x, y ], [ '1' ], identity, identity, {} ); // $ExpectError - unary3dBy( [ x, y ], {}, identity, identity, {} ); // $ExpectError - unary3dBy( [ x, y ], ( x: number ): number => x, identity, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid function... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - unary3dBy( [ x, y ], [ 1, 2, 2 ], 'abc', identity ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], 3.14, identity ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], true, identity ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], false, identity ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], null, identity ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], [ '1' ], identity ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], {}, identity ); // $ExpectError - - unary3dBy( [ x, y ], [ 1, 2, 2 ], 'abc', identity, {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], 3.14, identity, {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], true, identity, {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], false, identity, {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], null, identity, {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], [ '1' ], identity, {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], {}, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a valid function... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, 'abc' ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, 3.14 ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, true ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, false ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, null ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, [ '1' ] ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, {} ); // $ExpectError - - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, 'abc', {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, 3.14, {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, true, {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, false, {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, null, {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, [ '1' ], {} ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - unary3dBy(); // $ExpectError - unary3dBy( [ x, y ] ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ] ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity ); // $ExpectError - unary3dBy( [ x, y ], [ 1, 2, 2 ], identity, identity, {}, {} ); // $ExpectError -} diff --git a/base/unary3d-by/examples/index.js b/base/unary3d-by/examples/index.js deleted file mode 100644 index 37ac73ab7..000000000 --- a/base/unary3d-by/examples/index.js +++ /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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary3dBy = require( './../lib' ); - -function accessor( v ) { - // Randomly determine whether a value should be considered "missing": - return ( bernoulli( 0.5 ) > 0 ) ? v : void 0; -} - -var shape = [ 3, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros3d( shape ); -console.log( y ); - -unary3dBy( [ x, y ], shape, abs, accessor ); -console.log( y ); diff --git a/base/unary3d-by/lib/index.js b/base/unary3d-by/lib/index.js deleted file mode 100644 index 925350ae4..000000000 --- a/base/unary3d-by/lib/index.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -/** -* Apply a unary function to each element retrieved from a three-dimensional nested input array according to a callback function and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/unary3d-by -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var unary3dBy = require( '@stdlib/array/base/unary3d-by' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* unary3dBy( [ x, y ], shape, scale, accessor ); -* -* console.log( y ); -* // => [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/unary3d-by/lib/main.js b/base/unary3d-by/lib/main.js deleted file mode 100644 index d88eeb40a..000000000 --- a/base/unary3d-by/lib/main.js +++ /dev/null @@ -1,105 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a unary function to each element retrieved from a three-dimensional nested input array according to a callback function and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - unary function to apply to callback return values -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {void} -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* unary3dBy( [ x, y ], shape, scale, accessor ); -* -* console.log( y ); -* // => [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] -*/ -function unary3dBy( arrays, shape, fcn, clbk ) { - var thisArg; - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var x0; - var x1; - var y0; - var y1; - var x; - var y; - var v; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - if ( arguments.length > 4 ) { - thisArg = arguments[ 4 ]; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x[ i2 ]; - y1 = y[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v = clbk.call( thisArg, x0[ i0 ], [ i2, i1, i0 ], [ x, y ] ); - if ( v !== void 0 ) { - y0[ i0 ] = fcn( v ); - } - } - } - } -} - - -// EXPORTS // - -module.exports = unary3dBy; diff --git a/base/unary3d-by/package.json b/base/unary3d-by/package.json deleted file mode 100644 index 088e3504c..000000000 --- a/base/unary3d-by/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/unary3d-by", - "version": "0.0.0", - "description": "Apply a unary function to each element retrieved from a three-dimensional nested input array according to a callback function and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "unary", - "apply", - "foreach", - "map", - "transform", - "accessor", - "callback", - "clbk" - ], - "__stdlib__": {} -} diff --git a/base/unary3d-by/test/test.js b/base/unary3d-by/test/test.js deleted file mode 100644 index 633c71996..000000000 --- a/base/unary3d-by/test/test.js +++ /dev/null @@ -1,279 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var unary3dBy = require( './../lib' ); - - -// FUNCTIONS // - -function accessor( v ) { - if ( v === void 0 ) { - return; - } - return v * 2.0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof unary3dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a function to each nested input array element according to a callback function and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = [ - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ], - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ] - ]; - - y = zeros3d( shape ); - unary3dBy( [ x, y ], shape, abs, accessor ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ -1.0, void 0 ], - [ void 0, -4.0 ] - ], - [ - [ -1.0, void 0 ], - [ void 0, -4.0 ] - ] - ]; - - expected = [ - [ - [ 2.0, 0.0 ], - [ 0.0, 8.0 ] - ], - [ - [ 2.0, 0.0 ], - [ 0.0, 8.0 ] - ] - ]; - - y = zeros3d( shape ); - unary3dBy( [ x, y ], shape, abs, accessor ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke provided functions if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - unary3dBy( [ x, y ], [ 0, 2, 2 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function does not invoke provided functions if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - unary3dBy( [ x, y ], [ 1, 0, 2 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function does not invoke provided functions if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - unary3dBy( [ x, y ], [ 1, 2, 0 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function invokes the callback with three arguments', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var x; - var y; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - y = zeros3d( shape ); - - values = []; - indices = []; - arrays = []; - unary3dBy( [ x, y ], shape, abs, clbk ); - - expected = [ - -1.0, - -2.0, - -3.0, - -4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0 ], - [ 0, 0, 1 ], - [ 0, 1, 0 ], - [ 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - [ x, y ], - [ x, y ], - [ x, y ], - [ x, y ] - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( v, idx, arr ) { - values.push( v ); - indices.push( idx ); - arrays.push( arr ); - return v * 2.0; - } -}); - -tape( 'the function supports providing a callback execution context', function test( t ) { - var shape; - var ctx; - var x; - var y; - - shape = [ 1, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - y = zeros3d( shape ); - - ctx = { - 'count': 0 - }; - unary3dBy( [ x, y ], shape, abs, clbk, ctx ); - - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - t.end(); - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * 2.0; - } -}); diff --git a/base/unary3d/README.md b/base/unary3d/README.md deleted file mode 100644 index 5acf47da1..000000000 --- a/base/unary3d/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# unary3d - -> Apply a unary callback to elements in a three-dimensional nested input array and assign results to elements in a three-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var unary3d = require( '@stdlib/array/base/unary3d' ); -``` - -#### unary3d( arrays, shape, fcn ) - -Applies a unary callback to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; -var shape = [ 1, 2, 2 ]; - -// Compute the absolute values in-place: -unary3d( [ x, x ], shape, abs ); -// x => [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( '@stdlib/array/base/filled3d-by' ); -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary3d = require( '@stdlib/array/base/unary3d' ); - -var shape = [ 2, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros3d( shape ); -console.log( y ); - -unary3d( [ x, y ], shape, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/unary3d/benchmark/benchmark.js b/base/unary3d/benchmark/benchmark.js deleted file mode 100644 index 56edb735e..000000000 --- a/base/unary3d/benchmark/benchmark.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unary3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filled3dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros3d( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unary3d( arrays, shape, identity ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 1 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 1 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unary3d/docs/repl.txt b/base/unary3d/docs/repl.txt deleted file mode 100644 index fc5193e8f..000000000 --- a/base/unary3d/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a unary callback to elements in a three-dimensional nested input - array and assigns results to elements in a three-dimensional nested output - array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ]; - > var y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - > var shape = [ 1, 2, 2 ]; - > {{alias}}( [ x, y ], shape, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] - - See Also - -------- - diff --git a/base/unary3d/docs/types/index.d.ts b/base/unary3d/docs/types/index.d.ts deleted file mode 100644 index de727c6e6..000000000 --- a/base/unary3d/docs/types/index.d.ts +++ /dev/null @@ -1,68 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array3D } from '@stdlib/types/array'; -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Applies a unary callback to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* unary3d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -*/ -declare function unary3d( arrays: [ Array3D, Array3D ], shape: Shape3D, fcn: Unary ): void; - - -// EXPORTS // - -export = unary3d; diff --git a/base/unary3d/docs/types/test.ts b/base/unary3d/docs/types/test.ts deleted file mode 100644 index 1a3870669..000000000 --- a/base/unary3d/docs/types/test.ts +++ /dev/null @@ -1,91 +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. -*/ - -import unary3d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - unary3d( [ x, y ], [ 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - unary3d( 'abc', [ 1, 2, 2 ], fcn ); // $ExpectError - unary3d( 3.14, [ 1, 2, 2 ], fcn ); // $ExpectError - unary3d( true, [ 1, 2, 2 ], fcn ); // $ExpectError - unary3d( false, [ 1, 2, 2 ], fcn ); // $ExpectError - unary3d( null, [ 1, 2, 2 ], fcn ); // $ExpectError - unary3d( [ '1' ], [ 1, 2, 2 ], fcn ); // $ExpectError - unary3d( {}, [ 1, 2, 2 ], fcn ); // $ExpectError - unary3d( ( x: number ): number => x, [ 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - unary3d( [ x, y ], 'abc', fcn ); // $ExpectError - unary3d( [ x, y ], 3.14, fcn ); // $ExpectError - unary3d( [ x, y ], true, fcn ); // $ExpectError - unary3d( [ x, y ], false, fcn ); // $ExpectError - unary3d( [ x, y ], null, fcn ); // $ExpectError - unary3d( [ x, y ], [ '1' ], fcn ); // $ExpectError - unary3d( [ x, y ], {}, fcn ); // $ExpectError - unary3d( [ x, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - unary3d( [ x, y ], [ 1, 2, 2 ], 'abc' ); // $ExpectError - unary3d( [ x, y ], [ 1, 2, 2 ], 3.14 ); // $ExpectError - unary3d( [ x, y ], [ 1, 2, 2 ], true ); // $ExpectError - unary3d( [ x, y ], [ 1, 2, 2 ], false ); // $ExpectError - unary3d( [ x, y ], [ 1, 2, 2 ], null ); // $ExpectError - unary3d( [ x, y ], [ 1, 2, 2 ], [ '1' ] ); // $ExpectError - unary3d( [ x, y ], [ 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - unary3d(); // $ExpectError - unary3d( [ x, y ] ); // $ExpectError - unary3d( [ x, y ], [ 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/unary3d/examples/index.js b/base/unary3d/examples/index.js deleted file mode 100644 index 6ab2fead6..000000000 --- a/base/unary3d/examples/index.js +++ /dev/null @@ -1,36 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled3dBy = require( './../../../base/filled3d-by' ); -var zeros3d = require( './../../../base/zeros3d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary3d = require( './../lib' ); - -var shape = [ 2, 3, 3 ]; - -var x = filled3dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros3d( shape ); -console.log( y ); - -unary3d( [ x, y ], shape, abs ); -console.log( y ); diff --git a/base/unary3d/lib/index.js b/base/unary3d/lib/index.js deleted file mode 100644 index 407507d13..000000000 --- a/base/unary3d/lib/index.js +++ /dev/null @@ -1,53 +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'; - -/** -* Apply a unary callback to elements in a three-dimensional nested input array and assign results to elements in a three-dimensional nested output array. -* -* @module @stdlib/array/base/unary3d -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* var unary3d = require( '@stdlib/array/base/unary3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* unary3d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/unary3d/lib/main.js b/base/unary3d/lib/main.js deleted file mode 100644 index e6ecf9819..000000000 --- a/base/unary3d/lib/main.js +++ /dev/null @@ -1,91 +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'; - -// MAIN // - -/** -* Applies a unary callback to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>} arrays - array-like object containing one input nested array and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones3d = require( '@stdlib/array/base/ones3d' ); -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = ones3d( shape ); -* var y = zeros3d( shape ); -* -* unary3d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -*/ -function unary3d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var i0; - var i1; - var i2; - var x0; - var x1; - var y0; - var y1; - var x; - var y; - - S0 = shape[ 2 ]; - S1 = shape[ 1 ]; - S2 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x[ i2 ]; - y1 = y[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn( x0[ i0 ] ); - } - } - } -} - - -// EXPORTS // - -module.exports = unary3d; diff --git a/base/unary3d/package.json b/base/unary3d/package.json deleted file mode 100644 index 98758dbdd..000000000 --- a/base/unary3d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/unary3d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a three-dimensional nested input array and assign results to elements in a three-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "3d", - "unary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/unary3d/test/test.js b/base/unary3d/test/test.js deleted file mode 100644 index 876c36d6f..000000000 --- a/base/unary3d/test/test.js +++ /dev/null @@ -1,164 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros3d = require( './../../../base/zeros3d' ); -var unary3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof unary3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - - y = zeros3d( shape ); - unary3d( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - unary3d( [ x, y ], [ 0, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - unary3d( [ x, y ], [ 2, 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zeros3d( shape ); - - y = zeros3d( shape ); - unary3d( [ x, y ], [ 2, 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/unary4d-by/README.md b/base/unary4d-by/README.md deleted file mode 100644 index 96056731a..000000000 --- a/base/unary4d-by/README.md +++ /dev/null @@ -1,180 +0,0 @@ - - -# unary4dBy - -> Apply a unary function to each element retrieved from a four-dimensional nested input array according to a callback function and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var unary4dBy = require( '@stdlib/array/base/unary4d-by' ); -``` - -#### unary4dBy( arrays, shape, fcn, clbk\[, thisArg] ) - -Applies a unary function to each element retrieved from a four-dimensional nested input array according to a callback function and assigns results to elements in a four-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -function accessor( v ) { - return v * 2.0; -} - -var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; -var shape = [ 1, 1, 2, 2 ]; - -unary4dBy( [ x, x ], shape, abs, accessor ); -// x => [ [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply to callback return values. -- **clbk**: callback function. -- **thisArg**: callback function execution context (optional). - -The invoked callback function is provided the following arguments: - -- **value**: array element. -- **indices**: current array element indices. -- **arrays**: input and output arrays. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -function accessor( v ) { - this.count += 1; - return v * 2.0; -} - -var context = { - 'count': 0 -}; - -var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; -var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - -var shape = [ 1, 1, 2, 2 ]; - -unary4dBy( [ x, y ], shape, abs, accessor, context ); -// y => [ [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] ] - -var cnt = context.count; -// returns 4 -``` - -
- - - -
- -## Notes - -- If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is **ignored**. - - ```javascript - var abs = require( '@stdlib/math/base/special/abs' ); - - function accessor() { - // No-op... - } - - var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - var shape = [ 1, 1, 2, 2 ]; - - unary4dBy( [ x, y ], shape, abs, accessor ); - // y => [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] - ``` - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary4dBy = require( '@stdlib/array/base/unary4d-by' ); - -function accessor( v ) { - // Randomly determine whether a value should be considered "missing": - return ( bernoulli( 0.5 ) > 0 ) ? v : void 0; -} - -var shape = [ 2, 2, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros4d( shape ); -console.log( y ); - -unary4dBy( [ x, y ], shape, abs, accessor ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/unary4d-by/benchmark/benchmark.js b/base/unary4d-by/benchmark/benchmark.js deleted file mode 100644 index 078538db9..000000000 --- a/base/unary4d-by/benchmark/benchmark.js +++ /dev/null @@ -1,133 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unary4dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Accessor function. -* -* @private -* @param {number} value - array element -* @returns {number} accessed value -*/ -function accessor( value ) { - return value; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unary4dBy( arrays, shape, identity, accessor ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 1 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 1 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unary4d-by/docs/repl.txt b/base/unary4d-by/docs/repl.txt deleted file mode 100644 index 97627d851..000000000 --- a/base/unary4d-by/docs/repl.txt +++ /dev/null @@ -1,46 +0,0 @@ - -{{alias}}( arrays, shape, fcn, clbk[, thisArg] ) - Applies a unary function to each element retrieved from a four-dimensional - nested input array according to a callback function and assigns results to - elements in a four-dimensional nested output array. - - The callback function is provided the following arguments: - - - value: array element. - - indices: current array element indices. - - arrays: input and output arrays. - - If the callback function does not return any value (or equivalently, - explicitly returns `undefined`), the value is ignored. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Unary function to apply to callback return values. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > function clbk( v ) { return v * 2.0; }; - > {{alias}}( [ x, y ], shape, {{alias:@stdlib/math/base/special/abs}}, clbk ); - > y - [ [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] ] - - See Also - -------- - diff --git a/base/unary4d-by/docs/types/index.d.ts b/base/unary4d-by/docs/types/index.d.ts deleted file mode 100644 index c11e1214f..000000000 --- a/base/unary4d-by/docs/types/index.d.ts +++ /dev/null @@ -1,117 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Returns the accessed value. -* -* @returns accessed value -*/ -type NullaryCallback = ( this: W ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @returns accessed value -*/ -type UnaryCallback = ( this: W, value: T ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @returns accessed value -*/ -type BinaryCallback = ( this: W, value: T, indices: Array ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @returns accessed value -*/ -type TernaryCallback = ( this: W, value: T, indices: Array, arrays: [ Array4D, Array4D ] ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @param arrays - input and output arrays -* @returns accessed value -*/ -type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; - -/** -* Callback invoked for each nested array element retrieved via a callback function. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: U ) => V; - -/** -* Applies a unary function to each element retrieved from a four-dimensional nested input array according to a callback function and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary function to apply to callback return values -* @param clbk - callback function -* @param thisArg - callback execution context -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* unary4dBy( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ] -*/ -declare function unary4dBy( arrays: [ Array4D, Array4D ], shape: Shape4D, fcn: Unary, clbk: Callback, thisArg?: ThisParameterType> ): void; - - -// EXPORTS // - -export = unary4dBy; diff --git a/base/unary4d-by/docs/types/test.ts b/base/unary4d-by/docs/types/test.ts deleted file mode 100644 index e806e860f..000000000 --- a/base/unary4d-by/docs/types/test.ts +++ /dev/null @@ -1,142 +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. -*/ - -import unary4dBy = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function identity( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, identity ); // $ExpectType void - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - unary4dBy( 'abc', [ 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary4dBy( 3.14, [ 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary4dBy( true, [ 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary4dBy( false, [ 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary4dBy( null, [ 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary4dBy( [ '1' ], [ 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary4dBy( {}, [ 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary4dBy( ( x: number ): number => x, [ 1, 1, 2, 2 ], identity, identity ); // $ExpectError - - unary4dBy( 'abc', [ 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary4dBy( 3.14, [ 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary4dBy( true, [ 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary4dBy( false, [ 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary4dBy( null, [ 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary4dBy( [ '1' ], [ 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary4dBy( {}, [ 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary4dBy( ( x: number ): number => x, [ 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - unary4dBy( [ x, y ], 'abc', identity, identity ); // $ExpectError - unary4dBy( [ x, y ], 3.14, identity, identity ); // $ExpectError - unary4dBy( [ x, y ], true, identity, identity ); // $ExpectError - unary4dBy( [ x, y ], false, identity, identity ); // $ExpectError - unary4dBy( [ x, y ], null, identity, identity ); // $ExpectError - unary4dBy( [ x, y ], [ '1' ], identity, identity ); // $ExpectError - unary4dBy( [ x, y ], {}, identity, identity ); // $ExpectError - unary4dBy( [ x, y ], ( x: number ): number => x, identity, identity ); // $ExpectError - - unary4dBy( [ x, y ], 'abc', identity, identity, {} ); // $ExpectError - unary4dBy( [ x, y ], 3.14, identity, identity, {} ); // $ExpectError - unary4dBy( [ x, y ], true, identity, identity, {} ); // $ExpectError - unary4dBy( [ x, y ], false, identity, identity, {} ); // $ExpectError - unary4dBy( [ x, y ], null, identity, identity, {} ); // $ExpectError - unary4dBy( [ x, y ], [ '1' ], identity, identity, {} ); // $ExpectError - unary4dBy( [ x, y ], {}, identity, identity, {} ); // $ExpectError - unary4dBy( [ x, y ], ( x: number ): number => x, identity, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid function... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], 'abc', identity ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], 3.14, identity ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], true, identity ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], false, identity ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], null, identity ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], [ '1' ], identity ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], {}, identity ); // $ExpectError - - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], 'abc', identity, {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], 3.14, identity, {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], true, identity, {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], false, identity, {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], null, identity, {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], [ '1' ], identity, {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], {}, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a valid function... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, 'abc' ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, 3.14 ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, true ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, false ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, null ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, [ '1' ] ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, {} ); // $ExpectError - - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, 'abc', {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, 3.14, {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, true, {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, false, {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, null, {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, [ '1' ], {} ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - unary4dBy(); // $ExpectError - unary4dBy( [ x, y ] ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ] ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity ); // $ExpectError - unary4dBy( [ x, y ], [ 1, 1, 2, 2 ], identity, identity, {}, {} ); // $ExpectError -} diff --git a/base/unary4d-by/examples/index.js b/base/unary4d-by/examples/index.js deleted file mode 100644 index 1e90876d0..000000000 --- a/base/unary4d-by/examples/index.js +++ /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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary4dBy = require( './../lib' ); - -function accessor( v ) { - // Randomly determine whether a value should be considered "missing": - return ( bernoulli( 0.5 ) > 0 ) ? v : void 0; -} - -var shape = [ 2, 2, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros4d( shape ); -console.log( y ); - -unary4dBy( [ x, y ], shape, abs, accessor ); -console.log( y ); diff --git a/base/unary4d-by/lib/index.js b/base/unary4d-by/lib/index.js deleted file mode 100644 index 2ff069354..000000000 --- a/base/unary4d-by/lib/index.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -/** -* Apply a unary function to each element retrieved from a four-dimensional nested input array according to a callback function and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/unary4d-by -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var unary4dBy = require( '@stdlib/array/base/unary4d-by' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* unary4dBy( [ x, y ], shape, scale, accessor ); -* -* console.log( y ); -* // => [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/unary4d-by/lib/main.js b/base/unary4d-by/lib/main.js deleted file mode 100644 index 7d8e3f2d6..000000000 --- a/base/unary4d-by/lib/main.js +++ /dev/null @@ -1,114 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a unary function to each element retrieved from a four-dimensional nested input array according to a callback function and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - unary function to apply to callback return values -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {void} -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* unary4dBy( [ x, y ], shape, scale, accessor ); -* -* console.log( y ); -* // => [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ] -*/ -function unary4dBy( arrays, shape, fcn, clbk ) { - var thisArg; - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var x1; - var x2; - var y0; - var y1; - var y2; - var x; - var y; - var v; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - if ( arguments.length > 4 ) { - thisArg = arguments[ 4 ]; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v = clbk.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], [ x, y ] ); // eslint-disable-line max-len - if ( v !== void 0 ) { - y0[ i0 ] = fcn( v ); - } - } - } - } - } -} - - -// EXPORTS // - -module.exports = unary4dBy; diff --git a/base/unary4d-by/package.json b/base/unary4d-by/package.json deleted file mode 100644 index 6290f536c..000000000 --- a/base/unary4d-by/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/unary4d-by", - "version": "0.0.0", - "description": "Apply a unary function to each element retrieved from a four-dimensional nested input array according to a callback function and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "unary", - "apply", - "foreach", - "map", - "transform", - "accessor", - "callback", - "clbk" - ], - "__stdlib__": {} -} diff --git a/base/unary4d-by/test/test.js b/base/unary4d-by/test/test.js deleted file mode 100644 index c3abb5386..000000000 --- a/base/unary4d-by/test/test.js +++ /dev/null @@ -1,310 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var unary4dBy = require( './../lib' ); - - -// FUNCTIONS // - -function accessor( v ) { - if ( v === void 0 ) { - return; - } - return v * 2.0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof unary4dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a function to each nested input array element according to a callback function and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - unary4dBy( [ x, y ], shape, abs, accessor ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, void 0 ], - [ void 0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 2.0, 0.0 ], - [ 0.0, 8.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - unary4dBy( [ x, y ], shape, abs, accessor ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke provided functions if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - unary4dBy( [ x, y ], [ 0, 1, 2, 2 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function does not invoke provided functions if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - unary4dBy( [ x, y ], [ 1, 0, 2, 2 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function does not invoke provided functions if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - unary4dBy( [ x, y ], [ 1, 1, 0, 2 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function does not invoke provided functions if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - unary4dBy( [ x, y ], [ 1, 1, 2, 0 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function invokes the callback with three arguments', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - - values = []; - indices = []; - arrays = []; - unary4dBy( [ x, y ], shape, abs, clbk ); - - expected = [ - -1.0, - -2.0, - -3.0, - -4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - [ x, y ], - [ x, y ], - [ x, y ], - [ x, y ] - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( v, idx, arr ) { - values.push( v ); - indices.push( idx ); - arrays.push( arr ); - return v * 2.0; - } -}); - -tape( 'the function supports providing a callback execution context', function test( t ) { - var shape; - var ctx; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - - ctx = { - 'count': 0 - }; - unary4dBy( [ x, y ], shape, abs, clbk, ctx ); - - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - t.end(); - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * 2.0; - } -}); diff --git a/base/unary4d/README.md b/base/unary4d/README.md deleted file mode 100644 index 41df07c73..000000000 --- a/base/unary4d/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# unary4d - -> Apply a unary callback to elements in a four-dimensional nested input array and assign results to elements in a four-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var unary4d = require( '@stdlib/array/base/unary4d' ); -``` - -#### unary4d( arrays, shape, fcn ) - -Applies a unary callback to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; -var shape = [ 1, 1, 2, 2 ]; - -// Compute the absolute values in-place: -unary4d( [ x, x ], shape, abs ); -// x => [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array/base/filled4d-by' ); -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary4d = require( '@stdlib/array/base/unary4d' ); - -var shape = [ 2, 2, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros4d( shape ); -console.log( y ); - -unary4d( [ x, y ], shape, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/unary4d/benchmark/benchmark.js b/base/unary4d/benchmark/benchmark.js deleted file mode 100644 index 922204858..000000000 --- a/base/unary4d/benchmark/benchmark.js +++ /dev/null @@ -1,122 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unary4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unary4d( arrays, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 1 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 1 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unary4d/docs/repl.txt b/base/unary4d/docs/repl.txt deleted file mode 100644 index 234a075bd..000000000 --- a/base/unary4d/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a unary callback to elements in a four-dimensional nested input - array and assigns results to elements in a four-dimensional nested output - array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > {{alias}}( [ x, y ], shape, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - See Also - -------- - diff --git a/base/unary4d/docs/types/index.d.ts b/base/unary4d/docs/types/index.d.ts deleted file mode 100644 index c00abea67..000000000 --- a/base/unary4d/docs/types/index.d.ts +++ /dev/null @@ -1,68 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Applies a unary callback to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* unary4d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -declare function unary4d( arrays: [ Array4D, Array4D ], shape: Shape4D, fcn: Unary ): void; - - -// EXPORTS // - -export = unary4d; diff --git a/base/unary4d/docs/types/test.ts b/base/unary4d/docs/types/test.ts deleted file mode 100644 index f66ffcebb..000000000 --- a/base/unary4d/docs/types/test.ts +++ /dev/null @@ -1,91 +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. -*/ - -import unary4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - unary4d( [ x, y ], [ 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - unary4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - unary4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - unary4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - unary4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - unary4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - unary4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - unary4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - unary4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - unary4d( [ x, y ], 'abc', fcn ); // $ExpectError - unary4d( [ x, y ], 3.14, fcn ); // $ExpectError - unary4d( [ x, y ], true, fcn ); // $ExpectError - unary4d( [ x, y ], false, fcn ); // $ExpectError - unary4d( [ x, y ], null, fcn ); // $ExpectError - unary4d( [ x, y ], [ '1' ], fcn ); // $ExpectError - unary4d( [ x, y ], {}, fcn ); // $ExpectError - unary4d( [ x, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - unary4d( [ x, y ], [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - unary4d( [ x, y ], [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - unary4d( [ x, y ], [ 1, 1, 2, 2 ], true ); // $ExpectError - unary4d( [ x, y ], [ 1, 1, 2, 2 ], false ); // $ExpectError - unary4d( [ x, y ], [ 1, 1, 2, 2 ], null ); // $ExpectError - unary4d( [ x, y ], [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - unary4d( [ x, y ], [ 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - unary4d(); // $ExpectError - unary4d( [ x, y ] ); // $ExpectError - unary4d( [ x, y ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/unary4d/examples/index.js b/base/unary4d/examples/index.js deleted file mode 100644 index 87a977cfd..000000000 --- a/base/unary4d/examples/index.js +++ /dev/null @@ -1,36 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled4dBy = require( './../../../base/filled4d-by' ); -var zeros4d = require( './../../../base/zeros4d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary4d = require( './../lib' ); - -var shape = [ 2, 2, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros4d( shape ); -console.log( y ); - -unary4d( [ x, y ], shape, abs ); -console.log( y ); diff --git a/base/unary4d/lib/index.js b/base/unary4d/lib/index.js deleted file mode 100644 index 8c7f36ea7..000000000 --- a/base/unary4d/lib/index.js +++ /dev/null @@ -1,53 +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'; - -/** -* Apply a unary callback to elements in a four-dimensional nested input array and assign results to elements in a four-dimensional nested output array. -* -* @module @stdlib/array/base/unary4d -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* var unary4d = require( '@stdlib/array/base/unary4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* unary4d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/unary4d/lib/main.js b/base/unary4d/lib/main.js deleted file mode 100644 index 9c8f4cf80..000000000 --- a/base/unary4d/lib/main.js +++ /dev/null @@ -1,100 +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'; - -// MAIN // - -/** -* Applies a unary callback to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>} arrays - array-like object containing one input nested array and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones4d = require( '@stdlib/array/base/ones4d' ); -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* unary4d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function unary4d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var x1; - var x2; - var y0; - var y1; - var y2; - var x; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn( x0[ i0 ] ); - } - } - } - } -} - - -// EXPORTS // - -module.exports = unary4d; diff --git a/base/unary4d/package.json b/base/unary4d/package.json deleted file mode 100644 index d74d9136d..000000000 --- a/base/unary4d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/unary4d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a four-dimensional nested input array and assign results to elements in a four-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "4d", - "unary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/unary4d/test/test.js b/base/unary4d/test/test.js deleted file mode 100644 index bec07119a..000000000 --- a/base/unary4d/test/test.js +++ /dev/null @@ -1,267 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros4d = require( './../../../base/zeros4d' ); -var unary4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof unary4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - unary4d( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - unary4d( [ x, y ], [ 0, 2, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - unary4d( [ x, y ], [ 2, 0, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - unary4d( [ x, y ], [ 2, 2, 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - unary4d( [ x, y ], [ 2, 2, 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/unary5d-by/README.md b/base/unary5d-by/README.md deleted file mode 100644 index ba6bcfeeb..000000000 --- a/base/unary5d-by/README.md +++ /dev/null @@ -1,180 +0,0 @@ - - -# unary5dBy - -> Apply a unary function to each element retrieved from a five-dimensional nested input array according to a callback function and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var unary5dBy = require( '@stdlib/array/base/unary5d-by' ); -``` - -#### unary5dBy( arrays, shape, fcn, clbk\[, thisArg] ) - -Applies a unary function to each element retrieved from a five-dimensional nested input array according to a callback function and assigns results to elements in a five-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -function accessor( v ) { - return v * 2.0; -} - -var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; -var shape = [ 1, 1, 1, 2, 2 ]; - -unary5dBy( [ x, x ], shape, abs, accessor ); -// x => [ [ [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply to callback return values. -- **clbk**: callback function. -- **thisArg**: callback function execution context (optional). - -The invoked callback function is provided the following arguments: - -- **value**: array element. -- **indices**: current array element indices. -- **arrays**: input and output arrays. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -function accessor( v ) { - this.count += 1; - return v * 2.0; -} - -var context = { - 'count': 0 -}; - -var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; -var y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - -var shape = [ 1, 1, 1, 2, 2 ]; - -unary5dBy( [ x, y ], shape, abs, accessor, context ); -// y => [ [ [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] ] ] - -var cnt = context.count; -// returns 4 -``` - -
- - - -
- -## Notes - -- If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is **ignored**. - - ```javascript - var abs = require( '@stdlib/math/base/special/abs' ); - - function accessor() { - // No-op... - } - - var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; - var y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - var shape = [ 1, 1, 1, 2, 2 ]; - - unary5dBy( [ x, y ], shape, abs, accessor ); - // y => [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ] - ``` - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary5dBy = require( '@stdlib/array/base/unary5d-by' ); - -function accessor( v ) { - // Randomly determine whether a value should be considered "missing": - return ( bernoulli( 0.5 ) > 0 ) ? v : void 0; -} - -var shape = [ 2, 1, 2, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros5d( shape ); -console.log( y ); - -unary5dBy( [ x, y ], shape, abs, accessor ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/unary5d-by/benchmark/benchmark.js b/base/unary5d-by/benchmark/benchmark.js deleted file mode 100644 index 5c3191f17..000000000 --- a/base/unary5d-by/benchmark/benchmark.js +++ /dev/null @@ -1,136 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unary5dBy = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Accessor function. -* -* @private -* @param {number} value - array element -* @returns {number} accessed value -*/ -function accessor( value ) { - return value; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros5d( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unary5dBy( arrays, shape, identity, accessor ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 1 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 1 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unary5d-by/docs/repl.txt b/base/unary5d-by/docs/repl.txt deleted file mode 100644 index 3e9f727cb..000000000 --- a/base/unary5d-by/docs/repl.txt +++ /dev/null @@ -1,46 +0,0 @@ - -{{alias}}( arrays, shape, fcn, clbk[, thisArg] ) - Applies a unary function to each element retrieved from a five-dimensional - nested input array according to a callback function and assigns results to - elements in a five-dimensional nested output array. - - The callback function is provided the following arguments: - - - value: array element. - - indices: current array element indices. - - arrays: input and output arrays. - - If the callback function does not return any value (or equivalently, - explicitly returns `undefined`), the value is ignored. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Unary function to apply to callback return values. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Examples - -------- - > var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; - > var y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shape = [ 1, 1, 1, 2, 2 ]; - > function clbk( v ) { return v * 2.0; }; - > {{alias}}( [ x, y ], shape, {{alias:@stdlib/math/base/special/abs}}, clbk ); - > y - [ [ [ [ [ 2.0, 4.0 ], [ 6.0, 8.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/unary5d-by/docs/types/index.d.ts b/base/unary5d-by/docs/types/index.d.ts deleted file mode 100644 index 8dc381be7..000000000 --- a/base/unary5d-by/docs/types/index.d.ts +++ /dev/null @@ -1,117 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Returns the accessed value. -* -* @returns accessed value -*/ -type NullaryCallback = ( this: W ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @returns accessed value -*/ -type UnaryCallback = ( this: W, value: T ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @returns accessed value -*/ -type BinaryCallback = ( this: W, value: T, indices: Array ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @returns accessed value -*/ -type TernaryCallback = ( this: W, value: T, indices: Array, arrays: [ Array5D, Array5D ] ) => U; - -/** -* Returns the accessed value. -* -* @param value - array element value -* @param indices - current array element indices -* @param arrays - input and output arrays -* @returns accessed value -*/ -type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; - -/** -* Callback invoked for each nested array element retrieved via a callback function. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: U ) => V; - -/** -* Applies a unary function to each element retrieved from a five-dimensional nested input array according to a callback function and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary function to apply to callback return values -* @param clbk - callback function -* @param thisArg - callback execution context -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* unary2dBy( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ] ] -*/ -declare function unary5dBy( arrays: [ Array5D, Array5D ], shape: Shape5D, fcn: Unary, clbk: Callback, thisArg?: ThisParameterType> ): void; - - -// EXPORTS // - -export = unary5dBy; diff --git a/base/unary5d-by/docs/types/test.ts b/base/unary5d-by/docs/types/test.ts deleted file mode 100644 index 5808f3217..000000000 --- a/base/unary5d-by/docs/types/test.ts +++ /dev/null @@ -1,142 +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. -*/ - -import unary5dBy = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function identity( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, identity ); // $ExpectType void - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - unary5dBy( 'abc', [ 1, 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary5dBy( 3.14, [ 1, 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary5dBy( true, [ 1, 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary5dBy( false, [ 1, 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary5dBy( null, [ 1, 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary5dBy( [ '1' ], [ 1, 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary5dBy( {}, [ 1, 1, 1, 2, 2 ], identity, identity ); // $ExpectError - unary5dBy( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], identity, identity ); // $ExpectError - - unary5dBy( 'abc', [ 1, 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary5dBy( 3.14, [ 1, 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary5dBy( true, [ 1, 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary5dBy( false, [ 1, 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary5dBy( null, [ 1, 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary5dBy( [ '1' ], [ 1, 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary5dBy( {}, [ 1, 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError - unary5dBy( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], identity, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - unary5dBy( [ x, y ], 'abc', identity, identity ); // $ExpectError - unary5dBy( [ x, y ], 3.14, identity, identity ); // $ExpectError - unary5dBy( [ x, y ], true, identity, identity ); // $ExpectError - unary5dBy( [ x, y ], false, identity, identity ); // $ExpectError - unary5dBy( [ x, y ], null, identity, identity ); // $ExpectError - unary5dBy( [ x, y ], [ '1' ], identity, identity ); // $ExpectError - unary5dBy( [ x, y ], {}, identity, identity ); // $ExpectError - unary5dBy( [ x, y ], ( x: number ): number => x, identity, identity ); // $ExpectError - - unary5dBy( [ x, y ], 'abc', identity, identity, {} ); // $ExpectError - unary5dBy( [ x, y ], 3.14, identity, identity, {} ); // $ExpectError - unary5dBy( [ x, y ], true, identity, identity, {} ); // $ExpectError - unary5dBy( [ x, y ], false, identity, identity, {} ); // $ExpectError - unary5dBy( [ x, y ], null, identity, identity, {} ); // $ExpectError - unary5dBy( [ x, y ], [ '1' ], identity, identity, {} ); // $ExpectError - unary5dBy( [ x, y ], {}, identity, identity, {} ); // $ExpectError - unary5dBy( [ x, y ], ( x: number ): number => x, identity, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid function... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], 'abc', identity ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], 3.14, identity ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], true, identity ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], false, identity ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], null, identity ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], [ '1' ], identity ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], {}, identity ); // $ExpectError - - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], 'abc', identity, {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], 3.14, identity, {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], true, identity, {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], false, identity, {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], null, identity, {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], [ '1' ], identity, {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], {}, identity, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a valid function... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, 'abc' ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, 3.14 ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, true ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, false ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, null ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, [ '1' ] ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, {} ); // $ExpectError - - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, 'abc', {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, 3.14, {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, true, {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, false, {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, null, {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, [ '1' ], {} ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - unary5dBy(); // $ExpectError - unary5dBy( [ x, y ] ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ] ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity ); // $ExpectError - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 2 ], identity, identity, {}, {} ); // $ExpectError -} diff --git a/base/unary5d-by/examples/index.js b/base/unary5d-by/examples/index.js deleted file mode 100644 index 31a5ad3dd..000000000 --- a/base/unary5d-by/examples/index.js +++ /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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary5dBy = require( './../lib' ); - -function accessor( v ) { - // Randomly determine whether a value should be considered "missing": - return ( bernoulli( 0.5 ) > 0 ) ? v : void 0; -} - -var shape = [ 2, 1, 2, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros5d( shape ); -console.log( y ); - -unary5dBy( [ x, y ], shape, abs, accessor ); -console.log( y ); diff --git a/base/unary5d-by/lib/index.js b/base/unary5d-by/lib/index.js deleted file mode 100644 index be1f32c67..000000000 --- a/base/unary5d-by/lib/index.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -/** -* Apply a unary function to each element retrieved from a five-dimensional nested input array according to a callback function and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/unary5d-by -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var unary5dBy = require( '@stdlib/array/base/unary5d-by' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* unary5dBy( [ x, y ], shape, scale, accessor ); -* -* console.log( y ); -* // => [ [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/unary5d-by/lib/main.js b/base/unary5d-by/lib/main.js deleted file mode 100644 index a38ea853c..000000000 --- a/base/unary5d-by/lib/main.js +++ /dev/null @@ -1,124 +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. -*/ -/* eslint-disable max-depth */ - -'use strict'; - -// MAIN // - -/** -* Applies a unary function to each element retrieved from a five-dimensional nested input array according to a callback function and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - unary function to apply to callback return values -* @param {Callback} clbk - callback function -* @param {*} [thisArg] - callback execution context -* @returns {void} -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* function accessor( v ) { -* return v - 2.0; -* } -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* unary5dBy( [ x, y ], shape, scale, accessor ); -* -* console.log( y ); -* // => [ [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ] ] -*/ -function unary5dBy( arrays, shape, fcn, clbk ) { - var thisArg; - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var x0; - var x1; - var x2; - var x3; - var y0; - var y1; - var y2; - var y3; - var x; - var y; - var v; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return; - } - if ( arguments.length > 4 ) { - thisArg = arguments[ 4 ]; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - for ( i4 = 0; i4 < S4; i4++ ) { - x3 = x[ i4 ]; - y3 = y[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x3[ i3 ]; - y2 = y3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - v = clbk.call( thisArg, x0[ i0 ], [ i4, i3, i2, i1, i0 ], [ x, y ] ); // eslint-disable-line max-len - if ( v !== void 0 ) { - y0[ i0 ] = fcn( v ); - } - } - } - } - } - } -} - - -// EXPORTS // - -module.exports = unary5dBy; diff --git a/base/unary5d-by/package.json b/base/unary5d-by/package.json deleted file mode 100644 index d67360de1..000000000 --- a/base/unary5d-by/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/base/unary5d-by", - "version": "0.0.0", - "description": "Apply a unary function to each element retrieved from a five-dimensional nested input array according to a callback function and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "unary", - "apply", - "foreach", - "map", - "transform", - "accessor", - "callback", - "clbk" - ], - "__stdlib__": {} -} diff --git a/base/unary5d-by/test/test.js b/base/unary5d-by/test/test.js deleted file mode 100644 index 3c46339a3..000000000 --- a/base/unary5d-by/test/test.js +++ /dev/null @@ -1,355 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var unary5dBy = require( './../lib' ); - - -// FUNCTIONS // - -function accessor( v ) { - if ( v === void 0 ) { - return; - } - return v * 2.0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof unary5dBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a function to each nested input array element according to a callback function and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 2.0, 4.0 ], - [ 6.0, 8.0 ] - ] - ] - ] - ]; - - y = zeros5d( shape ); - unary5dBy( [ x, y ], shape, abs, accessor ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, void 0 ], - [ void 0, -4.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 2.0, 0.0 ], - [ 0.0, 8.0 ] - ] - ] - ] - ]; - - y = zeros5d( shape ); - unary5dBy( [ x, y ], shape, abs, accessor ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke provided functions if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - unary5dBy( [ x, y ], [ 0, 1, 1, 2, 2 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function does not invoke provided functions if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - unary5dBy( [ x, y ], [ 1, 0, 1, 2, 2 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function does not invoke provided functions if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - unary5dBy( [ x, y ], [ 1, 1, 0, 2, 2 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function does not invoke provided functions if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - unary5dBy( [ x, y ], [ 1, 1, 1, 0, 2 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function does not invoke provided functions if provided a shape having a five element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - unary5dBy( [ x, y ], [ 1, 1, 1, 2, 0 ], clbk, clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke function' ); - } -}); - -tape( 'the function invokes the callback with three arguments', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - y = zeros5d( shape ); - - values = []; - indices = []; - arrays = []; - unary5dBy( [ x, y ], shape, abs, clbk ); - - expected = [ - -1.0, - -2.0, - -3.0, - -4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0, 0 ], - [ 0, 0, 0, 0, 1 ], - [ 0, 0, 0, 1, 0 ], - [ 0, 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - [ x, y ], - [ x, y ], - [ x, y ], - [ x, y ] - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function clbk( v, idx, arr ) { - values.push( v ); - indices.push( idx ); - arrays.push( arr ); - return v * 2.0; - } -}); - -tape( 'the function supports providing a callback execution context', function test( t ) { - var shape; - var ctx; - var x; - var y; - - shape = [ 1, 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - y = zeros5d( shape ); - - ctx = { - 'count': 0 - }; - unary5dBy( [ x, y ], shape, abs, clbk, ctx ); - - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - t.end(); - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * 2.0; - } -}); diff --git a/base/unary5d/README.md b/base/unary5d/README.md deleted file mode 100644 index c20894d5b..000000000 --- a/base/unary5d/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# unary5d - -> Apply a unary callback to elements in a five-dimensional nested input array and assign results to elements in a five-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var unary5d = require( '@stdlib/array/base/unary5d' ); -``` - -#### unary5d( arrays, shape, fcn ) - -Applies a unary callback to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; -var shape = [ 1, 1, 1, 2, 2 ]; - -// Compute the absolute values in-place: -unary5d( [ x, x ], shape, abs ); -// x => [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( '@stdlib/array/base/filled5d-by' ); -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary5d = require( '@stdlib/array/base/unary5d' ); - -var shape = [ 2, 1, 2, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros5d( shape ); -console.log( y ); - -unary5d( [ x, y ], shape, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/unary5d/benchmark/benchmark.js b/base/unary5d/benchmark/benchmark.js deleted file mode 100644 index b9536bbd7..000000000 --- a/base/unary5d/benchmark/benchmark.js +++ /dev/null @@ -1,125 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unary5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filled5dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros5d( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unary5d( arrays, shape, identity ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 1 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 1 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unary5d/docs/repl.txt b/base/unary5d/docs/repl.txt deleted file mode 100644 index 49ff25dc2..000000000 --- a/base/unary5d/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a unary callback to elements in a five-dimensional nested input - array and assigns results to elements in a five-dimensional nested output - array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ] ]; - > var y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - > var shape = [ 1, 1, 1, 2, 2 ]; - > {{alias}}( [ x, y ], shape, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/unary5d/docs/types/index.d.ts b/base/unary5d/docs/types/index.d.ts deleted file mode 100644 index fa873ba4a..000000000 --- a/base/unary5d/docs/types/index.d.ts +++ /dev/null @@ -1,68 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array5D } from '@stdlib/types/array'; -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Applies a unary callback to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* unary5d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -*/ -declare function unary5d( arrays: [ Array5D, Array5D ], shape: Shape5D, fcn: Unary ): void; - - -// EXPORTS // - -export = unary5d; diff --git a/base/unary5d/docs/types/test.ts b/base/unary5d/docs/types/test.ts deleted file mode 100644 index 6b6973b0d..000000000 --- a/base/unary5d/docs/types/test.ts +++ /dev/null @@ -1,91 +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. -*/ - -import unary5d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - unary5d( [ x, y ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - unary5d( 'abc', [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - unary5d( 3.14, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - unary5d( true, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - unary5d( false, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - unary5d( null, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - unary5d( [ '1' ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - unary5d( {}, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError - unary5d( ( x: number ): number => x, [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - unary5d( [ x, y ], 'abc', fcn ); // $ExpectError - unary5d( [ x, y ], 3.14, fcn ); // $ExpectError - unary5d( [ x, y ], true, fcn ); // $ExpectError - unary5d( [ x, y ], false, fcn ); // $ExpectError - unary5d( [ x, y ], null, fcn ); // $ExpectError - unary5d( [ x, y ], [ '1' ], fcn ); // $ExpectError - unary5d( [ x, y ], {}, fcn ); // $ExpectError - unary5d( [ x, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - unary5d( [ x, y ], [ 1, 1, 1, 2, 2 ], 'abc' ); // $ExpectError - unary5d( [ x, y ], [ 1, 1, 1, 2, 2 ], 3.14 ); // $ExpectError - unary5d( [ x, y ], [ 1, 1, 1, 2, 2 ], true ); // $ExpectError - unary5d( [ x, y ], [ 1, 1, 1, 2, 2 ], false ); // $ExpectError - unary5d( [ x, y ], [ 1, 1, 1, 2, 2 ], null ); // $ExpectError - unary5d( [ x, y ], [ 1, 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - unary5d( [ x, y ], [ 1, 1, 1, 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - unary5d(); // $ExpectError - unary5d( [ x, y ] ); // $ExpectError - unary5d( [ x, y ], [ 1, 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/unary5d/examples/index.js b/base/unary5d/examples/index.js deleted file mode 100644 index 51bf594e1..000000000 --- a/base/unary5d/examples/index.js +++ /dev/null @@ -1,36 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filled5dBy = require( './../../../base/filled5d-by' ); -var zeros5d = require( './../../../base/zeros5d' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unary5d = require( './../lib' ); - -var shape = [ 2, 1, 2, 3, 3 ]; - -var x = filled5dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zeros5d( shape ); -console.log( y ); - -unary5d( [ x, y ], shape, abs ); -console.log( y ); diff --git a/base/unary5d/lib/index.js b/base/unary5d/lib/index.js deleted file mode 100644 index 5d8a22139..000000000 --- a/base/unary5d/lib/index.js +++ /dev/null @@ -1,53 +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'; - -/** -* Apply a unary callback to elements in a five-dimensional nested input array and assign results to elements in a five-dimensional nested output array. -* -* @module @stdlib/array/base/unary5d -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* var unary5d = require( '@stdlib/array/base/unary5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* unary5d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/unary5d/lib/main.js b/base/unary5d/lib/main.js deleted file mode 100644 index 6d537e747..000000000 --- a/base/unary5d/lib/main.js +++ /dev/null @@ -1,109 +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'; - -// MAIN // - -/** -* Applies a unary callback to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject>>} arrays - array-like object containing one input nested array and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var ones5d = require( '@stdlib/array/base/ones5d' ); -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = ones5d( shape ); -* var y = zeros5d( shape ); -* -* unary5d( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -*/ -function unary5d( arrays, shape, fcn ) { - var S0; - var S1; - var S2; - var S3; - var S4; - var i0; - var i1; - var i2; - var i3; - var i4; - var x0; - var x1; - var x2; - var x3; - var y0; - var y1; - var y2; - var y3; - var x; - var y; - - S0 = shape[ 4 ]; - S1 = shape[ 3 ]; - S2 = shape[ 2 ]; - S3 = shape[ 1 ]; - S4 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) { - return; - } - x = arrays[ 0 ]; - y = arrays[ 1 ]; - for ( i4 = 0; i4 < S4; i4++ ) { - x3 = x[ i4 ]; - y3 = y[ i4 ]; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x3[ i3 ]; - y2 = y3[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn( x0[ i0 ] ); - } - } - } - } - } -} - - -// EXPORTS // - -module.exports = unary5d; diff --git a/base/unary5d/package.json b/base/unary5d/package.json deleted file mode 100644 index d4fa5d19b..000000000 --- a/base/unary5d/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/base/unary5d", - "version": "0.0.0", - "description": "Apply a unary callback to elements in a five-dimensional nested input array and assign results to elements in a five-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "5d", - "unary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/unary5d/test/test.js b/base/unary5d/test/test.js deleted file mode 100644 index 4b8b97d57..000000000 --- a/base/unary5d/test/test.js +++ /dev/null @@ -1,478 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zeros5d = require( './../../../base/zeros5d' ); -var unary5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof unary5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ] - ]; - - y = zeros5d( shape ); - unary5d( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - unary5d( [ x, y ], [ 0, 2, 2, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - unary5d( [ x, y ], [ 2, 0, 2, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - unary5d( [ x, y ], [ 2, 2, 0, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - unary5d( [ x, y ], [ 2, 2, 2, 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zeros5d( shape ); - - y = zeros5d( shape ); - unary5d( [ x, y ], [ 2, 2, 2, 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/unarynd/README.md b/base/unarynd/README.md deleted file mode 100644 index 1a801032e..000000000 --- a/base/unarynd/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# unarynd - -> Apply a unary callback to elements in an n-dimensional nested input array and assign results to elements in an n-dimensional nested output array. - -
- -
- - - -
- -## Usage - -```javascript -var unarynd = require( '@stdlib/array/base/unarynd' ); -``` - -#### unarynd( arrays, shape, fcn ) - -Applies a unary callback to elements in an n-dimensional nested input array and assigns results to elements in an n-dimensional nested output array. - -```javascript -var abs = require( '@stdlib/math/base/special/abs' ); - -var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; -var shape = [ 2, 2 ]; - -// Compute the absolute values in-place: -unarynd( [ x, x ], shape, abs ); -// x => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] -``` - -The function accepts the following arguments: - -- **arrays**: array-like object containing one input nested array and one output nested array. -- **shape**: array shape. -- **fcn**: unary function to apply. - -
- - - -
- -## Notes - -- The function assumes that the input and output arrays have the same shape. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filledndBy = require( '@stdlib/array/base/fillednd-by' ); -var zerosnd = require( '@stdlib/array/base/zerosnd' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unarynd = require( '@stdlib/array/base/unarynd' ); - -var shape = [ 3, 3 ]; - -var x = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zerosnd( shape ); -console.log( y ); - -unarynd( [ x, y ], shape, abs ); -console.log( y ); - -shape = [ 3, 3, 3 ]; - -x = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -y = zerosnd( shape ); -console.log( y ); - -unarynd( [ x, y ], shape, abs ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/unarynd/benchmark/benchmark.size.2d.js b/base/unarynd/benchmark/benchmark.size.2d.js deleted file mode 100644 index 83aff34ac..000000000 --- a/base/unarynd/benchmark/benchmark.size.2d.js +++ /dev/null @@ -1,116 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filledndBy = require( './../../../base/fillednd-by' ); -var zerosnd = require( './../../../base/zerosnd' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unarynd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filledndBy( shape, uniform( -100.0, 100.0 ) ); - y = zerosnd( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unarynd( arrays, shape, identity ); - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 1 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i1 = i % shape[ 0 ]; - i0 = i % shape[ 1 ]; - if ( isnan( arrays[ 1 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - sh = [ N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::2d,equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unarynd/benchmark/benchmark.size.3d.js b/base/unarynd/benchmark/benchmark.size.3d.js deleted file mode 100644 index ecdb7bb00..000000000 --- a/base/unarynd/benchmark/benchmark.size.3d.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filledndBy = require( './../../../base/fillednd-by' ); -var zerosnd = require( './../../../base/zerosnd' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unarynd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filledndBy( shape, uniform( -100.0, 100.0 ) ); - y = zerosnd( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unarynd( arrays, shape, identity ); - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 1 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i2 = i % shape[ 0 ]; - i1 = i % shape[ 1 ]; - i0 = i % shape[ 2 ]; - if ( isnan( arrays[ 1 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/3.0 ) ); - sh = [ N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::3d,equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unarynd/benchmark/benchmark.size.4d.js b/base/unarynd/benchmark/benchmark.size.4d.js deleted file mode 100644 index a58f89255..000000000 --- a/base/unarynd/benchmark/benchmark.size.4d.js +++ /dev/null @@ -1,122 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filledndBy = require( './../../../base/fillednd-by' ); -var zerosnd = require( './../../../base/zerosnd' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unarynd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filledndBy( shape, uniform( -100.0, 100.0 ) ); - y = zerosnd( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unarynd( arrays, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 1 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( arrays[ 1 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::4d,equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unarynd/benchmark/benchmark.size.5d.js b/base/unarynd/benchmark/benchmark.size.5d.js deleted file mode 100644 index 5e888f40c..000000000 --- a/base/unarynd/benchmark/benchmark.size.5d.js +++ /dev/null @@ -1,125 +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 bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var identity = require( '@stdlib/number/float64/base/identity' ); -var filledndBy = require( './../../../base/fillednd-by' ); -var zerosnd = require( './../../../base/zerosnd' ); -var numel = require( '@stdlib/ndarray/base/numel' ); -var pkg = require( './../package.json' ).name; -var unarynd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var arrays; - var x; - var y; - - x = filledndBy( shape, uniform( -100.0, 100.0 ) ); - y = zerosnd( shape ); - - arrays = [ x, y ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - unarynd( arrays, shape, identity ); - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 1 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i4 = i % shape[ 0 ]; - i3 = i % shape[ 1 ]; - i2 = i % shape[ 2 ]; - i1 = i % shape[ 3 ]; - i0 = i % shape[ 4 ]; - if ( isnan( arrays[ 1 ][ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - sh = [ N, N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::5d,equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/base/unarynd/docs/repl.txt b/base/unarynd/docs/repl.txt deleted file mode 100644 index 19fa2c146..000000000 --- a/base/unarynd/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( arrays, shape, fcn ) - Applies a unary callback to elements in an n-dimensional nested input array - and assigns results to elements in an n-dimensional nested output array. - - Parameters - ---------- - arrays: ArrayLikeObject - Array-like object containing one input nested array and one output - nested array. - - shape: Array - Array shape. - - fcn: Function - Unary callback. - - Examples - -------- - > var x = [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ]; - > var y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - > var shape = [ 2, 2 ]; - > {{alias}}( [ x, y ], shape, {{alias:@stdlib/math/base/special/abs}} ); - > y - [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] - - See Also - -------- - diff --git a/base/unarynd/docs/types/index.d.ts b/base/unarynd/docs/types/index.d.ts deleted file mode 100644 index 961945ff9..000000000 --- a/base/unarynd/docs/types/index.d.ts +++ /dev/null @@ -1,378 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Array1D, Array2D, Array3D, Array4D, Array5D, Array6D, Array7D, Array8D, Array9D, Array10D } from '@stdlib/types/array'; -import { Shape, Shape1D, Shape2D, Shape3D, Shape4D, Shape5D, Shape6D, Shape7D, Shape8D, Shape9D, Shape10D } from '@stdlib/types/ndarray'; - -/** -* Unary callback. -* -* @param value - array element -* @returns result -*/ -type Unary = ( value: T ) => U; - -/** -* Applies a unary callback to elements in a one-dimensional nested input array and assigns results to elements in a one-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ 10.0, 10.0 ] -*/ -declare function unarynd( arrays: [ Array1D, Array1D ], shape: Shape1D, fcn: Unary ): void; - -/** -* Applies a unary callback to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -*/ -declare function unarynd( arrays: [ Array2D, Array2D ], shape: Shape2D, fcn: Unary ): void; - -/** -* Applies a unary callback to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] -*/ -declare function unarynd( arrays: [ Array3D, Array3D ], shape: Shape3D, fcn: Unary ): void; - -/** -* Applies a unary callback to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -declare function unarynd( arrays: [ Array4D, Array4D ], shape: Shape4D, fcn: Unary ): void; - -/** -* Applies a unary callback to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] -*/ -declare function unarynd( arrays: [ Array5D, Array5D ], shape: Shape5D, fcn: Unary ): void; - -/** -* Applies a unary callback to elements in a six-dimensional nested input array and assigns results to elements in a six-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] ] -*/ -declare function unarynd( arrays: [ Array6D, Array6D ], shape: Shape6D, fcn: Unary ): void; - -/** -* Applies a unary callback to elements in a seven-dimensional nested input array and assigns results to elements in a seven-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] ] ] -*/ -declare function unarynd( arrays: [ Array7D, Array7D ], shape: Shape7D, fcn: Unary ): void; - -/** -* Applies a unary callback to elements in an eight-dimensional nested input array and assigns results to elements in an eight-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] ] ] ] -*/ -declare function unarynd( arrays: [ Array8D, Array8D ], shape: Shape8D, fcn: Unary ): void; - -/** -* Applies a unary callback to elements in a nine-dimensional nested input array and assigns results to elements in a nine-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] ] ] ] ] -*/ -declare function unarynd( arrays: [ Array9D, Array9D ], shape: Shape9D, fcn: Unary ): void; - -/** -* Applies a unary callback to elements in a ten-dimensional nested input array and assigns results to elements in a ten-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] ] ] ] ] ] -*/ -declare function unarynd( arrays: [ Array10D, Array10D ], shape: Shape10D, fcn: Unary ): void; - -/** -* Applies a unary callback to elements in an n-dimensional nested input array and assigns results to elements in an n-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param arrays - array containing one input nested array and one output nested array -* @param shape - array shape -* @param fcn - unary callback -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ [ [ [ [ [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ] ] ] ] ] ] ] -*/ -declare function unarynd( arrays: [ Array, Array ], shape: Shape, fcn: Unary ): void; - - -// EXPORTS // - -export = unarynd; diff --git a/base/unarynd/docs/types/test.ts b/base/unarynd/docs/types/test.ts deleted file mode 100644 index d814de5a5..000000000 --- a/base/unarynd/docs/types/test.ts +++ /dev/null @@ -1,111 +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. -*/ - -import unarynd = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns undefined... -{ - const x1 = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y1 = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unarynd( [ x1, y1 ], [ 2, 2 ], fcn ); // $ExpectType void - - const x2 = [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ]; - const y2 = [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ]; - - unarynd( [ x2, y2 ], [ 1, 2, 2 ], fcn ); // $ExpectType void - - const x3 = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y3 = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - unarynd( [ x3, y3 ], [ 1, 1, 2, 2 ], fcn ); // $ExpectType void - - const x4 = [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ]; - const y4 = [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ]; - - unarynd( [ x4, y4 ], [ 1, 1, 2, 2 ], fcn ); // $ExpectType void - - const x5 = [ [ [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] ] ]; - const y5 = [ [ [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ] ] ]; - - unarynd( [ x5, y5 ], [ 1, 1, 1, 2, 2 ], fcn ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not an array of nested arrays... -{ - unarynd( 'abc', [ 2, 2 ], fcn ); // $ExpectError - unarynd( 3.14, [ 2, 2 ], fcn ); // $ExpectError - unarynd( true, [ 2, 2 ], fcn ); // $ExpectError - unarynd( false, [ 2, 2 ], fcn ); // $ExpectError - unarynd( null, [ 2, 2 ], fcn ); // $ExpectError - unarynd( [ '1' ], [ 2, 2 ], fcn ); // $ExpectError - unarynd( {}, [ 2, 2 ], fcn ); // $ExpectError - unarynd( ( x: number ): number => x, [ 2, 2 ], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unarynd( [ x, y ], 'abc', fcn ); // $ExpectError - unarynd( [ x, y ], 3.14, fcn ); // $ExpectError - unarynd( [ x, y ], true, fcn ); // $ExpectError - unarynd( [ x, y ], false, fcn ); // $ExpectError - unarynd( [ x, y ], null, fcn ); // $ExpectError - unarynd( [ x, y ], [ '1' ], fcn ); // $ExpectError - unarynd( [ x, y ], {}, fcn ); // $ExpectError - unarynd( [ x, y ], ( x: number ): number => x, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unarynd( [ x, y ], [ 2, 2 ], 'abc' ); // $ExpectError - unarynd( [ x, y ], [ 2, 2 ], 3.14 ); // $ExpectError - unarynd( [ x, y ], [ 2, 2 ], true ); // $ExpectError - unarynd( [ x, y ], [ 2, 2 ], false ); // $ExpectError - unarynd( [ x, y ], [ 2, 2 ], null ); // $ExpectError - unarynd( [ x, y ], [ 2, 2 ], [ '1' ] ); // $ExpectError - unarynd( [ x, y ], [ 2, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]; - const y = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - - unarynd(); // $ExpectError - unarynd( [ x, y ] ); // $ExpectError - unarynd( [ x, y ], [ 2, 2 ], fcn, {} ); // $ExpectError -} diff --git a/base/unarynd/examples/index.js b/base/unarynd/examples/index.js deleted file mode 100644 index b3555eba3..000000000 --- a/base/unarynd/examples/index.js +++ /dev/null @@ -1,47 +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'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filledndBy = require( './../../../base/fillednd-by' ); -var zerosnd = require( './../../../base/zerosnd' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var unarynd = require( './../lib' ); - -var shape = [ 3, 3 ]; - -var x = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = zerosnd( shape ); -console.log( y ); - -unarynd( [ x, y ], shape, abs ); -console.log( y ); - -shape = [ 3, 3, 3 ]; - -x = filledndBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -y = zerosnd( shape ); -console.log( y ); - -unarynd( [ x, y ], shape, abs ); -console.log( y ); diff --git a/base/unarynd/lib/index.js b/base/unarynd/lib/index.js deleted file mode 100644 index 7229d8b53..000000000 --- a/base/unarynd/lib/index.js +++ /dev/null @@ -1,53 +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'; - -/** -* Apply a unary callback to elements in an n-dimensional nested input array and assign results to elements in an n-dimensional nested output array. -* -* @module @stdlib/array/base/unarynd -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* var unarynd = require( '@stdlib/array/base/unarynd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/unarynd/lib/main.js b/base/unarynd/lib/main.js deleted file mode 100644 index bd90f72cc..000000000 --- a/base/unarynd/lib/main.js +++ /dev/null @@ -1,98 +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'; - -// FUNCTIONS // - -/** -* Recursively applies a unary callback. -* -* @private -* @param {ArrayLikeObject} x - input array -* @param {ArrayLikeObject} y - output array -* @param {NonNegativeInteger} ndims - number of dimensions -* @param {NonNegativeIntegerArray} shape - array shape -* @param {NonNegativeInteger} dim - dimension index -* @param {Callback} fcn - unary callback -* @returns {void} -*/ -function recurse( x, y, ndims, shape, dim, fcn ) { - var S; - var d; - var i; - - S = shape[ dim ]; - - // Check whether we've reached the innermost dimension: - d = dim + 1; - - if ( d === ndims ) { - // Apply the provided callback... - for ( i = 0; i < S; i++ ) { - y[ i ] = fcn( x[ i ] ); - } - return; - } - // Continue recursing into the nested arrays... - for ( i = 0; i < S; i++ ) { - recurse( x[ i ], y[ i ], ndims, shape, d, fcn ); - } -} - - -// MAIN // - -/** -* Applies a unary callback to elements in an n-dimensional nested input array and assigns results to elements in an n-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Callback} fcn - unary callback -* @returns {void} -* -* @example -* var onesnd = require( '@stdlib/array/base/onesnd' ); -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 2, 2 ]; -* -* var x = onesnd( shape ); -* var y = zerosnd( shape ); -* -* unarynd( [ x, y ], shape, scale ); -* -* console.log( y ); -* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] -*/ -function unarynd( arrays, shape, fcn ) { - return recurse( arrays[ 0 ], arrays[ 1 ], shape.length, shape, 0, fcn ); -} - - -// EXPORTS // - -module.exports = unarynd; diff --git a/base/unarynd/package.json b/base/unarynd/package.json deleted file mode 100644 index 6f1cd1daf..000000000 --- a/base/unarynd/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/base/unarynd", - "version": "0.0.0", - "description": "Apply a unary callback to elements in an n-dimensional nested input array and assign results to elements in an n-dimensional nested output array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "multidimensional", - "ndarray", - "matrix", - "cube", - "nd", - "unary", - "apply", - "foreach", - "map", - "transform" - ], - "__stdlib__": {} -} diff --git a/base/unarynd/test/test.js b/base/unarynd/test/test.js deleted file mode 100644 index 44a19ce57..000000000 --- a/base/unarynd/test/test.js +++ /dev/null @@ -1,1105 +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 abs = require( '@stdlib/math/base/special/abs' ); -var zerosnd = require( './../../../base/zerosnd' ); -var unarynd = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof unarynd, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array (0d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = []; - x = []; - - expected = []; - - y = zerosnd( shape ); - unarynd( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array (1d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2 ]; - x = [ -1.0, -2.0 ]; - - expected = [ 1.0, 2.0 ]; - - y = zerosnd( shape ); - unarynd( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array (2d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ]; - - y = zerosnd( shape ); - unarynd( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 2, 3 ]; - x = [ - [ -1.0, -2.0, -3.0 ], - [ -3.0, -4.0, -5.0 ] - ]; - - expected = [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ]; - - y = zerosnd( shape ); - unarynd( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array (3d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ]; - - y = zerosnd( shape ); - unarynd( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 2, 2, 3 ]; - x = [ - [ - [ -1.0, -2.0, -3.0 ], - [ -3.0, -4.0, -5.0 ] - ], - [ - [ -1.0, -2.0, -3.0 ], - [ -3.0, -4.0, -5.0 ] - ] - ]; - - expected = [ - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ], - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ] - ]; - - y = zerosnd( shape ); - unarynd( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array (4d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ], - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ], - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zerosnd( shape ); - unarynd( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 1, 2, 2, 3 ]; - x = [ - [ - [ - [ -1.0, -2.0, -3.0 ], - [ -3.0, -4.0, -5.0 ] - ], - [ - [ -1.0, -2.0, -3.0 ], - [ -3.0, -4.0, -5.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ], - [ - [ 1.0, 2.0, 3.0 ], - [ 3.0, 4.0, 5.0 ] - ] - ] - ]; - - y = zerosnd( shape ); - unarynd( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 1, 1, 1, 1, 3 ]; - x = [ - [ - [ - [ - [ -1.0, -1.0, -1.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 1.0, 1.0, 1.0 ] - ] - ] - ] - ]; - - y = zerosnd( shape ); - unarynd( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 2, 1, 2, 3, 1 ]; - x = [ - [ - [ - [ - [ -1.0 ], - [ -1.0 ], - [ -1.0 ] - ], - [ - [ -1.0 ], - [ -1.0 ], - [ -1.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0 ], - [ -1.0 ], - [ -1.0 ] - ], - [ - [ -1.0 ], - [ -1.0 ], - [ -1.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ], - [ - [ - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ], - [ - [ 1.0 ], - [ 1.0 ], - [ 1.0 ] - ] - ] - ] - ]; - - y = zerosnd( shape ); - unarynd( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - - shape = [ 1, 2, 2, 3, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -1.0 ], - [ -1.0, -1.0 ], - [ -1.0, -1.0 ] - ], - [ - [ -1.0, -1.0 ], - [ -1.0, -1.0 ], - [ -1.0, -1.0 ] - ] - ], - [ - [ - [ -1.0, -1.0 ], - [ -1.0, -1.0 ], - [ -1.0, -1.0 ] - ], - [ - [ -1.0, -1.0 ], - [ -1.0, -1.0 ], - [ -1.0, -1.0 ] - ] - ] - ] - ]; - - expected = [ - [ - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ], - [ - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ], - [ - [ 1.0, 1.0 ], - [ 1.0, 1.0 ], - [ 1.0, 1.0 ] - ] - ] - ] - ]; - - y = zerosnd( shape ); - unarynd( [ x, y ], shape, abs ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero (1d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2 ]; - x = [ -1.0, -2.0 ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero (2d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero (2d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2 ]; - x = [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero (3d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 0, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero (3d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 2, 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero (3d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2 ]; - x = [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 2, 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero (4d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 0, 2, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero (4d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 2, 0, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero (4d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 2, 2, 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero (4d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 2, 2, 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero (5d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 0, 2, 2, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero (5d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 2, 0, 2, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero (5d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 2, 2, 0, 2, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero (5d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 2, 2, 2, 0, 2 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fifth element equal to zero (5d)', function test( t ) { - var expected; - var shape; - var x; - var y; - - shape = [ 2, 2, 2, 2, 2 ]; - x = [ - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ], - [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ], - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ], - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ] - ]; - - expected = zerosnd( shape ); - - y = zerosnd( shape ); - unarynd( [ x, y ], [ 2, 2, 2, 2, 0 ], clbk ); - - t.deepEqual( y, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); diff --git a/base/unitspace/README.md b/base/unitspace/README.md deleted file mode 100644 index 67e36f9c6..000000000 --- a/base/unitspace/README.md +++ /dev/null @@ -1,128 +0,0 @@ - - -# unitspace - -> Generate a linearly spaced numeric array whose elements increment by 1. - -
- -## Usage - -```javascript -var unitspace = require( '@stdlib/array/base/unitspace' ); -``` - -#### unitspace( start, stop ) - -Generates a linearly spaced numeric `array` whose elements increment by `1`. - -```javascript -var arr = unitspace( 0, 6 ); -// returns [ 0, 1, 2, 3, 4, 5 ] -``` - -
- - - -
- -### Notes - -- The output `array` is guaranteed to include the `start` value but does **not** include the `stop` value. Beware that values subsequent to the `start` value are subject to floating-point errors. Hence, - - ```javascript - var arr = unitspace( -0.7, 1 ); - // returns [ -0.7, ~0.3 ] - ``` - - where `arr[1]` is only guaranteed to be approximately equal to `0.3`. - - If you desire more control over element precision, consider using [roundn][@stdlib/math/base/special/roundn]: - - ```javascript - var roundn = require( '@stdlib/math/base/special/roundn' ); - - // Create an array subject to floating-point errors: - var arr = unitspace( -10.7, 11.7 ); - - // Round each value to the nearest hundredth: - var i; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = roundn( arr[ i ], -2 ); - } - - console.log( arr.join( '\n' ) ); - ``` - -
- - - -
- -## Examples - - - -```javascript -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var filledBy = require( '@stdlib/array/base/filled-by' ); -var randu = require( '@stdlib/random/base/randu' ); -var unitspace = require( '@stdlib/array/base/unitspace' ); - -// Generate an array of random numbers: -var x = filledBy( 10, randu ); - -// Generate an array of indices: -var idx = unitspace( 0, x.length ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort the index array according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, idx, 1 ); - -console.log( x ); -console.log( idx ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/unitspace/benchmark/benchmark.js b/base/unitspace/benchmark/benchmark.js deleted file mode 100644 index c3d3b52ee..000000000 --- a/base/unitspace/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var unitspace = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - var v; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = unitspace( i, i+100 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/unitspace/benchmark/benchmark.length.js b/base/unitspace/benchmark/benchmark.length.js deleted file mode 100644 index ffa0cf6a8..000000000 --- a/base/unitspace/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var unitspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = unitspace( i, i+len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/unitspace/docs/repl.txt b/base/unitspace/docs/repl.txt deleted file mode 100644 index 5b4546a95..000000000 --- a/base/unitspace/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( start, stop ) - Generates a linearly spaced numeric array whose elements increment by 1. - - The output array is guaranteed to include the `start` value but does not - include the `stop` value. - - Parameters - ---------- - start: number - First array value. - - stop: number - Array element bound. - - Returns - ------- - out: Array - Linearly spaced numeric array. - - Examples - -------- - > var arr = {{alias}}( 0, 6 ) - [ 0, 1, 2, 3, 4, 5 ] - - See Also - -------- - diff --git a/base/unitspace/docs/types/index.d.ts b/base/unitspace/docs/types/index.d.ts deleted file mode 100644 index b5724ce18..000000000 --- a/base/unitspace/docs/types/index.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Generates a linearly spaced numeric array whose elements increment by 1. -* -* @param x1 - first array value -* @param x2 - array element bound -* @returns linearly spaced numeric array -* -* @example -* var arr = unitspace( 0, 6 ); -* // returns [ 0, 1, 2, 3, 4, 5 ] -*/ -declare function unitspace( x1: number, x2: number ): Array; - - -// EXPORTS // - -export = unitspace; diff --git a/base/unitspace/docs/types/test.ts b/base/unitspace/docs/types/test.ts deleted file mode 100644 index 05dcd9284..000000000 --- a/base/unitspace/docs/types/test.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 unitspace = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - unitspace( 0, 11 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided values other than two numbers for the first two parameters... -{ - unitspace( true, 10 ); // $ExpectError - unitspace( false, 10 ); // $ExpectError - unitspace( '5', 10 ); // $ExpectError - unitspace( [], 10 ); // $ExpectError - unitspace( {}, 20 ); // $ExpectError - unitspace( ( x: number ): number => x, 20 ); // $ExpectError - - unitspace( 9, true ); // $ExpectError - unitspace( 9, false ); // $ExpectError - unitspace( 5, '5' ); // $ExpectError - unitspace( 8, [] ); // $ExpectError - unitspace( 9, {} ); // $ExpectError - unitspace( 8, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - unitspace(); // $ExpectError - unitspace( 3 ); // $ExpectError - unitspace( 3, 4, 1 ); // $ExpectError -} diff --git a/base/unitspace/examples/index.js b/base/unitspace/examples/index.js deleted file mode 100644 index 5f0140270..000000000 --- a/base/unitspace/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var filledBy = require( './../../../base/filled-by' ); -var randu = require( '@stdlib/random/base/randu' ); -var unitspace = require( './../lib' ); - -// Generate an array of random numbers: -var x = filledBy( 10, randu ); - -// Generate an array of indices: -var idx = unitspace( 0, x.length ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort the index array according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, idx, 1 ); - -console.log( x ); -console.log( idx ); diff --git a/base/unitspace/lib/index.js b/base/unitspace/lib/index.js deleted file mode 100644 index 29dec0a7d..000000000 --- a/base/unitspace/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Generate a linearly spaced numeric array whose elements increment by 1. -* -* @module @stdlib/array/base/unitspace -* -* @example -* var unitspace = require( '@stdlib/array/base/unitspace' ); -* -* var arr = unitspace( 0, 6 ); -* // returns [ 0, 1, 2, 3, 4, 5 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/unitspace/lib/main.js b/base/unitspace/lib/main.js deleted file mode 100644 index 0b4721413..000000000 --- a/base/unitspace/lib/main.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Generates a linearly spaced numeric array whose elements increment by 1. -* -* @param {number} x1 - first array value -* @param {number} x2 - array element bound -* @returns {Array} linearly spaced numeric array -* -* @example -* var arr = unitspace( 0, 6 ); -* // returns [ 0, 1, 2, 3, 4, 5 ] -*/ -function unitspace( x1, x2 ) { - var arr; - var len; - var i; - - len = x2 - x1; - if ( len <= 1 ) { - return [ x1 ]; - } - arr = [ x1 ]; - for ( i = 1; i < len; i++ ) { - arr.push( x1 + i ); - } - return arr; -} - - -// EXPORTS // - -module.exports = unitspace; diff --git a/base/unitspace/package.json b/base/unitspace/package.json deleted file mode 100644 index 2babb6df9..000000000 --- a/base/unitspace/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/unitspace", - "version": "0.0.0", - "description": "Generate a linearly spaced numeric array whose elements increment by 1.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "matlab", - "linear", - "linspace", - "sequence", - "increment" - ] -} diff --git a/base/unitspace/test/test.js b/base/unitspace/test/test.js deleted file mode 100644 index c6e2815e1..000000000 --- a/base/unitspace/test/test.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 unitspace = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof unitspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a linearly spaced array', function test( t ) { - var expected; - var actual; - - actual = unitspace( 0, 10 ); - expected = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = unitspace( -5, 5 ); - expected = [ -5, -4, -3, -2, -1, 0, 1, 2, 3, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a single element array for bounds incompatible with incrementing', function test( t ) { - t.deepEqual( unitspace( 0, -1 ), [ 0 ], 'returns expected value' ); - t.deepEqual( unitspace( 5, 4 ), [ 5 ], 'returns expected value' ); - t.deepEqual( unitspace( 5, 5 ), [ 5 ], 'returns expected value' ); - t.deepEqual( unitspace( 5, 5.5 ), [ 5 ], 'returns expected value' ); - t.deepEqual( unitspace( 5, 6 ), [ 5 ], 'returns expected value' ); - t.end(); -}); diff --git a/base/where/README.md b/base/where/README.md deleted file mode 100644 index cf21b0c84..000000000 --- a/base/where/README.md +++ /dev/null @@ -1,222 +0,0 @@ - - -# where - -> Take elements from either one of two arrays depending on a condition. - -
- -## Usage - -```javascript -var where = require( '@stdlib/array/base/where' ); -``` - -#### where( condition, x, y ) - -Takes elements from either `x` or `y` depending on a condition. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var y = [ 5, 6, 7, 8 ]; - -var condition = [ true, false, true, false ]; - -var z = where( condition, x, y ); -// returns [ 1, 6, 3, 8 ] -``` - -The function supports the following parameters: - -- **condition**: array of values indicating whether to take an element from either `x` or `y`. If a condition element is truthy, the function takes a respective element from `x`; otherwise, the function takes a respective element from `y`. If non-empty, must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes] with the resolved output array length. -- **x**: first input array. If `condition` is non-empty, must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes] with the resolved output array length. -- **y**: second input array. If `condition` is non-empty, must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes] with the resolved output array length. - -When all input arrays are non-empty, the function supports broadcasting single-element arrays to the resolved output array length, which is equal to the maximum length of all provided input arrays. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var y = [ 5 ]; - -var condition = [ true, false, true, false ]; - -var z = where( condition, x, y ); -// returns [ 1, 5, 3, 5 ] - -z = where( condition, y, x ); -// returns [ 5, 2, 5, 4 ] - -z = where( [ true ], x, y ); -// returns [ 1, 2, 3, 4 ] - -z = where( [ false ], x, y ); -// returns [ 5, 5, 5, 5 ] - -z = where( condition, [ 1 ], y ); -// returns [ 1, 5, 1, 5 ] -``` - -If `condition` is an empty array, the function returns an empty array. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var y = [ 5, 6, 7, 8 ]; - -var condition = []; - -var z = where( condition, x, y ); -// returns [] -``` - -#### where.assign( condition, x, y, out, stride, offset ) - -Takes elements from either `x` or `y` depending on a condition and assigns the values to elements in a provided output array. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var y = [ 5, 6, 7, 8 ]; - -var out = [ 0, 0, 0, 0 ]; -var condition = [ true, false, true, false ]; - -var arr = where.assign( condition, x, y, out, 1, 0 ); -// returns [ 1, 6, 3, 8 ] - -var bool = ( arr === out ); -// returns true -``` - -The function supports the following parameters: - -- **condition**: array of values indicating whether to take an element from either `x` or `y`. If a condition element is truthy, the function takes a respective element from `x`; otherwise, the function takes a respective element from `y`. If non-empty, must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes] with the output array. -- **x**: first input array. If `condition` is non-empty, must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes] with the output array. -- **y**: second input array. If `condition` is non-empty, must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes] with the output array. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. - -The function supports broadcasting single-element arrays to the output array length. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var y = [ 5 ]; - -var condition = [ true, false, true, false ]; - -var out = [ 0, 0, 0, 0 ]; -var arr = where.assign( condition, x, y, out, 1, 0 ); -// returns [ 1, 5, 3, 5 ] - -out = [ 0, 0, 0, 0 ]; -arr = where.assign( condition, y, x, out, 1, 0 ); -// returns [ 5, 2, 5, 4 ] - -out = [ 0, 0, 0, 0 ]; -arr = where.assign( [ true ], x, y, out, 1, 0 ); -// returns [ 1, 2, 3, 4 ] - -out = [ 0, 0, 0, 0 ]; -arr = where.assign( [ false ], x, y, out, 1, 0 ); -// returns [ 5, 5, 5, 5 ] - -out = [ 0, 0, 0, 0 ]; -arr = where.assign( condition, [ 1 ], y, out, 1, 0 ); -// returns [ 1, 5, 1, 5 ] -``` - -When `condition` is an empty array, the function returns the output array unchanged. - -```javascript -var x = [ 1, 2, 3, 4 ]; -var y = [ 5, 6, 7, 8 ]; - -var out = [ 0, 0, 0, 0 ]; -var condition = []; - -var arr = where.assign( condition, x, y, out, 1, 0 ); -// returns [ 0, 0, 0, 0 ] - -var bool = ( arr === out ); -// returns true -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var where = require( '@stdlib/array/base/where' ); - -var opts = { - 'dtype': 'generic' -}; - -// Generate an array of indicator values: -var condition = bernoulli( 20, 0.9, opts ); -console.log( condition ); - -// Generate an array of random values: -var x = discreteUniform( condition.length, 0, 10, opts ); -console.log( x ); - -// Define an array containing a broadcasted "missing" value: -var y = [ NaN ]; - -// Return an array with randomly placed missing values: -var z = where( condition, x, y ); -console.log( z ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/where/benchmark/benchmark.assign.length.js b/base/where/benchmark/benchmark.assign.length.js deleted file mode 100644 index 403b92f3f..000000000 --- a/base/where/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,116 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var zeros = require( './../../../zeros' ); -var ones = require( './../../../ones' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var where = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'dtype': 'generic' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var conditions; - var out; - var x; - var y; - - conditions = [ - bernoulli( len, 0.5, opts ), - bernoulli( len, 0.5, opts ) - ]; - out = zeros( len, opts.dtype ); - x = zeros( len, opts.dtype ); - y = ones( len, opts.dtype ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = where.assign( conditions[ i%conditions.length ], x, y, out, 1, 0 ); // eslint-disable-line max-len - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/where/benchmark/benchmark.js b/base/where/benchmark/benchmark.js deleted file mode 100644 index fc98c2b38..000000000 --- a/base/where/benchmark/benchmark.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var zeros = require( './../../../base/zeros' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var where = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var conditions; - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = zeroTo( 100 ); - conditions = [ - zeros( 100 ), - ones( 100 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = where( conditions[ i%conditions.length ], x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/where/benchmark/benchmark.length.js b/base/where/benchmark/benchmark.length.js deleted file mode 100644 index dcda3f822..000000000 --- a/base/where/benchmark/benchmark.length.js +++ /dev/null @@ -1,106 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var zeros = require( './../../../base/zeros' ); -var ones = require( './../../../base/ones' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var where = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'dtype': 'generic' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var condition = bernoulli( len, 0.5, opts ); - var x = zeros( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = where( condition, x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/where/docs/repl.txt b/base/where/docs/repl.txt deleted file mode 100644 index 018de5fe5..000000000 --- a/base/where/docs/repl.txt +++ /dev/null @@ -1,96 +0,0 @@ - -{{alias}}( condition, x, y ) - Takes elements from either one of two arrays depending on a condition. - - When all input arrays are non-empty, the function supports broadcasting - single-element arrays to the resolved output array length, which is equal to - the maximum length of all provided input arrays. - - If `condition` is an empty array, the function returns an empty array. - - Parameters - ---------- - condition: ArrayLikeObject - Array containing values indicating whether to take an element from - either `x` or `y`. If a condition element is truthy, the function takes - a respective element from `x`; otherwise, the function takes a - respective element from `y`. If non-empty, must be broadcast compatible - with the resolved output array length. - - x: ArrayLikeObject - First input array. If `condition` is non-empty, must be broadcast - compatible with the resolved output array length. - - y: ArrayLikeObject - Second input array. If `condition` is non-empty, must be broadcast - compatible with the resolved output array length. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = [ 5, 6, 7, 8 ]; - > var c = [ true, false, true, false ]; - > var z = {{alias}}( c, x, y ) - [ 1, 6, 3, 8 ] - - -{{alias}}.assign( condition, x, y, out, stride, offset ) - Takes elements from either one of two arrays depending on a condition and - assigns the values to elements in a provided output array. - - The function supports broadcasting single-element arrays to the output array - length. - - When `condition` is an empty array, the function returns the output array - unchanged. - - Parameters - ---------- - condition: ArrayLikeObject - Array containing values indicating whether to take an element from - either `x` or `y`. If a condition element is truthy, the function takes - a respective element from `x`; otherwise, the function takes a - respective element from `y`. If non-empty, must be broadcast compatible - with the output array. - - x: ArrayLikeObject - First input array. If `condition` is non-empty, must be broadcast - compatible with the output array. - - y: ArrayLikeObject - Second input array. If `condition` is non-empty, must be broadcast - compatible with the output array. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = [ 5, 6, 7, 8 ]; - > var c = [ true, false, true, false ]; - > var out = [ 0, 0, 0, 0, 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( c, x, y, out, 2, 0 ) - [ 1, 0, 6, 0, 3, 0, 8, 0 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/base/where/docs/types/index.d.ts b/base/where/docs/types/index.d.ts deleted file mode 100644 index 1471dd556..000000000 --- a/base/where/docs/types/index.d.ts +++ /dev/null @@ -1,238 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; - -/** -* Input array. -*/ -type InputArray = Collection | AccessorArrayLike; - -/** -* Interface describing `where`. -*/ -interface Where { - /** - * Takes elements from either one of two arrays depending on a condition. - * - * @param condition - array containing indicator values - * @param x - first input array - * @param y - second input array - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var y = [ 5, 6, 7, 8 ]; - * - * var condition = [ true, false, true, false ]; - * - * var z = where( condition, x, y ); - * // returns [ 1, 6, 3, 8 ] - */ - ( condition: InputArray, x: InputArray, y: InputArray ): Array; - - /** - * Takes elements from either one of two arrays depending on a condition and assigns the values to elements in a provided output array. - * - * @param condition - array containing indicator values - * @param x - first input array - * @param y - second input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Int32Array = require( './../../../../int32' ); - * - * var x = new Int32Array( [ 1, 2, 3, 4 ] ); - * var y = new Int32Array( [ 5, 6, 7, 8 ] ); - * - * var out = new Int32Array( [ 0, 0, 0, 0 ] ); - * var condition = [ true, false, true, false ]; - * - * var arr = assign( condition, x, y, out, 1, 0 ); - * // returns [ 1, 6, 3, 8 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( condition: InputArray, x: InputArray, y: InputArray, out: T, stride: number, offset: number ): T; - - /** - * Takes elements from either one of two arrays depending on a condition and assigns the values to elements in a provided output array. - * - * @param condition - array containing indicator values - * @param x - first input array - * @param y - second input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var BooleanArray = require( './../../../../bool' ); - * - * var x = new BooleanArray( [ 0, 1, 0, 1 ] ); - * var y = new BooleanArray( [ 1, 0, 1, 0 ] ); - * - * var out = new BooleanArray( [ 0, 0, 0, 0 ] ); - * var condition = [ true, false, true, false ]; - * - * var arr = assign( condition, x, y, out, 1, 0 ); - * // returns - * - * var bool = ( arr === out ); - * // returns true - * - * var v = arr.get( 0 ); - * // returns true - * - * v = arr.get( 1 ); - * // returns true - */ - assign( condition: InputArray, x: InputArray, y: InputArray, out: T, stride: number, offset: number ): T; - - /** - * Takes elements from either one of two arrays depending on a condition and assigns the values to elements in a provided output array. - * - * @param condition - array containing indicator values - * @param x - first input array - * @param y - second input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var BooleanArray = require( './../../../../bool' ); - * - * var x = new BooleanArray( [ 0, 1, 0, 1 ] ); - * var y = new BooleanArray( [ 1, 0, 1, 0 ] ); - * - * var out = new BooleanArray( [ 0, 0, 0, 0 ] ); - * var condition = [ true, false, true, false ]; - * - * var arr = assign( condition, x, y, out, 1, 0 ); - * // returns - * - * var bool = ( arr === out ); - * // returns true - * - * var v = arr.get( 0 ); - * // returns true - * - * v = arr.get( 1 ); - * // returns true - */ - assign( condition: InputArray, x: InputArray, y: InputArray, out: T, stride: number, offset: number ): T; - - /** - * Takes elements from either one of two arrays depending on a condition and assigns the values to elements in a provided output array. - * - * @param condition - array containing indicator values - * @param x - first input array - * @param y - second input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var y = [ 5, 6, 7, 8 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * var condition = [ true, false, true, false ]; - * - * var arr = assign( condition, x, y, out, 1, 0 ); - * // returns [ 1, 6, 3, 8 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( condition: InputArray, x: InputArray, y: InputArray, out: Array, stride: number, offset: number ): Array; - - /** - * Takes elements from either one of two arrays depending on a condition and assigns the values to elements in a provided output array. - * - * @param condition - array containing indicator values - * @param x - first input array - * @param y - second input array - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * var y = [ 5, 6, 7, 8 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * var condition = [ true, false, true, false ]; - * - * var arr = assign( condition, x, y, out, 1, 0 ); - * // returns [ 1, 6, 3, 8 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( condition: InputArray, x: InputArray, y: InputArray, out: InputArray, stride: number, offset: number ): InputArray; -} - -/** -* Takes elements from either one of two arrays depending on a condition. -* -* @param condition - array containing indicator values -* @param x - first input array -* @param y - second input array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* -* var condition = [ true, false, true, false ]; -* -* var z = where( condition, x, y ); -* // returns [ 1, 6, 3, 8 ] -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* var condition = [ true, false, true, false ]; -* -* var arr = where.assign( condition, x, y, out, 1, 0 ); -* // returns [ 1, 6, 3, 8 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var where: Where; - - -// EXPORTS // - -export = where; diff --git a/base/where/docs/types/test.ts b/base/where/docs/types/test.ts deleted file mode 100644 index 11d128771..000000000 --- a/base/where/docs/types/test.ts +++ /dev/null @@ -1,177 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import BooleanArray = require( './../../../../bool' ); -import where = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - where( [ true, false ], [ 1, 2 ], [ 3, 4 ] ); // $ExpectType number[] - where( [ true, false ], [ 1, 2 ], [ '3', '4' ] ); // $ExpectType (string | number)[] - where( [ true, false ], new Int32Array( [ 1, 2 ] ), new Int32Array( [ 3, 4 ] ) ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - where( 1, [ 1, 2 ], [ 3, 4 ] ); // $ExpectError - where( true, [ 1, 2 ], [ 3, 4 ] ); // $ExpectError - where( false, [ 1, 2 ], [ 3, 4 ] ); // $ExpectError - where( null, [ 1, 2 ], [ 3, 4 ] ); // $ExpectError - where( void 0, [ 1, 2 ], [ 3, 4 ] ); // $ExpectError - where( {}, [ 1, 2 ], [ 3, 4 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - where( [], 1, [ 3, 4 ] ); // $ExpectError - where( [], true, [ 3, 4 ] ); // $ExpectError - where( [], false, [ 3, 4 ] ); // $ExpectError - where( [], null, [ 3, 4 ] ); // $ExpectError - where( [], void 0, [ 3, 4 ] ); // $ExpectError - where( [], {}, [ 3, 4 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object... -{ - where( [], [ 1, 2 ], 1 ); // $ExpectError - where( [], [ 1, 2 ], true ); // $ExpectError - where( [], [ 1, 2 ], false ); // $ExpectError - where( [], [ 1, 2 ], null ); // $ExpectError - where( [], [ 1, 2 ], void 0 ); // $ExpectError - where( [], [ 1, 2 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - where(); // $ExpectError - where( [] ); // $ExpectError - where( [], [] ); // $ExpectError - where( [], [], [], [] ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const condition = [ true ]; - - where.assign( condition, [ 0 ], [ 0 ], [ 0 ], 1, 0 ); // $ExpectType number[] - where.assign( condition, [ 0 ], [ '0' ], [ 0 ], 1, 0 ); // $ExpectType (string | number)[] - where.assign( condition, new Float64Array( [ 0 ] ), [ 0 ], [ 0 ], 1, 0 ); // $ExpectType number[] - - where.assign( condition, new Float64Array( 1 ), new Float64Array( 1 ), new Float64Array( 1 ), 1, 0 ); // $ExpectType Float64Array - where.assign( condition, new Float32Array( 1 ), new Float32Array( 1 ), new Float32Array( 1 ), 1, 0 ); // $ExpectType Float32Array - where.assign( condition, new Int32Array( 1 ), new Int32Array( 1 ), new Int32Array( 1 ), 1, 0 ); // $ExpectType Int32Array - where.assign( condition, new Int16Array( 1 ), new Int16Array( 1 ), new Int16Array( 1 ), 1, 0 ); // $ExpectType Int16Array - where.assign( condition, new Int8Array( 1 ), new Int8Array( 1 ), new Int8Array( 1 ), 1, 0 ); // $ExpectType Int8Array - where.assign( condition, new Uint32Array( 1 ), new Uint32Array( 1 ), new Uint32Array( 1 ), 1, 0 ); // $ExpectType Uint32Array - where.assign( condition, new Uint16Array( 1 ), new Uint16Array( 1 ), new Uint16Array( 1 ), 1, 0 ); // $ExpectType Uint16Array - where.assign( condition, new Uint8Array( 1 ), new Uint8Array( 1 ), new Uint8Array( 1 ), 1, 0 ); // $ExpectType Uint8Array - where.assign( condition, new Uint8ClampedArray( 1 ), new Uint8ClampedArray( 1 ), new Uint8ClampedArray( 1 ), 1, 0 ); // $ExpectType Uint8ClampedArray - where.assign( condition, new BooleanArray( 1 ), new BooleanArray( 1 ), new BooleanArray( 1 ), 1, 0 ); // $ExpectType BooleanArray - where.assign( condition, new Complex128Array( 1 ), new Complex128Array( 1 ), new Complex128Array( 1 ), 1, 0 ); // $ExpectType Complex128Array - where.assign( condition, new Complex64Array( 1 ), new Complex64Array( 1 ), new Complex64Array( 1 ), 1, 0 ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0 ]; - - where.assign( 1, [ 0 ], [ 0 ], out, 1, 0 ); // $ExpectError - where.assign( true, [ 0 ], [ 0 ], out, 1, 0 ); // $ExpectError - where.assign( false, [ 0 ], [ 0 ], out, 1, 0 ); // $ExpectError - where.assign( null, [ 0 ], [ 0 ], out, 1, 0 ); // $ExpectError - where.assign( void 0, [ 0 ], [ 0 ], out, 1, 0 ); // $ExpectError - where.assign( {}, [ 0 ], [ 0 ], out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not an array-like object... -{ - const out = [ 0 ]; - - where.assign( [], 1, [ 0 ], out, 1, 0 ); // $ExpectError - where.assign( [], true, [ 0 ], out, 1, 0 ); // $ExpectError - where.assign( [], false, [ 0 ], out, 1, 0 ); // $ExpectError - where.assign( [], null, [ 0 ], out, 1, 0 ); // $ExpectError - where.assign( [], void 0, [ 0 ], out, 1, 0 ); // $ExpectError - where.assign( [], {}, [ 0 ], out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const out = [ 0 ]; - - where.assign( [], [ 0 ], 1, out, 1, 0 ); // $ExpectError - where.assign( [], [ 0 ], true, out, 1, 0 ); // $ExpectError - where.assign( [], [ 0 ], false, out, 1, 0 ); // $ExpectError - where.assign( [], [ 0 ], null, out, 1, 0 ); // $ExpectError - where.assign( [], [ 0 ], void 0, out, 1, 0 ); // $ExpectError - where.assign( [], [ 0 ], {}, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - where.assign( [], [ 0 ], [ 0 ], 1, 1, 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], true, 1, 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], false, 1, 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], null, 1, 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], void 0, 1, 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const out = [ 0 ]; - - where.assign( [], [ 0 ], [ 0 ], out, '1', 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, true, 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, false, 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, null, 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, void 0, 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, {}, 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, [], 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const out = [ 0 ]; - - where.assign( [], [ 0 ], [ 0 ], out, 1, '1' ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, 1, true ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, 1, false ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, 1, null ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, 1, void 0 ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, 1, {} ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, 1, [] ); // $ExpectError - where.assign( [], [ 0 ], [ 0 ], out, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - where.assign(); // $ExpectError - where.assign( [] ); // $ExpectError - where.assign( [], [] ); // $ExpectError - where.assign( [], [], [] ); // $ExpectError - where.assign( [], [], [], [] ); // $ExpectError - where.assign( [], [], [], [], 1 ); // $ExpectError - where.assign( [], [], [], [], 1, 0, {} ); // $ExpectError -} diff --git a/base/where/examples/index.js b/base/where/examples/index.js deleted file mode 100644 index 80c864bac..000000000 --- a/base/where/examples/index.js +++ /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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var where = require( './../lib' ); - -var opts = { - 'dtype': 'generic' -}; - -// Generate an array of indicator values: -var condition = bernoulli( 20, 0.9, opts ); -console.log( condition ); - -// Generate an array of random values: -var x = discreteUniform( condition.length, 0, 10, opts ); -console.log( x ); - -// Define an array containing a broadcasted "missing" value: -var y = [ NaN ]; - -// Return an array with randomly placed missing values: -var z = where( condition, x, y ); -console.log( z ); diff --git a/base/where/lib/assign.js b/base/where/lib/assign.js deleted file mode 100644 index 3df880118..000000000 --- a/base/where/lib/assign.js +++ /dev/null @@ -1,330 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var isBooleanDataType = require( './../../../base/assert/is-boolean-data-type' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpretCmplx = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBool = require( '@stdlib/strided/base/reinterpret-boolean' ); -var resolveStride = require( './resolve_stride.js' ); -var numel = require( './numel.js' ); - - -// FUNCTIONS // - -/** -* Takes elements from either one indexed array or another depending on a condition and assigns the values to elements in an indexed output array. -* -* @private -* @param {NonNegativeInteger} N - number of indexed elements -* @param {Collection} condition - indicator array -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @throws {Error} input arrays must be broadcast compatible with the output array -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* var condition = [ true, false, true, false ]; -* -* var arr = indexed( out.length, condition, x, y, out, 1, 0 ); -* // returns [ 1, 6, 3, 8 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function indexed( N, condition, x, y, out, stride, offset ) { - var sx; - var sy; - var sc; - var ix; - var iy; - var ic; - var io; - var i; - - // Broadcast the arrays by computing strides: - sc = resolveStride( condition.length, N ); - sx = resolveStride( x.length, N ); - sy = resolveStride( y.length, N ); - - // Initialize indices: - ic = 0; - ix = 0; - iy = 0; - io = offset; - - // Extract each desired element from a provided array... - for ( i = 0; i < N; i++ ) { - out[ io ] = ( condition[ ic ] ) ? x[ ix ] : y[ iy ]; - ic += sc; - ix += sx; - iy += sy; - io += stride; - } - return out; -} - -/** -* Takes elements from either one accessor array or another depending on a condition and assigns the values to elements in an accessor output array. -* -* @private -* @param {NonNegativeInteger} N - number of indexed elements -* @param {Object} condition - condition array object -* @param {Object} x - first input array object -* @param {Object} y - second input array object -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* var y = toAccessorArray( [ 5, 6, 7, 8 ] ); -* -* var condition = toAccessorArray( [ true, false, true, false ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( out.length, arraylike2object( condition ), arraylike2object( x ), arraylike2object( y ), arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 1 -* -* v = arr.get( 1 ); -* // returns 6 -*/ -function accessors( N, condition, x, y, out, stride, offset ) { - var xdata; - var ydata; - var cdata; - var odata; - var xget; - var yget; - var cget; - var oset; - var sx; - var sy; - var sc; - var ix; - var iy; - var ic; - var io; - var i; - - cdata = condition.data; - xdata = x.data; - ydata = y.data; - odata = out.data; - - cget = condition.accessors[ 0 ]; - xget = x.accessors[ 0 ]; - yget = y.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - // Broadcast the arrays by computing strides: - sc = resolveStride( cdata.length, N ); - sx = resolveStride( xdata.length, N ); - sy = resolveStride( ydata.length, N ); - - // Initialize indices: - ic = 0; - ix = 0; - iy = 0; - io = offset; - - // Extract each desired element from a provided array... - for ( i = 0; i < N; i++ ) { - oset( odata, io, ( cget( cdata, ic ) ) ? xget( xdata, ix ) : yget( ydata, iy ) ); // eslint-disable-line max-len - ic += sc; - ix += sx; - iy += sy; - io += stride; - } - return odata; -} - -/** -* Takes elements from either one complex array or another depending on a condition and assigns the values to elements in a complex output array. -* -* @private -* @param {NonNegativeInteger} N - number of indexed elements -* @param {Object} condition - condition array object -* @param {Collection} x - first real-valued floating-point input array view -* @param {Collection} y - second real-valued floating-point input array view -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* var y = new Float64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] ); -* -* var condition = [ true, false, true, false ]; -* -* var out = new Float64Array( 8 ); -* -* var arr = complex( 4, arraylike2object( condition ), x, y, out, 1, 0 ); -* // returns [ 1.0, 2.0, 11.0, 12.0, 5.0, 6.0, 15.0, 16.0 ] -*/ -function complex( N, condition, x, y, out, stride, offset ) { - var cdata; - var cget; - var sx; - var sy; - var sc; - var so; - var ix; - var iy; - var ic; - var io; - var i; - - cdata = condition.data; - cget = condition.accessors[ 0 ]; - - // Broadcast the arrays by computing strides (note: multiply strides by 2 for complex array arguments, as a real-valued array view consists of interleaved real and imaginary components): - sc = resolveStride( cdata.length, N ); - sx = resolveStride( x.length/2, N ) * 2; - sy = resolveStride( y.length/2, N ) * 2; - so = stride * 2; - - // Initialize indices: - ic = 0; - ix = 0; - iy = 0; - io = offset * 2; // note: account for interleaved real and imaginary components - - // Extract each desired element from a provided array... - for ( i = 0; i < N; i++ ) { - if ( cget( cdata, ic ) ) { - out[ io ] = x[ ix ]; - out[ io+1 ] = x[ ix+1 ]; - } else { - out[ io ] = y[ iy ]; - out[ io+1 ] = y[ iy+1 ]; - } - ic += sc; - ix += sx; - iy += sy; - io += so; - } - return out; -} - - -// MAIN // - -/** -* Takes elements from either one of two arrays depending on a condition and assigns the values to elements in a provided output array. -* -* @param {Collection} condition - indicator array -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @throws {Error} input arrays must be broadcast compatible with the output array -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* var condition = [ true, false, true, false ]; -* -* var arr = assign( condition, x, y, out, 1, 0 ); -* // returns [ 1, 6, 3, 8 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( condition, x, y, out, stride, offset ) { - var co; - var xo; - var yo; - var oo; - var N; - - // Check whether we can avoid doing any work... - if ( condition.length === 0 ) { - return out; - } - // Compute the number of indexed elements in the output array: - N = numel( out.length, stride, offset ); - - co = arraylike2object( condition ); - if ( isBooleanDataType( co.dtype ) ) { - condition = reinterpretBool( condition, 0 ); - co = arraylike2object( condition ); - } - xo = arraylike2object( x ); - yo = arraylike2object( y ); - oo = arraylike2object( out ); - if ( - co.accessorProtocol || - xo.accessorProtocol || - yo.accessorProtocol || - oo.accessorProtocol - ) { - // Note: we only explicitly special case a select number of same dtype-to-dtype combinations, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - co.accessorProtocol === false && - isBooleanDataType( xo.dtype ) && - isBooleanDataType( yo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - indexed( N, condition, reinterpretBool( x, 0 ), reinterpretBool( y, 0 ), reinterpretBool( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( yo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( N, co, reinterpretCmplx( x, 0 ), reinterpretCmplx( y, 0 ), reinterpretCmplx( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( N, co, xo, yo, oo, stride, offset ); - return out; - } - indexed( N, condition, x, y, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/where/lib/index.js b/base/where/lib/index.js deleted file mode 100644 index 79618dd88..000000000 --- a/base/where/lib/index.js +++ /dev/null @@ -1,67 +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. -*/ - -'use strict'; - -/** -* Take elements from either one of two arrays depending on a condition. -* -* @module @stdlib/array/base/where -* -* @example -* var where = require( '@stdlib/array/base/where' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* -* var condition = [ true, false, true, false ]; -* -* var z = where( condition, x, y ); -* // returns [ 1, 6, 3, 8 ] -* -* @example -* var where = require( '@stdlib/array/base/where' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* var condition = [ true, false, true, false ]; -* -* var arr = where.assign( condition, x, y, out, 1, 0 ); -* // returns [ 1, 6, 3, 8 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/where/lib/main.js b/base/where/lib/main.js deleted file mode 100644 index bcddecc91..000000000 --- a/base/where/lib/main.js +++ /dev/null @@ -1,109 +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. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); -var maxn = require( '@stdlib/math/base/special/maxn' ); -var resolveStride = require( './resolve_stride.js' ); - - -// MAIN // - -/** -* Takes elements from either one of two arrays depending on a condition. -* -* @param {Collection} condition - indicator array -* @param {Collection} x - first input array -* @param {Collection} y - second input array -* @throws {Error} input arrays must be broadcast compatible -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var y = [ 5, 6, 7, 8 ]; -* -* var condition = [ true, false, true, false ]; -* -* var z = where( condition, x, y ); -* // returns [ 1, 6, 3, 8 ] -*/ -function where( condition, x, y ) { - var xget; - var yget; - var cget; - var lens; - var out; - var sx; - var sy; - var sc; - var ix; - var iy; - var ic; - var N; - var v; - var i; - - // Cache the lengths of the input arrays: - lens = [ condition.length, x.length, y.length ]; - - // Check whether we can avoid doing any further work... - if ( lens[ 0 ] === 0 ) { - // E.g., `where( [], [ 1, 2 ], [ 3, 4 ] )` - return []; - } - // Compute the output array length: - N = maxn( lens[ 0 ], lens[ 1 ], lens[ 2 ] ); - - // Broadcast the arrays by computing strides: - sc = resolveStride( lens[ 0 ], N ); - sx = resolveStride( lens[ 1 ], N ); - sy = resolveStride( lens[ 2 ], N ); - - // Resolve accessors for retrieving array elements: - cget = resolveGetter( condition ); - xget = resolveGetter( x ); - yget = resolveGetter( y ); - - // Initialize indices: - ic = 0; - ix = 0; - iy = 0; - - // Extract each desired element from a provided array... - out = []; - for ( i = 0; i < N; i++ ) { - if ( cget( condition, ic ) ) { - v = xget( x, ix ); - } else { - v = yget( y, iy ); - } - out.push( v ); // use `Array#push` to ensure "fast" elements - ic += sc; - ix += sx; - iy += sy; - } - return out; -} - - -// EXPORTS // - -module.exports = where; diff --git a/base/where/lib/numel.js b/base/where/lib/numel.js deleted file mode 100644 index ed3bfd0fe..000000000 --- a/base/where/lib/numel.js +++ /dev/null @@ -1,105 +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. -*/ - -'use strict'; - -// MODULES // - -var ceil = require( '@stdlib/math/base/special/ceil' ); - - -// MAIN // - -/** -* Computes the number of indexed elements in a strided array. -* -* @private -* @param {NonNegativeInteger} len - array length -* @param {integer} stride - array stride -* @param {NonNegativeInteger} offset - array offset -* @returns {NonNegativeInteger} number of indexed elements -* -* @example -* var N = numel( 10, -2, 9 ); -* // returns 5 -* -* N = numel( 10, -2, 8 ); -* // returns 5 -* -* N = numel( 10, -2, 7 ); -* // returns 4 -* -* N = numel( 10, -2, 6 ); -* // returns 4 -* -* N = numel( 10, -2, 5 ); -* // returns 3 -* -* @example -* var N = numel( 10, -3, 9 ); -* // returns 4 -* -* N = numel( 10, -3, 8 ); -* // returns 3 -* -* N = numel( 10, -3, 7 ); -* // returns 3 -* -* N = numel( 10, -3, 6 ); -* // returns 3 -* -* N = numel( 10, -3, 5 ); -* // returns 2 -* -* @example -* var N = numel( 10, 2, 0 ); -* // returns 5 -* -* N = numel( 10, 2, 1 ); -* // returns 5 -* -* N = numel( 10, 2, 2 ); -* // returns 4 -* -* N = numel( 10, 2, 3 ); -* // returns 4 -* -* @example -* var N = numel( 10, 3, 0 ); -* // returns 4 -* -* N = numel( 10, 3, 1 ); -* // returns 3 -* -* N = numel( 10, 3, 2 ); -* // returns 3 -* -* N = numel( 10, 3, 3 ); -* // returns 3 -*/ -function numel( len, stride, offset ) { - if ( stride < 0 ) { - return ceil( (offset+1) / -stride ); - } - return ceil( (len-offset) / stride ); -} - - -// EXPORTS // - -module.exports = numel; diff --git a/base/where/lib/resolve_stride.js b/base/where/lib/resolve_stride.js deleted file mode 100644 index 63d3538a7..000000000 --- a/base/where/lib/resolve_stride.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Resolves a stride length for broadcasting a one-dimensional array. -* -* @private -* @param {NonNegativeInteger} M - input array length -* @param {NonNegativeInteger} N - output array length -* @throws {Error} input arrays must be broadcast compatible -* @returns {NonNegativeInteger} stride length -*/ -function resolveStride( M, N ) { - // Note that this effectively in-lines logic from `@stdlib/array/base/broadcast-array` in order to avoid unnecessary object creation... - if ( M === 1 ) { - return 0; - } - if ( M === N ) { - return 1; - } - throw new Error( 'invalid arguments. Input arguments are not broadcast compatible.' ); -} - - -// EXPORTS // - -module.exports = resolveStride; diff --git a/base/where/package.json b/base/where/package.json deleted file mode 100644 index e9393e967..000000000 --- a/base/where/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/base/where", - "version": "0.0.0", - "description": "Take elements from either one of two arrays depending on a condition.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index", - "where" - ] -} diff --git a/base/where/test/test.assign.js b/base/where/test/test.assign.js deleted file mode 100644 index 12cbbe263..000000000 --- a/base/where/test/test.assign.js +++ /dev/null @@ -1,745 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int32Array = require( './../../../int32' ); -var Uint8Array = require( './../../../uint8' ); -var BooleanArray = require( './../../../bool' ); -var Complex64Array = require( './../../../complex64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isAccessorArray = require( '@stdlib/assert/is-accessor-array' ); -var reinterpretBool = require( '@stdlib/strided/base/reinterpret-boolean' ); -var zeros = require( './../../../zeros' ); -var where = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof where, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (generic)', function test( t ) { - var condition; - var expected; - var actual; - var out; - var x; - var y; - - x = [ 1 ]; - y = [ 5 ]; - - out = zeros( 1, 'generic' ); - condition = [ true ]; - actual = where( condition, x, y, out, 1, 0 ); - expected = [ 1 ]; - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 2, 'generic' ); - condition = [ false ]; - actual = where( condition, x, y, out, 1, 1 ); - expected = [ 0, 5 ]; - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = [ 5, 6, 7, 8 ]; - - out = zeros( 4, 'generic' ); - condition = [ true, false, true, false ]; - actual = where( condition, x, y, out, 1, 0 ); - expected = [ 1, 6, 3, 8 ]; - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 4, 'generic' ); - condition = [ true, true, true, true ]; - actual = where( condition, x, y, out, 1, 0 ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 8, 'generic' ); - condition = [ false, false, false, false ]; - actual = where( condition, x, y, out, 2, 0 ); - expected = [ 5, 0, 6, 0, 7, 0, 8, 0 ]; - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (generic, broadcasting)', function test( t ) { - var condition; - var expected; - var actual; - var out; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = [ 5, 6, 7, 8 ]; - - out = zeros( 4, 'generic' ); - condition = [ true, false, true, false ]; - actual = where( condition, x, [ 5 ], out, 1, 0 ); - expected = [ 1, 5, 3, 5 ]; - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 4, 'generic' ); - condition = [ true, false, true, false ]; - actual = where( condition, [ -1 ], y, out, 1, 0 ); - expected = [ -1, 6, -1, 8 ]; - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 8, 'generic' ); - condition = [ true ]; - actual = where( condition, x, y, out, 2, 1 ); - expected = [ 0, 1, 0, 2, 0, 3, 0, 4 ]; - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 4, 'generic' ); - condition = [ false ]; - actual = where( condition, x, y, out, -1, 3 ); - expected = [ 8, 7, 6, 5 ]; - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 4, 'generic' ); - condition = [ true ]; - actual = where( condition, [ -1 ], y, out, 1, 0 ); - expected = [ -1, -1, -1, -1 ]; - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 4, 'generic' ); - condition = [ false ]; - actual = where( condition, x, [ 5 ], out, 1, 0 ); - expected = [ 5, 5, 5, 5 ]; - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (accessors)', function test( t ) { - var condition; - var expected; - var actual; - var out; - var x; - var y; - - x = toAccessorArray( [ 1 ] ); - y = toAccessorArray( [ 5 ] ); - - out = zeros( 1, 'generic' ); - condition = toAccessorArray( [ true ] ); - actual = where( condition, x, y, toAccessorArray( out ), 1, 0 ); - expected = [ 1 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - out = zeros( 2, 'generic' ); - condition = toAccessorArray( [ false ] ); - actual = where( condition, x, y, toAccessorArray( out ), 1, 1 ); - expected = [ 0, 5 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - y = toAccessorArray( [ 5, 6, 7, 8 ] ); - - out = zeros( 4, 'generic' ); - condition = toAccessorArray( [ true, false, true, false ] ); - actual = where( condition, x, y, toAccessorArray( out ), 1, 0 ); - expected = [ 1, 6, 3, 8 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - out = zeros( 8, 'generic' ); - condition = toAccessorArray( [ true, true, true, true ] ); - actual = where( condition, x, y, toAccessorArray( out ), 2, 0 ); - expected = [ 1, 0, 2, 0, 3, 0, 4, 0 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - out = zeros( 4, 'generic' ); - condition = toAccessorArray( [ false, false, false, false ] ); - actual = where( condition, x, y, toAccessorArray( out ), -1, 3 ); - expected = [ 8, 7, 6, 5 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (accessors, broadcasting)', function test( t ) { - var condition; - var expected; - var actual; - var out; - var x; - var y; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - y = toAccessorArray( [ 5, 6, 7, 8 ] ); - - out = zeros( 4, 'generic' ); - condition = toAccessorArray( [ true, false, true, false ] ); - actual = where( condition, x, [ 5 ], toAccessorArray( out ), 1, 0 ); - expected = [ 1, 5, 3, 5 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - out = zeros( 4, 'generic' ); - condition = toAccessorArray( [ true, false, true, false ] ); - actual = where( condition, [ -1 ], y, toAccessorArray( out ), 1, 0 ); - expected = [ -1, 6, -1, 8 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - out = zeros( 8, 'generic' ); - condition = toAccessorArray( [ true ] ); - actual = where( condition, x, y, toAccessorArray( out ), 2, 1 ); - expected = [ 0, 1, 0, 2, 0, 3, 0, 4 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - out = zeros( 4, 'generic' ); - condition = toAccessorArray( [ false ] ); - actual = where( condition, x, y, toAccessorArray( out ), -1, 3 ); - expected = [ 8, 7, 6, 5 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - out = zeros( 4, 'generic' ); - condition = toAccessorArray( [ true ] ); - actual = where( condition, [ -1 ], y, toAccessorArray( out ), 1, 0 ); - expected = [ -1, -1, -1, -1 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - out = zeros( 4, 'generic' ); - condition = toAccessorArray( [ false ] ); - actual = where( condition, x, [ 5 ], toAccessorArray( out ), 1, 0 ); - expected = [ 5, 5, 5, 5 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (typed)', function test( t ) { - var condition; - var expected; - var actual; - var out; - var x; - var y; - - x = new Int32Array( [ 1 ] ); - y = new Int32Array( [ 5 ] ); - - out = new Int32Array( 1 ); - condition = [ true ]; - actual = where( condition, x, y, out, 1, 0 ); - expected = new Int32Array( [ 1 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Int32Array( 2 ); - condition = [ false ]; - actual = where( condition, x, y, out, 1, 1 ); - expected = new Int32Array( [ 0, 5 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = new Int32Array( [ 5, 6, 7, 8 ] ); - - out = new Int32Array( 4 ); - condition = [ true, false, true, false ]; - actual = where( condition, x, y, out, 1, 0 ); - expected = new Int32Array( [ 1, 6, 3, 8 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Int32Array( 8 ); - condition = [ true, true, true, true ]; - actual = where( condition, x, y, out, 2, 0 ); - expected = new Int32Array( [ 1, 0, 2, 0, 3, 0, 4, 0 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Int32Array( 4 ); - condition = [ false, false, false, false ]; - actual = where( condition, x, y, out, -1, 3 ); - expected = new Int32Array( [ 8, 7, 6, 5 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (typed, broadcasting)', function test( t ) { - var condition; - var expected; - var actual; - var out; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = new Int32Array( [ 5, 6, 7, 8 ] ); - - out = new Int32Array( 4 ); - condition = [ true, false, true, false ]; - actual = where( condition, x, [ 5 ], out, 1, 0 ); - expected = new Int32Array( [ 1, 5, 3, 5 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Int32Array( 4 ); - condition = [ true, false, true, false ]; - actual = where( condition, [ -1 ], y, out, 1, 0 ); - expected = new Int32Array( [ -1, 6, -1, 8 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Int32Array( 8 ); - condition = [ true ]; - actual = where( condition, x, y, out, 2, 1 ); - expected = new Int32Array( [ 0, 1, 0, 2, 0, 3, 0, 4 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Int32Array( 4 ); - condition = [ false ]; - actual = where( condition, x, y, out, -1, 3 ); - expected = new Int32Array( [ 8, 7, 6, 5 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Int32Array( 4 ); - condition = [ true ]; - actual = where( condition, [ -1 ], y, out, 1, 0 ); - expected = new Int32Array( [ -1, -1, -1, -1 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Int32Array( 4 ); - condition = [ false ]; - actual = where( condition, x, [ 5 ], out, 1, 0 ); - expected = new Int32Array( [ 5, 5, 5, 5 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (boolean)', function test( t ) { - var condition; - var expected; - var actual; - var out; - var x; - var y; - - x = new BooleanArray( [ true ] ); - y = new BooleanArray( [ false ] ); - - out = new BooleanArray( 1 ); - condition = new BooleanArray( [ true ] ); - actual = where( condition, x, y, out, 1, 0 ); - expected = new Uint8Array( [ 1 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - - out = new BooleanArray( 2 ); - condition = new BooleanArray( [ false ] ); - actual = where( condition, x, y, out, 1, 1 ); - expected = new Uint8Array( [ 0, 0 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true, false ] ); - y = new BooleanArray( [ false, true, false, true ] ); - - out = new BooleanArray( 8 ); - condition = new BooleanArray( [ true, false, true, false ] ); - actual = where( condition, x, y, out, 2, 0 ); - expected = new Uint8Array( [ 1, 0, 1, 0, 1, 0, 1, 0 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - - out = new BooleanArray( 4 ); - condition = new BooleanArray( [ true, true, true, true ] ); - actual = where( condition, x, y, out, -1, 3 ); - expected = new Uint8Array( [ 0, 1, 0, 1 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - - out = new BooleanArray( 4 ); - condition = new BooleanArray( [ false, false, false, false ] ); - actual = where( condition, x, y, out, 1, 0 ); - expected = new Uint8Array( [ 0, 1, 0, 1 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (boolean, broadcasting)', function test( t ) { - var condition; - var expected; - var actual; - var out; - var x; - var y; - - x = new BooleanArray( [ true, false, true, false ] ); - y = new BooleanArray( [ false, true, false, true ] ); - - out = new BooleanArray( 4 ); - condition = [ true, false, true, false ]; - actual = where( condition, x, new BooleanArray( [ true ] ), out, 1, 0 ); - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - - out = new BooleanArray( 8 ); - condition = [ true, false, true, false ]; - actual = where( condition, new BooleanArray( [ false ] ), y, out, 2, 1 ); - expected = new Uint8Array( [ 0, 0, 0, 1, 0, 0, 0, 1 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - - out = new BooleanArray( 4 ); - condition = [ true ]; - actual = where( condition, x, y, out, -1, 3 ); - expected = new Uint8Array( [ 0, 1, 0, 1 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - - out = new BooleanArray( 4 ); - condition = [ false ]; - actual = where( condition, x, y, out, 1, 0 ); - expected = new Uint8Array( [ 0, 1, 0, 1 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - - out = new BooleanArray( 4 ); - condition = [ true ]; - actual = where( condition, [ false ], y, out, 1, 0 ); - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - - out = new BooleanArray( 4 ); - condition = [ false ]; - actual = where( condition, x, [ true ], out, 1, 0 ); - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (complex)', function test( t ) { - var condition; - var expected; - var actual; - var out; - var x; - var y; - - x = new Complex64Array( [ 1.0, 2.0 ] ); - y = new Complex64Array( [ 5.0, 6.0 ] ); - - out = new Complex64Array( 1 ); - condition = [ true ]; - actual = where( condition, x, y, out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0 ] ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( 2 ); - condition = [ false ]; - actual = where( condition, x, y, out, 1, 1 ); - expected = new Complex64Array( [ 0.0, 0.0, 5.0, 6.0 ] ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - y = new Complex64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 ] ); - - out = new Complex64Array( 8 ); - condition = [ true, false, true, false ]; - actual = where( condition, x, y, out, 2, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 0.0, 0.0, -3.0, -4.0, 0.0, 0.0, 5.0, 6.0, 0.0, 0.0, -7.0, -8.0, 0.0, 0.0 ] ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( 4 ); - condition = [ true, true, true, true ]; - actual = where( condition, x, y, out, -1, 3 ); - expected = new Complex64Array( [ 7.0, 8.0, 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( 4 ); - condition = [ false, false, false, false ]; - actual = where( condition, x, y, out, 1, 0 ); - expected = new Complex64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 ] ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (complex, broadcasting)', function test( t ) { - var condition; - var expected; - var actual; - var out; - var x; - var y; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - y = new Complex64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 ] ); - - out = new Complex64Array( 4 ); - condition = [ true, false, true, false ]; - actual = where( condition, x, new Complex64Array( [ 9.0, 10.0 ] ), out, 1, 0 ); - expected = new Complex64Array( [ 1.0, 2.0, 9.0, 10.0, 5.0, 6.0, 9.0, 10.0 ] ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( 4 ); - condition = [ true, false, true, false ]; - actual = where( condition, new Complex64Array( [ -9.0, -10.0 ] ), y, out, 1, 0 ); - expected = new Complex64Array( [ -9.0, -10.0, -3.0, -4.0, -9.0, -10.0, -7.0, -8.0 ] ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( 8 ); - condition = [ true ]; - actual = where( condition, x, y, out, 2, 1 ); - expected = new Complex64Array( [ 0.0, 0.0, 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 5.0, 6.0, 0.0, 0.0, 7.0, 8.0 ] ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( 4 ); - condition = [ false ]; - actual = where( condition, x, y, out, -1, 3 ); - expected = new Complex64Array( [ -7.0, -8.0, -5.0, -6.0, -3.0, -4.0, -1.0, -2.0 ] ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( 4 ); - condition = [ true ]; - actual = where( condition, new Complex64Array( [ -9.0, -10.0 ] ), y, out, 1, 0 ); - expected = new Complex64Array( [ -9.0, -10.0, -9.0, -10.0, -9.0, -10.0, -9.0, -10.0 ] ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( 4 ); - condition = [ false ]; - actual = where( condition, x, new Complex64Array( [ 9.0, 10.0 ] ), out, 1, 0 ); - expected = new Complex64Array( [ 9.0, 10.0, 9.0, 10.0, 9.0, 10.0, 9.0, 10.0 ] ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the output array unchanged if provided a first argument which is empty', function test( t ) { - var expected; - var actual; - var out; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - out = [ 0, 0, 0, 0 ]; - actual = where( [], x, x, out, 1, 0 ); - expected = [ 0, 0, 0, 0 ]; - t.strictEqual( out, actual, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = []; - y = []; - out = []; - actual = where( [], x, y, out, 1, 0 ); - expected = []; - t.strictEqual( out, actual, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided broadcast incompatible arguments (generic)', function test( t ) { - var values; - var i; - - values = [ - [ [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ], 2, 0 ], - [ [ 1, 2, 3, 4 ], [ 1, 2 ], [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ], 1, 0 ], - [ [ 1, 2 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ], 1, 0 ], - [ [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2 ], [ 0, 0, 0, 0 ], 1, 0 ], - [ [ 1, 2, 3, 4 ], [], [ 1, 2 ], [ 0, 0, 0, 0 ], 1, 0 ], - [ [ 1 ], [], [ 1, 2 ], [ 0, 0 ], 1, 0 ], - [ [ 1 ], [ 1, 2 ], [], [ 0, 0 ], 1, 0 ], - [ [ 1 ], [], [ 1 ], [ 0 ], 1, 0 ], - [ [ 1 ], [ 1 ], [], [ 0 ], 1, 0 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( args ) { - return function badValue() { - where.apply( null, args ); - }; - } -}); - -tape( 'the function throws an error if provided broadcast incompatible arguments (accessors)', function test( t ) { - var values; - var i; - - values = [ - [ [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ], 2, 0 ], - [ [ 1, 2, 3, 4 ], [ 1, 2 ], [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ], 1, 0 ], - [ [ 1, 2 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ], 1, 0 ], - [ [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2 ], [ 0, 0, 0, 0 ], 1, 0 ], - [ [ 1, 2, 3, 4 ], [], [ 1, 2 ], [ 0, 0, 0, 0 ], 1, 0 ], - [ [ 1 ], [], [ 1, 2 ], [ 0, 0 ], 1, 0 ], - [ [ 1 ], [ 1, 2 ], [], [ 0, 0 ], 1, 0 ], - [ [ 1 ], [], [ 1 ], [ 0 ], 1, 0 ], - [ [ 1 ], [ 1 ], [], [ 0 ], 1, 0 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( args ) { - var i; - for ( i = 0; i < 4; i++ ) { - args[ i ] = toAccessorArray( args[ i ] ); - } - return function badValue() { - where.apply( null, args ); - }; - } -}); - -tape( 'the function throws an error if provided broadcast incompatible arguments (typed)', function test( t ) { - var values; - var i; - - values = [ - [ new Int32Array( 4 ), new Int32Array( 4 ), new Int32Array( 4 ), new Int32Array( 4 ), 2, 0 ], - [ new Int32Array( 4 ), new Int32Array( 2 ), new Int32Array( 4 ), new Int32Array( 4 ), 2, 0 ], - [ new Int32Array( 4 ), new Int32Array( 2 ), new Int32Array( 4 ), new Int32Array( 4 ), 1, 0 ], - [ new Int32Array( 2 ), new Int32Array( 4 ), new Int32Array( 4 ), new Int32Array( 4 ), 1, 0 ], - [ new Int32Array( 4 ), new Int32Array( 4 ), new Int32Array( 2 ), new Int32Array( 4 ), 1, 0 ], - [ new Int32Array( 4 ), new Int32Array( 0 ), new Int32Array( 2 ), new Int32Array( 4 ), 1, 0 ], - [ new Int32Array( 1 ), new Int32Array( 0 ), new Int32Array( 2 ), new Int32Array( 2 ), 1, 0 ], - [ new Int32Array( 1 ), new Int32Array( 2 ), new Int32Array( 0 ), new Int32Array( 2 ), 1, 0 ], - [ new Int32Array( 1 ), new Int32Array( 0 ), new Int32Array( 1 ), new Int32Array( 1 ), 1, 0 ], - [ new Int32Array( 1 ), new Int32Array( 1 ), new Int32Array( 0 ), new Int32Array( 1 ), 1, 0 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( args ) { - return function badValue() { - where.apply( null, args ); - }; - } -}); - -tape( 'the function throws an error if provided broadcast incompatible arguments (boolean)', function test( t ) { - var values; - var i; - - values = [ - [ new BooleanArray( 4 ), new BooleanArray( 4 ), new BooleanArray( 4 ), new BooleanArray( 4 ), 2, 0 ], - [ new BooleanArray( 4 ), new BooleanArray( 2 ), new BooleanArray( 4 ), new BooleanArray( 4 ), 2, 0 ], - [ new BooleanArray( 4 ), new BooleanArray( 2 ), new BooleanArray( 4 ), new BooleanArray( 4 ), 1, 0 ], - [ new BooleanArray( 2 ), new BooleanArray( 4 ), new BooleanArray( 4 ), new BooleanArray( 4 ), 1, 0 ], - [ new BooleanArray( 4 ), new BooleanArray( 4 ), new BooleanArray( 2 ), new BooleanArray( 4 ), 1, 0 ], - [ new BooleanArray( 4 ), new BooleanArray( 0 ), new BooleanArray( 2 ), new BooleanArray( 4 ), 1, 0 ], - [ new BooleanArray( 1 ), new BooleanArray( 0 ), new BooleanArray( 2 ), new BooleanArray( 2 ), 1, 0 ], - [ new BooleanArray( 1 ), new BooleanArray( 2 ), new BooleanArray( 0 ), new BooleanArray( 2 ), 1, 0 ], - [ new BooleanArray( 1 ), new BooleanArray( 0 ), new BooleanArray( 1 ), new BooleanArray( 1 ), 1, 0 ], - [ new BooleanArray( 1 ), new BooleanArray( 1 ), new BooleanArray( 0 ), new BooleanArray( 1 ), 1, 0 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( args ) { - return function badValue() { - where.apply( null, args ); - }; - } -}); - -tape( 'the function throws an error if provided broadcast incompatible arguments (complex)', function test( t ) { - var values; - var i; - - values = [ - [ new Complex64Array( 4 ), new Complex64Array( 4 ), new Complex64Array( 4 ), new Complex64Array( 4 ), 2, 0 ], - [ new Complex64Array( 4 ), new Complex64Array( 2 ), new Complex64Array( 4 ), new Complex64Array( 4 ), 2, 0 ], - [ new Complex64Array( 4 ), new Complex64Array( 2 ), new Complex64Array( 4 ), new Complex64Array( 4 ), 1, 0 ], - [ new Complex64Array( 2 ), new Complex64Array( 4 ), new Complex64Array( 4 ), new Complex64Array( 4 ), 1, 0 ], - [ new Complex64Array( 4 ), new Complex64Array( 4 ), new Complex64Array( 2 ), new Complex64Array( 4 ), 1, 0 ], - [ new Complex64Array( 4 ), new Complex64Array( 0 ), new Complex64Array( 2 ), new Complex64Array( 4 ), 1, 0 ], - [ new Complex64Array( 1 ), new Complex64Array( 0 ), new Complex64Array( 2 ), new Complex64Array( 2 ), 1, 0 ], - [ new Complex64Array( 1 ), new Complex64Array( 2 ), new Complex64Array( 0 ), new Complex64Array( 2 ), 1, 0 ], - [ new Complex64Array( 1 ), new Complex64Array( 0 ), new Complex64Array( 1 ), new Complex64Array( 1 ), 1, 0 ], - [ new Complex64Array( 1 ), new Complex64Array( 1 ), new Complex64Array( 0 ), new Complex64Array( 1 ), 1, 0 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( args ) { - return function badValue() { - where.apply( null, args ); - }; - } -}); diff --git a/base/where/test/test.js b/base/where/test/test.js deleted file mode 100644 index e6b284f5c..000000000 --- a/base/where/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var where = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof where, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( where, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( where, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/where/test/test.main.js b/base/where/test/test.main.js deleted file mode 100644 index 6c8c999c6..000000000 --- a/base/where/test/test.main.js +++ /dev/null @@ -1,627 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int32Array = require( './../../../int32' ); -var BooleanArray = require( './../../../bool' ); -var Complex64Array = require( './../../../complex64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var isSameComplex64 = require( '@stdlib/assert/is-same-complex64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var where = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof where, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (generic)', function test( t ) { - var condition; - var expected; - var actual; - var x; - var y; - - x = [ 1 ]; - y = [ 5 ]; - - condition = [ true ]; - actual = where( condition, x, y ); - expected = [ 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, y ); - expected = [ 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = [ 5, 6, 7, 8 ]; - - condition = [ true, false, true, false ]; - actual = where( condition, x, y ); - expected = [ 1, 6, 3, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true, true, true, true ]; - actual = where( condition, x, y ); - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false, false, false, false ]; - actual = where( condition, x, y ); - expected = [ 5, 6, 7, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (generic, broadcasting)', function test( t ) { - var condition; - var expected; - var actual; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = [ 5, 6, 7, 8 ]; - - condition = [ true, false, true, false ]; - actual = where( condition, x, [ 5 ] ); - expected = [ 1, 5, 3, 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true, false, true, false ]; - actual = where( condition, [ -1 ], y ); - expected = [ -1, 6, -1, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true ]; - actual = where( condition, x, y ); - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, y ); - expected = [ 5, 6, 7, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true ]; - actual = where( condition, [ -1 ], y ); - expected = [ -1, -1, -1, -1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, [ 5 ] ); - expected = [ 5, 5, 5, 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (accessors)', function test( t ) { - var condition; - var expected; - var actual; - var x; - var y; - - x = toAccessorArray( [ 1 ] ); - y = toAccessorArray( [ 5 ] ); - - condition = toAccessorArray( [ true ] ); - actual = where( condition, x, y ); - expected = [ 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = toAccessorArray( [ false ] ); - actual = where( condition, x, y ); - expected = [ 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - y = toAccessorArray( [ 5, 6, 7, 8 ] ); - - condition = toAccessorArray( [ true, false, true, false ] ); - actual = where( condition, x, y ); - expected = [ 1, 6, 3, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = toAccessorArray( [ true, true, true, true ] ); - actual = where( condition, x, y ); - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = toAccessorArray( [ false, false, false, false ] ); - actual = where( condition, x, y ); - expected = [ 5, 6, 7, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (accessors, broadcasting)', function test( t ) { - var condition; - var expected; - var actual; - var x; - var y; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - y = toAccessorArray( [ 5, 6, 7, 8 ] ); - - condition = toAccessorArray( [ true, false, true, false ] ); - actual = where( condition, x, [ 5 ] ); - expected = [ 1, 5, 3, 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = toAccessorArray( [ true, false, true, false ] ); - actual = where( condition, [ -1 ], y ); - expected = [ -1, 6, -1, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = toAccessorArray( [ true ] ); - actual = where( condition, x, y ); - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = toAccessorArray( [ false ] ); - actual = where( condition, x, y ); - expected = [ 5, 6, 7, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = toAccessorArray( [ true ] ); - actual = where( condition, [ -1 ], y ); - expected = [ -1, -1, -1, -1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = toAccessorArray( [ false ] ); - actual = where( condition, x, [ 5 ] ); - expected = [ 5, 5, 5, 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (typed)', function test( t ) { - var condition; - var expected; - var actual; - var x; - var y; - - x = new Int32Array( [ 1 ] ); - y = new Int32Array( [ 5 ] ); - - condition = [ true ]; - actual = where( condition, x, y ); - expected = [ 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, y ); - expected = [ 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = new Int32Array( [ 5, 6, 7, 8 ] ); - - condition = [ true, false, true, false ]; - actual = where( condition, x, y ); - expected = [ 1, 6, 3, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true, true, true, true ]; - actual = where( condition, x, y ); - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false, false, false, false ]; - actual = where( condition, x, y ); - expected = [ 5, 6, 7, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (typed, broadcasting)', function test( t ) { - var condition; - var expected; - var actual; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = new Int32Array( [ 5, 6, 7, 8 ] ); - - condition = [ true, false, true, false ]; - actual = where( condition, x, [ 5 ] ); - expected = [ 1, 5, 3, 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true, false, true, false ]; - actual = where( condition, [ -1 ], y ); - expected = [ -1, 6, -1, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true ]; - actual = where( condition, x, y ); - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, y ); - expected = [ 5, 6, 7, 8 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true ]; - actual = where( condition, [ -1 ], y ); - expected = [ -1, -1, -1, -1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, [ 5 ] ); - expected = [ 5, 5, 5, 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (boolean)', function test( t ) { - var condition; - var expected; - var actual; - var x; - var y; - - x = new BooleanArray( [ true ] ); - y = new BooleanArray( [ false ] ); - - condition = [ true ]; - actual = where( condition, x, y ); - expected = [ true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, y ); - expected = [ false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ true, false, true, false ] ); - y = new BooleanArray( [ false, true, false, true ] ); - - condition = [ true, false, true, false ]; - actual = where( condition, x, y ); - expected = [ true, true, true, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true, true, true, true ]; - actual = where( condition, x, y ); - expected = [ true, false, true, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false, false, false, false ]; - actual = where( condition, x, y ); - expected = [ false, true, false, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (boolean, broadcasting)', function test( t ) { - var condition; - var expected; - var actual; - var x; - var y; - - x = new BooleanArray( [ true, false, true, false ] ); - y = new BooleanArray( [ false, true, false, true ] ); - - condition = [ true, false, true, false ]; - actual = where( condition, x, [ 5 ] ); - expected = [ true, 5, true, 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true, false, true, false ]; - actual = where( condition, [ -1 ], y ); - expected = [ -1, true, -1, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true ]; - actual = where( condition, x, y ); - expected = [ true, false, true, false ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, y ); - expected = [ false, true, false, true ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ true ]; - actual = where( condition, [ -1 ], y ); - expected = [ -1, -1, -1, -1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, [ 5 ] ); - expected = [ 5, 5, 5, 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from one of two arrays (complex)', function test( t ) { - var condition; - var expected; - var actual; - var x; - var y; - - x = new Complex64Array( [ 1.0, 2.0 ] ); - y = new Complex64Array( [ 5.0, 6.0 ] ); - - condition = [ true ]; - actual = where( condition, x, y ); - expected = [ new Complex64( 1.0, 2.0 ) ]; - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, y ); - expected = [ new Complex64( 5.0, 6.0 ) ]; - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - y = new Complex64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 ] ); - - condition = [ true, false, true, false ]; - actual = where( condition, x, y ); - expected = [ new Complex64( 1.0, 2.0 ), new Complex64( -3.0, -4.0 ), new Complex64( 5.0, 6.0 ), new Complex64( -7.0, -8.0 ) ]; - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - condition = [ true, true, true, true ]; - actual = where( condition, x, y ); - expected = [ new Complex64( 1.0, 2.0 ), new Complex64( 3.0, 4.0 ), new Complex64( 5.0, 6.0 ), new Complex64( 7.0, 8.0 ) ]; - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - condition = [ false, false, false, false ]; - actual = where( condition, x, y ); - expected = [ new Complex64( -1.0, -2.0 ), new Complex64( -3.0, -4.0 ), new Complex64( -5.0, -6.0 ), new Complex64( -7.0, -8.0 ) ]; - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function isSameComplex64Array( actual, expected ) { - var i; - - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value for element ' + i ); - } - return true; - } -}); - -tape( 'the function takes elements from one of two arrays (complex, broadcasting)', function test( t ) { - var condition; - var expected; - var actual; - var x; - var y; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - y = new Complex64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0, -8.0 ] ); - - condition = [ true, false, true, false ]; - actual = where( condition, x, new Complex64Array( [ 9.0, 10.0 ] ) ); - expected = [ new Complex64( 1.0, 2.0 ), new Complex64( 9.0, 10.0 ), new Complex64( 5.0, 6.0 ), new Complex64( 9.0, 10.0 ) ]; - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - condition = [ true, false, true, false ]; - actual = where( condition, new Complex64Array( [ -9.0, -10.0 ] ), y ); - expected = [ new Complex64( -9.0, -10.0 ), new Complex64( -3.0, -4.0 ), new Complex64( -9.0, -10.0 ), new Complex64( -7.0, -8.0 ) ]; - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - condition = [ true ]; - actual = where( condition, x, y ); - expected = [ new Complex64( 1.0, 2.0 ), new Complex64( 3.0, 4.0 ), new Complex64( 5.0, 6.0 ), new Complex64( 7.0, 8.0 ) ]; - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, y ); - expected = [ new Complex64( -1.0, -2.0 ), new Complex64( -3.0, -4.0 ), new Complex64( -5.0, -6.0 ), new Complex64( -7.0, -8.0 ) ]; - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - condition = [ true ]; - actual = where( condition, new Complex64Array( [ -9.0, -10.0 ] ), y ); - expected = [ new Complex64( -9.0, -10.0 ), new Complex64( -9.0, -10.0 ), new Complex64( -9.0, -10.0 ), new Complex64( -9.0, -10.0 ) ]; - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - condition = [ false ]; - actual = where( condition, x, new Complex64Array( [ 9.0, 10.0 ] ) ); - expected = [ new Complex64( 9.0, 10.0 ), new Complex64( 9.0, 10.0 ), new Complex64( 9.0, 10.0 ), new Complex64( 9.0, 10.0 ) ]; - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); - - function isSameComplex64Array( actual, expected ) { - var i; - - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isSameComplex64( actual[ i ], expected[ i ] ), true, 'returns expected value for element ' + i ); - } - return true; - } -}); - -tape( 'the function returns an empty array if provided a first argument which is empty', function test( t ) { - var x = [ 1, 2, 3, 4 ]; - t.deepEqual( where( [], x, x ), [], 'returns expected value' ); - t.deepEqual( where( [], [], [] ), [], 'returns expected value' ); - t.end(); -}); - -tape( 'the function throws an error if provided broadcast incompatible arguments (generic)', function test( t ) { - var values; - var i; - - values = [ - [ [ 1, 2, 3, 4 ], [ 1, 2 ], [ 1, 2, 3, 4 ] ], - [ [ 1, 2 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ] ], - [ [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2 ] ], - [ [ 1, 2, 3, 4 ], [], [ 1, 2 ] ], - [ [ 1 ], [], [ 1, 2 ] ], - [ [ 1 ], [ 1, 2 ], [] ], - [ [ 1 ], [], [ 1 ] ], - [ [ 1 ], [ 1 ], [] ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( args ) { - return function badValue() { - where.apply( null, args ); - }; - } -}); - -tape( 'the function throws an error if provided broadcast incompatible arguments (accessors)', function test( t ) { - var values; - var i; - - values = [ - [ [ 1, 2, 3, 4 ], [ 1, 2 ], [ 1, 2, 3, 4 ] ], - [ [ 1, 2 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ] ], - [ [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2 ] ], - [ [ 1, 2, 3, 4 ], [], [ 1, 2 ] ], - [ [ 1 ], [], [ 1, 2 ] ], - [ [ 1 ], [ 1, 2 ], [] ], - [ [ 1 ], [], [ 1 ] ], - [ [ 1 ], [ 1 ], [] ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( args ) { - var i; - for ( i = 0; i < args.length; i++ ) { - args[ i ] = toAccessorArray( args[ i ] ); - } - return function badValue() { - where.apply( null, args ); - }; - } -}); - -tape( 'the function throws an error if provided broadcast incompatible arguments (typed)', function test( t ) { - var values; - var i; - - values = [ - [ new Int32Array( 4 ), new Int32Array( 2 ), new Int32Array( 4 ) ], - [ new Int32Array( 2 ), new Int32Array( 4 ), new Int32Array( 4 ) ], - [ new Int32Array( 4 ), new Int32Array( 4 ), new Int32Array( 2 ) ], - [ new Int32Array( 4 ), new Int32Array( 0 ), new Int32Array( 2 ) ], - [ new Int32Array( 1 ), new Int32Array( 0 ), new Int32Array( 2 ) ], - [ new Int32Array( 1 ), new Int32Array( 2 ), new Int32Array( 0 ) ], - [ new Int32Array( 1 ), new Int32Array( 0 ), new Int32Array( 1 ) ], - [ new Int32Array( 1 ), new Int32Array( 1 ), new Int32Array( 0 ) ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( args ) { - return function badValue() { - where.apply( null, args ); - }; - } -}); - -tape( 'the function throws an error if provided broadcast incompatible arguments (boolean)', function test( t ) { - var values; - var i; - - values = [ - [ new BooleanArray( 4 ), new BooleanArray( 2 ), new BooleanArray( 4 ) ], - [ new BooleanArray( 2 ), new BooleanArray( 4 ), new BooleanArray( 4 ) ], - [ new BooleanArray( 4 ), new BooleanArray( 4 ), new BooleanArray( 2 ) ], - [ new BooleanArray( 4 ), new BooleanArray( 0 ), new BooleanArray( 2 ) ], - [ new BooleanArray( 1 ), new BooleanArray( 0 ), new BooleanArray( 2 ) ], - [ new BooleanArray( 1 ), new BooleanArray( 2 ), new BooleanArray( 0 ) ], - [ new BooleanArray( 1 ), new BooleanArray( 0 ), new BooleanArray( 1 ) ], - [ new BooleanArray( 1 ), new BooleanArray( 1 ), new BooleanArray( 0 ) ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( args ) { - return function badValue() { - where.apply( null, args ); - }; - } -}); - -tape( 'the function throws an error if provided broadcast incompatible arguments (complex)', function test( t ) { - var values; - var i; - - values = [ - [ new Complex64Array( 4 ), new Complex64Array( 2 ), new Complex64Array( 4 ) ], - [ new Complex64Array( 2 ), new Complex64Array( 4 ), new Complex64Array( 4 ) ], - [ new Complex64Array( 4 ), new Complex64Array( 4 ), new Complex64Array( 2 ) ], - [ new Complex64Array( 4 ), new Complex64Array( 0 ), new Complex64Array( 2 ) ], - [ new Complex64Array( 1 ), new Complex64Array( 0 ), new Complex64Array( 2 ) ], - [ new Complex64Array( 1 ), new Complex64Array( 2 ), new Complex64Array( 0 ) ], - [ new Complex64Array( 1 ), new Complex64Array( 0 ), new Complex64Array( 1 ) ], - [ new Complex64Array( 1 ), new Complex64Array( 1 ), new Complex64Array( 0 ) ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( args ) { - return function badValue() { - where.apply( null, args ); - }; - } -}); diff --git a/base/with/README.md b/base/with/README.md deleted file mode 100644 index ac7b68b92..000000000 --- a/base/with/README.md +++ /dev/null @@ -1,168 +0,0 @@ - - -# arrayWith - -> Return a new array with the element at the specified index replaced with a provided value. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var arrayWith = require( '@stdlib/array/base/with' ); -``` - -#### arrayWith( x, index, value ) - -Returns a new array with the element at the specified index replaced with a provided value. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = arrayWith( x, 0, 5 ); -// returns [ 5, 2, 3, 4 ] - -out = arrayWith( x, -1, 6 ); -// returns [ 1, 2, 3, 6 ] -``` - -The function accepts the following arguments: - -- **x**: an input array. -- **index**: element index. -- **value**: replacement value. - -### arrayWith.assign( x, index, value, out, stride, offset ) - -Copies elements from one array to another array and sets the element at the specified index to a provided value. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = [ 0, 0, 0, 0 ]; -var arr = arrayWith.assign( x, 0, 5, out, 1, 0 ); -// returns [ 5, 2, 3, 4 ] - -var bool = ( arr === out ); -// returns true -``` - -The function accepts the following arguments: - -- **x**: an input array. -- **index**: element index. -- **value**: replacement value. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. - -
- - - - - -
- -## Notes - -- If provided an array-like object having a `with` method, the `arrayWith` function defers execution to that method and assumes that the method has the following signature: - - ```text - x.with( index, value ) - ``` - - If provided an array-like object without a `with` method, the `arrayWith` function shallow copies input array data to a new generic array, normalizes a provided index, and sets a specified element. - -- Negative indices are resolved relative to the last array element, with the last element corresponding to `-1`. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var arrayWith = require( '@stdlib/array/base/with' ); - -// Define an array: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 5, -100, 100, opts ); - -// Define an array containing random index values: -var indices = discreteUniform( 100, -x.length, x.length-1, opts ); - -// Define an array with random values to set: -var values = discreteUniform( indices.length, -10000, 10000, opts ); - -// Randomly set elements in the input array: -var i; -for ( i = 0; i < indices.length; i++ ) { - console.log( 'x = [%s]', arrayWith( x, indices[ i ], values[ i ] ).join( ',' ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/with/benchmark/benchmark.assign.length.js b/base/with/benchmark/benchmark.assign.length.js deleted file mode 100644 index 4522ded5d..000000000 --- a/base/with/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var ones = require( './../../../base/ones' ); -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var arrayWith = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = zeros( len ); - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arrayWith.assign( x, i%len, i, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':assign:dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/with/benchmark/benchmark.length.js b/base/with/benchmark/benchmark.length.js deleted file mode 100644 index 2822cf332..000000000 --- a/base/with/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var arrayWith = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arrayWith( x, i%len, i ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/with/docs/repl.txt b/base/with/docs/repl.txt deleted file mode 100644 index 2002a5580..000000000 --- a/base/with/docs/repl.txt +++ /dev/null @@ -1,89 +0,0 @@ - -{{alias}}( x, index, value ) - Returns a new array with the element at the specified index replaced with a - provided value. - - Negative indices are resolved relative to the last array element, with the - last element corresponding to `-1`. - - If provided an array-like object having a `with` method , the function - defers execution to that method and assumes that the method has the - following signature: - - x.with( index, value ) - - If provided an array-like object without a `with` method, the function - shallow copies input array data to a new generic array, normalizes a - provided index, and sets a specified element. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - index: integer - Index of the element to be replaced. - - value: any - Replacement value. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > {{alias}}( x, 0, 5 ) - [ 5, 2, 3, 4 ] - > {{alias}}( x, -1, 6 ) - [ 1, 2, 3, 6 ] - > x - [ 1, 2, 3, 4 ] - - -{{alias}}.assign( x, index, value, out, stride, offset ) - Copies elements from one array to another array and sets the element at the - specified index to a provided value. - - Negative indices are resolved relative to the last array element, with the - last element corresponding to `-1`. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - index: integer - Index of the element to be replaced. - - value: any - Replacement value. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = [ 0, 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, 0, 5, out, 1, 0 ) - [ 5, 2, 3, 4 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/base/with/docs/types/index.d.ts b/base/with/docs/types/index.d.ts deleted file mode 100644 index ae3b511b4..000000000 --- a/base/with/docs/types/index.d.ts +++ /dev/null @@ -1,251 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealTypedArray, ComplexTypedArray, AccessorArrayLike } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; - -/** -* Interface describing `arrayWith`. -*/ -interface ArrayWith { - /** - * Returns a new array with the element at the specified index replaced with a provided value. - * - * @param x - input array - * @param index - index at which to set a provided value - * @param value - replacement value - * @returns output array - * - * @example - * var Complex128Array = require( './../../../../complex128' ); - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - * - * var out = arrayWith( x, 0, new Complex128( 7.0, 8.0 ) ); - * // returns [ 7.0, 8.0, 3.0, 4.0, 5.0, 6.0 ] - */ - ( x: T, index: number, value: ComplexLike ): T; - - /** - * Returns a new array with the element at the specified index replaced with a provided value. - * - * @param x - input array - * @param index - index at which to set a provided value - * @param value - replacement value - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = arrayWith( x, 0, 5.0 ); - * // returns [ 5.0, 2.0, 3.0 ] - */ - ( x: T, index: number, value: number ): T; // eslint-disable-line @typescript-eslint/unified-signatures - - /** - * Returns a new array with the element at the specified index replaced with a provided value. - * - * @param x - input array - * @param index - index at which to set a provided value - * @param value - replacement value - * @returns output array - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = arrayWith( x, 0, 7 ); - * // returns [ 7, 2, 3 ] - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var out = arrayWith( x, 1, 8 ); - * // returns [ 1, 8, 3, 4, 5, 6 ] - */ - ( x: Collection, index: number, value: T ): Array; - - /** - * Copies elements from one array to another array and sets the element at the specified index to a provided value. - * - * @param x - input array - * @param index - index at which to set a provided value - * @param value - replacement value - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ 1, 2, 3, 4 ]; - * - * var out = new Float64Array( [ 0, 0, 0, 0 ] ); - * var arr = arrayWith.assign( x, 0, 5, out, 1, 0 ); - * // returns [ 5, 2, 3, 4 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, index: number, value: number, out: T, stride: number, offset: number ): T; - - /** - * Copies elements from one array to another array and sets the element at the specified index to a provided value. - * - * @param x - input array - * @param index - index at which to set a provided value - * @param value - replacement value - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Complex128Array = require( './../../../../complex128' ); - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - * - * var out = new Complex128Array( x.length ); - * var arr = arrayWith.assign( x, 0, new Complex128( 7.0, 8.0 ), out, 1, 0 ); - * // returns [ 7.0, 8.0, 3.0, 4.0, 5.0, 6.0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, index: number, value: ComplexLike, out: T, stride: number, offset: number ): T; // eslint-disable-line @typescript-eslint/unified-signatures - - /** - * Copies elements from one array to another array and sets the element at the specified index to a provided value. - * - * @param x - input array - * @param index - index at which to set a provided value - * @param value - replacement value - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * var arr = arrayWith.assign( x, 0, 5, out, 1, 0 ); - * // returns [ 5, 2, 3, 4 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, index: number, value: U, out: Array, stride: number, offset: number ): Array; - - /** - * Copies elements from one array to another array and sets the element at the specified index to a provided value. - * - * @param x - input array - * @param index - index at which to set a provided value - * @param value - replacement value - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var toAccessorArray = require( './../../../../base/to-accessor-array' ); - * - * var x = toAccessorArray( [ 1, 2, 3, 4 ] ); - * - * var out = toAccessorArray( [ 0, 0, 0, 0 ] ); - * var arr = arrayWith.assign( x, 0, 5, out, 1, 0 ); - * - * var v = out[ 0 ]; - * // returns 5 - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, index: number, value: U, out: AccessorArrayLike, stride: number, offset: number ): AccessorArrayLike; - - /** - * Copies elements from one array to another array and sets the element at the specified index to a provided value. - * - * @param x - input array - * @param index - index at which to set a provided value - * @param value - replacement value - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var out = [ 0, 0, 0, 0 ]; - * var arr = arrayWith.assign( x, 0, 5, out, 1, 0 ); - * // returns [ 5, 2, 3, 4 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, index: number, value: U, out: Collection, stride: number, offset: number ): Collection; -} - -/** -* Returns a new array with the element at the specified index replaced with a provided value. -* -* @param x - input array -* @param index - index at which to set a provided value -* @param value - replacement value -* @returns output array -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = arrayWith( x, 0, 7 ); -* // returns [ 7, 2, 3 ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var out = arrayWith( x, 1, 8 ); -* // returns [ 1, 8, 3, 4, 5, 6 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = new Float64Array( [ 0, 0, 0, 0 ] ); -* var arr = arrayWith.assign( x, 0, 5, out, 1, 0 ); -* // returns [ 5, 2, 3, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var arrayWith: ArrayWith; - - -// EXPORTS // - -export = arrayWith; diff --git a/base/with/docs/types/test.ts b/base/with/docs/types/test.ts deleted file mode 100644 index 52dce4005..000000000 --- a/base/with/docs/types/test.ts +++ /dev/null @@ -1,170 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import arrayWith = require( './index' ); - - -// TESTS // - -// The function returns an updated array... -{ - arrayWith( [ 1, 2, 3, 4 ], 0, 5 ); // $ExpectType number[] - arrayWith( new Complex128Array( 5 ), 0, { 're': 1.0, 'im': 1.0 } ); // $ExpectType Complex128Array - arrayWith( new Complex64Array( 5 ), 0, { 're': 1.0, 'im': 1.0 } ); // $ExpectType Complex64Array - arrayWith( toAccessorArray( [ 1, 2, 3, 4 ] ), 0, 5 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - arrayWith( 5, 0, 5 ); // $ExpectError - arrayWith( true, 0, 5 ); // $ExpectError - arrayWith( false, 0, 5 ); // $ExpectError - arrayWith( null, 0, 5 ); // $ExpectError - arrayWith( void 0, 0, 5 ); // $ExpectError - arrayWith( {}, 0, 5 ); // $ExpectError - arrayWith( ( x: number ): number => x, 0, 5 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ 1, 2, 3, 4 ]; - - arrayWith( x, 'abc', 5 ); // $ExpectError - arrayWith( x, true, 5 ); // $ExpectError - arrayWith( x, false, 5 ); // $ExpectError - arrayWith( x, null, 5 ); // $ExpectError - arrayWith( x, void 0, 5 ); // $ExpectError - arrayWith( x, [ '1' ], 5 ); // $ExpectError - arrayWith( x, {}, 5 ); // $ExpectError - arrayWith( x, ( x: number ): number => x, 5 ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4 ]; - - arrayWith(); // $ExpectError - arrayWith( x ); // $ExpectError - arrayWith( x, 0 ); // $ExpectError - arrayWith( x, 0, 0, 5 ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 1, 2, 3, 4 ]; - const y = new Complex128Array( 4 ); - - arrayWith.assign( x, 0, 5, [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectType number[] - arrayWith.assign( x, 0, 5, new Float64Array( 4 ), 1, 0 ); // $ExpectType Float64Array - arrayWith.assign( x, 0, 5, new Float32Array( 4 ), 1, 0 ); // $ExpectType Float32Array - arrayWith.assign( x, 0, 5, new Int32Array( 4 ), 1, 0 ); // $ExpectType Int32Array - arrayWith.assign( x, 0, 5, new Int16Array( 4 ), 1, 0 ); // $ExpectType Int16Array - arrayWith.assign( x, 0, 5, new Int8Array( 4 ), 1, 0 ); // $ExpectType Int8Array - arrayWith.assign( x, 0, 5, new Uint32Array( 4 ), 1, 0 ); // $ExpectType Uint32Array - arrayWith.assign( x, 0, 5, new Uint16Array( 4 ), 1, 0 ); // $ExpectType Uint16Array - arrayWith.assign( x, 0, 5, new Uint8Array( 4 ), 1, 0 ); // $ExpectType Uint8Array - arrayWith.assign( x, 0, 5, new Uint8ClampedArray( 4 ), 1, 0 ); // $ExpectType Uint8ClampedArray - arrayWith.assign( y, 0, { 're': 1.0, 'im': 1.0 }, new Complex128Array( 4 ), 1, 0 ); // $ExpectType Complex128Array - arrayWith.assign( y, 0, { 're': 1.0, 'im': 1.0 }, new Complex64Array( 4 ), 1, 0 ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0, 0 ]; - - arrayWith.assign( 1, 0, 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( true, 0, 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( false, 0, 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( null, 0, 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( void 0, 0, 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( {}, 0, 5, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a number... -{ - const x = [ 1, 2, 3, 4 ]; - const out = [ 0, 0, 0, 0 ]; - - arrayWith.assign( x, '1', 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( x, true, 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( x, false, 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( x, null, 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( x, void 0, 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( x, [], 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( x, {}, 5, out, 1, 0 ); // $ExpectError - arrayWith.assign( x, ( x: number ): number => x, 5, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not an array-like object... -{ - const x = [ 1, 2, 3, 4 ]; - - arrayWith.assign( x, 0, 5, 1, 1, 0 ); // $ExpectError - arrayWith.assign( x, 0, 5, true, 1, 0 ); // $ExpectError - arrayWith.assign( x, 0, 5, false, 1, 0 ); // $ExpectError - arrayWith.assign( x, 0, 5, null, 1, 0 ); // $ExpectError - arrayWith.assign( x, 0, 5, void 0, 1, 0 ); // $ExpectError - arrayWith.assign( x, 0, 5, {}, 1, 0 ); // $ExpectError - arrayWith.assign( x, 0, 5, ( x: number ): number => x, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1, 2, 3, 4 ]; - const out = [ 0, 0, 0, 0 ]; - - arrayWith.assign( x, 0, 1, out, '1', 0 ); // $ExpectError - arrayWith.assign( x, 0, 1, out, true, 0 ); // $ExpectError - arrayWith.assign( x, 0, 1, out, false, 0 ); // $ExpectError - arrayWith.assign( x, 0, 1, out, null, 0 ); // $ExpectError - arrayWith.assign( x, 0, 1, out, void 0, 0 ); // $ExpectError - arrayWith.assign( x, 0, 1, out, [], 0 ); // $ExpectError - arrayWith.assign( x, 0, 1, out, {}, 0 ); // $ExpectError - arrayWith.assign( x, 0, 1, out, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... -{ - const x = [ 1, 2, 3, 4 ]; - const out = [ 0, 0, 0, 0 ]; - - arrayWith.assign( x, 0, 1, out, 1, '1' ); // $ExpectError - arrayWith.assign( x, 0, 1, out, 1, true ); // $ExpectError - arrayWith.assign( x, 0, 1, out, 1, false ); // $ExpectError - arrayWith.assign( x, 0, 1, out, 1, null ); // $ExpectError - arrayWith.assign( x, 0, 1, out, 1, void 0 ); // $ExpectError - arrayWith.assign( x, 0, 1, out, 1, [] ); // $ExpectError - arrayWith.assign( x, 0, 1, out, 1, {} ); // $ExpectError - arrayWith.assign( x, 0, 1, out, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4 ]; - const out = [ 0, 0, 0, 0 ]; - - arrayWith.assign(); // $ExpectError - arrayWith.assign( x ); // $ExpectError - arrayWith.assign( x, 0 ); // $ExpectError - arrayWith.assign( x, 0, 0, out ); // $ExpectError - arrayWith.assign( x, 0, 0, out, 1 ); // $ExpectError - arrayWith.assign( x, 0, 0, out, 1, 0, {} ); // $ExpectError -} diff --git a/base/with/examples/index.js b/base/with/examples/index.js deleted file mode 100644 index 6fa34b5f8..000000000 --- a/base/with/examples/index.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var arrayWith = require( './../lib' ); - -// Define an array: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 5, -100, 100, opts ); - -// Define an array containing random index values: -var indices = discreteUniform( 100, -x.length, x.length-1, opts ); - -// Define an array with random values to set: -var values = discreteUniform( indices.length, -10000, 10000, opts ); - -// Randomly set elements in the input array: -var i; -for ( i = 0; i < indices.length; i++ ) { - console.log( 'x = [%s]', arrayWith( x, indices[ i ], values[ i ] ).join( ',' ) ); -} diff --git a/base/with/lib/assign.js b/base/with/lib/assign.js deleted file mode 100644 index a6c335ba3..000000000 --- a/base/with/lib/assign.js +++ /dev/null @@ -1,224 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var isBooleanDataType = require( './../../../base/assert/is-boolean-data-type' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var format = require( '@stdlib/string/format' ); - - -// FUNCTIONS // - -/** -* Copies elements from one array to another array and sets the element at the specified index to a provided value. -* -* @private -* @param {Collection} x - input array -* @param {integer} index - element index -* @param {*} value - replacement value -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* var arr = indexed( x, 0, 5, out, 1, 0 ); -* // returns [ 5, 2, 3, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function indexed( x, index, value, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - out[ io ] = x[ i ]; - io += stride; - } - out[ offset+(index*stride) ] = value; - return out; -} - -/** -* Copies elements from one accessor array to another accessor array and sets the element at the specified index to a provided value. -* -* @private -* @param {Object} x - input array object -* @param {integer} index - element index -* @param {*} value - replacement value -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), 0, 5, arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 5 -*/ -function accessors( x, index, value, out, stride, offset ) { - var xdata; - var odata; - var xget; - var oset; - var io; - var i; - - xdata = x.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - oset( odata, offset+(index*stride), value ); - return odata; -} - -/** -* Copies elements from one complex array to another complex array and sets the element at the specified index to a provided value. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {integer} index - element index -* @param {ComplexLike} value - replacement value -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* var out = new Float64Array( 4 ); -* var arr = complex( x, 0, new Complex128( 5.0, 6.0 ), out, 1, 0 ); -* // returns [ 5.0, 6.0, 3.0, 4.0 ] -*/ -function complex( x, index, value, out, stride, offset ) { - var so; - var io; - var i; - var j; - - so = stride * 2; // multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < x.length/2; i++ ) { - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - io = ( offset+(index*stride) ) * 2; - out[ io ] = real( value ); - out[ io+1 ] = imag( value ); - return out; -} - - -// MAIN // - -/** -* Copies elements from one array to another array and sets the element at the specified index to a provided value. -* -* @param {Collection} x - input array -* @param {integer} index - element index -* @param {*} value - replacement value -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @throws {RangeError} second argument must not exceed array bounds -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* var arr = assign( x, 0, 5, out, 1, 0 ); -* // returns [ 5, 2, 3, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, index, value, out, stride, offset ) { - var xo; - var oo; - - index = normalizeIndex( index, x.length-1 ); - if ( index < 0 ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) ); - } - xo = arraylike2object( x ); - oo = arraylike2object( out ); - if ( xo.accessorProtocol || oo.accessorProtocol ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) && - isComplexLike( value ) - ) { - complex( reinterpret( x, 0 ), index, value, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - indexed( reinterpretBoolean( x, 0 ), index, Boolean( value ), reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, index, value, oo, stride, offset ); - return out; - } - indexed( x, index, value, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/with/lib/index.js b/base/with/lib/index.js deleted file mode 100644 index 8953ca3d4..000000000 --- a/base/with/lib/index.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -/** -* Return a new array with the element at the specified index replaced with a provided value. -* -* @module @stdlib/array/base/with -* -* @example -* var arrayWith = require( '@stdlib/array/base/with' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var v = arrayWith( x, 0, 5 ); -* // returns [ 5, 2, 3, 4 ] -* -* v = arrayWith( x, -2, -1 ); -* // returns [ 1, 2, -1, 4 ] -* -* @example -* var arrayWith = require( '@stdlib/array/base/with' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = [ 0, 0, 0, 0 ]; -* var arr = arrayWith.assign( x, 0, 5, out, 1, 0 ); -* // returns [ 5, 2, 3, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/with/lib/main.js b/base/with/lib/main.js deleted file mode 100644 index dc7591c75..000000000 --- a/base/with/lib/main.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -// MODULES // - -var slice = require( './../../../base/slice' ); -var resolveSetter = require( './../../../base/resolve-setter' ); -var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); -var format = require( '@stdlib/string/format' ); - - -// FUNCTIONS // - -/** -* Tests whether an object has a specified method. -* -* @private -* @param {Object} obj - input object -* @param {string} method - method name -* @returns {boolean} boolean indicating whether an object has a specified method -* -* @example -* var bool = hasMethod( [], 'map' ); -* // returns true -* -* @example -* var bool = hasMethod( [], 'beep' ); -* // returns false -*/ -function hasMethod( obj, method ) { - return ( typeof obj[ method ] === 'function' ); -} - - -// MAIN // - -/** -* Returns a new array with the element at the specified index replaced with a provided value. -* -* @param {Collection} x - input array -* @param {integer} index - element index -* @param {*} value - replacement value -* @throws {RangeError} second argument must not exceed array bounds -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var v = arrayWith( x, 0, 5 ); -* // returns [ 5, 2, 3, 4 ] -* -* v = arrayWith( x, 1, 6 ); -* // returns [ 1, 6, 3, 4 ] -* -* v = arrayWith( x, -2, 7 ); -* // returns [ 1, 2, 7, 4 ] -*/ -function arrayWith( x, index, value ) { - var out; - var set; - if ( hasMethod( x, 'with' ) ) { - return x.with( index, value ); - } - index = normalizeIndex( index, x.length-1 ); - if ( index < 0 ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) ); - } - out = slice( x, 0, x.length ); - set = resolveSetter( out ); - set( out, index, value ); - return out; -} - - -// EXPORTS // - -module.exports = arrayWith; diff --git a/base/with/package.json b/base/with/package.json deleted file mode 100644 index 3ac630af7..000000000 --- a/base/with/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/with", - "version": "0.0.0", - "description": "Return a new array with the element at the specified index replaced with a provided value.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "typed", - "collection", - "vector", - "with", - "set", - "setter", - "copy" - ], - "__stdlib__": {} -} diff --git a/base/with/test/test.assign.js b/base/with/test/test.assign.js deleted file mode 100644 index 4cfb81046..000000000 --- a/base/with/test/test.assign.js +++ /dev/null @@ -1,491 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int32Array = require( './../../../int32' ); -var Float64Array = require( './../../../float64' ); -var Complex128Array = require( './../../../complex128' ); -var BooleanArray = require( './../../../bool' ); -var AccessorArray = require( './../../../base/accessor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); -var zeros = require( './../../../zeros' ); -var arrayWith = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arrayWith, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (generic)', function test( t ) { - var values; - var out; - var x; - var i; - - x = [ 1, 2, 3 ]; - out = zeros( x.length, 'generic' ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, 0, out, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (float64)', function test( t ) { - var values; - var out; - var x; - var i; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = zeros( x.length, 'float64' ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, 0.0, out, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (int32)', function test( t ) { - var values; - var out; - var x; - var i; - - x = new Int32Array( [ 1, 2, 3 ] ); - out = zeros( x.length, 'int32' ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, 0, out, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (complex128)', function test( t ) { - var values; - var out; - var x; - var i; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - out = zeros( x.length, 'complex128' ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, new Complex128( 0.0, 0.0 ), out, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (accessors)', function test( t ) { - var values; - var out; - var x; - var i; - - x = new AccessorArray( [ 1, 2, 3 ] ); - out = new AccessorArray( zeros( x.length, 'generic' ) ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, 0, out, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (array-like)', function test( t ) { - var values; - var out; - var x; - var i; - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - - out = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, 0, out, 1, 0 ); - }; - } -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (generic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ 1, 2, 3 ]; - - out = zeros( x.length, 'generic' ); - expected = [ 5, 2, 3 ]; - actual = arrayWith( x, 0, 5, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( x.length*2, 'generic' ); - expected = [ 1, 0, 5, 0, 3, 0 ]; - actual = arrayWith( x, 1, 5, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( x.length*2, 'generic' ); - expected = [ 0, 5, 0, 2, 0, 1 ]; - actual = arrayWith( x, 2, 5, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (float64)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - - out = zeros( x.length, 'float64' ); - expected = new Float64Array( [ 5.0, 2.0, 3.0 ] ); - actual = arrayWith( x, 0, 5.0, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( x.length*2, 'float64' ); - expected = new Float64Array( [ 1.0, 0.0, 5.0, 0.0, 3.0, 0.0 ] ); - actual = arrayWith( x, 1, 5.0, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( x.length*2, 'float64' ); - expected = new Float64Array( [ 0.0, 5.0, 0.0, 2.0, 0.0, 1.0 ] ); - actual = arrayWith( x, 2, 5.0, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (int32)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - - out = zeros( x.length, 'int32' ); - expected = new Int32Array( [ 5, 2, 3 ] ); - actual = arrayWith( x, 0, 5, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( x.length*2, 'int32' ); - expected = new Int32Array( [ 1, 0, 5, 0, 3, 0 ] ); - actual = arrayWith( x, 1, 5, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( x.length*2, 'int32' ); - expected = new Int32Array( [ 0, 5, 0, 2, 0, 1 ] ); - actual = arrayWith( x, 2, 5, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (complex128)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - out = zeros( x.length, 'complex128' ); - expected = new Complex128Array( [ 7.0, 8.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = arrayWith( x, 0, new Complex128( 7.0, 8.0 ), out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - out = zeros( x.length*2, 'complex128' ); - expected = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 5.0, 6.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - actual = arrayWith( x, 1, new Complex128( 7.0, 8.0 ), out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - out = zeros( x.length*2, 'complex128' ); - expected = new Complex128Array( [ 0.0, 0.0, 7.0, 8.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 1.0, 2.0 ] ); // eslint-disable-line max-len - actual = arrayWith( x, 2, new Complex128( 7.0, 8.0 ), out, -2, out.length-1 ); // eslint-disable-line max-len - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (bool)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = new BooleanArray( [ 0, 0, 1, 1 ] ); - - out = new BooleanArray( x.length ); - expected = new BooleanArray( [ 1, 0, 1, 1 ] ); - actual = arrayWith( x, 0, true, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - out = new BooleanArray( x.length*2 ); - expected = new BooleanArray( [ 0, 0, 1, 0, 1, 0, 1, 0 ] ); - actual = arrayWith( x, 1, true, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - out = new BooleanArray( x.length*2 ); - expected = new BooleanArray( [ 0, 1, 0, 0, 0, 0, 0, 0 ] ); - actual = arrayWith( x, 2, false, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (accessors)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = new AccessorArray( [ 1, 2, 3 ] ); - - out = new AccessorArray( zeros( x.length, 'generic' ) ); - expected = [ 5, 2, 3 ]; - actual = arrayWith( x, 0, 5, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = new AccessorArray( zeros( x.length*2, 'generic' ) ); - expected = [ 1, 0, 5, 0, 3, 0 ]; - actual = arrayWith( x, 1, 5, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = new AccessorArray( zeros( x.length*2, 'generic' ) ); - expected = [ 0, 5, 0, 2, 0, 1 ]; - actual = arrayWith( x, 2, 5, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (array-like)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - - out = { - 'length': 3, - '0': 0, - '1': 0, - '2': 0 - }; - expected = [ 5, 2, 3 ]; - actual = arrayWith( x, 0, 5, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = { - 'length': 6, - '0': 0, - '1': 0, - '2': 0, - '3': 0, - '4': 0, - '5': 0 - }; - expected = [ 1, 0, 5, 0, 3, 0 ]; - actual = arrayWith( x, 1, 5, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = { - 'length': 6, - '0': 0, - '1': 0, - '2': 0, - '3': 0, - '4': 0, - '5': 0 - }; - expected = [ 0, 5, 0, 2, 0, 1 ]; - actual = arrayWith( x, 2, 5, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - } -}); diff --git a/base/with/test/test.js b/base/with/test/test.js deleted file mode 100644 index 3d03f52f0..000000000 --- a/base/with/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var arrayWith = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arrayWith, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( arrayWith, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( arrayWith, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/with/test/test.main.js b/base/with/test/test.main.js deleted file mode 100644 index 08048378c..000000000 --- a/base/with/test/test.main.js +++ /dev/null @@ -1,401 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int32Array = require( './../../../int32' ); -var Float64Array = require( './../../../float64' ); -var Complex128Array = require( './../../../complex128' ); -var AccessorArray = require( './../../../base/accessor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var arrayWith = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arrayWith, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (generic)', function test( t ) { - var values; - var x; - var i; - - x = [ 1, 2, 3 ]; - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (float64)', function test( t ) { - var values; - var x; - var i; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, 0.0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (int32)', function test( t ) { - var values; - var x; - var i; - - x = new Int32Array( [ 1, 2, 3 ] ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (complex128)', function test( t ) { - var values; - var x; - var i; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, new Complex128( 0.0, 0.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (accessors)', function test( t ) { - var values; - var x; - var i; - - x = new AccessorArray( [ 1, 2, 3 ] ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (array-like)', function test( t ) { - var values; - var x; - var i; - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayWith( x, value, 0 ); - }; - } -}); - -tape( 'the function returns a new array with an element at a specified index containing a provided value (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - - expected = [ 5, 2, 3 ]; - actual = arrayWith( x, 0, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 3 ]; - actual = arrayWith( x, 1, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5 ]; - actual = arrayWith( x, 2, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a new array with an element at a specified index containing a provided value (float64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - - expected = [ 5.0, 2.0, 3.0 ]; - actual = arrayWith( x, 0, 5.0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1.0, 5.0, 3.0 ]; - actual = arrayWith( x, 1, 5.0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1.0, 2.0, 5.0 ]; - actual = arrayWith( x, 2, 5.0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a new array with an element at a specified index containing a provided value (int32)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - - expected = new Int32Array( [ 5, 2, 3 ] ); - actual = arrayWith( x, 0, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1, 5, 3 ] ); - actual = arrayWith( x, 1, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1, 2, 5 ] ); - actual = arrayWith( x, 2, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a new array with an element at a specified index containing a provided value (complex128)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - expected = new Complex128Array( [ 7.0, 8.0, 3.0, 4.0, 5.0, 6.0 ] ); - actual = arrayWith( x, 0, new Complex128( 7.0, 8.0 ) ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - expected = new Complex128Array( [ 1.0, 2.0, 7.0, 8.0, 5.0, 6.0 ] ); - actual = arrayWith( x, 1, new Complex128( 7.0, 8.0 ) ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - expected = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 7.0, 8.0 ] ); - actual = arrayWith( x, 2, new Complex128( 7.0, 8.0 ) ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a new array with an element at a specified index containing a provided value (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = new AccessorArray( [ 1, 2, 3 ] ); - - expected = [ 5, 2, 3 ]; - actual = arrayWith( x, 0, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 3 ]; - actual = arrayWith( x, 1, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5 ]; - actual = arrayWith( x, 2, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a new array with an element at a specified index containing a provided value (array-like)', function test( t ) { - var expected; - var actual; - var x; - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - - expected = [ 5, 2, 3 ]; - actual = arrayWith( x, 0, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 5, 3 ]; - actual = arrayWith( x, 1, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 5 ]; - actual = arrayWith( x, 2, 5 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/without/README.md b/base/without/README.md deleted file mode 100644 index 634900d05..000000000 --- a/base/without/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# without - -> Return a new array containing every element from an input array, except for the element at a specified index. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var without = require( '@stdlib/array/base/without' ); -``` - -#### without( x, index ) - -Returns a new array containing every element from an input array, except for the element at a specified index. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = without( x, 0 ); -// returns [ 2, 3, 4 ] - -out = without( x, -1 ); -// returns [ 1, 2, 3 ] -``` - -The function accepts the following arguments: - -- **x**: an input array. -- **index**: element index. - -### without.assign( x, index, out, stride, offset ) - -Copies every element from one array to another array, except for the element at a specified index. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = [ 0, 0, 0 ]; -var arr = without.assign( x, 0, out, 1, 0 ); -// returns [ 2, 3, 4 ] - -var bool = ( arr === out ); -// returns true -``` - -The function accepts the following arguments: - -- **x**: an input array. -- **index**: element index. -- **out**: output array. -- **stride**: output array stride. -- **offset**: output array offset. - -
- - - - - -
- -## Notes - -- Negative indices are resolved relative to the last array element, with the last element corresponding to `-1`. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var without = require( '@stdlib/array/base/without' ); - -// Define an array: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 5, -100, 100, opts ); - -// Define an array containing random index values: -var indices = discreteUniform( 100, -x.length, x.length-1, opts ); - -// Randomly omit elements from the input array: -var i; -for ( i = 0; i < indices.length; i++ ) { - console.log( 'x = [%s]', without( x, indices[ i ] ).join( ',' ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/without/benchmark/benchmark.assign.length.js b/base/without/benchmark/benchmark.assign.length.js deleted file mode 100644 index ad7cf999a..000000000 --- a/base/without/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var ones = require( './../../../base/ones' ); -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var without = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = zeros( len+1 ); - var x = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = without.assign( x, i%len, out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':assign:dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/without/benchmark/benchmark.length.js b/base/without/benchmark/benchmark.length.js deleted file mode 100644 index b339f6951..000000000 --- a/base/without/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var ones = require( './../../../base/ones' ); -var pkg = require( './../package.json' ).name; -var without = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len+1 ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = without( x, i%len, i ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/base/without/docs/repl.txt b/base/without/docs/repl.txt deleted file mode 100644 index 736079776..000000000 --- a/base/without/docs/repl.txt +++ /dev/null @@ -1,73 +0,0 @@ - -{{alias}}( x, index ) - Returns a new array containing every element from an input array, except for - the element at a specified index. - - Negative indices are resolved relative to the last array element, with the - last element corresponding to `-1`. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - index: integer - Index of the element to be omitted. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > {{alias}}( x, 0 ) - [ 2, 3, 4 ] - > {{alias}}( x, -1 ) - [ 1, 2, 3 ] - > x - [ 1, 2, 3, 4 ] - - -{{alias}}.assign( x, index, out, stride, offset ) - Copies every element from one array to another array, except for the element - at a specified index. - - Negative indices are resolved relative to the last array element, with the - last element corresponding to `-1`. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - index: integer - Index of the element to be omitted. - - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array offset. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = [ 0, 0, 0 ]; - > var arr = {{alias}}.assign( x, 0, out, 1, 0 ) - [ 2, 3, 4 ] - > var bool = ( arr === out ) - true - - See Also - -------- - diff --git a/base/without/docs/types/index.d.ts b/base/without/docs/types/index.d.ts deleted file mode 100644 index e251ec9a0..000000000 --- a/base/without/docs/types/index.d.ts +++ /dev/null @@ -1,218 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealTypedArray, ComplexTypedArray, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Interface describing `without`. -*/ -interface ArrayWith { - /** - * Returns a new array containing every element from an input array, except for the element at a specified index. - * - * @param x - input array - * @param index - index of the element to exclude - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - * - * var out = without( x, 0 ); - * // returns [ 2.0, 3.0 ] - * - * @example - * var Complex128Array = require( './../../../../complex128' ); - * - * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - * - * var out = without( x, 0 ); - * // returns [ 3.0, 4.0, 5.0, 6.0 ] - */ - ( x: T, index: number ): T; - - /** - * Returns a new array containing every element from an input array, except for the element at a specified index. - * - * @param x - input array - * @param index - index of the element to exclude - * @returns output array - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = without( x, 0 ); - * // returns [ 2, 3 ] - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var out = without( x, 1 ); - * // returns [ 1, 3, 4, 5, 6 ] - */ - ( x: Collection, index: number ): Array; - - /** - * Copies every element from one array to another array, except for the element at a specified index. - * - * @param x - input array - * @param index - index of the element to exclude - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var x = [ 1, 2, 3, 4 ]; - * - * var out = new Float64Array( [ 0, 0, 0 ] ); - * var arr = without.assign( x, 0, out, 1, 0 ); - * // returns [ 2, 3, 4 ] - * - * var bool = ( arr === out ); - * // returns true - * - * @example - * var Complex128Array = require( './../../../../complex128' ); - * - * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - * - * var out = new Complex128Array( x.length-1 ); - * var arr = without.assign( x, 0, out, 1, 0 ); - * // returns [ 3.0, 4.0, 5.0, 6.0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, index: number, out: T, stride: number, offset: number ): T; - - /** - * Copies every element from one array to another array, except for the element at a specified index. - * - * @param x - input array - * @param index - index of the element to exclude - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var out = [ 0, 0, 0 ]; - * var arr = without.assign( x, 0, out, 1, 0 ); - * // returns [ 2, 3, 4 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, index: number, out: Array, stride: number, offset: number ): Array; - - /** - * Copies every element from one array to another array, except for the element at a specified index. - * - * @param x - input array - * @param index - index of the element to exclude - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var toAccessorArray = require( './../../../../base/to-accessor-array' ); - * - * var x = toAccessorArray( [ 1, 2, 3, 4 ] ); - * - * var out = toAccessorArray( [ 0, 0, 0 ] ); - * var arr = without.assign( x, 0, out, 1, 0 ); - * - * var v = out[ 0 ]; - * // returns 2 - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, index: number, out: AccessorArrayLike, stride: number, offset: number ): AccessorArrayLike; - - /** - * Copies every element from one array to another array, except for the element at a specified index. - * - * @param x - input array - * @param index - index of the element to exclude - * @param out - output array - * @param stride - output array stride - * @param offset - output array offset - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var out = [ 0, 0, 0 ]; - * var arr = without.assign( x, 0, out, 1, 0 ); - * // returns [ 2, 3, 4 ] - * - * var bool = ( arr === out ); - * // returns true - */ - assign( x: Collection | AccessorArrayLike, index: number, out: Collection, stride: number, offset: number ): Collection; -} - -/** -* Returns a new array containing every element from an input array, except for the element at a specified index. -* -* @param x - input array -* @param index - index of the element to exclude -* @returns output array -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = without( x, 0 ); -* // returns [ 2, 3 ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var out = without( x, 1 ); -* // returns [ 1, 3, 4, 5, 6 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = new Float64Array( [ 0, 0, 0 ] ); -* var arr = without.assign( x, 0, out, 1, 0 ); -* // returns [ 2, 3, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var without: ArrayWith; - - -// EXPORTS // - -export = without; diff --git a/base/without/docs/types/test.ts b/base/without/docs/types/test.ts deleted file mode 100644 index 66989a70c..000000000 --- a/base/without/docs/types/test.ts +++ /dev/null @@ -1,169 +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. -*/ - -import Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import toAccessorArray = require( './../../../../base/to-accessor-array' ); -import without = require( './index' ); - - -// TESTS // - -// The function returns an updated array... -{ - without( [ 1, 2, 3, 4 ], 0 ); // $ExpectType number[] - without( new Complex128Array( 5 ), 0 ); // $ExpectType Complex128Array - without( new Complex64Array( 5 ), 0 ); // $ExpectType Complex64Array - without( toAccessorArray( [ 1, 2, 3, 4 ] ), 0 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - without( 5, 0 ); // $ExpectError - without( true, 0 ); // $ExpectError - without( false, 0 ); // $ExpectError - without( null, 0 ); // $ExpectError - without( void 0, 0 ); // $ExpectError - without( {}, 0 ); // $ExpectError - without( ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ 1, 2, 3, 4 ]; - - without( x, 'abc' ); // $ExpectError - without( x, true ); // $ExpectError - without( x, false ); // $ExpectError - without( x, null ); // $ExpectError - without( x, void 0 ); // $ExpectError - without( x, [ '1' ] ); // $ExpectError - without( x, {} ); // $ExpectError - without( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4 ]; - - without(); // $ExpectError - without( x ); // $ExpectError - without( x, 0, 0 ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - const x = [ 1, 2, 3, 4 ]; - const y = new Complex128Array( 4 ); - - without.assign( x, 0, [ 0, 0, 0 ], 1, 0 ); // $ExpectType number[] - without.assign( x, 0, new Float64Array( 3 ), 1, 0 ); // $ExpectType Float64Array - without.assign( x, 0, new Float32Array( 3 ), 1, 0 ); // $ExpectType Float32Array - without.assign( x, 0, new Int32Array( 3 ), 1, 0 ); // $ExpectType Int32Array - without.assign( x, 0, new Int16Array( 3 ), 1, 0 ); // $ExpectType Int16Array - without.assign( x, 0, new Int8Array( 3 ), 1, 0 ); // $ExpectType Int8Array - without.assign( x, 0, new Uint32Array( 3 ), 1, 0 ); // $ExpectType Uint32Array - without.assign( x, 0, new Uint16Array( 3 ), 1, 0 ); // $ExpectType Uint16Array - without.assign( x, 0, new Uint8Array( 3 ), 1, 0 ); // $ExpectType Uint8Array - without.assign( x, 0, new Uint8ClampedArray( 3 ), 1, 0 ); // $ExpectType Uint8ClampedArray - without.assign( y, 0, new Complex128Array( 3 ), 1, 0 ); // $ExpectType Complex128Array - without.assign( y, 0, new Complex64Array( 3 ), 1, 0 ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - const out = [ 0, 0, 0 ]; - - without.assign( 1, 0, out, 1, 0 ); // $ExpectError - without.assign( true, 0, out, 1, 0 ); // $ExpectError - without.assign( false, 0, out, 1, 0 ); // $ExpectError - without.assign( null, 0, out, 1, 0 ); // $ExpectError - without.assign( void 0, 0, out, 1, 0 ); // $ExpectError - without.assign( {}, 0, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a number... -{ - const x = [ 1, 2, 3, 4 ]; - const out = [ 0, 0, 0 ]; - - without.assign( x, '1', out, 1, 0 ); // $ExpectError - without.assign( x, true, out, 1, 0 ); // $ExpectError - without.assign( x, false, out, 1, 0 ); // $ExpectError - without.assign( x, null, out, 1, 0 ); // $ExpectError - without.assign( x, void 0, out, 1, 0 ); // $ExpectError - without.assign( x, [], out, 1, 0 ); // $ExpectError - without.assign( x, {}, out, 1, 0 ); // $ExpectError - without.assign( x, ( x: number ): number => x, out, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array-like object... -{ - const x = [ 1, 2, 3, 4 ]; - - without.assign( x, 0, 1, 1, 0 ); // $ExpectError - without.assign( x, 0, true, 1, 0 ); // $ExpectError - without.assign( x, 0, false, 1, 0 ); // $ExpectError - without.assign( x, 0, null, 1, 0 ); // $ExpectError - without.assign( x, 0, void 0, 1, 0 ); // $ExpectError - without.assign( x, 0, {}, 1, 0 ); // $ExpectError - without.assign( x, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... -{ - const x = [ 1, 2, 3, 4 ]; - const out = [ 0, 0, 0 ]; - - without.assign( x, 0, out, '1', 0 ); // $ExpectError - without.assign( x, 0, out, true, 0 ); // $ExpectError - without.assign( x, 0, out, false, 0 ); // $ExpectError - without.assign( x, 0, out, null, 0 ); // $ExpectError - without.assign( x, 0, out, void 0, 0 ); // $ExpectError - without.assign( x, 0, out, [], 0 ); // $ExpectError - without.assign( x, 0, out, {}, 0 ); // $ExpectError - without.assign( x, 0, out, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fifth argument which is not a number... -{ - const x = [ 1, 2, 3, 4 ]; - const out = [ 0, 0, 0 ]; - - without.assign( x, 0, out, 1, '1' ); // $ExpectError - without.assign( x, 0, out, 1, true ); // $ExpectError - without.assign( x, 0, out, 1, false ); // $ExpectError - without.assign( x, 0, out, 1, null ); // $ExpectError - without.assign( x, 0, out, 1, void 0 ); // $ExpectError - without.assign( x, 0, out, 1, [] ); // $ExpectError - without.assign( x, 0, out, 1, {} ); // $ExpectError - without.assign( x, 0, out, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4 ]; - const out = [ 0, 0, 0 ]; - - without.assign(); // $ExpectError - without.assign( x ); // $ExpectError - without.assign( x, 0 ); // $ExpectError - without.assign( x, 0, out ); // $ExpectError - without.assign( x, 0, out, 1 ); // $ExpectError - without.assign( x, 0, out, 1, 0, {} ); // $ExpectError -} diff --git a/base/without/examples/index.js b/base/without/examples/index.js deleted file mode 100644 index 748574525..000000000 --- a/base/without/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var without = require( './../lib' ); - -// Define an array: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 5, -100, 100, opts ); - -// Define an array containing random index values: -var indices = discreteUniform( 100, -x.length, x.length-1, opts ); - -// Randomly omit elements from the input array: -var i; -for ( i = 0; i < indices.length; i++ ) { - console.log( 'x = [%s]', without( x, indices[ i ] ).join( ',' ) ); -} diff --git a/base/without/lib/assign.js b/base/without/lib/assign.js deleted file mode 100644 index 4eef0febb..000000000 --- a/base/without/lib/assign.js +++ /dev/null @@ -1,219 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../../base/assert/is-complex-floating-point-data-type' ); -var isBooleanDataType = require( './../../../base/assert/is-boolean-data-type' ); -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); -var format = require( '@stdlib/string/format' ); - - -// FUNCTIONS // - -/** -* Copies every element from one array to another array, except for the element at a specified index. -* -* @private -* @param {Collection} x - input array -* @param {integer} index - element index -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = [ 0, 0, 0 ]; -* var arr = indexed( x, 0, out, 1, 0 ); -* // returns [ 2, 3, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function indexed( x, index, out, stride, offset ) { - var io; - var i; - - io = offset; - for ( i = 0; i < x.length; i++ ) { - if ( i === index ) { - continue; - } - out[ io ] = x[ i ]; - io += stride; - } - return out; -} - -/** -* Copies every element from one accessor array to another accessor array, except for the element at a specified index. -* -* @private -* @param {Object} x - input array object -* @param {integer} index - element index -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var out = toAccessorArray( [ 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( x ), 0, arraylike2object( out ), 1, 0 ); -* -* var v = arr.get( 0 ); -* // returns 2 -*/ -function accessors( x, index, out, stride, offset ) { - var xdata; - var odata; - var xget; - var oset; - var io; - var i; - - xdata = x.data; - odata = out.data; - - xget = x.accessors[ 0 ]; - oset = out.accessors[ 1 ]; - - io = offset; - for ( i = 0; i < xdata.length; i++ ) { - if ( i === index ) { - continue; - } - oset( odata, io, xget( xdata, i ) ); - io += stride; - } - return odata; -} - -/** -* Copies every element from one complex array to another complex array, except for the element at a specified index. -* -* @private -* @param {Collection} x - real-valued floating-point input array view -* @param {integer} index - element index -* @param {Collection} out - real-valued floating-point output array view -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @returns {Collection} output array view -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* -* var out = new Float64Array( 2 ); -* var arr = complex( x, 0, out, 1, 0 ); -* // returns [ 3.0, 4.0 ] -*/ -function complex( x, index, out, stride, offset ) { - var so; - var io; - var i; - var j; - - so = stride * 2; // multiply by 2, as real-valued array consists of interleaved real and imaginary components - io = offset * 2; - for ( i = 0; i < x.length/2; i++ ) { - if ( i === index ) { - continue; - } - j = i * 2; - out[ io ] = x[ j ]; - out[ io+1 ] = x[ j+1 ]; - io += so; - } - return out; -} - - -// MAIN // - -/** -* Copies every element from one array to another array, except for the element at a specified index. -* -* @param {Collection} x - input array -* @param {integer} index - element index -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array offset -* @throws {RangeError} second argument must not exceed array bounds -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = [ 0, 0, 0 ]; -* var arr = assign( x, 0, out, 1, 0 ); -* // returns [ 2, 3, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -function assign( x, index, out, stride, offset ) { - var xo; - var oo; - - index = normalizeIndex( index, x.length-1 ); - if ( index < 0 ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) ); - } - xo = arraylike2object( x ); - oo = arraylike2object( out ); - if ( xo.accessorProtocol || oo.accessorProtocol ) { - // Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland... - if ( - isComplexDataType( xo.dtype ) && - isComplexDataType( oo.dtype ) - ) { - complex( reinterpret( x, 0 ), index, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - if ( - isBooleanDataType( xo.dtype ) && - isBooleanDataType( oo.dtype ) - ) { - indexed( reinterpretBoolean( x, 0 ), index, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len - return out; - } - accessors( xo, index, oo, stride, offset ); - return out; - } - indexed( x, index, out, stride, offset ); - return out; -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/without/lib/index.js b/base/without/lib/index.js deleted file mode 100644 index e08a39078..000000000 --- a/base/without/lib/index.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -/** -* Return a new array containing every element from an input array, except for the element at a specified index. -* -* @module @stdlib/array/base/without -* -* @example -* var without = require( '@stdlib/array/base/without' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var v = without( x, 0 ); -* // returns [ 2, 3, 4 ] -* -* v = without( x, -2 ); -* // returns [ 1, 2, 4 ] -* -* @example -* var without = require( '@stdlib/array/base/without' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = [ 0, 0, 0 ]; -* var arr = without.assign( x, 0, out, 1, 0 ); -* // returns [ 2, 3, 4 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/without/lib/main.js b/base/without/lib/main.js deleted file mode 100644 index 7fe974547..000000000 --- a/base/without/lib/main.js +++ /dev/null @@ -1,67 +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. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); -var zeros = require( './../../../zeros' ); -var dtype = require( './../../../dtype' ); -var format = require( '@stdlib/string/format' ); -var assign = require( './assign.js' ); - - -// MAIN // - -/** -* Returns a new array containing every element from an input array, except for the element at a specified index. -* -* @param {Collection} x - input array -* @param {integer} index - element index -* @throws {RangeError} second argument must not exceed array bounds -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var v = without( x, 0 ); -* // returns [ 2, 3, 4 ] -* -* v = without( x, 1 ); -* // returns [ 1, 3, 4 ] -* -* v = without( x, -2 ); -* // returns [ 1, 2, 4 ] -*/ -function without( x, index ) { - var out; - - index = normalizeIndex( index, x.length-1 ); - if ( index < 0 ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) ); - } - out = zeros( x.length-1, dtype( x ) || 'generic' ); - assign( x, index, out, 1, 0 ); - return out; -} - - -// EXPORTS // - -module.exports = without; diff --git a/base/without/package.json b/base/without/package.json deleted file mode 100644 index 563b0d9d5..000000000 --- a/base/without/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/without", - "version": "0.0.0", - "description": "Return a new array containing every element from an input array, except for the element at a specified index.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "base", - "array", - "typed", - "collection", - "vector", - "omit", - "exclude", - "skip", - "copy" - ], - "__stdlib__": {} -} diff --git a/base/without/test/test.assign.js b/base/without/test/test.assign.js deleted file mode 100644 index 384e86693..000000000 --- a/base/without/test/test.assign.js +++ /dev/null @@ -1,484 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int32Array = require( './../../../int32' ); -var Float64Array = require( './../../../float64' ); -var Complex128Array = require( './../../../complex128' ); -var BooleanArray = require( './../../../bool' ); -var AccessorArray = require( './../../../base/accessor' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isEqualBooleanArray = require( '@stdlib/assert/is-equal-booleanarray' ); -var zeros = require( './../../../zeros' ); -var without = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof without, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (generic)', function test( t ) { - var values; - var out; - var x; - var i; - - x = [ 1, 2, 3 ]; - out = zeros( x.length-1, 'generic' ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value, out, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (float64)', function test( t ) { - var values; - var out; - var x; - var i; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = zeros( x.length-1, 'float64' ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value, out, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (int32)', function test( t ) { - var values; - var out; - var x; - var i; - - x = new Int32Array( [ 1, 2, 3 ] ); - out = zeros( x.length-1, 'int32' ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value, out, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (complex128)', function test( t ) { - var values; - var out; - var x; - var i; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - out = zeros( x.length-1, 'complex128' ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value, out, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (accessors)', function test( t ) { - var values; - var out; - var x; - var i; - - x = new AccessorArray( [ 1, 2, 3 ] ); - out = new AccessorArray( zeros( x.length-1, 'generic' ) ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value, out, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (array-like)', function test( t ) { - var values; - var out; - var x; - var i; - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - - out = { - 'length': 2, - '0': 0, - '1': 0 - }; - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value, out, 1, 0 ); - }; - } -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (generic)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = [ 1, 2, 3 ]; - - out = zeros( x.length-1, 'generic' ); - expected = [ 2, 3 ]; - actual = without( x, 0, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( (x.length-1)*2, 'generic' ); - expected = [ 1, 0, 3, 0 ]; - actual = without( x, 1, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( (x.length-1)*2, 'generic' ); - expected = [ 0, 2, 0, 1 ]; - actual = without( x, 2, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (float64)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - - out = zeros( x.length-1, 'float64' ); - expected = new Float64Array( [ 2.0, 3.0 ] ); - actual = without( x, 0, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( (x.length-1)*2, 'float64' ); - expected = new Float64Array( [ 1.0, 0.0, 3.0, 0.0 ] ); - actual = without( x, 1, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( (x.length-1)*2, 'float64' ); - expected = new Float64Array( [ 0.0, 2.0, 0.0, 1.0 ] ); - actual = without( x, 2, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (int32)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - - out = zeros( x.length-1, 'int32' ); - expected = new Int32Array( [ 2, 3 ] ); - actual = without( x, 0, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( (x.length-1)*2, 'int32' ); - expected = new Int32Array( [ 1, 0, 3, 0 ] ); - actual = without( x, 1, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( (x.length-1)*2, 'int32' ); - expected = new Int32Array( [ 0, 2, 0, 1 ] ); - actual = without( x, 2, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (complex128)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - out = zeros( x.length-1, 'complex128' ); - expected = new Complex128Array( [ 3.0, 4.0, 5.0, 6.0 ] ); - actual = without( x, 0, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - out = zeros( (x.length-1)*2, 'complex128' ); - expected = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - actual = without( x, 1, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - out = zeros( (x.length-1)*2, 'complex128' ); - expected = new Complex128Array( [ 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 1.0, 2.0 ] ); // eslint-disable-line max-len - actual = without( x, 2, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (bool)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = new BooleanArray( [ 1, 1, 1, 1 ] ); - - out = new BooleanArray( x.length-1 ); - expected = new BooleanArray( [ 1, 1, 1 ] ); - actual = without( x, 0, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - out = new BooleanArray( (x.length-1)*2 ); - expected = new BooleanArray( [ 1, 0, 1, 0, 1, 0 ] ); - actual = without( x, 1, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - out = new BooleanArray( (x.length-1)*2 ); - expected = new BooleanArray( [ 0, 1, 0, 1, 0, 1 ] ); - actual = without( x, 2, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (accessors)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = new AccessorArray( [ 1, 2, 3 ] ); - - out = new AccessorArray( zeros( x.length-1, 'generic' ) ); - expected = [ 2, 3 ]; - actual = without( x, 0, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = new AccessorArray( zeros( (x.length-1)*2, 'generic' ) ); - expected = [ 1, 0, 3, 0 ]; - actual = without( x, 1, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = new AccessorArray( zeros( (x.length-1)*2, 'generic' ) ); - expected = [ 0, 2, 0, 1 ]; - actual = without( x, 2, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function copies elements to another array and sets an element at a specified index to a provided value (array-like)', function test( t ) { - var expected; - var actual; - var out; - var x; - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - - out = { - 'length': 2, - '0': 0, - '1': 0 - }; - expected = [ 2, 3 ]; - actual = without( x, 0, out, 1, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - expected = [ 1, 0, 3, 0 ]; - actual = without( x, 1, out, 2, 0 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - expected = [ 0, 2, 0, 1 ]; - actual = without( x, 2, out, -2, out.length-1 ); - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } - } -}); diff --git a/base/without/test/test.js b/base/without/test/test.js deleted file mode 100644 index e87361746..000000000 --- a/base/without/test/test.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasMethod = require( '@stdlib/assert/is-method' ); -var without = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof without, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( without, 'assign' ), true, 'returns expected value' ); - t.strictEqual( hasMethod( without, 'assign' ), true, 'returns expected value' ); - t.end(); -}); diff --git a/base/without/test/test.main.js b/base/without/test/test.main.js deleted file mode 100644 index 6b760707b..000000000 --- a/base/without/test/test.main.js +++ /dev/null @@ -1,400 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int32Array = require( './../../../int32' ); -var Float64Array = require( './../../../float64' ); -var Complex128Array = require( './../../../complex128' ); -var AccessorArray = require( './../../../base/accessor' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var without = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof without, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (generic)', function test( t ) { - var values; - var x; - var i; - - x = [ 1, 2, 3 ]; - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (float64)', function test( t ) { - var values; - var x; - var i; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (int32)', function test( t ) { - var values; - var x; - var i; - - x = new Int32Array( [ 1, 2, 3 ] ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (complex128)', function test( t ) { - var values; - var x; - var i; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (accessors)', function test( t ) { - var values; - var x; - var i; - - x = new AccessorArray( [ 1, 2, 3 ] ); - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is out-of-bounds (array-like)', function test( t ) { - var values; - var x; - var i; - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - - values = [ - 10, - 100, - 1000, - -10, - -100, - -1000 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - without( x, value ); - }; - } -}); - -tape( 'the function returns a new array containing every element in an input array, except for an element at a specified index (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - - expected = [ 2, 3 ]; - actual = without( x, 0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 3 ]; - actual = without( x, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = without( x, 2 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a new array containing every element in an input array, except for an element at a specified index (float64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - - expected = [ 2.0, 3.0 ]; - actual = without( x, 0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1.0, 3.0 ]; - actual = without( x, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1.0, 2.0 ]; - actual = without( x, 2 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a new array containing every element in an input array, except for an element at a specified index (int32)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - - expected = new Int32Array( [ 2, 3 ] ); - actual = without( x, 0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1, 3 ] ); - actual = without( x, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1, 2 ] ); - actual = without( x, 2 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a new array containing every element in an input array, except for an element at a specified index (complex128)', function test( t ) { - var expected; - var actual; - var x; - - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - expected = new Complex128Array( [ 3.0, 4.0, 5.0, 6.0 ] ); - actual = without( x, 0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - expected = new Complex128Array( [ 1.0, 2.0, 5.0, 6.0 ] ); - actual = without( x, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - expected = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - actual = without( x, 2 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a new array containing every element in an input array, except for an element at a specified index (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = new AccessorArray( [ 1, 2, 3 ] ); - - expected = [ 2, 3 ]; - actual = without( x, 0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 3 ]; - actual = without( x, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = without( x, 2 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a new array containing every element in an input array, except for an element at a specified index (array-like)', function test( t ) { - var expected; - var actual; - var x; - - x = { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }; - - expected = [ 2, 3 ]; - actual = without( x, 0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 3 ]; - actual = without( x, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = without( x, 2 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/zero-to/README.md b/base/zero-to/README.md deleted file mode 100644 index 871beaad3..000000000 --- a/base/zero-to/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# zeroTo - -> Generate a linearly spaced numeric array whose elements increment by 1 starting from zero. - -
- -## Usage - -```javascript -var zeroTo = require( '@stdlib/array/base/zero-to' ); -``` - -#### zeroTo( n ) - -Generates a linearly spaced numeric array whose elements increment by `1` starting from zero. - -```javascript -var arr = zeroTo( 6 ); -// returns [ 0, 1, 2, 3, 4, 5 ] -``` - -If `n <= 0`, the function returns an empty array. - -```javascript -var arr = zeroTo( 0 ); -// returns [] - -arr = zeroTo( -1 ); -// returns [] -``` - -If `n` is a non-integer value greater than zero, the function returns an array having `ceil(n)` elements. - -```javascript -var arr = zeroTo( 5.1 ); -// returns [ 0, 1, 2, 3, 4, 5 ] -``` - -#### zeroTo.assign( out, stride, offset ) - -Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - -```javascript -var out = [ 0, 0, 0, 0, 0, 0 ]; - -var arr = zeroTo.assign( out, -1, out.length-1 ); -// returns [ 5, 4, 3, 2, 1, 0 ] - -var bool = ( arr === out ); -// returns true -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var filledBy = require( '@stdlib/array/base/filled-by' ); -var randu = require( '@stdlib/random/base/randu' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); - -// Generate an array of random numbers: -var x = filledBy( 10, randu ); - -// Generate an array of indices: -var idx = zeroTo( x.length ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort the index array according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, idx, 1 ); - -console.log( x ); -console.log( idx ); -``` - -
- - - - - - - - - - - - - - diff --git a/base/zero-to/benchmark/benchmark.assign.length.js b/base/zero-to/benchmark/benchmark.assign.length.js deleted file mode 100644 index aec772134..000000000 --- a/base/zero-to/benchmark/benchmark.assign.length.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zeroTo.assign( out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':assign:len='+len, f ); - } -} - -main(); diff --git a/base/zero-to/benchmark/benchmark.js b/base/zero-to/benchmark/benchmark.js deleted file mode 100644 index e40af9364..000000000 --- a/base/zero-to/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - var v; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zeroTo( 100 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':assign', function benchmark( b ) { - var out; - var i; - var v; - - out = zeros( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zeroTo.assign( out, 1, 0 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/zero-to/benchmark/benchmark.length.js b/base/zero-to/benchmark/benchmark.length.js deleted file mode 100644 index c3299c96f..000000000 --- a/base/zero-to/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zeroTo( len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/zero-to/docs/repl.txt b/base/zero-to/docs/repl.txt deleted file mode 100644 index a25337b88..000000000 --- a/base/zero-to/docs/repl.txt +++ /dev/null @@ -1,56 +0,0 @@ - -{{alias}}( n ) - Generates a linearly spaced numeric array whose elements increment by 1 - starting from zero. - - If `n` is a non-integer value greater than zero, the function returns an - array having `ceil(n)` elements. - - If `n` is less than or equal to zero, the function returns an empty array. - - Parameters - ---------- - n: number - Number of elements. - - Returns - ------- - out: Array - Linearly spaced numeric array. - - Examples - -------- - > var arr = {{alias}}( 6 ) - [ 0, 1, 2, 3, 4, 5 ] - - -{{alias}}.assign( out, stride, offset ) - Fills an array with linearly spaced numeric elements which increment by 1 - starting from zero. - - Parameters - ---------- - out: ArrayLikeObject - Output array. - - stride: integer - Output array stride. - - offset: integer - Output array index offset. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var out = [ 0, 0, 0, 0, 0, 0 ]; - > {{alias}}.assign( out, -1, out.length-1 ); - > out - [ 5, 4, 3, 2, 1, 0 ] - - See Also - -------- - diff --git a/base/zero-to/docs/types/index.d.ts b/base/zero-to/docs/types/index.d.ts deleted file mode 100644 index 2c321a846..000000000 --- a/base/zero-to/docs/types/index.d.ts +++ /dev/null @@ -1,361 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection, AccessorArrayLike, Complex128Array, Complex64Array } from '@stdlib/types/array'; - -/** -* Interface describing `zeroTo`. -*/ -interface ZeroTo { - /** - * Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. - * - * @param n - number of elements - * @returns linearly spaced numeric array - * - * @example - * var arr = zeroTo( 6 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - */ - ( n: number ): Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Float64Array = require( './../../../../float64' ); - * - * var out = new Float64Array( 6 ); - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - */ - assign( out: Float64Array, stride: number, offset: number ): Float64Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Float32Array = require( './../../../../float32' ); - * - * var out = new Float32Array( 6 ); - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - */ - assign( out: Float32Array, stride: number, offset: number ): Float32Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Int32Array = require( './../../../../int32' ); - * - * var out = new Int32Array( 6 ); - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - */ - assign( out: Int32Array, stride: number, offset: number ): Int32Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Int16Array = require( './../../../../int16' ); - * - * var out = new Int16Array( 6 ); - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - */ - assign( out: Int16Array, stride: number, offset: number ): Int16Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Int8Array = require( './../../../../int8' ); - * - * var out = new Int8Array( 6 ); - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - */ - assign( out: Int8Array, stride: number, offset: number ): Int8Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Uint32Array = require( './../../../../uint32' ); - * - * var out = new Uint32Array( 6 ); - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - */ - assign( out: Uint32Array, stride: number, offset: number ): Uint32Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Uint16Array = require( './../../../../uint16' ); - * - * var out = new Uint16Array( 6 ); - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - */ - assign( out: Uint16Array, stride: number, offset: number ): Uint16Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Uint8Array = require( './../../../../uint8' ); - * - * var out = new Uint8Array( 6 ); - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - */ - assign( out: Uint8Array, stride: number, offset: number ): Uint8Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Uint8ClampedArray = require( './../../../../uint8c' ); - * - * var out = new Uint8ClampedArray( 6 ); - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - */ - assign( out: Uint8ClampedArray, stride: number, offset: number ): Uint8ClampedArray; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Complex128Array = require( './../../../../complex128' ); - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * var out = new Complex128Array( 6 ); - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns - * - * var bool = ( arr === out ); - * // returns true - * - * var v = out.get( out.length-1 ); - * // returns - * - * var re = real( v ); - * // returns 5.0 - * - * var im = imag( v ); - * // returns 0.0 - */ - assign( out: Complex128Array, stride: number, offset: number ): Complex128Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var Complex64Array = require( './../../../../complex64' ); - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * var out = new Complex64Array( 6 ); - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns - * - * var bool = ( arr === out ); - * // returns true - * - * var v = out.get( out.length-1 ); - * // returns - * - * var re = realf( v ); - * // returns 5.0 - * - * var im = imagf( v ); - * // returns 0.0 - */ - assign( out: Complex64Array, stride: number, offset: number ): Complex64Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var toAccessorArray = require( './../../../../base/to-accessor-array' ); - * - * var out = toAccessorArray( [ 0, 0, 0, 0, 0, 0 ] ); - * var arr = zeroTo.assign( out, 1, 0 ); - * - * var bool = ( arr === out ); - * // returns true - * - * var v = out.get( out.length-1 ); - * // returns 5 - */ - assign( out: AccessorArrayLike, stride: number, offset: number ): AccessorArrayLike; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = zeroTo.assign( out, -1, out.length-1 ); - * // returns [ 5, 4, 3, 2, 1, 0 ] - */ - assign( out: Array, stride: number, offset: number ): Array; - - /** - * Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. - * - * @param out - output array - * @param stride - output array stride - * @param offset - output array index offset - * @returns output array - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = zeroTo.assign( out, 1, 0 ); - * // returns [ 0, 1, 2, 3, 4, 5 ] - * - * @example - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * - * var arr = zeroTo.assign( out, -1, out.length-1 ); - * // returns [ 5, 4, 3, 2, 1, 0 ] - */ - assign( out: Collection, stride: number, offset: number ): Collection; -} - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 6 ); -* // returns [ 0, 1, 2, 3, 4, 5 ] -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = zeroTo.assign( out, 1, 0 ); -* // returns [ 0, 1, 2, 3, 4, 5 ] -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = zeroTo.assign( out, -1, out.length-1 ); -* // returns [ 5, 4, 3, 2, 1, 0 ] -*/ -declare var zeroTo: ZeroTo; - - -// EXPORTS // - -export = zeroTo; diff --git a/base/zero-to/docs/types/test.ts b/base/zero-to/docs/types/test.ts deleted file mode 100644 index 6779ce93d..000000000 --- a/base/zero-to/docs/types/test.ts +++ /dev/null @@ -1,110 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 Complex128Array = require( './../../../../complex128' ); -import Complex64Array = require( './../../../../complex64' ); -import zeroTo = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - zeroTo( 11 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is not provided a number... -{ - zeroTo( true ); // $ExpectError - zeroTo( false ); // $ExpectError - zeroTo( '5' ); // $ExpectError - zeroTo( [] ); // $ExpectError - zeroTo( {} ); // $ExpectError - zeroTo( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeroTo(); // $ExpectError - zeroTo( 3, 4 ); // $ExpectError - zeroTo( 3, 4, 1 ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a collection... -{ - zeroTo.assign( [ 0, 0, 0, 0 ], 1, 0 ); // $ExpectType number[] - zeroTo.assign( new Float64Array( 4 ), 1, 0 ); // $ExpectType Float64Array - zeroTo.assign( new Float32Array( 4 ), 1, 0 ); // $ExpectType Float32Array - zeroTo.assign( new Int32Array( 4 ), 1, 0 ); // $ExpectType Int32Array - zeroTo.assign( new Int16Array( 4 ), 1, 0 ); // $ExpectType Int16Array - zeroTo.assign( new Int8Array( 4 ), 1, 0 ); // $ExpectType Int8Array - zeroTo.assign( new Uint32Array( 4 ), 1, 0 ); // $ExpectType Uint32Array - zeroTo.assign( new Uint16Array( 4 ), 1, 0 ); // $ExpectType Uint16Array - zeroTo.assign( new Uint8Array( 4 ), 1, 0 ); // $ExpectType Uint8Array - zeroTo.assign( new Uint8ClampedArray( 4 ), 1, 0 ); // $ExpectType Uint8ClampedArray - zeroTo.assign( new Complex128Array( 4 ), 1, 0 ); // $ExpectType Complex128Array - zeroTo.assign( new Complex64Array( 4 ), 1, 0 ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not an array-like object... -{ - zeroTo.assign( 1, 1, 0 ); // $ExpectError - zeroTo.assign( true, 1, 0 ); // $ExpectError - zeroTo.assign( false, 1, 0 ); // $ExpectError - zeroTo.assign( null, 1, 0 ); // $ExpectError - zeroTo.assign( void 0, 1, 0 ); // $ExpectError - zeroTo.assign( {}, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a number... -{ - const out = [ 0, 0, 0, 0 ]; - - zeroTo.assign( out, '1', 0 ); // $ExpectError - zeroTo.assign( out, true, 0 ); // $ExpectError - zeroTo.assign( out, false, 0 ); // $ExpectError - zeroTo.assign( out, null, 0 ); // $ExpectError - zeroTo.assign( out, void 0, 0 ); // $ExpectError - zeroTo.assign( out, {}, 0 ); // $ExpectError - zeroTo.assign( out, [], 0 ); // $ExpectError - zeroTo.assign( out, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not a number... -{ - const out = [ 0, 0, 0, 0 ]; - - zeroTo.assign( out, 1, '1' ); // $ExpectError - zeroTo.assign( out, 1, true ); // $ExpectError - zeroTo.assign( out, 1, false ); // $ExpectError - zeroTo.assign( out, 1, null ); // $ExpectError - zeroTo.assign( out, 1, void 0 ); // $ExpectError - zeroTo.assign( out, 1, {} ); // $ExpectError - zeroTo.assign( out, 1, [] ); // $ExpectError - zeroTo.assign( out, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const out = [ 0, 0, 0, 0 ]; - - zeroTo.assign(); // $ExpectError - zeroTo.assign( out ); // $ExpectError - zeroTo.assign( out, 1 ); // $ExpectError - zeroTo.assign( out, 1, 0, {} ); // $ExpectError -} diff --git a/base/zero-to/examples/index.js b/base/zero-to/examples/index.js deleted file mode 100644 index 7bcf309ec..000000000 --- a/base/zero-to/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var filledBy = require( './../../../base/filled-by' ); -var randu = require( '@stdlib/random/base/randu' ); -var zeroTo = require( './../lib' ); - -// Generate an array of random numbers: -var x = filledBy( 10, randu ); - -// Generate an array of indices: -var idx = zeroTo( x.length ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort the index array according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, idx, 1 ); - -console.log( x ); -console.log( idx ); diff --git a/base/zero-to/lib/assign.js b/base/zero-to/lib/assign.js deleted file mode 100644 index 30b48f74b..000000000 --- a/base/zero-to/lib/assign.js +++ /dev/null @@ -1,196 +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. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); - - -// FUNCTIONS // - -/** -* Fills an indexed array with linearly spaced numeric elements which increment by 1 starting from zero. -* -* @private -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {Collection} output array -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = indexed( out, 1, 0 ); -* // returns [ 0, 1, 2, 3, 4, 5 ] -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = indexed( out, -1, out.length-1 ); -* // returns [ 5, 4, 3, 2, 1, 0 ] -*/ -function indexed( out, stride, offset ) { - var v; - var i; - - i = offset; - v = 0; - while ( i >= 0 && i < out.length ) { - out[ i ] = v; - i += stride; - v += 1; - } - return out; -} - -/** -* Fills a complex number array with linearly spaced numeric elements which increment by 1 starting from zero. -* -* @private -* @param {(Complex128Array|Complex64Array)} out - output complex number array -* @param {(Float64Array|Float32Array)} data - output array data -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {(Complex128Array|Complex64Array)} output array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -* -* var out = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -* // returns -* -* var data = reinterpret128( out, 0 ); -* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] -* -* var arr = complex( out, data, 1, 0 ); -* // returns -* -* var bool = ( arr === out ); -* // returns true -* -* data = reinterpret128( out, 0 ); -* returns [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] -*/ -function complex( out, data, stride, offset ) { - var v; - var s; - var i; - - s = stride * 2; - i = offset * 2; - v = 0.0; - while ( i >= 0 && i < data.length ) { - data[ i ] = v; // real component - data[ i+1 ] = 0.0; // imaginary component - i += s; - v += 1.0; - } - return out; -} - -/** -* Fills an accessor array with linearly spaced numeric elements which increment by 1 starting from zero. -* -* @private -* @param {Object} out - output array object -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {Collection} output array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); - -* var out = toAccessorArray( [ 0, 0, 0, 0, 0, 0 ] ); -* var arr = accessors( arraylike2object( out ), 1, 0 ); -* -* var bool = ( arr === out ); -* // returns true -* -* var v = out.get( 0 ); -* // returns 0 -* -* v = out.get( out.length-1 ); -* // returns 5 -*/ -function accessors( out, stride, offset ) { - var data; - var set; - var v; - var i; - - data = out.data; - set = out.accessors[ 1 ]; - - i = offset; - v = 0; - while ( i >= 0 && i < data.length ) { - set( data, i, v ); - i += stride; - v += 1; - } - return data; -} - - -// MAIN // - -/** -* Fills an array with linearly spaced numeric elements which increment by 1 starting from zero. -* -* @param {Collection} out - output array -* @param {integer} stride - output array stride -* @param {NonNegativeInteger} offset - output array index offset -* @returns {Collection} output array -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = assign( out, 1, 0 ); -* // returns [ 0, 1, 2, 3, 4, 5 ] -* -* @example -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* -* var arr = assign( out, -1, out.length-1 ); -* // returns [ 5, 4, 3, 2, 1, 0 ] -*/ -function assign( out, stride, offset ) { - var obj = arraylike2object( out ); - if ( obj.accessorProtocol ) { - // If provided a complex number array, reinterpret as a real typed array and only set the real components... - if ( obj.dtype === 'complex128' ) { - return complex( out, reinterpret128( out, 0 ), stride, offset ); - } - if ( obj.dtype === 'complex64' ) { - return complex( out, reinterpret64( out, 0 ), stride, offset ); - } - return accessors( obj, stride, offset ); - } - return indexed( out, stride, offset ); -} - - -// EXPORTS // - -module.exports = assign; diff --git a/base/zero-to/lib/index.js b/base/zero-to/lib/index.js deleted file mode 100644 index 9452954ad..000000000 --- a/base/zero-to/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Generate a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @module @stdlib/array/base/zero-to -* -* @example -* var zeroTo = require( '@stdlib/array/base/zero-to' ); -* -* var arr = zeroTo( 6 ); -* // returns [ 0, 1, 2, 3, 4, 5 ] -* -* @example -* var zeroTo = require( '@stdlib/array/base/zero-to' ); -* -* var out = [ 0, 0, 0, 0, 0, 0 ]; -* var arr = zeroTo.assign( out, 1, 0 ); -* // returns [ 0, 1, 2, 3, 4, 5 ] -* -* var bool = ( out === arr ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/zero-to/lib/main.js b/base/zero-to/lib/main.js deleted file mode 100644 index 50b3309d0..000000000 --- a/base/zero-to/lib/main.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param {number} n - number of elements -* @returns {Array} linearly spaced numeric array -* -* @example -* var arr = zeroTo( 6 ); -* // returns [ 0, 1, 2, 3, 4, 5 ] -*/ -function zeroTo( n ) { - var arr; - var i; - - arr = []; - if ( n <= 0 ) { - return arr; - } - for ( i = 0; i < n; i++ ) { - arr.push( i ); - } - return arr; -} - - -// EXPORTS // - -module.exports = zeroTo; diff --git a/base/zero-to/package.json b/base/zero-to/package.json deleted file mode 100644 index 98e754773..000000000 --- a/base/zero-to/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/base/zero-to", - "version": "0.0.0", - "description": "Generate a linearly spaced numeric array whose elements increment by 1 starting from zero.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "matlab", - "linear", - "linspace", - "sequence", - "increment", - "unitspace" - ] -} diff --git a/base/zero-to/test/test.assign.js b/base/zero-to/test/test.assign.js deleted file mode 100644 index 15a6c4683..000000000 --- a/base/zero-to/test/test.assign.js +++ /dev/null @@ -1,211 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128Array = require( './../../../complex128' ); -var Complex64Array = require( './../../../complex64' ); -var Float64Array = require( './../../../float64' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var zeroTo = require( './../lib/assign.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeroTo, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function fills an array with linearly spaced numbers (generic)', function test( t ) { - var expected; - var actual; - var out; - - out = [ 0, 0, 0, 0, 0 ]; - actual = zeroTo( out, 1, 0 ); - expected = [ 0, 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = [ 0, 0, 0 ]; - actual = zeroTo( out, -1, out.length-1 ); - expected = [ 2, 1, 0 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = [ -1, -1, -1, -1, -1 ]; - actual = zeroTo( out, 2, 1 ); - expected = [ -1, 0, -1, 1, -1 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = [ -1, -1, -1, -1, -1, -1 ]; - actual = zeroTo( out, -2, out.length-2 ); - expected = [ 2, -1, 1, -1, 0, -1 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array with linearly spaced numbers (real typed array)', function test( t ) { - var expected; - var actual; - var out; - - out = new Float64Array( [ 0, 0, 0, 0, 0 ] ); - actual = zeroTo( out, 1, 0 ); - expected = new Float64Array( [ 0, 1, 2, 3, 4 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( actual, expected ), true, 'returns expected value' ); - - out = new Float64Array( [ 0, 0, 0 ] ); - actual = zeroTo( out, -1, out.length-1 ); - expected = new Float64Array( [ 2, 1, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( actual, expected ), true, 'returns expected value' ); - - out = new Float64Array( [ -1, -1, -1, -1, -1 ] ); - actual = zeroTo( out, 2, 1 ); - expected = new Float64Array( [ -1, 0, -1, 1, -1 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( actual, expected ), true, 'returns expected value' ); - - out = new Float64Array( [ -1, -1, -1, -1, -1, -1 ] ); - actual = zeroTo( out, -2, out.length-2 ); - expected = new Float64Array( [ 2, -1, 1, -1, 0, -1 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameFloat64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array with linearly spaced numbers (complex typed array)', function test( t ) { - var expected; - var actual; - var out; - - out = new Complex128Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ); - actual = zeroTo( out, 1, 0 ); - expected = new Complex128Array( [ 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex128Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ); - actual = zeroTo( out, -1, out.length-1 ); - expected = new Complex128Array( [ 4, 0, 3, 0, 2, 0, 1, 0, 0, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex128Array( [ -1, -1, -1, -1, -1, -1, -1, -1 ] ); - actual = zeroTo( out, 2, 1 ); - expected = new Complex128Array( [ -1, -1, 0, 0, -1, -1, 1, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ); - actual = zeroTo( out, 1, 0 ); - expected = new Complex64Array( [ 0, 0, 1, 0, 2, 0, 3, 0, 4, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ); - actual = zeroTo( out, -1, out.length-1 ); - expected = new Complex64Array( [ 4, 0, 3, 0, 2, 0, 1, 0, 0, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - out = new Complex64Array( [ -1, -1, -1, -1, -1, -1, -1, -1 ] ); - actual = zeroTo( out, 2, 1 ); - expected = new Complex64Array( [ -1, -1, 0, 0, -1, -1, 1, 0 ] ); - - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function fills an array with linearly spaced numbers (accessor)', function test( t ) { - var expected; - var actual; - var out; - - out = toAccessorArray( [ 0, 0, 0, 0, 0 ] ); - actual = zeroTo( out, 1, 0 ); - expected = [ 0, 1, 2, 3, 4 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = toAccessorArray( [ 0, 0, 0 ] ); - actual = zeroTo( out, -1, out.length-1 ); - expected = [ 2, 1, 0 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = toAccessorArray( [ -1, -1, -1, -1, -1 ] ); - actual = zeroTo( out, 2, 1 ); - expected = [ -1, 0, -1, 1, -1 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - out = toAccessorArray( [ -1, -1, -1, -1, -1, -1 ] ); - actual = zeroTo( out, -2, out.length-2 ); - expected = [ 2, -1, 1, -1, 0, -1 ]; - - t.strictEqual( actual, out, 'returns expected value' ); - isEqual( actual, expected ); - - t.end(); - - function isEqual( actual, expected ) { - var i; - for ( i = 0; i < expected.length; i++ ) { - t.strictEqual( actual.get( i ), expected[ i ], 'returns expected value' ); - } - } -}); - -tape( 'the function returns an empty array if provided an empty array', function test( t ) { - t.deepEqual( zeroTo( [], 1, 0 ), [], 'returns expected value' ); - t.deepEqual( zeroTo( [], 1, 0 ), [], 'returns expected value' ); - t.end(); -}); diff --git a/base/zero-to/test/test.js b/base/zero-to/test/test.js deleted file mode 100644 index 0bf45f533..000000000 --- a/base/zero-to/test/test.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var zeroTo = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeroTo, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( hasOwnProp( zeroTo, 'assign' ), true, 'has property' ); - t.strictEqual( typeof zeroTo.assign, 'function', 'has method' ); - t.end(); -}); diff --git a/base/zero-to/test/test.main.js b/base/zero-to/test/test.main.js deleted file mode 100644 index 37e82a1c7..000000000 --- a/base/zero-to/test/test.main.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 zeroTo = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeroTo, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a linearly spaced array', function test( t ) { - var expected; - var actual; - - actual = zeroTo( 10 ); - expected = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zeroTo( 5 ); - expected = [ 0, 1, 2, 3, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (fractional argument)', function test( t ) { - var expected; - var actual; - - actual = zeroTo( 10.5 ); - expected = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zeroTo( 5.0000001 ); - expected = [ 0, 1, 2, 3, 4, 5 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided a value which is less than or equal to zero', function test( t ) { - t.deepEqual( zeroTo( -1 ), [], 'returns expected value' ); - t.deepEqual( zeroTo( 0 ), [], 'returns expected value' ); - t.end(); -}); diff --git a/base/zeros/README.md b/base/zeros/README.md deleted file mode 100644 index e93a84d37..000000000 --- a/base/zeros/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# zeros - -> Create a zero-filled "generic" array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var zeros = require( '@stdlib/array/base/zeros' ); -``` - -#### zeros( len ) - -Returns a zero-filled "generic" array. - -```javascript -var out = zeros( 3 ); -// returns [ 0.0, 0.0, 0.0 ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var gfill = require( '@stdlib/blas/ext/base/gfill' ).ndarray; -var zeros = require( '@stdlib/array/base/zeros' ); - -// Create a zero-filled array: -var arr = zeros( 10 ); - -// Fill element pairs with the same value... -gfill( 2, 1.0, arr, 1, 0 ); -gfill( 2, 2.0, arr, 1, 2 ); -gfill( 2, 3.0, arr, 1, 4 ); -gfill( 2, 4.0, arr, 1, 6 ); -gfill( 2, 5.0, arr, 1, 8 ); - -console.log( arr ); -// => [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/zeros/benchmark/benchmark.length.js b/base/zeros/benchmark/benchmark.length.js deleted file mode 100644 index a44caab1e..000000000 --- a/base/zeros/benchmark/benchmark.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = zeros( len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/zeros/docs/repl.txt b/base/zeros/docs/repl.txt deleted file mode 100644 index 32178e61a..000000000 --- a/base/zeros/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( len ) - Returns a zero-filled "generic" array. - - Parameters - ---------- - len: integer - Array length. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/base/zeros/docs/types/index.d.ts b/base/zeros/docs/types/index.d.ts deleted file mode 100644 index f66fe6b1d..000000000 --- a/base/zeros/docs/types/index.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a zero-filled "generic" array. -* -* @param len - array length -* @returns output array -* -* @example -* var out = zeros( 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function zeros( len: number ): Array; - - -// EXPORTS // - -export = zeros; diff --git a/base/zeros/docs/types/test.ts b/base/zeros/docs/types/test.ts deleted file mode 100644 index bc740b9eb..000000000 --- a/base/zeros/docs/types/test.ts +++ /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. -*/ - -import zeros = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - zeros( 3 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided an argument which is not a number... -{ - zeros( 'abc' ); // $ExpectError - zeros( true ); // $ExpectError - zeros( false ); // $ExpectError - zeros( null ); // $ExpectError - zeros( [] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros(); // $ExpectError - zeros( 3, 2 ); // $ExpectError -} diff --git a/base/zeros/examples/index.js b/base/zeros/examples/index.js deleted file mode 100644 index 015942266..000000000 --- a/base/zeros/examples/index.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 gfill = require( '@stdlib/blas/ext/base/gfill' ).ndarray; -var zeros = require( './../lib' ); - -// Create a zero-filled array: -var arr = zeros( 10 ); - -// Fill element pairs with the same value... -gfill( 2, 1.0, arr, 1, 0 ); -gfill( 2, 2.0, arr, 1, 2 ); -gfill( 2, 3.0, arr, 1, 4 ); -gfill( 2, 4.0, arr, 1, 6 ); -gfill( 2, 5.0, arr, 1, 8 ); - -console.log( arr ); -// => [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0 ] diff --git a/base/zeros/lib/index.js b/base/zeros/lib/index.js deleted file mode 100644 index 3e6a2e33f..000000000 --- a/base/zeros/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled "generic" array. -* -* @module @stdlib/array/base/zeros -* -* @example -* var zeros = require( '@stdlib/array/base/zeros' ); -* -* var out = zeros( 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/zeros/lib/main.js b/base/zeros/lib/main.js deleted file mode 100644 index 801d6098f..000000000 --- a/base/zeros/lib/main.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var filled = require( './../../../base/filled' ); - - -// MAIN // - -/** -* Returns a zero-filled "generic" array. -* -* @param {NonNegativeInteger} len - array length -* @returns {Array} output array -* -* @example -* var out = zeros( 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function zeros( len ) { - return filled( 0.0, len ); -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/base/zeros/package.json b/base/zeros/package.json deleted file mode 100644 index 65c90c5f6..000000000 --- a/base/zeros/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/base/zeros", - "version": "0.0.0", - "description": "Create a zero-filled generic array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "zeros" - ] -} diff --git a/base/zeros/test/test.js b/base/zeros/test/test.js deleted file mode 100644 index 348e255ab..000000000 --- a/base/zeros/test/test.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a zero-filled "generic" array', function test( t ) { - var expected; - var actual; - - expected = [ 0.0, 0.0, 0.0 ]; - actual = zeros( 3 ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a length of `0`', function test( t ) { - var expected; - var actual; - - expected = []; - actual = zeros( 0 ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/base/zeros2d/README.md b/base/zeros2d/README.md deleted file mode 100644 index 4db1bb56d..000000000 --- a/base/zeros2d/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# zeros2d - -> Create a zero-filled two-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var zeros2d = require( '@stdlib/array/base/zeros2d' ); -``` - -#### zeros2d( shape ) - -Returns a zero-filled two-dimensional nested array. - -```javascript -var out = zeros2d( [ 2, 3 ] ); -// returns [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var gfill = require( '@stdlib/blas/ext/base/gfill' ); -var zeros2d = require( '@stdlib/array/base/zeros2d' ); - -// Create a zero-filled array: -var arr = zeros2d( [ 5, 10 ] ); - -// Fill nested arrays with the same value... -gfill( arr[ 0 ].length, 1.0, arr[ 0 ], 1 ); -gfill( arr[ 1 ].length, 2.0, arr[ 1 ], 1 ); -gfill( arr[ 2 ].length, 3.0, arr[ 2 ], 1 ); -gfill( arr[ 3 ].length, 4.0, arr[ 3 ], 1 ); -gfill( arr[ 4 ].length, 5.0, arr[ 4 ], 1 ); - -console.log( arr ); -// => [ [ 1.0, 1.0, ... ], [ 2.0, 2.0, ... ], [ 3.0, 3.0, ... ], [ 4.0, 4.0, ... ], [ 5.0, 5.0, ... ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/zeros2d/benchmark/benchmark.size.js b/base/zeros2d/benchmark/benchmark.size.js deleted file mode 100644 index 0a06c8172..000000000 --- a/base/zeros2d/benchmark/benchmark.size.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var zeros2d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = zeros2d( [ N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::square_matrix:size='+(N*N), f ); - } -} - -main(); diff --git a/base/zeros2d/docs/repl.txt b/base/zeros2d/docs/repl.txt deleted file mode 100644 index 81eeb8cbc..000000000 --- a/base/zeros2d/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( shape ) - Returns a zero-filled two-dimensional nested array. - - Parameters - ---------- - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 3 ] ) - [ [ 0.0, 0.0, 0.0 ] ] - - See Also - -------- - diff --git a/base/zeros2d/docs/types/index.d.ts b/base/zeros2d/docs/types/index.d.ts deleted file mode 100644 index 1ebbcd2c5..000000000 --- a/base/zeros2d/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape2D } from '@stdlib/types/ndarray'; - -/** -* Two-dimensional nested array. -*/ -type Array2D = Array>; - -/** -* Returns a zero-filled two-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zeros2d( [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -*/ -declare function zeros2d( shape: Shape2D ): Array2D; - - -// EXPORTS // - -export = zeros2d; diff --git a/base/zeros2d/docs/types/test.ts b/base/zeros2d/docs/types/test.ts deleted file mode 100644 index 7bb8f5781..000000000 --- a/base/zeros2d/docs/types/test.ts +++ /dev/null @@ -1,44 +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. -*/ - -import zeros2d = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - zeros2d( [ 1, 3 ] ); // $ExpectType Array2D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - zeros2d( 'abc' ); // $ExpectError - zeros2d( true ); // $ExpectError - zeros2d( false ); // $ExpectError - zeros2d( null ); // $ExpectError - zeros2d( [ '1' ] ); // $ExpectError - zeros2d( {} ); // $ExpectError - zeros2d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros2d(); // $ExpectError - zeros2d( [ 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/zeros2d/examples/index.js b/base/zeros2d/examples/index.js deleted file mode 100644 index 985d02fcb..000000000 --- a/base/zeros2d/examples/index.js +++ /dev/null @@ -1,35 +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'; - -var gfill = require( '@stdlib/blas/ext/base/gfill' ); -var zeros2d = require( './../lib' ); - -// Create a zero-filled array: -var arr = zeros2d( [ 5, 10 ] ); - -// Fill nested arrays with the same value... -gfill( arr[ 0 ].length, 1.0, arr[ 0 ], 1 ); -gfill( arr[ 1 ].length, 2.0, arr[ 1 ], 1 ); -gfill( arr[ 2 ].length, 3.0, arr[ 2 ], 1 ); -gfill( arr[ 3 ].length, 4.0, arr[ 3 ], 1 ); -gfill( arr[ 4 ].length, 5.0, arr[ 4 ], 1 ); - -console.log( arr ); -// => [ [ 1.0, 1.0, ... ], [ 2.0, 2.0, ... ], [ 3.0, 3.0, ... ], [ 4.0, 4.0, ... ], [ 5.0, 5.0, ... ] ] diff --git a/base/zeros2d/lib/index.js b/base/zeros2d/lib/index.js deleted file mode 100644 index 5d3aa8a4f..000000000 --- a/base/zeros2d/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Create a zero-filled two-dimensional nested array. -* -* @module @stdlib/array/base/zeros2d -* -* @example -* var zeros2d = require( '@stdlib/array/base/zeros2d' ); -* -* var out = zeros2d( [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/zeros2d/lib/main.js b/base/zeros2d/lib/main.js deleted file mode 100644 index e1b5388cb..000000000 --- a/base/zeros2d/lib/main.js +++ /dev/null @@ -1,45 +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 filled2d = require( './../../../base/filled2d' ); - - -// MAIN // - -/** -* Returns a zero-filled two-dimensional nested array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {ArrayArray} filled array -* -* @example -* var out = zeros2d( [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -*/ -function zeros2d( shape ) { - return filled2d( 0.0, shape ); -} - - -// EXPORTS // - -module.exports = zeros2d; diff --git a/base/zeros2d/package.json b/base/zeros2d/package.json deleted file mode 100644 index 4fa2961df..000000000 --- a/base/zeros2d/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/zeros2d", - "version": "0.0.0", - "description": "Create a zero-filled two-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "zeros", - "multidimensional", - "matrix", - "strided", - "ndarray", - "2d" - ] -} diff --git a/base/zeros2d/test/test.js b/base/zeros2d/test/test.js deleted file mode 100644 index 959e4b0de..000000000 --- a/base/zeros2d/test/test.js +++ /dev/null @@ -1,89 +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 zeros2d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros2d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ [ 0.0, 0.0, 0.0 ] ]; - actual = zeros2d( [ 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ]; - actual = zeros2d( [ 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - actual = zeros2d( [ 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = zeros2d( [ 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zeros2d( [ 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zeros2d( [ 0, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = zeros2d( [ 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = zeros2d( [ 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = zeros2d( [ 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/zeros3d/README.md b/base/zeros3d/README.md deleted file mode 100644 index ad7f2c626..000000000 --- a/base/zeros3d/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# zeros3d - -> Create a zero-filled three-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var zeros3d = require( '@stdlib/array/base/zeros3d' ); -``` - -#### zeros3d( shape ) - -Returns a zero-filled three-dimensional nested array. - -```javascript -var out = zeros3d( [ 1, 2, 3 ] ); -// returns [ [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var zeros3d = require( '@stdlib/array/base/zeros3d' ); - -var out = zeros3d( [ 1, 1, 3 ] ); -// returns [ [ [ 0.0, 0.0, 0.0 ] ] ] - -out = zeros3d( [ 1, 3, 1 ] ); -// returns [ [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/zeros3d/benchmark/benchmark.size.js b/base/zeros3d/benchmark/benchmark.size.js deleted file mode 100644 index 95992659b..000000000 --- a/base/zeros3d/benchmark/benchmark.size.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var cbrt = require( '@stdlib/math/base/special/cbrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var zeros3d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = zeros3d( [ N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( cbrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N), f ); - } -} - -main(); diff --git a/base/zeros3d/docs/repl.txt b/base/zeros3d/docs/repl.txt deleted file mode 100644 index 584382b73..000000000 --- a/base/zeros3d/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( shape ) - Returns a zero-filled three-dimensional nested array. - - Parameters - ---------- - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 1, 3 ] ) - [ [ [ 0.0, 0.0, 0.0 ] ] ] - - See Also - -------- - diff --git a/base/zeros3d/docs/types/index.d.ts b/base/zeros3d/docs/types/index.d.ts deleted file mode 100644 index 403fd1dbb..000000000 --- a/base/zeros3d/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape3D } from '@stdlib/types/ndarray'; - -/** -* Three-dimensional nested array. -*/ -type Array3D = Array>>; - -/** -* Returns a zero-filled three-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zeros3d( [ 1, 1, 3 ] ); -* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ] -*/ -declare function zeros3d( shape: Shape3D ): Array3D; - - -// EXPORTS // - -export = zeros3d; diff --git a/base/zeros3d/docs/types/test.ts b/base/zeros3d/docs/types/test.ts deleted file mode 100644 index a122a1716..000000000 --- a/base/zeros3d/docs/types/test.ts +++ /dev/null @@ -1,44 +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. -*/ - -import zeros3d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - zeros3d( [ 1, 1, 3 ] ); // $ExpectType Array3D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - zeros3d( 'abc' ); // $ExpectError - zeros3d( true ); // $ExpectError - zeros3d( false ); // $ExpectError - zeros3d( null ); // $ExpectError - zeros3d( [ '1' ] ); // $ExpectError - zeros3d( {} ); // $ExpectError - zeros3d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros3d(); // $ExpectError - zeros3d( [ 1, 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/zeros3d/examples/index.js b/base/zeros3d/examples/index.js deleted file mode 100644 index 97c6c6414..000000000 --- a/base/zeros3d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var zeros3d = require( './../lib' ); - -var out = zeros3d( [ 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ 0.0, 0.0, 0.0 ] ] ] - -out = zeros3d( [ 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ] ] diff --git a/base/zeros3d/lib/index.js b/base/zeros3d/lib/index.js deleted file mode 100644 index e7826022a..000000000 --- a/base/zeros3d/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Create a zero-filled three-dimensional nested array. -* -* @module @stdlib/array/base/zeros3d -* -* @example -* var zeros3d = require( '@stdlib/array/base/zeros3d' ); -* -* var out = zeros3d( [ 1, 1, 3 ] ); -* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/zeros3d/lib/main.js b/base/zeros3d/lib/main.js deleted file mode 100644 index 04fbe7c5c..000000000 --- a/base/zeros3d/lib/main.js +++ /dev/null @@ -1,45 +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 filled3d = require( './../../../base/filled3d' ); - - -// MAIN // - -/** -* Returns a zero-filled three-dimensional nested array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = zeros3d( [ 1, 1, 3 ] ); -* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ] -*/ -function zeros3d( shape ) { - return filled3d( 0.0, shape ); -} - - -// EXPORTS // - -module.exports = zeros3d; diff --git a/base/zeros3d/package.json b/base/zeros3d/package.json deleted file mode 100644 index 6fcefad50..000000000 --- a/base/zeros3d/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/array/base/zeros3d", - "version": "0.0.0", - "description": "Create a zero-filled three-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "3d", - "zeros" - ] -} diff --git a/base/zeros3d/test/test.js b/base/zeros3d/test/test.js deleted file mode 100644 index 8e77a23be..000000000 --- a/base/zeros3d/test/test.js +++ /dev/null @@ -1,134 +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 zeros3d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros3d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ 0.0, 0.0, 0.0 ] - ] - ]; - actual = zeros3d( [ 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ], - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ] - ]; - actual = zeros3d( [ 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ], - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ] - ]; - actual = zeros3d( [ 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = zeros3d( [ 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zeros3d( [ 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zeros3d( [ 0, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = zeros3d( [ 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = zeros3d( [ 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = zeros3d( [ 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [ [] ] ]; - actual = zeros3d( [ 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [] ] ]; - actual = zeros3d( [ 1, 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [], [] ] ]; - actual = zeros3d( [ 1, 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/zeros4d/README.md b/base/zeros4d/README.md deleted file mode 100644 index b2274a16f..000000000 --- a/base/zeros4d/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# zeros4d - -> Create a zero-filled four-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var zeros4d = require( '@stdlib/array/base/zeros4d' ); -``` - -#### zeros4d( shape ) - -Returns a zero-filled four-dimensional nested array. - -```javascript -var out = zeros4d( [ 1, 1, 2, 3 ] ); -// returns [ [ [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var zeros4d = require( '@stdlib/array/base/zeros4d' ); - -var out = zeros4d( [ 1, 1, 1, 3 ] ); -// returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] - -out = zeros4d( [ 1, 1, 3, 1 ] ); -// returns [ [ [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/zeros4d/benchmark/benchmark.size.js b/base/zeros4d/benchmark/benchmark.size.js deleted file mode 100644 index 0703c0a58..000000000 --- a/base/zeros4d/benchmark/benchmark.size.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var zeros4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = zeros4d( [ N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N*N), f ); - } -} - -main(); diff --git a/base/zeros4d/docs/repl.txt b/base/zeros4d/docs/repl.txt deleted file mode 100644 index d0601b556..000000000 --- a/base/zeros4d/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( shape ) - Returns a zero-filled four-dimensional nested array. - - Parameters - ---------- - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 1, 1, 3 ] ) - [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] - - See Also - -------- - diff --git a/base/zeros4d/docs/types/index.d.ts b/base/zeros4d/docs/types/index.d.ts deleted file mode 100644 index 83a2e7a73..000000000 --- a/base/zeros4d/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Four-dimensional nested array. -*/ -type Array4D = Array>>>; - -/** -* Returns a zero-filled four-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zeros4d( [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] -*/ -declare function zeros4d( shape: Shape4D ): Array4D; - - -// EXPORTS // - -export = zeros4d; diff --git a/base/zeros4d/docs/types/test.ts b/base/zeros4d/docs/types/test.ts deleted file mode 100644 index 93be96f4e..000000000 --- a/base/zeros4d/docs/types/test.ts +++ /dev/null @@ -1,44 +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. -*/ - -import zeros4d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - zeros4d( [ 1, 1, 1, 3 ] ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - zeros4d( 'abc' ); // $ExpectError - zeros4d( true ); // $ExpectError - zeros4d( false ); // $ExpectError - zeros4d( null ); // $ExpectError - zeros4d( [ '1' ] ); // $ExpectError - zeros4d( {} ); // $ExpectError - zeros4d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros4d(); // $ExpectError - zeros4d( [ 1, 1, 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/zeros4d/examples/index.js b/base/zeros4d/examples/index.js deleted file mode 100644 index 4319014c5..000000000 --- a/base/zeros4d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var zeros4d = require( './../lib' ); - -var out = zeros4d( [ 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] - -out = zeros4d( [ 1, 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ] ] ] diff --git a/base/zeros4d/lib/index.js b/base/zeros4d/lib/index.js deleted file mode 100644 index 75e1579b5..000000000 --- a/base/zeros4d/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Create a zero-filled four-dimensional nested array. -* -* @module @stdlib/array/base/zeros4d -* -* @example -* var zeros4d = require( '@stdlib/array/base/zeros4d' ); -* -* var out = zeros4d( [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/zeros4d/lib/main.js b/base/zeros4d/lib/main.js deleted file mode 100644 index 9878278a3..000000000 --- a/base/zeros4d/lib/main.js +++ /dev/null @@ -1,45 +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 filled4d = require( './../../../base/filled4d' ); - - -// MAIN // - -/** -* Returns a zero-filled four-dimensional nested array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = zeros4d( [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] -*/ -function zeros4d( shape ) { - return filled4d( 0.0, shape ); -} - - -// EXPORTS // - -module.exports = zeros4d; diff --git a/base/zeros4d/package.json b/base/zeros4d/package.json deleted file mode 100644 index cf2c4c470..000000000 --- a/base/zeros4d/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/array/base/zeros4d", - "version": "0.0.0", - "description": "Create a zero-filled four-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "4d", - "zeros" - ] -} diff --git a/base/zeros4d/test/test.js b/base/zeros4d/test/test.js deleted file mode 100644 index b02e589a6..000000000 --- a/base/zeros4d/test/test.js +++ /dev/null @@ -1,201 +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 zeros4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ 0.0, 0.0, 0.0 ] - ] - ] - ]; - actual = zeros4d( [ 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ], - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ] - ] - ]; - actual = zeros4d( [ 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ], - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ] - ], - [ - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ], - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ] - ] - ]; - actual = zeros4d( [ 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = zeros4d( [ 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zeros4d( [ 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zeros4d( [ 0, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = zeros4d( [ 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = zeros4d( [ 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = zeros4d( [ 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = zeros4d( [ 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = zeros4d( [ 1, 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = zeros4d( [ 1, 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = zeros4d( [ 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = zeros4d( [ 1, 2, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = zeros4d( [ 1, 3, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/zeros5d/README.md b/base/zeros5d/README.md deleted file mode 100644 index 1189159f8..000000000 --- a/base/zeros5d/README.md +++ /dev/null @@ -1,135 +0,0 @@ - - -# zeros5d - -> Create a zero-filled five-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var zeros5d = require( '@stdlib/array/base/zeros5d' ); -``` - -#### zeros5d( shape ) - -Returns a zero-filled five-dimensional nested array. - -```javascript -var out = zeros5d( [ 1, 1, 1, 2, 3 ] ); -// returns [ [ [ [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] ] ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var zeros5d = require( '@stdlib/array/base/zeros5d' ); - -var out = zeros5d( [ 1, 1, 1, 1, 3 ] ); -// returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] - -out = zeros5d( [ 1, 1, 1, 3, 1 ] ); -// returns [ [ [ [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/zeros5d/benchmark/benchmark.size.js b/base/zeros5d/benchmark/benchmark.size.js deleted file mode 100644 index 80a327451..000000000 --- a/base/zeros5d/benchmark/benchmark.size.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var zeros5d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = zeros5d( [ N, N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::equidimensional:size='+(N*N*N*N*N), f ); - } -} - -main(); diff --git a/base/zeros5d/docs/repl.txt b/base/zeros5d/docs/repl.txt deleted file mode 100644 index 05589c886..000000000 --- a/base/zeros5d/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( shape ) - Returns a zero-filled five-dimensional nested array. - - Parameters - ---------- - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 1, 1, 1, 3 ] ) - [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] - - See Also - -------- - diff --git a/base/zeros5d/docs/types/index.d.ts b/base/zeros5d/docs/types/index.d.ts deleted file mode 100644 index 8a82afa87..000000000 --- a/base/zeros5d/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape5D } from '@stdlib/types/ndarray'; - -/** -* Five-dimensional nested array. -*/ -type Array5D = Array>>>>; - -/** -* Returns a zero-filled five-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zeros5d( [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] -*/ -declare function zeros5d( shape: Shape5D ): Array5D; - - -// EXPORTS // - -export = zeros5d; diff --git a/base/zeros5d/docs/types/test.ts b/base/zeros5d/docs/types/test.ts deleted file mode 100644 index a77abe213..000000000 --- a/base/zeros5d/docs/types/test.ts +++ /dev/null @@ -1,44 +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. -*/ - -import zeros5d = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - zeros5d( [ 1, 1, 1, 1, 3 ] ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - zeros5d( 'abc' ); // $ExpectError - zeros5d( true ); // $ExpectError - zeros5d( false ); // $ExpectError - zeros5d( null ); // $ExpectError - zeros5d( [ '1' ] ); // $ExpectError - zeros5d( {} ); // $ExpectError - zeros5d( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros5d(); // $ExpectError - zeros5d( [ 1, 1, 1, 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/zeros5d/examples/index.js b/base/zeros5d/examples/index.js deleted file mode 100644 index 7ebdfc8da..000000000 --- a/base/zeros5d/examples/index.js +++ /dev/null @@ -1,29 +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'; - -var zeros5d = require( './../lib' ); - -var out = zeros5d( [ 1, 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] - -out = zeros5d( [ 1, 1, 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ] ] ] ] diff --git a/base/zeros5d/lib/index.js b/base/zeros5d/lib/index.js deleted file mode 100644 index c84c0d160..000000000 --- a/base/zeros5d/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Create a zero-filled five-dimensional nested array. -* -* @module @stdlib/array/base/zeros5d -* -* @example -* var zeros5d = require( '@stdlib/array/base/zeros5d' ); -* -* var out = zeros5d( [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/zeros5d/lib/main.js b/base/zeros5d/lib/main.js deleted file mode 100644 index d3c8f5a07..000000000 --- a/base/zeros5d/lib/main.js +++ /dev/null @@ -1,45 +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 filled5d = require( './../../../base/filled5d' ); - - -// MAIN // - -/** -* Returns a zero-filled five-dimensional nested array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = zeros5d( [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] -*/ -function zeros5d( shape ) { - return filled5d( 0.0, shape ); -} - - -// EXPORTS // - -module.exports = zeros5d; diff --git a/base/zeros5d/package.json b/base/zeros5d/package.json deleted file mode 100644 index 007c26e0a..000000000 --- a/base/zeros5d/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/array/base/zeros5d", - "version": "0.0.0", - "description": "Create a zero-filled five-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "5d", - "zeros" - ] -} diff --git a/base/zeros5d/test/test.js b/base/zeros5d/test/test.js deleted file mode 100644 index 2b70e386a..000000000 --- a/base/zeros5d/test/test.js +++ /dev/null @@ -1,257 +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 zeros5d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros5d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ - [ 0.0, 0.0, 0.0 ] - ] - ] - ] - ]; - actual = zeros5d( [ 1, 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ], - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ] - ] - ], - [ - [ - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ], - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ] - ] - ] - ]; - actual = zeros5d( [ 2, 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ], - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ] - ], - [ - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ], - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ] - ] - ] - ]; - actual = zeros5d( [ 1, 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = zeros5d( [ 0, 1, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zeros5d( [ 0, 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zeros5d( [ 0, 100, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = zeros5d( [ 1, 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = zeros5d( [ 2, 0, 2, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = zeros5d( [ 3, 0, 3, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = zeros5d( [ 1, 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = zeros5d( [ 1, 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = zeros5d( [ 1, 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = zeros5d( [ 1, 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = zeros5d( [ 1, 2, 1, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = zeros5d( [ 1, 3, 1, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fifth element equal to zero', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ [] ] - ] - ] - ]; - actual = zeros5d( [ 1, 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = zeros5d( [ 1, 2, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = zeros5d( [ 1, 3, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/zerosnd/README.md b/base/zerosnd/README.md deleted file mode 100644 index c211c33a7..000000000 --- a/base/zerosnd/README.md +++ /dev/null @@ -1,144 +0,0 @@ - - -# zerosnd - -> Create a zero-filled n-dimensional nested array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var zerosnd = require( '@stdlib/array/base/zerosnd' ); -``` - -#### zerosnd( shape ) - -Returns a zero-filled n-dimensional nested array. - -```javascript -var out = zerosnd( [ 2, 3 ] ); -// returns [ [ 0.0, 0.0, 0.0 ], [ 0.0, 0.0, 0.0 ] ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var zerosnd = require( '@stdlib/array/base/zerosnd' ); - -var out = zerosnd( [ 1, 3 ] ); -// returns [ [ 0.0, 0.0, 0.0 ] ] - -out = zerosnd( [ 3, 1 ] ); -// returns [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ] - -out = zerosnd( [ 1, 1, 3 ] ); -// returns [ [ [ 0.0, 0.0, 0.0 ] ] ] - -out = zerosnd( [ 1, 3, 1 ] ); -// returns [ [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ] ] - -out = zerosnd( [ 1, 1, 1, 3 ] ); -// returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/base/zerosnd/benchmark/benchmark.size.2d.js b/base/zerosnd/benchmark/benchmark.size.2d.js deleted file mode 100644 index f26c0556f..000000000 --- a/base/zerosnd/benchmark/benchmark.size.2d.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var zerosnd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = zerosnd( [ N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( sqrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::2d,equidimensional:size='+(N*N), f ); - } -} - -main(); diff --git a/base/zerosnd/benchmark/benchmark.size.3d.js b/base/zerosnd/benchmark/benchmark.size.3d.js deleted file mode 100644 index 83ffc2f06..000000000 --- a/base/zerosnd/benchmark/benchmark.size.3d.js +++ /dev/null @@ -1,96 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var cbrt = require( '@stdlib/math/base/special/cbrt' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var zerosnd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = zerosnd( [ N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( cbrt( pow( 10, i ) ) ); - - f = createBenchmark( N ); - bench( pkg+'::3d,equidimensional:size='+(N*N*N), f ); - } -} - -main(); diff --git a/base/zerosnd/benchmark/benchmark.size.4d.js b/base/zerosnd/benchmark/benchmark.size.4d.js deleted file mode 100644 index 0159c91da..000000000 --- a/base/zerosnd/benchmark/benchmark.size.4d.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var zerosnd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = zerosnd( [ N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::4d,equidimensional:size='+(N*N*N*N), f ); - } -} - -main(); diff --git a/base/zerosnd/benchmark/benchmark.size.5d.js b/base/zerosnd/benchmark/benchmark.size.5d.js deleted file mode 100644 index c0505581c..000000000 --- a/base/zerosnd/benchmark/benchmark.size.5d.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var zerosnd = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - array lengths -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = zerosnd( [ N, N, N, N, N ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( out ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/5.0 ) ); - - f = createBenchmark( N ); - bench( pkg+'::5d,equidimensional:size='+(N*N*N*N*N), f ); - } -} - -main(); diff --git a/base/zerosnd/docs/repl.txt b/base/zerosnd/docs/repl.txt deleted file mode 100644 index f580d1ff2..000000000 --- a/base/zerosnd/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( shape ) - Returns a zero-filled n-dimensional nested array. - - Parameters - ---------- - shape: Array - Array shape. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 3 ] ) - [ [ 0.0, 0.0, 0.0 ] ] - - See Also - -------- - diff --git a/base/zerosnd/docs/types/index.d.ts b/base/zerosnd/docs/types/index.d.ts deleted file mode 100644 index 6ac1768b0..000000000 --- a/base/zerosnd/docs/types/index.d.ts +++ /dev/null @@ -1,258 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Shape } from '@stdlib/types/ndarray'; - -/** -* One-dimensional array. -*/ -type Array1D = Array; - -/** -* One-dimensional array shape. -*/ -type Shape1D = [ number ]; - -/** -* Two-dimensional array. -*/ -type Array2D = Array>; - -/** -* Two-dimensional array shape. -*/ -type Shape2D = [ number, number ]; - -/** -* Three-dimensional array. -*/ -type Array3D = Array>; - -/** -* Three-dimensional array shape. -*/ -type Shape3D = [ number, number, number ]; - -/** -* Four-dimensional array. -*/ -type Array4D = Array>; - -/** -* Four-dimensional array shape. -*/ -type Shape4D = [ number, number, number, number ]; - -/** -* Five-dimensional array. -*/ -type Array5D = Array>; - -/** -* Five-dimensional array shape. -*/ -type Shape5D = [ number, number, number, number, number ]; - -/** -* Six-dimensional array. -*/ -type Array6D = Array>; - -/** -* Six-dimensional array shape. -*/ -type Shape6D = [ number, number, number, number, number, number ]; - -/** -* Seven-dimensional array. -*/ -type Array7D = Array>; - -/** -* Seven-dimensional array shape. -*/ -type Shape7D = [ number, number, number, number, number, number, number ]; - -/** -* Eight-dimensional array. -*/ -type Array8D = Array>; - -/** -* Eight-dimensional array shape. -*/ -type Shape8D = [ number, number, number, number, number, number, number, number ]; - -/** -* Nine-dimensional array. -*/ -type Array9D = Array>; - -/** -* Nine-dimensional array shape. -*/ -type Shape9D = [ number, number, number, number, number, number, number, number, number ]; - -/** -* Ten-dimensional array. -*/ -type Array10D = Array>; // WARNING: arbitrarily limited to 10 dimensions, which should be fine for most practical purposes - -/** -* Ten-dimensional array shape. -*/ -type Shape10D = [ number, number, number, number, number, number, number, number, number, number ]; - -/** -* Returns a zero-filled one-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zerosnd( [ 3 ] ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function zerosnd( shape: Shape1D ): Array1D; -/** -* Returns a zero-filled two-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zerosnd( [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -*/ -declare function zerosnd( shape: Shape2D ): Array2D; -/** -* Returns a zero-filled three-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zerosnd( [ 1, 1, 3 ] ); -* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ] -*/ -declare function zerosnd( shape: Shape3D ): Array3D; - -/** -* Returns a zero-filled four-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zerosnd( [ 1, 1, 1, 3 ] ); -* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] -*/ -declare function zerosnd( shape: Shape4D ): Array4D; - -/** -* Returns a zero-filled five-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zerosnd( [ 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] -*/ -declare function zerosnd( shape: Shape5D ): Array5D; - -/** -* Returns a zero-filled six-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zerosnd( [ 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] -*/ -declare function zerosnd( shape: Shape6D ): Array6D; - -/** -* Returns a zero-filled seven-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zerosnd( [ 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] -*/ -declare function zerosnd( shape: Shape7D ): Array7D; - -/** -* Returns a zero-filled eight-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zerosnd( [ 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] ] -*/ -declare function zerosnd( shape: Shape8D ): Array8D; - -/** -* Returns a zero-filled nine-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zerosnd( [ 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] ] ] -*/ -declare function zerosnd( shape: Shape9D ): Array9D; - -/** -* Returns a zero-filled ten-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zerosnd( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] ] ] ] -*/ -declare function zerosnd( shape: Shape10D ): Array10D; - -/** -* Returns a zero-filled n-dimensional nested array. -* -* @param shape - array shape -* @returns output array -* -* @example -* var out = zerosnd( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ] ); -* // returns [ [ [ [ [ [ [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ] ] ] ] ] ] -*/ -declare function zerosnd( shape: Shape ): Array; - - -// EXPORTS // - -export = zerosnd; diff --git a/base/zerosnd/docs/types/test.ts b/base/zerosnd/docs/types/test.ts deleted file mode 100644 index 5e604f6b9..000000000 --- a/base/zerosnd/docs/types/test.ts +++ /dev/null @@ -1,48 +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. -*/ - -import zerosnd = require( './index' ); - - -// TESTS // - -// The function returns a nested array... -{ - zerosnd( [ 3 ] ); // $ExpectType Array1D - zerosnd( [ 1, 3 ] ); // $ExpectType Array2D - zerosnd( [ 1, 1, 3 ] ); // $ExpectType Array3D - zerosnd( [ 1, 1, 1, 3 ] ); // $ExpectType Array4D - zerosnd( [ 1, 1, 1, 1, 3 ] ); // $ExpectType Array5D -} - -// The compiler throws an error if the function is provided a first argument which is not an array of numbers... -{ - zerosnd( 'abc' ); // $ExpectError - zerosnd( true ); // $ExpectError - zerosnd( false ); // $ExpectError - zerosnd( null ); // $ExpectError - zerosnd( [ '1' ] ); // $ExpectError - zerosnd( {} ); // $ExpectError - zerosnd( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zerosnd(); // $ExpectError - zerosnd( [ 1, 3 ], 2 ); // $ExpectError -} diff --git a/base/zerosnd/examples/index.js b/base/zerosnd/examples/index.js deleted file mode 100644 index 0dc47e18e..000000000 --- a/base/zerosnd/examples/index.js +++ /dev/null @@ -1,41 +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'; - -var zerosnd = require( './../lib' ); - -var out = zerosnd( [ 1, 3 ] ); -console.log( out ); -// => [ [ 0.0, 0.0, 0.0 ] ] - -out = zerosnd( [ 3, 1 ] ); -console.log( out ); -// => [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ] - -out = zerosnd( [ 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ 0.0, 0.0, 0.0 ] ] ] - -out = zerosnd( [ 1, 3, 1 ] ); -console.log( out ); -// => [ [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ] ] - -out = zerosnd( [ 1, 1, 1, 3 ] ); -console.log( out ); -// => [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] diff --git a/base/zerosnd/lib/index.js b/base/zerosnd/lib/index.js deleted file mode 100644 index 3fb21e566..000000000 --- a/base/zerosnd/lib/index.js +++ /dev/null @@ -1,40 +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'; - -/** -* Create a zero-filled n-dimensional nested array. -* -* @module @stdlib/array/base/zerosnd -* -* @example -* var zerosnd = require( '@stdlib/array/base/zerosnd' ); -* -* var out = zerosnd( [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/zerosnd/lib/main.js b/base/zerosnd/lib/main.js deleted file mode 100644 index a1618c5e0..000000000 --- a/base/zerosnd/lib/main.js +++ /dev/null @@ -1,49 +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 fillednd = require( './../../../base/fillednd' ); - - -// MAIN // - -/** -* Returns a zero-filled n-dimensional nested array. -* -* @param {NonNegativeIntegerArray} shape - array shape -* @returns {Array} filled array -* -* @example -* var out = zerosnd( [ 3 ] ); -* // returns [ 0.0, 0.0, 0.0 ] -* -* @example -* var out = zerosnd( [ 1, 3 ] ); -* // returns [ [ 0.0, 0.0, 0.0 ] ] -*/ -function zerosnd( shape ) { - return fillednd( 0.0, shape ); -} - - -// EXPORTS // - -module.exports = zerosnd; diff --git a/base/zerosnd/package.json b/base/zerosnd/package.json deleted file mode 100644 index 0ecf968bb..000000000 --- a/base/zerosnd/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/base/zerosnd", - "version": "0.0.0", - "description": "Create a zero-filled n-dimensional nested array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "allocate", - "alloc", - "fill", - "filled", - "multidimensional", - "matrix", - "cube", - "strided", - "ndarray", - "zeros" - ] -} diff --git a/base/zerosnd/test/test.js b/base/zerosnd/test/test.js deleted file mode 100644 index 0b36573f1..000000000 --- a/base/zerosnd/test/test.js +++ /dev/null @@ -1,616 +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 zerosnd = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zerosnd, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a filled nested array (0d)', function test( t ) { - var expected; - var actual; - - expected = []; - actual = zerosnd( [] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (1d)', function test( t ) { - var expected; - var actual; - - expected = [ 0.0, 0.0, 0.0 ]; - actual = zerosnd( [ 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (2d)', function test( t ) { - var expected; - var actual; - - expected = [ [ 0.0, 0.0, 0.0 ] ]; - actual = zerosnd( [ 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0.0 ], [ 0.0 ], [ 0.0 ] ]; - actual = zerosnd( [ 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ 0.0, 0.0 ], [ 0.0, 0.0 ], [ 0.0, 0.0 ] ]; - actual = zerosnd( [ 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (3d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ 0.0, 0.0, 0.0 ] - ] - ]; - actual = zerosnd( [ 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ], - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ] - ]; - actual = zerosnd( [ 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ], - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ] - ]; - actual = zerosnd( [ 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ 0.0, 0.0, 0.0 ] - ] - ] - ]; - actual = zerosnd( [ 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ], - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ] - ] - ]; - actual = zerosnd( [ 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ], - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ] - ], - [ - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ], - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ] - ] - ]; - actual = zerosnd( [ 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled nested array', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ - [ 0.0, 0.0, 0.0 ] - ] - ] - ] - ]; - actual = zerosnd( [ 1, 1, 1, 1, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ], - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ] - ] - ], - [ - [ - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ], - [ - [ 0.0 ], - [ 0.0 ], - [ 0.0 ] - ] - ] - ] - ]; - actual = zerosnd( [ 2, 1, 2, 3, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ], - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ] - ], - [ - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ], - [ - [ 0.0, 0.0 ], - [ 0.0, 0.0 ], - [ 0.0, 0.0 ] - ] - ] - ] - ]; - actual = zerosnd( [ 1, 2, 2, 3, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided a shape having a first element equal to zero (1d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = zerosnd( [ 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (2d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = zerosnd( [ 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zerosnd( [ 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zerosnd( [ 0, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (2d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = zerosnd( [ 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = zerosnd( [ 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = zerosnd( [ 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = zerosnd( [ 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zerosnd( [ 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zerosnd( [ 0, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = zerosnd( [ 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = zerosnd( [ 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = zerosnd( [ 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (3d)', function test( t ) { - var expected; - var actual; - - expected = [ [ [] ] ]; - actual = zerosnd( [ 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [] ] ]; - actual = zerosnd( [ 1, 2, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [ [], [], [] ] ]; - actual = zerosnd( [ 1, 3, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = zerosnd( [ 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zerosnd( [ 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zerosnd( [ 0, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = zerosnd( [ 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = zerosnd( [ 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = zerosnd( [ 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = zerosnd( [ 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = zerosnd( [ 1, 2, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = zerosnd( [ 1, 3, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero (4d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = zerosnd( [ 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = zerosnd( [ 1, 2, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = zerosnd( [ 1, 3, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty outer array if provided a shape having a first element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = zerosnd( [ 0, 1, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zerosnd( [ 0, 0, 0, 0, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zerosnd( [ 0, 100, 100, 100, 100 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a second element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ [] ]; - actual = zerosnd( [ 1, 0, 1, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [] ]; - actual = zerosnd( [ 2, 0, 2, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ [], [], [] ]; - actual = zerosnd( [ 3, 0, 3, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a third element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [] - ] - ]; - actual = zerosnd( [ 1, 1, 0, 1, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [] - ] - ]; - actual = zerosnd( [ 1, 2, 0, 2, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [], - [], - [] - ] - ]; - actual = zerosnd( [ 1, 3, 0, 3, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fourth element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ [] ] - ] - ]; - actual = zerosnd( [ 1, 1, 1, 0, 1 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ] - ] - ]; - actual = zerosnd( [ 1, 2, 1, 0, 2 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [] ], - [ [] ], - [ [] ] - ] - ]; - actual = zerosnd( [ 1, 3, 1, 0, 3 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty inner arrays if provided a shape having a fifth element equal to zero (5d)', function test( t ) { - var expected; - var actual; - - expected = [ - [ - [ - [ [] ] - ] - ] - ]; - actual = zerosnd( [ 1, 1, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = zerosnd( [ 1, 2, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ - [ - [ [ [] ] ], - [ [ [] ] ], - [ [ [] ] ] - ] - ]; - actual = zerosnd( [ 1, 3, 1, 1, 0 ] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/zip/README.md b/base/zip/README.md deleted file mode 100644 index 18bd089f5..000000000 --- a/base/zip/README.md +++ /dev/null @@ -1,97 +0,0 @@ - - -# zip - -> Zip one or more arrays. - -
- -## Usage - -```javascript -var zip = require( '@stdlib/array/base/zip' ); -``` - -#### zip( arrays ) - -Zips one or more arrays. - -```javascript -var x = [ 1, 2 ]; -var y = [ 3, 4 ]; - -var out = zip( [ x, y ] ); -// returns [ [ 1, 3 ], [ 2, 4 ] ] -``` - -The function supports the following parameters: - -- **arrays**: list of arrays to zip. - -
- - - -
- -- The function assumes that the list of arrays to be zipped all have the same length. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var zip = require( '@stdlib/array/base/zip' ); - -var x = zeroTo( 10 ); -var y = discreteUniform( x.length, -100, 100 ); - -var out = zip( [ x, y ] ); -// returns [...] -``` - -
- - - - - - - - - - - - - - diff --git a/base/zip/benchmark/benchmark.js b/base/zip/benchmark/benchmark.js deleted file mode 100644 index 6514412e2..000000000 --- a/base/zip/benchmark/benchmark.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var zip = require( './../lib' ); - - -// MAIN // - -bench( pkg+':len=10', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zip( [ x, x ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/zip/benchmark/benchmark.length.js b/base/zip/benchmark/benchmark.length.js deleted file mode 100644 index a27bb8a5c..000000000 --- a/base/zip/benchmark/benchmark.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var zip = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zip( [ x, x ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of arrays' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/zip/docs/repl.txt b/base/zip/docs/repl.txt deleted file mode 100644 index 97575ded2..000000000 --- a/base/zip/docs/repl.txt +++ /dev/null @@ -1,27 +0,0 @@ - -{{alias}}( arrays ) - Zips one or more arrays. - - The function assumes that the list of arrays to be zipped all have the same - length. - - Parameters - ---------- - arrays: ArrayLikeObject - List of arrays to zip. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2 ]; - > var y = [ 3, 4 ]; - > var out = {{alias}}( [ x, y ] ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/base/zip/docs/types/index.d.ts b/base/zip/docs/types/index.d.ts deleted file mode 100644 index 3665af969..000000000 --- a/base/zip/docs/types/index.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Zips one or more arrays. -* -* ## Notes -* -* - The function assumes that the list of arrays to be zipped all have the same length. -* -* @param arrays - list of arrays to be zipped -* @returns output array -* -* @example -* var x = [ 1, 2, 3 ]; -* var y = [ 'a', 'b', 'c' ]; -* -* var z = zip( [ x, y ] ); -* // returns [ [ 1, 'a' ], [ 2, 'b' ], [ 3, 'c' ] ] -*/ -declare function zip( arrays: ArrayLike | AccessorArrayLike> ): Array>; - - -// EXPORTS // - -export = zip; diff --git a/base/zip/docs/types/test.ts b/base/zip/docs/types/test.ts deleted file mode 100644 index bf0e708d5..000000000 --- a/base/zip/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zip = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - zip( [ [ 1, 2 ], [ 1, 3 ] ] ); // $ExpectType number[][] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - zip( 1 ); // $ExpectError - zip( true ); // $ExpectError - zip( false ); // $ExpectError - zip( null ); // $ExpectError - zip( void 0 ); // $ExpectError - zip( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zip(); // $ExpectError - zip( [], [] ); // $ExpectError - zip( [], [], [] ); // $ExpectError -} diff --git a/base/zip/examples/index.js b/base/zip/examples/index.js deleted file mode 100644 index 2ac168d4a..000000000 --- a/base/zip/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../../../base/zero-to' ); -var zip = require( './../lib' ); - -var x = zeroTo( 10 ); -var y = discreteUniform( x.length, -100, 100 ); - -var out = zip( [ x, y ] ); -console.log( out ); -// => [...] diff --git a/base/zip/lib/index.js b/base/zip/lib/index.js deleted file mode 100644 index db9b3b0d4..000000000 --- a/base/zip/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Zip one or more arrays. -* -* @module @stdlib/array/base/zip -* -* @example -* var zip = require( '@stdlib/array/base/zip' ); -* -* var x = [ 1, 2, 3 ]; -* var y = [ 'a', 'b', 'c' ]; -* -* var z = zip( [ x, y ] ); -* // returns [ [ 1, 'a' ], [ 2, 'b' ], [ 3, 'c' ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/zip/lib/main.js b/base/zip/lib/main.js deleted file mode 100644 index dee9c1f89..000000000 --- a/base/zip/lib/main.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); -var copy = require( './../../../base/copy' ); - - -// MAIN // - -/** -* Zips one or more arrays. -* -* ## Notes -* -* - The function assumes that the list of arrays to be zipped all have the same length. -* -* @param {Collection} arrays - list of arrays to be zipped -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3 ]; -* var y = [ 'a', 'b', 'c' ]; -* -* var z = zip( [ x, y ] ); -* // returns [ [ 1, 'a' ], [ 2, 'b' ], [ 3, 'c' ] ] -*/ -function zip( arrays ) { - var getters; - var list; - var out; - var arr; - var M; - var N; - var i; - var j; - - M = arrays.length; - if ( M < 1 ) { - return []; - } - list = copy( arrays ); - N = list[ 0 ].length; - if ( N < 1 ) { - return []; - } - getters = []; - for ( j = 0; j < M; j++ ) { - getters.push( resolveGetter( list[ j ] ) ); - } - out = []; - for ( i = 0; i < N; i++ ) { - arr = []; - for ( j = 0; j < M; j++ ) { - arr.push( getters[ j ]( list[ j ], i ) ); - } - out.push( arr ); - } - return out; -} - - -// EXPORTS // - -module.exports = zip; diff --git a/base/zip/package.json b/base/zip/package.json deleted file mode 100644 index 382841a2e..000000000 --- a/base/zip/package.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "@stdlib/array/base/zip", - "version": "0.0.0", - "description": "Zip one or more arrays.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "zip" - ] -} diff --git a/base/zip/test/test.js b/base/zip/test/test.js deleted file mode 100644 index 79c073b05..000000000 --- a/base/zip/test/test.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var zip = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zip, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided no input arrays (indexed)', function test( t ) { - var expected; - var actual; - - actual = zip( [] ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided no input arrays (accessors)', function test( t ) { - var expected; - var actual; - - actual = zip( toAccessorArray( [] ) ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty input arrays (indexed)', function test( t ) { - var expected; - var actual; - - actual = zip( [ [], [] ] ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty input arrays (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ toAccessorArray( [] ), toAccessorArray( [] ) ] ); - - actual = zip( x ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips one array to an array of arrays (indexed)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2 ]; - - actual = zip( [ x ] ); - expected = [ - [ 1 ], - [ 2 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips one array to an array of arrays (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = toAccessorArray( [ 1, 2 ] ); - - actual = zip( [ x ] ); - expected = [ - [ 1 ], - [ 2 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips two arrays to an array of arrays (indexed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 1, 2 ]; - y = [ 3, 4 ]; - - actual = zip( [ x, y ] ); - expected = [ - [ 1, 3 ], - [ 2, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips two arrays to an array of arrays (accessors)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 1, 2 ]; - y = [ 3, 4 ]; - - actual = zip( [ toAccessorArray( x ), y ] ); - expected = [ - [ 1, 3 ], - [ 2, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zip( [ x, toAccessorArray( y ) ] ); - expected = [ - [ 1, 3 ], - [ 2, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zip( [ toAccessorArray( x ), toAccessorArray( y ) ] ); - expected = [ - [ 1, 3 ], - [ 2, 4 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips three arrays to an array of arrays (indexed)', function test( t ) { - var expected; - var actual; - var x; - var y; - var z; - - x = [ 1, 2 ]; - y = [ 3, 4 ]; - z = [ 5, 6 ]; - - actual = zip( [ x, y, z ] ); - expected = [ - [ 1, 3, 5 ], - [ 2, 4, 6 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips three arrays to an array of arrays (accessors)', function test( t ) { - var expected; - var actual; - var x; - var y; - var z; - - x = toAccessorArray( [ 1, 2 ] ); - y = toAccessorArray( [ 3, 4 ] ); - z = toAccessorArray( [ 5, 6 ] ); - - actual = zip( [ x, y, z ] ); - expected = [ - [ 1, 3, 5 ], - [ 2, 4, 6 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/zip2object/README.md b/base/zip2object/README.md deleted file mode 100644 index daee563cf..000000000 --- a/base/zip2object/README.md +++ /dev/null @@ -1,98 +0,0 @@ - - -# zip2object - -> Create an object from a provided list of properties and a provided list of corresponding values. - -
- -## Usage - -```javascript -var zip2object = require( '@stdlib/array/base/zip2object' ); -``` - -#### zip2object( properties, values ) - -Returns an object from a provided list of properties and a provided list of corresponding values. - -```javascript -var properties = [ 'a', 'b' ]; -var values = [ 1, 2 ]; - -var out = zip2object( properties, values ); -// returns { 'a': 1, 'b': 2 } -``` - -The function supports the following parameters: - -- **properties**: list of properties. -- **values**: list of values. - -
- - - -
- -- The function assumes that both input arrays have the same length. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var zip2object = require( '@stdlib/array/base/zip2object' ); - -var x1 = zeroTo( 10 ); -var x2 = discreteUniform( x1.length, -100, 100 ); - -var out = zip2object( x1, x2 ); -// returns {...} -``` - -
- - - - - - - - - - - - - - diff --git a/base/zip2object/benchmark/benchmark.js b/base/zip2object/benchmark/benchmark.js deleted file mode 100644 index b462ff3bd..000000000 --- a/base/zip2object/benchmark/benchmark.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var zip2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+':len=10', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zip2object( x, x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( v ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/zip2object/benchmark/benchmark.length.js b/base/zip2object/benchmark/benchmark.length.js deleted file mode 100644 index 47abe3b1d..000000000 --- a/base/zip2object/benchmark/benchmark.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var pkg = require( './../package.json' ).name; -var zip2object = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zip2object( x, x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( v ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/zip2object/docs/repl.txt b/base/zip2object/docs/repl.txt deleted file mode 100644 index b5d726638..000000000 --- a/base/zip2object/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( properties, values ) - Creates an object from a provided list of properties and a provided list of - corresponding values. - - The function assumes that both input arrays are the same length. - - Parameters - ---------- - properties: ArrayLikeObject - List of properties. - - values: ArrayLikeObject - List of values. - - Returns - ------- - out: Object - Result. - - Examples - -------- - > var x1 = [ 1, 2 ]; - > var x2 = [ 3, 4 ]; - > var out = {{alias}}( x1, x2 ) - { '1': 3, '2': 4 } - - See Also - -------- - diff --git a/base/zip2object/docs/types/index.d.ts b/base/zip2object/docs/types/index.d.ts deleted file mode 100644 index dfda6d21b..000000000 --- a/base/zip2object/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Creates an object from a provided list of properties and a provided list of corresponding values. -* -* ## Notes -* -* - The function assumes that both input arrays are the same length. -* -* @param properties - list of properties -* @param values - list of values -* @returns result -* -* @example -* var properties = [ 1, 2 ]; -* var values = [ 3, 4 ]; -* -* var out = zip2object( properties, values ); -* // returns { '1': 3, '2': 4 } -*/ -declare function zip2object( properties: Collection | AccessorArrayLike, values: Collection | AccessorArrayLike ): Record; - - -// EXPORTS // - -export = zip2object; diff --git a/base/zip2object/docs/types/test.ts b/base/zip2object/docs/types/test.ts deleted file mode 100644 index efac14a2b..000000000 --- a/base/zip2object/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zip2object = require( './index' ); - - -// TESTS // - -// The function returns an object... -{ - zip2object( [ 1, 2 ], [ 1, 3 ] ); // $ExpectType Record<1 | 2, number> -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - zip2object( 1, [ 1, 3 ] ); // $ExpectError - zip2object( true, [ 1, 3 ] ); // $ExpectError - zip2object( false, [ 1, 3 ] ); // $ExpectError - zip2object( null, [ 1, 3 ] ); // $ExpectError - zip2object( void 0, [ 1, 3 ] ); // $ExpectError - zip2object( {}, [ 1, 3 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - zip2object( [], 1 ); // $ExpectError - zip2object( [], true ); // $ExpectError - zip2object( [], false ); // $ExpectError - zip2object( [], null ); // $ExpectError - zip2object( [], void 0 ); // $ExpectError - zip2object( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zip2object(); // $ExpectError - zip2object( [] ); // $ExpectError - zip2object( [], [], [] ); // $ExpectError -} diff --git a/base/zip2object/examples/index.js b/base/zip2object/examples/index.js deleted file mode 100644 index a3922b685..000000000 --- a/base/zip2object/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../../../base/zero-to' ); -var zip2object = require( './../lib' ); - -var x1 = zeroTo( 10 ); -var x2 = discreteUniform( x1.length, -100, 100 ); - -var out = zip2object( x1, x2 ); -console.log( out ); -// => {...} diff --git a/base/zip2object/lib/index.js b/base/zip2object/lib/index.js deleted file mode 100644 index f6376a48c..000000000 --- a/base/zip2object/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an object from a provided list of properties and a provided list of corresponding values. -* -* @module @stdlib/array/base/zip2object -* -* @example -* var zip2object = require( '@stdlib/array/base/zip2object' ); -* -* var props = [ 'a', 'b', 'c' ]; -* var values = [ 1, 2, 3 ]; -* -* var obj = zip2object( props, values ); -* // returns { 'a': 1, 'b': 2, 'c': 3 } -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/zip2object/lib/main.js b/base/zip2object/lib/main.js deleted file mode 100644 index 15ae39b96..000000000 --- a/base/zip2object/lib/main.js +++ /dev/null @@ -1,123 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( './../../../base/arraylike2object' ); - - -// FUNCTIONS // - -/** -* Zips accessor arrays to an object. -* -* @private -* @param {Object} properties - properties object -* @param {Object} values - values object -* @returns {Object} result -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -* -* var props = toAccessorArray( [ 'a', 'b', 'c' ] ); -* var values = toAccessorArray( [ 1, 2, 3 ] ); -* -* var obj = accessors( arraylike2object( props ), arraylike2object( values ) ); -* // returns { 'a': 1, 'b': 2, 'c': 3 } -*/ -function accessors( properties, values ) { - var pdata; - var vdata; - var pget; - var vget; - var out; - var i; - - pdata = properties.data; - pget = properties.accessors[ 0 ]; - - vdata = values.data; - vget = values.accessors[ 0 ]; - - out = {}; - for ( i = 0; i < pdata.length; i++ ) { - out[ pget( pdata, i ) ] = vget( vdata, i ); - } - return out; -} - -/** -* Zips indexed collections to an object. -* -* @private -* @param {Collection} properties - list of properties -* @param {Collection} values - list of values -* @returns {Object} result -* -* @example -* var props = [ 'a', 'b', 'c' ]; -* var values = [ 1, 2, 3 ]; -* -* var obj = indexed( props, values ); -* // returns { 'a': 1, 'b': 2, 'c': 3 } -*/ -function indexed( properties, values ) { - var out; - var i; - - out = {}; - for ( i = 0; i < properties.length; i++ ) { - out[ properties[ i ] ] = values[ i ]; - } - return out; -} - - -// MAIN // - -/** -* Creates an object from a provided list of properties and a provided list of corresponding values. -* -* @param {Collection} properties - list of properties -* @param {Collection} values - list of values -* @returns {Object} result -* -* @example -* var props = [ 'a', 'b', 'c' ]; -* var values = [ 1, 2, 3 ]; -* -* var obj = zip2object( props, values ); -* // returns { 'a': 1, 'b': 2, 'c': 3 } -*/ -function zip2object( properties, values ) { - var o1 = arraylike2object( properties ); - var o2 = arraylike2object( values ); - - if ( o1.accessorProtocol || o2.accessorProtocol ) { - return accessors( o1, o2 ); - } - return indexed( properties, values ); -} - - -// EXPORTS // - -module.exports = zip2object; diff --git a/base/zip2object/package.json b/base/zip2object/package.json deleted file mode 100644 index 94f57bd6f..000000000 --- a/base/zip2object/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "name": "@stdlib/array/base/zip2object", - "version": "0.0.0", - "description": "Create an object from a provided list of properties and a provided list of corresponding values.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "zip", - "object" - ] -} diff --git a/base/zip2object/test/test.js b/base/zip2object/test/test.js deleted file mode 100644 index 261778a37..000000000 --- a/base/zip2object/test/test.js +++ /dev/null @@ -1,76 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var zip2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zip2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function zips two arrays to an object (indexed)', function test( t ) { - var expected; - var actual; - - actual = zip2object( [ 1, 2 ], [ 3, 4 ] ); - expected = { - '1': 3, - '2': 4 - }; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips two arrays to an object (accessors)', function test( t ) { - var expected; - var actual; - - actual = zip2object( toAccessorArray( [ 1, 2 ] ), [ 3, 4 ] ); - expected = { - '1': 3, - '2': 4 - }; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zip2object( [ 1, 2 ], toAccessorArray( [ 3, 4 ] ) ); - expected = { - '1': 3, - '2': 4 - }; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zip2object( toAccessorArray( [ 1, 2 ] ), toAccessorArray( [ 3, 4 ] ) ); // eslint-disable-line max-len - expected = { - '1': 3, - '2': 4 - }; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/zip2objects/README.md b/base/zip2objects/README.md deleted file mode 100644 index a97f90b44..000000000 --- a/base/zip2objects/README.md +++ /dev/null @@ -1,103 +0,0 @@ - - -# zip2objects - -> Zip one or more arrays to an array of objects. - -
- -## Usage - -```javascript -var zip2objects = require( '@stdlib/array/base/zip2objects' ); -``` - -#### zip2objects( arrays, labels ) - -Zips one or more arrays to an array of objects. - -```javascript -var x = [ 1, 2 ]; -var y = [ 3, 4 ]; - -var labels = [ 'x', 'y' ]; - -var out = zip2objects( [ x, y ], labels ); -// returns [ { 'x': 1, 'y': 3 }, { 'x': 2, 'y': 4 } ] -``` - -The function supports the following parameters: - -- **arrays**: list of arrays to zip. -- **labels**: list of array labels. - -
- - - -
- -- The function assumes that the list of arrays to be zipped all have the same length. -- The number of provided array labels should equal the number of arrays to be zipped. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var zip2objects = require( '@stdlib/array/base/zip2objects' ); - -var x = zeroTo( 10 ); -var y = discreteUniform( x.length, -100, 100 ); - -var labels = [ 'x', 'y' ]; - -var out = zip2objects( [ x, y ], labels ); -// returns [...] -``` - -
- - - - - - - - - - - - - - diff --git a/base/zip2objects/benchmark/benchmark.js b/base/zip2objects/benchmark/benchmark.js deleted file mode 100644 index f1c7d9df7..000000000 --- a/base/zip2objects/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var zip2objects = require( './../lib' ); - - -// MAIN // - -bench( pkg+':len=10', function benchmark( b ) { - var labels; - var x; - var i; - var v; - - labels = [ 'x', 'y' ]; - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zip2objects( [ x, x ], labels ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/zip2objects/benchmark/benchmark.length.js b/base/zip2objects/benchmark/benchmark.length.js deleted file mode 100644 index b9096bf96..000000000 --- a/base/zip2objects/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var zip2objects = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var labels = [ 'x', 'y' ]; - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zip2objects( [ x, x ], labels ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/zip2objects/docs/repl.txt b/base/zip2objects/docs/repl.txt deleted file mode 100644 index 9d0e24fc8..000000000 --- a/base/zip2objects/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( arrays, labels ) - Zips one or more arrays to an array of objects. - - The function assumes that the list of arrays to be zipped all have the same - length. - - The number of provided array labels should equal the number of arrays to be - zipped. - - Parameters - ---------- - arrays: ArrayLikeObject - List of arrays to zip. - - labels: ArrayLikeObject - List of array labels. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2 ]; - > var y = [ 3, 4 ]; - > var labels = [ 'x', 'y' ]; - > var out = {{alias}}( [ x, y ], labels ) - [ { 'x': 1, 'y': 3 }, { 'x': 2, 'y': 4 } ] - - See Also - -------- - diff --git a/base/zip2objects/docs/types/index.d.ts b/base/zip2objects/docs/types/index.d.ts deleted file mode 100644 index 9e2d5123d..000000000 --- a/base/zip2objects/docs/types/index.d.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Zips one or more arrays to an array of objects. -* -* ## Notes -* -* - The function assumes that the list of arrays to be zipped all have the same length. -* - The number of provided array labels should equal the number of arrays to be zipped. -* -* @param arrays - list of arrays to be zipped -* @param labels - list of array labels -* @returns output array -* -* @example -* var x = [ 1, 2, 3 ]; -* var y = [ 'a', 'b', 'c' ]; -* -* var labels = [ 'x', 'y' ]; -* -* var z = zip2objects( [ x, y ], labels ); -* // returns [ { 'x': 1, 'y': 'a' }, { 'x': 2, 'y': 'b' }, { 'x': 3, 'y': 'c' } ] -*/ -declare function zip2objects( arrays: ArrayLike | AccessorArrayLike>, labels: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = zip2objects; diff --git a/base/zip2objects/docs/types/test.ts b/base/zip2objects/docs/types/test.ts deleted file mode 100644 index f6bc9fd74..000000000 --- a/base/zip2objects/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zip2objects = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - zip2objects( [ [ 1, 2 ], [ 1, 3 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - zip2objects( 1, [ 'x', 'y' ] ); // $ExpectError - zip2objects( true, [ 'x', 'y' ] ); // $ExpectError - zip2objects( false, [ 'x', 'y' ] ); // $ExpectError - zip2objects( null, [ 'x', 'y' ] ); // $ExpectError - zip2objects( void 0, [ 'x', 'y' ] ); // $ExpectError - zip2objects( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - zip2objects( [], 1 ); // $ExpectError - zip2objects( [], true ); // $ExpectError - zip2objects( [], false ); // $ExpectError - zip2objects( [], null ); // $ExpectError - zip2objects( [], void 0 ); // $ExpectError - zip2objects( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zip2objects(); // $ExpectError - zip2objects( [] ); // $ExpectError - zip2objects( [], [], [] ); // $ExpectError -} diff --git a/base/zip2objects/examples/index.js b/base/zip2objects/examples/index.js deleted file mode 100644 index facb3921b..000000000 --- a/base/zip2objects/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../../../base/zero-to' ); -var zip2objects = require( './../lib' ); - -var x = zeroTo( 10 ); -var y = discreteUniform( x.length, -100, 100 ); - -var labels = [ 'x', 'y' ]; - -var out = zip2objects( [ x, y ], labels ); -console.log( out ); -// => [...] diff --git a/base/zip2objects/lib/index.js b/base/zip2objects/lib/index.js deleted file mode 100644 index 9d2e811ed..000000000 --- a/base/zip2objects/lib/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Zip one or more arrays to an array of objects. -* -* @module @stdlib/array/base/zip2objects -* -* @example -* var zip2objects = require( '@stdlib/array/base/zip2objects' ); -* -* var x = [ 1, 2, 3 ]; -* var y = [ 'a', 'b', 'c' ]; -* -* var labels = [ 'x', 'y' ]; -* -* var z = zip2objects( [ x, y ], labels ); -* // returns [ { 'x': 1, 'y': 'a' }, { 'x': 2, 'y': 'b' }, { 'x': 3, 'y': 'c' } ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/zip2objects/lib/main.js b/base/zip2objects/lib/main.js deleted file mode 100644 index 24cfde77d..000000000 --- a/base/zip2objects/lib/main.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveGetter = require( './../../../base/resolve-getter' ); -var copy = require( './../../../base/copy' ); - - -// MAIN // - -/** -* Zips one or more arrays to an array of objects. -* -* ## Notes -* -* - The function assumes that the list of arrays to be zipped all have the same length. -* - The number of provided array labels should equal the number of arrays to be zipped. -* -* @param {Collection} arrays - list of arrays to be zipped -* @param {ArrayLikeObject} labels - list of array labels -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3 ]; -* var y = [ 'a', 'b', 'c' ]; -* -* var labels = [ 'x', 'y' ]; -* -* var z = zip2objects( [ x, y ], labels ); -* // returns [ { 'x': 1, 'y': 'a' }, { 'x': 2, 'y': 'b' }, { 'x': 3, 'y': 'c' } ] -*/ -function zip2objects( arrays, labels ) { - var getters; - var list; - var keys; - var get; - var out; - var obj; - var M; - var N; - var i; - var j; - - M = arrays.length; - if ( M < 1 ) { - return []; - } - list = copy( arrays ); - N = list[ 0 ].length; - if ( N < 1 ) { - return []; - } - getters = []; - - get = resolveGetter( labels ); - keys = []; - for ( j = 0; j < M; j++ ) { - getters.push( resolveGetter( list[ j ] ) ); - keys.push( get( labels, j ) ); - } - out = []; - for ( i = 0; i < N; i++ ) { - obj = {}; - for ( j = 0; j < M; j++ ) { - obj[ keys[ j ] ] = getters[ j ]( list[ j ], i ); - } - out.push( obj ); - } - return out; -} - - -// EXPORTS // - -module.exports = zip2objects; diff --git a/base/zip2objects/package.json b/base/zip2objects/package.json deleted file mode 100644 index 4c39abe98..000000000 --- a/base/zip2objects/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/zip2objects", - "version": "0.0.0", - "description": "Zip one or more arrays to an array of objects.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "zip", - "object", - "tidy" - ] -} diff --git a/base/zip2objects/test/test.js b/base/zip2objects/test/test.js deleted file mode 100644 index 90ee061a7..000000000 --- a/base/zip2objects/test/test.js +++ /dev/null @@ -1,287 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var zip2objects = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zip2objects, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided no input arrays (indexed)', function test( t ) { - var expected; - var actual; - var labels; - - labels = []; - - actual = zip2objects( [], labels ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided no input arrays (accessors)', function test( t ) { - var expected; - var actual; - var labels; - - labels = []; - - actual = zip2objects( toAccessorArray( [] ), labels ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty input arrays (indexed)', function test( t ) { - var expected; - var actual; - var labels; - - labels = [ 'x', 'y' ]; - - actual = zip2objects( [ [], [] ], labels ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty input arrays (accessors)', function test( t ) { - var expected; - var actual; - var labels; - var x; - - labels = [ 'x', 'y' ]; - - x = toAccessorArray( [ toAccessorArray( [] ), toAccessorArray( [] ) ] ); - - actual = zip2objects( x, labels ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips one array to an array of objects (indexed)', function test( t ) { - var expected; - var actual; - var labels; - var x; - - labels = [ 'x' ]; - - x = [ 1, 2 ]; - - actual = zip2objects( [ x ], labels ); - expected = [ - { - 'x': 1 - }, - { - 'x': 2 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips one array to an array of objects (accessors)', function test( t ) { - var expected; - var actual; - var labels; - var x; - - labels = [ 'x' ]; - - x = toAccessorArray( [ 1, 2 ] ); - - actual = zip2objects( [ x ], labels ); - expected = [ - { - 'x': 1 - }, - { - 'x': 2 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips two arrays to an array of objects (indexed)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var y; - - labels = [ 'x', 'y' ]; - - x = [ 1, 2 ]; - y = [ 3, 4 ]; - - actual = zip2objects( [ x, y ], labels ); - expected = [ - { - 'x': 1, - 'y': 3 - }, - { - 'x': 2, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips two arrays to an array of objects (accessors)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var y; - - labels = [ 'x', 'y' ]; - - x = [ 1, 2 ]; - y = [ 3, 4 ]; - - actual = zip2objects( [ toAccessorArray( x ), y ], labels ); - expected = [ - { - 'x': 1, - 'y': 3 - }, - { - 'x': 2, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zip2objects( [ x, toAccessorArray( y ) ], labels ); - expected = [ - { - 'x': 1, - 'y': 3 - }, - { - 'x': 2, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zip2objects( [ toAccessorArray( x ), toAccessorArray( y ) ], toAccessorArray( labels ) ); // eslint-disable-line max-len - expected = [ - { - 'x': 1, - 'y': 3 - }, - { - 'x': 2, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips three arrays to an array of objects (indexed)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var y; - var z; - - labels = [ 'x', 'y', 'z' ]; - - x = [ 1, 2 ]; - y = [ 3, 4 ]; - z = [ 5, 6 ]; - - actual = zip2objects( [ x, y, z ], labels ); - expected = [ - { - 'x': 1, - 'y': 3, - 'z': 5 - }, - { - 'x': 2, - 'y': 4, - 'z': 6 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips three arrays to an array of objects (accessors)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var y; - var z; - - labels = toAccessorArray( [ 'x', 'y', 'z' ] ); - - x = toAccessorArray( [ 1, 2 ] ); - y = toAccessorArray( [ 3, 4 ] ); - z = toAccessorArray( [ 5, 6 ] ); - - actual = zip2objects( [ x, y, z ], labels ); - expected = [ - { - 'x': 1, - 'y': 3, - 'z': 5 - }, - { - 'x': 2, - 'y': 4, - 'z': 6 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/base/zip2views/README.md b/base/zip2views/README.md deleted file mode 100644 index 1f5db322f..000000000 --- a/base/zip2views/README.md +++ /dev/null @@ -1,130 +0,0 @@ - - -# zip2views - -> Zip one or more arrays to an array of composite views. - -
- -## Usage - -```javascript -var zip2views = require( '@stdlib/array/base/zip2views' ); -``` - -#### zip2views( arrays, labels ) - -Zips one or more arrays to an array of composite views. - -```javascript -var x = [ 1, 2, 3 ]; -var y = [ 'a', 'b', 'c' ]; - -var labels = [ 'x', 'y' ]; - -var z = zip2views( [ x, y ], labels ); -// returns [ , , ] - -var v0 = z[ 0 ].toJSON(); -// returns { 'x': 1, 'y': 'a' } - -var v1 = z[ 1 ].toJSON(); -// returns { 'x': 2, 'y': 'b' } - -var v2 = z[ 2 ].toJSON(); -// returns { 'x': 3, 'y': 'c' } - -// Mutate one of the input arrays: -x[ 0 ] = 5; - -v0 = z[ 0 ].toJSON(); -// returns { 'x': 5, 'y': 'a' } - -// Set a view property: -z[ 1 ].y = 'beep'; - -v1 = z[ 1 ].toJSON(); -// returns { 'x': 2, 'y': 'beep' } - -var y1 = y.slice(); -// returns [ 'a', 'beep', 'c' ] -``` - -The function supports the following parameters: - -- **arrays**: list of arrays to zip. -- **labels**: list of array labels. - -Each element in the returned array is a class instance having prototype properties corresponding to the list of array labels. As demonstrated in the example above, to convert an element to a regular object, invoke an element's `toJSON` method. Note, however, that the object returned by an element's `toJSON` method no longer shares the same memory as the provided input arrays. - - - - - -
- -- The function assumes that the list of arrays to be zipped all have the same length. -- The number of provided array labels should equal the number of arrays to be zipped. -- Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either an input array or a view will mutate the other. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( '@stdlib/array/base/zero-to' ); -var zip2views = require( '@stdlib/array/base/zip2views' ); - -var x = zeroTo( 10 ); -var y = discreteUniform( x.length, -100, 100 ); - -var labels = [ 'x', 'y' ]; - -var out = zip2views( [ x, y ], labels ); -// returns [...] -``` - -
- - - - - - - - - - - - - - diff --git a/base/zip2views/benchmark/benchmark.js b/base/zip2views/benchmark/benchmark.js deleted file mode 100644 index 92b95ce4b..000000000 --- a/base/zip2views/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var zip2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':len=10', function benchmark( b ) { - var labels; - var x; - var i; - var v; - - labels = [ 'x', 'y' ]; - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zip2views( [ x, x ], labels ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/base/zip2views/benchmark/benchmark.length.js b/base/zip2views/benchmark/benchmark.length.js deleted file mode 100644 index 1c2b771c7..000000000 --- a/base/zip2views/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../../base/zero-to' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var zip2views = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var labels = [ 'x', 'y' ]; - var x = zeroTo( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = zip2views( [ x, x ], labels ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/base/zip2views/docs/repl.txt b/base/zip2views/docs/repl.txt deleted file mode 100644 index 0a043417d..000000000 --- a/base/zip2views/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( arrays, labels ) - Zips one or more arrays to an array of composite views. - - The function assumes that the list of arrays to be zipped all have the same - length. - - The number of provided array labels should equal the number of arrays to be - zipped. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either an input array - or a view will mutate the other. - - Parameters - ---------- - arrays: ArrayLikeObject - List of arrays to zip. - - labels: ArrayLikeObject - List of array labels. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ 1, 2 ]; - > var y = [ 3, 4 ]; - > var labels = [ 'x', 'y' ]; - > var out = {{alias}}( [ x, y ], labels ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 3 } - > v = out[ 1 ].toJSON() - { 'x': 2, 'y': 4 } - - See Also - -------- - diff --git a/base/zip2views/docs/types/index.d.ts b/base/zip2views/docs/types/index.d.ts deleted file mode 100644 index a2d26dbac..000000000 --- a/base/zip2views/docs/types/index.d.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Zips one or more arrays to an array of composite views. -* -* ## Notes -* -* - The function assumes that the list of arrays to be zipped all have the same length. -* - The number of provided array labels should equal the number of arrays to be zipped. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either an input array or a view will mutate the other. -* -* @param arrays - list of arrays to be zipped -* @param labels - list of array labels -* @returns output array -* -* @example -* var x = [ 1, 2, 3 ]; -* var y = [ 'a', 'b', 'c' ]; -* -* var labels = [ 'x', 'y' ]; -* -* var z = zip2views( [ x, y ], labels ); -* // returns [ , , ] -* -* var v0 = z[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 'a' } -* -* var v1 = z[ 1 ].toJSON(); -* // returns { 'x': 2, 'y': 'b' } -* -* var v2 = z[ 2 ].toJSON(); -* // returns { 'x': 3, 'y': 'c' } -* -* // Mutate one of the input arrays: -* x[ 0 ] = 5; -* -* v0 = z[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 'a' } -* -* // Set a view property: -* z[ 1 ].y = 'beep'; -* -* v1 = z[ 1 ].toJSON(); -* // returns { 'x': 2, 'y': 'beep' } -* -* var y1 = y.slice(); -* // returns [ 'a', 'beep', 'c' ] -*/ -declare function zip2views( arrays: ArrayLike | AccessorArrayLike>, labels: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = zip2views; diff --git a/base/zip2views/docs/types/test.ts b/base/zip2views/docs/types/test.ts deleted file mode 100644 index ff8974c85..000000000 --- a/base/zip2views/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import zip2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - zip2views( [ [ 1, 2 ], [ 1, 3 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - zip2views( 1, [ 'x', 'y' ] ); // $ExpectError - zip2views( true, [ 'x', 'y' ] ); // $ExpectError - zip2views( false, [ 'x', 'y' ] ); // $ExpectError - zip2views( null, [ 'x', 'y' ] ); // $ExpectError - zip2views( void 0, [ 'x', 'y' ] ); // $ExpectError - zip2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - zip2views( [], 1 ); // $ExpectError - zip2views( [], true ); // $ExpectError - zip2views( [], false ); // $ExpectError - zip2views( [], null ); // $ExpectError - zip2views( [], void 0 ); // $ExpectError - zip2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zip2views(); // $ExpectError - zip2views( [] ); // $ExpectError - zip2views( [], [], [] ); // $ExpectError -} diff --git a/base/zip2views/examples/index.js b/base/zip2views/examples/index.js deleted file mode 100644 index 0f76bfbfe..000000000 --- a/base/zip2views/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../../../base/zero-to' ); -var zip2views = require( './../lib' ); - -var x = zeroTo( 10 ); -var y = discreteUniform( x.length, -100, 100 ); - -var labels = [ 'x', 'y' ]; - -var out = zip2views( [ x, y ], labels ); -console.log( out ); -// => [...] diff --git a/base/zip2views/lib/index.js b/base/zip2views/lib/index.js deleted file mode 100644 index 84622a6a6..000000000 --- a/base/zip2views/lib/index.js +++ /dev/null @@ -1,69 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Zip one or more arrays to an array of composite views. -* -* @module @stdlib/array/base/zip2views -* -* @example -* var zip2views = require( '@stdlib/array/base/zip2views' ); -* -* var x = [ 1, 2, 3 ]; -* var y = [ 'a', 'b', 'c' ]; -* -* var labels = [ 'x', 'y' ]; -* -* var z = zip2views( [ x, y ], labels ); -* // returns [ , , ] -* -* var v0 = z[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 'a' } -* -* var v1 = z[ 1 ].toJSON(); -* // returns { 'x': 2, 'y': 'b' } -* -* var v2 = z[ 2 ].toJSON(); -* // returns { 'x': 3, 'y': 'c' } -* -* // Mutate one of the input arrays: -* x[ 0 ] = 5; -* -* v0 = z[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 'a' } -* -* // Set a view property: -* z[ 1 ].y = 'beep'; -* -* v1 = z[ 1 ].toJSON(); -* // returns { 'x': 2, 'y': 'beep' } -* -* var y1 = y.slice(); -* // returns [ 'a', 'beep', 'c' ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/base/zip2views/lib/main.js b/base/zip2views/lib/main.js deleted file mode 100644 index 0ab2b2de7..000000000 --- a/base/zip2views/lib/main.js +++ /dev/null @@ -1,202 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var setReadWriteAccessor = require( '@stdlib/utils/define-read-write-accessor' ); -var accessors = require( './../../../base/accessors' ); -var copy = require( './../../../base/copy' ); - - -// MAIN // - -/** -* Zips one or more arrays to an array of composite views. -* -* ## Notes -* -* - The function assumes that the list of arrays to be zipped all have the same length. -* - The list of provided array labels should equal the number of arrays to be zipped. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either an input array or a view will mutate the other. -* -* @param {Collection} arrays - list of arrays to be zipped -* @param {ArrayLikeObject} labels - list of array labels -* @returns {Array} output array -* -* @example -* var x = [ 1, 2, 3 ]; -* var y = [ 'a', 'b', 'c' ]; -* -* var labels = [ 'x', 'y' ]; -* -* var z = zip2views( [ x, y ], labels ); -* // returns [ , , ] -* -* var v0 = z[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 'a' } -* -* var v1 = z[ 1 ].toJSON(); -* // returns { 'x': 2, 'y': 'b' } -* -* var v2 = z[ 2 ].toJSON(); -* // returns { 'x': 3, 'y': 'c' } -* -* // Mutate one of the input arrays: -* x[ 0 ] = 5; -* -* v0 = z[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 'a' } -* -* // Set a view property: -* z[ 1 ].y = 'beep'; -* -* v1 = z[ 1 ].toJSON(); -* // returns { 'x': 2, 'y': 'beep' } -* -* var y1 = y.slice(); -* // returns [ 'a', 'beep', 'c' ] -*/ -function zip2views( arrays, labels ) { - var getter; - var setter; - var list; - var keys; - var out; - var acc; - var M; - var N; - var i; - - M = arrays.length; - if ( M < 1 ) { - return []; - } - list = copy( arrays ); - N = list[ 0 ].length; - if ( N < 1 ) { - return []; - } - // Resolve element accessors... - acc = []; - for ( i = 0; i < M; i++ ) { - acc.push( accessors( list[ i ] ).accessors ); - } - // Create a copy of provided labels to prevent external mutation: - keys = copy( labels ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view of zipped elements. - * - * @private - * @constructor - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( i ) { - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define read/write accessors for each label... - for ( i = 0; i < M; i++ ) { - getter = getValue( list[ i ], acc[ i ][ 0 ] ); - setter = setValue( list[ i ], acc[ i ][ 1 ] ); - setReadWriteAccessor( Datum.prototype, keys[ i ], getter, setter ); - } - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < N; i++ ) { - out.push( new Datum( i ) ); - } - return out; - - /** - * Returns an accessor for returning the value associated with a label. - * - * @private - * @param {Collection} arr - input array - * @param {Function} getter - array element accessor - * @returns {Function} accessor - */ - function getValue( arr, getter ) { - return get; - - /** - * Returns the value associated with a label. - * - * @private - * @returns {*} result - */ - function get() { - return getter( arr, this._i ); // eslint-disable-line no-invalid-this - } - } - - /** - * Returns an accessor for setting the value associated with a label. - * - * @private - * @param {Collection} arr - input array - * @param {Function} setter - array element accessor - * @returns {Function} accessor - */ - function setValue( arr, setter ) { - return set; - - /** - * Sets the value associated with a label. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - setter( arr, this._i, value ); // eslint-disable-line no-invalid-this - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < M; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; // eslint-disable-line no-invalid-this - } - return out; - } -} - - -// EXPORTS // - -module.exports = zip2views; diff --git a/base/zip2views/package.json b/base/zip2views/package.json deleted file mode 100644 index 628c16607..000000000 --- a/base/zip2views/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "name": "@stdlib/array/base/zip2views", - "version": "0.0.0", - "description": "Zip one or more arrays to an array of composite views.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "zip", - "object", - "tidy" - ] -} diff --git a/base/zip2views/test/test.js b/base/zip2views/test/test.js deleted file mode 100644 index c652c02a6..000000000 --- a/base/zip2views/test/test.js +++ /dev/null @@ -1,402 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var toAccessorArray = require( './../../../base/to-accessor-array' ); -var zip2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zip2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided no input arrays (indexed)', function test( t ) { - var expected; - var actual; - var labels; - - labels = []; - - actual = zip2views( [], labels ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided no input arrays (accessors)', function test( t ) { - var expected; - var actual; - var labels; - - labels = []; - - actual = zip2views( toAccessorArray( [] ), labels ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty input arrays (indexed)', function test( t ) { - var expected; - var actual; - var labels; - - labels = [ 'x', 'y' ]; - - actual = zip2views( [ [], [] ], labels ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty input arrays (accessors)', function test( t ) { - var expected; - var actual; - var labels; - var x; - - labels = [ 'x', 'y' ]; - - x = toAccessorArray( [ toAccessorArray( [] ), toAccessorArray( [] ) ] ); - - actual = zip2views( x, labels ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips one array to an array of objects (indexed)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var i; - - labels = [ 'x' ]; - - x = [ 1, 2 ]; - - actual = zip2views( [ x ], labels ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1 - }, - { - 'x': 2 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips one array to an array of objects (accessors)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var i; - - labels = [ 'x' ]; - - x = toAccessorArray( [ 1, 2 ] ); - - actual = zip2views( [ x ], labels ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1 - }, - { - 'x': 2 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips two arrays to an array of objects (indexed)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var y; - var i; - - labels = [ 'x', 'y' ]; - - x = [ 1, 2 ]; - y = [ 3, 4 ]; - - actual = zip2views( [ x, y ], labels ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 3 - }, - { - 'x': 2, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips two arrays to an array of objects (accessors)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var y; - var i; - - labels = [ 'x', 'y' ]; - - x = [ 1, 2 ]; - y = [ 3, 4 ]; - - actual = zip2views( [ toAccessorArray( x ), y ], labels ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 3 - }, - { - 'x': 2, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zip2views( [ x, toAccessorArray( y ) ], labels ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 3 - }, - { - 'x': 2, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = zip2views( [ toAccessorArray( x ), toAccessorArray( y ) ], toAccessorArray( labels ) ); // eslint-disable-line max-len - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 3 - }, - { - 'x': 2, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips three arrays to an array of objects (indexed)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var y; - var z; - var i; - - labels = [ 'x', 'y', 'z' ]; - - x = [ 1, 2 ]; - y = [ 3, 4 ]; - z = [ 5, 6 ]; - - actual = zip2views( [ x, y, z ], labels ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 3, - 'z': 5 - }, - { - 'x': 2, - 'y': 4, - 'z': 6 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function zips three arrays to an array of objects (accessors)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var y; - var z; - var i; - - labels = toAccessorArray( [ 'x', 'y', 'z' ] ); - - x = toAccessorArray( [ 1, 2 ] ); - y = toAccessorArray( [ 3, 4 ] ); - z = toAccessorArray( [ 5, 6 ] ); - - actual = zip2views( [ x, y, z ], labels ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 3, - 'z': 5 - }, - { - 'x': 2, - 'y': 4, - 'z': 6 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var y; - - labels = [ 'x', 'y' ]; - - x = [ 1, 2 ]; - y = [ 3, 4 ]; - - actual = zip2views( [ x, y ], labels ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 3, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 2, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].x = -99; - actual[ 1 ].y = 99; - - t.strictEqual( actual[ 0 ].x, -99, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 3, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 2, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 99, 'returns expected value' ); - - expected = [ -99, 2 ]; - t.deepEqual( x, expected, 'returns expected value' ); - - expected = [ 3, 99 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var labels; - var x; - var y; - - labels = [ 'x', 'y' ]; - - x = [ 1, 2 ]; - y = [ 3, 4 ]; - - actual = zip2views( [ toAccessorArray( x ), toAccessorArray( y ) ], labels ); // eslint-disable-line max-len - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 3, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 2, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].x = -99; - actual[ 1 ].y = 99; - - t.strictEqual( actual[ 0 ].x, -99, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 3, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 2, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 99, 'returns expected value' ); - - expected = [ -99, 2 ]; - t.deepEqual( x, expected, 'returns expected value' ); - - expected = [ 3, 99 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/bool/README.md b/bool/README.md deleted file mode 100644 index 5036215f1..000000000 --- a/bool/README.md +++ /dev/null @@ -1,1858 +0,0 @@ - - -# BooleanArray - -> Boolean array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var BooleanArray = require( '@stdlib/array/bool' ); -``` - - - -#### BooleanArray() - -Creates a boolean array. - -```javascript -var arr = new BooleanArray(); -// returns -``` - -#### BooleanArray( length ) - -Creates a boolean array having a specified `length`. - -```javascript -var arr = new BooleanArray( 10 ); -// returns - -var len = arr.length; -// returns 10 -``` - -#### BooleanArray( booleanarray ) - -Creates a boolean array from another boolean array. - -```javascript -var arr1 = new BooleanArray( [ true, false, false, true ] ); -// returns - -var arr2 = new BooleanArray( arr1 ); -// returns - -var len = arr2.length; -// returns 4 -``` - -#### BooleanArray( typedarray ) - -Creates a boolean array from a [typed array][@stdlib/array/typed]. - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); - -var buf = new Uint8Array( [ 1, 0, 0, 1 ] ); -// returns [ 1, 0, 0, 1 ] - -var arr = new BooleanArray( buf ); -// returns - -var len = arr.length; -// returns 4 -``` - -#### BooleanArray( obj ) - -Creates a boolean array from an array-like object or iterable. - -```javascript -// From an array of booleans: -var arr1 = new BooleanArray( [ true, false, false, true ] ); -// returns - -var len = arr1.length; -// returns 4 - -// From an array containing non-booleans: -var arr2 = new BooleanArray( [ {}, null, '', 4 ] ); - -len = arr2.length; -// returns 4 -``` - -#### BooleanArray( buffer\[, byteOffset\[, length]] ) - -Returns a boolean array view of an [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); -var buf = new ArrayBuffer( 240 ); - -var arr1 = new BooleanArray( buf ); -// returns - -var len = arr1.length; -// returns 240 - -var arr2 = new BooleanArray( buf, 8 ); -// returns - -len = arr2.length; -// returns 232 - -var arr3 = new BooleanArray( buf, 8, 20 ); -// returns - -len = arr3.length; -// returns 20 -``` - -* * * - -### Properties - - - -#### BooleanArray.BYTES_PER_ELEMENT - -Static property returning the size (in bytes) of each array element. - -```javascript -var nbytes = BooleanArray.BYTES_PER_ELEMENT; -// returns 1 -``` - - - -#### BooleanArray.name - -Static property returning the constructor name. - -```javascript -var str = BooleanArray.name; -// returns 'BooleanArray' -``` - - - -#### BooleanArray.prototype.buffer - -Pointer to the underlying data buffer. - -```javascript -var arr = new BooleanArray( 2 ); -// returns - -var buf = arr.buffer; -// returns -``` - - - -#### BooleanArray.prototype.byteLength - -Size (in bytes) of the array. - -```javascript -var arr = new BooleanArray( 10 ); -// returns - -var nbytes = arr.byteLength; -// returns 10 -``` - - - -#### BooleanArray.prototype.byteOffset - -Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var arr = new BooleanArray( 10 ); -// returns - -var offset = arr.byteOffset; -// returns 0 - -var buf = new ArrayBuffer( 240 ); -arr = new BooleanArray( buf, 64 ); -// returns - -offset = arr.byteOffset; -// returns 64 -``` - - - -#### BooleanArray.prototype.BYTES_PER_ELEMENT - -Size (in bytes) of each array element. - -```javascript -var arr = new BooleanArray( 10 ); -// returns - -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 1 -``` - - - -#### BooleanArray.prototype.length - -Number of array elements. - -```javascript -var arr = new BooleanArray( 10 ); -// returns - -var len = arr.length; -// returns 10 -``` - -* * * - -### Methods - - - -#### BooleanArray.from( src\[, clbk\[, thisArg]] ) - -Creates a new boolean array from an array-like object or an iterable. - -```javascript -var arr = BooleanArray.from( [ true, false ] ); -// returns - -var len = arr.length; -// returns 2 -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function map( v ) { - return !v; -} - -// Create a source array: -var src = [ true, false ]; - -// Create a new boolean array by inverting the source array: -var arr = BooleanArray.from( src, map ); -// returns - -var len = arr.length; -// returns 2 - -var v = arr.get( 0 ); -// returns false - -v = arr.get( 1 ); -// returns true -``` - -A callback function is provided two arguments: - -- **value**: source value. -- **index**: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function map( v ) { - this.count += 1; - return !v; -} - -// Create a source array: -var src = [ true, false ]; - -// Define an execution context: -var ctx = { - 'count': 0 -}; - -// Create a new boolean array by inverting the source array: -var arr = BooleanArray.from( src, map, ctx ); -// returns - -var len = arr.length; -// returns 2 - -var n = ctx.count; -// returns 2 -``` - - - -#### BooleanArray.of( element0\[, element1\[, ...elementN]] ) - -Creates a new boolean array from a variable number of arguments. - -```javascript -var arr = BooleanArray.of( true, false, false, true ); -// returns - -var len = arr.length; -// returns 4 -``` - - - -#### BooleanArray.prototype.at( i ) - -Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer positions. - -```javascript -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var v = arr.at( 0 ); -// returns true - -v = arr.at( -1 ); -// returns true -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var arr = new BooleanArray( 10 ); - -var v = arr.at( 100 ); -// returns undefined - -v = arr.at( -100 ); -// returns undefined -``` - - - -#### BooleanArray.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within the array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - -```javascript -var arr = new BooleanArray( 4 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( false, 2 ); -arr.set( true, 3 ); - -var v = arr.get( 0 ); -// returns true - -v = arr.get( 1 ); -// returns false - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 2 ); - -v = arr.get( 0 ); -// returns false - -v = arr.get( 1 ); -// returns true -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - -```javascript -var arr = new BooleanArray( 4 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( false, 2 ); -arr.set( true, 3 ); - -var v = arr.get( 2 ); -// returns false - -v = arr.get( 3 ); -// returns true - -// Copy the first two elements to the last two elements: -arr.copyWithin( 2, 0, 2 ); - -v = arr.get( 2 ); -// returns true - -v = arr.get( 3 ); -// returns false -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - -```javascript -var arr = new BooleanArray( 4 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( false, 2 ); -arr.set( true, 3 ); - -var v = arr.get( 2 ); -// returns false - -v = arr.get( 3 ); -// returns true - -// Copy the first two elements to the last two elements using negative indices: -arr.copyWithin( -2, -4, -2 ); - -v = arr.get( 2 ); -// returns true - -v = arr.get( 3 ); -// returns false -``` - - - -#### BooleanArray.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - -```javascript -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var it = arr.entries(); - -var v = it.next().value; -// returns [ 0, true ] - -v = it.next().value; -// returns [ 1, false ] - -v = it.next().value; -// returns [ 2, true ] - -var bool = it.next().done; -// returns true -``` - -The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: - -- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. -- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. - - - -#### BooleanArray.prototype.every( predicate\[, thisArg] ) - -Returns a boolean indicating whether all elements pass a test. - -```javascript -function predicate( v ) { - return v === true; -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( true, 1 ); -arr.set( true, 2 ); - -var bool = arr.every( predicate ); -// returns true -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function predicate( v ) { - this.count += 1; - return v === true; -} - -var arr = new BooleanArray( 3 ); - -var context = { - 'count': 0 -}; - -arr.set( true, 0 ); -arr.set( true, 1 ); -arr.set( true, 2 ); - -var bool = arr.every( predicate, context ); -// returns true - -var count = context.count; -// returns 3 -``` - - - -#### BooleanArray.prototype.fill( value\[, start\[, end]] ) - -Returns a modified typed array filled with a fill value. - -```javascript -var arr = new BooleanArray( 3 ); - -// Set all elements to the same value: -arr.fill( true ); - -var v = arr.get( 0 ); -// returns true - -v = arr.get( 1 ); -// returns true - -v = arr.get( 2 ); -// returns true - -// Fill all elements starting from the second element: -arr.fill( false, 1 ); - -v = arr.get( 1 ); -// returns false - -v = arr.get( 2 ); -// returns false - -// Fill all elements from first element until the second-to-last element: -arr.fill( false, 0, 2 ); - -v = arr.get( 0 ); -// returns false - -v = arr.get( 1 ); -// returns false -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - -```javascript -var arr = new BooleanArray( 3 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( true, 0, -1 ); - -var v = arr.get( 0 ); -// returns true - -v = arr.get( 2 ); -// returns false -``` - - - -#### BooleanArray.prototype.filter( predicate\[, thisArg] ) - -Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - -```javascript -function predicate( v ) { - return ( v === true ); -} - -var arr = new BooleanArray( 3 ); - -// Set the first three elements: -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var out = arr.filter( predicate ); -// returns - -var len = out.length; -// returns 2 - -var v = out.get( 0 ); -// returns true - -v = out.get( 1 ); -// return true -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function predicate( v, i ) { - this.count += 1; - return ( v === true ); -} - -var arr = new BooleanArray( 3 ); - -var context = { - 'count': 0 -}; - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var out = arr.filter( predicate, context ); -// returns - -var len = out.length; -// returns 2 - -var count = context.count; -// returns 3 -``` - - - -#### BooleanArray.prototype.find( predicate\[, thisArg] ) - -Returns the first element in an array for which a predicate function returns a truthy value. - -```javascript -function predicate( v ) { - return v === true; -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var v = arr.find( predicate ); -// returns true -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function predicate( v ) { - this.count += 1; - return ( v === true ); -} - -var arr = new BooleanArray( 3 ); - -var context = { - 'count': 0 -}; - -arr.set( false, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var z = arr.find( predicate, context ); -// returns true - -var count = context.count; -// returns 3 -``` - - - -#### BooleanArray.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first element in an array for which a predicate function returns a truthy value. - -```javascript -function predicate( v ) { - return v === true; -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var v = arr.findIndex( predicate ); -// returns 0 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function predicate( v ) { - this.count += 1; - return ( v === true ); -} - -var arr = new BooleanArray( 3 ); - -var context = { - 'count': 0 -}; - -arr.set( false, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var z = arr.findIndex( predicate, context ); -// returns 2 - -var count = context.count; -// returns 3 -``` - - - -#### BooleanArray.prototype.findLast( predicate\[, thisArg] ) - -Returns the last element in an array for which a predicate function returns a truthy value. - -```javascript -function predicate( v ) { - return v === true; -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var v = arr.findLast( predicate ); -// returns true -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function predicate( v ) { - this.count += 1; - return ( v === true ); -} - -var arr = new BooleanArray( 3 ); - -var context = { - 'count': 0 -}; - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( false, 2 ); - -var z = arr.findLast( predicate, context ); -// returns true - -var count = context.count; -// returns 3 -``` - - - -#### BooleanArray.prototype.findLastIndex( predicate\[, thisArg] ) - -Returns the index of the last element in an array for which a predicate function returns a truthy value. - -```javascript -function predicate( v ) { - return v === true; -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var v = arr.findLastIndex( predicate ); -// returns 2 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function predicate( v ) { - this.count += 1; - return ( v === true ); -} - -var arr = new BooleanArray( 3 ); - -var context = { - 'count': 0 -}; - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( false, 2 ); - -var z = arr.findLastIndex( predicate, context ); -// returns 0 - -var count = context.count; -// returns 3 -``` - - - -#### BooleanArray.prototype.forEach( callbackFn\[, thisArg] ) - -Invokes a function once for each array element. - -```javascript -function log( v, i ) { - console.log( '%s: %s', i.toString(), v.toString() ); -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -arr.forEach( log ); -/* => - 0: true - 1: false - 2: true -*/ -``` - -The invoked function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function fcn( v, i ) { - this.count += 1; - console.log( '%s: %s', i.toString(), v.toString() ); -} - -var arr = new BooleanArray( 3 ); - -var context = { - 'count': 0 -}; - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -arr.forEach( fcn, context ); - -var count = context.count; -// returns 3 -``` - - - -#### BooleanArray.prototype.get( i ) - -Returns an array element located at a nonnegative integer position (index) `i`. - -```javascript -var arr = new BooleanArray( 10 ); - -// Set the first element: -arr.set( true, 0 ); - -// Get the first element: -var v = arr.get( 0 ); -// returns true -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var arr = new BooleanArray( 10 ); - -var v = arr.get( 100 ); -// returns undefined -``` - - - -#### BooleanArray.prototype.includes( searchElement\[, fromIndex] ) - -Returns a boolean indicating whether an array includes a provided value. - -```javascript -var arr = new BooleanArray( 5 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); -arr.set( true, 3 ); -arr.set( true, 4 ); - -var bool = arr.includes( true ); -// returns true - -bool = arr.includes( false, 2 ); -// returns false -``` - - - -#### BooleanArray.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the first index at which a given element can be found. - -```javascript -var arr = new BooleanArray( 5 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); -arr.set( true, 3 ); -arr.set( true, 4 ); - -var idx = arr.indexOf( true ); -// returns 0 - -idx = arr.indexOf( false, 1 ); -// returns 1 - -idx = arr.indexOf( true, -3 ); -// returns 2 -``` - -If `searchElement` is not present in the array, the method returns `-1`. - -```javascript -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( true, 1 ); -arr.set( true, 2 ); - -var idx = arr.indexOf( false ); -// returns -1 -``` - - - -#### BooleanArray.prototype.join( \[separator] ) - -Returns a new string by concatenating all array elements. - -```javascript -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var str = arr.join(); -// returns 'true,false,true' -``` - -By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string. - -```javascript -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var str = arr.join( '|' ); -// returns 'true|false|true' -``` - - - -#### BooleanArray.prototype.keys() - -Returns an iterator for iterating over each index key in a typed array. - -```javascript -var arr = new BooleanArray( 2 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); - -var iter = arr.keys(); - -var v = iter.next().value; -// returns 0 - -v = iter.next().value; -// returns 1 - -var bool = iter.next().done; -// returns true -``` - -The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: - -- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. -- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. - - - -#### BooleanArray.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the last index at which a given element can be found. - -```javascript -var arr = new BooleanArray( 5 ); - -arr.set( true, 0 ); -arr.set( true, 1 ); -arr.set( true, 2 ); -arr.set( false, 3 ); -arr.set( true, 4 ); - -var idx = arr.lastIndexOf( true ); -// returns 4 - -idx = arr.lastIndexOf( false, 3 ); -// returns 3 - -idx = arr.lastIndexOf( true, -3 ); -// returns 2 -``` - -If `searchElement` is not present in the array, the method returns `-1`. - -```javascript -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( true, 1 ); -arr.set( true, 2 ); - -var idx = arr.lastIndexOf( false ); -// returns -1 -``` - - - -#### BooleanArray.prototype.map( callbackFn\[, thisArg] ) - -Returns a new array with each element being the result of a provided callback function. - -```javascript -function invert( v ) { - return !v; -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var out = arr.map( invert ); -// returns - -var z = out.get( 0 ); -// returns false - -z = out.get( 1 ); -// returns true - -z = out.get( 2 ); -// returns false -``` - -The callback function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function invert( v, i ) { - this.count += i; - return !v; -} - -var arr = new BooleanArray( 3 ); - -var context = { - 'count': 0 -}; - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var out = arr.map( invert, context ); -// returns - -var count = context.count; -// returns 3; -``` - - - -#### BooleanArray.prototype.reduce( reducerFn\[, initialValue] ) - -Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - -```javascript -function reducer( acc, v ) { - return ( acc && v ); -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var out = arr.reduce( reducer ); -// returns false -``` - -The reducer function is provided four arguments: - -- **acc**: accumulated result. -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. - -```javascript -function reducer( acc, v ) { - if ( v ) { - return acc + 1; - } - return acc; -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var out = arr.reduce( reducer, 0 ); -// returns 2 -``` - - - -#### BooleanArray.prototype.reduceRight( reducerFn\[, initialValue] ) - -Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - -```javascript -function reducer( acc, v ) { - return ( acc && v ); -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var out = arr.reduceRight( reducer ); -// returns false -``` - -The reducer function is provided four arguments: - -- **acc**: accumulated result. -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -By default, the function initializes the accumulated result to the last element in the array and passes the second-last array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the last array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. - -```javascript -function reducer( acc, v ) { - if ( v ) { - return acc + 1; - } - return acc; -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var out = arr.reduceRight( reducer, 0 ); -// returns 2 -``` - - - -#### BooleanArray.prototype.reverse() - -Reverses an array in-place. - -```javascript -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( false, 2 ); - -var out = arr.reverse(); -// returns - -var v = out.get( 0 ); -// returns false - -v = out.get( 1 ); -// returns false - -v = out.get( 2 ); -// returns true -``` - - - -#### BooleanArray.prototype.set( v\[, i] ) - -Sets one or more array elements. - -```javascript -var arr = new BooleanArray( 10 ); - -// Get the first element: -var v = arr.get( 0 ); -// returns false - -// Set the first element: -arr.set( true ); - -// Get the first element: -v = arr.get( 0 ); -// returns true -``` - -By default, the method sets array elements starting at position (index) `i = 0`. To set elements starting elsewhere in the array, provide an index argument `i`. - -```javascript -var arr = new BooleanArray( 10 ); - -// Get the fifth element: -var v = arr.get( 4 ); -// returns false - -// Set the fifth element: -arr.set( true, 4 ); - -// Get the fifth element: -v = arr.get( 4 ); -// returns true -``` - -In addition to providing a single value, to set one or more array elements, provide an array-like object containing truthy and falsy values - -```javascript -var arr = new BooleanArray( 10 ); - -// Define an array of values: -var buf = [ '', 1, null ]; - -// Set the fifth, sixth, and seventh elements: -arr.set( buf, 4 ); - -// Get the sixth element: -var v = arr.get( 5 ); -// returns true -``` - -A few notes: - -- If `i` is out-of-bounds, the method throws an error. -- If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error. -- If provided a [typed array][@stdlib/array/typed] which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range. - - - -#### BooleanArray.prototype.slice( \[start\[, end]] ) - -Copies a portion of a typed array to a new typed array. - -```javascript -var arr = new BooleanArray( 5 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); -arr.set( false, 3 ); -arr.set( true, 4 ); - -var out = arr.slice(); -// returns - -var len = out.length; -// returns 5 - -var bool = out.get( 0 ); -// returns true - -bool = out.get( len-1 ); -// returns true -``` - -By default, the method returns a typed array beginning with the first array element. To specify an alternative array index at which to begin, provide a `start` index (inclusive). - -```javascript -var arr = new BooleanArray( 5 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); -arr.set( false, 3 ); -arr.set( true, 4 ); - -var out = arr.slice( 1 ); -// returns - -var len = out.length; -// returns 4 - -var bool = out.get( 0 ); -// returns false - -bool = out.get( len-1 ); -// returns true -``` - -By default, the method returns a typed array which includes all array elements after `start`. To limit the number of array elements after `start`, provide an `end` index (exclusive). - -```javascript -var arr = new BooleanArray( 5 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); -arr.set( false, 3 ); -arr.set( true, 4 ); - -var out = arr.slice( 1, -2 ); -// returns - -var len = out.length; -// returns 2 - -var bool = out.get( 0 ); -// returns false - -bool = out.get( len-1 ); -// returns true -``` - - - -#### BooleanArray.prototype.some( predicate\[, thisArg] ) - -Returns a boolean indicating whether at least one element passes a test. - -```javascript -function predicate( v ) { - return v === true; -} - -var arr = new BooleanArray( 3 ); - -arr.set( false, 0 ); -arr.set( true, 1 ); -arr.set( false, 2 ); - -var bool = arr.some( predicate ); -// returns true -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function predicate( v ) { - this.count += 1; - return v === true; -} - -var arr = new BooleanArray( 3 ); - -var context = { - 'count': 0 -}; - -arr.set( false, 0 ); -arr.set( true, 1 ); -arr.set( false, 2 ); - -var bool = arr.some( predicate, context ); -// returns true - -var count = context.count; -// returns 2 -``` - - - -#### BooleanArray.prototype.sort( \[compareFcn] ) - -Sorts an array in-place. - -```javascript -function compare( a, b ) { - if ( a === false ) { - if ( b === false ) { - return 0; - } - return 1; - } - if ( b === true ) { - return 0; - } - return -1; -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -arr.sort( compare ); - -var v = arr.get( 0 ); -// returns true - -v = arr.get( 1 ); -// returns true - -v = arr.get( 2 ); -// returns false -``` - -The `compareFcn` determines the order of the elements. The function is called with the following arguments: - -- **a**: the first boolean value for comparison. -- **b**: the second boolean value for comparison. - -The function should return a number where: - -- a negative value indicates that `a` should come before `b`. -- a positive value indicates that `a` should come after `b`. -- zero or `NaN` indicates that `a` and `b` are considered equal. - - - -#### BooleanArray.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - -```javascript -var arr = new BooleanArray( 5 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); -arr.set( false, 3 ); -arr.set( true, 4 ); - -var subarr = arr.subarray(); -// returns - -var len = subarr.length; -// returns 5 - -var bool = subarr.get( 0 ); -// returns true - -bool = subarr.get( len-1 ); -// returns true -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - -```javascript -var arr = new BooleanArray( 5 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); -arr.set( false, 3 ); -arr.set( true, 4 ); - -var subarr = arr.subarray( 1 ); -// returns - -var len = subarr.length; -// returns 4 - -var bool = subarr.get( 0 ); -// returns false - -bool = subarr.get( len-1 ); -// returns true -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - -```javascript -var arr = new BooleanArray( 5 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); -arr.set( false, 3 ); -arr.set( true, 4 ); - -var subarr = arr.subarray( 1, -2 ); -// returns - -var len = subarr.length; -// returns 2 - -var bool = subarr.get( 0 ); -// returns false - -bool = subarr.get( len-1 ); -// returns true -``` - - - -#### BooleanArray.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific string. - -```javascript -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var str = arr.toLocaleString(); -// returns 'true,false,true' -``` - -The method supports the following arguments: - -- **locales**: a string with a BCP 47 language tag or an array of such strings. -- **options**: configuration properties. - - - -#### BooleanArray.prototype.toReversed() - -Returns a new typed array containing the elements in reversed order. - -```javascript -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( false, 2 ); - -var out = arr.toReversed(); -// returns - -var v = out.get( 0 ); -// returns false - -v = out.get( 1 ); -// returns false - -v = out.get( 2 ); -// returns true -``` - - - -#### BooleanArray.prototype.toSorted( \[compareFcn] ) - -Returns a new typed array containing the elements in sorted order. - -```javascript -function compare( a, b ) { - if ( a === false ) { - if ( b === false ) { - return 0; - } - return 1; - } - if ( b === true ) { - return 0; - } - return -1; -} - -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var out = arr.sort( compare ); -// returns - -var v = out.get( 0 ); -// returns true - -v = out.get( 1 ); -// returns true - -v = out.get( 2 ); -// returns false -``` - -The `compareFcn` determines the order of the elements. The function is called with the following arguments: - -- **a**: the first boolean value for comparison. -- **b**: the second boolean value for comparison. - -The function should return a number where: - -- a negative value indicates that `a` should come before `b`. -- a positive value indicates that `a` should come after `b`. -- zero or `NaN` indicates that `a` and `b` are considered equal. - - - -#### BooleanArray.prototype.toString() - -Serializes an array as a string. - -```javascript -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 2 ); - -var str = arr.toString(); -// returns 'true,false,true' -``` - - - -#### BooleanArray.prototype.values() - -Returns an iterator for iterating over each value in a typed array. - -```javascript -var arr = new BooleanArray( 2 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); - -var iter = arr.values(); - -var v = iter.next().value; -// returns true - -v = iter.next().value; -// returns false - -var bool = iter.next().done; -// returns true -``` - -The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: - -- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. -- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. - - - -#### BooleanArray.prototype.with( index, value ) - -Returns a new typed array with the element at a provided index replaced with a provided value. - -```javascript -var arr = new BooleanArray( 3 ); - -arr.set( true, 0 ); -arr.set( false, 1 ); -arr.set( true, 1 ); - -var out = arr.with( 0, false ); -// returns - -var v = out.get( 0 ); -// returns false -``` - -
- - - - - -
- -* * * - -## Notes - -- While a `BooleanArray` _strives_ to maintain (but does not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: - - - The constructor does **not** require the `new` operator. - - Accessing array elements using bracket syntax (e.g., `X[i]`) is **not** supported. Instead, one **must** use the `.get()` method. - -
- - - - - -
- -* * * - -## Examples - - - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); -var logEach = require( '@stdlib/console/log-each' ); -var BooleanArray = require( '@stdlib/array/bool' ); - -// Create a boolean array by specifying a length: -var out = new BooleanArray( 3 ); -logEach( '%s', out ); - -// Create a boolean array from an array of booleans: -var arr = [ true, false, true ]; -out = new BooleanArray( arr ); -logEach( '%s', out ); - -// Create a boolean array from an array buffer: -arr = new Uint8Array( [ 1, 0, 1, 1, 0, 1 ] ); -out = new BooleanArray( arr.buffer ); -logEach( '%s', out ); - -// Create a boolean array from an array buffer view: -arr = new Uint8Array( [ 1, 0, 1, 1, 0, 1 ] ); -out = new BooleanArray( arr.buffer, 1, 2 ); -logEach( '%s', out ); - -console.log( '%s', false ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/bool/benchmark/benchmark.at.js b/bool/benchmark/benchmark.at.js deleted file mode 100644 index 674a02850..000000000 --- a/bool/benchmark/benchmark.at.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::nonnegative_indices:at', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i%N ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::negative_indices:at', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -(i%N)-1 ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.copy_within.js b/bool/benchmark/benchmark.copy_within.js deleted file mode 100644 index b2675cfda..000000000 --- a/bool/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var buf; - var i; - - arr = []; - for ( i = 0; i < 5; i++ ) { - arr.push( i%2 ); - } - arr = new BooleanArray( arr ); - buf = arr.buffer; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = i%2; - arr = arr.copyWithin( 1, 0 ); - if ( buf[ 0 ] !== i%2 ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( buf[ 0 ] !== buf[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.copy_within.length.js b/bool/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 259434b7e..000000000 --- a/bool/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var buf; - var i; - - arr = []; - for ( i = 0; i < len+1; i++ ) { - arr.push( i%2 ); - } - arr = new BooleanArray( arr ); - buf = arr.buffer; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = i%2; - arr.copyWithin( 1, 0 ); - if ( buf[ 0 ] !== i%2 ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( buf[ 0 ] !== buf[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.entries.js b/bool/benchmark/benchmark.entries.js deleted file mode 100644 index 01781590d..000000000 --- a/bool/benchmark/benchmark.entries.js +++ /dev/null @@ -1,54 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.every.js b/bool/benchmark/benchmark.every.js deleted file mode 100644 index 31de61739..000000000 --- a/bool/benchmark/benchmark.every.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v === true; - } -}); diff --git a/bool/benchmark/benchmark.every.length.js b/bool/benchmark/benchmark.every.length.js deleted file mode 100644 index ac36b2c8b..000000000 --- a/bool/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,115 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value === true; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.fill.js b/bool/benchmark/benchmark.fill.js deleted file mode 100644 index 388e8cff9..000000000 --- a/bool/benchmark/benchmark.fill.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ - true, - false - ]; - arr = new BooleanArray( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.fill.length.js b/bool/benchmark/benchmark.fill.length.js deleted file mode 100644 index bac49a2cb..000000000 --- a/bool/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,100 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new BooleanArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ - true, - false - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.filter.js b/bool/benchmark/benchmark.filter.js deleted file mode 100644 index aa04c6ac4..000000000 --- a/bool/benchmark/benchmark.filter.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v === true ); - } -}); diff --git a/bool/benchmark/benchmark.filter.length.js b/bool/benchmark/benchmark.filter.length.js deleted file mode 100644 index d9c3986d7..000000000 --- a/bool/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,115 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value === true; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.find.js b/bool/benchmark/benchmark.find.js deleted file mode 100644 index 5401d45bd..000000000 --- a/bool/benchmark/benchmark.find.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.find( predicate ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v === false ); - } -}); diff --git a/bool/benchmark/benchmark.find.length.js b/bool/benchmark/benchmark.find.length.js deleted file mode 100644 index 7fd45a1f8..000000000 --- a/bool/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,117 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value === false ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( Boolean( 1 ) ); - } - arr.push( Boolean( 0 ) ); - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.find( predicate ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.find_index.js b/bool/benchmark/benchmark.find_index.js deleted file mode 100644 index c1be2df59..000000000 --- a/bool/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var arr; - var idx; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v === false ); - } -}); diff --git a/bool/benchmark/benchmark.find_index.length.js b/bool/benchmark/benchmark.find_index.length.js deleted file mode 100644 index d1def6840..000000000 --- a/bool/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,117 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value === true ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( Boolean( 0 ) ); - } - arr.push( Boolean( 1 ) ); - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.find_last.js b/bool/benchmark/benchmark.find_last.js deleted file mode 100644 index f0878a99f..000000000 --- a/bool/benchmark/benchmark.find_last.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findLast', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.findLast( predicate ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v === false ); - } -}); diff --git a/bool/benchmark/benchmark.find_last.length.js b/bool/benchmark/benchmark.find_last.length.js deleted file mode 100644 index 1aef5ed9b..000000000 --- a/bool/benchmark/benchmark.find_last.length.js +++ /dev/null @@ -1,117 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value === false ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - arr.push( Boolean( 0 ) ); - for ( i = 0; i < len-1; i++ ) { - arr.push( Boolean( 1 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.findLast( predicate ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findLast:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.find_last_index.js b/bool/benchmark/benchmark.find_last_index.js deleted file mode 100644 index 2c2429f72..000000000 --- a/bool/benchmark/benchmark.find_last_index.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findLastIndex', function benchmark( b ) { - var arr; - var idx; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findLastIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return ( v === false ); - } -}); diff --git a/bool/benchmark/benchmark.find_last_index.length.js b/bool/benchmark/benchmark.find_last_index.length.js deleted file mode 100644 index d0b620e05..000000000 --- a/bool/benchmark/benchmark.find_last_index.length.js +++ /dev/null @@ -1,117 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( value === true ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - arr.push( Boolean( 1 ) ); - for ( i = 0; i < len-1; i++ ) { - arr.push( Boolean( 0 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findLastIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findLastIndex:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.for_each.js b/bool/benchmark/benchmark.for_each.js deleted file mode 100644 index 284f95550..000000000 --- a/bool/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( check ); - if ( arr.length !== 4 ) { - b.fail( 'should not change an array length' ); - } - } - b.toc(); - if ( arr.length !== 4 ) { - b.fail( 'should not change an array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function check( v ) { - if ( !isBoolean( v ) ) { - b.fail( 'should be a boolean' ); - } - } -}); diff --git a/bool/benchmark/benchmark.for_each.length.js b/bool/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 62b02b9a3..000000000 --- a/bool/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( callback ); - if ( arr.length !== len ) { - b.fail( 'should not change an array length' ); - } - } - b.toc(); - if ( arr.length !== len ) { - b.fail( 'should not change an array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function callback( value ) { - if ( value !== true ) { - throw new Error( 'something went wrong' ); - } - } - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.from.js b/bool/benchmark/benchmark.from.js deleted file mode 100644 index 46739e5d2..000000000 --- a/bool/benchmark/benchmark.from.js +++ /dev/null @@ -1,310 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Uint8Array = require( './../../uint8' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return !v; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ true, true, true, true, true ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ true, true, true, true, true ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return !v; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.from( createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return !v; - } -}); diff --git a/bool/benchmark/benchmark.get.js b/bool/benchmark/benchmark.get.js deleted file mode 100644 index 597b1a30b..000000000 --- a/bool/benchmark/benchmark.get.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i%2 ); - } - arr = new BooleanArray( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.includes.js b/bool/benchmark/benchmark.includes.js deleted file mode 100644 index 42d559998..000000000 --- a/bool/benchmark/benchmark.includes.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.includes( true, 0 ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.includes.length.js b/bool/benchmark/benchmark.includes.length.js deleted file mode 100644 index d7b4b81be..000000000 --- a/bool/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( false ); - } - arr.push( true ); - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.includes( true ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.index_of.js b/bool/benchmark/benchmark.index_of.js deleted file mode 100644 index 875befae7..000000000 --- a/bool/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var arr; - var idx; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.indexOf( false, 0 ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.index_of.length.js b/bool/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 6f800919e..000000000 --- a/bool/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( false ); - } - arr.push( true ); - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.indexOf( true ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.join.js b/bool/benchmark/benchmark.join.js deleted file mode 100644 index d96ca36ae..000000000 --- a/bool/benchmark/benchmark.join.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.join.length.js b/bool/benchmark/benchmark.join.length.js deleted file mode 100644 index 515815322..000000000 --- a/bool/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,102 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.join( '/' ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.js b/bool/benchmark/benchmark.js deleted file mode 100644 index 09470637f..000000000 --- a/bool/benchmark/benchmark.js +++ /dev/null @@ -1,337 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( './../../buffer' ); -var Uint8Array = require( './../../uint8' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = BooleanArray; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new BooleanArray(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.keys.js b/bool/benchmark/benchmark.keys.js deleted file mode 100644 index b39411e67..000000000 --- a/bool/benchmark/benchmark.keys.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new BooleanArray( [ true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.keys.length.js b/bool/benchmark/benchmark.keys.length.js deleted file mode 100644 index 4cda0778b..000000000 --- a/bool/benchmark/benchmark.keys.length.js +++ /dev/null @@ -1,102 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':keys:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.last_index_of.js b/bool/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 6a8ee0c63..000000000 --- a/bool/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var arr; - var idx; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( false ); - } - arr = new BooleanArray( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.lastIndexOf( true, 0 ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.last_index_of.length.js b/bool/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 76171de79..000000000 --- a/bool/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,102 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = [ true ]; - for ( i = 1; i < len; i++ ) { - arr.push( false ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.lastIndexOf( true ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.length.js b/bool/benchmark/benchmark.length.js deleted file mode 100644 index 2f1bc80e1..000000000 --- a/bool/benchmark/benchmark.length.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new BooleanArray( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.map.js b/bool/benchmark/benchmark.map.js deleted file mode 100644 index 7bade7313..000000000 --- a/bool/benchmark/benchmark.map.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( invert ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function invert( v ) { - return !v; - } -}); diff --git a/bool/benchmark/benchmark.map.length.js b/bool/benchmark/benchmark.map.length.js deleted file mode 100644 index 29b06c9aa..000000000 --- a/bool/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,104 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var identity = require( '@stdlib/utils/identity-function' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( identity ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.of.js b/bool/benchmark/benchmark.of.js deleted file mode 100644 index 87fd2c3ef..000000000 --- a/bool/benchmark/benchmark.of.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.of(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ true, true, true, true, true ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = BooleanArray.of.apply( BooleanArray, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof BooleanArray) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.reduce.js b/bool/benchmark/benchmark.reduce.js deleted file mode 100644 index 52b3166a0..000000000 --- a/bool/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {boolean} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( reducer, 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.reduce.length.js b/bool/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 03e391b16..000000000 --- a/bool/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var Boolean = require( '@stdlib/boolean/ctor' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {boolean} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( reducer, 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.reduce_right.js b/bool/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 3026a51a4..000000000 --- a/bool/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {boolean} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( reducer, 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.reduce_right.length.js b/bool/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 8de497b05..000000000 --- a/bool/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var Boolean = require( '@stdlib/boolean/ctor' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {boolean} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( reducer, 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.reverse.js b/bool/benchmark/benchmark.reverse.js deleted file mode 100644 index 722b0b80f..000000000 --- a/bool/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.reverse.length.js b/bool/benchmark/benchmark.reverse.length.js deleted file mode 100644 index b3e3b7c5b..000000000 --- a/bool/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.set.js b/bool/benchmark/benchmark.set.js deleted file mode 100644 index 7c14e3a2a..000000000 --- a/bool/benchmark/benchmark.set.js +++ /dev/null @@ -1,119 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Uint8Array = require( './../../uint8' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::boolean:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i%2 ); - } - arr = new BooleanArray( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i%2 ); - } - arr = new BooleanArray( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Uint8Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i % 2; - } - arr = new BooleanArray( values ); - buf = new Uint8Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.set.length.js b/bool/benchmark/benchmark.set.length.js deleted file mode 100644 index 4f4813804..000000000 --- a/bool/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,116 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randu = require( '@stdlib/random/base/randu' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - var i; - - arr1 = []; - arr2 = []; - arr3 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( i > (len/2) ); - arr2.push( randu() > 0.5 ); - arr3.push( randu() < 0.2 ); - } - arr1 = new BooleanArray( arr1 ); - - values = [ - new BooleanArray( arr2 ), - new BooleanArray( arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 4; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.slice.js b/bool/benchmark/benchmark.slice.js deleted file mode 100644 index 06f31754d..000000000 --- a/bool/benchmark/benchmark.slice.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.slice.length.js b/bool/benchmark/benchmark.slice.length.js deleted file mode 100644 index 5b077fe4f..000000000 --- a/bool/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,103 +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 bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.some.js b/bool/benchmark/benchmark.some.js deleted file mode 100644 index 5024c0062..000000000 --- a/bool/benchmark/benchmark.some.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v === true; - } -}); diff --git a/bool/benchmark/benchmark.some.length.js b/bool/benchmark/benchmark.some.length.js deleted file mode 100644 index 4cf28e18c..000000000 --- a/bool/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,117 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {boolean} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {BooleanArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value === true; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 1; i < len; i++ ) { - arr.push( Boolean( 0 ) ); - } - arr.push( Boolean( 1 ) ); - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.sort.js b/bool/benchmark/benchmark.sort.js deleted file mode 100644 index a8e15baa8..000000000 --- a/bool/benchmark/benchmark.sort.js +++ /dev/null @@ -1,75 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.sort( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.sort.length.js b/bool/benchmark/benchmark.sort.length.js deleted file mode 100644 index 2efc4b813..000000000 --- a/bool/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.sort( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.subarray.js b/bool/benchmark/benchmark.subarray.js deleted file mode 100644 index 60f38ba51..000000000 --- a/bool/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.subarray.length.js b/bool/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 17ec983b8..000000000 --- a/bool/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.to_locale_string.js b/bool/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 67d577c7c..000000000 --- a/bool/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.to_locale_string.length.js b/bool/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 431b75bd5..000000000 --- a/bool/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,101 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.to_reversed.js b/bool/benchmark/benchmark.to_reversed.js deleted file mode 100644 index f8f840da5..000000000 --- a/bool/benchmark/benchmark.to_reversed.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toReversed', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toReversed(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.to_reversed.length.js b/bool/benchmark/benchmark.to_reversed.length.js deleted file mode 100644 index da5511f65..000000000 --- a/bool/benchmark/benchmark.to_reversed.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toReversed(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toReversed:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.to_sorted.js b/bool/benchmark/benchmark.to_sorted.js deleted file mode 100644 index cab83d5f8..000000000 --- a/bool/benchmark/benchmark.to_sorted.js +++ /dev/null @@ -1,75 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - - -// MAIN // - -bench( pkg+':toSorted', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toSorted( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.to_sorted.length.js b/bool/benchmark/benchmark.to_sorted.length.js deleted file mode 100644 index 0e94fef16..000000000 --- a/bool/benchmark/benchmark.to_sorted.length.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toSorted( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toSorted:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.to_string.js b/bool/benchmark/benchmark.to_string.js deleted file mode 100644 index d549731f6..000000000 --- a/bool/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new BooleanArray( [ true, false, false, true ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.to_string.length.js b/bool/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 36834b583..000000000 --- a/bool/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,102 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( Boolean( i%2 ) ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.values.js b/bool/benchmark/benchmark.values.js deleted file mode 100644 index 48283aaed..000000000 --- a/bool/benchmark/benchmark.values.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new BooleanArray( [ true, false ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.values.length.js b/bool/benchmark/benchmark.values.length.js deleted file mode 100644 index 585ff42b8..000000000 --- a/bool/benchmark/benchmark.values.length.js +++ /dev/null @@ -1,102 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( true ); - } - arr = new BooleanArray( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':values:len='+len, f ); - } -} - -main(); diff --git a/bool/benchmark/benchmark.with.js b/bool/benchmark/benchmark.with.js deleted file mode 100644 index b7e3e68d6..000000000 --- a/bool/benchmark/benchmark.with.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':with', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ - true, - false - ]; - arr = new BooleanArray( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/bool/benchmark/benchmark.with.length.js b/bool/benchmark/benchmark.with.length.js deleted file mode 100644 index 508e63f18..000000000 --- a/bool/benchmark/benchmark.with.length.js +++ /dev/null @@ -1,100 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new BooleanArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ - true, - false - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isBooleanArray( out ) ) { - b.fail( 'should return a BooleanArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':with:len='+len, f ); - } -} - -main(); diff --git a/bool/docs/repl.txt b/bool/docs/repl.txt deleted file mode 100644 index 88ca25a13..000000000 --- a/bool/docs/repl.txt +++ /dev/null @@ -1,1266 +0,0 @@ - -{{alias}}() - A Boolean array. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Creates a boolean array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var len = arr.length - 10 - - -{{alias}}( booleanarray ) - Creates a boolean array from another boolean array. - - Parameters - ---------- - booleanarray: BooleanArray - Boolean array from which to generate another boolean array. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ true, false, false, true ] ) - - > var arr2 = new {{alias}}( arr1 ) - - > var len = arr2.length - 4 - - -{{alias}}( typedarray ) - Creates a boolean array from a typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate boolean array. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/uint8}}( [ 1, 0, 0, 1 ] ) - - > var arr = new {{alias}}( buf ) - - > var len = arr.length - 4 - - -{{alias}}( obj ) - Creates a boolean array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a boolean array. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ true, false, false, true ] ) - - > var len = arr1.length - 4 - > var arr2 = new {{alias}}( [ {}, null, '', 4 ] ); - > len = arr2.length - 4 - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a boolean array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 240 ); - > var arr1 = new {{alias}}( buf ) - - > var len = arr1.length - 240 - > var arr2 = new {{alias}}( buf, 8 ) - - > len = arr2.length - 232 - > var arr3 = new {{alias}}( buf, 8, 20 ) - - > len = arr3.length - 20 - - -{{alias}}.from( src[, clbk[, thisArg]] ) - Creates a new boolean array from an array-like object or an iterable. - - A callback function is provided two arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - clbk: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > function map( v ) { return !v }; - > var src = [ true, false ]; - > var arr = {{alias}}.from( src, map ) - - > var len = arr.length - 2 - > var v = arr.get( 0 ) - false - > v = arr.get( 1 ) - true - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new boolean array from a variable number of arguments. - - Parameters - ---------- - element0: bool - Array element. - - element1: bool (optional) - Array element. - - elementN: ...bool (optional) - Array elements. - - Returns - ------- - out: BooleanArray - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( true, false, false, true ) - - > var len = arr.length - 4 - - -{{alias}}.BYTES_PER_ELEMENT - The size of each array element in bytes. - - Examples - -------- - > var nbytes = {{alias}}.BYTES_PER_ELEMENT - 1 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'BooleanArray' - - -{{alias}}.prototype.buffer - Pointer to the underlying data buffer. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > var buf = arr.buffer - - - -{{alias}}.prototype.byteLength - Size of the array in bytes. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var nbytes = arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Offset (in bytes) of the array from the start of its underlying - ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var offset = arr.byteOffset - 0 - > var buf = new {{alias:@stdlib/array/buffer}}( 240 ); - > arr = new {{alias}}( buf, 64 ) - - > offset = arr.byteOffset - 64 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > arr.BYTES_PER_ELEMENT - 1 - - -{{alias}}.prototype.length - The number of array elements. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var len = arr.length - 10 - - -{{alias}}.prototype.at( i ) - Returns an array element located at integer position (index) `i`, with - support for noth nonnegative and negative integer positions. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: boolean|void - An array element. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, false, true ] ) - - > var v = arr.at( 1 ) - false - > v = arr.at( -1 ) - true - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: BooleanArray - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, false, true ] ) - - > arr.copyWithin( 0, 2 ) - - > var v = arr.get( 0 ) - false - > v = arr.get( 1 ) - true - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true ] ) - - > var it = arr.entries(); - > var v = it.next().value - [ 0, true ] - > v = it.next().value - [ 1, false ] - > v = it.next().value - [ 2, true ] - > var bool = it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Returns a boolean indicating whether all elements in the array pass a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all elements pass the test. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ true, true, true ] ) - - > var bool = arr.every( predicate ) - true - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Returns a modified typed array filled with a fill value. - - Parameters - ---------- - value: boolean - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: BooleanArray - Modified array. - - Examples - -------- - > var arr = new {{alias}}( 3 ) - - > arr.fill( true ); - > var v = arr.get( 0 ) - true - > v = arr.get( 1 ) - true - > v = arr.get( 2 ) - true - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Returns a new array containing the elements of an array which pass a test - implemented by a predicate function. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: BooleanArray - A new typed array. - - Examples - -------- - > function predicate( v ) { return ( v === true ); }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.filter( predicate ) - - > var len = out.length - 2 - > var v = out.get( 0 ) - true - > v = out.get( 1 ) - true - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first element in an array for which a predicate function returns - a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: boolean|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var v = arr.find( predicate ) - true - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var idx = arr.findIndex( predicate ) - 0 - - -{{alias}}.prototype.findLast( predicate[, thisArg] ) - Returns the last element in an array for which a predicate function returns - a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: boolean|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var v = arr.findLast( predicate ) - true - - -{{alias}}.prototype.findLastIndex( predicate[, thisArg] ) - Returns the index of the last element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var idx = arr.findLastIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( clbk[, thisArg] ) - Invokes a function once for each array element. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - clbk: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Execution context. - - Examples - -------- - > var str = '%'; - > function clbk( v ) { str += v.toString() + '%'; }; - > var arr = new {{alias}}( [ true, false, false, true ] ) - - > arr.forEach( clbk ); - > str - '%true%false%false%true%' - - -{{alias}}.prototype.get( i ) - Returns an array element located at integer position (index) `i`. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: boolean|void - Array element or `undefined`. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > arr.set( true, 0 ); - > var v = arr.get( 0 ) - true - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a provided value. - - Parameters - ---------- - searchElement: boolean - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true, true, true ] ) - - > var bool = arr.includes( true ) - true - > bool = arr.includes( false, 3 ) - false - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the first index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: boolean - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true, true, true ] ) - - > var idx = arr.indexOf( true ) - 0 - > idx = arr.indexOf( false, 3 ) - -1 - - -{{alias}}.prototype.join( [separator] ) - Returns a new string by concatenating all array elements separated by a - separator string. - - Parameters - ---------- - separator: string (optional) - Separator string. Default: ','. - - Returns - ------- - out: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true ] ) - - > var str = arr.join() - 'true,false,true' - > str = arr.join( '|' ) - 'true|false|true' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over each index key in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array index keys. - - Examples - -------- - > var arr = new {{alias}}( [ true, false ] ) - - > var it = arr.keys(); - > var v = it.next().value - 0 - > v = it.next().value - 1 - > v = it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the last index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: boolean - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: out.length-1. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ true, true, true, false, true ] ) - - > var idx = arr.lastIndexOf( false ) - 3 - > idx = arr.lastIndexOf( false, 2 ) - -1 - - -{{alias}}.prototype.map( clbk[, thisArg] ) - Returns a new array with each element being the result of a provided - callback function. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - clbk: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: BooleanArray - A new typed array. - - Examples - -------- - > function invert( v ) { return !v; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.map( invert ) - - > var v = out.get( 0 ) - false - > v = out.get( 1 ) - true - > v = out.get( 2 ) - false - - -{{alias}}.prototype.reduce( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in order, passing - in the return value from the calculation on the preceding element and - returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > function reducer( acc, v ) { return ( acc && v ); }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.reduce( reducer ) - false - - -{{alias}}.prototype.reduceRight( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in reverse order, - passing in the return value from the calculation on the preceding element - and returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > function reducer( acc, v ) { return ( acc && v ); }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.reduceRight( reducer ) - false - - -{{alias}}.prototype.reverse() - Reverses the array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: BooleanArray - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, false ] ) - - > arr.reverse(); - > var v = arr.get( 0 ) - false - > v = arr.get( 1 ) - false - > v = arr.get( 2 ) - true - - -{{alias}}.prototype.set( v[, i] ) - Sets one or more array elements. - - If provided a single argument, the method sets array elements starting at - position (index) `i = 0`. To set elements starting elsewhere in the array, - provide an index argument `i`. - - To set one or more array elements, provide an array-like object containing - truthy and falsy values. - - Parameters - ---------- - v: bool|BooleanArray|ArrayLikeObject - Boolean value or Boolean value array. - - i: integer (optional) - Array index at which to start setting elements. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > arr.set( false ); - > var v = arr.get( 0 ) - false - > arr.set( true, 1 ); - > v = arr.get( 1 ) - true - - -{{alias}}.prototype.slice( [start[, end]] ) - Copies a portion of a typed array to a new typed array. - - Parameters - ---------- - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: BooleanArray - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true, false, true ] ) - - > var out = arr.slice( 1 ) - - > var len = out.length - 4 - > var v = out.get( 0 ) - false - > v = out.get( 1 ) - true - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Returns a boolean indicating whether at least one element passes a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one element passes the test. - - Examples - -------- - > function predicate( v ) { return v === true; }; - > var arr = new {{alias}}( [ false, true, false ] ) - - > var bool = arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array in-place. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first boolean value for comparison. - - b: second boolean value for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFunction: Function (optional) - Comparison function. - - Returns - ------- - out: BooleanArray - Modified array. - - Examples - -------- - > function compare( a, b ) { return a === true ? -1 : 1; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > arr.sort( compare ); - > var v = arr.get( 0 ) - true - > v = arr.get( 1 ) - true - > v = arr.get( 2 ) - false - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array view over the same underlying `ArrayBuffer` and - with the same underlying data type as the host array. - - Parameters - ---------- - begin: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: BooleanArray - New typed array view. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true, false, true ] ) - - > var out = arr.subarray( 1, 3 ) - - > var len = out.length - 2 - > var v = out.get( 0 ) - false - > v = out.get( 1 ) - true - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - Locale identifier(s). - - options: Object (optional) - An object containing serialization options. - - Returns - ------- - str: string - Local-specific string. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true ] ) - - > var str = arr.toLocaleString() - 'true,false,true' - - -{{alias}}.prototype.toReversed() - Returns a new typed array containing the elements in reversed order. - - Returns - ------- - out: BooleanArray - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, false ] ) - - > var out = arr.toReversed() - - > var v = out.get( 0 ) - false - > v = out.get( 1 ) - false - > v = out.get( 2 ) - true - - -{{alias}}.prototype.toSorted( [compareFunction] ) - Returns a new typed array containing the elements in sorted order. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first boolean value for comparison. - - b: second boolean value for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFunction: Function (optional) - Comparison function. - - Returns - ------- - out: BooleanArray - New typed array. - - Examples - -------- - > function compare( a, b ) { return a === true ? -1 : 1; }; - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.toSorted( compare ); - > var v = out.get( 0 ) - true - > v = out.get( 1 ) - true - > v = out.get( 2 ) - false - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - out: string - String serialization of the array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true ] ) - - > var str = arr.toString() - 'true,false,true' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over each value in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array values. - - Examples - -------- - > var arr = new {{alias}}( [ true, false ] ) - - > var it = arr.values(); - > var v = it.next().value - true - > v = it.next().value - false - > var bool = it.next().done - true - - -{{alias}}.prototype.with( index, value ) - Returns a new typed array with the element at a provided index replaced - with a provided value. - - Parameters - ---------- - index: integer - Element index. - - value: boolean - Element value. - - Returns - ------- - out: BooleanArray - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ true, false, true ] ) - - > var out = arr.with( 0, false ) - - > var v = out.get( 0 ) - false - - - See Also - -------- diff --git a/bool/docs/types/index.d.ts b/bool/docs/types/index.d.ts deleted file mode 100644 index 2e72c7d73..000000000 --- a/bool/docs/types/index.d.ts +++ /dev/null @@ -1,1526 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; -import { ArrayLike, BooleanArray as BooleanArrayInterface } from '@stdlib/types/array'; -import ArrayBuffer = require( './../../../buffer' ); - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Locale-specific configuration options. -*/ -interface LocaleOptions { - /** - * Configuration property. - */ - [ key: string | symbol | number ]: T | undefined; -} - -/** -* Callback invoked for each element in a source object. -* -* @returns transformed value -*/ -type FromNullary = ( this: U ) => boolean; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @returns transformed value -*/ -type FromUnary = ( this: U, value: boolean ) => boolean; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromBinary = ( this: U, value: boolean, index: number ) => boolean; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromCallback = FromNullary | FromUnary | FromBinary; - -/** -* Checks whether an element in an array passes a test. -* -* @returns boolean indicating whether an element in an array passes a test -*/ -type NullaryPredicate = ( this: U ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element in an array passes a test -*/ -type UnaryPredicate = ( this: U, value: boolean ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element in an array passes a test -*/ -type BinaryPredicate = ( this: U, value: boolean, index: number ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type TernaryPredicate = ( this: U, value: boolean, index: number, arr: BooleanArray ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Callback invoked for each element in an array. -* -* @returns undefined -*/ -type NullaryCallback = ( this: U ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns undefined -*/ -type UnaryCallback = ( this: U, value: boolean ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns undefined -*/ -type BinaryCallback = ( this: U, value: boolean, index: number ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type TernaryCallback = ( this: U, value: boolean, index: number, arr: BooleanArray ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; - -/** -* Callback invoked for each element in an array. -* -* @returns returned value -*/ -type NullaryMapFcn = ( this: U ) => any; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns returned value -*/ -type UnaryMapFcn = ( this: U, value: boolean ) => any; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns returned value -*/ -type BinaryMapFcn = ( this: U, value: boolean, index: number ) => any; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns returned value -*/ -type TernaryMapFcn = ( this: U, value: boolean, index: number, arr: BooleanArray ) => any; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns returned value -*/ -type MapFcn = NullaryMapFcn | UnaryMapFcn | BinaryMapFcn | TernaryMapFcn; - -/** -* Reducer function invoked for each element in an array. -* -* @returns accumulated result -*/ -type NullaryReducer = () => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @returns accumulated result -*/ -type UnaryReducer = ( acc: U ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @returns accumulated result -*/ -type BinaryReducer = ( acc: U, value: boolean ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @returns accumulated result -*/ -type TernaryReducer = ( acc: U, value: boolean, index: number ) => U; - -/** -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type QuaternaryReducer = ( acc: U, value: boolean, index: number, arr: BooleanArray ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type Reducer = NullaryReducer | UnaryReducer | BinaryReducer | TernaryReducer | QuaternaryReducer; - -/** -* Comparator function. -* -* @param a - first boolean value for comparison -* @param b - second boolean value for comparison -* @returns number indicating comparison result -*/ -type CompareFcn = ( a: boolean, b: boolean ) => number; - -/** -* Class for creating a Boolean array. -*/ -declare class BooleanArray implements BooleanArrayInterface { - /** - * Boolean array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns boolean array - * - * @example - * var arr = new BooleanArray(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new BooleanArray( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new BooleanArray( [ true, false ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new BooleanArray( buf ); - * // returns - * - * var len = arr.length; - * // returns 16 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new BooleanArray( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new BooleanArray( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - constructor( arg?: number | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ); - - /** - * Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices. - * - * @param i - element index - * @throws index argument must be a integer - * @returns array element - * - * @example - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var v = arr.at( 0 ); - * // returns true - * - * v = arr.at( -1 ); - * // returns true - * - * v = arr.at( 100 ); - * // returns undefined - */ - at( i: number ): boolean | void; - - /** - * Pointer to the underlying data buffer. - * - * @example - * var arr = new BooleanArray( 10 ); - * - * var buf = arr.buffer; - * // returns - */ - readonly buffer: ArrayBuffer; - - /** - * Length (in bytes) of the array. - * - * @example - * var arr = new BooleanArray( 10 ); - * - * var byteLength = arr.byteLength; - * // returns 10 - */ - readonly byteLength: number; - - /** - * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - * - * @example - * var arr = new BooleanArray( 10 ); - * - * var byteOffset = arr.byteOffset; - * // returns 0 - */ - readonly byteOffset: number; - - /** - * Size (in bytes) of each array element. - * - * @example - * var arr = new BooleanArray( 10 ); - * - * var nbytes = arr.BYTES_PER_ELEMENT; - * // returns 1 - */ - readonly BYTES_PER_ELEMENT: 1; - - /** - * Number of array elements. - * - * @example - * var arr = new BooleanArray( 10 ); - * - * var len = arr.length; - * // returns 10 - */ - readonly length: number; - - /** - * Copies a sequence of elements within the array to the position starting at `target`. - * - * @param target - index at which to start copying elements - * @param start - source index at which to copy elements from - * @param end - source index at which to stop copying elements from - * @returns modified array - * - * @example - * var arr = new BooleanArray( 4 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( false, 2 ); - * arr.set( true, 3 ); - * - * // Copy the first two elements to the last two elements: - * arr.copyWithin( 2, 0, 2 ); - * - * var v = arr.get( 2 ); - * // returns true - * - * v = arr.get( 3 ); - * // returns false - */ - copyWithin( target: number, start: number, end?: number ): BooleanArray; - - /** - * Returns an iterator for iterating over array key-value pairs. - * - * @returns iterator - * - * @example - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var it = arr.entries(); - * - * var v = it.next().value; - * // returns [ 0, true ] - * - * v = it.next().value; - * // returns [ 1, false ] - * - * v = it.next().value; - * // returns [ 2, true ] - * - * var bool = it.next().done; - * // returns true - */ - entries(): TypedIterator<[number, boolean]>; - - /** - * Tests whether all elements in an array pass a test implemented by a predicate function. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether all elements pass a test - * - * @example - * function predicate( v ) { - * return v === true; - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( true, 1 ); - * arr.set( true, 2 ); - * - * var bool = arr.every( predicate ); - * // returns true - */ - every( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Returns a modified typed array filled with a fill value. - * - * @param value - fill value - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @returns modified typed array - * - * @example - * var arr = new BooleanArray( 3 ); - * - * arr.fill( true, 1 ); - * - * var v = arr.get( 0 ); - * // returns false - * - * v = arr.get( 1 ); - * // returns true - * - * v = arr.get( 2 ); - * // returns true - */ - fill( value: boolean, start?: number, end?: number ): BooleanArray; - - /** - * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns new array containing elements which pass a test implemented by a predicate function - * - * @example - * function predicate( v ) { - * return ( v === true ); - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var out = arr.filter( predicate ); - * // returns - * - * var len = out.length; - * // returns 2 - * - * var v = out.get( 0 ); - * // returns true - * - * v = out.get( 1 ); - * // returns true - */ - filter( predicate: Predicate, thisArg?: ThisParameterType> ): BooleanArray; - - /** - * Returns the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array element or undefined - * - * @example - * function predicate( v ) { - * return v === true; - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var v = arr.find( predicate ); - * // returns true - */ - find( predicate: Predicate, thisArg?: ThisParameterType> ): boolean | void; - - /** - * Returns the index of the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array index or -1 - * - * @example - * function predicate( v ) { - * return v === true; - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var v = arr.findIndex( predicate ); - * // returns 0 - */ - findIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Returns the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array element or undefined - * - * @example - * function predicate( v ) { - * return v === true; - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var v = arr.findLast( predicate ); - * // returns true - */ - findLast( predicate: Predicate, thisArg?: ThisParameterType> ): boolean | void; - - /** - * Returns the index of the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns array index or -1 - * - * @example - * function predicate( v ) { - * return v === true; - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var v = arr.findLastIndex( predicate ); - * // returns 2 - */ - findLastIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Invokes a function once for each array element. - * - * @param fcn - function to invoke - * @param thisArg - execution context - * @returns undefined - * - * @example - * function log( v, i ) { - * console.log( '%s: %s', i, v.toString() ); - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * arr.forEach( log ); - * // => 0: true - * // => 1: false - * // => 2: true - */ - forEach( fcn: Callback, thisArg?: ThisParameterType> ): void; - - /** - * Returns an array element. - * - * @param i - element index - * @throws index argument must be a nonnegative integer - * @returns array element - * - * @example - * var arr = new BooleanArray( 10 ); - * - * var v = arr.get( 0 ); - * // returns false - * - * arr.set( true, 0 ); - * - * v = arr.get( 100 ); - * // returns undefined - */ - get( i: number ): boolean | void; - - /** - * Returns a boolean indicating whether an array includes a provided value. - * - * @param searchElement - element to search for - * @param fromIndex - starting index (inclusive) - * @returns boolean indicating whether an array includes a value - * - * @example - * var arr = new BooleanArray( 5 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * arr.set( true, 3 ); - * arr.set( true, 4 ); - * - * var bool = arr.includes( true ); - * // returns true - * - * bool = arr.includes( false, 2 ); - * // returns false - */ - includes( searchElement: boolean, fromIndex?: number ): boolean; - - /** - * Returns the first index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - starting index (inclusive) - * @returns index or -1 - * - * @example - * var arr = new BooleanArray( 5 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * arr.set( true, 3 ); - * arr.set( true, 4 ); - * - * var idx = arr.indexOf( true ); - * // returns 0 - * - * idx = arr.indexOf( false, 2 ); - * // returns -1 - * - * idx = arr.indexOf( false, -3 ); - * // returns -1 - */ - indexOf( searchElement: boolean, fromIndex?: number ): number; - - /** - * Returns a new string by concatenating all array elements. - * - * @param separator - value separator (default: ',') - * @returns string - * - * @example - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var str = arr.join(); - * // returns 'true,false,true' - * - * str = arr.join( '|' ); - * // returns 'true|false|true' - */ - join( separator?: string ): string; - - /** - * Returns an iterator for iterating over each index key in a typed array. - * - * @returns iterator - * - * @example - * var arr = new BooleanArray( 2 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * - * var iter = arr.keys(); - * - * var v = iter.next().value; - * // returns 0 - * - * v = iter.next().value; - * // returns 1 - * - * var bool = iter.next().done; - * // returns true - */ - keys(): TypedIterator; - - /** - * Returns the last index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - index at which to start searching backward (inclusive) - * @returns index or -1 - * - * @example - * var arr = new BooleanArray( 5 ); - * - * arr.set( true, 0 ); - * arr.set( true, 1 ); - * arr.set( true, 2 ); - * arr.set( false, 3 ); - * arr.set( true, 4 ); - * - * var idx = arr.lastIndexOf( true ); - * // returns 4 - * - * idx = arr.lastIndexOf( false, 2 ); - * // returns -1 - * - * idx = arr.lastIndexOf( false, -3 ); - * // returns -1 - */ - lastIndexOf( searchElement: boolean, fromIndex?: number ): number; - - /** - * Returns a new array with each element being the result of a provided callback function. - * - * @param fcn - callback function - * @param thisArg - callback function execution context - * @returns new boolean array - * - * @example - * function invert( v ) { - * return !v; - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var out = arr.map( invert ); - * // returns - * - * var v = out.get( 0 ); - * // returns false - * - * v = out.get( 1 ); - * // returns true - * - * v = out.get( 2 ); - * // returns false - */ - map( fcn: MapFcn, thisArg?: ThisParameterType> ): BooleanArray; - - /** - * Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * function reducer( acc, v ) { - * if ( v ) { - * return acc + 1; - * } - * return acc; - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var out = arr.reduce( reducer, 0 ); - * // returns 2 - */ - reduce( reducer: Reducer, initialValue?: U ): U; - - /** - * Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * function reducer( acc, v ) { - * if ( v ) { - * return acc + 1; - * } - * return acc; - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var out = arr.reduceRight( reducer, 0 ); - * // returns 2 - */ - reduceRight( reducer: Reducer, initialValue?: U ): U; - - /** - * Reverses an array in-place. - * - * @returns reversed array - * - * @example - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( false, 2 ); - * - * var out = arr.reverse(); - * // returns - * - * var v = out.get( 0 ); - * // returns false - * - * v = out.get( 1 ); - * // returns false - * - * v = out.get( 2 ); - * // returns true - */ - reverse(): BooleanArray; - - /** - * Sets an array element. - * - * ## Notes - * - * - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. - * - * In the other overlapping scenario, - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended. - * - * - * @param value - value(s) - * @param i - element index at which to start writing values (default: 0) - * @throws index argument must be a nonnegative integer - * @throws index argument is out-of-bounds - * @throws target array lacks sufficient storage to accommodate source values - * - * @example - * var arr = new BooleanArray( 10 ); - * - * var v = arr.get( 0 ); - * // returns false - * - * arr.set( true, 0 ); - * - * v = arr.get( 0 ); - * // returns true - */ - set( value: ArrayLike | any, i?: number ): void; - - /** - * Copies a portion of a typed array to a new typed array. - * - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns output array - * - * @example - * var arr = new BooleanArray( 5 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * arr.set( false, 3 ); - * arr.set( true, 4 ); - * - * var out = arr.slice(); - * // returns - * - * var len = out.length; - * // returns 5 - * - * var bool = out.get( 0 ); - * // returns true - * - * bool = out.get( len-1 ); - * // returns true - * - * out = arr.slice( 1, -2 ); - * // returns - * - * len = out.length; - * // returns 2 - * - * bool = out.get( 0 ); - * // returns false - * - * bool = out.get( len-1 ); - * // returns true - */ - slice( start?: number, end?: number ): BooleanArray; - - /** - * Tests whether at least one element in an array passes a test implemented by a predicate function. - * - * @param predicate - predicate function - * @param thisArg - predicate function execution context - * @returns boolean indicating whether at least one element passes a test - * - * @example - * function predicate( v ) { - * return v === true; - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( false, 0 ); - * arr.set( true, 1 ); - * arr.set( false, 2 ); - * - * var bool = arr.some( predicate ); - * // returns true - */ - some( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Sorts an array in-place. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * function compare( a, b ) { - * if ( a === false ) { - * if ( b === false ) { - * return 0; - * } - * return 1; - * } - * if ( b === true ) { - * return 0; - * } - * return -1; - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * arr.sort( compare ); - * - * var v = arr.get( 0 ); - * // returns true - * - * v = arr.get( 1 ); - * // returns true - * - * v = arr.get( 2 ); - * // returns false - */ - sort( compareFcn: CompareFcn ): BooleanArray; - - /** - * Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. - * - * @param begin - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns subarray - * - * @example - * var arr = new BooleanArray( 5 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * arr.set( false, 3 ); - * arr.set( true, 4 ); - * - * var subarr = arr.subarray(); - * // returns - * - * var len = subarr.length; - * // returns 5 - * - * var bool = subarr.get( 0 ); - * // returns true - * - * bool = subarr.get( len-1 ); - * // returns true - * - * subarr = arr.subarray( 1, -2 ); - * // returns - * - * len = subarr.length; - * // returns 2 - * - * bool = subarr.get( 0 ); - * // returns false - * - * bool = subarr.get( len-1 ); - * // returns true - */ - subarray( begin?: number, end?: number ): BooleanArray; - - /** - * Serializes an array as a locale-specific string. - * - * @param locales - locale identifier(s) - * @param options - configuration options - * @returns string - * - * @example - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 1 ); - * - * var str = arr.toLocaleString(); - * // returns 'true,false,true' - */ - toLocaleString( locales?: string | Array, options?: LocaleOptions ): string; - - /** - * Returns a new typed array containing the elements in reversed order. - * - * @returns reversed array - * - * @example - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( false, 2 ); - * - * var out = arr.toReversed(); - * // returns - * - * var v = out.get( 0 ); - * // returns false - * - * v = out.get( 1 ); - * // returns false - * - * v = out.get( 2 ); - * // returns true - */ - toReversed(): BooleanArray; - - /** - * Returns a new typed array containing the elements in sorted order. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * function compare( a, b ) { - * if ( a === false ) { - * if ( b === false ) { - * return 0; - * } - * return 1; - * } - * if ( b === true ) { - * return 0; - * } - * return -1; - * } - * - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var out = arr.sort( compare ); - * // returns - * - * var v = out.get( 0 ); - * // returns true - * - * v = out.get( 1 ); - * // returns true - * - * v = out.get( 2 ); - * // returns false - */ - toSorted( compareFcn: CompareFcn ): BooleanArray; - - /** - * Serializes an array as a string. - * - * @returns string - * - * @example - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var str = arr.toString(); - * // returns 'true,false,true' - */ - toString(): string; - - /** - * Returns an iterator for iterating over each value in a typed array. - * - * @returns iterator - * - * @example - * var arr = new BooleanArray( 2 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * - * var iter = arr.values(); - * - * var v = iter.next().value; - * // returns true - * - * v = iter.next().value; - * // returns false - * - * var bool = iter.next().done; - * // returns true - */ - values(): TypedIterator; - - /** - * Returns a new typed array with the element at a provided index replaced with a provided value. - * - * @param index - element index - * @param value - new value - * @throws first argument must be an integer - * @throws second argument must be a boolean - * @throws index argument is out-of-bounds - * @returns modified typed array - * - * @example - * var arr = new BooleanArray( 3 ); - * - * arr.set( true, 0 ); - * arr.set( false, 1 ); - * arr.set( true, 2 ); - * - * var out = arr.with( 0, false ); - * // returns - * - * var v = out.get( 0 ); - * // returns false - */ - with( index: number, value: boolean ): BooleanArray; -} - -/** -* Interface defining a Boolean array constructor which is both "newable" and "callable". -*/ -interface BooleanArrayConstructor { - /** - * Boolean array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns boolean array - * - * @example - * var arr = new BooleanArray(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new BooleanArray( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new BooleanArray( [ true, false ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new BooleanArray( buf ); - * // returns - * - * var len = arr.length; - * // returns 16 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new BooleanArray( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new BooleanArray( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - new( arg?: number | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): BooleanArray; - - /** - * Boolean array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns boolean array - * - * @example - * var arr = new BooleanArray(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new BooleanArray( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new BooleanArray( [ true, false ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new BooleanArray( buf ); - * // returns - * - * var len = arr.length; - * // returns 16 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new BooleanArray( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new BooleanArray( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - ( arg?: number | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): BooleanArray; - - /** - * Constructor name. - * - * @example - * var str = BooleanArray.name; - * // returns 'BooleanArray' - */ - readonly name: 'BooleanArray'; - - /** - * Size (in bytes) of each array element. - * - * @example - * var nbytes = BooleanArray.BYTES_PER_ELEMENT; - * // returns 1 - */ - readonly BYTES_PER_ELEMENT: 1; - - /** - * Creates a new boolean array from an array-like object or an iterable. - * - * @param src - array-like object or iterable - * @param clbk - callback to invoke for each source element - * @param thisArg - context - * @returns boolean array - * - * @example - * var arr = BooleanArray.from( [ true, false ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * function clbk( v ) { - * return !v; - * } - * - * var arr = BooleanArray.from( [ true, false ], clbk ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - from( src: ArrayLike | Iterable, clbk?: FromCallback, thisArg?: ThisParameterType> ): BooleanArray; - - /** - * Creates a new boolean array from a variable number of arguments. - * - * @param elements - array elements - * @returns boolean array - * - * @example - * var arr = BooleanArray.of( true, true, true, true ); - * // returns - * - * var len = arr.length; - * // returns 4 - */ - of( ...elements: Array ): BooleanArray; -} - -/** -* Boolean array constructor. -* -* @param arg - length, typed array, array-like object, or buffer -* @param byteOffset - byte offset (default: 0) -* @param length - view length -* @throws if provided only a single argument, must provide a valid argument -* @throws byte offset must be a nonnegative integer -* @throws must provide sufficient memory to accommodate byte offset and view length requirements -* @returns boolean array -* -* @example -* var arr = new BooleanArray(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new BooleanArray( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new BooleanArray( [ true, false ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new BooleanArray( buf ); -* // returns -* -* var len = arr.length; -* // returns 16 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new BooleanArray( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new BooleanArray( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -declare var ctor: BooleanArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/bool/docs/types/test.ts b/bool/docs/types/test.ts deleted file mode 100644 index cfc206fe3..000000000 --- a/bool/docs/types/test.ts +++ /dev/null @@ -1,147 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ArrayBuffer = require( './../../../buffer' ); -import BooleanArray = require( './index' ); - -/** -* Callback function. -* -* @private -* @param v - value -* @returns input value -*/ -function clbk( v: boolean ): boolean { - return v; -} - - -// TESTS // - -// The function returns a boolean array... -{ - new BooleanArray(); // $ExpectType BooleanArray - BooleanArray(); // $ExpectType BooleanArray - new BooleanArray( 2 ); // $ExpectType BooleanArray - BooleanArray( 2 ); // $ExpectType BooleanArray - new BooleanArray( [ 1.0, -1.0 ] ); // $ExpectType BooleanArray - BooleanArray( [ 1.0, -1.0 ] ); // $ExpectType BooleanArray - - const buf = new ArrayBuffer( 16 ); - new BooleanArray( buf ); // $ExpectType BooleanArray - BooleanArray( buf ); // $ExpectType BooleanArray - new BooleanArray( buf, 8 ); // $ExpectType BooleanArray - BooleanArray( buf, 8 ); // $ExpectType BooleanArray - new BooleanArray( buf, 8, 2 ); // $ExpectType BooleanArray - BooleanArray( buf, 8, 2 ); // $ExpectType BooleanArray -} - -// The compiler throws an error if the function is provided a first argument that is not a number, typed array, array-like object, or array buffer... -{ - new BooleanArray( true ); // $ExpectError - new BooleanArray( false ); // $ExpectError - new BooleanArray( null ); // $ExpectError - new BooleanArray( {} ); // $ExpectError - new BooleanArray( ( x: boolean ): boolean => x ); // $ExpectError - - BooleanArray( true ); // $ExpectError - BooleanArray( false ); // $ExpectError - BooleanArray( null ); // $ExpectError - BooleanArray( {} ); // $ExpectError - BooleanArray( ( x: boolean ): boolean => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new BooleanArray( buf, true ); // $ExpectError - new BooleanArray( buf, false ); // $ExpectError - new BooleanArray( buf, null ); // $ExpectError - new BooleanArray( buf, 'abc' ); // $ExpectError - new BooleanArray( buf, {} ); // $ExpectError - new BooleanArray( buf, ( x: boolean ): boolean => x ); // $ExpectError - - BooleanArray( buf, true ); // $ExpectError - BooleanArray( buf, false ); // $ExpectError - BooleanArray( buf, null ); // $ExpectError - BooleanArray( buf, 'abc' ); // $ExpectError - BooleanArray( buf, {} ); // $ExpectError - BooleanArray( buf, ( x: boolean ): boolean => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new BooleanArray( buf, 8, true ); // $ExpectError - new BooleanArray( buf, 8, false ); // $ExpectError - new BooleanArray( buf, 8, null ); // $ExpectError - new BooleanArray( buf, 8, 'abc' ); // $ExpectError - new BooleanArray( buf, 8, {} ); // $ExpectError - new BooleanArray( buf, 8, ( x: boolean ): boolean => x ); // $ExpectError - - BooleanArray( buf, 8, true ); // $ExpectError - BooleanArray( buf, 8, false ); // $ExpectError - BooleanArray( buf, 8, null ); // $ExpectError - BooleanArray( buf, 8, 'abc' ); // $ExpectError - BooleanArray( buf, 8, {} ); // $ExpectError - BooleanArray( buf, 8, ( x: boolean ): boolean => x ); // $ExpectError -} - -// The `from` method returns a boolean array... -{ - BooleanArray.from( [ true, true ] ); // $ExpectType BooleanArray - BooleanArray.from( [ true, true ], ( x: boolean ): boolean => x ); // $ExpectType BooleanArray - BooleanArray.from( [ true ], clbk, {} ); // $ExpectType BooleanArray -} - -// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable... -{ - BooleanArray.from( true ); // $ExpectError - BooleanArray.from( false ); // $ExpectError - BooleanArray.from( 123 ); // $ExpectError - BooleanArray.from( null ); // $ExpectError - BooleanArray.from( {} ); // $ExpectError - - BooleanArray.from( true, clbk ); // $ExpectError - BooleanArray.from( false, clbk ); // $ExpectError - BooleanArray.from( 123, clbk ); // $ExpectError - BooleanArray.from( null, clbk ); // $ExpectError - BooleanArray.from( {}, clbk ); // $ExpectError - - BooleanArray.from( true, clbk, {} ); // $ExpectError - BooleanArray.from( false, clbk, {} ); // $ExpectError - BooleanArray.from( 123, clbk, {} ); // $ExpectError - BooleanArray.from( null, clbk, {} ); // $ExpectError - BooleanArray.from( {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `from` method is provided a second argument which is not a function with a supported signature... -{ - BooleanArray.from( [ true, true ], true ); // $ExpectError - BooleanArray.from( [ true, true ], false ); // $ExpectError - BooleanArray.from( [ true, true ], 123 ); // $ExpectError - BooleanArray.from( [ true, true ], null ); // $ExpectError - BooleanArray.from( [ true, true ], {} ); // $ExpectError -} - -// The `of` method returns a boolean array... -{ - BooleanArray.of( true, true, true, true ); // $ExpectType BooleanArray -} diff --git a/bool/examples/index.js b/bool/examples/index.js deleted file mode 100644 index 76abe9eb7..000000000 --- a/bool/examples/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -var Uint8Array = require( './../../uint8' ); -var logEach = require( '@stdlib/console/log-each' ); -var BooleanArray = require( './../lib' ); - -// Create a boolean array by specifying a length: -var out = new BooleanArray( 3 ); -logEach( '%s', out ); - -// Create a boolean array from an array of booleans: -var arr = [ true, false, true ]; -out = new BooleanArray( arr ); -logEach( '%s', out ); - -// Create a boolean array from an array buffer: -arr = new Uint8Array( [ 1, 0, 1, 1, 0, 1 ] ); -out = new BooleanArray( arr.buffer ); -logEach( '%s', out ); - -// Create a boolean array from an array buffer view: -arr = new Uint8Array( [ 1, 0, 1, 1, 0, 1 ] ); -out = new BooleanArray( arr.buffer, 1, 2 ); -logEach( '%s', out ); - -console.log( '%s', false ); diff --git a/bool/lib/from_array.js b/bool/lib/from_array.js deleted file mode 100644 index 1a8840207..000000000 --- a/bool/lib/from_array.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean/ctor' ); - - -// MAIN // - -/** -* Fills an output array with "boolean" values. -* -* @private -* @param {Uint8Array} buf - output array -* @param {Array} arr - input array -* @returns {Uint8Array} output array -*/ -function fromArray( buf, arr ) { - var len; - var i; - - len = arr.length; - for ( i = 0; i < len; i++ ) { - buf[ i ] = Boolean( arr[ i ] ); - } - return buf; -} - - -// EXPORTS // - -module.exports = fromArray; diff --git a/bool/lib/from_iterator.js b/bool/lib/from_iterator.js deleted file mode 100644 index 4062b95c8..000000000 --- a/bool/lib/from_iterator.js +++ /dev/null @@ -1,53 +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. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean/ctor' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( Boolean( v.value ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/bool/lib/from_iterator_map.js b/bool/lib/from_iterator_map.js deleted file mode 100644 index 2bce56cbc..000000000 --- a/bool/lib/from_iterator_map.js +++ /dev/null @@ -1,58 +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. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean/ctor' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( Boolean( clbk.call( thisArg, v.value, i ) ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/bool/lib/index.js b/bool/lib/index.js deleted file mode 100644 index b44e4f2f1..000000000 --- a/bool/lib/index.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -/** -* Boolean array. -* -* @module @stdlib/array/bool -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var arr = new BooleanArray(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var arr = new BooleanArray( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var arr = new BooleanArray( [ true, false ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new BooleanArray( buf ); -* // returns -* -* var len = arr.length; -* // returns 16 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new BooleanArray( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new BooleanArray( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/bool/lib/main.js b/bool/lib/main.js deleted file mode 100644 index cf0ebe854..000000000 --- a/bool/lib/main.js +++ /dev/null @@ -1,2492 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert/is-collection' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isObject = require( '@stdlib/assert/is-object' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); -var Uint8Array = require( './../../uint8' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var getter = require( './../../base/getter' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var format = require( '@stdlib/string/format' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); -var fromArray = require( './from_array.js' ); - - -// VARIABLES // - -var BYTES_PER_ELEMENT = Uint8Array.BYTES_PER_ELEMENT; -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating if a value is a `BooleanArray`. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a `BooleanArray` -*/ -function isBooleanArray( value ) { - return ( - typeof value === 'object' && - value !== null && - value.constructor.name === 'BooleanArray' && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); -} - -/** -* Returns a boolean indicating if a value is a boolean typed array constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a boolean typed array constructor -*/ -function isBooleanArrayConstructor( value ) { - return ( value === BooleanArray ); -} - - -// MAIN // - -/** -* Boolean array constructor. -* -* @constructor -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {TypeError} if provided only a single argument, must provide a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @returns {BooleanArray} boolean array -* -* @example -* var arr = new BooleanArray(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new BooleanArray( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new BooleanArray( [ true, false ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new BooleanArray( buf ); -* // returns -* -* var len = arr.length; -* // returns 16 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new BooleanArray( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 8 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new BooleanArray( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function BooleanArray() { - var byteOffset; - var nargs; - var buf; - var len; - var arg; - - nargs = arguments.length; - if ( !(this instanceof BooleanArray) ) { - if ( nargs === 0 ) { - return new BooleanArray(); - } - if ( nargs === 1 ) { - return new BooleanArray( arguments[0] ); - } - if ( nargs === 2 ) { - return new BooleanArray( arguments[0], arguments[1] ); - } - return new BooleanArray( arguments[0], arguments[1], arguments[2] ); - } - // Create the underlying data buffer... - if ( nargs === 0 ) { - buf = new Uint8Array( 0 ); // backward-compatibility - } else if ( nargs === 1 ) { - arg = arguments[ 0 ]; - if ( isNonNegativeInteger( arg ) ) { - buf = new Uint8Array( arg ); - } else if ( isCollection( arg ) ) { - buf = fromArray( new Uint8Array( arg.length ), arg ); - } else if ( isArrayBuffer( arg ) ) { - buf = new Uint8Array( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - buf = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - buf = new Uint8Array( fromIterator( buf ) ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - } else { - buf = arguments[ 0 ]; - if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) ); - } - byteOffset = arguments[ 1 ]; - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); - } - if ( nargs === 2 ) { - buf = new Uint8Array( buf, byteOffset ); - } else { - len = arguments[ 2 ]; - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); - } - if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) ); - } - buf = new Uint8Array( buf, byteOffset, len ); - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_length', buf.length ); - - return this; -} - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof BooleanArray -* @readonly -* @type {PositiveInteger} -* @default 1 -* -* @example -* var nbytes = BooleanArray.BYTES_PER_ELEMENT; -* // returns 1 -*/ -setReadOnly( BooleanArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - -/** -* Constructor name. -* -* @name name -* @memberof BooleanArray -* @readonly -* @type {string} -* @default 'BooleanArray' -* -* @example -* var str = BooleanArray.name; -* // returns 'BooleanArray' -*/ -setReadOnly( BooleanArray, 'name', 'BooleanArray' ); - -/** -* Creates a new boolean array from an array-like object or an iterable. -* -* @name from -* @memberof BooleanArray -* @type {Function} -* @param {(Collection|Iterable)} src - array-like object or iterable -* @param {Function} [clbk] - callback to invoke for each source element -* @param {*} [thisArg] - context -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be an array-like object or an iterable -* @throws {TypeError} second argument must be a function -* @returns {BooleanArray} boolean array -* -* @example -* var arr = BooleanArray.from( [ true, false ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* function clbk( v ) { -* return !v; -* } -* -* var arr = BooleanArray.from( [ true, false ], clbk ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -setReadOnly( BooleanArray, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var get; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isBooleanArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - if ( src.get && src.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = Boolean( clbk.call( thisArg, get( src, i ), i ) ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = tmp[ i ]; - } - return out; - } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); -}); - -/** -* Creates a new boolean array from a variable number of arguments. -* -* @name of -* @memberof BooleanArray -* @type {Function} -* @param {...*} element - array elements -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a boolean array -* @returns {BooleanArray} boolean array -* -* @example -* var arr = BooleanArray.of( true, true, true, true ); -* // returns -* -* var len = arr.length; -* // returns 4 -*/ -setReadOnly( BooleanArray, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isBooleanArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); -}); - -/** -* Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices. -* -* @name at -* @memberof BooleanArray.prototype -* @type {Function} -* @param {integer} idx - element index -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} must provide an integer -* @returns {(boolean|void)} array element -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var v = arr.at( 0 ); -* // returns true -* -* v = arr.at( -1 ); -* // returns true -* -* v = arr.at( 100 ); -* // returns undefined -*/ -setReadOnly( BooleanArray.prototype, 'at', function at( idx ) { - var buf; - var len; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); - } - len = this._length; - buf = this._buffer; - if ( idx < 0 ) { - idx += len; - } - if ( idx < 0 || idx >= len ) { - return; - } - return Boolean( buf[ idx ] ); -}); - -/** -* Pointer to the underlying data buffer. -* -* @name buffer -* @memberof BooleanArray.prototype -* @readonly -* @type {ArrayBuffer} -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var buf = arr.buffer; -* // returns -*/ -setReadOnlyAccessor( BooleanArray.prototype, 'buffer', function get() { - return this._buffer.buffer; -}); - -/** -* Size (in bytes) of the array. -* -* @name byteLength -* @memberof BooleanArray.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var byteLength = arr.byteLength; -* // returns 10 -*/ -setReadOnlyAccessor( BooleanArray.prototype, 'byteLength', function get() { - return this._buffer.byteLength; -}); - -/** -* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. -* -* @name byteOffset -* @memberof BooleanArray.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var byteOffset = arr.byteOffset; -* // returns 0 -*/ -setReadOnlyAccessor( BooleanArray.prototype, 'byteOffset', function get() { - return this._buffer.byteOffset; -}); - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof BooleanArray.prototype -* @readonly -* @type {PositiveInteger} -* @default 1 -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var nbytes = arr.BYTES_PER_ELEMENT; -* // returns 1 -*/ -setReadOnly( BooleanArray.prototype, 'BYTES_PER_ELEMENT', BooleanArray.BYTES_PER_ELEMENT ); - -/** -* Copies a sequence of elements within the array to the position starting at `target`. -* -* @name copyWithin -* @memberof BooleanArray.prototype -* @type {Function} -* @param {integer} target - index at which to start copying elements -* @param {integer} start - source index at which to copy elements from -* @param {integer} [end] - source index at which to stop copying elements from -* @throws {TypeError} `this` must be a boolean array -* @returns {BooleanArray} modified array -* -* @example -* var arr = new BooleanArray( 4 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( false, 2 ); -* arr.set( true, 3 ); -* -* // Copy the first two elements to the last two elements: -* arr.copyWithin( 2, 0, 2 ); -* -* var v = arr.get( 2 ); -* // returns true -* -* v = arr.get( 3 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'copyWithin', function copyWithin( target, start ) { - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled - if ( arguments.length === 2 ) { - this._buffer.copyWithin( target, start ); - } else { - this._buffer.copyWithin( target, start, arguments[2] ); - } - return this; -}); - -/** -* Returns an iterator for iterating over array key-value pairs. -* -* @name entries -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {Iterator} iterator -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var it = arr.entries(); -* -* var v = it.next().value; -* // returns [ 0, true ] -* -* v = it.next().value; -* // returns [ 1, false ] -* -* v = it.next().value; -* // returns [ 2, true ] -* -* var bool = it.next().done; -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'entries', function entries() { - var self; - var iter; - var len; - var buf; - var FLG; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': [ i, Boolean( buf[ i ] ) ], - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.entries(); - } -}); - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @name every -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( true, 1 ); -* arr.set( true, 2 ); -* -* var bool = arr.every( predicate ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'every', function every( predicate, thisArg ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( !predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) { - return false; - } - } - return true; -}); - -/** -* Returns a modified typed array filled with a fill value. -* -* @name fill -* @memberof BooleanArray.prototype -* @type {Function} -* @param {boolean} value - fill value -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a boolean -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be an integer -* @returns {BooleanArray} modified array -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.fill( true, 1 ); -* -* var v = arr.get( 0 ); -* // returns false -* -* v = arr.get( 1 ); -* // returns true -* -* v = arr.get( 2 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'fill', function fill( value, start, end ) { - var buf; - var len; - var val; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isBoolean( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', value ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); - } - if ( start < 0 ) { - start += len; - if ( start < 0 ) { - start = 0; - } - } - if ( arguments.length > 2 ) { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } - if ( end > len ) { - end = len; - } - } else { - end = len; - } - } else { - start = 0; - end = len; - } - if ( value ) { - val = 1; - } else { - val = 0; - } - for ( i = start; i < end; i++ ) { - buf[ i ] = val; - } - return this; -}); - -/** -* Returns a new array containing the elements of an array which pass a test implemented by a predicate function. -* -* @name filter -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {BooleanArray} boolean array -* -* @example -* function predicate( v ) { -* return ( v === true ); -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.filter( predicate ); -* // returns -* -* var len = out.length; -* // returns 2 -* -* var v = out.get( 0 ); -* // returns true -* -* v = out.get( 1 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'filter', function filter( predicate, thisArg ) { - var buf; - var out; - var i; - var v; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - v = Boolean( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - out.push( v ); - } - } - return new this.constructor( out ); -}); - -/** -* Returns the first element in an array for which a predicate function returns a truthy value. -* -* @name find -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var v = arr.find( predicate ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'find', function find( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = Boolean( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the first element in an array for which a predicate function returns a truthy value. -* -* @name findIndex -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var v = arr.findIndex( predicate ); -* // returns 0 -*/ -setReadOnly( BooleanArray.prototype, 'findIndex', function findIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - v = Boolean( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Returns the last element in an array for which a predicate function returns a truthy value. -* -* @name findLast -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {(boolean|void)} array element or undefined -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var v = arr.findLast( predicate ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'findLast', function findLast( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = Boolean( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return v; - } - } -}); - -/** -* Returns the index of the last element in an array for which a predicate function returns a truthy value. -* -* @name findLastIndex -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var v = arr.findLastIndex( predicate ); -* // returns 2 -*/ -setReadOnly( BooleanArray.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) { - var buf; - var v; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - v = Boolean( buf[ i ] ); - if ( predicate.call( thisArg, v, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Invokes a function once for each array element. -* -* @name forEach -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} fcn - function to invoke -* @param {*} [thisArg] - function invocation context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* -* @example -* function log( v, i ) { -* console.log( '%s: %s', i, v.toString() ); -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* arr.forEach( log ); -*/ -setReadOnly( BooleanArray.prototype, 'forEach', function forEach( fcn, thisArg ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - fcn.call( thisArg, Boolean( buf[ i ] ), i, this ); - } -}); - -/** -* Returns an array element. -* -* @name get -* @memberof BooleanArray.prototype -* @type {Function} -* @param {NonNegativeInteger} idx - element index -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} must provide a nonnegative integer -* @returns {(boolean|void)} array element -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var v = arr.get( 0 ); -* // returns false -* -* arr.set( [ true, false ], 0 ); -* -* v = arr.get( 0 ); -* // returns true -* -* v = arr.get( 100 ); -* // returns undefined -*/ -setReadOnly( BooleanArray.prototype, 'get', function get( idx ) { - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return Boolean( this._buffer[ idx ] ); -}); - -/** -* Returns a boolean indicating whether an array includes a provided value. -* -* @name includes -* @memberof BooleanArray.prototype -* @type {Function} -* @param {boolean} searchElement - search element -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a boolean value -* @throws {TypeError} second argument must be an integer -* @returns {boolean} boolean indicating whether an array includes a value -* -* @example -* var arr = new BooleanArray( 5 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* arr.set( true, 3 ); -* arr.set( true, 4 ); -* -* var bool = arr.includes( true ); -* // returns true -* -* bool = arr.includes( false, 2 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'includes', function includes( searchElement, fromIndex ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isBoolean( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - for ( i = fromIndex; i < this._length; i++ ) { - if ( searchElement === Boolean( buf[ i ] ) ) { - return true; - } - } - return false; -}); - -/** -* Returns the first index at which a given element can be found. -* -* @name indexOf -* @memberof BooleanArray.prototype -* @type {Function} -* @param {boolean} searchElement - element to find -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a boolean value -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new BooleanArray( 5 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* arr.set( true, 3 ); -* arr.set( true, 4 ); -* -* var idx = arr.indexOf( true ); -* // returns 0 -* -* idx = arr.indexOf( false, 2 ); -* // returns -1 -* -* idx = arr.indexOf( false, -3 ); -* // returns -1 -*/ -setReadOnly( BooleanArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isBoolean( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - for ( i = fromIndex; i < this._length; i++ ) { - if ( searchElement === Boolean( buf[ i ] ) ) { - return i; - } - } - return -1; -}); - -/** -* Returns a new string by concatenating all array elements. -* -* @name join -* @memberof BooleanArray.prototype -* @type {Function} -* @param {string} [separator=','] - element separator -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a string -* @returns {string} string representation -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var str = arr.join(); -* // returns 'true,false,true' -* -* str = arr.join( '|' ); -* // returns 'true|false|true' -*/ -setReadOnly( BooleanArray.prototype, 'join', function join( separator ) { - var buf; - var out; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( arguments.length > 0 ) { - if ( !isString( separator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); - } - } else { - separator = ','; - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - if ( buf[i] ) { - out.push( 'true' ); - } else { - out.push( 'false' ); - } - } - return out.join( separator ); -}); - -/** -* Returns an iterator for iterating over each index key in a typed array. -* -* @name keys -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {Iterator} iterator -* -* @example -* var arr = new BooleanArray( 2 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* -* var iter = arr.keys(); -* -* var v = iter.next().value; -* // returns 0 -* -* v = iter.next().value; -* // returns 1 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'keys', function keys() { - var self; - var iter; - var len; - var FLG; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - self = this; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': i, - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.keys(); - } -}); - -/** -* Returns the last index at which a given element can be found. -* -* @name lastIndexOf -* @memberof BooleanArray.prototype -* @type {Function} -* @param {boolean} searchElement - element to find -* @param {integer} [fromIndex] - starting index (inclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a boolean value -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var arr = new BooleanArray( 5 ); -* -* arr.set( true, 0 ); -* arr.set( true, 1 ); -* arr.set( true, 2 ); -* arr.set( false, 3 ); -* arr.set( true, 4 ); -* -* var idx = arr.lastIndexOf( true ); -* // returns 4 -* -* idx = arr.lastIndexOf( false, 2 ); -* // returns -1 -* -* idx = arr.lastIndexOf( false, -3 ); -* // returns -1 -*/ -setReadOnly( BooleanArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isBoolean( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex >= this._length ) { - fromIndex = this._length - 1; - } else if ( fromIndex < 0 ) { - fromIndex += this._length; - } - } else { - fromIndex = this._length - 1; - } - buf = this._buffer; - for ( i = fromIndex; i >= 0; i-- ) { - if ( searchElement === Boolean( buf[ i ] ) ) { - return i; - } - } - return -1; -}); - -/** -* Number of array elements. -* -* @name length -* @memberof BooleanArray.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var len = arr.length; -* // returns 10 -*/ -setReadOnlyAccessor( BooleanArray.prototype, 'length', function get() { - return this._length; -}); - -/** -* Returns a new array with each element being the result of a provided callback function. -* -* @name map -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {BooleanArray} new boolean array -* -* @example -* function invert( v ) { -* return !v; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.map( invert ); -* // returns -* -* var z = out.get( 0 ); -* // returns false -* -* z = out.get( 1 ); -* // returns true -* -* z = out.get( 2 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'map', function map( fcn, thisArg ) { - var outbuf; - var out; - var buf; - var i; - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ); - } - buf = this._buffer; - out = new this.constructor( this._length ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < this._length; i++ ) { - outbuf[ i ] = Boolean( fcn.call( thisArg, Boolean( buf[ i ] ), i, this ) ); - } - return out; -}); - -/** -* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduce -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a boolean array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function reducer( acc, v ) { -* if ( v ) { -* return acc + 1; -* } -* return acc; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.reduce( reducer, 0 ); -* // returns 2 -*/ -setReadOnly( BooleanArray.prototype, 'reduce', function reduce( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = 0; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = Boolean( buf[ 0 ] ); - i = 1; - } - for ( ; i < len; i++ ) { - acc = reducer( acc, Boolean( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduceRight -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a boolean array -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* function reducer( acc, v ) { -* if ( v ) { -* return acc + 1; -* } -* return acc; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.reduceRight( reducer, 0 ); -* // returns 2 -*/ -setReadOnly( BooleanArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = len - 1; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = Boolean( buf[ len-1 ] ); - i = len - 2; - } - for ( ; i >= 0; i-- ) { - acc = reducer( acc, Boolean( buf[ i ] ), i, this ); - } - return acc; -}); - -/** -* Reverses an array in-place. -* -* @name reverse -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {BooleanArray} reversed array -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( false, 2 ); -* -* var out = arr.reverse(); -* // returns -* -* var v = out.get( 0 ); -* // returns false -* -* v = out.get( 1 ); -* // returns false -* -* v = out.get( 2 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'reverse', function reverse() { - var buf; - var tmp; - var len; - var N; - var i; - var j; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - buf = this._buffer; - len = this._length; - N = floor( len / 2 ); - for ( i = 0; i < N; i++ ) { - j = len - i - 1; - tmp = buf[ i ]; - buf[ i ] = buf[ j ]; - buf[ j ] = tmp; - } - return this; -}); - -/** -* Sets an array element. -* -* ## Notes -* -* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. -* -* In the other overlapping scenario, -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended. -* -* @name set -* @memberof BooleanArray.prototype -* @type {Function} -* @param {(Collection|BooleanArray|*)} value - value(s) -* @param {NonNegativeInteger} [i=0] - element index at which to start writing values -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} index argument must be a nonnegative integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {RangeError} target array lacks sufficient storage to accommodate source values -* @returns {void} -* -* @example -* var arr = new BooleanArray( 10 ); -* -* var v = arr.get( 0 ); -* // returns false -* -* arr.set( [ true, false ], 0 ); -* -* v = arr.get( 0 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'set', function set( value ) { - var sbuf; - var idx; - var buf; - var tmp; - var N; - var i; - var j; - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - buf = this._buffer; - if ( arguments.length > 1 ) { - idx = arguments[ 1 ]; - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); - } - } else { - idx = 0; - } - if ( isCollection( value ) ) { - N = value.length; - if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); - } - if ( isBooleanArray( value ) ) { - sbuf = value._buffer; // eslint-disable-line no-underscore-dangle - } else { - sbuf = value; - } - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = new Uint8Array( sbuf.length ); - for ( i = 0; i < sbuf.length; i++ ) { - tmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays - } - sbuf = tmp; - } - for ( i = 0; i < N; idx++, i++ ) { - buf[ idx ] = ( sbuf[ i ] ) ? 1 : 0; - } - return; - } - if ( idx >= this._length ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) ); - } - buf[ idx ] = ( value ) ? 1 : 0; -}); - -/** -* Copies a portion of a typed array to a new typed array. -* -* @name slice -* @memberof BooleanArray.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be integer -* @throws {TypeError} second argument must be integer -* @returns {BooleanArray} boolean array -* -* @example -* var arr = new BooleanArray( 5 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* arr.set( false, 3 ); -* arr.set( true, 4 ); -* -* var out = arr.slice(); -* // returns -* -* var len = out.length; -* // returns 5 -* -* var bool = out.get( 0 ); -* // returns true -* -* bool = out.get( len-1 ); -* // returns true -* -* out = arr.slice( 1, -2 ); -* // returns -* -* len = out.length; -* // returns 2 -* -* bool = out.get( 0 ); -* // returns false -* -* bool = out.get( len-1 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'slice', function slice( begin, end ) { - var outlen; - var outbuf; - var out; - var buf; - var len; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin < end ) { - outlen = end - begin; - } else { - outlen = 0; - } - out = new this.constructor( outlen ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < outlen; i++ ) { - outbuf[ i ] = buf[ i+begin ]; - } - return out; -}); - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @name some -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} predicate - predicate function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* function predicate( v ) { -* return v === true; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( false, 0 ); -* arr.set( true, 1 ); -* arr.set( false, 2 ); -* -* var bool = arr.some( predicate ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'some', function some( predicate, thisArg ) { - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) { - return true; - } - } - return false; -}); - -/** -* Sorts an array in-place. -* -* @name sort -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {BooleanArray} sorted array -* -* @example -* function compare( a, b ) { -* if ( a === false ) { -* if ( b === false ) { -* return 0; -* } -* return 1; -* } -* if ( b === true ) { -* return 0; -* } -* return -1; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* arr.sort( compare ); -* -* var v = arr.get( 0 ); -* // returns true -* -* v = arr.get( 1 ); -* // returns true -* -* v = arr.get( 2 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'sort', function sort( compareFcn ) { - var buf; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - buf = this._buffer; - if ( arguments.length === 0 ) { - buf.sort(); - return this; - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); - } - buf.sort( compare ); - return this; - - /** - * Comparison function for sorting. - * - * @private - * @param {boolean} a - first boolean value for comparison - * @param {boolean} b - second boolean value for comparison - * @returns {number} comparison result - */ - function compare( a, b ) { - return compareFcn( Boolean( a ), Boolean( b ) ); - } -}); - -/** -* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. -* -* @name subarray -* @memberof BooleanArray.prototype -* @type {Function} -* @param {integer} [begin] - start index (inclusive) -* @param {integer} [end] - end index (exclusive) -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be an integer -* @throws {TypeError} second argument must be an integer -* @returns {BooleanArray} subarray -* -* @example -* var arr = new BooleanArray( 5 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* arr.set( false, 3 ); -* arr.set( true, 4 ); -* -* var subarr = arr.subarray(); -* // returns -* -* var len = subarr.length; -* // returns 5 -* -* var bool = subarr.get( 0 ); -* // returns true -* -* bool = subarr.get( len-1 ); -* // returns true -* -* subarr = arr.subarray( 1, -2 ); -* // returns -* -* len = subarr.length; -* // returns 2 -* -* bool = subarr.get( 0 ); -* // returns false -* -* bool = subarr.get( len-1 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'subarray', function subarray( begin, end ) { - var offset; - var buf; - var len; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin >= len ) { - len = 0; - offset = buf.byteLength; - } else if ( begin >= end ) { - len = 0; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } else { - len = end - begin; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } - return new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len ); -}); - -/** -* Serializes an array as a locale-specific string. -* -* @name toLocaleString -* @memberof BooleanArray.prototype -* @type {Function} -* @param {(string|Array)} [locales] - locale identifier(s) -* @param {Object} [options] - configuration options -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a string or an array of strings -* @throws {TypeError} options argument must be an object -* @returns {string} string representation -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var str = arr.toLocaleString(); -* // returns 'true,false,true' -*/ -setReadOnly( BooleanArray.prototype, 'toLocaleString', function toLocaleString( locales, options ) { - var opts; - var loc; - var out; - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( arguments.length === 0 ) { - loc = []; - } else if ( isString( locales ) || isStringArray( locales ) ) { - loc = locales; - } else { - throw new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) ); - } - if ( arguments.length < 2 ) { - opts = {}; - } else if ( isObject( options ) ) { - opts = options; - } else { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( Boolean( buf[ i ] ).toLocaleString( loc, opts ) ); - } - return out.join( ',' ); -}); - -/** -* Returns a new typed array containing the elements in reversed order. -* -* @name toReversed -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {BooleanArray} reversed array -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( false, 2 ); -* -* var out = arr.toReversed(); -* // returns -* -* var v = out.get( 0 ); -* // returns false -* -* v = out.get( 1 ); -* // returns false -* -* v = out.get( 2 ); -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'toReversed', function toReversed() { - var outbuf; - var out; - var len; - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - len = this._length; - out = new this.constructor( len ); - buf = this._buffer; - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - outbuf[ i ] = buf[ len - i - 1 ]; - } - return out; -}); - -/** -* Returns a new typed array containing the elements in sorted order. -* -* @name toSorted -* @memberof BooleanArray.prototype -* @type {Function} -* @param {Function} [compareFcn] - comparison function -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be a function -* @returns {BooleanArray} sorted array -* -* @example -* function compare( a, b ) { -* if ( a === false ) { -* if ( b === false ) { -* return 0; -* } -* return 1; -* } -* if ( b === true ) { -* return 0; -* } -* return -1; -* } -* -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.sort( compare ); -* // returns -* -* var v = out.get( 0 ); -* // returns true -* -* v = out.get( 1 ); -* // returns true -* -* v = out.get( 2 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'toSorted', function toSorted( compareFcn ) { - var outbuf; - var out; - var len; - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - len = this._length; - out = new this.constructor( len ); - buf = this._buffer; - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - outbuf[ i ] = buf[ i ]; - } - if ( arguments.length === 0 ) { - outbuf.sort(); - return out; - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); - } - outbuf.sort( compare ); - return out; - - /** - * Comparison function for sorting. - * - * @private - * @param {boolean} a - first boolean value for comparison - * @param {boolean} b - second boolean value for comparison - * @returns {number} comparison result - */ - function compare( a, b ) { - return compareFcn( Boolean( a ), Boolean( b ) ); - } -}); - -/** -* Serializes an array as a string. -* -* @name toString -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {string} string representation -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var str = arr.toString(); -* // returns 'true,false,true' -*/ -setReadOnly( BooleanArray.prototype, 'toString', function toString() { - var out; - var buf; - var i; - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - out = []; - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( buf[i] ) { - out.push( 'true' ); - } else { - out.push( 'false' ); - } - } - return out.join( ',' ); -}); - -/** -* Returns an iterator for iterating over each value in a typed array. -* -* @name values -* @memberof BooleanArray.prototype -* @type {Function} -* @throws {TypeError} `this` must be a boolean array -* @returns {Iterator} iterator -* -* @example -* var arr = new BooleanArray( 2 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* -* var iter = arr.values(); -* -* var v = iter.next().value; -* // returns true -* -* v = iter.next().value; -* // returns false -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( BooleanArray.prototype, 'values', function values() { - var iter; - var self; - var len; - var FLG; - var buf; - var i; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': Boolean( buf[ i ] ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.values(); - } -}); - -/** -* Returns a new typed array with the element at a provided index replaced with a provided value. -* -* @name with -* @memberof BooleanArray.prototype -* @type {Function} -* @param {integer} index - element index -* @param {boolean} value - new value -* @throws {TypeError} `this` must be a boolean array -* @throws {TypeError} first argument must be an integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {TypeError} second argument must be a boolean -* @returns {BooleanArray} new typed array -* -* @example -* var arr = new BooleanArray( 3 ); -* -* arr.set( true, 0 ); -* arr.set( false, 1 ); -* arr.set( true, 2 ); -* -* var out = arr.with( 0, false ); -* // returns -* -* var v = out.get( 0 ); -* // returns false -*/ -setReadOnly( BooleanArray.prototype, 'with', function copyWith( index, value ) { - var buf; - var out; - var len; - - if ( !isBooleanArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a boolean array.' ); - } - if ( !isInteger( index ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); - } - len = this._length; - if ( index < 0 ) { - index += len; - } - if ( index < 0 || index >= len ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); - } - if ( !isBoolean( value ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a boolean. Value: `%s`.', value ) ); - } - out = new this.constructor( this._buffer ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - if ( value ) { - buf[ index ] = 1; - } else { - buf[ index ] = 0; - } - return out; -}); - - -// EXPORTS // - -module.exports = BooleanArray; diff --git a/bool/package.json b/bool/package.json deleted file mode 100644 index 094f66420..000000000 --- a/bool/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/bool", - "version": "0.0.0", - "description": "BooleanArray.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "booleanarray", - "boolean", - "bool", - "binary", - "mask" - ] -} diff --git a/bool/test/test.at.js b/bool/test/test.at.js deleted file mode 100644 index e43dd6d7d..000000000 --- a/bool/test/test.at.js +++ /dev/null @@ -1,136 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'at' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.at.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.at( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new BooleanArray( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var expected; - var arr; - var v; - var i; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = [ true, false, true, false, true, true, false, true, false, true ]; - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - t.strictEqual( v, expected[ i+arr.length ], 'returns expected value' ); - } - t.end(); -}); diff --git a/bool/test/test.copy_within.js b/bool/test/test.copy_within.js deleted file mode 100644 index 863bc4c5f..000000000 --- a/bool/test/test.copy_within.js +++ /dev/null @@ -1,215 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var Uint8Array = require( './../../uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a boolean array', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 0, 5 ); - - expected = new Uint8Array( [ 0, 0, 1, 1, 1, 0, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( -arr.length, 5 ); - - expected = new Uint8Array( [ 0, 0, 1, 1, 1, 0, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 0, -3 ); - - expected = new Uint8Array( [ 0, 0, 1, 1, 1, 0, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 0, 5, arr.length ); - - expected = new Uint8Array( [ 0, 0, 1, 1, 1, 0, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 2, 0, 4 ); - - expected = new Uint8Array( [ 1, 0, 1, 0, 0, 1, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 2, 0, -4 ); - - expected = new Uint8Array( [ 1, 0, 1, 0, 0, 1, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( arr.length, 5 ); - - expected = new Uint8Array( [ 1, 0, 0, 1, 1, 0, 0, 1 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false, false, true ] ); - arr.copyWithin( 2, 0 ); - - expected = new Uint8Array( [ 1, 0, 1, 0, 0, 1, 1, 0 ] ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); diff --git a/bool/test/test.entries.js b/bool/test/test.entries.js deleted file mode 100644 index 1d85b375b..000000000 --- a/bool/test/test.entries.js +++ /dev/null @@ -1,237 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'entries' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns expected value' ); - t.strictEqual( v.value[ 0 ], i, 'returns expected value' ); - t.strictEqual( isBoolean( v.value[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( v.value[ 1 ], buf[ i ], 'returns expected value' ); - t.strictEqual( typeof v.done, 'boolean', 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (no argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], buf[ 0 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], buf[ 1 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( v.value[ 1 ], buf[ 0 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value[ 1 ], buf[ 1 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'finished' ); - t.strictEqual( v.value, 'finished', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it1 = arr.entries(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns an object' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1[ 0 ], v2[ 0 ], 'returns expected value' ); - t.strictEqual( v1[ 1 ], v2[ 1 ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it = arr.entries(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/bool/test/test.every.js b/bool/test/test.every.js deleted file mode 100644 index 0eae1a727..000000000 --- a/bool/test/test.every.js +++ /dev/null @@ -1,173 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'every' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty boolean array', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray(); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, true, true, true ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, false, true, false ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ true, true, true, true ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === true; - } -}); diff --git a/bool/test/test.fill.js b/bool/test/test.fill.js deleted file mode 100644 index 00d772054..000000000 --- a/bool/test/test.fill.js +++ /dev/null @@ -1,280 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Uint8Array = require( './../../uint8' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'fill' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a boolean', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( true, value ); - }; - } -}); - -tape( 'the method throws an error if provided a third argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( true, 0, value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.fill( true ); - - t.strictEqual( out instanceof BooleanArray, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( 10 ); - out = arr.fill( true ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr.fill( true ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 0, 1, 1 ] ); - - arr.fill( true, 1 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 1, 1, 0 ] ); - - arr.fill( true, 0, 2 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 1, 1, 0 ] ); - - arr.fill( true, -3, -1 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr.fill( true, -10 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 0, 1, 1 ] ); - - arr.fill( true, 1, 10 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var expected; - var arr; - - arr = new BooleanArray( 3 ); - expected = new Uint8Array( [ 0, 0, 0 ] ); - - arr.fill( true, 2, 1 ); - - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.filter.js b/bool/test/test.filter.js deleted file mode 100644 index 6d8ed5053..000000000 --- a/bool/test/test.filter.js +++ /dev/null @@ -1,208 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Uint8Array = require( './../../uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'filter' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method returns a new boolean array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true ] ); - expected = new Uint8Array( [ 1, 1 ] ); - actual = arr.filter( predicate ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, true, true, true ] ); - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - actual = arr.filter( predicate ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ false, false, false, false ] ); - expected = new Uint8Array( [] ); - actual = arr.filter( predicate ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var ctx; - - arr = new BooleanArray( [ true, false, true ] ); - expected = new Uint8Array( [ 1, 1 ] ); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === true ); - } -}); diff --git a/bool/test/test.find.js b/bool/test/test.find.js deleted file mode 100644 index c675e996b..000000000 --- a/bool/test/test.find.js +++ /dev/null @@ -1,173 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'find' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty boolean array', function test( t ) { - var arr; - var v; - - arr = new BooleanArray(); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( [ true, false, true, false ] ); - v = arr.find( predicate ); - - t.strictEqual( v, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === false ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( [ true, true, true, true, true ] ); - v = arr.find( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === false ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ true, true, false, true, false ] ); - v = arr.find( predicate, ctx ); - - t.strictEqual( v, false, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === false ); - } -}); diff --git a/bool/test/test.find_index.js b/bool/test/test.find_index.js deleted file mode 100644 index 0a9f8e181..000000000 --- a/bool/test/test.find_index.js +++ /dev/null @@ -1,173 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'findIndex' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty boolean array', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray(); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray( [ false, false, true, true ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray( [ false, false, false, false ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ false, true, true, false ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === true ); - } -}); diff --git a/bool/test/test.find_last.js b/bool/test/test.find_last.js deleted file mode 100644 index bdd461acc..000000000 --- a/bool/test/test.find_last.js +++ /dev/null @@ -1,173 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'findLast' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === false ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty boolean array', function test( t ) { - var arr; - var v; - - arr = new BooleanArray(); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === false ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( [ true, true, true, true, true ] ); - v = arr.findLast( predicate ); - - t.strictEqual( v, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === false ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var v; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ true, true, false, true, false ] ); - v = arr.findLast( predicate, ctx ); - - t.strictEqual( v, true, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === true ); - } -}); diff --git a/bool/test/test.find_last_index.js b/bool/test/test.find_last_index.js deleted file mode 100644 index 027cf150d..000000000 --- a/bool/test/test.find_last_index.js +++ /dev/null @@ -1,173 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'findLastIndex' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty boolean array', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray(); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray( [ false, false, true, true ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray( [ false, false, false, false ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( v === true ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ false, true, true, false ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v === true ); - } -}); diff --git a/bool/test/test.for_each.js b/bool/test/test.for_each.js deleted file mode 100644 index 4251b2a70..000000000 --- a/bool/test/test.for_each.js +++ /dev/null @@ -1,187 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'forEach' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isBoolean( v ) ) { - t.fail( 'should be a boolean' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty boolean array', function test( t ) { - var arr; - - arr = new BooleanArray(); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, true ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isBoolean( v ) ) { - t.fail( 'should be a boolean' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var indices; - var values; - var arrays; - var arr; - - indices = []; - values = []; - arrays = []; - - arr = new BooleanArray( [ true, false, false, true ] ); - arr.forEach( fcn ); - - t.deepEqual( values, [ true, false, false, true ], 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ true, false, false, true ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/bool/test/test.from.js b/bool/test/test.from.js deleted file mode 100644 index 8e6f3322d..000000000 --- a/bool/test/test.from.js +++ /dev/null @@ -1,654 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Uint8Array = require( './../../float32' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a boolean array from an array-like object or iterable', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( BooleanArray, 'from' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.from ), true, 'has method' ); - - arr = BooleanArray.from( [] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( value, clbk ); - }; - } - - function clbk() { - return true; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback, thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( value, clbk, {} ); - }; - } - - function clbk() { - return true; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a boolean array', function test( t ) { - var arr; - var v; - - // Generic array: - arr = BooleanArray.from( [] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( [ true, true, true, true ] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-booleans: - arr = BooleanArray.from( [ 'beep' ] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = BooleanArray.from( [ null, 4 ] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = BooleanArray.from( [ true, {}, '' ] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 3, 'returns expected value' ); - - // Typed array: - arr = BooleanArray.from( new Uint8Array( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( new Uint8Array( [ 1, 1 ] ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Boolean typed array: - arr = BooleanArray.from( new BooleanArray( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( new BooleanArray( [ true, false ] ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns a boolean array (iterable)', function test( t ) { - var BooleanArray; - var iter; - var arr; - var v; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = BooleanArray.from( createIterable( iter ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var v; - - // Generic array: - arr = BooleanArray.from( [], clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( [ true, true, true, true ], clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Generic array containing non-booleans: - arr = BooleanArray.from( [ 'beep' ], clbk2 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = BooleanArray.from( [ null ], clbk2 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = BooleanArray.from( [ [], {} ], clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - arr = BooleanArray.from( [ 4, 5 ], clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Typed array: - arr = BooleanArray.from( new Uint8Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( new Uint8Array( [ 1, 1 ] ), clbk1 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Boolean typed array: - arr = BooleanArray.from( new BooleanArray( 0 ), clbk2 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = BooleanArray.from( new BooleanArray( [ true, true ] ), clbk2 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - return v; - } - - function clbk2() { - return true; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each iterated value', function test( t ) { - var BooleanArray; - var iter; - var arr; - var v; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = BooleanArray.from( createIterable( iter ), clbk ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - return !v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = BooleanArray.from( [ true, true, true, true ], clbk1, ctx ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method supports providing a `this` context for a provided map function (iterable)', function test( t ) { - var BooleanArray; - var iter; - var ctx; - var arr; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - ctx = { - 'count': 0 - }; - - arr = BooleanArray.from( createIterable( iter ), clbk, ctx ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var BooleanArray; - var values; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var BooleanArray; - var values; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); diff --git a/bool/test/test.get.js b/bool/test/test.get.js deleted file mode 100644 index 0352bf54e..000000000 --- a/bool/test/test.get.js +++ /dev/null @@ -1,135 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.get.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.get( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new BooleanArray( 10 ); - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i%2 ); - } - arr = new BooleanArray( arr ); - - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, Boolean( i%2 ), 'returns expected value for index '+i ); - } - t.end(); -}); diff --git a/bool/test/test.includes.js b/bool/test/test.includes.js deleted file mode 100644 index 8cf5a5c5b..000000000 --- a/bool/test/test.includes.js +++ /dev/null @@ -1,221 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'includes' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a boolean value', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes( true, value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty boolean array', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray(); - bool = arr.includes( true ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a boolean value is not found', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( 10 ); - bool = arr.includes( true ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified boolean value', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, false, false, true] ); - bool = arr.includes( false ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( 10 ); - bool = arr.includes( true, 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, false, true, true, true ] ); - - bool = arr.includes( true, 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( false, 1 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( false, 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, false, true, true, true ] ); - - bool = arr.includes( true, -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( false, -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ true, false, true, true, true ] ); - - bool = arr.includes( true, -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( false, -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.index_of.js b/bool/test/test.index_of.js deleted file mode 100644 index 9558e9d02..000000000 --- a/bool/test/test.index_of.js +++ /dev/null @@ -1,221 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'indexOf' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a boolean value', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf( true, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty boolean array', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray(); - idx = arr.indexOf( true ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a boolean value is not found', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( 10 ); - idx = arr.indexOf( true ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a boolean value is found', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - idx = arr.indexOf( false ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( 10 ); - idx = arr.indexOf( false, 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.indexOf( false, 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( true, 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( false, 3 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.indexOf( false, -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( false, -2 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.indexOf( false, -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( true, -10 ); - t.strictEqual( idx, 0, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.join.js b/bool/test/test.join.js deleted file mode 100644 index 096cf8c0f..000000000 --- a/bool/test/test.join.js +++ /dev/null @@ -1,162 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'join' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.join.call( value ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.join( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new BooleanArray(); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a boolean array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - expected = 'true@false@false@true'; - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a boolean array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new BooleanArray( [ true ] ); - expected = 'true'; - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new BooleanArray( [ false ] ); - expected = 'false'; - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a boolean array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - expected = 'true,false,false,true'; - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.js b/bool/test/test.js deleted file mode 100644 index 879a11a3b..000000000 --- a/bool/test/test.js +++ /dev/null @@ -1,660 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var ArrayBuffer = require( './../../buffer' ); -var Uint8Array = require( './../../uint8' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new BooleanArray( 0 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( 0 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (no argument)', function test( t ) { - var arr = new BooleanArray(); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (no argument, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor(); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (length)', function test( t ) { - var arr = new BooleanArray( 10 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( 10 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (array)', function test( t ) { - var arr = new BooleanArray( [] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( [] ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (typed array)', function test( t ) { - var arr = new BooleanArray( new Uint8Array( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( new Uint8Array( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (iterable)', function test( t ) { - var BooleanArray; - var arr; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - arr = new BooleanArray( createIterable() ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a boolean array (iterable, no new)', function test( t ) { - var ctor; - var arr; - - ctor = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - arr = ctor( createIterable() ); - t.strictEqual( arr instanceof ctor, true, 'returns an instance' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer)', function test( t ) { - var arr = new BooleanArray( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new BooleanArray( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer, byte offset, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new BooleanArray( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a boolean array (ArrayBuffer, byte offset, length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = BooleanArray; - - arr = ctor( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( BooleanArray.BYTES_PER_ELEMENT, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray, 'name' ), true, 'has property' ); - t.strictEqual( BooleanArray.name, 'BooleanArray', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( BooleanArray.prototype.BYTES_PER_ELEMENT, 1, 'returns expected value' ); - - arr = new BooleanArray( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new BooleanArray( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new BooleanArray( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var v; - - // No arguments: - arr = new BooleanArray(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new BooleanArray( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new BooleanArray( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( [ true, false, true, false ] ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Typed array: - arr = new BooleanArray( new Uint8Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( new Uint8Array( [ 1, 1 ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Boolean typed array: - arr = new BooleanArray( new BooleanArray( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( new BooleanArray( [ true, true ] ) ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // ArrayBuffer: - arr = new BooleanArray( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new BooleanArray( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements (iterable)', function test( t ) { - var BooleanArray; - var iter; - var arr; - var v; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - arr = new BooleanArray( createIterable( iter ) ); - v = arr.length; - t.strictEqual( v, iter.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': true - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var BooleanArray; - var values; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var BooleanArray; - var values; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( value ); - }; - } -}); - -tape( 'the constructor throws an error if provided more than one argument and the first argument is not an ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( value, 0 ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( new ArrayBuffer( 64 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a length argument which is not a nonnegative integer (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( new ArrayBuffer( 64 ), 0, value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new BooleanArray( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/bool/test/test.keys.js b/bool/test/test.keys.js deleted file mode 100644 index 5aa8284d1..000000000 --- a/bool/test/test.keys.js +++ /dev/null @@ -1,261 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'keys' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new BooleanArray( [ true, false ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new BooleanArray( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new BooleanArray( [ true, false, true ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new BooleanArray( [ true, false, true ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1, 0, 0, 1 ]; - arr = new BooleanArray( buf ); - - it1 = arr.keys(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns an object' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - buf = [ 1, 0, 0, 1 ]; - arr = new BooleanArray( buf ); - - it = arr.keys(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/bool/test/test.last_index_of.js b/bool/test/test.last_index_of.js deleted file mode 100644 index 3fdb29736..000000000 --- a/bool/test/test.last_index_of.js +++ /dev/null @@ -1,210 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'lastIndexOf' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf.call( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a boolean value', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf( true, value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty boolean array', function test( t ) { - var arr; - var idx; - - arr = new BooleanArray(); - idx = arr.lastIndexOf( true ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a boolean value is not found', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( 10 ); - idx = arr.lastIndexOf( true ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - idx = arr.lastIndexOf( false ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.lastIndexOf( true, 4 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( false, 2 ); - t.strictEqual( idx, 2, 'returns expected value' ); - - idx = arr.lastIndexOf( false, 0 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.lastIndexOf( true, -3 ); - t.strictEqual( idx, 0, 'returns expected value' ); - - idx = arr.lastIndexOf( false, -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true ] ); - - idx = arr.lastIndexOf( true, 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( false, 10 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.map.js b/bool/test/test.map.js deleted file mode 100644 index 3d3a5d5c1..000000000 --- a/bool/test/test.map.js +++ /dev/null @@ -1,164 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var identity = require( '@stdlib/utils/identity-function' ); -var reinterpretBool = require( '@stdlib/strided/base/reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Uint8Array = require( './../../uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'map' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new boolean array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - expected = new Uint8Array( [ 0, 1, 1, 0, 0, 1 ] ); - actual = arr.map( invert ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function invert( v ) { - return !v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var ctx; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - expected = new Uint8Array( [ 0, 1, 1, 0, 0, 1 ] ); - ctx = { - 'count': 0 - }; - actual = arr.map( invert, ctx ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBool( actual, 0 ), expected, 'returns expected value' ); - t.strictEqual( ctx.count, 15, 'returns expected value' ); - t.end(); - - function invert( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return !v; - } -}); diff --git a/bool/test/test.of.js b/bool/test/test.of.js deleted file mode 100644 index b9e6dc4e0..000000000 --- a/bool/test/test.of.js +++ /dev/null @@ -1,130 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a boolean array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( BooleanArray, 'of' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.of ), true, 'has method' ); - - arr = BooleanArray.of(); - t.strictEqual( arr instanceof BooleanArray, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.of.call( value, true, true ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array constructor', function test( t ) { - var values; - var i; - - values = [ - {}, - null, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return BooleanArray.of.call( value, true, true ); - }; - } -}); - -tape( 'the method returns a boolean array', function test( t ) { - var arr; - var v; - - // No arguments: - arr = BooleanArray.of(); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Boolean arguments: - arr = BooleanArray.of( true, false, false, true ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - // Non-boolean arguments: - arr = BooleanArray.of( 1, {}, 0, null, 'beep' ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - arr = BooleanArray.of( true, 1, false, 0 ); - t.strictEqual( arr instanceof BooleanArray, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/bool/test/test.reduce.js b/bool/test/test.reduce.js deleted file mode 100644 index 8684c68d7..000000000 --- a/bool/test/test.reduce.js +++ /dev/null @@ -1,197 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'reduce' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty boolean array', function test( t ) { - var arr; - - arr = new BooleanArray( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var ind; - - arr = new BooleanArray( [ true, false, true, false ] ); - accArray = [ true, false, false ]; - valueArray = [ false, true, false ]; - expected = false; - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, accArray[ ind ], 'returns expected value' ); - t.strictEqual( value, valueArray[ ind ], 'returns expected value' ); - return ( acc && value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - accArray = [ 0, 1, 1, 1 ]; - valueArray = [ true, false, false, true ]; - expected = 2; - actual = arr.reduce( reducer, 0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, accArray[ index ], 'returns expected value' ); - t.strictEqual( value, valueArray[ index ], 'returns expected value' ); - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, true ] ); - expected = false; - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return ( acc && value ); - } -}); diff --git a/bool/test/test.reduce_right.js b/bool/test/test.reduce_right.js deleted file mode 100644 index bbfd96674..000000000 --- a/bool/test/test.reduce_right.js +++ /dev/null @@ -1,200 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'reduceRight' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty boolean array', function test( t ) { - var arr; - - arr = new BooleanArray( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new BooleanArray( [ true, false, true, false ] ); - len = arr.length; - accArray = [ false, false, false ]; - valueArray = [ true, false, true ]; - expected = false; - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-2); - t.strictEqual( acc, accArray[ ind ], 'returns expected value' ); - t.strictEqual( value, valueArray[ ind ], 'returns expected value' ); - return ( acc && value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new BooleanArray( [ true, false, false, true ] ); - len = arr.length; - accArray = [ 0, 1, 1, 1 ]; - valueArray = [ true, false, false, true ]; - expected = 2; - actual = arr.reduceRight( reducer, 0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - var ind = (len-index-1); - t.strictEqual( acc, accArray[ ind ], 'returns expected value' ); - t.strictEqual( value, valueArray[ ind ], 'returns expected value' ); - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, true ] ); - expected = false; - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return ( acc && value ); - } -}); diff --git a/bool/test/test.reverse.js b/bool/test/test.reverse.js deleted file mode 100644 index 799a95a23..000000000 --- a/bool/test/test.reverse.js +++ /dev/null @@ -1,114 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Uint8Array = require( './../../uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reverse` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'reverse' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reverse.call( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.reverse(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method reverses elements of a boolean array in-place', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - expected = new Uint8Array( [ 0, 1, 1, 0, 0, 1 ] ); - out = arr.reverse(); - - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.set.js b/bool/test/test.set.js deleted file mode 100644 index 5b9f1df5c..000000000 --- a/bool/test/test.set.js +++ /dev/null @@ -1,387 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ArrayBuffer = require( './../../buffer' ); -var Uint8Array = require( './../../uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( true, value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (non-array)', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - arr.length, - arr.length + 1, - arr.length + 2, - arr.length + 3 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( true, value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (array-like object)', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new BooleanArray( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( true ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method sets an array element (non-array)', function test( t ) { - var arr; - var v; - var i; - - arr = new BooleanArray( 10 ); - - v = arr.get( 0 ); - t.strictEqual( v, false, 'returns expected value' ); - - // No index argument: - arr.set( true ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - arr.set( false ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, false, 'returns expected value' ); - - arr.set( true, i ); - v = arr.get( i ); - t.strictEqual( v, true, 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method sets an array element (array-like object)', function test( t ) { - var arr; - var v; - var i; - - arr = new BooleanArray( 10 ); - - v = arr.get( 0 ); - t.strictEqual( v, false, 'returns expected value' ); - - // No index argument: - arr.set( [ true ] ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - arr.set( [ false ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, false, 'returns expected value' ); - - arr.set( [ true ], i ); - - v = arr.get( i ); - t.strictEqual( v, true, 'returns expected value' ); - } - - // Multiple values, no index argument: - arr.set( [ true, true ] ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Multiple values, index argument: - arr.set( [ true, true ], 2 ); - - v = arr.get( 2 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (typed array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new BooleanArray( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ true, true ]; - src = new Uint8Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ true, true ]; - src = new Uint8Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ true, true ]; - src = new Uint8Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ true, true ]; - src = new Uint8Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (boolean array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new BooleanArray( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ true, true ]; - src = new BooleanArray( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src.set( buf[ i ], i ); - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ true, true ]; - src = new BooleanArray( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src.set( buf[ i ], i ); - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ true, true ]; - src = new BooleanArray( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src.set( buf[ i ], i ); - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( v, true, 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ true, true ]; - src = new BooleanArray( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - for ( i = 0; i < buf.length; i++ ) { - src.set( buf[ i ], i ); - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - t.end(); -}); diff --git a/bool/test/test.slice.js b/bool/test/test.slice.js deleted file mode 100644 index e72095ce5..000000000 --- a/bool/test/test.slice.js +++ /dev/null @@ -1,271 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Uint8Array = require( './../../uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'slice' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice( 0, value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 1, 0, 1, 0, 1 ] ); - actual = arr.slice(); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 1, 0, 1 ] ); - actual = arr.slice( 1 ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 1 ] ); - actual = arr.slice( 1, 3 ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 1, 0, 1 ] ); - actual = arr.slice( 1, 30 ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - - expected = new Uint8Array( [ 1, 0 ] ); - actual = arr.slice( -3, -1 ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - - expected = new Uint8Array( [ 1, 0, 1 ] ); - actual = arr.slice( -30, -2 ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [] ); - actual = arr.slice( 2, 0 ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false ] ); - expected = new Uint8Array( [] ); - actual = arr.slice( 5 ); - - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Uint8Array( [] ); - - actual = arr.slice( 2, -8 ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.some.js b/bool/test/test.some.js deleted file mode 100644 index 3d405035d..000000000 --- a/bool/test/test.some.js +++ /dev/null @@ -1,195 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'some' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty boolean array', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray(); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ false, true, false, true ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new BooleanArray( [ false, false, false, false ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === true; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ false, true, false, true ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === true; - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new BooleanArray( [ false, true, true, false ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v === true; - } -}); diff --git a/bool/test/test.sort.js b/bool/test/test.sort.js deleted file mode 100644 index 0bb955f69..000000000 --- a/bool/test/test.sort.js +++ /dev/null @@ -1,168 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Uint8Array = require( './../../uint8' ); -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'sort' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a boolean array in-place', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 0, 1, 1, 1 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.subarray.js b/bool/test/test.subarray.js deleted file mode 100644 index cefc930b3..000000000 --- a/bool/test/test.subarray.js +++ /dev/null @@ -1,272 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Uint8Array = require( './../../uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'subarray' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray( 0, value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 1, 0, 1, 0, 1 ] ); - actual = arr.subarray(); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 1, 0, 1 ] ); - actual = arr.subarray( 1 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [ 0, 1 ] ); - actual = arr.subarray( 1, 3 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - - expected = new Uint8Array( [ 1, 0 ] ); - actual = arr.subarray( -3, -1 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - - expected = new Uint8Array( [ 1, 0, 1 ] ); - actual = arr.subarray( -30, -2 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [] ); - actual = arr.subarray( 2, 0 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false ] ); - expected = new Uint8Array( [] ); - actual = arr.subarray( 5 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - - arr = new BooleanArray( [ true, false, true, false, true ] ); - expected = new Uint8Array( [] ); - - actual = arr.subarray( 2, -8 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.to_locale_string.js b/bool/test/test.to_locale_string.js deleted file mode 100644 index 99b398dfd..000000000 --- a/bool/test/test.to_locale_string.js +++ /dev/null @@ -1,187 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'toLocaleString' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (options)', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( value, {} ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an object', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - 'beep', - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( 'en-GB', value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new BooleanArray(); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a boolean array', function test( t ) { - var expected; - var str; - var arr; - - arr = new BooleanArray( [ true, false, true ] ); - expected = 'true,false,true'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.to_reversed.js b/bool/test/test.to_reversed.js deleted file mode 100644 index 331485456..000000000 --- a/bool/test/test.to_reversed.js +++ /dev/null @@ -1,113 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Uint8Array = require( './../../uint8' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toReversed` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'toReversed' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toReversed.call( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.toReversed(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in reverse order', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - expected = new Uint8Array( [ 0, 1, 1, 0, 0, 1 ] ); - out = arr.toReversed(); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.to_sorted.js b/bool/test/test.to_sorted.js deleted file mode 100644 index fbcd84420..000000000 --- a/bool/test/test.to_sorted.js +++ /dev/null @@ -1,167 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Uint8Array = require( './../../uint8' ); -var BooleanArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {boolean} a - first boolean value for comparison -* @param {boolean} b - second boolean value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - if ( a === true ) { - if ( b === true ) { - return 0; - } - return 1; - } - if ( b === false ) { - return 0; - } - return -1; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'toSorted' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty boolean array', function test( t ) { - var arr; - var out; - - arr = new BooleanArray(); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - expected = new Uint8Array( [ 0, 0, 0, 1, 1, 1 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, true, true, false ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.to_string.js b/bool/test/test.to_string.js deleted file mode 100644 index cdfc074e4..000000000 --- a/bool/test/test.to_string.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new BooleanArray(); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a boolean array', function test( t ) { - var expected; - var str; - var arr; - - arr = new BooleanArray( [ true, false, false, true ] ); - expected = 'true,false,false,true'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/bool/test/test.values.js b/bool/test/test.values.js deleted file mode 100644 index 39e73e034..000000000 --- a/bool/test/test.values.js +++ /dev/null @@ -1,263 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'values' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new BooleanArray( [ true, false ] ); - expected = [ - { - 'value': true, - 'done': false - }, - { - 'value': false, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( isBoolean( r.value ), true, 'returns expected value' ); - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new BooleanArray( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new BooleanArray( [ true, false, true ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, true, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, false, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new BooleanArray( [ true, false, true ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( v.value, true, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, false, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1, 0, 0, 1 ]; - arr = new BooleanArray( buf ); - - it1 = arr.values(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns an object' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var BooleanArray; - var arr; - var buf; - var it; - - BooleanArray = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - buf = [ true, false, false, true ]; - arr = new BooleanArray( buf ); - - it = arr.values(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/bool/test/test.with.js b/bool/test/test.with.js deleted file mode 100644 index 29a3a16d7..000000000 --- a/bool/test/test.with.js +++ /dev/null @@ -1,200 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Uint8Array = require( './../../uint8' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var BooleanArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof BooleanArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( hasOwnProp( BooleanArray.prototype, 'with' ), true, 'has property' ); - t.strictEqual( isFunction( BooleanArray.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a boolean array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with.call( value, 0, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 5 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, true ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, false ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a boolean', function test( t ) { - var values; - var arr; - var i; - - arr = new BooleanArray( 10 ); - - values = [ - '5', - 3.14, - NaN, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( 0, value ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new BooleanArray( 10 ); - out = arr.with( 5, true ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new boolean array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, false, false ] ); - expected = new Uint8Array( [ 1, 0, 0, 1 ] ); - out = arr.with( 3, true ); - - t.strictEqual( out instanceof BooleanArray, true, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, false ] ); - expected = new Uint8Array( [ 1, 0, 1 ] ); - - out = arr.with( -1, true ); - - t.strictEqual( out instanceof BooleanArray, true, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8a6ccca98..000000000 --- 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/array" -%% click B href "https://github.com/stdlib-js/array/tree/main" -%% click C href "https://github.com/stdlib-js/array/tree/production" -%% click D href "https://github.com/stdlib-js/array/tree/esm" -%% click E href "https://github.com/stdlib-js/array/tree/deno" -%% click F href "https://github.com/stdlib-js/array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array -[production-url]: https://github.com/stdlib-js/array/tree/production -[deno-url]: https://github.com/stdlib-js/array/tree/deno -[deno-readme]: https://github.com/stdlib-js/array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array/tree/umd -[umd-readme]: https://github.com/stdlib-js/array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array/tree/esm -[esm-readme]: https://github.com/stdlib-js/array/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 000000000..ae98c1177 --- /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 r,t;r=this,t=function(){"use strict";var r="function"==typeof Object.defineProperty?Object.defineProperty:null,t=Object.defineProperty;function e(r){return"number"==typeof r}function n(r){var t,e="";for(t=0;t0&&(e-=1),n=r.toExponential(e)):n=r.toPrecision(t.precision),t.alternate||(n=c.call(n,v,"$1e"),n=c.call(n,d,"e"),n=c.call(n,m,""));break;default:throw new Error("invalid double notation. Value: "+t.specifier)}return n=c.call(n,h,"e+0$1"),n=c.call(n,p,"e-0$1"),t.alternate&&(n=c.call(n,g,"$1."),n=c.call(n,y,"$1.e")),r>=0&&t.sign&&(n=t.sign+n),n=t.specifier===s.call(t.specifier)?s.call(n):l.call(n)}function b(r){var t,e="";for(t=0;t127)throw new Error("invalid character code. Value: "+o.arg);o.arg=T(f)?String(o.arg):E(f)}break;case"e":case"E":case"f":case"F":case"g":case"G":if(t||(o.precision=6),c=parseFloat(o.arg),!isFinite(c)){if(!e(o.arg))throw new Error("invalid floating-point number. Value: "+l);c=o.arg,o.padZeros=!1}o.arg=w(c,o);break;default:throw new Error("invalid specifier: "+o.specifier)}o.maxWidth>=0&&o.arg.length>o.maxWidth&&(o.arg=o.arg.substring(0,o.maxWidth)),o.padZeros?o.arg=i(o.arg,o.width||o.precision,o.padRight):o.width&&(o.arg=(g=o.arg,y=o.width,m=o.padRight,d=void 0,(d=y-g.length)<0?g:g=m?g+b(d):b(d)+g)),l+=o.arg||"",s+=1}return l}var A=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function S(r){var t={mapping:r[1]?parseInt(r[1],10):void 0,flags:r[2],width:r[3],precision:r[5],specifier:r[6]};return"."===r[4]&&void 0===r[5]&&(t.precision="1"),t}function F(r){var t,e,n,i;for(e=[],i=0,n=A.exec(r);n;)(t=r.slice(i,A.lastIndex-n[0].length)).length&&e.push(t),"%"===n[6]?e.push("%"):e.push(S(n)),i=A.lastIndex,n=A.exec(r);return(t=r.slice(i)).length&&e.push(t),e}function j(r){var t,e;if("string"!=typeof r)throw new TypeError(j("invalid argument. First argument must be a string. Value: `%s`.",r));for(t=[F(r)],e=1;ewt&&Et(r)}function Tt(r){return pt(r)&&_t(r)}function xt(r){return dt(r)&&_t(r.valueOf())}function Vt(r){return Tt(r)||xt(r)}function At(r){return Tt(r)&&r>=0}function St(r){return xt(r)&&r.valueOf()>=0}function Ft(r){return At(r)||St(r)}C(Vt,"isPrimitive",Tt),C(Vt,"isObject",xt),C(Ft,"isPrimitive",At),C(Ft,"isObject",St);var jt=4294967295;function kt(r){return"object"==typeof r&&null!==r&&"number"==typeof r.length&&Et(r.length)&&r.length>=0&&r.length<=jt}var Lt=9007199254740991;function It(r){return"object"==typeof r&&null!==r&&"number"==typeof r.length&&Et(r.length)&&r.length>=0&&r.length<=Lt}var Ot="function"==typeof ArrayBuffer;function Rt(r){return Ot&&r instanceof ArrayBuffer||"[object ArrayBuffer]"===nr(r)}function Bt(r){return"object"==typeof r&&null!==r&&!ir(r)}function Pt(r){return"string"==typeof r}var Mt=String.prototype.valueOf,Nt=X();function Ct(r){return"object"==typeof r&&(r instanceof String||(Nt?function(r){try{return Mt.call(r),!0}catch(r){return!1}}(r):"[object String]"===nr(r)))}function Ut(r){return Pt(r)||Ct(r)}C(Ut,"isPrimitive",Pt),C(Ut,"isObject",Ct);var Dt=or(Ut.isPrimitive),Yt=or(Ut.isObject),Wt=or(Ut);C(Wt,"primitives",Dt),C(Wt,"objects",Yt);var zt=/./;function qt(r){return"boolean"==typeof r}var Gt=Boolean,$t=Boolean.prototype.toString,Ht=X();function Jt(r){return"object"==typeof r&&(r instanceof Gt||(Ht?function(r){try{return $t.call(r),!0}catch(r){return!1}}(r):"[object Boolean]"===nr(r)))}function Qt(r){return qt(r)||Jt(r)}C(Qt,"isPrimitive",qt),C(Qt,"isObject",Jt);var Xt="object"==typeof self?self:null,Zt="object"==typeof window?window:null,Kt="object"==typeof globalThis?globalThis:null,re=function(r){if(arguments.length){if(!qt(r))throw new TypeError(j("invalid argument. Must provide a boolean. Value: `%s`.",r));if(r)return new Function("return this;")()}if(Kt)return Kt;if(Xt)return Xt;if(Zt)return Zt;throw new Error("unexpected error. Unable to resolve global object.")}(),te=re.document&&re.document.childNodes,ee=Int8Array,ne="function"==typeof zt||"object"==typeof ee||"function"==typeof te?function(r){return sr(r).toLowerCase()}:function(r){var t;return null===r?"null":"object"==(t=typeof r)?sr(r).toLowerCase():t};function ie(r){return"function"===ne(r)}function oe(r,t){if(!(this instanceof oe))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!pt(r))throw new TypeError(j("invalid argument. Real component must be a number. Value: `%s`.",r));if(!pt(t))throw new TypeError(j("invalid argument. Imaginary component must be a number. Value: `%s`.",t));return M(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),M(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:t}),this}C(oe,"BYTES_PER_ELEMENT",8),C(oe.prototype,"BYTES_PER_ELEMENT",8),C(oe.prototype,"byteLength",16),C(oe.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),C(oe.prototype,"toJSON",(function(){var r={type:"Complex128"};return r.re=this.re,r.im=this.im,r}));var ae="function"==typeof Math.fround?Math.fround:null,ue="function"==typeof Float32Array?Float32Array:void 0,fe=br()?ue:function(){throw new Error("not implemented")},le=new fe(1),se="function"==typeof ae?ae:function(r){return le[0]=r,le[0]};function ce(r,t){if(!(this instanceof ce))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!pt(r))throw new TypeError(j("invalid argument. Real component must be a number. Value: `%s`.",r));if(!pt(t))throw new TypeError(j("invalid argument. Imaginary component must be a number. Value: `%s`.",t));return M(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:se(r)}),M(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:se(t)}),this}function he(r){return r instanceof oe||r instanceof ce||"object"==typeof r&&null!==r&&"number"==typeof r.re&&"number"==typeof r.im}function pe(r){return Et(r/2)}C(ce,"BYTES_PER_ELEMENT",4),C(ce.prototype,"BYTES_PER_ELEMENT",4),C(ce.prototype,"byteLength",8),C(ce.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),C(ce.prototype,"toJSON",(function(){var r={type:"Complex64"};return r.re=this.re,r.im=this.im,r}));var ge=8;function ye(r){return"object"==typeof r&&null!==r&&"Complex64Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===ge}var me=16;function de(r){return"object"==typeof r&&null!==r&&"Complex128Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===me}function ve(){return"function"==typeof tr&&"symbol"==typeof tr("foo")&&rr(tr,"iterator")&&"symbol"==typeof tr.iterator}var we=ve()?Symbol.iterator:null;function be(r,t,e){M(r,t,{configurable:!1,enumerable:!1,get:e})}function Ee(r){return r.re}function _e(r){return r.im}function Te(r,t){return new fe(r.buffer,r.byteOffset+r.BYTES_PER_ELEMENT*t,2*(r.length-t))}var xe="function"==typeof Float64Array?Float64Array:void 0,Ve=gr()?xe:function(){throw new Error("not implemented")};function Ae(r,t){return new Ve(r.buffer,r.byteOffset+r.BYTES_PER_ELEMENT*t,2*(r.length-t))}function Se(r){var t,e,n;for(t=[];!(e=r.next()).done;)if(kt(n=e.value)&&n.length>=2)t.push(n[0],n[1]);else{if(!he(n))return new TypeError(j("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));t.push(Ee(n),_e(n))}return t}var Fe=2*_r.BYTES_PER_ELEMENT,je=ve();function ke(r){return r instanceof Oe||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function Le(r){return r===Oe||"Complex128Array"===r.name}function Ie(r,t){return new ce(r[t*=2],r[t+1])}function Oe(){var r,t,e,n;if(t=arguments.length,!(this instanceof Oe))return 0===t?new Oe:1===t?new Oe(arguments[0]):2===t?new Oe(arguments[0],arguments[1]):new Oe(arguments[0],arguments[1],arguments[2]);if(0===t)e=new _r(0);else if(1===t)if(At(arguments[0]))e=new _r(2*arguments[0]);else if(It(arguments[0]))if((n=(e=arguments[0]).length)&&ir(e)&&he(e[0])){if(e=function(r,t){var e,n,i,o;for(e=t.length,o=0,i=0;ie.byteLength-r)throw new RangeError(j("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*Fe));e=new _r(e,r,2*n)}}return C(this,"_buffer",e),C(this,"_length",e.length/2),this}function Re(r){return r.re}function Be(r){return r.im}function Pe(r){var t,e,n;for(t=[];!(e=r.next()).done;)if(kt(n=e.value)&&n.length>=2)t.push(n[0],n[1]);else{if(!he(n))return new TypeError(j("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));t.push(Re(n),Be(n))}return t}C(Oe,"BYTES_PER_ELEMENT",Fe),C(Oe,"name","Complex64Array"),C(Oe,"from",(function(r){var t,e,n,i,o,a,u,f,l,s,c,h;if(!ie(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!Le(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((e=arguments.length)>1){if(!ie(n=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(ke(r)){if(f=r.length,n){for(o=(i=new this(f))._buffer,h=0,c=0;c=2))throw new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(It(r)){if(n){for(f=r.length,u=r.get&&r.set?$("default"):W("default"),c=0;c=2))throw new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Bt(r)&&je&&ie(r[we])){if(!ie((o=r[we]()).next))throw new TypeError(j("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(a=n?function(r,t,e){var n,i,o,a;for(n=[],a=-1;!(i=r.next()).done;)if(a+=1,kt(o=t.call(e,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!he(o))return new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(Ee(o),_e(o))}return n}(o,n,t):Se(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,c=0;c=this._length))return Ie(this._buffer,r)})),be(Oe.prototype,"buffer",(function(){return this._buffer.buffer})),be(Oe.prototype,"byteLength",(function(){return this._buffer.byteLength})),be(Oe.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),C(Oe.prototype,"BYTES_PER_ELEMENT",Oe.BYTES_PER_ELEMENT),C(Oe.prototype,"copyWithin",(function(r,t){if(!ke(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*t):this._buffer.copyWithin(2*r,2*t,2*arguments[2]),this})),C(Oe.prototype,"entries",(function(){var r,t,e,n,i,o;if(!ke(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return r=this,n=this._buffer,e=this._length,o=-1,C(t={},"next",(function(){return o+=1,i||o>=e?{done:!0}:{value:[o,Ie(n,o)],done:!1}})),C(t,"return",(function(r){return i=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(t,we,(function(){return r.entries()})),t})),C(Oe.prototype,"every",(function(r,t){var e,n;if(!ke(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Et(e))throw new TypeError(j("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(a=Ee(r),u=_e(r),f=t;f=0;n--)if(i=Ie(e,n),r.call(t,i,n,this))return i})),C(Oe.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!ke(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=this._length-1;n>=0;n--)if(i=Ie(e,n),r.call(t,i,n,this))return n;return-1})),C(Oe.prototype,"forEach",(function(r,t){var e,n,i;if(!ke(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return Ie(this._buffer,r)})),C(Oe.prototype,"includes",(function(r,t){var e,n,i,o,a;if(!ke(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!he(r))throw new TypeError(j("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Ee(r),o=_e(r),e=this._buffer,a=t;a1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Ee(r),o=_e(r),e=this._buffer,a=t;a=e?{done:!0}:{value:i,done:!1}})),C(t,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(t,we,(function(){return r.keys()})),t})),C(Oe.prototype,"lastIndexOf",(function(r,t){var e,n,i,o,a;if(!ke(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!he(r))throw new TypeError(j("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=Ee(r),o=_e(r),e=this._buffer,a=t;a>=0;a--)if(i===e[n=2*a]&&o===e[n+1])return a;return-1})),be(Oe.prototype,"length",(function(){return this._length})),C(Oe.prototype,"map",(function(r,t){var e,n,i,o,a;if(!ke(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,e=(i=new this.constructor(this._length))._buffer,o=0;o1)n=t,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=Ie(e,0),o=1}for(;o1)n=t,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=Ie(e,i-1),o=i-2}for(;o>=0;o--)n=r(n,Ie(e,o),o,this);return n})),C(Oe.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!ke(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(e=this._length,r=this._buffer,n=bt(e/2),i=0;i1){if(!At(e=arguments[1]))throw new TypeError(j("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(he(r)){if(e>=this._length)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));return n[e*=2]=Ee(r),void(n[e+1]=_e(r))}if(ke(r)){if(e+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r._buffer,l=n.byteOffset+e*Fe,t.buffer===n.buffer&&t.byteOffsetl){for(i=new _r(t.length),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r,l=n.byteOffset+e*Fe,t.buffer===n.buffer&&t.byteOffsetl){for(i=new _r(a),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(e*=2,f=0;fu&&(t=u)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*Fe):(i=t-r,e=n.byteOffset+r*Fe),new this.constructor(n.buffer,e,i<0?0:i)})),C(Oe.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!ke(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(0===arguments.length)n=[];else{if(!Pt(r)&&!Dt(r))throw new TypeError(j("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Bt(t))throw new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e?{done:!0}:{value:Ie(i,o),done:!1}})),C(r,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(r,we,(function(){return t.values()})),r})),C(Oe.prototype,"with",(function(r,t){var e,n,i;if(!ke(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Et(r))throw new TypeError(j("invalid argument. First argument must be an integer. Value: `%s`.",r));if(i=this._length,r<0&&(r+=i),r<0||r>=i)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!he(t))throw new TypeError(j("invalid argument. Second argument must be a complex number. Value: `%s`.",t));return(e=(n=new this.constructor(this._buffer))._buffer)[2*r]=Ee(t),e[2*r+1]=_e(t),n}));var Me=2*mr.BYTES_PER_ELEMENT,Ne=ve();function Ce(r){return r instanceof Ye||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function Ue(r){return r===Ye||"Complex64Array"===r.name}function De(r,t){return new oe(r[t*=2],r[t+1])}function Ye(){var r,t,e,n;if(t=arguments.length,!(this instanceof Ye))return 0===t?new Ye:1===t?new Ye(arguments[0]):2===t?new Ye(arguments[0],arguments[1]):new Ye(arguments[0],arguments[1],arguments[2]);if(0===t)e=new mr(0);else if(1===t)if(At(arguments[0]))e=new mr(2*arguments[0]);else if(It(arguments[0]))if((n=(e=arguments[0]).length)&&ir(e)&&he(e[0])){if(e=function(r,t){var e,n,i,o;for(e=t.length,o=0,i=0;ie.byteLength-r)throw new RangeError(j("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*Me));e=new mr(e,r,2*n)}}return C(this,"_buffer",e),C(this,"_length",e.length/2),this}function We(r){var t,e;for(t=[];!(e=r.next()).done;)t.push(Gt(e.value));return t}C(Ye,"BYTES_PER_ELEMENT",Me),C(Ye,"name","Complex128Array"),C(Ye,"from",(function(r){var t,e,n,i,o,a,u,f,l,s,c,h;if(!ie(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!Ue(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((e=arguments.length)>1){if(!ie(n=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(Ce(r)){if(f=r.length,n){for(o=(i=new this(f))._buffer,h=0,c=0;c=2))throw new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(It(r)){if(n){for(f=r.length,u=r.get&&r.set?$("default"):W("default"),c=0;c=2))throw new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Bt(r)&&Ne&&ie(r[we])){if(!ie((o=r[we]()).next))throw new TypeError(j("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(a=n?function(r,t,e){var n,i,o,a;for(n=[],a=-1;!(i=r.next()).done;)if(a+=1,kt(o=t.call(e,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!he(o))return new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(Re(o),Be(o))}return n}(o,n,t):Pe(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,c=0;c=this._length))return De(this._buffer,r)})),be(Ye.prototype,"buffer",(function(){return this._buffer.buffer})),be(Ye.prototype,"byteLength",(function(){return this._buffer.byteLength})),be(Ye.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),C(Ye.prototype,"BYTES_PER_ELEMENT",Ye.BYTES_PER_ELEMENT),C(Ye.prototype,"copyWithin",(function(r,t){if(!Ce(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*t):this._buffer.copyWithin(2*r,2*t,2*arguments[2]),this})),C(Ye.prototype,"entries",(function(){var r,t,e,n,i,o,a;if(!Ce(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return t=this,r=this._buffer,n=this._length,o=-1,a=-2,C(e={},"next",(function(){var t;return o+=1,i||o>=n?{done:!0}:(t=new oe(r[a+=2],r[a+1]),{value:[o,t],done:!1})})),C(e,"return",(function(r){return i=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(e,we,(function(){return t.entries()})),e})),C(Ye.prototype,"every",(function(r,t){var e,n;if(!Ce(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Et(e))throw new TypeError(j("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(a=Re(r),u=Be(r),f=t;f=0;n--)if(i=De(e,n),r.call(t,i,n,this))return i})),C(Ye.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!Ce(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=this._length-1;n>=0;n--)if(i=De(e,n),r.call(t,i,n,this))return n;return-1})),C(Ye.prototype,"forEach",(function(r,t){var e,n,i;if(!Ce(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return De(this._buffer,r)})),be(Ye.prototype,"length",(function(){return this._length})),C(Ye.prototype,"includes",(function(r,t){var e,n,i,o,a;if(!Ce(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!he(r))throw new TypeError(j("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Re(r),o=Be(r),e=this._buffer,a=t;a1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Re(r),o=Be(r),e=this._buffer,a=t;a=e?{done:!0}:{value:i,done:!1}})),C(t,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(t,we,(function(){return r.keys()})),t})),C(Ye.prototype,"lastIndexOf",(function(r,t){var e,n,i,o,a;if(!Ce(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!he(r))throw new TypeError(j("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=Re(r),o=Be(r),e=this._buffer,a=t;a>=0;a--)if(i===e[n=2*a]&&o===e[n+1])return a;return-1})),C(Ye.prototype,"map",(function(r,t){var e,n,i,o,a;if(!Ce(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,e=(i=new this.constructor(this._length))._buffer,o=0;o1)n=t,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=De(e,0),o=1}for(;o1)n=t,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=De(e,i-1),o=i-2}for(;o>=0;o--)n=r(n,De(e,o),o,this);return n})),C(Ye.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!Ce(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(e=this._length,r=this._buffer,n=bt(e/2),i=0;i1){if(!At(e=arguments[1]))throw new TypeError(j("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(he(r)){if(e>=this._length)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));return n[e*=2]=Re(r),void(n[e+1]=Be(r))}if(Ce(r)){if(e+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r._buffer,l=n.byteOffset+e*Me,t.buffer===n.buffer&&t.byteOffsetl){for(i=new mr(t.length),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r,l=n.byteOffset+e*Me,t.buffer===n.buffer&&t.byteOffsetl){for(i=new mr(a),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(e*=2,f=0;fu&&(t=u)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*Me):(i=t-r,e=n.byteOffset+r*Me),new this.constructor(n.buffer,e,i<0?0:i)})),C(Ye.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!Ce(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(0===arguments.length)n=[];else{if(!Ut(r)&&!Dt(r))throw new TypeError(j("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Bt(t))throw new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e?{done:!0}:{value:De(i,o),done:!1}})),C(r,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(r,we,(function(){return t.values()})),r})),C(Ye.prototype,"with",(function(r,t){var e,n,i;if(!Ce(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Et(r))throw new TypeError(j("invalid argument. First argument must be an integer. Value: `%s`.",r));if(i=this._length,r<0&&(r+=i),r<0||r>=i)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!he(t))throw new TypeError(j("invalid argument. Second argument must be a complex number. Value: `%s`.",t));return(e=(n=new this.constructor(this._buffer))._buffer)[2*r]=Re(t),e[2*r+1]=Be(t),n}));var ze=rt.BYTES_PER_ELEMENT,qe=ve();function Ge(r){return"object"==typeof r&&null!==r&&"BooleanArray"===r.constructor.name&&r.BYTES_PER_ELEMENT===ze}function $e(r){return r===He}function He(){var r,t,e,n,i;if(t=arguments.length,!(this instanceof He))return 0===t?new He:1===t?new He(arguments[0]):2===t?new He(arguments[0],arguments[1]):new He(arguments[0],arguments[1],arguments[2]);if(0===t)e=new rt(0);else if(1===t)if(At(i=arguments[0]))e=new rt(i);else if(It(i))e=function(r,t){var e,n;for(e=t.length,n=0;ne.byteLength-r)throw new RangeError(j("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*ze));e=new rt(e,r,n)}}return C(this,"_buffer",e),C(this,"_length",e.length),this}C(He,"BYTES_PER_ELEMENT",ze),C(He,"name","BooleanArray"),C(He,"from",(function(r){var t,e,n,i,o,a,u,f,l;if(!ie(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!$e(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if((e=arguments.length)>1){if(!ie(n=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(It(r)){if(n){for(f=r.length,u=r.get&&r.set?$("default"):W("default"),o=(i=new this(f))._buffer,l=0;l=e))return Gt(t[r])})),be(He.prototype,"buffer",(function(){return this._buffer.buffer})),be(He.prototype,"byteLength",(function(){return this._buffer.byteLength})),be(He.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),C(He.prototype,"BYTES_PER_ELEMENT",He.BYTES_PER_ELEMENT),C(He.prototype,"copyWithin",(function(r,t){if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return 2===arguments.length?this._buffer.copyWithin(r,t):this._buffer.copyWithin(r,t,arguments[2]),this})),C(He.prototype,"entries",(function(){var r,t,e,n,i,o;if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return r=this,n=this._buffer,e=this._length,o=-1,C(t={},"next",(function(){return o+=1,i||o>=e?{done:!0}:{value:[o,Gt(n[o])],done:!1}})),C(t,"return",(function(r){return i=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(t,we,(function(){return r.entries()})),t})),C(He.prototype,"every",(function(r,t){var e,n;if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Tt(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Tt(e))throw new TypeError(j("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(o=r?1:0,a=t;a=0;i--)if(n=Gt(e[i]),r.call(t,n,i,this))return n})),C(He.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,i=this._length-1;i>=0;i--)if(n=Gt(e[i]),r.call(t,n,i,this))return i;return-1})),C(He.prototype,"forEach",(function(r,t){var e,n;if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return Gt(this._buffer[r])})),C(He.prototype,"includes",(function(r,t){var e,n;if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!qt(r))throw new TypeError(j("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(e=this._buffer,n=t;n1){if(!Tt(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(e=this._buffer,n=t;n0){if(!Pt(r))throw new TypeError(j("invalid argument. First argument must be a string. Value: `%s`.",r))}else r=",";for(t=this._buffer,e=[],n=0;n=e?{done:!0}:{value:i,done:!1}})),C(t,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(t,we,(function(){return r.keys()})),t})),C(He.prototype,"lastIndexOf",(function(r,t){var e,n;if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!qt(r))throw new TypeError(j("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(e=this._buffer,n=t;n>=0;n--)if(r===Gt(e[n]))return n;return-1})),be(He.prototype,"length",(function(){return this._length})),C(He.prototype,"map",(function(r,t){var e,n,i,o;if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ie(r))throw new TypeError("invalid argument. First argument must be a function. Value: `%s`.",r);for(i=this._buffer,e=(n=new this.constructor(this._length))._buffer,o=0;o1)i=t,o=0;else{if(0===n)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");i=Gt(e[0]),o=1}for(;o1)i=t,o=n-1;else{if(0===n)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");i=Gt(e[n-1]),o=n-2}for(;o>=0;o--)i=r(i,Gt(e[o]),o,this);return i})),C(He.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");for(r=this._buffer,e=this._length,n=bt(e/2),i=0;i1){if(!At(e=arguments[1]))throw new TypeError(j("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(It(r)){if(e+(o=r.length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=Ge(r)?r._buffer:r,u=n.byteOffset+e*ze,t.buffer===n.buffer&&t.byteOffsetu){for(i=new rt(t.length),a=0;a=this._length)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));n[e]=r?1:0}})),C(He.prototype,"slice",(function(r,t){var e,n,i,o,a,u;if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(o=this._buffer,a=this._length,0===arguments.length)r=0,t=a;else{if(!Tt(r))throw new TypeError(j("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=a)<0&&(r=0),1===arguments.length)t=a;else{if(!Tt(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0?(t+=a)<0&&(t=0):t>a&&(t=a)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*ze):(i=t-r,e=n.byteOffset+r*ze),new this.constructor(n.buffer,e,i<0?0:i)})),C(He.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(0===arguments.length)n=[];else{if(!Pt(r)&&!Dt(r))throw new TypeError(j("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Bt(t))throw new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e?{done:!0}:{value:Gt(i[o]),done:!1}})),C(r,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(r,we,(function(){return t.values()})),r})),C(He.prototype,"with",(function(r,t){var e,n;if(!Ge(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!Tt(r))throw new TypeError(j("invalid argument. First argument must be an integer. Value: `%s`.",r));if(n=this._length,r<0&&(r+=n),r<0||r>=n)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!qt(t))throw new TypeError(j("invalid argument. Second argument must be a boolean. Value: `%s`.",t));return(e=new this.constructor(this._buffer))._buffer[r]=t?1:0,e}));var Je=[mr,_r,Br,Fr,Hr,Dr,ht,rt,ot,Oe,Ye,He],Qe=["float64","float32","int32","uint32","int16","uint16","int8","uint8","uint8c","complex64","complex128","bool"],Xe=Qe.length;function Ze(r){var t;if(ir(r))return"generic";if(ur(r))return null;for(t=0;t>>0}function _n(r,t,e){return n=se(r),i=se(t),(pn(n)||pn(i)?NaN:(o=wn(n),a=wn(i),bn((o=En(o))-(a=En(a)))))<=e;var n,i,o,a}function Tn(r){return r!=r}var xn,Vn=2147483648,An="function"==typeof Uint16Array?Uint16Array:void 0,Sn=Cr()?An:function(){throw new Error("not implemented")},Fn={uint16:Sn,uint8:an};(xn=new Fn.uint16(1))[0]=4660;var jn,kn,Ln=52===new Fn.uint8(xn.buffer)[0];!0===Ln?(jn=1,kn=0):(jn=0,kn=1);var In={HIGH:jn,LOW:kn},On=new Ve(1),Rn=new mn(On.buffer),Bn=In.HIGH,Pn=In.LOW;function Mn(r,t,e,n){return On[0]=r,t[n]=Rn[Bn],t[n+e]=Rn[Pn],t}function Nn(r){return Mn(r,[0,0],1,0)}C(Nn,"assign",Mn);var Cn=new mn(2),Un=new mn(2),Dn=new mn(2),Yn=4294967296;function Wn(r){return r[0]&Vn?r=function(r){return r[0]=~r[0],r[1]=~r[1],r[1]+=1,0===r[1]&&(r[0]+=1),r}(r):r[0]|=Vn,r}function zn(r,t,e){var n,i,o,a;return n=r[0],o=r[1],i=t[0],o>=(a=t[1])?(e[0]=n-i,e[1]=o-a):(e[0]=n-i-1,e[1]=o+Yn-a),e}function qn(r,t,e){return i=t,(Tn(n=r)||Tn(i)?NaN:(a=Mn(n,Cn,1,0),u=Mn(i,Un,1,0),a=Wn(a),u=Wn(u),s=u,0==(o=(l=a)[0]>s[0]?1:l[0]s[1]?1:l[1]0&&t.push("generic"),t)}var ui=hn(ai("boolean")),fi=["little-endian","big-endian"];function li(){return fi.slice()}var si=hn(li()),ci=hn(ai("complex_floating_point")),hi=8,pi=16;function gi(r){return"object"==typeof r&&null!==r&&("Complex128Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===pi||"Complex64Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===hi)}var yi=hn(ai()),mi=hn(ai("floating_point")),di=hn(ai("integer"));function vi(r){return Object.keys(Object(r))}var wi,bi=void 0!==Object.keys;function Ei(r){return"[object Arguments]"===nr(r)}wi=function(){return Ei(arguments)}();var _i=wi;function Ti(r){return pt(r)&&Tn(r)}function xi(r){return dt(r)&&Tn(r.valueOf())}function Vi(r){return Ti(r)||xi(r)}C(Vi,"isPrimitive",Ti),C(Vi,"isObject",xi);var Ai=Object.prototype.propertyIsEnumerable,Si=!Ai.call("beep","0");function Fi(r,t){var e;return null!=r&&(!(e=Ai.call(r,t))&&Si&&Ut(r)?!Ti(t=+t)&&Tt(t)&&t>=0&&t=0&&r.length<=xr&&rr(r,"callee")&&!Fi(r,"callee")},ki=Array.prototype.slice,Li=Fi((function(){}),"prototype"),Ii=!Fi({toString:null},"toString");function Oi(r,t,e){var n,i;if(!It(r)&&!Pt(r))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(0===(n=r.length))return-1;if(3===arguments.length){if(!Tt(e))throw new TypeError(j("invalid argument. Third argument must be an integer. Value: `%s`.",e));if(e>=0){if(e>=n)return-1;i=e}else(i=n+e)<0&&(i=0)}else i=0;if(Vi(t)){for(;i0&&!rr(r,"0"))for(u=0;u0&&t.push("generic"),t)}function ro(){return{bool:0,int8:1,uint8:2,uint8c:3,int16:4,uint16:5,int32:6,uint32:7,int64:8,uint64:9,float16:10,float32:11,float64:12,complex32:13,complex64:14,complex128:15,binary:16,generic:17,notype:18,userdefined_type:256}}C(Ki,"enum",ro),function(r,t){var e,n,i;for(e=Yi(t),i=0;i1){if(!Hi(t))throw new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t));if(rr(t,"duplicates")&&!qt(l=t.duplicates))throw new TypeError(j("invalid option. `%s` option must be a boolean. Option: `%s`.","duplicates",l))}if(n=(e=Yi(r)).length,a={},l)for(f=0;f0}var co,ho=hn(ai("numeric")),po=hn(ai("real")),go=hn(ai("real_floating_point")),yo={float64:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,bool:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,bool:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,bool:1,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,bool:0,generic:1}};function mo(r){return 0===arguments.length?function(){var r,t,e,n,i,o,a,u,f;for(e={},t=(r=Yi(yo)).length,f=0;f0}var bo,Eo={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:0,bool:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,bool:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,bool:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,bool:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,bool:1,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,bool:0,generic:1}};function _o(r){return 0===arguments.length?function(){var r,t,e,n,i,o,a,u,f;for(e={},t=(r=Yi(Eo)).length,f=0;ft?r:t}function Fo(r,t){return r0})),N(Ao,"isSignedIntegerDataType",xo),N(Ao,"isSortedAscending",(function(r){var t,e,n,i,o,a;if(n=Ze(r),e=D(r)?$(n):W(n),0===(t=r.length))return!1;for(i=e(r,0),a=1;a(o=e(r,a)))return!1;i=o}return!0})),N(Ao,"isUnsignedIntegerDataType",Vo);var Io={};function Oo(r,t,e,n,i,o,a){var u,f,l;if(u=i[o],(f=o+1)!==n)for(l=0;l=0;l--)if(!((s=u-a+l)<0)){if(f=t[s],0!==(i=e[l])&&i0?r-1:r+1)}function No(r){return r===vr||r===wt}N(Io,"filled2dBy",(function(r,t,e,n,i,o){var a,u,f,l,s,c;for(l=r[0],f=r[1],a=[],c=0;c=c&&s<=c+t||s<=c&&c<=s+e?u.push(i.call(o,[c,s])):u.push(n);a.push(u)}return a})),N(Io,"toCompact",(function(r,t,e,n){var i,o,a,u,f,l,s;if(a=r.length,u=r[0].length,n){for(i=Lo([u,t+e+1]),l=0;l>>0,Do[0]}function zo(r){return 0|r}var qo,Go,$o=2147483647,Ho=!0===Ln?1:0,Jo=new Ve(1),Qo=new mn(Jo.buffer);function Xo(r){return Jo[0]=r,Qo[Ho]}!0===Ln?(qo=1,Go=0):(qo=0,Go=1);var Zo={HIGH:qo,LOW:Go},Ko=new Ve(1),ra=new mn(Ko.buffer),ta=Zo.HIGH,ea=Zo.LOW;function na(r,t){return ra[ta]=r,ra[ea]=t,Ko[0]}var ia=[0,0];function oa(r,t){var e,n;return Nn.assign(r,ia,1,0),e=ia[0],e&=$o,n=Xo(t),na(e|=n&=Vn,ia[1])}var aa=1072693247,ua=1e300,fa=1e-300,la=!0===Ln?1:0,sa=new Ve(1),ca=new mn(sa.buffer);function ha(r,t){return sa[0]=r,ca[la]=t>>>0,sa[0]}var pa=1023,ga=20,ya=1048575,ma=1048576,da=1072693248,va=536870912,wa=524288,ba=9007199254740992,Ea=.9617966939259756,_a=.9617967009544373,Ta=-7.028461650952758e-9,xa=[1,1.5],Va=[0,.5849624872207642],Aa=[0,1.350039202129749e-8],Sa=1.4426950408889634,Fa=1.4426950216293335,ja=1.9259629911266175e-8,ka=1023,La=-1023,Ia=-1074,Oa=22250738585072014e-324,Ra=4503599627370496;function Ba(r,t,e,n){return Tn(r)||No(r)?(t[n]=r,t[n+e]=0,t):0!==r&&bn(r)>>20)-pa|0}(r),tka?r<0?wt:vr:(t<=La?(t+=52,n=Ma):n=1,Nn.assign(r,Ua,1,0),e=Ua[0],e&=Na,n*na(e|=t+pa<<20,Ua[1])))}var Ya=.6931471805599453,Wa=1048575,za=1048576,qa=1071644672,Ga=.6931471824645996,$a=-1.904654299957768e-9,Ha=1072693247,Ja=1105199104,Qa=1139802112,Xa=1083179008,Za=1072693248,Ka=1083231232,ru=3230714880,tu=31,eu=1e300,nu=1e-300,iu=8008566259537294e-32,ou=[0,0],au=[0,0];function uu(r,t){var e,n,i,o,a,u,f,l,s,c,h,p,g,y;if(Tn(r)||Tn(t))return NaN;if(Nn.assign(t,ou,1,0),a=ou[0],0===ou[1]){if(0===t)return 1;if(1===t)return r;if(-1===t)return 1/r;if(.5===t)return Co(r);if(-.5===t)return 1/Co(r);if(2===t)return r*r;if(3===t)return r*r*r;if(4===t)return(r*=r)*r;if(No(t))return function(r,t){return-1===r?(r-r)/(r-r):1===r?1:bn(r)<1==(t===vr)?0:vr}(r,t)}if(Nn.assign(r,ou,1,0),o=ou[0],0===ou[1]){if(0===o)return function(r,t){return t===wt?vr:t===vr?0:t>0?Mo(t)?r:0:Mo(t)?oa(vr,r):vr}(r,t);if(1===r)return 1;if(-1===r&&Mo(t))return-1;if(No(r))return r===wt?uu(-0,-t):t<0?0:vr}if(r<0&&!1===Et(t))return(r-r)/(r-r);if(i=bn(r),e=o&$o|0,n=a&$o|0,f=a>>>tu|0,u=(u=o>>>tu|0)&&Mo(t)?-1:1,n>Ja){if(n>Qa)return function(r,t){return(Xo(r)&$o)<=aa?t<0?ua*ua:fa*fa:t>0?ua*ua:fa*fa}(r,t);if(eZa)return 0===f?u*eu*eu:u*nu*nu;h=function(r,t){var e,n,i,o,a,u,f;return o=(i=t-1)*i*(0===(f=i)?.5:.5+f*(.25*f-.3333333333333333)),e=(u=i*ja-o*Sa)-((n=Wo(n=(a=Fa*i)+u,0))-a),r[0]=n,r[1]=e,r}(au,i)}else h=function(r,t,e){var n,i,o,a,u,f,l,s,c,h,p,g,y,m,d,v,w,b,E,_,T;return b=0,e>ga)-pa|0,e=(E=e&ya|0)|da|0,E<=235662?_=0:E<767610?_=1:(_=0,b+=1,e-=ma),a=Wo(i=(v=(t=ha(t,e))-(l=xa[_]))*(w=1/(t+l)),0),n=(e>>1|va)+wa,f=ha(0,n+=_<<18),d=(o=i*i)*o*(0===(T=o)?.5999999999999946:.5999999999999946+T*(.4285714285785502+T*(.33333332981837743+T*(.272728123808534+T*(.23066074577556175+.20697501780033842*T))))),f=Wo(f=3+(o=a*a)+(d+=(u=w*(v-a*f-a*(t-(f-l))))*(a+i)),0),c=Wo(c=(v=a*f)+(w=u*f+(d-(f-3-o))*i),0),h=_a*c,y=(p=Ta*c+(w-(c-v))*Ea+Aa[_])-((g=Wo(g=h+p+(s=Va[_])+(m=b),0))-m-s-h),r[0]=g,r[1]=y,r}(au,i,e);if(p=(c=(t-(l=Wo(t,0)))*h[0]+t*h[1])+(s=l*h[0]),Nn.assign(p,ou,1,0),g=zo(ou[0]),y=zo(ou[1]),g>=Xa){if(0!=(g-Xa|y))return u*eu*eu;if(c+iu>p-s)return u*eu*eu}else if((g&$o)>=Ka){if(0!=(g-ru|y))return u*nu*nu;if(c<=p-s)return u*nu*nu}return p=function(r,t,e){var n,i,o,a,u,f,l,s,c,h;return c=((s=r&$o|0)>>ga)-pa|0,l=0,s>qa&&(i=ha(0,((l=r+(za>>c+1)>>>0)&~(Wa>>(c=((l&$o)>>ga)-pa|0)))>>>0),l=(l&Wa|za)>>ga-c>>>0,r<0&&(l=-l),t-=i),r=zo(r=Xo(f=1-((f=(o=(i=Wo(i=e+t,0))*Ga)+(a=(e-(i-t))*Ya+i*$a))*(n=f-(i=f*f)*(0===(h=i)?.16666666666666602:.16666666666666602+h*(h*(6613756321437934e-20+h*(4.1381367970572385e-8*h-16533902205465252e-22))-.0027777777777015593)))/(n-2)-((u=a-(f-o))+f*u)-f))),(r+=l<>>0)>>ga<=0?Da(f,l):ha(f,r)}(g,s,c),u*p}function fu(r,t){var e,n,i,o,a,u,f,l,s,c;if((u=r.length)<=0||t<=0)return[];for(e=ln(r),a=uu(u,t),o=[],l=0;l=0;s--)c-=f=c%u,c/=u,o[s]=f;for(i=[],s=0;s=0&&a0?0:t-1;else if(n<0){if((n=t+n)<0){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};n=0}}else if(n>=t){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};n=o<0?t-1:t}if(null===i)i=o>0?t:null;else if(i<0){if((i=t+i)<0)if(o>0){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};i=0}else{if(e&&i<-1)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};i=null}}else if(i>t){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};i=t}return new Uu(n,i,o)}C(wu,"assign",(function(r,t,e){var n=nn(r);return n.accessorProtocol?"complex128"===n.dtype?bu(r,Ae(r,0),t,e):"complex64"===n.dtype?bu(r,Te(r,0),t,e):function(r,t,e){var n,i,o,a;for(n=r.data,i=r.accessors[1],a=e,o=0;a>=0&&a=0&&i0&&e>=n||t<0&&e<=n?0:Yu((n-e)/t)}var zu="function";function qu(r){return typeof r.get===zu&&typeof r.set===zu}var Gu={float64:function(r,t){return r[t]},float32:function(r,t){return r[t]},int32:function(r,t){return r[t]},int16:function(r,t){return r[t]},int8:function(r,t){return r[t]},uint32:function(r,t){return r[t]},uint16:function(r,t){return r[t]},uint8:function(r,t){return r[t]},uint8c:function(r,t){return r[t]},generic:function(r,t){return r[t]},default:function(r,t){return r[t]}};function $u(r){var t=Gu[r];return"function"==typeof t?t:Gu.default}var Hu={float64:function(r,t,e){r[t]=e},float32:function(r,t,e){r[t]=e},int32:function(r,t,e){r[t]=e},int16:function(r,t,e){r[t]=e},int8:function(r,t,e){r[t]=e},uint32:function(r,t,e){r[t]=e},uint16:function(r,t,e){r[t]=e},uint8:function(r,t,e){r[t]=e},uint8c:function(r,t,e){r[t]=e},generic:function(r,t,e){r[t]=e},default:function(r,t,e){r[t]=e}};function Ju(r){var t=Hu[r];return"function"==typeof t?t:Hu.default}var Qu={complex128:function(r,t){return r.get(t)},complex64:function(r,t){return r.get(t)},default:function(r,t){return r.get(t)}};function Xu(r){var t=Qu[r];return"function"==typeof t?t:Qu.default}var Zu={complex128:function(r,t,e){r.set(e,t)},complex64:function(r,t,e){r.set(e,t)},default:function(r,t,e){r.set(e,t)}};function Ku(r){var t=Zu[r];return"function"==typeof t?t:Zu.default}var rf={Float32Array:"float32",Float64Array:"float64",Array:"generic",Int16Array:"int16",Int32Array:"int32",Int8Array:"int8",Uint16Array:"uint16",Uint32Array:"uint32",Uint8Array:"uint8",Uint8ClampedArray:"uint8c",Complex64Array:"complex64",Complex128Array:"complex128",BooleanArray:"bool"},tf="function"==typeof Int32Array?Int32Array:void 0,ef=Or()?tf:function(){throw new Error("not implemented")},nf="function"==typeof Int16Array?Int16Array:void 0,of=Gr()?nf:function(){throw new Error("not implemented")},af="function"==typeof Uint8ClampedArray?Uint8ClampedArray:void 0,uf=nt()?af:function(){throw new Error("not implemented")},ff="function"==typeof Int8Array?Int8Array:void 0,lf=st()?ff:function(){throw new Error("not implemented")};function sf(r){var t,e,n;for(t=[];!(e=r.next()).done;)if(kt(n=e.value)&&n.length>=2)t.push(n[0],n[1]);else{if(!he(n))return new TypeError(j("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));t.push(Ee(n),_e(n))}return t}var cf=2*fe.BYTES_PER_ELEMENT,hf=ve();function pf(r){return r instanceof mf||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function gf(r){return r===mf||"Complex128Array"===r.name}function yf(r,t){return new ce(r[t*=2],r[t+1])}function mf(){var r,t,e,n;if(t=arguments.length,!(this instanceof mf))return 0===t?new mf:1===t?new mf(arguments[0]):2===t?new mf(arguments[0],arguments[1]):new mf(arguments[0],arguments[1],arguments[2]);if(0===t)e=new fe(0);else if(1===t)if(At(arguments[0]))e=new fe(2*arguments[0]);else if(It(arguments[0]))if((n=(e=arguments[0]).length)&&ir(e)&&he(e[0])){if(e=function(r,t){var e,n,i,o;for(e=t.length,o=0,i=0;ie.byteLength-r)throw new RangeError(j("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*cf));e=new fe(e,r,2*n)}}return C(this,"_buffer",e),C(this,"_length",e.length/2),this}function df(r){var t,e,n;for(t=[];!(e=r.next()).done;)if(kt(n=e.value)&&n.length>=2)t.push(n[0],n[1]);else{if(!he(n))return new TypeError(j("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));t.push(Re(n),Be(n))}return t}C(mf,"BYTES_PER_ELEMENT",cf),C(mf,"name","Complex64Array"),C(mf,"from",(function(r){var t,e,n,i,o,a,u,f,l,s,c,h;if(!ie(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!gf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((e=arguments.length)>1){if(!ie(n=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(pf(r)){if(f=r.length,n){for(o=(i=new this(f))._buffer,h=0,c=0;c=2))throw new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(It(r)){if(n){for(f=r.length,u=r.get&&r.set?Xu("default"):$u("default"),c=0;c=2))throw new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Bt(r)&&hf&&ie(r[we])){if(!ie((o=r[we]()).next))throw new TypeError(j("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(a=n?function(r,t,e){var n,i,o,a;for(n=[],a=-1;!(i=r.next()).done;)if(a+=1,kt(o=t.call(e,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!he(o))return new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(Ee(o),_e(o))}return n}(o,n,t):sf(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,c=0;c=this._length))return yf(this._buffer,r)})),be(mf.prototype,"buffer",(function(){return this._buffer.buffer})),be(mf.prototype,"byteLength",(function(){return this._buffer.byteLength})),be(mf.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),C(mf.prototype,"BYTES_PER_ELEMENT",mf.BYTES_PER_ELEMENT),C(mf.prototype,"copyWithin",(function(r,t){if(!pf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*t):this._buffer.copyWithin(2*r,2*t,2*arguments[2]),this})),C(mf.prototype,"entries",(function(){var r,t,e,n,i,o;if(!pf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return r=this,n=this._buffer,e=this._length,o=-1,C(t={},"next",(function(){return o+=1,i||o>=e?{done:!0}:{value:[o,yf(n,o)],done:!1}})),C(t,"return",(function(r){return i=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(t,we,(function(){return r.entries()})),t})),C(mf.prototype,"every",(function(r,t){var e,n;if(!pf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Et(e))throw new TypeError(j("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(a=Ee(r),u=_e(r),f=t;f=0;n--)if(i=yf(e,n),r.call(t,i,n,this))return i})),C(mf.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!pf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=this._length-1;n>=0;n--)if(i=yf(e,n),r.call(t,i,n,this))return n;return-1})),C(mf.prototype,"forEach",(function(r,t){var e,n,i;if(!pf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return yf(this._buffer,r)})),C(mf.prototype,"includes",(function(r,t){var e,n,i,o,a;if(!pf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!he(r))throw new TypeError(j("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Ee(r),o=_e(r),e=this._buffer,a=t;a1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Ee(r),o=_e(r),e=this._buffer,a=t;a=e?{done:!0}:{value:i,done:!1}})),C(t,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(t,we,(function(){return r.keys()})),t})),C(mf.prototype,"lastIndexOf",(function(r,t){var e,n,i,o,a;if(!pf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!he(r))throw new TypeError(j("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=Ee(r),o=_e(r),e=this._buffer,a=t;a>=0;a--)if(i===e[n=2*a]&&o===e[n+1])return a;return-1})),be(mf.prototype,"length",(function(){return this._length})),C(mf.prototype,"map",(function(r,t){var e,n,i,o,a;if(!pf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,e=(i=new this.constructor(this._length))._buffer,o=0;o1)n=t,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=yf(e,0),o=1}for(;o1)n=t,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=yf(e,i-1),o=i-2}for(;o>=0;o--)n=r(n,yf(e,o),o,this);return n})),C(mf.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!pf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(e=this._length,r=this._buffer,n=bt(e/2),i=0;i1){if(!At(e=arguments[1]))throw new TypeError(j("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(he(r)){if(e>=this._length)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));return n[e*=2]=Ee(r),void(n[e+1]=_e(r))}if(pf(r)){if(e+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r._buffer,l=n.byteOffset+e*cf,t.buffer===n.buffer&&t.byteOffsetl){for(i=new fe(t.length),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r,l=n.byteOffset+e*cf,t.buffer===n.buffer&&t.byteOffsetl){for(i=new fe(a),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(e*=2,f=0;fu&&(t=u)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*cf):(i=t-r,e=n.byteOffset+r*cf),new this.constructor(n.buffer,e,i<0?0:i)})),C(mf.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!pf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(0===arguments.length)n=[];else{if(!Pt(r)&&!Dt(r))throw new TypeError(j("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Bt(t))throw new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e?{done:!0}:{value:yf(i,o),done:!1}})),C(r,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(r,we,(function(){return t.values()})),r})),C(mf.prototype,"with",(function(r,t){var e,n,i;if(!pf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Et(r))throw new TypeError(j("invalid argument. First argument must be an integer. Value: `%s`.",r));if(i=this._length,r<0&&(r+=i),r<0||r>=i)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!he(t))throw new TypeError(j("invalid argument. Second argument must be a complex number. Value: `%s`.",t));return(e=(n=new this.constructor(this._buffer))._buffer)[2*r]=Ee(t),e[2*r+1]=_e(t),n}));var vf=2*Ve.BYTES_PER_ELEMENT,wf=ve();function bf(r){return r instanceof Tf||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function Ef(r){return r===Tf||"Complex64Array"===r.name}function _f(r,t){return new oe(r[t*=2],r[t+1])}function Tf(){var r,t,e,n;if(t=arguments.length,!(this instanceof Tf))return 0===t?new Tf:1===t?new Tf(arguments[0]):2===t?new Tf(arguments[0],arguments[1]):new Tf(arguments[0],arguments[1],arguments[2]);if(0===t)e=new Ve(0);else if(1===t)if(At(arguments[0]))e=new Ve(2*arguments[0]);else if(It(arguments[0]))if((n=(e=arguments[0]).length)&&ir(e)&&he(e[0])){if(e=function(r,t){var e,n,i,o;for(e=t.length,o=0,i=0;ie.byteLength-r)throw new RangeError(j("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*vf));e=new Ve(e,r,2*n)}}return C(this,"_buffer",e),C(this,"_length",e.length/2),this}function xf(r){var t,e;for(t=[];!(e=r.next()).done;)t.push(Gt(e.value));return t}C(Tf,"BYTES_PER_ELEMENT",vf),C(Tf,"name","Complex128Array"),C(Tf,"from",(function(r){var t,e,n,i,o,a,u,f,l,s,c,h;if(!ie(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!Ef(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((e=arguments.length)>1){if(!ie(n=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(bf(r)){if(f=r.length,n){for(o=(i=new this(f))._buffer,h=0,c=0;c=2))throw new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(It(r)){if(n){for(f=r.length,u=r.get&&r.set?Xu("default"):$u("default"),c=0;c=2))throw new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Bt(r)&&wf&&ie(r[we])){if(!ie((o=r[we]()).next))throw new TypeError(j("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(a=n?function(r,t,e){var n,i,o,a;for(n=[],a=-1;!(i=r.next()).done;)if(a+=1,kt(o=t.call(e,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!he(o))return new TypeError(j("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(Re(o),Be(o))}return n}(o,n,t):df(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,c=0;c=this._length))return _f(this._buffer,r)})),be(Tf.prototype,"buffer",(function(){return this._buffer.buffer})),be(Tf.prototype,"byteLength",(function(){return this._buffer.byteLength})),be(Tf.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),C(Tf.prototype,"BYTES_PER_ELEMENT",Tf.BYTES_PER_ELEMENT),C(Tf.prototype,"copyWithin",(function(r,t){if(!bf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*t):this._buffer.copyWithin(2*r,2*t,2*arguments[2]),this})),C(Tf.prototype,"entries",(function(){var r,t,e,n,i,o,a;if(!bf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return t=this,r=this._buffer,n=this._length,o=-1,a=-2,C(e={},"next",(function(){var t;return o+=1,i||o>=n?{done:!0}:(t=new oe(r[a+=2],r[a+1]),{value:[o,t],done:!1})})),C(e,"return",(function(r){return i=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(e,we,(function(){return t.entries()})),e})),C(Tf.prototype,"every",(function(r,t){var e,n;if(!bf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Et(e))throw new TypeError(j("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(a=Re(r),u=Be(r),f=t;f=0;n--)if(i=_f(e,n),r.call(t,i,n,this))return i})),C(Tf.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!bf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=this._length-1;n>=0;n--)if(i=_f(e,n),r.call(t,i,n,this))return n;return-1})),C(Tf.prototype,"forEach",(function(r,t){var e,n,i;if(!bf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return _f(this._buffer,r)})),be(Tf.prototype,"length",(function(){return this._length})),C(Tf.prototype,"includes",(function(r,t){var e,n,i,o,a;if(!bf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!he(r))throw new TypeError(j("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Re(r),o=Be(r),e=this._buffer,a=t;a1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Re(r),o=Be(r),e=this._buffer,a=t;a=e?{done:!0}:{value:i,done:!1}})),C(t,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(t,we,(function(){return r.keys()})),t})),C(Tf.prototype,"lastIndexOf",(function(r,t){var e,n,i,o,a;if(!bf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!he(r))throw new TypeError(j("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Et(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=Re(r),o=Be(r),e=this._buffer,a=t;a>=0;a--)if(i===e[n=2*a]&&o===e[n+1])return a;return-1})),C(Tf.prototype,"map",(function(r,t){var e,n,i,o,a;if(!bf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,e=(i=new this.constructor(this._length))._buffer,o=0;o1)n=t,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=_f(e,0),o=1}for(;o1)n=t,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=_f(e,i-1),o=i-2}for(;o>=0;o--)n=r(n,_f(e,o),o,this);return n})),C(Tf.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!bf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(e=this._length,r=this._buffer,n=bt(e/2),i=0;i1){if(!At(e=arguments[1]))throw new TypeError(j("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(he(r)){if(e>=this._length)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));return n[e*=2]=Re(r),void(n[e+1]=Be(r))}if(bf(r)){if(e+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r._buffer,l=n.byteOffset+e*vf,t.buffer===n.buffer&&t.byteOffsetl){for(i=new Ve(t.length),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r,l=n.byteOffset+e*vf,t.buffer===n.buffer&&t.byteOffsetl){for(i=new Ve(a),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(e*=2,f=0;fu&&(t=u)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*vf):(i=t-r,e=n.byteOffset+r*vf),new this.constructor(n.buffer,e,i<0?0:i)})),C(Tf.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!bf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(0===arguments.length)n=[];else{if(!Ut(r)&&!Dt(r))throw new TypeError(j("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Bt(t))throw new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e?{done:!0}:{value:_f(i,o),done:!1}})),C(r,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(r,we,(function(){return t.values()})),r})),C(Tf.prototype,"with",(function(r,t){var e,n,i;if(!bf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Et(r))throw new TypeError(j("invalid argument. First argument must be an integer. Value: `%s`.",r));if(i=this._length,r<0&&(r+=i),r<0||r>=i)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!he(t))throw new TypeError(j("invalid argument. Second argument must be a complex number. Value: `%s`.",t));return(e=(n=new this.constructor(this._buffer))._buffer)[2*r]=Re(t),e[2*r+1]=Be(t),n}));var Vf=an.BYTES_PER_ELEMENT,Af=ve();function Sf(r){return"object"==typeof r&&null!==r&&"BooleanArray"===r.constructor.name&&r.BYTES_PER_ELEMENT===Vf}function Ff(r){return r===jf}function jf(){var r,t,e,n,i;if(t=arguments.length,!(this instanceof jf))return 0===t?new jf:1===t?new jf(arguments[0]):2===t?new jf(arguments[0],arguments[1]):new jf(arguments[0],arguments[1],arguments[2]);if(0===t)e=new an(0);else if(1===t)if(At(i=arguments[0]))e=new an(i);else if(It(i))e=function(r,t){var e,n;for(e=t.length,n=0;ne.byteLength-r)throw new RangeError(j("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*Vf));e=new an(e,r,n)}}return C(this,"_buffer",e),C(this,"_length",e.length),this}C(jf,"BYTES_PER_ELEMENT",Vf),C(jf,"name","BooleanArray"),C(jf,"from",(function(r){var t,e,n,i,o,a,u,f,l;if(!ie(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!Ff(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if((e=arguments.length)>1){if(!ie(n=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(It(r)){if(n){for(f=r.length,u=r.get&&r.set?Xu("default"):$u("default"),o=(i=new this(f))._buffer,l=0;l=e))return Gt(t[r])})),be(jf.prototype,"buffer",(function(){return this._buffer.buffer})),be(jf.prototype,"byteLength",(function(){return this._buffer.byteLength})),be(jf.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),C(jf.prototype,"BYTES_PER_ELEMENT",jf.BYTES_PER_ELEMENT),C(jf.prototype,"copyWithin",(function(r,t){if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return 2===arguments.length?this._buffer.copyWithin(r,t):this._buffer.copyWithin(r,t,arguments[2]),this})),C(jf.prototype,"entries",(function(){var r,t,e,n,i,o;if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return r=this,n=this._buffer,e=this._length,o=-1,C(t={},"next",(function(){return o+=1,i||o>=e?{done:!0}:{value:[o,Gt(n[o])],done:!1}})),C(t,"return",(function(r){return i=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(t,we,(function(){return r.entries()})),t})),C(jf.prototype,"every",(function(r,t){var e,n;if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Tt(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Tt(e))throw new TypeError(j("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(o=r?1:0,a=t;a=0;i--)if(n=Gt(e[i]),r.call(t,n,i,this))return n})),C(jf.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,i=this._length-1;i>=0;i--)if(n=Gt(e[i]),r.call(t,n,i,this))return i;return-1})),C(jf.prototype,"forEach",(function(r,t){var e,n;if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ie(r))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return Gt(this._buffer[r])})),C(jf.prototype,"includes",(function(r,t){var e,n;if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!qt(r))throw new TypeError(j("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(e=this._buffer,n=t;n1){if(!Tt(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(e=this._buffer,n=t;n0){if(!Pt(r))throw new TypeError(j("invalid argument. First argument must be a string. Value: `%s`.",r))}else r=",";for(t=this._buffer,e=[],n=0;n=e?{done:!0}:{value:i,done:!1}})),C(t,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(t,we,(function(){return r.keys()})),t})),C(jf.prototype,"lastIndexOf",(function(r,t){var e,n;if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!qt(r))throw new TypeError(j("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(e=this._buffer,n=t;n>=0;n--)if(r===Gt(e[n]))return n;return-1})),be(jf.prototype,"length",(function(){return this._length})),C(jf.prototype,"map",(function(r,t){var e,n,i,o;if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ie(r))throw new TypeError("invalid argument. First argument must be a function. Value: `%s`.",r);for(i=this._buffer,e=(n=new this.constructor(this._length))._buffer,o=0;o1)i=t,o=0;else{if(0===n)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");i=Gt(e[0]),o=1}for(;o1)i=t,o=n-1;else{if(0===n)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");i=Gt(e[n-1]),o=n-2}for(;o>=0;o--)i=r(i,Gt(e[o]),o,this);return i})),C(jf.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");for(r=this._buffer,e=this._length,n=bt(e/2),i=0;i1){if(!At(e=arguments[1]))throw new TypeError(j("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(It(r)){if(e+(o=r.length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=Sf(r)?r._buffer:r,u=n.byteOffset+e*Vf,t.buffer===n.buffer&&t.byteOffsetu){for(i=new an(t.length),a=0;a=this._length)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));n[e]=r?1:0}})),C(jf.prototype,"slice",(function(r,t){var e,n,i,o,a,u;if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(o=this._buffer,a=this._length,0===arguments.length)r=0,t=a;else{if(!Tt(r))throw new TypeError(j("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=a)<0&&(r=0),1===arguments.length)t=a;else{if(!Tt(t))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0?(t+=a)<0&&(t=0):t>a&&(t=a)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*Vf):(i=t-r,e=n.byteOffset+r*Vf),new this.constructor(n.buffer,e,i<0?0:i)})),C(jf.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(0===arguments.length)n=[];else{if(!Pt(r)&&!Dt(r))throw new TypeError(j("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Bt(t))throw new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e?{done:!0}:{value:Gt(i[o]),done:!1}})),C(r,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(r,we,(function(){return t.values()})),r})),C(jf.prototype,"with",(function(r,t){var e,n;if(!Sf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!Tt(r))throw new TypeError(j("invalid argument. First argument must be an integer. Value: `%s`.",r));if(n=this._length,r<0&&(r+=n),r<0||r>=n)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!qt(t))throw new TypeError(j("invalid argument. Second argument must be a boolean. Value: `%s`.",t));return(e=new this.constructor(this._buffer))._buffer[r]=t?1:0,e}));var kf=[Ve,fe,ef,mn,of,Sn,lf,an,uf,mf,Tf,jf],Lf=["float64","float32","int32","uint32","int16","uint16","int8","uint8","uint8c","complex64","complex128","bool"],If=Lf.length;function Of(r){var t;if(ir(r))return"generic";if(ur(r))return null;for(t=0;t0)for(s=0;s0)for(h=0;h=0;i--)e[i]=n,n*=r[i];return e}(r)}function il(r,t,e,n,i,o){var a,u,f,l,s;for(a=r.length,u=1,s=0;s=u&&(i=u-1);else if("wrap"===o)i<0?(i+=u)<0&&0!=(i%=u)&&(i+=u):i>=u&&(i-=u)>=u&&(i%=u);else if("normalize"===o&&i<0&&(i+=u),i<0||i>=u)throw new RangeError(j("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",u,i));if(f=e,el(n)){for(s=0;s=0;s--)i-=l=i%r[s],i/=r[s],f+=l*t[s];return f}function ol(r,t){return t>0?0:(1-r)*t}C(nl,"assign",(function(r,t,e){return el(t)?function(r,t){var e,n;for(e=1,n=0;n=0;n--)t[n]=e,e*=r[n];return t}(r,e)}));var al=3;function ul(r,t,e,n){var i,o,a,u,f,l,s;if(r<=0)return t;if((u=Rf(t)).accessorProtocol)return function(r,t,e,n){var i,o,a,u,f,l,s,c;for(i=t.data,a=t.accessors[0],o=t.accessors[1],s=bt(r/2),l=(f=n)+(r-1)*e,c=0;c0)for(s=0;s=0;o--)n.push(e[o]);t.push(n)}return t}function Sl(r){var t,e;for(t=[],e=0;e=0;e--)t.push(r[e]);return t}function kl(r){var t,e;for(t=[],e=0;e=ft?"int8":r>=zr?"int16":r>=Lr?"int32":"float64":r<=ut?"int8":r<=Wr?"int16":r<=kr?"int32":"float64"}function Dl(r,t){var e,n,i,o;for(e=ln(r),n=ln(t),i=[],o=0;ou)throw new Error("invalid arguments. Insufficient values to satisfy mask array.")}else if("strict_broadcast"===n){if(1!==u&&vu(t)!==u)throw new Error("invalid arguments. Number of values does not equal the number of falsy values in the mask array.")}else if("non_strict"===n&&vu(t)>u)throw new Error("invalid arguments. Insufficient values to satisfy mask array.");return i=nn(r),o=nn(t),a=nn(e),i.accessorProtocol||o.accessorProtocol||a.accessorProtocol?ci(i.dtype)&&ci(a.dtype)?(function(r,t,e){var n,i,o,a,u;for(n=t.data,i=t.accessors[0],a=e.length,o=0,u=0;u=0&&au)throw new Error("invalid arguments. Insufficient values to satisfy mask array.")}else if("strict_broadcast"===n){if(1!==u&&Au(t)!==u)throw new Error("invalid arguments. Number of values does not equal the number of truthy values in the mask array.")}else if("non_strict"===n&&Au(t)>u)throw new Error("invalid arguments. Insufficient values to satisfy mask array.");return i=nn(r),o=nn(t),a=nn(e),i.accessorProtocol||o.accessorProtocol||a.accessorProtocol?ci(i.dtype)&&ci(a.dtype)?(function(r,t,e){var n,i,o,a,u;for(n=t.data,i=t.accessors[0],a=e.length,o=0,u=0;ut?t:r}function Xl(r,t){var e=t+1;return r<0?((r+=e)<0&&0!=(r%=e)&&(r+=e),r):r>t?((r-=e)>t&&(r%=e),r):r}function Zl(r,t){return r<0?(r+=t+1)<0?-1:r:r>t?-1:r}function Kl(r){var t,e,n;if(!It(r))throw new TypeError(j("invalid argument. Must provide an array-like object. Value: `%s`.",r));return n=Of(r),qu(r)&&(t=Xu(n)),e=r.length,void 0===t?function(t){var n;for(n=0;n=0&&a=0&&it)throw new RangeError(j("invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.",t,r));return e},throw:function(r,t){if(r<0||r>t)throw new RangeError(j("invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.",t,r));return r}};function is(r){if(!es(r))throw new TypeError(j("invalid argument. First argument must be a recognized index mode. Value: `%s`.",r));return ns[r]}function os(r,t,e,n){var i,o,a,u,f,l;if(t.length>0)if(e.length===t.length)o=1;else{if(1!==e.length)throw new Error(j("invalid argument. The third argument must be broadcast compatible with the second argument. Array shape: (%d). Desired shape: (%d).",e.length,t.length));o=0}return i=is(n),a=r.length-1,u=nn(r),f=nn(t),l=nn(e),u.accessorProtocol||f.accessorProtocol||l.accessorProtocol?ci(u.dtype)&&ci(l.dtype)?(function(r,t,e,n,i,o){var a,u,f,l,s,c;for(a=t.data,u=t.accessors[0],l=2*n,f=0,s=0;st)throw new RangeError(j("invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.",t,r));return n}),"factory",is);var as=Array.prototype.slice;function us(r,t,e){var n;return function(r,t){return"function"==typeof r[t]}(r,"slice")?r.slice(t,e):(n=nn(r)).accessorProtocol?function(r,t,e){var n,i,o,a;for(n=r.data,i=r.accessors[0],o=[],a=t;aa?i.push(n[a][o]):i.push(t.call(e,[o,a]));n.push(i)}return n}));var cs={};function hs(r,t,e){var n,i,o,a,u,f,l;for(i=ln(r),o=ln(t),n=is(e),u=r.length-1,a=[],f=0;f=u&&f<=u+t?a.push(n.call(i,[u,f])):ft?r:t;for(n=wt,o=0;on||i===n&&0===i&&ms(i))&&(n=i)}return n}(a[0],a[1],a[2]),s=ds(a[0],g),f=ds(a[1],g),l=ds(a[2],g),o=ln(r),n=ln(t),i=ln(e),p=0,c=0,h=0,u=[],m=0;m1?arguments[1]:As))return Bo(r);if(null===(e=Yf(t)))throw new TypeError(j("invalid argument. Second argument must be a recognized data type. Value: `%s`.",t));return new e(r)}function Fs(r,t,e,n,i){var o,a;for(o=i,a=0;a=0;o--)if(t.call(e,i(n,o),o,n))return!0;return!1}(n,t,e):function(r,t,e){var n;for(n=r.length-1;n>=0;n--)if(t.call(e,r[n],n,r))return!0;return!1}(r,t,e)})),N(Ls,"anyHasOwnProp",(function(r,t){return D(r)?function(r,t){var e,n;for(e=ln(r),n=0;n=r.length)return;return ln(r)(r,t)})),N(Ls,"at2d",(function(r,t,e){var n,i;if(i=r.length,t<0&&(t+=i),!(t<0||t>=i||(i=(n=r[t]).length,e<0&&(e+=i),e<0||e>=i)))return n[e]})),N(Ls,"at3d",(function(r,t,e,n){var i,o,a;if(a=r.length,t<0&&(t+=a),!(t<0||t>=a||(a=(i=r[t]).length,e<0&&(e+=a),e<0||e>=a||(a=(o=i[e]).length,n<0&&(n+=a),n<0||n>=a))))return o[n]})),N(Ls,"at4d",(function(r,t,e,n,i){var o,a,u,f,l;for(a=[t,e,n,i],o=r,f=0;f=u)return;o=o[l]}return o})),N(Ls,"at5d",(function(r,t,e,n,i,o){var a,u,f,l,s;for(u=[t,e,n,i,o],a=r,l=0;l=f)return;a=a[s]}return a})),N(Ls,"atnd",(function(r,t){var e,n,i,o,a;for(n=[t],o=2;o=i)return;e=e[a]}return e})),N(Ls,"banded",Io),N(Ls,"bifurcateEntries",(function(r,t){var e,n,i,o,a,u;if(i=r.length,t.length!==i)throw new RangeError("invalid argument. The first and second arguments must have the same length.");if(0===i)return[];for(e=ln(r),n=ln(t),o=[[],[]],u=0;u=0;o--)if(!t.call(e,i(n,o),o,n))return!1;return!0}(n,t,e):function(r,t,e){var n;for(n=r.length-1;n>=0;n--)if(!t.call(e,r[n],n,r))return!1;return!0}(r,t,e)})),N(Ls,"fancySlice",Uf),N(Ls,"fancySliceAssign",$f),N(Ls,"fill",(function(r,t,e,n){var i;return function(r,t){return"function"==typeof r[t]}(r,"fill")?r.fill(t,e,n):(e<0&&(e+=r.length)<0&&(e=0),n<0?n+=r.length:n>r.length&&(n=r.length),(i=nn(r)).accessorProtocol?function(r,t,e,n){var i,o,a;for(i=r.data,o=r.accessors[1],a=e;ar.length&&(e=r.length),(o=nn(r)).accessorProtocol?function(r,t,e,n,i){var o,a,u,f;for(o=r.data,a=r.accessors[0],u=r.accessors[1],f=t;fr.length&&(e=r.length-1);return Ol(r)?function(r,t,e){var n,i;for(n=ln(r),i=e;i>=0;i--)if(t===n(r,i))return i;return-1}(r,t,e):function(r,t,e){var n;for(n=e;n>=0;n--)if(t===r[n])return n;return-1}(r,t,e)})),N(Ls,"lastIndexOfSameValue",(function(r,t,e){if(e<0){if((e+=r.length)<0)return-1}else e>r.length&&(e=r.length-1);return Ol(r)?gi(r)?function(r,t,e){var n,i,o,a;if(!he(t))return-1;for(n=mu(r,0),i=Re(t),o=Be(t),a=2*e;a>=0;a-=2)if(ri(n[a],i)&&ri(n[a+1],o))return a/2;return-1}(r,t,e):en(r)?function(r,t,e){var n,i,o;if(!qt(t))return-1;for(n=un(r,0),i=t?1:0,o=e;o>=0;o--)if(n[o]===i)return o;return-1}(r,t,e):function(r,t,e){var n,i;for(n=ln(r),i=e;i>=0;i--)if(ri(t,n(r,i)))return i;return-1}(r,t,e):function(r,t,e){var n;for(n=e;n>=0;n--)if(ri(t,r[n]))return n;return-1}(r,t,e)})),N(Ls,"linspace",(function(r,t,e){var n,i,o,a;if(0===e)return[];for(o=(t-r)/(i=e-1),n=[r],a=1;a=0;h--)p-=s=p%n[h],p/=n[h],f[h]=s;for(a=[],h=0;h=0;o--)if(t.call(e,i(n,o),o,n))return!1;return!0}(n,t,e):function(r,t,e){var n;for(n=r.length-1;n>=0;n--)if(t.call(e,r[n],n,r))return!1;return!0}(r,t,e)})),N(Ls,"nulls",(function(r){return jo(null,r)})),N(Ls,"oneTo",$l),N(Ls,"ones",(function(r){return jo(1,r)})),N(Ls,"ones2d",(function(r){return ko(1,r)})),N(Ls,"ones3d",(function(r){return Jf(1,r)})),N(Ls,"ones4d",(function(r){return Qf(1,r)})),N(Ls,"ones5d",(function(r){return Xf(1,r)})),N(Ls,"onesnd",(function(r){return Kf(1,r)})),N(Ls,"place",Jl),N(Ls,"put",os),N(Ls,"quaternary2d",(function(r,t,e){var n,i,o,a,u,f,l,s,c,h,p,g,y,m;if(n=t[1],i=t[0],!(n<=0||i<=0))for(h=r[0],p=r[1],g=r[2],y=r[3],m=r[4],a=0;a=e)return r;for(i=t,n=t+1;n=0;i--)n.push(e(t,i));return n}(t):function(r){var t,e;for(t=[],e=r.length-1;e>=0;e--)t.push(r[e]);return t}(r)})),N(Ls,"unary2d",(function(r,t,e){var n,i,o,a,u,f,l,s;if(n=t[1],i=t[0],!(n<=0||i<=0))for(l=r[0],s=r[1],a=0;a4&&(i=arguments[4]),c=r[0],h=r[1],f=0;f4&&(i=arguments[4]),y=r[0],m=r[1],s=0;s4&&(i=arguments[4]),w=r[0],b=r[1],h=0;h4&&(i=arguments[4]),T=r[0],x=r[1],g=0;g1?Ss(r,arguments[1]):Ss(r)}var Hs=8;function Js(r,t,e,n,i){var o,a,u,f;if(r<=0)return e;if((u=Rf(e)).accessorProtocol)return function(r,t,e,n,i){var o,a,u,f;for(o=e.data,a=e.accessors[1],u=i,f=0;f0)for(f=0;fa.byteLength-r)throw new RangeError(j("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",u));a=new Ys(a,r,u)}}return C(this,"_buffer",a),C(this,"_length",a.byteLength/t),C(this,"_isLE",i),this}return t=uc(r),e=function(r){return fc(r)+"ArrayFE"}(r),n=gc[r],i=pc[r],C(o,"BYTES_PER_ELEMENT",t),C(o,"name",e),C(o,"from",(function(n,o){var u,f,l,s,c,h,p,g,y,m,d;if(!ie(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!a(this))throw new TypeError(j("invalid invocation. `this` is not %s %s.",yc[r[0]],e));if(null===(f=dc(n))||!si(f))throw new TypeError(j("invalid argument. First argument must be a supported byte order. Value: `%s`.",n));if(c=vc(f),(l=arguments.length)>2){if(!ie(s=arguments[2]))throw new TypeError(j("invalid argument. Third argument must be a function. Value: `%s`.",s));l>3&&(u=arguments[3])}if(It(o)){if(s){for(m=o.length,y=o.get&&o.set?$("default"):W("default"),p=(h=new this(f,m))._buffer,d=0;d=o))return this._buffer[n](i*t,this._isLE)})),be(o.prototype,"buffer",(function(){return this._buffer.buffer})),be(o.prototype,"byteLength",(function(){return this._buffer.byteLength})),be(o.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),C(o.prototype,"BYTES_PER_ELEMENT",o.BYTES_PER_ELEMENT),C(o.prototype,"every",(function(i,o){var a,f;if(!u(this))throw new TypeError(j("invalid invocation. `this` is not %s %s.",yc[r[0]],e));if(!ie(i))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",i));for(a=this._buffer,f=0;f=this._length))return this._buffer[n](i*t,this._isLE)})),C(o.prototype,"includes",(function(i,o){var a,f;if(!u(this))throw new TypeError(j("invalid invocation. `this` is not %s %s.",yc[r[0]],e));if(arguments.length>1){if(!Tt(o))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",o));o<0&&(o+=this._length)<0&&(o=0)}else o=0;for(a=this._buffer,f=o;f1){if(!Tt(o))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",o));o<0&&(o+=this._length)<0&&(o=0)}else o=0;for(a=this._buffer,f=o;f0){if(!Pt(i))throw new TypeError(j("invalid argument. First argument must be a string. Value: `%s`.",i));f=i}else f=",";for(o=[],a=this._buffer,l=0;l1){if(!Tt(o))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",o));o>=this._length?o=this._length-1:o<0&&(o+=this._length)}else o=this._length-1;for(a=this._buffer,f=o;f>=0;f--)if(a[n](f*t,this._isLE)===i)return f;return-1})),be(o.prototype,"length",(function(){return this._length})),C(o.prototype,"map",(function(o,a){var f,l,s,c,h;if(!u(this))throw new TypeError(j("invalid invocation. `this` is not %s %s.",yc[r[0]],e));if(!ie(o))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",o));for(s=this._buffer,f=(l=new this.constructor(wc(this._isLE),this._length))._buffer,c=0;c1)l=o,s=0;else{if(0===f)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");l=a[n](0*t,this._isLE),s=1}for(;s1)l=o,s=f-1;else{if(0===f)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");l=a[n]((f-1)*t,this._isLE),s=f-2}for(;s>=0;s--)l=i(l,a[n](s*t,this._isLE),s,this);return l})),C(o.prototype,"set",(function(n){var o,a,f,l,s,c,h,p;if(!u(this))throw new TypeError(j("invalid invocation. `this` is not %s %s.",yc[r[0]],e));if(f=this._buffer,arguments.length>1){if(!At(a=arguments[1]))throw new TypeError(j("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",a))}else a=0;if(It(n)){if(a+(c=n.length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(s=(o=n).get&&o.set?$("default"):W("default"),p=f.byteOffset+a*t,o.buffer===f.buffer&&o.byteOffsetp){for(l=[],h=0;h=this._length)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%u`.",a));f[i](a*t,n,this._isLE)}})),C(o.prototype,"some",(function(i,o){var a,f;if(!u(this))throw new TypeError(j("invalid invocation. `this` is not %s %s.",yc[r[0]],e));if(!ie(i))throw new TypeError(j("invalid argument. First argument must be a function. Value: `%s`.",i));for(a=this._buffer,f=0;f=l)throw new RangeError(j("invalid argument. Index argument is out-of-bounds. Value: `%s`.",n));return(f=new this.constructor(wc(this._isLE),a.buffer))._buffer[i](n*t,o,this._isLE),f})),o;function a(r){return r===o}function u(r){return"object"==typeof r&&null!==r&&(r.constructor.name===e||function(r,t){var e=typeof t;if(null===t||"object"!==e&&"function"!==e)throw new TypeError(j("invalid argument. Second argument must be either an object (except null) or a function. Value: `%s`.",t));return e=typeof r,null!==r&&("object"===e||"function"===e)&&oc.call(t,r)}(r,o.prototype))&&r.BYTES_PER_ELEMENT===t}function f(r,e,n){var o,a,u;for(o=e.length,a=e.get&&e.set?$("default"):W("default"),u=0;u2?arguments[2]:Bc))return jo(t,r);if(null===(n=Yf(e)))throw new TypeError(j("invalid argument. Third argument must be a recognized data type. Value: `%s`.",e));return Qs(r,t,i=new n(r),1),i}function Mc(){}var Nc="foo"===Mc.name,Cc=[Ve,fe,ef,mn,of,Sn,lf,an,uf],Uc=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"],Dc=gr()?Gi(Ve):Yc;function Yc(){}Dc="TypedArray"===function(r){if(!1===ie(r))throw new TypeError(j("invalid argument. Must provide a function. Value: `%s`.",r));return Nc?r.name:lr.exec(r.toString())[1]}(Dc)?Dc:Yc;var Wc=[Tf,mf],zc=["Complex64Array","Complex128Array"];function qc(r){return r instanceof jf||"BooleanArray"===sr(r)}function Gc(r,t){if("function"!=typeof t)throw new TypeError(j("invalid argument. Second argument must be callable. Value: `%s`.",t));return r instanceof t}var $c=[[mr,"Float64Array"],[_r,"Float32Array"],[Br,"Int32Array"],[Fr,"Uint32Array"],[Hr,"Int16Array"],[Dr,"Uint16Array"],[ht,"Int8Array"],[rt,"Uint8Array"],[ot,"Uint8ClampedArray"],[Oe,"Complex64Array"],[Ye,"Complex128Array"],[He,"BooleanArray"]];function Hc(r){var t,e;for(e=0;e<$c.length;e++)if(Gc(r,$c[e][0]))return $c[e][1];for(;r;){for(t=sr(r),e=0;e<$c.length;e++)if(t===$c[e][1])return $c[e][1];r=Gi(r)}}function Jc(r){var t,e,n;if(function(r){var t,e;if("object"!=typeof r||null===r)return!1;if(r instanceof Dc)return!0;for(e=0;e=r.length?{done:!0}:{value:r[i],done:!1}})),C(t,"return",(function(r){return n=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(t,we,(function(){return e.iterator()})),t})),C(Xc.prototype,"last",(function(){if(this._length)return this._last})),be(Xc.prototype,"length",(function(){return this._length})),C(Xc.prototype,"pop",(function(){var r;return this._length&&(r=this._last.value,this._last._prev?(this._last=this._last._prev,this._last._next=null):(this._first=null,this._last=null),this._length-=1),r})),C(Xc.prototype,"push",(function(r){var t;return t=new Qc(r),0===this._length?(this._first=t,this._last=t):(t._prev=this._last,this._last._next=t,this._last=t),this._length+=1,this})),C(Xc.prototype,"remove",(function(r){var t,e;if(r===this._first)return this.shift();if(r===this._last)return this.pop();for(t=r.value,e=this._first;e!==this._last&&e!==r;)e=e._next;if(e===this._last)throw new Error("invalid argument. The list does not contain the provided list node.");return r._prev._next=r._next,r._next._prev=r._prev,this._length-=1,t})),C(Xc.prototype,"shift",(function(){var r;return this._length&&(r=this._first.value,this._first._next?(this._first=this._first._next,this._first._prev=null):(this._first=null,this._last=null),this._length-=1),r})),C(Xc.prototype,"toArray",(function(){var r,t,e;for(t=[],r=this._first,e=0;e1?new th(r,arguments[1]):new th(r);if(!It(r))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if("generic"===(n=Ze(r))||null===n)if(r.length>0)if(qt(o=ln(r)(r,0)))i="bool";else{if(!Tt(o))throw new TypeError("invalid argument. First argument must be a valid index array.");i="int"}else i="int";else if("int32"===n)i="int";else if("uint8"===n)i="mask";else{if("bool"!==n)throw new TypeError("invalid argument. First argument must be a valid index array.");i="bool"}if(t={persist:!1},arguments.length>1&&(e=function(r,t){return Hi(t)?rr(t,"persist")&&(r.persist=t.persist,!qt(r.persist))?new TypeError(j("invalid option. `%s` option must be a boolean. Option: `%s`.","persist",r.persist)):null:new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t))}(t,arguments[1]),e))throw e;return Zc.push({id:(rh+=1).toString(),ref:this,data:r,type:i,dtype:n,persist:t.persist}),C(this,"_node",Zc.last()),ql(this,"_invalidated",!1),this}C(th,"name","ArrayIndex"),C(th,"free",(function(r){var t,e;return null!==(t=Kc(r))&&(C((e=t.value).ref,"_invalidated",!0),Zc.remove(t),e.data=null,!0)})),C(th,"get",(function(r){var t,e,n;return null===(t=Kc(r))?null:(e={data:(n=t.value).data,type:n.type,dtype:n.dtype},n.persist||th.free(r),e)})),be(th.prototype,"data",(function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.data})),be(th.prototype,"dtype",(function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.dtype})),be(th.prototype,"id",(function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.id})),be(th.prototype,"isCached",(function(){return!this._invalidated})),be(th.prototype,"type",(function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.type})),C(th.prototype,"toString",(function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return"ArrayIndex<"+this._node.value.id+">"})),C(th.prototype,"toJSON",(function(){var r;if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return{type:"ArrayIndex",data:"generic"===(r=this._node.value).dtype||null===r.dtype?D(r.data)?cu(r.data):r.data:Jc(r.data)}}));var eh={float64:mr,float32:_r,complex128:Ye,complex64:Oe};function nh(r){return eh[r]||null}function ih(r,t,e,n,i){var o,a,u;if(0===n)return r;if(1===n)return r[0]=i?e:t,r;for(r[0]=t,a=(e-t)/(o=i?n-1:n),u=1;u3&&(o=ah(n,arguments[3])))throw o;if("generic"===n.dtype)return l?function(r,t,e,n,i,o){var a,u,f,l,s,c,h,p,g,y,m,d,v;if(0===i)return[];if(u=0,"float64"===r?(l=t,c=0):"complex64"===r?(u+=1,l=Ee(t),c=_e(t)):(l=Re(t),c=Be(t)),"float64"===e?(s=n,h=0):"complex64"===e?(u+=1,s=Ee(n),h=_e(n)):(s=Re(n),h=Be(n)),a=2===u?ce:oe,1===i)return o?[new a(s,h)]:[new a(l,c)];for(f=[new a(l,c)],y=(s-l)/(d=o?i-1:i),m=(h-c)/d,v=1;v3&&(i=ah(n,arguments[3])))throw i;if(null===(f=Ze(e))&&(f="generic"),"complex64"===f)return oh(Te(e,0),o,r,a,t,e.length,n.endpoint),e;if("complex128"===f)return oh(Ae(e,0),o,r,a,t,e.length,n.endpoint),e;if(u){if("generic"===f)return function(r,t,e,n,i,o,a){var u,f,l,s,c,h,p,g,y,m,d,v;if(0===o)return r;if(f=0,"float64"===t?(l=e,c=0):"complex64"===t?(f+=1,l=Ee(e),c=_e(e)):(l=Re(e),c=Be(e)),"float64"===n?(s=i,h=0):"complex64"===n?(f+=1,s=Ee(i),h=_e(i)):(s=Re(i),h=Be(i)),u=2===f?ce:oe,g=r.data,p=r.accessors[1],1===o)return p(g,0,a?new u(s,h):new u(l,c)),r;for(p(g,0,new u(l,c)),y=(s-l)/(d=a?o-1:o),m=(h-c)/d,v=1;v1){if(!ie(f=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be a function. Value: `%s`.",f));u>2&&(o=arguments[2])}if(It(i)){if(f){for(p=i.length,h=i.get&&i.set?$("default"):W("default"),s=(l=new this(p))._buffer,g=0;g=xh&&r<=Th?"float32":"float64":r>-_h&&r<_h?"float64":"float32"}function Ah(r){return pt(r)?r!=r||r===vr||r===wt?"float32":Et(r)?0===r&&Eh(r)?"float32":r<0?r>=ft?"int8":r>=zr?"int16":r>=Lr?"int32":"float64":r<=Qr?"uint8":r<=Mr?"uint16":r<=xr?"uint32":"float64":r>-_h&&r<_h?"float64":"float32":qt(r)?"bool":he(r)?"float64"===Vh(r.re)||"float64"===Vh(r.im)?"complex128":"complex64":"generic"}function Sh(r,t){var e;if(!It(r))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!It(t))throw new TypeError(j("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));if(r.length!==t.length)throw new Error(j("invalid arguments. Must provide equal length array-like objects."));return"generic"===(e=Ze(r))||null===e?Dl(r,t):Dl.assign(r,t,Ss(Au(t),e),1,0)}var Fh=["strict","non_strict","strict_broadcast","broadcast","repeat"],jh=hn(Fh);function kh(r,t){var e;if(!It(r))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!It(t))throw new TypeError(j("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));if(r.length!==t.length)throw new Error(j("invalid arguments. Must provide equal length array-like objects."));return"generic"===(e=Ze(r))||null===e?zl(r,t):zl.assign(r,t,Ss(vu(t),e),1,0)}var Lh=new oe(NaN,NaN),Ih=new ce(NaN,NaN),Oh=ai("floating_point_and_generic"),Rh=hn(Oh),Bh=Ts.get("dtypes.real_floating_point"),Ph=new oe(NaN,NaN),Mh=new ce(NaN,NaN),Nh=["float64","float32","complex128","complex64","generic"],Ch={float64:-1,float32:"float64",int32:-1,int16:"int32",int8:"int16",uint32:-1,uint16:"uint32",uint8:"uint16",uint8c:"uint16",generic:-1,bool:-1,complex64:"complex128",complex128:-1},Uh=Ts.get("dtypes.default");function Dh(r){var t;if(!At(r))throw new TypeError(j("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",r));if(arguments.length>1){if("generic"===(t=arguments[1]))return $l(r)}else t=Uh;return $l.assign(Ss(r,t),1,0)}var Yh=new oe(1,0),Wh=new ce(1,0),zh=Ts.get("dtypes.default"),qh=new oe(1,0),Gh=new ce(1,0),$h=["strict","non_strict","strict_broadcast","broadcast","repeat"],Hh=hn($h);function Jh(r,t,e){var n,i,o,a;if(!It(r))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!It(t))throw new TypeError(j("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));if(!It(e))throw new TypeError(j("invalid argument. Third argument must be an array-like object. Value: `%s`.",e));if(n={mode:"repeat"},arguments.length>3&&(i=function(r,t){return Hi(t)?rr(t,"mode")&&(r.mode=t.mode,!Hh(r.mode))?new TypeError(j('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"mode",$h.join('", "'),r.mode)):null:new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t))}(n,arguments[3]),i))throw i;if(o=Ze(r)||"generic",!so(a=Ze(e)||"generic",o))throw new TypeError(j("invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].",a,o));return ci(o)&&po(a)&&(e=Gf(e,o)),Jl(r,t,e,n.mode)}var Qh={float64:mr,float32:_r,int16:Hr,int32:Br,int8:ht,uint16:Dr,uint32:Fr,uint8:rt,uint8c:ot,complex64:Oe,complex128:Ye,bool:He};function Xh(r){return Qh[r]||null}var Zh=0x40000000000000,Kh=1.4426950407214463,rp=1.6751713164886512e-10,tp=2146435072,ep=1048576,np=1072693248,ip=[0,0];function op(r){var t,e,n,i,o,a,u,f,l,s,c,h,p;if(Tn(r)||r<0)return NaN;if(Nn.assign(r,ip,1,0),i=0|ip[0],o=ip[1],p=0,i=tp?r+r:i===np&&0===o?0:(p+=(i>>20)-pa|0,c=p+=(h=614244+(i&=Wa)&ep|0)>>20|0,n=.5*(f=(r=ha(r,i|h^np))-1)*f,l=function(r){var t,e,n,i,o,a;return t=(o=(i=(n=r/(2+r))*n)*i)*(0===(a=o)?.3999999999940942:.3999999999940942+a*(.22222198432149784+.15313837699209373*a)),e=i*function(r){return 0===r?.6666666666666735:.6666666666666735+r*(.2857142874366239+r*(.1818357216161805+.14798198605116586*r))}(o),n*(.5*r*r+(e+t))}(f),e=((u=f-(a=Wo(a=f-n,0))-n+l)+a)*rp+u*Kh,(e+=c-(s=c+(t=a*Kh))+t)+(t=s))}var ap={bool:1,float64:8,float32:4,int16:2,int32:4,int8:1,uint16:2,uint32:4,uint8:1,uint8c:1,complex64:8,complex128:16},up=Ts.get("dtypes.default"),fp=Xh("complex64"),lp=Xh("complex128"),sp=Xh("bool");function cp(r){return r instanceof fp}function hp(r){return r instanceof lp}function pp(r){return r instanceof sp}function gp(r){var t,e,n,i;if(n={highWaterMark:9007199254740992},arguments.length&&(i=function(r,t){return Hi(t)?rr(t,"highWaterMark")&&(r.highWaterMark=t.highWaterMark,!At(r.highWaterMark))?new TypeError(j("invalid option. `%s` option must be a nonnegative integer. Option: `%s`.","highWaterMark",r.highWaterMark)):null:new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t))}(n,r),i))throw i;return e=function(r){var t,e;for(t=[],e=0;e0){for(t=bt(op(r.byteLength)),a=e.length-1,u=t,t=Tn(a)||Tn(u)?NaN:a===wt||u===wt?wt:a===u&&0===a?Eh(a)?a:u:an.highWaterMark?null:(i=new Ps(r),t+=r,i)}((Tn(u=i)||No(u)||0===u?u:(u<0?(u=-u,f=-1):f=1,(l=op(u))===Ia?u:(l=-1===f?bt(l):Yu(l))>ka?vr:f*uu(2,l)))*ap[o]),null===a?a:new r(a,0,i))}function a(){var r,t,e,n,i,a,u,f,l,s;if(null===(e=Xh(t=(r=arguments.length)&&Pt(arguments[r-1])?arguments[r-=1]:up)))throw new TypeError(j("invalid argument. Must provide a recognized data type. Value: `%s`.",t));if(r<=0)return new e(0);if(At(arguments[0]))return o(e,arguments[0],t);if(It(arguments[0])){if(f=(n=arguments[0]).length,(s=n)instanceof Tf||"Complex128Array"===sr(s)?n=Ae(n,0):function(r){return r instanceof mf||"Complex64Array"===sr(r)}(n)?n=Te(n,0):qc(n)?n=un(n,0):ci(t)&&(f/=2),null===(i=o(e,f,t)))return i;if(hp(i)||cp(i)||pp(i))return i.set(n),i;for(u=ln(n),a=ls(i),l=0;l3&&(i=function(r,t){return Hi(t)?rr(t,"mode")&&(r.mode=t.mode,!es(r.mode))?new TypeError(j('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"mode",ts().join('", "'),r.mode)):null:new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t))}(n,arguments[3]),i))throw i;if(o=Ze(r)||"generic",!so(a=Ze(e)||"generic",o))throw new TypeError(j("invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].",a,o));return ci(o)&&po(a)&&(e=Gf(e,o)),os(r,t,e,n.mode)}var vp={Float64Array:mr,Float32Array:_r,Int32Array:Br,Uint32Array:Fr,Int16Array:Hr,Uint16Array:Dr,Int8Array:ht,Uint8Array:rt,Uint8ClampedArray:ot,Complex64Array:Oe,Complex128Array:Ye,BooleanArray:He};function wp(r,t){var e=t[0];return kt(e)&&(r.push(e.length),wp(r,e)),r}function bp(r,t,e,n,i){var o,a,u;for(o=t[e],u=0;u2&&(n=function(r,t){return Hi(t)?rr(t,"mode")&&(r.mode=t.mode,!es(r.mode))?new TypeError(j('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"mode",ts().join('", "'),r.mode)):null:new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t))}(e,arguments[2]),n))throw n;return"generic"===(i=Ze(r))||null===i?hs(r,t,e.mode):hs.assign(r,t,e.mode,Ss(t.length,i),1,0)}var Fp,jp=eval,kp="undefined"==typeof Proxy?null:Proxy;Fp=function(){var r;try{jp('"use strict"; var handler = { "get": function get( t, n ) { return t[ n ] * 100; } }; var target = { "beep": 3.14 }; var p = new Proxy( target, handler ); var x = p.beep; if ( x !== 314 ) { throw new Error( "native Proxy is not supported." ); }'),r=!0}catch(t){r=!1}return r}()?kp:function(r){return r};var Lp,Ip=Fp,Op=ie(Object.assign),Rp=Object.assign,Bp=void 0!==Object.getOwnPropertySymbols,Pp=Wi.getOwnPropertySymbols,Mp=Bp?function(r){return Pp(Wi(r))}:function(){return[]};function Np(r){var t,e,n;for(t=Yi(r),e=Mp(r),n=0;n]+>\s*/;function eg(r){return Pt(r)&&tg.test(r)}var ng=void 0!==String.prototype.trim,ig=String.prototype.trim,og=/^[\u0020\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]*([\S\s]*?)[\u0020\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]*$/,ag=ng&&""===ig.call(" \n\t\r\n\f\v            \u2028\u2029   \ufeff")&&"᠎"===ig.call("᠎")?function(r){return ig.call(r)}:function(r){return ni(r,og,"$1")};function ug(r,t){var e,n=t.get((e=ag(r)).substring(11,e.length-1));if(null===n)throw new Error(j("invalid operation. Unable to resolve array index. Value: `%s`.",r));return n}function fg(r,t,e){var n,i;if(-1===(i=Zl(n=parseInt(r,10),t-1))){if(e)throw new RangeError(j("invalid operation. Index exceeds array bounds."));return n}return i}function lg(r){return ni(r,/^invalid arguments?/,"invalid operation")}var sg=/(?:\s*-\s*)(?=\d+)(\d+)$/,cg=/(?:\s*\/\s*)(?=\d*\.?\d+)(\d*\.?\d+)$/;function hg(r,t,e,n){var i;if("end"===r)return t;if(i=r.match(sg)){if((r=t-parseInt(i[1],10))<0){if(n)return-2;r=0}return r}return(i=r.match(cg))?(r=parseFloat(i[1]))<1?n?-2:-1:bt(e&&t>0&&1!==r?(t-1)/r:t/r):-1}var pg=/\s*:\s*/,gg=/^[-+]?[0-9]+$/,yg=/^end/;function mg(r,t,e){var n,i,o;if((i=(n=ag(r).split(pg)).length)<2||i>3)return{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};if(3===i)if(0===(o=n[2]).length)n[2]=1;else{if(!1===gg.test(o))return{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};if(0===(o=parseInt(o,10)))return{code:"ERR_SLICE_INVALID_INCREMENT"};n[2]=o}else n.push(1);if(0===(o=n[0]).length)n[2]<0&&t>0?n[0]=t-1:n[0]=0;else if(yg.test(o)){if((o=hg(o,t,n[2]<0,e))<0)return-2===o?{code:"ERR_SLICE_OUT_OF_BOUNDS"}:{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};n[2]<0&&o>=t&&(o-=1),n[0]=o}else{if(!gg.test(o))return{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};if((o=parseInt(o,10))<0){if((o=t+o)<0){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};o=0}}else if(o>=t){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};o=n[2]<0?t-1:t}n[0]=o}if(0===(o=n[1]).length)n[2]<0?n[1]=null:n[1]=t;else if(yg.test(o)){if((o=hg(o,t,n[2]<0,e))<0)return-2===o?{code:"ERR_SLICE_OUT_OF_BOUNDS"}:{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};n[1]=o}else{if(!gg.test(o))return{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};if((o=parseInt(o,10))<0){if((o=t+o)<0)if(n[2]>0){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};o=0}else{if(e&&o<-1)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};o=null}}else if(o>t){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};o=t}n[1]=o}return 0===t?new Uu(0,0,n[2]):new Uu(n[0],n[1],n[2])}var dg,vg="Slice(",wg=3,bg=/\s*,\s*/,Eg=/^-?[0-9]+$/,_g=void 0!==String.prototype.startsWith,Tg=String.prototype.startsWith;dg=_g?function(r,t,e){var n;return n=e<0?r.length+e:e,0===t.length||!(n<0||n+t.length>r.length)&&Tg.call(r,t,n)}:function(r,t,e){var n,i;if(n=e<0?r.length+e:e,0===t.length)return!0;if(n<0||n+t.length>r.length)return!1;for(i=0;i=0&&f.length<=jt||It(e)))throw new TypeError(j("invalid argument. First argument must be array-like. Value: `%s`.",e));if(Wp){if(n=Cp({},r),arguments.length>1&&(i=zp(n,arguments[1])))throw i;return u={ref:e,dtype:a=(o=nn(e)).dtype||"",getter:o.accessors[0],setter:o.accessors[1],preSetElement:Dp(a),postGetArray:Yp(t,n),cache:n.cache,strict:n.strict,validator:Xp(a),array2fancy:t,ctor:new Ip(e.constructor||Array,{construct:Zp(t,n)})},new Ip(e,{get:Fg(u),set:kg(u)})}return console.warn("WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available."),e}}var Ig=Lg();C(Ig,"factory",Lg),C(Ig,"idx",th);var Og=Ts.get("dtypes.default"),Rg=Xh("complex64"),Bg=Xh("complex128"),Pg=Xh("bool"),Mg={complex128:Ye,complex64:Oe};function Ng(r){return Mg[r]||null}var Cg=Ts.get("dtypes.complex_floating_point"),Ug={int16:Hr,int32:Br,int8:ht,uint16:Dr,uint32:Fr,uint8:rt,uint8c:ot},Dg=Ts.get("dtypes.real"),Yg={float64:mr,float32:_r,int16:Hr,int32:Br,int8:ht,uint16:Dr,uint32:Fr,uint8:rt,uint8c:ot},Wg={float64:mr,float32:_r},zg={int16:Hr,int32:Br,int8:ht},qg={uint16:Dr,uint32:Fr,uint8:rt,uint8c:ot},Gg=Ts.get("dtypes.default");function $g(r){var t;if(!At(r))throw new TypeError(j("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",r));if(arguments.length>1){if("generic"===(t=arguments[1]))return wu(r)}else t=Gg;return wu.assign(Ss(r,t),1,0)}var Hg={};N(Hg,"MAX_ARRAY_LENGTH",jt),N(Hg,"MAX_TYPED_ARRAY_LENGTH",Lt);var Jg={};return N(Jg,"base",Ls),N(Jg,"BooleanArray",He),N(Jg,"ArrayBuffer",Ps),N(Jg,"byteOrders",li),N(Jg,"cartesianPower",(function(r,t){if(!It(r))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!At(t))throw new TypeError(j("invalid argument. Second argument must be a nonnegative integer. Value: `%s`.",t));return fu(r,t)})),N(Jg,"cartesianProduct",(function(r,t){if(!It(r))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!It(t))throw new TypeError(j("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));return lu(r,t)})),N(Jg,"cartesianSquare",(function(r){if(!It(r))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",r));return su(r)})),N(Jg,"Complex64Array",Oe),N(Jg,"Complex128Array",Ye),N(Jg,"convert",Gf),N(Jg,"convertSame",(function(r,t){var e=Ze(t);if(null===e)throw new TypeError(j("invalid argument. Second argument must have a recognized/supported data type. Type: `%s`. Value: `%s`.",e,t));return Gf(r,e)})),N(Jg,"ctors",Yf),N(Jg,"DataView",Ys),N(Jg,"datespace",(function(r,t,e,n){var i,o,a,u,f,l,s,c,h;if(o=100,a=!0,i={round:"floor"},r=Gs(r,"Start"),t=Gs(t,"Stop"),arguments.length>2){if(3===arguments.length?Bt(e)?i=e:(o=e,a=!1):(i=n,o=e),0===o)return[];if(!Vt(o)||o<0)throw new TypeError(j("invalid argument. Length must be a positive integer. Value: `%s`.",o));if(a){if(!Bt(i))throw new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",i));if(rr(i,"round")){if(!Pt(i.round))throw new TypeError(j("invalid option. `%s` option must be a string. Option: `%s`.","round",i.round));if(-1===qs.indexOf(i.round))throw new Error(j('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"round",qs.join('", "'),i.round))}}}switch(i.round){case"round":l=Ws;break;case"ceil":l=Yu;break;default:l=bt}for(f=o-1,c=(t.getTime()-r.getTime())/f,s=r,(u=new Array(o))[0]=s,s=s.getTime(),h=1;h1&&(t=arguments[1]),$s(r.length,t)})),N(Jg,"filled",(function(){var r,t,e,n,i,o,a;if(t=arguments.length,(t-=1)>=0&&Pt(arguments[t])?(e=arguments[t],t-=1):e=rc,null===(n=Yf(e)))throw new TypeError(j("invalid argument. Must provide a recognized data type. Value: `%s`.",e));if("generic"===e){if(t<=0)return[];if(r=arguments[0],a=arguments[1],1===t){if(At(a)?o=a:It(a)&&(o=a.length),void 0!==o)return jo(r,o);if(Rt(a))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(Bt(a)){if(!1===Ks)throw new TypeError(j("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",a));if(!ie(a[we]))throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(!ie((a=a[we]()).next))throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));return function(r,t){var e;for(e=[];!r.next().done;)e.push(t);return e}(a,r)}throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a))}if(Rt(a))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a))}if(t<=0)return new n(0);if(1===t)if(It(a=arguments[1]))i=new n(a.length);else if(Rt(a))i=new n(a);else if(At(a))i=new n(a);else{if(!Bt(a))throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(!1===Ks)throw new TypeError(j("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",a));if(!ie(a[we]))throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(!ie((a=a[we]()).next))throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));i=new n(Zs(a))}else i=2===t?new n(arguments[1],arguments[2]):new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(r=arguments[0],ci(e)?function(r,t){var e;for(e=0;e1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(i=Yf(e)))throw new TypeError(j("invalid argument. Must provide a recognized data type. Value: `%s`.",e));return new i(0)}if(t<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(ie(arguments[t-=1]))if(ie(arguments[t-1])){if(r=arguments[t],n=arguments[t-=1],0===t)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else n=arguments[t];else{if(!(t>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(r=arguments[t],!ie(n=arguments[t-=1]))throw new TypeError(j("invalid argument. Callback argument must be a function. Value: `%s`.",n))}if((t-=1)>=0&&Pt(arguments[t])?(e=arguments[t],t-=1):e=ic,null===(i=Yf(e)))throw new TypeError(j("invalid argument. Must provide a recognized data type. Value: `%s`.",e));if("generic"===e){if(u=arguments[0],0===t){if(At(u)?a=u:It(u)&&(a=u.length),void 0!==a)return Hf(a,n,r);if(Rt(u))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(Bt(u)){if(!1===nc)throw new TypeError(j("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",u));if(!ie(u[we]))throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u));if(!ie((u=u[we]()).next))throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u));return function(r,t,e){var n,i;for(n=[],i=-1;!r.next().done;)i+=1,n.push(t.call(e,i));return n}(u,n,r)}throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u))}if(Rt(u))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u))}if(0===t)if(It(u=arguments[0]))o=new i(u.length);else if(Rt(u))o=new i(u);else if(At(u))o=new i(u);else{if(!Bt(u))throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u));if(!1===nc)throw new TypeError(j("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",u));if(!ie(u[we]))throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u));if(!ie((u=u[we]()).next))throw new TypeError(j("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u));o=new i(Zs(u))}else o=1===t?new i(arguments[0],arguments[1]):new i(arguments[0],arguments[1],arguments[2]);return o.length>0&&(ci(e)||ui(e)?function(r,t,e){var n;for(n=0;n1)if(It(arguments[1])){if(n=arguments[1],arguments.length>2){if(!ie(e=arguments[2]))throw new TypeError(j("invalid argument. Callback argument must be a function. Value: `%s`.",e));t=arguments[3]}}else{if(!ie(e=arguments[1]))throw new TypeError(j("invalid argument. Callback argument must be a function. Value: `%s`.",e));t=arguments[2]}if(!Xs(r))throw new TypeError(j("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",r));if(u=-1,void 0===n){if(n=[],e){for(;u+=1,!(f=r.next()).done;)n.push(e.call(t,f.value,u));return n}for(;!(f=r.next()).done;)n.push(f.value);return n}if(i=n.length,a=Ze(n),o=D(n)?J(a):q(a),e){for(;u2&&(e=arguments[2]),n="number"==typeof t?"complex128"===e?new oe(t,0):"complex64"===e?new ce(t,0):t:t,Pc(r.length,n,e)})),N(Jg,"incrspace",(function(r,t,e){var n;if(!pt(r)||Tn(r))throw new TypeError(j("invalid argument. Start must be numeric. Value: `%s`.",r));if(!pt(t)||Tn(t))throw new TypeError(j("invalid argument. Stop must be numeric. Value: `%s`.",t));if(arguments.length<3)n=1;else if(!pt(n=e)||Tn(n))throw new TypeError(j("invalid argument. Increment must be numeric. Value: `%s`.",n));if(Yu((t-r)/n)>xr)throw new RangeError("invalid arguments. Generated array exceeds maximum array length.");return Il(r,t,n)})),N(Jg,"ArrayIndex",th),N(Jg,"Int8Array",ht),N(Jg,"Int16Array",Hr),N(Jg,"Int32Array",Br),N(Jg,"linspace",lh),N(Jg,"littleEndianFactory",vh),N(Jg,"Float32ArrayLE",wh),N(Jg,"Float64ArrayLE",bh),N(Jg,"logspace",(function(r,t,e){if(!pt(r)||Tn(r))throw new TypeError(j("invalid argument. Exponent of start value must be numeric. Value: `%s`.",r));if(!pt(t)||Tn(t))throw new TypeError(j("invalid argument. Exponent of stop value must be numeric. Value: `%s`.",t));if(arguments.length<3)e=10;else if(!At(e))throw new TypeError(j("invalid argument. Length must be a nonnegative integer. Value: `%s`.",e));return Bl(r,t,e)})),N(Jg,"minDataType",Ah),N(Jg,"mostlySafeCasts",fo),N(Jg,"mskfilter",Sh),N(Jg,"mskput",(function(r,t,e){var n,i,o,a;if(!It(r))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!It(t))throw new TypeError(j("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));if(!It(e))throw new TypeError(j("invalid argument. Third argument must be an array-like object. Value: `%s`.",e));if(n={mode:"repeat"},arguments.length>3&&(i=function(r,t){return Hi(t)?rr(t,"mode")&&(r.mode=t.mode,!jh(r.mode))?new TypeError(j('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"mode",Fh.join('", "'),r.mode)):null:new TypeError(j("invalid argument. Options argument must be an object. Value: `%s`.",t))}(n,arguments[3]),i))throw i;if(o=Ze(r)||"generic",!so(a=Ze(e)||"generic",o))throw new TypeError(j("invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].",a,o));return ci(o)&&po(a)&&(e=Gf(e,o)),Wl(r,t,e,n.mode)})),N(Jg,"mskreject",kh),N(Jg,"nans",(function(r){var t;if(arguments.length>1){if(!Rh(t=arguments[1]))throw new TypeError(j('invalid argument. Second argument must be one of the following: "%s". Value: `%s`.',Oh.join('", "'),t))}else t=Bh;return Pc(r,"complex128"===t?Lh:"complex64"===t?Ih:NaN,t)})),N(Jg,"nansLike",(function(r){var t,e;if(null===(t=Ze(r)))throw new TypeError(j("invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.",r));if(arguments.length>1){if(t=arguments[1],-1===Nh.indexOf(t))throw new TypeError(j('invalid argument. Second argument must be one of the following: "%s". Value: `%s`.',Nh.join('", "'),t))}else if(-1===Nh.indexOf(t))throw new TypeError(j('invalid argument. First argument must be one of the following data types: "%s". Value: `%s`.',Nh.join('", "'),t));return e="complex128"===t?Ph:"complex64"===t?Mh:NaN,Pc(r.length,e,t)})),N(Jg,"nextDataType",(function(r){return 0===arguments.length?function(){var r,t,e,n;for(e={},t=(r=Yi(Ch)).length,n=0;n1&&(t=arguments[1]),Dh(r.length,t)})),N(Jg,"ones",(function(r){var t;return Pc(r,"complex128"===(t=arguments.length>1?arguments[1]:zh)?Yh:"complex64"===t?Wh:1,t)})),N(Jg,"onesLike",(function(r){var t,e;if(null===(t=Ze(r)))throw new TypeError(j("invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.",r));return arguments.length>1&&(t=arguments[1]),e="complex128"===t?qh:"complex64"===t?Gh:1,Pc(r.length,e,t)})),N(Jg,"place",Jh),N(Jg,"typedarraypool",yp),N(Jg,"promotionRules",(function(r,t){var e;return 0===arguments.length?function(){var r,t,e,n,i,o,a,u,f;for(e={},t=(r=Yi(mp)).length,f=0;f1&&(t.length=bp(e,t,1,r,e>2)),t})),N(Jg,"SharedArrayBuffer",Ap),N(Jg,"slice",(function(r){var t,e;if(!It(r))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(arguments.length>2){if(!Tt(e=arguments[2]))throw new TypeError(j("invalid argument. Third argument must be an integer. Value: `%s`.",e))}else e=r.length}else t=0,e=r.length;return us(r,t,e)})),N(Jg,"take",Sp),N(Jg,"circarray2iterator",(function r(t){var e,n,i,o,a,u,f,l,s,c;if(!It(t))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(o={iter:1e308,dir:1},arguments.length>1)if(Hi(arguments[1])){if(n=arguments[1],arguments.length>2){if(!ie(f=arguments[2]))throw new TypeError(j("invalid argument. Callback argument must be a function. Value: `%s`.",f));e=arguments[3]}if(rr(n,"iter")&&(o.iter=n.iter,!At(n.iter)))throw new TypeError(j("invalid option. `%s` option must be a nonnegative integer. Option: `%s`.","iter",n.iter));if(rr(n,"dir")&&(o.dir=n.dir,1!==n.dir&&-1!==n.dir))throw new TypeError(j("invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.","dir",n.dir))}else{if(!ie(f=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be either a function or an options object. Value: `%s`.",f));e=arguments[2]}return i=0,a={},f?1===o.dir?(c=-1,C(a,"next",(function(){return c=(c+1)%t.length,i+=1,u||i>o.iter||0===t.length?{done:!0}:{value:f.call(e,l(t,c),c,i,t),done:!1}}))):(c=t.length,C(a,"next",(function(){return(c-=1)<0&&(c+=t.length),i+=1,u||i>o.iter||0===t.length?{done:!0}:{value:f.call(e,l(t,c),c,i,t),done:!1}}))):1===o.dir?(c=-1,C(a,"next",(function(){return c=(c+1)%t.length,i+=1,u||i>o.iter||0===t.length?{done:!0}:{value:l(t,c),done:!1}}))):(c=t.length,C(a,"next",(function(){return(c-=1)<0&&(c+=t.length),i+=1,u||i>o.iter||0===t.length?{done:!0}:{value:l(t,c),done:!1}}))),C(a,"return",(function(r){return u=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(a,we,(function(){return f?r(t,o,f,e):r(t,o)})),s=Ze(t),l=D(t)?$(s):W(s),a})),N(Jg,"array2fancy",Ig),N(Jg,"array2iterator",(function r(t){var e,n,i,o,a,u,f;if(!It(t))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(arguments.length>1){if(!ie(o=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be a function. Value: `%s`.",o));e=arguments[2]}return f=-1,C(n={},"next",o?function(){return f+=1,i||f>=t.length?{done:!0}:{value:o.call(e,a(t,f),f,t),done:!1}}:function(){return f+=1,i||f>=t.length?{done:!0}:{value:a(t,f),done:!1}}),C(n,"return",(function(r){return i=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(n,we,(function(){return o?r(t,o,e):r(t)})),u=Ze(t),a=D(t)?$(u):W(u),n})),N(Jg,"array2iteratorRight",(function r(t){var e,n,i,o,a,u,f,l;if(!It(t))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(arguments.length>1){if(!ie(o=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be a function. Value: `%s`.",o));e=arguments[2]}return a=t.length,l=a,C(n={},"next",o?function(){return l+=t.length-a-1,a=t.length,i||l<0?(i=!0,{done:!0}):{value:o.call(e,u(t,l),l,t),done:!1}}:function(){return l+=t.length-a-1,a=t.length,i||l<0?(i=!0,{done:!0}):{value:u(t,l),done:!1}}),C(n,"return",(function(r){return i=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(n,we,(function(){return o?r(t,o,e):r(t)})),f=Ze(t),u=D(t)?$(f):W(f),n})),N(Jg,"typedarray2json",Jc),N(Jg,"sparsearray2iterator",(function r(t){var e,n,i,o,a,u,f;if(!It(t))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(arguments.length>1){if(!ie(o=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be a function. Value: `%s`.",o));e=arguments[2]}return f=-1,C(n={},"next",o?function(){var r;if(i)return{done:!0};for(r=t.length,f+=1;f=r?(i=!0,{done:!0}):{value:o.call(e,a(t,f),f,t),done:!1}}:function(){var r;if(i)return{done:!0};for(r=t.length,f+=1;f=r?(i=!0,{done:!0}):{value:a(t,f),done:!1}}),C(n,"return",(function(r){return i=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(n,we,(function(){return o?r(t,o,e):r(t)})),u=Ze(t),a=D(t)?$(u):W(u),n})),N(Jg,"sparsearray2iteratorRight",(function r(t){var e,n,i,o,a,u,f,l;if(!It(t))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(arguments.length>1){if(!ie(o=arguments[1]))throw new TypeError(j("invalid argument. Second argument must be a function. Value: `%s`.",o));e=arguments[2]}return a=t.length,l=a,C(n={},"next",o?function(){if(i)return{done:!0};for(l+=t.length-a-1,a=t.length;l>=0&&void 0===u(t,l);)l-=1;return l<0?(i=!0,{done:!0}):{value:o.call(e,u(t,l),l,t),done:!1}}:function(){if(i)return{done:!0};for(l+=t.length-a-1,a=t.length;l>=0&&void 0===u(t,l);)l-=1;return l<0?(i=!0,{done:!0}):{value:u(t,l),done:!1}}),C(n,"return",(function(r){return i=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(n,we,(function(){return o?r(t,o,e):r(t)})),f=Ze(t),u=D(t)?$(f):W(f),n})),N(Jg,"stridedarray2iterator",(function r(t,e,n,i){var o,a,u,f,l,s,c,h;if(!At(t))throw new TypeError(j("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",t));if(!It(e))throw new TypeError(j("invalid argument. Second argument must be an array-like object. Value: `%s`.",e));if(!Tt(n))throw new TypeError(j("invalid argument. Third argument must be an integer. Value: `%s`.",n));if(!At(i))throw new TypeError(j("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",i));if(arguments.length>4){if(!ie(f=arguments[4]))throw new TypeError(j("invalid argument. Fifth argument must be a function. Value: `%s`.",f));o=arguments[5]}return l=i,h=-1,C(a={},"next",f?function(){var r;return h+=1,u||h>=t?{done:!0}:(r=f.call(o,s(e,l),l,h,e),l+=n,{value:r,done:!1})}:function(){var r;return h+=1,u||h>=t?{done:!0}:(r=s(e,l),l+=n,{value:r,done:!1})}),C(a,"return",(function(r){return u=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(a,we,(function(){return f?r(t,e,n,i,f,o):r(t,e,n,i)})),c=Ze(e),s=D(e)?$(c):W(c),a})),N(Jg,"arrayview2iterator",(function r(t){var e,n,i,o,a,u,f,l,s,c;if(!It(t))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(1===(i=arguments.length))n=0,f=t.length;else if(2===i)ie(arguments[1])?(n=0,u=arguments[1]):n=arguments[1],f=t.length;else if(3===i)ie(arguments[1])?(n=0,f=t.length,u=arguments[1],e=arguments[2]):ie(arguments[2])?(n=arguments[1],f=t.length,u=arguments[2]):(n=arguments[1],f=arguments[2]);else{if(n=arguments[1],f=arguments[2],!ie(u=arguments[3]))throw new TypeError(j("invalid argument. Fourth argument must be a function. Value: `%s`.",u));e=arguments[4]}if(!Tt(n))throw new TypeError(j("invalid argument. Second argument must be either an integer (starting index) or a function. Value: `%s`.",n));if(!Tt(f))throw new TypeError(j("invalid argument. Third argument must be either an integer (ending index) or a function. Value: `%s`.",f));return f<0?(f=t.length+f)<0&&(f=0):f>t.length&&(f=t.length),n<0&&(n=t.length+n)<0&&(n=0),c=n-1,C(o={},"next",u?function(){return c+=1,a||c>=f?{done:!0}:{value:u.call(e,l(t,c),c,c-n,t),done:!1}}:function(){return c+=1,a||c>=f?{done:!0}:{value:l(t,c),done:!1}}),C(o,"return",(function(r){return a=!0,arguments.length?{value:r,done:!0}:{done:!0}})),we&&C(o,we,(function(){return u?r(t,n,f,u,e):r(t,n,f)})),s=Ze(t),l=D(t)?$(s):W(s),o})),N(Jg,"arrayview2iteratorRight",(function r(t){var e,n,i,o,a,u,f,l,s,c;if(!It(t))throw new TypeError(j("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(1===(i=arguments.length))n=0,f=t.length;else if(2===i)ie(arguments[1])?(n=0,u=arguments[1]):n=arguments[1],f=t.length;else if(3===i)ie(arguments[1])?(n=0,f=t.length,u=arguments[1],e=arguments[2]):ie(arguments[2])?(n=arguments[1],f=t.length,u=arguments[2]):(n=arguments[1],f=arguments[2]);else{if(n=arguments[1],f=arguments[2],!ie(u=arguments[3]))throw new TypeError(j("invalid argument. Fourth argument must be a function. Value: `%s`.",u));e=arguments[4]}if(!Tt(n))throw new TypeError(j("invalid argument. Second argument must be either an integer (starting view index) or a function. Value: `%s`.",n));if(!Tt(f))throw new TypeError(j("invalid argument. Third argument must be either an integer (ending view index) or a function. Value: `%s`.",f));return f<0?(f=t.length+f)<0&&(f=0):f>t.length&&(f=t.length),n<0&&(n=t.length+n)<0&&(n=0),c=f,C(o={},"next",u?function(){return c-=1,a||c1&&(t=arguments[1]),$g(r.length,t)})),N(Jg,"zeros",Ss),N(Jg,"zerosLike",(function(r){var t=Ze(r);if(null===t)throw new TypeError(j("invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.",r));return arguments.length>1&&(t=arguments[1]),Ss(r.length,t)})),N(Jg,"constants",Hg),Jg},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(r="undefined"!=typeof globalThis?globalThis:r||self).ns=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 000000000..12cd8014d --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../node_modules/@stdlib/utils/define-property/lib/define_property.js","../node_modules/@stdlib/utils/define-property/lib/builtin.js","../node_modules/@stdlib/string/base/format-interpolate/lib/is_number.js","../node_modules/@stdlib/string/base/format-interpolate/lib/zero_pad.js","../node_modules/@stdlib/string/base/format-interpolate/lib/format_integer.js","../node_modules/@stdlib/string/base/format-interpolate/lib/format_double.js","../node_modules/@stdlib/string/base/format-interpolate/lib/space_pad.js","../node_modules/@stdlib/string/base/format-interpolate/lib/main.js","../node_modules/@stdlib/string/base/format-interpolate/lib/is_string.js","../node_modules/@stdlib/string/base/format-tokenize/lib/main.js","../node_modules/@stdlib/string/format/lib/main.js","../node_modules/@stdlib/string/format/lib/is_string.js","../node_modules/@stdlib/utils/define-property/lib/polyfill.js","../node_modules/@stdlib/utils/define-property/lib/index.js","../node_modules/@stdlib/utils/define-property/lib/has_define_property_support.js","../node_modules/@stdlib/utils/define-read-only-property/lib/main.js","../node_modules/@stdlib/utils/define-nonenumerable-read-only-property/lib/main.js","../base/assert/is-accessor-array/lib/main.js","../base/getter/lib/main.js","../base/setter/lib/main.js","../base/accessor-getter/lib/main.js","../base/accessor-setter/lib/main.js","../node_modules/@stdlib/assert/has-tostringtag-support/lib/main.js","../node_modules/@stdlib/assert/has-symbol-support/lib/main.js","../node_modules/@stdlib/utils/native-class/lib/tostring.js","../node_modules/@stdlib/assert/has-own-property/lib/main.js","../node_modules/@stdlib/symbol/ctor/lib/main.js","../node_modules/@stdlib/utils/native-class/lib/tostringtag.js","../node_modules/@stdlib/utils/native-class/lib/index.js","../node_modules/@stdlib/utils/native-class/lib/polyfill.js","../node_modules/@stdlib/utils/native-class/lib/main.js","../node_modules/@stdlib/assert/is-array/lib/main.js","../node_modules/@stdlib/assert/tools/array-function/lib/main.js","../node_modules/@stdlib/assert/is-object-like/lib/main.js","../node_modules/@stdlib/assert/is-buffer/lib/main.js","../node_modules/@stdlib/regexp/function-name/lib/main.js","../node_modules/@stdlib/assert/is-object-like/lib/index.js","../node_modules/@stdlib/regexp/function-name/lib/regexp.js","../node_modules/@stdlib/utils/constructor-name/lib/main.js","../node_modules/@stdlib/regexp/function-name/lib/index.js","../dtype/lib/ctor2dtype.js","../node_modules/@stdlib/assert/is-float64array/lib/main.js","../node_modules/@stdlib/assert/has-float64array-support/lib/float64array.js","../node_modules/@stdlib/assert/has-float64array-support/lib/main.js","../float64/lib/main.js","../float64/lib/index.js","../float64/lib/polyfill.js","../node_modules/@stdlib/assert/is-float32array/lib/main.js","../node_modules/@stdlib/constants/float64/pinf/lib/index.js","../node_modules/@stdlib/assert/has-float32array-support/lib/float32array.js","../node_modules/@stdlib/assert/has-float32array-support/lib/main.js","../float32/lib/main.js","../float32/lib/index.js","../float32/lib/polyfill.js","../node_modules/@stdlib/assert/is-uint32array/lib/main.js","../node_modules/@stdlib/constants/uint32/max/lib/index.js","../node_modules/@stdlib/assert/has-uint32array-support/lib/uint32array.js","../node_modules/@stdlib/assert/has-uint32array-support/lib/main.js","../uint32/lib/main.js","../uint32/lib/index.js","../uint32/lib/polyfill.js","../node_modules/@stdlib/assert/is-int32array/lib/main.js","../node_modules/@stdlib/constants/int32/max/lib/index.js","../node_modules/@stdlib/constants/int32/min/lib/index.js","../node_modules/@stdlib/assert/has-int32array-support/lib/int32array.js","../node_modules/@stdlib/assert/has-int32array-support/lib/main.js","../int32/lib/main.js","../int32/lib/index.js","../int32/lib/polyfill.js","../node_modules/@stdlib/assert/is-uint16array/lib/main.js","../node_modules/@stdlib/constants/uint16/max/lib/index.js","../node_modules/@stdlib/assert/has-uint16array-support/lib/uint16array.js","../node_modules/@stdlib/assert/has-uint16array-support/lib/main.js","../uint16/lib/main.js","../uint16/lib/index.js","../uint16/lib/polyfill.js","../node_modules/@stdlib/assert/is-int16array/lib/main.js","../node_modules/@stdlib/constants/int16/max/lib/index.js","../node_modules/@stdlib/constants/int16/min/lib/index.js","../node_modules/@stdlib/assert/has-int16array-support/lib/int16array.js","../node_modules/@stdlib/assert/has-int16array-support/lib/main.js","../int16/lib/main.js","../int16/lib/index.js","../int16/lib/polyfill.js","../node_modules/@stdlib/assert/is-uint8array/lib/main.js","../node_modules/@stdlib/constants/uint8/max/lib/index.js","../node_modules/@stdlib/assert/has-uint8array-support/lib/uint8array.js","../node_modules/@stdlib/assert/has-uint8array-support/lib/main.js","../uint8/lib/main.js","../uint8/lib/index.js","../uint8/lib/polyfill.js","../node_modules/@stdlib/assert/is-uint8clampedarray/lib/main.js","../node_modules/@stdlib/assert/has-uint8clampedarray-support/lib/uint8clampedarray.js","../node_modules/@stdlib/assert/has-uint8clampedarray-support/lib/main.js","../uint8c/lib/main.js","../uint8c/lib/index.js","../uint8c/lib/polyfill.js","../node_modules/@stdlib/assert/is-int8array/lib/main.js","../node_modules/@stdlib/constants/int8/max/lib/index.js","../node_modules/@stdlib/constants/int8/min/lib/index.js","../node_modules/@stdlib/assert/has-int8array-support/lib/int8array.js","../node_modules/@stdlib/assert/has-int8array-support/lib/main.js","../int8/lib/main.js","../int8/lib/index.js","../int8/lib/polyfill.js","../node_modules/@stdlib/assert/is-number/lib/primitive.js","../node_modules/@stdlib/number/ctor/lib/main.js","../node_modules/@stdlib/assert/is-number/lib/tostring.js","../node_modules/@stdlib/assert/is-number/lib/object.js","../node_modules/@stdlib/assert/is-number/lib/try2serialize.js","../node_modules/@stdlib/assert/is-number/lib/main.js","../node_modules/@stdlib/assert/is-number/lib/index.js","../node_modules/@stdlib/constants/float64/ninf/lib/index.js","../node_modules/@stdlib/math/base/special/floor/lib/main.js","../node_modules/@stdlib/math/base/assert/is-integer/lib/main.js","../node_modules/@stdlib/assert/is-integer/lib/integer.js","../node_modules/@stdlib/assert/is-integer/lib/primitive.js","../node_modules/@stdlib/assert/is-integer/lib/object.js","../node_modules/@stdlib/assert/is-integer/lib/main.js","../node_modules/@stdlib/assert/is-nonnegative-integer/lib/primitive.js","../node_modules/@stdlib/assert/is-nonnegative-integer/lib/object.js","../node_modules/@stdlib/assert/is-nonnegative-integer/lib/main.js","../node_modules/@stdlib/assert/is-integer/lib/index.js","../node_modules/@stdlib/assert/is-nonnegative-integer/lib/index.js","../node_modules/@stdlib/constants/array/max-array-length/lib/index.js","../node_modules/@stdlib/assert/is-array-like-object/lib/main.js","../node_modules/@stdlib/constants/array/max-typed-array-length/lib/index.js","../node_modules/@stdlib/assert/is-collection/lib/main.js","../node_modules/@stdlib/assert/is-arraybuffer/lib/main.js","../node_modules/@stdlib/assert/is-object/lib/main.js","../node_modules/@stdlib/assert/is-string/lib/primitive.js","../node_modules/@stdlib/assert/is-string/lib/valueof.js","../node_modules/@stdlib/assert/is-string/lib/object.js","../node_modules/@stdlib/assert/is-string/lib/try2valueof.js","../node_modules/@stdlib/assert/is-string/lib/main.js","../node_modules/@stdlib/assert/is-string/lib/index.js","../node_modules/@stdlib/assert/is-string-array/lib/index.js","../node_modules/@stdlib/utils/type-of/lib/fixtures/re.js","../node_modules/@stdlib/assert/is-boolean/lib/primitive.js","../node_modules/@stdlib/boolean/ctor/lib/main.js","../node_modules/@stdlib/assert/is-boolean/lib/tostring.js","../node_modules/@stdlib/assert/is-boolean/lib/object.js","../node_modules/@stdlib/assert/is-boolean/lib/try2serialize.js","../node_modules/@stdlib/assert/is-boolean/lib/main.js","../node_modules/@stdlib/assert/is-boolean/lib/index.js","../node_modules/@stdlib/utils/global/lib/self.js","../node_modules/@stdlib/utils/global/lib/window.js","../node_modules/@stdlib/utils/global/lib/global_this.js","../node_modules/@stdlib/utils/type-of/lib/fixtures/nodelist.js","../node_modules/@stdlib/utils/global/lib/browser.js","../node_modules/@stdlib/utils/global/lib/codegen.js","../node_modules/@stdlib/utils/type-of/lib/fixtures/typedarray.js","../node_modules/@stdlib/utils/type-of/lib/index.js","../node_modules/@stdlib/utils/type-of/lib/check.js","../node_modules/@stdlib/utils/type-of/lib/polyfill.js","../node_modules/@stdlib/utils/type-of/lib/main.js","../node_modules/@stdlib/assert/is-function/lib/main.js","../node_modules/@stdlib/complex/float64/ctor/lib/main.js","../node_modules/@stdlib/complex/float64/ctor/lib/tostring.js","../node_modules/@stdlib/complex/float64/ctor/lib/tojson.js","../node_modules/@stdlib/number/float64/base/to-float32/lib/main.js","../node_modules/@stdlib/array/float32/lib/main.js","../node_modules/@stdlib/array/float32/lib/index.js","../node_modules/@stdlib/array/float32/lib/polyfill.js","../node_modules/@stdlib/number/float64/base/to-float32/lib/polyfill.js","../node_modules/@stdlib/number/float64/base/to-float32/lib/index.js","../node_modules/@stdlib/complex/float32/ctor/lib/main.js","../node_modules/@stdlib/assert/is-complex-like/lib/main.js","../node_modules/@stdlib/math/base/assert/is-even/lib/main.js","../node_modules/@stdlib/complex/float32/ctor/lib/tostring.js","../node_modules/@stdlib/complex/float32/ctor/lib/tojson.js","../base/assert/is-complex64array/lib/main.js","../base/assert/is-complex128array/lib/main.js","../node_modules/@stdlib/assert/has-iterator-symbol-support/lib/main.js","../node_modules/@stdlib/symbol/iterator/lib/main.js","../node_modules/@stdlib/utils/define-nonenumerable-read-only-accessor/lib/main.js","../node_modules/@stdlib/complex/float32/real/lib/main.js","../node_modules/@stdlib/complex/float32/imag/lib/main.js","../node_modules/@stdlib/strided/base/reinterpret-complex64/lib/main.js","../node_modules/@stdlib/array/float64/lib/main.js","../node_modules/@stdlib/array/float64/lib/index.js","../node_modules/@stdlib/array/float64/lib/polyfill.js","../node_modules/@stdlib/strided/base/reinterpret-complex128/lib/main.js","../complex64/lib/from_iterator.js","../complex64/lib/main.js","../complex64/lib/from_array.js","../node_modules/@stdlib/complex/float64/real/lib/main.js","../node_modules/@stdlib/complex/float64/imag/lib/main.js","../complex128/lib/from_iterator.js","../complex64/lib/from_iterator_map.js","../complex128/lib/main.js","../complex128/lib/from_array.js","../bool/lib/from_iterator.js","../complex128/lib/from_iterator_map.js","../bool/lib/main.js","../bool/lib/from_array.js","../bool/lib/from_iterator_map.js","../dtype/lib/ctors.js","../dtype/lib/dtypes.js","../dtype/lib/main.js","../base/accessors/lib/main.js","../base/accessor/lib/main.js","../node_modules/@stdlib/utils/define-nonenumerable-read-write-accessor/lib/main.js","../base/assert/is-booleanarray/lib/main.js","../base/arraylike2object/lib/main.js","../node_modules/@stdlib/array/uint8/lib/main.js","../node_modules/@stdlib/array/uint8/lib/index.js","../node_modules/@stdlib/array/uint8/lib/polyfill.js","../node_modules/@stdlib/strided/base/reinterpret-boolean/lib/main.js","../base/any/lib/main.js","../base/resolve-getter/lib/main.js","../node_modules/@stdlib/assert/has-property/lib/main.js","../base/assert/contains/lib/main.js","../base/assert/contains/lib/factory.js","../node_modules/@stdlib/math/base/assert/is-nanf/lib/main.js","../base/assert/contains/lib/index.js","../node_modules/@stdlib/constants/float32/sign-mask/lib/index.js","../node_modules/@stdlib/array/uint32/lib/main.js","../node_modules/@stdlib/array/uint32/lib/index.js","../node_modules/@stdlib/array/uint32/lib/polyfill.js","../node_modules/@stdlib/number/float32/base/to-word/lib/main.js","../node_modules/@stdlib/math/base/special/abs/lib/main.js","../node_modules/@stdlib/number/float32/base/ulp-difference/lib/main.js","../node_modules/@stdlib/number/float32/base/assert/is-almost-equal/lib/main.js","../node_modules/@stdlib/math/base/assert/is-nan/lib/main.js","../node_modules/@stdlib/constants/float64/high-word-sign-mask/lib/index.js","../node_modules/@stdlib/assert/is-little-endian/lib/main.js","../node_modules/@stdlib/array/uint16/lib/main.js","../node_modules/@stdlib/array/uint16/lib/index.js","../node_modules/@stdlib/array/uint16/lib/polyfill.js","../node_modules/@stdlib/assert/is-little-endian/lib/ctors.js","../node_modules/@stdlib/number/float64/base/to-words/lib/indices.js","../node_modules/@stdlib/number/float64/base/to-words/lib/assign.js","../node_modules/@stdlib/number/float64/base/to-words/lib/main.js","../node_modules/@stdlib/number/float64/base/to-words/lib/index.js","../node_modules/@stdlib/number/float64/base/ulp-difference/lib/main.js","../node_modules/@stdlib/number/float64/base/assert/is-almost-equal/lib/main.js","../node_modules/@stdlib/complex/float32/reim/lib/main.js","../node_modules/@stdlib/complex/float64/reim/lib/main.js","../node_modules/@stdlib/assert/is-almost-equal/lib/main.js","../node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/lib/main.js","../node_modules/@stdlib/complex/float64/base/assert/is-almost-equal/lib/main.js","../base/assert/has-almost-equal-values/lib/main.js","../base/assert/has-equal-values/lib/main.js","../node_modules/@stdlib/number/float64/base/assert/is-same-value/lib/main.js","../node_modules/@stdlib/assert/is-same-value/lib/main.js","../node_modules/@stdlib/complex/float64/base/assert/is-same-value/lib/main.js","../base/assert/has-same-values/lib/main.js","../node_modules/@stdlib/string/base/replace/lib/main.js","../dtypes/lib/main.js","../base/assert/is-boolean-data-type/lib/main.js","../byte-orders/lib/main.js","../base/assert/is-byte-order/lib/main.js","../base/assert/is-complex-floating-point-data-type/lib/main.js","../base/assert/is-complex-typed-array/lib/main.js","../base/assert/is-data-type/lib/main.js","../base/assert/is-floating-point-data-type/lib/main.js","../base/assert/is-integer-data-type/lib/main.js","../node_modules/@stdlib/utils/keys/lib/builtin.js","../node_modules/@stdlib/utils/keys/lib/has_builtin.js","../node_modules/@stdlib/assert/is-arguments/lib/detect.js","../node_modules/@stdlib/assert/is-arguments/lib/main.js","../node_modules/@stdlib/assert/is-nan/lib/primitive.js","../node_modules/@stdlib/assert/is-nan/lib/object.js","../node_modules/@stdlib/assert/is-nan/lib/main.js","../node_modules/@stdlib/assert/is-nan/lib/index.js","../node_modules/@stdlib/assert/is-enumerable-property/lib/native.js","../node_modules/@stdlib/assert/is-enumerable-property/lib/has_string_enumerability_bug.js","../node_modules/@stdlib/assert/is-enumerable-property/lib/main.js","../node_modules/@stdlib/assert/is-arguments/lib/index.js","../node_modules/@stdlib/assert/is-arguments/lib/polyfill.js","../node_modules/@stdlib/utils/keys/lib/builtin_wrapper.js","../node_modules/@stdlib/utils/keys/lib/has_enumerable_prototype_bug.js","../node_modules/@stdlib/utils/noop/lib/main.js","../node_modules/@stdlib/utils/keys/lib/has_non_enumerable_properties_bug.js","../node_modules/@stdlib/utils/index-of/lib/main.js","../node_modules/@stdlib/utils/keys/lib/is_constructor_prototype.js","../node_modules/@stdlib/utils/keys/lib/main.js","../node_modules/@stdlib/utils/keys/lib/window.js","../node_modules/@stdlib/utils/keys/lib/has_automation_equality_bug.js","../node_modules/@stdlib/utils/keys/lib/has_window.js","../node_modules/@stdlib/utils/keys/lib/has_arguments_bug.js","../node_modules/@stdlib/utils/keys/lib/polyfill.js","../node_modules/@stdlib/utils/keys/lib/is_constructor_prototype_wrapper.js","../node_modules/@stdlib/utils/get-prototype-of/lib/detect.js","../node_modules/@stdlib/object/ctor/lib/main.js","../node_modules/@stdlib/utils/get-prototype-of/lib/native.js","../node_modules/@stdlib/utils/get-prototype-of/lib/polyfill.js","../node_modules/@stdlib/utils/get-prototype-of/lib/proto.js","../node_modules/@stdlib/utils/get-prototype-of/lib/main.js","../node_modules/@stdlib/assert/is-plain-object/lib/main.js","../node_modules/@stdlib/strided/dtypes/lib/main.js","../node_modules/@stdlib/ndarray/dtypes/lib/main.js","../node_modules/@stdlib/ndarray/dtypes/lib/enum.js","../node_modules/@stdlib/ndarray/dtypes/lib/index.js","../node_modules/@stdlib/ndarray/dtypes/lib/assign.js","../node_modules/@stdlib/strided/dtypes/lib/enum.js","../node_modules/@stdlib/strided/dtypes/lib/index.js","../node_modules/@stdlib/strided/dtypes/lib/assign.js","../node_modules/@stdlib/strided/base/dtype-enum2str/lib/main.js","../node_modules/@stdlib/utils/object-inverse/lib/main.js","../node_modules/@stdlib/strided/base/dtype-str2enum/lib/main.js","../node_modules/@stdlib/strided/base/dtype-resolve-str/lib/main.js","../mostly-safe-casts/lib/main.js","../base/assert/is-mostly-safe-data-type-cast/lib/main.js","../base/assert/is-numeric-data-type/lib/main.js","../safe-casts/lib/main.js","../base/assert/is-real-data-type/lib/main.js","../base/assert/is-real-floating-point-data-type/lib/main.js","../base/assert/is-safe-data-type-cast/lib/main.js","../same-kind-casts/lib/main.js","../base/assert/is-same-kind-data-type-cast/lib/main.js","../base/assert/is-signed-integer-data-type/lib/main.js","../base/assert/is-unsigned-integer-data-type/lib/main.js","../base/assert/lib/index.js","../node_modules/@stdlib/math/base/special/fast/max/lib/main.js","../node_modules/@stdlib/math/base/special/fast/min/lib/main.js","../base/filled/lib/main.js","../base/filled2d/lib/main.js","../base/zeros2d/lib/main.js","../base/assert/has-equal-values-indexed/lib/main.js","../base/assert/is-sorted-ascending/lib/main.js","../base/banded/lib/index.js","../base/binarynd/lib/main.js","../base/copy-indexed/lib/main.js","../base/zeros/lib/main.js","../base/broadcast-array/lib/main.js","../node_modules/@stdlib/math/base/assert/is-odd/lib/main.js","../node_modules/@stdlib/math/base/assert/is-infinite/lib/main.js","../base/banded/filled2d-by/lib/main.js","../base/banded/to-compact/lib/main.js","../node_modules/@stdlib/math/base/special/sqrt/lib/main.js","../node_modules/@stdlib/number/float64/base/set-low-word/lib/low.js","../node_modules/@stdlib/number/float64/base/set-low-word/lib/main.js","../node_modules/@stdlib/number/uint32/base/to-int32/lib/main.js","../node_modules/@stdlib/constants/float64/high-word-abs-mask/lib/index.js","../node_modules/@stdlib/number/float64/base/from-words/lib/indices.js","../node_modules/@stdlib/number/float64/base/get-high-word/lib/high.js","../node_modules/@stdlib/number/float64/base/get-high-word/lib/main.js","../node_modules/@stdlib/number/float64/base/from-words/lib/main.js","../node_modules/@stdlib/math/base/special/copysign/lib/main.js","../node_modules/@stdlib/math/base/special/pow/lib/y_is_huge.js","../node_modules/@stdlib/number/float64/base/set-high-word/lib/high.js","../node_modules/@stdlib/number/float64/base/set-high-word/lib/main.js","../node_modules/@stdlib/constants/float64/exponent-bias/lib/index.js","../node_modules/@stdlib/constants/float64/num-high-word-significand-bits/lib/index.js","../node_modules/@stdlib/math/base/special/pow/lib/log2ax.js","../node_modules/@stdlib/math/base/special/pow/lib/logx.js","../node_modules/@stdlib/constants/float64/max-base2-exponent/lib/index.js","../node_modules/@stdlib/constants/float64/max-base2-exponent-subnormal/lib/index.js","../node_modules/@stdlib/constants/float64/min-base2-exponent-subnormal/lib/index.js","../node_modules/@stdlib/constants/float64/smallest-normal/lib/index.js","../node_modules/@stdlib/number/float64/base/normalize/lib/assign.js","../node_modules/@stdlib/number/float64/base/normalize/lib/index.js","../node_modules/@stdlib/number/float64/base/normalize/lib/main.js","../node_modules/@stdlib/constants/float64/high-word-exponent-mask/lib/index.js","../node_modules/@stdlib/math/base/special/ldexp/lib/main.js","../node_modules/@stdlib/number/float64/base/exponent/lib/main.js","../node_modules/@stdlib/constants/float64/ln-two/lib/index.js","../node_modules/@stdlib/constants/float64/high-word-significand-mask/lib/index.js","../node_modules/@stdlib/math/base/special/pow/lib/pow2.js","../node_modules/@stdlib/math/base/special/pow/lib/main.js","../node_modules/@stdlib/math/base/special/pow/lib/y_is_infinite.js","../node_modules/@stdlib/math/base/special/pow/lib/x_is_zero.js","../node_modules/@stdlib/math/base/special/pow/lib/polyval_w.js","../node_modules/@stdlib/math/base/special/pow/lib/polyval_l.js","../node_modules/@stdlib/math/base/special/pow/lib/polyval_p.js","../base/cartesian-power/lib/main.js","../base/cartesian-product/lib/main.js","../base/cartesian-square/lib/main.js","../base/copy/lib/main.js","../node_modules/@stdlib/array/base/assert/is-complex128array/lib/main.js","../node_modules/@stdlib/array/base/assert/is-complex64array/lib/main.js","../node_modules/@stdlib/strided/base/reinterpret-complex/lib/main.js","../base/count-falsy/lib/main.js","../base/zero-to/lib/main.js","../base/zero-to/lib/assign.js","../base/count-ifs/lib/main.js","../node_modules/@stdlib/number/float64/base/assert/is-same-value-zero/lib/main.js","../node_modules/@stdlib/assert/is-same-value-zero/lib/main.js","../node_modules/@stdlib/complex/float64/base/assert/is-same-value-zero/lib/main.js","../base/count-truthy/lib/main.js","../base/cuany/lib/assign.js","../base/cuany/lib/main.js","../base/cuevery/lib/assign.js","../base/cuevery/lib/main.js","../base/cunone/lib/assign.js","../base/cunone/lib/main.js","../node_modules/@stdlib/utils/define-read-write-accessor/lib/main.js","../base/every/lib/main.js","../node_modules/@stdlib/slice/ctor/lib/main.js","../node_modules/@stdlib/assert/is-null/lib/main.js","../node_modules/@stdlib/assert/is-undefined/lib/main.js","../node_modules/@stdlib/slice/base/normalize-slice/lib/main.js","../node_modules/@stdlib/slice/base/normalize-slice/lib/error_out_of_bounds.js","../base/zero-to/lib/index.js","../base/cuany/lib/index.js","../base/cuevery/lib/index.js","../base/cunone/lib/index.js","../node_modules/@stdlib/math/base/special/ceil/lib/main.js","../node_modules/@stdlib/slice/base/length/lib/main.js","../node_modules/@stdlib/array/base/assert/is-accessor-array/lib/main.js","../node_modules/@stdlib/array/base/getter/lib/main.js","../node_modules/@stdlib/array/base/setter/lib/main.js","../node_modules/@stdlib/array/base/accessor-getter/lib/main.js","../node_modules/@stdlib/array/base/accessor-setter/lib/main.js","../node_modules/@stdlib/array/dtype/lib/ctor2dtype.js","../node_modules/@stdlib/array/int32/lib/main.js","../node_modules/@stdlib/array/int32/lib/index.js","../node_modules/@stdlib/array/int32/lib/polyfill.js","../node_modules/@stdlib/array/int16/lib/main.js","../node_modules/@stdlib/array/int16/lib/index.js","../node_modules/@stdlib/array/int16/lib/polyfill.js","../node_modules/@stdlib/array/uint8c/lib/main.js","../node_modules/@stdlib/array/uint8c/lib/index.js","../node_modules/@stdlib/array/uint8c/lib/polyfill.js","../node_modules/@stdlib/array/int8/lib/main.js","../node_modules/@stdlib/array/int8/lib/index.js","../node_modules/@stdlib/array/int8/lib/polyfill.js","../node_modules/@stdlib/array/complex64/lib/from_iterator.js","../node_modules/@stdlib/array/complex64/lib/main.js","../node_modules/@stdlib/array/complex64/lib/from_array.js","../node_modules/@stdlib/array/complex128/lib/from_iterator.js","../node_modules/@stdlib/array/complex64/lib/from_iterator_map.js","../node_modules/@stdlib/array/complex128/lib/main.js","../node_modules/@stdlib/array/complex128/lib/from_array.js","../node_modules/@stdlib/array/bool/lib/from_iterator.js","../node_modules/@stdlib/array/complex128/lib/from_iterator_map.js","../node_modules/@stdlib/array/bool/lib/main.js","../node_modules/@stdlib/array/bool/lib/from_array.js","../node_modules/@stdlib/array/bool/lib/from_iterator_map.js","../node_modules/@stdlib/array/dtype/lib/ctors.js","../node_modules/@stdlib/array/dtype/lib/dtypes.js","../node_modules/@stdlib/array/dtype/lib/main.js","../node_modules/@stdlib/array/base/arraylike2object/lib/main.js","../node_modules/@stdlib/blas/base/gcopy/lib/accessors.js","../node_modules/@stdlib/blas/base/gcopy/lib/main.js","../node_modules/@stdlib/blas/base/gcopy/lib/ndarray.js","../base/fancy-slice/lib/main.js","../node_modules/@stdlib/blas/base/gcopy/lib/index.js","../ctors/lib/ctors.js","../ctors/lib/main.js","../convert/lib/main.js","../base/fancy-slice-assign/lib/main.js","../base/filled-by/lib/main.js","../base/filled3d/lib/main.js","../base/filled4d/lib/main.js","../base/filled5d/lib/main.js","../base/fillednd/lib/main.js","../base/fillednd-by/lib/main.js","../node_modules/@stdlib/ndarray/base/numel/lib/main.js","../node_modules/@stdlib/ndarray/base/assert/is-column-major-string/lib/main.js","../node_modules/@stdlib/ndarray/base/shape2strides/lib/main.js","../node_modules/@stdlib/ndarray/base/vind2bind/lib/main.js","../node_modules/@stdlib/strided/base/stride2offset/lib/main.js","../node_modules/@stdlib/ndarray/base/shape2strides/lib/index.js","../node_modules/@stdlib/ndarray/base/shape2strides/lib/assign.js","../node_modules/@stdlib/blas/ext/base/grev/lib/ndarray.js","../node_modules/@stdlib/blas/ext/base/grev/lib/accessors.js","../node_modules/@stdlib/blas/ext/base/grev/lib/main.js","../node_modules/@stdlib/blas/ext/base/grev/lib/index.js","../base/flatten/lib/assign.js","../base/flatten/lib/main.js","../base/flatten/lib/index.js","../base/flatten-by/lib/assign.js","../base/flatten-by/lib/main.js","../base/flatten2d/lib/main.js","../base/flatten2d-by/lib/main.js","../base/flatten3d/lib/main.js","../base/flatten3d-by/lib/main.js","../base/flatten4d/lib/main.js","../base/flatten4d-by/lib/main.js","../base/flatten5d/lib/main.js","../base/flatten5d-by/lib/main.js","../base/fliplr2d/lib/main.js","../base/fliplr3d/lib/main.js","../base/fliplr4d/lib/main.js","../base/flipud2d/lib/main.js","../base/flipud3d/lib/main.js","../base/flipud4d/lib/main.js","../base/incrspace/lib/main.js","../node_modules/@stdlib/assert/is-accessor-array/lib/main.js","../node_modules/@stdlib/assert/is-undefined-or-null/lib/main.js","../base/logspace/lib/main.js","../base/map2d/lib/main.js","../base/map3d/lib/main.js","../base/map4d/lib/main.js","../base/map5d/lib/main.js","../base/min-signed-integer-dtype/lib/main.js","../base/mskfilter/lib/main.js","../base/mskfilter-map/lib/main.js","../base/mskput/lib/main.js","../base/mskreject/lib/main.js","../node_modules/@stdlib/utils/define-nonenumerable-property/lib/main.js","../base/none/lib/main.js","../base/one-to/lib/main.js","../base/one-to/lib/assign.js","../base/place/lib/main.js","../node_modules/@stdlib/ndarray/base/clamp-index/lib/main.js","../node_modules/@stdlib/ndarray/base/wrap-index/lib/main.js","../node_modules/@stdlib/ndarray/base/normalize-index/lib/main.js","../node_modules/@stdlib/array/base/assert/contains/lib/factory.js","../base/flatten-by/lib/index.js","../base/flatten2d/lib/index.js","../base/flatten2d/lib/assign.js","../base/flatten2d-by/lib/index.js","../base/flatten2d-by/lib/assign.js","../base/flatten3d/lib/index.js","../base/flatten3d/lib/assign.js","../base/flatten3d-by/lib/index.js","../base/flatten3d-by/lib/assign.js","../base/flatten4d/lib/index.js","../base/flatten4d/lib/assign.js","../base/flatten4d-by/lib/index.js","../base/flatten4d-by/lib/assign.js","../base/flatten5d/lib/index.js","../base/flatten5d/lib/assign.js","../base/flatten5d-by/lib/index.js","../base/flatten5d-by/lib/assign.js","../base/map2d/lib/index.js","../base/map2d/lib/assign.js","../base/map3d/lib/index.js","../base/map3d/lib/assign.js","../base/map4d/lib/index.js","../base/map4d/lib/assign.js","../base/map5d/lib/index.js","../base/map5d/lib/assign.js","../base/mskfilter/lib/index.js","../base/mskfilter/lib/assign.js","../base/mskfilter-map/lib/index.js","../base/mskfilter-map/lib/assign.js","../base/mskreject/lib/index.js","../base/mskreject/lib/assign.js","../base/one-to/lib/index.js","../node_modules/@stdlib/array/base/assert/contains/lib/index.js","../node_modules/@stdlib/array/base/assert/contains/lib/main.js","../node_modules/@stdlib/ndarray/index-modes/lib/main.js","../node_modules/@stdlib/ndarray/index-modes/lib/index.js","../node_modules/@stdlib/ndarray/index-modes/lib/enum.js","../node_modules/@stdlib/ndarray/base/assert/is-index-mode/lib/main.js","../node_modules/@stdlib/ndarray/base/ind/lib/factory.js","../base/put/lib/main.js","../node_modules/@stdlib/ndarray/base/ind/lib/index.js","../node_modules/@stdlib/ndarray/base/ind/lib/main.js","../base/slice/lib/main.js","../base/reshape/lib/main.js","../base/resolve-setter/lib/main.js","../base/symmetric/lib/index.js","../base/symmetric/filled2d-by/lib/main.js","../base/symmetric-banded/lib/index.js","../base/take/lib/main.js","../base/symmetric-banded/filled2d-by/lib/main.js","../base/symmetric-banded/to-compact/lib/main.js","../base/take/lib/index.js","../base/take/lib/assign.js","../base/take2d/lib/main.js","../base/unarynd/lib/main.js","../node_modules/@stdlib/math/base/assert/is-positive-zero/lib/main.js","../base/where/lib/resolve_stride.js","../base/where/lib/main.js","../node_modules/@stdlib/math/base/special/maxn/lib/main.js","../base/where/lib/assign.js","../base/where/lib/numel.js","../base/with/lib/main.js","../base/with/lib/assign.js","../defaults/lib/main.js","../base/where/lib/index.js","../base/with/lib/index.js","../defaults/lib/get.js","../defaults/lib/index.js","../zeros/lib/main.js","../base/without/lib/assign.js","../base/without/lib/main.js","../base/without/lib/index.js","../base/lib/index.js","../base/any-by/lib/main.js","../base/any-by-right/lib/main.js","../base/any-has-own-property/lib/main.js","../base/any-has-property/lib/main.js","../base/any-is-entry/lib/main.js","../base/any-is-entry-in/lib/main.js","../base/at/lib/main.js","../base/at2d/lib/main.js","../base/at3d/lib/main.js","../base/at4d/lib/main.js","../base/at5d/lib/main.js","../base/atnd/lib/main.js","../base/bifurcate-entries/lib/main.js","../base/bifurcate-entries-by/lib/main.js","../base/bifurcate-indices/lib/main.js","../base/bifurcate-indices-by/lib/main.js","../base/bifurcate-values/lib/main.js","../base/bifurcate-values-by/lib/main.js","../base/binary2d/lib/main.js","../base/binary3d/lib/main.js","../base/binary4d/lib/main.js","../base/binary5d/lib/main.js","../base/broadcasted-binary2d/lib/main.js","../base/broadcasted-binary3d/lib/main.js","../base/broadcasted-binary4d/lib/main.js","../base/broadcasted-binary5d/lib/main.js","../base/broadcasted-quaternary2d/lib/main.js","../base/broadcasted-quaternary3d/lib/main.js","../base/broadcasted-quaternary4d/lib/main.js","../base/broadcasted-quaternary5d/lib/main.js","../base/broadcasted-quinary2d/lib/main.js","../base/broadcasted-quinary4d/lib/main.js","../base/broadcasted-ternary2d/lib/main.js","../base/broadcasted-ternary3d/lib/main.js","../base/broadcasted-ternary4d/lib/main.js","../base/broadcasted-ternary5d/lib/main.js","../base/broadcasted-unary2d/lib/main.js","../base/broadcasted-unary3d/lib/main.js","../base/broadcasted-unary4d/lib/main.js","../base/broadcasted-unary5d/lib/main.js","../base/count-if/lib/main.js","../base/count-same-value/lib/main.js","../base/count-same-value-zero/lib/main.js","../base/dedupe/lib/main.js","../base/entries2objects/lib/main.js","../base/entries2views/lib/main.js","../node_modules/@stdlib/utils/define-read-only-accessor/lib/main.js","../base/every-by/lib/main.js","../base/every-by-right/lib/main.js","../base/fill/lib/main.js","../base/fill-by/lib/main.js","../base/filled2d-by/lib/main.js","../base/filled3d-by/lib/main.js","../base/filled4d-by/lib/main.js","../base/filled5d-by/lib/main.js","../base/filter/lib/main.js","../base/first/lib/main.js","../base/fliplr5d/lib/main.js","../base/flipud5d/lib/main.js","../base/from-strided/lib/main.js","../base/group-entries/lib/main.js","../base/group-entries-by/lib/main.js","../base/group-indices/lib/main.js","../base/group-indices-by/lib/main.js","../base/group-values/lib/main.js","../base/group-values-by/lib/main.js","../base/group-values-on-key/lib/main.js","../base/index-of/lib/main.js","../base/index-of-same-value/lib/main.js","../base/indices-complement/lib/main.js","../base/join/lib/main.js","../base/last/lib/main.js","../base/last-index-of/lib/main.js","../base/last-index-of-same-value/lib/main.js","../base/linspace/lib/main.js","../base/linspace2d/lib/main.js","../base/min-unsigned-integer-dtype/lib/main.js","../base/mskbinary2d/lib/main.js","../base/mskbinary3d/lib/main.js","../base/mskbinary4d/lib/main.js","../base/mskbinary5d/lib/main.js","../base/mskfilter2/lib/main.js","../base/mskfiltern/lib/main.js","../base/mskunary2d/lib/main.js","../base/mskunary3d/lib/main.js","../base/mskunary4d/lib/main.js","../base/mskunary5d/lib/main.js","../base/n-cartesian-product/lib/main.js","../base/nested2objects/lib/main.js","../base/nested2views/lib/main.js","../base/none-by/lib/main.js","../base/none-by-right/lib/main.js","../base/nulls/lib/main.js","../base/ones/lib/main.js","../base/ones2d/lib/main.js","../base/ones3d/lib/main.js","../base/ones4d/lib/main.js","../base/ones5d/lib/main.js","../base/onesnd/lib/main.js","../base/quaternary2d/lib/main.js","../base/quaternary3d/lib/main.js","../base/quaternary4d/lib/main.js","../base/quaternary5d/lib/main.js","../base/quinary2d/lib/main.js","../base/quinary3d/lib/main.js","../base/quinary4d/lib/main.js","../base/quinary5d/lib/main.js","../base/reject/lib/main.js","../base/rekey/lib/main.js","../base/rekey-views/lib/main.js","../base/remove-at/lib/main.js","../base/reverse/lib/main.js","../base/scatter-filled/lib/main.js","../base/scattered/lib/main.js","../base/strided2array2d/lib/main.js","../base/strided2array3d/lib/main.js","../base/strided2array4d/lib/main.js","../base/strided2array5d/lib/main.js","../base/take-indexed/lib/main.js","../base/take-indexed2/lib/main.js","../base/take3d/lib/main.js","../base/ternary2d/lib/main.js","../base/ternary3d/lib/main.js","../base/ternary4d/lib/main.js","../base/ternary5d/lib/main.js","../base/to-accessor-array/lib/main.js","../base/to-deduped/lib/main.js","../base/to-reversed/lib/main.js","../base/unary2d/lib/main.js","../base/unary2d-by/lib/main.js","../base/unary3d/lib/main.js","../base/unary3d-by/lib/main.js","../base/unary4d/lib/main.js","../base/unary4d-by/lib/main.js","../base/unary5d/lib/main.js","../base/unary5d-by/lib/main.js","../base/unitspace/lib/main.js","../base/zeros3d/lib/main.js","../base/zeros4d/lib/main.js","../base/zeros5d/lib/main.js","../base/zerosnd/lib/main.js","../base/zip/lib/main.js","../base/zip2object/lib/main.js","../base/zip2objects/lib/main.js","../base/zip2views/lib/main.js","../node_modules/@stdlib/assert/has-arraybuffer-support/lib/arraybuffer.js","../node_modules/@stdlib/assert/has-arraybuffer-support/lib/main.js","../buffer/lib/main.js","../dataview/lib/index.js","../buffer/lib/index.js","../buffer/lib/polyfill.js","../node_modules/@stdlib/assert/is-dataview/lib/main.js","../node_modules/@stdlib/array/buffer/lib/main.js","../node_modules/@stdlib/array/buffer/lib/index.js","../node_modules/@stdlib/array/buffer/lib/polyfill.js","../node_modules/@stdlib/assert/has-dataview-support/lib/dataview.js","../dataview/lib/main.js","../node_modules/@stdlib/assert/has-dataview-support/lib/main.js","../dataview/lib/polyfill.js","../node_modules/@stdlib/math/base/special/round/lib/main.js","../datespace/lib/main.js","../empty/lib/polyfill.js","../node_modules/@stdlib/blas/ext/base/gfill/lib/ndarray.js","../node_modules/@stdlib/blas/ext/base/gfill/lib/accessors.js","../node_modules/@stdlib/blas/ext/base/gfill/lib/main.js","../node_modules/@stdlib/assert/is-iterator-like/lib/main.js","../node_modules/@stdlib/iter/length/lib/main.js","../node_modules/@stdlib/blas/ext/base/gfill/lib/index.js","../filled/lib/main.js","../node_modules/@stdlib/blas/ext/base/gfill-by/lib/ndarray.js","../node_modules/@stdlib/blas/ext/base/gfill-by/lib/accessors.js","../node_modules/@stdlib/blas/ext/base/gfill-by/lib/main.js","../node_modules/@stdlib/blas/ext/base/gfill-by/lib/index.js","../filled-by/lib/main.js","../node_modules/@stdlib/assert/is-prototype-of/lib/main.js","../node_modules/@stdlib/ndarray/base/bytes-per-element/lib/main.js","../node_modules/@stdlib/string/base/capitalize/lib/main.js","../fixed-endian-factory/lib/from_iterator.js","../fixed-endian-factory/lib/main.js","../node_modules/@stdlib/string/base/lowercase/lib/main.js","../fixed-endian-factory/lib/from_iterator_map.js","../fixed-endian-float32/lib/main.js","../fixed-endian-float64/lib/main.js","../node_modules/@stdlib/complex/dtype/lib/ctor2dtype.js","../node_modules/@stdlib/complex/ctors/lib/ctors.js","../node_modules/@stdlib/complex/ctors/lib/main.js","../node_modules/@stdlib/complex/dtype/lib/dtypes.js","../node_modules/@stdlib/complex/dtype/lib/ctors.js","../node_modules/@stdlib/complex/dtypes/lib/main.js","../node_modules/@stdlib/complex/dtype/lib/main.js","../from-scalar/lib/main.js","../full/lib/main.js","../node_modules/@stdlib/assert/has-function-name-support/lib/foo.js","../node_modules/@stdlib/utils/function-name/lib/main.js","../node_modules/@stdlib/assert/has-function-name-support/lib/main.js","../node_modules/@stdlib/assert/is-typed-array/lib/ctors.js","../node_modules/@stdlib/assert/is-typed-array/lib/main.js","../node_modules/@stdlib/assert/is-complex-typed-array/lib/ctors.js","../node_modules/@stdlib/assert/is-booleanarray/lib/main.js","../node_modules/@stdlib/assert/instance-of/lib/main.js","../to-json/lib/ctors.js","../to-json/lib/type.js","../to-json/lib/main.js","../node_modules/@stdlib/assert/is-complex-typed-array/lib/main.js","../node_modules/@stdlib/dstructs/linked-list/lib/node.js","../node_modules/@stdlib/dstructs/linked-list/lib/main.js","../index/lib/cache.js","../index/lib/find.js","../index/lib/id.js","../index/lib/main.js","../index/lib/defaults.js","../index/lib/validate.js","../typed-float-ctors/lib/ctors.js","../typed-float-ctors/lib/main.js","../linspace/lib/typed_real.js","../linspace/lib/typed_complex.js","../linspace/lib/validate.js","../linspace/lib/main.js","../linspace/lib/generic_complex.js","../linspace/lib/generic_real.js","../node_modules/@stdlib/utils/inherit/lib/validate.js","../linspace/lib/index.js","../linspace/lib/assign.js","../linspace/lib/accessors_complex.js","../linspace/lib/accessors_real.js","../node_modules/@stdlib/utils/inherit/lib/native.js","../node_modules/@stdlib/utils/inherit/lib/polyfill.js","../node_modules/@stdlib/utils/inherit/lib/detect.js","../little-endian-factory/lib/main.js","../little-endian-factory/lib/from_iterator_map.js","../little-endian-factory/lib/from_iterator.js","../node_modules/@stdlib/utils/inherit/lib/main.js","../little-endian-float32/lib/main.js","../little-endian-float64/lib/main.js","../node_modules/@stdlib/math/base/assert/is-negative-zero/lib/main.js","../node_modules/@stdlib/constants/float32/smallest-subnormal/lib/index.js","../node_modules/@stdlib/constants/float32/max-safe-integer/lib/index.js","../node_modules/@stdlib/constants/float32/min-safe-integer/lib/index.js","../min-dtype/lib/main.js","../mskfilter/lib/main.js","../mskput/lib/validate.js","../mskreject/lib/main.js","../nans/lib/main.js","../nans-like/lib/main.js","../one-to/lib/main.js","../ones/lib/main.js","../ones-like/lib/main.js","../place/lib/validate.js","../place/lib/main.js","../place/lib/defaults.js","../typed-ctors/lib/ctors.js","../typed-ctors/lib/main.js","../node_modules/@stdlib/math/base/special/log2/lib/main.js","../node_modules/@stdlib/math/base/special/kernel-log1p/lib/main.js","../node_modules/@stdlib/math/base/special/kernel-log1p/lib/polyval_p.js","../node_modules/@stdlib/math/base/special/kernel-log1p/lib/polyval_q.js","../pool/lib/factory.js","../pool/lib/defaults.js","../pool/lib/validate.js","../pool/lib/pool.js","../node_modules/@stdlib/assert/is-typed-array-like/lib/main.js","../node_modules/@stdlib/math/base/special/min/lib/main.js","../node_modules/@stdlib/math/base/special/ceil2/lib/main.js","../node_modules/@stdlib/assert/is-complex128array/lib/main.js","../node_modules/@stdlib/assert/is-complex64array/lib/main.js","../pool/lib/main.js","../pool/lib/index.js","../put/lib/main.js","../put/lib/defaults.js","../put/lib/validate.js","../reviver/lib/ctors.js","../shape/lib/main.js","../node_modules/@stdlib/assert/is-sharedarraybuffer/lib/main.js","../node_modules/@stdlib/assert/has-sharedarraybuffer-support/lib/sharedarraybuffer.js","../shared-buffer/lib/index.js","../shared-buffer/lib/main.js","../node_modules/@stdlib/assert/has-sharedarraybuffer-support/lib/main.js","../shared-buffer/lib/polyfill.js","../take/lib/main.js","../take/lib/defaults.js","../take/lib/validate.js","../node_modules/@stdlib/utils/eval/lib/index.js","../node_modules/@stdlib/proxy/ctor/lib/index.js","../node_modules/@stdlib/proxy/ctor/lib/main.js","../node_modules/@stdlib/assert/has-proxy-support/lib/main.js","../node_modules/@stdlib/proxy/ctor/lib/polyfill.js","../node_modules/@stdlib/object/assign/lib/index.js","../node_modules/@stdlib/object/assign/lib/has_object_assign.js","../node_modules/@stdlib/object/assign/lib/builtin.js","../node_modules/@stdlib/utils/property-symbols/lib/has_builtin.js","../node_modules/@stdlib/utils/property-symbols/lib/builtin.js","../node_modules/@stdlib/utils/property-symbols/lib/index.js","../node_modules/@stdlib/utils/property-symbols/lib/polyfill.js","../node_modules/@stdlib/utils/enumerable-properties/lib/main.js","../node_modules/@stdlib/object/assign/lib/polyfill.js","../to-fancy/lib/set_element_wrapper.js","../to-fancy/lib/get_array_wrapper.js","../to-fancy/lib/has_proxy_support.js","../to-fancy/lib/validate.js","../node_modules/@stdlib/assert/is-method-in/lib/main.js","../to-fancy/lib/validator.js","../to-fancy/lib/ctor.js","../to-fancy/lib/re_integer.js","../to-fancy/lib/is_integer_string.js","../to-fancy/lib/re_array_index.js","../to-fancy/lib/is_array_index_string.js","../node_modules/@stdlib/string/base/trim/lib/has_builtin.js","../node_modules/@stdlib/string/base/trim/lib/builtin.js","../node_modules/@stdlib/string/base/trim/lib/polyfill.js","../node_modules/@stdlib/string/base/trim/lib/index.js","../node_modules/@stdlib/string/base/trim/lib/check.js","../node_modules/@stdlib/string/base/trim/lib/main.js","../to-fancy/lib/prop2array.js","../to-fancy/lib/resolve_index.js","../to-fancy/lib/error_message.js","../node_modules/@stdlib/slice/base/seq2slice/lib/re_end_minus.js","../node_modules/@stdlib/slice/base/seq2slice/lib/re_end_divide.js","../node_modules/@stdlib/slice/base/seq2slice/lib/resolve_end.js","../node_modules/@stdlib/slice/base/seq2slice/lib/re_colon_sep.js","../node_modules/@stdlib/slice/base/seq2slice/lib/re_integer.js","../node_modules/@stdlib/slice/base/seq2slice/lib/re_end.js","../node_modules/@stdlib/slice/base/seq2slice/lib/main.js","../node_modules/@stdlib/slice/base/seq2slice/lib/error_invalid_subsequence.js","../node_modules/@stdlib/slice/base/seq2slice/lib/error_invalid_increment.js","../node_modules/@stdlib/slice/base/seq2slice/lib/error_out_of_bounds.js","../node_modules/@stdlib/slice/base/str2slice/lib/main.js","../node_modules/@stdlib/string/base/starts-with/lib/index.js","../node_modules/@stdlib/string/base/starts-with/lib/has_builtin.js","../node_modules/@stdlib/string/base/starts-with/lib/builtin.js","../node_modules/@stdlib/string/base/starts-with/lib/main.js","../node_modules/@stdlib/string/base/starts-with/lib/polyfill.js","../to-fancy/lib/re_subseq.js","../to-fancy/lib/prop2slice.js","../to-fancy/lib/get.js","../to-fancy/lib/get_element.js","../to-fancy/lib/get_value.js","../to-fancy/lib/get_elements.js","../to-fancy/lib/get_slice.js","../to-fancy/lib/set_value.js","../to-fancy/lib/set.js","../to-fancy/lib/set_element.js","../to-fancy/lib/set_elements.js","../to-fancy/lib/set_slice.js","../to-fancy/lib/factory.js","../to-fancy/lib/defaults.js","../node_modules/@stdlib/assert/is-array-like/lib/main.js","../to-fancy/lib/main.js","../to-fancy/lib/index.js","../typed/lib/main.js","../typed-complex-ctors/lib/ctors.js","../typed-complex-ctors/lib/main.js","../typed-complex/lib/main.js","../typed-integer-ctors/lib/ctors.js","../typed-real/lib/main.js","../typed-real-ctors/lib/ctors.js","../typed-real-float-ctors/lib/ctors.js","../typed-signed-integer-ctors/lib/ctors.js","../typed-unsigned-integer-ctors/lib/ctors.js","../zero-to/lib/main.js","../node_modules/@stdlib/constants/array/lib/index.js","../lib/index.js","../cartesian-power/lib/main.js","../cartesian-product/lib/main.js","../cartesian-square/lib/main.js","../convert-same/lib/main.js","../empty-like/lib/main.js","../from-iterator/lib/main.js","../full-like/lib/main.js","../incrspace/lib/main.js","../logspace/lib/main.js","../mskput/lib/main.js","../mskput/lib/defaults.js","../next-dtype/lib/main.js","../one-to-like/lib/main.js","../promotion-rules/lib/main.js","../reviver/lib/main.js","../slice/lib/main.js","../to-circular-iterator/lib/main.js","../to-iterator/lib/main.js","../to-iterator-right/lib/main.js","../to-sparse-iterator/lib/main.js","../to-sparse-iterator-right/lib/main.js","../to-strided-iterator/lib/main.js","../to-view-iterator/lib/main.js","../to-view-iterator-right/lib/main.js","../typed-complex-dtypes/lib/main.js","../typed-dtypes/lib/main.js","../typed-float-dtypes/lib/main.js","../typed-integer-ctors/lib/main.js","../typed-integer-dtypes/lib/main.js","../typed-real-ctors/lib/main.js","../typed-real-dtypes/lib/main.js","../typed-real-float-ctors/lib/main.js","../typed-real-float-dtypes/lib/main.js","../typed-signed-integer-ctors/lib/main.js","../typed-signed-integer-dtypes/lib/main.js","../typed-unsigned-integer-ctors/lib/main.js","../typed-unsigned-integer-dtypes/lib/main.js","../zero-to-like/lib/main.js","../zeros-like/lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Object.defineProperty === 'function' ) ? Object.defineProperty : null;\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Defines (or modifies) an object property.\n*\n* ## Notes\n*\n* - Property descriptors come in two flavors: **data descriptors** and **accessor descriptors**. A data descriptor is a property that has a value, which may or may not be writable. An accessor descriptor is a property described by a getter-setter function pair. A descriptor must be one of these two flavors and cannot be both.\n*\n* @name defineProperty\n* @type {Function}\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Object} descriptor - property descriptor\n* @param {boolean} [descriptor.configurable=false] - boolean indicating if property descriptor can be changed and if the property can be deleted from the provided object\n* @param {boolean} [descriptor.enumerable=false] - boolean indicating if the property shows up when enumerating object properties\n* @param {boolean} [descriptor.writable=false] - boolean indicating if the value associated with the property can be changed with an assignment operator\n* @param {*} [descriptor.value] - property value\n* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the property value.\n* @param {(Function|void)} [descriptor.set=undefined] - function which serves as a setter for the property, or, if no setter, undefined. When assigning a property value, a setter function is called with one argument (the value being assigned to the property) and with the `this` context set to the object through which the property is assigned.\n* @throws {TypeError} first argument must be an object\n* @throws {TypeError} third argument must be an object\n* @throws {Error} property descriptor cannot have both a value and a setter and/or getter\n* @returns {Object} object with added property\n*\n* @example\n* var obj = {};\n*\n* defineProperty( obj, 'foo', {\n* 'value': 'bar'\n* });\n*\n* var str = obj.foo;\n* // returns 'bar'\n*/\nvar defineProperty = Object.defineProperty;\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a number primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* @example\n* var bool = isNumber( NaN );\n* // returns true\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns false\n*/\nfunction isNumber( value ) {\n\treturn ( typeof value === 'number' ); // NOTE: we inline the `isNumber.isPrimitive` function from `@stdlib/assert/is-number` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Tests if a string starts with a minus sign (`-`).\n*\n* @private\n* @param {string} str - input string\n* @returns {boolean} boolean indicating if a string starts with a minus sign (`-`)\n*/\nfunction startsWithMinus( str ) {\n\treturn str[ 0 ] === '-';\n}\n\n/**\n* Returns a string of `n` zeros.\n*\n* @private\n* @param {number} n - number of zeros\n* @returns {string} string of zeros\n*/\nfunction zeros( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += '0';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with zeros to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction zeroPad( str, width, right ) {\n\tvar negative = false;\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tif ( startsWithMinus( str ) ) {\n\t\tnegative = true;\n\t\tstr = str.substr( 1 );\n\t}\n\tstr = ( right ) ?\n\t\tstr + zeros( pad ) :\n\t\tzeros( pad ) + str;\n\tif ( negative ) {\n\t\tstr = '-' + str;\n\t}\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default zeroPad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isNumber from './is_number.js';\nimport zeroPad from './zero_pad.js';\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as an integer.\n*\n* @private\n* @param {Object} token - token object\n* @throws {Error} must provide a valid integer\n* @returns {string} formatted token argument\n*/\nfunction formatInteger( token ) {\n\tvar base;\n\tvar out;\n\tvar i;\n\n\tswitch ( token.specifier ) {\n\tcase 'b':\n\t\t// Case: %b (binary)\n\t\tbase = 2;\n\t\tbreak;\n\tcase 'o':\n\t\t// Case: %o (octal)\n\t\tbase = 8;\n\t\tbreak;\n\tcase 'x':\n\tcase 'X':\n\t\t// Case: %x, %X (hexadecimal)\n\t\tbase = 16;\n\t\tbreak;\n\tcase 'd':\n\tcase 'i':\n\tcase 'u':\n\tdefault:\n\t\t// Case: %d, %i, %u (decimal)\n\t\tbase = 10;\n\t\tbreak;\n\t}\n\tout = token.arg;\n\ti = parseInt( out, 10 );\n\tif ( !isFinite( i ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\tif ( !isNumber( out ) ) {\n\t\t\tthrow new Error( 'invalid integer. Value: ' + out );\n\t\t}\n\t\ti = 0;\n\t}\n\tif ( i < 0 && ( token.specifier === 'u' || base !== 10 ) ) {\n\t\ti = 0xffffffff + i + 1;\n\t}\n\tif ( i < 0 ) {\n\t\tout = ( -i ).toString( base );\n\t\tif ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tout = '-' + out;\n\t} else {\n\t\tout = i.toString( base );\n\t\tif ( !i && !token.precision ) {\n\t\t\tout = '';\n\t\t} else if ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tif ( token.sign ) {\n\t\t\tout = token.sign + out;\n\t\t}\n\t}\n\tif ( base === 16 ) {\n\t\tif ( token.alternate ) {\n\t\t\tout = '0x' + out;\n\t\t}\n\t\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\t\tuppercase.call( out ) :\n\t\t\tlowercase.call( out );\n\t}\n\tif ( base === 8 ) {\n\t\tif ( token.alternate && out.charAt( 0 ) !== '0' ) {\n\t\t\tout = '0' + out;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar abs = Math.abs; // eslint-disable-line stdlib/no-builtin-math\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\nvar replace = String.prototype.replace;\n\n\n// VARIABLES //\n\nvar RE_EXP_POS_DIGITS = /e\\+(\\d)$/;\nvar RE_EXP_NEG_DIGITS = /e-(\\d)$/;\nvar RE_ONLY_DIGITS = /^(\\d+)$/;\nvar RE_DIGITS_BEFORE_EXP = /^(\\d+)e/;\nvar RE_TRAILING_PERIOD_ZERO = /\\.0$/;\nvar RE_PERIOD_ZERO_EXP = /\\.0*e/;\nvar RE_ZERO_BEFORE_EXP = /(\\..*[^0])0*e/;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as a floating-point number.\n*\n* @private\n* @param {number} f - parsed number\n* @param {Object} token - token object\n* @throws {Error} must provide a valid floating-point number\n* @returns {string} formatted token argument\n*/\nfunction formatDouble( f, token ) {\n\tvar digits;\n\tvar out;\n\n\tswitch ( token.specifier ) {\n\tcase 'e':\n\tcase 'E':\n\t\tout = f.toExponential( token.precision );\n\t\tbreak;\n\tcase 'f':\n\tcase 'F':\n\t\tout = f.toFixed( token.precision );\n\t\tbreak;\n\tcase 'g':\n\tcase 'G':\n\t\tif ( abs( f ) < 0.0001 ) {\n\t\t\tdigits = token.precision;\n\t\t\tif ( digits > 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport isNumber from './is_number.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar f;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\tf = parseFloat( token.arg );\n\t\t\t\tif ( !isFinite( f ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\t\t\t\tif ( !isNumber( token.arg ) ) {\n\t\t\t\t\t\tthrow new Error( 'invalid floating-point number. Value: ' + out );\n\t\t\t\t\t}\n\t\t\t\t\t// Case: NaN, Infinity, or -Infinity\n\t\t\t\t\tf = token.arg;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( f, token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\t// Check for an escaped percent sign `%%`...\n\t\tif ( match[ 6 ] === '%' ) {\n\t\t\ttokens.push( '%' );\n\t\t} else {\n\t\t\ttokens.push( parse( match ) );\n\t\t}\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport interpolate from './../../base/format-interpolate';\nimport tokenize from './../../base/format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-underscore-dangle, no-proto */\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar objectProtoype = Object.prototype;\nvar toStr = objectProtoype.toString;\nvar defineGetter = objectProtoype.__defineGetter__;\nvar defineSetter = objectProtoype.__defineSetter__;\nvar lookupGetter = objectProtoype.__lookupGetter__;\nvar lookupSetter = objectProtoype.__lookupSetter__;\n\n\n// MAIN //\n\n/**\n* Defines (or modifies) an object property.\n*\n* ## Notes\n*\n* - Property descriptors come in two flavors: **data descriptors** and **accessor descriptors**. A data descriptor is a property that has a value, which may or may not be writable. An accessor descriptor is a property described by a getter-setter function pair. A descriptor must be one of these two flavors and cannot be both.\n*\n* @param {Object} obj - object on which to define the property\n* @param {string} prop - property name\n* @param {Object} descriptor - property descriptor\n* @param {boolean} [descriptor.configurable=false] - boolean indicating if property descriptor can be changed and if the property can be deleted from the provided object\n* @param {boolean} [descriptor.enumerable=false] - boolean indicating if the property shows up when enumerating object properties\n* @param {boolean} [descriptor.writable=false] - boolean indicating if the value associated with the property can be changed with an assignment operator\n* @param {*} [descriptor.value] - property value\n* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the property value.\n* @param {(Function|void)} [descriptor.set=undefined] - function which serves as a setter for the property, or, if no setter, undefined. When assigning a property value, a setter function is called with one argument (the value being assigned to the property) and with the `this` context set to the object through which the property is assigned.\n* @throws {TypeError} first argument must be an object\n* @throws {TypeError} third argument must be an object\n* @throws {Error} property descriptor cannot have both a value and a setter and/or getter\n* @returns {Object} object with added property\n*\n* @example\n* var obj = {};\n*\n* defineProperty( obj, 'foo', {\n* 'value': 'bar'\n* });\n*\n* var str = obj.foo;\n* // returns 'bar'\n*/\nfunction defineProperty( obj, prop, descriptor ) {\n\tvar prototype;\n\tvar hasValue;\n\tvar hasGet;\n\tvar hasSet;\n\n\tif ( typeof obj !== 'object' || obj === null || toStr.call( obj ) === '[object Array]' ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) );\n\t}\n\tif ( typeof descriptor !== 'object' || descriptor === null || toStr.call( descriptor ) === '[object Array]' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Property descriptor must be an object. Value: `%s`.', descriptor ) );\n\t}\n\thasValue = ( 'value' in descriptor );\n\tif ( hasValue ) {\n\t\tif (\n\t\t\tlookupGetter.call( obj, prop ) ||\n\t\t\tlookupSetter.call( obj, prop )\n\t\t) {\n\t\t\t// Override `__proto__` to avoid touching inherited accessors:\n\t\t\tprototype = obj.__proto__;\n\t\t\tobj.__proto__ = objectProtoype;\n\n\t\t\t// Delete property as existing getters/setters prevent assigning value to specified property:\n\t\t\tdelete obj[ prop ];\n\t\t\tobj[ prop ] = descriptor.value;\n\n\t\t\t// Restore original prototype:\n\t\t\tobj.__proto__ = prototype;\n\t\t} else {\n\t\t\tobj[ prop ] = descriptor.value;\n\t\t}\n\t}\n\thasGet = ( 'get' in descriptor );\n\thasSet = ( 'set' in descriptor );\n\n\tif ( hasValue && ( hasGet || hasSet ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot specify one or more accessors and a value or writable attribute in the property descriptor.' );\n\t}\n\n\tif ( hasGet && defineGetter ) {\n\t\tdefineGetter.call( obj, prop, descriptor.get );\n\t}\n\tif ( hasSet && defineSetter ) {\n\t\tdefineSetter.call( obj, prop, descriptor.set );\n\t}\n\treturn obj;\n}\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Define (or modify) an object property.\n*\n* @module @stdlib/utils/define-property\n*\n* @example\n* import defineProperty from '@stdlib/utils/define-property';\n*\n* var obj = {};\n* defineProperty( obj, 'foo', {\n* 'value': 'bar',\n* 'writable': false,\n* 'configurable': false,\n* 'enumerable': false\n* });\n* obj.foo = 'boop'; // => throws\n*/\n\n// MODULES //\n\nimport hasDefinePropertySupport from './has_define_property_support.js';\nimport builtin from './builtin.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar defineProperty;\nif ( hasDefinePropertySupport() ) {\n\tdefineProperty = builtin;\n} else {\n\tdefineProperty = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './define_property.js';\n\n\n// MAIN //\n\n/**\n* Tests for `Object.defineProperty` support.\n*\n* @private\n* @returns {boolean} boolean indicating if an environment has `Object.defineProperty` support\n*\n* @example\n* var bool = hasDefinePropertySupport();\n* // returns \n*/\nfunction hasDefinePropertySupport() {\n\t// Test basic support...\n\ttry {\n\t\tdefineProperty( {}, 'x', {} );\n\t\treturn true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default hasDefinePropertySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a read-only property.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* var obj = {};\n*\n* setReadOnly( obj, 'foo', 'bar' );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setReadOnly( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': value\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setReadOnly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a non-enumerable read-only property.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* var obj = {};\n*\n* setNonEnumerableReadOnly( obj, 'foo', 'bar' );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setNonEnumerableReadOnly( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'writable': false,\n\t\t'value': value\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setNonEnumerableReadOnly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar TYPE = 'function';\n\n\n// MAIN //\n\n/**\n* Tests if an array-like object supports the accessor (get/set) protocol.\n*\n* @param {Object} value - value to test\n* @returns {boolean} boolean indicating whether a value is an accessor array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isAccessorArray( new Complex128Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isAccessorArray( [] );\n* // returns false\n*/\nfunction isAccessorArray( value ) {\n\treturn ( typeof value.get === TYPE && typeof value.set === TYPE ); // eslint-disable-line valid-typeof\n}\n\n\n// EXPORTS //\n\nexport default isAccessorArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar GETTERS = {\n\t'float64': getFloat64,\n\t'float32': getFloat32,\n\t'int32': getInt32,\n\t'int16': getInt16,\n\t'int8': getInt8,\n\t'uint32': getUint32,\n\t'uint16': getUint16,\n\t'uint8': getUint8,\n\t'uint8c': getUint8c,\n\t'generic': getGeneric,\n\t'default': getArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an element from a `Float64Array`.\n*\n* @private\n* @param {Float64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getFloat64( arr, 2 );\n* // returns 3.0\n*/\nfunction getFloat64( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Float32Array`.\n*\n* @private\n* @param {Float32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Float32Array from '@stdlib/array/float32';\n*\n* var arr = new Float32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getFloat32( arr, 2 );\n* // returns 3.0\n*/\nfunction getFloat32( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int32Array`.\n*\n* @private\n* @param {Int32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var arr = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt32( arr, 2 );\n* // returns 3\n*/\nfunction getInt32( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int16Array`.\n*\n* @private\n* @param {Int16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int16Array from '@stdlib/array/int16';\n*\n* var arr = new Int16Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt16( arr, 2 );\n* // returns 3\n*/\nfunction getInt16( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int8Array`.\n*\n* @private\n* @param {Int8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var arr = new Int8Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt8( arr, 2 );\n* // returns 3\n*/\nfunction getInt8( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint32Array`.\n*\n* @private\n* @param {Uint32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var arr = new Uint32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint32( arr, 2 );\n* // returns 3\n*/\nfunction getUint32( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint16Array`.\n*\n* @private\n* @param {Uint16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint16Array from '@stdlib/array/uint16';\n*\n* var arr = new Uint16Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint16( arr, 2 );\n* // returns 3\n*/\nfunction getUint16( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint8Array`.\n*\n* @private\n* @param {Uint8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var arr = new Uint8Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint8( arr, 2 );\n* // returns 3\n*/\nfunction getUint8( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint8ClampedArray`.\n*\n* @private\n* @param {Uint8ClampedArray} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint8ClampedArray from '@stdlib/array/uint8c';\n*\n* var arr = new Uint8ClampedArray( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint8c( arr, 2 );\n* // returns 3\n*/\nfunction getUint8c( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a generic `Array`.\n*\n* @private\n* @param {Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var v = getGeneric( arr, 2 );\n* // returns 3\n*/\nfunction getGeneric( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an indexed array-like object.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var v = getArrayLike( arr, 2 );\n* // returns 3\n*/\nfunction getArrayLike( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an indexed array-like object.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 2 );\n* // returns 3\n*/\nfunction getter( dtype ) {\n\tvar f = GETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn GETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar SETTERS = {\n\t'float64': setFloat64,\n\t'float32': setFloat32,\n\t'int32': setInt32,\n\t'int16': setInt16,\n\t'int8': setInt8,\n\t'uint32': setUint32,\n\t'uint16': setUint16,\n\t'uint8': setUint8,\n\t'uint8c': setUint8c,\n\t'generic': setGeneric,\n\t'default': setArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Sets an element in a `Float64Array`.\n*\n* @private\n* @param {Float64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( 4 );\n*\n* setFloat64( arr, 2, 3.0 );\n*\n* var v = arr[ 2 ];\n* // returns 3.0\n*/\nfunction setFloat64( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Float32Array`.\n*\n* @private\n* @param {Float32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Float32Array from '@stdlib/array/float32';\n*\n* var arr = new Float32Array( 4 );\n*\n* setFloat32( arr, 2, 3.0 );\n*\n* var v = arr[ 2 ];\n* // returns 3.0\n*/\nfunction setFloat32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int32Array`.\n*\n* @private\n* @param {Int32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var arr = new Int32Array( 4 );\n*\n* setInt32( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int16Array`.\n*\n* @private\n* @param {Int16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int16Array from '@stdlib/array/int16';\n*\n* var arr = new Int16Array( 4 );\n*\n* setInt16( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt16( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int8Array`.\n*\n* @private\n* @param {Int8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var arr = new Int8Array( 4 );\n*\n* setInt8( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt8( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint32Array`.\n*\n* @private\n* @param {Uint32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var arr = new Uint32Array( 4 );\n*\n* setUint32( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint16Array`.\n*\n* @private\n* @param {Uint16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint16Array from '@stdlib/array/uint16';\n*\n* var arr = new Uint16Array( 4 );\n*\n* setUint16( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint16( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint8Array`.\n*\n* @private\n* @param {Uint8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var arr = new Uint8Array( 4 );\n*\n* setUint8( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint8( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint8ClampedArray`.\n*\n* @private\n* @param {Uint8ClampedArray} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint8ClampedArray from '@stdlib/array/uint8c';\n*\n* var arr = new Uint8ClampedArray( 4 );\n*\n* setUint8c( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint8c( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a generic `Array`.\n*\n* @private\n* @param {Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* setGeneric( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setGeneric( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an indexed array-like object.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* setArrayLike( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setArrayLike( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for setting an element in an indexed array-like object.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var set = setter( dtype( arr ) );\n* set( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setter( dtype ) {\n\tvar f = SETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn SETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar GETTERS = {\n\t'complex128': getComplex128,\n\t'complex64': getComplex64,\n\t'default': getArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an element from a `Complex128Array`.\n*\n* @private\n* @param {Complex128Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex128( arr, 1 );\n* // returns \n*\n* var re = real( v );\n* // returns 3.0\n*\n* var im = imag( v );\n* // returns 4.0\n*/\nfunction getComplex128( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from a `Complex64Array`.\n*\n* @private\n* @param {Complex64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex64( arr, 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getComplex64( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from an array-like object supporting the get/set protocol.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* function get( idx ) {\n* return arr[ idx ];\n* }\n*\n* function set( value, idx ) {\n* arr[ idx ] = value;\n* }\n*\n* arr.get = get;\n* arr.set = set;\n*\n* var v = getArrayLike( arr, 2 );\n* // returns 3\n*/\nfunction getArrayLike( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getter( dtype ) {\n\tvar f = GETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn GETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar SETTERS = {\n\t'complex128': setComplex128,\n\t'complex64': setComplex64,\n\t'default': setArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Sets an element in a `Complex128Array`.\n*\n* @private\n* @param {Complex128Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );\n*\n* setComplex128( arr, 1, new Complex128( 10.0, 11.0 ) );\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = real( v );\n* // returns 10.0\n*\n* var im = imag( v );\n* // returns 11.0\n*/\nfunction setComplex128( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n/**\n* Sets an element in a `Complex64Array`.\n*\n* @private\n* @param {Complex64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* setComplex64( arr, 1, new Complex64( 10.0, 11.0 ) );\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 11.0\n*/\nfunction setComplex64( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n/**\n* Sets an element in an array-like object supporting the get/set protocol.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* function get( idx ) {\n* return arr[ idx ];\n* }\n*\n* function set( value, idx ) {\n* arr[ idx ] = value;\n* }\n*\n* arr.get = get;\n* arr.set = set;\n*\n* setArrayLike( arr, 2, 10 );\n*\n* var v = arr[ 2 ];\n* // returns 10\n*/\nfunction setArrayLike( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for setting an element in an array-like object supporting the get/set protocol.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var set = setter( dtype( arr ) );\n* set( arr, 1, new Complex64( 10.0, 11.0 ) );\n*\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 11.0\n*/\nfunction setter( dtype ) {\n\tvar f = SETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn SETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasSymbols from './../../has-symbol-support';\n\n\n// VARIABLES //\n\nvar FLG = hasSymbols();\n\n\n// MAIN //\n\n/**\n* Tests for native `Symbol.toStringTag` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Symbol.toStringTag` support\n*\n* @example\n* var bool = hasToStringTagSupport();\n* // returns \n*/\nfunction hasToStringTagSupport() {\n\treturn ( FLG && typeof Symbol.toStringTag === 'symbol' );\n}\n\n\n// EXPORTS //\n\nexport default hasToStringTagSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests for native `Symbol` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Symbol` support\n*\n* @example\n* var bool = hasSymbolSupport();\n* // returns \n*/\nfunction hasSymbolSupport() {\n\treturn (\n\t\ttypeof Symbol === 'function' &&\n\t\ttypeof Symbol( 'foo' ) === 'symbol'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default hasSymbolSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar toStr = Object.prototype.toString;\n\n\n// EXPORTS //\n\nexport default toStr;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\nvar has = Object.prototype.hasOwnProperty;\n\n\n// MAIN //\n\n/**\n* Tests if an object has a specified property.\n*\n* @param {*} value - value to test\n* @param {*} property - property to test\n* @returns {boolean} boolean indicating if an object has a specified property\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = hasOwnProp( beep, 'boop' );\n* // returns true\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = hasOwnProp( beep, 'bap' );\n* // returns false\n*/\nfunction hasOwnProp( value, property ) {\n\tif (\n\t\tvalue === void 0 ||\n\t\tvalue === null\n\t) {\n\t\treturn false;\n\t}\n\treturn has.call( value, property );\n}\n\n\n// EXPORTS //\n\nexport default hasOwnProp;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar Sym = ( typeof Symbol === 'function' ) ? Symbol : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Sym;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Symbol from '@stdlib/symbol/ctor';\n\n\n// MAIN //\n\nvar toStrTag = ( typeof Symbol === 'function' ) ? Symbol.toStringTag : '';\n\n\n// EXPORTS //\n\nexport default toStrTag;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return a string value indicating a specification defined classification of an object.\n*\n* @module @stdlib/utils/native-class\n*\n* @example\n* import nativeClass from '@stdlib/utils/native-class';\n*\n* var str = nativeClass( 'a' );\n* // returns '[object String]'\n*\n* str = nativeClass( 5 );\n* // returns '[object Number]'\n*\n* function Beep() {\n* return this;\n* }\n* str = nativeClass( new Beep() );\n* // returns '[object Object]'\n*/\n\n// MODULES //\n\nimport hasToStringTag from '@stdlib/assert/has-tostringtag-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar main;\nif ( hasToStringTag() ) {\n\tmain = polyfill;\n} else {\n\tmain = builtin;\n}\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport toStringTag from './tostringtag.js';\nimport toStr from './tostring.js';\n\n\n// MAIN //\n\n/**\n* Returns a string value indicating a specification defined classification of an object in environments supporting `Symbol.toStringTag`.\n*\n* @param {*} v - input value\n* @returns {string} string value indicating a specification defined classification of the input value\n*\n* @example\n* var str = nativeClass( 'a' );\n* // returns '[object String]'\n*\n* @example\n* var str = nativeClass( 5 );\n* // returns '[object Number]'\n*\n* @example\n* function Beep() {\n* return this;\n* }\n* var str = nativeClass( new Beep() );\n* // returns '[object Object]'\n*/\nfunction nativeClass( v ) {\n\tvar isOwn;\n\tvar tag;\n\tvar out;\n\n\tif ( v === null || v === void 0 ) {\n\t\treturn toStr.call( v );\n\t}\n\ttag = v[ toStringTag ];\n\tisOwn = hasOwnProp( v, toStringTag );\n\n\t// Attempt to override the `toStringTag` property. For built-ins having a `Symbol.toStringTag` property (e.g., `JSON`, `Math`, etc), the `Symbol.toStringTag` property is read-only (e.g., , so we need to wrap in a `try/catch`.\n\ttry {\n\t\tv[ toStringTag ] = void 0;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn toStr.call( v );\n\t}\n\tout = toStr.call( v );\n\n\tif ( isOwn ) {\n\t\tv[ toStringTag ] = tag;\n\t} else {\n\t\tdelete v[ toStringTag ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default nativeClass;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport toStr from './tostring.js';\n\n\n// MAIN //\n\n/**\n* Returns a string value indicating a specification defined classification (via the internal property `[[Class]]`) of an object.\n*\n* @param {*} v - input value\n* @returns {string} string value indicating a specification defined classification of the input value\n*\n* @example\n* var str = nativeClass( 'a' );\n* // returns '[object String]'\n*\n* @example\n* var str = nativeClass( 5 );\n* // returns '[object Number]'\n*\n* @example\n* function Beep() {\n* return this;\n* }\n* var str = nativeClass( new Beep() );\n* // returns '[object Object]'\n*/\nfunction nativeClass( v ) {\n\treturn toStr.call( v );\n}\n\n\n// EXPORTS //\n\nexport default nativeClass;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar f;\n\n\n// FUNCTIONS //\n\n/**\n* Tests if a value is an array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an array\n*\n* @example\n* var bool = isArray( [] );\n* // returns true\n*\n* @example\n* var bool = isArray( {} );\n* // returns false\n*/\nfunction isArray( value ) {\n\treturn ( nativeClass( value ) === '[object Array]' );\n}\n\n\n// MAIN //\n\nif ( Array.isArray ) {\n\tf = Array.isArray;\n} else {\n\tf = isArray;\n}\n\n\n// EXPORTS //\n\nexport default f;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from './../../../is-array';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a function which tests if every element in an array passes a test condition.\n*\n* @param {Function} predicate - function to apply\n* @throws {TypeError} must provide a function\n* @returns {Function} an array function\n*\n* @example\n* import isOdd from '@stdlib/assert/is-odd';\n*\n* var arr1 = [ 1, 3, 5, 7 ];\n* var arr2 = [ 3, 5, 8 ];\n*\n* var validate = arrayfcn( isOdd );\n*\n* var bool = validate( arr1 );\n* // returns true\n*\n* bool = validate( arr2 );\n* // returns false\n*/\nfunction arrayfcn( predicate ) {\n\tif ( typeof predicate !== 'function' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a function. Value: `%s`.', predicate ) );\n\t}\n\treturn every;\n\n\t/**\n\t* Tests if every element in an array passes a test condition.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating whether a value is an array for which all elements pass a test condition\n\t*/\n\tfunction every( value ) {\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isArray( value ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tlen = value.length;\n\t\tif ( len === 0 ) {\n\t\t\treturn false;\n\t\t}\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( predicate( value[ i ] ) === false ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default arrayfcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is object-like.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is object-like\n*\n* @example\n* var bool = isObjectLike( {} );\n* // returns true\n*\n* @example\n* var bool = isObjectLike( [] );\n* // returns true\n*\n* @example\n* var bool = isObjectLike( null );\n* // returns false\n*/\nfunction isObjectLike( value ) {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === 'object'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isObjectLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObjectLike from './../../is-object-like';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Buffer instance.\n*\n* @param {*} value - value to validate\n* @returns {boolean} boolean indicating if a value is a Buffer instance\n*\n* @example\n* var v = isBuffer( new Buffer( 'beep' ) );\n* // returns true\n*\n* @example\n* var v = isBuffer( new Buffer( [1,2,3,4] ) );\n* // returns true\n*\n* @example\n* var v = isBuffer( {} );\n* // returns false\n*\n* @example\n* var v = isBuffer( [] );\n* // returns false\n*/\nfunction isBuffer( value ) {\n\treturn (\n\t\tisObjectLike( value ) &&\n\t\t(\n\t\t\t// eslint-disable-next-line no-underscore-dangle\n\t\t\tvalue._isBuffer || // for envs missing Object.prototype.constructor (e.g., Safari 5-7)\n\t\t\t(\n\t\t\t\tvalue.constructor &&\n\n\t\t\t\t// WARNING: `typeof` is not a foolproof check, as certain envs consider RegExp and NodeList instances to be functions\n\t\t\t\ttypeof value.constructor.isBuffer === 'function' &&\n\t\t\t\tvalue.constructor.isBuffer( value )\n\t\t\t)\n\t\t)\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isBuffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a regular expression to capture everything that is not a space immediately after the `function` keyword and before the first left parenthesis.\n*\n* @returns {RegExp} regular expression\n*\n* @example\n* var RE_FUNCTION_NAME = reFunctionName();\n*\n* function fname( fcn ) {\n* return RE_FUNCTION_NAME.exec( fcn.toString() )[ 1 ];\n* }\n*\n* var fn = fname( Math.sqrt );\n* // returns 'sqrt'\n*\n* fn = fname( Int8Array );\n* // returns 'Int8Array'\n*\n* fn = fname( Object.prototype.toString );\n* // returns 'toString'\n*\n* fn = fname( function(){} );\n* // returns ''\n*/\nfunction reFunctionName() {\n\treturn /^\\s*function\\s*([^(]*)/i;\n}\n\n\n// EXPORTS //\n\nexport default reFunctionName;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is object-like.\n*\n* @module @stdlib/assert/is-object-like\n*\n* @example\n* import isObjectLike from '@stdlib/assert/is-object-like';\n*\n* var bool = isObjectLike( {} );\n* // returns true\n*\n* bool = isObjectLike( [] );\n* // returns true\n*\n* bool = isObjectLike( null );\n* // returns false\n*\n* @example\n* import { isObjectLikeArray as isObjectLike } from '@stdlib/assert/is-object-like';\n*\n* var bool = isObjectLike( [ {}, [] ] );\n* // returns true\n*\n* bool = isObjectLike( [ {}, '3.0' ] );\n* // returns false\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport arrayfun from './../../tools/array-function';\nimport main from './main.js';\n\n\n// VARIABLES //\n\nvar isObjectLikeArray = arrayfun( main );\n\n\n// MAIN //\n\nsetReadOnly( main, 'isObjectLikeArray', isObjectLikeArray );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport reFunctionName from './main.js';\n\n\n// MAIN //\n\n/**\n* Captures everything that is not a space immediately after the `function` keyword and before the first left parenthesis.\n*\n* Regular expression: `/^\\s*function\\s*([^(]*)/i`\n*\n* - `/^\\s*`\n* - Match zero or more spaces at beginning\n*\n* - `function`\n* - Match the word `function`\n*\n* - `\\s*`\n* - Match zero or more spaces after the word `function`\n*\n* - `()`\n* - Capture\n*\n* - `[^(]*`\n* - Match anything except a left parenthesis `(` zero or more times\n*\n* - `/i`\n* - ignore case\n*\n* @constant\n* @type {RegExp}\n* @default /^\\s*function\\s*([^(]*)/i\n*/\nvar RE_FUNCTION_NAME = reFunctionName();\n\n\n// EXPORTS //\n\nexport default RE_FUNCTION_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from './../../native-class';\nimport { REGEXP as RE } from '@stdlib/regexp/function-name';\nimport isBuffer from '@stdlib/assert/is-buffer';\n\n\n// MAIN //\n\n/**\n* Determines the name of a value's constructor.\n*\n* @param {*} v - input value\n* @returns {string} name of a value's constructor\n*\n* @example\n* var v = constructorName( 'a' );\n* // returns 'String'\n*\n* @example\n* var v = constructorName( 5 );\n* // returns 'Number'\n*\n* @example\n* var v = constructorName( null );\n* // returns 'Null'\n*\n* @example\n* var v = constructorName( undefined );\n* // returns 'Undefined'\n*\n* @example\n* var v = constructorName( function noop() {} );\n* // returns 'Function'\n*/\nfunction constructorName( v ) {\n\tvar match;\n\tvar name;\n\tvar ctor;\n\tname = nativeClass( v ).slice( 8, -1 );\n\tif ( (name === 'Object' || name === 'Error') && v.constructor ) {\n\t\tctor = v.constructor;\n\t\tif ( typeof ctor.name === 'string' ) {\n\t\t\treturn ctor.name;\n\t\t}\n\t\tmatch = RE.exec( ctor.toString() );\n\t\tif ( match ) {\n\t\t\treturn match[ 1 ];\n\t\t}\n\t}\n\tif ( isBuffer( v ) ) {\n\t\treturn 'Buffer';\n\t}\n\treturn name;\n}\n\n\n// EXPORTS //\n\nexport default constructorName;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Regular expression to capture everything that is not a space immediately after the `function` keyword and before the first left parenthesis.\n*\n* @module @stdlib/regexp/function-name\n*\n* @example\n* import reFunctionName from '@stdlib/regexp/function-name';\n* var RE_FUNCTION_NAME = reFunctionName();\n*\n* function fname( fcn ) {\n* return RE_FUNCTION_NAME.exec( fcn.toString() )[ 1 ];\n* }\n*\n* var fn = fname( Math.sqrt );\n* // returns 'sqrt'\n*\n* fn = fname( Int8Array );\n* // returns 'Int8Array'\n*\n* fn = fname( Object.prototype.toString );\n* // returns 'toString'\n*\n* fn = fname( function(){} );\n* // returns ''\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport REGEXP from './regexp.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'REGEXP', REGEXP );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Mapping from array constructors to data types...\nvar ctor2dtypes = {\n\t'Float32Array': 'float32',\n\t'Float64Array': 'float64',\n\t'Array': 'generic',\n\t'Int16Array': 'int16',\n\t'Int32Array': 'int32',\n\t'Int8Array': 'int8',\n\t'Uint16Array': 'uint16',\n\t'Uint32Array': 'uint32',\n\t'Uint8Array': 'uint8',\n\t'Uint8ClampedArray': 'uint8c',\n\t'Complex64Array': 'complex64',\n\t'Complex128Array': 'complex128',\n\t'BooleanArray': 'bool'\n};\n\n\n// EXPORTS //\n\nexport default ctor2dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasFloat64Array = ( typeof Float64Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Float64Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Float64Array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var bool = isFloat64Array( new Float64Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isFloat64Array( [] );\n* // returns false\n*/\nfunction isFloat64Array( value ) {\n\treturn (\n\t\t( hasFloat64Array && value instanceof Float64Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Float64Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isFloat64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Float64Array === 'function' ) ? Float64Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFloat64Array from './../../is-float64array';\nimport GlobalFloat64Array from './float64array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Float64Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Float64Array` support\n*\n* @example\n* var bool = hasFloat64ArraySupport();\n* // returns \n*/\nfunction hasFloat64ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalFloat64Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalFloat64Array( [ 1.0, 3.14, -3.14, NaN ] );\n\t\tbool = (\n\t\t\tisFloat64Array( arr ) &&\n\t\t\tarr[ 0 ] === 1.0 &&\n\t\t\tarr[ 1 ] === 3.14 &&\n\t\t\tarr[ 2 ] === -3.14 &&\n\t\t\tarr[ 3 ] !== arr[ 3 ]\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasFloat64ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float64Array === 'function' ) ? Float64Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in the platform byte order.\n*\n* @module @stdlib/array/float64\n*\n* @example\n* import ctor from '@stdlib/array/float64';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasFloat64ArraySupport from '@stdlib/assert/has-float64array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat64ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of double-precision floating-point numbers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasFloat32Array = ( typeof Float32Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Float32Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Float32Array\n*\n* @example\n* import Float32Array from '@stdlib/array/float32';\n*\n* var bool = isFloat32Array( new Float32Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isFloat32Array( [] );\n* // returns false\n*/\nfunction isFloat32Array( value ) {\n\treturn (\n\t\t( hasFloat32Array && value instanceof Float32Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Float32Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isFloat32Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Double-precision floating-point positive infinity.\n*\n* @module @stdlib/constants/float64/pinf\n* @type {number}\n*\n* @example\n* import FLOAT64_PINF from '@stdlib/constants/float64/pinf';\n* // returns Infinity\n*/\n\n\n// MAIN //\n\n/**\n* Double-precision floating-point positive infinity.\n*\n* ## Notes\n*\n* Double-precision floating-point positive infinity has the bit sequence\n*\n* ```binarystring\n* 0 11111111111 00000000000000000000 00000000000000000000000000000000\n* ```\n*\n* @constant\n* @type {number}\n* @default Number.POSITIVE_INFINITY\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_PINF = Number.POSITIVE_INFINITY; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default FLOAT64_PINF;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Float32Array === 'function' ) ? Float32Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFloat32Array from './../../is-float32array';\nimport PINF from '@stdlib/constants/float64/pinf';\nimport GlobalFloat32Array from './float32array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Float32Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Float32Array` support\n*\n* @example\n* var bool = hasFloat32ArraySupport();\n* // returns \n*/\nfunction hasFloat32ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalFloat32Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalFloat32Array( [ 1.0, 3.14, -3.14, 5.0e40 ] );\n\t\tbool = (\n\t\t\tisFloat32Array( arr ) &&\n\t\t\tarr[ 0 ] === 1.0 &&\n\t\t\tarr[ 1 ] === 3.140000104904175 &&\n\t\t\tarr[ 2 ] === -3.140000104904175 &&\n\t\t\tarr[ 3 ] === PINF\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasFloat32ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float32Array === 'function' ) ? Float32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order.\n*\n* @module @stdlib/array/float32\n*\n* @example\n* import ctor from '@stdlib/array/float32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasFloat32ArraySupport from '@stdlib/assert/has-float32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of single-precision floating-point numbers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasUint32Array = ( typeof Uint32Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Uint32Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Uint32Array\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var bool = isUint32Array( new Uint32Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isUint32Array( [] );\n* // returns false\n*/\nfunction isUint32Array( value ) {\n\treturn (\n\t\t( hasUint32Array && value instanceof Uint32Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Uint32Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isUint32Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum unsigned 32-bit integer.\n*\n* @module @stdlib/constants/uint32/max\n* @type {uinteger32}\n*\n* @example\n* import UINT32_MAX from '@stdlib/constants/uint32/max';\n* // returns 4294967295\n*/\n\n\n// MAIN //\n\n/**\n* Maximum unsigned 32-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* 2^{32} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 11111111111111111111111111111111\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 4294967295\n*/\nvar UINT32_MAX = 4294967295;\n\n\n// EXPORTS //\n\nexport default UINT32_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Uint32Array === 'function' ) ? Uint32Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUint32Array from './../../is-uint32array';\nimport UINT32_MAX from '@stdlib/constants/uint32/max';\nimport GlobalUint32Array from './uint32array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Uint32Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Uint32Array` support\n*\n* @example\n* var bool = hasUint32ArraySupport();\n* // returns \n*/\nfunction hasUint32ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalUint32Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = [ 1, 3.14, -3.14, UINT32_MAX+1, UINT32_MAX+2 ];\n\t\tarr = new GlobalUint32Array( arr );\n\t\tbool = (\n\t\t\tisUint32Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === UINT32_MAX-2 && // truncation and wrap around\n\t\t\tarr[ 3 ] === 0 && // wrap around\n\t\t\tarr[ 4 ] === 1 // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasUint32ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint32Array === 'function' ) ? Uint32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 32-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint32\n*\n* @example\n* import ctor from '@stdlib/array/uint32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint32ArraySupport from '@stdlib/assert/has-uint32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 32-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasInt32Array = ( typeof Int32Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is an Int32Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an Int32Array\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var bool = isInt32Array( new Int32Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isInt32Array( [] );\n* // returns false\n*/\nfunction isInt32Array( value ) {\n\treturn (\n\t\t( hasInt32Array && value instanceof Int32Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Int32Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInt32Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum signed 32-bit integer.\n*\n* @module @stdlib/constants/int32/max\n* @type {integer32}\n*\n* @example\n* import INT32_MAX from '@stdlib/constants/int32/max';\n* // returns 2147483647\n*/\n\n\n// MAIN //\n\n/**\n* Maximum signed 32-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* 2^{31} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 01111111111111111111111111111111\n* ```\n*\n* @constant\n* @type {integer32}\n* @default 2147483647\n*/\nvar INT32_MAX = 2147483647|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT32_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Minimum signed 32-bit integer.\n*\n* @module @stdlib/constants/int32/min\n* @type {integer32}\n*\n* @example\n* import INT32_MIN from '@stdlib/constants/int32/min';\n* // returns -2147483648\n*/\n\n\n// MAIN //\n\n/**\n* Minimum signed 32-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* -(2^{31})\n* ```\n*\n* which corresponds to the two's complement bit sequence\n*\n* ```binarystring\n* 10000000000000000000000000000000\n* ```\n*\n* @constant\n* @type {integer32}\n* @default -2147483648\n*/\nvar INT32_MIN = -2147483648|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT32_MIN;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Int32Array === 'function' ) ? Int32Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInt32Array from './../../is-int32array';\nimport INT32_MAX from '@stdlib/constants/int32/max';\nimport INT32_MIN from '@stdlib/constants/int32/min';\nimport GlobalInt32Array from './int32array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Int32Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Int32Array` support\n*\n* @example\n* var bool = hasInt32ArraySupport();\n* // returns \n*/\nfunction hasInt32ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalInt32Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalInt32Array( [ 1, 3.14, -3.14, INT32_MAX+1 ] );\n\t\tbool = (\n\t\t\tisInt32Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === -3 && // truncation\n\t\t\tarr[ 3 ] === INT32_MIN // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasInt32ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int32Array === 'function' ) ? Int32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 32-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int32\n*\n* @example\n* import ctor from '@stdlib/array/int32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt32ArraySupport from '@stdlib/assert/has-int32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 32-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasUint16Array = ( typeof Uint16Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Uint16Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Uint16Array\n*\n* @example\n* import Uint16Array from '@stdlib/array/uint16';\n*\n* var bool = isUint16Array( new Uint16Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isUint16Array( [] );\n* // returns false\n*/\nfunction isUint16Array( value ) {\n\treturn (\n\t\t( hasUint16Array && value instanceof Uint16Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Uint16Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isUint16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum unsigned 16-bit integer.\n*\n* @module @stdlib/constants/uint16/max\n* @type {integer32}\n*\n* @example\n* import UINT16_MAX from '@stdlib/constants/uint16/max';\n* // returns 65535\n*/\n\n\n// MAIN //\n\n/**\n* Maximum unsigned 16-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* 2^{16} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 1111111111111111\n* ```\n*\n* @constant\n* @type {integer32}\n* @default 65535\n*/\nvar UINT16_MAX = 65535|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default UINT16_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Uint16Array === 'function' ) ? Uint16Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUint16Array from './../../is-uint16array';\nimport UINT16_MAX from '@stdlib/constants/uint16/max';\nimport GlobalUint16Array from './uint16array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Uint16Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Uint16Array` support\n*\n* @example\n* var bool = hasUint16ArraySupport();\n* // returns \n*/\nfunction hasUint16ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalUint16Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = [ 1, 3.14, -3.14, UINT16_MAX+1, UINT16_MAX+2 ];\n\t\tarr = new GlobalUint16Array( arr );\n\t\tbool = (\n\t\t\tisUint16Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === UINT16_MAX-2 && // truncation and wrap around\n\t\t\tarr[ 3 ] === 0 && // wrap around\n\t\t\tarr[ 4 ] === 1 // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasUint16ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint16\n*\n* @example\n* import ctor from '@stdlib/array/uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert/has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasInt16Array = ( typeof Int16Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is an Int16Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an Int16Array\n*\n* @example\n* import Int16Array from '@stdlib/array/int16';\n*\n* var bool = isInt16Array( new Int16Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isInt16Array( [] );\n* // returns false\n*/\nfunction isInt16Array( value ) {\n\treturn (\n\t\t( hasInt16Array && value instanceof Int16Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Int16Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInt16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum signed 16-bit integer.\n*\n* @module @stdlib/constants/int16/max\n* @type {integer32}\n*\n* @example\n* import INT16_MAX from '@stdlib/constants/int16/max';\n* // returns 32767\n*/\n\n\n// MAIN //\n\n/**\n* Maximum signed 16-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* 2^{15} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 0111111111111111\n* ```\n*\n* @constant\n* @type {integer32}\n* @default 32767\n*/\nvar INT16_MAX = 32767|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT16_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Minimum signed 16-bit integer.\n*\n* @module @stdlib/constants/int16/min\n* @type {integer32}\n*\n* @example\n* import INT16_MIN from '@stdlib/constants/int16/min';\n* // returns -32768\n*/\n\n\n// MAIN //\n\n/**\n* Minimum signed 16-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* -(2^{15})\n* ```\n*\n* which corresponds to the two's complement bit sequence\n*\n* ```binarystring\n* 1000000000000000\n* ```\n*\n* @constant\n* @type {integer32}\n* @default -32768\n*/\nvar INT16_MIN = -32768|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT16_MIN;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Int16Array === 'function' ) ? Int16Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInt16Array from './../../is-int16array';\nimport INT16_MAX from '@stdlib/constants/int16/max';\nimport INT16_MIN from '@stdlib/constants/int16/min';\nimport GlobalInt16Array from './int16array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Int16Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Int16Array` support\n*\n* @example\n* var bool = hasInt16ArraySupport();\n* // returns \n*/\nfunction hasInt16ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalInt16Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalInt16Array( [ 1, 3.14, -3.14, INT16_MAX+1 ] );\n\t\tbool = (\n\t\t\tisInt16Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === -3 && // truncation\n\t\t\tarr[ 3 ] === INT16_MIN // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasInt16ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int16Array === 'function' ) ? Int16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 16-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int16\n*\n* @example\n* import ctor from '@stdlib/array/int16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt16ArraySupport from '@stdlib/assert/has-int16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 16-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasUint8Array = ( typeof Uint8Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Uint8Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Uint8Array\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var bool = isUint8Array( new Uint8Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isUint8Array( [] );\n* // returns false\n*/\nfunction isUint8Array( value ) {\n\treturn (\n\t\t( hasUint8Array && value instanceof Uint8Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Uint8Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isUint8Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum unsigned 8-bit integer.\n*\n* @module @stdlib/constants/uint8/max\n* @type {integer32}\n*\n* @example\n* import UINT8_MAX from '@stdlib/constants/uint8/max';\n* // returns 255\n*/\n\n\n// MAIN //\n\n/**\n* Maximum unsigned 8-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* 2^{8} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 11111111\n* ```\n*\n* @constant\n* @type {integer32}\n* @default 255\n*/\nvar UINT8_MAX = 255|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default UINT8_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Uint8Array === 'function' ) ? Uint8Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUint8Array from './../../is-uint8array';\nimport UINT8_MAX from '@stdlib/constants/uint8/max';\nimport GlobalUint8Array from './uint8array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Uint8Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Uint8Array` support\n*\n* @example\n* var bool = hasUint8ArraySupport();\n* // returns \n*/\nfunction hasUint8ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalUint8Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = [ 1, 3.14, -3.14, UINT8_MAX+1, UINT8_MAX+2 ];\n\t\tarr = new GlobalUint8Array( arr );\n\t\tbool = (\n\t\t\tisUint8Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === UINT8_MAX-2 && // truncation and wrap around\n\t\t\tarr[ 3 ] === 0 && // wrap around\n\t\t\tarr[ 4 ] === 1 // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasUint8ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint8Array === 'function' ) ? Uint8Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint8\n*\n* @example\n* import ctor from '@stdlib/array/uint8';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint8ArraySupport from '@stdlib/assert/has-uint8array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint8ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 8-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasUint8ClampedArray = ( typeof Uint8ClampedArray === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Uint8ClampedArray.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Uint8ClampedArray\n*\n* @example\n* import Uint8ClampedArray from '@stdlib/array/uint8c';\n*\n* var bool = isUint8ClampedArray( new Uint8ClampedArray( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isUint8ClampedArray( [] );\n* // returns false\n*/\nfunction isUint8ClampedArray( value ) {\n\treturn (\n\t\t( hasUint8ClampedArray && value instanceof Uint8ClampedArray ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Uint8ClampedArray]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isUint8ClampedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Uint8ClampedArray === 'function' ) ? Uint8ClampedArray : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUint8ClampedArray from './../../is-uint8clampedarray';\nimport GlobalUint8ClampedArray from './uint8clampedarray.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Uint8ClampedArray` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Uint8ClampedArray` support\n*\n* @example\n* var bool = hasUint8ClampedArraySupport();\n* // returns \n*/\nfunction hasUint8ClampedArraySupport() { // eslint-disable-line id-length\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalUint8ClampedArray !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalUint8ClampedArray( [ -1, 0, 1, 3.14, 4.99, 255, 256 ] );\n\t\tbool = (\n\t\t\tisUint8ClampedArray( arr ) &&\n\t\t\tarr[ 0 ] === 0 && // clamped\n\t\t\tarr[ 1 ] === 0 &&\n\t\t\tarr[ 2 ] === 1 &&\n\t\t\tarr[ 3 ] === 3 && // round to nearest\n\t\t\tarr[ 4 ] === 5 && // round to nearest\n\t\t\tarr[ 5 ] === 255 &&\n\t\t\tarr[ 6 ] === 255 // clamped\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasUint8ClampedArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint8ClampedArray === 'function' ) ? Uint8ClampedArray : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order clamped to 0-255.\n*\n* @module @stdlib/array/uint8c\n*\n* @example\n* import ctor from '@stdlib/array/uint8c';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint8ClampedArraySupport from '@stdlib/assert/has-uint8clampedarray-support'; // eslint-disable-line id-length\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint8ClampedArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 8-bit unsigned integers in the platform byte order clamped to 0-255.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasInt8Array = ( typeof Int8Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is an Int8Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an Int8Array\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var bool = isInt8Array( new Int8Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isInt8Array( [] );\n* // returns false\n*/\nfunction isInt8Array( value ) {\n\treturn (\n\t\t( hasInt8Array && value instanceof Int8Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Int8Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInt8Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum signed 8-bit integer.\n*\n* @module @stdlib/constants/int8/max\n* @type {integer32}\n*\n* @example\n* import INT8_MAX from '@stdlib/constants/int8/max';\n* // returns 127\n*/\n\n\n// MAIN //\n\n/**\n* Maximum signed 8-bit integer.\n*\n* ## Notes\n*\n* The number is given by\n*\n* ```tex\n* 2^{7} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 01111111\n* ```\n*\n* @constant\n* @type {integer32}\n* @default 127\n*/\nvar INT8_MAX = 127|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT8_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Minimum signed 8-bit integer.\n*\n* @module @stdlib/constants/int8/min\n* @type {integer32}\n*\n* @example\n* import INT8_MIN from '@stdlib/constants/int8/min';\n* // returns -128\n*/\n\n\n// MAIN //\n\n/**\n* Minimum signed 8-bit integer.\n*\n* ## Notes\n*\n* The number is given by\n*\n* ```tex\n* -(2^{7})\n* ```\n*\n* which corresponds to the two's complement bit sequence\n*\n* ```binarystring\n* 10000000\n* ```\n*\n* @constant\n* @type {integer32}\n* @default -128\n*/\nvar INT8_MIN = -128|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT8_MIN;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Int8Array === 'function' ) ? Int8Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInt8Array from './../../is-int8array';\nimport INT8_MAX from '@stdlib/constants/int8/max';\nimport INT8_MIN from '@stdlib/constants/int8/min';\nimport GlobalInt8Array from './int8array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Int8Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Int8Array` support\n*\n* @example\n* var bool = hasInt8ArraySupport();\n* // returns \n*/\nfunction hasInt8ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalInt8Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalInt8Array( [ 1, 3.14, -3.14, INT8_MAX+1 ] );\n\t\tbool = (\n\t\t\tisInt8Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === -3 && // truncation\n\t\t\tarr[ 3 ] === INT8_MIN // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasInt8ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int8Array === 'function' ) ? Int8Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 8-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int8\n*\n* @example\n* import ctor from '@stdlib/array/int8';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt8ArraySupport from '@stdlib/assert/has-int8array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt8ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 8-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a number primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* @example\n* var bool = isNumber( NaN );\n* // returns true\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns false\n*/\nfunction isNumber( value ) {\n\treturn ( typeof value === 'number' );\n}\n\n\n// EXPORTS //\n\nexport default isNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// EXPORTS //\n\nexport default Number; // eslint-disable-line stdlib/require-globals\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number/ctor';\n\n\n// MAIN //\n\n// eslint-disable-next-line stdlib/no-redeclare\nvar toString = Number.prototype.toString; // non-generic\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasToStringTag from './../../has-tostringtag-support';\nimport nativeClass from '@stdlib/utils/native-class';\nimport Number from '@stdlib/number/ctor';\nimport test from './try2serialize.js';\n\n\n// VARIABLES //\n\nvar FLG = hasToStringTag();\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number object\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns false\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns true\n*/\nfunction isNumber( value ) {\n\tif ( typeof value === 'object' ) {\n\t\tif ( value instanceof Number ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( FLG ) {\n\t\t\treturn test( value );\n\t\t}\n\t\treturn ( nativeClass( value ) === '[object Number]' );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\n\n\n// MAIN //\n\n/**\n* Attempts to serialize a value to a string.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value can be serialized\n*/\nfunction test( value ) {\n\ttry {\n\t\ttoString.call( value );\n\t\treturn true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default test;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a number\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns true\n*\n* @example\n* var bool = isNumber( NaN );\n* // returns true\n*\n* @example\n* var bool = isNumber( null );\n* // returns false\n*/\nfunction isNumber( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is a number.\n*\n* @module @stdlib/assert/is-number\n*\n* @example\n* import isNumber from '@stdlib/assert/is-number';\n*\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* bool = isNumber( new Number( 3.14 ) );\n* // returns true\n*\n* bool = isNumber( NaN );\n* // returns true\n*\n* bool = isNumber( null );\n* // returns false\n*\n* @example\n* import { isPrimitive as isNumber } from '@stdlib/assert/is-number';\n*\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* bool = isNumber( NaN );\n* // returns true\n*\n* bool = isNumber( new Number( 3.14 ) );\n* // returns false\n*\n* @example\n* import { isObject as isNumber } from '@stdlib/assert/is-number';\n*\n* var bool = isNumber( 3.14 );\n* // returns false\n*\n* bool = isNumber( new Number( 3.14 ) );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Double-precision floating-point negative infinity.\n*\n* @module @stdlib/constants/float64/ninf\n* @type {number}\n*\n* @example\n* import FLOAT64_NINF from '@stdlib/constants/float64/ninf';\n* // returns -Infinity\n*/\n\n// MODULES //\n\nimport Number from '@stdlib/number/ctor';\n\n\n// MAIN //\n\n/**\n* Double-precision floating-point negative infinity.\n*\n* ## Notes\n*\n* Double-precision floating-point negative infinity has the bit sequence\n*\n* ```binarystring\n* 1 11111111111 00000000000000000000 00000000000000000000000000000000\n* ```\n*\n* @constant\n* @type {number}\n* @default Number.NEGATIVE_INFINITY\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_NINF = Number.NEGATIVE_INFINITY;\n\n\n// EXPORTS //\n\nexport default FLOAT64_NINF;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: implementation (?)\n\n/**\n* Rounds a double-precision floating-point number toward negative infinity.\n*\n* @param {number} x - input value\n* @returns {number} rounded value\n*\n* @example\n* var v = floor( -4.2 );\n* // returns -5.0\n*\n* @example\n* var v = floor( 9.99999 );\n* // returns 9.0\n*\n* @example\n* var v = floor( 0.0 );\n* // returns 0.0\n*\n* @example\n* var v = floor( NaN );\n* // returns NaN\n*/\nvar floor = Math.floor; // eslint-disable-line stdlib/no-builtin-math\n\n\n// EXPORTS //\n\nexport default floor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from './../../../../base/special/floor';\n\n\n// MAIN //\n\n/**\n* Tests if a finite double-precision floating-point number is an integer.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is an integer\n*\n* @example\n* var bool = isInteger( 1.0 );\n* // returns true\n*\n* @example\n* var bool = isInteger( 3.14 );\n* // returns false\n*/\nfunction isInteger( x ) {\n\treturn (floor(x) === x);\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport PINF from '@stdlib/constants/float64/pinf';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport isInt from '@stdlib/math/base/assert/is-integer';\n\n\n// MAIN //\n\n/**\n* Tests if a number primitive is an integer value.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a number primitive is an integer value\n*/\nfunction isInteger( value ) {\n\treturn (\n\t\tvalue < PINF &&\n\t\tvalue > NINF &&\n\t\tisInt( value )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from './../../is-number';\nimport isInt from './integer.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number primitive having an integer value.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive having an integer value\n*\n* @example\n* var bool = isInteger( -3.0 );\n* // returns true\n*\n* @example\n* var bool = isInteger( new Number( -3.0 ) );\n* // returns false\n*/\nfunction isInteger( value ) {\n\treturn (\n\t\tisNumber( value ) &&\n\t\tisInt( value )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isObject as isNumber } from './../../is-number';\nimport isInt from './integer.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number object having an integer value.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number object having an integer value\n*\n* @example\n* var bool = isInteger( 3.0 );\n* // returns false\n*\n* @example\n* var bool = isInteger( new Number( 3.0 ) );\n* // returns true\n*/\nfunction isInteger( value ) {\n\treturn (\n\t\tisNumber( value ) &&\n\t\tisInt( value.valueOf() )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an integer.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an integer\n*\n* @example\n* var bool = isInteger( 5.0 );\n* // returns true\n*\n* @example\n* var bool = isInteger( new Number( 5.0 ) );\n* // returns true\n*\n* @example\n* var bool = isInteger( -3.14 );\n* // returns false\n*\n* @example\n* var bool = isInteger( null );\n* // returns false\n*/\nfunction isInteger( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isInteger } from './../../is-integer';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number primitive having a nonnegative integer value.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive having a nonnegative integer value\n*\n* @example\n* var bool = isNonNegativeInteger( 3.0 );\n* // returns true\n*\n* @example\n* var bool = isNonNegativeInteger( new Number( 3.0 ) );\n* // returns false\n*/\nfunction isNonNegativeInteger( value ) {\n\treturn (\n\t\tisInteger( value ) &&\n\t\tvalue >= 0\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isNonNegativeInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isObject as isInteger } from './../../is-integer';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number object having a nonnegative integer value.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number object having a nonnegative integer value\n*\n* @example\n* var bool = isNonNegativeInteger( 3.0 );\n* // returns false\n*\n* @example\n* var bool = isNonNegativeInteger( new Number( 3.0 ) );\n* // returns true\n*/\nfunction isNonNegativeInteger( value ) {\n\treturn (\n\t\tisInteger( value ) &&\n\t\tvalue.valueOf() >= 0\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isNonNegativeInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a nonnegative integer.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a nonnegative integer\n*\n* @example\n* var bool = isNonNegativeInteger( 5.0 );\n* // returns true\n*\n* @example\n* var bool = isNonNegativeInteger( new Number( 5.0 ) );\n* // returns true\n*\n* @example\n* var bool = isNonNegativeInteger( -5.0 );\n* // returns false\n*\n* @example\n* var bool = isNonNegativeInteger( 3.14 );\n* // returns false\n*\n* @example\n* var bool = isNonNegativeInteger( null );\n* // returns false\n*/\nfunction isNonNegativeInteger( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isNonNegativeInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is an integer.\n*\n* @module @stdlib/assert/is-integer\n*\n* @example\n* import isInteger from '@stdlib/assert/is-integer';\n*\n* var bool = isInteger( 5.0 );\n* // returns true\n*\n* bool = isInteger( new Number( 5.0 ) );\n* // returns true\n*\n* bool = isInteger( -3.14 );\n* // returns false\n*\n* bool = isInteger( null );\n* // returns false\n*\n* @example\n* // Use interface to check for integer primitives...\n* import { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\n*\n* var bool = isInteger( -3.0 );\n* // returns true\n*\n* bool = isInteger( new Number( -3.0 ) );\n* // returns false\n*\n* @example\n* // Use interface to check for integer objects...\n* import { isObject as isInteger } from '@stdlib/assert/is-integer';\n*\n* var bool = isInteger( 3.0 );\n* // returns false\n*\n* bool = isInteger( new Number( 3.0 ) );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is a nonnegative integer.\n*\n* @module @stdlib/assert/is-nonnegative-integer\n*\n* @example\n* import isNonNegativeInteger from '@stdlib/assert/is-nonnegative-integer';\n*\n* var bool = isNonNegativeInteger( 5.0 );\n* // returns true\n*\n* bool = isNonNegativeInteger( new Number( 5.0 ) );\n* // returns true\n*\n* bool = isNonNegativeInteger( -5.0 );\n* // returns false\n*\n* bool = isNonNegativeInteger( 3.14 );\n* // returns false\n*\n* bool = isNonNegativeInteger( null );\n* // returns false\n*\n* @example\n* import { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\n*\n* var bool = isNonNegativeInteger( 3.0 );\n* // returns true\n*\n* bool = isNonNegativeInteger( new Number( 3.0 ) );\n* // returns false\n*\n* @example\n* import { isObject as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\n*\n* var bool = isNonNegativeInteger( 3.0 );\n* // returns false\n*\n* bool = isNonNegativeInteger( new Number( 3.0 ) );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Maximum length of a generic array.\n*\n* @module @stdlib/constants/array/max-array-length\n*\n* @example\n* import MAX_ARRAY_LENGTH from '@stdlib/constants/array/max-array-length';\n* // returns 4294967295\n*/\n\n// MAIN //\n\n/**\n* Maximum length of a generic array.\n*\n* ```tex\n* 2^{32} - 1\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 4294967295\n*/\nvar MAX_ARRAY_LENGTH = 4294967295>>>0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default MAX_ARRAY_LENGTH;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport MAX_LENGTH from '@stdlib/constants/array/max-array-length';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array-like object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is an array-like object\n*\n* @example\n* var bool = isArrayLikeObject( [] );\n* // returns true\n*\n* @example\n* var bool = isArrayLikeObject( { 'length': 10 } );\n* // returns true\n*\n* @example\n* var bool = isArrayLikeObject( 'beep' );\n* // returns false\n*/\nfunction isArrayLikeObject( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof value.length === 'number' &&\n\t\tisInteger( value.length ) &&\n\t\tvalue.length >= 0 &&\n\t\tvalue.length <= MAX_LENGTH\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isArrayLikeObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum length of a typed array.\n*\n* @module @stdlib/constants/array/max-typed-array-length\n*\n* @example\n* import MAX_TYPED_ARRAY_LENGTH from '@stdlib/constants/array/max-typed-array-length';\n* // returns 9007199254740991\n*/\n\n// MAIN //\n\n/**\n* Maximum length of a typed array.\n*\n* ```tex\n* 2^{53} - 1\n* ```\n*\n* @constant\n* @type {number}\n* @default 9007199254740991\n*/\nvar MAX_TYPED_ARRAY_LENGTH = 9007199254740991;\n\n\n// EXPORTS //\n\nexport default MAX_TYPED_ARRAY_LENGTH;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport MAX_LENGTH from '@stdlib/constants/array/max-typed-array-length';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a collection.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is a collection\n*\n* @example\n* var bool = isCollection( [] );\n* // returns true\n*\n* @example\n* var bool = isCollection( {} );\n* // returns false\n*/\nfunction isCollection( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof value.length === 'number' &&\n\t\tisInteger( value.length ) &&\n\t\tvalue.length >= 0 &&\n\t\tvalue.length <= MAX_LENGTH\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isCollection;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasArrayBuffer = ( typeof ArrayBuffer === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is an ArrayBuffer.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an ArrayBuffer\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var bool = isArrayBuffer( new ArrayBuffer( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isArrayBuffer( [] );\n* // returns false\n*/\nfunction isArrayBuffer( value ) {\n\treturn (\n\t\t( hasArrayBuffer && value instanceof ArrayBuffer ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object ArrayBuffer]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isArrayBuffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from './../../is-array';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an object; e.g., `{}`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an object\n*\n* @example\n* var bool = isObject( {} );\n* // returns true\n*\n* @example\n* var bool = isObject( null );\n* // returns false\n*/\nfunction isObject( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t!isArray( value )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' );\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// eslint-disable-next-line stdlib/no-redeclare\nvar valueOf = String.prototype.valueOf; // non-generic\n\n\n// EXPORTS //\n\nexport default valueOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasToStringTag from './../../has-tostringtag-support';\nimport nativeClass from '@stdlib/utils/native-class';\nimport test from './try2valueof.js';\n\n\n// VARIABLES //\n\nvar FLG = hasToStringTag();\n\n\n// MAIN //\n\n/**\n* Tests if a value is a string object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string object\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns true\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns false\n*/\nfunction isString( value ) {\n\tif ( typeof value === 'object' ) {\n\t\tif ( value instanceof String ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( FLG ) {\n\t\t\treturn test( value );\n\t\t}\n\t\treturn ( nativeClass( value ) === '[object String]' );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport valueOf from './valueof.js'; // eslint-disable-line stdlib/no-redeclare\n\n\n// MAIN //\n\n/**\n* Attempts to extract a string value.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a string can be extracted\n*/\nfunction test( value ) {\n\ttry {\n\t\tvalueOf.call( value );\n\t\treturn true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default test;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a string.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a string\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns true\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*/\nfunction isString( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is a string.\n*\n* @module @stdlib/assert/is-string\n*\n* @example\n* import isString from '@stdlib/assert/is-string';\n*\n* var bool = isString( 'beep' );\n* // returns true\n*\n* bool = isString( new String( 'beep' ) );\n* // returns true\n*\n* bool = isString( 5 );\n* // returns false\n*\n* @example\n* import { isObject as isString } from '@stdlib/assert/is-string';\n*\n* var bool = isString( new String( 'beep' ) );\n* // returns true\n*\n* bool = isString( 'beep' );\n* // returns false\n*\n* @example\n* import { isPrimitive as isString } from '@stdlib/assert/is-string';\n*\n* var bool = isString( 'beep' );\n* // returns true\n*\n* bool = isString( new String( 'beep' ) );\n* // returns false\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of strings.\n*\n* @module @stdlib/assert/is-string-array\n*\n* @example\n* import isStringArray from '@stdlib/assert/is-string-array';\n*\n* var bool = isStringArray( [ 'abc', 'def' ] );\n* // returns true\n*\n* bool = isStringArray( [ 'abc', 123 ] );\n* // returns false\n*\n* @example\n* import { primitives as isStringArray } from '@stdlib/assert/is-string-array';\n*\n* var bool = isStringArray( [ 'abc', 'def' ] );\n* // returns true\n*\n* bool = isStringArray( [ 'abc', new String( 'def' ) ] );\n* // returns false\n*\n* @example\n* import { objects as isStringArray } from '@stdlib/assert/is-string-array';\n*\n* var bool = isStringArray( [ new String( 'abc' ), new String( 'def' ) ] );\n* // returns true\n*\n* bool = isStringArray( [ new String( 'abc' ), 'def' ] );\n* // returns false\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport arrayfun from './../../tools/array-function';\nimport isString from './../../is-string';\n\n\n// VARIABLES //\n\nvar isPrimitiveArray = arrayfun( isString.isPrimitive );\nvar isObjectArray = arrayfun( isString.isObject );\n\n\n// MAIN //\n\nvar isStringArray = arrayfun( isString );\nsetReadOnly( isStringArray, 'primitives', isPrimitiveArray );\nsetReadOnly( isStringArray, 'objects', isObjectArray );\n\n\n// EXPORTS //\n\nexport default isStringArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nvar RE = /./;\n\n\n// EXPORTS //\n\nexport default RE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a boolean primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a boolean primitive\n*\n* @example\n* var bool = isBoolean( true );\n* // returns true\n*\n* @example\n* var bool = isBoolean( false );\n* // returns true\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n*\n* var bool = isBoolean( new Boolean( true ) );\n* // returns false\n*/\nfunction isBoolean( value ) {\n\treturn ( typeof value === 'boolean' );\n}\n\n\n// EXPORTS //\n\nexport default isBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a boolean.\n*\n* @name Boolean\n* @constructor\n* @type {Function}\n* @param {*} value - input value\n* @returns {(boolean|Boolean)} boolean\n*\n* @example\n* var b = Boolean( null );\n* // returns false\n*\n* b = Boolean( [] );\n* // returns true\n*\n* b = Boolean( {} );\n* // returns true\n*\n* @example\n* var b = new Boolean( false );\n* // returns \n*/\nvar Bool = Boolean; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// eslint-disable-next-line stdlib/no-redeclare\nvar toString = Boolean.prototype.toString; // non-generic\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasToStringTag from './../../has-tostringtag-support';\nimport nativeClass from '@stdlib/utils/native-class';\nimport Boolean from '@stdlib/boolean/ctor';\nimport test from './try2serialize.js';\n\n\n// VARIABLES //\n\nvar FLG = hasToStringTag();\n\n\n// MAIN //\n\n/**\n* Tests if a value is a boolean object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a boolean object\n*\n* @example\n* var bool = isBoolean( true );\n* // returns false\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n*\n* var bool = isBoolean( new Boolean( false ) );\n* // returns true\n*/\nfunction isBoolean( value ) {\n\tif ( typeof value === 'object' ) {\n\t\tif ( value instanceof Boolean ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( FLG ) {\n\t\t\treturn test( value );\n\t\t}\n\t\treturn ( nativeClass( value ) === '[object Boolean]' );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\n\n\n// MAIN //\n\n/**\n* Attempts to serialize a value to a string.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value can be serialized\n*/\nfunction test( value ) {\n\ttry {\n\t\ttoString.call( value );\n\t\treturn true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default test;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a boolean.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a boolean\n*\n* @example\n* var bool = isBoolean( false );\n* // returns true\n*\n* @example\n* var bool = isBoolean( true );\n* // returns true\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n*\n* var bool = isBoolean( new Boolean( false ) );\n* // returns true\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n*\n* var bool = isBoolean( new Boolean( true ) );\n* // returns true\n*/\nfunction isBoolean( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is a boolean.\n*\n* @module @stdlib/assert/is-boolean\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n* import isBoolean from '@stdlib/assert/is-boolean';\n*\n* var bool = isBoolean( false );\n* // returns true\n*\n* bool = isBoolean( new Boolean( false ) );\n* // returns true\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n* import { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\n*\n* var bool = isBoolean( false );\n* // returns true\n*\n* bool = isBoolean( new Boolean( true ) );\n* // returns false\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n* import { isObject as isBoolean } from '@stdlib/assert/is-boolean';\n*\n* var bool = isBoolean( true );\n* // returns false\n*\n* bool = isBoolean( new Boolean( false ) );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar obj = ( typeof self === 'object' ) ? self : null;\n\n\n// EXPORTS //\n\nexport default obj;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar obj = ( typeof window === 'object' ) ? window : null;\n\n\n// EXPORTS //\n\nexport default obj;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar obj = ( typeof globalThis === 'object' ) ? globalThis : null; // eslint-disable-line no-undef\n\n\n// EXPORTS //\n\nexport default obj;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getGlobal from './../../../global';\n\n\n// MAIN //\n\nvar root = getGlobal();\nvar nodeList = root.document && root.document.childNodes;\n\n\n// EXPORTS //\n\nexport default nodeList;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport format from '@stdlib/string/format';\nimport getThis from './codegen.js';\nimport Self from './self.js';\nimport Win from './window.js';\nimport GlobalThis from './global_this.js';\n\n\n// MAIN //\n\n/**\n* Returns the global object.\n*\n* ## Notes\n*\n* - Using code generation is the **most** reliable way to resolve the global object; however, doing so is likely to violate content security policies (CSPs) in, e.g., Chrome Apps and elsewhere.\n*\n* @private\n* @param {boolean} [codegen=false] - boolean indicating whether to use code generation to resolve the global object\n* @throws {TypeError} must provide a boolean\n* @throws {Error} unable to resolve global object\n* @returns {Object} global object\n*\n* @example\n* var g = getGlobal();\n* // returns {...}\n*/\nfunction getGlobal( codegen ) {\n\tif ( arguments.length ) {\n\t\tif ( !isBoolean( codegen ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a boolean. Value: `%s`.', codegen ) );\n\t\t}\n\t\tif ( codegen ) {\n\t\t\treturn getThis();\n\t\t}\n\t\t// Fall through...\n\t}\n\t// Case: 2020 revision of ECMAScript standard\n\tif ( GlobalThis ) {\n\t\treturn GlobalThis;\n\t}\n\t// Case: browsers and web workers\n\tif ( Self ) {\n\t\treturn Self;\n\t}\n\t// Case: browsers\n\tif ( Win ) {\n\t\treturn Win;\n\t}\n\t// Case: unknown\n\tthrow new Error( 'unexpected error. Unable to resolve global object.' );\n}\n\n\n// EXPORTS //\n\nexport default getGlobal;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the global object using code generation.\n*\n* @private\n* @returns {Object} global object\n*/\nfunction getGlobal() {\n\treturn new Function( 'return this;' )(); // eslint-disable-line no-new-func, stdlib/require-globals\n}\n\n\n// EXPORTS //\n\nexport default getGlobal;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nvar typedarray = Int8Array; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default typedarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Determine a value's type.\n*\n* @module @stdlib/utils/type-of\n*\n* @example\n* import typeOf from '@stdlib/utils/type-of';\n*\n* var str = typeOf( 'a' );\n* // returns 'string'\n*\n* str = typeOf( 5 );\n* // returns 'number'\n*/\n\n// MODULES //\n\nimport usePolyfill from './check.js';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar main = ( usePolyfill() ) ? polyfill : builtin;\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport RE from './fixtures/re.js';\nimport nodeList from './fixtures/nodelist.js';\nimport typedarray from './fixtures/typedarray.js';\n\n\n// MAIN //\n\n/**\n* Checks whether a polyfill is needed when using the `typeof` operator.\n*\n* @private\n* @returns {boolean} boolean indicating whether a polyfill is needed\n*/\nfunction check() {\n\tif (\n\t\t// Chrome 1-12 returns 'function' for regular expression instances (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof):\n\t\ttypeof RE === 'function' ||\n\n\t\t// Safari 8 returns 'object' for typed array and weak map constructors (underscore #1929):\n\t\ttypeof typedarray === 'object' ||\n\n\t\t// PhantomJS 1.9 returns 'function' for `NodeList` instances (underscore #2236):\n\t\ttypeof nodeList === 'function'\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default check;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctorName from './../../constructor-name';\n\n\n// MAIN //\n\n/**\n* Determines a value's type.\n*\n* @param {*} v - input value\n* @returns {string} string indicating the value's type\n*/\nfunction typeOf( v ) {\n\treturn ctorName( v ).toLowerCase();\n}\n\n\n// EXPORTS //\n\nexport default typeOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctorName from './../../constructor-name';\n\n\n// NOTES //\n\n/*\n* Built-in `typeof` operator behavior:\n*\n* ```text\n* typeof null => 'object'\n* typeof undefined => 'undefined'\n* typeof 'a' => 'string'\n* typeof 5 => 'number'\n* typeof NaN => 'number'\n* typeof true => 'boolean'\n* typeof false => 'boolean'\n* typeof {} => 'object'\n* typeof [] => 'object'\n* typeof function foo(){} => 'function'\n* typeof function* foo(){} => 'object'\n* typeof Symbol() => 'symbol'\n* ```\n*\n*/\n\n\n// MAIN //\n\n/**\n* Determines a value's type.\n*\n* @param {*} v - input value\n* @returns {string} string indicating the value's type\n*/\nfunction typeOf( v ) {\n\tvar type;\n\n\t// Address `typeof null` => `object` (see http://wiki.ecmascript.org/doku.php?id=harmony:typeof_null):\n\tif ( v === null ) {\n\t\treturn 'null';\n\t}\n\ttype = typeof v;\n\n\t// If the `typeof` operator returned something other than `object`, we are done. Otherwise, we need to check for an internal class name or search for a constructor.\n\tif ( type === 'object' ) {\n\t\treturn ctorName( v ).toLowerCase();\n\t}\n\treturn type;\n}\n\n\n// EXPORTS //\n\nexport default typeOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport typeOf from '@stdlib/utils/type-of';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a function.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a function\n*\n* @example\n* function beep() {\n* return 'beep';\n* }\n*\n* var bool = isFunction( beep );\n* // returns true\n*/\nfunction isFunction( value ) {\n\t// Note: cannot use `typeof` directly, as various browser engines incorrectly return `'function'` when operating on non-function objects, such as regular expressions and NodeLists.\n\treturn ( typeOf( value ) === 'function' );\n}\n\n\n// EXPORTS //\n\nexport default isFunction;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport defineProperty from '@stdlib/utils/define-property';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport format from '@stdlib/string/format';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar fround = ( typeof Math.fround === 'function' ) ? Math.fround : null; // eslint-disable-line stdlib/no-builtin-math\n\n\n// EXPORTS //\n\nexport default fround;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float32Array === 'function' ) ? Float32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order.\n*\n* @module @stdlib/array/float32\n*\n* @example\n* import ctor from '@stdlib/array/float32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasFloat32ArraySupport from '@stdlib/assert/has-float32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of single-precision floating-point numbers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float32Array from '@stdlib/array/float32';\n\n\n// VARIABLES //\n\nvar FLOAT32_VIEW = new Float32Array( 1 );\n\n\n// MAIN //\n\n/**\n* Converts a double-precision floating-point number to the nearest single-precision floating-point number.\n*\n* @param {number} x - double-precision floating-point number\n* @returns {number} nearest single-precision floating-point number\n*\n* @example\n* var y = float64ToFloat32( 1.337 );\n* // returns 1.3370000123977661\n*/\nfunction float64ToFloat32( x ) {\n\tFLOAT32_VIEW[ 0 ] = x;\n\treturn FLOAT32_VIEW[ 0 ];\n}\n\n\n// EXPORTS //\n\nexport default float64ToFloat32;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Convert a double-precision floating-point number to the nearest single-precision floating-point number.\n*\n* @module @stdlib/number/float64/base/to-float32\n*\n* @example\n* import float64ToFloat32 from '@stdlib/number/float64/base/to-float32';\n*\n* var y = float64ToFloat32( 1.337 );\n* // returns 1.3370000123977661\n*/\n\n// MODULES //\n\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar float64ToFloat32;\nif ( typeof builtin === 'function' ) {\n\tfloat64ToFloat32 = builtin;\n} else {\n\tfloat64ToFloat32 = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default float64ToFloat32;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport defineProperty from '@stdlib/utils/define-property';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport float64ToFloat32 from '@stdlib/number/float64/base/to-float32';\nimport format from '@stdlib/string/format';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 64-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex64} 64-bit complex number\n*\n* @example\n* var z = new Complex64( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex64( real, imag ) {\n\tif ( !( this instanceof Complex64 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': float64ToFloat32( real )\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': float64ToFloat32( imag )\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex64.BYTES_PER_ELEMENT;\n* // returns 4\n*/\nsetReadOnly( Complex64, 'BYTES_PER_ELEMENT', 4 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 4\n*/\nsetReadOnly( Complex64.prototype, 'BYTES_PER_ELEMENT', 4 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex64.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 8\n*/\nsetReadOnly( Complex64.prototype, 'byteLength', 8 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex64.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex64.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex64` instance.\n*\n* @name toJSON\n* @memberof Complex64.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex64', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex64.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex64;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a complex number-like object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex number-like object.\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var x = new Complex128( 4.0, 2.0 );\n* var bool = isComplexLike( x );\n* // returns true\n*\n* x = new Complex64( 4.0, 2.0 );\n* bool = isComplexLike( x );\n* // returns true\n*/\nfunction isComplexLike( value ) {\n\tif ( value instanceof Complex128 || value instanceof Complex64 ) {\n\t\treturn true;\n\t}\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof value.re === 'number' &&\n\t\ttypeof value.im === 'number'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplexLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInteger from './../../../../base/assert/is-integer';\n\n\n// MAIN //\n\n/**\n* Tests if a finite numeric value is an even number.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is an even number\n*\n* @example\n* var bool = isEven( 5.0 );\n* // returns false\n*\n* @example\n* var bool = isEven( -2.0 );\n* // returns true\n*\n* @example\n* var bool = isEven( 0.0 );\n* // returns true\n*\n* @example\n* var bool = isEven( NaN );\n* // returns false\n*/\nfunction isEven( x ) {\n\treturn isInteger( x/2.0 );\n}\n\n\n// EXPORTS //\n\nexport default isEven;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex64';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = 8; // 4 bytes per float32 x (1 real + 1 imag component)\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `Complex64Array`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Complex64Array`\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n*\n* var bool = isComplex64Array( new Complex64Array( 10 ) );\n* // returns true\n*\n* bool = isComplex64Array( [] );\n* // returns false\n*/\nfunction isComplex64Array( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex64Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex64array`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Complex64Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = 16; // 8 bytes per float64 x (1 real + 1 imag component)\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `Complex128Array`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Complex128Array`\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isComplex128Array( new Complex128Array( 10 ) );\n* // returns true\n*\n* bool = isComplex128Array( [] );\n* // returns false\n*/\nfunction isComplex128Array( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex128Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex128array`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Complex128Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex128Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasOwnProp from './../../has-own-property';\nimport Symbol from '@stdlib/symbol/ctor';\n\n\n// MAIN //\n\n/**\n* Tests for native `Symbol.iterator` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Symbol.iterator` support\n*\n* @example\n* var bool = hasIteratorSymbolSupport();\n* // returns \n*/\nfunction hasIteratorSymbolSupport() {\n\treturn (\n\t\ttypeof Symbol === 'function' &&\n\t\ttypeof Symbol( 'foo' ) === 'symbol' &&\n\t\thasOwnProp( Symbol, 'iterator' ) &&\n\t\ttypeof Symbol.iterator === 'symbol'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default hasIteratorSymbolSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\n\n\n// MAIN //\n\n/**\n* Iterator symbol.\n*\n* @name IteratorSymbol\n* @constant\n* @type {(symbol|null)}\n*\n* @example\n* function iterator() {\n* var it;\n* var i;\n*\n* i = -1;\n*\n* it = {};\n* it.next = next;\n* it.return = done;\n*\n* if ( IteratorSymbol ) {\n* it[ IteratorSymbol ] = iterator;\n* }\n* return it;\n*\n* function next() {\n* i += 1;\n* return {\n* 'value': i,\n* 'done': false\n* };\n* }\n*\n* function done( value ) {\n* if ( arguments.length === 0 ) {\n* return {\n* 'done': true\n* };\n* }\n* return {\n* 'value': value,\n* 'done': true\n* };\n* }\n* }\n*\n* var obj = iterator();\n*/\nvar IteratorSymbol = ( hasIteratorSymbolSupport() ) ? Symbol.iterator : null;\n\n\n// EXPORTS //\n\nexport default IteratorSymbol;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a non-enumerable read-only accessor.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Function} getter - accessor\n*\n* @example\n* function getter() {\n* return 'bar';\n* }\n*\n* var obj = {};\n*\n* setNonEnumerableReadOnlyAccessor( obj, 'foo', getter );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setNonEnumerableReadOnlyAccessor( obj, prop, getter ) { // eslint-disable-line id-length\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'get': getter\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setNonEnumerableReadOnlyAccessor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Returns the real component of a single-precision complex floating-point number.\n*\n* @param {Complex} z - complex number\n* @returns {number} real component\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var re = real( z );\n* // returns 5.0\n*/\nfunction real( z ) {\n\treturn z.re;\n}\n\n\n// EXPORTS //\n\nexport default real;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Returns the imaginary component of a single-precision complex floating-point number.\n*\n* @param {Complex} z - complex number\n* @returns {number} imaginary component\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var im = imag( z );\n* // returns 3.0\n*/\nfunction imag( z ) {\n\treturn z.im;\n}\n\n\n// EXPORTS //\n\nexport default imag;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float32Array from '@stdlib/array/float32';\n\n\n// MAIN //\n\n/**\n* Reinterprets a `Complex64Array` as a `Float32Array`.\n*\n* @param {Complex64Array} x - input array\n* @param {NonNegativeInteger} offset - starting index\n* @returns {Float32Array} `Float32Array` view\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n*\n* var x = new Complex64Array( 10 );\n*\n* var out = reinterpret( x, 0 );\n* // returns \n*\n* var bool = ( out.buffer === x.buffer );\n* // returns true\n*/\nfunction reinterpret( x, offset ) {\n\treturn new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), 2*(x.length-offset) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default reinterpret;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float64Array === 'function' ) ? Float64Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in the platform byte order.\n*\n* @module @stdlib/array/float64\n*\n* @example\n* import ctor from '@stdlib/array/float64';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasFloat64ArraySupport from '@stdlib/assert/has-float64array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat64ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of double-precision floating-point numbers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from '@stdlib/array/float64';\n\n\n// MAIN //\n\n/**\n* Reinterprets a `Complex128Array` as a `Float64Array`.\n*\n* @param {Complex128Array} x - input array\n* @param {NonNegativeInteger} offset - starting index\n* @returns {Float64Array} `Float64Array` view\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var x = new Complex128Array( 10 );\n*\n* var out = reinterpret( x, 0 );\n* // returns \n*\n* var bool = ( out.buffer === x.buffer );\n* // returns true\n*/\nfunction reinterpret( x, offset ) {\n\treturn new Float64Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), 2*(x.length-offset) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default reinterpret;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tz = v.value;\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( realf( z ), imagf( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/* eslint-disable no-restricted-syntax, max-lines, no-invalid-this */\n\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isArray from '@stdlib/assert/is-array';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport isFunction from '@stdlib/assert/is-function';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport isEven from '@stdlib/math/base/assert/is-even';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport isComplex64Array from './../../base/assert/is-complex64array';\nimport isComplex128Array from './../../base/assert/is-complex128array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Float32Array from './../../float32';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport format from '@stdlib/string/format';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport floor from '@stdlib/math/base/special/floor';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Float32Array.BYTES_PER_ELEMENT * 2;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a complex typed array.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*/\nfunction isComplexArray( value ) {\n\treturn (\n\t\tvalue instanceof Complex64Array ||\n\t\t(\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex64Array' ||\n\t\t\t\tvalue.constructor.name === 'Complex128Array'\n\t\t\t) &&\n\t\t\ttypeof value._length === 'number' && // eslint-disable-line no-underscore-dangle\n\n\t\t\t// NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks...\n\t\t\ttypeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle\n\t\t)\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a complex typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array constructor\n*/\nfunction isComplexArrayConstructor( value ) {\n\treturn (\n\t\tvalue === Complex64Array ||\n\n\t\t// NOTE: weaker test in order to avoid a circular dependency with Complex128Array...\n\t\tvalue.name === 'Complex128Array'\n\t);\n}\n\n/**\n* Retrieves a complex number from a complex number array buffer.\n*\n* @private\n* @param {Float32Array} buf - array buffer\n* @param {NonNegativeInteger} idx - element index\n* @returns {Complex64} complex number\n*/\nfunction getComplex64( buf, idx ) {\n\tidx *= 2;\n\treturn new Complex64( buf[ idx ], buf[ idx+1 ] );\n}\n\n\n// MAIN //\n\n/**\n* 64-bit complex number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `8`\n* @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `8`\n* @throws {TypeError} view length must be a positive multiple of `8`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex64Array} complex number array\n*\n* @example\n* var arr = new Complex64Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Complex64Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Complex64Array( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Complex64Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Complex64Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex64Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Complex64Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Complex64Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Complex64Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Complex64Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Complex64Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Complex64Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Float32Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\tif ( isNonNegativeInteger( arguments[0] ) ) {\n\t\t\tbuf = new Float32Array( arguments[0]*2 );\n\t\t} else if ( isCollection( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tlen = buf.length;\n\n\t\t\t// If provided a \"generic\" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to \"normal\" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number...\n\t\t\tif ( len && isArray( buf ) && isComplexLike( buf[0] ) ) {\n\t\t\t\tbuf = fromArray( new Float32Array( len*2 ), buf );\n\t\t\t\tif ( buf === null ) {\n\t\t\t\t\t// We failed and we are now forced to allocate a new array :-(\n\t\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t\t}\n\t\t\t\t\t// We failed, so fall back to directly setting values...\n\t\t\t\t\tbuf = new Float32Array( arguments[0] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( isComplex64Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret64( buf, 0 );\n\t\t\t\t} else if ( isComplex128Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret128( buf, 0 );\n\t\t\t\t} else if ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tbuf = new Float32Array( buf );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf );\n\t\t} else if ( isObject( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tif ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = buf[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); // FIXME: `buf` is what is returned from above, NOT the original value\n\t\t\t}\n\t\t\tbuf = fromIterator( buf );\n\t\t\tif ( buf instanceof Error ) {\n\t\t\t\tthrow buf;\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arguments[0] ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf, byteOffset, len*2 );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length/2 );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64Array\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var nbytes = Complex64Array.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex64Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex64Array\n* @readonly\n* @type {string}\n* @default 'Complex64Array'\n*\n* @example\n* var str = Complex64Array.name;\n* // returns 'Complex64Array'\n*/\nsetReadOnly( Complex64Array, 'name', 'Complex64Array' );\n\n/**\n* Creates a new 64-bit complex number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Complex64Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex64Array} 64-bit complex number array\n*\n* @example\n* var arr = Complex64Array.from( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function clbk( v ) {\n* return new Complex64( realf(v)*2.0, imagf(v)*2.0 );\n* }\n*\n* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*/\nsetReadOnly( Complex64Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar flg;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isComplexArray( src ) ) {\n\t\tlen = src.length;\n\t\tif ( clbk ) {\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, src.get( i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = realf( v );\n\t\t\t\t\tbuf[ j+1 ] = imagf( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\t// Note: array contents affect how we iterate over a provided data source. If only complex number objects, we can extract real and imaginary components. Otherwise, for non-complex number arrays (e.g., `Float64Array`, etc), we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component.\n\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\t// Detect whether we've been provided an array which returns complex number objects...\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tif ( !isComplexLike( get( src, i ) ) ) {\n\t\t\t\t\tflg = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If an array does not contain only complex number objects, then we assume interleaved real and imaginary components...\n\t\t\tif ( flg ) {\n\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. First argument must have a length which is a multiple of %u. Length: `%u`.', 2, len ) );\n\t\t\t\t}\n\t\t\t\tout = new this( len/2 );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ i ] = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\t// If an array contains only complex number objects, then we need to extract real and imaginary components...\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = realf( v );\n\t\t\t\t\tbuf[ j+1 ] = imagf( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length / 2;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 64-bit complex number array from a variable number of arguments.\n*\n* @name of\n* @memberof Complex64Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} 64-bit complex number array\n*\n* @example\n* var arr = Complex64Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Complex64Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide an integer\n* @returns {(Complex64|void)} array element\n*\n* @example\n* var arr = new Complex64Array( 10 );\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var z = arr.at( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 9.0, -9.0 ], 9 );\n*\n* z = arr.at( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*\n* z = arr.at( -1 );\n* // returns \n*\n* re = realf( z );\n* // returns 9.0\n*\n* im = imagf( z );\n* // returns -9.0\n*\n* z = arr.at( 100 );\n* // returns undefined\n*\n* z = arr.at( -100 );\n* // returns undefined\n*/\nsetReadOnly( Complex64Array.prototype, 'at', function at( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex64( this._buffer, idx );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 80\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex64Array.prototype, 'BYTES_PER_ELEMENT', Complex64Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} modified array\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 4 );\n*\n* // Set the array elements:\n* arr.set( new Complex64( 1.0, 1.0 ), 0 );\n* arr.set( new Complex64( 2.0, 2.0 ), 1 );\n* arr.set( new Complex64( 3.0, 3.0 ), 2 );\n* arr.set( new Complex64( 4.0, 4.0 ), 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* // Get the last array element:\n* var z = arr.get( 3 );\n*\n* var re = realf( z );\n* // returns 2.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex64Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target*2, start*2 );\n\t} else {\n\t\tthis._buffer.copyWithin( target*2, start*2, arguments[2]*2 );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = [\n* new Complex64( 1.0, 1.0 ),\n* new Complex64( 2.0, 2.0 ),\n* new Complex64( 3.0, 3.0 )\n* ];\n* arr = new Complex64Array( arr );\n*\n* // Create an iterator:\n* var it = arr.entries();\n*\n* // Iterate over the key-value pairs...\n* var v = it.next().value;\n* // returns [ 0, ]\n*\n* v = it.next().value;\n* // returns [ 1, ]\n*\n* v = it.next().value;\n* // returns [ 2, ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, getComplex64( buf, i ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, getComplex64( buf, i ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Complex64Array} modified array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.fill( new Complex64( 1.0, 1.0 ), 1 );\n*\n* var z = arr.get( 1 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 1.0\n*\n* z = arr.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tre = realf( value );\n\tim = imagf( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tidx = 2*i;\n\t\tbuf[ idx ] = re;\n\t\tbuf[ idx+1 ] = im;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 1\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 2.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex64Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\tout.push( z );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex64|void)} array element or undefined\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.find( predicate );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var idx = arr.findIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( Complex64Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex64|void)} array element or undefined\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.findLast( predicate );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var idx = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Complex64Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Complex64Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tfcn.call( thisArg, z, i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(Complex64|void)} array element\n*\n* @example\n* var arr = new Complex64Array( 10 );\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*\n* z = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( Complex64Array.prototype, 'get', function get( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex64( this._buffer, idx );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a provided value\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var bool = arr.includes( new Complex64( 3.0, -3.0 ) );\n* // returns true\n*\n* bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 );\n* // returns false\n*\n* bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 10 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) );\n* // returns 2\n*\n* idx = arr.indexOf( new Complex64( 3.0, -3.0 ), 3 );\n* // returns -1\n*\n* idx = arr.indexOf( new Complex64( 4.0, -4.0 ), -3 );\n* // returns -1\n*/\nsetReadOnly( Complex64Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.join();\n* // returns '1 + 1i,2 + 2i'\n*\n* str = arr.join( '/' );\n* // returns '1 + 1i/2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'join', function join( separator ) {\n\tvar out;\n\tvar buf;\n\tvar sep;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tsep = ',';\n\t} else if ( isString( separator ) ) {\n\t\tsep = separator;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toString() );\n\t}\n\treturn out.join( sep );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex] - index at which to start searching backward (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 3.0, -3.0 ], 4 );\n*\n* var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) );\n* // returns 4\n*\n* idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ), 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( new Complex64( 5.0, -5.0 ), 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), -3 );\n* // returns 1\n*/\nsetReadOnly( Complex64Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function scale( v, i ) {\n* return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 2\n*\n* var im = imagf( z );\n* // returns -2\n*/\nsetReadOnly( Complex64Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fcn.call( thisArg, getComplex64( buf, i ), i, this );\n\t\tif ( isComplexLike( v ) ) {\n\t\t\toutbuf[ 2*i ] = realf( v );\n\t\t\toutbuf[ (2*i)+1 ] = imagf( v );\n\t\t} else if ( isArrayLikeObject( v ) && v.length === 2 ) {\n\t\t\toutbuf[ 2*i ] = v[ 0 ];\n\t\t\toutbuf[ (2*i)+1 ] = v[ 1 ];\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t}\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import caddf from '@stdlib/complex/float32/base/add';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduce( caddf );\n* // returns \n*\n* var re = realf( z );\n* // returns 6.0\n*\n* var im = imagf( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex64( buf, 0 );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tv = getComplex64( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import caddf from '@stdlib/complex/float32/base/add';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduceRight( caddf );\n* // returns \n*\n* var re = realf( z );\n* // returns 6.0\n*\n* var im = imagf( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len-1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex64( buf, len-1 );\n\t\ti = len-2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tv = getComplex64( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} reversed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ (2*i) ];\n\t\tbuf[ (2*i) ] = buf[ (2*j) ];\n\t\tbuf[ (2*j) ] = tmp;\n\t\ttmp = buf[ (2*i)+1 ];\n\t\tbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t\tbuf[ (2*j)+1 ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'set', function set( value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tidx *= 2;\n\t\tbuf[ idx ] = realf( value );\n\t\tbuf[ idx+1 ] = imagf( value );\n\t\treturn;\n\t}\n\tif ( isComplexArray( value ) ) {\n\t\tN = value._length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tsbuf = value._buffer;\n\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Float32Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tidx *= 2;\n\t\tj = 0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\tidx += 2; // stride\n\t\t\tj += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// Detect whether we've been provided an array of complex numbers...\n\t\tN = value.length;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tif ( !isComplexLike( value[ i ] ) ) {\n\t\t\t\tflg = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// If an array does not contain only complex numbers, then we assume interleaved real and imaginary components...\n\t\tif ( flg ) {\n\t\t\tif ( !isEven( N ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', N ) );\n\t\t\t}\n\t\t\tif ( idx+(N/2) > this._length ) {\n\t\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t\t}\n\t\t\tsbuf = value;\n\n\t\t\t// Check for overlapping memory...\n\t\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\t\tif (\n\t\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t\t(\n\t\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// We need to copy source values...\n\t\t\t\ttmp = new Float32Array( N );\n\t\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\t\ttmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays\n\t\t\t\t}\n\t\t\t\tsbuf = tmp;\n\t\t\t}\n\t\t\tidx *= 2;\n\t\t\tN /= 2;\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\t\tidx += 2; // stride\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// If an array contains only complex numbers, then we need to extract real and imaginary components...\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tidx *= 2;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tv = value[ i ];\n\t\t\tbuf[ idx ] = realf( v );\n\t\t\tbuf[ idx+1 ] = imagf( v );\n\t\t\tidx += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.', value ) );\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 5.0\n*\n* im = imagf( z );\n* // returns -5.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* z = out.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'slice', function slice( start, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar idx;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tstart = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( start < end ) {\n\t\toutlen = end - start;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\tidx = 2*(i+start);\n\t\toutbuf[ 2*i ] = buf[ idx ];\n\t\toutbuf[ (2*i)+1 ] = buf[ idx+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, getComplex64( buf, i ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} sorted array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = realf( a );\n* re2 = realf( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imagf( a );\n* im2 = imagf( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex64( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = 2 * i;\n\t\tbuf[ j ] = realf( tmp[i] );\n\t\tbuf[ j+1 ] = imagf( tmp[i] );\n\t}\n\treturn this;\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} [begin=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} subarray\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var z = subarr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 5.0\n*\n* im = imagf( z );\n* // returns -5.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* z = subarr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + (begin*BYTES_PER_ELEMENT);\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toLocaleString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} reversed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = len - i - 1;\n\t\toutbuf[ (2*i) ] = buf[ (2*j) ];\n\t\toutbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} sorted array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = realf( a );\n* re2 = realf( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imagf( a );\n* im2 = imagf( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex64( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\treturn new Complex64Array( tmp );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toString() );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns \n*\n* var re = realf( v );\n* // returns 1.0\n*\n* var im = imagf( v );\n* // returns -1.0\n*\n* v = iter.next().value;\n* // returns \n*\n* re = realf( v );\n* // returns 2.0\n*\n* im = imagf( v );\n* // returns -2.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': getComplex64( buf, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {ComplexLike} value - new value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a complex number\n* @returns {Complex64Array} new typed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.with( 0, new Complex64( 4.0, 4.0 ) );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 4.0\n*\n* var im = imagf( z );\n* // returns 4.0\n*/\nsetReadOnly( Complex64Array.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tbuf[ 2*index ] = realf( value );\n\tbuf[ (2*index)+1 ] = imagf( value );\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Complex64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\n\n\n// MAIN //\n\n/**\n* Returns a strided array of real and imaginary components.\n*\n* @private\n* @param {Float32Array} buf - output array\n* @param {Array} arr - array containing complex numbers\n* @returns {(Float32Array|null)} output array or null\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tlen = arr.length;\n\tj = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = arr[ i ];\n\t\tif ( !isComplexLike( v ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tbuf[ j ] = realf( v );\n\t\tbuf[ j+1 ] = imagf( v );\n\t\tj += 2; // stride\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Returns the real component of a double-precision complex floating-point number.\n*\n* @param {Complex} z - complex number\n* @returns {number} real component\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var re = real( z );\n* // returns 5.0\n*/\nfunction real( z ) {\n\treturn z.re;\n}\n\n\n// EXPORTS //\n\nexport default real;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Returns the imaginary component of a double-precision complex floating-point number.\n*\n* @param {Complex} z - complex number\n* @returns {number} imaginary component\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var im = imag( z );\n* // returns 3.0\n*/\nfunction imag( z ) {\n\treturn z.im;\n}\n\n\n// EXPORTS //\n\nexport default imag;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport format from '@stdlib/string/format';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tz = v.value;\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( real( z ), imag( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tz = clbk.call( thisArg, v.value, i );\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( realf( z ), imagf( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/* eslint-disable no-restricted-syntax, max-lines, no-invalid-this */\n\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isArray from '@stdlib/assert/is-array';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport isString from '@stdlib/assert/is-string';\nimport isFunction from '@stdlib/assert/is-function';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport isEven from '@stdlib/math/base/assert/is-even';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport isComplex64Array from './../../base/assert/is-complex64array';\nimport isComplex128Array from './../../base/assert/is-complex128array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Float64Array from './../../float64';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport floor from '@stdlib/math/base/special/floor';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Float64Array.BYTES_PER_ELEMENT * 2;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a complex typed array.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*/\nfunction isComplexArray( value ) {\n\treturn (\n\t\tvalue instanceof Complex128Array ||\n\t\t(\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex64Array' ||\n\t\t\t\tvalue.constructor.name === 'Complex128Array'\n\t\t\t) &&\n\t\t\ttypeof value._length === 'number' && // eslint-disable-line no-underscore-dangle\n\n\t\t\t// NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks...\n\t\t\ttypeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle\n\t\t)\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a complex typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array constructor\n*/\nfunction isComplexArrayConstructor( value ) {\n\treturn (\n\t\tvalue === Complex128Array ||\n\n\t\t// NOTE: weaker test in order to avoid a circular dependency with Complex64Array...\n\t\tvalue.name === 'Complex64Array'\n\t);\n}\n\n/**\n* Retrieves a complex number from a complex number array buffer.\n*\n* @private\n* @param {Float64Array} buf - array buffer\n* @param {NonNegativeInteger} idx - element index\n* @returns {Complex128} complex number\n*/\nfunction getComplex128( buf, idx ) {\n\tidx *= 2;\n\treturn new Complex128( buf[ idx ], buf[ idx+1 ] );\n}\n\n\n// MAIN //\n\n/**\n* 128-bit complex number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `16`\n* @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `16`\n* @throws {TypeError} view length must be a positive multiple of `16`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex128Array} complex number array\n*\n* @example\n* var arr = new Complex128Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Complex128Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Complex128Array( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex128Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex128Array( buf, 16 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 64 );\n* var arr = new Complex128Array( buf, 16, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Complex128Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Complex128Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Complex128Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Complex128Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Complex128Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Complex128Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Float64Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\tif ( isNonNegativeInteger( arguments[0] ) ) {\n\t\t\tbuf = new Float64Array( arguments[0]*2 );\n\t\t} else if ( isCollection( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tlen = buf.length;\n\n\t\t\t// If provided a \"generic\" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to \"normal\" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number...\n\t\t\tif ( len && isArray( buf ) && isComplexLike( buf[0] ) ) {\n\t\t\t\tbuf = fromArray( new Float64Array( len*2 ), buf );\n\t\t\t\tif ( buf === null ) {\n\t\t\t\t\t// We failed and we are now forced to allocate a new array :-(\n\t\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t\t}\n\t\t\t\t\t// We failed, so fall back to directly setting values...\n\t\t\t\t\tbuf = new Float64Array( arguments[0] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( isComplex64Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret64( buf, 0 );\n\t\t\t\t} else if ( isComplex128Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret128( buf, 0 );\n\t\t\t\t} else if ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tbuf = new Float64Array( buf );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf );\n\t\t} else if ( isObject( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tif ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = buf[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = fromIterator( buf );\n\t\t\tif ( buf instanceof Error ) {\n\t\t\t\tthrow buf;\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arguments[0] ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf, byteOffset, len*2 );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length/2 );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128Array\n* @readonly\n* @type {PositiveInteger}\n* @default 16\n*\n* @example\n* var nbytes = Complex128Array.BYTES_PER_ELEMENT;\n* // returns 16\n*/\nsetReadOnly( Complex128Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128Array\n* @readonly\n* @type {string}\n* @default 'Complex128Array'\n*\n* @example\n* var name = Complex128Array.name;\n* // returns 'Complex128Array'\n*/\nsetReadOnly( Complex128Array, 'name', 'Complex128Array' );\n\n/**\n* Creates a new 128-bit complex number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Complex128Array\n* @type {Function}\n* @param {(Collection|Object)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex128Array} 128-bit complex number array\n*\n* @example\n* var arr = Complex128Array.from( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function clbk( v ) {\n* return new Complex128( real(v)*2.0, imag(v)*2.0 );\n* }\n*\n* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*/\nsetReadOnly( Complex128Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar flg;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isComplexArray( src ) ) {\n\t\tlen = src.length;\n\t\tif ( clbk ) {\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, src.get( i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = real( v );\n\t\t\t\t\tbuf[ j+1 ] = imag( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\t// Note: array contents affect how we iterate over a provided data source. If only complex number objects, we can extract real and imaginary components. Otherwise, for non-complex number arrays (e.g., `Float64Array`, etc), we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component.\n\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\t// Detect whether we've been provided an array which returns complex number objects...\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tif ( !isComplexLike( get( src, i ) ) ) {\n\t\t\t\t\tflg = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If an array does not contain only complex number objects, then we assume interleaved real and imaginary components...\n\t\t\tif ( flg ) {\n\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. First argument must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tout = new this( len/2 );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ i ] = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\t// If an array contains only complex number objects, then we need to extract real and imaginary components...\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = real( v );\n\t\t\t\t\tbuf[ j+1 ] = imag( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length / 2;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 128-bit complex number array from a variable number of arguments.\n*\n* @name of\n* @memberof Complex128Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} 128-bit complex number array\n*\n* @example\n* var arr = Complex128Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Complex128Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide an integer\n* @returns {(Complex128|void)} array element\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 10 );\n*\n* var z = arr.at( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 9.0, -9.0 ], 9 );\n*\n* z = arr.at( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*\n* z = arr.at( -1 );\n* // returns \n*\n* re = real( z );\n* // returns 9.0\n*\n* im = imag( z );\n* // returns -9.0\n*\n* z = arr.at( 100 );\n* // returns undefined\n*\n* z = arr.at( -100 );\n* // returns undefined\n*/\nsetReadOnly( Complex128Array.prototype, 'at', function at( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex128( this._buffer, idx );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 160\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 16\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 16\n*/\nsetReadOnly( Complex128Array.prototype, 'BYTES_PER_ELEMENT', Complex128Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} modified array\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 4 );\n*\n* // Set the array elements:\n* arr.set( new Complex128( 1.0, 1.0 ), 0 );\n* arr.set( new Complex128( 2.0, 2.0 ), 1 );\n* arr.set( new Complex128( 3.0, 3.0 ), 2 );\n* arr.set( new Complex128( 4.0, 4.0 ), 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* // Get the last array element:\n* var z = arr.get( 3 );\n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target*2, start*2 );\n\t} else {\n\t\tthis._buffer.copyWithin( target*2, start*2, arguments[2]*2 );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = [\n* new Complex128( 1.0, 1.0 ),\n* new Complex128( 2.0, 2.0 ),\n* new Complex128( 3.0, 3.0 )\n* ];\n* arr = new Complex128Array( arr );\n*\n* // Create an iterator:\n* var it = arr.entries();\n*\n* // Iterate over the key-value pairs...\n* var v = it.next().value;\n* // returns [ 0, ]\n*\n* v = it.next().value;\n* // returns [ 1, ]\n*\n* v = it.next().value;\n* // returns [ 2, ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'entries', function entries() {\n\tvar buffer;\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuffer = this._buffer;\n\tlen = this._length;\n\n\t// Initialize the iteration indices:\n\ti = -1;\n\tj = -2;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\tvar z;\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tj += 2;\n\t\tz = new Complex128( buffer[ j ], buffer[ j+1 ] );\n\t\treturn {\n\t\t\t'value': [ i, z ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, getComplex128( buf, i ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Complex128Array} modified array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.fill( new Complex128( 1.0, 1.0 ), 1 );\n*\n* var z = arr.get( 1 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns 1.0\n*\n* z = arr.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tre = real( value );\n\tim = imag( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tidx = 2*i;\n\t\tbuf[ idx ] = re;\n\t\tbuf[ idx+1 ] = im;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 1\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\tout.push( z );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex128|void)} array element or undefined\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.find( predicate );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var idx = arr.findIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( Complex128Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex128|void)} array element or undefined\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.findLast( predicate );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var idx = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Complex128Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Complex128Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tfcn.call( thisArg, z, i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(Complex128|void)} array element\n*\n* @example\n* var arr = new Complex128Array( 10 );\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*\n* z = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( Complex128Array.prototype, 'get', function get( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex128( this._buffer, idx );\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a provided value\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var bool = arr.includes( new Complex128( 3.0, -3.0 ) );\n* // returns true\n*\n* bool = arr.includes( new Complex128( 3.0, -3.0 ), 3 );\n* // returns false\n*\n* bool = arr.includes( new Complex128( 4.0, -4.0 ), -3 );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var idx = arr.indexOf( new Complex128( 3.0, -3.0 ) );\n* // returns 2\n*\n* idx = arr.indexOf( new Complex128( 3.0, -3.0 ), 3 );\n* // returns -1\n*\n* idx = arr.indexOf( new Complex128( 4.0, -4.0 ), -3 );\n* // returns 3\n*/\nsetReadOnly( Complex128Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.join();\n* // returns '1 + 1i,2 + 2i'\n*\n* str = arr.join( '/' );\n* // returns '1 + 1i/2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'join', function join( separator ) {\n\tvar out;\n\tvar buf;\n\tvar sep;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tsep = ',';\n\t} else if ( isString( separator ) ) {\n\t\tsep = separator;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toString() );\n\t}\n\treturn out.join( sep );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex] - index at which to start searching backward (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 3.0, -3.0 ], 4 );\n*\n* var idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ) );\n* // returns 4\n*\n* idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ), 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( new Complex128( 5.0, -5.0 ), 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), -3 );\n* // returns 1\n*/\nsetReadOnly( Complex128Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function scale( v, i ) {\n* return new Complex128( 2.0*real( v ), 2.0*imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns -2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fcn.call( thisArg, getComplex128( buf, i ), i, this );\n\t\tif ( isComplexLike( v ) ) {\n\t\t\toutbuf[ 2*i ] = real( v );\n\t\t\toutbuf[ (2*i)+1 ] = imag( v );\n\t\t} else if ( isArrayLikeObject( v ) && v.length === 2 ) {\n\t\t\toutbuf[ 2*i ] = v[ 0 ];\n\t\t\toutbuf[ (2*i)+1 ] = v[ 1 ];\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t}\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import cadd from '@stdlib/complex/float64/base/add';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduce( cadd );\n* // returns \n*\n* var re = real( z );\n* // returns 6.0\n*\n* var im = imag( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex128( buf, 0 );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tv = getComplex128( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import cadd from '@stdlib/complex/float64/base/add';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduceRight( cadd );\n* // returns \n*\n* var re = real( z );\n* // returns 6.0\n*\n* var im = imag( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len-1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex128( buf, len-1 );\n\t\ti = len-2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tv = getComplex128( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} reversed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ (2*i) ];\n\t\tbuf[ (2*i) ] = buf[ (2*j) ];\n\t\tbuf[ (2*j) ] = tmp;\n\t\ttmp = buf[ (2*i)+1 ];\n\t\tbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t\tbuf[ (2*j)+1 ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended.\n*\n* @name set\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'set', function set( value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tidx *= 2;\n\t\tbuf[ idx ] = real( value );\n\t\tbuf[ idx+1 ] = imag( value );\n\t\treturn;\n\t}\n\tif ( isComplexArray( value ) ) {\n\t\tN = value._length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tsbuf = value._buffer;\n\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Float64Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tidx *= 2;\n\t\tj = 0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\tidx += 2; // stride\n\t\t\tj += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// Detect whether we've been provided an array of complex numbers...\n\t\tN = value.length;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tif ( !isComplexLike( value[ i ] ) ) {\n\t\t\t\tflg = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// If an array does not contain only complex numbers, then we assume interleaved real and imaginary components...\n\t\tif ( flg ) {\n\t\t\tif ( !isEven( N ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', N ) );\n\t\t\t}\n\t\t\tif ( idx+(N/2) > this._length ) {\n\t\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t\t}\n\t\t\tsbuf = value;\n\n\t\t\t// Check for overlapping memory...\n\t\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\t\tif (\n\t\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t\t(\n\t\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// We need to copy source values...\n\t\t\t\ttmp = new Float64Array( N );\n\t\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t\t}\n\t\t\t\tsbuf = tmp;\n\t\t\t}\n\t\t\tidx *= 2;\n\t\t\tN /= 2;\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\t\tidx += 2; // stride\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// If an array contains only complex numbers, then we need to extract real and imaginary components...\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tidx *= 2;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tv = value[ i ];\n\t\t\tbuf[ idx ] = real( v );\n\t\t\tbuf[ idx+1 ] = imag( v );\n\t\t\tidx += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.', value ) );\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 5.0\n*\n* im = imag( z );\n* // returns -5.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* z = out.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'slice', function slice( start, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar idx;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tstart = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( start < end ) {\n\t\toutlen = end - start;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\tidx = 2*(i+start);\n\t\toutbuf[ 2*i ] = buf[ idx ];\n\t\toutbuf[ (2*i)+1 ] = buf[ idx+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, getComplex128( buf, i ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} sorted array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = real( a );\n* re2 = real( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imag( a );\n* im2 = imag( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex128( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = 2 * i;\n\t\tbuf[ j ] = real( tmp[i] );\n\t\tbuf[ j+1 ] = imag( tmp[i] );\n\t}\n\treturn this;\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} [begin=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} subarray\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var z = subarr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 5.0\n*\n* im = imag( z );\n* // returns -5.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* z = subarr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toLocaleString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} reversed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = len - i - 1;\n\t\toutbuf[ (2*i) ] = buf[ (2*j) ];\n\t\toutbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} sorted array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = real( a );\n* re2 = real( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imag( a );\n* im2 = imag( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex128( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\treturn new Complex128Array( tmp );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toString() );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns \n*\n* var re = real( v );\n* // returns 1.0\n*\n* var im = imag( v );\n* // returns -1.0\n*\n* v = iter.next().value;\n* // returns \n*\n* re = real( v );\n* // returns 2.0\n*\n* im = imag( v );\n* // returns -2.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': getComplex128( buf, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {ComplexLike} value - new value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a complex number\n* @returns {Complex128Array} new typed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.with( 0, new Complex128( 4.0, 4.0 ) );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 4.0\n*\n* var im = imag( z );\n* // returns 4.0\n*/\nsetReadOnly( Complex128Array.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tbuf[ 2*index ] = real( value );\n\tbuf[ (2*index)+1 ] = imag( value );\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Complex128Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns a strided array of real and imaginary components.\n*\n* @private\n* @param {Float64Array} buf - output array\n* @param {Array} arr - array containing complex numbers\n* @returns {(Float64Array|null)} output array or null\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tlen = arr.length;\n\tj = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = arr[ i ];\n\t\tif ( !isComplexLike( v ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tbuf[ j ] = real( v );\n\t\tbuf[ j+1 ] = imag( v );\n\t\tj += 2; // stride\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( Boolean( v.value ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport format from '@stdlib/string/format';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tz = clbk.call( thisArg, v.value, i );\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( real( z ), imag( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Uint8Array from './../../uint8';\nimport Boolean from '@stdlib/boolean/ctor';\nimport getter from './../../base/getter';\nimport floor from '@stdlib/math/base/special/floor';\nimport accessorGetter from './../../base/accessor-getter';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint8Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `BooleanArray`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `BooleanArray`\n*/\nfunction isBooleanArray( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'BooleanArray' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a boolean typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a boolean typed array constructor\n*/\nfunction isBooleanArrayConstructor( value ) {\n\treturn ( value === BooleanArray );\n}\n\n\n// MAIN //\n\n/**\n* Boolean array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new BooleanArray( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new BooleanArray( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 16\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new BooleanArray( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction BooleanArray() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof BooleanArray) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new BooleanArray();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new BooleanArray( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new BooleanArray( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new BooleanArray( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint8Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tbuf = fromArray( new Uint8Array( arg.length ), arg );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tbuf = new Uint8Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var nbytes = BooleanArray.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof BooleanArray\n* @readonly\n* @type {string}\n* @default 'BooleanArray'\n*\n* @example\n* var str = BooleanArray.name;\n* // returns 'BooleanArray'\n*/\nsetReadOnly( BooleanArray, 'name', 'BooleanArray' );\n\n/**\n* Creates a new boolean array from an array-like object or an iterable.\n*\n* @name from\n* @memberof BooleanArray\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.from( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return !v;\n* }\n*\n* var arr = BooleanArray.from( [ true, false ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( BooleanArray, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = Boolean( clbk.call( thisArg, get( src, i ), i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new boolean array from a variable number of arguments.\n*\n* @name of\n* @memberof BooleanArray\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.of( true, true, true, true );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( BooleanArray, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide an integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.at( 0 );\n* // returns true\n*\n* v = arr.at( -1 );\n* // returns true\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'at', function at( idx ) {\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tif ( idx < 0 ) {\n\t\tidx += len;\n\t}\n\tif ( idx < 0 || idx >= len ) {\n\t\treturn;\n\t}\n\treturn Boolean( buf[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray.prototype, 'BYTES_PER_ELEMENT', BooleanArray.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 4 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n* arr.set( true, 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr.get( 2 );\n* // returns true\n*\n* v = arr.get( 3 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, true ]\n*\n* v = it.next().value;\n* // returns [ 1, false ]\n*\n* v = it.next().value;\n* // returns [ 2, true ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, Boolean( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.fill( true, 1 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar val;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tif ( value ) {\n\t\tval = 1;\n\t} else {\n\t\tval = 0;\n\t}\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = val;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* function predicate( v ) {\n* return ( v === true );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.find( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findIndex( predicate );\n* // returns 0\n*/\nsetReadOnly( BooleanArray.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLast( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( BooleanArray.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, Boolean( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'get', function get( idx ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn Boolean( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var bool = arr.includes( true );\n* // returns true\n*\n* bool = arr.includes( false, 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.indexOf( true );\n* // returns 0\n*\n* idx = arr.indexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.indexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.join();\n* // returns 'true,false,true'\n*\n* str = arr.join( '|' );\n* // returns 'true|false|true'\n*/\nsetReadOnly( BooleanArray.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.lastIndexOf( true );\n* // returns 4\n*\n* idx = arr.lastIndexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} new boolean array\n*\n* @example\n* function invert( v ) {\n* return !v;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.map( invert );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns false\n*\n* z = out.get( 1 );\n* // returns true\n*\n* z = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = Boolean( fcn.call( thisArg, Boolean( buf[ i ] ), i, this ) );\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduce( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduceRight( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(Collection|BooleanArray|*)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isCollection( value ) ) {\n\t\tN = value.length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tif ( isBooleanArray( value ) ) {\n\t\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\t} else {\n\t\t\tsbuf = value;\n\t\t}\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Uint8Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = ( sbuf[ i ] ) ? 1 : 0;\n\t\t}\n\t\treturn;\n\t}\n\tif ( idx >= this._length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t}\n\tbuf[ idx ] = ( value ) ? 1 : 0;\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var bool = out.get( 0 );\n* // returns true\n*\n* bool = out.get( len-1 );\n* // returns true\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* bool = out.get( 0 );\n* // returns false\n*\n* bool = out.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( false, 0 );\n* arr.set( true, 1 );\n* arr.set( false, 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.sort( compare );\n*\n* var v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort();\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {BooleanArray} subarray\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr.get( 0 );\n* // returns true\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr.get( 0 );\n* // returns false\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toLocaleString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( Boolean( buf[ i ] ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*\n* v = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ i ];\n\t}\n\tif ( arguments.length === 0 ) {\n\t\toutbuf.sort();\n\t\treturn out;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\toutbuf.sort( compare );\n\treturn out;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns true\n*\n* v = iter.next().value;\n* // returns false\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': Boolean( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {boolean} value - new value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a boolean\n* @returns {BooleanArray} new typed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.with( 0, false );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a boolean. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tif ( value ) {\n\t\tbuf[ index ] = 1;\n\t} else {\n\t\tbuf[ index ] = 0;\n\t}\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default BooleanArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Fills an output array with \"boolean\" values.\n*\n* @private\n* @param {Uint8Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint8Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = Boolean( arr[ i ] );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( Boolean( clbk.call( thisArg, v.value, i ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Uint32Array from './../../uint32';\nimport Int32Array from './../../int32';\nimport Uint16Array from './../../uint16';\nimport Int16Array from './../../int16';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Int8Array from './../../int8';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\n// Note: order should match `dtypes` order\nvar CTORS = [\n\tFloat64Array,\n\tFloat32Array,\n\tInt32Array,\n\tUint32Array,\n\tInt16Array,\n\tUint16Array,\n\tInt8Array,\n\tUint8Array,\n\tUint8ClampedArray,\n\tComplex64Array,\n\tComplex128Array,\n\tBooleanArray\n];\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Note: order should match `ctors` order\nvar DTYPES = [\n\t'float64',\n\t'float32',\n\t'int32',\n\t'uint32',\n\t'int16',\n\t'uint16',\n\t'int8',\n\t'uint8',\n\t'uint8c',\n\t'complex64',\n\t'complex128',\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isBuffer from '@stdlib/assert/is-buffer';\nimport isArray from '@stdlib/assert/is-array';\nimport constructorName from '@stdlib/utils/constructor-name';\nimport ctor2dtype from './ctor2dtype.js';\nimport CTORS from './ctors.js';\nimport DTYPES from './dtypes.js';\n\n\n// VARIABLES //\n\nvar NTYPES = DTYPES.length;\n\n\n// MAIN //\n\n/**\n* Returns the data type of an array.\n*\n* @param {*} value - input value\n* @returns {(string|null)} data type\n*\n* @example\n* var dt = dtype( [ 1, 2, 3 ] );\n* // returns 'generic'\n*\n* var dt = dtype( 'beep' );\n* // returns null\n*/\nfunction dtype( value ) {\n\tvar i;\n\tif ( isArray( value ) ) {\n\t\treturn 'generic';\n\t}\n\tif ( isBuffer( value ) ) {\n\t\treturn null;\n\t}\n\tfor ( i = 0; i < NTYPES; i++ ) {\n\t\tif ( value instanceof CTORS[ i ] ) {\n\t\t\treturn DTYPES[ i ];\n\t\t}\n\t}\n\t// If the above failed, fall back to a more robust (and significantly slower) means for resolving underlying data types:\n\treturn ctor2dtype[ constructorName( value ) ] || null;\n}\n\n\n// EXPORTS //\n\nexport default dtype;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport getter from './../../../base/getter';\nimport setter from './../../../base/setter';\nimport accessorGetter from './../../../base/accessor-getter';\nimport accessorSetter from './../../../base/accessor-setter';\nimport dtype from './../../../dtype';\n\n\n// MAIN //\n\n/**\n* Returns element accessors for a provided array-like object.\n*\n* ## Notes\n*\n* - The returned object has the following properties:\n*\n* - **accessorProtocol**: `boolean` indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements).\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing accessor data\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var obj = accessors( x );\n* // returns {...}\n*\n* var bool = obj.accessorProtocol;\n* // returns false\n*\n* var fcns = obj.accessors;\n* // returns [ , ]\n*\n* var v = fcns[ 0 ]( x, 2 );\n* // returns 3\n*/\nfunction accessors( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default accessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils/define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport accessors from './../../../base/accessors';\nimport isCollection from '@stdlib/assert/is-collection';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a non-enumerable read-write accessor.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Function} getter - get accessor\n* @param {Function} setter - set accessor\n*\n* @example\n* function getter() {\n* return name + ' foo';\n* }\n*\n* function setter( v ) {\n* name = v;\n* }\n*\n* var name = 'bar';\n* var obj = {};\n*\n* setNonEnumerableReadWriteAccessor( obj, 'foo', getter, setter );\n*\n* var v = obj.foo;\n* // returns 'bar foo'\n*\n* obj.foo = 'beep';\n*\n* v = obj.foo;\n* // returns 'beep foo'\n*/\nfunction setNonEnumerableReadWriteAccessor( obj, prop, getter, setter ) { // eslint-disable-line id-length\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'get': getter,\n\t\t'set': setter\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setNonEnumerableReadWriteAccessor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = 1; // 1 bytes per uint8\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `BooleanArray`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `BooleanArray`\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var bool = isBooleanArray( new BooleanArray( 10 ) );\n* // returns true\n*\n* bool = isBooleanArray( [] );\n* // returns false\n*/\nfunction isBooleanArray( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `BooleanArray` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-booleanarray`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'BooleanArray' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isBooleanArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport getter from './../../../base/getter';\nimport setter from './../../../base/setter';\nimport accessorGetter from './../../../base/accessor-getter';\nimport accessorSetter from './../../../base/accessor-setter';\nimport dtype from './../../../dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint8Array === 'function' ) ? Uint8Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint8\n*\n* @example\n* import ctor from '@stdlib/array/uint8';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint8ArraySupport from '@stdlib/assert/has-uint8array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint8ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 8-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array/uint8';\n\n\n// MAIN //\n\n/**\n* Reinterprets a `BooleanArray` as a `Uint8Array`.\n*\n* @param {BooleanArray} x - input array\n* @param {NonNegativeInteger} offset - starting index\n* @returns {Uint8Array} `Uint8Array` view\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var x = new BooleanArray( 10 );\n*\n* var out = reinterpret( x, 0 );\n* // returns \n*\n* var bool = ( out.buffer === x.buffer );\n* // returns true\n*/\nfunction reinterpret( x, offset ) {\n\treturn new Uint8Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default reinterpret;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in an array is truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether at least one element is truthy\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = internal( x );\n* // returns false\n*/\nfunction internal( x ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( x[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in an array is truthy.\n*\n* @private\n* @param {Object} x - input array object\n* @returns {boolean} boolean indicating whether at least one element is truthy\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n*\n* var out = accessors( x );\n* // returns false\n*/\nfunction accessors( x ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( get( data, i ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in an array is truthy.\n*\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether at least one element is truthy\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = any( x );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = any( x );\n* // returns false\n*/\nfunction any( x ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\treturn internal( reinterpret128( x, 0 ) );\n\t\t}\n\t\tif ( isComplex64Array( x ) ) {\n\t\t\treturn internal( reinterpret64( x, 0 ) );\n\t\t}\n\t\t// If provided a boolean array, reinterpret as typed array and test for truthiness...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn internal( reinterpretBoolean( x, 0 ) );\n\t\t}\n\t\treturn accessors( obj );\n\t}\n\treturn internal( x );\n}\n\n\n// EXPORTS //\n\nexport default any;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../base/accessor-getter';\nimport getter from './../../../base/getter';\nimport dtype from './../../../dtype';\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an array-like object.\n*\n* @param {Collection} x - input array\n* @returns {Function} accessor\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var get = resolveGetter( arr );\n* var v = get( arr, 2 );\n* // returns 3\n*/\nfunction resolveGetter( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessorGetter( dt );\n\t}\n\treturn getter( dt );\n}\n\n\n// EXPORTS //\n\nexport default resolveGetter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if an object has a specified property, either own or inherited.\n*\n* @param {*} value - value to test\n* @param {*} property - property to test\n* @returns {boolean} boolean indicating if an object has a specified property\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = hasProp( beep, 'boop' );\n* // returns true\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = hasProp( beep, 'bap' );\n* // returns false\n*/\nfunction hasProp( value, property ) {\n\tif ( value === void 0 || value === null ) {\n\t\treturn false;\n\t}\n\tif ( typeof property === 'symbol' ) {\n\t\treturn property in Object( value );\n\t}\n\treturn ( String( property ) in Object( value ) );\n}\n\n\n// EXPORTS //\n\nexport default hasProp;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../../base/accessor-getter';\nimport getter from './../../../../base/getter';\nimport dtype from './../../../../dtype';\n\n\n// MAIN //\n\n/**\n* Tests if an array contains a provided search value.\n*\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {boolean} boolean indicating if an array contains a search value\n*\n* @example\n* var out = contains( [ 1, 2, 3 ], 2 );\n* // returns true\n*/\nfunction contains( x, value ) {\n\tvar len;\n\tvar get;\n\tvar dt;\n\tvar i;\n\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Resolve an accessor for retrieving input array elements:\n\tif ( isAccessorArray( x ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\t// Get the number of elements over which to iterate:\n\tlen = x.length;\n\n\t// Loop over the elements...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( get( x, i ) === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default contains;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../../base/accessor-getter';\nimport dtype from './../../../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a function to tests if an array contains a provided search value.\n*\n* @param {Collection} x - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {Function} function to test if an array contains a search value\n*\n* @example\n* var contains = factory( [ 1, 2, 3 ] );\n* // returns \n*\n* var bool = contains( 2 );\n* // returns true\n*/\nfunction factory( x ) {\n\tvar get;\n\tvar len;\n\tvar dt;\n\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', x ) );\n\t}\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Resolve an accessor for retrieving input array elements:\n\tif ( isAccessorArray( x ) ) {\n\t\tget = accessorGetter( dt );\n\t}\n\t// Get the number of elements over which to iterate:\n\tlen = x.length;\n\n\treturn ( get === void 0 ) ? contains : accessors;\n\t/**\n\t* Tests if an array contains a provided search value.\n\t*\n\t* @private\n\t* @param {*} value - search value\n\t* @returns {boolean} boolean indicating if an array contains a search value\n\t*\n\t* @example\n\t* var out = contains( [ 1, 2, 3 ], 2 );\n\t* // returns true\n\t*/\n\tfunction contains( value ) {\n\t\tvar i;\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( x[ i ] === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t* Tests if an array contains a provided search value.\n\t*\n\t* @private\n\t* @param {*} value - search value\n\t* @returns {boolean} boolean indicating if an array contains a search value\n\t*/\n\tfunction accessors( value ) {\n\t\tvar i;\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( get( x, i ) === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if a single-precision floating-point numeric value is `NaN`.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is `NaN`\n*\n* @example\n* var bool = isnanf( NaN );\n* // returns true\n*\n* @example\n* var bool = isnanf( 7.0 );\n* // returns false\n*/\nfunction isnanf( x ) {\n\treturn ( x !== x );\n}\n\n\n// EXPORTS //\n\nexport default isnanf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if an array contains a provided search value.\n*\n* @module @stdlib/array/base/assert/contains\n*\n* @example\n* import contains from '@stdlib/array/base/assert/contains';\n*\n* var out = contains( [ 1, 2, 3 ], 2 );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"factory\": \"main.factory\" }\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Mask for the sign bit of a single-precision floating-point number.\n*\n* @module @stdlib/constants/float32/sign-mask\n* @type {uinteger32}\n*\n* @example\n* import FLOAT32_SIGN_MASK from '@stdlib/constants/float32/sign-mask';\n* // returns 2147483648\n*/\n\n\n// MAIN //\n\n/**\n* Mask for the sign bit of a single-precision floating-point number.\n*\n* ## Notes\n*\n* The mask for the sign bit of a single-precision floating-point number is an unsigned 32-bit integer with the value \\\\( 2147483648 \\\\), which corresponds to the bit sequence\n*\n* ```binarystring\n* 1 00000000 00000000000000000000000\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 0x80000000\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT32_SIGN_MASK = 0x80000000>>>0;\n\n\n// EXPORTS //\n\nexport default FLOAT32_SIGN_MASK;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint32Array === 'function' ) ? Uint32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 32-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint32\n*\n* @example\n* import ctor from '@stdlib/array/uint32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint32ArraySupport from '@stdlib/assert/has-uint32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 32-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float32Array from '@stdlib/array/float32';\nimport Uint32Array from '@stdlib/array/uint32';\n\n\n// VARIABLES //\n\nvar FLOAT32_VIEW = new Float32Array( 1.0 );\nvar UINT32_VIEW = new Uint32Array( FLOAT32_VIEW.buffer );\n\n\n// MAIN //\n\n/**\n* Returns an unsigned 32-bit integer corresponding to the IEEE 754 binary representation of a single-precision floating-point number.\n*\n* @param {number} x - single-precision floating-point number\n* @returns {unsigned32} unsigned 32-bit integer\n*\n* @example\n* import float64ToFloat32 from '@stdlib/number/float64/base/to-float32';\n*\n* var f32 = float64ToFloat32( 1.337 );\n* // returns 1.3370000123977661\n*\n* var w = toWordf( f32 ); // => 0 01111111 01010110010001011010001\n* // returns 1068180177\n*/\nfunction toWordf( x ) {\n\tFLOAT32_VIEW[ 0 ] = x;\n\treturn UINT32_VIEW[ 0 ];\n}\n\n\n// EXPORTS //\n\nexport default toWordf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the absolute value of a double-precision floating-point number `x`.\n*\n* @param {number} x - input value\n* @returns {number} absolute value\n*\n* @example\n* var v = abs( -1.0 );\n* // returns 1.0\n*\n* @example\n* var v = abs( 2.0 );\n* // returns 2.0\n*\n* @example\n* var v = abs( 0.0 );\n* // returns 0.0\n*\n* @example\n* var v = abs( -0.0 );\n* // returns 0.0\n*\n* @example\n* var v = abs( NaN );\n* // returns NaN\n*/\nfunction abs( x ) {\n\treturn Math.abs( x ); // eslint-disable-line stdlib/no-builtin-math\n}\n\n\n// EXPORTS //\n\nexport default abs;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnanf from '@stdlib/math/base/assert/is-nanf';\nimport SIGN_MASK from '@stdlib/constants/float32/sign-mask';\nimport toWordf from './../../../../float32/base/to-word';\nimport abs from '@stdlib/math/base/special/abs';\n\n\n// FUNCTIONS //\n\n/**\n* Converts an unsigned 32-bit integer corresponding to the IEEE 754 binary representation of a single-precision floating-point number to a lexicographically ordered integer.\n*\n* @private\n* @param {unsigned32} word - unsigned 32-bit integer\n* @returns {integer} lexicographically ordered integer\n*/\nfunction monotoneKey( word ) {\n\tif ( word & SIGN_MASK ) { // x < 0\n\t\treturn ( ~word + 1 ); // two's-complement negation\n\t}\n\t// x >= 0\n\treturn ( word | SIGN_MASK ) >>> 0; // push +0 to just above -0\n}\n\n\n// MAIN //\n\n/**\n* Computes the number of representable single-precision floating-point values that separate two single-precision floating-point numbers along the real number line.\n*\n* ## Notes\n*\n* - Adjacent single-precision floating-point numbers differ by 1 ulp (unit in the last place).\n* - Signed zeros differ only in the sign bit but are considered numerically equal, and thus their ULP difference is 0.\n*\n* @param {number} x - first value\n* @param {number} y - second value\n* @returns {number} result\n*\n* @example\n* import EPS from '@stdlib/constants/float32/eps';\n*\n* var d = ulpdiff( 1.0, 1.0+EPS );\n* // returns 1.0\n*\n* d = ulpdiff( 1.0+EPS, 1.0 );\n* // returns 1.0\n*\n* d = ulpdiff( 1.0, 1.0+EPS+EPS );\n* // returns 2.0\n*\n* d = ulpdiff( 1.0, NaN );\n* // returns NaN\n*\n* d = ulpdiff( NaN, 1.0 );\n* // returns NaN\n*\n* d = ulpdiff( NaN, NaN );\n* // returns NaN\n*/\nfunction ulpdiff( x, y ) {\n\tvar wx;\n\tvar wy;\n\n\tif ( isnanf( x ) || isnanf( y ) ) {\n\t\treturn NaN;\n\t}\n\t// Convert input values to unsigned 32-bit integers corresponding to the IEEE 754 binary representation of single-precision floating-point numbers:\n\twx = toWordf( x );\n\twy = toWordf( y );\n\n\t// Convert the words to lexicographically ordered integers:\n\twx = monotoneKey( wx );\n\twy = monotoneKey( wy );\n\n\t// Return a double as a result, which can exactly represent the ULP difference for all representable single-precision floating-point numbers:\n\treturn abs( wx - wy );\n}\n\n\n// EXPORTS //\n\nexport default ulpdiff;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f32 from './../../../../../float64/base/to-float32';\nimport ulpdiff from './../../../../../float32/base/ulp-difference';\n\n\n// MAIN //\n\n/**\n* Tests if two single-precision floating-point numbers are approximately equal within a specified number of ULPs (units in the last place).\n*\n* ## Notes\n*\n* - The function returns `false` if either input value is `NaN`.\n* - The function does not distinguish between `-0` and `+0`, treating them as equal.\n*\n* @param {number} a - first input value\n* @param {number} b - second input value\n* @param {number} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating whether two single-precision floating-point numbers are approximately equal within a specified number of ULPs\n*\n* @example\n* import EPS from '@stdlib/constants/float32/eps';\n*\n* var bool = isAlmostEqualf( 1.0, 1.0+EPS, 1 );\n* // returns true\n*\n* bool = isAlmostEqualf( 1.0+EPS, 1.0, 1 );\n* // returns true\n*\n* bool = isAlmostEqualf( 1.0, 1.0+EPS+EPS, 1 );\n* // returns false\n*\n* bool = isAlmostEqualf( 1.0, 1.0+EPS, 0 );\n* // returns false\n*\n* bool = isAlmostEqualf( 0.0, -0.0, 0 );\n* // returns true\n*\n* bool = isAlmostEqualf( 1.0, NaN, 1 );\n* // returns false\n*\n* bool = isAlmostEqualf( NaN, NaN, 1 );\n* // returns false\n*/\nfunction isAlmostEqualf( a, b, maxULP ) {\n\treturn ulpdiff( f32( a ), f32( b ) ) <= maxULP;\n}\n\n\n// EXPORTS //\n\nexport default isAlmostEqualf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if a double-precision floating-point numeric value is `NaN`.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 7.0 );\n* // returns false\n*/\nfunction isnan( x ) {\n\treturn ( x !== x );\n}\n\n\n// EXPORTS //\n\nexport default isnan;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* High word mask for the sign bit of a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/high-word-sign-mask\n* @type {uinteger32}\n*\n* @example\n* import FLOAT64_HIGH_WORD_SIGN_MASK from '@stdlib/constants/float64/high-word-sign-mask';\n* // returns 2147483648\n*/\n\n\n// MAIN //\n\n/**\n* High word mask for the sign bit of a double-precision floating-point number.\n*\n* ## Notes\n*\n* The high word mask for the sign bit of a double-precision floating-point number is an unsigned 32-bit integer with the value \\\\( 2147483648 \\\\), which corresponds to the bit sequence\n*\n* ```binarystring\n* 1 00000000000 00000000000000000000\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 0x80000000\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_HIGH_WORD_SIGN_MASK = 0x80000000>>>0; // eslint-disable-line id-length\n\n\n// EXPORTS //\n\nexport default FLOAT64_HIGH_WORD_SIGN_MASK;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctors from './ctors.js';\n\n\n// VARIABLES //\n\nvar bool;\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if an environment is little endian.\n*\n* @private\n* @returns {boolean} boolean indicating if an environment is little endian\n*\n* @example\n* var bool = isLittleEndian();\n* // returns \n*/\nfunction isLittleEndian() {\n\tvar uint16view;\n\tvar uint8view;\n\n\tuint16view = new ctors[ 'uint16' ]( 1 );\n\n\t/*\n\t* Set the uint16 view to a value having distinguishable lower and higher order words.\n\t*\n\t* 4660 => 0x1234 => 0x12 0x34 => '00010010 00110100' => (0x12,0x34) == (18,52)\n\t*/\n\tuint16view[ 0 ] = 0x1234;\n\n\t// Create a uint8 view on top of the uint16 buffer:\n\tuint8view = new ctors[ 'uint8' ]( uint16view.buffer );\n\n\t// If little endian, the least significant byte will be first...\n\treturn ( uint8view[ 0 ] === 0x34 );\n}\n\n\n// MAIN //\n\nbool = isLittleEndian();\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint16\n*\n* @example\n* import ctor from '@stdlib/array/uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert/has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array/uint8';\nimport Uint16Array from '@stdlib/array/uint16';\n\n\n// MAIN //\n\nvar ctors = {\n\t'uint16': Uint16Array,\n\t'uint8': Uint8Array\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isLittleEndian from '@stdlib/assert/is-little-endian';\n\n\n// MAIN //\n\nvar indices;\nvar HIGH;\nvar LOW;\n\nif ( isLittleEndian === true ) {\n\tHIGH = 1; // second index\n\tLOW = 0; // first index\n} else {\n\tHIGH = 0; // first index\n\tLOW = 1; // second index\n}\nindices = {\n\t'HIGH': HIGH,\n\t'LOW': LOW\n};\n\n\n// EXPORTS //\n\nexport default indices;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float64Array from '@stdlib/array/float64';\nimport indices from './indices.js';\n\n\n// VARIABLES //\n\nvar FLOAT64_VIEW = new Float64Array( 1 );\nvar UINT32_VIEW = new Uint32Array( FLOAT64_VIEW.buffer );\n\nvar HIGH = indices.HIGH;\nvar LOW = indices.LOW;\n\n\n// MAIN //\n\n/**\n* Splits a double-precision floating-point number into a higher order word (unsigned 32-bit integer) and a lower order word (unsigned 32-bit integer).\n*\n* ## Notes\n*\n* ```text\n* float64 (64 bits)\n* f := fraction (significand/mantissa) (52 bits)\n* e := exponent (11 bits)\n* s := sign bit (1 bit)\n*\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Float64 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Uint32 | Uint32 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* ```\n*\n* If little endian (more significant bits last):\n*\n* ```text\n* <-- lower higher -->\n* | f7 f6 f5 f4 f3 f2 e2 | f1 |s| e1 |\n* ```\n*\n* If big endian (more significant bits first):\n*\n* ```text\n* <-- higher lower -->\n* |s| e1 e2 | f1 f2 f3 f4 f5 f6 f7 |\n* ```\n*\n* In which Uint32 can we find the higher order bits? If little endian, the second; if big endian, the first.\n*\n* ## References\n*\n* - [Open Group][1]\n*\n* [1]: http://pubs.opengroup.org/onlinepubs/9629399/chap14.htm\n*\n* @private\n* @param {number} x - input value\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var out = new Uint32Array( 2 );\n*\n* var w = toWords( 3.14e201, out, 1, 0 );\n* // returns [ 1774486211, 2479577218 ]\n*\n* var bool = ( w === out );\n* // returns true\n*/\nfunction toWords( x, out, stride, offset ) {\n\tFLOAT64_VIEW[ 0 ] = x;\n\tout[ offset ] = UINT32_VIEW[ HIGH ];\n\tout[ offset + stride ] = UINT32_VIEW[ LOW ];\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toWords;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fcn from './assign.js';\n\n\n// MAIN //\n\n/**\n* Splits a double-precision floating-point number into a higher order word (unsigned 32-bit integer) and a lower order word (unsigned 32-bit integer).\n*\n* @param {number} x - input value\n* @returns {Array} output array\n*\n* @example\n* var w = toWords( 3.14e201 );\n* // returns [ 1774486211, 2479577218 ]\n*/\nfunction toWords( x ) {\n\treturn fcn( x, [ 0>>>0, 0>>>0 ], 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default toWords;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Split a double-precision floating-point number into a higher order word (unsigned 32-bit integer) and a lower order word (unsigned 32-bit integer).\n*\n* @module @stdlib/number/float64/base/to-words\n*\n* @example\n* import toWords from '@stdlib/number/float64/base/to-words';\n*\n* var w = toWords( 3.14e201 );\n* // returns [ 1774486211, 2479577218 ]\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n* import toWords from '@stdlib/number/float64/base/to-words';\n*\n* var out = new Uint32Array( 2 );\n*\n* var w = toWords.assign( 3.14e201, out, 1, 0 );\n* // returns [ 1774486211, 2479577218 ]\n*\n* var bool = ( w === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport SIGN_MASK from '@stdlib/constants/float64/high-word-sign-mask';\nimport { assign as toWords } from './../../../../float64/base/to-words';\nimport Uint32Array from '@stdlib/array/uint32';\n\n\n// VARIABLES //\n\nvar WX = new Uint32Array( 2 ); // WARNING: not thread safe\nvar WY = new Uint32Array( 2 );\nvar WZ = new Uint32Array( 2 );\n\n// 2^32:\nvar TWO_32 = 4294967296;\n\n\n// FUNCTIONS //\n\n/**\n* Converts the high and low words of a double-precision floating-point number to a lexicographically ordered integer.\n*\n* ## Notes\n*\n* - This function mutates the input array.\n*\n* @private\n* @param {Array} words - high and low words\n* @returns {Array} input array\n*/\nfunction monotoneKey( words ) {\n\tif ( words[ 0 ]&SIGN_MASK ) { // x < 0\n\t\twords = negate( words ); // maps -∞ to 0\n\t} else { // x >= 0\n\t\twords[ 0 ] |= SIGN_MASK; // push +0 to just above -0\n\t}\n\treturn words;\n}\n\n/**\n* Perform two's-complement negation.\n*\n* ## Notes\n*\n* - This function mutates the input array.\n*\n* @private\n* @param {Array} words - high and low words\n* @returns {Array} input array\n*/\nfunction negate( words ) {\n\twords[ 0 ] = ~words[ 0 ];\n\twords[ 1 ] = ~words[ 1 ];\n\twords[ 1 ] += 1;\n\n\t// Handle the carry into the high word...\n\tif ( words[ 1 ] === 0 ) {\n\t\twords[ 0 ] += 1;\n\t}\n\treturn words;\n}\n\n/**\n* Returns the ordering of two double-precision floating-point numbers according to their lexicographically ordered high and low words.\n*\n* @private\n* @param {Array} wa - high and low words for first value\n* @param {Array} wb - high and low words for second value\n* @returns {integer} relative ordering\n*/\nfunction compare( wa, wb ) {\n\tif ( wa[ 0 ] > wb[ 0 ] ) {\n\t\treturn 1;\n\t}\n\tif ( wa[ 0 ] < wb[ 0 ] ) {\n\t\treturn -1;\n\t}\n\tif ( wa[ 1 ] > wb[ 1 ] ) {\n\t\treturn 1;\n\t}\n\tif ( wa[ 1 ] < wb[ 1 ] ) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\n/**\n* Performs double-word subtraction.\n*\n* @private\n* @param {Array} wa - high and low words for first value\n* @param {Array} wb - high and low words for second value\n* @param {Array} wc - output array\n* @returns {Array} output array\n*/\nfunction subtract( wa, wb, wc ) {\n\tvar ha;\n\tvar hb;\n\tvar la;\n\tvar lb;\n\n\tha = wa[ 0 ];\n\tla = wa[ 1 ];\n\thb = wb[ 0 ];\n\tlb = wb[ 1 ];\n\n\tif ( la >= lb ) {\n\t\twc[ 0 ] = ha - hb;\n\t\twc[ 1 ] = la - lb;\n\t} else {\n\t\twc[ 0 ] = ( ha - hb - 1 ); // wrap\n\t\twc[ 1 ] = ( la + TWO_32 ) - lb; // borrow\n\t}\n\treturn wc;\n}\n\n\n// MAIN //\n\n/**\n* Computes the number of representable double-precision floating-point values that separate two double-precision floating-point numbers along the real number line.\n*\n* ## Notes\n*\n* - Adjacent double-precision floating-point numbers differ by 1 ulp (unit in the last place).\n* - Signed zeros differ only in the sign bit but are considered numerically equal, and thus their ULP difference is 0.\n*\n* @param {number} x - first value\n* @param {number} y - second value\n* @returns {number} result\n*\n* @example\n* import EPS from '@stdlib/constants/float64/eps';\n*\n* var d = ulpdiff( 1.0, 1.0+EPS );\n* // returns 1.0\n*\n* d = ulpdiff( 1.0+EPS, 1.0 );\n* // returns 1.0\n*\n* d = ulpdiff( 1.0, 1.0+EPS+EPS );\n* // returns 2.0\n*\n* d = ulpdiff( 1.0, NaN );\n* // returns NaN\n*\n* d = ulpdiff( NaN, 1.0 );\n* // returns NaN\n*\n* d = ulpdiff( NaN, NaN );\n* // returns NaN\n*/\nfunction ulpdiff( x, y ) {\n\tvar ord;\n\tvar wx;\n\tvar wy;\n\tvar wz;\n\tif ( isnan( x ) || isnan( y ) ) {\n\t\treturn NaN;\n\t}\n\t// Convert input values to high and low words:\n\twx = toWords( x, WX, 1, 0 );\n\twy = toWords( y, WY, 1, 0 );\n\n\t// Convert the values to lexicographically ordered integers:\n\twx = monotoneKey( wx );\n\twy = monotoneKey( wy );\n\n\t// Determine the relative ordering of the two values so that we always subtract the smaller value from the larger value and ensure that the result is always >= 0:\n\tord = compare( wx, wy );\n\n\t// Perform subtraction...\n\tif ( ord === 0 ) {\n\t\t// Identical encoding:\n\t\treturn 0;\n\t}\n\tif ( ord === 1 ) {\n\t\twz = subtract( wx, wy, WZ );\n\t} else { // ord === -1\n\t\twz = subtract( wy, wx, WZ );\n\t}\n\t// Return a double as a result, which is fine for ≤2^53 ulps:\n\treturn ( wz[ 0 ]*TWO_32 ) + wz[ 1 ];\n}\n\n\n// EXPORTS //\n\nexport default ulpdiff;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ulpdiff from './../../../../../float64/base/ulp-difference';\n\n\n// MAIN //\n\n/**\n* Tests if two double-precision floating-point numbers are approximately equal within a specified number of ULPs (units in the last place).\n*\n* ## Notes\n*\n* - The function returns `false` if either input value is `NaN`.\n* - The function does not distinguish between `-0` and `+0`, treating them as equal.\n*\n* @param {number} a - first input value\n* @param {number} b - second input value\n* @param {number} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating whether two double-precision floating-point numbers are approximately equal within a specified number of ULPs\n*\n* @example\n* import EPS from '@stdlib/constants/float64/eps';\n*\n* var bool = isAlmostEqual( 1.0, 1.0+EPS, 1 );\n* // returns true\n*\n* bool = isAlmostEqual( 1.0+EPS, 1.0, 1 );\n* // returns true\n*\n* bool = isAlmostEqual( 1.0, 1.0+EPS+EPS, 1 );\n* // returns false\n*\n* bool = isAlmostEqual( 1.0, 1.0+EPS, 0 );\n* // returns false\n*\n* bool = isAlmostEqual( 0.0, -0.0, 0 );\n* // returns true\n*\n* bool = isAlmostEqual( 1.0, NaN, 1 );\n* // returns false\n*\n* bool = isAlmostEqual( NaN, NaN, 1 );\n* // returns false\n*/\nfunction isAlmostEqual( a, b, maxULP ) {\n\treturn ulpdiff( a, b ) <= maxULP;\n}\n\n\n// EXPORTS //\n\nexport default isAlmostEqual;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float32Array from '@stdlib/array/float32';\n\n\n// MAIN //\n\n/**\n* Returns the real and imaginary components of a single-precision complex floating-point number.\n*\n* @param {Complex64} z - complex number\n* @returns {Float32Array} real and imaginary components\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var out = reim( z );\n* // returns [ 5.0, 3.0 ]\n*/\nfunction reim( z ) {\n\tvar out = new Float32Array( 2 );\n\tout[ 0 ] = z.re;\n\tout[ 1 ] = z.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default reim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from '@stdlib/array/float64';\n\n\n// MAIN //\n\n/**\n* Returns the real and imaginary components of a double-precision complex floating-point number.\n*\n* @param {Complex128} z - complex number\n* @returns {Float64Array} real and imaginary components\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var out = reim( z );\n* // returns [ 5.0, 3.0 ]\n*/\nfunction reim( z ) {\n\tvar out = new Float64Array( 2 );\n\tout[ 0 ] = z.re;\n\tout[ 1 ] = z.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default reim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAlmostEqualComplex64 from '@stdlib/complex/float32/base/assert/is-almost-equal';\nimport isAlmostEqualComplex128 from '@stdlib/complex/float64/base/assert/is-almost-equal';\nimport { isPrimitive as isNumber } from './../../is-number';\nimport isAlmostEqualF64 from '@stdlib/number/float64/base/assert/is-almost-equal';\nimport isComplexLike from './../../is-complex-like';\n\n\n// MAIN //\n\n/**\n* Tests if two arguments are approximately equal within a specified number of ULPs (units in the last place).\n*\n* ## Notes\n*\n* - The function returns `false` if either input value is `NaN` or, in the case of complex numbers, if either the real or imaginary component is `NaN`.\n* - The function does not distinguish between `-0` and `+0`, treating them as equal.\n*\n* @param {*} a - first input value\n* @param {*} b - second input value\n* @param {NonNegativeInteger} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating whether two arguments are approximately equal within a specified number of ULPs\n*\n* @example\n* import EPS from '@stdlib/constants/float64/eps';\n*\n* var bool = isAlmostEqual( 1.0, 1.0+EPS, 0 );\n* // returns false\n*\n* bool = isAlmostEqual( 1.0, 1.0+EPS, 1 );\n* // returns true\n*\n* bool = isAlmostEqual( {}, {}, 0 );\n* // returns false\n*\n* bool = isAlmostEqual( -0.0, 0.0, 0 );\n* // returns true\n*\n* bool = isAlmostEqual( NaN, NaN, 0 );\n* // returns false\n*\n* bool = isAlmostEqual( [], [], 1 );\n* // returns false\n*/\nfunction isAlmostEqual( a, b, maxULP ) {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\tif ( isNumber( a ) && isNumber( b ) ) {\n\t\treturn isAlmostEqualF64( a, b, maxULP );\n\t}\n\tif ( isComplexLike( a ) && isComplexLike( b ) ) {\n\t\tif ( a.BYTES_PER_ELEMENT === 4 && b.BYTES_PER_ELEMENT === 4 ) {\n\t\t\treturn isAlmostEqualComplex64( a, b, maxULP );\n\t\t}\n\t\treturn isAlmostEqualComplex128( a, b, maxULP );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isAlmostEqual;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAlmostEqualF32 from '@stdlib/number/float32/base/assert/is-almost-equal';\nimport reimf from './../../../../../float32/reim';\n\n\n// MAIN //\n\n/**\n* Tests whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs (units in the last place).\n*\n* ## Notes\n*\n* - The function returns `false` if either input value has a `NaN` real or imaginary component.\n* - The function does not distinguish between `-0` and `+0`, treating them as equal.\n*\n* @param {Complex64} z1 - first complex number\n* @param {Complex64} z2 - second complex number\n* @param {number} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs\n*\n* @example\n* import EPS from '@stdlib/constants/float32/eps';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var z1 = new Complex64( 1.0, 3.0 );\n* var z2 = new Complex64( 1.0+EPS, 3.0 );\n*\n* var bool = isAlmostEqualf( z1, z2, 0 );\n* // returns false\n*\n* bool = isAlmostEqualf( z1, z2, 1 );\n* // returns true\n*/\nfunction isAlmostEqualf( z1, z2, maxULP ) {\n\tvar parts1 = reimf( z1 );\n\tvar parts2 = reimf( z2 );\n\treturn (\n\t\tisAlmostEqualF32( parts1[ 0 ], parts2[ 0 ], maxULP ) &&\n\t\tisAlmostEqualF32( parts1[ 1 ], parts2[ 1 ], maxULP )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isAlmostEqualf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAlmostEqualF64 from '@stdlib/number/float64/base/assert/is-almost-equal';\nimport reim from './../../../../../float64/reim';\n\n\n// MAIN //\n\n/**\n* Tests whether two double-precision complex floating-point numbers are approximately equal within a specified number of ULPs (units in the last place).\n*\n* ## Notes\n*\n* - The function returns `false` if either input value has a `NaN` real or imaginary component.\n* - The function does not distinguish between `-0` and `+0`, treating them as equal.\n*\n* @param {Complex128} z1 - first complex number\n* @param {Complex128} z2 - second complex number\n* @param {number} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating whether two double-precision complex floating-point numbers are approximately equal within a specified number of ULPs\n*\n* @example\n* import EPS from '@stdlib/constants/float64/eps';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z1 = new Complex128( 1.0, 3.0 );\n* var z2 = new Complex128( 1.0+EPS, 3.0 );\n*\n* var bool = isAlmostEqual( z1, z2, 0 );\n* // returns false\n*\n* bool = isAlmostEqual( z1, z2, 1 );\n* // returns true\n*/\nfunction isAlmostEqual( z1, z2, maxULP ) {\n\tvar parts1 = reim( z1 );\n\tvar parts2 = reim( z2 );\n\treturn (\n\t\tisAlmostEqualF64( parts1[ 0 ], parts2[ 0 ], maxULP ) &&\n\t\tisAlmostEqualF64( parts1[ 1 ], parts2[ 1 ], maxULP )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isAlmostEqual;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isAlmostEqualF32 from '@stdlib/number/float32/base/assert/is-almost-equal';\nimport isAlmostEqualF64 from '@stdlib/number/float64/base/assert/is-almost-equal';\nimport isAlmostEqual from '@stdlib/assert/is-almost-equal';\n\n\n// FUNCTIONS //\n\n/**\n* Tests if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place).\n*\n* @private\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {NonNegativeInteger} maxULP - maximum allowed ULP difference\n* @param {Function} fcn - function which tests approximate equality\n* @returns {boolean} boolean indicating if both arrays have respective elements which are approximately equal\n*\n* @example\n* import base from '@stdlib/number/float64/base/assert/is-almost-equal';\n*\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y, 1, base );\n* // returns true\n*\n* @example\n* import base from '@stdlib/number/float64/base/assert/is-almost-equal';\n*\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y, 1, base );\n* // returns false\n*/\nfunction internal( x, y, maxULP, fcn ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !fcn( x[ i ], y[ i ], maxULP ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place).\n*\n* @private\n* @param {Object} x - first input array object\n* @param {Object} y - second input array object\n* @param {NonNegativeInteger} maxULP - maximum allowed ULP difference\n* @param {Function} fcn - function which tests approximate equality\n* @returns {boolean} boolean indicating if both arrays have respective elements which are approximately equal\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import assert from '@stdlib/assert/is-almost-equal';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y, 0, assert );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import assert from '@stdlib/assert/is-almost-equal';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y, 1, assert );\n* // returns false\n*/\nfunction accessors( x, y, maxULP, fcn ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yget;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyget = y.accessors[ 0 ];\n\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( !fcn( xget( xdata, i ), yget( ydata, i ), maxULP ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place).\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {NonNegativeInteger} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating if both arrays have respective elements which are approximately equal\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasAlmostEqualValues( x, y, 0 );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasAlmostEqualValues( x, y, 1 );\n* // returns false\n*/\nfunction hasAlmostEqualValues( x, y, maxULP ) {\n\tvar FLG;\n\tvar xo;\n\tvar yo;\n\tvar xr;\n\tvar yr;\n\n\tif ( x.length !== y.length ) {\n\t\treturn false;\n\t}\n\txo = arraylike2object( x );\n\tyo = arraylike2object( y );\n\tif ( xo.accessorProtocol || yo.accessorProtocol ) {\n\t\tFLG = 2;\n\n\t\t// If provided boolean arrays, reinterpret the arrays to avoid using accessors to access array elements...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\tif ( isBooleanArray( y ) ) {\n\t\t\t\treturn internal( reinterpretBoolean( x, 0 ), reinterpretBoolean( y, 0 ), maxULP, isAlmostEqualF64 ); // eslint-disable-line max-len\n\t\t\t}\n\t\t\treturn accessors( xo, yo, maxULP, isAlmostEqual ); // general accessors should always use general comparison\n\t\t}\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\txr = reinterpret128( x, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\txr = reinterpret64( x, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( isComplex128Array( y ) ) {\n\t\t\tyr = reinterpret128( y, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( y ) ) {\n\t\t\tyr = reinterpret64( y, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( FLG === 0 ) {\n\t\t\t// Determine whether we should use double-precision or single-precision comparison...\n\t\t\tif ( xr.BYTES_PER_ELEMENT === 8 || yr.BYTES_PER_ELEMENT === 8 ) {\n\t\t\t\treturn internal( xr, yr, maxULP, isAlmostEqualF64 );\n\t\t\t}\n\t\t\treturn internal( xr, yr, maxULP, isAlmostEqualF32 );\n\t\t}\n\t\treturn accessors( xo, yo, maxULP, isAlmostEqual ); // general accessors should always use general comparison\n\t}\n\t// Determine whether we should use double-precision or single-precision comparison...\n\tif ( x.BYTES_PER_ELEMENT === 4 && y.BYTES_PER_ELEMENT === 4 ) {\n\t\treturn internal( x, y, maxULP, isAlmostEqualF32 );\n\t}\n\treturn internal( x, y, maxULP, isAlmostEqual ); // default to general comparison\n}\n\n\n// EXPORTS //\n\nexport default hasAlmostEqualValues;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Tests if two arrays have equal values.\n*\n* @private\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @returns {boolean} boolean indicating if both arrays have equal values\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y );\n* // returns false\n*/\nfunction internal( x, y ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( x[ i ] !== y[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests if two arrays have equal values.\n*\n* @private\n* @param {Object} x - first input array object\n* @param {Object} y - second input array object\n* @returns {boolean} boolean indicating if both arrays have equal values\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y );\n* // returns false\n*/\nfunction accessors( x, y ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yget;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyget = y.accessors[ 0 ];\n\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( xget( xdata, i ) !== yget( ydata, i ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests if two arrays have equal values.\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @returns {boolean} boolean indicating if both arrays have equal values\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasEqualValues( x, y );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasEqualValues( x, y );\n* // returns false\n*/\nfunction hasEqualValues( x, y ) {\n\tvar FLG;\n\tvar xo;\n\tvar yo;\n\tvar xr;\n\tvar yr;\n\n\tif ( x.length !== y.length ) {\n\t\treturn false;\n\t}\n\txo = arraylike2object( x );\n\tyo = arraylike2object( y );\n\tif ( xo.accessorProtocol || yo.accessorProtocol ) {\n\t\tFLG = 2;\n\n\t\t// If provided boolean arrays, reinterpret the arrays to avoid using accessors to access array elements...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\tif ( isBooleanArray( y ) ) {\n\t\t\t\treturn internal( reinterpretBoolean( x, 0 ), reinterpretBoolean( y, 0 ) ); // eslint-disable-line max-len\n\t\t\t}\n\t\t\treturn accessors( xo, yo );\n\t\t}\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\txr = reinterpret128( x, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\txr = reinterpret64( x, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( isComplex128Array( y ) ) {\n\t\t\tyr = reinterpret128( y, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( y ) ) {\n\t\t\tyr = reinterpret64( y, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( FLG === 0 ) {\n\t\t\treturn internal( xr, yr );\n\t\t}\n\t\treturn accessors( xo, yo );\n\t}\n\treturn internal( x, y );\n}\n\n\n// EXPORTS //\n\nexport default hasEqualValues;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if two double-precision floating-point numbers are the same value.\n*\n* ## Notes\n*\n* - The function implements the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {number} a - first input value\n* @param {number} b - second input value\n* @returns {boolean} boolean indicating whether two double-precision floating-point numbers are the same value\n*\n* @example\n* var bool = isSameValue( 3.14, 3.14 );\n* // returns true\n*\n* @example\n* var bool = isSameValue( -0.0, -0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValue( -0.0, 0.0 );\n* // returns false\n*\n* @example\n* var bool = isSameValue( NaN, NaN );\n* // returns true\n*/\nfunction isSameValue( a, b ) {\n\tif ( a === b ) {\n\t\tif ( a === 0.0 ) {\n\t\t\treturn 1.0 / a === 1.0 / b; // handles +-0\n\t\t}\n\t\treturn true;\n\t}\n\treturn ( a !== a && b !== b ); // handles NaNs\n}\n\n\n// EXPORTS //\n\nexport default isSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isSameComplexValue from '@stdlib/complex/float64/base/assert/is-same-value';\nimport isComplexLike from './../../is-complex-like';\n\n\n// MAIN //\n\n/**\n* Tests if two arguments are the same value.\n*\n* ## Notes\n*\n* - The function implements the [SameValue Algorithm][ecma-262-same-value-algorithm] (as specified in ECMAScript 5), with support for complex number objects.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {*} a - first input value\n* @param {*} b - second input value\n* @returns {boolean} boolean indicating whether two arguments are the same value\n*\n* @example\n* var bool = isSameValue( true, true );\n* // returns true\n*\n* @example\n* var bool = isSameValue( 3.14, 3.14 );\n* // returns true\n*\n* @example\n* var bool = isSameValue( {}, {} );\n* // returns false\n*\n* @example\n* var bool = isSameValue( -0.0, -0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValue( -0.0, 0.0 );\n* // returns false\n*\n* @example\n* var bool = isSameValue( NaN, NaN );\n* // returns true\n*\n* @example\n* var bool = isSameValue( [], [] );\n* // returns false\n*/\nfunction isSameValue( a, b ) {\n\tif ( a === b ) {\n\t\tif ( a === 0.0 ) {\n\t\t\treturn 1.0 / a === 1.0 / b; // handles +-0\n\t\t}\n\t\treturn true;\n\t}\n\tif ( a !== a && b !== b ) { // handles NaNs\n\t\treturn true;\n\t}\n\tif ( isComplexLike( a ) && isComplexLike( b ) ) {\n\t\treturn isSameComplexValue( a, b );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isSame from '@stdlib/number/float64/base/assert/is-same-value';\nimport reim from './../../../../../float64/reim';\n\n\n// MAIN //\n\n/**\n* Tests whether two double-precision complex floating-point numbers are the same value.\n*\n* ## Notes\n*\n* - The function implements the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {Complex128} z1 - first complex number\n* @param {Complex128} z2 - second complex number\n* @returns {boolean} result\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z1 = new Complex128( 5.0, 3.0 );\n* var z2 = new Complex128( 5.0, 3.0 );\n*\n* var v = isSameValue( z1, z2 );\n* // returns true\n*/\nfunction isSameValue( z1, z2 ) {\n\tvar parts1 = reim( z1 );\n\tvar parts2 = reim( z2 );\n\treturn (\n\t\tisSame( parts1[ 0 ], parts2[ 0 ] ) &&\n\t\tisSame( parts1[ 1 ], parts2[ 1 ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isSameValue from '@stdlib/assert/is-same-value';\n\n\n// FUNCTIONS //\n\n/**\n* Tests if two arrays have the same values.\n*\n* @private\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @returns {boolean} boolean indicating if both arrays have the same values\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y );\n* // returns false\n*/\nfunction internal( x, y ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !isSameValue( x[ i ], y[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests if two arrays have the same values.\n*\n* @private\n* @param {Object} x - first input array object\n* @param {Object} y - second input array object\n* @returns {boolean} boolean indicating if both arrays have the same values\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y );\n* // returns false\n*/\nfunction accessors( x, y ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yget;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyget = y.accessors[ 0 ];\n\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( !isSameValue( xget( xdata, i ), yget( ydata, i ) ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests if two arrays have the same values.\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @returns {boolean} boolean indicating if both arrays have the same values\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasSameValues( x, y );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasSameValues( x, y );\n* // returns false\n*/\nfunction hasSameValues( x, y ) {\n\tvar FLG;\n\tvar xo;\n\tvar yo;\n\tvar xr;\n\tvar yr;\n\n\tif ( x.length !== y.length ) {\n\t\treturn false;\n\t}\n\txo = arraylike2object( x );\n\tyo = arraylike2object( y );\n\tif ( xo.accessorProtocol || yo.accessorProtocol ) {\n\t\tFLG = 2;\n\n\t\t// If provided boolean arrays, reinterpret the arrays to avoid using accessors to access array elements...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\tif ( isBooleanArray( y ) ) {\n\t\t\t\treturn internal( reinterpretBoolean( x, 0 ), reinterpretBoolean( y, 0 ) );\n\t\t\t}\n\t\t\treturn accessors( xo, yo );\n\t\t}\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\txr = reinterpret128( x, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\txr = reinterpret64( x, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( isComplex128Array( y ) ) {\n\t\t\tyr = reinterpret128( y, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( y ) ) {\n\t\t\tyr = reinterpret64( y, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( FLG === 0 ) {\n\t\t\treturn internal( xr, yr );\n\t\t}\n\t\treturn accessors( xo, yo );\n\t}\n\treturn internal( x, y );\n}\n\n\n// EXPORTS //\n\nexport default hasSameValues;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Replaces search occurrences with a replacement string.\n*\n* @param {string} str - input string\n* @param {RegExp} search - search expression\n* @param {(string|Function)} newval - replacement value or function\n* @returns {string} new string containing replacement(s)\n*\n* @example\n* var str = 'Hello World';\n* var out = replace( str, /world/i, 'Mr. President' );\n* // returns 'Hello Mr. President'\n*\n* @example\n* import capitalize from '@stdlib/string/base/capitalize';\n*\n* var str = 'Oranges and lemons say the bells of St. Clement\\'s';\n*\n* function replacer( match, p1 ) {\n* return capitalize( p1 );\n* }\n*\n* var out = replace( str, /([^\\s]*)/gi, replacer );\n* // returns 'Oranges And Lemons Say The Bells Of St. Clement\\'s'\n*/\nfunction replace( str, search, newval ) {\n\treturn str.replace( search, newval );\n}\n\n\n// EXPORTS //\n\nexport default replace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string/base/replace';\nimport DTYPES from './dtypes.json';\n\n\n// VARIABLES //\n\nvar RE_SUFFIX = /_and_generic$/;\n\n\n// MAIN //\n\n/**\n* Returns a list of array data types.\n*\n* @param {string} [kind] - data type kind\n* @returns {StringArray} list of array data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'float32', 'float64', ... ]\n*\n* @example\n* var list = dtypes( 'floating_point' );\n* // returns [...]\n*/\nfunction dtypes() {\n\tvar kind;\n\tvar out;\n\tvar FLG;\n\tif ( arguments.length === 0 ) {\n\t\treturn DTYPES.all.slice();\n\t}\n\tFLG = false;\n\tkind = arguments[ 0 ];\n\tif ( RE_SUFFIX.test( kind ) ) {\n\t\tkind = replace( kind, RE_SUFFIX, '' );\n\t\tif ( kind !== 'all' && kind !== 'index' ) {\n\t\t\tFLG = true;\n\t\t}\n\t}\n\tout = DTYPES[ kind ];\n\tout = ( out ) ? out.slice() : [];\n\tif ( FLG && out.length > 0 ) {\n\t\tout.push( 'generic' );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array boolean data type.\n*\n* @name isBooleanDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array boolean data type\n*\n* @example\n* var bool = isBooleanDataType( 'bool' );\n* // returns true\n*\n* bool = isBooleanDataType( 'complex64' );\n* // returns false\n*\n* bool = isBooleanDataType( 'complex128' );\n* // returns false\n*\n* bool = isBooleanDataType( 'float32' );\n* // returns false\n*\n* bool = isBooleanDataType( 'float64' );\n* // returns false\n*\n* bool = isBooleanDataType( 'generic' );\n* // returns false\n*\n* bool = isBooleanDataType( 'int16' );\n* // returns false\n*\n* bool = isBooleanDataType( 'int32' );\n* // returns false\n*\n* bool = isBooleanDataType( 'int8' );\n* // returns false\n*\n* bool = isBooleanDataType( 'uint16' );\n* // returns false\n*\n* bool = isBooleanDataType( 'uint32' );\n* // returns false\n*\n* bool = isBooleanDataType( 'uint8' );\n* // returns false\n*\n* bool = isBooleanDataType( 'uint8c' );\n* // returns false\n*\n* bool = isBooleanDataType( 'foo' );\n* // returns false\n*/\nvar isBooleanDataType = contains( dtypes( 'boolean' ) );\n\n\n// EXPORTS //\n\nexport default isBooleanDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ORDERS from './orders.json';\n\n\n// MAIN //\n\n/**\n* Returns a list of byte orders.\n*\n* @returns {StringArray} list of byte orders\n*\n* @example\n* var list = orders();\n* // e.g., returns [ 'little-endian', 'big-endian' ]\n*/\nfunction orders() {\n\treturn ORDERS.slice();\n}\n\n\n// EXPORTS //\n\nexport default orders;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport byteOrders from './../../../../byte-orders';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array byte order.\n*\n* @name isByteOrder\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array byte order\n*\n* @example\n* var bool = isByteOrder( 'little-endian' );\n* // returns true\n*\n* bool = isByteOrder( 'big-endian' );\n* // returns true\n*\n* bool = isByteOrder( 'foo' );\n* // returns false\n*/\nvar isByteOrder = contains( byteOrders() );\n\n\n// EXPORTS //\n\nexport default isByteOrder;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array complex-valued floating-point data type.\n*\n* @name isComplexFloatingPointDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array complex-valued floating-point data type\n*\n* @example\n* var bool = isComplexFloatingPointDataType( 'complex64' );\n* // returns true\n*\n* bool = isComplexFloatingPointDataType( 'complex128' );\n* // returns true\n*\n* bool = isComplexFloatingPointDataType( 'float32' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'float64' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'generic' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'int16' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'int32' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'int8' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'uint16' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'uint32' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'uint8' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'uint8c' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'foo' );\n* // returns false\n*/\nvar isComplexFloatingPointDataType = contains( dtypes( 'complex_floating_point' ) ); // eslint-disable-line id-length\n\n\n// EXPORTS //\n\nexport default isComplexFloatingPointDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar C64_BYTES_PER_ELEMENT = 8; // 4 bytes per float32 x (1 real + 1 imag component)\nvar C128_BYTES_PER_ELEMENT = 16; // 8 bytes per float64 x (1 real + 1 imag component)\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a complex typed array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isComplexTypedArray( new Complex128Array( 10 ) );\n* // returns true\n*\n* bool = isComplexTypedArray( [] );\n* // returns false\n*/\nfunction isComplexTypedArray( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex128Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex-typed-array`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t(\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex128Array' &&\n\t\t\t\tvalue.BYTES_PER_ELEMENT === C128_BYTES_PER_ELEMENT\n\t\t\t) ||\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex64Array' &&\n\t\t\t\tvalue.BYTES_PER_ELEMENT === C64_BYTES_PER_ELEMENT\n\t\t\t)\n\t\t)\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplexTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array data type.\n*\n* @name isDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array data type\n*\n* @example\n* var bool = isDataType( 'float32' );\n* // returns true\n*\n* bool = isDataType( 'float64' );\n* // returns true\n*\n* bool = isDataType( 'generic' );\n* // returns true\n*\n* bool = isDataType( 'int16' );\n* // returns true\n*\n* bool = isDataType( 'int32' );\n* // returns true\n*\n* bool = isDataType( 'int8' );\n* // returns true\n*\n* bool = isDataType( 'uint16' );\n* // returns true\n*\n* bool = isDataType( 'uint32' );\n* // returns true\n*\n* bool = isDataType( 'uint8' );\n* // returns true\n*\n* bool = isDataType( 'uint8c' );\n* // returns true\n*\n* bool = isDataType( 'foo' );\n* // returns false\n*/\nvar isDataType = contains( dtypes() );\n\n\n// EXPORTS //\n\nexport default isDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array floating-point data type.\n*\n* @name isFloatingPointDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array floating-point data type\n*\n* @example\n* var bool = isFloatingPointDataType( 'float32' );\n* // returns true\n*\n* bool = isFloatingPointDataType( 'float64' );\n* // returns true\n*\n* bool = isFloatingPointDataType( 'generic' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'int16' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'int32' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'int8' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'uint16' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'uint32' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'uint8' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'uint8c' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'foo' );\n* // returns false\n*/\nvar isFloatingPointDataType = contains( dtypes( 'floating_point' ) );\n\n\n// EXPORTS //\n\nexport default isFloatingPointDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array integer data type.\n*\n* @name isIntegerDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array integer data type\n*\n* @example\n* var bool = isIntegerDataType( 'float32' );\n* // returns false\n*\n* bool = isIntegerDataType( 'float64' );\n* // returns false\n*\n* bool = isIntegerDataType( 'generic' );\n* // returns false\n*\n* bool = isIntegerDataType( 'int16' );\n* // returns true\n*\n* bool = isIntegerDataType( 'int32' );\n* // returns true\n*\n* bool = isIntegerDataType( 'int8' );\n* // returns true\n*\n* bool = isIntegerDataType( 'uint16' );\n* // returns true\n*\n* bool = isIntegerDataType( 'uint32' );\n* // returns true\n*\n* bool = isIntegerDataType( 'uint8' );\n* // returns true\n*\n* bool = isIntegerDataType( 'uint8c' );\n* // returns true\n*\n* bool = isIntegerDataType( 'foo' );\n* // returns false\n*/\nvar isIntegerDataType = contains( dtypes( 'integer' ) );\n\n\n// EXPORTS //\n\nexport default isIntegerDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of an object's own enumerable property names.\n*\n* ## Notes\n*\n* - In contrast to the built-in `Object.keys()`, this function returns an empty array if provided `undefined` or `null`, rather than throwing an error.\n*\n* @private\n* @param {*} value - input object\n* @returns {Array} a list of own enumerable property names\n*\n* @example\n* var obj = {\n* 'beep': 'boop',\n* 'foo': 3.14\n* };\n*\n* var k = keys( obj );\n* // e.g., returns [ 'beep', 'foo' ]\n*/\nfunction keys( value ) {\n\treturn Object.keys( Object( value ) );\n}\n\n\n// EXPORTS //\n\nexport default keys;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar bool = ( typeof Object.keys !== 'undefined' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArguments from './main.js';\n\n\n// VARIABLES //\n\nvar bool;\n\n\n// FUNCTIONS //\n\n/**\n* Detects whether an environment returns the expected internal class of the `arguments` object.\n*\n* @private\n* @returns {boolean} boolean indicating whether an environment behaves as expected\n*\n* @example\n* var bool = detect();\n* // returns \n*/\nfunction detect() {\n\treturn isArguments( arguments );\n}\n\n\n// MAIN //\n\nbool = detect();\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// MAIN //\n\n/**\n* Tests whether a value is an `arguments` object.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is an `arguments` object\n*\n* @example\n* function foo() {\n* return arguments;\n* }\n*\n* var bool = isArguments( foo() );\n* // returns true\n*\n* @example\n* var bool = isArguments( [] );\n* // returns false\n*/\nfunction isArguments( value ) {\n\treturn ( nativeClass( value ) === '[object Arguments]' );\n}\n\n\n// EXPORTS //\n\nexport default isArguments;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from './../../is-number';\nimport isNan from '@stdlib/math/base/assert/is-nan';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a `NaN` number primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `NaN` number primitive\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 3.14 );\n* // returns false\n*\n* @example\n* var bool = isnan( new Number( NaN ) );\n* // returns false\n*/\nfunction isnan( value ) {\n\treturn (\n\t\tisNumber( value ) &&\n\t\tisNan( value )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isnan;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isObject as isNumber } from './../../is-number';\nimport isNan from '@stdlib/math/base/assert/is-nan';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number object having a value of `NaN`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number object having a value of `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns false\n*\n* @example\n* var bool = isnan( new Number( NaN ) );\n* // returns true\n*/\nfunction isnan( value ) {\n\treturn (\n\t\tisNumber( value ) &&\n\t\tisNan( value.valueOf() )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isnan;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is `NaN`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( new Number( NaN ) );\n* // returns true\n*\n* @example\n* var bool = isnan( 3.14 );\n* // returns false\n*\n* @example\n* var bool = isnan( null );\n* // returns false\n*/\nfunction isnan( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isnan;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is `NaN`.\n*\n* @module @stdlib/assert/is-nan\n*\n* @example\n* import isnan from '@stdlib/assert/is-nan';\n*\n* var bool = isnan( NaN );\n* // returns true\n*\n* bool = isnan( new Number( NaN ) );\n* // returns true\n*\n* bool = isnan( 3.14 );\n* // returns false\n*\n* bool = isnan( null );\n* // returns false\n*\n* @example\n* import { isPrimitive as isnan } from '@stdlib/assert/is-nan';\n*\n* var bool = isnan( NaN );\n* // returns true\n*\n* bool = isnan( 3.14 );\n* // returns false\n*\n* bool = isnan( new Number( NaN ) );\n* // returns false\n*\n* @example\n* import { isObject as isnan } from '@stdlib/assert/is-nan';\n*\n* var bool = isnan( NaN );\n* // returns false\n*\n* bool = isnan( new Number( NaN ) );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if an object's own property is enumerable.\n*\n* @private\n* @name isEnumerableProperty\n* @type {Function}\n* @param {*} value - value to test\n* @param {*} property - property to test\n* @returns {boolean} boolean indicating if an object property is enumerable\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = isEnumerableProperty( beep, 'boop' );\n* // returns true\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = isEnumerableProperty( beep, 'hasOwnProperty' );\n* // returns false\n*/\nvar isEnumerableProperty = Object.prototype.propertyIsEnumerable;\n\n\n// EXPORTS //\n\nexport default isEnumerableProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isEnum from './native.js';\n\n\n// VARIABLES //\n\nvar bool;\n\n\n// FUNCTIONS //\n\n/**\n* Detects whether an environment has a bug where String indices are not detected as \"enumerable\" properties. Observed in Node v0.10.\n*\n* @private\n* @returns {boolean} boolean indicating whether an environment has the bug\n*/\nfunction detect() {\n\treturn !isEnum.call( 'beep', '0' );\n}\n\n\n// MAIN //\n\nbool = detect();\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isString from './../../is-string';\nimport { isPrimitive as isnan } from './../../is-nan';\nimport { isPrimitive as isInteger } from './../../is-integer';\nimport isEnum from './native.js';\nimport hasStringEnumBug from './has_string_enumerability_bug.js';\n\n\n// MAIN //\n\n/**\n* Tests if an object's own property is enumerable.\n*\n* @param {*} value - value to test\n* @param {*} property - property to test\n* @returns {boolean} boolean indicating if an object property is enumerable\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = isEnumerableProperty( beep, 'boop' );\n* // returns true\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = isEnumerableProperty( beep, 'hasOwnProperty' );\n* // returns false\n*/\nfunction isEnumerableProperty( value, property ) {\n\tvar bool;\n\tif (\n\t\tvalue === void 0 ||\n\t\tvalue === null\n\t) {\n\t\treturn false;\n\t}\n\tbool = isEnum.call( value, property );\n\tif ( !bool && hasStringEnumBug && isString( value ) ) {\n\t\t// Note: we only check for indices, as properties attached to a `String` object are properly detected as enumerable above.\n\t\tproperty = +property;\n\t\treturn (\n\t\t\t!isnan( property ) &&\n\t\t\tisInteger( property ) &&\n\t\t\tproperty >= 0 &&\n\t\t\tproperty < value.length\n\t\t);\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default isEnumerableProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is an `arguments` object.\n*\n* @module @stdlib/assert/is-arguments\n*\n* @example\n* import isArguments from '@stdlib/assert/is-arguments';\n*\n* function foo() {\n* return arguments;\n* }\n*\n* var bool = isArguments( foo() );\n* // returns true\n*\n* bool = isArguments( [] );\n* // returns false\n*/\n\n// MODULES //\n\nimport hasArgumentsClass from './detect.js';\nimport main from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar isArguments;\nif ( hasArgumentsClass ) {\n\tisArguments = main;\n} else {\n\tisArguments = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default isArguments;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasOwnProp from './../../has-own-property';\nimport isEnumerableProperty from './../../is-enumerable-property';\nimport isArray from './../../is-array';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport MAX_LENGTH from '@stdlib/constants/uint32/max';\n\n\n// MAIN //\n\n/**\n* Tests whether a value is an `arguments` object.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is an `arguments` object\n*\n* @example\n* function foo() {\n* return arguments;\n* }\n*\n* var bool = isArguments( foo() );\n* // returns true\n*\n* @example\n* var bool = isArguments( [] );\n* // returns false\n*/\nfunction isArguments( value ) {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === 'object' &&\n\t\t!isArray( value ) &&\n\t\ttypeof value.length === 'number' &&\n\t\tisInteger( value.length ) &&\n\t\tvalue.length >= 0 &&\n\t\tvalue.length <= MAX_LENGTH &&\n\t\thasOwnProp( value, 'callee' ) &&\n\t\t!isEnumerableProperty( value, 'callee' )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isArguments;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArguments from '@stdlib/assert/is-arguments';\nimport builtin from './builtin.js';\n\n\n// VARIABLES //\n\nvar slice = Array.prototype.slice;\n\n\n// MAIN //\n\n/**\n* Returns an array of an object's own enumerable property names.\n*\n* @private\n* @param {*} value - input object\n* @returns {Array} a list of own enumerable property names\n*\n* @example\n* var obj = {\n* 'beep': 'boop',\n* 'foo': 3.14\n* };\n*\n* var k = keys( obj );\n* // e.g., returns [ 'beep', 'foo' ]\n*/\nfunction keys( value ) {\n\tif ( isArguments( value ) ) {\n\t\treturn builtin( slice.call( value ) );\n\t}\n\treturn builtin( value );\n}\n\n\n// EXPORTS //\n\nexport default keys;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isEnumerableProperty from '@stdlib/assert/is-enumerable-property';\nimport noop from './../../noop';\n\n\n// MAIN //\n\n// Note: certain environments treat an object's prototype as enumerable, which, as a matter of convention, it shouldn't be...\nvar bool = isEnumerableProperty( noop, 'prototype' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* No operation.\n*\n* @example\n* noop();\n* // ...does nothing.\n*/\nfunction noop() {\n\t// Empty function...\n}\n\n\n// EXPORTS //\n\nexport default noop;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isEnumerableProperty from '@stdlib/assert/is-enumerable-property';\n\n\n// VARIABLES //\n\nvar obj = {\n\t'toString': null\n};\n\n\n// MAIN //\n\n// Note: certain environments don't allow enumeration of overwritten properties which are considered non-enumerable...\nvar bool = !isEnumerableProperty( obj, 'toString' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from '@stdlib/assert/is-nan';\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @param {ArrayLike} arr - array-like object\n* @param {*} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (if negative, the start index is determined relative to last element)\n* @throws {TypeError} must provide an array-like object\n* @throws {TypeError} third argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = [ 4, 3, 2, 1 ];\n* var idx = indexOf( arr, 3 );\n* // returns 1\n*\n* @example\n* var arr = [ 4, 3, 2, 1 ];\n* var idx = indexOf( arr, 5 );\n* // returns -1\n*\n* @example\n* // Using a `fromIndex`:\n* var arr = [ 1, 2, 3, 4, 5, 2, 6 ];\n* var idx = indexOf( arr, 2, 3 );\n* // returns 5\n*\n* @example\n* // `fromIndex` which exceeds `array` length:\n* var arr = [ 1, 2, 3, 4, 2, 5 ];\n* var idx = indexOf( arr, 2, 10 );\n* // returns -1\n*\n* @example\n* // Negative `fromIndex`:\n* var arr = [ 1, 2, 3, 4, 5, 2, 6, 2 ];\n* var idx = indexOf( arr, 2, -4 );\n* // returns 5\n*\n* idx = indexOf( arr, 2, -1 );\n* // returns 7\n*\n* @example\n* // Negative `fromIndex` exceeding input `array` length:\n* var arr = [ 1, 2, 3, 4, 5, 2, 6 ];\n* var idx = indexOf( arr, 2, -10 );\n* // returns 1\n*\n* @example\n* // Array-like objects:\n* var str = 'bebop';\n* var idx = indexOf( str, 'o' );\n* // returns 3\n*/\nfunction indexOf( arr, searchElement, fromIndex ) {\n\tvar len;\n\tvar i;\n\tif ( !isCollection( arr ) && !isString( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', arr ) );\n\t}\n\tlen = arr.length;\n\tif ( len === 0 ) {\n\t\treturn -1;\n\t}\n\tif ( arguments.length === 3 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= 0 ) {\n\t\t\tif ( fromIndex >= len ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\ti = fromIndex;\n\t\t} else {\n\t\t\ti = len + fromIndex;\n\t\t\tif ( i < 0 ) {\n\t\t\t\ti = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\ti = 0;\n\t}\n\t// Check for `NaN`...\n\tif ( isnan( searchElement ) ) {\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tif ( isnan( arr[i] ) ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tif ( arr[ i ] === searchElement ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t}\n\treturn -1;\n}\n\n\n// EXPORTS //\n\nexport default indexOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests whether a value equals the prototype of its constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value equals the prototype of its constructor\n*/\nfunction isConstructorPrototype( value ) {\n\treturn ( value.constructor && value.constructor.prototype === value );\n}\n\n\n// EXPORTS //\n\nexport default isConstructorPrototype;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasArgumentsBug from './has_arguments_bug.js';\nimport HAS_BUILTIN from './has_builtin.js';\nimport builtin from './builtin.js';\nimport wrapper from './builtin_wrapper.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\n/**\n* Returns an array of an object's own enumerable property names.\n*\n* @name keys\n* @type {Function}\n* @param {*} value - input object\n* @returns {Array} a list of own enumerable property names\n*\n* @example\n* var obj = {\n* 'beep': 'boop',\n* 'foo': 3.14\n* };\n*\n* var k = keys( obj );\n* // e.g., returns [ 'beep', 'foo' ]\n*/\nvar keys;\nif ( HAS_BUILTIN ) {\n\tif ( hasArgumentsBug() ) {\n\t\tkeys = wrapper;\n\t} else {\n\t\tkeys = builtin;\n\t}\n} else {\n\tkeys = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default keys;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar w = ( typeof window === 'undefined' ) ? void 0 : window;\n\n\n// EXPORTS //\n\nexport default w;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport indexOf from './../../index-of';\nimport typeOf from './../../type-of';\nimport isConstructorPrototype from './is_constructor_prototype.js';\nimport EXCLUDED_KEYS from './excluded_keys.json';\nimport win from './window.js';\n\n\n// VARIABLES //\n\nvar bool;\n\n\n// FUNCTIONS //\n\n/**\n* Determines whether an environment throws when comparing to the prototype of a value's constructor (e.g., [IE9][1]).\n*\n* [1]: https://stackoverflow.com/questions/7688070/why-is-comparing-the-constructor-property-of-two-windows-unreliable\n*\n* @private\n* @returns {boolean} boolean indicating whether an environment is buggy\n*/\nfunction check() {\n\tvar k;\n\tif ( typeOf( win ) === 'undefined' ) {\n\t\treturn false;\n\t}\n\tfor ( k in win ) { // eslint-disable-line guard-for-in\n\t\ttry {\n\t\t\tif (\n\t\t\t\tindexOf( EXCLUDED_KEYS, k ) === -1 &&\n\t\t\t\thasOwnProp( win, k ) &&\n\t\t\t\twin[ k ] !== null &&\n\t\t\t\ttypeOf( win[ k ] ) === 'object'\n\t\t\t) {\n\t\t\t\tisConstructorPrototype( win[ k ] );\n\t\t\t}\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\nbool = check();\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar bool = ( typeof window !== 'undefined' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport keys from './builtin.js';\n\n\n// FUNCTIONS //\n\n/**\n* Tests the built-in `Object.keys()` implementation when provided `arguments`.\n*\n* @private\n* @returns {boolean} boolean indicating whether the built-in implementation returns the expected number of keys\n*/\nfunction test() {\n\treturn ( keys( arguments ) || '' ).length !== 2;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether the built-in `Object.keys()` implementation supports providing `arguments` as an input value.\n*\n* ## Notes\n*\n* - Safari 5.0 does **not** support `arguments` as an input value.\n*\n* @private\n* @returns {boolean} boolean indicating whether a built-in implementation supports `arguments`\n*/\nfunction check() {\n\treturn test( 1, 2 );\n}\n\n\n// EXPORTS //\n\nexport default check;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObjectLike from '@stdlib/assert/is-object-like';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport isArguments from '@stdlib/assert/is-arguments';\nimport HAS_ENUM_PROTO_BUG from './has_enumerable_prototype_bug.js';\nimport HAS_NON_ENUM_PROPS_BUG from './has_non_enumerable_properties_bug.js';\nimport isConstructorPrototype from './is_constructor_prototype_wrapper.js';\nimport NON_ENUMERABLE from './non_enumerable.json';\n\n\n// MAIN //\n\n/**\n* Returns an array of an object's own enumerable property names.\n*\n* @private\n* @param {*} value - input object\n* @returns {Array} a list of own enumerable property names\n*\n* @example\n* var obj = {\n* 'beep': 'boop',\n* 'foo': 3.14\n* };\n*\n* var k = keys( obj );\n* // e.g., returns [ 'beep', 'foo' ]\n*/\nfunction keys( value ) {\n\tvar skipConstructor;\n\tvar skipPrototype;\n\tvar isFcn;\n\tvar out;\n\tvar k;\n\tvar p;\n\tvar i;\n\n\tout = [];\n\tif ( isArguments( value ) ) {\n\t\t// Account for environments which treat `arguments` differently...\n\t\tfor ( i = 0; i < value.length; i++ ) {\n\t\t\tout.push( i.toString() );\n\t\t}\n\t\t// Note: yes, we are precluding the `arguments` array-like object from having other enumerable properties; however, this should (1) be very rare and (2) not be encouraged (e.g., doing something like `arguments.a = 'b'`; in certain engines directly manipulating the `arguments` value results in automatic de-optimization).\n\t\treturn out;\n\t}\n\tif ( typeof value === 'string' ) {\n\t\t// Account for environments which do not treat string character indices as \"own\" properties...\n\t\tif ( value.length > 0 && !hasOwnProp( value, '0' ) ) {\n\t\t\tfor ( i = 0; i < value.length; i++ ) {\n\t\t\t\tout.push( i.toString() );\n\t\t\t}\n\t\t}\n\t} else {\n\t\tisFcn = ( typeof value === 'function' );\n\t\tif ( isFcn === false && !isObjectLike( value ) ) {\n\t\t\treturn out;\n\t\t}\n\t\tskipPrototype = ( HAS_ENUM_PROTO_BUG && isFcn );\n\t}\n\tfor ( k in value ) {\n\t\tif ( !( skipPrototype && k === 'prototype' ) && hasOwnProp( value, k ) ) {\n\t\t\tout.push( String( k ) );\n\t\t}\n\t}\n\tif ( HAS_NON_ENUM_PROPS_BUG ) {\n\t\tskipConstructor = isConstructorPrototype( value );\n\t\tfor ( i = 0; i < NON_ENUMERABLE.length; i++ ) {\n\t\t\tp = NON_ENUMERABLE[ i ];\n\t\t\tif ( !( skipConstructor && p === 'constructor' ) && hasOwnProp( value, p ) ) {\n\t\t\t\tout.push( String( p ) );\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default keys;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasAutomationEqualityBug from './has_automation_equality_bug.js';\nimport isConstructorPrototype from './is_constructor_prototype.js';\nimport HAS_WINDOW from './has_window.js';\n\n\n// MAIN //\n\n/**\n* Wraps the test for constructor prototype equality to accommodate buggy environments (e.g., environments which throw when testing equality).\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value equals the prototype of its constructor\n*/\nfunction wrapper( value ) {\n\tif ( HAS_WINDOW === false && !hasAutomationEqualityBug ) {\n\t\treturn isConstructorPrototype( value );\n\t}\n\ttry {\n\t\treturn isConstructorPrototype( value );\n\t} catch ( error ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default wrapper;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert/is-function';\nimport builtin from './native.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar getProto;\nif ( isFunction( Object.getPrototypeOf ) ) {\n\tgetProto = builtin;\n} else {\n\tgetProto = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default getProto;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an object.\n*\n* @name Object\n* @constructor\n* @type {Function}\n* @param {*} value - input value\n* @returns {Object} object\n*\n* @example\n* var o = new Object( null );\n* // returns {}\n*\n* @example\n* var o = new Object( 5.0 );\n* // returns \n*\n* @example\n* var o = new Object( 'beep' );\n* // returns \n*\n* @example\n* var o1 = {};\n*\n* var o2 = new Object( o1 );\n* // returns {}\n*\n* var bool = ( o1 === o2 );\n* // returns true\n*/\nvar Obj = Object; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Obj;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar getProto = Object.getPrototypeOf;\n\n\n// EXPORTS //\n\nexport default getProto;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from './../../native-class';\nimport Object from '@stdlib/object/ctor';\nimport getProto from './proto.js';\n\n\n// MAIN //\n\n/**\n* Returns the prototype of a provided object.\n*\n* @private\n* @param {Object} obj - input object\n* @returns {(Object|null)} prototype\n*/\nfunction getPrototypeOf( obj ) {\n\tvar proto = getProto( obj );\n\tif ( proto || proto === null ) {\n\t\treturn proto;\n\t}\n\tif ( nativeClass( obj.constructor ) === '[object Function]' ) {\n\t\t// May break if the constructor has been tampered with...\n\t\treturn obj.constructor.prototype;\n\t}\n\tif ( obj instanceof Object ) {\n\t\treturn Object.prototype;\n\t}\n\t// Return `null` for objects created via `Object.create( null )`. Also return `null` for cross-realm objects on browsers that lack `__proto__` support, such as IE < 11.\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default getPrototypeOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Returns the value of the `__proto__` property.\n*\n* @private\n* @param {Object} obj - input object\n* @returns {*} value of `__proto__` property\n*/\nfunction getProto( obj ) {\n\t// eslint-disable-next-line no-proto\n\treturn obj.__proto__;\n}\n\n\n// EXPORTS //\n\nexport default getProto;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Object from '@stdlib/object/ctor';\nimport getProto from './detect.js';\n\n\n// MAIN //\n\n/**\n* Returns the prototype of a provided object.\n*\n* @param {*} value - input value\n* @returns {(Object|null)} prototype\n*\n* @example\n* var proto = getPrototypeOf( {} );\n* // returns {}\n*/\nfunction getPrototypeOf( value ) {\n\tif (\n\t\tvalue === null ||\n\t\tvalue === void 0\n\t) {\n\t\treturn null;\n\t}\n\t// In order to ensure consistent ES5/ES6 behavior, cast input value to an object (strings, numbers, booleans); ES5 `Object.getPrototypeOf` throws when provided primitives and ES6 `Object.getPrototypeOf` casts:\n\tvalue = Object( value );\n\n\treturn getProto( value );\n}\n\n\n// EXPORTS //\n\nexport default getPrototypeOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from './../../is-object';\nimport isFunction from './../../is-function';\nimport getPrototypeOf from '@stdlib/utils/get-prototype-of';\nimport hasOwnProp from './../../has-own-property';\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar objectPrototype = Object.prototype;\n\n\n// FUNCTIONS //\n\n/**\n* Tests that an object only has own properties.\n*\n* @private\n* @param {Object} obj - value to test\n* @returns {boolean} boolean indicating if an object only has own properties\n*/\nfunction ownProps( obj ) {\n\tvar key;\n\n\t// NOTE: possibility of perf boost if key enumeration order is known (see http://stackoverflow.com/questions/18531624/isplainobject-thing).\n\tfor ( key in obj ) {\n\t\tif ( !hasOwnProp( obj, key ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests if a value is a plain object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a plain object\n*\n* @example\n* var bool = isPlainObject( {} );\n* // returns true\n*\n* @example\n* var bool = isPlainObject( null );\n* // returns false\n*/\nfunction isPlainObject( value ) {\n\tvar proto;\n\n\t// Screen for obvious non-objects...\n\tif ( !isObject( value ) ) {\n\t\treturn false;\n\t}\n\t// Objects with no prototype (e.g., `Object.create( null )`) are plain...\n\tproto = getPrototypeOf( value );\n\tif ( !proto ) {\n\t\treturn true;\n\t}\n\t// Objects having a prototype are plain if and only if they are constructed with a global `Object` function and the prototype points to the prototype of a plain object...\n\treturn (\n\t\t// Cannot have own `constructor` property:\n\t\t!hasOwnProp( value, 'constructor' ) &&\n\n\t\t// Prototype `constructor` property must be a function (see also https://bugs.jquery.com/ticket/9897 and http://stackoverflow.com/questions/18531624/isplainobject-thing):\n\t\thasOwnProp( proto, 'constructor' ) &&\n\t\tisFunction( proto.constructor ) &&\n\t\tnativeClass( proto.constructor ) === '[object Function]' &&\n\n\t\t// Test for object-specific method:\n\t\thasOwnProp( proto, 'isPrototypeOf' ) &&\n\t\tisFunction( proto.isPrototypeOf ) &&\n\n\t\t(\n\t\t\t// Test if the prototype matches the global `Object` prototype (same realm):\n\t\t\tproto === objectPrototype ||\n\n\t\t\t// Test that all properties are own properties (cross-realm; *most* likely a plain object):\n\t\t\townProps( value )\n\t\t)\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isPlainObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport DTYPES from './dtypes.json';\n\n\n// MAIN //\n\n/**\n* Returns a list of strided array data type strings.\n*\n* @returns {StringArray} list of strided array data type strings\n*\n* @example\n* var list = dtypes();\n* // returns [...]\n*/\nfunction dtypes() {\n\treturn DTYPES.slice();\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string/base/replace';\nimport DTYPES from './dtypes.json';\n\n\n// VARIABLES //\n\nvar RE_SUFFIX = /_and_generic$/;\n\n\n// MAIN //\n\n/**\n* Returns a list of ndarray data types.\n*\n* @param {string} [kind] - data type kind\n* @returns {StringArray} list of ndarray data types\n*\n* @example\n* var list = dtypes();\n* // returns [...]\n*\n* @example\n* var list = dtypes( 'floating_point' );\n* // returns [...]\n*/\nfunction dtypes() {\n\tvar kind;\n\tvar out;\n\tvar FLG;\n\tif ( arguments.length === 0 ) {\n\t\treturn DTYPES.all.slice();\n\t}\n\tFLG = false;\n\tkind = arguments[ 0 ];\n\tif ( RE_SUFFIX.test( kind ) ) {\n\t\tkind = replace( kind, RE_SUFFIX, '' );\n\t\tif ( kind !== 'all' && kind !== 'index' ) {\n\t\t\tFLG = true;\n\t\t}\n\t}\n\tout = DTYPES[ kind ];\n\tout = ( out ) ? out.slice() : [];\n\tif ( FLG && out.length > 0 ) {\n\t\tout.push( 'generic' );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable stdlib/empty-line-before-comment */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an object mapping supported data type strings to enumeration constants.\n*\n* ## Notes\n*\n* - Downstream consumers of this mapping should **not** rely on specific integer values (e.g., `INT8 == 0`). Instead, the object should be used in an opaque manner.\n* - The main purpose of this function is JavaScript and C inter-operation of ndarray objects. While certain dtypes, such as \"generic\" and \"binary\", have special behavior in JavaScript, they do not have a direct complement in C.\n*\n* @private\n* @returns {Object} object mapping supported dtypes to enumeration constants\n*\n* @example\n* var table = enumeration();\n* // returns \n*/\nfunction enumeration() {\n\t// NOTE: the following should match the C `dtypes.h` enumeration!!!!\n\treturn {\n\t\t// Boolean data types:\n\t\t'bool': 0,\n\n\t\t// Integer data types:\n\t\t'int8': 1,\n\t\t'uint8': 2,\n\t\t'uint8c': 3,\n\t\t'int16': 4,\n\t\t'uint16': 5,\n\t\t'int32': 6,\n\t\t'uint32': 7,\n\t\t'int64': 8,\n\t\t'uint64': 9,\n\t\t// 'int128': 10, // uncomment once supported\n\t\t// 'uint128': 11,\n\t\t// 'int256': 12,\n\t\t// 'uint256': 13,\n\n\t\t// Floating-point data types:\n\t\t'float16': 10,\n\t\t// 'bfloat16': 15,\n\t\t'float32': 11,\n\t\t'float64': 12,\n\t\t// 'float128': 18, // uncomment once supported\n\n\t\t// Complex floating-point number data types:\n\t\t'complex32': 13,\n\t\t'complex64': 14,\n\t\t'complex128': 15,\n\n\t\t// Data type for \"binary\" data (i.e., data stored in a Node.js `Buffer` object):\n\t\t'binary': 16,\n\n\t\t// Data type for \"generic\" JavaScript values (objects):\n\t\t'generic': 17,\n\n\t\t// Define a signaling value which is guaranteed not to be a valid type enumeration value:\n\t\t'notype': 18,\n\n\t\t// Indicate the start of user defined type numbers (leaving room for type growth above):\n\t\t'userdefined_type': 256\n\t};\n}\n\n\n// EXPORTS //\n\nexport default enumeration;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return a list of ndarray data types.\n*\n* @module @stdlib/ndarray/dtypes\n*\n* @example\n* import dtypes from '@stdlib/ndarray/dtypes';\n*\n* var list = dtypes();\n* // returns [...]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport enumeration from './enum.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'enum', enumeration );\nassign( main, enumeration() );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\nimport objectKeys from '@stdlib/utils/keys';\n\n\n// MAIN //\n\n/**\n* Copies all enumerable own properties from a source object to a target object as enumerable read-only properties.\n*\n* @private\n* @param {Object} target - target object\n* @param {Object} source - source object\n* @returns {Object} modified target object\n*\n* @example\n* var source = {\n* 'beep': 'boop'\n* };\n* var target = {};\n*\n* var out = assign( target, source );\n* // returns \n*\n* var bool = ( out === target );\n* // returns true\n*\n* var v = target.beep;\n* // returns 'boop'\n*/\nfunction assign( target, source ) {\n\tvar keys;\n\tvar k;\n\tvar i;\n\n\tkeys = objectKeys( source );\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tsetReadOnly( target, k, source[ k ] );\n\t}\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { enum as ndtypes } from '@stdlib/ndarray/dtypes';\n\n\n// VARIABLES //\n\nvar dt = ndtypes();\n\n\n// MAIN //\n\n/**\n* Returns an object mapping supported data strings to enumeration constants for purposes of C inter-operation.\n*\n* ## Notes\n*\n* - Downstream consumers of this mapping should **not** rely on specific integer values (e.g., `INT8 == 0`). Instead, the object should be used in an opaque manner.\n* - The main purpose of this function is JavaScript and C inter-operation of strided arrays.\n*\n* @private\n* @returns {Object} object mapping supported data strings strings to enumeration constants\n*\n* @example\n* var table = enumeration();\n* // returns \n*/\nfunction enumeration() {\n\t// NOTE: the returned object should match the C `dtypes.h` enumeration!!!!\n\treturn {\n\t\t'bool': dt[ 'bool' ],\n\n\t\t'int8': dt[ 'int8' ],\n\t\t'uint8': dt[ 'uint8' ],\n\t\t'uint8c': dt[ 'uint8c' ],\n\t\t'int16': dt[ 'int16' ],\n\t\t'uint16': dt[ 'uint16' ],\n\t\t'int32': dt[ 'int32' ],\n\t\t'uint32': dt[ 'uint32' ],\n\t\t'int64': dt[ 'int64' ],\n\t\t'uint64': dt[ 'uint64' ],\n\n\t\t'float32': dt[ 'float32' ],\n\t\t'float64': dt[ 'float64' ],\n\n\t\t'complex64': dt[ 'complex64' ],\n\t\t'complex128': dt[ 'complex128' ],\n\n\t\t'binary': dt[ 'binary' ],\n\n\t\t'generic': dt[ 'generic' ],\n\n\t\t'notype': dt[ 'notype' ],\n\n\t\t'userdefined_type': dt[ 'userdefined_type' ]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default enumeration;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return a list of strided array data types.\n*\n* @module @stdlib/strided/dtypes\n*\n* @example\n* import dtypes from '@stdlib/strided/dtypes';\n*\n* var list = dtypes();\n* // returns [...]\n*\n* @example\n* import { enum as enumeration } from '@stdlib/strided/dtypes';\n*\n* var table = enumeration();\n* // returns {...}\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport enumeration from './enum.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'enum', enumeration );\nassign( main, enumeration() );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\nimport objectKeys from '@stdlib/utils/keys';\n\n\n// MAIN //\n\n/**\n* Copies all enumerable own properties from a source object to a target object as enumerable read-only properties.\n*\n* @private\n* @param {Object} target - target object\n* @param {Object} source - source object\n* @returns {Object} modified target object\n*\n* @example\n* var source = {\n* 'beep': 'boop'\n* };\n* var target = {};\n*\n* var out = assign( target, source );\n* // returns \n*\n* var bool = ( out === target );\n* // returns true\n*\n* var v = target.beep;\n* // returns 'boop'\n*/\nfunction assign( target, source ) {\n\tvar keys;\n\tvar k;\n\tvar i;\n\n\tkeys = objectKeys( source );\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tsetReadOnly( target, k, source[ k ] );\n\t}\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectInverse from '@stdlib/utils/object-inverse';\nimport { enum as enumeration } from './../../../dtypes';\n\n\n// VARIABLES //\n\nvar hash = objectInverse( enumeration(), {\n\t'duplicates': false\n});\n\n\n// MAIN //\n\n/**\n* Returns the data type string associated with a strided array data type enumeration constant.\n*\n* @param {integer} dtype - data type enumeration constant\n* @returns {(string|null)} data type string or null\n*\n* @example\n* import str2enum from '@stdlib/strided/base/dtype-str2enum';\n*\n* var v = str2enum( 'float64' );\n* // returns \n*\n* var dt = enum2str( v );\n* // returns 'float64'\n*/\nfunction enum2str( dtype ) {\n\tvar v = hash[ dtype ];\n\treturn ( typeof v === 'string' ) ? v : null; // note: we include this guard to prevent walking the prototype chain\n}\n\n\n// EXPORTS //\n\nexport default enum2str;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from './../../keys';\nimport isArray from '@stdlib/assert/is-array';\nimport isObject from '@stdlib/assert/is-plain-object';\nimport isObjectLike from '@stdlib/assert/is-object-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Inverts an object, such that keys become values and values become keys.\n*\n* @param {ObjectLike} obj - input object\n* @param {Options} [opts] - function options\n* @param {boolean} [opts.duplicates=true] - boolean indicating whether to store duplicate keys\n* @throws {TypeError} first argument must be object-like\n* @throws {TypeError} second argument must an an object\n* @throws {TypeError} must provide valid options\n* @returns {Object} inverted object\n*\n* @example\n* var out = invert({\n* 'a': 'beep',\n* 'b': 'boop'\n* });\n* // returns { 'beep': 'a', 'boop': 'b' }\n*\n* @example\n* var out = invert({\n* 'a': 'beep',\n* 'b': 'beep'\n* });\n* // returns { 'beep': [ 'a', 'b' ] }\n*\n* @example\n* var obj = {};\n* obj.a = 'beep';\n* obj.b = 'boop';\n* obj.c = 'beep'; // inserted after `a`\n*\n* var out = invert( obj, {\n* 'duplicates': false\n* });\n* // returns { 'beep': 'c', 'boop': 'b' }\n*/\nfunction invert( obj, opts ) {\n\tvar allowDupes = true;\n\tvar keys;\n\tvar len;\n\tvar key;\n\tvar val;\n\tvar out;\n\tvar v;\n\tvar i;\n\tif ( !isObjectLike( obj ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object (except null). Value: `%s`.', obj ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\tif ( hasOwnProp( opts, 'duplicates' ) ) {\n\t\t\tallowDupes = opts.duplicates;\n\t\t\tif ( !isBoolean( allowDupes ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'duplicates', allowDupes ) );\n\t\t\t}\n\t\t}\n\t}\n\tkeys = objectKeys( obj );\n\tlen = keys.length;\n\tout = {};\n\tif ( allowDupes ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tkey = keys[ i ];\n\t\t\tval = obj[ key ];\n\t\t\tif ( !hasOwnProp( out, val ) ) {\n\t\t\t\tout[ val ] = key;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tv = out[ val ];\n\t\t\tif ( isArray( v ) ) {\n\t\t\t\tout[ val ].push( key );\n\t\t\t} else {\n\t\t\t\tout[ val ] = [ v, key ];\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tkey = keys[ i ];\n\t\t\tout[ obj[ key ] ] = key;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default invert;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { enum as enumeration } from './../../../dtypes';\n\n\n// VARIABLES //\n\nvar ENUM = enumeration();\n\n\n// MAIN //\n\n/**\n* Returns the enumeration constant associated with a strided array data type string.\n*\n* ## Notes\n*\n* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `INT8 == 0`). Instead, the function should be used in an opaque manner.\n*\n* @param {string} dtype - data type string\n* @returns {(integer|null)} integer value or null\n*\n* @example\n* var v = str2enum( 'int8' );\n* // returns \n*/\nfunction str2enum( dtype ) {\n\tvar v = ENUM[ dtype ];\n\treturn ( typeof v === 'number' ) ? v : null; // note: we include this guard to prevent walking the prototype chain\n}\n\n\n// EXPORTS //\n\nexport default str2enum;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport enum2str from './../../../base/dtype-enum2str';\nimport str2enum from './../../../base/dtype-str2enum';\n\n\n// MAIN //\n\n/**\n* Returns the data type string associated with a supported strided array data type value.\n*\n* @param {*} dtype - data type value\n* @returns {(string|null)} data type string or null\n*\n* @example\n* import str2enum from '@stdlib/strided/base/dtype-str2enum';\n*\n* var v = resolve( str2enum( 'float64' ) );\n* // returns 'float64'\n*/\nfunction resolve( dtype ) {\n\tvar t = ( typeof dtype );\n\tif ( t === 'string' ) {\n\t\treturn ( str2enum( dtype ) === null ) ? null : dtype;\n\t}\n\tif ( t === 'number' ) {\n\t\treturn enum2str( dtype );\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default resolve;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport resolve from '@stdlib/strided/base/dtype-resolve-str';\nimport CASTS from './data.json';\n\n\n// VARIABLES //\n\nvar TABLE;\n\n\n// FUNCTIONS //\n\n/**\n* Generates a full table of casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateFullTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = CASTS[ dt1 ];\n\t\ttmp = {};\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\ttmp[ dt2 ] = o[ dt2 ];\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n/**\n* Generates a table of casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = CASTS[ dt1 ];\n\t\ttmp = [];\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\tif ( o[ dt2 ] === 1 ) {\n\t\t\t\ttmp.push( dt2 );\n\t\t\t}\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a list of array data types to which a provided array data type can be safely cast and, for floating-point data types, can be downcast.\n*\n* @param {*} [dtype] - array data type value\n* @returns {(Object|StringArray|null)} list of array data types or null\n*\n* @example\n* var list = mostlySafeCasts( 'float32' );\n* // returns [...]\n*/\nfunction mostlySafeCasts( dtype ) {\n\tif ( arguments.length === 0 ) {\n\t\treturn generateFullTable();\n\t}\n\tif ( TABLE === void 0 ) {\n\t\t// Lazily generate table...\n\t\tTABLE = generateTable();\n\t}\n\tdtype = resolve( dtype );\n\tif ( hasOwnProp( TABLE, dtype ) ) {\n\t\treturn TABLE[ dtype ].slice();\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default mostlySafeCasts;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport casts from './../../../../mostly-safe-casts';\n\n\n// VARIABLES //\n\nvar TABLE = casts();\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a provided array data type can be safely cast or, for floating-point data types, downcast to another array data type.\n*\n* @param {string} from - array data type\n* @param {string} to - array data type\n* @returns {boolean} boolean indicating if a data type can be cast to another data type\n*\n* @example\n* var bool = isMostlySafeCast( 'float32', 'float64' );\n* // returns true\n*\n* bool = isMostlySafeCast( 'float64', 'int32' );\n* // returns false\n*/\nfunction isMostlySafeCast( from, to ) {\n\tif ( from === to ) {\n\t\treturn true;\n\t}\n\treturn ( TABLE[ from ][ to ] > 0 );\n}\n\n\n// EXPORTS //\n\nexport default isMostlySafeCast;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array numeric data type.\n*\n* @name isNumericDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array numeric data type\n*\n* @example\n* var bool = isNumericDataType( 'float32' );\n* // returns true\n*\n* bool = isNumericDataType( 'float64' );\n* // returns true\n*\n* bool = isNumericDataType( 'generic' );\n* // returns false\n*\n* bool = isNumericDataType( 'int16' );\n* // returns true\n*\n* bool = isNumericDataType( 'int32' );\n* // returns true\n*\n* bool = isNumericDataType( 'int8' );\n* // returns true\n*\n* bool = isNumericDataType( 'uint16' );\n* // returns true\n*\n* bool = isNumericDataType( 'uint32' );\n* // returns true\n*\n* bool = isNumericDataType( 'uint8' );\n* // returns true\n*\n* bool = isNumericDataType( 'uint8c' );\n* // returns true\n*\n* bool = isNumericDataType( 'foo' );\n* // returns false\n*/\nvar isNumericDataType = contains( dtypes( 'numeric' ) );\n\n\n// EXPORTS //\n\nexport default isNumericDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport resolve from '@stdlib/strided/base/dtype-resolve-str';\nimport SAFE_CASTS from './safe_casts.json';\n\n\n// VARIABLES //\n\nvar TABLE;\n\n\n// FUNCTIONS //\n\n/**\n* Generates a full table of safe casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateFullTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( SAFE_CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = SAFE_CASTS[ dt1 ];\n\t\ttmp = {};\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\ttmp[ dt2 ] = o[ dt2 ];\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n/**\n* Generates a table of safe casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( SAFE_CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = SAFE_CASTS[ dt1 ];\n\t\ttmp = [];\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\tif ( o[ dt2 ] === 1 ) {\n\t\t\t\ttmp.push( dt2 );\n\t\t\t}\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a list of array data types to which a provided array data type can be safely cast.\n*\n* @param {*} [dtype] - array data type value\n* @returns {(Object|StringArray|null)} list of array data types or null\n*\n* @example\n* var list = safeCasts( 'float32' );\n* // returns [...]\n*/\nfunction safeCasts( dtype ) {\n\tif ( arguments.length === 0 ) {\n\t\treturn generateFullTable();\n\t}\n\tif ( TABLE === void 0 ) {\n\t\t// Lazily generate table...\n\t\tTABLE = generateTable();\n\t}\n\tdtype = resolve( dtype );\n\tif ( hasOwnProp( TABLE, dtype ) ) {\n\t\treturn TABLE[ dtype ].slice();\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default safeCasts;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array real-valued data type.\n*\n* @name isRealDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array real-valued data type\n*\n* @example\n* var bool = isRealDataType( 'float32' );\n* // returns true\n*\n* bool = isRealDataType( 'float64' );\n* // returns true\n*\n* bool = isRealDataType( 'complex128' );\n* // returns false\n*\n* bool = isRealDataType( 'generic' );\n* // returns false\n*\n* bool = isRealDataType( 'int16' );\n* // returns true\n*\n* bool = isRealDataType( 'int32' );\n* // returns true\n*\n* bool = isRealDataType( 'int8' );\n* // returns true\n*\n* bool = isRealDataType( 'uint16' );\n* // returns true\n*\n* bool = isRealDataType( 'uint32' );\n* // returns true\n*\n* bool = isRealDataType( 'uint8' );\n* // returns true\n*\n* bool = isRealDataType( 'uint8c' );\n* // returns true\n*\n* bool = isRealDataType( 'foo' );\n* // returns false\n*/\nvar isRealDataType = contains( dtypes( 'real' ) );\n\n\n// EXPORTS //\n\nexport default isRealDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array real-valued floating-point data type.\n*\n* @name isRealFloatingPointDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array real-valued floating-point data type\n*\n* @example\n* var bool = isRealFloatingPointDataType( 'float32' );\n* // returns true\n*\n* bool = isRealFloatingPointDataType( 'float64' );\n* // returns true\n*\n* bool = isRealFloatingPointDataType( 'generic' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'int16' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'int32' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'int8' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'uint16' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'uint32' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'uint8' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'uint8c' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'foo' );\n* // returns false\n*/\nvar isRealFloatingPointDataType = contains( dtypes( 'real_floating_point' ) ); // eslint-disable-line id-length\n\n\n// EXPORTS //\n\nexport default isRealFloatingPointDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport safeCasts from './../../../../safe-casts';\n\n\n// VARIABLES //\n\nvar TABLE = safeCasts();\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a provided array data type can be safely cast to another array data type.\n*\n* @param {string} from - array data type\n* @param {string} to - array data type\n* @returns {boolean} boolean indicating if a data type can be safely cast to another data type\n*\n* @example\n* var bool = isSafeCast( 'float32', 'float64' );\n* // returns true\n*\n* bool = isSafeCast( 'float64', 'int32' );\n* // returns false\n*/\nfunction isSafeCast( from, to ) {\n\tif ( from === to ) {\n\t\treturn true;\n\t}\n\treturn ( TABLE[ from ][ to ] > 0 );\n}\n\n\n// EXPORTS //\n\nexport default isSafeCast;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport resolve from '@stdlib/strided/base/dtype-resolve-str';\nimport SAME_KIND_CASTS from './same_kind_casts.json';\n\n\n// VARIABLES //\n\nvar TABLE;\n\n\n// FUNCTIONS //\n\n/**\n* Generates a full table of same \"kind\" casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateFullTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( SAME_KIND_CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = SAME_KIND_CASTS[ dt1 ];\n\t\ttmp = {};\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\ttmp[ dt2 ] = o[ dt2 ];\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n/**\n* Generates a table of same \"kind\" casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( SAME_KIND_CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = SAME_KIND_CASTS[ dt1 ];\n\t\ttmp = [];\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\tif ( o[ dt2 ] === 1 ) {\n\t\t\t\ttmp.push( dt2 );\n\t\t\t}\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a list of array data types to which a provided array data type can be safely cast or cast within the same \"kind\".\n*\n* @param {*} [dtype] - array data type value\n* @returns {(Object|StringArray|null)} list of array data types or null\n*\n* @example\n* var list = sameKindCasts( 'float32' );\n* // returns [...]\n*/\nfunction sameKindCasts( dtype ) {\n\tif ( arguments.length === 0 ) {\n\t\treturn generateFullTable();\n\t}\n\tif ( TABLE === void 0 ) {\n\t\t// Lazily generate table...\n\t\tTABLE = generateTable();\n\t}\n\tdtype = resolve( dtype );\n\tif ( hasOwnProp( TABLE, dtype ) ) {\n\t\treturn TABLE[ dtype ].slice();\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default sameKindCasts;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport sameKindCasts from './../../../../same-kind-casts';\n\n\n// VARIABLES //\n\nvar TABLE = sameKindCasts();\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a provided array data type can be safely cast to, or is of the same \"kind\" as, another array data type.\n*\n* @param {string} from - array data type\n* @param {string} to - array data type\n* @returns {boolean} boolean indicating if a data type can be cast to another data type\n*\n* @example\n* var bool = isSameKindCast( 'float32', 'float64' );\n* // returns true\n*\n* bool = isSameKindCast( 'uint16', 'int16' );\n* // returns false\n*/\nfunction isSameKindCast( from, to ) {\n\tif ( from === to ) {\n\t\treturn true;\n\t}\n\treturn ( TABLE[ from ][ to ] > 0 );\n}\n\n\n// EXPORTS //\n\nexport default isSameKindCast;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array signed integer data type.\n*\n* @name isSignedIntegerDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array signed integer data type\n*\n* @example\n* var bool = isSignedIntegerDataType( 'float32' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'float64' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'generic' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'int16' );\n* // returns true\n*\n* bool = isSignedIntegerDataType( 'int32' );\n* // returns true\n*\n* bool = isSignedIntegerDataType( 'int8' );\n* // returns true\n*\n* bool = isSignedIntegerDataType( 'uint16' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'uint32' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'uint8' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'uint8c' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'foo' );\n* // returns false\n*/\nvar isSignedIntegerDataType = contains( dtypes( 'signed_integer' ) );\n\n\n// EXPORTS //\n\nexport default isSignedIntegerDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array unsigned integer data type.\n*\n* @name isUnsignedIntegerDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array unsigned integer data type\n*\n* @example\n* var bool = isUnsignedIntegerDataType( 'float32' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'float64' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'generic' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'int16' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'int32' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'int8' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'uint16' );\n* // returns true\n*\n* bool = isUnsignedIntegerDataType( 'uint32' );\n* // returns true\n*\n* bool = isUnsignedIntegerDataType( 'uint8' );\n* // returns true\n*\n* bool = isUnsignedIntegerDataType( 'uint8c' );\n* // returns true\n*\n* bool = isUnsignedIntegerDataType( 'foo' );\n* // returns false\n*/\nvar isUnsignedIntegerDataType = contains( dtypes( 'unsigned_integer' ) );\n\n\n// EXPORTS //\n\nexport default isUnsignedIntegerDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name contains\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/contains}\n*/\nimport contains from './../../../base/assert/contains';\nsetReadOnly( ns, 'contains', contains );\n\n/**\n* @name hasAlmostEqualValues\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/has-almost-equal-values}\n*/\nimport hasAlmostEqualValues from './../../../base/assert/has-almost-equal-values';\nsetReadOnly( ns, 'hasAlmostEqualValues', hasAlmostEqualValues );\n\n/**\n* @name hasEqualValues\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/has-equal-values}\n*/\nimport hasEqualValues from './../../../base/assert/has-equal-values';\nsetReadOnly( ns, 'hasEqualValues', hasEqualValues );\n\n/**\n* @name hasEqualValuesIndexed\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/has-equal-values-indexed}\n*/\nimport hasEqualValuesIndexed from './../../../base/assert/has-equal-values-indexed';\nsetReadOnly( ns, 'hasEqualValuesIndexed', hasEqualValuesIndexed );\n\n/**\n* @name hasSameValues\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/has-same-values}\n*/\nimport hasSameValues from './../../../base/assert/has-same-values';\nsetReadOnly( ns, 'hasSameValues', hasSameValues );\n\n/**\n* @name isAccessorArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-accessor-array}\n*/\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nsetReadOnly( ns, 'isAccessorArray', isAccessorArray );\n\n/**\n* @name isBooleanDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-boolean-data-type}\n*/\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nsetReadOnly( ns, 'isBooleanDataType', isBooleanDataType );\n\n/**\n* @name isBooleanArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-booleanarray}\n*/\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nsetReadOnly( ns, 'isBooleanArray', isBooleanArray );\n\n/**\n* @name isByteOrder\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-byte-order}\n*/\nimport isByteOrder from './../../../base/assert/is-byte-order';\nsetReadOnly( ns, 'isByteOrder', isByteOrder );\n\n/**\n* @name isComplexFloatingPointDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-complex-floating-point-data-type}\n*/\nimport isComplexFloatingPointDataType from './../../../base/assert/is-complex-floating-point-data-type';\nsetReadOnly( ns, 'isComplexFloatingPointDataType', isComplexFloatingPointDataType );\n\n/**\n* @name isComplexTypedArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-complex-typed-array}\n*/\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nsetReadOnly( ns, 'isComplexTypedArray', isComplexTypedArray );\n\n/**\n* @name isComplex64Array\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-complex64array}\n*/\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nsetReadOnly( ns, 'isComplex64Array', isComplex64Array );\n\n/**\n* @name isComplex128Array\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-complex128array}\n*/\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nsetReadOnly( ns, 'isComplex128Array', isComplex128Array );\n\n/**\n* @name isDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-data-type}\n*/\nimport isDataType from './../../../base/assert/is-data-type';\nsetReadOnly( ns, 'isDataType', isDataType );\n\n/**\n* @name isFloatingPointDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-floating-point-data-type}\n*/\nimport isFloatingPointDataType from './../../../base/assert/is-floating-point-data-type';\nsetReadOnly( ns, 'isFloatingPointDataType', isFloatingPointDataType );\n\n/**\n* @name isIntegerDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-integer-data-type}\n*/\nimport isIntegerDataType from './../../../base/assert/is-integer-data-type';\nsetReadOnly( ns, 'isIntegerDataType', isIntegerDataType );\n\n/**\n* @name isMostlySafeDataTypeCast\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-mostly-safe-data-type-cast}\n*/\nimport isMostlySafeDataTypeCast from './../../../base/assert/is-mostly-safe-data-type-cast';\nsetReadOnly( ns, 'isMostlySafeDataTypeCast', isMostlySafeDataTypeCast );\n\n/**\n* @name isNumericDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-numeric-data-type}\n*/\nimport isNumericDataType from './../../../base/assert/is-numeric-data-type';\nsetReadOnly( ns, 'isNumericDataType', isNumericDataType );\n\n/**\n* @name isRealDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-real-data-type}\n*/\nimport isRealDataType from './../../../base/assert/is-real-data-type';\nsetReadOnly( ns, 'isRealDataType', isRealDataType );\n\n/**\n* @name isRealFloatingPointDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-real-floating-point-data-type}\n*/\nimport isRealFloatingPointDataType from './../../../base/assert/is-real-floating-point-data-type';\nsetReadOnly( ns, 'isRealFloatingPointDataType', isRealFloatingPointDataType );\n\n/**\n* @name isSafeDataTypeCast\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-safe-data-type-cast}\n*/\nimport isSafeDataTypeCast from './../../../base/assert/is-safe-data-type-cast';\nsetReadOnly( ns, 'isSafeDataTypeCast', isSafeDataTypeCast );\n\n/**\n* @name isSameKindDataTypeCast\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-same-kind-data-type-cast}\n*/\nimport isSameKindDataTypeCast from './../../../base/assert/is-same-kind-data-type-cast';\nsetReadOnly( ns, 'isSameKindDataTypeCast', isSameKindDataTypeCast );\n\n/**\n* @name isSignedIntegerDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-signed-integer-data-type}\n*/\nimport isSignedIntegerDataType from './../../../base/assert/is-signed-integer-data-type';\nsetReadOnly( ns, 'isSignedIntegerDataType', isSignedIntegerDataType );\n\n/**\n* @name isSortedAscending\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-sorted-ascending}\n*/\nimport isSortedAscending from './../../../base/assert/is-sorted-ascending';\nsetReadOnly( ns, 'isSortedAscending', isSortedAscending );\n\n/**\n* @name isUnsignedIntegerDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-unsigned-integer-data-type}\n*/\nimport isUnsignedIntegerDataType from './../../../base/assert/is-unsigned-integer-data-type';\nsetReadOnly( ns, 'isUnsignedIntegerDataType', isUnsignedIntegerDataType );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the maximum value.\n*\n* @param {number} x - first number\n* @param {number} y - second number\n* @returns {number} maximum value\n*\n* @example\n* var v = max( 3.14, 4.2 );\n* // returns 4.2\n*\n* @example\n* var v = max( 3.14, NaN );\n* // returns NaN\n*\n* @example\n* var v = max( NaN, 3.14 );\n* // returns 3.14\n*\n* @example\n* var v = max( -0.0, +0.0 );\n* // returns +0.0\n*\n* @example\n* var v = max( +0.0, -0.0 );\n* // returns -0.0\n*/\nfunction max( x, y ) {\n\tif ( x > y ) {\n\t\treturn x;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default max;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the minimum value.\n*\n* @param {number} x - first number\n* @param {number} y - second number\n* @returns {number} minimum value\n*\n* @example\n* var v = min( 3.14, 4.2 );\n* // returns 3.14\n*\n* @example\n* var v = min( 3.14, NaN );\n* // returns NaN\n*\n* @example\n* var v = min( NaN, 3.14 );\n* // returns 3.14\n*\n* @example\n* var v = min( -0.0, +0.0 );\n* // returns +0.0\n*\n* @example\n* var v = min( +0.0, -0.0 );\n* // returns -0.0\n*/\nfunction min( x, y ) {\n\tif ( x < y ) {\n\t\treturn x;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default min;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled \"generic\" array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeInteger} len - array length\n* @returns {Array} filled array\n*\n* @example\n* var out = filled( 0.0, 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*\n* @example\n* var out = filled( 'beep', 3 );\n* // returns [ 'beep', 'beep', 'beep' ]\n*/\nfunction filled( value, len ) {\n\tvar arr;\n\tvar i;\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tarr.push( value );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional nested array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = filled2d( 0.0, [ 1, 3 ] );\n* // returns [ [ 0.0, 0.0, 0.0 ] ]\n*\n* @example\n* var out = filled2d( 'beep', [ 3, 1 ] );\n* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ]\n*/\nfunction filled2d( value, shape ) {\n\tvar arr;\n\tvar S0;\n\tvar S1;\n\tvar i;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < S1; i++ ) {\n\t\tarr.push( filled( value, S0 ) );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled2d from './../../../base/filled2d';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled two-dimensional nested array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {ArrayArray} filled array\n*\n* @example\n* var out = zeros2d( [ 1, 3 ] );\n* // returns [ [ 0.0, 0.0, 0.0 ] ]\n*/\nfunction zeros2d( shape ) {\n\treturn filled2d( 0.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default zeros2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if two indexed arrays have equal values.\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @returns {boolean} boolean indicating if both arrays have equal values\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasEqualValuesIndexed( x, y );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasEqualValuesIndexed( x, y );\n* // returns false\n*/\nfunction hasEqualValuesIndexed( x, y ) {\n\tvar i;\n\tif ( x.length !== y.length ) {\n\t\treturn false;\n\t}\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( x[ i ] !== y[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasEqualValuesIndexed;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../../base/accessor-getter';\nimport getter from './../../../../base/getter';\nimport dtype from './../../../../dtype';\n\n\n// MAIN //\n\n/**\n* Tests if an array is sorted in ascending order.\n*\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating if an array is sorted in ascending order\n*\n* @example\n* var out = isSortedAscending( [ 1, 2, 3 ] );\n* // returns true\n*\n* @example\n* var out = isSortedAscending( [ 3, 2, 1 ] );\n* // returns false\n*\n* @example\n* var out = isSortedAscending( [ 3, 3, 3 ] );\n* // returns true\n*\n* @example\n* var out = isSortedAscending( [ 3 ] );\n* // returns true\n*\n* @example\n* var out = isSortedAscending( [] );\n* // returns false\n*\n* @example\n* var out = isSortedAscending( [ 1, 3, 2 ] );\n* // returns false\n*/\nfunction isSortedAscending( x ) {\n\tvar len;\n\tvar get;\n\tvar dt;\n\tvar v1;\n\tvar v2;\n\tvar i;\n\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Resolve an accessor for retrieving input array elements:\n\tif ( isAccessorArray( x ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\t// Get the number of elements over which to iterate:\n\tlen = x.length;\n\n\t// Check for an empty array:\n\tif ( len === 0 ) {\n\t\treturn false;\n\t}\n\t// Loop over the elements...\n\tv1 = get( x, 0 );\n\tfor ( i = 1; i < len; i++ ) {\n\t\tv2 = get( x, i );\n\t\tif ( v1 > v2 ) {\n\t\t\treturn false;\n\t\t}\n\t\tv1 = v2;\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default isSortedAscending;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/*\n* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name filled2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/banded/filled2d-by}\n*/\nimport filled2dBy from './../../../base/banded/filled2d-by';\nsetReadOnly( ns, 'filled2dBy', filled2dBy );\n\n/**\n* @name toCompact\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/banded/to-compact}\n*/\nimport toCompact from './../../../base/banded/to-compact';\nsetReadOnly( ns, 'toCompact', toCompact );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Recursively applies a binary callback.\n*\n* @private\n* @param {ArrayLikeObject} x - input array\n* @param {ArrayLikeObject} y - input array\n* @param {ArrayLikeObject} z - output array\n* @param {NonNegativeInteger} ndims - number of dimensions\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} dim - dimension index\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*/\nfunction recurse( x, y, z, ndims, shape, dim, fcn ) {\n\tvar S;\n\tvar d;\n\tvar i;\n\n\tS = shape[ dim ];\n\n\t// Check whether we've reached the innermost dimension:\n\td = dim + 1;\n\n\tif ( d === ndims ) {\n\t\t// Apply the provided callback...\n\t\tfor ( i = 0; i < S; i++ ) {\n\t\t\tz[ i ] = fcn( x[ i ], y[ i ] );\n\t\t}\n\t\treturn;\n\t}\n\t// Continue recursing into the nested arrays...\n\tfor ( i = 0; i < S; i++ ) {\n\t\trecurse( x[ i ], y[ i ], z[ i ], ndims, shape, d, fcn );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two n-dimensional nested input arrays and assigns results to elements in an n-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add';\n* import onesnd from '@stdlib/array/base/onesnd';\n* import zerosnd from '@stdlib/array/base/zerosnd';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = onesnd( shape );\n* var y = onesnd( shape );\n* var z = zerosnd( shape );\n*\n* binarynd( [ x, y, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ]\n*/\nfunction binarynd( arrays, shape, fcn ) {\n\treturn recurse( arrays[ 0 ], arrays[ 1 ], arrays[ 2 ], shape.length, shape, 0, fcn ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default binarynd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies the elements of an indexed array-like object to a new \"generic\" array.\n*\n* @param {Collection} x - input array\n* @returns {Array} output array\n*\n* @example\n* var out = copy( [ 1, 2, 3 ] );\n* // returns [ 1, 2, 3 ]\n*/\nfunction copy( x ) {\n\tvar out;\n\tvar len;\n\tvar i;\n\n\tlen = x.length;\n\tout = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tout.push( x[ i ] ); // use `Array#push` to ensure \"fast\" elements\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default copy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled \"generic\" array.\n*\n* @param {NonNegativeInteger} len - array length\n* @returns {Array} output array\n*\n* @example\n* var out = zeros( 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction zeros( len ) {\n\treturn filled( 0.0, len );\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from './../../../base/copy-indexed';\nimport zeros from './../../../base/zeros';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Broadcasts an array to a specified shape.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} inShape - input array shape\n* @param {NonNegativeIntegerArray} outShape - output array shape\n* @throws {Error} input array cannot have more dimensions than the desired shape\n* @throws {Error} input array dimension sizes must be `1` or equal to the corresponding dimension in the provided output shape\n* @throws {Error} input array and desired shape must be broadcast compatible\n* @returns {Object} broadcast object\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = broadcastArray( x, [ 2 ], [ 2, 2 ] );\n* // returns {...}\n*\n* var shape = out.shape;\n* // returns [ 2, 2 ]\n*\n* var strides = out.strides;\n* // returns [ 0, 1 ]\n*\n* var ref = out.ref;\n* // returns [ 1, 2 ]\n*\n* var bool = ( x === ref );\n* // returns true\n*\n* var data = out.data;\n* // returns [ [ 1, 2 ] ]\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = broadcastArray( x, [ 2 ], [ 2, 1, 2 ] );\n* // returns {...}\n*\n* var data = out.data;\n* // returns [ [ [ 1, 2 ] ] ]\n*\n* var strides = out.strides;\n* // returns [ 0, 0, 1 ]\n*\n* @example\n* var x = [ [ 1 ], [ 2 ] ];\n*\n* var out = broadcastArray( x, [ 2, 1 ], [ 3, 2, 2 ] );\n* // returns {...}\n*\n* var data = out.data;\n* // returns [ [ [ 1 ], [ 2 ] ] ]\n*\n* var strides = out.strides;\n* // returns [ 0, 1, 0 ]\n*/\nfunction broadcastArray( x, inShape, outShape ) {\n\tvar data;\n\tvar dim;\n\tvar st;\n\tvar N;\n\tvar M;\n\tvar d;\n\tvar i;\n\tvar j;\n\n\tN = outShape.length;\n\tM = inShape.length;\n\tif ( N < M ) {\n\t\tthrow new Error( 'invalid argument. Cannot broadcast an array to a shape having fewer dimensions. Arrays can only be broadcasted to shapes having the same or more dimensions.' );\n\t}\n\t// Prepend additional dimensions...\n\tdata = x;\n\tfor ( i = M; i < N; i++ ) {\n\t\tdata = [ data ];\n\t}\n\n\t// Initialize a strides array:\n\tst = zeros( N );\n\n\t// Determine the output array strides...\n\tfor ( i = N-1; i >= 0; i-- ) {\n\t\tj = M - N + i;\n\t\tif ( j < 0 ) {\n\t\t\t// Prepended singleton dimension; stride is zero...\n\t\t\tcontinue;\n\t\t}\n\t\td = inShape[ j ];\n\t\tdim = outShape[ i ];\n\t\tif ( dim !== 0 && dim < d ) {\n\t\t\tthrow new Error( format( 'invalid argument. Input array cannot be broadcast to the specified shape, as the specified shape has a dimension whose size is less than the size of the corresponding dimension in the input array. Array shape: (%s). Desired shape: (%s). Dimension: %u.', copy( inShape ).join( ', ' ), copy( outShape ).join( ', ' ), i ) );\n\t\t}\n\t\tif ( d === dim ) {\n\t\t\t// As the dimension sizes are equal, the stride is one, meaning that each element in the array should be iterated over as normal...\n\t\t\tst[ i ] = 1;\n\t\t} else if ( d === 1 ) {\n\t\t\t// In order to broadcast a dimension, we set the stride for that dimension to zero...\n\t\t\tst[ i ] = 0;\n\t\t} else {\n\t\t\t// At this point, we know that `dim > d` and that `d` does not equal `1` (e.g., `dim=3` and `d=2`); in which case, the shapes are considered incompatible (even for desired shapes which are multiples of array dimensions, as might be desired when \"tiling\" an array; e.g., `dim=4` and `d=2`)...\n\t\t\tthrow new Error( format( 'invalid argument. Input array and the specified shape are broadcast incompatible. Array shape: (%s). Desired shape: (%s). Dimension: %u.', copy( inShape ).join( ', ' ), copy( outShape ).join( ', ' ), i ) );\n\t\t}\n\t}\n\t// Return broadcast results:\n\treturn {\n\t\t'ref': x, // reference to the original input array\n\t\t'data': data, // broadcasted array\n\t\t'shape': copy( outShape ), // copy in order to prevent mutation\n\t\t'strides': st\n\t};\n}\n\n\n// EXPORTS //\n\nexport default broadcastArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isEven from './../../../../base/assert/is-even';\n\n\n// MAIN //\n\n/**\n* Tests if a finite double-precision floating-point number is an odd number.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is an odd number\n*\n* @example\n* var bool = isOdd( 5.0 );\n* // returns true\n*\n* @example\n* var bool = isOdd( -2.0 );\n* // returns false\n*\n* @example\n* var bool = isOdd( 0.0 );\n* // returns false\n*\n* @example\n* var bool = isOdd( NaN );\n* // returns false\n*/\nfunction isOdd( x ) {\n\t// Check sign to prevent overflow...\n\tif ( x > 0.0 ) {\n\t\treturn isEven( x-1.0 );\n\t}\n\treturn isEven( x+1.0 );\n}\n\n\n// EXPORTS //\n\nexport default isOdd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport PINF from '@stdlib/constants/float64/pinf';\nimport NINF from '@stdlib/constants/float64/ninf';\n\n\n// MAIN //\n\n/**\n* Tests if a double-precision floating-point numeric value is infinite.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is infinite\n*\n* @example\n* var bool = isInfinite( Infinity );\n* // returns true\n*\n* @example\n* var bool = isInfinite( -Infinity );\n* // returns true\n*\n* @example\n* var bool = isInfinite( 5.0 );\n* // returns false\n*\n* @example\n* var bool = isInfinite( NaN );\n* // returns false\n*/\nfunction isInfinite( x ) {\n\treturn (x === PINF || x === NINF);\n}\n\n\n// EXPORTS //\n\nexport default isInfinite;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional banded nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} ku - number of super-diagonals\n* @param {NonNegativeInteger} kl - number of sub-diagonals\n* @param {*} fill - fill value for values outside the band\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 3, 3 ], 1, 1, 0, clbk );\n* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 4, 4 ], 1, 1, 0, clbk );\n* // returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 4, 4 ], 2, 1, 0, clbk );\n* // returns [ [ 0, 1, 2, 0 ], [ 1, 2, 3, 4 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 4, 4 ], 0, 2, 0, clbk );\n* // returns [ [ 0, 0, 0, 0 ], [ 1, 2, 0, 0 ], [ 2, 3, 4, 0 ], [ 0, 4, 5, 6 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 3, 4 ], 1, 1, 0, clbk );\n* // returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 4, 3 ], 1, 1, 0, clbk );\n* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ], [ 0, 0, 5 ] ]\n*/\nfunction filled2dBy( shape, ku, kl, fill, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\n\tS1 = shape[ 0 ]; // rows\n\tS0 = shape[ 1 ]; // columns\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ta0 = [];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t// Check whether we are within the band...\n\t\t\tif (\n\t\t\t\t( i0 >= i1 && i0 <= i1+ku ) || // super-diagonals\n\t\t\t\t( i0 <= i1 && i1 <= i0+kl ) // sub-diagonals\n\t\t\t) {\n\t\t\t\ta0.push( clbk.call( thisArg, [ i1, i0 ] ) );\n\t\t\t}\n\t\t\t// Otherwise, we are outside the band...\n\t\t\telse {\n\t\t\t\ta0.push( fill );\n\t\t\t}\n\t\t}\n\t\tarr.push( a0 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport max from '@stdlib/math/base/special/fast/max';\nimport min from '@stdlib/math/base/special/fast/min';\nimport zeros2d from './../../../../base/zeros2d';\n\n\n// MAIN //\n\n/**\n* Converts a two-dimensional banded nested array to compact banded storage.\n*\n* @param {Array} arr - input two-dimensional array\n* @param {NonNegativeInteger} ku - number of super-diagonals\n* @param {NonNegativeInteger} kl - number of sub-diagonals\n* @param {boolean} colexicographic - specifies whether to store diagonals in colexicographic access order\n* @returns {Array} output array\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 3, 12, 4 ],\n* [ 0, 5, 13 ]\n* ];\n*\n* var out = toCompact( M, 1, 1, false );\n* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ], [ 3, 5, 0 ] ]\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 3, 12, 4 ],\n* [ 0, 5, 13 ]\n* ];\n*\n* var out = toCompact( M, 1, 1, true );\n* // returns [ [ 0, 11, 3 ], [ 2, 12, 5 ], [ 4, 13, 0 ] ]\n*/\nfunction toCompact( arr, ku, kl, colexicographic ) {\n\tvar out;\n\tvar to;\n\tvar M;\n\tvar N;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tM = arr.length;\n\tN = arr[ 0 ].length;\n\n\t// Check whether to store diagonals along the columns...\n\tif ( colexicographic ) {\n\t\tout = zeros2d( [ N, ku+kl+1 ] );\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tto = out[ j ];\n\t\t\tk = ku - j;\n\t\t\tfor ( i = max( 0, j-ku ); i < min( M, j+kl+1 ); i++ ) {\n\t\t\t\tto[ k+i ] = arr[ i ][ j ];\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\t// Store diagonals along the rows...\n\tout = zeros2d( [ ku+kl+1, N ] );\n\tfor ( j = 0; j < N; j++ ) {\n\t\tk = ku - j;\n\t\tfor ( i = max( 0, j-ku ); i < min( M, j+kl+1 ); i++ ) {\n\t\t\tout[ k+i ][ j ] = arr[ i ][ j ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toCompact;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Compute the principal square root of a double-precision floating-point number.\n*\n* @type {Function}\n* @param {number} x - input value\n* @returns {number} principal square root\n*\n* @example\n* var v = sqrt( 4.0 );\n* // returns 2.0\n*\n* v = sqrt( 9.0 );\n* // returns 3.0\n*\n* v = sqrt( 0.0 );\n* // returns 0.0\n*\n* v = sqrt( -4.0 );\n* // returns NaN\n*\n* v = sqrt( NaN );\n* // returns NaN\n*/\nvar sqrt = Math.sqrt; // eslint-disable-line stdlib/no-builtin-math\n\n\n// EXPORTS //\n\nexport default sqrt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isLittleEndian from '@stdlib/assert/is-little-endian';\n\n\n// MAIN //\n\nvar LOW;\nif ( isLittleEndian === true ) {\n\tLOW = 0; // first index\n} else {\n\tLOW = 1; // second index\n}\n\n\n// EXPORTS //\n\nexport default LOW;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float64Array from '@stdlib/array/float64';\nimport LOW from './low.js';\n\n\n// VARIABLES //\n\nvar FLOAT64_VIEW = new Float64Array( 1 );\nvar UINT32_VIEW = new Uint32Array( FLOAT64_VIEW.buffer );\n\n\n// MAIN //\n\n/**\n* Sets the less significant 32 bits of a double-precision floating-point number.\n*\n* ## Notes\n*\n* ```text\n* float64 (64 bits)\n* f := fraction (significand/mantissa) (52 bits)\n* e := exponent (11 bits)\n* s := sign bit (1 bit)\n*\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Float64 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Uint32 | Uint32 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* ```\n*\n* If little endian (more significant bits last):\n*\n* ```text\n* <-- lower higher -->\n* | f7 f6 f5 f4 f3 f2 e2 | f1 |s| e1 |\n* ```\n*\n* If big endian (more significant bits first):\n*\n* ```text\n* <-- higher lower -->\n* |s| e1 e2 | f1 f2 f3 f4 f5 f6 f7 |\n* ```\n*\n* In which Uint32 can we find the lower order bits? If little endian, the first; if big endian, the second.\n*\n* ## References\n*\n* - [Open Group][1]\n*\n* [1]: http://pubs.opengroup.org/onlinepubs/9629399/chap14.htm\n*\n* @param {number} x - double\n* @param {uinteger32} low - unsigned 32-bit integer to replace the lower order word of `x`\n* @returns {number} double having the same higher order word as `x`\n*\n* @example\n* var low = 5 >>> 0; // => 00000000000000000000000000000101\n*\n* var x = 3.14e201; // => 0 11010011100 01001000001011000011 10010011110010110101100010000010\n*\n* var y = setLowWord( x, low ); // => 0 11010011100 01001000001011000011 00000000000000000000000000000101\n* // returns 3.139998651394392e+201\n*\n* @example\n* import PINF from '@stdlib/constants/float64/pinf';\n* import NINF from '@stdlib/constants/float64/ninf';\n*\n* var low = 12345678;\n*\n* var y = setLowWord( PINF, low );\n* // returns NaN\n*\n* y = setLowWord( NINF, low );\n* // returns NaN\n*\n* y = setLowWord( NaN, low );\n* // returns NaN\n*/\nfunction setLowWord( x, low ) {\n\tFLOAT64_VIEW[ 0 ] = x;\n\tUINT32_VIEW[ LOW ] = ( low >>> 0 ); // identity bit shift to ensure integer\n\treturn FLOAT64_VIEW[ 0 ];\n}\n\n\n// EXPORTS //\n\nexport default setLowWord;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts an unsigned 32-bit integer to a signed 32-bit integer.\n*\n* @param {uinteger32} x - unsigned 32-bit integer\n* @returns {integer32} signed 32-bit integer\n*\n* @example\n* import float64ToUint32 from '@stdlib/number/float64/base/to-uint32';\n* var y = uint32ToInt32( float64ToUint32( 4294967295 ) );\n* // returns -1\n*\n* @example\n* import float64ToUint32 from '@stdlib/number/float64/base/to-uint32';\n* var y = uint32ToInt32( float64ToUint32( 3 ) );\n* // returns 3\n*/\nfunction uint32ToInt32( x ) {\n\t// NOTE: we could also use typed-arrays to achieve the same end.\n\treturn x|0; // asm type annotation\n}\n\n\n// EXPORTS //\n\nexport default uint32ToInt32;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* High word mask for excluding the sign bit of a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/high-word-abs-mask\n* @type {uinteger32}\n*\n* @example\n* import FLOAT64_HIGH_WORD_ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\n* // returns 2147483647\n*/\n\n\n// MAIN //\n\n/**\n* High word mask for excluding the sign bit of a double-precision floating-point number.\n*\n* ## Notes\n*\n* The high word mask for excluding the sign bit of a double-precision floating-point number is an unsigned 32-bit integer with the value \\\\( 2147483647 \\\\), which corresponds to the bit sequence\n*\n* ```binarystring\n* 0 11111111111 11111111111111111111\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 0x7fffffff\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_HIGH_WORD_ABS_MASK = 0x7fffffff>>>0; // eslint-disable-line id-length\n\n\n// EXPORTS //\n\nexport default FLOAT64_HIGH_WORD_ABS_MASK;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isLittleEndian from '@stdlib/assert/is-little-endian';\n\n\n// MAIN //\n\nvar indices;\nvar HIGH;\nvar LOW;\n\nif ( isLittleEndian === true ) {\n\tHIGH = 1; // second index\n\tLOW = 0; // first index\n} else {\n\tHIGH = 0; // first index\n\tLOW = 1; // second index\n}\nindices = {\n\t'HIGH': HIGH,\n\t'LOW': LOW\n};\n\n\n// EXPORTS //\n\nexport default indices;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isLittleEndian from '@stdlib/assert/is-little-endian';\n\n\n// MAIN //\n\nvar HIGH;\nif ( isLittleEndian === true ) {\n\tHIGH = 1; // second index\n} else {\n\tHIGH = 0; // first index\n}\n\n\n// EXPORTS //\n\nexport default HIGH;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float64Array from '@stdlib/array/float64';\nimport HIGH from './high.js';\n\n\n// VARIABLES //\n\nvar FLOAT64_VIEW = new Float64Array( 1 );\nvar UINT32_VIEW = new Uint32Array( FLOAT64_VIEW.buffer );\n\n\n// MAIN //\n\n/**\n* Returns an unsigned 32-bit integer corresponding to the more significant 32 bits of a double-precision floating-point number.\n*\n* ## Notes\n*\n* ```text\n* float64 (64 bits)\n* f := fraction (significand/mantissa) (52 bits)\n* e := exponent (11 bits)\n* s := sign bit (1 bit)\n*\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Float64 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Uint32 | Uint32 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* ```\n*\n* If little endian (more significant bits last):\n*\n* ```text\n* <-- lower higher -->\n* | f7 f6 f5 f4 f3 f2 e2 | f1 |s| e1 |\n* ```\n*\n* If big endian (more significant bits first):\n*\n* ```text\n* <-- higher lower -->\n* |s| e1 e2 | f1 f2 f3 f4 f5 f6 f7 |\n* ```\n*\n* In which Uint32 can we find the higher order bits? If little endian, the second; if big endian, the first.\n*\n* ## References\n*\n* - [Open Group][1]\n*\n* [1]: http://pubs.opengroup.org/onlinepubs/9629399/chap14.htm\n*\n* @param {number} x - input value\n* @returns {uinteger32} higher order word\n*\n* @example\n* var w = getHighWord( 3.14e201 ); // => 01101001110001001000001011000011\n* // returns 1774486211\n*/\nfunction getHighWord( x ) {\n\tFLOAT64_VIEW[ 0 ] = x;\n\treturn UINT32_VIEW[ HIGH ];\n}\n\n\n// EXPORTS //\n\nexport default getHighWord;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float64Array from '@stdlib/array/float64';\nimport indices from './indices.js';\n\n\n// VARIABLES //\n\nvar FLOAT64_VIEW = new Float64Array( 1 );\nvar UINT32_VIEW = new Uint32Array( FLOAT64_VIEW.buffer );\n\nvar HIGH = indices.HIGH;\nvar LOW = indices.LOW;\n\n\n// MAIN //\n\n/**\n* Creates a double-precision floating-point number from a higher order word (unsigned 32-bit integer) and a lower order word (unsigned 32-bit integer).\n*\n* ## Notes\n*\n* ```text\n* float64 (64 bits)\n* f := fraction (significand/mantissa) (52 bits)\n* e := exponent (11 bits)\n* s := sign bit (1 bit)\n*\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Float64 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Uint32 | Uint32 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* ```\n*\n* If little endian (more significant bits last):\n*\n* ```text\n* <-- lower higher -->\n* | f7 f6 f5 f4 f3 f2 e2 | f1 |s| e1 |\n* ```\n*\n* If big endian (more significant bits first):\n*\n* ```text\n* <-- higher lower -->\n* |s| e1 e2 | f1 f2 f3 f4 f5 f6 f7 |\n* ```\n*\n* In which Uint32 should we place the higher order bits? If little endian, the second; if big endian, the first.\n*\n* ## References\n*\n* - [Open Group][1]\n*\n* [1]: http://pubs.opengroup.org/onlinepubs/9629399/chap14.htm\n*\n* @param {uinteger32} high - higher order word (unsigned 32-bit integer)\n* @param {uinteger32} low - lower order word (unsigned 32-bit integer)\n* @returns {number} floating-point number\n*\n* @example\n* var v = fromWords( 1774486211, 2479577218 );\n* // returns 3.14e201\n*\n* @example\n* var v = fromWords( 3221823995, 1413754136 );\n* // returns -3.141592653589793\n*\n* @example\n* var v = fromWords( 0, 0 );\n* // returns 0.0\n*\n* @example\n* var v = fromWords( 2147483648, 0 );\n* // returns -0.0\n*\n* @example\n* var v = fromWords( 2146959360, 0 );\n* // returns NaN\n*\n* @example\n* var v = fromWords( 2146435072, 0 );\n* // returns Infinity\n*\n* @example\n* var v = fromWords( 4293918720, 0 );\n* // returns -Infinity\n*/\nfunction fromWords( high, low ) {\n\tUINT32_VIEW[ HIGH ] = high;\n\tUINT32_VIEW[ LOW ] = low;\n\treturn FLOAT64_VIEW[ 0 ];\n}\n\n\n// EXPORTS //\n\nexport default fromWords;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport SIGN_MASK from '@stdlib/constants/float64/high-word-sign-mask';\nimport ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\nimport toWords from '@stdlib/number/float64/base/to-words';\nimport getHighWord from '@stdlib/number/float64/base/get-high-word';\nimport fromWords from '@stdlib/number/float64/base/from-words';\n\n\n// VARIABLES //\n\n// High/low words workspace:\nvar WORDS = [ 0, 0 ];\n\n\n// MAIN //\n\n/**\n* Returns a double-precision floating-point number with the magnitude of `x` and the sign of `y`.\n*\n* @param {number} x - number from which to derive a magnitude\n* @param {number} y - number from which to derive a sign\n* @returns {number} a double-precision floating-point number\n*\n* @example\n* var z = copysign( -3.14, 10.0 );\n* // returns 3.14\n*\n* @example\n* var z = copysign( 3.14, -1.0 );\n* // returns -3.14\n*\n* @example\n* var z = copysign( 1.0, -0.0 );\n* // returns -1.0\n*\n* @example\n* var z = copysign( -3.14, -0.0 );\n* // returns -3.14\n*\n* @example\n* var z = copysign( -0.0, 1.0 );\n* // returns 0.0\n*/\nfunction copysign( x, y ) {\n\tvar hx;\n\tvar hy;\n\n\t// Split `x` into higher and lower order words:\n\ttoWords.assign( x, WORDS, 1, 0 );\n\thx = WORDS[ 0 ];\n\n\t// Turn off the sign bit of `x`:\n\thx &= ABS_MASK;\n\n\t// Extract the higher order word from `y`:\n\thy = getHighWord( y );\n\n\t// Leave only the sign bit of `y` turned on:\n\thy &= SIGN_MASK;\n\n\t// Copy the sign bit of `y` to `x`:\n\thx |= hy;\n\n\t// Return a new value having the same magnitude as `x`, but with the sign of `y`:\n\treturn fromWords( hx, WORDS[ 1 ] );\n}\n\n\n// EXPORTS //\n\nexport default copysign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\nimport getHighWord from '@stdlib/number/float64/base/get-high-word';\n\n\n// VARIABLES //\n\n// 0x3fefffff = 1072693247 => 0 01111111110 11111111111111111111 => biased exponent: 1022 = -1+1023 => 2^-1\nvar HIGH_MAX_NEAR_UNITY = 0x3fefffff|0; // asm type annotation\n\nvar HUGE = 1.0e300;\nvar TINY = 1.0e-300;\n\n\n// MAIN //\n\n/**\n* Evaluates the exponential function when \\\\(|y| > 2^64\\\\).\n*\n* @private\n* @param {number} x - base\n* @param {number} y - exponent\n* @returns {number} overflow or underflow result\n*\n* @example\n* var v = pow( 9.0, 3.6893488147419103e19 );\n* // returns Infinity\n*\n* @example\n* var v = pow( -3.14, -3.6893488147419103e19 );\n* // returns 0.0\n*/\nfunction pow( x, y ) {\n\tvar ahx;\n\tvar hx;\n\n\thx = getHighWord( x );\n\tahx = (hx & ABS_MASK);\n\n\tif ( ahx <= HIGH_MAX_NEAR_UNITY ) {\n\t\tif ( y < 0 ) {\n\t\t\t// Signal overflow...\n\t\t\treturn HUGE * HUGE;\n\t\t}\n\t\t// Signal underflow...\n\t\treturn TINY * TINY;\n\t}\n\t// `x` has a biased exponent greater than or equal to `0`...\n\n\tif ( y > 0 ) {\n\t\t// Signal overflow...\n\t\treturn HUGE * HUGE;\n\t}\n\t// Signal underflow...\n\treturn TINY * TINY;\n}\n\n\n// EXPORTS //\n\nexport default pow;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isLittleEndian from '@stdlib/assert/is-little-endian';\n\n\n// MAIN //\n\nvar HIGH;\nif ( isLittleEndian === true ) {\n\tHIGH = 1; // second index\n} else {\n\tHIGH = 0; // first index\n}\n\n\n// EXPORTS //\n\nexport default HIGH;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float64Array from '@stdlib/array/float64';\nimport HIGH from './high.js';\n\n\n// VARIABLES //\n\nvar FLOAT64_VIEW = new Float64Array( 1 );\nvar UINT32_VIEW = new Uint32Array( FLOAT64_VIEW.buffer );\n\n\n// MAIN //\n\n/**\n* Sets the more significant 32 bits of a double-precision floating-point number.\n*\n* ## Notes\n*\n* ```text\n* float64 (64 bits)\n* f := fraction (significand/mantissa) (52 bits)\n* e := exponent (11 bits)\n* s := sign bit (1 bit)\n*\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Float64 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Uint32 | Uint32 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* ```\n*\n* If little endian (more significant bits last):\n*\n* ```text\n* <-- lower higher -->\n* | f7 f6 f5 f4 f3 f2 e2 | f1 |s| e1 |\n* ```\n*\n* If big endian (more significant bits first):\n*\n* ```text\n* <-- higher lower -->\n* |s| e1 e2 | f1 f2 f3 f4 f5 f6 f7 |\n* ```\n*\n* In which Uint32 can we find the higher order bits? If little endian, the second; if big endian, the first.\n*\n* ## References\n*\n* - [Open Group][1]\n*\n* [1]: http://pubs.opengroup.org/onlinepubs/9629399/chap14.htm\n*\n* @param {number} x - double\n* @param {uinteger32} high - unsigned 32-bit integer to replace the higher order word of `x`\n* @returns {number} double having the same lower order word as `x`\n*\n* @example\n* var high = 5 >>> 0; // => 0 00000000000 00000000000000000101\n*\n* var y = setHighWord( 3.14e201, high ); // => 0 00000000000 0000000000000000010110010011110010110101100010000010\n* // returns 1.18350528745e-313\n*\n* @example\n* import PINF from '@stdlib/constants/float64/pinf'; // => 0 11111111111 00000000000000000000 00000000000000000000000000000000\n*\n* var high = 1072693248 >>> 0; // => 0 01111111111 00000000000000000000\n*\n* // Set the higher order bits of `+infinity` to return `1`:\n* var y = setHighWord( PINF, high ); // => 0 01111111111 0000000000000000000000000000000000000000000000000000\n* // returns 1.0\n*/\nfunction setHighWord( x, high ) {\n\tFLOAT64_VIEW[ 0 ] = x;\n\tUINT32_VIEW[ HIGH ] = ( high >>> 0 ); // identity bit shift to ensure integer\n\treturn FLOAT64_VIEW[ 0 ];\n}\n\n\n// EXPORTS //\n\nexport default setHighWord;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* The bias of a double-precision floating-point number's exponent.\n*\n* @module @stdlib/constants/float64/exponent-bias\n* @type {integer32}\n*\n* @example\n* import FLOAT64_EXPONENT_BIAS from '@stdlib/constants/float64/exponent-bias';\n* // returns 1023\n*/\n\n\n// MAIN //\n\n/**\n* Bias of a double-precision floating-point number's exponent.\n*\n* ## Notes\n*\n* The bias can be computed via\n*\n* ```tex\n* \\mathrm{bias} = 2^{k-1} - 1\n* ```\n*\n* where \\\\(k\\\\) is the number of bits in the exponent; here, \\\\(k = 11\\\\).\n*\n* @constant\n* @type {integer32}\n* @default 1023\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_EXPONENT_BIAS = 1023|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default FLOAT64_EXPONENT_BIAS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Number of significand bits in the high word of a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/num-high-word-significand-bits\n* @type {integer32}\n*\n* @example\n* import FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS from '@stdlib/constants/float64/num-high-word-significand-bits';\n* // returns 20\n*/\n\n\n// MAIN //\n\n/**\n* Number of significand bits in the high word of a double-precision floating-point number.\n*\n* @constant\n* @type {integer32}\n* @default 20\n*/\nvar FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS = 20|0; // eslint-disable-line id-length\n\n\n// EXPORTS //\n\nexport default FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getHighWord from '@stdlib/number/float64/base/get-high-word';\nimport setLowWord from '@stdlib/number/float64/base/set-low-word';\nimport setHighWord from '@stdlib/number/float64/base/set-high-word';\nimport BIAS from '@stdlib/constants/float64/exponent-bias';\nimport HIGH_NUM_SIGNIFICAND_BITS from '@stdlib/constants/float64/num-high-word-significand-bits';\nimport polyvalL from './polyval_l.js';\n\n\n// VARIABLES //\n\n// 0x000fffff = 1048575 => 0 00000000000 11111111111111111111\nvar HIGH_SIGNIFICAND_MASK = 0x000fffff|0; // asm type annotation\n\n// 0x00100000 = 1048576 => 0 00000000001 00000000000000000000 => biased exponent: 1 = -1022+1023 => 2^-1022\nvar HIGH_MIN_NORMAL_EXP = 0x00100000|0; // asm type annotation\n\n// 0x3ff00000 = 1072693248 => 0 01111111111 00000000000000000000 => biased exponent: 1023 = 0+1023 => 2^0 = 1\nvar HIGH_BIASED_EXP_0 = 0x3ff00000|0; // asm type annotation\n\n// 0x20000000 = 536870912 => 0 01000000000 00000000000000000000 => biased exponent: 512 = -511+1023\nvar HIGH_BIASED_EXP_NEG_512 = 0x20000000|0; // asm type annotation\n\n// 0x00080000 = 524288 => 0 00000000000 10000000000000000000\nvar HIGH_SIGNIFICAND_HALF = 0x00080000|0; // asm type annotation\n\nvar TWO53 = 9007199254740992.0;\t// 0x43400000, 0x00000000\n\n// 2/(3*LN2)\nvar CP = 9.61796693925975554329e-01; // 0x3FEEC709, 0xDC3A03FD\n\n// (float)CP\nvar CP_HI = 9.61796700954437255859e-01; // 0x3FEEC709, 0xE0000000\n\n// Low: CP_HI\nvar CP_LO = -7.02846165095275826516e-09; // 0xBE3E2FE0, 0x145B01F5\n\nvar BP = [\n\t1.0,\n\t1.5\n];\nvar DP_HI = [\n\t0.0,\n\t5.84962487220764160156e-01 // 0x3FE2B803, 0x40000000\n];\nvar DP_LO = [\n\t0.0,\n\t1.35003920212974897128e-08 // 0x3E4CFDEB, 0x43CFD006\n];\n\n\n// MAIN //\n\n/**\n* Computes \\\\(\\operatorname{log2}(ax)\\\\).\n*\n* @private\n* @param {Array} out - output array\n* @param {number} ax - absolute value of `x`\n* @param {number} ahx - high word of `ax`\n* @returns {Array} output array containing a tuple comprised of high and low parts\n*\n* @example\n* var t = log2ax( [ 0.0, 0.0 ], 9.0, 1075970048 ); // => [ t1, t2 ]\n* // returns [ 3.169923782348633, 0.0000012190936795504075 ]\n*/\nfunction log2ax( out, ax, ahx ) {\n\tvar tmp;\n\tvar ss; // `hs + ls`\n\tvar s2; // `ss` squared\n\tvar hs;\n\tvar ls;\n\tvar ht;\n\tvar lt;\n\tvar bp; // `BP` constant\n\tvar dp; // `DP` constant\n\tvar hp;\n\tvar lp;\n\tvar hz;\n\tvar lz;\n\tvar t1;\n\tvar t2;\n\tvar t;\n\tvar r;\n\tvar u;\n\tvar v;\n\tvar n;\n\tvar j;\n\tvar k;\n\n\tn = 0|0; // asm type annotation\n\n\t// Check if `x` is subnormal...\n\tif ( ahx < HIGH_MIN_NORMAL_EXP ) {\n\t\tax *= TWO53;\n\t\tn -= 53|0; // asm type annotation\n\t\tahx = getHighWord( ax );\n\t}\n\t// Extract the unbiased exponent of `x`:\n\tn += ((ahx >> HIGH_NUM_SIGNIFICAND_BITS) - BIAS)|0; // asm type annotation\n\n\t// Isolate the significand bits of `x`:\n\tj = (ahx & HIGH_SIGNIFICAND_MASK)|0; // asm type annotation\n\n\t// Normalize `ahx` by setting the (biased) exponent to `1023`:\n\tahx = (j | HIGH_BIASED_EXP_0)|0; // asm type annotation\n\n\t// Determine the interval of `|x|` by comparing significand bits...\n\n\t// |x| < sqrt(3/2)\n\tif ( j <= 0x3988E ) { // 0 00000000000 00111001100010001110\n\t\tk = 0;\n\t}\n\t// |x| < sqrt(3)\n\telse if ( j < 0xBB67A ) { // 0 00000000000 10111011011001111010\n\t\tk = 1;\n\t}\n\t// |x| >= sqrt(3)\n\telse {\n\t\tk = 0;\n\t\tn += 1|0; // asm type annotation\n\t\tahx -= HIGH_MIN_NORMAL_EXP;\n\t}\n\t// Load the normalized high word into `|x|`:\n\tax = setHighWord( ax, ahx );\n\n\t// Compute `ss = hs + ls = (x-1)/(x+1)` or `(x-1.5)/(x+1.5)`:\n\tbp = BP[ k ]; // BP[0] = 1.0, BP[1] = 1.5\n\tu = ax - bp; // (x-1) || (x-1.5)\n\tv = 1.0 / (ax + bp); // 1/(x+1) || 1/(x+1.5)\n\tss = u * v;\n\ths = setLowWord( ss, 0 ); // set all low word (less significant significand) bits to 0s\n\n\t// Compute `ht = ax + bp` (via manipulation, i.e., bit flipping, of the high word):\n\ttmp = ((ahx>>1) | HIGH_BIASED_EXP_NEG_512) + HIGH_SIGNIFICAND_HALF;\n\ttmp += (k << 18); // `(k<<18)` can be considered the word equivalent of `1.0` or `1.5`\n\tht = setHighWord( 0.0, tmp );\n\tlt = ax - (ht - bp);\n\tls = v * ( ( u - (hs*ht) ) - ( hs*lt ) );\n\n\t// Compute `log(ax)`...\n\n\ts2 = ss * ss;\n\tr = s2 * s2 * polyvalL( s2 );\n\tr += ls * (hs + ss);\n\ts2 = hs * hs;\n\tht = 3.0 + s2 + r;\n\tht = setLowWord( ht, 0 );\n\tlt = r - ((ht-3.0) - s2);\n\n\t// u+v = ss*(1+...):\n\tu = hs * ht;\n\tv = ( ls*ht ) + ( lt*ss );\n\n\t// 2/(3LN2) * (ss+...):\n\thp = u + v;\n\thp = setLowWord( hp, 0 );\n\tlp = v - (hp - u);\n\thz = CP_HI * hp; // CP_HI+CP_LO = 2/(3*LN2)\n\tlz = ( CP_LO*hp ) + ( lp*CP ) + DP_LO[ k ];\n\n\t// log2(ax) = (ss+...)*2/(3*LN2) = n + dp + hz + lz\n\tdp = DP_HI[ k ];\n\tt = n;\n\tt1 = ((hz+lz) + dp) + t; // log2(ax)\n\tt1 = setLowWord( t1, 0 );\n\tt2 = lz - (((t1-t) - dp) - hz);\n\n\tout[ 0 ] = t1;\n\tout[ 1 ] = t2;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default log2ax;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setLowWord from '@stdlib/number/float64/base/set-low-word';\nimport polyvalW from './polyval_w.js';\n\n\n// VARIABLES //\n\n// 1/LN2\nvar INV_LN2 = 1.44269504088896338700e+00; // 0x3FF71547, 0x652B82FE\n\n// High (24 bits): 1/LN2\nvar INV_LN2_HI = 1.44269502162933349609e+00; // 0x3FF71547, 0x60000000\n\n// Low: 1/LN2\nvar INV_LN2_LO = 1.92596299112661746887e-08; // 0x3E54AE0B, 0xF85DDF44\n\n\n// MAIN //\n\n/**\n* Computes \\\\(\\operatorname{log}(x)\\\\) assuming \\\\(|1-x|\\\\) is small and using the approximation \\\\(x - x^2/2 + x^3/3 - x^4/4\\\\).\n*\n* @private\n* @param {Array} out - output array\n* @param {number} ax - absolute value of `x`\n* @returns {Array} output array containing a tuple comprised of high and low parts\n*\n* @example\n* var t = logx( [ 0.0, 0.0 ], 9.0 ); // => [ t1, t2 ]\n* // returns [ -1265.7236328125, -0.0008163940840404393 ]\n*/\nfunction logx( out, ax ) {\n\tvar t2;\n\tvar t1;\n\tvar t;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tt = ax - 1.0; // `t` has `20` trailing zeros\n\tw = t * t * polyvalW( t );\n\tu = INV_LN2_HI * t; // `INV_LN2_HI` has `21` significant bits\n\tv = ( t*INV_LN2_LO ) - ( w*INV_LN2 );\n\tt1 = u + v;\n\tt1 = setLowWord( t1, 0 );\n\tt2 = v - (t1 - u);\n\n\tout[ 0 ] = t1;\n\tout[ 1 ] = t2;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default logx;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* The maximum biased base 2 exponent for a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/max-base2-exponent\n* @type {integer32}\n*\n* @example\n* import FLOAT64_MAX_BASE2_EXPONENT from '@stdlib/constants/float64/max-base2-exponent';\n* // returns 1023\n*/\n\n\n// MAIN //\n\n/**\n* The maximum biased base 2 exponent for a double-precision floating-point number.\n*\n* ```text\n* 11111111110 => 2046 - BIAS = 1023\n* ```\n*\n* where `BIAS = 1023`.\n*\n* @constant\n* @type {integer32}\n* @default 1023\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_MAX_BASE2_EXPONENT = 1023|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default FLOAT64_MAX_BASE2_EXPONENT;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* The maximum biased base 2 exponent for a subnormal double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/max-base2-exponent-subnormal\n* @type {integer32}\n*\n* @example\n* import FLOAT64_MAX_BASE2_EXPONENT_SUBNORMAL from '@stdlib/constants/float64/max-base2-exponent-subnormal';\n* // returns -1023\n*/\n\n\n// MAIN //\n\n/**\n* The maximum biased base 2 exponent for a subnormal double-precision floating-point number.\n*\n* ```text\n* 00000000000 => 0 - BIAS = -1023\n* ```\n*\n* where `BIAS = 1023`.\n*\n* @constant\n* @type {integer32}\n* @default -1023\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_MAX_BASE2_EXPONENT_SUBNORMAL = -1023|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default FLOAT64_MAX_BASE2_EXPONENT_SUBNORMAL;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* The minimum biased base 2 exponent for a subnormal double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/min-base2-exponent-subnormal\n* @type {integer32}\n*\n* @example\n* import FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL from '@stdlib/constants/float64/min-base2-exponent-subnormal';\n* // returns -1074\n*/\n\n\n// MAIN //\n\n/**\n* The minimum biased base 2 exponent for a subnormal double-precision floating-point number.\n*\n* ```text\n* -(BIAS+(52-1)) = -(1023+51) = -1074\n* ```\n*\n* where `BIAS = 1023` and `52` is the number of digits in the significand.\n*\n* @constant\n* @type {integer32}\n* @default -1074\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL = -1074|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Smallest positive double-precision floating-point normal number.\n*\n* @module @stdlib/constants/float64/smallest-normal\n* @type {number}\n*\n* @example\n* import FLOAT64_SMALLEST_NORMAL from '@stdlib/constants/float64/smallest-normal';\n* // returns 2.2250738585072014e-308\n*/\n\n\n// MAIN //\n\n/**\n* The smallest positive double-precision floating-point normal number.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* \\frac{1}{2^{1023-1}}\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 0 00000000001 00000000000000000000 00000000000000000000000000000000\n* ```\n*\n* @constant\n* @type {number}\n* @default 2.2250738585072014e-308\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_SMALLEST_NORMAL = 2.2250738585072014e-308;\n\n\n// EXPORTS //\n\nexport default FLOAT64_SMALLEST_NORMAL;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport FLOAT64_SMALLEST_NORMAL from '@stdlib/constants/float64/smallest-normal';\nimport isInfinite from '@stdlib/math/base/assert/is-infinite';\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport abs from '@stdlib/math/base/special/abs';\n\n\n// VARIABLES //\n\n// (1<<52)\nvar SCALAR = 4503599627370496;\n\n\n// MAIN //\n\n/**\n* Returns a normal number `y` and exponent `exp` satisfying \\\\(x = y \\cdot 2^\\mathrm{exp}\\\\) and assigns results to a provided output array.\n*\n* @param {number} x - input value\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import pow from '@stdlib/math/base/special/pow';\n*\n* var out = normalize( 3.14e-319, [ 0.0, 0 ], 1, 0 );\n* // returns [ 1.4141234400356668e-303, -52 ]\n*\n* var y = out[ 0 ];\n* var exp = out[ 1 ];\n*\n* var bool = ( y*pow(2.0,exp) === 3.14e-319 );\n* // returns true\n*\n* @example\n* var out = normalize( 0.0, [ 0.0, 0 ], 1, 0 );\n* // returns [ 0.0, 0 ];\n*\n* @example\n* import PINF from '@stdlib/constants/float64/pinf';\n*\n* var out = normalize( PINF, [ 0.0, 0 ], 1, 0 );\n* // returns [ Infinity, 0 ]\n*\n* @example\n* import NINF from '@stdlib/constants/float64/ninf';\n*\n* var out = normalize( NINF, [ 0.0, 0 ], 1, 0 );\n* // returns [ -Infinity, 0 ]\n*\n* @example\n* var out = normalize( NaN, [ 0.0, 0 ], 1, 0 );\n* // returns [ NaN, 0 ]\n*/\nfunction normalize( x, out, stride, offset ) {\n\tif ( isnan( x ) || isInfinite( x ) ) {\n\t\tout[ offset ] = x;\n\t\tout[ offset + stride ] = 0;\n\t\treturn out;\n\t}\n\tif ( x !== 0.0 && abs( x ) < FLOAT64_SMALLEST_NORMAL ) {\n\t\tout[ offset ] = x * SCALAR;\n\t\tout[ offset + stride ] = -52;\n\t\treturn out;\n\t}\n\tout[ offset ] = x;\n\tout[ offset + stride ] = 0;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return a normal number `y` and exponent `exp` satisfying \\\\(x = y \\cdot 2^\\mathrm{exp}\\\\).\n*\n* @module @stdlib/number/float64/base/normalize\n*\n* @example\n* import normalize from '@stdlib/number/float64/base/normalize';\n* import pow from '@stdlib/math/base/special/pow';\n*\n* var out = normalize( 3.14e-319 );\n* // returns [ 1.4141234400356668e-303, -52 ]\n*\n* var y = out[ 0 ];\n* var exp = out[ 1 ];\n*\n* var bool = ( y*pow(2.0, exp) === 3.14e-319 );\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import normalize from '@stdlib/number/float64/base/normalize';\n*\n* var out = new Float64Array( 2 );\n*\n* var v = normalize.assign( 3.14e-319, out, 1, 0 );\n* // returns [ 1.4141234400356668e-303, -52 ]\n*\n* var bool = ( v === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fcn from './assign.js';\n\n\n// MAIN //\n\n/**\n* Returns a normal number `y` and exponent `exp` satisfying \\\\(x = y \\cdot 2^\\mathrm{exp}\\\\).\n*\n* @param {number} x - input value\n* @returns {NumberArray} output array\n*\n* @example\n* import pow from '@stdlib/math/base/special/pow';\n*\n* var out = normalize( 3.14e-319 );\n* // returns [ 1.4141234400356668e-303, -52 ]\n*\n* var y = out[ 0 ];\n* var exp = out[ 1 ];\n*\n* var bool = ( y*pow(2.0,exp) === 3.14e-319 );\n* // returns true\n*\n* @example\n* var out = normalize( 0.0 );\n* // returns [ 0.0, 0 ]\n*\n* @example\n* import PINF from '@stdlib/constants/float64/pinf';\n*\n* var out = normalize( PINF );\n* // returns [ Infinity, 0 ]\n*\n* @example\n* import NINF from '@stdlib/constants/float64/ninf';\n*\n* var out = normalize( NINF );\n* // returns [ -Infinity, 0 ]\n*\n* @example\n* var out = normalize( NaN );\n* // returns [ NaN, 0 ]\n*/\nfunction normalize( x ) {\n\treturn fcn( x, [ 0.0, 0 ], 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* High word mask for the exponent of a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/high-word-exponent-mask\n* @type {uinteger32}\n*\n* @example\n* import FLOAT64_HIGH_WORD_EXPONENT_MASK from '@stdlib/constants/float64/high-word-exponent-mask';\n* // returns 2146435072\n*/\n\n\n// MAIN //\n\n/**\n* High word mask for the exponent of a double-precision floating-point number.\n*\n* ## Notes\n*\n* The high word mask for the exponent of a double-precision floating-point number is an unsigned 32-bit integer with the value \\\\( 2146435072 \\\\), which corresponds to the bit sequence\n*\n* ```binarystring\n* 0 11111111111 00000000000000000000\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 0x7ff00000\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_HIGH_WORD_EXPONENT_MASK = 0x7ff00000;\n\n\n// EXPORTS //\n\nexport default FLOAT64_HIGH_WORD_EXPONENT_MASK;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// NOTES //\n\n/*\n* => ldexp: load exponent (see [The Open Group]{@link http://pubs.opengroup.org/onlinepubs/9699919799/functions/ldexp.html} and [cppreference]{@link http://en.cppreference.com/w/c/numeric/math/ldexp}).\n*/\n\n\n// MODULES //\n\nimport PINF from '@stdlib/constants/float64/pinf';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport BIAS from '@stdlib/constants/float64/exponent-bias';\nimport MAX_EXPONENT from '@stdlib/constants/float64/max-base2-exponent';\nimport MAX_SUBNORMAL_EXPONENT from '@stdlib/constants/float64/max-base2-exponent-subnormal';\nimport MIN_SUBNORMAL_EXPONENT from '@stdlib/constants/float64/min-base2-exponent-subnormal';\nimport isnan from './../../../../base/assert/is-nan';\nimport isInfinite from './../../../../base/assert/is-infinite';\nimport copysign from './../../../../base/special/copysign';\nimport { assign as normalize } from '@stdlib/number/float64/base/normalize';\nimport floatExp from '@stdlib/number/float64/base/exponent';\nimport toWords from '@stdlib/number/float64/base/to-words';\nimport fromWords from '@stdlib/number/float64/base/from-words';\n\n\n// VARIABLES //\n\n// 1/(1<<52) = 1/(2**52) = 1/4503599627370496\nvar TWO52_INV = 2.220446049250313e-16;\n\n// Exponent all 0s: 1 00000000000 11111111111111111111 => 2148532223\nvar CLEAR_EXP_MASK = 0x800fffff>>>0; // asm type annotation\n\n// Normalization workspace:\nvar FRAC = [ 0.0, 0.0 ];\n\n// High/low words workspace:\nvar WORDS = [ 0, 0 ];\n\n\n// MAIN //\n\n/**\n* Multiplies a double-precision floating-point number by an integer power of two.\n*\n* @param {number} frac - fraction\n* @param {integer} exp - exponent\n* @returns {number} double-precision floating-point number\n*\n* @example\n* var x = ldexp( 0.5, 3 ); // => 0.5 * 2^3 = 0.5 * 8\n* // returns 4.0\n*\n* @example\n* var x = ldexp( 4.0, -2 ); // => 4 * 2^(-2) = 4 * (1/4)\n* // returns 1.0\n*\n* @example\n* var x = ldexp( 0.0, 20 );\n* // returns 0.0\n*\n* @example\n* var x = ldexp( -0.0, 39 );\n* // returns -0.0\n*\n* @example\n* var x = ldexp( NaN, -101 );\n* // returns NaN\n*\n* @example\n* var x = ldexp( Infinity, 11 );\n* // returns Infinity\n*\n* @example\n* var x = ldexp( -Infinity, -118 );\n* // returns -Infinity\n*/\nfunction ldexp( frac, exp ) {\n\tvar high;\n\tvar m;\n\tif (\n\t\texp === 0 ||\n\t\tfrac === 0.0 || // handles +-0\n\t\tisnan( frac ) ||\n\t\tisInfinite( frac )\n\t) {\n\t\treturn frac;\n\t}\n\t// Normalize the input fraction:\n\tnormalize( frac, FRAC, 1, 0 );\n\tfrac = FRAC[ 0 ];\n\texp += FRAC[ 1 ];\n\n\t// Extract the exponent from `frac` and add it to `exp`:\n\texp += floatExp( frac );\n\n\t// Check for underflow/overflow...\n\tif ( exp < MIN_SUBNORMAL_EXPONENT ) {\n\t\treturn copysign( 0.0, frac );\n\t}\n\tif ( exp > MAX_EXPONENT ) {\n\t\tif ( frac < 0.0 ) {\n\t\t\treturn NINF;\n\t\t}\n\t\treturn PINF;\n\t}\n\t// Check for a subnormal and scale accordingly to retain precision...\n\tif ( exp <= MAX_SUBNORMAL_EXPONENT ) {\n\t\texp += 52;\n\t\tm = TWO52_INV;\n\t} else {\n\t\tm = 1.0;\n\t}\n\t// Split the fraction into higher and lower order words:\n\ttoWords.assign( frac, WORDS, 1, 0 );\n\thigh = WORDS[ 0 ];\n\n\t// Clear the exponent bits within the higher order word:\n\thigh &= CLEAR_EXP_MASK;\n\n\t// Set the exponent bits to the new exponent:\n\thigh |= ((exp+BIAS) << 20);\n\n\t// Create a new floating-point number:\n\treturn m * fromWords( high, WORDS[ 1 ] );\n}\n\n\n// EXPORTS //\n\nexport default ldexp;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getHighWord from './../../../../float64/base/get-high-word';\nimport EXP_MASK from '@stdlib/constants/float64/high-word-exponent-mask';\nimport BIAS from '@stdlib/constants/float64/exponent-bias';\n\n\n// MAIN //\n\n/**\n* Returns an integer corresponding to the unbiased exponent of a double-precision floating-point number.\n*\n* @param {number} x - input value\n* @returns {integer32} unbiased exponent\n*\n* @example\n* var exp = exponent( 3.14e-307 ); // => 2**-1019 ~ 1e-307\n* // returns -1019\n*\n* @example\n* var exp = exponent( -3.14 );\n* // returns 1\n*\n* @example\n* var exp = exponent( 0.0 );\n* // returns -1023\n*\n* @example\n* var exp = exponent( NaN );\n* // returns 1024\n*/\nfunction exponent( x ) {\n\t// Extract from the input value a higher order word (unsigned 32-bit integer) which contains the exponent:\n\tvar high = getHighWord( x );\n\n\t// Apply a mask to isolate only the exponent bits and then shift off all bits which are part of the fraction:\n\thigh = ( high & EXP_MASK ) >>> 20;\n\n\t// Remove the bias and return:\n\treturn (high - BIAS)|0; // asm type annotation\n}\n\n\n// EXPORTS //\n\nexport default exponent;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Natural logarithm of `2`.\n*\n* @module @stdlib/constants/float64/ln-two\n* @type {number}\n*\n* @example\n* import LN2 from '@stdlib/constants/float64/ln-two';\n* // returns 0.6931471805599453\n*/\n\n\n// MAIN //\n\n/**\n* Natural logarithm of `2`.\n*\n* ```tex\n* \\ln 2\n* ```\n*\n* @constant\n* @type {number}\n* @default 0.6931471805599453\n*/\nvar LN2 = 6.93147180559945309417232121458176568075500134360255254120680009493393621969694715605863326996418687542001481021e-01; // eslint-disable-line max-len\n\n\n// EXPORTS //\n\nexport default LN2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* High word mask for the significand of a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/high-word-significand-mask\n* @type {uinteger32}\n*\n* @example\n* import FLOAT64_HIGH_WORD_SIGNIFICAND_MASK from '@stdlib/constants/float64/high-word-significand-mask';\n* // returns 1048575\n*/\n\n\n// MAIN //\n\n/**\n* High word mask for the significand of a double-precision floating-point number.\n*\n* ## Notes\n*\n* The high word mask for the significand of a double-precision floating-point number is an unsigned 32-bit integer with the value \\\\( 1048575 \\\\), which corresponds to the bit sequence\n*\n* ```binarystring\n* 0 00000000000 11111111111111111111\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 0x000fffff\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_HIGH_WORD_SIGNIFICAND_MASK = 0x000fffff;\n\n\n// EXPORTS //\n\nexport default FLOAT64_HIGH_WORD_SIGNIFICAND_MASK;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getHighWord from '@stdlib/number/float64/base/get-high-word';\nimport setHighWord from '@stdlib/number/float64/base/set-high-word';\nimport setLowWord from '@stdlib/number/float64/base/set-low-word';\nimport uint32ToInt32 from '@stdlib/number/uint32/base/to-int32';\nimport ldexp from './../../../../base/special/ldexp';\nimport LN2 from '@stdlib/constants/float64/ln-two';\nimport BIAS from '@stdlib/constants/float64/exponent-bias';\nimport ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\nimport HIGH_SIGNIFICAND_MASK from '@stdlib/constants/float64/high-word-significand-mask';\nimport HIGH_NUM_SIGNIFICAND_BITS from '@stdlib/constants/float64/num-high-word-significand-bits';\nimport polyvalP from './polyval_p.js';\n\n\n// VARIABLES //\n\n// 0x00100000 = 1048576 => 0 00000000001 00000000000000000000 => biased exponent: 1 = -1022+1023 => 2^-1022\nvar HIGH_MIN_NORMAL_EXP = 0x00100000|0; // asm type annotation\n\n// 0x3fe00000 = 1071644672 => 0 01111111110 00000000000000000000 => biased exponent: 1022 = -1+1023 => 2^-1\nvar HIGH_BIASED_EXP_NEG_1 = 0x3fe00000|0; // asm type annotation\n\n// High: LN2\nvar LN2_HI = 6.93147182464599609375e-01; // 0x3FE62E43, 0x00000000\n\n// Low: LN2\nvar LN2_LO = -1.90465429995776804525e-09; // 0xBE205C61, 0x0CA86C39\n\n\n// MAIN //\n\n/**\n* Computes \\\\(2^{\\mathrm{hp} + \\mathrm{lp}\\\\).\n*\n* @private\n* @param {number} j - high word of `hp + lp`\n* @param {number} hp - first power summand\n* @param {number} lp - second power summand\n* @returns {number} function value\n*\n* @example\n* var z = pow2( 1065961648, -0.3398475646972656, -0.000002438187359100815 );\n* // returns ~0.79\n*/\nfunction pow2( j, hp, lp ) {\n\tvar tmp;\n\tvar t1;\n\tvar t;\n\tvar r;\n\tvar u;\n\tvar v;\n\tvar w;\n\tvar z;\n\tvar n;\n\tvar i;\n\tvar k;\n\n\ti = (j & ABS_MASK)|0; // asm type annotation\n\tk = ((i>>HIGH_NUM_SIGNIFICAND_BITS) - BIAS)|0; // asm type annotation\n\tn = 0;\n\n\t// `|z| > 0.5`, set `n = z+0.5`\n\tif ( i > HIGH_BIASED_EXP_NEG_1 ) {\n\t\tn = (j + (HIGH_MIN_NORMAL_EXP>>(k+1)))>>>0; // asm type annotation\n\t\tk = (((n & ABS_MASK)>>HIGH_NUM_SIGNIFICAND_BITS) - BIAS)|0; // new k for n\n\t\ttmp = ((n & ~(HIGH_SIGNIFICAND_MASK >> k)))>>>0; // asm type annotation\n\t\tt = setHighWord( 0.0, tmp );\n\t\tn = (((n & HIGH_SIGNIFICAND_MASK)|HIGH_MIN_NORMAL_EXP) >> (HIGH_NUM_SIGNIFICAND_BITS-k))>>>0; // eslint-disable-line max-len\n\t\tif ( j < 0 ) {\n\t\t\tn = -n;\n\t\t}\n\t\thp -= t;\n\t}\n\tt = lp + hp;\n\tt = setLowWord( t, 0 );\n\tu = t * LN2_HI;\n\tv = ( (lp - (t-hp))*LN2 ) + ( t*LN2_LO );\n\tz = u + v;\n\tw = v - (z - u);\n\tt = z * z;\n\tt1 = z - ( t*polyvalP( t ) );\n\tr = ( (z*t1) / (t1-2.0) ) - ( w + (z*w) );\n\tz = 1.0 - (r - z);\n\tj = getHighWord( z );\n\tj = uint32ToInt32( j );\n\tj += (n << HIGH_NUM_SIGNIFICAND_BITS)>>>0; // asm type annotation\n\n\t// Check for subnormal output...\n\tif ( (j>>HIGH_NUM_SIGNIFICAND_BITS) <= 0 ) {\n\t\tz = ldexp( z, n );\n\t} else {\n\t\tz = setHighWord( z, j );\n\t}\n\treturn z;\n}\n\n\n// EXPORTS //\n\nexport default pow2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from './../../../../base/assert/is-nan';\nimport isOdd from './../../../../base/assert/is-odd';\nimport isInfinite from './../../../../base/assert/is-infinite';\nimport isInteger from './../../../../base/assert/is-integer';\nimport sqrt from './../../../../base/special/sqrt';\nimport abs from './../../../../base/special/abs';\nimport toWords from '@stdlib/number/float64/base/to-words';\nimport setLowWord from '@stdlib/number/float64/base/set-low-word';\nimport uint32ToInt32 from '@stdlib/number/uint32/base/to-int32';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport PINF from '@stdlib/constants/float64/pinf';\nimport ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\nimport xIsZero from './x_is_zero.js';\nimport yIsHuge from './y_is_huge.js';\nimport yIsInfinite from './y_is_infinite.js';\nimport log2ax from './log2ax.js';\nimport logx from './logx.js';\nimport pow2 from './pow2.js';\n\n\n// VARIABLES //\n\n// 0x3fefffff = 1072693247 => 0 01111111110 11111111111111111111 => biased exponent: 1022 = -1+1023 => 2^-1\nvar HIGH_MAX_NEAR_UNITY = 0x3fefffff|0; // asm type annotation\n\n// 0x41e00000 = 1105199104 => 0 10000011110 00000000000000000000 => biased exponent: 1054 = 31+1023 => 2^31\nvar HIGH_BIASED_EXP_31 = 0x41e00000|0; // asm type annotation\n\n// 0x43f00000 = 1139802112 => 0 10000111111 00000000000000000000 => biased exponent: 1087 = 64+1023 => 2^64\nvar HIGH_BIASED_EXP_64 = 0x43f00000|0; // asm type annotation\n\n// 0x40900000 = 1083179008 => 0 10000001001 00000000000000000000 => biased exponent: 1033 = 10+1023 => 2^10 = 1024\nvar HIGH_BIASED_EXP_10 = 0x40900000|0; // asm type annotation\n\n// 0x3ff00000 = 1072693248 => 0 01111111111 00000000000000000000 => biased exponent: 1023 = 0+1023 => 2^0 = 1\nvar HIGH_BIASED_EXP_0 = 0x3ff00000|0; // asm type annotation\n\n// 0x4090cc00 = 1083231232 => 0 10000001001 00001100110000000000\nvar HIGH_1075 = 0x4090cc00|0; // asm type annotation\n\n// 0xc090cc00 = 3230714880 => 1 10000001001 00001100110000000000\nvar HIGH_NEG_1075 = 0xc090cc00>>>0; // asm type annotation\n\nvar HIGH_NUM_NONSIGN_BITS = 31|0; // asm type annotation\n\nvar HUGE = 1.0e300;\nvar TINY = 1.0e-300;\n\n// -(1024-log2(ovfl+.5ulp))\nvar OVT = 8.0085662595372944372e-17;\n\n// High/low words workspace:\nvar WORDS = [ 0|0, 0|0 ];\n\n// Log workspace:\nvar LOG_WORKSPACE = [ 0.0, 0.0 ];\n\n\n// MAIN //\n\n/**\n* Evaluates the exponential function.\n*\n* ## Method\n*\n* 1. Let \\\\(x = 2^n (1+f)\\\\).\n*\n* 2. Compute \\\\(\\operatorname{log2}(x)\\\\) as\n*\n* ```tex\n* \\operatorname{log2}(x) = w_1 + w_2\n* ```\n*\n* where \\\\(w_1\\\\) has \\\\(53 - 24 = 29\\\\) bit trailing zeros.\n*\n* 3. Compute\n*\n* ```tex\n* y \\cdot \\operatorname{log2}(x) = n + y^\\prime\n* ```\n*\n* by simulating multi-precision arithmetic, where \\\\(|y^\\prime| \\leq 0.5\\\\).\n*\n* 4. Return\n*\n* ```tex\n* x^y = 2^n e^{y^\\prime \\cdot \\mathrm{log2}}\n* ```\n*\n* ## Special Cases\n*\n* ```tex\n* \\begin{align*}\n* x^{\\mathrm{NaN}} &= \\mathrm{NaN} & \\\\\n* (\\mathrm{NaN})^y &= \\mathrm{NaN} & \\\\\n* 1^y &= 1 & \\\\\n* x^0 &= 1 & \\\\\n* x^1 &= x & \\\\\n* (\\pm 0)^\\infty &= +0 & \\\\\n* (\\pm 0)^{-\\infty} &= +\\infty & \\\\\n* (+0)^y &= +0 & \\mathrm{if}\\ y > 0 \\\\\n* (+0)^y &= +\\infty & \\mathrm{if}\\ y < 0 \\\\\n* (-0)^y &= -\\infty & \\mathrm{if}\\ y\\ \\mathrm{is\\ an\\ odd\\ integer\\ and}\\ y < 0 \\\\\n* (-0)^y &= +\\infty & \\mathrm{if}\\ y\\ \\mathrm{is\\ not\\ an\\ odd\\ integer\\ and}\\ y < 0 \\\\\n* (-0)^y &= -0 & \\mathrm{if}\\ y\\ \\mathrm{is\\ an\\ odd\\ integer\\ and}\\ y > 0 \\\\\n* (-0)^y &= +0 & \\mathrm{if}\\ y\\ \\mathrm{is\\ not\\ an\\ odd\\ integer\\ and}\\ y > 0 \\\\\n* (-1)^{\\pm\\infty} &= \\mathrm{NaN} & \\\\\n* x^{\\infty} &= +\\infty & |x| > 1 \\\\\n* x^{\\infty} &= +0 & |x| < 1 \\\\\n* x^{-\\infty} &= +0 & |x| > 1 \\\\\n* x^{-\\infty} &= +\\infty & |x| < 1 \\\\\n* (-\\infty)^y &= (-0)^y & \\\\\n* \\infty^y &= +0 & y < 0 \\\\\n* \\infty^y &= +\\infty & y > 0 \\\\\n* x^y &= \\mathrm{NaN} & \\mathrm{if}\\ y\\ \\mathrm{is\\ not\\ a\\ finite\\ integer\\ and}\\ x < 0\n* \\end{align*}\n* ```\n*\n* ## Notes\n*\n* - \\\\(\\operatorname{pow}(x,y)\\\\) returns \\\\(x^y\\\\) nearly rounded. In particular, \\\\(\\operatorname{pow}(<\\mathrm{integer}>,<\\mathrm{integer}>)\\\\) **always** returns the correct integer, provided the value is representable.\n* - The hexadecimal values shown in the source code are the intended values for used constants. Decimal values may be used, provided the compiler will accurately convert decimal to binary in order to produce the hexadecimal values.\n*\n* @param {number} x - base\n* @param {number} y - exponent\n* @returns {number} function value\n*\n* @example\n* var v = pow( 2.0, 3.0 );\n* // returns 8.0\n*\n* @example\n* var v = pow( 4.0, 0.5 );\n* // returns 2.0\n*\n* @example\n* var v = pow( 100.0, 0.0 );\n* // returns 1.0\n*\n* @example\n* var v = pow( 3.141592653589793, 5.0 );\n* // returns ~306.0197\n*\n* @example\n* var v = pow( 3.141592653589793, -0.2 );\n* // returns ~0.7954\n*\n* @example\n* var v = pow( NaN, 3.0 );\n* // returns NaN\n*\n* @example\n* var v = pow( 5.0, NaN );\n* // returns NaN\n*\n* @example\n* var v = pow( NaN, NaN );\n* // returns NaN\n*/\nfunction pow( x, y ) {\n\tvar ahx; // absolute value high word `x`\n\tvar ahy; // absolute value high word `y`\n\tvar ax; // absolute value `x`\n\tvar hx; // high word `x`\n\tvar lx; // low word `x`\n\tvar hy; // high word `y`\n\tvar ly; // low word `y`\n\tvar sx; // sign `x`\n\tvar sy; // sign `y`\n\tvar y1;\n\tvar hp;\n\tvar lp;\n\tvar t;\n\tvar z; // y prime\n\tvar j;\n\tvar i;\n\tif ( isnan( x ) || isnan( y ) ) {\n\t\treturn NaN;\n\t}\n\t// Split `y` into high and low words:\n\ttoWords.assign( y, WORDS, 1, 0 );\n\thy = WORDS[ 0 ];\n\tly = WORDS[ 1 ];\n\n\t// Special cases `y`...\n\tif ( ly === 0 ) {\n\t\tif ( y === 0.0 ) {\n\t\t\treturn 1.0;\n\t\t}\n\t\tif ( y === 1.0 ) {\n\t\t\treturn x;\n\t\t}\n\t\tif ( y === -1.0 ) {\n\t\t\treturn 1.0 / x;\n\t\t}\n\t\tif ( y === 0.5 ) {\n\t\t\treturn sqrt( x );\n\t\t}\n\t\tif ( y === -0.5 ) {\n\t\t\treturn 1.0 / sqrt( x );\n\t\t}\n\t\tif ( y === 2.0 ) {\n\t\t\treturn x * x;\n\t\t}\n\t\tif ( y === 3.0 ) {\n\t\t\treturn x * x * x;\n\t\t}\n\t\tif ( y === 4.0 ) {\n\t\t\tx *= x;\n\t\t\treturn x * x;\n\t\t}\n\t\tif ( isInfinite( y ) ) {\n\t\t\treturn yIsInfinite( x, y );\n\t\t}\n\t}\n\t// Split `x` into high and low words:\n\ttoWords.assign( x, WORDS, 1, 0 );\n\thx = WORDS[ 0 ];\n\tlx = WORDS[ 1 ];\n\n\t// Special cases `x`...\n\tif ( lx === 0 ) {\n\t\tif ( hx === 0 ) {\n\t\t\treturn xIsZero( x, y );\n\t\t}\n\t\tif ( x === 1.0 ) {\n\t\t\treturn 1.0;\n\t\t}\n\t\tif (\n\t\t\tx === -1.0 &&\n\t\t\tisOdd( y )\n\t\t) {\n\t\t\treturn -1.0;\n\t\t}\n\t\tif ( isInfinite( x ) ) {\n\t\t\tif ( x === NINF ) {\n\t\t\t\t// `pow( 1/x, -y )`\n\t\t\t\treturn pow( -0.0, -y );\n\t\t\t}\n\t\t\tif ( y < 0.0 ) {\n\t\t\t\treturn 0.0;\n\t\t\t}\n\t\t\treturn PINF;\n\t\t}\n\t}\n\tif (\n\t\tx < 0.0 &&\n\t\tisInteger( y ) === false\n\t) {\n\t\t// Signal NaN...\n\t\treturn (x-x)/(x-x);\n\t}\n\tax = abs( x );\n\n\t// Remove the sign bits (i.e., get absolute values):\n\tahx = (hx & ABS_MASK)|0; // asm type annotation\n\tahy = (hy & ABS_MASK)|0; // asm type annotation\n\n\t// Extract the sign bits:\n\tsx = (hx >>> HIGH_NUM_NONSIGN_BITS)|0; // asm type annotation\n\tsy = (hy >>> HIGH_NUM_NONSIGN_BITS)|0; // asm type annotation\n\n\t// Determine the sign of the result...\n\tif ( sx && isOdd( y ) ) {\n\t\tsx = -1.0;\n\t} else {\n\t\tsx = 1.0;\n\t}\n\t// Case 1: `|y|` is huge...\n\n\t// |y| > 2^31\n\tif ( ahy > HIGH_BIASED_EXP_31 ) {\n\t\t// `|y| > 2^64`, then must over- or underflow...\n\t\tif ( ahy > HIGH_BIASED_EXP_64 ) {\n\t\t\treturn yIsHuge( x, y );\n\t\t}\n\t\t// Over- or underflow if `x` is not close to unity...\n\n\t\tif ( ahx < HIGH_MAX_NEAR_UNITY ) {\n\t\t\t// y < 0\n\t\t\tif ( sy === 1 ) {\n\t\t\t\t// Signal overflow...\n\t\t\t\treturn sx * HUGE * HUGE;\n\t\t\t}\n\t\t\t// Signal underflow...\n\t\t\treturn sx * TINY * TINY;\n\t\t}\n\t\tif ( ahx > HIGH_BIASED_EXP_0 ) {\n\t\t\t// y > 0\n\t\t\tif ( sy === 0 ) {\n\t\t\t\t// Signal overflow...\n\t\t\t\treturn sx * HUGE * HUGE;\n\t\t\t}\n\t\t\t// Signal underflow...\n\t\t\treturn sx * TINY * TINY;\n\t\t}\n\t\t// At this point, `|1-x|` is tiny (`<= 2^-20`). Suffice to compute `log(x)` by `x - x^2/2 + x^3/3 - x^4/4`.\n\t\tt = logx( LOG_WORKSPACE, ax );\n\t}\n\t// Case 2: `|y|` is not huge...\n\telse {\n\t\tt = log2ax( LOG_WORKSPACE, ax, ahx );\n\t}\n\t// Split `y` into `y1 + y2` and compute `(y1+y2) * (t1+t2)`...\n\ty1 = setLowWord( y, 0 );\n\tlp = ( (y-y1)*t[0] ) + ( y*t[1] );\n\thp = y1 * t[0];\n\tz = lp + hp;\n\n\t// Note: *can* be more performant to use `getHighWord` and `getLowWord` directly, but using `toWords` looks cleaner.\n\ttoWords.assign( z, WORDS, 1, 0 );\n\tj = uint32ToInt32( WORDS[0] );\n\ti = uint32ToInt32( WORDS[1] );\n\n\t// z >= 1024\n\tif ( j >= HIGH_BIASED_EXP_10 ) {\n\t\t// z > 1024\n\t\tif ( ((j-HIGH_BIASED_EXP_10)|i) !== 0 ) {\n\t\t\t// Signal overflow...\n\t\t\treturn sx * HUGE * HUGE;\n\t\t}\n\t\tif ( (lp+OVT) > (z-hp) ) {\n\t\t\t// Signal overflow...\n\t\t\treturn sx * HUGE * HUGE;\n\t\t}\n\t}\n\t// z <= -1075\n\telse if ( (j&ABS_MASK) >= HIGH_1075 ) {\n\t\t// z < -1075\n\t\tif ( ((j-HIGH_NEG_1075)|i) !== 0 ) {\n\t\t\t// Signal underflow...\n\t\t\treturn sx * TINY * TINY;\n\t\t}\n\t\tif ( lp <= (z-hp) ) {\n\t\t\t// Signal underflow...\n\t\t\treturn sx * TINY * TINY;\n\t\t}\n\t}\n\t// Compute `2^(hp+lp)`...\n\tz = pow2( j, hp, lp );\n\n\treturn sx * z;\n}\n\n\n// EXPORTS //\n\nexport default pow;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport abs from './../../../../base/special/abs';\nimport PINF from '@stdlib/constants/float64/pinf';\n\n\n// MAIN //\n\n/**\n* Evaluates the exponential function when \\\\( y = \\pm \\infty\\\\).\n*\n* @private\n* @param {number} x - base\n* @param {number} y - exponent\n* @returns {number} function value\n*\n* @example\n* var v = pow( -1.0, Infinity );\n* // returns NaN\n*\n* @example\n* var v = pow( -1.0, -Infinity );\n* // returns NaN\n*\n* @example\n* var v = pow( 1.0, Infinity );\n* // returns 1.0\n*\n* @example\n* var v = pow( 1.0, -Infinity );\n* // returns 1.0\n*\n* @example\n* var v = pow( 0.5, Infinity );\n* // returns 0.0\n*\n* @example\n* var v = pow( 0.5, -Infinity );\n* // returns Infinity\n*\n* @example\n* var v = pow( 1.5, -Infinity );\n* // returns 0.0\n*\n* @example\n* var v = pow( 1.5, Infinity );\n* // returns Infinity\n*/\nfunction pow( x, y ) {\n\tif ( x === -1.0 ) {\n\t\t// Julia (0.4.2) and Python (2.7.9) return `1.0` (WTF???). JavaScript (`Math.pow`), R, and libm return `NaN`. We choose `NaN`, as the value is indeterminate; i.e., we cannot determine whether `y` is odd, even, or somewhere in between.\n\t\treturn (x-x)/(x-x); // signal NaN\n\t}\n\tif ( x === 1.0 ) {\n\t\treturn 1.0;\n\t}\n\t// (|x| > 1 && y === NINF) || (|x| < 1 && y === PINF)\n\tif ( (abs(x) < 1.0) === (y === PINF) ) {\n\t\treturn 0.0;\n\t}\n\t// (|x| > 1 && y === PINF) || (|x| < 1 && y === NINF)\n\treturn PINF;\n}\n\n\n// EXPORTS //\n\nexport default pow;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isOdd from './../../../../base/assert/is-odd';\nimport copysign from './../../../../base/special/copysign';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport PINF from '@stdlib/constants/float64/pinf';\n\n\n// MAIN //\n\n/**\n* Evaluates the exponential function when \\\\(|x| = 0\\\\).\n*\n* @private\n* @param {number} x - base\n* @param {number} y - exponent\n* @returns {number} function value\n*\n* @example\n* var v = pow( 0.0, 2 );\n* // returns 0.0\n*\n* @example\n* var v = pow( -0.0, -9 );\n* // returns -Infinity\n*\n* @example\n* var v = pow( 0.0, -9 );\n* // returns Infinity\n*\n* @example\n* var v = pow( -0.0, 9 );\n* // returns 0.0\n*\n* @example\n* var v = pow( 0.0, -Infinity );\n* // returns Infinity\n*\n* @example\n* var v = pow( 0.0, Infinity );\n* // returns 0.0\n*/\nfunction pow( x, y ) {\n\tif ( y === NINF ) {\n\t\treturn PINF;\n\t}\n\tif ( y === PINF ) {\n\t\treturn 0.0;\n\t}\n\tif ( y > 0.0 ) {\n\t\tif ( isOdd( y ) ) {\n\t\t\treturn x; // handles +-0\n\t\t}\n\t\treturn 0.0;\n\t}\n\t// y < 0.0\n\tif ( isOdd( y ) ) {\n\t\treturn copysign( PINF, x ); // handles +-0\n\t}\n\treturn PINF;\n}\n\n\n// EXPORTS //\n\nexport default pow;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* This is a generated file. Do not edit directly. */\n'use strict';\n\n// MAIN //\n\n/**\n* Evaluates a polynomial.\n*\n* ## Notes\n*\n* - The implementation uses [Horner's rule][horners-method] for efficient computation.\n*\n* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method\n*\n* @private\n* @param {number} x - value at which to evaluate the polynomial\n* @returns {number} evaluated polynomial\n*/\nfunction evalpoly( x ) {\n\tif ( x === 0.0 ) {\n\t\treturn 0.5;\n\t}\n\treturn 0.5 + (x * (-0.3333333333333333 + (x * 0.25)));\n}\n\n\n// EXPORTS //\n\nexport default evalpoly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* This is a generated file. Do not edit directly. */\n'use strict';\n\n// MAIN //\n\n/**\n* Evaluates a polynomial.\n*\n* ## Notes\n*\n* - The implementation uses [Horner's rule][horners-method] for efficient computation.\n*\n* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method\n*\n* @private\n* @param {number} x - value at which to evaluate the polynomial\n* @returns {number} evaluated polynomial\n*/\nfunction evalpoly( x ) {\n\tif ( x === 0.0 ) {\n\t\treturn 0.5999999999999946;\n\t}\n\treturn 0.5999999999999946 + (x * (0.4285714285785502 + (x * (0.33333332981837743 + (x * (0.272728123808534 + (x * (0.23066074577556175 + (x * 0.20697501780033842))))))))); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default evalpoly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* This is a generated file. Do not edit directly. */\n'use strict';\n\n// MAIN //\n\n/**\n* Evaluates a polynomial.\n*\n* ## Notes\n*\n* - The implementation uses [Horner's rule][horners-method] for efficient computation.\n*\n* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method\n*\n* @private\n* @param {number} x - value at which to evaluate the polynomial\n* @returns {number} evaluated polynomial\n*/\nfunction evalpoly( x ) {\n\tif ( x === 0.0 ) {\n\t\treturn 0.16666666666666602;\n\t}\n\treturn 0.16666666666666602 + (x * (-0.0027777777777015593 + (x * (0.00006613756321437934 + (x * (-0.0000016533902205465252 + (x * 4.1381367970572385e-8))))))); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default evalpoly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport pow from '@stdlib/math/base/special/pow';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian power.\n*\n* ## Notes\n*\n* - The Cartesian power is an n-fold Cartesian product involving a single array. The main insight of this implementation is that the n-fold Cartesian product can be represented as an n-dimensional array stored in row-major order. As such, we can\n*\n* - Compute the total number of tuples, which is simply the size of the provided array (set) raised to the specified power `n`. For n-dimensional arrays, this is the equivalent of computing the product of array dimensions to determine the total number of elements.\n* - Initialize an array for storing indices for indexing into the provided array. For n-dimensional arrays, the index array is equivalent to an array of subscripts for indexing into each dimension.\n* - For the outermost loop, treat the loop index as a linear index into an n-dimensional array and resolve the corresponding subscripts.\n* - Continue iterating until all tuples have been generated.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} n - power\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = cartesianPower( x, 2 );\n* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]\n*/\nfunction cartesianPower( x, n ) {\n\tvar get;\n\tvar out;\n\tvar tmp;\n\tvar idx;\n\tvar len;\n\tvar N;\n\tvar s;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = x.length;\n\tif ( N <= 0 || n <= 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve an array element accessor:\n\tget = resolveGetter( x );\n\n\t// Compute the total number of ordered tuples:\n\tlen = pow( N, n );\n\n\t// Initialize a list of indices for indexing into the array (equivalent to ndarray subscripts):\n\tidx = [];\n\tfor ( i = 0; i < n; i++ ) {\n\t\tidx.push( 0 );\n\t}\n\t// Compute the n-fold Cartesian product...\n\tout = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\t// Resolve a linear index to array indices (logic is equivalent to what is found in ndarray/base/ind2sub for an ndarray stored in row-major order; see https://github.com/stdlib-js/stdlib/blob/215ca5355f3404f15996fd0ced58a98e46f22be6/lib/node_modules/%40stdlib/ndarray/base/ind2sub/lib/assign.js)...\n\t\tk = i;\n\t\tfor ( j = n-1; j >= 0; j-- ) {\n\t\t\ts = k % N;\n\t\t\tk -= s;\n\t\t\tk /= N;\n\t\t\tidx[ j ] = s;\n\t\t}\n\t\t// Generate the next ordered tuple...\n\t\ttmp = [];\n\t\tfor ( j = 0; j < n; j++ ) {\n\t\t\ttmp.push( get( x, idx[ j ] ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default cartesianPower;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian product.\n*\n* @param {Collection} x1 - first input array\n* @param {Collection} x2 - second input array\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x1 = [ 1, 2, 3 ];\n* var x2 = [ 4, 5 ];\n*\n* var out = cartesianProduct( x1, x2 );\n* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ]\n*/\nfunction cartesianProduct( x1, x2 ) {\n\tvar get1;\n\tvar get2;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tget1 = resolveGetter( x1 );\n\tget2 = resolveGetter( x2 );\n\n\tM = x1.length;\n\tN = x2.length;\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv = get1( x1, i );\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tout.push( [ v, get2( x2, j ) ] );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default cartesianProduct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian square.\n*\n* @param {Collection} x - input array\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = cartesianSquare( x );\n* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]\n*/\nfunction cartesianSquare( x ) {\n\tvar get;\n\tvar out;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tget = resolveGetter( x );\n\tN = x.length;\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv = get( x, i );\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tout.push( [ v, get( x, j ) ] );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default cartesianSquare;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Copies the elements of an array-like object to a new \"generic\" array.\n*\n* @param {Collection} x - input array\n* @returns {Array} output array\n*\n* @example\n* var out = copy( [ 1, 2, 3 ] );\n* // returns [ 1, 2, 3 ]\n*/\nfunction copy( x ) {\n\tvar out;\n\tvar len;\n\tvar get;\n\tvar i;\n\n\t// Resolve an accessor for retrieving input array elements:\n\tget = resolveGetter( x );\n\n\t// Get the number of elements to copy:\n\tlen = x.length;\n\n\t// Loop over the elements...\n\tout = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tout.push( get( x, i ) ); // ensure \"fast\" elements\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default copy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = 16; // 8 bytes per float64 x (1 real + 1 imag component)\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `Complex128Array`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Complex128Array`\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isComplex128Array( new Complex128Array( 10 ) );\n* // returns true\n*\n* bool = isComplex128Array( [] );\n* // returns false\n*/\nfunction isComplex128Array( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex128Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex128array`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Complex128Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex128Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = 8; // 4 bytes per float32 x (1 real + 1 imag component)\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `Complex64Array`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Complex64Array`\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n*\n* var bool = isComplex64Array( new Complex64Array( 10 ) );\n* // returns true\n*\n* bool = isComplex64Array( [] );\n* // returns false\n*/\nfunction isComplex64Array( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex64Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex64array`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Complex64Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from '@stdlib/array/base/assert/is-complex128array';\nimport isComplex64Array from '@stdlib/array/base/assert/is-complex64array';\nimport reinterpret128 from './../../../base/reinterpret-complex128';\nimport reinterpret64 from './../../../base/reinterpret-complex64';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Reinterprets a complex-valued floating-point array as a real-valued floating-point array having the same precision.\n*\n* @param {(Complex128Array|Complex64Array)} x - input array\n* @param {NonNegativeInteger} offset - starting index\n* @throws {TypeError} first argument must be a supported complex-valued floating-point array\n* @returns {(Float64Array|Float32Array)} real-valued floating-point array view\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var x = new Complex128Array( 10 );\n*\n* var out = reinterpret( x, 0 );\n* // returns \n*\n* var bool = ( out.buffer === x.buffer );\n* // returns true\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n*\n* var x = new Complex64Array( 10 );\n*\n* var out = reinterpret( x, 0 );\n* // returns \n*\n* var bool = ( out.buffer === x.buffer );\n* // returns true\n*/\nfunction reinterpret( x, offset ) {\n\tif ( isComplex128Array( x ) ) {\n\t\treturn reinterpret128( x, offset );\n\t}\n\tif ( isComplex64Array( x ) ) {\n\t\treturn reinterpret64( x, offset );\n\t}\n\t// Note: intentionally throw here to catch the scenario in which we add, e.g., a Complex32Array and need to explicitly add support here...\n\tthrow new TypeError( format( 'invalid argument. First argument must be a complex-valued floating-point array. Value: `%s`.', x ) );\n}\n\n\n// EXPORTS //\n\nexport default reinterpret;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport reinterpretComplex from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of falsy values in an indexed array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of falsy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x );\n* // returns 2\n*/\nfunction indexed( x ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !x[ i ] ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of falsy values in an accessor array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of falsy values\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x );\n* // returns 2\n*/\nfunction accessors( x ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !get( x, i ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of falsy values in a complex array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of falsy values\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 5.0, 6.0 ] );\n*\n* var n = complex( x );\n* // returns 2\n*/\nfunction complex( x ) {\n\tvar view;\n\tvar n;\n\tvar i;\n\n\tview = reinterpretComplex( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( view[ i ] === 0.0 && view[ i+1 ] === 0.0 ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of falsy values in an array.\n*\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of falsy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countFalsy( x );\n* // returns 2\n*/\nfunction countFalsy( x ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn indexed( reinterpretBoolean( x, 0 ) );\n\t\t}\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x );\n\t\t}\n\t\treturn accessors( x );\n\t}\n\treturn indexed( x );\n}\n\n\n// EXPORTS //\n\nexport default countFalsy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero.\n*\n* @param {number} n - number of elements\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = zeroTo( 6 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*/\nfunction zeroTo( n ) {\n\tvar arr;\n\tvar i;\n\n\tarr = [];\n\tif ( n <= 0 ) {\n\t\treturn arr;\n\t}\n\tfor ( i = 0; i < n; i++ ) {\n\t\tarr.push( i );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default zeroTo;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n\n\n// FUNCTIONS //\n\n/**\n* Fills an indexed array with linearly spaced numeric elements which increment by 1 starting from zero.\n*\n* @private\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = indexed( out, 1, 0 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = indexed( out, -1, out.length-1 );\n* // returns [ 5, 4, 3, 2, 1, 0 ]\n*/\nfunction indexed( out, stride, offset ) {\n\tvar v;\n\tvar i;\n\n\ti = offset;\n\tv = 0;\n\twhile ( i >= 0 && i < out.length ) {\n\t\tout[ i ] = v;\n\t\ti += stride;\n\t\tv += 1;\n\t}\n\treturn out;\n}\n\n/**\n* Fills a complex number array with linearly spaced numeric elements which increment by 1 starting from zero.\n*\n* @private\n* @param {(Complex128Array|Complex64Array)} out - output complex number array\n* @param {(Float64Array|Float32Array)} data - output array data\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {(Complex128Array|Complex64Array)} output array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\n*\n* var out = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );\n* // returns \n*\n* var data = reinterpret128( out, 0 );\n* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]\n*\n* var arr = complex( out, data, 1, 0 );\n* // returns \n*\n* var bool = ( arr === out );\n* // returns true\n*\n* data = reinterpret128( out, 0 );\n* returns [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ]\n*/\nfunction complex( out, data, stride, offset ) {\n\tvar v;\n\tvar s;\n\tvar i;\n\n\ts = stride * 2;\n\ti = offset * 2;\n\tv = 0.0;\n\twhile ( i >= 0 && i < data.length ) {\n\t\tdata[ i ] = v; // real component\n\t\tdata[ i+1 ] = 0.0; // imaginary component\n\t\ti += s;\n\t\tv += 1.0;\n\t}\n\treturn out;\n}\n\n/**\n* Fills an accessor array with linearly spaced numeric elements which increment by 1 starting from zero.\n*\n* @private\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n\n* var out = toAccessorArray( [ 0, 0, 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( out ), 1, 0 );\n*\n* var bool = ( arr === out );\n* // returns true\n*\n* var v = out.get( 0 );\n* // returns 0\n*\n* v = out.get( out.length-1 );\n* // returns 5\n*/\nfunction accessors( out, stride, offset ) {\n\tvar data;\n\tvar set;\n\tvar v;\n\tvar i;\n\n\tdata = out.data;\n\tset = out.accessors[ 1 ];\n\n\ti = offset;\n\tv = 0;\n\twhile ( i >= 0 && i < data.length ) {\n\t\tset( data, i, v );\n\t\ti += stride;\n\t\tv += 1;\n\t}\n\treturn data;\n}\n\n\n// MAIN //\n\n/**\n* Fills an array with linearly spaced numeric elements which increment by 1 starting from zero.\n*\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = assign( out, 1, 0 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = assign( out, -1, out.length-1 );\n* // returns [ 5, 4, 3, 2, 1, 0 ]\n*/\nfunction assign( out, stride, offset ) {\n\tvar obj = arraylike2object( out );\n\tif ( obj.accessorProtocol ) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and only set the real components...\n\t\tif ( obj.dtype === 'complex128' ) {\n\t\t\treturn complex( out, reinterpret128( out, 0 ), stride, offset );\n\t\t}\n\t\tif ( obj.dtype === 'complex64' ) {\n\t\t\treturn complex( out, reinterpret64( out, 0 ), stride, offset );\n\t\t}\n\t\treturn accessors( obj, stride, offset );\n\t}\n\treturn indexed( out, stride, offset );\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\nimport zeroTo from './../../../base/zero-to';\n\n\n// FUNCTIONS //\n\n/**\n* Returns an array of indices corresponding to the elements of an input array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Array} idx - list of indices\n* @param {Function} predicate - predicate function\n* @returns {Array} updated list of indices\n*\n* @example\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import zeroTo from '@stdlib/array/base/zero-to';\n*\n* function predicate( v ) {\n* return ( v > 0 );\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ -1, 2, 3, -4, 5 ] ) );\n* var idx = zeroTo( 5 );\n*\n* var out = accessors( x, idx, predicate );\n* // returns [ 1, 2, 4 ]\n*/\nfunction accessors( x, idx, predicate ) {\n\tvar buf;\n\tvar get;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tbuf = x.data;\n\tget = x.accessors[ 0 ];\n\n\tk = 0;\n\tfor ( i = 0; i < idx.length; i++ ) {\n\t\tj = idx[ i ];\n\t\tif ( predicate( get( buf, j ), j, buf ) ) {\n\t\t\tidx[ k ] = j;\n\t\t\tk += 1;\n\t\t}\n\t}\n\tidx.length = k;\n\treturn idx;\n}\n\n/**\n* Returns an array of indices corresponding to the elements of an input array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Array} idx - list of indices\n* @param {Function} predicate - predicate function\n* @returns {Array} updated list of indices\n*\n* @example\n* import zeroTo from '@stdlib/array/base/zero-to';\n*\n* function predicate( v ) {\n* return ( v > 0 );\n* }\n*\n* var x = [ -1, 2, 3, -4, 5 ];\n* var idx = zeroTo( 5 );\n*\n* var out = indexed( x, idx, predicate );\n* // returns [ 1, 2, 4 ]\n*/\nfunction indexed( x, idx, predicate ) {\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tk = 0;\n\tfor ( i = 0; i < idx.length; i++ ) {\n\t\tj = idx[ i ];\n\t\tif ( predicate( x[ j ], j, x ) ) {\n\t\t\tidx[ k ] = j;\n\t\t\tk += 1;\n\t\t}\n\t}\n\tidx.length = k;\n\treturn idx;\n}\n\n\n// MAIN //\n\n/**\n* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`.\n*\n* @param {Collection} x0 - first input array\n* @param {Function} predicate0 - first predicate function\n* @param {Collection} [x1] - second input array\n* @param {Function} [predicate1] - second predicate function\n* @param {Collection} [x2] - third input array\n* @param {Function} [predicate2] - third predicate function\n* @param {...(Collection|Function)} [args] - additional input arrays and predicate functions\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate0( value ) {\n* return ( value > 0 );\n* }\n*\n* function predicate1( value ) {\n* return ( value < 3 );\n* }\n*\n* var x0 = [ 0, 1, 0, 1, 2 ];\n* var x1 = [ 2, 3, 1, 2, 5 ];\n*\n* var n = countIfs( x0, predicate0, x1, predicate1 );\n* // returns 1\n*/\nfunction countIfs() {\n\tvar predicates;\n\tvar arrays;\n\tvar len;\n\tvar idx;\n\tvar x;\n\tvar i;\n\n\tarrays = [];\n\tpredicates = [];\n\tfor ( i = 0; i < arguments.length; i += 2 ) {\n\t\tarrays.push( arraylike2object( arguments[ i ] ) );\n\t\tpredicates.push( arguments[ i+1 ] );\n\t}\n\n\tlen = arguments[ 0 ].length;\n\tidx = zeroTo( len );\n\tfor ( i = 0; i < arrays.length; i++ ) {\n\t\tx = arrays[ i ];\n\t\tif ( x.accessorProtocol ) {\n\t\t\tidx = accessors( x, idx, predicates[ i ] );\n\t\t} else {\n\t\t\tidx = indexed( x.data, idx, predicates[ i ] );\n\t\t}\n\t}\n\treturn idx.length;\n}\n\n\n// EXPORTS //\n\nexport default countIfs;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if two double-precision floating-point numbers are the same value.\n*\n* ## Notes\n*\n* - The function implements the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016.\n* - In contrast to the strict equality operator `===`, `NaNs` are considered the same value.\n*\n* @param {number} a - first input value\n* @param {number} b - second input value\n* @returns {boolean} boolean indicating whether two double-precision floating-point numbers are the same value\n*\n* @example\n* var bool = isSameValueZero( 3.14, 3.14 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( -0.0, -0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( -0.0, 0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( NaN, NaN );\n* // returns true\n*/\nfunction isSameValueZero( a, b ) {\n\treturn ( a === b ) || ( a !== a && b !== b ); // handles NaNs\n}\n\n\n// EXPORTS //\n\nexport default isSameValueZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isSameComplexValueZero from '@stdlib/complex/float64/base/assert/is-same-value-zero';\nimport isComplexLike from './../../is-complex-like';\n\n\n// MAIN //\n\n/**\n* Tests if two arguments are the same value.\n*\n* ## Notes\n*\n* - The function implements the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016, and includes support for complex number objects.\n* - In contrast to the strict equality operator `===`, `NaNs` are considered the same value.\n*\n* @param {*} a - first input value\n* @param {*} b - second input value\n* @returns {boolean} boolean indicating whether two arguments are the same value\n*\n* @example\n* var bool = isSameValueZero( true, true );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( 3.14, 3.14 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( {}, {} );\n* // returns false\n*\n* @example\n* var bool = isSameValueZero( -0.0, -0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( -0.0, 0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( NaN, NaN );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( [], [] );\n* // returns false\n*/\nfunction isSameValueZero( a, b ) {\n\tif ( ( a === b ) || ( a !== a && b !== b ) ) { // handles NaNs\n\t\treturn true;\n\t}\n\tif ( isComplexLike( a ) && isComplexLike( b ) ) {\n\t\treturn isSameComplexValueZero( a, b );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isSameValueZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isSame from '@stdlib/number/float64/base/assert/is-same-value-zero';\nimport reim from './../../../../../float64/reim';\n\n\n// MAIN //\n\n/**\n* Tests whether two double-precision complex floating-point numbers are the same value.\n*\n* ## Notes\n*\n* - The function implements the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016.\n* - In contrast to the strict equality operator `===`, `NaNs` are considered the same value.\n*\n* @param {Complex128} z1 - first complex number\n* @param {Complex128} z2 - second complex number\n* @returns {boolean} result\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z1 = new Complex128( 5.0, 3.0 );\n* var z2 = new Complex128( 5.0, 3.0 );\n*\n* var v = isSameValueZero( z1, z2 );\n* // returns true\n*/\nfunction isSameValueZero( z1, z2 ) {\n\tvar parts1 = reim( z1 );\n\tvar parts2 = reim( z2 );\n\treturn (\n\t\tisSame( parts1[ 0 ], parts2[ 0 ] ) &&\n\t\tisSame( parts1[ 1 ], parts2[ 1 ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isSameValueZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport reinterpretComplex from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of truthy values in an indexed array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* var x = [ 0, 1, 0, 1 ];\n*\n* var n = indexed( x );\n* // returns 2\n*/\nfunction indexed( x ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( x[ i ] ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of truthy values in an accessor array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1 ] );\n*\n* var n = accessors( x );\n* // returns 2\n*/\nfunction accessors( x ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( get( x, i ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of truthy values in a complex array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var n = complex( x );\n* // returns 2\n*/\nfunction complex( x ) {\n\tvar view;\n\tvar n;\n\tvar i;\n\n\tview = reinterpretComplex( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( view[ i ] || view[ i+1 ] ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of truthy values in an array.\n*\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countTruthy( x );\n* // returns 3\n*/\nfunction countTruthy( x ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn indexed( reinterpretBoolean( x, 0 ) );\n\t\t}\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x );\n\t\t}\n\t\treturn accessors( x );\n\t}\n\treturn indexed( x );\n}\n\n\n// EXPORTS //\n\nexport default countTruthy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Cumulatively tests whether at least one element in an indexed array is truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ false, false, true, false, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = indexed( x, y, 2, 0 );\n* // returns [ false, null, false, null, true, null, true, null, true, null ]\n*/\nfunction indexed( x, y, stride, offset ) {\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tflg = false;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === false && x[ i ] ) {\n\t\t\tflg = true;\n\t\t}\n\t\ty[ io ] = flg;\n\t\tio += stride;\n\t}\n\treturn y;\n}\n\n/**\n* Cumulatively tests whether at least one element in a provided accessor array is truthy.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ false, false, true, false, false ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );\n*\n* var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns false\n*\n* v = y.get( 2 );\n* // returns false\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns true\n*\n* v = y.get( 8 );\n* // returns true\n*/\nfunction accessors( x, y, stride, offset ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyset = y.accessors[ 1 ];\n\n\tflg = false;\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( flg === false && xget( xdata, i ) ) {\n\t\t\tflg = true;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether at least one element in a provided complex number array is truthy.\n*\n* @private\n* @param {Collection} x - array containing interleaved real and imaginary components\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );\n*\n* var arr = complex( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns false\n*\n* v = y.get( 2 );\n* // returns false\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns true\n*\n* v = y.get( 8 );\n* // returns true\n*/\nfunction complex( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = false;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( flg === false && ( x[ i ] || x[ i+1 ] ) ) {\n\t\t\tflg = true;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether at least one element in a provided boolean array is truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 0, 0, 1, 1, 0 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );\n*\n* var arr = boolean( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns false\n*\n* v = y.get( 2 );\n* // returns false\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns true\n*\n* v = y.get( 8 );\n* // returns true\n*/\nfunction boolean( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = false;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === false && x[ i ] ) {\n\t\t\tflg = true;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether at least one element in an array is truthy and assigns results to a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ false, false, true, false, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = assign( x, y, 2, 0 );\n* // returns [ false, null, false, null, true, null, true, null, true, null ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\nfunction assign( x, y, stride, offset ) {\n\tvar xo = arraylike2object( x );\n\tvar yo = arraylike2object( y );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tyo.accessorProtocol\n\t) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\tcomplex( reinterpret128( x, 0 ), yo, stride, offset );\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\tcomplex( reinterpret64( x, 0 ), yo, stride, offset );\n\t\t} else if ( isBooleanArray( x ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), yo, stride, offset );\n\t\t} else {\n\t\t\taccessors( xo, yo, stride, offset );\n\t\t}\n\t\treturn y;\n\t}\n\tindexed( x, y, stride, offset );\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether at least one element in a provided array is truthy.\n*\n* @param {Collection} x - input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ false, false, true, false, false ];\n*\n* var y = cuany( x );\n* // returns [ false, false, true, true, true ]\n*/\nfunction cuany( x ) {\n\tvar y = filled( false, x.length );\n\treturn assign( x, y, 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default cuany;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Cumulatively tests whether every element in an indexed array is truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ true, true, true, false, true ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = indexed( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*/\nfunction indexed( x, y, stride, offset ) {\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === true && !x[ i ] ) {\n\t\t\tflg = false;\n\t\t}\n\t\ty[ io ] = flg;\n\t\tio += stride;\n\t}\n\treturn y;\n}\n\n/**\n* Cumulatively tests whether every element in a provided accessor array is truthy.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ true, true, true, false, true ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );\n*\n* var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction accessors( x, y, stride, offset ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyset = y.accessors[ 1 ];\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( flg === true && !xget( xdata, i ) ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether every element in a provided complex number array is truthy.\n*\n* @private\n* @param {Collection} x - array containing interleaved real and imaginary components\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] );\n*\n* var arr = complex( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction complex( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( flg === true && !( x[ i ] || x[ i+1 ] ) ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether every element in a provided boolean array is truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 1, 1, 0, 1 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] );\n*\n* var arr = boolean( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction boolean( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === true && !x[ i ] ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether every element in an array is truthy and assigns results to a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ true, true, true, false, true ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = assign( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\nfunction assign( x, y, stride, offset ) {\n\tvar xo = arraylike2object( x );\n\tvar yo = arraylike2object( y );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tyo.accessorProtocol\n\t) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\tcomplex( reinterpret128( x, 0 ), yo, stride, offset );\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\tcomplex( reinterpret64( x, 0 ), yo, stride, offset );\n\t\t} else if ( isBooleanArray( x ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), yo, stride, offset );\n\t\t} else {\n\t\t\taccessors( xo, yo, stride, offset );\n\t\t}\n\t\treturn y;\n\t}\n\tindexed( x, y, stride, offset );\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether every element in a provided array is truthy.\n*\n* @param {Collection} x - input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ true, true, true, false, true ];\n*\n* var y = cuevery( x );\n* // returns [ true, true, true, false, false ];\n*/\nfunction cuevery( x ) {\n\tvar y = filled( true, x.length );\n\treturn assign( x, y, 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default cuevery;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Cumulatively tests whether every element in an indexed array is falsy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ false, false, false, true, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = indexed( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*/\nfunction indexed( x, y, stride, offset ) {\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === true && x[ i ] ) {\n\t\t\tflg = false;\n\t\t}\n\t\ty[ io ] = flg;\n\t\tio += stride;\n\t}\n\treturn y;\n}\n\n/**\n* Cumulatively tests whether every element in a provided accessor array is falsy.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ false, false, false, true, false ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );\n*\n* var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction accessors( x, y, stride, offset ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyset = y.accessors[ 1 ];\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( flg === true && xget( xdata, i ) ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether every element in a provided complex number array is falsy.\n*\n* @private\n* @param {Collection} x - array containing interleaved real and imaginary components\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] );\n*\n* var arr = complex( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction complex( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( flg === true && ( x[ i ] || x[ i+1 ] ) ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether every element in a provided boolean array is falsy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 0, 0, 0, 1, 0 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] );\n*\n* var arr = boolean( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction boolean( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === true && x[ i ] ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether every element in an array is falsy and assigns results to a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ false, false, false, true, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = assign( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\nfunction assign( x, y, stride, offset ) {\n\tvar xo = arraylike2object( x );\n\tvar yo = arraylike2object( y );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tyo.accessorProtocol\n\t) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\tcomplex( reinterpret128( x, 0 ), yo, stride, offset );\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\tcomplex( reinterpret64( x, 0 ), yo, stride, offset );\n\t\t} else if ( isBooleanArray( x ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), yo, stride, offset );\n\t\t} else {\n\t\t\taccessors( xo, yo, stride, offset );\n\t\t}\n\t\treturn y;\n\t}\n\tindexed( x, y, stride, offset );\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether every element in a provided array is falsy.\n*\n* @param {Collection} x - input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ false, false, false, true, false ];\n*\n* var y = cunone( x );\n* // returns [ true, true, true, false, false ]\n*/\nfunction cunone( x ) {\n\tvar y = filled( true, x.length );\n\treturn assign( x, y, 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default cunone;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a read-write accessor.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Function} getter - get accessor\n* @param {Function} setter - set accessor\n*\n* @example\n* function getter() {\n* return name + ' foo';\n* }\n*\n* function setter( v ) {\n* name = v;\n* }\n*\n* var name = 'bar';\n* var obj = {};\n*\n* setReadWriteAccessor( obj, 'foo', getter, setter );\n*\n* var v = obj.foo;\n* // returns 'bar foo'\n*\n* obj.foo = 'beep';\n*\n* v = obj.foo;\n* // returns 'beep foo'\n*/\nfunction setReadWriteAccessor( obj, prop, getter, setter ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'get': getter,\n\t\t'set': setter\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setReadWriteAccessor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether all elements in an array are truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether all elements are truthy\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internal( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 4 ];\n*\n* var out = internal( x );\n* // returns false\n*/\nfunction internal( x ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !x[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in a complex number array are truthy.\n*\n* @private\n* @param {Collection} x - underlying data buffer\n* @returns {boolean} boolean indicating whether all elements are truthy\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internalComplex( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 4 ];\n*\n* var out = internalComplex( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 0 ];\n*\n* var out = internalComplex( x );\n* // returns false\n*/\nfunction internalComplex( x ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( !( x[ i ] || x[ i+1 ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array are truthy.\n*\n* @private\n* @param {Object} x - input array object\n* @returns {boolean} boolean indicating whether all elements are truthy\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) );\n*\n* var out = accessors( x );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 0, 4 ] ) );\n*\n* var out = accessors( x );\n* // returns false\n*/\nfunction accessors( x ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( !get( data, i ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array are truthy.\n*\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether all elements are truthy\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = every( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 4 ];\n*\n* var out = every( x );\n* // returns false\n*/\nfunction every( x ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\treturn internalComplex( reinterpret128( x, 0 ) );\n\t\t}\n\t\tif ( isComplex64Array( x ) ) {\n\t\t\treturn internalComplex( reinterpret64( x, 0 ) );\n\t\t}\n\t\t// If provided a boolean array, reinterpret as a typed array and test each element...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn internal( reinterpretBoolean( x, 0 ) );\n\t\t}\n\t\treturn accessors( obj );\n\t}\n\treturn internal( x );\n}\n\n\n// EXPORTS //\n\nexport default every;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isNull from '@stdlib/assert/is-null';\nimport isUndefined from '@stdlib/assert/is-undefined';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an input argument is valid.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether the argument is valid\n*\n* @example\n* var bool = isValid( 3 );\n* // returns true\n*\n* bool = isValid( null );\n* // returns true\n*\n* bool = isValid( void 0 );\n* // returns true\n*\n* bool = isValid( '3' );\n* // returns false\n*/\nfunction isValid( value ) {\n\treturn ( isInteger( value ) || isNull( value ) || isUndefined( value ) );\n}\n\n\n// MAIN //\n\n/**\n* Slice constructor.\n*\n* @constructor\n* @param {(integer|null|void)} [start] - starting index (inclusive)\n* @param {(integer|null|void)} stop - ending index (exclusive)\n* @param {(integer|null|void)} [step] - index increment\n* @throws {TypeError} first argument must be an integer, null, or undefined\n* @throws {TypeError} second argument must be an integer, null, or undefined\n* @throws {TypeError} third argument must be an integer, null, or undefined\n* @throws {RangeError} third argument cannot be zero\n* @returns {Slice} Slice instance\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var start = s.start;\n* // returns null\n*\n* var stop = s.stop;\n* // returns 10\n*\n* var step = s.step;\n* // returns null\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var start = s.start;\n* // returns 3\n*\n* var stop = s.stop;\n* // returns 10\n*\n* var step = s.step;\n* // returns null\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var start = s.start;\n* // returns 3\n*\n* var stop = s.stop;\n* // returns 10\n*\n* var step = s.step;\n* // returns 2\n*/\nfunction Slice() {\n\tvar nargs;\n\tvar start;\n\tvar stop;\n\tvar step;\n\n\tnargs = arguments.length;\n\tif ( nargs === 0 ) {\n\t\tstart = null;\n\t\tstop = null;\n\t\tstep = null;\n\t} else if ( nargs === 1 ) {\n\t\tstart = null;\n\t\tstop = arguments[ 0 ];\n\t\tstep = null;\n\t} else if ( nargs === 2 ) {\n\t\tstart = arguments[ 0 ];\n\t\tstop = arguments[ 1 ];\n\t\tstep = null;\n\t} else {\n\t\tstart = arguments[ 0 ];\n\t\tstop = arguments[ 1 ];\n\t\tstep = arguments[ 2 ];\n\t}\n\tif ( !( this instanceof Slice ) ) {\n\t\treturn new Slice( start, stop, step );\n\t}\n\tif ( !isValid( start ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer, null, or undefined. Value: `%s`.', start ) );\n\t}\n\tif ( !isValid( stop ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer, null, or undefined. Value: `%s`.', stop ) );\n\t}\n\tif ( !isValid( step ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer, null, or undefined. Value: `%s`.', step ) );\n\t} else if ( step === 0 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Third argument cannot be zero. Value: `%s`.', step ) );\n\t}\n\tthis._start = ( start === void 0 ) ? null : start;\n\tthis._stop = ( stop === void 0 ) ? null : stop;\n\tthis._step = ( step === void 0 ) ? null : step;\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Slice\n* @readonly\n* @type {string}\n* @default 'Slice'\n*\n* @example\n* var str = Slice.name;\n* // returns 'Slice'\n*/\nsetReadOnly( Slice, 'name', 'Slice' );\n\n/**\n* Returns the slice's starting index.\n*\n* @name start\n* @memberof Slice.prototype\n* @readonly\n* @type {(integer|null)}\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var start = s.start;\n* // returns null\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var start = s.start;\n* // returns 3\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var start = s.start;\n* // returns 3\n*/\nsetReadOnlyAccessor( Slice.prototype, 'start', function get() {\n\treturn this._start;\n});\n\n/**\n* Returns the slice's ending index.\n*\n* @name stop\n* @memberof Slice.prototype\n* @readonly\n* @type {(integer|null)}\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var stop = s.stop;\n* // returns 10\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var stop = s.stop;\n* // returns 10\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var stop = s.stop;\n* // returns 10\n*/\nsetReadOnlyAccessor( Slice.prototype, 'stop', function get() {\n\treturn this._stop;\n});\n\n/**\n* Returns the slice's index increment.\n*\n* @name step\n* @memberof Slice.prototype\n* @readonly\n* @type {(integer|null)}\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var step = s.step;\n* // returns null\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var step = s.step;\n* // returns null\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var step = s.step;\n* // returns 2\n*/\nsetReadOnlyAccessor( Slice.prototype, 'step', function get() {\n\treturn this._step;\n});\n\n/**\n* Serializes a slice to a string.\n*\n* @name toString\n* @memberof Slice.prototype\n* @type {Function}\n* @returns {string} serialized Slice\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var str = s.toString();\n* // returns 'Slice(null,10,null)'\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var str = s.toString();\n* // returns 'Slice(3,10,null)'\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var str = s.toString();\n* // returns 'Slice(3,10,2)'\n*/\nsetReadOnly( Slice.prototype, 'toString', function toString() {\n\treturn 'Slice('+this._start+','+this._stop+','+this.step+')';\n});\n\n/**\n* Serializes a slice as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Slice` instance.\n*\n* @name toJSON\n* @memberof Slice.prototype\n* @type {Function}\n* @returns {Object} serialized Slice\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var o = s.toJSON();\n* // returns { 'type': 'Slice', 'data': [ null, 10, null ] }\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var o = s.toJSON();\n* // returns { 'type': 'Slice', 'data': [ 3, 10, null ] }\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var o = s.toJSON();\n* // returns { 'type': 'Slice', 'data': [ 3, 10, 2 ] }\n*/\nsetReadOnly( Slice.prototype, 'toJSON', function toJSON() {\n\treturn {\n\t\t'type': 'Slice',\n\t\t'data': [\n\t\t\tthis._start,\n\t\t\tthis._stop,\n\t\t\tthis._step\n\t\t]\n\t};\n});\n\n\n// EXPORTS //\n\nexport default Slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is `null`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is null\n*\n* @example\n* var bool = isNull( null );\n* // returns true\n*\n* bool = isNull( true );\n* // returns false\n*/\nfunction isNull( value ) {\n\treturn value === null;\n}\n\n\n// EXPORTS //\n\nexport default isNull;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is `undefined`.\n*\n* ## Notes\n*\n* - In older browsers, `undefined` is a global which can be overridden. `void`, however, is an operator which **cannot** be overridden. Consequently, better to use `void` to check for `undefined`. See [Stack Overflow][1].\n*\n* [1]: http://stackoverflow.com/a/19369078/2225624\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is undefined\n*\n* @example\n* var bool = isUndefined( undefined );\n* // returns true\n*\n* bool = isUndefined( null );\n* // returns false\n*/\nfunction isUndefined( value ) {\n\treturn value === void 0;\n}\n\n\n// EXPORTS //\n\nexport default isUndefined;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Slice from './../../../ctor';\nimport eOutOfBounds from './error_out_of_bounds.js';\n\n\n// MAIN //\n\n/**\n* Returns a normalized Slice object.\n*\n* @param {Slice} slice - input slice\n* @param {NonNegativeInteger} len - maximum number of elements allowed in a slice\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @returns {(Slice|ErrorObject)} slice object or an error object\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var s = normalizeSlice( new Slice(), 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var s = normalizeSlice( new Slice( null, 20, 2 ), 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 2\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var s = normalizeSlice( new Slice( -5, -1, 1 ), 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 5\n*\n* v = s.stop;\n* // returns 9\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var s = normalizeSlice( new Slice( -5, null, -1 ), 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 5\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*/\nfunction normalizeSlice( slice, len, strict ) {\n\tvar start;\n\tvar stop;\n\tvar step;\n\n\tstart = slice.start;\n\tstop = slice.stop;\n\tstep = slice.step;\n\n\t// If necessary, set the default increment...\n\tif ( step === null ) {\n\t\tstep = 1;\n\t}\n\n\t// Case: start is not specified\n\tif ( start === null ) {\n\t\t// If the step is positive, we default to the first index...\n\t\tif ( step > 0 ) {\n\t\t\tstart = 0;\n\t\t}\n\t\t// If the step is negative, we default to the last index (inclusive)...\n\t\telse {\n\t\t\tstart = len - 1;\n\t\t}\n\t}\n\t// Case: start is negative and should be resolved relative to the last index\n\telse if ( start < 0 ) {\n\t\tstart = len + start;\n\n\t\t// Check whether start still exceeds the index bounds...\n\t\tif ( start < 0 ) {\n\t\t\tif ( strict ) {\n\t\t\t\treturn eOutOfBounds();\n\t\t\t}\n\t\t\t// Clamp to the first index (inclusive):\n\t\t\tstart = 0;\n\t\t}\n\t}\n\t// Case: start exceeds index bounds\n\telse if ( start >= len ) {\n\t\tif ( strict ) {\n\t\t\treturn eOutOfBounds();\n\t\t}\n\t\t// If the increment is negative, clamp to the last index (inclusive)...\n\t\tif ( step < 0 ) {\n\t\t\tstart = len - 1;\n\t\t}\n\t\t// If the increment is positive, clamp to the \"index\" following the last index...\n\t\telse {\n\t\t\tstart = len;\n\t\t}\n\t}\n\n\t// Case: stop is not specified\n\tif ( stop === null ) {\n\t\t// If the step is positive, we default to just beyond the last index, as the stopping index is exclusive...\n\t\tif ( step > 0 ) {\n\t\t\tstop = len;\n\t\t}\n\t\t// If the step is negative, we default to a sentinel value indicating that one should iterate through the first index when decrementing...\n\t\telse {\n\t\t\tstop = null;\n\t\t}\n\t}\n\t// Case: stop is negative and should be resolved relative to the last index\n\telse if ( stop < 0 ) {\n\t\tstop = len + stop;\n\n\t\t// Check whether stop still exceeds the index bounds...\n\t\tif ( stop < 0 ) {\n\t\t\t// If the step is positive, we should clamp to the first index, as Slice(x,0,step) is an empty slice regardless of `x`...\n\t\t\tif ( step > 0 ) {\n\t\t\t\tif ( strict ) {\n\t\t\t\t\treturn eOutOfBounds();\n\t\t\t\t}\n\t\t\t\tstop = 0;\n\t\t\t}\n\t\t\t// If the step is negative, we default to just beyond the first index (using a sentinel value), as the stopping index is exclusive, thus indicating to iterate through the first index when decrementing...\n\t\t\telse {\n\t\t\t\tif ( strict && stop < -1 ) {\n\t\t\t\t\treturn eOutOfBounds();\n\t\t\t\t}\n\t\t\t\tstop = null;\n\t\t\t}\n\t\t}\n\t}\n\t// Case: stop exceeds index bounds\n\telse if ( stop > len ) {\n\t\tif ( strict ) {\n\t\t\treturn eOutOfBounds();\n\t\t}\n\t\t// Clamp to just beyond the last index, as the stopping index is exclusive:\n\t\tstop = len;\n\t}\n\n\t// Return a normalized slice:\n\treturn new Slice( start, stop, step );\n}\n\n\n// EXPORTS //\n\nexport default normalizeSlice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an error object for a slice which exceeds index bounds.\n*\n* @private\n* @returns {Object} error object\n*/\nfunction error() {\n\treturn {\n\t\t'code': 'ERR_SLICE_OUT_OF_BOUNDS'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default error;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Generate a linearly spaced numeric array whose elements increment by 1 starting from zero.\n*\n* @module @stdlib/array/base/zero-to\n*\n* @example\n* import zeroTo from '@stdlib/array/base/zero-to';\n*\n* var arr = zeroTo( 6 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*\n* @example\n* import zeroTo from '@stdlib/array/base/zero-to';\n*\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n* var arr = zeroTo.assign( out, 1, 0 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*\n* var bool = ( out === arr );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Cumulatively test whether at least one element in a provided array is truthy.\n*\n* @module @stdlib/array/base/cuany\n*\n* @example\n* import cuany from '@stdlib/array/base/cuany';\n*\n* var x = [ false, false, true, false, false ];\n*\n* var y = cuany( x );\n* // returns [ false, false, true, true, true ]\n*\n* @example\n* import cuany from '@stdlib/array/base/cuany';\n*\n* var x = [ false, false, true, false, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var arr = cuany.assign( x, y, 2, 0 );\n* // returns [ false, null, false, null, true, null, true, null, true, null ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Cumulatively test whether every element in a provided array is truthy.\n*\n* @module @stdlib/array/base/cuevery\n*\n* @example\n* import cuevery from '@stdlib/array/base/cuevery';\n*\n* var x = [ true, true, true, false, true ]\n*\n* var y = cuevery( x );\n* // returns [ true, true, true, false, false ]\n*\n* @example\n* import cuevery from '@stdlib/array/base/cuevery';\n*\n* var x = [ true, true, true, false, true ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var arr = cuevery.assign( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Cumulatively test whether every element in a provided array is falsy.\n*\n* @module @stdlib/array/base/cunone\n*\n* @example\n* import cunone from '@stdlib/array/base/cunone';\n*\n* var x = [ false, false, false, true, false ]\n*\n* var y = cunone( x );\n* // returns [ true, true, true, false, false ]\n*\n* @example\n* import cunone from '@stdlib/array/base/cunone';\n*\n* var x = [ false, false, false, true, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var arr = cunone.assign( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: implementation (?)\n\n/**\n* Rounds a double-precision floating-point number toward positive infinity.\n*\n* @param {number} x - input value\n* @returns {number} rounded value\n*\n* @example\n* var v = ceil( -4.2 );\n* // returns -4.0\n*\n* @example\n* var v = ceil( 9.99999 );\n* // returns 10.0\n*\n* @example\n* var v = ceil( 0.0 );\n* // returns 0.0\n*\n* @example\n* var v = ceil( NaN );\n* // returns NaN\n*/\nvar ceil = Math.ceil; // eslint-disable-line stdlib/no-builtin-math\n\n\n// EXPORTS //\n\nexport default ceil;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ceil from '@stdlib/math/base/special/ceil';\n\n\n// MAIN //\n\n/**\n* Returns the number of elements in a normalized slice.\n*\n* @param {Slice} slice - normalized Slice object\n* @returns {NonNegativeInteger} number of elements\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n* import normalizeSlice from '@stdlib/slice/base/normalize-slice';\n*\n* var s = new Slice( 2, null, 1 );\n* // returns \n*\n* var v = sliceLength( normalizeSlice( s, 10, false ) );\n* // returns 8\n*\n* v = sliceLength( normalizeSlice( s, 11, false ) );\n* // returns 9\n*\n* v = sliceLength( normalizeSlice( s, 5, false ) );\n* // returns 3\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n* import normalizeSlice from '@stdlib/slice/base/normalize-slice';\n*\n* var s = new Slice( 2, null, 2 );\n* // returns \n*\n* var v = sliceLength( normalizeSlice( s, 10, false ) );\n* // returns 4\n*\n* v = sliceLength( normalizeSlice( s, 11, false ) );\n* // returns 5\n*\n* v = sliceLength( normalizeSlice( s, 5, false ) );\n* // returns 2\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n* import normalizeSlice from '@stdlib/slice/base/normalize-slice';\n*\n* var s = new Slice( -1, null, -2 );\n*\n* var v = sliceLength( normalizeSlice( s, 10, false ) );\n* // returns 5\n*\n* v = sliceLength( normalizeSlice( s, 11, false ) );\n* // returns 6\n*\n* v = sliceLength( normalizeSlice( s, 5, false ) );\n* // returns 3\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n* import normalizeSlice from '@stdlib/slice/base/normalize-slice';\n*\n* var s = new Slice( 3, 5, -1 );\n*\n* var v = sliceLength( normalizeSlice( s, 10, false ) );\n* // returns 0\n*\n* v = sliceLength( normalizeSlice( s, 11, false ) );\n* // returns 0\n*\n* v = sliceLength( normalizeSlice( s, 5, false ) );\n* // returns 0\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n* import normalizeSlice from '@stdlib/slice/base/normalize-slice';\n*\n* var s = new Slice( 5, 3, 1 );\n*\n* var v = sliceLength( normalizeSlice( s, 10, false ) );\n* // returns 0\n*\n* v = sliceLength( normalizeSlice( s, 11, false ) );\n* // returns 0\n*\n* v = sliceLength( normalizeSlice( s, 5, false ) );\n* // returns 0\n*/\nfunction sliceLength( slice ) {\n\tvar inc;\n\tvar x1;\n\tvar x2;\n\n\tx1 = slice.start;\n\tx2 = slice.stop;\n\tinc = slice.step;\n\n\t// For a normalized slice, stop should only be `null` when the increment is negative...\n\tif ( x2 === null ) {\n\t\tx2 = -1; // set to -1 to ensure that the first element is included\n\t}\n\tif (\n\t\t// If the increment is positive, the slice is empty whenever the starting index is greater than or equal to the stopping index:\n\t\t( inc > 0 && x1 >= x2 ) ||\n\n\t\t// If the increment is negative, the slice is empty whenever the starting index is less than or equal to the stopping index:\n\t\t( inc < 0 && x1 <= x2 )\n\t) {\n\t\treturn 0;\n\t}\n\treturn ceil( ( x2 - x1 ) / inc );\n}\n\n\n// EXPORTS //\n\nexport default sliceLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar TYPE = 'function';\n\n\n// MAIN //\n\n/**\n* Tests if an array-like object supports the accessor (get/set) protocol.\n*\n* @param {Object} value - value to test\n* @returns {boolean} boolean indicating whether a value is an accessor array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isAccessorArray( new Complex128Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isAccessorArray( [] );\n* // returns false\n*/\nfunction isAccessorArray( value ) {\n\treturn ( typeof value.get === TYPE && typeof value.set === TYPE ); // eslint-disable-line valid-typeof\n}\n\n\n// EXPORTS //\n\nexport default isAccessorArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar GETTERS = {\n\t'float64': getFloat64,\n\t'float32': getFloat32,\n\t'int32': getInt32,\n\t'int16': getInt16,\n\t'int8': getInt8,\n\t'uint32': getUint32,\n\t'uint16': getUint16,\n\t'uint8': getUint8,\n\t'uint8c': getUint8c,\n\t'generic': getGeneric,\n\t'default': getArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an element from a `Float64Array`.\n*\n* @private\n* @param {Float64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getFloat64( arr, 2 );\n* // returns 3.0\n*/\nfunction getFloat64( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Float32Array`.\n*\n* @private\n* @param {Float32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Float32Array from '@stdlib/array/float32';\n*\n* var arr = new Float32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getFloat32( arr, 2 );\n* // returns 3.0\n*/\nfunction getFloat32( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int32Array`.\n*\n* @private\n* @param {Int32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var arr = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt32( arr, 2 );\n* // returns 3\n*/\nfunction getInt32( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int16Array`.\n*\n* @private\n* @param {Int16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int16Array from '@stdlib/array/int16';\n*\n* var arr = new Int16Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt16( arr, 2 );\n* // returns 3\n*/\nfunction getInt16( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int8Array`.\n*\n* @private\n* @param {Int8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var arr = new Int8Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt8( arr, 2 );\n* // returns 3\n*/\nfunction getInt8( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint32Array`.\n*\n* @private\n* @param {Uint32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var arr = new Uint32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint32( arr, 2 );\n* // returns 3\n*/\nfunction getUint32( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint16Array`.\n*\n* @private\n* @param {Uint16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint16Array from '@stdlib/array/uint16';\n*\n* var arr = new Uint16Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint16( arr, 2 );\n* // returns 3\n*/\nfunction getUint16( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint8Array`.\n*\n* @private\n* @param {Uint8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var arr = new Uint8Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint8( arr, 2 );\n* // returns 3\n*/\nfunction getUint8( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint8ClampedArray`.\n*\n* @private\n* @param {Uint8ClampedArray} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint8ClampedArray from '@stdlib/array/uint8c';\n*\n* var arr = new Uint8ClampedArray( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint8c( arr, 2 );\n* // returns 3\n*/\nfunction getUint8c( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a generic `Array`.\n*\n* @private\n* @param {Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var v = getGeneric( arr, 2 );\n* // returns 3\n*/\nfunction getGeneric( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an indexed array-like object.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var v = getArrayLike( arr, 2 );\n* // returns 3\n*/\nfunction getArrayLike( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an indexed array-like object.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 2 );\n* // returns 3\n*/\nfunction getter( dtype ) {\n\tvar f = GETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn GETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar SETTERS = {\n\t'float64': setFloat64,\n\t'float32': setFloat32,\n\t'int32': setInt32,\n\t'int16': setInt16,\n\t'int8': setInt8,\n\t'uint32': setUint32,\n\t'uint16': setUint16,\n\t'uint8': setUint8,\n\t'uint8c': setUint8c,\n\t'generic': setGeneric,\n\t'default': setArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Sets an element in a `Float64Array`.\n*\n* @private\n* @param {Float64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( 4 );\n*\n* setFloat64( arr, 2, 3.0 );\n*\n* var v = arr[ 2 ];\n* // returns 3.0\n*/\nfunction setFloat64( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Float32Array`.\n*\n* @private\n* @param {Float32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Float32Array from '@stdlib/array/float32';\n*\n* var arr = new Float32Array( 4 );\n*\n* setFloat32( arr, 2, 3.0 );\n*\n* var v = arr[ 2 ];\n* // returns 3.0\n*/\nfunction setFloat32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int32Array`.\n*\n* @private\n* @param {Int32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var arr = new Int32Array( 4 );\n*\n* setInt32( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int16Array`.\n*\n* @private\n* @param {Int16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int16Array from '@stdlib/array/int16';\n*\n* var arr = new Int16Array( 4 );\n*\n* setInt16( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt16( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int8Array`.\n*\n* @private\n* @param {Int8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var arr = new Int8Array( 4 );\n*\n* setInt8( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt8( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint32Array`.\n*\n* @private\n* @param {Uint32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var arr = new Uint32Array( 4 );\n*\n* setUint32( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint16Array`.\n*\n* @private\n* @param {Uint16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint16Array from '@stdlib/array/uint16';\n*\n* var arr = new Uint16Array( 4 );\n*\n* setUint16( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint16( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint8Array`.\n*\n* @private\n* @param {Uint8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var arr = new Uint8Array( 4 );\n*\n* setUint8( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint8( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint8ClampedArray`.\n*\n* @private\n* @param {Uint8ClampedArray} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint8ClampedArray from '@stdlib/array/uint8c';\n*\n* var arr = new Uint8ClampedArray( 4 );\n*\n* setUint8c( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint8c( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a generic `Array`.\n*\n* @private\n* @param {Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* setGeneric( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setGeneric( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an indexed array-like object.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* setArrayLike( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setArrayLike( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for setting an element in an indexed array-like object.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var set = setter( dtype( arr ) );\n* set( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setter( dtype ) {\n\tvar f = SETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn SETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar GETTERS = {\n\t'complex128': getComplex128,\n\t'complex64': getComplex64,\n\t'default': getArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an element from a `Complex128Array`.\n*\n* @private\n* @param {Complex128Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex128( arr, 1 );\n* // returns \n*\n* var re = real( v );\n* // returns 3.0\n*\n* var im = imag( v );\n* // returns 4.0\n*/\nfunction getComplex128( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from a `Complex64Array`.\n*\n* @private\n* @param {Complex64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex64( arr, 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getComplex64( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from an array-like object supporting the get/set protocol.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* function get( idx ) {\n* return arr[ idx ];\n* }\n*\n* function set( value, idx ) {\n* arr[ idx ] = value;\n* }\n*\n* arr.get = get;\n* arr.set = set;\n*\n* var v = getArrayLike( arr, 2 );\n* // returns 3\n*/\nfunction getArrayLike( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getter( dtype ) {\n\tvar f = GETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn GETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar SETTERS = {\n\t'complex128': setComplex128,\n\t'complex64': setComplex64,\n\t'default': setArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Sets an element in a `Complex128Array`.\n*\n* @private\n* @param {Complex128Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );\n*\n* setComplex128( arr, 1, new Complex128( 10.0, 11.0 ) );\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = real( v );\n* // returns 10.0\n*\n* var im = imag( v );\n* // returns 11.0\n*/\nfunction setComplex128( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n/**\n* Sets an element in a `Complex64Array`.\n*\n* @private\n* @param {Complex64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* setComplex64( arr, 1, new Complex64( 10.0, 11.0 ) );\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 11.0\n*/\nfunction setComplex64( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n/**\n* Sets an element in an array-like object supporting the get/set protocol.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* function get( idx ) {\n* return arr[ idx ];\n* }\n*\n* function set( value, idx ) {\n* arr[ idx ] = value;\n* }\n*\n* arr.get = get;\n* arr.set = set;\n*\n* setArrayLike( arr, 2, 10 );\n*\n* var v = arr[ 2 ];\n* // returns 10\n*/\nfunction setArrayLike( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for setting an element in an array-like object supporting the get/set protocol.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var set = setter( dtype( arr ) );\n* set( arr, 1, new Complex64( 10.0, 11.0 ) );\n*\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 11.0\n*/\nfunction setter( dtype ) {\n\tvar f = SETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn SETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Mapping from array constructors to data types...\nvar ctor2dtypes = {\n\t'Float32Array': 'float32',\n\t'Float64Array': 'float64',\n\t'Array': 'generic',\n\t'Int16Array': 'int16',\n\t'Int32Array': 'int32',\n\t'Int8Array': 'int8',\n\t'Uint16Array': 'uint16',\n\t'Uint32Array': 'uint32',\n\t'Uint8Array': 'uint8',\n\t'Uint8ClampedArray': 'uint8c',\n\t'Complex64Array': 'complex64',\n\t'Complex128Array': 'complex128',\n\t'BooleanArray': 'bool'\n};\n\n\n// EXPORTS //\n\nexport default ctor2dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int32Array === 'function' ) ? Int32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 32-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int32\n*\n* @example\n* import ctor from '@stdlib/array/int32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt32ArraySupport from '@stdlib/assert/has-int32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 32-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int16Array === 'function' ) ? Int16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 16-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int16\n*\n* @example\n* import ctor from '@stdlib/array/int16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt16ArraySupport from '@stdlib/assert/has-int16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 16-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint8ClampedArray === 'function' ) ? Uint8ClampedArray : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order clamped to 0-255.\n*\n* @module @stdlib/array/uint8c\n*\n* @example\n* import ctor from '@stdlib/array/uint8c';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint8ClampedArraySupport from '@stdlib/assert/has-uint8clampedarray-support'; // eslint-disable-line id-length\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint8ClampedArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 8-bit unsigned integers in the platform byte order clamped to 0-255.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int8Array === 'function' ) ? Int8Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 8-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int8\n*\n* @example\n* import ctor from '@stdlib/array/int8';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt8ArraySupport from '@stdlib/assert/has-int8array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt8ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 8-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tz = v.value;\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( realf( z ), imagf( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/* eslint-disable no-restricted-syntax, max-lines, no-invalid-this */\n\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isArray from '@stdlib/assert/is-array';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport isFunction from '@stdlib/assert/is-function';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport isEven from '@stdlib/math/base/assert/is-even';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport isComplex64Array from './../../base/assert/is-complex64array';\nimport isComplex128Array from './../../base/assert/is-complex128array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Float32Array from './../../float32';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport format from '@stdlib/string/format';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport floor from '@stdlib/math/base/special/floor';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Float32Array.BYTES_PER_ELEMENT * 2;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a complex typed array.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*/\nfunction isComplexArray( value ) {\n\treturn (\n\t\tvalue instanceof Complex64Array ||\n\t\t(\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex64Array' ||\n\t\t\t\tvalue.constructor.name === 'Complex128Array'\n\t\t\t) &&\n\t\t\ttypeof value._length === 'number' && // eslint-disable-line no-underscore-dangle\n\n\t\t\t// NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks...\n\t\t\ttypeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle\n\t\t)\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a complex typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array constructor\n*/\nfunction isComplexArrayConstructor( value ) {\n\treturn (\n\t\tvalue === Complex64Array ||\n\n\t\t// NOTE: weaker test in order to avoid a circular dependency with Complex128Array...\n\t\tvalue.name === 'Complex128Array'\n\t);\n}\n\n/**\n* Retrieves a complex number from a complex number array buffer.\n*\n* @private\n* @param {Float32Array} buf - array buffer\n* @param {NonNegativeInteger} idx - element index\n* @returns {Complex64} complex number\n*/\nfunction getComplex64( buf, idx ) {\n\tidx *= 2;\n\treturn new Complex64( buf[ idx ], buf[ idx+1 ] );\n}\n\n\n// MAIN //\n\n/**\n* 64-bit complex number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `8`\n* @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `8`\n* @throws {TypeError} view length must be a positive multiple of `8`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex64Array} complex number array\n*\n* @example\n* var arr = new Complex64Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Complex64Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Complex64Array( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Complex64Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Complex64Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex64Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Complex64Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Complex64Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Complex64Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Complex64Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Complex64Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Complex64Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Float32Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\tif ( isNonNegativeInteger( arguments[0] ) ) {\n\t\t\tbuf = new Float32Array( arguments[0]*2 );\n\t\t} else if ( isCollection( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tlen = buf.length;\n\n\t\t\t// If provided a \"generic\" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to \"normal\" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number...\n\t\t\tif ( len && isArray( buf ) && isComplexLike( buf[0] ) ) {\n\t\t\t\tbuf = fromArray( new Float32Array( len*2 ), buf );\n\t\t\t\tif ( buf === null ) {\n\t\t\t\t\t// We failed and we are now forced to allocate a new array :-(\n\t\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t\t}\n\t\t\t\t\t// We failed, so fall back to directly setting values...\n\t\t\t\t\tbuf = new Float32Array( arguments[0] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( isComplex64Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret64( buf, 0 );\n\t\t\t\t} else if ( isComplex128Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret128( buf, 0 );\n\t\t\t\t} else if ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tbuf = new Float32Array( buf );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf );\n\t\t} else if ( isObject( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tif ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = buf[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); // FIXME: `buf` is what is returned from above, NOT the original value\n\t\t\t}\n\t\t\tbuf = fromIterator( buf );\n\t\t\tif ( buf instanceof Error ) {\n\t\t\t\tthrow buf;\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arguments[0] ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf, byteOffset, len*2 );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length/2 );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64Array\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var nbytes = Complex64Array.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex64Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex64Array\n* @readonly\n* @type {string}\n* @default 'Complex64Array'\n*\n* @example\n* var str = Complex64Array.name;\n* // returns 'Complex64Array'\n*/\nsetReadOnly( Complex64Array, 'name', 'Complex64Array' );\n\n/**\n* Creates a new 64-bit complex number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Complex64Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex64Array} 64-bit complex number array\n*\n* @example\n* var arr = Complex64Array.from( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function clbk( v ) {\n* return new Complex64( realf(v)*2.0, imagf(v)*2.0 );\n* }\n*\n* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*/\nsetReadOnly( Complex64Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar flg;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isComplexArray( src ) ) {\n\t\tlen = src.length;\n\t\tif ( clbk ) {\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, src.get( i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = realf( v );\n\t\t\t\t\tbuf[ j+1 ] = imagf( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\t// Note: array contents affect how we iterate over a provided data source. If only complex number objects, we can extract real and imaginary components. Otherwise, for non-complex number arrays (e.g., `Float64Array`, etc), we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component.\n\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\t// Detect whether we've been provided an array which returns complex number objects...\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tif ( !isComplexLike( get( src, i ) ) ) {\n\t\t\t\t\tflg = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If an array does not contain only complex number objects, then we assume interleaved real and imaginary components...\n\t\t\tif ( flg ) {\n\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. First argument must have a length which is a multiple of %u. Length: `%u`.', 2, len ) );\n\t\t\t\t}\n\t\t\t\tout = new this( len/2 );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ i ] = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\t// If an array contains only complex number objects, then we need to extract real and imaginary components...\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = realf( v );\n\t\t\t\t\tbuf[ j+1 ] = imagf( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length / 2;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 64-bit complex number array from a variable number of arguments.\n*\n* @name of\n* @memberof Complex64Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} 64-bit complex number array\n*\n* @example\n* var arr = Complex64Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Complex64Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide an integer\n* @returns {(Complex64|void)} array element\n*\n* @example\n* var arr = new Complex64Array( 10 );\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var z = arr.at( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 9.0, -9.0 ], 9 );\n*\n* z = arr.at( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*\n* z = arr.at( -1 );\n* // returns \n*\n* re = realf( z );\n* // returns 9.0\n*\n* im = imagf( z );\n* // returns -9.0\n*\n* z = arr.at( 100 );\n* // returns undefined\n*\n* z = arr.at( -100 );\n* // returns undefined\n*/\nsetReadOnly( Complex64Array.prototype, 'at', function at( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex64( this._buffer, idx );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 80\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex64Array.prototype, 'BYTES_PER_ELEMENT', Complex64Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} modified array\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 4 );\n*\n* // Set the array elements:\n* arr.set( new Complex64( 1.0, 1.0 ), 0 );\n* arr.set( new Complex64( 2.0, 2.0 ), 1 );\n* arr.set( new Complex64( 3.0, 3.0 ), 2 );\n* arr.set( new Complex64( 4.0, 4.0 ), 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* // Get the last array element:\n* var z = arr.get( 3 );\n*\n* var re = realf( z );\n* // returns 2.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex64Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target*2, start*2 );\n\t} else {\n\t\tthis._buffer.copyWithin( target*2, start*2, arguments[2]*2 );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = [\n* new Complex64( 1.0, 1.0 ),\n* new Complex64( 2.0, 2.0 ),\n* new Complex64( 3.0, 3.0 )\n* ];\n* arr = new Complex64Array( arr );\n*\n* // Create an iterator:\n* var it = arr.entries();\n*\n* // Iterate over the key-value pairs...\n* var v = it.next().value;\n* // returns [ 0, ]\n*\n* v = it.next().value;\n* // returns [ 1, ]\n*\n* v = it.next().value;\n* // returns [ 2, ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, getComplex64( buf, i ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, getComplex64( buf, i ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Complex64Array} modified array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.fill( new Complex64( 1.0, 1.0 ), 1 );\n*\n* var z = arr.get( 1 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 1.0\n*\n* z = arr.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tre = realf( value );\n\tim = imagf( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tidx = 2*i;\n\t\tbuf[ idx ] = re;\n\t\tbuf[ idx+1 ] = im;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 1\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 2.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex64Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\tout.push( z );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex64|void)} array element or undefined\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.find( predicate );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var idx = arr.findIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( Complex64Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex64|void)} array element or undefined\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.findLast( predicate );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var idx = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Complex64Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Complex64Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tfcn.call( thisArg, z, i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(Complex64|void)} array element\n*\n* @example\n* var arr = new Complex64Array( 10 );\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*\n* z = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( Complex64Array.prototype, 'get', function get( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex64( this._buffer, idx );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a provided value\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var bool = arr.includes( new Complex64( 3.0, -3.0 ) );\n* // returns true\n*\n* bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 );\n* // returns false\n*\n* bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 10 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) );\n* // returns 2\n*\n* idx = arr.indexOf( new Complex64( 3.0, -3.0 ), 3 );\n* // returns -1\n*\n* idx = arr.indexOf( new Complex64( 4.0, -4.0 ), -3 );\n* // returns -1\n*/\nsetReadOnly( Complex64Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.join();\n* // returns '1 + 1i,2 + 2i'\n*\n* str = arr.join( '/' );\n* // returns '1 + 1i/2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'join', function join( separator ) {\n\tvar out;\n\tvar buf;\n\tvar sep;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tsep = ',';\n\t} else if ( isString( separator ) ) {\n\t\tsep = separator;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toString() );\n\t}\n\treturn out.join( sep );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex] - index at which to start searching backward (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 3.0, -3.0 ], 4 );\n*\n* var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) );\n* // returns 4\n*\n* idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ), 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( new Complex64( 5.0, -5.0 ), 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), -3 );\n* // returns 1\n*/\nsetReadOnly( Complex64Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function scale( v, i ) {\n* return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 2\n*\n* var im = imagf( z );\n* // returns -2\n*/\nsetReadOnly( Complex64Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fcn.call( thisArg, getComplex64( buf, i ), i, this );\n\t\tif ( isComplexLike( v ) ) {\n\t\t\toutbuf[ 2*i ] = realf( v );\n\t\t\toutbuf[ (2*i)+1 ] = imagf( v );\n\t\t} else if ( isArrayLikeObject( v ) && v.length === 2 ) {\n\t\t\toutbuf[ 2*i ] = v[ 0 ];\n\t\t\toutbuf[ (2*i)+1 ] = v[ 1 ];\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t}\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import caddf from '@stdlib/complex/float32/base/add';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduce( caddf );\n* // returns \n*\n* var re = realf( z );\n* // returns 6.0\n*\n* var im = imagf( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex64( buf, 0 );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tv = getComplex64( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import caddf from '@stdlib/complex/float32/base/add';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduceRight( caddf );\n* // returns \n*\n* var re = realf( z );\n* // returns 6.0\n*\n* var im = imagf( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len-1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex64( buf, len-1 );\n\t\ti = len-2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tv = getComplex64( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} reversed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ (2*i) ];\n\t\tbuf[ (2*i) ] = buf[ (2*j) ];\n\t\tbuf[ (2*j) ] = tmp;\n\t\ttmp = buf[ (2*i)+1 ];\n\t\tbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t\tbuf[ (2*j)+1 ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'set', function set( value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tidx *= 2;\n\t\tbuf[ idx ] = realf( value );\n\t\tbuf[ idx+1 ] = imagf( value );\n\t\treturn;\n\t}\n\tif ( isComplexArray( value ) ) {\n\t\tN = value._length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tsbuf = value._buffer;\n\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Float32Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tidx *= 2;\n\t\tj = 0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\tidx += 2; // stride\n\t\t\tj += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// Detect whether we've been provided an array of complex numbers...\n\t\tN = value.length;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tif ( !isComplexLike( value[ i ] ) ) {\n\t\t\t\tflg = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// If an array does not contain only complex numbers, then we assume interleaved real and imaginary components...\n\t\tif ( flg ) {\n\t\t\tif ( !isEven( N ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', N ) );\n\t\t\t}\n\t\t\tif ( idx+(N/2) > this._length ) {\n\t\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t\t}\n\t\t\tsbuf = value;\n\n\t\t\t// Check for overlapping memory...\n\t\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\t\tif (\n\t\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t\t(\n\t\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// We need to copy source values...\n\t\t\t\ttmp = new Float32Array( N );\n\t\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\t\ttmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays\n\t\t\t\t}\n\t\t\t\tsbuf = tmp;\n\t\t\t}\n\t\t\tidx *= 2;\n\t\t\tN /= 2;\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\t\tidx += 2; // stride\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// If an array contains only complex numbers, then we need to extract real and imaginary components...\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tidx *= 2;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tv = value[ i ];\n\t\t\tbuf[ idx ] = realf( v );\n\t\t\tbuf[ idx+1 ] = imagf( v );\n\t\t\tidx += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.', value ) );\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 5.0\n*\n* im = imagf( z );\n* // returns -5.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* z = out.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'slice', function slice( start, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar idx;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tstart = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( start < end ) {\n\t\toutlen = end - start;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\tidx = 2*(i+start);\n\t\toutbuf[ 2*i ] = buf[ idx ];\n\t\toutbuf[ (2*i)+1 ] = buf[ idx+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, getComplex64( buf, i ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} sorted array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = realf( a );\n* re2 = realf( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imagf( a );\n* im2 = imagf( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex64( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = 2 * i;\n\t\tbuf[ j ] = realf( tmp[i] );\n\t\tbuf[ j+1 ] = imagf( tmp[i] );\n\t}\n\treturn this;\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} [begin=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} subarray\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var z = subarr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 5.0\n*\n* im = imagf( z );\n* // returns -5.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* z = subarr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + (begin*BYTES_PER_ELEMENT);\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toLocaleString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} reversed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = len - i - 1;\n\t\toutbuf[ (2*i) ] = buf[ (2*j) ];\n\t\toutbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} sorted array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = realf( a );\n* re2 = realf( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imagf( a );\n* im2 = imagf( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex64( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\treturn new Complex64Array( tmp );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toString() );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns \n*\n* var re = realf( v );\n* // returns 1.0\n*\n* var im = imagf( v );\n* // returns -1.0\n*\n* v = iter.next().value;\n* // returns \n*\n* re = realf( v );\n* // returns 2.0\n*\n* im = imagf( v );\n* // returns -2.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': getComplex64( buf, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {ComplexLike} value - new value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a complex number\n* @returns {Complex64Array} new typed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.with( 0, new Complex64( 4.0, 4.0 ) );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 4.0\n*\n* var im = imagf( z );\n* // returns 4.0\n*/\nsetReadOnly( Complex64Array.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tbuf[ 2*index ] = realf( value );\n\tbuf[ (2*index)+1 ] = imagf( value );\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Complex64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\n\n\n// MAIN //\n\n/**\n* Returns a strided array of real and imaginary components.\n*\n* @private\n* @param {Float32Array} buf - output array\n* @param {Array} arr - array containing complex numbers\n* @returns {(Float32Array|null)} output array or null\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tlen = arr.length;\n\tj = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = arr[ i ];\n\t\tif ( !isComplexLike( v ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tbuf[ j ] = realf( v );\n\t\tbuf[ j+1 ] = imagf( v );\n\t\tj += 2; // stride\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport format from '@stdlib/string/format';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tz = v.value;\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( real( z ), imag( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tz = clbk.call( thisArg, v.value, i );\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( realf( z ), imagf( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/* eslint-disable no-restricted-syntax, max-lines, no-invalid-this */\n\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isArray from '@stdlib/assert/is-array';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport isString from '@stdlib/assert/is-string';\nimport isFunction from '@stdlib/assert/is-function';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport isEven from '@stdlib/math/base/assert/is-even';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport isComplex64Array from './../../base/assert/is-complex64array';\nimport isComplex128Array from './../../base/assert/is-complex128array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Float64Array from './../../float64';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport floor from '@stdlib/math/base/special/floor';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Float64Array.BYTES_PER_ELEMENT * 2;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a complex typed array.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*/\nfunction isComplexArray( value ) {\n\treturn (\n\t\tvalue instanceof Complex128Array ||\n\t\t(\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex64Array' ||\n\t\t\t\tvalue.constructor.name === 'Complex128Array'\n\t\t\t) &&\n\t\t\ttypeof value._length === 'number' && // eslint-disable-line no-underscore-dangle\n\n\t\t\t// NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks...\n\t\t\ttypeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle\n\t\t)\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a complex typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array constructor\n*/\nfunction isComplexArrayConstructor( value ) {\n\treturn (\n\t\tvalue === Complex128Array ||\n\n\t\t// NOTE: weaker test in order to avoid a circular dependency with Complex64Array...\n\t\tvalue.name === 'Complex64Array'\n\t);\n}\n\n/**\n* Retrieves a complex number from a complex number array buffer.\n*\n* @private\n* @param {Float64Array} buf - array buffer\n* @param {NonNegativeInteger} idx - element index\n* @returns {Complex128} complex number\n*/\nfunction getComplex128( buf, idx ) {\n\tidx *= 2;\n\treturn new Complex128( buf[ idx ], buf[ idx+1 ] );\n}\n\n\n// MAIN //\n\n/**\n* 128-bit complex number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `16`\n* @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `16`\n* @throws {TypeError} view length must be a positive multiple of `16`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex128Array} complex number array\n*\n* @example\n* var arr = new Complex128Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Complex128Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Complex128Array( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex128Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex128Array( buf, 16 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 64 );\n* var arr = new Complex128Array( buf, 16, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Complex128Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Complex128Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Complex128Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Complex128Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Complex128Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Complex128Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Float64Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\tif ( isNonNegativeInteger( arguments[0] ) ) {\n\t\t\tbuf = new Float64Array( arguments[0]*2 );\n\t\t} else if ( isCollection( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tlen = buf.length;\n\n\t\t\t// If provided a \"generic\" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to \"normal\" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number...\n\t\t\tif ( len && isArray( buf ) && isComplexLike( buf[0] ) ) {\n\t\t\t\tbuf = fromArray( new Float64Array( len*2 ), buf );\n\t\t\t\tif ( buf === null ) {\n\t\t\t\t\t// We failed and we are now forced to allocate a new array :-(\n\t\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t\t}\n\t\t\t\t\t// We failed, so fall back to directly setting values...\n\t\t\t\t\tbuf = new Float64Array( arguments[0] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( isComplex64Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret64( buf, 0 );\n\t\t\t\t} else if ( isComplex128Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret128( buf, 0 );\n\t\t\t\t} else if ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tbuf = new Float64Array( buf );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf );\n\t\t} else if ( isObject( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tif ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = buf[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = fromIterator( buf );\n\t\t\tif ( buf instanceof Error ) {\n\t\t\t\tthrow buf;\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arguments[0] ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf, byteOffset, len*2 );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length/2 );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128Array\n* @readonly\n* @type {PositiveInteger}\n* @default 16\n*\n* @example\n* var nbytes = Complex128Array.BYTES_PER_ELEMENT;\n* // returns 16\n*/\nsetReadOnly( Complex128Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128Array\n* @readonly\n* @type {string}\n* @default 'Complex128Array'\n*\n* @example\n* var name = Complex128Array.name;\n* // returns 'Complex128Array'\n*/\nsetReadOnly( Complex128Array, 'name', 'Complex128Array' );\n\n/**\n* Creates a new 128-bit complex number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Complex128Array\n* @type {Function}\n* @param {(Collection|Object)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex128Array} 128-bit complex number array\n*\n* @example\n* var arr = Complex128Array.from( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function clbk( v ) {\n* return new Complex128( real(v)*2.0, imag(v)*2.0 );\n* }\n*\n* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*/\nsetReadOnly( Complex128Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar flg;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isComplexArray( src ) ) {\n\t\tlen = src.length;\n\t\tif ( clbk ) {\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, src.get( i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = real( v );\n\t\t\t\t\tbuf[ j+1 ] = imag( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\t// Note: array contents affect how we iterate over a provided data source. If only complex number objects, we can extract real and imaginary components. Otherwise, for non-complex number arrays (e.g., `Float64Array`, etc), we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component.\n\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\t// Detect whether we've been provided an array which returns complex number objects...\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tif ( !isComplexLike( get( src, i ) ) ) {\n\t\t\t\t\tflg = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If an array does not contain only complex number objects, then we assume interleaved real and imaginary components...\n\t\t\tif ( flg ) {\n\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. First argument must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tout = new this( len/2 );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ i ] = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\t// If an array contains only complex number objects, then we need to extract real and imaginary components...\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = real( v );\n\t\t\t\t\tbuf[ j+1 ] = imag( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length / 2;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 128-bit complex number array from a variable number of arguments.\n*\n* @name of\n* @memberof Complex128Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} 128-bit complex number array\n*\n* @example\n* var arr = Complex128Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Complex128Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide an integer\n* @returns {(Complex128|void)} array element\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 10 );\n*\n* var z = arr.at( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 9.0, -9.0 ], 9 );\n*\n* z = arr.at( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*\n* z = arr.at( -1 );\n* // returns \n*\n* re = real( z );\n* // returns 9.0\n*\n* im = imag( z );\n* // returns -9.0\n*\n* z = arr.at( 100 );\n* // returns undefined\n*\n* z = arr.at( -100 );\n* // returns undefined\n*/\nsetReadOnly( Complex128Array.prototype, 'at', function at( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex128( this._buffer, idx );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 160\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 16\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 16\n*/\nsetReadOnly( Complex128Array.prototype, 'BYTES_PER_ELEMENT', Complex128Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} modified array\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 4 );\n*\n* // Set the array elements:\n* arr.set( new Complex128( 1.0, 1.0 ), 0 );\n* arr.set( new Complex128( 2.0, 2.0 ), 1 );\n* arr.set( new Complex128( 3.0, 3.0 ), 2 );\n* arr.set( new Complex128( 4.0, 4.0 ), 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* // Get the last array element:\n* var z = arr.get( 3 );\n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target*2, start*2 );\n\t} else {\n\t\tthis._buffer.copyWithin( target*2, start*2, arguments[2]*2 );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = [\n* new Complex128( 1.0, 1.0 ),\n* new Complex128( 2.0, 2.0 ),\n* new Complex128( 3.0, 3.0 )\n* ];\n* arr = new Complex128Array( arr );\n*\n* // Create an iterator:\n* var it = arr.entries();\n*\n* // Iterate over the key-value pairs...\n* var v = it.next().value;\n* // returns [ 0, ]\n*\n* v = it.next().value;\n* // returns [ 1, ]\n*\n* v = it.next().value;\n* // returns [ 2, ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'entries', function entries() {\n\tvar buffer;\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuffer = this._buffer;\n\tlen = this._length;\n\n\t// Initialize the iteration indices:\n\ti = -1;\n\tj = -2;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\tvar z;\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tj += 2;\n\t\tz = new Complex128( buffer[ j ], buffer[ j+1 ] );\n\t\treturn {\n\t\t\t'value': [ i, z ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, getComplex128( buf, i ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Complex128Array} modified array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.fill( new Complex128( 1.0, 1.0 ), 1 );\n*\n* var z = arr.get( 1 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns 1.0\n*\n* z = arr.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tre = real( value );\n\tim = imag( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tidx = 2*i;\n\t\tbuf[ idx ] = re;\n\t\tbuf[ idx+1 ] = im;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 1\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\tout.push( z );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex128|void)} array element or undefined\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.find( predicate );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var idx = arr.findIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( Complex128Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex128|void)} array element or undefined\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.findLast( predicate );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var idx = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Complex128Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Complex128Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tfcn.call( thisArg, z, i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(Complex128|void)} array element\n*\n* @example\n* var arr = new Complex128Array( 10 );\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*\n* z = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( Complex128Array.prototype, 'get', function get( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex128( this._buffer, idx );\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a provided value\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var bool = arr.includes( new Complex128( 3.0, -3.0 ) );\n* // returns true\n*\n* bool = arr.includes( new Complex128( 3.0, -3.0 ), 3 );\n* // returns false\n*\n* bool = arr.includes( new Complex128( 4.0, -4.0 ), -3 );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var idx = arr.indexOf( new Complex128( 3.0, -3.0 ) );\n* // returns 2\n*\n* idx = arr.indexOf( new Complex128( 3.0, -3.0 ), 3 );\n* // returns -1\n*\n* idx = arr.indexOf( new Complex128( 4.0, -4.0 ), -3 );\n* // returns 3\n*/\nsetReadOnly( Complex128Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.join();\n* // returns '1 + 1i,2 + 2i'\n*\n* str = arr.join( '/' );\n* // returns '1 + 1i/2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'join', function join( separator ) {\n\tvar out;\n\tvar buf;\n\tvar sep;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tsep = ',';\n\t} else if ( isString( separator ) ) {\n\t\tsep = separator;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toString() );\n\t}\n\treturn out.join( sep );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex] - index at which to start searching backward (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 3.0, -3.0 ], 4 );\n*\n* var idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ) );\n* // returns 4\n*\n* idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ), 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( new Complex128( 5.0, -5.0 ), 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), -3 );\n* // returns 1\n*/\nsetReadOnly( Complex128Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function scale( v, i ) {\n* return new Complex128( 2.0*real( v ), 2.0*imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns -2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fcn.call( thisArg, getComplex128( buf, i ), i, this );\n\t\tif ( isComplexLike( v ) ) {\n\t\t\toutbuf[ 2*i ] = real( v );\n\t\t\toutbuf[ (2*i)+1 ] = imag( v );\n\t\t} else if ( isArrayLikeObject( v ) && v.length === 2 ) {\n\t\t\toutbuf[ 2*i ] = v[ 0 ];\n\t\t\toutbuf[ (2*i)+1 ] = v[ 1 ];\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t}\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import cadd from '@stdlib/complex/float64/base/add';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduce( cadd );\n* // returns \n*\n* var re = real( z );\n* // returns 6.0\n*\n* var im = imag( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex128( buf, 0 );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tv = getComplex128( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import cadd from '@stdlib/complex/float64/base/add';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduceRight( cadd );\n* // returns \n*\n* var re = real( z );\n* // returns 6.0\n*\n* var im = imag( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len-1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex128( buf, len-1 );\n\t\ti = len-2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tv = getComplex128( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} reversed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ (2*i) ];\n\t\tbuf[ (2*i) ] = buf[ (2*j) ];\n\t\tbuf[ (2*j) ] = tmp;\n\t\ttmp = buf[ (2*i)+1 ];\n\t\tbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t\tbuf[ (2*j)+1 ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended.\n*\n* @name set\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'set', function set( value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tidx *= 2;\n\t\tbuf[ idx ] = real( value );\n\t\tbuf[ idx+1 ] = imag( value );\n\t\treturn;\n\t}\n\tif ( isComplexArray( value ) ) {\n\t\tN = value._length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tsbuf = value._buffer;\n\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Float64Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tidx *= 2;\n\t\tj = 0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\tidx += 2; // stride\n\t\t\tj += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// Detect whether we've been provided an array of complex numbers...\n\t\tN = value.length;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tif ( !isComplexLike( value[ i ] ) ) {\n\t\t\t\tflg = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// If an array does not contain only complex numbers, then we assume interleaved real and imaginary components...\n\t\tif ( flg ) {\n\t\t\tif ( !isEven( N ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', N ) );\n\t\t\t}\n\t\t\tif ( idx+(N/2) > this._length ) {\n\t\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t\t}\n\t\t\tsbuf = value;\n\n\t\t\t// Check for overlapping memory...\n\t\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\t\tif (\n\t\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t\t(\n\t\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// We need to copy source values...\n\t\t\t\ttmp = new Float64Array( N );\n\t\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t\t}\n\t\t\t\tsbuf = tmp;\n\t\t\t}\n\t\t\tidx *= 2;\n\t\t\tN /= 2;\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\t\tidx += 2; // stride\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// If an array contains only complex numbers, then we need to extract real and imaginary components...\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tidx *= 2;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tv = value[ i ];\n\t\t\tbuf[ idx ] = real( v );\n\t\t\tbuf[ idx+1 ] = imag( v );\n\t\t\tidx += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.', value ) );\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 5.0\n*\n* im = imag( z );\n* // returns -5.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* z = out.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'slice', function slice( start, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar idx;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tstart = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( start < end ) {\n\t\toutlen = end - start;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\tidx = 2*(i+start);\n\t\toutbuf[ 2*i ] = buf[ idx ];\n\t\toutbuf[ (2*i)+1 ] = buf[ idx+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, getComplex128( buf, i ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} sorted array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = real( a );\n* re2 = real( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imag( a );\n* im2 = imag( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex128( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = 2 * i;\n\t\tbuf[ j ] = real( tmp[i] );\n\t\tbuf[ j+1 ] = imag( tmp[i] );\n\t}\n\treturn this;\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} [begin=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} subarray\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var z = subarr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 5.0\n*\n* im = imag( z );\n* // returns -5.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* z = subarr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toLocaleString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} reversed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = len - i - 1;\n\t\toutbuf[ (2*i) ] = buf[ (2*j) ];\n\t\toutbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} sorted array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = real( a );\n* re2 = real( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imag( a );\n* im2 = imag( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex128( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\treturn new Complex128Array( tmp );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toString() );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns \n*\n* var re = real( v );\n* // returns 1.0\n*\n* var im = imag( v );\n* // returns -1.0\n*\n* v = iter.next().value;\n* // returns \n*\n* re = real( v );\n* // returns 2.0\n*\n* im = imag( v );\n* // returns -2.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': getComplex128( buf, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {ComplexLike} value - new value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a complex number\n* @returns {Complex128Array} new typed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.with( 0, new Complex128( 4.0, 4.0 ) );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 4.0\n*\n* var im = imag( z );\n* // returns 4.0\n*/\nsetReadOnly( Complex128Array.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tbuf[ 2*index ] = real( value );\n\tbuf[ (2*index)+1 ] = imag( value );\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Complex128Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns a strided array of real and imaginary components.\n*\n* @private\n* @param {Float64Array} buf - output array\n* @param {Array} arr - array containing complex numbers\n* @returns {(Float64Array|null)} output array or null\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tlen = arr.length;\n\tj = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = arr[ i ];\n\t\tif ( !isComplexLike( v ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tbuf[ j ] = real( v );\n\t\tbuf[ j+1 ] = imag( v );\n\t\tj += 2; // stride\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( Boolean( v.value ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport format from '@stdlib/string/format';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tz = clbk.call( thisArg, v.value, i );\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( real( z ), imag( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Uint8Array from './../../uint8';\nimport Boolean from '@stdlib/boolean/ctor';\nimport getter from './../../base/getter';\nimport floor from '@stdlib/math/base/special/floor';\nimport accessorGetter from './../../base/accessor-getter';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint8Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `BooleanArray`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `BooleanArray`\n*/\nfunction isBooleanArray( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'BooleanArray' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a boolean typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a boolean typed array constructor\n*/\nfunction isBooleanArrayConstructor( value ) {\n\treturn ( value === BooleanArray );\n}\n\n\n// MAIN //\n\n/**\n* Boolean array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new BooleanArray( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new BooleanArray( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 16\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new BooleanArray( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction BooleanArray() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof BooleanArray) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new BooleanArray();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new BooleanArray( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new BooleanArray( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new BooleanArray( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint8Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tbuf = fromArray( new Uint8Array( arg.length ), arg );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tbuf = new Uint8Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var nbytes = BooleanArray.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof BooleanArray\n* @readonly\n* @type {string}\n* @default 'BooleanArray'\n*\n* @example\n* var str = BooleanArray.name;\n* // returns 'BooleanArray'\n*/\nsetReadOnly( BooleanArray, 'name', 'BooleanArray' );\n\n/**\n* Creates a new boolean array from an array-like object or an iterable.\n*\n* @name from\n* @memberof BooleanArray\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.from( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return !v;\n* }\n*\n* var arr = BooleanArray.from( [ true, false ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( BooleanArray, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = Boolean( clbk.call( thisArg, get( src, i ), i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new boolean array from a variable number of arguments.\n*\n* @name of\n* @memberof BooleanArray\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.of( true, true, true, true );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( BooleanArray, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide an integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.at( 0 );\n* // returns true\n*\n* v = arr.at( -1 );\n* // returns true\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'at', function at( idx ) {\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tif ( idx < 0 ) {\n\t\tidx += len;\n\t}\n\tif ( idx < 0 || idx >= len ) {\n\t\treturn;\n\t}\n\treturn Boolean( buf[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray.prototype, 'BYTES_PER_ELEMENT', BooleanArray.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 4 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n* arr.set( true, 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr.get( 2 );\n* // returns true\n*\n* v = arr.get( 3 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, true ]\n*\n* v = it.next().value;\n* // returns [ 1, false ]\n*\n* v = it.next().value;\n* // returns [ 2, true ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, Boolean( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.fill( true, 1 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar val;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tif ( value ) {\n\t\tval = 1;\n\t} else {\n\t\tval = 0;\n\t}\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = val;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* function predicate( v ) {\n* return ( v === true );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.find( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findIndex( predicate );\n* // returns 0\n*/\nsetReadOnly( BooleanArray.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLast( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( BooleanArray.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, Boolean( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'get', function get( idx ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn Boolean( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var bool = arr.includes( true );\n* // returns true\n*\n* bool = arr.includes( false, 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.indexOf( true );\n* // returns 0\n*\n* idx = arr.indexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.indexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.join();\n* // returns 'true,false,true'\n*\n* str = arr.join( '|' );\n* // returns 'true|false|true'\n*/\nsetReadOnly( BooleanArray.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.lastIndexOf( true );\n* // returns 4\n*\n* idx = arr.lastIndexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} new boolean array\n*\n* @example\n* function invert( v ) {\n* return !v;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.map( invert );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns false\n*\n* z = out.get( 1 );\n* // returns true\n*\n* z = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = Boolean( fcn.call( thisArg, Boolean( buf[ i ] ), i, this ) );\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduce( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduceRight( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(Collection|BooleanArray|*)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isCollection( value ) ) {\n\t\tN = value.length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tif ( isBooleanArray( value ) ) {\n\t\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\t} else {\n\t\t\tsbuf = value;\n\t\t}\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Uint8Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = ( sbuf[ i ] ) ? 1 : 0;\n\t\t}\n\t\treturn;\n\t}\n\tif ( idx >= this._length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t}\n\tbuf[ idx ] = ( value ) ? 1 : 0;\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var bool = out.get( 0 );\n* // returns true\n*\n* bool = out.get( len-1 );\n* // returns true\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* bool = out.get( 0 );\n* // returns false\n*\n* bool = out.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( false, 0 );\n* arr.set( true, 1 );\n* arr.set( false, 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.sort( compare );\n*\n* var v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort();\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {BooleanArray} subarray\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr.get( 0 );\n* // returns true\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr.get( 0 );\n* // returns false\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toLocaleString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( Boolean( buf[ i ] ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*\n* v = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ i ];\n\t}\n\tif ( arguments.length === 0 ) {\n\t\toutbuf.sort();\n\t\treturn out;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\toutbuf.sort( compare );\n\treturn out;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns true\n*\n* v = iter.next().value;\n* // returns false\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': Boolean( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {boolean} value - new value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a boolean\n* @returns {BooleanArray} new typed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.with( 0, false );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a boolean. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tif ( value ) {\n\t\tbuf[ index ] = 1;\n\t} else {\n\t\tbuf[ index ] = 0;\n\t}\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default BooleanArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Fills an output array with \"boolean\" values.\n*\n* @private\n* @param {Uint8Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint8Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = Boolean( arr[ i ] );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( Boolean( clbk.call( thisArg, v.value, i ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Uint32Array from './../../uint32';\nimport Int32Array from './../../int32';\nimport Uint16Array from './../../uint16';\nimport Int16Array from './../../int16';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Int8Array from './../../int8';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\n// Note: order should match `dtypes` order\nvar CTORS = [\n\tFloat64Array,\n\tFloat32Array,\n\tInt32Array,\n\tUint32Array,\n\tInt16Array,\n\tUint16Array,\n\tInt8Array,\n\tUint8Array,\n\tUint8ClampedArray,\n\tComplex64Array,\n\tComplex128Array,\n\tBooleanArray\n];\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Note: order should match `ctors` order\nvar DTYPES = [\n\t'float64',\n\t'float32',\n\t'int32',\n\t'uint32',\n\t'int16',\n\t'uint16',\n\t'int8',\n\t'uint8',\n\t'uint8c',\n\t'complex64',\n\t'complex128',\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isBuffer from '@stdlib/assert/is-buffer';\nimport isArray from '@stdlib/assert/is-array';\nimport constructorName from '@stdlib/utils/constructor-name';\nimport ctor2dtype from './ctor2dtype.js';\nimport CTORS from './ctors.js';\nimport DTYPES from './dtypes.js';\n\n\n// VARIABLES //\n\nvar NTYPES = DTYPES.length;\n\n\n// MAIN //\n\n/**\n* Returns the data type of an array.\n*\n* @param {*} value - input value\n* @returns {(string|null)} data type\n*\n* @example\n* var dt = dtype( [ 1, 2, 3 ] );\n* // returns 'generic'\n*\n* var dt = dtype( 'beep' );\n* // returns null\n*/\nfunction dtype( value ) {\n\tvar i;\n\tif ( isArray( value ) ) {\n\t\treturn 'generic';\n\t}\n\tif ( isBuffer( value ) ) {\n\t\treturn null;\n\t}\n\tfor ( i = 0; i < NTYPES; i++ ) {\n\t\tif ( value instanceof CTORS[ i ] ) {\n\t\t\treturn DTYPES[ i ];\n\t\t}\n\t}\n\t// If the above failed, fall back to a more robust (and significantly slower) means for resolving underlying data types:\n\treturn ctor2dtype[ constructorName( value ) ] || null;\n}\n\n\n// EXPORTS //\n\nexport default dtype;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport getter from './../../../base/getter';\nimport setter from './../../../base/setter';\nimport accessorGetter from './../../../base/accessor-getter';\nimport accessorSetter from './../../../base/accessor-setter';\nimport dtype from './../../../dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies values from `x` into `y`.\n*\n* @private\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Object} x - input array object\n* @param {Collection} x.data - input array data\n* @param {Array} x.accessors - array element accessors\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Object} y - output array object\n* @param {Collection} y.data - output array data\n* @param {Array} y.accessors - array element accessors\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @returns {Object} output array object\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n*\n* function setter( data, idx, value ) {\n* data.set( value, idx );\n* }\n*\n* function getter( data, idx ) {\n* return data.get( idx );\n* }\n*\n* var x = {\n* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ),\n* 'accessors': [ getter, setter ]\n* };\n*\n* var y = {\n* 'data': new Complex64Array( [ 5.0, 6.0, 7.0, 8.0 ] ),\n* 'accessors': [ getter, setter ]\n* };\n*\n* gcopy( x.data.length, x, 1, 0, y, 1, 0 );\n*\n* var view = reinterpret64( y.data, 0 );\n* // view => [ 1.0, 2.0, 3.0, 4.0 ]\n*/\nfunction gcopy( N, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar xbuf;\n\tvar ybuf;\n\tvar set;\n\tvar get;\n\tvar ix;\n\tvar iy;\n\tvar i;\n\n\t// Cache references to array data:\n\txbuf = x.data;\n\tybuf = y.data;\n\n\t// Cache a reference to the element accessors:\n\tget = x.accessors[ 0 ];\n\tset = y.accessors[ 1 ];\n\n\tix = offsetX;\n\tiy = offsetY;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tset( ybuf, iy, get( xbuf, ix ) );\n\t\tix += strideX;\n\t\tiy += strideY;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default gcopy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from '@stdlib/array/base/arraylike2object';\nimport accessors from './accessors.js';\n\n\n// VARIABLES //\n\nvar M = 8;\n\n\n// MAIN //\n\n/**\n* Copies values from `x` into `y`.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {Collection} y - output array\n* @param {integer} strideY - `y` stride length\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n* var y = [ 6.0, 7.0, 8.0, 9.0, 10.0 ];\n*\n* gcopy( x.length, x, 1, y, 1 );\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\nfunction gcopy( N, x, strideX, y, strideY ) {\n\tvar ix;\n\tvar iy;\n\tvar ox;\n\tvar oy;\n\tvar m;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tox = arraylike2object( x );\n\toy = arraylike2object( y );\n\tif ( ox.accessorProtocol || oy.accessorProtocol ) {\n\t\tif ( strideX < 0 ) {\n\t\t\tix = (1-N) * strideX;\n\t\t} else {\n\t\t\tix = 0;\n\t\t}\n\t\tif ( strideY < 0 ) {\n\t\t\tiy = (1-N) * strideY;\n\t\t} else {\n\t\t\tiy = 0;\n\t\t}\n\t\taccessors( N, ox, strideX, ix, oy, strideY, iy );\n\t\treturn oy.data;\n\t}\n\t// Use unrolled loops if both strides are equal to `1`...\n\tif ( strideX === 1 && strideY === 1 ) {\n\t\tm = N % M;\n\n\t\t// If we have a remainder, run a clean-up loop...\n\t\tif ( m > 0 ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\ty[ i ] = x[ i ];\n\t\t\t}\n\t\t}\n\t\tif ( N < M ) {\n\t\t\treturn y;\n\t\t}\n\t\tfor ( i = m; i < N; i += M ) {\n\t\t\ty[ i ] = x[ i ];\n\t\t\ty[ i+1 ] = x[ i+1 ];\n\t\t\ty[ i+2 ] = x[ i+2 ];\n\t\t\ty[ i+3 ] = x[ i+3 ];\n\t\t\ty[ i+4 ] = x[ i+4 ];\n\t\t\ty[ i+5 ] = x[ i+5 ];\n\t\t\ty[ i+6 ] = x[ i+6 ];\n\t\t\ty[ i+7 ] = x[ i+7 ];\n\t\t}\n\t\treturn y;\n\t}\n\tif ( strideX < 0 ) {\n\t\tix = (1-N) * strideX;\n\t} else {\n\t\tix = 0;\n\t}\n\tif ( strideY < 0 ) {\n\t\tiy = (1-N) * strideY;\n\t} else {\n\t\tiy = 0;\n\t}\n\tfor ( i = 0; i < N; i++ ) {\n\t\ty[ iy ] = x[ ix ];\n\t\tix += strideX;\n\t\tiy += strideY;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default gcopy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from '@stdlib/array/base/arraylike2object';\nimport accessors from './accessors.js';\n\n\n// VARIABLES //\n\nvar M = 8;\n\n\n// MAIN //\n\n/**\n* Copies values from `x` into `y`.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Collection} y - output array\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n* var y = [ 6.0, 7.0, 8.0, 9.0, 10.0 ];\n*\n* gcopy( x.length, x, 1, 0, y, 1, 0 );\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\nfunction gcopy( N, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar ix;\n\tvar iy;\n\tvar ox;\n\tvar oy;\n\tvar m;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tox = arraylike2object( x );\n\toy = arraylike2object( y );\n\tif ( ox.accessorProtocol || oy.accessorProtocol ) {\n\t\taccessors( N, ox, strideX, offsetX, oy, strideY, offsetY );\n\t\treturn oy.data;\n\t}\n\tix = offsetX;\n\tiy = offsetY;\n\n\t// Use unrolled loops if both strides are equal to `1`...\n\tif ( strideX === 1 && strideY === 1 ) {\n\t\tm = N % M;\n\n\t\t// If we have a remainder, run a clean-up loop...\n\t\tif ( m > 0 ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\ty[ iy ] = x[ ix ];\n\t\t\t\tix += strideX;\n\t\t\t\tiy += strideY;\n\t\t\t}\n\t\t}\n\t\tif ( N < M ) {\n\t\t\treturn y;\n\t\t}\n\t\tfor ( i = m; i < N; i += M ) {\n\t\t\ty[ iy ] = x[ ix ];\n\t\t\ty[ iy+1 ] = x[ ix+1 ];\n\t\t\ty[ iy+2 ] = x[ ix+2 ];\n\t\t\ty[ iy+3 ] = x[ ix+3 ];\n\t\t\ty[ iy+4 ] = x[ ix+4 ];\n\t\t\ty[ iy+5 ] = x[ ix+5 ];\n\t\t\ty[ iy+6 ] = x[ ix+6 ];\n\t\t\ty[ iy+7 ] = x[ ix+7 ];\n\t\t\tix += M;\n\t\t\tiy += M;\n\t\t}\n\t\treturn y;\n\t}\n\tfor ( i = 0; i < N; i++ ) {\n\t\ty[ iy ] = x[ ix ];\n\t\tix += strideX;\n\t\tiy += strideY;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default gcopy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeSlice from '@stdlib/slice/base/normalize-slice';\nimport sliceLength from '@stdlib/slice/base/length';\nimport zeros from './../../../base/zeros';\nimport dtype from './../../../dtype';\nimport { ndarray as gcopy } from '@stdlib/blas/base/gcopy';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a shallow copy of a portion of an array.\n*\n* @param {Collection} x - input array\n* @param {Slice} s - slice object\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {RangeError} slice exceeds array bounds\n* @returns {Collection} output array\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var x = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n*\n* var s = new Slice( null, null, -2 );\n* // returns \n*\n* var y = slice( x, s, false );\n* // returns [ 8, 6, 4, 2 ]\n*\n* var out = ( y === x );\n* // returns false\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n* import Slice from '@stdlib/slice/ctor';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] );\n*\n* var s = new Slice( null, null, -2 );\n* // returns \n*\n* var y = slice( x, s, false );\n* // returns [ 8, 6, 4, 2 ]\n*\n* var out = ( y === x );\n* // returns false\n*/\nfunction slice( x, s, strict ) {\n\tvar out;\n\tvar len;\n\tvar ns;\n\tvar dt;\n\tvar N;\n\n\tlen = x.length;\n\n\t// Normalize the slice object base on the array length:\n\tns = normalizeSlice( s, len, true );\n\n\t// Check whether the slice exceeds the array bounds...\n\tif ( ns.code ) {\n\t\tif ( strict ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Slice exceeds array bounds. Array length: %d.', len ) );\n\t\t}\n\t\t// Normalize again, this time allowing for out-of-bounds indices:\n\t\tns = normalizeSlice( s, len, false );\n\t}\n\t// Compute the slice length:\n\tN = sliceLength( ns );\n\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Allocate an output array:\n\tif ( dt === 'generic' || dt === null ) { // note: if we were provided an \"exotic\" array object, fallback to always returning a \"generic\" array\n\t\tout = zeros( N );\n\t} else {\n\t\tout = new x.constructor( N ); // note: this should accommodate array species which inherit from built-in/known constructors and we assume that all constructors support providing a length argument\n\t}\n\t// Copy elements to the output array:\n\tgcopy( N, x, ns.step, ns.start, out, 1, 0 );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* BLAS level 1 routine to copy values from `x` into `y`.\n*\n* @module @stdlib/blas/base/gcopy\n*\n* @example\n* import gcopy from '@stdlib/blas/base/gcopy';\n*\n* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n* var y = [ 6.0, 7.0, 8.0, 9.0, 10.0 ];\n*\n* gcopy( x.length, x, 1, y, 1 );\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* @example\n* import gcopy from '@stdlib/blas/base/gcopy';\n*\n* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n* var y = [ 6.0, 7.0, 8.0, 9.0, 10.0 ];\n*\n* gcopy.ndarray( x.length, x, 1, 0, y, 1, 0 );\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'float64': Float64Array,\n\t'float32': Float32Array,\n\t'generic': Array, // TODO: replace with `stdlib` pkg\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array,\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray,\n\t'complex64': Complex64Array,\n\t'complex128': Complex128Array,\n\t'bool': BooleanArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns an array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport getType from './../../dtype';\nimport ctors from './../../ctors';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport gcopy from '@stdlib/blas/base/gcopy';\nimport copy from './../../base/copy';\nimport resolveGetter from './../../base/resolve-getter';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether a data type is a single-precision complex floating-point number data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} boolean indicating whether a provided data type is a single-precision complex floating-point number data type\n*\n* @example\n* var bool = isComplex64( 'float64' );\n* // returns false\n*\n* @example\n* var bool = isComplex64( 'complex64' );\n* // returns true\n*/\nfunction isComplex64( dtype ) {\n\treturn ( dtype === 'complex64' );\n}\n\n/**\n* Tests whether a data type is a double-precision complex floating-point number data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} boolean indicating whether a provided data type is a double-precision complex floating-point number data type\n*\n* @example\n* var bool = isComplex128( 'float64' );\n* // returns false\n*\n* @example\n* var bool = isComplex128( 'complex128' );\n* // returns true\n*/\nfunction isComplex128( dtype ) {\n\treturn ( dtype === 'complex128' );\n}\n\n/**\n* Tests whether a data type is a boolean data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} boolean indicating whether a provided data type is a boolean data type\n*\n* @example\n* var bool = isBool( 'bool' );\n* // returns true\n*\n* @example\n* var bool = isBool( 'complex128' );\n* // returns false\n*/\nfunction isBool( dtype ) {\n\treturn ( dtype === 'bool' );\n}\n\n\n// MAIN //\n\n/**\n* Converts an array to an array of a different data type.\n*\n* @param {Collection} x - array to convert\n* @param {string} dtype - output data type\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be a recognized array data type\n* @returns {(Array|TypedArray|ComplexArray)} output array\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0 ];\n*\n* var out = convert( arr, 'float64' );\n* // returns [ 1.0, 2.0, 3.0, 4.0 ]\n*/\nfunction convert( x, dtype ) {\n\tvar isc64;\n\tvar ctor;\n\tvar xbuf;\n\tvar obuf;\n\tvar get;\n\tvar out;\n\tvar len;\n\tvar t;\n\tvar i;\n\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\t// If the output data type is \"generic\", our task is relatively straightforward...\n\tif ( dtype === 'generic' ) {\n\t\treturn copy( x );\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a recognized array data type. Value: `%s`.', dtype ) );\n\t}\n\t// Cache the input array length:\n\tlen = x.length;\n\n\t// Get the input array data type:\n\tt = getType( x );\n\tisc64 = isComplex64( t );\n\n\t// Create the output array:\n\tout = new ctor( len );\n\n\t// As the output data type is not \"generic\", we need to explicitly handle complex number input arrays...\n\tif ( isc64 || isComplex128( t ) ) {\n\t\tif ( isc64 ) {\n\t\t\txbuf = reinterpret64( x, 0 );\n\t\t} else {\n\t\t\txbuf = reinterpret128( x, 0 );\n\t\t}\n\t\t// Check whether the output data type is a complex number data type...\n\t\tif ( isComplex64( dtype ) ) { // cmplx => cmplx\n\t\t\tobuf = reinterpret64( out, 0 );\n\t\t\tgcopy( len*2, xbuf, 1, obuf, 1 );\n\t\t\treturn out;\n\t\t}\n\t\tif ( isComplex128( dtype ) ) { // cmplx => cmplx\n\t\t\tobuf = reinterpret128( out, 0 );\n\t\t\tgcopy( len*2, xbuf, 1, obuf, 1 );\n\t\t\treturn out;\n\t\t}\n\t\t// Check whether the output data type is a boolean data type...\n\t\tif ( isBool( dtype ) ) { // cmplx => bool\n\t\t\tobuf = reinterpretBoolean( out, 0 );\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t// A complex number is only falsy when both the real and imaginary components are zero...\n\t\t\t\tif ( xbuf[ 2*i ] || xbuf[ (2*i)+1 ] ) {\n\t\t\t\t\tobuf[ i ] = 1;\n\t\t\t\t} else {\n\t\t\t\t\tobuf[ i ] = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\t// We assume that the output data type is a real number data type, given that we're looking to convert a provided complex number array; in which case, we'll only extract the real components from the complex number input array...\n\t\tgcopy( len, xbuf, 2, out, 1 ); // cmplx => real\n\t\treturn out;\n\t}\n\t// Check whether the input array is a boolean array...\n\tif ( isBool( t ) ) {\n\t\txbuf = reinterpretBoolean( x, 0 );\n\n\t\t// Check whether the output data type is a boolean data type...\n\t\tif ( isBool( dtype ) ) { // bool => bool\n\t\t\tobuf = reinterpretBoolean( out, 0 );\n\t\t\tgcopy( len, xbuf, 1, obuf, 1 );\n\t\t\treturn out;\n\t\t}\n\t\t// Check whether the output data type is a complex number data type...\n\t\tif ( isComplex64( dtype ) ) { // bool => cmplx\n\t\t\tobuf = reinterpret64( out, 0 );\n\t\t\tgcopy( len, xbuf, 1, obuf, 2 );\n\t\t\treturn out;\n\t\t}\n\t\tif ( isComplex128( dtype ) ) { // bool => cmplx\n\t\t\tobuf = reinterpret128( out, 0 );\n\t\t\tgcopy( len, xbuf, 1, obuf, 2 );\n\t\t\treturn out;\n\t\t}\n\t\tgcopy( len, xbuf, 1, out, 1 ); // bool => real\n\t\treturn out;\n\t}\n\t// Check whether we need to explicitly handle complex number output arrays...\n\tisc64 = isComplex64( dtype );\n\tif ( isc64 || isComplex128( dtype ) ) {\n\t\tif ( isc64 ) {\n\t\t\tobuf = reinterpret64( out, 0 );\n\t\t} else {\n\t\t\tobuf = reinterpret128( out, 0 );\n\t\t}\n\t\t// We assume that the input data type is a real number data type, given that we're looking to convert to a complex number array; in which case, we'll only set the real components... (WARNING: we're assuming that the output array has been zero-initialized! The imaginary components should be zero!)\n\t\tgcopy( len, x, 1, obuf, 2 ); // real => cmplx\n\t\treturn out;\n\t}\n\t// Check whether the output data type is a boolean data type...\n\tif ( isBool( dtype ) ) {\n\t\tobuf = reinterpretBoolean( out, 0 );\n\t\tget = resolveGetter( x );\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( get( x, i ) ) {\n\t\t\t\tobuf[ i ] = 1;\n\t\t\t} else {\n\t\t\t\tobuf[ i ] = 0;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\t// At this point, we're no longer handling complex number or boolean arrays, so we'll just assume that we can perform a straightforward copy...\n\tgcopy( len, x, 1, out, 1 ); // note: `gcopy` is assumed to support arrays using accessors\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default convert;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isMostlySafeCast from './../../../base/assert/is-mostly-safe-data-type-cast';\nimport isRealDataType from './../../../base/assert/is-real-data-type';\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport normalizeSlice from '@stdlib/slice/base/normalize-slice';\nimport sliceLength from '@stdlib/slice/base/length';\nimport dtype from './../../../dtype';\nimport convert from './../../../convert';\nimport { ndarray as gcopy } from '@stdlib/blas/base/gcopy';\nimport format from '@stdlib/string/format';\n\n\n// MODULES //\n\n/**\n* Assigns element values from a broadcasted input array to corresponding elements in an output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {Slice} s - slice object\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {RangeError} slice exceeds array bounds\n* @throws {Error} input array must be broadcast compatible with an output array view\n* @throws {TypeError} input array cannot be safely cast to the output array data type\n* @returns {Collection} output array\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 0, 0, 0, 0, 0, 0, 0, 0 ];\n*\n* var s = new Slice( null, null, -2 );\n* // returns \n*\n* var out = sliceAssign( x, y, s, false );\n* // returns [ 0, 4, 0, 3, 0, 2, 0, 1 ]\n*\n* var bool = ( out === y );\n* // returns true\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n* import Slice from '@stdlib/slice/ctor';\n*\n* var x = new Int32Array( [ 5 ] );\n* var y = new Int32Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] );\n*\n* var s = new Slice( null, null, -2 );\n* // returns \n*\n* var out = sliceAssign( x, y, s, false );\n* // returns [ 0, 5, 0, 5, 0, 5, 0, 5 ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction sliceAssign( x, y, s, strict ) {\n\tvar xlen;\n\tvar ylen;\n\tvar xdt;\n\tvar ydt;\n\tvar ns;\n\tvar xs;\n\tvar N;\n\n\txdt = dtype( x ) || 'generic';\n\tydt = dtype( y ) || 'generic';\n\n\txlen = x.length;\n\tylen = y.length;\n\n\t// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the output data type is floating-point...\n\tif ( !isMostlySafeCast( xdt, ydt ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Input array values cannot be safely cast to the output array data type. Data types: [%s, %s].', xdt, ydt ) );\n\t}\n\t// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...\n\tif ( isComplexDataType( ydt ) && isRealDataType( xdt ) ) {\n\t\tx = convert( x, ydt );\n\t}\n\t// Normalize the slice object base on the output array length:\n\tns = normalizeSlice( s, ylen, true );\n\n\t// Check whether the slice exceeds the array bounds...\n\tif ( ns.code ) {\n\t\tif ( strict ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Slice exceeds array bounds. Array length: %d.', ylen ) );\n\t\t}\n\t\t// Normalize again, this time allowing for out-of-bounds indices:\n\t\tns = normalizeSlice( s, ylen, false );\n\t}\n\t// Compute the slice length:\n\tN = sliceLength( ns );\n\n\t// Broadcast the input array:\n\tif ( xlen === 1 ) {\n\t\txs = 0;\n\t} else if ( xlen === N ) {\n\t\txs = 1;\n\t} else {\n\t\tthrow new Error( format( 'invalid argument. Input array and the output array slice are broadcast incompatible. Array length: %u. Desired length: %u.', xlen, N ) );\n\t}\n\t// Copy elements to the output array:\n\tgcopy( N, x, xs, 0, y, ns.step, ns.start );\n\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled \"generic\" array according to a provided callback function.\n*\n* @param {NonNegativeInteger} len - array length\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filledBy( 3, constantFunction( 'beep' ) );\n* // returns [ 'beep', 'beep', 'beep' ]\n*/\nfunction filledBy( len, clbk, thisArg ) {\n\tvar arr;\n\tvar i;\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tarr.push( clbk.call( thisArg, i ) );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a filled three-dimensional nested array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = filled3d( 0.0, [ 1, 1, 3 ] );\n* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ]\n*\n* @example\n* var out = filled3d( 'beep', [ 1, 3, 1 ] );\n* // returns [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ]\n*/\nfunction filled3d( value, shape ) {\n\tvar out;\n\tvar a1;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i2;\n\tvar i1;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tout = [];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = [];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta1.push( filled( value, S0 ) );\n\t\t}\n\t\tout.push( a1 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default filled3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a filled four-dimensional nested array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = filled4d( 0.0, [ 1, 1, 1, 3 ] );\n* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ]\n*\n* @example\n* var out = filled4d( 'beep', [ 1, 1, 3, 1 ] );\n* // returns [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ]\n*/\nfunction filled4d( value, shape ) {\n\tvar out;\n\tvar a1;\n\tvar a2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tout = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta1.push( filled( value, S0 ) );\n\t\t\t}\n\t\t\ta2.push( a1 );\n\t\t}\n\t\tout.push( a2 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default filled4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a filled five-dimensional nested array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = filled5d( 0.0, [ 1, 1, 1, 1, 3 ] );\n* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ]\n*\n* @example\n* var out = filled5d( 'beep', [ 1, 1, 1, 3, 1 ] );\n* // returns [ [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] ]\n*/\nfunction filled5d( value, shape ) {\n\tvar out;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tout = [];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = [];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = [];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = [];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta1.push( filled( value, S0 ) );\n\t\t\t\t}\n\t\t\t\ta2.push( a1 );\n\t\t\t}\n\t\t\ta3.push( a2 );\n\t\t}\n\t\tout.push( a3 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default filled5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// FUNCTIONS //\n\n/**\n* Recursive fills an array.\n*\n* @private\n* @param {*} value - fill value\n* @param {NonNegativeInteger} ndims - number of dimensions\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} dim - dimension index\n* @param {Array} out - output array\n* @returns {Array} output array\n*/\nfunction recurse( value, ndims, shape, dim, out ) {\n\tvar S;\n\tvar d;\n\tvar i;\n\n\tS = shape[ dim ];\n\n\t// Check whether we're filling the last dimension:\n\td = dim + 1;\n\tif ( d === ndims ) {\n\t\treturn filled( value, S );\n\t}\n\n\t// Fill nested dimensions...\n\tfor ( i = 0; i < S; i++ ) {\n\t\tout.push( recurse( value, ndims, shape, d, [] ) );\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a filled n-dimensional nested array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = fillednd( 0.0, [ 3 ] );\n* // returns [ 0.0, 0.0, 0.0 ]\n*\n* @example\n* var out = fillednd( 0.0, [ 1, 3 ] );\n* // returns [ [ 0.0, 0.0, 0.0 ] ]\n*\n* @example\n* var out = fillednd( 'beep', [ 3, 1 ] );\n* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ]\n*/\nfunction fillednd( value, shape ) {\n\treturn recurse( value, shape.length, shape, 0, [] );\n}\n\n\n// EXPORTS //\n\nexport default fillednd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Recursive fills an array.\n*\n* @private\n* @param {NonNegativeInteger} ndims - number of dimensions\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} dim - dimension index\n* @param {NonNegativeIntegerArray} indices - outer array element indices\n* @param {Array} out - output array\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} output array\n*/\nfunction recurse( ndims, shape, dim, indices, out, clbk, thisArg ) {\n\tvar idx;\n\tvar FLG;\n\tvar S;\n\tvar d;\n\tvar i;\n\n\t// Check whether we're filling the last dimension:\n\td = dim + 1;\n\tFLG = ( d === ndims );\n\n\tS = shape[ dim ];\n\tfor ( i = 0; i < S; i++ ) {\n\t\tidx = indices.slice(); // we explicitly copy in order to avoid potential mutation when calling `clbk`\n\t\tidx.push( i );\n\t\tif ( FLG ) {\n\t\t\tout.push( clbk.call( thisArg, idx ) );\n\t\t} else {\n\t\t\tout.push( recurse( ndims, shape, d, idx, [], clbk, thisArg ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filledndBy( [ 3, 1 ], constantFunction( 'beep' ) );\n* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ]\n*/\nfunction filledndBy( shape, clbk, thisArg ) {\n\treturn recurse( shape.length, shape, 0, [], [], clbk, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default filledndBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the number of elements in an array.\n*\n* @param {(NonNegativeIntegerArray|EmptyArray)} shape - array shape\n* @returns {NonNegativeInteger} number of elements\n*\n* @example\n* var n = numel( [ 3, 3, 3 ] );\n* // returns 27\n*/\nfunction numel( shape ) {\n\tvar ndims;\n\tvar n;\n\tvar i;\n\n\tndims = shape.length;\n\tif ( ndims === 0 ) {\n\t\treturn 0;\n\t}\n\tn = 1;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tn *= shape[ i ];\n\t}\n\treturn n;\n}\n\n\n// EXPORTS //\n\nexport default numel;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests whether an input value is the string representing column-major order.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean result\n*\n* @example\n* var bool = isColumnMajorString( 'column-major' );\n* // returns true\n*\n* bool = isColumnMajorString( 'row-major' );\n* // returns false\n*\n* bool = isColumnMajorString( 'foo' );\n* // returns false\n*/\nfunction isColumnMajorString( v ) {\n\treturn ( v === 'column-major' );\n}\n\n\n// EXPORTS //\n\nexport default isColumnMajorString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from './../../../base/assert/is-column-major-string';\n\n\n// FUNCTIONS //\n\n/**\n* Generates a stride array from an array shape (row-major).\n*\n* @private\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} array strides\n*/\nfunction rowmajor( shape ) {\n\tvar ndims;\n\tvar out;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tout = [];\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tout.push( 0 );\n\t}\n\ts = 1;\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\tout[ i ] = s;\n\t\ts *= shape[ i ];\n\t}\n\treturn out;\n}\n\n/**\n* Generates a stride array from an array shape (column-major).\n*\n* @private\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} array strides\n*/\nfunction columnmajor( shape ) {\n\tvar out;\n\tvar s;\n\tvar i;\n\n\tout = [];\n\ts = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tout.push( s );\n\t\ts *= shape[ i ];\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates a stride array from an array shape.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {Array} array strides\n*\n* @example\n* var s = shape2strides( [ 3, 2 ], 'row-major' );\n* // returns [ 2, 1 ]\n*\n* s = shape2strides( [ 3, 2 ], 'column-major' );\n* // returns [ 1, 3 ]\n*/\nfunction shape2strides( shape, order ) {\n\tif ( isColumnMajor( order ) ) {\n\t\treturn columnmajor( shape );\n\t}\n\treturn rowmajor( shape );\n}\n\n\n// EXPORTS //\n\nexport default shape2strides;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from './../../../base/assert/is-column-major-string';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Converts a linear index in an array view to a linear index in an underlying data buffer.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - location of the first indexed value **based** on the stride array\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {integer} idx - linear index in an array view\n* @param {string} mode - specifies how to handle a linear index which exceeds array dimensions\n* @throws {RangeError} linear index must not exceed array dimensions\n* @returns {NonNegativeInteger} linear index in an underlying data buffer\n*\n* @example\n* var shape = [ 3, 3 ];\n* var strides = [ -3, 1 ];\n* var offset = 6;\n* var order = 'row-major';\n* var mode = 'throw';\n*\n* var ind = vind2bind( shape, strides, offset, order, 1, mode );\n* // returns 7\n*/\nfunction vind2bind( shape, strides, offset, order, idx, mode ) {\n\tvar ndims;\n\tvar len;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tlen = 1;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\tif ( mode === 'clamp' ) {\n\t\tif ( idx < 0 ) {\n\t\t\tidx = 0;\n\t\t} else if ( idx >= len ) {\n\t\t\tidx = len - 1;\n\t\t}\n\t} else if ( mode === 'wrap' ) {\n\t\tif ( idx < 0 ) {\n\t\t\tidx += len; // slight optimization to avoid modulo arithmetic when |idx| <= len\n\t\t\tif ( idx < 0 ) {\n\t\t\t\tidx %= len;\n\t\t\t\tif ( idx !== 0 ) {\n\t\t\t\t\tidx += len;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ( idx >= len ) {\n\t\t\tidx -= len; // slight optimization to avoid modulo arithmetic when len < idx <= 2*len\n\t\t\tif ( idx >= len ) {\n\t\t\t\tidx %= len;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif ( mode === 'normalize' && idx < 0 ) {\n\t\t\tidx += len;\n\t\t}\n\t\tif ( idx < 0 || idx >= len ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.', len, idx ) );\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tind = offset;\n\tif ( isColumnMajor( order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\treturn ind;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\treturn ind;\n}\n\n\n// EXPORTS //\n\nexport default vind2bind;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the index offset which specifies the location of the first indexed value in a strided array.\n*\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {integer} stride - index increment\n* @returns {NonNegativeInteger} offset - offset\n*\n* @example\n* var offset = stride2offset( 10, -10 );\n* // returns 90\n*/\nfunction stride2offset( N, stride ) {\n\tif ( stride > 0 ) {\n\t\treturn 0;\n\t}\n\treturn ( 1 - N ) * stride;\n}\n\n\n// EXPORTS //\n\nexport default stride2offset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Generate a stride array from an array shape.\n*\n* @module @stdlib/ndarray/base/shape2strides\n*\n* @example\n* import shape2strides from '@stdlib/ndarray/base/shape2strides';\n*\n* var strides = shape2strides( [ 3, 2 ], 'row-major' );\n* // returns [ 2, 1 ]\n*\n* strides = shape2strides( [ 3, 2 ], 'column-major' );\n* // returns [ 1, 3 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from './../../../base/assert/is-column-major-string';\n\n\n// FUNCTIONS //\n\n/**\n* Generates a stride array from an array shape (row-major).\n*\n* @private\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} array strides\n*/\nfunction rowmajor( shape, out ) {\n\tvar ndims;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\ts = 1;\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\tout[ i ] = s;\n\t\ts *= shape[ i ];\n\t}\n\treturn out;\n}\n\n/**\n* Generates a stride array from an array shape (column-major).\n*\n* @private\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} array strides\n*/\nfunction columnmajor( shape, out ) {\n\tvar s;\n\tvar i;\n\n\ts = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tout[ i ] = s;\n\t\ts *= shape[ i ];\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates a stride array from an array shape.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} array strides\n*\n* @example\n* var strides = [ 0, 0 ];\n*\n* var out = shape2strides( [ 3, 2 ], 'row-major', strides );\n* // returns [ 2, 1 ]\n*\n* var bool = ( out === strides );\n* // returns true\n*\n* out = shape2strides( [ 3, 2 ], 'column-major', strides );\n* // returns [ 1, 3 ]\n*/\nfunction shape2strides( shape, order, out ) {\n\tif ( isColumnMajor( order ) ) {\n\t\treturn columnmajor( shape, out );\n\t}\n\treturn rowmajor( shape, out );\n}\n\n\n// EXPORTS //\n\nexport default shape2strides;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math/base/special/floor';\nimport arraylike2object from '@stdlib/array/base/arraylike2object';\nimport accessors from './accessors.js';\n\n\n// VARIABLES //\n\nvar M = 3;\n\n\n// MAIN //\n\n/**\n* Reverses a strided array in-place.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {NumericArray} input array\n*\n* @example\n* var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];\n*\n* grev( 3, x, 1, x.length-3 );\n* // x => [ 1.0, -2.0, 3.0, -6.0, 5.0, -4.0 ]\n*/\nfunction grev( N, x, strideX, offsetX ) {\n\tvar tmp;\n\tvar ix;\n\tvar iy;\n\tvar o;\n\tvar m;\n\tvar n;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn x;\n\t}\n\to = arraylike2object( x );\n\tif ( o.accessorProtocol ) {\n\t\taccessors( N, o, strideX, offsetX );\n\t\treturn o.data;\n\t}\n\tn = floor( N/2 );\n\tix = offsetX;\n\n\t// Use loop unrolling if the stride is equal to `1`...\n\tif ( strideX === 1 ) {\n\t\tm = n % M;\n\t\tiy = ix + N - 1;\n\n\t\t// If we have a remainder, run a clean-up loop...\n\t\tif ( m > 0 ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\ttmp = x[ ix ];\n\t\t\t\tx[ ix ] = x[ iy ];\n\t\t\t\tx[ iy ] = tmp;\n\t\t\t\tix += strideX;\n\t\t\t\tiy -= strideX;\n\t\t\t}\n\t\t}\n\t\tif ( n < M ) {\n\t\t\treturn x;\n\t\t}\n\t\tfor ( i = m; i < n; i += M ) {\n\t\t\ttmp = x[ ix ];\n\t\t\tx[ ix ] = x[ iy ];\n\t\t\tx[ iy ] = tmp;\n\n\t\t\ttmp = x[ ix+1 ];\n\t\t\tx[ ix+1 ] = x[ iy-1 ];\n\t\t\tx[ iy-1 ] = tmp;\n\n\t\t\ttmp = x[ ix+2 ];\n\t\t\tx[ ix+2 ] = x[ iy-2 ];\n\t\t\tx[ iy-2 ] = tmp;\n\n\t\t\tix += M;\n\t\t\tiy -= M;\n\t\t}\n\t\treturn x;\n\t}\n\tiy = ix + ( ( N - 1 ) * strideX );\n\tfor ( i = 0; i < n; i++ ) {\n\t\ttmp = x[ ix ];\n\t\tx[ ix ] = x[ iy ];\n\t\tx[ iy ] = tmp;\n\t\tix += strideX;\n\t\tiy -= strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default grev;\n","\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math/base/special/floor';\n\n\n// MAIN //\n\n/**\n* Reverses a strided array in-place.\n*\n* @private\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Object} x - input array object\n* @param {Collection} x.data - input array data\n* @param {Array} x.accessors - array element accessors\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {Object} input array object\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n*\n* function setter( data, idx, value ) {\n* data.set( value, idx );\n* }\n*\n* function getter( data, idx ) {\n* return data.get( idx );\n* }\n*\n* var data = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );\n*\n* var x = {\n* 'data': data,\n* 'accessors': [ getter, setter ]\n* };\n*\n* grev( data.length, x, 1, 0 );\n*\n* var view = reinterpret64( x.data, 0 );\n* // view => [ -1.0, -3.0, 4.0, 0.0, 3.0, -5.0, -2.0, 1.0 ]\n*/\nfunction grev( N, x, strideX, offsetX ) {\n\tvar xbuf;\n\tvar set;\n\tvar get;\n\tvar tmp;\n\tvar ix;\n\tvar iy;\n\tvar n;\n\tvar i;\n\n\t// Cache reference to array data:\n\txbuf = x.data;\n\n\t// Cache a reference to the element accessors:\n\tget = x.accessors[ 0 ];\n\tset = x.accessors[ 1 ];\n\n\tn = floor( N/2 );\n\tix = offsetX;\n\tiy = ix + ( ( N - 1 ) * strideX );\n\tfor ( i = 0; i < n; i++ ) {\n\t\ttmp = get( xbuf, ix );\n\t\tset( xbuf, ix, get( xbuf, iy ) );\n\t\tset( xbuf, iy, tmp );\n\t\tix += strideX;\n\t\tiy -= strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default grev;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport stride2offset from '@stdlib/strided/base/stride2offset';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\n/**\n* Reverses a strided array in-place.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} strideX - stride length\n* @returns {NumericArray} input array\n*\n* @example\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* grev( x.length, x, 1 );\n* // x => [ -3.0, -1.0, 0.0, 4.0, -5.0, 3.0, 1.0, -2.0 ]\n*/\nfunction grev( N, x, strideX ) {\n\treturn ndarray( N, x, strideX, stride2offset( N, strideX ) );\n}\n\n\n// EXPORTS //\n\nexport default grev;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Reverse a strided array in-place.\n*\n* @module @stdlib/blas/ext/base/grev\n*\n* @example\n* import grev from '@stdlib/blas/ext/base/grev';\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* grev( x.length, x, 1 );\n* // x => [ -3.0, -1.0, 0.0, 4.0, -5.0, 3.0, 1.0, -2.0 ]\n*\n* @example\n* import grev from '@stdlib/blas/ext/base/grev';\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* grev( x.length, x, 1, 0 );\n* // x => [ -3.0, -1.0, 0.0, 4.0, -5.0, 3.0, 1.0, -2.0 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray/base/shape2strides';\nimport vind2bind from '@stdlib/ndarray/base/vind2bind';\nimport numel from '@stdlib/ndarray/base/numel';\nimport grev from '@stdlib/blas/ext/base/grev';\nimport zeros from './../../../base/zeros';\n\n\n// VARIABLES //\n\nvar MODE = 'throw';\n\n\n// FUNCTIONS //\n\n/**\n* Copies a specified number of array elements to a provided array.\n*\n* @private\n* @param {Array} x - input array\n* @param {NonNegativeInteger} N - number of elements to copy\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0 ];\n* copy( x, 3, out, 1, 0 );\n*\n* var o = out;\n* // returns [ 1, 2, 3 ]\n*/\nfunction copy( x, N, out, stride, offset ) {\n\tvar i;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout[ offset ] = x[ i ];\n\t\toffset += stride;\n\t}\n}\n\n/**\n* Recursively flattens an array in lexicographic order.\n*\n* @private\n* @param {Array} x - array to flatten\n* @param {NonNegativeInteger} ndims - number of dimensions in the input array\n* @param {NonNegativeIntegerArray} shape - shape of the input array\n* @param {NonNegativeInteger} dim - dimension index\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {NonNegativeInteger} offset for next output array element\n*/\nfunction recurseLexicographic( x, ndims, shape, dim, out, stride, offset ) {\n\tvar FLG;\n\tvar S;\n\tvar d;\n\tvar i;\n\n\t// Check whether we've reached the last dimension:\n\td = dim + 1;\n\tFLG = ( d === ndims );\n\n\tS = shape[ dim ];\n\tfor ( i = 0; i < S; i++ ) {\n\t\tif ( FLG ) {\n\t\t\tout[ offset ] = x[ i ];\n\t\t\toffset += stride;\n\t\t} else {\n\t\t\toffset = recurseLexicographic( x[ i ], ndims, shape, d, out, stride, offset ); // eslint-disable-line max-len\n\t\t}\n\t}\n\treturn offset;\n}\n\n/**\n* Flattens an array in colexicographic order.\n*\n* @private\n* @param {Array} x - array to flatten\n* @param {NonNegativeInteger} ndims - number of dimensions in the input array\n* @param {NonNegativeIntegerArray} shape - shape of the input array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n*/\nfunction flattenColexicographic( x, ndims, shape, out, stride, offset ) {\n\tvar len;\n\tvar tmp;\n\tvar ord;\n\tvar sh;\n\tvar sx;\n\tvar j;\n\tvar i;\n\n\t// Note that, in contrast to lexicographic iteration, we cannot readily define a straightforward recursive definition for colexicographic iteration. Accordingly, we have to perform a workaround in which we first flatten in lexicographic order and then perform an out-of-place transposition to return an array in colexicographic order.\n\n\t// Determine how many elements will be in the output array:\n\tlen = numel( shape );\n\n\t// For input arrays having an arbitrary number of dimensions, first flatten in lexicographic order:\n\ttmp = zeros( len );\n\trecurseLexicographic( x, ndims, shape, 0, tmp, 1, 0 );\n\n\t// Define the memory layout:\n\tord = 'row-major';\n\n\t// Generate a stride array for lexicographic order:\n\tsx = shape2strides( shape, ord );\n\n\t// Reverse the dimensions and strides (i.e., define the shape and strides of the transpose):\n\tsh = zeros( ndims );\n\tcopy( shape, ndims, sh, 1, 0 );\n\tgrev( ndims, sh, 1 );\n\tgrev( ndims, sx, 1 );\n\n\t// Iterate over each element based on the linear **view** index (note: this has negative performance implications due to lack of data locality)...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = vind2bind( sh, sx, 0, ord, i, MODE );\n\t\tout[ offset ] = tmp[ j ];\n\t\toffset += stride;\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Flattens an n-dimensional nested array and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten( x, shape, colexicographic, out, stride, offset ) {\n\tvar ndims = shape.length;\n\tif ( ndims === 0 ) { // 0-dimensional array\n\t\treturn out;\n\t}\n\tif ( ndims === 1 ) { // 1-dimensional array\n\t\t// For 1-dimensional arrays, we can perform a simple copy:\n\t\tcopy( x, shape[ 0 ], out, stride, offset );\n\t\treturn out;\n\t}\n\tif ( colexicographic ) {\n\t\tflattenColexicographic( x, ndims, shape, out, stride, offset );\n\t\treturn out;\n\t}\n\trecurseLexicographic( x, ndims, shape, 0, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport numel from '@stdlib/ndarray/base/numel';\nimport zeros from './../../../base/zeros';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Flattens an n-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @returns {Array} flattened array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten( x, shape, colexicographic ) {\n\tvar out = zeros( numel( shape ) );\n\treturn assign( x, shape, colexicographic, out, 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten an n-dimensional nested array.\n*\n* @module @stdlib/array/base/flatten\n*\n* @example\n* import flatten from '@stdlib/array/base/flatten';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import flatten from '@stdlib/array/base/flatten';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten from '@stdlib/array/base/flatten';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten.assign( x, [ 2, 2 ], true, out, 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray/base/shape2strides';\nimport vind2bind from '@stdlib/ndarray/base/vind2bind';\nimport numel from '@stdlib/ndarray/base/numel';\nimport grev from '@stdlib/blas/ext/base/grev';\nimport zeros from './../../../base/zeros';\nimport copy from './../../../base/copy-indexed';\n\n\n// VARIABLES //\n\nvar MODE = 'throw';\n\n\n// FUNCTIONS //\n\n/**\n* Copies a specified number of array elements to a provided array according to a callback function.\n*\n* @private\n* @param {Array} x - input array\n* @param {NonNegativeInteger} N - number of elements to copy\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0 ];\n* copyBy( x, 3, out, 1, 0, scale );\n*\n* var o = out;\n* // returns [ 2, 4, 6 ]\n*/\nfunction copyBy( x, N, out, stride, offset, clbk, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout[ offset ] = clbk.call( thisArg, x[ i ], [ i ], x );\n\t\toffset += stride;\n\t}\n}\n\n/**\n* Recursively flattens an array in lexicographic order.\n*\n* @private\n* @param {Array} orig - original input array\n* @param {Array} x - array to flatten\n* @param {NonNegativeInteger} ndims - number of dimensions in the input array\n* @param {NonNegativeIntegerArray} shape - shape of the input array\n* @param {NonNegativeInteger} dim - dimension index\n* @param {NonNegativeIntegerArray} indices - outer array element indices\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {NonNegativeInteger} offset for next output array element\n*/\nfunction recurseLexicographic( orig, x, ndims, shape, dim, indices, out, stride, offset, clbk, thisArg ) { // eslint-disable-line max-params\n\tvar FLG;\n\tvar idx;\n\tvar S;\n\tvar d;\n\tvar i;\n\n\t// Check whether we've reached the last dimension:\n\td = dim + 1;\n\tFLG = ( d === ndims );\n\n\tS = shape[ dim ];\n\tfor ( i = 0; i < S; i++ ) {\n\t\tidx = indices.slice(); // we explicitly copy in order to avoid potential mutation when calling `clbk`\n\t\tidx.push( i );\n\t\tif ( FLG ) {\n\t\t\tout[ offset ] = clbk.call( thisArg, x[ i ], idx, orig );\n\t\t\toffset += stride;\n\t\t} else {\n\t\t\toffset = recurseLexicographic( orig, x[ i ], ndims, shape, d, idx, out, stride, offset, clbk, thisArg );\n\t\t}\n\t}\n\treturn offset;\n}\n\n/**\n* Flattens an array in colexicographic order.\n*\n* @private\n* @param {Array} x - array to flatten\n* @param {NonNegativeInteger} ndims - number of dimensions in the input array\n* @param {NonNegativeIntegerArray} shape - shape of the input array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n*/\nfunction flattenColexicographic( x, ndims, shape, out, stride, offset, clbk, thisArg ) {\n\tvar len;\n\tvar tmp;\n\tvar ord;\n\tvar sh;\n\tvar sx;\n\tvar j;\n\tvar i;\n\n\t// Note that, in contrast to lexicographic iteration, we cannot readily define a straightforward recursive definition for colexicographic iteration. Accordingly, we have to perform a workaround in which we first flatten in lexicographic order and then perform an out-of-place transposition to return an array in colexicographic order.\n\n\t// Determine how many elements will be in the output array:\n\tlen = numel( shape );\n\n\t// For input arrays having an arbitrary number of dimensions, first flatten in lexicographic order:\n\ttmp = zeros( len );\n\trecurseLexicographic( x, x, ndims, shape, 0, [], tmp, 1, 0, clbk, thisArg );\n\n\t// Define the memory layout:\n\tord = 'row-major';\n\n\t// Generate a stride array for lexicographic order:\n\tsx = shape2strides( shape, ord );\n\n\t// Reverse the dimensions and strides (i.e., define the shape and strides of the transpose):\n\tsh = copy( shape );\n\tgrev( ndims, sh, 1 );\n\tgrev( ndims, sx, 1 );\n\n\t// Iterate over each element based on the linear **view** index (note: this has negative performance implications due to lack of data locality)...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = vind2bind( sh, sx, 0, ord, i, MODE );\n\t\tout[ offset ] = tmp[ j ];\n\t\toffset += stride;\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Flattens an n-dimensional nested array according to a callback function and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flattenBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) {\n\tvar ndims = shape.length;\n\tif ( ndims === 0 ) { // 0-dimensional array\n\t\treturn out;\n\t}\n\tif ( ndims === 1 ) { // 1-dimensional array\n\t\t// For 1-dimensional arrays, we can perform simple iteration:\n\t\tcopyBy( x, shape[ 0 ], out, stride, offset, clbk, thisArg );\n\t\treturn out;\n\t}\n\tif ( colexicographic ) {\n\t\tflattenColexicographic( x, ndims, shape, out, stride, offset, clbk, thisArg );\n\t\treturn out;\n\t}\n\trecurseLexicographic( x, x, ndims, shape, 0, [], out, stride, offset, clbk, thisArg );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flattenBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport numel from '@stdlib/ndarray/base/numel';\nimport zeros from './../../../base/zeros';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Flattens an n-dimensional nested array according to a callback function.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} flattened array\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flattenBy( x, shape, colexicographic, clbk, thisArg ) {\n\tvar out = zeros( numel( shape ) );\n\treturn assign( x, shape, colexicographic, out, 1, 0, clbk, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default flattenBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a two-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @returns {Array} flattened array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten2d( x, shape, colexicographic ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar a0;\n\n\t// Extract loop variables:\n\tS0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tout.push( x[ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ta0 = x[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tout.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a two-dimensional nested array according to a callback function.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} flattened array\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten2dBy( x, shape, colexicographic, clbk, thisArg ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar a0;\n\n\t// Extract loop variables:\n\tS0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tout.push( clbk.call( thisArg, x[ i1 ][ i0 ], [ i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ta0 = x[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tout.push( clbk.call( thisArg, a0[ i0 ], [ i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a three-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @returns {Array} flattened array\n*\n* @example\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten3d( x, shape, colexicographic ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar a0;\n\tvar a1;\n\n\t// Extract loop variables:\n\tS0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tout.push( x[ i2 ][ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = x[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta0 = a1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tout.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a three-dimensional nested array according to a callback function.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} flattened array\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten3dBy( x, shape, colexicographic, clbk, thisArg ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar a0;\n\tvar a1;\n\n\t// Extract loop variables:\n\tS0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tout.push( clbk.call( thisArg, x[ i2 ][ i1 ][ i0 ], [ i2, i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = x[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta0 = a1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tout.push( clbk.call( thisArg, a0[ i0 ], [ i2, i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten3dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a four-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @returns {Array} flattened array\n*\n* @example\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten4d( x, shape, colexicographic ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\n\t// Extract loop variables:\n\tS0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tout.push( x[ i3 ][ i2 ][ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = x[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = a2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tout.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a four-dimensional nested array according to a callback function.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} flattened array\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten4dBy( x, shape, colexicographic, clbk, thisArg ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\n\t// Extract loop variables:\n\tS0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tout.push( clbk.call( thisArg, x[ i3 ][ i2 ][ i1 ][ i0 ], [ i3, i2, i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = x[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = a2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tout.push( clbk.call( thisArg, a0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten4dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a five-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @returns {Array} flattened array\n*\n* @example\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten5d( x, shape, colexicographic ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\n\t// Extract loop variables:\n\tS0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\t\t\t\t\t\tout.push( x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = x[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = a3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = a2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tout.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth, max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a five-dimensional nested array according to a callback function.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} flattened array\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten5dBy( x, shape, colexicographic, clbk, thisArg ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\n\t// Extract loop variables:\n\tS0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\t\t\t\t\t\tout.push( clbk.call( thisArg, x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ], [ i4, i3, i2, i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = x[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = a3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = a2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tout.push( clbk.call( thisArg, a0[ i0 ], [ i4, i3, i2, i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten5dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the last dimension of a two-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject} x - nested input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ];\n*\n* var out = fliplr2d( x );\n* // returns [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ]\n*/\nfunction fliplr2d( x ) {\n\tvar out;\n\tvar x0;\n\tvar y0;\n\tvar i1;\n\tvar i0;\n\n\tout = [];\n\tfor ( i1 = 0; i1 < x.length; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = [];\n\t\tfor ( i0 = x0.length-1; i0 >= 0; i0-- ) {\n\t\t\ty0.push( x0[ i0 ] );\n\t\t}\n\t\tout.push( y0 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fliplr2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fliplr2d from './../../../base/fliplr2d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the last dimension of a three-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>} x - nested input array\n* @returns {Array>} output array\n*\n* @example\n* var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ];\n*\n* var out = fliplr3d( x );\n* // returns [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ]\n*/\nfunction fliplr3d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( fliplr2d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fliplr3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fliplr3d from './../../../base/fliplr3d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the last dimension of a four-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>>} x - nested input array\n* @returns {Array>>} output array\n*\n* @example\n* var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ];\n*\n* var out = fliplr4d( x );\n* // returns [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ]\n*/\nfunction fliplr4d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( fliplr3d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fliplr4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the first dimension of a two-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject} x - nested input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ];\n*\n* var out = flipud2d( x );\n* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ]\n*/\nfunction flipud2d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = x.length-1; i >= 0; i-- ) {\n\t\tout.push( x[ i ] );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flipud2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport flipud2d from './../../../base/flipud2d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the second-to-last dimension of a three-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>} x - nested input array\n* @returns {Array>} output array\n*\n* @example\n* var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ];\n*\n* var out = flipud3d( x );\n* // returns [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ]\n*/\nfunction flipud3d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( flipud2d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flipud3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport flipud3d from './../../../base/flipud3d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the second-to-last dimension of a four-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>>} x - nested input array\n* @returns {Array>>} output array\n*\n* @example\n* var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ];\n*\n* var out = flipud4d( x );\n* // returns [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ]\n*/\nfunction flipud4d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( flipud3d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flipud4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ceil from '@stdlib/math/base/special/ceil';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array according to a provided increment.\n*\n* @param {number} x1 - first array value\n* @param {number} x2 - array element bound\n* @param {number} increment - increment\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = incrspace( 0, 11, 2 );\n* // returns [ 0, 2, 4, 6, 8, 10 ]\n*/\nfunction incrspace( x1, x2, increment ) {\n\tvar arr;\n\tvar len;\n\tvar i;\n\n\tlen = ceil( ( x2-x1 ) / increment );\n\tif ( len <= 1 ) {\n\t\treturn [ x1 ];\n\t}\n\tarr = [ x1 ];\n\tfor ( i = 1; i < len; i++ ) {\n\t\tarr.push( x1 + (increment*i) );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default incrspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from './../../is-collection';\nimport isFunction from './../../is-function';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array-like object supporting the accessor (get/set) protocol.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is an accessor array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isAccessorArray( new Complex128Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isAccessorArray( [] );\n* // returns false\n*\n* @example\n* var bool = isAccessorArray( {} );\n* // returns false\n*/\nfunction isAccessorArray( value ) {\n\treturn (\n\t\tisCollection( value ) &&\n\t\tisFunction( value.get ) &&\n\t\tisFunction( value.set )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isAccessorArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is `undefined` or `null`.\n*\n* ## Notes\n*\n* - In older browsers, `undefined` is a global which can be overridden. `void`, however, is an operator which **cannot** be overridden. Consequently, better to use `void` to check for `undefined`. See [Stack Overflow][1].\n*\n* [1]: http://stackoverflow.com/a/19369078/2225624\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is undefined\n*\n* @example\n* var bool = isUndefinedOrNull( undefined );\n* // returns true\n*\n* bool = isUndefinedOrNull( null );\n* // returns true\n*\n* bool = isUndefinedOrNull( false );\n* // returns false\n*/\nfunction isUndefinedOrNull( value ) {\n\treturn ( value === void 0 || value === null );\n}\n\n\n// EXPORTS //\n\nexport default isUndefinedOrNull;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport pow from '@stdlib/math/base/special/pow';\n\n\n// MAIN //\n\n/**\n* Generates a logarithmically spaced numeric array.\n*\n* @param {number} a - exponent of start value\n* @param {number} b - exponent of end value\n* @param {NonNegativeInteger} len - length of output array\n* @returns {Array} logarithmically spaced numeric array\n*\n* @example\n* var arr = logspace( 0, 2, 6 );\n* // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ]\n*/\nfunction logspace( a, b, len ) {\n\tvar arr;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Calculate the increment:\n\tN = len - 1;\n\td = ( b-a ) / N;\n\n\t// Build the output array...\n\tarr = [ pow( 10, a ) ];\n\tfor ( i = 1; i < N; i++ ) {\n\t\tarr.push( pow( 10, a+(d*i) ) );\n\t}\n\tarr.push( pow( 10, b ) );\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default logspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a new two-dimensional nested output array.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = map2d( x, shape, scale );\n* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*/\nfunction map2d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar y;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\ty = [];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = [];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i1, i0 ], x ) );\n\t\t}\n\t\ty.push( y0 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a new three-dimensional nested output array.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = map3d( x, shape, scale );\n* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*/\nfunction map3d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar y;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\ty = [];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = [];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = [];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i2, i1, i0 ], x ) );\n\t\t\t}\n\t\t\ty1.push( y0 );\n\t\t}\n\t\ty.push( y1 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a new five-dimensional nested output array.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = map5d( x, shape, scale );\n* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*/\nfunction map5d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar x3;\n\tvar y3;\n\tvar y;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\ty = [];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = [];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = [];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = [];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = [];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i4, i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t\t}\n\t\t\t\t\ty1.push( y0 );\n\t\t\t\t}\n\t\t\t\ty2.push( y1 );\n\t\t\t}\n\t\t\ty3.push( y2 );\n\t\t}\n\t\ty.push( y3 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport INT8_MIN from '@stdlib/constants/int8/min';\nimport INT16_MIN from '@stdlib/constants/int16/min';\nimport INT32_MIN from '@stdlib/constants/int32/min';\nimport INT8_MAX from '@stdlib/constants/int8/max';\nimport INT16_MAX from '@stdlib/constants/int16/max';\nimport INT32_MAX from '@stdlib/constants/int32/max';\n\n\n// MAIN //\n\n/**\n* Returns the minimum array data type for storing a provided signed integer value.\n*\n* @param {integer} value - scalar value\n* @returns {string} array data type\n*\n* @example\n* var dt = minSignedIntegerDataType( 9999 );\n* // returns 'int16'\n*\n* @example\n* var dt = minSignedIntegerDataType( 3 );\n* // returns 'int8'\n*/\nfunction minSignedIntegerDataType( value ) {\n\tif ( value < 0 ) {\n\t\tif ( value >= INT8_MIN ) {\n\t\t\treturn 'int8';\n\t\t}\n\t\tif ( value >= INT16_MIN ) {\n\t\t\treturn 'int16';\n\t\t}\n\t\tif ( value >= INT32_MIN ) {\n\t\t\treturn 'int32';\n\t\t}\n\t\treturn 'float64';\n\t}\n\tif ( value <= INT8_MAX ) {\n\t\treturn 'int8';\n\t}\n\tif ( value <= INT16_MAX ) {\n\t\treturn 'int16';\n\t}\n\tif ( value <= INT32_MAX ) {\n\t\treturn 'int32';\n\t}\n\treturn 'float64';\n}\n\n\n// EXPORTS //\n\nexport default minSignedIntegerDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns a new array by applying a mask to a provided input array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*/\nfunction mskfilter( x, mask ) {\n\tvar xget;\n\tvar mget;\n\tvar out;\n\tvar i;\n\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tmget = resolveGetter( mask );\n\n\t// Extract each desired element from the provided array...\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mget( mask, i ) ) {\n\t\t\tout.push( xget( x, i ) ); // use `Array#push` to ensure \"fast\" elements\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default mskfilter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns a new array after applying a mask and a callback function to a provided input array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* function scale( val ) {\n* return 10 * val;\n* }\n*\n* var y = mskfilterMap( x, mask, scale );\n* // returns [ 20, 40 ]\n*/\nfunction mskfilterMap( x, mask, clbk, thisArg ) {\n\tvar xget;\n\tvar mget;\n\tvar out;\n\tvar i;\n\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tmget = resolveGetter( mask );\n\n\t// Extract each desired element from the provided array...\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mget( mask, i ) ) {\n\t\t\tout.push( clbk.call( thisArg, xget( x, i ), i, x ) ); // use `Array#push` to ensure \"fast\" elements\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default mskfilterMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpretComplex from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport countFalsy from './../../../base/count-falsy';\n\n\n// FUNCTIONS //\n\n/**\n* Replaces elements in an indexed array with provided values.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = [ 20, 30 ];\n*\n* var out = indexed( x, mask, values );\n* // returns [ 1, 20, 30, 4 ]\n*/\nfunction indexed( x, mask, values ) {\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !mask[ i ] ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tiv = ( iv+1 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n/**\n* Replaces elements of an accessor array with provided values.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} mask - mask array object\n* @param {Object} values - values object\n* @returns {Collection} input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var mask = toAccessorArray( [ 1, 0, 0, 1 ] );\n* var values = toAccessorArray( [ 20, 30 ] );\n*\n* var out = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( values ) );\n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* v = x.get( 1 );\n* // returns 20\n*/\nfunction accessors( x, mask, values ) {\n\tvar xdata;\n\tvar mdata;\n\tvar vdata;\n\tvar xset;\n\tvar mget;\n\tvar vget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\txdata = x.data;\n\tmdata = mask.data;\n\tvdata = values.data;\n\n\txset = x.accessors[ 1 ];\n\tmget = mask.accessors[ 0 ];\n\tvget = values.accessors[ 0 ];\n\n\tN = vdata.length;\n\tiv = 0;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( !mget( mdata, i ) ) {\n\t\t\txset( xdata, i, vget( vdata, iv ) );\n\t\t\tiv = ( iv+1 ) % N;\n\t\t}\n\t}\n\treturn xdata;\n}\n\n/**\n* Replaces elements in a complex array with provided values.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} mask - mask array object\n* @param {Collection} values - real-valued floating-point values array view\n* @returns {Collection} input array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n*\n* var mask = [ 0, 1, 0, 1 ];\n* var values = new Float64Array( [ 10.0, 20.0, 50.0, 60.0 ] );\n*\n* var out = complex( x, arraylike2object( mask ), values );\n* // returns [ 10.0, 20.0, 3.0, 4.0, 50.0, 60.0, 7.0, 8.0 ]\n*/\nfunction complex( x, mask, values ) {\n\tvar mdata;\n\tvar mget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( !mget( mdata, i/2 ) ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tx[ i+1 ] = values[ iv+1 ];\n\t\t\tiv = ( iv+2 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n/**\n* Replaces elements in a boolean array with provided values.\n*\n* @private\n* @param {Uint8Array} x - input array\n* @param {Object} mask - mask array object\n* @param {Uint8Array} values - values to set\n* @returns {Uint8Array} input array\n*\n* @example\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = new Uint8Array( [ 1, 1 ] );\n*\n* var out = boolean( x, arraylike2object( mask ), values );\n* // returns [ 1, 1, 1, 1 ]\n*/\nfunction boolean( x, mask, values ) {\n\tvar mdata;\n\tvar mget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !mget( mdata, i ) ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tiv = ( i+1 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n\n// MAIN //\n\n/**\n* Replaces elements of an array with provided values according to a provided mask array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @param {string} mode - string specifying behavior when the number of values does not equal the number of falsy mask values\n* @throws {Error} insufficient values to satisfy mask array\n* @throws {Error} number of values does not equal the number of falsy mask values\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = [ 20, 30 ];\n*\n* var out = mskput( x, mask, values, 'strict' );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = [ 30 ];\n*\n* var out = mskput( x, mask, values, 'strict_broadcast' );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 0, 1, 0 ];\n* var values = [ 20, 30 ];\n*\n* var out = mskput( x, mask, values, 'repeat' );\n* // returns [ 20, 30, 3, 20 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction mskput( x, mask, values, mode ) {\n\tvar xo;\n\tvar mo;\n\tvar vo;\n\tvar M;\n\n\tM = values.length;\n\tif ( mode === 'strict' ) {\n\t\tif ( countFalsy( mask ) !== M ) {\n\t\t\tthrow new Error( 'invalid arguments. Number of values does not equal the number of falsy values in the mask array.' );\n\t\t}\n\t} else if ( mode === 'broadcast' ) {\n\t\tif ( M !== 1 && countFalsy( mask ) > M ) {\n\t\t\tthrow new Error( 'invalid arguments. Insufficient values to satisfy mask array.' );\n\t\t}\n\t} else if ( mode === 'strict_broadcast' ) {\n\t\tif ( M !== 1 && countFalsy( mask ) !== M ) {\n\t\t\tthrow new Error( 'invalid arguments. Number of values does not equal the number of falsy values in the mask array.' );\n\t\t}\n\t} else if ( mode === 'non_strict' ) {\n\t\tif ( countFalsy( mask ) > M ) {\n\t\t\tthrow new Error( 'invalid arguments. Insufficient values to satisfy mask array.' );\n\t\t}\n\t}\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\tvo = arraylike2object( values );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\tvo.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support select dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif ( isComplexDataType( xo.dtype ) && isComplexDataType( vo.dtype ) ) {\n\t\t\tcomplex( reinterpretComplex( x, 0 ), mo, reinterpretComplex( values, 0 ) ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\tif ( isBooleanDataType( xo.dtype ) && isBooleanDataType( vo.dtype ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( values, 0 ) ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\taccessors( xo, mo, vo );\n\t\treturn x;\n\t}\n\tindexed( x, mask, values );\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default mskput;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns a new array by applying a mask to a provided input array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskreject( x, mask );\n* // returns [ 1, 3 ]\n*/\nfunction mskreject( x, mask ) {\n\tvar xget;\n\tvar mget;\n\tvar out;\n\tvar i;\n\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tmget = resolveGetter( mask );\n\n\t// Extract each desired element from the provided array...\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !mget( mask, i ) ) {\n\t\t\tout.push( xget( x, i ) ); // use `Array#push` to ensure \"fast\" elements\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default mskreject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a non-enumerable property.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* import objectKeys from '@stdlib/utils/keys';\n*\n* var obj = {};\n*\n* setNonEnumerableProperty( obj, 'foo', 'bar' );\n*\n* var v = obj.foo;\n* // returns 'bar'\n*\n* var keys = objectKeys( obj );\n* // returns []\n*/\nfunction setNonEnumerableProperty( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': true,\n\t\t'enumerable': false,\n\t\t'writable': true,\n\t\t'value': value\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setNonEnumerableProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether all elements in an array are falsy.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether all elements are falsy\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = internal( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 4 ];\n*\n* var out = internal( x );\n* // returns false\n*/\nfunction internal( x ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( x[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array are falsy.\n*\n* @private\n* @param {Object} x - input array object\n* @returns {boolean} boolean indicating whether all elements are falsy\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n*\n* var out = accessors( x );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 0, 4 ] ) );\n*\n* var out = accessors( x );\n* // returns false\n*/\nfunction accessors( x ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( get( data, i ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array are falsy.\n*\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether all elements are falsy\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = none( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 4 ];\n*\n* var out = none( x );\n* // returns false\n*/\nfunction none( x ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be falsy if both components are zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\treturn internal( reinterpret128( x, 0 ) );\n\t\t}\n\t\tif ( isComplex64Array( x ) ) {\n\t\t\treturn internal( reinterpret64( x, 0 ) );\n\t\t}\n\t\t// If provided a boolean array, reinterpret as a typed array and test whether all elements are false...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn internal( reinterpretBoolean( x, 0 ) );\n\t\t}\n\t\treturn accessors( obj );\n\t}\n\treturn internal( x );\n}\n\n\n// EXPORTS //\n\nexport default none;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from one.\n*\n* @param {number} n - number of elements\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = oneTo( 6 );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nfunction oneTo( n ) {\n\tvar arr;\n\tvar i;\n\n\tarr = [];\n\tif ( n <= 0 ) {\n\t\treturn arr;\n\t}\n\tfor ( i = 1; i < n+1; i++ ) {\n\t\tarr.push( i );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default oneTo;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n\n\n// FUNCTIONS //\n\n/**\n* Fills an indexed array with linearly spaced numeric elements which increment by 1 starting from one.\n*\n* @private\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = indexed( out, 1, 0 );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = indexed( out, -1, out.length-1 );\n* // returns [ 6, 5, 4, 3, 2, 1 ]\n*/\nfunction indexed( out, stride, offset ) {\n\tvar v;\n\tvar i;\n\n\ti = offset;\n\tv = 1;\n\twhile ( i >= 0 && i < out.length ) {\n\t\tout[ i ] = v;\n\t\ti += stride;\n\t\tv += 1;\n\t}\n\treturn out;\n}\n\n/**\n* Fills a complex number array with linearly spaced numeric elements which increment by 1 starting from one.\n*\n* @private\n* @param {(Complex128Array|Complex64Array)} out - output complex number array\n* @param {(Float64Array|Float32Array)} data - output array data\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {(Complex128Array|Complex64Array)} output array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\n*\n* var out = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );\n* // returns \n*\n* var data = reinterpret128( out, 0 );\n* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]\n*\n* var arr = complex( out, data, 1, 0 );\n* // returns \n*\n* var bool = ( arr === out );\n* // returns true\n*\n* data = reinterpret128( out, 0 );\n* returns [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ]\n*/\nfunction complex( out, data, stride, offset ) {\n\tvar v;\n\tvar s;\n\tvar i;\n\n\ts = stride * 2;\n\ti = offset * 2;\n\tv = 1.0;\n\twhile ( i >= 0 && i < data.length ) {\n\t\tdata[ i ] = v; // real component\n\t\tdata[ i+1 ] = 0.0; // imaginary component\n\t\ti += s;\n\t\tv += 1.0;\n\t}\n\treturn out;\n}\n\n/**\n* Fills an accessor array with linearly spaced numeric elements which increment by 1 starting from one.\n*\n* @private\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n\n* var out = toAccessorArray( [ 0, 0, 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( out ), 1, 0 );\n*\n* var bool = ( arr === out );\n* // returns true\n*\n* var v = out.get( 0 );\n* // returns 1\n*\n* v = out.get( out.length-1 );\n* // returns 6\n*/\nfunction accessors( out, stride, offset ) {\n\tvar data;\n\tvar set;\n\tvar v;\n\tvar i;\n\n\tdata = out.data;\n\tset = out.accessors[ 1 ];\n\n\ti = offset;\n\tv = 1;\n\twhile ( i >= 0 && i < data.length ) {\n\t\tset( data, i, v );\n\t\ti += stride;\n\t\tv += 1;\n\t}\n\treturn data;\n}\n\n\n// MAIN //\n\n/**\n* Fills an array with linearly spaced numeric elements which increment by 1 starting from one.\n*\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = assign( out, 1, 0 );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = assign( out, -1, out.length-1 );\n* // returns [ 6, 5, 4, 3, 2, 1 ]\n*/\nfunction assign( out, stride, offset ) {\n\tvar obj = arraylike2object( out );\n\tif ( obj.accessorProtocol ) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and only set the real components...\n\t\tif ( isComplex128Array( out ) ) {\n\t\t\treturn complex( out, reinterpret128( out, 0 ), stride, offset );\n\t\t}\n\t\tif ( isComplex64Array( out ) ) {\n\t\t\treturn complex( out, reinterpret64( out, 0 ), stride, offset );\n\t\t}\n\t\treturn accessors( obj, stride, offset );\n\t}\n\treturn indexed( out, stride, offset );\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpretComplex from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport countTruthy from './../../../base/count-truthy';\n\n\n// FUNCTIONS //\n\n/**\n* Replaces elements in an indexed array with provided values.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 1, 1, 0 ];\n* var values = [ 20, 30 ];\n*\n* var out = indexed( x, mask, values );\n* // returns [ 1, 20, 30, 4 ]\n*/\nfunction indexed( x, mask, values ) {\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mask[ i ] ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tiv = ( iv+1 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n/**\n* Replaces elements of an accessor array with provided values.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} mask - mask array object\n* @param {Object} values - values object\n* @returns {Collection} input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var mask = toAccessorArray( [ 0, 1, 1, 0 ] );\n* var values = toAccessorArray( [ 20, 30 ] );\n*\n* var out = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( values ) );\n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* v = x.get( 1 );\n* // returns 20\n*/\nfunction accessors( x, mask, values ) {\n\tvar xdata;\n\tvar mdata;\n\tvar vdata;\n\tvar xset;\n\tvar mget;\n\tvar vget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\txdata = x.data;\n\tmdata = mask.data;\n\tvdata = values.data;\n\n\txset = x.accessors[ 1 ];\n\tmget = mask.accessors[ 0 ];\n\tvget = values.accessors[ 0 ];\n\n\tN = vdata.length;\n\tiv = 0;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\txset( xdata, i, vget( vdata, iv ) );\n\t\t\tiv = ( iv+1 ) % N;\n\t\t}\n\t}\n\treturn xdata;\n}\n\n/**\n* Replaces elements in a complex array with provided values.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} mask - mask array object\n* @param {Collection} values - real-valued floating-point values array view\n* @returns {Collection} input array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n*\n* var mask = [ 1, 0, 1, 0 ];\n* var values = new Float64Array( [ 10.0, 20.0, 50.0, 60.0 ] );\n*\n* var out = complex( x, arraylike2object( mask ), values );\n* // returns [ 10.0, 20.0, 3.0, 4.0, 50.0, 60.0, 7.0, 8.0 ]\n*/\nfunction complex( x, mask, values ) {\n\tvar mdata;\n\tvar mget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( mget( mdata, i/2 ) ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tx[ i+1 ] = values[ iv+1 ];\n\t\t\tiv = ( iv+2 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n/**\n* Replaces elements in a boolean array with provided values.\n*\n* @private\n* @param {Uint8Array} x - input array\n* @param {Object} mask - mask array object\n* @param {Uint8Array} values - values to set\n* @returns {Uint8Array} input array\n*\n* @example\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var x = new Uint8Array( [ 0, 1, 1, 0 ] );\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = new Uint8Array( [ 1, 1 ] );\n*\n* var out = boolean( x, arraylike2object( mask ), values );\n* // returns [ 1, 1, 1, 1 ]\n*/\nfunction boolean( x, mask, values ) {\n\tvar mdata;\n\tvar mget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tiv = ( i+1 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n\n// MAIN //\n\n/**\n* Replaces elements of an array with provided values according to a provided mask array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @param {string} mode - string specifying behavior when the number of values does not equal the number of truthy mask values\n* @throws {Error} insufficient values to satisfy mask array\n* @throws {Error} number of values does not equal the number of truthy mask values\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 1, 1, 0 ];\n* var values = [ 20, 30 ];\n*\n* var out = place( x, mask, values, 'strict' );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 1, 1, 0 ];\n* var values = [ 30 ];\n*\n* var out = place( x, mask, values, 'strict_broadcast' );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 1, 0, 1 ];\n* var values = [ 20, 30 ];\n*\n* var out = place( x, mask, values, 'repeat' );\n* // returns [ 20, 30, 3, 20 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction place( x, mask, values, mode ) {\n\tvar xo;\n\tvar mo;\n\tvar vo;\n\tvar M;\n\n\tM = values.length;\n\tif ( mode === 'strict' ) {\n\t\tif ( countTruthy( mask ) !== M ) {\n\t\t\tthrow new Error( 'invalid arguments. Number of values does not equal the number of truthy values in the mask array.' );\n\t\t}\n\t} else if ( mode === 'broadcast' ) {\n\t\tif ( M !== 1 && countTruthy( mask ) > M ) {\n\t\t\tthrow new Error( 'invalid arguments. Insufficient values to satisfy mask array.' );\n\t\t}\n\t} else if ( mode === 'strict_broadcast' ) {\n\t\tif ( M !== 1 && countTruthy( mask ) !== M ) {\n\t\t\tthrow new Error( 'invalid arguments. Number of values does not equal the number of truthy values in the mask array.' );\n\t\t}\n\t} else if ( mode === 'non_strict' ) {\n\t\tif ( countTruthy( mask ) > M ) {\n\t\t\tthrow new Error( 'invalid arguments. Insufficient values to satisfy mask array.' );\n\t\t}\n\t}\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\tvo = arraylike2object( values );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\tvo.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support select dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif ( isComplexDataType( xo.dtype ) && isComplexDataType( vo.dtype ) ) {\n\t\t\tcomplex( reinterpretComplex( x, 0 ), mo, reinterpretComplex( values, 0 ) ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\tif ( isBooleanDataType( xo.dtype ) && isBooleanDataType( vo.dtype ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( values, 0 ) ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\taccessors( xo, mo, vo );\n\t\treturn x;\n\t}\n\tindexed( x, mask, values );\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default place;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Restricts an index to the interval `[0,max]`.\n*\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @returns {NonNegativeInteger} index\n*\n* @example\n* var idx = clampIndex( -1, 10 );\n* // returns 0\n*\n* idx = clampIndex( 15, 10 );\n* // returns 10\n*\n* idx = clampIndex( 5, 10 );\n* // returns 5\n*/\nfunction clampIndex( idx, max ) {\n\tif ( idx < 0 ) {\n\t\treturn 0;\n\t}\n\tif ( idx > max ) {\n\t\treturn max;\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default clampIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Wraps an index on the interval `[0,max]`.\n*\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @returns {NonNegativeInteger} index\n*\n* @example\n* var idx = wrapIndex( -1, 10 );\n* // returns 10\n*\n* idx = wrapIndex( 13, 10 );\n* // returns 2\n*\n* idx = wrapIndex( 6, 10 );\n* // returns 6\n*/\nfunction wrapIndex( idx, max ) {\n\tvar mp1 = max + 1;\n\tif ( idx < 0 ) {\n\t\tidx += mp1; // slight optimization to avoid modulo arithmetic when |idx| <= max+1\n\t\tif ( idx < 0 ) {\n\t\t\tidx %= mp1;\n\t\t\tif ( idx !== 0 ) {\n\t\t\t\tidx += mp1;\n\t\t\t}\n\t\t}\n\t\treturn idx;\n\t}\n\tif ( idx > max ) {\n\t\tidx -= mp1; // slight optimization to avoid modulo arithmetic when max+1 < idx <= 2*(max+1)\n\t\tif ( idx > max ) {\n\t\t\tidx %= mp1;\n\t\t}\n\t\treturn idx;\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default wrapIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Normalizes an index to the interval `[0,max]`.\n*\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @returns {integer} index\n*\n* @example\n* var idx = normalizeIndex( -2, 10 );\n* // returns 9\n*\n* idx = normalizeIndex( 15, 10 );\n* // returns -1\n*\n* idx = normalizeIndex( 5, 10 );\n* // returns 5\n*/\nfunction normalizeIndex( idx, max ) {\n\tif ( idx < 0 ) {\n\t\tidx += max + 1;\n\t\tif ( idx < 0 ) {\n\t\t\treturn -1;\n\t\t}\n\t\treturn idx;\n\t}\n\tif ( idx > max ) {\n\t\treturn -1;\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default normalizeIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../../base/accessor-getter';\nimport dtype from './../../../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a function to tests if an array contains a provided search value.\n*\n* @param {Collection} x - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {Function} function to test if an array contains a search value\n*\n* @example\n* var contains = factory( [ 1, 2, 3 ] );\n* // returns \n*\n* var bool = contains( 2 );\n* // returns true\n*/\nfunction factory( x ) {\n\tvar get;\n\tvar len;\n\tvar dt;\n\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', x ) );\n\t}\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Resolve an accessor for retrieving input array elements:\n\tif ( isAccessorArray( x ) ) {\n\t\tget = accessorGetter( dt );\n\t}\n\t// Get the number of elements over which to iterate:\n\tlen = x.length;\n\n\treturn ( get === void 0 ) ? contains : accessors;\n\t/**\n\t* Tests if an array contains a provided search value.\n\t*\n\t* @private\n\t* @param {*} value - search value\n\t* @returns {boolean} boolean indicating if an array contains a search value\n\t*\n\t* @example\n\t* var out = contains( [ 1, 2, 3 ], 2 );\n\t* // returns true\n\t*/\n\tfunction contains( value ) {\n\t\tvar i;\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( x[ i ] === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t* Tests if an array contains a provided search value.\n\t*\n\t* @private\n\t* @param {*} value - search value\n\t* @returns {boolean} boolean indicating if an array contains a search value\n\t*/\n\tfunction accessors( value ) {\n\t\tvar i;\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( get( x, i ) === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten an n-dimensional nested array according to a callback function.\n*\n* @module @stdlib/array/base/flatten-by\n*\n* @example\n* import flattenBy from '@stdlib/array/base/flatten-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import flattenBy from '@stdlib/array/base/flatten-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flattenBy from '@stdlib/array/base/flatten-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flattenBy.assign( x, [ 2, 2 ], true, out, 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a two-dimensional nested array.\n*\n* @module @stdlib/array/base/flatten2d\n*\n* @example\n* import flatten2d from '@stdlib/array/base/flatten2d';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import flatten2d from '@stdlib/array/base/flatten2d';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten2d from '@stdlib/array/base/flatten2d';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten2d.assign( x, [ 2, 2 ], true, out, 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a two-dimensional nested array and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten2d( x, shape, colexicographic, out, stride, offset ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar a0;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tout[ io ] = x[ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\tio += stride;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ta0 = x[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tout[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a two-dimensional nested array according to a callback function.\n*\n* @module @stdlib/array/base/flatten2d-by\n*\n* @example\n* import flatten2dBy from '@stdlib/array/base/flatten2d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import flatten2dBy from '@stdlib/array/base/flatten2d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten2dBy from '@stdlib/array/base/flatten2d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten2dBy( x, [ 2, 2 ], true, out, 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a two-dimensional nested array according to a callback function and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten2dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) { // eslint-disable-line max-len\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar a0;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tout[ io ] = clbk.call( thisArg, x[ i1 ][ i0 ], [ i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\tio += stride;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ta0 = x[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tout[ io ] = clbk.call( thisArg, a0[ i0 ], [ i1, i0 ], x ); // equivalent to storing in row-major (C-style) order\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a three-dimensional nested array.\n*\n* @module @stdlib/array/base/flatten3d\n*\n* @example\n* import flatten3d from '@stdlib/array/base/flatten3d';\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import flatten3d from '@stdlib/array/base/flatten3d';\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten3d from '@stdlib/array/base/flatten3d';\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten3d.assign( x, [ 2, 1, 2 ], true, out, 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*\n* var bool = ( y === out );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a three-dimensional nested array and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], false, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], true, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten3d( x, shape, colexicographic, out, stride, offset ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar a0;\n\tvar a1;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tout[ io ] = x[ i2 ][ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\tio += stride;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = x[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta0 = a1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tout[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order\n\t\t\t\tio += stride;\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a three-dimensional nested array according to a callback function.\n*\n* @module @stdlib/array/base/flatten3d-by\n*\n* @example\n* import flatten3dBy from '@stdlib/array/base/flatten3d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import flatten3dBy from '@stdlib/array/base/flatten3d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten3dBy from '@stdlib/array/base/flatten3d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten3dBy.assign( x, [ 2, 1, 2 ], true, out, 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* var bool = ( y === out );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a three-dimensional nested array according to a callback function and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], false, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], true, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten3dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar a0;\n\tvar a1;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tout[ io ] = clbk.call( thisArg, x[ i2 ][ i1 ][ i0 ], [ i2, i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\tio += stride;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = x[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta0 = a1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tout[ io ] = clbk.call( thisArg, a0[ i0 ], [ i2, i1, i0 ], x ); // equivalent to storing in row-major (C-style) order\n\t\t\t\tio += stride;\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten3dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a four-dimensional nested array.\n*\n* @module @stdlib/array/base/flatten4d\n*\n* @example\n* import flatten4d from '@stdlib/array/base/flatten4d';\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import flatten4d from '@stdlib/array/base/flatten4d';\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten4d from '@stdlib/array/base/flatten4d';\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten4d.assign( x, [ 2, 1, 1, 2 ], true, out, 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a four-dimensional nested array and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten4d( x, shape, colexicographic, out, stride, offset ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tout[ io ] = x[ i3 ][ i2 ][ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\tio += stride;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = x[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = a2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tout[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order\n\t\t\t\t\tio += stride;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a four-dimensional nested array according to a callback function.\n*\n* @module @stdlib/array/base/flatten4d-by\n*\n* @example\n* import flatten4dBy from '@stdlib/array/base/flatten4d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import flatten4dBy from '@stdlib/array/base/flatten4d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten4dBy from '@stdlib/array/base/flatten4d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten4dBy.assign( x, [ 2, 1, 1, 2 ], true, out, 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a four-dimensional nested array according to a callback function and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten4dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tout[ io ] = clbk.call( thisArg, x[ i3 ][ i2 ][ i1 ][ i0 ], [ i3, i2, i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\tio += stride;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = x[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = a2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tout[ io ] = clbk.call( thisArg, a0[ i0 ], [ i3, i2, i1, i0 ], x ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t\tio += stride;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten4dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a five-dimensional nested array.\n*\n* @module @stdlib/array/base/flatten5d\n*\n* @example\n* import flatten5d from '@stdlib/array/base/flatten5d';\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import flatten5d from '@stdlib/array/base/flatten5d';\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten5d from '@stdlib/array/base/flatten5d';\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], true, out, 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a five-dimensional nested array and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten5d( x, shape, colexicographic, out, stride, offset ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\t\t\t\t\t\tout[ io ] = x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\t\tio += stride;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = x[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = a3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = a2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tout[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order\n\t\t\t\t\t\tio += stride;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a five-dimensional nested array according to a callback function.\n*\n* @module @stdlib/array/base/flatten5d-by\n*\n* @example\n* import flatten5dBy from '@stdlib/array/base/flatten5d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import flatten5dBy from '@stdlib/array/base/flatten5d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten5dBy from '@stdlib/array/base/flatten5d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], true, out, 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth, max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a five-dimensional nested array according to a callback function and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten5dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\t\t\t\t\t\tout[ io ] = clbk.call( thisArg, x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ], [ i4, i3, i2, i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\t\tio += stride;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = x[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = a3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = a2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tout[ io ] = clbk.call( thisArg, a0[ i0 ], [ i4, i3, i2, i1, i0 ], x ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t\t\tio += stride;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten5dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a two-dimensional nested input array and assign results to elements in a new two-dimensional nested output array.\n*\n* @module @stdlib/array/base/map2d\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import map2d from '@stdlib/array/base/map2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = map2d( x, shape, scale );\n* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import map2d from '@stdlib/array/base/map2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = zeros2d( shape );\n*\n* var out = map2d.assign( x, y, shape, scale );\n* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = zeros2d( shape );\n*\n* var out = map2d( x, y, shape, scale );\n* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map2d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i1, i0 ], x );\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a three-dimensional nested input array and assign results to elements in a new three-dimensional nested output array.\n*\n* @module @stdlib/array/base/map3d\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import map3d from '@stdlib/array/base/map3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = map3d( x, shape, scale );\n* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import map3d from '@stdlib/array/base/map3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = zeros3d( shape );\n*\n* var out = map3d.assign( x, y, shape, scale );\n* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = zeros3d( shape );\n*\n* var out = map3d( x, y, shape, scale );\n* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map3d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i2, i1, i0 ], x );\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array/base/map4d\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import map4d from '@stdlib/array/base/map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import map4d from '@stdlib/array/base/map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a five-dimensional nested input array and assign results to elements in a new five-dimensional nested output array.\n*\n* @module @stdlib/array/base/map5d\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import map5d from '@stdlib/array/base/map5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = map5d( x, shape, scale );\n* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import map5d from '@stdlib/array/base/map5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = zeros5d( shape );\n*\n* var out = map5d.assign( x, y, shape, scale );\n* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = zeros5d( shape );\n*\n* var out = map5d( x, y, shape, scale );\n* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map5d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar x3;\n\tvar y3;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i4, i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array/base/mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array/base/mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array/base/mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array.\n*\n* @private\n* @param {Collection} x - input array\n* @param {IntegerArray} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n*\n* var arr = indexed( x, mask, out, 1, 0 );\n* // returns [ 2, 4, 0, 0 ]\n*/\nfunction indexed( x, mask, out, stride, offset ) {\n\tvar io;\n\tvar i;\n\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mask[ i ] ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} mask - mask array object\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var mask = toAccessorArray( [ 0, 1, 0, 1 ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 2\n*\n* v = arr.get( 1 );\n* // returns 4\n*/\nfunction accessors( x, mask, out, stride, offset ) {\n\tvar xdata;\n\tvar mdata;\n\tvar odata;\n\tvar xget;\n\tvar mget;\n\tvar oset;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tmdata = mask.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\tmget = mask.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\toset( odata, io, xget( xdata, i ) );\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn odata;\n}\n\n/**\n* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Float64Array( 8 );\n*\n* var arr = complex( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask and a callback function to a provided input array.\n*\n* @module @stdlib/array/base/mskfilter-map\n*\n* @example\n* import mskfilterMap from '@stdlib/array/base/mskfilter-map';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* function scale( val ) {\n* return 10 * val;\n* }\n*\n* var y = mskfilterMap( x, mask, scale );\n* // returns [ 20, 40 ]\n*\n* @example\n* import mskfilterMap from '@stdlib/array/base/mskfilter-map';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* function scale( val ) {\n* return 10 * val;\n* }\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale );\n* // returns [ 20, 40 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Applies a mask and a callback function to an indexed array and assigns results to elements in an indexed output array.\n*\n* @private\n* @param {Collection} x - input array\n* @param {IntegerArray} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - function to apply\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n*\n* function scale( x ) {\n* return x * 10;\n* }\n*\n* var arr = indexed( x, mask, out, 1, 0, scale );\n* // returns [ 20, 40, 0, 0 ]\n*/\nfunction indexed( x, mask, out, stride, offset, clbk, thisArg ) {\n\tvar io;\n\tvar i;\n\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mask[ i ] ) {\n\t\t\tout[ io ] = clbk.call( thisArg, x[ i ], i, x );\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask and a callback function to an input accessor array and assigns results to elements in an output accessor array.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} mask - mask array object\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - function to apply\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var mask = toAccessorArray( [ 0, 1, 0, 1 ] );\n*\n* function scale( x ) {\n* return x * 10;\n* }\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0, scale );\n*\n* var v = arr.get( 0 );\n* // returns 20\n*\n* v = arr.get( 1 );\n* // returns 40\n*/\nfunction accessors( x, mask, out, stride, offset, clbk, thisArg ) {\n\tvar xdata;\n\tvar mdata;\n\tvar odata;\n\tvar xget;\n\tvar mget;\n\tvar oset;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tmdata = mask.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\tmget = mask.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\toset( odata, io, clbk.call( thisArg, xget( xdata, i ), i, xdata ) );\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn odata;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask and a callback function to a provided input array and assigns results to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - function to apply\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* function scale( x ) {\n* return x * 10;\n* }\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0, scale );\n* // returns [ 20, 40 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset, clbk, thisArg ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\taccessors( xo, mo, oo, stride, offset, clbk, thisArg );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset, clbk, thisArg );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array/base/mskreject\n*\n* @example\n* import mskreject from '@stdlib/array/base/mskreject';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskreject( x, mask );\n* // returns [ 1, 3 ]\n*\n* @example\n* import mskreject from '@stdlib/array/base/mskreject';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskreject.assign( x, mask, out, 1, 0 );\n* // returns [ 1, 3 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array.\n*\n* @private\n* @param {Collection} x - input array\n* @param {IntegerArray} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n*\n* var arr = indexed( x, mask, out, 1, 0 );\n* // returns [ 1, 3, 0, 0 ]\n*/\nfunction indexed( x, mask, out, stride, offset ) {\n\tvar io;\n\tvar i;\n\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !mask[ i ] ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} mask - mask array object\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var mask = toAccessorArray( [ 0, 1, 0, 1 ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* v = arr.get( 1 );\n* // returns 3\n*/\nfunction accessors( x, mask, out, stride, offset ) {\n\tvar xdata;\n\tvar mdata;\n\tvar odata;\n\tvar xget;\n\tvar mget;\n\tvar oset;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tmdata = mask.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\tmget = mask.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( !mget( mdata, i ) ) {\n\t\t\toset( odata, io, xget( xdata, i ) );\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn odata;\n}\n\n/**\n* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Float64Array( 8 );\n*\n* var arr = complex( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 1.0, 2.0, 5.0, 6.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( !mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 1, 0, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( !mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 1, 3 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Generate a linearly spaced numeric array whose elements increment by 1 starting from one.\n*\n* @module @stdlib/array/base/one-to\n*\n* @example\n* import oneTo from '@stdlib/array/base/one-to';\n*\n* var arr = oneTo( 6 );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*\n* @example\n* import oneTo from '@stdlib/array/base/one-to';\n*\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n* var arr = oneTo.assign( out, 1, 0 );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*\n* var bool = ( out === arr );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if an array contains a provided search value.\n*\n* @module @stdlib/array/base/assert/contains\n*\n* @example\n* import contains from '@stdlib/array/base/assert/contains';\n*\n* var out = contains( [ 1, 2, 3 ], 2 );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"factory\": \"main.factory\" }\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../../base/accessor-getter';\nimport getter from './../../../../base/getter';\nimport dtype from './../../../../dtype';\n\n\n// MAIN //\n\n/**\n* Tests if an array contains a provided search value.\n*\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {boolean} boolean indicating if an array contains a search value\n*\n* @example\n* var out = contains( [ 1, 2, 3 ], 2 );\n* // returns true\n*/\nfunction contains( x, value ) {\n\tvar len;\n\tvar get;\n\tvar dt;\n\tvar i;\n\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Resolve an accessor for retrieving input array elements:\n\tif ( isAccessorArray( x ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\t// Get the number of elements over which to iterate:\n\tlen = x.length;\n\n\t// Loop over the elements...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( get( x, i ) === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default contains;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport MODES from './modes.json';\n\n\n// MAIN //\n\n/**\n* Returns a list of ndarray index modes.\n*\n* @returns {StringArray} list of ndarray index modes\n*\n* @example\n* var list = modes();\n* // returns [ 'throw', 'normalize', 'clamp', 'wrap' ]\n*/\nfunction modes() {\n\treturn MODES.slice();\n}\n\n\n// EXPORTS //\n\nexport default modes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return a list of ndarray index modes.\n*\n* @module @stdlib/ndarray/index-modes\n*\n* @example\n* import modes from '@stdlib/ndarray/index-modes';\n*\n* var list = modes();\n* // returns [ 'throw', 'normalize', 'clamp', 'wrap' ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport modes from './main.js';\nimport enumeration from './enum.js';\n\n\n// MAIN //\n\nsetReadOnly( modes, 'enum', enumeration );\n\n\n// EXPORTS //\n\nexport default modes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an object mapping supported index modes to integer values for purposes of C inter-operation.\n*\n* ## Notes\n*\n* - Downstream consumers of this mapping should **not** rely on specific integer values (e.g., `throw == 1`). Instead, the object should be used in an opaque manner.\n* - The main purpose of this function is JavaScript and C inter-operation of ndarray objects.\n*\n* @returns {Object} object mapping supported index modes to integer values\n*\n* @example\n* var table = enumerated();\n* // returns \n*/\nfunction enumerated() {\n\t// NOTE: the following should match the C `index_modes.h` enumeration!!!!\n\treturn {\n\t\t'throw': 1,\n\t\t'clamp': 2,\n\t\t'wrap': 3,\n\t\t'normalize': 4\n\t};\n}\n\n\n// EXPORTS //\n\nexport default enumerated;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from '@stdlib/array/base/assert/contains';\nimport modes from './../../../../index-modes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported ndarray index mode.\n*\n* @name isIndexMode\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported ndarray index mode\n*\n* @example\n* var bool = isIndexMode( 'wrap' );\n* // returns true\n*\n* bool = isIndexMode( 'clamp' );\n* // returns true\n*\n* bool = isIndexMode( 'throw' );\n* // returns true\n*\n* bool = isIndexMode( 'foo' );\n* // returns false\n*/\nvar isIndexMode = contains( modes() );\n\n\n// EXPORTS //\n\nexport default isIndexMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport clampIndex from './../../../base/clamp-index';\nimport wrapIndex from './../../../base/wrap-index';\nimport normalize from './../../../base/normalize-index';\nimport isIndexMode from './../../../base/assert/is-index-mode';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar TABLE = {\n\t'wrap': wrapIndex,\n\t'clamp': clampIndex,\n\t'normalize': normalizeIndex,\n\t'throw': throwIfOutOfBounds\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an index if within bounds and throw an error otherwise.\n*\n* @private\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @throws {RangeError} index out-of-bounds\n* @returns {integer} index\n*\n* @example\n* var idx = throwIfOutOfBounds( 2, 9 );\n* // returns 2\n*\n* idx = throwIfOutOfBounds( 10, 9 );\n* // throws \n*\n* idx = throwIfOutOfBounds( -1, 9 );\n* // throws \n*/\nfunction throwIfOutOfBounds( idx, max ) {\n\tif ( idx < 0 || idx > max ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.', max, idx ) );\n\t}\n\treturn idx;\n}\n\n/**\n* Normalizes an index before performing a strict bounds check.\n*\n* @private\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @throws {RangeError} index out-of-bounds\n* @returns {integer} index\n*\n* @example\n* var idx = normalizeIndex( 1, 10 );\n* // returns 1\n*\n* idx = normalizeIndex( -4, 10 );\n* // returns 7\n*\n* idx = normalizeIndex( -100, 10 );\n* // throws \n*/\nfunction normalizeIndex( idx, max ) {\n\tvar index = normalize( idx, max );\n\tif ( index < 0 || index > max ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.', max, idx ) );\n\t}\n\treturn index;\n}\n\n\n// MAIN //\n\n/**\n* Returns a function for returning an index according to a provided index mode.\n*\n* @param {string} mode - specifies how to handle an out-of-bounds index\n* @throws {TypeError} first argument must be a recognized index mode\n* @returns {Function} function for returning an index\n*\n* @example\n* var ind = factory( 'clamp' );\n*\n* var idx = ind( 2, 9 );\n* // returns 2\n*\n* idx = ind( 10, 9 );\n* // returns 9\n*\n* idx = ind( -1, 9 );\n* // returns 0\n*\n* @example\n* var ind = factory( 'wrap' );\n*\n* var idx = ind( 2, 9 );\n* // returns 2\n*\n* idx = ind( 10, 9 );\n* // returns 0\n*\n* idx = ind( -1, 9 );\n* // returns 9\n*\n* @example\n* var ind = factory( 'throw' );\n*\n* var idx = ind( 2, 9 );\n* // returns 2\n*\n* idx = ind( 10, 9 );\n* // throws \n*\n* idx = ind( -1, 9 );\n* // throws \n*\n* @example\n* var ind = factory( 'normalize' );\n*\n* var idx = ind( 1, 10 );\n* // returns 1\n*\n* idx = ind( -4, 10 );\n* // returns 7\n*\n* idx = ind( -100, 10 );\n* // throws \n*/\nfunction factory( mode ) {\n\tif ( !isIndexMode( mode ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a recognized index mode. Value: `%s`.', mode ) );\n\t}\n\treturn TABLE[ mode ];\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpretComplex from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport { factory as ind } from '@stdlib/ndarray/base/ind';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Replaces elements in an indexed array with provided values.\n*\n* @private\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {Collection} values - values to set\n* @param {NonNegativeInteger} stride - index stride for accessing elements in `values`\n* @param {Function} getIndex - function for resolving an array index\n* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive)\n* @returns {Collection} input array\n*\n* @example\n* import { factory as ind } from '@stdlib/ndarray/base/ind';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 3, 1, 2, 0 ];\n* var values = [ 5, 6, 7, 8 ];\n*\n* var getIndex = ind( 'throw' );\n*\n* var out = indexed( x, indices, values, 1, getIndex, x.length-1 );\n* // returns [ 8, 6, 7, 5 ]\n*/\nfunction indexed( x, indices, values, stride, getIndex, maxIndex ) {\n\tvar iv;\n\tvar i;\n\tvar j;\n\n\tiv = 0;\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\tj = getIndex( indices[ i ], maxIndex );\n\t\tx[ j ] = values[ iv ];\n\t\tiv += stride;\n\t}\n\treturn x;\n}\n\n/**\n* Replaces specified elements of an accessor array with provided values.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} indices - index object\n* @param {Object} values - values object\n* @param {NonNegativeInteger} stride - index stride for accessing elements in `values`\n* @param {Function} getIndex - function for resolving an array index\n* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive)\n* @returns {Collection} input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import { factory as ind } from '@stdlib/ndarray/base/ind';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var indices = toAccessorArray( [ 1, 2 ] );\n* var values = toAccessorArray( [ 20, 30 ] );\n*\n* var getIndex = ind( 'throw' );\n*\n* var out = accessors( arraylike2object( x ), arraylike2object( indices ), arraylike2object( values ), 1, getIndex, x.length-1 );\n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* v = x.get( 1 );\n* // returns 20\n*/\nfunction accessors( x, indices, values, stride, getIndex, maxIndex ) {\n\tvar xdata;\n\tvar idata;\n\tvar vdata;\n\tvar xset;\n\tvar iget;\n\tvar vget;\n\tvar iv;\n\tvar i;\n\tvar j;\n\n\txdata = x.data;\n\tidata = indices.data;\n\tvdata = values.data;\n\n\txset = x.accessors[ 1 ];\n\tiget = indices.accessors[ 0 ];\n\tvget = values.accessors[ 0 ];\n\n\tiv = 0;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), maxIndex );\n\t\txset( xdata, j, vget( vdata, iv ) );\n\t\tiv += stride;\n\t}\n\treturn xdata;\n}\n\n/**\n* Replaces elements in a complex array with provided values.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} indices - index array object\n* @param {Collection} values - real-valued floating-point values array view\n* @param {NonNegativeInteger} stride - index stride for accessing elements in `values`\n* @param {Function} getIndex - function for resolving an array index\n* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive)\n* @returns {Collection} input array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import { factory as ind } from '@stdlib/ndarray/base/ind';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n*\n* var indices = [ 0, 2 ];\n* var values = new Float64Array( [ 10.0, 20.0, 50.0, 60.0 ] );\n*\n* var getIndex = ind( 'throw' );\n*\n* var out = complex( x, arraylike2object( indices ), values, 1, getIndex, x.length-1 );\n* // returns [ 10.0, 20.0, 3.0, 4.0, 50.0, 60.0, 7.0, 8.0 ]\n*/\nfunction complex( x, indices, values, stride, getIndex, maxIndex ) {\n\tvar idata;\n\tvar iget;\n\tvar iv;\n\tvar sv;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tidata = indices.data;\n\tiget = indices.accessors[ 0 ];\n\n\tsv = stride * 2; // note: multiply by 2, as real-valued values array consists of interleaved real and imaginary components\n\tiv = 0;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), maxIndex );\n\t\tk = j * 2;\n\t\tx[ k ] = values[ iv ];\n\t\tx[ k+1 ] = values[ iv+1 ];\n\t\tiv += sv;\n\t}\n\treturn x;\n}\n\n/**\n* Replaces elements in a boolean array with provided values.\n*\n* @private\n* @param {Uint8Array} x - input array\n* @param {Object} indices - index array object\n* @param {Uint8Array} values - values to set\n* @param {NonNegativeInteger} stride - index stride for accessing elements in `values`\n* @param {Function} getIndex - function for resolving an array index\n* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive)\n* @returns {Uint8Array} input array\n*\n* @example\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import Uint8Array from '@stdlib/array/uint8';\n* import { factory as ind } from '@stdlib/ndarray/base/ind';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n*\n* var indices = [ 3, 1, 2, 0 ];\n* var values = new Uint8Array( [ 0, 1, 1, 0 ] );\n*\n* var getIndex = ind( 'throw' );\n*\n* var out = boolean( x, arraylike2object( indices ), values, 1, getIndex, x.length-1 );\n* // returns [ 0, 1, 1, 0 ]\n*/\nfunction boolean( x, indices, values, stride, getIndex, maxIndex ) {\n\tvar idata;\n\tvar iget;\n\tvar iv;\n\tvar i;\n\tvar j;\n\n\tidata = indices.data;\n\tiget = indices.accessors[ 0 ];\n\n\tiv = 0;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), maxIndex );\n\t\tx[ j ] = values[ iv ];\n\t\tiv += stride;\n\t}\n\treturn x;\n}\n\n\n// MAIN //\n\n/**\n* Replaces specified elements of an array with provided values.\n*\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {Collection} values - values to set\n* @param {string} mode - index mode\n* @throws {Error} third argument must be broadcast compatible with the second argument\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 1, 2 ];\n* var values = [ 20, 30 ];\n*\n* var out = put( x, indices, values, 'throw' );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 1, 2 ];\n* var values = [ 30 ];\n*\n* var out = put( x, indices, values, 'throw' );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction put( x, indices, values, mode ) {\n\tvar getIndex;\n\tvar stride;\n\tvar max;\n\tvar xo;\n\tvar io;\n\tvar vo;\n\n\t// Broadcast the `values` array...\n\tif ( indices.length > 0 ) { // note: this allows `indices` to be empty and `values` to be non-empty (and not broadcast compatible with `indices`) to allow the potential use case where having an empty `indices` array is expected behavior and you don't want to trigger an exception simply because `values` has elements\n\t\t// Note that this effectively in-lines logic from `@stdlib/array/base/broadcast-array` in order to avoid unnecessary object creation...\n\t\tif ( values.length === indices.length ) {\n\t\t\tstride = 1;\n\t\t} else if ( values.length === 1 ) {\n\t\t\tstride = 0;\n\t\t} else {\n\t\t\tthrow new Error( format( 'invalid argument. The third argument must be broadcast compatible with the second argument. Array shape: (%d). Desired shape: (%d).', values.length, indices.length ) );\n\t\t}\n\t}\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = x.length - 1;\n\n\txo = arraylike2object( x );\n\tio = arraylike2object( indices );\n\tvo = arraylike2object( values );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tio.accessorProtocol ||\n\t\tvo.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support select dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif ( isComplexDataType( xo.dtype ) && isComplexDataType( vo.dtype ) ) {\n\t\t\tcomplex( reinterpretComplex( x, 0 ), io, reinterpretComplex( values, 0 ), stride, getIndex, max ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\tif ( isBooleanDataType( xo.dtype ) && isBooleanDataType( vo.dtype ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), io, reinterpretBoolean( values, 0 ), stride, getIndex, max ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\taccessors( xo, io, vo, stride, getIndex, max );\n\t\treturn x;\n\t}\n\tindexed( x, indices, values, stride, getIndex, max );\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default put;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return an index given an index mode.\n*\n* @module @stdlib/ndarray/base/ind\n*\n* @example\n* import ind from '@stdlib/ndarray/base/ind';\n*\n* var idx = ind( -1, 10, 'wrap' );\n* // returns 10\n*\n* idx = ind( 14, 10, 'wrap' );\n* // returns 3\n*\n* idx = ind( 6, 10, 'wrap' );\n* // returns 6\n*\n* @example\n* import ind from '@stdlib/ndarray/base/ind';\n*\n* var idx = ind( -1, 10, 'clamp' );\n* // returns 0\n*\n* idx = ind( 14, 10, 'clamp' );\n* // returns 10\n*\n* idx = ind( 6, 10, 'clamp' );\n* // returns 6\n*\n* @example\n* import ind from '@stdlib/ndarray/base/ind';\n*\n* var idx = ind( 1, 10, 'throw' );\n* // returns 1\n*\n* idx = ind( 14, 10, 'throw' );\n* // throws \n*\n* idx = ind( -1, 10, 'throw' );\n* // throws \n*\n* @example\n* import ind from '@stdlib/ndarray/base/ind';\n*\n* var idx = ind( 1, 10, 'normalize' );\n* // returns 1\n*\n* idx = ind( -4, 10, 'normalize' );\n* // returns 7\n*\n* idx = ind( -100, 10, 'normalize' );\n* // throws \n*\n* @example\n* import ind from '@stdlib/ndarray/base/ind';\n*\n* var fcn = ind.factory( 'clamp' );\n*\n* var idx = fcn( -1, 10 );\n* // returns 0\n*\n* idx = fcn( 14, 10 );\n* // returns 10\n*\n* idx = fcn( 6, 10 );\n* // returns 6\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport factory from './factory.js';\nimport main from './main.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport clampIndex from './../../../base/clamp-index';\nimport wrapIndex from './../../../base/wrap-index';\nimport normalizeIndex from './../../../base/normalize-index';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an index given an index mode.\n*\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @param {string} mode - specifies how to handle an index outside the interval `[0,max]`\n* @throws {RangeError} index out-of-bounds\n* @returns {integer} index\n*\n* @example\n* var idx = ind( 2, 9, 'clamp' );\n* // returns 2\n*\n* idx = ind( 10, 9, 'clamp' );\n* // returns 9\n*\n* idx = ind( -1, 9, 'clamp' );\n* // returns 0\n*\n* @example\n* var idx = ind( 2, 9, 'wrap' );\n* // returns 2\n*\n* idx = ind( 10, 9, 'wrap' );\n* // returns 0\n*\n* idx = ind( -1, 9, 'wrap' );\n* // returns 9\n*\n* @example\n* var idx = ind( 2, 9, 'throw' );\n* // returns 2\n*\n* idx = ind( 10, 9, 'throw' );\n* // throws \n*\n* idx = ind( -1, 9, 'throw' );\n* // throws \n*\n* @example\n* var idx = ind( 1, 10, 'normalize' );\n* // returns 1\n*\n* idx = ind( -4, 10, 'normalize' );\n* // returns 7\n*\n* idx = ind( -100, 10, 'normalize' );\n* // throws \n*/\nfunction ind( idx, max, mode ) {\n\tvar index;\n\tif ( mode === 'clamp' ) {\n\t\treturn clampIndex( idx, max );\n\t}\n\tif ( mode === 'wrap' ) {\n\t\treturn wrapIndex( idx, max );\n\t}\n\tindex = idx;\n\tif ( mode === 'normalize' ) {\n\t\tindex = normalizeIndex( index, max );\n\t}\n\tif ( index < 0 || index > max ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.', max, idx ) );\n\t}\n\treturn index;\n}\n\n\n// EXPORTS //\n\nexport default ind;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// VARIABLES //\n\nvar arraySlice = Array.prototype.slice;\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'slice' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns a shallow copy of a portion of an array using the `Array#slice` built-in.\n*\n* @private\n* @param {Collection} x - input array\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = builtin( x, 1, 3 );\n* // returns [ 2, 3 ]\n*/\nfunction builtin( x, start, end ) {\n\treturn arraySlice.call( x, start, end );\n}\n\n/**\n* Returns a shallow copy of a portion of an accessor array.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {Array} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) );\n*\n* var out = accessors( x, 1, 3 );\n* // returns [ 2, 3 ]\n*/\nfunction accessors( x, start, end ) {\n\tvar data;\n\tvar get;\n\tvar out;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\tout = [];\n\tfor ( i = start; i < end; i++ ) {\n\t\tout.push( get( data, i ) );\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a shallow copy of a portion of an array.\n*\n* @param {Collection} x - input array\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = slice( x, 1, 3 );\n* // returns [ 2, 3 ]\n*\n* var bool = ( out === x );\n* // returns false\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var out = slice( x, 1, 3 );\n* // returns [ 2, 3 ]\n*\n* var bool = ( out === x );\n* // returns false\n*/\nfunction slice( x, start, end ) {\n\tvar obj;\n\tif ( hasMethod( x, 'slice' ) ) {\n\t\treturn x.slice( start, end );\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, start, end );\n\t}\n\t// Assume we can use the built-in `Array#slice` method to copy elements to a generic array:\n\treturn builtin( x, start, end );\n}\n\n\n// EXPORTS //\n\nexport default slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport flatten from './../../../base/flatten';\nimport slice from './../../../base/slice';\n\n\n// FUNCTIONS //\n\n/**\n* Recursive reshapes an array.\n*\n* @private\n* @param {Array} array - input n-dimensional nested array\n* @param {NonNegativeInteger} ndims - number of dimensions\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} dim - dimension index\n* @param {NonNegativeInteger} index - sub-array index\n* @returns {Array} output m-dimensional nested array\n*/\nfunction recurse( array, ndims, shape, dim, index ) {\n\tvar stepSize;\n\tvar subArray;\n\tvar out;\n\tvar d;\n\tvar S;\n\tvar i;\n\n\tS = shape[ dim ];\n\tif ( dim === ndims - 1 ) {\n\t\treturn slice( array, index, index + S );\n\t}\n\n\td = dim + 1;\n\tstepSize = 1;\n\tfor ( i = d; i < shape.length; i++ ) {\n\t\tstepSize *= shape[ i ];\n\t}\n\n\tout = [];\n\tfor ( i = 0; i < S; i++ ) {\n\t\tsubArray = recurse( array, ndims, shape, d, index );\n\t\tout.push( subArray );\n\t\tindex += stepSize;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Reshape a nested array into another nested array having a desired shape.\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} fromShape - shape of the input array\n* @param {NonNegativeIntegerArray} toShape - shape of the output array\n* @param {boolean} colexicographic - specifies whether to reshape the array in colexicographic order\n* @returns {Array} output nested array\n*\n* @example\n* var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ];\n*\n* var out = reshape( x, [ 2, 3 ], [ 3, 2 ], false );\n* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]\n*/\nfunction reshape( x, fromShape, toShape, colexicographic ) {\n\tvar f = flatten( x, fromShape, colexicographic );\n\treturn recurse( f, toShape.length, toShape, 0, 0 );\n}\n\n\n// EXPORTS //\n\nexport default reshape;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport accessorSetter from './../../../base/accessor-setter';\nimport setter from './../../../base/setter';\nimport dtype from './../../../dtype';\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for setting an element in an array-like object.\n*\n* @param {Collection} x - input array\n* @returns {Function} accessor\n*\n* @example\n* import resolveGetter from '@stdlib/array/base/resolve-getter';\n*\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var set = resolveSetter( arr );\n* // returns \n*\n* set( arr, 2, 10 );\n*\n* var get = resolveGetter( arr );\n* // returns \n*\n* var v = get( arr, 2 );\n* // returns 10\n*/\nfunction resolveSetter( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessorSetter( dt );\n\t}\n\treturn setter( dt );\n}\n\n\n// EXPORTS //\n\nexport default resolveSetter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/*\n* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name filled2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/symmetric/filled2d-by}\n*/\nimport filled2dBy from './../../../base/symmetric/filled2d-by';\nsetReadOnly( ns, 'filled2dBy', filled2dBy );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional symmetric nested array according to a provided callback function.\n*\n* @param {NonNegativeInteger} N - number of rows and columns\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( 3, clbk );\n* // returns [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( 4, clbk );\n* // returns [ [ 0, 1, 2, 3 ], [ 1, 2, 3, 4 ], [ 2, 3, 4, 5 ], [ 3, 4, 5, 6 ] ]\n*/\nfunction filled2dBy( N, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar i;\n\tvar j;\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\ta0 = [];\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tif ( i > j ) {\n\t\t\t\ta0.push( arr[ j ][ i ] );\n\t\t\t} else {\n\t\t\t\ta0.push( clbk.call( thisArg, [ i, j ] ) );\n\t\t\t}\n\t\t}\n\t\tarr.push( a0 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/*\n* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name filled2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/symmetric-banded/filled2d-by}\n*/\nimport filled2dBy from './../../../base/symmetric-banded/filled2d-by';\nsetReadOnly( ns, 'filled2dBy', filled2dBy );\n\n/**\n* @name toCompact\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/symmetric-banded/to-compact}\n*/\nimport toCompact from './../../../base/symmetric-banded/to-compact';\nsetReadOnly( ns, 'toCompact', toCompact );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport { factory as ind } from '@stdlib/ndarray/base/ind';\n\n\n// MAIN //\n\n/**\n* Takes elements from an array.\n*\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {string} mode - index mode\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var y = take( x, indices, 'throw' );\n* // returns [ 4, 2, 3, 1 ]\n*/\nfunction take( x, indices, mode ) {\n\tvar getIndex;\n\tvar xget;\n\tvar iget;\n\tvar out;\n\tvar max;\n\tvar i;\n\tvar j;\n\n\t// Resolve an accessor for retrieving array elements:\n\txget = resolveGetter( x );\n\tiget = resolveGetter( indices );\n\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = x.length - 1;\n\n\t// Extract each desired element from the provided array...\n\tout = [];\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\tj = getIndex( iget( indices, i ), max );\n\t\tout.push( xget( x, j ) ); // use `Array#push` to ensure \"fast\" elements\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default take;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional symmetric banded nested array according to a provided callback function.\n*\n* @param {NonNegativeInteger} N - number of rows and columns\n* @param {NonNegativeInteger} k - number of super-/sub-diagonals\n* @param {*} fill - fill value for values outside the band\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( 3, 1, 0, clbk );\n* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( 4, 1, 0, clbk );\n* // returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ]\n*/\nfunction filled2dBy( N, k, fill, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar i;\n\tvar j;\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\ta0 = [];\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\t// Check whether we are within the band in the upper triangle...\n\t\t\tif ( j >= i && j <= i+k ) {\n\t\t\t\ta0.push( clbk.call( thisArg, [ i, j ] ) );\n\t\t\t}\n\t\t\t// Check whether we can take advantage of symmetry...\n\t\t\telse if ( j < i ) {\n\t\t\t\ta0.push( arr[ j ][ i ] );\n\t\t\t}\n\t\t\t// Otherwise, we are outside the band in the upper triangle...\n\t\t\telse {\n\t\t\t\ta0.push( fill );\n\t\t\t}\n\t\t}\n\t\tarr.push( a0 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport max from '@stdlib/math/base/special/fast/max';\nimport min from '@stdlib/math/base/special/fast/min';\nimport zeros2d from './../../../../base/zeros2d';\n\n\n// MAIN //\n\n/**\n* Converts a two-dimensional symmetric banded nested array to compact banded storage.\n*\n* @param {string} uplo - specifies whether to reference the upper or lower triangular part of the input array\n* @param {Array} arr - input two-dimensional array\n* @param {NonNegativeInteger} k - number of super-/sub-diagonals\n* @param {boolean} colexicographic - specifies whether to store diagonals in colexicographic access order\n* @returns {Array} output array\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 2, 12, 4 ],\n* [ 0, 4, 13 ]\n* ];\n*\n* var out = toCompact( 'upper', M, 1, false );\n* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ] ]\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 2, 12, 4 ],\n* [ 0, 4, 13 ]\n* ];\n*\n* var out = toCompact( 'lower', M, 1, false );\n* // returns [ [ 11, 12, 13 ], [ 2, 4, 0 ] ]\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 2, 12, 4 ],\n* [ 0, 4, 13 ]\n* ];\n*\n* var out = toCompact( 'upper', M, 1, true );\n* // returns [ [ 11, 2 ], [ 12, 4 ], [ 13, 0 ] ]\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 2, 12, 4 ],\n* [ 0, 4, 13 ]\n* ];\n*\n* var out = toCompact( 'lower', M, 1, true );\n* // returns [ [ 0, 11 ], [ 2, 12 ], [ 4, 13 ] ]\n*/\nfunction toCompact( uplo, arr, k, colexicographic ) {\n\tvar out;\n\tvar to;\n\tvar ta;\n\tvar m;\n\tvar i;\n\tvar j;\n\tvar o;\n\n\tm = arr.length;\n\n\t// Check whether to store diagonals along the columns...\n\tif ( colexicographic ) {\n\t\tout = zeros2d( [ m, k+1 ] );\n\t\tif ( uplo === 'upper' ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\tto = out[ i ];\n\t\t\t\tta = arr[ i ];\n\t\t\t\tfor ( j = i; j < min( m, i+k+1 ); j++ ) {\n\t\t\t\t\tto[ j-i ] = ta[ j ];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\t// uplo === 'lower'\n\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\tto = out[ i ];\n\t\t\tta = arr[ i ];\n\t\t\to = max( 0, k-i );\n\t\t\tfor ( j = max( 0, i-k ); j <= i; j++ ) {\n\t\t\t\tto[ o ] = ta[ j ];\n\t\t\t\to += 1;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\t// Store diagonals along the rows...\n\tout = zeros2d( [ k+1, m ] );\n\tif ( uplo === 'upper' ) {\n\t\tfor ( j = 0; j < m; j++ ) {\n\t\t\to = k - j;\n\t\t\tfor ( i = max( 0, j-k ); i <= j; i++ ) {\n\t\t\t\tout[ o+i ][ j ] = arr[ i ][ j ];\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\t// uplo === 'lower'\n\tfor ( j = 0; j < m; j++ ) {\n\t\to = -j;\n\t\tfor ( i = j; i < min( m, j+k+1 ); i++ ) {\n\t\t\tout[ o+i ][ j ] = arr[ i ][ j ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toCompact;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Take elements from an array.\n*\n* @module @stdlib/array/base/take\n*\n* @example\n* import take from '@stdlib/array/base/take';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 0, 0, 1, 1, 3, 3 ];\n* var y = take( x, indices, 'throw' );\n* // returns [ 1, 1, 2, 2, 4, 4 ]\n*\n* @example\n* import take from '@stdlib/array/base/take';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n* var indices = [ 0, 0, 1, 1, 3, 3 ];\n*\n* var arr = take.assign( x, indices, 'throw', out, 1, 0 );\n* // returns [ 1, 1, 2, 2, 4, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport { factory as ind } from '@stdlib/ndarray/base/ind';\n\n\n// FUNCTIONS //\n\n/**\n* Takes elements from an indexed array and assigns the values to elements in an indexed output array.\n*\n* @private\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {string} mode - index mode\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n*\n* var arr = indexed( x, indices, 'throw', out, 1, 0 );\n* // returns [ 4, 2, 3, 1 ]\n*/\nfunction indexed( x, indices, mode, out, stride, offset ) {\n\tvar getIndex;\n\tvar max;\n\tvar io;\n\tvar i;\n\tvar j;\n\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = x.length - 1;\n\n\t// Extract each desired element from the provided array...\n\tio = offset;\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\tj = getIndex( indices[ i ], max );\n\t\tout[ io ] = x[ j ];\n\t\tio += stride;\n\t}\n\treturn out;\n}\n\n/**\n* Takes elements from an accessor array and assigns the values to elements in an accessor output array.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} indices - index array object\n* @param {string} mode - index mode\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var indices = toAccessorArray( [ 3, 1, 2, 0 ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), arraylike2object( indices ), 'throw', arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 4\n*/\nfunction accessors( x, indices, mode, out, stride, offset ) {\n\tvar getIndex;\n\tvar xdata;\n\tvar idata;\n\tvar odata;\n\tvar xget;\n\tvar iget;\n\tvar oset;\n\tvar max;\n\tvar io;\n\tvar i;\n\tvar j;\n\n\txdata = x.data;\n\tidata = indices.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\tiget = indices.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = xdata.length - 1;\n\n\t// Extract each desired element from the provided array...\n\tio = offset;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), max );\n\t\toset( odata, io, xget( xdata, j ) );\n\t\tio += stride;\n\t}\n\treturn odata;\n}\n\n/**\n* Takes elements from a complex array and assigns the values to elements in a complex output array.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} indices - index array object\n* @param {string} mode - index mode\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n* var indices = [ 0, 0, 1, 1 ];\n*\n* var out = new Float64Array( 8 );\n*\n* var arr = complex( x, arraylike2object( indices ), 'throw', out, 1, 0 );\n* // returns [ 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]\n*/\nfunction complex( x, indices, mode, out, stride, offset ) {\n\tvar getIndex;\n\tvar idata;\n\tvar iget;\n\tvar max;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tidata = indices.data;\n\tiget = indices.accessors[ 0 ];\n\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = ( x.length/2 ) - 1; // resolve the length of the original complex array\n\n\t// Extract each desired element from the provided array...\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), max );\n\t\tk = j * 2;\n\t\tout[ io ] = x[ k ];\n\t\tout[ io+1 ] = x[ k+1 ];\n\t\tio += so;\n\t}\n\treturn out;\n}\n\n/**\n* Takes elements from a boolean array and assigns the values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean value input array view\n* @param {Object} indices - index array object\n* @param {string} mode - index mode\n* @param {Collection} out - boolean value output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var indices = [ 0, 0, 1, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( indices ), 'throw', out, 1, 0 );\n* // returns [ 1, 1, 0, 0 ]\n*/\nfunction boolean( x, indices, mode, out, stride, offset ) {\n\tvar getIndex;\n\tvar idata;\n\tvar iget;\n\tvar max;\n\tvar io;\n\tvar i;\n\tvar j;\n\n\tidata = indices.data;\n\tiget = indices.accessors[ 0 ];\n\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = x.length - 1;\n\n\t// Extract each desired element from the provided array...\n\tio = offset;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), max );\n\t\tout[ io ] = x[ j ];\n\t\tio += stride;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Takes elements from an array and assigns the values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {string} mode - index mode\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var arr = assign( x, indices, 'throw', out, 1, 0 );\n* // returns [ 4, 2, 3, 1 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, indices, mode, out, stride, offset ) {\n\tvar xo;\n\tvar io;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tio = arraylike2object( indices );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tio.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), io, mode, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), io, mode, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, io, mode, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, indices, mode, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport { factory as indexFunction } from '@stdlib/ndarray/base/ind';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar NDIMS = 2;\n\n\n// MAIN //\n\n/**\n* Takes elements from a two-dimensional nested array.\n*\n* ## Notes\n*\n* - The function does **not** deep copy nested array elements.\n*\n* @param {ArrayLikeObject} x - input array\n* @param {NonNegativeIntegerArray} indices - list of indices\n* @param {integer} dimension - dimension along which to take elements\n* @param {string} mode - index mode specifying how to handle an index which is out-of-bounds\n* @throws {RangeError} third argument exceeds the number of dimensions\n* @throws {TypeError} fourth argument must be a recognized index mode\n* @returns {(Array|Array)} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var indices = [ 1, 1, 0, 0, -1, -1 ];\n*\n* var y = take2d( x, indices, 1, 'normalize' );\n* // returns [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ]\n*/\nfunction take2d( x, indices, dimension, mode ) {\n\tvar lastIndex;\n\tvar out;\n\tvar dim;\n\tvar ind;\n\tvar idx;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\n\tdim = normalizeIndex( dimension, NDIMS-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Third argument exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', NDIMS, dimension ) );\n\t}\n\tind = indexFunction( mode );\n\tout = [];\n\tif ( dim === 0 ) {\n\t\tlastIndex = x.length - 1;\n\t\tfor ( i1 = 0; i1 < indices.length; i1++ ) {\n\t\t\tidx = ind( indices[ i1 ], lastIndex );\n\t\t\tout.push( x[ idx ] );\n\t\t}\n\t\treturn out;\n\t}\n\t// Case: dim === 1\n\tfor ( i1 = 0; i1 < x.length; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = [];\n\t\tlastIndex = x0.length - 1;\n\t\tfor ( i0 = 0; i0 < indices.length; i0++ ) {\n\t\t\tidx = ind( indices[ i0 ], lastIndex );\n\t\t\ty0.push( x0[ idx ] );\n\t\t}\n\t\tout.push( y0 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default take2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Recursively applies a unary callback.\n*\n* @private\n* @param {ArrayLikeObject} x - input array\n* @param {ArrayLikeObject} y - output array\n* @param {NonNegativeInteger} ndims - number of dimensions\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} dim - dimension index\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*/\nfunction recurse( x, y, ndims, shape, dim, fcn ) {\n\tvar S;\n\tvar d;\n\tvar i;\n\n\tS = shape[ dim ];\n\n\t// Check whether we've reached the innermost dimension:\n\td = dim + 1;\n\n\tif ( d === ndims ) {\n\t\t// Apply the provided callback...\n\t\tfor ( i = 0; i < S; i++ ) {\n\t\t\ty[ i ] = fcn( x[ i ] );\n\t\t}\n\t\treturn;\n\t}\n\t// Continue recursing into the nested arrays...\n\tfor ( i = 0; i < S; i++ ) {\n\t\trecurse( x[ i ], y[ i ], ndims, shape, d, fcn );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in an n-dimensional nested input array and assigns results to elements in an n-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import onesnd from '@stdlib/array/base/onesnd';\n* import zerosnd from '@stdlib/array/base/zerosnd';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = onesnd( shape );\n* var y = zerosnd( shape );\n*\n* unarynd( [ x, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*/\nfunction unarynd( arrays, shape, fcn ) {\n\treturn recurse( arrays[ 0 ], arrays[ 1 ], shape.length, shape, 0, fcn );\n}\n\n\n// EXPORTS //\n\nexport default unarynd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport PINF from '@stdlib/constants/float64/pinf';\n\n\n// MAIN //\n\n/**\n* Tests if a double-precision floating-point numeric value is positive zero.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is positive zero\n*\n* @example\n* var bool = isPositiveZero( 0.0 );\n* // returns true\n*\n* @example\n* var bool = isPositiveZero( -0.0 );\n* // returns false\n*/\nfunction isPositiveZero( x ) {\n\treturn (x === 0.0 && 1.0/x === PINF);\n}\n\n\n// EXPORTS //\n\nexport default isPositiveZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves a stride length for broadcasting a one-dimensional array.\n*\n* @private\n* @param {NonNegativeInteger} M - input array length\n* @param {NonNegativeInteger} N - output array length\n* @throws {Error} input arrays must be broadcast compatible\n* @returns {NonNegativeInteger} stride length\n*/\nfunction resolveStride( M, N ) {\n\t// Note that this effectively in-lines logic from `@stdlib/array/base/broadcast-array` in order to avoid unnecessary object creation...\n\tif ( M === 1 ) {\n\t\treturn 0;\n\t}\n\tif ( M === N ) {\n\t\treturn 1;\n\t}\n\tthrow new Error( 'invalid arguments. Input arguments are not broadcast compatible.' );\n}\n\n\n// EXPORTS //\n\nexport default resolveStride;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport maxn from '@stdlib/math/base/special/maxn';\nimport resolveStride from './resolve_stride.js';\n\n\n// MAIN //\n\n/**\n* Takes elements from either one of two arrays depending on a condition.\n*\n* @param {Collection} condition - indicator array\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @throws {Error} input arrays must be broadcast compatible\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n*\n* var condition = [ true, false, true, false ];\n*\n* var z = where( condition, x, y );\n* // returns [ 1, 6, 3, 8 ]\n*/\nfunction where( condition, x, y ) {\n\tvar xget;\n\tvar yget;\n\tvar cget;\n\tvar lens;\n\tvar out;\n\tvar sx;\n\tvar sy;\n\tvar sc;\n\tvar ix;\n\tvar iy;\n\tvar ic;\n\tvar N;\n\tvar v;\n\tvar i;\n\n\t// Cache the lengths of the input arrays:\n\tlens = [ condition.length, x.length, y.length ];\n\n\t// Check whether we can avoid doing any further work...\n\tif ( lens[ 0 ] === 0 ) {\n\t\t// E.g., `where( [], [ 1, 2 ], [ 3, 4 ] )`\n\t\treturn [];\n\t}\n\t// Compute the output array length:\n\tN = maxn( lens[ 0 ], lens[ 1 ], lens[ 2 ] );\n\n\t// Broadcast the arrays by computing strides:\n\tsc = resolveStride( lens[ 0 ], N );\n\tsx = resolveStride( lens[ 1 ], N );\n\tsy = resolveStride( lens[ 2 ], N );\n\n\t// Resolve accessors for retrieving array elements:\n\tcget = resolveGetter( condition );\n\txget = resolveGetter( x );\n\tyget = resolveGetter( y );\n\n\t// Initialize indices:\n\tic = 0;\n\tix = 0;\n\tiy = 0;\n\n\t// Extract each desired element from a provided array...\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( cget( condition, ic ) ) {\n\t\t\tv = xget( x, ix );\n\t\t} else {\n\t\t\tv = yget( y, iy );\n\t\t}\n\t\tout.push( v ); // use `Array#push` to ensure \"fast\" elements\n\t\tic += sc;\n\t\tix += sx;\n\t\tiy += sy;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default where;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPositiveZero from './../../../../base/assert/is-positive-zero';\nimport isnan from './../../../../base/assert/is-nan';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport PINF from '@stdlib/constants/float64/pinf';\n\n\n// MAIN //\n\n/**\n* Returns the maximum value.\n*\n* @param {number} [x] - first number\n* @param {number} [y] - second number\n* @param {...number} [args] - numbers\n* @returns {number} maximum value\n*\n* @example\n* var v = maxn( 3.14, 4.2 );\n* // returns 4.2\n*\n* @example\n* var v = maxn( 5.9, 3.14, 4.2 );\n* // returns 5.9\n*\n* @example\n* var v = maxn( 3.14, NaN );\n* // returns NaN\n*\n* @example\n* var v = maxn( +0.0, -0.0 );\n* // returns +0.0\n*/\nfunction maxn( x, y ) {\n\tvar len;\n\tvar m;\n\tvar v;\n\tvar i;\n\n\tlen = arguments.length;\n\tif ( len === 2 ) {\n\t\tif ( isnan( x ) || isnan( y ) ) {\n\t\t\treturn NaN;\n\t\t}\n\t\tif ( x === PINF || y === PINF ) {\n\t\t\treturn PINF;\n\t\t}\n\t\tif ( x === y && x === 0.0 ) {\n\t\t\tif ( isPositiveZero( x ) ) {\n\t\t\t\treturn x;\n\t\t\t}\n\t\t\treturn y;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn x;\n\t\t}\n\t\treturn y;\n\t}\n\tm = NINF;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = arguments[ i ];\n\t\tif ( isnan( v ) || v === PINF ) {\n\t\t\treturn v;\n\t\t}\n\t\tif ( v > m ) {\n\t\t\tm = v;\n\t\t} else if (\n\t\t\tv === m &&\n\t\t\tv === 0.0 &&\n\t\t\tisPositiveZero( v )\n\t\t) {\n\t\t\tm = v;\n\t\t}\n\t}\n\treturn m;\n}\n\n\n// EXPORTS //\n\nexport default maxn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpretCmplx from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBool from '@stdlib/strided/base/reinterpret-boolean';\nimport resolveStride from './resolve_stride.js';\nimport numel from './numel.js';\n\n\n// FUNCTIONS //\n\n/**\n* Takes elements from either one indexed array or another depending on a condition and assigns the values to elements in an indexed output array.\n*\n* @private\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {Collection} condition - indicator array\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @throws {Error} input arrays must be broadcast compatible with the output array\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var condition = [ true, false, true, false ];\n*\n* var arr = indexed( out.length, condition, x, y, out, 1, 0 );\n* // returns [ 1, 6, 3, 8 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction indexed( N, condition, x, y, out, stride, offset ) {\n\tvar sx;\n\tvar sy;\n\tvar sc;\n\tvar ix;\n\tvar iy;\n\tvar ic;\n\tvar io;\n\tvar i;\n\n\t// Broadcast the arrays by computing strides:\n\tsc = resolveStride( condition.length, N );\n\tsx = resolveStride( x.length, N );\n\tsy = resolveStride( y.length, N );\n\n\t// Initialize indices:\n\tic = 0;\n\tix = 0;\n\tiy = 0;\n\tio = offset;\n\n\t// Extract each desired element from a provided array...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout[ io ] = ( condition[ ic ] ) ? x[ ix ] : y[ iy ];\n\t\tic += sc;\n\t\tix += sx;\n\t\tiy += sy;\n\t\tio += stride;\n\t}\n\treturn out;\n}\n\n/**\n* Takes elements from either one accessor array or another depending on a condition and assigns the values to elements in an accessor output array.\n*\n* @private\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {Object} condition - condition array object\n* @param {Object} x - first input array object\n* @param {Object} y - second input array object\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var y = toAccessorArray( [ 5, 6, 7, 8 ] );\n*\n* var condition = toAccessorArray( [ true, false, true, false ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( out.length, arraylike2object( condition ), arraylike2object( x ), arraylike2object( y ), arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* v = arr.get( 1 );\n* // returns 6\n*/\nfunction accessors( N, condition, x, y, out, stride, offset ) {\n\tvar xdata;\n\tvar ydata;\n\tvar cdata;\n\tvar odata;\n\tvar xget;\n\tvar yget;\n\tvar cget;\n\tvar oset;\n\tvar sx;\n\tvar sy;\n\tvar sc;\n\tvar ix;\n\tvar iy;\n\tvar ic;\n\tvar io;\n\tvar i;\n\n\tcdata = condition.data;\n\txdata = x.data;\n\tydata = y.data;\n\todata = out.data;\n\n\tcget = condition.accessors[ 0 ];\n\txget = x.accessors[ 0 ];\n\tyget = y.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\t// Broadcast the arrays by computing strides:\n\tsc = resolveStride( cdata.length, N );\n\tsx = resolveStride( xdata.length, N );\n\tsy = resolveStride( ydata.length, N );\n\n\t// Initialize indices:\n\tic = 0;\n\tix = 0;\n\tiy = 0;\n\tio = offset;\n\n\t// Extract each desired element from a provided array...\n\tfor ( i = 0; i < N; i++ ) {\n\t\toset( odata, io, ( cget( cdata, ic ) ) ? xget( xdata, ix ) : yget( ydata, iy ) ); // eslint-disable-line max-len\n\t\tic += sc;\n\t\tix += sx;\n\t\tiy += sy;\n\t\tio += stride;\n\t}\n\treturn odata;\n}\n\n/**\n* Takes elements from either one complex array or another depending on a condition and assigns the values to elements in a complex output array.\n*\n* @private\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {Object} condition - condition array object\n* @param {Collection} x - first real-valued floating-point input array view\n* @param {Collection} y - second real-valued floating-point input array view\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n* var y = new Float64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] );\n*\n* var condition = [ true, false, true, false ];\n*\n* var out = new Float64Array( 8 );\n*\n* var arr = complex( 4, arraylike2object( condition ), x, y, out, 1, 0 );\n* // returns [ 1.0, 2.0, 11.0, 12.0, 5.0, 6.0, 15.0, 16.0 ]\n*/\nfunction complex( N, condition, x, y, out, stride, offset ) {\n\tvar cdata;\n\tvar cget;\n\tvar sx;\n\tvar sy;\n\tvar sc;\n\tvar so;\n\tvar ix;\n\tvar iy;\n\tvar ic;\n\tvar io;\n\tvar i;\n\n\tcdata = condition.data;\n\tcget = condition.accessors[ 0 ];\n\n\t// Broadcast the arrays by computing strides (note: multiply strides by 2 for complex array arguments, as a real-valued array view consists of interleaved real and imaginary components):\n\tsc = resolveStride( cdata.length, N );\n\tsx = resolveStride( x.length/2, N ) * 2;\n\tsy = resolveStride( y.length/2, N ) * 2;\n\tso = stride * 2;\n\n\t// Initialize indices:\n\tic = 0;\n\tix = 0;\n\tiy = 0;\n\tio = offset * 2; // note: account for interleaved real and imaginary components\n\n\t// Extract each desired element from a provided array...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( cget( cdata, ic ) ) {\n\t\t\tout[ io ] = x[ ix ];\n\t\t\tout[ io+1 ] = x[ ix+1 ];\n\t\t} else {\n\t\t\tout[ io ] = y[ iy ];\n\t\t\tout[ io+1 ] = y[ iy+1 ];\n\t\t}\n\t\tic += sc;\n\t\tix += sx;\n\t\tiy += sy;\n\t\tio += so;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Takes elements from either one of two arrays depending on a condition and assigns the values to elements in a provided output array.\n*\n* @param {Collection} condition - indicator array\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @throws {Error} input arrays must be broadcast compatible with the output array\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var condition = [ true, false, true, false ];\n*\n* var arr = assign( condition, x, y, out, 1, 0 );\n* // returns [ 1, 6, 3, 8 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( condition, x, y, out, stride, offset ) {\n\tvar co;\n\tvar xo;\n\tvar yo;\n\tvar oo;\n\tvar N;\n\n\t// Check whether we can avoid doing any work...\n\tif ( condition.length === 0 ) {\n\t\treturn out;\n\t}\n\t// Compute the number of indexed elements in the output array:\n\tN = numel( out.length, stride, offset );\n\n\tco = arraylike2object( condition );\n\tif ( isBooleanDataType( co.dtype ) ) {\n\t\tcondition = reinterpretBool( condition, 0 );\n\t\tco = arraylike2object( condition );\n\t}\n\txo = arraylike2object( x );\n\tyo = arraylike2object( y );\n\too = arraylike2object( out );\n\tif (\n\t\tco.accessorProtocol ||\n\t\txo.accessorProtocol ||\n\t\tyo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly special case a select number of same dtype-to-dtype combinations, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tco.accessorProtocol === false &&\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( yo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tindexed( N, condition, reinterpretBool( x, 0 ), reinterpretBool( y, 0 ), reinterpretBool( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( yo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( N, co, reinterpretCmplx( x, 0 ), reinterpretCmplx( y, 0 ), reinterpretCmplx( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( N, co, xo, yo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( N, condition, x, y, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ceil from '@stdlib/math/base/special/ceil';\n\n\n// MAIN //\n\n/**\n* Computes the number of indexed elements in a strided array.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {integer} stride - array stride\n* @param {NonNegativeInteger} offset - array offset\n* @returns {NonNegativeInteger} number of indexed elements\n*\n* @example\n* var N = numel( 10, -2, 9 );\n* // returns 5\n*\n* N = numel( 10, -2, 8 );\n* // returns 5\n*\n* N = numel( 10, -2, 7 );\n* // returns 4\n*\n* N = numel( 10, -2, 6 );\n* // returns 4\n*\n* N = numel( 10, -2, 5 );\n* // returns 3\n*\n* @example\n* var N = numel( 10, -3, 9 );\n* // returns 4\n*\n* N = numel( 10, -3, 8 );\n* // returns 3\n*\n* N = numel( 10, -3, 7 );\n* // returns 3\n*\n* N = numel( 10, -3, 6 );\n* // returns 3\n*\n* N = numel( 10, -3, 5 );\n* // returns 2\n*\n* @example\n* var N = numel( 10, 2, 0 );\n* // returns 5\n*\n* N = numel( 10, 2, 1 );\n* // returns 5\n*\n* N = numel( 10, 2, 2 );\n* // returns 4\n*\n* N = numel( 10, 2, 3 );\n* // returns 4\n*\n* @example\n* var N = numel( 10, 3, 0 );\n* // returns 4\n*\n* N = numel( 10, 3, 1 );\n* // returns 3\n*\n* N = numel( 10, 3, 2 );\n* // returns 3\n*\n* N = numel( 10, 3, 3 );\n* // returns 3\n*/\nfunction numel( len, stride, offset ) {\n\tif ( stride < 0 ) {\n\t\treturn ceil( (offset+1) / -stride );\n\t}\n\treturn ceil( (len-offset) / stride );\n}\n\n\n// EXPORTS //\n\nexport default numel;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport slice from './../../../base/slice';\nimport resolveSetter from './../../../base/resolve-setter';\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'map' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n\n// MAIN //\n\n/**\n* Returns a new array with the element at the specified index replaced with a provided value.\n*\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @param {*} value - replacement value\n* @throws {RangeError} second argument must not exceed array bounds\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var v = arrayWith( x, 0, 5 );\n* // returns [ 5, 2, 3, 4 ]\n*\n* v = arrayWith( x, 1, 6 );\n* // returns [ 1, 6, 3, 4 ]\n*\n* v = arrayWith( x, -2, 7 );\n* // returns [ 1, 2, 7, 4 ]\n*/\nfunction arrayWith( x, index, value ) {\n\tvar out;\n\tvar set;\n\tif ( hasMethod( x, 'with' ) ) {\n\t\treturn x.with( index, value );\n\t}\n\tindex = normalizeIndex( index, x.length-1 );\n\tif ( index < 0 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) );\n\t}\n\tout = slice( x, 0, x.length );\n\tset = resolveSetter( out );\n\tset( out, index, value );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default arrayWith;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport Boolean from '@stdlib/boolean/ctor';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Copies elements from one array to another array and sets the element at the specified index to a provided value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @param {*} value - replacement value\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var arr = indexed( x, 0, 5, out, 1, 0 );\n* // returns [ 5, 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction indexed( x, index, value, out, stride, offset ) {\n\tvar io;\n\tvar i;\n\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout[ io ] = x[ i ];\n\t\tio += stride;\n\t}\n\tout[ offset+(index*stride) ] = value;\n\treturn out;\n}\n\n/**\n* Copies elements from one accessor array to another accessor array and sets the element at the specified index to a provided value.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} index - element index\n* @param {*} value - replacement value\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), 0, 5, arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 5\n*/\nfunction accessors( x, index, value, out, stride, offset ) {\n\tvar xdata;\n\tvar odata;\n\tvar xget;\n\tvar oset;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\toset( odata, io, xget( xdata, i ) );\n\t\tio += stride;\n\t}\n\toset( odata, offset+(index*stride), value );\n\treturn odata;\n}\n\n/**\n* Copies elements from one complex array to another complex array and sets the element at the specified index to a provided value.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {integer} index - element index\n* @param {ComplexLike} value - replacement value\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = new Float64Array( 4 );\n* var arr = complex( x, 0, new Complex128( 5.0, 6.0 ), out, 1, 0 );\n* // returns [ 5.0, 6.0, 3.0, 4.0 ]\n*/\nfunction complex( x, index, value, out, stride, offset ) {\n\tvar so;\n\tvar io;\n\tvar i;\n\tvar j;\n\n\tso = stride * 2; // multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < x.length/2; i++ ) {\n\t\tj = i * 2;\n\t\tout[ io ] = x[ j ];\n\t\tout[ io+1 ] = x[ j+1 ];\n\t\tio += so;\n\t}\n\tio = ( offset+(index*stride) ) * 2;\n\tout[ io ] = real( value );\n\tout[ io+1 ] = imag( value );\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Copies elements from one array to another array and sets the element at the specified index to a provided value.\n*\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @param {*} value - replacement value\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @throws {RangeError} second argument must not exceed array bounds\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var arr = assign( x, 0, 5, out, 1, 0 );\n* // returns [ 5, 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, index, value, out, stride, offset ) {\n\tvar xo;\n\tvar oo;\n\n\tindex = normalizeIndex( index, x.length-1 );\n\tif ( index < 0 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) );\n\t}\n\txo = arraylike2object( x );\n\too = arraylike2object( out );\n\tif ( xo.accessorProtocol || oo.accessorProtocol ) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype ) &&\n\t\t\tisComplexLike( value )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), index, value, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tindexed( reinterpretBoolean( x, 0 ), index, Boolean( value ), reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, index, value, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, index, value, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default array settings.\n*\n* @returns {Object} defaults\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t// Data types:\n\t\t'dtypes': {\n\t\t\t'default': 'float64',\n\t\t\t'numeric': 'float64',\n\t\t\t'real': 'float64',\n\t\t\t'floating_point': 'float64',\n\t\t\t'real_floating_point': 'float64',\n\t\t\t'complex_floating_point': 'complex128',\n\t\t\t'integer': 'int32',\n\t\t\t'signed_integer': 'int32',\n\t\t\t'unsigned_integer': 'uint32',\n\t\t\t'boolean': 'bool',\n\t\t\t'index': 'int32',\n\t\t\t'integer_index': 'int32',\n\t\t\t'boolean_index': 'bool',\n\t\t\t'mask_index': 'uint8'\n\t\t}\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Take elements from either one of two arrays depending on a condition.\n*\n* @module @stdlib/array/base/where\n*\n* @example\n* import where from '@stdlib/array/base/where';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n*\n* var condition = [ true, false, true, false ];\n*\n* var z = where( condition, x, y );\n* // returns [ 1, 6, 3, 8 ]\n*\n* @example\n* import where from '@stdlib/array/base/where';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var condition = [ true, false, true, false ];\n*\n* var arr = where.assign( condition, x, y, out, 1, 0 );\n* // returns [ 1, 6, 3, 8 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a new array with the element at the specified index replaced with a provided value.\n*\n* @module @stdlib/array/base/with\n*\n* @example\n* import arrayWith from '@stdlib/array/base/with';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var v = arrayWith( x, 0, 5 );\n* // returns [ 5, 2, 3, 4 ]\n*\n* v = arrayWith( x, -2, -1 );\n* // returns [ 1, 2, -1, 4 ]\n*\n* @example\n* import arrayWith from '@stdlib/array/base/with';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var arr = arrayWith.assign( x, 0, 5, out, 1, 0 );\n* // returns [ 5, 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defaults from './main.js';\n\n\n// VARIABLES //\n\nvar DEFAULTS = defaults();\nvar HASH = {\n\t'dtypes.default': DEFAULTS.dtypes.default,\n\t'dtypes.numeric': DEFAULTS.dtypes.numeric,\n\t'dtypes.real': DEFAULTS.dtypes.real,\n\t'dtypes.floating_point': DEFAULTS.dtypes.floating_point,\n\t'dtypes.real_floating_point': DEFAULTS.dtypes.real_floating_point,\n\t'dtypes.complex_floating_point': DEFAULTS.dtypes.complex_floating_point,\n\t'dtypes.integer': DEFAULTS.dtypes.integer,\n\t'dtypes.signed_integer': DEFAULTS.dtypes.signed_integer,\n\t'dtypes.unsigned_integer': DEFAULTS.dtypes.unsigned_integer,\n\t'dtypes.boolean': DEFAULTS.dtypes.boolean,\n\t'dtypes.index': DEFAULTS.dtypes.index,\n\t'dtypes.integer_index': DEFAULTS.dtypes.integer_index,\n\t'dtypes.boolean_index': DEFAULTS.dtypes.boolean_index,\n\t'dtypes.mask_index': DEFAULTS.dtypes.mask_index\n};\n\n\n// MAIN //\n\n/**\n* Returns a default array setting.\n*\n* @param {string} name - setting name\n* @returns {*} default setting or null\n*\n* @example\n* var v = get( 'dtypes.default' );\n* // returns \n*/\nfunction get( name ) {\n\tvar v = HASH[ name ];\n\treturn ( v === void 0 ) ? null : v;\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return default array settings.\n*\n* @module @stdlib/array/defaults\n*\n* @example\n* import defaults from '@stdlib/array/defaults';\n*\n* var o = defaults();\n* // returns {...}\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport get from './get.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'get', get );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport ctors from './../../ctors';\nimport gzeros from './../../base/zeros';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled array having a specified length.\n*\n* @param {NonNegativeInteger} length - array length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = zeros( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = zeros( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*/\nfunction zeros( length ) {\n\tvar dtype;\n\tvar ctor;\n\tif ( !isNonNegativeInteger( length ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', length ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tif ( dtype === 'generic' ) {\n\t\treturn gzeros( length );\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\treturn new ctor( length ); // WARNING: we assume that, apart from 'generic', the constructors for supported array data types are zero-filled by default\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Copies every element from one array to another array, except for the element at a specified index.\n*\n* @private\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0 ];\n* var arr = indexed( x, 0, out, 1, 0 );\n* // returns [ 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction indexed( x, index, out, stride, offset ) {\n\tvar io;\n\tvar i;\n\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( i === index ) {\n\t\t\tcontinue;\n\t\t}\n\t\tout[ io ] = x[ i ];\n\t\tio += stride;\n\t}\n\treturn out;\n}\n\n/**\n* Copies every element from one accessor array to another accessor array, except for the element at a specified index.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} index - element index\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), 0, arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 2\n*/\nfunction accessors( x, index, out, stride, offset ) {\n\tvar xdata;\n\tvar odata;\n\tvar xget;\n\tvar oset;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( i === index ) {\n\t\t\tcontinue;\n\t\t}\n\t\toset( odata, io, xget( xdata, i ) );\n\t\tio += stride;\n\t}\n\treturn odata;\n}\n\n/**\n* Copies every element from one complex array to another complex array, except for the element at a specified index.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {integer} index - element index\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = new Float64Array( 2 );\n* var arr = complex( x, 0, out, 1, 0 );\n* // returns [ 3.0, 4.0 ]\n*/\nfunction complex( x, index, out, stride, offset ) {\n\tvar so;\n\tvar io;\n\tvar i;\n\tvar j;\n\n\tso = stride * 2; // multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < x.length/2; i++ ) {\n\t\tif ( i === index ) {\n\t\t\tcontinue;\n\t\t}\n\t\tj = i * 2;\n\t\tout[ io ] = x[ j ];\n\t\tout[ io+1 ] = x[ j+1 ];\n\t\tio += so;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Copies every element from one array to another array, except for the element at a specified index.\n*\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @throws {RangeError} second argument must not exceed array bounds\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0 ];\n* var arr = assign( x, 0, out, 1, 0 );\n* // returns [ 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, index, out, stride, offset ) {\n\tvar xo;\n\tvar oo;\n\n\tindex = normalizeIndex( index, x.length-1 );\n\tif ( index < 0 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) );\n\t}\n\txo = arraylike2object( x );\n\too = arraylike2object( out );\n\tif ( xo.accessorProtocol || oo.accessorProtocol ) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), index, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tindexed( reinterpretBoolean( x, 0 ), index, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, index, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, index, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport zeros from './../../../zeros';\nimport dtype from './../../../dtype';\nimport format from '@stdlib/string/format';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Returns a new array containing every element from an input array, except for the element at a specified index.\n*\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @throws {RangeError} second argument must not exceed array bounds\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var v = without( x, 0 );\n* // returns [ 2, 3, 4 ]\n*\n* v = without( x, 1 );\n* // returns [ 1, 3, 4 ]\n*\n* v = without( x, -2 );\n* // returns [ 1, 2, 4 ]\n*/\nfunction without( x, index ) {\n\tvar out;\n\n\tindex = normalizeIndex( index, x.length-1 );\n\tif ( index < 0 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) );\n\t}\n\tout = zeros( x.length-1, dtype( x ) || 'generic' );\n\tassign( x, index, out, 1, 0 );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default without;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a new array containing every element from an input array, except for the element at a specified index.\n*\n* @module @stdlib/array/base/without\n*\n* @example\n* import without from '@stdlib/array/base/without';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var v = without( x, 0 );\n* // returns [ 2, 3, 4 ]\n*\n* v = without( x, -2 );\n* // returns [ 1, 2, 4 ]\n*\n* @example\n* import without from '@stdlib/array/base/without';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0 ];\n* var arr = without.assign( x, 0, out, 1, 0 );\n* // returns [ 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/*\n* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name AccessorArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/accessor}\n*/\nimport AccessorArray from './../../base/accessor';\nsetReadOnly( ns, 'AccessorArray', AccessorArray );\n\n/**\n* @name accessorGetter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/accessor-getter}\n*/\nimport accessorGetter from './../../base/accessor-getter';\nsetReadOnly( ns, 'accessorGetter', accessorGetter );\n\n/**\n* @name accessorSetter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/accessor-setter}\n*/\nimport accessorSetter from './../../base/accessor-setter';\nsetReadOnly( ns, 'accessorSetter', accessorSetter );\n\n/**\n* @name accessors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/accessors}\n*/\nimport accessors from './../../base/accessors';\nsetReadOnly( ns, 'accessors', accessors );\n\n/**\n* @name any\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any}\n*/\nimport any from './../../base/any';\nsetReadOnly( ns, 'any', any );\n\n/**\n* @name anyBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-by}\n*/\nimport anyBy from './../../base/any-by';\nsetReadOnly( ns, 'anyBy', anyBy );\n\n/**\n* @name anyByRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-by-right}\n*/\nimport anyByRight from './../../base/any-by-right';\nsetReadOnly( ns, 'anyByRight', anyByRight );\n\n/**\n* @name anyHasOwnProp\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-has-own-property}\n*/\nimport anyHasOwnProp from './../../base/any-has-own-property';\nsetReadOnly( ns, 'anyHasOwnProp', anyHasOwnProp );\n\n/**\n* @name anyHasProp\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-has-property}\n*/\nimport anyHasProp from './../../base/any-has-property';\nsetReadOnly( ns, 'anyHasProp', anyHasProp );\n\n/**\n* @name anyIsEntry\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-is-entry}\n*/\nimport anyIsEntry from './../../base/any-is-entry';\nsetReadOnly( ns, 'anyIsEntry', anyIsEntry );\n\n/**\n* @name anyIsEntryIn\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-is-entry-in}\n*/\nimport anyIsEntryIn from './../../base/any-is-entry-in';\nsetReadOnly( ns, 'anyIsEntryIn', anyIsEntryIn );\n\n/**\n* @name arraylike2object\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/arraylike2object}\n*/\nimport arraylike2object from './../../base/arraylike2object';\nsetReadOnly( ns, 'arraylike2object', arraylike2object );\n\n/**\n* @name assert\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/assert}\n*/\nimport assert from './../../base/assert';\nsetReadOnly( ns, 'assert', assert );\n\n/**\n* @name at\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/at}\n*/\nimport at from './../../base/at';\nsetReadOnly( ns, 'at', at );\n\n/**\n* @name at2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/at2d}\n*/\nimport at2d from './../../base/at2d';\nsetReadOnly( ns, 'at2d', at2d );\n\n/**\n* @name at3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/at3d}\n*/\nimport at3d from './../../base/at3d';\nsetReadOnly( ns, 'at3d', at3d );\n\n/**\n* @name at4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/at4d}\n*/\nimport at4d from './../../base/at4d';\nsetReadOnly( ns, 'at4d', at4d );\n\n/**\n* @name at5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/at5d}\n*/\nimport at5d from './../../base/at5d';\nsetReadOnly( ns, 'at5d', at5d );\n\n/**\n* @name atnd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/atnd}\n*/\nimport atnd from './../../base/atnd';\nsetReadOnly( ns, 'atnd', atnd );\n\n/**\n* @name banded\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/banded}\n*/\nimport banded from './../../base/banded';\nsetReadOnly( ns, 'banded', banded );\n\n/**\n* @name bifurcateEntries\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-entries}\n*/\nimport bifurcateEntries from './../../base/bifurcate-entries';\nsetReadOnly( ns, 'bifurcateEntries', bifurcateEntries );\n\n/**\n* @name bifurcateEntriesBy\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-entries-by}\n*/\nimport bifurcateEntriesBy from './../../base/bifurcate-entries-by';\nsetReadOnly( ns, 'bifurcateEntriesBy', bifurcateEntriesBy );\n\n/**\n* @name bifurcateIndices\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-indices}\n*/\nimport bifurcateIndices from './../../base/bifurcate-indices';\nsetReadOnly( ns, 'bifurcateIndices', bifurcateIndices );\n\n/**\n* @name bifurcateIndicesBy\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-indices-by}\n*/\nimport bifurcateIndicesBy from './../../base/bifurcate-indices-by';\nsetReadOnly( ns, 'bifurcateIndicesBy', bifurcateIndicesBy );\n\n/**\n* @name bifurcateValues\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-values}\n*/\nimport bifurcateValues from './../../base/bifurcate-values';\nsetReadOnly( ns, 'bifurcateValues', bifurcateValues );\n\n/**\n* @name bifurcateValuesBy\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-values-by}\n*/\nimport bifurcateValuesBy from './../../base/bifurcate-values-by';\nsetReadOnly( ns, 'bifurcateValuesBy', bifurcateValuesBy );\n\n/**\n* @name binary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/binary2d}\n*/\nimport binary2d from './../../base/binary2d';\nsetReadOnly( ns, 'binary2d', binary2d );\n\n/**\n* @name binary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/binary3d}\n*/\nimport binary3d from './../../base/binary3d';\nsetReadOnly( ns, 'binary3d', binary3d );\n\n/**\n* @name binary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/binary4d}\n*/\nimport binary4d from './../../base/binary4d';\nsetReadOnly( ns, 'binary4d', binary4d );\n\n/**\n* @name binary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/binary5d}\n*/\nimport binary5d from './../../base/binary5d';\nsetReadOnly( ns, 'binary5d', binary5d );\n\n/**\n* @name binarynd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/binarynd}\n*/\nimport binarynd from './../../base/binarynd';\nsetReadOnly( ns, 'binarynd', binarynd );\n\n/**\n* @name broadcastArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcast-array}\n*/\nimport broadcastArray from './../../base/broadcast-array';\nsetReadOnly( ns, 'broadcastArray', broadcastArray );\n\n/**\n* @name bbinary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-binary2d}\n*/\nimport bbinary2d from './../../base/broadcasted-binary2d';\nsetReadOnly( ns, 'bbinary2d', bbinary2d );\n\n/**\n* @name bbinary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-binary3d}\n*/\nimport bbinary3d from './../../base/broadcasted-binary3d';\nsetReadOnly( ns, 'bbinary3d', bbinary3d );\n\n/**\n* @name bbinary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-binary4d}\n*/\nimport bbinary4d from './../../base/broadcasted-binary4d';\nsetReadOnly( ns, 'bbinary4d', bbinary4d );\n\n/**\n* @name bbinary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-binary5d}\n*/\nimport bbinary5d from './../../base/broadcasted-binary5d';\nsetReadOnly( ns, 'bbinary5d', bbinary5d );\n\n/**\n* @name bquaternary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quaternary2d}\n*/\nimport bquaternary2d from './../../base/broadcasted-quaternary2d';\nsetReadOnly( ns, 'bquaternary2d', bquaternary2d );\n\n/**\n* @name bquaternary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quaternary3d}\n*/\nimport bquaternary3d from './../../base/broadcasted-quaternary3d';\nsetReadOnly( ns, 'bquaternary3d', bquaternary3d );\n\n/**\n* @name bquaternary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quaternary4d}\n*/\nimport bquaternary4d from './../../base/broadcasted-quaternary4d';\nsetReadOnly( ns, 'bquaternary4d', bquaternary4d );\n\n/**\n* @name bquaternary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quaternary5d}\n*/\nimport bquaternary5d from './../../base/broadcasted-quaternary5d';\nsetReadOnly( ns, 'bquaternary5d', bquaternary5d );\n\n/**\n* @name bquinary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quinary2d}\n*/\nimport bquinary2d from './../../base/broadcasted-quinary2d';\nsetReadOnly( ns, 'bquinary2d', bquinary2d );\n\n/**\n* @name bquinary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quinary4d}\n*/\nimport bquinary4d from './../../base/broadcasted-quinary4d';\nsetReadOnly( ns, 'bquinary4d', bquinary4d );\n\n/**\n* @name bternary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-ternary2d}\n*/\nimport bternary2d from './../../base/broadcasted-ternary2d';\nsetReadOnly( ns, 'bternary2d', bternary2d );\n\n/**\n* @name bternary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-ternary3d}\n*/\nimport bternary3d from './../../base/broadcasted-ternary3d';\nsetReadOnly( ns, 'bternary3d', bternary3d );\n\n/**\n* @name bternary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-ternary4d}\n*/\nimport bternary4d from './../../base/broadcasted-ternary4d';\nsetReadOnly( ns, 'bternary4d', bternary4d );\n\n/**\n* @name bternary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-ternary5d}\n*/\nimport bternary5d from './../../base/broadcasted-ternary5d';\nsetReadOnly( ns, 'bternary5d', bternary5d );\n\n/**\n* @name bunary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-unary2d}\n*/\nimport bunary2d from './../../base/broadcasted-unary2d';\nsetReadOnly( ns, 'bunary2d', bunary2d );\n\n/**\n* @name bunary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-unary3d}\n*/\nimport bunary3d from './../../base/broadcasted-unary3d';\nsetReadOnly( ns, 'bunary3d', bunary3d );\n\n/**\n* @name bunary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-unary4d}\n*/\nimport bunary4d from './../../base/broadcasted-unary4d';\nsetReadOnly( ns, 'bunary4d', bunary4d );\n\n/**\n* @name bunary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-unary5d}\n*/\nimport bunary5d from './../../base/broadcasted-unary5d';\nsetReadOnly( ns, 'bunary5d', bunary5d );\n\n/**\n* @name cartesianPower\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cartesian-power}\n*/\nimport cartesianPower from './../../base/cartesian-power';\nsetReadOnly( ns, 'cartesianPower', cartesianPower );\n\n/**\n* @name cartesianProduct\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cartesian-product}\n*/\nimport cartesianProduct from './../../base/cartesian-product';\nsetReadOnly( ns, 'cartesianProduct', cartesianProduct );\n\n/**\n* @name cartesianSquare\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cartesian-square}\n*/\nimport cartesianSquare from './../../base/cartesian-square';\nsetReadOnly( ns, 'cartesianSquare', cartesianSquare );\n\n/**\n* @name copy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/copy}\n*/\nimport copy from './../../base/copy';\nsetReadOnly( ns, 'copy', copy );\n\n/**\n* @name copyIndexed\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/copy-indexed}\n*/\nimport copyIndexed from './../../base/copy-indexed';\nsetReadOnly( ns, 'copyIndexed', copyIndexed );\n\n/**\n* @name countFalsy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-falsy}\n*/\nimport countFalsy from './../../base/count-falsy';\nsetReadOnly( ns, 'countFalsy', countFalsy );\n\n/**\n* @name countIf\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-if}\n*/\nimport countIf from './../../base/count-if';\nsetReadOnly( ns, 'countIf', countIf );\n\n/**\n* @name countIfs\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-ifs}\n*/\nimport countIfs from './../../base/count-ifs';\nsetReadOnly( ns, 'countIfs', countIfs );\n\n/**\n* @name countSameValue\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-same-value}\n*/\nimport countSameValue from './../../base/count-same-value';\nsetReadOnly( ns, 'countSameValue', countSameValue );\n\n/**\n* @name countSameValueZero\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-same-value-zero}\n*/\nimport countSameValueZero from './../../base/count-same-value-zero';\nsetReadOnly( ns, 'countSameValueZero', countSameValueZero );\n\n/**\n* @name countTruthy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-truthy}\n*/\nimport countTruthy from './../../base/count-truthy';\nsetReadOnly( ns, 'countTruthy', countTruthy );\n\n/**\n* @name cuany\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cuany}\n*/\nimport cuany from './../../base/cuany';\nsetReadOnly( ns, 'cuany', cuany );\n\n/**\n* @name cuevery\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cuevery}\n*/\nimport cuevery from './../../base/cuevery';\nsetReadOnly( ns, 'cuevery', cuevery );\n\n/**\n* @name cunone\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cunone}\n*/\nimport cunone from './../../base/cunone';\nsetReadOnly( ns, 'cunone', cunone );\n\n/**\n* @name dedupe\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/dedupe}\n*/\nimport dedupe from './../../base/dedupe';\nsetReadOnly( ns, 'dedupe', dedupe );\n\n/**\n* @name entries2objects\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/entries2objects}\n*/\nimport entries2objects from './../../base/entries2objects';\nsetReadOnly( ns, 'entries2objects', entries2objects );\n\n/**\n* @name entries2views\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/entries2views}\n*/\nimport entries2views from './../../base/entries2views';\nsetReadOnly( ns, 'entries2views', entries2views );\n\n/**\n* @name every\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/every}\n*/\nimport every from './../../base/every';\nsetReadOnly( ns, 'every', every );\n\n/**\n* @name everyBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/every-by}\n*/\nimport everyBy from './../../base/every-by';\nsetReadOnly( ns, 'everyBy', everyBy );\n\n/**\n* @name everyByRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/every-by-right}\n*/\nimport everyByRight from './../../base/every-by-right';\nsetReadOnly( ns, 'everyByRight', everyByRight );\n\n/**\n* @name fancySlice\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fancy-slice}\n*/\nimport fancySlice from './../../base/fancy-slice';\nsetReadOnly( ns, 'fancySlice', fancySlice );\n\n/**\n* @name fancySliceAssign\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fancy-slice-assign}\n*/\nimport fancySliceAssign from './../../base/fancy-slice-assign';\nsetReadOnly( ns, 'fancySliceAssign', fancySliceAssign );\n\n/**\n* @name fill\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fill}\n*/\nimport fill from './../../base/fill';\nsetReadOnly( ns, 'fill', fill );\n\n/**\n* @name fillBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fill-by}\n*/\nimport fillBy from './../../base/fill-by';\nsetReadOnly( ns, 'fillBy', fillBy );\n\n/**\n* @name filled\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled}\n*/\nimport filled from './../../base/filled';\nsetReadOnly( ns, 'filled', filled );\n\n/**\n* @name filledBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled-by}\n*/\nimport filledBy from './../../base/filled-by';\nsetReadOnly( ns, 'filledBy', filledBy );\n\n/**\n* @name filled2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled2d}\n*/\nimport filled2d from './../../base/filled2d';\nsetReadOnly( ns, 'filled2d', filled2d );\n\n/**\n* @name filled2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled2d-by}\n*/\nimport filled2dBy from './../../base/filled2d-by';\nsetReadOnly( ns, 'filled2dBy', filled2dBy );\n\n/**\n* @name filled3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled3d}\n*/\nimport filled3d from './../../base/filled3d';\nsetReadOnly( ns, 'filled3d', filled3d );\n\n/**\n* @name filled3dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled3d-by}\n*/\nimport filled3dBy from './../../base/filled3d-by';\nsetReadOnly( ns, 'filled3dBy', filled3dBy );\n\n/**\n* @name filled4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled4d}\n*/\nimport filled4d from './../../base/filled4d';\nsetReadOnly( ns, 'filled4d', filled4d );\n\n/**\n* @name filled4dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled4d-by}\n*/\nimport filled4dBy from './../../base/filled4d-by';\nsetReadOnly( ns, 'filled4dBy', filled4dBy );\n\n/**\n* @name filled5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled5d}\n*/\nimport filled5d from './../../base/filled5d';\nsetReadOnly( ns, 'filled5d', filled5d );\n\n/**\n* @name filled5dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled5d-by}\n*/\nimport filled5dBy from './../../base/filled5d-by';\nsetReadOnly( ns, 'filled5dBy', filled5dBy );\n\n/**\n* @name fillednd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fillednd}\n*/\nimport fillednd from './../../base/fillednd';\nsetReadOnly( ns, 'fillednd', fillednd );\n\n/**\n* @name filledndBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fillednd-by}\n*/\nimport filledndBy from './../../base/fillednd-by';\nsetReadOnly( ns, 'filledndBy', filledndBy );\n\n/**\n* @name filter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filter}\n*/\nimport filter from './../../base/filter';\nsetReadOnly( ns, 'filter', filter );\n\n/**\n* @name first\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/first}\n*/\nimport first from './../../base/first';\nsetReadOnly( ns, 'first', first );\n\n/**\n* @name flatten\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten}\n*/\nimport flatten from './../../base/flatten';\nsetReadOnly( ns, 'flatten', flatten );\n\n/**\n* @name flattenBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten-by}\n*/\nimport flattenBy from './../../base/flatten-by';\nsetReadOnly( ns, 'flattenBy', flattenBy );\n\n/**\n* @name flatten2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten2d}\n*/\nimport flatten2d from './../../base/flatten2d';\nsetReadOnly( ns, 'flatten2d', flatten2d );\n\n/**\n* @name flatten2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten2d-by}\n*/\nimport flatten2dBy from './../../base/flatten2d-by';\nsetReadOnly( ns, 'flatten2dBy', flatten2dBy );\n\n/**\n* @name flatten3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten3d}\n*/\nimport flatten3d from './../../base/flatten3d';\nsetReadOnly( ns, 'flatten3d', flatten3d );\n\n/**\n* @name flatten3dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten3d-by}\n*/\nimport flatten3dBy from './../../base/flatten3d-by';\nsetReadOnly( ns, 'flatten3dBy', flatten3dBy );\n\n/**\n* @name flatten4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten4d}\n*/\nimport flatten4d from './../../base/flatten4d';\nsetReadOnly( ns, 'flatten4d', flatten4d );\n\n/**\n* @name flatten4dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten4d-by}\n*/\nimport flatten4dBy from './../../base/flatten4d-by';\nsetReadOnly( ns, 'flatten4dBy', flatten4dBy );\n\n/**\n* @name flatten5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten5d}\n*/\nimport flatten5d from './../../base/flatten5d';\nsetReadOnly( ns, 'flatten5d', flatten5d );\n\n/**\n* @name flatten5dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten5d-by}\n*/\nimport flatten5dBy from './../../base/flatten5d-by';\nsetReadOnly( ns, 'flatten5dBy', flatten5dBy );\n\n/**\n* @name fliplr2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fliplr2d}\n*/\nimport fliplr2d from './../../base/fliplr2d';\nsetReadOnly( ns, 'fliplr2d', fliplr2d );\n\n/**\n* @name fliplr3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fliplr3d}\n*/\nimport fliplr3d from './../../base/fliplr3d';\nsetReadOnly( ns, 'fliplr3d', fliplr3d );\n\n/**\n* @name fliplr4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fliplr4d}\n*/\nimport fliplr4d from './../../base/fliplr4d';\nsetReadOnly( ns, 'fliplr4d', fliplr4d );\n\n/**\n* @name fliplr5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fliplr5d}\n*/\nimport fliplr5d from './../../base/fliplr5d';\nsetReadOnly( ns, 'fliplr5d', fliplr5d );\n\n/**\n* @name flipud2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flipud2d}\n*/\nimport flipud2d from './../../base/flipud2d';\nsetReadOnly( ns, 'flipud2d', flipud2d );\n\n/**\n* @name flipud3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flipud3d}\n*/\nimport flipud3d from './../../base/flipud3d';\nsetReadOnly( ns, 'flipud3d', flipud3d );\n\n/**\n* @name flipud4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flipud4d}\n*/\nimport flipud4d from './../../base/flipud4d';\nsetReadOnly( ns, 'flipud4d', flipud4d );\n\n/**\n* @name flipud5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flipud5d}\n*/\nimport flipud5d from './../../base/flipud5d';\nsetReadOnly( ns, 'flipud5d', flipud5d );\n\n/**\n* @name strided2array\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/from-strided}\n*/\nimport strided2array from './../../base/from-strided';\nsetReadOnly( ns, 'strided2array', strided2array );\n\n/**\n* @name getter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/getter}\n*/\nimport getter from './../../base/getter';\nsetReadOnly( ns, 'getter', getter );\n\n/**\n* @name groupEntries\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-entries}\n*/\nimport groupEntries from './../../base/group-entries';\nsetReadOnly( ns, 'groupEntries', groupEntries );\n\n/**\n* @name groupEntriesBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-entries-by}\n*/\nimport groupEntriesBy from './../../base/group-entries-by';\nsetReadOnly( ns, 'groupEntriesBy', groupEntriesBy );\n\n/**\n* @name groupIndices\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-indices}\n*/\nimport groupIndices from './../../base/group-indices';\nsetReadOnly( ns, 'groupIndices', groupIndices );\n\n/**\n* @name groupIndicesBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-indices-by}\n*/\nimport groupIndicesBy from './../../base/group-indices-by';\nsetReadOnly( ns, 'groupIndicesBy', groupIndicesBy );\n\n/**\n* @name groupValues\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-values}\n*/\nimport groupValues from './../../base/group-values';\nsetReadOnly( ns, 'groupValues', groupValues );\n\n/**\n* @name groupValuesBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-values-by}\n*/\nimport groupValuesBy from './../../base/group-values-by';\nsetReadOnly( ns, 'groupValuesBy', groupValuesBy );\n\n/**\n* @name groupValuesOnKey\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-values-on-key}\n*/\nimport groupValuesOnKey from './../../base/group-values-on-key';\nsetReadOnly( ns, 'groupValuesOnKey', groupValuesOnKey );\n\n/**\n* @name incrspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/incrspace}\n*/\nimport incrspace from './../../base/incrspace';\nsetReadOnly( ns, 'incrspace', incrspace );\n\n/**\n* @name indexOf\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/index-of}\n*/\nimport indexOf from './../../base/index-of';\nsetReadOnly( ns, 'indexOf', indexOf );\n\n/**\n* @name indexOfSameValue\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/index-of-same-value}\n*/\nimport indexOfSameValue from './../../base/index-of-same-value';\nsetReadOnly( ns, 'indexOfSameValue', indexOfSameValue );\n\n/**\n* @name indicesComplement\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/indices-complement}\n*/\nimport indicesComplement from './../../base/indices-complement';\nsetReadOnly( ns, 'indicesComplement', indicesComplement );\n\n/**\n* @name join\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/join}\n*/\nimport join from './../../base/join';\nsetReadOnly( ns, 'join', join );\n\n/**\n* @name last\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/last}\n*/\nimport last from './../../base/last';\nsetReadOnly( ns, 'last', last );\n\n/**\n* @name lastIndexOf\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/last-index-of}\n*/\nimport lastIndexOf from './../../base/last-index-of';\nsetReadOnly( ns, 'lastIndexOf', lastIndexOf );\n\n/**\n* @name lastIndexOfSameValue\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/last-index-of-same-value}\n*/\nimport lastIndexOfSameValue from './../../base/last-index-of-same-value';\nsetReadOnly( ns, 'lastIndexOfSameValue', lastIndexOfSameValue );\n\n/**\n* @name linspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/linspace}\n*/\nimport linspace from './../../base/linspace';\nsetReadOnly( ns, 'linspace', linspace );\n\n/**\n* @name linspace2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/linspace2d}\n*/\nimport linspace2d from './../../base/linspace2d';\nsetReadOnly( ns, 'linspace2d', linspace2d );\n\n/**\n* @name logspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/logspace}\n*/\nimport logspace from './../../base/logspace';\nsetReadOnly( ns, 'logspace', logspace );\n\n/**\n* @name map2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/map2d}\n*/\nimport map2d from './../../base/map2d';\nsetReadOnly( ns, 'map2d', map2d );\n\n/**\n* @name map3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/map3d}\n*/\nimport map3d from './../../base/map3d';\nsetReadOnly( ns, 'map3d', map3d );\n\n/**\n* @name map4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/map4d}\n*/\nimport map4d from './../../base/map4d';\nsetReadOnly( ns, 'map4d', map4d );\n\n/**\n* @name map5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/map5d}\n*/\nimport map5d from './../../base/map5d';\nsetReadOnly( ns, 'map5d', map5d );\n\n/**\n* @name minSignedIntegerDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/min-signed-integer-dtype}\n*/\nimport minSignedIntegerDataType from './../../base/min-signed-integer-dtype';\nsetReadOnly( ns, 'minSignedIntegerDataType', minSignedIntegerDataType );\n\n/**\n* @name minUnsignedIntegerDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/min-unsigned-integer-dtype}\n*/\nimport minUnsignedIntegerDataType from './../../base/min-unsigned-integer-dtype';\nsetReadOnly( ns, 'minUnsignedIntegerDataType', minUnsignedIntegerDataType );\n\n/**\n* @name mskbinary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskbinary2d}\n*/\nimport mskbinary2d from './../../base/mskbinary2d';\nsetReadOnly( ns, 'mskbinary2d', mskbinary2d );\n\n/**\n* @name mskbinary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskbinary3d}\n*/\nimport mskbinary3d from './../../base/mskbinary3d';\nsetReadOnly( ns, 'mskbinary3d', mskbinary3d );\n\n/**\n* @name mskbinary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskbinary4d}\n*/\nimport mskbinary4d from './../../base/mskbinary4d';\nsetReadOnly( ns, 'mskbinary4d', mskbinary4d );\n\n/**\n* @name mskbinary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskbinary5d}\n*/\nimport mskbinary5d from './../../base/mskbinary5d';\nsetReadOnly( ns, 'mskbinary5d', mskbinary5d );\n\n/**\n* @name mskfilter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskfilter}\n*/\nimport mskfilter from './../../base/mskfilter';\nsetReadOnly( ns, 'mskfilter', mskfilter );\n\n/**\n* @name mskfilterMap\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskfilter-map}\n*/\nimport mskfilterMap from './../../base/mskfilter-map';\nsetReadOnly( ns, 'mskfilterMap', mskfilterMap );\n\n/**\n* @name mskfilter2\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskfilter2}\n*/\nimport mskfilter2 from './../../base/mskfilter2';\nsetReadOnly( ns, 'mskfilter2', mskfilter2 );\n\n/**\n* @name mskfiltern\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskfiltern}\n*/\nimport mskfiltern from './../../base/mskfiltern';\nsetReadOnly( ns, 'mskfiltern', mskfiltern );\n\n/**\n* @name mskput\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskput}\n*/\nimport mskput from './../../base/mskput';\nsetReadOnly( ns, 'mskput', mskput );\n\n/**\n* @name mskreject\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskreject}\n*/\nimport mskreject from './../../base/mskreject';\nsetReadOnly( ns, 'mskreject', mskreject );\n\n/**\n* @name mskunary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskunary2d}\n*/\nimport mskunary2d from './../../base/mskunary2d';\nsetReadOnly( ns, 'mskunary2d', mskunary2d );\n\n/**\n* @name mskunary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskunary3d}\n*/\nimport mskunary3d from './../../base/mskunary3d';\nsetReadOnly( ns, 'mskunary3d', mskunary3d );\n\n/**\n* @name mskunary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskunary4d}\n*/\nimport mskunary4d from './../../base/mskunary4d';\nsetReadOnly( ns, 'mskunary4d', mskunary4d );\n\n/**\n* @name mskunary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskunary5d}\n*/\nimport mskunary5d from './../../base/mskunary5d';\nsetReadOnly( ns, 'mskunary5d', mskunary5d );\n\n/**\n* @name nCartesianProduct\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/n-cartesian-product}\n*/\nimport nCartesianProduct from './../../base/n-cartesian-product';\nsetReadOnly( ns, 'nCartesianProduct', nCartesianProduct );\n\n/**\n* @name nested2objects\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/nested2objects}\n*/\nimport nested2objects from './../../base/nested2objects';\nsetReadOnly( ns, 'nested2objects', nested2objects );\n\n/**\n* @name nested2views\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/nested2views}\n*/\nimport nested2views from './../../base/nested2views';\nsetReadOnly( ns, 'nested2views', nested2views );\n\n/**\n* @name none\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/none}\n*/\nimport none from './../../base/none';\nsetReadOnly( ns, 'none', none );\n\n/**\n* @name noneBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/none-by}\n*/\nimport noneBy from './../../base/none-by';\nsetReadOnly( ns, 'noneBy', noneBy );\n\n/**\n* @name noneByRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/none-by-right}\n*/\nimport noneByRight from './../../base/none-by-right';\nsetReadOnly( ns, 'noneByRight', noneByRight );\n\n/**\n* @name nulls\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/nulls}\n*/\nimport nulls from './../../base/nulls';\nsetReadOnly( ns, 'nulls', nulls );\n\n/**\n* @name oneTo\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/one-to}\n*/\nimport oneTo from './../../base/one-to';\nsetReadOnly( ns, 'oneTo', oneTo );\n\n/**\n* @name ones\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ones}\n*/\nimport ones from './../../base/ones';\nsetReadOnly( ns, 'ones', ones );\n\n/**\n* @name ones2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ones2d}\n*/\nimport ones2d from './../../base/ones2d';\nsetReadOnly( ns, 'ones2d', ones2d );\n\n/**\n* @name ones3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ones3d}\n*/\nimport ones3d from './../../base/ones3d';\nsetReadOnly( ns, 'ones3d', ones3d );\n\n/**\n* @name ones4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ones4d}\n*/\nimport ones4d from './../../base/ones4d';\nsetReadOnly( ns, 'ones4d', ones4d );\n\n/**\n* @name ones5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ones5d}\n*/\nimport ones5d from './../../base/ones5d';\nsetReadOnly( ns, 'ones5d', ones5d );\n\n/**\n* @name onesnd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/onesnd}\n*/\nimport onesnd from './../../base/onesnd';\nsetReadOnly( ns, 'onesnd', onesnd );\n\n/**\n* @name place\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/place}\n*/\nimport place from './../../base/place';\nsetReadOnly( ns, 'place', place );\n\n/**\n* @name put\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/put}\n*/\nimport put from './../../base/put';\nsetReadOnly( ns, 'put', put );\n\n/**\n* @name quaternary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quaternary2d}\n*/\nimport quaternary2d from './../../base/quaternary2d';\nsetReadOnly( ns, 'quaternary2d', quaternary2d );\n\n/**\n* @name quaternary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quaternary3d}\n*/\nimport quaternary3d from './../../base/quaternary3d';\nsetReadOnly( ns, 'quaternary3d', quaternary3d );\n\n/**\n* @name quaternary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quaternary4d}\n*/\nimport quaternary4d from './../../base/quaternary4d';\nsetReadOnly( ns, 'quaternary4d', quaternary4d );\n\n/**\n* @name quaternary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quaternary5d}\n*/\nimport quaternary5d from './../../base/quaternary5d';\nsetReadOnly( ns, 'quaternary5d', quaternary5d );\n\n/**\n* @name quinary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quinary2d}\n*/\nimport quinary2d from './../../base/quinary2d';\nsetReadOnly( ns, 'quinary2d', quinary2d );\n\n/**\n* @name quinary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quinary3d}\n*/\nimport quinary3d from './../../base/quinary3d';\nsetReadOnly( ns, 'quinary3d', quinary3d );\n\n/**\n* @name quinary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quinary4d}\n*/\nimport quinary4d from './../../base/quinary4d';\nsetReadOnly( ns, 'quinary4d', quinary4d );\n\n/**\n* @name quinary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quinary5d}\n*/\nimport quinary5d from './../../base/quinary5d';\nsetReadOnly( ns, 'quinary5d', quinary5d );\n\n/**\n* @name reject\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/reject}\n*/\nimport reject from './../../base/reject';\nsetReadOnly( ns, 'reject', reject );\n\n/**\n* @name rekey\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/rekey}\n*/\nimport rekey from './../../base/rekey';\nsetReadOnly( ns, 'rekey', rekey );\n\n/**\n* @name rekeyViews\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/rekey-views}\n*/\nimport rekeyViews from './../../base/rekey-views';\nsetReadOnly( ns, 'rekeyViews', rekeyViews );\n\n/**\n* @name removeAt\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/remove-at}\n*/\nimport removeAt from './../../base/remove-at';\nsetReadOnly( ns, 'removeAt', removeAt );\n\n/**\n* @name reshape\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/reshape}\n*/\nimport reshape from './../../base/reshape';\nsetReadOnly( ns, 'reshape', reshape );\n\n/**\n* @name resolveGetter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/resolve-getter}\n*/\nimport resolveGetter from './../../base/resolve-getter';\nsetReadOnly( ns, 'resolveGetter', resolveGetter );\n\n/**\n* @name resolveSetter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/resolve-setter}\n*/\nimport resolveSetter from './../../base/resolve-setter';\nsetReadOnly( ns, 'resolveSetter', resolveSetter );\n\n/**\n* @name reverse\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/reverse}\n*/\nimport reverse from './../../base/reverse';\nsetReadOnly( ns, 'reverse', reverse );\n\n/**\n* @name scatterFilled\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/scatter-filled}\n*/\nimport scatterFilled from './../../base/scatter-filled';\nsetReadOnly( ns, 'scatterFilled', scatterFilled );\n\n/**\n* @name scattered\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/scattered}\n*/\nimport scattered from './../../base/scattered';\nsetReadOnly( ns, 'scattered', scattered );\n\n/**\n* @name setter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/setter}\n*/\nimport setter from './../../base/setter';\nsetReadOnly( ns, 'setter', setter );\n\n/**\n* @name slice\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/slice}\n*/\nimport slice from './../../base/slice';\nsetReadOnly( ns, 'slice', slice );\n\n/**\n* @name strided2array2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/strided2array2d}\n*/\nimport strided2array2d from './../../base/strided2array2d';\nsetReadOnly( ns, 'strided2array2d', strided2array2d );\n\n/**\n* @name strided2array3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/strided2array3d}\n*/\nimport strided2array3d from './../../base/strided2array3d';\nsetReadOnly( ns, 'strided2array3d', strided2array3d );\n\n/**\n* @name strided2array4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/strided2array4d}\n*/\nimport strided2array4d from './../../base/strided2array4d';\nsetReadOnly( ns, 'strided2array4d', strided2array4d );\n\n/**\n* @name strided2array5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/strided2array5d}\n*/\nimport strided2array5d from './../../base/strided2array5d';\nsetReadOnly( ns, 'strided2array5d', strided2array5d );\n\n/**\n* @name symmetric\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/symmetric}\n*/\nimport symmetric from './../../base/symmetric';\nsetReadOnly( ns, 'symmetric', symmetric );\n\n/**\n* @name symmetricBanded\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/symmetric-banded}\n*/\nimport symmetricBanded from './../../base/symmetric-banded';\nsetReadOnly( ns, 'symmetricBanded', symmetricBanded );\n\n/**\n* @name take\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/take}\n*/\nimport take from './../../base/take';\nsetReadOnly( ns, 'take', take );\n\n/**\n* @name takeIndexed\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/take-indexed}\n*/\nimport takeIndexed from './../../base/take-indexed';\nsetReadOnly( ns, 'takeIndexed', takeIndexed );\n\n/**\n* @name takeIndexed2\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/take-indexed2}\n*/\nimport takeIndexed2 from './../../base/take-indexed2';\nsetReadOnly( ns, 'takeIndexed2', takeIndexed2 );\n\n/**\n* @name take2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/take2d}\n*/\nimport take2d from './../../base/take2d';\nsetReadOnly( ns, 'take2d', take2d );\n\n/**\n* @name take3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/take3d}\n*/\nimport take3d from './../../base/take3d';\nsetReadOnly( ns, 'take3d', take3d );\n\n/**\n* @name ternary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ternary2d}\n*/\nimport ternary2d from './../../base/ternary2d';\nsetReadOnly( ns, 'ternary2d', ternary2d );\n\n/**\n* @name ternary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ternary3d}\n*/\nimport ternary3d from './../../base/ternary3d';\nsetReadOnly( ns, 'ternary3d', ternary3d );\n\n/**\n* @name ternary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ternary4d}\n*/\nimport ternary4d from './../../base/ternary4d';\nsetReadOnly( ns, 'ternary4d', ternary4d );\n\n/**\n* @name ternary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ternary5d}\n*/\nimport ternary5d from './../../base/ternary5d';\nsetReadOnly( ns, 'ternary5d', ternary5d );\n\n/**\n* @name toAccessorArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/to-accessor-array}\n*/\nimport toAccessorArray from './../../base/to-accessor-array';\nsetReadOnly( ns, 'toAccessorArray', toAccessorArray );\n\n/**\n* @name toDeduped\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/to-deduped}\n*/\nimport toDeduped from './../../base/to-deduped';\nsetReadOnly( ns, 'toDeduped', toDeduped );\n\n/**\n* @name toReversed\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/to-reversed}\n*/\nimport toReversed from './../../base/to-reversed';\nsetReadOnly( ns, 'toReversed', toReversed );\n\n/**\n* @name unary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary2d}\n*/\nimport unary2d from './../../base/unary2d';\nsetReadOnly( ns, 'unary2d', unary2d );\n\n/**\n* @name unary2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary2d-by}\n*/\nimport unary2dBy from './../../base/unary2d-by';\nsetReadOnly( ns, 'unary2dBy', unary2dBy );\n\n/**\n* @name unary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary3d}\n*/\nimport unary3d from './../../base/unary3d';\nsetReadOnly( ns, 'unary3d', unary3d );\n\n/**\n* @name unary3dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary3d-by}\n*/\nimport unary3dBy from './../../base/unary3d-by';\nsetReadOnly( ns, 'unary3dBy', unary3dBy );\n\n/**\n* @name unary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary4d}\n*/\nimport unary4d from './../../base/unary4d';\nsetReadOnly( ns, 'unary4d', unary4d );\n\n/**\n* @name unary4dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary4d-by}\n*/\nimport unary4dBy from './../../base/unary4d-by';\nsetReadOnly( ns, 'unary4dBy', unary4dBy );\n\n/**\n* @name unary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary5d}\n*/\nimport unary5d from './../../base/unary5d';\nsetReadOnly( ns, 'unary5d', unary5d );\n\n/**\n* @name unary5dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary5d-by}\n*/\nimport unary5dBy from './../../base/unary5d-by';\nsetReadOnly( ns, 'unary5dBy', unary5dBy );\n\n/**\n* @name unarynd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unarynd}\n*/\nimport unarynd from './../../base/unarynd';\nsetReadOnly( ns, 'unarynd', unarynd );\n\n/**\n* @name unitspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unitspace}\n*/\nimport unitspace from './../../base/unitspace';\nsetReadOnly( ns, 'unitspace', unitspace );\n\n/**\n* @name where\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/where}\n*/\nimport where from './../../base/where';\nsetReadOnly( ns, 'where', where );\n\n/**\n* @name arrayWith\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/with}\n*/\nimport arrayWith from './../../base/with';\nsetReadOnly( ns, 'arrayWith', arrayWith );\n\n/**\n* @name without\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/without}\n*/\nimport without from './../../base/without';\nsetReadOnly( ns, 'without', without );\n\n/**\n* @name zeroTo\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zero-to}\n*/\nimport zeroTo from './../../base/zero-to';\nsetReadOnly( ns, 'zeroTo', zeroTo );\n\n/**\n* @name zeros\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zeros}\n*/\nimport zeros from './../../base/zeros';\nsetReadOnly( ns, 'zeros', zeros );\n\n/**\n* @name zeros2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zeros2d}\n*/\nimport zeros2d from './../../base/zeros2d';\nsetReadOnly( ns, 'zeros2d', zeros2d );\n\n/**\n* @name zeros3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zeros3d}\n*/\nimport zeros3d from './../../base/zeros3d';\nsetReadOnly( ns, 'zeros3d', zeros3d );\n\n/**\n* @name zeros4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zeros4d}\n*/\nimport zeros4d from './../../base/zeros4d';\nsetReadOnly( ns, 'zeros4d', zeros4d );\n\n/**\n* @name zeros5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zeros5d}\n*/\nimport zeros5d from './../../base/zeros5d';\nsetReadOnly( ns, 'zeros5d', zeros5d );\n\n/**\n* @name zerosnd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zerosnd}\n*/\nimport zerosnd from './../../base/zerosnd';\nsetReadOnly( ns, 'zerosnd', zerosnd );\n\n/**\n* @name zip\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zip}\n*/\nimport zip from './../../base/zip';\nsetReadOnly( ns, 'zip', zip );\n\n/**\n* @name zip2object\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zip2object}\n*/\nimport zip2object from './../../base/zip2object';\nsetReadOnly( ns, 'zip2object', zip2object );\n\n/**\n* @name zip2objects\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zip2objects}\n*/\nimport zip2objects from './../../base/zip2objects';\nsetReadOnly( ns, 'zip2objects', zip2objects );\n\n/**\n* @name zip2views\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zip2views}\n*/\nimport zip2views from './../../base/zip2views';\nsetReadOnly( ns, 'zip2views', zip2views );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'some' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = anyBy( x, isPositive );\n* // returns true\n*/\nfunction anyBy( x, predicate, thisArg ) {\n\tvar obj;\n\tif ( hasMethod( x, 'some' ) ) {\n\t\treturn x.some( predicate, thisArg );\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default anyBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = x.length-1; i >= 0; i-- ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = data.length-1; i >= 0; i-- ) {\n\t\tif ( predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function, while iterating from right to left.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = anyByRight( x, isPositive );\n* // returns true\n*/\nfunction anyByRight( x, predicate, thisArg ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default anyByRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in a provided indexed array has a specified own property.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = indexed( [ o1, o2, o3 ], 'b' );\n* // returns true\n*\n* bool = indexed( [ o1, o2, o3 ], 'd' );\n* // returns false\n*\n* bool = indexed( [ o1, o2, o3 ], 'toString' );\n* // returns false\n*/\nfunction indexed( arr, prop ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( hasOwnProp( arr[ i ], prop ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in a provided accessor array has a specified own property.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b' );\n* // returns true\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd' );\n* // returns false\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'toString' );\n* // returns false\n*/\nfunction accessors( arr, prop ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( arr );\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( hasOwnProp( get( arr, i ), prop ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in a provided array has a specified own property.\n*\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = anyHasOwnProp( [ o1, o2, o3 ], 'b' );\n* // returns true\n*\n* bool = anyHasOwnProp( [ o1, o2, o3 ], 'd' );\n* // returns false\n*\n* bool = anyHasOwnProp( [ o1, o2, o3 ], 'toString' );\n* // returns false\n*/\nfunction anyHasOwnProp( arr, prop ) {\n\tif ( isAccessorArray( arr ) ) {\n\t\treturn accessors( arr, prop );\n\t}\n\treturn indexed( arr, prop );\n}\n\n\n// EXPORTS //\n\nexport default anyHasOwnProp;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport hasProp from '@stdlib/assert/has-property';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in a provided indexed array has a specified property, either own or inherited.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = indexed( [ o1, o2, o3 ], 'b' );\n* // returns true\n*\n* bool = indexed( [ o1, o2, o3 ], 'd' );\n* // returns false\n*\n* bool = indexed( [ o1, o2, o3 ], 'toString' );\n* // returns true\n*/\nfunction indexed( arr, prop ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( hasProp( arr[ i ], prop ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in a provided accessor array has a specified property, either own or inherited.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b' );\n* // returns true\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd' );\n* // returns false\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'toString' );\n* // returns true\n*/\nfunction accessors( arr, prop ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( arr );\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( hasProp( get( arr, i ), prop ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in a provided array has a specified property, either own or inherited.\n*\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = anyHasProp( [ o1, o2, o3 ], 'b' );\n* // returns true\n*\n* bool = anyHasProp( [ o1, o2, o3 ], 'd' );\n* // returns false\n*\n* bool = anyHasProp( [ o1, o2, o3 ], 'toString' );\n* // returns true\n*/\nfunction anyHasProp( arr, prop ) {\n\tif ( isAccessorArray( arr ) ) {\n\t\treturn accessors( arr, prop );\n\t}\n\treturn indexed( arr, prop );\n}\n\n\n// EXPORTS //\n\nexport default anyHasProp;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in a provided indexed array has a specified own property key-value pair.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = indexed( [ o1, o2, o3 ], 'b', 2 );\n* // returns true\n*\n* bool = indexed( [ o1, o2, o3 ], 'b', 3 );\n* // returns false\n*\n* bool = indexed( [ o1, o2, o3 ], 'd', 0 );\n* // returns false\n*/\nfunction indexed( arr, prop, value ) {\n\tvar v;\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tv = arr[ i ];\n\t\tif ( hasOwnProp( v, prop ) && v[ prop ] === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in a provided accessor array has a specified own property key-value pair.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 2 );\n* // returns true\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 3 );\n* // returns false\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd', 0 );\n* // returns false\n*/\nfunction accessors( arr, prop, value ) {\n\tvar get;\n\tvar v;\n\tvar i;\n\n\tget = resolveGetter( arr );\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tv = get( arr, i );\n\t\tif ( hasOwnProp( v, prop ) && v[ prop ] === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in a provided array has a specified own property key-value pair.\n*\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = anyIsEntry( [ o1, o2, o3 ], 'b', 2 );\n* // returns true\n*\n* bool = anyIsEntry( [ o1, o2, o3 ], 'b', 3 );\n* // returns false\n*\n* bool = anyIsEntry( [ o1, o2, o3 ], 'd', 0 );\n* // returns false\n*/\nfunction anyIsEntry( arr, prop, value ) {\n\tif ( isAccessorArray( arr ) ) {\n\t\treturn accessors( arr, prop, value );\n\t}\n\treturn indexed( arr, prop, value );\n}\n\n\n// EXPORTS //\n\nexport default anyIsEntry;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport hasProp from '@stdlib/assert/has-property';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in a provided indexed array has a specified property key-value pair, either own or inherited.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = indexed( [ o1, o2, o3 ], 'b', 2 );\n* // returns true\n*\n* bool = indexed( [ o1, o2, o3 ], 'b', 3 );\n* // returns false\n*\n* bool = indexed( [ o1, o2, o3 ], 'd', 0 );\n* // returns false\n*/\nfunction indexed( arr, prop, value ) {\n\tvar v;\n\tvar i;\n\tif ( value === void 0 ) {\n\t\tfor ( i = 0; i < arr.length; i++ ) {\n\t\t\tv = arr[ i ];\n\t\t\tif ( hasProp( v, prop ) && v[ prop ] === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( arr[ i ][ prop ] === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in a provided accessor array has a specified property key-value pair, either own or inherited.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 2 );\n* // returns true\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 3 );\n* // returns false\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd', 0 );\n* // returns false\n*/\nfunction accessors( arr, prop, value ) {\n\tvar get;\n\tvar v;\n\tvar i;\n\n\tget = resolveGetter( arr );\n\tif ( value === void 0 ) {\n\t\tfor ( i = 0; i < arr.length; i++ ) {\n\t\t\tv = get( arr, i );\n\t\t\tif ( hasProp( v, prop ) && v[ prop ] === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( get( arr, i )[ prop ] === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in a provided array has a specified property key-value pair, either own or inherited.\n*\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 2 );\n* // returns true\n*\n* bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 3 );\n* // returns false\n*\n* bool = anyIsEntryIn( [ o1, o2, o3 ], 'd', 0 );\n* // returns false\n*/\nfunction anyIsEntryIn( arr, prop, value ) {\n\tif ( isAccessorArray( arr ) ) {\n\t\treturn accessors( arr, prop, value );\n\t}\n\treturn indexed( arr, prop, value );\n}\n\n\n// EXPORTS //\n\nexport default anyIsEntryIn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'map' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n\n// MAIN //\n\n/**\n* Returns an element from an array.\n*\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @returns {*} array element\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var v = at( x, 0 );\n* // returns 1\n*\n* v = at( x, 1 );\n* // returns 2\n*\n* v = at( x, -2 );\n* // returns 3\n*/\nfunction at( x, index ) {\n\tvar get;\n\tif ( hasMethod( x, 'at' ) ) {\n\t\treturn x.at( index );\n\t}\n\tif ( index < 0 ) {\n\t\tindex += x.length;\n\t\tif ( index < 0 ) {\n\t\t\treturn;\n\t\t}\n\t} else if ( index >= x.length ) {\n\t\treturn;\n\t}\n\tget = resolveGetter( x );\n\treturn get( x, index );\n}\n\n\n// EXPORTS //\n\nexport default at;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an element from a two-dimensional nested array.\n*\n* @param {ArrayLikeObject} x - input array\n* @param {integer} i0 - first dimension index\n* @param {integer} i1 - second dimension index\n* @returns {*} nested array element\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var v = at2d( x, 0, 1 );\n* // returns 2\n*\n* v = at2d( x, 1, 0 );\n* // returns 3\n*\n* v = at2d( x, -2, -2 );\n* // returns 1\n*/\nfunction at2d( x, i0, i1 ) {\n\tvar x0;\n\tvar N;\n\n\tN = x.length;\n\tif ( i0 < 0 ) {\n\t\ti0 += N;\n\t}\n\tif ( i0 < 0 || i0 >= N ) {\n\t\treturn;\n\t}\n\tx0 = x[ i0 ];\n\tN = x0.length;\n\tif ( i1 < 0 ) {\n\t\ti1 += N;\n\t}\n\tif ( i1 < 0 || i1 >= N ) {\n\t\treturn;\n\t}\n\treturn x0[ i1 ];\n}\n\n\n// EXPORTS //\n\nexport default at2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an element from a three-dimensional nested array.\n*\n* @param {ArrayLikeObject>} x - input array\n* @param {integer} i0 - first dimension index\n* @param {integer} i1 - second dimension index\n* @param {integer} i2 - third dimension index\n* @returns {*} nested array element\n*\n* @example\n* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ];\n*\n* var v = at3d( x, 0, 0, 1 );\n* // returns 2\n*\n* v = at3d( x, 0, 1, 0 );\n* // returns 3\n*\n* v = at3d( x, 0, -2, -2 );\n* // returns 1\n*/\nfunction at3d( x, i0, i1, i2 ) {\n\tvar x0;\n\tvar x1;\n\tvar N;\n\n\tN = x.length;\n\tif ( i0 < 0 ) {\n\t\ti0 += N;\n\t}\n\tif ( i0 < 0 || i0 >= N ) {\n\t\treturn;\n\t}\n\tx0 = x[ i0 ];\n\tN = x0.length;\n\tif ( i1 < 0 ) {\n\t\ti1 += N;\n\t}\n\tif ( i1 < 0 || i1 >= N ) {\n\t\treturn;\n\t}\n\tx1 = x0[ i1 ];\n\tN = x1.length;\n\tif ( i2 < 0 ) {\n\t\ti2 += N;\n\t}\n\tif ( i2 < 0 || i2 >= N ) {\n\t\treturn;\n\t}\n\treturn x1[ i2 ];\n}\n\n\n// EXPORTS //\n\nexport default at3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an element from a four-dimensional nested array.\n*\n* @param {ArrayLikeObject>>} x - input array\n* @param {integer} i0 - first dimension index\n* @param {integer} i1 - second dimension index\n* @param {integer} i2 - third dimension index\n* @param {integer} i3 - fourth dimension index\n* @returns {*} nested array element\n*\n* @example\n* var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ];\n*\n* var v = at4d( x, 0, 0, 0, 1 );\n* // returns 2\n*\n* v = at4d( x, 0, 0, 1, 0 );\n* // returns 3\n*\n* v = at4d( x, 0, 0, -2, -2 );\n* // returns 1\n*/\nfunction at4d( x, i0, i1, i2, i3 ) {\n\tvar value;\n\tvar idx;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tidx = [ i0, i1, i2, i3 ];\n\tvalue = x;\n\tfor ( i = 0; i < idx.length; i++ ) {\n\t\tj = idx[ i ];\n\t\tN = value.length;\n\t\tif ( j < 0 ) {\n\t\t\tj += N;\n\t\t}\n\t\tif ( j < 0 || j >= N ) {\n\t\t\treturn;\n\t\t}\n\t\tvalue = value[ j ];\n\t}\n\treturn value;\n}\n\n\n// EXPORTS //\n\nexport default at4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an element from a five-dimensional nested array.\n*\n* @param {ArrayLikeObject>>>} x - input array\n* @param {integer} i0 - first dimension index\n* @param {integer} i1 - second dimension index\n* @param {integer} i2 - third dimension index\n* @param {integer} i3 - fourth dimension index\n* @param {integer} i4 - fifth dimension index\n* @returns {*} nested array element\n*\n* @example\n* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ];\n*\n* var v = at5d( x, 0, 0, 0, 0, 1 );\n* // returns 2\n*\n* v = at5d( x, 0, 0, 0, 1, 0 );\n* // returns 3\n*\n* v = at5d( x, 0, 0, 0, -2, -2 );\n* // returns 1\n*/\nfunction at5d( x, i0, i1, i2, i3, i4 ) {\n\tvar value;\n\tvar idx;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tidx = [ i0, i1, i2, i3, i4 ];\n\tvalue = x;\n\tfor ( i = 0; i < idx.length; i++ ) {\n\t\tj = idx[ i ];\n\t\tN = value.length;\n\t\tif ( j < 0 ) {\n\t\t\tj += N;\n\t\t}\n\t\tif ( j < 0 || j >= N ) {\n\t\t\treturn;\n\t\t}\n\t\tvalue = value[ j ];\n\t}\n\treturn value;\n}\n\n\n// EXPORTS //\n\nexport default at5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an element from an n-dimensional nested array.\n*\n* @param {ArrayLikeObject} x - input array\n* @param {integer} i0 - first dimension index\n* @param {...integer} indices - dimension indices\n* @returns {*} nested array element\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var v = atnd( x, 0, 1 );\n* // returns 2\n*\n* v = atnd( x, 1, 0 );\n* // returns 3\n*\n* v = atnd( x, -2, -2 );\n* // returns 1\n*/\nfunction atnd( x, i0 ) {\n\tvar value;\n\tvar idx;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tidx = [ i0 ];\n\tfor ( i = 2; i < arguments.length; i++ ) {\n\t\tidx.push( arguments[ i ] );\n\t}\n\tvalue = x;\n\tfor ( i = 0; i < idx.length; i++ ) {\n\t\tj = idx[ i ];\n\t\tN = value.length;\n\t\tif ( j < 0 ) {\n\t\t\tj += N;\n\t\t}\n\t\tif ( j < 0 || j >= N ) {\n\t\t\treturn;\n\t\t}\n\t\tvalue = value[ j ];\n\t}\n\treturn value;\n}\n\n\n// EXPORTS //\n\nexport default atnd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits array element entries into two groups.\n*\n* @param {Collection} x - input array\n* @param {Collection} filter - array indicating which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {ArrayArray} results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var filter = [ true, true, false, true ];\n*\n* var out = bifurcateEntries( x, filter );\n* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ]\n*/\nfunction bifurcateEntries( x, filter ) {\n\tvar xget;\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( filter.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tgget = resolveGetter( filter );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = xget( x, i );\n\t\tg = gget( filter, i );\n\t\tif ( g ) {\n\t\t\tout[ 0 ].push( [ i, v ] );\n\t\t} else {\n\t\t\tout[ 1 ].push( [ i, v ] );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateEntries;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits element entries into two groups according to a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - predicate function execution context\n* @returns {Object} group results\n*\n* @example\n* function predicate( v ) {\n* return v[ 0 ] === 'b';\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = bifurcateEntriesBy( x, predicate );\n* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ]\n*/\nfunction bifurcateEntriesBy( x, predicate, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = get( x, i );\n\t\tif ( predicate.call( thisArg, v, i, x ) ) {\n\t\t\tout[ 0 ].push( [ i, v ] );\n\t\t} else {\n\t\t\tout[ 1 ].push( [ i, v ] );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateEntriesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits array element indices into two groups.\n*\n* @param {Collection} x - input array\n* @param {Collection} filter - array indicating which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {ArrayArray} results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var filter = [ true, true, false, true ];\n*\n* var out = bifurcateIndices( x, filter );\n* // returns [ [ 0, 1, 3 ], [ 2 ] ]\n*/\nfunction bifurcateIndices( x, filter ) {\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( filter.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve accessors for retrieving array elements:\n\tgget = resolveGetter( filter );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tg = gget( filter, i );\n\t\tif ( g ) {\n\t\t\tout[ 0 ].push( i );\n\t\t} else {\n\t\t\tout[ 1 ].push( i );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateIndices;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits element indices into two groups according to a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - predicate function execution context\n* @returns {Object} group results\n*\n* @example\n* function predicate( v ) {\n* return v[ 0 ] === 'b';\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = bifurcateIndicesBy( x, predicate );\n* // returns [ [ 0, 1, 3 ], [ 2 ] ]\n*/\nfunction bifurcateIndicesBy( x, predicate, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tout[ 0 ].push( i );\n\t\t} else {\n\t\t\tout[ 1 ].push( i );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateIndicesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits array element values into two groups.\n*\n* @param {Collection} x - input array\n* @param {Collection} filter - array indicating which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {ArrayArray} results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var filter = [ true, true, false, true ];\n*\n* var out = bifurcateValues( x, filter );\n* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]\n*/\nfunction bifurcateValues( x, filter ) {\n\tvar xget;\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( filter.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tgget = resolveGetter( filter );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = xget( x, i );\n\t\tg = gget( filter, i );\n\t\tif ( g ) {\n\t\t\tout[ 0 ].push( v );\n\t\t} else {\n\t\t\tout[ 1 ].push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateValues;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits element values into two groups according to a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - predicate function execution context\n* @returns {Object} group results\n*\n* @example\n* function predicate( v ) {\n* return v[ 0 ] === 'b';\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = bifurcateValuesBy( x, predicate );\n* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]\n*/\nfunction bifurcateValuesBy( x, predicate, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = get( x, i );\n\t\tif ( predicate.call( thisArg, v, i, x ) ) {\n\t\t\tout[ 0 ].push( v );\n\t\t} else {\n\t\t\tout[ 1 ].push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateValuesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = ones2d( shape );\n* var z = zeros2d( shape );\n*\n* binary2d( [ x, y, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ]\n*/\nfunction binary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tz0 = z[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default binary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 2, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = ones3d( shape );\n* var z = zeros3d( shape );\n*\n* binary3d( [ x, y, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ]\n*/\nfunction binary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar z0;\n\tvar z1;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tz1 = z[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default binary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 1, 2, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = ones4d( shape );\n* var z = zeros4d( shape );\n*\n* binary4d( [ x, y, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ]\n*/\nfunction binary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tz2 = z[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default binary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 1, 1, 2, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = ones5d( shape );\n* var z = zeros5d( shape );\n*\n* binary5d( [ x, y, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ]\n*/\nfunction binary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar z3;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tz3 = z[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default binary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shapes = [\n* [ 1, 2 ],\n* [ 2, 1 ],\n* [ 2, 2 ]\n* ];\n*\n* var x = ones2d( shapes[ 0 ] );\n* var y = ones2d( shapes[ 1 ] );\n* var z = zeros2d( shapes[ 2 ] );\n*\n* bbinary2d( [ x, y, z ], shapes, add );\n*\n* console.log( z );\n* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ]\n*/\nfunction bbinary2d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dy0;\n\tvar dy1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar j0;\n\tvar j1;\n\tvar k0;\n\tvar k1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tsh = shapes[ 2 ];\n\tS0 = sh[ 1 ];\n\tS1 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 1 ];\n\tdx1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 1 ];\n\tdy1 = st[ 0 ];\n\n\tz = arrays[ 2 ];\n\n\tj1 = 0;\n\tk1 = 0;\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tj0 = 0;\n\t\tk0 = 0;\n\t\tx0 = x[ j1 ];\n\t\ty0 = y[ k1 ];\n\t\tz0 = z[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tz0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] );\n\t\t\tj0 += dx0;\n\t\t\tk0 += dy0;\n\t\t}\n\t\tj1 += dx1;\n\t\tk1 += dy1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bbinary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shapes = [\n* [ 1, 1, 2 ],\n* [ 2, 1, 1 ],\n* [ 2, 2, 2 ]\n* ];\n*\n* var x = ones3d( shapes[ 0 ] );\n* var y = ones3d( shapes[ 1 ] );\n* var z = zeros3d( shapes[ 2 ] );\n*\n* bbinary3d( [ x, y, z ], shapes, add );\n*\n* console.log( z );\n* // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ]\n*/\nfunction bbinary3d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar z0;\n\tvar z1;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tsh = shapes[ 2 ];\n\tS0 = sh[ 2 ];\n\tS1 = sh[ 1 ];\n\tS2 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 2 ];\n\tdx1 = st[ 1 ];\n\tdx2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 2 ];\n\tdy1 = st[ 1 ];\n\tdy2 = st[ 0 ];\n\n\tz = arrays[ 2 ];\n\n\tj2 = 0;\n\tk2 = 0;\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tj1 = 0;\n\t\tk1 = 0;\n\t\tx1 = x[ j2 ];\n\t\ty1 = y[ k2 ];\n\t\tz1 = z[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tj0 = 0;\n\t\t\tk0 = 0;\n\t\t\tx0 = x1[ j1 ];\n\t\t\ty0 = y1[ k1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tz0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] );\n\t\t\t\tj0 += dx0;\n\t\t\t\tk0 += dy0;\n\t\t\t}\n\t\t\tj1 += dx1;\n\t\t\tk1 += dy1;\n\t\t}\n\t\tj2 += dx2;\n\t\tk2 += dy2;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bbinary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shapes = [\n* [ 1, 1, 1, 2 ],\n* [ 1, 2, 1, 1 ],\n* [ 1, 2, 2, 2 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = ones4d( shapes[ 1 ] );\n* var z = zeros4d( shapes[ 2 ] );\n*\n* bbinary4d( [ x, y, z ], shapes, add );\n*\n* console.log( z );\n* // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ]\n*/\nfunction bbinary4d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tsh = shapes[ 2 ];\n\tS0 = sh[ 3 ];\n\tS1 = sh[ 2 ];\n\tS2 = sh[ 1 ];\n\tS3 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 3 ];\n\tdx1 = st[ 2 ];\n\tdx2 = st[ 1 ];\n\tdx3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 3 ];\n\tdy1 = st[ 2 ];\n\tdy2 = st[ 1 ];\n\tdy3 = st[ 0 ];\n\n\tz = arrays[ 2 ];\n\n\tj3 = 0;\n\tk3 = 0;\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tj2 = 0;\n\t\tk2 = 0;\n\t\tx2 = x[ j3 ];\n\t\ty2 = y[ k3 ];\n\t\tz2 = z[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tj1 = 0;\n\t\t\tk1 = 0;\n\t\t\tx1 = x2[ j2 ];\n\t\t\ty1 = y2[ k2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tj0 = 0;\n\t\t\t\tk0 = 0;\n\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tz0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] );\n\t\t\t\t\tj0 += dx0;\n\t\t\t\t\tk0 += dy0;\n\t\t\t\t}\n\t\t\t\tj1 += dx1;\n\t\t\t\tk1 += dy1;\n\t\t\t}\n\t\t\tj2 += dx2;\n\t\t\tk2 += dy2;\n\t\t}\n\t\tj3 += dx3;\n\t\tk3 += dy3;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bbinary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shapes = [\n* [ 1, 1, 1, 1, 2 ],\n* [ 1, 1, 2, 1, 1 ],\n* [ 1, 1, 2, 2, 2 ]\n* ];\n*\n* var x = ones5d( shapes[ 0 ] );\n* var y = ones5d( shapes[ 1 ] );\n* var z = zeros5d( shapes[ 2 ] );\n*\n* bbinary5d( [ x, y, z ], shapes, add );\n*\n* console.log( z );\n* // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ]\n*/\nfunction bbinary5d( arrays, shapes, fcn ) { // eslint-disable-line max-statements\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dx4;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dy4;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar j4;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar k4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar z3;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tsh = shapes[ 2 ];\n\tS0 = sh[ 4 ];\n\tS1 = sh[ 3 ];\n\tS2 = sh[ 2 ];\n\tS3 = sh[ 1 ];\n\tS4 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 4 ];\n\tdx1 = st[ 3 ];\n\tdx2 = st[ 2 ];\n\tdx3 = st[ 1 ];\n\tdx4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 4 ];\n\tdy1 = st[ 3 ];\n\tdy2 = st[ 2 ];\n\tdy3 = st[ 1 ];\n\tdy4 = st[ 0 ];\n\n\tz = arrays[ 2 ];\n\n\tj4 = 0;\n\tk4 = 0;\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tj3 = 0;\n\t\tk3 = 0;\n\t\tx3 = x[ j4 ];\n\t\ty3 = y[ k4 ];\n\t\tz3 = z[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tj2 = 0;\n\t\t\tk2 = 0;\n\t\t\tx2 = x3[ j3 ];\n\t\t\ty2 = y3[ k3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tj1 = 0;\n\t\t\t\tk1 = 0;\n\t\t\t\tx1 = x2[ j2 ];\n\t\t\t\ty1 = y2[ k2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tj0 = 0;\n\t\t\t\t\tk0 = 0;\n\t\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tz0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] );\n\t\t\t\t\t\tj0 += dx0;\n\t\t\t\t\t\tk0 += dy0;\n\t\t\t\t\t}\n\t\t\t\t\tj1 += dx1;\n\t\t\t\t\tk1 += dy1;\n\t\t\t\t}\n\t\t\t\tj2 += dx2;\n\t\t\t\tk2 += dy2;\n\t\t\t}\n\t\t\tj3 += dx3;\n\t\t\tk3 += dy3;\n\t\t}\n\t\tj4 += dx4;\n\t\tk4 += dy4;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bbinary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* var shapes = [\n* [ 1, 2 ],\n* [ 2, 1 ],\n* [ 1, 1 ],\n* [ 2, 2 ],\n* [ 2, 2 ]\n* ];\n*\n* var x = ones2d( shapes[ 0 ] );\n* var y = ones2d( shapes[ 1 ] );\n* var z = ones2d( shapes[ 2 ] );\n* var w = ones2d( shapes[ 3 ] );\n* var out = zeros2d( shapes[ 4 ] );\n*\n* bquaternary2d( [ x, y, z, w, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ]\n*/\nfunction bquaternary2d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dy0;\n\tvar dy1;\n\tvar dz0;\n\tvar dz1;\n\tvar dw0;\n\tvar dw1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar j0;\n\tvar j1;\n\tvar k0;\n\tvar k1;\n\tvar m0;\n\tvar m1;\n\tvar n0;\n\tvar n1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\n\tsh = shapes[ 4 ];\n\tS0 = sh[ 1 ];\n\tS1 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 1 ];\n\tdx1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 1 ];\n\tdy1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 1 ];\n\tdz1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 1 ];\n\tdw1 = st[ 0 ];\n\n\tu = arrays[ 4 ];\n\n\tj1 = 0;\n\tk1 = 0;\n\tm1 = 0;\n\tn1 = 0;\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tj0 = 0;\n\t\tk0 = 0;\n\t\tm0 = 0;\n\t\tn0 = 0;\n\t\tx0 = x[ j1 ];\n\t\ty0 = y[ k1 ];\n\t\tz0 = z[ m1 ];\n\t\tw0 = w[ n1 ];\n\t\tu0 = u[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tu0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] );\n\t\t\tj0 += dx0;\n\t\t\tk0 += dy0;\n\t\t\tm0 += dz0;\n\t\t\tn0 += dw0;\n\t\t}\n\t\tj1 += dx1;\n\t\tk1 += dy1;\n\t\tm1 += dz1;\n\t\tn1 += dw1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquaternary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* var shapes = [\n* [ 1, 1, 3 ],\n* [ 3, 1, 1 ],\n* [ 1, 3, 1 ],\n* [ 3, 3, 3 ],\n* [ 3, 3, 3 ]\n* ];\n*\n* var x = ones3d( shapes[ 0 ] );\n* var y = ones3d( shapes[ 1 ] );\n* var z = ones3d( shapes[ 2 ] );\n* var w = ones3d( shapes[ 3 ] );\n* var out = zeros3d( shapes[ 4 ] );\n*\n* bquaternary3d( [ x, y, z, w, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ]\n*/\nfunction bquaternary3d( arrays, shapes, fcn ) { // eslint-disable-line max-statements\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dw0;\n\tvar dw1;\n\tvar dw2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar n0;\n\tvar n1;\n\tvar n2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar z0;\n\tvar z1;\n\tvar w0;\n\tvar w1;\n\tvar u0;\n\tvar u1;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\n\tsh = shapes[ 4 ];\n\tS0 = sh[ 2 ];\n\tS1 = sh[ 1 ];\n\tS2 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 2 ];\n\tdx1 = st[ 1 ];\n\tdx2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 2 ];\n\tdy1 = st[ 1 ];\n\tdy2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 2 ];\n\tdz1 = st[ 1 ];\n\tdz2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 2 ];\n\tdw1 = st[ 1 ];\n\tdw2 = st[ 0 ];\n\n\tu = arrays[ 4 ];\n\n\tj2 = 0;\n\tk2 = 0;\n\tm2 = 0;\n\tn2 = 0;\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tj1 = 0;\n\t\tk1 = 0;\n\t\tm1 = 0;\n\t\tn1 = 0;\n\t\tx1 = x[ j2 ];\n\t\ty1 = y[ k2 ];\n\t\tz1 = z[ m2 ];\n\t\tw1 = w[ n2 ];\n\t\tu1 = u[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tj0 = 0;\n\t\t\tk0 = 0;\n\t\t\tm0 = 0;\n\t\t\tn0 = 0;\n\t\t\tx0 = x1[ j1 ];\n\t\t\ty0 = y1[ k1 ];\n\t\t\tz0 = z1[ m1 ];\n\t\t\tw0 = w1[ n1 ];\n\t\t\tu0 = u1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tu0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] );\n\t\t\t\tj0 += dx0;\n\t\t\t\tk0 += dy0;\n\t\t\t\tm0 += dz0;\n\t\t\t\tn0 += dw0;\n\t\t\t}\n\t\t\tj1 += dx1;\n\t\t\tk1 += dy1;\n\t\t\tm1 += dz1;\n\t\t\tn1 += dw1;\n\t\t}\n\t\tj2 += dx2;\n\t\tk2 += dy2;\n\t\tm2 += dz2;\n\t\tn2 += dw2;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquaternary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* var shapes = [\n* [ 1, 3, 1, 1 ],\n* [ 1, 1, 3, 1 ],\n* [ 1, 1, 1, 3 ],\n* [ 1, 1, 1, 1 ],\n* [ 1, 3, 3, 3 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = ones4d( shapes[ 1 ] );\n* var z = ones4d( shapes[ 2 ] );\n* var w = ones4d( shapes[ 3 ] );\n* var out = zeros4d( shapes[ 4 ] );\n*\n* bquaternary4d( [ x, y, z, w, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ]\n*/\nfunction bquaternary4d( arrays, shapes, fcn ) { // eslint-disable-line max-statements\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dz3;\n\tvar dw0;\n\tvar dw1;\n\tvar dw2;\n\tvar dw3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar n0;\n\tvar n1;\n\tvar n2;\n\tvar n3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar w0;\n\tvar w1;\n\tvar w2;\n\tvar u0;\n\tvar u1;\n\tvar u2;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\n\tsh = shapes[ 4 ];\n\tS0 = sh[ 3 ];\n\tS1 = sh[ 2 ];\n\tS2 = sh[ 1 ];\n\tS3 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 3 ];\n\tdx1 = st[ 2 ];\n\tdx2 = st[ 1 ];\n\tdx3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 3 ];\n\tdy1 = st[ 2 ];\n\tdy2 = st[ 1 ];\n\tdy3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 3 ];\n\tdz1 = st[ 2 ];\n\tdz2 = st[ 1 ];\n\tdz3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 3 ];\n\tdw1 = st[ 2 ];\n\tdw2 = st[ 1 ];\n\tdw3 = st[ 0 ];\n\n\tu = arrays[ 4 ];\n\n\tj3 = 0;\n\tk3 = 0;\n\tm3 = 0;\n\tn3 = 0;\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tj2 = 0;\n\t\tk2 = 0;\n\t\tm2 = 0;\n\t\tn2 = 0;\n\t\tx2 = x[ j3 ];\n\t\ty2 = y[ k3 ];\n\t\tz2 = z[ m3 ];\n\t\tw2 = w[ n3 ];\n\t\tu2 = u[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tj1 = 0;\n\t\t\tk1 = 0;\n\t\t\tm1 = 0;\n\t\t\tn1 = 0;\n\t\t\tx1 = x2[ j2 ];\n\t\t\ty1 = y2[ k2 ];\n\t\t\tz1 = z2[ m2 ];\n\t\t\tw1 = w2[ n2 ];\n\t\t\tu1 = u2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tj0 = 0;\n\t\t\t\tk0 = 0;\n\t\t\t\tm0 = 0;\n\t\t\t\tn0 = 0;\n\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\tz0 = z1[ m1 ];\n\t\t\t\tw0 = w1[ n1 ];\n\t\t\t\tu0 = u1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tu0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] );\n\t\t\t\t\tj0 += dx0;\n\t\t\t\t\tk0 += dy0;\n\t\t\t\t\tm0 += dz0;\n\t\t\t\t\tn0 += dw0;\n\t\t\t\t}\n\t\t\t\tj1 += dx1;\n\t\t\t\tk1 += dy1;\n\t\t\t\tm1 += dz1;\n\t\t\t\tn1 += dw1;\n\t\t\t}\n\t\t\tj2 += dx2;\n\t\t\tk2 += dy2;\n\t\t\tm2 += dz2;\n\t\t\tn2 += dw2;\n\t\t}\n\t\tj3 += dx3;\n\t\tk3 += dy3;\n\t\tm3 += dz3;\n\t\tn3 += dw3;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquaternary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* var shapes = [\n* [ 1, 1, 3, 1, 1 ],\n* [ 1, 1, 1, 3, 1 ],\n* [ 1, 1, 1, 1, 3 ],\n* [ 1, 1, 1, 1, 1 ],\n* [ 1, 1, 3, 3, 3 ]\n* ];\n*\n* var x = ones5d( shapes[ 0 ] );\n* var y = ones5d( shapes[ 1 ] );\n* var z = ones5d( shapes[ 2 ] );\n* var w = ones5d( shapes[ 3 ] );\n* var out = zeros5d( shapes[ 4 ] );\n*\n* bquaternary5d( [ x, y, z, w, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ] ]\n*/\nfunction bquaternary5d( arrays, shapes, fcn ) { // eslint-disable-line max-statements\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dx4;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dy4;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dz3;\n\tvar dz4;\n\tvar dw0;\n\tvar dw1;\n\tvar dw2;\n\tvar dw3;\n\tvar dw4;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar j4;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar k4;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar m4;\n\tvar n0;\n\tvar n1;\n\tvar n2;\n\tvar n3;\n\tvar n4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar z3;\n\tvar w0;\n\tvar w1;\n\tvar w2;\n\tvar w3;\n\tvar u0;\n\tvar u1;\n\tvar u2;\n\tvar u3;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\n\tsh = shapes[ 4 ];\n\tS0 = sh[ 4 ];\n\tS1 = sh[ 3 ];\n\tS2 = sh[ 2 ];\n\tS3 = sh[ 1 ];\n\tS4 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 4 ];\n\tdx1 = st[ 3 ];\n\tdx2 = st[ 2 ];\n\tdx3 = st[ 1 ];\n\tdx4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 4 ];\n\tdy1 = st[ 3 ];\n\tdy2 = st[ 2 ];\n\tdy3 = st[ 1 ];\n\tdy4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 4 ];\n\tdz1 = st[ 3 ];\n\tdz2 = st[ 2 ];\n\tdz3 = st[ 1 ];\n\tdz4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 4 ];\n\tdw1 = st[ 3 ];\n\tdw2 = st[ 2 ];\n\tdw3 = st[ 1 ];\n\tdw4 = st[ 0 ];\n\n\tu = arrays[ 4 ];\n\n\tj4 = 0;\n\tk4 = 0;\n\tm4 = 0;\n\tn4 = 0;\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tj3 = 0;\n\t\tk3 = 0;\n\t\tm3 = 0;\n\t\tn3 = 0;\n\t\tx3 = x[ j4 ];\n\t\ty3 = y[ k4 ];\n\t\tz3 = z[ m4 ];\n\t\tw3 = w[ n4 ];\n\t\tu3 = u[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tj2 = 0;\n\t\t\tk2 = 0;\n\t\t\tm2 = 0;\n\t\t\tn2 = 0;\n\t\t\tx2 = x3[ j3 ];\n\t\t\ty2 = y3[ k3 ];\n\t\t\tz2 = z3[ m3 ];\n\t\t\tw2 = w3[ n3 ];\n\t\t\tu2 = u3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tj1 = 0;\n\t\t\t\tk1 = 0;\n\t\t\t\tm1 = 0;\n\t\t\t\tn1 = 0;\n\t\t\t\tx1 = x2[ j2 ];\n\t\t\t\ty1 = y2[ k2 ];\n\t\t\t\tz1 = z2[ m2 ];\n\t\t\t\tw1 = w2[ n2 ];\n\t\t\t\tu1 = u2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tj0 = 0;\n\t\t\t\t\tk0 = 0;\n\t\t\t\t\tm0 = 0;\n\t\t\t\t\tn0 = 0;\n\t\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\t\tz0 = z1[ m1 ];\n\t\t\t\t\tw0 = w1[ n1 ];\n\t\t\t\t\tu0 = u1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tu0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] );\n\t\t\t\t\t\tj0 += dx0;\n\t\t\t\t\t\tk0 += dy0;\n\t\t\t\t\t\tm0 += dz0;\n\t\t\t\t\t\tn0 += dw0;\n\t\t\t\t\t}\n\t\t\t\t\tj1 += dx1;\n\t\t\t\t\tk1 += dy1;\n\t\t\t\t\tm1 += dz1;\n\t\t\t\t\tn1 += dw1;\n\t\t\t\t}\n\t\t\t\tj2 += dx2;\n\t\t\t\tk2 += dy2;\n\t\t\t\tm2 += dz2;\n\t\t\t\tn2 += dw2;\n\t\t\t}\n\t\t\tj3 += dx3;\n\t\t\tk3 += dy3;\n\t\t\tm3 += dz3;\n\t\t\tn3 += dw3;\n\t\t}\n\t\tj4 += dx4;\n\t\tk4 += dy4;\n\t\tm4 += dz4;\n\t\tn4 += dw4;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquaternary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function add( x, y, z, w, v ) {\n* return x + y + z + w + v;\n* }\n*\n* var shapes = [\n* [ 1, 2 ],\n* [ 2, 1 ],\n* [ 1, 1 ],\n* [ 2, 2 ],\n* [ 1, 1 ],\n* [ 2, 2 ]\n* ];\n*\n* var x = ones2d( shapes[ 0 ] );\n* var y = ones2d( shapes[ 1 ] );\n* var z = ones2d( shapes[ 2 ] );\n* var w = ones2d( shapes[ 3 ] );\n* var v = ones2d( shapes[ 4 ] );\n* var out = zeros2d( shapes[ 5 ] );\n*\n* bquinary2d( [ x, y, z, w, v, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ]\n*/\nfunction bquinary2d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dy0;\n\tvar dy1;\n\tvar dz0;\n\tvar dz1;\n\tvar dw0;\n\tvar dw1;\n\tvar du0;\n\tvar du1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar j0;\n\tvar j1;\n\tvar k0;\n\tvar k1;\n\tvar m0;\n\tvar m1;\n\tvar n0;\n\tvar n1;\n\tvar p0;\n\tvar p1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar v0;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tsh = shapes[ 5 ];\n\tS0 = sh[ 1 ];\n\tS1 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 1 ];\n\tdx1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 1 ];\n\tdy1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 1 ];\n\tdz1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 1 ];\n\tdw1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 4 ], shapes[ 4 ], sh );\n\tu = o.data;\n\tst = o.strides;\n\tdu0 = st[ 1 ];\n\tdu1 = st[ 0 ];\n\n\tv = arrays[ 5 ];\n\n\tj1 = 0;\n\tk1 = 0;\n\tm1 = 0;\n\tn1 = 0;\n\tp1 = 0;\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tj0 = 0;\n\t\tk0 = 0;\n\t\tm0 = 0;\n\t\tn0 = 0;\n\t\tp0 = 0;\n\t\tx0 = x[ j1 ];\n\t\ty0 = y[ k1 ];\n\t\tz0 = z[ m1 ];\n\t\tw0 = w[ n1 ];\n\t\tu0 = u[ p1 ];\n\t\tv0 = v[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tv0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ], u0[ p0 ] );\n\t\t\tj0 += dx0;\n\t\t\tk0 += dy0;\n\t\t\tm0 += dz0;\n\t\t\tn0 += dw0;\n\t\t\tp0 += du0;\n\t\t}\n\t\tj1 += dx1;\n\t\tk1 += dy1;\n\t\tm1 += dz1;\n\t\tn1 += dw1;\n\t\tp1 += du1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquinary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function add( x, y, z, w, v ) {\n* return x + y + z + w + v;\n* }\n*\n* var shapes = [\n* [ 1, 1, 1, 2 ],\n* [ 1, 1, 2, 1 ],\n* [ 1, 1, 2, 2 ],\n* [ 1, 2, 1, 1 ],\n* [ 2, 2, 2, 2 ],\n* [ 2, 2, 2, 2 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = ones4d( shapes[ 1 ] );\n* var z = ones4d( shapes[ 2 ] );\n* var w = ones4d( shapes[ 3 ] );\n* var v = ones4d( shapes[ 4 ] );\n* var out = zeros4d( shapes[ 5 ] );\n*\n* bquinary4d( [ x, y, z, w, v, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ], [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ]\n*/\nfunction bquinary4d( arrays, shapes, fcn ) { // eslint-disable-line max-statements\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dz3;\n\tvar dw0;\n\tvar dw1;\n\tvar dw2;\n\tvar dw3;\n\tvar du0;\n\tvar du1;\n\tvar du2;\n\tvar du3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar n0;\n\tvar n1;\n\tvar n2;\n\tvar n3;\n\tvar p0;\n\tvar p1;\n\tvar p2;\n\tvar p3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar w0;\n\tvar w1;\n\tvar w2;\n\tvar u0;\n\tvar u1;\n\tvar u2;\n\tvar v0;\n\tvar v1;\n\tvar v2;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tsh = shapes[ 5 ];\n\tS0 = sh[ 3 ];\n\tS1 = sh[ 2 ];\n\tS2 = sh[ 1 ];\n\tS3 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 3 ];\n\tdx1 = st[ 2 ];\n\tdx2 = st[ 1 ];\n\tdx3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 3 ];\n\tdy1 = st[ 2 ];\n\tdy2 = st[ 1 ];\n\tdy3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 3 ];\n\tdz1 = st[ 2 ];\n\tdz2 = st[ 1 ];\n\tdz3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 3 ];\n\tdw1 = st[ 2 ];\n\tdw2 = st[ 1 ];\n\tdw3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 4 ], shapes[ 4 ], sh );\n\tu = o.data;\n\tst = o.strides;\n\tdu0 = st[ 3 ];\n\tdu1 = st[ 2 ];\n\tdu2 = st[ 1 ];\n\tdu3 = st[ 0 ];\n\n\tv = arrays[ 5 ];\n\n\tj3 = 0;\n\tk3 = 0;\n\tm3 = 0;\n\tn3 = 0;\n\tp3 = 0;\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tj2 = 0;\n\t\tk2 = 0;\n\t\tm2 = 0;\n\t\tn2 = 0;\n\t\tp2 = 0;\n\t\tx2 = x[ j3 ];\n\t\ty2 = y[ k3 ];\n\t\tz2 = z[ m3 ];\n\t\tw2 = w[ n3 ];\n\t\tu2 = u[ p3 ];\n\t\tv2 = v[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tj1 = 0;\n\t\t\tk1 = 0;\n\t\t\tm1 = 0;\n\t\t\tn1 = 0;\n\t\t\tp1 = 0;\n\t\t\tx1 = x2[ j2 ];\n\t\t\ty1 = y2[ k2 ];\n\t\t\tz1 = z2[ m2 ];\n\t\t\tw1 = w2[ n2 ];\n\t\t\tu1 = u2[ p2 ];\n\t\t\tv1 = v2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tj0 = 0;\n\t\t\t\tk0 = 0;\n\t\t\t\tm0 = 0;\n\t\t\t\tn0 = 0;\n\t\t\t\tp0 = 0;\n\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\tz0 = z1[ m1 ];\n\t\t\t\tw0 = w1[ n1 ];\n\t\t\t\tu0 = u1[ p1 ];\n\t\t\t\tv0 = v1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tv0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ], u0[ p0 ] ); // eslint-disable-line max-len\n\t\t\t\t\tj0 += dx0;\n\t\t\t\t\tk0 += dy0;\n\t\t\t\t\tm0 += dz0;\n\t\t\t\t\tn0 += dw0;\n\t\t\t\t\tp0 += du0;\n\t\t\t\t}\n\t\t\t\tj1 += dx1;\n\t\t\t\tk1 += dy1;\n\t\t\t\tm1 += dz1;\n\t\t\t\tn1 += dw1;\n\t\t\t\tp1 += du1;\n\t\t\t}\n\t\t\tj2 += dx2;\n\t\t\tk2 += dy2;\n\t\t\tm2 += dz2;\n\t\t\tn2 += dw2;\n\t\t\tp2 += du2;\n\t\t}\n\t\tj3 += dx3;\n\t\tk3 += dy3;\n\t\tm3 += dz3;\n\t\tn3 += dw3;\n\t\tp3 += du3;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquinary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import add from '@stdlib/number/float64/base/add3';\n*\n* var shapes = [\n* [ 1, 2 ],\n* [ 2, 1 ],\n* [ 1, 1 ],\n* [ 2, 2 ]\n* ];\n*\n* var x = ones2d( shapes[ 0 ] );\n* var y = ones2d( shapes[ 1 ] );\n* var z = ones2d( shapes[ 2 ] );\n* var out = zeros2d( shapes[ 3 ] );\n*\n* bternary2d( [ x, y, z, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ]\n*/\nfunction bternary2d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dy0;\n\tvar dy1;\n\tvar dz0;\n\tvar dz1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar j0;\n\tvar j1;\n\tvar k0;\n\tvar k1;\n\tvar m0;\n\tvar m1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tsh = shapes[ 3 ];\n\tS0 = sh[ 1 ];\n\tS1 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 1 ];\n\tdx1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 1 ];\n\tdy1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 1 ];\n\tdz1 = st[ 0 ];\n\n\tw = arrays[ 3 ];\n\n\tj1 = 0;\n\tk1 = 0;\n\tm1 = 0;\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tj0 = 0;\n\t\tk0 = 0;\n\t\tm0 = 0;\n\t\tx0 = x[ j1 ];\n\t\ty0 = y[ k1 ];\n\t\tz0 = z[ m1 ];\n\t\tw0 = w[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tw0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] );\n\t\t\tj0 += dx0;\n\t\t\tk0 += dy0;\n\t\t\tm0 += dz0;\n\t\t}\n\t\tj1 += dx1;\n\t\tk1 += dy1;\n\t\tm1 += dz1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bternary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import add from '@stdlib/number/float64/base/add3';\n*\n* var shapes = [\n* [ 1, 2, 1 ],\n* [ 2, 1, 1 ],\n* [ 1, 1, 2 ],\n* [ 2, 2, 2 ]\n* ];\n*\n* var x = ones3d( shapes[ 0 ] );\n* var y = ones3d( shapes[ 1 ] );\n* var z = ones3d( shapes[ 2 ] );\n* var out = zeros3d( shapes[ 3 ] );\n*\n* bternary3d( [ x, y, z, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] , [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ]\n*/\nfunction bternary3d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar z0;\n\tvar z1;\n\tvar sh;\n\tvar st;\n\tvar w0;\n\tvar w1;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tsh = shapes[ 3 ];\n\tS0 = sh[ 2 ];\n\tS1 = sh[ 1 ];\n\tS2 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 2 ];\n\tdx1 = st[ 1 ];\n\tdx2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 2 ];\n\tdy1 = st[ 1 ];\n\tdy2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 2 ];\n\tdz1 = st[ 1 ];\n\tdz2 = st[ 0 ];\n\n\tw = arrays[ 3 ];\n\tj2 = 0;\n\tk2 = 0;\n\tm2 = 0;\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tj1 = 0;\n\t\tk1 = 0;\n\t\tm1 = 0;\n\t\tx1 = x[ j2 ];\n\t\ty1 = y[ k2 ];\n\t\tz1 = z[ m2 ];\n\t\tw1 = w[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tj0 = 0;\n\t\t\tk0 = 0;\n\t\t\tm0 = 0;\n\t\t\tx0 = x1[ j1 ];\n\t\t\ty0 = y1[ k1 ];\n\t\t\tz0 = z1[ m1 ];\n\t\t\tw0 = w1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tw0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] );\n\t\t\t\tj0 += dx0;\n\t\t\t\tk0 += dy0;\n\t\t\t\tm0 += dz0;\n\t\t\t}\n\t\t\tj1 += dx1;\n\t\t\tk1 += dy1;\n\t\t\tm1 += dz1;\n\t\t}\n\t\tj2 += dx2;\n\t\tk2 += dy2;\n\t\tm2 += dz2;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bternary3d;\n","/* eslint-disable max-statements */\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import add from '@stdlib/number/float64/base/add3';\n*\n* var shapes = [\n* [ 1, 2, 1, 1 ],\n* [ 2, 1, 1, 1 ],\n* [ 1, 1, 2, 1 ],\n* [ 2, 2, 2, 2 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = ones4d( shapes[ 1 ] );\n* var z = ones4d( shapes[ 2 ] );\n* var out = zeros4d( shapes[ 3 ] );\n*\n* bternary4d( [ x, y, z, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ], [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ]\n*/\nfunction bternary4d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dz3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar sh;\n\tvar st;\n\tvar w0;\n\tvar w1;\n\tvar w2;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tsh = shapes[ 3 ];\n\tS0 = sh[ 3 ];\n\tS1 = sh[ 2 ];\n\tS2 = sh[ 1 ];\n\tS3 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 3 ];\n\tdx1 = st[ 2 ];\n\tdx2 = st[ 1 ];\n\tdx3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 3 ];\n\tdy1 = st[ 2 ];\n\tdy2 = st[ 1 ];\n\tdy3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 3 ];\n\tdz1 = st[ 2 ];\n\tdz2 = st[ 1 ];\n\tdz3 = st[ 0 ];\n\n\tw = arrays[ 3 ];\n\tj3 = 0;\n\tk3 = 0;\n\tm3 = 0;\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tj2 = 0;\n\t\tk2 = 0;\n\t\tm2 = 0;\n\t\tx2 = x[ j3 ];\n\t\ty2 = y[ k3 ];\n\t\tz2 = z[ m3 ];\n\t\tw2 = w[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tj1 = 0;\n\t\t\tk1 = 0;\n\t\t\tm1 = 0;\n\t\t\tx1 = x2[ j2 ];\n\t\t\ty1 = y2[ k2 ];\n\t\t\tz1 = z2[ m2 ];\n\t\t\tw1 = w2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tj0 = 0;\n\t\t\t\tk0 = 0;\n\t\t\t\tm0 = 0;\n\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\tz0 = z1[ m1 ];\n\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tw0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] );\n\t\t\t\t\tj0 += dx0;\n\t\t\t\t\tk0 += dy0;\n\t\t\t\t\tm0 += dz0;\n\t\t\t\t}\n\t\t\t\tj1 += dx1;\n\t\t\t\tk1 += dy1;\n\t\t\t\tm1 += dz1;\n\t\t\t}\n\t\t\tj2 += dx2;\n\t\t\tk2 += dy2;\n\t\t\tm2 += dz2;\n\t\t}\n\t\tj3 += dx3;\n\t\tk3 += dy3;\n\t\tm3 += dz3;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bternary4d;\n","/* eslint-disable max-statements */\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import add from '@stdlib/number/float64/base/add3';\n\n* var shapes = [\n* [ 1, 2, 1, 1, 1 ],\n* [ 2, 1, 1, 1, 1 ],\n* [ 1, 1, 1, 1, 1 ],\n* [ 2, 2, 1, 1, 1 ]\n* ];\n*\n* var x = ones5d( shapes[ 0 ] );\n* var y = ones5d( shapes[ 1 ] );\n* var z = ones5d( shapes[ 2 ] );\n* var out = zeros5d( shapes[ 3 ] );\n*\n* bternary5d( [ x, y, z, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ [ 3.0 ] ] ], [ [ [ 3.0 ] ] ] ], [ [ [ [ 3.0 ] ] ], [ [ [ 3.0 ] ] ] ] ]\n*/\nfunction bternary5d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dx4;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dy4;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dz3;\n\tvar dz4;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar j4;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar k4;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar m4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar z3;\n\tvar sh;\n\tvar st;\n\tvar w0;\n\tvar w1;\n\tvar w2;\n\tvar w3;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tsh = shapes[ 3 ];\n\tS0 = sh[ 4 ];\n\tS1 = sh[ 3 ];\n\tS2 = sh[ 2 ];\n\tS3 = sh[ 1 ];\n\tS4 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 4 ];\n\tdx1 = st[ 3 ];\n\tdx2 = st[ 2 ];\n\tdx3 = st[ 1 ];\n\tdx4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 4 ];\n\tdy1 = st[ 3 ];\n\tdy2 = st[ 2 ];\n\tdy3 = st[ 1 ];\n\tdy4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 4 ];\n\tdz1 = st[ 3 ];\n\tdz2 = st[ 2 ];\n\tdz3 = st[ 1 ];\n\tdz4 = st[ 0 ];\n\n\tw = arrays[ 3 ];\n\tj4 = 0;\n\tk4 = 0;\n\tm4 = 0;\n\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tj3 = 0;\n\t\tk3 = 0;\n\t\tm3 = 0;\n\t\tx3 = x[ j4 ];\n\t\ty3 = y[ k4 ];\n\t\tz3 = z[ m4 ];\n\t\tw3 = w[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tj2 = 0;\n\t\t\tk2 = 0;\n\t\t\tm2 = 0;\n\t\t\tx2 = x3[ j3 ];\n\t\t\ty2 = y3[ k3 ];\n\t\t\tz2 = z3[ m3 ];\n\t\t\tw2 = w3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tj1 = 0;\n\t\t\t\tk1 = 0;\n\t\t\t\tm1 = 0;\n\t\t\t\tx1 = x2[ j2 ];\n\t\t\t\ty1 = y2[ k2 ];\n\t\t\t\tz1 = z2[ m2 ];\n\t\t\t\tw1 = w2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tj0 = 0;\n\t\t\t\t\tk0 = 0;\n\t\t\t\t\tm0 = 0;\n\t\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\t\tz0 = z1[ m1 ];\n\t\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tw0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] );\n\t\t\t\t\t\tj0 += dx0;\n\t\t\t\t\t\tk0 += dy0;\n\t\t\t\t\t\tm0 += dz0;\n\t\t\t\t\t}\n\t\t\t\t\tj1 += dx1;\n\t\t\t\t\tk1 += dy1;\n\t\t\t\t\tm1 += dz1;\n\t\t\t\t}\n\t\t\t\tj2 += dx2;\n\t\t\t\tk2 += dy2;\n\t\t\t\tm2 += dz2;\n\t\t\t}\n\t\t\tj3 += dx3;\n\t\t\tk3 += dy3;\n\t\t\tm3 += dz3;\n\t\t}\n\t\tj4 += dx4;\n\t\tk4 += dy4;\n\t\tm4 += dz4;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bternary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a two-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shapes = [\n* [ 1, 2 ],\n* [ 2, 2 ]\n* ];\n*\n* var x = ones2d( shapes[ 0 ] );\n* var y = zeros2d( shapes[ 1 ] );\n*\n* bunary2d( [ x, y ], shapes, scale );\n*\n* console.log( y );\n* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*/\nfunction bunary2d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar j0;\n\tvar j1;\n\tvar x0;\n\tvar y0;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\n\tsh = shapes[ 1 ];\n\tS0 = sh[ 1 ];\n\tS1 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 1 ];\n\tdx1 = st[ 0 ];\n\n\ty = arrays[ 1 ];\n\n\tj1 = 0;\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tj0 = 0;\n\t\tx0 = x[ j1 ];\n\t\ty0 = y[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\ty0[ i0 ] = fcn( x0[ j0 ] );\n\t\t\tj0 += dx0;\n\t\t}\n\t\tj1 += dx1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bunary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a three-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shapes = [\n* [ 1, 1, 2 ],\n* [ 1, 2, 2 ]\n* ];\n*\n* var x = ones3d( shapes[ 0 ] );\n* var y = zeros3d( shapes[ 1 ] );\n*\n* bunary3d( [ x, y ], shapes, scale );\n*\n* console.log( y );\n* // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*/\nfunction bunary3d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\n\tsh = shapes[ 1 ];\n\tS0 = sh[ 2 ];\n\tS1 = sh[ 1 ];\n\tS2 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 2 ];\n\tdx1 = st[ 1 ];\n\tdx2 = st[ 0 ];\n\n\ty = arrays[ 1 ];\n\tj2 = 0;\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tj1 = 0;\n\t\tx1 = x[ j2 ];\n\t\ty1 = y[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tj0 = 0;\n\t\t\tx0 = x1[ j1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\ty0[ i0 ] = fcn( x0[ j0 ] );\n\t\t\t\tj0 += dx0;\n\t\t\t}\n\t\t\tj1 += dx1;\n\t\t}\n\t\tj2 += dx2;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bunary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shapes = [\n* [ 1, 1, 1, 2 ],\n* [ 1, 1, 2, 2 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = zeros4d( shapes[ 1 ] );\n*\n* bunary4d( [ x, y ], shapes, scale );\n*\n* console.log( y );\n* // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction bunary4d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\n\tsh = shapes[ 1 ];\n\tS0 = sh[ 3 ];\n\tS1 = sh[ 2 ];\n\tS2 = sh[ 1 ];\n\tS3 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 3 ];\n\tdx1 = st[ 2 ];\n\tdx2 = st[ 1 ];\n\tdx3 = st[ 0 ];\n\n\ty = arrays[ 1 ];\n\tj3 = 0;\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tj2 = 0;\n\t\tx2 = x[ j3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tj1 = 0;\n\t\t\tx1 = x2[ j2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tj0 = 0;\n\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn( x0[ j0 ] );\n\t\t\t\t\tj0 += dx0;\n\t\t\t\t}\n\t\t\t\tj1 += dx1;\n\t\t\t}\n\t\t\tj2 += dx2;\n\t\t}\n\t\tj3 += dx3;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bunary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a five-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shapes = [\n* [ 1, 1, 1, 1, 2 ],\n* [ 1, 1, 1, 2, 2 ]\n* ];\n*\n* var x = ones5d( shapes[ 0 ] );\n* var y = zeros5d( shapes[ 1 ] );\n*\n* bunary5d( [ x, y ], shapes, scale );\n*\n* console.log( y );\n* // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*/\nfunction bunary5d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dx4;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar j4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\n\tsh = shapes[ 1 ];\n\tS0 = sh[ 4 ];\n\tS1 = sh[ 3 ];\n\tS2 = sh[ 2 ];\n\tS3 = sh[ 1 ];\n\tS4 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 4 ];\n\tdx1 = st[ 3 ];\n\tdx2 = st[ 2 ];\n\tdx3 = st[ 1 ];\n\tdx4 = st[ 0 ];\n\n\ty = arrays[ 1 ];\n\tj4 = 0;\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tj3 = 0;\n\t\tx3 = x[ j4 ];\n\t\ty3 = y[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tj2 = 0;\n\t\t\tx2 = x3[ j3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tj1 = 0;\n\t\t\t\tx1 = x2[ j2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tj0 = 0;\n\t\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\ty0[ i0 ] = fcn( x0[ j0 ] );\n\t\t\t\t\t\tj0 += dx0;\n\t\t\t\t\t}\n\t\t\t\t\tj1 += dx1;\n\t\t\t\t}\n\t\t\t\tj2 += dx2;\n\t\t\t}\n\t\t\tj3 += dx3;\n\t\t}\n\t\tj4 += dx4;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bunary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of elements in an indexed array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport isSameValue from '@stdlib/assert/is-same-value';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of elements in an array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, 1 );\n* // returns 3\n*/\nfunction indexed( x, value ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValue( x[ i ], value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a provided value\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, 1 );\n* // returns 3\n*/\nfunction accessors( x, value ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValue( get( x, i ), value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var n = complex( x, new Complex128( 1.0, 2.0 ) );\n* // returns 1\n*/\nfunction complex( x, value ) {\n\tvar view;\n\tvar re;\n\tvar im;\n\tvar n;\n\tvar i;\n\n\tif ( !isComplexLike( value ) ) {\n\t\treturn 0;\n\t}\n\tre = real( value );\n\tim = imag( value );\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( isSameValue( view[ i ], re ) && isSameValue( view[ i+1 ], im ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a boolean array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var x = new BooleanArray( [ true, false, true, false, true ] );\n*\n* var n = boolean( x, true );\n* // returns 3\n*/\nfunction boolean( x, value ) {\n\tvar view;\n\tvar n;\n\tvar v;\n\tvar i;\n\n\tif ( !isBoolean( value ) ) {\n\t\treturn 0;\n\t}\n\tview = reinterpretBoolean( x, 0 );\n\n\tv = ( value ) ? 1 : 0;\n\tn = 0;\n\tfor ( i = 0; i < view.length; i++ ) {\n\t\tif ( view[ i ] === v ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that are equal to a specified value.\n*\n* ## Notes\n*\n* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countSameValue( x, 1 );\n* // returns 3\n*/\nfunction countSameValue( x, value ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, value );\n\t\t}\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn boolean( x, value );\n\t\t}\n\t\treturn accessors( x, value );\n\t}\n\treturn indexed( x, value );\n}\n\n\n// EXPORTS //\n\nexport default countSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport isSameValueZero from '@stdlib/assert/is-same-value-zero';\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of elements in an indexed array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var x = [ 0, 0, 1, 0, 1 ];\n*\n* var n = indexed( x, 0 );\n* // returns 3\n*/\nfunction indexed( x, value ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValueZero( x[ i ], value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 0, 1, 0, 1 ] );\n*\n* var n = accessors( x, 0 );\n* // returns 3\n*/\nfunction accessors( x, value ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValueZero( get( x, i ), value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var n = complex( x, new Complex128( 1.0, 2.0 ) );\n* // returns 1\n*/\nfunction complex( x, value ) {\n\tvar view;\n\tvar re;\n\tvar im;\n\tvar n;\n\tvar i;\n\n\tif ( !isComplexLike( value ) ) {\n\t\treturn 0;\n\t}\n\tre = real( value );\n\tim = imag( value );\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( isSameValueZero( view[ i ], re ) && isSameValueZero( view[ i+1 ], im ) ) { // eslint-disable-line max-len\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a boolean array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var x = new BooleanArray( [ true, false, true, false, true ] );\n*\n* var n = boolean( x, true );\n* // returns 3\n*/\nfunction boolean( x, value ) {\n\tvar view;\n\tvar n;\n\tvar v;\n\tvar i;\n\n\tif ( !isBoolean( value ) ) {\n\t\treturn 0;\n\t}\n\tview = reinterpretBoolean( x, 0 );\n\n\tv = ( value ) ? 1 : 0;\n\tn = 0;\n\tfor ( i = 0; i < view.length; i++ ) {\n\t\tif ( view[ i ] === v ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that are equal to a specified value.\n*\n* ## Notes\n*\n* - The function uses the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016.\n* - In contrast to an implementation based on the strict equality operator `===`, the function treats `NaNs` as the same value.\n*\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import countSameValueZero from '@stdlib/array/base/count-same-value-zero';\n*\n* var x = [ 0, 0, 1, 0, 1 ];\n*\n* var n = countSameValueZero( x, 1 );\n* // returns 2\n*/\nfunction countSameValueZero( x, value ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, value );\n\t\t}\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn boolean( x, value );\n\t\t}\n\t\treturn accessors( x, value );\n\t}\n\treturn indexed( x, value );\n}\n\n\n// EXPORTS //\n\nexport default countSameValueZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from '@stdlib/math/base/assert/is-nan';\n\n\n// FUNCTIONS //\n\n/**\n* De-duplicates values in-place.\n*\n* @private\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @returns {Array} input array\n*\n* @example\n* var x = [ 1, 1, 2, 3, 3 ];\n*\n* var y = dedupeInPlace( x, 1 );\n* // returns [ 1, 2, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ];\n*\n* var y = dedupeInPlace( x, 2 );\n* // returns [ 1, 1, 2, 1, 1, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*/\nfunction dedupeInPlace( x, limit ) {\n\tvar count;\n\tvar prev;\n\tvar len;\n\tvar ptr;\n\tvar v;\n\tvar i;\n\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn x;\n\t}\n\tprev = x[ 0 ];\n\tcount = 1;\n\tptr = 1;\n\tfor ( i = 1; i < len; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( v === prev ) {\n\t\t\tcount += 1;\n\t\t\tif ( count <= limit ) {\n\t\t\t\tx[ ptr ] = prev;\n\t\t\t\tptr += 1;\n\t\t\t}\n\t\t} else {\n\t\t\tprev = v;\n\t\t\tcount = 1;\n\t\t\tx[ ptr ] = prev;\n\t\t\tptr += 1;\n\t\t}\n\t}\n\tx.length = ptr;\n\treturn x;\n}\n\n/**\n* De-duplicates values in-place, treating `NaN` values as equal.\n*\n* @private\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @returns {Array} input array\n*\n* @example\n* var x = [ 1, 1, 2, NaN, NaN, 3, 3 ];\n*\n* var y = dedupeEqualNaNs( x, 1 );\n* // returns [ 1, 2, NaN, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, NaN, NaN, NaN, 3, 3 ];\n*\n* var y = dedupeEqualNaNs( x, 2 );\n* // returns [ 1, 1, 2, 1, 1, NaN, NaN, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*/\nfunction dedupeEqualNaNs( x, limit ) {\n\tvar count;\n\tvar prev;\n\tvar len;\n\tvar ptr;\n\tvar FLG;\n\tvar v;\n\tvar i;\n\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn x;\n\t}\n\tFLG = false;\n\tprev = x[ 0 ];\n\tif ( isnan( prev ) ) {\n\t\tFLG = true;\n\t}\n\tcount = 1;\n\tptr = 1;\n\tfor ( i = 1; i < len; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( v === prev || ( FLG && isnan( v ) ) ) {\n\t\t\tcount += 1;\n\t\t\tif ( count <= limit ) {\n\t\t\t\tx[ ptr ] = prev;\n\t\t\t\tptr += 1;\n\t\t\t}\n\t\t} else {\n\t\t\tprev = v;\n\t\t\tcount = 1;\n\t\t\tx[ ptr ] = prev;\n\t\t\tptr += 1;\n\t\t\tFLG = false;\n\t\t\tif ( isnan( prev ) ) {\n\t\t\t\tFLG = true;\n\t\t\t}\n\t\t}\n\t}\n\tx.length = ptr;\n\treturn x;\n}\n\n\n// MAIN //\n\n/**\n* Removes consecutive duplicated values.\n*\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @param {boolean} equalNaNs - boolean indicating whether NaNs should be considered equal\n* @returns {Array} de-duplicated values\n*\n* @example\n* var x = [ 1, 1, 2, 3, 3 ];\n*\n* var y = dedupe( x, 1, false );\n* // returns [ 1, 2, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ];\n*\n* var y = dedupe( x, 2, false );\n* // returns [ 1, 1, 2, 1, 1, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*/\nfunction dedupe( x, limit, equalNaNs ) {\n\tif ( equalNaNs ) {\n\t\treturn dedupeEqualNaNs( x, limit );\n\t}\n\treturn dedupeInPlace( x, limit );\n}\n\n\n// EXPORTS //\n\nexport default dedupe;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Convert array entries to an array of objects.\n*\n* ## Notes\n*\n* - The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value.\n*\n* @param {Collection} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3 ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = entries2objects( x, fields );\n* // returns [ { 'x': 0, 'y': 1 }, { 'x': 1, 'y': 2 }, { 'x': 2, 'y': 3 } ]\n*/\nfunction entries2objects( arr, fields ) {\n\tvar get;\n\tvar out;\n\tvar obj;\n\tvar N;\n\tvar i;\n\tvar k;\n\tvar v;\n\n\tN = arr.length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\tget = resolveGetter( fields );\n\tk = get( fields, 0 );\n\tv = get( fields, 1 );\n\n\tget = resolveGetter( arr );\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tobj = {};\n\t\tobj[ k ] = i;\n\t\tobj[ v ] = get( arr, i );\n\t\tout.push( obj );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default entries2objects;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils/define-read-write-accessor';\nimport resolveGetter from './../../../base/resolve-getter';\nimport accessors from './../../../base/accessors';\n\n\n// MAIN //\n\n/**\n* Converts array entries to an array of composite views.\n*\n* ## Notes\n*\n* - The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value.\n* - For each element of the returned array, the index view field is read-only and cannot be mutated.\n*\n* @param {Collection} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3 ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = entries2views( x, fields );\n* // returns [ , , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 0, 'y': 1 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v2 = out[ 2 ].toJSON();\n* // returns { 'x': 2, 'y': 3 }\n*\n* // Mutate the input array:\n* x[ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 0, 'y': 5 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 1, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ 5, 'beep', 3 ]\n*/\nfunction entries2views( arr, fields ) {\n\tvar fget;\n\tvar get;\n\tvar set;\n\tvar acc;\n\tvar out;\n\tvar N;\n\tvar k;\n\tvar v;\n\tvar i;\n\n\tN = arr.length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Resolve element accessors:\n\tacc = accessors( arr ).accessors;\n\tget = acc[ 0 ];\n\tset = acc[ 1 ];\n\n\t// Cache field names:\n\tfget = resolveGetter( fields );\n\tk = fget( fields, 0 );\n\tv = fget( fields, 1 );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( i ) {\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field:\n\tsetReadOnlyAccessor( Datum.prototype, k, getIndex );\n\tsetReadWriteAccessor( Datum.prototype, v, getValue, setValue );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout.push( new Datum( i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Returns the entry index.\n\t*\n\t* @private\n\t* @returns {*} result\n\t*/\n\tfunction getIndex() {\n\t\treturn this._i;\n\t}\n\n\t/**\n\t* Returns the value associated with a field.\n\t*\n\t* @private\n\t* @returns {*} result\n\t*/\n\tfunction getValue() {\n\t\treturn get( arr, this._i );\n\t}\n\n\t/**\n\t* Sets the value associated with a field.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t*/\n\tfunction setValue( value ) {\n\t\tset( arr, this._i, value );\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\n\t\tout = {};\n\t\tout[ k ] = this[ k ];\n\t\tout[ v ] = this[ v ];\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default entries2views;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a read-only accessor.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Function} getter - accessor\n*\n* @example\n* function getter() {\n* return 'bar';\n* }\n*\n* var obj = {};\n*\n* setReadOnlyAccessor( obj, 'foo', getter );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setReadOnlyAccessor( obj, prop, getter ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'get': getter\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setReadOnlyAccessor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'every' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( !predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = everyBy( x, isPositive );\n* // returns true\n*/\nfunction everyBy( x, predicate, thisArg ) {\n\tvar obj;\n\tif ( hasMethod( x, 'every' ) ) {\n\t\treturn x.every( predicate, thisArg );\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default everyBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = x.length-1; i >= 0; i-- ) {\n\t\tif ( !predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = data.length-1; i >= 0; i-- ) {\n\t\tif ( !predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function, iterating from right to left.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = everyByRight( x, isPositive );\n* // returns true\n*/\nfunction everyByRight( x, predicate, thisArg ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default everyByRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'fill' );\n* // e.g., returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Fills all elements within a portion of an indexed array with a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - fill value\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = indexed( x, 5, 1, 3 );\n* // returns [ 1, 5, 5, 4 ]\n*/\nfunction indexed( x, value, start, end ) {\n\tvar i;\n\tfor ( i = start; i < end; i++ ) {\n\t\tx[ i ] = value;\n\t}\n\treturn x;\n}\n\n/**\n* Fills all elements within a portion of an accessor array with a specified value.\n*\n* @private\n* @param {Object} x - input array object\n* @param {*} value - fill value\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {AccessorArray} modified input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var obj = arraylike2object( x );\n*\n* var out = accessors( obj, 5, 1, 3 );\n* // returns \n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* v = x.get( 1 );\n* // returns 5\n*\n* v = x.get( 2 );\n* // returns 5\n*\n* v = x.get( 3 );\n* // returns 4\n*/\nfunction accessors( x, value, start, end ) {\n\tvar data;\n\tvar set;\n\tvar i;\n\n\tdata = x.data;\n\tset = x.accessors[ 1 ];\n\tfor ( i = start; i < end; i++ ) {\n\t\tset( data, i, value );\n\t}\n\treturn data;\n}\n\n\n// MAIN //\n\n/**\n* Fills all elements within a portion of an array with a specified value.\n*\n* @param {Collection} x - input array\n* @param {*} value - fill value\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = fill( x, 5, 1, 3 );\n* // returns [ 1, 5, 5, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var out = fill( x, 5, 1, 3 );\n* // returns [ 1, 5, 5, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction fill( x, value, start, end ) {\n\tvar obj;\n\tif ( hasMethod( x, 'fill' ) ) {\n\t\treturn x.fill( value, start, end );\n\t}\n\tif ( start < 0 ) {\n\t\tstart += x.length;\n\t\tif ( start < 0 ) {\n\t\t\tstart = 0;\n\t\t}\n\t}\n\tif ( end < 0 ) {\n\t\tend += x.length; // if `end` is still negative, that is fine, as `x` will be returned un-mutated\n\t} else if ( end > x.length ) {\n\t\tend = x.length;\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, value, start, end );\n\t}\n\treturn indexed( x, value, start, end );\n}\n\n\n// EXPORTS //\n\nexport default fill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Fills all elements within a portion of an indexed array according to a callback function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @param {Function} fcn - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {Array} output array\n*\n* @example\n* function fcn() {\n* return 5;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = indexed( x, 1, 3, fcn, {} );\n* // returns [ 1, 5, 5, 4 ]\n*/\nfunction indexed( x, start, end, fcn, thisArg ) {\n\tvar i;\n\tfor ( i = start; i < end; i++ ) {\n\t\tx[ i ] = fcn.call( thisArg, x[ i ], i, x );\n\t}\n\treturn x;\n}\n\n/**\n* Fills all elements within a portion of an accessor array according to a callback function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @param {Function} fcn - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {AccessorArray} modified input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function fcn() {\n* return 5;\n* }\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var obj = arraylike2object( x );\n*\n* var out = accessors( obj, 1, 3, fcn, {} );\n* // returns \n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* v = x.get( 1 );\n* // returns 5\n*\n* v = x.get( 2 );\n* // returns 5\n*\n* v = x.get( 3 );\n* // returns 4\n*/\nfunction accessors( x, start, end, fcn, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar set;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\tset = x.accessors[ 1 ];\n\tfor ( i = start; i < end; i++ ) {\n\t\tset( data, i, fcn.call( thisArg, get( data, i ), i, data ) );\n\t}\n\treturn data;\n}\n\n\n// MAIN //\n\n/**\n* Fills all elements within a portion of an array according to a callback function.\n*\n* @param {Collection} x - input array\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Collection} output array\n*\n* @example\n* function fcn() {\n* return 5;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = fillBy( x, 1, 3, fcn );\n* // returns [ 1, 5, 5, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* function fcn() {\n* return 5;\n* }\n*\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var out = fillBy( x, 1, 3, fcn );\n* // returns [ 1, 5, 5, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction fillBy( x, start, end, fcn, thisArg ) {\n\tvar obj;\n\tif ( start < 0 ) {\n\t\tstart += x.length;\n\t\tif ( start < 0 ) {\n\t\t\tstart = 0;\n\t\t}\n\t}\n\tif ( end < 0 ) {\n\t\tend += x.length; // if `end` is still negative, that is fine, as `x` will be returned un-mutated\n\t} else if ( end > x.length ) {\n\t\tend = x.length;\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, start, end, fcn, thisArg );\n\t}\n\treturn indexed( x, start, end, fcn, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default fillBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filled2dBy( [ 1, 3 ], constantFunction( 'beep' ) );\n* // returns [ [ 'beep', 'beep', 'beep' ] ]\n*/\nfunction filled2dBy( shape, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar S0;\n\tvar S1;\n\tvar i;\n\tvar j;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < S1; i++ ) {\n\t\ta0 = [];\n\t\tfor ( j = 0; j < S0; j++ ) {\n\t\t\ta0.push( clbk.call( thisArg, [ i, j ] ) );\n\t\t}\n\t\tarr.push( a0 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled three-dimensional nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filled3dBy( [ 1, 1, 3 ], constantFunction( 'beep' ) );\n* // returns [ [ [ 'beep', 'beep', 'beep' ] ] ]\n*/\nfunction filled3dBy( shape, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar a1;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = [];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta0 = [];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\ta0.push( clbk.call( thisArg, [ i2, i1, i0 ] ) );\n\t\t\t}\n\t\t\ta1.push( a0 );\n\t\t}\n\t\tarr.push( a1 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled3dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled four-dimensional nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filled4dBy( [ 1, 1, 1, 3 ], constantFunction( 'beep' ) );\n* // returns [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ]\n*/\nfunction filled4dBy( shape, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ta0.push( clbk.call( thisArg, [ i3, i2, i1, i0 ] ) );\n\t\t\t\t}\n\t\t\t\ta1.push( a0 );\n\t\t\t}\n\t\t\ta2.push( a1 );\n\t\t}\n\t\tarr.push( a2 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled4dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled five-dimensional nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filled5dBy( [ 1, 1, 1, 1, 3 ], constantFunction( 'beep' ) );\n* // returns [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ]\n*/\nfunction filled5dBy( shape, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = [];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = [];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = [];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta0 = [];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\ta0.push( clbk.call( thisArg, [ i4, i3, i2, i1, i0 ] ) );\n\t\t\t\t\t}\n\t\t\t\t\ta1.push( a0 );\n\t\t\t\t}\n\t\t\t\ta2.push( a1 );\n\t\t\t}\n\t\t\ta3.push( a2 );\n\t\t}\n\t\tarr.push( a3 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled5dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'filter' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {Array} output array\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, -2, -3, 4 ];\n*\n* var out = internal( x, isPositive );\n* // returns [ 1, 4 ]\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( predicate.call( thisArg, v, i, x ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {Array} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 1, -2, -3, 4 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns [ 1, 4 ]\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tout = [];\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tv = get( data, i );\n\t\tif ( predicate.call( thisArg, v, i, data ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {Collection} output array\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, -2, -3, 4 ];\n*\n* var out = filter( x, isPositive );\n* // returns [ 1, 4 ]\n*/\nfunction filter( x, predicate, thisArg ) {\n\tvar obj;\n\tif ( hasMethod( x, 'filter' ) ) {\n\t\treturn x.filter( predicate, thisArg );\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default filter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns the first element of an array-like object.\n*\n* @param {Collection} arr - input array\n* @returns {*} - first element\n*\n* @example\n* var out = first( [ 1, 2, 3 ] );\n* // returns 1\n*/\nfunction first( arr ) {\n\tvar get;\n\n\tif ( arr.length === 0 ) {\n\t\treturn;\n\t}\n\t// Resolve an accessor for retrieving input array elements:\n\tget = resolveGetter( arr );\n\n\t// Return the first element:\n\treturn get( arr, 0 );\n}\n\n\n// EXPORTS //\n\nexport default first;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fliplr4d from './../../../base/fliplr4d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the last dimension of a five-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>>>} x - nested input array\n* @returns {Array>>>} output array\n*\n* @example\n* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ];\n*\n* var out = fliplr5d( x );\n* // returns [ [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ] ]\n*/\nfunction fliplr5d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( fliplr4d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fliplr5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport flipud4d from './../../../base/flipud4d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the second-to-last dimension of a five-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>>>} x - nested input array\n* @returns {Array>>>} output array\n*\n* @example\n* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ];\n*\n* var out = flipud5d( x );\n* // returns [ [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ] ]\n*/\nfunction flipud5d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( flipud4d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flipud5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Converts a strided array to a non-strided generic array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified number of elements, index stride, and index offset.\n*\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} stride - index stride\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array( 3, x, 2, 0 );\n* // returns [ 1, 3, 5 ]\n*/\nfunction strided2array( N, x, stride, offset ) {\n\tvar out;\n\tvar get;\n\tvar ix;\n\tvar i;\n\n\t// Resolve an accessor function for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Copy strided elements to a dense non-strided array...\n\tix = offset;\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout.push( get( x, ix ) );\n\t\tix += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default strided2array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups element entries as arrays associated with distinct keys.\n*\n* @param {Collection} x - input array\n* @param {Collection} groups - array defining which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {Object} group results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var groups = [ 'b', 'b', 'f', 'b' ];\n*\n* var out = groupEntries( x, groups );\n* // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] }\n*/\nfunction groupEntries( x, groups ) {\n\tvar xget;\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( groups.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tgget = resolveGetter( groups );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = xget( x, i );\n\t\tg = gget( groups, i ).toString();\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( [ i, v ] );\n\t\t} else {\n\t\t\tout[ g ] = [ [ i, v ] ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupEntries;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups element entries according to an indicator function.\n*\n* @param {Collection} x - input array\n* @param {Function} indicator - indicator function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - indicator function execution context\n* @returns {Object} group results\n*\n* @example\n* function indicator( v ) {\n* return v[ 0 ];\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = groupEntriesBy( x, indicator );\n* // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] }\n*/\nfunction groupEntriesBy( x, indicator, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = get( x, i );\n\t\tg = indicator.call( thisArg, v, i, x );\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( [ i, v ] );\n\t\t} else {\n\t\t\tout[ g ] = [ [ i, v ] ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupEntriesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups element indices as arrays associated with distinct keys.\n*\n* @param {Collection} x - input array\n* @param {Collection} groups - array defining which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {Object} group results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var groups = [ 'b', 'b', 'f', 'b' ];\n*\n* var out = groupIndices( x, groups );\n* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] }\n*/\nfunction groupIndices( x, groups ) {\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( groups.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\t// Resolve accessors for retrieving array elements:\n\tgget = resolveGetter( groups );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tg = gget( groups, i ).toString();\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( i );\n\t\t} else {\n\t\t\tout[ g ] = [ i ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupIndices;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups element indices according to an indicator function.\n*\n* @param {Collection} x - input array\n* @param {Function} indicator - indicator function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - indicator function execution context\n* @returns {Object} group results\n*\n* @example\n* function indicator( v ) {\n* return v[ 0 ];\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = groupIndicesBy( x, indicator );\n* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] }\n*/\nfunction groupIndicesBy( x, indicator, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tg = indicator.call( thisArg, get( x, i ), i, x );\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( i );\n\t\t} else {\n\t\t\tout[ g ] = [ i ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupIndicesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups elements as arrays associated with distinct keys.\n*\n* @param {Collection} x - input array\n* @param {Collection} groups - array defining which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {Object} group results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var groups = [ 'b', 'b', 'f', 'b' ];\n*\n* var out = groupValues( x, groups );\n* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] }\n*/\nfunction groupValues( x, groups ) {\n\tvar xget;\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( groups.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tgget = resolveGetter( groups );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = xget( x, i );\n\t\tg = gget( groups, i ).toString();\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( v );\n\t\t} else {\n\t\t\tout[ g ] = [ v ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupValues;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups element values according to an indicator function.\n*\n* @param {Collection} x - input array\n* @param {Function} indicator - indicator function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - indicator function execution context\n* @returns {Object} group results\n*\n* @example\n* function indicator( v ) {\n* return v[ 0 ];\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = groupValuesBy( x, indicator );\n* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] }\n*/\nfunction groupValuesBy( x, indicator, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = get( x, i );\n\t\tg = indicator.call( thisArg, v, i, x );\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( v );\n\t\t} else {\n\t\t\tout[ g ] = [ v ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupValuesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups the elements of an array according to a specified property name.\n*\n* @param {Collection} x - input array\n* @param {(string|symbol|number)} key - property name whose values are used to determine groups\n* @returns {Object} group results\n*\n* @example\n* var x = [\n* {\n* 'x': 1,\n* 'y': 2\n* },\n* {\n* 'x': 1,\n* 'y': 3\n* }\n* ];\n*\n* var out = groupValuesOnKey( x, 'y' );\n* // returns { '2': [ { 'x': 1, 'y': 2 } ], '3': [ { 'x': 1, 'y': 3 } ] }\n*/\nfunction groupValuesOnKey( x, key ) {\n\tvar get;\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\tvar k;\n\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tv = get( x, i );\n\t\tk = v[ key ];\n\t\to = out[ k ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( v );\n\t\t} else {\n\t\t\tout[ k ] = [ v ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupValuesOnKey;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from '@stdlib/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'indexOf' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns the index of the first element which equals a provided search element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = internal( x, 2, 0 );\n* // returns 1\n*/\nfunction internal( x, searchElement, fromIndex ) {\n\tvar i;\n\tfor ( i = fromIndex; i < x.length; i++ ) {\n\t\tif ( searchElement === x[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the first element which equals a provided search element.\n*\n* @private\n* @param {Object} x - input array object\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var idx = accessors( x, 2, 0 );\n* // returns 1\n*/\nfunction accessors( x, searchElement, fromIndex ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( x );\n\tfor ( i = fromIndex; i < x.length; i++ ) {\n\t\tif ( searchElement === get( x, i ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n\n// MAIN //\n\n/**\n* Returns the index of the first element which equals a provided search element.\n*\n* ## Notes\n*\n* - If unable to find an element which equals a provided search element, the function returns `-1`.\n*\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {integer} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = indexOf( x, 2, 0 );\n* // returns 1\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var idx = indexOf( x, 2, 0 );\n* // returns 1\n*/\nfunction indexOf( x, searchElement, fromIndex ) {\n\tif ( hasMethod( x, 'indexOf' ) ) {\n\t\treturn x.indexOf( searchElement, fromIndex );\n\t}\n\tif ( fromIndex < 0 ) {\n\t\tfromIndex += x.length;\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex = 0;\n\t\t}\n\t}\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, searchElement, fromIndex );\n\t}\n\treturn internal( x, searchElement, fromIndex );\n}\n\n\n// EXPORTS //\n\nexport default indexOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from '@stdlib/assert/is-accessor-array';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport resolveGetter from './../../../base/resolve-getter';\nimport isSameValue from '@stdlib/assert/is-same-value';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// FUNCTIONS //\n\n/**\n* Returns the index of the first element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = indexed( x, 2, 0 );\n* // returns 1\n*/\nfunction indexed( x, searchElement, fromIndex ) {\n\tvar i;\n\tfor ( i = fromIndex; i < x.length; i++ ) {\n\t\tif ( isSameValue( searchElement, x[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the first element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array object\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var idx = accessors( x, 2, 0 );\n* // returns 1\n*/\nfunction accessors( x, searchElement, fromIndex ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( x );\n\tfor ( i = fromIndex; i < x.length; i++ ) {\n\t\tif ( isSameValue( searchElement, get( x, i ) ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the first element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var idx = complex( x, new Complex128( 3.0, 4.0 ), 1 );\n* // returns 2\n*/\nfunction complex( x, searchElement, fromIndex ) {\n\tvar view;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexLike( searchElement ) ) {\n\t\treturn -1;\n\t}\n\tview = reinterpret( x, 0 );\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tfor ( i = fromIndex*2; i < view.length; i += 2 ) {\n\t\tif ( isSameValue( view[ i ], re ) && isSameValue( view[ i+1 ], im ) ) {\n\t\t\treturn i / 2;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the first element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var x = new BooleanArray( [ true, false, true, false, true ] );\n*\n* var idx = boolean( x, true, 1 );\n* // returns 2\n*/\nfunction boolean( x, searchElement, fromIndex ) {\n\tvar view;\n\tvar v;\n\tvar i;\n\tif ( !isBoolean( searchElement ) ) {\n\t\treturn -1;\n\t}\n\tview = reinterpretBoolean( x, 0 );\n\tv = ( searchElement ) ? 1 : 0;\n\tfor ( i = fromIndex; i < view.length; i++ ) {\n\t\tif ( view[ i ] === v ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n\n// MAIN //\n\n/**\n* Returns the index of the first element which equals a provided search element according to the same value algorithm.\n*\n* ## Notes\n*\n* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n* - If unable to find an element which equals a provided search element, the function returns `-1`.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {integer} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = indexOfSameValue( x, 2, 0 );\n* // returns 1\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var idx = indexOfSameValue( x, 2, 0 );\n* // returns 1\n*/\nfunction indexOfSameValue( x, searchElement, fromIndex ) {\n\tif ( fromIndex < 0 ) {\n\t\tfromIndex += x.length;\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex = 0;\n\t\t}\n\t}\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, searchElement, fromIndex );\n\t\t}\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn boolean( x, searchElement, fromIndex );\n\t\t}\n\t\treturn accessors( x, searchElement, fromIndex );\n\t}\n\treturn indexed( x, searchElement, fromIndex );\n}\n\n\n// EXPORTS //\n\nexport default indexOfSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the complement of a list of array indices.\n*\n* @param {NonNegativeInteger} N - array length\n* @param {NonNegativeIntegerArray} indices - list of indices\n* @returns {NonNegativeIntegerArray} indices complement\n*\n* @example\n* var idx = indicesComplement( 5, [ 1, 2 ] );\n* // returns [ 0, 3, 4 ]\n*/\nfunction indicesComplement( N, indices ) {\n\tvar hash;\n\tvar out;\n\tvar i;\n\n\thash = {};\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\thash[ indices[ i ] ] = true;\n\t}\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( hash[ i ] === void 0 ) {\n\t\t\tout.push( i );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default indicesComplement;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\nimport isUndefinedOrNull from '@stdlib/assert/is-undefined-or-null';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'join' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns a string created by joining elements in an accessor array using a specified separator.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} separator - separator\n* @returns {string} output string\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) );\n*\n* var out = accessors( x, ',' );\n* // returns '1,2,3,4'\n*/\nfunction accessors( x, separator ) {\n\tvar data;\n\tvar out;\n\tvar get;\n\tvar N;\n\tvar v;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tN = data.length - 1;\n\tout = '';\n\tfor ( i = 0; i <= N; i++ ) {\n\t\tv = get( data, i );\n\t\tif ( !isUndefinedOrNull( v ) ) {\n\t\t\tout += String( v );\n\t\t}\n\t\tif ( i < N ) {\n\t\t\tout += separator;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Returns a string created by manually joining array elements using a specified separator.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} separator - separator\n* @returns {string} output string\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = indexed( x, ',' );\n* // returns '1,2,3,4'\n*/\nfunction indexed( x, separator ) {\n\tvar out;\n\tvar N;\n\tvar v;\n\tvar i;\n\n\tN = x.length - 1;\n\tout = '';\n\tfor ( i = 0; i <= N; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( !isUndefinedOrNull( v ) ) {\n\t\t\tout += String( v );\n\t\t}\n\t\tif ( i < N ) {\n\t\t\tout += separator;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a string created by joining array elements using a specified separator.\n*\n* @param {Collection} x - input array\n* @param {integer} separator - separator\n* @returns {string} output string\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = join( x, ',' );\n* // returns '1,2,3,4'\n*\n* @example\n* var x = [ 1, 2, 3, null, undefined, 4 ];\n*\n* var out = join( x, '-' );\n* // returns '1-2-3---4'\n*/\nfunction join( x, separator ) {\n\tvar obj;\n\tif ( hasMethod( x, 'join' ) ) {\n\t\treturn x.join( separator );\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, separator );\n\t}\n\treturn indexed( x, separator );\n}\n\n\n// EXPORTS //\n\nexport default join;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns the last element of an array-like object.\n*\n* @param {Collection} arr - input array\n* @returns {*} - last element\n*\n* @example\n* var out = last( [ 1, 2, 3 ] );\n* // returns 3\n*/\nfunction last( arr ) {\n\tvar get;\n\tvar idx;\n\n\t// Resolve an accessor for retrieving input array elements:\n\tget = resolveGetter( arr );\n\n\t// Resolve the last index:\n\tidx = arr.length - 1;\n\n\t// Return the last element:\n\tif ( idx < 0 ) {\n\t\treturn;\n\t}\n\treturn get( arr, idx );\n}\n\n\n// EXPORTS //\n\nexport default last;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from '@stdlib/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'lastIndexOf' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns the index of the last element which equals a provided search element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = internal( x, 2, 3 );\n* // returns 1\n*/\nfunction internal( x, searchElement, fromIndex ) {\n\tvar i;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( searchElement === x[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the last element which equals a provided search element.\n*\n* @private\n* @param {Object} x - input array object\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var idx = accessors( x, 2, 3 );\n* // returns 1\n*/\nfunction accessors( x, searchElement, fromIndex ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( x );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( searchElement === get( x, i ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n\n// MAIN //\n\n/**\n* Returns the index of the last element which equals a provided search element.\n*\n* ## Notes\n*\n* - If unable to find an element which equals a provided search element, the function returns `-1`.\n*\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {integer} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = lastIndexOf( x, 2, 3 );\n* // returns 1\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var idx = lastIndexOf( x, 2, 3 );\n* // returns 1\n*/\nfunction lastIndexOf( x, searchElement, fromIndex ) {\n\tif ( hasMethod( x, 'lastIndexOf' ) ) {\n\t\treturn x.lastIndexOf( searchElement, fromIndex );\n\t}\n\tif ( fromIndex < 0 ) {\n\t\tfromIndex += x.length;\n\t\tif ( fromIndex < 0 ) {\n\t\t\treturn -1;\n\t\t}\n\t} else if ( fromIndex > x.length ) {\n\t\tfromIndex = x.length - 1;\n\t}\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, searchElement, fromIndex );\n\t}\n\treturn internal( x, searchElement, fromIndex );\n}\n\n\n// EXPORTS //\n\nexport default lastIndexOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from '@stdlib/assert/is-accessor-array';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport resolveGetter from './../../../base/resolve-getter';\nimport isSameValue from '@stdlib/assert/is-same-value';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// FUNCTIONS //\n\n/**\n* Returns the index of the last element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = indexed( x, 2, 3 );\n* // returns 1\n*/\nfunction indexed( x, searchElement, fromIndex ) {\n\tvar i;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( isSameValue( searchElement, x[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the last element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Object} x - input array object\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var idx = accessors( x, 2, 3 );\n* // returns 1\n*/\nfunction accessors( x, searchElement, fromIndex ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( x );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( isSameValue( searchElement, get( x, i ) ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the last element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var idx = complex( x, new Complex128( 3.0, 4.0 ), 3 );\n* // returns 2\n*/\nfunction complex( x, searchElement, fromIndex ) {\n\tvar view;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexLike( searchElement ) ) {\n\t\treturn -1;\n\t}\n\tview = reinterpret( x, 0 );\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tfor ( i = fromIndex*2; i >= 0; i -= 2 ) {\n\t\tif ( isSameValue( view[ i ], re ) && isSameValue( view[ i+1 ], im ) ) {\n\t\t\treturn i / 2;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the last element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var x = new BooleanArray( [ true, false, true, false, true ] );\n*\n* var idx = boolean( x, true, 3 );\n* // returns 2\n*/\nfunction boolean( x, searchElement, fromIndex ) {\n\tvar view;\n\tvar v;\n\tvar i;\n\tif ( !isBoolean( searchElement ) ) {\n\t\treturn -1;\n\t}\n\tview = reinterpretBoolean( x, 0 );\n\tv = ( searchElement ) ? 1 : 0;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( view[ i ] === v ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n\n// MAIN //\n\n/**\n* Returns the index of the last element which equals a provided search element according to the same value algorithm.\n*\n* ## Notes\n*\n* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n* - If unable to find an element which equals a provided search element, the function returns `-1`.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {integer} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = lastIndexOfSameValue( x, 2, 3 );\n* // returns 1\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var idx = lastIndexOfSameValue( x, 2, 3 );\n* // returns 1\n*/\nfunction lastIndexOfSameValue( x, searchElement, fromIndex ) {\n\tif ( fromIndex < 0 ) {\n\t\tfromIndex += x.length;\n\t\tif ( fromIndex < 0 ) {\n\t\t\treturn -1;\n\t\t}\n\t} else if ( fromIndex > x.length ) {\n\t\tfromIndex = x.length - 1;\n\t}\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, searchElement, fromIndex );\n\t\t}\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn boolean( x, searchElement, fromIndex );\n\t\t}\n\t\treturn accessors( x, searchElement, fromIndex );\n\t}\n\treturn indexed( x, searchElement, fromIndex );\n}\n\n\n// EXPORTS //\n\nexport default lastIndexOfSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array.\n*\n* @param {number} x1 - first array value\n* @param {number} x2 - last array value\n* @param {NonNegativeInteger} len - length of output array\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = linspace( 0, 100, 6 );\n* // returns [ 0, 20, 40, 60, 80, 100 ]\n*/\nfunction linspace( x1, x2, len ) {\n\tvar arr;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Calculate the increment:\n\tN = len - 1;\n\td = ( x2-x1 ) / N;\n\n\t// Build the output array...\n\tarr = [ x1 ];\n\tfor ( i = 1; i < N; i++ ) {\n\t\tarr.push( x1 + (d*i) );\n\t}\n\tarr.push( x2 );\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced two-dimensional nested numeric array.\n*\n* @param {number} start - first array value\n* @param {number} stop - last array value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether generated array values should be stored in colexicographic order\n* @returns {Array} linearly spaced two-dimensional nested numeric array\n*\n* @example\n* var x = linspace2d( 0, 100, [ 2, 3 ], false );\n* // returns [ [ 0, 20, 40 ], [ 60, 80, 100 ] ]\n*\n* x = linspace2d( 0, 100, [ 2, 3 ], true );\n* // returns [ [ 0, 40, 80 ], [ 20, 60, 100 ] ]\n*/\nfunction linspace2d( start, stop, shape, colexicographic ) {\n\tvar inc0;\n\tvar inc1;\n\tvar out;\n\tvar tmp;\n\tvar idx;\n\tvar s0;\n\tvar i0;\n\tvar s1;\n\tvar i1;\n\tvar d;\n\tvar n;\n\n\ts0 = shape[ 1 ];\n\ts1 = shape[ 0 ];\n\n\tn = s0 * s1;\n\tif ( n === 0 ) {\n\t\treturn [];\n\t}\n\td = ( stop - start ) / ( n - 1 );\n\tif ( colexicographic ) {\n\t\tinc0 = s1; // index increment for the innermost loop\n\t\tinc1 = 1 - ( s0 * inc0 ); // index increment for the outermost loop\n\t} else {\n\t\tinc0 = 1; // index increment for the innermost loop\n\t\tinc1 = 0; // index increment for the outermost loop\n\t}\n\tout = [];\n\tidx = 0;\n\tfor ( i1 = 0; i1 < s1; i1++ ) {\n\t\ttmp = [];\n\t\tfor ( i0 = 0; i0 < s0; i0++ ) {\n\t\t\ttmp.push( start + ( idx * d ) );\n\t\t\tidx += inc0;\n\t\t}\n\t\tout.push( tmp );\n\t\tidx += inc1;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport UINT8_MAX from '@stdlib/constants/uint8/max';\nimport UINT16_MAX from '@stdlib/constants/uint16/max';\nimport UINT32_MAX from '@stdlib/constants/uint32/max';\n\n\n// MAIN //\n\n/**\n* Returns the minimum array data type for storing a provided unsigned integer value.\n*\n* @param {uinteger} value - scalar value\n* @returns {string} array data type\n*\n* @example\n* var dt = minUnsignedIntegerDataType( 9999 );\n* // returns 'uint16'\n*\n* @example\n* var dt = minUnsignedIntegerDataType( 3 );\n* // returns 'uint8'\n*/\nfunction minUnsignedIntegerDataType( value ) { // eslint-disable-line id-length\n\tif ( value <= UINT8_MAX ) {\n\t\treturn 'uint8';\n\t}\n\tif ( value <= UINT16_MAX ) {\n\t\treturn 'uint16';\n\t}\n\tif ( value <= UINT32_MAX ) {\n\t\treturn 'uint32';\n\t}\n\treturn 'float64';\n}\n\n\n// EXPORTS //\n\nexport default minUnsignedIntegerDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two two-dimensional nested input arrays according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = ones2d( shape );\n* var z = zeros2d( shape );\n*\n* var mask = [ [ 0, 1 ], [ 0, 0 ] ];\n*\n* mskbinary2d( [ x, y, mask, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ]\n*/\nfunction mskbinary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar m0;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar m;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 3 ];\n\tm = arrays[ 2 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tz0 = z[ i1 ];\n\t\tm0 = m[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskbinary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 2, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = ones3d( shape );\n* var z = zeros3d( shape );\n*\n* var mask = [\n* [ [ 0, 1 ], [ 0, 0 ] ],\n* [ [ 1, 0 ], [ 0, 1 ] ]\n* ];\n*\n* mskbinary3d( [ x, y, mask, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ], [ [ 0.0, 2.0 ], [ 2.0, 0.0 ] ] ]\n*/\nfunction mskbinary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar m0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar m1;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar m;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 3 ];\n\tm = arrays[ 2 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tz1 = z[ i2 ];\n\t\tm1 = m[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tm0 = m1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskbinary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = ones4d( shape );\n* var z = zeros4d( shape );\n*\n* var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ];\n*\n* mskbinary4d( [ x, y, mask, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ]\n*/\nfunction mskbinary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar m;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tm = arrays[ 2 ];\n\tz = arrays[ 3 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tz2 = z[ i3 ];\n\t\tm2 = m[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tm1 = m2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tm0 = m1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskbinary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = ones5d( shape );\n* var z = zeros5d( shape );\n*\n* var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ];\n*\n* mskbinary5d( [ x, y, mask, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ] ]\n*/\nfunction mskbinary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar z3;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar m;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tm = arrays[ 2 ];\n\tz = arrays[ 3 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tz3 = z[ i4 ];\n\t\tm3 = m[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tm2 = m3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tm1 = m2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tm0 = m1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskbinary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns new arrays by applying a mask to two provided input arrays in a single pass.\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {Collection} mask - mask array\n* @returns {Array} output arrays\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = mskfilter2( x, y, mask );\n* // returns [ [ 2, 4 ], [ 6, 8 ] ]\n*/\nfunction mskfilter2( x, y, mask ) {\n\tvar xget;\n\tvar yget;\n\tvar mget;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tyget = resolveGetter( y );\n\tmget = resolveGetter( mask );\n\n\t// Extract each desired element from the provided arrays...\n\to1 = [];\n\to2 = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mget( mask, i ) ) {\n\t\t\to1.push( xget( x, i ) ); // use `Array#push` to ensure \"fast\" elements\n\t\t\to2.push( yget( y, i ) );\n\t\t}\n\t}\n\treturn [ o1, o2 ];\n}\n\n\n// EXPORTS //\n\nexport default mskfilter2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns new arrays by applying a mask to one or more provided input arrays in a single pass.\n*\n* @param {Collection} x - first input array\n* @param {Collection} [...arrays] - additional input arrays\n* @param {Collection} mask - mask array\n* @returns {Array} output arrays\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = mskfiltern( x, y, mask );\n* // returns [ [ 2, 4 ], [ 6, 8 ] ]\n*/\nfunction mskfiltern() {\n\tvar getters;\n\tvar arrays;\n\tvar nargs;\n\tvar mget;\n\tvar mask;\n\tvar out;\n\tvar i;\n\tvar j;\n\n\tnargs = arguments.length;\n\tnargs -= 1;\n\n\t// Resolve the mask array and its associated accessor:\n\tmask = arguments[ nargs ];\n\tmget = resolveGetter( mask );\n\n\t// Resolve accessors for retrieving array elements and initialize the output arrays...\n\tgetters = [];\n\tarrays = [];\n\tout = [];\n\tfor ( i = 0; i < nargs; i++ ) {\n\t\tarrays.push( arguments[ i ] );\n\t\tgetters.push( resolveGetter( arrays[ i ] ) );\n\t\tout.push( [] );\n\t}\n\t// Extract each desired element from the provided arrays...\n\tfor ( i = 0; i < mask.length; i++ ) {\n\t\tif ( mget( mask, i ) ) {\n\t\t\tfor ( j = 0; j < nargs; j++ ) {\n\t\t\t\tout[ j ].push( getters[ j ]( arrays[ j ], i ) ); // use `Array#push` to ensure \"fast\" elements\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default mskfiltern;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a two-dimensional nested input array according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = zeros2d( shape );\n*\n* var mask = [ [ 0, 1 ], [ 0, 0 ] ];\n*\n* mskunary2d( [ x, mask, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ]\n*/\nfunction mskunary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar m0;\n\tvar x;\n\tvar y;\n\tvar m;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 2 ];\n\tm = arrays[ 1 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tm0 = m[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskunary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a three-dimensional nested input array according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = zeros3d( shape );\n*\n* var mask = [ [ [ 0, 1 ], [ 0, 0 ] ] ];\n*\n* mskunary3d( [ x, mask, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ]\n*/\nfunction mskunary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar m0;\n\tvar m1;\n\tvar x;\n\tvar y;\n\tvar m;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 2 ];\n\tm = arrays[ 1 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tm1 = m[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tm0 = m1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskunary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a four-dimensional nested input array according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ];\n*\n* mskunary4d( [ x, mask, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction mskunary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar x;\n\tvar y;\n\tvar m;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 2 ];\n\tm = arrays[ 1 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tm2 = m[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tm1 = m2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tm0 = m1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskunary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a five-dimensional nested input array according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = zeros5d( shape );\n*\n* var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ];\n*\n* mskunary5d( [ x, mask, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*/\nfunction mskunary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar x;\n\tvar y;\n\tvar m;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 2 ];\n\tm = arrays[ 1 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tm3 = m[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tm2 = m3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tm1 = m2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tm0 = m1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskunary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the n-fold Cartesian product.\n*\n* ## Notes\n*\n* - The main insight of this implementation is that the n-fold Cartesian product can be presented as an n-dimensional array stored in row-major order. As such, we can\n*\n* - Compute the total number of tuples, which is simply the product of the size of each provided array (set). For n-dimensional arrays, this is the equivalent of computing the product of array dimensions to determine the total number of elements.\n* - Initialize an array for storing indices for indexing into each provided array. For n-dimensional arrays, the index array is equivalent to an array of subscripts for indexing into each dimension.\n* - For the outermost loop, treat the loop index as a linear index into an n-dimensional array and resolve the corresponding subscripts.\n* - Continue iterating until all tuples have been generated.\n*\n* @param {ArrayLikeObject} x1 - first input array\n* @param {ArrayLikeObject} x2 - second input array\n* @param {ArrayLikeObject} [...args] - additional input arrays\n* @returns {Array} list of ordered tuples comprising the n-fold Cartesian product\n*\n* @example\n* var x1 = [ 1, 2, 3 ];\n* var x2 = [ 4, 5 ];\n*\n* var out = nCartesianProduct( x1, x2 );\n* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ]\n*/\nfunction nCartesianProduct( x1, x2 ) {\n\tvar nargs;\n\tvar dims;\n\tvar arr;\n\tvar out;\n\tvar tmp;\n\tvar arg;\n\tvar idx;\n\tvar N;\n\tvar s;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tnargs = arguments.length;\n\n\t// Initialize the list of arrays:\n\tarr = [ x1, x2 ];\n\n\t// Initialize the list of array dimensions (equivalent to ndarray shape):\n\tdims = [ x1.length, x2.length ];\n\n\t// Initialize a list of indices for indexing into each array (equivalent to ndarray subscripts):\n\tidx = [ 0, 0 ];\n\n\t// Compute the total number of ordered tuples:\n\tN = dims[ 0 ] * dims[ 1 ];\n\n\t// Update loop variables for any additional arrays...\n\tfor ( i = 2; i < nargs; i++ ) {\n\t\targ = arguments[ i ];\n\t\tarr.push( arg );\n\t\tdims.push( arg.length );\n\t\tidx.push( 0 );\n\t\tN *= dims[ i ];\n\t}\n\t// Compute the n-fold Cartesian product...\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\t// Resolve a linear index to array indices (logic is equivalent to what is found in ndarray/base/ind2sub for an ndarray stored in row-major order; see https://github.com/stdlib-js/stdlib/blob/215ca5355f3404f15996fd0ced58a98e46f22be6/lib/node_modules/%40stdlib/ndarray/base/ind2sub/lib/assign.js)...\n\t\tk = i;\n\t\tfor ( j = nargs-1; j >= 0; j-- ) {\n\t\t\ts = k % dims[ j ];\n\t\t\tk -= s;\n\t\t\tk /= dims[ j ];\n\t\t\tidx[ j ] = s;\n\t\t}\n\t\t// Generate the next ordered tuple...\n\t\ttmp = [];\n\t\tfor ( j = 0; j < nargs; j++ ) {\n\t\t\ttmp.push( arr[ j ][ idx[ j ] ] );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default nCartesianProduct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport copy from './../../../base/copy';\n\n\n// MAIN //\n\n/**\n* Converts each nested array to an object.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length.\n* - The number of provided array labels should equal the length of each nested array.\n*\n* @param {Collection} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2objects( x, fields );\n* // returns [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ]\n*/\nfunction nested2objects( arr, fields ) {\n\tvar names;\n\tvar oget;\n\tvar get;\n\tvar out;\n\tvar obj;\n\tvar tmp;\n\tvar M;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\t// Resolve the accessor for the outer array:\n\toget = resolveGetter( arr );\n\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Copy the list of fields to an indexed array to avoid repeated accessor calls:\n\tnames = copy( fields );\n\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\ttmp = oget( arr, i );\n\t\tget = resolveGetter( tmp );\n\t\tobj = {};\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tobj[ names[ j ] ] = get( tmp, j );\n\t\t}\n\t\tout.push( obj );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default nested2objects;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setNonEnumerable from '@stdlib/utils/define-nonenumerable-property';\nimport setReadWriteAccessor from '@stdlib/utils/define-read-write-accessor';\nimport resolveGetter from './../../../base/resolve-getter';\nimport accessors from './../../../base/accessors';\nimport copy from './../../../base/copy';\n\n\n// MAIN //\n\n/**\n* Converts each nested array to a composite view.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length.\n* - The number of provided array labels should equal the length of each nested array.\n* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other.\n*\n* @param {Collection} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = noneBy( x, isPositive );\n* // returns true\n*/\nfunction noneBy( x, predicate, thisArg ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default noneBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = x.length-1; i >= 0; i-- ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = data.length-1; i >= 0; i-- ) {\n\t\tif ( predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function, iterating from right to left.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = noneByRight( x, isPositive );\n* // returns true\n*/\nfunction noneByRight( x, predicate, thisArg ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default noneByRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a \"generic\" array filled with null values.\n*\n* @param {NonNegativeInteger} len - array length\n* @returns {Array} output array\n*\n* @example\n* var out = nulls( 3 );\n* // returns [ null, null, null ]\n*/\nfunction nulls( len ) {\n\treturn filled( null, len );\n}\n\n\n// EXPORTS //\n\nexport default nulls;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a \"generic\" array filled with ones.\n*\n* @param {NonNegativeInteger} len - array length\n* @returns {Array} output array\n*\n* @example\n* var out = ones( 3 );\n* // returns [ 1.0, 1.0, 1.0 ]\n*/\nfunction ones( len ) {\n\treturn filled( 1.0, len );\n}\n\n\n// EXPORTS //\n\nexport default ones;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled2d from './../../../base/filled2d';\n\n\n// MAIN //\n\n/**\n* Returns a two-dimensional nested array filled with ones.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {ArrayArray} filled array\n*\n* @example\n* var out = ones2d( [ 1, 3 ] );\n* // returns [ [ 1.0, 1.0, 1.0 ] ]\n*/\nfunction ones2d( shape ) {\n\treturn filled2d( 1.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default ones2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled3d from './../../../base/filled3d';\n\n\n// MAIN //\n\n/**\n* Returns a three-dimensional nested array filled with ones.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = ones3d( [ 1, 1, 3 ] );\n* // returns [ [ [ 1.0, 1.0, 1.0 ] ] ]\n*/\nfunction ones3d( shape ) {\n\treturn filled3d( 1.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default ones3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled4d from './../../../base/filled4d';\n\n\n// MAIN //\n\n/**\n* Returns a four-dimensional nested array filled with ones.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = ones4d( [ 1, 1, 1, 3 ] );\n* // returns [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ]\n*/\nfunction ones4d( shape ) {\n\treturn filled4d( 1.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default ones4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled5d from './../../../base/filled5d';\n\n\n// MAIN //\n\n/**\n* Returns a five-dimensional nested array filled with ones.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = ones5d( [ 1, 1, 1, 1, 3 ] );\n* // returns [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ]\n*/\nfunction ones5d( shape ) {\n\treturn filled5d( 1.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default ones5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fillednd from './../../../base/fillednd';\n\n\n// MAIN //\n\n/**\n* Returns an n-dimensional nested array filled with ones.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = onesnd( [ 3 ] );\n* // returns [ 1.0, 1.0, 1.0 ]\n*\n* @example\n* var out = onesnd( [ 1, 3 ] );\n* // returns [ [ 1.0, 1.0, 1.0 ] ]\n*/\nfunction onesnd( shape ) {\n\treturn fillednd( 1.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default onesnd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = ones2d( shape );\n* var z = ones2d( shape );\n* var w = ones2d( shape );\n* var out = zeros2d( shape );\n*\n* quaternary2d( [ x, y, z, w, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ]\n*/\nfunction quaternary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar v0;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar v;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tv = arrays[ 4 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tz0 = z[ i1 ];\n\t\tw0 = w[ i1 ];\n\t\tv0 = v[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quaternary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = ones3d( shape );\n* var z = ones3d( shape );\n* var w = ones3d( shape );\n* var out = zeros3d( shape );\n*\n* quaternary3d( [ x, y, z, w, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ]\n*/\nfunction quaternary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar v1;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar v;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tv = arrays[ 4 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tz1 = z[ i2 ];\n\t\tw1 = w[ i2 ];\n\t\tv1 = v[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tw0 = w1[ i1 ];\n\t\t\tv0 = v1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quaternary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = ones4d( shape );\n* var z = ones4d( shape );\n* var w = ones4d( shape );\n* var out = zeros4d( shape );\n*\n* quaternary4d( [ x, y, z, w, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ]\n*/\nfunction quaternary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar v1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar v2;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar v;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tv = arrays[ 4 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tz2 = z[ i3 ];\n\t\tw2 = w[ i3 ];\n\t\tv2 = v[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tw1 = w2[ i2 ];\n\t\t\tv1 = v2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\tv0 = v1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quaternary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = ones5d( shape );\n* var z = ones5d( shape );\n* var w = ones5d( shape );\n* var out = zeros5d( shape );\n*\n* quaternary5d( [ x, y, z, w, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ] ]\n*/\nfunction quaternary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar v1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar v2;\n\tvar x3;\n\tvar y3;\n\tvar z3;\n\tvar w3;\n\tvar v3;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar v;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tv = arrays[ 4 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tz3 = z[ i4 ];\n\t\tw3 = w[ i4 ];\n\t\tv3 = v[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tw2 = w3[ i3 ];\n\t\t\tv2 = v3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tw1 = w2[ i2 ];\n\t\t\t\tv1 = v2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\t\tv0 = v1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] ); // eslint-disable-line max-len\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quaternary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import add from '@stdlib/number/float64/base/add5';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = ones2d( shape );\n* var z = ones2d( shape );\n* var w = ones2d( shape );\n* var v = ones2d( shape );\n* var out = zeros2d( shape );\n*\n* quinary2d( [ x, y, z, w, v, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ]\n*/\nfunction quinary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar v0;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tu = arrays[ 4 ];\n\tv = arrays[ 5 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tz0 = z[ i1 ];\n\t\tw0 = w[ i1 ];\n\t\tu0 = u[ i1 ];\n\t\tv0 = v[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quinary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import add from '@stdlib/number/float64/base/add5';\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = ones3d( shape );\n* var z = ones3d( shape );\n* var w = ones3d( shape );\n* var v = ones3d( shape );\n* var out = zeros3d( shape );\n*\n* quinary3d( [ x, y, z, w, v, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ]\n*/\nfunction quinary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar u1;\n\tvar v1;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tu = arrays[ 4 ];\n\tv = arrays[ 5 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tz1 = z[ i2 ];\n\t\tw1 = w[ i2 ];\n\t\tu1 = u[ i2 ];\n\t\tv1 = v[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tw0 = w1[ i1 ];\n\t\t\tu0 = u1[ i1 ];\n\t\t\tv0 = v1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] ); // eslint-disable-line max-len\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quinary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import add from '@stdlib/number/float64/base/add5';\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = ones4d( shape );\n* var z = ones4d( shape );\n* var w = ones4d( shape );\n* var v = ones4d( shape );\n* var out = zeros4d( shape );\n*\n* quinary4d( [ x, y, z, w, v, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ]\n*/\nfunction quinary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar u1;\n\tvar v1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar u2;\n\tvar v2;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tu = arrays[ 4 ];\n\tv = arrays[ 5 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tz2 = z[ i3 ];\n\t\tw2 = w[ i3 ];\n\t\tu2 = u[ i3 ];\n\t\tv2 = v[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tw1 = w2[ i2 ];\n\t\t\tu1 = u2[ i2 ];\n\t\t\tv1 = v2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\tu0 = u1[ i1 ];\n\t\t\t\tv0 = v1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quinary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>>} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import add from '@stdlib/number/float64/base/add5';\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = ones5d( shape );\n* var z = ones5d( shape );\n* var w = ones5d( shape );\n* var v = ones5d( shape );\n* var out = zeros5d( shape );\n*\n* quinary5d( [ x, y, z, w, v, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] ]\n*/\nfunction quinary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar u1;\n\tvar v1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar u2;\n\tvar v2;\n\tvar x3;\n\tvar y3;\n\tvar z3;\n\tvar w3;\n\tvar u3;\n\tvar v3;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tu = arrays[ 4 ];\n\tv = arrays[ 5 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tz3 = z[ i4 ];\n\t\tw3 = w[ i4 ];\n\t\tu3 = u[ i4 ];\n\t\tv3 = v[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tw2 = w3[ i3 ];\n\t\t\tu2 = u3[ i3 ];\n\t\t\tv2 = v3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tw1 = w2[ i2 ];\n\t\t\t\tu1 = u2[ i2 ];\n\t\t\t\tv1 = v2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\t\tu0 = u1[ i1 ];\n\t\t\t\t\tv0 = v1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] ); // eslint-disable-line max-len\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quinary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {Array} output array\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, -2, -3, 4 ];\n*\n* var out = internal( x, isPositive );\n* // returns [ -2, -3 ]\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( !predicate.call( thisArg, v, i, x ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {Array} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 1, -2, -3, 4 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns [ -2, -3 ]\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tout = [];\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tv = get( data, i );\n\t\tif ( !predicate.call( thisArg, v, i, data ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {Collection} output array\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, -2, -3, 4 ];\n*\n* var out = reject( x, isPositive );\n* // returns [ -2, -3 ]\n*/\nfunction reject( x, predicate, thisArg ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default reject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Copies and renames specified keys for every element in a provided array.\n*\n* ## Notes\n*\n* - The function only copies and renames those keys which are present in a provided mapping object. Any keys which are not present in the provided mapping object, but are present in the original objects, are omitted during object creation.\n* - The function assumes that each object has the keys specified in a provided mapping object.\n* - The function performs shallow copies of key values.\n*\n* @param {ArrayLikeObject} arr - input array\n* @param {Object} mapping - object mapping existing keys to new key names\n* @returns {Array} output array\n*\n* @example\n* var x = [\n* {\n* 'x': 1,\n* 'y': 2\n* },\n* {\n* 'x': 3,\n* 'y': 4\n* }\n* ];\n* var mapping = {\n* 'x': 'a',\n* 'y': 'b'\n* };\n*\n* var out = rekey( x, mapping );\n* // returns [ { 'a': 1, 'b': 2 }, { 'a': 3, 'b': 4 } ]\n*/\nfunction rekey( arr, mapping ) {\n\tvar okeys;\n\tvar nkeys;\n\tvar get;\n\tvar out;\n\tvar obj;\n\tvar tmp;\n\tvar M;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\t// Resolve the list of old key names:\n\tokeys = objectKeys( mapping );\n\tN = okeys.length;\n\n\t// Resolve the list of new key names:\n\tnkeys = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tnkeys.push( mapping[ okeys[ i ] ] );\n\t}\n\n\tget = resolveGetter( arr );\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\ttmp = get( arr, i );\n\t\tobj = {};\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tobj[ nkeys[ j ] ] = tmp[ okeys[ j ] ];\n\t\t}\n\t\tout.push( obj );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default rekey;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils/define-read-write-accessor';\nimport resolveGetter from './../../../base/resolve-getter';\nimport objectKeys from '@stdlib/utils/keys';\n\n\n// MAIN //\n\n/**\n* Returns an array containing views with renamed keys for every element in a provided array.\n*\n* ## Notes\n*\n* - The function returns views having only those keys which are present in a provided mapping object. Any keys which are not present in the provided mapping object, but are present in the original objects, are omitted during view creation.\n* - The function assumes that each object has the keys specified in a provided mapping object.\n* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either an array element or a view will mutate the other.\n*\n* @param {ArrayLikeObject} arr - input array\n* @param {Object} mapping - object mapping existing keys to new key names\n* @returns {Array} output array\n*\n* @example\n* var x = [\n* {\n* 'x': 1,\n* 'y': 2\n* },\n* {\n* 'x': 3,\n* 'y': 4\n* }\n* ];\n* var mapping = {\n* 'x': 'a',\n* 'y': 'b'\n* };\n*\n* var out = rekeyViews( x, mapping );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'a': 1, 'b': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'a': 3, 'b': 4 }\n*\n* // Mutate the first element in the input array:\n* x[ 0 ].x = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'a': 5, 'b': 2 }\n*\n* // Set a view property:\n* out[ 1 ].b = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'a': 3, 'b': 'beep' }\n*\n* var y = x.slice();\n* // returns [ { 'x': 5, 'y': 2 }, { 'x': 3, 'y': 'beep' } ]\n*/\nfunction rekeyViews( arr, mapping ) {\n\tvar getter;\n\tvar okeys;\n\tvar nkeys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\t// Resolve the list of old key names:\n\tokeys = objectKeys( mapping );\n\tN = okeys.length;\n\n\t// Resolve the list of new key names:\n\tnkeys = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tnkeys.push( mapping[ okeys[ i ] ] );\n\t}\n\t// Resolve the accessor for the input array:\n\tgetter = resolveGetter( arr );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( i ) {\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, nkeys[ i ], getValue( okeys[ i ] ), setValue( okeys[ i ] ) ); // eslint-disable-line max-len\n\t}\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {string} key - field name\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( key ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\treturn getter( arr, this._i )[ key ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {string} key - field name\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( key ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tgetter( arr, this._i )[ key ] = value;\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = nkeys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default rekeyViews;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Removes an element from an array.\n*\n* @param {Array} x - input array\n* @param {integer} index - element index\n* @returns {Array} mutated input array\n*\n* @example\n* var x = [ 1, 1, 2, 3, 3 ];\n*\n* var y = removeAt( x, -3 );\n* // returns [ 1, 1, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*/\nfunction removeAt( x, index ) {\n\tvar len;\n\tvar i;\n\tvar j;\n\n\tlen = x.length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t\tif ( index < 0 ) {\n\t\t\treturn x;\n\t\t}\n\t} else if ( index >= len ) {\n\t\treturn x;\n\t}\n\tj = index;\n\tfor ( i = index+1; i < len; i++ ) {\n\t\tx[ j ] = x[ i ];\n\t\tj += 1;\n\t}\n\tx.length = j;\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default removeAt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\nimport floor from '@stdlib/math/base/special/floor';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'reverse' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Reverses an array in-place.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internal( x );\n* // returns [ 4, 3, 2, 1 ]\n*/\nfunction internal( x ) {\n\tvar tmp;\n\tvar N;\n\tvar M;\n\tvar i;\n\tvar j;\n\n\tN = floor( x.length/2 );\n\tM = x.length - 1;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = M - i;\n\t\ttmp = x[ i ];\n\t\tx[ i ] = x[ j ];\n\t\tx[ j ] = tmp;\n\t}\n\treturn x;\n}\n\n/**\n* Reverses an array in-place.\n*\n* @private\n* @param {Object} x - input array object\n* @returns {Collection} input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* var out = accessors( arraylike2object( x ) );\n*\n* v = x.get( 0 );\n* // returns 4\n*/\nfunction accessors( x ) {\n\tvar data;\n\tvar get;\n\tvar set;\n\tvar tmp;\n\tvar N;\n\tvar M;\n\tvar i;\n\tvar j;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\tset = x.accessors[ 1 ];\n\n\tN = floor( data.length/2 );\n\tM = data.length - 1;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = M - i;\n\t\ttmp = get( data, i );\n\t\tset( data, i, get( data, j ) );\n\t\tset( data, j, tmp );\n\t}\n\treturn data;\n}\n\n\n// MAIN //\n\n/**\n* Reverses an array in-place.\n*\n* @param {Collection} x - input array\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = reverse( x );\n* // returns [ 4, 3, 2, 1 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var out = reverse( x );\n* // returns [ 4, 3, 2, 1 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction reverse( x ) {\n\tvar obj;\n\tif ( hasMethod( x, 'reverse' ) ) {\n\t\treturn x.reverse();\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj );\n\t}\n\treturn internal( x );\n}\n\n\n// EXPORTS //\n\nexport default reverse;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\nimport put from './../../../base/put';\n\n\n// MAIN //\n\n/**\n* Scatters a list of provided values to specified indices in a new filled \"generic\" array.\n*\n* @param {*} fill - fill value\n* @param {NonNegativeInteger} len - output array length\n* @param {IntegerArray} indices - list of indices\n* @param {Collection} values - values to scatter\n* @param {string} mode - index mode\n* @throws {Error} third argument must be broadcast compatible with the second argument\n* @returns {Array} output array\n*\n* @example\n* var indices = [ 1, 2 ];\n* var values = [ 20, 30 ];\n*\n* var out = scatterFilled( null, 4, indices, values, 'throw' );\n* // returns [ null, 20, 30, null ]\n*\n* @example\n* var indices = [ 1, 2 ];\n* var values = [ 30 ];\n*\n* var out = scatterFilled( null, 4, indices, values, 'throw' );\n* // returns [ null, 30, 30, null ]\n*/\nfunction scatterFilled( fill, len, indices, values, mode ) {\n\treturn put( filled( fill, len ), indices, values, mode );\n}\n\n\n// EXPORTS //\n\nexport default scatterFilled;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport zeros from './../../../base/zeros';\nimport put from './../../../base/put';\n\n\n// MAIN //\n\n/**\n* Scatters a list of provided values to specified indices in a new zero-filled \"generic\" array.\n*\n* @param {NonNegativeInteger} len - output array length\n* @param {IntegerArray} indices - list of indices\n* @param {Collection} values - values to scatter\n* @param {string} mode - index mode\n* @throws {Error} third argument must be broadcast compatible with the second argument\n* @returns {Array} output array\n*\n* @example\n* var indices = [ 1, 2 ];\n* var values = [ 20, 30 ];\n*\n* var out = scattered( 4, indices, values, 'throw' );\n* // returns [ 0, 20, 30, 0 ]\n*\n* @example\n* var indices = [ 1, 2 ];\n* var values = [ 30 ];\n*\n* var out = scattered( 4, indices, values, 'throw' );\n* // returns [ 0, 30, 30, 0 ]\n*/\nfunction scattered( len, indices, values, mode ) {\n\treturn put( zeros( len ), indices, values, mode );\n}\n\n\n// EXPORTS //\n\nexport default scattered;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Converts a strided array to a two-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - dimension strides\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array} two-dimensional nested array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array2d( x, [ 3, 2 ], [ 2, 1 ], 0 );\n* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array2d( x, [ 3, 2 ], [ 1, 3 ], 0 );\n* // returns [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]\n*/\nfunction strided2array2d( x, shape, strides, offset ) {\n\tvar get;\n\tvar out;\n\tvar tmp;\n\tvar dx0;\n\tvar dx1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar ix;\n\n\tget = resolveGetter( x );\n\n\tS1 = shape[ 0 ];\n\tS0 = shape[ 1 ];\n\n\tdx1 = strides[ 0 ];\n\tdx0 = strides[ 1 ];\n\n\tout = [];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ttmp = [];\n\t\tix = offset + ( dx1*i1 );\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\ttmp.push( get( x, ix ) );\n\t\t\tix += dx0;\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default strided2array2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Converts a strided array to a three-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - dimension strides\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array>} three-dimensional nested array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 );\n* // returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 );\n* // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ]\n*/\nfunction strided2array3d( x, shape, strides, offset ) {\n\tvar get;\n\tvar out;\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar ix1;\n\tvar ix0;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar t2;\n\tvar t1;\n\n\tget = resolveGetter( x );\n\n\tS2 = shape[ 0 ];\n\tS1 = shape[ 1 ];\n\tS0 = shape[ 2 ];\n\n\tdx2 = strides[ 0 ];\n\tdx1 = strides[ 1 ];\n\tdx0 = strides[ 2 ];\n\n\tout = [];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tt2 = [];\n\t\tix1 = offset + ( dx2*i2 );\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tt1 = [];\n\t\t\tix0 = ix1 + ( dx1*i1 );\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tt1.push( get( x, ix0 ) );\n\t\t\t\tix0 += dx0;\n\t\t\t}\n\t\t\tt2.push( t1 );\n\t\t}\n\t\tout.push( t2 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default strided2array3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Converts a strided array to a four-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - dimension strides\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array>>} four-dimensional nested array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 6, 6, 2, 1 ], 0 );\n* // returns [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ]\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 1, 1, 1, 3 ], 0 );\n* // returns [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ]\n*/\nfunction strided2array4d( x, shape, strides, offset ) {\n\tvar get;\n\tvar out;\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar ix2;\n\tvar ix1;\n\tvar ix0;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar t3;\n\tvar t2;\n\tvar t1;\n\n\tget = resolveGetter( x );\n\n\tS3 = shape[ 0 ];\n\tS2 = shape[ 1 ];\n\tS1 = shape[ 2 ];\n\tS0 = shape[ 3 ];\n\n\tdx3 = strides[ 0 ];\n\tdx2 = strides[ 1 ];\n\tdx1 = strides[ 2 ];\n\tdx0 = strides[ 3 ];\n\n\tout = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tt3 = [];\n\t\tix2 = offset + ( dx3*i3 );\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tt2 = [];\n\t\t\tix1 = ix2 + ( dx2*i2 );\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tt1 = [];\n\t\t\t\tix0 = ix1 + ( dx1*i1 );\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tt1.push( get( x, ix0 ) );\n\t\t\t\t\tix0 += dx0;\n\t\t\t\t}\n\t\t\t\tt2.push( t1 );\n\t\t\t}\n\t\t\tt3.push( t2 );\n\t\t}\n\t\tout.push( t3 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default strided2array4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Converts a strided array to a five-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - dimension strides\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array>>>} five-dimensional nested array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 6, 6, 6, 2, 1 ], 0 );\n* // returns [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ]\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 1, 1, 1, 1, 3 ], 0 );\n* // returns [ [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] ]\n*/\nfunction strided2array5d( x, shape, strides, offset ) {\n\tvar get;\n\tvar out;\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dx4;\n\tvar ix3;\n\tvar ix2;\n\tvar ix1;\n\tvar ix0;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar t4;\n\tvar t3;\n\tvar t2;\n\tvar t1;\n\n\tget = resolveGetter( x );\n\n\tS4 = shape[ 0 ];\n\tS3 = shape[ 1 ];\n\tS2 = shape[ 2 ];\n\tS1 = shape[ 3 ];\n\tS0 = shape[ 4 ];\n\n\tdx4 = strides[ 0 ];\n\tdx3 = strides[ 1 ];\n\tdx2 = strides[ 2 ];\n\tdx1 = strides[ 3 ];\n\tdx0 = strides[ 4 ];\n\n\tout = [];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tt4 = [];\n\t\tix3 = offset + ( dx4*i4 );\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tt3 = [];\n\t\t\tix2 = ix3 + ( dx3*i3 );\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tt2 = [];\n\t\t\t\tix1 = ix2 + ( dx2*i2 );\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tt1 = [];\n\t\t\t\t\tix0 = ix1 + ( dx1*i1 );\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tt1.push( get( x, ix0 ) );\n\t\t\t\t\t\tix0 += dx0;\n\t\t\t\t\t}\n\t\t\t\t\tt2.push( t1 );\n\t\t\t\t}\n\t\t\t\tt3.push( t2 );\n\t\t\t}\n\t\t\tt4.push( t3 );\n\t\t}\n\t\tout.push( t4 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default strided2array5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Takes elements from an indexed array.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} indices - list of indices\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var y = take( x, indices );\n* // returns [ 4, 2, 3, 1 ]\n*/\nfunction take( x, indices ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\tout.push( x[ indices[ i ] ] ); // use `Array#push` to ensure \"fast\" elements\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default take;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Takes elements from two indexed arrays in a single pass.\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {NonNegativeIntegerArray} indices - list of indices\n* @returns {Array} output arrays\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var out = take2( x, y, indices );\n* // returns [ [ 4, 2, 3, 1 ], [ 8, 6, 7, 5 ] ]\n*/\nfunction take2( x, y, indices ) {\n\tvar o1;\n\tvar o2;\n\tvar i;\n\n\to1 = [];\n\to2 = [];\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\to1.push( x[ indices[ i ] ] ); // use `Array#push` to ensure \"fast\" elements\n\t\to2.push( y[ indices[ i ] ] );\n\t}\n\treturn [ o1, o2 ];\n}\n\n\n// EXPORTS //\n\nexport default take2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport { factory as indexFunction } from '@stdlib/ndarray/base/ind';\nimport take2d from './../../../base/take2d';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar NDIMS = 3;\n\n\n// MAIN //\n\n/**\n* Takes elements from a three-dimensional nested array.\n*\n* ## Notes\n*\n* - The function does **not** deep copy nested array elements.\n*\n* @param {ArrayLikeObject} x - input array\n* @param {NonNegativeIntegerArray} indices - list of indices\n* @param {integer} dimension - dimension along which to take elements\n* @param {string} mode - index mode specifying how to handle an index which is out-of-bounds\n* @throws {RangeError} third argument exceeds the number of dimensions\n* @throws {TypeError} fourth argument must be a recognized index mode\n* @returns {(Array|Array)} output array\n*\n* @example\n* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ];\n* var indices = [ 1, 1, 0, 0, -1, -1 ];\n*\n* var y = take3d( x, indices, 2, 'normalize' );\n* // returns [ [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] ]\n*/\nfunction take3d( x, indices, dimension, mode ) {\n\tvar lastIndex;\n\tvar out;\n\tvar dim;\n\tvar ind;\n\tvar idx;\n\tvar i;\n\n\tdim = normalizeIndex( dimension, NDIMS-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Third argument exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', NDIMS, dimension ) );\n\t}\n\tout = [];\n\tif ( dim === 0 ) {\n\t\tind = indexFunction( mode );\n\t\tlastIndex = x.length - 1;\n\t\tfor ( i = 0; i < indices.length; i++ ) {\n\t\t\tidx = ind( indices[ i ], lastIndex );\n\t\t\tout.push( x[ idx ] );\n\t\t}\n\t\treturn out;\n\t}\n\t// Case: dim > 0\n\tdim = dimension - 1;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( take2d( x[ i ], indices, dim, mode ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default take3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add3';\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = ones2d( shape );\n* var z = ones2d( shape );\n* var out = zeros2d( shape );\n*\n* ternary2d( [ x, y, z, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ]\n*/\nfunction ternary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tz0 = z[ i1 ];\n\t\tw0 = w[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tw0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default ternary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add3';\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = ones3d( shape );\n* var z = ones3d( shape );\n* var out = zeros3d( shape );\n*\n* ternary3d( [ x, y, z, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ]\n*/\nfunction ternary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tz1 = z[ i2 ];\n\t\tw1 = w[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tw0 = w1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tw0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default ternary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add3';\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = ones4d( shape );\n* var z = ones4d( shape );\n* var out = zeros4d( shape );\n*\n* ternary4d( [ x, y, z, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ]\n*/\nfunction ternary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tz2 = z[ i3 ];\n\t\tw2 = w[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tw1 = w2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tw0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default ternary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add3';\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = ones5d( shape );\n* var z = ones5d( shape );\n* var out = zeros5d( shape );\n*\n* ternary5d( [ x, y, z, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] ]\n*/\nfunction ternary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar x3;\n\tvar y3;\n\tvar z3;\n\tvar w3;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tz3 = z[ i4 ];\n\t\tw3 = w[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tw2 = w3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tw1 = w2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tw0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default ternary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport AccessorArray from './../../../base/accessor';\n\n\n// MAIN //\n\n/**\n* Converts an array-like object to a minimal array-like object supporting the accessor protocol.\n*\n* ## Notes\n*\n* - If a provided array-like object already supports the accessor protocol, the function returns the provided array-like object; otherwise, the function wraps the provided value in a object which uses accessors for getting and setting elements.\n*\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {(Collection|AccessorArray)} array-like object supporting the accessor protocol\n*\n* @example\n* var o = toAccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = o.get( 0 );\n* // returns 1\n*/\nfunction toAccessorArray( arr ) {\n\tif ( arr && typeof arr === 'object' && isAccessorArray( arr ) ) {\n\t\treturn arr;\n\t}\n\treturn new AccessorArray( arr );\n}\n\n\n// EXPORTS //\n\nexport default toAccessorArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from '@stdlib/math/base/assert/is-nan';\n\n\n// FUNCTIONS //\n\n/**\n* Copies de-duplicated values to a new array.\n*\n* @private\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 1, 2, 3, 3 ];\n*\n* var y = dedupeCopy( x, 1 );\n* // returns [ 1, 2, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ];\n*\n* var y = dedupeCopy( x, 2 );\n* // returns [ 1, 1, 2, 1, 1, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*/\nfunction dedupeCopy( x, limit ) {\n\tvar count;\n\tvar prev;\n\tvar len;\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tprev = NaN; // we leverage the fact that `NaN` is not equal to anything, including itself, to handle the initial condition\n\tcount = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( v === prev ) {\n\t\t\tcount += 1;\n\t\t\tif ( count <= limit ) {\n\t\t\t\tout.push( prev );\n\t\t\t}\n\t\t} else {\n\t\t\tprev = v;\n\t\t\tcount = 1;\n\t\t\tout.push( prev );\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Copies de-duplicated values to a new array, treating `NaN` values as equal.\n*\n* @private\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 1, 2, NaN, NaN, 3, 3 ];\n*\n* var y = dedupeEqualNaNs( x, 1 );\n* // returns [ 1, 2, NaN, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, NaN, NaN, NaN, 3, 3 ];\n*\n* var y = dedupeEqualNaNs( x, 2 );\n* // returns [ 1, 1, 2, 1, 1, NaN, NaN, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*/\nfunction dedupeEqualNaNs( x, limit ) {\n\tvar count;\n\tvar prev;\n\tvar len;\n\tvar out;\n\tvar FLG;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tFLG = false;\n\tprev = NaN; // we leverage the fact that `NaN` is not equal to anything, including itself, to handle the initial condition\n\tcount = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( v === prev || ( FLG && isnan( v ) ) ) {\n\t\t\tcount += 1;\n\t\t\tif ( count <= limit ) {\n\t\t\t\tout.push( prev );\n\t\t\t}\n\t\t} else {\n\t\t\tprev = v;\n\t\t\tcount = 1;\n\t\t\tout.push( prev );\n\t\t\tFLG = false;\n\t\t\tif ( isnan( prev ) ) {\n\t\t\t\tFLG = true;\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Copies elements to a new \"generic\" array after removing consecutive duplicated values.\n*\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @param {boolean} equalNaNs - boolean indicating whether NaNs should be considered equal\n* @returns {Array} de-duplicated values\n*\n* @example\n* var x = [ 1, 1, 2, 3, 3 ];\n*\n* var y = dedupe( x, 1, false );\n* // returns [ 1, 2, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ];\n*\n* var y = dedupe( x, 2, false );\n* // returns [ 1, 1, 2, 1, 1, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*/\nfunction dedupe( x, limit, equalNaNs ) {\n\tif ( equalNaNs ) {\n\t\treturn dedupeEqualNaNs( x, limit );\n\t}\n\treturn dedupeCopy( x, limit );\n}\n\n\n// EXPORTS //\n\nexport default dedupe;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns a new array with elements in reverse order.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internal( x );\n* // returns [ 4, 3, 2, 1 ]\n*/\nfunction internal( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = x.length-1; i >= 0; i-- ) {\n\t\tout.push( x[ i ] );\n\t}\n\treturn out;\n}\n\n/**\n* Returns a new array with elements in reverse order.\n*\n* @private\n* @param {Object} x - input array object\n* @returns {Array} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* var out = accessors( arraylike2object( x ) );\n* // returns [ 4, 3, 2, 1 ]\n*/\nfunction accessors( x ) {\n\tvar data;\n\tvar get;\n\tvar out;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tout = [];\n\tfor ( i = data.length-1; i >= 0; i-- ) {\n\t\tout.push( get( data, i ) );\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a new array with elements in reverse order.\n*\n* @param {Collection} x - input array\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = toReversed( x );\n* // returns [ 4, 3, 2, 1 ]\n*\n* var bool = ( out === x );\n* // returns false\n*/\nfunction toReversed( x ) {\n\tvar obj;\n\tif ( hasMethod( x, 'toReversed' ) ) {\n\t\treturn x.toReversed();\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj );\n\t}\n\treturn internal( x );\n}\n\n\n// EXPORTS //\n\nexport default toReversed;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = zeros2d( shape );\n*\n* unary2d( [ x, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*/\nfunction unary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar x;\n\tvar y;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary function to each element retrieved from a two-dimensional nested input array according to a callback function and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - unary function to apply to callback return values\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function accessor( v ) {\n* return v - 2.0;\n* }\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = zeros2d( shape );\n*\n* unary2dBy( [ x, y ], shape, scale, accessor );\n*\n* console.log( y );\n* // => [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ]\n*/\nfunction unary2dBy( arrays, shape, fcn, clbk ) {\n\tvar thisArg;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar x;\n\tvar y;\n\tvar v;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tif ( arguments.length > 4 ) {\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tv = clbk.call( thisArg, x0[ i0 ], [ i1, i0 ], [ x, y ] );\n\t\t\tif ( v !== void 0 ) {\n\t\t\t\ty0[ i0 ] = fcn( v );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = zeros3d( shape );\n*\n* unary3d( [ x, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*/\nfunction unary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar x;\n\tvar y;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary function to each element retrieved from a three-dimensional nested input array according to a callback function and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - unary function to apply to callback return values\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* function accessor( v ) {\n* return v - 2.0;\n* }\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = zeros3d( shape );\n*\n* unary3dBy( [ x, y ], shape, scale, accessor );\n*\n* console.log( y );\n* // => [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ]\n*/\nfunction unary3dBy( arrays, shape, fcn, clbk ) {\n\tvar thisArg;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar x;\n\tvar y;\n\tvar v;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tif ( arguments.length > 4 ) {\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tv = clbk.call( thisArg, x0[ i0 ], [ i2, i1, i0 ], [ x, y ] );\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\ty0[ i0 ] = fcn( v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary3dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* unary4d( [ x, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction unary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar x;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary function to each element retrieved from a four-dimensional nested input array according to a callback function and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - unary function to apply to callback return values\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function accessor( v ) {\n* return v - 2.0;\n* }\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* unary4dBy( [ x, y ], shape, scale, accessor );\n*\n* console.log( y );\n* // => [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ]\n*/\nfunction unary4dBy( arrays, shape, fcn, clbk ) {\n\tvar thisArg;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar x;\n\tvar y;\n\tvar v;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tif ( arguments.length > 4 ) {\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tv = clbk.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], [ x, y ] ); // eslint-disable-line max-len\n\t\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\t\ty0[ i0 ] = fcn( v );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary4dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = zeros5d( shape );\n*\n* unary5d( [ x, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*/\nfunction unary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar x;\n\tvar y;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n/* eslint-disable max-depth */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary function to each element retrieved from a five-dimensional nested input array according to a callback function and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - unary function to apply to callback return values\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* function accessor( v ) {\n* return v - 2.0;\n* }\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = zeros5d( shape );\n*\n* unary5dBy( [ x, y ], shape, scale, accessor );\n*\n* console.log( y );\n* // => [ [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ] ]\n*/\nfunction unary5dBy( arrays, shape, fcn, clbk ) {\n\tvar thisArg;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar x;\n\tvar y;\n\tvar v;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tif ( arguments.length > 4 ) {\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tv = clbk.call( thisArg, x0[ i0 ], [ i4, i3, i2, i1, i0 ], [ x, y ] ); // eslint-disable-line max-len\n\t\t\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\t\t\ty0[ i0 ] = fcn( v );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary5dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1.\n*\n* @param {number} x1 - first array value\n* @param {number} x2 - array element bound\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = unitspace( 0, 6 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*/\nfunction unitspace( x1, x2 ) {\n\tvar arr;\n\tvar len;\n\tvar i;\n\n\tlen = x2 - x1;\n\tif ( len <= 1 ) {\n\t\treturn [ x1 ];\n\t}\n\tarr = [ x1 ];\n\tfor ( i = 1; i < len; i++ ) {\n\t\tarr.push( x1 + i );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default unitspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled3d from './../../../base/filled3d';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled three-dimensional nested array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = zeros3d( [ 1, 1, 3 ] );\n* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ]\n*/\nfunction zeros3d( shape ) {\n\treturn filled3d( 0.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default zeros3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled4d from './../../../base/filled4d';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled four-dimensional nested array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = zeros4d( [ 1, 1, 1, 3 ] );\n* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ]\n*/\nfunction zeros4d( shape ) {\n\treturn filled4d( 0.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default zeros4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled5d from './../../../base/filled5d';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled five-dimensional nested array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = zeros5d( [ 1, 1, 1, 1, 3 ] );\n* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ]\n*/\nfunction zeros5d( shape ) {\n\treturn filled5d( 0.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default zeros5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fillednd from './../../../base/fillednd';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled n-dimensional nested array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = zerosnd( [ 3 ] );\n* // returns [ 0.0, 0.0, 0.0 ]\n*\n* @example\n* var out = zerosnd( [ 1, 3 ] );\n* // returns [ [ 0.0, 0.0, 0.0 ] ]\n*/\nfunction zerosnd( shape ) {\n\treturn fillednd( 0.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default zerosnd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport copy from './../../../base/copy';\n\n\n// MAIN //\n\n/**\n* Zips one or more arrays.\n*\n* ## Notes\n*\n* - The function assumes that the list of arrays to be zipped all have the same length.\n*\n* @param {Collection} arrays - list of arrays to be zipped\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3 ];\n* var y = [ 'a', 'b', 'c' ];\n*\n* var z = zip( [ x, y ] );\n* // returns [ [ 1, 'a' ], [ 2, 'b' ], [ 3, 'c' ] ]\n*/\nfunction zip( arrays ) {\n\tvar getters;\n\tvar list;\n\tvar out;\n\tvar arr;\n\tvar M;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tM = arrays.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\tlist = copy( arrays );\n\tN = list[ 0 ].length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\tgetters = [];\n\tfor ( j = 0; j < M; j++ ) {\n\t\tgetters.push( resolveGetter( list[ j ] ) );\n\t}\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tarr = [];\n\t\tfor ( j = 0; j < M; j++ ) {\n\t\t\tarr.push( getters[ j ]( list[ j ], i ) );\n\t\t}\n\t\tout.push( arr );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default zip;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Zips accessor arrays to an object.\n*\n* @private\n* @param {Object} properties - properties object\n* @param {Object} values - values object\n* @returns {Object} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var props = toAccessorArray( [ 'a', 'b', 'c' ] );\n* var values = toAccessorArray( [ 1, 2, 3 ] );\n*\n* var obj = accessors( arraylike2object( props ), arraylike2object( values ) );\n* // returns { 'a': 1, 'b': 2, 'c': 3 }\n*/\nfunction accessors( properties, values ) {\n\tvar pdata;\n\tvar vdata;\n\tvar pget;\n\tvar vget;\n\tvar out;\n\tvar i;\n\n\tpdata = properties.data;\n\tpget = properties.accessors[ 0 ];\n\n\tvdata = values.data;\n\tvget = values.accessors[ 0 ];\n\n\tout = {};\n\tfor ( i = 0; i < pdata.length; i++ ) {\n\t\tout[ pget( pdata, i ) ] = vget( vdata, i );\n\t}\n\treturn out;\n}\n\n/**\n* Zips indexed collections to an object.\n*\n* @private\n* @param {Collection} properties - list of properties\n* @param {Collection} values - list of values\n* @returns {Object} result\n*\n* @example\n* var props = [ 'a', 'b', 'c' ];\n* var values = [ 1, 2, 3 ];\n*\n* var obj = indexed( props, values );\n* // returns { 'a': 1, 'b': 2, 'c': 3 }\n*/\nfunction indexed( properties, values ) {\n\tvar out;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < properties.length; i++ ) {\n\t\tout[ properties[ i ] ] = values[ i ];\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Creates an object from a provided list of properties and a provided list of corresponding values.\n*\n* @param {Collection} properties - list of properties\n* @param {Collection} values - list of values\n* @returns {Object} result\n*\n* @example\n* var props = [ 'a', 'b', 'c' ];\n* var values = [ 1, 2, 3 ];\n*\n* var obj = zip2object( props, values );\n* // returns { 'a': 1, 'b': 2, 'c': 3 }\n*/\nfunction zip2object( properties, values ) {\n\tvar o1 = arraylike2object( properties );\n\tvar o2 = arraylike2object( values );\n\n\tif ( o1.accessorProtocol || o2.accessorProtocol ) {\n\t\treturn accessors( o1, o2 );\n\t}\n\treturn indexed( properties, values );\n}\n\n\n// EXPORTS //\n\nexport default zip2object;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport copy from './../../../base/copy';\n\n\n// MAIN //\n\n/**\n* Zips one or more arrays to an array of objects.\n*\n* ## Notes\n*\n* - The function assumes that the list of arrays to be zipped all have the same length.\n* - The number of provided array labels should equal the number of arrays to be zipped.\n*\n* @param {Collection} arrays - list of arrays to be zipped\n* @param {ArrayLikeObject} labels - list of array labels\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3 ];\n* var y = [ 'a', 'b', 'c' ];\n*\n* var labels = [ 'x', 'y' ];\n*\n* var z = zip2objects( [ x, y ], labels );\n* // returns [ { 'x': 1, 'y': 'a' }, { 'x': 2, 'y': 'b' }, { 'x': 3, 'y': 'c' } ]\n*/\nfunction zip2objects( arrays, labels ) {\n\tvar getters;\n\tvar list;\n\tvar keys;\n\tvar get;\n\tvar out;\n\tvar obj;\n\tvar M;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tM = arrays.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\tlist = copy( arrays );\n\tN = list[ 0 ].length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\tgetters = [];\n\n\tget = resolveGetter( labels );\n\tkeys = [];\n\tfor ( j = 0; j < M; j++ ) {\n\t\tgetters.push( resolveGetter( list[ j ] ) );\n\t\tkeys.push( get( labels, j ) );\n\t}\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tobj = {};\n\t\tfor ( j = 0; j < M; j++ ) {\n\t\t\tobj[ keys[ j ] ] = getters[ j ]( list[ j ], i );\n\t\t}\n\t\tout.push( obj );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default zip2objects;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils/define-read-write-accessor';\nimport accessors from './../../../base/accessors';\nimport copy from './../../../base/copy';\n\n\n// MAIN //\n\n/**\n* Zips one or more arrays to an array of composite views.\n*\n* ## Notes\n*\n* - The function assumes that the list of arrays to be zipped all have the same length.\n* - The list of provided array labels should equal the number of arrays to be zipped.\n* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either an input array or a view will mutate the other.\n*\n* @param {Collection} arrays - list of arrays to be zipped\n* @param {ArrayLikeObject} labels - list of array labels\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3 ];\n* var y = [ 'a', 'b', 'c' ];\n*\n* var labels = [ 'x', 'y' ];\n*\n* var z = zip2views( [ x, y ], labels );\n* // returns [ , , ]\n*\n* var v0 = z[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 'a' }\n*\n* var v1 = z[ 1 ].toJSON();\n* // returns { 'x': 2, 'y': 'b' }\n*\n* var v2 = z[ 2 ].toJSON();\n* // returns { 'x': 3, 'y': 'c' }\n*\n* // Mutate one of the input arrays:\n* x[ 0 ] = 5;\n*\n* v0 = z[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 'a' }\n*\n* // Set a view property:\n* z[ 1 ].y = 'beep';\n*\n* v1 = z[ 1 ].toJSON();\n* // returns { 'x': 2, 'y': 'beep' }\n*\n* var y1 = y.slice();\n* // returns [ 'a', 'beep', 'c' ]\n*/\nfunction zip2views( arrays, labels ) {\n\tvar getter;\n\tvar setter;\n\tvar list;\n\tvar keys;\n\tvar out;\n\tvar acc;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arrays.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\tlist = copy( arrays );\n\tN = list[ 0 ].length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Resolve element accessors...\n\tacc = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tacc.push( accessors( list[ i ] ).accessors );\n\t}\n\t// Create a copy of provided labels to prevent external mutation:\n\tkeys = copy( labels );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view of zipped elements.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( i ) {\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define read/write accessors for each label...\n\tfor ( i = 0; i < M; i++ ) {\n\t\tgetter = getValue( list[ i ], acc[ i ][ 0 ] );\n\t\tsetter = setValue( list[ i ], acc[ i ][ 1 ] );\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getter, setter );\n\t}\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout.push( new Datum( i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Returns an accessor for returning the value associated with a label.\n\t*\n\t* @private\n\t* @param {Collection} arr - input array\n\t* @param {Function} getter - array element accessor\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( arr, getter ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a label.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\treturn getter( arr, this._i ); // eslint-disable-line no-invalid-this\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a label.\n\t*\n\t* @private\n\t* @param {Collection} arr - input array\n\t* @param {Function} setter - array element accessor\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( arr, setter ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a label.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tsetter( arr, this._i, value ); // eslint-disable-line no-invalid-this\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < M; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ]; // eslint-disable-line no-invalid-this\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default zip2views;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof ArrayBuffer === 'function' ) ? ArrayBuffer : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayBuffer from './../../is-arraybuffer';\nimport Float64Array from '@stdlib/array/float64';\nimport GlobalArrayBuffer from './arraybuffer.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `ArrayBuffer` support.\n*\n* @returns {boolean} boolean indicating if an environment has `ArrayBuffer` support\n*\n* @example\n* var bool = hasArrayBufferSupport();\n* // returns \n*/\nfunction hasArrayBufferSupport() {\n\tvar bool;\n\tvar view;\n\tvar buf;\n\n\tif ( typeof GlobalArrayBuffer !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tbuf = new GlobalArrayBuffer( 16 );\n\t\tbool = ( isArrayBuffer( buf ) && typeof GlobalArrayBuffer.isView === 'function' );\n\t\tif ( bool ) {\n\t\t\tview = new Float64Array( buf );\n\t\t\tview[ 0 ] = -3.14;\n\t\t\tview[ 1 ] = NaN;\n\t\t\tbool = (\n\t\t\t\tbool &&\n\t\t\t\tGlobalArrayBuffer.isView( view ) &&\n\t\t\t\tbuf.byteLength === 16 &&\n\t\t\t\tview[ 0 ] === -3.14 &&\n\t\t\t\tview[ 1 ] !== view[ 1 ]\n\t\t\t);\n\t\t}\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasArrayBufferSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof ArrayBuffer === 'function' ) ? ArrayBuffer : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Constructor which returns a data view representing a provided array buffer.\n*\n* @module @stdlib/array/dataview\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n* import DataView from '@stdlib/array/dataview';\n*\n* var buf = new ArrayBuffer( 10 );\n* // returns \n*\n* var dv = new DataView( buf );\n* // returns \n*/\n\n// MODULES //\n\nimport hasDataViewSupport from '@stdlib/assert/has-dataview-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasDataViewSupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.\n*\n* @module @stdlib/array/buffer\n*\n* @example\n* import ctor from '@stdlib/array/buffer';\n*\n* var buf = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasArrayBufferSupport from '@stdlib/assert/has-arraybuffer-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasArrayBufferSupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasDataView = ( typeof DataView === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a `DataView`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a DataView\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n* import DataView from '@stdlib/array/dataview';\n*\n* var bool = isDataView( new DataView( new ArrayBuffer( 10 ) ) );\n* // returns true\n*\n* @example\n* var bool = isDataView( [] );\n* // returns false\n*/\nfunction isDataView( value ) {\n\treturn (\n\t\t( hasDataView && value instanceof DataView ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object DataView]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isDataView;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof ArrayBuffer === 'function' ) ? ArrayBuffer : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.\n*\n* @module @stdlib/array/buffer\n*\n* @example\n* import ctor from '@stdlib/array/buffer';\n*\n* var buf = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasArrayBufferSupport from '@stdlib/assert/has-arraybuffer-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasArrayBufferSupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof DataView === 'function' ) ? DataView : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof DataView === 'function' ) ? DataView : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from './../../is-dataview';\nimport ArrayBuffer from '@stdlib/array/buffer';\nimport GlobalDataView from './dataview.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `DataView` support.\n*\n* @returns {boolean} boolean indicating if an environment has `DataView` support\n*\n* @example\n* var bool = hasDataViewSupport();\n* // returns \n*/\nfunction hasDataViewSupport() {\n\tvar bool;\n\tvar view;\n\tvar buf;\n\n\tif ( typeof GlobalDataView !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tbuf = new ArrayBuffer( 24 );\n\t\tview = new GlobalDataView( buf, 8 );\n\t\tbool = ( isDataView( view ) && typeof view.getFloat64 === 'function' && typeof view.setFloat64 === 'function' );\n\t\tif ( bool ) {\n\t\t\tview.setFloat64( 0, -3.14 );\n\t\t\tview.setFloat64( 8, NaN );\n\t\t\tbool = (\n\t\t\t\tbool &&\n\t\t\t\tview.buffer === buf &&\n\t\t\t\tview.byteLength === 16 &&\n\t\t\t\tview.byteOffset === 8 &&\n\t\t\t\tview.getFloat64( 0 ) === -3.14 &&\n\t\t\t\tview.getFloat64( 8 ) !== view.getFloat64( 8 )\n\t\t\t);\n\t\t}\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasDataViewSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Constructor which returns a data view representing a provided array buffer.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Rounds a numeric value to the nearest integer.\n*\n* @param {number} x - input value\n* @returns {number} function value\n*\n* @example\n* var v = round( -4.2 );\n* // returns -4.0\n*\n* @example\n* var v = round( -4.5 );\n* // returns -4.0\n*\n* @example\n* var v = round( -4.6 );\n* // returns -5.0\n*\n* @example\n* var v = round( 9.99999 );\n* // returns 10.0\n*\n* @example\n* var v = round( 9.5 );\n* // returns 10.0\n*\n* @example\n* var v = round( 9.2 );\n* // returns 9.0\n*\n* @example\n* var v = round( 0.0 );\n* // returns 0.0\n*\n* @example\n* var v = round( -0.0 );\n* // returns -0.0\n*\n* @example\n* var v = round( Infinity );\n* // returns Infinity\n*\n* @example\n* var v = round( -Infinity );\n* // returns -Infinity\n*\n* @example\n* var v = round( NaN );\n* // returns NaN\n*/\nvar round = Math.round; // eslint-disable-line stdlib/no-builtin-math\n\n\n// EXPORTS //\n\nexport default round;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport isInteger from '@stdlib/assert/is-integer';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport isObject from '@stdlib/assert/is-object';\nimport format from '@stdlib/string/format';\nimport floor from '@stdlib/math/base/special/floor';\nimport round from '@stdlib/math/base/special/round';\nimport ceil from '@stdlib/math/base/special/ceil';\n\n\n// VARIABLES //\n\nvar timestamp = /^\\d{10}$|^\\d{13}$/;\nvar rounders = [ 'floor', 'ceil', 'round' ];\n\n\n// FUNCTIONS //\n\n/**\n* Validates a date parameter.\n*\n* @private\n* @param {*} value - value to be validated\n* @param {string} name - name to be used in error messages\n* @throws {TypeError} value must either be a date string, Date object, Unix timestamp, or JavaScript timestamp\n* @throws {Error} numeric date must be either a Unix or JavaScript timestamp\n* @returns {Date} validated date\n*/\nfunction validDate( value, name ) {\n\tvar type;\n\n\ttype = typeof value;\n\tif ( type === 'string' ) {\n\t\tvalue = Date.parse( value );\n\t\tif ( value !== value ) {\n\t\t\tthrow new Error( format( 'invalid argument. Unable to parse %s date.', name.toLowerCase() ) );\n\t\t}\n\t\tvalue = new Date( value );\n\t}\n\tif ( type === 'number' ) {\n\t\tif ( !timestamp.test( value ) ) {\n\t\t\tthrow new Error( format( 'invalid argument. Numeric %s date must be either a Unix or JavaScript timestamp.', name.toLowerCase() ) );\n\t\t}\n\t\tif ( value.toString().length === 10 ) {\n\t\t\tvalue *= 1000; // sec to ms\n\t\t}\n\t\tvalue = new Date( value );\n\t}\n\tif ( !(value instanceof Date) ) {\n\t\tthrow new TypeError( format( 'invalid argument. %s date must either be a date string, Date object, Unix timestamp, or JavaScript timestamp.', name ) );\n\t}\n\treturn value;\n}\n\n\n// MAIN //\n\n/**\n* Generates an array of linearly spaced dates.\n*\n* @param {(Date|number|string)} start - start time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string\n* @param {(Date|number|string)} stop - stop time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string\n* @param {number} [length] - output array length (default: 100)\n* @param {Object} [options] - function options\n* @param {string} [options.round] - specifies how sub-millisecond times should be rounded: [ 'floor', 'ceil', 'round' ] (default: 'floor' )\n* @throws {TypeError} length argument must a positive integer\n* @throws {Error} must provide valid options\n* @returns {Array} array of dates\n*\n* @example\n* var stop = '2014-12-02T07:00:54.973Z';\n* var start = new Date( stop ) - 60000;\n*\n* var arr = datespace( start, stop, 6 );\n* // returns [...]\n*\n* @example\n* // Equivalent of Math.ceil():\n* var arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'ceil' } );\n* // returns [...]\n*\n* // Equivalent of Math.round():\n* arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'round' } );\n* // returns [...]\n*/\nfunction datespace( start, stop, length, options ) {\n\tvar opts;\n\tvar len;\n\tvar flg;\n\tvar arr;\n\tvar end;\n\tvar fcn;\n\tvar tmp;\n\tvar d;\n\tvar i;\n\n\tlen = 100;\n\tflg = true;\n\topts = {\n\t\t'round': 'floor'\n\t};\n\tstart = validDate( start, 'Start' );\n\tstop = validDate( stop, 'Stop' );\n\tif ( arguments.length > 2 ) {\n\t\tif ( arguments.length === 3 ) {\n\t\t\tif ( isObject( length ) ) {\n\t\t\t\topts = length;\n\t\t\t} else {\n\t\t\t\tlen = length;\n\n\t\t\t\t// Turn off checking the options object...\n\t\t\t\tflg = false;\n\t\t\t}\n\t\t} else {\n\t\t\topts = options;\n\t\t\tlen = length;\n\t\t}\n\t\tif ( len === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( !isInteger( len ) || len < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t\tif ( flg ) {\n\t\t\tif ( !isObject( opts ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t\t}\n\t\t\tif ( hasOwnProp( opts, 'round' ) ) {\n\t\t\t\tif ( !isString( opts.round ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'round', opts.round ) );\n\t\t\t\t}\n\t\t\t\tif ( rounders.indexOf( opts.round ) === -1 ) {\n\t\t\t\t\tthrow new Error( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'round', rounders.join( '\", \"' ), opts.round ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tswitch ( opts.round ) {\n\tcase 'round':\n\t\tfcn = round;\n\t\tbreak;\n\tcase 'ceil':\n\t\tfcn = ceil;\n\t\tbreak;\n\tcase 'floor':\n\tdefault:\n\t\tfcn = floor;\n\t\tbreak;\n\t}\n\n\t// Calculate the increment...\n\tend = len - 1;\n\td = ( stop.getTime() - start.getTime() ) / end;\n\n\t// Build the output array...\n\tarr = new Array( len );\n\ttmp = start;\n\tarr[ 0 ] = tmp;\n\ttmp = tmp.getTime();\n\tfor ( i = 1; i < end; i++ ) {\n\t\ttmp += d;\n\t\tarr[ i ] = new Date( fcn( tmp ) );\n\t}\n\tarr[ end ] = stop;\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default datespace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport zeros from './../../zeros';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized array having a specified length.\n*\n* @private\n* @param {NonNegativeInteger} length - array length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = empty( 2 );\n* // returns \n*\n* @example\n* var arr = empty( 2, 'float32' );\n* // returns \n*/\nfunction empty( length ) {\n\tif ( arguments.length > 1 ) {\n\t\treturn zeros( length, arguments[ 1 ] );\n\t}\n\treturn zeros( length );\n}\n\n\n// EXPORTS //\n\nexport default empty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from '@stdlib/array/base/arraylike2object';\nimport accessors from './accessors.js';\n\n\n// VARIABLES //\n\nvar M = 8;\n\n\n// MAIN //\n\n/**\n* Fills a strided array with a specified scalar constant.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {*} alpha - scalar constant\n* @param {Collection} x - input array\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];\n*\n* gfill( 3, 5.0, x, 1, x.length-3 );\n* // x => [ 1.0, -2.0, 3.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfill( N, alpha, x, strideX, offsetX ) {\n\tvar ix;\n\tvar m;\n\tvar o;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn x;\n\t}\n\to = arraylike2object( x );\n\tif ( o.accessorProtocol ) {\n\t\taccessors( N, alpha, o, strideX, offsetX );\n\t\treturn o.data;\n\t}\n\tix = offsetX;\n\n\t// Use loop unrolling if the stride is equal to `1`...\n\tif ( strideX === 1 ) {\n\t\tm = N % M;\n\n\t\t// If we have a remainder, run a clean-up loop...\n\t\tif ( m > 0 ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\tx[ ix ] = alpha;\n\t\t\t\tix += strideX;\n\t\t\t}\n\t\t}\n\t\tif ( N < M ) {\n\t\t\treturn x;\n\t\t}\n\t\tfor ( i = m; i < N; i += M ) {\n\t\t\tx[ ix ] = alpha;\n\t\t\tx[ ix+1 ] = alpha;\n\t\t\tx[ ix+2 ] = alpha;\n\t\t\tx[ ix+3 ] = alpha;\n\t\t\tx[ ix+4 ] = alpha;\n\t\t\tx[ ix+5 ] = alpha;\n\t\t\tx[ ix+6 ] = alpha;\n\t\t\tx[ ix+7 ] = alpha;\n\t\t\tix += M;\n\t\t}\n\t\treturn x;\n\t}\n\tfor ( i = 0; i < N; i++ ) {\n\t\tx[ ix ] = alpha;\n\t\tix += strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default gfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills a strided array with a specified scalar constant.\n*\n* @private\n* @param {PositiveInteger} N - number of indexed elements\n* @param {*} alpha - scalar constant\n* @param {Object} x - input array object\n* @param {Collection} x.data - input array data\n* @param {Array} x.accessors - array element accessors\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {Object} input array object\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n*\n* function setter( data, idx, value ) {\n* data.set( value, idx );\n* }\n*\n* var data = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );\n*\n* var x = {\n* 'data': data,\n* 'accessors': [ null, setter ]\n* };\n*\n* var alpha = new Complex64( 5.0, 5.0 );\n*\n* gfill( data.length, alpha, x, 1, 0 );\n*\n* var view = reinterpret64( x.data, 0 );\n* // returns [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfill( N, alpha, x, strideX, offsetX ) {\n\tvar xbuf;\n\tvar set;\n\tvar ix;\n\tvar i;\n\n\t// Cache reference to array data:\n\txbuf = x.data;\n\n\t// Cache a reference to the element accessor:\n\tset = x.accessors[ 1 ];\n\n\tix = offsetX;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tset( xbuf, ix, alpha );\n\t\tix += strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default gfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport stride2offset from '@stdlib/strided/base/stride2offset';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\n/**\n* Fills a strided array with a specified scalar constant.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {*} alpha - scalar constant\n* @param {Collection} x - input array\n* @param {integer} strideX - stride length\n* @returns {Collection} input array\n*\n* @example\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfill( x.length, 5.0, x, 1 );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfill( N, alpha, x, strideX ) {\n\treturn ndarray( N, alpha, x, strideX, stride2offset( N, strideX ) );\n}\n\n\n// EXPORTS //\n\nexport default gfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from './../../is-function';\n\n\n// MAIN //\n\n/**\n* Tests if a value is iterator-like.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is iterator-like\n*\n* @example\n* var it = {\n* 'next': function noop() {}\n* };\n* var bool = isIteratorLike( it );\n* // returns true\n*\n* @example\n* var bool = isIteratorLike( {} );\n* // returns false\n*\n* @example\n* var bool = isIteratorLike( null );\n* // returns false\n*/\nfunction isIteratorLike( value ) {\n\tvar t = typeof value;\n\treturn (\n\t\tvalue !== null &&\n\t\t( t === 'object' || t === 'function' ) &&\n\t\tisFunction( value.next )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isIteratorLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isIteratorLike from '@stdlib/assert/is-iterator-like';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Consumes an iterator and returns the number of iterated values (i.e., the iterator length).\n*\n* @param {Iterator} iterator - input iterator\n* @throws {TypeError} must provide an iterator\n* @returns {NonNegativeInteger} iterator length\n*\n* @example\n* import array2iterator from '@stdlib/array/to-iterator';\n*\n* var it = array2iterator( [ 0, 0, 0, 0, 1 ] );\n*\n* var v = iterLength( it );\n* // returns 5\n*/\nfunction iterLength( iterator ) {\n\tvar count;\n\tvar v;\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an iterator. Value: `%s`.', iterator ) );\n\t}\n\tcount = 0;\n\twhile ( true ) {\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\treturn count;\n\t\t}\n\t\tcount += 1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default iterLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Fill a strided array with a specified scalar constant.\n*\n* @module @stdlib/blas/ext/base/gfill\n*\n* @example\n* import gfill from '@stdlib/blas/ext/base/gfill';\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfill( x.length, 5.0, x, 1 );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*\n* @example\n* import gfill from '@stdlib/blas/ext/base/gfill';\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfill.ndarray( x.length, 5.0, x, 1, 0 );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../base/assert/is-boolean-data-type';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport ctors from './../../ctors';\nimport gfill from '@stdlib/blas/ext/base/gfill';\nimport filled from './../../base/filled';\nimport reinterpretBool from '@stdlib/strided/base/reinterpret-boolean';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport iterLength from '@stdlib/iter/length';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\n\t}\n\treturn arr;\n}\n\n/**\n* Fills an array exposing accessors for getting and setting array elements.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\n* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} must provide a recognized data type\n* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable\n* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tnargs -= 1;\n\tif ( nargs >= 0 && isString( arguments[ nargs ] ) ) {\n\t\tdtype = arguments[ nargs ];\n\t\tnargs -= 1;\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\n\t\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\t\tlen = arg;\n\t\t\t} else if ( isCollection( arg ) ) {\n\t\t\t\tlen = arg.length;\n\t\t\t}\n\t\t\tif ( len !== void 0 ) {\n\t\t\t\treturn filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t\t}\n\t\t\tif ( isObject( arg ) ) {\n\t\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\n\t\tif ( isCollection( arg ) ) {\n\t\t\tarr = new ctor( arg.length );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isNonNegativeInteger( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from '@stdlib/array/base/arraylike2object';\nimport accessors from './accessors.js';\n\n\n// MAIN //\n\n/**\n* Fills a strided array according to a provided callback function.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - execution context\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* gfillBy( 3, x, 1, x.length-3, fill );\n* // x => [ 1.0, -2.0, 3.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfillBy( N, x, strideX, offsetX, clbk, thisArg ) {\n\tvar ix;\n\tvar o;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn x;\n\t}\n\to = arraylike2object( x );\n\tif ( o.accessorProtocol ) {\n\t\taccessors( N, o, strideX, offsetX, clbk, thisArg );\n\t\treturn o.data;\n\t}\n\tix = offsetX;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tx[ ix ] = clbk.call( thisArg, x[ ix ], i, ix, x );\n\t\tix += strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default gfillBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills a strided array according to a provided callback function.\n*\n* @private\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Object} x - input array object\n* @param {Collection} x.data - input array data\n* @param {Array} x.accessors - array element accessors\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @param {Callback} clbk - callback function\n* @param {*} thisArg - execution context\n* @returns {Object} input array object\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n*\n* function setter( data, idx, value ) {\n* data.set( value, idx );\n* }\n*\n* function getter( data, idx ) {\n* return data.get( idx );\n* }\n*\n* var data = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );\n*\n* var x = {\n* 'data': data,\n* 'accessors': [ getter, setter ]\n* };\n*\n* function clbk() {\n* return new Complex64( 5.0, 5.0 );\n* }\n*\n* gfillBy( data.length, x, 1, 0, clbk, void 0 );\n*\n* var view = reinterpret64( x.data, 0 );\n* // view => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfillBy( N, x, strideX, offsetX, clbk, thisArg ) {\n\tvar xbuf;\n\tvar set;\n\tvar get;\n\tvar ix;\n\tvar i;\n\n\t// Cache reference to array data:\n\txbuf = x.data;\n\n\t// Cache a reference to the element accessors:\n\tget = x.accessors[ 0 ];\n\tset = x.accessors[ 1 ];\n\n\tix = offsetX;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tset( xbuf, ix, clbk.call( thisArg, get( xbuf, ix ), i, ix, x ) );\n\t\tix += strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default gfillBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport stride2offset from '@stdlib/strided/base/stride2offset';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\n/**\n* Fills a strided array according to a provided callback function.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} strideX - stride length\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - execution context\n* @returns {Collection} input array\n*\n* @example\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* gfillBy( x.length, x, 1, fill );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfillBy( N, x, strideX, clbk, thisArg ) {\n\treturn ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default gfillBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Fill a strided array according to a provided callback function.\n*\n* @module @stdlib/blas/ext/base/gfill-by\n*\n* @example\n* import gfillBy from '@stdlib/blas/ext/base/gfill-by';\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfillBy( x.length, x, 1, fill );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*\n* @example\n* import gfillBy from '@stdlib/blas/ext/base/gfill-by';\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfillBy.ndarray( x.length, x, 1, 0, fill );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../base/assert/is-boolean-data-type';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport ctors from './../../ctors';\nimport gfillBy from '@stdlib/blas/ext/base/gfill-by';\nimport filledArray from './../../base/filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport iterLength from '@stdlib/iter/length';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterable} it - iterator\n* @param {Callback} clbk - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {Array} filled array\n*/\nfunction filledArrayIterator( it, clbk, thisArg ) {\n\tvar arr;\n\tvar i;\n\tvar v;\n\n\tarr = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tarr.push( clbk.call( thisArg, i ) );\n\t}\n\treturn arr;\n}\n\n/**\n* Fills an array exposing accessors for getting and setting array elements.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {Callback} clbk - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, clbk, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( clbk.call( thisArg, i ), i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array according to a provided callback function.\n*\n* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"float64\"] - data type\n* @param {Callback} [clbk] - callback to invoke\n* @param {*} [thisArg] - callback execution context\n* @throws {TypeError} must provide a recognized data type\n* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable\n* @throws {TypeError} callback argument must be a function.\n* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array)} array or typed array\n*\n* @example\n* var arr = filledarrayBy();\n* // returns \n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'generic', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1;\n* }\n*\n* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk );\n* // returns [ 1, 1 ]\n*\n* @example\n* function clbk1() {\n* return 10;\n* }\n*\n* function clbk2() {\n* return 1.0;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, clbk2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk1() {\n* return 1.0;\n* }\n*\n* function clbk2() {\n* return 2;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 );\n* // returns [ 2, 2 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 'float32', clbk );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, clbk );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk );\n* // returns [ 1, 1 ]\n*/\nfunction filledarrayBy() {\n\tvar thisArg;\n\tvar nargs;\n\tvar dtype;\n\tvar clbk;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\n\t// If we weren't provided any arguments, return an empty array...\n\tif ( nargs === 0 ) {\n\t\tctor = ctors( DEFAULT_DTYPE );\n\t\treturn new ctor( 0 );\n\t}\n\t// Check if we were provided a dtype as the first argument...\n\tdtype = arguments[ 0 ];\n\tif ( isString( dtype ) ) {\n\t\t// Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)...\n\t\tif ( nargs > 1 ) {\n\t\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t\t}\n\t\t// Return an empty array having the specified dtype:\n\t\treturn new ctor( 0 );\n\t}\n\t// For all other supported invocations, we need at least two arguments...\n\tif ( nargs < 2 ) {\n\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t}\n\t// At this point, we need to do some argument juggling...\n\tnargs -= 1; // henceforth, the number of available arguments is `nargs+1`\n\n\t// Determine whether the last argument is a callback or \"this\" context...\n\tif ( isFunction( arguments[ nargs ] ) ) {\n\t\t// If the last argument is a function, we need to check the next-to-last argument, and, if the next-to-last argument is a function, assume that the next-to-last argument is the callback and the last argument is a \"this\" context...\n\t\tif ( isFunction( arguments[ nargs-1 ] ) ) {\n\t\t\tthisArg = arguments[ nargs ];\n\t\t\tnargs -= 1;\n\t\t\tclbk = arguments[ nargs ];\n\n\t\t\t// Check if we were provided only a callback and a \"this\" context..\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t\t\t}\n\t\t} else {\n\t\t\t// \"this\" context is left undefined...\n\t\t\tclbk = arguments[ nargs ];\n\t\t}\n\t}\n\t// If we were provided 3 or more arguments and the last argument was not a function, assume that we were provided a callback and a \"this\" context...\n\telse if ( nargs >= 2 ) {\n\t\tthisArg = arguments[ nargs ];\n\t\tnargs -= 1;\n\t\tclbk = arguments[ nargs ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t}\n\t// If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments...\n\telse {\n\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t}\n\t// Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument...\n\tnargs -= 1;\n\tif ( nargs >= 0 && isString( arguments[ nargs ] ) ) {\n\t\tdtype = arguments[ nargs ];\n\t\tnargs -= 1;\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\t// At this point, we've resolved the output array data type, and now we can actually create the output array...\n\tif ( dtype === 'generic' ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( nargs === 0 ) {\n\t\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\t\tlen = arg;\n\t\t\t} else if ( isCollection( arg ) ) {\n\t\t\t\tlen = arg.length;\n\t\t\t}\n\t\t\tif ( len !== void 0 ) {\n\t\t\t\treturn filledArray( len, clbk, thisArg );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t\t}\n\t\t\tif ( isObject( arg ) ) {\n\t\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledArrayIterator( arg, clbk, thisArg );\n\t\t\t}\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t}\n\tif ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 0 ];\n\t\tif ( isCollection( arg ) ) {\n\t\t\tarr = new ctor( arg.length );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isNonNegativeInteger( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else if ( nargs === 1 ) {\n\t\tarr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, clbk, thisArg );\n\t\t} else {\n\t\t\tgfillBy( arr.length, arr, 1, callback );\n\t\t}\n\t}\n\treturn arr;\n\n\t/**\n\t* Callback which wraps a provided callback and is invoked for each array element.\n\t*\n\t* @private\n\t* @param {*} value - element value\n\t* @param {NonNegativeInteger} aidx - array index\n\t* @param {NonNegativeInteger} sidx - strided index\n\t* @param {Collection} array - input array/collection\n\t* @returns {*} callback return value\n\t*/\n\tfunction callback( value, aidx ) {\n\t\treturn clbk.call( thisArg, aidx );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default filledarrayBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar isProtoOf = Object.prototype.isPrototypeOf;\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Tests if an object's prototype chain contains a provided prototype.\n*\n* @param {*} value - value to test\n* @param {(Object|Function)} proto - prototype\n* @throws {TypeError} second argument must be an object and not null\n* @returns {boolean} boolean indicating if a provided prototype exists in a prototype chain\n*\n* @example\n* import inherit from '@stdlib/utils/inherit';\n*\n* function Foo() {\n* return this;\n* }\n*\n* function Bar() {\n* return this;\n* }\n* inherit( Bar, Foo );\n*\n* var bar = new Bar();\n*\n* var bool = isPrototypeOf( bar, Foo.prototype );\n* // returns true\n*/\nfunction isPrototypeOf( value, proto ) { // eslint-disable-line stdlib/no-redeclare\n\tvar type = typeof proto;\n\tif (\n\t\tproto === null ||\n\t\t(type !== 'object' && type !== 'function')\n\t) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either an object (except null) or a function. Value: `%s`.', proto ) );\n\t}\n\ttype = typeof value;\n\tif (\n\t\tvalue === null ||\n\t\t(type !== 'object' && type !== 'function')\n\t) {\n\t\treturn false;\n\t}\n\treturn isProtoOf.call( proto, value );\n}\n\n\n// EXPORTS //\n\nexport default isPrototypeOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BYTES_PER_ELEMENT from './bytes_per_element.json';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes per element provided an underlying array data type.\n*\n* @param {string} dtype - data type\n* @returns {(NonNegativeInteger|null)} number of bytes per element\n*\n* @example\n* var nbytes = bytesPerElement( 'float64' );\n* // returns 8\n*\n* nbytes = bytesPerElement( 'generic' );\n* // returns null\n*/\nfunction bytesPerElement( dtype ) {\n\treturn BYTES_PER_ELEMENT[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default bytesPerElement;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Capitalizes the first character in a string.\n*\n* @param {string} str - input string\n* @returns {string} capitalized string\n*\n* @example\n* var out = capitalize( 'last man standing' );\n* // returns 'Last man standing'\n*\n* @example\n* var out = capitalize( 'presidential election' );\n* // returns 'Presidential election'\n*\n* @example\n* var out = capitalize( 'javaScript' );\n* // returns 'JavaScript'\n*\n* @example\n* var out = capitalize( 'Hidden Treasures' );\n* // returns 'Hidden Treasures'\n*/\nfunction capitalize( str ) {\n\tif ( str === '' ) {\n\t\treturn '';\n\t}\n\treturn str.charAt( 0 ).toUpperCase() + str.slice( 1 );\n}\n\n\n// EXPORTS //\n\nexport default capitalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len, no-restricted-syntax, no-invalid-this, max-lines */\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport isByteOrder from './../../base/assert/is-byte-order';\nimport lowercase from '@stdlib/string/base/lowercase';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isPrototypeOf from '@stdlib/assert/is-prototype-of'; // eslint-disable-line stdlib/no-redeclare\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport ArrayBuffer from './../../buffer';\nimport DataView from './../../dataview';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport { factory as contains } from './../../base/assert/contains';\nimport bytesPerElement from '@stdlib/ndarray/base/bytes-per-element';\nimport capitalize from '@stdlib/string/base/capitalize';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar LITTLE_ENDIAN = 'little-endian';\nvar BIG_ENDIAN = 'big-endian';\nvar DTYPES = [ 'float64', 'float32', 'int32', 'int16', 'uint32', 'uint16' ];\nvar DTYPE2SET = {\n\t'float64': 'setFloat64',\n\t'float32': 'setFloat32',\n\t'int32': 'setInt32',\n\t'int16': 'setInt16',\n\t'uint32': 'setUint32',\n\t'uint16': 'setUint16'\n};\nvar DTYPE2GET = {\n\t'float64': 'getFloat64',\n\t'float32': 'getFloat32',\n\t'int32': 'getInt32',\n\t'int16': 'getInt16',\n\t'uint32': 'getUint32',\n\t'uint16': 'getUint16'\n};\nvar CHAR2ARTICLE = {\n\t'c': 'a',\n\t'f': 'a',\n\t'i': 'an',\n\t'u': 'a',\n\t'b': 'a'\n};\nvar isDataType = contains( DTYPES );\n\n\n// FUNCTIONS //\n\n/**\n* Normalizes a byte order value.\n*\n* @private\n* @param {*} value - byte order\n* @returns {(string|null)} normalized byte order\n*/\nfunction byteOrder( value ) {\n\treturn ( isString( value ) ) ? lowercase( value ) : null;\n}\n\n/**\n* Tests whether a provided byte order is little-endian byte order.\n*\n* @private\n* @param {string} value - byte order\n* @returns {boolean} boolean indicating whether a byte order is little-endian byte order\n*/\nfunction isLittleEndian( value ) {\n\treturn ( value === LITTLE_ENDIAN );\n}\n\n/**\n* Resolves a byte order string from a boolean flag.\n*\n* @private\n* @param {boolean} isLE - flag indicating whether an array is little-endian\n* @returns {string} resolved byte order\n*/\nfunction flag2byteOrder( isLE ) {\n\treturn ( isLE ) ? LITTLE_ENDIAN : BIG_ENDIAN;\n}\n\n/**\n* Converts a data type string to a constructor name.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {string} constructor name\n*\n* @example\n* var n = dtype2ctor( 'float64' );\n* // returns 'Float64ArrayFE'\n*\n* @example\n* var n = dtype2ctor( 'int32' );\n* // returns 'Int32ArrayFE'\n*/\nfunction dtype2ctor( dtype ) {\n\treturn capitalize( dtype ) + 'ArrayFE';\n}\n\n\n// MAIN //\n\n/**\n* Returns a typed array constructor for creating typed arrays having a specified byte order.\n*\n* @param {string} dtype - typed array data type\n* @throws {TypeError} first argument must be a supported data type\n* @returns {Function} typed array constructor\n*\n* @example\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var arr = new Float64ArrayFE( 'little-endian' );\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var arr = new Float64ArrayFE( 'little-endian', 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayFE( 'little-endian', buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayFE( 'little-endian', buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayFE( 'little-endian', buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) { // eslint-disable-line max-lines-per-function, stdlib/jsdoc-require-throws-tags\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar GETTER;\n\tvar SETTER;\n\n\tif ( !isDataType( dtype ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a supported data type. Value: `%s`.', dtype ) );\n\t}\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tGETTER = DTYPE2GET[ dtype ];\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in a specified byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {string} endianness - byte order\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} first argument must be a supported byte order\n\t* @throws {TypeError} if provided only two arguments, the second argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {RangeError} byte offset must be a multiple of the data type size\n\t* @throws {TypeError} view length must be a positive multiple of the data type size\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar byteOffset;\n\t\tvar endianness;\n\t\tvar nargs;\n\t\tvar isLE;\n\t\tvar buf;\n\t\tvar len;\n\t\tvar arg;\n\t\tvar tmp;\n\n\t\tnargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs < 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\tif ( nargs === 3 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2], arguments[3] );\n\t\t}\n\t\tendianness = byteOrder( arguments[ 0 ] );\n\t\tif ( endianness === null || !isByteOrder( endianness ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a supported byte order. Value: `%s`.', arguments[ 0 ] ) );\n\t\t}\n\t\tisLE = isLittleEndian( endianness );\n\n\t\tnargs -= 1;\n\n\t\t// Create the underlying data buffer...\n\t\tif ( nargs === 0 ) {\n\t\t\tbuf = new DataView( new ArrayBuffer( 0 ) ); // backward-compatibility\n\t\t} else if ( nargs === 1 ) {\n\t\t\targ = arguments[ nargs ];\n\t\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\t\tbuf = new DataView( new ArrayBuffer( arg*BYTES_PER_ELEMENT ) );\n\t\t\t} else if ( isCollection( arg ) ) {\n\t\t\t\tbuf = fromArray( new DataView( new ArrayBuffer( arg.length*BYTES_PER_ELEMENT ) ), arg, isLE );\n\t\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\t\tbuf = new DataView( arg );\n\t\t\t\tif ( !isNonNegativeInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) );\n\t\t\t\t}\n\t\t\t} else if ( isObject( arg ) ) {\n\t\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t\tbuf = fromArray( new DataView( new ArrayBuffer( tmp.length*BYTES_PER_ELEMENT ) ), tmp, isLE );\n\t\t\t} else {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t} else {\n\t\t\tbuf = arguments[ 1 ];\n\t\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbyteOffset = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\tbuf = new DataView( buf, byteOffset );\n\t\t\t} else {\n\t\t\t\tlen = arguments[ 3 ];\n\t\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t\t}\n\t\t\t\tlen *= BYTES_PER_ELEMENT;\n\t\t\t\tif ( len > (buf.byteLength-byteOffset) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tbuf = new DataView( buf, byteOffset, len );\n\t\t\t}\n\t\t}\n\t\tsetReadOnly( this, '_buffer', buf );\n\t\tsetReadOnly( this, '_length', buf.byteLength/BYTES_PER_ELEMENT );\n\t\tsetReadOnly( this, '_isLE', isLE );\n\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {string} endianness - byte order\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be a supported byte order\n\t* @throws {TypeError} second argument must be an array-like object or an iterable\n\t* @throws {TypeError} third argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( endianness, src ) {\n\t\tvar thisArg;\n\t\tvar order;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar isLE;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\torder = byteOrder( endianness );\n\t\tif ( order === null || !isByteOrder( order ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a supported byte order. Value: `%s`.', endianness ) );\n\t\t}\n\t\tisLE = isLittleEndian( order );\n\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 2 ) {\n\t\t\tclbk = arguments[ 2 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( order, len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), isLE );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( order, src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( order, len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], isLE );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {string} endianness - byte order\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be a supported byte order\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of( endianness ) {\n\t\tvar order;\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\torder = byteOrder( endianness );\n\t\tif ( order === null || !isByteOrder( order ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a supported byte order. Value: `%s`.', endianness ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( order, args );\n\t});\n\n\t/**\n\t* Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices.\n\t*\n\t* @private\n\t* @name at\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {integer} idx - element index\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} must provide an integer\n\t* @returns {(*|void)} array element\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'at', function at( idx ) {\n\t\tvar len;\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t\t}\n\t\tlen = this._length;\n\t\tif ( idx < 0 ) {\n\t\t\tidx += len;\n\t\t}\n\t\tif ( idx < 0 || idx >= len ) {\n\t\t\treturn;\n\t\t}\n\t\treturn this._buffer[ GETTER ]( idx * BYTES_PER_ELEMENT, this._isLE );\n\t});\n\n\t/**\n\t* Pointer to the underlying data buffer.\n\t*\n\t* @private\n\t* @name buffer\n\t* @memberof TypedArray.prototype\n\t* @readonly\n\t* @type {ArrayBuffer}\n\t*/\n\tsetReadOnlyAccessor( TypedArray.prototype, 'buffer', function get() {\n\t\treturn this._buffer.buffer;\n\t});\n\n\t/**\n\t* Size (in bytes) of the array.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof TypedArray.prototype\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnlyAccessor( TypedArray.prototype, 'byteLength', function get() {\n\t\treturn this._buffer.byteLength;\n\t});\n\n\t/**\n\t* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n\t*\n\t* @private\n\t* @name byteOffset\n\t* @memberof TypedArray.prototype\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnlyAccessor( TypedArray.prototype, 'byteOffset', function get() {\n\t\treturn this._buffer.byteOffset;\n\t});\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray.prototype\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'BYTES_PER_ELEMENT', TypedArray.BYTES_PER_ELEMENT );\n\n\t/**\n\t* Tests whether all elements in an array pass a test implemented by a predicate function.\n\t*\n\t* @private\n\t* @name every\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} predicate - predicate function\n\t* @param {*} [thisArg] - predicate function execution context\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a function\n\t* @returns {boolean} boolean indicating whether all elements pass a test\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'every', function every( predicate, thisArg ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( predicate ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tif ( !predicate.call( thisArg, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t});\n\n\t/**\n\t* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n\t*\n\t* @private\n\t* @name filter\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} predicate - test function\n\t* @param {*} [thisArg] - predicate function execution context\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a function\n\t* @returns {TypedArray} typed array\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'filter', function filter( predicate, thisArg ) {\n\t\tvar buf;\n\t\tvar out;\n\t\tvar i;\n\t\tvar v;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( predicate ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tout = [];\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tv = buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE );\n\t\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\t\tout.push( v );\n\t\t\t}\n\t\t}\n\t\treturn new this.constructor( flag2byteOrder( this._isLE ), out );\n\t});\n\n\t/**\n\t* Invokes a function once for each array element.\n\t*\n\t* @private\n\t* @name forEach\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} fcn - function to invoke\n\t* @param {*} [thisArg] - function invocation context\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a function\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tfcn.call( thisArg, buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE ), i, this );\n\t\t}\n\t});\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @name get\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {NonNegativeInteger} idx - element index\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} must provide a nonnegative integer\n\t* @returns {(*|void)} array element\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'get', function get( idx ) {\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t\tif ( idx >= this._length ) {\n\t\t\treturn;\n\t\t}\n\t\treturn this._buffer[ GETTER ]( idx*BYTES_PER_ELEMENT, this._isLE );\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether an array includes a provided value.\n\t*\n\t* @private\n\t* @name includes\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {*} searchElement - search element\n\t* @param {integer} [fromIndex=0] - starting index (inclusive)\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} second argument must be an integer\n\t* @returns {boolean} boolean indicating whether an array includes a provided value\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( arguments.length > 1 ) {\n\t\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t\t}\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex += this._length;\n\t\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\t\tfromIndex = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfromIndex = 0;\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\t\tif ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t});\n\n\t/**\n\t* Returns the index of the first occurrence of a given element.\n\t*\n\t* @private\n\t* @name indexOf\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {*} searchElement - element to search for\n\t* @param {integer} [fromIndex=0] - starting index (inclusive)\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} second argument must be an integer\n\t* @returns {integer} index or -1\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( arguments.length > 1 ) {\n\t\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t\t}\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex += this._length;\n\t\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\t\tfromIndex = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfromIndex = 0;\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\t\tif ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t});\n\n\t/**\n\t* Returns a new string by concatenating all array elements.\n\t*\n\t* @private\n\t* @name join\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {string} [separator=','] - element separator\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a string\n\t* @returns {string} joined string\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'join', function join( separator ) {\n\t\tvar out;\n\t\tvar buf;\n\t\tvar sep;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\tif ( !isString( separator ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t\t}\n\t\t\tsep = separator;\n\t\t} else {\n\t\t\tsep = ',';\n\t\t}\n\t\tout = [];\n\t\tbuf = this._buffer;\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tout.push( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) );\n\t\t}\n\t\treturn out.join( sep );\n\t});\n\n\t/**\n\t* Returns the index of the last occurrence of a given element.\n\t*\n\t* @private\n\t* @name lastIndexOf\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {*} searchElement - element to search for\n\t* @param {integer} [fromIndex] - starting index (inclusive)\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} second argument must be an integer\n\t* @returns {integer} index or -1\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[ 0 ] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( arguments.length > 1 ) {\n\t\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t\t}\n\t\t\tif ( fromIndex >= this._length ) {\n\t\t\t\tfromIndex = this._length - 1;\n\t\t\t} else if ( fromIndex < 0 ) {\n\t\t\t\tfromIndex += this._length;\n\t\t\t}\n\t\t} else {\n\t\t\tfromIndex = this._length - 1;\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\t\tif ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t});\n\n\t/**\n\t* Number of array elements.\n\t*\n\t* @private\n\t* @name length\n\t* @memberof TypedArray.prototype\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnlyAccessor( TypedArray.prototype, 'length', function get() {\n\t\treturn this._length;\n\t});\n\n\t/**\n\t* Returns a new array with each element being the result of a provided callback function.\n\t*\n\t* @private\n\t* @name map\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} fcn - function to invoke\n\t* @param {*} [thisArg] - function invocation context\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a function\n\t* @returns {TypedArray} new typed array\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'map', function map( fcn, thisArg ) {\n\t\tvar obuf;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar i;\n\t\tvar v;\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tout = new this.constructor( flag2byteOrder( this._isLE ), this._length );\n\t\tobuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tv = fcn.call( thisArg, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this );\n\t\t\tobuf[ SETTER ]( i * BYTES_PER_ELEMENT, v, this._isLE );\n\t\t}\n\t\treturn out;\n\t});\n\n\t/**\n\t* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n\t*\n\t* @private\n\t* @name reduce\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} reducer - callback function\n\t* @param {*} [initialValue] - initial value\n\t* @throws {TypeError} `this` must be a typed array\n\t* @throws {Error} if not provided an initial value, the array must have at least one element\n\t* @returns {*} accumulated result\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\t\tvar buf;\n\t\tvar len;\n\t\tvar acc;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( reducer ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tlen = this._length;\n\t\tif ( arguments.length > 1 ) {\n\t\t\tacc = initialValue;\n\t\t\ti = 0;\n\t\t} else {\n\t\t\tif ( len === 0 ) {\n\t\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t\t}\n\t\t\tacc = buf[ GETTER ]( 0 * BYTES_PER_ELEMENT, this._isLE );\n\t\t\ti = 1;\n\t\t}\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tacc = reducer( acc, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this );\n\t\t}\n\t\treturn acc;\n\t});\n\n\t/**\n\t* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion.\n\t*\n\t* @private\n\t* @name reduceRight\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} reducer - callback function\n\t* @param {*} [initialValue] - initial value\n\t* @throws {TypeError} `this` must be a typed array\n\t* @throws {Error} if not provided an initial value, the array must have at least one element\n\t* @returns {*} accumulated result\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\t\tvar buf;\n\t\tvar len;\n\t\tvar acc;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( reducer ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tlen = this._length;\n\t\tif ( arguments.length > 1 ) {\n\t\t\tacc = initialValue;\n\t\t\ti = len - 1;\n\t\t} else {\n\t\t\tif ( len === 0 ) {\n\t\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t\t}\n\t\t\tacc = buf[ GETTER ]( ( len - 1 ) * BYTES_PER_ELEMENT, this._isLE );\n\t\t\ti = len - 2;\n\t\t}\n\t\tfor ( ; i >= 0; i-- ) {\n\t\t\tacc = reducer( acc, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this );\n\t\t}\n\t\treturn acc;\n\t});\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* ## Notes\n\t*\n\t* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n\t*\n\t* ```text\n\t* buf: ---------------------\n\t* src: ---------------------\n\t* ```\n\t*\n\t* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n\t*\n\t* In the other overlapping scenario,\n\t*\n\t* ```text\n\t* buf: ---------------------\n\t* src: ---------------------\n\t* ```\n\t*\n\t* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n\t*\n\t* @private\n\t* @name set\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {(Collection|TypedArray|*)} value - value(s)\n\t* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} index argument must be a nonnegative integer\n\t* @throws {RangeError} index argument is out-of-bounds\n\t* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n\t* @returns {void}\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'set', function set( value ) {\n\t\tvar sbuf;\n\t\tvar idx;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar N;\n\t\tvar i;\n\t\tvar j;\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tif ( arguments.length > 1 ) {\n\t\t\tidx = arguments[ 1 ];\n\t\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t\t}\n\t\t} else {\n\t\t\tidx = 0;\n\t\t}\n\t\tif ( isCollection( value ) ) {\n\t\t\tN = value.length;\n\t\t\tif ( idx+N > this._length ) {\n\t\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t\t}\n\t\t\tsbuf = value;\n\t\t\tif ( sbuf.get && sbuf.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\t// Check for overlapping memory...\n\t\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\t\tif (\n\t\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t\t(\n\t\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// We need to copy source values...\n\t\t\t\ttmp = [];\n\t\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\t\ttmp.push( get( value, i ) );\n\t\t\t\t}\n\t\t\t\tsbuf = tmp;\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\t\tbuf[ SETTER ]( idx*BYTES_PER_ELEMENT, get( sbuf, i ), this._isLE );\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tbuf[ SETTER ]( idx*BYTES_PER_ELEMENT, value, this._isLE );\n\t});\n\n\t/**\n\t* Tests whether at least one element in the typed array passes a test implemented by a predicate function.\n\t*\n\t* @private\n\t* @name some\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} predicate - predicate function\n\t* @param {*} [thisArg] - predicate function execution context\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a function\n\t* @returns {boolean} boolean indicating whether at least one element passes a test\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'some', function some( predicate, thisArg ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( predicate ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tif ( predicate.call( thisArg, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this ) ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t});\n\n\t/**\n\t* Serializes an array as a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @returns {string} string representation\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'toString', function toString() {\n\t\tvar out;\n\t\tvar buf;\n\t\tvar i;\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tout = [];\n\t\tbuf = this._buffer;\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tout.push( buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE ) );\n\t\t}\n\t\treturn out.join( ',' );\n\t});\n\n\t/**\n\t* Returns a new typed array with the element at a provided index replaced with a provided value.\n\t*\n\t* @private\n\t* @name with\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {integer} index - element index\n\t* @param {number} value - new value\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be an integer\n\t* @throws {RangeError} index argument is out-of-bounds\n\t* @returns {TypedArray} new typed array\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'with', function copyWith( index, value ) {\n\t\tvar outbuf;\n\t\tvar buf;\n\t\tvar out;\n\t\tvar len;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isInteger( index ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t\t}\n\t\tlen = this._length;\n\t\tbuf = this._buffer;\n\t\tif ( index < 0 ) {\n\t\t\tindex += len;\n\t\t}\n\t\tif ( index < 0 || index >= len ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t\t}\n\t\tout = new this.constructor( flag2byteOrder( this._isLE ), buf.buffer );\n\t\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\toutbuf[ SETTER ]( index * BYTES_PER_ELEMENT, value, this._isLE );\n\t\treturn out;\n\t});\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array\n\t*/\n\tfunction isTypedArray( value ) {\n\t\treturn (\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\t(\n\t\t\t\tvalue.constructor.name === CTOR_NAME ||\n\t\t\t\tisPrototypeOf( value, TypedArray.prototype )\n\t\t\t) &&\n\t\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t\t);\n\t}\n\n\t/**\n\t* Fills an output DataView with array values.\n\t*\n\t* @private\n\t* @param {DataView} view - output data view\n\t* @param {Array} arr - input array\n\t* @param {boolean} isLE - boolean indicating whether to store values in little-endian byte order\n\t* @returns {DataView} output data view\n\t*/\n\tfunction fromArray( view, arr, isLE ) {\n\t\tvar len;\n\t\tvar get;\n\t\tvar i;\n\n\t\tlen = arr.length;\n\t\tif ( arr.get && arr.set ) {\n\t\t\tget = accessorGetter( 'default' );\n\t\t} else {\n\t\t\tget = getter( 'default' );\n\t\t}\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tview[ SETTER ]( i*BYTES_PER_ELEMENT, get( arr, i ), isLE );\n\t\t}\n\t\treturn view;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a string to lowercase.\n*\n* @param {string} str - string to convert\n* @returns {string} lowercase string\n*\n* @example\n* var str = lowercase( 'bEEp' );\n* // returns 'beep'\n*/\nfunction lowercase( str ) {\n\treturn str.toLowerCase();\n}\n\n\n// EXPORTS //\n\nexport default lowercase;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './../../fixed-endian-factory';\n\n\n// MAIN //\n\n/**\n* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in a specified byte order.\n*\n* @name Float32ArrayFE\n* @constructor\n* @type {Function}\n* @param {string} endianness - byte order\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} first argument must be a supported byte order\n* @throws {TypeError} if provided only two arguments, the second argument must be a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float32ArrayFE} typed array instance\n*\n* @example\n* var arr = new Float32ArrayFE( 'little-endian' );\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float32ArrayFE( 'little-endian', 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Float32ArrayFE( 'little-endian', [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 8 );\n* var arr = new Float32ArrayFE( 'little-endian', buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 8 );\n* var arr = new Float32ArrayFE( 'little-endian', buf, 4 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float32ArrayFE( 'little-endian', buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nvar Float32ArrayFE = factory( 'float32' );\n\n\n// EXPORTS //\n\nexport default Float32ArrayFE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './../../fixed-endian-factory';\n\n\n// MAIN //\n\n/**\n* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in a specified byte order.\n*\n* @name Float64ArrayFE\n* @constructor\n* @type {Function}\n* @param {string} endianness - byte order\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} first argument must be a supported byte order\n* @throws {TypeError} if provided only two arguments, the second argument must be a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float64ArrayFE} typed array instance\n*\n* @example\n* var arr = new Float64ArrayFE( 'little-endian' );\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float64ArrayFE( 'little-endian', 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayFE( 'little-endian', buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayFE( 'little-endian', buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayFE( 'little-endian', buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nvar Float64ArrayFE = factory( 'float64' );\n\n\n// EXPORTS //\n\nexport default Float64ArrayFE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Mapping from complex number constructors to data types...\nvar ctor2dtypes = {\n\t'Complex64': 'complex64',\n\t'Complex128': 'complex128'\n};\n\n\n// EXPORTS //\n\nexport default ctor2dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64 from './../../float32/ctor';\nimport Complex128 from './../../float64/ctor';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'complex64': Complex64,\n\t'complex128': Complex128\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a complex number constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'complex128' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'complex' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dtypes from './../../dtypes';\n\n\n// MAIN //\n\nvar DTYPES = dtypes();\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctors from './../../ctors';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\nvar CTORS = [];\nvar i;\nfor ( i = 0; i < DTYPES.length; i++ ) {\n\tCTORS.push( ctors( DTYPES[ i ] ) );\n}\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport DTYPES from './dtypes.json';\n\n\n// MAIN //\n\n/**\n* Returns a list of complex number data types.\n*\n* @returns {StringArray} list of complex number data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'complex64', 'complex128' ]\n*/\nfunction dtypes() {\n\treturn DTYPES.slice();\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport constructorName from '@stdlib/utils/constructor-name';\nimport ctor2dtype from './ctor2dtype.js';\nimport CTORS from './ctors.js';\nimport DTYPES from './dtypes.js';\n\n\n// VARIABLES //\n\nvar NTYPES = DTYPES.length;\n\n\n// MAIN //\n\n/**\n* Returns the data type of a complex number.\n*\n* @param {*} value - input value\n* @returns {(string|null)} data type\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var dt = dtype( new Complex128( 1.0, 2.0 ) );\n* // returns 'complex128'\n*\n* var dt = dtype( 'beep' );\n* // returns null\n*/\nfunction dtype( value ) {\n\tvar i;\n\tfor ( i = 0; i < NTYPES; i++ ) {\n\t\tif ( value instanceof CTORS[ i ] ) {\n\t\t\treturn DTYPES[ i ];\n\t\t}\n\t}\n\t// If the above failed, fall back to a more robust (and significantly slower) means for resolving underlying data types:\n\treturn ctor2dtype[ constructorName( value ) ] || null;\n}\n\n\n// EXPORTS //\n\nexport default dtype;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport accessorSetter from './../../base/accessor-setter';\nimport setter from './../../base/setter';\nimport zeros from './../../zeros';\nimport dtype from '@stdlib/complex/dtype';\nimport defaults from './../../defaults';\n\n\n// VARIABLES //\n\nvar DEFAULT_REAL = defaults.get( 'dtypes.real_floating_point' );\nvar DEFAULT_CMPLX = defaults.get( 'dtypes.complex_floating_point' );\nvar DEFAULT_BOOL = defaults.get( 'dtypes.boolean' );\n\n\n// MAIN //\n\n/**\n* Returns a single-element array containing a provided scalar value.\n*\n* ## Notes\n*\n* - If a `dtype` option is not provided and `value`\n*\n* - is a number, the default data type is the default real-valued floating-point data type.\n* - is a boolean, the default data type is the default boolean data type.\n* - is a complex number object of a known complex data type, the data type is the same as the provided value.\n* - is a complex number object of an unknown complex data type, the default data type is the default complex-valued floating-point data type.\n* - is any other value type, the default data type is `'generic'`.\n*\n* @param {*} value - scalar value\n* @param {string} dtype - output array data type\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {Collection} output array\n*\n* @example\n* var x = scalar2array( 1.0 );\n* // returns [ 1.0 ]\n*\n* @example\n* var x = scalar2array( 1.0, 'float32' );\n* // returns [ 1.0 ]\n*/\nfunction scalar2array( value ) {\n\tvar flg;\n\tvar out;\n\tvar set;\n\tvar dt;\n\tvar v;\n\n\tflg = isNumber( value );\n\tif ( arguments.length < 2 ) {\n\t\tif ( flg ) {\n\t\t\tdt = DEFAULT_REAL;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = DEFAULT_BOOL;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = dtype( value );\n\t\t\tif ( dt === null ) {\n\t\t\t\tdt = DEFAULT_CMPLX;\n\t\t\t}\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t}\n\t} else {\n\t\tdt = arguments[ 1 ];\n\t}\n\tout = zeros( 1, dt ); // delegate dtype validation to `zeros`\n\tif ( flg && isComplexDataType( dt ) ) {\n\t\tv = [ value, 0.0 ]; // note: we're assuming that the ComplexXXArray setter accepts an array of interleaved real and imaginary components\n\t} else {\n\t\tv = value;\n\t}\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tset( out, 0, v );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default scalar2array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport ctors from './../../ctors';\nimport afill from './../../base/filled';\nimport gfill from '@stdlib/blas/ext/base/gfill';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Creates a filled array having a specified length.\n*\n* @param {NonNegativeInteger} length - array length\n* @param {*} value - fill value\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} third argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = full( 2, 1.0 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = full( 2, 1.0, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*/\nfunction full( length, value ) {\n\tvar dtype;\n\tvar ctor;\n\tvar out;\n\tif ( !isNonNegativeInteger( length ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', length ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tdtype = arguments[ 2 ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tif ( dtype === 'generic' ) {\n\t\treturn afill( value, length );\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\tout = new ctor( length );\n\n\t// TODO: revisit the following, as using `gfill` is not the most performant, especially for large arrays. We have two options: (1) use a native add-on which delegates to an appropriate C function which performs the loop or (2) use @stdlib/blas/ext/base/(d|s|c|z)fill functions which use native add-ons. The latter option is not great, as we only get perf boosts for large arrays for a select number of dtypes. The former option is more work, as we may need to write a bespoke add-on for handling the argument signature and the various types that `value` can assume (e.g., number, complex, etc). If we had a generic strided `copy` package with an add-on, we could wrap the value as a single element strided array with a stride of `0` and copy from `x` to `y`, and thus would not need to write a bespoke add-on. Note, however, that calling into a native add-on is not free. For shorter arrays, we'll likely observe a perf hit in Node.js. For now, we focus on just getting something working...\n\tgfill( length, value, out, 1 );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default full;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Dummy function.\n*\n* @private\n*/\nfunction foo() {\n\t// No-op...\n}\n\n\n// EXPORTS //\n\nexport default foo;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert/is-function';\nimport hasFunctionNameSupport from '@stdlib/assert/has-function-name-support';\nimport format from '@stdlib/string/format';\nimport { REGEXP as RE } from '@stdlib/regexp/function-name';\n\n\n// VARIABLES //\n\nvar isFunctionNameSupported = hasFunctionNameSupport();\n\n\n// MAIN //\n\n/**\n* Returns the name of a function.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} function name\n*\n* @example\n* var v = functionName( Math.sqrt );\n* // returns 'sqrt'\n*\n* @example\n* var v = functionName( function foo(){} );\n* // returns 'foo'\n*\n* @example\n* var v = functionName( function(){} );\n* // returns '' || 'anonymous'\n*\n* @example\n* var v = functionName( String );\n* // returns 'String'\n*/\nfunction functionName( fcn ) {\n\t// TODO: add support for generator functions?\n\tif ( isFunction( fcn ) === false ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a function. Value: `%s`.', fcn ) );\n\t}\n\tif ( isFunctionNameSupported ) {\n\t\treturn fcn.name;\n\t}\n\treturn RE.exec( fcn.toString() )[ 1 ];\n}\n\n\n// EXPORTS //\n\nexport default functionName;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport foo from './foo.js';\n\n\n// MAIN //\n\n/**\n* Tests for native function `name` support.\n*\n* @returns {boolean} boolean indicating if an environment has function `name` support\n*\n* @example\n* var bool = hasFunctionNameSupport();\n* // returns \n*/\nfunction hasFunctionNameSupport() {\n\treturn ( foo.name === 'foo' );\n}\n\n\n// EXPORTS //\n\nexport default hasFunctionNameSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Int8Array from '@stdlib/array/int8';\nimport Uint8Array from '@stdlib/array/uint8';\nimport Uint8ClampedArray from '@stdlib/array/uint8c';\nimport Int16Array from '@stdlib/array/int16';\nimport Uint16Array from '@stdlib/array/uint16';\nimport Int32Array from '@stdlib/array/int32';\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float32Array from '@stdlib/array/float32';\nimport Float64Array from '@stdlib/array/float64';\n\n\n// MAIN //\n\nvar CTORS = [\n\tFloat64Array,\n\tFloat32Array,\n\tInt32Array,\n\tUint32Array,\n\tInt16Array,\n\tUint16Array,\n\tInt8Array,\n\tUint8Array,\n\tUint8ClampedArray\n];\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctorName from '@stdlib/utils/constructor-name';\nimport fcnName from '@stdlib/utils/function-name';\nimport getPrototypeOf from '@stdlib/utils/get-prototype-of';\nimport hasFloat64ArraySupport from './../../has-float64array-support';\nimport Float64Array from '@stdlib/array/float64';\nimport CTORS from './ctors.js';\nimport NAMES from './names.json';\n\n\n// VARIABLES //\n\n// Abstract `TypedArray` class:\nvar TypedArray = ( hasFloat64ArraySupport() ) ? getPrototypeOf( Float64Array ) : Dummy; // eslint-disable-line max-len\n\n// Ensure abstract typed array class has expected name:\nTypedArray = ( fcnName( TypedArray ) === 'TypedArray' ) ? TypedArray : Dummy;\n\n\n// FUNCTIONS //\n\n/**\n* Dummy constructor.\n*\n* @private\n*/\nfunction Dummy() {} // eslint-disable-line no-empty-function\n\n\n// MAIN //\n\n/**\n* Tests if a value is a typed array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a typed array\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var bool = isTypedArray( new Int8Array( 10 ) );\n* // returns true\n*/\nfunction isTypedArray( value ) {\n\tvar v;\n\tvar i;\n\n\tif ( typeof value !== 'object' || value === null ) {\n\t\treturn false;\n\t}\n\t// Check for the abstract class...\n\tif ( value instanceof TypedArray ) {\n\t\treturn true;\n\t}\n\t// Check for typed array objects from the same realm (same Node.js `vm` or same `Window` object)...\n\tfor ( i = 0; i < CTORS.length; i++ ) {\n\t\tif ( value instanceof CTORS[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\t// Walk the prototype tree until we find an object having a desired class...\n\twhile ( value ) {\n\t\tv = ctorName( value );\n\t\tfor ( i = 0; i < NAMES.length; i++ ) {\n\t\t\tif ( NAMES[ i ] === v ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tvalue = getPrototypeOf( value );\n\t}\n\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64Array from '@stdlib/array/complex64';\nimport Complex128Array from '@stdlib/array/complex128';\n\n\n// MAIN //\n\nvar CTORS = [\n\tComplex128Array,\n\tComplex64Array\n];\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BooleanArray from '@stdlib/array/bool';\nimport constructorName from '@stdlib/utils/constructor-name';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a BooleanArray.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is a BooleanArray\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var bool = isBooleanArray( new BooleanArray( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isBooleanArray( [] );\n* // returns false\n*/\nfunction isBooleanArray( value ) {\n\treturn (\n\t\tvalue instanceof BooleanArray ||\n\t\tconstructorName( value ) === 'BooleanArray'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isBooleanArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Tests whether a value has in its prototype chain a specified constructor as a prototype property.\n*\n* @param {*} value - value to test\n* @param {Function} constructor - constructor to test against\n* @throws {TypeError} constructor must be callable\n* @returns {boolean} boolean indicating whether a value is an instance of a provided constructor\n*\n* @example\n* var bool = instanceOf( [], Array );\n* // returns true\n*\n* @example\n* var bool = instanceOf( {}, Object ); // exception\n* // returns true\n*\n* @example\n* var bool = instanceOf( 'beep', String );\n* // returns false\n*\n* @example\n* var bool = instanceOf( null, Object );\n* // returns false\n*\n* @example\n* var bool = instanceOf( 5, Object );\n* // returns false\n*/\nfunction instanceOf( value, constructor ) {\n\t// TODO: replace with `isCallable` check\n\tif ( typeof constructor !== 'function' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be callable. Value: `%s`.', constructor ) );\n\t}\n\treturn ( value instanceof constructor );\n}\n\n\n// EXPORTS //\n\nexport default instanceOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Int8Array from './../../int8';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Int16Array from './../../int16';\nimport Uint16Array from './../../uint16';\nimport Int32Array from './../../int32';\nimport Uint32Array from './../../uint32';\nimport Float32Array from './../../float32';\nimport Float64Array from './../../float64';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\nvar CTORS = [\n\t[ Float64Array, 'Float64Array' ],\n\t[ Float32Array, 'Float32Array' ],\n\t[ Int32Array, 'Int32Array' ],\n\t[ Uint32Array, 'Uint32Array' ],\n\t[ Int16Array, 'Int16Array' ],\n\t[ Uint16Array, 'Uint16Array' ],\n\t[ Int8Array, 'Int8Array' ],\n\t[ Uint8Array, 'Uint8Array' ],\n\t[ Uint8ClampedArray, 'Uint8ClampedArray' ],\n\t[ Complex64Array, 'Complex64Array' ],\n\t[ Complex128Array, 'Complex128Array' ],\n\t[ BooleanArray, 'BooleanArray' ]\n];\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport instanceOf from '@stdlib/assert/instance-of';\nimport ctorName from '@stdlib/utils/constructor-name';\nimport getPrototypeOf from '@stdlib/utils/get-prototype-of';\nimport CTORS from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns the typed array type.\n*\n* @private\n* @param {TypedArray} arr - typed array\n* @returns {(string|void)} typed array type\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( 5 );\n* var str = typeName( arr );\n* // returns 'Float64Array'\n*/\nfunction typeName( arr ) {\n\tvar v;\n\tvar i;\n\n\t// Check for typed array objects from the same realm (same Node.js `vm` or same `Window` object)...\n\tfor ( i = 0; i < CTORS.length; i++ ) {\n\t\tif ( instanceOf( arr, CTORS[ i ][ 0 ] ) ) {\n\t\t\treturn CTORS[ i ][ 1 ];\n\t\t}\n\t}\n\t// Walk the prototype tree until we find an object having a desired native class...\n\twhile ( arr ) {\n\t\tv = ctorName( arr );\n\t\tfor ( i = 0; i < CTORS.length; i++ ) {\n\t\t\tif ( v === CTORS[ i ][ 1 ] ) {\n\t\t\t\treturn CTORS[ i ][ 1 ];\n\t\t\t}\n\t\t}\n\t\tarr = getPrototypeOf( arr );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default typeName;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert/is-typed-array';\nimport isComplexTypedArray from '@stdlib/assert/is-complex-typed-array';\nimport isBooleanArray from '@stdlib/assert/is-booleanarray';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport format from '@stdlib/string/format';\nimport typeName from './type.js';\n\n\n// MAIN //\n\n/**\n* Returns a JSON representation of a typed array.\n*\n* ## Notes\n*\n* - We build a JSON object representing a typed array similar to how Node.js `Buffer` objects are represented. See [Buffer][1].\n*\n* [1]: https://nodejs.org/api/buffer.html#buffer_buf_tojson\n*\n* @param {TypedArray} arr - typed array to serialize\n* @throws {TypeError} first argument must be a typed array\n* @returns {Object} JSON representation\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( [ 5.0, 3.0 ] );\n* var json = typedarray2json( arr );\n* // returns { 'type': 'Float64Array', 'data': [ 5.0, 3.0 ] }\n*/\nfunction typedarray2json( arr ) {\n\tvar data;\n\tvar out;\n\tvar i;\n\n\tif ( isTypedArray( arr ) ) {\n\t\tdata = arr;\n\t} else if ( isComplexTypedArray( arr ) ) {\n\t\tif ( arr.BYTES_PER_ELEMENT === 8 ) {\n\t\t\tdata = reinterpret64( arr, 0 );\n\t\t} else { // arr.BYTES_PER_ELEMENT === 16\n\t\t\tdata = reinterpret128( arr, 0 );\n\t\t}\n\t} else if ( isBooleanArray( arr ) ) {\n\t\tdata = reinterpretBoolean( arr, 0 );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a typed array. Value: `%s`.', arr ) );\n\t}\n\tout = {\n\t\t'type': typeName( arr ),\n\t\t'data': []\n\t};\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tout.data.push( data[ i ] );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default typedarray2json;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctorName from '@stdlib/utils/constructor-name';\nimport getPrototypeOf from '@stdlib/utils/get-prototype-of';\nimport CTORS from './ctors.js';\nimport NAMES from './names.json';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a complex typed array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isComplexTypedArray( new Complex128Array( 10 ) );\n* // returns true\n*/\nfunction isComplexTypedArray( value ) {\n\tvar v;\n\tvar i;\n\n\tif ( typeof value !== 'object' || value === null ) {\n\t\treturn false;\n\t}\n\t// Check for complex typed array objects from the same realm (same Node.js `vm` or same `Window` object)...\n\tfor ( i = 0; i < CTORS.length; i++ ) {\n\t\tif ( value instanceof CTORS[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\t// Walk the prototype tree until we find an object having a desired class...\n\twhile ( value ) {\n\t\tv = ctorName( value );\n\t\tfor ( i = 0; i < NAMES.length; i++ ) {\n\t\t\tif ( NAMES[ i ] === v ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tvalue = getPrototypeOf( value );\n\t}\n\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isComplexTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from '@stdlib/utils/define-property';\n\n\n// MAIN //\n\n/**\n* List node constructor.\n*\n* @private\n* @constructor\n* @param {*} value - node value\n* @returns {Node} Node instance\n*\n* @example\n* var node = new Node( 'foo' );\n* // returns \n*/\nfunction Node( value ) { // eslint-disable-line stdlib/no-redeclare\n\t// Why a getter? Because some of the list APIs will return the list \"node\", not the value. In which case, the node API is no longer private and we have to guard against users mucking about (deleting, updating, etc) with property values (in particular, the `next` property).\n\tdefineProperty( this, 'next', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'get': function get() { // eslint-disable-line no-restricted-syntax\n\t\t\treturn this._next;\n\t\t}\n\t});\n\tthis.value = value;\n\n\tdefineProperty( this, '_next', {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'writable': true,\n\t\t'value': null\n\t});\n\n\t// NOTE: strictly speaking, we should not be keeping back-references in a singly-linked list; however, doing so allows us to more efficiently add, remove, and insert list values.\n\tdefineProperty( this, '_prev', {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'writable': true,\n\t\t'value': null\n\t});\n\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default Node;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport Node from './node.js'; // eslint-disable-line stdlib/no-redeclare\n\n\n// MAIN //\n\n/**\n* Linked list constructor.\n*\n* @constructor\n* @returns {LinkedList} linked list instance\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Remove the last value:\n* var v = list.pop();\n* // returns 'bar'\n*\n* // Add a new value to the list:\n* list.push( 'beep' );\n*\n* // Remove the first value:\n* v = list.shift();\n* // returns 'foo'\n*/\nfunction LinkedList() {\n\tif ( !(this instanceof LinkedList) ) {\n\t\treturn new LinkedList();\n\t}\n\tthis._length = 0;\n\tthis._first = null;\n\tthis._last = null;\n\treturn this;\n}\n\n/**\n* Clears the list.\n*\n* @name clear\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {LinkedList} list instance\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Peek at the first value:\n* var v = list.first().value;\n* // returns 'foo'\n*\n* // Examine the list length:\n* var len = list.length;\n* // returns 2\n*\n* // Clear all list items:\n* list.clear();\n*\n* // Peek at the first value:\n* v = list.first();\n* // returns undefined\n*\n* // Examine the list length:\n* len = list.length;\n* // returns 0\n*/\nsetReadOnly( LinkedList.prototype, 'clear', function clear() {\n\tthis._length = 0;\n\tthis._first = null;\n\tthis._last = null;\n\treturn this;\n});\n\n/**\n* Returns the first list node.\n*\n* @name first\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {(Node|void)} list node\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Peek at the first value:\n* var v = list.first().value;\n* // returns 'foo'\n*/\nsetReadOnly( LinkedList.prototype, 'first', function first() {\n\tif ( this._length ) {\n\t\treturn this._first;\n\t}\n});\n\n/**\n* Inserts a value into the list **after** a provided list node.\n*\n* @name insert\n* @memberof LinkedList.prototype\n* @type {Function}\n* @param {Node} node - node after which to insert the value\n* @param {*} value - value to insert\n* @throws {Error} must provide a node belonging to the list\n* @returns {LinkedList} list instance\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' ).push( 'beep' );\n*\n* // Determine the list length:\n* var len = list.length;\n* // returns 3\n*\n* // Get the second node:\n* var node = list.first().next;\n*\n* // Insert a value after the second node:\n* list.insert( node, 'boop' );\n*\n* // Determine the list length:\n* len = list.length;\n* // returns 4\n*/\nsetReadOnly( LinkedList.prototype, 'insert', function insert( node, value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar n;\n\n\t// Case: last node (equivalent to `push()`)\n\tif ( node === this._last ) {\n\t\treturn this.push( value );\n\t}\n\t// Unfortunately, we need to check whether we have been provided a node belonging to our list by walking the list. If we don't, we could erroneously increment the list length. This means our runtime goes from the theoretical O(1) to O(N).\n\tn = this._first;\n\twhile ( n !== this._last && n !== node ) {\n\t\tn = n._next;\n\t}\n\t// Check if we iterated through the entire list:\n\tif ( n === this._last ) {\n\t\tthrow new Error( 'invalid argument. The list does not contain the provided list node.' );\n\t}\n\t// Create a new list node:\n\tn = new Node( value );\n\n\t// Update pointers:\n\tnode._next._prev = n;\n\tn._next = node._next;\n\n\tnode._next = n;\n\tn._prev = node;\n\n\t// Increment the list length:\n\tthis._length += 1;\n\n\treturn this;\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Returns an iterator for iterating over a list.\n*\n* ## Notes\n*\n* - In order to prevent confusion arising from list mutation during iteration, a returned iterator **always** iterates over a list \"snapshot\", which is defined as the list of elements at the time of this method's invocation.\n*\n* @name iterator\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {Iterator} iterator\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Create an iterator:\n* var it = list.iterator();\n*\n* // Iterate over the list...\n* var v = it.next().value;\n* // returns 'foo'\n*\n* v = it.next().value;\n* // returns 'bar'\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( LinkedList.prototype, 'iterator', function iterator() {\n\tvar values;\n\tvar iter;\n\tvar self;\n\tvar FLG;\n\tvar i;\n\n\tself = this;\n\n\t// Initialize the iteration index:\n\ti = -1;\n\n\t// Create a copy of list values (necessary in order to \"snapshot\" the list; otherwise, values could come and go between calls to `next`):\n\tvalues = this.toArray();\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= values.length ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': values[ i ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.iterator();\n\t}\n});\n\n/**\n* Returns the last node.\n*\n* @name last\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {(Node|void)} list node\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Peek at the last value:\n* var v = list.last().value;\n* // returns 'bar'\n*/\nsetReadOnly( LinkedList.prototype, 'last', function last() {\n\tif ( this._length ) {\n\t\treturn this._last;\n\t}\n});\n\n/**\n* List length.\n*\n* @name length\n* @memberof LinkedList.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var list = new LinkedList();\n*\n* // Examine the initial list length:\n* var len = list.length;\n* // returns 0\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Retrieve the current list length:\n* len = list.length;\n* // returns 2\n*/\nsetReadOnlyAccessor( LinkedList.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Removes a value from the end of the list.\n*\n* @name pop\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {(*|void)} removed value\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Remove the last value:\n* var v = list.pop();\n* // returns 'bar'\n*\n* // Add a new value to the list:\n* list.push( 'beep' );\n*\n* // Remove the last value:\n* v = list.pop();\n* // returns 'beep'\n*/\nsetReadOnly( LinkedList.prototype, 'pop', function pop() {\n\t/* eslint-disable no-underscore-dangle */\n\tvar value;\n\tif ( this._length ) {\n\t\t// Retrieve the last value:\n\t\tvalue = this._last.value;\n\n\t\t// Check whether we have a new \"tail\" or whether we have emptied the list...\n\t\tif ( this._last._prev ) {\n\t\t\tthis._last = this._last._prev;\n\t\t\tthis._last._next = null;\n\t\t} else {\n\t\t\t// List is empty:\n\t\t\tthis._first = null;\n\t\t\tthis._last = null;\n\t\t}\n\t\t// Decrement the list length:\n\t\tthis._length -= 1;\n\t}\n\treturn value;\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Adds a value to the end of the list.\n*\n* @name push\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {LinkedList} list instance\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Remove the last value:\n* var v = list.pop();\n* // returns 'bar'\n*\n* // Add a new value to the list:\n* list.push( 'beep' );\n*\n* // Remove the last value:\n* v = list.pop();\n* // returns 'beep'\n*/\nsetReadOnly( LinkedList.prototype, 'push', function push( value ) {\n\tvar node;\n\n\t// Create a new list node:\n\tnode = new Node( value );\n\n\t// Check whether the list is currently empty...\n\tif ( this._length === 0 ) {\n\t\t// This is the only list node, making it both the first and last node:\n\t\tthis._first = node;\n\t\tthis._last = node;\n\t} else {\n\t\t// Link the new node to the previous last node:\n\t\tnode._prev = this._last; // eslint-disable-line no-underscore-dangle\n\n\t\t// Link the previous last node to the new node:\n\t\tthis._last._next = node; // eslint-disable-line no-underscore-dangle\n\n\t\t// Update the pointer for the last node:\n\t\tthis._last = node;\n\t}\n\t// Increment the list length:\n\tthis._length += 1;\n\n\treturn this;\n});\n\n/**\n* Removes a list node from the list.\n*\n* @name remove\n* @memberof LinkedList.prototype\n* @type {Function}\n* @param {Node} node - node to remove\n* @throws {Error} must provide a node belonging to the list\n* @returns {(*|void)} removed value\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' ).push( 'beep' );\n*\n* // Determine the list length:\n* var len = list.length;\n* // returns 3\n*\n* // Get the second node:\n* var node = list.first().next;\n*\n* // Remove the second node:\n* var v = list.remove( node );\n* // returns 'bar'\n*\n* // Determine the list length:\n* len = list.length;\n* // returns 2\n*/\nsetReadOnly( LinkedList.prototype, 'remove', function remove( node ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar value;\n\tvar n;\n\n\t// Case: first node (equivalent to `shift()`)\n\tif ( node === this._first ) {\n\t\treturn this.shift();\n\t}\n\t// Case: last node (equivalent to `pop()`)\n\tif ( node === this._last ) {\n\t\treturn this.pop();\n\t}\n\t// Retrieve the node value:\n\tvalue = node.value;\n\n\t// Unfortunately, we need to check whether we have been provided a node belonging to our list by walking the list. If we don't, we could erroneously decrement the list length. This means our runtime goes from the theoretical O(1) to O(N).\n\tn = this._first;\n\twhile ( n !== this._last && n !== node ) {\n\t\tn = n._next;\n\t}\n\t// Check if we iterated through the entire list:\n\tif ( n === this._last ) {\n\t\tthrow new Error( 'invalid argument. The list does not contain the provided list node.' );\n\t}\n\t// Update pointers:\n\tnode._prev._next = node._next;\n\tnode._next._prev = node._prev;\n\n\t// Decrement the list length:\n\tthis._length -= 1;\n\n\treturn value;\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Removes a value from the beginning of the list.\n*\n* @name shift\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {(*|void)} removed value\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Remove the first value:\n* var v = list.shift();\n* // returns 'foo'\n*\n* // Add a new value to the list:\n* list.push( 'beep' );\n*\n* // Remove the first value:\n* v = list.shift();\n* // returns 'bar'\n*/\nsetReadOnly( LinkedList.prototype, 'shift', function shift() {\n\t/* eslint-disable no-underscore-dangle */\n\tvar value;\n\tif ( this._length ) {\n\t\t// Retrieve the first value:\n\t\tvalue = this._first.value;\n\n\t\t// Check whether we have a new \"head\" or whether we have emptied the list...\n\t\tif ( this._first._next ) {\n\t\t\tthis._first = this._first._next;\n\t\t\tthis._first._prev = null;\n\t\t} else {\n\t\t\t// List is empty:\n\t\t\tthis._first = null;\n\t\t\tthis._last = null;\n\t\t}\n\t\t// Decrement the list length:\n\t\tthis._length -= 1;\n\t}\n\treturn value;\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Returns an array of list values.\n*\n* @name toArray\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {Array} list values\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Get an array of list values:\n* var vals = list.toArray();\n* // returns [ 'foo', 'bar' ]\n*/\nsetReadOnly( LinkedList.prototype, 'toArray', function toArray() {\n\tvar node;\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tnode = this._first;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( node.value );\n\t\tnode = node.next;\n\t}\n\treturn out;\n});\n\n/**\n* Serializes a list as JSON.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `LinkedList` instance.\n*\n* @name toJSON\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {Object} serialized list\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Serialize to JSON:\n* var o = list.toJSON();\n* // returns { 'type': 'linked-list', 'data': [ 'foo', 'bar' ] }\n*/\nsetReadOnly( LinkedList.prototype, 'toJSON', function toJSON() {\n\tvar out = {};\n\tout.type = 'linked-list';\n\tout.data = this.toArray();\n\treturn out;\n});\n\n/**\n* Adds a value to the beginning of the list.\n*\n* @name unshift\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {LinkedList} list instance\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the beginning of the list:\n* list.unshift( 'foo' ).unshift( 'bar' );\n*\n* // Remove the last value:\n* var v = list.pop();\n* // returns 'foo'\n*\n* // Add a new value to the beginning of the list:\n* list.unshift( 'beep' );\n*\n* // Remove the last value:\n* v = list.pop();\n* // returns 'bar'\n*/\nsetReadOnly( LinkedList.prototype, 'unshift', function unshift( value ) {\n\tvar node;\n\n\t// Create a new list node:\n\tnode = new Node( value );\n\n\t// Check whether the list is currently empty...\n\tif ( this._length === 0 ) {\n\t\t// This is the only list node, making it both the first and last node:\n\t\tthis._first = node;\n\t\tthis._last = node;\n\t} else {\n\t\t// Link the new node to the previous first node:\n\t\tnode._next = this._first; // eslint-disable-line no-underscore-dangle\n\n\t\t// Link the previous first node to the new node:\n\t\tthis._first._prev = node; // eslint-disable-line no-underscore-dangle\n\n\t\t// Update the pointer for the first node:\n\t\tthis._first = node;\n\t}\n\t// Increment the list length:\n\tthis._length += 1;\n\n\treturn this;\n});\n\n\n// EXPORTS //\n\nexport default LinkedList;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport LinkedList from '@stdlib/dstructs/linked-list';\n\n\n// MAIN //\n\n/**\n* Cache for storing index arrays.\n*\n* @private\n* @name cache\n* @type {LinkedList}\n*/\nvar cache = new LinkedList(); // note: created as a linked list to allow for more efficient removal of expired index arrays\n\n\n// EXPORTS //\n\nexport default cache;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport cache from './cache.js';\n\n\n// MAIN //\n\n/**\n* Returns an array index object associated with a specified identifier.\n*\n* @private\n* @param {*} id - identifier\n* @returns {(Node|null)} array index object\n*/\nfunction find( id ) { // eslint-disable-line stdlib/no-redeclare\n\tvar node = cache.first();\n\twhile ( node ) {\n\t\tif ( node.value.id === id ) {\n\t\t\treturn node;\n\t\t}\n\t\tnode = node.next;\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default find;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar COUNTER = -1; // TODO: consider another approach for unique identifier generation. For most cases, this should suffice; however, it is possible that two different libraries, both relying on separate copies of this package, may trigger id collisions in the event that instantiated instances were to interact (e.g., a consumer attempting to free an instance instantiated by another copy of the package, etc).\n\n\n// MAIN //\n\n/**\n* Generates a new identifier.\n*\n* @private\n* @returns {string} identifier\n*\n* @example\n* var v = id();\n* // returns \n*/\nfunction id() {\n\tCOUNTER += 1;\n\treturn COUNTER.toString();\n}\n\n\n// EXPORTS //\n\nexport default id;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setNonEnumerable from '@stdlib/utils/define-nonenumerable-property';\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport array2json from './../../to-json';\nimport dtype from './../../dtype';\nimport copy from './../../base/copy';\nimport resolveGetter from './../../base/resolve-getter';\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\nimport cache from './cache.js';\nimport findArrayIndex from './find.js';\nimport generateId from './id.js';\n\n\n// MAIN //\n\n/**\n* Array index constructor.\n*\n* @constructor\n* @param {Collection} x - input array\n* @param {Options} [options] - function options\n* @param {boolean} [options.persist=false] - boolean indicating whether to continue persisting an index object after first usage\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} first argument must be a valid index array\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayIndex} ArrayIndex instance\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var x = new Uint8Array( [ 1, 0, 1, 0 ] );\n*\n* var idx = new ArrayIndex( x );\n* // returns \n*/\nfunction ArrayIndex( x ) {\n\tvar opts;\n\tvar err;\n\tvar get;\n\tvar dt;\n\tvar t;\n\tvar v;\n\tif ( !(this instanceof ArrayIndex) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new ArrayIndex( x, arguments[ 1 ] );\n\t\t}\n\t\treturn new ArrayIndex( x );\n\t}\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tdt = dtype( x );\n\n\t// When provided a \"generic\" array or an array of an unknown data type, attempt to infer the type of index array...\n\tif ( dt === 'generic' || dt === null ) {\n\t\tif ( x.length > 0 ) {\n\t\t\tget = resolveGetter( x );\n\t\t\tv = get( x, 0 );\n\n\t\t\t// Infer the \"type\" of index array from the first element...\n\t\t\tif ( isBoolean( v ) ) {\n\t\t\t\tt = 'bool';\n\t\t\t} else if ( isInteger( v ) ) {\n\t\t\t\tt = 'int';\n\t\t\t} else {\n\t\t\t\tthrow new TypeError( 'invalid argument. First argument must be a valid index array.' );\n\t\t\t}\n\t\t} else {\n\t\t\tt = 'int';\n\t\t}\n\t} else if ( dt === 'int32' ) {\n\t\tt = 'int';\n\t} else if ( dt === 'uint8' ) {\n\t\tt = 'mask';\n\t} else if ( dt === 'bool' ) {\n\t\tt = 'bool';\n\t} else {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a valid index array.' );\n\t}\n\t// Resolve index options:\n\topts = defaults();\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, arguments[ 1 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Add the array index to the index cache:\n\tcache.push({\n\t\t'id': generateId(),\n\t\t'ref': this,\n\t\t'data': x,\n\t\t'type': t,\n\t\t'dtype': dt,\n\t\t'persist': opts.persist\n\t});\n\n\t// Store a reference to the cache node:\n\tsetReadOnly( this, '_node', cache.last() );\n\n\t// Initialize a boolean flag indicating whether an array index object has been invalidated (i.e., freed):\n\tsetNonEnumerable( this, '_invalidated', false );\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ArrayIndex\n* @readonly\n* @type {string}\n* @default 'ArrayIndex'\n*\n* @example\n* var str = ArrayIndex.name;\n* // returns 'ArrayIndex'\n*/\nsetReadOnly( ArrayIndex, 'name', 'ArrayIndex' );\n\n/**\n* Frees an array index object associated with a provided identifier.\n*\n* @name free\n* @memberof ArrayIndex\n* @type {Function}\n* @param {string} id - identifier\n* @returns {boolean} boolean indicating whether an array index object was successfully freed\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), {\n* 'persist': true\n* });\n* // returns \n*\n* // ...\n*\n* var out = ArrayIndex.free( idx.id );\n* // returns true\n*/\nsetReadOnly( ArrayIndex, 'free', function free( id ) {\n\tvar node;\n\tvar v;\n\n\t// Retrieve the array index object with the specified identifier:\n\tnode = findArrayIndex( id );\n\tif ( node === null ) {\n\t\treturn false;\n\t}\n\tv = node.value;\n\n\t// Invalidate the array instance object:\n\tsetReadOnly( v.ref, '_invalidated', true );\n\n\t// Remove the array instance from the cache:\n\tcache.remove( node );\n\n\t// Remove the reference to the original array:\n\tv.data = null;\n\n\treturn true;\n});\n\n/**\n* Returns the array associated with a provided identifier.\n*\n* @name get\n* @memberof ArrayIndex\n* @type {Function}\n* @param {string} id - identifier\n* @returns {(Object|null)} object containing array index data\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), {\n* 'persist': true\n* });\n* // returns \n*\n* // ...\n*\n* var o = ArrayIndex.get( idx.id );\n* // returns {...}\n*\n* var d = o.data;\n* // returns [ 1, 0, 1, 0 ]\n*\n* var t = o.type;\n* // returns 'mask'\n*\n* var dt = o.dtype;\n* // returns 'uint8'\n*/\nsetReadOnly( ArrayIndex, 'get', function get( id ) {\n\tvar node;\n\tvar out;\n\tvar v;\n\n\t// Retrieve the array index object with the specified identifier:\n\tnode = findArrayIndex( id );\n\tif ( node === null ) {\n\t\treturn null;\n\t}\n\tv = node.value;\n\n\t// Assemble the output object:\n\tout = {\n\t\t'data': v.data,\n\t\t'type': v.type,\n\t\t'dtype': v.dtype\n\t};\n\n\t// If the array index object should not be persisted, go ahead and remove the object from the cache...\n\tif ( !v.persist ) {\n\t\tArrayIndex.free( id ); // note: this should come last, after having retrieved all desired array index node data\n\t}\n\treturn out;\n});\n\n/**\n* Returns the underlying array data of an array index object.\n*\n* @name data\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {Collection}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var v = idx.data;\n* // returns [ 1, 0, 1, 0 ]\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'data', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.data;\n});\n\n/**\n* Returns the underlying array data type of an array index object.\n*\n* @name dtype\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var t = idx.dtype;\n* // returns 'uint8'\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'dtype', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.dtype;\n});\n\n/**\n* Returns the identifier associated with an array index object.\n*\n* @name id\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var id = idx.id;\n* // returns \n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'id', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.id;\n});\n\n/**\n* Returns a boolean indicating if an array index is actively cached.\n*\n* @name isCached\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {boolean}\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var out = idx.isCached;\n* // returns true\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'isCached', function get() {\n\treturn !this._invalidated;\n});\n\n/**\n* Returns the type of an array index object.\n*\n* @name type\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var t = idx.type;\n* // returns 'mask'\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'type', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.type;\n});\n\n/**\n* Serializes an array index object to a string.\n*\n* @name toString\n* @memberof ArrayIndex.prototype\n* @type {Function}\n* @throws {Error} array index is no longer valid\n* @returns {string} serialized array index object\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var str = idx.toString();\n* // e.g., 'ArrayIndex<0>'\n*/\nsetReadOnly( ArrayIndex.prototype, 'toString', function toString() {\n\tvar v;\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\tv = this._node.value;\n\treturn 'ArrayIndex<' + v.id + '>';\n});\n\n/**\n* Serializes an array index object as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ArrayIndex` instance.\n*\n* @name toJSON\n* @memberof ArrayIndex.prototype\n* @type {Function}\n* @throws {Error} array index is no longer valid\n* @returns {Object} serialized array index object\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var o = idx.toJSON();\n* // returns { 'type': 'ArrayIndex', 'data': { 'type': 'Uint8Array', 'data': [ 1, 0, 1, 0 ] } }\n*/\nsetReadOnly( ArrayIndex.prototype, 'toJSON', function toJSON() {\n\tvar v;\n\tvar o;\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\tv = this._node.value;\n\tif ( v.dtype === 'generic' || v.dtype === null ) {\n\t\tif ( isAccessorArray( v.data ) ) {\n\t\t\to = copy( v.data );\n\t\t} else {\n\t\t\to = v.data;\n\t\t}\n\t} else {\n\t\to = array2json( v.data );\n\t}\n\treturn {\n\t\t'type': 'ArrayIndex',\n\t\t'data': o\n\t};\n});\n\n\n// EXPORTS //\n\nexport default ArrayIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} defaults\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'persist': false\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {boolean} [options.persist] - boolean indicating whether to continue persisting an index object after first usage\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'persist': false\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'persist' ) ) {\n\t\topts.persist = options.persist;\n\t\tif ( !isBoolean( opts.persist ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'persist', opts.persist ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Complex128Array from './../../complex128';\nimport Complex64Array from './../../complex64';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'float64': Float64Array,\n\t'float32': Float32Array,\n\t'complex128': Complex128Array,\n\t'complex64': Complex64Array\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a floating-point typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array.\n*\n* @private\n* @param {TypedArray} out - output array\n* @param {number} start - start of interval\n* @param {number} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {TypedArray} linearly spaced array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var out = new Float64Array( 6 );\n* var arr = linspace( out, 0, 100, out.length, true );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var out = new Float64Array( 5 );\n* var arr = linspace( out, 0, 100, out.length, false );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*/\nfunction linspace( out, start, stop, len, endpoint ) {\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tout[ 0 ] = stop;\n\t\t} else {\n\t\t\tout[ 0 ] = start;\n\t\t}\n\t\treturn out;\n\t}\n\tout[ 0 ] = start;\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tout[ i ] = start + (d*i);\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tout[ N ] = stop;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number sequence over a specified interval and assigns the results to a provided output array strided view.\n*\n* @private\n* @param {(Float32Array|Float64Array)} out - output array strided view\n* @param {string} dt1 - start value data type\n* @param {(number|ComplexLike)} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {(Float32Array|Float64Array)} complex number array view\n*/\nfunction linspace( out, dt1, start, dt2, stop, len, endpoint ) {\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tout[ 0 ] = re2;\n\t\t\tout[ 1 ] = im2;\n\t\t} else {\n\t\t\tout[ 0 ] = re1;\n\t\t\tout[ 1 ] = im1;\n\t\t}\n\t\treturn out;\n\t}\n\tout[ 0 ] = re1;\n\tout[ 1 ] = im1;\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate linearly spaced complex numbers:\n\tj = 2;\n\tfor ( i = 1; i < N; i++ ) {\n\t\tout[ j ] = re1 + (dr*i);\n\t\tout[ j+1 ] = im1 + (di*i);\n\t\tj += 2;\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tout[ j ] = re2;\n\t\tout[ j+1 ] = im2;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.dtype] - output array data type\n* @param {boolean} [options.endpoint] - boolean indicating whether the `stop` value in the output array\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'endpoint': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\topts.dtype = options.dtype;\n\t\tif ( !isString( opts.dtype ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'dtype', opts.dtype ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'endpoint' ) ) {\n\t\topts.endpoint = options.endpoint;\n\t\tif ( !isBoolean( opts.endpoint ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'endpoint', opts.endpoint ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport dtype from '@stdlib/complex/dtype';\nimport ctors from './../../typed-float-ctors';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport DEFAULTS from './../../defaults';\nimport format from '@stdlib/string/format';\nimport genreal from './generic_real.js';\nimport gencmplx from './generic_complex.js';\nimport typedreal from './typed_real.js';\nimport typedcmplx from './typed_complex.js';\nimport validate from './validate.js';\nimport defaults from './defaults.json';\n\n\n// VARIABLES //\n\nvar DEFAULT_COMPLEX_DTYPE = DEFAULTS.get( 'dtypes.complex_floating_point' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced array over a specified interval.\n*\n* @param {(number|ComplexLike)} start - start of interval\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {Options} [options] - options\n* @param {string} [options.dtype] - output array data type\n* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array\n* @throws {TypeError} first argument must be either a real or complex number\n* @throws {TypeError} second argument must be either a real or complex number\n* @throws {TypeError} third argument must be a nonnegative integer\n* @throws {TypeError} last argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} the output array data type must be a complex number data type or \"generic\" when either `start` or `stop` is a complex number\n* @throws {TypeError} the output array data type must be a real or complex floating-point number data type or \"generic\"\n* @returns {(Array|TypedArray|ComplexArray)} linearly spaced array\n*\n* @example\n* var arr = linspace( 0, 100, 6, {\n* 'dtype': 'generic'\n* });\n* // returns [ 0, 20, 40, 60, 80, 100 ]\n*/\nfunction linspace( start, stop, len ) {\n\tvar opts;\n\tvar ctor;\n\tvar err;\n\tvar out;\n\tvar dt1;\n\tvar dt2;\n\tvar flg;\n\n\tif ( typeof start === 'object' ) {\n\t\tdt1 = dtype( start );\n\t\tif ( dt1 === null ) {\n\t\t\tif ( !isComplexLike( start ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t\t\t}\n\t\t\tdt1 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( start ) || isnan( start ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t} else {\n\t\tdt1 = 'float64';\n\t}\n\tif ( typeof stop === 'object' ) {\n\t\tdt2 = dtype( stop );\n\t\tif ( dt2 === null ) {\n\t\t\tif ( !isComplexLike( stop ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t\t\t}\n\t\t\tdt2 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( stop ) || isnan( stop ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t} else {\n\t\tdt2 = 'float64';\n\t}\n\tif ( !isNonNegativeInteger( len ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%s`.', len ) );\n\t}\n\topts = {\n\t\t'endpoint': defaults.endpoint\n\t};\n\tif ( dt1 === dt2 ) {\n\t\topts.dtype = dt1; // one of 'float64' || 'complex64' || 'complex128'\n\t} else {\n\t\t// If dtypes are different, then at least one is a complex number. According to type promotion rules, for all possible dtype permutations, the default output data type should be 'complex128'...\n\t\topts.dtype = DEFAULT_COMPLEX_DTYPE;\n\t}\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dtype === 'generic' ) {\n\t\tif ( flg ) {\n\t\t\treturn gencmplx( dt1, start, dt2, stop, len, opts.endpoint );\n\t\t}\n\t\treturn genreal( start, stop, len, opts.endpoint );\n\t}\n\tctor = ctors( opts.dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a real or complex floating-point data type or \"generic\". Option: `%s`.', 'dtype', opts.dtype ) );\n\t}\n\tout = new ctor( len );\n\tif ( opts.dtype === 'complex64' ) {\n\t\ttypedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( opts.dtype === 'complex128' ) {\n\t\ttypedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( flg ) {\n\t\tthrow new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array data type must be a complex number data type or \"generic\".' );\n\t}\n\treturn typedreal( out, start, stop, len, opts.endpoint );\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number array over a specified interval.\n*\n* @private\n* @param {string} dt1 - start value data type\n* @param {(number|ComplexLike)} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Array} linearly spaced array\n*/\nfunction linspace( dt1, start, dt2, stop, len, endpoint ) {\n\tvar cmplx;\n\tvar isf32;\n\tvar arr;\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar re;\n\tvar im;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\tisf32 = 0;\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Determine which complex number constructor to use according to type promotion rules:\n\tif ( isf32 === 2 ) {\n\t\tcmplx = Complex64;\n\t} else {\n\t\tcmplx = Complex128;\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\treturn [ new cmplx( re2, im2 ) ];\n\t\t}\n\t\treturn [ new cmplx( re1, im1 ) ];\n\t}\n\tarr = [ new cmplx( re1, im1 ) ];\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tre = re1 + (dr*i);\n\t\tim = im1 + (di*i);\n\t\tarr.push( new cmplx( re, im ) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tarr.push( new cmplx( re2, im2 ) );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced array over a specified interval.\n*\n* @private\n* @param {number} start - start of interval\n* @param {number} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Array} linearly spaced array\n*\n* @example\n* var arr = linspace( 0, 100, 6, true );\n* // returns [ 0, 20, 40, 60, 80, 100 ]\n*\n* @example\n* var arr = linspace( 0, 100, 5, false );\n* // returns [ 0, 20, 40, 60, 80 ]\n*/\nfunction linspace( start, stop, len, endpoint ) {\n\tvar arr;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\treturn [ stop ];\n\t\t}\n\t\treturn [ start ];\n\t}\n\tarr = [ start ];\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tarr.push( start + (d*i) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tarr.push( stop );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Tests that a value is a valid constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var ctor = function ctor() {};\n*\n* var err = validate( ctor );\n* // returns null\n*\n* err = validate( null );\n* // returns \n*/\nfunction validate( value ) {\n\tvar type = typeof value;\n\tif (\n\t\tvalue === null ||\n\t\t(type !== 'object' && type !== 'function')\n\t) {\n\t\treturn new TypeError( format( 'invalid argument. A provided constructor must be either an object (except null) or a function. Value: `%s`.', value ) );\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Generate a linearly spaced array.\n*\n* @module @stdlib/array/linspace\n*\n* @example\n* import linspace from '@stdlib/array/linspace';\n*\n* var arr = linspace( 0, 100, 6 );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* @example\n* import linspace from '@stdlib/array/linspace';\n*\n* var arr = linspace( 0, 100, 5, {\n* 'endpoint': false\n* });\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import linspace from '@stdlib/array/linspace';\n*\n* var arr = new Float64Array( 6 );\n* var out = linspace.assign( 0, 100, out );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import linspace from '@stdlib/array/linspace';\n*\n* var arr = new Float64Array( 5 );\n* var out = linspace.assign( 0, 100, out, {\n* 'endpoint': false\n* });\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport isCollection from '@stdlib/assert/is-collection';\nimport format from '@stdlib/string/format';\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport dtype from '@stdlib/complex/dtype';\nimport adtype from './../../dtype';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport arraylike2object from './../../base/arraylike2object';\nimport acccmplx from './accessors_complex.js';\nimport accreal from './accessors_real.js';\nimport typedcmplx from './typed_complex.js';\nimport typedreal from './typed_real.js';\nimport validate from './validate.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array.\n*\n* @param {(number|ComplexLike)} start - start of interval\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {Collection} out - output array\n* @param {Options} [options] - options\n* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array\n* @throws {TypeError} first argument must be either a real or complex number\n* @throws {TypeError} second argument must be either a real or complex number\n* @throws {TypeError} third argument must be an array-like object\n* @throws {TypeError} last argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} the output array data type must be a complex number data type or \"generic\" when either `start` or `stop` is a complex number\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var out = new Float64Array( 6 );\n* var arr = linspace( 0, 100, out );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*/\nfunction linspace( start, stop, out ) {\n\tvar opts;\n\tvar err;\n\tvar dt1;\n\tvar dt2;\n\tvar flg;\n\tvar odt;\n\tvar o;\n\n\tif ( typeof start === 'object' ) {\n\t\tdt1 = dtype( start );\n\t\tif ( dt1 === null ) {\n\t\t\tif ( !isComplexLike( start ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t\t\t}\n\t\t\tdt1 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( start ) || isnan( start ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t} else {\n\t\tdt1 = 'float64';\n\t}\n\tif ( typeof stop === 'object' ) {\n\t\tdt2 = dtype( stop );\n\t\tif ( dt2 === null ) {\n\t\t\tif ( !isComplexLike( stop ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t\t\t}\n\t\t\tdt2 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( stop ) || isnan( stop ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t} else {\n\t\tdt2 = 'float64';\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\topts = {\n\t\t'endpoint': defaults.endpoint\n\t};\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\todt = adtype( out );\n\tif ( odt === null ) {\n\t\todt = 'generic';\n\t}\n\tif ( odt === 'complex64' ) {\n\t\ttypedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( odt === 'complex128' ) {\n\t\ttypedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( flg ) {\n\t\tif ( odt === 'generic' ) {\n\t\t\to = arraylike2object( out );\n\t\t\tacccmplx( o, dt1, start, dt2, stop, out.length, opts.endpoint );\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array must be a complex number array or a \"generic\" array-like object.' );\n\t}\n\to = arraylike2object( out );\n\tif ( o.accessorProtocol ) {\n\t\taccreal( o, start, stop, out.length, opts.endpoint );\n\t\treturn out;\n\t}\n\ttypedreal( out, start, stop, out.length, opts.endpoint );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number sequence over a specified interval and assigns results to a provided output array.\n*\n* @private\n* @param {Object} out - output array object\n* @param {ArrayLikeObject} out.data - output array data\n* @param {Array} out.accessors - array element accessors\n* @param {string} dt1 - start value data type\n* @param {ComplexLike} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {ComplexLike} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Object} output array object\n*/\nfunction linspace( out, dt1, start, dt2, stop, len, endpoint ) {\n\tvar cmplx;\n\tvar isf32;\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar set;\n\tvar buf;\n\tvar re;\n\tvar im;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tisf32 = 0;\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Determine which complex number constructor to use according to type promotion rules:\n\tif ( isf32 === 2 ) {\n\t\tcmplx = Complex64;\n\t} else {\n\t\tcmplx = Complex128;\n\t}\n\t// Cache array object references:\n\tbuf = out.data;\n\tset = out.accessors[ 1 ];\n\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tset( buf, 0, new cmplx( re2, im2 ) );\n\t\t} else {\n\t\t\tset( buf, 0, new cmplx( re1, im1 ) );\n\t\t}\n\t\treturn out;\n\t}\n\tset( buf, 0, new cmplx( re1, im1 ) );\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate the linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tre = re1 + (dr*i);\n\t\tim = im1 + (di*i);\n\t\tset( buf, i, new cmplx( re, im ) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tset( buf, N, new cmplx( re2, im2 ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array.\n*\n* @private\n* @param {Object} out - output array object\n* @param {ArrayLikeObject} out.data - output array data\n* @param {Array} out.accessors - array element accessors\n* @param {number} start - start of interval\n* @param {number} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Object} output array object\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function set( buf, i, v ) {\n* buf[ i ] = v * 2.0;\n* }\n*\n* var out = new Float64Array( 6 );\n* var obj = {\n* 'data': out,\n* 'accessors': [ null, set ]\n* };\n* linspace( obj, 0, 100, out.length, true );\n*\n* var arr = obj.data;\n* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0, 200.0 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function set( buf, i, v ) {\n* buf[ i ] = v * 2.0;\n* }\n*\n* var out = new Float64Array( 5 );\n* var obj = {\n* 'data': out,\n* 'accessors': [ null, set ]\n* };\n* linspace( obj, 0, 100, out.length, false );\n*\n* var arr = obj.data;\n* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0 ]\n*/\nfunction linspace( out, start, stop, len, endpoint ) {\n\tvar buf;\n\tvar set;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\t// Cache array object references:\n\tbuf = out.data;\n\tset = out.accessors[ 1 ];\n\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tset( buf, 0, stop );\n\t\t} else {\n\t\t\tset( buf, 0, start );\n\t\t}\n\t\treturn out;\n\t}\n\tset( buf, 0, start );\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tset( buf, i, start + (d*i) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tset( buf, N, stop );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// EXPORTS //\n\nexport default Object.create;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Dummy constructor.\n*\n* @private\n*/\nfunction Ctor() {\n\t// Empty...\n}\n\n\n// MAIN //\n\n/**\n* An `Object.create` shim for older JavaScript engines.\n*\n* @private\n* @param {Object} proto - prototype\n* @returns {Object} created object\n*\n* @example\n* var obj = createObject( Object.prototype );\n* // returns {}\n*/\nfunction createObject( proto ) {\n\tCtor.prototype = proto;\n\treturn new Ctor();\n}\n\n\n// EXPORTS //\n\nexport default createObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport builtin from './native.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar createObject;\nif ( typeof builtin === 'function' ) {\n\tcreateObject = builtin;\n} else {\n\tcreateObject = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default createObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len, no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport inherits from '@stdlib/utils/inherit';\nimport fixedEndianFactory from './../../fixed-endian-factory';\nimport bytesPerElement from '@stdlib/ndarray/base/bytes-per-element';\nimport capitalize from '@stdlib/string/base/capitalize';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar BYTE_ORDER = 'little-endian';\nvar DTYPE2SET = {\n\t'float64': 'setFloat64',\n\t'float32': 'setFloat32',\n\t'int32': 'setInt32',\n\t'int16': 'setInt16',\n\t'uint32': 'setUint32',\n\t'uint16': 'setUint16'\n};\nvar CHAR2ARTICLE = {\n\t'c': 'a',\n\t'f': 'a',\n\t'i': 'an',\n\t'u': 'a',\n\t'b': 'a'\n};\n\n\n// FUNCTIONS //\n\n/**\n* Converts a data type string to a constructor name.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {string} constructor name\n*\n* @example\n* var n = dtype2ctor( 'float64' );\n* // returns 'Float64ArrayLE'\n*\n* @example\n* var n = dtype2ctor( 'int32' );\n* // returns 'Int32ArrayLE'\n*/\nfunction dtype2ctor( dtype ) {\n\treturn capitalize( dtype ) + 'ArrayLE';\n}\n\n\n// MAIN //\n\n/**\n* Returns a typed array constructor for creating typed arrays stored in little-endian byte order.\n*\n* @param {string} dtype - typed array data type\n* @throws {TypeError} first argument must be a supported data type\n* @returns {Function} typed array constructor\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\nimport format from '@stdlib/string/format';\nimport validate from './validate.js';\nimport createObject from './detect.js';\n\n\n// MAIN //\n\n/**\n* Implements prototypical inheritance by replacing the prototype of one constructor with the prototype of another constructor.\n*\n* ## Notes\n*\n* - This implementation is not designed to work with ES2015/ES6 classes. For ES2015/ES6 classes, use `class` with `extends`.\n* - For reference, see [node#3455](https://github.com/nodejs/node/pull/3455), [node#4179](https://github.com/nodejs/node/issues/4179), [node#3452](https://github.com/nodejs/node/issues/3452), and [node commit](https://github.com/nodejs/node/commit/29da8cf8d7ab8f66b9091ab22664067d4468461e#diff-3deb3f32958bb937ae05c6f3e4abbdf5).\n*\n* @param {(Object|Function)} ctor - constructor which will inherit\n* @param {(Object|Function)} superCtor - super (parent) constructor\n* @throws {TypeError} first argument must be either an object or a function which can inherit\n* @throws {TypeError} second argument must be either an object or a function from which a constructor can inherit\n* @throws {TypeError} second argument must have an inheritable prototype\n* @returns {(Object|Function)} child constructor\n*\n* @example\n* function Foo() {\n* return this;\n* }\n* Foo.prototype.beep = function beep() {\n* return 'boop';\n* };\n*\n* function Bar() {\n* Foo.call( this );\n* return this;\n* }\n* inherit( Bar, Foo );\n*\n* var bar = new Bar();\n* var v = bar.beep();\n* // returns 'boop'\n*/\nfunction inherit( ctor, superCtor ) {\n\tvar err = validate( ctor );\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\terr = validate( superCtor );\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( typeof superCtor.prototype === 'undefined' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must have a prototype from which another object can inherit. Value: `%s`.', superCtor.prototype ) );\n\t}\n\t// Create a prototype which inherits from the parent prototype:\n\tctor.prototype = createObject( superCtor.prototype );\n\n\t// Set the constructor to refer to the child constructor:\n\tdefineProperty( ctor.prototype, 'constructor', {\n\t\t'configurable': true,\n\t\t'enumerable': false,\n\t\t'writable': true,\n\t\t'value': ctor\n\t});\n\n\treturn ctor;\n}\n\n\n// EXPORTS //\n\nexport default inherit;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './../../little-endian-factory';\n\n\n// MAIN //\n\n/**\n* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in little-endian byte order.\n*\n* @name Float32ArrayLE\n* @constructor\n* @type {Function}\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float32ArrayLE} typed array instance\n*\n* @example\n* var arr = new Float32ArrayLE();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float32ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Float32ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 8 );\n* var arr = new Float32ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 8 );\n* var arr = new Float32ArrayLE( buf, 4 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float32ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nvar Float32ArrayLE = factory( 'float32' );\n\n\n// EXPORTS //\n\nexport default Float32ArrayLE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './../../little-endian-factory';\n\n\n// MAIN //\n\n/**\n* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in little-endian byte order.\n*\n* @name Float64ArrayLE\n* @constructor\n* @type {Function}\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float64ArrayLE} typed array instance\n*\n* @example\n* var arr = new Float64ArrayLE();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nvar Float64ArrayLE = factory( 'float64' );\n\n\n// EXPORTS //\n\nexport default Float64ArrayLE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport NINF from '@stdlib/constants/float64/ninf';\n\n\n// MAIN //\n\n/**\n* Tests if a double-precision floating-point numeric value is negative zero.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is negative zero\n*\n* @example\n* var bool = isNegativeZero( -0.0 );\n* // returns true\n*\n* @example\n* var bool = isNegativeZero( 0.0 );\n* // returns false\n*/\nfunction isNegativeZero( x ) {\n\treturn (x === 0.0 && 1.0/x === NINF);\n}\n\n\n// EXPORTS //\n\nexport default isNegativeZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Smallest positive single-precision floating-point subnormal number.\n*\n* @module @stdlib/constants/float32/smallest-subnormal\n* @type {number}\n*\n* @example\n* import FLOAT32_SMALLEST_SUBNORMAL from '@stdlib/constants/float32/smallest-subnormal';\n* // returns 1.401298464324817e-45\n*/\n\n\n// MAIN //\n\n/**\n* Smallest positive single-precision floating-point subnormal number.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* \\frac{1}{2^{127-1} 2^{23}}\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 0 00000000 00000000000000000000001\n* ```\n*\n* @constant\n* @type {number}\n* @default 1.401298464324817e-45\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT32_SMALLEST_SUBNORMAL = 1.401298464324817e-45;\n\n\n// EXPORTS //\n\nexport default FLOAT32_SMALLEST_SUBNORMAL;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum safe single-precision floating-point integer.\n*\n* @module @stdlib/constants/float32/max-safe-integer\n* @type {number}\n*\n* @example\n* import FLOAT32_MAX_SAFE_INTEGER from '@stdlib/constants/float32/max-safe-integer';\n* // returns 16777215\n*/\n\n\n// MAIN //\n\n/**\n* Maximum safe single-precision floating-point integer.\n*\n* ## Notes\n*\n* The maximum safe integer is given by\n*\n* ```tex\n* 2^{24} - 1\n* ```\n*\n* @constant\n* @type {number}\n* @default 16777215\n* @see [Safe Integers]{@link http://www.2ality.com/2013/10/safe-integers.html}\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT32_MAX_SAFE_INTEGER = 16777215;\n\n\n// EXPORTS //\n\nexport default FLOAT32_MAX_SAFE_INTEGER;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Minimum safe single-precision floating-point integer.\n*\n* @module @stdlib/constants/float32/min-safe-integer\n* @type {number}\n*\n* @example\n* import FLOAT32_MIN_SAFE_INTEGER from '@stdlib/constants/float32/min-safe-integer';\n* // returns -16777215\n*/\n\n\n// MAIN //\n\n/**\n* Minimum safe single-precision floating-point integer.\n*\n* ## Notes\n*\n* The minimum safe integer is given by\n*\n* ```tex\n* -(2^{24} - 1)\n* ```\n*\n* @constant\n* @type {number}\n* @default -16777215\n* @see [Safe Integers]{@link http://www.2ality.com/2013/10/safe-integers.html}\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT32_MIN_SAFE_INTEGER = -16777215;\n\n\n// EXPORTS //\n\nexport default FLOAT32_MIN_SAFE_INTEGER;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport isNegativeZero from '@stdlib/math/base/assert/is-negative-zero';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport PINF from '@stdlib/constants/float64/pinf';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport FLOAT32_SMALLEST_SUBNORMAL from '@stdlib/constants/float32/smallest-subnormal'; // eslint-disable-line id-length\nimport FLOAT32_MAX_SAFE_INTEGER from '@stdlib/constants/float32/max-safe-integer';\nimport FLOAT32_MIN_SAFE_INTEGER from '@stdlib/constants/float32/min-safe-integer';\nimport INT8_MIN from '@stdlib/constants/int8/min';\nimport INT16_MIN from '@stdlib/constants/int16/min';\nimport INT32_MIN from '@stdlib/constants/int32/min';\nimport UINT8_MAX from '@stdlib/constants/uint8/max';\nimport UINT16_MAX from '@stdlib/constants/uint16/max';\nimport UINT32_MAX from '@stdlib/constants/uint32/max';\n\n\n// FUNCTIONS //\n\n/**\n* Returns the minimum floating-point array data type of the closest \"kind\" necessary for storing a provided scalar.\n*\n* @private\n* @param {number} value - real value\n* @returns {string} array data type\n*/\nfunction minFloatDataType( value ) {\n\tif ( value !== value || value === PINF || value === NINF ) {\n\t\treturn 'float32';\n\t}\n\tif ( isInteger( value ) ) {\n\t\tif ( value >= FLOAT32_MIN_SAFE_INTEGER && value <= FLOAT32_MAX_SAFE_INTEGER ) { // eslint-disable-line max-len\n\t\t\treturn 'float32';\n\t\t}\n\t\treturn 'float64';\n\t}\n\t// Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float32`...\n\tif (\n\t\tvalue > -FLOAT32_SMALLEST_SUBNORMAL &&\n\t\tvalue < FLOAT32_SMALLEST_SUBNORMAL\n\t) {\n\t\treturn 'float64';\n\t}\n\t// Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)...\n\treturn 'float32';\n}\n\n\n// MAIN //\n\n/**\n* Returns the minimum array data type of the closest \"kind\" necessary for storing a provided scalar value.\n*\n* @param {*} value - scalar value\n* @returns {string} array data type\n*\n* @example\n* var dt = minDataType( 3.141592653589793 );\n* // returns 'float32'\n*\n* @example\n* var dt = minDataType( 3 );\n* // returns 'uint8'\n*/\nfunction minDataType( value ) {\n\tif ( !isNumber( value ) ) {\n\t\tif ( isBoolean( value ) ) {\n\t\t\treturn 'bool';\n\t\t}\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tif ( minFloatDataType( value.re ) === 'float64' || minFloatDataType( value.im ) === 'float64' ) {\n\t\t\t\treturn 'complex128';\n\t\t\t}\n\t\t\treturn 'complex64';\n\t\t}\n\t\treturn 'generic';\n\t}\n\tif ( value !== value || value === PINF || value === NINF ) {\n\t\treturn 'float32';\n\t}\n\tif ( isInteger( value ) ) {\n\t\tif ( value === 0 && isNegativeZero( value ) ) {\n\t\t\treturn 'float32';\n\t\t}\n\t\tif ( value < 0 ) {\n\t\t\tif ( value >= INT8_MIN ) {\n\t\t\t\treturn 'int8';\n\t\t\t}\n\t\t\tif ( value >= INT16_MIN ) {\n\t\t\t\treturn 'int16';\n\t\t\t}\n\t\t\tif ( value >= INT32_MIN ) {\n\t\t\t\treturn 'int32';\n\t\t\t}\n\t\t\treturn 'float64';\n\t\t}\n\t\tif ( value <= UINT8_MAX ) {\n\t\t\treturn 'uint8';\n\t\t}\n\t\tif ( value <= UINT16_MAX ) {\n\t\t\treturn 'uint16';\n\t\t}\n\t\tif ( value <= UINT32_MAX ) {\n\t\t\treturn 'uint32';\n\t\t}\n\t\treturn 'float64';\n\t}\n\t// Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float32`...\n\tif (\n\t\tvalue > -FLOAT32_SMALLEST_SUBNORMAL &&\n\t\tvalue < FLOAT32_SMALLEST_SUBNORMAL\n\t) {\n\t\treturn 'float64';\n\t}\n\t// Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)...\n\treturn 'float32';\n}\n\n\n// EXPORTS //\n\nexport default minDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/mskfilter';\nimport countTruthy from './../../base/count-truthy';\nimport zeros from './../../zeros';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a new array by applying a mask to a provided input array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {Error} must provide collections of equal length\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*/\nfunction mskfilter( x, mask ) {\n\tvar dt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( mask ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) );\n\t}\n\tif ( x.length !== mask.length ) {\n\t\tthrow new Error( format( 'invalid arguments. Must provide equal length array-like objects.' ) );\n\t}\n\tdt = dtype( x );\n\tif ( dt === 'generic' || dt === null ) {\n\t\treturn base( x, mask );\n\t}\n\treturn base.assign( x, mask, zeros( countTruthy( mask ), dt ), 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default mskfilter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { factory as contains } from './../../base/assert/contains';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar MODES = [\n\t'strict',\n\t'non_strict',\n\t'strict_broadcast',\n\t'broadcast',\n\t'repeat'\n];\nvar isMode = contains( MODES );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.mode] - mode option\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'mode': 'strict'\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\topts.mode = options.mode;\n\t\tif ( !isMode( opts.mode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'mode', MODES.join( '\", \"' ), opts.mode ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/mskreject';\nimport countFalsy from './../../base/count-falsy';\nimport zeros from './../../zeros';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a new array by applying a mask to a provided input array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {Error} must provide collections of equal length\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskreject( x, mask );\n* // returns [ 1, 3 ]\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskreject( x, mask );\n* // returns [ 1, 3 ]\n*/\nfunction mskreject( x, mask ) {\n\tvar dt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( mask ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) );\n\t}\n\tif ( x.length !== mask.length ) {\n\t\tthrow new Error( format( 'invalid arguments. Must provide equal length array-like objects.' ) );\n\t}\n\tdt = dtype( x );\n\tif ( dt === 'generic' || dt === null ) {\n\t\treturn base( x, mask );\n\t}\n\treturn base.assign( x, mask, zeros( countFalsy( mask ), dt ), 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default mskreject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../base/assert/contains';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport full from './../../full';\nimport defaults from './../../defaults';\nimport dtypes from './../../dtypes';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar Z128 = new Complex128( NaN, NaN );\nvar Z64 = new Complex64( NaN, NaN );\nvar DTYPES = dtypes( 'floating_point_and_generic' );\nvar isValidDType = contains( DTYPES );\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.real_floating_point' );\n\n\n// MAIN //\n\n/**\n* Creates an array filled with NaNs and having a specified length.\n*\n* @param {NonNegativeInteger} length - array length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a supported data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = nans( 2 );\n* // returns [ NaN, NaN ]\n*\n* @example\n* var arr = nans( 2, 'float32' );\n* // returns [ NaN, NaN ]\n*/\nfunction nans( length ) {\n\tvar dtype;\n\tvar value;\n\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t\tif ( !isValidDType( dtype ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be one of the following: \"%s\". Value: `%s`.', DTYPES.join( '\", \"' ), dtype ) );\n\t\t}\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tif ( dtype === 'complex128' ) {\n\t\tvalue = Z128;\n\t} else if ( dtype === 'complex64' ) {\n\t\tvalue = Z64;\n\t} else {\n\t\tvalue = NaN;\n\t}\n\treturn full( length, value, dtype );\n}\n\n\n// EXPORTS //\n\nexport default nans;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dtype from './../../dtype';\nimport full from './../../full';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar Z128 = new Complex128( NaN, NaN );\nvar Z64 = new Complex64( NaN, NaN );\nvar DTYPES = [ 'float64', 'float32', 'complex128', 'complex64', 'generic' ];\n\n\n// MAIN //\n\n/**\n* Creates an array filled with NaNs and having the same length and data type as a provided input array.\n*\n* @param {(Array|TypedArray|ComplexArray)} x - input array\n* @param {string} [dtype] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a supported data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = nansLike( [ 0.0, 0.0 ] );\n* // returns [ NaN, NaN ]\n*\n* @example\n* var arr = nansLike( [ 0.0, 0.0 ], 'float32' );\n* // returns [ NaN, NaN ]\n*/\nfunction nansLike( x ) {\n\tvar dt;\n\tvar v;\n\n\tdt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t\tif ( DTYPES.indexOf( dt ) === -1 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be one of the following: \"%s\". Value: `%s`.', DTYPES.join( '\", \"' ), dt ) );\n\t\t}\n\t} else if ( DTYPES.indexOf( dt ) === -1 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following data types: \"%s\". Value: `%s`.', DTYPES.join( '\", \"' ), dt ) );\n\t}\n\tif ( dt === 'complex128' ) {\n\t\tv = Z128;\n\t} else if ( dt === 'complex64' ) {\n\t\tv = Z64;\n\t} else {\n\t\tv = NaN;\n\t}\n\treturn full( x.length, v, dt );\n}\n\n\n// EXPORTS //\n\nexport default nansLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport base from './../../base/one-to';\nimport zeros from './../../zeros';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from one.\n*\n* @param {NonNegativeInteger} n - number of elements\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = oneTo( 2 );\n* // returns [ 1.0, 2.0 ]\n*\n* @example\n* var arr = oneTo( 2, 'float32' );\n* // returns [ 1.0, 2.0 ]\n*/\nfunction oneTo( n ) {\n\tvar dtype;\n\tif ( !isNonNegativeInteger( n ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', n ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t\tif ( dtype === 'generic' ) {\n\t\t\treturn base( n );\n\t\t}\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\treturn base.assign( zeros( n, dtype ), 1, 0 ); // defer dtype validation to `zeros`\n}\n\n\n// EXPORTS //\n\nexport default oneTo;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport full from './../../full';\nimport defaults from './../../defaults';\n\n\n// VARIABLES //\n\nvar Z128 = new Complex128( 1.0, 0.0 );\nvar Z64 = new Complex64( 1.0, 0.0 );\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Creates an array filled with ones and having a specified length.\n*\n* @param {NonNegativeInteger} length - array length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = ones( 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = ones( 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*/\nfunction ones( length ) {\n\tvar dtype;\n\tvar value;\n\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tif ( dtype === 'complex128' ) {\n\t\tvalue = Z128;\n\t} else if ( dtype === 'complex64' ) {\n\t\tvalue = Z64;\n\t} else {\n\t\tvalue = 1;\n\t}\n\treturn full( length, value, dtype );\n}\n\n\n// EXPORTS //\n\nexport default ones;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dtype from './../../dtype';\nimport full from './../../full';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar Z128 = new Complex128( 1.0, 0.0 );\nvar Z64 = new Complex64( 1.0, 0.0 );\n\n\n// MAIN //\n\n/**\n* Creates an array filled with ones and having the same length and data type as a provided input array.\n*\n* @param {(Array|TypedArray|ComplexArray)} x - input array\n* @param {string} [dtype] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = onesLike( [ 0.0, 0.0 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = onesLike( [ 0.0, 0.0 ], 'float32' );\n* // returns [ 1.0, 1.0 ]\n*/\nfunction onesLike( x ) {\n\tvar dt;\n\tvar v;\n\n\tdt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t}\n\tif ( dt === 'complex128' ) {\n\t\tv = Z128;\n\t} else if ( dt === 'complex64' ) {\n\t\tv = Z64;\n\t} else {\n\t\tv = 1.0;\n\t}\n\treturn full( x.length, v, dt );\n}\n\n\n// EXPORTS //\n\nexport default onesLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { factory as contains } from './../../base/assert/contains';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar MODES = [\n\t'strict',\n\t'non_strict',\n\t'strict_broadcast',\n\t'broadcast',\n\t'repeat'\n];\nvar isMode = contains( MODES );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.mode] - mode option\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'mode': 'strict'\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\topts.mode = options.mode;\n\t\tif ( !isMode( opts.mode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'mode', MODES.join( '\", \"' ), opts.mode ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isMostlySafeCast from './../../base/assert/is-mostly-safe-data-type-cast';\nimport isRealDataType from './../../base/assert/is-real-data-type';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/place';\nimport dtype from './../../dtype';\nimport convert from './../../convert';\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Replaces elements of an array with provided values according to a provided mask array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @param {Options} [options] - function options\n* @param {string} [options.mode='repeat'] - string specifying behavior when the number of values does not equal the number of truthy mask values\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {TypeError} third argument must be a collection\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @throws {Error} insufficient values to satisfy mask array\n* @throws {Error} number of values does not equal the number of truthy mask values\n* @throws {TypeError} third argument cannot be safely cast to the data type of the first argument\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 1, 1, 0 ];\n* var values = [ 20, 30 ];\n*\n* var out = place( x, mask, values );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 1, 1, 0 ];\n* var values = [ 30 ];\n*\n* var out = place( x, mask, values );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 1, 0, 1 ];\n* var values = [ 20, 30 ];\n*\n* var out = place( x, mask, values );\n* // returns [ 20, 30, 3, 20 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction place( x, mask, values ) {\n\tvar opts;\n\tvar err;\n\tvar xdt;\n\tvar vdt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( mask ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) );\n\t}\n\tif ( !isCollection( values ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', values ) );\n\t}\n\topts = defaults();\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\txdt = dtype( x ) || 'generic';\n\tvdt = dtype( values ) || 'generic';\n\n\t// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the input array data type is floating-point...\n\tif ( !isMostlySafeCast( vdt, xdt ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].', vdt, xdt ) );\n\t}\n\t// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...\n\tif ( isComplexDataType( xdt ) && isRealDataType( vdt ) ) {\n\t\tvalues = convert( values, xdt );\n\t}\n\t// Replace values in the input array:\n\treturn base( x, mask, values, opts.mode );\n}\n\n\n// EXPORTS //\n\nexport default place;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'mode': 'repeat'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'float64': Float64Array,\n\t'float32': Float32Array,\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array,\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray,\n\t'complex64': Complex64Array,\n\t'complex128': Complex128Array,\n\t'bool': BooleanArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/e_log2.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getHighWord from '@stdlib/number/float64/base/get-high-word';\nimport setHighWord from '@stdlib/number/float64/base/set-high-word';\nimport setLowWord from '@stdlib/number/float64/base/set-low-word';\nimport toWords from '@stdlib/number/float64/base/to-words';\nimport isnan from './../../../../base/assert/is-nan';\nimport ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\nimport HIGH_SIGNIFICAND_MASK from '@stdlib/constants/float64/high-word-significand-mask';\nimport BIAS from '@stdlib/constants/float64/exponent-bias';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport kernelLog1p from './../../../../base/special/kernel-log1p';\n\n\n// VARIABLES //\n\nvar TWO54 = 1.80143985094819840000e+16; // 0x43500000, 0x00000000\nvar IVLN2HI = 1.44269504072144627571e+00; // 0x3ff71547, 0x65200000\nvar IVLN2LO = 1.67517131648865118353e-10; // 0x3de705fc, 0x2eefa200\n\n// 0x7ff00000 = 2146435072 => 0 11111111111 00000000000000000000 => biased exponent: 2047 = 1023+1023 => 2^1023\nvar HIGH_MAX_NORMAL_EXP = 0x7ff00000|0; // asm type annotation\n\n// 0x00100000 = 1048576 => 0 00000000001 00000000000000000000 => biased exponent: 1 = -1022+1023 => 2^-1022\nvar HIGH_MIN_NORMAL_EXP = 0x00100000|0; // asm type annotation\n\n// 0x3ff00000 = 1072693248 => 0 01111111111 00000000000000000000 => biased exponent: 1023 = 0+1023 => 2^0 = 1\nvar HIGH_BIASED_EXP_0 = 0x3ff00000|0; // asm type annotation\n\n// High/low words workspace:\nvar WORDS = [ 0|0, 0|0 ];\n\n\n// MAIN //\n\n/**\n* Evaluates the binary logarithm (base two).\n*\n* @param {NonNegativeNumber} x - input value\n* @returns {number} function value\n*\n* @example\n* var v = log2( 4.0 );\n* // returns 2.0\n*\n* @example\n* var v = log2( 8.0 );\n* // returns 3.0\n*\n* @example\n* var v = log2( 0.0 );\n* // returns -Infinity\n*\n* @example\n* var v = log2( Infinity );\n* // returns Infinity\n*\n* @example\n* var v = log2( NaN );\n* // returns NaN\n*\n* @example\n* var v = log2( -4.0 );\n* // returns NaN\n*/\nfunction log2( x ) {\n\tvar valHi;\n\tvar valLo;\n\tvar hfsq;\n\tvar hx;\n\tvar lx;\n\tvar hi;\n\tvar lo;\n\tvar f;\n\tvar R;\n\tvar w;\n\tvar y;\n\tvar i;\n\tvar k;\n\n\tif ( isnan( x ) || x < 0.0 ) {\n\t\treturn NaN;\n\t}\n\ttoWords.assign( x, WORDS, 1, 0 );\n\thx = WORDS[ 0 ] | 0; // asm type annotation\n\tlx = WORDS[ 1 ];\n\tk = 0|0; // asm type annotation\n\tif ( hx < HIGH_MIN_NORMAL_EXP ) {\n\t\t// Case: x < 2**-1022\n\t\tif ( ( (hx&ABS_MASK) | lx ) === 0 ) {\n\t\t\treturn NINF;\n\t\t}\n\t\tk -= 54|0; // asm type annotation\n\n\t\t// Subnormal number, scale up x:\n\t\tx *= TWO54;\n\t\thx = getHighWord( x ) | 0; // asm type annotation\n\t}\n\tif ( hx >= HIGH_MAX_NORMAL_EXP ) {\n\t\treturn x + x;\n\t}\n\t// Case: log(1) = +0\n\tif ( hx === HIGH_BIASED_EXP_0 && lx === 0 ) {\n\t\treturn 0.0;\n\t}\n\tk += ( (hx>>20) - BIAS )|0; // asm type annotation\n\thx &= HIGH_SIGNIFICAND_MASK;\n\ti = ( ( hx+0x95f64 ) & HIGH_MIN_NORMAL_EXP )|0; // asm type annotation\n\n\t// Normalize x or x/2...\n\tx = setHighWord( x, hx|(i^HIGH_BIASED_EXP_0) );\n\tk += (i>>20)|0; // asm type annotation\n\ty = k;\n\tf = x - 1.0;\n\thfsq = 0.5 * f * f;\n\tR = kernelLog1p( f );\n\n\t/*\n\t* Notes:\n\t*\n\t* - `f-hfsq` must (for args near `1`) be evaluated in extra precision to avoid a large cancellation when `x` is near `sqrt(2)` or `1/sqrt(2)`.This is fairly efficient since `f-hfsq` only depends on `f`, so can be evaluated in parallel with `R`. Not combining `hfsq` with `R` also keeps `R` small (though not as small as a true `lo` term would be), so that extra precision is not needed for terms involving `R`.\n\t* - When implemented in C, compiler bugs involving extra precision used to break Dekker's theorem for spitting `f-hfsq` as `hi+lo`. These problems are now automatically avoided as a side effect of the optimization of combining the Dekker splitting step with the clear-low-bits step.\n\t* - `y` must (for args near `sqrt(2)` and `1/sqrt(2)`) be added in extra precision to avoid a very large cancellation when `x` is very near these values. Unlike the above cancellations, this problem is specific to base `2`. It is strange that adding `+-1` is so much harder than adding `+-ln2` or `+-log10_2`.\n\t* - This implementation uses Dekker's theorem to normalize `y+val_hi`, so, when implemented in C, compiler bugs may reappear in some configurations.\n\t* - The multi-precision calculations for the multiplications are routine.\n\t*/\n\thi = f - hfsq;\n\thi = setLowWord( hi, 0 );\n\tlo = ( f - hi ) - hfsq + R;\n\tvalHi = hi * IVLN2HI;\n\tvalLo = ( ( lo + hi ) * IVLN2LO ) + ( lo * IVLN2HI );\n\n\tw = y + valHi;\n\tvalLo += ( y - w ) + valHi;\n\tvalHi = w;\n\n\treturn valLo + valHi;\n}\n\n\n// EXPORTS //\n\nexport default log2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/k_log.h}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport polyvalP from './polyval_p.js';\nimport polyvalQ from './polyval_q.js';\n\n\n// MAIN //\n\n/**\n* Evaluates a correction term for double-precision base-2 and base-10 logarithms when `1+f` is in `[√2/2, √2]`.\n*\n* ## Method\n*\n* This function is a helper function for computing logarithms in base \\\\(e\\\\), and what follows describes the overall strategy for doing so. The argument reduction and adding the final term of the polynomial are done by the caller for increased accuracy when different bases are used.\n*\n* 1. Argument Reduction. Find \\\\(k\\\\) and \\\\(f\\\\) such that\n*\n* ```tex\n* x = 2^k \\cdot (1+f)\n* ```\n*\n* where \\\\(\\sqrt(2)/2 < 1+f < \\sqrt(2)\\\\).\n*\n* 2. Approximation of \\\\(\\operatorname{log}(1+f)\\\\). Let\n*\n* ```tex\n* \\begin{align*}\n* s &= \\frac{f}{2+f} \\\\\n* &= 2s + \\frac{2}{3} s^3 + \\frac{2}{5} s^5 + \\ldots \\\\\n* &= 2s + s R\n* \\end{align*}\n* ```\n*\n* based on\n*\n* ```tex\n* \\operatorname{log}(1+f) &= \\operatorname{log}(1+s) - \\operatorname{log}(1-s)\n* ```\n*\n* We use a special Reme algorithm on \\\\(\\[0,0.1716]\\\\) to generate a polynomial of degree \\\\(14\\\\) to approximate \\\\(R\\\\). The maximum error of this polynomial approximation is bounded by \\\\(2^{-58.45}\\\\). In other words,\n*\n* ```tex\n* R(z) ~ L_{g1} s^2 + L_{g2} s^4 + L_{g3} s^6 + L_{g4} s^8 + L_{g5} s^{10} + L_{g6} s^{12} + L_{g7} s^{14}\n* ```\n*\n* where the values of \\\\(L_{g1}\\\\) to \\\\(L_{g7}\\\\) are the polynomial coefficients used in the program below and\n*\n* ```tex\n* L_{g1} s^2 + \\ldots + L_{g7} s^{14} - R(z) \\leq 2^{-58.45}\n* ```\n*\n* Note that\n*\n* ```tex\n* 2s = f - s \\cdot f = f - h_{fsq} + (s \\cdot h_{fsq})\n* ```\n*\n* where \\\\(h_{fsq} = f^{2}/2\\\\).\n*\n* In order to guarantee an error in \\\\(\\operatorname{log}\\\\) below 1 ulp, we compute \\\\(\\operatorname{log}\\\\) by\n*\n* ```tex\n* \\begin{align*}\n* \\operatorname{log}(1+f) &= f - s (f - R) & \\textrm{(if f is not too large)} \\\\\n* \\operatorname{log}(1+f) &= f - (h_{fsq} - s (h_{fsq}+R)) & \\textrm{(better accuracy)}\n* \\end{align*}\n*\n* 3. Finally,\n*\n* ```tex\n* \\begin{align*}\n* \\operatorname{log}(x) &= k \\cdot \\operatorname{ln2} + \\operatorname{log}(1+f) \\\\\n* &= k \\cdot \\operatorname{ln2}_{hi} + (f-(h_{fsq}-(s \\cdot (h_{fsq}+R) + k \\cdot \\operatorname{ln2}_{lo})))\n* \\end{align*}\n* ```\n*\n* Here, \\\\(\\operatorname{ln2}\\\\) is split into two floating point numbers:\n*\n* ```tex\n* \\operatorname{ln2} = \\operatorname{ln2}_{hi} + \\operatorname{ln2}_{lo}\n* ```\n*\n* where \\\\(n \\cdot \\operatorname{ln2}_{hi}\\\\) is always exact for \\\\(|n| < 2000\\\\).\n*\n* @param {number} f - input value\n* @returns {number} function value\n*\n* @example\n* var v = kernelLog1p( 1.0 );\n* // returns ~0.1931\n*\n* @example\n* var v = kernelLog1p( 1.4142135623730951 );\n* // returns ~0.4672\n*\n* @example\n* var v = kernelLog1p( NaN );\n* // returns NaN\n*/\nfunction kernelLog1p( f ) {\n\tvar hfsq;\n\tvar t1;\n\tvar t2;\n\tvar s;\n\tvar z;\n\tvar R;\n\tvar w;\n\n\ts = f / ( 2.0 + f );\n\tz = s * s;\n\tw = z * z;\n\tt1 = w * polyvalP( w );\n\tt2 = z * polyvalQ( w );\n\tR = t2 + t1;\n\thfsq = 0.5 * f * f;\n\treturn s * ( hfsq + R );\n}\n\n\n// EXPORTS //\n\nexport default kernelLog1p;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* This is a generated file. Do not edit directly. */\n'use strict';\n\n// MAIN //\n\n/**\n* Evaluates a polynomial.\n*\n* ## Notes\n*\n* - The implementation uses [Horner's rule][horners-method] for efficient computation.\n*\n* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method\n*\n* @private\n* @param {number} x - value at which to evaluate the polynomial\n* @returns {number} evaluated polynomial\n*/\nfunction evalpoly( x ) {\n\tif ( x === 0.0 ) {\n\t\treturn 0.3999999999940942;\n\t}\n\treturn 0.3999999999940942 + (x * (0.22222198432149784 + (x * 0.15313837699209373))); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default evalpoly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* This is a generated file. Do not edit directly. */\n'use strict';\n\n// MAIN //\n\n/**\n* Evaluates a polynomial.\n*\n* ## Notes\n*\n* - The implementation uses [Horner's rule][horners-method] for efficient computation.\n*\n* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method\n*\n* @private\n* @param {number} x - value at which to evaluate the polynomial\n* @returns {number} evaluated polynomial\n*/\nfunction evalpoly( x ) {\n\tif ( x === 0.0 ) {\n\t\treturn 0.6666666666666735;\n\t}\n\treturn 0.6666666666666735 + (x * (0.2857142874366239 + (x * (0.1818357216161805 + (x * 0.14798198605116586))))); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default evalpoly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isTypedArrayLike from '@stdlib/assert/is-typed-array-like';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isComplex64Array from '@stdlib/assert/is-complex64array';\nimport isComplex128Array from '@stdlib/assert/is-complex128array';\nimport isBooleanArray from '@stdlib/assert/is-booleanarray';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport ctors from './../../typed-ctors';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport resolveGetter from './../../base/resolve-getter';\nimport resolveSetter from './../../base/resolve-setter';\nimport ARRAY_DEFAULTS from './../../defaults';\nimport format from '@stdlib/string/format';\nimport ArrayBuffer from './../../buffer';\nimport ceil from '@stdlib/math/base/special/ceil';\nimport floor from '@stdlib/math/base/special/floor';\nimport ceil2 from '@stdlib/math/base/special/ceil2';\nimport log2 from '@stdlib/math/base/special/log2';\nimport min from '@stdlib/math/base/special/min';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\nimport createPool from './pool.js';\nimport BYTES_PER_ELEMENT from './bytes_per_element.json';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = ARRAY_DEFAULTS.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an array is a single-precision complex floating-point number array.\n*\n* @private\n* @param {Collection} arr - input array\n* @returns {boolean} boolean indicating whether an input array is a single-precision complex floating-point number array\n*/\nfunction isCmplx64Array( arr ) {\n\treturn ( arr instanceof Complex64Array );\n}\n\n/**\n* Tests whether an array is a double-precision complex floating-point number array.\n*\n* @private\n* @param {Collection} arr - input array\n* @returns {boolean} boolean indicating whether an input array is a double-precision complex floating-point number array\n*/\nfunction isCmplx128Array( arr ) {\n\treturn ( arr instanceof Complex128Array );\n}\n\n/**\n* Tests whether an array is a boolean array.\n*\n* @private\n* @param {Collection} arr - input array\n* @returns {boolean} boolean indicating whether an input array is a boolean array\n*/\nfunction isBoolArray( arr ) {\n\treturn ( arr instanceof BooleanArray );\n}\n\n\n// MAIN //\n\n/**\n* Creates a typed array pool.\n*\n* @param {Options} [options] - pool options\n* @param {NonNegativeInteger} [options.highWaterMark] - maximum total memory which can be allocated\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {Function} allocator\n*\n* @example\n* var typedarraypool = factory();\n*\n* // Allocate an array of doubles:\n* var arr = typedarraypool( 5, 'float64' );\n* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ]\n*\n* arr[ 0 ] = 3.14;\n* arr[ 1 ] = 3.14;\n*\n* // ...\n*\n* // Free the allocated memory to be used in a future allocation:\n* typedarraypool.free( arr );\n*/\nfunction factory( options ) {\n\tvar nbytes;\n\tvar pool;\n\tvar opts;\n\tvar err;\n\n\topts = defaults();\n\tif ( arguments.length ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tpool = createPool( ceil( log2( opts.highWaterMark ) ) );\n\tnbytes = 0;\n\n\tsetReadOnly( malloc, 'malloc', malloc ); // circular reference\n\tsetReadOnly( malloc, 'calloc', calloc );\n\tsetReadOnly( malloc, 'free', free );\n\tsetReadOnly( malloc, 'clear', clear );\n\tsetReadOnly( malloc, 'highWaterMark', opts.highWaterMark );\n\tsetReadOnlyAccessor( malloc, 'nbytes', getBytes );\n\n\treturn malloc;\n\n\t/**\n\t* Returns the number of allocated bytes.\n\t*\n\t* @private\n\t* @returns {NonNegativeInteger} number of allocated bytes\n\t*/\n\tfunction getBytes() {\n\t\treturn nbytes;\n\t}\n\n\t/**\n\t* Returns an array buffer.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} n - number of bytes\n\t* @returns {(ArrayBuffer|null)} array buffer or null\n\t*/\n\tfunction arraybuffer( n ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\t// Convert the number of bytes to an index in our pool table:\n\t\ti = log2( n );\n\n\t\t// If we already have an available array buffer, use it...\n\t\tif ( i < pool.length && pool[ i ].length ) {\n\t\t\treturn pool[ i ].pop();\n\t\t}\n\t\t// Before allocating a new array buffer, ensure that we have not exceeded the maximum number of bytes we are allowed to allocate...\n\t\tif ( nbytes+n > opts.highWaterMark ) {\n\t\t\treturn null;\n\t\t}\n\t\tbuf = new ArrayBuffer( n );\n\n\t\t// Update the running counter of allocated bytes:\n\t\tnbytes += n;\n\n\t\treturn buf;\n\t}\n\n\t/**\n\t* Returns a typed array.\n\t*\n\t* @private\n\t* @param {Function} ctor - typed array constructor\n\t* @param {NonNegativeInteger} len - view length\n\t* @param {string} dtype - data type\n\t* @returns {(TypedArray|null)} typed array or null\n\t*/\n\tfunction typedarray( ctor, len, dtype ) {\n\t\tvar buf;\n\t\tif ( len === 0 ) {\n\t\t\treturn new ctor( 0 );\n\t\t}\n\t\tbuf = arraybuffer( ceil2( len )*BYTES_PER_ELEMENT[ dtype ] );\n\t\tif ( buf === null ) {\n\t\t\treturn buf;\n\t\t}\n\t\treturn new ctor( buf, 0, len );\n\t}\n\n\t/**\n\t* Returns an uninitialized typed array.\n\t*\n\t* ## Notes\n\t*\n\t* - Memory is **not** initialized.\n\t* - Memory is lazily allocated.\n\t* - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory).\n\t*\n\t* @private\n\t* @param {(NonNegativeInteger|Collection)} [arg] - an array length or an array-like object\n\t* @param {string} [dtype=\"float64\"] - data type\n\t* @throws {TypeError} must provide a valid array length or an array-like object\n\t* @throws {TypeError} must provide a recognized data type\n\t* @returns {(TypedArray|null)} typed array or null\n\t*/\n\tfunction malloc() {\n\t\tvar nargs;\n\t\tvar dtype;\n\t\tvar ctor;\n\t\tvar arr;\n\t\tvar out;\n\t\tvar set;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\n\t\tnargs = arguments.length;\n\t\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\t\tnargs -= 1;\n\t\t\tdtype = arguments[ nargs ];\n\t\t} else {\n\t\t\tdtype = DEFAULT_DTYPE;\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t\t}\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn new ctor( 0 );\n\t\t}\n\t\t// Check if provided a typed array length...\n\t\tif ( isNonNegativeInteger( arguments[ 0 ] ) ) {\n\t\t\treturn typedarray( ctor, arguments[ 0 ], dtype );\n\t\t}\n\t\t// Check if provided an array-like object containing data elements...\n\t\tif ( isCollection( arguments[ 0 ] ) ) {\n\t\t\tarr = arguments[ 0 ];\n\t\t\tlen = arr.length;\n\t\t\tif ( isComplex128Array( arr ) ) {\n\t\t\t\tarr = reinterpret128( arr, 0 );\n\t\t\t} else if ( isComplex64Array( arr ) ) {\n\t\t\t\tarr = reinterpret64( arr, 0 );\n\t\t\t} else if ( isBooleanArray( arr ) ) {\n\t\t\t\tarr = reinterpretBoolean( arr, 0 );\n\t\t\t} else if ( isComplexDataType( dtype ) ) {\n\t\t\t\t// Assume we've been provided an array of interleaved real and imaginary components...\n\t\t\t\tlen /= 2;\n\t\t\t}\n\t\t\tout = typedarray( ctor, len, dtype );\n\t\t\tif ( out === null ) {\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\tif ( isCmplx128Array( out ) || isCmplx64Array( out ) || isBoolArray( out ) ) {\n\t\t\t\tout.set( arr );\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\t// Resolve element accessors in order to account for the possibility that `arr` is a complex number array. As we don't prohibit other \"unsafe\" casts (e.g., providing a `Float64Array` and specifying a `dtype` of `uint8`), we don't prohibit providing a complex number array and specifying a real `dtype`. The results will probably be unexpected/gibberish, but I am not sure we should be overly pedantic in ensuring users don't do ill-advised things...\n\t\t\tget = resolveGetter( arr );\n\t\t\tset = resolveSetter( out );\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tset( out, i, get( arr, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array length or an array-like object. Value: `%s`.', arguments[ 0 ] ) );\n\t}\n\n\t/**\n\t* Returns a zero-initialized typed array.\n\t*\n\t* ## Notes\n\t*\n\t* - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory).\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} [len=0] - array length\n\t* @param {string} [dtype=\"float64\"] - data type\n\t* @throws {TypeError} must provide a valid array length\n\t* @throws {TypeError} must provide a recognized data type\n\t* @returns {(TypedArray|null)} typed array or null\n\t*/\n\tfunction calloc() {\n\t\tvar nargs;\n\t\tvar out;\n\t\tvar tmp;\n\t\tvar i;\n\n\t\tnargs = arguments.length;\n\t\tif ( nargs === 0 ) {\n\t\t\tout = malloc();\n\t\t} else if ( nargs === 1 ) {\n\t\t\tout = malloc( arguments[ 0 ] );\n\t\t} else {\n\t\t\tout = malloc( arguments[ 0 ], arguments[ 1 ] );\n\t\t}\n\t\tif ( out !== null ) {\n\t\t\t// Initialize the memory...\n\t\t\tif ( isCmplx128Array( out ) ) {\n\t\t\t\ttmp = reinterpret128( out, 0 );\n\t\t\t} else if ( isCmplx64Array( out ) ) {\n\t\t\t\ttmp = reinterpret64( out, 0 );\n\t\t\t} else if ( isBoolArray( out ) ) {\n\t\t\t\ttmp = reinterpretBoolean( out, 0 );\n\t\t\t} else {\n\t\t\t\ttmp = out;\n\t\t\t}\n\t\t\tfor ( i = 0; i < tmp.length; i++ ) {\n\t\t\t\ttmp[ i ] = 0.0;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\n\t/**\n\t* Frees a typed array or typed array buffer.\n\t*\n\t* ## Notes\n\t*\n\t* - Implicitly, we support providing non-internally allocated arrays and array buffer (e.g., \"freeing\" a typed array allocated in userland); however, the freed array buffer is likely to have excess capacity when compared to other members in its pool.\n\t*\n\t* @private\n\t* @param {(TypedArray|ArrayBuffer)} buf - typed array or array buffer to free\n\t* @throws {TypeError} must provide a typed array or typed array buffer\n\t* @returns {boolean} boolean indicating whether the typed array or array buffer was successfully freed\n\t*/\n\tfunction free( buf ) {\n\t\tvar n;\n\t\tvar p;\n\t\tvar i;\n\t\tif ( isTypedArrayLike( buf ) && buf.buffer ) {\n\t\t\tbuf = buf.buffer;\n\t\t} else if ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a typed array or ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tif ( buf.byteLength > 0 ) {\n\t\t\tn = floor( log2( buf.byteLength ) );\n\n\t\t\t// Prohibit \"freeing\" array buffers which would potentially allow users to circumvent high water mark limits:\n\t\t\tn = min( pool.length-1, n );\n\n\t\t\t// Ensure that we do not attempt to free the same buffer more than once...\n\t\t\tp = pool[ n ];\n\t\t\tfor ( i = 0; i < p.length; i++ ) {\n\t\t\t\tif ( p[ i ] === buf ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Add the buffer to our pool of free buffers:\n\t\t\tp.push( buf );\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t* Clears the typed array pool allowing garbage collection of previously allocated (and currently free) array buffers.\n\t*\n\t* @private\n\t*/\n\tfunction clear() {\n\t\tvar i;\n\t\tfor ( i = 0; i < pool.length; i++ ) {\n\t\t\tpool[ i ].length = 0;\n\t\t}\n\t\tnbytes = 0;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'highWaterMark': 9007199254740992\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {NonNegativeInteger} [options.highWaterMark] - maximum total memory which can be allocated\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'highWaterMark': 1024\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegativeInteger( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Initializes a cache for pooled typed array buffers.\n*\n* @private\n* @param {NonNegativeInteger} n - base-2 logarithm of the maximum typed array size\n* @returns {ArrayArray} initialized cache\n*/\nfunction pool( n ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < n+1; i++ ) {\n\t\tout.push( [] );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default pool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from './../../is-nonnegative-integer';\nimport MAX from '@stdlib/constants/array/max-typed-array-length';\n\n\n// MAIN //\n\n/**\n* Tests if a value is typed-array-like.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is typed-array-like\n*\n* @example\n* var arr = {\n* 'BYTES_PER_ELEMENT': 8,\n* 'length': 10,\n* 'byteOffset': 0,\n* 'byteLength': 10\n* };\n* var val = isTypedArrayLike( arr );\n* // returns true\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var val = isTypedArrayLike( new Int8Array( 4 ) );\n* // returns true\n*\n* @example\n* var val = isTypedArrayLike( [] );\n* // returns false\n*\n* @example\n* var val = isTypedArrayLike( {} );\n* // returns false\n*\n* @example\n* var val = isTypedArrayLike( null );\n* // returns false\n*\n* @example\n* var val = isTypedArrayLike( 'beep' );\n* // returns false\n*/\nfunction isTypedArrayLike( value ) {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === 'object' &&\n\t\tisNonNegativeInteger( value.length ) &&\n\t\tvalue.length <= MAX &&\n\t\ttypeof value.BYTES_PER_ELEMENT === 'number' &&\n\t\ttypeof value.byteOffset === 'number' &&\n\t\ttypeof value.byteLength === 'number'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isTypedArrayLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isNegativeZero from './../../../../base/assert/is-negative-zero';\nimport isnan from './../../../../base/assert/is-nan';\nimport NINF from '@stdlib/constants/float64/ninf';\n\n\n// MAIN //\n\n/**\n* Returns the minimum value.\n*\n* @param {number} x - first number\n* @param {number} y - second number\n* @returns {number} minimum value\n*\n* @example\n* var v = min( 3.14, 4.2 );\n* // returns 3.14\n*\n* @example\n* var v = min( 3.14, NaN );\n* // returns NaN\n*\n* @example\n* var v = min( +0.0, -0.0 );\n* // returns -0.0\n*/\nfunction min( x, y ) {\n\tif ( isnan( x ) || isnan( y ) ) {\n\t\treturn NaN;\n\t}\n\tif ( x === NINF || y === NINF ) {\n\t\treturn NINF;\n\t}\n\tif ( x === y && x === 0.0 ) {\n\t\tif ( isNegativeZero( x ) ) {\n\t\t\treturn x;\n\t\t}\n\t\treturn y;\n\t}\n\tif ( x < y ) {\n\t\treturn x;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default min;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from './../../../../base/assert/is-nan';\nimport isInfinite from './../../../../base/assert/is-infinite';\nimport pow from './../../../../base/special/pow';\nimport floor from './../../../../base/special/floor';\nimport ceil from './../../../../base/special/ceil';\nimport log2 from './../../../../base/special/log2';\nimport MAX_EXP from '@stdlib/constants/float64/max-base2-exponent';\nimport MIN_EXP_SUBNORMAL from '@stdlib/constants/float64/min-base2-exponent-subnormal';\nimport PINF from '@stdlib/constants/float64/pinf';\n\n\n// MAIN //\n\n/**\n* Rounds a numeric value to the nearest power of two toward positive infinity.\n*\n* @param {number} x - input value\n* @returns {number} rounded value\n*\n* @example\n* var v = ceil2( 3.141592653589793 );\n* // returns 4.0\n*\n* @example\n* var v = ceil2( 9.0 );\n* // returns 16.0\n*\n* @example\n* var v = ceil2( -0.314 );\n* // returns -0.25\n*/\nfunction ceil2( x ) {\n\tvar sign;\n\tvar p;\n\tif (\n\t\tisnan( x ) ||\n\t\tisInfinite( x ) ||\n\t\tx === 0.0\n\t) {\n\t\treturn x;\n\t}\n\tif ( x < 0 ) {\n\t\tx = -x;\n\t\tsign = -1.0;\n\t} else {\n\t\tsign = 1.0;\n\t}\n\t// Solve the equation `2^p = x` for `p`:\n\tp = log2( x );\n\n\t// If provided the smallest subnormal, no rounding possible:\n\tif ( p === MIN_EXP_SUBNORMAL ) {\n\t\treturn x;\n\t}\n\t// Determine a power of two which rounds the input value toward positive infinity:\n\tif ( sign === -1.0 ) {\n\t\tp = floor( p );\n\t} else {\n\t\tp = ceil( p );\n\t}\n\t// Handle overflow:\n\tif ( p > MAX_EXP ) {\n\t\treturn PINF;\n\t}\n\treturn sign * pow( 2.0, p );\n}\n\n\n// EXPORTS //\n\nexport default ceil2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex128Array from '@stdlib/array/complex128';\nimport constructorName from '@stdlib/utils/constructor-name';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Complex128Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Complex128Array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isComplex128Array( new Complex128Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isComplex128Array( [] );\n* // returns false\n*/\nfunction isComplex128Array( value ) {\n\treturn (\n\t\tvalue instanceof Complex128Array ||\n\t\tconstructorName( value ) === 'Complex128Array'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex128Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64Array from '@stdlib/array/complex64';\nimport constructorName from '@stdlib/utils/constructor-name';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Complex64Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Complex64Array\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n*\n* var bool = isComplex64Array( new Complex64Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isComplex64Array( [] );\n* // returns false\n*/\nfunction isComplex64Array( value ) {\n\treturn (\n\t\tvalue instanceof Complex64Array ||\n\t\tconstructorName( value ) === 'Complex64Array'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './factory.js';\n\n\n// MAIN //\n\n/**\n* Returns an uninitialized typed array.\n*\n* ## Notes\n*\n* - Memory is **not** initialized.\n* - Memory is lazily allocated.\n* - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory).\n*\n* @name typedarraypool\n* @type {Function}\n* @param {(NonNegativeInteger|ArrayLikeObject)} [arg] - an array length or an array-like object\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} must provide a valid array length or an array-like object\n* @throws {TypeError} must provide a recognized data type\n* @returns {(TypedArray|null)} typed array or null\n*\n* @example\n* // Allocate an array of doubles:\n* var arr = typedarraypool( 5, 'float64' );\n* // e.g., returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ]\n*\n* arr[ 0 ] = 3.14;\n* arr[ 1 ] = 3.14;\n*\n* // ...\n*\n* // Free the allocated memory to be used in a future allocation:\n* typedarraypool.free( arr );\n*/\nvar typedarraypool = factory();\n\n\n// EXPORTS //\n\nexport default typedarraypool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array pool.\n*\n* @module @stdlib/array/pool\n*\n* @example\n* import typedarraypool from '@stdlib/array/pool';\n*\n* // Allocate an array of doubles:\n* var arr = typedarraypool( 5, 'float64' );\n* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ]\n*\n* arr[ 0 ] = 3.14;\n* arr[ 1 ] = 3.14;\n*\n* // ...\n*\n* // Free the allocated memory to be used in a future allocation:\n* typedarraypool.free( arr );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isMostlySafeCast from './../../base/assert/is-mostly-safe-data-type-cast';\nimport isRealDataType from './../../base/assert/is-real-data-type';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/put';\nimport dtype from './../../dtype';\nimport convert from './../../convert';\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Replaces specified elements of an array with provided values.\n*\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {Collection} values - values to set\n* @param {Options} [options] - function options\n* @param {string} [options.mode='normalize'] - index mode\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {TypeError} third argument must be a collection\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @throws {Error} third argument must be broadcast compatible with the second argument\n* @throws {TypeError} third argument cannot be safely cast to the data type of the first argument\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 1, 2 ];\n* var values = [ 20, 30 ];\n*\n* var out = put( x, indices, values );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 1, 2 ];\n* var values = [ 30 ];\n*\n* var out = put( x, indices, values );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction put( x, indices, values ) {\n\tvar opts;\n\tvar err;\n\tvar xdt;\n\tvar vdt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( indices ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', indices ) );\n\t}\n\tif ( !isCollection( values ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', values ) );\n\t}\n\topts = defaults();\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\txdt = dtype( x ) || 'generic';\n\tvdt = dtype( values ) || 'generic';\n\n\t// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the input array data type is floating-point...\n\tif ( !isMostlySafeCast( vdt, xdt ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].', vdt, xdt ) );\n\t}\n\t// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...\n\tif ( isComplexDataType( xdt ) && isRealDataType( vdt ) ) {\n\t\tvalues = convert( values, xdt );\n\t}\n\t// Replace values in the input array:\n\treturn base( x, indices, values, opts.mode );\n}\n\n\n// EXPORTS //\n\nexport default put;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'mode': 'normalize'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport isIndexMode from '@stdlib/ndarray/base/assert/is-index-mode';\nimport modes from '@stdlib/ndarray/index-modes';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.mode] - index mode\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'mode': 'normalize'\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\topts.mode = options.mode;\n\t\tif ( !isIndexMode( opts.mode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'mode', modes().join( '\", \"' ), opts.mode ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\nvar ctors = {\n\t'Float64Array': Float64Array,\n\t'Float32Array': Float32Array,\n\t'Int32Array': Int32Array,\n\t'Uint32Array': Uint32Array,\n\t'Int16Array': Int16Array,\n\t'Uint16Array': Uint16Array,\n\t'Int8Array': Int8Array,\n\t'Uint8Array': Uint8Array,\n\t'Uint8ClampedArray': Uint8ClampedArray,\n\t'Complex64Array': Complex64Array,\n\t'Complex128Array': Complex128Array,\n\t'BooleanArray': BooleanArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Recursively (and eagerly) attempts to resolve nested array dimensions.\n*\n* @private\n* @param {Array} shape - output array\n* @param {ArrayLikeObject} arr - array\n* @returns {Array} shape array\n*/\nfunction recurse( shape, arr ) {\n\tvar v = arr[ 0 ];\n\tif ( isArrayLikeObject( v ) ) {\n\t\tshape.push( v.length );\n\t\trecurse( shape, v );\n\t}\n\treturn shape;\n}\n\n/**\n* Recursively verifies that all nested arrays have consistent dimensions.\n*\n* @private\n* @param {PositiveInteger} ndims - number of dimensions\n* @param {Array} shape - shape array\n* @param {NonNegativeInteger} d - dimension\n* @param {ArrayLikeObject} arr - array element to verify\n* @param {boolean} flg - boolean indicating whether to continue recursing\n* @returns {NonNegativeInteger} number of consistent dimensions\n*/\nfunction check( ndims, shape, d, arr, flg ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\n\t// Get the size of the current dimension:\n\tlen = shape[ d ];\n\n\t// Ensure that each array element is an array of the same size:\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tv = arr[ i ];\n\n\t\t// If the array element is not an array or is not the same size, we have found an inconsistent dimension:\n\t\tif ( !isArrayLikeObject( v ) || v.length !== len ) {\n\t\t\t// `d` is one more than the index of the last consistent dimension and thus equal to the number of consistent dimensions:\n\t\t\treturn d;\n\t\t}\n\t\t// Recursively examine nested elements:\n\t\tif ( flg ) {\n\t\t\tv = check( ndims, shape, d+1, v, d+1 < ndims-1 );\n\t\t\tif ( v < ndims ) {\n\t\t\t\t// Propagate the number of consistent dimensions up the recursion chain...\n\t\t\t\treturn v;\n\t\t\t}\n\t\t}\n\t}\n\treturn ndims;\n}\n\n\n// MAIN //\n\n/**\n* Determines (nested) array dimensions.\n*\n* @param {ArrayLikeObject} arr - array\n* @throws {TypeError} must provide an array\n* @returns {Array} array shape\n*\n* @example\n* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ];\n*\n* var shape = arrayShape( arr );\n* // returns [ 3, 3 ]\n*\n* @example\n* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ];\n*\n* var shape = arrayShape( arr );\n* // returns [ 3 ]\n*\n* @example\n* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], null ];\n*\n* var shape = arrayShape( arr );\n* // returns [ 3 ]\n*/\nfunction arrayShape( arr ) {\n\tvar shape;\n\tvar ndims;\n\n\tif ( !isArrayLikeObject( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\t// Initialize the shape/dimensions array:\n\tshape = [ arr.length ];\n\n\t// Eagerly determine array dimensions:\n\trecurse( shape, arr );\n\tndims = shape.length;\n\n\t// Check that all array element dimensions are consistent:\n\tif ( ndims > 1 ) {\n\t\t// If `check()` returns a value less than `ndims`, trim off the inconsistent dimensions:\n\t\tshape.length = check( ndims, shape, 1, arr, ndims > 2 );\n\t}\n\treturn shape;\n}\n\n\n// EXPORTS //\n\nexport default arrayShape;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasSharedArrayBuffer = ( typeof SharedArrayBuffer === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a `SharedArrayBuffer`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a `SharedArrayBuffer`\n*\n* @example\n* import SharedArrayBuffer from '@stdlib/array/shared-buffer';\n*\n* try {\n* var bool = isSharedArrayBuffer( new SharedArrayBuffer( 10 ) );\n* // returns true\n* } catch ( err ) {\n* console.log( 'Environment does not support SharedArrayBuffers.' );\n* }\n*\n* @example\n* var bool = isSharedArrayBuffer( [] );\n* // returns false\n*/\nfunction isSharedArrayBuffer( value ) {\n\treturn (\n\t\t( hasSharedArrayBuffer && value instanceof SharedArrayBuffer ) || // eslint-disable-line stdlib/require-globals, no-undef\n\t\tnativeClass( value ) === '[object SharedArrayBuffer]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isSharedArrayBuffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof SharedArrayBuffer === 'function' ) ? SharedArrayBuffer : null; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Constructor returning an object used to represent a generic, fixed-length raw binary data buffer which can be used to create views of shared memory.\n*\n* @module @stdlib/array/shared-buffer\n*\n* @example\n* import ctor from '@stdlib/array/shared-buffer';\n*\n* var buf;\n* try {\n* buf = new ctor( 10 );\n* // returns \n* } catch ( err ) {\n* console.log( 'Environment does not support SharedArrayBuffers.' );\n* }\n*/\n\n// MODULES //\n\nimport hasSharedArrayBufferSupport from '@stdlib/assert/has-sharedarraybuffer-support'; // eslint-disable-line id-length\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasSharedArrayBufferSupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof SharedArrayBuffer === 'function' ) ? SharedArrayBuffer : null; // eslint-disable-line stdlib/require-globals, no-undef\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isSharedArrayBuffer from './../../is-sharedarraybuffer';\nimport GlobalSharedArrayBuffer from './sharedarraybuffer.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `SharedArrayBuffer` support.\n*\n* @returns {boolean} boolean indicating if an environment has `SharedArrayBuffer` support\n*\n* @example\n* var bool = hasSharedArrayBufferSupport();\n* // returns \n*/\nfunction hasSharedArrayBufferSupport() { // eslint-disable-line id-length\n\tvar bool;\n\tvar b1;\n\tvar b2;\n\n\tif ( typeof GlobalSharedArrayBuffer !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tb1 = new GlobalSharedArrayBuffer( 16 );\n\t\tb2 = b1.slice( 4, 8 );\n\t\tbool = (\n\t\t\tisSharedArrayBuffer( b1 ) &&\n\t\t\tisSharedArrayBuffer( b2 ) &&\n\t\t\tb1.byteLength === 16 &&\n\t\t\tb2.byteLength === 4\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasSharedArrayBufferSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Constructor returning an object used to represent a generic, fixed-length raw binary data buffer which can be used to create views of shared memory.\n*\n* @param {NonNegativeInteger} size - number of bytes\n* @throws {Error} not implemented\n*/\nfunction polyfill( size ) { // eslint-disable-line no-unused-vars\n\tthrow new Error( 'not supported. The current environment does not support SharedArrayBuffers, and, unfortunately, SharedArrayBuffers cannot be polyfilled. For shared memory applications, upgrade your runtime environment to one which supports SharedArrayBuffers.' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/take';\nimport zeros from './../../zeros';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Takes elements from an array.\n*\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {Options} [options] - function options\n* @param {string} [options.mode='normalize'] - index mode\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var y = take( x, indices );\n* // returns [ 4, 2, 3, 1 ]\n*/\nfunction take( x, indices ) {\n\tvar opts;\n\tvar err;\n\tvar dt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( indices ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', indices ) );\n\t}\n\topts = defaults();\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, arguments[ 2 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tdt = dtype( x );\n\tif ( dt === 'generic' || dt === null ) {\n\t\treturn base( x, indices, opts.mode );\n\t}\n\treturn base.assign( x, indices, opts.mode, zeros( indices.length, dt ), 1, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default take;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'mode': 'normalize'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport isIndexMode from '@stdlib/ndarray/base/assert/is-index-mode';\nimport modes from '@stdlib/ndarray/index-modes';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.mode] - index mode\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'mode': 'normalize'\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\topts.mode = options.mode;\n\t\tif ( !isIndexMode( opts.mode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'mode', modes().join( '\", \"' ), opts.mode ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Alias for `eval` global.\n*\n* @module @stdlib/utils/eval\n*\n* @example\n* import evil from '@stdlib/utils/eval';\n*\n* var v = evil( '5*4*3*2*1' );\n* // returns 120\n*/\n\n// MODULES //\n\nvar evil = eval; // eslint-disable-line no-eval\n\n\n// EXPORTS //\n\nexport default evil;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Proxy object.\n*\n* @module @stdlib/proxy/ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy/ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert/has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport evil from '@stdlib/utils/eval';\n\n\n// MAIN //\n\n/**\n* Tests for native `Proxy` support.\n*\n* @returns {boolean} boolean indicating if an environment has native `Proxy` support\n*\n* @example\n* var bool = hasProxySupport();\n* // returns \n*/\nfunction hasProxySupport() {\n\tvar bool;\n\ttry {\n\t\tevil( '\"use strict\"; var handler = { \"get\": function get( t, n ) { return t[ n ] * 100; } }; var target = { \"beep\": 3.14 }; var p = new Proxy( target, handler ); var x = p.beep; if ( x !== 314 ) { throw new Error( \"native Proxy is not supported.\" ); }' );\n\t\tbool = true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasProxySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Copy enumerable own properties from one or more source objects to a target object.\n*\n* @module @stdlib/object/assign\n*\n* @example\n* import assign from '@stdlib/object/assign';\n*\n* var out = assign( {}, { 'foo': 'bar' }, { 'baz': 'beep' } );\n* // returns { 'foo': 'bar', 'baz': 'beep' }\n*/\n\n// MODULES //\n\nimport hasObjectAssign from './has_object_assign.js';\nimport main from './builtin.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar assign;\nif ( hasObjectAssign ) {\n\tassign = main;\n} else {\n\tassign = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert/is-function';\n\n\n// MAIN //\n\nvar bool = isFunction( Object.assign ); // eslint-disable-line node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies own enumerable properties from source objects to a target object.\n*\n* ## Notes\n*\n* - If a property key is present in multiple sources, the property from the last source that defines the key prevails.\n* - The target object is mutated.\n* - Both string and symbol properties are copied.\n*\n* @name assign\n* @type {Function}\n* @param {Object} target - target object\n* @param {...Object} source - source object(s)\n* @throws {TypeError} first argument must not be null or undefined\n* @returns {Object} target object\n*\n* @example\n* var obj1 = {\n* 'a': 'beep'\n* };\n* var obj2 = {\n* 'b': 'boop'\n* };\n*\n* var out = assign( obj1, obj2 );\n* // returns { 'a': 'beep', 'b': 'boop' }\n*/\nvar assign = Object.assign; // eslint-disable-line node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar bool = ( typeof Object.getOwnPropertySymbols !== 'undefined' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Object from '@stdlib/object/ctor';\n\n\n// VARIABLES //\n\nvar propertySymbols = Object.getOwnPropertySymbols;\n\n\n// MAIN //\n\n/**\n* Returns an array of an object's own symbol properties.\n*\n* ## Notes\n*\n* - In contrast to the built-in `Object.getOwnPropertySymbols()`, this function returns an empty array if provided `undefined` or `null`, rather than throwing an error.\n*\n* @private\n* @param {*} value - input object\n* @returns {Array} a list of own symbol properties\n*\n* @example\n* var symbols = getOwnPropertySymbols( {} );\n*/\nfunction getOwnPropertySymbols( value ) {\n\treturn propertySymbols( Object( value ) );\n}\n\n\n// EXPORTS //\n\nexport default getOwnPropertySymbols;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return an array of an object's own symbol properties.\n*\n* @module @stdlib/utils/property-symbols\n*\n* @example\n* import getOwnPropertySymbols from '@stdlib/utils/property-symbols';\n*\n* var symbols = getOwnPropertySymbols( {} );\n*/\n\n// MODULES //\n\nimport HAS_BUILTIN from './has_builtin.js';\nimport builtin from './builtin.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar main;\nif ( HAS_BUILTIN ) {\n\tmain = builtin;\n} else {\n\tmain = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of an object's own symbol properties.\n*\n* ## Notes\n*\n* - In contrast to the built-in `Object.getOwnPropertySymbols()`, this function returns an empty array if provided `undefined` or `null`, rather than throwing an error.\n*\n* @private\n* @param {*} value - input object\n* @returns {EmptyArray} a list of own symbol properties\n*\n* @example\n* var symbols = getOwnPropertySymbols( {} );\n* // returns []\n*/\nfunction getOwnPropertySymbols() {\n\treturn [];\n}\n\n\n// EXPORTS //\n\nexport default getOwnPropertySymbols;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport keys from './../../keys';\nimport propertySymbols from './../../property-symbols';\nimport isEnumerable from '@stdlib/assert/is-enumerable-property';\n\n\n// MAIN //\n\n/**\n* Returns an array of an object's own enumerable property names and symbols.\n*\n* @param {*} value - input object\n* @returns {Array} a list of own property enumerable names and symbols\n*\n* @example\n* var obj = {\n* 'beep': 'boop',\n* 'foo': 3.14\n* };\n*\n* var props = enumerableProperties( obj );\n* // e.g., returns [ 'beep', 'foo' ]\n*/\nfunction enumerableProperties( value ) {\n\tvar out;\n\tvar tmp;\n\tvar i;\n\n\tout = keys( value );\n\ttmp = propertySymbols( value );\n\tfor ( i = 0; i < tmp.length; i++ ) {\n\t\tif ( isEnumerable( value, tmp[ i ] ) ) {\n\t\t\tout.push( tmp[ i ] );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default enumerableProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport enumerableProperties from '@stdlib/utils/enumerable-properties';\nimport Object from './../../ctor';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Copies own enumerable properties from source objects to a target object.\n*\n* ## Notes\n*\n* - If a property key is present in multiple sources, the property from the last source that defines the key prevails.\n* - The target object is mutated.\n* - Both string and symbol properties are copied.\n*\n* @param {Object} target - target object\n* @param {...Object} source - source object(s)\n* @throws {TypeError} first argument must not be null or undefined\n* @returns {Object} target object\n*\n* @example\n* var obj1 = {\n* 'a': 'beep'\n* };\n* var obj2 = {\n* 'b': 'boop'\n* };\n*\n* var out = assign( obj1, obj2 );\n* // returns { 'a': 'beep', 'b': 'boop' }\n*/\nfunction assign( target ) {\n\tvar source;\n\tvar keys;\n\tvar key;\n\tvar len;\n\tvar to;\n\tvar i;\n\tvar j;\n\tif ( target === void 0 || target === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a non-null object. Value: `%s`.', target ) );\n\t}\n\tto = Object( target );\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\tsource = arguments[ i ];\n\t\tif ( source === void 0 || source === null ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tkeys = enumerableProperties( Object( source ) );\n\t\tlen = keys.length;\n\t\tfor ( j = 0; j < len; j++ ) {\n\t\t\tkey = keys[ j ];\n\t\t\tto[ key ] = source[ key ];\n\t\t}\n\t}\n\treturn to;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\n\n\n// FUNCTIONS //\n\n/**\n* Normalizes values assigned to complex number arrays.\n*\n* @private\n* @param {*} value - input value\n* @returns {(ComplexLike|*)} output value\n*/\nfunction wrapComplex( value ) {\n\t// Wrap real-valued scalars as valid input arguments to complex number arrays...\n\tif ( isNumber( value ) ) {\n\t\treturn [ value, 0.0 ]; // note: we're assuming that a ComplexXXArray setter accepts an array of interleaved real and imaginary components\n\t}\n\t// For everything other than a real-valued scalar, we delegate validation to the target complex number array:\n\treturn value;\n}\n\n\n// MAIN //\n\n/**\n* Returns a wrapper function for processing scalar input values before assignment.\n*\n* @private\n* @param {string} dtype - array data type\n* @returns {(Function|null)} wrapper function or null\n*/\nfunction wrapper( dtype ) {\n\tif ( isComplexDataType( dtype ) ) {\n\t\treturn wrapComplex;\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default wrapper;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a wrapper function for processing arrays after retrieval.\n*\n* @private\n* @param {Function} array2fancy - function for creating a proxied array\n* @param {Object} opts - options\n* @param {boolean} opts.strict - boolean indicating whether to perform strict bounds checking\n* @param {Function} opts.cache - cache for resolving array index objects\n* @returns {Function} wrapper function\n*/\nfunction wrapper( array2fancy, opts ) {\n\treturn wrap;\n\n\t/**\n\t* Returns a proxied array.\n\t*\n\t* @private\n\t* @param {Array} x - input array\n\t* @returns {Array} proxied array\n\t*/\n\tfunction wrap( x ) {\n\t\treturn array2fancy( x, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default wrapper;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Proxy from '@stdlib/proxy/ctor';\n\n\n// MAIN //\n\n/**\n* Boolean indicating if an environment has Proxy support.\n*\n* @private\n* @name hasSupport\n* @type {boolean}\n*/\nvar hasSupport = ( typeof Proxy === 'function' ); // NOTE: cannot use `@stdlib/assert/has-proxy-support` here, as that API uses code evaluation and might violate CSPs; consequently, this is a relatively weak check for proxy support\n\n\n// EXPORTS //\n\nexport default hasSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport isMethodIn from '@stdlib/assert/is-method-in';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking\n* @param {Function} [options.cache] - cache for resolving array index objects\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'strict': false\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\topts.strict = options.strict;\n\t\tif ( !isBoolean( opts.strict ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', opts.strict ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'cache' ) ) {\n\t\topts.cache = options.cache;\n\t\tif ( !isMethodIn( opts.cache, 'get' ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option is missing a `%s` method. Option: `%s`.', 'cache', 'get', opts.cache ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from './../../is-function';\nimport Object from '@stdlib/object/ctor';\n\n\n// MAIN //\n\n/**\n* Tests if an object has a specified method name, either own or inherited.\n*\n* @param {*} value - value to test\n* @param {*} property - property to test\n* @returns {boolean} boolean indicating if an object has a specified method name\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = isMethodIn( beep, 'toString' );\n* // returns true\n*\n* bool = isMethodIn( beep, 'boop' );\n* // returns false\n*/\nfunction isMethodIn( value, property ) {\n\tif ( value === void 0 || value === null ) {\n\t\treturn false;\n\t}\n\tvalue = Object( value );\n\tif ( typeof property !== 'symbol' ) {\n\t\tproperty = String( property );\n\t}\n\treturn (\n\t\t( property in value ) &&\n\t\tisFunction( value[ property ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isMethodIn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport isRealFloatingDataType from './../../base/assert/is-real-floating-point-data-type';\nimport isUnsignedIntegerDataType from './../../base/assert/is-unsigned-integer-data-type';\nimport isSignedIntegerDataType from './../../base/assert/is-signed-integer-data-type';\nimport isBooleanDataType from './../../base/assert/is-boolean-data-type';\nimport isSafeCast from './../../base/assert/is-safe-data-type-cast';\nimport minDataType from './../../min-dtype';\nimport minSignedIntegerDataType from './../../base/min-signed-integer-dtype';\nimport complexDataType from '@stdlib/complex/dtype';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a \"generic\" or unknown data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {null} null\n*\n* @example\n* var err = validateGeneric( 3, 'generic' );\n* // returns null\n*/\nfunction validateGeneric() {\n\treturn null;\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a boolean data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateBoolean( true, 'bool' );\n* // returns null\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var err = validateBoolean( new Complex128( 5.0, 6.0 ), 'bool' );\n* // returns \n*/\nfunction validateBoolean( value, dtype ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a real-valued floating-point data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateRealFloating( 3.14, 'float64' );\n* // returns null\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var err = validateRealFloating( new Complex128( 5.0, 6.0 ), 'float64' );\n* // returns \n*/\nfunction validateRealFloating( value, dtype ) {\n\tif ( isNumber( value ) ) {\n\t\treturn null;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a complex-valued floating-point data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var err = validateComplexFloating( new Complex128( 5.0, 6.0 ), 'complex128' );\n* // returns null\n*\n* @example\n* var err = validateComplexFloating( {}, 'complex128' );\n* // returns \n*/\nfunction validateComplexFloating( value, dtype ) {\n\tif ( isNumber( value ) || isComplexLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a signed integer data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateSignedInteger( 3, 'int32' );\n* // returns null\n*\n* @example\n* var err = validateSignedInteger( 3.14, 'int32' );\n* // returns \n*/\nfunction validateSignedInteger( value, dtype ) {\n\tvar vdt;\n\tif ( isNumber( value ) ) {\n\t\tif ( !isInteger( value ) ) {\n\t\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', minDataType( value ), dtype ) );\n\t\t}\n\t\tvdt = minSignedIntegerDataType( value );\n\t\tif ( isSafeCast( vdt, dtype ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) );\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having an unsigned integer data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateUnsignedInteger( 3, 'uint32' );\n* // returns null\n*\n* @example\n* var err = validateUnsignedInteger( -3, 'uint32' );\n* // returns \n*/\nfunction validateUnsignedInteger( value, dtype ) {\n\tvar vdt;\n\tif ( isNumber( value ) ) {\n\t\tvdt = minDataType( value ); // note: we rely on data type resolution to handle the case where `value` is a non-integer value. In that case, `vdt` will resolve to a floating-point data type and `isSafeCast` will evaluate to `false`\n\t\tif ( isSafeCast( vdt, dtype ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) );\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n\n// MAIN //\n\n/**\n* Returns a validation function for verifying whether a provided value can be safely assigned to an element in an array having a specified data type.\n*\n* @private\n* @param {string} dtype - array data type\n* @returns {Function} validation function\n*\n* @example\n* var fcn = validator( 'int32' );\n*\n* var err = fcn( 3, 'int32' );\n* // returns null\n*\n* err = fcn( 3.14, 'int32' );\n* // returns \n*/\nfunction validator( dtype ) {\n\tif ( dtype === 'generic' || dtype === '' ) {\n\t\treturn validateGeneric;\n\t}\n\tif ( isRealFloatingDataType( dtype ) ) {\n\t\treturn validateRealFloating;\n\t}\n\tif ( isUnsignedIntegerDataType( dtype ) ) {\n\t\treturn validateUnsignedInteger;\n\t}\n\tif ( isSignedIntegerDataType( dtype ) ) {\n\t\treturn validateSignedInteger;\n\t}\n\tif ( isBooleanDataType( dtype ) ) {\n\t\treturn validateBoolean;\n\t}\n\t// Case: isComplexDataType( dtype ) === true\n\treturn validateComplexFloating;\n}\n\n\n// EXPORTS //\n\nexport default validator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a trap for constructing new array instances.\n*\n* @private\n* @param {Function} array2fancy - function for creating a proxied array\n* @param {Object} opts - options\n* @param {boolean} opts.strict - boolean indicating whether to perform strict bounds checking\n* @param {Function} opts.cache - cache for resolving array index objects\n* @returns {Function} handler\n*/\nfunction factory( array2fancy, opts ) {\n\treturn constructor;\n\n\t/**\n\t* Trap for constructing new array instances.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {Array} args - list of constructor arguments\n\t* @param {Object} newTarget - constructor that was originally called\n\t* @returns {*} new instance\n\t*/\n\tfunction constructor( target, args ) {\n\t\tvar x;\n\t\tvar a;\n\n\t\ta = args;\n\t\tswitch ( a.length ) {\n\t\tcase 0:\n\t\t\tx = new target();\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tx = new target( a[0] );\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tx = new target( a[0], a[1] );\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tx = new target( a[0], a[1], a[2] );\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tx = new target( a[0], a[1], a[2], a[3] );\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4] );\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5] );\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6] );\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7] );\n\t\t\tbreak;\n\t\tcase 9:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8] ); // eslint-disable-line max-len\n\t\t\tbreak;\n\t\tcase 10:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9] ); // eslint-disable-line max-len\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t// Fallback to using `apply`; however, some constructors may error if the constructor is not callable (i.e., if a constructor always requires `new`):\n\t\t\tx = target.apply( null, a );\n\t\t}\n\t\treturn array2fancy( x, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is an integer string.\n*\n* @private\n* @name RE_INTEGER\n* @type {RegExp}\n*\n* @example\n* var bool = RE_INTEGER.test( '10' );\n* // returns true\n*\n* @example\n* var bool = RE_INTEGER.test( '-1' );\n* // returns true\n*\n* @example\n* var bool = RE_INTEGER.test( '0:10:2' );\n* // returns false\n*/\nvar RE_INTEGER = /^-?[0-9]+$/;\n\n\n// EXPORTS //\n\nexport default RE_INTEGER;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport RE_INTEGER from './re_integer.js';\n\n\n// MAIN //\n\n/**\n* Tests if an indexing expression is an integer.\n*\n* @private\n* @param {(string|symbol)} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isIntegerString( '1' );\n* // returns true\n*\n* @example\n* var out = isIntegerString( ':' );\n* // returns false\n*/\nfunction isIntegerString( prop ) {\n\treturn ( isString( prop ) && RE_INTEGER.test( prop ) );\n}\n\n\n// EXPORTS //\n\nexport default isIntegerString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is a serialized array index.\n*\n* @private\n* @name RE_ARRAY_INDEX\n* @type {RegExp}\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( 'ArrayIndex<0>' );\n* // returns true\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( '0' );\n* // returns false\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( 'Slice(0,10,2)' );\n* // returns false\n*/\nvar RE_ARRAY_INDEX = /\\s*ArrayIndex<[^>]+>\\s*/;\n\n\n// EXPORTS //\n\nexport default RE_ARRAY_INDEX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport RE_ARRAY_INDEX from './re_array_index.js';\n\n\n// MAIN //\n\n/**\n* Tests if an indexing expression is a serialized array index.\n*\n* @private\n* @param {(string|symbol)} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isArrayIndexString( 'ArrayIndex<0>' );\n* // returns true\n*\n* @example\n* var out = isArrayIndexString( ':' );\n* // returns false\n*/\nfunction isArrayIndexString( prop ) {\n\treturn ( isString( prop ) && RE_ARRAY_INDEX.test( prop ) );\n}\n\n\n// EXPORTS //\n\nexport default isArrayIndexString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar bool = ( typeof String.prototype.trim !== 'undefined' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar trim = String.prototype.trim;\n\n\n// EXPORTS //\n\nexport default trim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from './../../../base/replace';\n\n\n// VARIABLES //\n\n// The following regular expression should suffice to polyfill (most?) all environments.\nvar RE = /^[\\u0020\\f\\n\\r\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]*([\\S\\s]*?)[\\u0020\\f\\n\\r\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]*$/;\n\n\n// MAIN //\n\n/**\n* Trims whitespace characters from the beginning and end of a string.\n*\n* @private\n* @param {string} str - input string\n* @returns {string} trimmed string\n*\n* @example\n* var out = trim( ' Whitespace ' );\n* // returns 'Whitespace'\n*\n* @example\n* var out = trim( '\\t\\t\\tTabs\\t\\t\\t' );\n* // returns 'Tabs'\n*\n* @example\n* var out = trim( '\\n\\n\\nNew Lines\\n\\n\\n' );\n* // returns 'New Lines'\n*/\nfunction trim( str ) {\n\treturn replace( str, RE, '$1' );\n}\n\n\n// EXPORTS //\n\nexport default trim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Trim whitespace characters from the beginning and end of a string.\n*\n* @module @stdlib/string/base/trim\n*\n* @example\n* import trim from '@stdlib/string/base/trim';\n*\n* var out = trim( ' Whitespace ' );\n* // returns 'Whitespace'\n*\n* out = trim( '\\t\\t\\tTabs\\t\\t\\t' );\n* // returns 'Tabs'\n*\n* out = trim( '\\n\\n\\nNew Lines\\n\\n\\n' );\n* // returns 'New Lines'\n*/\n\n// MODULES //\n\nimport HAS_BUILTIN from './has_builtin.js';\nimport check from './check.js';\nimport polyfill from './polyfill.js';\nimport main from './main.js';\n\n\n// MAIN //\n\nvar trim;\nif ( HAS_BUILTIN && check() ) {\n\ttrim = main;\n} else {\n\ttrim = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default trim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport trim from './builtin.js';\n\n\n// VARIABLES //\n\nvar str1 = ' \\n\\t\\r\\n\\f\\v\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff';\nvar str2 = '\\u180e';\n\n\n// MAIN //\n\n/**\n* Tests the built-in `String.prototype.trim()` implementation when provided whitespace.\n*\n* ## Notes\n*\n* - For context, see . In short, we can only rely on the built-in `trim` method when it does not consider the Mongolian space separator as whitespace.\n*\n* @private\n* @returns {boolean} boolean indicating whether the built-in implementation returns the expected value\n*\n* @example\n* var b = test();\n* // returns \n*/\nfunction test() {\n\treturn ( trim.call( str1 ) === '' ) && ( trim.call( str2 ) === str2 );\n}\n\n\n// EXPORTS //\n\nexport default test;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport builtin from './builtin.js';\n\n\n// MAIN //\n\n/**\n* Trims whitespace characters from the beginning and end of a string.\n*\n* @param {string} str - input string\n* @returns {string} trimmed string\n*\n* @example\n* var out = trim( ' Whitespace ' );\n* // returns 'Whitespace'\n*\n* @example\n* var out = trim( '\\t\\t\\tTabs\\t\\t\\t' );\n* // returns 'Tabs'\n*\n* @example\n* var out = trim( '\\n\\n\\nNew Lines\\n\\n\\n' );\n* // returns 'New Lines'\n*/\nfunction trim( str ) {\n\treturn builtin.call( str );\n}\n\n\n// EXPORTS //\n\nexport default trim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport trim from '@stdlib/string/base/trim';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Extracts an array index identifier from an array index indexing expression.\n*\n* @private\n* @param {string} str - input string\n* @returns {string} identifier\n*\n* @example\n* var str = 'ArrayIndex<0>';\n*\n* var id = getIdentifier( str );\n* // returns '0'\n*/\nfunction getIdentifier( str ) {\n\treturn str.substring( 11, str.length-1 ); // ArrayIndex => XX\n}\n\n\n// MAIN //\n\n/**\n* Converts an indexing expression to an array index.\n*\n* @private\n* @param {string} property - property name\n* @param {Object} cache - cache for resolving array index objects\n* @throws {Error} invalid array index\n* @returns {(Object|null)} index object (or null)\n*/\nfunction prop2array( property, cache ) {\n\tvar o = cache.get( getIdentifier( trim( property ) ) );\n\tif ( o === null ) {\n\t\tthrow new Error( format( 'invalid operation. Unable to resolve array index. Value: `%s`.', property ) );\n\t}\n\treturn o;\n}\n\n\n// EXPORTS //\n\nexport default prop2array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Resolves an integer index from an integer string.\n*\n* @private\n* @param {string} str - integer string\n* @param {NonNegativeInteger} max - index upper bound (exclusive)\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {RangeError} index exceeds array bounds\n* @returns {integer} integer index\n*\n* @example\n* var idx = resolveIndex( '-1', 10, false );\n* // returns 9\n*\n* @example\n* var idx = resolveIndex( '-20', 10, false );\n* // returns -20\n*/\nfunction resolveIndex( str, max, strict ) {\n\tvar idx;\n\tvar i;\n\n\tidx = parseInt( str, 10 );\n\ti = normalizeIndex( idx, max-1 );\n\tif ( i === -1 ) {\n\t\tif ( strict ) {\n\t\t\tthrow new RangeError( format( 'invalid operation. Index exceeds array bounds.' ) );\n\t\t}\n\t\t// Return the non-normalized index, as this should fallback to default property handling and returning \"undefined\":\n\t\treturn idx;\n\t}\n\treturn i;\n}\n\n\n// EXPORTS //\n\nexport default resolveIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string/base/replace';\n\n\n// MAIN //\n\n/**\n* Returns an updated error message for trapped errors.\n*\n* @private\n* @param {string} msg - error message\n* @returns {string} updated message\n*/\nfunction errMessage( msg ) {\n\treturn replace( msg, /^invalid arguments?/, 'invalid operation' );\n}\n\n\n// EXPORTS //\n\nexport default errMessage;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Matches a subtraction operation following an 'end' character sequence.\n*\n* Regular expression: `/(?:\\s*-\\s*)(?=\\d+)(\\d+)?$/`\n*\n* - `(?:\\s*-\\s*)`\n*\n* - capture but do not remember a minus sign surrounded by any amount of whitespace\n*\n* - `(?=\\d+)`\n*\n* - but only match when the minus sign is followed by one or more digits\n*\n* - `(\\d+)`\n*\n* - capture one or more digits\n*\n* - `$`\n*\n* - end of input\n*\n* @private\n* @name RE_END_MINUS\n* @type {RegExp}\n*\n* @example\n* var m = 'end-2'.match( RE_END_MINUS );\n* // returns [...]\n*\n* var v = m[ 1 ];\n* // returns '2'\n*\n* m = 'end - 2'.match( RE_END_MINUS );\n* // returns [...]\n*\n* v = m[ 1 ];\n* // returns '2'\n*\n* m = 'end - 2.4'.match( RE_END_MINUS );\n* // returns null\n*/\nvar RE_END_MINUS = /(?:\\s*-\\s*)(?=\\d+)(\\d+)$/;\n\n\n// EXPORTS //\n\nexport default RE_END_MINUS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Matches a division operation following an 'end' character sequence.\n*\n* Regular expression: `/(?:\\s*\\/\\s*)(?=\\d*\\.?\\d+)(\\d*\\.?\\d+)?$/`\n*\n* - `(?:\\s*\\/\\s*)`\n*\n* - capture but do not remember a divide sign surrounded by any amount of whitespace\n*\n* - `(?=\\d*\\.?\\d+)`\n*\n* - but only match when the minus divide is followed by one or more digits\n*\n* - `(\\d*\\.?\\d+)`\n*\n* - capture one or more digits\n*\n* - `$`\n*\n* - end of input\n*\n* @private\n* @name RE_END_DIVIDE\n* @type {RegExp}\n*\n* @example\n* var m = 'end/2'.match( RE_END_DIVIDE );\n* // returns [...]\n*\n* var v = m[ 1 ];\n* // returns '2'\n*\n* m = 'end / 2'.match( RE_END_DIVIDE );\n* // returns [...]\n*\n* v = m[ 1 ];\n* // returns '2'\n*\n* m = 'end / 2.4'.match( RE_END_DIVIDE );\n* // returns [...]\n*\n* v = m[ 1 ];\n* // returns '2.4'\n*/\nvar RE_END_DIVIDE = /(?:\\s*\\/\\s*)(?=\\d*\\.?\\d+)(\\d*\\.?\\d+)$/;\n\n\n// EXPORTS //\n\nexport default RE_END_DIVIDE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math/base/special/floor';\nimport RE_END_MINUS from './re_end_minus.js';\nimport RE_END_DIVIDE from './re_end_divide.js';\n\n\n// MAIN //\n\n/**\n* Resolves an \"end\" index.\n*\n* ## Notes\n*\n* - The function returns `-1` if provided an invalid character sequence.\n* - The function returns `-2` if the resolved end index is out-of-bounds.\n*\n* @private\n* @param {string} v - character sequence containing the \"end\" keyword\n* @param {NonNegativeInteger} len - maximum number of elements allowed in the slice\n* @param {boolean} decrement - boolean indicating whether a subsequence has a negative decrement\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @returns {NonNegativeInteger} end index (exclusive)\n*\n* @example\n* var idx = resolveEnd( 'end', 10, false, false );\n* // returns 10\n*\n* idx = resolveEnd( 'end', 10, true, false );\n* // returns 10\n*\n* @example\n* var idx = resolveEnd( 'end-1', 10, false, false );\n* // returns 9\n*\n* idx = resolveEnd( 'end-1', 10, true, false );\n* // returns 9\n*\n* @example\n* var idx = resolveEnd( 'end-2', 10, false, false );\n* // returns 8\n*\n* idx = resolveEnd( 'end-2', 10, true, false );\n* // returns 8\n*\n* @example\n* var idx = resolveEnd( 'end/2', 10, false, false );\n* // returns 5\n*\n* idx = resolveEnd( 'end/2', 10, true, false );\n* // returns 4\n*\n* @example\n* var idx = resolveEnd( 'end/2', 11, false, false );\n* // returns 5\n*\n* idx = resolveEnd( 'end/2', 11, true, false );\n* // returns 5\n*\n* @example\n* var idx = resolveEnd( 'end/3', 10, false, false );\n* // returns 3\n*\n* idx = resolveEnd( 'end/3', 10, true, false );\n* // returns 3\n*\n* @example\n* var idx = resolveEnd( 'end/3', 11, false, false );\n* // returns 3\n*\n* idx = resolveEnd( 'end/3', 11, true, false );\n* // returns 3\n*\n* @example\n* var idx = resolveEnd( 'end/4', 10, false, false );\n* // returns 2\n*\n* idx = resolveEnd( 'end/4', 10, true, false );\n* // returns 2\n*\n* @example\n* var idx = resolveEnd( 'end/4', 11, false, false );\n* // returns 2\n*\n* idx = resolveEnd( 'end/4', 11, true, false );\n* // returns 2\n*\n* @example\n* var idx = resolveEnd( 'end/5', 10, false, false );\n* // returns 2\n*\n* idx = resolveEnd( 'end/5', 10, true, false );\n* // returns 1\n*\n* @example\n* var idx = resolveEnd( 'end/5', 11, false, false );\n* // returns 2\n*\n* idx = resolveEnd( 'end/5', 11, true, false );\n* // returns 2\n*\n* @example\n* var idx = resolveEnd( 'end-20', 10, false, false );\n* // returns 0\n*\n* idx = resolveEnd( 'end-20', 10, true, false );\n* // returns 0\n*\n* idx = resolveEnd( 'end-20', 10, true, true );\n* // returns -2\n*\n* @example\n* var idx = resolveEnd( 'end*2', 10, false, false );\n* // returns -1\n*\n* idx = resolveEnd( 'end*2', 10, true, false );\n* // returns -1\n*\n* @example\n* var idx = resolveEnd( 'end+1', 10, false, false );\n* // returns -1\n*\n* idx = resolveEnd( 'end+1', 10, true, false );\n* // returns -1\n*\n* @example\n* var idx = resolveEnd( 'end/0.5', 10, false, false );\n* // returns -1\n*\n* idx = resolveEnd( 'end/0.5', 10, true, false );\n* // returns -1\n*\n* idx = resolveEnd( 'end/0.5', 10, true, true );\n* // returns -2\n*/\nfunction resolveEnd( v, len, decrement, strict ) {\n\tvar tmp;\n\n\t// Check for the simple case where \"end\" refers to the last index (exclusive)...\n\tif ( v === 'end' ) {\n\t\treturn len;\n\t}\n\t// Check for a subtraction operation (e.g., `end-2`)...\n\ttmp = v.match( RE_END_MINUS );\n\tif ( tmp ) {\n\t\tv = len - parseInt( tmp[ 1 ], 10 );\n\n\t\t// If the computed index exceeds the index bounds, clamp to the first index...\n\t\tif ( v < 0 ) {\n\t\t\tif ( strict ) {\n\t\t\t\treturn -2; // return out-of-bounds error code\n\t\t\t}\n\t\t\tv = 0;\n\t\t}\n\t\treturn v;\n\t}\n\t// Check for a division operation (e.g., `end/2`)...\n\ttmp = v.match( RE_END_DIVIDE );\n\tif ( tmp ) {\n\t\tv = parseFloat( tmp[ 1 ] );\n\t\tif ( v < 1.0 ) {\n\t\t\treturn ( strict ) ? -2 : -1; // if `end/x > end`, then need to return out-of-bounds error code\n\t\t}\n\t\t// Handle division differently for increasing and decreasing increments in order to preserve the `:n + n: = :` identity and to satisfy user expectation that symmetry be maintained. The main issue being that, e.g., given a length 10 subsequence, `end/2` will yield `5`. Hence, `:end/2 + end/2: = :5 + :5 = :` (i.e., the first five elements (0,1,2,3,4) and the second five elements (5,6,7,8,9)); however, if increasing and decreasing are treated the same, `:end/2:-1 + end/2::-1 = :5:-1 + 5::-1 = :`, but the elements are not the same (i.e., the first elements (9,8,7,6) and the second elements (5,4,3,2,1)), due to the non-inclusive aspect of `j` in `i:j:k`. The slight adjustment (`len-1`) yields `:4:-1 + 4::-1 = :` and the slices (9,8,7,6,5) and (4,3,2,1,0), which better matches user expectation. For a length 11 subsequence, we get (0,1,2,3,4) and (5,6,7,8,9,10) for an increasing increment and (10,9,8,7,6) and (5,4,3,2,1,0), which seems fine given asymmetry in both cases.\n\t\tif ( decrement && len > 0 && v !== 1.0 ) { // note: avoid violating `end/1 = end` identity\n\t\t\treturn floor( (len-1) / v );\n\t\t}\n\t\treturn floor( len / v );\n\t}\n\t// The use of \"end\" includes invalid/unsupported operations...\n\treturn -1;\n}\n\n\n// EXPORTS //\n\nexport default resolveEnd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Matches a character sequence for a colon separator used within a provided subsequence string.\n*\n* Regular expression: `\\s*:\\s*`\n*\n* - `\\s*`\n*\n* - match zero or more whitespace characters\n*\n* - `:`\n*\n* - match the colon character exactly\n*\n* - `\\s*`\n*\n* - match zero or more whitespace characters\n*\n* ## Notes\n*\n* - The regular expression allows for whitespace to surround the `:` character in subsequence strings (e.g., '2 : 4 : 1' vs '2:4:1').\n*\n* @private\n* @name RE_COLON_SEP\n* @type {RegExp}\n*\n* @example\n* var parts = ':'.split( RE_COLON_SEP );\n* // returns [ '', '' ]\n*\n* parts = ' : '.split( RE_COLON_SEP );\n* // returns [ '', '' ]\n*/\nvar RE_COLON_SEP = /\\s*:\\s*/;\n\n\n// EXPORTS //\n\nexport default RE_COLON_SEP;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Matches a character sequence for an integer value.\n*\n* Regular expression: `/^[-+]?\\d+$/`\n*\n* - `^`\n*\n* - start of input\n*\n* - `[-+]?`\n*\n* - match a minus or plus sign (if present)\n*\n* - `\\d+`\n*\n* - match one or more digits\n*\n* - `$`\n*\n* - end of input\n*\n* @private\n* @name RE_INTEGER\n* @type {RegExp}\n*\n* @example\n* var bool = RE_INTEGER.test( '123' );\n* // returns true\n*\n* bool = RE_INTEGER.test( '12.3' );\n* // returns false\n*/\nvar RE_INTEGER = /^[-+]?[0-9]+$/;\n\n\n// EXPORTS //\n\nexport default RE_INTEGER;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Matches a character sequence which begins with 'end'.\n*\n* Regular expression: `/^end/`\n*\n* - `^`\n*\n* - start of input\n*\n* - `end`\n*\n* - match the character sequence 'end'\n*\n* @private\n* @name RE_END\n* @type {RegExp}\n*\n* @example\n* var bool = RE_END.test( 'end' );\n* // returns true\n*\n* bool = RE_END.test( 'foo end' );\n* // returns false\n*/\nvar RE_END = /^end/;\n\n\n// EXPORTS //\n\nexport default RE_END;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Slice from './../../../ctor';\nimport trim from '@stdlib/string/base/trim';\nimport resolveEnd from './resolve_end.js';\nimport RE_COLON_SEP from './re_colon_sep.js';\nimport RE_INTEGER from './re_integer.js';\nimport RE_END from './re_end.js';\nimport eInvalidSubsequence from './error_invalid_subsequence.js';\nimport eOutOfBounds from './error_out_of_bounds.js';\nimport eInvalidIncrement from './error_invalid_increment.js';\n\n\n// MAIN //\n\n/**\n* Converts a subsequence string to a Slice object.\n*\n* ## Notes\n*\n* - A subsequence string has the following format:\n*\n* ```text\n* ::\n* ```\n*\n* where\n*\n* - If an `increment` is not specified, the default increment is `1`. An increment of zero is **not** allowed.\n* - The `start` index is **inclusive**.\n* - The `stop` index is **exclusive**.\n* - Both `start` and `stop` indices are _optional_. If not provided, `start` and `stop` default to index extremes. Which extremes correspond to which index depends on whether the `increment` is positive or negative.\n* - Both `start` and `stop` can be negative; in which case, the corresponding index is resolved by subtracting the respective value from the provided length `len`.\n* - Both `start` and `stop` can use the `end` keyword (e.g., `end-2::2`, `end-3:`, etc), which supports basic subtraction and division.\n* - The `end` keyword resolves to the provided length `len`. Thus, `:-1` is equivalent to `:end-1`, `:-2` is equivalent to `:end-2`, and so on and so forth. The exception is when performing a division operation when the `increment` is less than zero; in which case, `end` is equal to `len-1` in order to preserve user expectations when `end/d` equals a whole number and slicing from right-to-left. The result from a division operation is **rounded down** to the nearest integer value.\n*\n* - When `strict` is `false`, the resolved slice start is clamped to the slice index bounds (i.e., `[0, len)`).\n*\n* - When `strict` is `false`, the resolved slice end is upper bound clamped to `len` (i.e., one greater than the last possible index).\n*\n* - When the increment is negative, the resolved slice end value may be `null`, thus indicating that a non-empty slice should include the first index.\n*\n* - The function ensures that results satisfy the convention that `:n` combined with `n:` is equivalent to `:` (i.e., selecting all elements).\n*\n* - When `len` is zero, the function always returns a Slice object equivalent to `0:0:`.\n*\n* - The function returns an error object if provided an invalid subsequence string.\n*\n* - If `strict` is `true`, the function returns an error object if provided a subsequence string which exceeds index bounds.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} len - maximum number of elements allowed in the slice\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @returns {(Slice|Object)} Slice object or an error object\n*\n* @example\n* var s = seq2slice( '0:10:1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( '::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 9\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( ':0:-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 9\n*\n* v = s.stop;\n* // returns 0\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( '4::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 4\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( '::', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( ':end:', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( 'end::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 9\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( 'end-2::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 8\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( 'end/2::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 4\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( 'end:end/2:-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 9\n*\n* v = s.stop;\n* // returns 4\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( ':end/2:-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 9\n*\n* v = s.stop;\n* // returns 4\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( ':end/2:1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 5\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( ':end/3', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 3\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( 'end/3::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 3\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( 'end/3::', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 3\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( 'end/3::', 9, false );\n* // returns \n*\n* var v = s.start;\n* // returns 3\n*\n* v = s.stop;\n* // returns 9\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( 'end/3::-1', 9, false );\n* // returns \n*\n* var v = s.start;\n* // returns 2\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( '5:5', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 5\n*\n* v = s.stop;\n* // returns 5\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( '5:5', 0, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 0\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( 'end:', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 10\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*/\nfunction seq2slice( str, len, strict ) {\n\tvar parts;\n\tvar N;\n\tvar v;\n\n\tparts = trim( str ).split( RE_COLON_SEP );\n\tN = parts.length;\n\n\t// Disallow providing standalone components (e.g., '1', 'end', etc) and strings having too many components (e.g., '1:2:3:4')...\n\tif ( N < 2 || N > 3 ) {\n\t\treturn eInvalidSubsequence();\n\t}\n\n\t/* Increment */\n\n\t// Process the increment...\n\tif ( N === 3 ) {\n\t\tv = parts[ 2 ];\n\t\tif ( v.length === 0 ) { // empty increment\n\t\t\tparts[ 2 ] = 1; // default increment\n\t\t} else {\n\t\t\tif ( RE_INTEGER.test( v ) === false ) {\n\t\t\t\treturn eInvalidSubsequence();\n\t\t\t}\n\t\t\tv = parseInt( v, 10 );\n\t\t\tif ( v === 0 ) {\n\t\t\t\treturn eInvalidIncrement(); // increment cannot be zero\n\t\t\t}\n\t\t\tparts[ 2 ] = v;\n\t\t}\n\t} else {\n\t\tparts.push( 1 ); // default increment\n\t}\n\n\t/* Starting Index */\n\n\t// Process the starting index...\n\tv = parts[ 0 ];\n\n\t// Case: empty starting index\n\tif ( v.length === 0 ) {\n\t\t// If the increment is negative, we need to iterate from the last index...\n\t\tif ( parts[ 2 ] < 0 && len > 0 ) {\n\t\t\tparts[ 0 ] = len - 1;\n\t\t} else {\n\t\t\tparts[ 0 ] = 0; // default starting index (inclusive)\n\t\t}\n\t}\n\t// Case: use of the \"end\" keyword\n\telse if ( RE_END.test( v ) ) {\n\t\tv = resolveEnd( v, len, parts[ 2 ] < 0, strict );\n\t\tif ( v < 0 ) {\n\t\t\tif ( v === -2 ) {\n\t\t\t\treturn eOutOfBounds();\n\t\t\t}\n\t\t\treturn eInvalidSubsequence();\n\t\t}\n\t\tif ( parts[ 2 ] < 0 && v >= len ) {\n\t\t\tv -= 1; // clamp to the last index\n\t\t}\n\t\tparts[ 0 ] = v;\n\t}\n\t// Case: integer character sequence\n\telse if ( RE_INTEGER.test( v ) ) {\n\t\tv = parseInt( v, 10 );\n\n\t\t// Check whether we need to resolve the starting index relative to the last index...\n\t\tif ( v < 0 ) {\n\t\t\tv = len + v;\n\n\t\t\t// If the computed index exceeds the index bounds, clamp to the first index...\n\t\t\tif ( v < 0 ) {\n\t\t\t\tif ( strict ) {\n\t\t\t\t\treturn eOutOfBounds();\n\t\t\t\t}\n\t\t\t\tv = 0;\n\t\t\t}\n\t\t}\n\t\t// If the index exceeds the index bounds, clamp to the starting index...\n\t\telse if ( v >= len ) {\n\t\t\tif ( strict ) {\n\t\t\t\treturn eOutOfBounds();\n\t\t\t}\n\t\t\t// If the increment is negative, clamp to the last index (inclusive)...\n\t\t\tif ( parts[ 2 ] < 0 ) {\n\t\t\t\tv = len - 1;\n\t\t\t}\n\t\t\t// If the increment is positive, clamp to the \"index\" following the last index...\n\t\t\telse {\n\t\t\t\tv = len;\n\t\t\t}\n\t\t}\n\t\tparts[ 0 ] = v;\n\t}\n\t// Case: invalid/unsupported characters/operations\n\telse {\n\t\treturn eInvalidSubsequence();\n\t}\n\n\t/* Ending Index */\n\n\t// Processing the ending index...\n\tv = parts[ 1 ];\n\n\t// Case: empty ending index\n\tif ( v.length === 0 ) {\n\t\t// If the increment is negative, we need to iterate toward the first index...\n\t\tif ( parts[ 2 ] < 0 ) {\n\t\t\tparts[ 1 ] = null;\n\t\t} else {\n\t\t\tparts[ 1 ] = len; // default ending index (exclusive)\n\t\t}\n\t}\n\t// Case: use of the \"end\" keyword\n\telse if ( RE_END.test( v ) ) {\n\t\tv = resolveEnd( v, len, parts[ 2 ] < 0, strict );\n\t\tif ( v < 0 ) {\n\t\t\tif ( v === -2 ) {\n\t\t\t\treturn eOutOfBounds();\n\t\t\t}\n\t\t\treturn eInvalidSubsequence();\n\t\t}\n\t\tparts[ 1 ] = v;\n\t}\n\t// Case: integer character sequence\n\telse if ( RE_INTEGER.test( v ) ) {\n\t\tv = parseInt( v, 10 );\n\n\t\t// Check whether we need to resolve the starting index relative to the last index...\n\t\tif ( v < 0 ) {\n\t\t\tv = len + v;\n\n\t\t\t// Check whether the computed index exceeds the index bounds...\n\t\t\tif ( v < 0 ) {\n\t\t\t\t// If the increment is positive, clamp the ending index to the first index (exclusive)...\n\t\t\t\tif ( parts[ 2 ] > 0 ) {\n\t\t\t\t\tif ( strict ) {\n\t\t\t\t\t\treturn eOutOfBounds();\n\t\t\t\t\t}\n\t\t\t\t\tv = 0;\n\t\t\t\t} else {\n\t\t\t\t\t// If the increment is negative, the ending index should resolve to the first index (inclusive)...\n\t\t\t\t\tif ( strict && v < -1 ) {\n\t\t\t\t\t\treturn eOutOfBounds();\n\t\t\t\t\t}\n\t\t\t\t\tv = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// If the index exceeds the index bounds, clamp to the last \"index\" (exclusive)...\n\t\telse if ( v > len ) {\n\t\t\tif ( strict ) {\n\t\t\t\treturn eOutOfBounds();\n\t\t\t}\n\t\t\tv = len;\n\t\t}\n\t\tparts[ 1 ] = v;\n\t}\n\t// Case: invalid/unsupported characters/operations\n\telse {\n\t\treturn eInvalidSubsequence();\n\t}\n\n\t// Handle empty slice (note: this is at the end rather than at the beginning in order to ensure that `start` and `stop` are always validated)...\n\tif ( len === 0 ) {\n\t\treturn new Slice( 0, 0, parts[ 2 ] );\n\t}\n\n\treturn new Slice( parts[ 0 ], parts[ 1 ], parts[ 2 ] );\n}\n\n\n// EXPORTS //\n\nexport default seq2slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an error object for an invalid subsequence string.\n*\n* @private\n* @returns {Object} error object\n*/\nfunction error() {\n\treturn {\n\t\t'code': 'ERR_SLICE_INVALID_SUBSEQUENCE'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default error;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an error object for a subsequence string containing a zero increment.\n*\n* @private\n* @returns {Object} error object\n*/\nfunction error() {\n\treturn {\n\t\t'code': 'ERR_SLICE_INVALID_INCREMENT'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default error;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an error object for a subsequence string resolving to a slice which exceeds index bounds.\n*\n* @private\n* @returns {Object} error object\n*/\nfunction error() {\n\treturn {\n\t\t'code': 'ERR_SLICE_OUT_OF_BOUNDS'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default error;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport trim from '@stdlib/string/base/trim';\nimport Slice from './../../../ctor';\n\n\n// VARIABLES //\n\nvar PREFIX = 'Slice(';\nvar NARGS = 3;\n\n/**\n* Regular expression matching the slice argument separator.\n*\n* @private\n* @name RE_SEP\n* @type {RegExp}\n*/\nvar RE_SEP = /\\s*,\\s*/;\n\n/**\n* Regular expression matching an integer value.\n*\n* @private\n* @name RE_INTEGER\n* @type {RegExp}\n*/\nvar RE_INTEGER = /^-?[0-9]+$/;\n\n\n// MAIN //\n\n/**\n* Parses a string-serialized Slice object.\n*\n* ## Notes\n*\n* - The function returns `null` if provided an invalid string.\n*\n* @param {string} str - input string\n* @returns {(Slice|null)} Slice object (or null)\n*\n* @example\n* var s = str2slice( 'Slice(null,null,null)' );\n* // returns \n*\n* var v = s.start;\n* // returns null\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns null\n*\n* @example\n* var s = str2slice( 'Slice(0,10,1)' );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = str2slice( 'Slice(foo,bar)' );\n* // returns null\n*/\nfunction str2slice( str ) {\n\tvar args;\n\tvar arg;\n\tvar n;\n\tvar v;\n\tvar i;\n\tif ( str.substring( 0, PREFIX.length ) !== PREFIX ) {\n\t\treturn null;\n\t}\n\tn = str.length - 1;\n\tif ( str[ n ] !== ')' ) {\n\t\treturn null;\n\t}\n\tstr = trim( str.substring( PREFIX.length, n ) );\n\tstr = str.split( RE_SEP );\n\tif ( str.length !== NARGS ) {\n\t\treturn null;\n\t}\n\targs = [];\n\tfor ( i = 0; i < NARGS; i++ ) {\n\t\tv = str[ i ];\n\t\tif ( v === 'null' ) {\n\t\t\targ = null;\n\t\t} else if ( RE_INTEGER.test( v ) ) {\n\t\t\targ = parseInt( v, 10 );\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t\targs.push( arg );\n\t}\n\treturn new Slice( args[ 0 ], args[ 1 ], args[ 2 ] );\n}\n\n\n// EXPORTS //\n\nexport default str2slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a string starts with the characters of another string.\n*\n* @module @stdlib/string/base/starts-with\n*\n* @example\n* import startsWith from '@stdlib/string/base/starts-with';\n*\n* var str = 'Fair is foul, and foul is fair, hover through fog and filthy air';\n* var bool = startsWith( str, 'Fair', 0 );\n* // returns true\n*\n* bool = startsWith( str, 'fair', 0 );\n* // returns false\n*\n* bool = startsWith( str, 'foul', 8 );\n* // returns true\n*\n* bool = startsWith( str, 'filthy', -10 );\n* // returns true\n*/\n\n// MODULES //\n\nimport HAS_BUILTIN from './has_builtin.js';\nimport polyfill from './polyfill.js';\nimport main from './main.js';\n\n\n// MAIN //\n\nvar startsWith;\nif ( HAS_BUILTIN ) {\n\tstartsWith = main;\n} else {\n\tstartsWith = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default startsWith;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar bool = ( typeof String.prototype.startsWith !== 'undefined' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar startsWith = String.prototype.startsWith;\n\n\n// EXPORTS //\n\nexport default startsWith;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport builtin from './builtin.js';\n\n\n// MAIN //\n\n/**\n* Tests if a string starts with the characters of another string.\n*\n* @param {string} str - input string\n* @param {string} search - search string\n* @param {integer} position - position at which to start searching\n* @returns {boolean} boolean indicating if the input string starts with the search string\n*\n* @example\n* var bool = startsWith( 'Remember the story I used to tell you when you were a boy?', 'Remember', 0 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'Remember the story I used to tell you when you were a boy?', 'Remember, remember', 0 );\n* // returns false\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'To be', 0 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'to be', 0 );\n* // returns false\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'to be', 14 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'quest', -9 );\n* // returns true\n*/\nfunction startsWith( str, search, position ) {\n\tvar pos;\n\tif ( position < 0 ) {\n\t\tpos = str.length + position;\n\t} else {\n\t\tpos = position;\n\t}\n\tif ( search.length === 0 ) {\n\t\treturn true;\n\t}\n\tif (\n\t\tpos < 0 ||\n\t\tpos + search.length > str.length\n\t) {\n\t\treturn false;\n\t}\n\treturn builtin.call( str, search, pos );\n}\n\n\n// EXPORTS //\n\nexport default startsWith;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if a string starts with the characters of another string.\n*\n* @private\n* @param {string} str - input string\n* @param {string} search - search string\n* @param {integer} position - position at which to start searching\n* @returns {boolean} boolean indicating if the input string starts with the search string\n*\n* @example\n* var bool = startsWith( 'Remember the story I used to tell you when you were a boy?', 'Remember', 0 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'Remember the story I used to tell you when you were a boy?', 'Remember, remember', 0 );\n* // returns false\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'To be', 0 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'to be', 0 );\n* // returns false\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'to be', 14 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'quest', -9 );\n* // returns true\n*/\nfunction startsWith( str, search, position ) {\n\tvar pos;\n\tvar i;\n\tif ( position < 0 ) {\n\t\tpos = str.length + position;\n\t} else {\n\t\tpos = position;\n\t}\n\tif ( search.length === 0 ) {\n\t\treturn true;\n\t}\n\tif (\n\t\tpos < 0 ||\n\t\tpos + search.length > str.length\n\t) {\n\t\treturn false;\n\t}\n\tfor ( i = 0; i < search.length; i++ ) {\n\t\tif ( str.charCodeAt( pos + i ) !== search.charCodeAt( i ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default startsWith;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is a subsequence string.\n*\n* @private\n* @name RE_SUBSEQ\n* @type {RegExp}\n*\n* @example\n* var bool = RE_SUBSEQ.test( '0:10:2' );\n* // returns true\n*\n* @example\n* var bool = RE_SUBSEQ.test( '0' );\n* // returns false\n*\n* @example\n* var bool = RE_SUBSEQ.test( 'Slice(0,10,2)' );\n* // returns false\n*/\nvar RE_SUBSEQ = /:/;\n\n\n// EXPORTS //\n\nexport default RE_SUBSEQ;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport trim from '@stdlib/string/base/trim';\nimport seq2slice from '@stdlib/slice/base/seq2slice';\nimport str2slice from '@stdlib/slice/base/str2slice';\nimport startsWith from '@stdlib/string/base/starts-with';\nimport format from '@stdlib/string/format';\nimport RE_SUBSEQ from './re_subseq.js';\n\n\n// FUNCTIONS //\n\n/**\n* Tests if an indexing expression is a serialized Slice object.\n*\n* @private\n* @param {string} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isSlice( 'Slice(null,null,1)' );\n* // returns true\n*\n* @example\n* var out = isSlice( ':' );\n* // returns false\n*/\nfunction isSlice( prop ) {\n\treturn (\n\t\tprop[ 0 ] === 'S' &&\n\t\tstartsWith( prop, 'Slice(', 0 ) &&\n\t\tprop[ prop.length-1 ] === ')'\n\t);\n}\n\n/**\n* Tests if an indexing expression is a subsequence.\n*\n* @private\n* @param {string} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isSubsequence( '::-2' );\n* // returns true\n*\n* @example\n* var out = isSubsequence( '-2' );\n* // returns false\n*/\nfunction isSubsequence( prop ) {\n\t// TODO: consider whether to make this check more robust (e.g., should we actually throw if someone tries to access `foo:bar`? If we make this check more exact, how would we distinguish between a non-existent `foo:bar` property and an actual error in the subsequence string?)\n\treturn RE_SUBSEQ.test( prop );\n}\n\n/**\n* Parses a serialized Slice object.\n*\n* @private\n* @param {string} raw - original unprocessed input string\n* @param {string} str - serialized Slice object\n* @throws {Error} invalid slice operation\n* @returns {Slice} Slice object\n*\n* @example\n* var s = parseSlice( ' Slice(null,null,1) ', 'Slice(null,null,1)' );\n* // returns \n*/\nfunction parseSlice( raw, str ) {\n\tvar s = str2slice( str );\n\tif ( s === null ) {\n\t\tthrow new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) );\n\t}\n\treturn s;\n}\n\n/**\n* Parses a subsequence string.\n*\n* @private\n* @param {string} raw - original unprocessed input string\n* @param {string} str - subsequence string\n* @param {NonNegativeInteger} max - index upper bound\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {Slice} Slice object\n*\n* @example\n* var s = parseSubsequence( ' ::-2 ', '::-2', 10, false );\n* // returns \n*/\nfunction parseSubsequence( raw, str, max, strict ) {\n\tvar s = seq2slice( str, max, true );\n\tif ( s.code ) {\n\t\tif ( s.code === 'ERR_SLICE_INVALID_INCREMENT' ) {\n\t\t\tthrow new Error( format( 'invalid operation. A subsequence increment must be a non-zero integer. Value: `%s`.', raw ) );\n\t\t}\n\t\tif ( s.code === 'ERR_SLICE_INVALID_SUBSEQUENCE' ) {\n\t\t\tthrow new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) );\n\t\t}\n\t\t// NOTE: the following error check must come last due to fall-through when in non-strict mode...\n\t\tif ( s.code === 'ERR_SLICE_OUT_OF_BOUNDS' ) {\n\t\t\tif ( strict ) {\n\t\t\t\tthrow new RangeError( format( 'invalid operation. Slice exceeds array bounds.' ) );\n\t\t\t}\n\t\t\t// Repeat parsing, this time allowing for out-of-bounds slices:\n\t\t\ts = seq2slice( str, max, false );\n\t\t}\n\t}\n\treturn s;\n}\n\n\n// MAIN //\n\n/**\n* Converts an indexing expression to a Slice object.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property name\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {(Slice|null)} slice object (or null)\n*/\nfunction prop2slice( target, property, strict ) {\n\tvar prop = trim( property );\n\tif ( isSlice( prop ) ) {\n\t\treturn parseSlice( property, prop );\n\t}\n\tif ( isSubsequence( prop ) ) {\n\t\treturn parseSubsequence( property, prop, target.length, strict );\n\t}\n\t// Everything else (including undefined/non-existent properties):\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default prop2slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport hasProperty from '@stdlib/assert/has-property';\nimport isIntegerString from './is_integer_string.js';\nimport isArrayIndexString from './is_array_index_string.js';\nimport getElements from './get_elements.js';\nimport getElement from './get_element.js';\nimport getValue from './get_value.js';\nimport getSlice from './get_slice.js';\n\n\n// MAIN //\n\n/**\n* Returns a trap for retrieving property values.\n*\n* @private\n* @param {Object} ctx - context object\n* @param {Function} ctx.getter - accessor for retrieving array elements\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.ctor - proxied array constructor\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @param {Object} ctx.cache - cache for resolving array index objects\n* @returns {Function} handler\n*/\nfunction factory( ctx ) {\n\treturn get;\n\n\t/**\n\t* Trap for retrieving property values.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {(string|symbol)} property - property name\n\t* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n\t* @throws {Error} invalid slice operation\n\t* @throws {RangeError} slice exceeds array bounds\n\t* @throws {RangeError} index exceeds array bounds\n\t* @returns {*} result\n\t*/\n\tfunction get( target, property, receiver ) {\n\t\tif ( isIntegerString( property ) ) {\n\t\t\treturn getElement( target, property, ctx );\n\t\t}\n\t\tif ( hasProperty( target, property ) || !isString( property ) ) {\n\t\t\treturn getValue( target, property, receiver, ctx );\n\t\t}\n\t\tif ( isArrayIndexString( property ) ) {\n\t\t\treturn getElements( target, property, ctx );\n\t\t}\n\t\treturn getSlice( target, property, ctx );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveIndex from './resolve_index.js';\n\n\n// MAIN //\n\n/**\n* Returns the element associated with a specified index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {Object} ctx - context object\n* @param {Function} ctx.getter - accessor for retrieving array elements\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @throws {RangeError} index exceeds array bounds\n* @returns {*} result\n*/\nfunction getElement( target, property, ctx ) {\n\treturn ctx.getter( target, resolveIndex( property, target.length, ctx.strict ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default getElement;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert/is-function';\n\n\n// MAIN //\n\n/**\n* Returns the property value associated with a specified property.\n*\n* @private\n* @param {Object} target - target object\n* @param {(string|symbol)} property - property\n* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n* @param {Object} ctx - context object\n* @param {Function} ctx.ctor - proxied array constructor\n* @returns {*} result\n*/\nfunction getValue( target, property, receiver, ctx ) {\n\tvar value = target[ property ];\n\tif ( isFunction( value ) ) {\n\t\tif ( value === target.constructor ) {\n\t\t\treturn ctx.ctor;\n\t\t}\n\t\treturn wrapper;\n\t}\n\treturn value;\n\n\t/**\n\t* Method wrapper.\n\t*\n\t* @private\n\t* @returns {*} results\n\t*/\n\tfunction wrapper() {\n\t\tvar args;\n\t\tvar i;\n\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn value.apply( ( this === receiver ) ? target : this, args ); // eslint-disable-line no-invalid-this\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport take from './../../take';\nimport mskfilter from './../../mskfilter';\nimport mskreject from './../../mskreject';\nimport format from '@stdlib/string/format';\nimport prop2array from './prop2array.js';\n\n\n// MAIN //\n\n/**\n* Returns the elements specified by an array index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {Object} ctx - context object\n* @param {Object} ctx.cache - cache for resolving array index objects\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @throws {Error} invalid array index\n* @throws {RangeError} index exceeds array bounds\n* @returns {Collection} result\n*/\nfunction getElements( target, property, ctx ) {\n\tvar idx = prop2array( property, ctx.cache );\n\tif ( idx.type === 'int' ) {\n\t\treturn ctx.postGetArray( take( target, idx.data ) );\n\t}\n\tif ( idx.type === 'bool' ) {\n\t\treturn ctx.postGetArray( mskfilter( target, idx.data ) );\n\t}\n\tif ( idx.type === 'mask' ) {\n\t\treturn ctx.postGetArray( mskreject( target, idx.data ) );\n\t}\n\tthrow new Error( format( 'invalid operation. Unrecognized array index type. Value: `%s`.', idx.type ) );\n}\n\n\n// EXPORTS //\n\nexport default getElements;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport slice from './../../base/fancy-slice';\nimport errMessage from './error_message.js';\nimport prop2slice from './prop2slice.js';\n\n\n// MAIN //\n\n/**\n* Returns a copy.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property name\n* @param {Object} ctx - context object\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {(Collection|void)} result\n*/\nfunction getSlice( target, property, ctx ) {\n\tvar s = prop2slice( target, property, ctx.strict );\n\tif ( s === null ) {\n\t\t// Ensure consistency with normal array behavior by returning `undefined` for any \"unrecognized\" property name:\n\t\treturn;\n\t}\n\ttry {\n\t\treturn ctx.postGetArray( slice( target, s, ctx.strict ) );\n\t} catch ( err ) {\n\t\t// In principle, we should only error when in \"strict\" mode and a slice exceeds array bounds...\n\t\tthrow new err.constructor( errMessage( err.message ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getSlice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets the value associated with a specified property.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property\n* @param {*} value - new value\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setValue( target, property, value ) {\n\ttarget[ property ] = value;\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default setValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport hasProperty from '@stdlib/assert/has-property';\nimport isIntegerString from './is_integer_string.js';\nimport isArrayIndexString from './is_array_index_string.js';\nimport setElements from './set_elements.js';\nimport setElement from './set_element.js';\nimport setValue from './set_value.js';\nimport setSlice from './set_slice.js';\n\n\n// MAIN //\n\n/**\n* Returns a trap for setting property values.\n*\n* @private\n* @param {Object} ctx - context object\n* @param {string} ctx.dtype - array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.validator - function for validating new values\n* @param {Function} ctx.setter - accessor for setting array elements\n* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary)\n* @returns {Function} handler\n*/\nfunction factory( ctx ) {\n\treturn set;\n\n\t/**\n\t* Trap for setting property values.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {(string|symbol)} property - property name\n\t* @param {*} value - new value\n\t* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n\t* @throws {Error} invalid slice operation\n\t* @throws {Error} assigned value must be broadcast compatible with output array view\n\t* @throws {TypeError} assigned value cannot be safely cast to the output array data type\n\t* @throws {TypeError} slice exceeds array bounds\n\t* @throws {TypeError} index exceeds array bounds\n\t* @returns {boolean} boolean indicating whether assignment succeeded\n\t*/\n\tfunction set( target, property, value, receiver ) {\n\t\tvar out;\n\n\t\t// Note that we need to check for an integer string *before* checking for an own property, as we want to explicitly handle *all* indexed properties, not just negative integers, in order to perform assignment validation...\n\t\tif ( isIntegerString( property ) ) {\n\t\t\treturn setElement( target, property, value, ctx );\n\t\t}\n\t\tif ( hasProperty( target, property ) || !isString( property ) ) {\n\t\t\treturn setValue( target, property, value, ctx );\n\t\t}\n\t\tif ( isArrayIndexString( property ) ) {\n\t\t\treturn setElements( target, property, value, ctx );\n\t\t}\n\t\tout = setSlice( target, property, value, receiver, ctx );\n\t\tif ( out ) {\n\t\t\treturn out;\n\t\t}\n\t\t// If we were unsuccessful (e.g., due to an invalid subsequence, etc), set the \"property\" in the same way as would any normal property (e.g., if an indexing expression is an invalid subsequence, assign as would a regular property: `i = 'a:b:c'` => `x[i] = 1` => `v = x[i]` => `v === 1`):\n\t\treturn setValue( target, property, value, ctx );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveIndex from './resolve_index.js';\n\n\n// MAIN //\n\n/**\n* Sets the element associated with a specified index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {*} value - new value\n* @param {Object} ctx - context object\n* @param {Function} ctx.setter - accessor for setting array elements\n* @param {string} ctx.dtype - target array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.validator - function for validating new values\n* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary)\n* @throws {TypeError} assigned value cannot be safely cast to the target array data type\n* @throws {TypeError} target array must have a supported data type\n* @throws {RangeError} index exceeds array bounds\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setElement( target, property, value, ctx ) {\n\tvar err;\n\tvar v;\n\n\terr = ctx.validator( value, ctx.dtype );\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( ctx.preSetElement ) {\n\t\tv = ctx.preSetElement( value );\n\t} else {\n\t\tv = value;\n\t}\n\tctx.setter( target, resolveIndex( property, target.length, ctx.strict ), v ); // eslint-disable-line max-len\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default setElement;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isMostlySafeCast from './../../base/assert/is-mostly-safe-data-type-cast';\nimport isRealDataType from './../../base/assert/is-real-data-type';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isCollection from '@stdlib/assert/is-collection';\nimport scalar2array from './../../from-scalar';\nimport dtype from './../../dtype';\nimport put from './../../put';\nimport place from './../../place';\nimport convert from './../../convert';\nimport { assign as where } from './../../base/where';\nimport format from '@stdlib/string/format';\nimport prop2array from './prop2array.js';\nimport errMessage from './error_message.js';\n\n\n// MAIN //\n\n/**\n* Replaces the elements specified by an array index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {*} value - new value(s)\n* @param {Object} ctx - context object\n* @param {string} ctx.dtype - array data type\n* @param {Object} ctx.cache - cache for resolving array index objects\n* @param {Function} ctx.validator - function for validating new values\n* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary)\n* @throws {Error} invalid array index\n* @throws {RangeError} index exceeds array bounds\n* @throws {Error} assigned value must be broadcast compatible with target array selection\n* @throws {TypeError} assigned value cannot be safely cast to the target array data type\n* @throws {TypeError} target array must have a supported data type\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setElements( target, property, value, ctx ) {\n\tvar tdt;\n\tvar vdt;\n\tvar idx;\n\tvar err;\n\tvar v;\n\n\tidx = prop2array( property, ctx.cache );\n\ttdt = ctx.dtype || 'generic';\n\tif ( isCollection( value ) ) {\n\t\t// When handling collections, we delegate to implementation APIs (see below) to perform argument validation (e.g., ensuring a (mostly) safe cast, broadcast compatibility, etc), so we just reassign the value here:\n\t\tv = value;\n\t} else {\n\t\t// When provided a \"scalar\", we need to check whether the value can be safely cast to the target array data type:\n\t\terr = ctx.validator( value, tdt );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\tif ( ctx.preSetElement ) {\n\t\t\tv = ctx.preSetElement( value );\n\t\t} else {\n\t\t\tv = value;\n\t\t}\n\t\t// As the scalar can be safely cast, convert the scalar to an array having the same data type as the target array to allow for broadcasting during assignment:\n\t\tv = scalar2array( v, tdt );\n\t\tvdt = tdt;\n\t}\n\tif ( idx.type === 'int' ) {\n\t\ttry {\n\t\t\tput( target, idx.data, v ); // note: defer to `put` for ensuring a mostly safe cast\n\t\t} catch ( err ) {\n\t\t\tthrow new err.constructor( errMessage( err.message ) );\n\t\t}\n\t\treturn true;\n\t}\n\tif ( idx.type === 'bool' ) {\n\t\ttry {\n\t\t\tplace( target, idx.data, v, {\n\t\t\t\t'mode': 'strict_broadcast'\n\t\t\t});\n\t\t} catch ( err ) {\n\t\t\tthrow new err.constructor( errMessage( err.message ) );\n\t\t}\n\t\treturn true;\n\t}\n\tif ( vdt === void 0 ) {\n\t\tvdt = dtype( value ) || 'generic';\n\t}\n\t// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the target array data type is floating-point...\n\tif ( !isMostlySafeCast( vdt, tdt ) ) {\n\t\tthrow new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, tdt ) );\n\t}\n\t// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...\n\tif ( isComplexDataType( tdt ) && isRealDataType( vdt ) ) {\n\t\tv = convert( v, tdt );\n\t}\n\tif ( idx.type === 'mask' ) {\n\t\t// NOTE: we intentionally deviate from boolean array indexing here and interpret the mask as applying to both the target and values array, thus requiring that the assigned value array be broadcast compatible with the target array and NOT just the selected elements as in boolean array indexing\n\t\ttry {\n\t\t\twhere( idx.data, target, v, target, 1, 0 );\n\t\t} catch ( err ) {\n\t\t\tthrow new err.constructor( errMessage( err.message ) );\n\t\t}\n\t\treturn true;\n\t}\n\tthrow new Error( format( 'invalid operation. Unrecognized array index type. Value: `%s`.', idx.type ) );\n}\n\n\n// EXPORTS //\n\nexport default setElements;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport sliceAssign from './../../base/fancy-slice-assign';\nimport scalar2array from './../../from-scalar';\nimport prop2slice from './prop2slice.js';\nimport errMessage from './error_message.js';\n\n\n// MAIN //\n\n/**\n* Sets element values belonging to the array view specified by an indexing expression.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - indexing expression\n* @param {*} value - new value\n* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n* @param {Object} ctx - context object\n* @param {string} ctx.dtype - array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.validator - function for validating new values\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @throws {Error} assigned value must be broadcast compatible with target array view\n* @throws {TypeError} assigned value cannot be safely cast to the target array data type\n* @throws {TypeError} target array must have a supported data type\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setSlice( target, property, value, receiver, ctx ) {\n\tvar err;\n\tvar s;\n\tvar v;\n\n\ts = prop2slice( target, property, ctx.strict );\n\tif ( s === null ) {\n\t\t// If unable to parse the property as an indexing expression, signal that we were unable to perform slice assignment:\n\t\treturn false;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// When handling collections, we delegate to `sliceAssign` (see below) to perform argument validation (e.g., ensuring a (mostly) safe cast, broadcast compatibility, etc), so we just reassign the value here:\n\t\tv = value;\n\t} else {\n\t\t// When provided a \"scalar\", we need to check whether the value can be safely cast to the target array data type:\n\t\terr = ctx.validator( value, ctx.dtype );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\t// As the scalar can be safely cast, convert the scalar to an array having the same data type as the target array to allow for broadcasting during slice assignment:\n\t\tv = scalar2array( value, ctx.dtype || 'generic' );\n\t}\n\ttry {\n\t\tsliceAssign( v, receiver, s, ctx.strict );\n\t} catch ( err ) {\n\t\tthrow new err.constructor( errMessage( err.message ) );\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default setSlice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayLike from '@stdlib/assert/is-array-like';\nimport Proxy from '@stdlib/proxy/ctor';\nimport arraylike2object from './../../base/arraylike2object';\nimport assign from '@stdlib/object/assign';\nimport format from '@stdlib/string/format';\nimport setElementWrapper from './set_element_wrapper.js';\nimport getArrayWrapper from './get_array_wrapper.js';\nimport hasProxySupport from './has_proxy_support.js';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\nimport validator from './validator.js';\nimport ctor from './ctor.js';\nimport get from './get.js';\nimport set from './set.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for converting an array to an object supporting fancy indexing.\n*\n* @param {Options} options - function options\n* @param {boolean} [options.strict=false] - boolean indicating whether to enforce strict bounds checking by default\n* @param {Function} [options.cache] - default cache for resolving array index objects\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {Function} function for converting an array to an object supporting fancy indexing\n*\n* @example\n* var array2fancy = factory();\n*\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\nfunction factory() {\n\tvar OPTIONS;\n\tvar err;\n\n\tOPTIONS = defaults();\n\tif ( arguments.length ) {\n\t\terr = validate( OPTIONS, arguments[ 0 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\treturn array2fancy;\n\n\t/**\n\t* Converts an array to an object supporting fancy indexing.\n\t*\n\t* @private\n\t* @param {ArrayLike} x - input array\n\t* @param {Options} [options] - function options\n\t* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking\n\t* @param {Function} [options.cache] - cache for resolving array index objects\n\t* @throws {TypeError} first argument must be array-like\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {ArrayLike} fancy array\n\t*\n\t* @example\n\t* var x = [ 1, 2, 3, 4, 5, 6 ];\n\t*\n\t* var y = array2fancy( x );\n\t* // returns \n\t*\n\t* var z = y[ '1::2' ];\n\t* // returns [ 2, 4, 6 ]\n\t*\n\t* var len = z.length;\n\t* // returns 3\n\t*\n\t* var v = z[ 0 ];\n\t* // returns 2\n\t*\n\t* v = z[ 1 ];\n\t* // returns 4\n\t*\n\t* v = z[ 2 ];\n\t* // returns 6\n\t*/\n\tfunction array2fancy( x ) {\n\t\tvar opts;\n\t\tvar err;\n\t\tvar arr;\n\t\tvar dt;\n\t\tvar o;\n\t\tif ( !isArrayLike( x ) && !isCollection( x ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be array-like. Value: `%s`.', x ) );\n\t\t}\n\t\tif ( hasProxySupport ) {\n\t\t\topts = assign( {}, OPTIONS );\n\t\t\tif ( arguments.length > 1 ) {\n\t\t\t\terr = validate( opts, arguments[ 1 ] );\n\t\t\t\tif ( err ) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t\tarr = arraylike2object( x );\n\t\t\tdt = arr.dtype || '';\n\t\t\to = {\n\t\t\t\t'ref': x,\n\t\t\t\t'dtype': dt,\n\t\t\t\t'getter': arr.accessors[ 0 ],\n\t\t\t\t'setter': arr.accessors[ 1 ],\n\t\t\t\t'preSetElement': setElementWrapper( dt ),\n\t\t\t\t'postGetArray': getArrayWrapper( array2fancy, opts ),\n\t\t\t\t'cache': opts.cache,\n\t\t\t\t'strict': opts.strict,\n\t\t\t\t'validator': validator( dt ),\n\t\t\t\t'array2fancy': array2fancy,\n\t\t\t\t'ctor': new Proxy( x.constructor || Array, {\n\t\t\t\t\t'construct': ctor( array2fancy, opts )\n\t\t\t\t})\n\t\t\t};\n\t\t\treturn new Proxy( x, {\n\t\t\t\t'get': get( o ),\n\t\t\t\t'set': set( o )\n\t\t\t});\n\t\t}\n\t\t// TODO: replace with `@stdlib/console/warn` (or equivalent once available)\n\t\tconsole.warn( 'WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available.' ); // eslint-disable-line no-console\n\t\treturn x;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ArrayIndex from './../../index';\n\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'cache': ArrayIndex,\n\t\t'strict': false\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport MAX_LENGTH from '@stdlib/constants/array/max-array-length';\n\n\n// MAIN //\n\n/**\n* Tests if a value is array-like.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is array-like\n*\n* @example\n* var bool = isArrayLike( [] );\n* // returns true\n*\n* @example\n* var bool = isArrayLike( { 'length': 10 } );\n* // returns true\n*/\nfunction isArrayLike( value ) {\n\treturn (\n\t\tvalue !== void 0 &&\n\t\tvalue !== null &&\n\t\ttypeof value !== 'function' &&\n\t\ttypeof value.length === 'number' &&\n\t\tisInteger( value.length ) &&\n\t\tvalue.length >= 0 &&\n\t\tvalue.length <= MAX_LENGTH\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isArrayLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './factory.js';\n\n\n// MAIN //\n\n/**\n* Converts an array to an object supporting fancy indexing.\n*\n* @name array2fancy\n* @type {Function}\n* @param {ArrayLike} x - input array\n* @param {Options} [options] - function options\n* @param {boolean} [options.strict=false] - boolean indicating whether to enforce strict bounds checking\n* @param {Function} [options.cache] - cache for resolving array index objects\n* @throws {TypeError} first argument must be array-like\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayLike} fancy array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\nvar array2fancy = factory();\n\n\n// EXPORTS //\n\nexport default array2fancy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an array to an object supporting fancy indexing.\n*\n* @module @stdlib/array/to-fancy\n*\n* @example\n* import array2fancy from '@stdlib/array/to-fancy';\n*\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport ArrayIndex from './../../index';\nimport main from './main.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\nsetReadOnly( main, 'idx', ArrayIndex );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport ctors from './../../typed-ctors';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} must provide a recognized data type\n* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex128Array from './../../complex128';\nimport Complex64Array from './../../complex64';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'complex128': Complex128Array,\n\t'complex64': Complex64Array\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a complex typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'complex128' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport ctors from './../../typed-complex-ctors';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.complex_floating_point' );\n\n\n// MAIN //\n\n/**\n* Creates a complex number typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"complex128\"] - data type\n* @throws {TypeError} must provide a recognized data type\n* @returns {ComplexArray} typed array\n*\n* @example\n* var arr = complexarray();\n* // returns \n*\n* @example\n* var arr = complexarray( 2 );\n* // returns \n*\n* @example\n* var arr = complexarray( 2, 'complex64' );\n* // returns \n*\n* @example\n* var arr = complexarray( [ 0.5, 0.5 ] );\n* // returns \n*\n* @example\n* var arr = complexarray( [ 5.0, -3.0 ], 'complex64' );\n* // returns \n*\n* @example\n* var arr1 = complexarray( [ 5.0, 3.0 ], 'complex64' );\n* var arr2 = complexarray( arr1 );\n* // returns \n*\n* @example\n* var arr1 = complexarray( [ 5.0, 3.0 ], 'complex128' );\n* var arr2 = complexarray( arr1, 'complex64' );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = complexarray( buf );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = complexarray( buf, 'complex64' );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = complexarray( buf, 16 );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = complexarray( buf, 16, 'complex64' );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 64 );\n* var arr = complexarray( buf, 16, 2 );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 64 );\n* var arr = complexarray( buf, 16, 2, 'complex64' );\n* // returns \n*/\nfunction complexarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\treturn new ctor( arguments[0] );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default complexarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array,\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport ctors from './../../typed-ctors';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.real' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} must provide a recognized data type\n* @returns {TypedArray} typed array\n*\n* @example\n* var arr = realarray();\n* // returns \n*\n* @example\n* var arr = realarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = realarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = realarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = realarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = realarray( [ 5, 3 ], 'int32' );\n* var arr2 = realarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = realarray( [ 5, 3 ], 'int32' );\n* var arr2 = realarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = realarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = realarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = realarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = realarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = realarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = realarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction realarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\treturn new ctor( arguments[0] );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default realarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'float64': Float64Array,\n\t'float32': Float32Array,\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array,\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'float64': Float64Array,\n\t'float32': Float32Array\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport base from './../../base/zero-to';\nimport zeros from './../../zeros';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero.\n*\n* @param {NonNegativeInteger} n - number of elements\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = zeroTo( 2 );\n* // returns [ 0.0, 1.0 ]\n*\n* @example\n* var arr = zeroTo( 2, 'float32' );\n* // returns [ 0.0, 1.0 ]\n*/\nfunction zeroTo( n ) {\n\tvar dtype;\n\tif ( !isNonNegativeInteger( n ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', n ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t\tif ( dtype === 'generic' ) {\n\t\t\treturn base( n );\n\t\t}\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\treturn base.assign( zeros( n, dtype ), 1, 0 ); // defer dtype validation to `zeros`\n}\n\n\n// EXPORTS //\n\nexport default zeroTo;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name MAX_ARRAY_LENGTH\n* @memberof ns\n* @readonly\n* @constant\n* @type {number}\n* @see {@link module:@stdlib/constants/array/max-array-length}\n*/\nimport MAX_ARRAY_LENGTH from './../../array/max-array-length';\nsetReadOnly( ns, 'MAX_ARRAY_LENGTH', MAX_ARRAY_LENGTH );\n\n/**\n* @name MAX_TYPED_ARRAY_LENGTH\n* @memberof ns\n* @readonly\n* @constant\n* @type {number}\n* @see {@link module:@stdlib/constants/array/max-typed-array-length}\n*/\nimport MAX_TYPED_ARRAY_LENGTH from './../../array/max-typed-array-length';\nsetReadOnly( ns, 'MAX_TYPED_ARRAY_LENGTH', MAX_TYPED_ARRAY_LENGTH );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n/*\n* The following modules are intentionally not exported: generic\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name base\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base}\n*/\nimport base from './../base';\nsetReadOnly( ns, 'base', base );\n\n/**\n* @name BooleanArray\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/bool}\n*/\nimport BooleanArray from './../bool';\nsetReadOnly( ns, 'BooleanArray', BooleanArray );\n\n/**\n* @name ArrayBuffer\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/buffer}\n*/\nimport ArrayBuffer from './../buffer';\nsetReadOnly( ns, 'ArrayBuffer', ArrayBuffer );\n\n/**\n* @name byteOrders\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/byte-orders}\n*/\nimport byteOrders from './../byte-orders';\nsetReadOnly( ns, 'byteOrders', byteOrders );\n\n/**\n* @name cartesianPower\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/cartesian-power}\n*/\nimport cartesianPower from './../cartesian-power';\nsetReadOnly( ns, 'cartesianPower', cartesianPower );\n\n/**\n* @name cartesianProduct\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/cartesian-product}\n*/\nimport cartesianProduct from './../cartesian-product';\nsetReadOnly( ns, 'cartesianProduct', cartesianProduct );\n\n/**\n* @name cartesianSquare\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/cartesian-square}\n*/\nimport cartesianSquare from './../cartesian-square';\nsetReadOnly( ns, 'cartesianSquare', cartesianSquare );\n\n/**\n* @name Complex64Array\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/complex64}\n*/\nimport Complex64Array from './../complex64';\nsetReadOnly( ns, 'Complex64Array', Complex64Array );\n\n/**\n* @name Complex128Array\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/complex128}\n*/\nimport Complex128Array from './../complex128';\nsetReadOnly( ns, 'Complex128Array', Complex128Array );\n\n/**\n* @name convert\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/convert}\n*/\nimport convert from './../convert';\nsetReadOnly( ns, 'convert', convert );\n\n/**\n* @name convertSame\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/convert-same}\n*/\nimport convertSame from './../convert-same';\nsetReadOnly( ns, 'convertSame', convertSame );\n\n/**\n* @name ctors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/ctors}\n*/\nimport ctors from './../ctors';\nsetReadOnly( ns, 'ctors', ctors );\n\n/**\n* @name DataView\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/dataview}\n*/\nimport DataView from './../dataview';\nsetReadOnly( ns, 'DataView', DataView );\n\n/**\n* @name datespace\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/datespace}\n*/\nimport datespace from './../datespace';\nsetReadOnly( ns, 'datespace', datespace );\n\n/**\n* @name defaults\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/defaults}\n*/\nimport defaults from './../defaults';\nsetReadOnly( ns, 'defaults', defaults );\n\n/**\n* @name dtype\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/dtype}\n*/\nimport dtype from './../dtype';\nsetReadOnly( ns, 'dtype', dtype );\n\n/**\n* @name dtypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/dtypes}\n*/\nimport dtypes from './../dtypes';\nsetReadOnly( ns, 'dtypes', dtypes );\n\n/**\n* @name empty\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/empty}\n*/\nimport empty from './../empty';\nsetReadOnly( ns, 'empty', empty );\n\n/**\n* @name emptyLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/empty-like}\n*/\nimport emptyLike from './../empty-like';\nsetReadOnly( ns, 'emptyLike', emptyLike );\n\n/**\n* @name filled\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/filled}\n*/\nimport filled from './../filled';\nsetReadOnly( ns, 'filled', filled );\n\n/**\n* @name filledBy\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/filled-by}\n*/\nimport filledBy from './../filled-by';\nsetReadOnly( ns, 'filledBy', filledBy );\n\n/**\n* @name fixedEndianFactory\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/fixed-endian-factory}\n*/\nimport fixedEndianFactory from './../fixed-endian-factory';\nsetReadOnly( ns, 'fixedEndianFactory', fixedEndianFactory );\n\n/**\n* @name Float32ArrayFE\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/fixed-endian-float32}\n*/\nimport Float32ArrayFE from './../fixed-endian-float32';\nsetReadOnly( ns, 'Float32ArrayFE', Float32ArrayFE );\n\n/**\n* @name Float64ArrayFE\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/fixed-endian-float64}\n*/\nimport Float64ArrayFE from './../fixed-endian-float64';\nsetReadOnly( ns, 'Float64ArrayFE', Float64ArrayFE );\n\n/**\n* @name Float32Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/float32}\n*/\nimport Float32Array from './../float32';\nsetReadOnly( ns, 'Float32Array', Float32Array );\n\n/**\n* @name Float64Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/float64}\n*/\nimport Float64Array from './../float64';\nsetReadOnly( ns, 'Float64Array', Float64Array );\n\n/**\n* @name iterator2array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/from-iterator}\n*/\nimport iterator2array from './../from-iterator';\nsetReadOnly( ns, 'iterator2array', iterator2array );\n\n/**\n* @name scalar2array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/from-scalar}\n*/\nimport scalar2array from './../from-scalar';\nsetReadOnly( ns, 'scalar2array', scalar2array );\n\n/**\n* @name full\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/full}\n*/\nimport full from './../full';\nsetReadOnly( ns, 'full', full );\n\n/**\n* @name fullLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/full-like}\n*/\nimport fullLike from './../full-like';\nsetReadOnly( ns, 'fullLike', fullLike );\n\n/**\n* @name incrspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/incrspace}\n*/\nimport incrspace from './../incrspace';\nsetReadOnly( ns, 'incrspace', incrspace );\n\n/**\n* @name ArrayIndex\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/index}\n*/\nimport ArrayIndex from './../index';\nsetReadOnly( ns, 'ArrayIndex', ArrayIndex );\n\n/**\n* @name Int8Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/int8}\n*/\nimport Int8Array from './../int8';\nsetReadOnly( ns, 'Int8Array', Int8Array );\n\n/**\n* @name Int16Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/int16}\n*/\nimport Int16Array from './../int16';\nsetReadOnly( ns, 'Int16Array', Int16Array );\n\n/**\n* @name Int32Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/int32}\n*/\nimport Int32Array from './../int32';\nsetReadOnly( ns, 'Int32Array', Int32Array );\n\n/**\n* @name linspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/linspace}\n*/\nimport linspace from './../linspace';\nsetReadOnly( ns, 'linspace', linspace );\n\n/**\n* @name littleEndianFactory\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/little-endian-factory}\n*/\nimport littleEndianFactory from './../little-endian-factory';\nsetReadOnly( ns, 'littleEndianFactory', littleEndianFactory );\n\n/**\n* @name Float32ArrayLE\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/little-endian-float32}\n*/\nimport Float32ArrayLE from './../little-endian-float32';\nsetReadOnly( ns, 'Float32ArrayLE', Float32ArrayLE );\n\n/**\n* @name Float64ArrayLE\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/little-endian-float64}\n*/\nimport Float64ArrayLE from './../little-endian-float64';\nsetReadOnly( ns, 'Float64ArrayLE', Float64ArrayLE );\n\n/**\n* @name logspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/logspace}\n*/\nimport logspace from './../logspace';\nsetReadOnly( ns, 'logspace', logspace );\n\n/**\n* @name minDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/min-dtype}\n*/\nimport minDataType from './../min-dtype';\nsetReadOnly( ns, 'minDataType', minDataType );\n\n/**\n* @name mostlySafeCasts\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/mostly-safe-casts}\n*/\nimport mostlySafeCasts from './../mostly-safe-casts';\nsetReadOnly( ns, 'mostlySafeCasts', mostlySafeCasts );\n\n/**\n* @name mskfilter\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/mskfilter}\n*/\nimport mskfilter from './../mskfilter';\nsetReadOnly( ns, 'mskfilter', mskfilter );\n\n/**\n* @name mskput\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/mskput}\n*/\nimport mskput from './../mskput';\nsetReadOnly( ns, 'mskput', mskput );\n\n/**\n* @name mskreject\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/mskreject}\n*/\nimport mskreject from './../mskreject';\nsetReadOnly( ns, 'mskreject', mskreject );\n\n/**\n* @name nans\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/nans}\n*/\nimport nans from './../nans';\nsetReadOnly( ns, 'nans', nans );\n\n/**\n* @name nansLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/nans-like}\n*/\nimport nansLike from './../nans-like';\nsetReadOnly( ns, 'nansLike', nansLike );\n\n/**\n* @name nextDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/next-dtype}\n*/\nimport nextDataType from './../next-dtype';\nsetReadOnly( ns, 'nextDataType', nextDataType );\n\n/**\n* @name oneTo\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/one-to}\n*/\nimport oneTo from './../one-to';\nsetReadOnly( ns, 'oneTo', oneTo );\n\n/**\n* @name oneToLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/one-to-like}\n*/\nimport oneToLike from './../one-to-like';\nsetReadOnly( ns, 'oneToLike', oneToLike );\n\n/**\n* @name ones\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/ones}\n*/\nimport ones from './../ones';\nsetReadOnly( ns, 'ones', ones );\n\n/**\n* @name onesLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/ones-like}\n*/\nimport onesLike from './../ones-like';\nsetReadOnly( ns, 'onesLike', onesLike );\n\n/**\n* @name place\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/place}\n*/\nimport place from './../place';\nsetReadOnly( ns, 'place', place );\n\n/**\n* @name typedarraypool\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/pool}\n*/\nimport typedarraypool from './../pool';\nsetReadOnly( ns, 'typedarraypool', typedarraypool );\n\n/**\n* @name promotionRules\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/promotion-rules}\n*/\nimport promotionRules from './../promotion-rules';\nsetReadOnly( ns, 'promotionRules', promotionRules );\n\n/**\n* @name put\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/put}\n*/\nimport put from './../put';\nsetReadOnly( ns, 'put', put );\n\n/**\n* @name typedarrayReviver\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/reviver}\n*/\nimport typedarrayReviver from './../reviver';\nsetReadOnly( ns, 'typedarrayReviver', typedarrayReviver );\n\n/**\n* @name safeCasts\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/safe-casts}\n*/\nimport safeCasts from './../safe-casts';\nsetReadOnly( ns, 'safeCasts', safeCasts );\n\n/**\n* @name sameKindCasts\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/same-kind-casts}\n*/\nimport sameKindCasts from './../same-kind-casts';\nsetReadOnly( ns, 'sameKindCasts', sameKindCasts );\n\n/**\n* @name shape\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/shape}\n*/\nimport shape from './../shape';\nsetReadOnly( ns, 'shape', shape );\n\n/**\n* @name SharedArrayBuffer\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/shared-buffer}\n*/\nimport SharedArrayBuffer from './../shared-buffer';\nsetReadOnly( ns, 'SharedArrayBuffer', SharedArrayBuffer );\n\n/**\n* @name slice\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/slice}\n*/\nimport slice from './../slice';\nsetReadOnly( ns, 'slice', slice );\n\n/**\n* @name take\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/take}\n*/\nimport take from './../take';\nsetReadOnly( ns, 'take', take );\n\n/**\n* @name circarray2iterator\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-circular-iterator}\n*/\nimport circarray2iterator from './../to-circular-iterator';\nsetReadOnly( ns, 'circarray2iterator', circarray2iterator );\n\n/**\n* @name array2fancy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-fancy}\n*/\nimport array2fancy from './../to-fancy';\nsetReadOnly( ns, 'array2fancy', array2fancy );\n\n/**\n* @name array2iterator\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-iterator}\n*/\nimport array2iterator from './../to-iterator';\nsetReadOnly( ns, 'array2iterator', array2iterator );\n\n/**\n* @name array2iteratorRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-iterator-right}\n*/\nimport array2iteratorRight from './../to-iterator-right';\nsetReadOnly( ns, 'array2iteratorRight', array2iteratorRight );\n\n/**\n* @name typedarray2json\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-json}\n*/\nimport typedarray2json from './../to-json';\nsetReadOnly( ns, 'typedarray2json', typedarray2json );\n\n/**\n* @name sparsearray2iterator\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-sparse-iterator}\n*/\nimport sparsearray2iterator from './../to-sparse-iterator';\nsetReadOnly( ns, 'sparsearray2iterator', sparsearray2iterator );\n\n/**\n* @name sparsearray2iteratorRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-sparse-iterator-right}\n*/\nimport sparsearray2iteratorRight from './../to-sparse-iterator-right';\nsetReadOnly( ns, 'sparsearray2iteratorRight', sparsearray2iteratorRight );\n\n/**\n* @name stridedarray2iterator\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-strided-iterator}\n*/\nimport stridedarray2iterator from './../to-strided-iterator';\nsetReadOnly( ns, 'stridedarray2iterator', stridedarray2iterator );\n\n/**\n* @name arrayview2iterator\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-view-iterator}\n*/\nimport arrayview2iterator from './../to-view-iterator';\nsetReadOnly( ns, 'arrayview2iterator', arrayview2iterator );\n\n/**\n* @name arrayview2iteratorRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-view-iterator-right}\n*/\nimport arrayview2iteratorRight from './../to-view-iterator-right';\nsetReadOnly( ns, 'arrayview2iteratorRight', arrayview2iteratorRight );\n\n/**\n* @name typedarray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed}\n*/\nimport typedarray from './../typed';\nsetReadOnly( ns, 'typedarray', typedarray );\n\n/**\n* @name complexarray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-complex}\n*/\nimport complexarray from './../typed-complex';\nsetReadOnly( ns, 'complexarray', complexarray );\n\n/**\n* @name complexarrayCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-complex-ctors}\n*/\nimport complexarrayCtors from './../typed-complex-ctors';\nsetReadOnly( ns, 'complexarrayCtors', complexarrayCtors );\n\n/**\n* @name complexarrayDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-complex-dtypes}\n*/\nimport complexarrayDataTypes from './../typed-complex-dtypes';\nsetReadOnly( ns, 'complexarrayDataTypes', complexarrayDataTypes );\n\n/**\n* @name typedarrayCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-ctors}\n*/\nimport typedarrayCtors from './../typed-ctors';\nsetReadOnly( ns, 'typedarrayCtors', typedarrayCtors );\n\n/**\n* @name typedarrayDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-dtypes}\n*/\nimport typedarrayDataTypes from './../typed-dtypes';\nsetReadOnly( ns, 'typedarrayDataTypes', typedarrayDataTypes );\n\n/**\n* @name floatarrayCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-float-ctors}\n*/\nimport floatarrayCtors from './../typed-float-ctors';\nsetReadOnly( ns, 'floatarrayCtors', floatarrayCtors );\n\n/**\n* @name floatarrayDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-float-dtypes}\n*/\nimport floatarrayDataTypes from './../typed-float-dtypes';\nsetReadOnly( ns, 'floatarrayDataTypes', floatarrayDataTypes );\n\n/**\n* @name intarrayCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-integer-ctors}\n*/\nimport intarrayCtors from './../typed-integer-ctors';\nsetReadOnly( ns, 'intarrayCtors', intarrayCtors );\n\n/**\n* @name intarrayDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-integer-dtypes}\n*/\nimport intarrayDataTypes from './../typed-integer-dtypes';\nsetReadOnly( ns, 'intarrayDataTypes', intarrayDataTypes );\n\n/**\n* @name realarray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-real}\n*/\nimport realarray from './../typed-real';\nsetReadOnly( ns, 'realarray', realarray );\n\n/**\n* @name realarrayCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-real-ctors}\n*/\nimport realarrayCtors from './../typed-real-ctors';\nsetReadOnly( ns, 'realarrayCtors', realarrayCtors );\n\n/**\n* @name realarrayDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-real-dtypes}\n*/\nimport realarrayDataTypes from './../typed-real-dtypes';\nsetReadOnly( ns, 'realarrayDataTypes', realarrayDataTypes );\n\n/**\n* @name realarrayFloatCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-real-float-ctors}\n*/\nimport realarrayFloatCtors from './../typed-real-float-ctors';\nsetReadOnly( ns, 'realarrayFloatCtors', realarrayFloatCtors );\n\n/**\n* @name realarrayFloatDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-real-float-dtypes}\n*/\nimport realarrayFloatDataTypes from './../typed-real-float-dtypes';\nsetReadOnly( ns, 'realarrayFloatDataTypes', realarrayFloatDataTypes );\n\n/**\n* @name intarraySignedCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-signed-integer-ctors}\n*/\nimport intarraySignedCtors from './../typed-signed-integer-ctors';\nsetReadOnly( ns, 'intarraySignedCtors', intarraySignedCtors );\n\n/**\n* @name intarraySignedDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-signed-integer-dtypes}\n*/\nimport intarraySignedDataTypes from './../typed-signed-integer-dtypes';\nsetReadOnly( ns, 'intarraySignedDataTypes', intarraySignedDataTypes );\n\n/**\n* @name intarrayUnsignedCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-unsigned-integer-ctors}\n*/\nimport intarrayUnsignedCtors from './../typed-unsigned-integer-ctors';\nsetReadOnly( ns, 'intarrayUnsignedCtors', intarrayUnsignedCtors );\n\n/**\n* @name intarrayUnsignedDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-unsigned-integer-dtypes}\n*/\nimport intarrayUnsignedDataTypes from './../typed-unsigned-integer-dtypes';\nsetReadOnly( ns, 'intarrayUnsignedDataTypes', intarrayUnsignedDataTypes );\n\n/**\n* @name Uint8Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/uint8}\n*/\nimport Uint8Array from './../uint8';\nsetReadOnly( ns, 'Uint8Array', Uint8Array );\n\n/**\n* @name Uint8ClampedArray\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/uint8c}\n*/\nimport Uint8ClampedArray from './../uint8c';\nsetReadOnly( ns, 'Uint8ClampedArray', Uint8ClampedArray );\n\n/**\n* @name Uint16Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/uint16}\n*/\nimport Uint16Array from './../uint16';\nsetReadOnly( ns, 'Uint16Array', Uint16Array );\n\n/**\n* @name Uint32Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/uint32}\n*/\nimport Uint32Array from './../uint32';\nsetReadOnly( ns, 'Uint32Array', Uint32Array );\n\n/**\n* @name zeroTo\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/zero-to}\n*/\nimport zeroTo from './../zero-to';\nsetReadOnly( ns, 'zeroTo', zeroTo );\n\n/**\n* @name zeroToLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/zero-to-like}\n*/\nimport zeroToLike from './../zero-to-like';\nsetReadOnly( ns, 'zeroToLike', zeroToLike );\n\n/**\n* @name zeros\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/zeros}\n*/\nimport zeros from './../zeros';\nsetReadOnly( ns, 'zeros', zeros );\n\n/**\n* @name zerosLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/zeros-like}\n*/\nimport zerosLike from './../zeros-like';\nsetReadOnly( ns, 'zerosLike', zerosLike );\n\n/**\n* @name constants\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/constants/array}\n*/\nimport constants from '@stdlib/constants/array';\nsetReadOnly( ns, 'constants', constants );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport base from './../../base/cartesian-power';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian power.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} n - power\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a nonnegative integer\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = cartesianPower( x, 2 );\n* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]\n*/\nfunction cartesianPower( x, n ) {\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isNonNegativeInteger( n ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', n ) );\n\t}\n\treturn base( x, n );\n}\n\n\n// EXPORTS //\n\nexport default cartesianPower;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/cartesian-product';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian product.\n*\n* @param {Collection} x1 - first input array\n* @param {Collection} x2 - second input array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x1 = [ 1, 2, 3 ];\n* var x2 = [ 4, 5 ];\n*\n* var out = cartesianProduct( x1, x2 );\n* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ]\n*/\nfunction cartesianProduct( x1, x2 ) {\n\tif ( !isCollection( x1 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x1 ) );\n\t}\n\tif ( !isCollection( x2 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', x2 ) );\n\t}\n\treturn base( x1, x2 );\n}\n\n\n// EXPORTS //\n\nexport default cartesianProduct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/cartesian-square';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian square.\n*\n* @param {Collection} x - input array\n* @throws {TypeError} first argument must be a collection\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = cartesianSquare( x );\n* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]\n*/\nfunction cartesianSquare( x ) {\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\treturn base( x );\n}\n\n\n// EXPORTS //\n\nexport default cartesianSquare;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getType from './../../dtype';\nimport convert from './../../convert';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Converts an array to the same data type as a second input array.\n*\n* @param {Collection} x - array to convert\n* @param {(Array|TypedArray|ComplexArray)} y - array having the desired output data type\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must have a recognized data type\n* @returns {(Array|TypedArray|ComplexArray)} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ 1.0, 2.0, 3.0, 4.0 ];\n* var y = new Float64Array( 0 );\n*\n* var out = convertSame( x, y );\n* // returns [ 1.0, 2.0, 3.0, 4.0 ]\n*/\nfunction convertSame( x, y ) {\n\tvar dtype = getType( y );\n\tif ( dtype === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must have a recognized/supported data type. Type: `%s`. Value: `%s`.', dtype, y ) );\n\t}\n\treturn convert( x, dtype );\n}\n\n\n// EXPORTS //\n\nexport default convertSame;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dtype from './../../dtype';\nimport empty from './../../empty';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized array having the same length and data type as a provided input array.\n*\n* @param {(Array|TypedArray|ComplexArray)} x - input array\n* @param {string} [dtype] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = emptyLike( [ 0.0, 0.0 ] );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = emptyLike( [ 0.0, 0.0 ], 'float32' );\n* // returns \n*/\nfunction emptyLike( x ) {\n\tvar dt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t}\n\treturn empty( x.length, dt );\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isIteratorLike from '@stdlib/assert/is-iterator-like';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport accessorSetter from './../../base/accessor-setter';\nimport setter from './../../base/setter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Creates (or fills) an array from an iterator.\n*\n* @param {Iterator} iterator - source iterator\n* @param {Collection} [out] - output array\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} iterator argument must be an iterator\n* @throws {TypeError} callback argument must be a function\n* @returns {Collection} output array\n*\n* @example\n* import randu from '@stdlib/random/iter/randu';\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\nimport dtype from './../../dtype';\nimport full from './../../full';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\n\n\n// MAIN //\n\n/**\n* Creates a filled array having the same length and data type as a provided input array.\n*\n* @param {(Array|TypedArray|ComplexArray)} x - input array\n* @param {number} value - fill value\n* @param {string} [dtype] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} third argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = fullLike( [ 0.0, 0.0 ], 1.0 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = fullLike( [ 0.0, 0.0 ], 1.0, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*/\nfunction fullLike( x, value ) {\n\tvar dt;\n\tvar v;\n\n\tdt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tdt = arguments[ 2 ];\n\t}\n\tif ( typeof value === 'number' ) {\n\t\tif ( dt === 'complex128' ) {\n\t\t\tv = new Complex128( value, 0.0 );\n\t\t} else if ( dt === 'complex64' ) {\n\t\t\tv = new Complex64( value, 0.0 );\n\t\t} else {\n\t\t\tv = value;\n\t\t}\n\t} else {\n\t\tv = value;\n\t}\n\treturn full( x.length, v, dt );\n}\n\n\n// EXPORTS //\n\nexport default fullLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ceil from '@stdlib/math/base/special/ceil';\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport format from '@stdlib/string/format';\nimport MAX_LENGTH from '@stdlib/constants/uint32/max';\nimport gen from './../../base/incrspace';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array using a provided increment.\n*\n* @param {number} x1 - first array value\n* @param {number} x2 - array element bound\n* @param {number} [increment=1] - increment\n* @throws {TypeError} first argument must be numeric\n* @throws {TypeError} second argument must be numeric\n* @throws {TypeError} third argument must be numeric\n* @throws {RangeError} length of created array must be less than `4294967295` (`2**32 - 1`)\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = incrspace( 0, 11, 2 );\n* // returns [ 0, 2, 4, 6, 8, 10 ]\n*/\nfunction incrspace( x1, x2, increment ) {\n\tvar len;\n\tvar inc;\n\tif ( !isNumber( x1 ) || isnan( x1 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Start must be numeric. Value: `%s`.', x1 ) );\n\t}\n\tif ( !isNumber( x2 ) || isnan( x2 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Stop must be numeric. Value: `%s`.', x2 ) );\n\t}\n\tif ( arguments.length < 3 ) {\n\t\tinc = 1;\n\t} else {\n\t\tinc = increment;\n\t\tif ( !isNumber( inc ) || isnan( inc ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Increment must be numeric. Value: `%s`.', inc ) );\n\t\t}\n\t}\n\tlen = ceil( ( x2-x1 ) / inc );\n\tif ( len > MAX_LENGTH ) {\n\t\tthrow new RangeError( 'invalid arguments. Generated array exceeds maximum array length.' );\n\t}\n\treturn gen( x1, x2, inc );\n}\n\n\n// EXPORTS //\n\nexport default incrspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport format from '@stdlib/string/format';\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport gen from './../../base/logspace';\n\n\n// MAIN //\n\n/**\n* Generates a logarithmically spaced numeric array.\n*\n* @param {number} a - exponent of start value\n* @param {number} b - exponent of end value\n* @param {NonNegativeInteger} [len=10] - length of output array\n* @throws {TypeError} first argument must be numeric\n* @throws {TypeError} second argument must be numeric\n* @throws {TypeError} third argument must be a nonnegative integer\n* @returns {Array} logarithmically spaced numeric array\n*\n* @example\n* var arr = logspace( 0, 2, 6 );\n* // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ]\n*/\nfunction logspace( a, b, len ) {\n\tif ( !isNumber( a ) || isnan( a ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Exponent of start value must be numeric. Value: `%s`.', a ) );\n\t}\n\tif ( !isNumber( b ) || isnan( b ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Exponent of stop value must be numeric. Value: `%s`.', b ) );\n\t}\n\tif ( arguments.length < 3 ) {\n\t\tlen = 10;\n\t} else if ( !isNonNegativeInteger( len ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t}\n\treturn gen( a, b, len );\n}\n\n\n// EXPORTS //\n\nexport default logspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isMostlySafeCast from './../../base/assert/is-mostly-safe-data-type-cast';\nimport isRealDataType from './../../base/assert/is-real-data-type';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/mskput';\nimport dtype from './../../dtype';\nimport convert from './../../convert';\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Replaces elements of an array with provided values according to a provided mask array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @param {Options} [options] - function options\n* @param {string} [options.mode='repeat'] - string specifying behavior when the number of values does not equal the number of falsy mask values\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {TypeError} third argument must be a collection\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @throws {Error} insufficient values to satisfy mask array\n* @throws {Error} number of values does not equal the number of falsy mask values\n* @throws {TypeError} third argument cannot be safely cast to the data type of the first argument\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = [ 20, 30 ];\n*\n* var out = mskput( x, mask, values );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = [ 30 ];\n*\n* var out = mskput( x, mask, values );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 0, 1, 0 ];\n* var values = [ 20, 30 ];\n*\n* var out = mskput( x, mask, values );\n* // returns [ 20, 30, 3, 20 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction mskput( x, mask, values ) {\n\tvar opts;\n\tvar err;\n\tvar xdt;\n\tvar vdt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( mask ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) );\n\t}\n\tif ( !isCollection( values ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', values ) );\n\t}\n\topts = defaults();\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\txdt = dtype( x ) || 'generic';\n\tvdt = dtype( values ) || 'generic';\n\n\t// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the input array data type is floating-point...\n\tif ( !isMostlySafeCast( vdt, xdt ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].', vdt, xdt ) );\n\t}\n\t// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...\n\tif ( isComplexDataType( xdt ) && isRealDataType( vdt ) ) {\n\t\tvalues = convert( values, xdt );\n\t}\n\t// Replace values in the input array:\n\treturn base( x, mask, values, opts.mode );\n}\n\n\n// EXPORTS //\n\nexport default mskput;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'mode': 'repeat'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport NEXT_DTYPES from './next_dtypes.json';\n\n\n// FUNCTIONS //\n\n/**\n* Generates a table.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( NEXT_DTYPES );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tout[ dtypes[i] ] = NEXT_DTYPES[ dtypes[i] ];\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns the next larger array data type of the same kind.\n*\n* @param {string} [dtype] - array data type\n* @returns {(Object|string|integer|null)} next larger data type(s) or null\n*\n* @example\n* var dt = nextDataType( 'float32' );\n* // returns 'float64'\n*/\nfunction nextDataType( dtype ) {\n\tif ( arguments.length === 0 ) {\n\t\treturn generateTable();\n\t}\n\tif ( hasOwnProp( NEXT_DTYPES, dtype ) ) {\n\t\treturn NEXT_DTYPES[ dtype ];\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default nextDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport oneTo from './../../one-to';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array.\n*\n* @param {(TypedArray|Array|ComplexArray)} x - input array\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = oneToLike( [ 0.0, 0.0 ] );\n* // returns [ 1.0, 2.0 ]\n*\n* @example\n* var arr = oneToLike( [ 0.0, 0.0 ], 'float32' );\n* // returns [ 1.0, 2.0 ]\n*/\nfunction oneToLike( x ) {\n\tvar dt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t}\n\treturn oneTo( x.length, dt );\n}\n\n\n// EXPORTS //\n\nexport default oneToLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport resolve from '@stdlib/strided/base/dtype-resolve-str';\nimport PROMOTION_RULES from './promotion_rules.json';\n\n\n// FUNCTIONS //\n\n/**\n* Generates a full table of promotion rules.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateFullTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( PROMOTION_RULES );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = PROMOTION_RULES[ dt1 ];\n\t\ttmp = {};\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\ttmp[ dt2 ] = o[ dt2 ];\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns the array data type with the smallest size and closest \"kind\" to which array data types can be safely cast.\n*\n* @param {*} [dtype1] - array data type value\n* @param {*} [dtype2] - array data type value\n* @returns {(Object|integer|string|null)} promotion rule(s) or null\n*\n* @example\n* var table = promotionRules();\n* // returns {...}\n*\n* @example\n* var dt = promotionRules( 'float32', 'uint32' );\n* // returns 'float64'\n*\n* @example\n* var dt = promotionRules( 'float32', 'foo' );\n* // returns null\n*/\nfunction promotionRules( dtype1, dtype2 ) {\n\tvar o;\n\tif ( arguments.length === 0 ) {\n\t\treturn generateFullTable();\n\t}\n\tdtype1 = resolve( dtype1 );\n\tif ( hasOwnProp( PROMOTION_RULES, dtype1 ) ) {\n\t\to = PROMOTION_RULES[ dtype1 ];\n\t\tdtype2 = resolve( dtype2 );\n\t\tif ( hasOwnProp( o, dtype2 ) ) {\n\t\t\treturn o[ dtype2 ];\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default promotionRules;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport ctors from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Revives a JSON-serialized typed array.\n*\n* @param {string} key - key\n* @param {*} value - value\n* @returns {(*|TypedArray)} value or typed array\n*\n* @example\n* import parseJSON from '@stdlib/utils/parse-json';\n*\n* var str = '{\"type\":\"Float64Array\",\"data\":[5,3]}';\n*\n* var arr = parseJSON( str, reviveTypedArray );\n* // returns [ 5.0, 3.0 ]\n*/\nfunction reviveTypedArray( key, value ) {\n\tvar ctor;\n\tif (\n\t\tvalue &&\n\t\tvalue.type &&\n\t\tisArray( value.data )\n\t) {\n\t\tctor = ctors[ value.type ];\n\t\tif ( ctor ) {\n\t\t\treturn new ctor( value.data );\n\t\t}\n\t}\n\treturn value;\n}\n\n\n// EXPORTS //\n\nexport default reviveTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport base from './../../base/slice';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a shallow copy of a portion of an array.\n*\n* @param {Collection} x - input array\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end=x.length] - ending index (exclusive)\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = slice( x, 1, 3 );\n* // returns [ 2, 3 ]\n*\n* var bool = ( out === x );\n* // returns false\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var out = slice( x, 1, 3 );\n* // returns [ 2, 3 ]\n*\n* var bool = ( out === x );\n* // returns false\n*/\nfunction slice( x ) {\n\tvar start;\n\tvar end;\n\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tstart = arguments[ 1 ];\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tend = arguments[ 2 ];\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t} else {\n\t\t\tend = x.length;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = x.length;\n\t}\n\treturn base( x, start, end );\n}\n\n\n// EXPORTS //\n\nexport default slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isObject from '@stdlib/assert/is-plain-object';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which repeatedly iterates over each element in an array-like object.\n*\n* @param {Collection} src - input value\n* @param {Options} [options] - function options\n* @param {NonNegativeInteger} [options.iter] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} callback argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = circarray2iterator( [ 1, 2, 3, 4 ] );\n*\n* var v = iter.next().value;\n* // returns 1\n*\n* v = iter.next().value;\n* // returns 2\n*\n* v = iter.next().value;\n* // returns 3\n*\n* // ...\n*/\nfunction circarray2iterator( src ) {\n\tvar thisArg;\n\tvar options;\n\tvar count;\n\tvar opts;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = {\n\t\t'iter': 1e308, // ~infinity\n\t\t'dir': 1 // left to right iteration\n\t};\n\tif ( arguments.length > 1 ) {\n\t\tif ( isObject( arguments[ 1 ] ) ) {\n\t\t\toptions = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\t\t\topts.iter = options.iter;\n\t\t\t\tif ( !isNonNegativeInteger( options.iter ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', options.iter ) );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\t\t\topts.dir = options.dir;\n\t\t\t\tif ( options.dir !== 1 && options.dir !== -1 ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', options.dir ) );\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a function or an options object. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tcount = 0;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tif ( opts.dir === 1 ) {\n\t\t\ti = -1;\n\t\t\tsetReadOnly( iter, 'next', next1a );\n\t\t} else {\n\t\t\ti = src.length;\n\t\t\tsetReadOnly( iter, 'next', next1b );\n\t\t}\n\t} else if ( opts.dir === 1 ) {\n\t\ti = -1;\n\t\tsetReadOnly( iter, 'next', next2a );\n\t} else {\n\t\ti = src.length;\n\t\tsetReadOnly( iter, 'next', next2b );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1a() {\n\t\ti = (i+1) % src.length;\n\t\tcount += 1;\n\t\tif ( FLG || count > opts.iter || src.length === 0 ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, count, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1b() {\n\t\ti -= 1;\n\t\tif ( i < 0 ) {\n\t\t\ti += src.length;\n\t\t}\n\t\tcount += 1;\n\t\tif ( FLG || count > opts.iter || src.length === 0 ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, count, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2a() {\n\t\ti = (i+1) % src.length;\n\t\tcount += 1;\n\t\tif ( FLG || count > opts.iter || src.length === 0 ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2b() {\n\t\ti -= 1;\n\t\tif ( i < 0 ) {\n\t\t\ti += src.length;\n\t\t}\n\t\tcount += 1;\n\t\tif ( FLG || count > opts.iter || src.length === 0 ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn circarray2iterator( src, opts, fcn, thisArg );\n\t\t}\n\t\treturn circarray2iterator( src, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default circarray2iterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates over each element in an array-like object.\n*\n* @param {Collection} src - input value\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = array2iterator( [ 1, 2, 3, 4 ] );\n*\n* var v = iter.next().value;\n* // returns 1\n*\n* v = iter.next().value;\n* // returns 2\n*\n* v = iter.next().value;\n* // returns 3\n*\n* // ...\n*/\nfunction array2iterator( src ) {\n\tvar thisArg;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tfcn = arguments[ 1 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 2 ];\n\t}\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\ti += 1;\n\t\tif ( FLG || i >= src.length ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\ti += 1;\n\t\tif ( FLG || i >= src.length ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn array2iterator( src, fcn, thisArg );\n\t\t}\n\t\treturn array2iterator( src );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default array2iterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates from right to left over each element in an array-like object.\n*\n* ## Notes\n*\n* - For dynamic array resizing, the only behavior made intentionally consistent with iterating from left to right is when elements are pushed onto the beginning (end) of an array. In other words, iterating from left to right combined with `[].push()` is consistent with iterating from right to left combined with `[].unshift()`.\n*\n* @param {Collection} src - input value\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = array2iteratorRight( [ 1, 2, 3, 4 ] );\n*\n* var v = iter.next().value;\n* // returns 4\n*\n* v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 2\n*\n* // ...\n*/\nfunction array2iteratorRight( src ) {\n\tvar thisArg;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar len;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tfcn = arguments[ 1 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 2 ];\n\t}\n\tlen = src.length;\n\ti = len;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\ti += src.length - len - 1; // accounts for a dynamic array\n\t\tlen = src.length;\n\t\tif ( FLG || i < 0 ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\ti += src.length - len - 1; // accounts for a dynamic array\n\t\tlen = src.length;\n\t\tif ( FLG || i < 0 ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn array2iteratorRight( src, fcn, thisArg );\n\t\t}\n\t\treturn array2iteratorRight( src );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default array2iteratorRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates over each element in a sparse array-like object.\n*\n* @param {Collection} src - input value\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = sparsearray2iterator( [ 1, , 3, 4 ] );\n*\n* var v = iter.next().value;\n* // returns 1\n*\n* v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 4\n*/\nfunction sparsearray2iterator( src ) {\n\tvar thisArg;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tfcn = arguments[ 1 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 2 ];\n\t}\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\tvar len;\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tlen = src.length;\n\t\ti += 1;\n\t\twhile ( i < len && get( src, i ) === void 0 ) {\n\t\t\ti += 1;\n\t\t}\n\t\tif ( i >= len ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\tvar len;\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tlen = src.length;\n\t\ti += 1;\n\t\twhile ( i < len && get( src, i ) === void 0 ) {\n\t\t\ti += 1;\n\t\t}\n\t\tif ( i >= len ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn sparsearray2iterator( src, fcn, thisArg );\n\t\t}\n\t\treturn sparsearray2iterator( src );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default sparsearray2iterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates from right to left over each element in a sparse array-like object.\n*\n* ## Notes\n*\n* - For dynamic array resizing, the only behavior made intentionally consistent with iterating from left to right is when elements are pushed onto the beginning (end) of an array. In other words, iterating from left to right combined with `[].push()` is consistent with iterating from right to left combined with `[].unshift()`.\n*\n* @param {Collection} src - input value\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = sparsearray2iteratorRight( [ 1, , 3, 4 ] );\n*\n* var v = iter.next().value;\n* // returns 4\n*\n* v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 1\n*/\nfunction sparsearray2iteratorRight( src ) {\n\tvar thisArg;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar len;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tfcn = arguments[ 1 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 2 ];\n\t}\n\tlen = src.length;\n\ti = len;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\ti += src.length - len - 1; // accounts for a dynamic array\n\t\tlen = src.length;\n\t\twhile ( i >= 0 && get( src, i ) === void 0 ) {\n\t\t\ti -= 1;\n\t\t}\n\t\tif ( i < 0 ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\ti += src.length - len - 1; // accounts for a dynamic array\n\t\tlen = src.length;\n\t\twhile ( i >= 0 && get( src, i ) === void 0 ) {\n\t\t\ti -= 1;\n\t\t}\n\t\tif ( i < 0 ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn sparsearray2iteratorRight( src, fcn, thisArg );\n\t\t}\n\t\treturn sparsearray2iteratorRight( src );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default sparsearray2iteratorRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates over elements in an array-like object according to specified stride parameters.\n*\n* @param {NonNegativeInteger} N - number of values to iterate\n* @param {Collection} src - input value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} fifth argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var values = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n*\n* var N = 4;\n* var stride = -2;\n* var offset = 6;\n*\n* var iter = stridedarray2iterator( N, values, stride, offset );\n*\n* var v = iter.next().value;\n* // returns 7\n*\n* v = iter.next().value;\n* // returns 5\n*\n* v = iter.next().value;\n* // returns 3\n*\n* // ...\n*/\nfunction stridedarray2iterator( N, src, stride, offset ) {\n\tvar thisArg;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar idx;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( arguments.length > 4 ) {\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tidx = offset;\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\tvar v;\n\t\ti += 1;\n\t\tif ( FLG || i >= N ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tv = fcn.call( thisArg, get( src, idx ), idx, i, src );\n\t\tidx += stride;\n\t\treturn {\n\t\t\t'value': v,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\tvar v;\n\t\ti += 1;\n\t\tif ( FLG || i >= N ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tv = get( src, idx );\n\t\tidx += stride;\n\t\treturn {\n\t\t\t'value': v,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn stridedarray2iterator( N, src, stride, offset, fcn, thisArg ); // eslint-disable-line max-len\n\t\t}\n\t\treturn stridedarray2iterator( N, src, stride, offset );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default stridedarray2iterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates over each element in an array-like object view.\n*\n* @param {Collection} src - input value\n* @param {integer} [begin=0] - starting index (inclusive)\n* @param {integer} [end=src.length] - ending index (non-inclusive)\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be either an integer (starting index) or a function\n* @throws {TypeError} third argument must be either an integer (ending index) or a function\n* @throws {TypeError} fourth argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = arrayview2iterator( [ 1, 2, 3, 4 ], 1, 3 );\n*\n* var v = iter.next().value;\n* // returns 2\n*\n* v = iter.next().value;\n* // returns 3\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nfunction arrayview2iterator( src ) {\n\tvar thisArg;\n\tvar begin;\n\tvar nargs;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar end;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 1 ) {\n\t\tbegin = 0;\n\t\tend = src.length;\n\t} else if ( nargs === 2 ) {\n\t\tif ( isFunction( arguments[ 1 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 1 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 1 ];\n\t\t}\n\t\tend = src.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 1 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = src.length;\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tthisArg = arguments[ 2 ];\n\t\t} else if ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = arguments[ 1 ];\n\t\t\tend = src.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 1 ];\n\t\t\tend = arguments[ 2 ];\n\t\t}\n\t} else { // nargs >= 4\n\t\tbegin = arguments[ 1 ];\n\t\tend = arguments[ 2 ];\n\t\tfcn = arguments[ 3 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = src.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > src.length ) {\n\t\tend = src.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = src.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\ti = begin - 1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', finish );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\ti += 1;\n\t\tif ( FLG || i >= end ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, i-begin, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\ti += 1;\n\t\tif ( FLG || i >= end ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction finish( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn arrayview2iterator( src, begin, end, fcn, thisArg );\n\t\t}\n\t\treturn arrayview2iterator( src, begin, end );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default arrayview2iterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates from right to left over each element in an array-like object view.\n*\n* @param {Collection} src - input value\n* @param {integer} [begin=0] - starting **view** index (inclusive)\n* @param {integer} [end=src.length] - ending **view** index (non-inclusive)\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be either an integer (starting index) or a function\n* @throws {TypeError} third argument must be either an integer (ending index) or a function\n* @throws {TypeError} fourth argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 3 );\n*\n* var v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 2\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nfunction arrayview2iteratorRight( src ) {\n\tvar thisArg;\n\tvar begin;\n\tvar nargs;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar end;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 1 ) {\n\t\tbegin = 0;\n\t\tend = src.length;\n\t} else if ( nargs === 2 ) {\n\t\tif ( isFunction( arguments[ 1 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 1 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 1 ];\n\t\t}\n\t\tend = src.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 1 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = src.length;\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tthisArg = arguments[ 2 ];\n\t\t} else if ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = arguments[ 1 ];\n\t\t\tend = src.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 1 ];\n\t\t\tend = arguments[ 2 ];\n\t\t}\n\t} else { // nargs >= 4\n\t\tbegin = arguments[ 1 ];\n\t\tend = arguments[ 2 ];\n\t\tfcn = arguments[ 3 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either an integer (starting view index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (ending view index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = src.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > src.length ) {\n\t\tend = src.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = src.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\ti = end;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', finish );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\ti -= 1;\n\t\tif ( FLG || i < begin ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, end-i-1, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\ti -= 1;\n\t\tif ( FLG || i < begin ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction finish( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn arrayview2iteratorRight( src, begin, end, fcn, thisArg );\n\t\t}\n\t\treturn arrayview2iteratorRight( src, begin, end );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default arrayview2iteratorRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of complex typed array data types.\n*\n* @returns {StringArray} list of complex typed array data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'complex64', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'complex_floating_point' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array data types.\n*\n* @returns {StringArray} list of typed array data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'float32', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'typed' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array floating-point data types.\n*\n* @returns {StringArray} list of typed array floating-point data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'float32', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'floating_point' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns an integer-valued typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'int32' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'int' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array integer data types.\n*\n* @returns {StringArray} list of typed array integer data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'int16', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'integer' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array real-valued data types.\n*\n* @returns {StringArray} list of typed array data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'float32', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'real' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a real-valued floating-point typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array real-valued floating-point data types.\n*\n* @returns {StringArray} list of typed array real-valued floating-point data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'float32', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'real_floating_point' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a signed integer typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'int32' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'int' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array signed integer data types.\n*\n* @returns {StringArray} list of typed array signed integer data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'int16', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'signed_integer' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns an unsigned integer typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'uint32' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'uint' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array unsigned integer data types.\n*\n* @returns {StringArray} list of typed array unsigned integer data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'uint16', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'unsigned_integer' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport zeroTo from './../../zero-to';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array.\n*\n* @param {(TypedArray|Array|ComplexArray)} x - input array\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = zeroToLike( [ 0.0, 0.0 ] );\n* // returns [ 0.0, 1.0 ]\n*\n* @example\n* var arr = zeroToLike( [ 0.0, 0.0 ], 'float32' );\n* // returns [ 0.0, 1.0 ]\n*/\nfunction zeroToLike( x ) {\n\tvar dt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t}\n\treturn zeroTo( x.length, dt );\n}\n\n\n// EXPORTS //\n\nexport default zeroToLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\nimport dtype from './../../dtype';\nimport zeros from './../../zeros';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled array having the same length and data type as a provided input array.\n*\n* @param {(Array|TypedArray|ComplexArray)} x - input array\n* @param {string} [dtype] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = zerosLike( [ 0.0, 0.0 ] );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = zerosLike( [ 0.0, 0.0 ], 'float32' );\n* // returns [ 0.0, 0.0 ]\n*/\nfunction zerosLike( x ) {\n\tvar dt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t}\n\treturn zeros( x.length, dt );\n}\n\n\n// EXPORTS //\n\nexport default zerosLike;\n"],"names":["main","Object","defineProperty","isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","f","digits","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","parseFloat","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply","objectProtoype","toStr","defineGetter","__defineGetter__","defineSetter","__defineSetter__","lookupGetter","__lookupGetter__","lookupSetter","__lookupSetter__","err","hasDefinePropertySupport","builtin","obj","prop","descriptor","hasValue","hasGet","hasSet","__proto__","get","set","defineProperty$1","setReadOnly","configurable","enumerable","writable","setNonEnumerableReadOnly","TYPE","isAccessorArray","GETTERS","float64","arr","idx","float32","int32","int16","int8","uint32","uint16","uint8","uint8c","generic","default","getter","dtype","SETTERS","setter","complex128","complex64","FLG","Symbol","hasToStringTagSupport","toStringTag","has","hasOwnProperty","hasOwnProp","property","Sym","toStrTag","nativeClass","hasToStringTag","v","isOwn","tag","main$g","arrayfcn","predicate","len","isObjectLike","isBuffer","_isBuffer","constructor","reFunctionName","arrayfun","RE_FUNCTION_NAME","constructorName","name","ctor","REGEXP","ctor2dtypes","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray","Complex64Array","Complex128Array","BooleanArray","hasFloat64Array","hasFloat64ArraySupport","bool","GlobalFloat64Array","NaN","Float64Array$2","hasFloat32Array","FLOAT64_PINF","Number","POSITIVE_INFINITY","hasFloat32ArraySupport","GlobalFloat32Array","PINF","Float32Array$2","hasUint32Array","UINT32_MAX","hasUint32ArraySupport","GlobalUint32Array","Uint32Array$2","hasInt32Array","INT32_MAX","INT32_MIN","hasInt32ArraySupport","GlobalInt32Array","Int32Array$2","hasUint16Array","UINT16_MAX","hasUint16ArraySupport","GlobalUint16Array","Uint16Array$2","hasInt16Array","INT16_MAX","INT16_MIN","hasInt16ArraySupport","GlobalInt16Array","Int16Array$2","hasUint8Array","UINT8_MAX","hasUint8ArraySupport","GlobalUint8Array","Uint8Array$2","hasUint8ClampedArray","hasUint8ClampedArraySupport","GlobalUint8ClampedArray","Uint8ClampedArray$2","hasInt8Array","INT8_MAX","INT8_MIN","hasInt8ArraySupport","GlobalInt8Array","Int8Array$2","main$6","test","isPrimitive","isObject","FLOAT64_NINF","NEGATIVE_INFINITY","floor","isInteger","x","NINF","isInt","valueOf","isNonNegativeInteger","MAX_ARRAY_LENGTH","isArrayLikeObject","MAX_LENGTH","MAX_TYPED_ARRAY_LENGTH","isCollection","hasArrayBuffer","ArrayBuffer","isArrayBuffer","isString","isPrimitiveArray","isObjectArray","isStringArray","isBoolean","Bool","Boolean","self","window","globalThis","root","codegen","Function","GlobalThis","Self","Win","getGlobal","nodeList","document","childNodes","typedarray","ctorName","type","isFunction","typeOf","Complex128","real","imag","this","re","im","fround","Float32Array$1","FLOAT32_VIEW","f32","Complex64","float64ToFloat32","isComplexLike","isEven","BYTES_PER_ELEMENT","isComplex64Array","isComplex128Array","hasIteratorSymbolSupport","iterator","IteratorSymbol","setNonEnumerableReadOnlyAccessor","z","reinterpret","offset","buffer","byteOffset","Float64Array$1","fromIterator","it","next","done","realf","imagf","HAS_ITERATOR_SYMBOL","isComplexArray","_length","_buffer","isComplexArrayConstructor","getComplex64","buf","nargs","fromArray","RangeError","reinterpret64","reinterpret128","byteLength","ITERATOR_SYMBOL","src","thisArg","clbk","tmp","flg","accessorGetter","fromIteratorMap","target","start","copyWithin","iter","entries","end","fcn","searchElement","fromIndex","separator","sep","join","keys","outbuf","reducer","initialValue","acc","N","sbuf","outlen","compareFcn","sort","begin","locales","options","opts","loc","toLocaleString","values","index","getComplex128","isBooleanArray","isBooleanArrayConstructor","val","a","b","CTORS","DTYPES","NTYPES","ctor2dtype","accessors","dt","accessorProtocol","accessorSetter","AccessorArray","o","_getter","_setter","setNonEnumerableReadWriteAccessor","arraylike2object","data","Uint8Array$1","internal","resolveGetter","hasProp","contains","factory","isnanf","FLOAT32_SIGN_MASK","Uint32Array$1","UINT32_VIEW","toWordf","monotoneKey","word","SIGN_MASK","isAlmostEqualf","maxULP","y","wx","wy","uint16view","FLOAT64_HIGH_WORD_SIGN_MASK","Uint16Array$1","ctors","HIGH","LOW","IS_LITTLE_ENDIAN","isLittleEndian","indices$3","FLOAT64_VIEW","indices","toWords","stride","assign","WX","WY","WZ","TWO_32","words","negate","subtract","wa","wb","wc","ha","hb","la","lb","isAlmostEqual","ord","wz","reim","isAlmostEqualF64","z1","z2","parts1","reimf","parts2","isAlmostEqualF32","isAlmostEqualComplex64","isAlmostEqualComplex128","xdata","ydata","xget","yget","isSameValue","isSame","search","newval","RE_SUFFIX","dtypes","kind","all","isBooleanDataType","orders","ORDERS","isByteOrder","byteOrders","isComplexFloatingPointDataType","C64_BYTES_PER_ELEMENT","C128_BYTES_PER_ELEMENT","isComplexTypedArray","isDataType","isFloatingPointDataType","isIntegerDataType","isArguments","bool$g","detect","hasArgumentsClass","isNan","isEnumerableProperty","propertyIsEnumerable","hasStringEnumBug","isEnum","isArguments$1","isConstructorPrototype","w","hasAutomationEqualityBug","k","win","EXCLUDED_KEYS","check","HAS_BUILTIN","skipConstructor","skipPrototype","isFcn","p","HAS_ENUM_PROTO_BUG","HAS_NON_ENUM_PROPS_BUG","HAS_WINDOW","error","NON_ENUMERABLE","getProto","main$4","Obj","getPrototypeOf","proto","getProto$1","objectPrototype","isPlainObject","isPrototypeOf","key","ownProps","enumeration","int64","uint64","float16","complex32","binary","notype","userdefined_type","source","objectKeys","hash","allowDupes","duplicates","objectInverse","ENUM","resolve","t","str2enum","enum2str","TABLE","mostlySafeCasts","ntypes","dt1","dt2","CASTS","generateFullTable","generateTable","casts","isMostlySafeCast","from","to","isNumericDataType","isRealDataType","isRealFloatingPointDataType","safeCasts","SAFE_CASTS","isSafeCast","sameKindCasts","SAME_KIND_CASTS","isSignedIntegerDataType","isUnsignedIntegerDataType","ns","max","min","filled","filled2d","shape","S0","S1","zeros2d","xo","yo","xr","yr","reinterpretBoolean","isMostlySafeDataTypeCast","isSafeDataTypeCast","v1","v2","recurse","ndims","dim","S","d","copy","broadcastArray","inShape","outShape","st","M","ref","strides","isOdd","isInfinite","ku","kl","fill","a0","i0","i1","colexicographic","sqrt","LOW$3","setLowWord","low","uint32ToInt32","FLOAT64_HIGH_WORD_ABS_MASK","HIGH$5","getHighWord","indices$1","fromWords","high","WORDS","copysign","hx","hy","ABS_MASK","HIGH_MAX_NEAR_UNITY","HUGE","TINY","HIGH$1","setHighWord","FLOAT64_EXPONENT_BIAS","FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS","HIGH_SIGNIFICAND_MASK","HIGH_MIN_NORMAL_EXP","HIGH_BIASED_EXP_0","HIGH_BIASED_EXP_NEG_512","HIGH_SIGNIFICAND_HALF","TWO53","CP","CP_HI","CP_LO","BP","DP_HI","DP_LO","INV_LN2","INV_LN2_HI","INV_LN2_LO","FLOAT64_MAX_BASE2_EXPONENT","FLOAT64_MAX_BASE2_EXPONENT_SUBNORMAL","FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL","FLOAT64_SMALLEST_NORMAL","SCALAR","normalize","FLOAT64_HIGH_WORD_EXPONENT_MASK","TWO52_INV","CLEAR_EXP_MASK","FRAC","ldexp","frac","exp","m","EXP_MASK","BIAS","floatExp","MIN_SUBNORMAL_EXPONENT","MAX_EXPONENT","MAX_SUBNORMAL_EXPONENT","LN2","FLOAT64_HIGH_WORD_SIGNIFICAND_MASK","HIGH_BIASED_EXP_NEG_1","LN2_HI","LN2_LO","HIGH_BIASED_EXP_31","HIGH_BIASED_EXP_64","HIGH_BIASED_EXP_10","HIGH_1075","HIGH_NEG_1075","HIGH_NUM_NONSIGN_BITS","OVT","LOG_WORKSPACE","pow","ahx","ahy","ax","sx","sy","y1","hp","lp","yIsInfinite","xIsZero","yIsHuge","t2","t1","u","logx","ss","s2","hs","ls","ht","bp","dp","hz","lz","r","HIGH_NUM_SIGNIFICAND_BITS","log2ax","pow2","cartesianPower","s","cartesianProduct","x1","x2","get1","get2","cartesianSquare","indexed","countFalsy","view","reinterpretComplex","complex","zeroTo","isSameValueZero","countTruthy","yset","io","boolean","cuany","cuevery","cunone","setReadWriteAccessor","internalComplex","isValid","isNull","isUndefined","Slice","stop","step","_start","_stop","_step","normalizeSlice","strict","code","ceil","sliceLength","inc","Int32Array$1","Int16Array$1","Uint8ClampedArray$1","Int8Array$1","gcopy","strideX","offsetX","strideY","offsetY","xbuf","ybuf","ix","iy","ox","oy","ndarray","table","isComplex64","isComplex128","isBool","convert","isc64","obuf","getType","sliceAssign","xlen","ylen","xdt","ydt","xs","isComplexDataType","filledBy","filled3d","a1","S2","i2","filled4d","a2","S3","i3","filled5d","a3","S4","i4","fillednd","numel","isColumnMajorString","shape2strides","order","isColumnMajor","columnmajor","rowmajor","vind2bind","mode","ind","stride2offset","grev","MODE","recurseLexicographic","flatten","sh","flattenColexicographic","orig","flattenBy","copyBy","flatten2d","flatten2dBy","flatten3d","flatten3dBy","flatten4d","flatten4dBy","flatten5d","flatten5dBy","fliplr2d","x0","y0","fliplr3d","fliplr4d","flipud2d","flipud3d","flipud4d","incrspace","increment","isUndefinedOrNull","logspace","map2d","map3d","map4d","y2","map5d","x3","y3","minSignedIntegerDataType","mskfilter","mask","mget","mskfilterMap","mskput","mo","vo","mdata","iv","vdata","xset","vget","mskreject","setNonEnumerableProperty","oneTo","place","clampIndex","wrapIndex","mp1","normalizeIndex","oo","so","odata","oset","modes","MODES","throw","clamp","wrap","isIndexMode","put","getIndex","maxIndex","idata","iget","sv","arraySlice","method","hasMethod","array","stepSize","subArray","resolveSetter","take","uplo","ta","NDIMS","take2d","dimension","indexFunction","isPositiveZero","resolveStride","where","condition","cget","lens","sc","ic","maxn","co","reinterpretBool","cdata","reinterpretCmplx","arrayWith","with","defaults","numeric","floating_point","real_floating_point","complex_floating_point","integer","signed_integer","unsigned_integer","integer_index","boolean_index","mask_index","DEFAULTS","HASH","DEFAULT_DTYPE","gzeros","without","some","assert","at","banded","filter","gget","arrays","z0","z3","shapes","dx0","dx1","dy0","dy1","j0","j1","k0","k1","dx2","dy2","j2","k2","dx3","dy3","j3","k3","dx4","dy4","j4","k4","dz0","dz1","dw0","dw1","m0","m1","n0","n1","w0","u0","dz2","dw2","m2","n2","w1","u1","dz3","dw3","m3","n3","w2","u2","dz4","dw4","m4","n4","w3","u3","du0","du1","p0","p1","v0","du2","du3","p2","p3","copyIndexed","predicates","limit","equalNaNs","count","ptr","dedupeEqualNaNs","dedupeInPlace","fields","fget","Datum","setReadOnlyAccessor","_i","every","fancySlice","fancySliceAssign","groups","g","indicator","lastIndexOf","inc0","inc1","s0","s1","o1","o2","getters","dims","names","oget","setNonEnumerable","getValue","setValue","_arr","_get","_set","_updateCache","v3","okeys","nkeys","fromShape","toShape","reverse","ix1","ix0","ix2","t3","ix3","t4","symmetric","symmetricBanded","dedupeCopy","toReversed","list","properties","pdata","pget","labels","hasArrayBufferSupport","GlobalArrayBuffer","isView","ArrayBuffer$2","hasDataView","DataView","ArrayBuffer$1","GlobalDataView","getFloat64","setFloat64","hasDataViewSupport","DataView$1","round","timestamp","rounders","validDate","Date","empty","gfill","alpha","isIteratorLike","iterLength","gfillBy","isProtoOf","bytesPerElement","capitalize","LITTLE_ENDIAN","BIG_ENDIAN","DTYPE2SET","DTYPE2GET","CHAR2ARTICLE","c","byteOrder","flag2byteOrder","isLE","CTOR_NAME","GETTER","SETTER","TypedArray","endianness","dtype2ctor","isTypedArrayConstructor","isTypedArray","_isLE","Float32ArrayFE","Float64ArrayFE","DEFAULT_REAL","DEFAULT_CMPLX","DEFAULT_BOOL","scalar2array","full","afill","foo","isFunctionNameSupported","Dummy","fcnName","instanceOf","typeName","typedarray2json","NAMES","Node","_next","LinkedList","_first","_last","node","_prev","toArray","iteratorSymbol","shift","pop","cache","find","id","first","COUNTER","ArrayIndex","persist","validate","last","findArrayIndex","remove","free","_invalidated","_node","array2json","linspace","endpoint","re1","re2","im1","im2","dr","di","DEFAULT_COMPLEX_DTYPE","cmplx","isf32","gencmplx","genreal","typedcmplx","typedreal","odt","adtype","acccmplx","accreal","create","Ctor","createObject$1","BYTE_ORDER","parent","fixedEndianFactory","superCtor","createObject","inherits","Float32ArrayLE","Float64ArrayLE","isNegativeZero","FLOAT32_SMALLEST_SUBNORMAL","FLOAT32_MAX_SAFE_INTEGER","FLOAT32_MIN_SAFE_INTEGER","minFloatDataType","minDataType","isMode","Z128","Z64","isValidDType","vdt","TWO54","IVLN2HI","IVLN2LO","HIGH_MAX_NORMAL_EXP","log2","valHi","valLo","hfsq","lx","hi","lo","R","polyvalQ","kernelLog1p","ARRAY_DEFAULTS","isCmplx64Array","isCmplx128Array","isBoolArray","nbytes","pool","highWaterMark","createPool","malloc","MAX","arraybuffer","MIN_EXP_SUBNORMAL","MAX_EXP","typedarraypool","hasSharedArrayBuffer","SharedArrayBuffer","isSharedArrayBuffer","b1","b2","GlobalSharedArrayBuffer","hasSharedArrayBufferSupport","size","SharedArrayBuffer$1","proxy","evil","eval","Proxy","hasProxySupport","Proxy$1","getOwnPropertySymbols","propertySymbols","enumerableProperties","isEnumerable","hasObjectAssign","assign$1","wrapComplex","wrapper","array2fancy","hasSupport","validateGeneric","validateBoolean","validateRealFloating","complexDataType","validateComplexFloating","validateSignedInteger","validateUnsignedInteger","validator","isRealFloatingDataType","RE_INTEGER","isIntegerString","RE_ARRAY_INDEX","isArrayIndexString","trim","trim$1","prop2array","resolveIndex","errMessage","msg","RE_END_MINUS","RE_END_DIVIDE","resolveEnd","decrement","RE_COLON_SEP","RE_END","seq2slice","parts","split","startsWith","PREFIX","NARGS","RE_SEP","position","charCodeAt","startsWith$1","RE_SUBSEQ","parseSlice","raw","str2slice","prop2slice","isSlice","isSubsequence","parseSubsequence","ctx","receiver","getElement","hasProperty","postGetArray","getElements","message","getSlice","preSetElement","setElement","tdt","setElements","setSlice","OPTIONS","setElementWrapper","getArrayWrapper","construct","console","warn","getTime","filledIterator","filledAccessors","filledArray","filledArrayIterator","aidx","gen","littleEndianFactory","NEXT_DTYPES","dtype1","dtype2","PROMOTION_RULES","circarray2iterator","dir","array2iterator","array2iteratorRight","sparsearray2iterator","sparsearray2iteratorRight","stridedarray2iterator","arrayview2iterator","arrayview2iteratorRight","complexarrayCtors","typedarrayCtors","floatarrayCtors","constants"],"mappings":";yCAsBA,IAAIA,EAA0C,mBAA1BC,OAAOC,eAAkCD,OAAOC,eAAiB,KCiCjFA,EAAiBD,OAAOC,eCjB5B,SAASC,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR,EAAMS,WAE5C1B,EAAM,IAAMA,IAEZA,EAAMD,EAAEyB,SAAUN,GACZnB,GAAMkB,EAAMQ,UAENR,EAAMQ,YACjBzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR,EAAMS,WAF3C1B,EAAM,GAIFiB,EAAMU,OACV3B,EAAMiB,EAAMU,KAAO3B,IAGP,KAATkB,IACCD,EAAMW,YACV5B,EAAM,KAAOA,GAEdA,EAAQiB,EAAME,YAAcL,EAAUe,KAAMZ,EAAME,WACjDL,EAAUe,KAAM7B,GAChBU,EAAUmB,KAAM7B,IAEJ,IAATkB,GACCD,EAAMW,WAAiC,MAApB5B,EAAI8B,OAAQ,KACnC9B,EAAM,IAAMA,GAGPA,CACR,CCtFA,IAAI+B,EAAMC,KAAKD,IACXrB,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAC7BkB,EAAUtB,OAAOC,UAAUqB,QAK3BC,EAAoB,WACpBC,EAAoB,UACpBC,EAAiB,UACjBC,EAAuB,UACvBC,EAA0B,OAC1BC,EAAqB,QACrBC,EAAqB,gBAczB,SAASC,EAAcC,EAAGzB,GACzB,IAAI0B,EACA3C,EAEJ,OAASiB,EAAME,WACf,IAAK,IACL,IAAK,IACJnB,EAAM0C,EAAEE,cAAe3B,EAAMQ,WAC7B,MACD,IAAK,IACL,IAAK,IACJzB,EAAM0C,EAAEG,QAAS5B,EAAMQ,WACvB,MACD,IAAK,IACL,IAAK,IACCM,EAAKW,GAAM,OACfC,EAAS1B,EAAMQ,WACD,IACbkB,GAAU,GAEX3C,EAAM0C,EAAEE,cAAeD,IAEvB3C,EAAM0C,EAAEI,YAAa7B,EAAMQ,WAEtBR,EAAMW,YACX5B,EAAMiC,EAAQJ,KAAM7B,EAAKwC,EAAoB,OAC7CxC,EAAMiC,EAAQJ,KAAM7B,EAAKuC,EAAoB,KAC7CvC,EAAMiC,EAAQJ,KAAM7B,EAAKsC,EAAyB,KAEnD,MACD,QACC,MAAM,IAAIf,MAAO,mCAAqCN,EAAME,WAc7D,OAZAnB,EAAMiC,EAAQJ,KAAM7B,EAAKkC,EAAmB,SAC5ClC,EAAMiC,EAAQJ,KAAM7B,EAAKmC,EAAmB,SACvClB,EAAMW,YACV5B,EAAMiC,EAAQJ,KAAM7B,EAAKoC,EAAgB,OACzCpC,EAAMiC,EAAQJ,KAAM7B,EAAKqC,EAAsB,SAE3CK,GAAK,GAAKzB,EAAMU,OACpB3B,EAAMiB,EAAMU,KAAO3B,GAEpBA,EAAQiB,EAAME,YAAcL,EAAUe,KAAMZ,EAAME,WACjDL,EAAUe,KAAM7B,GAChBU,EAAUmB,KAAM7B,EAElB,CCpEA,SAAS+C,EAAQjD,GAChB,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CCJA,IAAIgD,EAAerC,OAAOqC,aACtBC,EAAUC,MAAMD,QAoBpB,SAASE,EAAOvD,GACf,OAASA,GAAUA,CACpB,CASA,SAASwD,EAAYnC,GACpB,IAAIjB,EAAM,CAAA,EAMV,OALAA,EAAImB,UAAYF,EAAME,UACtBnB,EAAIyB,eAAkC,IAApBR,EAAMQ,UAAyB,EAAIR,EAAMQ,UAC3DzB,EAAIG,MAAQc,EAAMd,MAClBH,EAAIqD,MAAQpC,EAAMoC,OAAS,GAC3BrD,EAAIsD,QAAUrC,EAAMqC,QACbtD,CACR,CAmBA,SAASuD,EAAmBC,GAC3B,IAAIC,EACAJ,EACApC,EACAyC,EACAC,EACA3D,EACA4D,EACAlB,EACA3C,EACA8D,EDnDc3D,EAAKC,EAAOC,EAC1BE,ECoDJ,IAAM2C,EAASO,GACd,MAAM,IAAIM,UAAW,8DAAgEN,EAAS,MAI/F,IAFAxD,EAAM,GACN4D,EAAM,EACA7D,EAAI,EAAGA,EAAIyD,EAAOjD,OAAQR,IAE/B,GC3EyB,iBD0EzBkB,EAAQuC,EAAQzD,IAEfC,GAAOiB,MACD,CAGN,GAFAwC,OAAgC,IAApBxC,EAAMQ,YAClBR,EAAQmC,EAAYnC,IACRE,UACX,MAAM,IAAI2C,UAAW,oEAAqE/D,EAAG,cAAgBkB,EAAQ,MAMtH,IAJKA,EAAMqC,UACVM,EAAM3C,EAAMqC,SAEbD,EAAQpC,EAAMoC,MACRQ,EAAI,EAAGA,EAAIR,EAAM9C,OAAQsD,IAE9B,OADAH,EAAOL,EAAMvB,OAAQ+B,IAErB,IAAK,IACJ5C,EAAMU,KAAO,IACb,MACD,IAAK,IACJV,EAAMU,KAAO,IACb,MACD,IAAK,IACJV,EAAMS,UAAW,EACjBT,EAAM8C,UAAW,EACjB,MACD,IAAK,IACJ9C,EAAM8C,SAAWV,EAAMW,QAAS,KAAQ,EACxC,MACD,IAAK,IACJ/C,EAAMW,WAAY,EAClB,MACD,QACC,MAAM,IAAIL,MAAO,iBAAmBmC,GAGtC,GAAqB,MAAhBzC,EAAMd,MAAgB,CAG1B,GAFAc,EAAMd,MAAQkB,SAAU4C,UAAWL,GAAO,IAC1CA,GAAO,EACFT,EAAOlC,EAAMd,OACjB,MAAM,IAAI2D,UAAW,wCAA0CF,EAAM,6BAA+B3C,EAAMd,MAAQ,MAE9Gc,EAAMd,MAAQ,IAClBc,EAAMS,UAAW,EACjBT,EAAMd,OAASc,EAAMd,MAEtB,CACD,GAAKsD,GACqB,MAApBxC,EAAMQ,UAAoB,CAG9B,GAFAR,EAAMQ,UAAYJ,SAAU4C,UAAWL,GAAO,IAC9CA,GAAO,EACFT,EAAOlC,EAAMQ,WACjB,MAAM,IAAIqC,UAAW,4CAA8CF,EAAM,6BAA+B3C,EAAMQ,UAAY,MAEtHR,EAAMQ,UAAY,IACtBR,EAAMQ,UAAY,EAClBgC,GAAY,EAEb,CAGF,OADAxC,EAAMG,IAAM6C,UAAWL,GACd3C,EAAME,WACf,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IAECsC,IACJxC,EAAM8C,UAAW,GAElB9C,EAAMG,IAAMJ,EAAeC,GAC3B,MACD,IAAK,IAEJA,EAAMiD,SAAW,EAAgBjD,EAAMQ,WAAa,EACpDR,EAAMG,IAAMT,OAAQM,EAAMG,KAC1B,MACD,IAAK,IAEJ,IAAM+B,EAAOlC,EAAMG,KAAQ,CAE1B,IADAuC,EAAMtC,SAAUJ,EAAMG,IAAK,KAChB,GAAKuC,EAAM,IACrB,MAAM,IAAIpC,MAAO,kCAAoCN,EAAMG,KAE5DH,EAAMG,IAAQ+B,EAAOQ,GAAUhD,OAAQM,EAAMG,KAAQ4B,EAAcW,EACnE,CACD,MACD,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IAMJ,GAJMF,IACLxC,EAAMQ,UAAY,GAEnBiB,EAAIyB,WAAYlD,EAAMG,MAChBE,SAAUoB,GAAM,CACrB,IAAM/C,EAAUsB,EAAMG,KACrB,MAAM,IAAIG,MAAO,yCAA2CvB,GAG7D0C,EAAIzB,EAAMG,IACVH,EAAM8C,UAAW,CACjB,CACD9C,EAAMG,IAAMqB,EAAcC,EAAGzB,GAC7B,MACD,QACC,MAAM,IAAIM,MAAO,sBAAwBN,EAAME,WAG3CF,EAAMiD,UAAY,GAAKjD,EAAMG,IAAIb,OAASU,EAAMiD,WACpDjD,EAAMG,IAAMH,EAAMG,IAAIgD,UAAW,EAAGnD,EAAMiD,WAEtCjD,EAAM8C,SACV9C,EAAMG,IAAMnB,EAASgB,EAAMG,IAAKH,EAAMd,OAASc,EAAMQ,UAAWR,EAAMS,UAC3DT,EAAMd,QACjBc,EAAMG,KDpLSlB,ECoLOe,EAAMG,IDpLRjB,ECoLac,EAAMd,MDpLZC,ECoLmBa,EAAMS,SDnLnDpB,YAAMH,EAAQD,EAAIK,QACX,EACHL,EAERA,EAAM,EACLA,EAAM6C,EAAQzC,GACdyC,EAAQzC,GAAQJ,IC+KfF,GAAOiB,EAAMG,KAAO,GACpBwC,GAAO,CACP,CAEF,OAAO5D,CACR,CEvNA,IAAIqE,EAAK,6EAYT,SAASC,EAAOC,GACf,IAAItD,EAAQ,CACXqC,QAAaiB,EAAO,GAAQlD,SAAUkD,EAAO,GAAK,SAAO,EACzDlB,MAASkB,EAAO,GAChBpE,MAASoE,EAAO,GAChB9C,UAAa8C,EAAO,GACpBpD,UAAaoD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCtD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASuD,EAAgBtE,GACxB,IAAIuE,EACAjB,EACAe,EACAG,EAKJ,IAHAlB,EAAS,GACTkB,EAAO,EACPH,EAAQF,EAAGM,KAAMzE,GACTqE,IACPE,EAAUvE,EAAI0E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIhE,SACxCA,QACZiD,EAAOsB,KAAML,GAGM,MAAfF,EAAO,GACXf,EAAOsB,KAAM,KAEbtB,EAAOsB,KAAMR,EAAOC,IAErBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZiD,EAAOsB,KAAML,GAEPjB,CACR,CC3CA,SAASuB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI4D,UAAWiB,EAAQ,kEAAmE7E,IAGjG,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAClCiF,EAAKF,KAAMb,UAAWlE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC,CE7BA,ICkBItF,EDlBA0F,EAAiB3F,OAAOmB,UACxByE,EAAQD,EAAe5D,SACvB8D,EAAeF,EAAeG,iBAC9BC,EAAeJ,EAAeK,iBAC9BC,EAAeN,EAAeO,iBAC9BC,EAAeR,EAAeS,iBCiBjCnG,ECdD,WAEC,IAEC,OADAA,EAAgB,CAAE,EAAE,IAAK,CAAA,IAClB,CACP,CAAC,MAAQoG,GACT,OAAO,CACP,CACF,CDGKC,GACaC,EDqBlB,SAAyBC,EAAKC,EAAMC,GACnC,IAAIvF,EACAwF,EACAC,EACAC,EAEJ,GAAoB,iBAARL,GAA4B,OAARA,GAAsC,mBAAtBZ,EAAMxD,KAAMoE,GAC3D,MAAM,IAAInC,UAAWiB,EAAQ,mEAAoEkB,IAElG,GAA2B,iBAAfE,GAA0C,OAAfA,GAAoD,mBAA7Bd,EAAMxD,KAAMsE,GACzE,MAAM,IAAIrC,UAAWiB,EAAQ,wEAAyEoB,IAyBvG,IAvBAC,EAAa,UAAWD,KAGtBT,EAAa7D,KAAMoE,EAAKC,IACxBN,EAAa/D,KAAMoE,EAAKC,IAGxBtF,EAAYqF,EAAIM,UAChBN,EAAIM,UAAYnB,SAGTa,EAAKC,GACZD,EAAKC,GAASC,EAAWvG,MAGzBqG,EAAIM,UAAY3F,GAEhBqF,EAAKC,GAASC,EAAWvG,OAG3ByG,EAAW,QAASF,EACpBG,EAAW,QAASH,EAEfC,IAAcC,GAAUC,GAC5B,MAAM,IAAI/E,MAAO,wHASlB,OANK8E,GAAUf,GACdA,EAAazD,KAAMoE,EAAKC,EAAMC,EAAWK,KAErCF,GAAUd,GACdA,EAAa3D,KAAMoE,EAAKC,EAAMC,EAAWM,KAEnCR,CACR,EC3DA,IAAAS,EAAehH,EEZf,SAASiH,EAAaV,EAAKC,EAAMtG,GAChCF,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASA,GAEX,CCPA,SAASmH,EAA0Bd,EAAKC,EAAMtG,GAC7CF,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASA,GAEX,CC9BA,IAAIoH,EAAO,WAqBX,SAASC,EAAiBrH,GACzB,cAAgBA,EAAM4G,MAAQQ,UAAepH,EAAM6G,MAAQO,CAC5D,CCvBA,IAAIE,EAAU,CACbC,QAgCD,SAAqBC,EAAKC,GACzB,OAAOD,EAAKC,EACb,EAjCCC,QAmDD,SAAqBF,EAAKC,GACzB,OAAOD,EAAKC,EACb,EApDCE,MAsED,SAAmBH,EAAKC,GACvB,OAAOD,EAAKC,EACb,EAvECG,MAyFD,SAAmBJ,EAAKC,GACvB,OAAOD,EAAKC,EACb,EA1FCI,KA4GD,SAAkBL,EAAKC,GACtB,OAAOD,EAAKC,EACb,EA7GCK,OA+HD,SAAoBN,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAhICM,OAkJD,SAAoBP,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAnJCO,MAqKD,SAAmBR,EAAKC,GACvB,OAAOD,EAAKC,EACb,EAtKCQ,OAwLD,SAAoBT,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAzLCS,QAyMD,SAAqBV,EAAKC,GACzB,OAAOD,EAAKC,EACb,EA1MCU,QA0ND,SAAuBX,EAAKC,GAC3B,OAAOD,EAAKC,EACb,GAoBA,SAASW,EAAQC,GAChB,IAAIvF,EAAIwE,EAASe,GACjB,MAAkB,mBAANvF,EACJA,EAEDwE,EAAQa,OAChB,CCjQA,IAAIG,EAAU,CACbf,QAkCD,SAAqBC,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EAnCC0H,QAuDD,SAAqBF,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EAxDC2H,MA4ED,SAAmBH,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EA7EC4H,MAiGD,SAAmBJ,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EAlGC6H,KAsHD,SAAkBL,EAAKC,EAAKzH,GAC3BwH,EAAKC,GAAQzH,CACd,EAvHC8H,OA2ID,SAAoBN,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EA5IC+H,OAgKD,SAAoBP,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EAjKCgI,MAqLD,SAAmBR,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EAtLCiI,OA0MD,SAAoBT,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EA3MCkI,QA6ND,SAAqBV,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EA9NCmI,QAgPD,SAAuBX,EAAKC,EAAKzH,GAChCwH,EAAKC,GAAQzH,CACd,GAsBA,SAASuI,EAAQF,GAChB,IAAIvF,EAAIwF,EAASD,GACjB,MAAkB,mBAANvF,EACJA,EAEDwF,EAAQH,OAChB,CCzRA,IAAIb,EAAU,CACbkB,WAgCD,SAAwBhB,EAAKC,GAC5B,OAAOD,EAAIZ,IAAKa,EACjB,EAjCCgB,UA2DD,SAAuBjB,EAAKC,GAC3B,OAAOD,EAAIZ,IAAKa,EACjB,EA5DCU,QAuFD,SAAuBX,EAAKC,GAC3B,OAAOD,EAAIZ,IAAKa,EACjB,GA6BA,SAASW,EAAQC,GAChB,IAAIvF,EAAIwE,EAASe,GACjB,MAAkB,mBAANvF,EACJA,EAEDwE,EAAQa,OAChB,CC/HA,IAAIG,EAAU,CACbE,WAkCD,SAAwBhB,EAAKC,EAAKzH,GACjCwH,EAAIX,IAAK7G,EAAOyH,EACjB,EAnCCgB,UA+DD,SAAuBjB,EAAKC,EAAKzH,GAChCwH,EAAIX,IAAK7G,EAAOyH,EACjB,EAhECU,QA6FD,SAAuBX,EAAKC,EAAKzH,GAChCwH,EAAIX,IAAK7G,EAAOyH,EACjB,GAgCA,SAASc,EAAQF,GAChB,IAAIvF,EAAIwF,EAASD,GACjB,MAAkB,mBAANvF,EACJA,EAEDwF,EAAQH,OAChB,CCnIA,IAAIO,ECMgB,mBAAXC,QACoB,iBAApBA,OAAQ,ODOjB,SAASC,IACR,OAASF,GAAqC,iBAAvBC,OAAOE,WAC/B,CErBA,IAAIpD,EAAQ5F,OAAOmB,UAAUY,SCAzBkH,EAAMjJ,OAAOmB,UAAU+H,eA4B3B,SAASC,GAAYhJ,EAAOiJ,GAC3B,OACCjJ,SAKM8I,EAAI7G,KAAMjC,EAAOiJ,EACzB,CCpCA,IAAIC,GAA0B,mBAAXP,OAA0BA,YAAS,ECKlDQ,GAA+B,mBAAXR,GAA0BA,GAAOE,YAAc,GCiCvEO,GATKC,ICDL,SAAsBC,GACrB,IAAIC,EACAC,EACApJ,EAEJ,GAAKkJ,QACJ,OAAO7D,EAAMxD,KAAMqH,GAEpBE,EAAMF,EAAGT,IACTU,EAAQP,GAAYM,EAAGT,IAGvB,IACCS,EAAGT,SAAgB,CACnB,CAAC,MAAQ3C,GACT,OAAOT,EAAMxD,KAAMqH,EACnB,CAQD,OAPAlJ,EAAMqF,EAAMxD,KAAMqH,GAEbC,EACJD,EAAGT,IAAgBW,SAEZF,EAAGT,IAEJzI,CACR,EC3BA,SAAsBkJ,GACrB,OAAO7D,EAAMxD,KAAMqH,EACpB,ECYAG,GATKnG,MAAMD,QACNC,MAAMD,QARX,SAAkBrD,GACjB,MAAkC,mBAAzBoJ,GAAapJ,EACvB,ECCA,SAAS0J,GAAUC,GAClB,GAA0B,mBAAdA,EACX,MAAM,IAAIzF,UAAWiB,EAAQ,0DAA2DwE,IAEzF,OASA,SAAgB3J,GACf,IAAI4J,EACAzJ,EACJ,IAAMkD,GAASrD,GACd,OAAO,EAGR,GAAa,KADb4J,EAAM5J,EAAMW,QAEX,OAAO,EAER,IAAMR,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,IAAiC,IAA5BwJ,EAAW3J,EAAOG,IACtB,OAAO,EAGT,OAAO,CACP,CACF,CCzCA,SAAS0J,GAAc7J,GACtB,OACW,OAAVA,GACiB,iBAAVA,CAET,CCMA,SAAS8J,GAAU9J,GAClB,OACC6J,GAAc7J,KAGbA,EAAM+J,WAEL/J,EAAMgK,aAGgC,mBAA/BhK,EAAMgK,YAAYF,UACzB9J,EAAMgK,YAAYF,SAAU9J,GAIhC,CClBA,SAASiK,KACR,MAAO,yBACR,CCaAlD,EAAAnH,GAAA,oBALAsK,GAAAtK,KCFA,IAAIuK,GFPI,0BGQR,SAASC,GAAiBd,GACzB,IAAI3E,EACA0F,EACAC,EAEJ,IAAe,YADfD,EAAOjB,GAAaE,GAAItE,MAAO,GAAI,KACC,UAATqF,IAAqBf,EAAEU,YAAc,CAE/D,GAA0B,iBAD1BM,EAAOhB,EAAEU,aACQK,KAChB,OAAOC,EAAKD,KAGb,GADA1F,EAAQF,GAAGM,KAAMuF,EAAK1I,YAErB,OAAO+C,EAAO,EAEf,CACD,OAAKmF,GAAUR,GACP,SAEDe,CACR,CCnBAtD,EAAAnH,GAAA,SAAA2K,IChCA,IAAIC,GAAc,CACjBC,aAAgB,UAChBC,aAAgB,UAChBpH,MAAS,UACTqH,WAAc,QACdC,WAAc,QACdC,UAAa,OACbC,YAAe,SACfC,YAAe,SACfC,WAAc,QACdC,kBAAqB,SACrBC,eAAkB,YAClBC,gBAAmB,aACnBC,aAAgB,QCTbC,GAA4C,mBAAjBX,aCL3B9K,GAAiC,mBAAjB8K,aAAgCA,aAAe,KCenE,SAASY,KACR,IAAIC,EACA/D,EFSoBxH,EEPxB,GAAmC,mBAAvBwL,GACX,OAAO,EAGR,IACChE,EAAM,IAAIgE,GAAoB,CAAE,EAAK,MAAO,KAAMC,MFE3BzL,EEANwH,EADjB+D,GFGEF,IAAmBrL,aAAiB0K,cACb,0BAAzBtB,GAAapJ,KEFC,IAAbwH,EAAK,IACQ,OAAbA,EAAK,KACS,OAAdA,EAAK,IACLA,EAAK,IAAQA,EAAK,EAEnB,CAAC,MAAQtB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCpCA,IAAIjB,GAAiC,mBAAjBI,aAAgCA,kBAAe,EC6BnEgB,GATKJ,KACGlF,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJIgK,GAA4C,mBAAjBlB,aCuB3BmB,GAAeC,OAAOC,kBC5BtBlM,GAAiC,mBAAjB6K,aAAgCA,aAAe,KCgBnE,SAASsB,KACR,IAAIR,EACA/D,EHQoBxH,EGNxB,GAAmC,mBAAvBgM,GACX,OAAO,EAGR,IACCxE,EAAM,IAAIwE,GAAoB,CAAE,EAAK,MAAO,KAAM,OHC3BhM,EGCNwH,EADjB+D,GHEEI,IAAmB3L,aAAiByK,cACb,0BAAzBrB,GAAapJ,KGDC,IAAbwH,EAAK,IACQ,oBAAbA,EAAK,KACS,oBAAdA,EAAK,IACLA,EAAK,KAAQyE,EAEd,CAAC,MAAQ/F,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCrCA,IAAIjB,GAAiC,mBAAjBG,aAAgCA,kBAAe,EC6BnEyB,GATKH,KACG3F,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJIwK,GAA0C,mBAAhBpB,YC4B1BqB,GAAa,WCjCbxM,GAAgC,mBAAhBmL,YAA+BA,YAAc,KCgBjE,SAASsB,KACR,IAAId,EACA/D,EHQmBxH,EGNvB,GAAkC,mBAAtBsM,GACX,OAAO,EAGR,IAEC9E,EAAM,IAAI8E,GADV9E,EAAM,CAAE,EAAG,MAAO,KAAM4E,GAAW,EAAGA,GAAW,IHC3BpM,EGENwH,EADhB+D,GHCEY,IAAkBnM,aAAiB+K,aACZ,yBAAzB3B,GAAapJ,KGAC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,IACLA,EAAK,KAAQ4E,GAAW,GACX,IAAb5E,EAAK,IACQ,IAAbA,EAAK,EAEN,CAAC,MAAQtB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCvCA,IAAIjB,GAAgC,mBAAhBS,YAA+BA,iBAAc,EC6BjEwB,GATKF,KACGjG,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJI6K,GAAwC,mBAAf5B,WC4BzB6B,GAAY,WCAZC,IAAY,WCjCZ9M,GAA+B,mBAAfgL,WAA8BA,WAAa,KCiB/D,SAAS+B,KACR,IAAIpB,EACA/D,EJOkBxH,EILtB,GAAiC,mBAArB4M,GACX,OAAO,EAGR,IACCpF,EAAM,IAAIoF,GAAkB,CAAE,EAAG,MAAO,KAAMH,GAAU,IJAnCzM,EIENwH,EADf+D,GJCEiB,IAAiBxM,aAAiB4K,YACX,wBAAzBxB,GAAapJ,KIAC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,KACS,IAAdA,EAAK,IACLA,EAAK,KAAQkF,EAEd,CAAC,MAAQxG,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCtCA,IAAIjB,GAA+B,mBAAfM,WAA8BA,gBAAa,EC6B/DiC,GATKF,KACGvG,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJImL,GAA0C,mBAAhBhC,YC4B1BiC,GAAa,MCjCbnN,GAAgC,mBAAhBkL,YAA+BA,YAAc,KCgBjE,SAASkC,KACR,IAAIzB,EACA/D,EHQmBxH,EGNvB,GAAkC,mBAAtBiN,GACX,OAAO,EAGR,IAECzF,EAAM,IAAIyF,GADVzF,EAAM,CAAE,EAAG,MAAO,KAAMuF,GAAW,EAAGA,GAAW,IHC3B/M,EGENwH,EADhB+D,GHCEuB,IAAkB9M,aAAiB8K,aACZ,yBAAzB1B,GAAapJ,KGAC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,IACLA,EAAK,KAAQuF,GAAW,GACX,IAAbvF,EAAK,IACQ,IAAbA,EAAK,EAEN,CAAC,MAAQtB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCvCA,IAAIjB,GAAgC,mBAAhBQ,YAA+BA,iBAAc,EC6BjEoC,GATKF,KACG5G,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJIwL,GAAwC,mBAAfxC,WC4BzByC,GAAY,MCAZC,IAAY,MCjCZzN,GAA+B,mBAAf+K,WAA8BA,WAAa,KCiB/D,SAAS2C,KACR,IAAI/B,EACA/D,EJOkBxH,EILtB,GAAiC,mBAArBuN,GACX,OAAO,EAGR,IACC/F,EAAM,IAAI+F,GAAkB,CAAE,EAAG,MAAO,KAAMH,GAAU,IJAnCpN,EIENwH,EADf+D,GJCE4B,IAAiBnN,aAAiB2K,YACX,wBAAzBvB,GAAapJ,KIAC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,KACS,IAAdA,EAAK,IACLA,EAAK,KAAQ6F,EAEd,CAAC,MAAQnH,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCtCA,IAAIjB,GAA+B,mBAAfK,WAA8BA,gBAAa,EC6B/D6C,GATKF,KACGlH,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJI8L,GAAwC,mBAAfzC,WC4BzB0C,GAAY,ICjCZ9N,GAA+B,mBAAfoL,WAA8BA,WAAa,KCgB/D,SAAS2C,KACR,IAAIpC,EACA/D,EHQkBxH,EGNtB,GAAiC,mBAArB4N,GACX,OAAO,EAGR,IAECpG,EAAM,IAAIoG,GADVpG,EAAM,CAAE,EAAG,MAAO,KAAMkG,GAAU,EAAGA,GAAU,IHC1B1N,EGENwH,EADf+D,GHCEkC,IAAiBzN,aAAiBgL,YACX,wBAAzB5B,GAAapJ,KGAC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,IACLA,EAAK,KAAQkG,GAAU,GACV,IAAblG,EAAK,IACQ,IAAbA,EAAK,EAEN,CAAC,MAAQtB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCvCA,IAAIjB,GAA+B,mBAAfU,WAA8BA,gBAAa,EC6B/D6C,GATKF,KACGvH,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJImM,GAAsD,mBAAtB7C,kBCLhCrL,GAAsC,mBAAtBqL,kBAAqCA,kBAAoB,KCe7E,SAAS8C,KACR,IAAIxC,EACA/D,EFSyBxH,EEP7B,GAAwC,mBAA5BgO,GACX,OAAO,EAGR,IACCxG,EAAM,IAAIwG,GAAyB,EAAG,EAAG,EAAG,EAAG,KAAM,KAAM,IAAK,MFEpChO,EEANwH,EADtB+D,GFGEuC,IAAwB9N,aAAiBiL,mBAClB,+BAAzB7B,GAAapJ,KEFC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,IACQ,IAAbA,EAAK,IACQ,IAAbA,EAAK,IACQ,IAAbA,EAAK,IACQ,MAAbA,EAAK,IACQ,MAAbA,EAAK,EAEN,CAAC,MAAQtB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCvCA,IAAIjB,GAAsC,mBAAtBW,kBAAqCA,uBAAoB,EC6B7EgD,GATKF,KACG3H,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJIuM,GAAsC,mBAAdrD,UC4BxBsD,GAAW,ICAXC,IAAW,ICjCXxO,GAA8B,mBAAdiL,UAA6BA,UAAY,KCiB7D,SAASwD,KACR,IAAI9C,EACA/D,EJOiBxH,EILrB,GAAgC,mBAApBsO,GACX,OAAO,EAGR,IACC9G,EAAM,IAAI8G,GAAiB,CAAE,EAAG,MAAO,KAAMH,GAAS,IJAlCnO,EIENwH,EADd+D,GJCE2C,IAAgBlO,aAAiB6K,WACV,uBAAzBzB,GAAapJ,KIAC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,KACS,IAAdA,EAAK,IACLA,EAAK,KAAQ4G,EAEd,CAAC,MAAQlI,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCtCA,IAAIjB,GAA8B,mBAAdO,UAA6BA,eAAY,EC6B7D0D,GATKF,KACGjI,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECOA,SAAS5B,GAAUC,GAClB,MAA0B,iBAAVA,CACjB,CClBA,IAAAwO,GAAe3C,OCMXjK,GAAWiK,GAAO7K,UAAUY,SCE5B8G,GAAMW,IAmBV,SAAStJ,GAAUC,GAClB,MAAsB,iBAAVA,IACNA,aAAiB6L,KAGjBnD,GCpBP,SAAe1I,GACd,IAEC,OADA4B,GAASK,KAAMjC,IACR,CACP,CAAC,MAAQkG,GACT,OAAO,CACP,CACF,CDcUuI,CAAMzO,GAEoB,oBAAzBoJ,GAAapJ,IAGxB,CEVA,SAASD,GAAUC,GAClB,OAAS0O,GAAa1O,IAAW2O,GAAU3O,EAC5C,CCoBA+G,EAAAnH,GAAA,cAAA8O,IACA3H,EAAAnH,GAAA,WAAA+O,ICnBA,IAAIC,GAAe/C,GAAOgD,kBCVtBC,GAAQ1M,KAAK0M,MCHjB,SAASC,GAAWC,GACnB,OAAQF,GAAME,KAAOA,CACtB,CCPA,SAASD,GAAW/O,GACnB,OACCA,EAAQiM,IACRjM,EAAQiP,IACRC,GAAOlP,EAET,CCAA,SAAS+O,GAAW/O,GACnB,OACCD,GAAUC,IACVkP,GAAOlP,EAET,CCLA,SAAS+O,GAAW/O,GACnB,OACCD,GAAUC,IACVkP,GAAOlP,EAAMmP,UAEf,CCGA,SAASJ,GAAW/O,GACnB,OAAS0O,GAAa1O,IAAW2O,GAAU3O,EAC5C,CCXA,SAASoP,GAAsBpP,GAC9B,OACC+O,GAAW/O,IACXA,GAAS,CAEX,CCLA,SAASoP,GAAsBpP,GAC9B,OACC+O,GAAW/O,IACXA,EAAMmP,WAAa,CAErB,CCQA,SAASC,GAAsBpP,GAC9B,OAAS0O,GAAa1O,IAAW2O,GAAU3O,EAC5C,CCeA+G,EAAAnH,GAAA,cAAA8O,IACA3H,EAAAnH,GAAA,WAAA+O,ICAA5H,EAAAnH,GAAA,cAAA8O,IACA3H,EAAAnH,GAAA,WAAA+O,IC9BA,IAAIU,GAAmB,WCGvB,SAASC,GAAmBtP,GAC3B,MACkB,iBAAVA,GACG,OAAVA,GACwB,iBAAjBA,EAAMW,QACboO,GAAW/O,EAAMW,SACjBX,EAAMW,QAAU,GAChBX,EAAMW,QAAU4O,EAElB,CCZA,IAAIC,GAAyB,iBCD7B,SAASC,GAAczP,GACtB,MACkB,iBAAVA,GACG,OAAVA,GACwB,iBAAjBA,EAAMW,QACboO,GAAW/O,EAAMW,SACjBX,EAAMW,QAAU,GAChBX,EAAMW,QAAU4O,EAElB,CCxBA,IAAIG,GAA0C,mBAAhBC,YAqB9B,SAASC,GAAe5P,GACvB,OACG0P,IAAkB1P,aAAiB2P,aACZ,yBAAzBvG,GAAapJ,EAEf,CCZA,SAAS2O,GAAU3O,GAClB,MACkB,iBAAVA,GACG,OAAVA,IACCqD,GAASrD,EAEZ,CCbA,SAAS6P,GAAU7P,GAClB,MAA0B,iBAAVA,CACjB,CCfA,IAAImP,GAAUpO,OAAOC,UAAUmO,QCQ3BzG,GAAMW,IAmBV,SAASwG,GAAU7P,GAClB,MAAsB,iBAAVA,IACNA,aAAiBe,SAGjB2H,GCnBP,SAAe1I,GACd,IAEC,OADAmP,GAAQlN,KAAMjC,IACP,CACP,CAAC,MAAQkG,GACT,OAAO,CACP,CACF,CDaUuI,CAAMzO,GAEoB,oBAAzBoJ,GAAapJ,IAGxB,CEjBA,SAAS6P,GAAU7P,GAClB,OAAS0O,GAAa1O,IAAW2O,GAAU3O,EAC5C,CCsBA+G,EAAAnH,GAAA,cAAA8O,IACA3H,EAAAnH,GAAA,WAAA+O,ICLA,IAAAmB,GAAA5F,GAAA2F,GAAAnB,aACAqB,GAAA7F,GAAA2F,GAAAlB,UAKAqB,GAAA9F,GAAA2F,IACA9I,EAAAiJ,GAAA,aAAAF,IACA/I,EAAAiJ,GAAA,UAAAD,IClDA,IAAItL,GAAK,ICoBT,SAASwL,GAAWjQ,GACnB,MAA0B,kBAAVA,CACjB,CCGA,IAAIkQ,GAAOC,QCxBPvO,GAAWuO,QAAQnP,UAAUY,SCS7B8G,GAAMW,IAqBV,SAAS4G,GAAWjQ,GACnB,MAAsB,iBAAVA,IACNA,aAAiBmQ,KAGjBzH,GCtBP,SAAe1I,GACd,IAEC,OADA4B,GAASK,KAAMjC,IACR,CACP,CAAC,MAAQkG,GACT,OAAO,CACP,CACF,CDgBUuI,CAAMzO,GAEoB,qBAAzBoJ,GAAapJ,IAGxB,CERA,SAASiQ,GAAWjQ,GACnB,OAAS0O,GAAa1O,IAAW2O,GAAU3O,EAC5C,CCUA+G,EAAAnH,GAAA,cAAA8O,IACA3H,EAAAnH,GAAA,WAAA+O,IC7CA,IAAItI,GAAwB,iBAAT+J,KAAsBA,KAAO,KCA5C/J,GAA0B,iBAAXgK,OAAwBA,OAAS,KCAhDhK,GAA8B,iBAAfiK,WAA4BA,WAAa,KCKxDC,GCsBJ,SAAoBC,GACnB,GAAKnM,UAAU1D,OAAS,CACvB,IAAMsP,GAAWO,GAChB,MAAM,IAAItM,UAAWiB,EAAQ,yDAA0DqL,IAExF,GAAKA,EACJ,OC1BK,IAAIC,SAAU,eAAd,ED6BN,CAED,GAAKC,GACJ,OAAOA,GAGR,GAAKC,GACJ,OAAOA,GAGR,GAAKC,GACJ,OAAOA,GAGR,MAAM,IAAIjP,MAAO,qDAClB,CD9CWkP,GACPC,GAAWP,GAAKQ,UAAYR,GAAKQ,SAASC,WGR1CC,GAAapG,UCwBbjL,GCNY,mBAAP6E,IAGe,iBAAfwM,IAGa,mBAAbH,GCXT,SAAiBxH,GAChB,OAAO4H,GAAU5H,GAAIrI,aACtB,ECqBA,SAAiBqI,GAChB,IAAI6H,EAGJ,OAAW,OAAN7H,EACG,OAKM,WAHd6H,SAAc7H,GAIN4H,GAAU5H,GAAIrI,cAEfkQ,CACR,EC7BA,SAASC,GAAYpR,GAEpB,MAA6B,aAApBqR,GAAQrR,EAClB,CCGA,SAASsR,GAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,IACvB,MAAM,IAAIpN,UAAW,0EAEtB,IAAMnE,GAAUwR,GACf,MAAM,IAAIrN,UAAWiB,EAAQ,kEAAmEoM,IAEjG,IAAMxR,GAAUyR,GACf,MAAM,IAAItN,UAAWiB,EAAQ,uEAAwEqM,IActG,OAZA1R,EAAgB2R,KAAM,KAAM,CAC3BzK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASuR,IAEVzR,EAAgB2R,KAAM,KAAM,CAC3BzK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASwR,IAEHC,IACR,CAcA1K,EAAauK,GAAY,oBAAqB,GAgBnCnK,EAAEmK,GAAWtQ,UAAW,oBAAqB,GAgB7CmG,EAAEmK,GAAWtQ,UAAW,aAAc,IAgBtCmG,EAAEmK,GAAWtQ,UAAW,YC1GnC,WAEC,IAAIV,EAAM,GAAKmR,KAAKC,GAOpB,OANKD,KAAKE,GAAK,EACdrR,GAAO,OAAUmR,KAAKE,GAEtBrR,GAAO,MAAQmR,KAAKE,GAErBrR,GAAO,GAER,IDoHW6G,EAAEmK,GAAWtQ,UAAW,UE9HnC,WAEC,IAAIZ,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIsR,GAAKD,KAAKC,GACdtR,EAAIuR,GAAKF,KAAKE,GACPvR,CACR,ICXA,IAAIwR,GAAkC,mBAAhBxP,KAAKwP,OAA0BxP,KAAKwP,OAAS,KCA/DtH,GAAiC,mBAAjBG,aAAgCA,kBAAe,EC6BnEoH,GATK9F,KACG3F,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJImQ,GAAe,IAAIrH,GAAc,GCuBrCsH,GATwB,mBAAZ3L,GACQA,GDApB,SAA2B4I,GAE1B,OADA8C,GAAc,GAAM9C,EACb8C,GAAc,EACtB,EEGA,SAASE,GAAWT,EAAMC,GACzB,KAAQC,gBAAgBO,IACvB,MAAM,IAAI9N,UAAW,0EAEtB,IAAMnE,GAAUwR,GACf,MAAM,IAAIrN,UAAWiB,EAAQ,kEAAmEoM,IAEjG,IAAMxR,GAAUyR,GACf,MAAM,IAAItN,UAAWiB,EAAQ,uEAAwEqM,IActG,OAZA1R,EAAgB2R,KAAM,KAAM,CAC3BzK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASiS,GAAkBV,KAE5BzR,EAAgB2R,KAAM,KAAM,CAC3BzK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASiS,GAAkBT,KAErBC,IACR,CCzBA,SAASS,GAAelS,GACvB,OAAKA,aAAiBsR,IAActR,aAAiBgS,IAInC,iBAAVhS,GACG,OAAVA,GACoB,iBAAbA,EAAM0R,IACO,iBAAb1R,EAAM2R,EAEf,CCPA,SAASQ,GAAQnD,GAChB,OAAOD,GAAWC,EAAE,EACrB,CFkCAjI,EAAaiL,GAAW,oBAAqB,GAgBlC7K,EAAE6K,GAAUhR,UAAW,oBAAqB,GAgB5CmG,EAAE6K,GAAUhR,UAAW,aAAc,GAgBrCmG,EAAE6K,GAAUhR,UAAW,YG3GlC,WAEC,IAAIV,EAAM,GAAKmR,KAAKC,GAOpB,OANKD,KAAKE,GAAK,EACdrR,GAAO,OAAUmR,KAAKE,GAEtBrR,GAAO,MAAQmR,KAAKE,GAErBrR,GAAO,GAER,IHqHW6G,EAAE6K,GAAUhR,UAAW,UI/HlC,WAEC,IAAIZ,EAAM,CACVA,KAAW,aAGX,OAFAA,EAAIsR,GAAKD,KAAKC,GACdtR,EAAIuR,GAAKF,KAAKE,GACPvR,CACR,ICXA,IAAIgS,GAAoB,EAoBxB,SAASC,GAAkBrS,GAE1B,MACkB,iBAAVA,GACG,OAAVA,GAC2B,mBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMoS,oBAAsBA,EAE9B,CC5BA,IAAIA,GAAoB,GAoBxB,SAASE,GAAmBtS,GAE3B,MACkB,iBAAVA,GACG,OAAVA,GAC2B,oBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMoS,oBAAsBA,EAE9B,CCbA,SAASG,KACR,MACmB,mBAAX5J,IACoB,iBAApBA,GAAQ,QACfK,GAAYL,GAAQ,aACO,iBAApBA,GAAO6J,QAEhB,CC6BA,IAAIC,GAAmBF,KAA+B5J,OAAO6J,SAAW,KCxBxE,SAASE,GAAkCrM,EAAKC,EAAM8B,GACrDtI,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdL,IAAOwB,GAET,CCrBA,SAASmJ,GAAMoB,GACd,OAAOA,EAAEjB,EACV,CCFA,SAASF,GAAMmB,GACd,OAAOA,EAAEhB,EACV,CCSA,SAASiB,GAAa5D,EAAG6D,GACxB,OAAO,IAAIpI,GAAcuE,EAAE8D,OAAQ9D,EAAE+D,WAAY/D,EAAEoD,kBAAkBS,EAAS,GAAG7D,EAAErO,OAAOkS,GAC3F,CCzBA,IAAIvI,GAAiC,mBAAjBI,aAAgCA,kBAAe,EC6BnEsI,GATK1H,KACGlF,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECcA,SAASiR,GAAa5D,EAAG6D,GACxB,OAAO,IAAInI,GAAcsE,EAAE8D,OAAQ9D,EAAE+D,WAAY/D,EAAEoD,kBAAkBS,EAAS,GAAG7D,EAAErO,OAAOkS,GAC3F,CCTA,SAASI,GAAcC,GACtB,IAAI9S,EACAkJ,EACAqJ,EAGJ,IADAvS,EAAM,KAELkJ,EAAI4J,EAAGC,QACAC,MAIP,GAAK9D,GADLqD,EAAIrJ,EAAEtJ,QACyB2S,EAAEhS,QAAU,EAC1CP,EAAI8E,KAAMyN,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAIzO,UAAWiB,EAAQ,kJAAmJwN,IAFjLvS,EAAI8E,KAAMmO,GAAOV,GAAKW,GAAOX,GAG7B,CAEF,OAAOvS,CACR,CCAA,IAAAgS,GAAA,EAAA3H,GAAA2H,kBACAmB,GAAAhB,KAYA,SAAAiB,GAAAxT,GACA,OACAA,aAAAkL,IAEA,iBAAAlL,GACA,OAAAA,IAEA,mBAAAA,EAAAgK,YAAAK,MACA,oBAAArK,EAAAgK,YAAAK,OAEA,iBAAArK,EAAAyT,SAGA,iBAAAzT,EAAA0T,OAGA,CASA,SAAAC,GAAA3T,GACA,OACAA,IAAAkL,IAGA,oBAAAlL,EAAAqK,IAEA,CAUA,SAAAuJ,GAAAC,EAAApM,GAEA,OAAA,IAAAuK,GAAA6B,EADApM,GAAA,GACAoM,EAAApM,EAAA,GACA,CAyEA,SAAAyD,KACA,IAAA6H,EACAe,EACAD,EACAjK,EAGA,GADAkK,EAAAzP,UAAA1D,SACA8Q,gBAAAvG,IACA,OAAA,IAAA4I,EACA,IAAA5I,GAEA,IAAA4I,EACA,IAAA5I,GAAA7G,UAAA,IAEA,IAAAyP,EACA,IAAA5I,GAAA7G,UAAA,GAAAA,UAAA,IAEA,IAAA6G,GAAA7G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAAyP,EACAD,EAAA,IAAApJ,GAAA,QACA,GAAA,IAAAqJ,EACA,GAAA1E,GAAA/K,UAAA,IACAwP,EAAA,IAAApJ,GAAA,EAAApG,UAAA,SACA,GAAAoL,GAAApL,UAAA,IAKA,IAHAuF,GADAiK,EAAAxP,UAAA,IACA1D,SAGA0C,GAAAwQ,IAAA3B,GAAA2B,EAAA,KAEA,GADAA,ECxLA,SAAoBA,EAAKrM,GACxB,IAAIoC,EACAN,EACAnJ,EACA8D,EAIJ,IAFA2F,EAAMpC,EAAI7G,OACVsD,EAAI,EACE9D,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,IAAM+R,GADN5I,EAAI9B,EAAKrH,IAER,OAAO,KAER0T,EAAK5P,GAAMoP,GAAO/J,GAClBuK,EAAK5P,EAAE,GAAMqP,GAAOhK,GACpBrF,GAAK,CACL,CACD,OAAO4P,CACR,CDsKAE,CAAA,IAAAtJ,GAAA,EAAAb,GAAAiK,GACA,OAAAA,EAAA,CAEA,IAAA1B,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,6GAAAyE,IAGAiK,EAAA,IAAApJ,GAAApG,UAAA,GACA,MACA,CACA,GAAAgO,GAAAwB,GACAA,EAAAI,GAAAJ,EAAA,QACA,GAAAvB,GAAAuB,GACAA,EAAAK,GAAAL,EAAA,QACA,IAAA1B,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,6HAAAyE,IAEAiK,EAAA,IAAApJ,GAAAoJ,EACA,MACA,GAAAjE,GAAAvL,UAAA,IAAA,CAEA,IAAA0K,IADA8E,EAAAxP,UAAA,IACA8P,WAAA/B,IACA,MAAA,IAAA4B,WAAA7O,EAAA,yFAAAiN,GAAAyB,EAAAM,aAEAN,EAAA,IAAApJ,GAAAoJ,EACA,KAAA,KAAAlF,GAAAtK,UAAA,IAkBA,MAAA,IAAAH,UAAAiB,EAAA,qHAAAd,UAAA,KAhBA,GADAwP,EAAAxP,UAAA,IACA,IAAAkP,GACA,MAAA,IAAArP,UAAAiB,EAAA,mJAAA0O,IAEA,IAAAzC,GAAAyC,EAAAO,KACA,MAAA,IAAAlQ,UAAAiB,EAAA,qHAAA0O,IAGA,IAAAzC,IADAyC,EAAAA,EAAAO,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,qHAAA0O,IAGA,IADAA,EAAAZ,GAAAY,cACAlS,MACA,MAAAkS,EAEAA,EAAA,IAAApJ,GAAAoJ,EAGA,KACA,CAEA,IAAAjE,GADAiE,EAAAxP,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA0O,IAGA,IAAAzE,GADA2D,EAAA1O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA4N,IAEA,IAAAhE,GAAAgE,EAAAX,IACA,MAAA,IAAA4B,WAAA7O,EAAA,uEAAAiN,GAAAW,IAEA,GAAA,IAAAe,EAAA,CAEA,IAAA/E,IADAnF,EAAAiK,EAAAM,WAAApB,GACAX,IACA,MAAA,IAAA4B,WAAA7O,EAAA,oGAAAiN,GAAAxI,IAEAiK,EAAA,IAAApJ,GAAAoJ,EAAAd,EACA,KAAA,CAEA,IAAA3D,GADAxF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAAwI,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAA7O,EAAA,iJAAAyE,EAAAwI,KAEAyB,EAAA,IAAApJ,GAAAoJ,EAAAd,EAAA,EAAAnJ,EACA,CACA,CAIA,OAHA7C,EAAA0K,KAAA,UAAAoC,GACA9M,EAAA0K,KAAA,UAAAoC,EAAAlT,OAAA,GAEA8Q,IACA,CEzQA,SAASF,GAAMoB,GACd,OAAOA,EAAEjB,EACV,CCFA,SAASF,GAAMmB,GACd,OAAOA,EAAEhB,EACV,CCEA,SAASsB,GAAcC,GACtB,IAAI9S,EACAkJ,EACAqJ,EAGJ,IADAvS,EAAM,KAELkJ,EAAI4J,EAAGC,QACAC,MAIP,GAAK9D,GADLqD,EAAIrJ,EAAEtJ,QACyB2S,EAAEhS,QAAU,EAC1CP,EAAI8E,KAAMyN,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAIzO,UAAWiB,EAAQ,kJAAmJwN,IAFjLvS,EAAI8E,KAAMqM,GAAMoB,GAAKnB,GAAMmB,GAG3B,CAEF,OAAOvS,CACR,CJ+PA2G,EAAAmE,GAAA,oBAAAkH,IAeArL,EAAAmE,GAAA,OAAA,kBAmDA/D,EAAA+D,GAAA,QAAA,SAAAmJ,GACA,IAAAC,EACAR,EACAS,EACAnU,EACAyT,EACAW,EACA5N,EACAgD,EACA6K,EACAnL,EACAnJ,EACA8D,EACA,IAAAmN,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAyP,GAAAlC,MACA,MAAA,IAAAvN,UAAA,6DAGA,IADA4P,EAAAzP,UAAA1D,QACA,EAAA,CAEA,IAAAyQ,GADAmD,EAAAlQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAoP,IAEAT,EAAA,IACAQ,EAAAjQ,UAAA,GAEA,CACA,GAAAmP,GAAAa,GAAA,CAEA,GADAzK,EAAAyK,EAAA1T,OACA4T,EAAA,CAIA,IAFAV,GADAzT,EAAA,IAAAqR,KAAA7H,IACA8J,QACAzP,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAA+R,GADA5I,EAAAiL,EAAAtS,KAAAqS,EAAAD,EAAAzN,IAAAzG,GAAAA,IAEA0T,EAAA5P,GAAAoP,GAAA/J,GACAuK,EAAA5P,EAAA,GAAAqP,GAAAhK,OACA,MAAAgG,GAAAhG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAuK,EAAA5P,GAAAqF,EAAA,GACAuK,EAAA5P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAqR,KAAA4C,EACA,CACA,GAAA5E,GAAA4E,GAAA,CACA,GAAAE,EAAA,CAUA,IAPA3K,EAAAyK,EAAA1T,OAEAiG,EADAyN,EAAAzN,KAAAyN,EAAAxN,IACA6N,EAAA,WAEAtM,EAAA,WAGAjI,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA,IAAA+R,GAAAtL,EAAAyN,EAAAlU,IAAA,CACAsU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,+FAAA,EAAAyE,IAIA,IADAiK,GADAzT,EAAA,IAAAqR,KAAA7H,EAAA,IACA8J,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAoU,EAAAtS,KAAAqS,EAAA1N,EAAAyN,EAAAlU,GAAAA,GAEA,OAAAC,CACA,CAKA,IAFAyT,GADAzT,EAAA,IAAAqR,KAAA7H,IACA8J,QACAzP,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAA+R,GADA5I,EAAAiL,EAAAtS,KAAAqS,EAAA1N,EAAAyN,EAAAlU,GAAAA,IAEA0T,EAAA5P,GAAAoP,GAAA/J,GACAuK,EAAA5P,EAAA,GAAAqP,GAAAhK,OACA,MAAAgG,GAAAhG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAuK,EAAA5P,GAAAqF,EAAA,GACAuK,EAAA5P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAqR,KAAA4C,EACA,CACA,GAAA1F,GAAA0F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,6FAAAkP,IAOA,GAJAG,EADAD,EK/bA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIlU,EACAkJ,EACAqJ,EACAxS,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI4J,EAAGC,QACAC,MAKP,GAFAjT,GAAK,EAEAmP,GADLqD,EAAI4B,EAAKtS,KAAMqS,EAAShL,EAAEtJ,MAAOG,KACFwS,EAAEhS,QAAU,EAC1CP,EAAI8E,KAAMyN,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAIzO,UAAWiB,EAAQ,+IAAgJwN,IAF9KvS,EAAI8E,KAAMmO,GAAOV,GAAKW,GAAOX,GAG7B,CAEF,OAAOvS,CACR,CLwaAuU,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAEAW,aAAA7S,MACA,MAAA6S,EAKA,IADAX,GADAzT,EAAA,IAAAqR,KADA7H,EAAA4K,EAAA7T,OAAA,IAEA+S,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAqU,EAAArU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAkP,GACA,IAoBAtN,EAAAmE,GAAA,MAAA,WACA,IAAA9F,EACAjF,EACA,IAAAiR,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAyP,GAAAlC,MACA,MAAA,IAAAvN,UAAA,6DAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAsR,KAAArM,EACA,IAuDA+B,EAAA+D,GAAAlK,UAAA,MAAA,SAAAyG,GACA,IAAA+L,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA6K,GAAAtH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAKA,GAHAA,EAAA,IACAA,GAAAgK,KAAAgC,WAEAhM,EAAA,GAAAA,GAAAgK,KAAAgC,SAGA,OAAAG,GAAAnC,KAAAiC,QAAAjM,EACA,IAgBAiL,GAAAxH,GAAAlK,UAAA,UAAA,WACA,OAAAyQ,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAAxH,GAAAlK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAS,UACA,IAgBAzB,GAAAxH,GAAAlK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAX,UACA,IAiBA5L,EAAA+D,GAAAlK,UAAA,oBAAAkK,GAAAkH,mBAuCArL,EAAAmE,GAAAlK,UAAA,cAAA,SAAA4T,EAAAC,GACA,IAAArB,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAQA,OALA,IAAAG,UAAA1D,OACA8Q,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,EAAA,EAAAxQ,UAAA,IAEAoN,IACA,IAqCAtK,EAAA+D,GAAAlK,UAAA,WAAA,WACA,IAAAoP,EACA2E,EACAnL,EACAiK,EACAnL,EACAvI,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAiBA,OAfAkM,EAAAqB,KACAoC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAA,CAAAG,EAAAyT,GAAAC,EAAA1T,IACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAA4E,SACA,IAjDAD,CAkDA,IA+BAhO,EAAAmE,GAAAlK,UAAA,SAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,IAAAwJ,EAAA1H,KAAAqS,EAAAV,GAAAC,EAAA1T,GAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA2CA1K,EAAAmE,GAAAlK,UAAA,QAAA,SAAAhB,EAAA6U,EAAAI,GACA,IAAApB,EACAjK,EACAnC,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAlS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,0EAAAnF,IAIA,GAFA6T,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAA8F,GACA,MAAA,IAAA3Q,UAAAiB,EAAA,qEAAA0P,IAQA,GANAA,EAAA,IACAA,GAAAjL,GACA,IACAiL,EAAA,GAGAxQ,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,oEAAA8P,IAEAA,EAAA,IACAA,GAAArL,GACA,IACAqL,EAAA,GAGAA,EAAArL,IACAqL,EAAArL,EAEA,MACAqL,EAAArL,CAEA,MACAiL,EAAA,EACAI,EAAArL,EAIA,IAFA8H,EAAA2B,GAAArT,GACA2R,EAAA2B,GAAAtT,GACAG,EAAA0U,EAAA1U,EAAA8U,EAAA9U,IAEA0T,EADApM,EAAA,EAAAtH,GACAuR,EACAmC,EAAApM,EAAA,GAAAkK,EAEA,OAAAF,IACA,IA2CA1K,EAAAmE,GAAAlK,UAAA,UAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAzT,EACAD,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAkK,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAwS,EAAAiB,GAAAC,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,OACArR,EAAA8E,KAAAyN,GAGA,OAAA,IAAAlB,KAAAzH,YAAA5J,EACA,IAsCA2G,EAAAmE,GAAAlK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAwS,EAAAiB,GAAAC,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAkB,CAGA,IAgCA5L,EAAAmE,GAAAlK,UAAA,aAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAwS,EAAAiB,GAAAC,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IAsCA4G,EAAAmE,GAAAlK,UAAA,YAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAwS,EAAAiB,GAAAC,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAkB,CAGA,IAgCA5L,EAAAmE,GAAAlK,UAAA,iBAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAwS,EAAAiB,GAAAC,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IA4BA4G,EAAAmE,GAAAlK,UAAA,WAAA,SAAAkU,EAAAZ,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAAiB,EAAA,oEAAA+P,IAGA,IADArB,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAwS,EAAAiB,GAAAC,EAAA1T,GACA+U,EAAAjT,KAAAqS,EAAA3B,EAAAxS,EAAAsR,KAEA,IAyCAtK,EAAA+D,GAAAlK,UAAA,OAAA,SAAAyG,GACA,IAAA+L,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkL,GAAA3H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAgK,KAAAgC,SAGA,OAAAG,GAAAnC,KAAAiC,QAAAjM,EACA,IAmCAV,EAAAmE,GAAAlK,UAAA,YAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAA,EAGA,OAAA,CACA,IAmCAV,EAAAmE,GAAAlK,UAAA,WAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyBAgH,EAAA+D,GAAAlK,UAAA,QAAA,SAAAqU,GACA,IAAAjV,EACAyT,EACAyB,EACAnV,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA2U,EAAA,QACA,KAAAzF,GAAAwF,GAGA,MAAA,IAAAnR,UAAAiB,EAAA,kEAAAkQ,IAFAC,EAAAD,CAGA,CAGA,IAFAjV,EAAA,GACAyT,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAA0O,GAAAC,EAAA1T,GAAAyB,YAEA,OAAAxB,EAAAmV,KAAAD,EACA,IA4BAnO,EAAA+D,GAAAlK,UAAA,QAAA,WACA,IAAAoP,EACA2E,EACAnL,EACAlB,EACAvI,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAgBA,OAdAkM,EAAAqB,KACA7H,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAAG,EACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoF,MACA,IAjDAT,CAkDA,IAsCAhO,EAAAmE,GAAAlK,UAAA,eAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAKA,IAHA/B,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,GAAA,EAAAA,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAgBAuS,GAAAxH,GAAAlK,UAAA,UAAA,WACA,OAAAyQ,KAAAgC,OACA,IAyCA1M,EAAAmE,GAAAlK,UAAA,OAAA,SAAAkU,EAAAZ,GACA,IAAAmB,EACA5B,EACAzT,EACAD,EACAmJ,EACA,IAAAkK,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAAiB,EAAA,oEAAA+P,IAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADArV,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAgC,UACAC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAA+R,GADA5I,EAAA4L,EAAAjT,KAAAqS,EAAAV,GAAAC,EAAA1T,GAAAA,EAAAsR,OAEAgE,EAAA,EAAAtV,GAAAkT,GAAA/J,GACAmM,EAAA,EAAAtV,EAAA,GAAAmT,GAAAhK,OACA,KAAAgG,GAAAhG,IAAA,IAAAA,EAAA3I,OAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAmM,EAAA,EAAAtV,GAAAmJ,EAAA,GACAmM,EAAA,EAAAtV,EAAA,GAAAmJ,EAAA,EAGA,CAEA,OAAAlJ,CACA,IAmCA2G,EAAAmE,GAAAlK,UAAA,UAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACA+B,EACAhM,EAEAzJ,EAEA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAhC,GAAAC,EAAA,GACA1T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IAEAyV,EAAAF,EAAAE,EADAhC,GAAAC,EAAA1T,GACAA,EAAAsR,MAEA,OAAAmE,CACA,IAmCA7O,EAAAmE,GAAAlK,UAAA,eAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACA+B,EACAhM,EAEAzJ,EAEA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAhC,GAAAC,EAAAjK,EAAA,GACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IAEAyV,EAAAF,EAAAE,EADAhC,GAAAC,EAAA1T,GACAA,EAAAsR,MAEA,OAAAmE,CACA,IAmDAzO,EAAA+D,GAAAlK,UAAA,WAAA,WACA,IAAA6S,EACAW,EACA5K,EACAiM,EACA1V,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAKA,IAHA0F,EAAA6H,KAAAgC,QACAI,EAAApC,KAAAiC,QACAmC,EAAA/G,GAAAlF,EAAA,GACAzJ,EAAA,EAAAA,EAAA0V,EAAA1V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAqU,EAAAX,EAAA,EAAA1T,GACA0T,EAAA,EAAA1T,GAAA0T,EAAA,EAAA5P,GACA4P,EAAA,EAAA5P,GAAAuQ,EACAA,EAAAX,EAAA,EAAA1T,EAAA,GACA0T,EAAA,EAAA1T,EAAA,GAAA0T,EAAA,EAAA5P,EAAA,GACA4P,EAAA,EAAA5P,EAAA,GAAAuQ,EAEA,OAAA/C,IACA,IAgEAtK,EAAA+D,GAAAlK,UAAA,OAAA,SAAAhB,GAEA,IAAA8V,EACArO,EACAoM,EACAW,EACAC,EACAoB,EACAvM,EACAnJ,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAGA,GADA2P,EAAApC,KAAAiC,QACArP,UAAA1D,OAAA,GAEA,IAAAyO,GADA3H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAAyK,GAAAlS,GAAA,CACA,GAAAyH,GAAAgK,KAAAgC,QACA,MAAA,IAAAO,WAAA7O,EAAA,kEAAAsC,IAKA,OAFAoM,EADApM,GAAA,GACA4L,GAAArT,QACA6T,EAAApM,EAAA,GAAA6L,GAAAtT,GAEA,CACA,GAAAwT,GAAAxT,GAAA,CAEA,GAAAyH,GADAoO,EAAA7V,EAAAyT,SACAhC,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAA9V,EAAA0T,QAGAzP,EAAA4P,EAAAd,WAAAtL,EAAA2K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAA9O,GACA6R,EAAA/C,WAAA+C,EAAA3B,WAAAlQ,EAEA,CAGA,IADAuQ,EAAA,IAAA/J,GAAAqL,EAAAnV,QACAR,EAAA,EAAAA,EAAA2V,EAAAnV,OAAAR,IACAqU,EAAArU,GAAA2V,EAAA3V,GAEA2V,EAAAtB,CACA,CAGA,IAFA/M,GAAA,EACAxD,EAAA,EACA9D,EAAA,EAAAA,EAAA0V,EAAA1V,IACA0T,EAAApM,GAAAqO,EAAA7R,GACA4P,EAAApM,EAAA,GAAAqO,EAAA7R,EAAA,GACAwD,GAAA,EACAxD,GAAA,CAGA,KAhCA,CAiCA,IAAAwL,GAAAzP,GA2DA,MAAA,IAAAkE,UAAAiB,EAAA,kIAAAnF,IAxDA,IADA6V,EAAA7V,EAAAW,OACAR,EAAA,EAAAA,EAAA0V,EAAA1V,IACA,IAAA+R,GAAAlS,EAAAG,IAAA,CACAsU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA0D,GACA,MAAA,IAAA7B,WAAA7O,EAAA,6GAAA0Q,IAEA,GAAApO,EAAAoO,EAAA,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAA9V,EAGAiE,EAAA4P,EAAAd,WAAAtL,EAAA2K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAA9O,GACA6R,EAAA/C,WAAA+C,EAAA3B,WAAAlQ,EAEA,CAGA,IADAuQ,EAAA,IAAA/J,GAAAoL,GACA1V,EAAA,EAAAA,EAAA0V,EAAA1V,IACAqU,EAAArU,GAAA2V,EAAA3V,GAEA2V,EAAAtB,CACA,CAIA,IAHA/M,GAAA,EACAoO,GAAA,EACA5R,EAAA,EACA9D,EAAA,EAAAA,EAAA0V,EAAA1V,IACA0T,EAAApM,GAAAqO,EAAA7R,GACA4P,EAAApM,EAAA,GAAAqO,EAAA7R,EAAA,GACAwD,GAAA,EACAxD,GAAA,EAEA,MACA,CAEA,GAAAwD,EAAAoO,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAGA,IADAvM,GAAA,EACAtH,EAAA,EAAAA,EAAA0V,EAAA1V,IACAmJ,EAAAtJ,EAAAG,GACA0T,EAAApM,GAAA4L,GAAA/J,GACAuK,EAAApM,EAAA,GAAA6L,GAAAhK,GACA7B,GAAA,CAxDA,CA+DA,IA2EAV,EAAAmE,GAAAlK,UAAA,SAAA,SAAA6T,EAAAI,GACA,IAAAc,EACAN,EACArV,EACAqH,EACAoM,EACAjK,EACAzJ,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAkU,EAAA,EACAI,EAAArL,MACA,CACA,IAAAmF,GAAA8F,GACA,MAAA,IAAA3Q,UAAAiB,EAAA,oEAAA0P,IAQA,GANAA,EAAA,IACAA,GAAAjL,GACA,IACAiL,EAAA,GAGA,IAAAxQ,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAQA,IANAmM,EADAlB,EAAAI,EACAA,EAAAJ,EAEA,EAGAY,GADArV,EAAA,IAAAqR,KAAAzH,YAAA+L,IACArC,QACAvT,EAAA,EAAAA,EAAA4V,EAAA5V,IACAsH,EAAA,GAAAtH,EAAA0U,GACAY,EAAA,EAAAtV,GAAA0T,EAAApM,GACAgO,EAAA,EAAAtV,EAAA,GAAA0T,EAAApM,EAAA,GAEA,OAAArH,CACA,IA+BA2G,EAAAmE,GAAAlK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,GAAAwJ,EAAA1H,KAAAqS,EAAAV,GAAAC,EAAA1T,GAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA6EAtK,EAAA+D,GAAAlK,UAAA,QAAA,SAAAgV,GACA,IAAAxB,EACAX,EACAjK,EACAzJ,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAKA,IAHAnC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACAe,EAAA,GACArU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAqU,EAAAtP,KAAA0O,GAAAC,EAAA1T,IAGA,IADAqU,EAAAyB,KAAAD,GACA7V,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAEA0T,EADA5P,EAAA,EAAA9D,GACAkT,GAAAmB,EAAArU,IACA0T,EAAA5P,EAAA,GAAAqP,GAAAkB,EAAArU,IAEA,OAAAsR,IACA,IA2EA1K,EAAAmE,GAAAlK,UAAA,YAAA,SAAAkV,EAAAjB,GACA,IAAApC,EACAgB,EACAjK,EACA,IAAA4J,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAuV,EAAA,EACAjB,EAAArL,MACA,CACA,IAAAmF,GAAAmH,GACA,MAAA,IAAAhS,UAAAiB,EAAA,oEAAA+Q,IAQA,GANAA,EAAA,IACAA,GAAAtM,GACA,IACAsM,EAAA,GAGA,IAAA7R,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAWA,OAVAsM,GAAAtM,GACAA,EAAA,EACAiJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACArL,EAAA,EACAiJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEAxI,EAAAqL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAAzH,YAAA6J,EAAAf,OAAAD,EAAAjJ,EAAA,EAAA,EAAAA,EACA,IAwBA7C,EAAAmE,GAAAlK,UAAA,kBAAA,SAAAmV,EAAAC,GACA,IAAAC,EACAC,EACAlW,EACAyT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA2V,EAAA,OACA,KAAAzG,GAAAsG,KAAAnG,GAAAmG,GAGA,MAAA,IAAAjS,UAAAiB,EAAA,yFAAAgR,IAFAG,EAAAH,CAGA,CACA,GAAA9R,UAAA1D,OAAA,EACA0V,EAAA,CAAA,MACA,KAAA1H,GAAAyH,GAGA,MAAA,IAAAlS,UAAAiB,EAAA,qEAAAiR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAA0O,GAAAC,EAAA1T,GAAAoW,eAAAD,EAAAD,IAEA,OAAAjW,EAAAmV,KAAA,IACA,IAmDApO,EAAA+D,GAAAlK,UAAA,cAAA,WACA,IAAAyU,EACArV,EACAwJ,EACAiK,EACA1T,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAMA,IAJA0F,EAAA6H,KAAAgC,QACArT,EAAA,IAAAqR,KAAAzH,YAAAJ,GACAiK,EAAApC,KAAAiC,QACA+B,EAAArV,EAAAsT,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAsV,EAAA,EAAAtV,GAAA0T,EAAA,EAAA5P,GACAwR,EAAA,EAAAtV,EAAA,GAAA0T,EAAA,EAAA5P,EAAA,GAEA,OAAA7D,CACA,IA6EA+G,EAAA+D,GAAAlK,UAAA,YAAA,SAAAgV,GACA,IAAAxB,EACAX,EACAjK,EACAzJ,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAKA,IAHAnC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACAe,EAAA,GACArU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAqU,EAAAtP,KAAA0O,GAAAC,EAAA1T,IAGA,OADAqU,EAAAyB,KAAAD,GACA,IAAA9K,GAAAsJ,EACA,IAoBArN,EAAA+D,GAAAlK,UAAA,YAAA,WACA,IAAAZ,EACAyT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,IAFA9D,EAAA,GACAyT,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAA0O,GAAAC,EAAA1T,GAAAyB,YAEA,OAAAxB,EAAAmV,KAAA,IACA,IA0CApO,EAAA+D,GAAAlK,UAAA,UAAA,WACA,IAAA+T,EACA3E,EACAxG,EACAlB,EACAmL,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAiBA,OAfAkM,EAAAqB,KACAoC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAA4T,GAAAC,EAAA1T,GACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoG,QACA,IAjDAzB,CAkDA,IAuCAhO,EAAAmE,GAAAlK,UAAA,QAAA,SAAAyV,EAAAzW,GACA,IAAA6T,EACAzT,EACAwJ,EACA,IAAA4J,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA6K,GAAA0H,GACA,MAAA,IAAAvS,UAAAiB,EAAA,oEAAAsR,IAMA,GAJA7M,EAAA6H,KAAAgC,QACAgD,EAAA,IACAA,GAAA7M,GAEA6M,EAAA,GAAAA,GAAA7M,EACA,MAAA,IAAAoK,WAAA7O,EAAA,kEAAAsR,IAEA,IAAAvE,GAAAlS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,2EAAAnF,IAMA,OAHA6T,GADAzT,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAiC,UACAA,SACA,EAAA+C,GAAApD,GAAArT,GACA6T,EAAA,EAAA4C,EAAA,GAAAnD,GAAAtT,GACAI,CACA,IM15FA,IAAAgS,GAAA,EAAA1H,GAAA0H,kBACAmB,GAAAhB,KAYA,SAAAiB,GAAAxT,GACA,OACAA,aAAAmL,IAEA,iBAAAnL,GACA,OAAAA,IAEA,mBAAAA,EAAAgK,YAAAK,MACA,oBAAArK,EAAAgK,YAAAK,OAEA,iBAAArK,EAAAyT,SAGA,iBAAAzT,EAAA0T,OAGA,CASA,SAAAC,GAAA3T,GACA,OACAA,IAAAmL,IAGA,mBAAAnL,EAAAqK,IAEA,CAUA,SAAAqM,GAAA7C,EAAApM,GAEA,OAAA,IAAA6J,GAAAuC,EADApM,GAAA,GACAoM,EAAApM,EAAA,GACA,CAyEA,SAAA0D,KACA,IAAA4H,EACAe,EACAD,EACAjK,EAGA,GADAkK,EAAAzP,UAAA1D,SACA8Q,gBAAAtG,IACA,OAAA,IAAA2I,EACA,IAAA3I,GAEA,IAAA2I,EACA,IAAA3I,GAAA9G,UAAA,IAEA,IAAAyP,EACA,IAAA3I,GAAA9G,UAAA,GAAAA,UAAA,IAEA,IAAA8G,GAAA9G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAAyP,EACAD,EAAA,IAAAnJ,GAAA,QACA,GAAA,IAAAoJ,EACA,GAAA1E,GAAA/K,UAAA,IACAwP,EAAA,IAAAnJ,GAAA,EAAArG,UAAA,SACA,GAAAoL,GAAApL,UAAA,IAKA,IAHAuF,GADAiK,EAAAxP,UAAA,IACA1D,SAGA0C,GAAAwQ,IAAA3B,GAAA2B,EAAA,KAEA,GADAA,ECxLA,SAAoBA,EAAKrM,GACxB,IAAIoC,EACAN,EACAnJ,EACA8D,EAIJ,IAFA2F,EAAMpC,EAAI7G,OACVsD,EAAI,EACE9D,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,IAAM+R,GADN5I,EAAI9B,EAAKrH,IAER,OAAO,KAER0T,EAAK5P,GAAMsN,GAAMjI,GACjBuK,EAAK5P,EAAE,GAAMuN,GAAMlI,GACnBrF,GAAK,CACL,CACD,OAAO4P,CACR,CDsKAE,CAAA,IAAArJ,GAAA,EAAAd,GAAAiK,GACA,OAAAA,EAAA,CAEA,IAAA1B,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,6GAAAyE,IAGAiK,EAAA,IAAAnJ,GAAArG,UAAA,GACA,MACA,CACA,GAAAgO,GAAAwB,GACAA,EAAAI,GAAAJ,EAAA,QACA,GAAAvB,GAAAuB,GACAA,EAAAK,GAAAL,EAAA,QACA,IAAA1B,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,6HAAAyE,IAEAiK,EAAA,IAAAnJ,GAAAmJ,EACA,MACA,GAAAjE,GAAAvL,UAAA,IAAA,CAEA,IAAA0K,IADA8E,EAAAxP,UAAA,IACA8P,WAAA/B,IACA,MAAA,IAAA4B,WAAA7O,EAAA,yFAAAiN,GAAAyB,EAAAM,aAEAN,EAAA,IAAAnJ,GAAAmJ,EACA,KAAA,KAAAlF,GAAAtK,UAAA,IAkBA,MAAA,IAAAH,UAAAiB,EAAA,qHAAAd,UAAA,KAhBA,GADAwP,EAAAxP,UAAA,IACA,IAAAkP,GACA,MAAA,IAAArP,UAAAiB,EAAA,mJAAA0O,IAEA,IAAAzC,GAAAyC,EAAAO,KACA,MAAA,IAAAlQ,UAAAiB,EAAA,qHAAA0O,IAGA,IAAAzC,IADAyC,EAAAA,EAAAO,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,qHAAA0O,IAGA,IADAA,EAAAZ,GAAAY,cACAlS,MACA,MAAAkS,EAEAA,EAAA,IAAAnJ,GAAAmJ,EAGA,KACA,CAEA,IAAAjE,GADAiE,EAAAxP,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA0O,IAGA,IAAAzE,GADA2D,EAAA1O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA4N,IAEA,IAAAhE,GAAAgE,EAAAX,IACA,MAAA,IAAA4B,WAAA7O,EAAA,uEAAAiN,GAAAW,IAEA,GAAA,IAAAe,EAAA,CAEA,IAAA/E,IADAnF,EAAAiK,EAAAM,WAAApB,GACAX,IACA,MAAA,IAAA4B,WAAA7O,EAAA,oGAAAiN,GAAAxI,IAEAiK,EAAA,IAAAnJ,GAAAmJ,EAAAd,EACA,KAAA,CAEA,IAAA3D,GADAxF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAAwI,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAA7O,EAAA,iJAAAyE,EAAAwI,KAEAyB,EAAA,IAAAnJ,GAAAmJ,EAAAd,EAAA,EAAAnJ,EACA,CACA,CAIA,OAHA7C,EAAA0K,KAAA,UAAAoC,GACA9M,EAAA0K,KAAA,UAAAoC,EAAAlT,OAAA,GAEA8Q,IACA,CEzQA,SAASwB,GAAcC,GACtB,IAAI9S,EACAkJ,EAGJ,IADAlJ,EAAM,KAELkJ,EAAI4J,EAAGC,QACAC,MAGPhT,EAAI8E,KAAMiL,GAAS7G,EAAEtJ,QAEtB,OAAOI,CACR,CF2QA2G,EAAAoE,GAAA,oBAAAiH,IAeArL,EAAAoE,GAAA,OAAA,mBAmDAhE,EAAAgE,GAAA,QAAA,SAAAkJ,GACA,IAAAC,EACAR,EACAS,EACAnU,EACAyT,EACAW,EACA5N,EACAgD,EACA6K,EACAnL,EACAnJ,EACA8D,EACA,IAAAmN,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAyP,GAAAlC,MACA,MAAA,IAAAvN,UAAA,6DAGA,IADA4P,EAAAzP,UAAA1D,QACA,EAAA,CAEA,IAAAyQ,GADAmD,EAAAlQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAoP,IAEAT,EAAA,IACAQ,EAAAjQ,UAAA,GAEA,CACA,GAAAmP,GAAAa,GAAA,CAEA,GADAzK,EAAAyK,EAAA1T,OACA4T,EAAA,CAIA,IAFAV,GADAzT,EAAA,IAAAqR,KAAA7H,IACA8J,QACAzP,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAA+R,GADA5I,EAAAiL,EAAAtS,KAAAqS,EAAAD,EAAAzN,IAAAzG,GAAAA,IAEA0T,EAAA5P,GAAAsN,GAAAjI,GACAuK,EAAA5P,EAAA,GAAAuN,GAAAlI,OACA,MAAAgG,GAAAhG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAuK,EAAA5P,GAAAqF,EAAA,GACAuK,EAAA5P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAqR,KAAA4C,EACA,CACA,GAAA5E,GAAA4E,GAAA,CACA,GAAAE,EAAA,CAUA,IAPA3K,EAAAyK,EAAA1T,OAEAiG,EADAyN,EAAAzN,KAAAyN,EAAAxN,IACA6N,EAAA,WAEAtM,EAAA,WAGAjI,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA,IAAA+R,GAAAtL,EAAAyN,EAAAlU,IAAA,CACAsU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,gGAAAyE,IAIA,IADAiK,GADAzT,EAAA,IAAAqR,KAAA7H,EAAA,IACA8J,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAoU,EAAAtS,KAAAqS,EAAA1N,EAAAyN,EAAAlU,GAAAA,GAEA,OAAAC,CACA,CAKA,IAFAyT,GADAzT,EAAA,IAAAqR,KAAA7H,IACA8J,QACAzP,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAA+R,GADA5I,EAAAiL,EAAAtS,KAAAqS,EAAA1N,EAAAyN,EAAAlU,GAAAA,IAEA0T,EAAA5P,GAAAsN,GAAAjI,GACAuK,EAAA5P,EAAA,GAAAuN,GAAAlI,OACA,MAAAgG,GAAAhG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAuK,EAAA5P,GAAAqF,EAAA,GACAuK,EAAA5P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAqR,KAAA4C,EACA,CACA,GAAA1F,GAAA0F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,6FAAAkP,IAOA,GAJAG,EADAD,EG/bA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIlU,EACAkJ,EACAqJ,EACAxS,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI4J,EAAGC,QACAC,MAKP,GAFAjT,GAAK,EAEAmP,GADLqD,EAAI4B,EAAKtS,KAAMqS,EAAShL,EAAEtJ,MAAOG,KACFwS,EAAEhS,QAAU,EAC1CP,EAAI8E,KAAMyN,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAIzO,UAAWiB,EAAQ,+IAAgJwN,IAF9KvS,EAAI8E,KAAMqM,GAAMoB,GAAKnB,GAAMmB,GAG3B,CAEF,OAAOvS,CACR,CHwaAuU,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAEAW,aAAA7S,MACA,MAAA6S,EAKA,IADAX,GADAzT,EAAA,IAAAqR,KADA7H,EAAA4K,EAAA7T,OAAA,IAEA+S,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAqU,EAAArU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAkP,GACA,IAoBAtN,EAAAoE,GAAA,MAAA,WACA,IAAA/F,EACAjF,EACA,IAAAiR,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAyP,GAAAlC,MACA,MAAA,IAAAvN,UAAA,6DAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAsR,KAAArM,EACA,IAwDA+B,EAAAgE,GAAAnK,UAAA,MAAA,SAAAyG,GACA,IAAA+L,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA6K,GAAAtH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAKA,GAHAA,EAAA,IACAA,GAAAgK,KAAAgC,WAEAhM,EAAA,GAAAA,GAAAgK,KAAAgC,SAGA,OAAAiD,GAAAjF,KAAAiC,QAAAjM,EACA,IAgBAiL,GAAAvH,GAAAnK,UAAA,UAAA,WACA,OAAAyQ,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAAvH,GAAAnK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAS,UACA,IAgBAzB,GAAAvH,GAAAnK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAX,UACA,IAiBA5L,EAAAgE,GAAAnK,UAAA,oBAAAmK,GAAAiH,mBAuCArL,EAAAoE,GAAAnK,UAAA,cAAA,SAAA4T,EAAAC,GACA,IAAArB,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAQA,OALA,IAAAG,UAAA1D,OACA8Q,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,EAAA,EAAAxQ,UAAA,IAEAoN,IACA,IAqCAtK,EAAAgE,GAAAnK,UAAA,WAAA,WACA,IAAA8R,EACA1C,EACA2E,EACAnL,EACAlB,EACAvI,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAkBA,OAhBAkM,EAAAqB,KACAqB,EAAArB,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EACA8D,GAAA,EAIA8C,EADAgO,EAAA,CAAA,EACA,QAcA,WACA,IAAApC,EAEA,OADAxS,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,IAIAT,EAAA,IAAArB,GAAAwB,EADA7O,GAAA,GACA6O,EAAA7O,EAAA,IACA,CACAjE,MAAA,CAAAG,EAAAwS,GACAS,MAAA,GAEA,IA3BArM,EAAAgO,EAAA,UAoCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA7CAgB,IACArN,EAAAgO,EAAAX,IAoDA,WACA,OAAAhE,EAAA4E,SACA,IApDAD,CAqDA,IA+BAhO,EAAAoE,GAAAnK,UAAA,SAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,IAAAwJ,EAAA1H,KAAAqS,EAAAoC,GAAA7C,EAAA1T,GAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA2CA1K,EAAAoE,GAAAnK,UAAA,QAAA,SAAAhB,EAAA6U,EAAAI,GACA,IAAApB,EACAjK,EACAnC,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAlS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,0EAAAnF,IAIA,GAFA6T,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAA8F,GACA,MAAA,IAAA3Q,UAAAiB,EAAA,qEAAA0P,IAQA,GANAA,EAAA,IACAA,GAAAjL,GACA,IACAiL,EAAA,GAGAxQ,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,oEAAA8P,IAEAA,EAAA,IACAA,GAAArL,GACA,IACAqL,EAAA,GAGAA,EAAArL,IACAqL,EAAArL,EAEA,MACAqL,EAAArL,CAEA,MACAiL,EAAA,EACAI,EAAArL,EAIA,IAFA8H,EAAAH,GAAAvR,GACA2R,EAAAH,GAAAxR,GACAG,EAAA0U,EAAA1U,EAAA8U,EAAA9U,IAEA0T,EADApM,EAAA,EAAAtH,GACAuR,EACAmC,EAAApM,EAAA,GAAAkK,EAEA,OAAAF,IACA,IA2CA1K,EAAAoE,GAAAnK,UAAA,UAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAzT,EACAD,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAkK,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAwS,EAAA+D,GAAA7C,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,OACArR,EAAA8E,KAAAyN,GAGA,OAAA,IAAAlB,KAAAzH,YAAA5J,EACA,IAqCA2G,EAAAoE,GAAAnK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAwS,EAAA+D,GAAA7C,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAkB,CAGA,IA+BA5L,EAAAoE,GAAAnK,UAAA,aAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAwS,EAAA+D,GAAA7C,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IAqCA4G,EAAAoE,GAAAnK,UAAA,YAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAwS,EAAA+D,GAAA7C,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAkB,CAGA,IA+BA5L,EAAAoE,GAAAnK,UAAA,iBAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAwS,EAAA+D,GAAA7C,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IA4BA4G,EAAAoE,GAAAnK,UAAA,WAAA,SAAAkU,EAAAZ,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAAiB,EAAA,oEAAA+P,IAGA,IADArB,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAwS,EAAA+D,GAAA7C,EAAA1T,GACA+U,EAAAjT,KAAAqS,EAAA3B,EAAAxS,EAAAsR,KAEA,IAyCAtK,EAAAgE,GAAAnK,UAAA,OAAA,SAAAyG,GACA,IAAA+L,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkL,GAAA3H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAgK,KAAAgC,SAGA,OAAAiD,GAAAjF,KAAAiC,QAAAjM,EACA,IAgBAiL,GAAAvH,GAAAnK,UAAA,UAAA,WACA,OAAAyQ,KAAAgC,OACA,IAmCA1M,EAAAoE,GAAAnK,UAAA,YAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAA,EAGA,OAAA,CACA,IAmCAV,EAAAoE,GAAAnK,UAAA,WAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyBAgH,EAAAgE,GAAAnK,UAAA,QAAA,SAAAqU,GACA,IAAAjV,EACAyT,EACAyB,EACAnV,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA2U,EAAA,QACA,KAAAzF,GAAAwF,GAGA,MAAA,IAAAnR,UAAAiB,EAAA,kEAAAkQ,IAFAC,EAAAD,CAGA,CAGA,IAFAjV,EAAA,GACAyT,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAAwR,GAAA7C,EAAA1T,GAAAyB,YAEA,OAAAxB,EAAAmV,KAAAD,EACA,IA4BAnO,EAAAgE,GAAAnK,UAAA,QAAA,WACA,IAAAoP,EACA2E,EACAnL,EACAlB,EACAvI,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAgBA,OAdAkM,EAAAqB,KACA7H,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAAG,EACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoF,MACA,IAjDAT,CAkDA,IAsCAhO,EAAAoE,GAAAnK,UAAA,eAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAKA,IAHA/B,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,GAAA,EAAAA,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyCA4G,EAAAoE,GAAAnK,UAAA,OAAA,SAAAkU,EAAAZ,GACA,IAAAmB,EACA5B,EACAzT,EACAD,EACAmJ,EACA,IAAAkK,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAAiB,EAAA,oEAAA+P,IAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADArV,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAgC,UACAC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAA+R,GADA5I,EAAA4L,EAAAjT,KAAAqS,EAAAoC,GAAA7C,EAAA1T,GAAAA,EAAAsR,OAEAgE,EAAA,EAAAtV,GAAAoR,GAAAjI,GACAmM,EAAA,EAAAtV,EAAA,GAAAqR,GAAAlI,OACA,KAAAgG,GAAAhG,IAAA,IAAAA,EAAA3I,OAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAmM,EAAA,EAAAtV,GAAAmJ,EAAA,GACAmM,EAAA,EAAAtV,EAAA,GAAAmJ,EAAA,EAGA,CAEA,OAAAlJ,CACA,IAmCA2G,EAAAoE,GAAAnK,UAAA,UAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACA+B,EACAhM,EAEAzJ,EAEA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAc,GAAA7C,EAAA,GACA1T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IAEAyV,EAAAF,EAAAE,EADAc,GAAA7C,EAAA1T,GACAA,EAAAsR,MAEA,OAAAmE,CACA,IAmCA7O,EAAAoE,GAAAnK,UAAA,eAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACA+B,EACAhM,EAEAzJ,EAEA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAc,GAAA7C,EAAAjK,EAAA,GACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IAEAyV,EAAAF,EAAAE,EADAc,GAAA7C,EAAA1T,GACAA,EAAAsR,MAEA,OAAAmE,CACA,IAmDAzO,EAAAgE,GAAAnK,UAAA,WAAA,WACA,IAAA6S,EACAW,EACA5K,EACAiM,EACA1V,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAKA,IAHA0F,EAAA6H,KAAAgC,QACAI,EAAApC,KAAAiC,QACAmC,EAAA/G,GAAAlF,EAAA,GACAzJ,EAAA,EAAAA,EAAA0V,EAAA1V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAqU,EAAAX,EAAA,EAAA1T,GACA0T,EAAA,EAAA1T,GAAA0T,EAAA,EAAA5P,GACA4P,EAAA,EAAA5P,GAAAuQ,EACAA,EAAAX,EAAA,EAAA1T,EAAA,GACA0T,EAAA,EAAA1T,EAAA,GAAA0T,EAAA,EAAA5P,EAAA,GACA4P,EAAA,EAAA5P,EAAA,GAAAuQ,EAEA,OAAA/C,IACA,IAgEAtK,EAAAgE,GAAAnK,UAAA,OAAA,SAAAhB,GAEA,IAAA8V,EACArO,EACAoM,EACAW,EACAC,EACAoB,EACAvM,EACAnJ,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAGA,GADA2P,EAAApC,KAAAiC,QACArP,UAAA1D,OAAA,GAEA,IAAAyO,GADA3H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAAyK,GAAAlS,GAAA,CACA,GAAAyH,GAAAgK,KAAAgC,QACA,MAAA,IAAAO,WAAA7O,EAAA,kEAAAsC,IAKA,OAFAoM,EADApM,GAAA,GACA8J,GAAAvR,QACA6T,EAAApM,EAAA,GAAA+J,GAAAxR,GAEA,CACA,GAAAwT,GAAAxT,GAAA,CAEA,GAAAyH,GADAoO,EAAA7V,EAAAyT,SACAhC,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAA9V,EAAA0T,QAGAzP,EAAA4P,EAAAd,WAAAtL,EAAA2K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAA9O,GACA6R,EAAA/C,WAAA+C,EAAA3B,WAAAlQ,EAEA,CAGA,IADAuQ,EAAA,IAAA9J,GAAAoL,EAAAnV,QACAR,EAAA,EAAAA,EAAA2V,EAAAnV,OAAAR,IACAqU,EAAArU,GAAA2V,EAAA3V,GAEA2V,EAAAtB,CACA,CAGA,IAFA/M,GAAA,EACAxD,EAAA,EACA9D,EAAA,EAAAA,EAAA0V,EAAA1V,IACA0T,EAAApM,GAAAqO,EAAA7R,GACA4P,EAAApM,EAAA,GAAAqO,EAAA7R,EAAA,GACAwD,GAAA,EACAxD,GAAA,CAGA,KAhCA,CAiCA,IAAAwL,GAAAzP,GA2DA,MAAA,IAAAkE,UAAAiB,EAAA,kIAAAnF,IAxDA,IADA6V,EAAA7V,EAAAW,OACAR,EAAA,EAAAA,EAAA0V,EAAA1V,IACA,IAAA+R,GAAAlS,EAAAG,IAAA,CACAsU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA0D,GACA,MAAA,IAAA7B,WAAA7O,EAAA,6GAAA0Q,IAEA,GAAApO,EAAAoO,EAAA,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAA9V,EAGAiE,EAAA4P,EAAAd,WAAAtL,EAAA2K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAA9O,GACA6R,EAAA/C,WAAA+C,EAAA3B,WAAAlQ,EAEA,CAGA,IADAuQ,EAAA,IAAA9J,GAAAmL,GACA1V,EAAA,EAAAA,EAAA0V,EAAA1V,IACAqU,EAAArU,GAAA2V,EAAA3V,GAEA2V,EAAAtB,CACA,CAIA,IAHA/M,GAAA,EACAoO,GAAA,EACA5R,EAAA,EACA9D,EAAA,EAAAA,EAAA0V,EAAA1V,IACA0T,EAAApM,GAAAqO,EAAA7R,GACA4P,EAAApM,EAAA,GAAAqO,EAAA7R,EAAA,GACAwD,GAAA,EACAxD,GAAA,EAEA,MACA,CAEA,GAAAwD,EAAAoO,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAGA,IADAvM,GAAA,EACAtH,EAAA,EAAAA,EAAA0V,EAAA1V,IACAmJ,EAAAtJ,EAAAG,GACA0T,EAAApM,GAAA8J,GAAAjI,GACAuK,EAAApM,EAAA,GAAA+J,GAAAlI,GACA7B,GAAA,CAxDA,CA+DA,IA2EAV,EAAAoE,GAAAnK,UAAA,SAAA,SAAA6T,EAAAI,GACA,IAAAc,EACAN,EACArV,EACAqH,EACAoM,EACAjK,EACAzJ,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAkU,EAAA,EACAI,EAAArL,MACA,CACA,IAAAmF,GAAA8F,GACA,MAAA,IAAA3Q,UAAAiB,EAAA,oEAAA0P,IAQA,GANAA,EAAA,IACAA,GAAAjL,GACA,IACAiL,EAAA,GAGA,IAAAxQ,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAQA,IANAmM,EADAlB,EAAAI,EACAA,EAAAJ,EAEA,EAGAY,GADArV,EAAA,IAAAqR,KAAAzH,YAAA+L,IACArC,QACAvT,EAAA,EAAAA,EAAA4V,EAAA5V,IACAsH,EAAA,GAAAtH,EAAA0U,GACAY,EAAA,EAAAtV,GAAA0T,EAAApM,GACAgO,EAAA,EAAAtV,EAAA,GAAA0T,EAAApM,EAAA,GAEA,OAAArH,CACA,IA+BA2G,EAAAoE,GAAAnK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,GAAAwJ,EAAA1H,KAAAqS,EAAAoC,GAAA7C,EAAA1T,GAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA6EAtK,EAAAgE,GAAAnK,UAAA,QAAA,SAAAgV,GACA,IAAAxB,EACAX,EACAjK,EACAzJ,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAKA,IAHAnC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACAe,EAAA,GACArU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAqU,EAAAtP,KAAAwR,GAAA7C,EAAA1T,IAGA,IADAqU,EAAAyB,KAAAD,GACA7V,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAEA0T,EADA5P,EAAA,EAAA9D,GACAoR,GAAAiD,EAAArU,IACA0T,EAAA5P,EAAA,GAAAuN,GAAAgD,EAAArU,IAEA,OAAAsR,IACA,IA2EA1K,EAAAoE,GAAAnK,UAAA,YAAA,SAAAkV,EAAAjB,GACA,IAAApC,EACAgB,EACAjK,EACA,IAAA4J,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAuV,EAAA,EACAjB,EAAArL,MACA,CACA,IAAAmF,GAAAmH,GACA,MAAA,IAAAhS,UAAAiB,EAAA,oEAAA+Q,IAQA,GANAA,EAAA,IACAA,GAAAtM,GACA,IACAsM,EAAA,GAGA,IAAA7R,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAWA,OAVAsM,GAAAtM,GACAA,EAAA,EACAiJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACArL,EAAA,EACAiJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEAxI,EAAAqL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAAzH,YAAA6J,EAAAf,OAAAD,EAAAjJ,EAAA,EAAA,EAAAA,EACA,IAwBA7C,EAAAoE,GAAAnK,UAAA,kBAAA,SAAAmV,EAAAC,GACA,IAAAC,EACAC,EACAlW,EACAyT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA2V,EAAA,OACA,KAAAzG,GAAAsG,KAAAnG,GAAAmG,GAGA,MAAA,IAAAjS,UAAAiB,EAAA,yFAAAgR,IAFAG,EAAAH,CAGA,CACA,GAAA9R,UAAA1D,OAAA,EACA0V,EAAA,CAAA,MACA,KAAA1H,GAAAyH,GAGA,MAAA,IAAAlS,UAAAiB,EAAA,qEAAAiR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAAwR,GAAA7C,EAAA1T,GAAAoW,eAAAD,EAAAD,IAEA,OAAAjW,EAAAmV,KAAA,IACA,IAmDApO,EAAAgE,GAAAnK,UAAA,cAAA,WACA,IAAAyU,EACArV,EACAwJ,EACAiK,EACA1T,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAMA,IAJA0F,EAAA6H,KAAAgC,QACArT,EAAA,IAAAqR,KAAAzH,YAAAJ,GACAiK,EAAApC,KAAAiC,QACA+B,EAAArV,EAAAsT,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAsV,EAAA,EAAAtV,GAAA0T,EAAA,EAAA5P,GACAwR,EAAA,EAAAtV,EAAA,GAAA0T,EAAA,EAAA5P,EAAA,GAEA,OAAA7D,CACA,IA6EA+G,EAAAgE,GAAAnK,UAAA,YAAA,SAAAgV,GACA,IAAAxB,EACAX,EACAjK,EACAzJ,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAKA,IAHAnC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACAe,EAAA,GACArU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAqU,EAAAtP,KAAAwR,GAAA7C,EAAA1T,IAGA,OADAqU,EAAAyB,KAAAD,GACA,IAAA7K,GAAAqJ,EACA,IAoBArN,EAAAgE,GAAAnK,UAAA,YAAA,WACA,IAAAZ,EACAyT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,IAFA9D,EAAA,GACAyT,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAAwR,GAAA7C,EAAA1T,GAAAyB,YAEA,OAAAxB,EAAAmV,KAAA,IACA,IA0CApO,EAAAgE,GAAAnK,UAAA,UAAA,WACA,IAAA+T,EACA3E,EACAxG,EACAlB,EACAmL,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAiBA,OAfAkM,EAAAqB,KACAoC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAA0W,GAAA7C,EAAA1T,GACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoG,QACA,IAjDAzB,CAkDA,IAuCAhO,EAAAoE,GAAAnK,UAAA,QAAA,SAAAyV,EAAAzW,GACA,IAAA6T,EACAzT,EACAwJ,EACA,IAAA4J,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA6K,GAAA0H,GACA,MAAA,IAAAvS,UAAAiB,EAAA,oEAAAsR,IAMA,GAJA7M,EAAA6H,KAAAgC,QACAgD,EAAA,IACAA,GAAA7M,GAEA6M,EAAA,GAAAA,GAAA7M,EACA,MAAA,IAAAoK,WAAA7O,EAAA,kEAAAsR,IAEA,IAAAvE,GAAAlS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,2EAAAnF,IAMA,OAHA6T,GADAzT,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAiC,UACAA,SACA,EAAA+C,GAAAlF,GAAAvR,GACA6T,EAAA,EAAA4C,EAAA,GAAAjF,GAAAxR,GACAI,CACA,IIr6FA,IAAAgS,GAAApH,GAAAoH,kBACAmB,GAAAhB,KAYA,SAAAoE,GAAA3W,GACA,MACA,iBAAAA,GACA,OAAAA,GACA,iBAAAA,EAAAgK,YAAAK,MACArK,EAAAoS,oBAAAA,EAEA,CASA,SAAAwE,GAAA5W,GACA,OAAAA,IAAAoL,EACA,CAoEA,SAAAA,KACA,IAAA2H,EACAe,EACAD,EACAjK,EACApI,EAGA,GADAsS,EAAAzP,UAAA1D,SACA8Q,gBAAArG,IACA,OAAA,IAAA0I,EACA,IAAA1I,GAEA,IAAA0I,EACA,IAAA1I,GAAA/G,UAAA,IAEA,IAAAyP,EACA,IAAA1I,GAAA/G,UAAA,GAAAA,UAAA,IAEA,IAAA+G,GAAA/G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAAyP,EACAD,EAAA,IAAA7I,GAAA,QACA,GAAA,IAAA8I,EAEA,GAAA1E,GADA5N,EAAA6C,UAAA,IAEAwP,EAAA,IAAA7I,GAAAxJ,QACA,GAAAiO,GAAAjO,GACAqS,EC9IA,SAAoBA,EAAKrM,GACxB,IAAIoC,EACAzJ,EAGJ,IADAyJ,EAAMpC,EAAI7G,OACJR,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB0T,EAAK1T,GAAMgQ,GAAS3I,EAAKrH,IAE1B,OAAO0T,CACR,CDqIAE,CAAA,IAAA/I,GAAAxJ,EAAAb,QAAAa,QACA,GAAAoO,GAAApO,GACAqS,EAAA,IAAA7I,GAAAxJ,OACA,KAAAmN,GAAAnN,GAaA,MAAA,IAAA0C,UAAAiB,EAAA,qHAAA3D,IAZA,IAAA,IAAA+R,GACA,MAAA,IAAArP,UAAAiB,EAAA,mJAAA3D,IAEA,IAAA4P,GAAA5P,EAAA4S,KACA,MAAA,IAAAlQ,UAAAiB,EAAA,qHAAA3D,IAGA,IAAA4P,IADAyC,EAAArS,EAAA4S,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,qHAAA3D,IAEAqS,EAAA,IAAA7I,GAAAiI,GAAAY,GAGA,KACA,CAEA,IAAAjE,GADAiE,EAAAxP,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA0O,IAGA,IAAAzE,GADA2D,EAAA1O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA4N,IAEA,GAAA,IAAAe,EACAD,EAAA,IAAA7I,GAAA6I,EAAAd,OACA,CAEA,IAAA3D,GADAxF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAAwI,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAA7O,EAAA,iJAAAyE,EAAAwI,KAEAyB,EAAA,IAAA7I,GAAA6I,EAAAd,EAAAnJ,EACA,CACA,CAIA,OAHA7C,EAAA0K,KAAA,UAAAoC,GACA9M,EAAA0K,KAAA,UAAAoC,EAAAlT,QAEA8Q,IACA,CAeA1K,EAAAqE,GAAA,oBAAAgH,IAeArL,EAAAqE,GAAA,OAAA,gBAmCAjE,EAAAiE,GAAA,QAAA,SAAAiJ,GACA,IAAAC,EACAR,EACAS,EACAnU,EACAyT,EACAW,EACA5N,EACAgD,EACAzJ,EACA,IAAAiR,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA0S,GAAAnF,MACA,MAAA,IAAAvN,UAAA,sDAGA,IADA4P,EAAAzP,UAAA1D,QACA,EAAA,CAEA,IAAAyQ,GADAmD,EAAAlQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAoP,IAEAT,EAAA,IACAQ,EAAAjQ,UAAA,GAEA,CACA,GAAAoL,GAAA4E,GAAA,CACA,GAAAE,EAAA,CASA,IARA3K,EAAAyK,EAAA1T,OAEAiG,EADAyN,EAAAzN,KAAAyN,EAAAxN,IACA6N,EAAA,WAEAtM,EAAA,WAGAyL,GADAzT,EAAA,IAAAqR,KAAA7H,IACA8J,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAgQ,GAAAoE,EAAAtS,KAAAqS,EAAA1N,EAAAyN,EAAAlU,GAAAA,IAEA,OAAAC,CACA,CACA,OAAA,IAAAqR,KAAA4C,EACA,CACA,GAAA1F,GAAA0F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,6FAAAkP,IAUA,IAPAG,EADAD,EE1SA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIlU,EACAkJ,EACAnJ,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI4J,EAAGC,QACAC,MAGPjT,GAAK,EACLC,EAAI8E,KAAMiL,GAASoE,EAAKtS,KAAMqS,EAAShL,EAAEtJ,MAAOG,KAEjD,OAAOC,CACR,CF2RAuU,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAIAA,GADAzT,EAAA,IAAAqR,KADA7H,EAAA4K,EAAA7T,SAEA+S,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAqU,EAAArU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAkP,GACA,IAoBAtN,EAAAqE,GAAA,MAAA,WACA,IAAAhG,EACAjF,EACA,IAAAiR,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA0S,GAAAnF,MACA,MAAA,IAAAvN,UAAA,sDAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAsR,KAAArM,EACA,IA6BA+B,EAAAiE,GAAApK,UAAA,MAAA,SAAAyG,GACA,IAAAoM,EACAjK,EAEA,IAAA+M,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA6K,GAAAtH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAOA,GALAmC,EAAA6H,KAAAgC,QACAI,EAAApC,KAAAiC,QACAjM,EAAA,IACAA,GAAAmC,KAEAnC,EAAA,GAAAA,GAAAmC,GAGA,OAAAuG,GAAA0D,EAAApM,GACA,IAgBAiL,GAAAtH,GAAApK,UAAA,UAAA,WACA,OAAAyQ,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAAtH,GAAApK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAS,UACA,IAgBAzB,GAAAtH,GAAApK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAX,UACA,IAiBA5L,EAAAiE,GAAApK,UAAA,oBAAAoK,GAAAgH,mBA+BArL,EAAAqE,GAAApK,UAAA,cAAA,SAAA4T,EAAAC,GACA,IAAA8B,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAQA,OALA,IAAAG,UAAA1D,OACA8Q,KAAAiC,QAAAoB,WAAAF,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAAF,EAAAC,EAAAxQ,UAAA,IAEAoN,IACA,IAgCAtK,EAAAiE,GAAApK,UAAA,WAAA,WACA,IAAAoP,EACA2E,EACAnL,EACAiK,EACAnL,EACAvI,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAiBA,OAfAkM,EAAAqB,KACAoC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAA,CAAAG,EAAAgQ,GAAA0D,EAAA1T,KACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAA4E,SACA,IAjDAD,CAkDA,IA4BAhO,EAAAqE,GAAApK,UAAA,SAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,IAAAwJ,EAAA1H,KAAAqS,EAAAnE,GAAA0D,EAAA1T,IAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA+BA1K,EAAAqE,GAAApK,UAAA,QAAA,SAAAhB,EAAA6U,EAAAI,GACA,IAAApB,EACAjK,EACAiN,EACA1W,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA+L,GAAAjQ,GACA,MAAA,IAAAkE,UAAAiB,EAAA,mEAAAnF,IAIA,GAFA6T,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAA8F,GACA,MAAA,IAAA3Q,UAAAiB,EAAA,qEAAA0P,IAQA,GANAA,EAAA,IACAA,GAAAjL,GACA,IACAiL,EAAA,GAGAxQ,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,oEAAA8P,IAEAA,EAAA,IACAA,GAAArL,GACA,IACAqL,EAAA,GAGAA,EAAArL,IACAqL,EAAArL,EAEA,MACAqL,EAAArL,CAEA,MACAiL,EAAA,EACAI,EAAArL,EAOA,IAJAiN,EADA7W,EACA,EAEA,EAEAG,EAAA0U,EAAA1U,EAAA8U,EAAA9U,IACA0T,EAAA1T,GAAA0W,EAEA,OAAApF,IACA,IAqCA1K,EAAAqE,GAAApK,UAAA,UAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAzT,EACAD,EACAmJ,EAEA,IAAAqN,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAkK,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAmJ,EAAA6G,GAAA0D,EAAA1T,IACAwJ,EAAA1H,KAAAqS,EAAAhL,EAAAnJ,EAAAsR,OACArR,EAAA8E,KAAAoE,GAGA,OAAA,IAAAmI,KAAAzH,YAAA5J,EACA,IA4BA2G,EAAAqE,GAAApK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAvK,EACAnJ,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAmJ,EAAA6G,GAAA0D,EAAA1T,IACAwJ,EAAA1H,KAAAqS,EAAAhL,EAAAnJ,EAAAsR,MACA,OAAAnI,CAGA,IA4BAvC,EAAAqE,GAAApK,UAAA,aAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAvK,EACAnJ,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAmJ,EAAA6G,GAAA0D,EAAA1T,IACAwJ,EAAA1H,KAAAqS,EAAAhL,EAAAnJ,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IA4BA4G,EAAAqE,GAAApK,UAAA,YAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAvK,EACAnJ,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAmJ,EAAA6G,GAAA0D,EAAA1T,IACAwJ,EAAA1H,KAAAqS,EAAAhL,EAAAnJ,EAAAsR,MACA,OAAAnI,CAGA,IA4BAvC,EAAAqE,GAAApK,UAAA,iBAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAvK,EACAnJ,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAmJ,EAAA6G,GAAA0D,EAAA1T,IACAwJ,EAAA1H,KAAAqS,EAAAhL,EAAAnJ,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IA0BA4G,EAAAqE,GAAApK,UAAA,WAAA,SAAAkU,EAAAZ,GACA,IAAAT,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAAiB,EAAA,oEAAA+P,IAGA,IADArB,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA+U,EAAAjT,KAAAqS,EAAAnE,GAAA0D,EAAA1T,IAAAA,EAAAsR,KAEA,IA2BAtK,EAAAiE,GAAApK,UAAA,OAAA,SAAAyG,GACA,IAAAkP,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkL,GAAA3H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAgK,KAAAgC,SAGA,OAAAtD,GAAAsB,KAAAiC,QAAAjM,GACA,IA8BAV,EAAAqE,GAAApK,UAAA,YAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA+L,GAAAkF,GACA,MAAA,IAAAjR,UAAAiB,EAAA,mEAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAGA,IADAvB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IACA,GAAAgV,IAAAhF,GAAA0D,EAAA1T,IACA,OAAA,EAGA,OAAA,CACA,IAiCA4G,EAAAqE,GAAApK,UAAA,WAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA+L,GAAAkF,GACA,MAAA,IAAAjR,UAAAiB,EAAA,mEAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAGA,IADAvB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IACA,GAAAgV,IAAAhF,GAAA0D,EAAA1T,IACA,OAAAA,EAGA,OAAA,CACA,IA0BAgH,EAAAiE,GAAApK,UAAA,QAAA,SAAAqU,GACA,IAAAxB,EACAzT,EACAD,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,GAAAG,UAAA1D,OAAA,GACA,IAAAkP,GAAAwF,GACA,MAAA,IAAAnR,UAAAiB,EAAA,kEAAAkQ,SAGAA,EAAA,IAIA,IAFAxB,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA0T,EAAA1T,GACAC,EAAA8E,KAAA,QAEA9E,EAAA8E,KAAA,SAGA,OAAA9E,EAAAmV,KAAAF,EACA,IA4BAlO,EAAAiE,GAAApK,UAAA,QAAA,WACA,IAAAoP,EACA2E,EACAnL,EACAlB,EACAvI,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAgBA,OAdAkM,EAAAqB,KACA7H,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAAG,EACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoF,MACA,IAjDAT,CAkDA,IAiCAhO,EAAAqE,GAAApK,UAAA,eAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA+L,GAAAkF,GACA,MAAA,IAAAjR,UAAAiB,EAAA,mEAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAGA,IADAI,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,GAAA,EAAAA,IACA,GAAAgV,IAAAhF,GAAA0D,EAAA1T,IACA,OAAAA,EAGA,OAAA,CACA,IAgBAuS,GAAAtH,GAAApK,UAAA,UAAA,WACA,OAAAyQ,KAAAgC,OACA,IAqCA1M,EAAAqE,GAAApK,UAAA,OAAA,SAAAkU,EAAAZ,GACA,IAAAmB,EACArV,EACAyT,EACA1T,EACA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAA,oEAAAgR,GAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADArV,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAgC,UACAC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAsV,EAAAtV,GAAAgQ,GAAA+E,EAAAjT,KAAAqS,EAAAnE,GAAA0D,EAAA1T,IAAAA,EAAAsR,OAEA,OAAArR,CACA,IA+BA2G,EAAAqE,GAAApK,UAAA,UAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACAjK,EACAgM,EACAzV,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAzF,GAAA0D,EAAA,IACA1T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IACAyV,EAAAF,EAAAE,EAAAzF,GAAA0D,EAAA1T,IAAAA,EAAAsR,MAEA,OAAAmE,CACA,IA+BA7O,EAAAqE,GAAApK,UAAA,eAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACAjK,EACAgM,EACAzV,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAzF,GAAA0D,EAAAjK,EAAA,IACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IACAyV,EAAAF,EAAAE,EAAAzF,GAAA0D,EAAA1T,IAAAA,EAAAsR,MAEA,OAAAmE,CACA,IA8BAzO,EAAAiE,GAAApK,UAAA,WAAA,WACA,IAAA6S,EACAW,EACA5K,EACAiM,EACA1V,EACA8D,EAEA,IAAA0S,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAKA,IAHA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACAoC,EAAA/G,GAAAlF,EAAA,GACAzJ,EAAA,EAAAA,EAAA0V,EAAA1V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAqU,EAAAX,EAAA1T,GACA0T,EAAA1T,GAAA0T,EAAA5P,GACA4P,EAAA5P,GAAAuQ,EAEA,OAAA/C,IACA,IA+CAtK,EAAAiE,GAAApK,UAAA,OAAA,SAAAhB,GACA,IAAA8V,EACArO,EACAoM,EACAW,EACAqB,EACA1V,EACA8D,EACA,IAAA0S,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAGA,GADA2P,EAAApC,KAAAiC,QACArP,UAAA1D,OAAA,GAEA,IAAAyO,GADA3H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAAgI,GAAAzP,GAAA,CAEA,GAAAyH,GADAoO,EAAA7V,EAAAW,QACA8Q,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FASA,GANA8B,EADAa,GAAA3W,GACAA,EAAA0T,QAEA1T,EAGAiE,EAAA4P,EAAAd,WAAAtL,EAAA2K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAA9O,GACA6R,EAAA/C,WAAA+C,EAAA3B,WAAAlQ,EAEA,CAGA,IADAuQ,EAAA,IAAAxJ,GAAA8K,EAAAnV,QACAR,EAAA,EAAAA,EAAA2V,EAAAnV,OAAAR,IACAqU,EAAArU,GAAA2V,EAAA3V,GAEA2V,EAAAtB,CACA,CACA,IAAArU,EAAA,EAAAA,EAAA0V,EAAApO,IAAAtH,IACA0T,EAAApM,GAAAqO,EAAA3V,GAAA,EAAA,CAGA,KA9BA,CA+BA,GAAAsH,GAAAgK,KAAAgC,QACA,MAAA,IAAAO,WAAA7O,EAAA,kEAAAsC,IAEAoM,EAAApM,GAAA,EAAA,EAAA,CAJA,CAKA,IAgDAV,EAAAqE,GAAApK,UAAA,SAAA,SAAAkV,EAAAjB,GACA,IAAAc,EACAN,EACArV,EACAyT,EACAjK,EACAzJ,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAuV,EAAA,EACAjB,EAAArL,MACA,CACA,IAAAmF,GAAAmH,GACA,MAAA,IAAAhS,UAAAiB,EAAA,oEAAA+Q,IAQA,GANAA,EAAA,IACAA,GAAAtM,GACA,IACAsM,EAAA,GAGA,IAAA7R,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAQA,IANAmM,EADAG,EAAAjB,EACAA,EAAAiB,EAEA,EAGAT,GADArV,EAAA,IAAAqR,KAAAzH,YAAA+L,IACArC,QACAvT,EAAA,EAAAA,EAAA4V,EAAA5V,IACAsV,EAAAtV,GAAA0T,EAAA1T,EAAA+V,GAEA,OAAA9V,CACA,IA4BA2G,EAAAqE,GAAApK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,GAAAwJ,EAAA1H,KAAAqS,EAAAnE,GAAA0D,EAAA1T,IAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA4CAtK,EAAAiE,GAAApK,UAAA,QAAA,SAAAgV,GACA,IAAAnC,EAEA,IAAA8C,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAGA,GADA2P,EAAApC,KAAAiC,QACA,IAAArP,UAAA1D,OAEA,OADAkT,EAAAoC,OACAxE,KAEA,IAAAL,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAGA,OADAnC,EAAAoC,MAWA,SAAAa,EAAAC,GACA,OAAAf,EAAA7F,GAAA2G,GAAA3G,GAAA4G,GACA,IAZAtF,IAaA,IAgDA1K,EAAAqE,GAAApK,UAAA,YAAA,SAAAkV,EAAAjB,GACA,IAAApC,EACAgB,EACAjK,EAEA,IAAA+M,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAuV,EAAA,EACAjB,EAAArL,MACA,CACA,IAAAmF,GAAAmH,GACA,MAAA,IAAAhS,UAAAiB,EAAA,oEAAA+Q,IAQA,GANAA,EAAA,IACAA,GAAAtM,GACA,IACAsM,EAAA,GAGA,IAAA7R,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAWA,OAVAsM,GAAAtM,GACAA,EAAA,EACAiJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACArL,EAAA,EACAiJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEAxI,EAAAqL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAAzH,YAAA6J,EAAAf,OAAAD,EAAAjJ,EAAA,EAAA,EAAAA,EACA,IAyBA7C,EAAAqE,GAAApK,UAAA,kBAAA,SAAAmV,EAAAC,GACA,IAAAC,EACAC,EACAlW,EACAyT,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,GAAA,IAAAG,UAAA1D,OACA2V,EAAA,OACA,KAAAzG,GAAAsG,KAAAnG,GAAAmG,GAGA,MAAA,IAAAjS,UAAAiB,EAAA,yFAAAgR,IAFAG,EAAAH,CAGA,CACA,GAAA9R,UAAA1D,OAAA,EACA0V,EAAA,CAAA,MACA,KAAA1H,GAAAyH,GAGA,MAAA,IAAAlS,UAAAiB,EAAA,qEAAAiR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAAiL,GAAA0D,EAAA1T,IAAAoW,eAAAD,EAAAD,IAEA,OAAAjW,EAAAmV,KAAA,IACA,IA8BApO,EAAAiE,GAAApK,UAAA,cAAA,WACA,IAAAyU,EACArV,EACAwJ,EACAiK,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAMA,IAJA0F,EAAA6H,KAAAgC,QACArT,EAAA,IAAAqR,KAAAzH,YAAAJ,GACAiK,EAAApC,KAAAiC,QACA+B,EAAArV,EAAAsT,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAsV,EAAAtV,GAAA0T,EAAAjK,EAAAzJ,EAAA,GAEA,OAAAC,CACA,IA6CA+G,EAAAiE,GAAApK,UAAA,YAAA,SAAAgV,GACA,IAAAP,EACArV,EACAwJ,EACAiK,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAMA,IAJA0F,EAAA6H,KAAAgC,QACArT,EAAA,IAAAqR,KAAAzH,YAAAJ,GACAiK,EAAApC,KAAAiC,QACA+B,EAAArV,EAAAsT,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAsV,EAAAtV,GAAA0T,EAAA1T,GAEA,GAAA,IAAAkE,UAAA1D,OAEA,OADA8U,EAAAQ,OACA7V,EAEA,IAAAgR,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAGA,OADAP,EAAAQ,MAWA,SAAAa,EAAAC,GACA,OAAAf,EAAA7F,GAAA2G,GAAA3G,GAAA4G,GACA,IAZA3W,CAaA,IAqBA+G,EAAAiE,GAAApK,UAAA,YAAA,WACA,IAAAZ,EACAyT,EACA1T,EACA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAIA,IAFA9D,EAAA,GACAyT,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA0T,EAAA1T,GACAC,EAAA8E,KAAA,QAEA9E,EAAA8E,KAAA,SAGA,OAAA9E,EAAAmV,KAAA,IACA,IA4BApO,EAAAiE,GAAApK,UAAA,UAAA,WACA,IAAA+T,EACA3E,EACAxG,EACAlB,EACAmL,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAiBA,OAfAkM,EAAAqB,KACAoC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAAmQ,GAAA0D,EAAA1T,IACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoG,QACA,IAjDAzB,CAkDA,IA6BAhO,EAAAqE,GAAApK,UAAA,QAAA,SAAAyV,EAAAzW,GACA,IACAI,EACAwJ,EAEA,IAAA+M,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA6K,GAAA0H,GACA,MAAA,IAAAvS,UAAAiB,EAAA,oEAAAsR,IAMA,GAJA7M,EAAA6H,KAAAgC,QACAgD,EAAA,IACAA,GAAA7M,GAEA6M,EAAA,GAAAA,GAAA7M,EACA,MAAA,IAAAoK,WAAA7O,EAAA,kEAAAsR,IAEA,IAAAxG,GAAAjQ,GACA,MAAA,IAAAkE,UAAAiB,EAAA,oEAAAnF,IASA,OAPAI,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAiC,UACAA,QAEA+C,GADAzW,EACA,EAEA,EAEAI,CACA,IG/4EA,IAAI4W,GAAQ,CACXtM,GACAD,GACAG,GACAG,GACAJ,GACAG,GACAD,GACAG,GACAC,GACAC,GACAC,GACAC,IC5BG6L,GAAS,CACZ,UACA,UACA,QACA,SACA,QACA,SACA,OACA,QACA,SACA,YACA,aACA,QCHGC,GAASD,GAAOtW,OAkBpB,SAAS0H,GAAOrI,GACf,IAAIG,EACJ,GAAKkD,GAASrD,GACb,MAAO,UAER,GAAK8J,GAAU9J,GACd,OAAO,KAER,IAAMG,EAAI,EAAGA,EAAI+W,GAAQ/W,IACxB,GAAKH,aAAiBgX,GAAO7W,GAC5B,OAAO8W,GAAQ9W,GAIjB,OAAOgX,GAAY/M,GAAiBpK,KAAa,IAClD,CCNA,SAASoX,GAAWpI,GACnB,IAAIqI,EAAKhP,GAAO2G,GAChB,OAAK3H,EAAiB2H,GACd,CACNsI,kBAAoB,EACpBF,UAAa,CACZ1C,EAAgB2C,GAChBE,EAAgBF,KAIZ,CACNC,kBAAoB,EACpBF,UAAa,CACZhP,EAAQiP,GACR9O,EAAQ8O,IAGX,CCNA,SAASG,GAAehQ,GACvB,IAAIiQ,EACJ,KAAOhG,gBAAgB+F,IACtB,OAAO,IAAIA,GAAehQ,GAE3B,IAAMiI,GAAcjI,GACnB,MAAM,IAAItD,UAAWiB,EAAQ,oEAAqEqC,IAMnG,OAJAiQ,EAAIL,GAAW5P,GACfiK,KAAKiC,QAAUlM,EACfiK,KAAKiG,QAAUD,EAAEL,UAAW,GAC5B3F,KAAKkG,QAAUF,EAAEL,UAAW,GACrB3F,IACR,CAeA1K,EAAayQ,GAAe,OAAQ,iBC1CpC,SAA4CnR,EAAKC,EAAM8B,EAAQG,GAC9DzI,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdL,IAAOwB,EACPvB,IAAO0B,GAET,CD4CoBqP,CAAEJ,GAAcxW,UAAW,UA3D/C,WACC,OAAOyQ,KAAKiC,QAAQ/S,MACrB,IAZA,SAAoBiJ,GACnB6H,KAAKiC,QAAQ/S,OAASiJ,CACvB,IAqFWzC,EAAEqQ,GAAcxW,UAAW,OAAO,SAAcyG,GAC1D,OAAOgK,KAAKiG,QAASjG,KAAKiC,QAASjM,EACpC,IAwBAV,EAAayQ,GAAcxW,UAAW,OAAO,SAAchB,EAAOyH,GAC5DpD,UAAU1D,OAAS,EACvB8Q,KAAKkG,QAASlG,KAAKiC,QAAS,EAAG1T,GAGhCyR,KAAKkG,QAASlG,KAAKiC,QAASjM,EAAKzH,EAClC,IExIA,IAAIoS,GAAoB,EAoBxB,SAASuE,GAAgB3W,GAExB,MACkB,iBAAVA,GACG,OAAVA,GAC2B,iBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMoS,oBAAsBA,EAE9B,CCGA,SAASyF,GAAkB7I,GAC1B,IAAIqI,EAAKhP,GAAO2G,GAChB,OAAK3H,EAAiB2H,GACd,CACN8I,KAAQ9I,EACR3G,MAASgP,EACTC,kBAAoB,EACpBF,UAAa,CACZ1C,EAAgB2C,GAChBE,EAAgBF,KAIZ,CACNS,KAAQ9I,EACR3G,MAASgP,EACTC,kBAAoB,EACpBF,UAAa,CACZhP,EAAQiP,GACR9O,EAAQ8O,IAGX,CCrDA,IAAI/M,GAA+B,mBAAfU,WAA8BA,gBAAa,EC6B/D+M,GATKpK,KACGvH,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECcA,SAASiR,GAAa5D,EAAG6D,GACxB,OAAO,IAAI7H,GAAYgE,EAAE8D,OAAQ9D,EAAE+D,WAAY/D,EAAEoD,kBAAkBS,EAAS7D,EAAErO,OAAOkS,EACtF,CCKA,SAASmF,GAAUhJ,GAClB,IAAI7O,EACJ,IAAMA,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1B,GAAK6O,EAAG7O,GACP,OAAO,EAGT,OAAO,CACR,CCjBA,SAAS8X,GAAejJ,GACvB,IAAIqI,EAAKhP,GAAO2G,GAChB,OAAK3H,EAAiB2H,GACd0F,EAAgB2C,GAEjBjP,EAAQiP,EAChB,CCJA,SAASa,GAASlY,EAAOiJ,GACxB,OAAKjJ,UAGoB,iBAAbiJ,EACJA,KAAYpJ,OAAQG,GAEnBe,OAAQkI,KAAcpJ,OAAQG,GACxC,CCZA,SAASmY,GAAUnJ,EAAGhP,GACrB,IAAI4J,EACAhD,EACAyQ,EACAlX,EAeJ,IAZAkX,EAAKhP,GAAO2G,GAIXpI,EADIS,EAAiB2H,GACf0F,EAAgB2C,GAEhBjP,EAAQiP,GAGfzN,EAAMoF,EAAErO,OAGFR,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAKyG,EAAKoI,EAAG7O,KAAQH,EACpB,OAAO,EAGT,OAAO,CACR,CCrBA,SAASoY,GAASpJ,GACjB,IAAIpI,EACAgD,EACAyN,EAEJ,IAAM5H,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,oEAAqE6J,IAYnG,OATAqI,EAAKhP,GAAO2G,GAGP3H,EAAiB2H,KACrBpI,EAAM8N,EAAgB2C,IAGvBzN,EAAMoF,EAAErO,YAES,IAARiG,EAYT,SAAmB5G,GAClB,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAK6O,EAAG7O,KAAQH,EACf,OAAO,EAGT,OAAO,CACP,EAQD,SAAoBA,GACnB,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAKyG,EAAKoI,EAAG7O,KAAQH,EACpB,OAAO,EAGT,OAAO,CACP,CACF,CChEA,SAASqY,GAAQrJ,GAChB,OAASA,GAAMA,CAChB,CCGAjI,EAAAnH,GAAA,UAAAwY,ICSA,IAAIE,GAAoB,WC5BpBhO,GAAgC,mBAAhBS,YAA+BA,iBAAc,EC6BjEwN,GATKlM,KACGjG,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECHImQ,GAAe,IAAIrH,GAAc,GACjC+N,GAAc,IAAIzN,GAAa+G,GAAagB,QAoBhD,SAAS2F,GAASzJ,GAEjB,OADA8C,GAAc,GAAM9C,EACbwJ,GAAa,EACrB,CCJA,SAASrW,GAAK6M,GACb,OAAO5M,KAAKD,IAAK6M,EAClB,CCbA,SAAS0J,GAAaC,GACrB,OAAKA,EAAOC,GACM,GAAPD,GAGFA,EAAOC,MAAgB,CACjC,CCsBA,SAASC,GAAgB/B,EAAGC,EAAG+B,GAC9B,ODeiB9J,ECfD+C,GAAK+E,GDeDiC,ECfMhH,GAAKgF,IDmB1BsB,GAAQrJ,IAAOqJ,GAAQU,GACpBtN,KAGRuN,EAAKP,GAASzJ,GACdiK,EAAKR,GAASM,GAOP5W,IAJP6W,EAAKN,GAAaM,KAClBC,EAAKP,GAAaO,QC5BsBH,EDezC,IAAkB9J,EAAG+J,EAChBC,EACAC,CChBL,CC/BA,SAAS1V,GAAOyL,GACf,OAASA,GAAMA,CAChB,CCYA,ICPKkK,GDODC,GAA8B,WE5B9B7O,GAAgC,mBAAhBQ,YAA+BA,iBAAc,EC6BjEsO,GATKpM,KACG5G,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECHI0X,GAAQ,CACXtR,OAAU+C,GACV9C,MAASgD,KJgBTkO,GAAa,IAAIG,GAAiB,OAAE,IAOxB,GAAM,KAiBnB,IK1CIC,GACAC,GLyCJC,GAX6B,KAHhB,IAAIH,GAAgB,MAAEH,GAAWpG,QAGzB,IK5BG,IAAnB2G,IACJH,GAAO,EACPC,GAAM,IAEND,GAAO,EACPC,GAAM,GAUP,IAAAG,GARU,CACTJ,KAAQA,GACRC,IAAOA,ICXJI,GAAe,IAAIjP,GAAc,GACjC8N,GAAc,IAAIzN,GAAa4O,GAAa7G,QAE5CwG,GAAOM,GAAQN,KACfC,GAAMK,GAAQL,IA+DlB,SAASM,GAAS7K,EAAG5O,EAAK0Z,EAAQjH,GAIjC,OAHA8G,GAAc,GAAM3K,EACpB5O,EAAKyS,GAAW2F,GAAac,IAC7BlZ,EAAKyS,EAASiH,GAAWtB,GAAae,IAC/BnZ,CACR,CChEA,SAASyZ,GAAS7K,GACjB,OAAOkG,GAAKlG,EAAG,CAAE,EAAO,GAAS,EAAG,EACrC,CCcAjI,EAAAnH,GAAA,SAAAma,ICvBA,IAAIC,GAAK,IAAIjP,GAAa,GACtBkP,GAAK,IAAIlP,GAAa,GACtBmP,GAAK,IAAInP,GAAa,GAGtBoP,GAAS,WAgBb,SAASzB,GAAa0B,GAMrB,OALKA,EAAO,GAAIxB,GACfwB,EAkBF,SAAiBA,GAShB,OARAA,EAAO,IAAOA,EAAO,GACrBA,EAAO,IAAOA,EAAO,GACrBA,EAAO,IAAO,EAGM,IAAfA,EAAO,KACXA,EAAO,IAAO,GAERA,CACR,CA5BUC,CAAQD,GAEhBA,EAAO,IAAOxB,GAERwB,CACR,CA0DA,SAASE,GAAUC,EAAIC,EAAIC,GAC1B,IAAIC,EACAC,EACAC,EACAC,EAcJ,OAZAH,EAAKH,EAAI,GACTK,EAAKL,EAAI,GACTI,EAAKH,EAAI,GAGJI,IAFLC,EAAKL,EAAI,KAGRC,EAAI,GAAMC,EAAKC,EACfF,EAAI,GAAMG,EAAKC,IAEfJ,EAAI,GAAQC,EAAKC,EAAK,EACtBF,EAAI,GAAQG,EAAKT,GAAWU,GAEtBJ,CACR,CCvEA,SAASK,GAAehE,EAAGC,EAAG+B,GAC7B,OD4GoBC,EC5GDhC,GDiHdxT,GALYyL,EC5GD8H,IDiHGvT,GAAOwV,GAClBtN,KAGRuN,EAAKa,GAAS7K,EAAGgL,GAAI,EAAG,GACxBf,EAAKY,GAASd,EAAGkB,GAAI,EAAG,GAGxBjB,EAAKN,GAAaM,GAClBC,EAAKP,GAAaO,GAhGGuB,EAmGFvB,EAGN,IAHb8B,GAnGiBR,EAmGFvB,GAlGN,GAAMwB,EAAI,GACX,EAEHD,EAAI,GAAMC,EAAI,IACV,EAEJD,EAAI,GAAMC,EAAI,GACX,EAEHD,EAAI,GAAMC,EAAI,IACV,EAEF,GA2FC,GAGPQ,EADY,IAARD,EACCT,GAAUtB,EAAIC,EAAIiB,IAElBI,GAAUrB,EAAID,EAAIkB,KAGX,GAAIC,GAAWa,EAAI,MC1INlC,ED4G3B,IAAkB9J,EAAG+J,EAChBgC,EACA/B,EACAC,EACA+B,EAtFaT,EAAIC,CCzBtB,CCzBA,SAASS,GAAMtI,GACd,IAAIvS,EAAM,IAAIqK,GAAc,GAG5B,OAFArK,EAAK,GAAMuS,EAAEjB,GACbtR,EAAK,GAAMuS,EAAEhB,GACNvR,CACR,CCLA,SAAS6a,GAAMtI,GACd,IAAIvS,EAAM,IAAIsK,GAAc,GAG5B,OAFAtK,EAAK,GAAMuS,EAAEjB,GACbtR,EAAK,GAAMuS,EAAEhB,GACNvR,CACR,CCmBA,SAAS0a,GAAehE,EAAGC,EAAG+B,GAC7B,OAAKhC,IAAMC,IAGNhX,GAAU+W,IAAO/W,GAAUgX,GACxBmE,GAAkBpE,EAAGC,EAAG+B,MAE3B5G,GAAe4E,KAAO5E,GAAe6E,MACZ,IAAxBD,EAAE1E,mBAAmD,IAAxB2E,EAAE3E,kBCnBtC,SAAyB+I,EAAIC,EAAItC,GAChC,IAAIuC,EAASC,GAAOH,GAChBI,EAASD,GAAOF,GACpB,OACCI,GAAkBH,EAAQ,GAAKE,EAAQ,GAAKzC,IAC5C0C,GAAkBH,EAAQ,GAAKE,EAAQ,GAAKzC,EAE9C,CDaU2C,CAAwB3E,EAAGC,EAAG+B,GEpBxC,SAAwBqC,EAAIC,EAAItC,GAC/B,IAAIuC,EAASJ,GAAME,GACfI,EAASN,GAAMG,GACnB,OACCF,GAAkBG,EAAQ,GAAKE,EAAQ,GAAKzC,IAC5CoC,GAAkBG,EAAQ,GAAKE,EAAQ,GAAKzC,EAE9C,CFeS4C,CAAyB5E,EAAGC,EAAG+B,IAGxC,CGfA,SAASd,GAAUhJ,EAAG+J,EAAGD,EAAQ5D,GAChC,IAAI/U,EACJ,IAAMA,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1B,IAAM+U,EAAKlG,EAAG7O,GAAK4Y,EAAG5Y,GAAK2Y,GAC1B,OAAO,EAGT,OAAO,CACR,CAkCA,SAAS1B,GAAWpI,EAAG+J,EAAGD,EAAQ5D,GACjC,IAAIyG,EACAC,EACAC,EACAC,EACA3b,EAQJ,IANAwb,EAAQ3M,EAAE8I,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO7M,EAAEoI,UAAW,GACpB0E,EAAO/C,EAAE3B,UAAW,GAEdjX,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,IAC9B,IAAM+U,EAAK2G,EAAMF,EAAOxb,GAAK2b,EAAMF,EAAOzb,GAAK2Y,GAC9C,OAAO,EAGT,OAAO,CACR,CCtEA,SAASd,GAAUhJ,EAAG+J,GACrB,IAAI5Y,EACJ,IAAMA,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1B,GAAK6O,EAAG7O,KAAQ4Y,EAAG5Y,GAClB,OAAO,EAGT,OAAO,CACR,CA8BA,SAASiX,GAAWpI,EAAG+J,GACtB,IAAI4C,EACAC,EACAC,EACAC,EACA3b,EAQJ,IANAwb,EAAQ3M,EAAE8I,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO7M,EAAEoI,UAAW,GACpB0E,EAAO/C,EAAE3B,UAAW,GAEdjX,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,IAC9B,GAAK0b,EAAMF,EAAOxb,KAAQ2b,EAAMF,EAAOzb,GACtC,OAAO,EAGT,OAAO,CACR,CC5DA,SAAS4b,GAAajF,EAAGC,GACxB,OAAKD,IAAMC,EACC,IAAND,GACG,EAAMA,GAAM,EAAMC,EAIlBD,GAAMA,GAAKC,GAAMA,CAC3B,CCUA,SAASgF,GAAajF,EAAGC,GACxB,OAAKD,IAAMC,EACC,IAAND,GACG,EAAMA,GAAM,EAAMC,EAItBD,GAAMA,GAAKC,GAAMA,MAGjB7E,GAAe4E,KAAO5E,GAAe6E,MC7BjBqE,ED8BMrE,EC7B3BsE,EAASJ,GD6BenE,GC5BxByE,EAASN,GAAMG,GAElBY,GAAQX,EAAQ,GAAKE,EAAQ,KAC7BS,GAAQX,EAAQ,GAAKE,EAAQ,KAL/B,IAA0BH,EACrBC,EACAE,CD+BL,CE5BA,SAASvD,GAAUhJ,EAAG+J,GACrB,IAAI5Y,EACJ,IAAMA,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1B,IAAM4b,GAAa/M,EAAG7O,GAAK4Y,EAAG5Y,IAC7B,OAAO,EAGT,OAAO,CACR,CA8BA,SAASiX,GAAWpI,EAAG+J,GACtB,IAAI4C,EACAC,EACAC,EACAC,EACA3b,EAQJ,IANAwb,EAAQ3M,EAAE8I,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO7M,EAAEoI,UAAW,GACpB0E,EAAO/C,EAAE3B,UAAW,GAEdjX,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,IAC9B,IAAM4b,GAAaF,EAAMF,EAAOxb,GAAK2b,EAAMF,EAAOzb,IACjD,OAAO,EAGT,OAAO,CACR,CClEA,SAASkC,GAAS/B,EAAK2b,EAAQC,GAC9B,OAAO5b,EAAI+B,QAAS4Z,EAAQC,EAC7B,m6BCrBIC,GAAY,gBAmBhB,SAASC,KACR,IAAIC,EACAjc,EACAsI,EACJ,OAA0B,IAArBrE,UAAU1D,OACPsW,GAAOqF,IAAItX,SAEnB0D,GAAM,EACN2T,EAAOhY,UAAW,GACb8X,GAAU1N,KAAM4N,IAEN,SADdA,EAAOha,GAASga,EAAMF,GAAW,MACD,UAATE,IACtB3T,GAAM,GAIRtI,GADAA,EAAM6W,GAAQoF,IACEjc,EAAI4E,QAAU,GACzB0D,GAAOtI,EAAIO,OAAS,GACxBP,EAAI8E,KAAM,WAEJ9E,EACR,CCWA,IAAImc,GAAoBpE,GAAUiE,GAAQ,8CC3C1C,SAASI,KACR,OAAOC,GAAOzX,OACf,CCQA,IAAI0X,GAAcvE,GAAUwE,MC8BxBC,GAAiCzE,GAAUiE,GAAQ,2BCtDnDS,GAAwB,EACxBC,GAAyB,GAoB7B,SAASC,GAAqB/c,GAE7B,MACkB,iBAAVA,GACG,OAAVA,IAG6B,oBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMoS,oBAAsB0K,IAGD,mBAA3B9c,EAAMgK,YAAYK,MAClBrK,EAAMoS,oBAAsByK,GAIhC,CCWA,IAAIG,GAAa7E,GAAUiE,MCAvBa,GAA0B9E,GAAUiE,GAAQ,mBCA5Cc,GAAoB/E,GAAUiE,GAAQ,YC5B1C,SAAS5G,GAAMxV,GACd,OAAOH,OAAO2V,KAAM3V,OAAQG,GAC7B,CCtBA,ICKIuL,GDLAA,QAAgC,IAAhB1L,OAAO2V,KEwB3B,SAAS2H,GAAand,GACrB,MAAkC,uBAAzBoJ,GAAapJ,EACvB,CDCIod,GAPJ,WACC,OAAOD,GAAa9Y,UACrB,CAKOgZ,GAKP,IAAAC,GAAe/R,GERf,SAAShI,GAAOvD,GACf,OACCD,GAAUC,IACVud,GAAOvd,EAET,CCTA,SAASuD,GAAOvD,GACf,OACCD,GAAUC,IACVud,GAAOvd,EAAMmP,UAEf,CCGA,SAAS5L,GAAOvD,GACf,OAAS0O,GAAa1O,IAAW2O,GAAU3O,EAC5C,CCoBA+G,EAAAnH,GAAA,cAAA8O,IACA3H,EAAAnH,GAAA,WAAA+O,ICzBA,IAAI6O,GAAuB3d,OAAOmB,UAAUyc,qBCE5CC,IAXSC,GAAO1b,KAAM,OAAQ,KCe9B,SAASub,GAAsBxd,EAAOiJ,GACrC,IAAIsC,EACJ,OACCvL,YAKDuL,EAAOoS,GAAO1b,KAAMjC,EAAOiJ,KACbyU,IAAoB7N,GAAU7P,IAIzCuD,GAFF0F,GAAYA,IAGX8F,GAAW9F,IACXA,GAAY,GACZA,EAAWjJ,EAAMW,OAGZ4K,EACR,CChBA,IAAAqS,GATKN,GACU1d,GCAf,SAAsBI,GACrB,OACW,OAAVA,GACiB,iBAAVA,IACNqD,GAASrD,IACc,iBAAjBA,EAAMW,QACboO,GAAW/O,EAAMW,SACjBX,EAAMW,QAAU,GAChBX,EAAMW,QAAU4O,IAChBvG,GAAYhJ,EAAO,YAClBwd,GAAsBxd,EAAO,SAEhC,EClCIgF,GAAQ1B,MAAMtC,UAAUgE,MCCxBuG,GAAOiS,ICFX,WAEA,GDAuC,aEMnCjS,IAAQiS,GARF,CACT5b,SAAY,MAO0B,YCiDvC,SAASwC,GAASoD,EAAK2N,EAAeC,GACrC,IAAIxL,EACAzJ,EACJ,IAAMsP,GAAcjI,KAAUqI,GAAUrI,GACvC,MAAM,IAAItD,UAAWiB,EAAQ,8EAA+EqC,IAG7G,GAAa,KADboC,EAAMpC,EAAI7G,QAET,OAAQ,EAET,GAA0B,IAArB0D,UAAU1D,OAAe,CAC7B,IAAMoO,GAAWqG,GAChB,MAAM,IAAIlR,UAAWiB,EAAQ,oEAAqEiQ,IAEnG,GAAKA,GAAa,EAAI,CACrB,GAAKA,GAAaxL,EACjB,OAAQ,EAETzJ,EAAIiV,CACP,MACGjV,EAAIyJ,EAAMwL,GACD,IACRjV,EAAI,EAGR,MACEA,EAAI,EAGL,GAAKoD,GAAO4R,IACX,KAAQhV,EAAIyJ,EAAKzJ,IAChB,GAAKoD,GAAOiE,EAAIrH,IACf,OAAOA,OAIT,KAAQA,EAAIyJ,EAAKzJ,IAChB,GAAKqH,EAAKrH,KAAQgV,EACjB,OAAOhV,EAIV,OAAQ,CACT,CClGA,SAAS0d,GAAwB7d,GAChC,OAASA,EAAMgK,aAAehK,EAAMgK,YAAYhJ,YAAchB,CAC/D,KCiBIwV,2PC1BAsI,GAAwB,oBAAXzN,YAA2B,EAASA,OCqDrD0N,GA9BA,WACC,IAAIC,EACJ,GAAuB,cAAlB3M,GAAQ4M,IACZ,OAAO,EAER,IAAMD,KAAKC,GACV,KAEmC,IAAjC7Z,GAAS8Z,GAAeF,IACxBhV,GAAYiV,GAAKD,IACJ,OAAbC,GAAKD,IACkB,WAAvB3M,GAAQ4M,GAAKD,KAEbH,GAAwBI,GAAKD,GAE9B,CAAC,MAAQ9X,GACT,OAAO,CACP,CAEF,OAAO,CACR,CAKOiY,GChDH5S,GAA2B,oBAAX8E,wHH+BlBmF,GAJG4I,GIhBL,WACC,OAA8C,KAArC5I,GAAMnR,YAAe,IAAK1D,MACpC,CAgBQ8N,CAAM,EAAG,GVFjB,SAAezO,GACd,OAAKmd,GAAand,GACVoG,GAASpB,GAAM/C,KAAMjC,IAEtBoG,GAASpG,EACjB,EMDSoG,GKJT,SAAepG,GACd,IAAIqe,EACAC,EACAC,EACAne,EACA4d,EACAQ,EACAre,EAGJ,GADAC,EAAM,GACD+c,GAAand,GAAU,CAE3B,IAAMG,EAAI,EAAGA,EAAIH,EAAMW,OAAQR,IAC9BC,EAAI8E,KAAM/E,EAAEyB,YAGb,OAAOxB,CACP,CACD,GAAsB,iBAAVJ,GAEX,GAAKA,EAAMW,OAAS,IAAMqI,GAAYhJ,EAAO,KAC5C,IAAMG,EAAI,EAAGA,EAAIH,EAAMW,OAAQR,IAC9BC,EAAI8E,KAAM/E,EAAEyB,gBAGR,CAEN,GAAe,IADf2c,EAA2B,mBAAVve,KACQ6J,GAAc7J,GACtC,OAAOI,EAERke,EAAkBG,IAAsBF,CACxC,CACD,IAAMP,KAAKhe,EACFse,GAAuB,cAANN,IAAuBhV,GAAYhJ,EAAOge,IAClE5d,EAAI8E,KAAMnE,OAAQid,IAGpB,GAAKU,GAEJ,IADAL,ECnDF,SAAkBre,GACjB,IAAoB,IAAf2e,KAAyBZ,GAC7B,OAAOF,GAAwB7d,GAEhC,IACC,OAAO6d,GAAwB7d,EAC/B,CAAC,MAAQ4e,GACT,OAAO,CACP,CACF,CD0CoBf,CAAwB7d,GACpCG,EAAI,EAAGA,EAAI0e,GAAele,OAAQR,IACvCqe,EAAIK,GAAgB1e,GACZke,GAAyB,gBAANG,IAAyBxV,GAAYhJ,EAAOwe,IACtEpe,EAAI8E,KAAMnE,OAAQyd,IAIrB,OAAOpe,CACR,ELlCA,IOjCI0e,GPiCJC,GAAevJ,GQVXwJ,GAAMnf,OC9BNif,GAAWjf,OAAOof,eFSrBH,GADI1N,GAAYvR,OAAOof,gBACZ7Y,GGKZ,SAAyBC,GACxB,IAAI6Y,ECVL,SAAmB7Y,GAElB,OAAOA,EAAIM,SACZ,CDOamY,CAAUzY,GACtB,OAAK6Y,GAAmB,OAAVA,EACNA,EAEgC,sBAAnC9V,GAAa/C,EAAI2D,aAEd3D,EAAI2D,YAAYhJ,UAEnBqF,aAAexG,GACZA,GAAOmB,UAGR,IACR,EHXA,IAAAme,GAAeL,GKDf,SAASG,GAAgBjf,GACxB,OACCA,QAGO,MAGRA,EAAQH,GAAQG,GAET8e,GAAU9e,GAClB,CClBA,IAAIof,GAAkBvf,OAAOmB,UAyC7B,SAASqe,GAAerf,GACvB,IAAIkf,EAGJ,QAAMvQ,GAAU3O,OAIhBkf,EAAQD,GAAgBjf,MAOtBgJ,GAAYhJ,EAAO,gBAGpBgJ,GAAYkW,EAAO,gBACnB9N,GAAY8N,EAAMlV,cACmB,sBAArCZ,GAAa8V,EAAMlV,cAGnBhB,GAAYkW,EAAO,kBACnB9N,GAAY8N,EAAMI,iBAIjBJ,IAAUE,IAzDb,SAAmB/Y,GAClB,IAAIkZ,EAGJ,IAAMA,KAAOlZ,EACZ,IAAM2C,GAAY3C,EAAKkZ,GACtB,OAAO,EAGT,OAAO,CACR,CAkDGC,CAAUxf,IAGb,2ICtEA,SAASoc,KACR,OAAOnF,GAAOjS,OACf,6iCCVImX,GAAY,gBAmBhB,SAASC,KACR,IAAIC,EACAjc,EACAsI,EACJ,OAA0B,IAArBrE,UAAU1D,OACPsW,GAAOqF,IAAItX,SAEnB0D,GAAM,EACN2T,EAAOhY,UAAW,GACb8X,GAAU1N,KAAM4N,IAEN,SADdA,EAAOha,GAASga,EAAMF,GAAW,MACD,UAATE,IACtB3T,GAAM,GAIRtI,GADAA,EAAM6W,GAAQoF,IACEjc,EAAI4E,QAAU,GACzB0D,GAAOtI,EAAIO,OAAS,GACxBP,EAAI8E,KAAM,WAEJ9E,EACR,CC7BA,SAASqf,KAER,MAAO,CAENlU,KAAQ,EAGR1D,KAAQ,EACRG,MAAS,EACTC,OAAU,EACVL,MAAS,EACTG,OAAU,EACVJ,MAAS,EACTG,OAAU,EACV4X,MAAS,EACTC,OAAU,EAOVC,QAAW,GAEXlY,QAAW,GACXH,QAAW,GAIXsY,UAAa,GACbpX,UAAa,GACbD,WAAc,GAGdsX,OAAU,GAGV5X,QAAW,GAGX6X,OAAU,GAGVC,iBAAoB,IAEtB,CC1CAjZ,EAAAnH,GAAA,OAAA6f,ICSA,SAAiB7K,EAAQqL,GACxB,IAAIzK,EACAwI,EACA7d,EAGJ,IADAqV,EAAO0K,GAAYD,GACb9f,EAAI,EAAGA,EAAIqV,EAAK7U,OAAQR,IAE7B4G,EAAa6N,EADboJ,EAAIxI,EAAMrV,GACc8f,EAAQjC,GAGlC,CDnBAjE,CAAAna,GDFQ,CAEN2L,KAAQ,EAGR1D,KAAQ,EACRG,MAAS,EACTC,OAAU,EACVL,MAAS,EACTG,OAAU,EACVJ,MAAS,EACTG,OAAU,EACV4X,MAAS,EACTC,OAAU,EAOVC,QAAW,GAEXlY,QAAW,GACXH,QAAW,GAIXsY,UAAa,GACbpX,UAAa,GACbD,WAAc,GAGdsX,OAAU,GAGV5X,QAAW,GAGX6X,OAAU,GAGVC,iBAAoB,MGvDtB,IAAI3I,GHcI,CAEN9L,KAAQ,EAGR1D,KAAQ,EACRG,MAAS,EACTC,OAAU,EACVL,MAAS,EACTG,OAAU,EACVJ,MAAS,EACTG,OAAU,EACV4X,MAAS,EACTC,OAAU,EAOVC,QAAW,GAEXlY,QAAW,GACXH,QAAW,GAIXsY,UAAa,GACbpX,UAAa,GACbD,WAAc,GAGdsX,OAAU,GAGV5X,QAAW,GAGX6X,OAAU,GAGVC,iBAAoB,KGnCtB,SAASP,KAER,MAAO,CACNlU,KAAQ8L,GAAY,KAEpBxP,KAAQwP,GAAY,KACpBrP,MAASqP,GAAa,MACtBpP,OAAUoP,GAAc,OACxBzP,MAASyP,GAAa,MACtBtP,OAAUsP,GAAc,OACxB1P,MAAS0P,GAAa,MACtBvP,OAAUuP,GAAc,OACxBqI,MAASrI,GAAa,MACtBsI,OAAUtI,GAAc,OAExB3P,QAAW2P,GAAe,QAC1B9P,QAAW8P,GAAe,QAE1B5O,UAAa4O,GAAiB,UAC9B7O,WAAc6O,GAAkB,WAEhCyI,OAAUzI,GAAc,OAExBnP,QAAWmP,GAAe,QAE1B0I,OAAU1I,GAAc,OAExB2I,iBAAoB3I,GAAwB,iBAE9C,CC5BAtQ,EAAAnH,GAAA,OAAA6f,ICGA,SAAiB7K,EAAQqL,GACxB,IAAIzK,EACAwI,EACA7d,EAGJ,IADAqV,EAAO0K,GAAYD,GACb9f,EAAI,EAAGA,EAAIqV,EAAK7U,OAAQR,IAE7B4G,EAAa6N,EADboJ,EAAIxI,EAAMrV,GACc8f,EAAQjC,GAGlC,CDbAjE,CAAAna,GAAA6f,MErBA,IAAIU,GCyCJ,SAAiB9Z,EAAKgQ,GACrB,IACIb,EACA5L,EACA2V,EACA1I,EACAzW,EACAkJ,EACAnJ,EAPAigB,GAAa,EAQjB,IAAMvW,GAAcxD,GACnB,MAAM,IAAInC,UAAWiB,EAAQ,iFAAkFkB,IAEhH,GAAKhC,UAAU1D,OAAS,EAAI,CAC3B,IAAMgO,GAAU0H,GACf,MAAM,IAAInS,UAAWiB,EAAQ,qEAAsEkR,IAEpG,GAAKrN,GAAYqN,EAAM,gBAEhBpG,GADNmQ,EAAa/J,EAAKgK,YAEjB,MAAM,IAAInc,UAAWiB,EAAQ,+DAAgE,aAAcib,GAG7G,CAID,GAFAxW,GADA4L,EAAO0K,GAAY7Z,IACR1F,OACXP,EAAM,CAAA,EACDggB,EACJ,IAAMjgB,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAGf6I,GAAY5I,EADlByW,EAAMxQ,EADNkZ,EAAM/J,EAAMrV,MAMZmJ,EAAIlJ,EAAKyW,GACJxT,GAASiG,GACblJ,EAAKyW,GAAM3R,KAAMqa,GAEjBnf,EAAKyW,GAAQ,CAAEvN,EAAGiW,IAPlBnf,EAAKyW,GAAQ0I,OAWf,IAAMpf,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAErBC,EAAKiG,EADLkZ,EAAM/J,EAAMrV,KACQof,EAGtB,OAAOnf,CACR,CDzFWkgB,CAAeb,KAAe,CACxCY,YAAc,IEFXE,GAAOd,KCaX,SAASe,GAASnY,GACjB,IAAIoY,SAAapY,EACjB,MAAW,WAANoY,EAC2B,ODGjC,SAAmBpY,GAClB,IAAIiB,EAAIiX,GAAMlY,GACd,MAAsB,iBAANiB,EAAmBA,EAAI,IACxC,CCNWoX,CAAUrY,GAAqB,KAAOA,EAErC,WAANoY,EHKN,SAAmBpY,GAClB,IAAIiB,EAAI6W,GAAM9X,GACd,MAAsB,iBAANiB,EAAmBA,EAAI,IACxC,CGPSqX,CAAUtY,GAEX,IACR,KCnBIuY,wpDAsFJ,SAASC,GAAiBxY,GACzB,OAA0B,IAArBhE,UAAU1D,OA5EhB,WACC,IAAIyb,EACA0E,EACA1gB,EACAoU,EACAuM,EACAC,EACAvJ,EACAxT,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN0gB,GADA1E,EAAS8D,GAAYe,KACLtgB,OACVR,EAAI,EAAGA,EAAI2gB,EAAQ3gB,IAAM,CAI9B,IAHA4gB,EAAM3E,EAAQjc,GACdsX,EAAIwJ,GAAOF,GACXvM,EAAM,CAAA,EACAvQ,EAAI,EAAGA,EAAI6c,EAAQ7c,IAExBuQ,EADAwM,EAAM5E,EAAQnY,IACDwT,EAAGuJ,GAEjB5gB,EAAK2gB,GAAQvM,CACb,CACD,OAAOpU,CACR,CAoDS8gB,SAEO,IAAVN,KAEJA,GAhDF,WACC,IAAIxE,EACA0E,EACA1gB,EACAoU,EACAuM,EACAC,EACAvJ,EACAxT,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN0gB,GADA1E,EAAS8D,GAAYe,KACLtgB,OACVR,EAAI,EAAGA,EAAI2gB,EAAQ3gB,IAAM,CAI9B,IAHA4gB,EAAM3E,EAAQjc,GACdsX,EAAIwJ,GAAOF,GACXvM,EAAM,GACAvQ,EAAI,EAAGA,EAAI6c,EAAQ7c,IAEN,IAAbwT,EADLuJ,EAAM5E,EAAQnY,KAEbuQ,EAAItP,KAAM8b,GAGZ5gB,EAAK2gB,GAAQvM,CACb,CACD,OAAOpU,CACR,CAqBU+gB,IAET9Y,EAAQmY,GAASnY,GACZW,GAAY4X,GAAOvY,GAChBuY,GAAOvY,GAAQrD,QAEhB,KACR,CCtGA,IAAI4b,GAAQQ,KAmBZ,SAASC,GAAkBC,EAAMC,GAChC,OAAKD,IAASC,GAGLX,GAAOU,GAAQC,GAAO,CAChC,CCmBA,ICxCIX,GDwCAY,GAAoBrJ,GAAUiE,GAAQ,YEGtCqF,GAAiBtJ,GAAUiE,GAAQ,SCHnCsF,GAA8BvJ,GAAUiE,GAAQ,6qDF8CpD,SAASuF,GAAWtZ,GACnB,OAA0B,IAArBhE,UAAU1D,OA5EhB,WACC,IAAIyb,EACA0E,EACA1gB,EACAoU,EACAuM,EACAC,EACAvJ,EACAxT,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN0gB,GADA1E,EAAS8D,GAAY0B,KACLjhB,OACVR,EAAI,EAAGA,EAAI2gB,EAAQ3gB,IAAM,CAI9B,IAHA4gB,EAAM3E,EAAQjc,GACdsX,EAAImK,GAAYb,GAChBvM,EAAM,CAAA,EACAvQ,EAAI,EAAGA,EAAI6c,EAAQ7c,IAExBuQ,EADAwM,EAAM5E,EAAQnY,IACDwT,EAAGuJ,GAEjB5gB,EAAK2gB,GAAQvM,CACb,CACD,OAAOpU,CACR,CAoDS8gB,SAEO,IAAVN,KAEJA,GAhDF,WACC,IAAIxE,EACA0E,EACA1gB,EACAoU,EACAuM,EACAC,EACAvJ,EACAxT,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN0gB,GADA1E,EAAS8D,GAAY0B,KACLjhB,OACVR,EAAI,EAAGA,EAAI2gB,EAAQ3gB,IAAM,CAI9B,IAHA4gB,EAAM3E,EAAQjc,GACdsX,EAAImK,GAAYb,GAChBvM,EAAM,GACAvQ,EAAI,EAAGA,EAAI6c,EAAQ7c,IAEN,IAAbwT,EADLuJ,EAAM5E,EAAQnY,KAEbuQ,EAAItP,KAAM8b,GAGZ5gB,EAAK2gB,GAAQvM,CACb,CACD,OAAOpU,CACR,CAqBU+gB,IAET9Y,EAAQmY,GAASnY,GACZW,GAAY4X,GAAOvY,GAChBuY,GAAOvY,GAAQrD,QAEhB,KACR,CGtGA,IAAI4b,GAAQe,KAmBZ,SAASE,GAAYP,EAAMC,GAC1B,OAAKD,IAASC,GAGLX,GAAOU,GAAQC,GAAO,CAChC,KCrBIX,wpDAsFJ,SAASkB,GAAezZ,GACvB,OAA0B,IAArBhE,UAAU1D,OA5EhB,WACC,IAAIyb,EACA0E,EACA1gB,EACAoU,EACAuM,EACAC,EACAvJ,EACAxT,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN0gB,GADA1E,EAAS8D,GAAY6B,KACLphB,OACVR,EAAI,EAAGA,EAAI2gB,EAAQ3gB,IAAM,CAI9B,IAHA4gB,EAAM3E,EAAQjc,GACdsX,EAAIsK,GAAiBhB,GACrBvM,EAAM,CAAA,EACAvQ,EAAI,EAAGA,EAAI6c,EAAQ7c,IAExBuQ,EADAwM,EAAM5E,EAAQnY,IACDwT,EAAGuJ,GAEjB5gB,EAAK2gB,GAAQvM,CACb,CACD,OAAOpU,CACR,CAoDS8gB,SAEO,IAAVN,KAEJA,GAhDF,WACC,IAAIxE,EACA0E,EACA1gB,EACAoU,EACAuM,EACAC,EACAvJ,EACAxT,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN0gB,GADA1E,EAAS8D,GAAY6B,KACLphB,OACVR,EAAI,EAAGA,EAAI2gB,EAAQ3gB,IAAM,CAI9B,IAHA4gB,EAAM3E,EAAQjc,GACdsX,EAAIsK,GAAiBhB,GACrBvM,EAAM,GACAvQ,EAAI,EAAGA,EAAI6c,EAAQ7c,IAEN,IAAbwT,EADLuJ,EAAM5E,EAAQnY,KAEbuQ,EAAItP,KAAM8b,GAGZ5gB,EAAK2gB,GAAQvM,CACb,CACD,OAAOpU,CACR,CAqBU+gB,IAET9Y,EAAQmY,GAASnY,GACZW,GAAY4X,GAAOvY,GAChBuY,GAAOvY,GAAQrD,QAEhB,KACR,CCtGA,IAAI4b,GAAQkB,KC2CRE,GAA0B7J,GAAUiE,GAAQ,mBCA5C6F,GAA4B9J,GAAUiE,GAAQ,qBClClD8F,GAAA,CAAA,ECaA,SAASC,GAAKnT,EAAG+J,GAChB,OAAK/J,EAAI+J,EACD/J,EAED+J,CACR,CCLA,SAASqJ,GAAKpT,EAAG+J,GAChB,OAAK/J,EAAI+J,EACD/J,EAED+J,CACR,CCjBA,SAASsJ,GAAQriB,EAAO4J,GACvB,IAAIpC,EACArH,EAIJ,IADAqH,EAAM,GACArH,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBqH,EAAItC,KAAMlF,GAEX,OAAOwH,CACR,CCLA,SAAS8a,GAAUtiB,EAAOuiB,GACzB,IAAI/a,EACAgb,EACAC,EACAtiB,EAOJ,IALAqiB,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZ/a,EAAM,GACArH,EAAI,EAAGA,EAAIsiB,EAAItiB,IACpBqH,EAAItC,KAAMmd,GAAQriB,EAAOwiB,IAE1B,OAAOhb,CACR,CCpBA,SAASkb,GAASH,GACjB,OAAOD,GAAU,EAAKC,EACvB,CLOAxb,EAAAmb,GAAA,WAAA/J,IAUApR,EAAAmb,GAAA,wBxEgGA,SAA+BlT,EAAG+J,EAAGD,GACpC,IAAIpQ,EACAia,EACAC,EACAC,EACAC,EAEJ,OAAK9T,EAAErO,SAAWoY,EAAEpY,SAGpBgiB,EAAK9K,GAAkB7I,GACvB4T,EAAK/K,GAAkBkB,GAClB4J,EAAGrL,kBAAoBsL,EAAGtL,kBAC9B5O,EAAM,EAGDiO,GAAgB3H,GACf2H,GAAgBoC,GACbf,GAAU+K,GAAoB/T,EAAG,GAAK+T,GAAoBhK,EAAG,GAAKD,EAAQoC,IAE3E9D,GAAWuL,EAAIC,EAAI9J,EAAQgC,KAG9BxI,GAAmBtD,IACvB6T,EAAK3O,GAAgBlF,EAAG,GACxBtG,GAAO,GACI2J,GAAkBrD,KAC7B6T,EAAK5O,GAAejF,EAAG,GACvBtG,GAAO,GAEH4J,GAAmByG,IACvB+J,EAAK5O,GAAgB6E,EAAG,GACxBrQ,GAAO,GACI2J,GAAkB0G,KAC7B+J,EAAK7O,GAAe8E,EAAG,GACvBrQ,GAAO,GAEK,IAARA,EAE0B,IAAzBma,EAAGzQ,mBAAoD,IAAzB0Q,EAAG1Q,kBAC9B4F,GAAU6K,EAAIC,EAAIhK,EAAQoC,IAE3BlD,GAAU6K,EAAIC,EAAIhK,EAAQ0C,IAE3BpE,GAAWuL,EAAIC,EAAI9J,EAAQgC,MAGN,IAAxB9L,EAAEoD,mBAAmD,IAAxB2G,EAAE3G,kBAC5B4F,GAAUhJ,EAAG+J,EAAGD,EAAQ0C,IAEzBxD,GAAUhJ,EAAG+J,EAAGD,EAAQgC,IAChC,IwEzIA/T,EAAAmb,GAAA,kBvEwEA,SAAyBlT,EAAG+J,GAC3B,IAAIrQ,EACAia,EACAC,EACAC,EACAC,EAEJ,OAAK9T,EAAErO,SAAWoY,EAAEpY,SAGpBgiB,EAAK9K,GAAkB7I,GACvB4T,EAAK/K,GAAkBkB,GAClB4J,EAAGrL,kBAAoBsL,EAAGtL,kBAC9B5O,EAAM,EAGDiO,GAAgB3H,GACf2H,GAAgBoC,GACbf,GAAU+K,GAAoB/T,EAAG,GAAK+T,GAAoBhK,EAAG,IAE9D3B,GAAWuL,EAAIC,IAGlBtQ,GAAmBtD,IACvB6T,EAAK3O,GAAgBlF,EAAG,GACxBtG,GAAO,GACI2J,GAAkBrD,KAC7B6T,EAAK5O,GAAejF,EAAG,GACvBtG,GAAO,GAEH4J,GAAmByG,IACvB+J,EAAK5O,GAAgB6E,EAAG,GACxBrQ,GAAO,GACI2J,GAAkB0G,KAC7B+J,EAAK7O,GAAe8E,EAAG,GACvBrQ,GAAO,GAEK,IAARA,EACGsP,GAAU6K,EAAIC,GAEf1L,GAAWuL,EAAIC,KAEhB5K,GAAUhJ,EAAG+J,GACrB,IuEzGAhS,EAAAmb,GAAA,yBMjCA,SAAgClT,EAAG+J,GAClC,IAAI5Y,EACJ,GAAK6O,EAAErO,SAAWoY,EAAEpY,OACnB,OAAO,EAER,IAAMR,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1B,GAAK6O,EAAG7O,KAAQ4Y,EAAG5Y,GAClB,OAAO,EAGT,OAAO,CACR,INgCA4G,EAAAmb,GAAA,iBnEqDA,SAAwBlT,EAAG+J,GAC1B,IAAIrQ,EACAia,EACAC,EACAC,EACAC,EAEJ,OAAK9T,EAAErO,SAAWoY,EAAEpY,SAGpBgiB,EAAK9K,GAAkB7I,GACvB4T,EAAK/K,GAAkBkB,GAClB4J,EAAGrL,kBAAoBsL,EAAGtL,kBAC9B5O,EAAM,EAGDiO,GAAgB3H,GACf2H,GAAgBoC,GACbf,GAAU+K,GAAoB/T,EAAG,GAAK+T,GAAoBhK,EAAG,IAE9D3B,GAAWuL,EAAIC,IAGlBtQ,GAAmBtD,IACvB6T,EAAK3O,GAAgBlF,EAAG,GACxBtG,GAAO,GACI2J,GAAkBrD,KAC7B6T,EAAK5O,GAAejF,EAAG,GACvBtG,GAAO,GAEH4J,GAAmByG,IACvB+J,EAAK5O,GAAgB6E,EAAG,GACxBrQ,GAAO,GACI2J,GAAkB0G,KAC7B+J,EAAK7O,GAAe8E,EAAG,GACvBrQ,GAAO,GAEK,IAARA,EACGsP,GAAU6K,EAAIC,GAEf1L,GAAWuL,EAAIC,KAEhB5K,GAAUhJ,EAAG+J,GACrB,ImEtFAhS,EAAAmb,GAAA,kBAAA7a,GAUAN,EAAAmb,GAAA,oBAAA3F,IAUAxV,EAAAmb,GAAA,iBAAAvL,IAUA5P,EAAAmb,GAAA,cAAAxF,IAUA3V,EAAAmb,GAAA,iCAAAtF,IAUA7V,EAAAmb,GAAA,sBAAAnF,IAUAhW,EAAAmb,GAAA,mBAAA7P,IAUAtL,EAAAmb,GAAA,oBAAA5P,IAUAvL,EAAAmb,GAAA,aAAAlF,IAUAjW,EAAAmb,GAAA,0BAAAjF,IAUAlW,EAAAmb,GAAA,oBAAAhF,IAUAnW,EAAAmb,GAAA,2BAAAc,IAUAjc,EAAAmb,GAAA,oBAAAV,IAUAza,EAAAmb,GAAA,iBAAAT,IAUA1a,EAAAmb,GAAA,8BAAAR,IAUA3a,EAAAmb,GAAA,qBAAAe,IAUAlc,EAAAmb,GAAA,0BHlNA,SAAyBZ,EAAMC,GAC9B,OAAKD,IAASC,GAGLX,GAAOU,GAAQC,GAAO,CAChC,IGuNAxa,EAAAmb,GAAA,0BAAAF,IAUAjb,EAAAmb,GAAA,qBOxNA,SAA4BlT,GAC3B,IAAIpF,EACAhD,EACAyQ,EACA6L,EACAC,EACAhjB,EAeJ,GAZAkX,EAAKhP,GAAO2G,GAIXpI,EADIS,EAAiB2H,GACf0F,EAAgB2C,GAEhBjP,EAAQiP,GAMF,KAHbzN,EAAMoF,EAAErO,QAIP,OAAO,EAIR,IADAuiB,EAAKtc,EAAKoI,EAAG,GACP7O,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,GAAK+iB,GADLC,EAAKvc,EAAKoI,EAAG7O,IAEZ,OAAO,EAER+iB,EAAKC,CACL,CACD,OAAO,CACR,IPgMApc,EAAAmb,GAAA,4BAAAD,IQ1PA,IAAAC,GAAA,CAAA,ECDA,SAASkB,GAASpU,EAAG+J,EAAGpG,EAAG0Q,EAAOd,EAAOe,EAAKpO,GAC7C,IAAIqO,EACAC,EACArjB,EAOJ,GALAojB,EAAIhB,EAAOe,IAGXE,EAAIF,EAAM,KAECD,EAQX,IAAMljB,EAAI,EAAGA,EAAIojB,EAAGpjB,IACnBijB,GAASpU,EAAG7O,GAAK4Y,EAAG5Y,GAAKwS,EAAGxS,GAAKkjB,EAAOd,EAAOiB,EAAGtO,QAPlD,IAAM/U,EAAI,EAAGA,EAAIojB,EAAGpjB,IACnBwS,EAAGxS,GAAM+U,EAAKlG,EAAG7O,GAAK4Y,EAAG5Y,GAQ5B,CCxBA,SAASsjB,GAAMzU,GACd,IAAI5O,EACAwJ,EACAzJ,EAIJ,IAFAyJ,EAAMoF,EAAErO,OACRP,EAAM,GACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBC,EAAI8E,KAAM8J,EAAG7O,IAEd,OAAOC,CACR,CCNA,SAASH,GAAO2J,GACf,OAAOyY,GAAQ,EAAKzY,EACrB,CC8CA,SAAS8Z,GAAgB1U,EAAG2U,EAASC,GACpC,IAAI9L,EACAwL,EACAO,EACAhO,EACAiO,EACAN,EACArjB,EACA8D,EAIJ,IAFA4R,EAAI+N,EAASjjB,SACbmjB,EAAIH,EAAQhjB,QAEX,MAAM,IAAIgB,MAAO,gKAIlB,IADAmW,EAAO9I,EACD7O,EAAI2jB,EAAG3jB,EAAI0V,EAAG1V,IACnB2X,EAAO,CAAEA,GAOV,IAHA+L,EAAK5jB,GAAO4V,GAGN1V,EAAI0V,EAAE,EAAG1V,GAAK,EAAGA,IAEtB,MADA8D,EAAI6f,EAAIjO,EAAI1V,GACH,GAAT,CAMA,GAFAqjB,EAAIG,EAAS1f,GAEA,KADbqf,EAAMM,EAAUzjB,KACEmjB,EAAME,EACvB,MAAM,IAAI7hB,MAAOwD,EAAQ,8PAA+Pse,GAAME,GAAUpO,KAAM,MAAQkO,GAAMG,GAAWrO,KAAM,MAAQpV,IAEtV,GAAKqjB,IAAMF,EAEVO,EAAI1jB,GAAM,MACJ,IAAW,IAANqjB,EAKX,MAAM,IAAI7hB,MAAOwD,EAAQ,2IAA4Ise,GAAME,GAAUpO,KAAM,MAAQkO,GAAMG,GAAWrO,KAAM,MAAQpV,IAHlO0jB,EAAI1jB,GAAM,CAIV,CAfA,CAkBF,MAAO,CACN4jB,IAAO/U,EACP8I,KAAQA,EACRyK,MAASkB,GAAMG,GACfI,QAAWH,EAEb,CC1FA,SAASI,GAAOjV,GAEf,OACQmD,GADHnD,EAAI,EACOA,EAAE,EAEHA,EAAE,EAClB,CCLA,SAASkV,GAAYlV,GACpB,OAAQA,IAAM/C,IAAQ+C,IAAMC,EAC7B,CNNAlI,EAAAmb,GAAA,cOmCA,SAAqBK,EAAO4B,EAAIC,EAAIC,EAAM9P,EAAMD,GAC/C,IAAI9M,EACA8c,EACA9B,EACAC,EACA8B,EACAC,EAOJ,IALA/B,EAAKF,EAAO,GACZC,EAAKD,EAAO,GAGZ/a,EAAM,GACAgd,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAE7B,IADAF,EAAK,GACCC,EAAK,EAAGA,EAAK/B,EAAI+B,IAGnBA,GAAMC,GAAMD,GAAMC,EAAGL,GACrBI,GAAMC,GAAMA,GAAMD,EAAGH,EAEvBE,EAAGpf,KAAMqP,EAAKtS,KAAMqS,EAAS,CAAEkQ,EAAID,KAInCD,EAAGpf,KAAMmf,GAGX7c,EAAItC,KAAMof,EACV,CACD,OAAO9c,CACR,IPxDAT,EAAAmb,GAAA,aQEA,SAAoB1a,EAAK2c,EAAIC,EAAIK,GAChC,IAAIrkB,EACAmhB,EACAuC,EACAjO,EACA1V,EACA8D,EACA+Z,EAMJ,GAJA8F,EAAItc,EAAI7G,OACRkV,EAAIrO,EAAK,GAAI7G,OAGR8jB,EAAkB,CAEtB,IADArkB,EAAMsiB,GAAS,CAAE7M,EAAGsO,EAAGC,EAAG,IACpBngB,EAAI,EAAGA,EAAI4R,EAAG5R,IAGnB,IAFAsd,EAAKnhB,EAAK6D,GACV+Z,EAAImG,EAAKlgB,EACH9D,EAAIgiB,GAAK,EAAGle,EAAEkgB,GAAMhkB,EAAIiiB,GAAK0B,EAAG7f,EAAEmgB,EAAG,GAAKjkB,IAC/CohB,EAAIvD,EAAE7d,GAAMqH,EAAKrH,GAAK8D,GAGxB,OAAO7D,CACP,CAGD,IADAA,EAAMsiB,GAAS,CAAEyB,EAAGC,EAAG,EAAGvO,IACpB5R,EAAI,EAAGA,EAAI4R,EAAG5R,IAEnB,IADA+Z,EAAImG,EAAKlgB,EACH9D,EAAIgiB,GAAK,EAAGle,EAAEkgB,GAAMhkB,EAAIiiB,GAAK0B,EAAG7f,EAAEmgB,EAAG,GAAKjkB,IAC/CC,EAAK4d,EAAE7d,GAAK8D,GAAMuD,EAAKrH,GAAK8D,GAG9B,OAAO7D,CACR,IC9CA,IAAIskB,GAAOtiB,KAAKsiB,KCRhBC,IATwB,IAAnBlL,GACE,EAEA,ECFHE,GAAe,IAAIjP,GAAc,GACjC8N,GAAc,IAAIzN,GAAa4O,GAAa7G,QAwEhD,SAAS8R,GAAY5V,EAAG6V,GAGvB,OAFAlL,GAAc,GAAM3K,EACpBwJ,GAAae,IAAUsL,IAAQ,EACxBlL,GAAc,EACtB,CCpEA,SAASmL,GAAe9V,GAEvB,OAAS,EAAFA,CACR,CCSA,ICtBIsK,GACAC,GDqBAwL,GAA6B,WEbjCC,IATwB,IAAnBvL,GACG,EAEA,ECFJE,GAAe,IAAIjP,GAAc,GACjC8N,GAAc,IAAIzN,GAAa4O,GAAa7G,QAoDhD,SAASmS,GAAajW,GAErB,OADA2K,GAAc,GAAM3K,EACbwJ,GAAac,GACrB,EFtDwB,IAAnBG,IACJH,GAAO,EACPC,GAAM,IAEND,GAAO,EACPC,GAAM,GAUP,IAAA2L,GARU,CACT5L,KAAQA,GACRC,IAAOA,IGXJI,GAAe,IAAIjP,GAAc,GACjC8N,GAAc,IAAIzN,GAAa4O,GAAa7G,QAE5CwG,GAAOM,GAAQN,KACfC,GAAMK,GAAQL,IA6ElB,SAAS4L,GAAWC,EAAMP,GAGzB,OAFArM,GAAac,IAAS8L,EACtB5M,GAAae,IAAQsL,EACdlL,GAAc,EACtB,CClFA,IAAI0L,GAAQ,CAAE,EAAG,GAgCjB,SAASC,GAAUtW,EAAG+J,GACrB,IAAIwM,EACAC,EAmBJ,OAhBA3L,GAAQE,OAAQ/K,EAAGqW,GAAO,EAAG,GAC7BE,EAAKF,GAAO,GAGZE,GAAME,GAGND,EAAKP,GAAalM,GASXoM,GAHPI,GAHAC,GAAM5M,GAMgByM,GAAO,GAC9B,CC3CA,IAAIK,GAAsB,WAEtBC,GAAO,MACPC,GAAO,OCTXC,IATwB,IAAnBpM,GACG,EAEA,ECFJE,GAAe,IAAIjP,GAAc,GACjC8N,GAAc,IAAIzN,GAAa4O,GAAa7G,QAgEhD,SAASgT,GAAa9W,EAAGoW,GAGxB,OAFAzL,GAAc,GAAM3K,EACpBwJ,GAAac,IAAW8L,IAAS,EAC1BzL,GAAc,EACtB,CC9CA,IAAIoM,GAAwB,KCXxBC,GAAyC,GCMzCC,GAAwB,QAGxBC,GAAsB,QAGtBC,GAAoB,WAGpBC,GAA0B,UAG1BC,GAAwB,OAExBC,GAAQ,iBAGRC,GAAK,kBAGLC,GAAQ,kBAGRC,IAAS,qBAETC,GAAK,CACR,EACA,KAEGC,GAAQ,CACX,EACA,mBAEGC,GAAQ,CACX,EACA,sBCvCGC,GAAU,mBAGVC,GAAa,mBAGbC,GAAa,sBCDbC,GAA6B,KCA7BC,IAAuC,KCAvCC,IAAuC,KCQvCC,GAA0B,uBCzB1BC,GAAS,iBA8Cb,SAASC,GAAWrY,EAAG5O,EAAK0Z,EAAQjH,GACnC,OAAKtP,GAAOyL,IAAOkV,GAAYlV,IAC9B5O,EAAKyS,GAAW7D,EAChB5O,EAAKyS,EAASiH,GAAW,EAClB1Z,GAEG,IAAN4O,GAAa7M,GAAK6M,GAAMmY,IAC5B/mB,EAAKyS,GAAW7D,EAAIoY,GACpBhnB,EAAKyS,EAASiH,IAAY,GACnB1Z,IAERA,EAAKyS,GAAW7D,EAChB5O,EAAKyS,EAASiH,GAAW,EAClB1Z,EACR,CC/BA2G,GCKA,SAAoBiI,GACnB,OAAOkG,GAAKlG,EAAG,CAAE,EAAK,GAAK,EAAG,EAC/B,GDPA,SAAA+K,IEVA,IAAIuN,GAAkC,WCHlCC,GAAY,qBAGZC,GAAiB,WAGjBC,GAAO,CAAE,EAAK,GAGdpC,GAAQ,CAAE,EAAG,GAwCjB,SAASqC,GAAOC,EAAMC,GACrB,IAAIxC,EACAyC,EACJ,OACS,IAARD,GACS,IAATD,GACApkB,GAAOokB,IACPzD,GAAYyD,GAELA,GAGRN,GAAWM,EAAMF,GAAM,EAAG,GAC1BE,EAAOF,GAAM,GACbG,GAAOH,GAAM,GAGbG,GC9DD,SAAmB5Y,GAElB,IAAIoW,EAAOH,GAAajW,GAMxB,OAHAoW,GAASA,EAAO0C,MAAe,IAGhBC,GAAM,CACtB,CDqDQC,CAAUL,GAGZC,EAAMK,GACH3C,GAAU,EAAKqC,GAElBC,EAAMM,GACLP,EAAO,EACJ1Y,GAEDhD,IAGH2b,GAAOO,IACXP,GAAO,GACPC,EAAIN,IAEJM,EAAI,EAGLhO,GAAQE,OAAQ4N,EAAMtC,GAAO,EAAG,GAChCD,EAAOC,GAAO,GAGdD,GAAQoC,GAMDK,EAAI1C,GAHXC,GAAUwC,EAAIG,IAAS,GAGK1C,GAAO,KACpC,CEnGA,IAAI+C,GAAM,kBCKNC,GAAqC,QCErCnC,GAAsB,QAGtBoC,GAAwB,WAGxBC,GAAS,kBAGTC,IAAU,qBCFV9C,GAAsB,WAGtB+C,GAAqB,WAGrBC,GAAqB,WAGrBC,GAAqB,WAGrBxC,GAAoB,WAGpByC,GAAY,WAGZC,GAAgB,WAEhBC,GAAwB,GAExBnD,GAAO,MACPC,GAAO,OAGPmD,GAAM,qBAGN1D,GAAQ,CAAE,EAAK,GAGf2D,GAAgB,CAAE,EAAK,GAwG3B,SAASC,GAAKja,EAAG+J,GAChB,IAAImQ,EACAC,EACAC,EACA7D,EAEAC,EAEA6D,EACAC,EACAC,EACAC,EACAC,EACAhJ,EACA9N,EACA1O,EACA9D,EACJ,GAAKoD,GAAOyL,IAAOzL,GAAOwV,GACzB,OAAOtN,IAQR,GALAoO,GAAQE,OAAQhB,EAAGsM,GAAO,EAAG,GAC7BG,EAAKH,GAAO,GAIA,IAHPA,GAAO,GAGI,CACf,GAAW,IAANtM,EACJ,OAAO,EAER,GAAW,IAANA,EACJ,OAAO/J,EAER,IAAY,IAAP+J,EACJ,OAAO,EAAM/J,EAEd,GAAW,KAAN+J,EACJ,OAAO2L,GAAM1V,GAEd,IAAY,KAAP+J,EACJ,OAAO,EAAM2L,GAAM1V,GAEpB,GAAW,IAAN+J,EACJ,OAAO/J,EAAIA,EAEZ,GAAW,IAAN+J,EACJ,OAAO/J,EAAIA,EAAIA,EAEhB,GAAW,IAAN+J,EAEJ,OADA/J,GAAKA,GACMA,EAEZ,GAAKkV,GAAYnL,GAChB,OCpLH,SAAc/J,EAAG+J,GAChB,OAAY,IAAP/J,GAEIA,EAAEA,IAAIA,EAAEA,GAEN,IAANA,EACG,EAGF7M,GAAI6M,GAAK,IAAU+J,IAAM9M,IACvB,EAGDA,EACR,CDsKUyd,CAAa1a,EAAG+J,EAExB,CAOD,GALAc,GAAQE,OAAQ/K,EAAGqW,GAAO,EAAG,GAC7BE,EAAKF,GAAO,GAIA,IAHPA,GAAO,GAGI,CACf,GAAY,IAAPE,EACJ,OEvLH,SAAcvW,EAAG+J,GAChB,OAAKA,IAAM9J,GACHhD,GAEH8M,IAAM9M,GACH,EAEH8M,EAAI,EACHkL,GAAOlL,GACJ/J,EAED,EAGHiV,GAAOlL,GACJuM,GAAUrZ,GAAM+C,GAEjB/C,EACR,CFqKU0d,CAAS3a,EAAG+J,GAEpB,GAAW,IAAN/J,EACJ,OAAO,EAER,IACQ,IAAPA,GACAiV,GAAOlL,GAEP,OAAQ,EAET,GAAKmL,GAAYlV,GAChB,OAAKA,IAAMC,GAEHga,IAAM,GAAMlQ,GAEfA,EAAI,EACD,EAED9M,EAER,CACD,GACC+C,EAAI,IACe,IAAnBD,GAAWgK,GAGX,OAAQ/J,EAAEA,IAAIA,EAAEA,GAqBjB,GAnBAoa,EAAKjnB,GAAK6M,GAGVka,EAAO3D,EAAKE,GAAU,EACtB0D,EAAO3D,EAAKC,GAAU,EAItB6D,EAAM9D,IAAOsD,GAAuB,EAInCO,GALDA,EAAM9D,IAAOuD,GAAuB,IAIzB7E,GAAOlL,IACX,EAED,EAKDoQ,EAAMV,GAAqB,CAE/B,GAAKU,EAAMT,GACV,OpBnPH,SAAc1Z,EAAG+J,GAOhB,OAHKkM,GAAajW,GACNyW,KAEAC,GACN3M,EAAI,EAED4M,GAAOA,GAGRC,GAAOA,GAIV7M,EAAI,EAED4M,GAAOA,GAGRC,GAAOA,EACf,CoB4NUgE,CAAS5a,EAAG+J,GAIpB,GAAKmQ,EAAMxD,GAEV,OAAY,IAAP4D,EAEGD,EAAK1D,GAAOA,GAGb0D,EAAKzD,GAAOA,GAEpB,GAAKsD,EAAM/C,GAEV,OAAY,IAAPmD,EAEGD,EAAK1D,GAAOA,GAGb0D,EAAKzD,GAAOA,GAGpBnF,Ed3QF,SAAergB,EAAKgpB,GACnB,IAAIS,EACAC,EACArJ,EACA3C,EACAiM,EACAzgB,EiBpCc0F,EjBgDlB,OATA8O,GADA2C,EAAI2I,EAAK,GACD3I,GiBtCG,KADOzR,EjBuCIyR,GiBrCd,GAED,GAAOzR,GAAgC,IAAJA,EAAtB,oBjBwCpB6a,GAHAvgB,EAAMmX,EAAEsG,GAAiBjJ,EAAE+I,MAE3BiD,EAAKlF,GADLkF,GAFAC,EAAIjD,GAAarG,GAERnX,EACY,IACNygB,GAEf3pB,EAAK,GAAM0pB,EACX1pB,EAAK,GAAMypB,EACJzpB,CACR,CcwPM4pB,CAAMhB,GAAeI,EACzB,MAGA3I,Ef5OF,SAAiBrgB,EAAKgpB,EAAIF,GACzB,IAAI1U,EACAyV,EACAC,EACAC,EACAC,EACAC,EAEAC,EACAC,EACAf,EAEAgB,EACAC,EACAX,EACAD,EACApJ,EACAiK,EACAX,EACAzgB,EACApJ,EACA+D,EACA+Z,EmBvFchP,EnByKlB,OAhFA9O,EAAI,EAGCgpB,EAAMhD,KAEVhmB,GAAK,GACLgpB,EAAMjE,GAFNmE,GAAM9C,KAKPpmB,IAAOgpB,GAAOyB,IAA6B5C,GAAM,EAMjDmB,GAHAjlB,EAAKilB,EAAMjD,GAAuB,GAGvBE,GAAmB,EAKzBliB,GAAK,OACT+Z,EAAI,EAGK/Z,EAAI,OACb+Z,EAAI,GAIJA,EAAI,EACJ9d,GAAK,EACLgpB,GAAOhD,IAURiE,EAAKvF,GADLqF,GAFAF,GAJAX,EAAKtD,GAAasD,EAAIF,KAGtBoB,EAAK5D,GAAI1I,MAET1U,EAAI,GAAO8f,EAAKkB,IAEK,GAGrB9V,GAAQ0U,GAAK,EAAK9C,IAA2BC,GAE7CgE,EAAKvE,GAAa,EADlBtR,GAAQwJ,GAAK,IAQb0M,GADAR,EAAKD,EAAKA,GACDC,GmB7IE,KADOlb,EnB8IMkb,GmB5IhB,kBAED,kBAAsBlb,GAAK,kBAAsBA,GAAK,mBAAuBA,GAAK,iBAAqBA,GAAK,mBAA2B,mBAAJA,OnB8I1Iqb,EAAKzF,GADLyF,EAAK,GADLH,EAAKC,EAAKA,IADVO,IANAN,EAAK9gB,GAAQygB,EAAKI,EAAGE,EAAUF,GAD1Bf,GAAMiB,EAAKC,OAOLH,EAAKF,IAGK,GASrBT,EAAK5E,GADL4E,GAJAO,EAAII,EAAKE,IACT/gB,EAAM8gB,EAAGC,GAJJK,GAAML,EAAG,EAAOH,IAIAD,GAIA,GAErBO,EAAKhE,GAAQgD,EAQbK,GAPAY,EAAOhE,GAAM+C,GAFRlgB,GAAKkgB,EAAKO,IAEUxD,GAAOK,GAAO5I,MAMvC8L,EAAKlF,GADLkF,EAAOU,EAAGC,GAFVF,EAAK5D,GAAO3I,KACZyC,EAAIvgB,GAEiB,IACLugB,EAAK8J,EAAMC,GAE3BpqB,EAAK,GAAM0pB,EACX1pB,EAAK,GAAMypB,EACJzpB,CACR,CemIMwqB,CAAQ5B,GAAeI,EAAIF,GAchC,GARAvW,GAFA8W,GAAQ1Q,GADRwQ,EAAK3E,GAAY7L,EAAG,KACN0H,EAAE,GAAS1H,EAAE0H,EAAE,KAC7B+I,EAAKD,EAAK9I,EAAE,IAIZ5G,GAAQE,OAAQpH,EAAG0S,GAAO,EAAG,GAC7BphB,EAAI6gB,GAAeO,GAAM,IACzBllB,EAAI2kB,GAAeO,GAAM,IAGpBphB,GAAK0kB,GAAqB,CAE9B,GAAoC,IAA7B1kB,EAAE0kB,GAAoBxoB,GAE5B,OAAOkpB,EAAK1D,GAAOA,GAEpB,GAAM8D,EAAGV,GAAQpW,EAAE6W,EAElB,OAAOH,EAAK1D,GAAOA,EAEpB,MAEI,IAAM1hB,EAAEwhB,KAAamD,GAAY,CAErC,GAA+B,IAAxB3kB,EAAE4kB,GAAe1oB,GAEvB,OAAOkpB,EAAKzD,GAAOA,GAEpB,GAAK6D,GAAO9W,EAAE6W,EAEb,OAAOH,EAAKzD,GAAOA,EAEpB,CAID,OAFAjT,EDxSD,SAAe1O,EAAGulB,EAAIC,GACrB,IACIK,EACArJ,EAEAsJ,EACAzgB,EACAwU,EACAnL,EACAzS,EACAC,EACA6d,EMtDchP,EN4FlB,OAnCAgP,IADA7d,EAAK8D,EAAIwhB,GAAU,IACVkF,IAA6B5C,GAAM,EAC5C7nB,EAAI,EAGCC,EAAImoB,KAIR7H,EAAIqF,GAAa,IAHjB5lB,EAAK+D,GAAKiiB,IAAsBlI,EAAE,KAAO,KAE3BiI,KADdjI,IAAO9d,EAAIulB,KAAWkF,IAA6B5C,GAAM,OACX,GAE9C7nB,GAAOA,EAAI+lB,GAAuBC,KAAyByE,GAA0B3M,IAAM,EACtF/Z,EAAI,IACR/D,GAAKA,GAENspB,GAAM/I,GAaPxc,EAAI6gB,GADJ7gB,EAAIghB,GADJtS,EAAI,IALJA,GAFAoX,GADAtJ,EAAImE,GADJnE,EAAIgJ,EAAKD,EACU,IACXjB,KACRjf,GAAOmgB,GAAMhJ,EAAE+I,IAAKpB,GAAU3H,EAAE+H,MAIhCsB,EAAKnX,GADL8N,EAAI9N,EAAIA,IM7EG,KADO3D,EN+EKyR,GM7Ef,mBAED,mBAAuBzR,GAA+BA,GAAK,qBAA0BA,GAAsC,sBAAJA,EAA5B,wBAA9D,yBN4EpB8a,EAAG,KAHnBhM,EAAIxU,GAAKqJ,EAAIoX,IAGsBpX,EAAEmL,GACtBnL,MAGf1O,GAAM/D,GAAKyqB,KAA6B,IAG/BA,IAA8B,EAClCjD,GAAO/U,EAAGzS,GAEV4lB,GAAanT,EAAG1O,EAGtB,CCsPK4mB,CAAM5mB,EAAGulB,EAAIC,GAEVJ,EAAK1W,CACb,CMxUA,SAASmY,GAAgB9b,EAAG9O,GAC3B,IAAI0G,EACAxG,EACAoU,EACA/M,EACAmC,EACAiM,EACAkV,EACA5qB,EACA8D,EACA+Z,EAGJ,IADAnI,EAAI7G,EAAErO,SACI,GAAKT,GAAK,EACnB,MAAO,GAUR,IAPA0G,EAAMqR,GAAejJ,GAGrBpF,EAAMqf,GAAKpT,EAAG3V,GAGduH,EAAM,GACAtH,EAAI,EAAGA,EAAID,EAAGC,IACnBsH,EAAIvC,KAAM,GAIX,IADA9E,EAAM,GACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAG3B,IADA6d,EAAI7d,EACE8D,EAAI/D,EAAE,EAAG+D,GAAK,EAAGA,IAEtB+Z,GADA+M,EAAI/M,EAAInI,EAERmI,GAAKnI,EACLpO,EAAKxD,GAAM8mB,EAIZ,IADAvW,EAAM,GACAvQ,EAAI,EAAGA,EAAI/D,EAAG+D,IACnBuQ,EAAItP,KAAM0B,EAAKoI,EAAGvH,EAAKxD,KAExB7D,EAAI8E,KAAMsP,EACV,CACD,OAAOpU,CACR,CCvDA,SAAS4qB,GAAkBC,EAAIC,GAC9B,IAAIC,EACAC,EACAhrB,EACA0jB,EACAjO,EACAvM,EACAnJ,EACA8D,EAQJ,IANAknB,EAAOlT,GAAegT,GACtBG,EAAOnT,GAAeiT,GAEtBpH,EAAImH,EAAGtqB,OACPkV,EAAIqV,EAAGvqB,OACPP,EAAM,GACAD,EAAI,EAAGA,EAAI2jB,EAAG3jB,IAEnB,IADAmJ,EAAI6hB,EAAMF,EAAI9qB,GACR8D,EAAI,EAAGA,EAAI4R,EAAG5R,IACnB7D,EAAI8E,KAAM,CAAEoE,EAAG8hB,EAAMF,EAAIjnB,KAG3B,OAAO7D,CACR,CCzBA,SAASirB,GAAiBrc,GACzB,IAAIpI,EACAxG,EACAyV,EACAvM,EACAnJ,EACA8D,EAKJ,IAHA2C,EAAMqR,GAAejJ,GACrB6G,EAAI7G,EAAErO,OACNP,EAAM,GACAD,EAAI,EAAGA,EAAI0V,EAAG1V,IAEnB,IADAmJ,EAAI1C,EAAKoI,EAAG7O,GACN8D,EAAI,EAAGA,EAAI4R,EAAG5R,IACnB7D,EAAI8E,KAAM,CAAEoE,EAAG1C,EAAKoI,EAAG/K,KAGzB,OAAO7D,CACR,CCpBA,SAASqjB,GAAMzU,GACd,IAAI5O,EACAwJ,EACAhD,EACAzG,EAUJ,IAPAyG,EAAMqR,GAAejJ,GAGrBpF,EAAMoF,EAAErO,OAGRP,EAAM,GACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBC,EAAI8E,KAAM0B,EAAKoI,EAAG7O,IAEnB,OAAOC,CACR,CCjCA,IAAIgS,GAAoB,GAoBxB,SAASE,GAAmBtS,GAE3B,MACkB,iBAAVA,GACG,OAAVA,GAC2B,oBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMoS,oBAAsBA,EAE9B,CC5BA,IAAIA,GAAoB,EAoBxB,SAASC,GAAkBrS,GAE1B,MACkB,iBAAVA,GACG,OAAVA,GAC2B,mBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMoS,oBAAsBA,EAE9B,CCWA,SAASQ,GAAa5D,EAAG6D,GACxB,GAAKP,GAAmBtD,GACvB,OAAOkF,GAAgBlF,EAAG6D,GAE3B,GAAKR,GAAkBrD,GACtB,OAAOiF,GAAejF,EAAG6D,GAG1B,MAAM,IAAI3O,UAAWiB,EAAQ,+FAAgG6J,GAC9H,CCzBA,SAASsc,GAAStc,GACjB,IAAI9O,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACpB6O,EAAG7O,KACRD,GAAK,GAGP,OAAOA,CACR,CA+EA,SAASqrB,GAAYvc,GACpB,OAAK3H,EAAiB2H,GAChB2H,GAAgB3H,GACbsc,GAASvI,GAAoB/T,EAAG,IAEnC+N,GAAqB/N,GApC5B,SAAkBA,GACjB,IAAIwc,EACAtrB,EACAC,EAKJ,IAHAqrB,EAAOC,GAAoBzc,EAAG,GAE9B9O,EAAI,EACEC,EAAI,EAAGA,EAAIqrB,EAAK7qB,OAAQR,GAAK,EACf,IAAdqrB,EAAMrrB,IAA+B,IAAhBqrB,EAAMrrB,EAAE,KACjCD,GAAK,GAGP,OAAOA,CACR,CAuBUwrB,CAAS1c,GApEnB,SAAoBA,GACnB,IAAIpI,EACA1G,EACAC,EAKJ,IAHAyG,EAAMqR,GAAejJ,GAErB9O,EAAI,EACEC,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACpByG,EAAKoI,EAAG7O,KACbD,GAAK,GAGP,OAAOA,CACR,CAwDSkX,CAAWpI,GAEZsc,GAAStc,EACjB,CClHA,SAAS2c,GAAQzrB,GAChB,IAAIsH,EACArH,EAGJ,GADAqH,EAAM,GACDtH,GAAK,EACT,OAAOsH,EAER,IAAMrH,EAAI,EAAGA,EAAID,EAAGC,IACnBqH,EAAItC,KAAM/E,GAEX,OAAOqH,CACR,CCiDA,SAASkkB,GAAStrB,EAAK0X,EAAMgC,EAAQjH,GACpC,IAAIvJ,EACAyhB,EACA5qB,EAKJ,IAHA4qB,EAAa,EAATjR,EACJ3Z,EAAa,EAAT0S,EACJvJ,EAAI,EACInJ,GAAK,GAAKA,EAAI2X,EAAKnX,QAC1BmX,EAAM3X,GAAMmJ,EACZwO,EAAM3X,EAAE,GAAM,EACdA,GAAK4qB,EACLzhB,GAAK,EAEN,OAAOlJ,CACR,CCxDA,SAASgX,GAAWpI,EAAGvH,EAAKkC,GAC3B,IAAIkK,EACAjN,EACAzG,EACA8D,EACA+Z,EAMJ,IAJAnK,EAAM7E,EAAE8I,KACRlR,EAAMoI,EAAEoI,UAAW,GAEnB4G,EAAI,EACE7d,EAAI,EAAGA,EAAIsH,EAAI9G,OAAQR,IAEvBwJ,EAAW/C,EAAKiN,EADrB5P,EAAIwD,EAAKtH,IACsB8D,EAAG4P,KACjCpM,EAAKuW,GAAM/Z,EACX+Z,GAAK,GAIP,OADAvW,EAAI9G,OAASqd,EACNvW,CACR,CAwBA,SAAS6jB,GAAStc,EAAGvH,EAAKkC,GACzB,IAAIxJ,EACA8D,EACA+Z,EAGJ,IADAA,EAAI,EACE7d,EAAI,EAAGA,EAAIsH,EAAI9G,OAAQR,IAEvBwJ,EAAWqF,EADhB/K,EAAIwD,EAAKtH,IACe8D,EAAG+K,KAC1BvH,EAAKuW,GAAM/Z,EACX+Z,GAAK,GAIP,OADAvW,EAAI9G,OAASqd,EACNvW,CACR,CC7DA,SAASmkB,GAAiB9U,EAAGC,GAC5B,OAASD,IAAMC,GAASD,GAAMA,GAAKC,GAAMA,CAC1C,CCgBA,SAAS6U,GAAiB9U,EAAGC,GAC5B,OAAOD,IAAMC,GAASD,GAAMA,GAAKC,GAAMA,MAGlC7E,GAAe4E,KAAO5E,GAAe6E,MCvBbqE,EDwBMrE,ECvB/BsE,EAASJ,GDuBmBnE,GCtB5ByE,EAASN,GAAMG,GAElBY,GAAQX,EAAQ,GAAKE,EAAQ,KAC7BS,GAAQX,EAAQ,GAAKE,EAAQ,KAL/B,IAA8BH,EACzBC,EACAE,CDyBL,CE/BA,SAAS+P,GAAStc,GACjB,IAAI9O,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrB6O,EAAG7O,KACPD,GAAK,GAGP,OAAOA,CACR,CA+EA,SAAS2rB,GAAa7c,GACrB,OAAK3H,EAAiB2H,GAChB2H,GAAgB3H,GACbsc,GAASvI,GAAoB/T,EAAG,IAEnC+N,GAAqB/N,GApC5B,SAAkBA,GACjB,IAAIwc,EACAtrB,EACAC,EAKJ,IAHAqrB,EAAOC,GAAoBzc,EAAG,GAE9B9O,EAAI,EACEC,EAAI,EAAGA,EAAIqrB,EAAK7qB,OAAQR,GAAK,GAC7BqrB,EAAMrrB,IAAOqrB,EAAMrrB,EAAE,MACzBD,GAAK,GAGP,OAAOA,CACR,CAuBUwrB,CAAS1c,GApEnB,SAAoBA,GACnB,IAAIpI,EACA1G,EACAC,EAKJ,IAHAyG,EAAMqR,GAAejJ,GAErB9O,EAAI,EACEC,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrByG,EAAKoI,EAAG7O,KACZD,GAAK,GAGP,OAAOA,CACR,CAwDSkX,CAAWpI,GAEZsc,GAAStc,EACjB,CCiBA,SAAS0c,GAAS1c,EAAG+J,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA5rB,EAOJ,IALA2rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,GAAK,GAClB,IAARsU,IAAmBzF,EAAG7O,IAAO6O,EAAG7O,EAAE,MACtCsU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,EAEP,OAAO8B,CACR,CAiFA,SAAS7B,GAAQ/K,EAAG+J,EAAGe,EAAQjH,GAC9B,IAAI8P,EAAK9K,GAAkB7I,GACvB4T,EAAK/K,GAAkBkB,GAC3B,OACC4J,EAAGrL,kBACHsL,EAAGtL,kBAGEhF,GAAmBtD,GACvB0c,GAASxX,GAAgBlF,EAAG,GAAK4T,EAAI9I,EAAQjH,GAClCR,GAAkBrD,GAC7B0c,GAASzX,GAAejF,EAAG,GAAK4T,EAAI9I,EAAQjH,GACjC8D,GAAgB3H,GAxD9B,SAAkBA,EAAG+J,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA5rB,EAOJ,IALA2rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,KACb,IAARsU,GAAiBzF,EAAG7O,KACxBsU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAqCGkS,CAASjJ,GAAoB/T,EAAG,GAAK4T,EAAI9I,EAAQjH,GAhLpD,SAAoB7D,EAAG+J,EAAGe,EAAQjH,GACjC,IAAI8I,EACAC,EACAC,EACAiQ,EACArX,EACAsX,EACA5rB,EAUJ,IARAwb,EAAQ3M,EAAE8I,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO7M,EAAEoI,UAAW,GACpB0U,EAAO/S,EAAE3B,UAAW,GAEpB3C,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,KACjB,IAARsU,GAAiBoH,EAAMF,EAAOxb,KAClCsU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAyJG1C,CAAWuL,EAAIC,EAAI9I,EAAQjH,GAErBkG,IAvOT,SAAkB/J,EAAG+J,EAAGe,EAAQjH,GAC/B,IAAI4B,EACAsX,EACA5rB,EAIJ,IAFAsU,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,KACb,IAARsU,GAAiBzF,EAAG7O,KACxBsU,GAAM,GAEPsE,EAAGgT,GAAOtX,EACVsX,GAAMjS,CAGR,CA0NCwR,CAAStc,EAAG+J,EAAGe,EAAQjH,GAChBkG,EACR,CCrPA,SAASkT,GAAOjd,GAEf,OAAO+K,GAAQ/K,EADPqT,IAAQ,EAAOrT,EAAErO,QACJ,EAAG,EACzB,CCwHA,SAAS+qB,GAAS1c,EAAG+J,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA5rB,EAOJ,IALA2rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,GAAK,GAClB,IAARsU,GAAmBzF,EAAG7O,IAAO6O,EAAG7O,EAAE,KACtCsU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,EAEP,OAAO8B,CACR,CAiFA,SAAS7B,GAAQ/K,EAAG+J,EAAGe,EAAQjH,GAC9B,IAAI8P,EAAK9K,GAAkB7I,GACvB4T,EAAK/K,GAAkBkB,GAC3B,OACC4J,EAAGrL,kBACHsL,EAAGtL,kBAGEhF,GAAmBtD,GACvB0c,GAASxX,GAAgBlF,EAAG,GAAK4T,EAAI9I,EAAQjH,GAClCR,GAAkBrD,GAC7B0c,GAASzX,GAAejF,EAAG,GAAK4T,EAAI9I,EAAQjH,GACjC8D,GAAgB3H,GAxD9B,SAAkBA,EAAG+J,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA5rB,EAOJ,IALA2rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,KACb,IAARsU,GAAiBzF,EAAG7O,KACxBsU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAqCGkS,CAASjJ,GAAoB/T,EAAG,GAAK4T,EAAI9I,EAAQjH,GAhLpD,SAAoB7D,EAAG+J,EAAGe,EAAQjH,GACjC,IAAI8I,EACAC,EACAC,EACAiQ,EACArX,EACAsX,EACA5rB,EAUJ,IARAwb,EAAQ3M,EAAE8I,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO7M,EAAEoI,UAAW,GACpB0U,EAAO/S,EAAE3B,UAAW,GAEpB3C,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,KACjB,IAARsU,GAAiBoH,EAAMF,EAAOxb,KAClCsU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAyJG1C,CAAWuL,EAAIC,EAAI9I,EAAQjH,GAErBkG,IAvOT,SAAkB/J,EAAG+J,EAAGe,EAAQjH,GAC/B,IAAI4B,EACAsX,EACA5rB,EAIJ,IAFAsU,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,KACb,IAARsU,GAAiBzF,EAAG7O,KACxBsU,GAAM,GAEPsE,EAAGgT,GAAOtX,EACVsX,GAAMjS,CAGR,CA0NCwR,CAAStc,EAAG+J,EAAGe,EAAQjH,GAChBkG,EACR,CCrPA,SAASmT,GAASld,GAEjB,OAAO+K,GAAQ/K,EADPqT,IAAQ,EAAMrT,EAAErO,QACH,EAAG,EACzB,CCwHA,SAAS+qB,GAAS1c,EAAG+J,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA5rB,EAOJ,IALA2rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,GAAK,GAClB,IAARsU,IAAkBzF,EAAG7O,IAAO6O,EAAG7O,EAAE,MACrCsU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,EAEP,OAAO8B,CACR,CAiFA,SAAS7B,GAAQ/K,EAAG+J,EAAGe,EAAQjH,GAC9B,IAAI8P,EAAK9K,GAAkB7I,GACvB4T,EAAK/K,GAAkBkB,GAC3B,OACC4J,EAAGrL,kBACHsL,EAAGtL,kBAGEhF,GAAmBtD,GACvB0c,GAASxX,GAAgBlF,EAAG,GAAK4T,EAAI9I,EAAQjH,GAClCR,GAAkBrD,GAC7B0c,GAASzX,GAAejF,EAAG,GAAK4T,EAAI9I,EAAQjH,GACjC8D,GAAgB3H,GAxD9B,SAAkBA,EAAG+J,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA5rB,EAOJ,IALA2rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,KACb,IAARsU,GAAgBzF,EAAG7O,KACvBsU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAqCGkS,CAASjJ,GAAoB/T,EAAG,GAAK4T,EAAI9I,EAAQjH,GAhLpD,SAAoB7D,EAAG+J,EAAGe,EAAQjH,GACjC,IAAI8I,EACAC,EACAC,EACAiQ,EACArX,EACAsX,EACA5rB,EAUJ,IARAwb,EAAQ3M,EAAE8I,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO7M,EAAEoI,UAAW,GACpB0U,EAAO/S,EAAE3B,UAAW,GAEpB3C,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,KACjB,IAARsU,GAAgBoH,EAAMF,EAAOxb,KACjCsU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAyJG1C,CAAWuL,EAAIC,EAAI9I,EAAQjH,GAErBkG,IAvOT,SAAkB/J,EAAG+J,EAAGe,EAAQjH,GAC/B,IAAI4B,EACAsX,EACA5rB,EAIJ,IAFAsU,GAAM,EACNsX,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,KACb,IAARsU,GAAgBzF,EAAG7O,KACvBsU,GAAM,GAEPsE,EAAGgT,GAAOtX,EACVsX,GAAMjS,CAGR,CA0NCwR,CAAStc,EAAG+J,EAAGe,EAAQjH,GAChBkG,EACR,CCrPA,SAASoT,GAAQnd,GAEhB,OAAO+K,GAAQ/K,EADPqT,IAAQ,EAAMrT,EAAErO,QACH,EAAG,EACzB,CCcA,SAASyrB,GAAsB/lB,EAAKC,EAAM8B,EAAQG,GACjDzI,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdL,IAAOwB,EACPvB,IAAO0B,GAET,CCZA,SAASyP,GAAUhJ,GAClB,IAAI7O,EACJ,IAAMA,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1B,IAAM6O,EAAG7O,GACR,OAAO,EAGT,OAAO,CACR,CA2BA,SAASksB,GAAiBrd,GACzB,IAAI7O,EACJ,IAAMA,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,GAAK,EAC/B,IAAQ6O,EAAG7O,KAAO6O,EAAG7O,EAAE,GACtB,OAAO,EAGT,OAAO,CACR,CCzCA,SAASmsB,GAAStsB,GACjB,OAAS+O,GAAW/O,ICtBrB,SAAiBA,GAChB,OAAiB,OAAVA,CACR,CDoBgCusB,CAAQvsB,IEhBxC,SAAsBA,GACrB,YAAiB,IAAVA,CACR,CFcmDwsB,CAAaxsB,EAChE,CAyDA,SAASysB,KACR,IAAI3Y,EACAe,EACA6X,EACAC,EAoBJ,GAjBe,KADf7Y,EAAQzP,UAAU1D,SAEjBkU,EAAQ,KACR6X,EAAO,KACPC,EAAO,MACc,IAAV7Y,GACXe,EAAQ,KACR6X,EAAOroB,UAAW,GAClBsoB,EAAO,MACc,IAAV7Y,GACXe,EAAQxQ,UAAW,GACnBqoB,EAAOroB,UAAW,GAClBsoB,EAAO,OAEP9X,EAAQxQ,UAAW,GACnBqoB,EAAOroB,UAAW,GAClBsoB,EAAOtoB,UAAW,MAEXoN,gBAAgBgb,IACvB,OAAO,IAAIA,GAAO5X,EAAO6X,EAAMC,GAEhC,IAAML,GAASzX,GACd,MAAM,IAAI3Q,UAAWiB,EAAQ,wFAAyF0P,IAEvH,IAAMyX,GAASI,GACd,MAAM,IAAIxoB,UAAWiB,EAAQ,yFAA0FunB,IAExH,IAAMJ,GAASK,GACd,MAAM,IAAIzoB,UAAWiB,EAAQ,wFAAyFwnB,IAChH,GAAc,IAATA,EACX,MAAM,IAAI3Y,WAAY7O,EAAQ,gEAAiEwnB,IAKhG,OAHAlb,KAAKmb,YAAqB,IAAV/X,EAAqB,KAAOA,EAC5CpD,KAAKob,WAAmB,IAATH,EAAoB,KAAOA,EAC1Cjb,KAAKqb,WAAmB,IAATH,EAAoB,KAAOA,EACnClb,IACR,CG3DA,SAASsb,GAAgB/nB,EAAO4E,EAAKojB,GACpC,IAAInY,EACA6X,EACAC,EAYJ,GAVA9X,EAAQ7P,EAAM6P,MACd6X,EAAO1nB,EAAM0nB,KAIC,QAHdC,EAAO3nB,EAAM2nB,QAIZA,EAAO,GAIO,OAAV9X,EAGHA,EADI8X,EAAO,EACH,EAIA/iB,EAAM,OAIX,GAAKiL,EAAQ,GAIjB,IAHAA,EAAQjL,EAAMiL,GAGD,EAAI,CAChB,GAAKmY,EACJ,MCnGI,CACNC,KAAQ,2BDqGPpY,EAAQ,CACR,OAGG,GAAKA,GAASjL,EAAM,CACxB,GAAKojB,EACJ,MC5GK,CACNC,KAAQ,2BD+GPpY,EADI8X,EAAO,EACH/iB,EAAM,EAINA,CAET,CAGD,GAAc,OAAT8iB,EAGHA,EADIC,EAAO,EACJ/iB,EAIA,UAIJ,GAAK8iB,EAAO,GAIhB,IAHAA,EAAO9iB,EAAM8iB,GAGD,EAEX,GAAKC,EAAO,EAAI,CACf,GAAKK,EACJ,MC5IG,CACNC,KAAQ,2BD6INP,EAAO,CACP,KAEI,CACJ,GAAKM,GAAUN,GAAQ,EACtB,MCnJG,CACNO,KAAQ,2BDoJNP,EAAO,IACP,OAIE,GAAKA,EAAO9iB,EAAM,CACtB,GAAKojB,EACJ,MC5JK,CACNC,KAAQ,2BD8JRP,EAAO9iB,CACP,CAGD,OAAO,IAAI6iB,GAAO5X,EAAO6X,EAAMC,EAChC,CE9IA5lB,EAAAnH,GAAA,UnB8HA,SAAiBQ,EAAK0Z,EAAQjH,GAC7B,IAAIxM,EAAMwR,GAAkBzX,GAC5B,OAAKiG,EAAIiR,iBAEW,eAAdjR,EAAIgC,MACDqjB,GAAStrB,EAAK8T,GAAgB9T,EAAK,GAAK0Z,EAAQjH,GAErC,cAAdxM,EAAIgC,MACDqjB,GAAStrB,EAAK6T,GAAe7T,EAAK,GAAK0Z,EAAQjH,GAlDzD,SAAoBzS,EAAK0Z,EAAQjH,GAChC,IAAIiF,EACAjR,EACAyC,EACAnJ,EAOJ,IALA2X,EAAO1X,EAAI0X,KACXjR,EAAMzG,EAAIgX,UAAW,GAErBjX,EAAI0S,EACJvJ,EAAI,EACInJ,GAAK,GAAKA,EAAI2X,EAAKnX,QAC1BkG,EAAKiR,EAAM3X,EAAGmJ,GACdnJ,GAAK2Z,EACLxQ,GAAK,EAEN,OAAOwO,CACR,CAmCSV,CAAW/Q,EAAKyT,EAAQjH,GAzIjC,SAAkBzS,EAAK0Z,EAAQjH,GAC9B,IAAIvJ,EACAnJ,EAIJ,IAFAA,EAAI0S,EACJvJ,EAAI,EACInJ,GAAK,GAAKA,EAAIC,EAAIO,QACzBP,EAAKD,GAAMmJ,EACXnJ,GAAK2Z,EACLxQ,GAAK,EAEN,OAAOlJ,CACR,CA+HQkrB,CAASlrB,EAAK0Z,EAAQjH,EAC9B,IoB1IA9L,EAAAnH,GAAA,SAAAma,ICAAhT,EAAAnH,GAAA,SAAAma,ICAAhT,EAAAnH,GAAA,SAAAma,IRsHAhT,EAAa0lB,GAAO,OAAQ,SA+BT/Z,GAAE+Z,GAAMzrB,UAAW,SAAS,WAC9C,OAAOyQ,KAAKmb,MACb,IA+BmBla,GAAE+Z,GAAMzrB,UAAW,QAAQ,WAC7C,OAAOyQ,KAAKob,KACb,IA+BmBna,GAAE+Z,GAAMzrB,UAAW,QAAQ,WAC7C,OAAOyQ,KAAKqb,KACb,IA+BW3lB,EAAEslB,GAAMzrB,UAAW,YAAY,WACzC,MAAO,SAASyQ,KAAKmb,OAAO,IAAInb,KAAKob,MAAM,IAAIpb,KAAKkb,KAAK,GAC1D,IAmCWxlB,EAAEslB,GAAMzrB,UAAW,UAAU,WACvC,MAAO,CACNmQ,KAAQ,QACR2G,KAAQ,CACPrG,KAAKmb,OACLnb,KAAKob,MACLpb,KAAKqb,OAGR,IS9SA,IAAII,GAAO9qB,KAAK8qB,KCkEhB,SAASC,GAAanoB,GACrB,IAAIooB,EACAnC,EACAC,EAUJ,OARAD,EAAKjmB,EAAM6P,MAKC,QAJZqW,EAAKlmB,EAAM0nB,QAKVxB,GAAM,IAJPkC,EAAMpoB,EAAM2nB,MAQH,GAAK1B,GAAMC,GAGjBkC,EAAM,GAAKnC,GAAMC,EAEZ,EAEDgC,IAAQhC,EAAKD,GAAOmC,EAC5B,CC/GA,IAAIhmB,GAAO,WAqBX,SAASC,GAAiBrH,GACzB,cAAgBA,EAAM4G,MAAQQ,WAAepH,EAAM6G,MAAQO,EAC5D,CCvBA,IAAIE,GAAU,CACbC,QAgCD,SAAqBC,EAAKC,GACzB,OAAOD,EAAKC,EACb,EAjCCC,QAmDD,SAAqBF,EAAKC,GACzB,OAAOD,EAAKC,EACb,EApDCE,MAsED,SAAmBH,EAAKC,GACvB,OAAOD,EAAKC,EACb,EAvECG,MAyFD,SAAmBJ,EAAKC,GACvB,OAAOD,EAAKC,EACb,EA1FCI,KA4GD,SAAkBL,EAAKC,GACtB,OAAOD,EAAKC,EACb,EA7GCK,OA+HD,SAAoBN,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAhICM,OAkJD,SAAoBP,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAnJCO,MAqKD,SAAmBR,EAAKC,GACvB,OAAOD,EAAKC,EACb,EAtKCQ,OAwLD,SAAoBT,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAzLCS,QAyMD,SAAqBV,EAAKC,GACzB,OAAOD,EAAKC,EACb,EA1MCU,QA0ND,SAAuBX,EAAKC,GAC3B,OAAOD,EAAKC,EACb,GAoBA,SAASW,GAAQC,GAChB,IAAIvF,EAAIwE,GAASe,GACjB,MAAkB,mBAANvF,EACJA,EAEDwE,GAAQa,OAChB,CCjQA,IAAIG,GAAU,CACbf,QAkCD,SAAqBC,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EAnCC0H,QAuDD,SAAqBF,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EAxDC2H,MA4ED,SAAmBH,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EA7EC4H,MAiGD,SAAmBJ,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EAlGC6H,KAsHD,SAAkBL,EAAKC,EAAKzH,GAC3BwH,EAAKC,GAAQzH,CACd,EAvHC8H,OA2ID,SAAoBN,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EA5IC+H,OAgKD,SAAoBP,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EAjKCgI,MAqLD,SAAmBR,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EAtLCiI,OA0MD,SAAoBT,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EA3MCkI,QA6ND,SAAqBV,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EA9NCmI,QAgPD,SAAuBX,EAAKC,EAAKzH,GAChCwH,EAAKC,GAAQzH,CACd,GAsBA,SAASuI,GAAQF,GAChB,IAAIvF,EAAIwF,GAASD,GACjB,MAAkB,mBAANvF,EACJA,EAEDwF,GAAQH,OAChB,CCzRA,IAAIb,GAAU,CACbkB,WAgCD,SAAwBhB,EAAKC,GAC5B,OAAOD,EAAIZ,IAAKa,EACjB,EAjCCgB,UA2DD,SAAuBjB,EAAKC,GAC3B,OAAOD,EAAIZ,IAAKa,EACjB,EA5DCU,QAuFD,SAAuBX,EAAKC,GAC3B,OAAOD,EAAIZ,IAAKa,EACjB,GA6BA,SAASW,GAAQC,GAChB,IAAIvF,EAAIwE,GAASe,GACjB,MAAkB,mBAANvF,EACJA,EAEDwE,GAAQa,OAChB,CC/HA,IAAIG,GAAU,CACbE,WAkCD,SAAwBhB,EAAKC,EAAKzH,GACjCwH,EAAIX,IAAK7G,EAAOyH,EACjB,EAnCCgB,UA+DD,SAAuBjB,EAAKC,EAAKzH,GAChCwH,EAAIX,IAAK7G,EAAOyH,EACjB,EAhECU,QA6FD,SAAuBX,EAAKC,EAAKzH,GAChCwH,EAAIX,IAAK7G,EAAOyH,EACjB,GAgCA,SAASc,GAAQF,GAChB,IAAIvF,EAAIwF,GAASD,GACjB,MAAkB,mBAANvF,EACJA,EAEDwF,GAAQH,OAChB,CCvIA,IAAIqC,GAAc,CACjBC,aAAgB,UAChBC,aAAgB,UAChBpH,MAAS,UACTqH,WAAc,QACdC,WAAc,QACdC,UAAa,OACbC,YAAe,SACfC,YAAe,SACfC,WAAc,QACdC,kBAAqB,SACrBC,eAAkB,YAClBC,gBAAmB,aACnBC,aAAgB,QCdbd,GAA+B,mBAAfM,WAA8BA,gBAAa,EC6B/DyiB,GATK1gB,KACGvG,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECTI2I,GAA+B,mBAAfK,WAA8BA,gBAAa,EC6B/D2iB,GATKhgB,KACGlH,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECTI2I,GAAsC,mBAAtBW,kBAAqCA,uBAAoB,EC6B7EsiB,GATKxf,KACG3H,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECTI2I,GAA8B,mBAAdO,UAA6BA,eAAY,EC6B7D2iB,GATKnf,KACGjI,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECOA,SAASsR,GAAcC,GACtB,IAAI9S,EACAkJ,EACAqJ,EAGJ,IADAvS,EAAM,KAELkJ,EAAI4J,EAAGC,QACAC,MAIP,GAAK9D,GADLqD,EAAIrJ,EAAEtJ,QACyB2S,EAAEhS,QAAU,EAC1CP,EAAI8E,KAAMyN,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAIzO,UAAWiB,EAAQ,kJAAmJwN,IAFjLvS,EAAI8E,KAAMmO,GAAOV,GAAKW,GAAOX,GAG7B,CAEF,OAAOvS,CACR,CCAA,IAAAgS,GAAA,EAAA3H,GAAA2H,kBACAmB,GAAAhB,KAYA,SAAAiB,GAAAxT,GACA,OACAA,aAAAkL,IAEA,iBAAAlL,GACA,OAAAA,IAEA,mBAAAA,EAAAgK,YAAAK,MACA,oBAAArK,EAAAgK,YAAAK,OAEA,iBAAArK,EAAAyT,SAGA,iBAAAzT,EAAA0T,OAGA,CASA,SAAAC,GAAA3T,GACA,OACAA,IAAAkL,IAGA,oBAAAlL,EAAAqK,IAEA,CAUA,SAAAuJ,GAAAC,EAAApM,GAEA,OAAA,IAAAuK,GAAA6B,EADApM,GAAA,GACAoM,EAAApM,EAAA,GACA,CAyEA,SAAAyD,KACA,IAAA6H,EACAe,EACAD,EACAjK,EAGA,GADAkK,EAAAzP,UAAA1D,SACA8Q,gBAAAvG,IACA,OAAA,IAAA4I,EACA,IAAA5I,GAEA,IAAA4I,EACA,IAAA5I,GAAA7G,UAAA,IAEA,IAAAyP,EACA,IAAA5I,GAAA7G,UAAA,GAAAA,UAAA,IAEA,IAAA6G,GAAA7G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAAyP,EACAD,EAAA,IAAApJ,GAAA,QACA,GAAA,IAAAqJ,EACA,GAAA1E,GAAA/K,UAAA,IACAwP,EAAA,IAAApJ,GAAA,EAAApG,UAAA,SACA,GAAAoL,GAAApL,UAAA,IAKA,IAHAuF,GADAiK,EAAAxP,UAAA,IACA1D,SAGA0C,GAAAwQ,IAAA3B,GAAA2B,EAAA,KAEA,GADAA,ECxLA,SAAoBA,EAAKrM,GACxB,IAAIoC,EACAN,EACAnJ,EACA8D,EAIJ,IAFA2F,EAAMpC,EAAI7G,OACVsD,EAAI,EACE9D,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,IAAM+R,GADN5I,EAAI9B,EAAKrH,IAER,OAAO,KAER0T,EAAK5P,GAAMoP,GAAO/J,GAClBuK,EAAK5P,EAAE,GAAMqP,GAAOhK,GACpBrF,GAAK,CACL,CACD,OAAO4P,CACR,CDsKAE,CAAA,IAAAtJ,GAAA,EAAAb,GAAAiK,GACA,OAAAA,EAAA,CAEA,IAAA1B,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,6GAAAyE,IAGAiK,EAAA,IAAApJ,GAAApG,UAAA,GACA,MACA,CACA,GAAAgO,GAAAwB,GACAA,EAAAI,GAAAJ,EAAA,QACA,GAAAvB,GAAAuB,GACAA,EAAAK,GAAAL,EAAA,QACA,IAAA1B,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,6HAAAyE,IAEAiK,EAAA,IAAApJ,GAAAoJ,EACA,MACA,GAAAjE,GAAAvL,UAAA,IAAA,CAEA,IAAA0K,IADA8E,EAAAxP,UAAA,IACA8P,WAAA/B,IACA,MAAA,IAAA4B,WAAA7O,EAAA,yFAAAiN,GAAAyB,EAAAM,aAEAN,EAAA,IAAApJ,GAAAoJ,EACA,KAAA,KAAAlF,GAAAtK,UAAA,IAkBA,MAAA,IAAAH,UAAAiB,EAAA,qHAAAd,UAAA,KAhBA,GADAwP,EAAAxP,UAAA,IACA,IAAAkP,GACA,MAAA,IAAArP,UAAAiB,EAAA,mJAAA0O,IAEA,IAAAzC,GAAAyC,EAAAO,KACA,MAAA,IAAAlQ,UAAAiB,EAAA,qHAAA0O,IAGA,IAAAzC,IADAyC,EAAAA,EAAAO,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,qHAAA0O,IAGA,IADAA,EAAAZ,GAAAY,cACAlS,MACA,MAAAkS,EAEAA,EAAA,IAAApJ,GAAAoJ,EAGA,KACA,CAEA,IAAAjE,GADAiE,EAAAxP,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA0O,IAGA,IAAAzE,GADA2D,EAAA1O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA4N,IAEA,IAAAhE,GAAAgE,EAAAX,IACA,MAAA,IAAA4B,WAAA7O,EAAA,uEAAAiN,GAAAW,IAEA,GAAA,IAAAe,EAAA,CAEA,IAAA/E,IADAnF,EAAAiK,EAAAM,WAAApB,GACAX,IACA,MAAA,IAAA4B,WAAA7O,EAAA,oGAAAiN,GAAAxI,IAEAiK,EAAA,IAAApJ,GAAAoJ,EAAAd,EACA,KAAA,CAEA,IAAA3D,GADAxF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAAwI,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAA7O,EAAA,iJAAAyE,EAAAwI,KAEAyB,EAAA,IAAApJ,GAAAoJ,EAAAd,EAAA,EAAAnJ,EACA,CACA,CAIA,OAHA7C,EAAA0K,KAAA,UAAAoC,GACA9M,EAAA0K,KAAA,UAAAoC,EAAAlT,OAAA,GAEA8Q,IACA,CErQA,SAASwB,GAAcC,GACtB,IAAI9S,EACAkJ,EACAqJ,EAGJ,IADAvS,EAAM,KAELkJ,EAAI4J,EAAGC,QACAC,MAIP,GAAK9D,GADLqD,EAAIrJ,EAAEtJ,QACyB2S,EAAEhS,QAAU,EAC1CP,EAAI8E,KAAMyN,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAIzO,UAAWiB,EAAQ,kJAAmJwN,IAFjLvS,EAAI8E,KAAMqM,GAAMoB,GAAKnB,GAAMmB,GAG3B,CAEF,OAAOvS,CACR,CF+PA2G,EAAAmE,GAAA,oBAAAkH,IAeArL,EAAAmE,GAAA,OAAA,kBAmDA/D,EAAA+D,GAAA,QAAA,SAAAmJ,GACA,IAAAC,EACAR,EACAS,EACAnU,EACAyT,EACAW,EACA5N,EACAgD,EACA6K,EACAnL,EACAnJ,EACA8D,EACA,IAAAmN,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAyP,GAAAlC,MACA,MAAA,IAAAvN,UAAA,6DAGA,IADA4P,EAAAzP,UAAA1D,QACA,EAAA,CAEA,IAAAyQ,GADAmD,EAAAlQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAoP,IAEAT,EAAA,IACAQ,EAAAjQ,UAAA,GAEA,CACA,GAAAmP,GAAAa,GAAA,CAEA,GADAzK,EAAAyK,EAAA1T,OACA4T,EAAA,CAIA,IAFAV,GADAzT,EAAA,IAAAqR,KAAA7H,IACA8J,QACAzP,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAA+R,GADA5I,EAAAiL,EAAAtS,KAAAqS,EAAAD,EAAAzN,IAAAzG,GAAAA,IAEA0T,EAAA5P,GAAAoP,GAAA/J,GACAuK,EAAA5P,EAAA,GAAAqP,GAAAhK,OACA,MAAAgG,GAAAhG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAuK,EAAA5P,GAAAqF,EAAA,GACAuK,EAAA5P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAqR,KAAA4C,EACA,CACA,GAAA5E,GAAA4E,GAAA,CACA,GAAAE,EAAA,CAUA,IAPA3K,EAAAyK,EAAA1T,OAEAiG,EADAyN,EAAAzN,KAAAyN,EAAAxN,IACA6N,GAAA,WAEAtM,GAAA,WAGAjI,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA,IAAA+R,GAAAtL,EAAAyN,EAAAlU,IAAA,CACAsU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,+FAAA,EAAAyE,IAIA,IADAiK,GADAzT,EAAA,IAAAqR,KAAA7H,EAAA,IACA8J,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAoU,EAAAtS,KAAAqS,EAAA1N,EAAAyN,EAAAlU,GAAAA,GAEA,OAAAC,CACA,CAKA,IAFAyT,GADAzT,EAAA,IAAAqR,KAAA7H,IACA8J,QACAzP,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAA+R,GADA5I,EAAAiL,EAAAtS,KAAAqS,EAAA1N,EAAAyN,EAAAlU,GAAAA,IAEA0T,EAAA5P,GAAAoP,GAAA/J,GACAuK,EAAA5P,EAAA,GAAAqP,GAAAhK,OACA,MAAAgG,GAAAhG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAuK,EAAA5P,GAAAqF,EAAA,GACAuK,EAAA5P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAqR,KAAA4C,EACA,CACA,GAAA1F,GAAA0F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,6FAAAkP,IAOA,GAJAG,EADAD,EG/bA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIlU,EACAkJ,EACAqJ,EACAxS,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI4J,EAAGC,QACAC,MAKP,GAFAjT,GAAK,EAEAmP,GADLqD,EAAI4B,EAAKtS,KAAMqS,EAAShL,EAAEtJ,MAAOG,KACFwS,EAAEhS,QAAU,EAC1CP,EAAI8E,KAAMyN,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAIzO,UAAWiB,EAAQ,+IAAgJwN,IAF9KvS,EAAI8E,KAAMmO,GAAOV,GAAKW,GAAOX,GAG7B,CAEF,OAAOvS,CACR,CHwaAuU,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAEAW,aAAA7S,MACA,MAAA6S,EAKA,IADAX,GADAzT,EAAA,IAAAqR,KADA7H,EAAA4K,EAAA7T,OAAA,IAEA+S,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAqU,EAAArU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAkP,GACA,IAoBAtN,EAAAmE,GAAA,MAAA,WACA,IAAA9F,EACAjF,EACA,IAAAiR,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAyP,GAAAlC,MACA,MAAA,IAAAvN,UAAA,6DAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAsR,KAAArM,EACA,IAuDA+B,EAAA+D,GAAAlK,UAAA,MAAA,SAAAyG,GACA,IAAA+L,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA6K,GAAAtH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAKA,GAHAA,EAAA,IACAA,GAAAgK,KAAAgC,WAEAhM,EAAA,GAAAA,GAAAgK,KAAAgC,SAGA,OAAAG,GAAAnC,KAAAiC,QAAAjM,EACA,IAgBAiL,GAAAxH,GAAAlK,UAAA,UAAA,WACA,OAAAyQ,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAAxH,GAAAlK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAS,UACA,IAgBAzB,GAAAxH,GAAAlK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAX,UACA,IAiBA5L,EAAA+D,GAAAlK,UAAA,oBAAAkK,GAAAkH,mBAuCArL,EAAAmE,GAAAlK,UAAA,cAAA,SAAA4T,EAAAC,GACA,IAAArB,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAQA,OALA,IAAAG,UAAA1D,OACA8Q,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,EAAA,EAAAxQ,UAAA,IAEAoN,IACA,IAqCAtK,EAAA+D,GAAAlK,UAAA,WAAA,WACA,IAAAoP,EACA2E,EACAnL,EACAiK,EACAnL,EACAvI,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAiBA,OAfAkM,EAAAqB,KACAoC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAA,CAAAG,EAAAyT,GAAAC,EAAA1T,IACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAA4E,SACA,IAjDAD,CAkDA,IA+BAhO,EAAAmE,GAAAlK,UAAA,SAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,IAAAwJ,EAAA1H,KAAAqS,EAAAV,GAAAC,EAAA1T,GAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA2CA1K,EAAAmE,GAAAlK,UAAA,QAAA,SAAAhB,EAAA6U,EAAAI,GACA,IAAApB,EACAjK,EACAnC,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAlS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,0EAAAnF,IAIA,GAFA6T,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAA8F,GACA,MAAA,IAAA3Q,UAAAiB,EAAA,qEAAA0P,IAQA,GANAA,EAAA,IACAA,GAAAjL,GACA,IACAiL,EAAA,GAGAxQ,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,oEAAA8P,IAEAA,EAAA,IACAA,GAAArL,GACA,IACAqL,EAAA,GAGAA,EAAArL,IACAqL,EAAArL,EAEA,MACAqL,EAAArL,CAEA,MACAiL,EAAA,EACAI,EAAArL,EAIA,IAFA8H,EAAA2B,GAAArT,GACA2R,EAAA2B,GAAAtT,GACAG,EAAA0U,EAAA1U,EAAA8U,EAAA9U,IAEA0T,EADApM,EAAA,EAAAtH,GACAuR,EACAmC,EAAApM,EAAA,GAAAkK,EAEA,OAAAF,IACA,IA2CA1K,EAAAmE,GAAAlK,UAAA,UAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAzT,EACAD,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAkK,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAwS,EAAAiB,GAAAC,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,OACArR,EAAA8E,KAAAyN,GAGA,OAAA,IAAAlB,KAAAzH,YAAA5J,EACA,IAsCA2G,EAAAmE,GAAAlK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAwS,EAAAiB,GAAAC,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAkB,CAGA,IAgCA5L,EAAAmE,GAAAlK,UAAA,aAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAwS,EAAAiB,GAAAC,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IAsCA4G,EAAAmE,GAAAlK,UAAA,YAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAwS,EAAAiB,GAAAC,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAkB,CAGA,IAgCA5L,EAAAmE,GAAAlK,UAAA,iBAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAwS,EAAAiB,GAAAC,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IA4BA4G,EAAAmE,GAAAlK,UAAA,WAAA,SAAAkU,EAAAZ,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAAiB,EAAA,oEAAA+P,IAGA,IADArB,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAwS,EAAAiB,GAAAC,EAAA1T,GACA+U,EAAAjT,KAAAqS,EAAA3B,EAAAxS,EAAAsR,KAEA,IAyCAtK,EAAA+D,GAAAlK,UAAA,OAAA,SAAAyG,GACA,IAAA+L,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkL,GAAA3H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAgK,KAAAgC,SAGA,OAAAG,GAAAnC,KAAAiC,QAAAjM,EACA,IAmCAV,EAAAmE,GAAAlK,UAAA,YAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAA,EAGA,OAAA,CACA,IAmCAV,EAAAmE,GAAAlK,UAAA,WAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyBAgH,EAAA+D,GAAAlK,UAAA,QAAA,SAAAqU,GACA,IAAAjV,EACAyT,EACAyB,EACAnV,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA2U,EAAA,QACA,KAAAzF,GAAAwF,GAGA,MAAA,IAAAnR,UAAAiB,EAAA,kEAAAkQ,IAFAC,EAAAD,CAGA,CAGA,IAFAjV,EAAA,GACAyT,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAA0O,GAAAC,EAAA1T,GAAAyB,YAEA,OAAAxB,EAAAmV,KAAAD,EACA,IA4BAnO,EAAA+D,GAAAlK,UAAA,QAAA,WACA,IAAAoP,EACA2E,EACAnL,EACAlB,EACAvI,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAgBA,OAdAkM,EAAAqB,KACA7H,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAAG,EACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoF,MACA,IAjDAT,CAkDA,IAsCAhO,EAAAmE,GAAAlK,UAAA,eAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAKA,IAHA/B,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,GAAA,EAAAA,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAgBAuS,GAAAxH,GAAAlK,UAAA,UAAA,WACA,OAAAyQ,KAAAgC,OACA,IAyCA1M,EAAAmE,GAAAlK,UAAA,OAAA,SAAAkU,EAAAZ,GACA,IAAAmB,EACA5B,EACAzT,EACAD,EACAmJ,EACA,IAAAkK,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAAiB,EAAA,oEAAA+P,IAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADArV,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAgC,UACAC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAA+R,GADA5I,EAAA4L,EAAAjT,KAAAqS,EAAAV,GAAAC,EAAA1T,GAAAA,EAAAsR,OAEAgE,EAAA,EAAAtV,GAAAkT,GAAA/J,GACAmM,EAAA,EAAAtV,EAAA,GAAAmT,GAAAhK,OACA,KAAAgG,GAAAhG,IAAA,IAAAA,EAAA3I,OAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAmM,EAAA,EAAAtV,GAAAmJ,EAAA,GACAmM,EAAA,EAAAtV,EAAA,GAAAmJ,EAAA,EAGA,CAEA,OAAAlJ,CACA,IAmCA2G,EAAAmE,GAAAlK,UAAA,UAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACA+B,EACAhM,EAEAzJ,EAEA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAhC,GAAAC,EAAA,GACA1T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IAEAyV,EAAAF,EAAAE,EADAhC,GAAAC,EAAA1T,GACAA,EAAAsR,MAEA,OAAAmE,CACA,IAmCA7O,EAAAmE,GAAAlK,UAAA,eAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACA+B,EACAhM,EAEAzJ,EAEA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAhC,GAAAC,EAAAjK,EAAA,GACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IAEAyV,EAAAF,EAAAE,EADAhC,GAAAC,EAAA1T,GACAA,EAAAsR,MAEA,OAAAmE,CACA,IAmDAzO,EAAA+D,GAAAlK,UAAA,WAAA,WACA,IAAA6S,EACAW,EACA5K,EACAiM,EACA1V,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAKA,IAHA0F,EAAA6H,KAAAgC,QACAI,EAAApC,KAAAiC,QACAmC,EAAA/G,GAAAlF,EAAA,GACAzJ,EAAA,EAAAA,EAAA0V,EAAA1V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAqU,EAAAX,EAAA,EAAA1T,GACA0T,EAAA,EAAA1T,GAAA0T,EAAA,EAAA5P,GACA4P,EAAA,EAAA5P,GAAAuQ,EACAA,EAAAX,EAAA,EAAA1T,EAAA,GACA0T,EAAA,EAAA1T,EAAA,GAAA0T,EAAA,EAAA5P,EAAA,GACA4P,EAAA,EAAA5P,EAAA,GAAAuQ,EAEA,OAAA/C,IACA,IAgEAtK,EAAA+D,GAAAlK,UAAA,OAAA,SAAAhB,GAEA,IAAA8V,EACArO,EACAoM,EACAW,EACAC,EACAoB,EACAvM,EACAnJ,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAGA,GADA2P,EAAApC,KAAAiC,QACArP,UAAA1D,OAAA,GAEA,IAAAyO,GADA3H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAAyK,GAAAlS,GAAA,CACA,GAAAyH,GAAAgK,KAAAgC,QACA,MAAA,IAAAO,WAAA7O,EAAA,kEAAAsC,IAKA,OAFAoM,EADApM,GAAA,GACA4L,GAAArT,QACA6T,EAAApM,EAAA,GAAA6L,GAAAtT,GAEA,CACA,GAAAwT,GAAAxT,GAAA,CAEA,GAAAyH,GADAoO,EAAA7V,EAAAyT,SACAhC,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAA9V,EAAA0T,QAGAzP,EAAA4P,EAAAd,WAAAtL,EAAA2K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAA9O,GACA6R,EAAA/C,WAAA+C,EAAA3B,WAAAlQ,EAEA,CAGA,IADAuQ,EAAA,IAAA/J,GAAAqL,EAAAnV,QACAR,EAAA,EAAAA,EAAA2V,EAAAnV,OAAAR,IACAqU,EAAArU,GAAA2V,EAAA3V,GAEA2V,EAAAtB,CACA,CAGA,IAFA/M,GAAA,EACAxD,EAAA,EACA9D,EAAA,EAAAA,EAAA0V,EAAA1V,IACA0T,EAAApM,GAAAqO,EAAA7R,GACA4P,EAAApM,EAAA,GAAAqO,EAAA7R,EAAA,GACAwD,GAAA,EACAxD,GAAA,CAGA,KAhCA,CAiCA,IAAAwL,GAAAzP,GA2DA,MAAA,IAAAkE,UAAAiB,EAAA,kIAAAnF,IAxDA,IADA6V,EAAA7V,EAAAW,OACAR,EAAA,EAAAA,EAAA0V,EAAA1V,IACA,IAAA+R,GAAAlS,EAAAG,IAAA,CACAsU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA0D,GACA,MAAA,IAAA7B,WAAA7O,EAAA,6GAAA0Q,IAEA,GAAApO,EAAAoO,EAAA,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAA9V,EAGAiE,EAAA4P,EAAAd,WAAAtL,EAAA2K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAA9O,GACA6R,EAAA/C,WAAA+C,EAAA3B,WAAAlQ,EAEA,CAGA,IADAuQ,EAAA,IAAA/J,GAAAoL,GACA1V,EAAA,EAAAA,EAAA0V,EAAA1V,IACAqU,EAAArU,GAAA2V,EAAA3V,GAEA2V,EAAAtB,CACA,CAIA,IAHA/M,GAAA,EACAoO,GAAA,EACA5R,EAAA,EACA9D,EAAA,EAAAA,EAAA0V,EAAA1V,IACA0T,EAAApM,GAAAqO,EAAA7R,GACA4P,EAAApM,EAAA,GAAAqO,EAAA7R,EAAA,GACAwD,GAAA,EACAxD,GAAA,EAEA,MACA,CAEA,GAAAwD,EAAAoO,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAGA,IADAvM,GAAA,EACAtH,EAAA,EAAAA,EAAA0V,EAAA1V,IACAmJ,EAAAtJ,EAAAG,GACA0T,EAAApM,GAAA4L,GAAA/J,GACAuK,EAAApM,EAAA,GAAA6L,GAAAhK,GACA7B,GAAA,CAxDA,CA+DA,IA2EAV,EAAAmE,GAAAlK,UAAA,SAAA,SAAA6T,EAAAI,GACA,IAAAc,EACAN,EACArV,EACAqH,EACAoM,EACAjK,EACAzJ,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAkU,EAAA,EACAI,EAAArL,MACA,CACA,IAAAmF,GAAA8F,GACA,MAAA,IAAA3Q,UAAAiB,EAAA,oEAAA0P,IAQA,GANAA,EAAA,IACAA,GAAAjL,GACA,IACAiL,EAAA,GAGA,IAAAxQ,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAQA,IANAmM,EADAlB,EAAAI,EACAA,EAAAJ,EAEA,EAGAY,GADArV,EAAA,IAAAqR,KAAAzH,YAAA+L,IACArC,QACAvT,EAAA,EAAAA,EAAA4V,EAAA5V,IACAsH,EAAA,GAAAtH,EAAA0U,GACAY,EAAA,EAAAtV,GAAA0T,EAAApM,GACAgO,EAAA,EAAAtV,EAAA,GAAA0T,EAAApM,EAAA,GAEA,OAAArH,CACA,IA+BA2G,EAAAmE,GAAAlK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,GAAAwJ,EAAA1H,KAAAqS,EAAAV,GAAAC,EAAA1T,GAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA6EAtK,EAAA+D,GAAAlK,UAAA,QAAA,SAAAgV,GACA,IAAAxB,EACAX,EACAjK,EACAzJ,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAKA,IAHAnC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACAe,EAAA,GACArU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAqU,EAAAtP,KAAA0O,GAAAC,EAAA1T,IAGA,IADAqU,EAAAyB,KAAAD,GACA7V,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAEA0T,EADA5P,EAAA,EAAA9D,GACAkT,GAAAmB,EAAArU,IACA0T,EAAA5P,EAAA,GAAAqP,GAAAkB,EAAArU,IAEA,OAAAsR,IACA,IA2EA1K,EAAAmE,GAAAlK,UAAA,YAAA,SAAAkV,EAAAjB,GACA,IAAApC,EACAgB,EACAjK,EACA,IAAA4J,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAuV,EAAA,EACAjB,EAAArL,MACA,CACA,IAAAmF,GAAAmH,GACA,MAAA,IAAAhS,UAAAiB,EAAA,oEAAA+Q,IAQA,GANAA,EAAA,IACAA,GAAAtM,GACA,IACAsM,EAAA,GAGA,IAAA7R,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAWA,OAVAsM,GAAAtM,GACAA,EAAA,EACAiJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACArL,EAAA,EACAiJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEAxI,EAAAqL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAAzH,YAAA6J,EAAAf,OAAAD,EAAAjJ,EAAA,EAAA,EAAAA,EACA,IAwBA7C,EAAAmE,GAAAlK,UAAA,kBAAA,SAAAmV,EAAAC,GACA,IAAAC,EACAC,EACAlW,EACAyT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA2V,EAAA,OACA,KAAAzG,GAAAsG,KAAAnG,GAAAmG,GAGA,MAAA,IAAAjS,UAAAiB,EAAA,yFAAAgR,IAFAG,EAAAH,CAGA,CACA,GAAA9R,UAAA1D,OAAA,EACA0V,EAAA,CAAA,MACA,KAAA1H,GAAAyH,GAGA,MAAA,IAAAlS,UAAAiB,EAAA,qEAAAiR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAA0O,GAAAC,EAAA1T,GAAAoW,eAAAD,EAAAD,IAEA,OAAAjW,EAAAmV,KAAA,IACA,IAmDApO,EAAA+D,GAAAlK,UAAA,cAAA,WACA,IAAAyU,EACArV,EACAwJ,EACAiK,EACA1T,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAMA,IAJA0F,EAAA6H,KAAAgC,QACArT,EAAA,IAAAqR,KAAAzH,YAAAJ,GACAiK,EAAApC,KAAAiC,QACA+B,EAAArV,EAAAsT,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAsV,EAAA,EAAAtV,GAAA0T,EAAA,EAAA5P,GACAwR,EAAA,EAAAtV,EAAA,GAAA0T,EAAA,EAAA5P,EAAA,GAEA,OAAA7D,CACA,IA6EA+G,EAAA+D,GAAAlK,UAAA,YAAA,SAAAgV,GACA,IAAAxB,EACAX,EACAjK,EACAzJ,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAKA,IAHAnC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACAe,EAAA,GACArU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAqU,EAAAtP,KAAA0O,GAAAC,EAAA1T,IAGA,OADAqU,EAAAyB,KAAAD,GACA,IAAA9K,GAAAsJ,EACA,IAoBArN,EAAA+D,GAAAlK,UAAA,YAAA,WACA,IAAAZ,EACAyT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,IAFA9D,EAAA,GACAyT,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAA0O,GAAAC,EAAA1T,GAAAyB,YAEA,OAAAxB,EAAAmV,KAAA,IACA,IA0CApO,EAAA+D,GAAAlK,UAAA,UAAA,WACA,IAAA+T,EACA3E,EACAxG,EACAlB,EACAmL,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAiBA,OAfAkM,EAAAqB,KACAoC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAA4T,GAAAC,EAAA1T,GACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoG,QACA,IAjDAzB,CAkDA,IAuCAhO,EAAAmE,GAAAlK,UAAA,QAAA,SAAAyV,EAAAzW,GACA,IAAA6T,EACAzT,EACAwJ,EACA,IAAA4J,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA6K,GAAA0H,GACA,MAAA,IAAAvS,UAAAiB,EAAA,oEAAAsR,IAMA,GAJA7M,EAAA6H,KAAAgC,QACAgD,EAAA,IACAA,GAAA7M,GAEA6M,EAAA,GAAAA,GAAA7M,EACA,MAAA,IAAAoK,WAAA7O,EAAA,kEAAAsR,IAEA,IAAAvE,GAAAlS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,2EAAAnF,IAMA,OAHA6T,GADAzT,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAiC,UACAA,SACA,EAAA+C,GAAApD,GAAArT,GACA6T,EAAA,EAAA4C,EAAA,GAAAnD,GAAAtT,GACAI,CACA,II15FA,IAAAgS,GAAA,EAAA1H,GAAA0H,kBACAmB,GAAAhB,KAYA,SAAAiB,GAAAxT,GACA,OACAA,aAAAmL,IAEA,iBAAAnL,GACA,OAAAA,IAEA,mBAAAA,EAAAgK,YAAAK,MACA,oBAAArK,EAAAgK,YAAAK,OAEA,iBAAArK,EAAAyT,SAGA,iBAAAzT,EAAA0T,OAGA,CASA,SAAAC,GAAA3T,GACA,OACAA,IAAAmL,IAGA,mBAAAnL,EAAAqK,IAEA,CAUA,SAAAqM,GAAA7C,EAAApM,GAEA,OAAA,IAAA6J,GAAAuC,EADApM,GAAA,GACAoM,EAAApM,EAAA,GACA,CAyEA,SAAA0D,KACA,IAAA4H,EACAe,EACAD,EACAjK,EAGA,GADAkK,EAAAzP,UAAA1D,SACA8Q,gBAAAtG,IACA,OAAA,IAAA2I,EACA,IAAA3I,GAEA,IAAA2I,EACA,IAAA3I,GAAA9G,UAAA,IAEA,IAAAyP,EACA,IAAA3I,GAAA9G,UAAA,GAAAA,UAAA,IAEA,IAAA8G,GAAA9G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAAyP,EACAD,EAAA,IAAAnJ,GAAA,QACA,GAAA,IAAAoJ,EACA,GAAA1E,GAAA/K,UAAA,IACAwP,EAAA,IAAAnJ,GAAA,EAAArG,UAAA,SACA,GAAAoL,GAAApL,UAAA,IAKA,IAHAuF,GADAiK,EAAAxP,UAAA,IACA1D,SAGA0C,GAAAwQ,IAAA3B,GAAA2B,EAAA,KAEA,GADAA,ECxLA,SAAoBA,EAAKrM,GACxB,IAAIoC,EACAN,EACAnJ,EACA8D,EAIJ,IAFA2F,EAAMpC,EAAI7G,OACVsD,EAAI,EACE9D,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,IAAM+R,GADN5I,EAAI9B,EAAKrH,IAER,OAAO,KAER0T,EAAK5P,GAAMsN,GAAMjI,GACjBuK,EAAK5P,EAAE,GAAMuN,GAAMlI,GACnBrF,GAAK,CACL,CACD,OAAO4P,CACR,CDsKAE,CAAA,IAAArJ,GAAA,EAAAd,GAAAiK,GACA,OAAAA,EAAA,CAEA,IAAA1B,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,6GAAAyE,IAGAiK,EAAA,IAAAnJ,GAAArG,UAAA,GACA,MACA,CACA,GAAAgO,GAAAwB,GACAA,EAAAI,GAAAJ,EAAA,QACA,GAAAvB,GAAAuB,GACAA,EAAAK,GAAAL,EAAA,QACA,IAAA1B,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,6HAAAyE,IAEAiK,EAAA,IAAAnJ,GAAAmJ,EACA,MACA,GAAAjE,GAAAvL,UAAA,IAAA,CAEA,IAAA0K,IADA8E,EAAAxP,UAAA,IACA8P,WAAA/B,IACA,MAAA,IAAA4B,WAAA7O,EAAA,yFAAAiN,GAAAyB,EAAAM,aAEAN,EAAA,IAAAnJ,GAAAmJ,EACA,KAAA,KAAAlF,GAAAtK,UAAA,IAkBA,MAAA,IAAAH,UAAAiB,EAAA,qHAAAd,UAAA,KAhBA,GADAwP,EAAAxP,UAAA,IACA,IAAAkP,GACA,MAAA,IAAArP,UAAAiB,EAAA,mJAAA0O,IAEA,IAAAzC,GAAAyC,EAAAO,KACA,MAAA,IAAAlQ,UAAAiB,EAAA,qHAAA0O,IAGA,IAAAzC,IADAyC,EAAAA,EAAAO,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,qHAAA0O,IAGA,IADAA,EAAAZ,GAAAY,cACAlS,MACA,MAAAkS,EAEAA,EAAA,IAAAnJ,GAAAmJ,EAGA,KACA,CAEA,IAAAjE,GADAiE,EAAAxP,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA0O,IAGA,IAAAzE,GADA2D,EAAA1O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA4N,IAEA,IAAAhE,GAAAgE,EAAAX,IACA,MAAA,IAAA4B,WAAA7O,EAAA,uEAAAiN,GAAAW,IAEA,GAAA,IAAAe,EAAA,CAEA,IAAA/E,IADAnF,EAAAiK,EAAAM,WAAApB,GACAX,IACA,MAAA,IAAA4B,WAAA7O,EAAA,oGAAAiN,GAAAxI,IAEAiK,EAAA,IAAAnJ,GAAAmJ,EAAAd,EACA,KAAA,CAEA,IAAA3D,GADAxF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAAwI,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAA7O,EAAA,iJAAAyE,EAAAwI,KAEAyB,EAAA,IAAAnJ,GAAAmJ,EAAAd,EAAA,EAAAnJ,EACA,CACA,CAIA,OAHA7C,EAAA0K,KAAA,UAAAoC,GACA9M,EAAA0K,KAAA,UAAAoC,EAAAlT,OAAA,GAEA8Q,IACA,CEzQA,SAASwB,GAAcC,GACtB,IAAI9S,EACAkJ,EAGJ,IADAlJ,EAAM,KAELkJ,EAAI4J,EAAGC,QACAC,MAGPhT,EAAI8E,KAAMiL,GAAS7G,EAAEtJ,QAEtB,OAAOI,CACR,CF2QA2G,EAAAoE,GAAA,oBAAAiH,IAeArL,EAAAoE,GAAA,OAAA,mBAmDAhE,EAAAgE,GAAA,QAAA,SAAAkJ,GACA,IAAAC,EACAR,EACAS,EACAnU,EACAyT,EACAW,EACA5N,EACAgD,EACA6K,EACAnL,EACAnJ,EACA8D,EACA,IAAAmN,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAyP,GAAAlC,MACA,MAAA,IAAAvN,UAAA,6DAGA,IADA4P,EAAAzP,UAAA1D,QACA,EAAA,CAEA,IAAAyQ,GADAmD,EAAAlQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAoP,IAEAT,EAAA,IACAQ,EAAAjQ,UAAA,GAEA,CACA,GAAAmP,GAAAa,GAAA,CAEA,GADAzK,EAAAyK,EAAA1T,OACA4T,EAAA,CAIA,IAFAV,GADAzT,EAAA,IAAAqR,KAAA7H,IACA8J,QACAzP,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAA+R,GADA5I,EAAAiL,EAAAtS,KAAAqS,EAAAD,EAAAzN,IAAAzG,GAAAA,IAEA0T,EAAA5P,GAAAsN,GAAAjI,GACAuK,EAAA5P,EAAA,GAAAuN,GAAAlI,OACA,MAAAgG,GAAAhG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAuK,EAAA5P,GAAAqF,EAAA,GACAuK,EAAA5P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAqR,KAAA4C,EACA,CACA,GAAA5E,GAAA4E,GAAA,CACA,GAAAE,EAAA,CAUA,IAPA3K,EAAAyK,EAAA1T,OAEAiG,EADAyN,EAAAzN,KAAAyN,EAAAxN,IACA6N,GAAA,WAEAtM,GAAA,WAGAjI,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA,IAAA+R,GAAAtL,EAAAyN,EAAAlU,IAAA,CACAsU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAAvI,GACA,MAAA,IAAAoK,WAAA7O,EAAA,gGAAAyE,IAIA,IADAiK,GADAzT,EAAA,IAAAqR,KAAA7H,EAAA,IACA8J,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAoU,EAAAtS,KAAAqS,EAAA1N,EAAAyN,EAAAlU,GAAAA,GAEA,OAAAC,CACA,CAKA,IAFAyT,GADAzT,EAAA,IAAAqR,KAAA7H,IACA8J,QACAzP,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAA+R,GADA5I,EAAAiL,EAAAtS,KAAAqS,EAAA1N,EAAAyN,EAAAlU,GAAAA,IAEA0T,EAAA5P,GAAAsN,GAAAjI,GACAuK,EAAA5P,EAAA,GAAAuN,GAAAlI,OACA,MAAAgG,GAAAhG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAuK,EAAA5P,GAAAqF,EAAA,GACAuK,EAAA5P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAqR,KAAA4C,EACA,CACA,GAAA1F,GAAA0F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,6FAAAkP,IAOA,GAJAG,EADAD,EG/bA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIlU,EACAkJ,EACAqJ,EACAxS,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI4J,EAAGC,QACAC,MAKP,GAFAjT,GAAK,EAEAmP,GADLqD,EAAI4B,EAAKtS,KAAMqS,EAAShL,EAAEtJ,MAAOG,KACFwS,EAAEhS,QAAU,EAC1CP,EAAI8E,KAAMyN,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAIzO,UAAWiB,EAAQ,+IAAgJwN,IAF9KvS,EAAI8E,KAAMqM,GAAMoB,GAAKnB,GAAMmB,GAG3B,CAEF,OAAOvS,CACR,CHwaAuU,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAEAW,aAAA7S,MACA,MAAA6S,EAKA,IADAX,GADAzT,EAAA,IAAAqR,KADA7H,EAAA4K,EAAA7T,OAAA,IAEA+S,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAqU,EAAArU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAkP,GACA,IAoBAtN,EAAAoE,GAAA,MAAA,WACA,IAAA/F,EACAjF,EACA,IAAAiR,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAyP,GAAAlC,MACA,MAAA,IAAAvN,UAAA,6DAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAsR,KAAArM,EACA,IAwDA+B,EAAAgE,GAAAnK,UAAA,MAAA,SAAAyG,GACA,IAAA+L,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA6K,GAAAtH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAKA,GAHAA,EAAA,IACAA,GAAAgK,KAAAgC,WAEAhM,EAAA,GAAAA,GAAAgK,KAAAgC,SAGA,OAAAiD,GAAAjF,KAAAiC,QAAAjM,EACA,IAgBAiL,GAAAvH,GAAAnK,UAAA,UAAA,WACA,OAAAyQ,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAAvH,GAAAnK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAS,UACA,IAgBAzB,GAAAvH,GAAAnK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAX,UACA,IAiBA5L,EAAAgE,GAAAnK,UAAA,oBAAAmK,GAAAiH,mBAuCArL,EAAAoE,GAAAnK,UAAA,cAAA,SAAA4T,EAAAC,GACA,IAAArB,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAQA,OALA,IAAAG,UAAA1D,OACA8Q,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,EAAA,EAAAxQ,UAAA,IAEAoN,IACA,IAqCAtK,EAAAgE,GAAAnK,UAAA,WAAA,WACA,IAAA8R,EACA1C,EACA2E,EACAnL,EACAlB,EACAvI,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAkBA,OAhBAkM,EAAAqB,KACAqB,EAAArB,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EACA8D,GAAA,EAIA8C,EADAgO,EAAA,CAAA,EACA,QAcA,WACA,IAAApC,EAEA,OADAxS,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,IAIAT,EAAA,IAAArB,GAAAwB,EADA7O,GAAA,GACA6O,EAAA7O,EAAA,IACA,CACAjE,MAAA,CAAAG,EAAAwS,GACAS,MAAA,GAEA,IA3BArM,EAAAgO,EAAA,UAoCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA7CAgB,IACArN,EAAAgO,EAAAX,IAoDA,WACA,OAAAhE,EAAA4E,SACA,IApDAD,CAqDA,IA+BAhO,EAAAoE,GAAAnK,UAAA,SAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,IAAAwJ,EAAA1H,KAAAqS,EAAAoC,GAAA7C,EAAA1T,GAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA2CA1K,EAAAoE,GAAAnK,UAAA,QAAA,SAAAhB,EAAA6U,EAAAI,GACA,IAAApB,EACAjK,EACAnC,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAlS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,0EAAAnF,IAIA,GAFA6T,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAA8F,GACA,MAAA,IAAA3Q,UAAAiB,EAAA,qEAAA0P,IAQA,GANAA,EAAA,IACAA,GAAAjL,GACA,IACAiL,EAAA,GAGAxQ,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,oEAAA8P,IAEAA,EAAA,IACAA,GAAArL,GACA,IACAqL,EAAA,GAGAA,EAAArL,IACAqL,EAAArL,EAEA,MACAqL,EAAArL,CAEA,MACAiL,EAAA,EACAI,EAAArL,EAIA,IAFA8H,EAAAH,GAAAvR,GACA2R,EAAAH,GAAAxR,GACAG,EAAA0U,EAAA1U,EAAA8U,EAAA9U,IAEA0T,EADApM,EAAA,EAAAtH,GACAuR,EACAmC,EAAApM,EAAA,GAAAkK,EAEA,OAAAF,IACA,IA2CA1K,EAAAoE,GAAAnK,UAAA,UAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAzT,EACAD,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAkK,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAwS,EAAA+D,GAAA7C,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,OACArR,EAAA8E,KAAAyN,GAGA,OAAA,IAAAlB,KAAAzH,YAAA5J,EACA,IAqCA2G,EAAAoE,GAAAnK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAwS,EAAA+D,GAAA7C,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAkB,CAGA,IA+BA5L,EAAAoE,GAAAnK,UAAA,aAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAwS,EAAA+D,GAAA7C,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IAqCA4G,EAAAoE,GAAAnK,UAAA,YAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAwS,EAAA+D,GAAA7C,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAkB,CAGA,IA+BA5L,EAAAoE,GAAAnK,UAAA,iBAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAwS,EAAA+D,GAAA7C,EAAA1T,GACAwJ,EAAA1H,KAAAqS,EAAA3B,EAAAxS,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IA4BA4G,EAAAoE,GAAAnK,UAAA,WAAA,SAAAkU,EAAAZ,GACA,IAAAT,EACA1T,EACAwS,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAAiB,EAAA,oEAAA+P,IAGA,IADArB,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAwS,EAAA+D,GAAA7C,EAAA1T,GACA+U,EAAAjT,KAAAqS,EAAA3B,EAAAxS,EAAAsR,KAEA,IAyCAtK,EAAAgE,GAAAnK,UAAA,OAAA,SAAAyG,GACA,IAAA+L,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkL,GAAA3H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAgK,KAAAgC,SAGA,OAAAiD,GAAAjF,KAAAiC,QAAAjM,EACA,IAgBAiL,GAAAvH,GAAAnK,UAAA,UAAA,WACA,OAAAyQ,KAAAgC,OACA,IAmCA1M,EAAAoE,GAAAnK,UAAA,YAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAA,EAGA,OAAA,CACA,IAmCAV,EAAAoE,GAAAnK,UAAA,WAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyBAgH,EAAAgE,GAAAnK,UAAA,QAAA,SAAAqU,GACA,IAAAjV,EACAyT,EACAyB,EACAnV,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA2U,EAAA,QACA,KAAAzF,GAAAwF,GAGA,MAAA,IAAAnR,UAAAiB,EAAA,kEAAAkQ,IAFAC,EAAAD,CAGA,CAGA,IAFAjV,EAAA,GACAyT,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAAwR,GAAA7C,EAAA1T,GAAAyB,YAEA,OAAAxB,EAAAmV,KAAAD,EACA,IA4BAnO,EAAAgE,GAAAnK,UAAA,QAAA,WACA,IAAAoP,EACA2E,EACAnL,EACAlB,EACAvI,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAgBA,OAdAkM,EAAAqB,KACA7H,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAAG,EACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoF,MACA,IAjDAT,CAkDA,IAsCAhO,EAAAoE,GAAAnK,UAAA,eAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACApM,EACAiK,EACAC,EACAxR,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAgO,GAAAiD,GACA,MAAA,IAAAjR,UAAAiB,EAAA,0EAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAKA,IAHA/B,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,GAAA,EAAAA,IAEA,GAAAuR,IAAAmC,EADApM,EAAA,EAAAtH,IACAwR,IAAAkC,EAAApM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyCA4G,EAAAoE,GAAAnK,UAAA,OAAA,SAAAkU,EAAAZ,GACA,IAAAmB,EACA5B,EACAzT,EACAD,EACAmJ,EACA,IAAAkK,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAAiB,EAAA,oEAAA+P,IAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADArV,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAgC,UACAC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GAAA+R,GADA5I,EAAA4L,EAAAjT,KAAAqS,EAAAoC,GAAA7C,EAAA1T,GAAAA,EAAAsR,OAEAgE,EAAA,EAAAtV,GAAAoR,GAAAjI,GACAmM,EAAA,EAAAtV,EAAA,GAAAqR,GAAAlI,OACA,KAAAgG,GAAAhG,IAAA,IAAAA,EAAA3I,OAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAmM,EAAA,EAAAtV,GAAAmJ,EAAA,GACAmM,EAAA,EAAAtV,EAAA,GAAAmJ,EAAA,EAGA,CAEA,OAAAlJ,CACA,IAmCA2G,EAAAoE,GAAAnK,UAAA,UAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACA+B,EACAhM,EAEAzJ,EAEA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAc,GAAA7C,EAAA,GACA1T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IAEAyV,EAAAF,EAAAE,EADAc,GAAA7C,EAAA1T,GACAA,EAAAsR,MAEA,OAAAmE,CACA,IAmCA7O,EAAAoE,GAAAnK,UAAA,eAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACA+B,EACAhM,EAEAzJ,EAEA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAc,GAAA7C,EAAAjK,EAAA,GACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IAEAyV,EAAAF,EAAAE,EADAc,GAAA7C,EAAA1T,GACAA,EAAAsR,MAEA,OAAAmE,CACA,IAmDAzO,EAAAgE,GAAAnK,UAAA,WAAA,WACA,IAAA6S,EACAW,EACA5K,EACAiM,EACA1V,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAKA,IAHA0F,EAAA6H,KAAAgC,QACAI,EAAApC,KAAAiC,QACAmC,EAAA/G,GAAAlF,EAAA,GACAzJ,EAAA,EAAAA,EAAA0V,EAAA1V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAqU,EAAAX,EAAA,EAAA1T,GACA0T,EAAA,EAAA1T,GAAA0T,EAAA,EAAA5P,GACA4P,EAAA,EAAA5P,GAAAuQ,EACAA,EAAAX,EAAA,EAAA1T,EAAA,GACA0T,EAAA,EAAA1T,EAAA,GAAA0T,EAAA,EAAA5P,EAAA,GACA4P,EAAA,EAAA5P,EAAA,GAAAuQ,EAEA,OAAA/C,IACA,IAgEAtK,EAAAgE,GAAAnK,UAAA,OAAA,SAAAhB,GAEA,IAAA8V,EACArO,EACAoM,EACAW,EACAC,EACAoB,EACAvM,EACAnJ,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAGA,GADA2P,EAAApC,KAAAiC,QACArP,UAAA1D,OAAA,GAEA,IAAAyO,GADA3H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAAyK,GAAAlS,GAAA,CACA,GAAAyH,GAAAgK,KAAAgC,QACA,MAAA,IAAAO,WAAA7O,EAAA,kEAAAsC,IAKA,OAFAoM,EADApM,GAAA,GACA8J,GAAAvR,QACA6T,EAAApM,EAAA,GAAA+J,GAAAxR,GAEA,CACA,GAAAwT,GAAAxT,GAAA,CAEA,GAAAyH,GADAoO,EAAA7V,EAAAyT,SACAhC,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAA9V,EAAA0T,QAGAzP,EAAA4P,EAAAd,WAAAtL,EAAA2K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAA9O,GACA6R,EAAA/C,WAAA+C,EAAA3B,WAAAlQ,EAEA,CAGA,IADAuQ,EAAA,IAAA9J,GAAAoL,EAAAnV,QACAR,EAAA,EAAAA,EAAA2V,EAAAnV,OAAAR,IACAqU,EAAArU,GAAA2V,EAAA3V,GAEA2V,EAAAtB,CACA,CAGA,IAFA/M,GAAA,EACAxD,EAAA,EACA9D,EAAA,EAAAA,EAAA0V,EAAA1V,IACA0T,EAAApM,GAAAqO,EAAA7R,GACA4P,EAAApM,EAAA,GAAAqO,EAAA7R,EAAA,GACAwD,GAAA,EACAxD,GAAA,CAGA,KAhCA,CAiCA,IAAAwL,GAAAzP,GA2DA,MAAA,IAAAkE,UAAAiB,EAAA,kIAAAnF,IAxDA,IADA6V,EAAA7V,EAAAW,OACAR,EAAA,EAAAA,EAAA0V,EAAA1V,IACA,IAAA+R,GAAAlS,EAAAG,IAAA,CACAsU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA0D,GACA,MAAA,IAAA7B,WAAA7O,EAAA,6GAAA0Q,IAEA,GAAApO,EAAAoO,EAAA,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAA9V,EAGAiE,EAAA4P,EAAAd,WAAAtL,EAAA2K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAA9O,GACA6R,EAAA/C,WAAA+C,EAAA3B,WAAAlQ,EAEA,CAGA,IADAuQ,EAAA,IAAA9J,GAAAmL,GACA1V,EAAA,EAAAA,EAAA0V,EAAA1V,IACAqU,EAAArU,GAAA2V,EAAA3V,GAEA2V,EAAAtB,CACA,CAIA,IAHA/M,GAAA,EACAoO,GAAA,EACA5R,EAAA,EACA9D,EAAA,EAAAA,EAAA0V,EAAA1V,IACA0T,EAAApM,GAAAqO,EAAA7R,GACA4P,EAAApM,EAAA,GAAAqO,EAAA7R,EAAA,GACAwD,GAAA,EACAxD,GAAA,EAEA,MACA,CAEA,GAAAwD,EAAAoO,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAGA,IADAvM,GAAA,EACAtH,EAAA,EAAAA,EAAA0V,EAAA1V,IACAmJ,EAAAtJ,EAAAG,GACA0T,EAAApM,GAAA8J,GAAAjI,GACAuK,EAAApM,EAAA,GAAA+J,GAAAlI,GACA7B,GAAA,CAxDA,CA+DA,IA2EAV,EAAAoE,GAAAnK,UAAA,SAAA,SAAA6T,EAAAI,GACA,IAAAc,EACAN,EACArV,EACAqH,EACAoM,EACAjK,EACAzJ,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAkU,EAAA,EACAI,EAAArL,MACA,CACA,IAAAmF,GAAA8F,GACA,MAAA,IAAA3Q,UAAAiB,EAAA,oEAAA0P,IAQA,GANAA,EAAA,IACAA,GAAAjL,GACA,IACAiL,EAAA,GAGA,IAAAxQ,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAQA,IANAmM,EADAlB,EAAAI,EACAA,EAAAJ,EAEA,EAGAY,GADArV,EAAA,IAAAqR,KAAAzH,YAAA+L,IACArC,QACAvT,EAAA,EAAAA,EAAA4V,EAAA5V,IACAsH,EAAA,GAAAtH,EAAA0U,GACAY,EAAA,EAAAtV,GAAA0T,EAAApM,GACAgO,EAAA,EAAAtV,EAAA,GAAA0T,EAAApM,EAAA,GAEA,OAAArH,CACA,IA+BA2G,EAAAoE,GAAAnK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,GAAAwJ,EAAA1H,KAAAqS,EAAAoC,GAAA7C,EAAA1T,GAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA6EAtK,EAAAgE,GAAAnK,UAAA,QAAA,SAAAgV,GACA,IAAAxB,EACAX,EACAjK,EACAzJ,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAKA,IAHAnC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACAe,EAAA,GACArU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAqU,EAAAtP,KAAAwR,GAAA7C,EAAA1T,IAGA,IADAqU,EAAAyB,KAAAD,GACA7V,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAEA0T,EADA5P,EAAA,EAAA9D,GACAoR,GAAAiD,EAAArU,IACA0T,EAAA5P,EAAA,GAAAuN,GAAAgD,EAAArU,IAEA,OAAAsR,IACA,IA2EA1K,EAAAoE,GAAAnK,UAAA,YAAA,SAAAkV,EAAAjB,GACA,IAAApC,EACAgB,EACAjK,EACA,IAAA4J,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAuV,EAAA,EACAjB,EAAArL,MACA,CACA,IAAAmF,GAAAmH,GACA,MAAA,IAAAhS,UAAAiB,EAAA,oEAAA+Q,IAQA,GANAA,EAAA,IACAA,GAAAtM,GACA,IACAsM,EAAA,GAGA,IAAA7R,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAWA,OAVAsM,GAAAtM,GACAA,EAAA,EACAiJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACArL,EAAA,EACAiJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEAxI,EAAAqL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAAzH,YAAA6J,EAAAf,OAAAD,EAAAjJ,EAAA,EAAA,EAAAA,EACA,IAwBA7C,EAAAoE,GAAAnK,UAAA,kBAAA,SAAAmV,EAAAC,GACA,IAAAC,EACAC,EACAlW,EACAyT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA2V,EAAA,OACA,KAAAzG,GAAAsG,KAAAnG,GAAAmG,GAGA,MAAA,IAAAjS,UAAAiB,EAAA,yFAAAgR,IAFAG,EAAAH,CAGA,CACA,GAAA9R,UAAA1D,OAAA,EACA0V,EAAA,CAAA,MACA,KAAA1H,GAAAyH,GAGA,MAAA,IAAAlS,UAAAiB,EAAA,qEAAAiR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAAwR,GAAA7C,EAAA1T,GAAAoW,eAAAD,EAAAD,IAEA,OAAAjW,EAAAmV,KAAA,IACA,IAmDApO,EAAAgE,GAAAnK,UAAA,cAAA,WACA,IAAAyU,EACArV,EACAwJ,EACAiK,EACA1T,EACA8D,EACA,IAAAuP,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAMA,IAJA0F,EAAA6H,KAAAgC,QACArT,EAAA,IAAAqR,KAAAzH,YAAAJ,GACAiK,EAAApC,KAAAiC,QACA+B,EAAArV,EAAAsT,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAsV,EAAA,EAAAtV,GAAA0T,EAAA,EAAA5P,GACAwR,EAAA,EAAAtV,EAAA,GAAA0T,EAAA,EAAA5P,EAAA,GAEA,OAAA7D,CACA,IA6EA+G,EAAAgE,GAAAnK,UAAA,YAAA,SAAAgV,GACA,IAAAxB,EACAX,EACAjK,EACAzJ,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAAkN,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAKA,IAHAnC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACAe,EAAA,GACArU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAqU,EAAAtP,KAAAwR,GAAA7C,EAAA1T,IAGA,OADAqU,EAAAyB,KAAAD,GACA,IAAA7K,GAAAqJ,EACA,IAoBArN,EAAAgE,GAAAnK,UAAA,YAAA,WACA,IAAAZ,EACAyT,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAIA,IAFA9D,EAAA,GACAyT,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAAwR,GAAA7C,EAAA1T,GAAAyB,YAEA,OAAAxB,EAAAmV,KAAA,IACA,IA0CApO,EAAAgE,GAAAnK,UAAA,UAAA,WACA,IAAA+T,EACA3E,EACAxG,EACAlB,EACAmL,EACA1T,EACA,IAAAqT,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAiBA,OAfAkM,EAAAqB,KACAoC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAA0W,GAAA7C,EAAA1T,GACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoG,QACA,IAjDAzB,CAkDA,IAuCAhO,EAAAoE,GAAAnK,UAAA,QAAA,SAAAyV,EAAAzW,GACA,IAAA6T,EACAzT,EACAwJ,EACA,IAAA4J,GAAA/B,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA6K,GAAA0H,GACA,MAAA,IAAAvS,UAAAiB,EAAA,oEAAAsR,IAMA,GAJA7M,EAAA6H,KAAAgC,QACAgD,EAAA,IACAA,GAAA7M,GAEA6M,EAAA,GAAAA,GAAA7M,EACA,MAAA,IAAAoK,WAAA7O,EAAA,kEAAAsR,IAEA,IAAAvE,GAAAlS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,2EAAAnF,IAMA,OAHA6T,GADAzT,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAiC,UACAA,SACA,EAAA+C,GAAAlF,GAAAvR,GACA6T,EAAA,EAAA4C,EAAA,GAAAjF,GAAAxR,GACAI,CACA,IIr6FA,IAAAgS,GAAApH,GAAAoH,kBACAmB,GAAAhB,KAYA,SAAAoE,GAAA3W,GACA,MACA,iBAAAA,GACA,OAAAA,GACA,iBAAAA,EAAAgK,YAAAK,MACArK,EAAAoS,oBAAAA,EAEA,CASA,SAAAwE,GAAA5W,GACA,OAAAA,IAAAoL,EACA,CAoEA,SAAAA,KACA,IAAA2H,EACAe,EACAD,EACAjK,EACApI,EAGA,GADAsS,EAAAzP,UAAA1D,SACA8Q,gBAAArG,IACA,OAAA,IAAA0I,EACA,IAAA1I,GAEA,IAAA0I,EACA,IAAA1I,GAAA/G,UAAA,IAEA,IAAAyP,EACA,IAAA1I,GAAA/G,UAAA,GAAAA,UAAA,IAEA,IAAA+G,GAAA/G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAAyP,EACAD,EAAA,IAAA7I,GAAA,QACA,GAAA,IAAA8I,EAEA,GAAA1E,GADA5N,EAAA6C,UAAA,IAEAwP,EAAA,IAAA7I,GAAAxJ,QACA,GAAAiO,GAAAjO,GACAqS,EC9IA,SAAoBA,EAAKrM,GACxB,IAAIoC,EACAzJ,EAGJ,IADAyJ,EAAMpC,EAAI7G,OACJR,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB0T,EAAK1T,GAAMgQ,GAAS3I,EAAKrH,IAE1B,OAAO0T,CACR,CDqIAE,CAAA,IAAA/I,GAAAxJ,EAAAb,QAAAa,QACA,GAAAoO,GAAApO,GACAqS,EAAA,IAAA7I,GAAAxJ,OACA,KAAAmN,GAAAnN,GAaA,MAAA,IAAA0C,UAAAiB,EAAA,qHAAA3D,IAZA,IAAA,IAAA+R,GACA,MAAA,IAAArP,UAAAiB,EAAA,mJAAA3D,IAEA,IAAA4P,GAAA5P,EAAA4S,KACA,MAAA,IAAAlQ,UAAAiB,EAAA,qHAAA3D,IAGA,IAAA4P,IADAyC,EAAArS,EAAA4S,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,qHAAA3D,IAEAqS,EAAA,IAAA7I,GAAAiI,GAAAY,GAGA,KACA,CAEA,IAAAjE,GADAiE,EAAAxP,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA0O,IAGA,IAAAzE,GADA2D,EAAA1O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA4N,IAEA,GAAA,IAAAe,EACAD,EAAA,IAAA7I,GAAA6I,EAAAd,OACA,CAEA,IAAA3D,GADAxF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAAwI,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAA7O,EAAA,iJAAAyE,EAAAwI,KAEAyB,EAAA,IAAA7I,GAAA6I,EAAAd,EAAAnJ,EACA,CACA,CAIA,OAHA7C,EAAA0K,KAAA,UAAAoC,GACA9M,EAAA0K,KAAA,UAAAoC,EAAAlT,QAEA8Q,IACA,CAeA1K,EAAAqE,GAAA,oBAAAgH,IAeArL,EAAAqE,GAAA,OAAA,gBAmCAjE,EAAAiE,GAAA,QAAA,SAAAiJ,GACA,IAAAC,EACAR,EACAS,EACAnU,EACAyT,EACAW,EACA5N,EACAgD,EACAzJ,EACA,IAAAiR,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA0S,GAAAnF,MACA,MAAA,IAAAvN,UAAA,sDAGA,IADA4P,EAAAzP,UAAA1D,QACA,EAAA,CAEA,IAAAyQ,GADAmD,EAAAlQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAoP,IAEAT,EAAA,IACAQ,EAAAjQ,UAAA,GAEA,CACA,GAAAoL,GAAA4E,GAAA,CACA,GAAAE,EAAA,CASA,IARA3K,EAAAyK,EAAA1T,OAEAiG,EADAyN,EAAAzN,KAAAyN,EAAAxN,IACA6N,GAAA,WAEAtM,GAAA,WAGAyL,GADAzT,EAAA,IAAAqR,KAAA7H,IACA8J,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAgQ,GAAAoE,EAAAtS,KAAAqS,EAAA1N,EAAAyN,EAAAlU,GAAAA,IAEA,OAAAC,CACA,CACA,OAAA,IAAAqR,KAAA4C,EACA,CACA,GAAA1F,GAAA0F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAAjP,UAAAiB,EAAA,6FAAAkP,IAUA,IAPAG,EADAD,EE1SA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIlU,EACAkJ,EACAnJ,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI4J,EAAGC,QACAC,MAGPjT,GAAK,EACLC,EAAI8E,KAAMiL,GAASoE,EAAKtS,KAAMqS,EAAShL,EAAEtJ,MAAOG,KAEjD,OAAOC,CACR,CF2RAuU,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAIAA,GADAzT,EAAA,IAAAqR,KADA7H,EAAA4K,EAAA7T,SAEA+S,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA0T,EAAA1T,GAAAqU,EAAArU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAkP,GACA,IAoBAtN,EAAAqE,GAAA,MAAA,WACA,IAAAhG,EACAjF,EACA,IAAAiR,GAAAK,MACA,MAAA,IAAAvN,UAAA,6DAEA,IAAA0S,GAAAnF,MACA,MAAA,IAAAvN,UAAA,sDAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAsR,KAAArM,EACA,IA6BA+B,EAAAiE,GAAApK,UAAA,MAAA,SAAAyG,GACA,IAAAoM,EACAjK,EAEA,IAAA+M,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA6K,GAAAtH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAOA,GALAmC,EAAA6H,KAAAgC,QACAI,EAAApC,KAAAiC,QACAjM,EAAA,IACAA,GAAAmC,KAEAnC,EAAA,GAAAA,GAAAmC,GAGA,OAAAuG,GAAA0D,EAAApM,GACA,IAgBAiL,GAAAtH,GAAApK,UAAA,UAAA,WACA,OAAAyQ,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAAtH,GAAApK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAS,UACA,IAgBAzB,GAAAtH,GAAApK,UAAA,cAAA,WACA,OAAAyQ,KAAAiC,QAAAX,UACA,IAiBA5L,EAAAiE,GAAApK,UAAA,oBAAAoK,GAAAgH,mBA+BArL,EAAAqE,GAAApK,UAAA,cAAA,SAAA4T,EAAAC,GACA,IAAA8B,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAQA,OALA,IAAAG,UAAA1D,OACA8Q,KAAAiC,QAAAoB,WAAAF,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAAF,EAAAC,EAAAxQ,UAAA,IAEAoN,IACA,IAgCAtK,EAAAiE,GAAApK,UAAA,WAAA,WACA,IAAAoP,EACA2E,EACAnL,EACAiK,EACAnL,EACAvI,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAiBA,OAfAkM,EAAAqB,KACAoC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAA,CAAAG,EAAAgQ,GAAA0D,EAAA1T,KACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAA4E,SACA,IAjDAD,CAkDA,IA4BAhO,EAAAqE,GAAApK,UAAA,SAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,IAAAwJ,EAAA1H,KAAAqS,EAAAnE,GAAA0D,EAAA1T,IAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA+BA1K,EAAAqE,GAAApK,UAAA,QAAA,SAAAhB,EAAA6U,EAAAI,GACA,IAAApB,EACAjK,EACAiN,EACA1W,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA+L,GAAAjQ,GACA,MAAA,IAAAkE,UAAAiB,EAAA,mEAAAnF,IAIA,GAFA6T,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAA8F,GACA,MAAA,IAAA3Q,UAAAiB,EAAA,qEAAA0P,IAQA,GANAA,EAAA,IACAA,GAAAjL,GACA,IACAiL,EAAA,GAGAxQ,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,oEAAA8P,IAEAA,EAAA,IACAA,GAAArL,GACA,IACAqL,EAAA,GAGAA,EAAArL,IACAqL,EAAArL,EAEA,MACAqL,EAAArL,CAEA,MACAiL,EAAA,EACAI,EAAArL,EAOA,IAJAiN,EADA7W,EACA,EAEA,EAEAG,EAAA0U,EAAA1U,EAAA8U,EAAA9U,IACA0T,EAAA1T,GAAA0W,EAEA,OAAApF,IACA,IAqCA1K,EAAAqE,GAAApK,UAAA,UAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAzT,EACAD,EACAmJ,EAEA,IAAAqN,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAkK,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAmJ,EAAA6G,GAAA0D,EAAA1T,IACAwJ,EAAA1H,KAAAqS,EAAAhL,EAAAnJ,EAAAsR,OACArR,EAAA8E,KAAAoE,GAGA,OAAA,IAAAmI,KAAAzH,YAAA5J,EACA,IA4BA2G,EAAAqE,GAAApK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAvK,EACAnJ,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAmJ,EAAA6G,GAAA0D,EAAA1T,IACAwJ,EAAA1H,KAAAqS,EAAAhL,EAAAnJ,EAAAsR,MACA,OAAAnI,CAGA,IA4BAvC,EAAAqE,GAAApK,UAAA,aAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAvK,EACAnJ,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IAEA,GADAmJ,EAAA6G,GAAA0D,EAAA1T,IACAwJ,EAAA1H,KAAAqS,EAAAhL,EAAAnJ,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IA4BA4G,EAAAqE,GAAApK,UAAA,YAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAvK,EACAnJ,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAmJ,EAAA6G,GAAA0D,EAAA1T,IACAwJ,EAAA1H,KAAAqS,EAAAhL,EAAAnJ,EAAAsR,MACA,OAAAnI,CAGA,IA4BAvC,EAAAqE,GAAApK,UAAA,iBAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACAvK,EACAnJ,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAAsR,KAAAgC,QAAA,EAAAtT,GAAA,EAAAA,IAEA,GADAmJ,EAAA6G,GAAA0D,EAAA1T,IACAwJ,EAAA1H,KAAAqS,EAAAhL,EAAAnJ,EAAAsR,MACA,OAAAtR,EAGA,OAAA,CACA,IA0BA4G,EAAAqE,GAAApK,UAAA,WAAA,SAAAkU,EAAAZ,GACA,IAAAT,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAAiB,EAAA,oEAAA+P,IAGA,IADArB,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA+U,EAAAjT,KAAAqS,EAAAnE,GAAA0D,EAAA1T,IAAAA,EAAAsR,KAEA,IA2BAtK,EAAAiE,GAAApK,UAAA,OAAA,SAAAyG,GACA,IAAAkP,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkL,GAAA3H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAgK,KAAAgC,SAGA,OAAAtD,GAAAsB,KAAAiC,QAAAjM,GACA,IA8BAV,EAAAqE,GAAApK,UAAA,YAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA+L,GAAAkF,GACA,MAAA,IAAAjR,UAAAiB,EAAA,mEAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAGA,IADAvB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IACA,GAAAgV,IAAAhF,GAAA0D,EAAA1T,IACA,OAAA,EAGA,OAAA,CACA,IAiCA4G,EAAAqE,GAAApK,UAAA,WAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA+L,GAAAkF,GACA,MAAA,IAAAjR,UAAAiB,EAAA,mEAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAGA,IADAvB,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,EAAAsR,KAAAgC,QAAAtT,IACA,GAAAgV,IAAAhF,GAAA0D,EAAA1T,IACA,OAAAA,EAGA,OAAA,CACA,IA0BAgH,EAAAiE,GAAApK,UAAA,QAAA,SAAAqU,GACA,IAAAxB,EACAzT,EACAD,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,GAAAG,UAAA1D,OAAA,GACA,IAAAkP,GAAAwF,GACA,MAAA,IAAAnR,UAAAiB,EAAA,kEAAAkQ,SAGAA,EAAA,IAIA,IAFAxB,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA0T,EAAA1T,GACAC,EAAA8E,KAAA,QAEA9E,EAAA8E,KAAA,SAGA,OAAA9E,EAAAmV,KAAAF,EACA,IA4BAlO,EAAAiE,GAAApK,UAAA,QAAA,WACA,IAAAoP,EACA2E,EACAnL,EACAlB,EACAvI,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAgBA,OAdAkM,EAAAqB,KACA7H,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAAG,EACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoF,MACA,IAjDAT,CAkDA,IAiCAhO,EAAAqE,GAAApK,UAAA,eAAA,SAAAmU,EAAAC,GACA,IAAAvB,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA+L,GAAAkF,GACA,MAAA,IAAAjR,UAAAiB,EAAA,mEAAAgQ,IAEA,GAAA9Q,UAAA1D,OAAA,EAAA,CACA,IAAAoO,GAAAqG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAGA,IADAI,EAAApC,KAAAiC,QACAvT,EAAAiV,EAAAjV,GAAA,EAAAA,IACA,GAAAgV,IAAAhF,GAAA0D,EAAA1T,IACA,OAAAA,EAGA,OAAA,CACA,IAgBAuS,GAAAtH,GAAApK,UAAA,UAAA,WACA,OAAAyQ,KAAAgC,OACA,IAqCA1M,EAAAqE,GAAApK,UAAA,OAAA,SAAAkU,EAAAZ,GACA,IAAAmB,EACArV,EACAyT,EACA1T,EACA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAA8D,GACA,MAAA,IAAAhR,UAAA,oEAAAgR,GAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADArV,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAgC,UACAC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAsV,EAAAtV,GAAAgQ,GAAA+E,EAAAjT,KAAAqS,EAAAnE,GAAA0D,EAAA1T,IAAAA,EAAAsR,OAEA,OAAArR,CACA,IA+BA2G,EAAAqE,GAAApK,UAAA,UAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACAjK,EACAgM,EACAzV,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAzF,GAAA0D,EAAA,IACA1T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IACAyV,EAAAF,EAAAE,EAAAzF,GAAA0D,EAAA1T,IAAAA,EAAAsR,MAEA,OAAAmE,CACA,IA+BA7O,EAAAqE,GAAApK,UAAA,eAAA,SAAA0U,EAAAC,GACA,IAAA9B,EACAjK,EACAgM,EACAzV,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAsE,GACA,MAAA,IAAAxR,UAAAiB,EAAA,oEAAAuQ,IAIA,GAFA7B,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACApP,UAAA1D,OAAA,EACAiV,EAAAD,EACAxV,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAiU,EAAAzF,GAAA0D,EAAAjK,EAAA,IACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IACAyV,EAAAF,EAAAE,EAAAzF,GAAA0D,EAAA1T,IAAAA,EAAAsR,MAEA,OAAAmE,CACA,IA8BAzO,EAAAiE,GAAApK,UAAA,WAAA,WACA,IAAA6S,EACAW,EACA5K,EACAiM,EACA1V,EACA8D,EAEA,IAAA0S,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAKA,IAHA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACAoC,EAAA/G,GAAAlF,EAAA,GACAzJ,EAAA,EAAAA,EAAA0V,EAAA1V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAqU,EAAAX,EAAA1T,GACA0T,EAAA1T,GAAA0T,EAAA5P,GACA4P,EAAA5P,GAAAuQ,EAEA,OAAA/C,IACA,IA+CAtK,EAAAiE,GAAApK,UAAA,OAAA,SAAAhB,GACA,IAAA8V,EACArO,EACAoM,EACAW,EACAqB,EACA1V,EACA8D,EACA,IAAA0S,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAGA,GADA2P,EAAApC,KAAAiC,QACArP,UAAA1D,OAAA,GAEA,IAAAyO,GADA3H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAAgI,GAAAzP,GAAA,CAEA,GAAAyH,GADAoO,EAAA7V,EAAAW,QACA8Q,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FASA,GANA8B,EADAa,GAAA3W,GACAA,EAAA0T,QAEA1T,EAGAiE,EAAA4P,EAAAd,WAAAtL,EAAA2K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAA9O,GACA6R,EAAA/C,WAAA+C,EAAA3B,WAAAlQ,EAEA,CAGA,IADAuQ,EAAA,IAAAxJ,GAAA8K,EAAAnV,QACAR,EAAA,EAAAA,EAAA2V,EAAAnV,OAAAR,IACAqU,EAAArU,GAAA2V,EAAA3V,GAEA2V,EAAAtB,CACA,CACA,IAAArU,EAAA,EAAAA,EAAA0V,EAAApO,IAAAtH,IACA0T,EAAApM,GAAAqO,EAAA3V,GAAA,EAAA,CAGA,KA9BA,CA+BA,GAAAsH,GAAAgK,KAAAgC,QACA,MAAA,IAAAO,WAAA7O,EAAA,kEAAAsC,IAEAoM,EAAApM,GAAA,EAAA,EAAA,CAJA,CAKA,IAgDAV,EAAAqE,GAAApK,UAAA,SAAA,SAAAkV,EAAAjB,GACA,IAAAc,EACAN,EACArV,EACAyT,EACAjK,EACAzJ,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAuV,EAAA,EACAjB,EAAArL,MACA,CACA,IAAAmF,GAAAmH,GACA,MAAA,IAAAhS,UAAAiB,EAAA,oEAAA+Q,IAQA,GANAA,EAAA,IACAA,GAAAtM,GACA,IACAsM,EAAA,GAGA,IAAA7R,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAQA,IANAmM,EADAG,EAAAjB,EACAA,EAAAiB,EAEA,EAGAT,GADArV,EAAA,IAAAqR,KAAAzH,YAAA+L,IACArC,QACAvT,EAAA,EAAAA,EAAA4V,EAAA5V,IACAsV,EAAAtV,GAAA0T,EAAA1T,EAAA+V,GAEA,OAAA9V,CACA,IA4BA2G,EAAAqE,GAAApK,UAAA,QAAA,SAAA2I,EAAA2K,GACA,IAAAT,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAAkN,GAAAzH,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAkK,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA,GAAAwJ,EAAA1H,KAAAqS,EAAAnE,GAAA0D,EAAA1T,IAAAA,EAAAsR,MACA,OAAA,EAGA,OAAA,CACA,IA4CAtK,EAAAiE,GAAApK,UAAA,QAAA,SAAAgV,GACA,IAAAnC,EAEA,IAAA8C,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAGA,GADA2P,EAAApC,KAAAiC,QACA,IAAArP,UAAA1D,OAEA,OADAkT,EAAAoC,OACAxE,KAEA,IAAAL,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAGA,OADAnC,EAAAoC,MAWA,SAAAa,EAAAC,GACA,OAAAf,EAAA7F,GAAA2G,GAAA3G,GAAA4G,GACA,IAZAtF,IAaA,IAgDA1K,EAAAqE,GAAApK,UAAA,YAAA,SAAAkV,EAAAjB,GACA,IAAApC,EACAgB,EACAjK,EAEA,IAAA+M,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAIA,GAFA2P,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QACA,IAAApP,UAAA1D,OACAuV,EAAA,EACAjB,EAAArL,MACA,CACA,IAAAmF,GAAAmH,GACA,MAAA,IAAAhS,UAAAiB,EAAA,oEAAA+Q,IAQA,GANAA,EAAA,IACAA,GAAAtM,GACA,IACAsM,EAAA,GAGA,IAAA7R,UAAA1D,OACAsU,EAAArL,MACA,CACA,IAAAmF,GAAAkG,GACA,MAAA,IAAA/Q,UAAAiB,EAAA,qEAAA8P,IAEAA,EAAA,GACAA,GAAArL,GACA,IACAqL,EAAA,GAEAA,EAAArL,IACAqL,EAAArL,EAEA,CACA,CAWA,OAVAsM,GAAAtM,GACAA,EAAA,EACAiJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACArL,EAAA,EACAiJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEAxI,EAAAqL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAAzH,YAAA6J,EAAAf,OAAAD,EAAAjJ,EAAA,EAAA,EAAAA,EACA,IAyBA7C,EAAAqE,GAAApK,UAAA,kBAAA,SAAAmV,EAAAC,GACA,IAAAC,EACAC,EACAlW,EACAyT,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,GAAA,IAAAG,UAAA1D,OACA2V,EAAA,OACA,KAAAzG,GAAAsG,KAAAnG,GAAAmG,GAGA,MAAA,IAAAjS,UAAAiB,EAAA,yFAAAgR,IAFAG,EAAAH,CAGA,CACA,GAAA9R,UAAA1D,OAAA,EACA0V,EAAA,CAAA,MACA,KAAA1H,GAAAyH,GAGA,MAAA,IAAAlS,UAAAiB,EAAA,qEAAAiR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAtT,EAAA,GACAD,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACAC,EAAA8E,KAAAiL,GAAA0D,EAAA1T,IAAAoW,eAAAD,EAAAD,IAEA,OAAAjW,EAAAmV,KAAA,IACA,IA8BApO,EAAAiE,GAAApK,UAAA,cAAA,WACA,IAAAyU,EACArV,EACAwJ,EACAiK,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAMA,IAJA0F,EAAA6H,KAAAgC,QACArT,EAAA,IAAAqR,KAAAzH,YAAAJ,GACAiK,EAAApC,KAAAiC,QACA+B,EAAArV,EAAAsT,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAsV,EAAAtV,GAAA0T,EAAAjK,EAAAzJ,EAAA,GAEA,OAAAC,CACA,IA6CA+G,EAAAiE,GAAApK,UAAA,YAAA,SAAAgV,GACA,IAAAP,EACArV,EACAwJ,EACAiK,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAMA,IAJA0F,EAAA6H,KAAAgC,QACArT,EAAA,IAAAqR,KAAAzH,YAAAJ,GACAiK,EAAApC,KAAAiC,QACA+B,EAAArV,EAAAsT,QACAvT,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAsV,EAAAtV,GAAA0T,EAAA1T,GAEA,GAAA,IAAAkE,UAAA1D,OAEA,OADA8U,EAAAQ,OACA7V,EAEA,IAAAgR,GAAA4E,GACA,MAAA,IAAA9R,UAAAiB,EAAA,oEAAA6Q,IAGA,OADAP,EAAAQ,MAWA,SAAAa,EAAAC,GACA,OAAAf,EAAA7F,GAAA2G,GAAA3G,GAAA4G,GACA,IAZA3W,CAaA,IAqBA+G,EAAAiE,GAAApK,UAAA,YAAA,WACA,IAAAZ,EACAyT,EACA1T,EACA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAIA,IAFA9D,EAAA,GACAyT,EAAApC,KAAAiC,QACAvT,EAAA,EAAAA,EAAAsR,KAAAgC,QAAAtT,IACA0T,EAAA1T,GACAC,EAAA8E,KAAA,QAEA9E,EAAA8E,KAAA,SAGA,OAAA9E,EAAAmV,KAAA,IACA,IA4BApO,EAAAiE,GAAApK,UAAA,UAAA,WACA,IAAA+T,EACA3E,EACAxG,EACAlB,EACAmL,EACA1T,EAEA,IAAAwW,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAiBA,OAfAkM,EAAAqB,KACAoC,EAAApC,KAAAiC,QACA9J,EAAA6H,KAAAgC,QAGAtT,GAAA,EAIA4G,EADAgO,EAAA,CAAA,EACA,QAcA,WAEA,OADA5U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,CACAwJ,MAAA,GAGA,CACApT,MAAAmQ,GAAA0D,EAAA1T,IACAiT,MAAA,EAEA,IAxBArM,EAAAgO,EAAA,UAiCA,SAAA/U,GAEA,OADA0I,GAAA,EACArE,UAAA1D,OACA,CACAX,MAAAA,EACAoT,MAAA,GAGA,CACAA,MAAA,EAEA,IA1CAgB,IACArN,EAAAgO,EAAAX,IAiDA,WACA,OAAAhE,EAAAoG,QACA,IAjDAzB,CAkDA,IA6BAhO,EAAAqE,GAAApK,UAAA,QAAA,SAAAyV,EAAAzW,GACA,IACAI,EACAwJ,EAEA,IAAA+M,GAAAlF,MACA,MAAA,IAAAvN,UAAA,sDAEA,IAAA6K,GAAA0H,GACA,MAAA,IAAAvS,UAAAiB,EAAA,oEAAAsR,IAMA,GAJA7M,EAAA6H,KAAAgC,QACAgD,EAAA,IACAA,GAAA7M,GAEA6M,EAAA,GAAAA,GAAA7M,EACA,MAAA,IAAAoK,WAAA7O,EAAA,kEAAAsR,IAEA,IAAAxG,GAAAjQ,GACA,MAAA,IAAAkE,UAAAiB,EAAA,oEAAAnF,IASA,OAPAI,EAAA,IAAAqR,KAAAzH,YAAAyH,KAAAiC,UACAA,QAEA+C,GADAzW,EACA,EAEA,EAEAI,CACA,IG/4EA,IAAI4W,GAAQ,CACXtM,GACAD,GACAG,GACAG,GACAJ,GACAG,GACAD,GACAG,GACAC,GACAC,GACAC,GACAC,IC5BG6L,GAAS,CACZ,UACA,UACA,QACA,SACA,QACA,SACA,OACA,QACA,SACA,YACA,aACA,QCHGC,GAASD,GAAOtW,OAkBpB,SAAS0H,GAAOrI,GACf,IAAIG,EACJ,GAAKkD,GAASrD,GACb,MAAO,UAER,GAAK8J,GAAU9J,GACd,OAAO,KAER,IAAMG,EAAI,EAAGA,EAAI+W,GAAQ/W,IACxB,GAAKH,aAAiBgX,GAAO7W,GAC5B,OAAO8W,GAAQ9W,GAIjB,OAAOgX,GAAY/M,GAAiBpK,KAAa,IAClD,CCZA,SAAS6X,GAAkB7I,GAC1B,IAAIqI,EAAKhP,GAAO2G,GAChB,OAAK3H,GAAiB2H,GACd,CACN8I,KAAQ9I,EACR3G,MAASgP,EACTC,kBAAoB,EACpBF,UAAa,CACZ1C,GAAgB2C,GAChBE,GAAgBF,KAIZ,CACNS,KAAQ9I,EACR3G,MAASgP,EACTC,kBAAoB,EACpBF,UAAa,CACZhP,GAAQiP,GACR9O,GAAQ8O,IAGX,CCRA,SAASoW,GAAO5X,EAAG7G,EAAG0e,EAASC,EAAS5U,EAAG6U,EAASC,GACnD,IAAIC,EACAC,EACAlnB,EACAD,EACAonB,EACAC,EACA9tB,EAYJ,IATA2tB,EAAO9e,EAAE8I,KACTiW,EAAOhV,EAAEjB,KAGTlR,EAAMoI,EAAEoI,UAAW,GACnBvQ,EAAMkS,EAAE3B,UAAW,GAEnB4W,EAAKL,EACLM,EAAKJ,EACC1tB,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB0G,EAAKknB,EAAME,EAAIrnB,EAAKknB,EAAME,IAC1BA,GAAMN,EACNO,GAAML,EAEP,OAAO5e,CACR,CChEA,IAAI8U,GAAI,EAsBR,SAAS2J,GAAO5X,EAAG7G,EAAG0e,EAAS3U,EAAG6U,GACjC,IAAII,EACAC,EACAC,EACAC,EACAtG,EACA1nB,EAEJ,GAAK0V,GAAK,EACT,OAAOkD,EAIR,GAFAmV,EAAKrW,GAAkB7I,GACvBmf,EAAKtW,GAAkBkB,GAClBmV,EAAG5W,kBAAoB6W,EAAG7W,iBAY9B,OADAF,GAAWvB,EAAGqY,EAAIR,EATjBM,EADIN,EAAU,GACR,EAAE7X,GAAK6X,EAER,EAOyBS,EAAIP,EAJlCK,EADIL,EAAU,GACR,EAAE/X,GAAK+X,EAER,GAGCO,EAAGrW,KAGX,GAAiB,IAAZ4V,GAA6B,IAAZE,EAAgB,CAIrC,IAHA/F,EAAIhS,EAAIiO,IAGC,EACR,IAAM3jB,EAAI,EAAGA,EAAI0nB,EAAG1nB,IACnB4Y,EAAG5Y,GAAM6O,EAAG7O,GAGd,GAAK0V,EAAIiO,GACR,OAAO/K,EAER,IAAM5Y,EAAI0nB,EAAG1nB,EAAI0V,EAAG1V,GAAK2jB,GACxB/K,EAAG5Y,GAAM6O,EAAG7O,GACZ4Y,EAAG5Y,EAAE,GAAM6O,EAAG7O,EAAE,GAChB4Y,EAAG5Y,EAAE,GAAM6O,EAAG7O,EAAE,GAChB4Y,EAAG5Y,EAAE,GAAM6O,EAAG7O,EAAE,GAChB4Y,EAAG5Y,EAAE,GAAM6O,EAAG7O,EAAE,GAChB4Y,EAAG5Y,EAAE,GAAM6O,EAAG7O,EAAE,GAChB4Y,EAAG5Y,EAAE,GAAM6O,EAAG7O,EAAE,GAChB4Y,EAAG5Y,EAAE,GAAM6O,EAAG7O,EAAE,GAEjB,OAAO4Y,CACP,CAWD,IATCiV,EADIN,EAAU,GACR,EAAE7X,GAAK6X,EAER,EAGLO,EADIL,EAAU,GACR,EAAE/X,GAAK+X,EAER,EAEAztB,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB4Y,EAAGkV,GAAOjf,EAAGgf,GACbA,GAAMN,EACNO,GAAML,EAEP,OAAO7U,CACR,CC1FA,IAAI+K,GAAI,EAwBR,SAAS2J,GAAO5X,EAAG7G,EAAG0e,EAASC,EAAS5U,EAAG6U,EAASC,GACnD,IAAIG,EACAC,EACAC,EACAC,EACAtG,EACA1nB,EAEJ,GAAK0V,GAAK,EACT,OAAOkD,EAIR,GAFAmV,EAAKrW,GAAkB7I,GACvBmf,EAAKtW,GAAkBkB,GAClBmV,EAAG5W,kBAAoB6W,EAAG7W,iBAE9B,OADAF,GAAWvB,EAAGqY,EAAIR,EAASC,EAASQ,EAAIP,EAASC,GAC1CM,EAAGrW,KAMX,GAJAkW,EAAKL,EACLM,EAAKJ,EAGY,IAAZH,GAA6B,IAAZE,EAAgB,CAIrC,IAHA/F,EAAIhS,EAAIiO,IAGC,EACR,IAAM3jB,EAAI,EAAGA,EAAI0nB,EAAG1nB,IACnB4Y,EAAGkV,GAAOjf,EAAGgf,GACbA,GAAMN,EACNO,GAAML,EAGR,GAAK/X,EAAIiO,GACR,OAAO/K,EAER,IAAM5Y,EAAI0nB,EAAG1nB,EAAI0V,EAAG1V,GAAK2jB,GACxB/K,EAAGkV,GAAOjf,EAAGgf,GACbjV,EAAGkV,EAAG,GAAMjf,EAAGgf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMjf,EAAGgf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMjf,EAAGgf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMjf,EAAGgf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMjf,EAAGgf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMjf,EAAGgf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMjf,EAAGgf,EAAG,GAClBA,GAAMlK,GACNmK,GAAMnK,GAEP,OAAO/K,CACP,CACD,IAAM5Y,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB4Y,EAAGkV,GAAOjf,EAAGgf,GACbA,GAAMN,EACNO,GAAML,EAEP,OAAO7U,CACR,CCrCA,SAAS/T,GAAOgK,EAAG+b,EAAGiC,GACrB,IAAI5sB,EACAwJ,EACAsY,EACA7K,EACAxB,EAQJ,IAHAqM,EAAK6K,GAAgBhC,EAHrBnhB,EAAMoF,EAAErO,QAGqB,IAGrBssB,KAAO,CACd,GAAKD,EACJ,MAAM,IAAIhZ,WAAY7O,EAAQ,kEAAmEyE,IAGlGsY,EAAK6K,GAAgBhC,EAAGnhB,GAAK,EAC7B,CAgBD,OAdAiM,EAAIsX,GAAajL,GAOhB9hB,EADW,aAHZiX,EAAKhP,GAAO2G,KAGoB,OAAPqI,EAClBpX,GAAO4V,GAEP,IAAI7G,EAAEhF,YAAa6L,GAG1B4X,GAAO5X,EAAG7G,EAAGkT,EAAGyK,KAAMzK,EAAGrN,MAAOzU,EAAK,EAAG,GAEjCA,CACR,CCrDA2G,EAAAnH,GAAA,UAAAwuB,ICdA,IAAI/U,GAAQ,CACX9R,QAAWmD,GACXhD,QAAW+C,GACXvC,QAAW5E,MACXsE,MAAS+C,GACThD,MAASiD,GACT/C,KAAQgD,GACR9C,OAAU+C,GACVhD,OAAUiD,GACV/C,MAASgD,GACT/C,OAAUgD,GACVxC,UAAayC,GACb1C,WAAc2C,GACdI,KAAQH,ICXT,SAASiO,GAAOhR,GACf,OAAOgmB,GAAOhmB,IAAW,IAC1B,CCQA,SAASimB,GAAajmB,GACrB,MAAmB,cAAVA,CACV,CAiBA,SAASkmB,GAAclmB,GACtB,MAAmB,eAAVA,CACV,CAiBA,SAASmmB,GAAQnmB,GAChB,MAAmB,SAAVA,CACV,CAoBA,SAASomB,GAASzf,EAAG3G,GACpB,IAAIqmB,EACApkB,EACAwjB,EACAa,EACA/nB,EACAxG,EACAwJ,EACA6W,EACAtgB,EAEJ,IAAMsP,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,8EAA+E6J,IAG7G,GAAe,YAAV3G,EACJ,OAAOob,GAAMzU,GAGd,GAAc,QADd1E,EAAO+O,GAAOhR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,uFAAwFkD,IAatH,GAVAuB,EAAMoF,EAAErO,OAIR+tB,EAAQJ,GADR7N,EAAImO,GAAS5f,IAIb5O,EAAM,IAAIkK,EAAMV,GAGX8kB,GAASH,GAAc9N,GAAM,CAOjC,GALCqN,EADIY,EACGza,GAAejF,EAAG,GAElBkF,GAAgBlF,EAAG,GAGtBsf,GAAajmB,GAGjB,OADAolB,GAAW,EAAJ7jB,EAAOkkB,EAAM,EADpBa,EAAO1a,GAAe7T,EAAK,GACE,GACtBA,EAER,GAAKmuB,GAAclmB,GAGlB,OADAolB,GAAW,EAAJ7jB,EAAOkkB,EAAM,EADpBa,EAAOza,GAAgB9T,EAAK,GACC,GACtBA,EAGR,GAAKouB,GAAQnmB,GAAU,CAEtB,IADAsmB,EAAO5L,GAAoB3iB,EAAK,GAC1BD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAEhB2tB,EAAM,EAAE3tB,IAAO2tB,EAAO,EAAE3tB,EAAG,GAC/BwuB,EAAMxuB,GAAM,EAEZwuB,EAAMxuB,GAAM,EAGd,OAAOC,CACP,CAGD,OADAqtB,GAAO7jB,EAAKkkB,EAAM,EAAG1tB,EAAK,GACnBA,CACP,CAED,GAAKouB,GAAQ/N,GAIZ,OAHAqN,EAAO/K,GAAoB/T,EAAG,GAGzBwf,GAAQnmB,IAEZolB,GAAO7jB,EAAKkkB,EAAM,EADlBa,EAAO5L,GAAoB3iB,EAAK,GACL,GACpBA,GAGHkuB,GAAajmB,IAEjBolB,GAAO7jB,EAAKkkB,EAAM,EADlBa,EAAO1a,GAAe7T,EAAK,GACA,GACpBA,GAEHmuB,GAAclmB,IAElBolB,GAAO7jB,EAAKkkB,EAAM,EADlBa,EAAOza,GAAgB9T,EAAK,GACD,GACpBA,IAERqtB,GAAO7jB,EAAKkkB,EAAM,EAAG1tB,EAAK,GACnBA,GAIR,IADAsuB,EAAQJ,GAAajmB,KACPkmB,GAAclmB,GAQ3B,OADAolB,GAAO7jB,EAAKoF,EAAG,EALd2f,EADID,EACGza,GAAe7T,EAAK,GAEpB8T,GAAgB9T,EAAK,GAGL,GACjBA,EAGR,GAAKouB,GAAQnmB,GAAU,CAGtB,IAFAsmB,EAAO5L,GAAoB3iB,EAAK,GAChCwG,EAAMqR,GAAejJ,GACf7O,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAChByG,EAAKoI,EAAG7O,GACZwuB,EAAMxuB,GAAM,EAEZwuB,EAAMxuB,GAAM,EAGd,OAAOC,CACP,CAGD,OADAqtB,GAAO7jB,EAAKoF,EAAG,EAAG5O,EAAK,GAChBA,CACR,CCxJA,SAASyuB,GAAa7f,EAAG+J,EAAGgS,EAAGiC,GAC9B,IAAI8B,EACAC,EACAC,EACAC,EACA/M,EACAgN,EACArZ,EASJ,GAPAmZ,EAAM3mB,GAAO2G,IAAO,UACpBigB,EAAM5mB,GAAO0Q,IAAO,UAEpB+V,EAAO9f,EAAErO,OACTouB,EAAOhW,EAAEpY,QAGH0gB,GAAkB2N,EAAKC,GAC5B,MAAM,IAAI/qB,UAAWiB,EAAQ,kHAAmH6pB,EAAKC,IAUtJ,GAPKE,GAAmBF,IAASxN,GAAgBuN,KAChDhgB,EAAIyf,GAASzf,EAAGigB,KAGjB/M,EAAK6K,GAAgBhC,EAAGgE,GAAM,IAGtB9B,KAAO,CACd,GAAKD,EACJ,MAAM,IAAIhZ,WAAY7O,EAAQ,kEAAmE4pB,IAGlG7M,EAAK6K,GAAgBhC,EAAGgE,GAAM,EAC9B,CAKD,GAHAlZ,EAAIsX,GAAajL,GAGH,IAAT4M,EACJI,EAAK,MACC,IAAKJ,IAASjZ,EAGpB,MAAM,IAAIlU,MAAOwD,EAAQ,6HAA8H2pB,EAAMjZ,IAF7JqZ,EAAK,CAGL,CAID,OAFAzB,GAAO5X,EAAG7G,EAAGkgB,EAAI,EAAGnW,EAAGmJ,EAAGyK,KAAMzK,EAAGrN,OAE5BkE,CACR,CC3FA,SAASqW,GAAUxlB,EAAK2K,EAAMD,GAC7B,IAAI9M,EACArH,EAIJ,IADAqH,EAAM,GACArH,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBqH,EAAItC,KAAMqP,EAAKtS,KAAMqS,EAASnU,IAE/B,OAAOqH,CACR,CCJA,SAAS6nB,GAAUrvB,EAAOuiB,GACzB,IAAIniB,EACAkvB,EACA9M,EACAC,EACA8M,EACAC,EACAhL,EAQJ,IANAhC,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZniB,EAAM,GACAovB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB8K,EAAGpqB,KAAMmd,GAAQriB,EAAOwiB,IAEzBpiB,EAAI8E,KAAMoqB,EACV,CACD,OAAOlvB,CACR,CCvBA,SAASqvB,GAAUzvB,EAAOuiB,GACzB,IAAIniB,EACAkvB,EACAI,EACAlN,EACAC,EACA8M,EACAI,EACAnL,EACAgL,EACAI,EASJ,IAPApN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZniB,EAAM,GACAwvB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB8K,EAAGpqB,KAAMmd,GAAQriB,EAAOwiB,IAEzBkN,EAAGxqB,KAAMoqB,EACT,CACDlvB,EAAI8E,KAAMwqB,EACV,CACD,OAAOtvB,CACR,CC/BA,SAASyvB,GAAU7vB,EAAOuiB,GACzB,IAAIniB,EACAkvB,EACAI,EACAI,EACAtN,EACAC,EACA8M,EACAI,EACAI,EACAvL,EACAgL,EACAI,EACAI,EAUJ,IARAxN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZniB,EAAM,GACA4vB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB8K,EAAGpqB,KAAMmd,GAAQriB,EAAOwiB,IAEzBkN,EAAGxqB,KAAMoqB,EACT,CACDQ,EAAG5qB,KAAMwqB,EACT,CACDtvB,EAAI8E,KAAM4qB,EACV,CACD,OAAO1vB,CACR,CC3CA,SAASgjB,GAASpjB,EAAOqjB,EAAOd,EAAOe,EAAKljB,GAC3C,IAAImjB,EACAC,EACArjB,EAMJ,GAJAojB,EAAIhB,EAAOe,IAGXE,EAAIF,EAAM,KACCD,EACV,OAAOhB,GAAQriB,EAAOujB,GAIvB,IAAMpjB,EAAI,EAAGA,EAAIojB,EAAGpjB,IACnBC,EAAI8E,KAAMke,GAASpjB,EAAOqjB,EAAOd,EAAOiB,EAAG,KAE5C,OAAOpjB,CACR,CAwBA,SAAS6vB,GAAUjwB,EAAOuiB,GACzB,OAAOa,GAASpjB,EAAOuiB,EAAM5hB,OAAQ4hB,EAAO,EAAG,GAChD,CC/CA,SAASa,GAASC,EAAOd,EAAOe,EAAK1J,EAASxZ,EAAKmU,EAAMD,GACxD,IAAI7M,EACAiB,EACA6a,EACAC,EACArjB,EAOJ,IAHAuI,GADA8a,EAAIF,EAAM,KACID,EAEdE,EAAIhB,EAAOe,GACLnjB,EAAI,EAAGA,EAAIojB,EAAGpjB,KACnBsH,EAAMmS,EAAQ5U,SACVE,KAAM/E,GACLuI,EACJtI,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAAS7M,IAE9BrH,EAAI8E,KAAMke,GAASC,EAAOd,EAAOiB,EAAG/b,EAAK,GAAI8M,EAAMD,IAGrD,OAAOlU,CACR,CCzBA,SAAS8vB,GAAO3N,GACf,IAAIc,EACAnjB,EACAC,EAGJ,GAAe,KADfkjB,EAAQd,EAAM5hB,QAEb,OAAO,EAGR,IADAT,EAAI,EACEC,EAAI,EAAGA,EAAIkjB,EAAOljB,IACvBD,GAAKqiB,EAAOpiB,GAEb,OAAOD,CACR,CCRA,SAASiwB,GAAqB7mB,GAC7B,MAAe,iBAANA,CACV,CCmDA,SAAS8mB,GAAe7N,EAAO8N,GAC9B,OAAKC,GAAeD,GAhCrB,SAAsB9N,GACrB,IAAIniB,EACA2qB,EACA5qB,EAIJ,IAFAC,EAAM,GACN2qB,EAAI,EACE5qB,EAAI,EAAGA,EAAIoiB,EAAM5hB,OAAQR,IAC9BC,EAAI8E,KAAM6lB,GACVA,GAAKxI,EAAOpiB,GAEb,OAAOC,CACR,CAqBSmwB,CAAahO,GA3DtB,SAAmBA,GAClB,IAAIc,EACAjjB,EACA2qB,EACA5qB,EAIJ,IAFAkjB,EAAQd,EAAM5hB,OACdP,EAAM,GACAD,EAAI,EAAGA,EAAIkjB,EAAOljB,IACvBC,EAAI8E,KAAM,GAGX,IADA6lB,EAAI,EACE5qB,EAAIkjB,EAAM,EAAGljB,GAAK,EAAGA,IAC1BC,EAAKD,GAAM4qB,EACXA,GAAKxI,EAAOpiB,GAEb,OAAOC,CACR,CA4CQowB,CAAUjO,EAClB,CC9CA,SAASkO,GAAWlO,EAAOyB,EAASnR,EAAQwd,EAAO5oB,EAAKipB,GACvD,IAAIrN,EACAzZ,EACA+mB,EACA5F,EACA5qB,EAIJ,IAFAkjB,EAAQd,EAAM5hB,OACdiJ,EAAM,EACAzJ,EAAI,EAAGA,EAAIkjB,EAAOljB,IACvByJ,GAAO2Y,EAAOpiB,GAEf,GAAc,UAATuwB,EACCjpB,EAAM,EACVA,EAAM,EACKA,GAAOmC,IAClBnC,EAAMmC,EAAM,QAEP,GAAc,SAAT8mB,EACNjpB,EAAM,GACVA,GAAOmC,GACI,GAEG,IADbnC,GAAOmC,KAENnC,GAAOmC,GAGEnC,GAAOmC,IAClBnC,GAAOmC,IACKA,IACXnC,GAAOmC,QAOT,GAHc,cAAT8mB,GAAwBjpB,EAAM,IAClCA,GAAOmC,GAEHnC,EAAM,GAAKA,GAAOmC,EACtB,MAAM,IAAIoK,WAAY7O,EAAQ,gHAAiHyE,EAAKnC,IAKtJ,GADAkpB,EAAM9d,EACDyd,GAAeD,GAAU,CAC7B,IAAMlwB,EAAI,EAAGA,EAAIkjB,EAAOljB,IAEvBsH,GADAsjB,EAAItjB,EAAM8a,EAAOpiB,GAEjBsH,GAAO8a,EAAOpiB,GACdwwB,GAAO5F,EAAI/G,EAAS7jB,GAErB,OAAOwwB,CACP,CAED,IAAMxwB,EAAIkjB,EAAM,EAAGljB,GAAK,EAAGA,IAE1BsH,GADAsjB,EAAItjB,EAAM8a,EAAOpiB,GAEjBsH,GAAO8a,EAAOpiB,GACdwwB,GAAO5F,EAAI/G,EAAS7jB,GAErB,OAAOwwB,CACR,CC7EA,SAASC,GAAe/a,EAAGiE,GAC1B,OAAKA,EAAS,EACN,GAEC,EAAIjE,GAAMiE,CACpB,CCMA/S,EAAAnH,GAAA,UCgDA,SAAwB2iB,EAAO8N,EAAOjwB,GACrC,OAAKkwB,GAAeD,GApCrB,SAAsB9N,EAAOniB,GAC5B,IAAI2qB,EACA5qB,EAGJ,IADA4qB,EAAI,EACE5qB,EAAI,EAAGA,EAAIoiB,EAAM5hB,OAAQR,IAC9BC,EAAKD,GAAM4qB,EACXA,GAAKxI,EAAOpiB,GAEb,OAAOC,CACR,CA2BSmwB,CAAahO,EAAOniB,GA3D7B,SAAmBmiB,EAAOniB,GACzB,IACI2qB,EACA5qB,EAIJ,IADA4qB,EAAI,EACE5qB,EAFEoiB,EAAM5hB,OAEE,EAAGR,GAAK,EAAGA,IAC1BC,EAAKD,GAAM4qB,EACXA,GAAKxI,EAAOpiB,GAEb,OAAOC,CACR,CAiDQowB,CAAUjO,EAAOniB,EACzB,ICpEA,IAAI0jB,GAAI,EAoBR,SAAS+M,GAAMhb,EAAG7G,EAAG0e,EAASC,GAC7B,IAAInZ,EACAwZ,EACAC,EACAxW,EACAoQ,EACA3nB,EACAC,EAEJ,GAAK0V,GAAK,EACT,OAAO7G,EAGR,IADAyI,EAAII,GAAkB7I,IACfsI,iBAEN,OCCF,SAAezB,EAAG7G,EAAG0e,EAASC,GAC7B,IAAIG,EACAjnB,EACAD,EACA4N,EACAwZ,EACAC,EACA/tB,EACAC,EAYJ,IATA2tB,EAAO9e,EAAE8I,KAGTlR,EAAMoI,EAAEoI,UAAW,GACnBvQ,EAAMmI,EAAEoI,UAAW,GAEnBlX,EAAI4O,GAAO+G,EAAE,GAEboY,GADAD,EAAKL,IACS9X,EAAI,GAAM6X,EAClBvtB,EAAI,EAAGA,EAAID,EAAGC,IACnBqU,EAAM5N,EAAKknB,EAAME,GACjBnnB,EAAKinB,EAAME,EAAIpnB,EAAKknB,EAAMG,IAC1BpnB,EAAKinB,EAAMG,EAAIzZ,GACfwZ,GAAMN,EACNO,GAAMP,CAGR,CD9BEtW,CAAWvB,EAAG4B,EAAGiW,EAASC,GACnBlW,EAAEK,KAMV,GAJA5X,EAAI4O,GAAO+G,EAAE,GACbmY,EAAKL,EAGY,IAAZD,EAAgB,CAKpB,GAHAO,EAAKD,EAAKnY,EAAI,GADdgS,EAAI3nB,EAAI4jB,IAIC,EACR,IAAM3jB,EAAI,EAAGA,EAAI0nB,EAAG1nB,IACnBqU,EAAMxF,EAAGgf,GACThf,EAAGgf,GAAOhf,EAAGif,GACbjf,EAAGif,GAAOzZ,EACVwZ,GAAMN,EACNO,GAAMP,EAGR,GAAKxtB,EAAI4jB,GACR,OAAO9U,EAER,IAAM7O,EAAI0nB,EAAG1nB,EAAID,EAAGC,GAAK2jB,GACxBtP,EAAMxF,EAAGgf,GACThf,EAAGgf,GAAOhf,EAAGif,GACbjf,EAAGif,GAAOzZ,EAEVA,EAAMxF,EAAGgf,EAAG,GACZhf,EAAGgf,EAAG,GAAMhf,EAAGif,EAAG,GAClBjf,EAAGif,EAAG,GAAMzZ,EAEZA,EAAMxF,EAAGgf,EAAG,GACZhf,EAAGgf,EAAG,GAAMhf,EAAGif,EAAG,GAClBjf,EAAGif,EAAG,GAAMzZ,EAEZwZ,GAAMlK,GACNmK,GAAMnK,GAEP,OAAO9U,CACP,CAED,IADAif,EAAKD,GAASnY,EAAI,GAAM6X,EAClBvtB,EAAI,EAAGA,EAAID,EAAGC,IACnBqU,EAAMxF,EAAGgf,GACThf,EAAGgf,GAAOhf,EAAGif,GACbjf,EAAGif,GAAOzZ,EACVwZ,GAAMN,EACNO,GAAMP,EAEP,OAAO1e,CACR,CExEA,SAAS6hB,GAAMhb,EAAG7G,EAAG0e,GACpB,OAAOU,GAASvY,EAAG7G,EAAG0e,EAASkD,GAAe/a,EAAG6X,GAClD,CCOA3mB,EAAAnH,GAAA,UAAAwuB,ICpBA,IAAI0C,GAAO,QAwBX,SAASrN,GAAMzU,EAAG6G,EAAGzV,EAAK0Z,EAAQjH,GACjC,IAAI1S,EACJ,IAAMA,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBC,EAAKyS,GAAW7D,EAAG7O,GACnB0S,GAAUiH,CAEZ,CAeA,SAASiX,GAAsB/hB,EAAGqU,EAAOd,EAAOe,EAAKljB,EAAK0Z,EAAQjH,GACjE,IAAInK,EACA6a,EACAC,EACArjB,EAOJ,IAHAuI,GADA8a,EAAIF,EAAM,KACID,EAEdE,EAAIhB,EAAOe,GACLnjB,EAAI,EAAGA,EAAIojB,EAAGpjB,IACduI,GACJtI,EAAKyS,GAAW7D,EAAG7O,GACnB0S,GAAUiH,GAEVjH,EAASke,GAAsB/hB,EAAG7O,GAAKkjB,EAAOd,EAAOiB,EAAGpjB,EAAK0Z,EAAQjH,GAGvE,OAAOA,CACR,CAqFA,SAASme,GAAShiB,EAAGuT,EAAOkC,EAAiBrkB,EAAK0Z,EAAQjH,GACzD,IAAIwQ,EAAQd,EAAM5hB,OAClB,OAAe,IAAV0iB,EACGjjB,EAEO,IAAVijB,GAEJI,GAAMzU,EAAGuT,EAAO,GAAKniB,EAAK0Z,EAAQjH,GAC3BzS,GAEHqkB,GAlFN,SAAiCzV,EAAGqU,EAAOd,EAAOniB,EAAK0Z,EAAQjH,GAC9D,IAAIjJ,EACA4K,EACAuG,EACAkW,EACA5H,EACAplB,EACA9D,EAwBJ,IAfA4wB,GAAsB/hB,EAAGqU,EAAOd,EAAO,EADvC/N,EAAMvU,GAHN2J,EAAMsmB,GAAO3N,IAIkC,EAAG,GAMlD8G,EAAK+G,GAAe7N,EAHpBxH,EAAM,aAON0I,GAAMlB,EAAOc,EADb4N,EAAKhxB,GAAOojB,GACY,EAAG,GAC3BwN,GAAMxN,EAAO4N,EAAI,GACjBJ,GAAMxN,EAAOgG,EAAI,GAGXlpB,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB8D,EAAIwsB,GAAWQ,EAAI5H,EAAI,EAAGtO,EAAK5a,EAAG2wB,IAClC1wB,EAAKyS,GAAW2B,EAAKvQ,GACrB4O,GAAUiH,CAEZ,CA+CEoX,CAAwBliB,EAAGqU,EAAOd,EAAOniB,EAAK0Z,EAAQjH,GAC/CzS,IAER2wB,GAAsB/hB,EAAGqU,EAAOd,EAAO,EAAGniB,EAAK0Z,EAAQjH,GAChDzS,EACR,CChJA,SAAS4wB,GAAShiB,EAAGuT,EAAOkC,GAE3B,OAAO1K,GAAQ/K,EAAGuT,EAAOkC,EADfxkB,GAAOiwB,GAAO3N,IACuB,EAAG,EACnD,CCQAxb,EAAAnH,GAAA,SAAAma,IC9BA,IAAI+W,GAAO,QAuDX,SAASC,GAAsBI,EAAMniB,EAAGqU,EAAOd,EAAOe,EAAK1J,EAASxZ,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GAC9F,IAAI5L,EACAjB,EACA8b,EACAC,EACArjB,EAOJ,IAHAuI,GADA8a,EAAIF,EAAM,KACID,EAEdE,EAAIhB,EAAOe,GACLnjB,EAAI,EAAGA,EAAIojB,EAAGpjB,KACnBsH,EAAMmS,EAAQ5U,SACVE,KAAM/E,GACLuI,GACJtI,EAAKyS,GAAW0B,EAAKtS,KAAMqS,EAAStF,EAAG7O,GAAKsH,EAAK0pB,GACjDte,GAAUiH,GAEVjH,EAASke,GAAsBI,EAAMniB,EAAG7O,GAAKkjB,EAAOd,EAAOiB,EAAG/b,EAAKrH,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GAGhG,OAAOzB,CACR,CAgGA,SAASue,GAAWpiB,EAAGuT,EAAOkC,EAAiBrkB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GACzE,IAAI+O,EAAQd,EAAM5hB,OAClB,OAAe,IAAV0iB,EACGjjB,EAEO,IAAVijB,GArJN,SAAiBrU,EAAG6G,EAAGzV,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GACjD,IAAInU,EACJ,IAAMA,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBC,EAAKyS,GAAW0B,EAAKtS,KAAMqS,EAAStF,EAAG7O,GAAK,CAAEA,GAAK6O,GACnD6D,GAAUiH,CAEZ,CAiJEuX,CAAQriB,EAAGuT,EAAO,GAAKniB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GAC3ClU,GAEHqkB,GA3FN,SAAiCzV,EAAGqU,EAAOd,EAAOniB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GAC5E,IAAI1K,EACA4K,EACAuG,EACAkW,EACA5H,EACAplB,EACA9D,EAuBJ,IAdA4wB,GAAsB/hB,EAAGA,EAAGqU,EAAOd,EAAO,EAAG,GAD7C/N,EAAMvU,GAHN2J,EAAMsmB,GAAO3N,IAIyC,EAAG,EAAGhO,EAAMD,GAMlE+U,EAAK+G,GAAe7N,EAHpBxH,EAAM,aAON8V,GAAMxN,EADN4N,EAAKxN,GAAMlB,GACM,GACjBsO,GAAMxN,EAAOgG,EAAI,GAGXlpB,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB8D,EAAIwsB,GAAWQ,EAAI5H,EAAI,EAAGtO,EAAK5a,EAAG2wB,IAClC1wB,EAAKyS,GAAW2B,EAAKvQ,GACrB4O,GAAUiH,CAEZ,CAyDEoX,CAAwBliB,EAAGqU,EAAOd,EAAOniB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GAC7DlU,IAER2wB,GAAsB/hB,EAAGA,EAAGqU,EAAOd,EAAO,EAAG,GAAIniB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GACrElU,EACR,CCjKA,SAASgxB,GAAWpiB,EAAGuT,EAAOkC,EAAiBlQ,EAAMD,GAEpD,OAAOyF,GAAQ/K,EAAGuT,EAAOkC,EADfxkB,GAAOiwB,GAAO3N,IACuB,EAAG,EAAGhO,EAAMD,EAC5D,CCpBA,SAASgd,GAAWtiB,EAAGuT,EAAOkC,GAC7B,IAAIrkB,EACAoiB,EACAC,EACA8B,EACAC,EACAF,EAUJ,GAPA9B,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZniB,EAAM,GAGDqkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBpkB,EAAI8E,KAAM8J,EAAGwV,GAAMD,IAGrB,OAAOnkB,CACP,CACD,IAAMokB,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKtV,EAAGwV,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAI8E,KAAMof,EAAIC,IAGhB,OAAOnkB,CACR,CCrBA,SAASmxB,GAAaviB,EAAGuT,EAAOkC,EAAiBlQ,EAAMD,GACtD,IAAIlU,EACAoiB,EACAC,EACA8B,EACAC,EACAF,EAUJ,GAPA9B,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZniB,EAAM,GAGDqkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBpkB,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAAStF,EAAGwV,GAAMD,GAAM,CAAEC,EAAID,GAAMvV,IAG3D,OAAO5O,CACP,CACD,IAAMokB,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKtV,EAAGwV,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAASgQ,EAAIC,GAAM,CAAEC,EAAID,GAAMvV,IAGtD,OAAO5O,CACR,CCzCA,SAASoxB,GAAWxiB,EAAGuT,EAAOkC,GAC7B,IAAIrkB,EACAoiB,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAlL,EACAgL,EAWJ,GARA9M,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZniB,EAAM,GAGDqkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtBpvB,EAAI8E,KAAM8J,EAAGwgB,GAAMhL,GAAMD,IAI5B,OAAOnkB,CACP,CACD,IAAMovB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKtgB,EAAGwgB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAI8E,KAAMof,EAAIC,IAIjB,OAAOnkB,CACR,CC5BA,SAASqxB,GAAaziB,EAAGuT,EAAOkC,EAAiBlQ,EAAMD,GACtD,IAAIlU,EACAoiB,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAlL,EACAgL,EAWJ,GARA9M,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZniB,EAAM,GAGDqkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtBpvB,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAAStF,EAAGwgB,GAAMhL,GAAMD,GAAM,CAAEiL,EAAIhL,EAAID,GAAMvV,IAItE,OAAO5O,CACP,CACD,IAAMovB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKtgB,EAAGwgB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAASgQ,EAAIC,GAAM,CAAEiL,EAAIhL,EAAID,GAAMvV,IAI3D,OAAO5O,CACR,CCpDA,SAASsxB,GAAW1iB,EAAGuT,EAAOkC,GAC7B,IAAIrkB,EACAoiB,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAtL,EACAgL,EACAI,EAYJ,GATAlN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZniB,EAAM,GAGDqkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtBxvB,EAAI8E,KAAM8J,EAAG4gB,GAAMJ,GAAMhL,GAAMD,IAKnC,OAAOnkB,CACP,CACD,IAAMwvB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK1gB,EAAG4gB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAI8E,KAAMof,EAAIC,IAKlB,OAAOnkB,CACR,CCrCA,SAASuxB,GAAa3iB,EAAGuT,EAAOkC,EAAiBlQ,EAAMD,GACtD,IAAIlU,EACAoiB,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAtL,EACAgL,EACAI,EAYJ,GATAlN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZniB,EAAM,GAGDqkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtBxvB,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAAStF,EAAG4gB,GAAMJ,GAAMhL,GAAMD,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMvV,IAKjF,OAAO5O,CACP,CACD,IAAMwvB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK1gB,EAAG4gB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAASgQ,EAAIC,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMvV,IAKhE,OAAO5O,CACR,CC3DA,SAASwxB,GAAW5iB,EAAGuT,EAAOkC,GAC7B,IAAIrkB,EACAoiB,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA1L,EACAgL,EACAI,EACAI,EAaJ,GAVAtN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZniB,EAAM,GAGDqkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB5vB,EAAI8E,KAAM8J,EAAGghB,GAAMJ,GAAMJ,GAAMhL,GAAMD,IAM1C,OAAOnkB,CACP,CACD,IAAM4vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK9gB,EAAGghB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAI8E,KAAMof,EAAIC,IAMnB,OAAOnkB,CACR,CChDA,SAASyxB,GAAa7iB,EAAGuT,EAAOkC,EAAiBlQ,EAAMD,GACtD,IAAIlU,EACAoiB,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA1L,EACAgL,EACAI,EACAI,EAaJ,GAVAtN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZniB,EAAM,GAGDqkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB5vB,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAAStF,EAAGghB,GAAMJ,GAAMJ,GAAMhL,GAAMD,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMvV,IAM5F,OAAO5O,CACP,CACD,IAAM4vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK9gB,EAAGghB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAASgQ,EAAIC,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMvV,IAMrE,OAAO5O,CACR,CC9EA,SAAS0xB,GAAU9iB,GAClB,IAAI5O,EACA2xB,EACAC,EACAxN,EACAD,EAGJ,IADAnkB,EAAM,GACAokB,EAAK,EAAGA,EAAKxV,EAAErO,OAAQ6jB,IAAO,CAGnC,IADAwN,EAAK,GACCzN,GAFNwN,EAAK/iB,EAAGwV,IAEM7jB,OAAO,EAAG4jB,GAAM,EAAGA,IAChCyN,EAAG9sB,KAAM6sB,EAAIxN,IAEdnkB,EAAI8E,KAAM8sB,EACV,CACD,OAAO5xB,CACR,CCZA,SAAS6xB,GAAUjjB,GAClB,IAAI5O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1BC,EAAI8E,KAAM4sB,GAAU9iB,EAAG7O,KAExB,OAAOC,CACR,CCTA,SAAS8xB,GAAUljB,GAClB,IAAI5O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1BC,EAAI8E,KAAM+sB,GAAUjjB,EAAG7O,KAExB,OAAOC,CACR,CCdA,SAAS+xB,GAAUnjB,GAClB,IAAI5O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI6O,EAAErO,OAAO,EAAGR,GAAK,EAAGA,IAC7BC,EAAI8E,KAAM8J,EAAG7O,IAEd,OAAOC,CACR,CCJA,SAASgyB,GAAUpjB,GAClB,IAAI5O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1BC,EAAI8E,KAAMitB,GAAUnjB,EAAG7O,KAExB,OAAOC,CACR,CCTA,SAASiyB,GAAUrjB,GAClB,IAAI5O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1BC,EAAI8E,KAAMktB,GAAUpjB,EAAG7O,KAExB,OAAOC,CACR,CCbA,SAASkyB,GAAWrH,EAAIC,EAAIqH,GAC3B,IAAI/qB,EACAoC,EACAzJ,EAGJ,IADAyJ,EAAMsjB,IAAQhC,EAAGD,GAAOsH,KACZ,EACX,MAAO,CAAEtH,GAGV,IADAzjB,EAAM,CAAEyjB,GACF9qB,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBqH,EAAItC,KAAM+lB,EAAMsH,EAAUpyB,GAE3B,OAAOqH,CACR,CCLA,SAASH,GAAiBrH,GACzB,OACCyP,GAAczP,IACdoR,GAAYpR,EAAM4G,MAClBwK,GAAYpR,EAAM6G,IAEpB,CCZA,SAAS2rB,GAAmBxyB,GAC3B,OAAA,MAASA,CACV,CCLA,SAASyyB,GAAU3b,EAAGC,EAAGnN,GACxB,IAAIpC,EACAqO,EACA2N,EACArjB,EAEJ,GAAa,IAARyJ,EACJ,MAAO,GAQR,IAJA4Z,GAAMzM,EAAED,IADRjB,EAAIjM,EAAM,GAIVpC,EAAM,CAAEyhB,GAAK,GAAInS,IACX3W,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBqH,EAAItC,KAAM+jB,GAAK,GAAInS,EAAG0M,EAAErjB,IAGzB,OADAqH,EAAItC,KAAM+jB,GAAK,GAAIlS,IACZvP,CACR,CCfA,SAASkrB,GAAO1jB,EAAGuT,EAAOrN,EAAKZ,GAC9B,IAAIkO,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACAjZ,EAKJ,IAHAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZxJ,EAAI,GACEyL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAuN,EAAK/iB,EAAGwV,GACRwN,EAAK,GACCzN,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAG9sB,KAAMgQ,EAAIjT,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEC,EAAID,GAAMvV,IAEnD+J,EAAE7T,KAAM8sB,EACR,CACD,OAAOjZ,CACR,CCrBA,SAAS4Z,GAAO3jB,EAAGuT,EAAOrN,EAAKZ,GAC9B,IAAIkO,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA/G,EACA1B,EACAxQ,EAMJ,IAJAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZxJ,EAAI,GACEyW,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAvE,EAAKjc,EAAGwgB,GACRjG,EAAK,GACC/E,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAK,GACCzN,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAG9sB,KAAMgQ,EAAIjT,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEiL,EAAIhL,EAAID,GAAMvV,IAEvDua,EAAGrkB,KAAM8sB,EACT,CACDjZ,EAAE7T,KAAMqkB,EACR,CACD,OAAOxQ,CACR,CC/BA,SAAS6Z,GAAO5jB,EAAGuT,EAAOrN,EAAKZ,GAC9B,IAAIkO,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACAC,EACA/G,EACA1B,EACA2B,EACA2H,EACA9Z,EAOJ,IALAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZxJ,EAAI,GACE6W,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA1E,EAAKlc,EAAG4gB,GACRiD,EAAK,GACCrD,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAK,GACC/E,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAK,GACCzN,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAG9sB,KAAMgQ,EAAIjT,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMvV,IAE3Dua,EAAGrkB,KAAM8sB,EACT,CACDa,EAAG3tB,KAAMqkB,EACT,CACDxQ,EAAE7T,KAAM2tB,EACR,CACD,OAAO9Z,CACR,CCzCA,SAAS+Z,GAAO9jB,EAAGuT,EAAOrN,EAAKZ,GAC9B,IAAIkO,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACAC,EACA/G,EACA1B,EACA2B,EACA2H,EACAE,EACAC,EACAja,EAQJ,IANAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GACZxJ,EAAI,GACEiX,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA+C,EAAK/jB,EAAGghB,GACRgD,EAAK,GACCpD,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA1E,EAAK6H,EAAInD,GACTiD,EAAK,GACCrD,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAK,GACC/E,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAK,GACCzN,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAG9sB,KAAMgQ,EAAIjT,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMvV,IAE/Dua,EAAGrkB,KAAM8sB,EACT,CACDa,EAAG3tB,KAAMqkB,EACT,CACDyJ,EAAG9tB,KAAM2tB,EACT,CACD9Z,EAAE7T,KAAM8tB,EACR,CACD,OAAOja,CACR,CCjDA,SAASka,GAA0BjzB,GAClC,OAAKA,EAAQ,EACPA,GAASoO,GACN,OAEHpO,GAASqN,GACN,QAEHrN,GAAS0M,GACN,QAED,UAEH1M,GAASmO,GACN,OAEHnO,GAASoN,GACN,QAEHpN,GAASyM,GACN,QAED,SACR,CC5BA,SAASymB,GAAWlkB,EAAGmkB,GACtB,IAAItX,EACAuX,EACAhzB,EACAD,EAQJ,IALA0b,EAAO5D,GAAejJ,GACtBokB,EAAOnb,GAAekb,GAGtB/yB,EAAM,GACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrBizB,EAAMD,EAAMhzB,IAChBC,EAAI8E,KAAM2W,EAAM7M,EAAG7O,IAGrB,OAAOC,CACR,CCZA,SAASizB,GAAcrkB,EAAGmkB,EAAM5e,EAAMD,GACrC,IAAIuH,EACAuX,EACAhzB,EACAD,EAQJ,IALA0b,EAAO5D,GAAejJ,GACtBokB,EAAOnb,GAAekb,GAGtB/yB,EAAM,GACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrBizB,EAAMD,EAAMhzB,IAChBC,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAASuH,EAAM7M,EAAG7O,GAAKA,EAAG6O,IAGjD,OAAO5O,CACR,CCgMA,SAASkzB,GAAQtkB,EAAGmkB,EAAM3c,EAAQka,GACjC,IAAI/N,EACA4Q,EACAC,EACA1P,EAGJ,GADAA,EAAItN,EAAO7V,OACG,WAAT+vB,GACJ,GAAKnF,GAAY4H,KAAWrP,EAC3B,MAAM,IAAIniB,MAAO,yGAEZ,GAAc,cAAT+uB,GACX,GAAW,IAAN5M,GAAWyH,GAAY4H,GAASrP,EACpC,MAAM,IAAIniB,MAAO,sEAEZ,GAAc,qBAAT+uB,GACX,GAAW,IAAN5M,GAAWyH,GAAY4H,KAAWrP,EACtC,MAAM,IAAIniB,MAAO,yGAEZ,GAAc,eAAT+uB,GACNnF,GAAY4H,GAASrP,EACzB,MAAM,IAAIniB,MAAO,iEAMnB,OAHAghB,EAAK9K,GAAkB7I,GACvBukB,EAAK1b,GAAkBsb,GACvBK,EAAK3b,GAAkBrB,GAEtBmM,EAAGrL,kBACHic,EAAGjc,kBACHkc,EAAGlc,iBAGE6X,GAAmBxM,EAAGta,QAAW8mB,GAAmBqE,EAAGnrB,QAnJ9D,SAAkB2G,EAAGmkB,EAAM3c,GAC1B,IAAIid,EACAL,EACAM,EACA7d,EACA1V,EAOJ,IALAszB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBvB,EAAIW,EAAO7V,OACX+yB,EAAK,EACCvzB,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,GAAK,EACzBizB,EAAMK,EAAOtzB,EAAE,KACpB6O,EAAG7O,GAAMqW,EAAQkd,GACjB1kB,EAAG7O,EAAE,GAAMqW,EAAQkd,EAAG,GACtBA,GAAOA,EAAG,GAAM7d,EAInB,CAgIG6V,CAASD,GAAoBzc,EAAG,GAAKukB,EAAI9H,GAAoBjV,EAAQ,IAC9DxH,GAEHuN,GAAmBoG,EAAGta,QAAWkU,GAAmBiX,EAAGnrB,QA5G9D,SAAkB2G,EAAGmkB,EAAM3c,GAC1B,IAAIid,EACAL,EACAM,EACA7d,EACA1V,EAOJ,IALAszB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBvB,EAAIW,EAAO7V,OACX+yB,EAAK,EACCvzB,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACpBizB,EAAMK,EAAOtzB,KAClB6O,EAAG7O,GAAMqW,EAAQkd,GACjBA,GAAOvzB,EAAE,GAAM0V,EAIlB,CA0FGmW,CAASjJ,GAAoB/T,EAAG,GAAKukB,EAAIxQ,GAAoBvM,EAAQ,IAC9DxH,IA5MV,SAAoBA,EAAGmkB,EAAM3c,GAC5B,IAAImF,EACA8X,EACAE,EACAC,EACAR,EACAS,EACAH,EACA7d,EACA1V,EAYJ,IAVAwb,EAAQ3M,EAAE8I,KACV2b,EAAQN,EAAKrb,KACb6b,EAAQnd,EAAOsB,KAEf8b,EAAO5kB,EAAEoI,UAAW,GACpBgc,EAAOD,EAAK/b,UAAW,GACvByc,EAAOrd,EAAOY,UAAW,GAEzBvB,EAAI8d,EAAMhzB,OACV+yB,EAAK,EACCvzB,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,IACxBizB,EAAMK,EAAOtzB,KAClByzB,EAAMjY,EAAOxb,EAAG0zB,EAAMF,EAAOD,IAC7BA,GAAOA,EAAG,GAAM7d,EAInB,CAkLEuB,CAAWuL,EAAI4Q,EAAIC,GACZxkB,IAzPT,SAAkBA,EAAGmkB,EAAM3c,GAC1B,IAAIkd,EACA7d,EACA1V,EAIJ,IAFA0V,EAAIW,EAAO7V,OACX+yB,EAAK,EACCvzB,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACpBgzB,EAAMhzB,KACX6O,EAAG7O,GAAMqW,EAAQkd,GACjBA,GAAOA,EAAG,GAAM7d,EAInB,CA6OCyV,CAAStc,EAAGmkB,EAAM3c,GACXxH,EACR,CCtQA,SAAS8kB,GAAW9kB,EAAGmkB,GACtB,IAAItX,EACAuX,EACAhzB,EACAD,EAQJ,IALA0b,EAAO5D,GAAejJ,GACtBokB,EAAOnb,GAAekb,GAGtB/yB,EAAM,GACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACpBizB,EAAMD,EAAMhzB,IACjBC,EAAI8E,KAAM2W,EAAM7M,EAAG7O,IAGrB,OAAOC,CACR,CCZA,SAAS2zB,GAA0B1tB,EAAKC,EAAMtG,GAC7CF,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASA,GAEX,CCFA,SAASgY,GAAUhJ,GAClB,IAAI7O,EACJ,IAAMA,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1B,GAAK6O,EAAG7O,GACP,OAAO,EAGT,OAAO,CACR,CC5BA,SAAS6zB,GAAO9zB,GACf,IAAIsH,EACArH,EAGJ,GADAqH,EAAM,GACDtH,GAAK,EACT,OAAOsH,EAER,IAAMrH,EAAI,EAAGA,EAAID,EAAE,EAAGC,IACrBqH,EAAItC,KAAM/E,GAEX,OAAOqH,CACR,CCmDA,SAASkkB,GAAStrB,EAAK0X,EAAMgC,EAAQjH,GACpC,IAAIvJ,EACAyhB,EACA5qB,EAKJ,IAHA4qB,EAAa,EAATjR,EACJ3Z,EAAa,EAAT0S,EACJvJ,EAAI,EACInJ,GAAK,GAAKA,EAAI2X,EAAKnX,QAC1BmX,EAAM3X,GAAMmJ,EACZwO,EAAM3X,EAAE,GAAM,EACdA,GAAK4qB,EACLzhB,GAAK,EAEN,OAAOlJ,CACR,CCmJA,SAAS6zB,GAAOjlB,EAAGmkB,EAAM3c,EAAQka,GAChC,IAAI/N,EACA4Q,EACAC,EACA1P,EAGJ,GADAA,EAAItN,EAAO7V,OACG,WAAT+vB,GACJ,GAAK7E,GAAasH,KAAWrP,EAC5B,MAAM,IAAIniB,MAAO,0GAEZ,GAAc,cAAT+uB,GACX,GAAW,IAAN5M,GAAW+H,GAAasH,GAASrP,EACrC,MAAM,IAAIniB,MAAO,sEAEZ,GAAc,qBAAT+uB,GACX,GAAW,IAAN5M,GAAW+H,GAAasH,KAAWrP,EACvC,MAAM,IAAIniB,MAAO,0GAEZ,GAAc,eAAT+uB,GACN7E,GAAasH,GAASrP,EAC1B,MAAM,IAAIniB,MAAO,iEAMnB,OAHAghB,EAAK9K,GAAkB7I,GACvBukB,EAAK1b,GAAkBsb,GACvBK,EAAK3b,GAAkBrB,GAEtBmM,EAAGrL,kBACHic,EAAGjc,kBACHkc,EAAGlc,iBAGE6X,GAAmBxM,EAAGta,QAAW8mB,GAAmBqE,EAAGnrB,QAnJ9D,SAAkB2G,EAAGmkB,EAAM3c,GAC1B,IAAIid,EACAL,EACAM,EACA7d,EACA1V,EAOJ,IALAszB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBvB,EAAIW,EAAO7V,OACX+yB,EAAK,EACCvzB,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,GAAK,EAC1BizB,EAAMK,EAAOtzB,EAAE,KACnB6O,EAAG7O,GAAMqW,EAAQkd,GACjB1kB,EAAG7O,EAAE,GAAMqW,EAAQkd,EAAG,GACtBA,GAAOA,EAAG,GAAM7d,EAInB,CAgIG6V,CAASD,GAAoBzc,EAAG,GAAKukB,EAAI9H,GAAoBjV,EAAQ,IAC9DxH,GAEHuN,GAAmBoG,EAAGta,QAAWkU,GAAmBiX,EAAGnrB,QA5G9D,SAAkB2G,EAAGmkB,EAAM3c,GAC1B,IAAIid,EACAL,EACAM,EACA7d,EACA1V,EAOJ,IALAszB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBvB,EAAIW,EAAO7V,OACX+yB,EAAK,EACCvzB,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrBizB,EAAMK,EAAOtzB,KACjB6O,EAAG7O,GAAMqW,EAAQkd,GACjBA,GAAOvzB,EAAE,GAAM0V,EAIlB,CA0FGmW,CAASjJ,GAAoB/T,EAAG,GAAKukB,EAAIxQ,GAAoBvM,EAAQ,IAC9DxH,IA5MV,SAAoBA,EAAGmkB,EAAM3c,GAC5B,IAAImF,EACA8X,EACAE,EACAC,EACAR,EACAS,EACAH,EACA7d,EACA1V,EAYJ,IAVAwb,EAAQ3M,EAAE8I,KACV2b,EAAQN,EAAKrb,KACb6b,EAAQnd,EAAOsB,KAEf8b,EAAO5kB,EAAEoI,UAAW,GACpBgc,EAAOD,EAAK/b,UAAW,GACvByc,EAAOrd,EAAOY,UAAW,GAEzBvB,EAAI8d,EAAMhzB,OACV+yB,EAAK,EACCvzB,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,IACzBizB,EAAMK,EAAOtzB,KACjByzB,EAAMjY,EAAOxb,EAAG0zB,EAAMF,EAAOD,IAC7BA,GAAOA,EAAG,GAAM7d,EAInB,CAkLEuB,CAAWuL,EAAI4Q,EAAIC,GACZxkB,IAzPT,SAAkBA,EAAGmkB,EAAM3c,GAC1B,IAAIkd,EACA7d,EACA1V,EAIJ,IAFA0V,EAAIW,EAAO7V,OACX+yB,EAAK,EACCvzB,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrBgzB,EAAMhzB,KACV6O,EAAG7O,GAAMqW,EAAQkd,GACjBA,GAAOA,EAAG,GAAM7d,EAInB,CA6OCyV,CAAStc,EAAGmkB,EAAM3c,GACXxH,EACR,CCxQA,SAASklB,GAAYzsB,EAAK0a,GACzB,OAAK1a,EAAM,EACH,EAEHA,EAAM0a,EACHA,EAED1a,CACR,CCRA,SAAS0sB,GAAW1sB,EAAK0a,GACxB,IAAIiS,EAAMjS,EAAM,EAChB,OAAK1a,EAAM,IACVA,GAAO2sB,GACI,GAEG,IADb3sB,GAAO2sB,KAEN3sB,GAAO2sB,GAGF3sB,GAEHA,EAAM0a,IACV1a,GAAO2sB,GACIjS,IACV1a,GAAO2sB,GAED3sB,GAEDA,CACR,CCpBA,SAAS4sB,GAAgB5sB,EAAK0a,GAC7B,OAAK1a,EAAM,GACVA,GAAO0a,EAAM,GACF,GACF,EAEF1a,EAEHA,EAAM0a,GACF,EAEF1a,CACR,CCNA,SAAS2Q,GAASpJ,GACjB,IAAIpI,EACAgD,EACAyN,EAEJ,IAAM5H,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,oEAAqE6J,IAYnG,OATAqI,EAAKhP,GAAO2G,GAGP3H,GAAiB2H,KACrBpI,EAAM8N,GAAgB2C,IAGvBzN,EAAMoF,EAAErO,YAES,IAARiG,EAYT,SAAmB5G,GAClB,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAK6O,EAAG7O,KAAQH,EACf,OAAO,EAGT,OAAO,CACP,EAQD,SAAoBA,GACnB,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAKyG,EAAKoI,EAAG7O,KAAQH,EACpB,OAAO,EAGT,OAAO,CACP,CACF,CCxBA+G,EAAAnH,GAAA,SAAAma,ICZAhT,EAAAnH,GAAA,UCXA,SAAoBoP,EAAGuT,EAAOkC,EAAiBrkB,EAAK0Z,EAAQjH,GAC3D,IAAI2P,EACAC,EACA8B,EACAC,EACAF,EACAyH,EAQJ,GALAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBpkB,EAAK2rB,GAAO/c,EAAGwV,GAAMD,GACrBwH,GAAMjS,EAGR,OAAO1Z,CACP,CACD,IAAMokB,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKtV,EAAGwV,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAK2rB,GAAOzH,EAAIC,GAChBwH,GAAMjS,EAGR,OAAO1Z,CACR,ICRA2G,EAAAnH,GAAA,UCbA,SAAsBoP,EAAGuT,EAAOkC,EAAiBrkB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GAC3E,IAAIkO,EACAC,EACA8B,EACAC,EACAF,EACAyH,EAQJ,GALAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBpkB,EAAK2rB,GAAOxX,EAAKtS,KAAMqS,EAAStF,EAAGwV,GAAMD,GAAM,CAAEC,EAAID,GAAMvV,GAC3D+c,GAAMjS,EAGR,OAAO1Z,CACP,CACD,IAAMokB,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKtV,EAAGwV,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAK2rB,GAAOxX,EAAKtS,KAAMqS,EAASgQ,EAAIC,GAAM,CAAEC,EAAID,GAAMvV,GACtD+c,GAAMjS,EAGR,OAAO1Z,CACR,IC/BA2G,EAAAnH,GAAA,UCVA,SAAoBoP,EAAGuT,EAAOkC,EAAiBrkB,EAAK0Z,EAAQjH,GAC3D,IAAI2P,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAlL,EACAgL,EACAvD,EASJ,GANAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtBpvB,EAAK2rB,GAAO/c,EAAGwgB,GAAMhL,GAAMD,GAC3BwH,GAAMjS,EAIT,OAAO1Z,CACP,CACD,IAAMovB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKtgB,EAAGwgB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAK2rB,GAAOzH,EAAIC,GAChBwH,GAAMjS,EAIT,OAAO1Z,CACR,IClBA2G,EAAAnH,GAAA,UCVA,SAAsBoP,EAAGuT,EAAOkC,EAAiBrkB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GAC3E,IAAIkO,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAlL,EACAgL,EACAvD,EASJ,GANAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtBpvB,EAAK2rB,GAAOxX,EAAKtS,KAAMqS,EAAStF,EAAGwgB,GAAMhL,GAAMD,GAAM,CAAEiL,EAAIhL,EAAID,GAAMvV,GACrE+c,GAAMjS,EAIT,OAAO1Z,CACP,CACD,IAAMovB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKtgB,EAAGwgB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAK2rB,GAAOxX,EAAKtS,KAAMqS,EAASgQ,EAAIC,GAAM,CAAEiL,EAAIhL,EAAID,GAAMvV,GAC1D+c,GAAMjS,EAIT,OAAO1Z,CACR,ICzCA2G,EAAAnH,GAAA,UCXA,SAAoBoP,EAAGuT,EAAOkC,EAAiBrkB,EAAK0Z,EAAQjH,GAC3D,IAAI2P,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAtL,EACAgL,EACAI,EACA3D,EAUJ,GAPAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtBxvB,EAAK2rB,GAAO/c,EAAG4gB,GAAMJ,GAAMhL,GAAMD,GACjCwH,GAAMjS,EAKV,OAAO1Z,CACP,CACD,IAAMwvB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK1gB,EAAG4gB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAK2rB,GAAOzH,EAAIC,GAChBwH,GAAMjS,EAKV,OAAO1Z,CACR,IC1BA2G,EAAAnH,GAAA,UCXA,SAAsBoP,EAAGuT,EAAOkC,EAAiBrkB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GAC3E,IAAIkO,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAtL,EACAgL,EACAI,EACA3D,EAUJ,GAPAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtBxvB,EAAK2rB,GAAOxX,EAAKtS,KAAMqS,EAAStF,EAAG4gB,GAAMJ,GAAMhL,GAAMD,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMvV,GAC/E+c,GAAMjS,EAKV,OAAO1Z,CACP,CACD,IAAMwvB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK1gB,EAAG4gB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAK2rB,GAAOxX,EAAKtS,KAAMqS,EAASgQ,EAAIC,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMvV,GAC9D+c,GAAMjS,EAKV,OAAO1Z,CACR,IClDA2G,EAAAnH,GAAA,UCTA,SAAoBoP,EAAGuT,EAAOkC,EAAiBrkB,EAAK0Z,EAAQjH,GAC3D,IAAI2P,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA1L,EACAgL,EACAI,EACAI,EACA/D,EAWJ,GARAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB5vB,EAAK2rB,GAAO/c,EAAGghB,GAAMJ,GAAMJ,GAAMhL,GAAMD,GACvCwH,GAAMjS,EAMX,OAAO1Z,CACP,CACD,IAAM4vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK9gB,EAAGghB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAK2rB,GAAOzH,EAAIC,GAChBwH,GAAMjS,EAMX,OAAO1Z,CACR,ICrCA2G,EAAAnH,GAAA,UCXA,SAAsBoP,EAAGuT,EAAOkC,EAAiBrkB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GAC3E,IAAIkO,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA1L,EACAgL,EACAI,EACAI,EACA/D,EAWJ,GARAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB5vB,EAAK2rB,GAAOxX,EAAKtS,KAAMqS,EAAStF,EAAGghB,GAAMJ,GAAMJ,GAAMhL,GAAMD,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMvV,GACzF+c,GAAMjS,EAMX,OAAO1Z,CACP,CACD,IAAM4vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK9gB,EAAGghB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBnkB,EAAK2rB,GAAOxX,EAAKtS,KAAMqS,EAASgQ,EAAIC,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMvV,GAClE+c,GAAMjS,EAMX,OAAO1Z,CACR,ICtDA2G,EAAAnH,GAAA,UCdA,SAAgBoP,EAAG+J,EAAGwJ,EAAOrN,EAAKZ,GACjC,IAAIkO,EACAC,EACA8B,EACAC,EACAuN,EACAC,EAIJ,GAFAxP,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACPC,GAAM,GAAKC,GAAM,EACrB,OAAO1J,EAER,IAAMyL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK/iB,EAAGwV,GACRwN,EAAKjZ,EAAGyL,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAIjT,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEC,EAAID,GAAMvV,GAGtD,OAAO+J,CACR,ICPAhS,EAAAnH,GAAA,UCdA,SAAgBoP,EAAG+J,EAAGwJ,EAAOrN,EAAKZ,GACjC,IAAIkO,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA/G,EACA1B,EAKJ,GAHA/G,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,EAChC,OAAOxW,EAER,IAAMyW,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKjc,EAAGwgB,GACRjG,EAAKxQ,EAAGyW,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAIjT,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEiL,EAAIhL,EAAID,GAAMvV,GAI3D,OAAO+J,CACR,IChBAhS,EAAAnH,GAAA,UCdA,SAAgBoP,EAAG+J,EAAGwJ,EAAOrN,EAAKZ,GACjC,IAAIkO,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACAC,EACA/G,EACA1B,EACA2B,EACA2H,EAMJ,GAJArQ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,EAC3C,OAAO5W,EAER,IAAM6W,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAKlc,EAAG4gB,GACRiD,EAAK9Z,EAAG6W,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAIjT,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMvV,GAKhE,OAAO+J,CACR,ICzBAhS,EAAAnH,GAAA,UCdA,SAAgBoP,EAAG+J,EAAGwJ,EAAOrN,EAAKZ,GACjC,IAAIkO,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACAC,EACA/G,EACA1B,EACA2B,EACA2H,EACAE,EACAC,EAOJ,GALAxQ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,EACtD,OAAOhX,EAER,IAAMiX,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA+C,EAAK/jB,EAAGghB,GACRgD,EAAKja,EAAGiX,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAIjT,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMvV,GAMrE,OAAO+J,CACR,IC9CAhS,EAAAnH,GAAA,UCgLA,SAAiBoP,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACtC,IAAI8P,EACA4Q,EACAe,EAKJ,OAHA3R,EAAK9K,GAAkB7I,GACvBukB,EAAK1b,GAAkBsb,GACvBmB,EAAKzc,GAAkBzX,GAEtBuiB,EAAGrL,kBACHic,EAAGjc,kBACHgd,EAAGhd,iBAIF6X,GAAmBxM,EAAGta,QACtB8mB,GAAmBmF,EAAGjsB,QA1GzB,SAAkB2G,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACvC,IAAI4gB,EACAL,EACArH,EACAwI,EACAp0B,EACA8D,EAOJ,IALAwvB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBmd,EAAc,EAATza,EACLiS,EAAc,EAATlZ,EACC1S,EAAI,EAAGA,EAAIszB,EAAM9yB,OAAQR,IACzBizB,EAAMK,EAAOtzB,KACjB8D,EAAQ,EAAJ9D,EACJC,EAAK2rB,GAAO/c,EAAG/K,GACf7D,EAAK2rB,EAAG,GAAM/c,EAAG/K,EAAE,GACnB8nB,GAAMwI,EAIT,CAsFG7I,CAAS9Y,GAAa5D,EAAG,GAAKukB,EAAI3gB,GAAaxS,EAAK,GAAK0Z,EAAQjH,GAC1DzS,GAGPmc,GAAmBoG,EAAGta,QACtBkU,GAAmB+X,EAAGjsB,QAlEzB,SAAkB2G,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACvC,IAAI4gB,EACAL,EACArH,EACA5rB,EAMJ,IAJAszB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvB2U,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIszB,EAAM9yB,OAAQR,IACzBizB,EAAMK,EAAOtzB,KACjBC,EAAK2rB,GAAO/c,EAAG7O,GACf4rB,GAAMjS,EAIT,CAmDGkS,CAASjJ,GAAoB/T,EAAG,GAAKukB,EAAIxQ,GAAoB3iB,EAAK,GAAK0Z,EAAQjH,GACxEzS,IAvKV,SAAoB4O,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACzC,IAAI8I,EACA8X,EACAe,EACA3Y,EACAuX,EACAqB,EACA1I,EACA5rB,EAWJ,IATAwb,EAAQ3M,EAAE8I,KACV2b,EAAQN,EAAKrb,KACb0c,EAAQp0B,EAAI0X,KAEZ+D,EAAO7M,EAAEoI,UAAW,GACpBgc,EAAOD,EAAK/b,UAAW,GACvBqd,EAAOr0B,EAAIgX,UAAW,GAEtB2U,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,IACzBizB,EAAMK,EAAOtzB,KACjBs0B,EAAMD,EAAOzI,EAAIlQ,EAAMF,EAAOxb,IAC9B4rB,GAAMjS,EAIT,CA+IE1C,CAAWuL,EAAI4Q,EAAIe,EAAIxa,EAAQjH,GACxBzS,IAnNT,SAAkB4O,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACvC,IAAIkZ,EACA5rB,EAGJ,IADA4rB,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrBgzB,EAAMhzB,KACVC,EAAK2rB,GAAO/c,EAAG7O,GACf4rB,GAAMjS,EAIT,CAyMCwR,CAAStc,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACxBzS,EACR,ICzMA2G,EAAAnH,GAAA,UC6FA,SAAiBoP,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GACpD,IAAIqO,EACA4Q,EACAe,EAKJ,OAHA3R,EAAK9K,GAAkB7I,GACvBukB,EAAK1b,GAAkBsb,GACvBmB,EAAKzc,GAAkBzX,GAEtBuiB,EAAGrL,kBACHic,EAAGjc,kBACHgd,EAAGhd,kBArEL,SAAoBtI,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GACvD,IAAIqH,EACA8X,EACAe,EACA3Y,EACAuX,EACAqB,EACA1I,EACA5rB,EAWJ,IATAwb,EAAQ3M,EAAE8I,KACV2b,EAAQN,EAAKrb,KACb0c,EAAQp0B,EAAI0X,KAEZ+D,EAAO7M,EAAEoI,UAAW,GACpBgc,EAAOD,EAAK/b,UAAW,GACvBqd,EAAOr0B,EAAIgX,UAAW,GAEtB2U,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,IACzBizB,EAAMK,EAAOtzB,KACjBs0B,EAAMD,EAAOzI,EAAIxX,EAAKtS,KAAMqS,EAASuH,EAAMF,EAAOxb,GAAKA,EAAGwb,IAC1DoQ,GAAMjS,EAIT,CA6CE1C,CAAWuL,EAAI4Q,EAAIe,EAAIxa,EAAQjH,EAAQ0B,EAAMD,GACtClU,IAvHT,SAAkB4O,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GACrD,IAAIyX,EACA5rB,EAGJ,IADA4rB,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrBgzB,EAAMhzB,KACVC,EAAK2rB,GAAOxX,EAAKtS,KAAMqS,EAAStF,EAAG7O,GAAKA,EAAG6O,GAC3C+c,GAAMjS,EAIT,CA6GCwR,CAAStc,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,EAAQ0B,EAAMD,GACtClU,EACR,ICvHA2G,EAAAnH,GAAA,UCgLA,SAAiBoP,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACtC,IAAI8P,EACA4Q,EACAe,EAKJ,OAHA3R,EAAK9K,GAAkB7I,GACvBukB,EAAK1b,GAAkBsb,GACvBmB,EAAKzc,GAAkBzX,GAEtBuiB,EAAGrL,kBACHic,EAAGjc,kBACHgd,EAAGhd,iBAIF6X,GAAmBxM,EAAGta,QACtB8mB,GAAmBmF,EAAGjsB,QA1GzB,SAAkB2G,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACvC,IAAI4gB,EACAL,EACArH,EACAwI,EACAp0B,EACA8D,EAOJ,IALAwvB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBmd,EAAc,EAATza,EACLiS,EAAc,EAATlZ,EACC1S,EAAI,EAAGA,EAAIszB,EAAM9yB,OAAQR,IACxBizB,EAAMK,EAAOtzB,KAClB8D,EAAQ,EAAJ9D,EACJC,EAAK2rB,GAAO/c,EAAG/K,GACf7D,EAAK2rB,EAAG,GAAM/c,EAAG/K,EAAE,GACnB8nB,GAAMwI,EAIT,CAsFG7I,CAAS9Y,GAAa5D,EAAG,GAAKukB,EAAI3gB,GAAaxS,EAAK,GAAK0Z,EAAQjH,GAC1DzS,GAGPmc,GAAmBoG,EAAGta,QACtBkU,GAAmB+X,EAAGjsB,QAlEzB,SAAkB2G,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACvC,IAAI4gB,EACAL,EACArH,EACA5rB,EAMJ,IAJAszB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvB2U,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIszB,EAAM9yB,OAAQR,IACxBizB,EAAMK,EAAOtzB,KAClBC,EAAK2rB,GAAO/c,EAAG7O,GACf4rB,GAAMjS,EAIT,CAmDGkS,CAASjJ,GAAoB/T,EAAG,GAAKukB,EAAIxQ,GAAoB3iB,EAAK,GAAK0Z,EAAQjH,GACxEzS,IAvKV,SAAoB4O,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACzC,IAAI8I,EACA8X,EACAe,EACA3Y,EACAuX,EACAqB,EACA1I,EACA5rB,EAWJ,IATAwb,EAAQ3M,EAAE8I,KACV2b,EAAQN,EAAKrb,KACb0c,EAAQp0B,EAAI0X,KAEZ+D,EAAO7M,EAAEoI,UAAW,GACpBgc,EAAOD,EAAK/b,UAAW,GACvBqd,EAAOr0B,EAAIgX,UAAW,GAEtB2U,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,IACxBizB,EAAMK,EAAOtzB,KAClBs0B,EAAMD,EAAOzI,EAAIlQ,EAAMF,EAAOxb,IAC9B4rB,GAAMjS,EAIT,CA+IE1C,CAAWuL,EAAI4Q,EAAIe,EAAIxa,EAAQjH,GACxBzS,IAnNT,SAAkB4O,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACvC,IAAIkZ,EACA5rB,EAGJ,IADA4rB,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACpBgzB,EAAMhzB,KACXC,EAAK2rB,GAAO/c,EAAG7O,GACf4rB,GAAMjS,EAIT,CAyMCwR,CAAStc,EAAGmkB,EAAM/yB,EAAK0Z,EAAQjH,GACxBzS,EACR,ICvNA2G,EAAAnH,GAAA,UrCgIA,SAAiBQ,EAAK0Z,EAAQjH,GAC7B,IAAIxM,EAAMwR,GAAkBzX,GAC5B,OAAKiG,EAAIiR,iBAEHhF,GAAmBlS,GAChBsrB,GAAStrB,EAAK8T,GAAgB9T,EAAK,GAAK0Z,EAAQjH,GAEnDR,GAAkBjS,GACfsrB,GAAStrB,EAAK6T,GAAe7T,EAAK,GAAK0Z,EAAQjH,GAlDzD,SAAoBzS,EAAK0Z,EAAQjH,GAChC,IAAIiF,EACAjR,EACAyC,EACAnJ,EAOJ,IALA2X,EAAO1X,EAAI0X,KACXjR,EAAMzG,EAAIgX,UAAW,GAErBjX,EAAI0S,EACJvJ,EAAI,EACInJ,GAAK,GAAKA,EAAI2X,EAAKnX,QAC1BkG,EAAKiR,EAAM3X,EAAGmJ,GACdnJ,GAAK2Z,EACLxQ,GAAK,EAEN,OAAOwO,CACR,CAmCSV,CAAW/Q,EAAKyT,EAAQjH,GAzIjC,SAAkBzS,EAAK0Z,EAAQjH,GAC9B,IAAIvJ,EACAnJ,EAIJ,IAFAA,EAAI0S,EACJvJ,EAAI,EACInJ,GAAK,GAAKA,EAAIC,EAAIO,QACzBP,EAAKD,GAAMmJ,EACXnJ,GAAK2Z,EACLxQ,GAAK,EAEN,OAAOlJ,CACR,CA+HQkrB,CAASlrB,EAAK0Z,EAAQjH,EAC9B,IsCvJA9L,GCAA,SAAmBiI,EAAGhP,GACrB,IAAI4J,EACAhD,EACAyQ,EACAlX,EAeJ,IAZAkX,EAAKhP,GAAO2G,GAIXpI,EADIS,GAAiB2H,GACf0F,GAAgB2C,GAEhBjP,GAAQiP,GAGfzN,EAAMoF,EAAErO,OAGFR,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAKyG,EAAKoI,EAAG7O,KAAQH,EACpB,OAAO,EAGT,OAAO,CACR,GDzBA,UAAAoY,gDELA,SAASsc,KACR,OAAOC,GAAM3vB,OACd,CCGA+B,EAAA2tB,GAAA,QCLA,WAEC,MAAO,CACNE,MAAS,EACTC,MAAS,EACTC,KAAQ,EACRzN,UAAa,EAEf,ICKA,IAAI0N,GAAc5c,GAAUuc,MClBxB9T,GAAQ,CACXkU,KAAQX,GACRU,MAASX,GACT7M,UAoDD,SAAyB5f,EAAK0a,GAC7B,IAAI1L,EAAQ4Q,GAAW5f,EAAK0a,GAC5B,GAAK1L,EAAQ,GAAKA,EAAQ0L,EACzB,MAAM,IAAInO,WAAY7O,EAAQ,yFAA0Fgd,EAAK1a,IAE9H,OAAOgP,CACR,EAzDCme,MAyBD,SAA6BntB,EAAK0a,GACjC,GAAK1a,EAAM,GAAKA,EAAM0a,EACrB,MAAM,IAAInO,WAAY7O,EAAQ,yFAA0Fgd,EAAK1a,IAE9H,OAAOA,CACR,GAuFA,SAAS2Q,GAASsY,GACjB,IAAMqE,GAAarE,GAClB,MAAM,IAAIxsB,UAAWiB,EAAQ,iFAAkFurB,IAEhH,OAAO9P,GAAO8P,EACf,CC6GA,SAASsE,GAAKhmB,EAAG4K,EAASpD,EAAQka,GACjC,IAAIuE,EACAnb,EACAqI,EACAQ,EACAoJ,EACAyH,EAGJ,GAAK5Z,EAAQjZ,OAAS,EAErB,GAAK6V,EAAO7V,SAAWiZ,EAAQjZ,OAC9BmZ,EAAS,MACH,IAAuB,IAAlBtD,EAAO7V,OAGlB,MAAM,IAAIgB,MAAOwD,EAAQ,sIAAuIqR,EAAO7V,OAAQiZ,EAAQjZ,SAFvLmZ,EAAS,CAGT,CAWF,OARAmb,EAAWtE,GAAKD,GAGhBvO,EAAMnT,EAAErO,OAAS,EAEjBgiB,EAAK9K,GAAkB7I,GACvB+c,EAAKlU,GAAkB+B,GACvB4Z,EAAK3b,GAAkBrB,GAEtBmM,EAAGrL,kBACHyU,EAAGzU,kBACHkc,EAAGlc,iBAGE6X,GAAmBxM,EAAGta,QAAW8mB,GAAmBqE,EAAGnrB,QA7I9D,SAAkB2G,EAAG4K,EAASpD,EAAQsD,EAAQmb,EAAUC,GACvD,IAAIC,EACAC,EACA1B,EACA2B,EACAl1B,EAEA6d,EAOJ,IALAmX,EAAQvb,EAAQ9B,KAChBsd,EAAOxb,EAAQxC,UAAW,GAE1Bie,EAAc,EAATvb,EACL4Z,EAAK,EACCvzB,EAAI,EAAGA,EAAIg1B,EAAMx0B,OAAQR,IAG9B6O,EADAgP,EAAQ,EADJiX,EAAUG,EAAMD,EAAOh1B,GAAK+0B,IAEvB1e,EAAQkd,GACjB1kB,EAAGgP,EAAE,GAAMxH,EAAQkd,EAAG,GACtBA,GAAM2B,CAGR,CAwHG3J,CAASD,GAAoBzc,EAAG,GAAK+c,EAAIN,GAAoBjV,EAAQ,GAAKsD,EAAQmb,EAAU9S,GACrFnT,GAEHuN,GAAmBoG,EAAGta,QAAWkU,GAAmBiX,EAAGnrB,QA9F9D,SAAkB2G,EAAG4K,EAASpD,EAAQsD,EAAQmb,EAAUC,GACvD,IAAIC,EACAC,EACA1B,EACAvzB,EAOJ,IAJAg1B,EAAQvb,EAAQ9B,KAChBsd,EAAOxb,EAAQxC,UAAW,GAE1Bsc,EAAK,EACCvzB,EAAI,EAAGA,EAAIg1B,EAAMx0B,OAAQR,IAE9B6O,EADIimB,EAAUG,EAAMD,EAAOh1B,GAAK+0B,IACvB1e,EAAQkd,GACjBA,GAAM5Z,CAGR,CA8EGkS,CAASjJ,GAAoB/T,EAAG,GAAK+c,EAAIhJ,GAAoBvM,EAAQ,GAAKsD,EAAQmb,EAAU9S,GACrFnT,IA1MV,SAAoBA,EAAG4K,EAASpD,EAAQsD,EAAQmb,EAAUC,GACzD,IAAIvZ,EACAwZ,EACAxB,EACAC,EACAwB,EACAvB,EACAH,EACAvzB,EAYJ,IATAwb,EAAQ3M,EAAE8I,KACVqd,EAAQvb,EAAQ9B,KAChB6b,EAAQnd,EAAOsB,KAEf8b,EAAO5kB,EAAEoI,UAAW,GACpBge,EAAOxb,EAAQxC,UAAW,GAC1Byc,EAAOrd,EAAOY,UAAW,GAEzBsc,EAAK,EACCvzB,EAAI,EAAGA,EAAIg1B,EAAMx0B,OAAQR,IAE9ByzB,EAAMjY,EADFsZ,EAAUG,EAAMD,EAAOh1B,GAAK+0B,GAChBrB,EAAMF,EAAOD,IAC7BA,GAAM5Z,CAGR,CAkLE1C,CAAWuL,EAAIoJ,EAAIyH,EAAI1Z,EAAQmb,EAAU9S,GAClCnT,IA3PT,SAAkBA,EAAG4K,EAASpD,EAAQsD,EAAQmb,EAAUC,GACvD,IAAIxB,EACAvzB,EAIJ,IADAuzB,EAAK,EACCvzB,EAAI,EAAGA,EAAIyZ,EAAQjZ,OAAQR,IAEhC6O,EADIimB,EAAUrb,EAASzZ,GAAK+0B,IACnB1e,EAAQkd,GACjBA,GAAM5Z,CAGR,CAiPCwR,CAAStc,EAAG4K,EAASpD,EAAQsD,EAAQmb,EAAU9S,GACxCnT,EACR,CCxNAjI,GClBA,SAAcU,EAAK0a,EAAKuO,GACvB,IAAIja,EACJ,GAAc,UAATia,EACJ,OAAOwD,GAAYzsB,EAAK0a,GAEzB,GAAc,SAATuO,EACJ,OAAOyD,GAAW1sB,EAAK0a,GAMxB,GAJA1L,EAAQhP,EACM,cAATipB,IACJja,EAAQ4d,GAAgB5d,EAAO0L,IAE3B1L,EAAQ,GAAKA,EAAQ0L,EACzB,MAAM,IAAInO,WAAY7O,EAAQ,yFAA0Fgd,EAAK1a,IAE9H,OAAOgP,CACR,GDEA,UAAA2B,IEtEA,IAAIkd,GAAahyB,MAAMtC,UAAUgE,MA4GjC,SAASA,GAAOgK,EAAG6F,EAAOI,GACzB,IAAI5O,EACJ,OAzFD,SAAoBA,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CAuFMC,CAAWxmB,EAAG,SACXA,EAAEhK,MAAO6P,EAAOI,IAExB5O,EAAMwR,GAAkB7I,IACfsI,iBApDV,SAAoBtI,EAAG6F,EAAOI,GAC7B,IAAI6C,EACAlR,EACAxG,EACAD,EAKJ,IAHA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GACnBhX,EAAM,GACAD,EAAI0U,EAAO1U,EAAI8U,EAAK9U,IACzBC,EAAI8E,KAAM0B,EAAKkR,EAAM3X,IAEtB,OAAOC,CACR,CAwCSgX,CAAW/Q,EAAKwO,EAAOI,GA3EhC,SAAkBjG,EAAG6F,EAAOI,GAC3B,OAAOqgB,GAAWrzB,KAAM+M,EAAG6F,EAAOI,EACnC,CA4EQ7O,CAAS4I,EAAG6F,EAAOI,EAC3B,CC3GA,SAASmO,GAASqS,EAAOpS,EAAOd,EAAOe,EAAK7M,GAC3C,IAAIif,EACAC,EACAv1B,EACAojB,EACAD,EACApjB,EAGJ,GADAojB,EAAIhB,EAAOe,GACNA,IAAQD,EAAQ,EACpB,OAAOre,GAAOywB,EAAOhf,EAAOA,EAAQ8M,GAKrC,IADAmS,EAAW,EACLv1B,EAFNqjB,EAAIF,EAAM,EAEGnjB,EAAIoiB,EAAM5hB,OAAQR,IAC9Bu1B,GAAYnT,EAAOpiB,GAIpB,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAIojB,EAAGpjB,IACnBw1B,EAAWvS,GAASqS,EAAOpS,EAAOd,EAAOiB,EAAG/M,GAC5CrW,EAAI8E,KAAMywB,GACVlf,GAASif,EAEV,OAAOt1B,CACR,CCbA,SAASw1B,GAAe5mB,GACvB,IAAIqI,EAAKhP,GAAO2G,GAChB,OAAK3H,EAAiB2H,GACduI,EAAgBF,GAEjB9O,EAAQ8O,EAChB,CCtBA,IAAA6K,GAAA,CAAA,EAUAnb,EAAAmb,GAAA,cCAA,SAAqBrM,EAAGtB,EAAMD,GAC7B,IAAI9M,EACA8c,EACAnkB,EACA8D,EAIJ,IADAuD,EAAM,GACArH,EAAI,EAAGA,EAAI0V,EAAG1V,IAAM,CAEzB,IADAmkB,EAAK,GACCrgB,EAAI,EAAGA,EAAI4R,EAAG5R,IACd9D,EAAI8D,EACRqgB,EAAGpf,KAAMsC,EAAKvD,GAAK9D,IAEnBmkB,EAAGpf,KAAMqP,EAAKtS,KAAMqS,EAAS,CAAEnU,EAAG8D,KAGpCuD,EAAItC,KAAMof,EACV,CACD,OAAO9c,CACR,IC9BA,IAAA0a,GAAA,CAAA,ECOA,SAAS2T,GAAM7mB,EAAG4K,EAAS8W,GAC1B,IAAIuE,EACApZ,EACAuZ,EACAh1B,EACA+hB,EACAhiB,EACA8D,EAcJ,IAXA4X,EAAO5D,GAAejJ,GACtBomB,EAAOnd,GAAe2B,GAGtBqb,EAAWtE,GAAKD,GAGhBvO,EAAMnT,EAAErO,OAAS,EAGjBP,EAAM,GACAD,EAAI,EAAGA,EAAIyZ,EAAQjZ,OAAQR,IAChC8D,EAAIgxB,EAAUG,EAAMxb,EAASzZ,GAAKgiB,GAClC/hB,EAAI8E,KAAM2W,EAAM7M,EAAG/K,IAEpB,OAAO7D,CACR,CDvBA2G,EAAAmb,GAAA,cEEA,SAAqBrM,EAAGmI,EAAGqG,EAAM9P,EAAMD,GACtC,IAAI9M,EACA8c,EACAnkB,EACA8D,EAIJ,IADAuD,EAAM,GACArH,EAAI,EAAGA,EAAI0V,EAAG1V,IAAM,CAEzB,IADAmkB,EAAK,GACCrgB,EAAI,EAAGA,EAAI4R,EAAG5R,IAEdA,GAAK9D,GAAK8D,GAAK9D,EAAE6d,EACrBsG,EAAGpf,KAAMqP,EAAKtS,KAAMqS,EAAS,CAAEnU,EAAG8D,KAGzBA,EAAI9D,EACbmkB,EAAGpf,KAAMsC,EAAKvD,GAAK9D,IAInBmkB,EAAGpf,KAAMmf,GAGX7c,EAAItC,KAAMof,EACV,CACD,OAAO9c,CACR,IFnBAT,EAAAmb,GAAA,aGsBA,SAAoB4T,EAAMtuB,EAAKwW,EAAGyG,GACjC,IAAIrkB,EACAmhB,EACAwU,EACAlO,EACA1nB,EACA8D,EACAwT,EAKJ,GAHAoQ,EAAIrgB,EAAI7G,OAGH8jB,EAAkB,CAEtB,GADArkB,EAAMsiB,GAAS,CAAEmF,EAAG7J,EAAE,IACR,UAAT8X,EAAmB,CACvB,IAAM31B,EAAI,EAAGA,EAAI0nB,EAAG1nB,IAGnB,IAFAohB,EAAKnhB,EAAKD,GACV41B,EAAKvuB,EAAKrH,GACJ8D,EAAI9D,EAAG8D,EAAIme,GAAKyF,EAAG1nB,EAAE6d,EAAE,GAAK/Z,IACjCsd,EAAItd,EAAE9D,GAAM41B,EAAI9xB,GAGlB,OAAO7D,CACP,CAED,IAAMD,EAAI,EAAGA,EAAI0nB,EAAG1nB,IAInB,IAHAohB,EAAKnhB,EAAKD,GACV41B,EAAKvuB,EAAKrH,GACVsX,EAAI0K,GAAK,EAAGnE,EAAE7d,GACR8D,EAAIke,GAAK,EAAGhiB,EAAE6d,GAAK/Z,GAAK9D,EAAG8D,IAChCsd,EAAI9J,GAAMse,EAAI9xB,GACdwT,GAAK,EAGP,OAAOrX,CACP,CAGD,GADAA,EAAMsiB,GAAS,CAAE1E,EAAE,EAAG6J,IACR,UAATiO,EAAmB,CACvB,IAAM7xB,EAAI,EAAGA,EAAI4jB,EAAG5jB,IAEnB,IADAwT,EAAIuG,EAAI/Z,EACF9D,EAAIgiB,GAAK,EAAGle,EAAE+Z,GAAK7d,GAAK8D,EAAG9D,IAChCC,EAAKqX,EAAEtX,GAAK8D,GAAMuD,EAAKrH,GAAK8D,GAG9B,OAAO7D,CACP,CAED,IAAM6D,EAAI,EAAGA,EAAI4jB,EAAG5jB,IAEnB,IADAwT,GAAKxT,EACC9D,EAAI8D,EAAG9D,EAAIiiB,GAAKyF,EAAG5jB,EAAE+Z,EAAE,GAAK7d,IACjCC,EAAKqX,EAAEtX,GAAK8D,GAAMuD,EAAKrH,GAAK8D,GAG9B,OAAO7D,CACR,IC3EA2G,EAAAnH,GAAA,UCsNA,SAAiBoP,EAAG4K,EAAS8W,EAAMtwB,EAAK0Z,EAAQjH,GAC/C,IAAI8P,EACAoJ,EACAuI,EAKJ,OAHA3R,EAAK9K,GAAkB7I,GACvB+c,EAAKlU,GAAkB+B,GACvB0a,EAAKzc,GAAkBzX,GAEtBuiB,EAAGrL,kBACHyU,EAAGzU,kBACHgd,EAAGhd,iBAIF6X,GAAmBxM,EAAGta,QACtB8mB,GAAmBmF,EAAGjsB,QA9HzB,SAAkB2G,EAAG4K,EAAS8W,EAAMtwB,EAAK0Z,EAAQjH,GAChD,IAAIoiB,EACAE,EACAC,EACAjT,EACA4J,EACAwI,EACAp0B,EAEA6d,EAcJ,IAZAmX,EAAQvb,EAAQ9B,KAChBsd,EAAOxb,EAAQxC,UAAW,GAG1B6d,EAAWtE,GAAKD,GAGhBvO,EAAQnT,EAAErO,OAAO,EAAM,EAGvB4zB,EAAc,EAATza,EACLiS,EAAc,EAATlZ,EACC1S,EAAI,EAAGA,EAAIg1B,EAAMx0B,OAAQR,IAE9B6d,EAAQ,EADJiX,EAAUG,EAAMD,EAAOh1B,GAAKgiB,GAEhC/hB,EAAK2rB,GAAO/c,EAAGgP,GACf5d,EAAK2rB,EAAG,GAAM/c,EAAGgP,EAAE,GACnB+N,GAAMwI,CAGR,CAiGG7I,CAAS9Y,GAAa5D,EAAG,GAAK+c,EAAI2E,EAAM9d,GAAaxS,EAAK,GAAK0Z,EAAQjH,GAChEzS,GAGPmc,GAAmBoG,EAAGta,QACtBkU,GAAmB+X,EAAGjsB,QA5EzB,SAAkB2G,EAAG4K,EAAS8W,EAAMtwB,EAAK0Z,EAAQjH,GAChD,IAAIoiB,EACAE,EACAC,EACAjT,EACA4J,EACA5rB,EACA8D,EAaJ,IAXAkxB,EAAQvb,EAAQ9B,KAChBsd,EAAOxb,EAAQxC,UAAW,GAG1B6d,EAAWtE,GAAKD,GAGhBvO,EAAMnT,EAAErO,OAAS,EAGjBorB,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIg1B,EAAMx0B,OAAQR,IAC9B8D,EAAIgxB,EAAUG,EAAMD,EAAOh1B,GAAKgiB,GAChC/hB,EAAK2rB,GAAO/c,EAAG/K,GACf8nB,GAAMjS,CAGR,CAoDGkS,CAASjJ,GAAoB/T,EAAG,GAAK+c,EAAI2E,EAAM3N,GAAoB3iB,EAAK,GAAK0Z,EAAQjH,GAC9EzS,IArMV,SAAoB4O,EAAG4K,EAAS8W,EAAMtwB,EAAK0Z,EAAQjH,GAClD,IAAIoiB,EACAtZ,EACAwZ,EACAX,EACA3Y,EACAuZ,EACAX,EACAtS,EACA4J,EACA5rB,EAmBJ,IAhBAwb,EAAQ3M,EAAE8I,KACVqd,EAAQvb,EAAQ9B,KAChB0c,EAAQp0B,EAAI0X,KAEZ+D,EAAO7M,EAAEoI,UAAW,GACpBge,EAAOxb,EAAQxC,UAAW,GAC1Bqd,EAAOr0B,EAAIgX,UAAW,GAGtB6d,EAAWtE,GAAKD,GAGhBvO,EAAMxG,EAAMhb,OAAS,EAGrBorB,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIg1B,EAAMx0B,OAAQR,IAE9Bs0B,EAAMD,EAAOzI,EAAIlQ,EAAMF,EADnBsZ,EAAUG,EAAMD,EAAOh1B,GAAKgiB,KAEhC4J,GAAMjS,CAGR,CAoKE1C,CAAWuL,EAAIoJ,EAAI2E,EAAM4D,EAAIxa,EAAQjH,GAC9BzS,IAxPT,SAAkB4O,EAAG4K,EAAS8W,EAAMtwB,EAAK0Z,EAAQjH,GAChD,IAAIoiB,EACA9S,EACA4J,EACA5rB,EACA8D,EAUJ,IAPAgxB,EAAWtE,GAAKD,GAGhBvO,EAAMnT,EAAErO,OAAS,EAGjBorB,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIyZ,EAAQjZ,OAAQR,IAChC8D,EAAIgxB,EAAUrb,EAASzZ,GAAKgiB,GAC5B/hB,EAAK2rB,GAAO/c,EAAG/K,GACf8nB,GAAMjS,CAGR,CAqOCwR,CAAStc,EAAG4K,EAAS8W,EAAMtwB,EAAK0Z,EAAQjH,GACjCzS,EACR,ICpRA,IAAI41B,GAAQ,EA2BZ,SAASC,GAAQjnB,EAAG4K,EAASsc,EAAWxF,GACvC,IAAIzrB,EACA7E,EACAkjB,EACAqN,EACAlpB,EACA8c,EACAC,EACAuN,EACAC,EAGJ,IAAc,KADd1O,EAAM+Q,GAAgB6B,EAAWF,GAAM,IAEtC,MAAM,IAAIhiB,WAAY7O,EAAQ,4GAA6G6wB,GAAOE,IAInJ,GAFAvF,EAAMwF,GAAezF,GACrBtwB,EAAM,GACO,IAARkjB,EAAY,CAEhB,IADAre,EAAY+J,EAAErO,OAAS,EACjB6jB,EAAK,EAAGA,EAAK5K,EAAQjZ,OAAQ6jB,IAClC/c,EAAMkpB,EAAK/W,EAAS4K,GAAMvf,GAC1B7E,EAAI8E,KAAM8J,EAAGvH,IAEd,OAAOrH,CACP,CAED,IAAMokB,EAAK,EAAGA,EAAKxV,EAAErO,OAAQ6jB,IAAO,CAInC,IAFAwN,EAAK,GACL/sB,GAFA8sB,EAAK/iB,EAAGwV,IAEO7jB,OAAS,EAClB4jB,EAAK,EAAGA,EAAK3K,EAAQjZ,OAAQ4jB,IAClC9c,EAAMkpB,EAAK/W,EAAS2K,GAAMtf,GAC1B+sB,EAAG9sB,KAAM6sB,EAAItqB,IAEdrH,EAAI8E,KAAM8sB,EACV,CACD,OAAO5xB,CACR,CC3DA,SAASgjB,GAASpU,EAAG+J,EAAGsK,EAAOd,EAAOe,EAAKpO,GAC1C,IAAIqO,EACAC,EACArjB,EAOJ,GALAojB,EAAIhB,EAAOe,IAGXE,EAAIF,EAAM,KAECD,EAQX,IAAMljB,EAAI,EAAGA,EAAIojB,EAAGpjB,IACnBijB,GAASpU,EAAG7O,GAAK4Y,EAAG5Y,GAAKkjB,EAAOd,EAAOiB,EAAGtO,QAP1C,IAAM/U,EAAI,EAAGA,EAAIojB,EAAGpjB,IACnB4Y,EAAG5Y,GAAM+U,EAAKlG,EAAG7O,GAQpB,CCdA,SAASi2B,GAAgBpnB,GACxB,OAAc,IAANA,GAAa,EAAIA,IAAM/C,EAChC,CCZA,SAASoqB,GAAevS,EAAGjO,GAE1B,GAAW,IAANiO,EACJ,OAAO,EAER,GAAKA,IAAMjO,EACV,OAAO,EAER,MAAM,IAAIlU,MAAO,mEAClB,CCOA,SAAS20B,GAAOC,EAAWvnB,EAAG+J,GAC7B,IAAI8C,EACAC,EACA0a,EACAC,EACAr2B,EACAipB,EACAC,EACAoN,EACA1I,EACAC,EACA0I,EACA9gB,EACAvM,EACAnJ,EAMJ,GAAmB,KAHnBs2B,EAAO,CAAEF,EAAU51B,OAAQqO,EAAErO,OAAQoY,EAAEpY,SAG5B,GAEV,MAAO,GAsBR,IAnBAkV,EClBD,SAAe7G,EAAG+J,GACjB,IAAInP,EACAie,EACAve,EACAnJ,EAGJ,GAAa,KADbyJ,EAAMvF,UAAU1D,QAEf,OAAK4C,GAAOyL,IAAOzL,GAAOwV,GAClBtN,IAEHuD,IAAM/C,IAAQ8M,IAAM9M,GACjBA,GAEH+C,IAAM+J,GAAW,IAAN/J,EACVonB,GAAgBpnB,GACbA,EAED+J,EAEH/J,EAAI+J,EACD/J,EAED+J,EAGR,IADA8O,EAAI5Y,GACE9O,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,GAAKoD,GADL+F,EAAIjF,UAAWlE,KACImJ,IAAM2C,GACxB,OAAO3C,GAEHA,EAAIue,GAGRve,IAAMue,GACA,IAANve,GACA8sB,GAAgB9sB,MAJhBue,EAAIve,EAQL,CACD,OAAOue,CACR,CDxBK+O,CAAMH,EAAM,GAAKA,EAAM,GAAKA,EAAM,IAGtCC,EAAKL,GAAeI,EAAM,GAAK5gB,GAC/BwT,EAAKgN,GAAeI,EAAM,GAAK5gB,GAC/ByT,EAAK+M,GAAeI,EAAM,GAAK5gB,GAG/B2gB,EAAOve,GAAese,GACtB1a,EAAO5D,GAAejJ,GACtB8M,EAAO7D,GAAec,GAGtB4d,EAAK,EACL3I,EAAK,EACLC,EAAK,EAGL7tB,EAAM,GACAD,EAAI,EAAGA,EAAI0V,EAAG1V,IAElBmJ,EADIktB,EAAMD,EAAWI,GACjB9a,EAAM7M,EAAGgf,GAETlS,EAAM/C,EAAGkV,GAEd7tB,EAAI8E,KAAMoE,GACVqtB,GAAMD,EACN1I,GAAM3E,EACN4E,GAAM3E,EAEP,OAAOlpB,CACR,CE3CA,SAASkrB,GAASzV,EAAG0gB,EAAWvnB,EAAG+J,EAAG3Y,EAAK0Z,EAAQjH,GAClD,IAAIwW,EACAC,EACAoN,EACA1I,EACAC,EACA0I,EACA5K,EACA5rB,EAcJ,IAXAu2B,EAAKL,GAAeE,EAAU51B,OAAQkV,GACtCwT,EAAKgN,GAAernB,EAAErO,OAAQkV,GAC9ByT,EAAK+M,GAAetd,EAAEpY,OAAQkV,GAG9B8gB,EAAK,EACL3I,EAAK,EACLC,EAAK,EACLlC,EAAKlZ,EAGC1S,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBC,EAAK2rB,GAASwK,EAAWI,GAAS3nB,EAAGgf,GAAOjV,EAAGkV,GAC/C0I,GAAMD,EACN1I,GAAM3E,EACN4E,GAAM3E,EACNyC,GAAMjS,EAEP,OAAO1Z,CACR,CAuLA,SAAS2Z,GAAQwc,EAAWvnB,EAAG+J,EAAG3Y,EAAK0Z,EAAQjH,GAC9C,IAAIgkB,EACAlU,EACAC,EACA0R,EACAze,EAGJ,OAA0B,IAArB0gB,EAAU51B,OACPP,GAGRyV,EC/LD,SAAgBjM,EAAKkQ,EAAQjH,GAC5B,OACQqa,GADHpT,EAAS,GACCjH,EAAO,IAAMiH,GAEdlQ,EAAIiJ,GAAUiH,EAC7B,CD0LKoW,CAAO9vB,EAAIO,OAAQmZ,EAAQjH,GAE/BgkB,EAAKhf,GAAkB0e,GAClBha,GAAmBsa,EAAGxuB,SAE1BwuB,EAAKhf,GADL0e,EAAYO,GAAiBP,EAAW,KAGzC5T,EAAK9K,GAAkB7I,GACvB4T,EAAK/K,GAAkBkB,GACvBub,EAAKzc,GAAkBzX,GAEtBy2B,EAAGvf,kBACHqL,EAAGrL,kBACHsL,EAAGtL,kBACHgd,EAAGhd,kBAIsB,IAAxBuf,EAAGvf,kBACHiF,GAAmBoG,EAAGta,QACtBkU,GAAmBqG,EAAGva,QACtBkU,GAAmB+X,EAAGjsB,QAEtBijB,GAASzV,EAAG0gB,EAAWO,GAAiB9nB,EAAG,GAAK8nB,GAAiB/d,EAAG,GAAK+d,GAAiB12B,EAAK,GAAK0Z,EAAQjH,GACrGzS,GAGP+uB,GAAmBxM,EAAGta,QACtB8mB,GAAmBvM,EAAGva,QACtB8mB,GAAmBmF,EAAGjsB,QAlHzB,SAAkBwN,EAAG0gB,EAAWvnB,EAAG+J,EAAG3Y,EAAK0Z,EAAQjH,GAClD,IAAIkkB,EACAP,EACAnN,EACAC,EACAoN,EACAnC,EACAvG,EACAC,EACA0I,EACA5K,EACA5rB,EAkBJ,IAhBA42B,EAAQR,EAAUze,KAClB0e,EAAOD,EAAUnf,UAAW,GAG5Bsf,EAAKL,GAAeU,EAAMp2B,OAAQkV,GAClCwT,EAAsC,EAAjCgN,GAAernB,EAAErO,OAAO,EAAGkV,GAChCyT,EAAsC,EAAjC+M,GAAetd,EAAEpY,OAAO,EAAGkV,GAChC0e,EAAc,EAATza,EAGL6c,EAAK,EACL3I,EAAK,EACLC,EAAK,EACLlC,EAAc,EAATlZ,EAGC1S,EAAI,EAAGA,EAAI0V,EAAG1V,IACdq2B,EAAMO,EAAOJ,IACjBv2B,EAAK2rB,GAAO/c,EAAGgf,GACf5tB,EAAK2rB,EAAG,GAAM/c,EAAGgf,EAAG,KAEpB5tB,EAAK2rB,GAAOhT,EAAGkV,GACf7tB,EAAK2rB,EAAG,GAAMhT,EAAGkV,EAAG,IAErB0I,GAAMD,EACN1I,GAAM3E,EACN4E,GAAM3E,EACNyC,GAAMwI,CAGR,CAyEG7I,CAAS7V,EAAGghB,EAAIG,GAAkBhoB,EAAG,GAAKgoB,GAAkBje,EAAG,GAAKie,GAAkB52B,EAAK,GAAK0Z,EAAQjH,GACjGzS,IAlMV,SAAoByV,EAAG0gB,EAAWvnB,EAAG+J,EAAG3Y,EAAK0Z,EAAQjH,GACpD,IAAI8I,EACAC,EACAmb,EACAvC,EACA3Y,EACAC,EACA0a,EACA/B,EACApL,EACAC,EACAoN,EACA1I,EACAC,EACA0I,EACA5K,EACA5rB,EAwBJ,IAtBA42B,EAAQR,EAAUze,KAClB6D,EAAQ3M,EAAE8I,KACV8D,EAAQ7C,EAAEjB,KACV0c,EAAQp0B,EAAI0X,KAEZ0e,EAAOD,EAAUnf,UAAW,GAC5ByE,EAAO7M,EAAEoI,UAAW,GACpB0E,EAAO/C,EAAE3B,UAAW,GACpBqd,EAAOr0B,EAAIgX,UAAW,GAGtBsf,EAAKL,GAAeU,EAAMp2B,OAAQkV,GAClCwT,EAAKgN,GAAe1a,EAAMhb,OAAQkV,GAClCyT,EAAK+M,GAAeza,EAAMjb,OAAQkV,GAGlC8gB,EAAK,EACL3I,EAAK,EACLC,EAAK,EACLlC,EAAKlZ,EAGC1S,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBs0B,EAAMD,EAAOzI,EAAMyK,EAAMO,EAAOJ,GAAS9a,EAAMF,EAAOqS,GAAOlS,EAAMF,EAAOqS,IAC1E0I,GAAMD,EACN1I,GAAM3E,EACN4E,GAAM3E,EACNyC,GAAMjS,CAGR,CAoJE1C,CAAWvB,EAAGghB,EAAIlU,EAAIC,EAAI0R,EAAIxa,EAAQjH,GAC/BzS,IAERkrB,GAASzV,EAAG0gB,EAAWvnB,EAAG+J,EAAG3Y,EAAK0Z,EAAQjH,GACnCzS,GACR,CE1PA,SAAS62B,GAAWjoB,EAAGyH,EAAOzW,GAC7B,IAAII,EAEJ,GA/BD,SAAoBiG,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CA6BMC,CAAWxmB,EAAG,QAClB,OAAOA,EAAEkoB,KAAMzgB,EAAOzW,GAGvB,IADAyW,EAAQ4d,GAAgB5d,EAAOzH,EAAErO,OAAO,IAC3B,EACZ,MAAM,IAAIqT,WAAY7O,EAAQ,kEAAmEsR,IAKlG,OAFMmf,GADNx1B,EAAM4E,GAAOgK,EAAG,EAAGA,EAAErO,QAErBkG,CAAKzG,EAAKqW,EAAOzW,GACVI,CACR,CC7BA,SAASkrB,GAAStc,EAAGyH,EAAOzW,EAAOI,EAAK0Z,EAAQjH,GAC/C,IAAIkZ,EACA5rB,EAGJ,IADA4rB,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1BC,EAAK2rB,GAAO/c,EAAG7O,GACf4rB,GAAMjS,EAGP,OADA1Z,EAAKyS,EAAQ4D,EAAMqD,GAAY9Z,EACxBI,CACR,CCvCA,SAAS+2B,KACR,MAAO,CAEN/a,OAAU,CACTjU,QAAW,UACXivB,QAAW,UACX7lB,KAAQ,UACR8lB,eAAkB,UAClBC,oBAAuB,UACvBC,uBAA0B,aAC1BC,QAAW,QACXC,eAAkB,QAClBC,iBAAoB,SACpB1L,QAAW,OACXvV,MAAS,QACTkhB,cAAiB,QACjBC,cAAiB,OACjBC,WAAc,SAGjB,CCUA9wB,EAAAnH,GAAA,SAAAma,ICHAhT,EAAAnH,GAAA,UHgIA,SAAiBoP,EAAGyH,EAAOzW,EAAOI,EAAK0Z,EAAQjH,GAC9C,IAAI8P,EACA2R,EAGJ,IADA7d,EAAQ4d,GAAgB5d,EAAOzH,EAAErO,OAAO,IAC3B,EACZ,MAAM,IAAIqT,WAAY7O,EAAQ,kEAAmEsR,IAIlG,OAFAkM,EAAK9K,GAAkB7I,GACvBslB,EAAKzc,GAAkBzX,GAClBuiB,EAAGrL,kBAAoBgd,EAAGhd,iBAG7B6X,GAAmBxM,EAAGta,QACtB8mB,GAAmBmF,EAAGjsB,QACtB6J,GAAelS,IA5DlB,SAAkBgP,EAAGyH,EAAOzW,EAAOI,EAAK0Z,EAAQjH,GAC/C,IAAI0hB,EACAxI,EACA5rB,EACA8D,EAIJ,IAFAswB,EAAc,EAATza,EACLiS,EAAc,EAATlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAO,EAAGR,IAC5B8D,EAAQ,EAAJ9D,EACJC,EAAK2rB,GAAO/c,EAAG/K,GACf7D,EAAK2rB,EAAG,GAAM/c,EAAG/K,EAAE,GACnB8nB,GAAMwI,EAGPn0B,EADA2rB,EAAiC,GAA1BlZ,EAAQ4D,EAAMqD,IACTvI,GAAMvR,GAClBI,EAAK2rB,EAAG,GAAMva,GAAMxR,EAErB,CA4CG0rB,CAAS9Y,GAAa5D,EAAG,GAAKyH,EAAOzW,EAAO4S,GAAaxS,EAAK,GAAK0Z,EAAQjH,GACpEzS,GAGPmc,GAAmBoG,EAAGta,QACtBkU,GAAmB+X,EAAGjsB,QAEtBijB,GAASvI,GAAoB/T,EAAG,GAAKyH,EAAOtG,GAASnQ,GAAS+iB,GAAoB3iB,EAAK,GAAK0Z,EAAQjH,GAC7FzS,IAnHV,SAAoB4O,EAAGyH,EAAOzW,EAAOI,EAAK0Z,EAAQjH,GACjD,IAAI8I,EACA6Y,EACA3Y,EACA4Y,EACA1I,EACA5rB,EASJ,IAPAwb,EAAQ3M,EAAE8I,KACV0c,EAAQp0B,EAAI0X,KAEZ+D,EAAO7M,EAAEoI,UAAW,GACpBqd,EAAOr0B,EAAIgX,UAAW,GAEtB2U,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,IAC9Bs0B,EAAMD,EAAOzI,EAAIlQ,EAAMF,EAAOxb,IAC9B4rB,GAAMjS,EAEP2a,EAAMD,EAAO3hB,EAAQ4D,EAAMqD,EAAS9Z,EAErC,CAgGEoX,CAAWuL,EAAIlM,EAAOzW,EAAOs0B,EAAIxa,EAAQjH,GAClCzS,IAERkrB,GAAStc,EAAGyH,EAAOzW,EAAOI,EAAK0Z,EAAQjH,GAChCzS,EACR,II/LA,IAAI03B,GHKI,CAEN1b,OAAU,CACTjU,QAAW,UACXivB,QAAW,UACX7lB,KAAQ,UACR8lB,eAAkB,UAClBC,oBAAuB,UACvBC,uBAA0B,aAC1BC,QAAW,QACXC,eAAkB,QAClBC,iBAAoB,SACpB1L,QAAW,OACXvV,MAAS,QACTkhB,cAAiB,QACjBC,cAAiB,OACjBC,WAAc,UGpBbE,GAAO,CACV,iBAAkBD,GAAS1b,OAAOjU,QAClC,iBAAkB2vB,GAAS1b,OAAOgb,QAClC,cAAeU,GAAS1b,OAAO7K,KAC/B,wBAAyBumB,GAAS1b,OAAOib,eACzC,6BAA8BS,GAAS1b,OAAOkb,oBAC9C,gCAAiCQ,GAAS1b,OAAOmb,uBACjD,iBAAkBO,GAAS1b,OAAOob,QAClC,wBAAyBM,GAAS1b,OAAOqb,eACzC,0BAA2BK,GAAS1b,OAAOsb,iBAC3C,iBAAkBI,GAAS1b,OAAO4P,QAClC,eAAgB8L,GAAS1b,OAAO3F,MAChC,uBAAwBqhB,GAAS1b,OAAOub,cACxC,uBAAwBG,GAAS1b,OAAOwb,cACxC,oBAAqBE,GAAS1b,OAAOyb,YCDtC9wB,EAAAnH,GAAA,ODiBA,SAAcyK,GACb,IAAIf,EAAIyuB,GAAM1tB,GACd,YAAe,IAANf,EAAiB,KAAOA,CAClC,IE9BA,IAAI0uB,GAAgBb,GAASvwB,IAAK,kBAsBlC,SAAS3G,GAAOU,GACf,IAAI0H,EACAiC,EACJ,IAAM8E,GAAsBzO,GAC3B,MAAM,IAAIuD,UAAWiB,EAAQ,+EAAgFxE,IAO9G,GAAe,aAJd0H,EADIhE,UAAU1D,OAAS,EACf0D,UAAW,GAEX2zB,IAGR,OAAOC,GAAQt3B,GAGhB,GAAc,QADd2J,EAAO+O,GAAOhR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,iFAAkFkD,IAEhH,OAAO,IAAIiC,EAAM3J,EAClB,CClBA,SAAS2qB,GAAStc,EAAGyH,EAAOrW,EAAK0Z,EAAQjH,GACxC,IAAIkZ,EACA5rB,EAGJ,IADA4rB,EAAKlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrBA,IAAMsW,IAGXrW,EAAK2rB,GAAO/c,EAAG7O,GACf4rB,GAAMjS,GAEP,OAAO1Z,CACR,CAmHA,SAAS2Z,GAAQ/K,EAAGyH,EAAOrW,EAAK0Z,EAAQjH,GACvC,IAAI8P,EACA2R,EAGJ,IADA7d,EAAQ4d,GAAgB5d,EAAOzH,EAAErO,OAAO,IAC3B,EACZ,MAAM,IAAIqT,WAAY7O,EAAQ,kEAAmEsR,IAIlG,OAFAkM,EAAK9K,GAAkB7I,GACvBslB,EAAKzc,GAAkBzX,GAClBuiB,EAAGrL,kBAAoBgd,EAAGhd,iBAG7B6X,GAAmBxM,EAAGta,QACtB8mB,GAAmBmF,EAAGjsB,QA1DzB,SAAkB2G,EAAGyH,EAAOrW,EAAK0Z,EAAQjH,GACxC,IAAI0hB,EACAxI,EACA5rB,EACA8D,EAIJ,IAFAswB,EAAc,EAATza,EACLiS,EAAc,EAATlZ,EACC1S,EAAI,EAAGA,EAAI6O,EAAErO,OAAO,EAAGR,IACvBA,IAAMsW,IAGXxS,EAAQ,EAAJ9D,EACJC,EAAK2rB,GAAO/c,EAAG/K,GACf7D,EAAK2rB,EAAG,GAAM/c,EAAG/K,EAAE,GACnB8nB,GAAMwI,EAGR,CA0CG7I,CAAS9Y,GAAa5D,EAAG,GAAKyH,EAAO7D,GAAaxS,EAAK,GAAK0Z,EAAQjH,GAC7DzS,GAGPmc,GAAmBoG,EAAGta,QACtBkU,GAAmB+X,EAAGjsB,QAEtBijB,GAASvI,GAAoB/T,EAAG,GAAKyH,EAAOsM,GAAoB3iB,EAAK,GAAK0Z,EAAQjH,GAC3EzS,IAlHV,SAAoB4O,EAAGyH,EAAOrW,EAAK0Z,EAAQjH,GAC1C,IAAI8I,EACA6Y,EACA3Y,EACA4Y,EACA1I,EACA5rB,EASJ,IAPAwb,EAAQ3M,EAAE8I,KACV0c,EAAQp0B,EAAI0X,KAEZ+D,EAAO7M,EAAEoI,UAAW,GACpBqd,EAAOr0B,EAAIgX,UAAW,GAEtB2U,EAAKlZ,EACC1S,EAAI,EAAGA,EAAIwb,EAAMhb,OAAQR,IACzBA,IAAMsW,IAGXge,EAAMD,EAAOzI,EAAIlQ,EAAMF,EAAOxb,IAC9B4rB,GAAMjS,EAGR,CA6FE1C,CAAWuL,EAAIlM,EAAO6d,EAAIxa,EAAQjH,GAC3BzS,IAERkrB,GAAStc,EAAGyH,EAAOrW,EAAK0Z,EAAQjH,GACzBzS,EACR,CClKA,SAAS83B,GAASlpB,EAAGyH,GACpB,IAAIrW,EAGJ,IADAqW,EAAQ4d,GAAgB5d,EAAOzH,EAAErO,OAAO,IAC3B,EACZ,MAAM,IAAIqT,WAAY7O,EAAQ,kEAAmEsR,IAIlG,OADAsD,GAAQ/K,EAAGyH,EADXrW,EAAMH,GAAO+O,EAAErO,OAAO,EAAG0H,GAAO2G,IAAO,WAChB,EAAG,GACnB5O,CACR,CCHA2G,EAAAnH,GAAA,SAAAma,ICtBA,IAAAmI,GAAA,CAAA,EAUAnb,EAAAmb,GAAA,gBAAA1K,IAUAzQ,EAAAmb,GAAA,iBAAAxN,GAUA3N,EAAAmb,GAAA,iBAAA3K,GAUAxQ,EAAAmb,GAAA,YAAA9K,IAUArQ,EAAAmb,GAAA,O7WsCA,SAAclT,GACb,IAAI3I,EAAMwR,GAAkB7I,GAC5B,OAAK3I,EAAIiR,iBAEHhF,GAAmBtD,GAChBgJ,GAAU9D,GAAgBlF,EAAG,IAEhCqD,GAAkBrD,GACfgJ,GAAU/D,GAAejF,EAAG,IAG/B2H,GAAgB3H,GACbgJ,GAAU+K,GAAoB/T,EAAG,IAjD3C,SAAoBA,GACnB,IAAI8I,EACAlR,EACAzG,EAKJ,IAHA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEbjX,EAAI,EAAGA,EAAI2X,EAAKnX,OAAQR,IAC7B,GAAKyG,EAAKkR,EAAM3X,GACf,OAAO,EAGT,OAAO,CACR,CAqCSiX,CAAW/Q,GAEZ2R,GAAUhJ,EAClB,I6W7CAjI,EAAAmb,GAAA,SCuCA,SAAgBlT,EAAGrF,EAAW2K,GAC7B,IAAIjO,EACJ,OA9FD,SAAoBA,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CA4FMC,CAAWxmB,EAAG,QACXA,EAAEmpB,KAAMxuB,EAAW2K,IAE3BjO,EAAMwR,GAAkB7I,IACfsI,iBA3CV,SAAoBtI,EAAGrF,EAAW2K,GACjC,IAAIwD,EACAlR,EACAzG,EAKJ,IAHA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEbjX,EAAI,EAAGA,EAAI2X,EAAKnX,OAAQR,IAC7B,GAAKwJ,EAAU1H,KAAMqS,EAAS1N,EAAKkR,EAAM3X,GAAKA,EAAG2X,GAChD,OAAO,EAGT,OAAO,CACR,CA8BSV,CAAW/Q,EAAKsD,EAAW2K,GA5EpC,SAAmBtF,EAAGrF,EAAW2K,GAChC,IAAInU,EACJ,IAAMA,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1B,GAAKwJ,EAAU1H,KAAMqS,EAAStF,EAAG7O,GAAKA,EAAG6O,GACxC,OAAO,EAGT,OAAO,CACR,CAsEQgJ,CAAUhJ,EAAGrF,EAAW2K,EAChC,IDvCAvN,EAAAmb,GAAA,cESA,SAAqBlT,EAAGrF,EAAW2K,GAClC,IAAIjO,EAAMwR,GAAkB7I,GAC5B,OAAK3I,EAAIiR,iBAvCV,SAAoBtI,EAAGrF,EAAW2K,GACjC,IAAIwD,EACAlR,EACAzG,EAKJ,IAHA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEbjX,EAAI2X,EAAKnX,OAAO,EAAGR,GAAK,EAAGA,IAChC,GAAKwJ,EAAU1H,KAAMqS,EAAS1N,EAAKkR,EAAM3X,GAAKA,EAAG2X,GAChD,OAAO,EAGT,OAAO,CACR,CA0BSV,CAAW/Q,EAAKsD,EAAW2K,GAxEpC,SAAmBtF,EAAGrF,EAAW2K,GAChC,IAAInU,EACJ,IAAMA,EAAI6O,EAAErO,OAAO,EAAGR,GAAK,EAAGA,IAC7B,GAAKwJ,EAAU1H,KAAMqS,EAAStF,EAAG7O,GAAKA,EAAG6O,GACxC,OAAO,EAGT,OAAO,CACR,CAkEQgJ,CAAUhJ,EAAGrF,EAAW2K,EAChC,IFLAvN,EAAAmb,GAAA,iBGwBA,SAAwB1a,EAAKlB,GAC5B,OAAKe,EAAiBG,GA5CvB,SAAoBA,EAAKlB,GACxB,IAAIM,EACAzG,EAGJ,IADAyG,EAAMqR,GAAezQ,GACfrH,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAK6I,GAAYpC,EAAKY,EAAKrH,GAAKmG,GAC/B,OAAO,EAGT,OAAO,CACR,CAkCS8Q,CAAW5P,EAAKlB,GArFzB,SAAkBkB,EAAKlB,GACtB,IAAInG,EACJ,IAAMA,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAK6I,GAAYxB,EAAKrH,GAAKmG,GAC1B,OAAO,EAGT,OAAO,CACR,CA+EQglB,CAAS9jB,EAAKlB,EACtB,IHnBAS,EAAAmb,GAAA,cIcA,SAAqB1a,EAAKlB,GACzB,OAAKe,EAAiBG,GA5CvB,SAAoBA,EAAKlB,GACxB,IAAIM,EACAzG,EAGJ,IADAyG,EAAMqR,GAAezQ,GACfrH,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAK+X,GAAStR,EAAKY,EAAKrH,GAAKmG,GAC5B,OAAO,EAGT,OAAO,CACR,CAkCS8Q,CAAW5P,EAAKlB,GArFzB,SAAkBkB,EAAKlB,GACtB,IAAInG,EACJ,IAAMA,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAK+X,GAAS1Q,EAAKrH,GAAKmG,GACvB,OAAO,EAGT,OAAO,CACR,CA+EQglB,CAAS9jB,EAAKlB,EACtB,IJTAS,EAAAmb,GAAA,cKWA,SAAqB1a,EAAKlB,EAAMtG,GAC/B,OAAKqH,EAAiBG,GA/CvB,SAAoBA,EAAKlB,EAAMtG,GAC9B,IAAI4G,EACA0C,EACAnJ,EAGJ,IADAyG,EAAMqR,GAAezQ,GACfrH,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAE5B,GAAK6I,GADLM,EAAI1C,EAAKY,EAAKrH,GACMmG,IAAUgD,EAAGhD,KAAWtG,EAC3C,OAAO,EAGT,OAAO,CACR,CAmCSoX,CAAW5P,EAAKlB,EAAMtG,GA3F/B,SAAkBwH,EAAKlB,EAAMtG,GAC5B,IAAIsJ,EACAnJ,EACJ,IAAMA,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAE5B,GAAK6I,GADLM,EAAI9B,EAAKrH,GACWmG,IAAUgD,EAAGhD,KAAWtG,EAC3C,OAAO,EAGT,OAAO,CACR,CAmFQsrB,CAAS9jB,EAAKlB,EAAMtG,EAC5B,ILNA+G,EAAAmb,GAAA,gBMiBA,SAAuB1a,EAAKlB,EAAMtG,GACjC,OAAKqH,EAAiBG,GAvDvB,SAAoBA,EAAKlB,EAAMtG,GAC9B,IAAI4G,EACA0C,EACAnJ,EAGJ,GADAyG,EAAMqR,GAAezQ,QACN,IAAVxH,EAAmB,CACvB,IAAMG,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAE5B,GAAK+X,GADL5O,EAAI1C,EAAKY,EAAKrH,GACGmG,IAAUgD,EAAGhD,KAAWtG,EACxC,OAAO,EAGT,OAAO,CACP,CACD,IAAMG,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAKyG,EAAKY,EAAKrH,GAAKmG,KAAWtG,EAC9B,OAAO,EAGT,OAAO,CACR,CAmCSoX,CAAW5P,EAAKlB,EAAMtG,GA3G/B,SAAkBwH,EAAKlB,EAAMtG,GAC5B,IAAIsJ,EACAnJ,EACJ,QAAe,IAAVH,EAAmB,CACvB,IAAMG,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAE5B,GAAK+X,GADL5O,EAAI9B,EAAKrH,GACQmG,IAAUgD,EAAGhD,KAAWtG,EACxC,OAAO,EAGT,OAAO,CACP,CACD,IAAMG,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAKqH,EAAKrH,GAAKmG,KAAWtG,EACzB,OAAO,EAGT,OAAO,CACR,CA2FQsrB,CAAS9jB,EAAKlB,EAAMtG,EAC5B,INZA+G,EAAAmb,GAAA,mBAAArK,IAUA9Q,EAAAmb,GAAA,SAAAkW,IAUArxB,EAAAmb,GAAA,MO3GA,SAAalT,EAAGyH,GAEf,GA5BD,SAAoBpQ,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CA0BMC,CAAWxmB,EAAG,MAClB,OAAOA,EAAEqpB,GAAI5hB,GAEd,GAAKA,EAAQ,GAEZ,IADAA,GAASzH,EAAErO,QACE,EACZ,YAEK,GAAK8V,GAASzH,EAAErO,OACtB,OAGD,OADMsX,GAAejJ,EACdpI,CAAKoI,EAAGyH,EAChB,IPsGA1P,EAAAmb,GAAA,QQhJA,SAAelT,EAAGuV,EAAIC,GACrB,IAAIuN,EACAlc,EAMJ,GAJAA,EAAI7G,EAAErO,OACD4jB,EAAK,IACTA,GAAM1O,KAEF0O,EAAK,GAAKA,GAAM1O,IAIrBA,GADAkc,EAAK/iB,EAAGuV,IACD5jB,OACF6jB,EAAK,IACTA,GAAM3O,GAEF2O,EAAK,GAAKA,GAAM3O,IAGrB,OAAOkc,EAAIvN,EACZ,IRsIAzd,EAAAmb,GAAA,QSzJA,SAAelT,EAAGuV,EAAIC,EAAIgL,GACzB,IAAIuC,EACA9G,EACApV,EAMJ,GAJAA,EAAI7G,EAAErO,OACD4jB,EAAK,IACTA,GAAM1O,KAEF0O,EAAK,GAAKA,GAAM1O,IAIrBA,GADAkc,EAAK/iB,EAAGuV,IACD5jB,OACF6jB,EAAK,IACTA,GAAM3O,GAEF2O,EAAK,GAAKA,GAAM3O,IAIrBA,GADAoV,EAAK8G,EAAIvN,IACF7jB,OACF6uB,EAAK,IACTA,GAAM3Z,GAEF2Z,EAAK,GAAKA,GAAM3Z,KAGrB,OAAOoV,EAAIuE,EACZ,ITsIAzoB,EAAAmb,GAAA,QUlKA,SAAelT,EAAGuV,EAAIC,EAAIgL,EAAII,GAC7B,IAAI5vB,EACAyH,EACAoO,EACA1V,EACA8D,EAIJ,IAFAwD,EAAM,CAAE8c,EAAIC,EAAIgL,EAAII,GACpB5vB,EAAQgP,EACF7O,EAAI,EAAGA,EAAIsH,EAAI9G,OAAQR,IAAM,CAMlC,GALA8D,EAAIwD,EAAKtH,GACT0V,EAAI7V,EAAMW,OACLsD,EAAI,IACRA,GAAK4R,GAED5R,EAAI,GAAKA,GAAK4R,EAClB,OAED7V,EAAQA,EAAOiE,EACf,CACD,OAAOjE,CACR,IVuJA+G,EAAAmb,GAAA,QW3KA,SAAelT,EAAGuV,EAAIC,EAAIgL,EAAII,EAAII,GACjC,IAAIhwB,EACAyH,EACAoO,EACA1V,EACA8D,EAIJ,IAFAwD,EAAM,CAAE8c,EAAIC,EAAIgL,EAAII,EAAII,GACxBhwB,EAAQgP,EACF7O,EAAI,EAAGA,EAAIsH,EAAI9G,OAAQR,IAAM,CAMlC,GALA8D,EAAIwD,EAAKtH,GACT0V,EAAI7V,EAAMW,OACLsD,EAAI,IACRA,GAAK4R,GAED5R,EAAI,GAAKA,GAAK4R,EAClB,OAED7V,EAAQA,EAAOiE,EACf,CACD,OAAOjE,CACR,IXgKA+G,EAAAmb,GAAA,QYxLA,SAAelT,EAAGuV,GACjB,IAAIvkB,EACAyH,EACAoO,EACA1V,EACA8D,EAGJ,IADAwD,EAAM,CAAE8c,GACFpkB,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAClCsH,EAAIvC,KAAMb,UAAWlE,IAGtB,IADAH,EAAQgP,EACF7O,EAAI,EAAGA,EAAIsH,EAAI9G,OAAQR,IAAM,CAMlC,GALA8D,EAAIwD,EAAKtH,GACT0V,EAAI7V,EAAMW,OACLsD,EAAI,IACRA,GAAK4R,GAED5R,EAAI,GAAKA,GAAK4R,EAClB,OAED7V,EAAQA,EAAOiE,EACf,CACD,OAAOjE,CACR,IZ0KA+G,EAAAmb,GAAA,SAAAoW,IAUAvxB,EAAAmb,GAAA,oBa5MA,SAA2BlT,EAAGupB,GAC7B,IAAI1c,EACA2c,EACA5uB,EACAxJ,EAEAkJ,EACAnJ,EAIJ,GADAyJ,EAAMoF,EAAErO,OACH43B,EAAO53B,SAAWiJ,EACtB,MAAM,IAAIoK,WAAY,+EAEvB,GAAa,IAARpK,EACJ,MAAO,GAQR,IALAiS,EAAO5D,GAAejJ,GACtBwpB,EAAOvgB,GAAesgB,GAGtBn4B,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAIuS,EAAM7M,EAAG7O,GACTq4B,EAAMD,EAAQp4B,GAEjBC,EAAK,GAAI8E,KAAM,CAAE/E,EAAGmJ,IAEpBlJ,EAAK,GAAI8E,KAAM,CAAE/E,EAAGmJ,IAGtB,OAAOlJ,CACR,IbqLA2G,EAAAmb,GAAA,sBcnNA,SAA6BlT,EAAGrF,EAAW2K,GAC1C,IAAI1N,EACAgD,EACAxJ,EACAkJ,EACAnJ,EAIJ,GAAa,KADbyJ,EAAMoF,EAAErO,QAEP,MAAO,GAOR,IAJAiG,EAAMqR,GAAejJ,GAGrB5O,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI1C,EAAKoI,EAAG7O,GACPwJ,EAAU1H,KAAMqS,EAAShL,EAAGnJ,EAAG6O,GACnC5O,EAAK,GAAI8E,KAAM,CAAE/E,EAAGmJ,IAEpBlJ,EAAK,GAAI8E,KAAM,CAAE/E,EAAGmJ,IAGtB,OAAOlJ,CACR,IdmMA2G,EAAAmb,GAAA,oBehOA,SAA2BlT,EAAGupB,GAC7B,IAAIC,EACA5uB,EACAxJ,EAEAD,EAIJ,GADAyJ,EAAMoF,EAAErO,OACH43B,EAAO53B,SAAWiJ,EACtB,MAAM,IAAIoK,WAAY,+EAEvB,GAAa,IAARpK,EACJ,MAAO,GAOR,IAJA4uB,EAAOvgB,GAAesgB,GAGtBn4B,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACjBq4B,EAAMD,EAAQp4B,GAEjBC,EAAK,GAAI8E,KAAM/E,GAEfC,EAAK,GAAI8E,KAAM/E,GAGjB,OAAOC,CACR,If6MA2G,EAAAmb,GAAA,sBgBvOA,SAA6BlT,EAAGrF,EAAW2K,GAC1C,IAAI1N,EACAgD,EACAxJ,EACAD,EAIJ,GAAa,KADbyJ,EAAMoF,EAAErO,QAEP,MAAO,GAOR,IAJAiG,EAAMqR,GAAejJ,GAGrB5O,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAChBwJ,EAAU1H,KAAMqS,EAAS1N,EAAKoI,EAAG7O,GAAKA,EAAG6O,GAC7C5O,EAAK,GAAI8E,KAAM/E,GAEfC,EAAK,GAAI8E,KAAM/E,GAGjB,OAAOC,CACR,IhByNA2G,EAAAmb,GAAA,mBiBpPA,SAA0BlT,EAAGupB,GAC5B,IAAI1c,EACA2c,EACA5uB,EACAxJ,EAEAkJ,EACAnJ,EAIJ,GADAyJ,EAAMoF,EAAErO,OACH43B,EAAO53B,SAAWiJ,EACtB,MAAM,IAAIoK,WAAY,+EAEvB,GAAa,IAARpK,EACJ,MAAO,GAQR,IALAiS,EAAO5D,GAAejJ,GACtBwpB,EAAOvgB,GAAesgB,GAGtBn4B,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAIuS,EAAM7M,EAAG7O,GACTq4B,EAAMD,EAAQp4B,GAEjBC,EAAK,GAAI8E,KAAMoE,GAEflJ,EAAK,GAAI8E,KAAMoE,GAGjB,OAAOlJ,CACR,IjB6NA2G,EAAAmb,GAAA,qBkB3PA,SAA4BlT,EAAGrF,EAAW2K,GACzC,IAAI1N,EACAgD,EACAxJ,EACAkJ,EACAnJ,EAIJ,GAAa,KADbyJ,EAAMoF,EAAErO,QAEP,MAAO,GAOR,IAJAiG,EAAMqR,GAAejJ,GAGrB5O,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI1C,EAAKoI,EAAG7O,GACPwJ,EAAU1H,KAAMqS,EAAShL,EAAGnJ,EAAG6O,GACnC5O,EAAK,GAAI8E,KAAMoE,GAEflJ,EAAK,GAAI8E,KAAMoE,GAGjB,OAAOlJ,CACR,IlB2OA2G,EAAAmb,GAAA,YmBhQA,SAAmBuW,EAAQlW,EAAOrN,GACjC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACA0G,EACA1pB,EACA+J,EACApG,EAIJ,GAFA6P,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAMtB,IAHAzT,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK/iB,EAAGwV,GACRwN,EAAKjZ,EAAGyL,GACRkU,EAAK/lB,EAAG6R,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAGjC,InB8OAxd,EAAAmb,GAAA,YoB1QA,SAAmBuW,EAAQlW,EAAOrN,GACjC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACA9G,EACA+G,EACAzI,EACAmP,EACAvd,EACAnM,EACA+J,EACApG,EAKJ,GAHA6P,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAMjC,IAHAvgB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKjc,EAAGwgB,GACRjG,EAAKxQ,EAAGyW,GACRrU,EAAKxI,EAAG6c,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAIlC,IpB6OAxd,EAAAmb,GAAA,YqBpRA,SAAmBuW,EAAQlW,EAAOrN,GACjC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA6F,EACAvd,EACAC,EACApM,EACA+J,EACApG,EAMJ,GAJA6P,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAM5C,IAHA3gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA1E,EAAKlc,EAAG4gB,GACRiD,EAAK9Z,EAAG6W,GACRxU,EAAKzI,EAAGid,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAKnC,IrB4OAxd,EAAAmb,GAAA,YsB9RA,SAAmBuW,EAAQlW,EAAOrN,GACjC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACA0F,EACAvd,EACAC,EACAud,EACA3pB,EACA+J,EACApG,EAOJ,GALA6P,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAMvD,IAHA/gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA+C,EAAK/jB,EAAGghB,GACRgD,EAAKja,EAAGiX,GACR2I,EAAKhmB,EAAGqd,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTxU,EAAKud,EAAI/I,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAMpC,ItB2OAxd,EAAAmb,GAAA,Y3PjQA,SAAmBuW,EAAQlW,EAAOrN,GACjC,OAAOkO,GAASqV,EAAQ,GAAKA,EAAQ,GAAKA,EAAQ,GAAKlW,EAAM5hB,OAAQ4hB,EAAO,EAAGrN,EAChF,I2PyQAnO,EAAAmb,GAAA,iBAAAwB,IAUA3c,EAAAmb,GAAA,auBvTA,SAAoBuW,EAAQG,EAAQ1jB,GACnC,IAAI2jB,EACAC,EACAC,EACAC,EACAxW,EACAC,EACA8B,EACAC,EACAyU,EACAC,EACAC,EACAC,EACArH,EACAC,EACA0G,EACAzH,EACApN,EACApM,EACAzI,EACA+J,EACApG,EAKJ,GAFA6P,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAmBtB,IAfAzT,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GAEVlR,EAAI8lB,EAAQ,GAEZS,EAAK,EACLE,EAAK,EACC5U,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAM7B,IALAyU,EAAK,EACLE,EAAK,EACLpH,EAAK/iB,EAAGkqB,GACRlH,EAAKjZ,EAAGqgB,GACRV,EAAK/lB,EAAG6R,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,IAC9BF,GAAMJ,EACNM,GAAMJ,EAEPG,GAAMJ,EACNM,GAAMJ,CACN,CACF,IvBsQAjyB,EAAAmb,GAAA,awBjUA,SAAoBuW,EAAQG,EAAQ1jB,GACnC,IAAI2jB,EACAC,EACAO,EACAN,EACAC,EACAM,EACA9W,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAyJ,EACAC,EACAK,EACAJ,EACAC,EACAI,EACAzH,EACA9G,EACA+G,EACAzI,EACAmP,EACAvd,EACA8V,EACApN,EACApM,EACAzI,EACA+J,EACApG,EAMJ,GAHA6P,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAqBjC,IAjBAvgB,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GAEVlR,EAAI8lB,EAAQ,GAEZc,EAAK,EACLC,EAAK,EACChK,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA0J,EAAK,EACLE,EAAK,EACLnO,EAAKjc,EAAGuqB,GACRhQ,EAAKxQ,EAAGygB,GACRre,EAAKxI,EAAG6c,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAM7B,IALAyU,EAAK,EACLE,EAAK,EACLpH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,IAC9BF,GAAMJ,EACNM,GAAMJ,EAEPG,GAAMJ,EACNM,GAAMJ,CACN,CACDO,GAAMF,EACNG,GAAMF,CACN,CACF,IxB2PAvyB,EAAAmb,GAAA,ayB3UA,SAAoBuW,EAAQG,EAAQ1jB,GACnC,IAAI2jB,EACAC,EACAO,EACAI,EACAV,EACAC,EACAM,EACAI,EACAlX,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAqJ,EACAC,EACAK,EACAI,EACAR,EACAC,EACAI,EACAI,EACA7H,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA6F,EACAvd,EACAC,EACA6V,EACApN,EACApM,EACAzI,EACA+J,EACApG,EAOJ,GAJA6P,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,GACTtB,EAAKsB,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAuB5C,IAnBA3gB,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GACV4V,EAAM5V,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GACV6V,EAAM7V,EAAI,GAEVlR,EAAI8lB,EAAQ,GAEZkB,EAAK,EACLC,EAAK,EACChK,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA2J,EAAK,EACLC,EAAK,EACLtO,EAAKlc,EAAG2qB,GACR9G,EAAK9Z,EAAG6gB,GACRxe,EAAKzI,EAAGid,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA0J,EAAK,EACLE,EAAK,EACLnO,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAI2G,GACTre,EAAKC,EAAIoU,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAM7B,IALAyU,EAAK,EACLE,EAAK,EACLpH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,IAC9BF,GAAMJ,EACNM,GAAMJ,EAEPG,GAAMJ,EACNM,GAAMJ,CACN,CACDO,GAAMF,EACNG,GAAMF,CACN,CACDK,GAAMF,EACNG,GAAMF,CACN,CACF,IzBgPA3yB,EAAAmb,GAAA,a0BrVA,SAAoBuW,EAAQG,EAAQ1jB,GACnC,IAAI2jB,EACAC,EACAO,EACAI,EACAI,EACAd,EACAC,EACAM,EACAI,EACAI,EACAtX,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACAiJ,EACAC,EACAK,EACAI,EACAI,EACAZ,EACAC,EACAI,EACAI,EACAI,EACAjI,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACA0F,EACAvd,EACAC,EACAud,EACA1H,EACApN,EACApM,EACAzI,EACA+J,EACApG,EAQJ,GALA6P,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,GACTtB,EAAKsB,EAAI,GACTlB,EAAKkB,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAyBvD,IArBA/gB,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GACV4V,EAAM5V,EAAI,GACVgW,EAAMhW,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GACV6V,EAAM7V,EAAI,GACViW,EAAMjW,EAAI,GAEVlR,EAAI8lB,EAAQ,GAEZsB,EAAK,EACLC,EAAK,EACChK,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA2J,EAAK,EACLC,EAAK,EACL7G,EAAK/jB,EAAG+qB,GACR/G,EAAKja,EAAGihB,GACRrB,EAAKhmB,EAAGqd,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA2J,EAAK,EACLC,EAAK,EACLtO,EAAK6H,EAAI4G,GACT9G,EAAKG,EAAI4G,GACTxe,EAAKud,EAAI/I,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA0J,EAAK,EACLE,EAAK,EACLnO,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAI2G,GACTre,EAAKC,EAAIoU,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAM7B,IALAyU,EAAK,EACLE,EAAK,EACLpH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,IAC9BF,GAAMJ,EACNM,GAAMJ,EAEPG,GAAMJ,EACNM,GAAMJ,CACN,CACDO,GAAMF,EACNG,GAAMF,CACN,CACDK,GAAMF,EACNG,GAAMF,CACN,CACDK,GAAMF,EACNG,GAAMF,CACN,CACF,I1BqOA/yB,EAAAmb,GAAA,iB2B3VA,SAAwBuW,EAAQG,EAAQ1jB,GACvC,IAAI2jB,EACAC,EACAC,EACAC,EACAiB,EACAC,EACAC,EACAC,EACA5X,EACAC,EACA8B,EACAC,EACAyU,EACAC,EACAC,EACAC,EACAiB,EACAC,EACAC,EACAC,EACAzI,EACAC,EACA0G,EACA+B,EACAC,EACAzJ,EACApN,EACApM,EACAzI,EACA+J,EACApG,EACAmL,EACAiM,EAKJ,GAFAvH,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAiCtB,IA7BAzT,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GAGV/F,GADArG,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENqiB,GADAtW,EAAKpM,EAAEuM,SACG,GACVoW,EAAMvW,EAAI,GAEVkG,EAAI0O,EAAQ,GAEZS,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACChW,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAU7B,IATAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLxI,EAAK/iB,EAAGkqB,GACRlH,EAAKjZ,EAAGqgB,GACRV,EAAK/lB,EAAG2nB,GACRG,EAAK3c,EAAG0c,GACRE,EAAK3Q,EAAGvF,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmW,EAAInW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,GAAMI,EAAIF,IAClDtB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EAEPjB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,CACN,CACF,I3BwQArzB,EAAAmb,GAAA,iB4BrWA,SAAwBuW,EAAQG,EAAQ1jB,GACvC,IAAI2jB,EACAC,EACAO,EACAN,EACAC,EACAM,EACAW,EACAC,EACAS,EACAR,EACAC,EACAQ,EACApY,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAyJ,EACAC,EACAK,EACAJ,EACAC,EACAI,EACAa,EACAC,EACAO,EACAN,EACAC,EACAM,EACA/I,EACA9G,EACA+G,EACAzI,EACAmP,EACAvd,EACAsf,EACAM,EACAL,EACAM,EACA/J,EACApN,EACApM,EACAzI,EACA+J,EACApG,EACAmL,EACAiM,EAMJ,GAHAvH,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAqCjC,IAjCAvgB,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GACV8W,EAAM9W,EAAI,GAGV/F,GADArG,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENqiB,GADAtW,EAAKpM,EAAEuM,SACG,GACVoW,EAAMvW,EAAI,GACV+W,EAAM/W,EAAI,GAEVkG,EAAI0O,EAAQ,GAEZc,EAAK,EACLC,EAAK,EACLqB,EAAK,EACLC,EAAK,EACCtL,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLvP,EAAKjc,EAAGuqB,GACRhQ,EAAKxQ,EAAGygB,GACRre,EAAKxI,EAAGkoB,GACRE,EAAKjd,EAAGgd,GACRE,EAAKjR,EAAGyF,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAU7B,IATAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLxI,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAImf,GACTG,EAAKM,EAAIP,GACTE,EAAKM,EAAIxW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmW,EAAInW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,GAAMI,EAAIF,IAClDtB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EAEPjB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,CACN,CACDb,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,EACNG,GAAMF,CACN,CACF,I5B+OA7zB,EAAAmb,GAAA,iB6B/WA,SAAwBuW,EAAQG,EAAQ1jB,GACvC,IAAI2jB,EACAC,EACAO,EACAI,EACAV,EACAC,EACAM,EACAI,EACAO,EACAC,EACAS,EACAM,EACAd,EACAC,EACAQ,EACAM,EACA1Y,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAqJ,EACAC,EACAK,EACAI,EACAR,EACAC,EACAI,EACAI,EACAS,EACAC,EACAO,EACAM,EACAZ,EACAC,EACAM,EACAM,EACArJ,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA6F,EACAvd,EACAC,EACAqf,EACAM,EACAM,GACAX,GACAM,GACAM,GACArK,GACApN,GACApM,GACAzI,GACA+J,GACApG,GACAmL,GACAiM,GAOJ,GAJAvH,GADAyO,GAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,GAAI,GACT1B,EAAK0B,GAAI,GACTtB,EAAKsB,GAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAyC5C,IArCA3gB,IADAyI,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAEN+gB,GADAhV,GAAKpM,GAAEuM,SACG,GACV8U,EAAMjV,GAAI,GACVwV,EAAMxV,GAAI,GACV4V,EAAM5V,GAAI,GAGV9K,IADAtB,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENihB,GADAlV,GAAKpM,GAAEuM,SACG,GACVgV,EAAMnV,GAAI,GACVyV,EAAMzV,GAAI,GACV6V,EAAM7V,GAAI,GAGVlR,IADA8E,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENmiB,GADApW,GAAKpM,GAAEuM,SACG,GACVkW,EAAMrW,GAAI,GACV8W,EAAM9W,GAAI,GACVoX,EAAMpX,GAAI,GAGV/F,IADArG,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENqiB,GADAtW,GAAKpM,GAAEuM,SACG,GACVoW,EAAMvW,GAAI,GACV+W,EAAM/W,GAAI,GACVqX,EAAMrX,GAAI,GAEVkG,GAAI0O,EAAQ,GAEZkB,EAAK,EACLC,EAAK,EACLuB,EAAK,EACLC,EAAK,EACCxL,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA2J,EAAK,EACLC,EAAK,EACLqB,EAAK,EACLC,EAAK,EACL5P,EAAKlc,GAAG2qB,GACR9G,EAAK9Z,GAAG6gB,GACRxe,EAAKzI,GAAGwoB,GACRE,GAAKvd,GAAGsd,GACRE,GAAKvR,GAAG6F,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLvP,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAI2G,GACTre,EAAKC,EAAIyf,GACTE,EAAKM,GAAIP,GACTE,GAAKM,GAAI9L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAU7B,IATAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLxI,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAImf,GACTG,EAAKM,EAAIP,GACTE,GAAKM,GAAIxW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmW,GAAInW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,GAAMI,EAAIF,IAClDtB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EAEPjB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,CACN,CACDb,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,EACNG,GAAMF,CACN,CACDjB,GAAMF,EACNG,GAAMF,EACNyB,GAAMF,EACNG,GAAMF,CACN,CACF,I7BsNAn0B,EAAAmb,GAAA,iB8BzXA,SAAwBuW,EAAQG,EAAQ1jB,GACvC,IAAI2jB,EACAC,EACAO,EACAI,EACAI,EACAd,EACAC,EACAM,EACAI,EACAI,EACAG,EACAC,EACAS,EACAM,EACAM,EACApB,EACAC,EACAQ,EACAM,EACAM,EACAhZ,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACAiJ,EACAC,EACAK,EACAI,EACAI,EACAZ,EACAC,EACAI,EACAI,EACAI,EACAK,EACAC,EACAO,EACAM,EACAM,EACAlB,EACAC,EACAM,EACAM,EACAM,EACA3J,EACA9G,GACAC,GACA6H,GACAf,GACAzI,GACAsJ,GACAG,GACA0F,GACAvd,GACAC,GACAud,GACA8B,GACAM,GACAM,GACAM,GACAjB,GACAM,GACAM,GACAM,GACA3K,GACApN,GACApM,GACAzI,GACA+J,GACApG,GACAmL,GACAiM,GAQJ,GALAvH,GADAyO,GAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,GAAI,GACT1B,EAAK0B,GAAI,GACTtB,EAAKsB,GAAI,GACTlB,EAAKkB,GAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GA6CvD,IAzCA/gB,IADAyI,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAEN+gB,GADAhV,GAAKpM,GAAEuM,SACG,GACV8U,EAAMjV,GAAI,GACVwV,EAAMxV,GAAI,GACV4V,EAAM5V,GAAI,GACVgW,EAAMhW,GAAI,GAGV9K,IADAtB,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENihB,GADAlV,GAAKpM,GAAEuM,SACG,GACVgV,EAAMnV,GAAI,GACVyV,EAAMzV,GAAI,GACV6V,EAAM7V,GAAI,GACViW,EAAMjW,GAAI,GAGVlR,IADA8E,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENmiB,GADApW,GAAKpM,GAAEuM,SACG,GACVkW,EAAMrW,GAAI,GACV8W,EAAM9W,GAAI,GACVoX,EAAMpX,GAAI,GACV0X,EAAM1X,GAAI,GAGV/F,IADArG,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENqiB,GADAtW,GAAKpM,GAAEuM,SACG,GACVoW,EAAMvW,GAAI,GACV+W,EAAM/W,GAAI,GACVqX,EAAMrX,GAAI,GACV2X,EAAM3X,GAAI,GAEVkG,GAAI0O,EAAQ,GAEZsB,EAAK,EACLC,EAAK,EACLyB,EAAK,EACLC,EAAK,EACC1L,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA2J,EAAK,EACLC,EAAK,EACLuB,EAAK,EACLC,EAAK,EACLrI,GAAK/jB,GAAG+qB,GACR/G,GAAKja,GAAGihB,GACRrB,GAAKhmB,GAAG8oB,GACRE,GAAK7d,GAAG4d,GACRE,GAAK7R,GAAGiG,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA2J,EAAK,EACLC,EAAK,EACLqB,EAAK,EACLC,EAAK,EACL5P,GAAK6H,GAAI4G,GACT9G,GAAKG,GAAI4G,GACTxe,GAAKud,GAAIwC,GACTE,GAAKM,GAAIP,GACTE,GAAKM,GAAIhM,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLvP,GAAKC,GAAIqO,GACThQ,GAAKsJ,GAAI2G,GACTre,GAAKC,GAAIyf,GACTE,GAAKM,GAAIP,GACTE,GAAKM,GAAI9L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAU7B,IATAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLxI,EAAK9G,GAAIiO,GACTlH,GAAKzI,GAAI6P,GACTV,GAAKvd,GAAImf,GACTG,GAAKM,GAAIP,GACTE,GAAKM,GAAIxW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmW,GAAInW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,GAAImH,GAAMT,GAAI2B,GAAMI,GAAIF,IAClDtB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EAEPjB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,CACN,CACDb,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,EACNG,GAAMF,CACN,CACDjB,GAAMF,EACNG,GAAMF,EACNyB,GAAMF,EACNG,GAAMF,CACN,CACDnB,GAAMF,EACNG,GAAMF,EACN2B,GAAMF,EACNG,GAAMF,CACN,CACF,I9B6LAz0B,EAAAmb,GAAA,c+B9XA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAC,EACAC,EACAiB,EACAC,EACAC,EACAC,EACAyB,EACAC,EACAtZ,EACAC,EACA8B,EACAC,EACAyU,EACAC,EACAC,EACAC,EACAiB,EACAC,EACAC,EACAC,EACAuB,EACAC,EACAjK,EACAC,EACA0G,EACA+B,EACAC,EACAuB,EACAhL,EACApN,EACApM,EACAzI,EACA+J,EACApG,EACAmL,EACAiM,EACAzgB,EAKJ,GAFAkZ,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAwCtB,IApCAzT,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GAGV/F,GADArG,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENqiB,GADAtW,EAAKpM,EAAEuM,SACG,GACVoW,EAAMvW,EAAI,GAGVkG,GADAtS,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+jB,GADAhY,EAAKpM,EAAEuM,SACG,GACV8X,EAAMjY,EAAI,GAEVva,EAAImvB,EAAQ,GAEZS,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLwB,EAAK,EACCxX,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAY7B,IAXAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLwB,EAAK,EACLhK,EAAK/iB,EAAGkqB,GACRlH,EAAKjZ,EAAGqgB,GACRV,EAAK/lB,EAAG2nB,GACRG,EAAK3c,EAAG0c,GACRE,EAAK3Q,EAAGiS,GACRC,EAAK3yB,EAAGkb,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,GAAMI,EAAIF,GAAMG,EAAIqB,IAC5D9C,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EACN4B,GAAMF,EAEP3C,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EACN4B,GAAMF,CACN,CACF,I/B0RA/0B,EAAAmb,GAAA,cgCxYA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAO,EACAI,EACAV,EACAC,EACAM,EACAI,EACAO,EACAC,EACAS,EACAM,EACAd,EACAC,EACAQ,EACAM,EACAW,EACAC,EACAI,EACAC,EACA3Z,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAqJ,EACAC,EACAK,EACAI,EACAR,EACAC,EACAI,EACAI,EACAS,EACAC,EACAO,EACAM,EACAZ,EACAC,EACAM,EACAM,EACAW,EACAC,EACAI,EACAC,EACAtK,EACA9G,EACAC,EACA8G,GACAzI,GACAsJ,GACA6F,GACAvd,GACAC,GACAqf,GACAM,GACAM,GACAX,GACAM,GACAM,GACAW,GACA/Y,GACAC,GACA8N,GACApN,GACApM,GACAzI,GACA+J,GACApG,GACAmL,GACAiM,GACAzgB,GAOJ,GAJAkZ,GADAyO,GAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,GAAI,GACT1B,EAAK0B,GAAI,GACTtB,EAAKsB,GAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAkD5C,IA9CA3gB,IADAyI,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAEN+gB,GADAhV,GAAKpM,GAAEuM,SACG,GACV8U,EAAMjV,GAAI,GACVwV,EAAMxV,GAAI,GACV4V,EAAM5V,GAAI,GAGV9K,IADAtB,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENihB,GADAlV,GAAKpM,GAAEuM,SACG,GACVgV,EAAMnV,GAAI,GACVyV,EAAMzV,GAAI,GACV6V,EAAM7V,GAAI,GAGVlR,IADA8E,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENmiB,GADApW,GAAKpM,GAAEuM,SACG,GACVkW,EAAMrW,GAAI,GACV8W,EAAM9W,GAAI,GACVoX,EAAMpX,GAAI,GAGV/F,IADArG,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENqiB,GADAtW,GAAKpM,GAAEuM,SACG,GACVoW,EAAMvW,GAAI,GACV+W,EAAM/W,GAAI,GACVqX,EAAMrX,GAAI,GAGVkG,IADAtS,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAEN+jB,GADAhY,GAAKpM,GAAEuM,SACG,GACV8X,EAAMjY,GAAI,GACVqY,EAAMrY,GAAI,GACVsY,EAAMtY,GAAI,GAEVva,GAAImvB,EAAQ,GAEZkB,EAAK,EACLC,EAAK,EACLuB,EAAK,EACLC,EAAK,EACLiB,EAAK,EACCzM,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAY7B,IAXA2J,EAAK,EACLC,EAAK,EACLqB,EAAK,EACLC,EAAK,EACLsB,EAAK,EACLlR,EAAKlc,GAAG2qB,GACR9G,GAAK9Z,GAAG6gB,GACRxe,GAAKzI,GAAGwoB,GACRE,GAAKvd,GAAGsd,GACRE,GAAKvR,GAAGsS,GACRlZ,GAAK7Z,GAAGsmB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAY7B,IAXA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLwB,EAAK,EACL/Q,EAAKC,EAAIqO,GACThQ,GAAKsJ,GAAI2G,GACTre,GAAKC,GAAIyf,GACTE,GAAKM,GAAIP,GACTE,GAAKM,GAAIc,GACTlZ,GAAKC,GAAIqM,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAY7B,IAXAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLwB,EAAK,EACLhK,EAAK9G,EAAIiO,GACTlH,GAAKzI,GAAI6P,GACTV,GAAKvd,GAAImf,GACTG,GAAKM,GAAIP,GACTE,GAAKM,GAAIgB,GACTC,GAAK/Y,GAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,GAAI1X,GAAOrP,EAAK6c,EAAIkH,GAAMjH,GAAImH,GAAMT,GAAI2B,GAAMI,GAAIF,GAAMG,GAAIqB,IAC5D9C,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EACN4B,GAAMF,EAEP3C,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EACN4B,GAAMF,CACN,CACDvC,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,EACNG,GAAMF,EACNwB,GAAMF,CACN,CACDvC,GAAMF,EACNG,GAAMF,EACNyB,GAAMF,EACNG,GAAMF,EACNmB,GAAMF,CACN,CACF,IhCgNAp1B,EAAAmb,GAAA,ciCzZA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAC,EACAC,EACAiB,EACAC,EACA1X,EACAC,EACA8B,EACAC,EACAyU,EACAC,EACAC,EACAC,EACAiB,EACAC,EACAvI,EACAC,EACA0G,EACA+B,EACAxJ,EACApN,EACApM,EACAzI,EACA+J,EACApG,EACAmL,EAKJ,GAFA0E,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,KACJzO,GAAM,GAAKC,GAAM,GA0BtB,IAtBAzT,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GAEV/F,EAAI2a,EAAQ,GAEZS,EAAK,EACLE,EAAK,EACLkB,EAAK,EACC9V,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAQ7B,IAPAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLtI,EAAK/iB,EAAGkqB,GACRlH,EAAKjZ,EAAGqgB,GACRV,EAAK/lB,EAAG2nB,GACRG,EAAK3c,EAAG0G,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,IACxCpB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EAEPf,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,CACN,CACF,IjCuVAnzB,EAAAmb,GAAA,ckCnaA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAO,EACAN,EACAC,EACAM,EACAW,EACAC,EACAS,EACAnY,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAyJ,EACAC,EACAK,EACAJ,EACAC,EACAI,EACAa,EACAC,EACAO,EACA9I,EACA9G,EACA+G,EACAzI,EACAmP,EACAvd,EACA8V,EACApN,EACA4W,EACAM,EACAtjB,EACAzI,EACA+J,EACApG,EACAmL,EAMJ,GAHA0E,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GA4BjC,IAxBAvgB,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GACV8W,EAAM9W,EAAI,GAEV/F,EAAI2a,EAAQ,GACZc,EAAK,EACLC,EAAK,EACLqB,EAAK,EACCrL,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLrP,EAAKjc,EAAGuqB,GACRhQ,EAAKxQ,EAAGygB,GACRre,EAAKxI,EAAGkoB,GACRE,EAAKjd,EAAG0R,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAQ7B,IAPAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLtI,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAImf,GACTG,EAAKM,EAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,IACxCpB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EAEPf,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,CACN,CACDX,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,CACN,CACF,IlCsUA5zB,EAAAmb,GAAA,cmC5aA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAO,EACAI,EACAV,EACAC,EACAM,EACAI,EACAO,EACAC,EACAS,EACAM,EACAzY,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAqJ,EACAC,EACAK,EACAI,EACAR,EACAC,EACAI,EACAI,EACAS,EACAC,EACAO,EACAM,EACApJ,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA6F,EACAvd,EACAC,EACA6V,EACApN,EACA4W,EACAM,EACAM,EACA5jB,EACAzI,EACA+J,EACApG,EACAmL,EAOJ,GAJA0E,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,GACTtB,EAAKsB,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GA+B5C,IA3BA3gB,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GACV4V,EAAM5V,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GACV6V,EAAM7V,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GACV8W,EAAM9W,EAAI,GACVoX,EAAMpX,EAAI,GAEV/F,EAAI2a,EAAQ,GACZkB,EAAK,EACLC,EAAK,EACLuB,EAAK,EACCvL,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA2J,EAAK,EACLC,EAAK,EACLqB,EAAK,EACL3P,EAAKlc,EAAG2qB,GACR9G,EAAK9Z,EAAG6gB,GACRxe,EAAKzI,EAAGwoB,GACRE,EAAKvd,EAAG8R,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLrP,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAI2G,GACTre,EAAKC,EAAIyf,GACTE,EAAKM,EAAI7L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAQ7B,IAPAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLtI,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAImf,GACTG,EAAKM,EAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,IACxCpB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EAEPf,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,CACN,CACDX,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,CACN,CACDhB,GAAMF,EACNG,GAAMF,EACNyB,GAAMF,CACN,CACF,InCmTAl0B,EAAAmb,GAAA,coCtbA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAO,EACAI,EACAI,EACAd,EACAC,EACAM,EACAI,EACAI,EACAG,EACAC,EACAS,EACAM,EACAM,EACA/Y,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACAiJ,EACAC,EACAK,EACAI,EACAI,EACAZ,EACAC,EACAI,EACAI,EACAI,EACAK,EACAC,EACAO,EACAM,EACAM,EACA1J,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACA0F,EACAvd,EACAC,EACAud,GACA1H,GACApN,GACA4W,GACAM,GACAM,GACAM,GACAlkB,GACAzI,GACA+J,GACApG,GACAmL,GAQJ,GALA0E,GADAyO,GAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,GAAI,GACT1B,EAAK0B,GAAI,GACTtB,EAAKsB,GAAI,GACTlB,EAAKkB,GAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAmCvD,IA/BA/gB,IADAyI,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAEN+gB,GADAhV,GAAKpM,GAAEuM,SACG,GACV8U,EAAMjV,GAAI,GACVwV,EAAMxV,GAAI,GACV4V,EAAM5V,GAAI,GACVgW,EAAMhW,GAAI,GAGV9K,IADAtB,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENihB,GADAlV,GAAKpM,GAAEuM,SACG,GACVgV,EAAMnV,GAAI,GACVyV,EAAMzV,GAAI,GACV6V,EAAM7V,GAAI,GACViW,EAAMjW,GAAI,GAGVlR,IADA8E,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENmiB,GADApW,GAAKpM,GAAEuM,SACG,GACVkW,EAAMrW,GAAI,GACV8W,EAAM9W,GAAI,GACVoX,EAAMpX,GAAI,GACV0X,EAAM1X,GAAI,GAEV/F,GAAI2a,EAAQ,GACZsB,EAAK,EACLC,EAAK,EACLyB,EAAK,EAECzL,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA2J,EAAK,EACLC,EAAK,EACLuB,EAAK,EACLpI,EAAK/jB,GAAG+qB,GACR/G,EAAKja,GAAGihB,GACRrB,GAAKhmB,GAAG8oB,GACRE,GAAK7d,GAAGkS,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA2J,EAAK,EACLC,EAAK,EACLqB,EAAK,EACL3P,EAAK6H,EAAI4G,GACT9G,EAAKG,EAAI4G,GACTxe,EAAKud,GAAIwC,GACTE,GAAKM,GAAI/L,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLrP,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAI2G,GACTre,EAAKC,EAAIyf,GACTE,GAAKM,GAAI7L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAQ7B,IAPAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLtI,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAImf,GACTG,GAAKM,GAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,GAAIlW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,IACxCpB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EAEPf,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,CACN,CACDX,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,CACN,CACDhB,GAAMF,EACNG,GAAMF,EACNyB,GAAMF,CACN,CACDlB,GAAMF,EACNG,GAAMF,EACN2B,GAAMF,CACN,CACF,IpCgSAx0B,EAAAmb,GAAA,YqClcA,SAAmBuW,EAAQG,EAAQ1jB,GAClC,IAAI2jB,EACAC,EACAtW,EACAC,EACA8B,EACAC,EACAyU,EACAC,EACAnH,EACAC,EACAf,EACApN,EACApM,EACAzI,EACA+J,EAKJ,GAFAyJ,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAYtB,IARAzT,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GAEV9K,EAAI0f,EAAQ,GAEZS,EAAK,EACC1U,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAI7B,IAHAyU,EAAK,EACLlH,EAAK/iB,EAAGkqB,GACRlH,EAAKjZ,EAAGyL,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIkH,IACpBA,GAAMJ,EAEPK,GAAMJ,CACN,CACF,IrCkaA/xB,EAAAmb,GAAA,YsC5cA,SAAmBuW,EAAQG,EAAQ1jB,GAClC,IAAI2jB,EACAC,EACAO,EACA7W,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAyJ,EACAC,EACAK,EACAxH,EACA9G,EACA+G,EACAzI,EACA0H,EACApN,EACApM,EACAzI,EACA+J,EAMJ,GAHAyJ,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAYjC,IARAvgB,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GAEV9K,EAAI0f,EAAQ,GACZc,EAAK,EACC/J,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA0J,EAAK,EACLjO,EAAKjc,EAAGuqB,GACRhQ,EAAKxQ,EAAGyW,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAI7B,IAHAyU,EAAK,EACLlH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIkH,IACpBA,GAAMJ,EAEPK,GAAMJ,CACN,CACDS,GAAMF,CACN,CACF,ItC+ZAtyB,EAAAmb,GAAA,YuCtdA,SAAmBuW,EAAQG,EAAQ1jB,GAClC,IAAI2jB,EACAC,EACAO,EACAI,EACAjX,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAqJ,EACAC,EACAK,EACAI,EACA5H,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA5B,EACApN,EACApM,EACAzI,EACA+J,EAOJ,GAJAyJ,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,GACTtB,EAAKsB,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAa5C,IATA3gB,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GACV4V,EAAM5V,EAAI,GAEV9K,EAAI0f,EAAQ,GACZkB,EAAK,EACC/J,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA2J,EAAK,EACLrO,EAAKlc,EAAG2qB,GACR9G,EAAK9Z,EAAG6W,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA0J,EAAK,EACLjO,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAI7B,IAHAyU,EAAK,EACLlH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIkH,IACpBA,GAAMJ,EAEPK,GAAMJ,CACN,CACDS,GAAMF,CACN,CACDM,GAAMF,CACN,CACF,IvC2ZA1yB,EAAAmb,GAAA,YwCheA,SAAmBuW,EAAQG,EAAQ1jB,GAClC,IAAI2jB,EACAC,EACAO,EACAI,EACAI,EACArX,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACAiJ,EACAC,EACAK,EACAI,EACAI,EACAhI,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACA/B,EACApN,EACApM,EACAzI,EACA+J,EAQJ,GALAyJ,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,GACTtB,EAAKsB,EAAI,GACTlB,EAAKkB,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAcvD,IAVA/gB,GADAyI,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GACV4V,EAAM5V,EAAI,GACVgW,EAAMhW,EAAI,GAEV9K,EAAI0f,EAAQ,GACZsB,EAAK,EACC/J,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA2J,EAAK,EACL5G,EAAK/jB,EAAG+qB,GACR/G,EAAKja,EAAGiX,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA2J,EAAK,EACLrO,EAAK6H,EAAI4G,GACT9G,EAAKG,EAAIpD,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA0J,EAAK,EACLjO,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAI7B,IAHAyU,EAAK,EACLlH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIkH,IACpBA,GAAMJ,EAEPK,GAAMJ,CACN,CACDS,GAAMF,CACN,CACDM,GAAMF,CACN,CACDM,GAAMF,CACN,CACF,IxCuZA9yB,EAAAmb,GAAA,iBAAA4I,IAUA/jB,EAAAmb,GAAA,mBAAA8I,IAUAjkB,EAAAmb,GAAA,kBAAAmJ,IAUAtkB,EAAAmb,GAAA,OAAAuB,IAUA1c,EAAAmb,GAAA,cAAAoa,IAUAv1B,EAAAmb,GAAA,aAAAqJ,IAUAxkB,EAAAmb,GAAA,WyCxeA,SAAkBlT,EAAGrF,EAAW2K,GAC/B,OAAKjN,EAAiB2H,GAtCvB,SAAoBA,EAAGrF,EAAW2K,GACjC,IAAI1N,EACA1G,EACAC,EAKJ,IAHAyG,EAAMqR,GAAejJ,GAErB9O,EAAI,EACEC,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrBwJ,EAAU1H,KAAMqS,EAAS1N,EAAKoI,EAAG7O,GAAKA,EAAG6O,KAC7C9O,GAAK,GAGP,OAAOA,CACR,CAyBSkX,CAAWpI,EAAGrF,EAAW2K,GAzElC,SAAkBtF,EAAGrF,EAAW2K,GAC/B,IAAIpU,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrBwJ,EAAU1H,KAAMqS,EAAStF,EAAG7O,GAAKA,EAAG6O,KACxC9O,GAAK,GAGP,OAAOA,CACR,CAgEQorB,CAAStc,EAAGrF,EAAW2K,EAC/B,IzC6eAvN,EAAAmb,GAAA,YrMzdA,WACC,IAAIqa,EACA9D,EAEAhxB,EACAuH,EACA7O,EAIJ,IAFAs4B,EAAS,GACT8D,EAAa,GACPp8B,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,GAAK,EACvCs4B,EAAOvzB,KAAM2S,GAAkBxT,UAAWlE,KAC1Co8B,EAAWr3B,KAAMb,UAAWlE,EAAE,IAK/B,IADAsH,EAAMkkB,GADAtnB,UAAW,GAAI1D,QAEfR,EAAI,EAAGA,EAAIs4B,EAAO93B,OAAQR,IAG9BsH,GAFDuH,EAAIypB,EAAQt4B,IACLmX,iBACAF,GAAWpI,EAAGvH,EAAK80B,EAAYp8B,IAE/BmrB,GAAStc,EAAE8I,KAAMrQ,EAAK80B,EAAYp8B,IAG1C,OAAOsH,EAAI9G,MACZ,IqMycAoG,EAAAmb,GAAA,kB0C7aA,SAAyBlT,EAAGhP,GAC3B,OAAKqH,EAAiB2H,GAChB+N,GAAqB/N,GAtF5B,SAAkBA,EAAGhP,GACpB,IAAIwrB,EACA9Z,EACAC,EACAzR,EACAC,EAEJ,IAAM+R,GAAelS,GACpB,OAAO,EAQR,IANA0R,EAAKH,GAAMvR,GACX2R,EAAKH,GAAMxR,GAEXwrB,EAAO5Y,GAAa5D,EAAG,GAEvB9O,EAAI,EACEC,EAAI,EAAGA,EAAIqrB,EAAK7qB,OAAQR,GAAK,EAC7B4b,GAAayP,EAAMrrB,GAAKuR,IAAQqK,GAAayP,EAAMrrB,EAAE,GAAKwR,KAC9DzR,GAAK,GAGP,OAAOA,CACR,CAiEUwrB,CAAS1c,EAAGhP,GAEf2W,GAAgB3H,GAjDvB,SAAkBA,EAAGhP,GACpB,IAAIwrB,EACAtrB,EACAoJ,EACAnJ,EAEJ,IAAM8P,GAAWjQ,GAChB,OAAO,EAMR,IAJAwrB,EAAOzI,GAAoB/T,EAAG,GAE9B1F,EAAI,EAAY,EAAI,EACpBpJ,EAAI,EACEC,EAAI,EAAGA,EAAIqrB,EAAK7qB,OAAQR,IACxBqrB,EAAMrrB,KAAQmJ,IAClBpJ,GAAK,GAGP,OAAOA,CACR,CA+BU8rB,CAAShd,EAAGhP,GA3HtB,SAAoBgP,EAAGhP,GACtB,IAAI4G,EACA1G,EACAC,EAKJ,IAHAyG,EAAMqR,GAAejJ,GAErB9O,EAAI,EACEC,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrB4b,GAAanV,EAAKoI,EAAG7O,GAAKH,KAC9BE,GAAK,GAGP,OAAOA,CACR,CA+GSkX,CAAWpI,EAAGhP,GA1JvB,SAAkBgP,EAAGhP,GACpB,IAAIE,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrB4b,GAAa/M,EAAG7O,GAAKH,KACzBE,GAAK,GAGP,OAAOA,CACR,CAiJQorB,CAAStc,EAAGhP,EACpB,I1C4aA+G,EAAAmb,GAAA,sB2CvbA,SAA6BlT,EAAGhP,GAC/B,OAAKqH,EAAiB2H,GAChB+N,GAAqB/N,GAtF5B,SAAkBA,EAAGhP,GACpB,IAAIwrB,EACA9Z,EACAC,EACAzR,EACAC,EAEJ,IAAM+R,GAAelS,GACpB,OAAO,EAQR,IANA0R,EAAKH,GAAMvR,GACX2R,EAAKH,GAAMxR,GAEXwrB,EAAO5Y,GAAa5D,EAAG,GAEvB9O,EAAI,EACEC,EAAI,EAAGA,EAAIqrB,EAAK7qB,OAAQR,GAAK,EAC7ByrB,GAAiBJ,EAAMrrB,GAAKuR,IAAQka,GAAiBJ,EAAMrrB,EAAE,GAAKwR,KACtEzR,GAAK,GAGP,OAAOA,CACR,CAiEUwrB,CAAS1c,EAAGhP,GAEf2W,GAAgB3H,GAjDvB,SAAkBA,EAAGhP,GACpB,IAAIwrB,EACAtrB,EACAoJ,EACAnJ,EAEJ,IAAM8P,GAAWjQ,GAChB,OAAO,EAMR,IAJAwrB,EAAOzI,GAAoB/T,EAAG,GAE9B1F,EAAI,EAAY,EAAI,EACpBpJ,EAAI,EACEC,EAAI,EAAGA,EAAIqrB,EAAK7qB,OAAQR,IACxBqrB,EAAMrrB,KAAQmJ,IAClBpJ,GAAK,GAGP,OAAOA,CACR,CA+BU8rB,CAAShd,EAAGhP,GA3HtB,SAAoBgP,EAAGhP,GACtB,IAAI4G,EACA1G,EACAC,EAKJ,IAHAyG,EAAMqR,GAAejJ,GAErB9O,EAAI,EACEC,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrByrB,GAAiBhlB,EAAKoI,EAAG7O,GAAKH,KAClCE,GAAK,GAGP,OAAOA,CACR,CA+GSkX,CAAWpI,EAAGhP,GA1JvB,SAAkBgP,EAAGhP,GACpB,IAAIE,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrByrB,GAAiB5c,EAAG7O,GAAKH,KAC7BE,GAAK,GAGP,OAAOA,CACR,CAiJQorB,CAAStc,EAAGhP,EACpB,I3CsbA+G,EAAAmb,GAAA,cAAA2J,IAUA9kB,EAAAmb,GAAA,QAAA+J,IAUAllB,EAAAmb,GAAA,UAAAgK,IAUAnlB,EAAAmb,GAAA,SAAAiK,IAUAplB,EAAAmb,GAAA,U4CrfA,SAAiBlT,EAAGwtB,EAAOC,GAC1B,OAAKA,EAzEN,SAA0BztB,EAAGwtB,GAC5B,IAAIE,EACA53B,EACA8E,EACA+yB,EACAj0B,EACAY,EACAnJ,EAGJ,GAAa,KADbyJ,EAAMoF,EAAErO,QAEP,OAAOqO,EASR,IAPAtG,GAAM,EAEDnF,GADLuB,EAAOkK,EAAG,MAETtG,GAAM,GAEPg0B,EAAQ,EACRC,EAAM,EACAx8B,EAAI,EAAGA,EAAIyJ,EAAKzJ,KACrBmJ,EAAI0F,EAAG7O,MACI2E,GAAU4D,GAAOnF,GAAO+F,IAClCozB,GAAS,IACKF,IACbxtB,EAAG2tB,GAAQ73B,EACX63B,GAAO,IAGR73B,EAAOwE,EACPozB,EAAQ,EACR1tB,EAAG2tB,GAAQ73B,EACX63B,GAAO,EACPj0B,GAAM,EACDnF,GAAOuB,KACX4D,GAAM,IAKT,OADAsG,EAAErO,OAASg8B,EACJ3tB,CACR,CAiCS4tB,CAAiB5tB,EAAGwtB,GAtI7B,SAAwBxtB,EAAGwtB,GAC1B,IAAIE,EACA53B,EACA8E,EACA+yB,EACArzB,EACAnJ,EAGJ,GAAa,KADbyJ,EAAMoF,EAAErO,QAEP,OAAOqO,EAKR,IAHAlK,EAAOkK,EAAG,GACV0tB,EAAQ,EACRC,EAAM,EACAx8B,EAAI,EAAGA,EAAIyJ,EAAKzJ,KACrBmJ,EAAI0F,EAAG7O,MACI2E,GACV43B,GAAS,IACKF,IACbxtB,EAAG2tB,GAAQ73B,EACX63B,GAAO,IAGR73B,EAAOwE,EACPozB,EAAQ,EACR1tB,EAAG2tB,GAAQ73B,EACX63B,GAAO,GAIT,OADA3tB,EAAErO,OAASg8B,EACJ3tB,CACR,CAwGQ6tB,CAAe7tB,EAAGwtB,EAC1B,I5C0fAz1B,EAAAmb,GAAA,mB6C3oBA,SAA0B1a,EAAKs1B,GAC9B,IAAIl2B,EACAxG,EACAiG,EACAwP,EACA1V,EACA6d,EACA1U,EAGJ,IADAuM,EAAIrO,EAAI7G,QACC,EACR,MAAO,GAQR,IALAqd,GADApX,EAAMqR,GAAe6kB,IACZA,EAAQ,GACjBxzB,EAAI1C,EAAKk2B,EAAQ,GAEjBl2B,EAAMqR,GAAezQ,GACrBpH,EAAM,GACAD,EAAI,EAAGA,EAAI0V,EAAG1V,KACnBkG,EAAM,CAAA,GACD2X,GAAM7d,EACXkG,EAAKiD,GAAM1C,EAAKY,EAAKrH,GACrBC,EAAI8E,KAAMmB,GAEX,OAAOjG,CACR,I7C2nBA2G,EAAAmb,GAAA,iB8CtnBA,SAAwB1a,EAAKs1B,GAC5B,IAAIC,EACAn2B,EACAC,EACA+O,EACAxV,EACAyV,EACAmI,EACA1U,EACAnJ,EAGJ,IADA0V,EAAIrO,EAAI7G,QACC,EACR,MAAO,GAqBR,SAASq8B,EAAO78B,GAEf,OADAgH,EAA0BsK,KAAM,KAAMtR,GAC/BsR,IACP,CAWD,IAhCAmE,EAAMwB,GAAW5P,GAAM4P,UACvBxQ,EAAMgP,EAAK,GACX/O,EAAM+O,EAAK,GAGXmnB,EAAO9kB,GAAe6kB,GACtB9e,EAAI+e,EAAMD,EAAQ,GAClBxzB,EAAIyzB,EAAMD,EAAQ,GClDnB,SAA8Bz2B,EAAKC,EAAM8B,GACxCtI,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdL,IAAOwB,GAET,CD6DC60B,CAAqBD,EAAMh8B,UAAWgd,GAmBtC,WACC,OAAOvM,KAAKyrB,EACZ,IApBD9Q,GAAsB4Q,EAAMh8B,UAAWsI,GA4BvC,WACC,OAAO1C,EAAKY,EAAKiK,KAAKyrB,GACtB,IAQD,SAAmBl9B,GAClB6G,EAAKW,EAAKiK,KAAKyrB,GAAIl9B,EACnB,IArCDmH,EAA0B61B,EAAMh8B,UAAW,UA6C3C,WACC,IAAIZ,EAKJ,OAHAA,EAAM,CAAA,GACD4d,GAAMvM,KAAMuM,GACjB5d,EAAKkJ,GAAMmI,KAAMnI,GACVlJ,CACP,IAjDDA,EAAM,GACAD,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBC,EAAI8E,KAAM,IAAI83B,EAAO78B,IAEtB,OAAOC,CA8CR,I9C+hBA2G,EAAAmb,GAAA,SzL7iBA,SAAgBlT,GACf,IAAI3I,EAAMwR,GAAkB7I,GAC5B,OAAK3I,EAAIiR,iBAEHhF,GAAmBtD,GAChBqd,GAAiBnY,GAAgBlF,EAAG,IAEvCqD,GAAkBrD,GACfqd,GAAiBpY,GAAejF,EAAG,IAGtC2H,GAAgB3H,GACbgJ,GAAU+K,GAAoB/T,EAAG,IAjD3C,SAAoBA,GACnB,IAAI8I,EACAlR,EACAzG,EAKJ,IAHA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEbjX,EAAI,EAAGA,EAAI2X,EAAKnX,OAAQR,IAC7B,IAAMyG,EAAKkR,EAAM3X,GAChB,OAAO,EAGT,OAAO,CACR,CAqCSiX,CAAW/Q,GAEZ2R,GAAUhJ,EAClB,IyLsiBAjI,EAAAmb,GAAA,WgD/kBA,SAAkBlT,EAAGrF,EAAW2K,GAC/B,IAAIjO,EACJ,OA9FD,SAAoBA,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CA4FMC,CAAWxmB,EAAG,SACXA,EAAEmuB,MAAOxzB,EAAW2K,IAE5BjO,EAAMwR,GAAkB7I,IACfsI,iBA3CV,SAAoBtI,EAAGrF,EAAW2K,GACjC,IAAIwD,EACAlR,EACAzG,EAKJ,IAHA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEbjX,EAAI,EAAGA,EAAI2X,EAAKnX,OAAQR,IAC7B,IAAMwJ,EAAU1H,KAAMqS,EAAS1N,EAAKkR,EAAM3X,GAAKA,EAAG2X,GACjD,OAAO,EAGT,OAAO,CACR,CA8BSV,CAAW/Q,EAAKsD,EAAW2K,GA5EpC,SAAmBtF,EAAGrF,EAAW2K,GAChC,IAAInU,EACJ,IAAMA,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1B,IAAMwJ,EAAU1H,KAAMqS,EAAStF,EAAG7O,GAAKA,EAAG6O,GACzC,OAAO,EAGT,OAAO,CACR,CAsEQgJ,CAAUhJ,EAAGrF,EAAW2K,EAChC,IhD+kBAvN,EAAAmb,GAAA,gBiD7mBA,SAAuBlT,EAAGrF,EAAW2K,GACpC,IAAIjO,EAAMwR,GAAkB7I,GAC5B,OAAK3I,EAAIiR,iBAvCV,SAAoBtI,EAAGrF,EAAW2K,GACjC,IAAIwD,EACAlR,EACAzG,EAKJ,IAHA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEbjX,EAAI2X,EAAKnX,OAAO,EAAGR,GAAK,EAAGA,IAChC,IAAMwJ,EAAU1H,KAAMqS,EAAS1N,EAAKkR,EAAM3X,GAAKA,EAAG2X,GACjD,OAAO,EAGT,OAAO,CACR,CA0BSV,CAAW/Q,EAAKsD,EAAW2K,GAxEpC,SAAmBtF,EAAGrF,EAAW2K,GAChC,IAAInU,EACJ,IAAMA,EAAI6O,EAAErO,OAAO,EAAGR,GAAK,EAAGA,IAC7B,IAAMwJ,EAAU1H,KAAMqS,EAAStF,EAAG7O,GAAKA,EAAG6O,GACzC,OAAO,EAGT,OAAO,CACR,CAkEQgJ,CAAUhJ,EAAGrF,EAAW2K,EAChC,IjDinBAvN,EAAAmb,GAAA,aAAAkb,IAUAr2B,EAAAmb,GAAA,mBAAAmb,IAUAt2B,EAAAmb,GAAA,QkD1mBA,SAAelT,EAAGhP,EAAO6U,EAAOI,GAC/B,IAAI5O,EACJ,OA3GD,SAAoBA,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CAyGMC,CAAWxmB,EAAG,QACXA,EAAEqV,KAAMrkB,EAAO6U,EAAOI,IAEzBJ,EAAQ,IACZA,GAAS7F,EAAErO,QACE,IACZkU,EAAQ,GAGLI,EAAM,EACVA,GAAOjG,EAAErO,OACEsU,EAAMjG,EAAErO,SACnBsU,EAAMjG,EAAErO,SAET0F,EAAMwR,GAAkB7I,IACfsI,iBA9DV,SAAoBtI,EAAGhP,EAAO6U,EAAOI,GACpC,IAAI6C,EACAjR,EACA1G,EAIJ,IAFA2X,EAAO9I,EAAE8I,KACTjR,EAAMmI,EAAEoI,UAAW,GACbjX,EAAI0U,EAAO1U,EAAI8U,EAAK9U,IACzB0G,EAAKiR,EAAM3X,EAAGH,GAEf,OAAO8X,CACR,CAoDSV,CAAW/Q,EAAKrG,EAAO6U,EAAOI,GAvGvC,SAAkBjG,EAAGhP,EAAO6U,EAAOI,GAClC,IAAI9U,EACJ,IAAMA,EAAI0U,EAAO1U,EAAI8U,EAAK9U,IACzB6O,EAAG7O,GAAMH,EAEV,OAAOgP,CACR,CAmGQsc,CAAStc,EAAGhP,EAAO6U,EAAOI,GAClC,IlD+lBAlO,EAAAmb,GAAA,UmDnnBA,SAAiBlT,EAAG6F,EAAOI,EAAKC,EAAKZ,GACpC,IAAIjO,EAaJ,OAZKwO,EAAQ,IACZA,GAAS7F,EAAErO,QACE,IACZkU,EAAQ,GAGLI,EAAM,EACVA,GAAOjG,EAAErO,OACEsU,EAAMjG,EAAErO,SACnBsU,EAAMjG,EAAErO,SAET0F,EAAMwR,GAAkB7I,IACfsI,iBAtEV,SAAoBtI,EAAG6F,EAAOI,EAAKC,EAAKZ,GACvC,IAAIwD,EACAlR,EACAC,EACA1G,EAKJ,IAHA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GACnBvQ,EAAMmI,EAAEoI,UAAW,GACbjX,EAAI0U,EAAO1U,EAAI8U,EAAK9U,IACzB0G,EAAKiR,EAAM3X,EAAG+U,EAAIjT,KAAMqS,EAAS1N,EAAKkR,EAAM3X,GAAKA,EAAG2X,IAErD,OAAOA,CACR,CA0DSV,CAAW/Q,EAAKwO,EAAOI,EAAKC,EAAKZ,GApH1C,SAAkBtF,EAAG6F,EAAOI,EAAKC,EAAKZ,GACrC,IAAInU,EACJ,IAAMA,EAAI0U,EAAO1U,EAAI8U,EAAK9U,IACzB6O,EAAG7O,GAAM+U,EAAIjT,KAAMqS,EAAStF,EAAG7O,GAAKA,EAAG6O,GAExC,OAAOA,CACR,CAgHQsc,CAAStc,EAAG6F,EAAOI,EAAKC,EAAKZ,EACrC,InD2mBAvN,EAAAmb,GAAA,SAAAG,IAUAtb,EAAAmb,GAAA,WAAAkN,IAUAroB,EAAAmb,GAAA,WAAAI,IAUAvb,EAAAmb,GAAA,coD5wBA,SAAqBK,EAAOhO,EAAMD,GACjC,IAAI9M,EACA8c,EACA9B,EACAC,EACAtiB,EACA8D,EAOJ,IALAue,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZ/a,EAAM,GACArH,EAAI,EAAGA,EAAIsiB,EAAItiB,IAAM,CAE1B,IADAmkB,EAAK,GACCrgB,EAAI,EAAGA,EAAIue,EAAIve,IACpBqgB,EAAGpf,KAAMqP,EAAKtS,KAAMqS,EAAS,CAAEnU,EAAG8D,KAEnCuD,EAAItC,KAAMof,EACV,CACD,OAAO9c,CACR,IpDiwBAT,EAAAmb,GAAA,WAAAmN,IAUAtoB,EAAAmb,GAAA,cqDhyBA,SAAqBK,EAAOhO,EAAMD,GACjC,IAAI9M,EACA8c,EACAgL,EACA9M,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EAQJ,IANAhN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZ/a,EAAM,GACAgoB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAE7B,IADAF,EAAK,GACCC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBD,EAAGpf,KAAMqP,EAAKtS,KAAMqS,EAAS,CAAEkb,EAAIhL,EAAID,KAExC+K,EAAGpqB,KAAMof,EACT,CACD9c,EAAItC,KAAMoqB,EACV,CACD,OAAO9nB,CACR,IrD6wBAT,EAAAmb,GAAA,WAAAuN,IAUA1oB,EAAAmb,GAAA,csDpzBA,SAAqBK,EAAOhO,EAAMD,GACjC,IAAI9M,EACA8c,EACAgL,EACAI,EACAlN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EASJ,IAPApN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZ/a,EAAM,GACAooB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAE7B,IADAF,EAAK,GACCC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBD,EAAGpf,KAAMqP,EAAKtS,KAAMqS,EAAS,CAAEsb,EAAIJ,EAAIhL,EAAID,KAE5C+K,EAAGpqB,KAAMof,EACT,CACDoL,EAAGxqB,KAAMoqB,EACT,CACD9nB,EAAItC,KAAMwqB,EACV,CACD,OAAOloB,CACR,ItDyxBAT,EAAAmb,GAAA,WAAA2N,IAUA9oB,EAAAmb,GAAA,cuDx0BA,SAAqBK,EAAOhO,EAAMD,GACjC,IAAI9M,EACA8c,EACAgL,EACAI,EACAI,EACAtN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EAUJ,IARAxN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZ/a,EAAM,GACAwoB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAE7B,IADAF,EAAK,GACCC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBD,EAAGpf,KAAMqP,EAAKtS,KAAMqS,EAAS,CAAE0b,EAAIJ,EAAIJ,EAAIhL,EAAID,KAEhD+K,EAAGpqB,KAAMof,EACT,CACDoL,EAAGxqB,KAAMoqB,EACT,CACDQ,EAAG5qB,KAAMwqB,EACT,CACDloB,EAAItC,KAAM4qB,EACV,CACD,OAAOtoB,CACR,IvDqyBAT,EAAAmb,GAAA,WAAA+N,IAUAlpB,EAAAmb,GAAA,c7HpzBA,SAAqBK,EAAOhO,EAAMD,GACjC,OAAO8O,GAASb,EAAM5hB,OAAQ4hB,EAAO,EAAG,GAAI,GAAIhO,EAAMD,EACvD,I6H4zBAvN,EAAAmb,GAAA,UwD1vBA,SAAiBlT,EAAGrF,EAAW2K,GAC9B,IAAIjO,EACJ,OAvGD,SAAoBA,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CAqGMC,CAAWxmB,EAAG,UACXA,EAAEupB,OAAQ5uB,EAAW2K,IAE7BjO,EAAMwR,GAAkB7I,IACfsI,iBA/CV,SAAoBtI,EAAGrF,EAAW2K,GACjC,IAAIwD,EACAlR,EACAxG,EACAkJ,EACAnJ,EAMJ,IAJA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEnBhX,EAAM,GACAD,EAAI,EAAGA,EAAI2X,EAAKnX,OAAQR,IAC7BmJ,EAAI1C,EAAKkR,EAAM3X,GACVwJ,EAAU1H,KAAMqS,EAAShL,EAAGnJ,EAAG2X,IACnC1X,EAAI8E,KAAMoE,GAGZ,OAAOlJ,CACR,CA8BSgX,CAAW/Q,EAAKsD,EAAW2K,GArFpC,SAAmBtF,EAAGrF,EAAW2K,GAChC,IAAIlU,EACAkJ,EACAnJ,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1BmJ,EAAI0F,EAAG7O,GACFwJ,EAAU1H,KAAMqS,EAAShL,EAAGnJ,EAAG6O,IACnC5O,EAAI8E,KAAMoE,GAGZ,OAAOlJ,CACR,CA0EQ4X,CAAUhJ,EAAGrF,EAAW2K,EAChC,IxD0vBAvN,EAAAmb,GAAA,SyD/2BA,SAAgB1a,GAGf,GAAoB,IAAfA,EAAI7G,OAOT,OAHMsX,GAAezQ,EAGdZ,CAAKY,EAAK,EAClB,IzD82BAT,EAAAmb,GAAA,UAAA8O,IAUAjqB,EAAAmb,GAAA,YAAAkP,IAUArqB,EAAAmb,GAAA,YAAAoP,IAUAvqB,EAAAmb,GAAA,cAAAqP,IAUAxqB,EAAAmb,GAAA,YAAAsP,IAUAzqB,EAAAmb,GAAA,cAAAuP,IAUA1qB,EAAAmb,GAAA,YAAAwP,IAUA3qB,EAAAmb,GAAA,cAAAyP,IAUA5qB,EAAAmb,GAAA,YAAA0P,IAUA7qB,EAAAmb,GAAA,cAAA2P,IAUA9qB,EAAAmb,GAAA,WAAA4P,IAUA/qB,EAAAmb,GAAA,WAAA+P,IAUAlrB,EAAAmb,GAAA,WAAAgQ,IAUAnrB,EAAAmb,GAAA,Y0Dr/BA,SAAmBlT,GAClB,IAAI5O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1BC,EAAI8E,KAAMgtB,GAAUljB,EAAG7O,KAExB,OAAOC,CACR,I1Ds/BA2G,EAAAmb,GAAA,WAAAiQ,IAUAprB,EAAAmb,GAAA,WAAAkQ,IAUArrB,EAAAmb,GAAA,WAAAmQ,IAUAtrB,EAAAmb,GAAA,Y2D7hCA,SAAmBlT,GAClB,IAAI5O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1BC,EAAI8E,KAAMmtB,GAAUrjB,EAAG7O,KAExB,OAAOC,CACR,I3D8hCA2G,EAAAmb,GAAA,iB4DpiCA,SAAwBrM,EAAG7G,EAAG8K,EAAQjH,GACrC,IAAIzS,EACAwG,EACAonB,EACA7tB,EAQJ,IALAyG,EAAMqR,GAAejJ,GAGrBgf,EAAKnb,EACLzS,EAAM,GACAD,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBC,EAAI8E,KAAM0B,EAAKoI,EAAGgf,IAClBA,GAAMlU,EAEP,OAAO1Z,CACR,I5D6hCA2G,EAAAmb,GAAA,SAAA9Z,GAUArB,EAAAmb,GAAA,gB6D3jCA,SAAuBlT,EAAGsuB,GACzB,IAAIzhB,EACA2c,EACA5uB,EACAxJ,EACAm9B,EACA9lB,EACAnO,EACAnJ,EAIJ,GADAyJ,EAAMoF,EAAErO,OACH28B,EAAO38B,SAAWiJ,EACtB,MAAM,IAAIoK,WAAY,+EAQvB,IALA6H,EAAO5D,GAAejJ,GACtBwpB,EAAOvgB,GAAeqlB,GAGtBl9B,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAIuS,EAAM7M,EAAG7O,GAEbsX,EAAIrX,EADJm9B,EAAI/E,EAAM8E,EAAQn9B,GAAIyB,YAEjByB,GAASoU,GACbA,EAAEvS,KAAM,CAAE/E,EAAGmJ,IAEblJ,EAAKm9B,GAAM,CAAE,CAAEp9B,EAAGmJ,IAGpB,OAAOlJ,CACR,I7DqiCA2G,EAAAmb,GAAA,kB8DlkCA,SAAyBlT,EAAGwuB,EAAWlpB,GACtC,IAAI1N,EACAgD,EACAxJ,EACAm9B,EACA9lB,EACAnO,EACAnJ,EAUJ,IAPAyJ,EAAMoF,EAAErO,OAGRiG,EAAMqR,GAAejJ,GAGrB5O,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI1C,EAAKoI,EAAG7O,GAEZsX,EAAIrX,EADJm9B,EAAIC,EAAUv7B,KAAMqS,EAAShL,EAAGnJ,EAAG6O,IAE9B3L,GAASoU,GACbA,EAAEvS,KAAM,CAAE/E,EAAGmJ,IAEblJ,EAAKm9B,GAAM,CAAE,CAAEp9B,EAAGmJ,IAGpB,OAAOlJ,CACR,I9DgjCA2G,EAAAmb,GAAA,gB+D/kCA,SAAuBlT,EAAGsuB,GACzB,IAAI9E,EACA5uB,EACAxJ,EACAm9B,EACA9lB,EACAtX,EAIJ,GADAyJ,EAAMoF,EAAErO,OACH28B,EAAO38B,SAAWiJ,EACtB,MAAM,IAAIoK,WAAY,+EAOvB,IAJAwkB,EAAOvgB,GAAeqlB,GAGtBl9B,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAErBsX,EAAIrX,EADJm9B,EAAI/E,EAAM8E,EAAQn9B,GAAIyB,YAEjByB,GAASoU,GACbA,EAAEvS,KAAM/E,GAERC,EAAKm9B,GAAM,CAAEp9B,GAGf,OAAOC,CACR,I/D6jCA2G,EAAAmb,GAAA,kBgEtlCA,SAAyBlT,EAAGwuB,EAAWlpB,GACtC,IAAI1N,EACAgD,EACAxJ,EACAm9B,EACA9lB,EACAtX,EAUJ,IAPAyJ,EAAMoF,EAAErO,OAGRiG,EAAMqR,GAAejJ,GAGrB5O,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAErBsX,EAAIrX,EADJm9B,EAAIC,EAAUv7B,KAAMqS,EAAS1N,EAAKoI,EAAG7O,GAAKA,EAAG6O,IAExC3L,GAASoU,GACbA,EAAEvS,KAAM/E,GAERC,EAAKm9B,GAAM,CAAEp9B,GAGf,OAAOC,CACR,IhEskCA2G,EAAAmb,GAAA,eiEnmCA,SAAsBlT,EAAGsuB,GACxB,IAAIzhB,EACA2c,EACA5uB,EACAxJ,EACAm9B,EACA9lB,EACAnO,EACAnJ,EAIJ,GADAyJ,EAAMoF,EAAErO,OACH28B,EAAO38B,SAAWiJ,EACtB,MAAM,IAAIoK,WAAY,+EAQvB,IALA6H,EAAO5D,GAAejJ,GACtBwpB,EAAOvgB,GAAeqlB,GAGtBl9B,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAIuS,EAAM7M,EAAG7O,GAEbsX,EAAIrX,EADJm9B,EAAI/E,EAAM8E,EAAQn9B,GAAIyB,YAEjByB,GAASoU,GACbA,EAAEvS,KAAMoE,GAERlJ,EAAKm9B,GAAM,CAAEj0B,GAGf,OAAOlJ,CACR,IjE6kCA2G,EAAAmb,GAAA,iBkE1mCA,SAAwBlT,EAAGwuB,EAAWlpB,GACrC,IAAI1N,EACAgD,EACAxJ,EACAm9B,EACA9lB,EACAnO,EACAnJ,EAUJ,IAPAyJ,EAAMoF,EAAErO,OAGRiG,EAAMqR,GAAejJ,GAGrB5O,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI1C,EAAKoI,EAAG7O,GAEZsX,EAAIrX,EADJm9B,EAAIC,EAAUv7B,KAAMqS,EAAShL,EAAGnJ,EAAG6O,IAE9B3L,GAASoU,GACbA,EAAEvS,KAAMoE,GAERlJ,EAAKm9B,GAAM,CAAEj0B,GAGf,OAAOlJ,CACR,IlEwlCA2G,EAAAmb,GAAA,oBmEhnCA,SAA2BlT,EAAGuQ,GAC7B,IAAI3Y,EACAxG,EACAqX,EACAnO,EACAnJ,EACA6d,EAOJ,IAJApX,EAAMqR,GAAejJ,GAGrB5O,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAG1BsX,EAAIrX,EADJ4d,GADA1U,EAAI1C,EAAKoI,EAAG7O,IACLof,IAEFlc,GAASoU,GACbA,EAAEvS,KAAMoE,GAERlJ,EAAK4d,GAAM,CAAE1U,GAGf,OAAOlJ,CACR,InEkmCA2G,EAAAmb,GAAA,YAAAoQ,IAUAvrB,EAAAmb,GAAA,WoEljCA,SAAkBlT,EAAGmG,EAAeC,GACnC,OAzFD,SAAoB/O,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CAuFMC,CAAWxmB,EAAG,WACXA,EAAE5K,QAAS+Q,EAAeC,IAE7BA,EAAY,IAChBA,GAAapG,EAAErO,QACE,IAChByU,EAAY,GAGT/N,GAAiB2H,GApDvB,SAAoBA,EAAGmG,EAAeC,GACrC,IAAIxO,EACAzG,EAGJ,IADAyG,EAAMqR,GAAejJ,GACf7O,EAAIiV,EAAWjV,EAAI6O,EAAErO,OAAQR,IAClC,GAAKgV,IAAkBvO,EAAKoI,EAAG7O,GAC9B,OAAOA,EAGT,OAAQ,CACT,CA0CSiX,CAAWpI,EAAGmG,EAAeC,GAhFtC,SAAmBpG,EAAGmG,EAAeC,GACpC,IAAIjV,EACJ,IAAMA,EAAIiV,EAAWjV,EAAI6O,EAAErO,OAAQR,IAClC,GAAKgV,IAAkBnG,EAAG7O,GACzB,OAAOA,EAGT,OAAQ,CACT,CA0EQ6X,CAAUhJ,EAAGmG,EAAeC,GACpC,IpE8iCArO,EAAAmb,GAAA,oBqE5/BA,SAA2BlT,EAAGmG,EAAeC,GAO5C,OANKA,EAAY,IAChBA,GAAapG,EAAErO,QACE,IAChByU,EAAY,GAGT/N,GAAiB2H,GAChB+N,GAAqB/N,GA9F5B,SAAkBA,EAAGmG,EAAeC,GACnC,IAAIoW,EACA9Z,EACAC,EACAxR,EACJ,IAAM+R,GAAeiD,GACpB,OAAQ,EAKT,IAHAqW,EAAO5Y,GAAa5D,EAAG,GACvB0C,EAAKH,GAAM4D,GACXxD,EAAKH,GAAM2D,GACLhV,EAAc,EAAViV,EAAajV,EAAIqrB,EAAK7qB,OAAQR,GAAK,EAC5C,GAAK4b,GAAayP,EAAMrrB,GAAKuR,IAAQqK,GAAayP,EAAMrrB,EAAE,GAAKwR,GAC9D,OAAOxR,EAAI,EAGb,OAAQ,CACT,CA8EUurB,CAAS1c,EAAGmG,EAAeC,GAE9BuB,GAAgB3H,GA7DvB,SAAkBA,EAAGmG,EAAeC,GACnC,IAAIoW,EACAliB,EACAnJ,EACJ,IAAM8P,GAAWkF,GAChB,OAAQ,EAIT,IAFAqW,EAAOzI,GAAoB/T,EAAG,GAC9B1F,EAAI,EAAoB,EAAI,EACtBnJ,EAAIiV,EAAWjV,EAAIqrB,EAAK7qB,OAAQR,IACrC,GAAKqrB,EAAMrrB,KAAQmJ,EAClB,OAAOnJ,EAGT,OAAQ,CACT,CA+CU6rB,CAAShd,EAAGmG,EAAeC,GAjIrC,SAAoBpG,EAAGmG,EAAeC,GACrC,IAAIxO,EACAzG,EAGJ,IADAyG,EAAMqR,GAAejJ,GACf7O,EAAIiV,EAAWjV,EAAI6O,EAAErO,OAAQR,IAClC,GAAK4b,GAAa5G,EAAevO,EAAKoI,EAAG7O,IACxC,OAAOA,EAGT,OAAQ,CACT,CAwHSiX,CAAWpI,EAAGmG,EAAeC,GA9JtC,SAAkBpG,EAAGmG,EAAeC,GACnC,IAAIjV,EACJ,IAAMA,EAAIiV,EAAWjV,EAAI6O,EAAErO,OAAQR,IAClC,GAAK4b,GAAa5G,EAAenG,EAAG7O,IACnC,OAAOA,EAGT,OAAQ,CACT,CAwJQmrB,CAAStc,EAAGmG,EAAeC,EACnC,IrEq/BArO,EAAAmb,GAAA,qBsEzqCA,SAA4BrM,EAAG+D,GAC9B,IAAIuG,EACA/f,EACAD,EAGJ,IADAggB,EAAO,CAAA,EACDhgB,EAAI,EAAGA,EAAIyZ,EAAQjZ,OAAQR,IAChCggB,EAAMvG,EAASzZ,KAAQ,EAGxB,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI0V,EAAG1V,SACA,IAAdggB,EAAMhgB,IACVC,EAAI8E,KAAM/E,GAGZ,OAAOC,CACR,ItEmqCA2G,EAAAmb,GAAA,QuElkCA,SAAelT,EAAGqG,GACjB,IAAIhP,EACJ,OAxGD,SAAoBA,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CAsGMC,CAAWxmB,EAAG,QACXA,EAAEuG,KAAMF,IAEhBhP,EAAMwR,GAAkB7I,IACfsI,iBAvFV,SAAoBtI,EAAGqG,GACtB,IAAIyC,EACA1X,EACAwG,EACAiP,EACAvM,EACAnJ,EAOJ,IALA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEnBvB,EAAIiC,EAAKnX,OAAS,EAClBP,EAAM,GACAD,EAAI,EAAGA,GAAK0V,EAAG1V,IAEdqyB,GADNlpB,EAAI1C,EAAKkR,EAAM3X,MAEdC,GAAOW,OAAQuI,IAEXnJ,EAAI0V,IACRzV,GAAOiV,GAGT,OAAOjV,CACR,CAiESgX,CAAW/Q,EAAKgP,GAjDzB,SAAkBrG,EAAGqG,GACpB,IAAIjV,EACAyV,EACAvM,EACAnJ,EAIJ,IAFA0V,EAAI7G,EAAErO,OAAS,EACfP,EAAM,GACAD,EAAI,EAAGA,GAAK0V,EAAG1V,IAEdqyB,GADNlpB,EAAI0F,EAAG7O,MAENC,GAAOW,OAAQuI,IAEXnJ,EAAI0V,IACRzV,GAAOiV,GAGT,OAAOjV,CACR,CAiCQkrB,CAAStc,EAAGqG,EACpB,IvEkkCAtO,EAAAmb,GAAA,QwEzrCA,SAAe1a,GACd,IAAIZ,EACAa,EASJ,GANAb,EAAMqR,GAAezQ,MAGrBC,EAAMD,EAAI7G,OAAS,GAGR,GAGX,OAAOiG,EAAKY,EAAKC,EAClB,IxEorCAV,EAAAmb,GAAA,eyEpmCA,SAAsBlT,EAAGmG,EAAeC,GACvC,GAzFD,SAAoB/O,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CAuFMC,CAAWxmB,EAAG,eAClB,OAAOA,EAAEyuB,YAAatoB,EAAeC,GAEtC,GAAKA,EAAY,GAEhB,IADAA,GAAapG,EAAErO,QACE,EAChB,OAAQ,OAEEyU,EAAYpG,EAAErO,SACzByU,EAAYpG,EAAErO,OAAS,GAExB,OAAK0G,GAAiB2H,GAtDvB,SAAoBA,EAAGmG,EAAeC,GACrC,IAAIxO,EACAzG,EAGJ,IADAyG,EAAMqR,GAAejJ,GACf7O,EAAIiV,EAAWjV,GAAK,EAAGA,IAC5B,GAAKgV,IAAkBvO,EAAKoI,EAAG7O,GAC9B,OAAOA,EAGT,OAAQ,CACT,CA4CSiX,CAAWpI,EAAGmG,EAAeC,GAlFtC,SAAmBpG,EAAGmG,EAAeC,GACpC,IAAIjV,EACJ,IAAMA,EAAIiV,EAAWjV,GAAK,EAAGA,IAC5B,GAAKgV,IAAkBnG,EAAG7O,GACzB,OAAOA,EAGT,OAAQ,CACT,CA4EQ6X,CAAUhJ,EAAGmG,EAAeC,EACpC,IzE8lCArO,EAAAmb,GAAA,wB0E9iCA,SAA+BlT,EAAGmG,EAAeC,GAChD,GAAKA,EAAY,GAEhB,IADAA,GAAapG,EAAErO,QACE,EAChB,OAAQ,OAEEyU,EAAYpG,EAAErO,SACzByU,EAAYpG,EAAErO,OAAS,GAExB,OAAK0G,GAAiB2H,GAChB+N,GAAqB/N,GAhG5B,SAAkBA,EAAGmG,EAAeC,GACnC,IAAIoW,EACA9Z,EACAC,EACAxR,EACJ,IAAM+R,GAAeiD,GACpB,OAAQ,EAKT,IAHAqW,EAAO5Y,GAAa5D,EAAG,GACvB0C,EAAKH,GAAM4D,GACXxD,EAAKH,GAAM2D,GACLhV,EAAc,EAAViV,EAAajV,GAAK,EAAGA,GAAK,EACnC,GAAK4b,GAAayP,EAAMrrB,GAAKuR,IAAQqK,GAAayP,EAAMrrB,EAAE,GAAKwR,GAC9D,OAAOxR,EAAI,EAGb,OAAQ,CACT,CAgFUurB,CAAS1c,EAAGmG,EAAeC,GAE9BuB,GAAgB3H,GA/DvB,SAAkBA,EAAGmG,EAAeC,GACnC,IAAIoW,EACAliB,EACAnJ,EACJ,IAAM8P,GAAWkF,GAChB,OAAQ,EAIT,IAFAqW,EAAOzI,GAAoB/T,EAAG,GAC9B1F,EAAI,EAAoB,EAAI,EACtBnJ,EAAIiV,EAAWjV,GAAK,EAAGA,IAC5B,GAAKqrB,EAAMrrB,KAAQmJ,EAClB,OAAOnJ,EAGT,OAAQ,CACT,CAiDU6rB,CAAShd,EAAGmG,EAAeC,GAnIrC,SAAoBpG,EAAGmG,EAAeC,GACrC,IAAIxO,EACAzG,EAGJ,IADAyG,EAAMqR,GAAejJ,GACf7O,EAAIiV,EAAWjV,GAAK,EAAGA,IAC5B,GAAK4b,GAAa5G,EAAevO,EAAKoI,EAAG7O,IACxC,OAAOA,EAGT,OAAQ,CACT,CA0HSiX,CAAWpI,EAAGmG,EAAeC,GAhKtC,SAAkBpG,EAAGmG,EAAeC,GACnC,IAAIjV,EACJ,IAAMA,EAAIiV,EAAWjV,GAAK,EAAGA,IAC5B,GAAK4b,GAAa5G,EAAenG,EAAG7O,IACnC,OAAOA,EAGT,OAAQ,CACT,CA0JQmrB,CAAStc,EAAGmG,EAAeC,EACnC,I1EqiCArO,EAAAmb,GAAA,Y2E1tCA,SAAmB+I,EAAIC,EAAIthB,GAC1B,IAAIpC,EACAqO,EACA2N,EACArjB,EAEJ,GAAa,IAARyJ,EACJ,MAAO,GAQR,IAJA4Z,GAAM0H,EAAGD,IADTpV,EAAIjM,EAAM,GAIVpC,EAAM,CAAEyjB,GACF9qB,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBqH,EAAItC,KAAM+lB,EAAMzH,EAAErjB,GAGnB,OADAqH,EAAItC,KAAMgmB,GACH1jB,CACR,I3EgtCAT,EAAAmb,GAAA,c4EhuCA,SAAqBrN,EAAO6X,EAAMnK,EAAOkC,GACxC,IAAIiZ,EACAC,EACAv9B,EACAoU,EACA/M,EACAm2B,EACArZ,EACAsZ,EACArZ,EACAhB,EACAtjB,EAMJ,GAAW,IADXA,GAHA09B,EAAKrb,EAAO,KACZsb,EAAKtb,EAAO,KAIX,MAAO,GAYR,IAVAiB,GAAMkJ,EAAO7X,IAAY3U,EAAI,GACxBukB,EAEJkZ,EAAO,EAAMC,GADbF,EAAOG,IAGPH,EAAO,EACPC,EAAO,GAERv9B,EAAM,GACNqH,EAAM,EACA+c,EAAK,EAAGA,EAAKqZ,EAAIrZ,IAAO,CAE7B,IADAhQ,EAAM,GACA+P,EAAK,EAAGA,EAAKqZ,EAAIrZ,IACtB/P,EAAItP,KAAM2P,EAAUpN,EAAM+b,GAC1B/b,GAAOi2B,EAERt9B,EAAI8E,KAAMsP,GACV/M,GAAOk2B,CACP,CACD,OAAOv9B,CACR,I5EksCA2G,EAAAmb,GAAA,WAAAuQ,IAUA1rB,EAAAmb,GAAA,QAAAwQ,IAUA3rB,EAAAmb,GAAA,QAAAyQ,IAUA5rB,EAAAmb,GAAA,QAAA0Q,IAUA7rB,EAAAmb,GAAA,QAAA4Q,IAUA/rB,EAAAmb,GAAA,2BAAA+Q,IAUAlsB,EAAAmb,GAAA,8B6EjyCA,SAAqCliB,GACpC,OAAKA,GAAS0N,GACN,QAEH1N,GAAS+M,GACN,SAEH/M,GAASoM,GACN,SAED,SACR,I7EgyCArF,EAAAmb,GAAA,e8ElyCA,SAAsBuW,EAAQlW,EAAOrN,GACpC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACA0G,EACA2B,EACArrB,EACA+J,EACApG,EACAkV,EAIJ,GAFArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAOtB,IAJAzT,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK/iB,EAAGwV,GACRwN,EAAKjZ,EAAGyL,GACRkU,EAAK/lB,EAAG6R,GACR6V,EAAKxS,EAAGrD,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,IAIlC,I9E0wCAxd,EAAAmb,GAAA,e+EzyCA,SAAsBuW,EAAQlW,EAAOrN,GACpC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA0G,EACA2B,EACApP,EACA1B,EACApO,EACAmf,EACAtrB,EACA+J,EACApG,EACAkV,EAKJ,GAHArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAOjC,IAJAvgB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKjc,EAAGwgB,GACRjG,EAAKxQ,EAAGyW,GACRrU,EAAKxI,EAAG6c,GACR8K,EAAKzS,EAAG2H,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,IAKnC,I/EowCAxd,EAAAmb,GAAA,egFtzCA,SAAsBuW,EAAQlW,EAAOrN,GACpC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA6F,EACAvd,EACAC,EACAif,EACAC,EACAO,EACA7rB,EACA+J,EACApG,EACAkV,EAMJ,GAJArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAO5C,IAJA3gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA1E,EAAKlc,EAAG4gB,GACRiD,EAAK9Z,EAAG6W,GACRxU,EAAKzI,EAAGid,GACRiL,EAAKhT,EAAG+H,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACT8K,EAAKO,EAAIrL,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,IAMpC,IhFowCAxd,EAAAmb,GAAA,eiF9zCA,SAAsBuW,EAAQlW,EAAOrN,GACpC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACA0F,EACAvd,EACAC,EACAud,EACA0B,EACAC,EACAO,EACAM,EACAnsB,EACA+J,EACApG,EACAkV,EAOJ,GALArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAOvD,IAJA/gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA+C,EAAK/jB,EAAGghB,GACRgD,EAAKja,EAAGiX,GACR2I,EAAKhmB,EAAGqd,GACRmL,EAAKtT,EAAGmI,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTxU,EAAKud,EAAI/I,GACTiL,EAAKM,EAAIvL,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACT8K,EAAKO,EAAIrL,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,IAOrC,IjF+vCAxd,EAAAmb,GAAA,YAAAgR,IAUAnsB,EAAAmb,GAAA,eAAAmR,IAUAtsB,EAAAmb,GAAA,ckFv2CA,SAAqBlT,EAAG+J,EAAGoa,GAC1B,IAAItX,EACAC,EACAsX,EACA0K,EACAC,EACA59B,EAUJ,IAPA0b,EAAO5D,GAAejJ,GACtB8M,EAAO7D,GAAec,GACtBqa,EAAOnb,GAAekb,GAGtB2K,EAAK,GACLC,EAAK,GACC59B,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IACrBizB,EAAMD,EAAMhzB,KAChB29B,EAAG54B,KAAM2W,EAAM7M,EAAG7O,IAClB49B,EAAG74B,KAAM4W,EAAM/C,EAAG5Y,KAGpB,MAAO,CAAE29B,EAAIC,EACd,IlF01CAh3B,EAAAmb,GAAA,cmFj3CA,WACC,IAAI8b,EACAvF,EACA3kB,EACAsf,EACAD,EACA/yB,EACAD,EACA8D,EAaJ,IAXA6P,EAAQzP,UAAU1D,OAKlByyB,EAAOnb,GADPkb,EAAO9uB,UAHPyP,GAAS,IAOTkqB,EAAU,GACVvF,EAAS,GACTr4B,EAAM,GACAD,EAAI,EAAGA,EAAI2T,EAAO3T,IACvBs4B,EAAOvzB,KAAMb,UAAWlE,IACxB69B,EAAQ94B,KAAM+S,GAAewgB,EAAQt4B,KACrCC,EAAI8E,KAAM,IAGX,IAAM/E,EAAI,EAAGA,EAAIgzB,EAAKxyB,OAAQR,IAC7B,GAAKizB,EAAMD,EAAMhzB,GAChB,IAAM8D,EAAI,EAAGA,EAAI6P,EAAO7P,IACvB7D,EAAK6D,GAAIiB,KAAM84B,EAAS/5B,GAAKw0B,EAAQx0B,GAAK9D,IAI7C,OAAOC,CACR,InFw1CA2G,EAAAmb,GAAA,SAAAoR,IAUAvsB,EAAAmb,GAAA,YAAA4R,IAUA/sB,EAAAmb,GAAA,coFp4CA,SAAqBuW,EAAQlW,EAAOrN,GACnC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACAqI,EACArrB,EACA+J,EACA8O,EAIJ,GAFArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAMtB,IAHAzT,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK/iB,EAAGwV,GACRwN,EAAKjZ,EAAGyL,GACR6V,EAAKxS,EAAGrD,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRyN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,IAIxB,IpFg3CAxd,EAAAmb,GAAA,cqF94CA,SAAqBuW,EAAQlW,EAAOrN,GACnC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACA9G,EACA+G,EACAzI,EACA8Q,EACAC,EACAtrB,EACA+J,EACA8O,EAKJ,GAHArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAMjC,IAHAvgB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKjc,EAAGwgB,GACRjG,EAAKxQ,EAAGyW,GACR8K,EAAKzS,EAAG2H,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRyN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,IAKzB,IrF+2CAxd,EAAAmb,GAAA,csFx5CA,SAAqBuW,EAAQlW,EAAOrN,GACnC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACAwH,EACAC,EACAO,EACA7rB,EACA+J,EACA8O,EAMJ,GAJArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAM5C,IAHA3gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA1E,EAAKlc,EAAG4gB,GACRiD,EAAK9Z,EAAG6W,GACRiL,EAAKhT,EAAG+H,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACT8K,EAAKO,EAAIrL,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRyN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,IAM1B,ItF82CAxd,EAAAmb,GAAA,cuFh6CA,SAAqBuW,EAAQlW,EAAOrN,GACnC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACAqH,EACAC,EACAO,EACAM,EACAnsB,EACA+J,EACA8O,EAOJ,GALArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAMvD,IAHA/gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA+C,EAAK/jB,EAAGghB,GACRgD,EAAKja,EAAGiX,GACRmL,EAAKtT,EAAGmI,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTiL,EAAKM,EAAIvL,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACT8K,EAAKO,EAAIrL,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRyN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,IAO3B,IvF22CAxd,EAAAmb,GAAA,qBwFp7CA,SAA4B+I,EAAIC,GAC/B,IAAIpX,EACAmqB,EACAz2B,EACApH,EACAoU,EACAhT,EACAiG,EACAoO,EACAkV,EACA5qB,EACA8D,EACA+Z,EAiBJ,IAfAlK,EAAQzP,UAAU1D,OAGlB6G,EAAM,CAAEyjB,EAAIC,GAMZzjB,EAAM,CAAE,EAAG,GAGXoO,GANAooB,EAAO,CAAEhT,EAAGtqB,OAAQuqB,EAAGvqB,SAMb,GAAMs9B,EAAM,GAGhB99B,EAAI,EAAGA,EAAI2T,EAAO3T,IACvBqB,EAAM6C,UAAWlE,GACjBqH,EAAItC,KAAM1D,GACVy8B,EAAK/4B,KAAM1D,EAAIb,QACf8G,EAAIvC,KAAM,GACV2Q,GAAKooB,EAAM99B,GAIZ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI0V,EAAG1V,IAAM,CAGzB,IADA6d,EAAI7d,EACE8D,EAAI6P,EAAM,EAAG7P,GAAK,EAAGA,IAE1B+Z,GADA+M,EAAI/M,EAAIigB,EAAMh6B,GAEd+Z,GAAKigB,EAAMh6B,GACXwD,EAAKxD,GAAM8mB,EAIZ,IADAvW,EAAM,GACAvQ,EAAI,EAAGA,EAAI6P,EAAO7P,IACvBuQ,EAAItP,KAAMsC,EAAKvD,GAAKwD,EAAKxD,KAE1B7D,EAAI8E,KAAMsP,EACV,CACD,OAAOpU,CACR,IxFu4CA2G,EAAAmb,GAAA,kByF77CA,SAAyB1a,EAAKs1B,GAC7B,IAAIoB,EACAC,EACAv3B,EACAxG,EACAiG,EACAmO,EACAsP,EACAjO,EACA1V,EACA8D,EAGJ,IADA6f,EAAItc,EAAI7G,QACC,EACR,MAAO,GAMR,IADAkV,GAFAsoB,EAAOlmB,GAAezQ,IAEZA,EAAK,GAAI7G,QACV,EACR,MAAO,GAMR,IAHAu9B,EAAQza,GAAMqZ,GAEd18B,EAAM,GACAD,EAAI,EAAGA,EAAI2jB,EAAG3jB,IAAM,CAIzB,IAFAyG,EAAMqR,GADNzD,EAAM2pB,EAAM32B,EAAKrH,IAEjBkG,EAAM,CAAA,EACApC,EAAI,EAAGA,EAAI4R,EAAG5R,IACnBoC,EAAK63B,EAAOj6B,IAAQ2C,EAAK4N,EAAKvQ,GAE/B7D,EAAI8E,KAAMmB,EACV,CACD,OAAOjG,CACR,IzFk6CA2G,EAAAmb,GAAA,gB0F36CA,SAAuB1a,EAAKs1B,GAC3B,IAAIqB,EACA3oB,EACApV,EACA0jB,EACAjO,EACA1V,EAGJ,IADA2jB,EAAItc,EAAI7G,QACC,EACR,MAAO,GAIR,GAFAw9B,EAAOlmB,GAAezQ,IACtBqO,EAAIsoB,EAAM32B,EAAK,GAAI7G,QACV,EACR,MAAO,GAeR,SAASq8B,EAAOx1B,EAAKrH,GACpB,IAAIyV,EAAMwB,GAAW5P,GAAM4P,UAK3B,OAJAgnB,GAAkB3sB,KAAM,OAAQjK,GAChC42B,GAAkB3sB,KAAM,OAAQmE,EAAK,IACrCwoB,GAAkB3sB,KAAM,OAAQmE,EAAK,IACrCzO,EAA0BsK,KAAM,KAAMtR,GAC/BsR,IACP,CAGD,IAtBA+D,EAAOiO,GAAMqZ,GAsBP38B,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBisB,GAAsB4Q,EAAMh8B,UAAWwU,EAAMrV,GAAKk+B,EAAUl+B,GAAKm+B,EAAUn+B,IAW5E,IAPAgH,EAA0B61B,EAAMh8B,UAAW,gBAiB3C,WACC,IAAI4U,EACAmO,GAEJA,EAAMoa,EAAM32B,EAAKiK,KAAKyrB,OACTzrB,KAAK8sB,OACjB3oB,EAAMwB,GAAW2M,GAAM3M,UACvB3F,KAAK8sB,KAAOxa,EACZtS,KAAK+sB,KAAO5oB,EAAK,GACjBnE,KAAKgtB,KAAO7oB,EAAK,GAElB,IAzBDzO,EAA0B61B,EAAMh8B,UAAW,UA6E3C,WACC,IAAIZ,EACA4d,EACA7d,EAGJ,IADAC,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAI0V,EAAG1V,IAEnBC,EADA4d,EAAIxI,EAAMrV,IACCsR,KAAMuM,GAElB,OAAO5d,CACP,IArFDA,EAAM,GACAD,EAAI,EAAGA,EAAI2jB,EAAG3jB,IACnBC,EAAI8E,KAAM,IAAI83B,EAAOmB,EAAM32B,EAAKrH,GAAKA,IAEtC,OAAOC,EA2BP,SAASi+B,EAAU52B,GAClB,OAQA,WAEC,OADAgK,KAAKitB,eACEjtB,KAAK+sB,KAAM/sB,KAAK8sB,KAAM92B,EAC7B,CACD,CASD,SAAS62B,EAAU72B,GAClB,OAQA,SAAczH,GACbyR,KAAKitB,eACLjtB,KAAKgtB,KAAMhtB,KAAK8sB,KAAM92B,EAAKzH,EAC3B,CACD,CAoBF,I1F4yCA+G,EAAAmb,GAAA,QhFp4CA,SAAelT,GACd,IAAI3I,EAAMwR,GAAkB7I,GAC5B,OAAK3I,EAAIiR,iBAEHhF,GAAmBtD,GAChBgJ,GAAU9D,GAAgBlF,EAAG,IAEhCqD,GAAkBrD,GACfgJ,GAAU/D,GAAejF,EAAG,IAG/B2H,GAAgB3H,GACbgJ,GAAU+K,GAAoB/T,EAAG,IAjD3C,SAAoBA,GACnB,IAAI8I,EACAlR,EACAzG,EAKJ,IAHA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEbjX,EAAI,EAAGA,EAAI2X,EAAKnX,OAAQR,IAC7B,GAAKyG,EAAKkR,EAAM3X,GACf,OAAO,EAGT,OAAO,CACR,CAqCSiX,CAAW/Q,GAEZ2R,GAAUhJ,EAClB,IgF63CAjI,EAAAmb,GAAA,U2Fv5CA,SAAiBlT,EAAGrF,EAAW2K,GAC9B,IAAIjO,EAAMwR,GAAkB7I,GAC5B,OAAK3I,EAAIiR,iBAvCV,SAAoBtI,EAAGrF,EAAW2K,GACjC,IAAIwD,EACAlR,EACAzG,EAKJ,IAHA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEbjX,EAAI,EAAGA,EAAI2X,EAAKnX,OAAQR,IAC7B,GAAKwJ,EAAU1H,KAAMqS,EAAS1N,EAAKkR,EAAM3X,GAAKA,EAAG2X,GAChD,OAAO,EAGT,OAAO,CACR,CA0BSV,CAAW/Q,EAAKsD,EAAW2K,GAxEpC,SAAmBtF,EAAGrF,EAAW2K,GAChC,IAAInU,EACJ,IAAMA,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1B,GAAKwJ,EAAU1H,KAAMqS,EAAStF,EAAG7O,GAAKA,EAAG6O,GACxC,OAAO,EAGT,OAAO,CACR,CAkEQgJ,CAAUhJ,EAAGrF,EAAW2K,EAChC,I3F25CAvN,EAAAmb,GAAA,e4Fj6CA,SAAsBlT,EAAGrF,EAAW2K,GACnC,IAAIjO,EAAMwR,GAAkB7I,GAC5B,OAAK3I,EAAIiR,iBAvCV,SAAoBtI,EAAGrF,EAAW2K,GACjC,IAAIwD,EACAlR,EACAzG,EAKJ,IAHA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEbjX,EAAI2X,EAAKnX,OAAO,EAAGR,GAAK,EAAGA,IAChC,GAAKwJ,EAAU1H,KAAMqS,EAAS1N,EAAKkR,EAAM3X,GAAKA,EAAG2X,GAChD,OAAO,EAGT,OAAO,CACR,CA0BSV,CAAW/Q,EAAKsD,EAAW2K,GAxEpC,SAAmBtF,EAAGrF,EAAW2K,GAChC,IAAInU,EACJ,IAAMA,EAAI6O,EAAErO,OAAO,EAAGR,GAAK,EAAGA,IAC7B,GAAKwJ,EAAU1H,KAAMqS,EAAStF,EAAG7O,GAAKA,EAAG6O,GACxC,OAAO,EAGT,OAAO,CACR,CAkEQgJ,CAAUhJ,EAAGrF,EAAW2K,EAChC,I5Fq6CAvN,EAAAmb,GAAA,S6Fz/CA,SAAgBtY,GACf,OAAOyY,GAAQ,KAAMzY,EACtB,I7FigDA7C,EAAAmb,GAAA,QAAA8R,IAUAjtB,EAAAmb,GAAA,Q8F7gDA,SAAetY,GACd,OAAOyY,GAAQ,EAAKzY,EACrB,I9FqhDA7C,EAAAmb,GAAA,U+FvhDA,SAAiBK,GAChB,OAAOD,GAAU,EAAKC,EACvB,I/F+hDAxb,EAAAmb,GAAA,UgGjiDA,SAAiBK,GAChB,OAAO8M,GAAU,EAAK9M,EACvB,IhGyiDAxb,EAAAmb,GAAA,UiG3iDA,SAAiBK,GAChB,OAAOkN,GAAU,EAAKlN,EACvB,IjGmjDAxb,EAAAmb,GAAA,UkGrjDA,SAAiBK,GAChB,OAAOsN,GAAU,EAAKtN,EACvB,IlG6jDAxb,EAAAmb,GAAA,UmG3jDA,SAAiBK,GAChB,OAAO0N,GAAU,EAAK1N,EACvB,InGmkDAxb,EAAAmb,GAAA,QAAA+R,IAUAltB,EAAAmb,GAAA,MAAA8S,IAUAjuB,EAAAmb,GAAA,gBoG9kDA,SAAuBuW,EAAQlW,EAAOrN,GACrC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACA0G,EACA+B,EACAwB,EACAjtB,EACA+J,EACApG,EACAmL,EACAxU,EAIJ,GAFAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAQtB,IALAzT,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZnvB,EAAImvB,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAMtB,IALAuN,EAAK/iB,EAAGwV,GACRwN,EAAKjZ,EAAGyL,GACRkU,EAAK/lB,EAAG6R,GACRiW,EAAK3c,EAAG0G,GACRyX,EAAK3yB,EAAGkb,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAGrD,IpGojDAxd,EAAAmb,GAAA,gBqGxlDA,SAAuBuW,EAAQlW,EAAOrN,GACrC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA0G,EACA+B,EACAwB,EACAhR,EACA1B,EACApO,EACA4f,EACA7X,EACAlU,EACA+J,EACApG,EACAmL,EACAxU,EAKJ,GAHAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAQjC,IALAvgB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZnvB,EAAImvB,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALAvE,EAAKjc,EAAGwgB,GACRjG,EAAKxQ,EAAGyW,GACRrU,EAAKxI,EAAG6c,GACRuL,EAAKjd,EAAG0R,GACRtM,EAAK5Z,EAAGkmB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAMtB,IALAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAItD,IrG+iDAxd,EAAAmb,GAAA,gBsGlmDA,SAAuBuW,EAAQlW,EAAOrN,GACrC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACAC,EACA0G,EACA+B,EACAwB,EACAhR,EACA1B,EACApO,EACA4f,EACA7X,EACAgI,EACA2H,EACAzX,EACAigB,EACAlY,EACAnU,EACA+J,EACApG,EACAmL,EACAxU,EAMJ,GAJAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAQ5C,IALA3gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZnvB,EAAImvB,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALA1E,EAAKlc,EAAG4gB,GACRiD,EAAK9Z,EAAG6W,GACRxU,EAAKzI,EAAGid,GACRyL,EAAKvd,EAAG8R,GACRzM,EAAK7Z,EAAGsmB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACTtM,EAAKC,EAAIqM,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAMtB,IALAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAKvD,ItG0iDAxd,EAAAmb,GAAA,gBuG5mDA,SAAuBuW,EAAQlW,EAAOrN,GACrC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACAC,EACA0G,EACA+B,EACAwB,EACAhR,EACA1B,EACApO,EACA4f,EACA7X,EACAgI,EACA2H,EACAzX,EACAigB,EACAlY,EACA4P,EACAC,EACA2F,EACAgD,EACAgD,EACA3vB,EACA+J,EACApG,EACAmL,EACAxU,EAOJ,GALAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAQvD,IALA/gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZnvB,EAAImvB,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALA+C,EAAK/jB,EAAGghB,GACRgD,EAAKja,EAAGiX,GACR2I,EAAKhmB,EAAGqd,GACR2L,EAAK7d,EAAGkS,GACR2O,EAAKr1B,EAAG0mB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTxU,EAAKud,EAAI/I,GACTyL,EAAKM,EAAI/L,GACTzM,EAAKwb,EAAI/O,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACTtM,EAAKC,EAAIqM,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAMtB,IALAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAMxD,IvGqiDAxd,EAAAmb,GAAA,awGrnDA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACA0G,EACA+B,EACAC,EACAuB,EACAjtB,EACA+J,EACApG,EACAmL,EACAiM,EACAzgB,EAIJ,GAFAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAStB,IANAzT,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZ1O,EAAI0O,EAAQ,GACZnvB,EAAImvB,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAOtB,IANAuN,EAAK/iB,EAAGwV,GACRwN,EAAKjZ,EAAGyL,GACRkU,EAAK/lB,EAAG6R,GACRiW,EAAK3c,EAAG0G,GACRkW,EAAK3Q,EAAGvF,GACRyX,EAAK3yB,EAAGkb,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAAMmW,EAAInW,GAG/D,IxGulDAxd,EAAAmb,GAAA,ayG/nDA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA0G,EACA+B,EACAC,EACAuB,EACAhR,EACA1B,EACApO,EACA4f,EACAC,EACA9X,EACAlU,EACA+J,EACApG,EACAmL,EACAiM,EACAzgB,EAKJ,GAHAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GASjC,IANAvgB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZ1O,EAAI0O,EAAQ,GACZnvB,EAAImvB,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANAvE,EAAKjc,EAAGwgB,GACRjG,EAAKxQ,EAAGyW,GACRrU,EAAKxI,EAAG6c,GACRuL,EAAKjd,EAAG0R,GACRwL,EAAKjR,EAAGyF,GACRtM,EAAK5Z,EAAGkmB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAOtB,IANAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTkW,EAAKM,EAAIxW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAAMmW,EAAInW,GAIhE,IzGglDAxd,EAAAmb,GAAA,a0GzoDA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACAC,EACA0G,EACA+B,EACAC,EACAuB,EACAhR,EACA1B,EACApO,EACA4f,EACAC,EACA9X,EACAgI,EACA2H,EACAzX,EACAigB,EACAC,EACAnY,EACAnU,EACA+J,EACApG,EACAmL,EACAiM,EACAzgB,EAMJ,GAJAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAS5C,IANA3gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZ1O,EAAI0O,EAAQ,GACZnvB,EAAImvB,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANA1E,EAAKlc,EAAG4gB,GACRiD,EAAK9Z,EAAG6W,GACRxU,EAAKzI,EAAGid,GACRyL,EAAKvd,EAAG8R,GACR0L,EAAKvR,EAAG6F,GACRzM,EAAK7Z,EAAGsmB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACTwL,EAAKM,EAAI9L,GACTtM,EAAKC,EAAIqM,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAOtB,IANAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTkW,EAAKM,EAAIxW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAAMmW,EAAInW,GAKjE,I1GykDAxd,EAAAmb,GAAA,a2GnpDA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACAC,EACA0G,EACA+B,EACAC,EACAuB,EACAhR,EACA1B,EACApO,EACA4f,EACAC,EACA9X,EACAgI,EACA2H,EACAzX,EACAigB,EACAC,EACAnY,EACA4P,EACAC,EACA2F,EACAgD,EACAC,EACA+C,EACA3vB,EACA+J,EACApG,EACAmL,EACAiM,EACAzgB,EAOJ,GALAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GASvD,IANA/gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZ1O,EAAI0O,EAAQ,GACZnvB,EAAImvB,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANA+C,EAAK/jB,EAAGghB,GACRgD,EAAKja,EAAGiX,GACR2I,EAAKhmB,EAAGqd,GACR2L,EAAK7d,EAAGkS,GACR4L,EAAK7R,EAAGiG,GACR2O,EAAKr1B,EAAG0mB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTxU,EAAKud,EAAI/I,GACTyL,EAAKM,EAAI/L,GACT0L,EAAKM,EAAIhM,GACTzM,EAAKwb,EAAI/O,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACTwL,EAAKM,EAAI9L,GACTtM,EAAKC,EAAIqM,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAOtB,IANAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTkW,EAAKM,EAAIxW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAAMmW,EAAInW,GAMlE,I3GkkDAxd,EAAAmb,GAAA,U4GtlDA,SAAiBlT,EAAGrF,EAAW2K,GAC9B,IAAIjO,EAAMwR,GAAkB7I,GAC5B,OAAK3I,EAAIiR,iBA3CV,SAAoBtI,EAAGrF,EAAW2K,GACjC,IAAIwD,EACAlR,EACAxG,EACAkJ,EACAnJ,EAMJ,IAJA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEnBhX,EAAM,GACAD,EAAI,EAAGA,EAAI2X,EAAKnX,OAAQR,IAC7BmJ,EAAI1C,EAAKkR,EAAM3X,GACTwJ,EAAU1H,KAAMqS,EAAShL,EAAGnJ,EAAG2X,IACpC1X,EAAI8E,KAAMoE,GAGZ,OAAOlJ,CACR,CA0BSgX,CAAW/Q,EAAKsD,EAAW2K,GAjFpC,SAAmBtF,EAAGrF,EAAW2K,GAChC,IAAIlU,EACAkJ,EACAnJ,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1BmJ,EAAI0F,EAAG7O,GACDwJ,EAAU1H,KAAMqS,EAAShL,EAAGnJ,EAAG6O,IACpC5O,EAAI8E,KAAMoE,GAGZ,OAAOlJ,CACR,CAsEQ4X,CAAUhJ,EAAGrF,EAAW2K,EAChC,I5G0lDAvN,EAAAmb,GAAA,S6GhqDA,SAAgB1a,EAAK9D,GACpB,IAAIk7B,EACAC,EACAj4B,EACAxG,EACAiG,EACAmO,EACAsP,EACAjO,EACA1V,EACA8D,EAGJ,IADA6f,EAAItc,EAAI7G,QACC,EACR,MAAO,GAQR,IAJAkV,GADA+oB,EAAQ1e,GAAYxc,IACV/C,OAGVk+B,EAAQ,GACF1+B,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB0+B,EAAM35B,KAAMxB,EAASk7B,EAAOz+B,KAK7B,IAFAyG,EAAMqR,GAAezQ,GACrBpH,EAAM,GACAD,EAAI,EAAGA,EAAI2jB,EAAG3jB,IAAM,CAGzB,IAFAqU,EAAM5N,EAAKY,EAAKrH,GAChBkG,EAAM,CAAA,EACApC,EAAI,EAAGA,EAAI4R,EAAG5R,IACnBoC,EAAKw4B,EAAO56B,IAAQuQ,EAAKoqB,EAAO36B,IAEjC7D,EAAI8E,KAAMmB,EACV,CACD,OAAOjG,CACR,I7GqoDA2G,EAAAmb,GAAA,c8GjpDA,SAAqB1a,EAAK9D,GACzB,IAAI0E,EACAw2B,EACAC,EACAz+B,EACA0jB,EACAjO,EACA1V,EAGJ,IADA2jB,EAAItc,EAAI7G,QACC,EACR,MAAO,GAQR,IALAi+B,EAAQ1e,GAAYxc,GACpBmS,EAAI+oB,EAAMj+B,OAGVk+B,EAAQ,GACF1+B,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB0+B,EAAM35B,KAAMxB,EAASk7B,EAAOz+B,KAc7B,SAAS68B,EAAO78B,GAEf,OADAgH,EAA0BsK,KAAM,KAAMtR,GAC/BsR,IACP,CAGD,IAjBArJ,EAAS6P,GAAezQ,GAiBlBrH,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBisB,GAAsB4Q,EAAMh8B,UAAW69B,EAAO1+B,GAAKk+B,EAAUO,EAAOz+B,IAAOm+B,EAAUM,EAAOz+B,KAQ7F,IAJAgH,EAA0B61B,EAAMh8B,UAAW,UAyD3C,WACC,IAAIZ,EACA4d,EACA7d,EAGJ,IADAC,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAI0V,EAAG1V,IAEnBC,EADA4d,EAAI6gB,EAAO1+B,IACAsR,KAAMuM,GAElB,OAAO5d,CACP,IAjEDA,EAAM,GACAD,EAAI,EAAGA,EAAI2jB,EAAG3jB,IACnBC,EAAI8E,KAAM,IAAI83B,EAAO78B,IAEtB,OAAOC,EASP,SAASi+B,EAAU9e,GAClB,OAQA,WACC,OAAOnX,EAAQZ,EAAKiK,KAAKyrB,IAAM3d,EAC/B,CACD,CASD,SAAS+e,EAAU/e,GAClB,OAQA,SAAcvf,GACboI,EAAQZ,EAAKiK,KAAKyrB,IAAM3d,GAAQvf,CAChC,CACD,CAoBF,I9GyiDA+G,EAAAmb,GAAA,Y+G1sDA,SAAmBlT,EAAGyH,GACrB,IAAI7M,EACAzJ,EACA8D,EAGJ,GADA2F,EAAMoF,EAAErO,OACH8V,EAAQ,GAEZ,IADAA,GAAS7M,GACI,EACZ,OAAOoF,OAEF,GAAKyH,GAAS7M,EACpB,OAAOoF,EAGR,IADA/K,EAAIwS,EACEtW,EAAIsW,EAAM,EAAGtW,EAAIyJ,EAAKzJ,IAC3B6O,EAAG/K,GAAM+K,EAAG7O,GACZ8D,GAAK,EAGN,OADA+K,EAAErO,OAASsD,EACJ+K,CACR,I/G+rDAjI,EAAAmb,GAAA,W7BrqDA,SAAkBlT,EAAG8vB,EAAWC,EAASta,GAExC,OAAOrB,GADC4N,GAAShiB,EAAG8vB,EAAWra,GACZsa,EAAQp+B,OAAQo+B,EAAS,EAAG,EAChD,I6B4qDAh4B,EAAAmb,GAAA,gBAAAjK,IAUAlR,EAAAmb,GAAA,gBAAA0T,IAUA7uB,EAAAmb,GAAA,WgH9nDA,SAAkBlT,GACjB,IAAI3I,EACJ,OAhHD,SAAoBA,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CA8GMC,CAAWxmB,EAAG,WACXA,EAAEgwB,WAEV34B,EAAMwR,GAAkB7I,IACfsI,iBA5DV,SAAoBtI,GACnB,IAAI8I,EACAlR,EACAC,EACA2N,EACAqB,EACAiO,EACA3jB,EACA8D,EAQJ,IANA6T,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GACnBvQ,EAAMmI,EAAEoI,UAAW,GAEnBvB,EAAI/G,GAAOgJ,EAAKnX,OAAO,GACvBmjB,EAAIhM,EAAKnX,OAAS,EACZR,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB8D,EAAI6f,EAAI3jB,EACRqU,EAAM5N,EAAKkR,EAAM3X,GACjB0G,EAAKiR,EAAM3X,EAAGyG,EAAKkR,EAAM7T,IACzB4C,EAAKiR,EAAM7T,EAAGuQ,GAEf,OAAOsD,CACR,CAsCSV,CAAW/Q,GApGpB,SAAmB2I,GAClB,IAAIwF,EACAqB,EACAiO,EACA3jB,EACA8D,EAIJ,IAFA4R,EAAI/G,GAAOE,EAAErO,OAAO,GACpBmjB,EAAI9U,EAAErO,OAAS,EACTR,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB8D,EAAI6f,EAAI3jB,EACRqU,EAAMxF,EAAG7O,GACT6O,EAAG7O,GAAM6O,EAAG/K,GACZ+K,EAAG/K,GAAMuQ,EAEV,OAAOxF,CACR,CAsFQgJ,CAAUhJ,EAClB,IhH8nDAjI,EAAAmb,GAAA,iBiH7uDA,SAAwBmC,EAAMza,EAAKgQ,EAASpD,EAAQka,GACnD,OAAOsE,GAAK3S,GAAQgC,EAAMza,GAAOgQ,EAASpD,EAAQka,EACnD,IjHqvDA3pB,EAAAmb,GAAA,akHxvDA,SAAoBtY,EAAKgQ,EAASpD,EAAQka,GACzC,OAAOsE,GAAK/0B,GAAO2J,GAAOgQ,EAASpD,EAAQka,EAC5C,IlHgwDA3pB,EAAAmb,GAAA,SAAA3Z,GAUAxB,EAAAmb,GAAA,QAAAld,IAUA+B,EAAAmb,GAAA,mBmHtxDA,SAA0BlT,EAAGuT,EAAOyB,EAASnR,GAC5C,IAAIjM,EACAxG,EACAoU,EACAqkB,EACAC,EACAtW,EACAC,EACA8B,EACAC,EACAwJ,EAWJ,IATApnB,EAAMqR,GAAejJ,GAErByT,EAAKF,EAAO,GACZC,EAAKD,EAAO,GAEZuW,EAAM9U,EAAS,GACf6U,EAAM7U,EAAS,GAEf5jB,EAAM,GACAokB,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAhQ,EAAM,GACNwZ,EAAKnb,EAAWimB,EAAItU,EACdD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB/P,EAAItP,KAAM0B,EAAKoI,EAAGgf,IAClBA,GAAM6K,EAEPz4B,EAAI8E,KAAMsP,EACV,CACD,OAAOpU,CACR,InHiwDA2G,EAAAmb,GAAA,mBoHhyDA,SAA0BlT,EAAGuT,EAAOyB,EAASnR,GAC5C,IAAIjM,EACAxG,EACAy4B,EACAC,EACAO,EACA4F,EACAC,EACA1c,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACA3F,EACAC,EAaJ,IAXAljB,EAAMqR,GAAejJ,GAErBugB,EAAKhN,EAAO,GACZE,EAAKF,EAAO,GACZC,EAAKD,EAAO,GAEZ8W,EAAMrV,EAAS,GACf8U,EAAM9U,EAAS,GACf6U,EAAM7U,EAAS,GAEf5jB,EAAM,GACAovB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA3F,EAAK,GACLoV,EAAMpsB,EAAWwmB,EAAI7J,EACfhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAsF,EAAK,GACLoV,EAAMD,EAAQnG,EAAItU,EACZD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBuF,EAAG5kB,KAAM0B,EAAKoI,EAAGkwB,IACjBA,GAAOrG,EAERhP,EAAG3kB,KAAM4kB,EACT,CACD1pB,EAAI8E,KAAM2kB,EACV,CACD,OAAOzpB,CACR,IpH+vDA2G,EAAAmb,GAAA,mBqH1yDA,SAA0BlT,EAAGuT,EAAOyB,EAASnR,GAC5C,IAAIjM,EACAxG,EACAy4B,EACAC,EACAO,EACAI,EACA0F,EACAF,EACAC,EACA1c,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAwP,EACAvV,EACAC,EAeJ,IAbAljB,EAAMqR,GAAejJ,GAErB2gB,EAAKpN,EAAO,GACZgN,EAAKhN,EAAO,GACZE,EAAKF,EAAO,GACZC,EAAKD,EAAO,GAEZkX,EAAMzV,EAAS,GACfqV,EAAMrV,EAAS,GACf8U,EAAM9U,EAAS,GACf6U,EAAM7U,EAAS,GAEf5jB,EAAM,GACAwvB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAwP,EAAK,GACLD,EAAMtsB,EAAW4mB,EAAI7J,EACfJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA3F,EAAK,GACLoV,EAAME,EAAQ9F,EAAI7J,EACZhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAsF,EAAK,GACLoV,EAAMD,EAAQnG,EAAItU,EACZD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBuF,EAAG5kB,KAAM0B,EAAKoI,EAAGkwB,IACjBA,GAAOrG,EAERhP,EAAG3kB,KAAM4kB,EACT,CACDsV,EAAGl6B,KAAM2kB,EACT,CACDzpB,EAAI8E,KAAMk6B,EACV,CACD,OAAOh/B,CACR,IrH6vDA2G,EAAAmb,GAAA,mBsHpzDA,SAA0BlT,EAAGuT,EAAOyB,EAASnR,GAC5C,IAAIjM,EACAxG,EACAy4B,EACAC,EACAO,EACAI,EACAI,EACAwF,EACAF,EACAF,EACAC,EACA1c,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACAsP,EACAF,EACAvV,EACAC,EAiBJ,IAfAljB,EAAMqR,GAAejJ,GAErB+gB,EAAKxN,EAAO,GACZoN,EAAKpN,EAAO,GACZgN,EAAKhN,EAAO,GACZE,EAAKF,EAAO,GACZC,EAAKD,EAAO,GAEZsX,EAAM7V,EAAS,GACfyV,EAAMzV,EAAS,GACfqV,EAAMrV,EAAS,GACf8U,EAAM9U,EAAS,GACf6U,EAAM7U,EAAS,GAEf5jB,EAAM,GACA4vB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAsP,EAAK,GACLD,EAAMxsB,EAAWgnB,EAAI7J,EACfJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAwP,EAAK,GACLD,EAAME,EAAQ5F,EAAI7J,EACZJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA3F,EAAK,GACLoV,EAAME,EAAQ9F,EAAI7J,EACZhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAsF,EAAK,GACLoV,EAAMD,EAAQnG,EAAItU,EACZD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBuF,EAAG5kB,KAAM0B,EAAKoI,EAAGkwB,IACjBA,GAAOrG,EAERhP,EAAG3kB,KAAM4kB,EACT,CACDsV,EAAGl6B,KAAM2kB,EACT,CACDyV,EAAGp6B,KAAMk6B,EACT,CACDh/B,EAAI8E,KAAMo6B,EACV,CACD,OAAOl/B,CACR,ItH2vDA2G,EAAAmb,GAAA,YAAAqd,IAUAx4B,EAAAmb,GAAA,kBAAAsd,IAUAz4B,EAAAmb,GAAA,OAAA2T,IAUA9uB,EAAAmb,GAAA,euH52DA,SAAelT,EAAG4K,GACjB,IAAIxZ,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAIyZ,EAAQjZ,OAAQR,IAChCC,EAAI8E,KAAM8J,EAAG4K,EAASzZ,KAEvB,OAAOC,CACR,IvH62DA2G,EAAAmb,GAAA,gBwHp3DA,SAAgBlT,EAAG+J,EAAGa,GACrB,IAAIkkB,EACAC,EACA59B,EAIJ,IAFA29B,EAAK,GACLC,EAAK,GACC59B,EAAI,EAAGA,EAAIyZ,EAAQjZ,OAAQR,IAChC29B,EAAG54B,KAAM8J,EAAG4K,EAASzZ,KACrB49B,EAAG74B,KAAM6T,EAAGa,EAASzZ,KAEtB,MAAO,CAAE29B,EAAIC,EACd,IxHk3DAh3B,EAAAmb,GAAA,SAAA+T,IAUAlvB,EAAAmb,GAAA,UyHr3DA,SAAiBlT,EAAG4K,EAASsc,EAAWxF,GACvC,IAAIzrB,EACA7E,EACAkjB,EACAqN,EACAlpB,EACAtH,EAGJ,IAAc,KADdmjB,EAAM+Q,GAAgB6B,EAAWF,IAEhC,MAAM,IAAIhiB,WAAY7O,EAAQ,4GArCpB,EAqCwI+wB,IAGnJ,GADA91B,EAAM,GACO,IAARkjB,EAAY,CAGhB,IAFAqN,EAAMwF,GAAezF,GACrBzrB,EAAY+J,EAAErO,OAAS,EACjBR,EAAI,EAAGA,EAAIyZ,EAAQjZ,OAAQR,IAChCsH,EAAMkpB,EAAK/W,EAASzZ,GAAK8E,GACzB7E,EAAI8E,KAAM8J,EAAGvH,IAEd,OAAOrH,CACP,CAGD,IADAkjB,EAAM4S,EAAY,EACZ/1B,EAAI,EAAGA,EAAI6O,EAAErO,OAAQR,IAC1BC,EAAI8E,KAAM+wB,GAAQjnB,EAAG7O,GAAKyZ,EAAS0J,EAAKoN,IAEzC,OAAOtwB,CACR,IzHm2DA2G,EAAAmb,GAAA,a0Hr4DA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACA0G,EACA+B,EACAzrB,EACA+J,EACApG,EACAmL,EAIJ,GAFA0E,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAOtB,IAJAzT,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK/iB,EAAGwV,GACRwN,EAAKjZ,EAAGyL,GACRkU,EAAK/lB,EAAG6R,GACRiW,EAAK3c,EAAG0G,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAG3C,I1H+2DAxd,EAAAmb,GAAA,a2H/4DA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA0G,EACA+B,EACAxP,EACA1B,EACApO,EACA4f,EACA/rB,EACA+J,EACApG,EACAmL,EAKJ,GAHA0E,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAOjC,IAJAvgB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKjc,EAAGwgB,GACRjG,EAAKxQ,EAAGyW,GACRrU,EAAKxI,EAAG6c,GACRuL,EAAKjd,EAAG0R,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAI5C,I3H42DAxd,EAAAmb,GAAA,a4Hz5DA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACAC,EACA0G,EACA+B,EACAxP,EACA1B,EACApO,EACA4f,EACA7P,EACA2H,EACAzX,EACAigB,EACArsB,EACA+J,EACApG,EACAmL,EAMJ,GAJA0E,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAO5C,IAJA3gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA1E,EAAKlc,EAAG4gB,GACRiD,EAAK9Z,EAAG6W,GACRxU,EAAKzI,EAAGid,GACRyL,EAAKvd,EAAG8R,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAK7C,I5Hy2DAxd,EAAAmb,GAAA,a6Hn6DA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACAC,EACA0G,EACA+B,EACAxP,EACA1B,EACApO,EACA4f,EACA7P,EACA2H,EACAzX,EACAigB,EACAtI,EACAC,EACA2F,EACAgD,EACA3sB,EACA+J,EACApG,EACAmL,EAOJ,GALA0E,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAO5C,IAJA3gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA+C,EAAK/jB,EAAGghB,GACRgD,EAAKja,EAAGiX,GACR2I,EAAKhmB,EAAGqd,GACR2L,EAAK7d,EAAGkS,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTxU,EAAKud,EAAI/I,GACTyL,EAAKM,EAAI/L,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAM9C,I7Hs2DAxd,EAAAmb,GAAA,mB8Hl7DA,SAA0B1a,GACzB,OAAKA,GAAsB,iBAARA,GAAoBH,EAAiBG,GAChDA,EAED,IAAIgQ,GAAehQ,EAC3B,I9Hu7DAT,EAAAmb,GAAA,a+H1zDA,SAAiBlT,EAAGwtB,EAAOC,GAC1B,OAAKA,EAnEN,SAA0BztB,EAAGwtB,GAC5B,IAAIE,EACA53B,EACA8E,EACAxJ,EACAsI,EACAY,EACAnJ,EAIJ,GAFAC,EAAM,GAEO,KADbwJ,EAAMoF,EAAErO,QAEP,OAAOP,EAKR,IAHAsI,GAAM,EACN5D,EAAO2G,IACPixB,EAAQ,EACFv8B,EAAI,EAAGA,EAAIyJ,EAAKzJ,KACrBmJ,EAAI0F,EAAG7O,MACI2E,GAAU4D,GAAOnF,GAAO+F,IAClCozB,GAAS,IACKF,GACbp8B,EAAI8E,KAAMJ,IAGXA,EAAOwE,EACPozB,EAAQ,EACRt8B,EAAI8E,KAAMJ,GACV4D,GAAM,EACDnF,GAAOuB,KACX4D,GAAM,IAIT,OAAOtI,CACR,CAiCSw8B,CAAiB5tB,EAAGwtB,GA7H7B,SAAqBxtB,EAAGwtB,GACvB,IAAIE,EACA53B,EACA8E,EACAxJ,EACAkJ,EACAnJ,EAIJ,GAFAC,EAAM,GAEO,KADbwJ,EAAMoF,EAAErO,QAEP,OAAOP,EAIR,IAFA0E,EAAO2G,IACPixB,EAAQ,EACFv8B,EAAI,EAAGA,EAAIyJ,EAAKzJ,KACrBmJ,EAAI0F,EAAG7O,MACI2E,GACV43B,GAAS,IACKF,GACbp8B,EAAI8E,KAAMJ,IAGXA,EAAOwE,EACPozB,EAAQ,EACRt8B,EAAI8E,KAAMJ,IAGZ,OAAO1E,CACR,CAkGQq/B,CAAYzwB,EAAGwtB,EACvB,I/H+zDAz1B,EAAAmb,GAAA,cgI53DA,SAAqBlT,GACpB,IAAI3I,EACJ,OAnFD,SAAoBA,EAAKkvB,GACxB,MAAkC,mBAAlBlvB,EAAKkvB,EACtB,CAiFMC,CAAWxmB,EAAG,cACXA,EAAE0wB,cAEVr5B,EAAMwR,GAAkB7I,IACfsI,iBAxCV,SAAoBtI,GACnB,IAAI8I,EACAlR,EACAxG,EACAD,EAMJ,IAJA2X,EAAO9I,EAAE8I,KACTlR,EAAMoI,EAAEoI,UAAW,GAEnBhX,EAAM,GACAD,EAAI2X,EAAKnX,OAAO,EAAGR,GAAK,EAAGA,IAChCC,EAAI8E,KAAM0B,EAAKkR,EAAM3X,IAEtB,OAAOC,CACR,CA2BSgX,CAAW/Q,GAvEpB,SAAmB2I,GAClB,IAAI5O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI6O,EAAErO,OAAO,EAAGR,GAAK,EAAGA,IAC7BC,EAAI8E,KAAM8J,EAAG7O,IAEd,OAAOC,CACR,CAgEQ4X,CAAUhJ,EAClB,IhI43DAjI,EAAAmb,GAAA,WiI18DA,SAAkBuW,EAAQlW,EAAOrN,GAChC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACAhjB,EACA+J,EAIJ,GAFAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAKtB,IAFAzT,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK/iB,EAAGwV,GACRwN,EAAKjZ,EAAGyL,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,GAGvB,IjI47DAxd,EAAAmb,GAAA,akI98DA,SAAoBuW,EAAQlW,EAAOrN,EAAKX,GACvC,IAAID,EACAkO,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACAhjB,EACA+J,EACAzP,EAIJ,GAFAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAQtB,IALKpe,UAAU1D,OAAS,IACvB2T,EAAUjQ,UAAW,IAEtB2K,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK/iB,EAAGwV,GACRwN,EAAKjZ,EAAGyL,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,SAEX,KADXjb,EAAIiL,EAAKtS,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEC,EAAID,GAAM,CAAEvV,EAAG+J,OAElDiZ,EAAIzN,GAAOrP,EAAK5L,GAIpB,IlIw7DAvC,EAAAmb,GAAA,WmI99DA,SAAkBuW,EAAQlW,EAAOrN,GAChC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACA9G,EACA+G,EACAzI,EACAva,EACA+J,EAKJ,GAHAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAKjC,IAFAvgB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKjc,EAAGwgB,GACRjG,EAAKxQ,EAAGyW,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,GAIxB,InIu8DAxd,EAAAmb,GAAA,aoIl+DA,SAAoBuW,EAAQlW,EAAOrN,EAAKX,GACvC,IAAID,EACAkO,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACA9G,EACA+G,EACAzI,EACAva,EACA+J,EACAzP,EAKJ,GAHAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAQjC,IALKlrB,UAAU1D,OAAS,IACvB2T,EAAUjQ,UAAW,IAEtB2K,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKjc,EAAGwgB,GACRjG,EAAKxQ,EAAGyW,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,SAEX,KADXjb,EAAIiL,EAAKtS,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEiL,EAAIhL,EAAID,GAAM,CAAEvV,EAAG+J,OAEtDiZ,EAAIzN,GAAOrP,EAAK5L,GAKrB,IpIm8DAvC,EAAAmb,GAAA,WqIl/DA,SAAkBuW,EAAQlW,EAAOrN,GAChC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA7jB,EACA+J,EAMJ,GAJAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAK5C,IAFA3gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAKlc,EAAG4gB,GACRiD,EAAK9Z,EAAG6W,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,GAKzB,IrIk9DAxd,EAAAmb,GAAA,asIt/DA,SAAoBuW,EAAQlW,EAAOrN,EAAKX,GACvC,IAAID,EACAkO,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA7jB,EACA+J,EACAzP,EAMJ,GAJAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAQ5C,IALKtrB,UAAU1D,OAAS,IACvB2T,EAAUjQ,UAAW,IAEtB2K,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAKlc,EAAG4gB,GACRiD,EAAK9Z,EAAG6W,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,SAEX,KADXjb,EAAIiL,EAAKtS,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAM,CAAEvV,EAAG+J,OAE1DiZ,EAAIzN,GAAOrP,EAAK5L,GAMtB,ItI88DAvC,EAAAmb,GAAA,WuItgEA,SAAkBuW,EAAQlW,EAAOrN,GAChC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACAhkB,EACA+J,EAOJ,GALAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAKvD,IAFA/gB,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA+C,EAAK/jB,EAAGghB,GACRgD,EAAKja,EAAGiX,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,GAM1B,IvI69DAxd,EAAAmb,GAAA,awIzgEA,SAAoBuW,EAAQlW,EAAOrN,EAAKX,GACvC,IAAID,EACAkO,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACAhkB,EACA+J,EACAzP,EAOJ,GALAkZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAQvD,IALK1rB,UAAU1D,OAAS,IACvB2T,EAAUjQ,UAAW,IAEtB2K,EAAIypB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA+C,EAAK/jB,EAAGghB,GACRgD,EAAKja,EAAGiX,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,SAEX,KADXjb,EAAIiL,EAAKtS,KAAMqS,EAASyd,EAAIxN,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAM,CAAEvV,EAAG+J,OAE9DiZ,EAAIzN,GAAOrP,EAAK5L,GAOvB,IxIw9DAvC,EAAAmb,GAAA,WlBp/DA,SAAkBuW,EAAQlW,EAAOrN,GAChC,OAAOkO,GAASqV,EAAQ,GAAKA,EAAQ,GAAKlW,EAAM5hB,OAAQ4hB,EAAO,EAAGrN,EACnE,IkB4/DAnO,EAAAmb,GAAA,ayIvjEA,SAAoB+I,EAAIC,GACvB,IAAI1jB,EACAoC,EACAzJ,EAGJ,IADAyJ,EAAMshB,EAAKD,IACC,EACX,MAAO,CAAEA,GAGV,IADAzjB,EAAM,CAAEyjB,GACF9qB,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBqH,EAAItC,KAAM+lB,EAAK9qB,GAEhB,OAAOqH,CACR,IzImjEAT,EAAAmb,GAAA,QAAAoU,IAUAvvB,EAAAmb,GAAA,YAAA+U,IAUAlwB,EAAAmb,GAAA,UAAAgW,IAUAnxB,EAAAmb,GAAA,SAAAyJ,IAUA5kB,EAAAmb,GAAA,QAAAjiB,IAUA8G,EAAAmb,GAAA,UAAAQ,IAUA3b,EAAAmb,GAAA,W0IznEA,SAAkBK,GACjB,OAAO8M,GAAU,EAAK9M,EACvB,I1IioEAxb,EAAAmb,GAAA,W2InoEA,SAAkBK,GACjB,OAAOkN,GAAU,EAAKlN,EACvB,I3I2oEAxb,EAAAmb,GAAA,W4I7oEA,SAAkBK,GACjB,OAAOsN,GAAU,EAAKtN,EACvB,I5IqpEAxb,EAAAmb,GAAA,W6InpEA,SAAkBK,GACjB,OAAO0N,GAAU,EAAK1N,EACvB,I7I2pEAxb,EAAAmb,GAAA,O8IzpEA,SAAcuW,GACb,IAAIuF,EACA2B,EACAv/B,EACAoH,EACAsc,EACAjO,EACA1V,EACA8D,EAGJ,IADA6f,EAAI2U,EAAO93B,QACF,EACR,MAAO,GAIR,IADAkV,GADA8pB,EAAOlc,GAAMgV,IACH,GAAI93B,QACL,EACR,MAAO,GAGR,IADAq9B,EAAU,GACJ/5B,EAAI,EAAGA,EAAI6f,EAAG7f,IACnB+5B,EAAQ94B,KAAM+S,GAAe0nB,EAAM17B,KAGpC,IADA7D,EAAM,GACAD,EAAI,EAAGA,EAAI0V,EAAG1V,IAAM,CAEzB,IADAqH,EAAM,GACAvD,EAAI,EAAGA,EAAI6f,EAAG7f,IACnBuD,EAAItC,KAAM84B,EAAS/5B,GAAK07B,EAAM17B,GAAK9D,IAEpCC,EAAI8E,KAAMsC,EACV,CACD,OAAOpH,CACR,I9ImoEA2G,EAAAmb,GAAA,c+InmEA,SAAqB0d,EAAYppB,GAChC,IAAIsnB,EAAKjmB,GAAkB+nB,GACvB7B,EAAKlmB,GAAkBrB,GAE3B,OAAKsnB,EAAGxmB,kBAAoBymB,EAAGzmB,iBApEhC,SAAoBsoB,EAAYppB,GAC/B,IAAIqpB,EACAlM,EACAmM,EACAjM,EACAzzB,EACAD,EASJ,IAPA0/B,EAAQD,EAAW9nB,KACnBgoB,EAAOF,EAAWxoB,UAAW,GAE7Buc,EAAQnd,EAAOsB,KACf+b,EAAOrd,EAAOY,UAAW,GAEzBhX,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAI0/B,EAAMl/B,OAAQR,IAC9BC,EAAK0/B,EAAMD,EAAO1/B,IAAQ0zB,EAAMF,EAAOxzB,GAExC,OAAOC,CACR,CAkDSgX,CAAW0mB,EAAIC,GAjCxB,SAAkB6B,EAAYppB,GAC7B,IAAIpW,EACAD,EAGJ,IADAC,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIy/B,EAAWj/B,OAAQR,IACnCC,EAAKw/B,EAAYz/B,IAAQqW,EAAQrW,GAElC,OAAOC,CACR,CA0BQkrB,CAASsU,EAAYppB,EAC7B,I/IqmEAzP,EAAAmb,GAAA,egJzqEA,SAAsBuW,EAAQsH,GAC7B,IAAI/B,EACA2B,EACAnqB,EACA5O,EACAxG,EACAiG,EACAyd,EACAjO,EACA1V,EACA8D,EAGJ,IADA6f,EAAI2U,EAAO93B,QACF,EACR,MAAO,GAIR,IADAkV,GADA8pB,EAAOlc,GAAMgV,IACH,GAAI93B,QACL,EACR,MAAO,GAMR,IAJAq9B,EAAU,GAEVp3B,EAAMqR,GAAe8nB,GACrBvqB,EAAO,GACDvR,EAAI,EAAGA,EAAI6f,EAAG7f,IACnB+5B,EAAQ94B,KAAM+S,GAAe0nB,EAAM17B,KACnCuR,EAAKtQ,KAAM0B,EAAKm5B,EAAQ97B,IAGzB,IADA7D,EAAM,GACAD,EAAI,EAAGA,EAAI0V,EAAG1V,IAAM,CAEzB,IADAkG,EAAM,CAAA,EACApC,EAAI,EAAGA,EAAI6f,EAAG7f,IACnBoC,EAAKmP,EAAMvR,IAAQ+5B,EAAS/5B,GAAK07B,EAAM17B,GAAK9D,GAE7CC,EAAI8E,KAAMmB,EACV,CACD,OAAOjG,CACR,IhJ6oEA2G,EAAAmb,GAAA,aiJxpEA,SAAoBuW,EAAQsH,GAC3B,IAAI33B,EACAG,EACAo3B,EACAnqB,EACApV,EACAwV,EACAkO,EACAjO,EACA1V,EAGJ,IADA2jB,EAAI2U,EAAO93B,QACF,EACR,MAAO,GAIR,IADAkV,GADA8pB,EAAOlc,GAAMgV,IACH,GAAI93B,QACL,EACR,MAAO,GAIR,IADAiV,EAAM,GACAzV,EAAI,EAAGA,EAAI2jB,EAAG3jB,IACnByV,EAAI1Q,KAAMkS,GAAWuoB,EAAMx/B,IAAMiX,WAclC,SAAS4lB,EAAO78B,GAEf,OADAgH,EAA0BsK,KAAM,KAAMtR,GAC/BsR,IACP,CAGD,IAjBA+D,EAAOiO,GAAMsc,GAiBP5/B,EAAI,EAAGA,EAAI2jB,EAAG3jB,IACnBiI,EAASi2B,EAAUsB,EAAMx/B,GAAKyV,EAAKzV,GAAK,IACxCoI,EAAS+1B,EAAUqB,EAAMx/B,GAAKyV,EAAKzV,GAAK,IACxCisB,GAAsB4Q,EAAMh8B,UAAWwU,EAAMrV,GAAKiI,EAAQG,GAO3D,IAJApB,EAA0B61B,EAAMh8B,UAAW,UA2D3C,WACC,IAAIZ,EACA4d,EACA7d,EAGJ,IADAC,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAI2jB,EAAG3jB,IAEnBC,EADA4d,EAAIxI,EAAMrV,IACCsR,KAAMuM,GAElB,OAAO5d,CACP,IAnEDA,EAAM,GACAD,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBC,EAAI8E,KAAM,IAAI83B,EAAO78B,IAEtB,OAAOC,EAUP,SAASi+B,EAAU72B,EAAKY,GACvB,OAQA,WACC,OAAOA,EAAQZ,EAAKiK,KAAKyrB,GACzB,CACD,CAUD,SAASoB,EAAU92B,EAAKe,GACvB,OAQA,SAAcvI,GACbuI,EAAQf,EAAKiK,KAAKyrB,GAAIl9B,EACtB,CACD,CAoBF,IC9KA,IAAIJ,GAAgC,mBAAhB+P,YAA+BA,YAAc,KCgBjE,SAASqwB,KACR,IAAIz0B,EACAigB,EACA3X,EAEJ,GAAkC,mBAAtBosB,GACX,OAAO,EAGR,KAEC10B,EAASqE,GADTiE,EAAM,IAAIosB,GAAmB,MACwC,mBAA7BA,GAAkBC,WAEzD1U,EAAO,IAAI9gB,GAAcmJ,IACnB,IAAO,KACb2X,EAAM,GAAM/f,IACZF,EACCA,GACA00B,GAAkBC,OAAQ1U,IACP,KAAnB3X,EAAIM,aACW,OAAfqX,EAAM,IACNA,EAAM,IAAQA,EAAM,GAGtB,CAAC,MAAQtlB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CC5CA,ICuBIjB,GDvBAA,GAAgC,mBAAhBqF,YAA+BA,iBAAc,EE6BjEwwB,GATKH,KACG55B,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJIy+B,GAAoC,mBAAbC,SCLvB/1B,GAAgC,mBAAhBqF,YAA+BA,iBAAc,EC6BjE2wB,GATKN,KACG55B,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECTI/B,GAA6B,mBAAbygC,SAA4BA,SAAW,KCAvD/1B,GAA6B,mBAAb+1B,SAA4BA,cAAW,ER2B1D/1B,GSXD,WACC,IAAIiB,EACAigB,EACA3X,ENQgB7T,EMNpB,GAA+B,mBAAnBugC,GACX,OAAO,EAGR,IACC1sB,EAAM,IAAIlE,GAAa,IACvB6b,EAAO,IAAI+U,GAAgB1sB,EAAK,GNAb7T,EMCEwrB,GAArBjgB,GNCE60B,IAAepgC,aAAiBqgC,UACT,sBAAzBj3B,GAAapJ,KMF6C,mBAApBwrB,EAAKgV,YAAwD,mBAApBhV,EAAKiV,cAEnFjV,EAAKiV,WAAY,GAAI,MACrBjV,EAAKiV,WAAY,EAAGh1B,KACpBF,EACCA,GACAigB,EAAK1Y,SAAWe,GACI,KAApB2X,EAAKrX,YACe,IAApBqX,EAAKzY,aACqB,OAA1ByY,EAAKgV,WAAY,IACjBhV,EAAKgV,WAAY,IAAQhV,EAAKgV,WAAY,GAG5C,CAAC,MAAQt6B,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CTrBKm1B,GACGt6B,GUlBR,WACC,MAAM,IAAIzE,MAAO,kBAClB,EVwBA,IAAAg/B,GAAer2B,GWiBXs2B,GAAQx+B,KAAKw+B,MCtCbC,GAAY,oBACZC,GAAW,CAAE,QAAS,OAAQ,SAelC,SAASC,GAAW/gC,EAAOqK,GAC1B,IAAI8G,EAGJ,GAAc,WADdA,SAAcnR,GACW,CAExB,IADAA,EAAQghC,KAAKt8B,MAAO1E,KACLA,EACd,MAAM,IAAI2B,MAAOwD,EAAQ,6CAA8CkF,EAAKpJ,gBAE7EjB,EAAQ,IAAIghC,KAAMhhC,EAClB,CACD,GAAc,WAATmR,EAAoB,CACxB,IAAM0vB,GAAUpyB,KAAMzO,GACrB,MAAM,IAAI2B,MAAOwD,EAAQ,mFAAoFkF,EAAKpJ,gBAElF,KAA5BjB,EAAM4B,WAAWjB,SACrBX,GAAS,KAEVA,EAAQ,IAAIghC,KAAMhhC,EAClB,CACD,KAAOA,aAAiBghC,MACvB,MAAM,IAAI98B,UAAWiB,EAAQ,gHAAiHkF,IAE/I,OAAOrK,CACR,CC7BA,SAASihC,GAAOtgC,GACf,OAAK0D,UAAU1D,OAAS,EAChBV,GAAOU,EAAQ0D,UAAW,IAE3BpE,GAAOU,EACf,CCtBA,IAAImjB,GAAI,EAqBR,SAASod,GAAOrrB,EAAGsrB,EAAOnyB,EAAG0e,EAASC,GACrC,IAAIK,EACAnG,EACApQ,EACAtX,EAEJ,GAAK0V,GAAK,EACT,OAAO7G,EAGR,IADAyI,EAAII,GAAkB7I,IACfsI,iBAEN,OCHF,SAAgBzB,EAAGsrB,EAAOnyB,EAAG0e,EAASC,GACrC,IAAIG,EACAjnB,EACAmnB,EACA7tB,EASJ,IANA2tB,EAAO9e,EAAE8I,KAGTjR,EAAMmI,EAAEoI,UAAW,GAEnB4W,EAAKL,EACCxtB,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB0G,EAAKinB,EAAME,EAAImT,GACfnT,GAAMN,CAGR,CDhBEtW,CAAWvB,EAAGsrB,EAAO1pB,EAAGiW,EAASC,GAC1BlW,EAAEK,KAKV,GAHAkW,EAAKL,EAGY,IAAZD,EAAgB,CAIpB,IAHA7F,EAAIhS,EAAIiO,IAGC,EACR,IAAM3jB,EAAI,EAAGA,EAAI0nB,EAAG1nB,IACnB6O,EAAGgf,GAAOmT,EACVnT,GAAMN,EAGR,GAAK7X,EAAIiO,GACR,OAAO9U,EAER,IAAM7O,EAAI0nB,EAAG1nB,EAAI0V,EAAG1V,GAAK2jB,GACxB9U,EAAGgf,GAAOmT,EACVnyB,EAAGgf,EAAG,GAAMmT,EACZnyB,EAAGgf,EAAG,GAAMmT,EACZnyB,EAAGgf,EAAG,GAAMmT,EACZnyB,EAAGgf,EAAG,GAAMmT,EACZnyB,EAAGgf,EAAG,GAAMmT,EACZnyB,EAAGgf,EAAG,GAAMmT,EACZnyB,EAAGgf,EAAG,GAAMmT,EACZnT,GAAMlK,GAEP,OAAO9U,CACP,CACD,IAAM7O,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB6O,EAAGgf,GAAOmT,EACVnT,GAAMN,EAEP,OAAO1e,CACR,CEtDA,SAASkyB,GAAOrrB,EAAGsrB,EAAOnyB,EAAG0e,GAC5B,OAAOU,GAASvY,EAAGsrB,EAAOnyB,EAAG0e,EAASkD,GAAe/a,EAAG6X,GACzD,CCGA,SAAS0T,GAAgBphC,GACxB,IAAIygB,SAAWzgB,EACf,OACW,OAAVA,IACQ,WAANygB,GAAwB,aAANA,IACpBrP,GAAYpR,EAAMmT,KAEpB,CCZA,SAASkuB,GAAY7uB,GACpB,IAAIkqB,EAEJ,IAAM0E,GAAgB5uB,GACrB,MAAM,IAAItO,UAAWiB,EAAQ,2DAA4DqN,IAG1F,IADAkqB,EAAQ,IACO,CAEd,GADIlqB,EAASW,OACNC,KACN,OAAOspB,EAERA,GAAS,CACT,CACF,CCNA31B,EAAAnH,GAAA,UAAAwuB,ICRA,IAAI7a,GAAsBhB,KACtBylB,GAAgBb,GAASvwB,IAAK,kBCKlC,SAAS06B,GAASzrB,EAAG7G,EAAG0e,EAASC,EAASpZ,EAAMD,GAC/C,IAAI0Z,EACAvW,EACAtX,EAEJ,GAAK0V,GAAK,EACT,OAAO7G,EAGR,IADAyI,EAAII,GAAkB7I,IACfsI,iBAEN,OCKF,SAAkBzB,EAAG7G,EAAG0e,EAASC,EAASpZ,EAAMD,GAC/C,IAAIwZ,EACAjnB,EACAD,EACAonB,EACA7tB,EAUJ,IAPA2tB,EAAO9e,EAAE8I,KAGTlR,EAAMoI,EAAEoI,UAAW,GACnBvQ,EAAMmI,EAAEoI,UAAW,GAEnB4W,EAAKL,EACCxtB,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB0G,EAAKinB,EAAME,EAAIzZ,EAAKtS,KAAMqS,EAAS1N,EAAKknB,EAAME,GAAM7tB,EAAG6tB,EAAIhf,IAC3Dgf,GAAMN,CAGR,CD1BEtW,CAAWvB,EAAG4B,EAAGiW,EAASC,EAASpZ,EAAMD,GAClCmD,EAAEK,KAGV,IADAkW,EAAKL,EACCxtB,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB6O,EAAGgf,GAAOzZ,EAAKtS,KAAMqS,EAAStF,EAAGgf,GAAM7tB,EAAG6tB,EAAIhf,GAC9Cgf,GAAMN,EAEP,OAAO1e,CACR,CEpBA,SAASsyB,GAASzrB,EAAG7G,EAAG0e,EAASnZ,EAAMD,GACtC,OAAO8Z,GAASvY,EAAG7G,EAAG0e,EAASkD,GAAe/a,EAAG6X,GAAWnZ,EAAMD,EACnE,CCSAvN,EAAAnH,GAAA,UAAAwuB,ICjBA,IAAI7a,GAAsBhB,KACtBylB,GAAgBb,GAASvwB,IAAK,kBCrB9B26B,GAAY1hC,OAAOmB,UAAUse,oPCkBjC,SAASkiB,GAAiBn5B,GACzB,OAAO+J,GAAmB/J,IAAW,IACtC,CCEA,SAASo5B,GAAYnhC,GACpB,MAAa,KAARA,EACG,GAEDA,EAAI4B,OAAQ,GAAIf,cAAgBb,EAAI0E,MAAO,EACnD,CCpBA,SAASiO,GAAcC,GACtB,IAAI9S,EACAkJ,EAGJ,IADAlJ,EAAM,KAELkJ,EAAI4J,EAAGC,QACAC,MAGPhT,EAAI8E,KAAMoE,EAAEtJ,OAEb,OAAOI,CACR,CCUA,IAAImT,GAAsBhB,KACtBmvB,GAAgB,gBAChBC,GAAa,aAEbC,GAAY,CACfr6B,QAAW,aACXG,QAAW,aACXC,MAAS,WACTC,MAAS,WACTE,OAAU,YACVC,OAAU,aAEP85B,GAAY,CACft6B,QAAW,aACXG,QAAW,aACXC,MAAS,WACTC,MAAS,WACTE,OAAU,YACVC,OAAU,aAEP+5B,GAAe,CAClBC,EAAK,IACLj/B,EAAK,IACL3C,EAAK,KACL4pB,EAAK,IACLhT,EAAK,KAEFiG,GAAa7E,GAxBJ,CAAE,UAAW,UAAW,QAAS,QAAS,SAAU,WAoCjE,SAAS6pB,GAAWhiC,GACnB,OAAS6P,GAAU7P,GAAuBA,EC3D/BiB,cD2DyC,IACrD,CASA,SAASwY,GAAgBzZ,GACxB,OAASA,IAAU0hC,EACpB,CASA,SAASO,GAAgBC,GACxB,OAAO,EAAWR,GAAgBC,EACnC,CA8FA,SAASvpB,GAAS/P,GACjB,IAAI+J,EACA+vB,EACAC,EACAC,EAEJ,IAAMrlB,GAAY3U,GACjB,MAAM,IAAInE,UAAWiB,EAAQ,+EAAgFkD,IAwB9G,SAASi6B,IACR,IAAIvvB,EACAwvB,EACAzuB,EACAouB,EACAruB,EACAjK,EACApI,EACAgT,EAGJ,GADAV,EAAQzP,UAAU1D,SACX8Q,gBAAgB6wB,GACtB,OAAKxuB,EAAQ,EACL,IAAIwuB,EAAYj+B,UAAU,IAEnB,IAAVyP,EACG,IAAIwuB,EAAYj+B,UAAU,GAAIA,UAAU,IAEjC,IAAVyP,EACG,IAAIwuB,EAAYj+B,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAEvD,IAAIi+B,EAAYj+B,UAAU,GAAIA,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAG5E,GAAoB,QADpBk+B,EAAaP,GAAW39B,UAAW,OACNqY,GAAa6lB,GACzC,MAAM,IAAIr+B,UAAWiB,EAAQ,gFAAiFd,UAAW,KAO1H,GALA69B,EAAOzoB,GAAgB8oB,GAKR,IAHfzuB,GAAS,GAIRD,EAAM,IAAIwsB,GAAU,IAAI1wB,GAAa,SAC/B,GAAe,IAAVmE,EAEX,GAAK1E,GADL5N,EAAM6C,UAAWyP,IAEhBD,EAAM,IAAIwsB,GAAU,IAAI1wB,GAAanO,EAAI4Q,SACnC,GAAK3C,GAAcjO,GACzBqS,EAAME,EAAW,IAAIssB,GAAU,IAAI1wB,GAAanO,EAAIb,OAAOyR,IAAuB5Q,EAAK0gC,QACjF,GAAKtyB,GAAepO,IAE1B,GADAqS,EAAM,IAAIwsB,GAAU7+B,IACd4N,GAAsB5N,EAAI2S,WAAW/B,GAC1C,MAAM,IAAI4B,WAAY7O,EAAQ,yFAA0FiN,EAAmByB,EAAIM,iBAE1I,KAAKxF,GAAUnN,GAcrB,MAAM,IAAI0C,UAAWiB,EAAQ,qHAAsH3D,IAbnJ,IAA6B,IAAxB+R,GACJ,MAAM,IAAIrP,UAAWiB,EAAQ,mJAAoJ3D,IAElL,IAAM4P,GAAY5P,EAAK4S,KACtB,MAAM,IAAIlQ,UAAWiB,EAAQ,qHAAsH3D,IAGpJ,IAAM4P,IADNyC,EAAMrS,EAAK4S,OACWjB,MACrB,MAAM,IAAIjP,UAAWiB,EAAQ,qHAAsH3D,IAEpJgT,EAAMvB,GAAcY,GACpBA,EAAME,EAAW,IAAIssB,GAAU,IAAI1wB,GAAa6E,EAAI7T,OAAOyR,IAAuBoC,EAAK0tB,EAGvF,KACK,CAEN,IAAMtyB,GADNiE,EAAMxP,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,8DAA+D0O,IAG7F,IAAMzE,GADN2D,EAAa1O,UAAW,IAEvB,MAAM,IAAIH,UAAWiB,EAAQ,4EAA6E4N,IAE3G,GAAe,IAAVe,EACJD,EAAM,IAAIwsB,GAAUxsB,EAAKd,OACnB,CAEN,IAAM3D,GADNxF,EAAMvF,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,uEAAwEyE,IAGtG,IADAA,GAAOwI,GACKyB,EAAIM,WAAWpB,EAC1B,MAAM,IAAIiB,WAAY7O,EAAQ,iJAAkJyE,IAEjLiK,EAAM,IAAIwsB,GAAUxsB,EAAKd,EAAYnJ,EACrC,CACD,CAKD,OAJA7C,EAAa0K,KAAM,UAAWoC,GAC9B9M,EAAa0K,KAAM,UAAWoC,EAAIM,WAAW/B,GAC7CrL,EAAa0K,KAAM,QAASywB,GAErBzwB,IACP,CAs0BD,OAr7BAW,EAAoBovB,GAAiBn5B,GACrC85B,EAvFD,SAAqB95B,GACpB,OAAOo5B,GAAYp5B,GAAU,SAC9B,CAqFam6B,CAAYn6B,GACxB+5B,EAASP,GAAWx5B,GACpBg6B,EAAST,GAAWv5B,GAuHpBtB,EAAau7B,EAAY,oBAAqBlwB,GAW9CrL,EAAau7B,EAAY,OAAQH,GAoBjCp7B,EAAau7B,EAAY,QAAQ,SAAeC,EAAYluB,GAC3D,IAAIC,EACA+b,EACAvc,EACAS,EACA2tB,EACA9hC,EACAyT,EACAW,EACA5N,EACAgD,EACAzJ,EACJ,IAAMiR,GAAYK,MACjB,MAAM,IAAIvN,UAAW,6DAEtB,IAAMu+B,EAAyBhxB,MAC9B,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAGpG,GAAe,QADf9R,EAAQ2R,GAAWO,MACK7lB,GAAa2T,GACpC,MAAM,IAAInsB,UAAWiB,EAAQ,gFAAiFo9B,IAK/G,GAHAL,EAAOzoB,GAAgB4W,IAEvBvc,EAAQzP,UAAU1D,QACL,EAAI,CAEhB,IAAMyQ,GADNmD,EAAOlQ,UAAW,IAEjB,MAAM,IAAIH,UAAWiB,EAAQ,oEAAqEoP,IAE9FT,EAAQ,IACZQ,EAAUjQ,UAAW,GAEtB,CACD,GAAKoL,GAAc4E,GAAQ,CAC1B,GAAKE,EAAO,CASX,IARA3K,EAAMyK,EAAI1T,OAETiG,EADIyN,EAAIzN,KAAOyN,EAAIxN,IACb6N,EAAgB,WAEhBtM,EAAQ,WAGfyL,GADAzT,EAAM,IAAIqR,KAAM4e,EAAOzmB,IACb8J,QACJvT,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB0T,EAAKwuB,GAAUliC,EAAEiS,EAAmBmC,EAAKtS,KAAMqS,EAAS1N,EAAKyN,EAAKlU,GAAKA,GAAK+hC,GAE7E,OAAO9hC,CACP,CACD,OAAO,IAAIqR,KAAM4e,EAAOhc,EACxB,CACD,GAAK1F,GAAU0F,IAASd,IAAuBnC,GAAYiD,EAAKD,KAAsB,CAErF,IAAMhD,IADNyC,EAAMQ,EAAKD,OACWjB,MACrB,MAAM,IAAIjP,UAAWiB,EAAQ,8FAA+FkP,IAU7H,IAPCG,EADID,EE5YR,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIlU,EACAkJ,EACAnJ,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI4J,EAAGC,QACAC,MAGPjT,GAAK,EACLC,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAAShL,EAAEtJ,MAAOG,IAExC,OAAOC,CACR,CF6XUuU,CAAiBd,EAAKU,EAAMD,GAE5BrB,GAAcY,GAIrBA,GADAzT,EAAM,IAAIqR,KAAM4e,EADhBzmB,EAAM4K,EAAI7T,SAEA+S,QACJvT,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB0T,EAAKwuB,GAAUliC,EAAEiS,EAAmBoC,EAAKrU,GAAK+hC,GAE/C,OAAO9hC,CACP,CACD,MAAM,IAAI8D,UAAWiB,EAAQ,8FAA+FkP,GAC9H,IAgBCtN,EAAau7B,EAAY,MAAM,SAAaC,GAC3C,IAAIlS,EACAjrB,EACAjF,EACJ,IAAMiR,GAAYK,MACjB,MAAM,IAAIvN,UAAW,6DAEtB,IAAMu+B,EAAyBhxB,MAC9B,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAGpG,GAAe,QADf9R,EAAQ2R,GAAWO,MACK7lB,GAAa2T,GACpC,MAAM,IAAInsB,UAAWiB,EAAQ,gFAAiFo9B,IAG/G,IADAn9B,EAAO,GACDjF,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAClCiF,EAAKF,KAAMb,UAAWlE,IAEvB,OAAO,IAAIsR,KAAM4e,EAAOjrB,EAC1B,IAcC2B,EAAau7B,EAAWthC,UAAW,MAAM,SAAayG,GACrD,IAAImC,EACJ,IAAM84B,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,IAAMpzB,GAAWtH,GAChB,MAAM,IAAIvD,UAAWiB,EAAQ,0DAA2DsC,IAMzF,GAJAmC,EAAM6H,KAAKgC,QACNhM,EAAM,IACVA,GAAOmC,KAEHnC,EAAM,GAAKA,GAAOmC,GAGvB,OAAO6H,KAAKiC,QAAS0uB,GAAU36B,EAAM2K,EAAmBX,KAAKkxB,MAC/D,IAWC1F,GAAqBqF,EAAWthC,UAAW,UAAU,WACpD,OAAOyQ,KAAKiC,QAAQZ,MACtB,IAWCmqB,GAAqBqF,EAAWthC,UAAW,cAAc,WACxD,OAAOyQ,KAAKiC,QAAQS,UACtB,IAWC8oB,GAAqBqF,EAAWthC,UAAW,cAAc,WACxD,OAAOyQ,KAAKiC,QAAQX,UACtB,IAWChM,EAAau7B,EAAWthC,UAAW,oBAAqBshC,EAAWlwB,mBAenErL,EAAau7B,EAAWthC,UAAW,SAAS,SAAgB2I,EAAW2K,GACtE,IAAIT,EACA1T,EAEJ,IAAMuiC,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,IAAM/wB,GAAYzH,GACjB,MAAM,IAAIzF,UAAWiB,EAAQ,oEAAqEwE,IAGnG,IADAkK,EAAMpC,KAAKiC,QACLvT,EAAI,EAAGA,EAAIsR,KAAKgC,QAAStT,IAC9B,IAAMwJ,EAAU1H,KAAMqS,EAAST,EAAKuuB,GAAUjiC,EAAIiS,EAAmBX,KAAKkxB,OAASxiC,EAAGsR,MACrF,OAAO,EAGT,OAAO,CACT,IAeC1K,EAAau7B,EAAWthC,UAAW,UAAU,SAAiB2I,EAAW2K,GACxE,IAAIT,EACAzT,EACAD,EACAmJ,EAEJ,IAAMo5B,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,IAAM/wB,GAAYzH,GACjB,MAAM,IAAIzF,UAAWiB,EAAQ,oEAAqEwE,IAInG,IAFAkK,EAAMpC,KAAKiC,QACXtT,EAAM,GACAD,EAAI,EAAGA,EAAIsR,KAAKgC,QAAStT,IAC9BmJ,EAAIuK,EAAKuuB,GAAUjiC,EAAEiS,EAAmBX,KAAKkxB,OACxCh5B,EAAU1H,KAAMqS,EAAShL,EAAGnJ,EAAGsR,OACnCrR,EAAI8E,KAAMoE,GAGZ,OAAO,IAAImI,KAAKzH,YAAai4B,GAAgBxwB,KAAKkxB,OAASviC,EAC7D,IAcC2G,EAAau7B,EAAWthC,UAAW,WAAW,SAAkBkU,EAAKZ,GACpE,IAAIT,EACA1T,EAEJ,IAAMuiC,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,IAAM/wB,GAAY8D,GACjB,MAAM,IAAIhR,UAAWiB,EAAQ,oEAAqE+P,IAGnG,IADArB,EAAMpC,KAAKiC,QACLvT,EAAI,EAAGA,EAAIsR,KAAKgC,QAAStT,IAC9B+U,EAAIjT,KAAMqS,EAAST,EAAKuuB,GAAUjiC,EAAEiS,EAAmBX,KAAKkxB,OAASxiC,EAAGsR,KAE3E,IAcC1K,EAAau7B,EAAWthC,UAAW,OAAO,SAAcyG,GACvD,IAAMi7B,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,IAAM/yB,GAAsB3H,GAC3B,MAAM,IAAIvD,UAAWiB,EAAQ,qEAAsEsC,IAEpG,KAAKA,GAAOgK,KAAKgC,SAGjB,OAAOhC,KAAKiC,QAAS0uB,GAAU36B,EAAI2K,EAAmBX,KAAKkxB,MAC7D,IAeC57B,EAAau7B,EAAWthC,UAAW,YAAY,SAAmBmU,EAAeC,GAChF,IAAIvB,EACA1T,EAEJ,IAAMuiC,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,GAAK99B,UAAU1D,OAAS,EAAI,CAC3B,IAAMoO,GAAWqG,GAChB,MAAM,IAAIlR,UAAWiB,EAAQ,qEAAsEiQ,IAE/FA,EAAY,IAChBA,GAAa3D,KAAKgC,SACD,IAChB2B,EAAY,EAGjB,MACGA,EAAY,EAGb,IADAvB,EAAMpC,KAAKiC,QACLvT,EAAIiV,EAAWjV,EAAIsR,KAAKgC,QAAStT,IACtC,GAAK0T,EAAKuuB,GAAUjiC,EAAIiS,EAAmBX,KAAKkxB,SAAYxtB,EAC3D,OAAO,EAGT,OAAO,CACT,IAeCpO,EAAau7B,EAAWthC,UAAW,WAAW,SAAkBmU,EAAeC,GAC9E,IAAIvB,EACA1T,EAEJ,IAAMuiC,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,GAAK99B,UAAU1D,OAAS,EAAI,CAC3B,IAAMoO,GAAWqG,GAChB,MAAM,IAAIlR,UAAWiB,EAAQ,qEAAsEiQ,IAE/FA,EAAY,IAChBA,GAAa3D,KAAKgC,SACD,IAChB2B,EAAY,EAGjB,MACGA,EAAY,EAGb,IADAvB,EAAMpC,KAAKiC,QACLvT,EAAIiV,EAAWjV,EAAIsR,KAAKgC,QAAStT,IACtC,GAAK0T,EAAKuuB,GAAUjiC,EAAIiS,EAAmBX,KAAKkxB,SAAYxtB,EAC3D,OAAOhV,EAGT,OAAQ,CACV,IAcC4G,EAAau7B,EAAWthC,UAAW,QAAQ,SAAeqU,GACzD,IAAIjV,EACAyT,EACAyB,EACAnV,EAEJ,IAAMuiC,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,GAAK99B,UAAU1D,OAAS,EAAI,CAC3B,IAAMkP,GAAUwF,GACf,MAAM,IAAInR,UAAWiB,EAAQ,kEAAmEkQ,IAEjGC,EAAMD,CACT,MACGC,EAAM,IAIP,IAFAlV,EAAM,GACNyT,EAAMpC,KAAKiC,QACLvT,EAAI,EAAGA,EAAIsR,KAAKgC,QAAStT,IAC9BC,EAAI8E,KAAM2O,EAAKuuB,GAAUjiC,EAAIiS,EAAmBX,KAAKkxB,QAEtD,OAAOviC,EAAImV,KAAMD,EACnB,IAeCvO,EAAau7B,EAAWthC,UAAW,eAAe,SAAsBmU,EAAeC,GACtF,IAAIvB,EACA1T,EAEJ,IAAMuiC,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAO,IAAO85B,IAEtG,GAAK99B,UAAU1D,OAAS,EAAI,CAC3B,IAAMoO,GAAWqG,GAChB,MAAM,IAAIlR,UAAWiB,EAAQ,qEAAsEiQ,IAE/FA,GAAa3D,KAAKgC,QACtB2B,EAAY3D,KAAKgC,QAAU,EAChB2B,EAAY,IACvBA,GAAa3D,KAAKgC,QAEtB,MACG2B,EAAY3D,KAAKgC,QAAU,EAG5B,IADAI,EAAMpC,KAAKiC,QACLvT,EAAIiV,EAAWjV,GAAK,EAAGA,IAC5B,GAAK0T,EAAKuuB,GAAUjiC,EAAIiS,EAAmBX,KAAKkxB,SAAYxtB,EAC3D,OAAOhV,EAGT,OAAQ,CACV,IAWC88B,GAAqBqF,EAAWthC,UAAW,UAAU,WACpD,OAAOyQ,KAAKgC,OACd,IAeC1M,EAAau7B,EAAWthC,UAAW,OAAO,SAAckU,EAAKZ,GAC5D,IAAIqa,EACAvuB,EACAyT,EACA1T,EACAmJ,EACJ,IAAMo5B,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,IAAM/wB,GAAY8D,GACjB,MAAM,IAAIhR,UAAWiB,EAAQ,oEAAqE+P,IAKnG,IAHArB,EAAMpC,KAAKiC,QAEXib,GADAvuB,EAAM,IAAIqR,KAAKzH,YAAai4B,GAAgBxwB,KAAKkxB,OAASlxB,KAAKgC,UACpDC,QACLvT,EAAI,EAAGA,EAAIsR,KAAKgC,QAAStT,IAC9BmJ,EAAI4L,EAAIjT,KAAMqS,EAAST,EAAKuuB,GAAUjiC,EAAIiS,EAAmBX,KAAKkxB,OAASxiC,EAAGsR,MAC9Ekd,EAAM0T,GAAUliC,EAAIiS,EAAmB9I,EAAGmI,KAAKkxB,OAEhD,OAAOviC,CACT,IAeC2G,EAAau7B,EAAWthC,UAAW,UAAU,SAAiB0U,EAASC,GACtE,IAAI9B,EACAjK,EACAgM,EACAzV,EAEJ,IAAMuiC,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,IAAM/wB,GAAYsE,GACjB,MAAM,IAAIxR,UAAWiB,EAAQ,oEAAqEuQ,IAInG,GAFA7B,EAAMpC,KAAKiC,QACX9J,EAAM6H,KAAKgC,QACNpP,UAAU1D,OAAS,EACvBiV,EAAMD,EACNxV,EAAI,MACE,CACN,GAAa,IAARyJ,EACJ,MAAM,IAAIjI,MAAO,oGAElBiU,EAAM/B,EAAKuuB,GAAU,EAAIhwB,EAAmBX,KAAKkxB,OACjDxiC,EAAI,CACJ,CACD,KAAQA,EAAIyJ,EAAKzJ,IAChByV,EAAMF,EAASE,EAAK/B,EAAKuuB,GAAUjiC,EAAIiS,EAAmBX,KAAKkxB,OAASxiC,EAAGsR,MAE5E,OAAOmE,CACT,IAeC7O,EAAau7B,EAAWthC,UAAW,eAAe,SAAsB0U,EAASC,GAChF,IAAI9B,EACAjK,EACAgM,EACAzV,EAEJ,IAAMuiC,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,IAAM/wB,GAAYsE,GACjB,MAAM,IAAIxR,UAAWiB,EAAQ,oEAAqEuQ,IAInG,GAFA7B,EAAMpC,KAAKiC,QACX9J,EAAM6H,KAAKgC,QACNpP,UAAU1D,OAAS,EACvBiV,EAAMD,EACNxV,EAAIyJ,EAAM,MACJ,CACN,GAAa,IAARA,EACJ,MAAM,IAAIjI,MAAO,oGAElBiU,EAAM/B,EAAKuuB,IAAYx4B,EAAM,GAAMwI,EAAmBX,KAAKkxB,OAC3DxiC,EAAIyJ,EAAM,CACV,CACD,KAAQzJ,GAAK,EAAGA,IACfyV,EAAMF,EAASE,EAAK/B,EAAKuuB,GAAUjiC,EAAIiS,EAAmBX,KAAKkxB,OAASxiC,EAAGsR,MAE5E,OAAOmE,CACT,IAqCC7O,EAAau7B,EAAWthC,UAAW,OAAO,SAAchB,GACvD,IAAI8V,EACArO,EACAoM,EACAW,EACA5N,EACAiP,EACA1V,EACA8D,EACJ,IAAMy+B,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAGpG,GADAtuB,EAAMpC,KAAKiC,QACNrP,UAAU1D,OAAS,GAEvB,IAAMyO,GADN3H,EAAMpD,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,+EAAgFsC,SAG9GA,EAAM,EAEP,GAAKgI,GAAczP,GAAnB,CAEC,GAAKyH,GADLoO,EAAI7V,EAAMW,QACG8Q,KAAKgC,QACjB,MAAM,IAAIO,WAAY,0FAUvB,GANCpN,GAFDkP,EAAO9V,GACG4G,KAAOkP,EAAKjP,IACf6N,EAAgB,WAEhBtM,EAAQ,WAGfnE,EAAI4P,EAAId,WAActL,EAAI2K,EAEzB0D,EAAKhD,SAAWe,EAAIf,QAEnBgD,EAAK/C,WAAa9O,GAClB6R,EAAK/C,WAAW+C,EAAK3B,WAAalQ,EAElC,CAGD,IADAuQ,EAAM,GACArU,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBqU,EAAItP,KAAM0B,EAAK5G,EAAOG,IAEvB2V,EAAOtB,EACP5N,EAAMwB,EAAQ,UACd,CACD,IAAMjI,EAAI,EAAGA,EAAI0V,EAAGpO,IAAOtH,IAC1B0T,EAAKwuB,GAAU56B,EAAI2K,EAAmBxL,EAAKkP,EAAM3V,GAAKsR,KAAKkxB,MAG5D,KAhCD,CAiCA,GAAKl7B,GAAOgK,KAAKgC,QAChB,MAAM,IAAIO,WAAY7O,EAAQ,kEAAmEsC,IAElGoM,EAAKwuB,GAAU56B,EAAI2K,EAAmBpS,EAAOyR,KAAKkxB,MAJjD,CAKH,IAeC57B,EAAau7B,EAAWthC,UAAW,QAAQ,SAAe2I,EAAW2K,GACpE,IAAIT,EACA1T,EAEJ,IAAMuiC,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,IAAM/wB,GAAYzH,GACjB,MAAM,IAAIzF,UAAWiB,EAAQ,oEAAqEwE,IAGnG,IADAkK,EAAMpC,KAAKiC,QACLvT,EAAI,EAAGA,EAAIsR,KAAKgC,QAAStT,IAC9B,GAAKwJ,EAAU1H,KAAMqS,EAAST,EAAKuuB,GAAUjiC,EAAIiS,EAAmBX,KAAKkxB,OAASxiC,EAAGsR,MACpF,OAAO,EAGT,OAAO,CACT,IAYC1K,EAAau7B,EAAWthC,UAAW,YAAY,WAC9C,IAAIZ,EACAyT,EACA1T,EACJ,IAAMuiC,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAIpG,IAFA/hC,EAAM,GACNyT,EAAMpC,KAAKiC,QACLvT,EAAI,EAAGA,EAAIsR,KAAKgC,QAAStT,IAC9BC,EAAI8E,KAAM2O,EAAKuuB,GAAUjiC,EAAEiS,EAAmBX,KAAKkxB,QAEpD,OAAOviC,EAAImV,KAAM,IACnB,IAgBCxO,EAAau7B,EAAWthC,UAAW,QAAQ,SAAmByV,EAAOzW,GACpE,IACI6T,EACAzT,EACAwJ,EAEJ,IAAM84B,EAAcjxB,MACnB,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAEpG,IAAMpzB,GAAW0H,GAChB,MAAM,IAAIvS,UAAWiB,EAAQ,oEAAqEsR,IAOnG,GALA7M,EAAM6H,KAAKgC,QACXI,EAAMpC,KAAKiC,QACN+C,EAAQ,IACZA,GAAS7M,GAEL6M,EAAQ,GAAKA,GAAS7M,EAC1B,MAAM,IAAIoK,WAAY7O,EAAQ,kEAAmEsR,IAKlG,OAHArW,EAAM,IAAIqR,KAAKzH,YAAai4B,GAAgBxwB,KAAKkxB,OAAS9uB,EAAIf,SACjDY,QACL2uB,GAAU5rB,EAAQrE,EAAmBpS,EAAOyR,KAAKkxB,OAClDviC,CACT,IAEQkiC,EASP,SAASG,EAAyBziC,GACjC,OAASA,IAAUsiC,CACnB,CASD,SAASI,EAAc1iC,GACtB,MACkB,iBAAVA,GACG,OAAVA,IAECA,EAAMgK,YAAYK,OAAS83B,GJnnC/B,SAAwBniC,EAAOkf,GAC9B,IAAI/N,SAAc+N,EAClB,GACW,OAAVA,GACU,WAAT/N,GAA8B,aAATA,EAEtB,MAAM,IAAIjN,UAAWiB,EAAQ,uGAAwG+Z,IAGtI,OADA/N,SAAcnR,EAEH,OAAVA,IACU,WAATmR,GAA8B,aAATA,IAIhBowB,GAAUt/B,KAAMid,EAAOlf,EAC/B,CIomCIsf,CAAetf,EAAOsiC,EAAWthC,aAElChB,EAAMoS,oBAAsBA,CAE7B,CAWD,SAAS2B,EAAWyX,EAAMhkB,EAAK06B,GAC9B,IAAIt4B,EACAhD,EACAzG,EAQJ,IANAyJ,EAAMpC,EAAI7G,OAETiG,EADIY,EAAIZ,KAAOY,EAAIX,IACb6N,EAAgB,WAEhBtM,EAAQ,WAETjI,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBqrB,EAAM6W,GAAUliC,EAAEiS,EAAmBxL,EAAKY,EAAKrH,GAAK+hC,GAErD,OAAO1W,CACP,CACF,CG1mCA,IAAIoX,GAAiBxqB,GAAS,WCA1ByqB,GAAiBzqB,GAAS,WCvE1B5N,GAAc,CACjBwH,UAAa,YACbV,WAAc,cCIX+H,GAAQ,CACX5Q,UAAauJ,GACbxJ,WAAc8I,ICUf,SAAS+H,GAAOhR,GACf,OAAOgmB,GAAOhmB,IAAW,IAC1B,CChBA,ICEIlI,GDFA8W,8BEUWjS,QDTXgS,GAAQ,GAEZ,IAAM7W,GAAI,EAAGA,GAAI8W,GAAOtW,OAAQR,KAC/B6W,GAAM9R,KAAMmU,GAAOpC,GAAQ9W,MED5B,IAAI+W,GAASD,GAAOtW,OAoBpB,SAAS0H,GAAOrI,GACf,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAI+W,GAAQ/W,IACxB,GAAKH,aAAiBgX,GAAO7W,GAC5B,OAAO8W,GAAQ9W,GAIjB,OAAOgX,GAAY/M,GAAiBpK,KAAa,IAClD,CCvBA,IAAI8iC,GAAe3L,GAASvwB,IAAK,8BAC7Bm8B,GAAgB5L,GAASvwB,IAAK,iCAC9Bo8B,GAAe7L,GAASvwB,IAAK,kBA+BjC,SAASq8B,GAAcjjC,GACtB,IAAIyU,EACArU,EAEAiX,EACA/N,EA+BJ,OA7BAmL,EAAM1U,GAAUC,GACXqE,UAAU1D,OAAS,EAClB8T,EACJ4C,EAAKyrB,GACM7yB,GAAWjQ,GACtBqX,EAAK2rB,GACM9wB,GAAelS,GAEd,QADZqX,EAAKhP,GAAOrI,MAEXqX,EAAK0rB,IAGN1rB,EAAK,UAGNA,EAAKhT,UAAW,GAEjBjE,EAAMH,GAAO,EAAGoX,GAEf/N,EADImL,GAAO0a,GAAmB9X,GAC1B,CAAErX,EAAO,GAETA,GAEAqH,EAAiBjH,GACfmX,EAAgBF,GAEhB9O,EAAQ8O,IAEVjX,EAAK,EAAGkJ,GACNlJ,CACR,CC1EA,IAAI43B,GAAgBb,GAASvwB,IAAK,kBAuBlC,SAASs8B,GAAMviC,EAAQX,GACtB,IAAIqI,EACAiC,EACAlK,EACJ,IAAMgP,GAAsBzO,GAC3B,MAAM,IAAIuD,UAAWiB,EAAQ,+EAAgFxE,IAO9G,GAAe,aAJd0H,EADIhE,UAAU1D,OAAS,EACf0D,UAAW,GAEX2zB,IAGR,OAAOmL,GAAOnjC,EAAOW,GAGtB,GAAc,QADd2J,EAAO+O,GAAOhR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,gFAAiFkD,IAO/G,OAFA64B,GAAOvgC,EAAQX,EAHfI,EAAM,IAAIkK,EAAM3J,GAGW,GAEpBP,CACR,CCvDA,SAASgjC,KAET,CCGA,IAAIC,GCOmB,QAAbD,GAAI/4B,KCFV2M,GAAQ,CACXtM,GACAD,GACAG,GACAG,GACAJ,GACAG,GACAD,GACAG,GACAC,0ICVGq3B,GAAeh3B,KAA6B2T,GAAgBvU,IAAiB44B,GAajF,SAASA,KAAU,CAVnBhB,GAAyC,eHqBzC,SAAuBptB,GAEtB,IAA2B,IAAtB9D,GAAY8D,GAChB,MAAM,IAAIhR,UAAWiB,EAAQ,0DAA2D+P,IAEzF,OAAKmuB,GACGnuB,EAAI7K,KAEL5F,GAAGM,KAAMmQ,EAAItT,YAAc,EACnC,CG9Be2hC,CAASjB,IAAkCA,GAAagB,GCTvE,IAAItsB,GAAQ,CACX7L,GACAD,4CCcD,SAASyL,GAAgB3W,GACxB,OACCA,aAAiBoL,IACY,iBAA7BhB,GAAiBpK,EAEnB,CCMA,SAASwjC,GAAYxjC,EAAOgK,GAE3B,GAA4B,mBAAhBA,EACX,MAAM,IAAI9F,UAAWiB,EAAQ,mEAAoE6E,IAElG,OAAShK,aAAiBgK,CAC3B,CCvBA,IAAIgN,GAAQ,CACX,CAAEtM,GAAc,gBAChB,CAAED,GAAc,gBAChB,CAAEG,GAAY,cACd,CAAEG,GAAa,eACf,CAAEJ,GAAY,cACd,CAAEG,GAAa,eACf,CAAED,GAAW,aACb,CAAEG,GAAY,cACd,CAAEC,GAAmB,qBACrB,CAAEC,GAAgB,kBAClB,CAAEC,GAAiB,mBACnB,CAAEC,GAAc,iBCNjB,SAASq4B,GAAUj8B,GAClB,IAAI8B,EACAnJ,EAGJ,IAAMA,EAAI,EAAGA,EAAI6W,GAAMrW,OAAQR,IAC9B,GAAKqjC,GAAYh8B,EAAKwP,GAAO7W,GAAK,IACjC,OAAO6W,GAAO7W,GAAK,GAIrB,KAAQqH,GAAM,CAEb,IADA8B,EAAI4H,GAAU1J,GACRrH,EAAI,EAAGA,EAAI6W,GAAMrW,OAAQR,IAC9B,GAAKmJ,IAAM0N,GAAO7W,GAAK,GACtB,OAAO6W,GAAO7W,GAAK,GAGrBqH,EAAMyX,GAAgBzX,EACtB,CACF,CCVA,SAASk8B,GAAiBl8B,GACzB,IAAIsQ,EACA1X,EACAD,EAEJ,GNKD,SAAuBH,GACtB,IAAIsJ,EACAnJ,EAEJ,GAAsB,iBAAVH,GAAgC,OAAVA,EACjC,OAAO,EAGR,GAAKA,aAAiBsiC,GACrB,OAAO,EAGR,IAAMniC,EAAI,EAAGA,EAAI6W,GAAMrW,OAAQR,IAC9B,GAAKH,aAAiBgX,GAAO7W,GAC5B,OAAO,EAIT,KAAQH,GAAQ,CAEf,IADAsJ,EAAI4H,GAAUlR,GACRG,EAAI,EAAGA,EAAIwjC,GAAMhjC,OAAQR,IAC9B,GAAKwjC,GAAOxjC,KAAQmJ,EACnB,OAAO,EAGTtJ,EAAQif,GAAgBjf,EACxB,CAED,OAAO,CACR,CMlCM0iC,CAAcl7B,GAClBsQ,EAAOtQ,OACD,GCnBR,SAA8BxH,GAC7B,IAAIsJ,EACAnJ,EAEJ,GAAsB,iBAAVH,GAAgC,OAAVA,EACjC,OAAO,EAGR,IAAMG,EAAI,EAAGA,EAAI6W,GAAMrW,OAAQR,IAC9B,GAAKH,aAAiBgX,GAAO7W,GAC5B,OAAO,EAIT,KAAQH,GAAQ,CAEf,IADAsJ,EAAI4H,GAAUlR,GACRG,EAAI,EAAGA,EAAIwjC,GAAMhjC,OAAQR,IAC9B,GAAKwjC,GAAOxjC,KAAQmJ,EACnB,OAAO,EAGTtJ,EAAQif,GAAgBjf,EACxB,CAED,OAAO,CACR,CDNa+c,CAAqBvV,GAE/BsQ,EAD8B,IAA1BtQ,EAAI4K,kBACD6B,GAAezM,EAAK,GAEpB0M,GAAgB1M,EAAK,OAEvB,KAAKmP,GAAgBnP,GAG3B,MAAM,IAAItD,UAAWiB,EAAQ,6DAA8DqC,IAF3FsQ,EAAOiL,GAAoBvb,EAAK,EAGhC,CAKD,IAJApH,EAAM,CACL+Q,KAAQsyB,GAAUj8B,GAClBsQ,KAAQ,IAEH3X,EAAI,EAAGA,EAAI2X,EAAKnX,OAAQR,IAC7BC,EAAI0X,KAAK5S,KAAM4S,EAAM3X,IAEtB,OAAOC,CACR,CEzCA,SAASwjC,GAAM5jC,GA0Bd,OAxBAF,EAAgB2R,KAAM,OAAQ,CAC7BzK,cAAgB,EAChBC,YAAc,EACdL,IAAO,WACN,OAAO6K,KAAKoyB,KACZ,IAEFpyB,KAAKzR,MAAQA,EAEbF,EAAgB2R,KAAM,QAAS,CAC9BzK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAAS,OAIVF,EAAgB2R,KAAM,QAAS,CAC9BzK,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAAS,OAGHyR,IACR,CCXA,SAASqyB,KACR,OAAOryB,gBAAgBqyB,IAGvBryB,KAAKgC,QAAU,EACfhC,KAAKsyB,OAAS,KACdtyB,KAAKuyB,MAAQ,KACNvyB,MALC,IAAIqyB,EAMb,CAmCW38B,EAAE28B,GAAW9iC,UAAW,SAAS,WAI3C,OAHAyQ,KAAKgC,QAAU,EACfhC,KAAKsyB,OAAS,KACdtyB,KAAKuyB,MAAQ,KACNvyB,IACR,IAoBWtK,EAAE28B,GAAW9iC,UAAW,SAAS,WAC3C,GAAKyQ,KAAKgC,QACT,OAAOhC,KAAKsyB,MAEd,IAiCAh9B,EAAa+8B,GAAW9iC,UAAW,UAAU,SAAiBijC,EAAMjkC,GAEnE,IAAIE,EAGJ,GAAK+jC,IAASxyB,KAAKuyB,MAClB,OAAOvyB,KAAKvM,KAAMlF,GAInB,IADAE,EAAIuR,KAAKsyB,OACD7jC,IAAMuR,KAAKuyB,OAAS9jC,IAAM+jC,GACjC/jC,EAAIA,EAAE2jC,MAGP,GAAK3jC,IAAMuR,KAAKuyB,MACf,MAAM,IAAIriC,MAAO,uEAelB,OAZAzB,EAAI,IAAI0jC,GAAM5jC,GAGdikC,EAAKJ,MAAMK,MAAQhkC,EACnBA,EAAE2jC,MAAQI,EAAKJ,MAEfI,EAAKJ,MAAQ3jC,EACbA,EAAEgkC,MAAQD,EAGVxyB,KAAKgC,SAAW,EAEThC,IAGR,IAiCWtK,EAAE28B,GAAW9iC,UAAW,YAAY,WAC9C,IAAIwV,EACAzB,EACA3E,EACA1H,EACAvI,EAiBJ,OAfAiQ,EAAOqB,KAGPtR,GAAK,EAGLqW,EAAS/E,KAAK0yB,UAIdp9B,EADAgO,EAAO,CAAA,EACY,QAanB,WAEC,OADA5U,GAAK,EACAuI,GAAOvI,GAAKqW,EAAO7V,OAChB,CACNyS,MAAQ,GAGH,CACNpT,MAASwW,EAAQrW,GACjBiT,MAAQ,EAET,IAvBDrM,EAAagO,EAAM,UAgCnB,SAAc/U,GAEb,OADA0I,GAAM,EACDrE,UAAU1D,OACP,CACNX,MAASA,EACToT,MAAQ,GAGH,CACNA,MAAQ,EAET,IA1CIgxB,IACJr9B,EAAagO,EAAMqvB,IAiDpB,WACC,OAAOh0B,EAAKoC,UACZ,IAjDMuC,CAkDR,IAoBW5N,EAAE28B,GAAW9iC,UAAW,QAAQ,WAC1C,GAAKyQ,KAAKgC,QACT,OAAOhC,KAAKuyB,KAEd,IAuBmBtxB,GAAEoxB,GAAW9iC,UAAW,UAAU,WACpD,OAAOyQ,KAAKgC,OACb,IA2BWtM,EAAE28B,GAAW9iC,UAAW,OAAO,WAEzC,IAAIhB,EAiBJ,OAhBKyR,KAAKgC,UAETzT,EAAQyR,KAAKuyB,MAAMhkC,MAGdyR,KAAKuyB,MAAME,OACfzyB,KAAKuyB,MAAQvyB,KAAKuyB,MAAME,MACxBzyB,KAAKuyB,MAAMH,MAAQ,OAGnBpyB,KAAKsyB,OAAS,KACdtyB,KAAKuyB,MAAQ,MAGdvyB,KAAKgC,SAAW,GAEVzT,CAGR,IA2BWmH,EAAE28B,GAAW9iC,UAAW,QAAQ,SAAehB,GACzD,IAAIikC,EAuBJ,OApBAA,EAAO,IAAIL,GAAM5jC,GAGK,IAAjByR,KAAKgC,SAEThC,KAAKsyB,OAASE,EACdxyB,KAAKuyB,MAAQC,IAGbA,EAAKC,MAAQzyB,KAAKuyB,MAGlBvyB,KAAKuyB,MAAMH,MAAQI,EAGnBxyB,KAAKuyB,MAAQC,GAGdxyB,KAAKgC,SAAW,EAEThC,IACR,IAiCWtK,EAAE28B,GAAW9iC,UAAW,UAAU,SAAiBijC,GAE7D,IAAIjkC,EACAE,EAGJ,GAAK+jC,IAASxyB,KAAKsyB,OAClB,OAAOtyB,KAAK4yB,QAGb,GAAKJ,IAASxyB,KAAKuyB,MAClB,OAAOvyB,KAAK6yB,MAOb,IAJAtkC,EAAQikC,EAAKjkC,MAGbE,EAAIuR,KAAKsyB,OACD7jC,IAAMuR,KAAKuyB,OAAS9jC,IAAM+jC,GACjC/jC,EAAIA,EAAE2jC,MAGP,GAAK3jC,IAAMuR,KAAKuyB,MACf,MAAM,IAAIriC,MAAO,uEASlB,OANAsiC,EAAKC,MAAML,MAAQI,EAAKJ,MACxBI,EAAKJ,MAAMK,MAAQD,EAAKC,MAGxBzyB,KAAKgC,SAAW,EAETzT,CAGR,IA2BWmH,EAAE28B,GAAW9iC,UAAW,SAAS,WAE3C,IAAIhB,EAiBJ,OAhBKyR,KAAKgC,UAETzT,EAAQyR,KAAKsyB,OAAO/jC,MAGfyR,KAAKsyB,OAAOF,OAChBpyB,KAAKsyB,OAAStyB,KAAKsyB,OAAOF,MAC1BpyB,KAAKsyB,OAAOG,MAAQ,OAGpBzyB,KAAKsyB,OAAS,KACdtyB,KAAKuyB,MAAQ,MAGdvyB,KAAKgC,SAAW,GAEVzT,CAGR,IAoBWmH,EAAE28B,GAAW9iC,UAAW,WAAW,WAC7C,IAAIijC,EACA7jC,EACAD,EAIJ,IAFAC,EAAM,GACN6jC,EAAOxyB,KAAKsyB,OACN5jC,EAAI,EAAGA,EAAIsR,KAAKgC,QAAStT,IAC9BC,EAAI8E,KAAM++B,EAAKjkC,OACfikC,EAAOA,EAAK9wB,KAEb,OAAO/S,CACR,IAwBW+G,EAAE28B,GAAW9iC,UAAW,UAAU,WAC5C,IAAIZ,EAAM,CACVA,KAAW,eAEX,OADAA,EAAI0X,KAAOrG,KAAK0yB,UACT/jC,CACR,IA2BW+G,EAAE28B,GAAW9iC,UAAW,WAAW,SAAkBhB,GAC/D,IAAIikC,EAuBJ,OApBAA,EAAO,IAAIL,GAAM5jC,GAGK,IAAjByR,KAAKgC,SAEThC,KAAKsyB,OAASE,EACdxyB,KAAKuyB,MAAQC,IAGbA,EAAKJ,MAAQpyB,KAAKsyB,OAGlBtyB,KAAKsyB,OAAOG,MAAQD,EAGpBxyB,KAAKsyB,OAASE,GAGfxyB,KAAKgC,SAAW,EAEThC,IACR,ICpoBA,IAAI8yB,GAAQ,IAAIT,GCAhB,SAASU,GAAMC,GAEd,IADA,IAAIR,EAAOM,GAAMG,QACTT,GAAO,CACd,GAAKA,EAAKjkC,MAAMykC,KAAOA,EACtB,OAAOR,EAERA,EAAOA,EAAK9wB,IACZ,CACD,OAAO,IACR,CCrBA,IAAIwxB,IAAW,EC4Cf,SAASC,GAAY51B,GACpB,IAAIqH,EACAnQ,EAEAmR,EACAoJ,EACAnX,EACJ,KAAOmI,gBAAgBmzB,IACtB,OAAKvgC,UAAU1D,OAAS,EAChB,IAAIikC,GAAY51B,EAAG3K,UAAW,IAE/B,IAAIugC,GAAY51B,GAExB,IAAMS,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,8EAA+E6J,IAK7G,GAAY,aAHZqI,EAAKhP,GAAO2G,KAGoB,OAAPqI,EACxB,GAAKrI,EAAErO,OAAS,EAKf,GAAKsP,GAHL3G,EADM2O,GAAejJ,EACjBpI,CAAKoI,EAAG,IAIXyR,EAAI,WACE,KAAK1R,GAAWzF,GAGtB,MAAM,IAAIpF,UAAW,iEAFrBuc,EAAI,KAGJ,MAEDA,EAAI,WAEC,GAAY,UAAPpJ,EACXoJ,EAAI,WACE,GAAY,UAAPpJ,EACXoJ,EAAI,WACE,IAAY,SAAPpJ,EAGX,MAAM,IAAInT,UAAW,iEAFrBuc,EAAI,MAGJ,CAGD,GADApK,EC9EO,CACNwuB,SAAW,GD8EPxgC,UAAU1D,OAAS,IACvBuF,EEhEF,SAAmBmQ,EAAMD,GACxB,OAAMzH,GAAUyH,GAGXpN,GAAYoN,EAAS,aACzBC,EAAKwuB,QAAUzuB,EAAQyuB,SACjB50B,GAAWoG,EAAKwuB,UACd,IAAI3gC,UAAWiB,EAAQ,+DAAgE,UAAWkR,EAAKwuB,UAGzG,KARC,IAAI3gC,UAAWiB,EAAQ,qEAAsEiR,GAStG,CFqDQ0uB,CAAUzuB,EAAMhS,UAAW,IAC5B6B,GACJ,MAAMA,EAmBR,OAfAq+B,GAAMr/B,KAAK,CACVu/B,IDlFDE,IAAW,GACI/iC,WCkFdmiB,IAAOtS,KACPqG,KAAQ9I,EACRmC,KAAQsP,EACRpY,MAASgP,EACTwtB,QAAWxuB,EAAKwuB,UAIjB99B,EAAa0K,KAAM,QAAS8yB,GAAMQ,QAGlC3G,GAAkB3sB,KAAM,gBAAgB,GAEjCA,IACR,CAeA1K,EAAa69B,GAAY,OAAQ,cAwBtBz9B,EAAEy9B,GAAY,QAAQ,SAAeH,GAC/C,IAAIR,EACA36B,EAIJ,OAAc,QADd26B,EAAOe,GAAgBP,MAOvB19B,GAHAuC,EAAI26B,EAAKjkC,OAGM+jB,IAAK,gBAAgB,GAGpCwgB,GAAMU,OAAQhB,GAGd36B,EAAEwO,KAAO,MAEF,EACR,IAiCW3Q,EAAEy9B,GAAY,OAAO,SAAcH,GAC7C,IAAIR,EACA7jC,EACAkJ,EAIJ,OAAc,QADd26B,EAAOe,GAAgBP,IAEf,MAKRrkC,EAAM,CACL0X,MAJDxO,EAAI26B,EAAKjkC,OAIE8X,KACV3G,KAAQ7H,EAAE6H,KACV9I,MAASiB,EAAEjB,OAINiB,EAAEu7B,SACPD,GAAWM,KAAMT,GAEXrkC,EACR,IAoBmBsS,GAAEkyB,GAAW5jC,UAAW,QAAQ,WAClD,GAAKyQ,KAAK0zB,aACT,MAAM,IAAIxjC,MAAO,kGAElB,OAAO8P,KAAK2zB,MAAMplC,MAAM8X,IACzB,IAoBmBpF,GAAEkyB,GAAW5jC,UAAW,SAAS,WACnD,GAAKyQ,KAAK0zB,aACT,MAAM,IAAIxjC,MAAO,kGAElB,OAAO8P,KAAK2zB,MAAMplC,MAAMqI,KACzB,IAoBmBqK,GAAEkyB,GAAW5jC,UAAW,MAAM,WAChD,GAAKyQ,KAAK0zB,aACT,MAAM,IAAIxjC,MAAO,kGAElB,OAAO8P,KAAK2zB,MAAMplC,MAAMykC,EACzB,IAmBmB/xB,GAAEkyB,GAAW5jC,UAAW,YAAY,WACtD,OAAQyQ,KAAK0zB,YACd,IAoBmBzyB,GAAEkyB,GAAW5jC,UAAW,QAAQ,WAClD,GAAKyQ,KAAK0zB,aACT,MAAM,IAAIxjC,MAAO,kGAElB,OAAO8P,KAAK2zB,MAAMplC,MAAMmR,IACzB,IAoBWhK,EAAEy9B,GAAW5jC,UAAW,YAAY,WAE9C,GAAKyQ,KAAK0zB,aACT,MAAM,IAAIxjC,MAAO,kGAGlB,MAAO,cADH8P,KAAK2zB,MAAMplC,MACUykC,GAAK,GAC/B,IAwBWt9B,EAAEy9B,GAAW5jC,UAAW,UAAU,WAC5C,IAAIsI,EAEJ,GAAKmI,KAAK0zB,aACT,MAAM,IAAIxjC,MAAO,kGAYlB,MAAO,CACNwP,KAAQ,aACR2G,KAXgB,aADjBxO,EAAImI,KAAK2zB,MAAMplC,OACRqI,OAAmC,OAAZiB,EAAEjB,MAC1BhB,EAAiBiC,EAAEwO,MACnB2L,GAAMna,EAAEwO,MAERxO,EAAEwO,KAGHutB,GAAY/7B,EAAEwO,MAMpB,IG7ZA,IAAIuB,GAAQ,CACX9R,QAAWmD,GACXhD,QAAW+C,GACXjC,WAAc2C,GACd1C,UAAayC,ICMd,SAASmO,GAAOhR,GACf,OAAOgmB,GAAOhmB,IAAW,IAC1B,CCIA,SAASi9B,GAAUllC,EAAKyU,EAAO6X,EAAM9iB,EAAK27B,GACzC,IAAI1vB,EACA2N,EACArjB,EAEJ,GAAa,IAARyJ,EACJ,OAAOxJ,EAGR,GAAa,IAARwJ,EAMJ,OAJCxJ,EAAK,GADDmlC,EACO7Y,EAEA7X,EAELzU,EAaR,IAXAA,EAAK,GAAMyU,EAQX2O,GAAMkJ,EAAK7X,IAJVgB,EADI0vB,EACA37B,EAAM,EAENA,GAKCzJ,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBC,EAAKD,GAAM0U,EAAS2O,EAAErjB,EAMvB,OAHKolC,IACJnlC,EAAKyV,GAAM6W,GAELtsB,CACR,CCxCA,SAASklC,GAAUllC,EAAK2gB,EAAKlM,EAAOmM,EAAK0L,EAAM9iB,EAAK27B,GACnD,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAhwB,EACA1V,EACA8D,EAEJ,GAAa,IAAR2F,EACJ,OAAOxJ,EAuBR,GArBa,YAAR2gB,GACJykB,EAAM3wB,EACN6wB,EAAM,GACa,cAAR3kB,GACXykB,EAAMnyB,GAAOwB,GACb6wB,EAAMpyB,GAAOuB,KAEb2wB,EAAMj0B,GAAMsD,GACZ6wB,EAAMl0B,GAAMqD,IAEA,YAARmM,GACJykB,EAAM/Y,EACNiZ,EAAM,GACa,cAAR3kB,GACXykB,EAAMpyB,GAAOqZ,GACbiZ,EAAMryB,GAAOoZ,KAEb+Y,EAAMl0B,GAAMmb,GACZiZ,EAAMn0B,GAAMkb,IAGA,IAAR9iB,EAQJ,OAPK27B,GACJnlC,EAAK,GAAMqlC,EACXrlC,EAAK,GAAMulC,IAEXvlC,EAAK,GAAMolC,EACXplC,EAAK,GAAMslC,GAELtlC,EAgBR,IAdAA,EAAK,GAAMolC,EACXplC,EAAK,GAAMslC,EAQXE,GAAOH,EAAID,IAJV3vB,EADI0vB,EACA37B,EAAM,EAENA,GAGLi8B,GAAOF,EAAID,GAAQ7vB,EAGnB5R,EAAI,EACE9D,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBC,EAAK6D,GAAMuhC,EAAOI,EAAGzlC,EACrBC,EAAK6D,EAAE,GAAMyhC,EAAOG,EAAG1lC,EACvB8D,GAAK,EAON,OAJKshC,IACJnlC,EAAK6D,GAAMwhC,EACXrlC,EAAK6D,EAAE,GAAM0hC,GAEPvlC,CACR,CC9DA,SAAS0kC,GAAUzuB,EAAMD,GACxB,OAAMzH,GAAUyH,GAGXpN,GAAYoN,EAAS,WACzBC,EAAKhO,MAAQ+N,EAAQ/N,OACfwH,GAAUwG,EAAKhO,QACb,IAAInE,UAAWiB,EAAQ,8DAA+D,QAASkR,EAAKhO,QAGxGW,GAAYoN,EAAS,cACzBC,EAAKkvB,SAAWnvB,EAAQmvB,UAClBt1B,GAAWoG,EAAKkvB,WACd,IAAIrhC,UAAWiB,EAAQ,+DAAgE,WAAYkR,EAAKkvB,WAG1G,KAdC,IAAIrhC,UAAWiB,EAAQ,qEAAsEiR,GAetG,WC1BI0vB,GAAwBhO,GAASlxB,IAAK,iCA6B1C,SAAS0+B,GAAUzwB,EAAO6X,EAAM9iB,GAC/B,IAAIyM,EACA/L,EACApE,EACA9F,EACA2gB,EACAC,EACAvM,EAEJ,GAAsB,iBAAVI,EAAqB,CAEhC,GAAa,QADbkM,EAAM1Y,GAAOwM,IACO,CACnB,IAAM3C,GAAe2C,GACpB,MAAM,IAAI3Q,UAAWiB,EAAQ,yFAA0F0P,IAExHkM,EAAM,YACN,CACDtM,GAAM,CACR,KAAQ,KAAM1U,GAAU8U,IAAWtR,GAAOsR,GACxC,MAAM,IAAI3Q,UAAWiB,EAAQ,yFAA0F0P,IAEvHkM,EAAM,SACN,CACD,GAAqB,iBAAT2L,EAAoB,CAE/B,GAAa,QADb1L,EAAM3Y,GAAOqkB,IACO,CACnB,IAAMxa,GAAewa,GACpB,MAAM,IAAIxoB,UAAWiB,EAAQ,0FAA2FunB,IAEzH1L,EAAM,YACN,CACDvM,GAAM,CACR,KAAQ,KAAM1U,GAAU2sB,IAAUnpB,GAAOmpB,GACvC,MAAM,IAAIxoB,UAAWiB,EAAQ,0FAA2FunB,IAExH1L,EAAM,SACN,CACD,IAAM5R,GAAsBxF,GAC3B,MAAM,IAAI1F,UAAWiB,EAAQ,+EAAgFyE,IAW9G,IATAyM,EAAO,CACNkvB,SAAYpO,KAGP9uB,MADD0Y,IAAQC,EACCD,EAGA+kB,GAETzhC,UAAU1D,OAAS,IACvBuF,EAAM4+B,GAAUzuB,EAAMhS,UAAW,KAEhC,MAAM6B,EAGR,GAAoB,YAAfmQ,EAAKhO,MACT,OAAKoM,ECnFP,SAAmBsM,EAAKlM,EAAOmM,EAAK0L,EAAM9iB,EAAK27B,GAC9C,IAAIQ,EACAC,EACAx+B,EACAg+B,EACAC,EACAC,EACAC,EACAj0B,EACAC,EACAi0B,EACAC,EACAhwB,EACA1V,EAEJ,GAAa,IAARyJ,EACJ,MAAO,GAgCR,GA9BAo8B,EAAQ,EACK,YAARjlB,GACJykB,EAAM3wB,EACN6wB,EAAM,GACa,cAAR3kB,GACXilB,GAAS,EACTR,EAAMnyB,GAAOwB,GACb6wB,EAAMpyB,GAAOuB,KAEb2wB,EAAMj0B,GAAMsD,GACZ6wB,EAAMl0B,GAAMqD,IAEA,YAARmM,GACJykB,EAAM/Y,EACNiZ,EAAM,GACa,cAAR3kB,GACXglB,GAAS,EACTP,EAAMpyB,GAAOqZ,GACbiZ,EAAMryB,GAAOoZ,KAEb+Y,EAAMl0B,GAAMmb,GACZiZ,EAAMn0B,GAAMkb,IAIZqZ,EADc,IAAVC,EACIh0B,GAEAV,GAGI,IAAR1H,EACJ,OAAK27B,EACG,CAAE,IAAIQ,EAAON,EAAKE,IAEnB,CAAE,IAAII,EAAOP,EAAKE,IAc1B,IAZAl+B,EAAM,CAAE,IAAIu+B,EAAOP,EAAKE,IAQxBE,GAAOH,EAAID,IAJV3vB,EADI0vB,EACA37B,EAAM,EAENA,GAGLi8B,GAAOF,EAAID,GAAQ7vB,EAGb1V,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBuR,EAAK8zB,EAAOI,EAAGzlC,EACfwR,EAAK+zB,EAAOG,EAAG1lC,EACfqH,EAAItC,KAAM,IAAI6gC,EAAOr0B,EAAIC,IAM1B,OAHK4zB,GACJ/9B,EAAItC,KAAM,IAAI6gC,EAAON,EAAKE,IAEpBn+B,CACR,CDQUy+B,CAAUllB,EAAKlM,EAAOmM,EAAK0L,EAAM9iB,EAAKyM,EAAKkvB,UExFrD,SAAmB1wB,EAAO6X,EAAM9iB,EAAK27B,GACpC,IAAI/9B,EACAqO,EACA2N,EACArjB,EAEJ,GAAa,IAARyJ,EACJ,MAAO,GAGR,GAAa,IAARA,EACJ,OAAK27B,EACG,CAAE7Y,GAEH,CAAE7X,GAaV,IAXArN,EAAM,CAAEqN,GAQR2O,GAAMkJ,EAAK7X,IAJVgB,EADI0vB,EACA37B,EAAM,EAENA,GAKCzJ,EAAI,EAAGA,EAAI0V,EAAG1V,IACnBqH,EAAItC,KAAM2P,EAAS2O,EAAErjB,GAMtB,OAHKolC,GACJ/9B,EAAItC,KAAMwnB,GAEJllB,CACR,CFuDS0+B,CAASrxB,EAAO6X,EAAM9iB,EAAKyM,EAAKkvB,UAGxC,GAAc,QADdj7B,EAAO+O,GAAOhD,EAAKhO,QAElB,MAAM,IAAInE,UAAWiB,EAAQ,6GAA8G,QAASkR,EAAKhO,QAG1J,GADAjI,EAAM,IAAIkK,EAAMV,GACI,cAAfyM,EAAKhO,MAET,OADA89B,GAAYlyB,GAAe7T,EAAK,GAAK2gB,EAAKlM,EAAOmM,EAAK0L,EAAM9iB,EAAKyM,EAAKkvB,UAC/DnlC,EAER,GAAoB,eAAfiW,EAAKhO,MAET,OADA89B,GAAYjyB,GAAgB9T,EAAK,GAAK2gB,EAAKlM,EAAOmM,EAAK0L,EAAM9iB,EAAKyM,EAAKkvB,UAChEnlC,EAER,GAAKqU,EACJ,MAAM,IAAIvQ,UAAW,4JAEtB,OAAOkiC,GAAWhmC,EAAKyU,EAAO6X,EAAM9iB,EAAKyM,EAAKkvB,SAC/C,CG1GA,SAAST,GAAU9kC,GAClB,IAAImR,SAAcnR,EAClB,OACW,OAAVA,GACU,WAATmR,GAA8B,aAATA,EAEf,IAAIjN,UAAWiB,EAAQ,8GAA+GnF,IAEvI,IACR,CCqBA+G,EAAAnH,GAAA,UCRA,SAAmBiV,EAAO6X,EAAMtsB,GAC/B,IAAIiW,EACAnQ,EACA6a,EACAC,EACAvM,EACA4xB,EACA5uB,EAEJ,GAAsB,iBAAV5C,EAAqB,CAEhC,GAAa,QADbkM,EAAM1Y,GAAOwM,IACO,CACnB,IAAM3C,GAAe2C,GACpB,MAAM,IAAI3Q,UAAWiB,EAAQ,yFAA0F0P,IAExHkM,EAAM,YACN,CACDtM,GAAM,CACR,KAAQ,KAAM1U,GAAU8U,IAAWtR,GAAOsR,GACxC,MAAM,IAAI3Q,UAAWiB,EAAQ,yFAA0F0P,IAEvHkM,EAAM,SACN,CACD,GAAqB,iBAAT2L,EAAoB,CAE/B,GAAa,QADb1L,EAAM3Y,GAAOqkB,IACO,CACnB,IAAMxa,GAAewa,GACpB,MAAM,IAAIxoB,UAAWiB,EAAQ,0FAA2FunB,IAEzH1L,EAAM,YACN,CACDvM,GAAM,CACR,KAAQ,KAAM1U,GAAU2sB,IAAUnpB,GAAOmpB,GACvC,MAAM,IAAIxoB,UAAWiB,EAAQ,0FAA2FunB,IAExH1L,EAAM,SACN,CACD,IAAMvR,GAAcrP,GACnB,MAAM,IAAI8D,UAAWiB,EAAQ,8EAA+E/E,IAK7G,GAHAiW,EAAO,CACNkvB,SAAYpO,IAER9yB,UAAU1D,OAAS,IACvBuF,EAAM4+B,GAAUzuB,EAAMhS,UAAW,KAEhC,MAAM6B,EAOR,GAHa,QADbmgC,EAAMC,GAAQlmC,MAEbimC,EAAM,WAEM,cAARA,EAEJ,OADAF,GAAYlyB,GAAe7T,EAAK,GAAK2gB,EAAKlM,EAAOmM,EAAK0L,EAAMtsB,EAAIO,OAAQ0V,EAAKkvB,UACtEnlC,EAER,GAAa,eAARimC,EAEJ,OADAF,GAAYjyB,GAAgB9T,EAAK,GAAK2gB,EAAKlM,EAAOmM,EAAK0L,EAAMtsB,EAAIO,OAAQ0V,EAAKkvB,UACvEnlC,EAER,GAAKqU,EAAM,CACV,GAAa,YAAR4xB,EAGJ,OCnFH,SAAmBjmC,EAAK2gB,EAAKlM,EAAOmM,EAAK0L,EAAM9iB,EAAK27B,GACnD,IAAIQ,EACAC,EACAR,EACAC,EACAC,EACAC,EACA9+B,EACAgN,EAGA+xB,EACAC,EACAhwB,EACA1V,EAEJ,GAAa,IAARyJ,EACJ,OAAOxJ,EAoCR,GAlCA4lC,EAAQ,EACK,YAARjlB,GACJykB,EAAM3wB,EACN6wB,EAAM,GACa,cAAR3kB,GACXilB,GAAS,EACTR,EAAMnyB,GAAOwB,GACb6wB,EAAMpyB,GAAOuB,KAEb2wB,EAAMj0B,GAAMsD,GACZ6wB,EAAMl0B,GAAMqD,IAEA,YAARmM,GACJykB,EAAM/Y,EACNiZ,EAAM,GACa,cAAR3kB,GACXglB,GAAS,EACTP,EAAMpyB,GAAOqZ,GACbiZ,EAAMryB,GAAOoZ,KAEb+Y,EAAMl0B,GAAMmb,GACZiZ,EAAMn0B,GAAMkb,IAIZqZ,EADc,IAAVC,EACIh0B,GAEAV,GAGTuC,EAAMzT,EAAI0X,KACVjR,EAAMzG,EAAIgX,UAAW,GAGR,IAARxN,EAMJ,OAJC/C,EAAKgN,EAAK,EADN0xB,EACS,IAAIQ,EAAON,EAAKE,GAEhB,IAAII,EAAOP,EAAKE,IAEvBtlC,EAcR,IAZAyG,EAAKgN,EAAK,EAAG,IAAIkyB,EAAOP,EAAKE,IAQ7BE,GAAOH,EAAID,IAJV3vB,EADI0vB,EACA37B,EAAM,EAENA,GAGLi8B,GAAOF,EAAID,GAAQ7vB,EAGb1V,EAAI,EAAGA,EAAI0V,EAAG1V,IAGnB0G,EAAKgN,EAAK1T,EAAG,IAAI4lC,EAFZP,EAAOI,EAAGzlC,EACVulC,EAAOG,EAAG1lC,IAIXolC,GACJ1+B,EAAKgN,EAAKgC,EAAG,IAAIkwB,EAAON,EAAKE,GAG/B,CDDGY,CADA9uB,EAAII,GAAkBzX,GACT2gB,EAAKlM,EAAOmM,EAAK0L,EAAMtsB,EAAIO,OAAQ0V,EAAKkvB,UAC9CnlC,EAER,MAAM,IAAI8D,UAAW,iKACrB,CAED,OADAuT,EAAII,GAAkBzX,IACfkX,kBElER,SAAmBlX,EAAKyU,EAAO6X,EAAM9iB,EAAK27B,GACzC,IAAI1xB,EACAhN,EACAgP,EACA2N,EACArjB,EAEJ,GAAa,IAARyJ,EACJ,OAAOxJ,EAOR,GAJAyT,EAAMzT,EAAI0X,KACVjR,EAAMzG,EAAIgX,UAAW,GAGR,IAARxN,EAMJ,OAJC/C,EAAKgN,EAAK,EADN0xB,EACS7Y,EAEA7X,GAEPzU,EAaR,IAXAyG,EAAKgN,EAAK,EAAGgB,GAQb2O,GAAMkJ,EAAK7X,IAJVgB,EADI0vB,EACA37B,EAAM,EAENA,GAKCzJ,EAAI,EAAGA,EAAI0V,EAAG1V,IACnB0G,EAAKgN,EAAK1T,EAAG0U,EAAS2O,EAAErjB,GAGpBolC,GACJ1+B,EAAKgN,EAAKgC,EAAG6W,EAGf,CFyBE8Z,CAAS/uB,EAAG5C,EAAO6X,EAAMtsB,EAAIO,OAAQ0V,EAAKkvB,UACnCnlC,IAERgmC,GAAWhmC,EAAKyU,EAAO6X,EAAMtsB,EAAIO,OAAQ0V,EAAKkvB,UACvCnlC,EACR,IGvHe,IAAAgG,GAAAvG,OAAO4mC,OCKtB,SAASC,KAET,CCSA,IAAAC,GATwB,mBAAZvgC,GACIA,GDehB,SAAuB8Y,GAEtB,OADAwnB,GAAK1lC,UAAYke,EACV,IAAIwnB,EACZ,EELInzB,GAAsBhB,KACtBq0B,GAAa,gBACbhF,GAAY,CACfr6B,QAAW,aACXG,QAAW,aACXC,MAAS,WACTC,MAAS,WACTE,OAAU,YACVC,OAAU,aAEP+5B,GAAe,CAClBC,EAAK,IACLj/B,EAAK,IACL3C,EAAK,KACL4pB,EAAK,IACLhT,EAAK,KAkGN,SAASqB,GAAS/P,GACjB,IAAI+J,EACA+vB,EACAE,EACAwE,EAsBJ,SAASvE,IACR,IAAIxuB,EAAQzP,UAAU1D,OACtB,OAAO8Q,gBAAgB6wB,GAYR,IAAVxuB,EACJ+yB,EAAO5kC,KAAMwP,KAAMm1B,IACE,IAAV9yB,EACX+yB,EAAO5kC,KAAMwP,KAAMm1B,GAAYviC,UAAU,IACpB,IAAVyP,EACX+yB,EAAO5kC,KAAMwP,KAAMm1B,GAAYviC,UAAU,GAAIA,UAAU,IAClC,IAAVyP,GACX+yB,EAAO5kC,KAAMwP,KAAMm1B,GAAYviC,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAE/DoN,MApBS,IAAVqC,EACG,IAAIwuB,EAEG,IAAVxuB,EACG,IAAIwuB,EAAYj+B,UAAU,IAEnB,IAAVyP,EACG,IAAIwuB,EAAYj+B,UAAU,GAAIA,UAAU,IAEzC,IAAIi+B,EAAYj+B,UAAU,GAAIA,UAAU,GAAIA,UAAU,GAY9D,CAuID,OAlLAwiC,EAASC,GAAoBz+B,GAE7B+J,EAAoBovB,GAAiBn5B,GACrC85B,EAvFD,SAAqB95B,GACpB,OAAOo5B,GAAYp5B,GAAU,SAC9B,CAqFam6B,CAAYn6B,GACxBg6B,EAAST,GAAWv5B,GAkDpBtB,EAAau7B,EAAY,oBAAqBlwB,GAW9CrL,EAAau7B,EAAY,OAAQH,GAkBjCp7B,EAAau7B,EAAY,QAAQ,SAAejuB,GAC/C,IAAIC,EACAR,EACAS,EACAnU,EACAyT,EACAW,EACA5N,EACAgD,EACAzJ,EACJ,IAAMiR,GAAYK,MACjB,MAAM,IAAIvN,UAAW,6DAEtB,IAAMu+B,EAAyBhxB,MAC9B,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAGpG,IADAruB,EAAQzP,UAAU1D,QACL,EAAI,CAEhB,IAAMyQ,GADNmD,EAAOlQ,UAAW,IAEjB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsEoP,IAE/FT,EAAQ,IACZQ,EAAUjQ,UAAW,GAEtB,CACD,GAAKoL,GAAc4E,GAAQ,CAC1B,GAAKE,EAAO,CASX,IARA3K,EAAMyK,EAAI1T,OAETiG,EADIyN,EAAIzN,KAAOyN,EAAIxN,IACb6N,EAAgB,WAEhBtM,EAAQ,WAGfyL,GADAzT,EAAM,IAAIqR,KAAM7H,IACN8J,QACJvT,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB0T,EAAKwuB,GAAUliC,EAAEiS,EAAmBmC,EAAKtS,KAAMqS,EAAS1N,EAAKyN,EAAKlU,GAAKA,IAAK,GAE7E,OAAOC,CACP,CACD,OAAO,IAAIqR,KAAM4C,EACjB,CACD,GAAK1F,GAAU0F,IAASd,IAAuBnC,GAAYiD,EAAKD,KAAsB,CAErF,IAAMhD,IADNyC,EAAMQ,EAAKD,OACWjB,MACrB,MAAM,IAAIjP,UAAWiB,EAAQ,6FAA8FkP,IAU5H,IAPCG,EADID,ECvQR,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIlU,EACAkJ,EACAnJ,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI4J,EAAGC,QACAC,MAGPjT,GAAK,EACLC,EAAI8E,KAAMqP,EAAKtS,KAAMqS,EAAShL,EAAEtJ,MAAOG,IAExC,OAAOC,CACR,CDwPUuU,CAAiBd,EAAKU,EAAMD,GE1QtC,SAAuBpB,GACtB,IAAI9S,EACAkJ,EAGJ,IADAlJ,EAAM,KAELkJ,EAAI4J,EAAGC,QACAC,MAGPhT,EAAI8E,KAAMoE,EAAEtJ,OAEb,OAAOI,CACR,CF+PU6S,CAAcY,GAIrBA,GADAzT,EAAM,IAAIqR,KADV7H,EAAM4K,EAAI7T,SAEA+S,QACJvT,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB0T,EAAKwuB,GAAUliC,EAAEiS,EAAmBoC,EAAKrU,IAAK,GAE/C,OAAOC,CACP,CACD,MAAM,IAAI8D,UAAWiB,EAAQ,6FAA8FkP,GAC7H,IAcCtN,EAAau7B,EAAY,MAAM,WAC9B,IAAIl9B,EACAjF,EACJ,IAAMiR,GAAYK,MACjB,MAAM,IAAIvN,UAAW,6DAEtB,IAAMu+B,EAAyBhxB,MAC9B,MAAM,IAAIvN,UAAWiB,EAAQ,2CAA4C28B,GAAcz5B,EAAM,IAAM85B,IAGpG,IADA/8B,EAAO,GACDjF,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAClCiF,EAAKF,KAAMb,UAAWlE,IAEvB,OAAO,IAAIsR,KAAMrM,EACnB,IGjRA,SAAkBkF,EAAMy8B,GACvB,IAAI7gC,EAAM4+B,GAAUx6B,GACpB,GAAKpE,EACJ,MAAMA,EAGP,GADAA,EAAM4+B,GAAUiC,GAEf,MAAM7gC,EAEP,QAAoC,IAAxB6gC,EAAU/lC,UACrB,MAAM,IAAIkD,UAAWiB,EAAQ,8GAA+G4hC,EAAU/lC,YAGvJsJ,EAAKtJ,UAAYgmC,GAAcD,EAAU/lC,WAGzClB,EAAgBwK,EAAKtJ,UAAW,cAAe,CAC9CgG,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASsK,GAIX,CH4PC28B,CAAU3E,EAAYuE,GAEfvE,EASP,SAASG,EAAyBziC,GACjC,OAASA,IAAUsiC,CACnB,CACF,CIrQA,IAAI4E,GAAiB9uB,GAAS,WCA1B+uB,GAAiB/uB,GAAS,WCnD9B,SAASgvB,GAAgBp4B,GACxB,OAAc,IAANA,GAAa,EAAIA,IAAMC,EAChC,CCaA,IAAIo4B,GAA6B,qBCL7BC,GAA2B,SCA3BC,IAA4B,SCFhC,SAASC,GAAkBxnC,GAC1B,OAAKA,GAAUA,GAASA,IAAUiM,IAAQjM,IAAUiP,GAC5C,UAEHF,GAAW/O,GACVA,GAASunC,IAA4BvnC,GAASsnC,GAC3C,UAED,UAIPtnC,GAASqnC,IACTrnC,EAAQqnC,GAED,UAGD,SACR,CAmBA,SAASI,GAAaznC,GACrB,OAAMD,GAAUC,GAYXA,GAAUA,GAASA,IAAUiM,IAAQjM,IAAUiP,GAC5C,UAEHF,GAAW/O,GACA,IAAVA,GAAeonC,GAAgBpnC,GAC5B,UAEHA,EAAQ,EACPA,GAASoO,GACN,OAEHpO,GAASqN,GACN,QAEHrN,GAAS0M,GACN,QAED,UAEH1M,GAAS0N,GACN,QAEH1N,GAAS+M,GACN,SAEH/M,GAASoM,GACN,SAED,UAIPpM,GAASqnC,IACTrnC,EAAQqnC,GAED,UAGD,UAjDDp3B,GAAWjQ,GACR,OAEHkS,GAAelS,GACmB,YAAjCwnC,GAAkBxnC,EAAM0R,KAAuD,YAAjC81B,GAAkBxnC,EAAM2R,IACnE,aAED,YAED,SAyCT,CCjFA,SAASuhB,GAAWlkB,EAAGmkB,GACtB,IAAI9b,EACJ,IAAM5H,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,8EAA+E6J,IAE7G,IAAMS,GAAc0jB,GACnB,MAAM,IAAIjvB,UAAWiB,EAAQ,+EAAgFguB,IAE9G,GAAKnkB,EAAErO,SAAWwyB,EAAKxyB,OACtB,MAAM,IAAIgB,MAAOwD,EAAQ,qEAG1B,MAAY,aADZkS,EAAKhP,GAAO2G,KACoB,OAAPqI,EACjB/V,GAAM0N,EAAGmkB,GAEV7xB,GAAKyY,OAAQ/K,EAAGmkB,EAAMlzB,GAAO4rB,GAAasH,GAAQ9b,GAAM,EAAG,EACnE,CC5CA,IAAIsd,GAAQ,CACX,SACA,aACA,mBACA,YACA,UAEG+S,GAASvvB,GAAUwc,ICqBvB,SAASb,GAAW9kB,EAAGmkB,GACtB,IAAI9b,EACJ,IAAM5H,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,8EAA+E6J,IAE7G,IAAMS,GAAc0jB,GACnB,MAAM,IAAIjvB,UAAWiB,EAAQ,+EAAgFguB,IAE9G,GAAKnkB,EAAErO,SAAWwyB,EAAKxyB,OACtB,MAAM,IAAIgB,MAAOwD,EAAQ,qEAG1B,MAAY,aADZkS,EAAKhP,GAAO2G,KACoB,OAAPqI,EACjB/V,GAAM0N,EAAGmkB,GAEV7xB,GAAKyY,OAAQ/K,EAAGmkB,EAAMlzB,GAAOsrB,GAAY4H,GAAQ9b,GAAM,EAAG,EAClE,CCzCA,IAAIswB,GAAO,IAAIr2B,GAAY7F,IAAKA,KAC5Bm8B,GAAM,IAAI51B,GAAWvG,IAAKA,KAC1BwL,GAASmF,GAAQ,8BACjByrB,GAAe1vB,GAAUlB,IACzB+gB,GAAgBb,GAASvwB,IAAK,8BCN9B+gC,GAAO,IAAIr2B,GAAY7F,IAAKA,KAC5Bm8B,GAAM,IAAI51B,GAAWvG,IAAKA,KAC1BwL,GAAS,CAAE,UAAW,UAAW,aAAc,YAAa,kMCF5D+gB,GAAgBb,GAASvwB,IAAK,kBAsBlC,SAASotB,GAAO9zB,GACf,IAAImI,EACJ,IAAM+G,GAAsBlP,GAC3B,MAAM,IAAIgE,UAAWiB,EAAQ,+EAAgFjF,IAE9G,GAAKmE,UAAU1D,OAAS,GAEvB,GAAe,aADf0H,EAAQhE,UAAW,IAElB,OAAO/C,GAAMpB,QAGdmI,EAAQ2vB,GAET,OAAO12B,GAAKyY,OAAQ9Z,GAAOC,EAAGmI,GAAS,EAAG,EAC3C,CCrCA,IAAIs/B,GAAO,IAAIr2B,GAAY,EAAK,GAC5Bs2B,GAAM,IAAI51B,GAAW,EAAK,GAC1BgmB,GAAgBb,GAASvwB,IAAK,kBCD9B+gC,GAAO,IAAIr2B,GAAY,EAAK,GAC5Bs2B,GAAM,IAAI51B,GAAW,EAAK,GCF1B2iB,GAAQ,CACX,SACA,aACA,mBACA,YACA,UAEG+S,GAASvvB,GAAUwc,ICqDvB,SAASV,GAAOjlB,EAAGmkB,EAAM3c,GACxB,IAAIH,EACAnQ,EACA8oB,EACA8Y,EACJ,IAAMr4B,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,8EAA+E6J,IAE7G,IAAMS,GAAc0jB,GACnB,MAAM,IAAIjvB,UAAWiB,EAAQ,+EAAgFguB,IAE9G,IAAM1jB,GAAc+G,GACnB,MAAM,IAAItS,UAAWiB,EAAQ,8EAA+EqR,IAG7G,GADAH,ECvEO,CACNqa,KAAQ,UDuEJrsB,UAAU1D,OAAS,IACvBuF,ED7CF,SAAmBmQ,EAAMD,GACxB,OAAMzH,GAAUyH,GAGXpN,GAAYoN,EAAS,UACzBC,EAAKqa,KAAOta,EAAQsa,MACdgX,GAAQrxB,EAAKqa,OACX,IAAIxsB,UAAWiB,EAAQ,gFAAiF,OAAQwvB,GAAMpf,KAAM,QAAUc,EAAKqa,OAG7I,KARC,IAAIxsB,UAAWiB,EAAQ,qEAAsEiR,GAStG,CCkCQ0uB,CAAUzuB,EAAMhS,UAAW,IAC5B6B,GACJ,MAAMA,EAOR,GAJA8oB,EAAM3mB,GAAO2G,IAAO,WAIdqS,GAHNymB,EAAMz/B,GAAOmO,IAAY,UAGIwY,GAC5B,MAAM,IAAI9qB,UAAWiB,EAAQ,6GAA8G2iC,EAAK9Y,IAOjJ,OAJKG,GAAmBH,IAASvN,GAAgBqmB,KAChDtxB,EAASiY,GAASjY,EAAQwY,IAGpB1tB,GAAM0N,EAAGmkB,EAAM3c,EAAQH,EAAKqa,KACpC,CErFA,IAAIrX,GAAQ,CACX9R,QAAWmD,GACXhD,QAAW+C,GACX7C,MAAS+C,GACThD,MAASiD,GACT/C,KAAQgD,GACR9C,OAAU+C,GACVhD,OAAUiD,GACV/C,MAASgD,GACT/C,OAAUgD,GACVxC,UAAayC,GACb1C,WAAc2C,GACdI,KAAQH,ICVT,SAASiO,GAAOhR,GACf,OAAOgmB,GAAOhmB,IAAW,IAC1B,CCOA,IAAI0/B,GAAQ,iBACRC,GAAU,mBACVC,GAAU,uBAGVC,GAAsB,WAGtBhiB,GAAsB,QAGtBC,GAAoB,WAGpBd,GAAQ,CAAE,EAAK,GAmCnB,SAAS8iB,GAAMn5B,GACd,IAAIo5B,EACAC,EACAC,EACA/iB,EACAgjB,EACAC,EACAC,EACA3lC,EACA4lC,EACA5qB,EACA/E,EACA5Y,EACA6d,EAEJ,GAAKza,GAAOyL,IAAOA,EAAI,EACtB,OAAOvD,IAMR,GAJAoO,GAAQE,OAAQ/K,EAAGqW,GAAO,EAAG,GAC7BE,EAAkB,EAAbF,GAAO,GACZkjB,EAAKljB,GAAO,GACZrH,EAAI,EACCuH,EAAKW,GAAsB,CAE/B,GAAgC,IAAxBX,EAAGE,GAAY8iB,GACtB,OAAOt5B,GAER+O,GAAK,GAILuH,EAAwB,EAAnBN,GADLjW,GAAK+4B,GAEL,CACD,OAAKxiB,GAAM2iB,GACHl5B,EAAIA,EAGPuW,IAAOY,IAA4B,IAAPoiB,EACzB,GAERvqB,IAAQuH,GAAI,IAAMwC,GAAO,EAOzBhP,EADAiF,IAJA7d,EAAW,QADXolB,GAAMU,IACiBC,GAAsB,IAIpC,GAAI,EAGboiB,EAAO,IADPxlC,GAHAkM,EAAI8W,GAAa9W,EAAGuW,EAAIplB,EAAEgmB,KAGlB,GACSrjB,EACjB4lC,EChBD,SAAsB5lC,GACrB,IACIgnB,EACAD,EACAkB,EACApY,EAEAmL,ECxGc9O,EDiHlB,OAJA8a,GADAhM,GADAnL,GADAoY,EAAIjoB,GAAM,EAAMA,IACRioB,GACApY,IC3GG,KADO3D,ED6GC8O,GC3GX,kBAED,kBAAsB9O,GAAK,mBAA2B,mBAAJA,ID0GzD6a,EAAKlX,EE9GN,SAAmB3D,GAClB,OAAW,IAANA,EACG,kBAED,kBAAsBA,GAAK,kBAAsBA,GAAK,kBAA0B,mBAAJA,GACpF,CFyGU25B,CAAU7qB,GAGZiN,GADA,GAAMjoB,EAAIA,GADb+mB,EAAKC,GAGV,CDDK8e,CAAa9lC,GAejBulC,IAFAI,EAAO3lC,GADP0lC,EAAK5jB,GADL4jB,EAAK1lC,EAAIwlC,EACY,IACHA,EAAOI,GAERF,GAAOP,GAAcQ,EAAKT,IAG3CK,GAAWtvB,GADX+E,EAAI/E,GAHJqvB,EAAQI,EAAKR,KAIQI,IACrBA,EAAQtqB,GAGT,yHIpHIka,GAAgB6Q,GAAejiC,IAAK,kBACpCsE,GAAiBmO,GAAO,aACxBlO,GAAkBkO,GAAO,cACzBjO,GAAeiO,GAAO,QAY1B,SAASyvB,GAAgBthC,GACxB,OAASA,aAAe0D,EACzB,CASA,SAAS69B,GAAiBvhC,GACzB,OAASA,aAAe2D,EACzB,CASA,SAAS69B,GAAaxhC,GACrB,OAASA,aAAe4D,EACzB,CA6BA,SAASgN,GAAShC,GACjB,IAAI6yB,EACAC,EACA7yB,EACAnQ,EAGJ,GADAmQ,EChGO,CACN8yB,cAAiB,kBDgGb9kC,UAAU1D,SACduF,EElFF,SAAmBmQ,EAAMD,GACxB,OAAMzH,GAAUyH,GAGXpN,GAAYoN,EAAS,mBACzBC,EAAK8yB,cAAgB/yB,EAAQ+yB,eACvB/5B,GAAsBiH,EAAK8yB,gBACzB,IAAIjlC,UAAWiB,EAAQ,2EAA4E,gBAAiBkR,EAAK8yB,gBAG3H,KARC,IAAIjlC,UAAWiB,EAAQ,qEAAsEiR,GAStG,CFuEQ0uB,CAAUzuB,EAAMD,GACjBlQ,GACJ,MAAMA,EAaR,OAVAgjC,EG3GD,SAAehpC,GACd,IAAIE,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAID,EAAE,EAAGC,IACrBC,EAAI8E,KAAM,IAEX,OAAO9E,CACR,CHkGQgpC,CAAYlc,GAAMib,GAAM9xB,EAAK8yB,iBACpCF,EAAS,EAETliC,EAAasiC,EAAQ,SAAUA,GAC/BtiC,EAAasiC,EAAQ,UAiKrB,WACC,IAAIv1B,EACA1T,EACAoU,EACArU,EAUJ,GAAa,QANZC,EADc,KADf0T,EAAQzP,UAAU1D,QAEX0oC,IACe,IAAVv1B,EACLu1B,EAAQhlC,UAAW,IAEnBglC,EAAQhlC,UAAW,GAAKA,UAAW,KAazC,IARCmQ,EADIu0B,GAAiB3oC,GACf8T,GAAgB9T,EAAK,GAChB0oC,GAAgB1oC,GACrB6T,GAAe7T,EAAK,GACf4oC,GAAa5oC,GAClB2iB,GAAoB3iB,EAAK,GAEzBA,EAEDD,EAAI,EAAGA,EAAIqU,EAAI7T,OAAQR,IAC5BqU,EAAKrU,GAAM,EAGb,OAAOC,CACP,IA9LD2G,EAAasiC,EAAQ,QA4MrB,SAAex1B,GACd,IAAI3T,EACAse,EACAre,EI1RqBH,EClBbgP,EAAG+J,EL6Sf,GIzRU,QAFe/Y,EJ2RF6T,IIxRN,iBAAV7T,GACPoP,GAAsBpP,EAAMW,SAC5BX,EAAMW,QAAU2oC,IACmB,iBAA5BtpC,EAAMoS,mBACe,iBAArBpS,EAAM+S,YACe,iBAArB/S,EAAMmU,YJmRmBN,EAAIf,OACnCe,EAAMA,EAAIf,YACJ,IAAMlD,GAAeiE,GAC3B,MAAM,IAAI3P,UAAWiB,EAAQ,4EAA6E0O,IAE3G,GAAKA,EAAIM,WAAa,EAAI,CAQzB,IAPAjU,EAAI4O,GAAOq5B,GAAMt0B,EAAIM,aKnTVnF,ELsTFk6B,EAAKvoC,OAAO,EKtTPoY,ELsTU7Y,EAAxBA,EKrTGqD,GAAOyL,IAAOzL,GAAOwV,GAClBtN,IAEHuD,IAAMC,IAAQ8J,IAAM9J,GACjBA,GAEHD,IAAM+J,GAAW,IAAN/J,EACVo4B,GAAgBp4B,GACbA,EAED+J,EAEH/J,EAAI+J,EACD/J,EAED+J,ELySLyF,EAAI0qB,EAAMhpC,GACJC,EAAI,EAAGA,EAAIqe,EAAE7d,OAAQR,IAC1B,GAAKqe,EAAGre,KAAQ0T,EACf,OAAO,EAIT2K,EAAEtZ,KAAM2O,EACR,CACD,OAAO,CACP,IArOD9M,EAAasiC,EAAQ,SA4OrB,WACC,IAAIlpC,EACJ,IAAMA,EAAI,EAAGA,EAAI+oC,EAAKvoC,OAAQR,IAC7B+oC,EAAM/oC,GAAIQ,OAAS,EAEpBsoC,EAAS,CACT,IAjPDliC,EAAasiC,EAAQ,gBAAiBhzB,EAAK8yB,eAC3ClM,GAAqBoM,EAAQ,UAU7B,WACC,OAAOJ,CACP,IAVMI,EAmDP,SAASp4B,EAAY3G,EAAMV,EAAKvB,GAC/B,IAAIwL,EMjJU7E,EACXjN,EACAyc,ENgJH,OAAa,IAAR5U,EACG,IAAIU,EAAM,IAElBuJ,EArCD,SAAsB3T,GACrB,IAAI2T,EACA1T,EAMJ,OAHAA,EAAIgoC,GAAMjoC,IAGDgpC,EAAKvoC,QAAUuoC,EAAM/oC,GAAIQ,OAC1BuoC,EAAM/oC,GAAImkC,MAGb2E,EAAO/oC,EAAImW,EAAK8yB,cACb,MAERt1B,EAAM,IAAIlE,GAAazP,GAGvB+oC,GAAU/oC,EAEH2T,EACP,CAgBM01B,EMjJNhmC,GAJcyL,ENqJYpF,IMhJ1Bsa,GAAYlV,IACN,IAANA,EAEOA,GAEHA,EAAI,GACRA,GAAKA,EACLjN,GAAQ,GAERA,EAAO,GAGRyc,EAAI2pB,GAAMn5B,MAGCw6B,GACHx6B,GAIPwP,GADc,IAAVzc,EACA+M,GAAO0P,GAEP0O,GAAM1O,IAGFirB,GACDx9B,GAEDlK,EAAOknB,GAAK,EAAKzK,KNoHSpM,GAAmB/J,IACtC,OAARwL,EACGA,EAED,IAAIvJ,EAAMuJ,EAAK,EAAGjK,GACzB,CAkBD,SAASy/B,IACR,IAAIv1B,EACAzL,EACAiC,EACA9C,EACApH,EACAyG,EACAD,EACAgD,EACAzJ,EO9LsBH,EPwM1B,GAAc,QADdsK,EAAO+O,GAJNhR,GAHDyL,EAAQzP,UAAU1D,SACJkP,GAAUxL,UAAWyP,EAAM,IAEhCzP,UADRyP,GAAS,GAGDkkB,KAIR,MAAM,IAAI9zB,UAAWiB,EAAQ,sEAAuEkD,IAErG,GAAKyL,GAAS,EACb,OAAO,IAAIxJ,EAAM,GAGlB,GAAK8E,GAAsB/K,UAAW,IACrC,OAAO4M,EAAY3G,EAAMjG,UAAW,GAAKgE,GAG1C,GAAKoH,GAAcpL,UAAW,IAAQ,CAcrC,GAZAuF,GADApC,EAAMnD,UAAW,IACP1D,QOrNeX,EPsNDwH,aOpNR2D,IACY,oBAA7Bf,GAAiBpK,GPoNfwH,EAAM0M,GAAgB1M,EAAK,GQvN/B,SAA2BxH,GAC1B,OACCA,aAAiBkL,IACY,mBAA7Bd,GAAiBpK,EAEnB,CRmNeqS,CAAkB7K,GAC7BA,EAAMyM,GAAezM,EAAK,GACfmP,GAAgBnP,GAC3BA,EAAMub,GAAoBvb,EAAK,GACpB2nB,GAAmB9mB,KAE9BuB,GAAO,GAGK,QADbxJ,EAAM6Q,EAAY3G,EAAMV,EAAKvB,IAE5B,OAAOjI,EAER,GAAK2oC,GAAiB3oC,IAAS0oC,GAAgB1oC,IAAS4oC,GAAa5oC,GAEpE,OADAA,EAAIyG,IAAKW,GACFpH,EAKR,IAFAwG,EAAMqR,GAAezQ,GACrBX,EAAM+uB,GAAex1B,GACfD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB0G,EAAKzG,EAAKD,EAAGyG,EAAKY,EAAKrH,IAExB,OAAOC,CACP,CACD,MAAM,IAAI8D,UAAWiB,EAAQ,wGAAyGd,UAAW,IACjJ,CAoGF,CSxUA,IAAIqlC,GAAiBtxB,KCPrBrR,EAAAnH,GAAA,UAAAwY,w2FC2BA,SAAS4c,GAAKhmB,EAAG4K,EAASpD,GACzB,IAAIH,EACAnQ,EACA8oB,EACA8Y,EACJ,IAAMr4B,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,8EAA+E6J,IAE7G,IAAMS,GAAcmK,GACnB,MAAM,IAAI1V,UAAWiB,EAAQ,+EAAgFyU,IAE9G,IAAMnK,GAAc+G,GACnB,MAAM,IAAItS,UAAWiB,EAAQ,8EAA+EqR,IAG7G,GADAH,EC1DO,CACNqa,KAAQ,aD0DJrsB,UAAU1D,OAAS,IACvBuF,EE3CF,SAAmBmQ,EAAMD,GACxB,OAAMzH,GAAUyH,GAGXpN,GAAYoN,EAAS,UACzBC,EAAKqa,KAAOta,EAAQsa,MACdqE,GAAa1e,EAAKqa,OAChB,IAAIxsB,UAAWiB,EAAQ,gFAAiF,OAAQuvB,KAAQnf,KAAM,QAAUc,EAAKqa,OAG/I,KARC,IAAIxsB,UAAWiB,EAAQ,qEAAsEiR,GAStG,CFgCQ0uB,CAAUzuB,EAAMhS,UAAW,IAC5B6B,GACJ,MAAMA,EAOR,GAJA8oB,EAAM3mB,GAAO2G,IAAO,WAIdqS,GAHNymB,EAAMz/B,GAAOmO,IAAY,UAGIwY,GAC5B,MAAM,IAAI9qB,UAAWiB,EAAQ,6GAA8G2iC,EAAK9Y,IAOjJ,OAJKG,GAAmBH,IAASvN,GAAgBqmB,KAChDtxB,EAASiY,GAASjY,EAAQwY,IAGpB1tB,GAAM0N,EAAG4K,EAASpD,EAAQH,EAAKqa,KACvC,CGzEA,IAAIrX,GAAQ,CACX3O,aAAgBA,GAChBD,aAAgBA,GAChBG,WAAcA,GACdG,YAAeA,GACfJ,WAAcA,GACdG,YAAeA,GACfD,UAAaA,GACbG,WAAcA,GACdC,kBAAqBA,GACrBC,eAAkBA,GAClBC,gBAAmBA,GACnBC,aAAgBA,ICdjB,SAASgY,GAASb,EAAO/a,GACxB,IAAI8B,EAAI9B,EAAK,GAKb,OAJK8H,GAAmBhG,KACvBiZ,EAAMrd,KAAMoE,EAAE3I,QACdyiB,GAASb,EAAOjZ,IAEViZ,CACR,CAaA,SAASpE,GAAOkF,EAAOd,EAAOiB,EAAGhc,EAAKiN,GACrC,IAAI7K,EACAN,EACAnJ,EAMJ,IAHAyJ,EAAM2Y,EAAOiB,GAGPrjB,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAAM,CAIlC,IAAMmP,GAHNhG,EAAI9B,EAAKrH,KAGuBmJ,EAAE3I,SAAWiJ,EAE5C,OAAO4Z,EAGR,GAAK/O,IACJnL,EAAI6U,GAAOkF,EAAOd,EAAOiB,EAAE,EAAGla,EAAGka,EAAE,EAAIH,EAAM,IACpCA,EAER,OAAO/Z,CAGT,CACD,OAAO+Z,CACR,CCxDA,IAAIsmB,GAAsD,mBAAtBC,kBAyBpC,SAASC,GAAqB7pC,GAC7B,OACG2pC,IAAwB3pC,aAAiB4pC,mBAClB,+BAAzBxgC,GAAapJ,EAEf,CCnCA,ICwBIsK,GDxBA1K,GAAsC,mBAAtBgqC,kBAAqCA,kBAAoB,KEAzEt/B,GAAsC,mBAAtBs/B,kBAAqCA,kBAAoB,KD4B5Et/B,GEbD,WACC,IAAIiB,EACAu+B,EACAC,EAEJ,GAAwC,mBAA5BC,GACX,OAAO,EAGR,IAECD,GADAD,EAAK,IAAIE,GAAyB,KAC1BhlC,MAAO,EAAG,GAClBuG,EACCs+B,GAAqBC,IACrBD,GAAqBE,IACH,KAAlBD,EAAG31B,YACe,IAAlB41B,EAAG51B,UAEJ,CAAC,MAAQjO,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CFZK0+B,GACG7jC,GGpBR,SAAmB8jC,GAClB,MAAM,IAAIvoC,MAAO,sPAClB,EH0BA,IAAAwoC,GAAe7/B,GIHf,SAASurB,GAAM7mB,EAAG4K,GACjB,IAAIvD,EACAnQ,EACAmR,EACJ,IAAM5H,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,8EAA+E6J,IAE7G,IAAMS,GAAcmK,GACnB,MAAM,IAAI1V,UAAWiB,EAAQ,+EAAgFyU,IAG9G,GADAvD,EC9BO,CACNqa,KAAQ,aD8BJrsB,UAAU1D,OAAS,IACvBuF,EEfF,SAAmBmQ,EAAMD,GACxB,OAAMzH,GAAUyH,GAGXpN,GAAYoN,EAAS,UACzBC,EAAKqa,KAAOta,EAAQsa,MACdqE,GAAa1e,EAAKqa,OAChB,IAAIxsB,UAAWiB,EAAQ,gFAAiF,OAAQuvB,KAAQnf,KAAM,QAAUc,EAAKqa,OAG/I,KARC,IAAIxsB,UAAWiB,EAAQ,qEAAsEiR,GAStG,CFIQ0uB,CAAUzuB,EAAMhS,UAAW,IAC5B6B,GACJ,MAAMA,EAIR,MAAY,aADZmR,EAAKhP,GAAO2G,KACoB,OAAPqI,EACjB/V,GAAM0N,EAAG4K,EAASvD,EAAKqa,MAExBpvB,GAAKyY,OAAQ/K,EAAG4K,EAASvD,EAAKqa,KAAMzwB,GAAO2Z,EAAQjZ,OAAQ0W,GAAM,EAAG,EAC5E,CGzCA,ICmBI+yB,GDnBAC,GAAOC,KEcPF,GAA2B,oBAAVG,MAA0B,KAAOA,MDSrDH,GErBD,WACC,IAAI7+B,EACJ,IACC8+B,GAAM,wPACN9+B,GAAO,CACP,CAAC,MAAQrF,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CFSKi/B,GACIpkC,GGTT,SAAgBwO,GAEf,OAAOA,CACR,EHcA,IItBImF,GJsBJ0wB,GAAeL,GKpCX7+B,GAAO6F,GAAYvR,OAAOka,QCsB1BA,GAASla,OAAOka,OC3BhBxO,QAAiD,IAAjC1L,OAAO6qC,sBCKvBC,GAAkB9qC,GAAO6qC,sBCuB7BC,GATKvsB,GDKL,SAAgCpe,GAC/B,OAAO2qC,GAAiB9qC,GAAQG,GACjC,EEXA,WACC,MAAO,EACR,ECKA,SAAS4qC,GAAsB5qC,GAC9B,IAAII,EACAoU,EACArU,EAIJ,IAFAC,EAAMoV,GAAMxV,GACZwU,EAAMm2B,GAAiB3qC,GACjBG,EAAI,EAAGA,EAAIqU,EAAI7T,OAAQR,IACvB0qC,GAAc7qC,EAAOwU,EAAKrU,KAC9BC,EAAI8E,KAAMsP,EAAKrU,IAGjB,OAAOC,CACR,CPdC2Z,GADI+wB,GACKlrC,GQWV,SAAiBgV,GAChB,IAAIqL,EACAzK,EACA+J,EACA3V,EACA2X,EACAphB,EACA8D,EACJ,GAAK2Q,QACJ,MAAM,IAAI1Q,UAAWiB,EAAQ,2EAA4EyP,IAG1G,IADA2M,EAAK1hB,GAAQ+U,GACPzU,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAElC,GAAK8f,OADLA,EAAS5b,UAAWlE,IAOpB,IADAyJ,GADA4L,EAAOo1B,GAAsB/qC,GAAQogB,KAC1Btf,OACLsD,EAAI,EAAGA,EAAI2F,EAAK3F,IAErBsd,EADAhC,EAAM/J,EAAMvR,IACAgc,EAAQV,GAGtB,OAAOgC,CACR,ER7BA,IAAAwpB,GAAehxB,GShBf,SAASixB,GAAahrC,GAErB,OAAKD,GAAUC,GACP,CAAEA,EAAO,GAGVA,CACR,CAYA,SAASirC,GAAS5iC,GACjB,OAAK8mB,GAAmB9mB,GAChB2iC,GAED,IACR,CC3BA,SAASC,GAASC,EAAa70B,GAC9B,OASA,SAAerH,GACd,OAAOk8B,EAAal8B,EAAGqH,EACvB,CACF,CCXA,IAAI80B,GAAgC,mBAAVZ,GCiB1B,SAASzF,GAAUzuB,EAAMD,GACxB,OAAMzH,GAAUyH,GAGXpN,GAAYoN,EAAS,YACzBC,EAAK2W,OAAS5W,EAAQ4W,QAChB/c,GAAWoG,EAAK2W,SACd,IAAI9oB,UAAWiB,EAAQ,+DAAgE,SAAUkR,EAAK2W,UAG1GhkB,GAAYoN,EAAS,WACzBC,EAAKkuB,MAAQnuB,EAAQmuB,MChBFvkC,EDiBDqW,EAAKkuB,MCjBGt7B,EDiBI,MChB1BjJ,UAGLA,EAAQH,GAAQG,GACS,iBAAbiJ,IACXA,EAAWlI,OAAQkI,IAGjBA,KAAYjJ,GACdoR,GAAYpR,EAAOiJ,MDWb,KAHE,IAAI/E,UAAWiB,EAAQ,sEAAuE,QAAS,MAAOkR,EAAKkuB,QAXpH,IAAIrgC,UAAWiB,EAAQ,qEAAsEiR,ICPtG,IAAqBpW,EAAOiJ,CDsB5B,CEjBA,SAASmiC,KACR,OAAO,IACR,CAoBA,SAASC,GAAiBrrC,EAAOqI,GAChC,OAAK4H,GAAWjQ,GACR,KAED,IAAIkE,UAAWiB,EAAQ,sHAAuHnF,EAAOqI,GAC7J,CAoBA,SAASijC,GAAsBtrC,EAAOqI,GACrC,OAAKtI,GAAUC,GACP,KAEHkS,GAAelS,GACZ,IAAIkE,UAAWiB,EAAQ,+GAAgHomC,GAAiBvrC,GAASqI,IAElK,IAAInE,UAAWiB,EAAQ,sHAAuHnF,EAAOqI,GAC7J,CAoBA,SAASmjC,GAAyBxrC,EAAOqI,GACxC,OAAKtI,GAAUC,IAAWkS,GAAelS,GACjC,KAED,IAAIkE,UAAWiB,EAAQ,sHAAuHnF,EAAOqI,GAC7J,CAkBA,SAASojC,GAAuBzrC,EAAOqI,GACtC,IAAIy/B,EACJ,OAAK/nC,GAAUC,GACR+O,GAAW/O,GAIZ6hB,GADLimB,EAAM7U,GAA0BjzB,GACVqI,GACd,KAED,IAAInE,UAAWiB,EAAQ,+GAAgH2iC,EAAKz/B,IAN3I,IAAInE,UAAWiB,EAAQ,+GAAgHsiC,GAAaznC,GAASqI,IAQjK6J,GAAelS,GACZ,IAAIkE,UAAWiB,EAAQ,+GAAgHomC,GAAiBvrC,GAASqI,IAElK,IAAInE,UAAWiB,EAAQ,sHAAuHnF,EAAOqI,GAC7J,CAkBA,SAASqjC,GAAyB1rC,EAAOqI,GACxC,IAAIy/B,EACJ,OAAK/nC,GAAUC,GAET6hB,GADLimB,EAAML,GAAaznC,GACGqI,GACd,KAED,IAAInE,UAAWiB,EAAQ,+GAAgH2iC,EAAKz/B,IAE/I6J,GAAelS,GACZ,IAAIkE,UAAWiB,EAAQ,+GAAgHomC,GAAiBvrC,GAASqI,IAElK,IAAInE,UAAWiB,EAAQ,sHAAuHnF,EAAOqI,GAC7J,CAqBA,SAASsjC,GAAWtjC,GACnB,MAAe,YAAVA,GAAiC,KAAVA,EACpB+iC,GAEHQ,GAAwBvjC,GACrBijC,GAEHrpB,GAA2B5Z,GACxBqjC,GAEH1pB,GAAyB3Z,GACtBojC,GAEHlvB,GAAmBlU,GAChBgjC,GAGDG,EACR,CC3MA,SAASpzB,GAAS8yB,EAAa70B,GAC9B,OAWA,SAAsBzB,EAAQxP,GAC7B,IAAI4J,EACA8H,EAGJ,QADAA,EAAI1R,GACOzE,QACX,KAAK,EACJqO,EAAI,IAAI4F,EACR,MACD,KAAK,EACJ5F,EAAI,IAAI4F,EAAQkC,EAAE,IAClB,MACD,KAAK,EACJ9H,EAAI,IAAI4F,EAAQkC,EAAE,GAAIA,EAAE,IACxB,MACD,KAAK,EACJ9H,EAAI,IAAI4F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAC9B,MACD,KAAK,EACJ9H,EAAI,IAAI4F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IACpC,MACD,KAAK,EACJ9H,EAAI,IAAI4F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAC1C,MACD,KAAK,EACJ9H,EAAI,IAAI4F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAChD,MACD,KAAK,EACJ9H,EAAI,IAAI4F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IACtD,MACD,KAAK,EACJ9H,EAAI,IAAI4F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAC5D,MACD,KAAK,EACJ9H,EAAI,IAAI4F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAClE,MACD,KAAK,GACJ9H,EAAI,IAAI4F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IACxE,MACD,QAEC9H,EAAI4F,EAAOrP,MAAO,KAAMuR,GAEzB,OAAOo0B,EAAal8B,EAAGqH,EACvB,CACF,CChDA,IAAIw1B,GAAa,aCEjB,SAASC,GAAiBxlC,GACzB,OAASuJ,GAAUvJ,IAAUulC,GAAWp9B,KAAMnI,EAC/C,CCJA,IAAIylC,GAAiB,0BCErB,SAASC,GAAoB1lC,GAC5B,OAASuJ,GAAUvJ,IAAUylC,GAAet9B,KAAMnI,EACnD,CCvBA,IAAIiF,QAA0C,IAA1BxK,OAAOC,UAAUirC,KCAjCA,GAAOlrC,OAAOC,UAAUirC,KCMxBxnC,GAAK,+KC8BTynC,GATK9tB,ICD2B,KAAtB6tB,GAAKhqC,KArBJ,mDACA,MAoB+BgqC,GAAKhqC,KApBpC,KCiBX,SAAe3B,GACd,OAAO8F,GAAQnE,KAAM3B,EACtB,EHKA,SAAeA,GACd,OAAO+B,GAAS/B,EAAKmE,GAAI,KAC1B,EIGA,SAAS0nC,GAAYljC,EAAUs7B,GAC9B,IAjBuBjkC,EAiBnBmX,EAAI8sB,EAAM39B,KAjBStG,EAiBW2rC,GAAMhjC,IAhB7BzE,UAAW,GAAIlE,EAAIK,OAAO,IAiBrC,GAAW,OAAN8W,EACJ,MAAM,IAAI9V,MAAOwD,EAAQ,iEAAkE8D,IAE5F,OAAOwO,CACR,CCjBA,SAAS20B,GAAc9rC,EAAK6hB,EAAK6K,GAChC,IAAIvlB,EACAtH,EAIJ,IAAY,KADZA,EAAIk0B,GADJ5sB,EAAMhG,SAAUnB,EAAK,IACI6hB,EAAI,IACb,CACf,GAAK6K,EACJ,MAAM,IAAIhZ,WAAY7O,EAAQ,mDAG/B,OAAOsC,CACP,CACD,OAAOtH,CACR,CC1BA,SAASksC,GAAYC,GACpB,OAAOjqC,GAASiqC,EAAK,sBAAuB,oBAC7C,CC2BA,IAAIC,GAAe,2BCGfC,GAAgB,wCCyFpB,SAASC,GAAYnjC,EAAGM,EAAK8iC,EAAW1f,GACvC,IAAIxY,EAGJ,GAAW,QAANlL,EACJ,OAAOM,EAIR,GADA4K,EAAMlL,EAAE3E,MAAO4nC,IACJ,CAIV,IAHAjjC,EAAIM,EAAMnI,SAAU+S,EAAK,GAAK,KAGrB,EAAI,CACZ,GAAKwY,EACJ,OAAQ,EAET1jB,EAAI,CACJ,CACD,OAAOA,CACP,CAGD,OADAkL,EAAMlL,EAAE3E,MAAO6nC,MAEdljC,EAAI/E,WAAYiQ,EAAK,KACZ,EACD,GAAc,GAAK,EAInB1F,GADH49B,GAAa9iC,EAAM,GAAW,IAANN,GACbM,EAAI,GAAKN,EAEXM,EAAMN,IAGb,CACT,CCzIA,IAAIqjC,GAAe,UCAfd,GAAa,gBCRbe,GAAS,OCiSb,SAASC,GAAWvsC,EAAKsJ,EAAKojB,GAC7B,IAAI8f,EACAj3B,EACAvM,EAMJ,IAHAuM,GADAi3B,EAAQb,GAAM3rC,GAAMysC,MAAOJ,KACjBhsC,QAGD,GAAKkV,EAAI,EACjB,MC5TM,CACNoX,KAAQ,iCDiUT,GAAW,IAANpX,EAEJ,GAAkB,KADlBvM,EAAIwjC,EAAO,IACJnsC,OACNmsC,EAAO,GAAM,MACP,CACN,IAA8B,IAAzBjB,GAAWp9B,KAAMnF,GACrB,MCxUI,CACN2jB,KAAQ,iCD0UP,GAAW,KADX3jB,EAAI7H,SAAU6H,EAAG,KAEhB,ME5UI,CACN2jB,KAAQ,+BF6UP6f,EAAO,GAAMxjC,CACb,MAEDwjC,EAAM5nC,KAAM,GASb,GAAkB,KAHlBoE,EAAIwjC,EAAO,IAGJnsC,OAEDmsC,EAAO,GAAM,GAAKljC,EAAM,EAC5BkjC,EAAO,GAAMljC,EAAM,EAEnBkjC,EAAO,GAAM,OAIV,GAAKF,GAAOn+B,KAAMnF,GAAM,CAE5B,IADAA,EAAImjC,GAAYnjC,EAAGM,EAAKkjC,EAAO,GAAM,EAAG9f,IAC/B,EACR,OAAY,IAAP1jB,EGtWA,CACN2jB,KAAQ,2BFDF,CACNA,KAAQ,iCD0WH6f,EAAO,GAAM,GAAKxjC,GAAKM,IAC3BN,GAAK,GAENwjC,EAAO,GAAMxjC,CACb,KAEI,KAAKuiC,GAAWp9B,KAAMnF,GAiC1B,MClZM,CACN2jB,KAAQ,iCDoXR,IAHA3jB,EAAI7H,SAAU6H,EAAG,KAGR,GAIR,IAHAA,EAAIM,EAAMN,GAGD,EAAI,CACZ,GAAK0jB,EACJ,MG3XG,CACNC,KAAQ,2BH4XN3jB,EAAI,CACJ,OAGG,GAAKA,GAAKM,EAAM,CACpB,GAAKojB,EACJ,MGnYI,CACNC,KAAQ,2BHsYN3jB,EADIwjC,EAAO,GAAM,EACbljC,EAAM,EAINA,CAEL,CACDkjC,EAAO,GAAMxjC,CAKb,CAQD,GAAkB,KAHlBA,EAAIwjC,EAAO,IAGJnsC,OAEDmsC,EAAO,GAAM,EACjBA,EAAO,GAAM,KAEbA,EAAO,GAAMljC,OAIV,GAAKgjC,GAAOn+B,KAAMnF,GAAM,CAE5B,IADAA,EAAImjC,GAAYnjC,EAAGM,EAAKkjC,EAAO,GAAM,EAAG9f,IAC/B,EACR,OAAY,IAAP1jB,EGvaA,CACN2jB,KAAQ,2BFDF,CACNA,KAAQ,iCD2aR6f,EAAO,GAAMxjC,CACb,KAEI,KAAKuiC,GAAWp9B,KAAMnF,GAmC1B,MCldM,CACN2jB,KAAQ,iCDkbR,IAHA3jB,EAAI7H,SAAU6H,EAAG,KAGR,GAIR,IAHAA,EAAIM,EAAMN,GAGD,EAER,GAAKwjC,EAAO,GAAM,EAAI,CACrB,GAAK9f,EACJ,MG3bE,CACNC,KAAQ,2BH4bL3jB,EAAI,CACT,KAAW,CAEN,GAAK0jB,GAAU1jB,GAAK,EACnB,MGjcE,CACN2jB,KAAQ,2BHkcL3jB,EAAI,IACJ,OAIE,GAAKA,EAAIM,EAAM,CACnB,GAAKojB,EACJ,MG1cI,CACNC,KAAQ,2BH2cP3jB,EAAIM,CACJ,CACDkjC,EAAO,GAAMxjC,CAKb,CAGD,OAAa,IAARM,EACG,IAAI6iB,GAAO,EAAG,EAAGqgB,EAAO,IAGzB,IAAIrgB,GAAOqgB,EAAO,GAAKA,EAAO,GAAKA,EAAO,GAClD,CI5dA,ICuBIE,GDvBAC,GAAS,SACTC,GAAQ,EASRC,GAAS,UASTtB,GAAa,aEzBbtgC,QAAgD,IAAhCxK,OAAOC,UAAUgsC,WCAjCA,GAAajsC,OAAOC,UAAUgsC,WF+BjCA,GADI5uB,GGOL,SAAqB9d,EAAK2b,EAAQmxB,GACjC,IAAIppC,EAMJ,OAJCA,EADIopC,EAAW,EACT9sC,EAAIK,OAASysC,EAEbA,EAEgB,IAAlBnxB,EAAOtb,UAIXqD,EAAM,GACNA,EAAMiY,EAAOtb,OAASL,EAAIK,SAIpByF,GAAQnE,KAAM3B,EAAK2b,EAAQjY,EACnC,ECrBA,SAAqB1D,EAAK2b,EAAQmxB,GACjC,IAAIppC,EACA7D,EAMJ,GAJC6D,EADIopC,EAAW,EACT9sC,EAAIK,OAASysC,EAEbA,EAEgB,IAAlBnxB,EAAOtb,OACX,OAAO,EAER,GACCqD,EAAM,GACNA,EAAMiY,EAAOtb,OAASL,EAAIK,OAE1B,OAAO,EAER,IAAMR,EAAI,EAAGA,EAAI8b,EAAOtb,OAAQR,IAC/B,GAAKG,EAAI+sC,WAAYrpC,EAAM7D,KAAQ8b,EAAOoxB,WAAYltC,GACrD,OAAO,EAGT,OAAO,CACR,EJjBA,IAAAmtC,GAAeN,GKpBXO,GAAY,IC+ChB,SAASC,GAAYC,EAAKntC,GACzB,IAAIyqB,EPGL,SAAoBzqB,GACnB,IAAI8E,EACA5D,EACAtB,EACAoJ,EACAnJ,EACJ,GAAKG,EAAIkE,UAAW,EAAGyoC,GAAOtsC,UAAassC,GAC1C,OAAO,KAGR,GAAkB,MAAb3sC,EADLJ,EAAII,EAAIK,OAAS,GAEhB,OAAO,KAIR,IADAL,GADAA,EAAM2rC,GAAM3rC,EAAIkE,UAAWyoC,GAAOtsC,OAAQT,KAChC6sC,MAAOI,KACRxsC,SAAWusC,GACnB,OAAO,KAGR,IADA9nC,EAAO,GACDjF,EAAI,EAAGA,EAAI+sC,GAAO/sC,IAAM,CAE7B,GAAW,UADXmJ,EAAIhJ,EAAKH,IAERqB,EAAM,SACA,KAAKqqC,GAAWp9B,KAAMnF,GAG5B,OAAO,KAFP9H,EAAMC,SAAU6H,EAAG,GAGnB,CACDlE,EAAKF,KAAM1D,EACX,CACD,OAAO,IAAIirB,GAAOrnB,EAAM,GAAKA,EAAM,GAAKA,EAAM,GAC/C,COlCSsoC,CAAWptC,GACnB,GAAW,OAANyqB,EACJ,MAAM,IAAIppB,MAAOwD,EAAQ,+DAAgEsoC,IAE1F,OAAO1iB,CACR,CAqDA,SAAS4iB,GAAY/4B,EAAQ3L,EAAU+jB,GACtC,IAAI1mB,EAAO2lC,GAAMhjC,GACjB,OAtGD,SAAkB3C,GACjB,MACe,MAAdA,EAAM,IACN0mC,GAAY1mC,EAAM,SAAU,IACF,MAA1BA,EAAMA,EAAK3F,OAAO,EAEpB,CAgGMitC,CAAStnC,GACNknC,GAAYvkC,EAAU3C,GAhF/B,SAAwBA,GAEvB,OAAOinC,GAAU9+B,KAAMnI,EACxB,CA+EMunC,CAAevnC,GAxCrB,SAA2BmnC,EAAKntC,EAAK6hB,EAAK6K,GACzC,IAAIjC,EAAI8hB,GAAWvsC,EAAK6hB,GAAK,GAC7B,GAAK4I,EAAEkC,KAAO,CACb,GAAgB,gCAAXlC,EAAEkC,KACN,MAAM,IAAItrB,MAAOwD,EAAQ,sFAAuFsoC,IAEjH,GAAgB,kCAAX1iB,EAAEkC,KACN,MAAM,IAAItrB,MAAOwD,EAAQ,+DAAgEsoC,IAG1F,GAAgB,4BAAX1iB,EAAEkC,KAAqC,CAC3C,GAAKD,EACJ,MAAM,IAAIhZ,WAAY7O,EAAQ,mDAG/B4lB,EAAI8hB,GAAWvsC,EAAK6hB,GAAK,EACzB,CACD,CACD,OAAO4I,CACR,CAsBS+iB,CAAkB7kC,EAAU3C,EAAMsO,EAAOjU,OAAQqsB,GAGlD,IACR,CC/GA,SAAS5U,GAAS21B,GACjB,OAcA,SAAcn5B,EAAQ3L,EAAU+kC,GAC/B,OAAKlC,GAAiB7iC,GCvBxB,SAAqB2L,EAAQ3L,EAAU8kC,GACtC,OAAOA,EAAI3lC,OAAQwM,EAAQw3B,GAAcnjC,EAAU2L,EAAOjU,OAAQotC,EAAI/gB,QACvE,CDsBUihB,CAAYr5B,EAAQ3L,EAAU8kC,GAEjCG,GAAat5B,EAAQ3L,KAAe4G,GAAU5G,GE3BrD,SAAmB2L,EAAQ3L,EAAU+kC,EAAUD,GAC9C,IAAI/tC,EAAQ4U,EAAQ3L,GACpB,OAAKmI,GAAYpR,GACXA,IAAU4U,EAAO5K,YACd+jC,EAAIzjC,KAYb,WACC,IAAIlF,EACAjF,EAGJ,IADAiF,EAAO,GACDjF,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAClCiF,EAAKF,KAAMb,UAAWlE,IAEvB,OAAOH,EAAMuF,MAASkM,OAASu8B,EAAap5B,EAASnD,KAAMrM,EAC3D,EAjBMpF,CAkBR,CFEUq+B,CAAUzpB,EAAQ3L,EAAU+kC,EAAUD,GAEzC/B,GAAoB/iC,GGxB3B,SAAsB2L,EAAQ3L,EAAU8kC,GACvC,IAAItmC,EAAM0kC,GAAYljC,EAAU8kC,EAAIxJ,OACpC,GAAkB,QAAb98B,EAAI0J,KACR,OAAO48B,EAAII,aAActY,GAAMjhB,EAAQnN,EAAIqQ,OAE5C,GAAkB,SAAbrQ,EAAI0J,KACR,OAAO48B,EAAII,aAAcjb,GAAWte,EAAQnN,EAAIqQ,OAEjD,GAAkB,SAAbrQ,EAAI0J,KACR,OAAO48B,EAAII,aAAcra,GAAWlf,EAAQnN,EAAIqQ,OAEjD,MAAM,IAAInW,MAAOwD,EAAQ,iEAAkEsC,EAAI0J,MAChG,CHaUi9B,CAAax5B,EAAQ3L,EAAU8kC,GI3BzC,SAAmBn5B,EAAQ3L,EAAU8kC,GACpC,IAAIhjB,EAAI4iB,GAAY/4B,EAAQ3L,EAAU8kC,EAAI/gB,QAC1C,GAAW,OAANjC,EAIL,IACC,OAAOgjB,EAAII,aAAcnpC,GAAO4P,EAAQmW,EAAGgjB,EAAI/gB,QAC/C,CAAC,MAAQ9mB,GAET,MAAM,IAAIA,EAAI8D,YAAaqiC,GAAYnmC,EAAImoC,SAC3C,CACF,CJiBSC,CAAU15B,EAAQ3L,EAAU8kC,EACnC,CACF,CK1CA,SAASzP,GAAU1pB,EAAQ3L,EAAUjJ,GAEpC,OADA4U,EAAQ3L,GAAajJ,GACd,CACR,CCYA,SAASoY,GAAS21B,GACjB,OAiBA,SAAcn5B,EAAQ3L,EAAUjJ,EAAOguC,GACtC,IAAI5tC,EAGJ,OAAK0rC,GAAiB7iC,GCvBxB,SAAqB2L,EAAQ3L,EAAUjJ,EAAO+tC,GAC7C,IAAI7nC,EACAoD,EAGJ,GADApD,EAAM6nC,EAAIpC,UAAW3rC,EAAO+tC,EAAI1lC,OAE/B,MAAMnC,EAQP,OALCoD,EADIykC,EAAIQ,cACJR,EAAIQ,cAAevuC,GAEnBA,EAEL+tC,EAAIxlC,OAAQqM,EAAQw3B,GAAcnjC,EAAU2L,EAAOjU,OAAQotC,EAAI/gB,QAAU1jB,IAClE,CACR,CDSUklC,CAAY55B,EAAQ3L,EAAUjJ,EAAO+tC,GAExCG,GAAat5B,EAAQ3L,KAAe4G,GAAU5G,GAC3Cq1B,GAAU1pB,EAAQ3L,EAAUjJ,GAE/BgsC,GAAoB/iC,GEhB3B,SAAsB2L,EAAQ3L,EAAUjJ,EAAO+tC,GAC9C,IAAIU,EACA3G,EACArgC,EACAvB,EACAoD,EAIJ,GAFA7B,EAAM0kC,GAAYljC,EAAU8kC,EAAIxJ,OAChCkK,EAAMV,EAAI1lC,OAAS,UACdoH,GAAczP,GAElBsJ,EAAItJ,MACE,CAGN,GADAkG,EAAM6nC,EAAIpC,UAAW3rC,EAAOyuC,GAE3B,MAAMvoC,EAQPoD,EAAI25B,GALH35B,EADIykC,EAAIQ,cACJR,EAAIQ,cAAevuC,GAEnBA,EAGgByuC,GACrB3G,EAAM2G,CACN,CACD,GAAkB,QAAbhnC,EAAI0J,KAAiB,CACzB,IACC6jB,GAAKpgB,EAAQnN,EAAIqQ,KAAMxO,EACvB,CAAC,MAAQpD,GACT,MAAM,IAAIA,EAAI8D,YAAaqiC,GAAYnmC,EAAImoC,SAC3C,CACD,OAAO,CACP,CACD,GAAkB,SAAb5mC,EAAI0J,KAAkB,CAC1B,IACC8iB,GAAOrf,EAAQnN,EAAIqQ,KAAMxO,EAAG,CAC3BonB,KAAQ,oBAET,CAAC,MAAQxqB,GACT,MAAM,IAAIA,EAAI8D,YAAaqiC,GAAYnmC,EAAImoC,SAC3C,CACD,OAAO,CACP,CAKD,QAJa,IAARvG,IACJA,EAAMz/B,GAAOrI,IAAW,YAGnBqhB,GAAkBymB,EAAK2G,GAC5B,MAAM,IAAIvqC,UAAWiB,EAAQ,+GAAgH2iC,EAAK2G,IAMnJ,GAHKtf,GAAmBsf,IAAShtB,GAAgBqmB,KAChDx+B,EAAImlB,GAASnlB,EAAGmlC,IAEC,SAAbhnC,EAAI0J,KAAkB,CAE1B,IACCmlB,GAAO7uB,EAAIqQ,KAAMlD,EAAQtL,EAAGsL,EAAQ,EAAG,EACvC,CAAC,MAAQ1O,GACT,MAAM,IAAIA,EAAI8D,YAAaqiC,GAAYnmC,EAAImoC,SAC3C,CACD,OAAO,CACP,CACD,MAAM,IAAI1sC,MAAOwD,EAAQ,iEAAkEsC,EAAI0J,MAChG,CFjDUu9B,CAAa95B,EAAQ3L,EAAUjJ,EAAO+tC,IAE9C3tC,EG3BF,SAAmBwU,EAAQ3L,EAAUjJ,EAAOguC,EAAUD,GACrD,IAAI7nC,EACA6kB,EACAzhB,EAGJ,GAAW,QADXyhB,EAAI4iB,GAAY/4B,EAAQ3L,EAAU8kC,EAAI/gB,SAGrC,OAAO,EAER,GAAKvd,GAAczP,GAElBsJ,EAAItJ,MACE,CAGN,GADAkG,EAAM6nC,EAAIpC,UAAW3rC,EAAO+tC,EAAI1lC,OAE/B,MAAMnC,EAGPoD,EAAI25B,GAAcjjC,EAAO+tC,EAAI1lC,OAAS,UACtC,CACD,IACCwmB,GAAavlB,EAAG0kC,EAAUjjB,EAAGgjB,EAAI/gB,OACjC,CAAC,MAAQ9mB,GACT,MAAM,IAAIA,EAAI8D,YAAaqiC,GAAYnmC,EAAImoC,SAC3C,CACD,OAAO,CACR,CHDQM,CAAU/5B,EAAQ3L,EAAUjJ,EAAOguC,EAAUD,GAC9C3tC,GAIEk+B,GAAU1pB,EAAQ3L,EAAUjJ,GACnC,CACF,CIVA,SAASoY,KACR,IAAIw2B,EACA1oC,EAGJ,GADA0oC,ECxCO,CACNrK,MAASK,GACT5X,QAAU,GDuCN3oB,UAAU1D,SACduF,EAAM4+B,GAAU8J,EAASvqC,UAAW,KAEnC,MAAM6B,EAGR,OAoCA,SAASglC,EAAal8B,GACrB,IAAIqH,EACAnQ,EACAsB,EACA6P,EACAI,EEpFgBzX,EFqFpB,KEnFAA,OAFoBA,EFqFDgP,IEjFF,mBAAVhP,GACiB,iBAAjBA,EAAMW,QACboO,GAAW/O,EAAMW,SACjBX,EAAMW,QAAU,GAChBX,EAAMW,QAAU4O,IF6EWE,GAAcT,IACxC,MAAM,IAAI9K,UAAWiB,EAAQ,oEAAqE6J,IAEnG,GAAKw7B,GAAkB,CAEtB,GADAn0B,EAAO0D,GAAQ,GAAI60B,GACdvqC,UAAU1D,OAAS,IACvBuF,EAAM4+B,GAAUzuB,EAAMhS,UAAW,KAEhC,MAAM6B,EAoBR,OAfAuR,EAAI,CACHsM,IAAO/U,EACP3G,MAHDgP,GADA7P,EAAMqQ,GAAkB7I,IACf3G,OAAS,GAIjBD,OAAUZ,EAAI4P,UAAW,GACzB7O,OAAUf,EAAI4P,UAAW,GACzBm3B,cAAiBM,GAAmBx3B,GACpC82B,aAAgBW,GAAiB5D,EAAa70B,GAC9CkuB,MAASluB,EAAKkuB,MACdvX,OAAU3W,EAAK2W,OACf2e,UAAaA,GAAWt0B,GACxB6zB,YAAeA,EACf5gC,KAAQ,IAAIigC,GAAOv7B,EAAEhF,aAAe1G,MAAO,CAC1CyrC,UAAazkC,GAAM4gC,EAAa70B,MAG3B,IAAIk0B,GAAOv7B,EAAG,CACpBpI,IAAOA,GAAK6Q,GACZ5Q,IAAOA,GAAK4Q,IAEb,CAGD,OADAu3B,QAAQC,KAAM,8HACPjgC,CACP,CACF,CGtGA,IAAIk8B,GAAc9yB,KCHlBrR,EAAAnH,GAAA,UAAAwY,IACArR,EAAAnH,GAAA,MAAAglC,IC3BA,IAAI5M,GAAgBb,GAASvwB,IAAK,kBAC9BsE,GAAiBmO,GAAO,aACxBlO,GAAkBkO,GAAO,cACzBjO,GAAeiO,GAAO,QCPtBA,GAAQ,CACX7Q,WAAc2C,GACd1C,UAAayC,ICUd,SAASmO,GAAOhR,GACf,OAAOgmB,GAAOhmB,IAAW,IAC1B,CCbA,IAAI2vB,GAAgBb,GAASvwB,IAAK,iCCI9ByS,GAAQ,CACXzR,MAAS+C,GACThD,MAASiD,GACT/C,KAAQgD,GACR9C,OAAU+C,GACVhD,OAAUiD,GACV/C,MAASgD,GACT/C,OAAUgD,ICXP+sB,GAAgBb,GAASvwB,IAAK,eCM9ByS,GAAQ,CACX9R,QAAWmD,GACXhD,QAAW+C,GACX7C,MAAS+C,GACThD,MAASiD,GACT/C,KAAQgD,GACR9C,OAAU+C,GACVhD,OAAUiD,GACV/C,MAASgD,GACT/C,OAAUgD,IChBPoO,GAAQ,CACX9R,QAAWmD,GACXhD,QAAW+C,ICDR4O,GAAQ,CACXzR,MAAS+C,GACThD,MAASiD,GACT/C,KAAQgD,ICFLwO,GAAQ,CACXtR,OAAU+C,GACVhD,OAAUiD,GACV/C,MAASgD,GACT/C,OAAUgD,ICJP+sB,GAAgBb,GAASvwB,IAAK,kBAsBlC,SAAS+kB,GAAQzrB,GAChB,IAAImI,EACJ,IAAM+G,GAAsBlP,GAC3B,MAAM,IAAIgE,UAAWiB,EAAQ,+EAAgFjF,IAE9G,GAAKmE,UAAU1D,OAAS,GAEvB,GAAe,aADf0H,EAAQhE,UAAW,IAElB,OAAO/C,GAAMpB,QAGdmI,EAAQ2vB,GAET,OAAO12B,GAAKyY,OAAQ9Z,GAAOC,EAAGmI,GAAS,EAAG,EAC3C,CC/BA,IAAA6Z,GAAA,CAAA,EAWAnb,EAAAmb,GAAA,mBAAA7S,IAWAtI,EAAAmb,GAAA,yBAAA1S,IClBI,IAAA0S,GAAK,CAAG,SAUZnb,EAAamb,GAAI,OAAQ5gB,IAUzByF,EAAamb,GAAI,eAAgB9W,IAUjCrE,EAAamb,GAAI,cAAevS,IAUhC5I,EAAamb,GAAI,aAAcvF,IAU/B5V,EAAamb,GAAI,kBC7CjB,SAAyBlT,EAAG9O,GAC3B,IAAMuP,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,8EAA+E6J,IAE7G,IAAMI,GAAsBlP,GAC3B,MAAM,IAAIgE,UAAWiB,EAAQ,gFAAiFjF,IAE/G,OAAOoB,GAAM0N,EAAG9O,EACjB,ID+CA6G,EAAamb,GAAI,oBEvDjB,SAA2B+I,EAAIC,GAC9B,IAAMzb,GAAcwb,GACnB,MAAM,IAAI/mB,UAAWiB,EAAQ,8EAA+E8lB,IAE7G,IAAMxb,GAAcyb,GACnB,MAAM,IAAIhnB,UAAWiB,EAAQ,+EAAgF+lB,IAE9G,OAAO5pB,GAAM2pB,EAAIC,EAClB,IFyDAnkB,EAAamb,GAAI,mBGpEjB,SAA0BlT,GACzB,IAAMS,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,8EAA+E6J,IAE7G,OAAO1N,GAAM0N,EACd,IHyEAjI,EAAamb,GAAI,iBAAkBhX,IAUnCnE,EAAamb,GAAI,kBAAmB/W,IAUpCpE,EAAamb,GAAI,UAAWuM,IAU5B1nB,EAAamb,GAAI,eIvGjB,SAAsBlT,EAAG+J,GACxB,IAAI1Q,EAAQumB,GAAS7V,GACrB,GAAe,OAAV1Q,EACJ,MAAM,IAAInE,UAAWiB,EAAQ,yGAA0GkD,EAAO0Q,IAE/I,OAAO0V,GAASzf,EAAG3G,EACpB,IJ2GAtB,EAAamb,GAAI,QAAS7I,IAU1BtS,EAAamb,GAAI,WAAYme,IAU7Bt5B,EAAamb,GAAI,axMzEjB,SAAoBrN,EAAO6X,EAAM/rB,EAAQyV,GACxC,IAAIC,EACAzM,EACA6K,EACAjN,EACAyN,EACAC,EACAV,EACAgP,EACArjB,EASJ,GAPAyJ,EAAM,IACN6K,GAAM,EACN4B,EAAO,CACNuqB,MAAS,SAEV/rB,EAAQksB,GAAWlsB,EAAO,SAC1B6X,EAAOqU,GAAWrU,EAAM,QACnBroB,UAAU1D,OAAS,EAAI,CAc3B,GAb0B,IAArB0D,UAAU1D,OACTgO,GAAUhO,GACd0V,EAAO1V,GAEPiJ,EAAMjJ,EAGN8T,GAAM,IAGP4B,EAAOD,EACPxM,EAAMjJ,GAEM,IAARiJ,EACJ,MAAO,GAER,IAAMmF,GAAWnF,IAASA,EAAM,EAC/B,MAAM,IAAI1F,UAAWiB,EAAQ,oEAAqEyE,IAEnG,GAAK6K,EAAM,CACV,IAAM9F,GAAU0H,GACf,MAAM,IAAInS,UAAWiB,EAAQ,qEAAsEkR,IAEpG,GAAKrN,GAAYqN,EAAM,SAAY,CAClC,IAAMxG,GAAUwG,EAAKuqB,OACpB,MAAM,IAAI18B,UAAWiB,EAAQ,8DAA+D,QAASkR,EAAKuqB,QAE3G,IAAyC,IAApCE,GAAS18B,QAASiS,EAAKuqB,OAC3B,MAAM,IAAIj/B,MAAOwD,EAAQ,gFAAiF,QAAS27B,GAASvrB,KAAM,QAAUc,EAAKuqB,OAElJ,CACD,CACD,CACD,OAASvqB,EAAKuqB,OACd,IAAK,QACJ1rB,EAAM0rB,GACN,MACD,IAAK,OACJ1rB,EAAMgY,GACN,MAED,QACChY,EAAMpG,GAaP,IARAmG,EAAMrL,EAAM,EACZ4Z,GAAMkJ,EAAKwiB,UAAYr6B,EAAMq6B,WAAcj6B,EAI3CT,EAAMK,GADNrN,EAAM,IAAIlE,MAAOsG,IAEZ,GAAM4K,EACXA,EAAMA,EAAI06B,UACJ/uC,EAAI,EAAGA,EAAI8U,EAAK9U,IACrBqU,GAAOgP,EACPhc,EAAKrH,GAAM,IAAI6gC,KAAM9rB,EAAKV,IAG3B,OADAhN,EAAKyN,GAAQyX,EACNllB,CACR,IwMGAT,EAAamb,GAAI,WAAYiV,IAU7BpwB,EAAamb,GAAI,QAAS7Z,IAU1BtB,EAAamb,GAAI,SAAU9F,IAU3BrV,EAAamb,GAAI,QAAS+e,IAU1Bl6B,EAAamb,GAAI,aKxLjB,SAAoBlT,GACnB,IAAIqI,EAAKhP,GAAO2G,GAChB,GAAY,OAAPqI,EACJ,MAAM,IAAInT,UAAWiB,EAAQ,8GAA+G6J,IAK7I,OAHK3K,UAAU1D,OAAS,IACvB0W,EAAKhT,UAAW,IAEV48B,GAAOjyB,EAAErO,OAAQ0W,EACzB,ILyLAtQ,EAAamb,GAAI,UhM5DjB,WACC,IAAIliB,EACA8T,EACAzL,EACAiC,EACA9C,EACAoC,EACApI,EAWJ,GATAsS,EAAQzP,UAAU1D,QAClBmT,GAAS,IACK,GAAKjE,GAAUxL,UAAWyP,KACvCzL,EAAQhE,UAAWyP,GACnBA,GAAS,GAETzL,EAAQ2vB,GAGK,QADd1tB,EAAO+O,GAAOhR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,sEAAuEkD,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAKyL,GAAS,EACb,MAAO,GAIR,GAFA9T,EAAQqE,UAAW,GACnB7C,EAAM6C,UAAW,GACF,IAAVyP,EAAc,CAMlB,GALK1E,GAAsB5N,GAC1BoI,EAAMpI,EACKiO,GAAcjO,KACzBoI,EAAMpI,EAAIb,aAEE,IAARiJ,EACJ,OAAOyY,GAAQriB,EAAO4J,GAEvB,GAAKgG,GAAepO,GACnB,MAAM,IAAIG,MAAO,qFAElB,GAAKgN,GAAUnN,GAAQ,CACtB,IAA6B,IAAxB+R,GACJ,MAAM,IAAIrP,UAAWiB,EAAQ,sIAAuI3D,IAErK,IAAM4P,GAAY5P,EAAK4S,KACtB,MAAM,IAAIlQ,UAAWiB,EAAQ,wGAAyG3D,IAGvI,IAAM4P,IADN5P,EAAMA,EAAK4S,OACWjB,MACrB,MAAM,IAAIjP,UAAWiB,EAAQ,wGAAyG3D,IAEvI,OA7KJ,SAAyB0R,EAAIlT,GAC5B,IAAIwH,EAIJ,IADAA,EAAM,IAED0L,EAAGC,OACAC,MAGP5L,EAAItC,KAAMlF,GAEX,OAAOwH,CACR,CAgKW2nC,CAAgB3tC,EAAKxB,EAC5B,CACD,MAAM,IAAIkE,UAAWiB,EAAQ,wGAAyG3D,GACzI,CAAS,GAAKoO,GAAepO,GAC1B,MAAM,IAAIG,MAAO,qFAElB,MAAM,IAAIuC,UAAWiB,EAAQ,wGAAyG3D,GACtI,CACD,GAAKsS,GAAS,EACb,OAAO,IAAIxJ,EAAM,GAElB,GAAe,IAAVwJ,EAEJ,GAAKrE,GADLjO,EAAM6C,UAAW,IAEhBmD,EAAM,IAAI8C,EAAM9I,EAAIb,aACd,GAAKiP,GAAepO,GAC1BgG,EAAM,IAAI8C,EAAM9I,QACV,GAAK4N,GAAsB5N,GACjCgG,EAAM,IAAI8C,EAAM9I,OACV,KAAKmN,GAAUnN,GAarB,MAAM,IAAI0C,UAAWiB,EAAQ,wGAAyG3D,IAZtI,IAA6B,IAAxB+R,GACJ,MAAM,IAAIrP,UAAWiB,EAAQ,sIAAuI3D,IAErK,IAAM4P,GAAY5P,EAAK4S,KACtB,MAAM,IAAIlQ,UAAWiB,EAAQ,wGAAyG3D,IAGvI,IAAM4P,IADN5P,EAAMA,EAAK4S,OACWjB,MACrB,MAAM,IAAIjP,UAAWiB,EAAQ,wGAAyG3D,IAEvIgG,EAAM,IAAI8C,EAAM+2B,GAAY7/B,GAG5B,MAEDgG,EADqB,IAAVsM,EACL,IAAIxJ,EAAMjG,UAAU,GAAIA,UAAU,IAElC,IAAIiG,EAAMjG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKmD,EAAI7G,OAAS,IACjBX,EAAQqE,UAAW,GACd8qB,GAAmB9mB,GA/L1B,SAA0Bb,EAAKxH,GAC9B,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5BqH,EAAIX,IAAK7G,EAAOG,EAGlB,CA0LGivC,CAAiB5nC,EAAKxH,GACXuc,GAAmBlU,GAC9B64B,GAAO15B,EAAI7G,OAAQ,EAAY,EAAI,EAAGm2B,GAAiBtvB,EAAK,GAAK,GAEjE05B,GAAO15B,EAAI7G,OAAQX,EAAOwH,EAAK,IAG1BA,CACR,IgM9BAT,EAAamb,GAAI,Y3LJjB,WACC,IAAI5N,EACAR,EACAzL,EACAkM,EACAjK,EACA9C,EACAoC,EACApI,EAKJ,GAAe,KAHfsS,EAAQzP,UAAU1D,QAKjB,OAAO,IADP2J,EAAO+O,GAAO2e,KACG,GAIlB,GAAKnoB,GADLxH,EAAQhE,UAAW,IACM,CAExB,GAAKyP,EAAQ,EACZ,MAAM,IAAI5P,UAAW,6FAGtB,GAAc,QADdoG,EAAO+O,GAAOhR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,sEAAuEkD,IAGrG,OAAO,IAAIiC,EAAM,EACjB,CAED,GAAKwJ,EAAQ,EACZ,MAAM,IAAI5P,UAAW,6FAMtB,GAAKkN,GAAY/M,UAHjByP,GAAS,IAKR,GAAK1C,GAAY/M,UAAWyP,EAAM,KAMjC,GALAQ,EAAUjQ,UAAWyP,GAErBS,EAAOlQ,UADPyP,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAI5P,UAAW,kGAItBqQ,EAAOlQ,UAAWyP,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAI5P,UAAW,6FANrB,GAHAoQ,EAAUjQ,UAAWyP,IAGf1C,GADNmD,EAAOlQ,UADPyP,GAAS,IAGR,MAAM,IAAI5P,UAAWiB,EAAQ,uEAAwEoP,GAMtG,CAUD,IARAT,GAAS,IACK,GAAKjE,GAAUxL,UAAWyP,KACvCzL,EAAQhE,UAAWyP,GACnBA,GAAS,GAETzL,EAAQ2vB,GAGK,QADd1tB,EAAO+O,GAAOhR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,sEAAuEkD,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADA7G,EAAM6C,UAAW,GACF,IAAVyP,EAAc,CAMlB,GALK1E,GAAsB5N,GAC1BoI,EAAMpI,EACKiO,GAAcjO,KACzBoI,EAAMpI,EAAIb,aAEE,IAARiJ,EACJ,OAAOylC,GAAazlC,EAAK2K,EAAMD,GAEhC,GAAK1E,GAAepO,GACnB,MAAM,IAAIG,MAAO,qFAElB,GAAKgN,GAAUnN,GAAQ,CACtB,IAA6B,IAAxB+R,GACJ,MAAM,IAAIrP,UAAWiB,EAAQ,sIAAuI3D,IAErK,IAAM4P,GAAY5P,EAAK4S,KACtB,MAAM,IAAIlQ,UAAWiB,EAAQ,wGAAyG3D,IAGvI,IAAM4P,IADN5P,EAAMA,EAAK4S,OACWjB,MACrB,MAAM,IAAIjP,UAAWiB,EAAQ,wGAAyG3D,IAEvI,OAvSJ,SAA8B0R,EAAIqB,EAAMD,GACvC,IAAI9M,EACArH,EAKJ,IAFAqH,EAAM,GACNrH,GAAK,GAEA+S,EAAGC,OACAC,MAGPjT,GAAK,EACLqH,EAAItC,KAAMqP,EAAKtS,KAAMqS,EAASnU,IAE/B,OAAOqH,CACR,CAuRW8nC,CAAqB9tC,EAAK+S,EAAMD,EACvC,CACD,MAAM,IAAIpQ,UAAWiB,EAAQ,wGAAyG3D,GACzI,CAAS,GAAKoO,GAAepO,GAC1B,MAAM,IAAIG,MAAO,qFAElB,MAAM,IAAIuC,UAAWiB,EAAQ,wGAAyG3D,GACtI,CACD,GAAe,IAAVsS,EAEJ,GAAKrE,GADLjO,EAAM6C,UAAW,IAEhBmD,EAAM,IAAI8C,EAAM9I,EAAIb,aACd,GAAKiP,GAAepO,GAC1BgG,EAAM,IAAI8C,EAAM9I,QACV,GAAK4N,GAAsB5N,GACjCgG,EAAM,IAAI8C,EAAM9I,OACV,KAAKmN,GAAUnN,GAarB,MAAM,IAAI0C,UAAWiB,EAAQ,wGAAyG3D,IAZtI,IAA6B,IAAxB+R,GACJ,MAAM,IAAIrP,UAAWiB,EAAQ,sIAAuI3D,IAErK,IAAM4P,GAAY5P,EAAK4S,KACtB,MAAM,IAAIlQ,UAAWiB,EAAQ,wGAAyG3D,IAGvI,IAAM4P,IADN5P,EAAMA,EAAK4S,OACWjB,MACrB,MAAM,IAAIjP,UAAWiB,EAAQ,wGAAyG3D,IAEvIgG,EAAM,IAAI8C,EAAM+2B,GAAY7/B,GAG5B,MAEDgG,EADqB,IAAVsM,EACL,IAAIxJ,EAAMjG,UAAU,GAAIA,UAAU,IAElC,IAAIiG,EAAMjG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKmD,EAAI7G,OAAS,IACZwuB,GAAmB9mB,IAAWkU,GAAmBlU,GAjTxD,SAA0Bb,EAAK+M,EAAMD,GACpC,IAAInU,EACJ,IAAMA,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5BqH,EAAIX,IAAK0N,EAAKtS,KAAMqS,EAASnU,GAAKA,EAGpC,CA4SGivC,CAAiB5nC,EAAK+M,EAAMD,GAE5BgtB,GAAS95B,EAAI7G,OAAQ6G,EAAK,GAe5B,SAAmBxH,EAAOuvC,GACzB,OAAOh7B,EAAKtS,KAAMqS,EAASi7B,EAC3B,KAdM/nC,CAeR,I2LtJAT,EAAamb,GAAI,qBAAsB4kB,IAUvC//B,EAAamb,GAAI,iBAAkB0gB,IAUnC77B,EAAamb,GAAI,iBAAkB2gB,IAUnC97B,EAAamb,GAAI,eAAgBzX,IAUjC1D,EAAamb,GAAI,eAAgBxX,IAUjC3D,EAAamb,GAAI,kBM/PjB,WACC,IAAI1P,EACA8B,EACAY,EACA9U,EACAwJ,EACA/C,EACAwQ,EACAlX,EACAmJ,EAGJ,GADAkJ,EAAWnO,UAAW,GACjBA,UAAU1D,OAAS,EACvB,GAAK8O,GAAcpL,UAAW,KAE7B,GADAjE,EAAMiE,UAAW,GACZA,UAAU1D,OAAS,EAAI,CAE3B,IAAMyQ,GADN8D,EAAM7Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,uEAAwE+P,IAEtGZ,EAAUjQ,UAAW,EACrB,MACK,CAEN,IAAM+M,GADN8D,EAAM7Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,uEAAwE+P,IAEtGZ,EAAUjQ,UAAW,EACrB,CAEF,IAAM+8B,GAAgB5uB,GACrB,MAAM,IAAItO,UAAWiB,EAAQ,kGAAmGqN,IAGjI,GADArS,GAAK,OACQ,IAARC,EAAiB,CAErB,GADAA,EAAM,GACD8U,EAAM,CACV,KACC/U,GAAK,IACLmJ,EAAIkJ,EAASW,QACNC,MAGPhT,EAAI8E,KAAMgQ,EAAIjT,KAAMqS,EAAShL,EAAEtJ,MAAOG,IAEvC,OAAOC,CACP,CACD,OACCkJ,EAAIkJ,EAASW,QACNC,MAGPhT,EAAI8E,KAAMoE,EAAEtJ,OAEb,OAAOI,CACP,CAQD,GAPAwJ,EAAMxJ,EAAIO,OACV0W,EAAKhP,GAAOjI,GAEXyG,EADIQ,EAAiBjH,GACfmX,EAAgBF,GAEhB9O,EAAQ8O,GAEVnC,EAAM,CACV,KAAQ/U,EAAIyJ,EAAI,IACfzJ,GAAK,IACLmJ,EAAIkJ,EAASW,QACNC,OAGPvM,EAAKzG,EAAKD,EAAG+U,EAAIjT,KAAMqS,EAAShL,EAAEtJ,MAAOG,IAE1C,OAAOC,CACP,CACD,KAAQD,EAAIyJ,EAAI,IACfzJ,GAAK,IACLmJ,EAAIkJ,EAASW,QACNC,OAGPvM,EAAKzG,EAAKD,EAAGmJ,EAAEtJ,OAEhB,OAAOI,CACR,INsLA2G,EAAamb,GAAI,eAAgB+gB,IAUjCl8B,EAAamb,GAAI,OAAQghB,IAUzBn8B,EAAamb,GAAI,YOnSjB,SAAmBlT,EAAGhP,GACrB,IAAIqX,EACA/N,EAGJ,GAAY,QADZ+N,EAAKhP,GAAO2G,IAEX,MAAM,IAAI9K,UAAWiB,EAAQ,8GAA+G6J,IAgB7I,OAdK3K,UAAU1D,OAAS,IACvB0W,EAAKhT,UAAW,IAIfiF,EAFoB,iBAAVtJ,EACC,eAAPqX,EACA,IAAI/F,GAAYtR,EAAO,GACT,cAAPqX,EACP,IAAIrF,GAAWhS,EAAO,GAEtBA,EAGDA,EAEEkjC,GAAMl0B,EAAErO,OAAQ2I,EAAG+N,EAC3B,IPsRAtQ,EAAamb,GAAI,aQ9SjB,SAAoB+I,EAAIC,EAAIqH,GAC3B,IACInF,EACJ,IAAMrtB,GAAUkrB,IAAQ1nB,GAAO0nB,GAC9B,MAAM,IAAI/mB,UAAWiB,EAAQ,wDAAyD8lB,IAEvF,IAAMlrB,GAAUmrB,IAAQ3nB,GAAO2nB,GAC9B,MAAM,IAAIhnB,UAAWiB,EAAQ,uDAAwD+lB,IAEtF,GAAK7mB,UAAU1D,OAAS,EACvBysB,EAAM,OAGN,IAAMrtB,GADNqtB,EAAMmF,IACmBhvB,GAAO6pB,GAC/B,MAAM,IAAIlpB,UAAWiB,EAAQ,4DAA6DioB,IAI5F,GADMF,IAAQhC,EAAGD,GAAOmC,GACb7d,GACV,MAAM,IAAIyE,WAAY,oEAEvB,OAAOw7B,GAAKvkB,EAAIC,EAAIkC,EACrB,IRkSArmB,EAAamb,GAAI,aAAc0iB,IAU/B79B,EAAamb,GAAI,YAAarX,IAU9B9D,EAAamb,GAAI,aAAcvX,IAU/B5D,EAAamb,GAAI,aAActX,IAU/B7D,EAAamb,GAAI,WAAYojB,IAU7Bv+B,EAAamb,GAAI,sBAAuButB,IAUxC1oC,EAAamb,GAAI,iBAAkBglB,IAUnCngC,EAAamb,GAAI,iBAAkBilB,IAUnCpgC,EAAamb,GAAI,YS1YjB,SAAmBpL,EAAGC,EAAGnN,GACxB,IAAM7J,GAAU+W,IAAOvT,GAAOuT,GAC7B,MAAM,IAAI5S,UAAWiB,EAAQ,0EAA2E2R,IAEzG,IAAM/W,GAAUgX,IAAOxT,GAAOwT,GAC7B,MAAM,IAAI7S,UAAWiB,EAAQ,yEAA0E4R,IAExG,GAAK1S,UAAU1D,OAAS,EACvBiJ,EAAM,QACA,IAAMwF,GAAsBxF,GAClC,MAAM,IAAI1F,UAAWiB,EAAQ,uEAAwEyE,IAEtG,OAAO4lC,GAAK14B,EAAGC,EAAGnN,EACnB,ITuYA7C,EAAamb,GAAI,cAAeulB,IAUhC1gC,EAAamb,GAAI,kBAAmBrB,IAUpC9Z,EAAamb,GAAI,YAAagR,IAU9BnsB,EAAamb,GAAI,UUtYjB,SAAiBlT,EAAGmkB,EAAM3c,GACzB,IAAIH,EACAnQ,EACA8oB,EACA8Y,EACJ,IAAMr4B,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,8EAA+E6J,IAE7G,IAAMS,GAAc0jB,GACnB,MAAM,IAAIjvB,UAAWiB,EAAQ,+EAAgFguB,IAE9G,IAAM1jB,GAAc+G,GACnB,MAAM,IAAItS,UAAWiB,EAAQ,8EAA+EqR,IAG7G,GADAH,ECvEO,CACNqa,KAAQ,UDuEJrsB,UAAU1D,OAAS,IACvBuF,ElI7CF,SAAmBmQ,EAAMD,GACxB,OAAMzH,GAAUyH,GAGXpN,GAAYoN,EAAS,UACzBC,EAAKqa,KAAOta,EAAQsa,MACdgX,GAAQrxB,EAAKqa,OACX,IAAIxsB,UAAWiB,EAAQ,gFAAiF,OAAQwvB,GAAMpf,KAAM,QAAUc,EAAKqa,OAG7I,KARC,IAAIxsB,UAAWiB,EAAQ,qEAAsEiR,GAStG,CkIkCQ0uB,CAAUzuB,EAAMhS,UAAW,IAC5B6B,GACJ,MAAMA,EAOR,GAJA8oB,EAAM3mB,GAAO2G,IAAO,WAIdqS,GAHNymB,EAAMz/B,GAAOmO,IAAY,UAGIwY,GAC5B,MAAM,IAAI9qB,UAAWiB,EAAQ,6GAA8G2iC,EAAK9Y,IAOjJ,OAJKG,GAAmBH,IAASvN,GAAgBqmB,KAChDtxB,EAASiY,GAASjY,EAAQwY,IAGpB1tB,GAAM0N,EAAGmkB,EAAM3c,EAAQH,EAAKqa,KACpC,IV8WA3pB,EAAamb,GAAI,YAAa4R,IAU9B/sB,EAAamb,GAAI,QtHzbjB,SAAevhB,GACd,IAAI0H,EAGJ,GAAKhE,UAAU1D,OAAS,GAEvB,IAAMknC,GADNx/B,EAAQhE,UAAW,IAElB,MAAM,IAAIH,UAAWiB,EAAQ,qFAAsF8R,GAAO1B,KAAM,QAAUlN,SAG3IA,EAAQ2vB,GAST,OAAOkL,GAAMviC,EAPE,eAAV0H,EACIs/B,GACa,cAAVt/B,EACHu/B,GAEAn8B,IAEmBpD,EAC7B,IsH+aAtB,EAAamb,GAAI,YrHvcjB,SAAmBlT,GAClB,IAAIqI,EACA/N,EAGJ,GAAY,QADZ+N,EAAKhP,GAAO2G,IAEX,MAAM,IAAI9K,UAAWiB,EAAQ,8GAA+G6J,IAE7I,GAAK3K,UAAU1D,OAAS,GAEvB,GADA0W,EAAKhT,UAAW,IACe,IAA1B4S,GAAO7S,QAASiT,GACpB,MAAM,IAAInT,UAAWiB,EAAQ,qFAAsF8R,GAAO1B,KAAM,QAAU8B,SAErI,IAA+B,IAA1BJ,GAAO7S,QAASiT,GAC3B,MAAM,IAAInT,UAAWiB,EAAQ,+FAAgG8R,GAAO1B,KAAM,QAAU8B,IASrJ,OANC/N,EADW,eAAP+N,EACAswB,GACc,cAAPtwB,EACPuwB,GAEAn8B,IAEEy3B,GAAMl0B,EAAErO,OAAQ2I,EAAG+N,EAC3B,IqHybAtQ,EAAamb,GAAI,gBYzcjB,SAAuB7Z,GACtB,OAA0B,IAArBhE,UAAU1D,OA7BhB,WACC,IAAIyb,EACA0E,EACA1gB,EACAD,EAKJ,IAHAC,EAAM,CAAA,EAEN0gB,GADA1E,EAAS8D,GAAYwvB,KACL/uC,OACVR,EAAI,EAAGA,EAAI2gB,EAAQ3gB,IACxBC,EAAKgc,EAAOjc,IAAOuvC,GAAatzB,EAAOjc,IAExC,OAAOC,CACR,CAiBS+gB,GAEHnY,GAAY0mC,GAAarnC,GACtBqnC,GAAarnC,GAEd,IACR,IZ2cAtB,EAAamb,GAAI,QAAS8R,IAU1BjtB,EAAamb,GAAI,aa9ejB,SAAoBlT,GACnB,IAAIqI,EAAKhP,GAAO2G,GAChB,GAAY,OAAPqI,EACJ,MAAM,IAAInT,UAAWiB,EAAQ,8GAA+G6J,IAK7I,OAHK3K,UAAU1D,OAAS,IACvB0W,EAAKhT,UAAW,IAEV2vB,GAAOhlB,EAAErO,OAAQ0W,EACzB,Ib+eAtQ,EAAamb,GAAI,QnHhfjB,SAAevhB,GACd,IAAI0H,EAeJ,OAAO66B,GAAMviC,EAPE,gBAJd0H,EADIhE,UAAU1D,OAAS,EACf0D,UAAW,GAEX2zB,IAGA2P,GACa,cAAVt/B,EACHu/B,GAEA,EAEmBv/B,EAC7B,ImHyeAtB,EAAamb,GAAI,YlH1fjB,SAAmBlT,GAClB,IAAIqI,EACA/N,EAGJ,GAAY,QADZ+N,EAAKhP,GAAO2G,IAEX,MAAM,IAAI9K,UAAWiB,EAAQ,8GAA+G6J,IAY7I,OAVK3K,UAAU1D,OAAS,IACvB0W,EAAKhT,UAAW,IAGhBiF,EADW,eAAP+N,EACAswB,GACc,cAAPtwB,EACPuwB,GAEA,EAEE1E,GAAMl0B,EAAErO,OAAQ2I,EAAG+N,EAC3B,IkHifAtQ,EAAamb,GAAI,QAAS+R,IAU1BltB,EAAamb,GAAI,iBAAkBwnB,IAUnC3iC,EAAamb,GAAI,kBczfjB,SAAyBytB,EAAQC,GAChC,IAAIn4B,EACJ,OAA0B,IAArBpT,UAAU1D,OAnDhB,WACC,IAAIyb,EACA0E,EACA1gB,EACAoU,EACAuM,EACAC,EACAvJ,EACAxT,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN0gB,GADA1E,EAAS8D,GAAY2vB,KACLlvC,OACVR,EAAI,EAAGA,EAAI2gB,EAAQ3gB,IAAM,CAI9B,IAHA4gB,EAAM3E,EAAQjc,GACdsX,EAAIo4B,GAAiB9uB,GACrBvM,EAAM,CAAA,EACAvQ,EAAI,EAAGA,EAAI6c,EAAQ7c,IAExBuQ,EADAwM,EAAM5E,EAAQnY,IACDwT,EAAGuJ,GAEjB5gB,EAAK2gB,GAAQvM,CACb,CACD,OAAOpU,CACR,CA2BS8gB,IAERyuB,EAASnvB,GAASmvB,GACb3mC,GAAY6mC,GAAiBF,IAG5B3mC,GAFLyO,EAAIo4B,GAAiBF,GACrBC,EAASpvB,GAASovB,IAEVn4B,EAAGm4B,GAGL,KACR,IdqfA7oC,EAAamb,GAAI,MAAO8S,IAUxBjuB,EAAamb,GAAI,qBevjBjB,SAA2B3C,EAAKvf,GAC/B,IAAIsK,EACJ,OACCtK,GACAA,EAAMmR,MACN9N,GAASrD,EAAM8X,QAEfxN,EAAO+O,GAAOrZ,EAAMmR,OAEZ,IAAI7G,EAAMtK,EAAM8X,MAGlB9X,CACR,IfojBA+G,EAAamb,GAAI,YAAaP,IAU9B5a,EAAamb,GAAI,gBAAiBJ,IAUlC/a,EAAamb,GAAI,SzF/gBjB,SAAqB1a,GACpB,IAAI+a,EACAc,EAEJ,IAAM/T,GAAmB9H,GACxB,MAAM,IAAItD,UAAWiB,EAAQ,oEAAqEqC,IAcnG,OARA4b,GAHAb,EAAQ,CAAE/a,EAAI7G,QAGE6G,IAChB6b,EAAQd,EAAM5hB,QAGD,IAEZ4hB,EAAM5hB,OAASwd,GAAOkF,EAAOd,EAAO,EAAG/a,EAAK6b,EAAQ,IAE9Cd,CACR,IyFqgBAxb,EAAamb,GAAI,oBAAqB0nB,IAUtC7iC,EAAamb,GAAI,SgBvlBjB,SAAgBlT,GACf,IAAI6F,EACAI,EAEJ,IAAMxF,GAAcT,GACnB,MAAM,IAAI9K,UAAWiB,EAAQ,8EAA+E6J,IAE7G,GAAK3K,UAAU1D,OAAS,EAAI,CAE3B,IAAMoO,GADN8F,EAAQxQ,UAAW,IAElB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsE0P,IAEpG,GAAKxQ,UAAU1D,OAAS,GAEvB,IAAMoO,GADNkG,EAAM5Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,oEAAqE8P,SAGnGA,EAAMjG,EAAErO,MAEX,MACEkU,EAAQ,EACRI,EAAMjG,EAAErO,OAET,OAAOW,GAAM0N,EAAG6F,EAAOI,EACxB,IhBwkBAlO,EAAamb,GAAI,OAAQ2T,IAUzB9uB,EAAamb,GAAI,sBiBrmBjB,SAAS4tB,EAAoBz7B,GAC5B,IAAIC,EACA8B,EACAsmB,EACArmB,EACAtB,EACArM,EACAwM,EACAtO,EACAyQ,EACAlX,EACJ,IAAMsP,GAAc4E,GACnB,MAAM,IAAInQ,UAAWiB,EAAQ,8EAA+EkP,IAM7G,GAJAgC,EAAO,CACNtB,KAAQ,MACRg7B,IAAO,GAEH1rC,UAAU1D,OAAS,EACvB,GAAKgO,GAAUtK,UAAW,IAAQ,CAEjC,GADA+R,EAAU/R,UAAW,GAChBA,UAAU1D,OAAS,EAAI,CAE3B,IAAMyQ,GADN8D,EAAM7Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,uEAAwE+P,IAEtGZ,EAAUjQ,UAAW,EACrB,CACD,GAAK2E,GAAYoN,EAAS,UACzBC,EAAKtB,KAAOqB,EAAQrB,MACd3F,GAAsBgH,EAAQrB,OACnC,MAAM,IAAI7Q,UAAWiB,EAAQ,2EAA4E,OAAQiR,EAAQrB,OAG3H,GAAK/L,GAAYoN,EAAS,SACzBC,EAAK05B,IAAM35B,EAAQ25B,IACE,IAAhB35B,EAAQ25B,MAA8B,IAAjB35B,EAAQ25B,KACjC,MAAM,IAAI7rC,UAAWiB,EAAQ,wEAAyE,MAAOiR,EAAQ25B,KAG1H,KAAS,CAEN,IAAM3+B,GADN8D,EAAM7Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,iGAAkG+P,IAEhIZ,EAAUjQ,UAAW,EACrB,CAkCF,OAhCAq4B,EAAQ,EAGR3nB,EAAO,CAAA,EACFG,EACc,IAAbmB,EAAK05B,KACT5vC,GAAK,EACL4G,EAAagO,EAAM,QAiCrB,WAGC,OAFA5U,GAAKA,EAAE,GAAKkU,EAAI1T,OAChB+7B,GAAS,EACJh0B,GAAOg0B,EAAQrmB,EAAKtB,MAAuB,IAAfV,EAAI1T,OAC7B,CACNyS,MAAQ,GAGH,CACNpT,MAASkV,EAAIjT,KAAMqS,EAAS1N,EAAKyN,EAAKlU,GAAKA,EAAGu8B,EAAOroB,GACrDjB,MAAQ,EAET,MA3CCjT,EAAIkU,EAAI1T,OACRoG,EAAagO,EAAM,QAkDrB,WAMC,OALA5U,GAAK,GACI,IACRA,GAAKkU,EAAI1T,QAEV+7B,GAAS,EACJh0B,GAAOg0B,EAAQrmB,EAAKtB,MAAuB,IAAfV,EAAI1T,OAC7B,CACNyS,MAAQ,GAGH,CACNpT,MAASkV,EAAIjT,KAAMqS,EAAS1N,EAAKyN,EAAKlU,GAAKA,EAAGu8B,EAAOroB,GACrDjB,MAAQ,EAET,KA/DwB,IAAbiD,EAAK05B,KAChB5vC,GAAK,EACL4G,EAAagO,EAAM,QAqEpB,WAGC,OAFA5U,GAAKA,EAAE,GAAKkU,EAAI1T,OAChB+7B,GAAS,EACJh0B,GAAOg0B,EAAQrmB,EAAKtB,MAAuB,IAAfV,EAAI1T,OAC7B,CACNyS,MAAQ,GAGH,CACNpT,MAAS4G,EAAKyN,EAAKlU,GACnBiT,MAAQ,EAET,MA/EAjT,EAAIkU,EAAI1T,OACRoG,EAAagO,EAAM,QAsFpB,WAMC,OALA5U,GAAK,GACI,IACRA,GAAKkU,EAAI1T,QAEV+7B,GAAS,EACJh0B,GAAOg0B,EAAQrmB,EAAKtB,MAAuB,IAAfV,EAAI1T,OAC7B,CACNyS,MAAQ,GAGH,CACNpT,MAAS4G,EAAKyN,EAAKlU,GACnBiT,MAAQ,EAET,KAnGDrM,EAAagO,EAAM,UA4GnB,SAAc/U,GAEb,OADA0I,GAAM,EACDrE,UAAU1D,OACP,CACNX,MAASA,EACToT,MAAQ,GAGH,CACNA,MAAQ,EAET,IApHIgxB,IACJr9B,EAAagO,EAAMqvB,IA2HpB,WACC,OAAKlvB,EACG46B,EAAoBz7B,EAAKgC,EAAMnB,EAAKZ,GAErCw7B,EAAoBz7B,EAAKgC,EAChC,IA7HDgB,EAAKhP,GAAOgM,GAEXzN,EADIS,EAAiBgN,GACfK,EAAgB2C,GAEhBjP,EAAQiP,GAERtC,CAwHR,IjBuaAhO,EAAamb,GAAI,cAAegpB,IAUhCnkC,EAAamb,GAAI,kBkBjoBjB,SAAS8tB,EAAgB37B,GACxB,IAAIC,EACAS,EACArM,EACAwM,EACAtO,EACAyQ,EACAlX,EACJ,IAAMsP,GAAc4E,GACnB,MAAM,IAAInQ,UAAWiB,EAAQ,8EAA+EkP,IAE7G,GAAKhQ,UAAU1D,OAAS,EAAI,CAE3B,IAAMyQ,GADN8D,EAAM7Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsE+P,IAEpGZ,EAAUjQ,UAAW,EACrB,CAuBD,OAtBAlE,GAAK,EAKJ4G,EAFDgO,EAAO,CAAA,EAEa,OADfG,EA0BL,WAEC,OADA/U,GAAK,EACAuI,GAAOvI,GAAKkU,EAAI1T,OACb,CACNyS,MAAQ,GAGH,CACNpT,MAASkV,EAAIjT,KAAMqS,EAAS1N,EAAKyN,EAAKlU,GAAKA,EAAGkU,GAC9CjB,MAAQ,EAET,EAQD,WAEC,OADAjT,GAAK,EACAuI,GAAOvI,GAAKkU,EAAI1T,OACb,CACNyS,MAAQ,GAGH,CACNpT,MAAS4G,EAAKyN,EAAKlU,GACnBiT,MAAQ,EAET,GAnDDrM,EAAagO,EAAM,UA4DnB,SAAc/U,GAEb,OADA0I,GAAM,EACDrE,UAAU1D,OACP,CACNX,MAASA,EACToT,MAAQ,GAGH,CACNA,MAAQ,EAET,IApEIgxB,IACJr9B,EAAagO,EAAMqvB,IA2EpB,WACC,OAAKlvB,EACG86B,EAAgB37B,EAAKa,EAAKZ,GAE3B07B,EAAgB37B,EACvB,IA7EDgD,EAAKhP,GAAOgM,GAEXzN,EADIS,EAAiBgN,GACfK,EAAgB2C,GAEhBjP,EAAQiP,GAERtC,CAwER,IlB2hBAhO,EAAamb,GAAI,uBmBvoBjB,SAAS+tB,EAAqB57B,GAC7B,IAAIC,EACAS,EACArM,EACAwM,EACAtL,EACAhD,EACAyQ,EACAlX,EACJ,IAAMsP,GAAc4E,GACnB,MAAM,IAAInQ,UAAWiB,EAAQ,8EAA+EkP,IAE7G,GAAKhQ,UAAU1D,OAAS,EAAI,CAE3B,IAAMyQ,GADN8D,EAAM7Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsE+P,IAEpGZ,EAAUjQ,UAAW,EACrB,CAwBD,OAvBAuF,EAAMyK,EAAI1T,OACVR,EAAIyJ,EAKH7C,EAFDgO,EAAO,CAAA,EAEa,OADfG,EA0BL,WAGC,OAFA/U,GAAKkU,EAAI1T,OAASiJ,EAAM,EACxBA,EAAMyK,EAAI1T,OACL+H,GAAOvI,EAAI,GACfuI,GAAM,EACC,CACN0K,MAAQ,IAGH,CACNpT,MAASkV,EAAIjT,KAAMqS,EAAS1N,EAAKyN,EAAKlU,GAAKA,EAAGkU,GAC9CjB,MAAQ,EAET,EAQD,WAGC,OAFAjT,GAAKkU,EAAI1T,OAASiJ,EAAM,EACxBA,EAAMyK,EAAI1T,OACL+H,GAAOvI,EAAI,GACfuI,GAAM,EACC,CACN0K,MAAQ,IAGH,CACNpT,MAAS4G,EAAKyN,EAAKlU,GACnBiT,MAAQ,EAET,GAvDDrM,EAAagO,EAAM,UAgEnB,SAAc/U,GAEb,OADA0I,GAAM,EACDrE,UAAU1D,OACP,CACNX,MAASA,EACToT,MAAQ,GAGH,CACNA,MAAQ,EAET,IAxEIgxB,IACJr9B,EAAagO,EAAMqvB,IA+EpB,WACC,OAAKlvB,EACG+6B,EAAqB57B,EAAKa,EAAKZ,GAEhC27B,EAAqB57B,EAC5B,IAjFDgD,EAAKhP,GAAOgM,GAEXzN,EADIS,EAAiBgN,GACfK,EAAgB2C,GAEhBjP,EAAQiP,GAERtC,CA4ER,InB2hBAhO,EAAamb,GAAI,kBAAmBwhB,IAUpC38B,EAAamb,GAAI,wBoBjqBjB,SAASguB,EAAsB77B,GAC9B,IAAIC,EACAS,EACArM,EACAwM,EACAtO,EACAyQ,EACAlX,EACJ,IAAMsP,GAAc4E,GACnB,MAAM,IAAInQ,UAAWiB,EAAQ,8EAA+EkP,IAE7G,GAAKhQ,UAAU1D,OAAS,EAAI,CAE3B,IAAMyQ,GADN8D,EAAM7Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsE+P,IAEpGZ,EAAUjQ,UAAW,EACrB,CAuBD,OAtBAlE,GAAK,EAKJ4G,EAFDgO,EAAO,CAAA,EAEa,OADfG,EA0BL,WACC,IAAItL,EACJ,GAAKlB,EACJ,MAAO,CACN0K,MAAQ,GAKV,IAFAxJ,EAAMyK,EAAI1T,OACVR,GAAK,EACGA,EAAIyJ,QAAyB,IAAlBhD,EAAKyN,EAAKlU,IAC5BA,GAAK,EAEN,OAAKA,GAAKyJ,GACTlB,GAAM,EACC,CACN0K,MAAQ,IAGH,CACNpT,MAASkV,EAAIjT,KAAMqS,EAAS1N,EAAKyN,EAAKlU,GAAKA,EAAGkU,GAC9CjB,MAAQ,EAET,EAQD,WACC,IAAIxJ,EACJ,GAAKlB,EACJ,MAAO,CACN0K,MAAQ,GAKV,IAFAxJ,EAAMyK,EAAI1T,OACVR,GAAK,EACGA,EAAIyJ,QAAyB,IAAlBhD,EAAKyN,EAAKlU,IAC5BA,GAAK,EAEN,OAAKA,GAAKyJ,GACTlB,GAAM,EACC,CACN0K,MAAQ,IAGH,CACNpT,MAAS4G,EAAKyN,EAAKlU,GACnBiT,MAAQ,EAET,GAzEDrM,EAAagO,EAAM,UAkFnB,SAAc/U,GAEb,OADA0I,GAAM,EACDrE,UAAU1D,OACP,CACNX,MAASA,EACToT,MAAQ,GAGH,CACNA,MAAQ,EAET,IA1FIgxB,IACJr9B,EAAagO,EAAMqvB,IAiGpB,WACC,OAAKlvB,EACGg7B,EAAsB77B,EAAKa,EAAKZ,GAEjC47B,EAAsB77B,EAC7B,IAnGDgD,EAAKhP,GAAOgM,GAEXzN,EADIS,EAAiBgN,GACfK,EAAgB2C,GAEhBjP,EAAQiP,GAERtC,CA8FR,IpBqiBAhO,EAAamb,GAAI,6BqBvqBjB,SAASiuB,EAA2B97B,GACnC,IAAIC,EACAS,EACArM,EACAwM,EACAtL,EACAhD,EACAyQ,EACAlX,EACJ,IAAMsP,GAAc4E,GACnB,MAAM,IAAInQ,UAAWiB,EAAQ,8EAA+EkP,IAE7G,GAAKhQ,UAAU1D,OAAS,EAAI,CAE3B,IAAMyQ,GADN8D,EAAM7Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsE+P,IAEpGZ,EAAUjQ,UAAW,EACrB,CAwBD,OAvBAuF,EAAMyK,EAAI1T,OACVR,EAAIyJ,EAKH7C,EAFDgO,EAAO,CAAA,EAEa,OADfG,EA0BL,WACC,GAAKxM,EACJ,MAAO,CACN0K,MAAQ,GAKV,IAFAjT,GAAKkU,EAAI1T,OAASiJ,EAAM,EACxBA,EAAMyK,EAAI1T,OACFR,GAAK,QAAuB,IAAlByG,EAAKyN,EAAKlU,IAC3BA,GAAK,EAEN,OAAKA,EAAI,GACRuI,GAAM,EACC,CACN0K,MAAQ,IAGH,CACNpT,MAASkV,EAAIjT,KAAMqS,EAAS1N,EAAKyN,EAAKlU,GAAKA,EAAGkU,GAC9CjB,MAAQ,EAET,EAQD,WACC,GAAK1K,EACJ,MAAO,CACN0K,MAAQ,GAKV,IAFAjT,GAAKkU,EAAI1T,OAASiJ,EAAM,EACxBA,EAAMyK,EAAI1T,OACFR,GAAK,QAAuB,IAAlByG,EAAKyN,EAAKlU,IAC3BA,GAAK,EAEN,OAAKA,EAAI,GACRuI,GAAM,EACC,CACN0K,MAAQ,IAGH,CACNpT,MAAS4G,EAAKyN,EAAKlU,GACnBiT,MAAQ,EAET,GAvEDrM,EAAagO,EAAM,UAgFnB,SAAc/U,GAEb,OADA0I,GAAM,EACDrE,UAAU1D,OACP,CACNX,MAASA,EACToT,MAAQ,GAGH,CACNA,MAAQ,EAET,IAxFIgxB,IACJr9B,EAAagO,EAAMqvB,IA+FpB,WACC,OAAKlvB,EACGi7B,EAA2B97B,EAAKa,EAAKZ,GAEtC67B,EAA2B97B,EAClC,IAjGDgD,EAAKhP,GAAOgM,GAEXzN,EADIS,EAAiBgN,GACfK,EAAgB2C,GAEhBjP,EAAQiP,GAERtC,CA4FR,IrB2iBAhO,EAAamb,GAAI,yBsBrqBjB,SAASkuB,EAAuBv6B,EAAGxB,EAAKyF,EAAQjH,GAC/C,IAAIyB,EACAS,EACArM,EACAwM,EACAzN,EACAb,EACAyQ,EACAlX,EACJ,IAAMiP,GAAsByG,GAC3B,MAAM,IAAI3R,UAAWiB,EAAQ,+EAAgF0Q,IAE9G,IAAMpG,GAAc4E,GACnB,MAAM,IAAInQ,UAAWiB,EAAQ,+EAAgFkP,IAE9G,IAAMtF,GAAW+K,GAChB,MAAM,IAAI5V,UAAWiB,EAAQ,oEAAqE2U,IAEnG,IAAM1K,GAAsByD,GAC3B,MAAM,IAAI3O,UAAWiB,EAAQ,gFAAiF0N,IAE/G,GAAKxO,UAAU1D,OAAS,EAAI,CAE3B,IAAMyQ,GADN8D,EAAM7Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,oEAAqE+P,IAEnGZ,EAAUjQ,UAAW,EACrB,CAwBD,OAvBAoD,EAAMoL,EACN1S,GAAK,EAKJ4G,EAFDgO,EAAO,CAAA,EAEa,OADfG,EA0BL,WACC,IAAI5L,EAEJ,OADAnJ,GAAK,EACAuI,GAAOvI,GAAK0V,EACT,CACNzC,MAAQ,IAGV9J,EAAI4L,EAAIjT,KAAMqS,EAAS1N,EAAKyN,EAAK5M,GAAOA,EAAKtH,EAAGkU,GAChD5M,GAAOqS,EACA,CACN9Z,MAASsJ,EACT8J,MAAQ,GAET,EAQD,WACC,IAAI9J,EAEJ,OADAnJ,GAAK,EACAuI,GAAOvI,GAAK0V,EACT,CACNzC,MAAQ,IAGV9J,EAAI1C,EAAKyN,EAAK5M,GACdA,GAAOqS,EACA,CACN9Z,MAASsJ,EACT8J,MAAQ,GAET,GAzDDrM,EAAagO,EAAM,UAkEnB,SAAc/U,GAEb,OADA0I,GAAM,EACDrE,UAAU1D,OACP,CACNX,MAASA,EACToT,MAAQ,GAGH,CACNA,MAAQ,EAET,IA1EIgxB,IACJr9B,EAAagO,EAAMqvB,IAiFpB,WACC,OAAKlvB,EACGk7B,EAAuBv6B,EAAGxB,EAAKyF,EAAQjH,EAAQqC,EAAKZ,GAErD87B,EAAuBv6B,EAAGxB,EAAKyF,EAAQjH,EAC9C,IAnFDwE,EAAKhP,GAAOgM,GAEXzN,EADIS,EAAiBgN,GACfK,EAAgB2C,GAEhBjP,EAAQiP,GAERtC,CA8ER,ItB8iBAhO,EAAamb,GAAI,sBuB1rBjB,SAASmuB,EAAoBh8B,GAC5B,IAAIC,EACA4B,EACApC,EACAiB,EACArM,EACAwM,EACAD,EACArO,EACAyQ,EACAlX,EACJ,IAAMsP,GAAc4E,GACnB,MAAM,IAAInQ,UAAWiB,EAAQ,8EAA+EkP,IAG7G,GAAe,KADfP,EAAQzP,UAAU1D,QAEjBuV,EAAQ,EACRjB,EAAMZ,EAAI1T,YACJ,GAAe,IAAVmT,EACN1C,GAAY/M,UAAW,KAC3B6R,EAAQ,EACRhB,EAAM7Q,UAAW,IAEjB6R,EAAQ7R,UAAW,GAEpB4Q,EAAMZ,EAAI1T,YACJ,GAAe,IAAVmT,EACN1C,GAAY/M,UAAW,KAC3B6R,EAAQ,EACRjB,EAAMZ,EAAI1T,OACVuU,EAAM7Q,UAAW,GACjBiQ,EAAUjQ,UAAW,IACV+M,GAAY/M,UAAW,KAClC6R,EAAQ7R,UAAW,GACnB4Q,EAAMZ,EAAI1T,OACVuU,EAAM7Q,UAAW,KAEjB6R,EAAQ7R,UAAW,GACnB4Q,EAAM5Q,UAAW,QAEZ,CAIN,GAHA6R,EAAQ7R,UAAW,GACnB4Q,EAAM5Q,UAAW,IAEX+M,GADN8D,EAAM7Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsE+P,IAEpGZ,EAAUjQ,UAAW,EACrB,CACD,IAAM0K,GAAWmH,GAChB,MAAM,IAAIhS,UAAWiB,EAAQ,2GAA4G+Q,IAE1I,IAAMnH,GAAWkG,GAChB,MAAM,IAAI/Q,UAAWiB,EAAQ,wGAAyG8P,IAsCvI,OApCKA,EAAM,GACVA,EAAMZ,EAAI1T,OAASsU,GACR,IACVA,EAAM,GAEIA,EAAMZ,EAAI1T,SACrBsU,EAAMZ,EAAI1T,QAENuV,EAAQ,IACZA,EAAQ7B,EAAI1T,OAASuV,GACR,IACZA,EAAQ,GAGV/V,EAAI+V,EAAQ,EAKXnP,EAFDgO,EAAO,CAAA,EAEa,OADfG,EA0BL,WAEC,OADA/U,GAAK,EACAuI,GAAOvI,GAAK8U,EACT,CACN7B,MAAQ,GAGH,CACNpT,MAASkV,EAAIjT,KAAMqS,EAAS1N,EAAKyN,EAAKlU,GAAKA,EAAGA,EAAE+V,EAAO7B,GACvDjB,MAAQ,EAET,EAQD,WAEC,OADAjT,GAAK,EACAuI,GAAOvI,GAAK8U,EACT,CACN7B,MAAQ,GAGH,CACNpT,MAAS4G,EAAKyN,EAAKlU,GACnBiT,MAAQ,EAET,GAnDDrM,EAAagO,EAAM,UA4DnB,SAAiB/U,GAEhB,OADA0I,GAAM,EACDrE,UAAU1D,OACP,CACNX,MAASA,EACToT,MAAQ,GAGH,CACNA,MAAQ,EAET,IApEIgxB,IACJr9B,EAAagO,EAAMqvB,IA2EpB,WACC,OAAKlvB,EACGm7B,EAAoBh8B,EAAK6B,EAAOjB,EAAKC,EAAKZ,GAE3C+7B,EAAoBh8B,EAAK6B,EAAOjB,EACvC,IA7EDoC,EAAKhP,GAAOgM,GAEXzN,EADIS,EAAiBgN,GACfK,EAAgB2C,GAEhBjP,EAAQiP,GAERtC,CAwER,IvBiiBAhO,EAAamb,GAAI,2BwBpsBjB,SAASouB,EAAyBj8B,GACjC,IAAIC,EACA4B,EACApC,EACAiB,EACArM,EACAwM,EACAD,EACArO,EACAyQ,EACAlX,EACJ,IAAMsP,GAAc4E,GACnB,MAAM,IAAInQ,UAAWiB,EAAQ,8EAA+EkP,IAG7G,GAAe,KADfP,EAAQzP,UAAU1D,QAEjBuV,EAAQ,EACRjB,EAAMZ,EAAI1T,YACJ,GAAe,IAAVmT,EACN1C,GAAY/M,UAAW,KAC3B6R,EAAQ,EACRhB,EAAM7Q,UAAW,IAEjB6R,EAAQ7R,UAAW,GAEpB4Q,EAAMZ,EAAI1T,YACJ,GAAe,IAAVmT,EACN1C,GAAY/M,UAAW,KAC3B6R,EAAQ,EACRjB,EAAMZ,EAAI1T,OACVuU,EAAM7Q,UAAW,GACjBiQ,EAAUjQ,UAAW,IACV+M,GAAY/M,UAAW,KAClC6R,EAAQ7R,UAAW,GACnB4Q,EAAMZ,EAAI1T,OACVuU,EAAM7Q,UAAW,KAEjB6R,EAAQ7R,UAAW,GACnB4Q,EAAM5Q,UAAW,QAEZ,CAIN,GAHA6R,EAAQ7R,UAAW,GACnB4Q,EAAM5Q,UAAW,IAEX+M,GADN8D,EAAM7Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsE+P,IAEpGZ,EAAUjQ,UAAW,EACrB,CACD,IAAM0K,GAAWmH,GAChB,MAAM,IAAIhS,UAAWiB,EAAQ,gHAAiH+Q,IAE/I,IAAMnH,GAAWkG,GAChB,MAAM,IAAI/Q,UAAWiB,EAAQ,6GAA8G8P,IAsC5I,OApCKA,EAAM,GACVA,EAAMZ,EAAI1T,OAASsU,GACR,IACVA,EAAM,GAEIA,EAAMZ,EAAI1T,SACrBsU,EAAMZ,EAAI1T,QAENuV,EAAQ,IACZA,EAAQ7B,EAAI1T,OAASuV,GACR,IACZA,EAAQ,GAGV/V,EAAI8U,EAKHlO,EAFDgO,EAAO,CAAA,EAEa,OADfG,EA0BL,WAEC,OADA/U,GAAK,EACAuI,GAAOvI,EAAI+V,EACR,CACN9C,MAAQ,GAGH,CACNpT,MAASkV,EAAIjT,KAAMqS,EAAS1N,EAAKyN,EAAKlU,GAAKA,EAAG8U,EAAI9U,EAAE,EAAGkU,GACvDjB,MAAQ,EAET,EAQD,WAEC,OADAjT,GAAK,EACAuI,GAAOvI,EAAI+V,EACR,CACN9C,MAAQ,GAGH,CACNpT,MAAS4G,EAAKyN,EAAKlU,GACnBiT,MAAQ,EAET,GAnDDrM,EAAagO,EAAM,UA4DnB,SAAiB/U,GAEhB,OADA0I,GAAM,EACDrE,UAAU1D,OACP,CACNX,MAASA,EACToT,MAAQ,GAGH,CACNA,MAAQ,EAET,IApEIgxB,IACJr9B,EAAagO,EAAMqvB,IA2EpB,WACC,OAAKlvB,EACGo7B,EAAyBj8B,EAAK6B,EAAOjB,EAAKC,EAAKZ,GAEhDg8B,EAAyBj8B,EAAK6B,EAAOjB,EAC5C,IA7EDoC,EAAKhP,GAAOgM,GAEXzN,EADIS,EAAiBgN,GACfK,EAAgB2C,GAEhBjP,EAAQiP,GAERtC,CAwER,IxB2iBAhO,EAAamb,GAAI,cZjpBjB,WACC,IAAIpO,EACAzL,EACAiC,EACA9I,EAUJ,GAAc,QADd8I,EAAO+O,GAJNhR,GAHDyL,EAAQzP,UAAU1D,SACJkP,GAAUxL,UAAWyP,EAAM,IAEhCzP,UADRyP,GAAS,GAGDkkB,KAIR,MAAM,IAAI9zB,UAAWiB,EAAQ,sEAAuEkD,IAErG,OAAKyL,GAAS,EACN,IAAIxJ,EAAM,GAEH,IAAVwJ,IACJtS,EAAM6C,UAAW,cAGG6G,GACnB1J,EAAMyS,GAAezS,EAAK,GACfA,aAAe2J,GAC1B3J,EAAM0S,GAAgB1S,EAAK,GAChBA,aAAe4J,KAC1B5J,EAAMuhB,GAAoBvhB,EAAK,IAEzB,IAAI8I,EAAM9I,IAEH,IAAVsS,EACG,IAAIxJ,EAAMjG,UAAU,GAAIA,UAAU,IAEnC,IAAIiG,EAAMjG,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD,IYsnBA0C,EAAamb,GAAI,gBTjqBjB,WACC,IAAIpO,EACAzL,EACAiC,EAUJ,GAAc,QADdA,EAAO+O,GAJNhR,GAHDyL,EAAQzP,UAAU1D,SACJkP,GAAUxL,UAAWyP,EAAM,IAEhCzP,UADRyP,GAAS,GAGDkkB,KAIR,MAAM,IAAI9zB,UAAWiB,EAAQ,sEAAuEkD,IAErG,OAAKyL,GAAS,EACN,IAAIxJ,EAAM,GAEH,IAAVwJ,EACG,IAAIxJ,EAAMjG,UAAU,IAEb,IAAVyP,EACG,IAAIxJ,EAAMjG,UAAU,GAAIA,UAAU,IAEnC,IAAIiG,EAAMjG,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD,ISipBA0C,EAAamb,GAAI,oBAAqBquB,IAUtCxpC,EAAamb,GAAI,yByBtwBjB,WACC,OAAO7K,GAAI,yBACZ,IzB8wBAtQ,EAAamb,GAAI,kBAAmBsuB,IAUpCzpC,EAAamb,GAAI,uB0B1xBjB,WACC,OAAO7K,GAAI,QACZ,I1BkyBAtQ,EAAamb,GAAI,kBAAmBuuB,IAUpC1pC,EAAamb,GAAI,uB2B9yBjB,WACC,OAAO7K,GAAI,iBACZ,I3BszBAtQ,EAAamb,GAAI,iB4BnzBjB,SAAgB7Z,GACf,OAAOgmB,GAAOhmB,IAAW,IAC1B,I5B2zBAtB,EAAamb,GAAI,qB6Bl0BjB,WACC,OAAO7K,GAAI,UACZ,I7B00BAtQ,EAAamb,GAAI,aP3vBjB,WACC,IAAIpO,EACAzL,EACAiC,EAUJ,GAAc,QADdA,EAAO+O,GAJNhR,GAHDyL,EAAQzP,UAAU1D,SACJkP,GAAUxL,UAAWyP,EAAM,IAEhCzP,UADRyP,GAAS,GAGDkkB,KAIR,MAAM,IAAI9zB,UAAWiB,EAAQ,sEAAuEkD,IAErG,OAAKyL,GAAS,EACN,IAAIxJ,EAAM,GAEH,IAAVwJ,EACG,IAAIxJ,EAAMjG,UAAU,IAEb,IAAVyP,EACG,IAAIxJ,EAAMjG,UAAU,GAAIA,UAAU,IAEnC,IAAIiG,EAAMjG,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD,IO2uBA0C,EAAamb,GAAI,kB8Bj1BjB,SAAgB7Z,GACf,OAAOgmB,GAAOhmB,IAAW,IAC1B,I9By1BAtB,EAAamb,GAAI,sB+Bh2BjB,WACC,OAAO7K,GAAI,OACZ,I/Bw2BAtQ,EAAamb,GAAI,uBgCr2BjB,SAAgB7Z,GACf,OAAOgmB,GAAOhmB,IAAW,IAC1B,IhC62BAtB,EAAamb,GAAI,2BiCp3BjB,WACC,OAAO7K,GAAI,sBACZ,IjC43BAtQ,EAAamb,GAAI,uBkCz3BjB,SAAgB7Z,GACf,OAAOgmB,GAAOhmB,IAAW,IAC1B,IlCi4BAtB,EAAamb,GAAI,2BmCx4BjB,WACC,OAAO7K,GAAI,iBACZ,InCg5BAtQ,EAAamb,GAAI,yBoC74BjB,SAAgB7Z,GACf,OAAOgmB,GAAOhmB,IAAW,IAC1B,IpCq5BAtB,EAAamb,GAAI,6BqC55BjB,WACC,OAAO7K,GAAI,mBACZ,IrCo6BAtQ,EAAamb,GAAI,aAAclX,IAU/BjE,EAAamb,GAAI,oBAAqBjX,IAUtClE,EAAamb,GAAI,cAAepX,IAUhC/D,EAAamb,GAAI,cAAenX,IAUhChE,EAAamb,GAAI,SAAUyJ,IAU3B5kB,EAAamb,GAAI,csC98BjB,SAAqBlT,GACpB,IAAIqI,EAAKhP,GAAO2G,GAChB,GAAY,OAAPqI,EACJ,MAAM,IAAInT,UAAWiB,EAAQ,8GAA+G6J,IAK7I,OAHK3K,UAAU1D,OAAS,IACvB0W,EAAKhT,UAAW,IAEVsnB,GAAQ3c,EAAErO,OAAQ0W,EAC1B,ItC+8BAtQ,EAAamb,GAAI,QAASjiB,IAU1B8G,EAAamb,GAAI,auCl+BjB,SAAoBlT,GACnB,IAAIqI,EAAKhP,GAAO2G,GAChB,GAAY,OAAPqI,EACJ,MAAM,IAAInT,UAAWiB,EAAQ,8GAA+G6J,IAK7I,OAHK3K,UAAU1D,OAAS,IACvB0W,EAAKhT,UAAW,IAEVpE,GAAO+O,EAAErO,OAAQ0W,EACzB,IvCm+BAtQ,EAAamb,GAAI,YAAawuB","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,41,42,43,47,48,49,50,54,55,56,57,61,62,63,64,65,69,70,71,72,76,77,78,79,80,84,85,86,87,91,92,93,97,98,99,100,101,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,173,174,175,176,177,178,179,180,181,182,186,187,202,205,206,207,208,211,214,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,244,245,246,248,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,315,316,327,328,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,371,372,373,378,379,380,388,390,391,392,393,394,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,439,450,451,452,453,454,455,456,457,458,459,460,481,482,493,498,499,500,501,534,535,536,537,538,539,540,542,543,557,560,621,720,721,726,727,728,729,730,732,734,737,738,739,740,741,742,744,745,746,747,749,750,751,754,758,759,760,761,762,763,764,767,768,769,770,771,772,773,774,778,779,780,795,800,801,802,806,809,810,811,812,827,828,829,830,835,836,837,838,839,847,848,851,856,857,858,859,860,861,862,863,864,865,866,867,868,869,874,881,882,883,884,885,886,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,920,934]} \ No newline at end of file diff --git a/buffer/README.md b/buffer/README.md deleted file mode 100644 index b29694200..000000000 --- a/buffer/README.md +++ /dev/null @@ -1,285 +0,0 @@ - - -# ArrayBuffer - -> [Constructor][mdn-arraybuffer] which returns an object used to represent a generic, fixed-length raw binary data buffer. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); -``` - -#### ArrayBuffer( size ) - -Returns an [`ArrayBuffer`][mdn-arraybuffer] having a specified number of bytes. - - - -```javascript -var buf = new ArrayBuffer( 5 ); -// returns -``` - -* * * - -### Properties - -#### ArrayBuffer.length - -Number of input arguments the constructor accepts. - - - -```javascript -var len = ArrayBuffer.length; -// returns 1 -``` - -#### ArrayBuffer.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [`ArrayBuffer`][mdn-arraybuffer]. - - - -```javascript -var buf = new ArrayBuffer( 5 ); -var byteLength = buf.byteLength; -// returns 5 -``` - -* * * - -### Methods - -#### ArrayBuffer.isView( arr ) - -Static method which returns a `boolean` indicating if provided a buffer view. - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var view = new Float64Array( 10 ); - -var bool = ArrayBuffer.isView( view ); -// returns true -``` - -#### ArrayBuffer.prototype.slice( \[start\[, end]] ) - -Copies the bytes of an `ArrayBuffer` to a new [`ArrayBuffer`][mdn-arraybuffer]. - - - -```javascript -var b1 = new ArrayBuffer( 10 ); - -var b2 = b1.slice(); -// returns - -var bool = ( b2 === b1 ); -// returns false -``` - -By default, the method copies from the beginning of the [`ArrayBuffer`][mdn-arraybuffer]. To beginning copying from a different byte index, provide a `start` argument, specifying the starting byte index (inclusive). - - - -```javascript -var b1 = new ArrayBuffer( 10 ); -var b2 = b1.slice( 2 ); - -var nbytes = b2.byteLength; -// returns 8 -``` - -If `start < 0`, the index is relative to the end of the [`ArrayBuffer`][mdn-arraybuffer]. - - - -```javascript -var b1 = new ArrayBuffer( 10 ); -var b2 = b1.slice( -2 ); - -var nbytes = b2.byteLength; -// returns 2 -``` - -By default, the method copies to the end of the [`ArrayBuffer`][mdn-arraybuffer]. To copy until a particular byte index, provide an `end` index, specifying the ending byte index (exclusive). - - - -```javascript -var b1 = new ArrayBuffer( 10 ); -var b2 = b1.slice( 2, 6 ); - -var nbytes = b2.byteLength; -// returns 4 -``` - -If `end < 0`, the index is relative to the end of the [`ArrayBuffer`][mdn-arraybuffer]. - - - -```javascript -var b1 = new ArrayBuffer( 10 ); -var b2 = b1.slice( 2, -2 ); - -var nbytes = b2.byteLength; -// returns 6 -``` - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Uint8Array = require( '@stdlib/array/uint8' ); -var toBinaryString = require( '@stdlib/number/uint8/base/to-binary-string' ); -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var bytes; -var buf; -var arr; -var i; - -// Create a new ArrayBuffer: -buf = new ArrayBuffer( 64 ); - -// Create a Float64 array buffer view: -arr = new Float64Array( buf.byteLength/8 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} - -// Create a "bytes" view of the array buffer: -bytes = new Uint8Array( arr.buffer ); - -// Print the bytes: -for ( i = 0; i < bytes.length; i++ ) { - console.log( 'byte %d: %s', i, toBinaryString( bytes[ i ] ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/buffer/benchmark/benchmark.js b/buffer/benchmark/benchmark.js deleted file mode 100644 index 579bbbbf1..000000000 --- a/buffer/benchmark/benchmark.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var hasArrayBufferSupport = require( '@stdlib/assert/has-arraybuffer-support' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasArrayBufferSupport() // TODO: remove once ArrayBuffer polyfill is written -}; - - -// MAIN // - -bench( pkg, opts, function benchmark( b ) { - var buf; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf = new ctor( 0 ); - if ( buf.byteLength !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArrayBuffer( buf ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/buffer/benchmark/benchmark.length.js b/buffer/benchmark/benchmark.length.js deleted file mode 100644 index c58f5d1e5..000000000 --- a/buffer/benchmark/benchmark.length.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasArrayBufferSupport = require( '@stdlib/assert/has-arraybuffer-support' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasArrayBufferSupport() // TODO: remove once ArrayBuffer polyfill is written -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var buf; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf = new ctor( len ); - if ( buf.byteLength !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArrayBuffer( buf ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, opts, f ); - } -} - -main(); diff --git a/buffer/docs/repl.txt b/buffer/docs/repl.txt deleted file mode 100644 index c99f899ad..000000000 --- a/buffer/docs/repl.txt +++ /dev/null @@ -1,92 +0,0 @@ - -{{alias}}( size ) - Returns an array buffer having a specified number of bytes. - - Buffer contents are initialized to 0. - - Parameters - ---------- - size: integer - Number of bytes. - - Returns - ------- - out: ArrayBuffer - An array buffer. - - Examples - -------- - > var buf = new {{alias}}( 5 ) - - - -{{alias}}.length - Number of input arguments the constructor accepts. - - Examples - -------- - > {{alias}}.length - 1 - - -{{alias}}.isView( arr ) - Returns a boolean indicating if provided an array buffer view. - - Parameters - ---------- - arr: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating if an input argument is a buffer view. - - Examples - -------- - > var arr = new {{alias:@stdlib/array/float64}}( 10 ); - > {{alias}}.isView( arr ) - true - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the array buffer. - - Examples - -------- - > var buf = new {{alias}}( 5 ); - > buf.byteLength - 5 - - -{{alias}}.prototype.slice( [start[, end]] ) - Copies the bytes of an array buffer to a new array buffer. - - Parameters - ---------- - start: integer (optional) - Index at which to start copying buffer contents (inclusive). If - negative, the index is relative to the end of the buffer. - - end: integer (optional) - Index at which to stop copying buffer contents (exclusive). If negative, - the index is relative to the end of the buffer. - - Returns - ------- - out: ArrayBuffer - A new array buffer whose contents have been copied from the calling - array buffer. - - Examples - -------- - > var b1 = new {{alias}}( 10 ); - > var b2 = b1.slice( 2, 6 ); - > var bool = ( b1 === b2 ) - false - > b2.byteLength - 4 - - See Also - -------- - diff --git a/buffer/docs/types/index.d.ts b/buffer/docs/types/index.d.ts deleted file mode 100644 index 8380dfa92..000000000 --- a/buffer/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer. -*/ -export = ArrayBuffer; diff --git a/buffer/docs/types/test.ts b/buffer/docs/types/test.ts deleted file mode 100644 index 07c5c0e5d..000000000 --- a/buffer/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ArrayBuffer = require( './index' ); - - -// TESTS // - -// The function returns a data view instance... -{ - new ArrayBuffer( 5 ); // $ExpectType ArrayBuffer -} - -// The constructor function has to be invoked with `new`... -{ - ArrayBuffer( 5 ); // $ExpectError -} diff --git a/buffer/examples/index.js b/buffer/examples/index.js deleted file mode 100644 index 77373ea8b..000000000 --- a/buffer/examples/index.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var proc = require( 'process' ); -var hasArrayBufferSupport = require( '@stdlib/assert/has-arraybuffer-support' ); -var randu = require( '@stdlib/random/base/randu' ); -var Float64Array = require( './../../float64' ); -var Uint8Array = require( './../../uint8' ); -var toBinaryString = require( '@stdlib/number/uint8/base/to-binary-string' ); -var ArrayBuffer = require( './../lib' ); - -var bytes; -var buf; -var arr; -var i; - -if ( !hasArrayBufferSupport() ) { - // TODO: remove once ArrayBuffer polyfill is written - console.error( 'Environment does not provide ArrayBuffer support.' ); - proc.exit( 0 ); -} -// Create a new ArrayBuffer: -buf = new ArrayBuffer( 64 ); - -// Create a Float64 array buffer view: -arr = new Float64Array( buf.byteLength/8 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} - -// Create a "bytes" view of the array buffer: -bytes = new Uint8Array( arr.buffer ); - -// Print the bytes: -for ( i = 0; i < bytes.length; i++ ) { - console.log( 'byte %d: %s', i, toBinaryString( bytes[ i ] ) ); -} diff --git a/buffer/lib/index.js b/buffer/lib/index.js deleted file mode 100644 index 03be58f9e..000000000 --- a/buffer/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer. -* -* @module @stdlib/array/buffer -* -* @example -* var ctor = require( '@stdlib/array/buffer' ); -* -* var buf = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasArrayBufferSupport = require( '@stdlib/assert/has-arraybuffer-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasArrayBufferSupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/buffer/lib/main.js b/buffer/lib/main.js deleted file mode 100644 index 39e05e18a..000000000 --- a/buffer/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof ArrayBuffer === 'function' ) ? ArrayBuffer : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/buffer/lib/polyfill.js b/buffer/lib/polyfill.js deleted file mode 100644 index f12499804..000000000 --- a/buffer/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/buffer/package.json b/buffer/package.json deleted file mode 100644 index 8e8caeae1..000000000 --- a/buffer/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/buffer", - "version": "0.0.0", - "description": "ArrayBuffer.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "arraybuffer", - "buffer", - "buf", - "binary" - ] -} diff --git a/buffer/test/test.js b/buffer/test/test.js deleted file mode 100644 index e2db906a6..000000000 --- a/buffer/test/test.js +++ /dev/null @@ -1,195 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasArrayBufferSupport = require( '@stdlib/assert/has-arraybuffer-support' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Float64Array = require( './../../float64' ); -var MAX_SAFE_INTEGER = require( '@stdlib/constants/float64/max-safe-integer' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasProp = require( '@stdlib/assert/has-property' ); -var NODE_VERSION = require( '@stdlib/process/node-version' ); -var polyfill = require( './../lib/polyfill.js' ); -var Ctor = require( './../lib' ); - - -// VARIABLES // - -var FLG = hasArrayBufferSupport(); -var opts = { - 'skip': ( NODE_VERSION && NODE_VERSION.slice( 0, 4 ) === '0.10' ) // FIXME: remove once polyfill is written -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `ArrayBuffer`, the export is an alias for `ArrayBuffer`', function test( t ) { - var Foo = proxyquire( './../lib', { - '@stdlib/assert/has-arraybuffer-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( FLG ) { - t.strictEqual( Ctor, ArrayBuffer, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `ArrayBuffer`, the export is a polyfill', function test( t ) { - var Foo = proxyquire( './../lib', { - '@stdlib/assert/has-arraybuffer-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); - -tape( 'the main export is a constructor', opts, function test( t ) { - var buf = new Ctor( 10 ); - t.strictEqual( instanceOf( buf, Ctor ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor has a static method for testing whether a value is a buffer view', opts, function test( t ) { - var arr; - - t.strictEqual( isFunction( Ctor.isView ), true, 'has method' ); - - arr = new Float64Array( 10 ); - t.strictEqual( Ctor.isView( arr ), true, 'returns expected value' ); - t.strictEqual( Ctor.isView( [] ), false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor length is equal to `1`', opts, function test( t ) { - t.strictEqual( Ctor.length, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a value exceeding `2^53-1`', opts, function test( t ) { - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - return new Ctor( MAX_SAFE_INTEGER+1 ); - } -}); - -tape( 'the constructor returns an `ArrayBuffer` instance having a `byteLength` property, which returns the number of bytes in an `ArrayBuffer`', opts, function test( t ) { - var buf; - - t.strictEqual( hasOwnProp( Ctor.prototype, 'byteLength' ), true, 'has prototype property' ); - - buf = new Ctor( 10 ); - t.strictEqual( hasOwnProp( buf, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( buf, 'byteLength' ), true, 'has property' ); - t.strictEqual( buf.byteLength, 10, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an `ArrayBuffer` instance having a `slice` method, which copies the bytes of an `ArrayBuffer` to a new `ArrayBuffer`', opts, function test( t ) { - var b1; - var b2; - - t.strictEqual( hasOwnProp( Ctor.prototype, 'slice' ), true, 'has prototype property' ); - t.strictEqual( isFunction( Ctor.prototype.slice ), true, 'has method' ); - - b1 = new Ctor( 10 ); - t.strictEqual( hasOwnProp( b1, 'slice' ), false, 'does not have own property' ); - t.strictEqual( hasProp( b1, 'slice' ), true, 'has property' ); - - b2 = b1.slice(); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, b1.byteLength, 'has same number of bytes' ); - - b2 = b1.slice( 2 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 8, 'has expected number of bytes' ); - - b2 = b1.slice( b1.byteLength + 10 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 0, 'has expected number of bytes' ); - - b2 = b1.slice( -2 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 2, 'has expected number of bytes' ); - - b2 = b1.slice( -100 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 10, 'has expected number of bytes' ); - - b2 = b1.slice( 0, 6 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 6, 'has expected number of bytes' ); - - b2 = b1.slice( 2, 6 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 4, 'has expected number of bytes' ); - - b2 = b1.slice( 0, -2 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 8, 'has expected number of bytes' ); - - b2 = b1.slice( 0, -100 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 0, 'has expected number of bytes' ); - - b2 = b1.slice( -4, -2 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 2, 'has expected number of bytes' ); - - t.end(); -}); diff --git a/buffer/test/test.polyfill.js b/buffer/test/test.polyfill.js deleted file mode 100644 index 9d6fcb190..000000000 --- a/buffer/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests diff --git a/byte-orders/README.md b/byte-orders/README.md deleted file mode 100644 index 7f18a6c05..000000000 --- a/byte-orders/README.md +++ /dev/null @@ -1,119 +0,0 @@ - - -# byteOrders - -> List of byte orders. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var byteOrders = require( '@stdlib/array/byte-orders' ); -``` - -#### byteOrders() - -Returns a list of byte orders. - -```javascript -var out = byteOrders(); -// e.g., returns [ 'little-endian', 'big-endian' ] -``` - -The output array contains the following orders: - -- **little-endian**: bytes are ordered from least-to-most significant byte. -- **big-endian**: bytes are ordered from most-to-least significant byte. - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var contains = require( '@stdlib/array/base/assert/contains' ).factory; -var byteOrders = require( '@stdlib/array/byte-orders' ); - -var isByteOrder = contains( byteOrders() ); - -var bool = isByteOrder( 'little-endian' ); -// returns true - -bool = isByteOrder( 'big-endian' ); -// returns true - -bool = isByteOrder( 'beep' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/byte-orders/benchmark/benchmark.js b/byte-orders/benchmark/benchmark.js deleted file mode 100644 index d965e8bbc..000000000 --- a/byte-orders/benchmark/benchmark.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var pkg = require( './../package.json' ).name; -var byteOrders = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = byteOrders(); - if ( out.length !== 2 ) { - b.fail( 'should return an array of length 2' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/byte-orders/docs/repl.txt b/byte-orders/docs/repl.txt deleted file mode 100644 index 4cbbb3a6e..000000000 --- a/byte-orders/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}() - Returns a list of byte orders. - - The output array contains the following orders: - - - little-endian: bytes are ordered from least-to-most significant byte. - - big-endian: bytes are ordered from most-to-least significant byte. - - Returns - ------- - out: Array - List of byte orders. - - Examples - -------- - > var out = {{alias}}() - [...] - - See Also - -------- - diff --git a/byte-orders/docs/types/index.d.ts b/byte-orders/docs/types/index.d.ts deleted file mode 100644 index 939a7d5d9..000000000 --- a/byte-orders/docs/types/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a list of byte orders. -* -* ## Notes -* -* - The output array contains the following orders: -* -* - little-endian: bytes are ordered from least-to-most significant byte. -* - big-endian: bytes are ordered from most-to-least significant byte. -* -* @returns list of byte orders -* -* @example -* var list = byteOrders(); -* // e.g., returns [ 'little-endian', 'big-endian' ] -*/ -declare function byteOrders(): Array; - - -// EXPORTS // - -export = byteOrders; diff --git a/byte-orders/docs/types/test.ts b/byte-orders/docs/types/test.ts deleted file mode 100644 index 7a90a2a17..000000000 --- a/byte-orders/docs/types/test.ts +++ /dev/null @@ -1,32 +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. -*/ - -import byteOrders = require( './index' ); - - -// TESTS // - -// The function returns an array of strings... -{ - byteOrders(); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided any arguments... -{ - byteOrders( 9 ); // $ExpectError -} diff --git a/byte-orders/examples/index.js b/byte-orders/examples/index.js deleted file mode 100644 index ced487ba7..000000000 --- a/byte-orders/examples/index.js +++ /dev/null @@ -1,36 +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. -*/ - -'use strict'; - -var contains = require( './../../base/assert/contains' ).factory; -var byteOrders = require( './../lib' ); - -var isByteOrder = contains( byteOrders() ); - -var bool = isByteOrder( 'little-endian' ); -console.log( bool ); -// => true - -bool = isByteOrder( 'big-endian' ); -console.log( bool ); -// => true - -bool = isByteOrder( 'beep' ); -console.log( bool ); -// => false diff --git a/byte-orders/lib/index.js b/byte-orders/lib/index.js deleted file mode 100644 index 9969e2f7a..000000000 --- a/byte-orders/lib/index.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -/** -* Return a list of byte orders. -* -* @module @stdlib/array/byte-orders -* -* @example -* var orders = require( '@stdlib/array/byte-orders' ); -* -* var list = orders(); -* // e.g., returns [ 'little-endian', 'big-endian' ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/byte-orders/lib/main.js b/byte-orders/lib/main.js deleted file mode 100644 index 09d60ff1a..000000000 --- a/byte-orders/lib/main.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -// MODULES // - -var ORDERS = require( './orders.json' ); - - -// MAIN // - -/** -* Returns a list of byte orders. -* -* @returns {StringArray} list of byte orders -* -* @example -* var list = orders(); -* // e.g., returns [ 'little-endian', 'big-endian' ] -*/ -function orders() { - return ORDERS.slice(); -} - - -// EXPORTS // - -module.exports = orders; diff --git a/byte-orders/lib/orders.json b/byte-orders/lib/orders.json deleted file mode 100644 index 0505d6211..000000000 --- a/byte-orders/lib/orders.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "little-endian", - "big-endian" -] diff --git a/byte-orders/package.json b/byte-orders/package.json deleted file mode 100644 index 097a17990..000000000 --- a/byte-orders/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/byte-orders", - "version": "0.0.0", - "description": "List of byte orders.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "order", - "little-endian", - "big-endian", - "layout", - "memory", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/byte-orders/test/test.js b/byte-orders/test/test.js deleted file mode 100644 index 15f4a90ea..000000000 --- a/byte-orders/test/test.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var orders = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof orders, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a list of byte orders', function test( t ) { - var expected; - var actual; - - expected = [ - 'little-endian', - 'big-endian' - ]; - actual = orders(); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/cartesian-power/README.md b/cartesian-power/README.md deleted file mode 100644 index 5c6fb4314..000000000 --- a/cartesian-power/README.md +++ /dev/null @@ -1,119 +0,0 @@ - - -# cartesianPower - -> Return the [Cartesian power][cartesian-product]. - -
- -## Usage - -```javascript -var cartesianPower = require( '@stdlib/array/cartesian-power' ); -``` - -#### cartesianPower( x, n ) - -Returns the [Cartesian power][cartesian-product]. - -```javascript -var x = [ 1, 2 ]; - -var out = cartesianPower( x, 2 ); -// returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -``` - -If provided an empty array, the function returns an empty array. - -```javascript -var out = cartesianPower( [], 2 ); -// returns [] -``` - -If `n` is less than or equal to zero, the function returns an empty array. - -```javascript -var out = cartesianPower( [ 1, 2 ], 0 ); -// returns [] -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var linspace = require( '@stdlib/array/linspace' ); -var cartesianPower = require( '@stdlib/array/cartesian-power' ); - -var x = linspace( 0, 5, 6 ); - -var out = cartesianPower( x, 3 ); -// returns [ [ 0, 0, 0 ], [ 0, 0, 1 ], ..., [ 5, 5, 4 ], [ 5, 5, 5 ] ] -``` - -
- - - - - - - - - - - - - - diff --git a/cartesian-power/benchmark/benchmark.js b/cartesian-power/benchmark/benchmark.js deleted file mode 100644 index b0a3a3d4a..000000000 --- a/cartesian-power/benchmark/benchmark.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var cartesianPower = require( './../lib' ); - - -// MAIN // - -bench( pkg+':exponent=2,len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianPower( x, 2 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/cartesian-power/benchmark/benchmark.length.js b/cartesian-power/benchmark/benchmark.length.js deleted file mode 100644 index cf5fbae3c..000000000 --- a/cartesian-power/benchmark/benchmark.length.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var cartesianPower = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = discreteUniform( len, 0, 3 ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianPower( x, 2 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 2^min - max = 10; // 2^max - - for ( i = min; i <= max; i++ ) { - len = pow( 2, i ); - f = createBenchmark( len ); - bench( pkg+':exponent=2,len='+(len*len), f ); - } -} - -main(); diff --git a/cartesian-power/docs/repl.txt b/cartesian-power/docs/repl.txt deleted file mode 100644 index 7dc356d67..000000000 --- a/cartesian-power/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, n ) - Returns the Cartesian power. - - If provided an empty array, the function returns an empty array. - - If `n` is less than or equal to zero, the function returns an empty array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - n: integer - Power. - - Returns - ------- - out: Array - Cartesian product. - - Examples - -------- - > var x = [ 1, 2 ]; - > var out = {{alias}}( x, 2 ) - [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] - - See Also - -------- - diff --git a/cartesian-power/docs/types/index.d.ts b/cartesian-power/docs/types/index.d.ts deleted file mode 100644 index 130ee002b..000000000 --- a/cartesian-power/docs/types/index.d.ts +++ /dev/null @@ -1,48 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns the Cartesian power. -* -* ## Notes -* -* - If provided an empty array, the function returns an empty array. -* - If `n` is less than or equal to zero, the function returns an empty array. -* -* @param x - input array -* @param n - power -* @returns Cartesian product -* -* @example -* var x = [ 1, 2 ]; -* -* var out = cartesianPower( x, 2 ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ -declare function cartesianPower( x: Collection | AccessorArrayLike, n: number ): Array>; - - -// EXPORTS // - -export = cartesianPower; diff --git a/cartesian-power/docs/types/test.ts b/cartesian-power/docs/types/test.ts deleted file mode 100644 index 77a5cc773..000000000 --- a/cartesian-power/docs/types/test.ts +++ /dev/null @@ -1,58 +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. -*/ - -import cartesianPower = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - cartesianPower( [ 1, 2, 3, 4 ], 3 ); // $ExpectType number[][] - cartesianPower( [ 1, 2, 3, 4 ], 3 ); // $ExpectType number[][] - cartesianPower( [ '1', '2', '3', '4' ], 3 ); // $ExpectType string[][] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cartesianPower( 1, 3 ); // $ExpectError - cartesianPower( true, 3 ); // $ExpectError - cartesianPower( false, 3 ); // $ExpectError - cartesianPower( null, 3 ); // $ExpectError - cartesianPower( void 0, 3 ); // $ExpectError - cartesianPower( {}, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - cartesianPower( [ 1, 2 ], '1' ); // $ExpectError - cartesianPower( [ 1, 2 ], true ); // $ExpectError - cartesianPower( [ 1, 2 ], false ); // $ExpectError - cartesianPower( [ 1, 2 ], null ); // $ExpectError - cartesianPower( [ 1, 2 ], void 0 ); // $ExpectError - cartesianPower( [ 1, 2 ], {} ); // $ExpectError - cartesianPower( [ 1, 2 ], [] ); // $ExpectError - cartesianPower( [ 1, 2 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cartesianPower(); // $ExpectError - cartesianPower( [], 2, [] ); // $ExpectError - cartesianPower( [], 2, [], [] ); // $ExpectError -} diff --git a/cartesian-power/examples/index.js b/cartesian-power/examples/index.js deleted file mode 100644 index 62286836b..000000000 --- a/cartesian-power/examples/index.js +++ /dev/null @@ -1,28 +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. -*/ - -'use strict'; - -var linspace = require( './../../linspace' ); -var cartesianPower = require( './../lib' ); - -var x = linspace( 0, 5, 6 ); - -var out = cartesianPower( x, 3 ); -console.log( out ); -// => [ [ 0, 0, 0 ], [ 0, 0, 1 ], ..., [ 5, 5, 4 ], [ 5, 5, 5 ] ] diff --git a/cartesian-power/lib/index.js b/cartesian-power/lib/index.js deleted file mode 100644 index 29f119eea..000000000 --- a/cartesian-power/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Return the Cartesian power. -* -* @module @stdlib/array/cartesian-power -* -* @example -* var cartesianPower = require( '@stdlib/array/cartesian-power' ); -* -* var x = [ 1, 2 ]; -* -* var out = cartesianPower( x, 2 ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ - -// MAIN // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/cartesian-power/lib/main.js b/cartesian-power/lib/main.js deleted file mode 100644 index 979939a03..000000000 --- a/cartesian-power/lib/main.js +++ /dev/null @@ -1,59 +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. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert/is-collection' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var base = require( './../../base/cartesian-power' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns the Cartesian power. -* -* @param {Collection} x - input array -* @param {NonNegativeInteger} n - power -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} second argument must be a nonnegative integer -* @returns {Array} list of ordered tuples comprising the Cartesian product -* -* @example -* var x = [ 1, 2 ]; -* -* var out = cartesianPower( x, 2 ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ -function cartesianPower( x, n ) { - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) ); - } - if ( !isNonNegativeInteger( n ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', n ) ); - } - return base( x, n ); -} - - -// EXPORTS // - -module.exports = cartesianPower; diff --git a/cartesian-power/package.json b/cartesian-power/package.json deleted file mode 100644 index 2b02c7292..000000000 --- a/cartesian-power/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/cartesian-power", - "version": "0.0.0", - "description": "Return the Cartesian power.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "cartesian", - "sets", - "math", - "mathematics", - "ordered", - "power" - ] -} diff --git a/cartesian-power/test/test.js b/cartesian-power/test/test.js deleted file mode 100644 index 87a8be955..000000000 --- a/cartesian-power/test/test.js +++ /dev/null @@ -1,293 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var cartesianPower = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cartesianPower, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - cartesianPower( value, 2 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - cartesianPower( [ 1, 2 ], value ); - }; - } -}); - -tape( 'the function returns the Cartesian power (n=1)', function test( t ) { - var expected; - var actual; - - actual = cartesianPower( [ 1, 2 ], 1 ); - expected = [ [ 1 ], [ 2 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1 ], 1 ); - expected = [ [ 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1, 2, 3 ], 1 ); - expected = [ - [ 1 ], - [ 2 ], - [ 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the Cartesian power (n=2)', function test( t ) { - var expected; - var actual; - - actual = cartesianPower( [ 1, 2 ], 2 ); - expected = [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1 ], 2 ); - expected = [ [ 1, 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1, 2, 3 ], 2 ); - expected = [ - [ 1, 1 ], - [ 1, 2 ], - [ 1, 3 ], - [ 2, 1 ], - [ 2, 2 ], - [ 2, 3 ], - [ 3, 1 ], - [ 3, 2 ], - [ 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the Cartesian power (n=3; indexed)', function test( t ) { - var expected; - var actual; - - actual = cartesianPower( [ 1, 2 ], 3 ); - expected = [ - [ 1, 1, 1 ], - [ 1, 1, 2 ], - [ 1, 2, 1 ], - [ 1, 2, 2 ], - [ 2, 1, 1 ], - [ 2, 1, 2 ], - [ 2, 2, 1 ], - [ 2, 2, 2 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1 ], 3 ); - expected = [ [ 1, 1, 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( [ 1, 2, 3 ], 3 ); - expected = [ - [ 1, 1, 1 ], - [ 1, 1, 2 ], - [ 1, 1, 3 ], - [ 1, 2, 1 ], - [ 1, 2, 2 ], - [ 1, 2, 3 ], - [ 1, 3, 1 ], - [ 1, 3, 2 ], - [ 1, 3, 3 ], - [ 2, 1, 1 ], - [ 2, 1, 2 ], - [ 2, 1, 3 ], - [ 2, 2, 1 ], - [ 2, 2, 2 ], - [ 2, 2, 3 ], - [ 2, 3, 1 ], - [ 2, 3, 2 ], - [ 2, 3, 3 ], - [ 3, 1, 1 ], - [ 3, 1, 2 ], - [ 3, 1, 3 ], - [ 3, 2, 1 ], - [ 3, 2, 2 ], - [ 3, 2, 3 ], - [ 3, 3, 1 ], - [ 3, 3, 2 ], - [ 3, 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the Cartesian power (n=3; accessor)', function test( t ) { - var expected; - var actual; - - actual = cartesianPower( toAccessorArray( [ 1, 2 ] ), 3 ); - expected = [ - [ 1, 1, 1 ], - [ 1, 1, 2 ], - [ 1, 2, 1 ], - [ 1, 2, 2 ], - [ 2, 1, 1 ], - [ 2, 1, 2 ], - [ 2, 2, 1 ], - [ 2, 2, 2 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( toAccessorArray( [ 1 ] ), 3 ); - expected = [ [ 1, 1, 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianPower( toAccessorArray( [ 1, 2, 3 ] ), 3 ); - expected = [ - [ 1, 1, 1 ], - [ 1, 1, 2 ], - [ 1, 1, 3 ], - [ 1, 2, 1 ], - [ 1, 2, 2 ], - [ 1, 2, 3 ], - [ 1, 3, 1 ], - [ 1, 3, 2 ], - [ 1, 3, 3 ], - [ 2, 1, 1 ], - [ 2, 1, 2 ], - [ 2, 1, 3 ], - [ 2, 2, 1 ], - [ 2, 2, 2 ], - [ 2, 2, 3 ], - [ 2, 3, 1 ], - [ 2, 3, 2 ], - [ 2, 3, 3 ], - [ 3, 1, 1 ], - [ 3, 1, 2 ], - [ 3, 1, 3 ], - [ 3, 2, 1 ], - [ 3, 2, 2 ], - [ 3, 2, 3 ], - [ 3, 3, 1 ], - [ 3, 3, 2 ], - [ 3, 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty array (indexed)', function test( t ) { - var actual; - - actual = cartesianPower( [], 1 ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianPower( [], 2 ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianPower( [], 3 ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty array (accessors)', function test( t ) { - var actual; - - actual = cartesianPower( toAccessorArray( [] ), 1 ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianPower( toAccessorArray( [] ), 2 ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianPower( toAccessorArray( [] ), 3 ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided a power equal to zero', function test( t ) { - var actual; - - actual = cartesianPower( [ 1, 2 ], 0 ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); diff --git a/cartesian-product/README.md b/cartesian-product/README.md deleted file mode 100644 index 936fc00bf..000000000 --- a/cartesian-product/README.md +++ /dev/null @@ -1,117 +0,0 @@ - - -# cartesianProduct - -> Return the [Cartesian product][cartesian-product]. - -
- -## Usage - -```javascript -var cartesianProduct = require( '@stdlib/array/cartesian-product' ); -``` - -#### cartesianProduct( x1, x2 ) - -Returns the [Cartesian product][cartesian-product]. - -```javascript -var x1 = [ 1, 2, 3 ]; -var x2 = [ 4, 5 ]; - -var out = cartesianProduct( x1, x2 ); -// returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -``` - -If provided one or more empty arrays, the function returns an empty array. - -```javascript -var x1 = [ 1, 2, 3, 4 ]; -var x2 = []; - -var out = cartesianProduct( x1, x2 ); -// returns [] -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var linspace = require( '@stdlib/array/linspace' ); -var cartesianProduct = require( '@stdlib/array/cartesian-product' ); - -var x1 = linspace( 0, 5, 6 ); -var x2 = linspace( 10, 15, 6 ); - -var out = cartesianProduct( x1, x2 ); -// returns [ [ 0, 10 ], [ 0, 11 ], ..., [ 5, 14 ], [ 5, 15 ] ] -``` - -
- - - - - - - - - - - - - - diff --git a/cartesian-product/benchmark/benchmark.js b/cartesian-product/benchmark/benchmark.js deleted file mode 100644 index 7ef9e94db..000000000 --- a/cartesian-product/benchmark/benchmark.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var cartesianProduct = require( './../lib' ); - - -// MAIN // - -bench( pkg+':len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianProduct( x, x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/cartesian-product/benchmark/benchmark.length.js b/cartesian-product/benchmark/benchmark.length.js deleted file mode 100644 index 2a2cfe155..000000000 --- a/cartesian-product/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var cartesianProduct = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = discreteUniform( len/2, 0, 3 ); - var y = [ 1, 2 ]; - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianProduct( x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/cartesian-product/docs/repl.txt b/cartesian-product/docs/repl.txt deleted file mode 100644 index 0ab51ad50..000000000 --- a/cartesian-product/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( x1, x2 ) - Returns the Cartesian product. - - If provided one or more empty arrays, the function returns an empty array. - - Parameters - ---------- - x1: ArrayLikeObject - First input array. - - x2: ArrayLikeObject - Second input array. - - Returns - ------- - out: Array - Cartesian product. - - Examples - -------- - > var x1 = [ 1, 2 ]; - > var x2 = [ 3, 4 ]; - > var out = {{alias}}( x1, x2 ) - [ [ 1, 3 ], [ 1, 4 ], [ 2, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/cartesian-product/docs/types/index.d.ts b/cartesian-product/docs/types/index.d.ts deleted file mode 100644 index d4ade0add..000000000 --- a/cartesian-product/docs/types/index.d.ts +++ /dev/null @@ -1,48 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns the Cartesian product. -* -* ## Notes -* -* - If provided one or more empty arrays, the function returns an empty array. -* -* @param x1 - first input array -* @param x2 - second input array -* @returns Cartesian product -* -* @example -* var x1 = [ 1, 2, 3 ]; -* var x2 = [ 4, 5 ]; -* -* var out = cartesianProduct( x1, x2 ); -* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -*/ -declare function cartesianProduct( x1: Collection | AccessorArrayLike, x2: Collection | AccessorArrayLike ): Array<[T, U]>; - - -// EXPORTS // - -export = cartesianProduct; diff --git a/cartesian-product/docs/types/test.ts b/cartesian-product/docs/types/test.ts deleted file mode 100644 index 5fd10ac55..000000000 --- a/cartesian-product/docs/types/test.ts +++ /dev/null @@ -1,54 +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. -*/ - -import cartesianProduct = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - cartesianProduct( [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType [number, number][] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cartesianProduct( 1, [ 1, 3 ] ); // $ExpectError - cartesianProduct( true, [ 1, 3 ] ); // $ExpectError - cartesianProduct( false, [ 1, 3 ] ); // $ExpectError - cartesianProduct( null, [ 1, 3 ] ); // $ExpectError - cartesianProduct( void 0, [ 1, 3 ] ); // $ExpectError - cartesianProduct( {}, [ 1, 3 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - cartesianProduct( [], 1 ); // $ExpectError - cartesianProduct( [], true ); // $ExpectError - cartesianProduct( [], false ); // $ExpectError - cartesianProduct( [], null ); // $ExpectError - cartesianProduct( [], void 0 ); // $ExpectError - cartesianProduct( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cartesianProduct(); // $ExpectError - cartesianProduct( [] ); // $ExpectError - cartesianProduct( [], [], [] ); // $ExpectError -} diff --git a/cartesian-product/examples/index.js b/cartesian-product/examples/index.js deleted file mode 100644 index 727250ad8..000000000 --- a/cartesian-product/examples/index.js +++ /dev/null @@ -1,29 +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. -*/ - -'use strict'; - -var linspace = require( './../../linspace' ); -var cartesianProduct = require( './../lib' ); - -var x1 = linspace( 0, 5, 6 ); -var x2 = linspace( 10, 15, 6 ); - -var out = cartesianProduct( x1, x2 ); -console.log( out ); -// => [ [ 0, 10 ], [ 0, 11 ], ..., [ 5, 14 ], [ 5, 15 ] ] diff --git a/cartesian-product/lib/index.js b/cartesian-product/lib/index.js deleted file mode 100644 index 12631d00a..000000000 --- a/cartesian-product/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Return the Cartesian product. -* -* @module @stdlib/array/cartesian-product -* -* @example -* var cartesianProduct = require( '@stdlib/array/cartesian-product' ); -* -* var x1 = [ 1, 2, 3 ]; -* var x2 = [ 4, 5 ]; -* -* var out = cartesianProduct( x1, x2 ); -* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -*/ - -// MAIN // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/cartesian-product/lib/main.js b/cartesian-product/lib/main.js deleted file mode 100644 index 4210ac629..000000000 --- a/cartesian-product/lib/main.js +++ /dev/null @@ -1,59 +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. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert/is-collection' ); -var base = require( './../../base/cartesian-product' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns the Cartesian product. -* -* @param {Collection} x1 - first input array -* @param {Collection} x2 - second input array -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} second argument must be a collection -* @returns {Array} list of ordered tuples comprising the Cartesian product -* -* @example -* var x1 = [ 1, 2, 3 ]; -* var x2 = [ 4, 5 ]; -* -* var out = cartesianProduct( x1, x2 ); -* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] -*/ -function cartesianProduct( x1, x2 ) { - if ( !isCollection( x1 ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x1 ) ); - } - if ( !isCollection( x2 ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', x2 ) ); - } - return base( x1, x2 ); -} - - -// EXPORTS // - -module.exports = cartesianProduct; diff --git a/cartesian-product/package.json b/cartesian-product/package.json deleted file mode 100644 index c6f30883e..000000000 --- a/cartesian-product/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/cartesian-product", - "version": "0.0.0", - "description": "Return the Cartesian product.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "cartesian", - "sets", - "math", - "mathematics", - "ordered" - ] -} diff --git a/cartesian-product/test/test.js b/cartesian-product/test/test.js deleted file mode 100644 index 1d5eb58fa..000000000 --- a/cartesian-product/test/test.js +++ /dev/null @@ -1,166 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var cartesianProduct = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cartesianProduct, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - cartesianProduct( value, [ 1, 2 ] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - cartesianProduct( [ 1, 2 ], value ); - }; - } -}); - -tape( 'the function returns the Cartesian product (indexed)', function test( t ) { - var expected; - var actual; - - actual = cartesianProduct( [ 1, 2 ], [ 3, 4 ] ); - expected = [ [ 1, 3 ], [ 1, 4 ], [ 2, 3 ], [ 2, 4 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( [ 1 ], [ 3, 4 ] ); - expected = [ [ 1, 3 ], [ 1, 4 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( [ 1, 2 ], [ 3 ] ); - expected = [ [ 1, 3 ], [ 2, 3 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( [ 1, 2 ], [ 3, 4, 5 ] ); - expected = [ [ 1, 3 ], [ 1, 4 ], [ 1, 5 ], [ 2, 3 ], [ 2, 4 ], [ 2, 5 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the Cartesian product (accessors)', function test( t ) { - var expected; - var actual; - - actual = cartesianProduct( toAccessorArray( [ 1, 2 ] ), toAccessorArray( [ 3, 4 ] ) ); - expected = [ [ 1, 3 ], [ 1, 4 ], [ 2, 3 ], [ 2, 4 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( toAccessorArray( [ 1 ] ), toAccessorArray( [ 3, 4 ] ) ); - expected = [ [ 1, 3 ], [ 1, 4 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( toAccessorArray( [ 1, 2 ] ), toAccessorArray( [ 3 ] ) ); - expected = [ [ 1, 3 ], [ 2, 3 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianProduct( toAccessorArray( [ 1, 2 ] ), toAccessorArray( [ 3, 4, 5 ] ) ); - expected = [ [ 1, 3 ], [ 1, 4 ], [ 1, 5 ], [ 2, 3 ], [ 2, 4 ], [ 2, 5 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided one or more empty arrays (indexed)', function test( t ) { - var actual; - - actual = cartesianProduct( [], [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianProduct( [ 1, 2 ], [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianProduct( [], [ 3, 4 ] ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided one or more empty arrays (accessors)', function test( t ) { - var actual; - - actual = cartesianProduct( toAccessorArray( [] ), toAccessorArray( [] ) ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianProduct( toAccessorArray( [ 1, 2 ] ), toAccessorArray( [] ) ); - t.deepEqual( actual, [], 'returns expected value' ); - - actual = cartesianProduct( toAccessorArray( [] ), toAccessorArray( [ 3, 4 ] ) ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); diff --git a/cartesian-square/README.md b/cartesian-square/README.md deleted file mode 100644 index 123d603ac..000000000 --- a/cartesian-square/README.md +++ /dev/null @@ -1,112 +0,0 @@ - - -# cartesianSquare - -> Return the [Cartesian square][cartesian-product]. - -
- -## Usage - -```javascript -var cartesianSquare = require( '@stdlib/array/cartesian-square' ); -``` - -#### cartesianSquare( x ) - -Returns the [Cartesian square][cartesian-product]. - -```javascript -var x = [ 1, 2 ]; - -var out = cartesianSquare( x ); -// returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -``` - -If provided an empty array, the function returns an empty array. - -```javascript -var out = cartesianSquare( [] ); -// returns [] -``` - -
- - - -
- -
- - - -
- -## Examples - - - -```javascript -var linspace = require( '@stdlib/array/linspace' ); -var cartesianSquare = require( '@stdlib/array/cartesian-square' ); - -var x = linspace( 0, 5, 6 ); - -var out = cartesianSquare( x ); -// returns [ [ 0, 0 ], [ 0, 1 ], ..., [ 5, 4 ], [ 5, 5 ] ] -``` - -
- - - - - - - - - - - - - - diff --git a/cartesian-square/benchmark/benchmark.js b/cartesian-square/benchmark/benchmark.js deleted file mode 100644 index dc956f7ae..000000000 --- a/cartesian-square/benchmark/benchmark.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var cartesianSquare = require( './../lib' ); - - -// MAIN // - -bench( pkg+':len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianSquare( x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/cartesian-square/benchmark/benchmark.length.js b/cartesian-square/benchmark/benchmark.length.js deleted file mode 100644 index b5272f144..000000000 --- a/cartesian-square/benchmark/benchmark.length.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isArrayArray = require( '@stdlib/assert/is-array-array' ); -var pkg = require( './../package.json' ).name; -var cartesianSquare = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = discreteUniform( len, 0, 3 ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = cartesianSquare( x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArrayArray( v ) ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 2^min - max = 10; // 2^max - - for ( i = min; i <= max; i++ ) { - len = pow( 2, i ); - f = createBenchmark( len ); - bench( pkg+':len='+(len*len), f ); - } -} - -main(); diff --git a/cartesian-square/docs/repl.txt b/cartesian-square/docs/repl.txt deleted file mode 100644 index 2b7744a1b..000000000 --- a/cartesian-square/docs/repl.txt +++ /dev/null @@ -1,24 +0,0 @@ - -{{alias}}( x ) - Returns the Cartesian square. - - If provided an empty array, the function returns an empty array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Array - Cartesian product. - - Examples - -------- - > var out = {{alias}}( [ 1, 2 ] ) - [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] - - See Also - -------- - diff --git a/cartesian-square/docs/types/index.d.ts b/cartesian-square/docs/types/index.d.ts deleted file mode 100644 index 3b650257c..000000000 --- a/cartesian-square/docs/types/index.d.ts +++ /dev/null @@ -1,46 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike } from '@stdlib/types/array'; - -/** -* Returns the Cartesian square. -* -* ## Notes -* -* - If provided an empty array, the function returns an empty array. -* -* @param x - input array -* @returns Cartesian product -* -* @example -* var x = [ 1, 2 ]; -* -* var out = cartesianSquare( x ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ -declare function cartesianSquare( x: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = cartesianSquare; diff --git a/cartesian-square/docs/types/test.ts b/cartesian-square/docs/types/test.ts deleted file mode 100644 index 1e55aa166..000000000 --- a/cartesian-square/docs/types/test.ts +++ /dev/null @@ -1,46 +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. -*/ - -import cartesianSquare = require( './index' ); - - -// TESTS // - -// The function returns an array of arrays... -{ - cartesianSquare( [ 1, 2, 3, 4 ] ); // $ExpectType number[][] - cartesianSquare( [ 1, 2, 3, 4 ] ); // $ExpectType number[][] - cartesianSquare( [ '1', '2', '3', '4' ] ); // $ExpectType string[][] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - cartesianSquare( 1 ); // $ExpectError - cartesianSquare( true ); // $ExpectError - cartesianSquare( false ); // $ExpectError - cartesianSquare( null ); // $ExpectError - cartesianSquare( void 0 ); // $ExpectError - cartesianSquare( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - cartesianSquare(); // $ExpectError - cartesianSquare( [], [] ); // $ExpectError - cartesianSquare( [], [], [] ); // $ExpectError -} diff --git a/cartesian-square/examples/index.js b/cartesian-square/examples/index.js deleted file mode 100644 index c2b3b9b1f..000000000 --- a/cartesian-square/examples/index.js +++ /dev/null @@ -1,28 +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. -*/ - -'use strict'; - -var linspace = require( './../../linspace' ); -var cartesianSquare = require( './../lib' ); - -var x = linspace( 0, 5, 6 ); - -var out = cartesianSquare( x ); -console.log( out ); -// => [ [ 0, 0 ], [ 0, 1 ], ..., [ 5, 4 ], [ 5, 5 ] ] diff --git a/cartesian-square/lib/index.js b/cartesian-square/lib/index.js deleted file mode 100644 index 9f1a23efc..000000000 --- a/cartesian-square/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Return the Cartesian square. -* -* @module @stdlib/array/cartesian-square -* -* @example -* var cartesianSquare = require( '@stdlib/array/cartesian-square' ); -* -* var x = [ 1, 2 ]; -* -* var out = cartesianSquare( x ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ - -// MAIN // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/cartesian-square/lib/main.js b/cartesian-square/lib/main.js deleted file mode 100644 index ac266f936..000000000 --- a/cartesian-square/lib/main.js +++ /dev/null @@ -1,53 +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. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert/is-collection' ); -var base = require( './../../base/cartesian-square' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns the Cartesian square. -* -* @param {Collection} x - input array -* @throws {TypeError} first argument must be a collection -* @returns {Array} list of ordered tuples comprising the Cartesian product -* -* @example -* var x = [ 1, 2 ]; -* -* var out = cartesianSquare( x ); -* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] -*/ -function cartesianSquare( x ) { - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) ); - } - return base( x ); -} - - -// EXPORTS // - -module.exports = cartesianSquare; diff --git a/cartesian-square/package.json b/cartesian-square/package.json deleted file mode 100644 index 609d62418..000000000 --- a/cartesian-square/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/cartesian-square", - "version": "0.0.0", - "description": "Return the Cartesian square.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "cartesian", - "sets", - "math", - "mathematics", - "ordered" - ] -} diff --git a/cartesian-square/test/test.js b/cartesian-square/test/test.js deleted file mode 100644 index 6cfac0b5b..000000000 --- a/cartesian-square/test/test.js +++ /dev/null @@ -1,137 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var cartesianSquare = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof cartesianSquare, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - cartesianSquare( value ); - }; - } -}); - -tape( 'the function returns the Cartesian square (indexed)', function test( t ) { - var expected; - var actual; - - actual = cartesianSquare( [ 1, 2 ] ); - expected = [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianSquare( [ 1 ] ); - expected = [ [ 1, 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianSquare( [ 1, 2, 3 ] ); - expected = [ - [ 1, 1 ], - [ 1, 2 ], - [ 1, 3 ], - [ 2, 1 ], - [ 2, 2 ], - [ 2, 3 ], - [ 3, 1 ], - [ 3, 2 ], - [ 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns the Cartesian square (accessors)', function test( t ) { - var expected; - var actual; - - actual = cartesianSquare( toAccessorArray( [ 1, 2 ] ) ); - expected = [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianSquare( toAccessorArray( [ 1 ] ) ); - expected = [ [ 1, 1 ] ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = cartesianSquare( toAccessorArray( [ 1, 2, 3 ] ) ); - expected = [ - [ 1, 1 ], - [ 1, 2 ], - [ 1, 3 ], - [ 2, 1 ], - [ 2, 2 ], - [ 2, 3 ], - [ 3, 1 ], - [ 3, 2 ], - [ 3, 3 ] - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty array (indexed)', function test( t ) { - var actual; - - actual = cartesianSquare( [] ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty array (accessors)', function test( t ) { - var actual; - - actual = cartesianSquare( toAccessorArray( [] ) ); - t.deepEqual( actual, [], 'returns expected value' ); - - t.end(); -}); diff --git a/complex128/README.md b/complex128/README.md deleted file mode 100644 index 32284116d..000000000 --- a/complex128/README.md +++ /dev/null @@ -1,2632 +0,0 @@ - - -# Complex128Array - -> 128-bit complex number array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Complex128Array = require( '@stdlib/array/complex128' ); -``` - - - -#### Complex128Array() - -Creates a 128-bit complex number array. - -```javascript -var arr = new Complex128Array(); -// returns -``` - -#### Complex128Array( length ) - -Creates a 128-bit complex number array having a specified `length`. - -```javascript -var arr = new Complex128Array( 10 ); -// returns - -var len = arr.length; -// returns 10 -``` - -#### Complex128Array( complexarray ) - -Creates a 128-bit complex number array from another complex number array. - -```javascript -var arr1 = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] -// returns - -var arr2 = new Complex128Array( arr1 ); -// returns - -var len = arr2.length; -// returns 2 -``` - -#### Complex128Array( typedarray ) - -Creates a 128-bit complex number array from a [typed array][@stdlib/array/typed] containing interleaved real and imaginary components. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var buf = new Float64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] -// returns [ 1.0, -1.0, 2.0, -2.0 ] - -var arr = new Complex128Array( buf ); -// returns - -var len = arr.length; -// returns 2 -``` - -#### Complex128Array( obj ) - -Creates a 128-bit complex number array from an array-like object or iterable. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -// From an array of interleaved real and imaginary components: -var arr1 = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); -// returns - -var len = arr1.length; -// returns 2 - -// From an array containing complex numbers: -var buf = [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) ]; -var arr2 = new Complex128Array( buf ); - -len = arr2.length; -// returns 2 -``` - -#### Complex128Array( buffer\[, byteOffset\[, length]] ) - -Returns a 128-bit complex number array view of an [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); -var buf = new ArrayBuffer( 480 ); - -var arr1 = new Complex128Array( buf ); -// returns - -var len = arr1.length; -// returns 30 - -var arr2 = new Complex128Array( buf, 16 ); -// returns - -len = arr2.length; -// returns 29 - -var arr3 = new Complex128Array( buf, 16, 20 ); -// returns - -len = arr3.length; -// returns 20 -``` - -* * * - -### Properties - - - -#### Complex128Array.BYTES_PER_ELEMENT - -Static property returning the size (in bytes) of each array element. - -```javascript -var nbytes = Complex128Array.BYTES_PER_ELEMENT; -// returns 16 -``` - - - -#### Complex128Array.name - -Static property returning the constructor name. - -```javascript -var str = Complex128Array.name; -// returns 'Complex128Array' -``` - - - -#### Complex128Array.prototype.buffer - -Pointer to the underlying data buffer. - -```javascript -var arr = new Complex128Array( 2 ); -// returns - -var buf = arr.buffer; -// returns -``` - - - -#### Complex128Array.prototype.byteLength - -Size (in bytes) of the array. - -```javascript -var arr = new Complex128Array( 10 ); -// returns - -var nbytes = arr.byteLength; -// returns 160 -``` - - - -#### Complex128Array.prototype.byteOffset - -Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var arr = new Complex128Array( 10 ); -// returns - -var offset = arr.byteOffset; -// returns 0 - -var buf = new ArrayBuffer( 480 ); -arr = new Complex128Array( buf, 128 ); -// returns - -offset = arr.byteOffset; -// returns 128 -``` - - - -#### Complex128Array.prototype.BYTES_PER_ELEMENT - -Size (in bytes) of each array element. - -```javascript -var arr = new Complex128Array( 10 ); -// returns - -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 16 -``` - - - -#### Complex128Array.prototype.length - -Number of array elements. - -```javascript -var arr = new Complex128Array( 10 ); -// returns - -var len = arr.length; -// returns 10 -``` - -* * * - -### Methods - - - -#### Complex128Array.from( src\[, clbk\[, thisArg]] ) - -Creates a new 128-bit complex number array from an array-like object or an iterable. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -// Create an array from interleaved real and imaginary components: -var arr = Complex128Array.from( [ 1.0, -1.0 ] ); -// returns - -var len = arr.length; -// returns 1 - -// Create an array from an array of complex numbers: -arr = Complex128Array.from( [ new Complex128( 1.0, -1.0 ) ] ); -// returns - -len = arr.length; -// returns 1 -``` - -The iterator returned by an iterable must return either a complex number or an array-like object containing a real and imaginary component. - -```javascript -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var Float64Array = require( '@stdlib/array/float64' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var iter; -var arr; -var len; -var re; -var im; -var z; - -// Define a function which returns an iterator protocol-compliant object... -function iterable() { - var buf = new Float64Array( 2 ); - var i = 0; - return { - 'next': next - }; - - function next() { - i += 1; - if ( i < 3 ) { - // Reuse allocated memory... - buf[ 0 ] = i; - buf[ 1 ] = -i; - return { - 'value': buf - }; - } - return { - 'done': true - }; - } -} - -if ( ITERATOR_SYMBOL === null ) { - console.error( 'Environment does not support iterables.' ); -} else { - // Create an iterable: - iter = {}; - iter[ ITERATOR_SYMBOL ] = iterable; - - // Generate a complex number array: - arr = Complex128Array.from( iter ); - // returns - - len = arr.length; - // returns 2 - - z = arr.get( 0 ); - // returns - - re = real( z ); - // returns 1.0 - - im = imag( z ); - // returns -1.0 -} -``` - -To invoke a function for each `src` value, provide a callback function. If `src` is an iterable or an array-like object containing complex numbers, the callback must return either a complex number - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function map( z ) { - return new Complex128( real(z)*2.0, imag(z)*2.0 ); -} - -// Create a source array: -var src = [ new Complex128( 1.0, -1.0 ) ]; - -// Create a new complex number array by scaling the source array: -var arr = Complex128Array.from( src, map ); -// returns - -var len = arr.length; -// returns 1 - -var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns -2.0 -``` - -or an array-like object containing real and imaginary components - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -// Return a callback which reuses allocated memory... -function mapFcn() { - var buf = new Float64Array( 2 ); - return map; - - function map( z ) { - buf[ 0 ] = real( z ) * 2.0; - buf[ 1 ] = imag( z ) * 2.0; - return buf; - } -} - -// Create a source array: -var src = [ new Complex128( 1.0, -1.0 ), new Complex128( 2.0, -2.0 ) ]; - -// Create a new complex number array by scaling the source array: -var arr = Complex128Array.from( src, mapFcn() ); -// returns - -var len = arr.length; -// returns 2 - -var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns -2.0 - -z = arr.get( 1 ); -// returns - -re = real( z ); -// returns 4.0 - -im = imag( z ); -// returns -4.0 -``` - -If `src` is an array-like object containing interleaved real and imaginary components, the callback is invoked for each component and should return the transformed component value. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function map( v ) { - return v * 2.0; -} - -// Create a source array: -var src = new Float64Array( [ 1.0, -1.0 ] ); - -// Create a new complex number array by scaling the source array: -var arr = Complex128Array.from( src, map ); -// returns - -var len = arr.length; -// returns 1 - -var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns -2.0 -``` - -A callback function is provided two arguments: - -- **value**: source value. -- **index**: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function map( z ) { - this.count += 1; - return new Complex128( real(z)*2.0, imag(z)*2.0 ); -} - -// Create a source array: -var src = [ new Complex128( 1.0, -1.0 ), new Complex128( 1.0, -1.0 ) ]; - -// Define an execution context: -var ctx = { - 'count': 0 -}; - -// Create a new complex number array by scaling the source array: -var arr = Complex128Array.from( src, map, ctx ); -// returns - -var len = arr.length; -// returns 2 - -var n = ctx.count; -// returns 2 -``` - - - -#### Complex128Array.of( element0\[, element1\[, ...elementN]] ) - -Creates a new 128-bit complex number array from a variable number of arguments. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -var arr = Complex128Array.of( 1.0, -1.0, 2.0, -2.0 ); -// returns - -var len = arr.length; -// returns 2 - -var z1 = new Complex128( 1.0, -1.0 ); -var z2 = new Complex128( 2.0, -2.0 ); - -arr = Complex128Array.of( z1, z2 ); -// returns - -len = arr.length; -// returns 2 -``` - - - -#### Complex128Array.prototype.at( i ) - -Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer positions. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 10 ); - -// Set the first, second, and last elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 9.0, -9.0 ], 9 ); - -// Get the first element: -var z = arr.at( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns -1.0 - -// Get the last element: -z = arr.at( -1 ); -// returns - -re = real( z ); -// returns 9.0 - -im = imag( z ); -// returns -9.0 -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var arr = new Complex128Array( 10 ); - -var z = arr.at( 100 ); -// returns undefined - -z = arr.at( -100 ); -// returns undefined -``` - - - -#### Complex128Array.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within the array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 4 ); - -// Set the array elements: -arr.set( new Complex128( 1.0, -1.0 ), 0 ); -arr.set( new Complex128( 2.0, -2.0 ), 1 ); -arr.set( new Complex128( 3.0, -3.0 ), 2 ); -arr.set( new Complex128( 4.0, -4.0 ), 3 ); - -// Get the first array element: -var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns -1.0 - -// Get the second array element: -z = arr.get( 1 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns -2.0 - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 2 ); - -// Get the first array element: -z = arr.get( 0 ); -// returns - -re = real( z ); -// returns 3.0 - -im = imag( z ); -// returns -3.0 - -// Get the second array element: -z = arr.get( 1 ); -// returns - -re = real( z ); -// returns 4.0 - -im = imag( z ); -// returns -4.0 -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 4 ); - -// Set the array elements: -arr.set( new Complex128( 1.0, -1.0 ), 0 ); -arr.set( new Complex128( 2.0, -2.0 ), 1 ); -arr.set( new Complex128( 3.0, -3.0 ), 2 ); -arr.set( new Complex128( 4.0, -4.0 ), 3 ); - -// Get the third array element: -var z = arr.get( 2 ); -// returns - -var re = real( z ); -// returns 3.0 - -var im = imag( z ); -// returns -3.0 - -// Get the last array element: -z = arr.get( 3 ); -// returns - -re = real( z ); -// returns 4.0 - -im = imag( z ); -// returns -4.0 - -// Copy the first two elements to the last two elements: -arr.copyWithin( 2, 0, 2 ); - -// Get the third array element: -z = arr.get( 2 ); -// returns - -re = real( z ); -// returns 1.0 - -im = imag( z ); -// returns -1.0 - -// Get the last array element: -z = arr.get( 3 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns -2.0 -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 4 ); - -// Set the array elements: -arr.set( new Complex128( 1.0, -1.0 ), 0 ); -arr.set( new Complex128( 2.0, -2.0 ), 1 ); -arr.set( new Complex128( 3.0, -3.0 ), 2 ); -arr.set( new Complex128( 4.0, -4.0 ), 3 ); - -// Get the third array element: -var z = arr.get( 2 ); -// returns - -var re = real( z ); -// returns 3.0 - -var im = imag( z ); -// returns -3.0 - -// Get the last array element: -z = arr.get( 3 ); -// returns - -re = real( z ); -// returns 4.0 - -im = imag( z ); -// returns -4.0 - -// Copy the first two elements to the last two elements using negative indices: -arr.copyWithin( -2, -4, -2 ); - -// Get the third array element: -z = arr.get( 2 ); -// returns - -re = real( z ); -// returns 1.0 - -im = imag( z ); -// returns -1.0 - -// Get the last array element: -z = arr.get( 3 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns -2.0 -``` - - - -#### Complex128Array.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = [ - new Complex128( 1.0, -1.0 ), - new Complex128( 2.0, -2.0 ), - new Complex128( 3.0, -3.0 ) -]; -arr = new Complex128Array( arr ); - -// Create an iterator: -var it = arr.entries(); - -// Iterate over the key-value pairs... -var v = it.next().value; -// returns [ 0, ] - -var re = real( v[ 1 ] ); -// returns 1.0 - -var im = imag( v[ 1 ] ); -// returns -1.0 - -v = it.next().value; -// returns [ 1, ] - -re = real( v[ 1 ] ); -// returns 2.0 - -im = imag( v[ 1 ] ); -// returns -2.0 - -v = it.next().value; -// returns [ 2, ] - -re = real( v[ 1 ] ); -// returns 3.0 - -im = imag( v[ 1 ] ); -// returns -3.0 - -var bool = it.next().done; -// returns true -``` - - - -#### Complex128Array.prototype.every( predicate\[, thisArg] ) - -Returns a boolean indicating whether all elements pass a test. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v ) { - return ( real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -// Check whether all elements pass a test: -var bool = arr.every( predicate ); -// returns true -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 ); -} - -var arr = new Complex128Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var bool = arr.every( predicate, context ); -// returns true - -var count = context.count; -// returns 3 -``` - - - -#### Complex128Array.prototype.fill( value\[, start\[, end]] ) - -Returns a modified typed array filled with a fill value. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 3 ); - -// Set all elements to the same value: -arr.fill( new Complex128( 1.0, 1.0 ) ); - -var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns 1.0 - -z = arr.get( 2 ); -// returns - -re = real( z ); -// returns 1.0 - -im = imag( z ); -// returns 1.0 - -// Fill all elements starting from the second element: -arr.fill( new Complex128( 2.0, 2.0 ), 1 ); - -z = arr.get( 1 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns 2.0 - -z = arr.get( 2 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns 2.0 - -// Fill all elements from first element until the second-to-last element: -arr.fill( new Complex128( 3.0, 3.0 ), 0, 2 ); - -z = arr.get( 0 ); -// returns - -re = real( z ); -// returns 3.0 - -im = imag( z ); -// returns 3.0 - -z = arr.get( 1 ); -// returns - -re = real( z ); -// returns 3.0 - -im = imag( z ); -// returns 3.0 -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 3 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( new Complex128( 1.0, 1.0 ), 0, -1 ); - -var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns 1.0 - -z = arr.get( arr.length - 1 ); -// returns - -re = real( z ); -// returns 0.0 - -im = imag( z ); -// returns 0.0 -``` - - - -#### Complex128Array.prototype.filter( predicate\[, thisArg] ) - -Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v ) { - return ( real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var out = arr.filter( predicate ); -// returns - -var len = out.length; -// returns 1 - -var z = out.get( 0 ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns 2.0 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 && real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var out = arr.filter( predicate, context ); -// returns - -var len = out.length; -// returns 2 - -var count = context.count; -// returns 3 -``` - - - -#### Complex128Array.prototype.find( predicate\[, thisArg] ) - -Returns the first element in an array for which a predicate function returns a truthy value. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v ) { - return ( real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.find( predicate ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns 1.0 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 && real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.find( predicate, context ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns 2.0 - -var count = context.count; -// returns 2 -``` - - - -#### Complex128Array.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first element in an array for which a predicate function returns a truthy value. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v ) { - return ( real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var idx = arr.findIndex( predicate ); -// returns 2 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 && real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var idx = arr.findIndex( predicate, context ); -// returns -1 - -var count = context.count; -// returns 3 -``` - - - -#### Complex128Array.prototype.findLast( predicate\[, thisArg] ) - -Returns the last element in an array for which a predicate function returns a truthy value. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v ) { - return ( real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.findLast( predicate ); -// returns - -var re = real( z ); -// returns 3.0 - -var im = imag( z ); -// returns 3.0 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 && real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var z = arr.findLast( predicate, context ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns 2.0 - -var count = context.count; -// returns 2 -``` - - - -#### Complex128Array.prototype.findLastIndex( predicate\[, thisArg] ) - -Returns the index of the last element in an array for which a predicate function returns a truthy value. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v ) { - return ( real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var idx = arr.findLastIndex( predicate ); -// returns 1 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 && real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var idx = arr.findLastIndex( predicate, context ); -// returns -1 - -var count = context.count; -// returns 3 -``` - - - -#### Complex128Array.prototype.forEach( callbackFn\[, thisArg] ) - -Invokes a function once for each array element. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -function log( v, i ) { - console.log( '%s: %s', i, v.toString() ); -} - -var arr = new Complex128Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -arr.forEach( log ); -/* => - 0: 1 + 1i - 1: 2 + 2i - 2: 3 + 3i -*/ -``` - -The invoked function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -function fcn( v, i ) { - this.count += 1; - console.log( '%s: %s', i, v.toString() ); -} - -var arr = new Complex128Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -arr.forEach( fcn, context ); -/* => - 0: 1 + 1i - 1: 2 + 2i - 2: 3 + 3i -*/ - -var count = context.count; -// returns 3 -``` - - - -#### Complex128Array.prototype.get( i ) - -Returns an array element located at position (index) `i`. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 10 ); - -// Set the first element: -arr.set( [ 1.0, -1.0 ], 0 ); - -// Get the first element: -var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns -1.0 -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var arr = new Complex128Array( 10 ); - -var z = arr.get( 100 ); -// returns undefined -``` - - - -#### Complex128Array.prototype.includes( searchElement\[, fromIndex] ) - -Returns a boolean indicating whether an array includes a provided value. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -var arr = new Complex128Array( 5 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); -arr.set( [ 4.0, -4.0 ], 3 ); -arr.set( [ 5.0, -5.0 ], 4 ); - -var bool = arr.includes( new Complex128( 3.0, -3.0 ) ); -// returns true - -bool = arr.includes( new Complex128( 3.0, -3.0 ), 3 ); -// returns false - -bool = arr.includes( new Complex128( 4.0, -4.0 ), -3 ); -// returns true -``` - - - -#### Complex128Array.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the first index at which a given element can be found. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -var arr = new Complex128Array( 5 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); -arr.set( [ 4.0, -4.0 ], 3 ); -arr.set( [ 2.0, -2.0 ], 4 ); - -var idx = arr.indexOf( new Complex128( 3.0, -3.0 ) ); -// returns 2 - -idx = arr.indexOf( new Complex128( 2.0, -2.0 ), 2 ); -// returns 4 - -idx = arr.indexOf( new Complex128( 4.0, -4.0 ), -3 ); -// returns 3 -``` - -If `searchElement` is not present in the array, the method returns `-1`. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -var arr = new Complex128Array( 5 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); - -var idx = arr.indexOf( new Complex128( 3.0, -3.0 ) ); -// returns -1 - -idx = arr.indexOf( new Complex128( 1.0, -1.0 ), 1 ); -// returns -1 -``` - - - -#### Complex128Array.prototype.join( \[separator] ) - -Returns a new string by concatenating all array elements. - -```javascript -var arr = new Complex128Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var str = arr.join(); -// returns '1 + 1i,2 - 2i,3 + 3i' -``` - -By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string. - -```javascript -var arr = new Complex128Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var str = arr.join( '/' ); -// returns '1 + 1i/2 - 2i/3 + 3i' -``` - - - -#### Complex128Array.prototype.keys() - -Returns an iterator for iterating over each index key in a typed array. - -```javascript -var arr = new Complex128Array( 2 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); - -var iter = arr.keys(); - -var v = iter.next().value; -// returns 0 - -v = iter.next().value; -// returns 1 - -var bool = iter.next().done; -// returns true -``` - -The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: - -- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. -- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. - - - -#### Complex128Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the last index at which a given element can be found. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -var arr = new Complex128Array( 5 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); -arr.set( [ 4.0, -4.0 ], 3 ); -arr.set( [ 2.0, -2.0 ], 4 ); - -var idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ) ); -// returns 2 - -idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), 2 ); -// returns 1 - -idx = arr.lastIndexOf( new Complex128( 4.0, -4.0 ), -1 ); -// returns 3 -``` - -If `searchElement` is not present in the array, the method returns `-1`. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -var arr = new Complex128Array( 5 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); - -var idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ) ); -// returns -1 - -idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), 0 ); -// returns -1 -``` - - - -#### Complex128Array.prototype.map( callbackFn\[, thisArg] ) - -Returns a new array with each element being the result of a provided callback function. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function scale( v ) { - return new Complex128( 2.0*real( v ), 2.0*imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var out = arr.map( scale ); -// returns - -var z = out.get( 0 ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns -2.0 -``` - -The callback function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function scale( v ) { - this.count += 1; - return new Complex128( 2.0*real( v ), 2.0*imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var out = arr.map( scale, context ); -// returns - -var count = context.count; -// returns 3 -``` - - - -#### Complex128Array.prototype.reduce( reducerFn\[, initialValue] ) - -Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var cadd = require( '@stdlib/complex/float64/base/add' ); - -var arr = new Complex128Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.reduce( cadd ); -// returns - -var re = real( z ); -// returns 6.0 - -var im = imag( z ); -// returns 6.0 -``` - -The reducer function is provided four arguments: - -- **acc**: accumulated result. -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); - -function reducer( acc, v ) { - acc += real( v ); - return acc; -} - -var arr = new Complex128Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.reduce( reducer, 0.0 ); -// returns 6.0 -``` - - - -#### Complex128Array.prototype.reduceRight( reducerFn\[, initialValue] ) - -Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var cadd = require( '@stdlib/complex/float64/base/add' ); - -var arr = new Complex128Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.reduceRight( cadd ); -// returns - -var re = real( z ); -// returns 6.0 - -var im = imag( z ); -// returns 6.0 -``` - -The reducer function is provided four arguments: - -- **acc**: accumulated result. -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -By default, the function initializes the accumulated result to the last element in the array and passes the second-last array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the last array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); - -function reducer( acc, v ) { - acc += real( v ); - return acc; -} - -var arr = new Complex128Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.reduceRight( reducer, 0.0 ); -// returns 6.0 -``` - - - -#### Complex128Array.prototype.reverse() - -Reverses an array in-place. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var out = arr.reverse(); -// returns - -var z = out.get( 0 ); -// returns - -var re = real( z ); -// returns 3.0 - -var im = imag( z ); -// returns 3.0 - -z = out.get( 1 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns 2.0 - -z = out.get( 2 ); -// returns - -re = real( z ); -// returns 1.0 - -im = imag( z ); -// returns 1.0 -``` - - - -#### Complex128Array.prototype.set( z\[, i] ) - -Sets one or more array elements. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 10 ); - -// Get the first element: -var z = arr.get( 0 ); -// returns - -var re = real( z ); -// returns 0.0 - -var im = imag( z ); -// returns 0.0 - -// Set the first element: -arr.set( new Complex128( 1.0, -1.0 ) ); - -// Get the first element: -z = arr.get( 0 ); -// returns - -re = real( z ); -// returns 1.0 - -im = imag( z ); -// returns -1.0 -``` - -By default, the method sets array elements starting at position (index) `i = 0`. To set elements starting elsewhere in the array, provide an index argument `i`. - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 10 ); - -// Get the fifth element: -var z = arr.get( 4 ); -// returns - -var re = real( z ); -// returns 0.0 - -var im = imag( z ); -// returns 0.0 - -// Set the fifth element: -arr.set( new Complex128( 1.0, -1.0 ), 4 ); - -// Get the fifth element: -z = arr.get( 4 ); -// returns - -re = real( z ); -// returns 1.0 - -im = imag( z ); -// returns -1.0 -``` - -In addition to providing a complex number, to set one or more array elements, provide an array-like object containing either complex numbers - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 10 ); - -// Define an array of complex numbers: -var buf = [ - new Complex128( 1.0, -1.0 ), - new Complex128( 2.0, -2.0 ), - new Complex128( 3.0, -3.0 ) -]; - -// Set the fifth, sixth, and seventh elements: -arr.set( buf, 4 ); - -// Get the sixth element: -var z = arr.get( 5 ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns -2.0 -``` - -or interleaved real and imaginary components - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 10 ); - -// Define an interleaved array of real and imaginary components: -var buf = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - -// Set the fifth, sixth, and seventh elements: -arr.set( buf, 4 ); - -// Get the sixth element: -var z = arr.get( 5 ); -// returns - -var re = real( z ); -// returns 2.0 - -var im = imag( z ); -// returns -2.0 -``` - -A few notes: - -- If `i` is out-of-bounds, the method throws an error. -- If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error. -- If provided a [typed array][@stdlib/array/typed] which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range. - - - -#### Complex128Array.prototype.slice( \[start\[, end]] ) - -Copies a portion of a typed array to a new typed array. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var out = arr.slice(); -// returns - -var len = out.length; -// returns 4 - -var z = out.get( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns 2.0 - -z = out.get( len-1 ); -// returns - -re = real( z ); -// returns 7.0 - -im = imag( z ); -// returns 8.0 -``` - -By default, the method returns a typed array beginning with the first array element. To specify an alternative array index at which to begin, provide a `start` index (inclusive). - -```javascript -var imag = require( '@stdlib/complex/float64/imag' ); -var real = require( '@stdlib/complex/float64/real' ); - -var arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var out = arr.slice( 1 ); -// returns - -var len = out.length; -// returns 3 - -var z = out.get( 0 ); -// returns - -var re = real( z ); -// returns 3.0 - -var im = imag( z ); -// returns 4.0 -``` - -By default, the method returns a typed array which includes all array elements after `start`. To limit the number of array elements after `start`, provide an `end` index (exclusive). - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var out = arr.slice( 1, -1 ); -// returns - -var len = out.length; -// returns 2 - -var z = out.get( 0 ); -// returns - -var re = real( z ); -// returns 3.0 - -var im = imag( z ); -// returns 4.0 - -z = out.get( len-1 ); -// returns - -re = real( z ); -// returns 5.0 - -im = imag( z ); -// returns 6.0 -``` - - - -#### Complex128Array.prototype.some( predicate\[, thisArg] ) - -Returns a boolean indicating whether at least one element passes a test. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v ) { - return ( real( v ) === imag( v ) ); -} - -var arr = new Complex128Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -// Check whether at least one element passes a test: -var bool = arr.some( predicate ); -// returns true -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( imag( v ) === real( v ) ); -} - -var arr = new Complex128Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var bool = arr.some( predicate, context ); -// returns true - -var count = context.count; -// returns 2 -``` - - - -#### Complex128Array.prototype.sort( compareFcn ) - -Sorts an array in-place. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function compare( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = real( a ); - re2 = real( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imag( a ); - im2 = imag( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - -var arr = new Complex128Array( 3 ); - -arr.set( [ 3.0, -3.0 ], 0 ); -arr.set( [ 1.0, -1.0 ], 1 ); -arr.set( [ 2.0, -2.0 ], 2 ); - -var out = arr.sort( compare ); -// returns - -var z = out.get( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns -1.0 - -z = out.get( 1 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns -2.0 - -z = out.get( 2 ); -// returns - -re = real( z ); -// returns 3.0 - -im = imag( z ); -// returns -3.0 -``` - -The `compareFcn` determines the order of the elements. The function is called with the following arguments: - -- **a**: the first element for comparison. -- **b**: the second element for comparison. - -The function should return a number where: - -- a negative value indicates that `a` should come before `b`. -- a positive value indicates that `a` should come after `b`. -- zero or `NaN` indicates that `a` and `b` are considered equal. - -In contrast to real numbers, one cannot define a default order relation which is compatible with multiplication. Accordingly, users **must** explicitly provide a `compareFcn` argument and are thus responsible for specifying a complex number ordering. - - - -#### Complex128Array.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var subarr = arr.subarray(); -// returns - -var len = subarr.length; -// returns 4 - -var z = subarr.get( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns 2.0 - -z = subarr.get( len-1 ); -// returns - -re = real( z ); -// returns 7.0 - -im = imag( z ); -// returns 8.0 -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - -```javascript -var imag = require( '@stdlib/complex/float64/imag' ); -var real = require( '@stdlib/complex/float64/real' ); - -var arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var subarr = arr.subarray( 1 ); -// returns - -var len = subarr.length; -// returns 3 - -var z = subarr.get( 0 ); -// returns - -var re = real( z ); -// returns 3.0 - -var im = imag( z ); -// returns 4.0 -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var subarr = arr.subarray( 1, -1 ); -// returns - -var len = subarr.length; -// returns 2 - -var z = subarr.get( 0 ); -// returns - -var re = real( z ); -// returns 3.0 - -var im = imag( z ); -// returns 4.0 - -z = subarr.get( len-1 ); -// returns - -re = real( z ); -// returns 5.0 - -im = imag( z ); -// returns 6.0 -``` - - - -#### Complex128Array.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific string. - -```javascript -var arr = new Complex128Array( 2 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); - -var str = arr.toLocaleString(); -// returns '1 + 1i,2 + 2i' -``` - -The method supports the following arguments: - -- **locales**: a string with a BCP 47 language tag or an array of such strings. -- **options**: configuration properties. - - - -#### Complex128Array.prototype.toReversed() - -Returns a new typed array containing the elements in reversed order. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var arr = new Complex128Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var out = arr.toReversed(); -// returns - -var z = out.get( 0 ); -// returns - -var re = real( z ); -// returns 3.0 - -var im = imag( z ); -// returns 3.0 - -z = out.get( 1 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns 2.0 - -z = out.get( 2 ); -// returns - -re = real( z ); -// returns 1.0 - -im = imag( z ); -// returns 1.0 -``` - - - -#### Complex128Array.prototype.toSorted( compareFcn ) - -Returns a new typed array containing the elements in sorted order. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -function compare( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = real( a ); - re2 = real( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imag( a ); - im2 = imag( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - -var arr = new Complex128Array( 3 ); - -arr.set( [ 3.0, -3.0 ], 0 ); -arr.set( [ 1.0, -1.0 ], 1 ); -arr.set( [ 2.0, -2.0 ], 2 ); - -var out = arr.toSorted( compare ); -// returns - -var z = out.get( 0 ); -// returns - -var re = real( z ); -// returns 1.0 - -var im = imag( z ); -// returns -1.0 - -z = out.get( 1 ); -// returns - -re = real( z ); -// returns 2.0 - -im = imag( z ); -// returns -2.0 - -z = out.get( 2 ); -// returns - -re = real( z ); -// returns 3.0 - -im = imag( z ); -// returns -3.0 -``` - -The `compareFcn` determines the order of the elements. The function is called with the following arguments: - -- **a**: the first element for comparison. -- **b**: the second element for comparison. - -The function should return a number where: - -- a negative value indicates that `a` should come before `b`. -- a positive value indicates that `a` should come after `b`. -- zero or `NaN` indicates that `a` and `b` are considered equal. - -In contrast to real numbers, one cannot define a default order relation which is compatible with multiplication. Accordingly, users **must** explicitly provide a `compareFcn` argument and are thus responsible for specifying a complex number ordering. - - - -#### Complex128Array.prototype.toString() - -Serializes an array as a string. - -```javascript -var arr = new Complex128Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var str = arr.toString(); -// returns '1 + 1i,2 - 2i,3 + 3i' -``` - - - -#### Complex128Array.prototype.values() - -Returns an iterator for iterating over each value in a typed array. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var arr = new Complex128Array( 2 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); - -var iter = arr.values(); - -var v = iter.next().value; -// returns - -var re = real( v ); -// returns 1.0 - -var im = imag( v ); -// returns -1.0 - -v = iter.next().value; -// returns - -re = real( v ); -// returns 2.0 - -im = imag( v ); -// returns -2.0 - -var bool = iter.next().done; -// returns true -``` - -The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: - -- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. -- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. - - - -#### Complex128Array.prototype.with( index, value ) - -Returns a new typed array with the element at a provided index replaced with a provided value. - -```javascript -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); - -var arr = new Complex128Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 1 ); - -var out = arr.with( 0, new Complex128( 4.0, 4.0 ) ); -// returns - -var z = out.get( 0 ); -// returns - -var re = real( z ); -// returns 4.0 - -var im = imag( z ); -// returns 4.0 -``` - -
- - - - - -
- -* * * - -## Notes - -- While a `Complex128Array` _strives_ to maintain (but does not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: - - - The constructor does **not** require the `new` operator. - - The constructor and associated methods support a broader variety of input argument types in order to better accommodate complex number input. - - Accessing array elements using bracket syntax (e.g., `Z[i]`) is **not** supported. Instead, one **must** use the `.get()` method which returns a value compatible with complex number output. - - The `set` method has extended behavior in order to support complex numbers. - -
- - - - - -
- -* * * - -## Examples - - - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Float64Array = require( '@stdlib/array/float64' ); -var logEach = require( '@stdlib/console/log-each' ); -var Complex128Array = require( '@stdlib/array/complex128' ); - -// Create a complex array by specifying a length: -var out = new Complex128Array( 3 ); -logEach( '%s', out ); - -// Create a complex array from an array of complex numbers: -var arr = [ - new Complex128( 1.0, -1.0 ), - new Complex128( -3.14, 3.14 ), - new Complex128( 0.5, 0.5 ) -]; -out = new Complex128Array( arr ); -logEach( '%s', out ); - -// Create a complex array from an interleaved typed array: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex128Array( arr ); -logEach( '%s', out ); - -// Create a complex array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex128Array( arr.buffer ); -logEach( '%s', out ); - -// Create a complex array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex128Array( arr.buffer, 16, 2 ); -logEach( '%s', out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/complex128/benchmark/benchmark.at.js b/complex128/benchmark/benchmark.at.js deleted file mode 100644 index dbdf2178b..000000000 --- a/complex128/benchmark/benchmark.at.js +++ /dev/null @@ -1,86 +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 bench = require( '@stdlib/bench' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::nonnegative_indices:at', function benchmark( b ) { - var arr; - var N; - var z; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.at( i%N ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::negative_indices:at', function benchmark( b ) { - var arr; - var N; - var z; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.at( -(i%N)-1 ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.every.js b/complex128/benchmark/benchmark.every.js deleted file mode 100644 index fadd9cae3..000000000 --- a/complex128/benchmark/benchmark.every.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex128( v ); - } -}); diff --git a/complex128/benchmark/benchmark.every.length.js b/complex128/benchmark/benchmark.every.length.js deleted file mode 100644 index 05779453c..000000000 --- a/complex128/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,118 +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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex128} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex128Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( real( value ) === imag( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.fill.js b/complex128/benchmark/benchmark.fill.js deleted file mode 100644 index 4fe6492bf..000000000 --- a/complex128/benchmark/benchmark.fill.js +++ /dev/null @@ -1,58 +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 bench = require( '@stdlib/bench' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ - new Complex128( 1.0, 1.0 ), - new Complex128( 2.0, 2.0 ), - new Complex128( 3.0, 3.0 ) - ]; - arr = new Complex128Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.fill.length.js b/complex128/benchmark/benchmark.fill.length.js deleted file mode 100644 index 5ee76c29a..000000000 --- a/complex128/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,102 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Complex128Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Complex128( 1.0, 1.0 ), - new Complex128( 2.0, 2.0 ), - new Complex128( 3.0, 3.0 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.filter.js b/complex128/benchmark/benchmark.filter.js deleted file mode 100644 index 065b84501..000000000 --- a/complex128/benchmark/benchmark.filter.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex128( v ); - } -}); diff --git a/complex128/benchmark/benchmark.filter.length.js b/complex128/benchmark/benchmark.filter.length.js deleted file mode 100644 index 9264ac3b0..000000000 --- a/complex128/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,118 +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 bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex128} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex128Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( real( value ) === imag( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.find.js b/complex128/benchmark/benchmark.find.js deleted file mode 100644 index a34db7725..000000000 --- a/complex128/benchmark/benchmark.find.js +++ /dev/null @@ -1,55 +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 bench = require( '@stdlib/bench' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var arr; - var z; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.find( predicate ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex128( v ); - } -}); diff --git a/complex128/benchmark/benchmark.find.length.js b/complex128/benchmark/benchmark.find.length.js deleted file mode 100644 index 36b1a5f78..000000000 --- a/complex128/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex128} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex128Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( real( value ) === -imag( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr.push( new Complex128( len-1, -( len-1 ) ) ); - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var z; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.find( predicate ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.find_index.js b/complex128/benchmark/benchmark.find_index.js deleted file mode 100644 index 70ea8f565..000000000 --- a/complex128/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var arr; - var idx; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex128( v ); - } -}); diff --git a/complex128/benchmark/benchmark.find_index.length.js b/complex128/benchmark/benchmark.find_index.length.js deleted file mode 100644 index c6e40a338..000000000 --- a/complex128/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex128} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex128Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( real( value ) === -imag( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr.push( new Complex128( len-1, -( len-1 ) ) ); - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.find_last.js b/complex128/benchmark/benchmark.find_last.js deleted file mode 100644 index 12cb71e45..000000000 --- a/complex128/benchmark/benchmark.find_last.js +++ /dev/null @@ -1,55 +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 bench = require( '@stdlib/bench' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findLast', function benchmark( b ) { - var arr; - var z; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.findLast( predicate ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex128( v ); - } -}); diff --git a/complex128/benchmark/benchmark.find_last.length.js b/complex128/benchmark/benchmark.find_last.length.js deleted file mode 100644 index 3e2ab969d..000000000 --- a/complex128/benchmark/benchmark.find_last.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex128} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex128Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( real( value ) === -imag( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - arr.push( new Complex128( 1, -1 ) ); - for ( i = 1; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var z; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.findLast( predicate ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findLast:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.find_last_index.js b/complex128/benchmark/benchmark.find_last_index.js deleted file mode 100644 index a8829cee9..000000000 --- a/complex128/benchmark/benchmark.find_last_index.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findLastIndex', function benchmark( b ) { - var arr; - var idx; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findLastIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex128( v ); - } -}); diff --git a/complex128/benchmark/benchmark.find_last_index.length.js b/complex128/benchmark/benchmark.find_last_index.length.js deleted file mode 100644 index fd82653c6..000000000 --- a/complex128/benchmark/benchmark.find_last_index.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex128} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex128Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( real( value ) === -imag( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - arr.push( new Complex128( 1, -1 ) ); - for ( i = 1; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findLastIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findLastIndex:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.for_each.js b/complex128/benchmark/benchmark.for_each.js deleted file mode 100644 index c1e073f08..000000000 --- a/complex128/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( check ); - if ( arr.length !== 2 ) { - b.fail( 'should not change an array length' ); - } - } - b.toc(); - if ( arr.length !== 2 ) { - b.fail( 'should not change an array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function check( v ) { - if ( !isComplex128( v ) ) { - b.fail( 'should be a complex number' ); - } - } -}); diff --git a/complex128/benchmark/benchmark.for_each.length.js b/complex128/benchmark/benchmark.for_each.length.js deleted file mode 100644 index b5a635040..000000000 --- a/complex128/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,109 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( callback ); - if ( arr.length !== len ) { - b.fail( 'should not change an array length' ); - } - } - b.toc(); - if ( arr.length !== len ) { - b.fail( 'should not change an array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function callback( value ) { - if ( real( value ) !== imag( value ) ) { - throw new Error( 'something went wrong' ); - } - } - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.includes.js b/complex128/benchmark/benchmark.includes.js deleted file mode 100644 index 0c80ec1d7..000000000 --- a/complex128/benchmark/benchmark.includes.js +++ /dev/null @@ -1,59 +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 bench = require( '@stdlib/bench' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - v = new Complex128( 10.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.includes( v, 0 ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.includes.length.js b/complex128/benchmark/benchmark.includes.length.js deleted file mode 100644 index fe8e43a19..000000000 --- a/complex128/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,107 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( new Complex128( i, -i ) ); - } - arr.push( new Complex128( i, i ) ); - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - v = new Complex128( len-1, len-1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.index_of.js b/complex128/benchmark/benchmark.index_of.js deleted file mode 100644 index 62188c7b1..000000000 --- a/complex128/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,59 +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 bench = require( '@stdlib/bench' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var arr; - var idx; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - v = new Complex128( 10.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.indexOf( v, 0 ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.index_of.length.js b/complex128/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 4101e78f5..000000000 --- a/complex128/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,107 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( new Complex128( i, -i ) ); - } - arr.push( new Complex128( i, i ) ); - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var v; - var i; - - v = new Complex128( len-1, len-1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.indexOf( v ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.join.js b/complex128/benchmark/benchmark.join.js deleted file mode 100644 index ee6a2bd1b..000000000 --- a/complex128/benchmark/benchmark.join.js +++ /dev/null @@ -1,50 +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 bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.join.length.js b/complex128/benchmark/benchmark.join.length.js deleted file mode 100644 index 139e00562..000000000 --- a/complex128/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,102 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.join( '/' ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.keys.js b/complex128/benchmark/benchmark.keys.js deleted file mode 100644 index 92a61423d..000000000 --- a/complex128/benchmark/benchmark.keys.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys:len=2', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.keys.length.js b/complex128/benchmark/benchmark.keys.length.js deleted file mode 100644 index 9cffd0956..000000000 --- a/complex128/benchmark/benchmark.keys.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':keys:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.last_index_of.js b/complex128/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 069b17dea..000000000 --- a/complex128/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,59 +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 bench = require( '@stdlib/bench' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var arr; - var idx; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - v = new Complex128( 10.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.lastIndexOf( v, 9 ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.last_index_of.length.js b/complex128/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 56f650dd5..000000000 --- a/complex128/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,106 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, -i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var v; - var i; - - v = new Complex128( 0, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.lastIndexOf( v ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.map.js b/complex128/benchmark/benchmark.map.js deleted file mode 100644 index 68ca7091c..000000000 --- a/complex128/benchmark/benchmark.map.js +++ /dev/null @@ -1,58 +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 bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( scale ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function scale( v ) { - return new Complex128( realf(v)*2.0, imagf(v)*2.0 ); - } -}); diff --git a/complex128/benchmark/benchmark.map.length.js b/complex128/benchmark/benchmark.map.length.js deleted file mode 100644 index ca1e844b2..000000000 --- a/complex128/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,104 +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 bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var identity = require( '@stdlib/utils/identity-function' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( identity ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.reduce.js b/complex128/benchmark/benchmark.reduce.js deleted file mode 100644 index 9e727dd4c..000000000 --- a/complex128/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,52 +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 bench = require( '@stdlib/bench' ); -var cadd = require( '@stdlib/complex/float64/base/add' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( cadd ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplexLike( out ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.reduce.length.js b/complex128/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 8c552664b..000000000 --- a/complex128/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,104 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var cadd = require( '@stdlib/complex/float64/base/add' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( cadd ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplexLike( out ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.reduce_right.js b/complex128/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ad6bca179..000000000 --- a/complex128/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var cadd = require( '@stdlib/complex/float64/base/add' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( cadd ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplexLike( out ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.reduce_right.length.js b/complex128/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 6afa19f3a..000000000 --- a/complex128/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,104 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var cadd = require( '@stdlib/complex/float64/base/add' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( cadd ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplexLike( out ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.reverse.js b/complex128/benchmark/benchmark.reverse.js deleted file mode 100644 index fa2731237..000000000 --- a/complex128/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,51 +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 bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.reverse.length.js b/complex128/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 292deee9d..000000000 --- a/complex128/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,103 +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 bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.slice.js b/complex128/benchmark/benchmark.slice.js deleted file mode 100644 index 5f8a43bc3..000000000 --- a/complex128/benchmark/benchmark.slice.js +++ /dev/null @@ -1,51 +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 bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.slice.length.js b/complex128/benchmark/benchmark.slice.length.js deleted file mode 100644 index 33042387c..000000000 --- a/complex128/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,103 +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 bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.some.js b/complex128/benchmark/benchmark.some.js deleted file mode 100644 index b4ceaffe6..000000000 --- a/complex128/benchmark/benchmark.some.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex128( v ); - } -}); diff --git a/complex128/benchmark/benchmark.some.length.js b/complex128/benchmark/benchmark.some.length.js deleted file mode 100644 index 904fe3280..000000000 --- a/complex128/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex128} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex128Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( real( value ) === imag( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( new Complex128( i, -i ) ); - } - arr.push( new Complex128( i, i ) ); - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.sort.js b/complex128/benchmark/benchmark.sort.js deleted file mode 100644 index a7548193f..000000000 --- a/complex128/benchmark/benchmark.sort.js +++ /dev/null @@ -1,88 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex128} a - first value for comparison -* @param {Complex128} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = real( a ); - re2 = real( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imag( a ); - im2 = imag( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.sort( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.sort.length.js b/complex128/benchmark/benchmark.sort.length.js deleted file mode 100644 index e74d85d39..000000000 --- a/complex128/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,137 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex128} a - first value for comparison -* @param {Complex128} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = real( a ); - re2 = real( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imag( a ); - im2 = imag( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.sort( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.subarray.js b/complex128/benchmark/benchmark.subarray.js deleted file mode 100644 index 22b790007..000000000 --- a/complex128/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +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 bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.subarray.length.js b/complex128/benchmark/benchmark.subarray.length.js deleted file mode 100644 index c7eda076d..000000000 --- a/complex128/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,103 +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 bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.to_locale_string.js b/complex128/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 625d7d413..000000000 --- a/complex128/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.to_locale_string.length.js b/complex128/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index c521cd477..000000000 --- a/complex128/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,102 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.to_reversed.js b/complex128/benchmark/benchmark.to_reversed.js deleted file mode 100644 index 9b91983e9..000000000 --- a/complex128/benchmark/benchmark.to_reversed.js +++ /dev/null @@ -1,51 +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 bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toReversed', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toReversed(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.to_reversed.length.js b/complex128/benchmark/benchmark.to_reversed.length.js deleted file mode 100644 index 09dc12099..000000000 --- a/complex128/benchmark/benchmark.to_reversed.length.js +++ /dev/null @@ -1,103 +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 bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toReversed(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toReversed:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.to_sorted.js b/complex128/benchmark/benchmark.to_sorted.js deleted file mode 100644 index c85170d51..000000000 --- a/complex128/benchmark/benchmark.to_sorted.js +++ /dev/null @@ -1,88 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex128} a - first value for comparison -* @param {Complex128} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = real( a ); - re2 = real( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imag( a ); - im2 = imag( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - - -// MAIN // - -bench( pkg+':toSorted', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toSorted( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.to_sorted.length.js b/complex128/benchmark/benchmark.to_sorted.length.js deleted file mode 100644 index 73df35db2..000000000 --- a/complex128/benchmark/benchmark.to_sorted.length.js +++ /dev/null @@ -1,137 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex128} a - first value for comparison -* @param {Complex128} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = real( a ); - re2 = real( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imag( a ); - im2 = imag( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toSorted( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toSorted:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.to_string.js b/complex128/benchmark/benchmark.to_string.js deleted file mode 100644 index 989c1a062..000000000 --- a/complex128/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,50 +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 bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.to_string.length.js b/complex128/benchmark/benchmark.to_string.length.js deleted file mode 100644 index d93da12fb..000000000 --- a/complex128/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,102 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.values.js b/complex128/benchmark/benchmark.values.js deleted file mode 100644 index 36d310dd2..000000000 --- a/complex128/benchmark/benchmark.values.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values:len=2', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.values.length.js b/complex128/benchmark/benchmark.values.length.js deleted file mode 100644 index 4de53fab3..000000000 --- a/complex128/benchmark/benchmark.values.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex128( i, i ) ); - } - arr = new Complex128Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':values:len='+len, f ); - } -} - -main(); diff --git a/complex128/benchmark/benchmark.with.js b/complex128/benchmark/benchmark.with.js deleted file mode 100644 index 5f85a2ab6..000000000 --- a/complex128/benchmark/benchmark.with.js +++ /dev/null @@ -1,58 +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 bench = require( '@stdlib/bench' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':with', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ - new Complex128( 1.0, 1.0 ), - new Complex128( 2.0, 2.0 ), - new Complex128( 3.0, 3.0 ) - ]; - arr = new Complex128Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex128/benchmark/benchmark.with.length.js b/complex128/benchmark/benchmark.with.length.js deleted file mode 100644 index 304edad93..000000000 --- a/complex128/benchmark/benchmark.with.length.js +++ /dev/null @@ -1,102 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var pkg = require( './../package.json' ).name; -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Complex128Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Complex128( 1.0, 1.0 ), - new Complex128( 2.0, 2.0 ), - new Complex128( 3.0, 3.0 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex128Array( out ) ) { - b.fail( 'should return a Complex128Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':with:len='+len, f ); - } -} - -main(); diff --git a/complex128/docs/repl.txt b/complex128/docs/repl.txt deleted file mode 100644 index 0d99f9950..000000000 --- a/complex128/docs/repl.txt +++ /dev/null @@ -1,1422 +0,0 @@ - -{{alias}}() - A 128-bit complex number array. - - Returns - ------- - out: Complex128Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Creates a 128-bit complex number array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Complex128Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var len = arr.length - 10 - - -{{alias}}( complexarray ) - Creates a 64-bit complex number array from another complex number array. - - Parameters - ---------- - complexarray: Complex128Array - Complex array from which to generate another complex array. - - Returns - ------- - out: Complex128Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var arr2 = new {{alias}}( arr1 ) - - > var len = arr2.length - 2 - - -{{alias}}( typedarray ) - Creates a 128-bit complex number array from a typed array - containing interleaved real and imaginary components. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate a complex array. - - Returns - ------- - out: Complex128Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/float64}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var arr = new {{alias}}( buf ) - - > var len = arr.length - 2 - - -{{alias}}( obj ) - Creates a 128-bit complex number array from an array-like object or - iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a complex array. - - Returns - ------- - out: Complex128Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var len = arr1.length - 2 - > var buf = [ new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ), new {{alias:@stdlib/complex/float64/ctor}}( 2.0, -2.0 ) ]; - > var arr2 = new {{alias}}( buf ) - - > len = arr2.length - 2 - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a 128-bit complex number array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Complex128Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 480 ); - > var arr1 = new {{alias}}( buf ) - - > var len = arr1.length - 30 - > var arr2 = new {{alias}}( buf, 16 ) - - > len = arr2.length - 29 - > var arr3 = new {{alias}}( buf, 16, 20 ) - - > len = arr3.length - 20 - - -{{alias}}.from( src[, clbk[, thisArg]] ) - Creates a new 128-bit complex number array from an array-like object or an - iterable. - - A callback function is provided two arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - clbk: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Complex128Array - A typed array. - - Examples - -------- - > function clbkFcn( v ) { return v * 2.0 }; - > var arr = {{alias}}.from( [ 1.0, -1.0, 2.0, -2.0 ], clbkFcn ) - - > var len = arr.length - 2 - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new 128-bit complex number array from a variable number of - arguments. - - Parameters - ---------- - element0: number|ComplexLike - Array element. - - element1: number |ComplexLike(optional) - Array element. - - elementN: ...number|ComplexLike (optional) - Array elements. - - Returns - ------- - out: Complex128Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1.0, -1.0, 2.0, -2.0 ) - - > var len = arr.length - 2 - > var z1 = new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ); - > var z2 = new {{alias:@stdlib/complex/float64/ctor}}( 2.0, -2.0 ); - > arr = {{alias}}.of( z1, z2 ) - - > len = arr.length - 2 - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -1.0 - - -{{alias}}.BYTES_PER_ELEMENT - The size of each array element in bytes. - - Examples - -------- - > var nbytes = {{alias}}.BYTES_PER_ELEMENT - 16 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Complex128Array' - - -{{alias}}.prototype.buffer - Pointer to the underlying data buffer. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > var buf = arr.buffer - - - -{{alias}}.prototype.byteLength - Length of the array in bytes. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var nbytes = arr.byteLength - 160 - - -{{alias}}.prototype.byteOffset - Offset (in bytes) of the array from the start of its underlying - ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var offset = arr.byteOffset - 0 - > var buf = new {{alias:@stdlib/array/buffer}}( 480 ); - > arr = new {{alias}}( buf, 128 ) - - > offset = arr.byteOffset - 128 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > arr.BYTES_PER_ELEMENT - 16 - - -{{alias}}.prototype.length - The number of array elements. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var len = arr.length - 10 - - -{{alias}}.prototype.at( i ) - Returns an array element located at integer position (index) `i`, with - support for both nonnegative and negative integer positions. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: Complex128|void - An array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var z = arr.at( 1 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Complex128Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) - - > arr.copyWithin( 0, 2 ) - - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -3.0 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) - - > var it = arr.entries(); - > var v = it.next().value - [ 0, ] - > var re = {{alias:@stdlib/complex/float64/real}}( v[ 1 ] ) - 1.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( v[ 1 ] ) - -1.0 - > v = it.next().value - [ 1, ] - > re = {{alias:@stdlib/complex/float64/real}}( v[ 1 ] ) - 2.0 - > im = {{alias:@stdlib/complex/float64/imag}}( v[ 1 ] ) - -2.0 - > v = it.next().value - [ 2, ] - > re = {{alias:@stdlib/complex/float64/real}}( v[ 1 ] ) - 3.0 - > im = {{alias:@stdlib/complex/float64/imag}}( v[ 1 ] ) - -3.0 - > var bool = it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Returns a boolean indicating whether all elements in the array pass a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all elements pass the test. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) > 0.0 ); }; - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var bool = arr.every( predicate ) - true - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Returns a modified typed array filled with a fill value. - - Parameters - ---------- - value: Complex128 - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Complex128Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( 3 ) - - > arr.fill( new {{alias:@stdlib/complex/float64/ctor}}( 1.0, 1.0 ) ); - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - 1.0 - > z = arr.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - 1.0 - > z = arr.get( 2 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - 1.0 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Returns a new array containing the elements of an array which pass a test - implemented by a predicate function. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Complex128Array - A new typed array. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var out = arr.filter( predicate ) - - > var len = out.length - 1 - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - 2.0 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first element in an array for which a predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Complex128|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var z = arr.find( predicate ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - 1.0 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var idx = arr.findIndex( predicate ) - 0 - - -{{alias}}.prototype.findLast( predicate[, thisArg] ) - Returns the last element in an array for which a predicate function returns - a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Complex128|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var z = arr.findLast( predicate ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - 2.0 - - -{{alias}}.prototype.findLastIndex( predicate[, thisArg] ) - Returns the index of the last element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var idx = arr.findLastIndex( predicate ) - 1 - - -{{alias}}.prototype.forEach( clbk[, thisArg] ) - Invokes a function once for each array element. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - clbk: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Execution context. - - Examples - -------- - > var str = '%'; - > function clbk( v ) { str += v.toString() + '%'; }; - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > arr.forEach( clbk ); - > str - '%1 - 1i%2 - 2i%' - - -{{alias}}.prototype.get( i ) - Returns an array element located at integer position (index) `i`. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: Complex128|void - Array element or `undefined`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var z = arr.get( 1 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a provided value. - - Parameters - ---------- - searchElement: Complex128 - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) - - > var bool = arr.includes( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ) ) - true - > bool = arr.includes( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ), 3 ) - false - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the first index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: Complex128 - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) - - > var idx = arr.indexOf( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ) ) - 2 - > idx = arr.indexOf( new {{alias:@stdlib/complex/float64/ctor}}( 3.0, -3.0 ), 3 ) - -1 - - -{{alias}}.prototype.join( [separator] ) - Returns a new string by concatenating all array elements separated by a - separator string. - - Parameters - ---------- - separator: string (optional) - Separator string. Default: ','. - - Returns - ------- - out: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var str = arr.join() - '1 - 1i,2 - 2i' - > str = arr.join( '/' ) - '1 - 1i/2 - 2i' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over each index key in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array index keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var it = arr.keys(); - > var v = it.next().value - 0 - > v = it.next().value - 1 - > v = it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the last index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: Complex128 - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: out.length-1. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) - - > var idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ) ) - 3 - > idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ), 2 ) - 0 - - -{{alias}}.prototype.map( clbk[, thisArg] ) - Returns a new array with each element being the result of a provided - callback function. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - clbk: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Complex128Array - A new typed array. - - Examples - -------- - > function clbk( v ) { return v; }; - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var out = arr.map( clbk ) - - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -1.0 - > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 - - -{{alias}}.prototype.reduce( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in order, passing - in the return value from the calculation on the preceding element and - returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var z = arr.reduce( {{alias:@stdlib/complex/float64/base/add}} ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -3.0 - - -{{alias}}.prototype.reduceRight( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in reverse order, - passing in the return value from the calculation on the preceding element - and returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var z = arr.reduceRight( {{alias:@stdlib/complex/float64/base/add}} ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -3.0 - - -{{alias}}.prototype.reverse() - Reverses the array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Complex128Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) - - > arr.reverse(); - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -3.0 - > z = arr.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 - > z = arr.get( 2 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -1.0 - - -{{alias}}.prototype.set( z[, i] ) - Sets one or more array elements. - - If provided a single argument, the method sets array elements starting at - position (index) `i = 0`. To set elements starting elsewhere in the array, - provide an index argument `i`. - - To set one or more array elements, provide an array-like object containing - either complex numbers or interleaved real and imaginary components. - - Parameters - ---------- - z: Complex128|Complex128Array|ArrayLikeObject - Complex number or complex number array. - - i: integer (optional) - Array index at which to start setting elements. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > arr.set( new {{alias:@stdlib/complex/float64/ctor}}( 1.0, -1.0 ) ); - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -1.0 - > arr.set( new {{alias:@stdlib/complex/float64/ctor}}( 2.0, -2.0 ), 1 ); - > z = arr.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 - - -{{alias}}.prototype.slice( [start[, end]] ) - Copies a portion of a typed array to a new typed array. - - Parameters - ---------- - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Complex128Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) - - > var out = arr.slice( 1 ) - - > var len = out.length - 2 - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 - > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -3.0 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Returns a boolean indicating whether at least one element passes a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one element passes the test. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float64/real}}( v ) === {{alias:@stdlib/complex/float64/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var bool = arr.some( predicate ) - true - - -{{alias}}.prototype.sort( compareFunction ) - Sorts an array in-place. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFunction: Function - Comparison function. - - Returns - ------- - out: Complex128Array - Modified array. - - Examples - -------- - > function compare( a, b ) { return ( {{alias:@stdlib/complex/float64/real}}( a ) - {{alias:@stdlib/complex/float64/real}}( b ) ); }; - > var arr = new {{alias}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) - - > arr.sort( compare ); - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -1.0 - > z = arr.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 - > z = arr.get( 2 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -3.0 - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array view over the same underlying `ArrayBuffer` and - with the same underlying data type as the host array. - - Parameters - ---------- - begin: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Complex128Array - New typed array view. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) - - > var out = arr.subarray( 1, 3 ) - - > var len = out.length - 2 - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 - > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -3.0 - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - Locale identifier(s). - - options: Object (optional) - An object containing serialization options. - - Returns - ------- - str: string - Local-specific string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0 ] ) - - > var str = arr.toLocaleString() - '1 + 1i,2 + 2i' - - -{{alias}}.prototype.toReversed() - Returns a new typed array containing the elements in reversed order. - - Returns - ------- - out: Complex128Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ) - - > var out = arr.toReversed() - - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - 3.0 - > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - 2.0 - > z = out.get( 2 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - 1.0 - - -{{alias}}.prototype.toSorted( compareFcn ) - Returns a new typed array containing the elements in sorted order. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFcn: Function - Comparison function. - - Returns - ------- - out: Complex128Array - New typed array. - - Examples - -------- - > function compare( a, b ) { return ( {{alias:@stdlib/complex/float64/real}}( a ) - {{alias:@stdlib/complex/float64/real}}( b ) ); }; - > var arr = new {{alias}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) - - > var out = arr.toSorted( compare ); - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -1.0 - > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -2.0 - > z = out.get( 2 ) - - > re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > im = {{alias:@stdlib/complex/float64/imag}}( z ) - -3.0 - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - String serialization of the array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, -2.0, 3.0, 3.0 ] ) - - > var str = arr.toString() - '1 + 1i,2 - 2i,3 + 3i' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over each value in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array values. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var it = arr.values(); - > var v = it.next().value - - > var re = {{alias:@stdlib/complex/float64/real}}( v ) - 1.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( v ) - -1.0 - > v = it.next().value - - > re = {{alias:@stdlib/complex/float64/real}}( v ) - 2.0 - > im = {{alias:@stdlib/complex/float64/imag}}( v ) - -2.0 - > var bool = it.next().done - true - - -{{alias}}.prototype.with( index, value ) - Returns a new typed array with the element at a provided index replaced - with a provided value. - - Parameters - ---------- - index: integer - Element index. - - value: Complex128 - Element value. - - Returns - ------- - out: Complex128Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var out = arr.with( 1, new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ) ) - - > var z = out.get( 1 ) - - > var re = {{alias:@stdlib/complex/float64/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float64/imag}}( z ) - -3.0 - - - See Also - -------- diff --git a/complex128/docs/types/index.d.ts b/complex128/docs/types/index.d.ts deleted file mode 100644 index babe3c9f4..000000000 --- a/complex128/docs/types/index.d.ts +++ /dev/null @@ -1,1843 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; -import { ArrayLike, RealOrComplexTypedArray, Complex128Array as Complex128ArrayInterface } from '@stdlib/types/array'; -import { ComplexLike, Complex128 } from '@stdlib/types/complex'; -import ArrayBuffer = require( './../../../buffer' ); - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Locale-specific configuration options. -*/ -interface LocaleOptions { - /** - * Configuration property. - */ - [ key: string | symbol | number ]: T | undefined; -} - -/** -* Callback invoked for each element in a source object. -* -* @returns transformed value -*/ -type FromNullary = ( this: U ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @returns transformed value -*/ -type FromUnary = ( this: U, value: ComplexLike | ArrayLike | number ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromBinary = ( this: U, value: ComplexLike | ArrayLike | number, index: number ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromCallback = FromNullary | FromUnary | FromBinary; - -/** -* Checks whether an element in an array passes a test. -* -* @returns boolean indicating whether an element in an array passes a test -*/ -type NullaryPredicate = ( this: U ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element in an array passes a test -*/ -type UnaryPredicate = ( this: U, value: Complex128 ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element in an array passes a test -*/ -type BinaryPredicate = ( this: U, value: Complex128, index: number ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type TernaryPredicate = ( this: U, value: Complex128, index: number, arr: Complex128Array ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Callback invoked for each element in an array. -* -* @returns undefined -*/ -type NullaryCallback = ( this: U ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns undefined -*/ -type UnaryCallback = ( this: U, value: Complex128 ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns undefined -*/ -type BinaryCallback = ( this: U, value: Complex128, index: number ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type TernaryCallback = ( this: U, value: Complex128, index: number, arr: Complex128Array ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; - -/** -* Callback invoked for each element in an array. -* -* @returns transformed value -*/ -type NullaryMapFcn = ( this: U ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns transformed value -*/ -type UnaryMapFcn = ( this: U, value: Complex128 ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns transformed value -*/ -type BinaryMapFcn = ( this: U, value: Complex128, index: number ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns transformed value -*/ -type TernaryMapFcn = ( this: U, value: Complex128, index: number, arr: Complex128Array ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns transformed value -*/ -type MapFcn = NullaryMapFcn | UnaryMapFcn | BinaryMapFcn | TernaryMapFcn; - -/** -* Reducer function invoked for each element in an array. -* -* @returns accumulated result -*/ -type NullaryReducer = () => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @returns accumulated result -*/ -type UnaryReducer = ( acc: U ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @returns accumulated result -*/ -type BinaryReducer = ( acc: U, value: Complex128 ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @returns accumulated result -*/ -type TernaryReducer = ( acc: U, value: Complex128, index: number ) => U; - -/** -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type QuaternaryReducer = ( acc: U, value: Complex128, index: number, arr: Complex128Array ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type Reducer = NullaryReducer | UnaryReducer | BinaryReducer | TernaryReducer | QuaternaryReducer; - -/** -* Comparator function. -* -* @param a - first value for comparison -* @param b - second value for comparison -* @returns number indicating comparison result -*/ -type CompareFcn = ( a: Complex128, b: Complex128 ) => number; - -/** -* Class for creating a 128-bit complex number array. -*/ -declare class Complex128Array implements Complex128ArrayInterface { - /** - * 128-bit complex number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `8` - * @throws array-like object and typed array input arguments must have a length which is a multiple of two - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `8` - * @throws view length must be a positive multiple of `8` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @throws an iterator must return either a two element array containing real and imaginary components or a complex number - * @returns complex number array - * - * @example - * var arr = new Complex128Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Complex128Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Complex128Array( [ 1.0, -1.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex128Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex128Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Complex128Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - constructor( arg?: number | RealOrComplexTypedArray | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ); - - /** - * Returns an array element with support for both nonnegative and negative integer indices. - * - * @param i - element index - * @throws index argument must be an integer - * @returns array element - * - * @example - * var arr = new Complex128Array( 10 ); - * - * var z = arr.at( 0 ); - * // returns - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 9.0, -9.0 ], 9 ); - * - * z = arr.get( -1 ) - * // return - * - * z = arr.at( 100 ); - * // returns undefined - * - * z = arr.at( -100 ); - * // returns undefined - */ - at( i: number ): Complex128 | void; - - /** - * Pointer to the underlying data buffer. - * - * @example - * var arr = new Complex128Array( 10 ); - * - * var buf = arr.buffer; - * // returns - */ - readonly buffer: ArrayBuffer; - - /** - * Length (in bytes) of the array. - * - * @example - * var arr = new Complex128Array( 10 ); - * - * var byteLength = arr.byteLength; - * // returns 160 - */ - readonly byteLength: number; - - /** - * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - * - * @example - * var arr = new Complex128Array( 10 ); - * - * var byteOffset = arr.byteOffset; - * // returns 0 - */ - readonly byteOffset: number; - - /** - * Size (in bytes) of each array element. - * - * @example - * var arr = new Complex128Array( 10 ); - * - * var nbytes = arr.BYTES_PER_ELEMENT; - * // returns 16 - */ - readonly BYTES_PER_ELEMENT: 16; - - /** - * Number of array elements. - * - * @example - * var arr = new Complex128Array( 10 ); - * - * var len = arr.length; - * // returns 10 - */ - readonly length: number; - - /** - * Copies a sequence of elements within the array to the position starting at `target`. - * - * @param target - index at which to start copying elements - * @param start - source index at which to copy elements from - * @param end - source index at which to stop copying elements from - * @returns modified array - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * var arr = new Complex128Array( 4 ); - * - * // Set the array elements: - * arr.set( new Complex128( 1.0, 1.0 ), 0 ); - * arr.set( new Complex128( 2.0, 2.0 ), 1 ); - * arr.set( new Complex128( 3.0, 3.0 ), 2 ); - * arr.set( new Complex128( 4.0, 4.0 ), 3 ); - * - * // Copy the first two elements to the last two elements: - * arr.copyWithin( 2, 0, 2 ); - * - * // Get the last array element: - * var z = arr.get( 3 ); - * - * var re = real( z ); - * // returns 2.0 - * - * var im = imag( z ); - * // returns 2.0 - */ - copyWithin( target: number, start: number, end?: number ): Complex128Array; - - /** - * Returns an iterator for iterating over array key-value pairs. - * - * @returns iterator - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var arr = [ - * new Complex128( 1.0, 1.0 ), - * new Complex128( 2.0, 2.0 ), - * new Complex128( 3.0, 3.0 ) - * ]; - * arr = new Complex128Array( arr ); - * - * // Create an iterator: - * var it = arr.entries(); - * - * // Iterate over the key-value pairs... - * var v = it.next().value; - * // returns [ 0, ] - * - * v = it.next().value; - * // returns [ 1, ] - * - * v = it.next().value; - * // returns [ 2, ] - * - * var bool = it.next().done; - * // returns true - */ - entries(): Iterator; - - /** - * Tests whether all elements in an array pass a test implemented by a predicate function. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns boolean indicating whether all elements pass a test - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * function predicate( v ) { - * return ( real( v ) === imag( v ) ); - * } - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0 , 1.0 ], 0 ); - * arr.set( [ 2.0 , 2.0 ], 1 ); - * arr.set( [ 3.0 , 3.0 ], 2 ); - * - * var bool = arr.every( predicate ); - * // returns true - */ - every( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Returns a modified typed array filled with a fill value. - * - * @param value - fill value - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @returns modified typed array - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * var arr = new Complex128Array( 3 ); - * - * arr.fill( new Complex128( 1.0, 1.0 ), 1 ); - * - * var z = arr.get( 1 ); - * // returns - * - * var re = real( z ); - * // returns 1.0 - * - * var im = imag( z ); - * // returns 1.0 - * - * z = arr.get( 2 ); - * // returns - * - * re = real( z ); - * // returns 1.0 - * - * im = imag( z ); - * // returns 1.0 - */ - fill( value: ComplexLike, start?: number, end?: number ): Complex128Array; - - /** - * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns new array containing elements which pass a test implemented by a predicate function - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * function predicate( v ) { - * return ( real( v ) === imag( v ) ); - * } - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * - * var out = arr.filter( predicate ); - * // returns - * - * var len = out.length; - * // returns 1 - * - * var z = out.get( 0 ); - * // returns - * - * var re = real( z ); - * // returns 2.0 - * - * var im = imag( z ); - * // returns 2.0 - */ - filter( predicate: Predicate, thisArg?: ThisParameterType> ): Complex128Array; - - /** - * Returns the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns array element or undefined - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * function predicate( v ) { - * return ( real( v ) === imag( v ) ); - * } - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var z = arr.find( predicate ); - * // returns - * - * var re = real( z ); - * // returns 1.0 - * - * var im = imag( z ); - * // returns 1.0 - */ - find( predicate: Predicate, thisArg?: ThisParameterType> ): Complex128 | void; - - /** - * Returns the index of the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns index or -1 - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * function predicate( v ) { - * return ( real( v ) === imag( v ) ); - * } - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var idx = arr.findIndex( predicate ); - * // returns 2 - */ - findIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Returns the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns array element or undefined - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * function predicate( v ) { - * return ( real( v ) === imag( v ) ); - * } - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var z = arr.findLast( predicate ); - * // returns - * - * var re = real( z ); - * // returns 3.0 - * - * var im = imag( z ); - * // returns 3.0 - */ - findLast( predicate: Predicate, thisArg?: ThisParameterType> ): Complex128 | void; - - /** - * Returns the index of the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns index or -1 - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * function predicate( v ) { - * return ( real( v ) === imag( v ) ); - * } - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * - * var idx = arr.findLastIndex( predicate ); - * // returns 1 - */ - findLastIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Invokes a function once for each array element. - * - * @param fcn - function to invoke - * @param thisArg - execution context - * @returns undefined - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * function log( v, i ) { - * console.log( '%s: %s', i, v.toString() ); - * } - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * arr.forEach( log ); - * // => 0: 1 + 1i - * // => 1: 2 + 2i - * // => 2: 3 + 3i - */ - forEach( fcn: Callback, thisArg?: ThisParameterType> ): void; - - /** - * Returns an array element. - * - * @param i - element index - * @throws index argument must be a nonnegative integer - * @returns array element - * - * @example - * var arr = new Complex128Array( 10 ); - * - * var z = arr.get( 0 ); - * // returns - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * - * z = arr.get( 100 ); - * // returns undefined - */ - get( i: number ): Complex128 | void; - - /** - * Returns a boolean indicating whether an array contains a provided value. - * - * @param searchElement - search element - * @param fromIndex - starting index (inclusive) - * @returns boolean indicating whether an array contains a provided value - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var arr = new Complex128Array( 5 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * arr.set( [ 4.0, -4.0 ], 3 ); - * arr.set( [ 5.0, -5.0 ], 4 ); - * - * var bool = arr.includes( new Complex128( 3.0, -3.0 ) ); - * // returns true - * - * bool = arr.includes( new Complex128( 3.0, -3.0 ), 3 ); - * // returns false - * - * bool = arr.includes( new Complex128( 4.0, -4.0 ), -3 ); - * // returns true - */ - includes( searchElement: ComplexLike, fromIndex?: number ): boolean; - - /** - * Returns the first index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - starting index (inclusive) - * @returns index or -1 - * - * @example - * var arr = new Complex128Array( 5 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * arr.set( [ 2.0, 2.0 ], 3 ); - * arr.set( [ 5.0, 5.0 ], 4 ); - * - * var idx = arr.indexOf( new Complex128( [ 2.0, 2.0 ] ) ); - * // returns 1 - * - * idx = arr.indexOf( new Complex128( [ 2.0, 2.0 ] ), 2 ); - * // returns 3 - * - * idx = arr.indexOf( new Complex128( [ 2.0, 2.0 ] ), -3 ); - * // returns 3 - */ - indexOf( searchElement: ComplexLike, fromIndex?: number ): number; - - /** - * Returns a new string by concatenating all array elements. - * - * @param separator - value separator (default: ',') - * @returns string - * - * @example - * var arr = new Complex128Array( 2 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * - * var str = arr.join(); - * // returns '1 + 1i,2 + 2i' - * - * str = arr.join( '/' ); - * // returns '1 + 1i/2 + 2i' - */ - join( separator?: string ): string; - - /** - * Returns an iterator for iterating over each index key in a typed array. - * - * @returns iterator - * - * @example - * var arr = new Complex128Array( 2 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * - * var iter = arr.keys(); - * - * var v = iter.next().value; - * // returns 0 - * - * v = iter.next().value; - * // returns 1 - * - * var bool = iter.next().done; - * // returns true - */ - keys(): TypedIterator; - - /** - * Returns the last index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - index at which to start searching backward (inclusive) - * @returns index or -1 - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var arr = new Complex128Array( 5 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * arr.set( [ 4.0, -4.0 ], 3 ); - * arr.set( [ 3.0, -3.0 ], 4 ); - * - * var idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ) ); - * // returns 4 - * - * idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ), 3 ); - * // returns 2 - * - * idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), -3 ); - * // returns 1 - */ - lastIndexOf( searchElement: ComplexLike, fromIndex?: number ): number; - - /** - * Returns a new array with each element being the result of a provided callback function. - * - * @param fcn - callback function - * @param thisArg - execution context - * @returns new array containing transformed elements - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * function scale( v, i ) { - * return new Complex128( 2.0*real( v ), 2.0*imag( v ) ); - * } - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * - * var out = arr.map( scale ); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = real( z ); - * // returns 2.0 - * - * var im = imag( z ); - * // returns -2.0 - */ - map( fcn: MapFcn, thisArg?: ThisParameterType> ): Complex128Array; - - /** - * Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * var cadd = require( '@stdlib/complex/float64/base/add' ); - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var z = arr.reduce( cadd ); - * // returns - * - * var re = real( z ); - * // returns 6.0 - * - * var im = imag( z ); - * // returns 6.0 - */ - reduce( reducer: Reducer, initialValue?: U ): U; - - /** - * Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * var cadd = require( '@stdlib/complex/float64/base/add' ); - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var z = arr.reduceRight( cadd ); - * // returns - * - * var re = real( z ); - * // returns 6.0 - * - * var im = imag( z ); - * // returns 6.0 - */ - reduceRight( reducer: Reducer, initialValue?: U ): U; - - /** - * Reverses an array in-place. - * - * @returns reversed array - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var out = arr.reverse(); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = real( z ); - * // returns 3.0 - * - * var im = imag( z ); - * // returns 3.0 - * - * z = out.get( 1 ); - * // returns - * - * re = real( z ); - * // returns 2.0 - * - * im = imag( z ); - * // returns 2.0 - * - * z = out.get( 2 ); - * // returns - * - * re = real( z ); - * // returns 1.0 - * - * im = imag( z ); - * // returns 1.0 - */ - reverse(): Complex128Array; - - /** - * Sets an array element. - * - * ## Notes - * - * - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. - * - * In the other overlapping scenario, - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended. - * - * - * @param value - value(s) - * @param i - element index at which to start writing values (default: 0) - * @throws index argument must be a nonnegative integer - * @throws array-like objects must have a length which is a multiple of two - * @throws index argument is out-of-bounds - * @throws target array lacks sufficient storage to accommodate source values - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * var arr = new Complex128Array( 10 ); - * - * var z = arr.get( 0 ); - * // returns - * - * var re = real( z ); - * // returns 0.0 - * - * var im = imag( z ); - * // returns 0.0 - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * - * z = arr.get( 0 ); - * // returns - * - * re = real( z ); - * // returns 1.0 - * - * im = imag( z ); - * // returns -1.0 - */ - set( value: ArrayLike | RealOrComplexTypedArray | ComplexLike, i?: number ): void; - - /** - * Copies a portion of a typed array to a new typed array. - * - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns output array - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * var arr = new Complex128Array( 5 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * arr.set( [ 4.0, -4.0 ], 3 ); - * arr.set( [ 5.0, -5.0 ], 4 ); - * - * var out = arr.slice(); - * // returns - * - * var len = out.length; - * // returns 5 - * - * var z = out.get( 0 ); - * // returns - * - * var re = real( z ); - * // returns 1.0 - * - * var im = imag( z ); - * // returns -1.0 - * - * z = out.get( len-1 ); - * // returns - * - * re = real( z ); - * // returns 5.0 - * - * im = imag( z ); - * // returns -5.0 - * - * out = arr.slice( 1, -2 ); - * // returns - * - * len = out.length; - * // returns 2 - * - * z = out.get( 0 ); - * // returns - * - * re = real( z ); - * // returns 2.0 - * - * im = imag( z ); - * // returns -2.0 - * - * z = out.get( len-1 ); - * // returns - * - * re = real( z ); - * // returns 3.0 - * - * im = imag( z ); - * // returns -3.0 - */ - slice( start?: number, end?: number ): Complex128Array; - - /** - * Tests whether at least one element in an array passes a test implemented by a predicate function. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns boolean indicating whether at least one element passes a test - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * function predicate( v ) { - * return ( real( v ) === imag( v ) ); - * } - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0 , -1.0 ], 0 ); - * arr.set( [ 2.0 , 2.0 ], 1 ); - * arr.set( [ 3.0 , -3.0 ], 2 ); - * - * var bool = arr.some( predicate ); - * // returns true - */ - some( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Sorts an array in-place. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * function compare( a, b ) { - * var re1; - * var re2; - * var im1; - * var im2; - * re1 = real( a ); - * re2 = real( b ); - * if ( re1 < re2 ) { - * return -1; - * } - * if ( re1 > re2 ) { - * return 1; - * } - * im1 = imag( a ); - * im2 = imag( b ); - * if ( im1 < im2 ) { - * return -1; - * } - * if ( im1 > im2 ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 3.0, -3.0 ], 0 ); - * arr.set( [ 1.0, -1.0 ], 1 ); - * arr.set( [ 2.0, -2.0 ], 2 ); - * - * var out = arr.sort( compare ); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = real( z ); - * // returns 1.0 - * - * var im = imag( z ); - * // returns -1.0 - * - * z = out.get( 1 ); - * // returns - * - * re = real( z ); - * // returns 2.0 - * - * im = imag( z ); - * // returns -2.0 - * - * z = out.get( 2 ); - * // returns - * - * re = real( z ); - * // returns 3.0 - * - * im = imag( z ); - * // returns -3.0 - */ - sort( compareFcn: CompareFcn ): Complex128Array; - - /** - * Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. - * - * @param begin - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns subarray - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * var arr = new Complex128Array( 5 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * arr.set( [ 4.0, -4.0 ], 3 ); - * arr.set( [ 5.0, -5.0 ], 4 ); - * - * var subarr = arr.subarray(); - * // returns - * - * var len = subarr.length; - * // returns 5 - * - * var z = subarr.get( 0 ); - * // returns - * - * var re = real( z ); - * // returns 1.0 - * - * var im = imag( z ); - * // returns -1.0 - * - * z = subarr.get( len-1 ); - * // returns - * - * re = real( z ); - * // returns 5.0 - * - * im = imag( z ); - * // returns -5.0 - * - * subarr = arr.subarray( 1, -2 ); - * // returns - * - * len = subarr.length; - * // returns 2 - * - * z = subarr.get( 0 ); - * // returns - * - * re = real( z ); - * // returns 2.0 - * - * im = imag( z ); - * // returns -2.0 - * - * z = subarr.get( len-1 ); - * // returns - * - * re = real( z ); - * // returns 3.0 - * - * im = imag( z ); - * // returns -3.0 - */ - subarray( begin?: number, end?: number ): Complex128Array; - - /** - * Serializes an array as a locale-specific string. - * - * @param locales - locale identifier(s) - * @param options - configuration options - * @returns string - * - * @example - * var arr = new Complex128Array( 2 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * - * var str = arr.toLocaleString(); - * // returns '1 + 1i,2 + 2i' - */ - toLocaleString( locales?: string | Array, options?: LocaleOptions ): string; - - /** - * Returns a new typed array containing the elements in reversed order. - * - * @returns reversed array - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var out = arr.toReversed(); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = real( z ); - * // returns 3.0 - * - * var im = imag( z ); - * // returns 3.0 - * - * z = out.get( 1 ); - * // returns - * - * re = real( z ); - * // returns 2.0 - * - * im = imag( z ); - * // returns 2.0 - * - * z = out.get( 2 ); - * // returns - * - * re = real( z ); - * // returns 1.0 - * - * im = imag( z ); - * // returns 1.0 - */ - toReversed(): Complex128Array; - - /** - * Returns a new typed array containing the elements in sorted order. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * function compare( a, b ) { - * var re1; - * var re2; - * var im1; - * var im2; - * re1 = real( a ); - * re2 = real( b ); - * if ( re1 < re2 ) { - * return -1; - * } - * if ( re1 > re2 ) { - * return 1; - * } - * im1 = imag( a ); - * im2 = imag( b ); - * if ( im1 < im2 ) { - * return -1; - * } - * if ( im1 > im2 ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 3.0, -3.0 ], 0 ); - * arr.set( [ 1.0, -1.0 ], 1 ); - * arr.set( [ 2.0, -2.0 ], 2 ); - * - * var out = arr.toSorted( compare ); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = real( z ); - * // returns 1.0 - * - * var im = imag( z ); - * // returns -1.0 - * - * z = out.get( 1 ); - * // returns - * - * re = real( z ); - * // returns 2.0 - * - * im = imag( z ); - * // returns -2.0 - * - * z = out.get( 2 ); - * // returns - * - * re = real( z ); - * // returns 3.0 - * - * im = imag( z ); - * // returns -3.0 - */ - toSorted( compareFcn: CompareFcn ): Complex128Array; - - /** - * Serializes an array as a string. - * - * @returns string - * - * @example - * var arr = new Complex128Array( 2 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * - * var str = arr.toString(); - * // returns '1 + 1i,2 + 2i' - */ - toString(): string; - - /** - * Returns an iterator for iterating over each value in a typed array. - * - * @returns iterator - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * var arr = new Complex128Array( 2 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * - * var iter = arr.values(); - * - * var v = iter.next().value; - * // returns - * - * var re = real( v ); - * // returns 1.0 - * - * var im = imag( v ); - * // returns -1.0 - * - * v = iter.next().value; - * // returns - * - * re = real( v ); - * // returns 2.0 - * - * im = imag( v ); - * // returns -2.0 - * - * var bool = iter.next().done; - * // returns true - */ - values(): TypedIterator; - - /** - * Returns a new typed array with the element at a provided index replaced with a provided value. - * - * @param index - element index - * @param value - new value - * @throws first argument must be an integer - * @throws second argument must be a complex number - * @throws index argument is out-of-bounds - * @returns modified typed array - * - * @example - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var arr = new Complex128Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var out = arr.with( 0, new Complex128( 4.0, 4.0 ) ); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = real( z ); - * // returns 4.0 - * - * var im = imag( z ); - * // returns 4.0 - */ - with( index: number, value: ComplexLike ): Complex128Array; -} - -/** -* Interface defining a 128-bit complex number array constructor which is both "newable" and "callable". -*/ -interface Complex128ArrayConstructor { - /** - * 128-bit complex number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `8` - * @throws array-like object and typed array input arguments must have a length which is a multiple of two - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `8` - * @throws view length must be a positive multiple of `8` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @throws an iterator must return either a two element array containing real and imaginary components or a complex number - * @returns complex number array - * - * @example - * var arr = new Complex128Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Complex128Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Complex128Array( [ 1.0, -1.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex128Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex128Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Complex128Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - new( arg?: number | RealOrComplexTypedArray | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): Complex128Array; - - /** - * 128-bit complex number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `8` - * @throws array-like object and typed array input arguments must have a length which is a multiple of two - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `8` - * @throws view length must be a positive multiple of `8` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @throws an iterator must return either a two element array containing real and imaginary components or a complex number - * @returns complex number array - * - * @example - * var arr = new Complex128Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Complex128Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Complex128Array( [ 1.0, -1.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex128Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex128Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Complex128Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - ( arg?: number | RealOrComplexTypedArray | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): Complex128Array; - - /** - * Constructor name. - * - * @example - * var str = Complex128Array.name; - * // returns 'Complex128Array' - */ - readonly name: 'Complex128Array'; - - /** - * Size (in bytes) of each array element. - * - * @example - * var nbytes = Complex128Array.BYTES_PER_ELEMENT; - * // returns 16 - */ - readonly BYTES_PER_ELEMENT: 16; - - /** - * Creates a new 128-bit complex number array from an array-like object or an iterable. - * - * @param src - array-like object or iterable - * @param clbk - callback to invoke for each source element - * @param thisArg - context - * @throws array-like objects must have a length which is a multiple of two - * @throws an iterator must return either a two element array containing real and imaginary components or a complex number - * @throws when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number - * @returns 128-bit complex number array - * - * @example - * var arr = Complex128Array.from( [ 1.0, -1.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * var real = require( '@stdlib/complex/float64/real' ); - * var imag = require( '@stdlib/complex/float64/imag' ); - * - * function clbk( v ) { - * return new Complex128( real(v)*2.0, imag(v)*2.0 ); - * } - * - * var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk ); - * // returns - * - * var len = arr.length; - * // returns 1 - */ - from( src: ArrayLike | RealOrComplexTypedArray | Iterable, clbk?: FromCallback, thisArg?: ThisParameterType> ): Complex128Array; - - /** - * Creates a new 128-bit complex number array from a variable number of arguments. - * - * @param elements - array elements - * @returns 128-bit complex number array - * - * @example - * var arr = Complex128Array.of( 1.0, 1.0, 1.0, 1.0 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - of( ...elements: Array ): Complex128Array; -} - -/** -* 128-bit complex number array constructor. -* -* @param arg - length, typed array, array-like object, or buffer -* @param byteOffset - byte offset (default: 0) -* @param length - view length -* @throws ArrayBuffer byte length must be a multiple of `8` -* @throws array-like object and typed array input arguments must have a length which is a multiple of two -* @throws if provided only a single argument, must provide a valid argument -* @throws byte offset must be a nonnegative integer -* @throws byte offset must be a multiple of `8` -* @throws view length must be a positive multiple of `8` -* @throws must provide sufficient memory to accommodate byte offset and view length requirements -* @throws an iterator must return either a two element array containing real and imaginary components or a complex number -* @returns complex number array -* -* @example -* var arr = new Complex128Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Complex128Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Complex128Array( [ 1.0, -1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Complex128Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Complex128Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Complex128Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -declare var ctor: Complex128ArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/complex128/docs/types/test.ts b/complex128/docs/types/test.ts deleted file mode 100644 index 4ecb3a1ca..000000000 --- a/complex128/docs/types/test.ts +++ /dev/null @@ -1,160 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import ArrayBuffer = require( './../../../buffer' ); -import real = require( '@stdlib/complex/float64/real' ); -import imag = require( '@stdlib/complex/float64/imag' ); -import Complex128Array = require( './index' ); - -/** -* Callback function. -* -* @private -* @param v - input value -* @returns output value -*/ -function clbk( v: Complex128 ): Complex128 { - return new Complex128( real( v ) * 2.0, imag( v ) * 2.0 ); -} - - -// TESTS // - -// The function returns a complex number array... -{ - new Complex128Array(); // $ExpectType Complex128Array - Complex128Array(); // $ExpectType Complex128Array - new Complex128Array( 2 ); // $ExpectType Complex128Array - Complex128Array( 2 ); // $ExpectType Complex128Array - new Complex128Array( [ 1.0, -1.0 ] ); // $ExpectType Complex128Array - Complex128Array( [ 1.0, -1.0 ] ); // $ExpectType Complex128Array - - const buf = new ArrayBuffer( 16 ); - new Complex128Array( buf ); // $ExpectType Complex128Array - Complex128Array( buf ); // $ExpectType Complex128Array - new Complex128Array( buf, 8 ); // $ExpectType Complex128Array - Complex128Array( buf, 8 ); // $ExpectType Complex128Array - new Complex128Array( buf, 8, 2 ); // $ExpectType Complex128Array - Complex128Array( buf, 8, 2 ); // $ExpectType Complex128Array -} - -// The compiler throws an error if the function is provided a first argument that is not a number, typed array, array-like object, or array buffer... -{ - new Complex128Array( true ); // $ExpectError - new Complex128Array( false ); // $ExpectError - new Complex128Array( null ); // $ExpectError - new Complex128Array( 'abc' ); // $ExpectError - new Complex128Array( {} ); // $ExpectError - new Complex128Array( ( x: number ): number => x ); // $ExpectError - - Complex128Array( true ); // $ExpectError - Complex128Array( false ); // $ExpectError - Complex128Array( null ); // $ExpectError - Complex128Array( 'abc' ); // $ExpectError - Complex128Array( {} ); // $ExpectError - Complex128Array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Complex128Array( buf, true ); // $ExpectError - new Complex128Array( buf, false ); // $ExpectError - new Complex128Array( buf, null ); // $ExpectError - new Complex128Array( buf, 'abc' ); // $ExpectError - new Complex128Array( buf, {} ); // $ExpectError - new Complex128Array( buf, ( x: number ): number => x ); // $ExpectError - - Complex128Array( buf, true ); // $ExpectError - Complex128Array( buf, false ); // $ExpectError - Complex128Array( buf, null ); // $ExpectError - Complex128Array( buf, 'abc' ); // $ExpectError - Complex128Array( buf, {} ); // $ExpectError - Complex128Array( buf, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Complex128Array( buf, 8, true ); // $ExpectError - new Complex128Array( buf, 8, false ); // $ExpectError - new Complex128Array( buf, 8, null ); // $ExpectError - new Complex128Array( buf, 8, 'abc' ); // $ExpectError - new Complex128Array( buf, 8, {} ); // $ExpectError - new Complex128Array( buf, 8, ( x: number ): number => x ); // $ExpectError - - Complex128Array( buf, 8, true ); // $ExpectError - Complex128Array( buf, 8, false ); // $ExpectError - Complex128Array( buf, 8, null ); // $ExpectError - Complex128Array( buf, 8, 'abc' ); // $ExpectError - Complex128Array( buf, 8, {} ); // $ExpectError - Complex128Array( buf, 8, ( x: number ): number => x ); // $ExpectError -} - -// The `from` method returns a complex number array... -{ - Complex128Array.from( [ 1.0, 1.0 ] ); // $ExpectType Complex128Array - Complex128Array.from( [ 1.0, 1.0 ], ( x: number ): number => x * x ); // $ExpectType Complex128Array - Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk, {} ); // $ExpectType Complex128Array -} - -// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable... -{ - Complex128Array.from( true ); // $ExpectError - Complex128Array.from( false ); // $ExpectError - Complex128Array.from( 123 ); // $ExpectError - Complex128Array.from( null ); // $ExpectError - Complex128Array.from( {} ); // $ExpectError - - Complex128Array.from( true, clbk ); // $ExpectError - Complex128Array.from( false, clbk ); // $ExpectError - Complex128Array.from( 123, clbk ); // $ExpectError - Complex128Array.from( null, clbk ); // $ExpectError - Complex128Array.from( {}, clbk ); // $ExpectError - - Complex128Array.from( true, clbk, {} ); // $ExpectError - Complex128Array.from( false, clbk, {} ); // $ExpectError - Complex128Array.from( 123, clbk, {} ); // $ExpectError - Complex128Array.from( null, clbk, {} ); // $ExpectError - Complex128Array.from( {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `from` method is provided a second argument which is not a function with a supported signature... -{ - Complex128Array.from( [ 1, 1 ], true ); // $ExpectError - Complex128Array.from( [ 1, 1 ], false ); // $ExpectError - Complex128Array.from( [ 1, 1 ], 123 ); // $ExpectError - Complex128Array.from( [ 1, 1 ], null ); // $ExpectError - Complex128Array.from( [ 1, 1 ], {} ); // $ExpectError -} - -// The `of` method returns a complex number array... -{ - Complex128Array.of( 1.0, 1.0, 1.0, 1.0 ); // $ExpectType Complex128Array -} - -// The compiler throws an error if the `of` method is provided arguments that are not numbers... -{ - Complex128Array.of( 'abc', 'def' ); // $ExpectError - Complex128Array.of( true, false ); // $ExpectError - Complex128Array.of( {}, [] ); // $ExpectError - Complex128Array.of( null, null ); // $ExpectError -} diff --git a/complex128/examples/index.js b/complex128/examples/index.js deleted file mode 100644 index 82e0b18c0..000000000 --- a/complex128/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Float64Array = require( './../../float64' ); -var logEach = require( '@stdlib/console/log-each' ); -var Complex128Array = require( './../lib' ); - -// Create a complex array by specifying a length: -var out = new Complex128Array( 3 ); -logEach( '%s', out ); - -// Create a complex array from an array of complex numbers: -var arr = [ - new Complex128( 1.0, -1.0 ), - new Complex128( -3.14, 3.14 ), - new Complex128( 0.5, 0.5 ) -]; -out = new Complex128Array( arr ); -logEach( '%s', out ); - -// Create a complex array from an interleaved typed array: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex128Array( arr ); -logEach( '%s', out ); - -// Create a complex array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex128Array( arr.buffer ); -logEach( '%s', out ); - -// Create a complex array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex128Array( arr.buffer, 16, 2 ); -logEach( '%s', out ); diff --git a/complex128/lib/from_array.js b/complex128/lib/from_array.js deleted file mode 100644 index 6e0f464cb..000000000 --- a/complex128/lib/from_array.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 isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - - -// MAIN // - -/** -* Returns a strided array of real and imaginary components. -* -* @private -* @param {Float64Array} buf - output array -* @param {Array} arr - array containing complex numbers -* @returns {(Float64Array|null)} output array or null -*/ -function fromArray( buf, arr ) { - var len; - var v; - var i; - var j; - - len = arr.length; - j = 0; - for ( i = 0; i < len; i++ ) { - v = arr[ i ]; - if ( !isComplexLike( v ) ) { - return null; - } - buf[ j ] = real( v ); - buf[ j+1 ] = imag( v ); - j += 2; // stride - } - return buf; -} - - -// EXPORTS // - -module.exports = fromArray; diff --git a/complex128/lib/from_iterator.js b/complex128/lib/from_iterator.js deleted file mode 100644 index 637ee6c00..000000000 --- a/complex128/lib/from_iterator.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var format = require( '@stdlib/string/format' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {(Array|TypeError)} array or an error -*/ -function fromIterator( it ) { - var out; - var v; - var z; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - z = v.value; - if ( isArrayLikeObject( z ) && z.length >= 2 ) { - out.push( z[ 0 ], z[ 1 ] ); - } else if ( isComplexLike( z ) ) { - out.push( real( z ), imag( z ) ); - } else { - return new TypeError( format( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/complex128/lib/from_iterator_map.js b/complex128/lib/from_iterator_map.js deleted file mode 100644 index f9482273e..000000000 --- a/complex128/lib/from_iterator_map.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var format = require( '@stdlib/string/format' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {(Array|TypeError)} array or an error -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var z; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - z = clbk.call( thisArg, v.value, i ); - if ( isArrayLikeObject( z ) && z.length >= 2 ) { - out.push( z[ 0 ], z[ 1 ] ); - } else if ( isComplexLike( z ) ) { - out.push( real( z ), imag( z ) ); - } else { - return new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/complex128/lib/index.js b/complex128/lib/index.js deleted file mode 100644 index 90dee3a46..000000000 --- a/complex128/lib/index.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 128-bit complex number array. -* -* @module @stdlib/array/complex128 -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var arr = new Complex128Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var arr = new Complex128Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var arr = new Complex128Array( [ 1.0, -1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Complex128Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Complex128Array( buf, 16 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var buf = new ArrayBuffer( 64 ); -* var arr = new Complex128Array( buf, 16, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/complex128/lib/main.js b/complex128/lib/main.js deleted file mode 100644 index 609a8ee28..000000000 --- a/complex128/lib/main.js +++ /dev/null @@ -1,3037 +0,0 @@ -/* eslint-disable no-restricted-syntax, max-lines, no-invalid-this */ - -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isObject = require( '@stdlib/assert/is-object' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var isString = require( '@stdlib/assert/is-string' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var isEven = require( '@stdlib/math/base/assert/is-even' ); -var isInteger = require( '@stdlib/math/base/assert/is-integer' ); -var isComplex64Array = require( './../../base/assert/is-complex64array' ); -var isComplex128Array = require( './../../base/assert/is-complex128array' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); -var Float64Array = require( './../../float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var getter = require( './../../base/getter' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var format = require( '@stdlib/string/format' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); -var fromArray = require( './from_array.js' ); - - -// VARIABLES // - -var BYTES_PER_ELEMENT = Float64Array.BYTES_PER_ELEMENT * 2; -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating if a value is a complex typed array. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a complex typed array -*/ -function isComplexArray( value ) { - return ( - value instanceof Complex128Array || - ( - typeof value === 'object' && - value !== null && - ( - value.constructor.name === 'Complex64Array' || - value.constructor.name === 'Complex128Array' - ) && - typeof value._length === 'number' && // eslint-disable-line no-underscore-dangle - - // NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks... - typeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle - ) - ); -} - -/** -* Returns a boolean indicating if a value is a complex typed array constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a complex typed array constructor -*/ -function isComplexArrayConstructor( value ) { - return ( - value === Complex128Array || - - // NOTE: weaker test in order to avoid a circular dependency with Complex64Array... - value.name === 'Complex64Array' - ); -} - -/** -* Retrieves a complex number from a complex number array buffer. -* -* @private -* @param {Float64Array} buf - array buffer -* @param {NonNegativeInteger} idx - element index -* @returns {Complex128} complex number -*/ -function getComplex128( buf, idx ) { - idx *= 2; - return new Complex128( buf[ idx ], buf[ idx+1 ] ); -} - - -// MAIN // - -/** -* 128-bit complex number array constructor. -* -* @constructor -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {RangeError} ArrayBuffer byte length must be a multiple of `16` -* @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two -* @throws {TypeError} if provided only a single argument, must provide a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} byte offset must be a multiple of `16` -* @throws {TypeError} view length must be a positive multiple of `16` -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number -* @returns {Complex128Array} complex number array -* -* @example -* var arr = new Complex128Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Complex128Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Complex128Array( [ 1.0, -1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Complex128Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Complex128Array( buf, 16 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 64 ); -* var arr = new Complex128Array( buf, 16, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function Complex128Array() { - var byteOffset; - var nargs; - var buf; - var len; - - nargs = arguments.length; - if ( !(this instanceof Complex128Array) ) { - if ( nargs === 0 ) { - return new Complex128Array(); - } - if ( nargs === 1 ) { - return new Complex128Array( arguments[0] ); - } - if ( nargs === 2 ) { - return new Complex128Array( arguments[0], arguments[1] ); - } - return new Complex128Array( arguments[0], arguments[1], arguments[2] ); - } - // Create the underlying data buffer... - if ( nargs === 0 ) { - buf = new Float64Array( 0 ); // backward-compatibility - } else if ( nargs === 1 ) { - if ( isNonNegativeInteger( arguments[0] ) ) { - buf = new Float64Array( arguments[0]*2 ); - } else if ( isCollection( arguments[0] ) ) { - buf = arguments[ 0 ]; - len = buf.length; - - // If provided a "generic" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to "normal" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number... - if ( len && isArray( buf ) && isComplexLike( buf[0] ) ) { - buf = fromArray( new Float64Array( len*2 ), buf ); - if ( buf === null ) { - // We failed and we are now forced to allocate a new array :-( - if ( !isEven( len ) ) { - throw new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', len ) ); - } - // We failed, so fall back to directly setting values... - buf = new Float64Array( arguments[0] ); - } - } else { - if ( isComplex64Array( buf ) ) { - buf = reinterpret64( buf, 0 ); - } else if ( isComplex128Array( buf ) ) { - buf = reinterpret128( buf, 0 ); - } else if ( !isEven( len ) ) { - throw new RangeError( format( 'invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.', len ) ); - } - buf = new Float64Array( buf ); - } - } else if ( isArrayBuffer( arguments[0] ) ) { - buf = arguments[ 0 ]; - if ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) ); - } - buf = new Float64Array( buf ); - } else if ( isObject( arguments[0] ) ) { - buf = arguments[ 0 ]; - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', buf ) ); - } - if ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); - } - buf = buf[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); - } - buf = fromIterator( buf ); - if ( buf instanceof Error ) { - throw buf; - } - buf = new Float64Array( buf ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arguments[0] ) ); - } - } else { - buf = arguments[ 0 ]; - if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) ); - } - byteOffset = arguments[ 1 ]; - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); - } - if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) ); - } - if ( nargs === 2 ) { - len = buf.byteLength - byteOffset; - if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) ); - } - buf = new Float64Array( buf, byteOffset ); - } else { - len = arguments[ 2 ]; - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); - } - if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) ); - } - buf = new Float64Array( buf, byteOffset, len*2 ); - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_length', buf.length/2 ); - - return this; -} - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128Array -* @readonly -* @type {PositiveInteger} -* @default 16 -* -* @example -* var nbytes = Complex128Array.BYTES_PER_ELEMENT; -* // returns 16 -*/ -setReadOnly( Complex128Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - -/** -* Constructor name. -* -* @name name -* @memberof Complex128Array -* @readonly -* @type {string} -* @default 'Complex128Array' -* -* @example -* var name = Complex128Array.name; -* // returns 'Complex128Array' -*/ -setReadOnly( Complex128Array, 'name', 'Complex128Array' ); - -/** -* Creates a new 128-bit complex number array from an array-like object or an iterable. -* -* @name from -* @memberof Complex128Array -* @type {Function} -* @param {(Collection|Object)} src - array-like object or iterable -* @param {Function} [clbk] - callback to invoke for each source element -* @param {*} [thisArg] - context -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be an array-like object or an iterable -* @throws {TypeError} second argument must be a function -* @throws {RangeError} array-like objects must have a length which is a multiple of two -* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number -* @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number -* @returns {Complex128Array} 128-bit complex number array -* -* @example -* var arr = Complex128Array.from( [ 1.0, -1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* function clbk( v ) { -* return new Complex128( real(v)*2.0, imag(v)*2.0 ); -* } -* -* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk ); -* // returns -* -* var len = arr.length; -* // returns 1 -*/ -setReadOnly( Complex128Array, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var get; - var len; - var flg; - var v; - var i; - var j; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isComplexArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isComplexArray( src ) ) { - len = src.length; - if ( clbk ) { - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - j = 0; - for ( i = 0; i < len; i++ ) { - v = clbk.call( thisArg, src.get( i ), i ); - if ( isComplexLike( v ) ) { - buf[ j ] = real( v ); - buf[ j+1 ] = imag( v ); - } else if ( isArrayLikeObject( v ) && v.length >= 2 ) { - buf[ j ] = v[ 0 ]; - buf[ j+1 ] = v[ 1 ]; - } else { - throw new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) ); - } - j += 2; // stride - } - return out; - } - return new this( src ); - } - if ( isCollection( src ) ) { - if ( clbk ) { - // Note: array contents affect how we iterate over a provided data source. If only complex number objects, we can extract real and imaginary components. Otherwise, for non-complex number arrays (e.g., `Float64Array`, etc), we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component. - - len = src.length; - if ( src.get && src.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - // Detect whether we've been provided an array which returns complex number objects... - for ( i = 0; i < len; i++ ) { - if ( !isComplexLike( get( src, i ) ) ) { - flg = true; - break; - } - } - // If an array does not contain only complex number objects, then we assume interleaved real and imaginary components... - if ( flg ) { - if ( !isEven( len ) ) { - throw new RangeError( format( 'invalid argument. First argument must have a length which is a multiple of two. Length: `%u`.', len ) ); - } - out = new this( len/2 ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = clbk.call( thisArg, get( src, i ), i ); - } - return out; - } - // If an array contains only complex number objects, then we need to extract real and imaginary components... - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - j = 0; - for ( i = 0; i < len; i++ ) { - v = clbk.call( thisArg, get( src, i ), i ); - if ( isComplexLike( v ) ) { - buf[ j ] = real( v ); - buf[ j+1 ] = imag( v ); - } else if ( isArrayLikeObject( v ) && v.length >= 2 ) { - buf[ j ] = v[ 0 ]; - buf[ j+1 ] = v[ 1 ]; - } else { - throw new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) ); - } - j += 2; // stride - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - if ( tmp instanceof Error ) { - throw tmp; - } - len = tmp.length / 2; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = tmp[ i ]; - } - return out; - } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); -}); - -/** -* Creates a new 128-bit complex number array from a variable number of arguments. -* -* @name of -* @memberof Complex128Array -* @type {Function} -* @param {...*} element - array elements -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a complex number array -* @returns {Complex128Array} 128-bit complex number array -* -* @example -* var arr = Complex128Array.of( 1.0, 1.0, 1.0, 1.0 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -setReadOnly( Complex128Array, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isComplexArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); -}); - -/** -* Returns an array element with support for both nonnegative and negative integer indices. -* -* @name at -* @memberof Complex128Array.prototype -* @type {Function} -* @param {integer} idx - element index -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} must provide an integer -* @returns {(Complex128|void)} array element -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var arr = new Complex128Array( 10 ); -* -* var z = arr.at( 0 ); -* // returns -* -* var re = real( z ); -* // returns 0.0 -* -* var im = imag( z ); -* // returns 0.0 -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 9.0, -9.0 ], 9 ); -* -* z = arr.at( 0 ); -* // returns -* -* re = real( z ); -* // returns 1.0 -* -* im = imag( z ); -* // returns -1.0 -* -* z = arr.at( -1 ); -* // returns -* -* re = real( z ); -* // returns 9.0 -* -* im = imag( z ); -* // returns -9.0 -* -* z = arr.at( 100 ); -* // returns undefined -* -* z = arr.at( -100 ); -* // returns undefined -*/ -setReadOnly( Complex128Array.prototype, 'at', function at( idx ) { - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); - } - if ( idx < 0 ) { - idx += this._length; - } - if ( idx < 0 || idx >= this._length ) { - return; - } - return getComplex128( this._buffer, idx ); -}); - -/** -* Pointer to the underlying data buffer. -* -* @name buffer -* @memberof Complex128Array.prototype -* @readonly -* @type {ArrayBuffer} -* -* @example -* var arr = new Complex128Array( 10 ); -* -* var buf = arr.buffer; -* // returns -*/ -setReadOnlyAccessor( Complex128Array.prototype, 'buffer', function get() { - return this._buffer.buffer; -}); - -/** -* Size (in bytes) of the array. -* -* @name byteLength -* @memberof Complex128Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Complex128Array( 10 ); -* -* var byteLength = arr.byteLength; -* // returns 160 -*/ -setReadOnlyAccessor( Complex128Array.prototype, 'byteLength', function get() { - return this._buffer.byteLength; -}); - -/** -* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. -* -* @name byteOffset -* @memberof Complex128Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Complex128Array( 10 ); -* -* var byteOffset = arr.byteOffset; -* // returns 0 -*/ -setReadOnlyAccessor( Complex128Array.prototype, 'byteOffset', function get() { - return this._buffer.byteOffset; -}); - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex128Array.prototype -* @readonly -* @type {PositiveInteger} -* @default 16 -* -* @example -* var arr = new Complex128Array( 10 ); -* -* var nbytes = arr.BYTES_PER_ELEMENT; -* // returns 16 -*/ -setReadOnly( Complex128Array.prototype, 'BYTES_PER_ELEMENT', Complex128Array.BYTES_PER_ELEMENT ); - -/** -* Copies a sequence of elements within the array to the position starting at `target`. -* -* @name copyWithin -* @memberof Complex128Array.prototype -* @type {Function} -* @param {integer} target - index at which to start copying elements -* @param {integer} start - source index at which to copy elements from -* @param {integer} [end] - source index at which to stop copying elements from -* @throws {TypeError} `this` must be a complex number array -* @returns {Complex128Array} modified array -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var arr = new Complex128Array( 4 ); -* -* // Set the array elements: -* arr.set( new Complex128( 1.0, 1.0 ), 0 ); -* arr.set( new Complex128( 2.0, 2.0 ), 1 ); -* arr.set( new Complex128( 3.0, 3.0 ), 2 ); -* arr.set( new Complex128( 4.0, 4.0 ), 3 ); -* -* // Copy the first two elements to the last two elements: -* arr.copyWithin( 2, 0, 2 ); -* -* // Get the last array element: -* var z = arr.get( 3 ); -* -* var re = real( z ); -* // returns 2.0 -* -* var im = imag( z ); -* // returns 2.0 -*/ -setReadOnly( Complex128Array.prototype, 'copyWithin', function copyWithin( target, start ) { - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled - if ( arguments.length === 2 ) { - this._buffer.copyWithin( target*2, start*2 ); - } else { - this._buffer.copyWithin( target*2, start*2, arguments[2]*2 ); - } - return this; -}); - -/** -* Returns an iterator for iterating over array key-value pairs. -* -* @name entries -* @memberof Complex128Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {Iterator} iterator -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var arr = [ -* new Complex128( 1.0, 1.0 ), -* new Complex128( 2.0, 2.0 ), -* new Complex128( 3.0, 3.0 ) -* ]; -* arr = new Complex128Array( arr ); -* -* // Create an iterator: -* var it = arr.entries(); -* -* // Iterate over the key-value pairs... -* var v = it.next().value; -* // returns [ 0, ] -* -* v = it.next().value; -* // returns [ 1, ] -* -* v = it.next().value; -* // returns [ 2, ] -* -* var bool = it.next().done; -* // returns true -*/ -setReadOnly( Complex128Array.prototype, 'entries', function entries() { - var buffer; - var self; - var iter; - var len; - var FLG; - var i; - var j; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - self = this; - buffer = this._buffer; - len = this._length; - - // Initialize the iteration indices: - i = -1; - j = -2; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - var z; - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - j += 2; - z = new Complex128( buffer[ j ], buffer[ j+1 ] ); - return { - 'value': [ i, z ], - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.entries(); - } -}); - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @name every -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* function predicate( v ) { -* return ( real( v ) === imag( v ) ); -* } -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var bool = arr.every( predicate ); -* // returns true -*/ -setReadOnly( Complex128Array.prototype, 'every', function every( predicate, thisArg ) { - var buf; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( !predicate.call( thisArg, getComplex128( buf, i ), i, this ) ) { - return false; - } - } - return true; -}); - -/** -* Returns a modified typed array filled with a fill value. -* -* @name fill -* @memberof Complex128Array.prototype -* @type {Function} -* @param {ComplexLike} value - fill value -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a complex number -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be an integer -* @returns {Complex128Array} modified array -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var arr = new Complex128Array( 3 ); -* -* arr.fill( new Complex128( 1.0, 1.0 ), 1 ); -* -* var z = arr.get( 1 ); -* // returns -* -* var re = real( z ); -* // returns 1.0 -* -* var im = imag( z ); -* // returns 1.0 -* -* z = arr.get( 2 ); -* // returns -* -* re = real( z ); -* // returns 1.0 -* -* im = imag( z ); -* // returns 1.0 -*/ -setReadOnly( Complex128Array.prototype, 'fill', function fill( value, start, end ) { - var buf; - var len; - var idx; - var re; - var im; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isComplexLike( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', value ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); - } - if ( start < 0 ) { - start += len; - if ( start < 0 ) { - start = 0; - } - } - if ( arguments.length > 2 ) { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } - if ( end > len ) { - end = len; - } - } else { - end = len; - } - } else { - start = 0; - end = len; - } - re = real( value ); - im = imag( value ); - for ( i = start; i < end; i++ ) { - idx = 2*i; - buf[ idx ] = re; - buf[ idx+1 ] = im; - } - return this; -}); - -/** -* Returns a new array containing the elements of an array which pass a test implemented by a predicate function. -* -* @name filter -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {Complex128Array} complex number array -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* function predicate( v ) { -* return ( real( v ) === imag( v ) ); -* } -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* -* var out = arr.filter( predicate ); -* // returns -* -* var len = out.length; -* // returns 1 -* -* var z = out.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 2.0 -* -* var im = imag( z ); -* // returns 2.0 -*/ -setReadOnly( Complex128Array.prototype, 'filter', function filter( predicate, thisArg ) { - var buf; - var out; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - z = getComplex128( buf, i ); - if ( predicate.call( thisArg, z, i, this ) ) { - out.push( z ); - } - } - return new this.constructor( out ); -}); - -/** -* Returns the first element in an array for which a predicate function returns a truthy value. -* -* @name find -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {(Complex128|void)} array element or undefined -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* function predicate( v ) { -* return ( real( v ) === imag( v ) ); -* } -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var z = arr.find( predicate ); -* // returns -* -* var re = real( z ); -* // returns 1.0 -* -* var im = imag( z ); -* // returns 1.0 -*/ -setReadOnly( Complex128Array.prototype, 'find', function find( predicate, thisArg ) { - var buf; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - z = getComplex128( buf, i ); - if ( predicate.call( thisArg, z, i, this ) ) { - return z; - } - } -}); - -/** -* Returns the index of the first element in an array for which a predicate function returns a truthy value. -* -* @name findIndex -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* function predicate( v ) { -* return ( real( v ) === imag( v ) ); -* } -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var idx = arr.findIndex( predicate ); -* // returns 2 -*/ -setReadOnly( Complex128Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) { - var buf; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - z = getComplex128( buf, i ); - if ( predicate.call( thisArg, z, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Returns the last element in an array for which a predicate function returns a truthy value. -* -* @name findLast -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {(Complex128|void)} array element or undefined -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* function predicate( v ) { -* return ( real( v ) === imag( v ) ); -* } -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var z = arr.findLast( predicate ); -* // returns -* -* var re = real( z ); -* // returns 3.0 -* -* var im = imag( z ); -* // returns 3.0 -*/ -setReadOnly( Complex128Array.prototype, 'findLast', function findLast( predicate, thisArg ) { - var buf; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - z = getComplex128( buf, i ); - if ( predicate.call( thisArg, z, i, this ) ) { - return z; - } - } -}); - -/** -* Returns the index of the last element in an array for which a predicate function returns a truthy value. -* -* @name findLastIndex -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* function predicate( v ) { -* return ( real( v ) === imag( v ) ); -* } -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* -* var idx = arr.findLastIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Complex128Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) { - var buf; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - z = getComplex128( buf, i ); - if ( predicate.call( thisArg, z, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Invokes a function once for each array element. -* -* @name forEach -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} fcn - function to invoke -* @param {*} [thisArg] - function invocation context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* function log( v, i ) { -* console.log( '%s: %s', i, v.toString() ); -* } -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* arr.forEach( log ); -*/ -setReadOnly( Complex128Array.prototype, 'forEach', function forEach( fcn, thisArg ) { - var buf; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - z = getComplex128( buf, i ); - fcn.call( thisArg, z, i, this ); - } -}); - -/** -* Returns an array element. -* -* @name get -* @memberof Complex128Array.prototype -* @type {Function} -* @param {NonNegativeInteger} idx - element index -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} must provide a nonnegative integer -* @returns {(Complex128|void)} array element -* -* @example -* var arr = new Complex128Array( 10 ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var z = arr.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 0.0 -* -* var im = imag( z ); -* // returns 0.0 -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* -* z = arr.get( 0 ); -* // returns -* -* re = real( z ); -* // returns 1.0 -* -* im = imag( z ); -* // returns -1.0 -* -* z = arr.get( 100 ); -* // returns undefined -*/ -setReadOnly( Complex128Array.prototype, 'get', function get( idx ) { - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return getComplex128( this._buffer, idx ); -}); - -/** -* Number of array elements. -* -* @name length -* @memberof Complex128Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Complex128Array( 10 ); -* -* var len = arr.length; -* // returns 10 -*/ -setReadOnlyAccessor( Complex128Array.prototype, 'length', function get() { - return this._length; -}); - -/** -* Returns a boolean indicating whether an array includes a provided value. -* -* @name includes -* @memberof Complex128Array.prototype -* @type {Function} -* @param {ComplexLike} searchElement - search element -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a complex number -* @throws {TypeError} second argument must be an integer -* @returns {boolean} boolean indicating whether an array includes a provided value -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var arr = new Complex128Array( 5 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* arr.set( [ 4.0, -4.0 ], 3 ); -* arr.set( [ 5.0, -5.0 ], 4 ); -* -* var bool = arr.includes( new Complex128( 3.0, -3.0 ) ); -* // returns true -* -* bool = arr.includes( new Complex128( 3.0, -3.0 ), 3 ); -* // returns false -* -* bool = arr.includes( new Complex128( 4.0, -4.0 ), -3 ); -* // returns true -*/ -setReadOnly( Complex128Array.prototype, 'includes', function includes( searchElement, fromIndex ) { - var buf; - var idx; - var re; - var im; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isComplexLike( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - re = real( searchElement ); - im = imag( searchElement ); - buf = this._buffer; - for ( i = fromIndex; i < this._length; i++ ) { - idx = 2 * i; - if ( re === buf[ idx ] && im === buf[ idx+1 ] ) { - return true; - } - } - return false; -}); - -/** -* Returns the first index at which a given element can be found. -* -* @name indexOf -* @memberof Complex128Array.prototype -* @type {Function} -* @param {ComplexLike} searchElement - element to find -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a complex number -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var arr = new Complex128Array( 5 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* arr.set( [ 4.0, -4.0 ], 3 ); -* arr.set( [ 5.0, -5.0 ], 4 ); -* -* var idx = arr.indexOf( new Complex128( 3.0, -3.0 ) ); -* // returns 2 -* -* idx = arr.indexOf( new Complex128( 3.0, -3.0 ), 3 ); -* // returns -1 -* -* idx = arr.indexOf( new Complex128( 4.0, -4.0 ), -3 ); -* // returns 3 -*/ -setReadOnly( Complex128Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { - var buf; - var idx; - var re; - var im; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isComplexLike( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - re = real( searchElement ); - im = imag( searchElement ); - buf = this._buffer; - for ( i = fromIndex; i < this._length; i++ ) { - idx = 2 * i; - if ( re === buf[ idx ] && im === buf[ idx+1 ] ) { - return i; - } - } - return -1; -}); - -/** -* Returns a new string by concatenating all array elements. -* -* @name join -* @memberof Complex128Array.prototype -* @type {Function} -* @param {string} [separator=','] - element separator -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a string -* @returns {string} string representation -* -* @example -* var arr = new Complex128Array( 2 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* -* var str = arr.join(); -* // returns '1 + 1i,2 + 2i' -* -* str = arr.join( '/' ); -* // returns '1 + 1i/2 + 2i' -*/ -setReadOnly( Complex128Array.prototype, 'join', function join( separator ) { - var out; - var buf; - var sep; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( arguments.length === 0 ) { - sep = ','; - } else if ( isString( separator ) ) { - sep = separator; - } else { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); - } - out = []; - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - out.push( getComplex128( buf, i ).toString() ); - } - return out.join( sep ); -}); - -/** -* Returns an iterator for iterating over each index key in a typed array. -* -* @name keys -* @memberof Complex128Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Complex128Array( 2 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* -* var iter = arr.keys(); -* -* var v = iter.next().value; -* // returns 0 -* -* v = iter.next().value; -* // returns 1 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Complex128Array.prototype, 'keys', function keys() { - var self; - var iter; - var len; - var FLG; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - self = this; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': i, - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.keys(); - } -}); - -/** -* Returns the last index at which a given element can be found. -* -* @name lastIndexOf -* @memberof Complex128Array.prototype -* @type {Function} -* @param {ComplexLike} searchElement - element to find -* @param {integer} [fromIndex] - index at which to start searching backward (inclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a complex number -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var arr = new Complex128Array( 5 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* arr.set( [ 4.0, -4.0 ], 3 ); -* arr.set( [ 3.0, -3.0 ], 4 ); -* -* var idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ) ); -* // returns 4 -* -* idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ), 3 ); -* // returns 2 -* -* idx = arr.lastIndexOf( new Complex128( 5.0, -5.0 ), 3 ); -* // returns -1 -* -* idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), -3 ); -* // returns 1 -*/ -setReadOnly( Complex128Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { - var buf; - var idx; - var re; - var im; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isComplexLike( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex >= this._length ) { - fromIndex = this._length - 1; - } else if ( fromIndex < 0 ) { - fromIndex += this._length; - } - } else { - fromIndex = this._length - 1; - } - re = real( searchElement ); - im = imag( searchElement ); - buf = this._buffer; - for ( i = fromIndex; i >= 0; i-- ) { - idx = 2 * i; - if ( re === buf[ idx ] && im === buf[ idx+1 ] ) { - return i; - } - } - return -1; -}); - -/** -* Returns a new array with each element being the result of a provided callback function. -* -* @name map -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {Complex128Array} complex number array -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* function scale( v, i ) { -* return new Complex128( 2.0*real( v ), 2.0*imag( v ) ); -* } -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* -* var out = arr.map( scale ); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 2.0 -* -* var im = imag( z ); -* // returns -2.0 -*/ -setReadOnly( Complex128Array.prototype, 'map', function map( fcn, thisArg ) { - var outbuf; - var buf; - var out; - var i; - var v; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - buf = this._buffer; - out = new this.constructor( this._length ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < this._length; i++ ) { - v = fcn.call( thisArg, getComplex128( buf, i ), i, this ); - if ( isComplexLike( v ) ) { - outbuf[ 2*i ] = real( v ); - outbuf[ (2*i)+1 ] = imag( v ); - } else if ( isArrayLikeObject( v ) && v.length === 2 ) { - outbuf[ 2*i ] = v[ 0 ]; - outbuf[ (2*i)+1 ] = v[ 1 ]; - } else { - throw new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) ); - } - } - return out; -}); - -/** -* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduce -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* var cadd = require( '@stdlib/complex/float64/base/add' ); -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var z = arr.reduce( cadd ); -* // returns -* -* var re = real( z ); -* // returns 6.0 -* -* var im = imag( z ); -* // returns 6.0 -*/ -setReadOnly( Complex128Array.prototype, 'reduce', function reduce( reducer, initialValue ) { - var buf; - var acc; - var len; - var v; - var i; - - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = 0; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = getComplex128( buf, 0 ); - i = 1; - } - for ( ; i < len; i++ ) { - v = getComplex128( buf, i ); - acc = reducer( acc, v, i, this ); - } - return acc; -}); - -/** -* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduceRight -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* var cadd = require( '@stdlib/complex/float64/base/add' ); -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var z = arr.reduceRight( cadd ); -* // returns -* -* var re = real( z ); -* // returns 6.0 -* -* var im = imag( z ); -* // returns 6.0 -*/ -setReadOnly( Complex128Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) { - var buf; - var acc; - var len; - var v; - var i; - - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = len-1; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = getComplex128( buf, len-1 ); - i = len-2; - } - for ( ; i >= 0; i-- ) { - v = getComplex128( buf, i ); - acc = reducer( acc, v, i, this ); - } - return acc; -}); - -/** -* Reverses an array in-place. -* -* @name reverse -* @memberof Complex128Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {Complex128Array} reversed array -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var out = arr.reverse(); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 3.0 -* -* var im = imag( z ); -* // returns 3.0 -* -* z = out.get( 1 ); -* // returns -* -* re = real( z ); -* // returns 2.0 -* -* im = imag( z ); -* // returns 2.0 -* -* z = out.get( 2 ); -* // returns -* -* re = real( z ); -* // returns 1.0 -* -* im = imag( z ); -* // returns 1.0 -*/ -setReadOnly( Complex128Array.prototype, 'reverse', function reverse() { - var buf; - var tmp; - var len; - var N; - var i; - var j; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - len = this._length; - buf = this._buffer; - N = floor( len / 2 ); - for ( i = 0; i < N; i++ ) { - j = len - i - 1; - tmp = buf[ (2*i) ]; - buf[ (2*i) ] = buf[ (2*j) ]; - buf[ (2*j) ] = tmp; - tmp = buf[ (2*i)+1 ]; - buf[ (2*i)+1 ] = buf[ (2*j)+1 ]; - buf[ (2*j)+1 ] = tmp; - } - return this; -}); - -/** -* Sets an array element. -* -* ## Notes -* -* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. -* -* In the other overlapping scenario, -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended. -* -* @name set -* @memberof Complex128Array.prototype -* @type {Function} -* @param {(Collection|Complex|ComplexArray)} value - value(s) -* @param {NonNegativeInteger} [i=0] - element index at which to start writing values -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array -* @throws {TypeError} index argument must be a nonnegative integer -* @throws {RangeError} array-like objects must have a length which is a multiple of two -* @throws {RangeError} index argument is out-of-bounds -* @throws {RangeError} target array lacks sufficient storage to accommodate source values -* @returns {void} -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var arr = new Complex128Array( 10 ); -* -* var z = arr.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 0.0 -* -* var im = imag( z ); -* // returns 0.0 -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* -* z = arr.get( 0 ); -* // returns -* -* re = real( z ); -* // returns 1.0 -* -* im = imag( z ); -* // returns -1.0 -*/ -setReadOnly( Complex128Array.prototype, 'set', function set( value ) { - /* eslint-disable no-underscore-dangle */ - var sbuf; - var idx; - var buf; - var tmp; - var flg; - var N; - var v; - var i; - var j; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - buf = this._buffer; - if ( arguments.length > 1 ) { - idx = arguments[ 1 ]; - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); - } - } else { - idx = 0; - } - if ( isComplexLike( value ) ) { - if ( idx >= this._length ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) ); - } - idx *= 2; - buf[ idx ] = real( value ); - buf[ idx+1 ] = imag( value ); - return; - } - if ( isComplexArray( value ) ) { - N = value._length; - if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); - } - sbuf = value._buffer; - - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = new Float64Array( sbuf.length ); - for ( i = 0; i < sbuf.length; i++ ) { - tmp[ i ] = sbuf[ i ]; - } - sbuf = tmp; - } - idx *= 2; - j = 0; - for ( i = 0; i < N; i++ ) { - buf[ idx ] = sbuf[ j ]; - buf[ idx+1 ] = sbuf[ j+1 ]; - idx += 2; // stride - j += 2; // stride - } - return; - } - if ( isCollection( value ) ) { - // Detect whether we've been provided an array of complex numbers... - N = value.length; - for ( i = 0; i < N; i++ ) { - if ( !isComplexLike( value[ i ] ) ) { - flg = true; - break; - } - } - // If an array does not contain only complex numbers, then we assume interleaved real and imaginary components... - if ( flg ) { - if ( !isEven( N ) ) { - throw new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', N ) ); - } - if ( idx+(N/2) > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); - } - sbuf = value; - - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = new Float64Array( N ); - for ( i = 0; i < N; i++ ) { - tmp[ i ] = sbuf[ i ]; - } - sbuf = tmp; - } - idx *= 2; - N /= 2; - j = 0; - for ( i = 0; i < N; i++ ) { - buf[ idx ] = sbuf[ j ]; - buf[ idx+1 ] = sbuf[ j+1 ]; - idx += 2; // stride - j += 2; // stride - } - return; - } - // If an array contains only complex numbers, then we need to extract real and imaginary components... - if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); - } - idx *= 2; - for ( i = 0; i < N; i++ ) { - v = value[ i ]; - buf[ idx ] = real( v ); - buf[ idx+1 ] = imag( v ); - idx += 2; // stride - } - return; - } - throw new TypeError( format( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.', value ) ); - - /* eslint-enable no-underscore-dangle */ -}); - -/** -* Copies a portion of a typed array to a new typed array. -* -* @name slice -* @memberof Complex128Array.prototype -* @type {Function} -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be an integer -* @throws {TypeError} second argument must be an integer -* @returns {Complex128Array} complex number array -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var arr = new Complex128Array( 5 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* arr.set( [ 4.0, -4.0 ], 3 ); -* arr.set( [ 5.0, -5.0 ], 4 ); -* -* var out = arr.slice(); -* // returns -* -* var len = out.length; -* // returns 5 -* -* var z = out.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 1.0 -* -* var im = imag( z ); -* // returns -1.0 -* -* z = out.get( len-1 ); -* // returns -* -* re = real( z ); -* // returns 5.0 -* -* im = imag( z ); -* // returns -5.0 -* -* out = arr.slice( 1, -2 ); -* // returns -* -* len = out.length; -* // returns 2 -* -* z = out.get( 0 ); -* // returns -* -* re = real( z ); -* // returns 2.0 -* -* im = imag( z ); -* // returns -2.0 -* -* z = out.get( len-1 ); -* // returns -* -* re = real( z ); -* // returns 3.0 -* -* im = imag( z ); -* // returns -3.0 -*/ -setReadOnly( Complex128Array.prototype, 'slice', function slice( start, end ) { - var outlen; - var outbuf; - var out; - var idx; - var buf; - var len; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - start = 0; - end = len; - } else { - if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', start ) ); - } - if ( start < 0 ) { - start += len; - if ( start < 0 ) { - start = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( start < end ) { - outlen = end - start; - } else { - outlen = 0; - } - out = new this.constructor( outlen ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < outlen; i++ ) { - idx = 2*(i+start); - outbuf[ 2*i ] = buf[ idx ]; - outbuf[ (2*i)+1 ] = buf[ idx+1 ]; - } - return out; -}); - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @name some -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* function predicate( v ) { -* return ( real( v ) === imag( v ) ); -* } -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* -* var bool = arr.some( predicate ); -* // returns true -*/ -setReadOnly( Complex128Array.prototype, 'some', function some( predicate, thisArg ) { - var buf; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( predicate.call( thisArg, getComplex128( buf, i ), i, this ) ) { - return true; - } - } - return false; -}); - -/** -* Sorts an array in-place. -* -* @name sort -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} compareFcn - comparison function -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {Complex128Array} sorted array -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* function compare( a, b ) { -* var re1; -* var re2; -* var im1; -* var im2; -* re1 = real( a ); -* re2 = real( b ); -* if ( re1 < re2 ) { -* return -1; -* } -* if ( re1 > re2 ) { -* return 1; -* } -* im1 = imag( a ); -* im2 = imag( b ); -* if ( im1 < im2 ) { -* return -1; -* } -* if ( im1 > im2 ) { -* return 1; -* } -* return 0; -* } -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 3.0, -3.0 ], 0 ); -* arr.set( [ 1.0, -1.0 ], 1 ); -* arr.set( [ 2.0, -2.0 ], 2 ); -* -* var out = arr.sort( compare ); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 1.0 -* -* var im = imag( z ); -* // returns -1.0 -* -* z = out.get( 1 ); -* // returns -* -* re = real( z ); -* // returns 2.0 -* -* im = imag( z ); -* // returns -2.0 -* -* z = out.get( 2 ); -* // returns -* -* re = real( z ); -* // returns 3.0 -* -* im = imag( z ); -* // returns -3.0 -*/ -setReadOnly( Complex128Array.prototype, 'sort', function sort( compareFcn ) { - var tmp; - var buf; - var len; - var i; - var j; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); - } - buf = this._buffer; - len = this._length; - tmp = []; - for ( i = 0; i < len; i++ ) { - tmp.push( getComplex128( buf, i ) ); - } - tmp.sort( compareFcn ); - for ( i = 0; i < len; i++ ) { - j = 2 * i; - buf[ j ] = real( tmp[i] ); - buf[ j+1 ] = imag( tmp[i] ); - } - return this; -}); - -/** -* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. -* -* @name subarray -* @memberof Complex128Array.prototype -* @type {Function} -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be an integer -* @throws {TypeError} second argument must be an integer -* @returns {Complex64Array} subarray -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var arr = new Complex128Array( 5 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* arr.set( [ 4.0, -4.0 ], 3 ); -* arr.set( [ 5.0, -5.0 ], 4 ); -* -* var subarr = arr.subarray(); -* // returns -* -* var len = subarr.length; -* // returns 5 -* -* var z = subarr.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 1.0 -* -* var im = imag( z ); -* // returns -1.0 -* -* z = subarr.get( len-1 ); -* // returns -* -* re = real( z ); -* // returns 5.0 -* -* im = imag( z ); -* // returns -5.0 -* -* subarr = arr.subarray( 1, -2 ); -* // returns -* -* len = subarr.length; -* // returns 2 -* -* z = subarr.get( 0 ); -* // returns -* -* re = real( z ); -* // returns 2.0 -* -* im = imag( z ); -* // returns -2.0 -* -* z = subarr.get( len-1 ); -* // returns -* -* re = real( z ); -* // returns 3.0 -* -* im = imag( z ); -* // returns -3.0 -*/ -setReadOnly( Complex128Array.prototype, 'subarray', function subarray( begin, end ) { - var offset; - var buf; - var len; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin >= len ) { - len = 0; - offset = buf.byteLength; - } else if ( begin >= end ) { - len = 0; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } else { - len = end - begin; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } - return new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len ); -}); - -/** -* Serializes an array as a locale-specific string. -* -* @name toLocaleString -* @memberof Complex128Array.prototype -* @type {Function} -* @param {(string|Array)} [locales] - locale identifier(s) -* @param {Object} [options] - configuration options -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a string or an array of strings -* @throws {TypeError} options argument must be an object -* @returns {string} string representation -* -* @example -* var arr = new Complex128Array( 2 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* -* var str = arr.toLocaleString(); -* // returns '1 + 1i,2 + 2i' -*/ -setReadOnly( Complex128Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) { - var opts; - var loc; - var out; - var buf; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( arguments.length === 0 ) { - loc = []; - } else if ( isString( locales ) || isStringArray( locales ) ) { - loc = locales; - } else { - throw new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) ); - } - if ( arguments.length < 2 ) { - opts = {}; - } else if ( isObject( options ) ) { - opts = options; - } else { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( getComplex128( buf, i ).toLocaleString( loc, opts ) ); - } - return out.join( ',' ); -}); - -/** -* Returns a new typed array containing the elements in reversed order. -* -* @name toReversed -* @memberof Complex128Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {Complex128Array} reversed array -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var out = arr.toReversed(); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 3.0 -* -* var im = imag( z ); -* // returns 3.0 -* -* z = out.get( 1 ); -* // returns -* -* re = real( z ); -* // returns 2.0 -* -* im = imag( z ); -* // returns 2.0 -* -* z = out.get( 2 ); -* // returns -* -* re = real( z ); -* // returns 1.0 -* -* im = imag( z ); -* // returns 1.0 -*/ -setReadOnly( Complex128Array.prototype, 'toReversed', function toReversed() { - var outbuf; - var out; - var len; - var buf; - var i; - var j; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - len = this._length; - out = new this.constructor( len ); - buf = this._buffer; - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - j = len - i - 1; - outbuf[ (2*i) ] = buf[ (2*j) ]; - outbuf[ (2*i)+1 ] = buf[ (2*j)+1 ]; - } - return out; -}); - -/** -* Returns a new typed array containing the elements in sorted order. -* -* @name toSorted -* @memberof Complex128Array.prototype -* @type {Function} -* @param {Function} compareFcn - comparison function -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {Complex128Array} sorted array -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* -* function compare( a, b ) { -* var re1; -* var re2; -* var im1; -* var im2; -* re1 = real( a ); -* re2 = real( b ); -* if ( re1 < re2 ) { -* return -1; -* } -* if ( re1 > re2 ) { -* return 1; -* } -* im1 = imag( a ); -* im2 = imag( b ); -* if ( im1 < im2 ) { -* return -1; -* } -* if ( im1 > im2 ) { -* return 1; -* } -* return 0; -* } -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 3.0, -3.0 ], 0 ); -* arr.set( [ 1.0, -1.0 ], 1 ); -* arr.set( [ 2.0, -2.0 ], 2 ); -* -* var out = arr.sort( compare ); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 1.0 -* -* var im = imag( z ); -* // returns -1.0 -* -* z = out.get( 1 ); -* // returns -* -* re = real( z ); -* // returns 2.0 -* -* im = imag( z ); -* // returns -2.0 -* -* z = out.get( 2 ); -* // returns -* -* re = real( z ); -* // returns 3.0 -* -* im = imag( z ); -* // returns -3.0 -*/ -setReadOnly( Complex128Array.prototype, 'toSorted', function toSorted( compareFcn ) { - var tmp; - var buf; - var len; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); - } - buf = this._buffer; - len = this._length; - tmp = []; - for ( i = 0; i < len; i++ ) { - tmp.push( getComplex128( buf, i ) ); - } - tmp.sort( compareFcn ); - return new Complex128Array( tmp ); -}); - -/** -* Serializes an array as a string. -* -* @name toString -* @memberof Complex128Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {string} string representation -* -* @example -* var arr = new Complex128Array( 2 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* -* var str = arr.toString(); -* // returns '1 + 1i,2 + 2i' -*/ -setReadOnly( Complex128Array.prototype, 'toString', function toString() { - var out; - var buf; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - out = []; - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - out.push( getComplex128( buf, i ).toString() ); - } - return out.join( ',' ); -}); - -/** -* Returns an iterator for iterating over each value in a typed array. -* -* @name values -* @memberof Complex128Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {Iterator} iterator -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* var arr = new Complex128Array( 2 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* -* var iter = arr.values(); -* -* var v = iter.next().value; -* // returns -* -* var re = real( v ); -* // returns 1.0 -* -* var im = imag( v ); -* // returns -1.0 -* -* v = iter.next().value; -* // returns -* -* re = real( v ); -* // returns 2.0 -* -* im = imag( v ); -* // returns -2.0 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Complex128Array.prototype, 'values', function values() { - var iter; - var self; - var len; - var FLG; - var buf; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': getComplex128( buf, i ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.values(); - } -}); - -/** -* Returns a new typed array with the element at a provided index replaced with a provided value. -* -* @name with -* @memberof Complex128Array.prototype -* @type {Function} -* @param {integer} index - element index -* @param {ComplexLike} value - new value -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be an integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {TypeError} second argument must be a complex number -* @returns {Complex128Array} new typed array -* -* @example -* var real = require( '@stdlib/complex/float64/real' ); -* var imag = require( '@stdlib/complex/float64/imag' ); -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var arr = new Complex128Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var out = arr.with( 0, new Complex128( 4.0, 4.0 ) ); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = real( z ); -* // returns 4.0 -* -* var im = imag( z ); -* // returns 4.0 -*/ -setReadOnly( Complex128Array.prototype, 'with', function copyWith( index, value ) { - var buf; - var out; - var len; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isInteger( index ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); - } - len = this._length; - if ( index < 0 ) { - index += len; - } - if ( index < 0 || index >= len ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); - } - if ( !isComplexLike( value ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a complex number. Value: `%s`.', value ) ); - } - out = new this.constructor( this._buffer ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - buf[ 2*index ] = real( value ); - buf[ (2*index)+1 ] = imag( value ); - return out; -}); - - -// EXPORTS // - -module.exports = Complex128Array; diff --git a/complex128/package.json b/complex128/package.json deleted file mode 100644 index cbde2f21f..000000000 --- a/complex128/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/complex128", - "version": "0.0.0", - "description": "Complex128Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "complex128array", - "complex128", - "complex", - "cmplx", - "real", - "imaginary", - "imag", - "double", - "float64", - "double-precision", - "ieee754" - ] -} diff --git a/complex128/test/test.at.js b/complex128/test/test.at.js deleted file mode 100644 index b63499e06..000000000 --- a/complex128/test/test.at.js +++ /dev/null @@ -1,147 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'at' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.at.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.at( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Complex128Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex128( i, -i ) ); - } - arr = new Complex128Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( real( v ), arr.length + i, 'returns expected real component for index '+i ); - t.strictEqual( imag( v ), -arr.length - i, 'returns expected imaginary component for index '+i ); - } else { - t.strictEqual( real( v ), i, 'returns expected real component for index '+i ); - t.strictEqual( imag( v ), -i, 'returns expected imaginary component for index '+i ); - } - } - t.end(); -}); diff --git a/complex128/test/test.copy_within.js b/complex128/test/test.copy_within.js deleted file mode 100644 index d73149a4a..000000000 --- a/complex128/test/test.copy_within.js +++ /dev/null @@ -1,379 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ).isPrimitive; -var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ).isPrimitive; -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Float64Array = require( './../../float64' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a complex number array', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex128( 0.0, -0.0 ), - new Complex128( 1.0, -1.0 ), - new Complex128( 2.0, -2.0 ), - new Complex128( 3.0, -3.0 ), - new Complex128( 4.0, -4.0 ) - ]; - arr = new Complex128Array( arr ); - - arr.copyWithin( 0, 3 ); - - buf = new Float64Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); - t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); - t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); - t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); - t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); - t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); - t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); - t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex128( 0.0, -0.0 ), - new Complex128( 1.0, -1.0 ), - new Complex128( 2.0, -2.0 ), - new Complex128( 3.0, -3.0 ), - new Complex128( 4.0, -4.0 ) - ]; - arr = new Complex128Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - - buf = new Float64Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); - t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); - t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); - t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); - t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); - t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); - t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); - t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex128( 0.0, -0.0 ), - new Complex128( 1.0, -1.0 ), - new Complex128( 2.0, -2.0 ), - new Complex128( 3.0, -3.0 ), - new Complex128( 4.0, -4.0 ) - ]; - arr = new Complex128Array( arr ); - - arr.copyWithin( 0, -2 ); - - buf = new Float64Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); - t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); - t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); - t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); - t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); - t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); - t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); - t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex128( 0.0, -0.0 ), - new Complex128( 1.0, -1.0 ), - new Complex128( 2.0, -2.0 ), - new Complex128( 3.0, -3.0 ), - new Complex128( 4.0, -4.0 ) - ]; - arr = new Complex128Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - - buf = new Float64Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], 3.0, 'returns expected real for complex number 0' ); - t.strictEqual( buf[ 1 ], -3.0, 'returns expected imag for complex number 0' ); - t.strictEqual( buf[ 2 ], 4.0, 'returns expected real for complex number 1' ); - t.strictEqual( buf[ 3 ], -4.0, 'returns expected imag for complex number 1' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); - t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); - t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); - t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); - t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex128( 0.0, -0.0 ), - new Complex128( 1.0, -1.0 ), - new Complex128( 2.0, -2.0 ), - new Complex128( 3.0, -3.0 ), - new Complex128( 4.0, -4.0 ) - ]; - arr = new Complex128Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - - buf = new Float64Array( arr.buffer ); - - // Remain the same: - t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); - t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); - t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); - t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); - - // Overwritten: - t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected real for complex number 2' ); - t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected imag for complex number 2' ); - t.strictEqual( buf[ 6 ], 1.0, 'returns expected real for complex number 3' ); - t.strictEqual( buf[ 7 ], -1.0, 'returns expected imag for complex number 3' ); - - // Remain the same: - t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex128( 0.0, -0.0 ), - new Complex128( 1.0, -1.0 ), - new Complex128( 2.0, -2.0 ), - new Complex128( 3.0, -3.0 ), - new Complex128( 4.0, -4.0 ) - ]; - arr = new Complex128Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - - buf = new Float64Array( arr.buffer ); - - // Remain the same: - t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); - t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); - t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); - t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); - - // Overwritten: - t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected real for complex number 2' ); - t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected imag for complex number 2' ); - t.strictEqual( buf[ 6 ], 1.0, 'returns expected real for complex number 3' ); - t.strictEqual( buf[ 7 ], -1.0, 'returns expected imag for complex number 3' ); - - // Remain the same: - t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex128( 0.0, -0.0 ), - new Complex128( 1.0, -1.0 ), - new Complex128( 2.0, -2.0 ), - new Complex128( 3.0, -3.0 ), - new Complex128( 4.0, -4.0 ) - ]; - arr = new Complex128Array( arr ); - - arr.copyWithin( arr.length, 3 ); - - buf = new Float64Array( arr.buffer ); - - // Remain the same: - t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); - t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); - t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); - t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); - t.strictEqual( buf[ 4 ], 2.0, 'returns expected real for complex number 2' ); - t.strictEqual( buf[ 5 ], -2.0, 'returns expected imag for complex number 2' ); - t.strictEqual( buf[ 6 ], 3.0, 'returns expected real for complex number 3' ); - t.strictEqual( buf[ 7 ], -3.0, 'returns expected imag for complex number 3' ); - t.strictEqual( buf[ 8 ], 4.0, 'returns expected real for complex number 4' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected imag for complex number 4' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex128( 0.0, -0.0 ), - new Complex128( 1.0, -1.0 ), - new Complex128( 2.0, -2.0 ), - new Complex128( 3.0, -3.0 ), - new Complex128( 4.0, -4.0 ) - ]; - arr = new Complex128Array( arr ); - - arr.copyWithin( 2, 0 ); - - buf = new Float64Array( arr.buffer ); - - // Remain the same: - t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected real for complex number 0' ); - t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected imag for complex number 0' ); - t.strictEqual( buf[ 2 ], 1.0, 'returns expected real for complex number 1' ); - t.strictEqual( buf[ 3 ], -1.0, 'returns expected imag for complex number 1' ); - - // Overwritten: - t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected real for complex number 2' ); - t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected imag for complex number 2' ); - t.strictEqual( buf[ 6 ], 1.0, 'returns expected real for complex number 3' ); - t.strictEqual( buf[ 7 ], -1.0, 'returns expected imag for complex number 3' ); - t.strictEqual( buf[ 8 ], 2.0, 'returns expected real for complex number 4' ); - t.strictEqual( buf[ 9 ], -2.0, 'returns expected imag for complex number 4' ); - - t.end(); -}); diff --git a/complex128/test/test.entries.js b/complex128/test/test.entries.js deleted file mode 100644 index 7bcbd416d..000000000 --- a/complex128/test/test.entries.js +++ /dev/null @@ -1,249 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'entries' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - var j; - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex128Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - j = 0; - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns an array' ); - t.strictEqual( v.value[ 0 ], i, 'returns an index' ); - t.strictEqual( isComplex128( v.value[ 1 ] ), true, 'returns a complex number' ); - t.strictEqual( real( v.value[ 1 ] ), buf[ j ], 'returns expected real component' ); - t.strictEqual( imag( v.value[ 1 ] ), buf[ j+1 ], 'returns expected imaginary component' ); - t.strictEqual( typeof v.done, 'boolean', 'returns a boolean' ); - - j += 2; // stride - } - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (no argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex128Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( real( v.value[ 1 ] ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imag( v.value[ 1 ] ), buf[ 1 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( real( v.value[ 1 ] ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imag( v.value[ 1 ] ), buf[ 3 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex128Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( real( v.value[ 1 ] ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imag( v.value[ 1 ] ), buf[ 1 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( real( v.value[ 1 ] ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imag( v.value[ 1 ] ), buf[ 3 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'finished' ); - t.strictEqual( v.value, 'finished', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Complex128Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex128Array( buf ); - - it1 = arr.entries(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns an object' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1[ 0 ], v2[ 0 ], 'returns expected value' ); - t.strictEqual( real( v1[ 1 ] ), real( v2[ 1 ] ), 'returns expected value' ); - t.strictEqual( imag( v1[ 1 ] ), imag( v2[ 1 ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Complex128Array; - var arr; - var buf; - var it; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex128Array( buf ); - - it = arr.entries(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/complex128/test/test.every.js b/complex128/test/test.every.js deleted file mode 100644 index 6249f3edd..000000000 --- a/complex128/test/test.every.js +++ /dev/null @@ -1,175 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'every' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( real( v ) > 0 && imag( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty complex number array', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array(); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === imag( v ) ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === imag( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imag( v ) === real( v ) ); - } -}); diff --git a/complex128/test/test.fill.js b/complex128/test/test.fill.js deleted file mode 100644 index e26a78fdf..000000000 --- a/complex128/test/test.fill.js +++ /dev/null @@ -1,283 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Float64Array = require( './../../float64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'fill' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill.call( value, new Complex128( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( new Complex128( 1.0, 1.0 ), value ); - }; - } -}); - -tape( 'the method throws an error if provided a third argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( new Complex128( 1.0, 1.0 ), 0, value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex128Array(); - out = arr.fill( new Complex128( 1.0, 1.0 ) ); - - t.strictEqual( out instanceof Complex128Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex128Array( 10 ); - out = arr.fill( new Complex128( 1.0, 1.0 ) ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var expected; - var arr; - - arr = new Complex128Array( 3 ); - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr.fill( new Complex128( 1.0, 1.0 ) ); - - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var expected; - var arr; - - arr = new Complex128Array( 3 ); - expected = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr.fill( new Complex128( 1.0, 1.0 ), 1 ); - - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var expected; - var arr; - - arr = new Complex128Array( 3 ); - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); - - arr.fill( new Complex128( 1.0, 1.0 ), 0, 2 ); - - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - - arr = new Complex128Array( 3 ); - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); - - arr.fill( new Complex128( 1.0, 1.0 ), -3, -1 ); - - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var expected; - var arr; - - arr = new Complex128Array( 3 ); - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr.fill( new Complex128( 1.0, 1.0 ), -10 ); - - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var expected; - var arr; - - arr = new Complex128Array( 3 ); - expected = new Float64Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr.fill( new Complex128( 1.0, 1.0 ), 1, 10 ); - - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var expected; - var arr; - - arr = new Complex128Array( 3 ); - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr.fill( new Complex128( 1.0, 1.0 ), 2, 1 ); - - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.filter.js b/complex128/test/test.filter.js deleted file mode 100644 index db4834e9f..000000000 --- a/complex128/test/test.filter.js +++ /dev/null @@ -1,190 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Float64Array = require( './../../float64' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'filter' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( real( v ) > 0 && imag( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex128Array(); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) > 0 && imag( v ) < 0 ); - } -}); - -tape( 'the method returns a new complex number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 1.0, -1.0, 3.0, -3.0 ] ); - actual = arr.filter( predicate ); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) > 0 && imag( v ) < 0 ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.filter( predicate ); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) > 0 && imag( v ) < 0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var ctx; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 1.0, -1.0, 3.0, -3.0 ] ); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( real( v ) > 0 && imag( v ) < 0 ); - } -}); diff --git a/complex128/test/test.find.js b/complex128/test/test.find.js deleted file mode 100644 index 44330be10..000000000 --- a/complex128/test/test.find.js +++ /dev/null @@ -1,177 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'find' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( real( v ) > 0 && imag( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty complex number array', function test( t ) { - var arr; - var z; - - arr = new Complex128Array(); - z = arr.find( predicate ); - - t.strictEqual( z, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var z; - - arr = new Complex128Array( [ 1.0, 1.0, 2.0, -2.0 ] ); - z = arr.find( predicate ); - - t.strictEqual( real( z ), 2.0, 'returns expected value' ); - t.strictEqual( imag( z ), -2.0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === -imag( v ) ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var z; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - z = arr.find( predicate ); - - t.strictEqual( z, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === imag( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var z; - - ctx = { - 'count': 0 - }; - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); - z = arr.find( predicate, ctx ); - - t.strictEqual( real( z ), 3.0, 'returns expected value' ); - t.strictEqual( imag( z ), 3.0, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imag( v ) === real( v ) ); - } -}); diff --git a/complex128/test/test.find_index.js b/complex128/test/test.find_index.js deleted file mode 100644 index 9515faec6..000000000 --- a/complex128/test/test.find_index.js +++ /dev/null @@ -1,175 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'findIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( real( v ) > 0 && imag( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty complex number array', function test( t ) { - var arr; - var idx; - - arr = new Complex128Array(); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Complex128Array( [ 1.0, 1.0, 2.0, -2.0 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === -imag( v ) ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === imag( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imag( v ) === real( v ) ); - } -}); diff --git a/complex128/test/test.find_last.js b/complex128/test/test.find_last.js deleted file mode 100644 index 7b052efcf..000000000 --- a/complex128/test/test.find_last.js +++ /dev/null @@ -1,177 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'findLast' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( real( v ) > 0 && imag( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty complex number array', function test( t ) { - var arr; - var z; - - arr = new Complex128Array(); - z = arr.findLast( predicate ); - - t.strictEqual( z, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var z; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - z = arr.findLast( predicate ); - - t.strictEqual( real( z ), 2.0, 'returns expected value' ); - t.strictEqual( imag( z ), -2.0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === -imag( v ) ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var z; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - z = arr.findLast( predicate ); - - t.strictEqual( z, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === imag( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var z; - - ctx = { - 'count': 0 - }; - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); - z = arr.findLast( predicate, ctx ); - - t.strictEqual( real( z ), 3.0, 'returns expected value' ); - t.strictEqual( imag( z ), 3.0, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imag( v ) === real( v ) ); - } -}); diff --git a/complex128/test/test.find_last_index.js b/complex128/test/test.find_last_index.js deleted file mode 100644 index 1e66b2e86..000000000 --- a/complex128/test/test.find_last_index.js +++ /dev/null @@ -1,175 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'findLastIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( real( v ) > 0 && imag( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty complex number array', function test( t ) { - var arr; - var idx; - - arr = new Complex128Array(); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === -imag( v ) ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === imag( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Complex128Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, 3.0 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imag( v ) === real( v ) ); - } -}); diff --git a/complex128/test/test.for_each.js b/complex128/test/test.for_each.js deleted file mode 100644 index a9d978b95..000000000 --- a/complex128/test/test.for_each.js +++ /dev/null @@ -1,176 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'forEach' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isComplex128( v ) ) { - t.fail( 'should be a complex number ' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty complex number array', function test( t ) { - var arr; - - arr = new Complex128Array(); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isComplex128( v ) ) { - t.fail( 'should be a complex number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var arr; - - expected = []; - arr = new Complex128Array( [ 1.0, 1.0, 2.0, -2.0 ] ); - arr.forEach( fcn ); - expected = new Complex128Array( expected ); - - t.deepEqual( reinterpret128( expected, 0 ), reinterpret128( arr, 0 ), 'returns expected value' ); - t.end(); - - function fcn( v ) { - expected.push( v ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/complex128/test/test.from.js b/complex128/test/test.from.js deleted file mode 100644 index 0bf1cbcc5..000000000 --- a/complex128/test/test.from.js +++ /dev/null @@ -1,1254 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( './../../float64' ); -var Complex64Array = require( './../../complex64' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a complex number array from an array-like object or iterable', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Complex128Array, 'from' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.from ), true, 'has method' ); - - arr = Complex128Array.from( [] ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex array constructor', function test( t ) { - var values; - var i; - - values = [ - Complex128, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from( value, clbk ); - }; - } - - function clbk() { - return [ 1.0, 1.0 ]; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback, thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from( value, clbk, {} ); - }; - } - - function clbk() { - return [ 1.0, 1.0 ]; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a complex number array', function test( t ) { - var arr; - var z; - var v; - - // Generic array: - arr = Complex128Array.from( [] ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex128Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Generic array containing complex numbers: - arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex128( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex128Array.from( [ z, 1.0 ] ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex128( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex128Array.from( [ 1.0, z ] ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Typed array: - arr = Complex128Array.from( new Float64Array( 0 ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex128Array.from( new Float64Array( [ 1.0, 1.0 ] ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Complex typed array: - arr = Complex128Array.from( new Complex64Array( 0 ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex128Array.from( new Complex64Array( [ 1.0, 1.0 ] ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Complex128Array.from( new Complex128Array( 0 ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex128Array.from( new Complex128Array( [ 1.0, 1.0 ] ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - t.end(); - - function valueOf( z ) { - return function valueOf() { - return realf( z ); - }; - } -}); - -tape( 'the method returns a complex number array (iterable)', function test( t ) { - var Complex128Array; - var iter1; - var iter2; - var arr; - var v; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter1 = { - 'next': next1, - 'i': 0, - 'N': 4 - }; - arr = Complex128Array.from( createIterable( iter1 ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter1.N, 'returns expected value' ); - - iter2 = { - 'next': next2, - 'i': 0, - 'N': 4 - }; - arr = Complex128Array.from( createIterable( iter2 ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter2.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next1() { - iter1.i += 1; - if ( iter1.i <= iter1.N ) { - return { - 'value': [ 1.0, 1.0 ] - }; - } - return { - 'done': true - }; - } - - function next2() { - iter2.i += 1; - if ( iter2.i <= iter2.N ) { - return { - 'value': new Complex128( 1.0, 1.0 ) - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var z; - var v; - - // Generic array: - arr = Complex128Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex128Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Generic array containing complex numbers: - arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk2 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk3a ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex128( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex128Array.from( [ z, 1.0 ], clbk1 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex128( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex128Array.from( [ 1.0, z ], clbk1 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Typed array: - arr = Complex128Array.from( new Float64Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex128Array.from( new Float64Array( [ 1.0, 1.0 ] ), clbk1 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Complex typed array: - arr = Complex128Array.from( new Complex64Array( 0 ), clbk3a ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex128Array.from( new Complex64Array( [ 1.0, 1.0 ] ), clbk3a ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Complex128Array.from( new Complex64Array( 0 ), clbk3b ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex128Array.from( new Complex64Array( [ 1.0, 1.0 ] ), clbk3b ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Complex128Array.from( new Complex128Array( 0 ), clbk4a ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex128Array.from( new Complex128Array( [ 1.0, 1.0 ] ), clbk4a ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Complex128Array.from( new Complex128Array( 0 ), clbk4b ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex128Array.from( new Complex128Array( [ 1.0, 1.0 ] ), clbk4b ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - t.end(); - - function valueOf( z ) { - return function valueOf() { - return realf( z ); - }; - } - - function clbk1( v ) { - return v; - } - - function clbk2() { - return [ 1.0, 1.0 ]; - } - - function clbk3a( v ) { - return new Complex128( realf(v)*2.0, imagf(v)*2.0 ); - } - - function clbk3b( v ) { - return [ realf(v)*2.0, imagf(v)*2.0 ]; - } - - function clbk4a( v ) { - return new Complex128( real(v)*2.0, imag(v)*2.0 ); - } - - function clbk4b( v ) { - return [ real(v)*2.0, imag(v)*2.0 ]; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each iterated value', function test( t ) { - var Complex128Array; - var iter1; - var iter2; - var arr; - var v; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter1 = { - 'next': next1, - 'i': 0, - 'N': 4 - }; - arr = Complex128Array.from( createIterable( iter1 ), clbk1 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter1.N, 'returns expected value' ); - - iter2 = { - 'next': next2, - 'i': 0, - 'N': 4 - }; - arr = Complex128Array.from( createIterable( iter2 ), clbk2 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter2.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next1() { - iter1.i += 1; - if ( iter1.i <= iter1.N ) { - return { - 'value': [ 1.0, 1.0 ] - }; - } - return { - 'done': true - }; - } - - function clbk1( v ) { - v[ 0 ] += 1.0; - v[ 1 ] += 1.0; - return v; - } - - function next2() { - iter2.i += 1; - if ( iter2.i <= iter2.N ) { - return { - 'value': new Complex128( 1.0, 1.0 ) - }; - } - return { - 'done': true - }; - } - - function clbk2( v ) { - return new Complex128( real(v)*2.0, imag(v)*2.0 ); - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Complex128Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - ctx = { - 'count': 0 - }; - arr = [ new Complex128( 1.0, 1.0 ), new Complex128( -1.0, -1.0 ) ]; - arr = Complex128Array.from( arr, clbk2, ctx ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } - - function clbk2( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return new Complex128( real(v)*2.0, imag(v)*2.0 ); - } -}); - -tape( 'the method supports providing a `this` context for a provided map function (iterable)', function test( t ) { - var Complex128Array; - var iter; - var ctx; - var arr; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - ctx = { - 'count': 0 - }; - - arr = Complex128Array.from( createIterable( iter ), clbk, ctx ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': [ 1.0, 1.0 ] - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - v[ 0 ] += 1.0; - v[ 1 ] += 1.0; - return v; - } -}); - -tape( 'the method throws an error if provided a generic array-like object having an odd length', function test( t ) { - var values; - var i; - - values = [ - [ 1, 2, 3 ], - new Float64Array( [ 1, 2, 3 ] ), - { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }, - [ new Complex128( 1.0, 1.0 ), 1.0, 1.0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an array-like object having a length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from( value ); - }; - } -}); - -tape( 'the method throws an error if provided a generic array-like object having an odd length (clbk)', function test( t ) { - var values; - var i; - - values = [ - [ 1, 2, 3 ], - new Float64Array( [ 1, 2, 3 ] ), - { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }, - [ new Complex128( 1.0, 1.0 ), 1.0, 1.0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an array-like object having a length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from( value, clbk ); - }; - } - - function clbk() { - return [ 1.0, 1.0 ]; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Complex128Array; - var values; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Complex128Array; - var values; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the method throws an error if provided an iterable object which does not return complex numbers or arrays of real and imaginary components', function test( t ) { - var Complex128Array; - var values; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': 1.0 - }; - } - - function next2() { - return { - 'value': '1.0 + 1.0i' - }; - } -}); - -tape( 'the method throws an error if provided an iterable object which does not return an array-like object containing at least two elements', function test( t ) { - var Complex128Array; - var values; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': [] - }; - } - - function next2() { - return { - 'value': [ 1.0 ] - }; - } -}); - -tape( 'the method throws an error if provided a complex number source array and a "map" function which does not return complex numbers or arrays of real and imaginary components (collection)', function test( t ) { - var values; - var clbks; - var i; - - values = [ - [ new Complex128( 1.0, 1.0 ) ], - [ new Complex128( 1.0, 1.0 ), new Complex128( -1.0, -1.0 ) ] - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex128Array.from( value, clbk ); - }; - } - - function clbk1() { - return 1.0; - } - - function clbk2() { - return {}; - } -}); - -tape( 'the method throws an error if provided a complex number source array and a "map" function which does not return an array containing at least two elements (collection)', function test( t ) { - var values; - var clbks; - var i; - - values = [ - [ new Complex128( 1.0, 1.0 ) ], - [ new Complex128( 1.0, 1.0 ), new Complex128( -1.0, -1.0 ) ] - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex128Array.from( value, clbk ); - }; - } - - function clbk1() { - return []; - } - - function clbk2() { - return [ 1.0 ]; - } -}); - -tape( 'the method throws an error if provided a complex number source array and a "map" function which does not return complex numbers or arrays of real and imaginary components (complex array)', function test( t ) { - var values; - var clbks; - var i; - - values = [ - new Complex128Array( [ 1.0, 1.0 ] ), - new Complex128Array( [ 1.0, 1.0, -1.0, -1.0 ] ) - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex128Array.from( value, clbk ); - }; - } - - function clbk1() { - return 1.0; - } - - function clbk2() { - return {}; - } -}); - -tape( 'the method throws an error if provided a complex number source array and a "map" function which does not return an array containing at least two elements (complex array)', function test( t ) { - var values; - var clbks; - var i; - - values = [ - new Complex128Array( [ 1.0, 1.0 ] ), - new Complex128Array( [ 1.0, 1.0, -1.0, -1.0 ] ) - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex128Array.from( value, clbk ); - }; - } - - function clbk1() { - return []; - } - - function clbk2() { - return [ 1.0 ]; - } -}); - -tape( 'the method throws an error if provided a "map" function which does not return complex numbers or arrays of real and imaginary components (iterable)', function test( t ) { - var Complex128Array; - var values; - var clbks; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex128Array.from( value, clbk ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': [ 1.0, 1.0 ] - }; - } - - function clbk1() { - return 1.0; - } - - function next2() { - return { - 'value': new Complex128( 1.0, 1.0 ) - }; - } - - function clbk2() { - return '1.0 - 1.0j'; - } -}); - -tape( 'the method throws an error if provided a "map" function which does not return an array containing at least two elements (iterable)', function test( t ) { - var Complex128Array; - var values; - var clbks; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex128Array.from( value, clbk ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': [ 1.0, 1.0 ] - }; - } - - function clbk1() { - return []; - } - - function next2() { - return { - 'value': new Complex128( 1.0, 1.0 ) - }; - } - - function clbk2() { - return [ 1.0 ]; - } -}); diff --git a/complex128/test/test.get.js b/complex128/test/test.get.js deleted file mode 100644 index b54dc083e..000000000 --- a/complex128/test/test.get.js +++ /dev/null @@ -1,138 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex128 = require( '@stdlib/complex/float32/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.get.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.get( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Complex128Array( 10 ); - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex128( i, -i ) ); - } - arr = new Complex128Array( arr ); - - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( real( v ), i, 'returns expected real component for index '+i ); - t.strictEqual( imag( v ), -i, 'returns expected imaginary component for index '+i ); - } - t.end(); -}); diff --git a/complex128/test/test.includes.js b/complex128/test/test.includes.js deleted file mode 100644 index 61185e6aa..000000000 --- a/complex128/test/test.includes.js +++ /dev/null @@ -1,242 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'includes' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes.call( value, new Complex128( 10.0, 10.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes( new Complex128( 1.0, 1.0 ), value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty complex number array', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array(); - bool = arr.includes( new Complex128( 1.0, 1.0 ) ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a complex number is not found', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array( 10 ); - bool = arr.includes( new Complex128( 1.0, 1.0 ) ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified complex number', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array( 10 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - bool = arr.includes( new Complex128( 2.0, 2.0 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array( 10 ); - bool = arr.includes( new Complex128( 1.0, 1.0), 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array( 10 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - - bool = arr.includes( new Complex128( 2.0, 2.0 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( new Complex128( 2.0, 2.0 ), 2 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( new Complex128( 3.0, 3.0 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - bool = arr.includes( new Complex128( 2.0, 2.0 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( new Complex128( 4.0, 4.0 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - bool = arr.includes( new Complex128( 2.0, 2.0 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( new Complex128( 4.0, 4.0 ), -10 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.index_of.js b/complex128/test/test.index_of.js deleted file mode 100644 index 92a35694e..000000000 --- a/complex128/test/test.index_of.js +++ /dev/null @@ -1,244 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'indexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf.call( value, new Complex128( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf( new Complex128( 1.0, 1.0 ), value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty complex number array', function test( t ) { - var arr; - var idx; - - arr = new Complex128Array(); - idx = arr.indexOf( new Complex128( 1.0, 1.0 ) ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a complex number is not found', function test( t ) { - var idx; - var arr; - - arr = new Complex128Array( 10 ); - idx = arr.indexOf( new Complex128( 1.0, 1.0 ) ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a complex number is found', function test( t ) { - var idx; - var arr; - - arr = new Complex128Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 5.0, 5.0 ], 4 ); - idx = arr.indexOf( new Complex128( 2.0, 2.0 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Complex128Array( 10 ); - idx = arr.indexOf( new Complex128( 1.0, 1.0), 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Complex128Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 4.0, 4.0 ], 4 ); - - idx = arr.indexOf( new Complex128( 2.0, 2.0 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( new Complex128( 2.0, 2.0 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( new Complex128( 3.0, 3.0 ), 3 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Complex128Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - idx = arr.indexOf( new Complex128( 2.0, 2.0 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( new Complex128( 4.0, 4.0 ), -2 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Complex128Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - idx = arr.indexOf( new Complex128( 2.0, 2.0 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( new Complex128( 4.0, 4.0 ), -10 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.join.js b/complex128/test/test.join.js deleted file mode 100644 index 4367d17e9..000000000 --- a/complex128/test/test.join.js +++ /dev/null @@ -1,162 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'join' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.join.call( value ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.join( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Complex128Array(); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a complex number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - - arr = new Complex128Array( [ 1, 2, -3, -4 ] ); - expected = '1 + 2i@-3 - 4i'; - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a complex number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Complex128Array( [ 1, 2 ] ); - expected = '1 + 2i'; - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Complex128Array( [ 1, 2 ] ); - expected = '1 + 2i'; - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if method invoked without a separator argument, the method returns a string representation of a complex number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - - arr = new Complex128Array( [ 1, 2, -3, -4 ] ); - expected = '1 + 2i,-3 - 4i'; - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.js b/complex128/test/test.js deleted file mode 100644 index 56a6c17a6..000000000 --- a/complex128/test/test.js +++ /dev/null @@ -1,961 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var ArrayBuffer = require( './../../buffer' ); -var Float64Array = require( './../../float64' ); -var Complex64Array = require( './../../complex64' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Complex128Array( 0 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = Complex128Array; - - arr = ctor( 0 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (no argument)', function test( t ) { - var arr = new Complex128Array(); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (no argument, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex128Array; - - arr = ctor(); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (length)', function test( t ) { - var arr = new Complex128Array( 10 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex128Array; - - arr = ctor( 10 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (array)', function test( t ) { - var arr = new Complex128Array( [] ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex128Array; - - arr = ctor( [] ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (typed array)', function test( t ) { - var arr = new Complex128Array( new Float64Array( 0 ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex128Array; - - arr = ctor( new Float64Array( 0 ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (complex typed array)', function test( t ) { - var arr = new Complex128Array( new Complex128Array( 0 ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (complex typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex128Array; - - arr = ctor( new Complex128Array( 0 ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (iterable)', function test( t ) { - var Complex128Array; - var arr; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - arr = new Complex128Array( createIterable() ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 128-bit complex number array (iterable, no new)', function test( t ) { - var ctor; - var arr; - - ctor = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - arr = ctor( createIterable() ); - t.strictEqual( arr instanceof ctor, true, 'returns an instance' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 128-bit complex number array (ArrayBuffer)', function test( t ) { - var arr = new Complex128Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (ArrayBuffer, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex128Array; - - arr = ctor( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Complex128Array( new ArrayBuffer( 16 ), 16 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (ArrayBuffer, byte offset, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex128Array; - - arr = ctor( new ArrayBuffer( 16 ), 16 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Complex128Array( new ArrayBuffer( 16 ), 16, 0 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 128-bit complex number array (ArrayBuffer, byte offset, length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex128Array; - - arr = ctor( new ArrayBuffer( 16 ), 16, 0 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128Array.BYTES_PER_ELEMENT, 16, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array, 'name' ), true, 'has property' ); - t.strictEqual( Complex128Array.name, 'Complex128Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex128Array.prototype.BYTES_PER_ELEMENT, 16, 'returns expected value' ); - - arr = new Complex128Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 16, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Complex128Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Complex128Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex128Array( new ArrayBuffer( 128 ), 16 ); - v = arr.byteLength; - t.strictEqual( v, 112, 'returns expected value' ); - - arr = new Complex128Array( new ArrayBuffer( 128 ), 128 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Complex128Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex128Array( new ArrayBuffer( 128 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - arr = new Complex128Array( new ArrayBuffer( 128 ), 128 ); - v = arr.byteOffset; - t.strictEqual( v, 128, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var z; - var v; - - // No arguments: - arr = new Complex128Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Complex128Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex128Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Complex128Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Generic array containing complex numbers: - arr = new Complex128Array( [ new Complex128( 1.0, 1.0 ) ] ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex128( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = new Complex128Array( [ z, 1.0 ] ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex128( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = new Complex128Array( [ 1.0, z ] ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Typed array: - arr = new Complex128Array( new Float64Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex128Array( new Float64Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Complex typed array: - arr = new Complex128Array( new Complex64Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex128Array( new Complex64Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = new Complex128Array( new Complex128Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex128Array( new Complex128Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // ArrayBuffer: - arr = new Complex128Array( new ArrayBuffer( 128 ), 64 ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - arr = new Complex128Array( new ArrayBuffer( 128 ), 128 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex128Array( new ArrayBuffer( 128 ), 64, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function valueOf( z ) { - return function valueOf() { - return real( z ); - }; - } -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements (iterable)', function test( t ) { - var Complex128Array; - var iter1; - var iter2; - var arr; - var v; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter1 = { - 'next': next1, - 'i': 0, - 'N': 4 - }; - arr = new Complex128Array( createIterable( iter1 ) ); - v = arr.length; - t.strictEqual( v, iter1.N, 'returns expected value' ); - - iter2 = { - 'next': next2, - 'i': 0, - 'N': 4 - }; - arr = new Complex128Array( createIterable( iter2 ) ); - v = arr.length; - t.strictEqual( v, iter2.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next1() { - iter1.i += 1; - if ( iter1.i <= iter1.N ) { - return { - 'value': [ 1.0, 1.0 ] - }; - } - return { - 'done': true - }; - } - - function next2() { - iter2.i += 1; - if ( iter2.i <= iter2.N ) { - return { - 'value': new Complex128( 1.0, 1.0 ) - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 16', function test( t ) { - var values; - var i; - - values = [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 9, - 24, - 74, - 801 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided an array-like object having an odd length', function test( t ) { - var values; - var i; - - values = [ - [ 1, 2, 3 ], - new Float64Array( [ 1, 2, 3 ] ), - { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }, - [ new Complex128( 1.0, 1.0 ), 1.0, 1.0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an array-like object having a length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Complex128Array; - var values; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Complex128Array; - var values; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the constructor throws an error if provided an iterable object which does not return complex numbers or arrays of real and imaginary components', function test( t ) { - var Complex128Array; - var values; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': 1.0 - }; - } - - function next2() { - return { - 'value': '1.0 + 1.0i' - }; - } -}); - -tape( 'the constructor throws an error if provided an iterable object which does not return array containing at least two elements', function test( t ) { - var Complex128Array; - var values; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': [] - }; - } - - function next2() { - return { - 'value': [ 1.0 ] - }; - } -}); - -tape( 'the constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( value ); - }; - } -}); - -tape( 'the constructor throws an error if provided more than one argument and the first argument is not an ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( value, 0 ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( new ArrayBuffer( 128 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 16', function test( t ) { - var values; - var i; - - values = [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 9, - 24, - 65, - 78, - 801 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( new ArrayBuffer( 1024 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 16', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32, - 48, - 56, - 64, - 72, - 80, - 88 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( new ArrayBuffer( 102 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a length argument which is not a nonnegative integer (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( new ArrayBuffer( 128 ), 0, value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 16, - 24, - 32, - 48 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex128Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/complex128/test/test.keys.js b/complex128/test/test.keys.js deleted file mode 100644 index 21ca92b56..000000000 --- a/complex128/test/test.keys.js +++ /dev/null @@ -1,261 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'keys' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Complex128Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Complex128Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex128Array( buf ); - - it1 = arr.keys(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns an object' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Complex128Array; - var arr; - var buf; - var it; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex128Array( buf ); - - it = arr.keys(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/complex128/test/test.last_index_of.js b/complex128/test/test.last_index_of.js deleted file mode 100644 index ced31bf20..000000000 --- a/complex128/test/test.last_index_of.js +++ /dev/null @@ -1,232 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'lastIndexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf.call( value, new Complex128( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf( new Complex128( 1.0, 1.0 ), value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty complex number array', function test( t ) { - var arr; - var idx; - - arr = new Complex128Array(); - idx = arr.lastIndexOf( new Complex128( 1.0, 1.0 ) ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a complex number is not found', function test( t ) { - var idx; - var arr; - - arr = new Complex128Array( 10 ); - idx = arr.lastIndexOf( new Complex128( 1.0, 1.0 ) ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Complex128Array( 10 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - idx = arr.lastIndexOf( new Complex128( 2.0, 2.0 ) ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Complex128Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 3.0, 3.0 ], 4 ); - - idx = arr.lastIndexOf( new Complex128( 2.0, 2.0 ), 4 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.lastIndexOf( new Complex128( 2.0, 2.0 ), 2 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.lastIndexOf( new Complex128( 3.0, 3.0 ), 1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Complex128Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - idx = arr.lastIndexOf( new Complex128( 2.0, 2.0 ), -3 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.lastIndexOf( new Complex128( 3.0, 3.0 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Complex128Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - idx = arr.lastIndexOf( new Complex128( 2.0, 2.0 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( new Complex128( 4.0, 4.0 ), 10 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.map.js b/complex128/test/test.map.js deleted file mode 100644 index 76a1cf2dd..000000000 --- a/complex128/test/test.map.js +++ /dev/null @@ -1,231 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var identity = require( '@stdlib/utils/identity-function' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Float64Array = require( './../../float64' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'map' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex128Array(); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new complex number array containing elements which are the result of a callback function', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); - actual = arr.map( scale ); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return new Complex128( real( v )*2.0, imag( v )*2.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var ctx; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 3.0, -3.0, 6.0, -6.0, 9.0, -9.0 ] ); - ctx = { - 'count': 0 - }; - actual = arr.map( scale, ctx ); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - t.end(); - - function scale( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return new Complex128( real( v )*3.0, imag( v )*3.0 ); - } -}); - -tape( 'the method supports a map function which returns a two-element array containing a real and an imaginary component', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); - actual = arr.map( scale ); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return [ real( v )*2.0, imag( v )*2.0 ]; - } -}); - -tape( 'the method throws an error if provided a map function which does not return a complex number or an array of length 2 containing real and imaginary components', function test( t ) { - var clbks; - var arr; - var i; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - clbks = [ - clbk1, - clbk2, - clbk3, - clbk4, - clbk5 - ]; - for ( i = 0; i < clbks.length; i++ ) { - t.throws( badValue( clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( clbk ) { - return function badValue() { - return arr.map( clbk ); - }; - } - - function clbk1() { - return 1.0; - } - - function clbk2() { - return {}; - } - - function clbk3() { - return [ 1.0, 2.0, 3.0 ]; - } - - function clbk4() { - return []; - } - - function clbk5() { - return [ 1.0 ]; - } -}); diff --git a/complex128/test/test.of.js b/complex128/test/test.of.js deleted file mode 100644 index 2e07f4991..000000000 --- a/complex128/test/test.of.js +++ /dev/null @@ -1,149 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a complex number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Complex128Array, 'of' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.of ), true, 'has method' ); - - arr = Complex128Array.of(); - t.strictEqual( arr instanceof Complex128Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.of.call( value, 1.0, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex array constructor', function test( t ) { - var values; - var i; - - values = [ - Complex128, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex128Array.of.call( value, 1.0, 1.0 ); - }; - } -}); - -tape( 'the method returns a complex number array', function test( t ) { - var arr; - var z; - var v; - - // No arguments: - arr = Complex128Array.of(); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Interleaved real and imaginary components: - arr = Complex128Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Complex numbers: - z = new Complex128( 1.0, 1.0 ); - arr = Complex128Array.of( z, z, z, z, z ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - z = new Complex128( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex128Array.of( z, 1.0 ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex128( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex128Array.of( 1.0, z ); - t.strictEqual( arr instanceof Complex128Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - t.end(); - - function valueOf( z ) { - return function valueOf() { - return real( z ); - }; - } -}); diff --git a/complex128/test/test.reduce.js b/complex128/test/test.reduce.js deleted file mode 100644 index e28424c48..000000000 --- a/complex128/test/test.reduce.js +++ /dev/null @@ -1,212 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var cadd = require( '@stdlib/complex/float64/base/add' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'reduce' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map.reduce( value, cadd ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty complex number array', function test( t ) { - var arr; - - arr = new Complex128Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( cadd ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - accArray = [ 1.0, -1.0, 3.0, -3.0 ]; - valueArray = [ 2.0, -2.0, 3.0, -3.0 ]; - expected = new Complex128( 6.0, -6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); - t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - var ind = 2*(index-1); - t.strictEqual( instanceOf( acc, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( acc ), accArray[ ind ], 'returns expected value' ); - t.strictEqual( imag( acc ), accArray[ ind+1 ], 'returns expected value' ); - t.strictEqual( instanceOf( value, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( value ), valueArray[ ind ], 'returns expected value' ); - t.strictEqual( imag( value ), valueArray[ ind+1 ], 'returns expected value' ); - return cadd( acc, value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - accArray = [ 2.0, -2.0, 3.0, -3.0, 5.0, -5.0 ]; - valueArray = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; - expected = new Complex128( 8.0, -8.0 ); - actual = arr.reduce( reducer, new Complex128( 2.0, -2.0 ) ); - - t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); - t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( instanceOf( acc, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( acc ), accArray[ 2*index ], 'returns expected value' ); - t.strictEqual( imag( acc ), accArray[ (2*index)+1 ], 'returns expected value' ); - t.strictEqual( instanceOf( value, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( value ), valueArray[ 2*index ], 'returns expected value' ); - t.strictEqual( imag( value ), valueArray[ (2*index)+1 ], 'returns expected value' ); - return cadd( acc, value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Complex128( 6.0, -6.0 ); - actual = arr.reduce( cadd ); - - t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); - t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports returning real-valued results', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = 6.0; - actual = arr.reduce( reducer, 0.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return acc + real( value ); - } -}); diff --git a/complex128/test/test.reduce_right.js b/complex128/test/test.reduce_right.js deleted file mode 100644 index 085702e40..000000000 --- a/complex128/test/test.reduce_right.js +++ /dev/null @@ -1,217 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var cadd = require( '@stdlib/complex/float64/base/add' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'reduceRight' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map.reduceRight( value, cadd ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty complex number array', function test( t ) { - var arr; - - arr = new Complex128Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( cadd ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - len = arr.length; - accArray = [ 3.0, -3.0, 5.0, -5.0 ]; - valueArray = [ 2.0, -2.0, 1.0, -1.0 ]; - expected = new Complex128( 6.0, -6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); - t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - var ind = 2*(len-index-2); - t.strictEqual( instanceOf( acc, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( acc ), accArray[ ind ], 'returns expected value' ); - t.strictEqual( imag( acc ), accArray[ ind+1 ], 'returns expected value' ); - t.strictEqual( instanceOf( value, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( value ), valueArray[ ind ], 'returns expected value' ); - t.strictEqual( imag( value ), valueArray[ ind+1 ], 'returns expected value' ); - return cadd( acc, value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - len = arr.length; - accArray = [ 2.0, -2.0, 5.0, -5.0, 7.0, -7.0 ]; - valueArray = [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ]; - expected = new Complex128( 8.0, -8.0 ); - actual = arr.reduceRight( reducer, new Complex128( 2.0, -2.0 ) ); - - t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); - t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - var ind = 2*(len-index-1); - t.strictEqual( instanceOf( acc, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( acc ), accArray[ ind ], 'returns expected value' ); - t.strictEqual( imag( acc ), accArray[ ind+1 ], 'returns expected value' ); - t.strictEqual( instanceOf( value, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( value ), valueArray[ ind ], 'returns expected value' ); - t.strictEqual( imag( value ), valueArray[ ind+1 ], 'returns expected value' ); - return cadd( acc, value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Complex128( 6.0, -6.0 ); - actual = arr.reduceRight( cadd ); - - t.strictEqual( instanceOf( actual, Complex128 ), true, 'returns expected value' ); - t.strictEqual( real( actual ), real( expected ), 'returns expected value' ); - t.strictEqual( imag( actual ), imag( expected ), 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports returning real-valued results', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = 6.0; - actual = arr.reduceRight( reducer, 0.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return acc + real( value ); - } -}); diff --git a/complex128/test/test.reverse.js b/complex128/test/test.reverse.js deleted file mode 100644 index 677e49a08..000000000 --- a/complex128/test/test.reverse.js +++ /dev/null @@ -1,114 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Float64Array = require( './../../float64' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reverse` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'reverse' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reverse.call( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex128Array(); - out = arr.reverse(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method reverses elements of a complex number array in-place', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); - out = arr.reverse(); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex128Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.set.js b/complex128/test/test.set.js deleted file mode 100644 index afd52efbc..000000000 --- a/complex128/test/test.set.js +++ /dev/null @@ -1,714 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ArrayBuffer = require( './../../buffer' ); -var Float64Array = require( './../../float64' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number, a complex number array, or an array-like object', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number, a complex number array, or an array-like object (index argument)', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( new Complex128( 1.0, -1.0 ), value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (complex number)', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - arr.length, - arr.length + 1, - arr.length + 2, - arr.length + 3 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( new Complex128( 1.0, -1.0 ), value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (complex typed array)', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Complex128Array( 10 ); - arr2 = new Complex128Array( 10 ); - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (array-like object containing complex numbers)', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Complex128Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( new Complex128( i, -i ) ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (array-like object containing interleaved components)', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Complex128Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( i ); - arr2.push( -i ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method throws an error if provided an array-like object containing interleaved components which has an odd length', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - [ 1 ], - [ 1, 2, 3 ], - [ 1, 2, 3, 4, 5 ], - [ 1, 2, 3, 4, 5, 6, 7 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( value ); - }; - } -}); - -tape( 'the method throws an error if provided an array-like object containing interleaved components which has an odd length (index argument)', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - [ 1 ], - [ 1, 2, 3 ], - [ 1, 2, 3, 4, 5 ], - [ 1, 2, 3, 4, 5, 6, 7 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( value, 0 ); - }; - } -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new Complex128Array( 10 ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+0 ); - - // No index argument: - arr.set( new Complex128( 20.0, -20.0 ) ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), 20.0, 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), -20.0, 'returns expected imaginary component for index '+0 ); - - arr.set( new Complex128( 0.0, 0.0 ) ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+i ); - t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+i ); - - arr.set( new Complex128( i, -i ), i ); - - v = arr.get( i ); - t.strictEqual( real( v ), i, 'returns expected real component for index '+i ); - t.strictEqual( imag( v ), -i, 'returns expected imaginary component for index '+i ); - } - t.end(); -}); - -tape( 'the method sets an array element (complex typed array)', function test( t ) { - var arr; - var buf; - var v; - var i; - - arr = new Complex128Array( 10 ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+0 ); - - // No index argument: - buf = [ 20.0, -20.0 ]; - arr.set( new Complex128Array( buf ) ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); - - buf = [ 0.0, 0.0 ]; - arr.set( new Complex128Array( buf ) ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+i ); - t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+i ); - - buf = [ i, -i ]; - arr.set( new Complex128Array( buf ), i ); - - v = arr.get( i ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+i ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+i ); - } - - // Multiple values, no index argument: - buf = [ 20.0, -20.0, -40.0, 40.0 ]; - arr.set( new Complex128Array( buf ) ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); - - v = arr.get( 1 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); - - // Multiple values, index argument: - buf = [ -100.0, -200.0, -300.0, -400.0 ]; - arr.set( new Complex128Array( buf ), 2 ); - - v = arr.get( 2 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); - - v = arr.get( 3 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); - - t.end(); -}); - -tape( 'the method sets an array element (array-like object containing complex numbers)', function test( t ) { - var arr; - var buf; - var v; - var i; - - arr = new Complex128Array( 10 ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+0 ); - - // No index argument: - buf = [ 20.0, -20.0 ]; - arr.set( [ new Complex128( buf[0], buf[1] ) ] ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); - - buf = [ 0.0, 0.0 ]; - arr.set( [ new Complex128( buf[0], buf[1] ) ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+i ); - t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+i ); - - buf = [ i, -i ]; - arr.set( [ new Complex128( buf[ 0 ], buf[ 1 ] ) ], i ); - - v = arr.get( i ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+i ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+i ); - } - - // Multiple values, no index argument: - buf = [ 20.0, -20.0, -40.0, 40.0 ]; - arr.set( [ new Complex128( buf[0], buf[1] ), new Complex128( buf[2], buf[3] ) ] ); // eslint-disable-line max-len - - v = arr.get( 0 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); - - v = arr.get( 1 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); - - // Multiple values, index argument: - buf = [ -100.0, -200.0, -300.0, -400.0 ]; - arr.set( [ new Complex128( buf[0], buf[1] ), new Complex128( buf[2], buf[3] ) ], 2 ); // eslint-disable-line max-len - - v = arr.get( 2 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); - - v = arr.get( 3 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); - - t.end(); -}); - -tape( 'the method sets an array element (array-like object containing interleaved components)', function test( t ) { - var arr; - var buf; - var v; - var i; - - arr = new Complex128Array( 10 ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+0 ); - - // No index argument: - buf = [ 20.0, -20.0 ]; - arr.set( buf ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); - - buf = [ 0.0, 0.0 ]; - arr.set( buf ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( real( v ), 0.0, 'returns expected real component for index '+i ); - t.strictEqual( imag( v ), 0.0, 'returns expected imaginary component for index '+i ); - - buf = [ i, -i ]; - arr.set( buf, i ); - - v = arr.get( i ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+i ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+i ); - } - - // Multiple values, no index argument: - buf = [ 20.0, -20.0, -40.0, 40.0 ]; - arr.set( buf ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); - - v = arr.get( 1 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); - - // Multiple values, index argument: - buf = [ -100.0, -200.0, -300.0, -400.0 ]; - arr.set( buf, 2 ); - - v = arr.get( 2 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); - - v = arr.get( 3 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); - - t.end(); -}); - -tape( 'the method sets an array element (complex typed array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - - byteOffset = 224; - - ab = new ArrayBuffer( 480 ); - arr = new Complex128Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 20.0, -20.0, -40.0, 40.0 ]; - src = new Complex128Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); - - v = arr.get( 1 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -100.0, -200.0, -300.0, -400.0 ]; - src = new Complex128Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); - - v = arr.get( 3 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 25.0, -25.0, -45.0, 45.0 ]; - src = new Complex128Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); - - v = arr.get( 1 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -105.0, -205.0, -305.0, -405.0 ]; - src = new Complex128Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); - - v = arr.get( 3 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); - - t.end(); -}); - -tape( 'the method sets an array element (typed array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 224; - - ab = new ArrayBuffer( 480 ); - arr = new Complex128Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 20.0, -20.0, -40.0, 40.0 ]; - src = new Float64Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 4 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); - - v = arr.get( 1 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -100.0, -200.0, -300.0, -400.0 ]; - src = new Float64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 4 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); - - v = arr.get( 3 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 25.0, -25.0, -45.0, 45.0 ]; - src = new Float64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 4 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+0 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+0 ); - - v = arr.get( 1 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+1 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+1 ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -105.0, -205.0, -305.0, -405.0 ]; - src = new Float64Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 4 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( real( v ), buf[ 0 ], 'returns expected real component for index '+2 ); - t.strictEqual( imag( v ), buf[ 1 ], 'returns expected imaginary component for index '+2 ); - - v = arr.get( 3 ); - t.strictEqual( real( v ), buf[ 2 ], 'returns expected real component for index '+3 ); - t.strictEqual( imag( v ), buf[ 3 ], 'returns expected imaginary component for index '+3 ); - - t.end(); -}); diff --git a/complex128/test/test.slice.js b/complex128/test/test.slice.js deleted file mode 100644 index c8d3dcbc1..000000000 --- a/complex128/test/test.slice.js +++ /dev/null @@ -1,271 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Float64Array = require( './../../float64' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'slice' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice( 0, value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex128Array(); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.slice(); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.slice( 1 ); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.slice( 1, 3 ); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - actual = arr.slice( 1, 30 ); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - - expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.slice( -3, -1 ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - actual = arr.slice( -30, -2 ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float64Array( [] ); - actual = arr.slice( 2, 0 ); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float64Array( [] ); - actual = arr.slice( 5 ); - - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float64Array( [] ); - - actual = arr.slice( 2, -8 ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.some.js b/complex128/test/test.some.js deleted file mode 100644 index a0e82023b..000000000 --- a/complex128/test/test.some.js +++ /dev/null @@ -1,197 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning a boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'some' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( real( v ) > 0 && imag( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty complex number array', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array(); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array( [ 1.0, 1.0, 1.0, 2.0 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === imag( v ) ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( real( v ) === imag( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imag( v ) === real( v ) ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imag( v ) === real( v ) ); - } -}); diff --git a/complex128/test/test.sort.js b/complex128/test/test.sort.js deleted file mode 100644 index 5acdbbe67..000000000 --- a/complex128/test/test.sort.js +++ /dev/null @@ -1,181 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var real = require( '@stdlib/complex/float64/real' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Float64Array = require( './../../float64' ); -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex128} a - first value for comparison -* @param {Complex128} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = real( a ); - re2 = real( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imag( a ); - im2 = imag( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'sort' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex128Array(); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a complex number array in-place', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex128Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); - expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.subarray.js b/complex128/test/test.subarray.js deleted file mode 100644 index 217330b64..000000000 --- a/complex128/test/test.subarray.js +++ /dev/null @@ -1,272 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Float64Array = require( './../../float64' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'subarray' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray( 0, value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex128Array(); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.subarray(); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.subarray( 1 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.subarray( 1, 3 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - - expected = new Float64Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.subarray( -3, -1 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - actual = arr.subarray( -30, -2 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float64Array( [] ); - actual = arr.subarray( 2, 0 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float64Array( [] ); - actual = arr.subarray( 5 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float64Array( [] ); - - actual = arr.subarray( 2, -8 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.to_locale_string.js b/complex128/test/test.to_locale_string.js deleted file mode 100644 index 4e92048e0..000000000 --- a/complex128/test/test.to_locale_string.js +++ /dev/null @@ -1,187 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toLocaleString' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (options)', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( value, {} ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an object', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - 'beep', - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( 'en-GB', value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Complex128Array(); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a complex number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Complex128Array( [ 1, 2, -3, -4 ] ); - expected = '1 + 2i,-3 - 4i'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.to_reversed.js b/complex128/test/test.to_reversed.js deleted file mode 100644 index 3835a896a..000000000 --- a/complex128/test/test.to_reversed.js +++ /dev/null @@ -1,113 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Float64Array = require( './../../float64' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toReversed` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toReversed' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toReversed.call( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex128Array(); - out = arr.toReversed(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in reverse order', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float64Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); - out = arr.toReversed(); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex128Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.to_sorted.js b/complex128/test/test.to_sorted.js deleted file mode 100644 index febf42dbc..000000000 --- a/complex128/test/test.to_sorted.js +++ /dev/null @@ -1,180 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Float64Array = require( './../../float64' ); -var Complex128Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex128} a - first value for comparison -* @param {Complex128} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = real( a ); - re2 = real( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imag( a ); - im2 = imag( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toSorted' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex128Array(); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex128Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); - expected = new Float64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.to_string.js b/complex128/test/test.to_string.js deleted file mode 100644 index 97b59bb96..000000000 --- a/complex128/test/test.to_string.js +++ /dev/null @@ -1,97 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Complex128Array(); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a complex number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Complex128Array( [ 1, 2, -3, -4 ] ); - expected = '1 + 2i,-3 - 4i'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex128/test/test.values.js b/complex128/test/test.values.js deleted file mode 100644 index 5a74e272b..000000000 --- a/complex128/test/test.values.js +++ /dev/null @@ -1,272 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'values' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - expected = [ - { - 'value': new Complex128( 1.0, -1.0 ), - 'done': false - }, - { - 'value': new Complex128( 2.0, -2.0 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( isComplex128( r.value ), true, 'returns expected value' ); - t.strictEqual( real( r.value ), real( e.value ), 'returns expected value' ); - t.strictEqual( imag( r.value ), imag( e.value ), 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Complex128Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( real( v.value ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v.value ), -1.0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( real( v.value ), 2.0, 'returns expected value' ); - t.strictEqual( imag( v.value ), -2.0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Complex128Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( real( v.value ), 1.0, 'returns expected value' ); - t.strictEqual( imag( v.value ), -1.0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( real( v.value ), 2.0, 'returns expected value' ); - t.strictEqual( imag( v.value ), -2.0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Complex128Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex128Array( buf ); - - it1 = arr.values(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns an object' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( real( v1 ), real( v2 ), 'returns expected value' ); - t.strictEqual( imag( v1 ), imag( v2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Complex128Array; - var arr; - var buf; - var it; - - Complex128Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex128Array( buf ); - - it = arr.values(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/complex128/test/test.with.js b/complex128/test/test.with.js deleted file mode 100644 index 27b65d776..000000000 --- a/complex128/test/test.with.js +++ /dev/null @@ -1,203 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Float64Array = require( './../../float64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex128Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex128Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex128Array.prototype, 'with' ), true, 'has property' ); - t.strictEqual( isFunction( Complex128Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with.call( value, 0, new Complex128( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 5 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, new Complex128( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, new Complex128( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a complex number', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex128Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( 0, value ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex128Array( 10 ); - out = arr.with( 5, new Complex128( 1.0, 1.0 ) ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new complex number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); - expected = new Float64Array( [ 1.0, 1.0, 5.0, 5.0, 3.0, 3.0, 4.0, 4.0 ] ); - out = arr.with( 1, new Complex128( 5.0, 5.0 ) ); - - t.strictEqual( out instanceof Complex128Array, true, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - expected = new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 1.0, 1.0 ] ); - - out = arr.with( -1, new Complex128( 1.0, 1.0 ) ); - - t.strictEqual( out instanceof Complex128Array, true, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/README.md b/complex64/README.md deleted file mode 100644 index 1edbaf968..000000000 --- a/complex64/README.md +++ /dev/null @@ -1,2639 +0,0 @@ - - -# Complex64Array - -> 64-bit complex number array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Complex64Array = require( '@stdlib/array/complex64' ); -``` - - - -#### Complex64Array() - -Creates a 64-bit complex number array. - -```javascript -var arr = new Complex64Array(); -// returns -``` - -#### Complex64Array( length ) - -Creates a 64-bit complex number array having a specified `length`. - -```javascript -var arr = new Complex64Array( 10 ); -// returns - -var len = arr.length; -// returns 10 -``` - -#### Complex64Array( complexarray ) - -Creates a 64-bit complex number array from another complex number array. - -```javascript -var arr1 = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] -// returns - -var arr2 = new Complex64Array( arr1 ); -// returns - -var len = arr2.length; -// returns 2 -``` - -#### Complex64Array( typedarray ) - -Creates a 64-bit complex number array from a [typed array][@stdlib/array/typed] containing interleaved real and imaginary components. - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var buf = new Float32Array( [ 1.0, -1.0, 2.0, -2.0 ] ); // [ re, im, re, im ] -// returns [ 1.0, -1.0, 2.0, -2.0 ] - -var arr = new Complex64Array( buf ); -// returns - -var len = arr.length; -// returns 2 -``` - -#### Complex64Array( obj ) - -Creates a 64-bit complex number array from an array-like object or iterable. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -// From an array of interleaved real and imaginary components: -var arr1 = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); -// returns - -var len = arr1.length; -// returns 2 - -// From an array containing complex numbers: -var buf = [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ]; -var arr2 = new Complex64Array( buf ); - -len = arr2.length; -// returns 2 -``` - -#### Complex64Array( buffer\[, byteOffset\[, length]] ) - -Returns a 64-bit complex number array view of an [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); -var buf = new ArrayBuffer( 240 ); - -var arr1 = new Complex64Array( buf ); -// returns - -var len = arr1.length; -// returns 30 - -var arr2 = new Complex64Array( buf, 8 ); -// returns - -len = arr2.length; -// returns 29 - -var arr3 = new Complex64Array( buf, 8, 20 ); -// returns - -len = arr3.length; -// returns 20 -``` - -* * * - -### Properties - - - -#### Complex64Array.BYTES_PER_ELEMENT - -Static property returning the size (in bytes) of each array element. - -```javascript -var nbytes = Complex64Array.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### Complex64Array.name - -Static property returning the constructor name. - -```javascript -var str = Complex64Array.name; -// returns 'Complex64Array' -``` - - - -#### Complex64Array.prototype.buffer - -Pointer to the underlying data buffer. - -```javascript -var arr = new Complex64Array( 2 ); -// returns - -var buf = arr.buffer; -// returns -``` - - - -#### Complex64Array.prototype.byteLength - -Size (in bytes) of the array. - -```javascript -var arr = new Complex64Array( 10 ); -// returns - -var nbytes = arr.byteLength; -// returns 80 -``` - - - -#### Complex64Array.prototype.byteOffset - -Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var arr = new Complex64Array( 10 ); -// returns - -var offset = arr.byteOffset; -// returns 0 - -var buf = new ArrayBuffer( 240 ); -arr = new Complex64Array( buf, 64 ); -// returns - -offset = arr.byteOffset; -// returns 64 -``` - - - -#### Complex64Array.prototype.BYTES_PER_ELEMENT - -Size (in bytes) of each array element. - -```javascript -var arr = new Complex64Array( 10 ); -// returns - -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### Complex64Array.prototype.length - -Number of array elements. - -```javascript -var arr = new Complex64Array( 10 ); -// returns - -var len = arr.length; -// returns 10 -``` - -* * * - -### Methods - - - -#### Complex64Array.from( src\[, clbk\[, thisArg]] ) - -Creates a new 64-bit complex number array from an array-like object or an iterable. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -// Create an array from interleaved real and imaginary components: -var arr = Complex64Array.from( [ 1.0, -1.0 ] ); -// returns - -var len = arr.length; -// returns 1 - -// Create an array from an array of complex numbers: -arr = Complex64Array.from( [ new Complex64( 1.0, -1.0 ) ] ); -// returns - -len = arr.length; -// returns 1 -``` - -The iterator returned by an iterable must return either a complex number or an array-like object containing a real and imaginary component. - -```javascript -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var Float32Array = require( '@stdlib/array/float32' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var iter; -var arr; -var len; -var re; -var im; -var z; - -// Define a function which returns an iterator protocol-compliant object... -function iterable() { - var buf = new Float32Array( 2 ); - var i = 0; - return { - 'next': next - }; - - function next() { - i += 1; - if ( i < 3 ) { - // Reuse allocated memory... - buf[ 0 ] = i; - buf[ 1 ] = -i; - return { - 'value': buf - }; - } - return { - 'done': true - }; - } -} - -if ( ITERATOR_SYMBOL === null ) { - console.error( 'Environment does not support iterables.' ); -} else { - // Create an iterable: - iter = {}; - iter[ ITERATOR_SYMBOL ] = iterable; - - // Generate a complex number array: - arr = Complex64Array.from( iter ); - // returns - - len = arr.length; - // returns 2 - - z = arr.get( 0 ); - // returns - - re = realf( z ); - // returns 1.0 - - im = imagf( z ); - // returns -1.0 -} -``` - -To invoke a function for each `src` value, provide a callback function. If `src` is an iterable or an array-like object containing complex numbers, the callback must return either a complex number - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function map( z ) { - return new Complex64( realf(z)*2.0, imagf(z)*2.0 ); -} - -// Create a source array: -var src = [ new Complex64( 1.0, -1.0 ) ]; - -// Create a new complex number array by scaling the source array: -var arr = Complex64Array.from( src, map ); -// returns - -var len = arr.length; -// returns 1 - -var z = arr.get( 0 ); -// returns - -var re = realf( z ); -// returns 2.0 - -var im = imagf( z ); -// returns -2.0 -``` - -or an array-like object containing real and imaginary components - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -// Return a callback which reuses allocated memory... -function mapFcn() { - var buf = new Float32Array( 2 ); - return map; - - function map( z ) { - buf[ 0 ] = realf( z ) * 2.0; - buf[ 1 ] = imagf( z ) * 2.0; - return buf; - } -} - -// Create a source array: -var src = [ new Complex64( 1.0, -1.0 ), new Complex64( 2.0, -2.0 ) ]; - -// Create a new complex number array by scaling the source array: -var arr = Complex64Array.from( src, mapFcn() ); -// returns - -var len = arr.length; -// returns 2 - -var z = arr.get( 0 ); -// returns - -var re = realf( z ); -// returns 2.0 - -var im = imagf( z ); -// returns -2.0 - -z = arr.get( 1 ); -// returns - -re = realf( z ); -// returns 4.0 - -im = imagf( z ); -// returns -4.0 -``` - -If `src` is an array-like object containing interleaved real and imaginary components, the callback is invoked for each component and should return the transformed component value. - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function map( v ) { - return v * 2.0; -} - -// Create a source array: -var src = new Float32Array( [ 1.0, -1.0 ] ); - -// Create a new complex number array by scaling the source array: -var arr = Complex64Array.from( src, map ); -// returns - -var len = arr.length; -// returns 1 - -var z = arr.get( 0 ); -// returns - -var re = realf( z ); -// returns 2.0 - -var im = imagf( z ); -// returns -2.0 -``` - -A callback function is provided two arguments: - -- **value**: source value. -- **index**: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function map( z ) { - this.count += 1; - return new Complex64( realf(z)*2.0, imagf(z)*2.0 ); -} - -// Create a source array: -var src = [ new Complex64( 1.0, -1.0 ), new Complex64( 1.0, -1.0 ) ]; - -// Define an execution context: -var ctx = { - 'count': 0 -}; - -// Create a new complex number array by scaling the source array: -var arr = Complex64Array.from( src, map, ctx ); -// returns - -var len = arr.length; -// returns 2 - -var n = ctx.count; -// returns 2 -``` - - - -#### Complex64Array.of( element0\[, element1\[, ...elementN]] ) - -Creates a new 64-bit complex number array from a variable number of arguments. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -var arr = Complex64Array.of( 1.0, -1.0, 2.0, -2.0 ); -// returns - -var len = arr.length; -// returns 2 - -var z1 = new Complex64( 1.0, -1.0 ); -var z2 = new Complex64( 2.0, -2.0 ); - -arr = Complex64Array.of( z1, z2 ); -// returns - -len = arr.length; -// returns 2 -``` - - - -#### Complex64Array.prototype.at( i ) - -Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer positions. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 10 ); - -// Set the first, second, and last elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 9.0, -9.0 ], 9 ); - -// Get the first element: -var z = arr.at( 0 ); -// returns - -var re = realf( z ); -// returns 1.0 - -var im = imagf( z ); -// returns -1.0 - -// Get the last element: -z = arr.at( -1 ); -// returns - -re = realf( z ); -// returns 9.0 - -im = imagf( z ); -// returns -9.0 -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var arr = new Complex64Array( 10 ); - -var z = arr.at( 100 ); -// returns undefined - -z = arr.at( -100 ); -// returns undefined -``` - - - -#### Complex64Array.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within the array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 4 ); - -// Set the array elements: -arr.set( new Complex64( 1.0, -1.0 ), 0 ); -arr.set( new Complex64( 2.0, -2.0 ), 1 ); -arr.set( new Complex64( 3.0, -3.0 ), 2 ); -arr.set( new Complex64( 4.0, -4.0 ), 3 ); - -// Get the first array element: -var z = arr.get( 0 ); -// returns - -var re = realf( z ); -// returns 1.0 - -var im = imagf( z ); -// returns -1.0 - -// Get the second array element: -z = arr.get( 1 ); -// returns - -re = realf( z ); -// returns 2.0 - -im = imagf( z ); -// returns -2.0 - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 2 ); - -// Get the first array element: -z = arr.get( 0 ); -// returns - -re = realf( z ); -// returns 3.0 - -im = imagf( z ); -// returns -3.0 - -// Get the second array element: -z = arr.get( 1 ); -// returns - -re = realf( z ); -// returns 4.0 - -im = imagf( z ); -// returns -4.0 -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 4 ); - -// Set the array elements: -arr.set( new Complex64( 1.0, -1.0 ), 0 ); -arr.set( new Complex64( 2.0, -2.0 ), 1 ); -arr.set( new Complex64( 3.0, -3.0 ), 2 ); -arr.set( new Complex64( 4.0, -4.0 ), 3 ); - -// Get the third array element: -var z = arr.get( 2 ); -// returns - -var re = realf( z ); -// returns 3.0 - -var im = imagf( z ); -// returns -3.0 - -// Get the last array element: -z = arr.get( 3 ); -// returns - -re = realf( z ); -// returns 4.0 - -im = imagf( z ); -// returns -4.0 - -// Copy the first two elements to the last two elements: -arr.copyWithin( 2, 0, 2 ); - -// Get the third array element: -z = arr.get( 2 ); -// returns - -re = realf( z ); -// returns 1.0 - -im = imagf( z ); -// returns -1.0 - -// Get the last array element: -z = arr.get( 3 ); -// returns - -re = realf( z ); -// returns 2.0 - -im = imagf( z ); -// returns -2.0 -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 4 ); - -// Set the array elements: -arr.set( new Complex64( 1.0, -1.0 ), 0 ); -arr.set( new Complex64( 2.0, -2.0 ), 1 ); -arr.set( new Complex64( 3.0, -3.0 ), 2 ); -arr.set( new Complex64( 4.0, -4.0 ), 3 ); - -// Get the third array element: -var z = arr.get( 2 ); -// returns - -var re = realf( z ); -// returns 3.0 - -var im = imagf( z ); -// returns -3.0 - -// Get the last array element: -z = arr.get( 3 ); -// returns - -re = realf( z ); -// returns 4.0 - -im = imagf( z ); -// returns -4.0 - -// Copy the first two elements to the last two elements using negative indices: -arr.copyWithin( -2, -4, -2 ); - -// Get the third array element: -z = arr.get( 2 ); -// returns - -re = realf( z ); -// returns 1.0 - -im = imagf( z ); -// returns -1.0 - -// Get the last array element: -z = arr.get( 3 ); -// returns - -re = realf( z ); -// returns 2.0 - -im = imagf( z ); -// returns -2.0 -``` - - - -#### Complex64Array.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = [ - new Complex64( 1.0, -1.0 ), - new Complex64( 2.0, -2.0 ), - new Complex64( 3.0, -3.0 ) -]; -arr = new Complex64Array( arr ); - -// Create an iterator: -var it = arr.entries(); - -// Iterate over the key-value pairs... -var v = it.next().value; -// returns [ 0, ] - -var re = realf( v[ 1 ] ); -// returns 1.0 - -var im = imagf( v[ 1 ] ); -// returns -1.0 - -v = it.next().value; -// returns [ 1, ] - -re = realf( v[ 1 ] ); -// returns 2.0 - -im = imagf( v[ 1 ] ); -// returns -2.0 - -v = it.next().value; -// returns [ 2, ] - -re = realf( v[ 1 ] ); -// returns 3.0 - -im = imagf( v[ 1 ] ); -// returns -3.0 - -var bool = it.next().done; -// returns true -``` - -The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: - -- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. -- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. - - - -#### Complex64Array.prototype.every( predicate\[, thisArg] ) - -Returns a boolean indicating whether all elements pass a test. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function predicate( v ) { - return ( realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -// Check whether all elements pass a test: -var z = arr.every( predicate ); -// returns true -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 ); -} - -var arr = new Complex64Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.every( predicate, context ); -// returns true - -var count = context.count; -// returns 3 -``` - - - -#### Complex64Array.prototype.fill( value\[, start\[, end]] ) - -Returns a modified typed array filled with a fill value. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 3 ); - -// Set all elements to the same value: -arr.fill( new Complex64( 1.0, 1.0 ) ); - -var z = arr.get( 0 ); -// returns - -var re = realf( z ); -// returns 1.0 - -var im = imagf( z ); -// returns 1.0 - -z = arr.get( 2 ); -// returns - -re = realf( z ); -// returns 1.0 - -im = imagf( z ); -// returns 1.0 - -// Fill all elements starting from the second element: -arr.fill( new Complex64( 2.0, 2.0 ), 1 ); - -z = arr.get( 1 ); -// returns - -re = realf( z ); -// returns 2.0 - -im = imagf( z ); -// returns 2.0 - -z = arr.get( 2 ); -// returns - -re = realf( z ); -// returns 2.0 - -im = imagf( z ); -// returns 2.0 - -// Fill all elements from first element until the second-to-last element: -arr.fill( new Complex64( 3.0, 3.0 ), 0, 2 ); - -z = arr.get( 0 ); -// returns - -re = realf( z ); -// returns 3.0 - -im = imagf( z ); -// returns 3.0 - -z = arr.get( 1 ); -// returns - -re = realf( z ); -// returns 3.0 - -im = imagf( z ); -// returns 3.0 -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 3 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( new Complex64( 1.0, 1.0 ), 0, -1 ); - -var z = arr.get( 0 ); -// returns - -var re = realf( z ); -// returns 1.0 - -var im = imagf( z ); -// returns 1.0 - -z = arr.get( arr.length - 1 ); -// returns - -re = realf( z ); -// returns 0.0 - -im = imagf( z ); -// returns 0.0 -``` - - - -#### Complex64Array.prototype.filter( predicate\[, thisArg] ) - -Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function predicate( v ) { - return ( realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var out = arr.filter( predicate ); -// returns - -var len = out.length; -// returns 1 - -var z = out.get( 0 ); -// returns - -var re = realf( z ); -// returns 2.0 - -var im = imagf( z ); -// returns 2.0 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 && realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var out = arr.filter( predicate, context ); -// returns - -var len = out.length; -// returns 2 - -var count = context.count; -// returns 3 -``` - - - -#### Complex64Array.prototype.find( predicate\[, thisArg] ) - -Returns the first element in an array for which a predicate function returns a truthy value. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -function predicate( v ) { - return ( realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.find( predicate ); -// returns - -var re = realf( z ); -// returns 1.0 - -var im = imagf( z ); -// returns 1.0 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 && realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.find( predicate, context ); -// returns - -var re = realf( z ); -// returns 2.0 - -var im = imagf( z ); -// returns 2.0 - -var count = context.count; -// returns 2 -``` - - - -#### Complex64Array.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first element in an array for which a predicate function returns a truthy value. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function predicate( v ) { - return ( realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var idx = arr.findIndex( predicate ); -// returns 2 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 && realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var idx = arr.findIndex( predicate, context ); -// returns -1 - -var count = context.count; -// returns 3 -``` - - - -#### Complex64Array.prototype.findLast( predicate\[, thisArg] ) - -Returns the last element in an array for which a predicate function returns a truthy value. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -function predicate( v ) { - return ( realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.findLast( predicate ); -// returns - -var re = realf( z ); -// returns 3.0 - -var im = imagf( z ); -// returns 3.0 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 && realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var z = arr.findLast( predicate, context ); -// returns - -var re = realf( z ); -// returns 2.0 - -var im = imagf( z ); -// returns 2.0 - -var count = context.count; -// returns 2 -``` - - - -#### Complex64Array.prototype.findLastIndex( predicate\[, thisArg] ) - -Returns the index of the last element in an array for which a predicate function returns a truthy value. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function predicate( v ) { - return ( realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var idx = arr.findLastIndex( predicate ); -// returns 1 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( i >= 0 && realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var idx = arr.findLastIndex( predicate, context ); -// returns -1 - -var count = context.count; -// returns 3 -``` - - - -#### Complex64Array.prototype.forEach( callbackFn\[, thisArg] ) - -Invokes a function once for each array element. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -function log( v, i ) { - console.log( '%s: %s', i, v.toString() ); -} - -var arr = new Complex64Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -arr.forEach( log ); -/* => - 0: 1 + 1i - 1: 2 + 2i - 2: 3 + 3i -*/ -``` - -The invoked function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -function fcn( v, i ) { - this.count += 1; - console.log( '%s: %s', i, v.toString() ); -} - -var arr = new Complex64Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -arr.forEach( fcn, context ); -/* => - 0: 1 + 1i - 1: 2 + 2i - 2: 3 + 3i -*/ - -var count = context.count; -// returns 3 -``` - - - -#### Complex64Array.prototype.get( i ) - -Returns an array element located at a nonnegative integer position (index) `i`. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 10 ); - -// Set the first element: -arr.set( [ 1.0, -1.0 ], 0 ); - -// Get the first element: -var z = arr.get( 0 ); -// returns - -var re = realf( z ); -// returns 1.0 - -var im = imagf( z ); -// returns -1.0 -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var arr = new Complex64Array( 10 ); - -var z = arr.get( 100 ); -// returns undefined -``` - - - -#### Complex64Array.prototype.includes( searchElement\[, fromIndex] ) - -Returns a boolean indicating whether an array includes a provided value. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -var arr = new Complex64Array( 5 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); -arr.set( [ 4.0, -4.0 ], 3 ); -arr.set( [ 5.0, -5.0 ], 4 ); - -var bool = arr.includes( new Complex64( 3.0, -3.0 ) ); -// returns true - -bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 ); -// returns false - -bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 ); -// returns true -``` - - - -#### Complex64Array.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the first index at which a given element can be found. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -var arr = new Complex64Array( 5 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); -arr.set( [ 4.0, -4.0 ], 3 ); -arr.set( [ 2.0, -2.0 ], 4 ); - -var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) ); -// returns 2 - -idx = arr.indexOf( new Complex64( 2.0, -2.0 ), 2 ); -// returns 4 - -idx = arr.indexOf( new Complex64( 4.0, -4.0 ), -3 ); -// returns 3 -``` - -If `searchElement` is not present in the array, the method returns `-1`. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -var arr = new Complex64Array( 10 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); - -var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) ); -// returns -1 - -idx = arr.indexOf( new Complex64( 1.0, -1.0 ), 1 ); -// returns -1 -``` - - - -#### Complex64Array.prototype.join( \[separator] ) - -Returns a new string by concatenating all array elements. - -```javascript -var arr = new Complex64Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var str = arr.join(); -// returns '1 + 1i,2 - 2i,3 + 3i' -``` - -By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string. - -```javascript -var arr = new Complex64Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var str = arr.join( '/' ); -// returns '1 + 1i/2 - 2i/3 + 3i' -``` - - - -#### Complex64Array.prototype.keys() - -Returns an iterator for iterating over each index key in a typed array. - -```javascript -var arr = new Complex64Array( 2 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); - -var iter = arr.keys(); - -var v = iter.next().value; -// returns 0 - -v = iter.next().value; -// returns 1 - -var bool = iter.next().done; -// returns true -``` - -The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: - -- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. -- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. - - - -#### Complex64Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the last index at which a given element can be found. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -var arr = new Complex64Array( 5 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); -arr.set( [ 4.0, -4.0 ], 3 ); -arr.set( [ 2.0, -2.0 ], 4 ); - -var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) ); -// returns 2 - -idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), 2 ); -// returns 1 - -idx = arr.lastIndexOf( new Complex64( 4.0, -4.0 ), -1 ); -// returns 3 -``` - -If `searchElement` is not present in the array, the method returns `-1`. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -var arr = new Complex64Array( 10 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); - -var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) ); -// returns -1 - -idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), 0 ); -// returns -1 -``` - - - -#### Complex64Array.prototype.map( callbackFn\[, thisArg] ) - -Returns a new array with each element being the result of a provided callback function. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function scale( v ) { - return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var out = arr.map( scale ); -// returns - -var z = out.get( 0 ); -// returns - -var re = realf( z ); -// returns 2.0 - -var im = imagf( z ); -// returns -2.0 -``` - -The callback function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function scale( v ) { - this.count += 1; - return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var out = arr.map( scale, context ); -// returns - -var count = context.count; -// returns 3 -``` - - - -#### Complex64Array.prototype.reduce( reducerFn\[, initialValue] ) - -Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var caddf = require( '@stdlib/complex/float32/base/add' ); - -var arr = new Complex64Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.reduce( caddf ); -// returns - -var re = realf( z ); -// returns 6.0 - -var im = imagf( z ); -// returns 6.0 -``` - -The reducer function is provided four arguments: - -- **acc**: accumulated result. -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); - -function reducer( acc, v ) { - acc += realf( v ); - return acc; -} - -var arr = new Complex64Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.reduce( reducer, 0.0 ); -// returns 6.0 -``` - - - -#### Complex64Array.prototype.reduceRight( reducerFn\[, initialValue] ) - -Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var caddf = require( '@stdlib/complex/float32/base/add' ); - -var arr = new Complex64Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.reduceRight( caddf ); -// returns - -var re = realf( z ); -// returns 6.0 - -var im = imagf( z ); -// returns 6.0 -``` - -The reducer function is provided four arguments: - -- **acc**: accumulated result. -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -By default, the function initializes the accumulated result to the last element in the array and passes the second-last array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the last array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); - -function reducer( acc, v ) { - acc += realf( v ); - return acc; -} - -var arr = new Complex64Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var z = arr.reduceRight( reducer, 0.0 ); -// returns 6.0 -``` - - - -#### Complex64Array.prototype.reverse() - -Reverses an array in-place. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var out = arr.reverse(); -// returns - -var z = out.get( 0 ); -// returns - -var re = realf( z ); -// returns 3.0 - -var im = imagf( z ); -// returns 3.0 - -z = out.get( 1 ); -// returns - -re = realf( z ); -// returns 2.0 - -im = imagf( z ); -// returns 2.0 - -z = out.get( 2 ); -// returns - -re = realf( z ); -// returns 1.0 - -im = imagf( z ); -// returns 1.0 -``` - - - -#### Complex64Array.prototype.set( z\[, i] ) - -Sets one or more array elements. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 10 ); - -// Get the first element: -var z = arr.get( 0 ); -// returns - -var re = realf( z ); -// returns 0.0 - -var im = imagf( z ); -// returns 0.0 - -// Set the first element: -arr.set( new Complex64( 1.0, -1.0 ) ); - -// Get the first element: -z = arr.get( 0 ); -// returns - -re = realf( z ); -// returns 1.0 - -im = imagf( z ); -// returns -1.0 -``` - -By default, the method sets array elements starting at position (index) `i = 0`. To set elements starting elsewhere in the array, provide an index argument `i`. - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 10 ); - -// Get the fifth element: -var z = arr.get( 4 ); -// returns - -var re = realf( z ); -// returns 0.0 - -var im = imagf( z ); -// returns 0.0 - -// Set the fifth element: -arr.set( new Complex64( 1.0, -1.0 ), 4 ); - -// Get the fifth element: -z = arr.get( 4 ); -// returns - -re = realf( z ); -// returns 1.0 - -im = imagf( z ); -// returns -1.0 -``` - -In addition to providing a complex number, to set one or more array elements, provide an array-like object containing either complex numbers - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 10 ); - -// Define an array of complex numbers: -var buf = [ - new Complex64( 1.0, -1.0 ), - new Complex64( 2.0, -2.0 ), - new Complex64( 3.0, -3.0 ) -]; - -// Set the fifth, sixth, and seventh elements: -arr.set( buf, 4 ); - -// Get the sixth element: -var z = arr.get( 5 ); -// returns - -var re = realf( z ); -// returns 2.0 - -var im = imagf( z ); -// returns -2.0 -``` - -or interleaved real and imaginary components - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 10 ); - -// Define an interleaved array of real and imaginary components: -var buf = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - -// Set the fifth, sixth, and seventh elements: -arr.set( buf, 4 ); - -// Get the sixth element: -var z = arr.get( 5 ); -// returns - -var re = realf( z ); -// returns 2.0 - -var im = imagf( z ); -// returns -2.0 -``` - -A few notes: - -- If `i` is out-of-bounds, the method throws an error. -- If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error. -- If provided a [typed array][@stdlib/array/typed] which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range. - - - -#### Complex64Array.prototype.slice( \[start\[, end]] ) - -Copies a portion of a typed array to a new typed array. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var out = arr.slice(); -// returns - -var len = out.length; -// returns 4 - -var z = out.get( 0 ); -// returns - -var re = realf( z ); -// returns 1.0 - -var im = imagf( z ); -// returns 2.0 - -z = out.get( len-1 ); -// returns - -re = realf( z ); -// returns 7.0 - -im = imagf( z ); -// returns 8.0 -``` - -By default, the method returns a typed array beginning with the first array element. To specify an alternative array index at which to begin, provide a `start` index (inclusive). - -```javascript -var imagf = require( '@stdlib/complex/float32/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); - -var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var out = arr.slice( 1 ); -// returns - -var len = out.length; -// returns 3 - -var z = out.get( 0 ); -// returns - -var re = realf( z ); -// returns 3.0 - -var im = imagf( z ); -// returns 4.0 -``` - -By default, the method returns a typed array which includes all array elements after `start`. To limit the number of array elements after `start`, provide an `end` index (exclusive). - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var out = arr.slice( 1, -1 ); -// returns - -var len = out.length; -// returns 2 - -var z = out.get( 0 ); -// returns - -var re = realf( z ); -// returns 3.0 - -var im = imagf( z ); -// returns 4.0 - -z = out.get( len-1 ); -// returns - -re = realf( z ); -// returns 5.0 - -im = imagf( z ); -// returns 6.0 -``` - - - -#### Complex64Array.prototype.some( predicate\[, thisArg] ) - -Returns a boolean indicating whether at least one element passes a test. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function predicate( v ) { - return ( realf( v ) === imagf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -// Check whether at least one element passes a test: -var z = arr.some( predicate ); -// returns true -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function predicate( v, i ) { - this.count += 1; - return ( imagf( v ) === realf( v ) ); -} - -var arr = new Complex64Array( 3 ); - -var context = { - 'count': 0 -}; - -// Set the first three elements: -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, -3.0 ], 2 ); - -var z = arr.some( predicate, context ); -// returns true - -var count = context.count; -// returns 2 -``` - - - -#### Complex64Array.prototype.sort( compareFcn ) - -Sorts an array in-place. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function compare( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = realf( a ); - re2 = realf( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imagf( a ); - im2 = imagf( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - -var arr = new Complex64Array( 3 ); - -arr.set( [ 3.0, -3.0 ], 0 ); -arr.set( [ 1.0, -1.0 ], 1 ); -arr.set( [ 2.0, -2.0 ], 2 ); - -var out = arr.sort( compare ); -// returns - -var z = out.get( 0 ); -// returns - -var re = realf( z ); -// returns 1.0 - -var im = imagf( z ); -// returns -1.0 - -z = out.get( 1 ); -// returns - -re = realf( z ); -// returns 2.0 - -im = imagf( z ); -// returns -2.0 - -z = out.get( 2 ); -// returns - -re = realf( z ); -// returns 3.0 - -im = imagf( z ); -// returns -3.0 -``` - -The `compareFcn` determines the order of the elements. The function is called with the following arguments: - -- **a**: the first element for comparison. -- **b**: the second element for comparison. - -The function should return a number where: - -- a negative value indicates that `a` should come before `b`. -- a positive value indicates that `a` should come after `b`. -- zero or `NaN` indicates that `a` and `b` are considered equal. - -In contrast to real numbers, one cannot define a default order relation which is compatible with multiplication. Accordingly, users **must** explicitly provide a `compareFcn` argument and are thus responsible for specifying a complex number ordering. - - - -#### Complex64Array.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var subarr = arr.subarray(); -// returns - -var len = subarr.length; -// returns 4 - -var z = subarr.get( 0 ); -// returns - -var re = realf( z ); -// returns 1.0 - -var im = imagf( z ); -// returns 2.0 - -z = subarr.get( len-1 ); -// returns - -re = realf( z ); -// returns 7.0 - -im = imagf( z ); -// returns 8.0 -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - -```javascript -var imagf = require( '@stdlib/complex/float32/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); - -var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var subarr = arr.subarray( 1 ); -// returns - -var len = subarr.length; -// returns 3 - -var z = subarr.get( 0 ); -// returns - -var re = realf( z ); -// returns 3.0 - -var im = imagf( z ); -// returns 4.0 -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - -var subarr = arr.subarray( 1, -1 ); -// returns - -var len = subarr.length; -// returns 2 - -var z = subarr.get( 0 ); -// returns - -var re = realf( z ); -// returns 3.0 - -var im = imagf( z ); -// returns 4.0 - -z = subarr.get( len-1 ); -// returns - -re = realf( z ); -// returns 5.0 - -im = imagf( z ); -// returns 6.0 -``` - - - -#### Complex64Array.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific string. - -```javascript -var arr = new Complex64Array( 2 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); - -var str = arr.toLocaleString(); -// returns '1 + 1i,2 + 2i' -``` - -The method supports the following arguments: - -- **locales**: a string with a BCP 47 language tag or an array of such strings. -- **options**: configuration properties. - - - -#### Complex64Array.prototype.toReversed() - -Returns a new typed array containing the elements in reversed order. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -var arr = new Complex64Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var out = arr.toReversed(); -// returns - -var z = out.get( 0 ); -// returns - -var re = realf( z ); -// returns 3.0 - -var im = imagf( z ); -// returns 3.0 - -z = out.get( 1 ); -// returns - -re = realf( z ); -// returns 2.0 - -im = imagf( z ); -// returns 2.0 - -z = out.get( 2 ); -// returns - -re = realf( z ); -// returns 1.0 - -im = imagf( z ); -// returns 1.0 -``` - - - -#### Complex64Array.prototype.toSorted( compareFcn ) - -Returns a new typed array containing the elements in sorted order. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - -function compare( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = realf( a ); - re2 = realf( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imagf( a ); - im2 = imagf( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - -var arr = new Complex64Array( 3 ); - -arr.set( [ 3.0, -3.0 ], 0 ); -arr.set( [ 1.0, -1.0 ], 1 ); -arr.set( [ 2.0, -2.0 ], 2 ); - -var out = arr.toSorted( compare ); -// returns - -var z = out.get( 0 ); -// returns - -var re = realf( z ); -// returns 1.0 - -var im = imagf( z ); -// returns -1.0 - -z = out.get( 1 ); -// returns - -re = realf( z ); -// returns 2.0 - -im = imagf( z ); -// returns -2.0 - -z = out.get( 2 ); -// returns - -re = realf( z ); -// returns 3.0 - -im = imagf( z ); -// returns -3.0 -``` - -The `compareFcn` determines the order of the elements. The function is called with the following arguments: - -- **a**: the first element for comparison. -- **b**: the second element for comparison. - -The function should return a number where: - -- a negative value indicates that `a` should come before `b`. -- a positive value indicates that `a` should come after `b`. -- zero or `NaN` indicates that `a` and `b` are considered equal. - -In contrast to real numbers, one cannot define a default order relation which is compatible with multiplication. Accordingly, users **must** explicitly provide a `compareFcn` argument and are thus responsible for specifying a complex number ordering. - - - -#### Complex64Array.prototype.toString() - -Serializes an array as a string. - -```javascript -var arr = new Complex64Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 2 ); - -var str = arr.toString(); -// returns '1 + 1i,2 - 2i,3 + 3i' -``` - - - -#### Complex64Array.prototype.values() - -Returns an iterator for iterating over each value in a typed array. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var arr = new Complex64Array( 2 ); - -arr.set( [ 1.0, -1.0 ], 0 ); -arr.set( [ 2.0, -2.0 ], 1 ); - -var iter = arr.values(); - -var v = iter.next().value; -// returns - -var re = realf( v ); -// returns 1.0 - -var im = imagf( v ); -// returns -1.0 - -v = iter.next().value; -// returns - -re = realf( v ); -// returns 2.0 - -im = imagf( v ); -// returns -2.0 - -var bool = iter.next().done; -// returns true -``` - -The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: - -- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. -- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object. - - - -#### Complex64Array.prototype.with( index, value ) - -Returns a new typed array with the element at a provided index replaced with a provided value. - -```javascript -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - -var arr = new Complex64Array( 3 ); - -arr.set( [ 1.0, 1.0 ], 0 ); -arr.set( [ 2.0, 2.0 ], 1 ); -arr.set( [ 3.0, 3.0 ], 1 ); - -var out = arr.with( 0, new Complex64( 4.0, 4.0 ) ); -// returns - -var z = out.get( 0 ); -// returns - -var re = realf( z ); -// returns 4.0 - -var im = imagf( z ); -// returns 4.0 -``` - -
- - - - - -
- -* * * - -## Notes - -- While a `Complex64Array` _strives_ to maintain (but does not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: - - - The constructor does **not** require the `new` operator. - - The constructor and associated methods support a broader variety of input argument types in order to better accommodate complex number input. - - Accessing array elements using bracket syntax (e.g., `Z[i]`) is **not** supported. Instead, one **must** use the `.get()` method which returns a value compatible with complex number output. - - The `set` method has extended behavior in order to support complex numbers. - -
- - - - - -
- -* * * - -## Examples - - - -```javascript -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Float32Array = require( '@stdlib/array/float32' ); -var logEach = require( '@stdlib/console/log-each' ); -var Complex64Array = require( '@stdlib/array/complex64' ); - -// Create a complex array by specifying a length: -var out = new Complex64Array( 3 ); -logEach( '%s', out ); - -// Create a complex array from an array of complex numbers: -var arr = [ - new Complex64( 1.0, -1.0 ), - new Complex64( -3.14, 3.14 ), - new Complex64( 0.5, 0.5 ) -]; -out = new Complex64Array( arr ); -logEach( '%s', out ); - -// Create a complex array from an interleaved typed array: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex64Array( arr ); -logEach( '%s', out ); - -// Create a complex array from an array buffer: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex64Array( arr.buffer ); -logEach( '%s', out ); - -// Create a complex array from an array buffer view: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex64Array( arr.buffer, 8, 2 ); -logEach( '%s', out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/complex64/benchmark/benchmark.at.js b/complex64/benchmark/benchmark.at.js deleted file mode 100644 index 3d5f948fb..000000000 --- a/complex64/benchmark/benchmark.at.js +++ /dev/null @@ -1,86 +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 bench = require( '@stdlib/bench' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::nonnegative_indices:at', function benchmark( b ) { - var arr; - var N; - var z; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.at( i%N ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::negative_indices:at', function benchmark( b ) { - var arr; - var N; - var z; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.at( -(i%N)-1 ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.copy_within.js b/complex64/benchmark/benchmark.copy_within.js deleted file mode 100644 index dee627273..000000000 --- a/complex64/benchmark/benchmark.copy_within.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'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin:len=5', function benchmark( b ) { - var arr; - var buf; - var i; - - arr = []; - for ( i = 0; i < 5; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - buf = arr.buffer; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( buf[ 0 ] !== i ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( buf[ 0 ] !== buf[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.copy_within.length.js b/complex64/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 898409cdd..000000000 --- a/complex64/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var buf; - var i; - - arr = []; - for ( i = 0; i < len+1; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - buf = arr.buffer; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = i; - arr.copyWithin( 1, 0 ); - if ( buf[ 0 ] !== i ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( buf[ 0 ] !== buf[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.entries.js b/complex64/benchmark/benchmark.entries.js deleted file mode 100644 index 52eeda61e..000000000 --- a/complex64/benchmark/benchmark.entries.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries:len=10', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.every.js b/complex64/benchmark/benchmark.every.js deleted file mode 100644 index b98046b73..000000000 --- a/complex64/benchmark/benchmark.every.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex64( v ); - } -}); diff --git a/complex64/benchmark/benchmark.every.length.js b/complex64/benchmark/benchmark.every.length.js deleted file mode 100644 index d83bd7210..000000000 --- a/complex64/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,118 +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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex64Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( realf( value ) === imagf( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.fill.js b/complex64/benchmark/benchmark.fill.js deleted file mode 100644 index 0c3d9e2aa..000000000 --- a/complex64/benchmark/benchmark.fill.js +++ /dev/null @@ -1,58 +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 bench = require( '@stdlib/bench' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ - new Complex64( 1.0, 1.0 ), - new Complex64( 2.0, 2.0 ), - new Complex64( 3.0, 3.0 ) - ]; - arr = new Complex64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.fill.length.js b/complex64/benchmark/benchmark.fill.length.js deleted file mode 100644 index bf4df7eaf..000000000 --- a/complex64/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,102 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Complex64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Complex64( 1.0, 1.0 ), - new Complex64( 2.0, 2.0 ), - new Complex64( 3.0, 3.0 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.fill( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.filter.js b/complex64/benchmark/benchmark.filter.js deleted file mode 100644 index 6c0babb03..000000000 --- a/complex64/benchmark/benchmark.filter.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex64( v ); - } -}); diff --git a/complex64/benchmark/benchmark.filter.length.js b/complex64/benchmark/benchmark.filter.length.js deleted file mode 100644 index 43d50db8a..000000000 --- a/complex64/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,118 +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 bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex64Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( realf( value ) === imagf( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.find.js b/complex64/benchmark/benchmark.find.js deleted file mode 100644 index 7c40a075f..000000000 --- a/complex64/benchmark/benchmark.find.js +++ /dev/null @@ -1,55 +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 bench = require( '@stdlib/bench' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var arr; - var z; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.find( predicate ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex64( v ); - } -}); diff --git a/complex64/benchmark/benchmark.find.length.js b/complex64/benchmark/benchmark.find.length.js deleted file mode 100644 index 1cb75ba67..000000000 --- a/complex64/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex64Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( realf( value ) === -imagf( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr.push( new Complex64( len-1, -( len-1 ) ) ); - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var z; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.find( predicate ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.find_index.js b/complex64/benchmark/benchmark.find_index.js deleted file mode 100644 index 42f097137..000000000 --- a/complex64/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var arr; - var idx; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex64( v ); - } -}); diff --git a/complex64/benchmark/benchmark.find_index.length.js b/complex64/benchmark/benchmark.find_index.length.js deleted file mode 100644 index b06269729..000000000 --- a/complex64/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex64Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( realf( value ) === -imagf( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr.push( new Complex64( len-1, -( len-1 ) ) ); - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.find_last.js b/complex64/benchmark/benchmark.find_last.js deleted file mode 100644 index d342cd80d..000000000 --- a/complex64/benchmark/benchmark.find_last.js +++ /dev/null @@ -1,55 +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 bench = require( '@stdlib/bench' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findLast', function benchmark( b ) { - var arr; - var z; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.findLast( predicate ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex64( v ); - } -}); diff --git a/complex64/benchmark/benchmark.find_last.length.js b/complex64/benchmark/benchmark.find_last.length.js deleted file mode 100644 index e10c9ee84..000000000 --- a/complex64/benchmark/benchmark.find_last.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex64Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( realf( value ) === -imagf( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - arr.push( new Complex64( 1, -1 ) ); - for ( i = 1; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var z; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.findLast( predicate ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findLast:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.find_last_index.js b/complex64/benchmark/benchmark.find_last_index.js deleted file mode 100644 index 61ba7ba95..000000000 --- a/complex64/benchmark/benchmark.find_last_index.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findLastIndex', function benchmark( b ) { - var arr; - var idx; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findLastIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex64( v ); - } -}); diff --git a/complex64/benchmark/benchmark.find_last_index.length.js b/complex64/benchmark/benchmark.find_last_index.length.js deleted file mode 100644 index 670314061..000000000 --- a/complex64/benchmark/benchmark.find_last_index.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex64Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( realf( value ) === -imagf( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - arr.push( new Complex64( 1, -1 ) ); - for ( i = 1; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.findLastIndex( predicate ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findLastIndex:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.for_each.js b/complex64/benchmark/benchmark.for_each.js deleted file mode 100644 index 07555a187..000000000 --- a/complex64/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( check ); - if ( arr.length !== 2 ) { - b.fail( 'should not change an array length' ); - } - } - b.toc(); - if ( arr.length !== 2 ) { - b.fail( 'should not change an array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function check( v ) { - if ( !isComplex64( v ) ) { - b.fail( 'should be a complex number' ); - } - } -}); diff --git a/complex64/benchmark/benchmark.for_each.length.js b/complex64/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ff569c350..000000000 --- a/complex64/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,109 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( callback ); - if ( arr.length !== len ) { - b.fail( 'should not change an array length' ); - } - } - b.toc(); - if ( arr.length !== len ) { - b.fail( 'should not change an array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function callback( value ) { - if ( realf( value ) !== imagf( value ) ) { - throw new Error( 'something went wrong' ); - } - } - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.from.js b/complex64/benchmark/benchmark.from.js deleted file mode 100644 index 747b0b294..000000000 --- a/complex64/benchmark/benchmark.from.js +++ /dev/null @@ -1,382 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float32Array = require( './../../float32' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( pkg+'::complex_typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Complex64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex_typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Complex64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex_typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Complex64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': [ 1.0, 1.0 ] - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.from( createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': [ 1.0, 1.0 ] - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - v[ 0 ] += 1.0; - v[ 1 ] += 1.0; - return v; - } -}); diff --git a/complex64/benchmark/benchmark.get.js b/complex64/benchmark/benchmark.get.js deleted file mode 100644 index 08ded3b53..000000000 --- a/complex64/benchmark/benchmark.get.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':get', function benchmark( b ) { - var arr; - var N; - var z; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = arr.get( i%N ); - if ( typeof z !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64( z ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.includes.js b/complex64/benchmark/benchmark.includes.js deleted file mode 100644 index a591b3944..000000000 --- a/complex64/benchmark/benchmark.includes.js +++ /dev/null @@ -1,59 +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 bench = require( '@stdlib/bench' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - v = new Complex64( 10.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.includes( v, 0 ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.includes.length.js b/complex64/benchmark/benchmark.includes.length.js deleted file mode 100644 index 7c5ad8388..000000000 --- a/complex64/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,107 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( new Complex64( i, -i ) ); - } - arr.push( new Complex64( i, i ) ); - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - v = new Complex64( len-1, len-1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.index_of.js b/complex64/benchmark/benchmark.index_of.js deleted file mode 100644 index 185d3fb80..000000000 --- a/complex64/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,59 +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 bench = require( '@stdlib/bench' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var arr; - var idx; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - v = new Complex64( 10.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.indexOf( v, 0 ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.index_of.length.js b/complex64/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 7d6dceb67..000000000 --- a/complex64/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,107 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( new Complex64( i, -i ) ); - } - arr.push( new Complex64( i, i ) ); - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var v; - var i; - - v = new Complex64( len-1, len-1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.indexOf( v ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.join.js b/complex64/benchmark/benchmark.join.js deleted file mode 100644 index 135683346..000000000 --- a/complex64/benchmark/benchmark.join.js +++ /dev/null @@ -1,50 +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 bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.join.length.js b/complex64/benchmark/benchmark.join.length.js deleted file mode 100644 index 2fbba07ff..000000000 --- a/complex64/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,102 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.join( '/' ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.js b/complex64/benchmark/benchmark.js deleted file mode 100644 index 6ebc9ab66..000000000 --- a/complex64/benchmark/benchmark.js +++ /dev/null @@ -1,359 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ArrayBuffer = require( './../../buffer' ); -var Float32Array = require( './../../float32' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Complex64Array(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Complex64Array; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Complex64Array( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Complex64Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,complex_typed_array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Complex64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Complex64Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Complex64Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Complex64Array( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Complex64Array( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Complex64Array( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Complex64Array( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Complex64Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Complex64Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Complex64Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Complex64Array(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.keys.js b/complex64/benchmark/benchmark.keys.js deleted file mode 100644 index ff9089346..000000000 --- a/complex64/benchmark/benchmark.keys.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys:len=2', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.keys.length.js b/complex64/benchmark/benchmark.keys.length.js deleted file mode 100644 index 51d4d3178..000000000 --- a/complex64/benchmark/benchmark.keys.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':keys:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.last_index_of.js b/complex64/benchmark/benchmark.last_index_of.js deleted file mode 100644 index dede9f2b5..000000000 --- a/complex64/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,59 +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 bench = require( '@stdlib/bench' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var arr; - var idx; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - v = new Complex64( 10.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.lastIndexOf( v, 9 ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.last_index_of.length.js b/complex64/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index f540a28fe..000000000 --- a/complex64/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,106 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, -i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var v; - var i; - - v = new Complex64( 0, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.lastIndexOf( v ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.length.js b/complex64/benchmark/benchmark.length.js deleted file mode 100644 index 35ea7ce03..000000000 --- a/complex64/benchmark/benchmark.length.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Complex64Array( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.map.js b/complex64/benchmark/benchmark.map.js deleted file mode 100644 index bef5e68a8..000000000 --- a/complex64/benchmark/benchmark.map.js +++ /dev/null @@ -1,58 +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 bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( scale ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function scale( v ) { - return new Complex64( realf(v)*2.0, imagf(v)*2.0 ); - } -}); diff --git a/complex64/benchmark/benchmark.map.length.js b/complex64/benchmark/benchmark.map.length.js deleted file mode 100644 index 07e81e1ea..000000000 --- a/complex64/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,104 +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 bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var identity = require( '@stdlib/utils/identity-function' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( identity ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.of.js b/complex64/benchmark/benchmark.of.js deleted file mode 100644 index 06b280a3c..000000000 --- a/complex64/benchmark/benchmark.of.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.of(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::interleaved:of:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.of.apply( Complex64Array, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex_numbers:of:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - for ( i = 0; i < 5; i++ ) { - buf.push( new Complex64( 1.0, 1.0 ) ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Complex64Array.of.apply( Complex64Array, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Complex64Array) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.reduce.js b/complex64/benchmark/benchmark.reduce.js deleted file mode 100644 index e81217709..000000000 --- a/complex64/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,52 +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 bench = require( '@stdlib/bench' ); -var caddf = require( '@stdlib/complex/float32/base/add' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( caddf ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplexLike( out ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.reduce.length.js b/complex64/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 0c211304c..000000000 --- a/complex64/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,104 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var caddf = require( '@stdlib/complex/float32/base/add' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( caddf ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplexLike( out ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.reduce_right.js b/complex64/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 64a5d97ad..000000000 --- a/complex64/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var caddf = require( '@stdlib/complex/float32/base/add' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( caddf ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplexLike( out ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.reduce_right.length.js b/complex64/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index e5e31412b..000000000 --- a/complex64/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,104 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var caddf = require( '@stdlib/complex/float32/base/add' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( caddf ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplexLike( out ) ) { - b.fail( 'should return a complex number' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.reverse.js b/complex64/benchmark/benchmark.reverse.js deleted file mode 100644 index 233c1ae83..000000000 --- a/complex64/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,51 +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 bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.reverse.length.js b/complex64/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 9343b34b0..000000000 --- a/complex64/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,103 +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 bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.set.js b/complex64/benchmark/benchmark.set.js deleted file mode 100644 index 38af92c21..000000000 --- a/complex64/benchmark/benchmark.set.js +++ /dev/null @@ -1,161 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float32Array = require( './../../float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::complex_number:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var arr; - var buf; - var M; - var N; - var v; - var i; - - values = new Float32Array( 20 ); - M = values.length; - for ( i = 0; i < M; i++ ) { - values[ i ] = i; - } - - arr = new Complex64Array( values ); - N = arr.length; - - buf = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - buf[ 1 ] = values[ (i+1)%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex_typed_array:set', function benchmark( b ) { - var values; - var arr; - var buf; - var M; - var N; - var v; - var i; - - values = new Float32Array( 20 ); - M = values.length; - for ( i = 0; i < M; i++ ) { - values[ i ] = i; - } - - arr = new Complex64Array( values ); - N = arr.length; - - buf = new Complex64Array( 1 ); - buf.set( new Complex64( 1.0, -1.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( buf, i%N ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.set.length.js b/complex64/benchmark/benchmark.set.length.js deleted file mode 100644 index 731f7ff7c..000000000 --- a/complex64/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,117 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randu = require( '@stdlib/random/base/randu' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - var i; - - arr1 = []; - arr2 = []; - arr3 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( new Complex64( i, i ) ); - arr2.push( new Complex64( randu(), randu() ) ); - arr3.push( new Complex64( randu(), -randu() ) ); - } - arr1 = new Complex64Array( arr1 ); - - values = [ - new Complex64Array( arr2 ), - new Complex64Array( arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 4; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.slice.js b/complex64/benchmark/benchmark.slice.js deleted file mode 100644 index 6bddeabf9..000000000 --- a/complex64/benchmark/benchmark.slice.js +++ /dev/null @@ -1,51 +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 bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.slice.length.js b/complex64/benchmark/benchmark.slice.length.js deleted file mode 100644 index 7cc75f783..000000000 --- a/complex64/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,103 +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 bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.some.js b/complex64/benchmark/benchmark.some.js deleted file mode 100644 index dc7d7c6d6..000000000 --- a/complex64/benchmark/benchmark.some.js +++ /dev/null @@ -1,56 +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 bench = require( '@stdlib/bench' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Complex64Array( [ 1, 3, 4, 5 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return isComplex64( v ); - } -}); diff --git a/complex64/benchmark/benchmark.some.length.js b/complex64/benchmark/benchmark.some.length.js deleted file mode 100644 index cf8b26866..000000000 --- a/complex64/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,119 +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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {Complex64} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {Complex64Array} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return ( realf( value ) === imagf( value ) ); -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len-1; i++ ) { - arr.push( new Complex64( i, -i ) ); - } - arr.push( new Complex64( i, i ) ); - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.sort.js b/complex64/benchmark/benchmark.sort.js deleted file mode 100644 index 1c4762929..000000000 --- a/complex64/benchmark/benchmark.sort.js +++ /dev/null @@ -1,88 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex64} a - first value for comparison -* @param {Complex64} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = realf( a ); - re2 = realf( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imagf( a ); - im2 = imagf( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.sort( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.sort.length.js b/complex64/benchmark/benchmark.sort.length.js deleted file mode 100644 index 48670b7cc..000000000 --- a/complex64/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,137 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex64} a - first value for comparison -* @param {Complex64} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = realf( a ); - re2 = realf( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imagf( a ); - im2 = imagf( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.sort( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.subarray.js b/complex64/benchmark/benchmark.subarray.js deleted file mode 100644 index ed57aaa76..000000000 --- a/complex64/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +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 bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.subarray.length.js b/complex64/benchmark/benchmark.subarray.length.js deleted file mode 100644 index a261987c3..000000000 --- a/complex64/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,103 +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 bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.to_locale_string.js b/complex64/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 046fa8fc7..000000000 --- a/complex64/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.to_locale_string.length.js b/complex64/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 2a815bcac..000000000 --- a/complex64/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,102 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.to_reversed.js b/complex64/benchmark/benchmark.to_reversed.js deleted file mode 100644 index 9cce98d32..000000000 --- a/complex64/benchmark/benchmark.to_reversed.js +++ /dev/null @@ -1,51 +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 bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toReversed', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toReversed(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.to_reversed.length.js b/complex64/benchmark/benchmark.to_reversed.length.js deleted file mode 100644 index 9d8e7f6f9..000000000 --- a/complex64/benchmark/benchmark.to_reversed.length.js +++ /dev/null @@ -1,103 +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 bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toReversed(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toReversed:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.to_sorted.js b/complex64/benchmark/benchmark.to_sorted.js deleted file mode 100644 index 4ebcfcc40..000000000 --- a/complex64/benchmark/benchmark.to_sorted.js +++ /dev/null @@ -1,88 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex64} a - first value for comparison -* @param {Complex64} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = realf( a ); - re2 = realf( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imagf( a ); - im2 = imagf( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - - -// MAIN // - -bench( pkg+':toSorted', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toSorted( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.to_sorted.length.js b/complex64/benchmark/benchmark.to_sorted.length.js deleted file mode 100644 index 507a70553..000000000 --- a/complex64/benchmark/benchmark.to_sorted.length.js +++ /dev/null @@ -1,137 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex64} a - first value for comparison -* @param {Complex64} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = realf( a ); - re2 = realf( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imagf( a ); - im2 = imagf( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toSorted( compareFcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toSorted:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.to_string.js b/complex64/benchmark/benchmark.to_string.js deleted file mode 100644 index 7af67206c..000000000 --- a/complex64/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,50 +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 bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.to_string.length.js b/complex64/benchmark/benchmark.to_string.length.js deleted file mode 100644 index b9a3ddbbb..000000000 --- a/complex64/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,102 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.values.js b/complex64/benchmark/benchmark.values.js deleted file mode 100644 index e241e0dd6..000000000 --- a/complex64/benchmark/benchmark.values.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values:len=2', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.values.length.js b/complex64/benchmark/benchmark.values.length.js deleted file mode 100644 index 30620c7ef..000000000 --- a/complex64/benchmark/benchmark.values.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( new Complex64( i, i ) ); - } - arr = new Complex64Array( arr ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var iter; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':values:len='+len, f ); - } -} - -main(); diff --git a/complex64/benchmark/benchmark.with.js b/complex64/benchmark/benchmark.with.js deleted file mode 100644 index 4216eb3f8..000000000 --- a/complex64/benchmark/benchmark.with.js +++ /dev/null @@ -1,58 +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 bench = require( '@stdlib/bench' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':with', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = [ - new Complex64( 1.0, 1.0 ), - new Complex64( 2.0, 2.0 ), - new Complex64( 3.0, 3.0 ) - ]; - arr = new Complex64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%arr.length, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/complex64/benchmark/benchmark.with.length.js b/complex64/benchmark/benchmark.with.length.js deleted file mode 100644 index 385ee2121..000000000 --- a/complex64/benchmark/benchmark.with.length.js +++ /dev/null @@ -1,102 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var pkg = require( './../package.json' ).name; -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Complex64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Complex64( 1.0, 1.0 ), - new Complex64( 2.0, 2.0 ), - new Complex64( 3.0, 3.0 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i%len, values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isComplex64Array( out ) ) { - b.fail( 'should return a Complex64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':with:len='+len, f ); - } -} - -main(); diff --git a/complex64/docs/repl.txt b/complex64/docs/repl.txt deleted file mode 100644 index ae7603c7d..000000000 --- a/complex64/docs/repl.txt +++ /dev/null @@ -1,1421 +0,0 @@ - -{{alias}}() - A 64-bit complex number array. - - Returns - ------- - out: Complex64Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Creates a 64-bit complex number array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Complex64Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var len = arr.length - 10 - - -{{alias}}( complexarray ) - Creates a 64-bit complex number array from another complex number array. - - Parameters - ---------- - complexarray: Complex64Array - Complex array from which to generate another complex array. - - Returns - ------- - out: Complex64Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var arr2 = new {{alias}}( arr1 ) - - > var len = arr2.length - 2 - - -{{alias}}( typedarray ) - Creates a 64-bit complex number array from a typed array - containing interleaved real and imaginary components. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate complex array. - - Returns - ------- - out: Complex64Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/float32}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var arr = new {{alias}}( buf ) - - > var len = arr.length - 2 - - -{{alias}}( obj ) - Creates a 64-bit complex number array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a complex array. - - Returns - ------- - out: Complex64Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var len = arr1.length - 2 - > var buf = [ new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ), new {{alias:@stdlib/complex/float32/ctor}}( 2.0, -2.0 )]; - > var arr2 = new {{alias}}( buf ) - - > len = arr2.length - 2 - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a 64-bit complex number array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Complex64Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 240 ); - > var arr1 = new {{alias}}( buf ) - - > var len = arr1.length - 30 - > var arr2 = new {{alias}}( buf, 8 ) - - > len = arr2.length - 29 - > var arr3 = new {{alias}}( buf, 8, 20 ) - - > len = arr3.length - 20 - - -{{alias}}.from( src[, clbk[, thisArg]] ) - Creates a new 64-bit complex number array from an array-like object or an - iterable. - - A callback function is provided two arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - clbk: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Complex64Array - A typed array. - - Examples - -------- - > function clbkFcn( v ) { return v * 2.0 }; - > var arr = {{alias}}.from( [ 1.0, -1.0, 2.0, -2.0 ], clbkFcn ) - - > var len = arr.length - 2 - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -2.0 - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new 64-bit complex number array from a variable number of - arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Complex64Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1.0, -1.0, 2.0, -2.0 ) - - > var len = arr.length - 2 - > var z1 = new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ); - > var z2 = new {{alias:@stdlib/complex/float32/ctor}}( 2.0, -2.0 ); - > arr = {{alias}}.of( z1, z2 ) - - > len = arr.length - 2 - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -1.0 - - -{{alias}}.BYTES_PER_ELEMENT - The size of each array element in bytes. - - Examples - -------- - > var nbytes = {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > var str = {{alias}}.name - 'Complex64Array' - - -{{alias}}.prototype.buffer - Pointer to the underlying data buffer. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > var buf = arr.buffer - - - -{{alias}}.prototype.byteLength - Length of the array in bytes. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var nbytes = arr.byteLength - 80 - - -{{alias}}.prototype.byteOffset - Offset (in bytes) of the array from the start of its underlying - ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - - > var offset = arr.byteOffset - 0 - > var buf = new {{alias:@stdlib/array/buffer}}( 240 ); - > arr = new {{alias}}( buf, 64 ) - - > offset = arr.byteOffset - 64 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Size (in bytes) of each array element. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.length - The number of array elements. - - Examples - -------- - > var arr = new {{alias}}( 10 ) - - > var len = arr.length - 10 - - -{{alias}}.prototype.at( i ) - Returns an array element located at integer position (index) `i`, with - support for noth nonnegative and negative integer positions. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: Complex64|void - An array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var z = arr.at( 1 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -2.0 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Complex64Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) - - > arr.copyWithin( 0, 2 ) - - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -3.0 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) - - > var it = arr.entries(); - > var v = it.next().value - [ 0, ] - > var re = {{alias:@stdlib/complex/float32/real}}( v[ 1 ] ) - 1.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( v[ 1 ] ) - -1.0 - > v = it.next().value - [ 1, ] - > re = {{alias:@stdlib/complex/float32/real}}( v[ 1 ] ) - 2.0 - > im = {{alias:@stdlib/complex/float32/imag}}( v[ 1 ] ) - -2.0 - > v = it.next().value - [ 2, ] - > re = {{alias:@stdlib/complex/float32/real}}( v[ 1 ] ) - 3.0 - > im = {{alias:@stdlib/complex/float32/imag}}( v[ 1 ] ) - -3.0 - > var bool = it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Returns a boolean indicating whether all elements in the array pass a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all elements pass the test. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) > 0.0 ); }; - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var bool = arr.every( predicate ) - true - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Returns a modified typed array filled with a fill value. - - Parameters - ---------- - value: Complex64 - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Complex64Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( 3 ) - - > arr.fill( new {{alias:@stdlib/complex/float32/ctor}}( 1.0, 1.0 ) ); - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - 1.0 - > z = arr.get( 1 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 1.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - 1.0 - > z = arr.get( 2 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 1.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - 1.0 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Returns a new array containing the elements of an array which pass a test - implemented by a predicate function. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Complex64Array - A new typed array. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var out = arr.filter( predicate ) - - > var len = out.length - 1 - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - 2.0 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first element in an array for which a predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Complex64|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var z = arr.find( predicate ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - 1.0 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var idx = arr.findIndex( predicate ) - 0 - - -{{alias}}.prototype.findLast( predicate[, thisArg] ) - Returns the last element in an array for which a predicate function returns - a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Complex64|void - Array element or `undefined`. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var z = arr.findLast( predicate ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - 2.0 - - -{{alias}}.prototype.findLastIndex( predicate[, thisArg] ) - Returns the index of the last element in an array for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var idx = arr.findLastIndex( predicate ) - 1 - - -{{alias}}.prototype.forEach( clbk[, thisArg] ) - Invokes a function once for each array element. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - clbk: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Execution context. - - Examples - -------- - > var str = '%'; - > function clbk( v ) { str += v.toString() + '%'; }; - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > arr.forEach( clbk ); - > str - '%1 - 1i%2 - 2i%' - - -{{alias}}.prototype.get( i ) - Returns an array element located at integer position (index) `i`. - - If provided an index outside the array index range, the method returns - `undefined`. - - Parameters - ---------- - i: integer - Element index. - - Returns - ------- - out: Complex64|void - Array element or `undefined`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var z = arr.get( 1 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -2.0 - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a provided value. - - Parameters - ---------- - searchElement: Complex64 - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) - - > var bool = arr.includes( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ) ) - true - > bool = arr.includes( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ), 3 ) - false - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the first index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: Complex64 - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) - - > var idx = arr.indexOf( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ) ) - 2 - > idx = arr.indexOf( new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ), 3 ) - -1 - - -{{alias}}.prototype.join( [separator] ) - Returns a new string by concatenating all array elements separated by a - separator string. - - Parameters - ---------- - separator: string (optional) - Separator string. Default: ','. - - Returns - ------- - out: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var str = arr.join() - '1 - 1i,2 - 2i' - > str = arr.join( '/' ) - '1 - 1i/2 - 2i' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over each index key in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array index keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var it = arr.keys(); - > var v = it.next().value - 0 - > v = it.next().value - 1 - > v = it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the last index at which a given element can be found. - - If method does not find a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: Complex64 - Search element. - - fromIndex: integer (optional) - Array index at which to start the search. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: out.length-1. - - Returns - ------- - out: integer - Array index or `-1`. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) - - > var idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ) ) - 3 - > idx = arr.lastIndexOf( new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ), 2 ) - 0 - - -{{alias}}.prototype.map( clbk[, thisArg] ) - Returns a new array with each element being the result of a provided - callback function. - - A callback function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - The returned array has the same data type as the host array. - - Parameters - ---------- - clbk: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - out: Complex64Array - A new typed array. - - Examples - -------- - > function clbk( v ) { return v; }; - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var out = arr.map( clbk ) - - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -1.0 - > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - -2.0 - - -{{alias}}.prototype.reduce( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in order, passing - in the return value from the calculation on the preceding element and - returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var z = arr.reduce( {{alias:@stdlib/complex/float32/base/add}} ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -3.0 - - -{{alias}}.prototype.reduceRight( reducerFn[, initialValue] ) - Applies a provided function to each element of the array, in reverse order, - passing in the return value from the calculation on the preceding element - and returning the accumulated result upon completion. - - A reducer function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - reducerFn: Function - Function to apply to each array element. - - initialValue: any (optional) - Initial accumulation value. - - Returns - ------- - out: any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var z = arr.reduceRight( {{alias:@stdlib/complex/float32/base/add}} ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -3.0 - - -{{alias}}.prototype.reverse() - Reverses the array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Complex64Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) - - > arr.reverse(); - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -3.0 - > z = arr.get( 1 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - -2.0 - > z = arr.get( 2 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 1.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - -1.0 - - -{{alias}}.prototype.set( z[, i] ) - Sets one or more array elements. - - If provided a single argument, the method sets array elements starting at - position (index) `i = 0`. To set elements starting elsewhere in the array, - provide an index argument `i`. - - To set one or more array elements, provide an array-like object containing - either complex numbers or interleaved real and imaginary components. - - Parameters - ---------- - z: Complex64|Complex64Array|ArrayLikeObject - Complex number or complex number array. - - i: integer (optional) - Array index at which to start setting elements. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( 2 ) - - > arr.set( new {{alias:@stdlib/complex/float32/ctor}}( 1.0, -1.0 ) ); - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -1.0 - > arr.set( new {{alias:@stdlib/complex/float32/ctor}}( 2.0, -2.0 ), 1 ); - > z = arr.get( 1 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - -2.0 - - -{{alias}}.prototype.slice( [start[, end]] ) - Copies a portion of a typed array to a new typed array. - - Parameters - ---------- - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Complex64Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ) - - > var out = arr.slice( 1 ) - - > var len = out.length - 2 - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -2.0 - > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 3.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - -3.0 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Returns a boolean indicating whether at least one element passes a test. - - A predicate function is provided the following arguments: - - - value: current array element. - - index: current array element index. - - arr: the array on which the method was called. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one element passes the test. - - Examples - -------- - > function predicate( v ) { return ( {{alias:@stdlib/complex/float32/real}}( v ) === {{alias:@stdlib/complex/float32/imag}}( v ) ); }; - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ) - - > var bool = arr.some( predicate ) - true - - -{{alias}}.prototype.sort( compareFunction ) - Sorts an array in-place. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFunction: Function - Comparison function. - - Returns - ------- - out: Complex64Array - Modified array. - - Examples - -------- - > function compare( a, b ) { return ( {{alias:@stdlib/complex/float32/real}}( a ) - {{alias:@stdlib/complex/float32/real}}( b ) ); }; - > var arr = new {{alias}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) - - > arr.sort( compare ); - > var z = arr.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -1.0 - > z = arr.get( 1 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - -2.0 - > z = arr.get( 2 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 3.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - -3.0 - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array view over the same underlying `ArrayBuffer` and - with the same underlying data type as the host array. - - Parameters - ---------- - begin: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Complex64Array - New typed array view. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ) - - > var out = arr.subarray( 1, 3 ) - - > var len = out.length - 2 - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -2.0 - > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 3.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - -3.0 - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - Locale identifier(s). - - options: Object (optional) - An object containing serialization options. - - Returns - ------- - str: string - Local-specific string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0 ] ) - - > var str = arr.toLocaleString() - '1 + 1i,2 + 2i' - - -{{alias}}.prototype.toReversed() - Returns a new typed array containing the elements in reversed order. - - Returns - ------- - out: Complex64Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ) - - > var out = arr.toReversed() - - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - 3.0 - > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - 2.0 - > z = out.get( 2 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 1.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - 1.0 - - -{{alias}}.prototype.toSorted( compareFcn ) - Returns a new typed array containing the elements in sorted order. - - A comparison function determines the order of the array elements. The - function is provided two arguments: - - - a: first element for comparison. - - b: second element for comparison. - - The function should return a value less than zero if `a` comes before `b`, - a value greater than zero if `a` comes after `b`, and zero if `a` and `b` - are equivalent. - - Parameters - ---------- - compareFcn: Function - Comparison function. - - Returns - ------- - out: Complex64Array - New typed array. - - Examples - -------- - > function compare( a, b ) { return ( {{alias:@stdlib/complex/float32/real}}( a ) - {{alias:@stdlib/complex/float32/real}}( b ) ); }; - > var arr = new {{alias}}( [ 2.0, -2.0, 3.0, -3.0, 1.0, -1.0 ] ) - - > var out = arr.toSorted( compare ); - > var z = out.get( 0 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 1.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -1.0 - > z = out.get( 1 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 2.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - -2.0 - > z = out.get( 2 ) - - > re = {{alias:@stdlib/complex/float32/real}}( z ) - 3.0 - > im = {{alias:@stdlib/complex/float32/imag}}( z ) - -3.0 - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - String serialization of the array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 1.0, 2.0, -2.0, 3.0, 3.0 ] ) - - > var str = arr.toString() - '1 + 1i,2 - 2i,3 + 3i' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over each value in a typed array. - - Returns - ------- - iterator: Iterator - Iterator for iterating over array values. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var it = arr.values(); - > var v = it.next().value - - > var re = {{alias:@stdlib/complex/float32/real}}( v ) - 1.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( v ) - -1.0 - > v = it.next().value - - > re = {{alias:@stdlib/complex/float32/real}}( v ) - 2.0 - > im = {{alias:@stdlib/complex/float32/imag}}( v ) - -2.0 - > var bool = it.next().done - true - - -{{alias}}.prototype.with( index, value ) - Returns a new typed array with the element at a provided index replaced - with a provided value. - - Parameters - ---------- - index: integer - Element index. - - value: Complex64 - Element value. - - Returns - ------- - out: Complex64Array - New typed array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 2.0, -2.0 ] ) - - > var out = arr.with( 1, new {{alias:@stdlib/complex/float32/ctor}}( 3.0, -3.0 ) ) - - > var z = out.get( 1 ) - - > var re = {{alias:@stdlib/complex/float32/real}}( z ) - 3.0 - > var im = {{alias:@stdlib/complex/float32/imag}}( z ) - -3.0 - - - See Also - -------- diff --git a/complex64/docs/types/index.d.ts b/complex64/docs/types/index.d.ts deleted file mode 100644 index a2a196807..000000000 --- a/complex64/docs/types/index.d.ts +++ /dev/null @@ -1,1845 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator, TypedIterator } from '@stdlib/types/iter'; -import { ArrayLike, RealOrComplexTypedArray, Complex64Array as Complex64ArrayInterface } from '@stdlib/types/array'; -import { ComplexLike, Complex64 } from '@stdlib/types/complex'; -import ArrayBuffer = require( './../../../buffer' ); - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Locale-specific configuration options. -*/ -interface LocaleOptions { - /** - * Configuration property. - */ - [ key: string | symbol | number ]: T | undefined; -} - -/** -* Callback invoked for each element in a source object. -* -* @returns transformed value -*/ -type FromNullary = ( this: U ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @returns transformed value -*/ -type FromUnary = ( this: U, value: ComplexLike | ArrayLike | number ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromBinary = ( this: U, value: ComplexLike | ArrayLike | number, index: number ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in a source object. -* -* @param value - source element -* @param index - source element index -* @returns transformed value -*/ -type FromCallback = FromNullary | FromUnary | FromBinary; - -/** -* Checks whether an element in an array passes a test. -* -* @returns boolean indicating whether an element in an array passes a test -*/ -type NullaryPredicate = ( this: U ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @returns boolean indicating whether an element in an array passes a test -*/ -type UnaryPredicate = ( this: U, value: Complex64 ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @returns boolean indicating whether an element in an array passes a test -*/ -type BinaryPredicate = ( this: U, value: Complex64, index: number ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type TernaryPredicate = ( this: U, value: Complex64, index: number, arr: Complex64Array ) => boolean; - -/** -* Checks whether an element in an array passes a test. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns boolean indicating whether an element in an array passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Callback invoked for each element in an array. -* -* @returns undefined -*/ -type NullaryCallback = ( this: U ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns undefined -*/ -type UnaryCallback = ( this: U, value: Complex64 ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns undefined -*/ -type BinaryCallback = ( this: U, value: Complex64, index: number ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type TernaryCallback = ( this: U, value: Complex64, index: number, arr: Complex64Array ) => void; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns undefined -*/ -type Callback = NullaryCallback | UnaryCallback | BinaryCallback | TernaryCallback; - -/** -* Callback invoked for each element in an array. -* -* @returns transformed value -*/ -type NullaryMapFcn = ( this: U ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @returns transformed value -*/ -type UnaryMapFcn = ( this: U, value: Complex64 ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @returns transformed value -*/ -type BinaryMapFcn = ( this: U, value: Complex64, index: number ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns transformed value -*/ -type TernaryMapFcn = ( this: U, value: Complex64, index: number, arr: Complex64Array ) => ComplexLike | ArrayLike; - -/** -* Callback invoked for each element in an array. -* -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns transformed value -*/ -type MapFcn = NullaryMapFcn | UnaryMapFcn | BinaryMapFcn | TernaryMapFcn; - -/** -* Reducer function invoked for each element in an array. -* -* @returns accumulated result -*/ -type NullaryReducer = () => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @returns accumulated result -*/ -type UnaryReducer = ( acc: U ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @returns accumulated result -*/ -type BinaryReducer = ( acc: U, value: Complex64 ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @returns accumulated result -*/ -type TernaryReducer = ( acc: U, value: Complex64, index: number ) => U; - -/** -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type QuaternaryReducer = ( acc: U, value: Complex64, index: number, arr: Complex64Array ) => U; - -/** -* Reducer function invoked for each element in an array. -* -* @param acc - accumulated result -* @param value - current array element -* @param index - current array element index -* @param arr - array on which the method was called -* @returns accumulated result -*/ -type Reducer = NullaryReducer | UnaryReducer | BinaryReducer | TernaryReducer | QuaternaryReducer; - -/** -* Comparator function. -* -* @param a - first value for comparison -* @param b - second value for comparison -* @returns number indicating comparison result -*/ -type CompareFcn = ( a: Complex64, b: Complex64 ) => number; - -/** -* Class for creating a 64-bit complex number array. -*/ -declare class Complex64Array implements Complex64ArrayInterface { - /** - * 64-bit complex number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `8` - * @throws array-like object and typed array input arguments must have a length which is a multiple of two - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `8` - * @throws view length must be a positive multiple of `8` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @throws an iterator must return either a two element array containing real and imaginary components or a complex number - * @returns complex number array - * - * @example - * var arr = new Complex64Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Complex64Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Complex64Array( [ 1.0, -1.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex64Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex64Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Complex64Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - constructor( arg?: number | RealOrComplexTypedArray | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ); - - /** - * Returns an array element with support for both nonnegative and negative integer indices. - * - * @param i - element index - * @throws index argument must be a integer - * @returns array element - * - * @example - * var arr = new Complex64Array( 10 ); - * - * var z = arr.at( 0 ); - * // returns - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 9.0, -9.0 ], 9 ); - * - * z = arr.get( -1 ) - * // return - * - * z = arr.at( 100 ); - * // returns undefined - * - * z = arr.at( -100 ); - * // returns undefined - */ - at( i: number ): Complex64 | void; - - /** - * Pointer to the underlying data buffer. - * - * @example - * var arr = new Complex64Array( 10 ); - * - * var buf = arr.buffer; - * // returns - */ - readonly buffer: ArrayBuffer; - - /** - * Length (in bytes) of the array. - * - * @example - * var arr = new Complex64Array( 10 ); - * - * var byteLength = arr.byteLength; - * // returns 80 - */ - readonly byteLength: number; - - /** - * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - * - * @example - * var arr = new Complex64Array( 10 ); - * - * var byteOffset = arr.byteOffset; - * // returns 0 - */ - readonly byteOffset: number; - - /** - * Size (in bytes) of each array element. - * - * @example - * var arr = new Complex64Array( 10 ); - * - * var nbytes = arr.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Number of array elements. - * - * @example - * var arr = new Complex64Array( 10 ); - * - * var len = arr.length; - * // returns 10 - */ - readonly length: number; - - /** - * Copies a sequence of elements within the array to the position starting at `target`. - * - * @param target - index at which to start copying elements - * @param start - source index at which to copy elements from - * @param end - source index at which to stop copying elements from - * @returns modified array - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * var arr = new Complex64Array( 4 ); - * - * // Set the array elements: - * arr.set( new Complex64( 1.0, 1.0 ), 0 ); - * arr.set( new Complex64( 2.0, 2.0 ), 1 ); - * arr.set( new Complex64( 3.0, 3.0 ), 2 ); - * arr.set( new Complex64( 4.0, 4.0 ), 3 ); - * - * // Copy the first two elements to the last two elements: - * arr.copyWithin( 2, 0, 2 ); - * - * // Get the last array element: - * var z = arr.get( 3 ); - * - * var re = realf( z ); - * // returns 2.0 - * - * var im = imagf( z ); - * // returns 2.0 - */ - copyWithin( target: number, start: number, end?: number ): Complex64Array; - - /** - * Returns an iterator for iterating over array key-value pairs. - * - * @returns iterator - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * var arr = [ - * new Complex64( 1.0, 1.0 ), - * new Complex64( 2.0, 2.0 ), - * new Complex64( 3.0, 3.0 ) - * ]; - * arr = new Complex64Array( arr ); - * - * // Create an iterator: - * var it = arr.entries(); - * - * // Iterate over the key-value pairs... - * var v = it.next().value; - * // returns [ 0, ] - * - * v = it.next().value; - * // returns [ 1, ] - * - * v = it.next().value; - * // returns [ 2, ] - * - * var bool = it.next().done; - * // returns true - */ - entries(): TypedIterator<[number, Complex64]>; - - /** - * Tests whether all elements in an array pass a test implemented by a predicate function. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns boolean indicating whether all elements pass a test - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * function predicate( v ) { - * return ( realf( v ) === imagf( v ) ); - * } - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0 , 1.0 ], 0 ); - * arr.set( [ 2.0 , 2.0 ], 1 ); - * arr.set( [ 3.0 , 3.0 ], 2 ); - * - * var bool = arr.every( predicate ); - * // returns true - */ - every( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Returns a modified typed array filled with a fill value. - * - * @param value - fill value - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @returns modified typed array - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * var arr = new Complex64Array( 3 ); - * - * arr.fill( new Complex64( 1.0, 1.0 ), 1 ); - * - * var z = arr.get( 1 ); - * // returns - * - * var re = realf( z ); - * // returns 1.0 - * - * var im = imagf( z ); - * // returns 1.0 - * - * z = arr.get( 2 ); - * // returns - * - * re = realf( z ); - * // returns 1.0 - * - * im = imagf( z ); - * // returns 1.0 - */ - fill( value: ComplexLike, start?: number, end?: number ): Complex64Array; - - /** - * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns new array containing elements which pass a test implemented by a predicate function - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * function predicate( v ) { - * return ( realf( v ) === imagf( v ) ); - * } - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * - * var out = arr.filter( predicate ); - * // returns - * - * var len = out.length; - * // returns 1 - * - * var z = out.get( 0 ); - * // returns - * - * var re = realf( z ); - * // returns 2.0 - * - * var im = imagf( z ); - * // returns 2.0 - */ - filter( predicate: Predicate, thisArg?: ThisParameterType> ): Complex64Array; - - /** - * Returns the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns array element or undefined - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * function predicate( v ) { - * return ( realf( v ) === imagf( v ) ); - * } - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var z = arr.find( predicate ); - * // returns - * - * var re = realf( z ); - * // returns 1.0 - * - * var im = imagf( z ); - * // returns 1.0 - */ - find( predicate: Predicate, thisArg?: ThisParameterType> ): Complex64 | void; - - /** - * Returns the index of the first element in an array for which a predicate function returns a truthy value. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns index or -1 - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * function predicate( v ) { - * return ( realf( v ) === imagf( v ) ); - * } - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var idx = arr.findIndex( predicate ); - * // returns 2 - */ - findIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Returns the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns array element or undefined - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * function predicate( v ) { - * return ( realf( v ) === imagf( v ) ); - * } - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var z = arr.findLast( predicate ); - * // returns - * - * var re = realf( z ); - * // returns 3.0 - * - * var im = imagf( z ); - * // returns 3.0 - */ - findLast( predicate: Predicate, thisArg?: ThisParameterType> ): Complex64 | void; - - /** - * Returns the index of the last element in an array for which a predicate function returns a truthy value. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns index or -1 - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * function predicate( v ) { - * return ( realf( v ) === imagf( v ) ); - * } - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * - * var idx = arr.findLastIndex( predicate ); - * // returns 1 - */ - findLastIndex( predicate: Predicate, thisArg?: ThisParameterType> ): number; - - /** - * Invokes a function once for each array element. - * - * @param fcn - function to invoke - * @param thisArg - execution context - * @returns undefined - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * function log( v, i ) { - * console.log( '%s: %s', i, v.toString() ); - * } - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * arr.forEach( log ); - * // => 0: 1 + 1i - * // => 1: 2 + 2i - * // => 2: 3 + 3i - */ - forEach( fcn: Callback, thisArg?: ThisParameterType> ): void; - - /** - * Returns an array element. - * - * @param i - element index - * @throws index argument must be a nonnegative integer - * @returns array element - * - * @example - * var arr = new Complex64Array( 10 ); - * - * var z = arr.get( 0 ); - * // returns - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * - * z = arr.get( 100 ); - * // returns undefined - */ - get( i: number ): Complex64 | void; - - /** - * Returns a boolean indicating whether an array contains a provided value. - * - * @param searchElement - search element - * @param fromIndex - starting index (inclusive) - * @returns boolean indicating whether an array contains a provided value - * - * @example - * var arr = new Complex64Array( 5 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * arr.set( [ 4.0, -4.0 ], 3 ); - * arr.set( [ 5.0, -5.0 ], 4 ); - * - * var bool = arr.includes( new Complex64( 3.0, -3.0 ) ); - * // returns true - * - * bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 ); - * // returns false - * - * bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 ); - * // returns true - */ - includes( searchElement: ComplexLike, fromIndex?: number ): boolean; - - /** - * Returns the first index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - starting index (inclusive) - * @returns index or -1 - * - * @example - * var arr = new Complex64Array( 5 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * arr.set( [ 2.0, 2.0 ], 3 ); - * arr.set( [ 5.0, 5.0 ], 4 ); - * - * var idx = arr.indexOf( new Complex64( [ 2.0, 2.0 ] ) ); - * // returns 1 - * - * idx = arr.indexOf( new Complex64( [ 2.0, 2.0 ] ), 2 ); - * // returns 3 - * - * idx = arr.indexOf( new Complex64( [ 2.0, 2.0 ] ), -3 ); - * // returns 3 - */ - indexOf( searchElement: ComplexLike, fromIndex?: number ): number; - - /** - * Returns a new string by concatenating all array elements. - * - * @param separator - value separator (default: ',') - * @returns string - * - * @example - * var arr = new Complex64Array( 2 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * - * var str = arr.join(); - * // returns '1 + 1i,2 + 2i' - * - * str = arr.join( '/' ); - * // returns '1 + 1i/2 + 2i' - */ - join( separator?: string ): string; - - /** - * Returns an iterator for iterating over each index key in a typed array. - * - * @returns iterator - * - * @example - * var arr = new Complex64Array( 2 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * - * var iter = arr.keys(); - * - * var v = iter.next().value; - * // returns 0 - * - * v = iter.next().value; - * // returns 1 - * - * var bool = iter.next().done; - * // returns true - */ - keys(): TypedIterator; - - /** - * Returns the last index at which a given element can be found. - * - * @param searchElement - element to find - * @param fromIndex - index at which to start searching backward (inclusive) - * @returns index or -1 - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * var arr = new Complex64Array( 5 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * arr.set( [ 4.0, -4.0 ], 3 ); - * arr.set( [ 3.0, -3.0 ], 4 ); - * - * var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) ); - * // returns 4 - * - * idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ), 3 ); - * // returns 2 - * - * idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), -3 ); - * // returns 1 - */ - lastIndexOf( searchElement: ComplexLike, fromIndex?: number ): number; - - /** - * Returns a new array with each element being the result of a provided callback function. - * - * @param fcn - callback function - * @param thisArg - execution context - * @returns new array containing transformed elements - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * function scale( v, i ) { - * return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) ); - * } - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * - * var out = arr.map( scale ); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = realf( z ); - * // returns 2.0 - * - * var im = imagf( z ); - * // returns -2.0 - */ - map( fcn: MapFcn, thisArg?: ThisParameterType> ): Complex64Array; - - /** - * Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * var caddf = require( '@stdlib/complex/float32/base/add' ); - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var z = arr.reduce( caddf ); - * // returns - * - * var re = realf( z ); - * // returns 6.0 - * - * var im = imagf( z ); - * // returns 6.0 - */ - reduce( reducer: Reducer, initialValue?: U ): U; - - /** - * Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - * - * @param reducer - callback function - * @param initialValue - initial value - * @returns accumulated result - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * var caddf = require( '@stdlib/complex/float32/base/add' ); - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var z = arr.reduceRight( caddf ); - * // returns - * - * var re = realf( z ); - * // returns 6.0 - * - * var im = imagf( z ); - * // returns 6.0 - */ - reduceRight( reducer: Reducer, initialValue?: U ): U; - - /** - * Reverses an array in-place. - * - * @returns reversed array - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var out = arr.reverse(); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = realf( z ); - * // returns 3.0 - * - * var im = imagf( z ); - * // returns 3.0 - * - * z = out.get( 1 ); - * // returns - * - * re = realf( z ); - * // returns 2.0 - * - * im = imagf( z ); - * // returns 2.0 - * - * z = out.get( 2 ); - * // returns - * - * re = realf( z ); - * // returns 1.0 - * - * im = imagf( z ); - * // returns 1.0 - */ - reverse(): Complex64Array; - - /** - * Sets an array element. - * - * ## Notes - * - * - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. - * - * In the other overlapping scenario, - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended. - * - * - * @param value - value(s) - * @param i - element index at which to start writing values (default: 0) - * @throws index argument must be a nonnegative integer - * @throws array-like objects must have a length which is a multiple of two - * @throws index argument is out-of-bounds - * @throws target array lacks sufficient storage to accommodate source values - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * var arr = new Complex64Array( 10 ); - * - * var z = arr.get( 0 ); - * // returns - * - * var re = realf( z ); - * // returns 0.0 - * - * var im = imagf( z ); - * // returns 0.0 - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * - * z = arr.get( 0 ); - * // returns - * - * re = realf( z ); - * // returns 1.0 - * - * im = imagf( z ); - * // returns -1.0 - */ - set( value: ArrayLike | RealOrComplexTypedArray | ComplexLike, i?: number ): void; - - /** - * Copies a portion of a typed array to a new typed array. - * - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns output array - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * var arr = new Complex64Array( 5 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * arr.set( [ 4.0, -4.0 ], 3 ); - * arr.set( [ 5.0, -5.0 ], 4 ); - * - * var out = arr.slice(); - * // returns - * - * var len = out.length; - * // returns 5 - * - * var z = out.get( 0 ); - * // returns - * - * var re = realf( z ); - * // returns 1.0 - * - * var im = imagf( z ); - * // returns -1.0 - * - * z = out.get( len-1 ); - * // returns - * - * re = realf( z ); - * // returns 5.0 - * - * im = imagf( z ); - * // returns -5.0 - * - * out = arr.slice( 1, -2 ); - * // returns - * - * len = out.length; - * // returns 2 - * - * z = out.get( 0 ); - * // returns - * - * re = realf( z ); - * // returns 2.0 - * - * im = imagf( z ); - * // returns -2.0 - * - * z = out.get( len-1 ); - * // returns - * - * re = realf( z ); - * // returns 3.0 - * - * im = imagf( z ); - * // returns -3.0 - */ - slice( start?: number, end?: number ): Complex64Array; - - /** - * Tests whether at least one element in an array passes a test implemented by a predicate function. - * - * @param predicate - test function - * @param thisArg - execution context - * @returns boolean indicating whether at least one element passes a test - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * function predicate( v ) { - * return ( realf( v ) === imagf( v ) ); - * } - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0 , -1.0 ], 0 ); - * arr.set( [ 2.0 , 2.0 ], 1 ); - * arr.set( [ 3.0 , -3.0 ], 2 ); - * - * var bool = arr.some( predicate ); - * // returns true - */ - some( predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - /** - * Sorts an array in-place. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * function compare( a, b ) { - * var re1; - * var re2; - * var im1; - * var im2; - * re1 = realf( a ); - * re2 = realf( b ); - * if ( re1 < re2 ) { - * return -1; - * } - * if ( re1 > re2 ) { - * return 1; - * } - * im1 = imagf( a ); - * im2 = imagf( b ); - * if ( im1 < im2 ) { - * return -1; - * } - * if ( im1 > im2 ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 3.0, -3.0 ], 0 ); - * arr.set( [ 1.0, -1.0 ], 1 ); - * arr.set( [ 2.0, -2.0 ], 2 ); - * - * var out = arr.sort( compare ); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = realf( z ); - * // returns 1.0 - * - * var im = imagf( z ); - * // returns -1.0 - * - * z = out.get( 1 ); - * // returns - * - * re = realf( z ); - * // returns 2.0 - * - * im = imagf( z ); - * // returns -2.0 - * - * z = out.get( 2 ); - * // returns - * - * re = realf( z ); - * // returns 3.0 - * - * im = imagf( z ); - * // returns -3.0 - */ - sort( compareFcn: CompareFcn ): Complex64Array; - - /** - * Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. - * - * @param begin - starting index (inclusive) - * @param end - ending index (exclusive) - * @throws indices must be integers - * @returns subarray - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * var arr = new Complex64Array( 5 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * arr.set( [ 3.0, -3.0 ], 2 ); - * arr.set( [ 4.0, -4.0 ], 3 ); - * arr.set( [ 5.0, -5.0 ], 4 ); - * - * var subarr = arr.subarray(); - * // returns - * - * var len = subarr.length; - * // returns 5 - * - * var z = subarr.get( 0 ); - * // returns - * - * var re = realf( z ); - * // returns 1.0 - * - * var im = imagf( z ); - * // returns -1.0 - * - * z = subarr.get( len-1 ); - * // returns - * - * re = realf( z ); - * // returns 5.0 - * - * im = imagf( z ); - * // returns -5.0 - * - * subarr = arr.subarray( 1, -2 ); - * // returns - * - * len = subarr.length; - * // returns 2 - * - * z = subarr.get( 0 ); - * // returns - * - * re = realf( z ); - * // returns 2.0 - * - * im = imagf( z ); - * // returns -2.0 - * - * z = subarr.get( len-1 ); - * // returns - * - * re = realf( z ); - * // returns 3.0 - * - * im = imagf( z ); - * // returns -3.0 - */ - subarray( begin?: number, end?: number ): Complex64Array; - - /** - * Serializes an array as a locale-specific string. - * - * @param locales - locale identifier(s) - * @param options - configuration options - * @returns string - * - * @example - * var arr = new Complex64Array( 2 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * - * var str = arr.toLocaleString(); - * // returns '1 + 1i,2 + 2i' - */ - toLocaleString( locales?: string | Array, options?: LocaleOptions ): string; - - /** - * Returns a new typed array containing the elements in reversed order. - * - * @returns reversed array - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var out = arr.toReversed(); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = realf( z ); - * // returns 3.0 - * - * var im = imagf( z ); - * // returns 3.0 - * - * z = out.get( 1 ); - * // returns - * - * re = realf( z ); - * // returns 2.0 - * - * im = imagf( z ); - * // returns 2.0 - * - * z = out.get( 2 ); - * // returns - * - * re = realf( z ); - * // returns 1.0 - * - * im = imagf( z ); - * // returns 1.0 - */ - toReversed(): Complex64Array; - - /** - * Returns a new typed array containing the elements in sorted order. - * - * @param compareFcn - comparison function - * @returns sorted array - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * function compare( a, b ) { - * var re1; - * var re2; - * var im1; - * var im2; - * re1 = realf( a ); - * re2 = realf( b ); - * if ( re1 < re2 ) { - * return -1; - * } - * if ( re1 > re2 ) { - * return 1; - * } - * im1 = imagf( a ); - * im2 = imagf( b ); - * if ( im1 < im2 ) { - * return -1; - * } - * if ( im1 > im2 ) { - * return 1; - * } - * return 0; - * } - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 3.0, -3.0 ], 0 ); - * arr.set( [ 1.0, -1.0 ], 1 ); - * arr.set( [ 2.0, -2.0 ], 2 ); - * - * var out = arr.toSorted( compare ); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = realf( z ); - * // returns 1.0 - * - * var im = imagf( z ); - * // returns -1.0 - * - * z = out.get( 1 ); - * // returns - * - * re = realf( z ); - * // returns 2.0 - * - * im = imagf( z ); - * // returns -2.0 - * - * z = out.get( 2 ); - * // returns - * - * re = realf( z ); - * // returns 3.0 - * - * im = imagf( z ); - * // returns -3.0 - */ - toSorted( compareFcn: CompareFcn ): Complex64Array; - - /** - * Serializes an array as a string. - * - * @returns string - * - * @example - * var arr = new Complex64Array( 2 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * - * var str = arr.toString(); - * // returns '1 + 1i,2 + 2i' - */ - toString(): string; - - /** - * Returns an iterator for iterating over each value in a typed array. - * - * @returns iterator - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * var arr = new Complex64Array( 2 ); - * - * arr.set( [ 1.0, -1.0 ], 0 ); - * arr.set( [ 2.0, -2.0 ], 1 ); - * - * var iter = arr.values(); - * - * var v = iter.next().value; - * // returns - * - * var re = realf( v ); - * // returns 1.0 - * - * var im = imagf( v ); - * // returns -1.0 - * - * v = iter.next().value; - * // returns - * - * re = realf( v ); - * // returns 2.0 - * - * im = imagf( v ); - * // returns -2.0 - * - * var bool = iter.next().done; - * // returns true - */ - values(): TypedIterator; - - /** - * Returns a new typed array with the element at a provided index replaced with a provided value. - * - * @param index - element index - * @param value - new value - * @throws first argument must be an integer - * @throws second argument must be a complex number - * @throws index argument is out-of-bounds - * @returns modified typed array - * - * @example - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * var arr = new Complex64Array( 3 ); - * - * arr.set( [ 1.0, 1.0 ], 0 ); - * arr.set( [ 2.0, 2.0 ], 1 ); - * arr.set( [ 3.0, 3.0 ], 2 ); - * - * var out = arr.with( 0, new Complex64( 4.0, 4.0 ) ); - * // returns - * - * var z = out.get( 0 ); - * // returns - * - * var re = realf( z ); - * // returns 4.0 - * - * var im = imagf( z ); - * // returns 4.0 - */ - with( index: number, value: ComplexLike ): Complex64Array; -} - -/** -* Interface defining a 64-bit complex number array constructor which is both "newable" and "callable". -*/ -interface Complex64ArrayConstructor { - /** - * 64-bit complex number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `8` - * @throws array-like object and typed array input arguments must have a length which is a multiple of two - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `8` - * @throws view length must be a positive multiple of `8` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @throws an iterator must return either a two element array containing real and imaginary components or a complex number - * @returns complex number array - * - * @example - * var arr = new Complex64Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Complex64Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Complex64Array( [ 1.0, -1.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex64Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex64Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Complex64Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - new( arg?: number | RealOrComplexTypedArray | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): Complex64Array; - - /** - * 64-bit complex number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `8` - * @throws array-like object and typed array input arguments must have a length which is a multiple of two - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `8` - * @throws view length must be a positive multiple of `8` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @throws an iterator must return either a two element array containing real and imaginary components or a complex number - * @returns complex number array - * - * @example - * var arr = new Complex64Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new Complex64Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new Complex64Array( [ 1.0, -1.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex64Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new Complex64Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new Complex64Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - ( arg?: number | RealOrComplexTypedArray | ArrayLike | ArrayBuffer | Iterable, byteOffset?: number, length?: number ): Complex64Array; - - /** - * Constructor name. - * - * @example - * var str = Complex64Array.name; - * // returns 'Complex64Array' - */ - readonly name: 'Complex64Array'; - - /** - * Size (in bytes) of each array element. - * - * @example - * var nbytes = Complex64Array.BYTES_PER_ELEMENT; - * // returns 8 - */ - readonly BYTES_PER_ELEMENT: 8; - - /** - * Creates a new 64-bit complex number array from an array-like object or an iterable. - * - * @param src - array-like object or iterable - * @param clbk - callback to invoke for each source element - * @param thisArg - context - * @throws array-like objects must have a length which is a multiple of two - * @throws an iterator must return either a two element array containing real and imaginary components or a complex number - * @throws when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number - * @returns 64-bit complex number array - * - * @example - * var arr = Complex64Array.from( [ 1.0, -1.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * var realf = require( '@stdlib/complex/float32/real' ); - * var imagf = require( '@stdlib/complex/float32/imag' ); - * - * function clbk( v ) { - * return new Complex64( realf(v)*2.0, imagf(v)*2.0 ); - * } - * - * var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk ); - * // returns - * - * var len = arr.length; - * // returns 1 - */ - from( src: ArrayLike | RealOrComplexTypedArray | Iterable, clbk?: FromCallback, thisArg?: ThisParameterType> ): Complex64Array; - - /** - * Creates a new 64-bit complex number array from a variable number of arguments. - * - * @param elements - array elements - * @returns 64-bit complex number array - * - * @example - * var arr = Complex64Array.of( 1.0, 1.0, 1.0, 1.0 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - of( ...elements: Array ): Complex64Array; -} - -/** -* 64-bit complex number array constructor. -* -* @param arg - length, typed array, array-like object, or buffer -* @param byteOffset - byte offset (default: 0) -* @param length - view length -* @throws ArrayBuffer byte length must be a multiple of `8` -* @throws array-like object and typed array input arguments must have a length which is a multiple of two -* @throws if provided only a single argument, must provide a valid argument -* @throws byte offset must be a nonnegative integer -* @throws byte offset must be a multiple of `8` -* @throws view length must be a positive multiple of `8` -* @throws must provide sufficient memory to accommodate byte offset and view length requirements -* @throws an iterator must return either a two element array containing real and imaginary components or a complex number -* @returns complex number array -* -* @example -* var arr = new Complex64Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Complex64Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Complex64Array( [ 1.0, -1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Complex64Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Complex64Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Complex64Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -declare var ctor: Complex64ArrayConstructor; - - -// EXPORTS // - -export = ctor; diff --git a/complex64/docs/types/test.ts b/complex64/docs/types/test.ts deleted file mode 100644 index 5c07f51d5..000000000 --- a/complex64/docs/types/test.ts +++ /dev/null @@ -1,160 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Complex64 = require( '@stdlib/complex/float32/ctor' ); -import ArrayBuffer = require( './../../../buffer' ); -import realf = require( '@stdlib/complex/float32/real' ); -import imagf = require( '@stdlib/complex/float32/imag' ); -import Complex64Array = require( './index' ); - -/** -* Callback function. -* -* @private -* @param v - input value -* @returns output value -*/ -function clbk( v: Complex64 ): Complex64 { - return new Complex64( realf( v ) * 2.0, imagf( v ) * 2.0 ); -} - - -// TESTS // - -// The function returns a complex number array... -{ - new Complex64Array(); // $ExpectType Complex64Array - Complex64Array(); // $ExpectType Complex64Array - new Complex64Array( 2 ); // $ExpectType Complex64Array - Complex64Array( 2 ); // $ExpectType Complex64Array - new Complex64Array( [ 1.0, -1.0 ] ); // $ExpectType Complex64Array - Complex64Array( [ 1.0, -1.0 ] ); // $ExpectType Complex64Array - - const buf = new ArrayBuffer( 16 ); - new Complex64Array( buf ); // $ExpectType Complex64Array - Complex64Array( buf ); // $ExpectType Complex64Array - new Complex64Array( buf, 8 ); // $ExpectType Complex64Array - Complex64Array( buf, 8 ); // $ExpectType Complex64Array - new Complex64Array( buf, 8, 2 ); // $ExpectType Complex64Array - Complex64Array( buf, 8, 2 ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the function is provided a first argument that is not a number, typed array, array-like object, or array buffer... -{ - new Complex64Array( true ); // $ExpectError - new Complex64Array( false ); // $ExpectError - new Complex64Array( null ); // $ExpectError - new Complex64Array( 'abc' ); // $ExpectError - new Complex64Array( {} ); // $ExpectError - new Complex64Array( ( x: number ): number => x ); // $ExpectError - - Complex64Array( true ); // $ExpectError - Complex64Array( false ); // $ExpectError - Complex64Array( null ); // $ExpectError - Complex64Array( 'abc' ); // $ExpectError - Complex64Array( {} ); // $ExpectError - Complex64Array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Complex64Array( buf, true ); // $ExpectError - new Complex64Array( buf, false ); // $ExpectError - new Complex64Array( buf, null ); // $ExpectError - new Complex64Array( buf, 'abc' ); // $ExpectError - new Complex64Array( buf, {} ); // $ExpectError - new Complex64Array( buf, ( x: number ): number => x ); // $ExpectError - - Complex64Array( buf, true ); // $ExpectError - Complex64Array( buf, false ); // $ExpectError - Complex64Array( buf, null ); // $ExpectError - Complex64Array( buf, 'abc' ); // $ExpectError - Complex64Array( buf, {} ); // $ExpectError - Complex64Array( buf, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument that is not a number... -{ - const buf = new ArrayBuffer( 16 ); - new Complex64Array( buf, 8, true ); // $ExpectError - new Complex64Array( buf, 8, false ); // $ExpectError - new Complex64Array( buf, 8, null ); // $ExpectError - new Complex64Array( buf, 8, 'abc' ); // $ExpectError - new Complex64Array( buf, 8, {} ); // $ExpectError - new Complex64Array( buf, 8, ( x: number ): number => x ); // $ExpectError - - Complex64Array( buf, 8, true ); // $ExpectError - Complex64Array( buf, 8, false ); // $ExpectError - Complex64Array( buf, 8, null ); // $ExpectError - Complex64Array( buf, 8, 'abc' ); // $ExpectError - Complex64Array( buf, 8, {} ); // $ExpectError - Complex64Array( buf, 8, ( x: number ): number => x ); // $ExpectError -} - -// The `from` method returns a complex number array... -{ - Complex64Array.from( [ 1.0, 1.0 ] ); // $ExpectType Complex64Array - Complex64Array.from( [ 1.0, 1.0 ], ( x: number ): number => x * x ); // $ExpectType Complex64Array - Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk, {} ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the `from` method is provided a first argument which is not array-like or iterable... -{ - Complex64Array.from( true ); // $ExpectError - Complex64Array.from( false ); // $ExpectError - Complex64Array.from( 123 ); // $ExpectError - Complex64Array.from( null ); // $ExpectError - Complex64Array.from( {} ); // $ExpectError - - Complex64Array.from( true, clbk ); // $ExpectError - Complex64Array.from( false, clbk ); // $ExpectError - Complex64Array.from( 123, clbk ); // $ExpectError - Complex64Array.from( null, clbk ); // $ExpectError - Complex64Array.from( {}, clbk ); // $ExpectError - - Complex64Array.from( true, clbk, {} ); // $ExpectError - Complex64Array.from( false, clbk, {} ); // $ExpectError - Complex64Array.from( 123, clbk, {} ); // $ExpectError - Complex64Array.from( null, clbk, {} ); // $ExpectError - Complex64Array.from( {}, clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the `from` method is provided a second argument which is not a function with a supported signature... -{ - Complex64Array.from( [ 1, 1 ], true ); // $ExpectError - Complex64Array.from( [ 1, 1 ], false ); // $ExpectError - Complex64Array.from( [ 1, 1 ], 123 ); // $ExpectError - Complex64Array.from( [ 1, 1 ], null ); // $ExpectError - Complex64Array.from( [ 1, 1 ], {} ); // $ExpectError -} - -// The `of` method returns a complex number array... -{ - Complex64Array.of( 1.0, 1.0, 1.0, 1.0 ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the `of` method is provided arguments that are not numbers... -{ - Complex64Array.of( 'abc', 'def' ); // $ExpectError - Complex64Array.of( true, false ); // $ExpectError - Complex64Array.of( {}, [] ); // $ExpectError - Complex64Array.of( null, null ); // $ExpectError -} diff --git a/complex64/examples/index.js b/complex64/examples/index.js deleted file mode 100644 index dfbfde430..000000000 --- a/complex64/examples/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Float32Array = require( './../../float32' ); -var logEach = require( '@stdlib/console/log-each' ); -var Complex64Array = require( './../lib' ); - -// Create a complex array by specifying a length: -var out = new Complex64Array( 3 ); -logEach( '%s', out ); - -// Create a complex array from an array of complex numbers: -var arr = [ - new Complex64( 1.0, -1.0 ), - new Complex64( -3.14, 3.14 ), - new Complex64( 0.5, 0.5 ) -]; -out = new Complex64Array( arr ); -logEach( '%s', out ); - -// Create a complex array from an interleaved typed array: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex64Array( arr ); -logEach( '%s', out ); - -// Create a complex array from an array buffer: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex64Array( arr.buffer ); -logEach( '%s', out ); - -// Create a complex array from an array buffer view: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); -out = new Complex64Array( arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/complex64/lib/from_array.js b/complex64/lib/from_array.js deleted file mode 100644 index 0c75de619..000000000 --- a/complex64/lib/from_array.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 isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - - -// MAIN // - -/** -* Returns a strided array of real and imaginary components. -* -* @private -* @param {Float32Array} buf - output array -* @param {Array} arr - array containing complex numbers -* @returns {(Float32Array|null)} output array or null -*/ -function fromArray( buf, arr ) { - var len; - var v; - var i; - var j; - - len = arr.length; - j = 0; - for ( i = 0; i < len; i++ ) { - v = arr[ i ]; - if ( !isComplexLike( v ) ) { - return null; - } - buf[ j ] = realf( v ); - buf[ j+1 ] = imagf( v ); - j += 2; // stride - } - return buf; -} - - -// EXPORTS // - -module.exports = fromArray; diff --git a/complex64/lib/from_iterator.js b/complex64/lib/from_iterator.js deleted file mode 100644 index 4addd2169..000000000 --- a/complex64/lib/from_iterator.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {(Array|TypeError)} array or an error -*/ -function fromIterator( it ) { - var out; - var v; - var z; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - z = v.value; - if ( isArrayLikeObject( z ) && z.length >= 2 ) { - out.push( z[ 0 ], z[ 1 ] ); - } else if ( isComplexLike( z ) ) { - out.push( realf( z ), imagf( z ) ); - } else { - return new TypeError( format( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/complex64/lib/from_iterator_map.js b/complex64/lib/from_iterator_map.js deleted file mode 100644 index 7d835f85c..000000000 --- a/complex64/lib/from_iterator_map.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {(Array|TypeError)} array or an error -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var z; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - z = clbk.call( thisArg, v.value, i ); - if ( isArrayLikeObject( z ) && z.length >= 2 ) { - out.push( z[ 0 ], z[ 1 ] ); - } else if ( isComplexLike( z ) ) { - out.push( realf( z ), imagf( z ) ); - } else { - return new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/complex64/lib/index.js b/complex64/lib/index.js deleted file mode 100644 index 1e9841f31..000000000 --- a/complex64/lib/index.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* 64-bit complex number array. -* -* @module @stdlib/array/complex64 -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var arr = new Complex64Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var arr = new Complex64Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var arr = new Complex64Array( [ 1.0, -1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Complex64Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Complex64Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Complex64Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/complex64/lib/main.js b/complex64/lib/main.js deleted file mode 100644 index 5cf71167c..000000000 --- a/complex64/lib/main.js +++ /dev/null @@ -1,3035 +0,0 @@ -/* eslint-disable no-restricted-syntax, max-lines, no-invalid-this */ - -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isObject = require( '@stdlib/assert/is-object' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isFunction = require( '@stdlib/assert/is-function' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var isEven = require( '@stdlib/math/base/assert/is-even' ); -var isInteger = require( '@stdlib/math/base/assert/is-integer' ); -var isComplex64Array = require( './../../base/assert/is-complex64array' ); -var isComplex128Array = require( './../../base/assert/is-complex128array' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); -var Float32Array = require( './../../float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var format = require( '@stdlib/string/format' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var getter = require( './../../base/getter' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); -var fromArray = require( './from_array.js' ); - - -// VARIABLES // - -var BYTES_PER_ELEMENT = Float32Array.BYTES_PER_ELEMENT * 2; -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating if a value is a complex typed array. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a complex typed array -*/ -function isComplexArray( value ) { - return ( - value instanceof Complex64Array || - ( - typeof value === 'object' && - value !== null && - ( - value.constructor.name === 'Complex64Array' || - value.constructor.name === 'Complex128Array' - ) && - typeof value._length === 'number' && // eslint-disable-line no-underscore-dangle - - // NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks... - typeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle - ) - ); -} - -/** -* Returns a boolean indicating if a value is a complex typed array constructor. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating if a value is a complex typed array constructor -*/ -function isComplexArrayConstructor( value ) { - return ( - value === Complex64Array || - - // NOTE: weaker test in order to avoid a circular dependency with Complex128Array... - value.name === 'Complex128Array' - ); -} - -/** -* Retrieves a complex number from a complex number array buffer. -* -* @private -* @param {Float32Array} buf - array buffer -* @param {NonNegativeInteger} idx - element index -* @returns {Complex64} complex number -*/ -function getComplex64( buf, idx ) { - idx *= 2; - return new Complex64( buf[ idx ], buf[ idx+1 ] ); -} - - -// MAIN // - -/** -* 64-bit complex number array constructor. -* -* @constructor -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {RangeError} ArrayBuffer byte length must be a multiple of `8` -* @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two -* @throws {TypeError} if provided only a single argument, must provide a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} byte offset must be a multiple of `8` -* @throws {TypeError} view length must be a positive multiple of `8` -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number -* @returns {Complex64Array} complex number array -* -* @example -* var arr = new Complex64Array(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Complex64Array( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Complex64Array( [ 1.0, -1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Complex64Array( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Complex64Array( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Complex64Array( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function Complex64Array() { - var byteOffset; - var nargs; - var buf; - var len; - - nargs = arguments.length; - if ( !(this instanceof Complex64Array) ) { - if ( nargs === 0 ) { - return new Complex64Array(); - } - if ( nargs === 1 ) { - return new Complex64Array( arguments[0] ); - } - if ( nargs === 2 ) { - return new Complex64Array( arguments[0], arguments[1] ); - } - return new Complex64Array( arguments[0], arguments[1], arguments[2] ); - } - // Create the underlying data buffer... - if ( nargs === 0 ) { - buf = new Float32Array( 0 ); // backward-compatibility - } else if ( nargs === 1 ) { - if ( isNonNegativeInteger( arguments[0] ) ) { - buf = new Float32Array( arguments[0]*2 ); - } else if ( isCollection( arguments[0] ) ) { - buf = arguments[ 0 ]; - len = buf.length; - - // If provided a "generic" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to "normal" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number... - if ( len && isArray( buf ) && isComplexLike( buf[0] ) ) { - buf = fromArray( new Float32Array( len*2 ), buf ); - if ( buf === null ) { - // We failed and we are now forced to allocate a new array :-( - if ( !isEven( len ) ) { - throw new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', len ) ); - } - // We failed, so fall back to directly setting values... - buf = new Float32Array( arguments[0] ); - } - } else { - if ( isComplex64Array( buf ) ) { - buf = reinterpret64( buf, 0 ); - } else if ( isComplex128Array( buf ) ) { - buf = reinterpret128( buf, 0 ); - } else if ( !isEven( len ) ) { - throw new RangeError( format( 'invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.', len ) ); - } - buf = new Float32Array( buf ); - } - } else if ( isArrayBuffer( arguments[0] ) ) { - buf = arguments[ 0 ]; - if ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) ); - } - buf = new Float32Array( buf ); - } else if ( isObject( arguments[0] ) ) { - buf = arguments[ 0 ]; - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', buf ) ); - } - if ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); - } - buf = buf[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); // FIXME: `buf` is what is returned from above, NOT the original value - } - buf = fromIterator( buf ); - if ( buf instanceof Error ) { - throw buf; - } - buf = new Float32Array( buf ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arguments[0] ) ); - } - } else { - buf = arguments[ 0 ]; - if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) ); - } - byteOffset = arguments[ 1 ]; - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); - } - if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) ); - } - if ( nargs === 2 ) { - len = buf.byteLength - byteOffset; - if ( !isInteger( len/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) ); - } - buf = new Float32Array( buf, byteOffset ); - } else { - len = arguments[ 2 ]; - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); - } - if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) ); - } - buf = new Float32Array( buf, byteOffset, len*2 ); - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_length', buf.length/2 ); - - return this; -} - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex64Array -* @readonly -* @type {PositiveInteger} -* @default 8 -* -* @example -* var nbytes = Complex64Array.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex64Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - -/** -* Constructor name. -* -* @name name -* @memberof Complex64Array -* @readonly -* @type {string} -* @default 'Complex64Array' -* -* @example -* var str = Complex64Array.name; -* // returns 'Complex64Array' -*/ -setReadOnly( Complex64Array, 'name', 'Complex64Array' ); - -/** -* Creates a new 64-bit complex number array from an array-like object or an iterable. -* -* @name from -* @memberof Complex64Array -* @type {Function} -* @param {(Collection|Iterable)} src - array-like object or iterable -* @param {Function} [clbk] - callback to invoke for each source element -* @param {*} [thisArg] - context -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be an array-like object or an iterable -* @throws {TypeError} second argument must be a function -* @throws {RangeError} array-like objects must have a length which is a multiple of two -* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number -* @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number -* @returns {Complex64Array} 64-bit complex number array -* -* @example -* var arr = Complex64Array.from( [ 1.0, -1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* -* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* function clbk( v ) { -* return new Complex64( realf(v)*2.0, imagf(v)*2.0 ); -* } -* -* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk ); -* // returns -* -* var len = arr.length; -* // returns 1 -*/ -setReadOnly( Complex64Array, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var get; - var len; - var flg; - var v; - var i; - var j; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isComplexArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isComplexArray( src ) ) { - len = src.length; - if ( clbk ) { - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - j = 0; - for ( i = 0; i < len; i++ ) { - v = clbk.call( thisArg, src.get( i ), i ); - if ( isComplexLike( v ) ) { - buf[ j ] = realf( v ); - buf[ j+1 ] = imagf( v ); - } else if ( isArrayLikeObject( v ) && v.length >= 2 ) { - buf[ j ] = v[ 0 ]; - buf[ j+1 ] = v[ 1 ]; - } else { - throw new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) ); - } - j += 2; // stride - } - return out; - } - return new this( src ); - } - if ( isCollection( src ) ) { - if ( clbk ) { - // Note: array contents affect how we iterate over a provided data source. If only complex number objects, we can extract real and imaginary components. Otherwise, for non-complex number arrays (e.g., `Float64Array`, etc), we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component. - - len = src.length; - if ( src.get && src.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - // Detect whether we've been provided an array which returns complex number objects... - for ( i = 0; i < len; i++ ) { - if ( !isComplexLike( get( src, i ) ) ) { - flg = true; - break; - } - } - // If an array does not contain only complex number objects, then we assume interleaved real and imaginary components... - if ( flg ) { - if ( !isEven( len ) ) { - throw new RangeError( format( 'invalid argument. First argument must have a length which is a multiple of %u. Length: `%u`.', 2, len ) ); - } - out = new this( len/2 ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = clbk.call( thisArg, get( src, i ), i ); - } - return out; - } - // If an array contains only complex number objects, then we need to extract real and imaginary components... - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - j = 0; - for ( i = 0; i < len; i++ ) { - v = clbk.call( thisArg, get( src, i ), i ); - if ( isComplexLike( v ) ) { - buf[ j ] = realf( v ); - buf[ j+1 ] = imagf( v ); - } else if ( isArrayLikeObject( v ) && v.length >= 2 ) { - buf[ j ] = v[ 0 ]; - buf[ j+1 ] = v[ 1 ]; - } else { - throw new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) ); - } - j += 2; // stride - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - if ( tmp instanceof Error ) { - throw tmp; - } - len = tmp.length / 2; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ i ] = tmp[ i ]; - } - return out; - } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); -}); - -/** -* Creates a new 64-bit complex number array from a variable number of arguments. -* -* @name of -* @memberof Complex64Array -* @type {Function} -* @param {...*} element - array elements -* @throws {TypeError} `this` context must be a constructor -* @throws {TypeError} `this` must be a complex number array -* @returns {Complex64Array} 64-bit complex number array -* -* @example -* var arr = Complex64Array.of( 1.0, 1.0, 1.0, 1.0 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -setReadOnly( Complex64Array, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isComplexArrayConstructor( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); -}); - -/** -* Returns an array element with support for both nonnegative and negative integer indices. -* -* @name at -* @memberof Complex64Array.prototype -* @type {Function} -* @param {integer} idx - element index -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} must provide an integer -* @returns {(Complex64|void)} array element -* -* @example -* var arr = new Complex64Array( 10 ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var z = arr.at( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 0.0 -* -* var im = imagf( z ); -* // returns 0.0 -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 9.0, -9.0 ], 9 ); -* -* z = arr.at( 0 ); -* // returns -* -* re = realf( z ); -* // returns 1.0 -* -* im = imagf( z ); -* // returns -1.0 -* -* z = arr.at( -1 ); -* // returns -* -* re = realf( z ); -* // returns 9.0 -* -* im = imagf( z ); -* // returns -9.0 -* -* z = arr.at( 100 ); -* // returns undefined -* -* z = arr.at( -100 ); -* // returns undefined -*/ -setReadOnly( Complex64Array.prototype, 'at', function at( idx ) { - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); - } - if ( idx < 0 ) { - idx += this._length; - } - if ( idx < 0 || idx >= this._length ) { - return; - } - return getComplex64( this._buffer, idx ); -}); - -/** -* Pointer to the underlying data buffer. -* -* @name buffer -* @memberof Complex64Array.prototype -* @readonly -* @type {ArrayBuffer} -* -* @example -* var arr = new Complex64Array( 10 ); -* -* var buf = arr.buffer; -* // returns -*/ -setReadOnlyAccessor( Complex64Array.prototype, 'buffer', function get() { - return this._buffer.buffer; -}); - -/** -* Size (in bytes) of the array. -* -* @name byteLength -* @memberof Complex64Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Complex64Array( 10 ); -* -* var byteLength = arr.byteLength; -* // returns 80 -*/ -setReadOnlyAccessor( Complex64Array.prototype, 'byteLength', function get() { - return this._buffer.byteLength; -}); - -/** -* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. -* -* @name byteOffset -* @memberof Complex64Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Complex64Array( 10 ); -* -* var byteOffset = arr.byteOffset; -* // returns 0 -*/ -setReadOnlyAccessor( Complex64Array.prototype, 'byteOffset', function get() { - return this._buffer.byteOffset; -}); - -/** -* Size (in bytes) of each array element. -* -* @name BYTES_PER_ELEMENT -* @memberof Complex64Array.prototype -* @readonly -* @type {PositiveInteger} -* @default 8 -* -* @example -* var arr = new Complex64Array( 10 ); -* -* var nbytes = arr.BYTES_PER_ELEMENT; -* // returns 8 -*/ -setReadOnly( Complex64Array.prototype, 'BYTES_PER_ELEMENT', Complex64Array.BYTES_PER_ELEMENT ); - -/** -* Copies a sequence of elements within the array to the position starting at `target`. -* -* @name copyWithin -* @memberof Complex64Array.prototype -* @type {Function} -* @param {integer} target - index at which to start copying elements -* @param {integer} start - source index at which to copy elements from -* @param {integer} [end] - source index at which to stop copying elements from -* @throws {TypeError} `this` must be a complex number array -* @returns {Complex64Array} modified array -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var arr = new Complex64Array( 4 ); -* -* // Set the array elements: -* arr.set( new Complex64( 1.0, 1.0 ), 0 ); -* arr.set( new Complex64( 2.0, 2.0 ), 1 ); -* arr.set( new Complex64( 3.0, 3.0 ), 2 ); -* arr.set( new Complex64( 4.0, 4.0 ), 3 ); -* -* // Copy the first two elements to the last two elements: -* arr.copyWithin( 2, 0, 2 ); -* -* // Get the last array element: -* var z = arr.get( 3 ); -* -* var re = realf( z ); -* // returns 2.0 -* -* var im = imagf( z ); -* // returns 2.0 -*/ -setReadOnly( Complex64Array.prototype, 'copyWithin', function copyWithin( target, start ) { - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - // FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled - if ( arguments.length === 2 ) { - this._buffer.copyWithin( target*2, start*2 ); - } else { - this._buffer.copyWithin( target*2, start*2, arguments[2]*2 ); - } - return this; -}); - -/** -* Returns an iterator for iterating over array key-value pairs. -* -* @name entries -* @memberof Complex64Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {Iterator} iterator -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* -* var arr = [ -* new Complex64( 1.0, 1.0 ), -* new Complex64( 2.0, 2.0 ), -* new Complex64( 3.0, 3.0 ) -* ]; -* arr = new Complex64Array( arr ); -* -* // Create an iterator: -* var it = arr.entries(); -* -* // Iterate over the key-value pairs... -* var v = it.next().value; -* // returns [ 0, ] -* -* v = it.next().value; -* // returns [ 1, ] -* -* v = it.next().value; -* // returns [ 2, ] -* -* var bool = it.next().done; -* // returns true -*/ -setReadOnly( Complex64Array.prototype, 'entries', function entries() { - var self; - var iter; - var len; - var buf; - var FLG; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': [ i, getComplex64( buf, i ) ], - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.entries(); - } -}); - -/** -* Tests whether all elements in an array pass a test implemented by a predicate function. -* -* @name every -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether all elements pass a test -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* function predicate( v ) { -* return ( realf( v ) === imagf( v ) ); -* } -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var bool = arr.every( predicate ); -* // returns true -*/ -setReadOnly( Complex64Array.prototype, 'every', function every( predicate, thisArg ) { - var buf; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( !predicate.call( thisArg, getComplex64( buf, i ), i, this ) ) { - return false; - } - } - return true; -}); - -/** -* Returns a modified typed array filled with a fill value. -* -* @name fill -* @memberof Complex64Array.prototype -* @type {Function} -* @param {ComplexLike} value - fill value -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a complex number -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be an integer -* @returns {Complex64Array} modified array -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var arr = new Complex64Array( 3 ); -* -* arr.fill( new Complex64( 1.0, 1.0 ), 1 ); -* -* var z = arr.get( 1 ); -* // returns -* -* var re = realf( z ); -* // returns 1.0 -* -* var im = imagf( z ); -* // returns 1.0 -* -* z = arr.get( 2 ); -* // returns -* -* re = realf( z ); -* // returns 1.0 -* -* im = imagf( z ); -* // returns 1.0 -*/ -setReadOnly( Complex64Array.prototype, 'fill', function fill( value, start, end ) { - var buf; - var len; - var idx; - var re; - var im; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isComplexLike( value ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', value ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); - } - if ( start < 0 ) { - start += len; - if ( start < 0 ) { - start = 0; - } - } - if ( arguments.length > 2 ) { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } - if ( end > len ) { - end = len; - } - } else { - end = len; - } - } else { - start = 0; - end = len; - } - re = realf( value ); - im = imagf( value ); - for ( i = start; i < end; i++ ) { - idx = 2*i; - buf[ idx ] = re; - buf[ idx+1 ] = im; - } - return this; -}); - -/** -* Returns a new array containing the elements of an array which pass a test implemented by a predicate function. -* -* @name filter -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {Complex64Array} complex number array -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* function predicate( v ) { -* return ( realf( v ) === imagf( v ) ); -* } -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* -* var out = arr.filter( predicate ); -* // returns -* -* var len = out.length; -* // returns 1 -* -* var z = out.get( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 2.0 -* -* var im = imagf( z ); -* // returns 2.0 -*/ -setReadOnly( Complex64Array.prototype, 'filter', function filter( predicate, thisArg ) { - var buf; - var out; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - z = getComplex64( buf, i ); - if ( predicate.call( thisArg, z, i, this ) ) { - out.push( z ); - } - } - return new this.constructor( out ); -}); - -/** -* Returns the first element in an array for which a predicate function returns a truthy value. -* -* @name find -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {(Complex64|void)} array element or undefined -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* -* function predicate( v ) { -* return ( realf( v ) === imagf( v ) ); -* } -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var z = arr.find( predicate ); -* // returns -* -* var re = realf( z ); -* // returns 1.0 -* -* var im = imagf( z ); -* // returns 1.0 -*/ -setReadOnly( Complex64Array.prototype, 'find', function find( predicate, thisArg ) { - var buf; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - z = getComplex64( buf, i ); - if ( predicate.call( thisArg, z, i, this ) ) { - return z; - } - } -}); - -/** -* Returns the index of the first element in an array for which a predicate function returns a truthy value. -* -* @name findIndex -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* function predicate( v ) { -* return ( realf( v ) === imagf( v ) ); -* } -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var idx = arr.findIndex( predicate ); -* // returns 2 -*/ -setReadOnly( Complex64Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) { - var buf; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - z = getComplex64( buf, i ); - if ( predicate.call( thisArg, z, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Returns the last element in an array for which a predicate function returns a truthy value. -* -* @name findLast -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {(Complex64|void)} array element or undefined -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* -* function predicate( v ) { -* return ( realf( v ) === imagf( v ) ); -* } -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var z = arr.findLast( predicate ); -* // returns -* -* var re = realf( z ); -* // returns 3.0 -* -* var im = imagf( z ); -* // returns 3.0 -*/ -setReadOnly( Complex64Array.prototype, 'findLast', function findLast( predicate, thisArg ) { - var buf; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - z = getComplex64( buf, i ); - if ( predicate.call( thisArg, z, i, this ) ) { - return z; - } - } -}); - -/** -* Returns the index of the last element in an array for which a predicate function returns a truthy value. -* -* @name findLastIndex -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {integer} index or -1 -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* function predicate( v ) { -* return ( realf( v ) === imagf( v ) ); -* } -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* -* var idx = arr.findLastIndex( predicate ); -* // returns 1 -*/ -setReadOnly( Complex64Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) { - var buf; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = this._length-1; i >= 0; i-- ) { - z = getComplex64( buf, i ); - if ( predicate.call( thisArg, z, i, this ) ) { - return i; - } - } - return -1; -}); - -/** -* Invokes a function once for each array element. -* -* @name forEach -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} fcn - function to invoke -* @param {*} [thisArg] - function invocation context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* -* function log( v, i ) { -* console.log( '%s: %s', i, v.toString() ); -* } -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* arr.forEach( log ); -*/ -setReadOnly( Complex64Array.prototype, 'forEach', function forEach( fcn, thisArg ) { - var buf; - var i; - var z; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - z = getComplex64( buf, i ); - fcn.call( thisArg, z, i, this ); - } -}); - -/** -* Returns an array element. -* -* @name get -* @memberof Complex64Array.prototype -* @type {Function} -* @param {NonNegativeInteger} idx - element index -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} must provide a nonnegative integer -* @returns {(Complex64|void)} array element -* -* @example -* var arr = new Complex64Array( 10 ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var z = arr.get( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 0.0 -* -* var im = imagf( z ); -* // returns 0.0 -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* -* z = arr.get( 0 ); -* // returns -* -* re = realf( z ); -* // returns 1.0 -* -* im = imagf( z ); -* // returns -1.0 -* -* z = arr.get( 100 ); -* // returns undefined -*/ -setReadOnly( Complex64Array.prototype, 'get', function get( idx ) { - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return getComplex64( this._buffer, idx ); -}); - -/** -* Returns a boolean indicating whether an array includes a provided value. -* -* @name includes -* @memberof Complex64Array.prototype -* @type {Function} -* @param {ComplexLike} searchElement - search element -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a complex number -* @throws {TypeError} second argument must be an integer -* @returns {boolean} boolean indicating whether an array includes a provided value -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* -* var arr = new Complex64Array( 5 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* arr.set( [ 4.0, -4.0 ], 3 ); -* arr.set( [ 5.0, -5.0 ], 4 ); -* -* var bool = arr.includes( new Complex64( 3.0, -3.0 ) ); -* // returns true -* -* bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 ); -* // returns false -* -* bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 ); -* // returns true -*/ -setReadOnly( Complex64Array.prototype, 'includes', function includes( searchElement, fromIndex ) { - var buf; - var idx; - var re; - var im; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isComplexLike( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - re = realf( searchElement ); - im = imagf( searchElement ); - buf = this._buffer; - for ( i = fromIndex; i < this._length; i++ ) { - idx = 2 * i; - if ( re === buf[ idx ] && im === buf[ idx+1 ] ) { - return true; - } - } - return false; -}); - -/** -* Returns the first index at which a given element can be found. -* -* @name indexOf -* @memberof Complex64Array.prototype -* @type {Function} -* @param {ComplexLike} searchElement - element to find -* @param {integer} [fromIndex=0] - starting index (inclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a complex number -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* -* var arr = new Complex64Array( 10 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* arr.set( [ 4.0, -4.0 ], 3 ); -* arr.set( [ 5.0, -5.0 ], 4 ); -* -* var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) ); -* // returns 2 -* -* idx = arr.indexOf( new Complex64( 3.0, -3.0 ), 3 ); -* // returns -1 -* -* idx = arr.indexOf( new Complex64( 4.0, -4.0 ), -3 ); -* // returns -1 -*/ -setReadOnly( Complex64Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { - var buf; - var idx; - var re; - var im; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isComplexLike( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - re = realf( searchElement ); - im = imagf( searchElement ); - buf = this._buffer; - for ( i = fromIndex; i < this._length; i++ ) { - idx = 2 * i; - if ( re === buf[ idx ] && im === buf[ idx+1 ] ) { - return i; - } - } - return -1; -}); - -/** -* Returns a new string by concatenating all array elements. -* -* @name join -* @memberof Complex64Array.prototype -* @type {Function} -* @param {string} [separator=','] - element separator -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a string -* @returns {string} string representation -* -* @example -* var arr = new Complex64Array( 2 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* -* var str = arr.join(); -* // returns '1 + 1i,2 + 2i' -* -* str = arr.join( '/' ); -* // returns '1 + 1i/2 + 2i' -*/ -setReadOnly( Complex64Array.prototype, 'join', function join( separator ) { - var out; - var buf; - var sep; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( arguments.length === 0 ) { - sep = ','; - } else if ( isString( separator ) ) { - sep = separator; - } else { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); - } - out = []; - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - out.push( getComplex64( buf, i ).toString() ); - } - return out.join( sep ); -}); - -/** -* Returns an iterator for iterating over each index key in a typed array. -* -* @name keys -* @memberof Complex64Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {Iterator} iterator -* -* @example -* var arr = new Complex64Array( 2 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* -* var iter = arr.keys(); -* -* var v = iter.next().value; -* // returns 0 -* -* v = iter.next().value; -* // returns 1 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Complex64Array.prototype, 'keys', function keys() { - var self; - var iter; - var len; - var FLG; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - self = this; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': i, - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.keys(); - } -}); - -/** -* Returns the last index at which a given element can be found. -* -* @name lastIndexOf -* @memberof Complex64Array.prototype -* @type {Function} -* @param {ComplexLike} searchElement - element to find -* @param {integer} [fromIndex] - index at which to start searching backward (inclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a complex number -* @throws {TypeError} second argument must be an integer -* @returns {integer} index or -1 -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* -* var arr = new Complex64Array( 5 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* arr.set( [ 4.0, -4.0 ], 3 ); -* arr.set( [ 3.0, -3.0 ], 4 ); -* -* var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) ); -* // returns 4 -* -* idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ), 3 ); -* // returns 2 -* -* idx = arr.lastIndexOf( new Complex64( 5.0, -5.0 ), 3 ); -* // returns -1 -* -* idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), -3 ); -* // returns 1 -*/ -setReadOnly( Complex64Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { - var buf; - var idx; - var re; - var im; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isComplexLike( searchElement ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex >= this._length ) { - fromIndex = this._length - 1; - } else if ( fromIndex < 0 ) { - fromIndex += this._length; - } - } else { - fromIndex = this._length - 1; - } - re = realf( searchElement ); - im = imagf( searchElement ); - buf = this._buffer; - for ( i = fromIndex; i >= 0; i-- ) { - idx = 2 * i; - if ( re === buf[ idx ] && im === buf[ idx+1 ] ) { - return i; - } - } - return -1; -}); - -/** -* Number of array elements. -* -* @name length -* @memberof Complex64Array.prototype -* @readonly -* @type {NonNegativeInteger} -* -* @example -* var arr = new Complex64Array( 10 ); -* -* var len = arr.length; -* // returns 10 -*/ -setReadOnlyAccessor( Complex64Array.prototype, 'length', function get() { - return this._length; -}); - -/** -* Returns a new array with each element being the result of a provided callback function. -* -* @name map -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} fcn - callback function -* @param {*} [thisArg] - callback function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {Complex64Array} complex number array -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* function scale( v, i ) { -* return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) ); -* } -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* -* var out = arr.map( scale ); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 2 -* -* var im = imagf( z ); -* // returns -2 -*/ -setReadOnly( Complex64Array.prototype, 'map', function map( fcn, thisArg ) { - var outbuf; - var buf; - var out; - var i; - var v; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - buf = this._buffer; - out = new this.constructor( this._length ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < this._length; i++ ) { - v = fcn.call( thisArg, getComplex64( buf, i ), i, this ); - if ( isComplexLike( v ) ) { - outbuf[ 2*i ] = realf( v ); - outbuf[ (2*i)+1 ] = imagf( v ); - } else if ( isArrayLikeObject( v ) && v.length === 2 ) { - outbuf[ 2*i ] = v[ 0 ]; - outbuf[ (2*i)+1 ] = v[ 1 ]; - } else { - throw new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) ); - } - } - return out; -}); - -/** -* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduce -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var caddf = require( '@stdlib/complex/float32/base/add' ); -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var z = arr.reduce( caddf ); -* // returns -* -* var re = realf( z ); -* // returns 6.0 -* -* var im = imagf( z ); -* // returns 6.0 -*/ -setReadOnly( Complex64Array.prototype, 'reduce', function reduce( reducer, initialValue ) { - var buf; - var acc; - var len; - var v; - var i; - - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = 0; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = getComplex64( buf, 0 ); - i = 1; - } - for ( ; i < len; i++ ) { - v = getComplex64( buf, i ); - acc = reducer( acc, v, i, this ); - } - return acc; -}); - -/** -* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. -* -* @name reduceRight -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} reducer - callback function -* @param {*} [initialValue] - initial value -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @throws {Error} if not provided an initial value, the array must have at least one element -* @returns {*} accumulated result -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var caddf = require( '@stdlib/complex/float32/base/add' ); -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var z = arr.reduceRight( caddf ); -* // returns -* -* var re = realf( z ); -* // returns 6.0 -* -* var im = imagf( z ); -* // returns 6.0 -*/ -setReadOnly( Complex64Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) { - var buf; - var acc; - var len; - var v; - var i; - - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = len-1; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = getComplex64( buf, len-1 ); - i = len-2; - } - for ( ; i >= 0; i-- ) { - v = getComplex64( buf, i ); - acc = reducer( acc, v, i, this ); - } - return acc; -}); - -/** -* Reverses an array in-place. -* -* @name reverse -* @memberof Complex64Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {Complex64Array} reversed array -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var out = arr.reverse(); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 3.0 -* -* var im = imagf( z ); -* // returns 3.0 -* -* z = out.get( 1 ); -* // returns -* -* re = realf( z ); -* // returns 2.0 -* -* im = imagf( z ); -* // returns 2.0 -* -* z = out.get( 2 ); -* // returns -* -* re = realf( z ); -* // returns 1.0 -* -* im = imagf( z ); -* // returns 1.0 -*/ -setReadOnly( Complex64Array.prototype, 'reverse', function reverse() { - var buf; - var tmp; - var len; - var N; - var i; - var j; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - len = this._length; - buf = this._buffer; - N = floor( len / 2 ); - for ( i = 0; i < N; i++ ) { - j = len - i - 1; - tmp = buf[ (2*i) ]; - buf[ (2*i) ] = buf[ (2*j) ]; - buf[ (2*j) ] = tmp; - tmp = buf[ (2*i)+1 ]; - buf[ (2*i)+1 ] = buf[ (2*j)+1 ]; - buf[ (2*j)+1 ] = tmp; - } - return this; -}); - -/** -* Sets an array element. -* -* ## Notes -* -* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. -* -* In the other overlapping scenario, -* -* ```text -* buf: --------------------- -* src: --------------------- -* ``` -* -* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended. -* -* @name set -* @memberof Complex64Array.prototype -* @type {Function} -* @param {(Collection|Complex|ComplexArray)} value - value(s) -* @param {NonNegativeInteger} [i=0] - element index at which to start writing values -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array -* @throws {TypeError} index argument must be a nonnegative integer -* @throws {RangeError} array-like objects must have a length which is a multiple of two -* @throws {RangeError} index argument is out-of-bounds -* @throws {RangeError} target array lacks sufficient storage to accommodate source values -* @returns {void} -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var arr = new Complex64Array( 10 ); -* -* var z = arr.get( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 0.0 -* -* var im = imagf( z ); -* // returns 0.0 -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* -* z = arr.get( 0 ); -* // returns -* -* re = realf( z ); -* // returns 1.0 -* -* im = imagf( z ); -* // returns -1.0 -*/ -setReadOnly( Complex64Array.prototype, 'set', function set( value ) { - /* eslint-disable no-underscore-dangle */ - var sbuf; - var idx; - var buf; - var tmp; - var flg; - var N; - var v; - var i; - var j; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - buf = this._buffer; - if ( arguments.length > 1 ) { - idx = arguments[ 1 ]; - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); - } - } else { - idx = 0; - } - if ( isComplexLike( value ) ) { - if ( idx >= this._length ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) ); - } - idx *= 2; - buf[ idx ] = realf( value ); - buf[ idx+1 ] = imagf( value ); - return; - } - if ( isComplexArray( value ) ) { - N = value._length; - if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); - } - sbuf = value._buffer; - - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = new Float32Array( sbuf.length ); - for ( i = 0; i < sbuf.length; i++ ) { - tmp[ i ] = sbuf[ i ]; - } - sbuf = tmp; - } - idx *= 2; - j = 0; - for ( i = 0; i < N; i++ ) { - buf[ idx ] = sbuf[ j ]; - buf[ idx+1 ] = sbuf[ j+1 ]; - idx += 2; // stride - j += 2; // stride - } - return; - } - if ( isCollection( value ) ) { - // Detect whether we've been provided an array of complex numbers... - N = value.length; - for ( i = 0; i < N; i++ ) { - if ( !isComplexLike( value[ i ] ) ) { - flg = true; - break; - } - } - // If an array does not contain only complex numbers, then we assume interleaved real and imaginary components... - if ( flg ) { - if ( !isEven( N ) ) { - throw new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', N ) ); - } - if ( idx+(N/2) > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); - } - sbuf = value; - - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = new Float32Array( N ); - for ( i = 0; i < N; i++ ) { - tmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays - } - sbuf = tmp; - } - idx *= 2; - N /= 2; - j = 0; - for ( i = 0; i < N; i++ ) { - buf[ idx ] = sbuf[ j ]; - buf[ idx+1 ] = sbuf[ j+1 ]; - idx += 2; // stride - j += 2; // stride - } - return; - } - // If an array contains only complex numbers, then we need to extract real and imaginary components... - if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); - } - idx *= 2; - for ( i = 0; i < N; i++ ) { - v = value[ i ]; - buf[ idx ] = realf( v ); - buf[ idx+1 ] = imagf( v ); - idx += 2; // stride - } - return; - } - throw new TypeError( format( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.', value ) ); - - /* eslint-enable no-underscore-dangle */ -}); - -/** -* Copies a portion of a typed array to a new typed array. -* -* @name slice -* @memberof Complex64Array.prototype -* @type {Function} -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be an integer -* @throws {TypeError} second argument must be an integer -* @returns {Complex64Array} complex number array -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var arr = new Complex64Array( 5 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* arr.set( [ 4.0, -4.0 ], 3 ); -* arr.set( [ 5.0, -5.0 ], 4 ); -* -* var out = arr.slice(); -* // returns -* -* var len = out.length; -* // returns 5 -* -* var z = out.get( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 1.0 -* -* var im = imagf( z ); -* // returns -1.0 -* -* z = out.get( len-1 ); -* // returns -* -* re = realf( z ); -* // returns 5.0 -* -* im = imagf( z ); -* // returns -5.0 -* -* out = arr.slice( 1, -2 ); -* // returns -* -* len = out.length; -* // returns 2 -* -* z = out.get( 0 ); -* // returns -* -* re = realf( z ); -* // returns 2.0 -* -* im = imagf( z ); -* // returns -2.0 -* -* z = out.get( len-1 ); -* // returns -* -* re = realf( z ); -* // returns 3.0 -* -* im = imagf( z ); -* // returns -3.0 -*/ -setReadOnly( Complex64Array.prototype, 'slice', function slice( start, end ) { - var outlen; - var outbuf; - var out; - var idx; - var buf; - var len; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - start = 0; - end = len; - } else { - if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', start ) ); - } - if ( start < 0 ) { - start += len; - if ( start < 0 ) { - start = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( start < end ) { - outlen = end - start; - } else { - outlen = 0; - } - out = new this.constructor( outlen ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < outlen; i++ ) { - idx = 2*(i+start); - outbuf[ 2*i ] = buf[ idx ]; - outbuf[ (2*i)+1 ] = buf[ idx+1 ]; - } - return out; -}); - -/** -* Tests whether at least one element in an array passes a test implemented by a predicate function. -* -* @name some -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} predicate - test function -* @param {*} [thisArg] - predicate function execution context -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {boolean} boolean indicating whether at least one element passes a test -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* function predicate( v ) { -* return ( realf( v ) === imagf( v ) ); -* } -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* -* var bool = arr.some( predicate ); -* // returns true -*/ -setReadOnly( Complex64Array.prototype, 'some', function some( predicate, thisArg ) { - var buf; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( predicate.call( thisArg, getComplex64( buf, i ), i, this ) ) { - return true; - } - } - return false; -}); - -/** -* Sorts an array in-place. -* -* @name sort -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} compareFcn - comparison function -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {Complex64Array} sorted array -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* function compare( a, b ) { -* var re1; -* var re2; -* var im1; -* var im2; -* re1 = realf( a ); -* re2 = realf( b ); -* if ( re1 < re2 ) { -* return -1; -* } -* if ( re1 > re2 ) { -* return 1; -* } -* im1 = imagf( a ); -* im2 = imagf( b ); -* if ( im1 < im2 ) { -* return -1; -* } -* if ( im1 > im2 ) { -* return 1; -* } -* return 0; -* } -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 3.0, -3.0 ], 0 ); -* arr.set( [ 1.0, -1.0 ], 1 ); -* arr.set( [ 2.0, -2.0 ], 2 ); -* -* var out = arr.sort( compare ); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 1.0 -* -* var im = imagf( z ); -* // returns -1.0 -* -* z = out.get( 1 ); -* // returns -* -* re = realf( z ); -* // returns 2.0 -* -* im = imagf( z ); -* // returns -2.0 -* -* z = out.get( 2 ); -* // returns -* -* re = realf( z ); -* // returns 3.0 -* -* im = imagf( z ); -* // returns -3.0 -*/ -setReadOnly( Complex64Array.prototype, 'sort', function sort( compareFcn ) { - var tmp; - var buf; - var len; - var i; - var j; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); - } - buf = this._buffer; - len = this._length; - tmp = []; - for ( i = 0; i < len; i++ ) { - tmp.push( getComplex64( buf, i ) ); - } - tmp.sort( compareFcn ); - for ( i = 0; i < len; i++ ) { - j = 2 * i; - buf[ j ] = realf( tmp[i] ); - buf[ j+1 ] = imagf( tmp[i] ); - } - return this; -}); - -/** -* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array. -* -* @name subarray -* @memberof Complex64Array.prototype -* @type {Function} -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end] - ending index (exclusive) -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be an integer -* @throws {TypeError} second argument must be an integer -* @returns {Complex64Array} subarray -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var arr = new Complex64Array( 5 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* arr.set( [ 3.0, -3.0 ], 2 ); -* arr.set( [ 4.0, -4.0 ], 3 ); -* arr.set( [ 5.0, -5.0 ], 4 ); -* -* var subarr = arr.subarray(); -* // returns -* -* var len = subarr.length; -* // returns 5 -* -* var z = subarr.get( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 1.0 -* -* var im = imagf( z ); -* // returns -1.0 -* -* z = subarr.get( len-1 ); -* // returns -* -* re = realf( z ); -* // returns 5.0 -* -* im = imagf( z ); -* // returns -5.0 -* -* subarr = arr.subarray( 1, -2 ); -* // returns -* -* len = subarr.length; -* // returns 2 -* -* z = subarr.get( 0 ); -* // returns -* -* re = realf( z ); -* // returns 2.0 -* -* im = imagf( z ); -* // returns -2.0 -* -* z = subarr.get( len-1 ); -* // returns -* -* re = realf( z ); -* // returns 3.0 -* -* im = imagf( z ); -* // returns -3.0 -*/ -setReadOnly( Complex64Array.prototype, 'subarray', function subarray( begin, end ) { - var offset; - var buf; - var len; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length === 0 ) { - begin = 0; - end = len; - } else { - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) ); - } - if ( begin < 0 ) { - begin += len; - if ( begin < 0 ) { - begin = 0; - } - } - if ( arguments.length === 1 ) { - end = len; - } else { - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end += len; - if ( end < 0 ) { - end = 0; - } - } else if ( end > len ) { - end = len; - } - } - } - if ( begin >= len ) { - len = 0; - offset = buf.byteLength; - } else if ( begin >= end ) { - len = 0; - offset = buf.byteOffset + (begin*BYTES_PER_ELEMENT); - } else { - len = end - begin; - offset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT ); - } - return new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len ); -}); - -/** -* Serializes an array as a locale-specific string. -* -* @name toLocaleString -* @memberof Complex64Array.prototype -* @type {Function} -* @param {(string|Array)} [locales] - locale identifier(s) -* @param {Object} [options] - configuration options -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a string or an array of strings -* @throws {TypeError} options argument must be an object -* @returns {string} string representation -* -* @example -* var arr = new Complex64Array( 2 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* -* var str = arr.toLocaleString(); -* // returns '1 + 1i,2 + 2i' -*/ -setReadOnly( Complex64Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) { - var opts; - var loc; - var out; - var buf; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( arguments.length === 0 ) { - loc = []; - } else if ( isString( locales ) || isStringArray( locales ) ) { - loc = locales; - } else { - throw new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) ); - } - if ( arguments.length < 2 ) { - opts = {}; - } else if ( isObject( options ) ) { - opts = options; - } else { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - out.push( getComplex64( buf, i ).toLocaleString( loc, opts ) ); - } - return out.join( ',' ); -}); - -/** -* Returns a new typed array containing the elements in reversed order. -* -* @name toReversed -* @memberof Complex64Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {Complex64Array} reversed array -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var out = arr.toReversed(); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 3.0 -* -* var im = imagf( z ); -* // returns 3.0 -* -* z = out.get( 1 ); -* // returns -* -* re = realf( z ); -* // returns 2.0 -* -* im = imagf( z ); -* // returns 2.0 -* -* z = out.get( 2 ); -* // returns -* -* re = realf( z ); -* // returns 1.0 -* -* im = imagf( z ); -* // returns 1.0 -*/ -setReadOnly( Complex64Array.prototype, 'toReversed', function toReversed() { - var outbuf; - var out; - var len; - var buf; - var i; - var j; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - len = this._length; - out = new this.constructor( len ); - buf = this._buffer; - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - j = len - i - 1; - outbuf[ (2*i) ] = buf[ (2*j) ]; - outbuf[ (2*i)+1 ] = buf[ (2*j)+1 ]; - } - return out; -}); - -/** -* Returns a new typed array containing the elements in sorted order. -* -* @name toSorted -* @memberof Complex64Array.prototype -* @type {Function} -* @param {Function} compareFcn - comparison function -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be a function -* @returns {Complex64Array} sorted array -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* -* function compare( a, b ) { -* var re1; -* var re2; -* var im1; -* var im2; -* re1 = realf( a ); -* re2 = realf( b ); -* if ( re1 < re2 ) { -* return -1; -* } -* if ( re1 > re2 ) { -* return 1; -* } -* im1 = imagf( a ); -* im2 = imagf( b ); -* if ( im1 < im2 ) { -* return -1; -* } -* if ( im1 > im2 ) { -* return 1; -* } -* return 0; -* } -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 3.0, -3.0 ], 0 ); -* arr.set( [ 1.0, -1.0 ], 1 ); -* arr.set( [ 2.0, -2.0 ], 2 ); -* -* var out = arr.sort( compare ); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 1.0 -* -* var im = imagf( z ); -* // returns -1.0 -* -* z = out.get( 1 ); -* // returns -* -* re = realf( z ); -* // returns 2.0 -* -* im = imagf( z ); -* // returns -2.0 -* -* z = out.get( 2 ); -* // returns -* -* re = realf( z ); -* // returns 3.0 -* -* im = imagf( z ); -* // returns -3.0 -*/ -setReadOnly( Complex64Array.prototype, 'toSorted', function toSorted( compareFcn ) { - var tmp; - var buf; - var len; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isFunction( compareFcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) ); - } - buf = this._buffer; - len = this._length; - tmp = []; - for ( i = 0; i < len; i++ ) { - tmp.push( getComplex64( buf, i ) ); - } - tmp.sort( compareFcn ); - return new Complex64Array( tmp ); -}); - -/** -* Serializes an array as a string. -* -* @name toString -* @memberof Complex64Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {string} string representation -* -* @example -* var arr = new Complex64Array( 2 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* -* var str = arr.toString(); -* // returns '1 + 1i,2 + 2i' -*/ -setReadOnly( Complex64Array.prototype, 'toString', function toString() { - var out; - var buf; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - out = []; - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - out.push( getComplex64( buf, i ).toString() ); - } - return out.join( ',' ); -}); - -/** -* Returns an iterator for iterating over each value in a typed array. -* -* @name values -* @memberof Complex64Array.prototype -* @type {Function} -* @throws {TypeError} `this` must be a complex number array -* @returns {Iterator} iterator -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var arr = new Complex64Array( 2 ); -* -* arr.set( [ 1.0, -1.0 ], 0 ); -* arr.set( [ 2.0, -2.0 ], 1 ); -* -* var iter = arr.values(); -* -* var v = iter.next().value; -* // returns -* -* var re = realf( v ); -* // returns 1.0 -* -* var im = imagf( v ); -* // returns -1.0 -* -* v = iter.next().value; -* // returns -* -* re = realf( v ); -* // returns 2.0 -* -* im = imagf( v ); -* // returns -2.0 -* -* var bool = iter.next().done; -* // returns true -*/ -setReadOnly( Complex64Array.prototype, 'values', function values() { - var iter; - var self; - var len; - var FLG; - var buf; - var i; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - self = this; - buf = this._buffer; - len = this._length; - - // Initialize an iteration index: - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - setReadOnly( iter, 'next', next ); - setReadOnly( iter, 'return', end ); - - if ( ITERATOR_SYMBOL ) { - setReadOnly( iter, ITERATOR_SYMBOL, factory ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next() { - i += 1; - if ( FLG || i >= len ) { - return { - 'done': true - }; - } - return { - 'value': getComplex64( buf, i ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - return self.values(); - } -}); - -/** -* Returns a new typed array with the element at a provided index replaced with a provided value. -* -* @name with -* @memberof Complex64Array.prototype -* @type {Function} -* @param {integer} index - element index -* @param {ComplexLike} value - new value -* @throws {TypeError} `this` must be a complex number array -* @throws {TypeError} first argument must be an integer -* @throws {RangeError} index argument is out-of-bounds -* @throws {TypeError} second argument must be a complex number -* @returns {Complex64Array} new typed array -* -* @example -* var realf = require( '@stdlib/complex/float32/real' ); -* var imagf = require( '@stdlib/complex/float32/imag' ); -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* -* var arr = new Complex64Array( 3 ); -* -* arr.set( [ 1.0, 1.0 ], 0 ); -* arr.set( [ 2.0, 2.0 ], 1 ); -* arr.set( [ 3.0, 3.0 ], 2 ); -* -* var out = arr.with( 0, new Complex64( 4.0, 4.0 ) ); -* // returns -* -* var z = out.get( 0 ); -* // returns -* -* var re = realf( z ); -* // returns 4.0 -* -* var im = imagf( z ); -* // returns 4.0 -*/ -setReadOnly( Complex64Array.prototype, 'with', function copyWith( index, value ) { - var buf; - var out; - var len; - if ( !isComplexArray( this ) ) { - throw new TypeError( 'invalid invocation. `this` is not a complex number array.' ); - } - if ( !isInteger( index ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); - } - len = this._length; - if ( index < 0 ) { - index += len; - } - if ( index < 0 || index >= len ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); - } - if ( !isComplexLike( value ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a complex number. Value: `%s`.', value ) ); - } - out = new this.constructor( this._buffer ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - buf[ 2*index ] = realf( value ); - buf[ (2*index)+1 ] = imagf( value ); - return out; -}); - - -// EXPORTS // - -module.exports = Complex64Array; diff --git a/complex64/package.json b/complex64/package.json deleted file mode 100644 index f8c7b7599..000000000 --- a/complex64/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/array/complex64", - "version": "0.0.0", - "description": "Complex64Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "complex64array", - "complex64", - "complex", - "cmplx", - "real", - "imaginary", - "imag", - "float", - "single-precision", - "ieee754" - ] -} diff --git a/complex64/test/test.at.js b/complex64/test/test.at.js deleted file mode 100644 index 8e94acab2..000000000 --- a/complex64/test/test.at.js +++ /dev/null @@ -1,147 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `at` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'at' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.at ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.at.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.at( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Complex64Array( 10 ); - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i-arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex64( i, -i ) ); - } - arr = new Complex64Array( arr ); - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - if ( i < 0 ) { - t.strictEqual( realf( v ), arr.length + i, 'returns expected real component for index '+i ); - t.strictEqual( imagf( v ), -arr.length - i, 'returns expected imaginary component for index '+i ); - } else { - t.strictEqual( realf( v ), i, 'returns expected real component for index '+i ); - t.strictEqual( imagf( v ), -i, 'returns expected imaginary component for index '+i ); - } - } - t.end(); -}); diff --git a/complex64/test/test.copy_within.js b/complex64/test/test.copy_within.js deleted file mode 100644 index 163e5e6e1..000000000 --- a/complex64/test/test.copy_within.js +++ /dev/null @@ -1,379 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isPositiveZero = require( '@stdlib/assert/is-positive-zero' ).isPrimitive; -var isNegativeZero = require( '@stdlib/assert/is-negative-zero' ).isPrimitive; -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Float32Array = require( './../../float32' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `copyWithin` method for copying a sequence of array elements within a complex number array', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within an array', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex64( 0.0, -0.0 ), - new Complex64( 1.0, -1.0 ), - new Complex64( 2.0, -2.0 ), - new Complex64( 3.0, -3.0 ), - new Complex64( 4.0, -4.0 ) - ]; - arr = new Complex64Array( arr ); - - arr.copyWithin( 0, 3 ); - - buf = new Float32Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( buf[ 1 ], -3.0, 'returns expected value' ); - t.strictEqual( buf[ 2 ], 4.0, 'returns expected value' ); - t.strictEqual( buf[ 3 ], -4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], 2.0, 'returns expected value' ); - t.strictEqual( buf[ 5 ], -2.0, 'returns expected value' ); - t.strictEqual( buf[ 6 ], 3.0, 'returns expected value' ); - t.strictEqual( buf[ 7 ], -3.0, 'returns expected value' ); - t.strictEqual( buf[ 8 ], 4.0, 'returns expected value' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative target)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex64( 0.0, -0.0 ), - new Complex64( 1.0, -1.0 ), - new Complex64( 2.0, -2.0 ), - new Complex64( 3.0, -3.0 ), - new Complex64( 4.0, -4.0 ) - ]; - arr = new Complex64Array( arr ); - - arr.copyWithin( -arr.length, 3 ); - - buf = new Float32Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( buf[ 1 ], -3.0, 'returns expected value' ); - t.strictEqual( buf[ 2 ], 4.0, 'returns expected value' ); - t.strictEqual( buf[ 3 ], -4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], 2.0, 'returns expected value' ); - t.strictEqual( buf[ 5 ], -2.0, 'returns expected value' ); - t.strictEqual( buf[ 6 ], 3.0, 'returns expected value' ); - t.strictEqual( buf[ 7 ], -3.0, 'returns expected value' ); - t.strictEqual( buf[ 8 ], 4.0, 'returns expected value' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative start)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex64( 0.0, -0.0 ), - new Complex64( 1.0, -1.0 ), - new Complex64( 2.0, -2.0 ), - new Complex64( 3.0, -3.0 ), - new Complex64( 4.0, -4.0 ) - ]; - arr = new Complex64Array( arr ); - - arr.copyWithin( 0, -2 ); - - buf = new Float32Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( buf[ 1 ], -3.0, 'returns expected value' ); - t.strictEqual( buf[ 2 ], 4.0, 'returns expected value' ); - t.strictEqual( buf[ 3 ], -4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], 2.0, 'returns expected value' ); - t.strictEqual( buf[ 5 ], -2.0, 'returns expected value' ); - t.strictEqual( buf[ 6 ], 3.0, 'returns expected value' ); - t.strictEqual( buf[ 7 ], -3.0, 'returns expected value' ); - t.strictEqual( buf[ 8 ], 4.0, 'returns expected value' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (end=length)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex64( 0.0, -0.0 ), - new Complex64( 1.0, -1.0 ), - new Complex64( 2.0, -2.0 ), - new Complex64( 3.0, -3.0 ), - new Complex64( 4.0, -4.0 ) - ]; - arr = new Complex64Array( arr ); - - arr.copyWithin( 0, 3, arr.length ); - - buf = new Float32Array( arr.buffer ); - - // Overwritten: - t.strictEqual( buf[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( buf[ 1 ], -3.0, 'returns expected value' ); - t.strictEqual( buf[ 2 ], 4.0, 'returns expected value' ); - t.strictEqual( buf[ 3 ], -4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 4 ], 2.0, 'returns expected value' ); - t.strictEqual( buf[ 5 ], -2.0, 'returns expected value' ); - t.strictEqual( buf[ 6 ], 3.0, 'returns expected value' ); - t.strictEqual( buf[ 7 ], -3.0, 'returns expected value' ); - t.strictEqual( buf[ 8 ], 4.0, 'returns expected value' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (non-inclusive end)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex64( 0.0, -0.0 ), - new Complex64( 1.0, -1.0 ), - new Complex64( 2.0, -2.0 ), - new Complex64( 3.0, -3.0 ), - new Complex64( 4.0, -4.0 ) - ]; - arr = new Complex64Array( arr ); - - arr.copyWithin( 2, 0, 2 ); - - buf = new Float32Array( arr.buffer ); - - // Remain the same: - t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( buf[ 2 ], 1.0, 'returns expected value' ); - t.strictEqual( buf[ 3 ], -1.0, 'returns expected value' ); - - // Overwritten: - t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected value' ); - t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected value' ); - t.strictEqual( buf[ 6 ], 1.0, 'returns expected value' ); - t.strictEqual( buf[ 7 ], -1.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 8 ], 4.0, 'returns expected value' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (negative end)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex64( 0.0, -0.0 ), - new Complex64( 1.0, -1.0 ), - new Complex64( 2.0, -2.0 ), - new Complex64( 3.0, -3.0 ), - new Complex64( 4.0, -4.0 ) - ]; - arr = new Complex64Array( arr ); - - arr.copyWithin( 2, 0, -3 ); - - buf = new Float32Array( arr.buffer ); - - // Remain the same: - t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( buf[ 2 ], 1.0, 'returns expected value' ); - t.strictEqual( buf[ 3 ], -1.0, 'returns expected value' ); - - // Overwritten: - t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected value' ); - t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected value' ); - t.strictEqual( buf[ 6 ], 1.0, 'returns expected value' ); - t.strictEqual( buf[ 7 ], -1.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( buf[ 8 ], 4.0, 'returns expected value' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target >= length)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex64( 0.0, -0.0 ), - new Complex64( 1.0, -1.0 ), - new Complex64( 2.0, -2.0 ), - new Complex64( 3.0, -3.0 ), - new Complex64( 4.0, -4.0 ) - ]; - arr = new Complex64Array( arr ); - - arr.copyWithin( arr.length, 3 ); - - buf = new Float32Array( arr.buffer ); - - // Remain the same: - t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( buf[ 2 ], 1.0, 'returns expected value' ); - t.strictEqual( buf[ 3 ], -1.0, 'returns expected value' ); - t.strictEqual( buf[ 4 ], 2.0, 'returns expected value' ); - t.strictEqual( buf[ 5 ], -2.0, 'returns expected value' ); - t.strictEqual( buf[ 6 ], 3.0, 'returns expected value' ); - t.strictEqual( buf[ 7 ], -3.0, 'returns expected value' ); - t.strictEqual( buf[ 8 ], 4.0, 'returns expected value' ); - t.strictEqual( buf[ 9 ], -4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within an array (target > start)', function test( t ) { - var arr; - var buf; - - arr = [ - new Complex64( 0.0, -0.0 ), - new Complex64( 1.0, -1.0 ), - new Complex64( 2.0, -2.0 ), - new Complex64( 3.0, -3.0 ), - new Complex64( 4.0, -4.0 ) - ]; - arr = new Complex64Array( arr ); - - arr.copyWithin( 2, 0 ); - - buf = new Float32Array( arr.buffer ); - - // Remain the same: - t.strictEqual( isPositiveZero( buf[ 0 ] ), true, 'returns expected value' ); - t.strictEqual( isNegativeZero( buf[ 1 ] ), true, 'returns expected value' ); - t.strictEqual( buf[ 2 ], 1.0, 'returns expected value' ); - t.strictEqual( buf[ 3 ], -1.0, 'returns expected value' ); - - // Overwritten: - t.strictEqual( isPositiveZero( buf[ 4 ] ), true, 'returns expected value' ); - t.strictEqual( isNegativeZero( buf[ 5 ] ), true, 'returns expected value' ); - t.strictEqual( buf[ 6 ], 1.0, 'returns expected value' ); - t.strictEqual( buf[ 7 ], -1.0, 'returns expected value' ); - t.strictEqual( buf[ 8 ], 2.0, 'returns expected value' ); - t.strictEqual( buf[ 9 ], -2.0, 'returns expected value' ); - - t.end(); -}); diff --git a/complex64/test/test.entries.js b/complex64/test/test.entries.js deleted file mode 100644 index 15bc88f6a..000000000 --- a/complex64/test/test.entries.js +++ /dev/null @@ -1,249 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `entries` method for returning an iterator for iterating over array key-value pairs', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'entries' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.entries ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.entries.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var buf; - var arr; - var it; - var v; - var i; - var j; - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex64Array( buf ); - - it = arr.entries(); - t.strictEqual( it.next.length, 0, 'has zero arity' ); - - j = 0; - for ( i = 0; i < arr.length; i++ ) { - v = it.next(); - t.strictEqual( isArray( v.value ), true, 'returns an array' ); - t.strictEqual( v.value[ 0 ], i, 'returns an index' ); - t.strictEqual( isComplex64( v.value[ 1 ] ), true, 'returns a complex number' ); - t.strictEqual( realf( v.value[ 1 ] ), buf[ j ], 'returns expected real component' ); - t.strictEqual( imagf( v.value[ 1 ] ), buf[ j+1 ], 'returns expected imaginary component' ); - t.strictEqual( typeof v.done, 'boolean', 'returns a boolean' ); - - j += 2; // stride - } - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (no argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex64Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( realf( v.value[ 1 ] ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v.value[ 1 ] ), buf[ 1 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( realf( v.value[ 1 ] ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v.value[ 1 ] ), buf[ 3 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns an iterator which has a `return` method for closing an iterator (argument)', function test( t ) { - var buf; - var arr; - var it; - var v; - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex64Array( buf ); - - it = arr.entries(); - - v = it.next(); - t.strictEqual( realf( v.value[ 1 ] ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v.value[ 1 ] ), buf[ 1 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( realf( v.value[ 1 ] ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v.value[ 1 ] ), buf[ 3 ], 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'finished' ); - t.strictEqual( v.value, 'finished', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Complex64Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex64Array( buf ); - - it1 = arr.entries(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns an object' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1[ 0 ], v2[ 0 ], 'returns expected value' ); - t.strictEqual( realf( v1[ 1 ] ), realf( v2[ 1 ] ), 'returns expected value' ); - t.strictEqual( imagf( v1[ 1 ] ), imagf( v2[ 1 ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Complex64Array; - var arr; - var buf; - var it; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex64Array( buf ); - - it = arr.entries(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/complex64/test/test.every.js b/complex64/test/test.every.js deleted file mode 100644 index ef9543790..000000000 --- a/complex64/test/test.every.js +++ /dev/null @@ -1,175 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `every` method for returning boolean indicating whether all elements pass a test', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'every' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.every ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.every.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( realf( v ) > 0 && imagf( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty complex number array', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array(); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === imagf( v ) ); - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === imagf( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imagf( v ) === realf( v ) ); - } -}); diff --git a/complex64/test/test.fill.js b/complex64/test/test.fill.js deleted file mode 100644 index 5171e567b..000000000 --- a/complex64/test/test.fill.js +++ /dev/null @@ -1,283 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( './../../float32' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `fill` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'fill' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.fill ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill.call( value, new Complex64( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( new Complex64( 1.0, 1.0 ), value ); - }; - } -}); - -tape( 'the method throws an error if provided a third argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.fill( new Complex64( 1.0, 1.0 ), 0, value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex64Array(); - out = arr.fill( new Complex64( 1.0, 1.0 ) ); - - t.strictEqual( out instanceof Complex64Array, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex64Array( 10 ); - out = arr.fill( new Complex64( 1.0, 1.0 ) ); - - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method sets each array element to the provided value', function test( t ) { - var expected; - var arr; - - arr = new Complex64Array( 3 ); - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr.fill( new Complex64( 1.0, 1.0 ) ); - - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with two arguments, the method sets each array element to the provided value starting from a start index (inclusive)', function test( t ) { - var expected; - var arr; - - arr = new Complex64Array( 3 ); - expected = new Float32Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr.fill( new Complex64( 1.0, 1.0 ), 1 ); - - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with three arguments, the method sets each array element to the provided value starting from a start index (inclusive) until a specified end index (exclusive)', function test( t ) { - var expected; - var arr; - - arr = new Complex64Array( 3 ); - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); - - arr.fill( new Complex64( 1.0, 1.0 ), 0, 2 ); - - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - - arr = new Complex64Array( 3 ); - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0 ] ); - - arr.fill( new Complex64( 1.0, 1.0 ), -3, -1 ); - - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided start index resolves to a negative index, the method fills an array starting from the first element', function test( t ) { - var expected; - var arr; - - arr = new Complex64Array( 3 ); - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr.fill( new Complex64( 1.0, 1.0 ), -10 ); - - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided end index resolves to an index exceeding the last array element index, the method fills an array until the last element (inclusive)', function test( t ) { - var expected; - var arr; - - arr = new Complex64Array( 3 ); - expected = new Float32Array( [ 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr.fill( new Complex64( 1.0, 1.0 ), 1, 10 ); - - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if a provided start index resolves to an index which is greater than or equal to a resolved end index, the method does not fill an array', function test( t ) { - var expected; - var arr; - - arr = new Complex64Array( 3 ); - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr.fill( new Complex64( 1.0, 1.0 ), 2, 1 ); - - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.filter.js b/complex64/test/test.filter.js deleted file mode 100644 index 11868894a..000000000 --- a/complex64/test/test.filter.js +++ /dev/null @@ -1,190 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Float32Array = require( './../../float32' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `filter` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'filter' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.filter ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.filter.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( realf( v ) > 0 && imagf( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex64Array(); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) > 0 && imagf( v ) < 0 ); - } -}); - -tape( 'the method returns a new complex number array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 1.0, -1.0, 3.0, -3.0 ] ); - actual = arr.filter( predicate ); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) > 0 && imagf( v ) < 0 ); - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.filter( predicate ); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) > 0 && imagf( v ) < 0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var ctx; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 1.0, -1.0, 3.0, -3.0 ] ); - ctx = { - 'count': 0 - }; - actual = arr.filter( predicate, ctx ); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( realf( v ) > 0 && imagf( v ) < 0 ); - } -}); diff --git a/complex64/test/test.find.js b/complex64/test/test.find.js deleted file mode 100644 index 9de0fda5d..000000000 --- a/complex64/test/test.find.js +++ /dev/null @@ -1,177 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `find` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'find' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.find ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.find.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( realf( v ) > 0 && imagf( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.find( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty complex number array', function test( t ) { - var arr; - var z; - - arr = new Complex64Array(); - z = arr.find( predicate ); - - t.strictEqual( z, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the first element which passes a test', function test( t ) { - var arr; - var z; - - arr = new Complex64Array( [ 1.0, 1.0, 2.0, -2.0 ] ); - z = arr.find( predicate ); - - t.strictEqual( realf( z ), 2.0, 'returns expected value' ); - t.strictEqual( imagf( z ), -2.0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === -imagf( v ) ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var z; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - z = arr.find( predicate ); - - t.strictEqual( z, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === imagf( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var z; - - ctx = { - 'count': 0 - }; - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); - z = arr.find( predicate, ctx ); - - t.strictEqual( realf( z ), 3, 'returns expected value' ); - t.strictEqual( imagf( z ), 3, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imagf( v ) === realf( v ) ); - } -}); diff --git a/complex64/test/test.find_index.js b/complex64/test/test.find_index.js deleted file mode 100644 index f87f978ef..000000000 --- a/complex64/test/test.find_index.js +++ /dev/null @@ -1,175 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'findIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.findIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( realf( v ) > 0 && imagf( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty complex number array', function test( t ) { - var arr; - var idx; - - arr = new Complex64Array(); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the first element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Complex64Array( [ 1.0, 1.0, 2.0, -2.0 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === -imagf( v ) ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - idx = arr.findIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === imagf( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); - idx = arr.findIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imagf( v ) === realf( v ) ); - } -}); diff --git a/complex64/test/test.find_last.js b/complex64/test/test.find_last.js deleted file mode 100644 index 2378969d8..000000000 --- a/complex64/test/test.find_last.js +++ /dev/null @@ -1,177 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLast` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'findLast' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.findLast ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLast.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( realf( v ) > 0 && imagf( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLast( value ); - }; - } -}); - -tape( 'the method returns `undefined` if operating on an empty complex number array', function test( t ) { - var arr; - var z; - - arr = new Complex64Array(); - z = arr.findLast( predicate ); - - t.strictEqual( z, void 0, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the last element which passes a test', function test( t ) { - var arr; - var z; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - z = arr.findLast( predicate ); - - t.strictEqual( realf( z ), 2.0, 'returns expected value' ); - t.strictEqual( imagf( z ), -2.0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === -imagf( v ) ); - } -}); - -tape( 'the method returns `undefined` if all elements fail a test', function test( t ) { - var arr; - var z; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - z = arr.findLast( predicate ); - - t.strictEqual( z, void 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === imagf( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var z; - - ctx = { - 'count': 0 - }; - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); - z = arr.findLast( predicate, ctx ); - - t.strictEqual( realf( z ), 3, 'returns expected value' ); - t.strictEqual( imagf( z ), 3, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imagf( v ) === realf( v ) ); - } -}); diff --git a/complex64/test/test.find_last_index.js b/complex64/test/test.find_last_index.js deleted file mode 100644 index 6b4f92408..000000000 --- a/complex64/test/test.find_last_index.js +++ /dev/null @@ -1,175 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `findLastIndex` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'findLastIndex' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.findLastIndex ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLastIndex.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( realf( v ) > 0 && imagf( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.findLastIndex( value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty complex number array', function test( t ) { - var arr; - var idx; - - arr = new Complex64Array(); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns the index of the last element which passes a test', function test( t ) { - var arr; - var idx; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === -imagf( v ) ); - } -}); - -tape( 'the method returns `-1` if all elements fail a test', function test( t ) { - var arr; - var idx; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - idx = arr.findLastIndex( predicate ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === imagf( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - var idx; - - ctx = { - 'count': 0 - }; - arr = new Complex64Array( [ 1.0, -1.0, 2.0, 2.0, 3.0, 3.0 ] ); - idx = arr.findLastIndex( predicate, ctx ); - - t.strictEqual( idx, 2, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imagf( v ) === realf( v ) ); - } -}); diff --git a/complex64/test/test.for_each.js b/complex64/test/test.for_each.js deleted file mode 100644 index ab30241b6..000000000 --- a/complex64/test/test.for_each.js +++ /dev/null @@ -1,176 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `forEach` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'forEach' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.forEach ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( !isComplex64( v ) ) { - t.fail( 'should be a complex number ' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty complex number array', function test( t ) { - var arr; - - arr = new Complex64Array(); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( !isComplex64( v ) ) { - t.fail( 'should be a complex number' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var expected; - var arr; - - expected = []; - arr = new Complex64Array( [ 1.0, 1.0, 2.0, -2.0 ] ); - arr.forEach( fcn ); - expected = new Complex64Array( expected ); - - t.deepEqual( reinterpret64( expected, 0 ), reinterpret64( arr, 0 ), 'returns expected value' ); - t.end(); - - function fcn( v ) { - expected.push( v ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/complex64/test/test.from.js b/complex64/test/test.from.js deleted file mode 100644 index 363aa9216..000000000 --- a/complex64/test/test.from.js +++ /dev/null @@ -1,1254 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float32Array = require( './../../float32' ); -var Complex128Array = require( './../../complex128' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `from` method for creating a complex number array from an array-like object or iterable', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Complex64Array, 'from' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.from ), true, 'has method' ); - - arr = Complex64Array.from( [] ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex array constructor', function test( t ) { - var values; - var i; - - values = [ - Complex64, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from.call( value, [] ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from( value, clbk ); - }; - } - - function clbk() { - return [ 1.0, 1.0 ]; - } -}); - -tape( 'the method throws an error if not provided an iterable or array-like object (callback, thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from( value, clbk, {} ); - }; - } - - function clbk() { - return [ 1.0, 1.0 ]; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from( [], value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a function (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from( [], value, {} ); - }; - } -}); - -tape( 'the method returns a complex number array', function test( t ) { - var arr; - var z; - var v; - - // Generic array: - arr = Complex64Array.from( [] ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex64Array.from( [ 1.0, 2.0, 3.0, 4.0 ] ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Generic array containing complex numbers: - arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ] ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex64( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex64Array.from( [ z, 1.0 ] ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex64( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex64Array.from( [ 1.0, z ] ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Typed array: - arr = Complex64Array.from( new Float32Array( 0 ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex64Array.from( new Float32Array( [ 1.0, 1.0 ] ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Complex typed array: - arr = Complex64Array.from( new Complex64Array( 0 ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex64Array.from( new Complex64Array( [ 1.0, 1.0 ] ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Complex64Array.from( new Complex128Array( 0 ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex64Array.from( new Complex128Array( [ 1.0, 1.0 ] ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - t.end(); - - function valueOf( z ) { - return function valueOf() { - return realf( z ); - }; - } -}); - -tape( 'the method returns a complex number array (iterable)', function test( t ) { - var Complex64Array; - var iter1; - var iter2; - var arr; - var v; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter1 = { - 'next': next1, - 'i': 0, - 'N': 4 - }; - arr = Complex64Array.from( createIterable( iter1 ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter1.N, 'returns expected value' ); - - iter2 = { - 'next': next2, - 'i': 0, - 'N': 4 - }; - arr = Complex64Array.from( createIterable( iter2 ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter2.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next1() { - iter1.i += 1; - if ( iter1.i <= iter1.N ) { - return { - 'value': [ 1.0, 1.0 ] - }; - } - return { - 'done': true - }; - } - - function next2() { - iter2.i += 1; - if ( iter2.i <= iter2.N ) { - return { - 'value': new Complex64( 1.0, 1.0 ) - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each source element', function test( t ) { - var arr; - var z; - var v; - - // Generic array: - arr = Complex64Array.from( [], clbk1 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex64Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Generic array containing complex numbers: - arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk2 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk3a ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex64( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex64Array.from( [ z, 1.0 ], clbk1 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex64( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex64Array.from( [ 1.0, z ], clbk1 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Typed array: - arr = Complex64Array.from( new Float32Array( 0 ), clbk1 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex64Array.from( new Float32Array( [ 1.0, 1.0 ] ), clbk1 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Complex typed array: - arr = Complex64Array.from( new Complex64Array( 0 ), clbk3a ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex64Array.from( new Complex64Array( [ 1.0, 1.0 ] ), clbk3a ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Complex64Array.from( new Complex64Array( 0 ), clbk3b ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex64Array.from( new Complex64Array( [ 1.0, 1.0 ] ), clbk3b ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Complex64Array.from( new Complex128Array( 0 ), clbk4a ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex64Array.from( new Complex128Array( [ 1.0, 1.0 ] ), clbk4a ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = Complex64Array.from( new Complex128Array( 0 ), clbk4b ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = Complex64Array.from( new Complex128Array( [ 1.0, 1.0 ] ), clbk4b ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - t.end(); - - function valueOf( z ) { - return function valueOf() { - return realf( z ); - }; - } - - function clbk1( v ) { - return v; - } - - function clbk2() { - return [ 1.0, 1.0 ]; - } - - function clbk3a( v ) { - return new Complex64( realf(v)*2.0, imagf(v)*2.0 ); - } - - function clbk3b( v ) { - return [ realf(v)*2.0, imagf(v)*2.0 ]; - } - - function clbk4a( v ) { - return new Complex64( real(v)*2.0, imag(v)*2.0 ); - } - - function clbk4b( v ) { - return [ real(v)*2.0, imag(v)*2.0 ]; - } -}); - -tape( 'the method supports providing a "map" function which is invoked for each iterated value', function test( t ) { - var Complex64Array; - var iter1; - var iter2; - var arr; - var v; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter1 = { - 'next': next1, - 'i': 0, - 'N': 4 - }; - arr = Complex64Array.from( createIterable( iter1 ), clbk1 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter1.N, 'returns expected value' ); - - iter2 = { - 'next': next2, - 'i': 0, - 'N': 4 - }; - arr = Complex64Array.from( createIterable( iter2 ), clbk2 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, iter2.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next1() { - iter1.i += 1; - if ( iter1.i <= iter1.N ) { - return { - 'value': [ 1.0, 1.0 ] - }; - } - return { - 'done': true - }; - } - - function clbk1( v ) { - v[ 0 ] += 1.0; - v[ 1 ] += 1.0; - return v; - } - - function next2() { - iter2.i += 1; - if ( iter2.i <= iter2.N ) { - return { - 'value': new Complex64( 1.0, 1.0 ) - }; - } - return { - 'done': true - }; - } - - function clbk2( v ) { - return new Complex64( realf(v)*2.0, imagf(v)*2.0 ); - } -}); - -tape( 'the method supports providing a `this` context for a provided map function', function test( t ) { - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - arr = Complex64Array.from( [ 1.0, 2.0, 3.0, 4.0 ], clbk1, ctx ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - ctx = { - 'count': 0 - }; - arr = [ new Complex64( 1.0, 1.0 ), new Complex64( -1.0, -1.0 ) ]; - arr = Complex64Array.from( arr, clbk2, ctx ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 2, 'returns expected value' ); - - t.end(); - - function clbk1( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v; - } - - function clbk2( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return new Complex64( realf(v)*2.0, imagf(v)*2.0 ); - } -}); - -tape( 'the method supports providing a `this` context for a provided map function (iterable)', function test( t ) { - var Complex64Array; - var iter; - var ctx; - var arr; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter = { - 'next': next, - 'i': 0, - 'N': 4 - }; - ctx = { - 'count': 0 - }; - - arr = Complex64Array.from( createIterable( iter ), clbk, ctx ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next() { - iter.i += 1; - if ( iter.i <= iter.N ) { - return { - 'value': [ 1.0, 1.0 ] - }; - } - return { - 'done': true - }; - } - - function clbk( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - v[ 0 ] += 1.0; - v[ 1 ] += 1.0; - return v; - } -}); - -tape( 'the method throws an error if provided a generic array-like object having an odd length', function test( t ) { - var values; - var i; - - values = [ - [ 1, 2, 3 ], - new Float32Array( [ 1, 2, 3 ] ), - { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }, - [ new Complex64( 1.0, 1.0 ), 1.0, 1.0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an array-like object having a length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from( value ); - }; - } -}); - -tape( 'the method throws an error if provided a generic array-like object having an odd length (clbk)', function test( t ) { - var values; - var i; - - values = [ - [ 1, 2, 3 ], - new Float32Array( [ 1, 2, 3 ] ), - { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }, - [ new Complex64( 1.0, 1.0 ), 1.0, 1.0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an array-like object having a length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from( value, clbk ); - }; - } - - function clbk() { - return [ 1.0, 1.0 ]; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Complex64Array; - var values; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the method throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Complex64Array; - var values; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the method throws an error if provided an iterable object which does not return complex numbers or arrays of real and imaginary components', function test( t ) { - var Complex64Array; - var values; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': 1.0 - }; - } - - function next2() { - return { - 'value': '1.0 + 1.0i' - }; - } -}); - -tape( 'the method throws an error if provided an iterable object which does not return an array-like object containing at least two elements', function test( t ) { - var Complex64Array; - var values; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.from( value ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': [] - }; - } - - function next2() { - return { - 'value': [ 1.0 ] - }; - } -}); - -tape( 'the method throws an error if provided a complex number source array and a "map" function which does not return complex numbers or arrays of real and imaginary components (collection)', function test( t ) { - var values; - var clbks; - var i; - - values = [ - [ new Complex64( 1.0, 1.0 ) ], - [ new Complex64( 1.0, 1.0 ), new Complex64( -1.0, -1.0 ) ] - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex64Array.from( value, clbk ); - }; - } - - function clbk1() { - return 1.0; - } - - function clbk2() { - return {}; - } -}); - -tape( 'the method throws an error if provided a complex number source array and a "map" function which does not return an array containing at least two elements (collection)', function test( t ) { - var values; - var clbks; - var i; - - values = [ - [ new Complex64( 1.0, 1.0 ) ], - [ new Complex64( 1.0, 1.0 ), new Complex64( -1.0, -1.0 ) ] - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex64Array.from( value, clbk ); - }; - } - - function clbk1() { - return []; - } - - function clbk2() { - return [ 1.0 ]; - } -}); - -tape( 'the method throws an error if provided a complex number source array and a "map" function which does not return complex numbers or arrays of real and imaginary components (complex array)', function test( t ) { - var values; - var clbks; - var i; - - values = [ - new Complex64Array( [ 1.0, 1.0 ] ), - new Complex64Array( [ 1.0, 1.0, -1.0, -1.0 ] ) - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex64Array.from( value, clbk ); - }; - } - - function clbk1() { - return 1.0; - } - - function clbk2() { - return {}; - } -}); - -tape( 'the method throws an error if provided a complex number source array and a "map" function which does not return an array containing at least two elements (complex array)', function test( t ) { - var values; - var clbks; - var i; - - values = [ - new Complex64Array( [ 1.0, 1.0 ] ), - new Complex64Array( [ 1.0, 1.0, -1.0, -1.0 ] ) - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex64Array.from( value, clbk ); - }; - } - - function clbk1() { - return []; - } - - function clbk2() { - return [ 1.0 ]; - } -}); - -tape( 'the method throws an error if provided a "map" function which does not return complex numbers or arrays of real and imaginary components (iterable)', function test( t ) { - var Complex64Array; - var values; - var clbks; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex64Array.from( value, clbk ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': [ 1.0, 1.0 ] - }; - } - - function clbk1() { - return 1.0; - } - - function next2() { - return { - 'value': new Complex64( 1.0, 1.0 ) - }; - } - - function clbk2() { - return '1.0 - 1.0j'; - } -}); - -tape( 'the method throws an error if provided a "map" function which does not return an array containing at least two elements (iterable)', function test( t ) { - var Complex64Array; - var values; - var clbks; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - clbks = [ - clbk1, - clbk2 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i], clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( value, clbk ) { - return function badValue() { - return Complex64Array.from( value, clbk ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': [ 1.0, 1.0 ] - }; - } - - function clbk1() { - return []; - } - - function next2() { - return { - 'value': new Complex64( 1.0, 1.0 ) - }; - } - - function clbk2() { - return [ 1.0 ]; - } -}); diff --git a/complex64/test/test.get.js b/complex64/test/test.get.js deleted file mode 100644 index 55b012644..000000000 --- a/complex64/test/test.get.js +++ /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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `get` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'get' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.get ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.get.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.get( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var arr; - var v; - var i; - - arr = new Complex64Array( 10 ); - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var arr; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( new Complex64( i, -i ) ); - } - arr = new Complex64Array( arr ); - - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( realf( v ), i, 'returns expected real component for index '+i ); - t.strictEqual( imagf( v ), -i, 'returns expected imaginary component for index '+i ); - } - t.end(); -}); diff --git a/complex64/test/test.includes.js b/complex64/test/test.includes.js deleted file mode 100644 index feaf0caf0..000000000 --- a/complex64/test/test.includes.js +++ /dev/null @@ -1,242 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `includes` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'includes' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.includes ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes.call( value, new Complex64( 10.0, 10.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes( new Complex64( 1.0, 1.0 ), value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty complex number array', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array(); - bool = arr.includes( new Complex64( 1.0, 1.0 ) ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if a complex number is not found', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array( 10 ); - bool = arr.includes( new Complex64( 1.0, 1.0 ) ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `true` if an array contains a specified complex number', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array( 10 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - bool = arr.includes( new Complex64( 2.0, 2.0 ) ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `false` if provided a second argument which exceeds the input array length', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array( 10 ); - bool = arr.includes( new Complex64( 1.0, 1.0), 20 ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array( 10 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - - bool = arr.includes( new Complex64( 2.0, 2.0 ), 0 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( new Complex64( 2.0, 2.0 ), 2 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( new Complex64( 3.0, 3.0 ), 3 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - bool = arr.includes( new Complex64( 2.0, 2.0 ), -5 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( new Complex64( 4.0, 4.0 ), -2 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - bool = arr.includes( new Complex64( 2.0, 2.0 ), -10 ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = arr.includes( new Complex64( 4.0, 4.0 ), -10 ); - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.index_of.js b/complex64/test/test.index_of.js deleted file mode 100644 index 9f5698050..000000000 --- a/complex64/test/test.index_of.js +++ /dev/null @@ -1,242 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is an `indexOf` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'indexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.indexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf.call( value, new Complex64( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf( new Complex64( 1.0, 1.0 ), value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty complex number array', function test( t ) { - var arr; - var idx; - - arr = new Complex64Array(); - idx = arr.indexOf( new Complex64( 1.0, 1.0 ) ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a complex number is not found', function test( t ) { - var idx; - var arr; - - arr = new Complex64Array( 10 ); - idx = arr.indexOf( new Complex64( 1.0, 1.0 ) ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match if a complex number is found', function test( t ) { - var idx; - var arr; - - arr = new Complex64Array( 10 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - idx = arr.indexOf( new Complex64( 2.0, 2.0 ) ); - - t.strictEqual( idx, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds the input array length', function test( t ) { - var idx; - var arr; - - arr = new Complex64Array( 10 ); - idx = arr.indexOf( new Complex64( 1.0, 1.0), 20 ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Complex64Array( 10 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - - idx = arr.indexOf( new Complex64( 2.0, 2.0 ), 0 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( new Complex64( 2.0, 2.0 ), 2 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.indexOf( new Complex64( 3.0, 3.0 ), 3 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Complex64Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - idx = arr.indexOf( new Complex64( 2.0, 2.0 ), -5 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( new Complex64( 4.0, 4.0 ), -2 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index which is less than zero, the method searches from the first array element', function test( t ) { - var idx; - var arr; - - arr = new Complex64Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - idx = arr.indexOf( new Complex64( 2.0, 2.0 ), -10 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.indexOf( new Complex64( 4.0, 4.0 ), -10 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.join.js b/complex64/test/test.join.js deleted file mode 100644 index ba626c57a..000000000 --- a/complex64/test/test.join.js +++ /dev/null @@ -1,162 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `join` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'join' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.join.call( value ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.join( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Complex64Array(); - str = arr.join(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a complex number array with elements separated by a separator', function test( t ) { - var expected; - var str; - var arr; - - arr = new Complex64Array( [ 1, 2, -3, -4 ] ); - expected = '1 + 2i@-3 - 4i'; - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a complex number array with elements separated by a separator (single element)', function test( t ) { - var expected; - var str; - var arr; - - arr = new Complex64Array( [ 1, 2 ] ); - expected = '1 + 2i'; - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new Complex64Array( [ 1, 2 ] ); - expected = '1 + 2i'; - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if method invoked without a separator argument, the method returns a string representation of a complex number array with elements separated by a comma', function test( t ) { - var expected; - var str; - var arr; - - arr = new Complex64Array( [ 1, 2, -3, -4 ] ); - expected = '1 + 2i,-3 - 4i'; - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.js b/complex64/test/test.js deleted file mode 100644 index 07555d4c5..000000000 --- a/complex64/test/test.js +++ /dev/null @@ -1,959 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var ArrayBuffer = require( './../../buffer' ); -var Float32Array = require( './../../float32' ); -var Complex128Array = require( './../../complex128' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var arr = new Complex64Array( 0 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor does not require the `new` keyword', function test( t ) { - var ctor; - var arr; - - ctor = Complex64Array; - - arr = ctor( 0 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (no argument)', function test( t ) { - var arr = new Complex64Array(); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (no argument, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex64Array; - - arr = ctor(); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (length)', function test( t ) { - var arr = new Complex64Array( 10 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex64Array; - - arr = ctor( 10 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (array)', function test( t ) { - var arr = new Complex64Array( [] ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex64Array; - - arr = ctor( [] ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (typed array)', function test( t ) { - var arr = new Complex64Array( new Float32Array( 0 ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex64Array; - - arr = ctor( new Float32Array( 0 ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (complex typed array)', function test( t ) { - var arr = new Complex64Array( new Complex64Array( 0 ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (complex typed array, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex64Array; - - arr = ctor( new Complex64Array( 0 ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (iterable)', function test( t ) { - var Complex64Array; - var arr; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - arr = new Complex64Array( createIterable() ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 64-bit complex number array (iterable, no new)', function test( t ) { - var ctor; - var arr; - - ctor = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - arr = ctor( createIterable() ); - t.strictEqual( arr instanceof ctor, true, 'returns an instance' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable() { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -tape( 'the constructor returns a 64-bit complex number array (ArrayBuffer)', function test( t ) { - var arr = new Complex64Array( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (ArrayBuffer, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex64Array; - - arr = ctor( new ArrayBuffer( 0 ) ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (ArrayBuffer, byte offset)', function test( t ) { - var arr = new Complex64Array( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (ArrayBuffer, byte offset, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex64Array; - - arr = ctor( new ArrayBuffer( 8 ), 8 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (ArrayBuffer, byte offset, length)', function test( t ) { - var arr = new Complex64Array( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor returns a 64-bit complex number array (ArrayBuffer, byte offset, length, no new)', function test( t ) { - var ctor; - var arr; - - ctor = Complex64Array; - - arr = ctor( new ArrayBuffer( 8 ), 8, 0 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'attached to the constructor is a property returning the number of bytes per array element', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex64Array.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a property returning the constructor name', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array, 'name' ), true, 'has property' ); - t.strictEqual( Complex64Array.name, 'Complex64Array', 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `BYTES_PER_ELEMENT` property returning the number of bytes per array element', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'BYTES_PER_ELEMENT' ), true, 'has property' ); - t.strictEqual( Complex64Array.prototype.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - - arr = new Complex64Array( 0 ); - t.strictEqual( arr.BYTES_PER_ELEMENT, 8, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `buffer` property for returning the underlying memory (i.e., ArrayBuffer)', function test( t ) { - var arr; - var buf; - - arr = new Complex64Array( 0 ); - buf = arr.buffer; - t.strictEqual( isArrayBuffer( buf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteLength` property for returning the number of bytes belonging to the array view', function test( t ) { - var arr; - var v; - - arr = new Complex64Array( 0 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex64Array( new ArrayBuffer( 64 ), 8 ); - v = arr.byteLength; - t.strictEqual( v, 56, 'returns expected value' ); - - arr = new Complex64Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteLength; - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `byteOffset` property for returning the byte offset pointing to the first array element in the underlying memory', function test( t ) { - var arr; - var v; - - arr = new Complex64Array( 0 ); - v = arr.byteOffset; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex64Array( new ArrayBuffer( 64 ), 32 ); - v = arr.byteOffset; - t.strictEqual( v, 32, 'returns expected value' ); - - arr = new Complex64Array( new ArrayBuffer( 64 ), 64 ); - v = arr.byteOffset; - t.strictEqual( v, 64, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements', function test( t ) { - var arr; - var z; - var v; - - // No arguments: - arr = new Complex64Array(); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Explicit array length: - arr = new Complex64Array( 0 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex64Array( 10 ); - v = arr.length; - t.strictEqual( v, 10, 'returns expected value' ); - - // Generic array: - arr = new Complex64Array( [] ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Generic array containing complex numbers: - arr = new Complex64Array( [ new Complex64( 1.0, 1.0 ) ] ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex64( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = new Complex64Array( [ z, 1.0 ] ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex64( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = new Complex64Array( [ 1.0, z ] ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Typed array: - arr = new Complex64Array( new Float32Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex64Array( new Float32Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // Complex typed array: - arr = new Complex64Array( new Complex64Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex64Array( new Complex64Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - arr = new Complex64Array( new Complex128Array( 0 ) ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex64Array( new Complex128Array( [ 1.0, 1.0 ] ) ); - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - // ArrayBuffer: - arr = new Complex64Array( new ArrayBuffer( 64 ), 32 ); - v = arr.length; - t.strictEqual( v, 4, 'returns expected value' ); - - arr = new Complex64Array( new ArrayBuffer( 64 ), 64 ); - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - arr = new Complex64Array( new ArrayBuffer( 64 ), 32, 2 ); - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - t.end(); - - function valueOf( z ) { - return function valueOf() { - return realf( z ); - }; - } -}); - -tape( 'the constructor returns an instance having a `length` property for returning the number of array elements (iterable)', function test( t ) { - var Complex64Array; - var iter1; - var iter2; - var arr; - var v; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - iter1 = { - 'next': next1, - 'i': 0, - 'N': 4 - }; - arr = new Complex64Array( createIterable( iter1 ) ); - v = arr.length; - t.strictEqual( v, iter1.N, 'returns expected value' ); - - iter2 = { - 'next': next2, - 'i': 0, - 'N': 4 - }; - arr = new Complex64Array( createIterable( iter2 ) ); - v = arr.length; - t.strictEqual( v, iter2.N, 'returns expected value' ); - - t.end(); - - function hasSupport() { - return true; - } - - function createIterable( iterator ) { - var it = {}; - it[ '__SYMBOL_ITERATOR__' ] = iterable; - return it; - - function iterable() { - return iterator; - } - } - - function next1() { - iter1.i += 1; - if ( iter1.i <= iter1.N ) { - return { - 'value': [ 1.0, 1.0 ] - }; - } - return { - 'done': true - }; - } - - function next2() { - iter2.i += 1; - if ( iter2.i <= iter2.N ) { - return { - 'value': new Complex64( 1.0, 1.0 ) - }; - } - return { - 'done': true - }; - } -}); - -tape( 'the constructor throws an error if provided an ArrayBuffer which is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 9, - 74, - 801 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an ArrayBuffer having a byte length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( new ArrayBuffer( value ) ); - }; - } -}); - -tape( 'the constructor throws an error if provided an array-like object having an odd length', function test( t ) { - var values; - var i; - - values = [ - [ 1, 2, 3 ], - new Float32Array( [ 1, 2, 3 ] ), - { - 'length': 3, - '0': 1, - '1': 2, - '2': 3 - }, - [ new Complex64( 1.0, 1.0 ), 1.0, 1.0 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided an array-like object having a length equal to '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (non-ES2015+)', function test( t ) { - var Complex64Array; - var values; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( value ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the constructor throws an error if provided a non-iterable object (ES2015+)', function test( t ) { - var Complex64Array; - var values; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - {}, - { - '0': 1, - '1': 2, - '2': 3 - }, - { - '__SYMBOL_ITERATOR__': null - }, - { - '__SYMBOL_ITERATOR__': 'beep' - }, - { - '__SYMBOL_ITERATOR__': nonIterable1 - }, - { - '__SYMBOL_ITERATOR__': nonIterable2 - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function nonIterable1() { - return null; - } - - function nonIterable2() { - return {}; - } -}); - -tape( 'the constructor throws an error if provided an iterable object which does not return complex numbers or arrays of real and imaginary components', function test( t ) { - var Complex64Array; - var values; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': 1.0 - }; - } - - function next2() { - return { - 'value': '1.0 + 1.0i' - }; - } -}); - -tape( 'the constructor throws an error if provided an iterable object which does not return array containing at least two elements', function test( t ) { - var Complex64Array; - var values; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__SYMBOL_ITERATOR__' - }); - - values = [ - { - '__SYMBOL_ITERATOR__': createIterable( next1 ) - }, - { - '__SYMBOL_ITERATOR__': createIterable( next2 ) - } - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( value ); - }; - } - - function hasSupport() { - return true; - } - - function createIterable( next ) { - return iterable; - - function iterable() { - return { - 'next': next - }; - } - } - - function next1() { - return { - 'value': [] - }; - } - - function next2() { - return { - 'value': [ 1.0 ] - }; - } -}); - -tape( 'the constructor throws an error if not provided a length, iterable, array-like object, or ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( value ); - }; - } -}); - -tape( 'the constructor throws an error if provided more than one argument and the first argument is not an ArrayBuffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( value, 0 ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( new ArrayBuffer( 64 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument which is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 9, - 65, - 78, - 801 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( new ArrayBuffer( 1e3 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a byte offset argument such that the view byte length is not a multiple of 8', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32, - 48, - 56, - 64, - 72, - 80, - 88 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( new ArrayBuffer( 102 ), value ); - }; - } -}); - -tape( 'the constructor throws an error if provided a length argument which is not a nonnegative integer (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - -1, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( new ArrayBuffer( 64 ), 0, value ); - }; - } -}); - -tape( 'the constructor throws an error if provided insufficient memory to accommodate byte offset and length arguments', function test( t ) { - var values; - var i; - - values = [ - 8, - 16, - 24, - 32 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return new Complex64Array( new ArrayBuffer( 100 ), value, 1e3 ); - }; - } -}); diff --git a/complex64/test/test.keys.js b/complex64/test/test.keys.js deleted file mode 100644 index 9fba96201..000000000 --- a/complex64/test/test.keys.js +++ /dev/null @@ -1,261 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `keys` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'keys' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.keys ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.keys.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - expected = [ - { - 'value': 0, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( r.value, e.value, 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Complex64Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.keys(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - it = arr.keys(); - - v = it.next(); - t.strictEqual( v.value, 0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, 1, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Complex64Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex64Array( buf ); - - it1 = arr.keys(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns an object' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( v1, v2, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Complex64Array; - var arr; - var buf; - var it; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex64Array( buf ); - - it = arr.keys(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/complex64/test/test.last_index_of.js b/complex64/test/test.last_index_of.js deleted file mode 100644 index 458eaaed2..000000000 --- a/complex64/test/test.last_index_of.js +++ /dev/null @@ -1,232 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `lastIndexOf` method for returning an array element', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'lastIndexOf' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.lastIndexOf ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf.call( value, new Complex64( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf( new Complex64( 1.0, 1.0 ), value ); - }; - } -}); - -tape( 'the method returns `-1` if operating on an empty complex number array', function test( t ) { - var arr; - var idx; - - arr = new Complex64Array(); - idx = arr.lastIndexOf( new Complex64( 1.0, 1.0 ) ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if a complex number is not found', function test( t ) { - var idx; - var arr; - - arr = new Complex64Array( 10 ); - idx = arr.lastIndexOf( new Complex64( 1.0, 1.0 ) ); - - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns the index of the first match when searching from the end of the array if a search element is found', function test( t ) { - var idx; - var arr; - - arr = new Complex64Array( 10 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - idx = arr.lastIndexOf( new Complex64( 2.0, 2.0 ) ); - - t.strictEqual( idx, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var idx; - var arr; - - arr = new Complex64Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 3.0, 3.0 ], 4 ); - - idx = arr.lastIndexOf( new Complex64( 2.0, 2.0 ), 4 ); - t.strictEqual( idx, 3, 'returns expected value' ); - - idx = arr.lastIndexOf( new Complex64( 2.0, 2.0 ), 2 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.lastIndexOf( new Complex64( 3.0, 3.0 ), 1 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var idx; - var arr; - - arr = new Complex64Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - idx = arr.lastIndexOf( new Complex64( 2.0, 2.0 ), -3 ); - t.strictEqual( idx, 1, 'returns expected value' ); - - idx = arr.lastIndexOf( new Complex64( 3.0, 3.0 ), -1 ); - t.strictEqual( idx, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var idx; - var arr; - - arr = new Complex64Array( 5 ); - arr.set( [ 1.0, 1.0 ], 0 ); - arr.set( [ 2.0, 2.0 ], 1 ); - arr.set( [ 3.0, 3.0 ], 2 ); - arr.set( [ 2.0, 2.0 ], 3 ); - arr.set( [ 2.0, 2.0 ], 4 ); - - idx = arr.lastIndexOf( new Complex64( 2.0, 2.0 ), 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( new Complex64( 4.0, 4.0 ), 10 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.map.js b/complex64/test/test.map.js deleted file mode 100644 index 62083ce0c..000000000 --- a/complex64/test/test.map.js +++ /dev/null @@ -1,231 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var identity = require( '@stdlib/utils/identity-function' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Float32Array = require( './../../float32' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `map` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'map' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.map ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex64Array(); - out = arr.map( identity ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new complex number array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); - actual = arr.map( scale ); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return new Complex64( realf( v )*2.0, imagf( v )*2.0 ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var arr; - var ctx; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 3.0, -3.0, 6.0, -6.0, 9.0, -9.0 ] ); - ctx = { - 'count': 0 - }; - actual = arr.map( scale, ctx ); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - t.end(); - - function scale( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return new Complex64( realf( v )*3.0, imagf( v )*3.0 ); - } -}); - -tape( 'the method supports a map function which returns a two-element array containing a real and an imaginary component', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 2.0, -2.0, 4.0, -4.0, 6.0, -6.0 ] ); - actual = arr.map( scale ); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); - - function scale( v ) { - return [ realf( v )*2.0, imagf( v )*2.0 ]; - } -}); - -tape( 'the method throws an error if provided a map function which does not return a complex number or an array of length 2 containing real and imaginary components', function test( t ) { - var clbks; - var arr; - var i; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - clbks = [ - clbk1, - clbk2, - clbk3, - clbk4, - clbk5 - ]; - for ( i = 0; i < clbks.length; i++ ) { - t.throws( badValue( clbks[i] ), TypeError, 'throws an error when provided callback '+i ); - } - t.end(); - - function badValue( clbk ) { - return function badValue() { - return arr.map( clbk ); - }; - } - - function clbk1() { - return 1.0; - } - - function clbk2() { - return {}; - } - - function clbk3() { - return [ 1.0, 2.0, 3.0 ]; - } - - function clbk4() { - return []; - } - - function clbk5() { - return [ 1.0 ]; - } -}); diff --git a/complex64/test/test.of.js b/complex64/test/test.of.js deleted file mode 100644 index 11a4288e2..000000000 --- a/complex64/test/test.of.js +++ /dev/null @@ -1,149 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `of` method for creating a complex number array from a variable number of arguments', function test( t ) { - var arr; - - t.strictEqual( hasOwnProp( Complex64Array, 'of' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.of ), true, 'has method' ); - - arr = Complex64Array.of(); - t.strictEqual( arr instanceof Complex64Array, true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a constructor', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.of.call( value, 1.0, 1.0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex array constructor', function test( t ) { - var values; - var i; - - values = [ - Complex64, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return Complex64Array.of.call( value, 1.0, 1.0 ); - }; - } -}); - -tape( 'the method returns a complex number array', function test( t ) { - var arr; - var z; - var v; - - // No arguments: - arr = Complex64Array.of(); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 0, 'returns expected value' ); - - // Interleaved real and imaginary components: - arr = Complex64Array.of( 1.0, 2.0, 3.0, 4.0 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 2, 'returns expected value' ); - - // Complex numbers: - z = new Complex64( 1.0, 1.0 ); - arr = Complex64Array.of( z, z, z, z, z ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 5, 'returns expected value' ); - - // Mixed arguments: - z = new Complex64( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex64Array.of( z, 1.0 ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - z = new Complex64( 1.0, 0.0 ); - z.valueOf = valueOf( z ); - arr = Complex64Array.of( 1.0, z ); - t.strictEqual( arr instanceof Complex64Array, true, 'returns expected value' ); - - v = arr.length; - t.strictEqual( v, 1, 'returns expected value' ); - - t.end(); - - function valueOf( z ) { - return function valueOf() { - return realf( z ); - }; - } -}); diff --git a/complex64/test/test.reduce.js b/complex64/test/test.reduce.js deleted file mode 100644 index 33ea16295..000000000 --- a/complex64/test/test.reduce.js +++ /dev/null @@ -1,212 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var caddf = require( '@stdlib/complex/float32/base/add' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduce` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'reduce' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.reduce ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map.reduce( value, caddf ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty complex number array', function test( t ) { - var arr; - - arr = new Complex64Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( caddf ); - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - accArray = [ 1.0, -1.0, 3.0, -3.0 ]; - valueArray = [ 2.0, -2.0, 3.0, -3.0 ]; - expected = new Complex64( 6.0, -6.0 ); - actual = arr.reduce( reducer ); - - t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); - t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - var ind = 2*(index-1); - t.strictEqual( instanceOf( acc, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( acc ), accArray[ ind ], 'returns expected value' ); - t.strictEqual( imagf( acc ), accArray[ ind+1 ], 'returns expected value' ); - t.strictEqual( instanceOf( value, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( value ), valueArray[ ind ], 'returns expected value' ); - t.strictEqual( imagf( value ), valueArray[ ind+1 ], 'returns expected value' ); - return caddf( acc, value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - accArray = [ 2.0, -2.0, 3.0, -3.0, 5.0, -5.0 ]; - valueArray = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ]; - expected = new Complex64( 8.0, -8.0 ); - actual = arr.reduce( reducer, new Complex64( 2.0, -2.0 ) ); - - t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); - t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( instanceOf( acc, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( acc ), accArray[ 2*index ], 'returns expected value' ); - t.strictEqual( imagf( acc ), accArray[ (2*index)+1 ], 'returns expected value' ); - t.strictEqual( instanceOf( value, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( value ), valueArray[ 2*index ], 'returns expected value' ); - t.strictEqual( imagf( value ), valueArray[ (2*index)+1 ], 'returns expected value' ); - return caddf( acc, value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Complex64( 6.0, -6.0 ); - actual = arr.reduce( caddf ); - - t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); - t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports returning real-valued results', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = 6.0; - actual = arr.reduce( reducer, 0.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return acc + realf( value ); - } -}); diff --git a/complex64/test/test.reduce_right.js b/complex64/test/test.reduce_right.js deleted file mode 100644 index 15f190261..000000000 --- a/complex64/test/test.reduce_right.js +++ /dev/null @@ -1,217 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var caddf = require( '@stdlib/complex/float32/base/add' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reduceRight` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'reduceRight' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.reduceRight ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map.reduceRight( value, caddf ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty complex number array', function test( t ) { - var arr; - - arr = new Complex64Array( 0 ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( caddf ); - } -}); - -tape( 'the method uses the last element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - len = arr.length; - accArray = [ 3.0, -3.0, 5.0, -5.0 ]; - valueArray = [ 2.0, -2.0, 1.0, -1.0 ]; - expected = new Complex64( 6.0, -6.0 ); - actual = arr.reduceRight( reducer ); - - t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); - t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - var ind = 2*(len-index-2); - t.strictEqual( instanceOf( acc, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( acc ), accArray[ ind ], 'returns expected value' ); - t.strictEqual( imagf( acc ), accArray[ ind+1 ], 'returns expected value' ); - t.strictEqual( instanceOf( value, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( value ), valueArray[ ind ], 'returns expected value' ); - t.strictEqual( imagf( value ), valueArray[ ind+1 ], 'returns expected value' ); - return caddf( acc, value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var arr; - var len; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - len = arr.length; - accArray = [ 2.0, -2.0, 5.0, -5.0, 7.0, -7.0 ]; - valueArray = [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ]; - expected = new Complex64( 8.0, -8.0 ); - actual = arr.reduceRight( reducer, new Complex64( 2.0, -2.0 ) ); - - t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); - t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - var ind = 2*(len-index-1); - t.strictEqual( instanceOf( acc, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( acc ), accArray[ ind ], 'returns expected value' ); - t.strictEqual( imagf( acc ), accArray[ ind+1 ], 'returns expected value' ); - t.strictEqual( instanceOf( value, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( value ), valueArray[ ind ], 'returns expected value' ); - t.strictEqual( imagf( value ), valueArray[ ind+1 ], 'returns expected value' ); - return caddf( acc, value ); - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Complex64( 6.0, -6.0 ); - actual = arr.reduceRight( caddf ); - - t.strictEqual( instanceOf( actual, Complex64 ), true, 'returns expected value' ); - t.strictEqual( realf( actual ), realf( expected ), 'returns expected value' ); - t.strictEqual( imagf( actual ), imagf( expected ), 'returns expected value' ); - t.end(); -}); - -tape( 'the method supports returning real-valued results', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = 6.0; - actual = arr.reduceRight( reducer, 0.0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return acc + realf( value ); - } -}); diff --git a/complex64/test/test.reverse.js b/complex64/test/test.reverse.js deleted file mode 100644 index 52ba71372..000000000 --- a/complex64/test/test.reverse.js +++ /dev/null @@ -1,114 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Float32Array = require( './../../float32' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `reverse` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'reverse' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.reverse ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reverse.call( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex64Array(); - out = arr.reverse(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method reverses elements of a complex number array in-place', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); - out = arr.reverse(); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex64Array( 10 ); - out = arr.reverse(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.set.js b/complex64/test/test.set.js deleted file mode 100644 index 7613cf926..000000000 --- a/complex64/test/test.set.js +++ /dev/null @@ -1,714 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ArrayBuffer = require( './../../buffer' ); -var Float32Array = require( './../../float32' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `set` method for setting one or more array elements', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'set' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.set ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number, a complex number array, or an array-like object', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a complex number, a complex number array, or an array-like object (index argument)', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not a nonnegative integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( new Complex64( 1.0, -1.0 ), value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (complex number)', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - arr.length, - arr.length + 1, - arr.length + 2, - arr.length + 3 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( new Complex64( 1.0, -1.0 ), value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (complex typed array)', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Complex64Array( 10 ); - arr2 = new Complex64Array( 10 ); - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (array-like object containing complex numbers)', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Complex64Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( new Complex64( i, -i ) ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is out-of-bounds (array-like object containing interleaved components)', function test( t ) { - var values; - var arr1; - var arr2; - var i; - - arr1 = new Complex64Array( 10 ); - arr2 = []; - for ( i = 0; i < arr1.length; i++ ) { - arr2.push( i ); - arr2.push( -i ); - } - - values = [ - 1, - 2, - 3, - 4, - 5 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr1.set( arr2, value ); - }; - } -}); - -tape( 'the method throws an error if provided an array-like object containing interleaved components which has an odd length', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - [ 1 ], - [ 1, 2, 3 ], - [ 1, 2, 3, 4, 5 ], - [ 1, 2, 3, 4, 5, 6, 7 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( value ); - }; - } -}); - -tape( 'the method throws an error if provided an array-like object containing interleaved components which has an odd length (index argument)', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - [ 1 ], - [ 1, 2, 3 ], - [ 1, 2, 3, 4, 5 ], - [ 1, 2, 3, 4, 5, 6, 7 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.set( value, 0 ); - }; - } -}); - -tape( 'the method sets an array element (complex number)', function test( t ) { - var arr; - var v; - var i; - - arr = new Complex64Array( 10 ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), 0.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 0.0, 'returns expected value' ); - - // No index argument: - arr.set( new Complex64( 20.0, -20.0 ) ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), 20.0, 'returns expected value' ); - t.strictEqual( imagf( v ), -20.0, 'returns expected value' ); - - arr.set( new Complex64( 0.0, 0.0 ) ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( realf( v ), 0.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 0.0, 'returns expected value' ); - - arr.set( new Complex64( i, -i ), i ); - - v = arr.get( i ); - t.strictEqual( realf( v ), i, 'returns expected value' ); - t.strictEqual( imagf( v ), -i, 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method sets an array element (complex typed array)', function test( t ) { - var arr; - var buf; - var v; - var i; - - arr = new Complex64Array( 10 ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), 0.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 0.0, 'returns expected value' ); - - // No index argument: - buf = [ 20.0, -20.0 ]; - arr.set( new Complex64Array( buf ) ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - buf = [ 0.0, 0.0 ]; - arr.set( new Complex64Array( buf ) ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( realf( v ), 0.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 0.0, 'returns expected value' ); - - buf = [ i, -i ]; - arr.set( new Complex64Array( buf ), i ); - - v = arr.get( i ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - } - - // Multiple values, no index argument: - buf = [ 20.0, -20.0, -40.0, 40.0 ]; - arr.set( new Complex64Array( buf ) ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - // Multiple values, index argument: - buf = [ -100.0, -200.0, -300.0, -400.0 ]; - arr.set( new Complex64Array( buf ), 2 ); - - v = arr.get( 2 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (array-like object containing complex numbers)', function test( t ) { - var arr; - var buf; - var v; - var i; - - arr = new Complex64Array( 10 ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), 0.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 0.0, 'returns expected value' ); - - // No index argument: - buf = [ 20.0, -20.0 ]; - arr.set( [ new Complex64( buf[0], buf[1] ) ] ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - buf = [ 0.0, 0.0 ]; - arr.set( [ new Complex64( buf[0], buf[1] ) ] ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( realf( v ), 0.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 0.0, 'returns expected value' ); - - buf = [ i, -i ]; - arr.set( [ new Complex64( buf[ 0 ], buf[ 1 ] ) ], i ); - - v = arr.get( i ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - } - - // Multiple values, no index argument: - buf = [ 20.0, -20.0, -40.0, 40.0 ]; - arr.set( [ new Complex64( buf[0], buf[1] ), new Complex64( buf[2], buf[3] ) ] ); // eslint-disable-line max-len - - v = arr.get( 0 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - // Multiple values, index argument: - buf = [ -100.0, -200.0, -300.0, -400.0 ]; - arr.set( [ new Complex64( buf[0], buf[1] ), new Complex64( buf[2], buf[3] ) ], 2 ); // eslint-disable-line max-len - - v = arr.get( 2 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (array-like object containing interleaved components)', function test( t ) { - var arr; - var buf; - var v; - var i; - - arr = new Complex64Array( 10 ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), 0.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 0.0, 'returns expected value' ); - - // No index argument: - buf = [ 20.0, -20.0 ]; - arr.set( buf ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - buf = [ 0.0, 0.0 ]; - arr.set( buf ); - - // Index argument: - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( realf( v ), 0.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 0.0, 'returns expected value' ); - - buf = [ i, -i ]; - arr.set( buf, i ); - - v = arr.get( i ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - } - - // Multiple values, no index argument: - buf = [ 20.0, -20.0, -40.0, 40.0 ]; - arr.set( buf ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - // Multiple values, index argument: - buf = [ -100.0, -200.0, -300.0, -400.0 ]; - arr.set( buf, 2 ); - - v = arr.get( 2 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (complex typed array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Complex64Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 20.0, -20.0, -40.0, 40.0 ]; - src = new Complex64Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -100.0, -200.0, -300.0, -400.0 ]; - src = new Complex64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 25.0, -25.0, -45.0, 45.0 ]; - src = new Complex64Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -105.0, -205.0, -305.0, -405.0 ]; - src = new Complex64Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 2 ); - src.set( buf ); - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the method sets an array element (typed array; shared buffer)', function test( t ) { - var byteOffset; - var arr; - var src; - var buf; - var ab; - var v; - var i; - - byteOffset = 112; - - ab = new ArrayBuffer( 240 ); - arr = new Complex64Array( ab, byteOffset, 10 ); - - // Overlapping (requires copy), multiple values, no index argument: - buf = [ 20.0, -20.0, -40.0, 40.0 ]; - src = new Float32Array( ab, byteOffset-(1*arr.BYTES_PER_ELEMENT), 4 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - // Overlapping (requires copy), multiple values, index argument: - buf = [ -100.0, -200.0, -300.0, -400.0 ]; - src = new Float32Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 4 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - // Overlapping (no copy), multiple values, no index argument: - buf = [ 25.0, -25.0, -45.0, 45.0 ]; - src = new Float32Array( ab, byteOffset+(1*arr.BYTES_PER_ELEMENT), 4 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src ); - - v = arr.get( 0 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 1 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - // Overlapping (no copy), multiple values, index argument: - buf = [ -105.0, -205.0, -305.0, -405.0 ]; - src = new Float32Array( ab, byteOffset+(3*arr.BYTES_PER_ELEMENT), 4 ); - for ( i = 0; i < buf.length; i++ ) { - src[ i ] = buf[ i ]; - } - arr.set( src, 2 ); - - v = arr.get( 2 ); - t.strictEqual( realf( v ), buf[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 1 ], 'returns expected value' ); - - v = arr.get( 3 ); - t.strictEqual( realf( v ), buf[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), buf[ 3 ], 'returns expected value' ); - - t.end(); -}); diff --git a/complex64/test/test.slice.js b/complex64/test/test.slice.js deleted file mode 100644 index 469e7bf94..000000000 --- a/complex64/test/test.slice.js +++ /dev/null @@ -1,271 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Float32Array = require( './../../float32' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `slice` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'slice' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.slice ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.slice( 0, value ); - }; - } -}); - -tape( 'the method returns an empty typed array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex64Array(); - out = arr.slice(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a typed array containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.slice(); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a typed array containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.slice( 1 ); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a typed array containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.slice( 1, 3 ); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - actual = arr.slice( 1, 30 ); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - - expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.slice( -3, -1 ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - actual = arr.slice( -30, -2 ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float32Array( [] ); - actual = arr.slice( 2, 0 ); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float32Array( [] ); - actual = arr.slice( 5 ); - - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty typed array if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float32Array( [] ); - - actual = arr.slice( 2, -8 ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = arr.slice( 1, 0 ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.some.js b/complex64/test/test.some.js deleted file mode 100644 index 05a8c3b92..000000000 --- a/complex64/test/test.some.js +++ /dev/null @@ -1,197 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `some` method for returning boolean indicating whether at least one element passes a test', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'some' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.some ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.some.call( value, predicate ); - }; - } - - function predicate( v ) { - return ( realf( v ) > 0 && imagf( v ) < 0 ); - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty complex number array', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array(); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array( [ 1.0, 1.0, 1.0, 2.0 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === imagf( v ) ); - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return ( realf( v ) === imagf( v ) ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, 3.0 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 3, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imagf( v ) === realf( v ) ); - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctx; - var arr; - - ctx = { - 'count': 0 - }; - arr = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 1, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( imagf( v ) === realf( v ) ); - } -}); diff --git a/complex64/test/test.sort.js b/complex64/test/test.sort.js deleted file mode 100644 index 8e4477917..000000000 --- a/complex64/test/test.sort.js +++ /dev/null @@ -1,181 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var realf = require( '@stdlib/complex/float32/real' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Float32Array = require( './../../float32' ); -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex64} a - first value for comparison -* @param {Complex64} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = realf( a ); - re2 = realf( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imagf( a ); - im2 = imagf( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `sort` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'sort' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.sort ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.sort.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.sort( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex64Array(); - out = arr.sort( compareFcn ); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method sorts elements of a complex number array in-place', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex64Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); - expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out, arr, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - out = arr.sort( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.subarray.js b/complex64/test/test.subarray.js deleted file mode 100644 index 0d912b439..000000000 --- a/complex64/test/test.subarray.js +++ /dev/null @@ -1,272 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Float32Array = require( './../../float32' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `subarray` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'subarray' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.subarray ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray( value ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.subarray( 0, value ); - }; - } -}); - -tape( 'the method returns empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex64Array(); - out = arr.subarray(); - - t.strictEqual( out.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'if called without arguments, the method returns a view containing the same elements as the original array', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.subarray(); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if called with one argument, the method returns a view containing elements starting from a specified beginning index (inclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.subarray( 1 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided two arguments, the method returns a view containing elements starting from a specified beginning index (inclusive) and ending at a specified stop index (exclusive)', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.subarray( 1, 3 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method resolves negative indices relative to the last element', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - - expected = new Float32Array( [ 2.0, -2.0, 3.0, -3.0 ] ); - actual = arr.subarray( -3, -1 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - actual = arr.subarray( -30, -2 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds a resolved ending index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float32Array( [] ); - actual = arr.subarray( 2, 0 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved beginning index exceeds the maximum array index', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float32Array( [] ); - actual = arr.subarray( 5 ); - - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns an empty view if a resolved ending index is less than or equal to zero', function test( t ) { - var expected; - var actual; - var arr; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ] ); - expected = new Float32Array( [] ); - - actual = arr.subarray( 2, -8 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = arr.subarray( 1, 0 ); - t.strictEqual( actual.buffer, arr.buffer, 'returns expected value' ); - t.strictEqual( instanceOf( actual, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.to_locale_string.js b/complex64/test/test.to_locale_string.js deleted file mode 100644 index e917b7171..000000000 --- a/complex64/test/test.to_locale_string.js +++ /dev/null @@ -1,187 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toLocaleString` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toLocaleString' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.toLocaleString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString.call( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( value ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a string or an array of strings (options)', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [ 1, 2, 3 ], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( value, {} ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an object', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array(); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - 'beep', - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toLocaleString( 'en-GB', value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Complex64Array(); - str = arr.toLocaleString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a complex number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Complex64Array( [ 1, 2, -3, -4 ] ); - expected = '1 + 2i,-3 - 4i'; - - str = arr.toLocaleString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.to_reversed.js b/complex64/test/test.to_reversed.js deleted file mode 100644 index 505d341a0..000000000 --- a/complex64/test/test.to_reversed.js +++ /dev/null @@ -1,113 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var Float32Array = require( './../../float32' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toReversed` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toReversed' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.toReversed ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toReversed.call( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex64Array(); - out = arr.toReversed(); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in reverse order', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - expected = new Float32Array( [ 3.0, -3.0, 2.0, -2.0, 1.0, -1.0 ] ); - out = arr.toReversed(); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex64Array( 10 ); - out = arr.toReversed(); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.to_sorted.js b/complex64/test/test.to_sorted.js deleted file mode 100644 index 4270b0305..000000000 --- a/complex64/test/test.to_sorted.js +++ /dev/null @@ -1,180 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Float32Array = require( './../../float32' ); -var Complex64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Comparison function. -* -* @private -* @param {Complex64} a - first value for comparison -* @param {Complex64} b - second value for comparison -* @returns {number} comparison result -*/ -function compareFcn( a, b ) { - var re1; - var re2; - var im1; - var im2; - re1 = realf( a ); - re2 = realf( b ); - if ( re1 < re2 ) { - return -1; - } - if ( re1 > re2 ) { - return 1; - } - im1 = imagf( a ); - im2 = imagf( b ); - if ( im1 < im2 ) { - return -1; - } - if ( im1 > im2 ) { - return 1; - } - return 0; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toSorted` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toSorted' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.toSorted ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toSorted.call( value, compareFcn ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toSorted( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty complex number array', function test( t ) { - var arr; - var out; - - arr = new Complex64Array(); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements in sorted order', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex64Array( [ 3.0, -3.0, 1.0, -1.0, 2.0, -2.0 ] ); - expected = new Float32Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - out = arr.toSorted( compareFcn ); - - t.strictEqual( out.length, arr.length, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.to_string.js b/complex64/test/test.to_string.js deleted file mode 100644 index 390df2314..000000000 --- a/complex64/test/test.to_string.js +++ /dev/null @@ -1,97 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `toString` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'toString' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.toString ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.toString.call( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var str; - var arr; - - arr = new Complex64Array(); - str = arr.toString(); - - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a complex number array', function test( t ) { - var expected; - var str; - var arr; - - arr = new Complex64Array( [ 1, 2, -3, -4 ] ); - expected = '1 + 2i,-3 - 4i'; - - str = arr.toString(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/complex64/test/test.values.js b/complex64/test/test.values.js deleted file mode 100644 index ea28ee6bd..000000000 --- a/complex64/test/test.values.js +++ /dev/null @@ -1,272 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `values` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'values' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.values ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.values.call( value ); - }; - } -}); - -tape( 'the method returns an iterator protocol-compliant object', function test( t ) { - var expected; - var arr; - var it; - var i; - var r; - var e; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0 ] ); - expected = [ - { - 'value': new Complex64( 1.0, -1.0 ), - 'done': false - }, - { - 'value': new Complex64( 2.0, -2.0 ), - 'done': false - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - r = it.next(); - e = expected[ i ]; - if ( e.value === void 0 ) { - t.deepEqual( r, e, 'returns expected value' ); - } else { - t.strictEqual( isComplex64( r.value ), true, 'returns expected value' ); - t.strictEqual( realf( r.value ), realf( e.value ), 'returns expected value' ); - t.strictEqual( imagf( r.value ), imagf( e.value ), 'returns expected value' ); - t.strictEqual( r.done, e.done, 'returns expected value' ); - } - } - - t.end(); -}); - -tape( 'the method returns an iterator which does not iterate over empty arrays', function test( t ) { - var expected; - var arr; - var it; - var i; - var v; - - arr = new Complex64Array( [] ); - expected = [ - { - 'done': true - }, - { - 'done': true - }, - { - 'done': true - } - ]; - it = arr.values(); - - t.strictEqual( typeof it, 'object', 'returns an object' ); - t.strictEqual( typeof it.next, 'function', 'has next method' ); - - for ( i = 0; i < expected.length; i++ ) { - v = it.next(); - t.deepEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( realf( v.value ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v.value ), -1.0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( realf( v.value ), 2.0, 'returns expected value' ); - t.strictEqual( imagf( v.value ), -2.0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var arr; - var it; - var v; - - arr = new Complex64Array( [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0 ] ); - it = arr.values(); - - v = it.next(); - t.strictEqual( realf( v.value ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v.value ), -1.0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.next(); - t.strictEqual( realf( v.value ), 2.0, 'returns expected value' ); - t.strictEqual( imagf( v.value ), -2.0, 'returns expected value' ); - t.strictEqual( v.done, false, 'returns expected value' ); - - v = it.return( 'beep' ); - t.strictEqual( v.value, 'beep', 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - v = it.next(); - t.strictEqual( v.value, void 0, 'returns expected value' ); - t.strictEqual( v.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the method returns an iterable', function test( t ) { - var Complex64Array; - var arr; - var buf; - var it1; - var it2; - var v1; - var v2; - var i; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex64Array( buf ); - - it1 = arr.values(); - t.strictEqual( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.strictEqual( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.strictEqual( typeof it2, 'object', 'returns an object' ); - t.strictEqual( typeof it2.next, 'function', 'has `next` method' ); - t.strictEqual( typeof it2.return, 'function', 'has `return` method' ); - - for ( i = 0; i < arr.length; i++ ) { - v1 = it1.next().value; - v2 = it2.next().value; - t.strictEqual( realf( v1 ), realf( v2 ), 'returns expected value' ); - t.strictEqual( imagf( v1 ), imagf( v2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the method does not return an "iterable"', function test( t ) { - var Complex64Array; - var arr; - var buf; - var it; - - Complex64Array = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - buf = [ 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 ]; - arr = new Complex64Array( buf ); - - it = arr.values(); - t.strictEqual( it[ ITERATOR_SYMBOL ], void 0, 'does not have property' ); - - t.end(); -}); diff --git a/complex64/test/test.with.js b/complex64/test/test.with.js deleted file mode 100644 index 4aefaddc9..000000000 --- a/complex64/test/test.with.js +++ /dev/null @@ -1,203 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( './../../float32' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Complex64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the main export is a `with` method', function test( t ) { - t.strictEqual( hasOwnProp( Complex64Array.prototype, 'with' ), true, 'has property' ); - t.strictEqual( isFunction( Complex64Array.prototype.with ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a complex number array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with.call( value, 0, new Complex64( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 5 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, new Complex64( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - -11, - -12, - 11, - 12 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, new Complex64( 1.0, 1.0 ) ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not a complex number', function test( t ) { - var values; - var arr; - var i; - - arr = new Complex64Array( 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( 0, value ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var arr; - var out; - - arr = new Complex64Array( 10 ); - out = arr.with( 5, new Complex64( 1.0, 1.0 ) ); - - t.strictEqual( out.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new complex number array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0 ] ); - expected = new Float32Array( [ 1.0, 1.0, 5.0, 5.0, 3.0, 3.0, 4.0, 4.0 ] ); - out = arr.with( 1, new Complex64( 5.0, 5.0 ) ); - - t.strictEqual( out instanceof Complex64Array, true, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - t.notEqual( out, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ); - expected = new Float32Array( [ 1.0, 1.0, 2.0, 2.0, 1.0, 1.0 ] ); - - out = arr.with( -1, new Complex64( 1.0, 1.0 ) ); - - t.strictEqual( out instanceof Complex64Array, true, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - t.end(); -}); diff --git a/convert-same/README.md b/convert-same/README.md deleted file mode 100644 index fd563b420..000000000 --- a/convert-same/README.md +++ /dev/null @@ -1,141 +0,0 @@ - - -# convertSame - -> Convert an array to the same [data type][@stdlib/array/dtypes] as a second input array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var convertSame = require( '@stdlib/array/convert-same' ); -``` - -#### convertSame( x, y ) - -Converts an array to the same [data type][@stdlib/array/dtypes] as a second input array. - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var x = [ 1.0, 2.0, 3.0 ]; -var y = new Float32Array( 0 ); - -var out = convertSame( x, y ); -// returns [ 1.0, 2.0, 3.0 ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filledarrayBy = require( '@stdlib/array/filled-by' ); -var dtypes = require( '@stdlib/array/dtypes' ); -var ctors = require( '@stdlib/array/ctors' ); -var convertSame = require( '@stdlib/array/convert-same' ); - -// Create a generic array: -var arr = filledarrayBy( 5, 'generic', discreteUniform( -100, 100 ) ); - -// Get a list of array data types: -var DTYPES = dtypes(); - -// Convert the generic array to each array data type: -var out; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - out = convertSame( arr, new ( ctors( DTYPES[ i ] ) )( 0 ) ); - console.log( out ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/convert-same/benchmark/benchmark.js b/convert-same/benchmark/benchmark.js deleted file mode 100644 index 275f7d98f..000000000 --- a/convert-same/benchmark/benchmark.js +++ /dev/null @@ -1,402 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Int16Array = require( './../../int16' ); -var Int8Array = require( './../../int8' ); -var Uint32Array = require( './../../uint32' ); -var Uint16Array = require( './../../uint16' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var pkg = require( './../package.json' ).name; -var convertArraySame = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, arr ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new Float32Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new BooleanArray( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new Complex128Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new Complex64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new Int32Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new Int16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new Int8Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new Uint32Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new Uint16Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new Uint8Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var out; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - v = new Uint8ClampedArray( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArraySame( arr, v ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/convert-same/benchmark/benchmark.length.js b/convert-same/benchmark/benchmark.length.js deleted file mode 100644 index e5f9cee3b..000000000 --- a/convert-same/benchmark/benchmark.length.js +++ /dev/null @@ -1,150 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Int16Array = require( './../../int16' ); -var Int8Array = require( './../../int8' ); -var Uint32Array = require( './../../uint32' ); -var Uint16Array = require( './../../uint16' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var pkg = require( './../package.json' ).name; -var convertArraySame = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @param {(Array|TypedArray)} v - value having desired data type -* @returns {Function} benchmark function -*/ -function createBenchmark( len, v ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( i ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = convertArraySame( arr, v ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len, [] ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( len, new Float64Array( 0 ) ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( len, new Float32Array( 0 ) ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( len, new Int32Array( 0 ) ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( len, new Int16Array( 0 ) ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( len, new Int8Array( 0 ) ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( len, new Uint32Array( 0 ) ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( len, new Uint16Array( 0 ) ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( len, new Uint8Array( 0 ) ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( len, new Uint8ClampedArray( 0 ) ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - - f = createBenchmark( len, new BooleanArray( 0 ) ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( len, new Complex128Array( 0 ) ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( len, new Complex64Array( 0 ) ); - bench( pkg+':len='+len+',dtype=complex64', f ); - } -} - -main(); diff --git a/convert-same/benchmark/julia/REQUIRE b/convert-same/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e192..000000000 --- a/convert-same/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/convert-same/benchmark/julia/benchmark.jl b/convert-same/benchmark/julia/benchmark.jl deleted file mode 100644 index 194844d84..000000000 --- a/convert-same/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env julia -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 BenchmarkTools -using Printf - -# Benchmark variables: -repeats = 3; -samples = 1e3; -count = 0; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, 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" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark( setup, expr ) - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Arguments - -* `setup`: setup expression -* `expr`: expression to benchmark - -# Examples - -``` julia -julia> out = benchmark( :(), :( sin( 3.14 ) ) ); -``` -""" -function benchmark( setup, expr ) - t = eval( :( BenchmarkTools.@benchmark $expr samples=$samples setup=($setup) ) ) - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - bench( name, setup, expr ) - -Run a named benchmark. - -# Arguments - -* `name`: benchmark name (suffix) -* `setup`: setup expression -* `expr`: expression to benchmark - -# Examples - -``` julia -julia> bench( "sin", :(), :( sin( 3.14 ) ) ); -``` -""" -function bench( name, setup, expr ) - for i in 1:repeats - @printf( "# julia::%s\n", name ); - global count += 1; - results = benchmark( setup, expr ); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", count ); - end -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - - dtypes = [ - Float64, - Float32, - Int32, - Int16, - Int8, - UInt32, - UInt16, - UInt8, - ComplexF64, - ComplexF32 - ]; - n = 1; - while n < 1e7 - n *= 10; - for i in 1:length( dtypes ) - name = string( "convert-same:len=", n, ",dtype=", lowercase( string( dtypes[i] ) ) ); - setup = :(A = ones( Float64, $n, 1 ); B = ones( $dtypes[$i], 1, 1 ) ); - stmt = :( C = oftype( B, A ) ); - bench( name, setup, stmt ); - end - end - - print_summary( count, count ); -end - -main(); diff --git a/convert-same/benchmark/python/numpy/benchmark.py b/convert-same/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b809d32b3..000000000 --- a/convert-same/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.astype.""" - -from __future__ import print_function, division -import timeit - -NAME = "convert-same" -REPEATS = 3 -ITERATIONS = 1000000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - dtypes = [ - "float64", - "float32", - "int32", - "int16", - "int8", - "uint32", - "uint16", - "uint8", - "complex64", - "complex128" - ] - iters = ITERATIONS - n = 1 - while n < 1e7: - n *= 10 - for i in range(0, len(dtypes)): - dtype = dtypes[i] - name = ":len="+str(n)+",dtype="+dtype - setup = "import numpy as np;" - setup += "A = np.ones([1,"+str(n)+"], dtype='float64');" - setup += "B = np.ones([1,1], dtype='"+dtype+"');" - stmt = "C = A.astype(B.dtype)" - benchmark(name, setup, stmt, iters) - iters //= 4 - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/convert-same/docs/repl.txt b/convert-same/docs/repl.txt deleted file mode 100644 index a8b1f2a7b..000000000 --- a/convert-same/docs/repl.txt +++ /dev/null @@ -1,27 +0,0 @@ - -{{alias}}( x, y ) - Converts an input array to the same data type as a second input array. - - Parameters - ---------- - x: ArrayLikeObject - Array to convert. - - y: Array|TypedArray - Array having desired output data type. - - Returns - ------- - out: Array|TypedArray - Output array. - - Examples - -------- - > var x = [ 1.0, 2.0, 3.0, 4.0 ]; - > var y = new {{alias:@stdlib/array/float32}}( 0 ); - > var out = {{alias}}( x, y ) - [ 1.0, 2.0, 3.0, 4.0 ] - - See Also - -------- - diff --git a/convert-same/docs/types/index.d.ts b/convert-same/docs/types/index.d.ts deleted file mode 100644 index 0b7337ac4..000000000 --- a/convert-same/docs/types/index.d.ts +++ /dev/null @@ -1,280 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { AnyArray, Collection, Complex128Array, Complex64Array, BooleanArray } from '@stdlib/types/array'; - -/** -* Converts an array to the same data type as a `Float64Array`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Float64Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ -declare function convertSame( x: Collection, y: Float64Array ): Float64Array; - -/** -* Converts an array to a `Float32Array`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Float32Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ -declare function convertSame( x: Collection, y: Float32Array ): Float32Array; - -/** -* Converts an array to an `Int32Array`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Int32Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convertSame( x: Collection, y: Int32Array ): Int32Array; - -/** -* Converts an array to an `Int16Array`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Int16Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convertSame( x: Collection, y: Int16Array ): Int16Array; - -/** -* Converts an array to an `Int8Array`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Int8Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convertSame( x: Collection, y: Int8Array ): Int8Array; - -/** -* Converts an array to a `Uint32Array`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Uint32Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convertSame( x: Collection, y: Uint32Array ): Uint32Array; - -/** -* Converts an array to a `Uint16Array`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Uint16Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convertSame( x: Collection, y: Uint16Array ): Uint16Array; - -/** -* Converts an array to a `Uint8Array`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Uint8Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convertSame( x: Collection, y: Uint8Array ): Uint8Array; - -/** -* Converts an array to a `Uint8ClampedArray`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Uint8ClampedArray( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1, 2, 3, 4 ] -*/ -declare function convertSame( x: Collection, y: Uint8ClampedArray ): Uint8ClampedArray; - -/** -* Converts an array to a `BooleanArray`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var x = [ -1, 0, 1, 2 ]; -* var y = new BooleanArray( 0 ); -* -* var out = convertSame( x, y ); -* // returns -*/ -declare function convertSame( x: Collection, y: BooleanArray ): BooleanArray; - -/** -* Converts an array to a `Complex128Array`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Complex128Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns -*/ -declare function convertSame( x: Collection, y: Complex128Array ): Complex128Array; - -/** -* Converts an array to a `Complex64Array`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Complex64Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns -*/ -declare function convertSame( x: Collection, y: Complex64Array ): Complex64Array; - -/** -* Converts an array to a generic `Array`. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -* var y = []; -* -* var out = convertSame( x, y ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ -declare function convertSame( x: Collection, y: Array ): Array; - -/** -* Converts an array to the same data type as a second input array. -* -* @param x - array to convert -* @param y - array having the desired output data type -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Float64Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ -declare function convertSame( x: Collection, y: AnyArray ): AnyArray; - - -// EXPORTS // - -export = convertSame; diff --git a/convert-same/docs/types/test.ts b/convert-same/docs/types/test.ts deleted file mode 100644 index ba0cee484..000000000 --- a/convert-same/docs/types/test.ts +++ /dev/null @@ -1,77 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import BooleanArray = require( './../../../bool' ); -import convertSame = require( './index' ); - - -// TESTS // - -// The function returns an array having a desired data type... -{ - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Float64Array( 0 ) ); // $ExpectType Float64Array - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Float32Array( 0 ) ); // $ExpectType Float32Array - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Int32Array( 0 ) ); // $ExpectType Int32Array - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Int16Array( 0 ) ); // $ExpectType Int16Array - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Int8Array( 0 ) ); // $ExpectType Int8Array - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Uint32Array( 0 ) ); // $ExpectType Uint32Array - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Uint16Array( 0 ) ); // $ExpectType Uint16Array - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Uint8Array( 0 ) ); // $ExpectType Uint8Array - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Uint8ClampedArray( 0 ) ); // $ExpectType Uint8ClampedArray - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Complex128Array( 0 ) ); // $ExpectType Complex128Array - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new Complex64Array( 0 ) ); // $ExpectType Complex64Array - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], new BooleanArray( 0 ) ); // $ExpectType BooleanArray - convertSame( [ 1.0, 2.0, 3.0, 4.0 ], [] ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not array-like... -{ - const y = new Float64Array( 0 ); - - convertSame( 123, y ); // $ExpectError - convertSame( true, y ); // $ExpectError - convertSame( false, y ); // $ExpectError - convertSame( {}, y ); // $ExpectError - convertSame( null, y ); // $ExpectError - convertSame( undefined, y ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array or typed array... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - - convertSame( x, 'abc' ); // $ExpectError - convertSame( x, 123 ); // $ExpectError - convertSame( x, true ); // $ExpectError - convertSame( x, false ); // $ExpectError - convertSame( x, {} ); // $ExpectError - convertSame( x, null ); // $ExpectError - convertSame( x, undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1.0, 2.0, 3.0, 4.0 ]; - const y = new Float64Array( 0 ); - - convertSame(); // $ExpectError - convertSame( x ); // $ExpectError - convertSame( x, y, 2 ); // $ExpectError -} diff --git a/convert-same/examples/index.js b/convert-same/examples/index.js deleted file mode 100644 index 7d24772b1..000000000 --- a/convert-same/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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' ).factory; -var filledarrayBy = require( './../../filled-by' ); -var dtypes = require( './../../dtypes' ); -var ctors = require( './../../ctors' ); -var convertSame = require( './../lib' ); - -// Create a generic array: -var arr = filledarrayBy( 5, 'generic', discreteUniform( -100, 100 ) ); - -// Get a list of array data types: -var DTYPES = dtypes(); - -// Convert the generic array to each array data type: -var out; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - out = convertSame( arr, new ( ctors( DTYPES[ i ] ) )( 0 ) ); - console.log( out ); -} diff --git a/convert-same/lib/index.js b/convert-same/lib/index.js deleted file mode 100644 index cd6093c9a..000000000 --- a/convert-same/lib/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an array to the same data type as a second input array. -* -* @module @stdlib/array/convert-same -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var convertSame = require( '@stdlib/array/convert-same' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Float64Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/convert-same/lib/main.js b/convert-same/lib/main.js deleted file mode 100644 index 556f918a5..000000000 --- a/convert-same/lib/main.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var getType = require( './../../dtype' ); -var convert = require( './../../convert' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Converts an array to the same data type as a second input array. -* -* @param {Collection} x - array to convert -* @param {(Array|TypedArray|ComplexArray)} y - array having the desired output data type -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} second argument must have a recognized data type -* @returns {(Array|TypedArray|ComplexArray)} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = [ 1.0, 2.0, 3.0, 4.0 ]; -* var y = new Float64Array( 0 ); -* -* var out = convertSame( x, y ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ -function convertSame( x, y ) { - var dtype = getType( y ); - if ( dtype === null ) { - throw new TypeError( format( 'invalid argument. Second argument must have a recognized/supported data type. Type: `%s`. Value: `%s`.', dtype, y ) ); - } - return convert( x, dtype ); -} - - -// EXPORTS // - -module.exports = convertSame; diff --git a/convert-same/package.json b/convert-same/package.json deleted file mode 100644 index 4c1db69ca..000000000 --- a/convert-same/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/convert-same", - "version": "0.0.0", - "description": "Convert an array to the same data type as a second input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "convert", - "cast", - "transform", - "copy", - "duplicate" - ] -} diff --git a/convert-same/test/test.js b/convert-same/test/test.js deleted file mode 100644 index 62585c1f0..000000000 --- a/convert-same/test/test.js +++ /dev/null @@ -1,752 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtype = require( './../../dtype' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var BooleanArray = require( './../../bool' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var convertArraySame = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof convertArraySame, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided an array-like object as its first argument, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - convertArraySame( value, 'float64' ); - }; - } -}); - -tape( 'if provided an argument having an unknown/unsupported data type, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - 'binary', - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits', - 'float64', - 'float32', - 'int32', - 'int16', - 'int8', - 'uint32', - 'uint16', - 'uint8', - 'uint8c', - 'generic', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - convertArraySame( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function converts an array to the same data type as a second input array', function test( t ) { - var expected; - var out; - var dt; - var x; - var y; - var i; - var j; - - y = [ - new Float64Array( 0 ), - new Float32Array( 0 ), - [], - new Int16Array( 0 ), - new Int32Array( 0 ), - new Int8Array( 0 ), - new Uint16Array( 0 ), - new Uint32Array( 0 ), - new Uint8Array( 0 ), - new Uint8ClampedArray( 0 ) - ]; - x = [ -1, 0, 1 ]; - expected = [ - [ new Float64Array( [ -1.0, 0.0, 1.0 ] ), isFloat64Array ], - [ new Float32Array( [ -1.0, 0.0, 1.0 ] ), isFloat32Array ], - [ x, isArray ], - [ new Int16Array( [ -1, 0, 1 ] ), isInt16Array ], - [ new Int32Array( [ -1, 0, 1 ] ), isInt32Array ], - [ new Int8Array( [ -1, 0, 1 ] ), isInt8Array ], - [ new Uint16Array( [ 65535, 0, 1 ] ), isUint16Array ], - [ new Uint32Array( [ 4294967295, 0, 1 ] ), isUint32Array ], - [ new Uint8Array( [ 255, 0, 1 ] ), isUint8Array ], - [ new Uint8ClampedArray( [ 0, 0, 1 ] ), isUint8ClampedArray ] - ]; - for ( i = 0; i < y.length; i++ ) { - dt = dtype( y[ i ] ); - out = convertArraySame( x, y[ i ] ); - t.strictEqual( expected[ i ][ 1 ]( out ), true, 'returns expected value type for ' + dt ); - for ( j = 0; j < x.length; j++ ) { - t.strictEqual( out[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dt ); - } - } - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (accessors)', function test( t ) { - var expected; - var arr; - var out; - var dt; - var y; - var i; - var j; - - y = [ - new Float64Array( 0 ), - new Float32Array( 0 ), - [], - new Int16Array( 0 ), - new Int32Array( 0 ), - new Int8Array( 0 ), - new Uint16Array( 0 ), - new Uint32Array( 0 ), - new Uint8Array( 0 ), - new Uint8ClampedArray( 0 ) - ]; - arr = { - 'length': 3, - 'data': [ -1, 0, 1 ], - 'get': getter, - 'set': setter - }; - expected = [ - [ new Float64Array( [ -1.0, 0.0, 1.0 ] ), isFloat64Array ], - [ new Float32Array( [ -1.0, 0.0, 1.0 ] ), isFloat32Array ], - [ [ -1, 0, 1 ], isArray ], - [ new Int16Array( [ -1, 0, 1 ] ), isInt16Array ], - [ new Int32Array( [ -1, 0, 1 ] ), isInt32Array ], - [ new Int8Array( [ -1, 0, 1 ] ), isInt8Array ], - [ new Uint16Array( [ 65535, 0, 1 ] ), isUint16Array ], - [ new Uint32Array( [ 4294967295, 0, 1 ] ), isUint32Array ], - [ new Uint8Array( [ 255, 0, 1 ] ), isUint8Array ], - [ new Uint8ClampedArray( [ 0, 0, 1 ] ), isUint8ClampedArray ] - ]; - for ( i = 0; i < y.length; i++ ) { - dt = dtype( y[ i ] ); - out = convertArraySame( arr, y[ i ] ); - t.strictEqual( expected[ i ][ 1 ]( out ), true, 'returns expected value type for ' + dt ); - for ( j = 0; j < arr.length; j++ ) { - t.strictEqual( out[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dt ); - } - } - t.end(); - - function getter( idx ) { - return arr.data[ idx ]; - } - - function setter( value, idx ) { - arr.data[ idx ] = value; - } -}); - -tape( 'the function converts an array to the same data type as a second input array (accessors => bool)', function test( t ) { - var expected; - var arr; - var out; - - arr = { - 'length': 3, - 'data': [ -1, 0, 1 ], - 'get': getter, - 'set': setter - }; - expected = new Uint8Array( [ 1, 0, 1 ] ); - out = convertArraySame( arr, new BooleanArray( 0 ) ); - - t.strictEqual( isBooleanArray( out ), true, 'returns expected value type' ); - t.strictEqual( out.length, expected.length, 'returns expected length' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); - - function getter( idx ) { - return arr.data[ idx ]; - } - - function setter( value, idx ) { - arr.data[ idx ] = value; - } -}); - -tape( 'the function converts an array to the same data type as a second input array (generic => bool)', function test( t ) { - var expected; - var arr; - var out; - - arr = [ 'foo', null, [], {} ]; - expected = new Uint8Array( [ 1, 0, 1, 1 ] ); - out = convertArraySame( arr, new BooleanArray( 0 ) ); - t.strictEqual( isBooleanArray( out ), true, 'returns expected value type' ); - t.strictEqual( out.length, expected.length, 'returns expected length' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (real => bool)', function test( t ) { - var expected; - var arr; - var out; - - arr = [ -1, 0, 1, 2 ]; - expected = new Uint8Array( [ 1, 0, 1, 1 ] ); - out = convertArraySame( arr, new BooleanArray( 0 ) ); - t.strictEqual( isBooleanArray( out ), true, 'returns expected value type' ); - t.strictEqual( out.length, expected.length, 'returns expected length' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (bool => complex)', function test( t ) { - var expected; - var arr; - var out; - var tmp; - var v1; - var v2; - var dt; - var y; - var i; - var j; - - y = [ - new Complex64Array( 0 ), - new Complex128Array( 0 ) - ]; - arr = new BooleanArray( [ true, false, true, true ] ); - expected = [ - [ new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ), isComplex64Array, reinterpret64 ], - [ new Complex128Array( [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ), isComplex128Array, reinterpret128 ] - ]; - for ( i = 0; i < y.length; i++ ) { - tmp = expected[ i ]; - dt = dtype( y[ i ] ); - out = convertArraySame( arr, y[ i ] ); - t.strictEqual( tmp[ 1 ]( out ), true, 'returns expected value type for ' + dt ); - v1 = tmp[ 2 ]( out, 0 ); - v2 = tmp[ 2 ]( tmp[ 0 ], 0 ); - for ( j = 0; j < arr.length*2; j += 2 ) { - t.strictEqual( v1[ j ], v2[ j ], 'returns expected real component for element ' + (j/2) + ' for ' + dt ); - t.strictEqual( v1[ j+1 ], v2[ j+1 ], 'returns expected imaginary component for element ' + (j/2) + ' for ' + dt ); - } - } - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (bool => real)', function test( t ) { - var expected; - var arr; - var out; - var dt; - var y; - var i; - var j; - - y = [ - new Float64Array( 0 ), - new Float32Array( 0 ), - new Int16Array( 0 ), - new Int32Array( 0 ), - new Int8Array( 0 ), - new Uint16Array( 0 ), - new Uint32Array( 0 ), - new Uint8Array( 0 ), - new Uint8ClampedArray( 0 ) - ]; - arr = new BooleanArray( [ true, false, true ] ); - expected = [ - [ new Float64Array( [ 1.0, 0.0, 1.0 ] ), isFloat64Array ], - [ new Float32Array( [ 1.0, 0.0, 1.0 ] ), isFloat32Array ], - [ new Int16Array( [ 1, 0, 1 ] ), isInt16Array ], - [ new Int32Array( [ 1, 0, 1 ] ), isInt32Array ], - [ new Int8Array( [ 1, 0, 1 ] ), isInt8Array ], - [ new Uint16Array( [ 1, 0, 1 ] ), isUint16Array ], - [ new Uint32Array( [ 1, 0, 1 ] ), isUint32Array ], - [ new Uint8Array( [ 1, 0, 1 ] ), isUint8Array ], - [ new Uint8ClampedArray( [ 1, 0, 1 ] ), isUint8ClampedArray ] - ]; - for ( i = 0; i < y.length; i++ ) { - dt = dtype( y[ i ] ); - out = convertArraySame( arr, y[ i ] ); - t.strictEqual( expected[ i ][ 1 ]( out ), true, 'returns expected value type for ' + dt ); - for ( j = 0; j < arr.length; j++ ) { - t.strictEqual( out[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dt ); - } - } - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (real => complex)', function test( t ) { - var expected; - var arr; - var out; - var tmp; - var v1; - var v2; - var dt; - var y; - var i; - var j; - - y = [ - new Complex64Array( 0 ), - new Complex128Array( 0 ) - ]; - arr = [ -1, 0, 1, 2 ]; - expected = [ - [ new Complex64Array( [ -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ), isComplex64Array, reinterpret64 ], - [ new Complex128Array( [ -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ), isComplex128Array, reinterpret128 ] - ]; - for ( i = 0; i < y.length; i++ ) { - tmp = expected[ i ]; - dt = dtype( y[ i ] ); - out = convertArraySame( arr, y[ i ] ); - t.strictEqual( tmp[ 1 ]( out ), true, 'returns expected value type for ' + dt ); - v1 = tmp[ 2 ]( out, 0 ); - v2 = tmp[ 2 ]( tmp[ 0 ], 0 ); - for ( j = 0; j < arr.length*2; j += 2 ) { - t.strictEqual( v1[ j ], v2[ j ], 'returns expected real component for element ' + (j/2) + ' for ' + dt ); - t.strictEqual( v1[ j+1 ], v2[ j+1 ], 'returns expected imaginary component for element ' + (j/2) + ' for ' + dt ); - } - } - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (complex64 => complex)', function test( t ) { - var expected; - var arr; - var out; - var tmp; - var v1; - var v2; - var dt; - var y; - var i; - var j; - - y = [ - new Complex64Array( 0 ), - new Complex128Array( 0 ) - ]; - arr = new Complex64Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - [ new Complex64Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ), isComplex64Array, reinterpret64 ], - [ new Complex128Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ), isComplex128Array, reinterpret128 ] - ]; - for ( i = 0; i < y.length; i++ ) { - tmp = expected[ i ]; - dt = dtype( y[ i ] ); - out = convertArraySame( arr, y[ i ] ); - t.strictEqual( tmp[ 1 ]( out ), true, 'returns expected value type for ' + dt ); - v1 = tmp[ 2 ]( out, 0 ); - v2 = tmp[ 2 ]( tmp[ 0 ], 0 ); - for ( j = 0; j < arr.length*2; j += 2 ) { - t.strictEqual( v1[ j ], v2[ j ], 'returns expected real component for element ' + (j/2) + ' for ' + dt ); - t.strictEqual( v1[ j+1 ], v2[ j+1 ], 'returns expected imaginary component for element ' + (j/2) + ' for ' + dt ); - } - } - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (complex128 => complex)', function test( t ) { - var expected; - var arr; - var out; - var tmp; - var v1; - var v2; - var dt; - var y; - var i; - var j; - - y = [ - new Complex64Array( 0 ), - new Complex128Array( 0 ) - ]; - arr = new Complex128Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - [ new Complex64Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ), isComplex64Array, reinterpret64 ], - [ new Complex128Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ), isComplex128Array, reinterpret128 ] - ]; - for ( i = 0; i < y.length; i++ ) { - tmp = expected[ i ]; - dt = dtype( y[ i ] ); - out = convertArraySame( arr, y[ i ] ); - t.strictEqual( tmp[ 1 ]( out ), true, 'returns expected value type for ' + dt ); - v1 = tmp[ 2 ]( out, 0 ); - v2 = tmp[ 2 ]( tmp[ 0 ], 0 ); - for ( j = 0; j < arr.length*2; j += 2 ) { - t.strictEqual( v1[ j ], v2[ j ], 'returns expected real component for element ' + (j/2) + ' for ' + dt ); - t.strictEqual( v1[ j+1 ], v2[ j+1 ], 'returns expected imaginary component for element ' + (j/2) + ' for ' + dt ); - } - } - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (complex64 => real)', function test( t ) { - var expected; - var arr; - var out; - var dt; - var y; - var i; - var j; - - y = [ - new Float64Array( 0 ), - new Float32Array( 0 ), - new Int16Array( 0 ), - new Int32Array( 0 ), - new Int8Array( 0 ), - new Uint16Array( 0 ), - new Uint32Array( 0 ), - new Uint8Array( 0 ), - new Uint8ClampedArray( 0 ) - ]; - arr = new Complex64Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - [ new Float64Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat64Array ], - [ new Float32Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat32Array ], - [ new Int16Array( [ -1, 0, 1, 2 ] ), isInt16Array ], - [ new Int32Array( [ -1, 0, 1, 2 ] ), isInt32Array ], - [ new Int8Array( [ -1, 0, 1, 2 ] ), isInt8Array ], - [ new Uint16Array( [ 65535, 0, 1, 2 ] ), isUint16Array ], - [ new Uint32Array( [ 4294967295, 0, 1, 2 ] ), isUint32Array ], - [ new Uint8Array( [ 255, 0, 1, 2 ] ), isUint8Array ], - [ new Uint8ClampedArray( [ 0, 0, 1, 2 ] ), isUint8ClampedArray ] - ]; - for ( i = 0; i < y.length; i++ ) { - dt = dtype( y[ i ] ); - out = convertArraySame( arr, y[ i ] ); - t.strictEqual( expected[ i ][ 1 ]( out ), true, 'returns expected value type for ' + dt ); - for ( j = 0; j < arr.length; j++ ) { - t.strictEqual( out[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dt ); - } - } - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (complex128 => real)', function test( t ) { - var expected; - var arr; - var out; - var dt; - var y; - var i; - var j; - - y = [ - new Float64Array( 0 ), - new Float32Array( 0 ), - new Int16Array( 0 ), - new Int32Array( 0 ), - new Int8Array( 0 ), - new Uint16Array( 0 ), - new Uint32Array( 0 ), - new Uint8Array( 0 ), - new Uint8ClampedArray( 0 ) - ]; - arr = new Complex128Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - [ new Float64Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat64Array ], - [ new Float32Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat32Array ], - [ new Int16Array( [ -1, 0, 1, 2 ] ), isInt16Array ], - [ new Int32Array( [ -1, 0, 1, 2 ] ), isInt32Array ], - [ new Int8Array( [ -1, 0, 1, 2 ] ), isInt8Array ], - [ new Uint16Array( [ 65535, 0, 1, 2 ] ), isUint16Array ], - [ new Uint32Array( [ 4294967295, 0, 1, 2 ] ), isUint32Array ], - [ new Uint8Array( [ 255, 0, 1, 2 ] ), isUint8Array ], - [ new Uint8ClampedArray( [ 0, 0, 1, 2 ] ), isUint8ClampedArray ] - ]; - for ( i = 0; i < y.length; i++ ) { - dt = dtype( y[ i ] ); - out = convertArraySame( arr, y[ i ] ); - t.strictEqual( expected[ i ][ 1 ]( out ), true, 'returns expected value type for ' + dt ); - for ( j = 0; j < arr.length; j++ ) { - t.strictEqual( out[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dt ); - } - } - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (complex64 => bool)', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex64Array( [ -1.0, 1.0, 0.0, 0.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = new Uint8Array( [ 1, 0, 1, 1 ] ); - - out = convertArraySame( arr, new BooleanArray( 0 ) ); - t.strictEqual( isBooleanArray( out ), true, 'returns expected value type' ); - t.strictEqual( out.length, expected.length, 'returns expected length' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (complex128 => bool)', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex128Array( [ -1.0, 1.0, 0.0, 0.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = new Uint8Array( [ 1, 0, 1, 1 ] ); - - out = convertArraySame( arr, new BooleanArray( 0 ) ); - t.strictEqual( isBooleanArray( out ), true, 'returns expected value type' ); - t.strictEqual( out.length, expected.length, 'returns expected length' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (bool => generic)', function test( t ) { - var expected; - var arr; - var out; - var i; - - arr = new BooleanArray( [ true, false, true ] ); - expected = [ - arr.get( 0 ), - arr.get( 1 ), - arr.get( 2 ) - ]; - out = convertArraySame( arr, [] ); - t.strictEqual( isArray( out ), true, 'returns expected value type' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( out[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (bool => bool)', function test( t ) { - var expected; - var arr; - var out; - - arr = new BooleanArray( [ true, false, true ] ); - expected = new Uint8Array( [ 1, 0, 1 ] ); - - out = convertArraySame( arr, new BooleanArray( 0 ) ); - t.strictEqual( isBooleanArray( out ), true, 'returns expected value type' ); - t.strictEqual( out.length, expected.length, 'returns expected length' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (complex64 => generic)', function test( t ) { - var expected; - var arr; - var out; - var v1; - var v2; - var i; - - arr = new Complex64Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - arr.get( 0 ), - arr.get( 1 ), - arr.get( 2 ), - arr.get( 3 ) - ]; - out = convertArraySame( arr, [] ); - t.strictEqual( isArray( out ), true, 'returns expected value type' ); - for ( i = 0; i < arr.length; i++ ) { - v1 = out[ i ]; - v2 = expected[ i ]; - t.strictEqual( isComplex64( v1 ), true, 'returns expected value' ); - t.strictEqual( realf( v1 ), realf( v2 ), 'returns expected real component' ); - t.strictEqual( imagf( v1 ), imagf( v2 ), 'returns expected imaginary component' ); - } - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (complex128 => generic)', function test( t ) { - var expected; - var arr; - var out; - var v1; - var v2; - var i; - - arr = new Complex128Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - arr.get( 0 ), - arr.get( 1 ), - arr.get( 2 ), - arr.get( 3 ) - ]; - out = convertArraySame( arr, [] ); - t.strictEqual( isArray( out ), true, 'returns expected value type' ); - for ( i = 0; i < arr.length; i++ ) { - v1 = out[ i ]; - v2 = expected[ i ]; - t.strictEqual( isComplex128( v1 ), true, 'returns expected value' ); - t.strictEqual( real( v1 ), real( v2 ), 'returns expected real component' ); - t.strictEqual( imag( v1 ), imag( v2 ), 'returns expected imaginary component' ); - } - t.end(); -}); - -tape( 'the function converts an array to the same data type as a second input array (large allocations)', function test( t ) { - var expected; - var out; - var dt; - var x; - var y; - var i; - - y = [ - new Float64Array( 0 ), - new Float32Array( 0 ), - [], - new Int16Array( 0 ), - new Int32Array( 0 ), - new Int8Array( 0 ), - new Uint16Array( 0 ), - new Uint32Array( 0 ), - new Uint8Array( 0 ), - new Uint8ClampedArray( 0 ), - new Complex64Array( 0 ), - new Complex128Array( 0 ), - new BooleanArray( 0 ) - ]; - x = []; - for ( i = 0; i < 1e6; i++ ) { - x.push( 0 ); - } - expected = [ - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray, - isComplex64Array, - isComplex128Array, - isBooleanArray - ]; - for ( i = 0; i < y.length; i++ ) { - dt = dtype( y[ i ] ); - out = convertArraySame( x, y[ i ] ); - t.strictEqual( expected[ i ]( out ), true, 'returns expected value type for ' + dt ); - } - t.end(); -}); diff --git a/convert/README.md b/convert/README.md deleted file mode 100644 index 433c01479..000000000 --- a/convert/README.md +++ /dev/null @@ -1,134 +0,0 @@ - - -# convert - -> Convert an array to an array of a different [data type][@stdlib/array/dtypes]. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var convert = require( '@stdlib/array/convert' ); -``` - -#### convert( arr, dtype ) - -Converts an array to an array of a different [data type][@stdlib/array/dtypes]. - -```javascript -var arr = [ 1.0, 2.0, 3.0 ]; -var out = convert( arr, 'float32' ); -// returns [ 1.0, 2.0, 3.0 ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filledarrayBy = require( '@stdlib/array/filled-by' ); -var dtypes = require( '@stdlib/array/dtypes' ); -var convert = require( '@stdlib/array/convert' ); - -// Create a generic array: -var arr = filledarrayBy( 5, 'generic', discreteUniform( -100, 100 ) ); - -// Get a list of array data types: -var DTYPES = dtypes(); - -// Convert the generic array to each array data type: -var out; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - out = convert( arr, DTYPES[ i ] ); - console.log( out ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/convert/benchmark/benchmark.js b/convert/benchmark/benchmark.js deleted file mode 100644 index 405c0b8cf..000000000 --- a/convert/benchmark/benchmark.js +++ /dev/null @@ -1,354 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var pkg = require( './../package.json' ).name; -var convertArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'generic' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'float64' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'float32' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'bool' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'complex128' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'complex64' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'int32' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'int16' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'int8' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'uint32' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'uint16' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'uint8' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var out; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] += 1; - out = convertArray( arr, 'uint8c' ); - if ( out.length !== arr.length ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/convert/benchmark/benchmark.length.js b/convert/benchmark/benchmark.length.js deleted file mode 100644 index 951f4cd47..000000000 --- a/convert/benchmark/benchmark.length.js +++ /dev/null @@ -1,138 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var pkg = require( './../package.json' ).name; -var convertArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @param {string} dtype - data type -* @returns {Function} benchmark function -*/ -function createBenchmark( len, dtype ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( i ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = convertArray( arr, dtype ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len, 'generic' ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( len, 'float64' ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( len, 'float32' ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( len, 'bool' ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( len, 'complex128' ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( len, 'complex64' ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( len, 'int32' ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( len, 'int16' ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( len, 'int8' ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( len, 'uint32' ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( len, 'uint16' ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( len, 'uint8' ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( len, 'uint8c' ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/convert/benchmark/julia/REQUIRE b/convert/benchmark/julia/REQUIRE deleted file mode 100644 index 98645e192..000000000 --- a/convert/benchmark/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -BenchmarkTools 0.5.0 diff --git a/convert/benchmark/julia/benchmark.jl b/convert/benchmark/julia/benchmark.jl deleted file mode 100644 index ee2aa5682..000000000 --- a/convert/benchmark/julia/benchmark.jl +++ /dev/null @@ -1,195 +0,0 @@ -#!/usr/bin/env julia -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT 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 BenchmarkTools -using Printf - -# Benchmark variables: -repeats = 3; -samples = 1e3; -count = 0; - -""" - print_version() - -Prints the TAP version. - -# Examples - -``` julia -julia> print_version() -``` -""" -function print_version() - @printf( "TAP version 13\n" ); -end - -""" - print_summary( total, passing ) - -Print the benchmark summary. - -# Arguments - -* `total`: total number of tests -* `passing`: number of passing tests - -# Examples - -``` julia -julia> print_summary( 3, 3 ) -``` -""" -function print_summary( total, 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" ); -end - -""" - print_results( iterations, elapsed ) - -Print benchmark results. - -# Arguments - -* `iterations`: number of iterations -* `elapsed`: elapsed time (in seconds) - -# Examples - -``` julia -julia> print_results( 1000000, 0.131009101868 ) -``` -""" -function print_results( iterations, elapsed ) - rate = iterations / elapsed - - @printf( " ---\n" ); - @printf( " iterations: %d\n", iterations ); - @printf( " elapsed: %0.9f\n", elapsed ); - @printf( " rate: %0.9f\n", rate ); - @printf( " ...\n" ); -end - -""" - benchmark( setup, expr ) - -Run a benchmark. - -# Notes - -* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. -* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. -* The elapsed time is in seconds. - -# Arguments - -* `setup`: setup expression -* `expr`: expression to benchmark - -# Examples - -``` julia -julia> out = benchmark( :(), :( sin( 3.14 ) ) ); -``` -""" -function benchmark( setup, expr ) - t = eval( :( BenchmarkTools.@benchmark $expr samples=$samples setup=($setup) ) ) - - # Compute the total "elapsed" time and convert from nanoseconds to seconds: - s = sum( t.times ) / 1.0e9; - - # Determine the number of "iterations": - iter = length( t.times ); - - # Return the results: - [ iter, s ]; -end - -""" - bench( name, setup, expr ) - -Run a named benchmark. - -# Arguments - -* `name`: benchmark name (suffix) -* `setup`: setup expression -* `expr`: expression to benchmark - -# Examples - -``` julia -julia> bench( "sin", :(), :( sin( 3.14 ) ) ); -``` -""" -function bench( name, setup, expr ) - for i in 1:repeats - @printf( "# julia::%s\n", name ); - global count += 1; - results = benchmark( setup, expr ); - print_results( results[ 1 ], results[ 2 ] ); - @printf( "ok %d benchmark finished\n", count ); - end -end - -""" - main() - -Run benchmarks. - -# Examples - -``` julia -julia> main(); -``` -""" -function main() - print_version(); - - dtypes = [ - Float64, - Float32, - Int32, - Int16, - Int8, - UInt32, - UInt16, - UInt8, - ComplexF64, - ComplexF32 - ]; - n = 1; - while n < 1e7 - n *= 10; - for i in 1:length( dtypes ) - name = string( "convert:len=", n, ",dtype=", lowercase( string( dtypes[i] ) ) ); - setup = :(A = ones( Float64, $n, 1 )); - stmt = :( B = convert( Array{ $dtypes[$i] }, A ) ); - bench( name, setup, stmt ); - end - end - - print_summary( count, count ); -end - -main(); diff --git a/convert/benchmark/python/numpy/benchmark.py b/convert/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 6660853b6..000000000 --- a/convert/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.astype.""" - -from __future__ import print_function, division -import timeit - -NAME = "convert" -REPEATS = 3 -ITERATIONS = 1000000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - print_version() - - dtypes = [ - "float64", - "float32", - "int32", - "int16", - "int8", - "uint32", - "uint16", - "uint8", - "complex64", - "complex128" - ] - iters = ITERATIONS - n = 1 - while n < 1e7: - n *= 10 - for i in range(0, len(dtypes)): - dtype = dtypes[i] - name = ":len="+str(n)+",dtype="+dtype - setup = "import numpy as np;" - setup += "A = np.ones([1,"+str(n)+"], dtype='float64');" - stmt = "B = A.astype('"+dtype+"')" - benchmark(name, setup, stmt, iters) - iters //= 4 - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/convert/docs/repl.txt b/convert/docs/repl.txt deleted file mode 100644 index a822c0ce9..000000000 --- a/convert/docs/repl.txt +++ /dev/null @@ -1,26 +0,0 @@ - -{{alias}}( arr, dtype ) - Converts an input array to an array of a different data type. - - Parameters - ---------- - arr: ArrayLikeObject - Array to convert. - - dtype: string - Output data type. - - Returns - ------- - out: Array|TypedArray - Output array. - - Examples - -------- - > var arr = [ 1.0, 2.0, 3.0, 4.0 ]; - > var out = {{alias}}( arr, 'float32' ) - [ 1.0, 2.0, 3.0, 4.0 ] - - See Also - -------- - diff --git a/convert/docs/types/index.d.ts b/convert/docs/types/index.d.ts deleted file mode 100644 index ea0c1d777..000000000 --- a/convert/docs/types/index.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection, DataTypeMap } from '@stdlib/types/array'; - -/** -* Converts an array to an array of a different data type. -* -* @param x - array to convert -* @param dtype - output data type -* @returns output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* var out = convert( arr, 'float64' ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ -declare function convert>( x: Collection, dtype: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = convert; diff --git a/convert/docs/types/test.ts b/convert/docs/types/test.ts deleted file mode 100644 index 6306c6ca4..000000000 --- a/convert/docs/types/test.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import convert = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float64' ); // $ExpectType Float64Array - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float32' ); // $ExpectType Float32Array - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'int32' ); // $ExpectType Int32Array - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'int16' ); // $ExpectType Int16Array - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'int8' ); // $ExpectType Int8Array - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'uint32' ); // $ExpectType Uint32Array - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'uint16' ); // $ExpectType Uint16Array - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'uint8' ); // $ExpectType Uint8Array - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'uint8c' ); // $ExpectType Uint8ClampedArray - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'complex128' ); // $ExpectType Complex128Array - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'complex64' ); // $ExpectType Complex64Array - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'bool' ); // $ExpectType BooleanArray - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'generic' ); // $ExpectType number[] - convert( [ 'a', 'b', 'c', 'd' ], 'generic' ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided a first argument which is not array-like... -{ - convert( 123, 'float64' ); // $ExpectError - convert( true, 'float64' ); // $ExpectError - convert( false, 'float64' ); // $ExpectError - convert( {}, 'float64' ); // $ExpectError - convert( null, 'float64' ); // $ExpectError - convert( undefined, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a known data type... -{ - convert( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - convert( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - convert( [ 1, 2, 3, 4 ], [] ); // $ExpectError - convert( [ 1, 2, 3, 4 ], {} ); // $ExpectError - convert( [ 1, 2, 3, 4 ], true ); // $ExpectError - convert( [ 1, 2, 3, 4 ], false ); // $ExpectError - convert( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - convert(); // $ExpectError - convert( [ 1.0, 2.0, 3.0, 4.0 ] ); // $ExpectError - convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float64', 2 ); // $ExpectError -} diff --git a/convert/examples/index.js b/convert/examples/index.js deleted file mode 100644 index bd7d64a61..000000000 --- a/convert/examples/index.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var filledarrayBy = require( './../../filled-by' ); -var dtypes = require( './../../dtypes' ); -var convert = require( './../lib' ); - -// Create a generic array: -var arr = filledarrayBy( 5, 'generic', discreteUniform( -100, 100 ) ); - -// Get a list of array data types: -var DTYPES = dtypes(); - -// Convert the generic array to each array data type: -var out; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - out = convert( arr, DTYPES[ i ] ); - console.log( out ); -} diff --git a/convert/lib/index.js b/convert/lib/index.js deleted file mode 100644 index a087384b2..000000000 --- a/convert/lib/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an array to an array of a different data type. -* -* @module @stdlib/array/convert -* -* @example -* var convert = require( '@stdlib/array/convert' ); -* -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* -* var out = convert( arr, 'float64' ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/convert/lib/main.js b/convert/lib/main.js deleted file mode 100644 index f5f07eccd..000000000 --- a/convert/lib/main.js +++ /dev/null @@ -1,236 +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. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert/is-collection' ); -var getType = require( './../../dtype' ); -var ctors = require( './../../ctors' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var gcopy = require( '@stdlib/blas/base/gcopy' ); -var copy = require( './../../base/copy' ); -var resolveGetter = require( './../../base/resolve-getter' ); -var format = require( '@stdlib/string/format' ); - - -// FUNCTIONS // - -/** -* Tests whether a data type is a single-precision complex floating-point number data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} boolean indicating whether a provided data type is a single-precision complex floating-point number data type -* -* @example -* var bool = isComplex64( 'float64' ); -* // returns false -* -* @example -* var bool = isComplex64( 'complex64' ); -* // returns true -*/ -function isComplex64( dtype ) { - return ( dtype === 'complex64' ); -} - -/** -* Tests whether a data type is a double-precision complex floating-point number data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} boolean indicating whether a provided data type is a double-precision complex floating-point number data type -* -* @example -* var bool = isComplex128( 'float64' ); -* // returns false -* -* @example -* var bool = isComplex128( 'complex128' ); -* // returns true -*/ -function isComplex128( dtype ) { - return ( dtype === 'complex128' ); -} - -/** -* Tests whether a data type is a boolean data type. -* -* @private -* @param {string} dtype - data type -* @returns {boolean} boolean indicating whether a provided data type is a boolean data type -* -* @example -* var bool = isBool( 'bool' ); -* // returns true -* -* @example -* var bool = isBool( 'complex128' ); -* // returns false -*/ -function isBool( dtype ) { - return ( dtype === 'bool' ); -} - - -// MAIN // - -/** -* Converts an array to an array of a different data type. -* -* @param {Collection} x - array to convert -* @param {string} dtype - output data type -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} second argument must be a recognized array data type -* @returns {(Array|TypedArray|ComplexArray)} output array -* -* @example -* var arr = [ 1.0, 2.0, 3.0, 4.0 ]; -* -* var out = convert( arr, 'float64' ); -* // returns [ 1.0, 2.0, 3.0, 4.0 ] -*/ -function convert( x, dtype ) { - var isc64; - var ctor; - var xbuf; - var obuf; - var get; - var out; - var len; - var t; - var i; - - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) ); - } - // If the output data type is "generic", our task is relatively straightforward... - if ( dtype === 'generic' ) { - return copy( x ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Second argument must be a recognized array data type. Value: `%s`.', dtype ) ); - } - // Cache the input array length: - len = x.length; - - // Get the input array data type: - t = getType( x ); - isc64 = isComplex64( t ); - - // Create the output array: - out = new ctor( len ); - - // As the output data type is not "generic", we need to explicitly handle complex number input arrays... - if ( isc64 || isComplex128( t ) ) { - if ( isc64 ) { - xbuf = reinterpret64( x, 0 ); - } else { - xbuf = reinterpret128( x, 0 ); - } - // Check whether the output data type is a complex number data type... - if ( isComplex64( dtype ) ) { // cmplx => cmplx - obuf = reinterpret64( out, 0 ); - gcopy( len*2, xbuf, 1, obuf, 1 ); - return out; - } - if ( isComplex128( dtype ) ) { // cmplx => cmplx - obuf = reinterpret128( out, 0 ); - gcopy( len*2, xbuf, 1, obuf, 1 ); - return out; - } - // Check whether the output data type is a boolean data type... - if ( isBool( dtype ) ) { // cmplx => bool - obuf = reinterpretBoolean( out, 0 ); - for ( i = 0; i < len; i++ ) { - // A complex number is only falsy when both the real and imaginary components are zero... - if ( xbuf[ 2*i ] || xbuf[ (2*i)+1 ] ) { - obuf[ i ] = 1; - } else { - obuf[ i ] = 0; - } - } - return out; - } - // We assume that the output data type is a real number data type, given that we're looking to convert a provided complex number array; in which case, we'll only extract the real components from the complex number input array... - gcopy( len, xbuf, 2, out, 1 ); // cmplx => real - return out; - } - // Check whether the input array is a boolean array... - if ( isBool( t ) ) { - xbuf = reinterpretBoolean( x, 0 ); - - // Check whether the output data type is a boolean data type... - if ( isBool( dtype ) ) { // bool => bool - obuf = reinterpretBoolean( out, 0 ); - gcopy( len, xbuf, 1, obuf, 1 ); - return out; - } - // Check whether the output data type is a complex number data type... - if ( isComplex64( dtype ) ) { // bool => cmplx - obuf = reinterpret64( out, 0 ); - gcopy( len, xbuf, 1, obuf, 2 ); - return out; - } - if ( isComplex128( dtype ) ) { // bool => cmplx - obuf = reinterpret128( out, 0 ); - gcopy( len, xbuf, 1, obuf, 2 ); - return out; - } - gcopy( len, xbuf, 1, out, 1 ); // bool => real - return out; - } - // Check whether we need to explicitly handle complex number output arrays... - isc64 = isComplex64( dtype ); - if ( isc64 || isComplex128( dtype ) ) { - if ( isc64 ) { - obuf = reinterpret64( out, 0 ); - } else { - obuf = reinterpret128( out, 0 ); - } - // We assume that the input data type is a real number data type, given that we're looking to convert to a complex number array; in which case, we'll only set the real components... (WARNING: we're assuming that the output array has been zero-initialized! The imaginary components should be zero!) - gcopy( len, x, 1, obuf, 2 ); // real => cmplx - return out; - } - // Check whether the output data type is a boolean data type... - if ( isBool( dtype ) ) { - obuf = reinterpretBoolean( out, 0 ); - get = resolveGetter( x ); - for ( i = 0; i < len; i++ ) { - if ( get( x, i ) ) { - obuf[ i ] = 1; - } else { - obuf[ i ] = 0; - } - } - return out; - } - // At this point, we're no longer handling complex number or boolean arrays, so we'll just assume that we can perform a straightforward copy... - gcopy( len, x, 1, out, 1 ); // note: `gcopy` is assumed to support arrays using accessors - return out; -} - - -// EXPORTS // - -module.exports = convert; diff --git a/convert/package.json b/convert/package.json deleted file mode 100644 index 41f391a2e..000000000 --- a/convert/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/convert", - "version": "0.0.0", - "description": "Convert an array to an array of a different data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "convert", - "cast", - "transform", - "copy", - "duplicate" - ] -} diff --git a/convert/test/test.js b/convert/test/test.js deleted file mode 100644 index 25f5f7c10..000000000 --- a/convert/test/test.js +++ /dev/null @@ -1,712 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var BooleanArray = require( './../../bool' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var convertArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof convertArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided an array-like object as its first argument, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - convertArray( value, 'float64' ); - }; - } -}); - -tape( 'if provided an unknown/unsupported data type, the function throws an error', function test( t ) { - var values; - var i; - - values = [ - 'binary', - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - convertArray( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function converts an array to an array of a different data type', function test( t ) { - var expected; - var dtypes; - var arr; - var out; - var i; - var j; - - dtypes = [ - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - arr = [ -1, 0, 1 ]; - expected = [ - [ new Float64Array( [ -1.0, 0.0, 1.0 ] ), isFloat64Array ], - [ new Float32Array( [ -1.0, 0.0, 1.0 ] ), isFloat32Array ], - [ arr, isArray ], - [ new Int16Array( [ -1, 0, 1 ] ), isInt16Array ], - [ new Int32Array( [ -1, 0, 1 ] ), isInt32Array ], - [ new Int8Array( [ -1, 0, 1 ] ), isInt8Array ], - [ new Uint16Array( [ 65535, 0, 1 ] ), isUint16Array ], - [ new Uint32Array( [ 4294967295, 0, 1 ] ), isUint32Array ], - [ new Uint8Array( [ 255, 0, 1 ] ), isUint8Array ], - [ new Uint8ClampedArray( [ 0, 0, 1 ] ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - out = convertArray( arr, dtypes[ i ] ); - t.strictEqual( expected[ i ][ 1 ]( out ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < arr.length; j++ ) { - t.strictEqual( out[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (accessors)', function test( t ) { - var expected; - var dtypes; - var arr; - var out; - var i; - var j; - - dtypes = [ - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - arr = { - 'length': 3, - 'data': [ -1, 0, 1 ], - 'get': getter, - 'set': setter - }; - expected = [ - [ new Float64Array( [ -1.0, 0.0, 1.0 ] ), isFloat64Array ], - [ new Float32Array( [ -1.0, 0.0, 1.0 ] ), isFloat32Array ], - [ [ -1, 0, 1 ], isArray ], - [ new Int16Array( [ -1, 0, 1 ] ), isInt16Array ], - [ new Int32Array( [ -1, 0, 1 ] ), isInt32Array ], - [ new Int8Array( [ -1, 0, 1 ] ), isInt8Array ], - [ new Uint16Array( [ 65535, 0, 1 ] ), isUint16Array ], - [ new Uint32Array( [ 4294967295, 0, 1 ] ), isUint32Array ], - [ new Uint8Array( [ 255, 0, 1 ] ), isUint8Array ], - [ new Uint8ClampedArray( [ 0, 0, 1 ] ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - out = convertArray( arr, dtypes[ i ] ); - t.strictEqual( expected[ i ][ 1 ]( out ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < arr.length; j++ ) { - t.strictEqual( out[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); - - function getter( idx ) { - return arr.data[ idx ]; - } - - function setter( value, idx ) { - arr.data[ idx ] = value; - } -}); - -tape( 'the function converts an array to an array of a different data type (generic => bool)', function test( t ) { - var expected; - var arr; - var out; - - arr = [ 'foo', null, [], {} ]; - expected = new Uint8Array( [ 1, 0, 1, 1 ] ); - out = convertArray( arr, 'bool' ); - t.strictEqual( isBooleanArray( out ), true, 'returns expected value type' ); - t.strictEqual( out.length, expected.length, 'returns expected length' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (real => bool)', function test( t ) { - var expected; - var arr; - var out; - - arr = [ -1, 0, 1, 2 ]; - expected = new Uint8Array( [ 1, 0, 1, 1 ] ); - out = convertArray( arr, 'bool' ); - t.strictEqual( isBooleanArray( out ), true, 'returns expected value type' ); - t.strictEqual( out.length, expected.length, 'returns expected length' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (accessors => bool)', function test( t ) { - var expected; - var arr; - var out; - - arr = { - 'length': 3, - 'data': [ -1, 0, 1 ], - 'get': getter, - 'set': setter - }; - expected = new Uint8Array( [ 1, 0, 1 ] ); - out = convertArray( arr, 'bool' ); - t.strictEqual( isBooleanArray( out ), true, 'returns expected value type' ); - t.strictEqual( out.length, expected.length, 'returns expected length' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); - - function getter( idx ) { - return arr.data[ idx ]; - } - - function setter( value, idx ) { - arr.data[ idx ] = value; - } -}); - -tape( 'the function converts an array to an array of a different data type (bool => complex)', function test( t ) { - var expected; - var dtypes; - var arr; - var out; - var tmp; - var v1; - var v2; - var i; - var j; - - dtypes = [ - 'complex64', - 'complex128' - ]; - arr = new BooleanArray( [ true, false, true, true ] ); - expected = [ - [ new Complex64Array( [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ), isComplex64Array, reinterpret64 ], - [ new Complex128Array( [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ), isComplex128Array, reinterpret128 ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - tmp = expected[ i ]; - out = convertArray( arr, dtypes[ i ] ); - t.strictEqual( tmp[ 1 ]( out ), true, 'returns expected value type for ' + dtypes[ i ] ); - v1 = tmp[ 2 ]( out, 0 ); - v2 = tmp[ 2 ]( tmp[ 0 ], 0 ); - for ( j = 0; j < arr.length*2; j += 2 ) { - t.strictEqual( v1[ j ], v2[ j ], 'returns expected real component for element ' + (j/2) + ' for ' + dtypes[ i ] ); - t.strictEqual( v1[ j+1 ], v2[ j+1 ], 'returns expected imaginary component for element ' + (j/2) + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (real => complex)', function test( t ) { - var expected; - var dtypes; - var arr; - var out; - var tmp; - var v1; - var v2; - var i; - var j; - - dtypes = [ - 'complex64', - 'complex128' - ]; - arr = [ -1, 0, 1, 2 ]; - expected = [ - [ new Complex64Array( [ -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ), isComplex64Array, reinterpret64 ], - [ new Complex128Array( [ -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ), isComplex128Array, reinterpret128 ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - tmp = expected[ i ]; - out = convertArray( arr, dtypes[ i ] ); - t.strictEqual( tmp[ 1 ]( out ), true, 'returns expected value type for ' + dtypes[ i ] ); - v1 = tmp[ 2 ]( out, 0 ); - v2 = tmp[ 2 ]( tmp[ 0 ], 0 ); - for ( j = 0; j < arr.length*2; j += 2 ) { - t.strictEqual( v1[ j ], v2[ j ], 'returns expected real component for element ' + (j/2) + ' for ' + dtypes[ i ] ); - t.strictEqual( v1[ j+1 ], v2[ j+1 ], 'returns expected imaginary component for element ' + (j/2) + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (complex64 => complex)', function test( t ) { - var expected; - var dtypes; - var arr; - var out; - var tmp; - var v1; - var v2; - var i; - var j; - - dtypes = [ - 'complex64', - 'complex128' - ]; - arr = new Complex64Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - [ new Complex64Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ), isComplex64Array, reinterpret64 ], - [ new Complex128Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ), isComplex128Array, reinterpret128 ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - tmp = expected[ i ]; - out = convertArray( arr, dtypes[ i ] ); - t.strictEqual( tmp[ 1 ]( out ), true, 'returns expected value type for ' + dtypes[ i ] ); - v1 = tmp[ 2 ]( out, 0 ); - v2 = tmp[ 2 ]( tmp[ 0 ], 0 ); - for ( j = 0; j < arr.length*2; j += 2 ) { - t.strictEqual( v1[ j ], v2[ j ], 'returns expected real component for element ' + (j/2) + ' for ' + dtypes[ i ] ); - t.strictEqual( v1[ j+1 ], v2[ j+1 ], 'returns expected imaginary component for element ' + (j/2) + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (complex128 => complex)', function test( t ) { - var expected; - var dtypes; - var arr; - var out; - var tmp; - var v1; - var v2; - var i; - var j; - - dtypes = [ - 'complex64', - 'complex128' - ]; - arr = new Complex128Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - [ new Complex64Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ), isComplex64Array, reinterpret64 ], - [ new Complex128Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ), isComplex128Array, reinterpret128 ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - tmp = expected[ i ]; - out = convertArray( arr, dtypes[ i ] ); - t.strictEqual( tmp[ 1 ]( out ), true, 'returns expected value type for ' + dtypes[ i ] ); - v1 = tmp[ 2 ]( out, 0 ); - v2 = tmp[ 2 ]( tmp[ 0 ], 0 ); - for ( j = 0; j < arr.length*2; j += 2 ) { - t.strictEqual( v1[ j ], v2[ j ], 'returns expected real component for element ' + (j/2) + ' for ' + dtypes[ i ] ); - t.strictEqual( v1[ j+1 ], v2[ j+1 ], 'returns expected imaginary component for element ' + (j/2) + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (complex64 => bool)', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex64Array( [ -1.0, 1.0, 0.0, 0.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = new Uint8Array( [ 1, 0, 1, 1 ] ); - - out = convertArray( arr, 'bool' ); - t.strictEqual( isBooleanArray( out ), true, 'returns expected value type' ); - t.strictEqual( out.length, expected.length, 'returns expected length' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (complex128 => bool)', function test( t ) { - var expected; - var arr; - var out; - - arr = new Complex128Array( [ -1.0, 1.0, 0.0, 0.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = new Uint8Array( [ 1, 0, 1, 1 ] ); - - out = convertArray( arr, 'bool' ); - t.strictEqual( isBooleanArray( out ), true, 'returns expected value type' ); - t.strictEqual( out.length, expected.length, 'returns expected length' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (complex64 => real)', function test( t ) { - var expected; - var dtypes; - var arr; - var out; - var i; - var j; - - dtypes = [ - 'float64', - 'float32', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - arr = new Complex64Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - [ new Float64Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat64Array ], - [ new Float32Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat32Array ], - [ new Int16Array( [ -1, 0, 1, 2 ] ), isInt16Array ], - [ new Int32Array( [ -1, 0, 1, 2 ] ), isInt32Array ], - [ new Int8Array( [ -1, 0, 1, 2 ] ), isInt8Array ], - [ new Uint16Array( [ 65535, 0, 1, 2 ] ), isUint16Array ], - [ new Uint32Array( [ 4294967295, 0, 1, 2 ] ), isUint32Array ], - [ new Uint8Array( [ 255, 0, 1, 2 ] ), isUint8Array ], - [ new Uint8ClampedArray( [ 0, 0, 1, 2 ] ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - out = convertArray( arr, dtypes[ i ] ); - t.strictEqual( expected[ i ][ 1 ]( out ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < arr.length; j++ ) { - t.strictEqual( out[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (complex128 => real)', function test( t ) { - var expected; - var dtypes; - var arr; - var out; - var i; - var j; - - dtypes = [ - 'float64', - 'float32', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - arr = new Complex128Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - [ new Float64Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat64Array ], - [ new Float32Array( [ -1.0, 0.0, 1.0, 2.0 ] ), isFloat32Array ], - [ new Int16Array( [ -1, 0, 1, 2 ] ), isInt16Array ], - [ new Int32Array( [ -1, 0, 1, 2 ] ), isInt32Array ], - [ new Int8Array( [ -1, 0, 1, 2 ] ), isInt8Array ], - [ new Uint16Array( [ 65535, 0, 1, 2 ] ), isUint16Array ], - [ new Uint32Array( [ 4294967295, 0, 1, 2 ] ), isUint32Array ], - [ new Uint8Array( [ 255, 0, 1, 2 ] ), isUint8Array ], - [ new Uint8ClampedArray( [ 0, 0, 1, 2 ] ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - out = convertArray( arr, dtypes[ i ] ); - t.strictEqual( expected[ i ][ 1 ]( out ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < arr.length; j++ ) { - t.strictEqual( out[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (bool => real)', function test( t ) { - var expected; - var dtypes; - var arr; - var out; - var i; - var j; - - dtypes = [ - 'float64', - 'float32', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - arr = new BooleanArray( [ true, false, true ] ); - expected = [ - [ new Float64Array( [ 1.0, 0.0, 1.0 ] ), isFloat64Array ], - [ new Float32Array( [ 1.0, 0.0, 1.0 ] ), isFloat32Array ], - [ new Int16Array( [ 1, 0, 1 ] ), isInt16Array ], - [ new Int32Array( [ 1, 0, 1 ] ), isInt32Array ], - [ new Int8Array( [ 1, 0, 1 ] ), isInt8Array ], - [ new Uint16Array( [ 1, 0, 1 ] ), isUint16Array ], - [ new Uint32Array( [ 1, 0, 1 ] ), isUint32Array ], - [ new Uint8Array( [ 1, 0, 1 ] ), isUint8Array ], - [ new Uint8ClampedArray( [ 1, 0, 1 ] ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - out = convertArray( arr, dtypes[ i ] ); - t.strictEqual( expected[ i ][ 1 ]( out ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < arr.length; j++ ) { - t.strictEqual( out[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (bool => generic)', function test( t ) { - var expected; - var arr; - var out; - var i; - - arr = new BooleanArray( [ true, false, true, true ] ); - expected = [ - arr.get( 0 ), - arr.get( 1 ), - arr.get( 2 ), - arr.get( 3 ) - ]; - out = convertArray( arr, 'generic' ); - t.strictEqual( isArray( out ), true, 'returns expected value type' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( out[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (bool => bool)', function test( t ) { - var expected; - var out; - var arr; - - arr = new BooleanArray( [ true, false, true, true ] ); - expected = new Uint8Array( [ 1, 0, 1, 1 ] ); - - out = convertArray( arr, 'bool' ); - t.deepEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (complex64 => generic)', function test( t ) { - var expected; - var arr; - var out; - var v1; - var v2; - var i; - - arr = new Complex64Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - arr.get( 0 ), - arr.get( 1 ), - arr.get( 2 ), - arr.get( 3 ) - ]; - out = convertArray( arr, 'generic' ); - t.strictEqual( isArray( out ), true, 'returns expected value type' ); - for ( i = 0; i < arr.length; i++ ) { - v1 = out[ i ]; - v2 = expected[ i ]; - t.strictEqual( isComplex64( v1 ), true, 'returns expected value' ); - t.strictEqual( realf( v1 ), realf( v2 ), 'returns expected real component' ); - t.strictEqual( imagf( v1 ), imagf( v2 ), 'returns expected imaginary component' ); - } - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (complex128 => generic)', function test( t ) { - var expected; - var arr; - var out; - var v1; - var v2; - var i; - - arr = new Complex128Array( [ -1.0, 1.0, 0.0, 2.0, 1.0, 3.0, 2.0, 4.0 ] ); - expected = [ - arr.get( 0 ), - arr.get( 1 ), - arr.get( 2 ), - arr.get( 3 ) - ]; - out = convertArray( arr, 'generic' ); - t.strictEqual( isArray( out ), true, 'returns expected value type' ); - for ( i = 0; i < arr.length; i++ ) { - v1 = out[ i ]; - v2 = expected[ i ]; - t.strictEqual( isComplex128( v1 ), true, 'returns expected value' ); - t.strictEqual( real( v1 ), real( v2 ), 'returns expected real component' ); - t.strictEqual( imag( v1 ), imag( v2 ), 'returns expected imaginary component' ); - } - t.end(); -}); - -tape( 'the function converts an array to an array of a different data type (large allocations)', function test( t ) { - var expected; - var dtypes; - var out; - var arr; - var i; - - dtypes = [ - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'complex64', - 'complex128', - 'bool' - ]; - arr = []; - for ( i = 0; i < 1e6; i++ ) { - arr.push( 0 ); - } - expected = [ - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray, - isComplex64Array, - isComplex128Array, - isBooleanArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - out = convertArray( arr, dtypes[ i ] ); - t.strictEqual( expected[ i ]( out ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/ctors/README.md b/ctors/README.md deleted file mode 100644 index 2b5b6cb31..000000000 --- a/ctors/README.md +++ /dev/null @@ -1,147 +0,0 @@ - - -# Constructors - -> Array constructors. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ctors = require( '@stdlib/array/ctors' ); -``` - -#### ctors( dtype ) - -Returns an array constructor for a specified data type. - -```javascript -var ctor = ctors( 'float64' ); -// returns -``` - -The function returns constructors for the following data types: - -- `float32`: single-precision floating-point numbers. -- `float64`: double-precision floating-point numbers. -- `complex64`: single-precision complex floating-point numbers. -- `complex128`: double-precision complex floating-point numbers. -- `bool`: boolean values. -- `generic`: values of any type. -- `int16`: signed 16-bit integers. -- `int32`: signed 32-bit integers. -- `int8`: signed 8-bit integers. -- `uint16`: unsigned 16-bit integers. -- `uint32`: unsigned 32-bit integers. -- `uint8`: unsigned 8-bit integers. -- `uint8c`: unsigned clamped 8-bit integers. - -If provided an unknown or unsupported data type, the function returns `null`. - -```javascript -var ctor = ctors( 'float' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var ctors = require( '@stdlib/array/ctors' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ctors/benchmark/benchmark.js b/ctors/benchmark/benchmark.js deleted file mode 100644 index ef79d6bd8..000000000 --- a/ctors/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var dtypes = require( './../../dtypes' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var ctors = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var ctor; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ctor = ctors( DTYPES[ i%DTYPES.length ] ); - if ( typeof ctor !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( ctor ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/ctors/docs/repl.txt b/ctors/docs/repl.txt deleted file mode 100644 index 6a7f5b2dc..000000000 --- a/ctors/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( dtype ) - Returns an array constructor. - - The function returns constructors for the following data types: - - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - bool: boolean values. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - Returns - ------- - out: Function|null - Constructor. - - Examples - -------- - > var ctor = {{alias}}( 'float64' ) - - > ctor = {{alias}}( 'float' ) - null - - See Also - -------- - diff --git a/ctors/docs/types/index.d.ts b/ctors/docs/types/index.d.ts deleted file mode 100644 index 504dffaee..000000000 --- a/ctors/docs/types/index.d.ts +++ /dev/null @@ -1,200 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import BooleanArray = require( './../../../bool' ); - -/** -* Returns a `Float64Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -*/ -declare function ctors( dtype: 'float64' ): typeof Float64Array; - -/** -* Returns a `Float32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'float32' ); -* // returns -*/ -declare function ctors( dtype: 'float32' ): typeof Float32Array; - -/** -* Returns a `Complex128Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'complex128' ); -* // returns -*/ -declare function ctors( dtype: 'complex128' ): typeof Complex128Array; - -/** -* Returns a `Complex64Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'complex64' ); -* // returns -*/ -declare function ctors( dtype: 'complex64' ): typeof Complex64Array; - -/** -* Returns a `BooleanArray` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'bool' ); -* // returns -*/ -declare function ctors( dtype: 'bool' ): typeof BooleanArray; - -/** -* Returns an `Int32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int32' ); -* // returns -*/ -declare function ctors( dtype: 'int32' ): typeof Int32Array; - -/** -* Returns an `Int16Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int16' ); -* // returns -*/ -declare function ctors( dtype: 'int16' ): typeof Int16Array; - -/** -* Returns an `Int8Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int8' ); -* // returns -*/ -declare function ctors( dtype: 'int8' ): typeof Int8Array; - -/** -* Returns a `Uint32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint32' ); -* // returns -*/ -declare function ctors( dtype: 'uint32' ): typeof Uint32Array; - -/** -* Returns a `Uint16Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint16' ); -* // returns -*/ -declare function ctors( dtype: 'uint16' ): typeof Uint16Array; - -/** -* Returns a `Uint8Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint8' ); -* // returns -*/ -declare function ctors( dtype: 'uint8' ): typeof Uint8Array; - -/** -* Returns a `Uint8ClampedArray` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint8c' ); -* // returns -*/ -declare function ctors( dtype: 'uint8c' ): typeof Uint8ClampedArray; - -/** -* Returns a generic array constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'generic' ); -* // returns -*/ -declare function ctors( dtype: 'generic' ): typeof Array; - -/** -* Returns an array constructor. -* -* @param dtype - data type -* @returns constructor or null -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -* -* @example -* var ctor = ctors( 'float' ); -* // returns null -*/ -declare function ctors( dtype: string ): Function | null; - - -// EXPORTS // - -export = ctors; diff --git a/ctors/docs/types/test.ts b/ctors/docs/types/test.ts deleted file mode 100644 index 45300bb6b..000000000 --- a/ctors/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import ctors = require( './index' ); - - -// TESTS // - -// The function returns a function or null.. -{ - ctors( 'float64' ); // $ExpectType Float64ArrayConstructor - ctors( 'float32' ); // $ExpectType Float32ArrayConstructor - ctors( 'complex128' ); // $ExpectType Complex128ArrayConstructor - ctors( 'complex64' ); // $ExpectType Complex64ArrayConstructor - ctors( 'bool' ); // $ExpectType BooleanArrayConstructor - ctors( 'int32' ); // $ExpectType Int32ArrayConstructor - ctors( 'int16' ); // $ExpectType Int16ArrayConstructor - ctors( 'int8' ); // $ExpectType Int8ArrayConstructor - ctors( 'uint32' ); // $ExpectType Uint32ArrayConstructor - ctors( 'uint16' ); // $ExpectType Uint16ArrayConstructor - ctors( 'uint8' ); // $ExpectType Uint8ArrayConstructor - ctors( 'uint8c' ); // $ExpectType Uint8ClampedArrayConstructor - ctors( 'generic' ); // $ExpectType ArrayConstructor - ctors( 'float' ); // $ExpectType Function | null -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ctors(); // $ExpectError - ctors( 'int32', 3 ); // $ExpectError -} diff --git a/ctors/examples/index.js b/ctors/examples/index.js deleted file mode 100644 index 1bae207c8..000000000 --- a/ctors/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../dtypes' ); -var ctors = require( './../lib' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} diff --git a/ctors/lib/ctors.js b/ctors/lib/ctors.js deleted file mode 100644 index 5e9859d24..000000000 --- a/ctors/lib/ctors.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); - - -// MAIN // - -// Mapping from data types to constructors... -var ctors = { - 'float64': Float64Array, - 'float32': Float32Array, - 'generic': Array, // TODO: replace with `stdlib` pkg - 'int16': Int16Array, - 'int32': Int32Array, - 'int8': Int8Array, - 'uint16': Uint16Array, - 'uint32': Uint32Array, - 'uint8': Uint8Array, - 'uint8c': Uint8ClampedArray, - 'complex64': Complex64Array, - 'complex128': Complex128Array, - 'bool': BooleanArray -}; - - -// EXPORTS // - -module.exports = ctors; diff --git a/ctors/lib/index.js b/ctors/lib/index.js deleted file mode 100644 index 7fa3a87ef..000000000 --- a/ctors/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Array constructors. -* -* @module @stdlib/array/ctors -* -* @example -* var ctors = require( '@stdlib/array/ctors' ); -* -* var ctor = ctors( 'float64' ); -* // returns -* -* ctor = ctors( 'int' ); -* // returns null -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ctors/lib/main.js b/ctors/lib/main.js deleted file mode 100644 index c86c29e50..000000000 --- a/ctors/lib/main.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var table = require( './ctors.js' ); - - -// MAIN // - -/** -* Returns an array constructor. -* -* @param {string} dtype - data type -* @returns {(Function|null)} constructor or null -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -* -* @example -* var ctor = ctors( 'float' ); -* // returns null -*/ -function ctors( dtype ) { - return table[ dtype ] || null; -} - - -// EXPORTS // - -module.exports = ctors; diff --git a/ctors/package.json b/ctors/package.json deleted file mode 100644 index 5812aafaf..000000000 --- a/ctors/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/array/ctors", - "version": "0.0.0", - "description": "Array constructors.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "list", - "dtypes", - "dtype", - "data", - "structure", - "constructors", - "constructor", - "ctors", - "ctor", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/ctors/test/test.js b/ctors/test/test.js deleted file mode 100644 index 05e15ee9d..000000000 --- a/ctors/test/test.js +++ /dev/null @@ -1,129 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( './../../dtypes' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ctors = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctors, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns array constructors', function test( t ) { - var expected; - var dtypes; - var ctor; - var i; - - dtypes = [ - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'complex64', - 'complex128', - 'bool' - ]; - expected = [ - Float64Array, - Float32Array, - Array, // TODO: explicitly require - Int16Array, - Int32Array, - Int8Array, - Uint16Array, - Uint32Array, - Uint8Array, - Uint8ClampedArray, - Complex64Array, - Complex128Array, - BooleanArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - ctor = ctors( dtypes[ i ] ); - t.strictEqual( ctor, expected[ i ], 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'the function returns a constructor for each supported array data type', function test( t ) { - var DTYPES; - var ctor; - var i; - - DTYPES = dtypes(); - for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - - // Note: this is a weak test for a "constructor" - t.strictEqual( isFunction( ctor ), true, 'returns a function for ' + DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'binary', - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( ctors( dtypes[i] ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/dataview/README.md b/dataview/README.md deleted file mode 100644 index 3ea7dde3b..000000000 --- a/dataview/README.md +++ /dev/null @@ -1,214 +0,0 @@ - - -# DataView - -> [Constructor][mdn-dataview] which returns a data view representing a provided array buffer. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var DataView = require( '@stdlib/array/dataview' ); -``` - -#### DataView( buffer\[, byteOffset\[, byteLength]] ) - -Returns a [`DataView`][mdn-dataview] representing a provided array buffer. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 5 ); -// returns - -var dv = new DataView( buf ); -// returns -``` - -* * * - -### Properties - -#### DataView.prototype.buffer - -**Read-only** property which returns the underlying array buffer. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf1 = new ArrayBuffer( 5 ); -var dv = new DataView( buf1 ); - -var buf2 = dv.buffer; -// returns - -var bool = ( buf1 === buf2 ); -// returns true -``` - -#### DataView.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [`DataView`][mdn-dataview]. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 5 ); -var dv = new DataView( buf ); - -var byteLength = dv.byteLength; -// returns 5 -``` - -#### DataView.prototype.byteOffset - -**Read-only** property which returns the number of bytes from the [`DataView`][mdn-dataview] to the start of the underlying array buffer. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 5 ); -var dv = new DataView( buf, 3 ); - -var byteOffset = dv.byteOffset; -// returns 3 -``` - -* * * - -### Methods - -TODO: document methods - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var IS_LITTLE_ENDIAN = require( '@stdlib/assert/is-little-endian' ); -var toBinaryString = require( '@stdlib/number/uint8/base/to-binary-string' ); -var randu = require( '@stdlib/random/base/randu' ); -var Uint8Array = require( '@stdlib/array/uint8' ); -var ArrayBuffer = require( '@stdlib/array/buffer' ); -var DataView = require( '@stdlib/array/dataview' ); - -// Create a new ArrayBuffer: -var buf = new ArrayBuffer( 64 ); - -// Create a new DataView: -var dv = new DataView( buf ); - -// Set values in the view: -var i; -for ( i = 0; i < dv.byteLength/8; i++ ) { - dv.setFloat64( i*8, randu()*100.0, IS_LITTLE_ENDIAN ); -} - -// Create a "bytes" view of the underlying array buffer: -var bytes = new Uint8Array( dv.buffer ); - -// Print the bytes: -for ( i = 0; i < bytes.length; i++ ) { - console.log( 'byte %d: %s', i, toBinaryString( bytes[ i ] ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/dataview/benchmark/benchmark.js b/dataview/benchmark/benchmark.js deleted file mode 100644 index 57f599918..000000000 --- a/dataview/benchmark/benchmark.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasDataViewSupport = require( '@stdlib/assert/has-dataview-support' ); -var isDataView = require( '@stdlib/assert/is-dataview' ); -var ArrayBuffer = require( './../../buffer' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasDataViewSupport() // TODO: remove once DataView polyfill is written -}; - - -// MAIN // - -bench( pkg, opts, function benchmark( b ) { - var buf; - var dv; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - dv = new ctor( buf ); - if ( dv.byteLength !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isDataView( dv ) ) { - b.fail( 'should return a DataView' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/dataview/benchmark/benchmark.length.js b/dataview/benchmark/benchmark.length.js deleted file mode 100644 index 0fc5f336d..000000000 --- a/dataview/benchmark/benchmark.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasDataViewSupport = require( '@stdlib/assert/has-dataview-support' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isDataView = require( '@stdlib/assert/is-dataview' ); -var ArrayBuffer = require( './../../buffer' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasDataViewSupport() // TODO: remove once DataView polyfill is written -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var buf; - var dv; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf = new ArrayBuffer( len ); - dv = new ctor( buf ); - if ( dv.byteLength !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isDataView( dv ) ) { - b.fail( 'should return a DataView' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, opts, f ); - } -} - -main(); diff --git a/dataview/docs/repl.txt b/dataview/docs/repl.txt deleted file mode 100644 index 8d0dadf67..000000000 --- a/dataview/docs/repl.txt +++ /dev/null @@ -1,74 +0,0 @@ - -{{alias}}( buffer[, byteOffset[, byteLength]] ) - Returns a data view representing a provided array buffer. - - Parameters - ---------- - buffer: ArrayBuffer|SharedArrayBuffer - Array buffer. - - byteOffset: integer (optional) - Offset (in bytes) to the first byte in the array buffer for the new view - to reference. Default: 0. - - byteLength: integer (optional) - Number of elements in the byte array. If not provided, the view's length - will equal the buffer's length. - - Returns - ------- - out: DataView - A data view. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 5 ) - - > var dv = new {{alias}}( buf ) - - - -{{alias}}.prototype.buffer - Read-only property which returns the underlying array buffer. - - Examples - -------- - > var buf1 = new {{alias:@stdlib/array/buffer}}( 5 ); - > var dv = new {{alias}}( buf1 ); - > var buf2 = dv.buffer - - > var b = ( buf1 === buf2 ) - true - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the view. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 5 ); - > var dv = new {{alias}}( buf ); - > dv.byteLength - 5 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the view to the - start of the underlying array buffer. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 5 ); - > var dv = new {{alias}}( buf, 2 ); - > dv.byteLength - 3 - > dv.byteOffset - 2 - - -TODO: document properties/methods - - - See Also - -------- - diff --git a/dataview/docs/types/index.d.ts b/dataview/docs/types/index.d.ts deleted file mode 100644 index d7b175e2c..000000000 --- a/dataview/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Constructor which returns a data view representing a provided array buffer. -*/ -export = DataView; diff --git a/dataview/docs/types/test.ts b/dataview/docs/types/test.ts deleted file mode 100644 index 746c3da0f..000000000 --- a/dataview/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ArrayBuffer = require( './../../../buffer' ); -import DataView = require( './index' ); - - -// TESTS // - -// The function returns a data view instance... -{ - const buf = new ArrayBuffer( 5 ); - new DataView( buf ); // $ExpectType DataView -} - -// The constructor function has to be invoked with `new`... -{ - const buf = new ArrayBuffer( 5 ); - DataView( buf ); // $ExpectError -} diff --git a/dataview/examples/index.js b/dataview/examples/index.js deleted file mode 100644 index 17f32a8ae..000000000 --- a/dataview/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 proc = require( 'process' ); -var IS_LITTLE_ENDIAN = require( '@stdlib/assert/is-little-endian' ); -var toBinaryString = require( '@stdlib/number/uint8/base/to-binary-string' ); -var hasDataViewSupport = require( '@stdlib/assert/has-dataview-support' ); -var randu = require( '@stdlib/random/base/randu' ); -var Uint8Array = require( './../../uint8' ); -var ArrayBuffer = require( './../../buffer' ); -var DataView = require( './../lib' ); - -if ( !hasDataViewSupport() ) { - // TODO: remove once DataView polyfill is written - console.error( 'Environment does not provide DataView support.' ); - proc.exit( 0 ); -} -// Create a new ArrayBuffer: -var buf = new ArrayBuffer( 64 ); - -// Create a new DataView: -var dv = new DataView( buf ); - -// Set values in the view: -var i; -for ( i = 0; i < dv.byteLength/8; i++ ) { - dv.setFloat64( i*8, randu()*100.0, IS_LITTLE_ENDIAN ); -} - -// Create a "bytes" view of the underlying array buffer: -var bytes = new Uint8Array( dv.buffer ); - -// Print the bytes: -for ( i = 0; i < bytes.length; i++ ) { - console.log( 'byte %d: %s', i, toBinaryString( bytes[ i ] ) ); -} diff --git a/dataview/lib/index.js b/dataview/lib/index.js deleted file mode 100644 index 134dd9d23..000000000 --- a/dataview/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Constructor which returns a data view representing a provided array buffer. -* -* @module @stdlib/array/dataview -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var DataView = require( '@stdlib/array/dataview' ); -* -* var buf = new ArrayBuffer( 10 ); -* // returns -* -* var dv = new DataView( buf ); -* // returns -*/ - -// MODULES // - -var hasDataViewSupport = require( '@stdlib/assert/has-dataview-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasDataViewSupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/dataview/lib/main.js b/dataview/lib/main.js deleted file mode 100644 index 7ab9b2191..000000000 --- a/dataview/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof DataView === 'function' ) ? DataView : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/dataview/lib/polyfill.js b/dataview/lib/polyfill.js deleted file mode 100644 index c229902e3..000000000 --- a/dataview/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Constructor which returns a data view representing a provided array buffer. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/dataview/package.json b/dataview/package.json deleted file mode 100644 index 8ae35a831..000000000 --- a/dataview/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/dataview", - "version": "0.0.0", - "description": "DataView.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "arraybuffer", - "dataview", - "buffer", - "buf", - "binary" - ] -} diff --git a/dataview/test/test.js b/dataview/test/test.js deleted file mode 100644 index 366545b52..000000000 --- a/dataview/test/test.js +++ /dev/null @@ -1,167 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasDataViewSupport = require( '@stdlib/assert/has-dataview-support' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasProp = require( '@stdlib/assert/has-property' ); -var NODE_VERSION = require( '@stdlib/process/node-version' ); -var ArrayBuffer = require( './../../buffer' ); -var polyfill = require( './../lib/polyfill.js' ); -var Ctor = require( './../lib' ); - - -// VARIABLES // - -var FLG = hasDataViewSupport(); -var opts = { - 'skip': ( NODE_VERSION && NODE_VERSION.slice( 0, 4 ) === '0.10' ) // FIXME: remove once polyfill is written -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `DataView`, the export is an alias for `DataView`', function test( t ) { - var Foo = proxyquire( './../lib', { - '@stdlib/assert/has-dataview-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( FLG ) { - t.strictEqual( Ctor, DataView, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `DataView`, the export is a polyfill', function test( t ) { - var Foo = proxyquire( './../lib', { - '@stdlib/assert/has-dataview-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); - -tape( 'the main export is a constructor', opts, function test( t ) { - var buf; - var dv; - - buf = new ArrayBuffer( 10 ); - - dv = new Ctor( buf ); - t.strictEqual( instanceOf( dv, Ctor ), true, 'returns an instance' ); - - dv = new Ctor( buf, 4 ); - t.strictEqual( instanceOf( dv, Ctor ), true, 'returns an instance' ); - - dv = new Ctor( buf, 4, 2 ); - t.strictEqual( instanceOf( dv, Ctor ), true, 'returns an instance' ); - - t.end(); -}); - -tape( 'the constructor throws an error if not provided an array buffer', opts, function test( t ) { - t.throws( badValue, TypeError, 'throws an error' ); - t.end(); - - function badValue() { - return new Ctor(); - } -}); - -tape( 'the constructor returns a `DataView` instance having a `buffer` property, which returns the underlying array buffer', opts, function test( t ) { - var buf; - var dv; - - t.strictEqual( hasOwnProp( Ctor.prototype, 'buffer' ), true, 'has prototype property' ); - - buf = new ArrayBuffer( 10 ); - dv = new Ctor( buf ); - t.strictEqual( hasOwnProp( dv, 'buffer' ), false, 'does not have own property' ); - t.strictEqual( hasProp( dv, 'buffer' ), true, 'has property' ); - t.strictEqual( dv.buffer, buf, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a `DataView` instance having a `byteLength` property, which returns the number of bytes in a `DataView`', opts, function test( t ) { - var buf; - var dv; - - t.strictEqual( hasOwnProp( Ctor.prototype, 'byteLength' ), true, 'has prototype property' ); - - buf = new ArrayBuffer( 10 ); - - dv = new Ctor( buf ); - t.strictEqual( hasOwnProp( dv, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( dv, 'byteLength' ), true, 'has property' ); - t.strictEqual( dv.byteLength, 10, 'returns expected value' ); - - dv = new Ctor( buf, 4 ); - t.strictEqual( hasOwnProp( dv, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( dv, 'byteLength' ), true, 'has property' ); - t.strictEqual( dv.byteLength, 6, 'returns expected value' ); - - dv = new Ctor( buf, 4, 2 ); - t.strictEqual( hasOwnProp( dv, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( dv, 'byteLength' ), true, 'has property' ); - t.strictEqual( dv.byteLength, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a `DataView` instance having a `byteOffset` property, which returns the number of bytes from the view to the start of the underlying array buffer', opts, function test( t ) { - var buf; - var dv; - - t.strictEqual( hasOwnProp( Ctor.prototype, 'byteOffset' ), true, 'has prototype property' ); - - buf = new ArrayBuffer( 10 ); - dv = new Ctor( buf, 4 ); - t.strictEqual( hasOwnProp( dv, 'byteOffset' ), false, 'does not have own property' ); - t.strictEqual( hasProp( dv, 'byteOffset' ), true, 'has property' ); - t.strictEqual( dv.byteOffset, 4, 'returns expected value' ); - - t.end(); -}); diff --git a/dataview/test/test.polyfill.js b/dataview/test/test.polyfill.js deleted file mode 100644 index 6e8465737..000000000 --- a/dataview/test/test.polyfill.js +++ /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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests diff --git a/datespace/README.md b/datespace/README.md deleted file mode 100644 index 586986452..000000000 --- a/datespace/README.md +++ /dev/null @@ -1,190 +0,0 @@ - - -# Datespace - -> Generate an array of linearly spaced [dates][mdn-date-object]. - -
- -## Usage - -```javascript -var datespace = require( '@stdlib/array/datespace' ); -``` - -#### datespace( start, stop\[, length]\[, opts] ) - -Generates an `array` of linearly spaced [`Date`][mdn-date-object] objects. If a `length` is not provided, the default output `array` length is `100`. - -```javascript -var end = '2014-12-02T07:00:54.973Z'; -var start = new Date( end ) - 60000; - -var arr = datespace( start, end, 6 ); -/* returns [ - 'Mon Dec 01 2014 22:59:54 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:06 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:18 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:30 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:42 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:54 GMT-0800 (PST)' -] -*/ -``` - -The `start` and `stop` times may be either [`Date`][mdn-date-object] objects, date strings, Unix timestamps, or JavaScript timestamps. - - - - - -```javascript -// JavaScript timestamps: -var end = 1417503654973; -var start = new Date( end - 60000 ); - -var arr = datespace( start, end, 6 ); -/* returns [ - 'Mon Dec 01 2014 22:59:54 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:06 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:18 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:30 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:42 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:54 GMT-0800 (PST)' -] -*/ - -// Unix timestamps: -end = 1417503655; -start = end - 60; - -arr = datespace( start, end, 6 ); -/* returns [ - 'Mon Dec 01 2014 22:59:54 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:06 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:18 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:30 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:42 GMT-0800 (PST)', - 'Mon Dec 01 2014 23:00:54 GMT-0800 (PST)' -] -*/ -``` - -The output `array` is guaranteed to include the `start` and `end` times. Beware, however, that values between the `start` and `end` are subject to rounding errors. For example, - -```javascript -var arr = datespace( 1417503655000, 1417503655001, 3 ); -// returns [ 1417503655000, 1417503655000, 1417503655001 ] -``` - -where sub-millisecond values are truncated by the [`Date`][mdn-date-object] constructor. Duplicate values should only be a problem when the interval separating consecutive times is less than a millisecond. As the interval separating consecutive dates goes to infinity, the quantization noise introduced by millisecond resolution is negligible. - -By default, fractional timestamps are floored. To specify that timestamps always be rounded up or to the nearest millisecond **when converted to [`Date`][mdn-date-object] objects**, set the `round` option (default: `floor`). - -```javascript -// Equivalent of Math.ceil(): -var arr = datespace( 1417503655000, 1417503655001, 3, { - 'round': 'ceil' -}); -// returns [ 1417503655000, 1417503655001, 1417503655001 ] - -// Equivalent of Math.round(): -arr = datespace( 1417503655000, 1417503655001, 3, { - 'round': 'round' -}); -// returns [ 1417503655000, 1417503655001, 1417503655001 ] -``` - -
- - - -
- -
- - - -
- -## Examples - -```javascript -var datespace = require( '@stdlib/array/datespace' ); -var start; -var arr; -var end; - -end = '2014-12-02T07:00:54.973Z'; -start = new Date( end ) - 100000; - -// Default behavior: -arr = datespace( start, end ); -console.log( arr.join( '\n' ) ); - -// Specify length: -arr = datespace( start, end, 10 ); -console.log( arr.join( '\n' ) ); - -arr = datespace( start, end, 11 ); -console.log( arr.join( '\n' ) ); - -// Create an array with decremented values: -arr = datespace( end, start, 11 ); -console.log( arr.join( '\n' ) ); -``` - -
- - - - - - - - - - - - - - diff --git a/datespace/benchmark/benchmark.js b/datespace/benchmark/benchmark.js deleted file mode 100644 index ece0779c9..000000000 --- a/datespace/benchmark/benchmark.js +++ /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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var datespace = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var start; - var end; - var i; - var v; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - end = '2014-12-02T07:00:54.973Z'; - start = new Date( end ) - round( randu()*100.0 ); - v = datespace( start, end ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/datespace/benchmark/benchmark.length.js b/datespace/benchmark/benchmark.length.js deleted file mode 100644 index 22612f40b..000000000 --- a/datespace/benchmark/benchmark.length.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var datespace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var start; - var end; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - end = '2014-12-02T07:00:54.973Z'; - start = new Date( end ) - round( randu()*100.0 ); - v = datespace( start, end, len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/datespace/docs/repl.txt b/datespace/docs/repl.txt deleted file mode 100644 index 187bce84c..000000000 --- a/datespace/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( start, stop[, length][ , options] ) - Generates an array of linearly spaced dates. - - Parameters - ---------- - start: number - Start time as either a `Date` object, Unix timestamp, JavaScript - timestamp, or date string. - - stop: number - Stop time as either a `Date` object, Unix timestamp, JavaScript - timestamp, or date string. - - length: integer (optional) - Length of output array. Default: `100`. - - options: Object (optional) - Options. - - options.round: string (optional) - Specifies how sub-millisecond times should be rounded: - [ 'floor', 'ceil', 'round' ]. Default: 'floor'. - - Returns - ------- - arr: Array - Array of dates. - - Examples - -------- - > var stop = '2014-12-02T07:00:54.973Z'; - > var start = new Date( stop ) - 60000; - > var arr = {{alias}}( start, stop, 6 ) - [...] - - // Equivalent of Math.ceil(): - > var opts = { 'round': 'ceil' }; - > arr = {{alias}}( 1417503655000, 1417503655001, 3, opts ) - [...] - - See Also - -------- - diff --git a/datespace/docs/types/index.d.ts b/datespace/docs/types/index.d.ts deleted file mode 100644 index 0fd5d0ba9..000000000 --- a/datespace/docs/types/index.d.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Specifies how sub-millisecond times should be rounded (default: 'floor' ). - */ - round?: 'floor' | 'round' | 'ceil'; -} - -/** -* Generates an array of linearly spaced dates. -* -* @param start - start time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string -* @param stop - stop time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string -* @param options - function options -* @param options.round - specifies how sub-millisecond times should be rounded: [ 'floor', 'ceil', 'round' ] (default: 'floor' ) -* @throws must provide valid options -* @returns array of dates -* -* @example -* var stop = '2014-12-02T07:00:54.973Z'; -* var start = new Date( stop ) - 60000; -* -* var arr = datespace( start, stop, 6 ); -* // returns [...] -* -* @example -* // Equivalent of Math.ceil(): -* var arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'ceil' } ); -* // returns [...] -* -* // Equivalent of Math.round(): -* var arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'round' } ); -* // returns [...] -*/ -declare function datespace( start: Date | number | string, stop: Date | number | string, options?: Options ): Array; - -/** -* Generates an array of linearly spaced dates. -* -* @param start - start time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string -* @param stop - stop time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string -* @param length - output array length (default: 100) -* @param options - function options -* @param options.round - specifies how sub-millisecond times should be rounded: [ 'floor', 'ceil', 'round' ] (default: 'floor' ) -* @throws length argument must a positive integer -* @throws must provide valid options -* @returns array of dates -* -* @example -* var stop = '2014-12-02T07:00:54.973Z'; -* var start = new Date( stop ) - 60000; -* -* var arr = datespace( start, stop, 6 ); -* // returns [...] -* -* @example -* // Equivalent of Math.ceil(): -* var arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'ceil' } ); -* // returns [...] -* -* // Equivalent of Math.round(): -* var arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'round' } ); -* // returns [...] -*/ -declare function datespace( start: Date | number | string, stop: Date | number | string, length: number, options?: Options ): Array; - - -// EXPORTS // - -export = datespace; diff --git a/datespace/docs/types/test.ts b/datespace/docs/types/test.ts deleted file mode 100644 index 20ae2fec2..000000000 --- a/datespace/docs/types/test.ts +++ /dev/null @@ -1,86 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import datespace = require( './index' ); - - -// TESTS // - -// The function returns an array of dates... -{ - const stop = '2014-12-02T07:00:54.973Z'; - const start = new Date( stop ).getTime() - 60000; - datespace( start, stop ); // $ExpectType Date[] - datespace( start, stop, 30 ); // $ExpectType Date[] - datespace( start, stop, { 'round': 'floor' } ); // $ExpectType Date[] - datespace( start, stop, 30, { 'round': 'floor' } ); // $ExpectType Date[] -} - -// The compiler throws an error if the function is provided values other `Date` objects, Unix timestamps, JavaScript timestamps, or date strings for the first two parameters... -{ - const stop = '2014-12-02T07:00:54.973Z'; - const start = new Date( stop ).getTime() - 60000; - datespace( true, stop ); // $ExpectError - datespace( false, stop ); // $ExpectError - datespace( null, stop ); // $ExpectError - datespace( [], stop ); // $ExpectError - datespace( {}, stop ); // $ExpectError - datespace( ( x: number ): number => x, stop ); // $ExpectError - - datespace( start, true ); // $ExpectError - datespace( start, false ); // $ExpectError - datespace( start, [] ); // $ExpectError - datespace( start, {} ); // $ExpectError - datespace( start, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a value other than a number or object for the third parameter... -{ - const stop = '2014-12-02T07:00:54.973Z'; - const start = new Date( stop ).getTime() - 60000; - datespace( start, stop, true ); // $ExpectError - datespace( start, stop, false ); // $ExpectError - datespace( start, stop, '5' ); // $ExpectError - datespace( start, stop, [] ); // $ExpectError - datespace( start, stop, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `round` option which is not a recognized rounding procedure... -{ - const stop = '2014-12-02T07:00:54.973Z'; - const start = new Date( stop ).getTime() - 60000; - datespace( start, stop, { 'round': 'abc' } ); // $ExpectError - datespace( start, stop, { 'round': 123 } ); // $ExpectError - datespace( start, stop, { 'round': null } ); // $ExpectError - datespace( start, stop, { 'round': [] } ); // $ExpectError - datespace( start, stop, { 'round': {} } ); // $ExpectError - datespace( start, stop, { 'round': ( x: number ): number => x } ); // $ExpectError - - datespace( start, stop, 10, { 'round': 'abc' } ); // $ExpectError - datespace( start, stop, 10, { 'round': 123 } ); // $ExpectError - datespace( start, stop, 10, { 'round': null } ); // $ExpectError - datespace( start, stop, 10, { 'round': [] } ); // $ExpectError - datespace( start, stop, 10, { 'round': {} } ); // $ExpectError - datespace( start, stop, 10, { 'round': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - datespace(); // $ExpectError - datespace( new Date() ); // $ExpectError -} diff --git a/datespace/examples/index.js b/datespace/examples/index.js deleted file mode 100644 index 16a947a0e..000000000 --- a/datespace/examples/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 datespace = require( './../lib' ); -var start; -var arr; -var end; - -end = '2014-12-02T07:00:54.973Z'; -start = new Date( end ) - 100000; - -// Default behavior: -console.log( '\nDefault:' ); -arr = datespace( start, end ); -console.log( arr.join( '\n' ) ); - -// Specify length: -console.log( '\nLength 10:' ); -arr = datespace( start, end, 10 ); -console.log( arr.join( '\n' ) ); - -console.log( '\nLength 11:' ); -arr = datespace( start, end, 11 ); -console.log( arr.join( '\n' ) ); - -// Create an array with decremented values: -console.log( '\nDecremented values:' ); -arr = datespace( end, start, 11 ); -console.log( arr.join( '\n' ) ); diff --git a/datespace/lib/index.js b/datespace/lib/index.js deleted file mode 100644 index f76ff4cf9..000000000 --- a/datespace/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Generate an array of linearly spaced dates. -* -* @module @stdlib/array/datespace -* -* @example -* var datespace = require( '@stdlib/array/datespace' ); -* -* var stop = '2014-12-02T07:00:54.973Z'; -* var start = new Date( stop ) - 60000; -* -* var arr = datespace( start, stop, 6 ); -* // returns [...] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/datespace/lib/main.js b/datespace/lib/main.js deleted file mode 100644 index 28032e29e..000000000 --- a/datespace/lib/main.js +++ /dev/null @@ -1,193 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isInteger = require( '@stdlib/assert/is-integer' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isObject = require( '@stdlib/assert/is-object' ); -var format = require( '@stdlib/string/format' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var round = require( '@stdlib/math/base/special/round' ); -var ceil = require( '@stdlib/math/base/special/ceil' ); - - -// VARIABLES // - -var timestamp = /^\d{10}$|^\d{13}$/; -var rounders = [ 'floor', 'ceil', 'round' ]; - - -// FUNCTIONS // - -/** -* Validates a date parameter. -* -* @private -* @param {*} value - value to be validated -* @param {string} name - name to be used in error messages -* @throws {TypeError} value must either be a date string, Date object, Unix timestamp, or JavaScript timestamp -* @throws {Error} numeric date must be either a Unix or JavaScript timestamp -* @returns {Date} validated date -*/ -function validDate( value, name ) { - var type; - - type = typeof value; - if ( type === 'string' ) { - value = Date.parse( value ); - if ( value !== value ) { - throw new Error( format( 'invalid argument. Unable to parse %s date.', name.toLowerCase() ) ); - } - value = new Date( value ); - } - if ( type === 'number' ) { - if ( !timestamp.test( value ) ) { - throw new Error( format( 'invalid argument. Numeric %s date must be either a Unix or JavaScript timestamp.', name.toLowerCase() ) ); - } - if ( value.toString().length === 10 ) { - value *= 1000; // sec to ms - } - value = new Date( value ); - } - if ( !(value instanceof Date) ) { - throw new TypeError( format( 'invalid argument. %s date must either be a date string, Date object, Unix timestamp, or JavaScript timestamp.', name ) ); - } - return value; -} - - -// MAIN // - -/** -* Generates an array of linearly spaced dates. -* -* @param {(Date|number|string)} start - start time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string -* @param {(Date|number|string)} stop - stop time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string -* @param {number} [length] - output array length (default: 100) -* @param {Object} [options] - function options -* @param {string} [options.round] - specifies how sub-millisecond times should be rounded: [ 'floor', 'ceil', 'round' ] (default: 'floor' ) -* @throws {TypeError} length argument must a positive integer -* @throws {Error} must provide valid options -* @returns {Array} array of dates -* -* @example -* var stop = '2014-12-02T07:00:54.973Z'; -* var start = new Date( stop ) - 60000; -* -* var arr = datespace( start, stop, 6 ); -* // returns [...] -* -* @example -* // Equivalent of Math.ceil(): -* var arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'ceil' } ); -* // returns [...] -* -* // Equivalent of Math.round(): -* arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'round' } ); -* // returns [...] -*/ -function datespace( start, stop, length, options ) { - var opts; - var len; - var flg; - var arr; - var end; - var fcn; - var tmp; - var d; - var i; - - len = 100; - flg = true; - opts = { - 'round': 'floor' - }; - start = validDate( start, 'Start' ); - stop = validDate( stop, 'Stop' ); - if ( arguments.length > 2 ) { - if ( arguments.length === 3 ) { - if ( isObject( length ) ) { - opts = length; - } else { - len = length; - - // Turn off checking the options object... - flg = false; - } - } else { - opts = options; - len = length; - } - if ( len === 0 ) { - return []; - } - if ( !isInteger( len ) || len < 0 ) { - throw new TypeError( format( 'invalid argument. Length must be a positive integer. Value: `%s`.', len ) ); - } - if ( flg ) { - if ( !isObject( opts ) ) { - throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) ); - } - if ( hasOwnProp( opts, 'round' ) ) { - if ( !isString( opts.round ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'round', opts.round ) ); - } - if ( rounders.indexOf( opts.round ) === -1 ) { - throw new Error( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'round', rounders.join( '", "' ), opts.round ) ); - } - } - } - } - switch ( opts.round ) { - case 'round': - fcn = round; - break; - case 'ceil': - fcn = ceil; - break; - case 'floor': - default: - fcn = floor; - break; - } - - // Calculate the increment... - end = len - 1; - d = ( stop.getTime() - start.getTime() ) / end; - - // Build the output array... - arr = new Array( len ); - tmp = start; - arr[ 0 ] = tmp; - tmp = tmp.getTime(); - for ( i = 1; i < end; i++ ) { - tmp += d; - arr[ i ] = new Date( fcn( tmp ) ); - } - arr[ end ] = stop; - return arr; -} - - -// EXPORTS // - -module.exports = datespace; diff --git a/datespace/package.json b/datespace/package.json deleted file mode 100644 index a1848548f..000000000 --- a/datespace/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/datespace", - "version": "0.0.0", - "description": "Generate an array of linearly spaced dates.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdmath", - "utilities", - "utils", - "mathematics", - "math", - "generic", - "array", - "matlab", - "linear", - "date" - ] -} diff --git a/datespace/test/test.js b/datespace/test/test.js deleted file mode 100644 index aa7cb7cb1..000000000 --- a/datespace/test/test.js +++ /dev/null @@ -1,445 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert/is-array' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var datespace = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof datespace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a valid start date', function test( t ) { - var values; - var stop; - var i; - - stop = new Date(); - - values = [ - 'beep', - 5, - -5, - true, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - datespace( value, stop ); - }; - } -}); - -tape( 'the function throws an error if not provided a valid stop date', function test( t ) { - var values; - var start; - var i; - - start = new Date().getTime(); - - values = [ - 'beep', - 5, - -5, - true, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - datespace( start, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid length', function test( t ) { - var values; - var start; - var stop; - var i; - - start = new Date().getTime(); - stop = new Date(); - - values = [ - 'beep', - 3.14, - -5, - true, - NaN, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue1( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - t.throws( badValue2( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue1( value ) { - return function badValue1() { - datespace( start, stop, value ); - }; - } - function badValue2( value ) { - return function badValue2() { - datespace( start, stop, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided a non-object for options', function test( t ) { - var values; - var start; - var stop; - var i; - - start = new Date().getTime(); - stop = new Date(); - - values = [ - 'beep', - 5, - true, - NaN, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - datespace( start, stop, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid round option', function test( t ) { - var values; - var start; - var stop; - var i; - - start = new Date().getTime(); - stop = new Date(); - - values = [ - 'beep', - 5, - true, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - datespace( start, stop, 10, { - 'round': value - }); - }; - } -}); - -tape( 'the function returns an empty array if provided a length of 0', function test( t ) { - var actual; - var start; - var stop; - - start = new Date().getTime(); - stop = new Date(); - actual = datespace( start, stop, 0 ); - - t.deepEqual( actual, [] ); - t.end(); -}); - -tape( 'the function returns an array of `Date` objects', function test( t ) { - var actual; - var start; - var stop; - var i; - - stop = '2014-12-02T07:00:55.973Z'; - start = new Date( stop ) - 5000; - - actual = datespace( start, stop ); - - t.strictEqual( isArray( actual ), true, 'returns an array' ); - for ( i = 0; i < actual.length; i++ ) { - t.ok( actual[i] instanceof Date, 'returns a date' ); - } - t.end(); -}); - -tape( 'the function supplies a default length', function test( t ) { - var actual; - var start; - var stop; - - stop = '2014-12-02T07:00:55.973Z'; - start = new Date( stop ) - 5000; - - actual = datespace( start, stop, { - 'round': 'floor' - }); - - t.ok( actual.length ); - t.ok( actual[0] < actual[1] ); - t.end(); -}); - -tape( 'the function outputs both incremental and decremental arrays', function test( t ) { - var actual; - var start; - var stop; - - stop = '2014-12-02T07:00:55.973Z'; - start = new Date( stop ) - 5000; - - // Incremental: - actual = datespace( start, stop, { - 'round': 'floor' - }); - - t.ok( actual[0] < actual[1] ); - - // Decremental: - actual = datespace( stop, start, { - 'round': 'round' - }); - - t.ok( actual[0] > actual[1] ); - t.end(); -}); - -tape( 'the function creates a linearly spaced array of dates', function test( t ) { - var expected; - var actual; - var start; - var stop; - var i; - - stop = '2014-12-02T07:00:55.973Z'; - start = new Date( stop ) - 5000; - - actual = datespace( start, stop, 6 ); - - for ( i = 0; i < actual.length; i++ ) { - actual[ i ] = actual[ i ].getTime(); - } - - expected = [ - 1417503650973, - 1417503651973, - 1417503652973, - 1417503653973, - 1417503654973, - 1417503655973 - ]; - - t.deepEqual( actual, expected ); - t.end(); -}); - -tape( 'the function accepts Unix timestamps', function test( t ) { - var expected; - var actual; - var start; - var stop; - var i; - - stop = '2014-12-02T07:00:55.973Z'; - stop = new Date( stop ).getTime(); - stop = floor( stop / 1000 ); - start = stop - 5; - - actual = datespace( start, stop, 6 ); - - for ( i = 0; i < actual.length; i++ ) { - actual[ i ] = actual[ i ].getTime(); - } - - expected = [ - 1417503650000, - 1417503651000, - 1417503652000, - 1417503653000, - 1417503654000, - 1417503655000 - ]; - - t.deepEqual( actual, expected ); - t.end(); -}); - -tape( 'the function ceils date values', function test( t ) { - var expected; - var actual; - var start; - var stop; - var i; - - stop = '2014-12-02T07:00:55.973Z'; - start = new Date( stop ) - 5; - - actual = datespace( start, stop, 11, { - 'round': 'ceil' - }); - - for ( i = 0; i < actual.length; i++ ) { - actual[ i ] = actual[ i ].getTime(); - } - - expected = [ - 1417503655968, - 1417503655969, - 1417503655969, - 1417503655970, - 1417503655970, - 1417503655971, - 1417503655971, - 1417503655972, - 1417503655972, - 1417503655973, - 1417503655973 - ]; - - t.deepEqual( actual, expected ); - t.end(); -}); - -tape( 'the function floors date values', function test( t ) { - var expected; - var actual; - var start; - var stop; - var i; - - stop = '2014-12-02T07:00:55.973Z'; - start = new Date( stop ) - 5; - - actual = datespace( start, stop, 11, { - 'round': 'floor' - }); - - for ( i = 0; i < actual.length; i++ ) { - actual[ i ] = actual[ i ].getTime(); - } - - expected = [ - 1417503655968, - 1417503655968, - 1417503655969, - 1417503655969, - 1417503655970, - 1417503655970, - 1417503655971, - 1417503655971, - 1417503655972, - 1417503655972, - 1417503655973 - ]; - - t.deepEqual( actual, expected ); - t.end(); -}); - -tape( 'the function rounds date values', function test( t ) { - var expected; - var actual; - var start; - var stop; - var i; - - stop = '2014-12-02T07:00:55.973Z'; - start = new Date( stop ) - 5; - - actual = datespace( start, stop, 11, { - 'round': 'round' - }); - - for ( i = 0; i < actual.length; i++ ) { - actual[ i ] = actual[ i ].getTime(); - } - - expected = [ - 1417503655968, - 1417503655969, - 1417503655969, - 1417503655970, - 1417503655970, - 1417503655971, - 1417503655971, - 1417503655972, - 1417503655972, - 1417503655973, - 1417503655973 - ]; - - t.deepEqual( actual, expected ); - t.end(); -}); diff --git a/defaults/README.md b/defaults/README.md deleted file mode 100644 index 2c55e0fd4..000000000 --- a/defaults/README.md +++ /dev/null @@ -1,154 +0,0 @@ - - -# defaults - -> Default array settings. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var defaults = require( '@stdlib/array/defaults' ); -``` - -#### defaults() - -Returns default array settings. - -```javascript -var out = defaults(); -// returns {...} -``` - -The returned object has the following properties: - -- **dtypes**: default data types. - - - **default**: default data type. - - **numeric**: default numeric data type. - - **real**: default real-valued data type. - - **floating_point**: default floating-point data type. - - **real_floating_point**: default real-valued floating-point data type. - - **complex_floating_point**: default complex-valued floating-point data type. - - **integer**: default integer data type. - - **signed_integer**: default signed integer data type. - - **unsigned_integer**: default unsigned integer data type. - - **boolean**: default boolean data type. - - **index**: default index data type. - - **integer_index**: default integer index data type. - - **boolean_index**: default boolean index data type. - - **mask_index**: default mask index data type. - -#### defaults.get( name ) - -Returns the setting value for a provided setting `name`. - -```javascript -var v = defaults.get( 'dtypes.floating_point' ); -// returns -``` - -The setting `name` corresponds to a flattened object path. For example, the setting name `'dtypes.default'` maps to the nested path `o.dtypes.default` as found in the object returned by `defaults()`. - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var empty = require( '@stdlib/array/empty' ); -var dtype = require( '@stdlib/array/dtype' ); -var defaults = require( '@stdlib/array/defaults' ); - -var o = defaults(); - -var x = empty( 10, o.dtypes.default ); -console.log( dtype( x ) ); - -x = empty( 10, o.dtypes.floating_point ); -console.log( dtype( x ) ); - -x = empty( 10, o.dtypes.real_floating_point ); -console.log( dtype( x ) ); - -x = empty( 10, o.dtypes.integer ); -console.log( dtype( x ) ); - -x = empty( 10, o.dtypes.signed_integer ); -console.log( dtype( x ) ); - -x = empty( 10, o.dtypes.unsigned_integer ); -console.log( dtype( x ) ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/defaults/benchmark/benchmark.js b/defaults/benchmark/benchmark.js deleted file mode 100644 index 7c3788dfd..000000000 --- a/defaults/benchmark/benchmark.js +++ /dev/null @@ -1,73 +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 bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var defaults = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = defaults(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( out.dtypes.default !== 'float64' ) { - b.fail( 'unexpected error' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'dtypes.default', - 'dtypes.real', - 'dtypes.integer' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = defaults.get( values[ i%values.length ] ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/defaults/docs/repl.txt b/defaults/docs/repl.txt deleted file mode 100644 index 2c730e1ee..000000000 --- a/defaults/docs/repl.txt +++ /dev/null @@ -1,81 +0,0 @@ - -{{alias}}() - Returns default array settings. - - Returns - ------- - out: Object - Default settings. - - out.dtypes: Object - Default data types. - - out.dtypes.default: string - Default data type. - - out.dtypes.numeric: string - Default numeric data type. - - out.dtypes.real: string - Default real-valued data type. - - out.dtypes.floating_point: string - Default floating-point data type. - - out.dtypes.real_floating_point: string - Default real-valued floating-point data type. - - out.dtypes.complex_floating_point: string - Default complex-valued floating-point data type. - - out.dtypes.integer: string - Default integer data type. - - out.dtypes.signed_integer: string - Default signed integer data type. - - out.dtypes.unsigned_integer: string - Default unsigned integer data type. - - out.dtypes.boolean: string - Default boolean data type. - - out.dtypes.index: string - Default index data type. - - out.dtypes.integer_index: string - Default integer index data type. - - out.dtypes.boolean_index: string - Default boolean index data type. - - out.dtypes.mask_index: string - Default mask index data type. - - Examples - -------- - > var out = {{alias}}() - {...} - - -{{alias}}.get( name ) - Returns a default setting. - - Parameters - ---------- - name: string - Setting name. - - Returns - ------- - out: any - Setting value. - - Examples - -------- - > var v = {{alias}}.get( 'dtypes.default' ) - - - See Also - -------- - diff --git a/defaults/docs/types/index.d.ts b/defaults/docs/types/index.d.ts deleted file mode 100644 index d5bcc46e0..000000000 --- a/defaults/docs/types/index.d.ts +++ /dev/null @@ -1,148 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Interface describing default data types. -*/ -interface DataTypes { - /** - * Default data type. - */ - default: 'float64'; - - /** - * Default numeric data type. - */ - numeric: 'float64'; - - /** - * Default real-valued data type. - */ - real: 'float64'; - - /** - * Default floating-point data type. - */ - floating_point: 'float64'; - - /** - * Default real-valued floating-point data type. - */ - real_floating_point: 'float64'; - - /** - * Default complex-valued floating-point data type. - */ - complex_floating_point: 'complex128'; - - /** - * Default integer data type. - */ - integer: 'int32'; - - /** - * Default signed integer data type. - */ - signed_integer: 'int32'; - - /** - * Default unsigned integer data type. - */ - unsigned_integer: 'uint32'; - - /** - * Default boolean data type. - */ - boolean: 'bool'; - - /** - * Default index data type. - */ - index: 'int32'; - - /** - * Default integer index data type. - */ - integer_index: 'int32'; - - /** - * Default boolean index data type. - */ - boolean_index: 'bool'; - - /** - * Default mask index data type. - */ - mask_index: 'uint8'; -} - -/** -* Interface describing default settings. -*/ -interface Defaults { - /** - * Default data types. - */ - dtypes: DataTypes; -} - -/** -* Interface for returning default settings. -*/ -interface DefaultsFunction { - /** - * Returns default settings. - * - * @returns default settings - * - * @example - * var o = defaults(); - * // returns {...} - */ - (): Defaults; - - /** - * Returns a default setting. - * - * @param name - setting name - * @returns setting value or null - * - * @example - * var v = defaults.get( 'dtypes.default' ); - * // returns - */ - get( name: string ): any; -} - -/** -* Returns default ndarray settings. -* -* @returns default settings -* -* @example -* var o = defaults(); -* // returns {...} -*/ -declare var defaults: DefaultsFunction; - - -// EXPORTS // - -export = defaults; diff --git a/defaults/docs/types/test.ts b/defaults/docs/types/test.ts deleted file mode 100644 index 79a0edbcd..000000000 --- a/defaults/docs/types/test.ts +++ /dev/null @@ -1,54 +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. -*/ - -import defaults = require( './index' ); - - -// TESTS // - -// The function returns an object... -{ - defaults(); // $ExpectType Defaults -} - -// The compiler throws an error if the function is provided any arguments... -{ - defaults( 9 ); // $ExpectError -} - -// Attached to the function is a `get` method for returning a default setting... -{ - defaults.get( 'dtypes.default' ); // $ExpectType any -} - -// The compiler throws an error if the method is not provided a string... -{ - defaults.get( 5 ); // $ExpectError - defaults.get( true ); // $ExpectError - defaults.get( false ); // $ExpectError - defaults.get( null ); // $ExpectError - defaults.get( [] ); // $ExpectError - defaults.get( {} ); // $ExpectError - defaults.get( ( x: number ) => x ); // $ExpectError -} - -// The compiler throws an error if the method is provided an unsupported number of arguments... -{ - defaults.get(); // $ExpectError - defaults.get( 'foo', 5 ); // $ExpectError -} diff --git a/defaults/examples/index.js b/defaults/examples/index.js deleted file mode 100644 index ebe00a447..000000000 --- a/defaults/examples/index.js +++ /dev/null @@ -1,43 +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'; - -var empty = require( './../../empty' ); -var dtype = require( './../../dtype' ); -var defaults = require( './../lib' ); - -var o = defaults(); - -var x = empty( 10, o.dtypes.default ); -console.log( dtype( x ) ); - -x = empty( 10, o.dtypes.floating_point ); -console.log( dtype( x ) ); - -x = empty( 10, o.dtypes.real_floating_point ); -console.log( dtype( x ) ); - -x = empty( 10, o.dtypes.integer ); -console.log( dtype( x ) ); - -x = empty( 10, o.dtypes.signed_integer ); -console.log( dtype( x ) ); - -x = empty( 10, o.dtypes.unsigned_integer ); -console.log( dtype( x ) ); diff --git a/defaults/lib/get.js b/defaults/lib/get.js deleted file mode 100644 index 8c3023c82..000000000 --- a/defaults/lib/get.js +++ /dev/null @@ -1,67 +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. -*/ - -'use strict'; - -// MODULES // - -var defaults = require( './main.js' ); - - -// VARIABLES // - -var DEFAULTS = defaults(); -var HASH = { - 'dtypes.default': DEFAULTS.dtypes.default, - 'dtypes.numeric': DEFAULTS.dtypes.numeric, - 'dtypes.real': DEFAULTS.dtypes.real, - 'dtypes.floating_point': DEFAULTS.dtypes.floating_point, - 'dtypes.real_floating_point': DEFAULTS.dtypes.real_floating_point, - 'dtypes.complex_floating_point': DEFAULTS.dtypes.complex_floating_point, - 'dtypes.integer': DEFAULTS.dtypes.integer, - 'dtypes.signed_integer': DEFAULTS.dtypes.signed_integer, - 'dtypes.unsigned_integer': DEFAULTS.dtypes.unsigned_integer, - 'dtypes.boolean': DEFAULTS.dtypes.boolean, - 'dtypes.index': DEFAULTS.dtypes.index, - 'dtypes.integer_index': DEFAULTS.dtypes.integer_index, - 'dtypes.boolean_index': DEFAULTS.dtypes.boolean_index, - 'dtypes.mask_index': DEFAULTS.dtypes.mask_index -}; - - -// MAIN // - -/** -* Returns a default array setting. -* -* @param {string} name - setting name -* @returns {*} default setting or null -* -* @example -* var v = get( 'dtypes.default' ); -* // returns -*/ -function get( name ) { - var v = HASH[ name ]; - return ( v === void 0 ) ? null : v; -} - - -// EXPORTS // - -module.exports = get; diff --git a/defaults/lib/index.js b/defaults/lib/index.js deleted file mode 100644 index a48f1d1a2..000000000 --- a/defaults/lib/index.js +++ /dev/null @@ -1,47 +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'; - -/** -* Return default array settings. -* -* @module @stdlib/array/defaults -* -* @example -* var defaults = require( '@stdlib/array/defaults' ); -* -* var o = defaults(); -* // returns {...} -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var get = require( './get.js' ); - - -// MAIN // - -setReadOnly( main, 'get', get ); - - -// EXPORTS // - -module.exports = main; diff --git a/defaults/lib/main.js b/defaults/lib/main.js deleted file mode 100644 index 5e4a58893..000000000 --- a/defaults/lib/main.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns default array settings. -* -* @returns {Object} defaults -* -* @example -* var o = defaults(); -* // returns {...} -*/ -function defaults() { - return { - // Data types: - 'dtypes': { - 'default': 'float64', - 'numeric': 'float64', - 'real': 'float64', - 'floating_point': 'float64', - 'real_floating_point': 'float64', - 'complex_floating_point': 'complex128', - 'integer': 'int32', - 'signed_integer': 'int32', - 'unsigned_integer': 'uint32', - 'boolean': 'bool', - 'index': 'int32', - 'integer_index': 'int32', - 'boolean_index': 'bool', - 'mask_index': 'uint8' - } - }; -} - - -// EXPORTS // - -module.exports = defaults; diff --git a/defaults/package.json b/defaults/package.json deleted file mode 100644 index 7ff70a0ed..000000000 --- a/defaults/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/defaults", - "version": "0.0.0", - "description": "Default array settings.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "utilities", - "utility", - "utils", - "util", - "defaults", - "settings" - ], - "__stdlib__": {} -} diff --git a/defaults/test/test.get.js b/defaults/test/test.get.js deleted file mode 100644 index 72666edb0..000000000 --- a/defaults/test/test.get.js +++ /dev/null @@ -1,84 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var defaults = require( './../lib/main.js' ); -var get = require( './../lib/get.js' ); - - -// VARIABLES // - -var DEFAULTS = defaults(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof get, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided a recognized setting, the function returns a default value', function test( t ) { - var expected; - var actual; - var values; - var i; - - values = [ - 'dtypes.default', - 'dtypes.numeric', - 'dtypes.real', - 'dtypes.floating_point', - 'dtypes.real_floating_point', - 'dtypes.complex_floating_point', - 'dtypes.boolean', - 'dtypes.integer', - 'dtypes.signed_integer', - 'dtypes.unsigned_integer', - 'dtypes.index', - 'dtypes.integer_index', - 'dtypes.boolean_index', - 'dtypes.mask_index' - ]; - expected = [ - DEFAULTS.dtypes.default, - DEFAULTS.dtypes.numeric, - DEFAULTS.dtypes.real, - DEFAULTS.dtypes.floating_point, - DEFAULTS.dtypes.real_floating_point, - DEFAULTS.dtypes.complex_floating_point, - DEFAULTS.dtypes.boolean, - DEFAULTS.dtypes.integer, - DEFAULTS.dtypes.signed_integer, - DEFAULTS.dtypes.unsigned_integer, - DEFAULTS.dtypes.index, - DEFAULTS.dtypes.integer_index, - DEFAULTS.dtypes.boolean_index, - DEFAULTS.dtypes.mask_index - ]; - for ( i = 0; i < values.length; i++ ) { - actual = get( values[ i ] ); - t.strictEqual( actual, expected[ i ], 'returns expected value. actual: '+actual+'. expected: '+expected[ i ]+'.' ); - } - t.end(); -}); diff --git a/defaults/test/test.js b/defaults/test/test.js deleted file mode 100644 index 8428ac9c5..000000000 --- a/defaults/test/test.js +++ /dev/null @@ -1,40 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var defaults = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof defaults, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main function is a method to retrieve a setting', function test( t ) { - t.strictEqual( hasOwnProp( defaults, 'get' ), true, 'has property' ); - t.strictEqual( typeof defaults.get, 'function', 'returns expected value' ); - t.end(); -}); diff --git a/defaults/test/test.main.js b/defaults/test/test.main.js deleted file mode 100644 index 0ffe851f6..000000000 --- a/defaults/test/test.main.js +++ /dev/null @@ -1,85 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var defaults = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof defaults, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns default settings', function test( t ) { - var o = defaults(); - - t.strictEqual( hasOwnProp( o, 'dtypes' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes, 'object', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'default' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.default, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'numeric' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.numeric, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'real' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.real, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'floating_point' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.floating_point, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'real_floating_point' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.real_floating_point, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'complex_floating_point' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.complex_floating_point, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'boolean' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.boolean, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'integer' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.integer, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'signed_integer' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.signed_integer, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'unsigned_integer' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.unsigned_integer, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'index' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.index, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'integer_index' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.integer_index, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'boolean_index' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.boolean_index, 'string', 'returns expected value' ); - - t.strictEqual( hasOwnProp( o.dtypes, 'mask_index' ), true, 'has property' ); - t.strictEqual( typeof o.dtypes.mask_index, 'string', 'returns expected value' ); - - t.end(); -}); diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 6511d75b6..000000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,2030 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable max-lines */ - -import base = require( './../../base' ); -import BooleanArray = require( './../../bool' ); -import ArrayBuffer = require( './../../buffer' ); -import byteOrders = require( './../../byte-orders' ); -import cartesianPower = require( './../../cartesian-power' ); -import cartesianProduct = require( './../../cartesian-product' ); -import cartesianSquare = require( './../../cartesian-square' ); -import Complex64Array = require( './../../complex64' ); -import Complex128Array = require( './../../complex128' ); -import convert = require( './../../convert' ); -import convertSame = require( './../../convert-same' ); -import ctors = require( './../../ctors' ); -import DataView = require( './../../dataview' ); -import datespace = require( './../../datespace' ); -import defaults = require( './../../defaults' ); -import dtype = require( './../../dtype' ); -import dtypes = require( './../../dtypes' ); -import empty = require( './../../empty' ); -import emptyLike = require( './../../empty-like' ); -import filled = require( './../../filled' ); -import filledBy = require( './../../filled-by' ); -import Float32Array = require( './../../float32' ); -import Float64Array = require( './../../float64' ); -import iterator2array = require( './../../from-iterator' ); -import scalar2array = require( './../../from-scalar' ); -import full = require( './../../full' ); -import fullLike = require( './../../full-like' ); -import incrspace = require( './../../incrspace' ); -import ArrayIndex = require( './../../index' ); -import Int8Array = require( './../../int8' ); -import Int16Array = require( './../../int16' ); -import Int32Array = require( './../../int32' ); -import linspace = require( './../../linspace' ); -import logspace = require( './../../logspace' ); -import minDataType = require( './../../min-dtype' ); -import mostlySafeCasts = require( './../../mostly-safe-casts' ); -import mskfilter = require( './../../mskfilter' ); -import mskput = require( './../../mskput' ); -import mskreject = require( './../../mskreject' ); -import nans = require( './../../nans' ); -import nansLike = require( './../../nans-like' ); -import nextDataType = require( './../../next-dtype' ); -import oneTo = require( './../../one-to' ); -import oneToLike = require( './../../one-to-like' ); -import ones = require( './../../ones' ); -import onesLike = require( './../../ones-like' ); -import place = require( './../../place' ); -import typedarraypool = require( './../../pool' ); -import promotionRules = require( './../../promotion-rules' ); -import put = require( './../../put' ); -import typedarrayReviver = require( './../../reviver' ); -import safeCasts = require( './../../safe-casts' ); -import sameKindCasts = require( './../../same-kind-casts' ); -import shape = require( './../../shape' ); -import SharedArrayBuffer = require( './../../shared-buffer' ); -import slice = require( './../../slice' ); -import take = require( './../../take' ); -import circarray2iterator = require( './../../to-circular-iterator' ); -import array2fancy = require( './../../to-fancy' ); -import array2iterator = require( './../../to-iterator' ); -import array2iteratorRight = require( './../../to-iterator-right' ); -import typedarray2json = require( './../../to-json' ); -import sparsearray2iterator = require( './../../to-sparse-iterator' ); -import sparsearray2iteratorRight = require( './../../to-sparse-iterator-right' ); -import stridedarray2iterator = require( './../../to-strided-iterator' ); -import arrayview2iterator = require( './../../to-view-iterator' ); -import arrayview2iteratorRight = require( './../../to-view-iterator-right' ); -import typedarray = require( './../../typed' ); -import complexarray = require( './../../typed-complex' ); -import complexarrayCtors = require( './../../typed-complex-ctors' ); -import complexarrayDataTypes = require( './../../typed-complex-dtypes' ); -import typedarrayCtors = require( './../../typed-ctors' ); -import typedarrayDataTypes = require( './../../typed-dtypes' ); -import floatarrayCtors = require( './../../typed-float-ctors' ); -import floatarrayDataTypes = require( './../../typed-float-dtypes' ); -import intarrayCtors = require( './../../typed-integer-ctors' ); -import intarrayDataTypes = require( './../../typed-integer-dtypes' ); -import realarray = require( './../../typed-real' ); -import realarrayCtors = require( './../../typed-real-ctors' ); -import realarrayDataTypes = require( './../../typed-real-dtypes' ); -import realarrayFloatCtors = require( './../../typed-real-float-ctors' ); -import realarrayFloatDataTypes = require( './../../typed-real-float-dtypes' ); -import intarraySignedCtors = require( './../../typed-signed-integer-ctors' ); -import intarraySignedDataTypes = require( './../../typed-signed-integer-dtypes' ); -import intarrayUnsignedCtors = require( './../../typed-unsigned-integer-ctors' ); -import intarrayUnsignedDataTypes = require( './../../typed-unsigned-integer-dtypes' ); -import Uint8Array = require( './../../uint8' ); -import Uint8ClampedArray = require( './../../uint8c' ); -import Uint16Array = require( './../../uint16' ); -import Uint32Array = require( './../../uint32' ); -import zeroTo = require( './../../zero-to' ); -import zeroToLike = require( './../../zero-to-like' ); -import zeros = require( './../../zeros' ); -import zerosLike = require( './../../zeros-like' ); -import constants = require( '@stdlib/constants/array' ); - -/** -* Interface describing the `array` namespace. -*/ -interface Namespace { - /** - * Base (i.e., lower-level) array utilities. - */ - base: typeof base; - - /** - * Boolean array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @returns boolean array - * - * @example - * var arr = new ns.BooleanArray(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new ns.BooleanArray( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new ns.BooleanArray( [ true, false ] ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new ns.BooleanArray( buf ); - * // returns - * - * var len = arr.length; - * // returns 16 - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new ns.BooleanArray( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 8 - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new ns.BooleanArray( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - BooleanArray: typeof BooleanArray; - - /** - * Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer. - */ - ArrayBuffer: typeof ArrayBuffer; - - /** - * Returns a list of byte orders. - * - * ## Notes - * - * - The output array contains the following orders: - * - * - little-endian: bytes are ordered from least-to-most significant byte. - * - big-endian: bytes are ordered from most-to-least significant byte. - * - * @returns list of byte orders - * - * @example - * var list = ns.byteOrders(); - * // e.g., returns [ 'little-endian', 'big-endian' ] - */ - byteOrders: typeof byteOrders; - - /** - * Returns the Cartesian power. - * - * ## Notes - * - * - If provided an empty array, the function returns an empty array. - * - If `n` is less than or equal to zero, the function returns an empty array. - * - * @param x - input array - * @param n - power - * @returns Cartesian product - * - * @example - * var x = [ 1, 2 ]; - * - * var out = ns.cartesianPower( x, 2 ); - * // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] - */ - cartesianPower: typeof cartesianPower; - - /** - * Returns the Cartesian product. - * - * ## Notes - * - * - If provided one or more empty arrays, the function returns an empty array. - * - * @param x1 - first input array - * @param x2 - second input array - * @returns Cartesian product - * - * @example - * var x1 = [ 1, 2, 3 ]; - * var x2 = [ 4, 5 ]; - * - * var out = ns.cartesianProduct( x1, x2 ); - * // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ] - */ - cartesianProduct: typeof cartesianProduct; - - /** - * Returns the Cartesian square. - * - * ## Notes - * - * - If provided an empty array, the function returns an empty array. - * - * @param x - input array - * @returns Cartesian product - * - * @example - * var x = [ 1, 2 ]; - * - * var out = ns.cartesianSquare( x ); - * // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ] - */ - cartesianSquare: typeof cartesianSquare; - - /** - * 64-bit complex number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `8` - * @throws array-like object and typed array input arguments must have a length which is a multiple of two - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `8` - * @throws view length must be a positive multiple of `8` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @throws an iterator must return either a two element array containing real and imaginary components or a complex number - * @returns complex number array - * - * @example - * var arr = new ns.Complex64Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new ns.Complex64Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new ns.Complex64Array( [ 1.0, -1.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new ns.Complex64Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new ns.Complex64Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new ns.Complex64Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - Complex64Array: typeof Complex64Array; - - /** - * 128-bit complex number array constructor. - * - * @param arg - length, typed array, array-like object, or buffer - * @param byteOffset - byte offset (default: 0) - * @param length - view length - * @throws ArrayBuffer byte length must be a multiple of `8` - * @throws array-like object and typed array input arguments must have a length which is a multiple of two - * @throws if provided only a single argument, must provide a valid argument - * @throws byte offset must be a nonnegative integer - * @throws byte offset must be a multiple of `8` - * @throws view length must be a positive multiple of `8` - * @throws must provide sufficient memory to accommodate byte offset and view length requirements - * @throws an iterator must return either a two element array containing real and imaginary components or a complex number - * @returns complex number array - * - * @example - * var arr = new ns.Complex128Array(); - * // returns - * - * var len = arr.length; - * // returns 0 - * - * @example - * var arr = new ns.Complex128Array( 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var arr = new ns.Complex128Array( [ 1.0, -1.0 ] ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new ns.Complex128Array( buf ); - * // returns - * - * var len = arr.length; - * // returns 2 - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 16 ); - * var arr = new ns.Complex128Array( buf, 8 ); - * // returns - * - * var len = arr.length; - * // returns 1 - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = new ns.Complex128Array( buf, 8, 2 ); - * // returns - * - * var len = arr.length; - * // returns 2 - */ - Complex128Array: typeof Complex128Array; - - /** - * Converts an array to an array of a different data type. - * - * @param x - array to convert - * @param dtype - output data type - * @returns output array - * - * @example - * var arr = [ 1.0, 2.0, 3.0, 4.0 ]; - * var out = ns.convert( arr, 'float64' ); - * // returns [ 1.0, 2.0, 3.0, 4.0 ] - */ - convert: typeof convert; - - /** - * Converts an array to the same data type as a second input array. - * - * @param x - array to convert - * @param y - array having the desired output data type - * @returns output array - * - * @example - * var Float64Array = require( './../../float64' ); - * - * var x = [ 1.0, 2.0, 3.0, 4.0 ]; - * var y = new Float64Array( 0 ); - * - * var out = ns.convertSame( x, y ); - * // returns [ 1.0, 2.0, 3.0, 4.0 ] - */ - convertSame: typeof convertSame; - - /** - * Returns an array constructor. - * - * @param dtype - data type - * @returns constructor or null - * - * @example - * var ctor = ns.ctors( 'float64' ); - * // returns - * - * @example - * var ctor = ns.ctors( 'float' ); - * // returns null - */ - ctors: typeof ctors; - - /** - * Constructor which returns a data view representing a provided array buffer. - */ - DataView: typeof DataView; - - /** - * Generates an array of linearly spaced dates. - * - * @param start - start time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string - * @param stop - stop time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string - * @param length - output array length (default: 100) - * @param options - function options - * @param options.round - specifies how sub-millisecond times should be rounded: [ 'floor', 'ceil', 'round' ] (default: 'floor' ) - * @throws length argument must a positive integer - * @throws must provide valid options - * @returns array of dates - * - * @example - * var stop = '2014-12-02T07:00:54.973Z'; - * var start = new Date( stop ) - 60000; - * - * var arr = ns.datespace( start, stop, 6 ); - * // returns [...] - * - * @example - * // Equivalent of Math.ceil(): - * var arr = ns.datespace( 1417503655000, 1417503655001, 3, { 'round': 'ceil' } ); - * // returns [...] - * - * // Equivalent of Math.round(): - * var arr = ns.datespace( 1417503655000, 1417503655001, 3, { 'round': 'round' } ); - * // returns [...] - */ - datespace: typeof datespace; - - /** - * Returns default ndarray settings. - * - * @returns default settings - * - * @example - * var o = ns.defaults(); - * // returns {...} - */ - defaults: typeof defaults; - - /** - * Returns the data type of an array. - * - * ## Notes - * - * - If provided an argument having an unknown or unsupported type, the function returns `null`. - * - * @param value - input value - * @returns data type - * - * @example - * var dt = ns.dtype( [ 1, 2, 3 ] ); - * // returns 'generic' - * - * var dt = ns.dtype( 'beep' ); - * // returns null - */ - dtype: typeof dtype; - - /** - * Returns a list of array data types. - * - * @param kind - data type kind - * @returns list of array data types - * - * @example - * var list = ns.dtypes(); - * // e.g., returns [ 'float32', 'float64', ... ] - * - * @example - * var list = ns.dtypes( 'floating_point' ); - * // returns [...] - */ - dtypes: typeof dtypes; - - /** - * Creates an uninitialized array having a specified length. - * - * ## Notes - * - * - In browser environments, the function always returns zero-filled arrays. - * - If `dtype` is `'generic'`, the function always returns a zero-filled array. - * - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. - * - * @param length - array length - * @param dtype - data type (default: 'float64') - * @returns empty array - * - * @example - * var arr = ns.empty( 2 ); - * // returns - * - * @example - * var arr = ns.empty( 2, 'float32' ); - * // returns - */ - empty: typeof empty; - - /** - * Creates an uninitialized array having the same length as a provided input array. - * - * ## Notes - * - * - In browser environments, the function always returns zero-filled arrays. - * - If `dtype` is `'generic'`, the function always returns a zero-filled array. - * - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. - * - * @param x - input array from which to derive the output array length - * @param dtype - data type - * @returns empty array - * - * @example - * var zeros = require( './../../zeros' ); - * - * var x = zeros( 2, 'float64' ); - * // returns [ 0.0, 0.0 ] - * - * var arr = ns.emptyLike( x, 'float32' ); - * // returns - */ - emptyLike: typeof emptyLike; - - /** - * Returns a filled typed array view of an `ArrayBuffer`. - * - * ## Notes - * - * - Creating a generic array from an `ArrayBuffer` is **not** supported. - * - * @param value - fill value - * @param buffer - `ArrayBuffer` - * @param dtype - data type (default: 'float64') - * @returns filled array - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = ns.filled( 1.0, buf ); - * // returns [ 1.0, 1.0, 1.0, 1.0 ] - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = ns.filled( 1.0, buf, 'float32' ); - * // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] - */ - filled: typeof filled; - - /** - * Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. - * - * ## Notes - * - * - Creating a generic array from an `ArrayBuffer` is **not** supported. - * - * @param buffer - `ArrayBuffer` - * @param dtype - data type - * @param clbk - callback function - * @param thisArg - callback function execution context - * @returns filled array - * - * @example - * var constantFunction = require( '@stdlib/utils/constant-function' ); - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = ns.filledBy( buf, 'float64', constantFunction( 1.0 ) ); - * // returns [ 1.0, 1.0, 1.0, 1.0 ] - */ - filledBy: typeof filledBy; - - /** - * Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order. - */ - Float32Array: typeof Float32Array; - - /** - * Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in the platform byte order. - */ - Float64Array: typeof Float64Array; - - /** - * Fills an array from an iterator. - * - * @param iterator - source iterator - * @param out - output array - * @param mapFcn - function to invoke for each iterated value - * @param thisArg - execution context - * @returns output array - * - * @example - * var Float64Array = require( './../../float64' ); - * var randu = require( '@stdlib/random/iter/randu' ); - * - * function scale( v ) { - * return v * 2.0; - * } - * - * var iter = randu({ - * 'iter': 10 - * }); - * - * var out = new Float64Array( 10 ); - * var arr = ns.iterator2array( iter, out, scale ); - * // returns - */ - iterator2array: typeof iterator2array; - - /** - * Returns a single-element array containing a provided scalar value. - * - * ## Notes - * - * - If a `dtype` argument is not provided and `value` - * - * - is a number, the default data type is the default real-valued floating-point data type. - * - is a boolean, the default data type is the default boolean data type. - * - is a complex number object of a known complex data type, the data type is the same as the provided value. - * - is a complex number object of an unknown complex data type, the default data type is the default complex-valued floating-point data type. - * - is any other value type, the default data type is `'generic'`. - * - * @param value - scalar value - * @param dtype - output array data type - * @returns output array - * - * @example - * var x = ns.scalar2array( 1.0, 'generic' ); - * // returns [ 1.0 ] - */ - scalar2array: typeof scalar2array; - - /** - * Creates a filled array having a specified length. - * - * @param length - array length - * @param value - fill value - * @param dtype - data type (default: 'float64') - * @returns filled array - * - * @example - * var arr = ns.full( 2, 1.0 ); - * // returns [ 1.0, 1.0 ] - * - * @example - * var arr = ns.full( 2, 1.0, 'float32' ); - * // returns [ 1.0, 1.0 ] - */ - full: typeof full; - - /** - * Creates a filled array having the same length and data type as a provided input array. - * - * @param x - input array from which to derive the output array length - * @param value - fill value - * @param dtype - data type - * @returns filled array - * - * @example - * var zeros = require( './../../zeros' ); - * - * var x = zeros( 2, 'float64' ); - * // returns [ 0.0, 0.0 ] - * - * var y = ns.fullLike( x, 1.0 ); - * // returns [ 1.0, 1.0 ] - * - * @example - * var zeros = require( './../../zeros' ); - * - * var x = zeros( 2, 'float64' ); - * // returns [ 0.0, 0.0 ] - * - * var y = ns.fullLike( x, 1.0, 'float32' ); - * // returns [ 1.0, 1.0 ] - */ - fullLike: typeof fullLike; - - /** - * Generates a linearly spaced numeric array using a provided increment. - * - * @param x1 - first array value - * @param x2 - array element bound - * @param increment - increment (default: 1) - * @throws length of created array must be less than `4294967295` (`2**32 - 1`) - * @returns linearly spaced numeric array - * - * @example - * var arr = ns.incrspace( 0, 11, 2 ); - * // returns [ 0, 2, 4, 6, 8, 10 ] - */ - incrspace: typeof incrspace; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var Uint8Array = require( './../../uint8' ); - * - * var x = new Uint8Array( [ 1, 0, 1, 0 ] ); - * - * var idx = new ns.ArrayIndex( x ); - * // returns - */ - ArrayIndex: typeof ArrayIndex; - - /** - * Typed array constructor which returns a typed array representing an array of twos-complement 8-bit signed integers in the platform byte order. - */ - Int8Array: typeof Int8Array; - - /** - * Typed array constructor which returns a typed array representing an array of twos-complement 16-bit signed integers in the platform byte order. - */ - Int16Array: typeof Int16Array; - - /** - * Typed array constructor which returns a typed array representing an array of twos-complement 32-bit signed integers in the platform byte order. - */ - Int32Array: typeof Int32Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var arr = ns.linspace( 0.0, 100.0, 6 ); - * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - * - * @example - * var Float32Array = require( './../../float32' ); - * - * var arr = new Float32Array( 6 ); - * var out = ns.linspace.assign( 0.0, 100.0, arr ); - * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - * - * var bool = ( arr === out ); - * // returns true - */ - linspace: typeof linspace; - - /** - * Generates a logarithmically spaced numeric array. - * - * @param a - exponent of start value - * @param b - exponent of end value - * @param len - length of output array (default: 10) - * @throws third argument must be a nonnegative integer - * @returns logarithmically spaced numeric array - * - * @example - * var arr = ns.logspace( 0, 2, 6 ); - * // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] - */ - logspace: typeof logspace; - - /** - * Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value. - * - * ## Notes - * - * - The function does *not* provide precision guarantees for non-integer-valued numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals. - * - * @param value - scalar value - * @returns array data type - * - * @example - * var dt = ns.minDataType( 'beep' ); - * // returns 'generic' - */ - minDataType: typeof minDataType; - - /** - * Returns a list of array data types to which a provided array data type can be safely cast and, for floating-point data types, can be downcast. - * - * ## Notes - * - * - If not provided an array data type, the function returns a casting table. - * - If provided an unrecognized array data type, the function returns `null`. - * - * @param dtype - array data type value - * @returns list of array data types or null - * - * @example - * var list = ns.mostlySafeCasts( 'float32' ); - * // returns [...] - */ - mostlySafeCasts: typeof mostlySafeCasts; - - /** - * Returns a new array by applying a mask to a provided input array. - * - * @param x - input array - * @param mask - mask array - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = ns.mskfilter( x, [ 0, 1, 0, 1 ] ); - * // returns [ 2, 4 ] - */ - mskfilter: typeof mskfilter; - - /** - * Replaces elements of an array with provided values according to a provided mask array. - * - * @param x - input array - * @param mask - mask array - * @param values - values to set - * @param options - function options - * @returns input array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var mask = [ 1, 0, 0, 1 ]; - * var values = [ 20, 30 ]; - * - * var out = ns.mskput( x, mask, values ); - * // returns [ 1, 20, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var out = ns.mskput( x, [ 1, 0, 0, 1 ], [ 30 ] ); - * // returns [ 1, 30, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - */ - mskput: typeof mskput; - - /** - * Returns a new array by applying a mask to a provided input array. - * - * @param x - input array - * @param mask - mask array - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = ns.mskreject( x, [ 0, 1, 0, 1 ] ); - * // returns [ 1, 3 ] - */ - mskreject: typeof mskreject; - - /** - * Creates an array filled with NaNs and having a specified length. - * - * The function recognizes the following data types: - * - * - `float64`: double-precision floating-point numbers (IEEE 754) - * - `float32`: single-precision floating-point numbers (IEEE 754) - * - `complex128`: double-precision complex floating-point numbers - * - `complex64`: single-precision complex floating-point numbers - * - `generic`: generic JavaScript values - * - * @param length - array length - * @param dtype - data type (default: 'float64') - * @returns filled array - * - * @example - * var arr = ns.nans( 2 ); - * // returns [ NaN, NaN ] - * - * @example - * var arr = ns.nans( 2, 'float32' ); - * // returns [ NaN, NaN ] - */ - nans: typeof nans; - - /** - * Creates an array filled with NaNs and having the same length and data type as a provided input array. - * - * The function supports the following data types: - * - * - `float64`: double-precision floating-point numbers (IEEE 754) - * - `float32`: single-precision floating-point numbers (IEEE 754) - * - `complex128`: double-precision complex floating-point numbers - * - `complex64`: single-precision complex floating-point numbers - * - `generic`: generic JavaScript values - * - * @param x - input array from which to derive the output array length - * @param dtype - data type - * @returns filled array - * - * @example - * var zeros = require( './../../zeros' ); - * - * var x = zeros( 2, 'float64' ); - * // returns [ 0.0, 0.0 ] - * - * var y = ns.nansLike( x ); - * // returns [ NaN, NaN ] - * - * @example - * var zeros = require( './../../zeros' ); - * - * var x = zeros( 2, 'float64' ); - * // returns [ 0.0, 0.0 ] - * - * var y = ns.nansLike( x, 'float32' ); - * // returns [ NaN, NaN ] - */ - nansLike: typeof nansLike; - - /** - * Returns the next larger array data type of the same kind. - * - * ## Notes - * - * - If not provided a data type, the function returns a table. - * - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. - * - If provided an unrecognized data type, the function returns `null`. - * - * @param dtype - array data type - * @returns next larger data type(s) or null - * - * @example - * var table = ns.nextDataType(); - * // returns {...} - * - * @example - * var dt = ns.nextDataType( 'float32' ); - * // returns 'float64' - */ - nextDataType: typeof nextDataType; - - /** - * Generates a linearly spaced numeric array whose elements increment by 1 starting from one. - * - * @param n - number of elements - * @param dtype - data type (default: 'float64') - * @returns linearly spaced numeric array - * - * @example - * var arr = ns.oneTo( 2 ); - * // returns [ 1.0, 2.0 ] - * - * @example - * var arr = ns.oneTo( 2, 'float32' ); - * // returns [ 1.0, 2.0 ] - */ - oneTo: typeof oneTo; - - /** - * Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. - * - * @param x - input array from which to derive the output array length - * @param dtype - data type - * @returns linearly spaced numeric array - * - * @example - * var zeros = require( './../../zeros' ); - * - * var x = zeros( 2, 'float32' ); - * // returns [ 0.0, 0.0 ] - * - * var y = ns.oneToLike( x ); - * // returns [ 1.0, 2.0 ] - */ - oneToLike: typeof oneToLike; - - /** - * Creates an array filled with ones and having a specified length. - * - * The function recognizes the following data types: - * - * - `float64`: double-precision floating-point numbers (IEEE 754) - * - `float32`: single-precision floating-point numbers (IEEE 754) - * - `complex128`: double-precision complex floating-point numbers - * - `complex64`: single-precision complex floating-point numbers - * - `int32`: 32-bit two's complement signed integers - * - `uint32`: 32-bit unsigned integers - * - `int16`: 16-bit two's complement signed integers - * - `uint16`: 16-bit unsigned integers - * - `int8`: 8-bit two's complement signed integers - * - `uint8`: 8-bit unsigned integers - * - `uint8c`: 8-bit unsigned integers clamped to `0-255` - * - `generic`: generic JavaScript values - * - * @param length - array length - * @param dtype - data type (default: 'float64') - * @returns filled array - * - * @example - * var arr = ns.ones( 2 ); - * // returns [ 1.0, 1.0 ] - * - * @example - * var arr = ns.ones( 2, 'float32' ); - * // returns [ 1.0, 1.0 ] - */ - ones: typeof ones; - - /** - * Creates an array filled with ones and having the same length as a provided input array. - * - * The function supports the following data types: - * - * - `float64`: double-precision floating-point numbers (IEEE 754) - * - `float32`: single-precision floating-point numbers (IEEE 754) - * - `complex128`: double-precision complex floating-point numbers - * - `complex64`: single-precision complex floating-point numbers - * - `int32`: 32-bit two's complement signed integers - * - `uint32`: 32-bit unsigned integers - * - `int16`: 16-bit two's complement signed integers - * - `uint16`: 16-bit unsigned integers - * - `int8`: 8-bit two's complement signed integers - * - `uint8`: 8-bit unsigned integers - * - `uint8c`: 8-bit unsigned integers clamped to `0-255` - * - `generic`: generic JavaScript values - * - * @param x - input array from which to derive the output array length - * @param dtype - data type - * @returns filled array - * - * @example - * var zeros = require( './../../zeros' ); - * - * var x = zeros( 2, 'float64' ); - * // returns [ 0.0, 0.0 ] - * - * var y = ns.onesLike( x, 'float32' ); - * // returns [ 1.0, 1.0 ] - */ - onesLike: typeof onesLike; - - /** - * Replaces elements of an array with provided values according to a provided mask array. - * - * @param x - input array - * @param mask - mask array - * @param values - values to set - * @param options - function options - * @returns input array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var mask = [ 0, 1, 1, 0 ]; - * var values = [ 20, 30 ]; - * - * var out = ns.place( x, mask, values ); - * // returns [ 1, 20, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var out = ns.place( x, [ 0, 1, 1, 0 ], [ 30 ] ); - * // returns [ 1, 30, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - */ - place: typeof place; - - /** - * Returns an uninitialized typed array. - * - * ## Notes - * - * - Memory is **not** initialized. - * - Memory is lazily allocated. - * - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory). - * - * @param arg - an array length or an array-like object - * @param dtype - data type (default: 'float64') - * @returns typed array or null - * - * @example - * // Allocate an array of doubles: - * var arr = ns.typedarraypool( 5, 'float64' ); - * // e.g., returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - * - * arr[ 0 ] = 3.14; - * arr[ 1 ] = 3.14; - * - * // ... - * - * // Free the allocated memory to be used in a future allocation: - * ns.typedarraypool.free( arr ); - */ - typedarraypool: typeof typedarraypool; - - /** - * Returns a type promotion table displaying array data types with the smallest size and closest "kind" to which array data types can be safely cast. - * - * @returns promotion rule table - * - * @example - * var table = ns.promotionRules(); - * // returns {...} - */ - promotionRules: typeof promotionRules; - - /** - * Replaces specified elements of an array with provided values. - * - * @param x - input array - * @param indices - list of element indices - * @param values - values to set - * @param options - function options - * @returns input array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var indices = [ 1, 2 ]; - * var values = [ 20, 30 ]; - * - * var out = ns.put( x, indices, values ); - * // returns [ 1, 20, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var out = ns.put( x, [ 1, 2 ], [ 30 ] ); - * // returns [ 1, 30, 30, 4 ] - * - * var bool = ( out === x ); - * // returns true - */ - put: typeof put; - - /** - * Revives a JSON-serialized typed array. - * - * @param key - key - * @param value - value - * @returns value or typed array - * - * @example - * var parseJSON = require( '@stdlib/utils/parse-json' ); - * - * var str = '{"type":"Float64Array","data":[5,3]}'; - * - * var arr = parseJSON( str, ns.typedarrayReviver ); - * // returns [ 5.0, 3.0 ] - */ - typedarrayReviver: typeof typedarrayReviver; - - /** - * Returns a list of array data types to which a provided array data type can be safely cast. - * - * ## Notes - * - * - If not provided an array data type, the function returns a casting table. - * - If provided an unrecognized array data type, the function returns `null`. - * - * @param dtype - array data type - * @returns a casting table, a list of array data types, or null - * - * @example - * var table = ns.safeCasts(); - * // returns {...} - * - * @example - * var list = ns.safeCasts( 'float32' ); - * // returns [...] - * - * @example - * var list = ns.safeCasts( 'float' ); - * // returns null - */ - safeCasts: typeof safeCasts; - - /** - * Returns a list of array data types to which a provided array data type can be safely cast or cast within the same "kind". - * - * ## Notes - * - * - If not provided an array data type, the function returns a casting table. - * - If provided an unrecognized array data type, the function returns `null`. - * - * @param dtype - array data type - * @returns a table, a list of array data types, or null - * - * @example - * var table = ns.sameKindCasts(); - * // returns {...} - * - * @example - * var list = ns.sameKindCasts( 'float32' ); - * // returns [...] - * - * @example - * var list = ns.sameKindCasts( 'float' ); - * // returns null - */ - sameKindCasts: typeof sameKindCasts; - - /** - * Determines (nested) array dimensions. - * - * @param arr - array - * @returns array shape - * - * @example - * var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; - * - * var ns.shape = ns.shape( arr ); - * // returns [ 3, 3 ] - * - * @example - * var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ]; - * - * var ns.shape = ns.shape( arr ); - * // returns [ 3 ] - * - * @example - * var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], null ]; - * - * var ns.shape = ns.shape( arr ); - * // returns [ 3 ] - */ - shape: typeof shape; - - /** - * Constructor returning an object used to represent a generic, fixed-length raw binary data buffer which can be used to create views of shared memory. - */ - SharedArrayBuffer: typeof SharedArrayBuffer; - - /** - * Returns a shallow copy of a portion of an array. - * - * @param x - input array - * @param start - starting index (inclusive) - * @param end - ending index (exclusive) - * @returns output array - * - * @example - * var x = [ 1, 2, 3 ]; - * - * var out = ns.slice( x ); - * // returns [ 1, 2, 3 ] - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var out = ns.slice( x, 0, 2 ); - * // returns [ 1, 2 ] - */ - slice: typeof slice; - - /** - * Takes elements from an array. - * - * @param x - input array - * @param indices - list of element indices - * @param options - function options - * @returns output array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = ns.take( x, [ 1, 3 ] ); - * // returns [ 2, 4 ] - */ - take: typeof take; - - /** - * Returns an iterator which repeatedly iterates over each element in an array-like object. - * - * @param src - input value - * @param options - function options - * @param options.iter - number of iterations - * @param options.dir - iteration direction - * @param mapFcn - function to invoke for each iterated value - * @param thisArg - execution context - * @throws must provide valid options - * @returns iterator - * - * @example - * var opts = { - * 'dir': -1 - * }; - * var it = ns.circarray2iterator( [ 1, 2, 3, 4 ], opts ); - * // returns - * - * var v = it.next().value; - * // returns 4 - * - * v = it.next().value; - * // returns 3 - * - * v = it.next().value; - * // returns 2 - */ - circarray2iterator: typeof circarray2iterator; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = ns.array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - */ - array2fancy: typeof array2fancy; - - /** - * Returns an iterator which iterates over each element in an array-like object. - * - * @param src - input value - * @param mapFcn - function to invoke for each iterated value - * @param thisArg - execution context - * @returns iterator - * - * @example - * var iter = ns.array2iterator( [ 1, 2, 3, 4 ] ); - * - * var v = iter.next().value; - * // returns 1 - * - * v = iter.next().value; - * // returns 2 - * - * v = iter.next().value; - * // returns 3 - * - * // ... - */ - array2iterator: typeof array2iterator; - - /** - * Returns an iterator which iterates from right to left over each element in an array-like object. - * - * ## Notes - * - * - For dynamic array resizing, the only behavior made intentionally consistent with iterating from left to right is when elements are pushed onto the beginning (end) of an array. In other words, iterating from left to right combined with `[].push()` is consistent with iterating from right to left combined with `[].unshift()`. - * - * @param src - input value - * @param mapFcn - function to invoke for each iterated value - * @param thisArg - execution context - * @returns iterator - * - * @example - * var iter = ns.array2iteratorRight( [ 1, 2, 3, 4 ] ); - * - * var v = iter.next().value; - * // returns 4 - * - * v = iter.next().value; - * // returns 3 - * - * v = iter.next().value; - * // returns 2 - * - * // ... - */ - array2iteratorRight: typeof array2iteratorRight; - - /** - * Returns a JSON representation of a typed array. - * - * ## Notes - * - * - We build a JSON object representing a typed array similar to how Node.js `Buffer` objects are represented. See [Buffer][1]. - * - * [1]: https://nodejs.org/api/buffer.html#buffer_buf_tojson - * - * @param arr - typed array to serialize - * @returns JSON representation - * - * @example - * var Float64Array = require( './../../float64' ); - * - * var arr = new Float64Array( [ 5.0, 3.0 ] ); - * var json = ns.typedarray2json( arr ); - * // returns { 'type': 'Float64Array', 'data': [ 5.0, 3.0 ] } - */ - typedarray2json: typeof typedarray2json; - - /** - * Returns an iterator which iterates over each element in a sparse array-like object. - * - * @param src - input value - * @param mapFcn - function to invoke for each iterated value - * @param thisArg - execution context - * @returns iterator - * - * @example - * var iter = ns.sparsearray2iterator( [ 1, , 3, 4 ] ); - * - * var v = iter.next().value; - * // returns 1 - * - * v = iter.next().value; - * // returns 3 - * - * v = iter.next().value; - * // returns 4 - */ - sparsearray2iterator: typeof sparsearray2iterator; - - /** - * Returns an iterator which iterates from right to left over each element in a sparse array-like object. - * - * ## Notes - * - * - For dynamic array resizing, the only behavior made intentionally consistent with iterating from left to right is when elements are pushed onto the beginning (end) of an array. In other words, iterating from left to right combined with `[].push()` is consistent with iterating from right to left combined with `[].unshift()`. - * - * @param src - input value - * @param mapFcn - function to invoke for each iterated value - * @param thisArg - execution context - * @returns iterator - * - * @example - * var iter = ns.sparsearray2iteratorRight( [ 1, , 3, 4 ] ); - * - * var v = iter.next().value; - * // returns 4 - * - * v = iter.next().value; - * // returns 3 - * - * v = iter.next().value; - * // returns 1 - */ - sparsearray2iteratorRight: typeof sparsearray2iteratorRight; - - /** - * Returns an iterator which iterates over elements in an array-like object according to specified stride parameters. - * - * @param N - number of values to iterate - * @param src - input value - * @param stride - stride length - * @param offset - starting index - * @param mapFcn - function to invoke for each iterated value - * @param thisArg - execution context - * @throws first argument must be a nonnegative integer - * @throws third argument must be an integer - * @throws fourth argument must be a nonnegative integer - * @returns iterator - * - * @example - * var values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - * - * var N = 4; - * var stride = -2; - * var offset = 6; - * - * var iter = ns.stridedarray2iterator( N, values, stride, offset ); - * - * var v = iter.next().value; - * // returns 7 - * - * v = iter.next().value; - * // returns 5 - * - * v = iter.next().value; - * // returns 3 - * - * // ... - */ - stridedarray2iterator: typeof stridedarray2iterator; - - /** - * Returns an iterator which iterates over each element in an array-like object view. - * - * @param src - input value - * @param begin - starting index (inclusive) (default: 0) - * @param end - ending index (non-inclusive) (default: src.length) - * @param mapFcn - function to invoke for each iterated value - * @param thisArg - execution context - * @returns iterator - * - * @example - * var iter = ns.arrayview2iterator( [ 1, 2, 3, 4 ], 1, 3 ); - * - * var v = iter.next().value; - * // returns 2 - * - * v = iter.next().value; - * // returns 3 - * - * var bool = iter.next().done; - * // returns true - */ - arrayview2iterator: typeof arrayview2iterator; - - /** - * Returns an iterator which iterates from right to left over each element in an array-like object view. - * - * @param src - input value - * @param begin - starting **view** index (inclusive) (default: 0) - * @param end - ending **view** index (non-inclusive) (default: src.length) - * @param mapFcn - function to invoke for each iterated value - * @param thisArg - execution context - * @returns iterator - * - * @example - * var iter = ns.arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 3 ); - * - * var v = iter.next().value; - * // returns 3 - * - * v = iter.next().value; - * // returns 2 - * - * var bool = iter.next().done; - * // returns true - */ - arrayview2iteratorRight: typeof arrayview2iteratorRight; - - /** - * Creates a typed array. - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @returns typed array - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = ns.typedarray( buf, 8, 2 ); - * // returns [ 0.0, 0.0 ] - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = ns.typedarray( buf, 8, 2, 'int32' ); - * // returns [ 0, 0 ] - */ - typedarray: typeof typedarray; - - /** - * Creates a complex number typed array. - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first array element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'complex128') - * @returns complex number typed array - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 64 ); - * var arr = ns.complexarray( buf, 16, 2 ); - * // returns - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 64 ); - * var arr = ns.complexarray( buf, 16, 2, 'complex64' ); - * // returns - */ - complexarray: typeof complexarray; - - /** - * Returns a complex typed array constructor. - * - * @param dtype - data type - * @returns constructor or null - * - * @example - * var ctor = ns.complexarrayCtors( 'complex128' ); - * // returns - * - * @example - * var ctor = ns.complexarrayCtors( 'float64' ); - * // returns null - */ - complexarrayCtors: typeof complexarrayCtors; - - /** - * Returns a list of complex typed array data types. - * - * @returns list of complex typed array data types - * - * @example - * var list = ns.complexarrayDataTypes(); - * // e.g., returns [ 'complex64', ... ] - */ - complexarrayDataTypes: typeof complexarrayDataTypes; - - /** - * Returns a typed array constructor. - * - * @param dtype - data type - * @returns constructor or null - * - * @example - * var ctor = ns.typedarrayCtors( 'float64' ); - * // returns - * - * @example - * var ctor = ns.typedarrayCtors( 'float' ); - * // returns null - */ - typedarrayCtors: typeof typedarrayCtors; - - /** - * Returns a list of typed array data types. - * - * @returns list of typed array data types - * - * @example - * var list = ns.typedarrayDataTypes(); - * // e.g., returns [ 'float32', ... ] - */ - typedarrayDataTypes: typeof typedarrayDataTypes; - - /** - * Returns a floating-point typed array constructor. - * - * @param dtype - data type - * @returns constructor or null - * - * @example - * var ctor = ns.floatarrayCtors( 'float64' ); - * // returns - * - * @example - * var ctor = ns.floatarrayCtors( 'float' ); - * // returns null - */ - floatarrayCtors: typeof floatarrayCtors; - - /** - * Returns a list of typed array floating-point data types. - * - * @returns list of typed array floating-point data types - * - * @example - * var list = ns.floatarrayDataTypes(); - * // e.g., returns [ 'float32', ... ] - */ - floatarrayDataTypes: typeof floatarrayDataTypes; - - /** - * Returns an integer-valued typed array constructor. - * - * @param dtype - data type - * @returns constructor or null - * - * @example - * var ctor = ns.intarrayCtors( 'int32' ); - * // returns - * - * @example - * var ctor = ns.intarrayCtors( 'int' ); - * // returns null - */ - intarrayCtors: typeof intarrayCtors; - - /** - * Returns a list of typed array integer data types. - * - * @returns list of typed array integer data types - * - * @example - * var list = ns.intarrayDataTypes(); - * // e.g., returns [ 'int16', ... ] - */ - intarrayDataTypes: typeof intarrayDataTypes; - - /** - * Creates a typed array. - * - * @param buffer - underlying ArrayBuffer - * @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) - * @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer - * @param dtype - data type (default: 'float64') - * @returns typed array - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = ns.realarray( buf, 8, 2 ); - * // returns [ 0.0, 0.0 ] - * - * @example - * var ArrayBuffer = require( './../../buffer' ); - * - * var buf = new ArrayBuffer( 32 ); - * var arr = ns.realarray( buf, 8, 2, 'int32' ); - * // returns [ 0, 0 ] - */ - realarray: typeof realarray; - - /** - * Returns a typed array constructor. - * - * @param dtype - data type - * @returns constructor or null - * - * @example - * var ctor = ns.realarrayCtors( 'float64' ); - * // returns - * - * @example - * var ctor = ns.realarrayCtors( 'float' ); - * // returns null - */ - realarrayCtors: typeof realarrayCtors; - - /** - * Returns a list of typed array real-valued data types. - * - * @returns list of typed array data types - * - * @example - * var list = ns.realarrayDataTypes(); - * // e.g., returns [ 'float32', ... ] - */ - realarrayDataTypes: typeof realarrayDataTypes; - - /** - * Returns a real-valued floating-point typed array constructor. - * - * @param dtype - data type - * @returns constructor or null - * - * @example - * var ctor = ns.realarrayFloatCtors( 'float64' ); - * // returns - * - * @example - * var ctor = ns.realarrayFloatCtors( 'float' ); - * // returns null - */ - realarrayFloatCtors: typeof realarrayFloatCtors; - - /** - * Returns a list of typed array real-valued floating-point data types. - * - * @returns list of typed array real-valued floating-point data types - * - * @example - * var list = ns.realarrayFloatDataTypes(); - * // e.g., returns [ 'float32', ... ] - */ - realarrayFloatDataTypes: typeof realarrayFloatDataTypes; - - /** - * Returns a signed integer typed array constructor. - * - * @param dtype - data type - * @returns constructor or null - * - * @example - * var ctor = ns.intarraySignedCtors( 'int32' ); - * // returns - * - * @example - * var ctor = ns.intarraySignedCtors( 'int' ); - * // returns null - */ - intarraySignedCtors: typeof intarraySignedCtors; - - /** - * Returns a list of typed array signed integer data types. - * - * @returns list of typed array signed integer data types - * - * @example - * var list = ns.intarraySignedDataTypes(); - * // e.g., returns [ 'int16', ... ] - */ - intarraySignedDataTypes: typeof intarraySignedDataTypes; - - /** - * Returns an unsigned integer typed array constructor. - * - * @param dtype - data type - * @returns constructor or null - * - * @example - * var ctor = ns.intarrayUnsignedCtors( 'uint32' ); - * // returns - * - * @example - * var ctor = ns.intarrayUnsignedCtors( 'uint' ); - * // returns null - */ - intarrayUnsignedCtors: typeof intarrayUnsignedCtors; - - /** - * Returns a list of typed array unsigned integer data types. - * - * @returns list of typed array unsigned integer data types - * - * @example - * var list = ns.intarrayUnsignedDataTypes(); - * // e.g., returns [ 'uint16', ... ] - */ - intarrayUnsignedDataTypes: typeof intarrayUnsignedDataTypes; - - /** - * Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order. - */ - Uint8Array: typeof Uint8Array; - - /** - * Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order clamped to 0-255. - */ - Uint8ClampedArray: typeof Uint8ClampedArray; - - /** - * Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. - */ - Uint16Array: typeof Uint16Array; - - /** - * Typed array constructor which returns a typed array representing an array of 32-bit unsigned integers in the platform byte order. - */ - Uint32Array: typeof Uint32Array; - - /** - * Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. - * - * @param n - number of elements - * @param dtype - data type (default: 'float64') - * @returns linearly spaced numeric array - * - * @example - * var arr = ns.zeroTo( 2 ); - * // returns [ 0.0, 1.0 ] - * - * @example - * var arr = ns.zeroTo( 2, 'float32' ); - * // returns [ 0.0, 1.0 ] - */ - zeroTo: typeof zeroTo; - - /** - * Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. - * - * @param x - input array from which to derive the output array length - * @param dtype - data type - * @returns linearly spaced numeric array - * - * @example - * var zeros = require( './../../zeros' ); - * - * var x = zeros( 2, 'float32' ); - * // returns [ 0.0, 0.0 ] - * - * var y = ns.zeroToLike( x ); - * // returns [ 0.0, 1.0 ] - */ - zeroToLike: typeof zeroToLike; - - /** - * Creates a zero-filled array having a specified length. - * - * The function recognizes the following data types: - * - * - `float64`: double-precision floating-point numbers (IEEE 754) - * - `float32`: single-precision floating-point numbers (IEEE 754) - * - `complex128`: double-precision complex floating-point numbers - * - `complex64`: single-precision complex floating-point numbers - * - `int32`: 32-bit two's complement signed integers - * - `uint32`: 32-bit unsigned integers - * - `int16`: 16-bit two's complement signed integers - * - `uint16`: 16-bit unsigned integers - * - `int8`: 8-bit two's complement signed integers - * - `uint8`: 8-bit unsigned integers - * - `uint8c`: 8-bit unsigned integers clamped to `0-255` - * - `generic`: generic JavaScript values - * - * @param length - array length - * @param dtype - data type (default: 'float64') - * @returns zero-filled array - * - * @example - * var arr = ns.zeros( 2 ); - * // returns [ 0.0, 0.0 ] - * - * @example - * var arr = ns.zeros( 2, 'float32' ); - * // returns [ 0.0, 0.0 ] - */ - zeros: typeof zeros; - - /** - * Creates a zero-filled array having the same length as a provided input array. - * - * The function supports the following data types: - * - * - `float64`: double-precision floating-point numbers (IEEE 754) - * - `float32`: single-precision floating-point numbers (IEEE 754) - * - `complex128`: double-precision complex floating-point numbers - * - `complex64`: single-precision complex floating-point numbers - * - `int32`: 32-bit two's complement signed integers - * - `uint32`: 32-bit unsigned integers - * - `int16`: 16-bit two's complement signed integers - * - `uint16`: 16-bit unsigned integers - * - `int8`: 8-bit two's complement signed integers - * - `uint8`: 8-bit unsigned integers - * - `uint8c`: 8-bit unsigned integers clamped to `0-255` - * - `generic`: generic JavaScript values - * - * @param x - input array from which to derive the output array length - * @param dtype - data type - * @returns zero-filled array - * - * @example - * var zeros = require( './../../zeros' ); - * - * var x = zeros( 2, 'float64' ); - * // returns [ 0.0, 0.0 ] - * - * var y = ns.zerosLike( x, 'float32' ); - * // returns [ 0.0, 0.0 ] - */ - zerosLike: typeof zerosLike; - - /** - * Array constants. - */ - constants: typeof constants; -} - -/** -* Arrays. -*/ -declare var ns: Namespace; - - -// EXPORTS // - -export = ns; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c2dd14ec1..000000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import ns = require( './index' ); - - -// TESTS // - -// The exported value is the expected interface... -{ - ns; // $ExpectType Namespace -} diff --git a/dtype/README.md b/dtype/README.md deleted file mode 100644 index c61e54f08..000000000 --- a/dtype/README.md +++ /dev/null @@ -1,149 +0,0 @@ - - -# Data Type - -> Return the data type of an array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var dtype = require( '@stdlib/array/dtype' ); -``` - -#### dtype( array ) - -Returns the [data type][@stdlib/array/dtypes] of an `array`. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var arr = new Float64Array( 10 ); - -var dt = dtype( arr ); -// returns 'float64' -``` - -If provided an argument having an unknown or unsupported [data type][@stdlib/array/dtypes], the function returns `null`. - -```javascript -var dt = dtype( 'beep' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var ctors = require( '@stdlib/array/ctors' ); -var dtype = require( '@stdlib/array/dtype' ); - -var DTYPES; -var ctor; -var arr; -var len; -var dt; -var i; - -// Get a list of supported array data types: -DTYPES = dtypes(); - -// Array length: -len = 10; - -// For each supported data type, create an array and confirm its data type... -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - arr = new ctor( len ); - dt = dtype( arr ); - console.log( '%s == %s => %s', DTYPES[ i ], dt, DTYPES[ i ] === dt ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/dtype/benchmark/benchmark.js b/dtype/benchmark/benchmark.js deleted file mode 100644 index f2c4bb35a..000000000 --- a/dtype/benchmark/benchmark.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../dtypes' ); -var ctors = require( './../../ctors' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var dtype = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arrays; - var ctor; - var dt; - var i; - - arrays = []; - for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - arrays.push( new ctor( 10 ) ); - } - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - dt = dtype( arrays[ i%arrays.length ] ); - if ( typeof dt !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( dt ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/dtype/docs/repl.txt b/dtype/docs/repl.txt deleted file mode 100644 index 563d172bd..000000000 --- a/dtype/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( array ) - Returns the data type of an array. - - If provided an argument having an unknown or unsupported type, the function - returns `null`. - - Parameters - ---------- - array: any - Input value. - - Returns - ------- - out: string|null - Data type. - - Examples - -------- - > var arr = new {{alias:@stdlib/array/float64}}( 10 ); - > var dt = {{alias}}( arr ) - 'float64' - > dt = {{alias}}( 'beep' ) - null - - See Also - -------- - diff --git a/dtype/docs/types/index.d.ts b/dtype/docs/types/index.d.ts deleted file mode 100644 index 48e3c2e7c..000000000 --- a/dtype/docs/types/index.d.ts +++ /dev/null @@ -1,227 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { RealOrComplexTypedArray, Complex128Array, Complex64Array, BooleanArray, DataType } from '@stdlib/types/array'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var dt = dtype( new Float64Array( [ 1, 2, 3 ] ) ); -* // returns 'float64' -*/ -declare function dtype( value: Float64Array ): 'float64'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var dt = dtype( new Float32Array( [ 1, 2, 3 ] ) ); -* // returns 'float32' -*/ -declare function dtype( value: Float32Array ): 'float32'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var dt = dtype( new Complex128Array( [ 1, 2, 3, 4 ] ) ); -* // returns 'complex128' -*/ -declare function dtype( value: Complex128Array ): 'complex128'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var dt = dtype( new Complex64Array( [ 1, 2, 3, 4 ] ) ); -* // returns 'complex64' -*/ -declare function dtype( value: Complex64Array ): 'complex64'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var BooleanArray = require( '@stdlib/array/bool' ); -* -* var dt = dtype( new BooleanArray( [ true, false, true, false ] ) ); -* // returns 'bool' -*/ -declare function dtype( value: BooleanArray ): 'bool'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var dt = dtype( new Int32Array( [ 1, 2, 3 ] ) ); -* // returns 'int32' -*/ -declare function dtype( value: Int32Array ): 'int32'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var Int16Array = require( '@stdlib/array/int16' ); -* -* var dt = dtype( new Int16Array( [ 1, 2, 3 ] ) ); -* // returns 'int16' -*/ -declare function dtype( value: Int16Array ): 'int16'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var Int8Array = require( '@stdlib/array/int8' ); -* -* var dt = dtype( new Int8Array( [ 1, 2, 3 ] ) ); -* // returns 'int8' -*/ -declare function dtype( value: Int8Array ): 'int8'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var Uint32Array = require( '@stdlib/array/uint32' ); -* -* var dt = dtype( new Uint32Array( [ 1, 2, 3 ] ) ); -* // returns 'uint32' -*/ -declare function dtype( value: Uint32Array ): 'uint32'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var Uint16Array = require( '@stdlib/array/uint16' ); -* -* var dt = dtype( new Uint16Array( [ 1, 2, 3 ] ) ); -* // returns 'uint16' -*/ -declare function dtype( value: Uint16Array ): 'uint16'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var dt = dtype( new Uint8Array( [ 1, 2, 3 ] ) ); -* // returns 'uint8' -*/ -declare function dtype( value: Uint8Array ): 'uint8'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -* -* var dt = dtype( new Uint8ClampedArray( [ 1, 2, 3 ] ) ); -* // returns 'uint8c' -*/ -declare function dtype( value: Uint8ClampedArray ): 'uint8c'; - -/** -* Returns the data type of an array. -* -* @param value - input value -* @returns data type -* -* @example -* var dt = dtype( [ 1, 2, 3 ] ); -* // returns 'generic' -*/ -declare function dtype( value: Array ): 'generic'; - -/** -* Returns the data type of an array. -* -* ## Notes -* -* - If provided an argument having an unknown or unsupported type, the function returns `null`. -* -* @param value - input value -* @returns data type -* -* @example -* var dt = dtype( [ 1, 2, 3 ] ); -* // returns 'generic' -* -* var dt = dtype( 'beep' ); -* // returns null -*/ -declare function dtype( value: Array | RealOrComplexTypedArray ): DataType | null; - - -// EXPORTS // - -export = dtype; diff --git a/dtype/docs/types/test.ts b/dtype/docs/types/test.ts deleted file mode 100644 index 12e5546cd..000000000 --- a/dtype/docs/types/test.ts +++ /dev/null @@ -1,48 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import BooleanArray = require( './../../../bool' ); -import dtype = require( './index' ); - - -// TESTS // - -// The function returns a data type or null.. -{ - dtype( new Float64Array( 10 ) ); // $ExpectType "float64" - dtype( new Float32Array( 10 ) ); // $ExpectType "float32" - dtype( new Complex128Array( 10 ) ); // $ExpectType "complex128" - dtype( new Complex64Array( 10 ) ); // $ExpectType "complex64" - dtype( new Int32Array( 10 ) ); // $ExpectType "int32" - dtype( new Int16Array( 10 ) ); // $ExpectType "int16" - dtype( new Int8Array( 10 ) ); // $ExpectType "int8" - dtype( new Uint32Array( 10 ) ); // $ExpectType "uint32" - dtype( new Uint16Array( 10 ) ); // $ExpectType "uint16" - dtype( new Uint8Array( 10 ) ); // $ExpectType "uint8" - dtype( new Uint8ClampedArray( 10 ) ); // $ExpectType "uint8c" - dtype( new BooleanArray( 10 ) ); // $ExpectType "bool" - dtype( [] ); // $ExpectType "generic" -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - dtype(); // $ExpectError - dtype( [ 1, 2, 3 ], 3 ); // $ExpectError -} diff --git a/dtype/examples/index.js b/dtype/examples/index.js deleted file mode 100644 index d51822481..000000000 --- a/dtype/examples/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var dtypes = require( './../../dtypes' ); -var ctors = require( './../../ctors' ); -var dtype = require( './../lib' ); - -var DTYPES; -var ctor; -var arr; -var len; -var dt; -var i; - -// Get a list of supported array data types: -DTYPES = dtypes(); - -// Array length: -len = 10; - -// For each supported data type, create an array and confirm its data type... -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - arr = new ctor( len ); - dt = dtype( arr ); - console.log( '%s == %s => %s', DTYPES[ i ], dt, DTYPES[ i ] === dt ); -} diff --git a/dtype/lib/ctor2dtype.js b/dtype/lib/ctor2dtype.js deleted file mode 100644 index 3ffd4bf52..000000000 --- a/dtype/lib/ctor2dtype.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -// MAIN // - -// Mapping from array constructors to data types... -var ctor2dtypes = { - 'Float32Array': 'float32', - 'Float64Array': 'float64', - 'Array': 'generic', - 'Int16Array': 'int16', - 'Int32Array': 'int32', - 'Int8Array': 'int8', - 'Uint16Array': 'uint16', - 'Uint32Array': 'uint32', - 'Uint8Array': 'uint8', - 'Uint8ClampedArray': 'uint8c', - 'Complex64Array': 'complex64', - 'Complex128Array': 'complex128', - 'BooleanArray': 'bool' -}; - - -// EXPORTS // - -module.exports = ctor2dtypes; diff --git a/dtype/lib/ctors.js b/dtype/lib/ctors.js deleted file mode 100644 index 0015e1cda..000000000 --- a/dtype/lib/ctors.js +++ /dev/null @@ -1,58 +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. -*/ - -'use strict'; - -// MODULES // - -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Uint32Array = require( './../../uint32' ); -var Int32Array = require( './../../int32' ); -var Uint16Array = require( './../../uint16' ); -var Int16Array = require( './../../int16' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Int8Array = require( './../../int8' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); - - -// MAIN // - -// Note: order should match `dtypes` order -var CTORS = [ - Float64Array, - Float32Array, - Int32Array, - Uint32Array, - Int16Array, - Uint16Array, - Int8Array, - Uint8Array, - Uint8ClampedArray, - Complex64Array, - Complex128Array, - BooleanArray -]; - - -// EXPORTS // - -module.exports = CTORS; diff --git a/dtype/lib/dtypes.js b/dtype/lib/dtypes.js deleted file mode 100644 index eb3d0b742..000000000 --- a/dtype/lib/dtypes.js +++ /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. -*/ - -'use strict'; - -// MAIN // - -// Note: order should match `ctors` order -var DTYPES = [ - 'float64', - 'float32', - 'int32', - 'uint32', - 'int16', - 'uint16', - 'int8', - 'uint8', - 'uint8c', - 'complex64', - 'complex128', - 'bool' -]; - - -// EXPORTS // - -module.exports = DTYPES; diff --git a/dtype/lib/index.js b/dtype/lib/index.js deleted file mode 100644 index eedee913e..000000000 --- a/dtype/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return the data type of an array. -* -* @module @stdlib/array/dtype -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var dtype = require( '@stdlib/array/dtype' ); -* -* var arr = new Float64Array( 10 ); -* -* var dt = dtype( arr ); -* // returns 'float64' -* -* dt = dtype( {} ); -* // returns null -* -* dt = dtype( 'beep' ); -* // returns null -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/dtype/lib/main.js b/dtype/lib/main.js deleted file mode 100644 index 98b761d39..000000000 --- a/dtype/lib/main.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isBuffer = require( '@stdlib/assert/is-buffer' ); -var isArray = require( '@stdlib/assert/is-array' ); -var constructorName = require( '@stdlib/utils/constructor-name' ); -var ctor2dtype = require( './ctor2dtype.js' ); -var CTORS = require( './ctors.js' ); -var DTYPES = require( './dtypes.js' ); - - -// VARIABLES // - -var NTYPES = DTYPES.length; - - -// MAIN // - -/** -* Returns the data type of an array. -* -* @param {*} value - input value -* @returns {(string|null)} data type -* -* @example -* var dt = dtype( [ 1, 2, 3 ] ); -* // returns 'generic' -* -* var dt = dtype( 'beep' ); -* // returns null -*/ -function dtype( value ) { - var i; - if ( isArray( value ) ) { - return 'generic'; - } - if ( isBuffer( value ) ) { - return null; - } - for ( i = 0; i < NTYPES; i++ ) { - if ( value instanceof CTORS[ i ] ) { - return DTYPES[ i ]; - } - } - // If the above failed, fall back to a more robust (and significantly slower) means for resolving underlying data types: - return ctor2dtype[ constructorName( value ) ] || null; -} - - -// EXPORTS // - -module.exports = dtype; diff --git a/dtype/package.json b/dtype/package.json deleted file mode 100644 index 0f00b4a21..000000000 --- a/dtype/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/dtype", - "version": "0.0.0", - "description": "Return the data type of an array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "dtypes", - "dtype", - "data", - "type", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/dtype/test/test.js b/dtype/test/test.js deleted file mode 100644 index 97c13bcb3..000000000 --- a/dtype/test/test.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../dtypes' ); -var ctors = require( './../../ctors' ); -var allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' ); -var dtype = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dtype, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the data type for an input array', function test( t ) { - var DTYPES; - var ctor; - var arr; - var dt; - var i; - - DTYPES = dtypes(); - - for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - arr = new ctor( 10 ); - dt = dtype( arr ); - t.strictEqual( dt, DTYPES[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function does not support array-like objects', function test( t ) { - var arr; - var dt; - - arr = { - 'length': 10 - }; - dt = dtype( arr ); - t.strictEqual( dt, null, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns `null` if provided a Node.js Buffer', function test( t ) { - var buf; - var dt; - - buf = allocUnsafe( 10 ); - dt = dtype( buf ); - t.strictEqual( dt, null, 'returns expected value' ); - t.end(); -}); - -tape( 'if provided an argument having an unknown/unsupported data type, the function returns `null`', function test( t ) { - var buffers; - var i; - - buffers = [ - 'beep', - 5, - NaN, - null, - void 0, - true, - false, - {}, - function noop() {} - ]; - for ( i = 0; i < buffers.length; i++ ) { - t.strictEqual( dtype( buffers[i] ), null, 'returns expected value for ' + buffers[ i ] ); - } - t.end(); -}); diff --git a/dtypes/README.md b/dtypes/README.md deleted file mode 100644 index c72e130aa..000000000 --- a/dtypes/README.md +++ /dev/null @@ -1,181 +0,0 @@ - - -# Data Types - -> List of array data types. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -``` - -#### dtypes( \[kind] ) - -Returns a list of array data types. - -```javascript -var out = dtypes(); -// e.g., returns [ 'float32', 'float64', ... ] -``` - -When not provided a data type "kind", the function returns an array containing the following data types: - -- `float32`: single-precision floating-point numbers. -- `float64`: double-precision floating-point numbers. -- `complex64`: single-precision complex floating-point numbers. -- `complex128`: double-precision complex floating-point numbers. -- `bool`: boolean values. -- `generic`: values of any type. -- `int16`: signed 16-bit integers. -- `int32`: signed 32-bit integers. -- `int8`: signed 8-bit integers. -- `uint16`: unsigned 16-bit integers. -- `uint32`: unsigned 32-bit integers. -- `uint8`: unsigned 8-bit integers. -- `uint8c`: unsigned clamped 8-bit integers. - -To return the subset of data types belonging to a specified data type kind, provide a `kind` argument. - -```javascript -var out = dtypes( 'floating_point' ); -// returns [...] -``` - -The function supports the following data type kinds: - -- `floating_point`: floating-point data types. -- `real_floating_point`: real-valued floating-point data types. -- `complex_floating_point`: complex-valued floating-point data types. -- `boolean`: boolean data types. -- `integer`: integer data types. -- `signed_integer`: signed integer data types. -- `unsigned_integer`: unsigned integer data types. -- `real`: real-valued data types. -- `numeric`: numeric data types. -- `typed`: typed data types. -- `integer_index`: integer index data types. -- `boolean_index`: boolean index data types. -- `mask_index`: mask index data types. -- `typed_index`: typed index data types. -- `index`: index data types. -- `all`: all data types. - -Additionally, the function supports extending the "kinds" listed above by appending an `_and_generic` suffix to the kind name (e.g., `real_and_generic`). - -```javascript -var out = dtypes( 'floating_point_and_generic' ); -// returns [...] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var contains = require( '@stdlib/array/base/assert/contains' ).factory; -var dtypes = require( '@stdlib/array/dtypes' ); - -var isdtype = contains( dtypes() ); - -var bool = isdtype( 'float64' ); -// returns true - -bool = isdtype( 'int8' ); -// returns true - -bool = isdtype( 'uint16' ); -// returns true - -bool = isdtype( 'beep' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/dtypes/benchmark/benchmark.js b/dtypes/benchmark/benchmark.js deleted file mode 100644 index 3c7886c54..000000000 --- a/dtypes/benchmark/benchmark.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var pkg = require( './../package.json' ).name; -var dtypes = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dtypes(); - if ( out.length === 0 ) { - b.fail( 'should return a non-empty array' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::kind', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'floating_point', - 'integer' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dtypes( values[ i%values.length ] ); - if ( out.length === 0 ) { - b.fail( 'should return a non-empty array' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::kind,generic', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'floating_point_and_generic', - 'integer_and_generic', - 'boolean_and_generic' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dtypes( values[ i%values.length ] ); - if ( out.length === 0 ) { - b.fail( 'should return a non-empty array' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/dtypes/docs/repl.txt b/dtypes/docs/repl.txt deleted file mode 100644 index 879c0d28a..000000000 --- a/dtypes/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( [kind] ) - Returns a list of array data types. - - When not provided a data type "kind", the function returns an array - containing the following data types: - - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - bool: boolean values. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - The function supports the following data type "kinds": - - - floating_point: floating-point data types. - - real_floating_point: real-valued floating-point data types. - - complex_floating_point: complex-valued floating-point data types. - - boolean: boolean data types. - - integer: integer data types. - - signed_integer: signed integer data types. - - unsigned_integer: unsigned integer data types. - - real: real-valued data types. - - numeric: numeric data types. - - typed: typed data types. - - integer_index: integer index data types. - - boolean_index: boolean index data types. - - mask_index: mask index data types. - - typed_index: typed index data types. - - index: index data types. - - all: all data types. - - Additionally, the function supports extending the "kinds" listed above by - appending a '_and_generic' suffix to the kind name (e.g., real_and_generic). - - Parameters - ---------- - kind: string (optional) - Data type kind. - - Returns - ------- - out: Array - List of array data types. - - Examples - -------- - > var out = {{alias}}() - [...] - > out = {{alias}}( 'floating_point' ) - [...] - > out = {{alias}}( 'floating_point_and_generic' ) - [...] - - See Also - -------- - diff --git a/dtypes/docs/types/index.d.ts b/dtypes/docs/types/index.d.ts deleted file mode 100644 index ec6cf2c99..000000000 --- a/dtypes/docs/types/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { DataType, DataTypeKind } from '@stdlib/types/array'; - -/** -* Returns a list of array data types. -* -* @param kind - data type kind -* @returns list of array data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'float32', 'float64', ... ] -* -* @example -* var list = dtypes( 'floating_point' ); -* // returns [...] -*/ -declare function dtypes( kind?: DataTypeKind ): Array; - - -// EXPORTS // - -export = dtypes; diff --git a/dtypes/docs/types/test.ts b/dtypes/docs/types/test.ts deleted file mode 100644 index 5f69057b1..000000000 --- a/dtypes/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import dtypes = require( './index' ); - - -// TESTS // - -// The function returns an array of data types... -{ - dtypes(); // $ExpectType DataType[] - dtypes( 'floating_point' ); // $ExpectType DataType[] - dtypes( 'floating_point_and_generic' ); // $ExpectType DataType[] -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - dtypes( 'floating_point', 2 ); // $ExpectError -} diff --git a/dtypes/examples/index.js b/dtypes/examples/index.js deleted file mode 100644 index b1b0c01b6..000000000 --- a/dtypes/examples/index.js +++ /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. -*/ - -'use strict'; - -var contains = require( './../../base/assert/contains' ).factory; -var dtypes = require( './../lib' ); - -var isdtype = contains( dtypes() ); - -var bool = isdtype( 'float64' ); -console.log( bool ); -// => true - -bool = isdtype( 'int8' ); -console.log( bool ); -// => true - -bool = isdtype( 'uint16' ); -console.log( bool ); -// => true - -bool = isdtype( 'beep' ); -console.log( bool ); -// => false diff --git a/dtypes/lib/dtypes.json b/dtypes/lib/dtypes.json deleted file mode 100644 index 2a827b1a4..000000000 --- a/dtypes/lib/dtypes.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "all": [ - "bool", - "complex64", - "complex128", - "float32", - "float64", - "generic", - "int16", - "int32", - "int8", - "uint16", - "uint32", - "uint8", - "uint8c" - ], - "typed": [ - "bool", - "complex64", - "complex128", - "float32", - "float64", - "int16", - "int32", - "int8", - "uint16", - "uint32", - "uint8", - "uint8c" - ], - "floating_point": [ - "complex64", - "complex128", - "float32", - "float64" - ], - "real_floating_point": [ - "float32", - "float64" - ], - "complex_floating_point": [ - "complex64", - "complex128" - ], - "boolean": [ - "bool" - ], - "integer": [ - "int16", - "int32", - "int8", - "uint16", - "uint32", - "uint8", - "uint8c" - ], - "signed_integer": [ - "int16", - "int32", - "int8" - ], - "unsigned_integer": [ - "uint16", - "uint32", - "uint8", - "uint8c" - ], - "real": [ - "float32", - "float64", - "int16", - "int32", - "int8", - "uint16", - "uint32", - "uint8", - "uint8c" - ], - "numeric": [ - "complex64", - "complex128", - "float32", - "float64", - "int16", - "int32", - "int8", - "uint16", - "uint32", - "uint8", - "uint8c" - ], - "index": [ - "int32", - "uint8", - "bool", - "generic" - ], - "integer_index": [ - "int32" - ], - "boolean_index": [ - "bool" - ], - "mask_index": [ - "uint8" - ], - "typed_index": [ - "int32", - "uint8", - "bool" - ] -} diff --git a/dtypes/lib/index.js b/dtypes/lib/index.js deleted file mode 100644 index eb466770e..000000000 --- a/dtypes/lib/index.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -/** -* Return a list of array data types. -* -* @module @stdlib/array/dtypes -* -* @example -* var dtypes = require( '@stdlib/array/dtypes' ); -* -* var list = dtypes(); -* // e.g., returns [ 'float32', 'float64', 'generic', 'int16', 'int32', 'int8', 'uint16', 'uint32', 'uint8', 'uint8c', 'complex128', 'complex64', 'bool' ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/dtypes/lib/main.js b/dtypes/lib/main.js deleted file mode 100644 index 2e09a3221..000000000 --- a/dtypes/lib/main.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'; - -// MODULES // - -var replace = require( '@stdlib/string/base/replace' ); -var DTYPES = require( './dtypes.json' ); - - -// VARIABLES // - -var RE_SUFFIX = /_and_generic$/; - - -// MAIN // - -/** -* Returns a list of array data types. -* -* @param {string} [kind] - data type kind -* @returns {StringArray} list of array data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'float32', 'float64', ... ] -* -* @example -* var list = dtypes( 'floating_point' ); -* // returns [...] -*/ -function dtypes() { - var kind; - var out; - var FLG; - if ( arguments.length === 0 ) { - return DTYPES.all.slice(); - } - FLG = false; - kind = arguments[ 0 ]; - if ( RE_SUFFIX.test( kind ) ) { - kind = replace( kind, RE_SUFFIX, '' ); - if ( kind !== 'all' && kind !== 'index' ) { - FLG = true; - } - } - out = DTYPES[ kind ]; - out = ( out ) ? out.slice() : []; - if ( FLG && out.length > 0 ) { - out.push( 'generic' ); - } - return out; -} - - -// EXPORTS // - -module.exports = dtypes; diff --git a/dtypes/package.json b/dtypes/package.json deleted file mode 100644 index d7019ec85..000000000 --- a/dtypes/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/dtypes", - "version": "0.0.0", - "description": "List of array data types.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "typed", - "array", - "dtypes", - "dtype", - "data", - "type", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/dtypes/test/test.js b/dtypes/test/test.js deleted file mode 100644 index 2f27dac27..000000000 --- a/dtypes/test/test.js +++ /dev/null @@ -1,621 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dtypes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a list of array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'bool', - 'complex64', - 'complex128', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - actual = dtypes(); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of array data types (all)', function test( t ) { - var expected; - var actual; - - expected = [ - 'bool', - 'complex64', - 'complex128', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - actual = dtypes( 'all' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of array data types (all, including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'bool', - 'complex64', - 'complex128', - 'float32', - 'float64', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - actual = dtypes( 'all_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of array data types (typed)', function test( t ) { - var expected; - var actual; - - expected = [ - 'bool', - 'complex64', - 'complex128', - 'float32', - 'float64', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - actual = dtypes( 'typed' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of array data types (typed, including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'bool', - 'complex64', - 'complex128', - 'float32', - 'float64', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'generic' - ]; - actual = dtypes( 'typed_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of floating-point array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'complex64', - 'complex128', - 'float32', - 'float64' - ]; - actual = dtypes( 'floating_point' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of floating-point array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'complex64', - 'complex128', - 'float32', - 'float64', - 'generic' - ]; - actual = dtypes( 'floating_point_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of real-valued floating-point array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'float32', - 'float64' - ]; - actual = dtypes( 'real_floating_point' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of real-valued floating-point array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'float32', - 'float64', - 'generic' - ]; - actual = dtypes( 'real_floating_point_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of complex-valued floating-point array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'complex64', - 'complex128' - ]; - actual = dtypes( 'complex_floating_point' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of complex-valued floating-point array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'complex64', - 'complex128', - 'generic' - ]; - actual = dtypes( 'complex_floating_point_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of boolean array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'bool' - ]; - actual = dtypes( 'boolean' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of boolean array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'bool', - 'generic' - ]; - actual = dtypes( 'boolean_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of integer array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - actual = dtypes( 'integer' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of integer array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'generic' - ]; - actual = dtypes( 'integer_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of signed integer array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'int16', - 'int32', - 'int8' - ]; - actual = dtypes( 'signed_integer' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of signed integer array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'int16', - 'int32', - 'int8', - 'generic' - ]; - actual = dtypes( 'signed_integer_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of unsigned integer array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - actual = dtypes( 'unsigned_integer' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of unsigned integer array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'generic' - ]; - actual = dtypes( 'unsigned_integer_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of real-valued array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'float32', - 'float64', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - actual = dtypes( 'real' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of real-valued array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'float32', - 'float64', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'generic' - ]; - actual = dtypes( 'real_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of numeric array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'complex64', - 'complex128', - 'float32', - 'float64', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - actual = dtypes( 'numeric' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of numeric array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'complex64', - 'complex128', - 'float32', - 'float64', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'generic' - ]; - actual = dtypes( 'numeric_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of integer index array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'int32' - ]; - actual = dtypes( 'integer_index' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of integer index array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'int32', - 'generic' - ]; - actual = dtypes( 'integer_index_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of boolean index array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'bool' - ]; - actual = dtypes( 'boolean_index' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of boolean index array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'bool', - 'generic' - ]; - actual = dtypes( 'boolean_index_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of mask index array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'uint8' - ]; - actual = dtypes( 'mask_index' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of mask index array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'uint8', - 'generic' - ]; - actual = dtypes( 'mask_index_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of typed index array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'int32', - 'uint8', - 'bool' - ]; - actual = dtypes( 'typed_index' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of typed index array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'int32', - 'uint8', - 'bool', - 'generic' - ]; - actual = dtypes( 'typed_index_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of index array data types', function test( t ) { - var expected; - var actual; - - expected = [ - 'int32', - 'uint8', - 'bool', - 'generic' - ]; - actual = dtypes( 'index' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports returning a list of index array data types (including "generic")', function test( t ) { - var expected; - var actual; - - expected = [ - 'int32', - 'uint8', - 'bool', - 'generic' - ]; - actual = dtypes( 'index_and_generic' ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an unrecognized data type kind', function test( t ) { - t.deepEqual( dtypes( 'beep' ), [], 'returns expected value' ); - t.deepEqual( dtypes( 'beep_and_generic' ), [], 'returns expected value' ); - t.deepEqual( dtypes( 'generic' ), [], 'returns expected value' ); - t.deepEqual( dtypes( '_and_generic' ), [], 'returns expected value' ); - t.deepEqual( dtypes( '' ), [], 'returns expected value' ); - t.end(); -}); diff --git a/empty-like/README.md b/empty-like/README.md deleted file mode 100644 index a7511bfb2..000000000 --- a/empty-like/README.md +++ /dev/null @@ -1,161 +0,0 @@ - - -# emptyLike - -> Create an uninitialized array having the same length and data type as a provided array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var emptyLike = require( '@stdlib/array/empty-like' ); -``` - -#### emptyLike( x\[, dtype] ) - -Creates an uninitialized array having the same length and [data type][@stdlib/array/dtypes] as a provided array `x`. - -```javascript -var x = [ 1, 2, 3, 4, 5 ]; - -var arr = emptyLike( x ); -// returns [ 0, 0, 0, 0, 0 ]; -``` - -By default, the output array [data type][@stdlib/array/dtypes] is inferred from the provided array `x`. To return an array having a different [data type][@stdlib/array/dtypes], provide a `dtype` argument. - -```javascript -var x = [ 1, 1 ]; - -var arr = emptyLike( x, 'int32' ); -// returns -``` - -
- - - - - -
- -## Notes - -- In browser environments, the function always returns zero-filled arrays. -- If `dtype` is `'generic'`, the function always returns a zero-filled array. -- In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. - -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var zeros = require( '@stdlib/array/zeros' ); -var emptyLike = require( '@stdlib/array/empty-like' ); - -// Create a zero-filled array: -var x = zeros( 4, 'complex128' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate empty arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = emptyLike( x, dt[ i ] ); - console.log( arr ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/empty-like/benchmark/benchmark.js b/empty-like/benchmark/benchmark.js deleted file mode 100644 index 4a456c92d..000000000 --- a/empty-like/benchmark/benchmark.js +++ /dev/null @@ -1,339 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'bool' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex128' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8c' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'generic' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/empty-like/benchmark/benchmark.length.bool.js b/empty-like/benchmark/benchmark.length.bool.js deleted file mode 100644 index bc60d612f..000000000 --- a/empty-like/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'bool' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.complex128.js b/empty-like/benchmark/benchmark.length.complex128.js deleted file mode 100644 index c24784c21..000000000 --- a/empty-like/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex128' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.complex64.js b/empty-like/benchmark/benchmark.length.complex64.js deleted file mode 100644 index a9e06f118..000000000 --- a/empty-like/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.float32.js b/empty-like/benchmark/benchmark.length.float32.js deleted file mode 100644 index 4aa321959..000000000 --- a/empty-like/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.float64.js b/empty-like/benchmark/benchmark.length.float64.js deleted file mode 100644 index 8f05f52f3..000000000 --- a/empty-like/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.generic.js b/empty-like/benchmark/benchmark.length.generic.js deleted file mode 100644 index 57d54b374..000000000 --- a/empty-like/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.int16.js b/empty-like/benchmark/benchmark.length.int16.js deleted file mode 100644 index df51c358a..000000000 --- a/empty-like/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.int32.js b/empty-like/benchmark/benchmark.length.int32.js deleted file mode 100644 index 22770d85c..000000000 --- a/empty-like/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.int8.js b/empty-like/benchmark/benchmark.length.int8.js deleted file mode 100644 index 4ca8ac68c..000000000 --- a/empty-like/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.uint16.js b/empty-like/benchmark/benchmark.length.uint16.js deleted file mode 100644 index a2e840674..000000000 --- a/empty-like/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.uint32.js b/empty-like/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 4d3cbf1fa..000000000 --- a/empty-like/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.uint8.js b/empty-like/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 020b6c1fe..000000000 --- a/empty-like/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/empty-like/benchmark/benchmark.length.uint8c.js b/empty-like/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 071ece7f0..000000000 --- a/empty-like/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var emptyLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8c' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = emptyLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/empty-like/docs/repl.txt b/empty-like/docs/repl.txt deleted file mode 100644 index 16de82e7f..000000000 --- a/empty-like/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( x[, dtype] ) - Creates an uninitialized array having the same length and data type as a - provided input array. - - In browser environments, the function always returns zero-filled arrays. - - If `dtype` is 'generic', the function always returns a zero-filled array. - - In Node.js versions >=3.0.0, the underlying memory of returned typed arrays - is *not* initialized. Memory contents are unknown and may contain - *sensitive* data. - - Parameters - ---------- - x: TypedArray|Array - Input array. - - dtype: string (optional) - Data type. If not provided, the output array data type is inferred from - the input array. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var x = new {{alias:@stdlib/array/float64}}( 2 ); - > var arr = {{alias}}( x ) - - > arr = {{alias}}( x, 'float32' ) - - - See Also - -------- - diff --git a/empty-like/docs/types/index.d.ts b/empty-like/docs/types/index.d.ts deleted file mode 100644 index 6f8397c49..000000000 --- a/empty-like/docs/types/index.d.ts +++ /dev/null @@ -1,96 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { AnyArray, DataTypeMap, TypedArray, BooleanTypedArray, ComplexTypedArray } from '@stdlib/types/array'; - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'generic' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x ); -* // returns [ 0.0, 0.0 ] -*/ -declare function emptyLike( x: Array ): Array; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'float32' ); -* // returns -*/ -declare function emptyLike( x: T ): T; - -/** -* Creates an uninitialized array having the same length as a provided input array. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - If `dtype` is `'generic'`, the function always returns a zero-filled array. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns empty array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var arr = emptyLike( x, 'float32' ); -* // returns -*/ -declare function emptyLike>( x: AnyArray, dtype: T ): DataTypeMap[T]; - - -// EXPORTS // - -export = emptyLike; diff --git a/empty-like/docs/types/test.ts b/empty-like/docs/types/test.ts deleted file mode 100644 index 20201b3c9..000000000 --- a/empty-like/docs/types/test.ts +++ /dev/null @@ -1,100 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import BooleanArray = require( './../../../bool' ); -import emptyLike = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - emptyLike( [ 0, 0 ] ); // $ExpectType number[] - emptyLike( new Float64Array( [ 0, 0 ] ) ); // $ExpectType Float64Array - emptyLike( new Float32Array( [ 0, 0 ] ) ); // $ExpectType Float32Array - emptyLike( new Complex128Array( [ 0, 0 ] ) ); // $ExpectType Complex128Array - emptyLike( new Complex128Array( [ 0, 0 ] ) ); // $ExpectType Complex128Array - emptyLike( new Complex64Array( [ 0, 0 ] ) ); // $ExpectType Complex64Array - emptyLike( new Complex64Array( [ 0, 0 ] ) ); // $ExpectType Complex64Array - emptyLike( new Int32Array( [ 0, 0 ] ) ); // $ExpectType Int32Array - emptyLike( new Int16Array( [ 0, 0 ] ) ); // $ExpectType Int16Array - emptyLike( new Int8Array( [ 0, 0 ] ) ); // $ExpectType Int8Array - emptyLike( new Uint32Array( [ 0, 0 ] ) ); // $ExpectType Uint32Array - emptyLike( new Uint16Array( [ 0, 0 ] ) ); // $ExpectType Uint16Array - emptyLike( new Uint8Array( [ 0, 0 ] ) ); // $ExpectType Uint8Array - emptyLike( new Uint8ClampedArray( [ 0, 0 ] ) ); // $ExpectType Uint8ClampedArray - emptyLike( new BooleanArray( [ 0, 0 ] ) ); // $ExpectType BooleanArray - emptyLike( [ 'a', 'b', 'c' ] ); // $ExpectType number[] - - emptyLike( [ 0, 0 ], 'float64' ); // $ExpectType Float64Array - emptyLike( [ 0, 0 ], 'float32' ); // $ExpectType Float32Array - emptyLike( [ 0, 0 ], 'complex128' ); // $ExpectType Complex128Array - emptyLike( [ 0, 0 ], 'complex128' ); // $ExpectType Complex128Array - emptyLike( [ 0, 0 ], 'complex64' ); // $ExpectType Complex64Array - emptyLike( [ 0, 0 ], 'complex64' ); // $ExpectType Complex64Array - emptyLike( [ 0, 0 ], 'bool' ); // $ExpectType BooleanArray - emptyLike( [ 0, 0 ], 'int32' ); // $ExpectType Int32Array - emptyLike( [ 0, 0 ], 'int16' ); // $ExpectType Int16Array - emptyLike( [ 0, 0 ], 'int8' ); // $ExpectType Int8Array - emptyLike( [ 0, 0 ], 'uint32' ); // $ExpectType Uint32Array - emptyLike( [ 0, 0 ], 'uint16' ); // $ExpectType Uint16Array - emptyLike( [ 0, 0 ], 'uint8' ); // $ExpectType Uint8Array - emptyLike( [ 0, 0 ], 'uint8c' ); // $ExpectType Uint8ClampedArray - emptyLike( [ 0, 0 ], 'generic' ); // $ExpectType number[] - emptyLike( new Int32Array( [ 0, 0 ] ), 'generic' ); // $ExpectType number[] - emptyLike( [ 'a', 'b', 'c' ], 'generic' ); // $ExpectType number[] - emptyLike( [ 'a', 'b', 'c' ], 'float64' ); // $ExpectType Float64Array -} - -// The compiler throws an error if the function is not provided an array or typed array for the first argument... -{ - emptyLike( '5' ); // $ExpectError - emptyLike( false ); // $ExpectError - emptyLike( true ); // $ExpectError - emptyLike( null ); // $ExpectError - emptyLike( undefined ); // $ExpectError - emptyLike( {} ); // $ExpectError - emptyLike( ( x: number ): number => x ); // $ExpectError - - emptyLike( '5', 'float32' ); // $ExpectError - emptyLike( false, 'float32' ); // $ExpectError - emptyLike( true, 'float32' ); // $ExpectError - emptyLike( null, 'float32' ); // $ExpectError - emptyLike( undefined, 'float32' ); // $ExpectError - emptyLike( {}, 'float32' ); // $ExpectError - emptyLike( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - emptyLike( [ 0, 0 ], '10' ); // $ExpectError - emptyLike( [ 0, 0 ], 10 ); // $ExpectError - emptyLike( [ 0, 0 ], false ); // $ExpectError - emptyLike( [ 0, 0 ], true ); // $ExpectError - emptyLike( [ 0, 0 ], null ); // $ExpectError - emptyLike( [ 0, 0 ], [] ); // $ExpectError - emptyLike( [ 0, 0 ], {} ); // $ExpectError - emptyLike( [ 0, 0 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - emptyLike( [ 0, 0 ], 'float64', 1 ); // $ExpectError -} diff --git a/empty-like/examples/index.js b/empty-like/examples/index.js deleted file mode 100644 index cd0df9240..000000000 --- a/empty-like/examples/index.js +++ /dev/null @@ -1,37 +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'; - -var dtypes = require( './../../dtypes' ); -var zeros = require( './../../zeros' ); -var emptyLike = require( './../lib' ); - -// Create a zero-filled array: -var x = zeros( 4, 'complex128' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate empty arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = emptyLike( x, dt[ i ] ); - console.log( arr ); -} diff --git a/empty-like/lib/index.js b/empty-like/lib/index.js deleted file mode 100644 index a8d8a8bd6..000000000 --- a/empty-like/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Create an uninitialized array having the same length and data type as a provided input array. -* -* @module @stdlib/array/empty-like -* -* @example -* var emptyLike = require( '@stdlib/array/empty-like' ); -* -* var arr = emptyLike( [ 0.0, 0.0 ] ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var emptyLike = require( '@stdlib/array/empty-like' ); -* -* var arr = emptyLike( [ 0.0, 0.0 ], 'float32' ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/empty-like/lib/main.js b/empty-like/lib/main.js deleted file mode 100644 index 3de22bda7..000000000 --- a/empty-like/lib/main.js +++ /dev/null @@ -1,61 +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 dtype = require( './../../dtype' ); -var empty = require( './../../empty' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Creates an uninitialized array having the same length and data type as a provided input array. -* -* @param {(Array|TypedArray|ComplexArray)} x - input array -* @param {string} [dtype] - data type -* @throws {TypeError} first argument must be an array or typed array -* @throws {TypeError} second argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = emptyLike( [ 0.0, 0.0 ] ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = emptyLike( [ 0.0, 0.0 ], 'float32' ); -* // returns -*/ -function emptyLike( x ) { - var dt = dtype( x ); // delegate input argument validation to dtype resolution - if ( dt === null ) { - throw new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) ); - } - if ( arguments.length > 1 ) { - dt = arguments[ 1 ]; - } - return empty( x.length, dt ); -} - - -// EXPORTS // - -module.exports = emptyLike; diff --git a/empty-like/package.json b/empty-like/package.json deleted file mode 100644 index d4e5f23b0..000000000 --- a/empty-like/package.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "name": "@stdlib/array/empty-like", - "version": "0.0.0", - "description": "Create an uninitialized array having the same length and data type as a provided array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "booleanarray", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "bool", - "generic", - "empty", - "empty-like" - ] -} diff --git a/empty-like/test/test.js b/empty-like/test/test.js deleted file mode 100644 index 8b685be45..000000000 --- a/empty-like/test/test.js +++ /dev/null @@ -1,477 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var emptyLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof emptyLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'emptyLike', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - emptyLike( [], value ); - }; - } -}); - -tape( 'the function returns an empty array (float64)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 5 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=float64)', function test( t ) { - var arr; - var x; - - x = new Float32Array( 5 ); - - arr = emptyLike( x, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (float32)', function test( t ) { - var arr; - var x; - - x = new Float32Array( 5 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=float32)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 5 ); - - arr = emptyLike( x, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (bool)', function test( t ) { - var arr; - var x; - - x = new BooleanArray( 2 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=bool)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 5 ); - - arr = emptyLike( x, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (complex128)', function test( t ) { - var arr; - var x; - - x = new Complex128Array( 2 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=complex128)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 2 ); - - arr = emptyLike( x, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (complex64)', function test( t ) { - var arr; - var x; - - x = new Complex64Array( 2 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=complex64)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 2 ); - - arr = emptyLike( x, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (int32)', function test( t ) { - var arr; - var x; - - x = new Int32Array( 5 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=int32)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 5 ); - - arr = emptyLike( x, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (uint32)', function test( t ) { - var arr; - var x; - - x = new Uint32Array( 5 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=uint32)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 5 ); - - arr = emptyLike( x, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (int16)', function test( t ) { - var arr; - var x; - - x = new Int16Array( 5 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=int16)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 5 ); - - arr = emptyLike( x, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (uint16)', function test( t ) { - var arr; - var x; - - x = new Uint16Array( 5 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=uint16)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 5 ); - - arr = emptyLike( x, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (int8)', function test( t ) { - var arr; - var x; - - x = new Int8Array( 5 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=int8)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 5 ); - - arr = emptyLike( x, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (uint8)', function test( t ) { - var arr; - var x; - - x = new Uint8Array( 5 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=uint8)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 5 ); - - arr = emptyLike( x, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (uint8c)', function test( t ) { - var arr; - var x; - - x = new Uint8ClampedArray( 5 ); - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=uint8c)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 5 ); - - arr = emptyLike( x, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (generic)', function test( t ) { - var arr; - var x; - - x = [ 1, 2, 3, 4, 5 ]; - - arr = emptyLike( x ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=generic)', function test( t ) { - var arr; - var x; - - x = new Float64Array( 5 ); - - arr = emptyLike( x, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - t.end(); -}); diff --git a/empty/README.md b/empty/README.md deleted file mode 100644 index dd19f0939..000000000 --- a/empty/README.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# empty - -> Create an uninitialized array having a specified length. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var empty = require( '@stdlib/array/empty' ); -``` - -#### empty( length\[, dtype] ) - -Creates an uninitialized array having a specified length. - -```javascript -var arr = empty( 2 ); -// returns -``` - -By default, the output array [data type][@stdlib/array/dtypes] is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative [data type][@stdlib/array/dtypes], provide a `dtype` argument. - -```javascript -var arr = empty( 2, 'int32' ); -// returns -``` - -
- - - - - -
- -## Notes - -- In browser environments, the function always returns zero-filled arrays. -- If `dtype` is `'generic'`, the function always returns a zero-filled array. -- In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. - -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var empty = require( '@stdlib/array/empty' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate empty arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( 4, dt[ i ] ); - console.log( arr ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/empty/benchmark/benchmark.js b/empty/benchmark/benchmark.js deleted file mode 100644 index 7f7ffb83c..000000000 --- a/empty/benchmark/benchmark.js +++ /dev/null @@ -1,282 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( 0, 'generic' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/empty/benchmark/benchmark.length.bool.js b/empty/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3b1bf8d87..000000000 --- a/empty/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.complex128.js b/empty/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 03a6aec59..000000000 --- a/empty/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.complex64.js b/empty/benchmark/benchmark.length.complex64.js deleted file mode 100644 index c21e4469a..000000000 --- a/empty/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.float32.js b/empty/benchmark/benchmark.length.float32.js deleted file mode 100644 index 18ce2885e..000000000 --- a/empty/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.float64.js b/empty/benchmark/benchmark.length.float64.js deleted file mode 100644 index ff0d09fff..000000000 --- a/empty/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.generic.js b/empty/benchmark/benchmark.length.generic.js deleted file mode 100644 index 553c67cfd..000000000 --- a/empty/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'generic' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.int16.js b/empty/benchmark/benchmark.length.int16.js deleted file mode 100644 index 4c7ced1fd..000000000 --- a/empty/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.int32.js b/empty/benchmark/benchmark.length.int32.js deleted file mode 100644 index e99124b6f..000000000 --- a/empty/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.int8.js b/empty/benchmark/benchmark.length.int8.js deleted file mode 100644 index dfe7ce82a..000000000 --- a/empty/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.uint16.js b/empty/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 661def499..000000000 --- a/empty/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.uint32.js b/empty/benchmark/benchmark.length.uint32.js deleted file mode 100644 index f1719042a..000000000 --- a/empty/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.uint8.js b/empty/benchmark/benchmark.length.uint8.js deleted file mode 100644 index d2106d864..000000000 --- a/empty/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/empty/benchmark/benchmark.length.uint8c.js b/empty/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 16d786b0c..000000000 --- a/empty/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var empty = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = empty( len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/empty/docs/repl.txt b/empty/docs/repl.txt deleted file mode 100644 index 2411a6917..000000000 --- a/empty/docs/repl.txt +++ /dev/null @@ -1,35 +0,0 @@ - -{{alias}}( length[, dtype] ) - Creates an uninitialized array having a specified length. - - In browser environments, the function always returns zero-filled arrays. - - If `dtype` is 'generic', the function always returns a zero-filled array. - - In Node.js versions >=3.0.0, the underlying memory of returned typed arrays - is *not* initialized. Memory contents are unknown and may contain - *sensitive* data. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 2 ) - - > arr = {{alias}}( 2, 'float32' ) - - - See Also - -------- - diff --git a/empty/docs/types/index.d.ts b/empty/docs/types/index.d.ts deleted file mode 100644 index 598c2b369..000000000 --- a/empty/docs/types/index.d.ts +++ /dev/null @@ -1,51 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { DataTypeMap } from '@stdlib/types/array'; - -/** -* Creates an uninitialized array having a specified length. -* -* ## Notes -* -* - In browser environments, the function always returns zero-filled arrays. -* - If `dtype` is `'generic'`, the function always returns a zero-filled array. -* - In Node.js versions `>=3.0.0`, the underlying memory of returned typed arrays is **not** initialized. Memory contents are unknown and may contain **sensitive** data. -* -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns empty array -* -* @example -* var arr = empty( 2 ); -* // returns -* -* @example -* var arr = empty( 2, 'float32' ); -* // returns -*/ -declare function empty = 'float64'>( length: number, dtype?: T ): DataTypeMap[T]; - - -// EXPORTS // - -export = empty; diff --git a/empty/docs/types/test.ts b/empty/docs/types/test.ts deleted file mode 100644 index 78de0828f..000000000 --- a/empty/docs/types/test.ts +++ /dev/null @@ -1,78 +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. -*/ - -import empty = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - empty( 10 ); // $ExpectType Float64Array - empty( 10, 'float64' ); // $ExpectType Float64Array - empty( 10, 'float32' ); // $ExpectType Float32Array - empty( 10, 'complex128' ); // $ExpectType Complex128Array - empty( 10, 'complex64' ); // $ExpectType Complex64Array - empty( 10, 'bool' ); // $ExpectType BooleanArray - empty( 10, 'int32' ); // $ExpectType Int32Array - empty( 10, 'int16' ); // $ExpectType Int16Array - empty( 10, 'int8' ); // $ExpectType Int8Array - empty( 10, 'uint32' ); // $ExpectType Uint32Array - empty( 10, 'uint16' ); // $ExpectType Uint16Array - empty( 10, 'uint8' ); // $ExpectType Uint8Array - empty( 10, 'uint8c' ); // $ExpectType Uint8ClampedArray - empty( 10, 'generic' ); // $ExpectType number[] -} - -// The compiler throws an error if the function is not provided a number for the first argument... -{ - empty( '5' ); // $ExpectError - empty( false ); // $ExpectError - empty( true ); // $ExpectError - empty( null ); // $ExpectError - empty( undefined ); // $ExpectError - empty( [] ); // $ExpectError - empty( {} ); // $ExpectError - empty( ( x: number ): number => x ); // $ExpectError - - empty( '5', 'float32' ); // $ExpectError - empty( false, 'float32' ); // $ExpectError - empty( true, 'float32' ); // $ExpectError - empty( null, 'float32' ); // $ExpectError - empty( undefined, 'float32' ); // $ExpectError - empty( [], 'float32' ); // $ExpectError - empty( {}, 'float32' ); // $ExpectError - empty( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - empty( 10, '10' ); // $ExpectError - empty( 10, 10 ); // $ExpectError - empty( 10, false ); // $ExpectError - empty( 10, true ); // $ExpectError - empty( 10, null ); // $ExpectError - empty( 10, [] ); // $ExpectError - empty( 10, {} ); // $ExpectError - empty( 10, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - empty( 10, 'float64', 1 ); // $ExpectError -} diff --git a/empty/examples/index.js b/empty/examples/index.js deleted file mode 100644 index 3f250c313..000000000 --- a/empty/examples/index.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'; - -var dtypes = require( './../../dtypes' ); -var empty = require( './../lib' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate empty arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = empty( 4, dt[ i ] ); - console.log( arr ); -} diff --git a/empty/lib/index.js b/empty/lib/index.js deleted file mode 100644 index 103bbbb18..000000000 --- a/empty/lib/index.js +++ /dev/null @@ -1,58 +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'; - -/** -* Create an uninitialized array having a specified length. -* -* @module @stdlib/array/empty -* -* @example -* var empty = require( '@stdlib/array/empty' ); -* -* var arr = empty( 2 ); -* // returns -* -* @example -* var empty = require( '@stdlib/array/empty' ); -* -* var arr = empty( 2, 'float32' ); -* // returns -*/ - -// MODULES // - -var isBufferUint8Array = require( './is_buffer_uint8array.js' ); -var main = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var empty; -if ( isBufferUint8Array() ) { - empty = main; -} else { - empty = polyfill; -} - - -// EXPORTS // - -module.exports = empty; diff --git a/empty/lib/is_buffer_uint8array.js b/empty/lib/is_buffer_uint8array.js deleted file mode 100644 index e9a918c9d..000000000 --- a/empty/lib/is_buffer_uint8array.js +++ /dev/null @@ -1,47 +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 allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); - - -// MAIN // - -/** -* Checks whether an environment supports Node.js buffer instances which inherit from `Uint8Array`. -* -* @private -* @returns {boolean} boolean indicating whether an environment supports Node.js buffer instances inheriting from `Uint8Array` -* -* @example -* var bool = check(); -* // returns -*/ -function check() { - var buf = allocUnsafe( 1 ); - return isUint8Array( buf ); -} - - -// EXPORTS // - -module.exports = check; diff --git a/empty/lib/main.js b/empty/lib/main.js deleted file mode 100644 index dab5ed2f5..000000000 --- a/empty/lib/main.js +++ /dev/null @@ -1,107 +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 isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' ); -var ctors = require( './../../typed-ctors' ); -var zeros = require( './../../base/zeros' ); -var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); -var defaults = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// MAIN // - -/** -* Creates an uninitialized array having a specified length. -* -* @param {NonNegativeInteger} length - array length -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = empty( 2 ); -* // returns -* -* @example -* var arr = empty( 2, 'float32' ); -* // returns -*/ -function empty( length ) { - var nbytes; - var offset; - var dtype; - var ctor; - var buf; - var out; - var nb; - - if ( !isNonNegativeInteger( length ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', length ) ); - } - if ( arguments.length > 1 ) { - dtype = arguments[ 1 ]; - } else { - dtype = DEFAULT_DTYPE; - } - if ( dtype === 'generic' ) { - return zeros( length ); - } - nbytes = bytesPerElement( dtype ); - if ( nbytes === null ) { - throw new TypeError( format( 'invalid argument. Second argument must be a supported data type. Value: `%s`.', dtype ) ); - } - // Resolve typed array constructor: - ctor = ctors( dtype ); - - // Compute the number of bytes to allocate: - nb = nbytes * length; - if ( dtype === 'complex128' ) { - nb += 8; // Note: need to allocate additional bytes to ensure alignment - } - // Allocate binary buffer: - buf = allocUnsafe( nb ); - - // Resolve the byte offset: - offset = buf.byteOffset; - if ( dtype === 'complex128' ) { - if ( !isNonNegativeInteger( offset/nbytes ) ) { - offset += 8; // Note: ensure alignment - } - } - // Reinterpret the binary buffer: - out = new ctor( buf.buffer, offset, length ); - - return out; -} - - -// EXPORTS // - -module.exports = empty; diff --git a/empty/lib/polyfill.js b/empty/lib/polyfill.js deleted file mode 100644 index 75eecf2c3..000000000 --- a/empty/lib/polyfill.js +++ /dev/null @@ -1,56 +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 zeros = require( './../../zeros' ); - - -// MAIN // - -/** -* Creates an uninitialized array having a specified length. -* -* @private -* @param {NonNegativeInteger} length - array length -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = empty( 2 ); -* // returns -* -* @example -* var arr = empty( 2, 'float32' ); -* // returns -*/ -function empty( length ) { - if ( arguments.length > 1 ) { - return zeros( length, arguments[ 1 ] ); - } - return zeros( length ); -} - - -// EXPORTS // - -module.exports = empty; diff --git a/empty/package.json b/empty/package.json deleted file mode 100644 index fbc53bc9e..000000000 --- a/empty/package.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "name": "@stdlib/array/empty", - "version": "0.0.0", - "description": "Create an uninitialized array having a specified length.", - "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", - "browser": "./lib/polyfill.js", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "bool", - "empty" - ] -} diff --git a/empty/test/test.js b/empty/test/test.js deleted file mode 100644 index 8e62cb82a..000000000 --- a/empty/test/test.js +++ /dev/null @@ -1,60 +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 proxyquire = require( 'proxyquire' ); -var main = require( './../lib/main.js' ); -var polyfill = require( './../lib/polyfill.js' ); -var empty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports Node.js buffer instances inheriting from Uint8Array, the main export supports returning arrays having uninitialized memory', function test( t ) { - var empty = proxyquire( './../lib', { - './is_buffer_uint8array.js': mock - }); - t.strictEqual( empty, main, 'returns expected value' ); - t.end(); - - function mock() { - return true; - } -}); - -tape( 'if an environment does not support Node.js buffer instances inheriting from Uint8Array, the main export supports returning zero-filled arrays', function test( t ) { - var empty = proxyquire( './../lib', { - './is_buffer_uint8array.js': mock - }); - t.strictEqual( empty, polyfill, 'returns expected value' ); - t.end(); - - function mock() { - return false; - } -}); diff --git a/empty/test/test.main.js b/empty/test/test.main.js deleted file mode 100644 index 89545c52a..000000000 --- a/empty/test/test.main.js +++ /dev/null @@ -1,285 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var empty = require( './../lib/main.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( 10, value ); - }; - } -}); - -tape( 'the function returns an empty array (default)', function test( t ) { - var arr; - - arr = empty( 5 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=float64)', function test( t ) { - var arr; - - arr = empty( 5, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=float32)', function test( t ) { - var arr; - - arr = empty( 5, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=bool)', function test( t ) { - var arr; - - arr = empty( 5, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=complex128)', function test( t ) { - var arr; - - arr = empty( 5, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=complex64)', function test( t ) { - var arr; - - arr = empty( 5, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=int32)', function test( t ) { - var arr; - - arr = empty( 5, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=uint32)', function test( t ) { - var arr; - - arr = empty( 5, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=int16)', function test( t ) { - var arr; - - arr = empty( 5, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=uint16)', function test( t ) { - var arr; - - arr = empty( 5, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=int8)', function test( t ) { - var arr; - - arr = empty( 5, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=uint8)', function test( t ) { - var arr; - - arr = empty( 5, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array (dtype=uint8c)', function test( t ) { - var arr; - - arr = empty( 5, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = empty( 5, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/empty/test/test.polyfill.js b/empty/test/test.polyfill.js deleted file mode 100644 index c63985d3b..000000000 --- a/empty/test/test.polyfill.js +++ /dev/null @@ -1,340 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var empty = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof empty, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'empty', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - empty( 10, value ); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = empty( 5 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = empty( 5, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = empty( 5, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=bool)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = empty( 4, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = empty( 2, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = empty( 2, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = empty( 5, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = empty( 5, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = empty( 5, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = empty( 5, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = empty( 5, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = empty( 5, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = empty( 5, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = empty( 5, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c7e940d87..000000000 --- a/examples/index.js +++ /dev/null @@ -1,24 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - -console.log( objectKeys( ns ) ); diff --git a/filled-by/README.md b/filled-by/README.md deleted file mode 100644 index 6ca6fb434..000000000 --- a/filled-by/README.md +++ /dev/null @@ -1,261 +0,0 @@ - - -# filledarrayBy - -> Create a filled array according to a provided callback function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filledarrayBy = require( '@stdlib/array/filled-by' ); -``` - -#### filledarrayBy( \[dtype] ) - -Creates a filled array having a specified [data type][@stdlib/array/dtypes] `dtype`. - -```javascript -var arr = filledarrayBy(); -// returns -``` - -By default, the output array [data type][@stdlib/array/dtypes] is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative [data type][@stdlib/array/dtypes], provide a `dtype` argument. - -```javascript -var arr = filledarrayBy( 'int32' ); -// returns -``` - -#### filledarrayBy( length\[, dtype], clbk\[, thisArg] ) - -Returns a filled array according to a provided callback function and having a specified `length`. - -```javascript -function constant() { - return 1.0; -} - -var arr1 = filledarrayBy( 5, constant ); -// returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - -var arr2 = filledarrayBy( 5, 'uint8', constant ); -// returns [ 1, 1, 1, 1, 1 ] -``` - -#### filledarrayBy( array\[, dtype], clbk\[, thisArg] ) - -Creates a filled array from another array (or array-like object) according to a provided callback function. - -```javascript -var arr0 = { - '0': 0.5, - '1': 0.5, - '2': 0.5, - 'length': 3 -}; - -function clbk1() { - return 1.0; -} -var arr1 = filledarrayBy( arr0, clbk1 ); -// returns [ 1.0, 1.0, 1.0 ] - -function clbk2() { - return 2.0; -} -var arr2 = filledarrayBy( arr1, clbk2 ); -// returns [ 2.0, 2.0, 2.0 ] - -function clbk3() { - return 3.0; -} -var arr3 = filledarrayBy( arr1, 'int32', clbk3 ); -// returns [ 3, 3, 3 ] -``` - -#### filledarrayBy( iterable\[, dtype], clbk\[, thisArg] ) - -Creates a filled array from an iterable according to a provided callback function. - -```javascript -var iterConstant = require( '@stdlib/iter/constant' ); - -function clbk() { - return 1.0; -} - -var it = iterConstant( 3.0, { - 'iter': 3 -}); - -var arr1 = filledarrayBy( it, clbk ); -// returns [ 1.0, 1.0, 1.0 ] - -var arr2 = filledarrayBy( it, 'float32', clbk ); -// returns [ 1.0, 1.0, 1.0 ] -``` - -#### filledarrayBy( buffer\[, byteOffset\[, length]]\[, dtype], clbk\[, thisArg] ) - -Returns a filled [typed array][mdn-typed-array] view of an [`ArrayBuffer`][mdn-arraybuffer] according to a provided callback function. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -function clbk() { - return 1.0; -} - -var buf = new ArrayBuffer( 32 ); -var arr = filledarrayBy( buf, clbk ); -// returns [ 1.0, 1.0, 1.0, 1.0 ] - -buf = new ArrayBuffer( 32 ); -arr = filledarrayBy( buf, 'float32', clbk ); -// returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] - -buf = new ArrayBuffer( 32 ); -arr = filledarrayBy( buf, 16, clbk ); -// returns [ 1.0, 1.0 ] - -buf = new ArrayBuffer( 32 ); -arr = filledarrayBy( buf, 16, 'float32', clbk ); -// returns [ 1.0, 1.0, 1.0, 1.0 ] - -buf = new ArrayBuffer( 32 ); -arr = filledarrayBy( buf, 16, 1, clbk ); -// returns [ 1.0 ] - -buf = new ArrayBuffer( 32 ); -arr = filledarrayBy( buf, 10, 4, 'int16', clbk ); -// returns [ 1, 1, 1, 1 ] -``` - -
- - - - - -
- -## Notes - -- Creating a generic [array][mdn-array] from an [`ArrayBuffer`][mdn-arraybuffer] is **not** supported. - -- A callback function is provided a single argument: - - - **index**: the current array index. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var dtypes = require( '@stdlib/array/typed-real-dtypes' ); -var filledarrayBy = require( '@stdlib/array/filled-by' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/filled-by/benchmark/benchmark.js b/filled-by/benchmark/benchmark.js deleted file mode 100644 index 0838b1cae..000000000 --- a/filled-by/benchmark/benchmark.js +++ /dev/null @@ -1,341 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var filledarrayBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float64', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'float32', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( true ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'bool', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex128', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'complex64', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int32', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint32', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int16', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint16', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'int8', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'uint8c', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarrayBy( 0, 'generic', clbk ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/filled-by/benchmark/benchmark.length.bool.js b/filled-by/benchmark/benchmark.length.bool.js deleted file mode 100644 index 4f1e81ffa..000000000 --- a/filled-by/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( true ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'bool', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.complex128.js b/filled-by/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 9cb7fbce3..000000000 --- a/filled-by/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex128( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex128', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.complex64.js b/filled-by/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 3f91f18bb..000000000 --- a/filled-by/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( new Complex64( 3.0, 5.0 ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'complex64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.float32.js b/filled-by/benchmark/benchmark.length.float32.js deleted file mode 100644 index e0a99ea0d..000000000 --- a/filled-by/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.float64.js b/filled-by/benchmark/benchmark.length.float64.js deleted file mode 100644 index 9f191d38c..000000000 --- a/filled-by/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'float64', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.generic.js b/filled-by/benchmark/benchmark.length.generic.js deleted file mode 100644 index 746b7c9bc..000000000 --- a/filled-by/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'generic', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.int16.js b/filled-by/benchmark/benchmark.length.int16.js deleted file mode 100644 index bcfac762e..000000000 --- a/filled-by/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.int32.js b/filled-by/benchmark/benchmark.length.int32.js deleted file mode 100644 index 0b9f1951a..000000000 --- a/filled-by/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.int8.js b/filled-by/benchmark/benchmark.length.int8.js deleted file mode 100644 index 530681224..000000000 --- a/filled-by/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'int8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.uint16.js b/filled-by/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 4abf73ff8..000000000 --- a/filled-by/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint16', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.uint32.js b/filled-by/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 32db87074..000000000 --- a/filled-by/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint32', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.uint8.js b/filled-by/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 023dde146..000000000 --- a/filled-by/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/filled-by/benchmark/benchmark.length.uint8c.js b/filled-by/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 4f6194bd4..000000000 --- a/filled-by/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var clbk; - var arr; - var i; - - clbk = constantFunction( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( len, 'uint8c', clbk ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/filled-by/docs/repl.txt b/filled-by/docs/repl.txt deleted file mode 100644 index 06f314604..000000000 --- a/filled-by/docs/repl.txt +++ /dev/null @@ -1,157 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype], clbk[, thisArg] ) - Returns a filled array according to a provided callback function and having - a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > function clbk() { return 1.0; }; - > var arr = {{alias}}( 5, clbk ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 5, 'int32', clbk ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( array[, dtype], clbk[, thisArg] ) - Creates a filled array from another array (or array-like object) according - to a provided callback function. - - Parameters - ---------- - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ], {{alias:@stdlib/utils/constant-function}}( 2.0 ) ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( iterable[, dtype], clbk[, thisArg] ) - Creates a filled array from an iterable according to a provided callback - function. - - Parameters - ---------- - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( arr1, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype], clbk[, thisArg] ) - Returns a filled typed array view of an ArrayBuffer according to a provided - callback function. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - clbk: Function - Callback function. - - thisArg: any (optional) - Callback execution context. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32', {{alias:@stdlib/utils/constant-function}}( 1.0 ) ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/filled-by/docs/types/index.d.ts b/filled-by/docs/types/index.d.ts deleted file mode 100644 index 6c4b6f680..000000000 --- a/filled-by/docs/types/index.d.ts +++ /dev/null @@ -1,322 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Array or typed array. -*/ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; - -/** -* Nullary callback function. -* -* @returns fill value -*/ -type Nullary = () => any; - -/** -* Unary callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Unary = ( i: number ) => any; - -/** -* Callback function. -* -* @param i - current array index -* @returns fill value -*/ -type Callback = Nullary | Unary; - -/** -* Creates a filled array according to a provided callback function and having a specified data type. -* -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* var arr = filledarrayBy( 'float32' ); -* // returns -*/ -declare function filledarrayBy( dtype?: DataType ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var arr = filledarrayBy( 5, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array according to a provided callback function and having a specified `length`. -* -* @param length - array length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var arr = filledarrayBy( 5, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var arr = filledarrayBy( [ 5.0, -3.0, 2.0 ], constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( array: Collection, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from another `array` according to a provided callback function. -* -* @param array - typed array or array-like object -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* -* var arr = filledarrayBy( [ 5.0, -3.0, 2.0 ], 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( array: Collection, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var iterConstant = require( '@stdlib/iter/constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Creates a filled array from an iterable according to a callback function. -* -* @param iterable - iterable -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var iterConstant = require( '@stdlib/iter/constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, length: number, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, length: number, dtype: DataType, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, dtype: DataType, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( buffer: ArrayBuffer, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param buffer - `ArrayBuffer` -* @param dtype - data type -* @param clbk - callback function -* @param thisArg - callback function execution context -* @returns filled array -* -* @example -* var constantFunction = require( '@stdlib/utils/constant-function' ); -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 'float64', constantFunction( 1.0 ) ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarrayBy( buffer: ArrayBuffer, dtype: DataType, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures - - -// EXPORTS // - -export = filledarrayBy; diff --git a/filled-by/docs/types/test.ts b/filled-by/docs/types/test.ts deleted file mode 100644 index bb876ed20..000000000 --- a/filled-by/docs/types/test.ts +++ /dev/null @@ -1,606 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { IterableIterator } from '@stdlib/types/iter'; -import filledarrayBy = require( './index' ); - - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Callback function. -* -* @param i - current array index -* @returns return value -*/ -function clbk( i: number ): number { - return i; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarrayBy(); // $ExpectType ArrayOrTypedArray - filledarrayBy( 'float32' ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( 10, 'int32', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( 10, 'int32', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const x = new Float64Array( 10 ); - filledarrayBy( x, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( x, 'uint8', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( x, 'uint8', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( y, 'float64', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( y, 'float64', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const it = iterator(); - filledarrayBy( it, clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, clbk, {} ); // $ExpectType ArrayOrTypedArray - - filledarrayBy( it, 'uint8c', clbk ); // $ExpectType ArrayOrTypedArray - filledarrayBy( it, 'uint8c', clbk, {} ); // $ExpectType ArrayOrTypedArray - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 'uint32', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 'uint32', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 'uint16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 'uint16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray - - filledarrayBy( buf, 8, 2, 'int16', clbk ); // $ExpectType RealOrComplexTypedArray | BooleanArray - filledarrayBy( buf, 8, 2, 'int16', clbk, {} ); // $ExpectType RealOrComplexTypedArray | BooleanArray -} - -// The compiler throws an error if a callback function argument is not a function... -{ - filledarrayBy( 'float64', '5' ); // $ExpectError - filledarrayBy( 'float64', 1.0 ); // $ExpectError - filledarrayBy( 'float64', false ); // $ExpectError - filledarrayBy( 'float64', true ); // $ExpectError - filledarrayBy( 'float64', null ); // $ExpectError - filledarrayBy( 'float64', undefined ); // $ExpectError - filledarrayBy( 'float64', [] ); // $ExpectError - filledarrayBy( 'float64', {} ); // $ExpectError - - filledarrayBy( 'float64', '5', {} ); // $ExpectError - filledarrayBy( 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 'float64', false, {} ); // $ExpectError - filledarrayBy( 'float64', true, {} ); // $ExpectError - filledarrayBy( 'float64', null, {} ); // $ExpectError - filledarrayBy( 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 'float64', [], {} ); // $ExpectError - filledarrayBy( 'float64', {}, {} ); // $ExpectError - - filledarrayBy( 10, '5' ); // $ExpectError - filledarrayBy( 10, 1.0 ); // $ExpectError - filledarrayBy( 10, false ); // $ExpectError - filledarrayBy( 10, true ); // $ExpectError - filledarrayBy( 10, null ); // $ExpectError - filledarrayBy( 10, undefined ); // $ExpectError - filledarrayBy( 10, [] ); // $ExpectError - filledarrayBy( 10, {} ); // $ExpectError - - filledarrayBy( 10, '5', {} ); // $ExpectError - filledarrayBy( 10, 1.0, {} ); // $ExpectError - filledarrayBy( 10, false, {} ); // $ExpectError - filledarrayBy( 10, true, {} ); // $ExpectError - filledarrayBy( 10, null, {} ); // $ExpectError - filledarrayBy( 10, undefined, {} ); // $ExpectError - filledarrayBy( 10, [], {} ); // $ExpectError - filledarrayBy( 10, {}, {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5' ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0 ); // $ExpectError - filledarrayBy( 10, 'float64', false ); // $ExpectError - filledarrayBy( 10, 'float64', true ); // $ExpectError - filledarrayBy( 10, 'float64', null ); // $ExpectError - filledarrayBy( 10, 'float64', undefined ); // $ExpectError - filledarrayBy( 10, 'float64', [] ); // $ExpectError - filledarrayBy( 10, 'float64', {} ); // $ExpectError - - filledarrayBy( 10, 'float64', '5', {} ); // $ExpectError - filledarrayBy( 10, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( 10, 'float64', false, {} ); // $ExpectError - filledarrayBy( 10, 'float64', true, {} ); // $ExpectError - filledarrayBy( 10, 'float64', null, {} ); // $ExpectError - filledarrayBy( 10, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( 10, 'float64', [], {} ); // $ExpectError - filledarrayBy( 10, 'float64', {}, {} ); // $ExpectError - - const x = new Float64Array( 10 ); - filledarrayBy( x, '5' ); // $ExpectError - filledarrayBy( x, 1.0 ); // $ExpectError - filledarrayBy( x, false ); // $ExpectError - filledarrayBy( x, true ); // $ExpectError - filledarrayBy( x, null ); // $ExpectError - filledarrayBy( x, undefined ); // $ExpectError - filledarrayBy( x, [] ); // $ExpectError - filledarrayBy( x, {} ); // $ExpectError - - filledarrayBy( x, '5', {} ); // $ExpectError - filledarrayBy( x, 1.0, {} ); // $ExpectError - filledarrayBy( x, false, {} ); // $ExpectError - filledarrayBy( x, true, {} ); // $ExpectError - filledarrayBy( x, null, {} ); // $ExpectError - filledarrayBy( x, undefined, {} ); // $ExpectError - filledarrayBy( x, [], {} ); // $ExpectError - filledarrayBy( x, {}, {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5' ); // $ExpectError - filledarrayBy( x, 'float64', 1.0 ); // $ExpectError - filledarrayBy( x, 'float64', false ); // $ExpectError - filledarrayBy( x, 'float64', true ); // $ExpectError - filledarrayBy( x, 'float64', null ); // $ExpectError - filledarrayBy( x, 'float64', undefined ); // $ExpectError - filledarrayBy( x, 'float64', [] ); // $ExpectError - filledarrayBy( x, 'float64', {} ); // $ExpectError - - filledarrayBy( x, 'float64', '5', {} ); // $ExpectError - filledarrayBy( x, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( x, 'float64', false, {} ); // $ExpectError - filledarrayBy( x, 'float64', true, {} ); // $ExpectError - filledarrayBy( x, 'float64', null, {} ); // $ExpectError - filledarrayBy( x, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( x, 'float64', [], {} ); // $ExpectError - filledarrayBy( x, 'float64', {}, {} ); // $ExpectError - - const y = [ 2.0, 2.0, 2.0 ]; - filledarrayBy( y, '5' ); // $ExpectError - filledarrayBy( y, 1.0 ); // $ExpectError - filledarrayBy( y, false ); // $ExpectError - filledarrayBy( y, true ); // $ExpectError - filledarrayBy( y, null ); // $ExpectError - filledarrayBy( y, undefined ); // $ExpectError - filledarrayBy( y, [] ); // $ExpectError - filledarrayBy( y, {} ); // $ExpectError - - filledarrayBy( y, '5', {} ); // $ExpectError - filledarrayBy( y, 1.0, {} ); // $ExpectError - filledarrayBy( y, false, {} ); // $ExpectError - filledarrayBy( y, true, {} ); // $ExpectError - filledarrayBy( y, null, {} ); // $ExpectError - filledarrayBy( y, undefined, {} ); // $ExpectError - filledarrayBy( y, [], {} ); // $ExpectError - filledarrayBy( y, {}, {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5' ); // $ExpectError - filledarrayBy( y, 'float64', 1.0 ); // $ExpectError - filledarrayBy( y, 'float64', false ); // $ExpectError - filledarrayBy( y, 'float64', true ); // $ExpectError - filledarrayBy( y, 'float64', null ); // $ExpectError - filledarrayBy( y, 'float64', undefined ); // $ExpectError - filledarrayBy( y, 'float64', [] ); // $ExpectError - filledarrayBy( y, 'float64', {} ); // $ExpectError - - filledarrayBy( y, 'float64', '5', {} ); // $ExpectError - filledarrayBy( y, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( y, 'float64', false, {} ); // $ExpectError - filledarrayBy( y, 'float64', true, {} ); // $ExpectError - filledarrayBy( y, 'float64', null, {} ); // $ExpectError - filledarrayBy( y, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( y, 'float64', [], {} ); // $ExpectError - filledarrayBy( y, 'float64', {}, {} ); // $ExpectError - - const it = iterator(); - filledarrayBy( it, '5' ); // $ExpectError - filledarrayBy( it, 1.0 ); // $ExpectError - filledarrayBy( it, false ); // $ExpectError - filledarrayBy( it, true ); // $ExpectError - filledarrayBy( it, null ); // $ExpectError - filledarrayBy( it, undefined ); // $ExpectError - filledarrayBy( it, [] ); // $ExpectError - filledarrayBy( it, {} ); // $ExpectError - - filledarrayBy( it, '5', {} ); // $ExpectError - filledarrayBy( it, 1.0, {} ); // $ExpectError - filledarrayBy( it, false, {} ); // $ExpectError - filledarrayBy( it, true, {} ); // $ExpectError - filledarrayBy( it, null, {} ); // $ExpectError - filledarrayBy( it, undefined, {} ); // $ExpectError - filledarrayBy( it, [], {} ); // $ExpectError - filledarrayBy( it, {}, {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5' ); // $ExpectError - filledarrayBy( it, 'float64', 1.0 ); // $ExpectError - filledarrayBy( it, 'float64', false ); // $ExpectError - filledarrayBy( it, 'float64', true ); // $ExpectError - filledarrayBy( it, 'float64', null ); // $ExpectError - filledarrayBy( it, 'float64', undefined ); // $ExpectError - filledarrayBy( it, 'float64', [] ); // $ExpectError - filledarrayBy( it, 'float64', {} ); // $ExpectError - - filledarrayBy( it, 'float64', '5', {} ); // $ExpectError - filledarrayBy( it, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( it, 'float64', false, {} ); // $ExpectError - filledarrayBy( it, 'float64', true, {} ); // $ExpectError - filledarrayBy( it, 'float64', null, {} ); // $ExpectError - filledarrayBy( it, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( it, 'float64', [], {} ); // $ExpectError - filledarrayBy( it, 'float64', {}, {} ); // $ExpectError - - const buf = new ArrayBuffer( 32 ); - filledarrayBy( buf, '5' ); // $ExpectError - filledarrayBy( buf, 1.0 ); // $ExpectError - filledarrayBy( buf, false ); // $ExpectError - filledarrayBy( buf, true ); // $ExpectError - filledarrayBy( buf, null ); // $ExpectError - filledarrayBy( buf, undefined ); // $ExpectError - filledarrayBy( buf, [] ); // $ExpectError - filledarrayBy( buf, {} ); // $ExpectError - - filledarrayBy( buf, '5', {} ); // $ExpectError - filledarrayBy( buf, 1.0, {} ); // $ExpectError - filledarrayBy( buf, false, {} ); // $ExpectError - filledarrayBy( buf, true, {} ); // $ExpectError - filledarrayBy( buf, null, {} ); // $ExpectError - filledarrayBy( buf, undefined, {} ); // $ExpectError - filledarrayBy( buf, [], {} ); // $ExpectError - filledarrayBy( buf, {}, {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 'float64', false ); // $ExpectError - filledarrayBy( buf, 'float64', true ); // $ExpectError - filledarrayBy( buf, 'float64', null ); // $ExpectError - filledarrayBy( buf, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5' ); // $ExpectError - filledarrayBy( buf, 8, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, false ); // $ExpectError - filledarrayBy( buf, 8, true ); // $ExpectError - filledarrayBy( buf, 8, null ); // $ExpectError - filledarrayBy( buf, 8, undefined ); // $ExpectError - filledarrayBy( buf, 8, [] ); // $ExpectError - filledarrayBy( buf, 8, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, false, {} ); // $ExpectError - filledarrayBy( buf, 8, true, {} ); // $ExpectError - filledarrayBy( buf, 8, null, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, [], {} ); // $ExpectError - filledarrayBy( buf, 8, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 'float64', {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, false ); // $ExpectError - filledarrayBy( buf, 8, 2, true ); // $ExpectError - filledarrayBy( buf, 8, 2, null ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, [] ); // $ExpectError - filledarrayBy( buf, 8, 2, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, {}, {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5' ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0 ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [] ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {} ); // $ExpectError - - filledarrayBy( buf, 8, 2, 'float64', '5', {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', 1.0, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', false, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', true, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', null, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', undefined, {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', [], {} ); // $ExpectError - filledarrayBy( buf, 8, 2, 'float64', {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarrayBy( false, clbk ); // $ExpectError - filledarrayBy( true, clbk ); // $ExpectError - filledarrayBy( null, clbk ); // $ExpectError - filledarrayBy( {}, clbk ); // $ExpectError - - filledarrayBy( false, clbk, {} ); // $ExpectError - filledarrayBy( true, clbk, {} ); // $ExpectError - filledarrayBy( null, clbk, {} ); // $ExpectError - filledarrayBy( {}, clbk, {} ); // $ExpectError - - filledarrayBy( false, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 'float64', clbk ); // $ExpectError - - filledarrayBy( false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, clbk ); // $ExpectError - filledarrayBy( false, 8, clbk ); // $ExpectError - filledarrayBy( true, 8, clbk ); // $ExpectError - filledarrayBy( null, 8, clbk ); // $ExpectError - filledarrayBy( undefined, 8, clbk ); // $ExpectError - filledarrayBy( [], 8, clbk ); // $ExpectError - filledarrayBy( {}, 8, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk ); // $ExpectError - - filledarrayBy( '5', 8, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk ); // $ExpectError - filledarrayBy( false, 8, 2, clbk ); // $ExpectError - filledarrayBy( true, 8, 2, clbk ); // $ExpectError - filledarrayBy( null, 8, 2, clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk ); // $ExpectError - filledarrayBy( [], 8, 2, clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, clbk, {} ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( '5', 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( 1.0, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( false, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( true, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( null, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( undefined, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( [], 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( {}, 8, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( ( x: number ): number => x, 8, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, false, clbk ); // $ExpectError - filledarrayBy( buf, true, clbk ); // $ExpectError - filledarrayBy( buf, null, clbk ); // $ExpectError - filledarrayBy( buf, [], clbk ); // $ExpectError - filledarrayBy( buf, {}, clbk ); // $ExpectError - - filledarrayBy( buf, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk ); // $ExpectError - filledarrayBy( buf, true, 2, clbk ); // $ExpectError - filledarrayBy( buf, null, 2, clbk ); // $ExpectError - filledarrayBy( buf, [], 2, clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk ); // $ExpectError - - filledarrayBy( buf, false, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, clbk, {} ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, '5', 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, false, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, true, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, null, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, undefined, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, [], 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, {}, 2, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, ( x: number ): number => x, 2, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, false, clbk ); // $ExpectError - filledarrayBy( buf, 8, true, clbk ); // $ExpectError - filledarrayBy( buf, 8, null, clbk ); // $ExpectError - filledarrayBy( buf, 8, [], clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk ); // $ExpectError - - filledarrayBy( buf, 8, false, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, clbk, {} ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk ); // $ExpectError - - filledarrayBy( buf, 8, '5', 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, false, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, true, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, null, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, undefined, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, [], 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, {}, 'float64', clbk, {} ); // $ExpectError - filledarrayBy( buf, 8, ( x: number ): number => x, 'float64', clbk, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarrayBy( buf, 8, 2, 'float64', 1, clbk, {}, {} ); // $ExpectError -} diff --git a/filled-by/examples/index.js b/filled-by/examples/index.js deleted file mode 100644 index b441fc585..000000000 --- a/filled-by/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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' ).factory; -var dtypes = require( './../../typed-real-dtypes' ); -var filledarrayBy = require( './../lib' ); - -// Create a pseudorandom number generator: -var rand = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarrayBy( 10, dt[ i ], rand ); - console.log( arr ); -} diff --git a/filled-by/lib/index.js b/filled-by/lib/index.js deleted file mode 100644 index b9074283c..000000000 --- a/filled-by/lib/index.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a filled array according to a provided callback function. -* -* @module @stdlib/array/filled-by -* -* @example -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* var arr = filledarrayBy(); -* // returns -* -* @example -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarrayBy = require( '@stdlib/array/filled-by' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/filled-by/lib/main.js b/filled-by/lib/main.js deleted file mode 100644 index d979bdaf4..000000000 --- a/filled-by/lib/main.js +++ /dev/null @@ -1,416 +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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isComplexDataType = require( './../../base/assert/is-complex-floating-point-data-type' ); -var isBooleanDataType = require( './../../base/assert/is-boolean-data-type' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isObject = require( '@stdlib/assert/is-object' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ctors = require( './../../ctors' ); -var gfillBy = require( '@stdlib/blas/ext/base/gfill-by' ); -var filledArray = require( './../../base/filled-by' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var iterLength = require( '@stdlib/iter/length' ); -var defaults = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterable} it - iterator -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Array} filled array -*/ -function filledArrayIterator( it, clbk, thisArg ) { - var arr; - var i; - var v; - - arr = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - arr.push( clbk.call( thisArg, i ) ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {Callback} clbk - callback function -* @param {*} thisArg - callback function execution context -* @returns {Collection} input array -*/ -function filledAccessors( arr, clbk, thisArg ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( clbk.call( thisArg, i ), i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array according to a provided callback function. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @param {Callback} [clbk] - callback to invoke -* @param {*} [thisArg] - callback execution context -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {TypeError} callback argument must be a function. -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array)} array or typed array -* -* @example -* var arr = filledarrayBy(); -* // returns -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( 2, 'generic', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1.0; -* } -* -* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk() { -* return 1; -* } -* -* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk ); -* // returns [ 1, 1 ] -* -* @example -* function clbk1() { -* return 10; -* } -* -* function clbk2() { -* return 1.0; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, clbk2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* function clbk1() { -* return 1.0; -* } -* -* function clbk2() { -* return 2; -* } -* -* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 ); -* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 'float32', clbk ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, clbk ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarrayBy( buf, 8, 'float32', clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* function clbk() { -* return 1.0; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, clbk ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* function clbk() { -* return 1; -* } -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk ); -* // returns [ 1, 1 ] -*/ -function filledarrayBy() { - var thisArg; - var nargs; - var dtype; - var clbk; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - - // If we weren't provided any arguments, return an empty array... - if ( nargs === 0 ) { - ctor = ctors( DEFAULT_DTYPE ); - return new ctor( 0 ); - } - // Check if we were provided a dtype as the first argument... - dtype = arguments[ 0 ]; - if ( isString( dtype ) ) { - // Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)... - if ( nargs > 1 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - // Return an empty array having the specified dtype: - return new ctor( 0 ); - } - // For all other supported invocations, we need at least two arguments... - if ( nargs < 2 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - // At this point, we need to do some argument juggling... - nargs -= 1; // henceforth, the number of available arguments is `nargs+1` - - // Determine whether the last argument is a callback or "this" context... - if ( isFunction( arguments[ nargs ] ) ) { - // If the last argument is a function, we need to check the next-to-last argument, and, if the next-to-last argument is a function, assume that the next-to-last argument is the callback and the last argument is a "this" context... - if ( isFunction( arguments[ nargs-1 ] ) ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - - // Check if we were provided only a callback and a "this" context.. - if ( nargs === 0 ) { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - } else { - // "this" context is left undefined... - clbk = arguments[ nargs ]; - } - } - // If we were provided 3 or more arguments and the last argument was not a function, assume that we were provided a callback and a "this" context... - else if ( nargs >= 2 ) { - thisArg = arguments[ nargs ]; - nargs -= 1; - clbk = arguments[ nargs ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) ); - } - } - // If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments... - else { - throw new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' ); - } - // Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument... - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - // At this point, we've resolved the output array data type, and now we can actually create the output array... - if ( dtype === 'generic' ) { - arg = arguments[ 0 ]; - if ( nargs === 0 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filledArray( len, clbk, thisArg ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - return filledArrayIterator( arg, clbk, thisArg ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - if ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 0 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - } else if ( nargs === 1 ) { - arr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { - filledAccessors( arr, clbk, thisArg ); - } else { - gfillBy( arr.length, arr, 1, callback ); - } - } - return arr; - - /** - * Callback which wraps a provided callback and is invoked for each array element. - * - * @private - * @param {*} value - element value - * @param {NonNegativeInteger} aidx - array index - * @param {NonNegativeInteger} sidx - strided index - * @param {Collection} array - input array/collection - * @returns {*} callback return value - */ - function callback( value, aidx ) { - return clbk.call( thisArg, aidx ); - } -} - - -// EXPORTS // - -module.exports = filledarrayBy; diff --git a/filled-by/package.json b/filled-by/package.json deleted file mode 100644 index 13b17ee0d..000000000 --- a/filled-by/package.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "name": "@stdlib/array/filled-by", - "version": "0.0.0", - "description": "Create a filled array according to a provided callback function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "complex64", - "complex128", - "complex", - "cmplx", - "clamped", - "short", - "long", - "generic", - "fill", - "filled", - "map", - "foreach", - "callback" - ] -} diff --git a/filled-by/test/test.js b/filled-by/test/test.js deleted file mode 100644 index ed3d82cf7..000000000 --- a/filled-by/test/test.js +++ /dev/null @@ -1,4397 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var ArrayBuffer = require( './../../buffer' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var iterConstant = require( '@stdlib/iter/constant' ); -var constantFunction = require( '@stdlib/utils/constant-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); -var filledarrayBy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarrayBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if only provided callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 8 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 8, 1, value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid callback argument (iterator; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( iterConstant( 1.0 ), value, {} ); - }; - } -}); - -tape( 'the function throws an error if only provided data type and callback arguments', function test( t ) { - t.throws( clbk1, TypeError, 'throws an error' ); - t.throws( clbk2, TypeError, 'throws an error' ); - t.throws( clbk3, TypeError, 'throws an error' ); - t.end(); - - function clbk1() { - filledarrayBy( 'float64', constantFunction( 1.0 ) ); - } - - function clbk2() { - filledarrayBy( 'float64', constantFunction( 1.0 ), {} ); - } - - function clbk3() { - filledarrayBy( 'float64', constantFunction( 1.0 ), constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( 10, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new Float64Array( 10 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( [ 1, 2, 3 ], value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarrayBy', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( new ArrayBuffer( 16 ), 0, 1, value, constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'generic', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ) ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function; thisArg)', function test( t ) { - var filledarrayBy; - var values; - var i; - - filledarrayBy = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarrayBy( obj, 'float64', constantFunction( 1.0 ), {} ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ) ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarrayBy( value, 1, 1, 'generic', constantFunction( 1.0 ), {} ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy(); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - arr = filledarrayBy( 'float64' ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - arr = filledarrayBy( 'float32' ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=bool)', function test( t ) { - var expected; - var arr; - - expected = new BooleanArray( 0 ); - arr = filledarrayBy( 'bool' ); - - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - arr = filledarrayBy( 'complex128' ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - arr = filledarrayBy( 'complex64' ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - arr = filledarrayBy( 'int32' ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - arr = filledarrayBy( 'uint32' ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - arr = filledarrayBy( 'int16' ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - arr = filledarrayBy( 'uint16' ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - arr = filledarrayBy( 'int8' ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - arr = filledarrayBy( 'uint8' ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - arr = filledarrayBy( 'uint8c' ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - arr = filledarrayBy( 'generic' ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length=0)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array(); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 0, clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (default, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float64', clbk ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, length; thisArg=function)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - indices = []; - ctx = { - 'count': 0 - }; - arr = filledarrayBy( 5, 'float64', clbk, context ); - - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - expected = [ 0, 1, 2, 3, 4 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this(); // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } - - function context() { - ctx.count += 1; - } -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = filledarrayBy( 5, 'float32', clbk ); - - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=bool, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( true ); - arr = filledarrayBy( 5, 'bool', clbk ); - - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex128', clbk ); - - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = filledarrayBy( 5, 'complex64', clbk ); - - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int32', clbk ); - - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint32', clbk ); - - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int16', clbk ); - - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint16', clbk ); - - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'int8', clbk ); - - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8', clbk ); - - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'uint8c', clbk ); - - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var clbk; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - clbk = constantFunction( 1 ); - arr = filledarrayBy( 5, 'generic', clbk ); - - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=bool, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - clbk = constantFunction( false ); - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = filledarrayBy( arr, 'bool', clbk ); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = [ 1.0, 2.0 ]; - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=bool, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( true ); - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = filledarrayBy( arr, 'bool', clbk ); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = new Float64Array( [ 1.0, 2.0 ] ); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=bool, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - clbk = constantFunction( false ); - buf = new ArrayBuffer( 4 ); - out = filledarrayBy( buf, 'bool', clbk ); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( true ); - buf = new ArrayBuffer( 6 ); - out = filledarrayBy( buf, 2, 'bool', clbk ); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 48 ); - out = filledarrayBy( buf, 16, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 24 ); - out = filledarrayBy( buf, 8, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int32', clbk ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 'uint8c', clbk ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - var expected; - var indices; - var ctx; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - ctx = { - 'count': 0 - }; - indices = []; - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - clbk = constantFunction( false ); - buf = new ArrayBuffer( 8 ); - out = filledarrayBy( buf, 2, 4, 'bool', clbk ); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 64 ); - out = filledarrayBy( buf, 16, 2, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - buf = new ArrayBuffer( 32 ); - out = filledarrayBy( buf, 8, 2, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var clbk; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - clbk = constantFunction( 1 ); - buf = new ArrayBuffer( 16 ); - out = filledarrayBy( buf, 4, 2, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ) ); - } -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length; thisArg)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarrayBy( buf, 4, 1, 'generic', constantFunction( 1.0 ), {} ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float64', clbk ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator; thisArg)', opts, function test( t ) { - var expected; - var indices; - var ctx; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - ctx = { - 'count': 0 - }; - indices = []; - out = filledarrayBy( arr, 'float64', clbk, ctx ); - - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - expected = [ 0, 1, 2 ]; - t.strictEqual( ctx.count, expected.length, 'returns expected value' ); - t.deepEqual( indices, expected, 'returns expected value' ); - - t.end(); - - function clbk( i ) { - this.count += 1; // eslint-disable-line no-invalid-this - indices.push( i ); - return 1.0; - } -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'float32', clbk ); - - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=bool, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - clbk = constantFunction( true ); - arr = iterConstant( false, { - 'iter': 4 - }); - out = filledarrayBy( arr, 'bool', clbk ); - - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex128( 1.0, 1.0 ) ); - arr = iterConstant( new Complex128( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex128', clbk ); - - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - clbk = constantFunction( new Complex64( 1.0, 1.0 ) ); - arr = iterConstant( new Complex64( 3.0, 3.0 ), { - 'iter': 2 - }); - out = filledarrayBy( arr, 'complex64', clbk ); - - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int32', clbk ); - - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint32', clbk ); - - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int16', clbk ); - - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint16', clbk ); - - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'int8', clbk ); - - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8', clbk ); - - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - clbk = constantFunction( 1 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'uint8c', clbk ); - - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var clbk; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - clbk = constantFunction( 1.0 ); - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarrayBy( arr, 'generic', clbk ); - - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/filled/README.md b/filled/README.md deleted file mode 100644 index b4e24b98e..000000000 --- a/filled/README.md +++ /dev/null @@ -1,235 +0,0 @@ - - -# filledarray - -> Create a filled array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var filledarray = require( '@stdlib/array/filled' ); -``` - -#### filledarray( \[dtype] ) - -Creates a filled array having a specified [data type][@stdlib/array/dtypes] `dtype`. - -```javascript -var arr = filledarray(); -// returns -``` - -By default, the output array [data type][@stdlib/array/dtypes] is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative [data type][@stdlib/array/dtypes], provide a `dtype` argument. - -```javascript -var arr = filledarray( 'int32' ); -// returns -``` - -#### filledarray( value, length\[, dtype] ) - -Returns a filled array having a specified `length`. - -```javascript -var arr1 = filledarray( 1.0, 5 ); -// returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - -var arr2 = filledarray( 1, 5, 'uint8' ); -// returns [ 1, 1, 1, 1, 1 ] -``` - -#### filledarray( value, array\[, dtype] ) - -Creates a filled array from another array (or array-like object). - -```javascript -var arr0 = { - '0': 0.5, - '1': 0.5, - '2': 0.5, - 'length': 3 -}; - -var arr1 = filledarray( 1.0, arr0 ); -// returns [ 1.0, 1.0, 1.0 ] - -var arr2 = filledarray( 2.0, arr1 ); -// returns [ 2.0, 2.0, 2.0 ] - -var arr3 = filledarray( 3, arr1, 'int32' ); -// returns [ 3, 3, 3 ] -``` - -#### filledarray( value, iterable\[, dtype] ) - -Creates a filled array from an iterable. - -```javascript -var iterConstant = require( '@stdlib/iter/constant' ); - -var it = iterConstant( 3.0, { - 'iter': 3 -}); -var arr1 = filledarray( 1.0, it ); -// returns [ 1.0, 1.0, 1.0 ] - -var arr2 = filledarray( 1.0, it, 'float32' ); -// returns [ 1.0, 1.0, 1.0 ] -``` - -#### filledarray( value, buffer\[, byteOffset\[, length]]\[, dtype] ) - -Returns a filled [typed array][mdn-typed-array] view of an [`ArrayBuffer`][mdn-arraybuffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 32 ); -var arr = filledarray( 1.0, buf ); -// returns [ 1.0, 1.0, 1.0, 1.0 ] - -buf = new ArrayBuffer( 32 ); -arr = filledarray( 1.0, buf, 'float32' ); -// returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] - -buf = new ArrayBuffer( 32 ); -arr = filledarray( 1.0, buf, 16 ); -// returns [ 1.0, 1.0 ] - -buf = new ArrayBuffer( 32 ); -arr = filledarray( 1.0, buf, 16, 'float32' ); -// returns [ 1.0, 1.0, 1.0, 1.0 ] - -buf = new ArrayBuffer( 32 ); -arr = filledarray( 1.0, buf, 16, 1 ); -// returns [ 1.0 ] - -buf = new ArrayBuffer( 32 ); -arr = filledarray( 1, buf, 10, 4, 'int16' ); -// returns [ 1, 1, 1, 1 ] -``` - -
- - - - - -
- -## Notes - -- Creating a generic [array][mdn-array] from an [`ArrayBuffer`][mdn-arraybuffer] is **not** supported. - -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var dtypes = require( '@stdlib/array/typed-real-dtypes' ); -var filledarray = require( '@stdlib/array/filled' ); - -// Generate a random number: -var r = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/filled/benchmark/benchmark.js b/filled/benchmark/benchmark.js deleted file mode 100644 index 376c1cdb0..000000000 --- a/filled/benchmark/benchmark.js +++ /dev/null @@ -1,292 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0.0, 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var v; - var i; - - v = new Complex128( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var v; - var i; - - v = new Complex64( 3.0, 5.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 0, 0, 'generic' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/filled/benchmark/benchmark.length.bool.js b/filled/benchmark/benchmark.length.bool.js deleted file mode 100644 index 3767ce243..000000000 --- a/filled/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( true, len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.complex128.js b/filled/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 29bbc5a56..000000000 --- a/filled/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var v; - var i; - - v = new Complex128( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.complex64.js b/filled/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 1fb372ccc..000000000 --- a/filled/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var v; - var i; - - v = new Complex64( 1.0, 1.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( v, len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.float32.js b/filled/benchmark/benchmark.length.float32.js deleted file mode 100644 index 251d5e9b4..000000000 --- a/filled/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.float64.js b/filled/benchmark/benchmark.length.float64.js deleted file mode 100644 index d67a24e16..000000000 --- a/filled/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.generic.js b/filled/benchmark/benchmark.length.generic.js deleted file mode 100644 index 0d21e4e97..000000000 --- a/filled/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1.0, len, 'generic' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.int16.js b/filled/benchmark/benchmark.length.int16.js deleted file mode 100644 index b28b58b5f..000000000 --- a/filled/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.int32.js b/filled/benchmark/benchmark.length.int32.js deleted file mode 100644 index 3ced244ba..000000000 --- a/filled/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.int8.js b/filled/benchmark/benchmark.length.int8.js deleted file mode 100644 index 98ad0f7c6..000000000 --- a/filled/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.uint16.js b/filled/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d50200295..000000000 --- a/filled/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.uint32.js b/filled/benchmark/benchmark.length.uint32.js deleted file mode 100644 index d23d29555..000000000 --- a/filled/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.uint8.js b/filled/benchmark/benchmark.length.uint8.js deleted file mode 100644 index a93ea6df0..000000000 --- a/filled/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/filled/benchmark/benchmark.length.uint8c.js b/filled/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 8bbc2694b..000000000 --- a/filled/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var filledarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = filledarray( 1, len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/filled/docs/repl.txt b/filled/docs/repl.txt deleted file mode 100644 index 47742a8cb..000000000 --- a/filled/docs/repl.txt +++ /dev/null @@ -1,140 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a filled array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( value, length[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - value: any - Fill value. - - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 1.0, 5 ) - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] - > arr = {{alias}}( 1, 5, 'int32' ) - [ 1, 1, 1, 1, 1 ] - - -{{alias}}( value, array[, dtype] ) - Creates a filled array from another array (or array-like object). - - Parameters - ---------- - value: any - Fill value. - - array: ArrayLikeObject - Array from which to generate another array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) - [ 2.0, 2.0, 2.0 ] - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, iterable[, dtype] ) - Creates a filled array from an iterable. - - Parameters - ---------- - value: any - Fill value. - - iterable: Iterable - Iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); - > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) - [ 1.0, 1.0, 1.0 ] - - -{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) - Returns a filled typed array view of an ArrayBuffer. - - The 'generic' array data type is *not* supported. - - Parameters - ---------- - value: any - Fill value. - - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) - [ 1.0, 1.0, 1.0, 1.0 ] - - See Also - -------- - diff --git a/filled/docs/types/index.d.ts b/filled/docs/types/index.d.ts deleted file mode 100644 index 4c16024e5..000000000 --- a/filled/docs/types/index.d.ts +++ /dev/null @@ -1,198 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/unified-signatures */ - -// TypeScript Version: 4.1 - -/// - -import { Collection, DataTypeMap } from '@stdlib/types/array'; -import { IterableIterator } from '@stdlib/types/iter'; - -/** -* Creates a filled array. -* -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 'float32' ); -* // returns -*/ -declare function filledarray = 'float64'>( dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array having a specified `length`. -* -* @param value - fill value -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, 5 ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 5, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from another `array`. -* -* @param value - fill value -* @param array - typed array or array-like object -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, array: Collection, dtype?: U ): DataTypeMap[U]; - -/** -* Creates a filled array from an iterable. -* -* @param value - fill value -* @param iterable - iterable -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var iterConstant = require( '@stdlib/iter/constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var iterConstant = require( '@stdlib/iter/constant' ); -* -* var it = iterConstant( 3.0, { -* 'iter': 3 -* }); -* var arr = filledarray( 1.0, it, 'float32' ); -* // returns [ 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, iterable: IterableIterator, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param length - view length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param byteOffset - byte offset -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, byteOffset: number, dtype?: U ): DataTypeMap[U]; - -/** -* Returns a filled typed array view of an `ArrayBuffer`. -* -* ## Notes -* -* - Creating a generic array from an `ArrayBuffer` is **not** supported. -* -* @param value - fill value -* @param buffer - `ArrayBuffer` -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] -*/ -declare function filledarray = 'float64'>( value: T, buffer: ArrayBuffer, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = filledarray; diff --git a/filled/docs/types/test.ts b/filled/docs/types/test.ts deleted file mode 100644 index 4da77fe1c..000000000 --- a/filled/docs/types/test.ts +++ /dev/null @@ -1,200 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/// - -import { IterableIterator } from '@stdlib/types/iter'; -import filledarray = require( './index' ); - -/** -* Implements the iterator protocol `next` method. -* -* @returns iterator protocol-compliant object -*/ -function next(): any { - return { - 'value': 1.0, - 'done': false - }; -} - -/** -* Returns an iterator protocol-compliant object. -* -* @returns iterator protocol-compliant object -*/ -function iterator(): IterableIterator { - const obj: IterableIterator = { - [Symbol.iterator]: iterator, - 'next': next - }; - return obj; -} - - -// TESTS // - -// The function returns an array or typed array... -{ - filledarray(); // $ExpectType Float64Array - filledarray( 'float32' ); // $ExpectType Float32Array - - filledarray( 1.0, 10 ); // $ExpectType Float64Array - filledarray( 1.0, 10, 'int32' ); // $ExpectType Int32Array - - const x = new Float64Array( 10 ); - filledarray( 1.0, x ); // $ExpectType Float64Array - filledarray( 1.0, x, 'uint8' ); // $ExpectType Uint8Array - - const y = [ 2.0, 2.0, 2.0 ]; - filledarray( 1.0, y ); // $ExpectType Float64Array - filledarray( 1.0, y, 'float64' ); // $ExpectType Float64Array - - const it = iterator(); - filledarray( 1.0, it ); // $ExpectType Float64Array - filledarray( 1.0, it, 'uint8c' ); // $ExpectType Uint8ClampedArray - - const buf = new ArrayBuffer( 32 ); - filledarray( 1.0, buf ); // $ExpectType Float64Array - filledarray( 1.0, buf, 'uint32' ); // $ExpectType Uint32Array - - filledarray( 1.0, buf, 8 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType Uint16Array - - filledarray( 1.0, buf, 8, 2 ); // $ExpectType Float64Array - filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType Int16Array -} - -// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, `ArrayBuffer`, or iterable argument... -{ - filledarray( 1.0, false ); // $ExpectError - filledarray( 1.0, true ); // $ExpectError - filledarray( 1.0, null ); // $ExpectError - filledarray( 1.0, {} ); // $ExpectError - - filledarray( 1.0, false, 'float64' ); // $ExpectError - filledarray( 1.0, true, 'float64' ); // $ExpectError - filledarray( 1.0, null, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8 ); // $ExpectError - filledarray( 1.0, 1.0, 8 ); // $ExpectError - filledarray( 1.0, false, 8 ); // $ExpectError - filledarray( 1.0, true, 8 ); // $ExpectError - filledarray( 1.0, null, 8 ); // $ExpectError - filledarray( 1.0, undefined, 8 ); // $ExpectError - filledarray( 1.0, [], 8 ); // $ExpectError - filledarray( 1.0, {}, 8 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError - - filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError - - filledarray( 1.0, '5', 8, 2 ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError - filledarray( 1.0, false, 8, 2 ); // $ExpectError - filledarray( 1.0, true, 8, 2 ); // $ExpectError - filledarray( 1.0, null, 8, 2 ); // $ExpectError - filledarray( 1.0, undefined, 8, 2 ); // $ExpectError - filledarray( 1.0, [], 8, 2 ); // $ExpectError - filledarray( 1.0, {}, 8, 2 ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError - - filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError - filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a byte offset argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, false ); // $ExpectError - filledarray( 1.0, buf, true ); // $ExpectError - filledarray( 1.0, buf, null ); // $ExpectError - filledarray( 1.0, buf, [] ); // $ExpectError - filledarray( 1.0, buf, {} ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, false, 2 ); // $ExpectError - filledarray( 1.0, buf, true, 2 ); // $ExpectError - filledarray( 1.0, buf, null, 2 ); // $ExpectError - filledarray( 1.0, buf, [], 2 ); // $ExpectError - filledarray( 1.0, buf, {}, 2 ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2 ); // $ExpectError - - filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError - - filledarray( 1.0, buf, '5', 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, false, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, true, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, null, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, undefined, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, [], 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, {}, 2, 'float64' ); // $ExpectError - filledarray( 1.0, buf, ( x: number ): number => x, 2, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a view length argument which is not a number... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, false ); // $ExpectError - filledarray( 1.0, buf, 8, true ); // $ExpectError - filledarray( 1.0, buf, 8, null ); // $ExpectError - filledarray( 1.0, buf, 8, [] ); // $ExpectError - filledarray( 1.0, buf, 8, {} ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError - - filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError - filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided too many arguments... -{ - const buf = new ArrayBuffer( 32 ); - - filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError -} diff --git a/filled/examples/index.js b/filled/examples/index.js deleted file mode 100644 index eb187c612..000000000 --- a/filled/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var dtypes = require( './../../typed-real-dtypes' ); -var filledarray = require( './../lib' ); - -// Generate a random number: -var r = discreteUniform( 0, 100 ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = filledarray( r, 10, dt[ i ] ); - console.log( arr ); -} diff --git a/filled/lib/index.js b/filled/lib/index.js deleted file mode 100644 index 9fc0dcc0d..000000000 --- a/filled/lib/index.js +++ /dev/null @@ -1,132 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a filled array. -* -* @module @stdlib/array/filled -* -* @example -* var filledarray = require( '@stdlib/array/filled' ); -* -* var arr = filledarray(); -* // returns -* -* @example -* var filledarray = require( '@stdlib/array/filled' ); -* -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array/filled' ); -* -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array/filled' ); -* -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array/filled' ); -* -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array/filled' ); -* -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var filledarray = require( '@stdlib/array/filled' ); -* -* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var filledarray = require( '@stdlib/array/filled' ); -* -* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 2, arr1, 'uint32' ); -* // returns [ 2, 2 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarray = require( '@stdlib/array/filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarray = require( '@stdlib/array/filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarray = require( '@stdlib/array/filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarray = require( '@stdlib/array/filled' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarray = require( '@stdlib/array/filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var filledarray = require( '@stdlib/array/filled' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/filled/lib/main.js b/filled/lib/main.js deleted file mode 100644 index ccb38acd3..000000000 --- a/filled/lib/main.js +++ /dev/null @@ -1,286 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../base/assert/is-complex-floating-point-data-type' ); -var isBooleanDataType = require( './../../base/assert/is-boolean-data-type' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert/is-collection' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isObject = require( '@stdlib/assert/is-object' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ctors = require( './../../ctors' ); -var gfill = require( '@stdlib/blas/ext/base/gfill' ); -var filled = require( './../../base/filled' ); -var reinterpretBool = require( '@stdlib/strided/base/reinterpret-boolean' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var iterLength = require( '@stdlib/iter/length' ); -var defaults = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// FUNCTIONS // - -/** -* Creates a filled "generic" array from an iterator. -* -* @private -* @param {Iterator} it - iterator -* @param {*} value - fill value -* @returns {Array} filled array -*/ -function filledIterator( it, value ) { - var arr; - var v; - - arr = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - arr.push( value ); - } - return arr; -} - -/** -* Fills an array exposing accessors for getting and setting array elements. -* -* @private -* @param {Collection} arr - input array -* @param {*} value - fill value -* @returns {Collection} input array -*/ -function filledAccessors( arr, value ) { - var i; - for ( i = 0; i < arr.length; i++ ) { - arr.set( value, i ); - } - return arr; -} - - -// MAIN // - -/** -* Creates a filled array. -* -* @param {*} [value] - fill value -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} must provide a recognized data type -* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable -* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = filledarray(); -* // returns -* -* @example -* var arr = filledarray( 1.0, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, 2, 'generic' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); -* // returns [ 1, 1 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1.0, arr1 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); -* var arr2 = filledarray( 1, arr1, 'uint32' ); -* // returns [ 1, 1 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 'float32' ); -* // returns [ 1.0, 1.0, 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8 ); -* // returns [ 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = filledarray( 1.0, buf, 8, 'float32' ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1.0, buf, 8, 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = filledarray( 1, buf, 8, 2, 'int32' ); -* // returns [ 1, 1 ] -*/ -function filledarray() { - var value; - var nargs; - var dtype; - var ctor; - var arr; - var len; - var arg; - - nargs = arguments.length; - nargs -= 1; - if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { - dtype = arguments[ nargs ]; - nargs -= 1; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - if ( dtype === 'generic' ) { - if ( nargs <= 0 ) { - return []; - } - value = arguments[ 0 ]; - arg = arguments[ 1 ]; - if ( nargs === 1 ) { - if ( isNonNegativeInteger( arg ) ) { - len = arg; - } else if ( isCollection( arg ) ) { - len = arg.length; - } - if ( len !== void 0 ) { - return filled( value, len ); - } - if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - return filledIterator( arg, value ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } else if ( isArrayBuffer( arg ) ) { - throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); - } - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable - arg = arguments[ 1 ]; - if ( isCollection( arg ) ) { - arr = new ctor( arg.length ); - } else if ( isArrayBuffer( arg ) ) { - arr = new ctor( arg ); - } else if ( isNonNegativeInteger( arg ) ) { - arr = new ctor( arg ); - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arg = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( arg.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - arr = new ctor( iterLength( arg ) ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - } else if ( nargs === 2 ) { - arr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset) - } else { - arr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length) - } - if ( arr.length > 0 ) { - value = arguments[ 0 ]; - if ( isComplexDataType( dtype ) ) { - filledAccessors( arr, value ); - } else if ( isBooleanDataType( dtype ) ) { - gfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len - } else { - gfill( arr.length, value, arr, 1 ); - } - } - return arr; -} - - -// EXPORTS // - -module.exports = filledarray; diff --git a/filled/package.json b/filled/package.json deleted file mode 100644 index 5334e5b73..000000000 --- a/filled/package.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "name": "@stdlib/array/filled", - "version": "0.0.0", - "description": "Create a filled array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "fill", - "filled" - ] -} diff --git a/filled/test/test.js b/filled/test/test.js deleted file mode 100644 index 202a046cb..000000000 --- a/filled/test/test.js +++ /dev/null @@ -1,2665 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var ArrayBuffer = require( './../../buffer' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var iterConstant = require( '@stdlib/iter/constant' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); -var filledarray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasIteratorSymbolSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'filledarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { - var values; - var i; - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'generic' ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarray( 1.0, obj, 'generic' ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarray( 1.0, obj, 'generic' ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (no iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - function hasSupport() { - return false; - } -}); - -tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a typed array (iterator symbol support)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport - }); - - values = [ - '5', - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 'float64' ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (non-function iterator symbol property)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': value - }; - filledarray( 1.0, obj, 'float64' ); - }; - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided a valid iterable when attempting to create a typed array (`next` property is not a function)', function test( t ) { - var filledarray; - var values; - var i; - - filledarray = proxyquire( './../lib/main.js', { - '@stdlib/assert/has-iterator-symbol-support': hasSupport, - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var obj = { - '__ITERATOR_SYMBOL__': iterator - }; - filledarray( 1.0, obj, 'float64' ); - }; - - function iterator() { - return { - 'next': value - }; - } - } - - function hasSupport() { - return true; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 1, 'generic' ); - }; - } -}); - -tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - filledarray( 1.0, value, 1, 1, 'generic' ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( 0 ); - - arr = filledarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( 0 ); - - arr = filledarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=bool)', function test( t ) { - var expected; - var arr; - - expected = new BooleanArray( 0 ); - - arr = filledarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Complex64Array( 0 ); - - arr = filledarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Complex128Array( 0 ); - - arr = filledarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( 0 ); - - arr = filledarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( 0 ); - - arr = filledarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( 0 ); - - arr = filledarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( 0 ); - - arr = filledarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( 0 ); - - arr = filledarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( 0 ); - - arr = filledarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( 0 ); - - arr = filledarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - - expected = []; - - arr = filledarray( 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, default, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=float64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = filledarray( 1.0, 5, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=float32, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = filledarray( 0.0, 5, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=false, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( false, 5, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=true, dtype=bool, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( true, 5, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=complex128, length)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex128( 0.0, 0.0 ), 5, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=complex64, length)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // eslint-disable-line max-len - - arr = filledarray( new Complex64( 0.0, 0.0 ), 5, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=int32, length)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=uint32, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=int16, length)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=uint16, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=int8, length)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=uint8, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = filledarray( 1, 5, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=uint8c, length)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = filledarray( 0, 5, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = filledarray( 1, 5, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (value=0, dtype=generic, length)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = filledarray( 0, 5, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=bool, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( false, arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( true, arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = [ 2.0, 2.0 ]; - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1, arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { - var expected; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = [ 1.0, 2.0, 3.0 ]; - out = filledarray( 1.0, arr, 'generic' ); - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (default, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=bool, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( false, arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = new Float64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( true, arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex128Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = new Complex64Array( [ 2.0, 2.0, 2.0, 2.0 ] ); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1, arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { - var expected; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = filledarray( 1.0, arr, 'generic' ); - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1.0, buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=bool, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( false, buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 2 ); - out = filledarray( true, buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( 1, buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarray( 1, buf, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( false, buf, 4, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 8 ); - out = filledarray( true, buf, 4, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 32, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 16, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarray( 1, buf, 4, 'generic' ); - } -}); - -tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( 1.0, buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1.0, buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint8Array( [ 0, 0, 0, 0 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( false, buf, 1, 4, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - buf = new ArrayBuffer( 6 ); - out = filledarray( true, buf, 1, 4, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 64 ); - out = filledarray( new Complex128( 1.0, 1.0 ), buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - buf = new ArrayBuffer( 32 ); - out = filledarray( new Complex64( 1.0, 1.0 ), buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Int32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint32Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Int16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint16Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Int8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint8Array( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var expected; - var buf; - var out; - - expected = new Uint8ClampedArray( [ 1, 1 ] ); - - buf = new ArrayBuffer( 16 ); - out = filledarray( 1, buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var buf = new ArrayBuffer( 8 ); - return filledarray( 1, buf, 4, 1, 'generic' ); - } -}); - -tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=bool, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint8Array( [ 0, 0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( false, arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - expected = new Uint8Array( [ 1, 1 ] ); - - arr = iterConstant( 0.0, { - 'iter': 2 - }); - out = filledarray( true, arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex128( 1.0, 1.0 ), arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); - - arr = iterConstant( 3.0, { - 'iter': 2 - }); - out = filledarray( new Complex64( 1.0, 1.0 ), arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( out, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Int32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint32Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Int16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint16Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Int8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint8Array( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1, arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { - var expected; - var arr; - var out; - - expected = [ 1.0, 1.0, 1.0 ]; - - arr = iterConstant( 3, { - 'iter': 3 - }); - out = filledarray( 1.0, arr, 'generic' ); - t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); - t.strictEqual( out.length, expected.length, 'returns expected value' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/fixed-endian-factory/README.md b/fixed-endian-factory/README.md deleted file mode 100644 index 2ff09109d..000000000 --- a/fixed-endian-factory/README.md +++ /dev/null @@ -1,1048 +0,0 @@ - - -# fixedEndianFactory - -> Return a typed array constructor for creating typed arrays having a specified byte order. - - - -
- -In contrast to built-in typed array constructors which store values according to the host platform byte order, the typed array constructors returned by the factory function allow enforcing a specific byte order. Such enforcement can be particularly advantageous when working with memory buffers which do not necessarily follow host platform byte order, such as [WebAssembly memory][@stdlib/wasm/memory]. - -
- - - - - -
- -## Usage - -```javascript -var fixedEndianFactory = require( '@stdlib/array/fixed-endian-factory' ); -``` - -#### fixedEndianFactory( dtype ) - -Returns a typed array constructor for creating typed arrays having a specified [data type][@stdlib/array/typed-dtypes] and byte order. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); -// returns - -var Float32ArrayFE = fixedEndianFactory( 'float32' ); -// returns -``` - -* * * - -### Typed Array Constructor - -#### TypedArrayFE( endianness ) - -A typed array constructor which returns a typed array representing values stored in a specified byte order. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian' ); -// returns -``` - -#### TypedArrayFE( endianness, length ) - -Returns a typed array having a specified length and byte order. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 5 ); -// returns -``` - -#### TypedArrayFE( endianness, typedarray ) - -Creates a typed array from another typed array. - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr1 = new Float32Array( [ 0.5, 0.5, 0.5 ] ); -var arr2 = new Float64ArrayFE( 'little-endian', arr1 ); -// returns - -var v = arr2.get( 0 ); -// returns 0.5 -``` - -#### TypedArrayFE( endianness, obj ) - -Creates a typed array from an array-like object or iterable. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 0.5, 0.5, 0.5 ] ); -// returns - -var v = arr.get( 0 ); -// returns 0.5 -``` - -#### TypedArrayFE( endianness, buffer\[, byteOffset\[, length]] ) - -Returns a typed array view of an [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var buf = new ArrayBuffer( 32 ); -var arr = new Float64ArrayFE( 'little-endian', buf, 0, 4 ); -// returns -``` - -* * * - -### Typed Array Properties - - - -#### TypedArrayFE.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var nbytes = Float64ArrayFE.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### TypedArrayFE.name - -Typed array constructor name. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var str = Float64ArrayFE.name; -// returns 'Float64ArrayFE' -``` - - - -#### TypedArrayFE.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the typed array. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### TypedArrayFE.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the typed array. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 5 ); -var byteLength = arr.byteLength; -// returns 40 -``` - - - -#### TypedArrayFE.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the typed array from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### TypedArrayFE.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### TypedArrayFE.prototype.length - -**Read-only** property which returns the number of view elements. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Typed Array Methods - - - -#### TypedArrayFE.from( endianness, src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like object or an iterable. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = Float64ArrayFE.from( 'little-endian', [ 1.0, -1.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2.0; -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = Float64ArrayFE.from( 'little-endian', [ 1.0, -1.0 ], mapFcn ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 -``` - -A callback function is provided two arguments: - -- **value**: source value. -- **index**: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2.0; -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var ctx = { - 'count': 0 -}; - -var arr = Float64ArrayFE.from( 'little-endian', [ 1.0, -1.0 ], mapFcn, ctx ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 - -var n = ctx.count; -// returns 2 -``` - - - -#### TypedArrayFE.of( endianness, element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = Float64ArrayFE.of( 'little-endian', 1.0, -1.0 ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - - - -#### TypedArrayFE.prototype.at( i ) - -Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer positions. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -// returns - -var out = arr.at( 0 ); -// returns 1.0 - -out = arr.at( -1 ); -// returns 3.0 -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -// returns - -var v = arr.at( 100 ); -// returns undefined - -v = arr.at( -100 ); -// returns undefined -``` - - - -#### TypedArrayFE.prototype.every( predicate\[, thisArg] ) - -Tests whether all the elements in an array pass a test implemented by a predicate function. - -```javascript -function isNegative( v ) { - return v < 0; -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ -1.0, -2.0, -3.0, -4.0 ] ); -// returns - -var bool = arr.every( isNegative ); -// returns true -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function isPositive( v, i ) { - this.count += 1; - return v > 0; -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, -3.0 ] ); -// returns - -var context = { - 'count': 0 -}; - -var bool = arr.every( isPositive, context ); -// returns false - -var count = context.count; -// returns 3 -``` - - - -#### TypedArrayFE.prototype.filter( predicate\[, thisArg] ) - -Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - -```javascript -function predicate( v ) { - return ( v % 2 === 0 ); -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - -var out = arr.filter( predicate ); -// returns - -var len = out.length; -// returns 2 - -var v = out.get( 0 ); -// returns 2.0 - -v = out.get( 1 ); -// return 4.0 -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function predicate( v, i ) { - this.count += 1; - return ( v % 2 === 0 ); -} - -var context = { - 'count': 0 -}; - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - -var out = arr.filter( predicate, context ); -// returns - -var len = out.length; -// returns 2 - -var count = context.count; -// returns 4 -``` - - - -#### TypedArrayFE.prototype.forEach( callbackFn\[, thisArg] ) - -Invokes a function once for each array element. - -```javascript -function log( v, i ) { - console.log( '%s: %s', i.toString(), v.toString() ); -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 3 ); -// returns - -arr.set( 1.5, 0 ); -arr.set( 2.5, 1 ); -arr.set( 3.5, 2 ); - -arr.forEach( log ); -/* => - 0: 1.5 - 1: 2.5 - 2: 3.5 -*/ -``` - -The invoked function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function fcn( v, i ) { - this.count += 1; - console.log( '%s: %s', i.toString(), v.toString() ); -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 3 ); -// returns - -var context = { - 'count': 0 -}; - -arr.set( 1.0, 0 ); -arr.set( 2.0, 1 ); -arr.set( 3.0, 2 ); - -arr.forEach( fcn, context ); - -var count = context.count; -// returns 3 -``` - - - -#### TypedArrayFE.prototype.get( i ) - -Returns an array element located at a nonnegative integer position (index) `i`. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 10 ); -// returns - -// Set the first element: -arr.set( 1.0, 0 ); - -// Get the first element: -var v = arr.get( 0 ); -// returns 1.0 -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 10 ); -// returns - -var v = arr.get( 100 ); -// returns undefined -``` - - - -#### TypedArrayFE.prototype.includes( searchElement\[, fromIndex] ) - -Returns a boolean indicating whether an array includes a provided value. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - -var idx = arr.includes( 2.0 ); -// returns true - -idx = arr.includes( 2.0, 2 ); -// returns true - -idx = arr.includes( 2.0, -4 ); -// returns true - -idx = arr.includes( 5.0 ); -// returns false -``` - - - -#### TypedArrayFE.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the first index at which a given element can be found. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - -var idx = arr.indexOf( 2.0 ); -// returns 1 - -idx = arr.indexOf( 2.0, 2 ); -// returns 4 - -idx = arr.indexOf( 2.0, -4 ); -// returns 1 -``` - -If `searchElement` is not present in the array, the method returns `-1`. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - -var idx = arr.indexOf( 5.0 ); -// returns -1 -``` - - - -#### TypedArrayFE.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the last index at which a given element can be found in the array. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - -var idx = arr.lastIndexOf( 2.0 ); -// returns 4 - -idx = arr.lastIndexOf( 2.0, 3 ); -// returns 1 - -idx = arr.lastIndexOf( 2.0, -2 ); -// returns 1 -``` - -If `searchElement` is not present in the array, the method returns `-1`. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - -var idx = arr.lastIndexOf( 5.0 ); -// returns -1 -``` - - - -#### TypedArray.prototype.map( callbackFn\[, thisArg] ) - -Returns a new array with each element being the result of a provided callback function. - -```javascript -function fcn( v ) { - return -v; -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -// returns - -var out = arr.map( fcn ); -// returns - -var z = out.get( 0 ); -// returns -1.0 - -z = out.get( 1 ); -// returns -2.0 - -z = out.get( 2 ); -// returns -3.0 -``` - -The callback function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function fcn( v, i ) { - this.count += i; - return -v; -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', 3 ); - -arr.set( -1.0, 0 ); -arr.set( 1.0, 1 ); -arr.set( -1.0, 2 ); - -var context = { - 'count': 0 -}; - -var out = arr.map( fcn, context ); -// returns - -var count = context.count; -// returns 3; -``` - - - -#### TypedArray.prototype.reduce( reducerFn\[, initialValue] ) - -Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - -```javascript -function reducer( acc, v ) { - return ( acc && v ); -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] ); -// returns - -var out = arr.reduce( reducer ); -// returns 0.0 -``` - -The reducer function is provided four arguments: - -- **acc**: accumulated result. -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. - -```javascript -function reducer( acc, v ) { - if ( v ) { - return acc + 1; - } - return acc; -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] ); -// returns - -var out = arr.reduce( reducer, 0 ); -// returns 2 -``` - - - -#### TypedArray.prototype.reduceRight( reducerFn\[, initialValue] ) - -Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - -```javascript -function reducer( acc, v ) { - return ( acc && v ); -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] ); -// returns - -var out = arr.reduceRight( reducer ); -// returns 0.0 -``` - -The reducer function is provided four arguments: - -- **acc**: accumulated result. -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument. - -```javascript -function reducer( acc, v ) { - if ( v ) { - return acc + 1; - } - return acc; -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 1.0 ] ); -// returns - -var out = arr.reduceRight( reducer, 0 ); -// returns 2 -``` - - - -#### TypedArrayFE.prototype.set( arr\[, offset] ) - -Sets array elements. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 - -v = arr.get( 1 ); -// returns 2.0 - -// Set the first two array elements: -arr.set( [ 4.0, 5.0 ] ); - -v = arr.get( 0 ); -// returns 4.0 - -v = arr.get( 1 ); -// returns 5.0 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -// returns - -// Set the last two array elements: -arr.set( [ 4.0, 5.0 ], 1 ); - -var v = arr.get( 1 ); -// returns 4.0 - -v = arr.get( 2 ); -// returns 5.0 -``` - -A few notes: - -- If `i` is out-of-bounds, the method throws an error. -- If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error. -- If provided a typed array which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range. - - - -#### TypedArrayFE.prototype.some( predicate\[, thisArg] ) - -Tests whether at least one element in an array passes a test implemented by a predicate function. - -```javascript -function isPositive( v ) { - return v > 0; -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ -1.0, 2.0, -3.0, -4.0 ] ); -// returns - -var bool = arr.some( isPositive ); -// returns true -``` - -The `predicate` function is provided three arguments: - -- **value**: current array element. -- **index**: current array element index. -- **arr**: the array on which this method was called. - -To set the function execution context, provide a `thisArg`. - -```javascript -function isPositive( v, i ) { - this.count += 1; - return v > 0; -} - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ -1.0, -2.0, -3.0 ] ); -// returns - -var context = { - 'count': 0 -}; - -var bool = arr.some( isPositive, context ); -// returns false - -var count = context.count; -// returns 3 -``` - - - -#### TypedArrayFE.prototype.toString() - -Serializes an array as a string. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -// returns - -var str = arr.toString(); -// returns '1,2,3' -``` - - - -#### TypedArrayFE.prototype.join( \[separator] ) - -Returns a new string by concatenating all array elements. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); - -var str = arr.join(); -// returns '1,2,3' -``` - -By default, the method separates serialized array elements with a comma. To use an alternative separator, provide a `separator` string. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); - -var str = arr.join( ' - ' ); -// returns '1 - 2 - 3' -``` - - - -#### TypedArrayFE.prototype.with( index, value ) - -Returns a new typed array with the element at a provided index replaced with a provided value. - -```javascript -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -// returns - -var out = arr.with( 0, 0.0 ); -// returns - -var v = out.get( 0 ); -// returns 0.0 -``` - -
- - - - - -
- -* * * - -## Notes - -- A returned constructor supports the following byte orders: - - - **little-endian**: store values such that bytes are stored from least-to-most significant bytes. This is the dominant ordering for processor architectures and their associated memory. This is also the ordering for [WebAssembly memory][@stdlib/wasm/memory]. - - **big-endian**: store values such that bytes are stored from most-to-least significant bytes. This is the dominant ordering in network protocols. - -- While returned constructors _strive_ to maintain (but do not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: - - - Constructors do **not** require the `new` operator. - - Accessing array elements using bracket syntax (e.g., `X[i]`) is **not** supported. Instead, one **must** use the `.get()` method. - -
- - - - - -
- -* * * - -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var logEach = require( '@stdlib/console/log-each' ); -var fixedEndianFactory = require( '@stdlib/array/fixed-endian-factory' ); - -var Float64ArrayFE = fixedEndianFactory( 'float64' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayFE( 'little-endian', 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayFE( 'big-endian', arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayFE( 'little-endian', arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayFE( 'big-endian', arr.buffer, 8, 2 ); -logEach( '%s', out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/fixed-endian-factory/benchmark/benchmark.at.js b/fixed-endian-factory/benchmark/benchmark.at.js deleted file mode 100644 index e1971ef52..000000000 --- a/fixed-endian-factory/benchmark/benchmark.at.js +++ /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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::nonnegative_indices:at:endianness=little-endian', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayFE( 'little-endian', arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i % N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::negative_indices:at:endianness=little-endian', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayFE( 'little-endian', arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -( i % N ) - 1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::nonnegative_indices:at:endianness=big-endian', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 1000; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayFE( 'big-endian', arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( i % N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::negative_indices:at:endianness=big-endian', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 1000; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayFE( 'big-endian', arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.at( -( i % N ) - 1 ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.every.js b/fixed-endian-factory/benchmark/benchmark.every.js deleted file mode 100644 index e0cc13643..000000000 --- a/fixed-endian-factory/benchmark/benchmark.every.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/fixed-endian-factory/benchmark/benchmark.every.length.js b/fixed-endian-factory/benchmark/benchmark.every.length.js deleted file mode 100644 index d90f91972..000000000 --- a/fixed-endian-factory/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,113 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {TypedArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.filter.js b/fixed-endian-factory/benchmark/benchmark.filter.js deleted file mode 100644 index 1cee20ed4..000000000 --- a/fixed-endian-factory/benchmark/benchmark.filter.js +++ /dev/null @@ -1,59 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( out instanceof Float64ArrayFE ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v % 2 === 0; - } -}); diff --git a/fixed-endian-factory/benchmark/benchmark.filter.length.js b/fixed-endian-factory/benchmark/benchmark.filter.length.js deleted file mode 100644 index 851302fef..000000000 --- a/fixed-endian-factory/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,112 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {TypedArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value % 2 === 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( out instanceof Float64ArrayFE ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.for_each.js b/fixed-endian-factory/benchmark/benchmark.for_each.js deleted file mode 100644 index 0bb9137f9..000000000 --- a/fixed-endian-factory/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var arr; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( check ); - if ( arr.length !== 4 ) { - b.fail( 'should not change an array length' ); - } - } - b.toc(); - if ( arr.length !== 4 ) { - b.fail( 'should not change an array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function check( v ) { - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - } -}); diff --git a/fixed-endian-factory/benchmark/benchmark.for_each.length.js b/fixed-endian-factory/benchmark/benchmark.for_each.length.js deleted file mode 100644 index e1579ef74..000000000 --- a/fixed-endian-factory/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,105 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( callback ); - if ( arr.length !== len ) { - b.fail( 'should not change an array length' ); - } - } - b.toc(); - if ( arr.length !== len ) { - b.fail( 'should not change an array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function callback( value ) { - if ( isnan( value ) ) { - throw new Error( 'something went wrong' ); - } - } - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.from.js b/fixed-endian-factory/benchmark/benchmark.from.js deleted file mode 100644 index bb4778c75..000000000 --- a/fixed-endian-factory/benchmark/benchmark.from.js +++ /dev/null @@ -1,311 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return v * 2.0; - } -}); diff --git a/fixed-endian-factory/benchmark/benchmark.get.js b/fixed-endian-factory/benchmark/benchmark.get.js deleted file mode 100644 index 92da9fe66..000000000 --- a/fixed-endian-factory/benchmark/benchmark.get.js +++ /dev/null @@ -1,90 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':get:endianness=little-endian', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayFE( 'little-endian', arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get:endianness=big-endian', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayFE( 'big-endian', arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.includes.js b/fixed-endian-factory/benchmark/benchmark.includes.js deleted file mode 100644 index d1c27cc4d..000000000 --- a/fixed-endian-factory/benchmark/benchmark.includes.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var factory = require( './../lib' ); -var pkg = require( './../package.json' ).name; - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var result; - var arr; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - result = arr.includes( 5.0, 0 ); - if ( typeof result !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( result ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.includes.length.js b/fixed-endian-factory/benchmark/benchmark.includes.length.js deleted file mode 100644 index 0f6a1dfd4..000000000 --- a/fixed-endian-factory/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var factory = require( './../lib' ); -var pkg = require( './../package.json' ).name; - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var result; - var v; - var i; - - v = len - 1; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - result = arr.includes( v ); - if ( typeof result !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( result ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.index_of.js b/fixed-endian-factory/benchmark/benchmark.index_of.js deleted file mode 100644 index 04944e3cc..000000000 --- a/fixed-endian-factory/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var factory = require( './../lib' ); -var pkg = require( './../package.json' ).name; - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var arr; - var idx; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.indexOf( 5.0, 0 ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.index_of.length.js b/fixed-endian-factory/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 249389408..000000000 --- a/fixed-endian-factory/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var factory = require( './../lib' ); -var pkg = require( './../package.json' ).name; - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var v; - var i; - - v = len - 1; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.indexOf( v ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.instantiation.js b/fixed-endian-factory/benchmark/benchmark.instantiation.js deleted file mode 100644 index 3142a7efe..000000000 --- a/fixed-endian-factory/benchmark/benchmark.instantiation.js +++ /dev/null @@ -1,440 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var ArrayBuffer = require( './../../buffer' ); -var Float64Array = require( './../../float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Returns an "iterable" object. -* -* @private -* @returns {Object} iterable object -*/ -function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } -} - - -// MAIN // - -bench( pkg+'::instantiation,new:endianness=little-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new:endianness=big-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new:endianness=little-endian', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float64ArrayFE; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor( 'little-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new:endianness=big-endian', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float64ArrayFE; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor( 'big-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length:endianness=little-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length:endianness=big-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable:endianness=little-endian', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable:endianness=big-endian', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.join.js b/fixed-endian-factory/benchmark/benchmark.join.js deleted file mode 100644 index 8defd362d..000000000 --- a/fixed-endian-factory/benchmark/benchmark.join.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var factory = require( './../lib' ); -var pkg = require( './../package.json' ).name; - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.join.length.js b/fixed-endian-factory/benchmark/benchmark.join.length.js deleted file mode 100644 index 8457dd036..000000000 --- a/fixed-endian-factory/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var factory = require( './../lib' ); -var pkg = require( './../package.json' ).name; - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.join( '/' ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.js b/fixed-endian-factory/benchmark/benchmark.js deleted file mode 100644 index 619c1f968..000000000 --- a/fixed-endian-factory/benchmark/benchmark.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = factory( 'float64' ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.last_index_of.js b/fixed-endian-factory/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 695e73fb3..000000000 --- a/fixed-endian-factory/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var factory = require( './../lib' ); -var pkg = require( './../package.json' ).name; - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var arr; - var idx; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.lastIndexOf( 5.0, arr.length - 1 ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.last_index_of.length.js b/fixed-endian-factory/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index aaa6c8780..000000000 --- a/fixed-endian-factory/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,103 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var factory = require( './../lib' ); -var pkg = require( './../package.json' ).name; - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var idx; - var v; - var i; - - v = len - 1; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = arr.lastIndexOf( v ); - if ( typeof idx !== 'number' ) { - b.fail( 'should return an integer' ); - } - } - b.toc(); - if ( !isInteger( idx ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.map.js b/fixed-endian-factory/benchmark/benchmark.map.js deleted file mode 100644 index ddb59955a..000000000 --- a/fixed-endian-factory/benchmark/benchmark.map.js +++ /dev/null @@ -1,59 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( identity ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( out instanceof Float64ArrayFE ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function identity( v ) { - return v; - } -}); diff --git a/fixed-endian-factory/benchmark/benchmark.map.length.js b/fixed-endian-factory/benchmark/benchmark.map.length.js deleted file mode 100644 index aa0978d7f..000000000 --- a/fixed-endian-factory/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,112 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Identity function. -* -* @private -* @param {number} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {TypedArray} arr - array instance -* @returns {number} input array element -*/ -function identity( value ) { - return value; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( identity ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( out instanceof Float64ArrayFE ) ) { - b.fail( 'should return a TypedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.of.js b/fixed-endian-factory/benchmark/benchmark.of.js deleted file mode 100644 index 273c669ae..000000000 --- a/fixed-endian-factory/benchmark/benchmark.of.js +++ /dev/null @@ -1,74 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.of( 'little-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 'little-endian', 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.of.apply( Float64ArrayFE, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.property_access.js b/fixed-endian-factory/benchmark/benchmark.property_access.js deleted file mode 100644 index e3f26a0fe..000000000 --- a/fixed-endian-factory/benchmark/benchmark.property_access.js +++ /dev/null @@ -1,127 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.reduce.js b/fixed-endian-factory/benchmark/benchmark.reduce.js deleted file mode 100644 index 9ad7fe329..000000000 --- a/fixed-endian-factory/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,75 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {number} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 0.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( reducer, 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.reduce.length.js b/fixed-endian-factory/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 2848ca062..000000000 --- a/fixed-endian-factory/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,116 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {number} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( reducer ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.reduce_right.js b/fixed-endian-factory/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 8507bd66c..000000000 --- a/fixed-endian-factory/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,75 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {number} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 0.0, 0.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( reducer, 0 ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.reduce_right.length.js b/fixed-endian-factory/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 09e37849d..000000000 --- a/fixed-endian-factory/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,116 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Reducer function. -* -* @private -* @param {integer} acc - accumulated value -* @param {number} value - current array element -* @param {integer} index - current array index -* @returns {integer} accumulated value -*/ -function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( reducer ); - if ( typeof out !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isInteger( out ) ) { - b.fail( 'should return an integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.set.js b/fixed-endian-factory/benchmark/benchmark.set.js deleted file mode 100644 index db914423f..000000000 --- a/fixed-endian-factory/benchmark/benchmark.set.js +++ /dev/null @@ -1,214 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../float64' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::number:set:endianness=little-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayFE( 'little-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::number:set:endianness=big-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayFE( 'big-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:set:endianness=little-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayFE( 'little-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:set:endianness=big-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayFE( 'big-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set:endianness=little-endian', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float64ArrayFE( 'little-endian', values ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set:endianness=big-endian', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float64ArrayFE( 'big-endian', values ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.set.length.js b/fixed-endian-factory/benchmark/benchmark.set.length.js deleted file mode 100644 index c459e9559..000000000 --- a/fixed-endian-factory/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,115 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randu = require( '@stdlib/random/array/randu' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - - arr1 = randu( len ); - arr2 = randu( len ); - arr3 = randu( len ); - arr1 = new Float64ArrayFE( 'little-endian', arr1 ); - - values = [ - new Float64ArrayFE( 'little-endian', arr2 ), - new Float64ArrayFE( 'big-endian', arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.some.js b/fixed-endian-factory/benchmark/benchmark.some.js deleted file mode 100644 index c0494cdf9..000000000 --- a/fixed-endian-factory/benchmark/benchmark.some.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ -1.0, -2.0, -2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/fixed-endian-factory/benchmark/benchmark.some.length.js b/fixed-endian-factory/benchmark/benchmark.some.length.js deleted file mode 100644 index 6cb1b10b6..000000000 --- a/fixed-endian-factory/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,113 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Predicate function. -* -* @private -* @param {number} value - array element -* @param {NonNegativeInteger} idx - array element index -* @param {TypedArray} arr - array instance -* @returns {boolean} boolean indicating whether a value passes a test -*/ -function predicate( value ) { - return value < 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.to_string.js b/fixed-endian-factory/benchmark/benchmark.to_string.js deleted file mode 100644 index 47494aa76..000000000 --- a/fixed-endian-factory/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.to_string.length.js b/fixed-endian-factory/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 1b5abedb7..000000000 --- a/fixed-endian-factory/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/benchmark/benchmark.with.js b/fixed-endian-factory/benchmark/benchmark.with.js deleted file mode 100644 index cc7eb40df..000000000 --- a/fixed-endian-factory/benchmark/benchmark.with.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':with', function benchmark( b ) { - var values; - var out; - var arr; - var i; - - values = [ - 1.0, - 2.0, - 3.0 - ]; - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i % arr.length, values[ i % values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( out instanceof Float64ArrayFE ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-factory/benchmark/benchmark.with.length.js b/fixed-endian-factory/benchmark/benchmark.with.length.js deleted file mode 100644 index e20c85cd4..000000000 --- a/fixed-endian-factory/benchmark/benchmark.with.length.js +++ /dev/null @@ -1,106 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayFE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 1.0, - 2.0, - 3.0 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.with( i % arr.length, values[ i % values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !( out instanceof Float64ArrayFE ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':with:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-factory/examples/index.js b/fixed-endian-factory/examples/index.js deleted file mode 100644 index 52a537239..000000000 --- a/fixed-endian-factory/examples/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -var Float64Array = require( './../../float64' ); -var logEach = require( '@stdlib/console/log-each' ); -var factory = require( './../lib' ); - -var Float64ArrayFE = factory( 'float64' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayFE( 'little-endian', 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayFE( 'big-endian', arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayFE( 'little-endian', arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayFE( 'big-endian', arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/fixed-endian-factory/lib/from_iterator.js b/fixed-endian-factory/lib/from_iterator.js deleted file mode 100644 index c1adb5d9a..000000000 --- a/fixed-endian-factory/lib/from_iterator.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/fixed-endian-factory/lib/from_iterator_map.js b/fixed-endian-factory/lib/from_iterator_map.js deleted file mode 100644 index 9a6e354eb..000000000 --- a/fixed-endian-factory/lib/from_iterator_map.js +++ /dev/null @@ -1,53 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( clbk.call( thisArg, v.value, i ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/fixed-endian-factory/lib/index.js b/fixed-endian-factory/lib/index.js deleted file mode 100644 index 0183dad67..000000000 --- a/fixed-endian-factory/lib/index.js +++ /dev/null @@ -1,106 +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. -*/ - -'use strict'; - -/** -* Return a typed array constructor for creating typed arrays having a specified byte order. -* -* @module @stdlib/array/fixed-endian-factory -* -* @example -* var factory = require( '@stdlib/array/fixed-endian-factory' ); -* -* var Float64ArrayFE = factory( 'float64' ); -* -* var arr = new Float64ArrayFE( 'little-endian' ); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var factory = require( '@stdlib/array/fixed-endian-factory' ); -* -* var Float64ArrayFE = factory( 'float64' ); -* -* var arr = new Float64ArrayFE( 'little-endian', 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var factory = require( '@stdlib/array/fixed-endian-factory' ); -* -* var Float64ArrayFE = factory( 'float64' ); -* -* var arr = new Float64ArrayFE( 'little-endian', [ 1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var factory = require( '@stdlib/array/fixed-endian-factory' ); -* -* var Float64ArrayFE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayFE( 'little-endian', buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var factory = require( '@stdlib/array/fixed-endian-factory' ); -* -* var Float64ArrayFE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayFE( 'little-endian', buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var factory = require( '@stdlib/array/fixed-endian-factory' ); -* -* var Float64ArrayFE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayFE( 'little-endian', buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/fixed-endian-factory/lib/main.js b/fixed-endian-factory/lib/main.js deleted file mode 100644 index 6e64abffb..000000000 --- a/fixed-endian-factory/lib/main.js +++ /dev/null @@ -1,1230 +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. -*/ - -/* eslint-disable max-len, no-restricted-syntax, no-invalid-this, max-lines */ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert/is-collection' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isObject = require( '@stdlib/assert/is-object' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isByteOrder = require( './../../base/assert/is-byte-order' ); -var lowercase = require( '@stdlib/string/base/lowercase' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var isPrototypeOf = require( '@stdlib/assert/is-prototype-of' ); // eslint-disable-line stdlib/no-redeclare -var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); -var ArrayBuffer = require( './../../buffer' ); -var DataView = require( './../../dataview' ); -var getter = require( './../../base/getter' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var contains = require( './../../base/assert/contains' ).factory; -var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); -var capitalize = require( '@stdlib/string/base/capitalize' ); -var format = require( '@stdlib/string/format' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var LITTLE_ENDIAN = 'little-endian'; -var BIG_ENDIAN = 'big-endian'; -var DTYPES = [ 'float64', 'float32', 'int32', 'int16', 'uint32', 'uint16' ]; -var DTYPE2SET = { - 'float64': 'setFloat64', - 'float32': 'setFloat32', - 'int32': 'setInt32', - 'int16': 'setInt16', - 'uint32': 'setUint32', - 'uint16': 'setUint16' -}; -var DTYPE2GET = { - 'float64': 'getFloat64', - 'float32': 'getFloat32', - 'int32': 'getInt32', - 'int16': 'getInt16', - 'uint32': 'getUint32', - 'uint16': 'getUint16' -}; -var CHAR2ARTICLE = { - 'c': 'a', - 'f': 'a', - 'i': 'an', - 'u': 'a', - 'b': 'a' -}; -var isDataType = contains( DTYPES ); - - -// FUNCTIONS // - -/** -* Normalizes a byte order value. -* -* @private -* @param {*} value - byte order -* @returns {(string|null)} normalized byte order -*/ -function byteOrder( value ) { - return ( isString( value ) ) ? lowercase( value ) : null; -} - -/** -* Tests whether a provided byte order is little-endian byte order. -* -* @private -* @param {string} value - byte order -* @returns {boolean} boolean indicating whether a byte order is little-endian byte order -*/ -function isLittleEndian( value ) { - return ( value === LITTLE_ENDIAN ); -} - -/** -* Resolves a byte order string from a boolean flag. -* -* @private -* @param {boolean} isLE - flag indicating whether an array is little-endian -* @returns {string} resolved byte order -*/ -function flag2byteOrder( isLE ) { - return ( isLE ) ? LITTLE_ENDIAN : BIG_ENDIAN; -} - -/** -* Converts a data type string to a constructor name. -* -* @private -* @param {string} dtype - data type -* @returns {string} constructor name -* -* @example -* var n = dtype2ctor( 'float64' ); -* // returns 'Float64ArrayFE' -* -* @example -* var n = dtype2ctor( 'int32' ); -* // returns 'Int32ArrayFE' -*/ -function dtype2ctor( dtype ) { - return capitalize( dtype ) + 'ArrayFE'; -} - - -// MAIN // - -/** -* Returns a typed array constructor for creating typed arrays having a specified byte order. -* -* @param {string} dtype - typed array data type -* @throws {TypeError} first argument must be a supported data type -* @returns {Function} typed array constructor -* -* @example -* var Float64ArrayFE = factory( 'float64' ); -* -* var arr = new Float64ArrayFE( 'little-endian' ); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float64ArrayFE = factory( 'float64' ); -* -* var arr = new Float64ArrayFE( 'little-endian', 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float64ArrayFE = factory( 'float64' ); -* -* var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var Float64ArrayFE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayFE( 'little-endian', buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var Float64ArrayFE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayFE( 'little-endian', buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var Float64ArrayFE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayFE( 'little-endian', buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function factory( dtype ) { // eslint-disable-line max-lines-per-function, stdlib/jsdoc-require-throws-tags - var BYTES_PER_ELEMENT; - var CTOR_NAME; - var GETTER; - var SETTER; - - if ( !isDataType( dtype ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a supported data type. Value: `%s`.', dtype ) ); - } - BYTES_PER_ELEMENT = bytesPerElement( dtype ); - CTOR_NAME = dtype2ctor( dtype ); - GETTER = DTYPE2GET[ dtype ]; - SETTER = DTYPE2SET[ dtype ]; - - /** - * Typed array constructor which returns a typed array representing an array of values in a specified byte order. - * - * @private - * @constructor - * @param {string} endianness - byte order - * @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable - * @param {NonNegativeInteger} [byteOffset=0] - byte offset - * @param {NonNegativeInteger} [length] - view length - * @throws {TypeError} first argument must be a supported byte order - * @throws {TypeError} if provided only two arguments, the second argument must be a valid argument - * @throws {TypeError} byte offset must be a nonnegative integer - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {RangeError} byte offset must be a multiple of the data type size - * @throws {TypeError} view length must be a positive multiple of the data type size - * @returns {TypedArray} typed array instance - */ - function TypedArray() { - var byteOffset; - var endianness; - var nargs; - var isLE; - var buf; - var len; - var arg; - var tmp; - - nargs = arguments.length; - if ( !(this instanceof TypedArray) ) { - if ( nargs < 2 ) { - return new TypedArray( arguments[0] ); - } - if ( nargs === 2 ) { - return new TypedArray( arguments[0], arguments[1] ); - } - if ( nargs === 3 ) { - return new TypedArray( arguments[0], arguments[1], arguments[2] ); - } - return new TypedArray( arguments[0], arguments[1], arguments[2], arguments[3] ); - } - endianness = byteOrder( arguments[ 0 ] ); - if ( endianness === null || !isByteOrder( endianness ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a supported byte order. Value: `%s`.', arguments[ 0 ] ) ); - } - isLE = isLittleEndian( endianness ); - - nargs -= 1; - - // Create the underlying data buffer... - if ( nargs === 0 ) { - buf = new DataView( new ArrayBuffer( 0 ) ); // backward-compatibility - } else if ( nargs === 1 ) { - arg = arguments[ nargs ]; - if ( isNonNegativeInteger( arg ) ) { - buf = new DataView( new ArrayBuffer( arg*BYTES_PER_ELEMENT ) ); - } else if ( isCollection( arg ) ) { - buf = fromArray( new DataView( new ArrayBuffer( arg.length*BYTES_PER_ELEMENT ) ), arg, isLE ); - } else if ( isArrayBuffer( arg ) ) { - buf = new DataView( arg ); - if ( !isNonNegativeInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) ); - } - } else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - buf = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - tmp = fromIterator( buf ); - buf = fromArray( new DataView( new ArrayBuffer( tmp.length*BYTES_PER_ELEMENT ) ), tmp, isLE ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - } else { - buf = arguments[ 1 ]; - if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ArrayBuffer. Value: `%s`.', buf ) ); - } - byteOffset = arguments[ 2 ]; - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) ); - } - if ( nargs === 2 ) { - buf = new DataView( buf, byteOffset ); - } else { - len = arguments[ 3 ]; - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); - } - len *= BYTES_PER_ELEMENT; - if ( len > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len ) ); - } - buf = new DataView( buf, byteOffset, len ); - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_length', buf.byteLength/BYTES_PER_ELEMENT ); - setReadOnly( this, '_isLE', isLE ); - - return this; - } - - /** - * Size (in bytes) of each array element. - * - * @private - * @name BYTES_PER_ELEMENT - * @memberof TypedArray - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - - /** - * Constructor name. - * - * @private - * @name name - * @memberof TypedArray - * @readonly - * @type {string} - */ - setReadOnly( TypedArray, 'name', CTOR_NAME ); - - /** - * Creates a new typed array from an array-like object or an iterable. - * - * @private - * @name from - * @memberof TypedArray - * @type {Function} - * @param {string} endianness - byte order - * @param {(Collection|Iterable)} src - array-like object or iterable - * @param {Function} [clbk] - callback to invoke for each source element - * @param {*} [thisArg] - context - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @throws {TypeError} first argument must be a supported byte order - * @throws {TypeError} second argument must be an array-like object or an iterable - * @throws {TypeError} third argument must be a function - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'from', function from( endianness, src ) { - var thisArg; - var order; - var nargs; - var clbk; - var isLE; - var out; - var buf; - var tmp; - var get; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - order = byteOrder( endianness ); - if ( order === null || !isByteOrder( order ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a supported byte order. Value: `%s`.', endianness ) ); - } - isLE = isLittleEndian( order ); - - nargs = arguments.length; - if ( nargs > 2 ) { - clbk = arguments[ 2 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', clbk ) ); - } - if ( nargs > 3 ) { - thisArg = arguments[ 3 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - if ( src.get && src.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - out = new this( order, len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), isLE ); - } - return out; - } - return new this( order, src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object or an iterable. Value: `%s`.', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - len = tmp.length; - out = new this( order, len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], isLE ); - } - return out; - } - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object or an iterable. Value: `%s`.', src ) ); - }); - - /** - * Creates a new typed array from a variable number of arguments. - * - * @private - * @name of - * @memberof TypedArray - * @type {Function} - * @param {string} endianness - byte order - * @param {...*} element - array elements - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @throws {TypeError} first argument must be a supported byte order - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'of', function of( endianness ) { - var order; - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - order = byteOrder( endianness ); - if ( order === null || !isByteOrder( order ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a supported byte order. Value: `%s`.', endianness ) ); - } - args = []; - for ( i = 1; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( order, args ); - }); - - /** - * Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices. - * - * @private - * @name at - * @memberof TypedArray.prototype - * @type {Function} - * @param {integer} idx - element index - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} must provide an integer - * @returns {(*|void)} array element - */ - setReadOnly( TypedArray.prototype, 'at', function at( idx ) { - var len; - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( !isInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) ); - } - len = this._length; - if ( idx < 0 ) { - idx += len; - } - if ( idx < 0 || idx >= len ) { - return; - } - return this._buffer[ GETTER ]( idx * BYTES_PER_ELEMENT, this._isLE ); - }); - - /** - * Pointer to the underlying data buffer. - * - * @private - * @name buffer - * @memberof TypedArray.prototype - * @readonly - * @type {ArrayBuffer} - */ - setReadOnlyAccessor( TypedArray.prototype, 'buffer', function get() { - return this._buffer.buffer; - }); - - /** - * Size (in bytes) of the array. - * - * @private - * @name byteLength - * @memberof TypedArray.prototype - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnlyAccessor( TypedArray.prototype, 'byteLength', function get() { - return this._buffer.byteLength; - }); - - /** - * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - * - * @private - * @name byteOffset - * @memberof TypedArray.prototype - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnlyAccessor( TypedArray.prototype, 'byteOffset', function get() { - return this._buffer.byteOffset; - }); - - /** - * Size (in bytes) of each array element. - * - * @private - * @name BYTES_PER_ELEMENT - * @memberof TypedArray.prototype - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( TypedArray.prototype, 'BYTES_PER_ELEMENT', TypedArray.BYTES_PER_ELEMENT ); - - /** - * Tests whether all elements in an array pass a test implemented by a predicate function. - * - * @private - * @name every - * @memberof TypedArray.prototype - * @type {Function} - * @param {Function} predicate - predicate function - * @param {*} [thisArg] - predicate function execution context - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} first argument must be a function - * @returns {boolean} boolean indicating whether all elements pass a test - */ - setReadOnly( TypedArray.prototype, 'every', function every( predicate, thisArg ) { - var buf; - var i; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( !predicate.call( thisArg, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this ) ) { - return false; - } - } - return true; - }); - - /** - * Returns a new array containing the elements of an array which pass a test implemented by a predicate function. - * - * @private - * @name filter - * @memberof TypedArray.prototype - * @type {Function} - * @param {Function} predicate - test function - * @param {*} [thisArg] - predicate function execution context - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} first argument must be a function - * @returns {TypedArray} typed array - */ - setReadOnly( TypedArray.prototype, 'filter', function filter( predicate, thisArg ) { - var buf; - var out; - var i; - var v; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - out = []; - for ( i = 0; i < this._length; i++ ) { - v = buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE ); - if ( predicate.call( thisArg, v, i, this ) ) { - out.push( v ); - } - } - return new this.constructor( flag2byteOrder( this._isLE ), out ); - }); - - /** - * Invokes a function once for each array element. - * - * @private - * @name forEach - * @memberof TypedArray.prototype - * @type {Function} - * @param {Function} fcn - function to invoke - * @param {*} [thisArg] - function invocation context - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} first argument must be a function - */ - setReadOnly( TypedArray.prototype, 'forEach', function forEach( fcn, thisArg ) { - var buf; - var i; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - fcn.call( thisArg, buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE ), i, this ); - } - }); - - /** - * Returns an array element. - * - * @private - * @name get - * @memberof TypedArray.prototype - * @type {Function} - * @param {NonNegativeInteger} idx - element index - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} must provide a nonnegative integer - * @returns {(*|void)} array element - */ - setReadOnly( TypedArray.prototype, 'get', function get( idx ) { - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return this._buffer[ GETTER ]( idx*BYTES_PER_ELEMENT, this._isLE ); - }); - - /** - * Returns a boolean indicating whether an array includes a provided value. - * - * @private - * @name includes - * @memberof TypedArray.prototype - * @type {Function} - * @param {*} searchElement - search element - * @param {integer} [fromIndex=0] - starting index (inclusive) - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} second argument must be an integer - * @returns {boolean} boolean indicating whether an array includes a provided value - */ - setReadOnly( TypedArray.prototype, 'includes', function includes( searchElement, fromIndex ) { - var buf; - var i; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - for ( i = fromIndex; i < this._length; i++ ) { - if ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) { - return true; - } - } - return false; - }); - - /** - * Returns the index of the first occurrence of a given element. - * - * @private - * @name indexOf - * @memberof TypedArray.prototype - * @type {Function} - * @param {*} searchElement - element to search for - * @param {integer} [fromIndex=0] - starting index (inclusive) - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} second argument must be an integer - * @returns {integer} index or -1 - */ - setReadOnly( TypedArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) { - var buf; - var i; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex < 0 ) { - fromIndex += this._length; - if ( fromIndex < 0 ) { - fromIndex = 0; - } - } - } else { - fromIndex = 0; - } - buf = this._buffer; - for ( i = fromIndex; i < this._length; i++ ) { - if ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) { - return i; - } - } - return -1; - }); - - /** - * Returns a new string by concatenating all array elements. - * - * @private - * @name join - * @memberof TypedArray.prototype - * @type {Function} - * @param {string} [separator=','] - element separator - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} first argument must be a string - * @returns {string} joined string - */ - setReadOnly( TypedArray.prototype, 'join', function join( separator ) { - var out; - var buf; - var sep; - var i; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( arguments.length > 0 ) { - if ( !isString( separator ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) ); - } - sep = separator; - } else { - sep = ','; - } - out = []; - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - out.push( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) ); - } - return out.join( sep ); - }); - - /** - * Returns the index of the last occurrence of a given element. - * - * @private - * @name lastIndexOf - * @memberof TypedArray.prototype - * @type {Function} - * @param {*} searchElement - element to search for - * @param {integer} [fromIndex] - starting index (inclusive) - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} second argument must be an integer - * @returns {integer} index or -1 - */ - setReadOnly( TypedArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) { - var buf; - var i; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[ 0 ] ], CTOR_NAME ) ); - } - if ( arguments.length > 1 ) { - if ( !isInteger( fromIndex ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) ); - } - if ( fromIndex >= this._length ) { - fromIndex = this._length - 1; - } else if ( fromIndex < 0 ) { - fromIndex += this._length; - } - } else { - fromIndex = this._length - 1; - } - buf = this._buffer; - for ( i = fromIndex; i >= 0; i-- ) { - if ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) { - return i; - } - } - return -1; - }); - - /** - * Number of array elements. - * - * @private - * @name length - * @memberof TypedArray.prototype - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnlyAccessor( TypedArray.prototype, 'length', function get() { - return this._length; - }); - - /** - * Returns a new array with each element being the result of a provided callback function. - * - * @private - * @name map - * @memberof TypedArray.prototype - * @type {Function} - * @param {Function} fcn - function to invoke - * @param {*} [thisArg] - function invocation context - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} first argument must be a function - * @returns {TypedArray} new typed array - */ - setReadOnly( TypedArray.prototype, 'map', function map( fcn, thisArg ) { - var obuf; - var out; - var buf; - var i; - var v; - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - buf = this._buffer; - out = new this.constructor( flag2byteOrder( this._isLE ), this._length ); - obuf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < this._length; i++ ) { - v = fcn.call( thisArg, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this ); - obuf[ SETTER ]( i * BYTES_PER_ELEMENT, v, this._isLE ); - } - return out; - }); - - /** - * Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion. - * - * @private - * @name reduce - * @memberof TypedArray.prototype - * @type {Function} - * @param {Function} reducer - callback function - * @param {*} [initialValue] - initial value - * @throws {TypeError} `this` must be a typed array - * @throws {Error} if not provided an initial value, the array must have at least one element - * @returns {*} accumulated result - */ - setReadOnly( TypedArray.prototype, 'reduce', function reduce( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = 0; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = buf[ GETTER ]( 0 * BYTES_PER_ELEMENT, this._isLE ); - i = 1; - } - for ( ; i < len; i++ ) { - acc = reducer( acc, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this ); - } - return acc; - }); - - /** - * Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion. - * - * @private - * @name reduceRight - * @memberof TypedArray.prototype - * @type {Function} - * @param {Function} reducer - callback function - * @param {*} [initialValue] - initial value - * @throws {TypeError} `this` must be a typed array - * @throws {Error} if not provided an initial value, the array must have at least one element - * @returns {*} accumulated result - */ - setReadOnly( TypedArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) { - var buf; - var len; - var acc; - var i; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( !isFunction( reducer ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) ); - } - buf = this._buffer; - len = this._length; - if ( arguments.length > 1 ) { - acc = initialValue; - i = len - 1; - } else { - if ( len === 0 ) { - throw new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' ); - } - acc = buf[ GETTER ]( ( len - 1 ) * BYTES_PER_ELEMENT, this._isLE ); - i = len - 2; - } - for ( ; i >= 0; i-- ) { - acc = reducer( acc, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this ); - } - return acc; - }); - - /** - * Sets an array element. - * - * ## Notes - * - * - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. - * - * In the other overlapping scenario, - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended. - * - * @private - * @name set - * @memberof TypedArray.prototype - * @type {Function} - * @param {(Collection|TypedArray|*)} value - value(s) - * @param {NonNegativeInteger} [i=0] - element index at which to start writing values - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} index argument must be a nonnegative integer - * @throws {RangeError} index argument is out-of-bounds - * @throws {RangeError} target array lacks sufficient storage to accommodate source values - * @returns {void} - */ - setReadOnly( TypedArray.prototype, 'set', function set( value ) { - var sbuf; - var idx; - var buf; - var tmp; - var get; - var N; - var i; - var j; - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - buf = this._buffer; - if ( arguments.length > 1 ) { - idx = arguments[ 1 ]; - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); - } - } else { - idx = 0; - } - if ( isCollection( value ) ) { - N = value.length; - if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); - } - sbuf = value; - if ( sbuf.get && sbuf.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - // Check for overlapping memory... - j = buf.byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf.buffer && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // We need to copy source values... - tmp = []; - for ( i = 0; i < N; i++ ) { - tmp.push( get( value, i ) ); - } - sbuf = tmp; - get = getter( 'default' ); - } - for ( i = 0; i < N; idx++, i++ ) { - buf[ SETTER ]( idx*BYTES_PER_ELEMENT, get( sbuf, i ), this._isLE ); - } - return; - } - if ( idx >= this._length ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) ); - } - buf[ SETTER ]( idx*BYTES_PER_ELEMENT, value, this._isLE ); - }); - - /** - * Tests whether at least one element in the typed array passes a test implemented by a predicate function. - * - * @private - * @name some - * @memberof TypedArray.prototype - * @type {Function} - * @param {Function} predicate - predicate function - * @param {*} [thisArg] - predicate function execution context - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} first argument must be a function - * @returns {boolean} boolean indicating whether at least one element passes a test - */ - setReadOnly( TypedArray.prototype, 'some', function some( predicate, thisArg ) { - var buf; - var i; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - if ( predicate.call( thisArg, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this ) ) { - return true; - } - } - return false; - }); - - /** - * Serializes an array as a string. - * - * @private - * @name toString - * @memberof TypedArray.prototype - * @type {Function} - * @throws {TypeError} `this` must be a typed array instance - * @returns {string} string representation - */ - setReadOnly( TypedArray.prototype, 'toString', function toString() { - var out; - var buf; - var i; - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - out = []; - buf = this._buffer; - for ( i = 0; i < this._length; i++ ) { - out.push( buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE ) ); - } - return out.join( ',' ); - }); - - /** - * Returns a new typed array with the element at a provided index replaced with a provided value. - * - * @private - * @name with - * @memberof TypedArray.prototype - * @type {Function} - * @param {integer} index - element index - * @param {number} value - new value - * @throws {TypeError} `this` must be a typed array instance - * @throws {TypeError} first argument must be an integer - * @throws {RangeError} index argument is out-of-bounds - * @returns {TypedArray} new typed array - */ - setReadOnly( TypedArray.prototype, 'with', function copyWith( index, value ) { - var outbuf; - var buf; - var out; - var len; - - if ( !isTypedArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - if ( !isInteger( index ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) ); - } - len = this._length; - buf = this._buffer; - if ( index < 0 ) { - index += len; - } - if ( index < 0 || index >= len ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) ); - } - out = new this.constructor( flag2byteOrder( this._isLE ), buf.buffer ); - outbuf = out._buffer; // eslint-disable-line no-underscore-dangle - outbuf[ SETTER ]( index * BYTES_PER_ELEMENT, value, this._isLE ); - return out; - }); - - return TypedArray; - - /** - * Returns a boolean indicating if a value is a typed array constructor. - * - * @private - * @param {*} value - value to test - * @returns {boolean} boolean indicating if a value is a typed array constructor - */ - function isTypedArrayConstructor( value ) { - return ( value === TypedArray ); - } - - /** - * Returns a boolean indicating if a value is a typed array. - * - * @private - * @param {*} value - value to test - * @returns {boolean} boolean indicating if a value is a typed array - */ - function isTypedArray( value ) { - return ( - typeof value === 'object' && - value !== null && - ( - value.constructor.name === CTOR_NAME || - isPrototypeOf( value, TypedArray.prototype ) - ) && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); - } - - /** - * Fills an output DataView with array values. - * - * @private - * @param {DataView} view - output data view - * @param {Array} arr - input array - * @param {boolean} isLE - boolean indicating whether to store values in little-endian byte order - * @returns {DataView} output data view - */ - function fromArray( view, arr, isLE ) { - var len; - var get; - var i; - - len = arr.length; - if ( arr.get && arr.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - for ( i = 0; i < len; i++ ) { - view[ SETTER ]( i*BYTES_PER_ELEMENT, get( arr, i ), isLE ); - } - return view; - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/fixed-endian-factory/package.json b/fixed-endian-factory/package.json deleted file mode 100644 index 264505289..000000000 --- a/fixed-endian-factory/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/fixed-endian-factory", - "version": "0.0.0", - "description": "Return a typed array constructor for creating typed arrays having a specified byte order.", - "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", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "factory", - "endian", - "little-endian", - "big-endian", - "byte-order" - ] -} diff --git a/fixed-endian-factory/test/test.at.js b/fixed-endian-factory/test/test.at.js deleted file mode 100644 index a46c5f419..000000000 --- a/fixed-endian-factory/test/test.at.js +++ /dev/null @@ -1,153 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is an `at` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'at' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.at ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.at.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided an index argument which is not an integer', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.at( value ); - }; - } -}); - -tape( 'the method returns `undefined` if provided an index which exceeds array dimensions', function test( t ) { - var ctor; - var arr; - var v; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); - - for ( i = -arr.length; i < arr.length; i++ ) { - if ( i < 0 ) { - v = arr.at( i - arr.length ); - t.strictEqual( v, void 0, 'returns expected value for index '+(i-arr.length) ); - } else { - v = arr.at( arr.length+i ); - t.strictEqual( v, void 0, 'returns expected value for index '+(arr.length+i) ); - } - } - t.end(); -}); - -tape( 'the method returns an array element', function test( t ) { - var expected; - var ctor; - var arr; - var v; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - expected = [ 1.0, 2.0, 3.0, 4.0, 5.0, 1.0, 2.0, 3.0, 4.0, 5.0 ]; - - for ( i = -arr.length; i < arr.length; i++ ) { - v = arr.at( i ); - t.strictEqual( v, expected[ i + arr.length ], 'returns expected value' ); - } - t.end(); -}); diff --git a/fixed-endian-factory/test/test.every.js b/fixed-endian-factory/test/test.every.js deleted file mode 100644 index ec349da54..000000000 --- a/fixed-endian-factory/test/test.every.js +++ /dev/null @@ -1,191 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is an `every` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'every' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.every ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.every.call( value, predicate ); - }; - } - function predicate( v ) { - return v < 0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.every( value ); - }; - } -}); - -tape( 'the method returns `true` if operating on an empty array', function test( t ) { - var bool; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian' ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if all elements pass a test', function test( t ) { - var bool; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v > 0; - } -}); - -tape( 'the method returns `false` if one or more elements fail a test', function test( t ) { - var bool; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ -1.0, 2.0, -3.0, 4.0, -5.0 ] ); - bool = arr.every( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v > 0; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctor; - var arr; - var ctx; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - ctx = { - 'count': 0 - }; - bool = arr.every( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 5, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v > 0; - } -}); diff --git a/fixed-endian-factory/test/test.filter.js b/fixed-endian-factory/test/test.filter.js deleted file mode 100644 index 47cf85db1..000000000 --- a/fixed-endian-factory/test/test.filter.js +++ /dev/null @@ -1,225 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is a `filter` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'filter' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.filter ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.filter.call( value, predicate ); - }; - } - function predicate( v ) { - return v < 0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.filter( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty array', function test( t ) { - var ctor; - var arr; - var out; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian' ); - out = arr.filter( predicate ); - - t.strictEqual( out.length, 0, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v > 0.0; - } -}); - -tape( 'the method returns a new typed array containing only those elements which satisfy a test condition', function test( t ) { - var expected; - var actual; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ -1.0, -2.0, 3.0, 4.0 ] ); - expected = new ctor( 'little-endian', [ 3.0, 4.0 ] ); - actual = arr.filter( predicate ); - - t.strictEqual( actual instanceof ctor, true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v > 0; - } -}); - -tape( 'the method copies all elements to a new array if all elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - actual = arr.filter( predicate ); - - t.strictEqual( actual instanceof ctor, true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v === v; - } -}); - -tape( 'the method returns an empty array if no elements satisfy a test condition', function test( t ) { - var expected; - var actual; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = new ctor( 'little-endian' ); - actual = arr.filter( predicate ); - - t.strictEqual( actual instanceof ctor, true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v !== v; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctor; - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = new ctor( 'little-endian', [ 2.0, 4.0 ] ); - actual = arr.filter( predicate, ctx ); - - t.strictEqual( actual instanceof ctor, true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return ( v % 2 === 0 ); - } -}); diff --git a/fixed-endian-factory/test/test.for_each.js b/fixed-endian-factory/test/test.for_each.js deleted file mode 100644 index e21247a52..000000000 --- a/fixed-endian-factory/test/test.for_each.js +++ /dev/null @@ -1,207 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is a `forEach` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'forEach' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.forEach ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.forEach.call( value, fcn ); - }; - } - - function fcn( v ) { - if ( isnan( v ) ) { - t.fail( 'should not be NaN' ); - } - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', 10 ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.forEach( value ); - }; - } -}); - -tape( 'the method should not invoke a provided callback function if operating on an empty array', function test( t ) { - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', 0 ); - arr.forEach( fcn ); - - t.end(); - - function fcn() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `undefined`', function test( t ) { - var ctor; - var arr; - var out; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - out = arr.forEach( fcn ); - - t.strictEqual( out, void 0, 'returns expected value' ); - t.end(); - - function fcn( v ) { - if ( isnan( v ) ) { - t.fail( 'should not be NaN' ); - } - } -}); - -tape( 'the method invokes a provided function for each element in an array', function test( t ) { - var indices; - var values; - var arrays; - var ctor; - var arr; - - indices = []; - values = []; - arrays = []; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - arr.forEach( fcn ); - - t.deepEqual( values, [ 1.0, 2.0, 3.0, 4.0 ], 'returns expected value' ); - t.deepEqual( indices, [ 0, 1, 2, 3 ], 'returns expected value' ); - t.strictEqual( arrays[ 0 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 1 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 2 ], arr, 'returns expected value' ); - t.strictEqual( arrays[ 3 ], arr, 'returns expected value' ); - - t.end(); - - function fcn( v, i, arr ) { - values.push( v ); - indices.push( i ); - arrays.push( arr ); - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var ctor; - var ctx; - var arr; - - ctor = factory( 'float64' ); - - ctx = { - 'count': 0 - }; - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - arr.forEach( fcn, ctx ); - - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function fcn() { - this.count += 1; // eslint-disable-line no-invalid-this - } -}); diff --git a/fixed-endian-factory/test/test.includes.js b/fixed-endian-factory/test/test.includes.js deleted file mode 100644 index ff0cf5d98..000000000 --- a/fixed-endian-factory/test/test.includes.js +++ /dev/null @@ -1,226 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is an `includes` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'includes' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.includes ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.includes( 1.0, value ); - }; - } -}); - -tape( 'the method returns `false` if provided a second argument which exceeds array dimensions', function test( t ) { - var ctor; - var arr; - var v; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); - - for ( i = arr.length; i < arr.length+5; i++ ) { - v = arr.includes( 1.0, i ); - t.strictEqual( v, false, 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method returns `false` if operating on an empty array', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [] ); - - v = arr.includes( 1.0 ); - t.strictEqual( v, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns `false` if a search element is not found', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - v = arr.includes( 10.0 ); - t.strictEqual( v, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns `true` if an element is found', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - v = arr.includes( 2.0 ); - t.strictEqual( v, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - v = arr.includes( 2.0, 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.includes( 2.0, 2 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.includes( 1.0, 4 ); - t.strictEqual( v, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - v = arr.includes( 2.0, -3 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.includes( 1.0, -3 ); - t.strictEqual( v, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index less than zero, the method searches from the first array element', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - v = arr.includes( 2.0, -10 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = arr.includes( 1.0, -10 ); - t.strictEqual( v, true, 'returns expected value' ); - - t.end(); -}); diff --git a/fixed-endian-factory/test/test.index_of.js b/fixed-endian-factory/test/test.index_of.js deleted file mode 100644 index ea6b8c2c2..000000000 --- a/fixed-endian-factory/test/test.index_of.js +++ /dev/null @@ -1,226 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is an `indexOf` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'indexOf' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.indexOf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.indexOf( 1.0, value ); - }; - } -}); - -tape( 'the method returns `-1` if provided a second argument which exceeds array dimensions', function test( t ) { - var ctor; - var arr; - var v; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); - - for ( i = arr.length; i < arr.length+5; i++ ) { - v = arr.indexOf( 1.0, i ); - t.strictEqual( v, -1, 'returns expected value' ); - } - t.end(); -}); - -tape( 'the method returns `-1` if operating on an empty array', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [] ); - - v = arr.indexOf( 1.0 ); - t.strictEqual( v, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns `-1` if a search element is not found', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - v = arr.indexOf( 10.0 ); - t.strictEqual( v, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns the index of the first match if an element is found', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - v = arr.indexOf( 2.0 ); - t.strictEqual( v, 1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - v = arr.indexOf( 2.0, 0 ); - t.strictEqual( v, 1, 'returns expected value' ); - - v = arr.indexOf( 2.0, 2 ); - t.strictEqual( v, 4, 'returns expected value' ); - - v = arr.indexOf( 1.0, 4 ); - t.strictEqual( v, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - v = arr.indexOf( 2.0, -3 ); - t.strictEqual( v, 4, 'returns expected value' ); - - v = arr.indexOf( 1.0, -3 ); - t.strictEqual( v, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'when provided a starting index which resolves to an index less than zero, the method searches from the first array element', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - v = arr.indexOf( 2.0, -10 ); - t.strictEqual( v, 1, 'returns expected value' ); - - v = arr.indexOf( 1.0, -10 ); - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); diff --git a/fixed-endian-factory/test/test.join.js b/fixed-endian-factory/test/test.join.js deleted file mode 100644 index e59fed52d..000000000 --- a/fixed-endian-factory/test/test.join.js +++ /dev/null @@ -1,175 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is a `join` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'join' ), true, 'has property' ); - t.strictEqual( isFunction( ctor.prototype.join ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided ' + values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.join.call( value ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `separator` argument which is not a string', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', 5 ); - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.join( value ); - }; - } -}); - -tape( 'the method returns an empty string if invoked on an empty array', function test( t ) { - var ctor; - var str; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [] ); - - str = arr.join(); - t.strictEqual( str, '', 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a typed array with elements separated by a separator', function test( t ) { - var expected; - var ctor; - var str; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1@2@3@4'; - - str = arr.join( '@' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a string representation of a typed array with elements separated by a separator (single element)', function test( t ) { - var expected; - var ctor; - var str; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0 ] ); - expected = '1'; - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - - arr = new ctor( 'little-endian', [ 2.0 ] ); - expected = '2'; - - str = arr.join( ';' ); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'if the method is invoked without a separator argument, the method returns a string representation of a typed array with elements separated by a comma', function test( t ) { - var expected; - var ctor; - var str; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = '1,2,3,4'; - - str = arr.join(); - - t.strictEqual( str, expected, 'returns expected value' ); - t.end(); -}); diff --git a/fixed-endian-factory/test/test.js b/fixed-endian-factory/test/test.js deleted file mode 100644 index 99d011d0b..000000000 --- a/fixed-endian-factory/test/test.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests diff --git a/fixed-endian-factory/test/test.last_index_of.js b/fixed-endian-factory/test/test.last_index_of.js deleted file mode 100644 index 54be9b624..000000000 --- a/fixed-endian-factory/test/test.last_index_of.js +++ /dev/null @@ -1,222 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is a `lastIndexOf` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'lastIndexOf' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.lastIndexOf ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', 5 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf.call( value, 0 ); - }; - } -}); - -tape( 'the method throws an error if provided a second argument which is not an integer', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.lastIndexOf( 1.0, value ); - }; - } -}); - -tape( 'the method returns `-1` if provided a second argument which resolves to an index less than zero', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - v = arr.lastIndexOf( 1.0, -10 ); - t.strictEqual( v, -1, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns `-1` if operating on an empty array', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [] ); - - v = arr.lastIndexOf( 1.0 ); - t.strictEqual( v, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns `-1` if a search element is not found', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - v = arr.lastIndexOf( 10.0 ); - t.strictEqual( v, -1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method returns the index of the last match if an element is found', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - v = arr.lastIndexOf( 2.0 ); - t.strictEqual( v, 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports specifying a starting search index', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - v = arr.lastIndexOf( 2.0, 4 ); - t.strictEqual( v, 4, 'returns expected value' ); - - v = arr.lastIndexOf( 2.0, 1 ); - t.strictEqual( v, 1, 'returns expected value' ); - - v = arr.lastIndexOf( 1.0, 0 ); - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method supports specifying a starting search index (negative)', function test( t ) { - var ctor; - var arr; - var v; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - v = arr.lastIndexOf( 2.0, -1 ); - t.strictEqual( v, 4, 'returns expected value' ); - - v = arr.lastIndexOf( 1.0, -3 ); - t.strictEqual( v, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the method is provided a starting index which resolves to an index which exceeds the maximum array index, the method searches from the last array element', function test( t ) { - var ctor; - var arr; - var idx; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 2.0 ] ); - - idx = arr.lastIndexOf( 2.0, 10 ); - t.strictEqual( idx, 4, 'returns expected value' ); - - idx = arr.lastIndexOf( 5.0, 10 ); - t.strictEqual( idx, -1, 'returns expected value' ); - t.end(); -}); diff --git a/fixed-endian-factory/test/test.map.js b/fixed-endian-factory/test/test.map.js deleted file mode 100644 index 0f45006f0..000000000 --- a/fixed-endian-factory/test/test.map.js +++ /dev/null @@ -1,177 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var identity = require( '@stdlib/utils/identity-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is a `map` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'map' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.map ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map.call( value, identity ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.map( value ); - }; - } -}); - -tape( 'the method returns an empty array if operating on an empty array', function test( t ) { - var ctor; - var arr; - var out; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian' ); - out = arr.map( identity ); - - t.strictEqual( out instanceof ctor, true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - t.notEqual( out, arr, 'returns a new instance' ); - t.end(); -}); - -tape( 'the method returns a new typed array containing elements which are the result of a provided callback function', function test( t ) { - var expected; - var actual; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = new ctor( 'little-endian', [ 2.0, 4.0, 6.0, 8.0 ] ); - actual = arr.map( scale ); - - t.strictEqual( actual instanceof ctor, true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.notEqual( actual, arr, 'returns a new instance' ); - t.end(); - - function scale( v ) { - return v * 2.0; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var expected; - var actual; - var ctor; - var arr; - var ctx; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - expected = new ctor( 'little-endian', [ -1.0, -2.0, -3.0, -4.0 ] ); - - ctx = { - 'count': 0 - }; - actual = arr.map( fcn, ctx ); - - t.strictEqual( actual instanceof ctor, true, 'returns expected value' ); - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - t.strictEqual( ctx.count, 6, 'returns expected value' ); - t.end(); - - function fcn( v, i ) { - this.count += i; // eslint-disable-line no-invalid-this - return -v; - } -}); diff --git a/fixed-endian-factory/test/test.reduce.js b/fixed-endian-factory/test/test.reduce.js deleted file mode 100644 index 7611a1748..000000000 --- a/fixed-endian-factory/test/test.reduce.js +++ /dev/null @@ -1,216 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is a `reduce` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'reduce' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.reduce ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduce.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduce( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty array', function test( t ) { - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduce( reducer ); - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var ctor; - var arr; - var ind; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 0.0, 1.0, 0.0 ] ); - accArray = [ 1.0, 0.0, 0.0 ]; - valueArray = [ 0.0, 1.0, 0.0 ]; - expected = 0.0; - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = index-1; - t.strictEqual( acc, accArray[ ind ], 'returns expected value' ); - t.strictEqual( value, valueArray[ ind ], 'returns expected value' ); - return ( acc && value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 0.0, 0.0, 1.0 ] ); - accArray = [ 0.0, 1.0, 1.0, 1.0 ]; - valueArray = [ 1.0, 0.0, 0.0, 1.0 ]; - expected = 2; - actual = arr.reduce( reducer, 0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - t.strictEqual( acc, accArray[ index ], 'returns expected value' ); - t.strictEqual( value, valueArray[ index ], 'returns expected value' ); - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 0.0, 1.0, 1.0 ] ); - expected = 0.0; - actual = arr.reduce( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return ( acc && value ); - } -}); diff --git a/fixed-endian-factory/test/test.reduce_right.js b/fixed-endian-factory/test/test.reduce_right.js deleted file mode 100644 index 79221a54a..000000000 --- a/fixed-endian-factory/test/test.reduce_right.js +++ /dev/null @@ -1,222 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is a `reduceRight` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'reduceRight' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.reduceRight ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduceRight.call( value, reducer ); - }; - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.reduceRight( value ); - }; - } -}); - -tape( 'the method throws an error if not provided an initial value when operating on an empty array', function test( t ) { - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian' ); - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - arr.reduceRight( reducer ); - } - - function reducer( acc, value ) { - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method uses the first element of the array as the initial value when an initial value is not provided', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var ctor; - var arr; - var ind; - var len; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 0.0, 1.0, 0.0 ] ); - len = arr.length; - accArray = [ 0.0, 0.0, 0.0 ]; - valueArray = [ 1.0, 0.0, 1.0 ]; - expected = 0.0; - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - - t.end(); - - function reducer( acc, value, index ) { - ind = ( len - index - 2 ); - t.strictEqual( acc, accArray[ ind ], 'returns expected value' ); - t.strictEqual( value, valueArray[ ind ], 'returns expected value' ); - return ( acc && value ); - } -}); - -tape( 'the method supports providing an initial value as the second argument', function test( t ) { - var valueArray; - var accArray; - var expected; - var actual; - var ctor; - var arr; - var ind; - var len; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 0.0, 0.0, 1.0 ] ); - len = arr.length; - accArray = [ 0.0, 1.0, 1.0, 1.0 ]; - valueArray = [ 1.0, 0.0, 0.0, 1.0 ]; - expected = 2; - actual = arr.reduceRight( reducer, 0 ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value, index ) { - ind = ( len - index - 1 ); - t.strictEqual( acc, accArray[ ind ], 'returns expected value' ); - t.strictEqual( value, valueArray[ ind ], 'returns expected value' ); - if ( value ) { - return acc + 1; - } - return acc; - } -}); - -tape( 'the method returns the accumulated result', function test( t ) { - var expected; - var actual; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 0.0, 1.0, 1.0 ] ); - expected = 0.0; - actual = arr.reduceRight( reducer ); - - t.strictEqual( actual, expected, 'returns expected value' ); - t.end(); - - function reducer( acc, value ) { - return ( acc && value ); - } -}); diff --git a/fixed-endian-factory/test/test.some.js b/fixed-endian-factory/test/test.some.js deleted file mode 100644 index 8e0b118b0..000000000 --- a/fixed-endian-factory/test/test.some.js +++ /dev/null @@ -1,214 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is a `some` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'some' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.some ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.some.call( value, predicate ); - }; - } - function predicate( v ) { - return v < 0; - } -}); - -tape( 'the method throws an error if provided a first argument which is not a function', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0 ] ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.some( value ); - }; - } -}); - -tape( 'the method returns `false` if operating on an empty array', function test( t ) { - var bool; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian' ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate() { - t.fail( 'should not be invoked' ); - } -}); - -tape( 'the method returns `true` if at least one element passes a test', function test( t ) { - var bool; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ -1.0, -2.0, 3.0, -4.0, 5.0 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v > 0; - } -}); - -tape( 'the method returns `false` if all elements fail a test', function test( t ) { - var bool; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ -1.0, -2.0, -3.0, -4.0, -5.0 ] ); - bool = arr.some( predicate ); - - t.strictEqual( bool, false, 'returns expected value' ); - t.end(); - - function predicate( v ) { - return v > 0; - } -}); - -tape( 'the method supports providing an execution context', function test( t ) { - var bool; - var ctor; - var arr; - var ctx; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - ctx = { - 'threshold': 3 - }; - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - return v > this.threshold; // eslint-disable-line no-invalid-this - } -}); - -tape( 'the method stops executing upon encountering the first element which passes a test', function test( t ) { - var bool; - var ctor; - var arr; - var ctx; - - ctx = { - 'count': 0 - }; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ -1.0, -2.0, -3.0, 4.0, -5.0 ] ); - bool = arr.some( predicate, ctx ); - - t.strictEqual( bool, true, 'returns expected value' ); - t.strictEqual( ctx.count, 4, 'returns expected value' ); - - t.end(); - - function predicate( v ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v > 0; - } -}); diff --git a/fixed-endian-factory/test/test.with.js b/fixed-endian-factory/test/test.with.js deleted file mode 100644 index bf02d17e9..000000000 --- a/fixed-endian-factory/test/test.with.js +++ /dev/null @@ -1,189 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasSameValues = require( './../../base/assert/has-same-values' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( isFunction( ctor ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the prototype of the returned function is a `with` method', function test( t ) { - var ctor = factory( 'float64' ); - t.strictEqual( hasOwnProp( ctor.prototype, 'with' ), true, 'returns expected value' ); - t.strictEqual( isFunction( ctor.prototype.with ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with.call( value, 0, 0.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not an integer', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 0.0 ); - }; - } -}); - -tape( 'the method throws an error if provided a first argument which is not in bounds', function test( t ) { - var values; - var ctor; - var arr; - var i; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - values = [ - -6, - -9, - 10, - 20 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.with( value, 0.0 ); - }; - } -}); - -tape( 'the method does not change the array length', function test( t ) { - var ctor; - var arr; - var out; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - out = arr.with( 0, 4.0 ); - - t.strictEqual( out.length, 5, 'returns expected value' ); - t.end(); -}); - -tape( 'the method returns a new boolean array with the element at a provided index replaced with a provided value', function test( t ) { - var expected; - var actual; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - expected = new ctor( 'little-endian', [ 0.0, 2.0, 3.0, 4.0, 5.0 ] ); - actual = arr.with( 0, 0.0 ); - t.strictEqual( actual instanceof ctor, true, 'returns expected value' ); - t.strictEqual( hasSameValues( actual, expected ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns new instance' ); - t.end(); -}); - -tape( 'the method supports negative indices', function test( t ) { - var expected; - var actual; - var ctor; - var arr; - - ctor = factory( 'float64' ); - arr = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - expected = new ctor( 'little-endian', [ 1.0, 2.0, 3.0, 4.0, 0.0 ] ); - actual = arr.with( -1, 0.0 ); - t.strictEqual( actual instanceof ctor, true, 'returns expected value' ); - t.strictEqual( hasSameValues( actual, expected ), true, 'returns expected value' ); - t.notEqual( actual, arr, 'returns new instance' ); - t.end(); -}); diff --git a/fixed-endian-float32/README.md b/fixed-endian-float32/README.md deleted file mode 100644 index 0b3dcfe36..000000000 --- a/fixed-endian-float32/README.md +++ /dev/null @@ -1,456 +0,0 @@ - - -# Float32ArrayFE - -> Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in a specified byte order. - - - -
- -In contrast to the [`Float32Array`][@stdlib/array/float32] typed array constructor which stores values according to the host platform byte order, the `Float32ArrayFE` constructor allows enforcing a specific byte order. Such enforcement can be particularly advantageous when working with memory buffers which do not necessarily follow host platform byte order, such as [WebAssembly memory][@stdlib/wasm/memory]. - -
- - - - - -
- -## Usage - -```javascript -var Float32ArrayFE = require( '@stdlib/array/fixed-endian-float32' ); -``` - -#### Float32ArrayFE( endianness ) - -A typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in a specified byte order. - -```javascript -var arr = new Float32ArrayFE( 'little-endian' ); -// returns -``` - -#### Float32ArrayFE( endianness, length ) - -Returns a typed array having a specified length and byte order. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', 5 ); -// returns -``` - -#### Float32ArrayFE( endianness, typedarray ) - -Creates a typed array from another typed array. - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 0.5, 0.5, 0.5 ] ); -var arr2 = new Float32ArrayFE( 'little-endian', arr1 ); -// returns - -var v = arr2.get( 0 ); -// returns 0.5 -``` - -#### Float32ArrayFE( endianness, obj ) - -Creates a typed array from an array-like object or iterable. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', [ 0.5, 0.5, 0.5 ] ); -// returns - -var v = arr.get( 0 ); -// returns 0.5 -``` - -#### Float32ArrayFE( endianness, buffer\[, byteOffset\[, length]] ) - -Returns a typed array view of an [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 32 ); -var arr = new Float32ArrayFE( 'little-endian', buf, 0, 4 ); -// returns -``` - -* * * - -### Properties - - - -#### Float32ArrayFE.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var nbytes = Float32ArrayFE.BYTES_PER_ELEMENT; -// returns 4 -``` - - - -#### Float32ArrayFE.name - -Typed array constructor name. - -```javascript -var str = Float32ArrayFE.name; -// returns 'Float32ArrayFE' -``` - - - -#### Float32ArrayFE.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the typed array. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Float32ArrayFE.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the typed array. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', 5 ); -var byteLength = arr.byteLength; -// returns 20 -``` - - - -#### Float32ArrayFE.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the typed array from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Float32ArrayFE.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 4 -``` - - - -#### Float32ArrayFE.prototype.length - -**Read-only** property which returns the number of view elements. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Float32ArrayFE.from( endianness, src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like object or an iterable. - -```javascript -var arr = Float32ArrayFE.from( 'little-endian', [ 1.0, -1.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2.0; -} - -var arr = Float32ArrayFE.from( 'little-endian', [ 1.0, -1.0 ], mapFcn ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 -``` - -A callback function is provided two arguments: - -- **value**: source value. -- **index**: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2.0; -} - -var ctx = { - 'count': 0 -}; - -var arr = Float32ArrayFE.from( 'little-endian', [ 1.0, -1.0 ], mapFcn, ctx ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 - -var n = ctx.count; -// returns 2 -``` - - - -#### Float32ArrayFE.of( endianness, element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Float32ArrayFE.of( 'little-endian', 1.0, -1.0 ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - - - -#### Float32ArrayFE.prototype.get( i ) - -Returns an array element located at a nonnegative integer position (index) `i`. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', 10 ); - -// Set the first element: -arr.set( 1.0, 0 ); - -// Get the first element: -var v = arr.get( 0 ); -// returns 1.0 -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', 10 ); - -var v = arr.get( 100 ); -// returns undefined -``` - - - -#### Float32ArrayFE.prototype.set( arr\[, offset] ) - -Sets array elements. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 - -v = arr.get( 1 ); -// returns 2.0 - -// Set the first two array elements: -arr.set( [ 4.0, 5.0 ] ); - -v = arr.get( 0 ); -// returns 4.0 - -v = arr.get( 1 ); -// returns 5.0 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -// returns - -// Set the last two array elements: -arr.set( [ 4.0, 5.0 ], 1 ); - -var v = arr.get( 1 ); -// returns 4.0 - -v = arr.get( 2 ); -// returns 5.0 -``` - -A few notes: - -- If `i` is out-of-bounds, the method throws an error. -- If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error. -- If provided a typed array which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range. - - - -#### Float32ArrayFE.prototype.toString() - -Serializes an array as a string. - -```javascript -var arr = new Float32ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - -
- - - - - -
- -* * * - -## Notes - -- The constructor supports the following byte orders: - - - **little-endian**: store values such that bytes are stored from least-to-most significant bytes. This is the dominant ordering for processor architectures and their associated memory. This is also the ordering for [WebAssembly memory][@stdlib/wasm/memory]. - - **big-endian**: store values such that bytes are stored from most-to-least significant bytes. This is the dominant ordering in network protocols. - -- While a `Float32ArrayFE` _strives_ to maintain (but does not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: - - - The constructor does **not** require the `new` operator. - - Accessing array elements using bracket syntax (e.g., `X[i]`) is **not** supported. Instead, one **must** use the `.get()` method. - -
- - - - - -
- -* * * - -## Examples - - - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); -var logEach = require( '@stdlib/console/log-each' ); -var Float32ArrayFE = require( '@stdlib/array/fixed-endian-float32' ); - -// Create a typed array by specifying a length: -var out = new Float32ArrayFE( 'little-endian', 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float32ArrayFE( 'big-endian', arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float32ArrayFE( 'little-endian', arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float32ArrayFE( 'big-endian', arr.buffer, 8, 2 ); -logEach( '%s', out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/fixed-endian-float32/benchmark/benchmark.from.js b/fixed-endian-float32/benchmark/benchmark.from.js deleted file mode 100644 index d8d94ca08..000000000 --- a/fixed-endian-float32/benchmark/benchmark.from.js +++ /dev/null @@ -1,310 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float32Array = require( './../../float32' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayFE = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayFE.from( 'little-endian', buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayFE.from( 'little-endian', buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayFE.from( 'little-endian', createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayFE.from( 'little-endian', createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayFE.from( 'little-endian', createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return v * 2.0; - } -}); diff --git a/fixed-endian-float32/benchmark/benchmark.get.js b/fixed-endian-float32/benchmark/benchmark.get.js deleted file mode 100644 index 525940eb0..000000000 --- a/fixed-endian-float32/benchmark/benchmark.get.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float32ArrayFE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':get:endianness=little-endian', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float32ArrayFE( 'little-endian', arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get:endianness=big-endian', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float32ArrayFE( 'big-endian', arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-float32/benchmark/benchmark.js b/fixed-endian-float32/benchmark/benchmark.js deleted file mode 100644 index 907cb4a46..000000000 --- a/fixed-endian-float32/benchmark/benchmark.js +++ /dev/null @@ -1,533 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var ArrayBuffer = require( './../../buffer' ); -var Float32Array = require( './../../float32' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayFE = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// FUNCTIONS // - -/** -* Returns an "iterable" object. -* -* @private -* @returns {Object} iterable object -*/ -function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } -} - - -// MAIN // - -bench( pkg+'::instantiation,new:endianness=little-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'little-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new:endianness=big-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'big-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new:endianness=little-endian', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float32ArrayFE; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor( 'little-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new:endianness=big-endian', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float32ArrayFE; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor( 'big-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length:endianness=little-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'little-endian', 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length:endianness=big-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'big-endian', 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'big-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'big-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable:endianness=little-endian', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'little-endian', createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable:endianness=big-endian', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'big-endian', createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'big-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'little-endian', buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'big-endian', buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'little-endian', buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayFE( 'big-endian', buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-float32/benchmark/benchmark.of.js b/fixed-endian-float32/benchmark/benchmark.of.js deleted file mode 100644 index 6b9670ab8..000000000 --- a/fixed-endian-float32/benchmark/benchmark.of.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayFE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayFE.of( 'little-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 'little-endian', 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayFE.of.apply( Float32ArrayFE, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-float32/benchmark/benchmark.set.js b/fixed-endian-float32/benchmark/benchmark.set.js deleted file mode 100644 index aa7d7d9e1..000000000 --- a/fixed-endian-float32/benchmark/benchmark.set.js +++ /dev/null @@ -1,209 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float32Array = require( './../../float32' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayFE = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::number:set:endianness=little-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float32ArrayFE( 'little-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::number:set:endianness=big-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float32ArrayFE( 'big-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:set:endianness=little-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float32ArrayFE( 'little-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:set:endianness=big-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float32ArrayFE( 'big-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set:endianness=little-endian', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float32Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float32ArrayFE( 'little-endian', values ); - buf = new Float32Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set:endianness=big-endian', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float32Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float32ArrayFE( 'big-endian', values ); - buf = new Float32Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-float32/benchmark/benchmark.set.length.js b/fixed-endian-float32/benchmark/benchmark.set.length.js deleted file mode 100644 index 0281c407e..000000000 --- a/fixed-endian-float32/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randu = require( '@stdlib/random/array/randu' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayFE = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - - arr1 = randu( len ); - arr2 = randu( len ); - arr3 = randu( len ); - arr1 = new Float32ArrayFE( 'little-endian', arr1 ); - - values = [ - new Float32ArrayFE( 'little-endian', arr2 ), - new Float32ArrayFE( 'big-endian', arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-float32/benchmark/benchmark.to_string.js b/fixed-endian-float32/benchmark/benchmark.to_string.js deleted file mode 100644 index 3e1e5a1dc..000000000 --- a/fixed-endian-float32/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayFE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32ArrayFE( 'little-endian', [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-float32/benchmark/benchmark.to_string.length.js b/fixed-endian-float32/benchmark/benchmark.to_string.length.js deleted file mode 100644 index e96ff135b..000000000 --- a/fixed-endian-float32/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayFE = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-float32/examples/index.js b/fixed-endian-float32/examples/index.js deleted file mode 100644 index 12e93469e..000000000 --- a/fixed-endian-float32/examples/index.js +++ /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. -*/ - -'use strict'; - -var Float32Array = require( './../../float32' ); -var logEach = require( '@stdlib/console/log-each' ); -var Float32ArrayFE = require( './../lib' ); - -// Create a typed array by specifying a length: -var out = new Float32ArrayFE( 'little-endian', 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float32ArrayFE( 'big-endian', arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float32ArrayFE( 'little-endian', arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float32ArrayFE( 'big-endian', arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/fixed-endian-float32/lib/index.js b/fixed-endian-float32/lib/index.js deleted file mode 100644 index 7ca737c2e..000000000 --- a/fixed-endian-float32/lib/index.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in a specified byte order. -* -* @module @stdlib/array/fixed-endian-float32 -* -* @example -* var Float32ArrayFE = require( '@stdlib/array/fixed-endian-float32' ); -* -* var arr = new Float32ArrayFE( 'little-endian' ); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float32ArrayFE = require( '@stdlib/array/fixed-endian-float32' ); -* -* var arr = new Float32ArrayFE( 'little-endian', 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float32ArrayFE = require( '@stdlib/array/fixed-endian-float32' ); -* -* var arr = new Float32ArrayFE( 'little-endian', [ 1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float32ArrayFE = require( '@stdlib/array/fixed-endian-float32' ); -* -* var buf = new ArrayBuffer( 8 ); -* var arr = new Float32ArrayFE( 'little-endian', buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float32ArrayFE = require( '@stdlib/array/fixed-endian-float32' ); -* -* var buf = new ArrayBuffer( 8 ); -* var arr = new Float32ArrayFE( 'little-endian', buf, 4 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float32ArrayFE = require( '@stdlib/array/fixed-endian-float32' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float32ArrayFE( 'little-endian', buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/fixed-endian-float32/lib/main.js b/fixed-endian-float32/lib/main.js deleted file mode 100644 index 86f9d4348..000000000 --- a/fixed-endian-float32/lib/main.js +++ /dev/null @@ -1,100 +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. -*/ - -'use strict'; - -// MODULES // - -var factory = require( './../../fixed-endian-factory' ); - - -// MAIN // - -/** -* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in a specified byte order. -* -* @name Float32ArrayFE -* @constructor -* @type {Function} -* @param {string} endianness - byte order -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {TypeError} first argument must be a supported byte order -* @throws {TypeError} if provided only two arguments, the second argument must be a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @returns {Float32ArrayFE} typed array instance -* -* @example -* var arr = new Float32ArrayFE( 'little-endian' ); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float32ArrayFE( 'little-endian', 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Float32ArrayFE( 'little-endian', [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 8 ); -* var arr = new Float32ArrayFE( 'little-endian', buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 8 ); -* var arr = new Float32ArrayFE( 'little-endian', buf, 4 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float32ArrayFE( 'little-endian', buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -var Float32ArrayFE = factory( 'float32' ); - - -// EXPORTS // - -module.exports = Float32ArrayFE; diff --git a/fixed-endian-float32/package.json b/fixed-endian-float32/package.json deleted file mode 100644 index 1e288f40b..000000000 --- a/fixed-endian-float32/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/fixed-endian-float32", - "version": "0.0.0", - "description": "Float32Array having a specified byte order.", - "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", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "float32array", - "float32", - "float", - "single-precision", - "ieee754", - "endian", - "little-endian", - "big-endian", - "byte-order" - ] -} diff --git a/fixed-endian-float32/test/test.js b/fixed-endian-float32/test/test.js deleted file mode 100644 index fc72bbf88..000000000 --- a/fixed-endian-float32/test/test.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests diff --git a/fixed-endian-float64/README.md b/fixed-endian-float64/README.md deleted file mode 100644 index 6c0fdc098..000000000 --- a/fixed-endian-float64/README.md +++ /dev/null @@ -1,456 +0,0 @@ - - -# Float64ArrayFE - -> Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in a specified byte order. - - - -
- -In contrast to the [`Float64Array`][@stdlib/array/float64] typed array constructor which stores values according to the host platform byte order, the `Float64ArrayFE` constructor allows enforcing a specific byte order. Such enforcement can be particularly advantageous when working with memory buffers which do not necessarily follow host platform byte order, such as [WebAssembly memory][@stdlib/wasm/memory]. - -
- - - - - -
- -## Usage - -```javascript -var Float64ArrayFE = require( '@stdlib/array/fixed-endian-float64' ); -``` - -#### Float64ArrayFE( endianness ) - -A typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in a specified byte order. - -```javascript -var arr = new Float64ArrayFE( 'little-endian' ); -// returns -``` - -#### Float64ArrayFE( endianness, length ) - -Returns a typed array having a specified length and byte order. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', 5 ); -// returns -``` - -#### Float64ArrayFE( endianness, typedarray ) - -Creates a typed array from another typed array. - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 0.5, 0.5, 0.5 ] ); -var arr2 = new Float64ArrayFE( 'little-endian', arr1 ); -// returns - -var v = arr2.get( 0 ); -// returns 0.5 -``` - -#### Float64ArrayFE( endianness, obj ) - -Creates a typed array from an array-like object or iterable. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', [ 0.5, 0.5, 0.5 ] ); -// returns - -var v = arr.get( 0 ); -// returns 0.5 -``` - -#### Float64ArrayFE( endianness, buffer\[, byteOffset\[, length]] ) - -Returns a typed array view of an [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 32 ); -var arr = new Float64ArrayFE( 'little-endian', buf, 0, 4 ); -// returns -``` - -* * * - -### Properties - - - -#### Float64ArrayFE.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var nbytes = Float64ArrayFE.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### Float64ArrayFE.name - -Typed array constructor name. - -```javascript -var str = Float64ArrayFE.name; -// returns 'Float64ArrayFE' -``` - - - -#### Float64ArrayFE.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the typed array. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Float64ArrayFE.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the typed array. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', 5 ); -var byteLength = arr.byteLength; -// returns 40 -``` - - - -#### Float64ArrayFE.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the typed array from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Float64ArrayFE.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### Float64ArrayFE.prototype.length - -**Read-only** property which returns the number of view elements. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Float64ArrayFE.from( endianness, src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like object or an iterable. - -```javascript -var arr = Float64ArrayFE.from( 'little-endian', [ 1.0, -1.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2.0; -} - -var arr = Float64ArrayFE.from( 'little-endian', [ 1.0, -1.0 ], mapFcn ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 -``` - -A callback function is provided two arguments: - -- **value**: source value. -- **index**: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2.0; -} - -var ctx = { - 'count': 0 -}; - -var arr = Float64ArrayFE.from( 'little-endian', [ 1.0, -1.0 ], mapFcn, ctx ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 - -var n = ctx.count; -// returns 2 -``` - - - -#### Float64ArrayFE.of( endianness, element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Float64ArrayFE.of( 'little-endian', 1.0, -1.0 ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - - - -#### Float64ArrayFE.prototype.get( i ) - -Returns an array element located at a nonnegative integer position (index) `i`. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', 10 ); - -// Set the first element: -arr.set( 1.0, 0 ); - -// Get the first element: -var v = arr.get( 0 ); -// returns 1.0 -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', 10 ); - -var v = arr.get( 100 ); -// returns undefined -``` - - - -#### Float64ArrayFE.prototype.set( arr\[, offset] ) - -Sets array elements. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 - -v = arr.get( 1 ); -// returns 2.0 - -// Set the first two array elements: -arr.set( [ 4.0, 5.0 ] ); - -v = arr.get( 0 ); -// returns 4.0 - -v = arr.get( 1 ); -// returns 5.0 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); -// returns - -// Set the last two array elements: -arr.set( [ 4.0, 5.0 ], 1 ); - -var v = arr.get( 1 ); -// returns 4.0 - -v = arr.get( 2 ); -// returns 5.0 -``` - -A few notes: - -- If `i` is out-of-bounds, the method throws an error. -- If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error. -- If provided a typed array which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range. - - - -#### Float64ArrayFE.prototype.toString() - -Serializes an array as a string. - -```javascript -var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 3.0 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - -
- - - - - -
- -* * * - -## Notes - -- The constructor supports the following byte orders: - - - **little-endian**: store values such that bytes are stored from least-to-most significant bytes. This is the dominant ordering for processor architectures and their associated memory. This is also the ordering for [WebAssembly memory][@stdlib/wasm/memory]. - - **big-endian**: store values such that bytes are stored from most-to-least significant bytes. This is the dominant ordering in network protocols. - -- While a `Float64ArrayFE` _strives_ to maintain (but does not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: - - - The constructor does **not** require the `new` operator. - - Accessing array elements using bracket syntax (e.g., `X[i]`) is **not** supported. Instead, one **must** use the `.get()` method. - -
- - - - - -
- -* * * - -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var logEach = require( '@stdlib/console/log-each' ); -var Float64ArrayFE = require( '@stdlib/array/fixed-endian-float64' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayFE( 'little-endian', 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayFE( 'big-endian', arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayFE( 'little-endian', arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayFE( 'big-endian', arr.buffer, 8, 2 ); -logEach( '%s', out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/fixed-endian-float64/benchmark/benchmark.from.js b/fixed-endian-float64/benchmark/benchmark.from.js deleted file mode 100644 index 06f8c4fb3..000000000 --- a/fixed-endian-float64/benchmark/benchmark.from.js +++ /dev/null @@ -1,310 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayFE = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.from( 'little-endian', createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return v * 2.0; - } -}); diff --git a/fixed-endian-float64/benchmark/benchmark.get.js b/fixed-endian-float64/benchmark/benchmark.get.js deleted file mode 100644 index 5ac1002f5..000000000 --- a/fixed-endian-float64/benchmark/benchmark.get.js +++ /dev/null @@ -1,85 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float64ArrayFE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':get:endianness=little-endian', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayFE( 'little-endian', arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':get:endianness=big-endian', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayFE( 'big-endian', arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-float64/benchmark/benchmark.js b/fixed-endian-float64/benchmark/benchmark.js deleted file mode 100644 index 946eff0d1..000000000 --- a/fixed-endian-float64/benchmark/benchmark.js +++ /dev/null @@ -1,533 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var ArrayBuffer = require( './../../buffer' ); -var Float64Array = require( './../../float64' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayFE = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// FUNCTIONS // - -/** -* Returns an "iterable" object. -* -* @private -* @returns {Object} iterable object -*/ -function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } -} - - -// MAIN // - -bench( pkg+'::instantiation,new:endianness=little-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,new:endianness=big-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new:endianness=little-endian', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float64ArrayFE; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor( 'little-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new:endianness=big-endian', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float64ArrayFE; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor( 'big-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length:endianness=little-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length:endianness=big-endian', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable:endianness=little-endian', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable:endianness=big-endian', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length:endianness=little-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'little-endian', buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length:endianness=big-endian', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayFE( 'big-endian', buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayFE( 'little-endian' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-float64/benchmark/benchmark.of.js b/fixed-endian-float64/benchmark/benchmark.of.js deleted file mode 100644 index 2222d5c82..000000000 --- a/fixed-endian-float64/benchmark/benchmark.of.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayFE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.of( 'little-endian' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 'little-endian', 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayFE.of.apply( Float64ArrayFE, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayFE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-float64/benchmark/benchmark.set.js b/fixed-endian-float64/benchmark/benchmark.set.js deleted file mode 100644 index 2cb984120..000000000 --- a/fixed-endian-float64/benchmark/benchmark.set.js +++ /dev/null @@ -1,209 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../float64' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayFE = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::number:set:endianness=little-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayFE( 'little-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::number:set:endianness=big-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayFE( 'big-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:set:endianness=little-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayFE( 'little-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:set:endianness=big-endian', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayFE( 'big-endian', values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set:endianness=little-endian', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float64ArrayFE( 'little-endian', values ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set:endianness=big-endian', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float64ArrayFE( 'big-endian', values ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-float64/benchmark/benchmark.set.length.js b/fixed-endian-float64/benchmark/benchmark.set.length.js deleted file mode 100644 index 5848832e7..000000000 --- a/fixed-endian-float64/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randu = require( '@stdlib/random/array/randu' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayFE = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - - arr1 = randu( len ); - arr2 = randu( len ); - arr3 = randu( len ); - arr1 = new Float64ArrayFE( 'little-endian', arr1 ); - - values = [ - new Float64ArrayFE( 'little-endian', arr2 ), - new Float64ArrayFE( 'big-endian', arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-float64/benchmark/benchmark.to_string.js b/fixed-endian-float64/benchmark/benchmark.to_string.js deleted file mode 100644 index f042a11e1..000000000 --- a/fixed-endian-float64/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayFE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/fixed-endian-float64/benchmark/benchmark.to_string.length.js b/fixed-endian-float64/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 89e570b2b..000000000 --- a/fixed-endian-float64/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayFE = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayFE( 'little-endian', zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/fixed-endian-float64/examples/index.js b/fixed-endian-float64/examples/index.js deleted file mode 100644 index 632c5e325..000000000 --- a/fixed-endian-float64/examples/index.js +++ /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. -*/ - -'use strict'; - -var Float64Array = require( './../../float64' ); -var logEach = require( '@stdlib/console/log-each' ); -var Float64ArrayFE = require( './../lib' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayFE( 'little-endian', 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayFE( 'big-endian', arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayFE( 'little-endian', arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayFE( 'big-endian', arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/fixed-endian-float64/lib/index.js b/fixed-endian-float64/lib/index.js deleted file mode 100644 index a4841f919..000000000 --- a/fixed-endian-float64/lib/index.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in a specified byte order. -* -* @module @stdlib/array/fixed-endian-float64 -* -* @example -* var Float64ArrayFE = require( '@stdlib/array/fixed-endian-float64' ); -* -* var arr = new Float64ArrayFE( 'little-endian' ); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float64ArrayFE = require( '@stdlib/array/fixed-endian-float64' ); -* -* var arr = new Float64ArrayFE( 'little-endian', 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float64ArrayFE = require( '@stdlib/array/fixed-endian-float64' ); -* -* var arr = new Float64ArrayFE( 'little-endian', [ 1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float64ArrayFE = require( '@stdlib/array/fixed-endian-float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayFE( 'little-endian', buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float64ArrayFE = require( '@stdlib/array/fixed-endian-float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayFE( 'little-endian', buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float64ArrayFE = require( '@stdlib/array/fixed-endian-float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayFE( 'little-endian', buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/fixed-endian-float64/lib/main.js b/fixed-endian-float64/lib/main.js deleted file mode 100644 index 4ba443b85..000000000 --- a/fixed-endian-float64/lib/main.js +++ /dev/null @@ -1,100 +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. -*/ - -'use strict'; - -// MODULES // - -var factory = require( './../../fixed-endian-factory' ); - - -// MAIN // - -/** -* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in a specified byte order. -* -* @name Float64ArrayFE -* @constructor -* @type {Function} -* @param {string} endianness - byte order -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {TypeError} first argument must be a supported byte order -* @throws {TypeError} if provided only two arguments, the second argument must be a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @returns {Float64ArrayFE} typed array instance -* -* @example -* var arr = new Float64ArrayFE( 'little-endian' ); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float64ArrayFE( 'little-endian', 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayFE( 'little-endian', buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayFE( 'little-endian', buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayFE( 'little-endian', buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -var Float64ArrayFE = factory( 'float64' ); - - -// EXPORTS // - -module.exports = Float64ArrayFE; diff --git a/fixed-endian-float64/package.json b/fixed-endian-float64/package.json deleted file mode 100644 index 3d453855c..000000000 --- a/fixed-endian-float64/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/fixed-endian-float64", - "version": "0.0.0", - "description": "Float64Array having a specified byte order.", - "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", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "float64array", - "float64", - "double", - "double-precision", - "ieee754", - "endian", - "little-endian", - "big-endian", - "byte-order" - ] -} diff --git a/fixed-endian-float64/test/test.js b/fixed-endian-float64/test/test.js deleted file mode 100644 index fc72bbf88..000000000 --- a/fixed-endian-float64/test/test.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests diff --git a/float32/README.md b/float32/README.md deleted file mode 100644 index 6de915a9a..000000000 --- a/float32/README.md +++ /dev/null @@ -1,1486 +0,0 @@ - - -# Float32Array - -> [Typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of single-precision floating-point numbers in the platform byte order. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); -``` - -#### Float32Array() - -A [typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of single-precision floating-point numbers in the platform byte order. - - - -```javascript -var arr = new Float32Array(); -// returns -``` - -#### Float32Array( length ) - -Returns a [typed array][mdn-typed-array] having a specified length. - - - -```javascript -var arr = new Float32Array( 5 ); -// returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] -``` - -#### Float32Array( typedarray ) - -Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var arr1 = new Float64Array( [ 0.5, 0.5, 0.5 ] ); -var arr2 = new Float32Array( arr1 ); -// returns [ 0.5, 0.5, 0.5 ] -``` - -#### Float32Array( obj ) - -Creates a [typed array][mdn-typed-array] from an array-like `object` or iterable. - - - -```javascript -var arr = new Float32Array( [ 0.5, 0.5, 0.5 ] ); -// returns [ 0.5, 0.5, 0.5 ] -``` - -#### Float32Array( buffer\[, byteOffset\[, length]] ) - -Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 16 ); -var arr = new Float32Array( buf, 0, 4 ); -// returns [ 0.0, 0.0, 0.0, 0.0 ] -``` - -* * * - -### Properties - - - -#### Float32Array.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var nbytes = Float32Array.BYTES_PER_ELEMENT; -// returns 4 -``` - - - -#### Float32Array.name - -[Typed array][mdn-typed-array] constructor name. - - - -```javascript -var str = Float32Array.name; -// returns 'Float32Array' -``` - - - -#### Float32Array.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Float32Array( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Float32Array.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Float32Array( 5 ); -var byteLength = arr.byteLength; -// returns 20 -``` - - - -#### Float32Array.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the [typed array][mdn-typed-array] from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var arr = new Float32Array( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Float32Array.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var arr = new Float32Array( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 4 -``` - - - -#### Float32Array.prototype.length - -**Read-only** property which returns the number of view elements. - - - -```javascript -var arr = new Float32Array( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Float32Array.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like `object` or an iterable. - - - -```javascript -var arr = Float32Array.from( [ 1.0, 2.0 ] ); -// returns [ 1.0, 2.0 ] -``` - -To invoke a function for each `src` value, provide a callback function. - - - -```javascript -function mapFcn( v ) { - return v * 2.0; -} - -var arr = Float32Array.from( [ 1.0, 2.0 ], mapFcn ); -// returns [ 2.0, 4.0 ] -``` - -A callback function is provided two arguments: - -- `value`: source value. -- `index`: source index. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2.0; -} - -var ctx = { - 'count': 0 -}; - -var arr = Float32Array.from( [ 1.0, 2.0 ], mapFcn, ctx ); -// returns [ 2.0, 4.0 ] - -var n = ctx.count; -// returns 2 -``` - - - -#### Float32Array.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - - - -```javascript -var arr = Float32Array.of( 1.0, 2.0 ); -// returns [ 1.0, 2.0 ] -``` - - - -#### Float32Array.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within an array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 3 ); - -var v = arr[ 0 ]; -// returns 4.0 - -v = arr[ 1 ]; -// returns 5.0 -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( 3, 0, 2 ); - -var v = arr[ 3 ]; -// returns 1.0 - -v = arr[ 4 ]; -// returns 2.0 -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( -2, -5, -3 ); - -var v = arr[ 3 ]; -// returns 1.0 - -v = arr[ 4 ]; -// returns 2.0 -``` - - - -#### Float32Array.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0 ] ); - -// Create an iterator: -var it = arr.entries(); - -// Iterate over key-value pairs... -var v = it.next().value; -// returns [ 0, 1.0 ] - -v = it.next().value; -// returns [ 1, 2.0 ] - -var bool = it.next().done; -// returns true -``` - - - -#### Float32Array.prototype.every( predicate\[, thisArg] ) - -Tests whether all array elements pass a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v <= 1.0 ); -} - -var arr = new Float32Array( [ 1.0, 2.0 ] ); - -var bool = arr.every( predicate ); -// returns false -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 1.0 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Float32Array( [ 1.0, 2.0 ] ); - -var bool = arr.every( predicate, ctx ); -// returns true - -var n = ctx.count; -// returns 2 -``` - - - -#### Float32Array.prototype.fill( value\[, start\[, end]] ) - -Fills an array from a `start` index to an `end` index (non-inclusive) with a provided `value`. - - - -```javascript -var arr = new Float32Array( 2 ); - -// Set all array elements to the same value: -arr.fill( 2.0 ); - -var v = arr[ 0 ]; -// returns 2.0 - -v = arr[ 1 ]; -// returns 2.0 - -// Set all array elements starting from the first index to the same value: -arr.fill( 3.0, 1 ); - -v = arr[ 0 ]; -// returns 2.0 - -v = arr[ 1 ]; -// returns 3.0 - -// Set all array elements, except the last element, to the same value: -arr.fill( 4.0, 0, arr.length-1 ); - -v = arr[ 0 ]; -// returns 4.0 - -v = arr[ 1 ]; -// returns 3.0 -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr = new Float32Array( 2 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( 2.0, -arr.length, -1 ); - -var v = arr[ 0 ]; -// returns 2.0 - -v = arr[ 1 ]; -// returns 0.0 -``` - - - -#### Float32Array.prototype.filter( predicate\[, thisArg] ) - -Creates a new array (of the same data type as the host array) which includes those elements for which a `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 2.0 ); -} - -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [ 2.0, 3.0 ] -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns an empty array. - - - -```javascript -function predicate( v ) { - return ( v >= 10.0 ); -} - -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [] -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2.0 ); -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.filter( predicate, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Float32Array.prototype.find( predicate\[, thisArg] ) - -Returns the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v > 2.0 ); -} - -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var v = arr.find( predicate ); -// returns 3.0 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `undefined`. - - - -```javascript -function predicate( v ) { - return ( v < 1.0 ); -} - -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var v = arr.find( predicate ); -// returns undefined -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v > 2.0 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var v = arr.find( predicate, ctx ); -// returns 3.0 - -var n = ctx.count; -// returns 3 -``` - - - -#### Float32Array.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 3.0 ); -} - -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.findIndex( predicate ); -// returns 2 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `-1`. - - - -```javascript -function predicate( v ) { - return ( v < 1.0 ); -} - -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.findIndex( predicate ); -// returns -1 -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 3.0 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.findIndex( predicate, ctx ); -// returns 2 - -var n = ctx.count; -// returns 3 -``` - - - -#### Float32Array.prototype.forEach( fcn\[, thisArg] ) - -Invokes a callback for each array element. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var str = ''; - -function fcn( v, i ) { - str += i + ':' + v; - if ( i < arr.length-1 ) { - str += ' '; - } -} - -arr.forEach( fcn ); - -console.log( str ); -// => '0:1 1:2 2:3' -``` - -The callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn() { - this.count += 1; -} - -var ctx = { - 'count': 0 -}; - -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -arr.forEach( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Float32Array.prototype.includes( searchElement\[, fromIndex] ) - -Returns a `boolean` indicating whether an array includes a search element. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var bool = arr.includes( 3.0 ); -// returns true - -bool = arr.includes( 0.0 ); -// returns false -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var bool = arr.includes( 1.0, 1 ); -// returns false -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var bool = arr.includes( 1.0, -2 ); -// returns false -``` - -The method does **not** distinguish between signed and unsigned zero. - - - -#### Float32Array.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the index of the first array element strictly equal to a search element. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.indexOf( 3.0 ); -// returns 2 - -idx = arr.indexOf( 0.0 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.indexOf( 1.0, 1 ); -// returns -1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.indexOf( 1.0, -2 ); -// returns -1 -``` - -The method does **not** distinguish between signed and unsigned zero. - - - -#### Float32Array.prototype.join( \[separator] ) - -Serializes an array by joining all array elements as a string. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var str = arr.join(); -// returns '1,2,3' -``` - -By default, the method delineates array elements using a comma `,`. To specify a custom separator, provide a `separator` string. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var str = arr.join( '|' ); -// returns '1|2|3' -``` - - - -#### Float32Array.prototype.keys() - -Returns an iterator for iterating over array keys. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0 ] ); - -// Create an iterator: -var it = arr.keys(); - -// Iterate over keys... -var v = it.next().value; -// returns 0 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - - - -#### Float32Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the index of the last array element strictly equal to a search element, iterating from right to left. - - - -```javascript -var arr = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 1.0 ] ); - -var idx = arr.lastIndexOf( 0.0 ); -// returns 3 - -idx = arr.lastIndexOf( 3.0 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = -1`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 1.0 ] ); - -var idx = arr.lastIndexOf( 0.0, 2 ); -// returns 1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 1.0 ] ); - -var idx = arr.lastIndexOf( 0.0, -3 ); -// returns 1 -``` - -The method does **not** distinguish between signed and unsigned zero. - - - -#### Float32Array.prototype.map( fcn\[, thisArg] ) - -Maps each array element to an element in a new array having the same data type as the host array. - - - -```javascript -function fcn( v ) { - return v * 2.0; -} - -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.map( fcn ); -// returns [ 2.0, 4.0, 6.0 ] -``` - -A callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn( v ) { - this.count += 1; - return v * 2.0; -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.map( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Float32Array.prototype.reduce( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Float32Array( [ 2.0, 1.0, 3.0 ] ); - -var v = arr.reduce( fcn ); -// returns 12.0 -``` - -If not provided an initial value, the method invokes a provided function with the first array element as the first argument and the second array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the first array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Float32Array( [ 2.0, 1.0, 3.0 ] ); - -var v = arr.reduce( fcn, 0.0 ); -// returns 14.0 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Float32Array.prototype.reduceRight( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result, iterating from right to left. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Float32Array( [ 2.0, 1.0, 3.0 ] ); - -var v = arr.reduceRight( fcn ); -// returns 8.0 -``` - -If not provided an initial value, the method invokes a provided function with the last array element as the first argument and the second-to-last array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the last array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Float32Array( [ 2.0, 1.0, 3.0 ] ); - -var v = arr.reduce( fcn, 0.0 ); -// returns 14.0 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Float32Array.prototype.reverse() - -Reverses an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Float32Array( [ 2.0, 0.0, 3.0 ] ); - -// Reverse the array: -arr.reverse(); - -var v = arr[ 0 ]; -// returns 3.0 - -v = arr[ 1 ]; -// returns 0.0 - -v = arr[ 2 ]; -// returns 2.0 -``` - - - -#### Float32Array.prototype.set( arr\[, offset] ) - -Sets array elements. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); -// returns [ 1.0, 2.0, 3.0 ] - -// Set the first two array elements: -arr.set( [ 4.0, 5.0 ] ); - -var v = arr[ 0 ]; -// returns 4.0 - -v = arr[ 1 ]; -// returns 5.0 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); -// returns [ 1.0, 2.0, 3.0 ] - -// Set the last two array elements: -arr.set( [ 4.0, 5.0 ], 1 ); - -var v = arr[ 1 ]; -// returns 4.0 - -v = arr[ 2 ]; -// returns 5.0 -``` - - - -#### Float32Array.prototype.slice( \[begin\[, end]] ) - -Copies array elements to a new array with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.slice(); - -var bool = ( arr1 === arr2 ); -// returns false - -bool = ( arr1.buffer === arr2.buffer ); -// returns false - -var v = arr2[ 0 ]; -// returns 1.0 - -v = arr2[ 1 ]; -// returns 2.0 - -v = arr2[ 2 ]; -// returns 3.0 -``` - -By default, the method copies elements beginning with the first array element. To specify an alternative array index at which to begin copying, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.slice( 1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 2.0 - -v = arr2[ 1 ]; -// returns 3.0 -``` - -By default, the method copies all array elements after `begin`. To specify an alternative array index at which to end copying, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.slice( 0, 2 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1.0 - -v = arr2[ 1 ]; -// returns 2.0 -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.slice( -arr1.length, -1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1.0 - -v = arr2[ 1 ]; -// returns 2.0 -``` - - - -#### Float32Array.prototype.some( predicate\[, thisArg] ) - -Tests whether at least one array element passes a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v >= 2.0 ); -} - -var arr = new Float32Array( [ 1.0, 2.0 ] ); - -var bool = arr.some( predicate ); -// returns true -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2.0 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Float32Array( [ 1.0, 1.0 ] ); - -var bool = arr.some( predicate, ctx ); -// returns false - -var n = ctx.count; -// returns 2 -``` - - - -#### Float32Array.prototype.sort( \[compareFunction] ) - -Sorts an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Float32Array( [ 2.0, 3.0, 0.0 ] ); - -// Sort the array (in ascending order): -arr.sort(); - -var v = arr[ 0 ]; -// returns 0.0 - -v = arr[ 1 ]; -// returns 2.0 - -v = arr[ 2 ]; -// returns 3.0 -``` - -By default, the method sorts array elements in ascending order. To impose a custom order, provide a `compareFunction`. - - - -```javascript -function descending( a, b ) { - return b - a; -} - -var arr = new Float32Array( [ 2.0, 3.0, 0.0 ] ); - -// Sort the array (in descending order): -arr.sort( descending ); - -var v = arr[ 0 ]; -// returns 3.0 - -v = arr[ 1 ]; -// returns 2.0 - -v = arr[ 2 ]; -// returns 0.0 -``` - -The comparison function is provided two array elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: - -- If the comparison function returns a value **less** than zero, then the method sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). -- If the comparison function returns a value **greater** than zero, then the method sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). -- If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. - - - -#### Float32Array.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.subarray(); -// returns [ 1.0, 2.0, 3.0 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.subarray( 1 ); -// returns [ 2.0, 3.0 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.subarray( 0, 2 ); -// returns [ 1.0, 2.0 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.subarray( -arr1.length, -1 ); -// returns [ 1.0, 2.0 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -If the method is unable to resolve indices to a non-empty array subsequence, the method returns an empty typed array. - - - -```javascript -var arr1 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.subarray( 10, -1 ); -// returns [] -``` - - - -#### Float32Array.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific `string`. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var str = arr.toLocaleString(); -// returns '1,2,3' -``` - - - -#### Float32Array.prototype.toString() - -Serializes an array as a `string`. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - - - -#### Float32Array.prototype.values() - -Returns an iterator for iterating over array elements. - - - -```javascript -var arr = new Float32Array( [ 1.0, 2.0 ] ); - -// Create an iterator: -var it = arr.values(); - -// Iterate over array elements... -var v = it.next().value; -// returns 1.0 - -v = it.next().value; -// returns 2.0 - -var bool = it.next().done; -// returns true -``` - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var ctor = require( '@stdlib/array/float32' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/float32/benchmark/benchmark.copy_within.js b/float32/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7e64a807c..000000000 --- a/float32/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== i ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.copy_within.length.js b/float32/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index e7c4529c1..000000000 --- a/float32/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== i ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.data.js b/float32/benchmark/benchmark.data.js deleted file mode 100644 index b120c9418..000000000 --- a/float32/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float32Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Float32Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.entries.js b/float32/benchmark/benchmark.entries.js deleted file mode 100644 index 66e8bb259..000000000 --- a/float32/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float32Array( [ 1.0, 2.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.every.js b/float32/benchmark/benchmark.every.js deleted file mode 100644 index 3ae104313..000000000 --- a/float32/benchmark/benchmark.every.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/float32/benchmark/benchmark.every.length.js b/float32/benchmark/benchmark.every.length.js deleted file mode 100644 index f5693bf22..000000000 --- a/float32/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.fill.js b/float32/benchmark/benchmark.fill.js deleted file mode 100644 index 2358c69c8..000000000 --- a/float32/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.fill.length.js b/float32/benchmark/benchmark.fill.length.js deleted file mode 100644 index e7c5dab2e..000000000 --- a/float32/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.filter.js b/float32/benchmark/benchmark.filter.js deleted file mode 100644 index 1534462c1..000000000 --- a/float32/benchmark/benchmark.filter.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/float32/benchmark/benchmark.filter.length.js b/float32/benchmark/benchmark.filter.length.js deleted file mode 100644 index 7bb44041a..000000000 --- a/float32/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.find.js b/float32/benchmark/benchmark.find.js deleted file mode 100644 index 993fa3db0..000000000 --- a/float32/benchmark/benchmark.find.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); diff --git a/float32/benchmark/benchmark.find.length.js b/float32/benchmark/benchmark.find.length.js deleted file mode 100644 index d53055c70..000000000 --- a/float32/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.find_index.js b/float32/benchmark/benchmark.find_index.js deleted file mode 100644 index ebfae0de4..000000000 --- a/float32/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); diff --git a/float32/benchmark/benchmark.find_index.length.js b/float32/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 05cfd05e4..000000000 --- a/float32/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.for_each.js b/float32/benchmark/benchmark.for_each.js deleted file mode 100644 index 60c398fa4..000000000 --- a/float32/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float32Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float32Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/float32/benchmark/benchmark.for_each.length.js b/float32/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 0d700cc3d..000000000 --- a/float32/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float32Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.from.js b/float32/benchmark/benchmark.from.js deleted file mode 100644 index 6465a9009..000000000 --- a/float32/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( [ 1.0, 2.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat32Array( arr ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( [ 1.0, 2.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat32Array( arr ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat32Array( arr ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat32Array( arr ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat32Array( arr ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat32Array( arr ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/float32/benchmark/benchmark.includes.js b/float32/benchmark/benchmark.includes.js deleted file mode 100644 index 3082378a5..000000000 --- a/float32/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.includes.length.js b/float32/benchmark/benchmark.includes.length.js deleted file mode 100644 index a9c2d9fab..000000000 --- a/float32/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.index_of.js b/float32/benchmark/benchmark.index_of.js deleted file mode 100644 index b289de192..000000000 --- a/float32/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Float32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.index_of.length.js b/float32/benchmark/benchmark.index_of.length.js deleted file mode 100644 index adb0e9706..000000000 --- a/float32/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.join.js b/float32/benchmark/benchmark.join.js deleted file mode 100644 index d31859c4c..000000000 --- a/float32/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.join.length.js b/float32/benchmark/benchmark.join.length.js deleted file mode 100644 index 93632d2fe..000000000 --- a/float32/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.js b/float32/benchmark/benchmark.js deleted file mode 100644 index b924b087c..000000000 --- a/float32/benchmark/benchmark.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isFloat32Array( arr ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -// TODO: add additional instantiation benchmarks (e.g., ArrayBuffer, etc) diff --git a/float32/benchmark/benchmark.keys.js b/float32/benchmark/benchmark.keys.js deleted file mode 100644 index b3445cc52..000000000 --- a/float32/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.last_index_of.js b/float32/benchmark/benchmark.last_index_of.js deleted file mode 100644 index b20104455..000000000 --- a/float32/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Float32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.last_index_of.length.js b/float32/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index a9bec6955..000000000 --- a/float32/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.length.js b/float32/benchmark/benchmark.length.js deleted file mode 100644 index cba0e610c..000000000 --- a/float32/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isFloat32Array( arr ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.map.js b/float32/benchmark/benchmark.map.js deleted file mode 100644 index fc405d038..000000000 --- a/float32/benchmark/benchmark.map.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/float32/benchmark/benchmark.map.length.js b/float32/benchmark/benchmark.map.length.js deleted file mode 100644 index 5149d9d79..000000000 --- a/float32/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.of.js b/float32/benchmark/benchmark.of.js deleted file mode 100644 index 0eaa15866..000000000 --- a/float32/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat32Array( arr ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.properties.js b/float32/benchmark/benchmark.properties.js deleted file mode 100644 index 563d90f41..000000000 --- a/float32/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.reduce.js b/float32/benchmark/benchmark.reduce.js deleted file mode 100644 index 52e04a3d5..000000000 --- a/float32/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/float32/benchmark/benchmark.reduce.length.js b/float32/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 2f7db2485..000000000 --- a/float32/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.reduce_right.js b/float32/benchmark/benchmark.reduce_right.js deleted file mode 100644 index bd2ff4988..000000000 --- a/float32/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/float32/benchmark/benchmark.reduce_right.length.js b/float32/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 5010b8c4c..000000000 --- a/float32/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.reverse.js b/float32/benchmark/benchmark.reverse.js deleted file mode 100644 index 9f19259a1..000000000 --- a/float32/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.reverse.length.js b/float32/benchmark/benchmark.reverse.length.js deleted file mode 100644 index e0f46f40b..000000000 --- a/float32/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.set.js b/float32/benchmark/benchmark.set.js deleted file mode 100644 index 9fc4b69e0..000000000 --- a/float32/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float32Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float32Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float32Array( 2 ); - buf = new Float32Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.set.length.js b/float32/benchmark/benchmark.set.length.js deleted file mode 100644 index b67f4fa0e..000000000 --- a/float32/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Float32Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.slice.js b/float32/benchmark/benchmark.slice.js deleted file mode 100644 index 0c585e89e..000000000 --- a/float32/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.slice.length.js b/float32/benchmark/benchmark.slice.length.js deleted file mode 100644 index 8458ec831..000000000 --- a/float32/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.some.js b/float32/benchmark/benchmark.some.js deleted file mode 100644 index 0fd324374..000000000 --- a/float32/benchmark/benchmark.some.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); diff --git a/float32/benchmark/benchmark.some.length.js b/float32/benchmark/benchmark.some.length.js deleted file mode 100644 index f82b82cbf..000000000 --- a/float32/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.sort.js b/float32/benchmark/benchmark.sort.js deleted file mode 100644 index 98441ed4f..000000000 --- a/float32/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 randi = require( '@stdlib/random/base/randi' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.sort.length.js b/float32/benchmark/benchmark.sort.length.js deleted file mode 100644 index aa0e5595b..000000000 --- a/float32/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Float32Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.subarray.js b/float32/benchmark/benchmark.subarray.js deleted file mode 100644 index 5b032889b..000000000 --- a/float32/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.subarray.length.js b/float32/benchmark/benchmark.subarray.length.js deleted file mode 100644 index d2a112e4b..000000000 --- a/float32/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat32Array( out ) ) { - b.fail( 'should return a Float32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.to_locale_string.js b/float32/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index e1bc74e71..000000000 --- a/float32/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.to_locale_string.length.js b/float32/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 5948a579f..000000000 --- a/float32/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.to_string.js b/float32/benchmark/benchmark.to_string.js deleted file mode 100644 index 25c4da95f..000000000 --- a/float32/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/benchmark/benchmark.to_string.length.js b/float32/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 954d17133..000000000 --- a/float32/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/float32/benchmark/benchmark.values.js b/float32/benchmark/benchmark.values.js deleted file mode 100644 index dda1b3f8c..000000000 --- a/float32/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float32/docs/repl.txt b/float32/docs/repl.txt deleted file mode 100644 index 9e3a8f87f..000000000 --- a/float32/docs/repl.txt +++ /dev/null @@ -1,959 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of single-precision floating-point numbers in the platform byte order. - - Returns - ------- - out: Float32Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Float32Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Float32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/float64}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Float32Array - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Float32Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0.0, 0.0, 0.0, 0.0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Float32Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2.0; }; - > var arr = {{alias}}.from( [ 1.0, -1.0 ], mapFcn ) - [ 2.0, -2.0 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Float32Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 2.0, -2.0 ) - [ 2.0, -2.0 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 4 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Float32Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 20 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 4 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Float32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 2.0, -2.0, 1.0, -1.0, 1.0 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 2.0 - > arr[ 4 ] - -2.0 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1.0 ] - > it.next().value - [ 1, -1.0 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > function predicate( v ) { return ( v >= 0.0 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > arr.fill( 2.0 ); - > arr[ 0 ] - 2.0 - > arr[ 1 ] - 2.0 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Float32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function predicate( v ) { return ( v >= 0.0 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function predicate( v ) { return ( v < 0.0 ); }; - > var v = arr.find( predicate ) - -1.0 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function predicate( v ) { return ( v < 0.0 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:1 1:0 2:-1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - The method does not distinguish between signed and unsigned zero. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > var bool = arr.includes( 2.0 ) - false - > bool = arr.includes( -1.0 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - The method does not distinguish between signed and unsigned zero. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > var idx = arr.indexOf( 2.0 ) - -1 - > idx = arr.indexOf( -1.0 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > arr.join( '|' ) - '1|0|-1' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - The method does not distinguish between signed and unsigned zero. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0, 0.0, 1.0 ] ); - > var idx = arr.lastIndexOf( 2.0 ) - -1 - > idx = arr.lastIndexOf( 0.0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Float32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function fcn( v ) { return v * 2.0; }; - > var arr2 = arr1.map( fcn ) - [ 2.0, 0.0, -2.0 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0.0 ) - 2.0 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0.0 ) - 2.0 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Float32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ) - - > arr.reverse() - [ -1.0, 0.0, 1.0 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > arr.set( [ -2.0, 2.0 ], 1 ); - > arr[ 1 ] - -2.0 - > arr[ 2 ] - 2.0 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Float32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 0.0 - > arr2[ 1 ] - -1.0 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > function predicate( v ) { return ( v < 0.0 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Float32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 0.0, 2.0, -2.0 ] ); - > arr.sort() - [ -2.0, -1.0, 0.0, 1.0, 2.0 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Float32Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, -1.0, 0.0, 2.0, -2.0 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 0.0, 2.0, -2.0 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 0.0 ] ); - > arr.toLocaleString() - '1,-1,0' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 0.0 ] ); - > arr.toString() - '1,-1,0' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > it = arr.values(); - > it.next().value - 1.0 - > it.next().value - -1.0 - > it.next().done - true - - - See Also - -------- - diff --git a/float32/docs/types/index.d.ts b/float32/docs/types/index.d.ts deleted file mode 100644 index bc414668b..000000000 --- a/float32/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order. -*/ -export = Float32Array; diff --git a/float32/docs/types/test.ts b/float32/docs/types/test.ts deleted file mode 100644 index e90fa4932..000000000 --- a/float32/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Float32Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Float32Array( 10 ); // $ExpectType Float32Array - new Float32Array( [ 2.1, 3.9, 5.2, 7.3 ] ); // $ExpectType Float32Array -} - -// The constructor function has to be invoked with `new`... -{ - Float32Array( 10 ); // $ExpectError - Float32Array( [ 2.1, 3.9, 5.2, 7.3 ] ); // $ExpectError -} diff --git a/float32/examples/index.js b/float32/examples/index.js deleted file mode 100644 index a47829c7c..000000000 --- a/float32/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -console.log( arr ); diff --git a/float32/lib/index.js b/float32/lib/index.js deleted file mode 100644 index 20514f089..000000000 --- a/float32/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order. -* -* @module @stdlib/array/float32 -* -* @example -* var ctor = require( '@stdlib/array/float32' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasFloat32ArraySupport = require( '@stdlib/assert/has-float32array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasFloat32ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/float32/lib/main.js b/float32/lib/main.js deleted file mode 100644 index 826b2ed64..000000000 --- a/float32/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof Float32Array === 'function' ) ? Float32Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/float32/lib/polyfill.js b/float32/lib/polyfill.js deleted file mode 100644 index 43e3bf4e9..000000000 --- a/float32/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of single-precision floating-point numbers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/float32/package.json b/float32/package.json deleted file mode 100644 index 1acdf01b9..000000000 --- a/float32/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/float32", - "version": "0.0.0", - "description": "Float32Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "float32array", - "float32", - "float", - "single", - "single-precision", - "ieee754" - ] -} diff --git a/float32/test/test.copy_within.js b/float32/test/test.copy_within.js deleted file mode 100644 index fb7e117ac..000000000 --- a/float32/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasProp = require( '@stdlib/assert/has-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Float32Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float32Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Float32Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float32Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float32Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float32Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float32Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float32Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float32Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float32Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1.0, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float32Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1.0, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float32Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1.0, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float32Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1.0, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2.0, 'returns expected value' ); - - t.end(); -}); diff --git a/float32/test/test.js b/float32/test/test.js deleted file mode 100644 index 097f091da..000000000 --- a/float32/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasFloat32ArraySupport = require( '@stdlib/assert/has-float32array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasFloat32Arrays = hasFloat32ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Float32Array`, the export is an alias for `Float32Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-float32array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasFloat32Arrays ) { - t.strictEqual( ctor, Float32Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Float32Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-float32array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/float32/test/test.polyfill.js b/float32/test/test.polyfill.js deleted file mode 100644 index 9d6fcb190..000000000 --- a/float32/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests diff --git a/float64/README.md b/float64/README.md deleted file mode 100644 index d848bb64b..000000000 --- a/float64/README.md +++ /dev/null @@ -1,1478 +0,0 @@ - - -# Float64Array - -> [Typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of double-precision floating-point numbers in the platform byte order. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -``` - -#### Float64Array() - -A [typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of double-precision floating-point numbers in the platform byte order. - - - -```javascript -var arr = new Float64Array(); -// returns -``` - -#### Float64Array( length ) - -Returns a [typed array][mdn-typed-array] having a specified length. - - - -```javascript -var arr = new Float64Array( 5 ); -// returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] -``` - -#### Float64Array( typedarray ) - -Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - - - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 0.5, 0.5, 0.5 ] ); -var arr2 = new Float64Array( arr1 ); -// returns [ 0.5, 0.5, 0.5 ] -``` - -#### Float64Array( obj ) - -Creates a [typed array][mdn-typed-array] from an array-like `object` or iterable. - - - -```javascript -var arr = new Float64Array( [ 0.5, 0.5, 0.5 ] ); -// returns [ 0.5, 0.5, 0.5 ] -``` - -#### Float64Array( buffer\[, byteOffset\[, length]] ) - -Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 32 ); -var arr = new Float64Array( buf, 0, 4 ); -// returns [ 0.0, 0.0, 0.0, 0.0 ] -``` - -* * * - -### Properties - - - -#### Float64Array.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var nbytes = Float64Array.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### Float64Array.name - -[Typed array][mdn-typed-array] constructor name. - - - -```javascript -var str = Float64Array.name; -// returns 'Float64Array' -``` - - - -#### Float64Array.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Float64Array( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Float64Array.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Float64Array( 5 ); -var byteLength = arr.byteLength; -// returns 40 -``` - - - -#### Float64Array.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the [typed array][mdn-typed-array] from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var arr = new Float64Array( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Float64Array.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var arr = new Float64Array( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### Float64Array.prototype.length - -**Read-only** property which returns the number of view elements. - - - -```javascript -var arr = new Float64Array( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Float64Array.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like `object` or an iterable. - -```javascript -var arr = Float64Array.from( [ 1.0, -1.0 ] ); -// returns [ 1.0, -1.0 ] -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2.0; -} - -var arr = Float64Array.from( [ 1.0, -1.0 ], mapFcn ); -// returns [ 2.0, -2.0 ] -``` - -A callback function is provided two arguments: - -- `value`: source value. -- `index`: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2.0; -} - -var ctx = { - 'count': 0 -}; - -var arr = Float64Array.from( [ 1.0, -1.0 ], mapFcn, ctx ); -// returns [ 2.0, -2.0 ] - -var n = ctx.count; -// returns 2 -``` - - - -#### Float64Array.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Float64Array.of( 1.0, -1.0 ); -// returns [ 1.0, -1.0 ] -``` - - - -#### Float64Array.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within an array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 3 ); - -var v = arr[ 0 ]; -// returns 4.0 - -v = arr[ 1 ]; -// returns 5.0 -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( 3, 0, 2 ); - -var v = arr[ 3 ]; -// returns 1.0 - -v = arr[ 4 ]; -// returns 2.0 -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( -2, -5, -3 ); - -var v = arr[ 3 ]; -// returns 1.0 - -v = arr[ 4 ]; -// returns 2.0 -``` - - - -#### Float64Array.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0 ] ); - -// Create an iterator: -var it = arr.entries(); - -// Iterate over key-value pairs... -var v = it.next().value; -// returns [ 0, 1.0 ] - -v = it.next().value; -// returns [ 1, 2.0 ] - -var bool = it.next().done; -// returns true -``` - - - -#### Float64Array.prototype.every( predicate\[, thisArg] ) - -Tests whether all array elements pass a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v <= 1.0 ); -} - -var arr = new Float64Array( [ 1.0, 2.0 ] ); - -var bool = arr.every( predicate ); -// returns false -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 1.0 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Float64Array( [ 1.0, 2.0 ] ); - -var bool = arr.every( predicate, ctx ); -// returns true - -var n = ctx.count; -// returns 2 -``` - - - -#### Float64Array.prototype.fill( value\[, start\[, end]] ) - -Fills an array from a `start` index to an `end` index (non-inclusive) with a provided `value`. - - - -```javascript -var arr = new Float64Array( 2 ); - -// Set all array elements to the same value: -arr.fill( 2.0 ); - -var v = arr[ 0 ]; -// returns 2.0 - -v = arr[ 1 ]; -// returns 2.0 - -// Set all array elements starting from the first index to the same value: -arr.fill( 3.0, 1 ); - -v = arr[ 0 ]; -// returns 2.0 - -v = arr[ 1 ]; -// returns 3.0 - -// Set all array elements, except the last element, to the same value: -arr.fill( 4.0, 0, arr.length-1 ); - -v = arr[ 0 ]; -// returns 4.0 - -v = arr[ 1 ]; -// returns 3.0 -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr = new Float64Array( 2 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( 2.0, -arr.length, -1 ); - -var v = arr[ 0 ]; -// returns 2.0 - -v = arr[ 1 ]; -// returns 0.0 -``` - - - -#### Float64Array.prototype.filter( predicate\[, thisArg] ) - -Creates a new array (of the same data type as the host array) which includes those elements for which a `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 2.0 ); -} - -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [ 2.0, 3.0 ] -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns an empty array. - - - -```javascript -function predicate( v ) { - return ( v >= 10.0 ); -} - -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [] -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2.0 ); -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.filter( predicate, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Float64Array.prototype.find( predicate\[, thisArg] ) - -Returns the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v > 2.0 ); -} - -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var v = arr.find( predicate ); -// returns 3.0 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `undefined`. - - - -```javascript -function predicate( v ) { - return ( v < 1.0 ); -} - -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var v = arr.find( predicate ); -// returns undefined -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v > 2.0 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var v = arr.find( predicate, ctx ); -// returns 3.0 - -var n = ctx.count; -// returns 3 -``` - - - -#### Float64Array.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 3.0 ); -} - -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.findIndex( predicate ); -// returns 2 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `-1`. - - - -```javascript -function predicate( v ) { - return ( v < 1.0 ); -} - -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.findIndex( predicate ); -// returns -1 -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 3.0 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.findIndex( predicate, ctx ); -// returns 2 - -var n = ctx.count; -// returns 3 -``` - - - -#### Float64Array.prototype.forEach( fcn\[, thisArg] ) - -Invokes a callback for each array element. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var str = ''; - -function fcn( v, i ) { - str += i + ':' + v; - if ( i < arr.length-1 ) { - str += ' '; - } -} - -arr.forEach( fcn ); - -console.log( str ); -// => '0:1 1:2 2:3' -``` - -The callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn() { - this.count += 1; -} - -var ctx = { - 'count': 0 -}; - -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -arr.forEach( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Float64Array.prototype.includes( searchElement\[, fromIndex] ) - -Returns a `boolean` indicating whether an array includes a search element. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var bool = arr.includes( 3.0 ); -// returns true - -bool = arr.includes( 0.0 ); -// returns false -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var bool = arr.includes( 1.0, 1 ); -// returns false -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var bool = arr.includes( 1.0, -2 ); -// returns false -``` - -The method does **not** distinguish between signed and unsigned zero. - - - -#### Float64Array.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the index of the first array element strictly equal to a search element. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.indexOf( 3.0 ); -// returns 2 - -idx = arr.indexOf( 0.0 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.indexOf( 1.0, 1 ); -// returns -1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var idx = arr.indexOf( 1.0, -2 ); -// returns -1 -``` - -The method does **not** distinguish between signed and unsigned zero. - - - -#### Float64Array.prototype.join( \[separator] ) - -Serializes an array by joining all array elements as a string. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var str = arr.join(); -// returns '1,2,3' -``` - -By default, the method delineates array elements using a comma `,`. To specify a custom separator, provide a `separator` string. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var str = arr.join( '|' ); -// returns '1|2|3' -``` - - - -#### Float64Array.prototype.keys() - -Returns an iterator for iterating over array keys. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0 ] ); - -// Create an iterator: -var it = arr.keys(); - -// Iterate over keys... -var v = it.next().value; -// returns 0 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - - - -#### Float64Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the index of the last array element strictly equal to a search element, iterating from right to left. - - - -```javascript -var arr = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 1.0 ] ); - -var idx = arr.lastIndexOf( 0.0 ); -// returns 3 - -idx = arr.lastIndexOf( 3.0 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = -1`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 1.0 ] ); - -var idx = arr.lastIndexOf( 0.0, 2 ); -// returns 1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 1.0 ] ); - -var idx = arr.lastIndexOf( 0.0, -3 ); -// returns 1 -``` - -The method does **not** distinguish between signed and unsigned zero. - - - -#### Float64Array.prototype.map( fcn\[, thisArg] ) - -Maps each array element to an element in a new array having the same data type as the host array. - - - -```javascript -function fcn( v ) { - return v * 2.0; -} - -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.map( fcn ); -// returns [ 2.0, 4.0, 6.0 ] -``` - -A callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn( v ) { - this.count += 1; - return v * 2.0; -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.map( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Float64Array.prototype.reduce( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Float64Array( [ 2.0, 1.0, 3.0 ] ); - -var v = arr.reduce( fcn ); -// returns 12.0 -``` - -If not provided an initial value, the method invokes a provided function with the first array element as the first argument and the second array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the first array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Float64Array( [ 2.0, 1.0, 3.0 ] ); - -var v = arr.reduce( fcn, 0.0 ); -// returns 14.0 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Float64Array.prototype.reduceRight( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result, iterating from right to left. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Float64Array( [ 2.0, 1.0, 3.0 ] ); - -var v = arr.reduceRight( fcn ); -// returns 8.0 -``` - -If not provided an initial value, the method invokes a provided function with the last array element as the first argument and the second-to-last array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the last array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Float64Array( [ 2.0, 1.0, 3.0 ] ); - -var v = arr.reduce( fcn, 0.0 ); -// returns 14.0 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Float64Array.prototype.reverse() - -Reverses an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Float64Array( [ 2.0, 0.0, 3.0 ] ); - -// Reverse the array: -arr.reverse(); - -var v = arr[ 0 ]; -// returns 3.0 - -v = arr[ 1 ]; -// returns 0.0 - -v = arr[ 2 ]; -// returns 2.0 -``` - - - -#### Float64Array.prototype.set( arr\[, offset] ) - -Sets array elements. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -// returns [ 1.0, 2.0, 3.0 ] - -// Set the first two array elements: -arr.set( [ 4.0, 5.0 ] ); - -var v = arr[ 0 ]; -// returns 4.0 - -v = arr[ 1 ]; -// returns 5.0 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -// returns [ 1.0, 2.0, 3.0 ] - -// Set the last two array elements: -arr.set( [ 4.0, 5.0 ], 1 ); - -var v = arr[ 1 ]; -// returns 4.0 - -v = arr[ 2 ]; -// returns 5.0 -``` - - - -#### Float64Array.prototype.slice( \[begin\[, end]] ) - -Copies array elements to a new array with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.slice(); - -var bool = ( arr1 === arr2 ); -// returns false - -bool = ( arr1.buffer === arr2.buffer ); -// returns false - -var v = arr2[ 0 ]; -// returns 1.0 - -v = arr2[ 1 ]; -// returns 2.0 - -v = arr2[ 2 ]; -// returns 3.0 -``` - -By default, the method copies elements beginning with the first array element. To specify an alternative array index at which to begin copying, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.slice( 1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 2.0 - -v = arr2[ 1 ]; -// returns 3.0 -``` - -By default, the method copies all array elements after `begin`. To specify an alternative array index at which to end copying, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.slice( 0, 2 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1.0 - -v = arr2[ 1 ]; -// returns 2.0 -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.slice( -arr1.length, -1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1.0 - -v = arr2[ 1 ]; -// returns 2.0 -``` - - - -#### Float64Array.prototype.some( predicate\[, thisArg] ) - -Tests whether at least one array element passes a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v >= 2.0 ); -} - -var arr = new Float64Array( [ 1.0, 2.0 ] ); - -var bool = arr.some( predicate ); -// returns true -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2.0 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Float64Array( [ 1.0, 1.0 ] ); - -var bool = arr.some( predicate, ctx ); -// returns false - -var n = ctx.count; -// returns 2 -``` - - - -#### Float64Array.prototype.sort( \[compareFunction] ) - -Sorts an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Float64Array( [ 2.0, 3.0, 0.0 ] ); - -// Sort the array (in ascending order): -arr.sort(); - -var v = arr[ 0 ]; -// returns 0.0 - -v = arr[ 1 ]; -// returns 2.0 - -v = arr[ 2 ]; -// returns 3.0 -``` - -By default, the method sorts array elements in ascending order. To impose a custom order, provide a `compareFunction`. - - - -```javascript -function descending( a, b ) { - return b - a; -} - -var arr = new Float64Array( [ 2.0, 3.0, 0.0 ] ); - -// Sort the array (in descending order): -arr.sort( descending ); - -var v = arr[ 0 ]; -// returns 3.0 - -v = arr[ 1 ]; -// returns 2.0 - -v = arr[ 2 ]; -// returns 0.0 -``` - -The comparison function is provided two array elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: - -- If the comparison function returns a value **less** than zero, then the method sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). -- If the comparison function returns a value **greater** than zero, then the method sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). -- If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. - - - -#### Float64Array.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.subarray(); -// returns [ 1.0, 2.0, 3.0 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.subarray( 1 ); -// returns [ 2.0, 3.0 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.subarray( 0, 2 ); -// returns [ 1.0, 2.0 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.subarray( -arr1.length, -1 ); -// returns [ 1.0, 2.0 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -If the method is unable to resolve indices to a non-empty array subsequence, the method returns an empty typed array. - - - -```javascript -var arr1 = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var arr2 = arr1.subarray( 10, -1 ); -// returns [] -``` - - - -#### Float64Array.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific `string`. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var str = arr.toLocaleString(); -// returns '1,2,3' -``` - - - -#### Float64Array.prototype.toString() - -Serializes an array as a `string`. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - - - -#### Float64Array.prototype.values() - -Returns an iterator for iterating over array elements. - - - -```javascript -var arr = new Float64Array( [ 1.0, 2.0 ] ); - -// Create an iterator: -var it = arr.values(); - -// Iterate over array elements... -var v = it.next().value; -// returns 1.0 - -v = it.next().value; -// returns 2.0 - -var bool = it.next().done; -// returns true -``` - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var ctor = require( '@stdlib/array/float64' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/float64/benchmark/benchmark.copy_within.js b/float64/benchmark/benchmark.copy_within.js deleted file mode 100644 index 52cb63a75..000000000 --- a/float64/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== i ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.copy_within.length.js b/float64/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index ebfc0c954..000000000 --- a/float64/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== i ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.data.js b/float64/benchmark/benchmark.data.js deleted file mode 100644 index f4a417b02..000000000 --- a/float64/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Float64Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Float64Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.entries.js b/float64/benchmark/benchmark.entries.js deleted file mode 100644 index 0eee51956..000000000 --- a/float64/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float64Array( [ 1.0, 2.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.every.js b/float64/benchmark/benchmark.every.js deleted file mode 100644 index 7499ada3d..000000000 --- a/float64/benchmark/benchmark.every.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/float64/benchmark/benchmark.every.length.js b/float64/benchmark/benchmark.every.length.js deleted file mode 100644 index b90ff3e26..000000000 --- a/float64/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.fill.js b/float64/benchmark/benchmark.fill.js deleted file mode 100644 index 7137c71f2..000000000 --- a/float64/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.fill.length.js b/float64/benchmark/benchmark.fill.length.js deleted file mode 100644 index f896f8ee3..000000000 --- a/float64/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.filter.js b/float64/benchmark/benchmark.filter.js deleted file mode 100644 index 8e4ce6a5b..000000000 --- a/float64/benchmark/benchmark.filter.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0.0; - } -}); diff --git a/float64/benchmark/benchmark.filter.length.js b/float64/benchmark/benchmark.filter.length.js deleted file mode 100644 index ebcae45a6..000000000 --- a/float64/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.find.js b/float64/benchmark/benchmark.find.js deleted file mode 100644 index 196c22c0a..000000000 --- a/float64/benchmark/benchmark.find.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); diff --git a/float64/benchmark/benchmark.find.length.js b/float64/benchmark/benchmark.find.length.js deleted file mode 100644 index 07c544480..000000000 --- a/float64/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.find_index.js b/float64/benchmark/benchmark.find_index.js deleted file mode 100644 index 44f1b1da0..000000000 --- a/float64/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); diff --git a/float64/benchmark/benchmark.find_index.length.js b/float64/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 78d12368b..000000000 --- a/float64/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.for_each.js b/float64/benchmark/benchmark.for_each.js deleted file mode 100644 index a5d013bc0..000000000 --- a/float64/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float64Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Float64Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/float64/benchmark/benchmark.for_each.length.js b/float64/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 1b33a73ff..000000000 --- a/float64/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Float64Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.from.js b/float64/benchmark/benchmark.from.js deleted file mode 100644 index 2d3e37593..000000000 --- a/float64/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( [ 1.0, 2.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat64Array( arr ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( [ 1.0, 2.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat64Array( arr ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat64Array( arr ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 2.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat64Array( arr ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat64Array( arr ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat64Array( arr ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1.0, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1.0; - } -}); diff --git a/float64/benchmark/benchmark.includes.js b/float64/benchmark/benchmark.includes.js deleted file mode 100644 index 411edf6a2..000000000 --- a/float64/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.includes.length.js b/float64/benchmark/benchmark.includes.length.js deleted file mode 100644 index 9c649244e..000000000 --- a/float64/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.index_of.js b/float64/benchmark/benchmark.index_of.js deleted file mode 100644 index ccbf9a329..000000000 --- a/float64/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Float64Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.index_of.length.js b/float64/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 6f5742809..000000000 --- a/float64/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.join.js b/float64/benchmark/benchmark.join.js deleted file mode 100644 index 96c057f1e..000000000 --- a/float64/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.join.length.js b/float64/benchmark/benchmark.join.length.js deleted file mode 100644 index 55bf7ae0f..000000000 --- a/float64/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.js b/float64/benchmark/benchmark.js deleted file mode 100644 index 27c726682..000000000 --- a/float64/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isFloat64Array( arr ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.keys.js b/float64/benchmark/benchmark.keys.js deleted file mode 100644 index e01f172d1..000000000 --- a/float64/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.last_index_of.js b/float64/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 3bd0469b6..000000000 --- a/float64/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Float64Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.last_index_of.length.js b/float64/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 4843100c8..000000000 --- a/float64/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1.0; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.length.js b/float64/benchmark/benchmark.length.js deleted file mode 100644 index 5be86c402..000000000 --- a/float64/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isFloat64Array( arr ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.map.js b/float64/benchmark/benchmark.map.js deleted file mode 100644 index 652e64838..000000000 --- a/float64/benchmark/benchmark.map.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/float64/benchmark/benchmark.map.length.js b/float64/benchmark/benchmark.map.length.js deleted file mode 100644 index 5b974ee49..000000000 --- a/float64/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.of.js b/float64/benchmark/benchmark.of.js deleted file mode 100644 index 25d5c5e3c..000000000 --- a/float64/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64Array.of( i, 2.0 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isFloat64Array( arr ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.properties.js b/float64/benchmark/benchmark.properties.js deleted file mode 100644 index 8fbfb46d9..000000000 --- a/float64/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.reduce.js b/float64/benchmark/benchmark.reduce.js deleted file mode 100644 index fd1a058be..000000000 --- a/float64/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/float64/benchmark/benchmark.reduce.length.js b/float64/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 7b4fd8835..000000000 --- a/float64/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.reduce_right.js b/float64/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 738859bbf..000000000 --- a/float64/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1.0; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3.14 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1.0; - } -}); diff --git a/float64/benchmark/benchmark.reduce_right.length.js b/float64/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index bb2b39bff..000000000 --- a/float64/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.reverse.js b/float64/benchmark/benchmark.reverse.js deleted file mode 100644 index 972570e08..000000000 --- a/float64/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.reverse.length.js b/float64/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 05138a829..000000000 --- a/float64/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.set.js b/float64/benchmark/benchmark.set.js deleted file mode 100644 index 026c58dd6..000000000 --- a/float64/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Float64Array( 2 ); - buf = [ 0.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Float64Array( 2 ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.set.length.js b/float64/benchmark/benchmark.set.length.js deleted file mode 100644 index d93bcd493..000000000 --- a/float64/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Float64Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.slice.js b/float64/benchmark/benchmark.slice.js deleted file mode 100644 index 27eb72d8a..000000000 --- a/float64/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.slice.length.js b/float64/benchmark/benchmark.slice.length.js deleted file mode 100644 index a808ebf91..000000000 --- a/float64/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.some.js b/float64/benchmark/benchmark.some.js deleted file mode 100644 index 9cec5ef7b..000000000 --- a/float64/benchmark/benchmark.some.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0.0; - } -}); diff --git a/float64/benchmark/benchmark.some.length.js b/float64/benchmark/benchmark.some.length.js deleted file mode 100644 index efa5670b7..000000000 --- a/float64/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.sort.js b/float64/benchmark/benchmark.sort.js deleted file mode 100644 index caf0421c9..000000000 --- a/float64/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 randi = require( '@stdlib/random/base/randi' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.sort.length.js b/float64/benchmark/benchmark.sort.length.js deleted file mode 100644 index 9f27d46eb..000000000 --- a/float64/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Float64Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.subarray.js b/float64/benchmark/benchmark.subarray.js deleted file mode 100644 index 797cd5e91..000000000 --- a/float64/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.subarray.length.js b/float64/benchmark/benchmark.subarray.length.js deleted file mode 100644 index fbfc2c339..000000000 --- a/float64/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isFloat64Array( out ) ) { - b.fail( 'should return a Float64Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.to_locale_string.js b/float64/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 005b9334f..000000000 --- a/float64/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.to_locale_string.length.js b/float64/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 2a99382fc..000000000 --- a/float64/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.to_string.js b/float64/benchmark/benchmark.to_string.js deleted file mode 100644 index a7275fc62..000000000 --- a/float64/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/benchmark/benchmark.to_string.length.js b/float64/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 39f880d65..000000000 --- a/float64/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/float64/benchmark/benchmark.values.js b/float64/benchmark/benchmark.values.js deleted file mode 100644 index 4d4bca6aa..000000000 --- a/float64/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Float64Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Float64Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/float64/docs/repl.txt b/float64/docs/repl.txt deleted file mode 100644 index 616aacdbf..000000000 --- a/float64/docs/repl.txt +++ /dev/null @@ -1,959 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of double-precision floating-point numbers in the platform byte order. - - Returns - ------- - out: Float64Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Float64Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Float64Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/float32}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Float64Array - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Float64Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 32 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0.0, 0.0, 0.0, 0.0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Float64Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2.0; }; - > var arr = {{alias}}.from( [ 1.0, -1.0 ], mapFcn ) - [ 2.0, -2.0 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Float64Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 2.0, -2.0 ) - [ 2.0, -2.0 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 8 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Float64Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 40 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 8 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Float64Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 2.0, -2.0, 1.0, -1.0, 1.0 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 2.0 - > arr[ 4 ] - -2.0 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1.0 ] - > it.next().value - [ 1, -1.0 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > function predicate( v ) { return ( v >= 0.0 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Float64Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > arr.fill( 2.0 ); - > arr[ 0 ] - 2.0 - > arr[ 1 ] - 2.0 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Float64Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function predicate( v ) { return ( v >= 0.0 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function predicate( v ) { return ( v < 0.0 ); }; - > var v = arr.find( predicate ) - -1.0 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function predicate( v ) { return ( v < 0.0 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:1 1:0 2:-1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - The method does not distinguish between signed and unsigned zero. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > var bool = arr.includes( 2.0 ) - false - > bool = arr.includes( -1.0 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - The method does not distinguish between signed and unsigned zero. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > var idx = arr.indexOf( 2.0 ) - -1 - > idx = arr.indexOf( -1.0 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > arr.join( '|' ) - '1|0|-1' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - The method does not distinguish between signed and unsigned zero. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0, 0.0, 1.0 ] ); - > var idx = arr.lastIndexOf( 2.0 ) - -1 - > idx = arr.lastIndexOf( 0.0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Float64Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function fcn( v ) { return v * 2.0; }; - > var arr2 = arr1.map( fcn ) - [ 2.0, 0.0, -2.0 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0.0 ) - 2.0 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0.0 ) - 2.0 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Float64Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ) - - > arr.reverse() - [ -1.0, 0.0, 1.0 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > arr.set( [ -2.0, 2.0 ], 1 ); - > arr[ 1 ] - -2.0 - > arr[ 2 ] - 2.0 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Float64Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, 0.0, -1.0 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 0.0 - > arr2[ 1 ] - -1.0 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > function predicate( v ) { return ( v < 0.0 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Float64Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 0.0, 2.0, -2.0 ] ); - > arr.sort() - [ -2.0, -1.0, 0.0, 1.0, 2.0 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Float64Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1.0, -1.0, 0.0, 2.0, -2.0 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 0.0, 2.0, -2.0 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 0.0 ] ); - > arr.toLocaleString() - '1,-1,0' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0, 0.0 ] ); - > arr.toString() - '1,-1,0' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1.0, -1.0 ] ); - > it = arr.values(); - > it.next().value - 1.0 - > it.next().value - -1.0 - > it.next().done - true - - - See Also - -------- - diff --git a/float64/docs/types/index.d.ts b/float64/docs/types/index.d.ts deleted file mode 100644 index 11f889476..000000000 --- a/float64/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in the platform byte order. -*/ -export = Float64Array; diff --git a/float64/docs/types/test.ts b/float64/docs/types/test.ts deleted file mode 100644 index 377f4cbd5..000000000 --- a/float64/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Float64Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Float64Array( 10 ); // $ExpectType Float64Array - new Float64Array( [ 2.1, 3.9, 5.2, 7.3 ] ); // $ExpectType Float64Array -} - -// The constructor function has to be invoked with `new`... -{ - Float64Array( 10 ); // $ExpectError - Float64Array( [ 2.1, 3.9, 5.2, 7.3 ] ); // $ExpectError -} diff --git a/float64/examples/index.js b/float64/examples/index.js deleted file mode 100644 index a47829c7c..000000000 --- a/float64/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -console.log( arr ); diff --git a/float64/lib/index.js b/float64/lib/index.js deleted file mode 100644 index 72d384422..000000000 --- a/float64/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in the platform byte order. -* -* @module @stdlib/array/float64 -* -* @example -* var ctor = require( '@stdlib/array/float64' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasFloat64ArraySupport = require( '@stdlib/assert/has-float64array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasFloat64ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/float64/lib/main.js b/float64/lib/main.js deleted file mode 100644 index 75b826d4b..000000000 --- a/float64/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof Float64Array === 'function' ) ? Float64Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/float64/lib/polyfill.js b/float64/lib/polyfill.js deleted file mode 100644 index f5e8b1ae2..000000000 --- a/float64/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of double-precision floating-point numbers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/float64/package.json b/float64/package.json deleted file mode 100644 index cc999e00e..000000000 --- a/float64/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/float64", - "version": "0.0.0", - "description": "Float64Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "float64array", - "float64", - "double", - "double-precision", - "ieee754" - ] -} diff --git a/float64/test/test.copy_within.js b/float64/test/test.copy_within.js deleted file mode 100644 index 01647bc09..000000000 --- a/float64/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasProp = require( '@stdlib/assert/has-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Float64Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Float64Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Float64Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Float64Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Float64Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float64Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float64Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float64Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float64Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float64Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1.0, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float64Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1.0, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1.0, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float64Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1.0, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0.0, - 1.0, - 2.0, - 3.0, - 4.0 - ]; - - p = new Float64Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1.0, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1.0, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2.0, 'returns expected value' ); - - t.end(); -}); diff --git a/float64/test/test.js b/float64/test/test.js deleted file mode 100644 index 89269e45a..000000000 --- a/float64/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasFloat64ArraySupport = require( '@stdlib/assert/has-float64array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasFloat64Arrays = hasFloat64ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Float64Array`, the export is an alias for `Float64Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-float64array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasFloat64Arrays ) { - t.strictEqual( ctor, Float64Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Float64Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-float64array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/float64/test/test.polyfill.js b/float64/test/test.polyfill.js deleted file mode 100644 index 9d6fcb190..000000000 --- a/float64/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests diff --git a/from-iterator/README.md b/from-iterator/README.md deleted file mode 100644 index 594c95e04..000000000 --- a/from-iterator/README.md +++ /dev/null @@ -1,220 +0,0 @@ - - -# iterator2array - -> Create (or fill) an array from an iterator. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var iterator2array = require( '@stdlib/array/from-iterator' ); -``` - -#### iterator2array( iterator\[, out]\[, mapFcn\[, thisArg]] ) - -Creates (or fills) an array from an `iterator`. - -```javascript -var randu = require( '@stdlib/random/iter/randu' ); - -var opts = { - 'iter': 10 -}; - -var arr = iterator2array( randu( opts ) ); -// returns -``` - -By default, the function creates and fills a generic `array`. To fill an array-like `object`, provide an `out` argument. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var randu = require( '@stdlib/random/iter/randu' ); - -var out = new Float64Array( 10 ); - -var arr = iterator2array( randu(), out ); -// returns - -var bool = ( out === arr ); -// returns true -``` - -To invoke a function for each iterated value, provide a callback function. - -```javascript -var array2iterator = require( '@stdlib/array/to-iterator' ); - -function fcn( v ) { - return v * 10.0; -} - -var arr = iterator2array( array2iterator( [ 1, 2, 3, 4 ] ), fcn ); -// returns [ 10.0, 20.0, 30.0, 40.0 ] -``` - -The invoked function is provided two arguments: - -- **value**: iterated value. -- **index**: iterated value index. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var randu = require( '@stdlib/random/iter/randu' ); - -function fcn( v, i ) { - return v * (i+1); -} - -var arr = iterator2array( randu(), new Float64Array( 10 ), fcn ); -// returns -``` - -To set the callback function execution context, provide a `thisArg`. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var randu = require( '@stdlib/random/iter/randu' ); - -function fcn( v ) { - this.count += 1; - return v * 10.0; -} - -var ctx = { - 'count': 0 -}; - -var arr = iterator2array( randu(), new Float64Array( 10 ), fcn, ctx ); -// returns - -var count = ctx.count; -// returns 10 -``` - -
- - - - - -
- -## Notes - -- If provided an output array, the function fills the output array with iterated values. -- Iteration stops when an output array is full **or** an iterator finishes; whichever comes first. -- By providing an output typed array, one avoids the temporary memory allocation when using the built-in `TypedArray.from`. - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var randu = require( '@stdlib/random/iter/randu' ); -var iterator2array = require( '@stdlib/array/from-iterator' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/from-iterator/benchmark/benchmark.js b/from-iterator/benchmark/benchmark.js deleted file mode 100644 index 11198484f..000000000 --- a/from-iterator/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert/is-array' ); -var array2iterator = require( './../../to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/from-iterator/docs/repl.txt b/from-iterator/docs/repl.txt deleted file mode 100644 index 9b949e48b..000000000 --- a/from-iterator/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value. - - index: iterated value index (zero-based). - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/from-iterator/docs/types/index.d.ts b/from-iterator/docs/types/index.d.ts deleted file mode 100644 index 2dbd40371..000000000 --- a/from-iterator/docs/types/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator as IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random/iter/randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random/iter/randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var randu = require( '@stdlib/random/iter/randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var randu = require( '@stdlib/random/iter/randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/from-iterator/docs/types/test.ts b/from-iterator/docs/types/test.ts deleted file mode 100644 index 22a782fdc..000000000 --- a/from-iterator/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random/iter/randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/from-iterator/examples/index.js b/from-iterator/examples/index.js deleted file mode 100644 index b2ec31eec..000000000 --- a/from-iterator/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( './../../float64' ); -var randu = require( '@stdlib/random/iter/randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/from-iterator/lib/index.js b/from-iterator/lib/index.js deleted file mode 100644 index 7be53da82..000000000 --- a/from-iterator/lib/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array/from-iterator -* -* @example -* var randu = require( '@stdlib/random/iter/randu' ); -* var iterator2array = require( '@stdlib/array/from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/from-iterator/lib/main.js b/from-iterator/lib/main.js deleted file mode 100644 index 9444320e4..000000000 --- a/from-iterator/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert/is-function' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var isAccessorArray = require( './../../base/assert/is-accessor-array' ); -var accessorSetter = require( './../../base/accessor-setter' ); -var setter = require( './../../base/setter' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random/iter/randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/from-iterator/package.json b/from-iterator/package.json deleted file mode 100644 index a9e3e9703..000000000 --- a/from-iterator/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/array/from-iterator", - "version": "0.0.0", - "description": "Create (or fill) an array from an iterator.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "arr", - "typed-array", - "typed array", - "iterator", - "iterate", - "iteration", - "iter", - "to", - "convert", - "fill", - "map" - ] -} diff --git a/from-iterator/test/test.js b/from-iterator/test/test.js deleted file mode 100644 index 61388dfa0..000000000 --- a/from-iterator/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 noop = require( '@stdlib/utils/noop' ); -var randu = require( '@stdlib/random/iter/randu' ); -var Float64Array = require( './../../float64' ); -var Complex64Array = require( './../../complex64' ); -var array2iterator = require( './../../to-iterator' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/from-scalar/README.md b/from-scalar/README.md deleted file mode 100644 index c2aff7236..000000000 --- a/from-scalar/README.md +++ /dev/null @@ -1,151 +0,0 @@ - - -# scalar2array - -> Create a single-element array containing a provided scalar value. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var scalar2array = require( '@stdlib/array/from-scalar' ); -``` - -#### scalar2array( value\[, dtype] ) - -Returns a single-element array containing a provided scalar value. - -```javascript -var x = scalar2array( 3.0 ); -// returns [ 3.0 ] -``` - -If not provided a `dtype` argument and `value` - -- is a number, the default [data type][@stdlib/array/dtypes] is the [default][@stdlib/array/defaults] real-valued floating-point data type. -- is a boolean, the default [data type][@stdlib/array/dtypes] is the [default][@stdlib/array/defaults] boolean data type. -- is a complex number object of a known data type, the data type is the same as the provided value. -- is a complex number object of an unknown data type, the default [data type][@stdlib/array/dtypes] is the [default][@stdlib/array/defaults] complex-valued floating-point data type. -- is any other value type, the default [data type][@stdlib/array/dtypes] is `'generic'`. - -To explicitly specify the [data type][@stdlib/array/dtypes] of the returned array, provide a `dtype` argument. - -```javascript -var x = scalar2array( 3.0, 'float32' ); -// returns [ 3.0 ] -``` - -
- - - - - -
- -## Notes - -- If `value` is a number and the `dtype` argument is a complex [data type][@stdlib/array/dtypes], the function returns a complex number array containing a complex number whose real component equals the provided scalar `value` and whose imaginary component is zero. -- The function does **not** guard against precision loss when `value` is a number and the `dtype` argument is an integer [data type][@stdlib/array/dtypes]. - -
- - - - - -
- -## Examples - - - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var array2scalar = require( '@stdlib/array/from-scalar' ); - -var x = array2scalar( 3.0 ); -// returns [ 3.0 ] - -x = array2scalar( 3, 'int32' ); -// returns [ 3 ] - -x = array2scalar( new Complex128( 3.0, 4.0 ) ); -// returns - -x = array2scalar( {} ); -// returns [ {} ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/from-scalar/benchmark/benchmark.js b/from-scalar/benchmark/benchmark.js deleted file mode 100644 index 924637416..000000000 --- a/from-scalar/benchmark/benchmark.js +++ /dev/null @@ -1,595 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var complex = require( '@stdlib/complex/cmplx' ); -var pkg = require( './../package.json' ).name; -var scalar2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::default,number', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ] ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::default,non-numeric', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - true, - false, - null, - {} - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ] ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::default,complex128', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - complex( 3.0, 4.0, 'float64' ), - complex( 1.0, 2.0, 'float64' ), - complex( 0.0, 0.0, 'float64' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ] ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::default,complex64', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - complex( 3.0, 4.0, 'float32' ), - complex( 1.0, 2.0, 'float32' ), - complex( 0.0, 0.0, 'float32' ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ] ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::default,complex-like', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - { - 're': 3.0, - 'im': 4.0 - }, - { - 're': 1.0, - 'im': 2.0 - }, - { - 're': 0.0, - 'im': 0.0 - } - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ] ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::default,bool', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - true, - false - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ] ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - console.log( v ); - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'float64' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'float32' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'int32' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'int16' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'int8' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'uint32' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'uint16' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'uint8' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'uint8c' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - true, - false - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'bool' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=complex128', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'complex128' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=complex64', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3 - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'complex64' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:dtype=complex128', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - complex( 3.0, 4.0, 'float64' ), - complex( 1.0, 2.0, 'float32' ), - { - 're': 0.0, - 'im': 0.0 - } - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'complex128' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:dtype=complex64', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - complex( 3.0, 4.0, 'float64' ), - complex( 1.0, 2.0, 'float32' ), - { - 're': 0.0, - 'im': 0.0 - } - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'complex64' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - 1, - 2, - 3, - true, - false, - [], - {} - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = scalar2array( values[ i%values.length ], 'generic' ); - if ( v.length !== 1 ) { - b.fail( 'should return a single-element array' ); - } - } - b.toc(); - if ( !isCollection ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/from-scalar/docs/repl.txt b/from-scalar/docs/repl.txt deleted file mode 100644 index 0a66ea6b1..000000000 --- a/from-scalar/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( value[, dtype] ) - Returns a single-element array containing a provided scalar value. - - If `value` is a number and `dtype` is a complex number data type, the - function returns a complex number array containing a complex number whose - real component equals the provided scalar value and whose imaginary - component is zero. - - Parameters - ---------- - value: any - Scalar value. - - dtype: string (optional) - Data type. If not provided and `value` - - - is a number, the default data type is the default real-valued - floating-point data type. - - is a boolean, the default data type is the default boolean data type. - - is a complex number object of a known complex data type, the data type - is the same as the provided value. - - is a complex number object of an unknown data type, the default data - type is the default complex-valued floating-point data type. - - is any other value type, the default data type is 'generic'. - - Returns - ------- - out: Array|TypedArray - Output array. - - Examples - -------- - > var x = {{alias}}( 1.0 ) - [ 1.0 ] - - See Also - -------- - diff --git a/from-scalar/docs/types/index.d.ts b/from-scalar/docs/types/index.d.ts deleted file mode 100644 index 88bddf9b9..000000000 --- a/from-scalar/docs/types/index.d.ts +++ /dev/null @@ -1,293 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ComplexLike, Complex64, Complex128 } from '@stdlib/types/complex'; -import { DataType, Complex128Array, Complex64Array, BooleanArray } from '@stdlib/types/array'; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( 1.0, 'float64' ); -* // returns [ 1.0 ] -*/ -declare function scalar2array( value: number, dtype: 'float64' ): Float64Array; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( 1.0, 'float32' ); -* // returns [ 1.0 ] -*/ -declare function scalar2array( value: number, dtype: 'float32' ): Float32Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( true, 'bool' ); -* // returns -*/ -declare function scalar2array( value: any, dtype: 'bool' ): BooleanArray; - -/** -* Returns a single-element array containing a provided scalar value. -* -* ## Notes -* -* - If provided a number, the function returns a complex number array containing a complex number whose real component equals the provided scalar value and whose imaginary component is zero. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var v = new Complex128( 1.0, 2.0 ); -* -* var x = scalar2array( v, 'complex128' ); -* // returns [ 1.0, 2.0 ] -*/ -declare function scalar2array( value: number | ComplexLike, dtype: 'complex128' ): Complex128Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* ## Notes -* -* - If provided a number, the function returns a complex number array containing a complex number whose real component equals the provided scalar value and whose imaginary component is zero. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var Complex64 = require( '@stdlib/complex/float64/ctor' ); -* -* var v = new Complex64( 1.0, 2.0 ); -* -* var x = scalar2array( v, 'complex64' ); -* // returns [ 1.0, 2.0 ] -*/ -declare function scalar2array( value: number | ComplexLike, dtype: 'complex64' ): Complex64Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( 1, int32 }; -* // returns [ 1 ] -*/ -declare function scalar2array( value: number, dtype: 'int32' ): Int32Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( 1, int16 }; -* // returns [ 1 ] -*/ -declare function scalar2array( value: number, dtype: 'int16' ): Int16Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( 1, 'int8' } -* // returns [ 1 ] -*/ -declare function scalar2array( value: number, dtype: 'int8' ): Int8Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( 1, 'uint32' ); -* // returns [ 1 ] -*/ -declare function scalar2array( value: number, dtype: 'uint32' ): Uint32Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( 1, 'uint16' ); -* // returns [ 1 ] -*/ -declare function scalar2array( value: number, dtype: 'uint16' ): Uint16Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( 1, uint8 }; -* // returns [ 1 ] -*/ -declare function scalar2array( value: number, dtype: 'uint8' ): Uint8Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( 1, uint8c' ); -* // returns [] -*/ -declare function scalar2array( value: number, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( 1.0, 'generic' ); -* // returns [ 1.0 ] -*/ -declare function scalar2array( value: T, dtype: 'generic' ): Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @returns output array -* -* @example -* var x = scalar2array( 1.0 ); -* // returns [ 1.0 ] -*/ -declare function scalar2array( value: number ): Float64Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @returns output array -* -* @example -* var x = scalar2array( true ); -* // returns -*/ -declare function scalar2array( value: boolean ): BooleanArray; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @returns output array -* -* @example -* var Complex64 = require( '@stdlib/complex/float32/ctor' ); -* -* var z = new Complex64( 3.0, 4.0 ); -* -* var x = scalar2array( z ); -* // returns [ 3.0, 4.0 ] -*/ -declare function scalar2array( value: Complex64 ): Complex64Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* @param value - scalar value -* @returns output array -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var z = new Complex128( 3.0, 4.0 ); -* -* var x = scalar2array( z ); -* // returns [ 3.0, 4.0 ] -*/ -declare function scalar2array( value: Complex128 | ComplexLike ): Complex128Array; - -/** -* Returns a single-element array containing a provided scalar value. -* -* ## Notes -* -* - If a `dtype` argument is not provided and `value` -* -* - is a number, the default data type is the default real-valued floating-point data type. -* - is a boolean, the default data type is the default boolean data type. -* - is a complex number object of a known complex data type, the data type is the same as the provided value. -* - is a complex number object of an unknown complex data type, the default data type is the default complex-valued floating-point data type. -* - is any other value type, the default data type is `'generic'`. -* -* @param value - scalar value -* @param dtype - output array data type -* @returns output array -* -* @example -* var x = scalar2array( 1.0, 'generic' ); -* // returns [ 1.0 ] -*/ -declare function scalar2array( value: T, dtype?: DataType ): Array; - - -// EXPORTS // - -export = scalar2array; diff --git a/from-scalar/docs/types/test.ts b/from-scalar/docs/types/test.ts deleted file mode 100644 index 700493ab6..000000000 --- a/from-scalar/docs/types/test.ts +++ /dev/null @@ -1,66 +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. -*/ - -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import Complex64 = require( '@stdlib/complex/float32/ctor' ); -import array2scalar = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - array2scalar( 1.0 ); // $ExpectType Float64Array - array2scalar( new Complex128( 3.0, 4.0 ) ); // $ExpectType Complex128Array - array2scalar( new Complex64( 3.0, 4.0 ) ); // $ExpectType Complex64Array - array2scalar( { 're': 3.0, 'im': 4.0 } ); // $ExpectType Complex128Array - array2scalar( true ); // $ExpectType BooleanArray - array2scalar( null ); // $ExpectType null[] - - array2scalar( 1.0, 'float64' ); // $ExpectType Float64Array - array2scalar( 1.0, 'float32' ); // $ExpectType Float32Array - array2scalar( 1.0, 'complex128' ); // $ExpectType Complex128Array - array2scalar( 1.0, 'complex64' ); // $ExpectType Complex64Array - array2scalar( true, 'bool' ); // $ExpectType BooleanArray - array2scalar( 1.0, 'int32' ); // $ExpectType Int32Array - array2scalar( 1.0, 'int16' ); // $ExpectType Int16Array - array2scalar( 1.0, 'int8' ); // $ExpectType Int8Array - array2scalar( 1.0, 'uint32' ); // $ExpectType Uint32Array - array2scalar( 1.0, 'uint16' ); // $ExpectType Uint16Array - array2scalar( 1.0, 'uint8' ); // $ExpectType Uint8Array - array2scalar( 1.0, 'uint8c' ); // $ExpectType Uint8ClampedArray - array2scalar( 1.0, 'generic' ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided a second argument which is not a recognized/supported data type... -{ - array2scalar( 1.0, '10' ); // $ExpectError - array2scalar( 1.0, 5 ); // $ExpectError - array2scalar( 1.0, false ); // $ExpectError - array2scalar( 1.0, true ); // $ExpectError - array2scalar( 1.0, null ); // $ExpectError - array2scalar( 1.0, [] ); // $ExpectError - array2scalar( 1.0, {} ); // $ExpectError - array2scalar( 1.0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - array2scalar(); // $ExpectError - array2scalar( 1.0, 'float64', 1 ); // $ExpectError -} diff --git a/from-scalar/examples/index.js b/from-scalar/examples/index.js deleted file mode 100644 index 93904a341..000000000 --- a/from-scalar/examples/index.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var array2scalar = require( './../lib' ); - -var x = array2scalar( 3.0 ); -console.log( x ); -// => [ 3.0 ] - -x = array2scalar( 3, 'int32' ); -console.log( x ); -// => [ 3 ] - -x = array2scalar( new Complex128( 3.0, 4.0 ) ); -console.log( x ); -// => - -x = array2scalar( {} ); -console.log( x ); -// => [ {} ] diff --git a/from-scalar/lib/index.js b/from-scalar/lib/index.js deleted file mode 100644 index e8133bc1c..000000000 --- a/from-scalar/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Create a single-element array containing a provided scalar value. -* -* @module @stdlib/array/from-scalar -* -* @example -* var array2scalar = require( '@stdlib/array/from-scalar' ); -* -* var x = scalar2array( 1.0 ); -* // returns [ 1.0 ] -* -* @example -* var array2scalar = require( '@stdlib/array/from-scalar' ); -* -* var x = scalar2array( 1.0, 'float32' ); -* // returns [ 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/from-scalar/lib/main.js b/from-scalar/lib/main.js deleted file mode 100644 index 2f7dd8b52..000000000 --- a/from-scalar/lib/main.js +++ /dev/null @@ -1,112 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../base/assert/is-complex-floating-point-data-type' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isAccessorArray = require( './../../base/assert/is-accessor-array' ); -var accessorSetter = require( './../../base/accessor-setter' ); -var setter = require( './../../base/setter' ); -var zeros = require( './../../zeros' ); -var dtype = require( '@stdlib/complex/dtype' ); -var defaults = require( './../../defaults' ); - - -// VARIABLES // - -var DEFAULT_REAL = defaults.get( 'dtypes.real_floating_point' ); -var DEFAULT_CMPLX = defaults.get( 'dtypes.complex_floating_point' ); -var DEFAULT_BOOL = defaults.get( 'dtypes.boolean' ); - - -// MAIN // - -/** -* Returns a single-element array containing a provided scalar value. -* -* ## Notes -* -* - If a `dtype` option is not provided and `value` -* -* - is a number, the default data type is the default real-valued floating-point data type. -* - is a boolean, the default data type is the default boolean data type. -* - is a complex number object of a known complex data type, the data type is the same as the provided value. -* - is a complex number object of an unknown complex data type, the default data type is the default complex-valued floating-point data type. -* - is any other value type, the default data type is `'generic'`. -* -* @param {*} value - scalar value -* @param {string} dtype - output array data type -* @throws {TypeError} second argument must be a recognized data type -* @returns {Collection} output array -* -* @example -* var x = scalar2array( 1.0 ); -* // returns [ 1.0 ] -* -* @example -* var x = scalar2array( 1.0, 'float32' ); -* // returns [ 1.0 ] -*/ -function scalar2array( value ) { - var flg; - var out; - var set; - var dt; - var v; - - flg = isNumber( value ); - if ( arguments.length < 2 ) { - if ( flg ) { - dt = DEFAULT_REAL; - } else if ( isBoolean( value ) ) { - dt = DEFAULT_BOOL; - } else if ( isComplexLike( value ) ) { - dt = dtype( value ); - if ( dt === null ) { - dt = DEFAULT_CMPLX; - } - } else { - dt = 'generic'; - } - } else { - dt = arguments[ 1 ]; - } - out = zeros( 1, dt ); // delegate dtype validation to `zeros` - if ( flg && isComplexDataType( dt ) ) { - v = [ value, 0.0 ]; // note: we're assuming that the ComplexXXArray setter accepts an array of interleaved real and imaginary components - } else { - v = value; - } - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - set( out, 0, v ); - return out; -} - - -// EXPORTS // - -module.exports = scalar2array; diff --git a/from-scalar/package.json b/from-scalar/package.json deleted file mode 100644 index f95da0add..000000000 --- a/from-scalar/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/from-scalar", - "version": "0.0.0", - "description": "Create a single-element array containing a provided scalar value.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "arr", - "typed-array", - "typed array", - "scalar", - "to", - "convert", - "cast", - "fill", - "wrap" - ] -} diff --git a/from-scalar/test/test.js b/from-scalar/test/test.js deleted file mode 100644 index 39bebb143..000000000 --- a/from-scalar/test/test.js +++ /dev/null @@ -1,292 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var BooleanArray = require( './../../bool' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var isEqualBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); -var isSameFloat32Array = require( '@stdlib/assert/is-same-float32array' ); -var isSameArray = require( '@stdlib/assert/is-same-array' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var array2scalar = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2scalar, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unsupported data type', function test( t ) { - var values; - var i; - - values = [ - 'foo', - 'bar', - 'beep', - 'boop' - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - array2scalar( 3, value ); - }; - } -}); - -tape( 'the function returns a single element containing a provided scalar value (default, number)', function test( t ) { - var expected; - var actual; - - actual = array2scalar( 3.0 ); - expected = new Float64Array( [ 3.0 ] ); - - t.strictEqual( isSameFloat64Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (default, bool)', function test( t ) { - var expected; - var actual; - - actual = array2scalar( true ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (default, complex128)', function test( t ) { - var expected; - var actual; - - actual = array2scalar( new Complex128( 3.0, 4.0 ) ); - expected = new Complex128Array( [ 3.0, 4.0 ] ); - - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (default, complex64)', function test( t ) { - var expected; - var actual; - - actual = array2scalar( new Complex64( 3.0, 4.0 ) ); - expected = new Complex64Array( [ 3.0, 4.0 ] ); - - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (default, complex-like)', function test( t ) { - var expected; - var actual; - - actual = array2scalar({ - 're': 3.0, - 'im': 4.0 - }); - expected = new Complex128Array( [ 3.0, 4.0 ] ); - - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (default, object)', function test( t ) { - var expected; - var actual; - var o; - - o = {}; - actual = array2scalar( o ); - expected = [ o ]; - - t.strictEqual( isSameArray( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (dtype=float64)', function test( t ) { - var expected; - var actual; - - actual = array2scalar( 3.0, 'float64' ); - expected = new Float64Array( [ 3.0 ] ); - - t.strictEqual( isSameFloat64Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (dtype=float32)', function test( t ) { - var expected; - var actual; - - actual = array2scalar( 3.0, 'float32' ); - expected = new Float32Array( [ 3.0 ] ); - - t.strictEqual( isSameFloat32Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (dtype=int32)', function test( t ) { - var expected; - var actual; - - actual = array2scalar( 3, 'int32' ); - expected = new Int32Array( [ 3 ] ); - - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (dtype=generic)', function test( t ) { - var expected; - var actual; - - actual = array2scalar( 3.0, 'generic' ); - expected = [ 3.0 ]; - - t.strictEqual( isSameArray( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (dtype=bool)', function test( t ) { - var expected; - var actual; - - actual = array2scalar( false, 'bool' ); - expected = new BooleanArray( [ false ] ); - - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - - actual = array2scalar( true, 'bool' ); - expected = new BooleanArray( [ true ] ); - - t.strictEqual( isEqualBooleanArray( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (dtype=complex128, complex)', function test( t ) { - var expected; - var actual; - var z; - - actual = array2scalar( new Complex128( 3.0, 4.0 ), 'complex128' ); - expected = new Complex128Array( [ 3.0, 4.0 ] ); - - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - actual = array2scalar( new Complex64( 3.0, 4.0 ), 'complex128' ); - expected = new Complex128Array( [ 3.0, 4.0 ] ); - - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - z = { - 're': 3.0, - 'im': 4.0 - }; - actual = array2scalar( z, 'complex128' ); - expected = new Complex128Array( [ 3.0, 4.0 ] ); - - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (dtype=complex64, complex)', function test( t ) { - var expected; - var actual; - var z; - - actual = array2scalar( new Complex64( 3.0, 4.0 ), 'complex64' ); - expected = new Complex64Array( [ 3.0, 4.0 ] ); - - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - actual = array2scalar( new Complex128( 3.0, 4.0 ), 'complex64' ); - expected = new Complex64Array( [ 3.0, 4.0 ] ); - - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - z = { - 're': 3.0, - 'im': 4.0 - }; - actual = array2scalar( z, 'complex64' ); - expected = new Complex64Array( [ 3.0, 4.0 ] ); - - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (dtype=generic, complex-like)', function test( t ) { - var expected; - var actual; - var z; - - z = { - 're': 3.0, - 'im': 4.0 - }; - actual = array2scalar( z, 'generic' ); - expected = [ z ]; - - t.strictEqual( isSameArray( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (dtype=complex128, real)', function test( t ) { - var expected; - var actual; - - actual = array2scalar( 3.0, 'complex128' ); - expected = new Complex128Array( [ 3.0, 0.0 ] ); - - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a single element containing a provided scalar value (dtype=complex64, real)', function test( t ) { - var expected; - var actual; - - actual = array2scalar( 3.0, 'complex64' ); - expected = new Complex64Array( [ 3.0, 0.0 ] ); - - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); diff --git a/full-like/README.md b/full-like/README.md deleted file mode 100644 index 784f9e2aa..000000000 --- a/full-like/README.md +++ /dev/null @@ -1,153 +0,0 @@ - - -# fullLike - -> Create a filled array having the same length and data type as a provided array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var fullLike = require( '@stdlib/array/full-like' ); -``` - -#### fullLike( x, value\[, dtype] ) - -Creates a filled array having the same length and [data type][@stdlib/array/dtypes] as a provided array `x`. - -```javascript -var x = [ 1, 2, 3, 4, 5 ]; - -var arr = fullLike( x, 1 ); -// returns [ 1, 1, 1, 1, 1 ] -``` - -By default, the output array [data type][@stdlib/array/dtypes] is inferred from the provided array `x`. To return an array having a different [data type][@stdlib/array/dtypes], provide a `dtype` argument. - -```javascript -var x = [ 1, 1 ]; - -var arr = fullLike( x, 1, 'int32' ); -// returns [ 1, 1 ] -``` - -
- - - - - -
- -## Notes - -- If provided a number and the output array [data type][@stdlib/array/dtypes] is a complex number [data type][@stdlib/array/dtypes], the function returns a complex number array where each element has a real component whose value equals the provided fill value and where each element has an imaginary component equal to `0`. - -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var zeros = require( '@stdlib/array/zeros' ); -var fullLike = require( '@stdlib/array/full-like' ); - -// Create a zero-filled array: -var x = zeros( 4, 'complex128' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - y = fullLike( x, 1.0, dt[ i ] ); - console.log( y ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/full-like/benchmark/benchmark.js b/full-like/benchmark/benchmark.js deleted file mode 100644 index 2a40368e7..000000000 --- a/full-like/benchmark/benchmark.js +++ /dev/null @@ -1,345 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'bool' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, true ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var z; - var x; - var i; - - x = zeros( 0, 'complex128' ); - z = new Complex128( 1.0, 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, z ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var z; - var x; - var i; - - x = zeros( 0, 'complex64' ); - z = new Complex64( 1.0, 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, z ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8c' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'generic' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/full-like/benchmark/benchmark.length.bool.js b/full-like/benchmark/benchmark.length.bool.js deleted file mode 100644 index 5b698d6cd..000000000 --- a/full-like/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'bool' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, true ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.complex128.js b/full-like/benchmark/benchmark.length.complex128.js deleted file mode 100644 index e2e61f7c6..000000000 --- a/full-like/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex128' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var z; - var i; - - z = new Complex128( 1.0, 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, z ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.complex64.js b/full-like/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 392cae3e1..000000000 --- a/full-like/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var z; - var i; - - z = new Complex64( 1.0, 0.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, z ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.float32.js b/full-like/benchmark/benchmark.length.float32.js deleted file mode 100644 index c93ea858e..000000000 --- a/full-like/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.float64.js b/full-like/benchmark/benchmark.length.float64.js deleted file mode 100644 index bb1799cf1..000000000 --- a/full-like/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.generic.js b/full-like/benchmark/benchmark.length.generic.js deleted file mode 100644 index 3a487e91b..000000000 --- a/full-like/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.int16.js b/full-like/benchmark/benchmark.length.int16.js deleted file mode 100644 index 7eb7e6fe5..000000000 --- a/full-like/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.int32.js b/full-like/benchmark/benchmark.length.int32.js deleted file mode 100644 index be89bd6af..000000000 --- a/full-like/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.int8.js b/full-like/benchmark/benchmark.length.int8.js deleted file mode 100644 index 7f968939d..000000000 --- a/full-like/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.uint16.js b/full-like/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 269f92bae..000000000 --- a/full-like/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.uint32.js b/full-like/benchmark/benchmark.length.uint32.js deleted file mode 100644 index cf63937bf..000000000 --- a/full-like/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.uint8.js b/full-like/benchmark/benchmark.length.uint8.js deleted file mode 100644 index dc81dff8c..000000000 --- a/full-like/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/full-like/benchmark/benchmark.length.uint8c.js b/full-like/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 4e2d7b757..000000000 --- a/full-like/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var fullLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8c' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fullLike( x, 1.0 ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/full-like/docs/repl.txt b/full-like/docs/repl.txt deleted file mode 100644 index d7d82ad6a..000000000 --- a/full-like/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x[, dtype] ) - Returns a filled array having the same length and data type as a provided - input array. - - Parameters - ---------- - x: TypedArray|Array - Input array. - - dtype: string (optional) - Data type. If not provided, the output array data type is inferred from - the input array. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var x = new {{alias:@stdlib/array/float64}}( 2 ); - > var y = {{alias}}( x, 1.0 ) - [ 1.0, 1.0 ] - > y = {{alias}}( x, 1.0, 'float32' ) - [ 1.0, 1.0 ] - - See Also - -------- - diff --git a/full-like/docs/types/index.d.ts b/full-like/docs/types/index.d.ts deleted file mode 100644 index 54abf1fd4..000000000 --- a/full-like/docs/types/index.d.ts +++ /dev/null @@ -1,567 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Complex128Array, Complex64Array, BooleanArray, AnyArray, DataType } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; - -/** -* Creates a filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1.0, 'float64' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function fullLike( x: AnyArray, value: number, dtype: 'float64' ): Float64Array; - -/** -* Creates a filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1.0, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function fullLike( x: AnyArray, value: number, dtype: 'float32' ): Float32Array; - -/** -* Creates a filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint8' ); -* // returns [ 0, 0 ] -* -* var y = fullLike( x, true, 'bool' ); -* // returns [ true, true ] -*/ -declare function fullLike( x: AnyArray, value: boolean, dtype: 'bool' ): BooleanArray; - -/** -* Creates a filled array having the same length as a provided input array. -* -* ## Notes -* -* - If provided a number, the function returns a complex number array where each element has a real component whose value equals the provided fill value and where each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1.0, 'complex128' ); -* // returns -*/ -declare function fullLike( x: AnyArray, value: number | ComplexLike, dtype: 'complex128' ): Complex128Array; - -/** -* Creates a filled array having the same length as a provided input array. -* -* ## Notes -* -* - If provided a number, the function returns a complex number array where each element has a real component whose value equals the provided fill value and where each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1.0, 'complex64' ); -* // returns -*/ -declare function fullLike( x: AnyArray, value: number | ComplexLike, dtype: 'complex64' ): Complex64Array; - -/** -* Creates a filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1, 'int32' ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: AnyArray, value: number, dtype: 'int32' ): Int32Array; - -/** -* Creates a filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1, 'int16' ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: AnyArray, value: number, dtype: 'int16' ): Int16Array; - -/** -* Creates a filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1, 'int8' ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: AnyArray, value: number, dtype: 'int8' ): Int8Array; - -/** -* Creates a filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0, 0 ] -* -* var y = fullLike( x, 1, 'uint32' ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: AnyArray, value: number, dtype: 'uint32' ): Uint32Array; - -/** -* Creates a filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1, 'uint16' ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: AnyArray, value: number, dtype: 'uint16' ): Uint16Array; - -/** -* Creates a filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1, 'uint8' ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: AnyArray, value: number, dtype: 'uint8' ): Uint8Array; - -/** -* Creates a filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1, 'uint8c' ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: AnyArray, value: number, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Creates a filled array having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1.0, 'generic' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function fullLike( x: AnyArray, value: any, dtype: 'generic' ): Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1.0 ); -* // returns [ 1.0, 1.0 ] -*/ -declare function fullLike( x: Float64Array, value: number, dtype?: DataType ): Float64Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1.0 ); -* // returns [ 1.0, 1.0 ] -*/ -declare function fullLike( x: Float32Array, value: number, dtype?: DataType ): Float32Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'bool' ); -* // returns [ false, false ] -* -* var y = fullLike( x, true ); -* // returns [ true, true ] -*/ -declare function fullLike( x: BooleanArray, value: boolean, dtype?: DataType ): BooleanArray; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* ## Notes -* -* - If provided a number, the function returns a complex number array where each element has a real component whose value equals the provided fill value and where each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex128' ); -* // returns -* -* var y = fullLike( x, 1.0 ); -* // returns -*/ -declare function fullLike( x: Complex128Array, value: number | ComplexLike, dtype?: DataType ): Complex128Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* ## Notes -* -* - If provided a number, the function returns a complex number array where each element has a real component whose value equals the provided fill value and where each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex64' ); -* // returns -* -* var y = fullLike( x, 1.0 ); -* // returns -*/ -declare function fullLike( x: Complex64Array, value: number | ComplexLike, dtype?: DataType ): Complex64Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int32' ); -* // returns [ 0, 0 ] -* -* var y = fullLike( x, 1 ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: Int32Array, value: number, dtype?: DataType ): Int32Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int16' ); -* // returns [ 0, 0 ] -* -* var y = fullLike( x, 1 ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: Int16Array, value: number, dtype?: DataType ): Int16Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int8' ); -* // returns [ 0, 0 ] -* -* var y = fullLike( x, 1 ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: Int8Array, value: number, dtype?: DataType ): Int8Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint32' ); -* // returns [ 0, 0 ] -* -* var y = fullLike( x, 1 ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: Uint32Array, value: number, dtype?: DataType ): Uint32Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint16' ); -* // returns [ 0, 0 ] -* -* var y = fullLike( x, 1 ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: Uint16Array, value: number, dtype?: DataType ): Uint16Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint8' ); -* // returns [ 0, 0 ] -* -* var y = fullLike( x, 1 ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: Uint8Array, value: number, dtype?: DataType ): Uint8Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint8c' ); -* // returns [ 0, 0 ] -* -* var y = fullLike( x, 1 ); -* // returns [ 1, 1 ] -*/ -declare function fullLike( x: Uint8ClampedArray, value: number, dtype?: DataType ): Uint8ClampedArray; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'generic' ); -* // returns [ 0, 0 ] -* -* var y = fullLike( x, 1.0 ); -* // returns [ 1.0, 1.0 ] -*/ -declare function fullLike( x: Array, value: any, dtype?: DataType ): Array; - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param value - fill value -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1.0 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = fullLike( x, 1.0, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function fullLike( x: AnyArray, value: any, dtype?: DataType ): AnyArray; - - -// EXPORTS // - -export = fullLike; diff --git a/full-like/docs/types/test.ts b/full-like/docs/types/test.ts deleted file mode 100644 index 6c94a7164..000000000 --- a/full-like/docs/types/test.ts +++ /dev/null @@ -1,100 +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. -*/ - -import BooleanArray = require( './../../../bool' ); -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import Complex64 = require( '@stdlib/complex/float32/ctor' ); -import fullLike = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - fullLike( [ 0, 0 ], 1 ); // $ExpectType any[] - fullLike( new Float64Array( [ 0, 0 ] ), 1 ); // $ExpectType Float64Array - fullLike( new Float32Array( [ 0, 0 ] ), 1 ); // $ExpectType Float32Array - fullLike( new Complex128Array( [ 0, 0 ] ), 1 ); // $ExpectType Complex128Array - fullLike( new Complex128Array( [ 0, 0 ] ), new Complex128( 1.0, 1.0 ) ); // $ExpectType Complex128Array - fullLike( new Complex64Array( [ 0, 0 ] ), 1 ); // $ExpectType Complex64Array - fullLike( new Complex64Array( [ 0, 0 ] ), new Complex64( 1.0, 1.0 ) ); // $ExpectType Complex64Array - fullLike( new BooleanArray( [ 0, 0 ] ), true ); // $ExpectType BooleanArray - fullLike( new Int32Array( [ 0, 0 ] ), 1 ); // $ExpectType Int32Array - fullLike( new Int16Array( [ 0, 0 ] ), 1 ); // $ExpectType Int16Array - fullLike( new Int8Array( [ 0, 0 ] ), 1 ); // $ExpectType Int8Array - fullLike( new Uint32Array( [ 0, 0 ] ), 1 ); // $ExpectType Uint32Array - fullLike( new Uint16Array( [ 0, 0 ] ), 1 ); // $ExpectType Uint16Array - fullLike( new Uint8Array( [ 0, 0 ] ), 1 ); // $ExpectType Uint8Array - fullLike( new Uint8ClampedArray( [ 0, 0 ] ), 1 ); // $ExpectType Uint8ClampedArray - - fullLike( [ 0, 0 ], 1, 'float64' ); // $ExpectType Float64Array - fullLike( [ 0, 0 ], 1, 'float32' ); // $ExpectType Float32Array - fullLike( [ 0, 0 ], 1, 'complex128' ); // $ExpectType Complex128Array - fullLike( [ 0, 0 ], new Complex128( 1.0, 1.0 ), 'complex128' ); // $ExpectType Complex128Array - fullLike( [ 0, 0 ], 1, 'complex64' ); // $ExpectType Complex64Array - fullLike( [ 0, 0 ], new Complex64( 1.0, 1.0 ), 'complex64' ); // $ExpectType Complex64Array - fullLike( [ 0, 0 ], true, 'bool' ); // $ExpectType BooleanArray - fullLike( [ 0, 0 ], 1, 'int32' ); // $ExpectType Int32Array - fullLike( [ 0, 0 ], 1, 'int16' ); // $ExpectType Int16Array - fullLike( [ 0, 0 ], 1, 'int8' ); // $ExpectType Int8Array - fullLike( [ 0, 0 ], 1, 'uint32' ); // $ExpectType Uint32Array - fullLike( [ 0, 0 ], 1, 'uint16' ); // $ExpectType Uint16Array - fullLike( [ 0, 0 ], 1, 'uint8' ); // $ExpectType Uint8Array - fullLike( [ 0, 0 ], 1, 'uint8c' ); // $ExpectType Uint8ClampedArray - fullLike( [ 0, 0 ], 1, 'generic' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is not provided an array or typed array for the first argument... -{ - fullLike( '5', 1 ); // $ExpectError - fullLike( 5, 1 ); // $ExpectError - fullLike( false, 1 ); // $ExpectError - fullLike( true, 1 ); // $ExpectError - fullLike( null, 1 ); // $ExpectError - fullLike( undefined, 1 ); // $ExpectError - fullLike( {}, 1 ); // $ExpectError - fullLike( ( x: number ): number => x, 1 ); // $ExpectError - - fullLike( '5', 1, 'float32' ); // $ExpectError - fullLike( 5, 1, 'float32' ); // $ExpectError - fullLike( false, 1, 'float32' ); // $ExpectError - fullLike( true, 1, 'float32' ); // $ExpectError - fullLike( null, 1, 'float32' ); // $ExpectError - fullLike( undefined, 1, 'float32' ); // $ExpectError - fullLike( {}, 1, 'float32' ); // $ExpectError - fullLike( ( x: number ): number => x, 1, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is an unrecognized/unsupported data type... -{ - fullLike( [ 0, 0 ], 1, '10' ); // $ExpectError - fullLike( [ 0, 0 ], 1, 10 ); // $ExpectError - fullLike( [ 0, 0 ], 1, false ); // $ExpectError - fullLike( [ 0, 0 ], 1, true ); // $ExpectError - fullLike( [ 0, 0 ], 1, null ); // $ExpectError - fullLike( [ 0, 0 ], 1, [] ); // $ExpectError - fullLike( [ 0, 0 ], 1, {} ); // $ExpectError - fullLike( [ 0, 0 ], 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - fullLike( [ 0, 0 ], 1, 'float64', 1 ); // $ExpectError -} diff --git a/full-like/examples/index.js b/full-like/examples/index.js deleted file mode 100644 index 2787ea956..000000000 --- a/full-like/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../dtypes' ); -var zeros = require( './../../zeros' ); -var fullLike = require( './../lib' ); - -// Create a zero-filled array: -var x = zeros( 4, 'complex128' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - y = fullLike( x, 1.0, dt[ i ] ); - console.log( y ); -} diff --git a/full-like/lib/index.js b/full-like/lib/index.js deleted file mode 100644 index 75af5a1bd..000000000 --- a/full-like/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a filled array having the same length and data type as a provided input array. -* -* @module @stdlib/array/full-like -* -* @example -* var fullLike = require( '@stdlib/array/full-like' ); -* -* var arr = fullLike( [ 0.0, 0.0 ], 1.0 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var fullLike = require( '@stdlib/array/full-like' ); -* -* var arr = fullLike( [ 0.0, 0.0 ], 1.0, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/full-like/lib/main.js b/full-like/lib/main.js deleted file mode 100644 index 2860b8c1f..000000000 --- a/full-like/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/string/format' ); -var dtype = require( './../../dtype' ); -var full = require( './../../full' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); - - -// MAIN // - -/** -* Creates a filled array having the same length and data type as a provided input array. -* -* @param {(Array|TypedArray|ComplexArray)} x - input array -* @param {number} value - fill value -* @param {string} [dtype] - data type -* @throws {TypeError} first argument must be an array or typed array -* @throws {TypeError} third argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = fullLike( [ 0.0, 0.0 ], 1.0 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = fullLike( [ 0.0, 0.0 ], 1.0, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -function fullLike( x, value ) { - var dt; - var v; - - dt = dtype( x ); // delegate input argument validation to dtype resolution - if ( dt === null ) { - throw new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) ); - } - if ( arguments.length > 2 ) { - dt = arguments[ 2 ]; - } - if ( typeof value === 'number' ) { - if ( dt === 'complex128' ) { - v = new Complex128( value, 0.0 ); - } else if ( dt === 'complex64' ) { - v = new Complex64( value, 0.0 ); - } else { - v = value; - } - } else { - v = value; - } - return full( x.length, v, dt ); -} - - -// EXPORTS // - -module.exports = fullLike; diff --git a/full-like/package.json b/full-like/package.json deleted file mode 100644 index 9e007de77..000000000 --- a/full-like/package.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "name": "@stdlib/array/full-like", - "version": "0.0.0", - "description": "Create a filled array having the same length and data type as a provided array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "fill", - "filled" - ] -} diff --git a/full-like/test/test.js b/full-like/test/test.js deleted file mode 100644 index a1086afa9..000000000 --- a/full-like/test/test.js +++ /dev/null @@ -1,632 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var fullLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof fullLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - fullLike( value, 1.0 ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - fullLike( value, 1.0, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'fullLike', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - fullLike( [], 1.0, value ); - }; - } -}); - -tape( 'the function returns a filled array (float64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = fullLike( x, 1.0 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float32Array( 5 ); - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = fullLike( x, 1.0, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (float32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float32Array( 5 ); - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = fullLike( x, 1.0 ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = fullLike( x, 1.0, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (bool)', function test( t ) { - var expected; - var arr; - var x; - - x = new BooleanArray( 4 ); - expected = new Uint8Array( [ true, true, true, true ] ); - - arr = fullLike( x, true ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=bool)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float32Array( 4 ); - expected = new Uint8Array( [ true, true, true, true ] ); - - arr = fullLike( x, true, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (complex128; real)', function test( t ) { - var expected; - var arr; - var x; - - x = new Complex128Array( 2 ); - expected = new Float64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); - - arr = fullLike( x, 1.0 ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (complex128; complex)', function test( t ) { - var expected; - var arr; - var z; - var x; - - x = new Complex128Array( 2 ); - expected = new Float64Array( [ 1.0, 2.0, 1.0, 2.0 ] ); - - z = new Complex128( 1.0, 2.0 ); - arr = fullLike( x, z ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128; real)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 2 ); - expected = new Float64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); - - arr = fullLike( x, 1.0, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128; complex)', function test( t ) { - var expected; - var arr; - var x; - var z; - - x = new Float64Array( 2 ); - expected = new Float64Array( [ 1.0, 2.0, 1.0, 2.0 ] ); - - z = new Complex128( 1.0, 2.0 ); - arr = fullLike( x, z, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (complex64; real)', function test( t ) { - var expected; - var arr; - var x; - - x = new Complex64Array( 2 ); - expected = new Float32Array( [ 1.0, 0.0, 1.0, 0.0 ] ); - - arr = fullLike( x, 1.0 ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (complex64; complex)', function test( t ) { - var expected; - var arr; - var x; - var z; - - x = new Complex64Array( 2 ); - expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0 ] ); - - z = new Complex64( 1.0, 2.0 ); - arr = fullLike( x, z ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64; real)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 2 ); - expected = new Float32Array( [ 1.0, 0.0, 1.0, 0.0 ] ); - - arr = fullLike( x, 1.0, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64; complex)', function test( t ) { - var expected; - var arr; - var x; - var z; - - x = new Float64Array( 2 ); - expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0 ] ); - - z = new Complex64( 1.0, 2.0 ); - arr = fullLike( x, z, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (int32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int32Array( 5 ); - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1 ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint32Array( 5 ); - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1 ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (int16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int16Array( 5 ); - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1 ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint16Array( 5 ); - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1 ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (int8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int8Array( 5 ); - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1 ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint8Array( 5 ); - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1 ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint8c)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint8ClampedArray( 5 ); - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1 ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = fullLike( x, 1, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (generic)', function test( t ) { - var expected; - var arr; - var x; - - x = [ 1, 2, 3, 4, 5 ]; - expected = [ 1, 1, 1, 1, 1 ]; - - arr = fullLike( x, 1 ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = [ 1, 1, 1, 1, 1 ]; - - arr = fullLike( x, 1, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/full/README.md b/full/README.md deleted file mode 100644 index 1bdb52edb..000000000 --- a/full/README.md +++ /dev/null @@ -1,143 +0,0 @@ - - -# full - -> Create a filled array having a specified length. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var full = require( '@stdlib/array/full' ); -``` - -#### full( length, value\[, dtype] ) - -Creates a filled array having a specified length. - -```javascript -var arr = full( 2, 1.0 ); -// returns [ 1.0, 1.0 ] -``` - -By default, the output array [data type][@stdlib/array/dtypes] is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative [data type][@stdlib/array/dtypes], provide a `dtype` argument. - -```javascript -var arr = full( 2, 1, 'int32' ); -// returns [ 1, 1 ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/typed-real-dtypes' ); -var full = require( '@stdlib/array/full' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = full( 5, i+1, dt[ i ] ); - console.log( arr ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/full/benchmark/benchmark.js b/full/benchmark/benchmark.js deleted file mode 100644 index b3a86b994..000000000 --- a/full/benchmark/benchmark.js +++ /dev/null @@ -1,293 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, 1.0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, 1.0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, 1.0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, true, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var v; - var i; - - v = new Complex128( 1.0, 2.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, v, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var v; - var i; - - v = new Complex64( 1.0, 2.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, v, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, 1, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, 1, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, 1, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, 1, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, 1, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, 1, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, 1, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( 0, 1, 'generic' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/full/benchmark/benchmark.length.bool.js b/full/benchmark/benchmark.length.bool.js deleted file mode 100644 index 36c962c31..000000000 --- a/full/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, true, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.complex128.js b/full/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 517bb30b0..000000000 --- a/full/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var v; - var i; - - v = new Complex128( 1.0, 2.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, v, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.complex64.js b/full/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 3dd42fd9f..000000000 --- a/full/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var v; - var i; - - v = new Complex64( 1.0, 2.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, v, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.float32.js b/full/benchmark/benchmark.length.float32.js deleted file mode 100644 index 7a8b407ce..000000000 --- a/full/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, 1.0, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.float64.js b/full/benchmark/benchmark.length.float64.js deleted file mode 100644 index f812e9d9d..000000000 --- a/full/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, 1.0, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.generic.js b/full/benchmark/benchmark.length.generic.js deleted file mode 100644 index 84ffcb8b6..000000000 --- a/full/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, 1.0, 'generic' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.int16.js b/full/benchmark/benchmark.length.int16.js deleted file mode 100644 index 39d2f34a0..000000000 --- a/full/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, 1, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.int32.js b/full/benchmark/benchmark.length.int32.js deleted file mode 100644 index 9e101c04f..000000000 --- a/full/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, 1, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.int8.js b/full/benchmark/benchmark.length.int8.js deleted file mode 100644 index 3a2623a06..000000000 --- a/full/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, 1, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.uint16.js b/full/benchmark/benchmark.length.uint16.js deleted file mode 100644 index fa1decc6c..000000000 --- a/full/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, 1, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.uint32.js b/full/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 97209dfb4..000000000 --- a/full/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, 1, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.uint8.js b/full/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 3f7c4a8ee..000000000 --- a/full/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, 1, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/full/benchmark/benchmark.length.uint8c.js b/full/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 471656b4a..000000000 --- a/full/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var full = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = full( len, 1, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/full/docs/repl.txt b/full/docs/repl.txt deleted file mode 100644 index 90fedbf95..000000000 --- a/full/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( length, value[, dtype] ) - Returns a filled array having a specified length. - - Parameters - ---------- - length: integer - Array length. - - value: any - Fill value. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 2, 1.0 ) - [ 1.0, 1.0 ] - > arr = {{alias}}( 2, 1.0, 'float32' ) - [ 1.0, 1.0 ] - - See Also - -------- - diff --git a/full/docs/types/index.d.ts b/full/docs/types/index.d.ts deleted file mode 100644 index 148e796dd..000000000 --- a/full/docs/types/index.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { DataTypeMap } from '@stdlib/types/array'; - -/** -* Creates a filled array having a specified length. -* -* @param length - array length -* @param value - fill value -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = full( 2, 1.0 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = full( 2, 1.0, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function full = 'float64'>( length: number, value: T, dtype?: U ): DataTypeMap[U]; - - -// EXPORTS // - -export = full; diff --git a/full/docs/types/test.ts b/full/docs/types/test.ts deleted file mode 100644 index 118d4985e..000000000 --- a/full/docs/types/test.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 Complex128 = require( '@stdlib/complex/float64/ctor' ); -import full = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - const z = new Complex128( 1.0, 2.0 ); - - full( 10, 1 ); // $ExpectType Float64Array - full( 10, 1, 'float64' ); // $ExpectType Float64Array - full( 10, 1, 'float32' ); // $ExpectType Float32Array - full( 10, z, 'complex128' ); // $ExpectType Complex128Array - full( 10, z, 'complex64' ); // $ExpectType Complex64Array - full( 10, true, 'bool' ); // $ExpectType BooleanArray - full( 10, 1, 'int32' ); // $ExpectType Int32Array - full( 10, 1, 'int16' ); // $ExpectType Int16Array - full( 10, 1, 'int8' ); // $ExpectType Int8Array - full( 10, 1, 'uint32' ); // $ExpectType Uint32Array - full( 10, 1, 'uint16' ); // $ExpectType Uint16Array - full( 10, 1, 'uint8' ); // $ExpectType Uint8Array - full( 10, 1, 'uint8c' ); // $ExpectType Uint8ClampedArray - full( 10, 1, 'generic' ); // $ExpectType number[] - full( 10, 'abc', 'generic' ); // $ExpectType string[] -} - -// The compiler throws an error if the function is not provided a number for the first argument... -{ - full( '5', 1 ); // $ExpectError - full( false, 1 ); // $ExpectError - full( true, 1 ); // $ExpectError - full( null, 1 ); // $ExpectError - full( undefined, 1 ); // $ExpectError - full( [], 1 ); // $ExpectError - full( {}, 1 ); // $ExpectError - full( ( x: number ): number => x, 1 ); // $ExpectError - - full( '5', 1, 'float32' ); // $ExpectError - full( false, 1, 'float32' ); // $ExpectError - full( true, 1, 'float32' ); // $ExpectError - full( null, 1, 'float32' ); // $ExpectError - full( undefined, 1, 'float32' ); // $ExpectError - full( [], 1, 'float32' ); // $ExpectError - full( {}, 1, 'float32' ); // $ExpectError - full( ( x: number ): number => x, 1, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is an unrecognized/unsupported data type... -{ - full( 10, 1, '10' ); // $ExpectError - full( 10, 1, 10 ); // $ExpectError - full( 10, 1, false ); // $ExpectError - full( 10, 1, true ); // $ExpectError - full( 10, 1, null ); // $ExpectError - full( 10, 1, [] ); // $ExpectError - full( 10, 1, {} ); // $ExpectError - full( 10, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - full( 10, 1, 'float64', 1 ); // $ExpectError -} diff --git a/full/examples/index.js b/full/examples/index.js deleted file mode 100644 index ba941a1d4..000000000 --- a/full/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../typed-real-dtypes' ); -var full = require( './../lib' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = full( 5, i+1, dt[ i ] ); - console.log( arr ); -} diff --git a/full/lib/index.js b/full/lib/index.js deleted file mode 100644 index 5e52f9683..000000000 --- a/full/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a filled array having a specified length. -* -* @module @stdlib/array/full -* -* @example -* var full = require( '@stdlib/array/full' ); -* -* var arr = full( 2, 1.0 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var full = require( '@stdlib/array/full' ); -* -* var arr = full( 2, 1.0, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/full/lib/main.js b/full/lib/main.js deleted file mode 100644 index 05f33a716..000000000 --- a/full/lib/main.js +++ /dev/null @@ -1,86 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var ctors = require( './../../ctors' ); -var afill = require( './../../base/filled' ); -var gfill = require( '@stdlib/blas/ext/base/gfill' ); -var defaults = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// MAIN // - -/** -* Creates a filled array having a specified length. -* -* @param {NonNegativeInteger} length - array length -* @param {*} value - fill value -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} third argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = full( 2, 1.0 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = full( 2, 1.0, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -function full( length, value ) { - var dtype; - var ctor; - var out; - if ( !isNonNegativeInteger( length ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', length ) ); - } - if ( arguments.length > 2 ) { - dtype = arguments[ 2 ]; - } else { - dtype = DEFAULT_DTYPE; - } - if ( dtype === 'generic' ) { - return afill( value, length ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Third argument must be a recognized data type. Value: `%s`.', dtype ) ); - } - out = new ctor( length ); - - // TODO: revisit the following, as using `gfill` is not the most performant, especially for large arrays. We have two options: (1) use a native add-on which delegates to an appropriate C function which performs the loop or (2) use @stdlib/blas/ext/base/(d|s|c|z)fill functions which use native add-ons. The latter option is not great, as we only get perf boosts for large arrays for a select number of dtypes. The former option is more work, as we may need to write a bespoke add-on for handling the argument signature and the various types that `value` can assume (e.g., number, complex, etc). If we had a generic strided `copy` package with an add-on, we could wrap the value as a single element strided array with a stride of `0` and copy from `x` to `y`, and thus would not need to write a bespoke add-on. Note, however, that calling into a native add-on is not free. For shorter arrays, we'll likely observe a perf hit in Node.js. For now, we focus on just getting something working... - gfill( length, value, out, 1 ); - - return out; -} - - -// EXPORTS // - -module.exports = full; diff --git a/full/package.json b/full/package.json deleted file mode 100644 index cf66f47da..000000000 --- a/full/package.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "name": "@stdlib/array/full", - "version": "0.0.0", - "description": "Create a filled array having a specified length.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "fill", - "filled", - "full" - ] -} diff --git a/full/test/test.js b/full/test/test.js deleted file mode 100644 index 80f9b6c8d..000000000 --- a/full/test/test.js +++ /dev/null @@ -1,346 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var full = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof full, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - full( value, 1.0 ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - full( value, 1.0, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'full', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - full( 10, 1.0, value ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = full( 5, 1.0 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = full( 5, 1.0, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = full( 5, 1.0, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=bool)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1 ] ); - - arr = full( 4, true, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - var z; - - expected = new Float64Array( [ 1.0, 2.0, 1.0, 2.0 ] ); - - z = new Complex128( 1.0, 2.0 ); - arr = full( 2, z, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - var z; - - expected = new Float32Array( [ 1.0, 2.0, 1.0, 2.0 ] ); - - z = new Complex64( 1.0, 2.0 ); - arr = full( 2, z, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = full( 5, 1, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = full( 5, 1, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = full( 5, 1, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = full( 5, 1, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = full( 5, 1, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = full( 5, 1, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = full( 5, 1, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = full( 5, 1, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/generic/benchmark/benchmark.fast_elements_array_length_heuristic.js b/generic/benchmark/benchmark.fast_elements_array_length_heuristic.js deleted file mode 100644 index 92d3b1183..000000000 --- a/generic/benchmark/benchmark.fast_elements_array_length_heuristic.js +++ /dev/null @@ -1,196 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert/is-array' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var randu = require( '@stdlib/random/base/randu' ); -var pow = require( '@stdlib/math/base/special/pow' ); - - -// VARIABLES // - -var NAME = 'js-array-length-fast-elements-heuristic'; - -/* -* In some engines, heuristics have been used to ensure "fast elements" (i.e., contiguous memory) for generic arrays. For historical background, see -* -* - https://www.html5rocks.com/en/tutorials/speed/v8/#toc-topic-numbers -* - https://github.com/thlorenz/v8-perf/blob/ee76ddf1e414f3299bd03943ef212072dd16200f/data-types.md#fast-elements -* -* Apparently, in more recent V8 versions, the limit at which dictionary mode is triggered when preallocating arrays has increased to ~32 million. -* -* - https://github.com/v8/v8/blob/2feb99dc8ac75f20d2e5c9c1b343e923476851ea/src/objects/js-array.h#L87-L88 -*/ -var MAX_FAST_ELEMENTS_HEURISTIC = 64000|0; // eslint-disable-line id-length - - -// FUNCTIONS // - -/** -* Copies an array using a heuristic for ensuring "fast" elements. -* -* @private -* @param {Array} arr - array to copy -* @returns {Array} array copy -*/ -function copy1( arr ) { - var out; - var len; - var i; - - len = arr.length; - if ( len > MAX_FAST_ELEMENTS_HEURISTIC ) { - out = new Array( MAX_FAST_ELEMENTS_HEURISTIC ); - for ( i = 0; i < MAX_FAST_ELEMENTS_HEURISTIC; i++ ) { - out[ i ] = arr[ i ]; - } - for ( i = MAX_FAST_ELEMENTS_HEURISTIC; i < len; i++ ) { - out.push( arr[ i ] ); - } - } else { - out = new Array( len ); - for ( i = 0; i < len; i++ ) { - out[ i ] = arr[ i ]; - } - } - return out; -} - -/** -* Copies an array by preallocating output array memory. -* -* @private -* @param {Array} arr - array to copy -* @returns {Array} array copy -*/ -function copy2( arr ) { - var out; - var len; - var i; - - len = arr.length; - out = new Array( len ); - for ( i = 0; i < len; i++ ) { - out[ i ] = arr[ i ]; - } - return out; -} - -/** -* Copies an array using dynamic memory allocation. -* -* @private -* @param {Array} arr - array to copy -* @returns {Array} array copy -*/ -function copy3( arr ) { - var out; - var len; - var i; - - len = arr.length; - out = []; - for ( i = 0; i < len; i++ ) { - out.push( arr[ i ] ); - } - return out; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - function to benchmark -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - var arr; - var i; - - arr = []; - for ( i = 0; i < len; i++ ) { - arr.push( 0 ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = floor( randu()*100.0 )|0; // cast to int32 - out = fcn( arr ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( copy1, len ); - bench( NAME+'::heuristic:len='+len, f ); - - f = createBenchmark( copy2, len ); - bench( NAME+'::preallocate:len='+len, f ); - - f = createBenchmark( copy3, len ); - bench( NAME+'::dynamic:len='+len, f ); - } -} - -main(); diff --git a/generic/benchmark/benchmark.nested_dimensions.js b/generic/benchmark/benchmark.nested_dimensions.js deleted file mode 100644 index 02b2f9c7c..000000000 --- a/generic/benchmark/benchmark.nested_dimensions.js +++ /dev/null @@ -1,762 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); -var randu = require( '@stdlib/random/base/randu' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; -var Float64Array = require( './../../float64' ); - - -// VARIABLES // - -var NAME = 'generic-array-nested-dimensions'; - - -// MAIN // - -bench( NAME+'::ndims=1,N=1e6', function benchmark( b ) { - var arr; - var N0; - var i0; - var v; - var i; - - N0 = 1e6; - - arr = []; - for ( i0 = 0; i0 < N0; i0++ ) { - arr.push( randu() ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sum( arr ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function sum( arr ) { - var i0; - var s; - - s = 0; - for ( i0 = 0; i0 < N0; i0++ ) { - s += arr[ i0 ]; - } - return s; - } -}); - -bench( NAME+'::ndims=2,N=1e6', function benchmark( b ) { - var arr; - var tmp; - var N0; - var N1; - var i0; - var i1; - var v; - var i; - - N0 = 1000; - N1 = 1000; // N0xN1 = 1e6 - - arr = []; - for ( i0 = 0; i0 < N0; i0++ ) { - tmp = []; - for ( i1 = 0; i1 < N1; i1++ ) { - tmp.push( randu() ); - } - arr.push( tmp ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sum( arr ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function sum( arr ) { - var i0; - var i1; - var s; - - s = 0; - for ( i0 = 0; i0 < N0; i0++ ) { - for ( i1 = 0; i1 < N1; i1++ ) { - s += arr[ i0 ][ i1 ]; - } - } - return s; - } -}); - -bench( NAME+'::ndims=3,N=1e6', function benchmark( b ) { - var arr; - var t1; - var t2; - var N0; - var N1; - var N2; - var i0; - var i1; - var i2; - var v; - var i; - - N0 = 100; - N1 = 100; - N2 = 100; // N0xN1xN2 = 1e6 - - arr = []; - for ( i0 = 0; i0 < N0; i0++ ) { - t1 = []; - for ( i1 = 0; i1 < N1; i1++ ) { - t2 = []; - for ( i2 = 0; i2 < N2; i2++ ) { - t2.push( randu() ); - } - t1.push( t2 ); - } - arr.push( t1 ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sum( arr ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function sum( arr ) { - var i0; - var i1; - var i2; - var s; - - s = 0; - for ( i0 = 0; i0 < N0; i0++ ) { - for ( i1 = 0; i1 < N1; i1++ ) { - for ( i2 = 0; i2 < N2; i2++ ) { - s += arr[ i0 ][ i1 ][ i2 ]; - } - } - } - return s; - } -}); - -bench( NAME+'::ndims=4,N=998784', function benchmark( b ) { - var arr; - var t1; - var t2; - var t3; - var i0; - var i1; - var i2; - var i3; - var N0; - var N1; - var N2; - var N3; - var v; - var i; - - N0 = 34; - N1 = 34; - N2 = 32; - N3 = 27; - - arr = []; - for ( i0 = 0; i0 < N0; i0++ ) { - t1 = []; - for ( i1 = 0; i1 < N1; i1++ ) { - t2 = []; - for ( i2 = 0; i2 < N2; i2++ ) { - t3 = []; - for ( i3 = 0; i3 < N3; i3++ ) { - t3.push( randu() ); - } - t2.push( t3 ); - } - t1.push( t2 ); - } - arr.push( t1 ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sum( arr ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function sum( arr ) { - var i0; - var i1; - var i2; - var i3; - var s; - - s = 0; - for ( i0 = 0; i0 < N0; i0++ ) { - for ( i1 = 0; i1 < N1; i1++ ) { - for ( i2 = 0; i2 < N2; i2++ ) { - for ( i3 = 0; i3 < N3; i3++ ) { - s += arr[ i0 ][ i1 ][ i2 ][ i3 ]; - } - } - } - } - return s; - } -}); - -bench( NAME+'::ndims=5,N=991440', function benchmark( b ) { - var arr; - var t1; - var t2; - var t3; - var t4; - var i0; - var i1; - var i2; - var i3; - var i4; - var N0; - var N1; - var N2; - var N3; - var N4; - var v; - var i; - - N0 = 18; - N1 = 18; - N2 = 18; - N3 = 17; - N4 = 10; - - arr = []; - for ( i0 = 0; i0 < N0; i0++ ) { - t1 = []; - for ( i1 = 0; i1 < N1; i1++ ) { - t2 = []; - for ( i2 = 0; i2 < N2; i2++ ) { - t3 = []; - for ( i3 = 0; i3 < N3; i3++ ) { - t4 = []; - for ( i4 = 0; i4 < N4; i4++ ) { - t4.push( randu() ); - } - t3.push( t4 ); - } - t2.push( t3 ); - } - t1.push( t2 ); - } - arr.push( t1 ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sum( arr ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function sum( arr ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var s; - - s = 0; - for ( i0 = 0; i0 < N0; i0++ ) { - for ( i1 = 0; i1 < N1; i1++ ) { - for ( i2 = 0; i2 < N2; i2++ ) { - for ( i3 = 0; i3 < N3; i3++ ) { - for ( i4 = 0; i4 < N4; i4++ ) { - s += arr[ i0 ][ i1 ][ i2 ][ i3 ][ i4 ]; - } - } - } - } - } - return s; - } -}); - -bench( NAME+'::ndims=6,N=1e6', function benchmark( b ) { - var arr; - var t1; - var t2; - var t3; - var t4; - var t5; - var i0; - var i1; - var i2; - var i3; - var i4; - var i5; - var N0; - var N1; - var N2; - var N3; - var N4; - var N5; - var v; - var i; - - N0 = 10; - N1 = 10; - N2 = 10; - N3 = 10; - N4 = 10; - N5 = 10; - - arr = []; - for ( i0 = 0; i0 < N0; i0++ ) { - t1 = []; - for ( i1 = 0; i1 < N1; i1++ ) { - t2 = []; - for ( i2 = 0; i2 < N2; i2++ ) { - t3 = []; - for ( i3 = 0; i3 < N3; i3++ ) { - t4 = []; - for ( i4 = 0; i4 < N4; i4++ ) { - t5 = []; - for ( i5 = 0; i5 < N5; i5++ ) { // eslint-disable-line max-depth - t5.push( randu() ); - } - t4.push( t5 ); - } - t3.push( t4 ); - } - t2.push( t3 ); - } - t1.push( t2 ); - } - arr.push( t1 ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sum( arr ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function sum( arr ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i5; - var s; - - s = 0; - for ( i0 = 0; i0 < N0; i0++ ) { - for ( i1 = 0; i1 < N1; i1++ ) { - for ( i2 = 0; i2 < N2; i2++ ) { - for ( i3 = 0; i3 < N3; i3++ ) { - for ( i4 = 0; i4 < N4; i4++ ) { - for ( i5 = 0; i5 < N5; i5++ ) { // eslint-disable-line max-depth - s += arr[ i0 ][ i1 ][ i2 ][ i3 ][ i4 ][ i5 ]; - } - } - } - } - } - } - return s; - } -}); - -bench( NAME+'::ndims=6,N=1e6,v8_deoptimized', function benchmark( b ) { - var randi; - var cache; - var arr; - var t1; - var t2; - var t3; - var t4; - var t5; - var i0; - var i1; - var i2; - var i3; - var i4; - var i5; - var N0; - var N1; - var N2; - var N3; - var N4; - var N5; - var v; - var i; - - N0 = 10; - N1 = 10; - N2 = 10; - N3 = 10; - N4 = 10; - N5 = 10; - - cache = []; - for ( i4 = 0; i4 < 1e5; i4++ ) { - t5 = []; - for ( i5 = 0; i5 < N5; i5++ ) { - t5.push( randu() ); - } - cache.push( t5 ); - } - - // The idea is to thwart V8's optimization efforts to ensure cache locality for the purposes of seeing if we can realize the theoretical, not the optimal, performance of nested arrays... - randi = discreteUniform( 0, 1e5-1 ); - - arr = []; - for ( i0 = 0; i0 < N0; i0++ ) { - t1 = []; - for ( i1 = 0; i1 < N1; i1++ ) { - t2 = []; - for ( i2 = 0; i2 < N2; i2++ ) { - t3 = []; - for ( i3 = 0; i3 < N3; i3++ ) { - t4 = []; - for ( i4 = 0; i4 < N4; i4++ ) { - t4.push( cache[ randi() ] ); - } - t3.push( t4 ); - } - t2.push( t3 ); - } - t1.push( t2 ); - } - arr.push( t1 ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sum( arr ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function sum( arr ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i5; - var s; - - s = 0; - for ( i0 = 0; i0 < N0; i0++ ) { - for ( i1 = 0; i1 < N1; i1++ ) { - for ( i2 = 0; i2 < N2; i2++ ) { - for ( i3 = 0; i3 < N3; i3++ ) { - for ( i4 = 0; i4 < N4; i4++ ) { - for ( i5 = 0; i5 < N5; i5++ ) { // eslint-disable-line max-depth - s += arr[ i0 ][ i1 ][ i2 ][ i3 ][ i4 ][ i5 ]; - } - } - } - } - } - } - return s; - } -}); - -bench( NAME+'::ndims=6,N=1e6,v8_deoptimized_w_float64arrays', function benchmark( b ) { - var randi; - var cache; - var arr; - var t1; - var t2; - var t3; - var t4; - var t5; - var i0; - var i1; - var i2; - var i3; - var i4; - var i5; - var N0; - var N1; - var N2; - var N3; - var N4; - var N5; - var v; - var i; - - N0 = 10; - N1 = 10; - N2 = 10; - N3 = 10; - N4 = 10; - N5 = 10; - - cache = []; - for ( i4 = 0; i4 < 1e5; i4++ ) { - t5 = new Float64Array( N5 ); - for ( i5 = 0; i5 < N5; i5++ ) { - t5[ i5 ] = randu(); - } - cache.push( t5 ); - } - - // The idea is to thwart V8's optimization efforts to ensure cache locality for the purposes of seeing if we can realize the theoretical, not the optimal, performance of nested arrays... - randi = discreteUniform( 0, 1e5-1 ); - - arr = []; - for ( i0 = 0; i0 < N0; i0++ ) { - t1 = []; - for ( i1 = 0; i1 < N1; i1++ ) { - t2 = []; - for ( i2 = 0; i2 < N2; i2++ ) { - t3 = []; - for ( i3 = 0; i3 < N3; i3++ ) { - t4 = []; - for ( i4 = 0; i4 < N4; i4++ ) { - t4.push( cache[ randi() ] ); - } - t3.push( t4 ); - } - t2.push( t3 ); - } - t1.push( t2 ); - } - arr.push( t1 ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sum( arr ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function sum( arr ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i5; - var s; - - s = 0; - for ( i0 = 0; i0 < N0; i0++ ) { - for ( i1 = 0; i1 < N1; i1++ ) { - for ( i2 = 0; i2 < N2; i2++ ) { - for ( i3 = 0; i3 < N3; i3++ ) { - for ( i4 = 0; i4 < N4; i4++ ) { - for ( i5 = 0; i5 < N5; i5++ ) { // eslint-disable-line max-depth - s += arr[ i0 ][ i1 ][ i2 ][ i3 ][ i4 ][ i5 ]; - } - } - } - } - } - } - return s; - } -}); - -bench( NAME+'::ndims=6,N=1e6,v8_deoptimized_w_mixed_array_types', function benchmark( b ) { - var randi; - var cache; - var arr; - var t1; - var t2; - var t3; - var t4; - var t5; - var i0; - var i1; - var i2; - var i3; - var i4; - var i5; - var N0; - var N1; - var N2; - var N3; - var N4; - var N5; - var v; - var i; - - N0 = 10; - N1 = 10; - N2 = 10; - N3 = 10; - N4 = 10; - N5 = 10; - - cache = []; - for ( i4 = 0; i4 < 1e5; i4++ ) { - if ( randu() < 0.5 ) { - t5 = new Float64Array( N5 ); - for ( i5 = 0; i5 < N5; i5++ ) { - t5[ i5 ] = randu(); - } - } else { - t5 = []; - for ( i5 = 0; i5 < N5; i5++ ) { - t5.push( randu() ); - } - } - cache.push( t5 ); - } - - // The idea is to thwart V8's optimization efforts to ensure cache locality for the purposes of seeing if we can realize the theoretical, not the optimal, performance of nested arrays... - randi = discreteUniform( 0, 1e5-1 ); - - arr = []; - for ( i0 = 0; i0 < N0; i0++ ) { - t1 = []; - for ( i1 = 0; i1 < N1; i1++ ) { - t2 = []; - for ( i2 = 0; i2 < N2; i2++ ) { - t3 = []; - for ( i3 = 0; i3 < N3; i3++ ) { - t4 = []; - for ( i4 = 0; i4 < N4; i4++ ) { - t4.push( cache[ randi() ] ); - } - t3.push( t4 ); - } - t2.push( t3 ); - } - t1.push( t2 ); - } - arr.push( t1 ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = sum( arr ); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function sum( arr ) { - var i0; - var i1; - var i2; - var i3; - var i4; - var i5; - var s; - - s = 0; - for ( i0 = 0; i0 < N0; i0++ ) { - for ( i1 = 0; i1 < N1; i1++ ) { - for ( i2 = 0; i2 < N2; i2++ ) { - for ( i3 = 0; i3 < N3; i3++ ) { - for ( i4 = 0; i4 < N4; i4++ ) { - for ( i5 = 0; i5 < N5; i5++ ) { // eslint-disable-line max-depth - s += arr[ i0 ][ i1 ][ i2 ][ i3 ][ i4 ][ i5 ]; - } - } - } - } - } - } - return s; - } -}); diff --git a/incrspace/README.md b/incrspace/README.md deleted file mode 100644 index f14bb3f37..000000000 --- a/incrspace/README.md +++ /dev/null @@ -1,152 +0,0 @@ - - -# Incrspace - -> Generate a linearly spaced numeric array using a provided increment. - -
- -## Usage - -```javascript -var incrspace = require( '@stdlib/array/incrspace' ); -``` - -#### incrspace( start, stop\[, increment] ) - -Generates a linearly spaced numeric `array`. If an `increment` is not provided, the default `increment` is `1`. - -```javascript -var arr = incrspace( 0, 11, 2 ); -// returns [ 0, 2, 4, 6, 8, 10 ] -``` - -
- - - -
- -### Notes - -- The output `array` is guaranteed to include the `start` value but does **not** include the `stop` value. Beware that values subsequent to the `start` value are subject to floating-point errors. Hence, - - ```javascript - var arr = incrspace( 0.1, 0.5, 0.2 ); - // returns [ 0.1, ~0.3 ] - ``` - - where `arr[1]` is only guaranteed to be approximately equal to `0.3`. - - If you desire more control over element precision, consider using [roundn][@stdlib/math/base/special/roundn]: - - ```javascript - var roundn = require( '@stdlib/math/base/special/roundn' ); - var arr; - var out; - var i; - - // Create an array subject to floating-point errors: - arr = incrspace( 0, 1.01, 0.02 ); - - // Round each value to the nearest hundredth: - out = []; - for ( i = 0; i < arr.length; i++ ) { - out.push( roundn( arr[ i ], -2 ) ); - } - - console.log( out.join( '\n' ) ); - ``` - -
- - - -
- -## Examples - - - -```javascript -var incrspace = require( '@stdlib/array/incrspace' ); -var out; - -// Default behavior: -console.log( '\nDefault:' ); -out = incrspace( 0, 10 ); -console.log( out.join( '\n' ) ); - -// Specify increment: -console.log( '\nIncrement 2:' ); -out = incrspace( 0, 10, 2 ); -console.log( out.join( '\n' ) ); - -console.log( '\nIncrement 2:' ); -out = incrspace( 0, 11, 2 ); -console.log( out.join( '\n' ) ); - -console.log( '\nIncrement 0.02:' ); -out = incrspace( 0, 1.01, 0.02 ); -console.log( out.join( '\n' ) ); - -// Create an array using a negative increment: -console.log( '\nDecremented values:' ); -out = incrspace( 10, 0, -2 ); -console.log( out.join( '\n' ) ); -``` - -
- - - - - - - - - - - - - - diff --git a/incrspace/benchmark/benchmark.js b/incrspace/benchmark/benchmark.js deleted file mode 100644 index 031adc210..000000000 --- a/incrspace/benchmark/benchmark.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 round = require( '@stdlib/math/base/special/round' ); -var randu = require( '@stdlib/random/base/randu' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var incrspace = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var start; - var stop; - var i; - var v; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - start = round( randu()*100.0 ); - stop = start + 100; - v = incrspace( start, stop ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':incr=10', function benchmark( b ) { - var start; - var incr; - var stop; - var i; - var v; - - incr = 10; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - start = round( randu()*100.0 ); - stop = start + (100*incr); - v = incrspace( start, stop, incr ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/incrspace/benchmark/benchmark.length.js b/incrspace/benchmark/benchmark.length.js deleted file mode 100644 index 6fa425e9d..000000000 --- a/incrspace/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var round = require( '@stdlib/math/base/special/round' ); -var randu = require( '@stdlib/random/base/randu' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var incrspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var start; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - start = round( randu() * 10.0 ); - v = incrspace( start, start + len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/incrspace/docs/repl.txt b/incrspace/docs/repl.txt deleted file mode 100644 index 7655937dd..000000000 --- a/incrspace/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( start, stop[, increment] ) - Generates a linearly spaced numeric array using a provided increment. - - If an `increment` is not provided, the default `increment` is `1`. - - The output array is guaranteed to include the `start` value but does not - include the `stop` value. - - Parameters - ---------- - start: number - First array value. - - stop: number - Array element bound. - - increment: number (optional) - Increment. Default: `1`. - - Returns - ------- - arr: Array - Linearly spaced numeric array. - - Examples - -------- - > var arr = {{alias}}( 0, 11, 2 ) - [ 0, 2, 4, 6, 8, 10 ] - - See Also - -------- - diff --git a/incrspace/docs/types/index.d.ts b/incrspace/docs/types/index.d.ts deleted file mode 100644 index a099b40ff..000000000 --- a/incrspace/docs/types/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Generates a linearly spaced numeric array using a provided increment. -* -* @param x1 - first array value -* @param x2 - array element bound -* @param increment - increment (default: 1) -* @throws length of created array must be less than `4294967295` (`2**32 - 1`) -* @returns linearly spaced numeric array -* -* @example -* var arr = incrspace( 0, 11, 2 ); -* // returns [ 0, 2, 4, 6, 8, 10 ] -*/ -declare function incrspace( x1: number, x2: number, increment?: number ): Array; - - -// EXPORTS // - -export = incrspace; diff --git a/incrspace/docs/types/test.ts b/incrspace/docs/types/test.ts deleted file mode 100644 index f2a99349f..000000000 --- a/incrspace/docs/types/test.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 incrspace = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - incrspace( 0, 11, 2 ); // $ExpectType number[] - incrspace( 0, 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided values other than two numbers for the first two parameters... -{ - incrspace( true, 10 ); // $ExpectError - incrspace( false, 10 ); // $ExpectError - incrspace( '5', 10 ); // $ExpectError - incrspace( [], 10 ); // $ExpectError - incrspace( {}, 20 ); // $ExpectError - incrspace( ( x: number ): number => x, 20 ); // $ExpectError - - incrspace( 9, true ); // $ExpectError - incrspace( 9, false ); // $ExpectError - incrspace( 5, '5' ); // $ExpectError - incrspace( 8, [] ); // $ExpectError - incrspace( 9, {} ); // $ExpectError - incrspace( 8, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a value other than a number for the third parameter... -{ - incrspace( 3, 20, true ); // $ExpectError - incrspace( 4, 20, false ); // $ExpectError - incrspace( 2, 20, '5' ); // $ExpectError - incrspace( 2, 20, [] ); // $ExpectError - incrspace( 9, 20, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - incrspace(); // $ExpectError - incrspace( 3 ); // $ExpectError -} diff --git a/incrspace/examples/index.js b/incrspace/examples/index.js deleted file mode 100644 index 2bf1492a9..000000000 --- a/incrspace/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 incrspace = require( './../lib' ); -var out; - -// Default behavior: -console.log( '\nDefault:' ); -out = incrspace( 0, 10 ); -console.log( out.join( '\n' ) ); - -// Specify increment: -console.log( '\nIncrement 2:' ); -out = incrspace( 0, 10, 2 ); -console.log( out.join( '\n' ) ); - -console.log( '\nIncrement 2:' ); -out = incrspace( 0, 11, 2 ); -console.log( out.join( '\n' ) ); - -console.log( '\nIncrement 0.02:' ); -out = incrspace( 0, 1.01, 0.02 ); -console.log( out.join( '\n' ) ); - -// Create an array using a negative increment: -console.log( '\nDecremented values:' ); -out = incrspace( 10, 0, -2 ); -console.log( out.join( '\n' ) ); diff --git a/incrspace/lib/index.js b/incrspace/lib/index.js deleted file mode 100644 index 34d2817fb..000000000 --- a/incrspace/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Generate a linearly spaced numeric array using a provided increment. -* -* @module @stdlib/array/incrspace -* -* @example -* var incrspace = require( '@stdlib/array/incrspace' ); -* -* var arr = incrspace( 0, 11, 2 ); -* // returns [ 0, 2, 4, 6, 8, 10 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/incrspace/lib/main.js b/incrspace/lib/main.js deleted file mode 100644 index 29bbc8628..000000000 --- a/incrspace/lib/main.js +++ /dev/null @@ -1,76 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var ceil = require( '@stdlib/math/base/special/ceil' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var format = require( '@stdlib/string/format' ); -var MAX_LENGTH = require( '@stdlib/constants/uint32/max' ); -var gen = require( './../../base/incrspace' ); - - -// MAIN // - -/** -* Generates a linearly spaced numeric array using a provided increment. -* -* @param {number} x1 - first array value -* @param {number} x2 - array element bound -* @param {number} [increment=1] - increment -* @throws {TypeError} first argument must be numeric -* @throws {TypeError} second argument must be numeric -* @throws {TypeError} third argument must be numeric -* @throws {RangeError} length of created array must be less than `4294967295` (`2**32 - 1`) -* @returns {Array} linearly spaced numeric array -* -* @example -* var arr = incrspace( 0, 11, 2 ); -* // returns [ 0, 2, 4, 6, 8, 10 ] -*/ -function incrspace( x1, x2, increment ) { - var len; - var inc; - if ( !isNumber( x1 ) || isnan( x1 ) ) { - throw new TypeError( format( 'invalid argument. Start must be numeric. Value: `%s`.', x1 ) ); - } - if ( !isNumber( x2 ) || isnan( x2 ) ) { - throw new TypeError( format( 'invalid argument. Stop must be numeric. Value: `%s`.', x2 ) ); - } - if ( arguments.length < 3 ) { - inc = 1; - } else { - inc = increment; - if ( !isNumber( inc ) || isnan( inc ) ) { - throw new TypeError( format( 'invalid argument. Increment must be numeric. Value: `%s`.', inc ) ); - } - } - len = ceil( ( x2-x1 ) / inc ); - if ( len > MAX_LENGTH ) { - throw new RangeError( 'invalid arguments. Generated array exceeds maximum array length.' ); - } - return gen( x1, x2, inc ); -} - - -// EXPORTS // - -module.exports = incrspace; diff --git a/incrspace/package.json b/incrspace/package.json deleted file mode 100644 index 1714c0620..000000000 --- a/incrspace/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/incrspace", - "version": "0.0.0", - "description": "Generate a linearly spaced numeric array using a provided increment.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdmath", - "utilities", - "utils", - "mathematics", - "math", - "generic", - "array", - "matlab", - "linear", - "linspace", - "sequence", - "increment" - ] -} diff --git a/incrspace/test/test.js b/incrspace/test/test.js deleted file mode 100644 index d0f95f67a..000000000 --- a/incrspace/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 incrspace = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof incrspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the `start` value is not a number primitive', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - incrspace( value, 10 ); - }; - } -}); - -tape( 'the function throws an error if the `stop` value is not a number primitive', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - incrspace( 0, value ); - }; - } -}); - -tape( 'the function throws an error if the `increment` value is not a number primitive', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - incrspace( 0, 10, value ); - }; - } -}); - -tape( 'the function returns a linearly spaced array', function test( t ) { - var expected; - var actual; - var start; - var stop; - - start = 0; - stop = 10; - - // Default behavior: - actual = incrspace( start, stop ); - expected = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; - t.deepEqual( actual, expected ); - - // Specify the increment: - actual = incrspace( start, stop, 2 ); - expected = [ 0, 2, 4, 6, 8 ]; - t.deepEqual( actual, expected ); - - actual = incrspace( start, 11, 2 ); - expected = [ 0, 2, 4, 6, 8, 10 ]; - t.deepEqual( actual, expected ); - - // Decrement: - actual = incrspace( stop, start, -2 ); - expected = [ 10, 8, 6, 4, 2 ]; - t.deepEqual( actual, expected ); - - // Large array: - actual = incrspace( start, 1e6, 1 ); - t.equal( actual.length, 1e6 ); - - t.end(); -}); - -tape( 'the function throws an error if the maximum array length is exceeded', function test( t ) { - var values; - var i; - - values = [ - 0.000000000000001, - 0.00000000000000000000001, - 0.000000000000000000000000001, - 0 - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), RangeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - incrspace( 0, 10, value ); - }; - } -}); - -tape( 'the function returns a single element array for incompatible increments', function test( t ) { - t.deepEqual( incrspace(0, 10, -1), [ 0 ] ); - t.deepEqual( incrspace(0, 10, 11), [ 0 ] ); - t.end(); -}); diff --git a/index.js b/index.js new file mode 100644 index 000000000..0e7714b2c --- /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 +!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("buffer")):"function"==typeof define&&define.amd?define(["buffer"],t):(r="undefined"!=typeof globalThis?globalThis:r||self).ns=t(r.require$$0)}(this,(function(r){"use strict";var t="function"==typeof Object.defineProperty?Object.defineProperty:null;var e=Object.defineProperty;function n(r){return"number"==typeof r}function i(r){var t,e="";for(t=0;t0&&(e-=1),n=r.toExponential(e)):n=r.toPrecision(t.precision),t.alternate||(n=h.call(n,w,"$1e"),n=h.call(n,v,"e"),n=h.call(n,d,""));break;default:throw new Error("invalid double notation. Value: "+t.specifier)}return n=h.call(n,p,"e+0$1"),n=h.call(n,g,"e-0$1"),t.alternate&&(n=h.call(n,y,"$1."),n=h.call(n,m,"$1.e")),r>=0&&t.sign&&(n=t.sign+n),n=t.specifier===c.call(t.specifier)?c.call(n):s.call(n)}function E(r){var t,e="";for(t=0;t127)throw new Error("invalid character code. Value: "+i.arg);i.arg=x(u)?String(i.arg):_(u)}break;case"e":case"E":case"f":case"F":case"g":case"G":if(t||(i.precision=6),c=parseFloat(i.arg),!isFinite(c)){if(!n(i.arg))throw new Error("invalid floating-point number. Value: "+l);c=i.arg,i.padZeros=!1}i.arg=b(c,i);break;default:throw new Error("invalid specifier: "+i.specifier)}i.maxWidth>=0&&i.arg.length>i.maxWidth&&(i.arg=i.arg.substring(0,i.maxWidth)),i.padZeros?i.arg=o(i.arg,i.width||i.precision,i.padRight):i.width&&(i.arg=(g=i.arg,y=i.width,m=i.padRight,d=void 0,(d=y-g.length)<0?g:g=m?g+E(d):E(d)+g)),l+=i.arg||"",s+=1}return l}var S=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function F(r){var t={mapping:r[1]?parseInt(r[1],10):void 0,flags:r[2],width:r[3],precision:r[5],specifier:r[6]};return"."===r[4]&&void 0===r[5]&&(t.precision="1"),t}function j(r){var t,e,n,i;for(e=[],i=0,n=S.exec(r);n;)(t=r.slice(i,S.lastIndex-n[0].length)).length&&e.push(t),"%"===n[6]?e.push("%"):e.push(F(n)),i=S.lastIndex,n=S.exec(r);return(t=r.slice(i)).length&&e.push(t),e}function k(r){var t,e;if("string"!=typeof r)throw new TypeError(k("invalid argument. First argument must be a string. Value: `%s`.",r));for(t=[j(r)],e=1;eEt&&Tt(r)}function Vt(r){return yt(r)&&xt(r)}function At(r){return wt(r)&&xt(r.valueOf())}function St(r){return Vt(r)||At(r)}function Ft(r){return Vt(r)&&r>=0}function jt(r){return At(r)&&r.valueOf()>=0}function kt(r){return Ft(r)||jt(r)}U(St,"isPrimitive",Vt),U(St,"isObject",At),U(kt,"isPrimitive",Ft),U(kt,"isObject",jt);var Lt=4294967295;function It(r){return"object"==typeof r&&null!==r&&"number"==typeof r.length&&Tt(r.length)&&r.length>=0&&r.length<=Lt}var Ot=9007199254740991;function Rt(r){return"object"==typeof r&&null!==r&&"number"==typeof r.length&&Tt(r.length)&&r.length>=0&&r.length<=Ot}var Bt="function"==typeof ArrayBuffer;function Mt(r){return Bt&&r instanceof ArrayBuffer||"[object ArrayBuffer]"===ir(r)}function Pt(r){return"object"==typeof r&&null!==r&&!or(r)}function Nt(r){return"string"==typeof r}var Ct=String.prototype.valueOf;var Ut=Z();function Dt(r){return"object"==typeof r&&(r instanceof String||(Ut?function(r){try{return Ct.call(r),!0}catch(r){return!1}}(r):"[object String]"===ir(r)))}function Yt(r){return Nt(r)||Dt(r)}U(Yt,"isPrimitive",Nt),U(Yt,"isObject",Dt);var Wt=ar(Yt.isPrimitive),zt=ar(Yt.isObject),qt=ar(Yt);U(qt,"primitives",Wt),U(qt,"objects",zt);var $t=/./;function Gt(r){return"boolean"==typeof r}var Ht=Boolean,Jt=Boolean.prototype.toString;var Qt=Z();function Xt(r){return"object"==typeof r&&(r instanceof Ht||(Qt?function(r){try{return Jt.call(r),!0}catch(r){return!1}}(r):"[object Boolean]"===ir(r)))}function Zt(r){return Gt(r)||Xt(r)}U(Zt,"isPrimitive",Gt),U(Zt,"isObject",Xt);var Kt="object"==typeof self?self:null,re="object"==typeof window?window:null,te="object"==typeof global?global:null,ee="object"==typeof globalThis?globalThis:null;var ne=function(r){if(arguments.length){if(!Gt(r))throw new TypeError(k("invalid argument. Must provide a boolean. Value: `%s`.",r));if(r)return new Function("return this;")()}if(ee)return ee;if(Kt)return Kt;if(re)return re;if(te)return te;throw new Error("unexpected error. Unable to resolve global object.")}(),ie=ne.document&&ne.document.childNodes,oe=Int8Array;var ae="function"==typeof $t||"object"==typeof oe||"function"==typeof ie?function(r){return cr(r).toLowerCase()}:function(r){var t;return null===r?"null":"object"===(t=typeof r)?cr(r).toLowerCase():t};function ue(r){return"function"===ae(r)}function fe(r,t){if(!(this instanceof fe))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!yt(r))throw new TypeError(k("invalid argument. Real component must be a number. Value: `%s`.",r));if(!yt(t))throw new TypeError(k("invalid argument. Imaginary component must be a number. Value: `%s`.",t));return N(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:r}),N(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:t}),this}U(fe,"BYTES_PER_ELEMENT",8),U(fe.prototype,"BYTES_PER_ELEMENT",8),U(fe.prototype,"byteLength",16),U(fe.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),U(fe.prototype,"toJSON",(function(){var r={type:"Complex128"};return r.re=this.re,r.im=this.im,r}));var le="function"==typeof Math.fround?Math.fround:null,se="function"==typeof Float32Array?Float32Array:void 0;var ce=Er()?se:function(){throw new Error("not implemented")},he=new ce(1);var pe="function"==typeof le?le:function(r){return he[0]=r,he[0]};function ge(r,t){if(!(this instanceof ge))throw new TypeError("invalid invocation. Constructor must be called with the `new` keyword.");if(!yt(r))throw new TypeError(k("invalid argument. Real component must be a number. Value: `%s`.",r));if(!yt(t))throw new TypeError(k("invalid argument. Imaginary component must be a number. Value: `%s`.",t));return N(this,"re",{configurable:!1,enumerable:!0,writable:!1,value:pe(r)}),N(this,"im",{configurable:!1,enumerable:!0,writable:!1,value:pe(t)}),this}function ye(r){return r instanceof fe||r instanceof ge||"object"==typeof r&&null!==r&&"number"==typeof r.re&&"number"==typeof r.im}function me(r){return Tt(r/2)}U(ge,"BYTES_PER_ELEMENT",4),U(ge.prototype,"BYTES_PER_ELEMENT",4),U(ge.prototype,"byteLength",8),U(ge.prototype,"toString",(function(){var r=""+this.re;return this.im<0?r+=" - "+-this.im:r+=" + "+this.im,r+="i"})),U(ge.prototype,"toJSON",(function(){var r={type:"Complex64"};return r.re=this.re,r.im=this.im,r}));var de=8;function ve(r){return"object"==typeof r&&null!==r&&"Complex64Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===de}var we=16;function be(r){return"object"==typeof r&&null!==r&&"Complex128Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===we}function Ee(){return"function"==typeof er&&"symbol"==typeof er("foo")&&tr(er,"iterator")&&"symbol"==typeof er.iterator}var _e=Ee()?Symbol.iterator:null;function Te(r,t,e){N(r,t,{configurable:!1,enumerable:!1,get:e})}function xe(r){return r.re}function Ve(r){return r.im}function Ae(r,t){return new ce(r.buffer,r.byteOffset+r.BYTES_PER_ELEMENT*t,2*(r.length-t))}var Se="function"==typeof Float64Array?Float64Array:void 0;var Fe=yr()?Se:function(){throw new Error("not implemented")};function je(r,t){return new Fe(r.buffer,r.byteOffset+r.BYTES_PER_ELEMENT*t,2*(r.length-t))}function ke(r){var t,e,n;for(t=[];!(e=r.next()).done;)if(It(n=e.value)&&n.length>=2)t.push(n[0],n[1]);else{if(!ye(n))return new TypeError(k("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));t.push(xe(n),Ve(n))}return t}var Le=2*Tr.BYTES_PER_ELEMENT,Ie=Ee();function Oe(r){return r instanceof Me||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function Re(r){return r===Me||"Complex128Array"===r.name}function Be(r,t){return new ge(r[t*=2],r[t+1])}function Me(){var r,t,e,n;if(t=arguments.length,!(this instanceof Me))return 0===t?new Me:1===t?new Me(arguments[0]):2===t?new Me(arguments[0],arguments[1]):new Me(arguments[0],arguments[1],arguments[2]);if(0===t)e=new Tr(0);else if(1===t)if(Ft(arguments[0]))e=new Tr(2*arguments[0]);else if(Rt(arguments[0]))if((n=(e=arguments[0]).length)&&or(e)&&ye(e[0])){if(e=function(r,t){var e,n,i,o;for(e=t.length,o=0,i=0;ie.byteLength-r)throw new RangeError(k("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*Le));e=new Tr(e,r,2*n)}}return U(this,"_buffer",e),U(this,"_length",e.length/2),this}function Pe(r){return r.re}function Ne(r){return r.im}function Ce(r){var t,e,n;for(t=[];!(e=r.next()).done;)if(It(n=e.value)&&n.length>=2)t.push(n[0],n[1]);else{if(!ye(n))return new TypeError(k("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));t.push(Pe(n),Ne(n))}return t}U(Me,"BYTES_PER_ELEMENT",Le),U(Me,"name","Complex64Array"),U(Me,"from",(function(r){var t,e,n,i,o,a,u,f,l,s,c,h;if(!ue(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!Re(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((e=arguments.length)>1){if(!ue(n=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(Oe(r)){if(f=r.length,n){for(o=(i=new this(f))._buffer,h=0,c=0;c=2))throw new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Rt(r)){if(n){for(f=r.length,u=r.get&&r.set?H("default"):z("default"),c=0;c=2))throw new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Pt(r)&&Ie&&ue(r[_e])){if(!ue((o=r[_e]()).next))throw new TypeError(k("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(a=n?function(r,t,e){var n,i,o,a;for(n=[],a=-1;!(i=r.next()).done;)if(a+=1,It(o=t.call(e,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!ye(o))return new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(xe(o),Ve(o))}return n}(o,n,t):ke(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,c=0;c=this._length))return Be(this._buffer,r)})),Te(Me.prototype,"buffer",(function(){return this._buffer.buffer})),Te(Me.prototype,"byteLength",(function(){return this._buffer.byteLength})),Te(Me.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),U(Me.prototype,"BYTES_PER_ELEMENT",Me.BYTES_PER_ELEMENT),U(Me.prototype,"copyWithin",(function(r,t){if(!Oe(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*t):this._buffer.copyWithin(2*r,2*t,2*arguments[2]),this})),U(Me.prototype,"entries",(function(){var r,t,e,n,i,o;if(!Oe(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return r=this,n=this._buffer,e=this._length,o=-1,U(t={},"next",(function(){if(o+=1,i||o>=e)return{done:!0};return{value:[o,Be(n,o)],done:!1}})),U(t,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(t,_e,(function(){return r.entries()})),t})),U(Me.prototype,"every",(function(r,t){var e,n;if(!Oe(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Tt(e))throw new TypeError(k("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(a=xe(r),u=Ve(r),f=t;f=0;n--)if(i=Be(e,n),r.call(t,i,n,this))return i})),U(Me.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!Oe(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=this._length-1;n>=0;n--)if(i=Be(e,n),r.call(t,i,n,this))return n;return-1})),U(Me.prototype,"forEach",(function(r,t){var e,n,i;if(!Oe(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return Be(this._buffer,r)})),U(Me.prototype,"includes",(function(r,t){var e,n,i,o,a;if(!Oe(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ye(r))throw new TypeError(k("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=xe(r),o=Ve(r),e=this._buffer,a=t;a1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=xe(r),o=Ve(r),e=this._buffer,a=t;a=e)return{done:!0};return{value:i,done:!1}})),U(t,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(t,_e,(function(){return r.keys()})),t})),U(Me.prototype,"lastIndexOf",(function(r,t){var e,n,i,o,a;if(!Oe(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ye(r))throw new TypeError(k("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=xe(r),o=Ve(r),e=this._buffer,a=t;a>=0;a--)if(i===e[n=2*a]&&o===e[n+1])return a;return-1})),Te(Me.prototype,"length",(function(){return this._length})),U(Me.prototype,"map",(function(r,t){var e,n,i,o,a;if(!Oe(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,e=(i=new this.constructor(this._length))._buffer,o=0;o1)n=t,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=Be(e,0),o=1}for(;o1)n=t,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=Be(e,i-1),o=i-2}for(;o>=0;o--)n=r(n,Be(e,o),o,this);return n})),U(Me.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!Oe(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(e=this._length,r=this._buffer,n=_t(e/2),i=0;i1){if(!Ft(e=arguments[1]))throw new TypeError(k("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(ye(r)){if(e>=this._length)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));return n[e*=2]=xe(r),void(n[e+1]=Ve(r))}if(Oe(r)){if(e+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r._buffer,l=n.byteOffset+e*Le,t.buffer===n.buffer&&t.byteOffsetl){for(i=new Tr(t.length),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r,l=n.byteOffset+e*Le,t.buffer===n.buffer&&t.byteOffsetl){for(i=new Tr(a),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(e*=2,f=0;fu&&(t=u)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*Le):(i=t-r,e=n.byteOffset+r*Le),new this.constructor(n.buffer,e,i<0?0:i)})),U(Me.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!Oe(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(0===arguments.length)n=[];else{if(!Nt(r)&&!Wt(r))throw new TypeError(k("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Pt(t))throw new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e)return{done:!0};return{value:Be(i,o),done:!1}})),U(r,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(r,_e,(function(){return t.values()})),r})),U(Me.prototype,"with",(function(r,t){var e,n,i;if(!Oe(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Tt(r))throw new TypeError(k("invalid argument. First argument must be an integer. Value: `%s`.",r));if(i=this._length,r<0&&(r+=i),r<0||r>=i)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!ye(t))throw new TypeError(k("invalid argument. Second argument must be a complex number. Value: `%s`.",t));return(e=(n=new this.constructor(this._buffer))._buffer)[2*r]=xe(t),e[2*r+1]=Ve(t),n}));var Ue=2*dr.BYTES_PER_ELEMENT,De=Ee();function Ye(r){return r instanceof qe||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function We(r){return r===qe||"Complex64Array"===r.name}function ze(r,t){return new fe(r[t*=2],r[t+1])}function qe(){var r,t,e,n;if(t=arguments.length,!(this instanceof qe))return 0===t?new qe:1===t?new qe(arguments[0]):2===t?new qe(arguments[0],arguments[1]):new qe(arguments[0],arguments[1],arguments[2]);if(0===t)e=new dr(0);else if(1===t)if(Ft(arguments[0]))e=new dr(2*arguments[0]);else if(Rt(arguments[0]))if((n=(e=arguments[0]).length)&&or(e)&&ye(e[0])){if(e=function(r,t){var e,n,i,o;for(e=t.length,o=0,i=0;ie.byteLength-r)throw new RangeError(k("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*Ue));e=new dr(e,r,2*n)}}return U(this,"_buffer",e),U(this,"_length",e.length/2),this}function $e(r){var t,e;for(t=[];!(e=r.next()).done;)t.push(Ht(e.value));return t}U(qe,"BYTES_PER_ELEMENT",Ue),U(qe,"name","Complex128Array"),U(qe,"from",(function(r){var t,e,n,i,o,a,u,f,l,s,c,h;if(!ue(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!We(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((e=arguments.length)>1){if(!ue(n=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(Ye(r)){if(f=r.length,n){for(o=(i=new this(f))._buffer,h=0,c=0;c=2))throw new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Rt(r)){if(n){for(f=r.length,u=r.get&&r.set?H("default"):z("default"),c=0;c=2))throw new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Pt(r)&&De&&ue(r[_e])){if(!ue((o=r[_e]()).next))throw new TypeError(k("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(a=n?function(r,t,e){var n,i,o,a;for(n=[],a=-1;!(i=r.next()).done;)if(a+=1,It(o=t.call(e,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!ye(o))return new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(Pe(o),Ne(o))}return n}(o,n,t):Ce(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,c=0;c=this._length))return ze(this._buffer,r)})),Te(qe.prototype,"buffer",(function(){return this._buffer.buffer})),Te(qe.prototype,"byteLength",(function(){return this._buffer.byteLength})),Te(qe.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),U(qe.prototype,"BYTES_PER_ELEMENT",qe.BYTES_PER_ELEMENT),U(qe.prototype,"copyWithin",(function(r,t){if(!Ye(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*t):this._buffer.copyWithin(2*r,2*t,2*arguments[2]),this})),U(qe.prototype,"entries",(function(){var r,t,e,n,i,o,a;if(!Ye(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return t=this,r=this._buffer,n=this._length,o=-1,a=-2,U(e={},"next",(function(){var t;if(o+=1,i||o>=n)return{done:!0};return t=new fe(r[a+=2],r[a+1]),{value:[o,t],done:!1}})),U(e,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(e,_e,(function(){return t.entries()})),e})),U(qe.prototype,"every",(function(r,t){var e,n;if(!Ye(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Tt(e))throw new TypeError(k("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(a=Pe(r),u=Ne(r),f=t;f=0;n--)if(i=ze(e,n),r.call(t,i,n,this))return i})),U(qe.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!Ye(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=this._length-1;n>=0;n--)if(i=ze(e,n),r.call(t,i,n,this))return n;return-1})),U(qe.prototype,"forEach",(function(r,t){var e,n,i;if(!Ye(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return ze(this._buffer,r)})),Te(qe.prototype,"length",(function(){return this._length})),U(qe.prototype,"includes",(function(r,t){var e,n,i,o,a;if(!Ye(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ye(r))throw new TypeError(k("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Pe(r),o=Ne(r),e=this._buffer,a=t;a1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Pe(r),o=Ne(r),e=this._buffer,a=t;a=e)return{done:!0};return{value:i,done:!1}})),U(t,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(t,_e,(function(){return r.keys()})),t})),U(qe.prototype,"lastIndexOf",(function(r,t){var e,n,i,o,a;if(!Ye(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ye(r))throw new TypeError(k("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=Pe(r),o=Ne(r),e=this._buffer,a=t;a>=0;a--)if(i===e[n=2*a]&&o===e[n+1])return a;return-1})),U(qe.prototype,"map",(function(r,t){var e,n,i,o,a;if(!Ye(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,e=(i=new this.constructor(this._length))._buffer,o=0;o1)n=t,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=ze(e,0),o=1}for(;o1)n=t,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=ze(e,i-1),o=i-2}for(;o>=0;o--)n=r(n,ze(e,o),o,this);return n})),U(qe.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!Ye(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(e=this._length,r=this._buffer,n=_t(e/2),i=0;i1){if(!Ft(e=arguments[1]))throw new TypeError(k("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(ye(r)){if(e>=this._length)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));return n[e*=2]=Pe(r),void(n[e+1]=Ne(r))}if(Ye(r)){if(e+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r._buffer,l=n.byteOffset+e*Ue,t.buffer===n.buffer&&t.byteOffsetl){for(i=new dr(t.length),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r,l=n.byteOffset+e*Ue,t.buffer===n.buffer&&t.byteOffsetl){for(i=new dr(a),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(e*=2,f=0;fu&&(t=u)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*Ue):(i=t-r,e=n.byteOffset+r*Ue),new this.constructor(n.buffer,e,i<0?0:i)})),U(qe.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!Ye(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(0===arguments.length)n=[];else{if(!Yt(r)&&!Wt(r))throw new TypeError(k("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Pt(t))throw new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e)return{done:!0};return{value:ze(i,o),done:!1}})),U(r,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(r,_e,(function(){return t.values()})),r})),U(qe.prototype,"with",(function(r,t){var e,n,i;if(!Ye(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Tt(r))throw new TypeError(k("invalid argument. First argument must be an integer. Value: `%s`.",r));if(i=this._length,r<0&&(r+=i),r<0||r>=i)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!ye(t))throw new TypeError(k("invalid argument. Second argument must be a complex number. Value: `%s`.",t));return(e=(n=new this.constructor(this._buffer))._buffer)[2*r]=Pe(t),e[2*r+1]=Ne(t),n}));var Ge=et.BYTES_PER_ELEMENT,He=Ee();function Je(r){return"object"==typeof r&&null!==r&&"BooleanArray"===r.constructor.name&&r.BYTES_PER_ELEMENT===Ge}function Qe(r){return r===Xe}function Xe(){var r,t,e,n,i;if(t=arguments.length,!(this instanceof Xe))return 0===t?new Xe:1===t?new Xe(arguments[0]):2===t?new Xe(arguments[0],arguments[1]):new Xe(arguments[0],arguments[1],arguments[2]);if(0===t)e=new et(0);else if(1===t)if(Ft(i=arguments[0]))e=new et(i);else if(Rt(i))e=function(r,t){var e,n;for(e=t.length,n=0;ne.byteLength-r)throw new RangeError(k("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*Ge));e=new et(e,r,n)}}return U(this,"_buffer",e),U(this,"_length",e.length),this}U(Xe,"BYTES_PER_ELEMENT",Ge),U(Xe,"name","BooleanArray"),U(Xe,"from",(function(r){var t,e,n,i,o,a,u,f,l;if(!ue(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!Qe(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if((e=arguments.length)>1){if(!ue(n=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(Rt(r)){if(n){for(f=r.length,u=r.get&&r.set?H("default"):z("default"),o=(i=new this(f))._buffer,l=0;l=e))return Ht(t[r])})),Te(Xe.prototype,"buffer",(function(){return this._buffer.buffer})),Te(Xe.prototype,"byteLength",(function(){return this._buffer.byteLength})),Te(Xe.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),U(Xe.prototype,"BYTES_PER_ELEMENT",Xe.BYTES_PER_ELEMENT),U(Xe.prototype,"copyWithin",(function(r,t){if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return 2===arguments.length?this._buffer.copyWithin(r,t):this._buffer.copyWithin(r,t,arguments[2]),this})),U(Xe.prototype,"entries",(function(){var r,t,e,n,i,o;if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return r=this,n=this._buffer,e=this._length,o=-1,U(t={},"next",(function(){if(o+=1,i||o>=e)return{done:!0};return{value:[o,Ht(n[o])],done:!1}})),U(t,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(t,_e,(function(){return r.entries()})),t})),U(Xe.prototype,"every",(function(r,t){var e,n;if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Vt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Vt(e))throw new TypeError(k("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(o=r?1:0,a=t;a=0;i--)if(n=Ht(e[i]),r.call(t,n,i,this))return n})),U(Xe.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,i=this._length-1;i>=0;i--)if(n=Ht(e[i]),r.call(t,n,i,this))return i;return-1})),U(Xe.prototype,"forEach",(function(r,t){var e,n;if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return Ht(this._buffer[r])})),U(Xe.prototype,"includes",(function(r,t){var e,n;if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!Gt(r))throw new TypeError(k("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!Vt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(e=this._buffer,n=t;n1){if(!Vt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(e=this._buffer,n=t;n0){if(!Nt(r))throw new TypeError(k("invalid argument. First argument must be a string. Value: `%s`.",r))}else r=",";for(t=this._buffer,e=[],n=0;n=e)return{done:!0};return{value:i,done:!1}})),U(t,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(t,_e,(function(){return r.keys()})),t})),U(Xe.prototype,"lastIndexOf",(function(r,t){var e,n;if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!Gt(r))throw new TypeError(k("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!Vt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(e=this._buffer,n=t;n>=0;n--)if(r===Ht(e[n]))return n;return-1})),Te(Xe.prototype,"length",(function(){return this._length})),U(Xe.prototype,"map",(function(r,t){var e,n,i,o;if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ue(r))throw new TypeError("invalid argument. First argument must be a function. Value: `%s`.",r);for(i=this._buffer,e=(n=new this.constructor(this._length))._buffer,o=0;o1)i=t,o=0;else{if(0===n)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");i=Ht(e[0]),o=1}for(;o1)i=t,o=n-1;else{if(0===n)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");i=Ht(e[n-1]),o=n-2}for(;o>=0;o--)i=r(i,Ht(e[o]),o,this);return i})),U(Xe.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");for(r=this._buffer,e=this._length,n=_t(e/2),i=0;i1){if(!Ft(e=arguments[1]))throw new TypeError(k("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(Rt(r)){if(e+(o=r.length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=Je(r)?r._buffer:r,u=n.byteOffset+e*Ge,t.buffer===n.buffer&&t.byteOffsetu){for(i=new et(t.length),a=0;a=this._length)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));n[e]=r?1:0}})),U(Xe.prototype,"slice",(function(r,t){var e,n,i,o,a,u;if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(o=this._buffer,a=this._length,0===arguments.length)r=0,t=a;else{if(!Vt(r))throw new TypeError(k("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=a)<0&&(r=0),1===arguments.length)t=a;else{if(!Vt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0?(t+=a)<0&&(t=0):t>a&&(t=a)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*Ge):(i=t-r,e=n.byteOffset+r*Ge),new this.constructor(n.buffer,e,i<0?0:i)})),U(Xe.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(0===arguments.length)n=[];else{if(!Nt(r)&&!Wt(r))throw new TypeError(k("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Pt(t))throw new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e)return{done:!0};return{value:Ht(i[o]),done:!1}})),U(r,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(r,_e,(function(){return t.values()})),r})),U(Xe.prototype,"with",(function(r,t){var e,n;if(!Je(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!Vt(r))throw new TypeError(k("invalid argument. First argument must be an integer. Value: `%s`.",r));if(n=this._length,r<0&&(r+=n),r<0||r>=n)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!Gt(t))throw new TypeError(k("invalid argument. Second argument must be a boolean. Value: `%s`.",t));return(e=new this.constructor(this._buffer))._buffer[r]=t?1:0,e}));var Ze=[dr,Tr,Mr,jr,Jr,Yr,gt,et,ut,Me,qe,Xe],Ke=["float64","float32","int32","uint32","int16","uint16","int8","uint8","uint8c","complex64","complex128","bool"],rn=Ke.length;function tn(r){var t;if(or(r))return"generic";if(fr(r))return null;for(t=0;t>>0}function Vn(r,t,e){return n=pe(r),i=pe(t),(mn(n)||mn(i)?NaN:(o=_n(n),a=_n(i),Tn((o=xn(o))-(a=xn(a)))))<=e;var n,i,o,a}function An(r){return r!=r}var Sn=2147483648,Fn="function"==typeof Uint16Array?Uint16Array:void 0;var jn,kn=Ur()?Fn:function(){throw new Error("not implemented")},Ln={uint16:kn,uint8:ln};(jn=new Ln.uint16(1))[0]=4660;var In,On,Rn=52===new Ln.uint8(jn.buffer)[0];!0===Rn?(In=1,On=0):(In=0,On=1);var Bn={HIGH:In,LOW:On},Mn=new Fe(1),Pn=new wn(Mn.buffer),Nn=Bn.HIGH,Cn=Bn.LOW;function Un(r,t,e,n){return Mn[0]=r,t[n]=Pn[Nn],t[n+e]=Pn[Cn],t}function Dn(r){return Un(r,[0,0],1,0)}U(Dn,"assign",Un);var Yn=new wn(2),Wn=new wn(2),zn=new wn(2),qn=4294967296;function $n(r){return r[0]&Sn?r=function(r){r[0]=~r[0],r[1]=~r[1],r[1]+=1,0===r[1]&&(r[0]+=1);return r}(r):r[0]|=Sn,r}function Gn(r,t,e){var n,i,o,a;return n=r[0],o=r[1],i=t[0],o>=(a=t[1])?(e[0]=n-i,e[1]=o-a):(e[0]=n-i-1,e[1]=o+qn-a),e}function Hn(r,t,e){return i=t,(An(n=r)||An(i)?NaN:(a=Un(n,Yn,1,0),u=Un(i,Wn,1,0),a=$n(a),u=$n(u),s=u,0==(o=(l=a)[0]>s[0]?1:l[0]s[1]?1:l[1]0&&t.push("generic"),t)}var si=yn(li("boolean")),ci=["little-endian","big-endian"];function hi(){return ci.slice()}var pi=yn(hi()),gi=yn(li("complex_floating_point")),yi=8,mi=16;function di(r){return"object"==typeof r&&null!==r&&("Complex128Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===mi||"Complex64Array"===r.constructor.name&&r.BYTES_PER_ELEMENT===yi)}var vi=yn(li()),wi=yn(li("floating_point")),bi=yn(li("integer"));function Ei(r){return Object.keys(Object(r))}var _i,Ti=void 0!==Object.keys;function xi(r){return"[object Arguments]"===ir(r)}_i=function(){return xi(arguments)}();var Vi=_i;function Ai(r){return yt(r)&&An(r)}function Si(r){return wt(r)&&An(r.valueOf())}function Fi(r){return Ai(r)||Si(r)}U(Fi,"isPrimitive",Ai),U(Fi,"isObject",Si);var ji=Object.prototype.propertyIsEnumerable;var ki=!ji.call("beep","0");function Li(r,t){var e;return null!=r&&(!(e=ji.call(r,t))&&ki&&Yt(r)?!Ai(t=+t)&&Vt(t)&&t>=0&&t=0&&r.length<=Vr&&tr(r,"callee")&&!Li(r,"callee")},Oi=Array.prototype.slice;var Ri=Li((function(){}),"prototype"),Bi=!Li({toString:null},"toString");function Mi(r,t,e){var n,i;if(!Rt(r)&&!Nt(r))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(0===(n=r.length))return-1;if(3===arguments.length){if(!Vt(e))throw new TypeError(k("invalid argument. Third argument must be an integer. Value: `%s`.",e));if(e>=0){if(e>=n)return-1;i=e}else(i=n+e)<0&&(i=0)}else i=0;if(Fi(t)){for(;i0&&!tr(r,"0"))for(u=0;u0&&t.push("generic"),t)}function no(){return{bool:0,int8:1,uint8:2,uint8c:3,int16:4,uint16:5,int32:6,uint32:7,int64:8,uint64:9,float16:10,float32:11,float64:12,complex32:13,complex64:14,complex128:15,binary:16,generic:17,notype:18,userdefined_type:256}}U(eo,"enum",no),function(r,t){var e,n,i;for(e=qi(t),i=0;i1){if(!Xi(t))throw new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t));if(tr(t,"duplicates")&&!Gt(l=t.duplicates))throw new TypeError(k("invalid option. `%s` option must be a boolean. Option: `%s`.","duplicates",l))}if(n=(e=qi(r)).length,a={},l)for(f=0;f0}var go,yo=yn(li("numeric")),mo=yn(li("real")),vo=yn(li("real_floating_point")),wo={float64:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,bool:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,bool:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,bool:1,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,bool:0,generic:1}};function bo(r){return 0===arguments.length?function(){var r,t,e,n,i,o,a,u,f;for(e={},t=(r=qi(wo)).length,f=0;f0}var To,xo={float64:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},float32:{float64:1,float32:1,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},int32:{float64:1,float32:0,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:0,bool:0,generic:1},int16:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},int8:{float64:1,float32:1,int32:1,int16:1,int8:1,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:1},uint32:{float64:1,float32:0,int32:0,int16:0,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:0,bool:0,generic:1},uint16:{float64:1,float32:1,int32:1,int16:0,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,bool:0,generic:1},uint8:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,bool:0,generic:1},uint8c:{float64:1,float32:1,int32:1,int16:1,int8:0,uint32:1,uint16:1,uint8:1,uint8c:1,complex128:1,complex64:1,bool:0,generic:1},complex128:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:0},complex64:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:1,complex64:1,bool:0,generic:0},bool:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,bool:1,generic:1},generic:{float64:0,float32:0,int32:0,int16:0,int8:0,uint32:0,uint16:0,uint8:0,uint8c:0,complex128:0,complex64:0,bool:0,generic:1}};function Vo(r){return 0===arguments.length?function(){var r,t,e,n,i,o,a,u,f;for(e={},t=(r=qi(xo)).length,f=0;ft?r:t}function Lo(r,t){return r0})),C(jo,"isSignedIntegerDataType",So),C(jo,"isSortedAscending",(function(r){var t,e,n,i,o,a;if(n=tn(r),e=Y(r)?H(n):z(n),0===(t=r.length))return!1;for(i=e(r,0),a=1;a(o=e(r,a)))return!1;i=o}return!0})),C(jo,"isUnsignedIntegerDataType",Fo);var Bo={};function Mo(r,t,e,n,i,o,a){var u,f,l;if(u=i[o],(f=o+1)!==n)for(l=0;l=0;l--)if(!((s=u-a+l)<0)){if(f=t[s],0!==(i=e[l])&&i0?r-1:r+1)}function Do(r){return r===wr||r===Et}C(Bo,"filled2dBy",(function(r,t,e,n,i,o){var a,u,f,l,s,c;for(l=r[0],f=r[1],a=[],c=0;c=c&&s<=c+t||s<=c&&c<=s+e?u.push(i.call(o,[c,s])):u.push(n);a.push(u)}return a})),C(Bo,"toCompact",(function(r,t,e,n){var i,o,a,u,f,l,s;if(a=r.length,u=r[0].length,n){for(i=Ro([u,t+e+1]),l=0;l>>0,zo[0]}function Go(r){return 0|r}var Ho,Jo,Qo=2147483647,Xo=!0===Rn?1:0,Zo=new Fe(1),Ko=new wn(Zo.buffer);function ra(r){return Zo[0]=r,Ko[Xo]}!0===Rn?(Ho=1,Jo=0):(Ho=0,Jo=1);var ta={HIGH:Ho,LOW:Jo},ea=new Fe(1),na=new wn(ea.buffer),ia=ta.HIGH,oa=ta.LOW;function aa(r,t){return na[ia]=r,na[oa]=t,ea[0]}var ua=[0,0];function fa(r,t){var e,n;return Dn.assign(r,ua,1,0),e=ua[0],e&=Qo,n=ra(t),aa(e|=n&=Sn,ua[1])}var la=1072693247,sa=1e300,ca=1e-300;var ha=!0===Rn?1:0,pa=new Fe(1),ga=new wn(pa.buffer);function ya(r,t){return pa[0]=r,ga[ha]=t>>>0,pa[0]}var ma=1023,da=20;var va=1048575,wa=1048576,ba=1072693248,Ea=536870912,_a=524288,Ta=9007199254740992,xa=.9617966939259756,Va=.9617967009544373,Aa=-7.028461650952758e-9,Sa=[1,1.5],Fa=[0,.5849624872207642],ja=[0,1.350039202129749e-8];var ka=1.4426950408889634,La=1.4426950216293335,Ia=1.9259629911266175e-8;var Oa=1023,Ra=-1023,Ba=-1074,Ma=22250738585072014e-324,Pa=4503599627370496;function Na(r,t,e,n){return An(r)||Do(r)?(t[n]=r,t[n+e]=0,t):0!==r&&Tn(r)>>20)-ma|0}(r),tOa?r<0?Et:wr:(t<=Ra?(t+=52,n=Ua):n=1,Dn.assign(r,Wa,1,0),e=Wa[0],e&=Da,n*aa(e|=t+ma<<20,Wa[1])))}var qa=.6931471805599453,$a=1048575;var Ga=1048576,Ha=1071644672,Ja=.6931471824645996,Qa=-1.904654299957768e-9;var Xa=1072693247,Za=1105199104,Ka=1139802112,ru=1083179008,tu=1072693248,eu=1083231232,nu=3230714880,iu=31,ou=1e300,au=1e-300,uu=8008566259537294e-32,fu=[0,0],lu=[0,0];function su(r,t){var e,n,i,o,a,u,f,l,s,c,h,p,g,y;if(An(r)||An(t))return NaN;if(Dn.assign(t,fu,1,0),a=fu[0],0===fu[1]){if(0===t)return 1;if(1===t)return r;if(-1===t)return 1/r;if(.5===t)return Yo(r);if(-.5===t)return 1/Yo(r);if(2===t)return r*r;if(3===t)return r*r*r;if(4===t)return(r*=r)*r;if(Do(t))return function(r,t){return-1===r?(r-r)/(r-r):1===r?1:Tn(r)<1==(t===wr)?0:wr}(r,t)}if(Dn.assign(r,fu,1,0),o=fu[0],0===fu[1]){if(0===o)return function(r,t){return t===Et?wr:t===wr?0:t>0?Uo(t)?r:0:Uo(t)?fa(wr,r):wr}(r,t);if(1===r)return 1;if(-1===r&&Uo(t))return-1;if(Do(r))return r===Et?su(-0,-t):t<0?0:wr}if(r<0&&!1===Tt(t))return(r-r)/(r-r);if(i=Tn(r),e=o&Qo|0,n=a&Qo|0,f=a>>>iu|0,u=(u=o>>>iu|0)&&Uo(t)?-1:1,n>Za){if(n>Ka)return function(r,t){return(ra(r)&Qo)<=la?t<0?sa*sa:ca*ca:t>0?sa*sa:ca*ca}(r,t);if(etu)return 0===f?u*ou*ou:u*au*au;h=function(r,t){var e,n,i,o,a,u,f;return o=(i=t-1)*i*(0===(f=i)?.5:.5+f*(.25*f-.3333333333333333)),e=(u=i*Ia-o*ka)-((n=$o(n=(a=La*i)+u,0))-a),r[0]=n,r[1]=e,r}(lu,i)}else h=function(r,t,e){var n,i,o,a,u,f,l,s,c,h,p,g,y,m,d,v,w,b,E,_,T;return b=0,e>da)-ma|0,e=(E=e&va|0)|ba|0,E<=235662?_=0:E<767610?_=1:(_=0,b+=1,e-=wa),a=$o(i=(v=(t=ya(t,e))-(l=Sa[_]))*(w=1/(t+l)),0),n=(e>>1|Ea)+_a,f=ya(0,n+=_<<18),d=(o=i*i)*o*(0===(T=o)?.5999999999999946:.5999999999999946+T*(.4285714285785502+T*(.33333332981837743+T*(.272728123808534+T*(.23066074577556175+.20697501780033842*T))))),f=$o(f=3+(o=a*a)+(d+=(u=w*(v-a*f-a*(t-(f-l))))*(a+i)),0),c=$o(c=(v=a*f)+(w=u*f+(d-(f-3-o))*i),0),h=Va*c,y=(p=Aa*c+(w-(c-v))*xa+ja[_])-((g=$o(g=h+p+(s=Fa[_])+(m=b),0))-m-s-h),r[0]=g,r[1]=y,r}(lu,i,e);if(p=(c=(t-(l=$o(t,0)))*h[0]+t*h[1])+(s=l*h[0]),Dn.assign(p,fu,1,0),g=Go(fu[0]),y=Go(fu[1]),g>=ru){if(0!=(g-ru|y))return u*ou*ou;if(c+uu>p-s)return u*ou*ou}else if((g&Qo)>=eu){if(0!=(g-nu|y))return u*au*au;if(c<=p-s)return u*au*au}return p=function(r,t,e){var n,i,o,a,u,f,l,s,c,h;return c=((s=r&Qo|0)>>da)-ma|0,l=0,s>Ha&&(i=ya(0,((l=r+(Ga>>c+1)>>>0)&~($a>>(c=((l&Qo)>>da)-ma|0)))>>>0),l=(l&$a|Ga)>>da-c>>>0,r<0&&(l=-l),t-=i),r=Go(r=ra(f=1-((f=(o=(i=$o(i=e+t,0))*Ja)+(a=(e-(i-t))*qa+i*Qa))*(n=f-(i=f*f)*(0===(h=i)?.16666666666666602:.16666666666666602+h*(h*(6613756321437934e-20+h*(4.1381367970572385e-8*h-16533902205465252e-22))-.0027777777777015593)))/(n-2)-((u=a-(f-o))+f*u)-f))),(r+=l<>>0)>>da<=0?za(f,l):ya(f,r)}(g,s,c),u*p}function cu(r,t){var e,n,i,o,a,u,f,l,s,c;if((u=r.length)<=0||t<=0)return[];for(e=hn(r),a=su(u,t),o=[],l=0;l=0;s--)c-=f=c%u,c/=u,o[s]=f;for(i=[],s=0;s=0&&a0?0:t-1;else if(n<0){if((n=t+n)<0){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};n=0}}else if(n>=t){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};n=o<0?t-1:t}if(null===i)i=o>0?t:null;else if(i<0){if((i=t+i)<0)if(o>0){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};i=0}else{if(e&&i<-1)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};i=null}}else if(i>t){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};i=t}return new Wu(n,i,o)}U(_u,"assign",(function(r,t,e){var n=un(r);return n.accessorProtocol?"complex128"===n.dtype?Tu(r,je(r,0),t,e):"complex64"===n.dtype?Tu(r,Ae(r,0),t,e):function(r,t,e){var n,i,o,a;for(n=r.data,i=r.accessors[1],a=e,o=0;a>=0&&a=0&&i0&&e>=n||t<0&&e<=n?0:qu((n-e)/t)}var Gu="function";function Hu(r){return typeof r.get===Gu&&typeof r.set===Gu}var Ju={float64:function(r,t){return r[t]},float32:function(r,t){return r[t]},int32:function(r,t){return r[t]},int16:function(r,t){return r[t]},int8:function(r,t){return r[t]},uint32:function(r,t){return r[t]},uint16:function(r,t){return r[t]},uint8:function(r,t){return r[t]},uint8c:function(r,t){return r[t]},generic:function(r,t){return r[t]},default:function(r,t){return r[t]}};function Qu(r){var t=Ju[r];return"function"==typeof t?t:Ju.default}var Xu={float64:function(r,t,e){r[t]=e},float32:function(r,t,e){r[t]=e},int32:function(r,t,e){r[t]=e},int16:function(r,t,e){r[t]=e},int8:function(r,t,e){r[t]=e},uint32:function(r,t,e){r[t]=e},uint16:function(r,t,e){r[t]=e},uint8:function(r,t,e){r[t]=e},uint8c:function(r,t,e){r[t]=e},generic:function(r,t,e){r[t]=e},default:function(r,t,e){r[t]=e}};function Zu(r){var t=Xu[r];return"function"==typeof t?t:Xu.default}var Ku={complex128:function(r,t){return r.get(t)},complex64:function(r,t){return r.get(t)},default:function(r,t){return r.get(t)}};function rf(r){var t=Ku[r];return"function"==typeof t?t:Ku.default}var tf={complex128:function(r,t,e){r.set(e,t)},complex64:function(r,t,e){r.set(e,t)},default:function(r,t,e){r.set(e,t)}};function ef(r){var t=tf[r];return"function"==typeof t?t:tf.default}var nf={Float32Array:"float32",Float64Array:"float64",Array:"generic",Int16Array:"int16",Int32Array:"int32",Int8Array:"int8",Uint16Array:"uint16",Uint32Array:"uint32",Uint8Array:"uint8",Uint8ClampedArray:"uint8c",Complex64Array:"complex64",Complex128Array:"complex128",BooleanArray:"bool"},of="function"==typeof Int32Array?Int32Array:void 0;var af=Rr()?of:function(){throw new Error("not implemented")},uf="function"==typeof Int16Array?Int16Array:void 0;var ff=Gr()?uf:function(){throw new Error("not implemented")},lf="function"==typeof Uint8ClampedArray?Uint8ClampedArray:void 0;var sf=ot()?lf:function(){throw new Error("not implemented")},cf="function"==typeof Int8Array?Int8Array:void 0;var hf=ht()?cf:function(){throw new Error("not implemented")};function pf(r){var t,e,n;for(t=[];!(e=r.next()).done;)if(It(n=e.value)&&n.length>=2)t.push(n[0],n[1]);else{if(!ye(n))return new TypeError(k("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));t.push(xe(n),Ve(n))}return t}var gf=2*ce.BYTES_PER_ELEMENT,yf=Ee();function mf(r){return r instanceof wf||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function df(r){return r===wf||"Complex128Array"===r.name}function vf(r,t){return new ge(r[t*=2],r[t+1])}function wf(){var r,t,e,n;if(t=arguments.length,!(this instanceof wf))return 0===t?new wf:1===t?new wf(arguments[0]):2===t?new wf(arguments[0],arguments[1]):new wf(arguments[0],arguments[1],arguments[2]);if(0===t)e=new ce(0);else if(1===t)if(Ft(arguments[0]))e=new ce(2*arguments[0]);else if(Rt(arguments[0]))if((n=(e=arguments[0]).length)&&or(e)&&ye(e[0])){if(e=function(r,t){var e,n,i,o;for(e=t.length,o=0,i=0;ie.byteLength-r)throw new RangeError(k("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*gf));e=new ce(e,r,2*n)}}return U(this,"_buffer",e),U(this,"_length",e.length/2),this}function bf(r){var t,e,n;for(t=[];!(e=r.next()).done;)if(It(n=e.value)&&n.length>=2)t.push(n[0],n[1]);else{if(!ye(n))return new TypeError(k("invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",n));t.push(Pe(n),Ne(n))}return t}U(wf,"BYTES_PER_ELEMENT",gf),U(wf,"name","Complex64Array"),U(wf,"from",(function(r){var t,e,n,i,o,a,u,f,l,s,c,h;if(!ue(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!df(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((e=arguments.length)>1){if(!ue(n=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(mf(r)){if(f=r.length,n){for(o=(i=new this(f))._buffer,h=0,c=0;c=2))throw new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Rt(r)){if(n){for(f=r.length,u=r.get&&r.set?rf("default"):Qu("default"),c=0;c=2))throw new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Pt(r)&&yf&&ue(r[_e])){if(!ue((o=r[_e]()).next))throw new TypeError(k("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(a=n?function(r,t,e){var n,i,o,a;for(n=[],a=-1;!(i=r.next()).done;)if(a+=1,It(o=t.call(e,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!ye(o))return new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(xe(o),Ve(o))}return n}(o,n,t):pf(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,c=0;c=this._length))return vf(this._buffer,r)})),Te(wf.prototype,"buffer",(function(){return this._buffer.buffer})),Te(wf.prototype,"byteLength",(function(){return this._buffer.byteLength})),Te(wf.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),U(wf.prototype,"BYTES_PER_ELEMENT",wf.BYTES_PER_ELEMENT),U(wf.prototype,"copyWithin",(function(r,t){if(!mf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*t):this._buffer.copyWithin(2*r,2*t,2*arguments[2]),this})),U(wf.prototype,"entries",(function(){var r,t,e,n,i,o;if(!mf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return r=this,n=this._buffer,e=this._length,o=-1,U(t={},"next",(function(){if(o+=1,i||o>=e)return{done:!0};return{value:[o,vf(n,o)],done:!1}})),U(t,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(t,_e,(function(){return r.entries()})),t})),U(wf.prototype,"every",(function(r,t){var e,n;if(!mf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Tt(e))throw new TypeError(k("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(a=xe(r),u=Ve(r),f=t;f=0;n--)if(i=vf(e,n),r.call(t,i,n,this))return i})),U(wf.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!mf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=this._length-1;n>=0;n--)if(i=vf(e,n),r.call(t,i,n,this))return n;return-1})),U(wf.prototype,"forEach",(function(r,t){var e,n,i;if(!mf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return vf(this._buffer,r)})),U(wf.prototype,"includes",(function(r,t){var e,n,i,o,a;if(!mf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ye(r))throw new TypeError(k("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=xe(r),o=Ve(r),e=this._buffer,a=t;a1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=xe(r),o=Ve(r),e=this._buffer,a=t;a=e)return{done:!0};return{value:i,done:!1}})),U(t,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(t,_e,(function(){return r.keys()})),t})),U(wf.prototype,"lastIndexOf",(function(r,t){var e,n,i,o,a;if(!mf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ye(r))throw new TypeError(k("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=xe(r),o=Ve(r),e=this._buffer,a=t;a>=0;a--)if(i===e[n=2*a]&&o===e[n+1])return a;return-1})),Te(wf.prototype,"length",(function(){return this._length})),U(wf.prototype,"map",(function(r,t){var e,n,i,o,a;if(!mf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,e=(i=new this.constructor(this._length))._buffer,o=0;o1)n=t,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=vf(e,0),o=1}for(;o1)n=t,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=vf(e,i-1),o=i-2}for(;o>=0;o--)n=r(n,vf(e,o),o,this);return n})),U(wf.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!mf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(e=this._length,r=this._buffer,n=_t(e/2),i=0;i1){if(!Ft(e=arguments[1]))throw new TypeError(k("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(ye(r)){if(e>=this._length)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));return n[e*=2]=xe(r),void(n[e+1]=Ve(r))}if(mf(r)){if(e+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r._buffer,l=n.byteOffset+e*gf,t.buffer===n.buffer&&t.byteOffsetl){for(i=new ce(t.length),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r,l=n.byteOffset+e*gf,t.buffer===n.buffer&&t.byteOffsetl){for(i=new ce(a),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(e*=2,f=0;fu&&(t=u)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*gf):(i=t-r,e=n.byteOffset+r*gf),new this.constructor(n.buffer,e,i<0?0:i)})),U(wf.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!mf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(0===arguments.length)n=[];else{if(!Nt(r)&&!Wt(r))throw new TypeError(k("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Pt(t))throw new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e)return{done:!0};return{value:vf(i,o),done:!1}})),U(r,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(r,_e,(function(){return t.values()})),r})),U(wf.prototype,"with",(function(r,t){var e,n,i;if(!mf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Tt(r))throw new TypeError(k("invalid argument. First argument must be an integer. Value: `%s`.",r));if(i=this._length,r<0&&(r+=i),r<0||r>=i)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!ye(t))throw new TypeError(k("invalid argument. Second argument must be a complex number. Value: `%s`.",t));return(e=(n=new this.constructor(this._buffer))._buffer)[2*r]=xe(t),e[2*r+1]=Ve(t),n}));var Ef=2*Fe.BYTES_PER_ELEMENT,_f=Ee();function Tf(r){return r instanceof Af||"object"==typeof r&&null!==r&&("Complex64Array"===r.constructor.name||"Complex128Array"===r.constructor.name)&&"number"==typeof r._length&&"object"==typeof r._buffer}function xf(r){return r===Af||"Complex64Array"===r.name}function Vf(r,t){return new fe(r[t*=2],r[t+1])}function Af(){var r,t,e,n;if(t=arguments.length,!(this instanceof Af))return 0===t?new Af:1===t?new Af(arguments[0]):2===t?new Af(arguments[0],arguments[1]):new Af(arguments[0],arguments[1],arguments[2]);if(0===t)e=new Fe(0);else if(1===t)if(Ft(arguments[0]))e=new Fe(2*arguments[0]);else if(Rt(arguments[0]))if((n=(e=arguments[0]).length)&&or(e)&&ye(e[0])){if(e=function(r,t){var e,n,i,o;for(e=t.length,o=0,i=0;ie.byteLength-r)throw new RangeError(k("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*Ef));e=new Fe(e,r,2*n)}}return U(this,"_buffer",e),U(this,"_length",e.length/2),this}function Sf(r){var t,e;for(t=[];!(e=r.next()).done;)t.push(Ht(e.value));return t}U(Af,"BYTES_PER_ELEMENT",Ef),U(Af,"name","Complex128Array"),U(Af,"from",(function(r){var t,e,n,i,o,a,u,f,l,s,c,h;if(!ue(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!xf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if((e=arguments.length)>1){if(!ue(n=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(Tf(r)){if(f=r.length,n){for(o=(i=new this(f))._buffer,h=0,c=0;c=2))throw new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Rt(r)){if(n){for(f=r.length,u=r.get&&r.set?rf("default"):Qu("default"),c=0;c=2))throw new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",s));o[h]=s[0],o[h+1]=s[1]}h+=2}return i}return new this(r)}if(Pt(r)&&_f&&ue(r[_e])){if(!ue((o=r[_e]()).next))throw new TypeError(k("invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.",r));if(a=n?function(r,t,e){var n,i,o,a;for(n=[],a=-1;!(i=r.next()).done;)if(a+=1,It(o=t.call(e,i.value,a))&&o.length>=2)n.push(o[0],o[1]);else{if(!ye(o))return new TypeError(k("invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.",o));n.push(Pe(o),Ne(o))}return n}(o,n,t):bf(o),a instanceof Error)throw a;for(o=(i=new this(f=a.length/2))._buffer,c=0;c=this._length))return Vf(this._buffer,r)})),Te(Af.prototype,"buffer",(function(){return this._buffer.buffer})),Te(Af.prototype,"byteLength",(function(){return this._buffer.byteLength})),Te(Af.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),U(Af.prototype,"BYTES_PER_ELEMENT",Af.BYTES_PER_ELEMENT),U(Af.prototype,"copyWithin",(function(r,t){if(!Tf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return 2===arguments.length?this._buffer.copyWithin(2*r,2*t):this._buffer.copyWithin(2*r,2*t,2*arguments[2]),this})),U(Af.prototype,"entries",(function(){var r,t,e,n,i,o,a;if(!Tf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");return t=this,r=this._buffer,n=this._length,o=-1,a=-2,U(e={},"next",(function(){var t;if(o+=1,i||o>=n)return{done:!0};return t=new fe(r[a+=2],r[a+1]),{value:[o,t],done:!1}})),U(e,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(e,_e,(function(){return t.entries()})),e})),U(Af.prototype,"every",(function(r,t){var e,n;if(!Tf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Tt(e))throw new TypeError(k("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(a=Pe(r),u=Ne(r),f=t;f=0;n--)if(i=Vf(e,n),r.call(t,i,n,this))return i})),U(Af.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!Tf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=this._length-1;n>=0;n--)if(i=Vf(e,n),r.call(t,i,n,this))return n;return-1})),U(Af.prototype,"forEach",(function(r,t){var e,n,i;if(!Tf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return Vf(this._buffer,r)})),Te(Af.prototype,"length",(function(){return this._length})),U(Af.prototype,"includes",(function(r,t){var e,n,i,o,a;if(!Tf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ye(r))throw new TypeError(k("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Pe(r),o=Ne(r),e=this._buffer,a=t;a1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(i=Pe(r),o=Ne(r),e=this._buffer,a=t;a=e)return{done:!0};return{value:i,done:!1}})),U(t,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(t,_e,(function(){return r.keys()})),t})),U(Af.prototype,"lastIndexOf",(function(r,t){var e,n,i,o,a;if(!Tf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ye(r))throw new TypeError(k("invalid argument. First argument must be a complex number. Value: `%s`.",r));if(arguments.length>1){if(!Tt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(i=Pe(r),o=Ne(r),e=this._buffer,a=t;a>=0;a--)if(i===e[n=2*a]&&o===e[n+1])return a;return-1})),U(Af.prototype,"map",(function(r,t){var e,n,i,o,a;if(!Tf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(n=this._buffer,e=(i=new this.constructor(this._length))._buffer,o=0;o1)n=t,o=0;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=Vf(e,0),o=1}for(;o1)n=t,o=i-1;else{if(0===i)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");n=Vf(e,i-1),o=i-2}for(;o>=0;o--)n=r(n,Vf(e,o),o,this);return n})),U(Af.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!Tf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");for(e=this._length,r=this._buffer,n=_t(e/2),i=0;i1){if(!Ft(e=arguments[1]))throw new TypeError(k("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(ye(r)){if(e>=this._length)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));return n[e*=2]=Pe(r),void(n[e+1]=Ne(r))}if(Tf(r)){if(e+(a=r._length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r._buffer,l=n.byteOffset+e*Ef,t.buffer===n.buffer&&t.byteOffsetl){for(i=new Fe(t.length),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=r,l=n.byteOffset+e*Ef,t.buffer===n.buffer&&t.byteOffsetl){for(i=new Fe(a),f=0;fthis._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");for(e*=2,f=0;fu&&(t=u)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*Ef):(i=t-r,e=n.byteOffset+r*Ef),new this.constructor(n.buffer,e,i<0?0:i)})),U(Af.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!Tf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(0===arguments.length)n=[];else{if(!Yt(r)&&!Wt(r))throw new TypeError(k("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Pt(t))throw new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e)return{done:!0};return{value:Vf(i,o),done:!1}})),U(r,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(r,_e,(function(){return t.values()})),r})),U(Af.prototype,"with",(function(r,t){var e,n,i;if(!Tf(this))throw new TypeError("invalid invocation. `this` is not a complex number array.");if(!Tt(r))throw new TypeError(k("invalid argument. First argument must be an integer. Value: `%s`.",r));if(i=this._length,r<0&&(r+=i),r<0||r>=i)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!ye(t))throw new TypeError(k("invalid argument. Second argument must be a complex number. Value: `%s`.",t));return(e=(n=new this.constructor(this._buffer))._buffer)[2*r]=Pe(t),e[2*r+1]=Ne(t),n}));var Ff=ln.BYTES_PER_ELEMENT,jf=Ee();function kf(r){return"object"==typeof r&&null!==r&&"BooleanArray"===r.constructor.name&&r.BYTES_PER_ELEMENT===Ff}function Lf(r){return r===If}function If(){var r,t,e,n,i;if(t=arguments.length,!(this instanceof If))return 0===t?new If:1===t?new If(arguments[0]):2===t?new If(arguments[0],arguments[1]):new If(arguments[0],arguments[1],arguments[2]);if(0===t)e=new ln(0);else if(1===t)if(Ft(i=arguments[0]))e=new ln(i);else if(Rt(i))e=function(r,t){var e,n;for(e=t.length,n=0;ne.byteLength-r)throw new RangeError(k("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",n*Ff));e=new ln(e,r,n)}}return U(this,"_buffer",e),U(this,"_length",e.length),this}U(If,"BYTES_PER_ELEMENT",Ff),U(If,"name","BooleanArray"),U(If,"from",(function(r){var t,e,n,i,o,a,u,f,l;if(!ue(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!Lf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if((e=arguments.length)>1){if(!ue(n=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be a function. Value: `%s`.",n));e>2&&(t=arguments[2])}if(Rt(r)){if(n){for(f=r.length,u=r.get&&r.set?rf("default"):Qu("default"),o=(i=new this(f))._buffer,l=0;l=e))return Ht(t[r])})),Te(If.prototype,"buffer",(function(){return this._buffer.buffer})),Te(If.prototype,"byteLength",(function(){return this._buffer.byteLength})),Te(If.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),U(If.prototype,"BYTES_PER_ELEMENT",If.BYTES_PER_ELEMENT),U(If.prototype,"copyWithin",(function(r,t){if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return 2===arguments.length?this._buffer.copyWithin(r,t):this._buffer.copyWithin(r,t,arguments[2]),this})),U(If.prototype,"entries",(function(){var r,t,e,n,i,o;if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");return r=this,n=this._buffer,e=this._length,o=-1,U(t={},"next",(function(){if(o+=1,i||o>=e)return{done:!0};return{value:[o,Ht(n[o])],done:!1}})),U(t,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(t,_e,(function(){return r.entries()})),t})),U(If.prototype,"every",(function(r,t){var e,n;if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n1){if(!Vt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(t<0&&(t+=i)<0&&(t=0),arguments.length>2){if(!Vt(e))throw new TypeError(k("invalid argument. Third argument must be an integer. Value: `%s`.",e));e<0&&(e+=i)<0&&(e=0),e>i&&(e=i)}else e=i}else t=0,e=i;for(o=r?1:0,a=t;a=0;i--)if(n=Ht(e[i]),r.call(t,n,i,this))return n})),U(If.prototype,"findLastIndex",(function(r,t){var e,n,i;if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,i=this._length-1;i>=0;i--)if(n=Ht(e[i]),r.call(t,n,i,this))return i;return-1})),U(If.prototype,"forEach",(function(r,t){var e,n;if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ue(r))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",r));for(e=this._buffer,n=0;n=this._length))return Ht(this._buffer[r])})),U(If.prototype,"includes",(function(r,t){var e,n;if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!Gt(r))throw new TypeError(k("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!Vt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(e=this._buffer,n=t;n1){if(!Vt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0&&(t+=this._length)<0&&(t=0)}else t=0;for(e=this._buffer,n=t;n0){if(!Nt(r))throw new TypeError(k("invalid argument. First argument must be a string. Value: `%s`.",r))}else r=",";for(t=this._buffer,e=[],n=0;n=e)return{done:!0};return{value:i,done:!1}})),U(t,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(t,_e,(function(){return r.keys()})),t})),U(If.prototype,"lastIndexOf",(function(r,t){var e,n;if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!Gt(r))throw new TypeError(k("invalid argument. First argument must be a boolean. Value: `%s`.",r));if(arguments.length>1){if(!Vt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t>=this._length?t=this._length-1:t<0&&(t+=this._length)}else t=this._length-1;for(e=this._buffer,n=t;n>=0;n--)if(r===Ht(e[n]))return n;return-1})),Te(If.prototype,"length",(function(){return this._length})),U(If.prototype,"map",(function(r,t){var e,n,i,o;if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!ue(r))throw new TypeError("invalid argument. First argument must be a function. Value: `%s`.",r);for(i=this._buffer,e=(n=new this.constructor(this._length))._buffer,o=0;o1)i=t,o=0;else{if(0===n)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");i=Ht(e[0]),o=1}for(;o1)i=t,o=n-1;else{if(0===n)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");i=Ht(e[n-1]),o=n-2}for(;o>=0;o--)i=r(i,Ht(e[o]),o,this);return i})),U(If.prototype,"reverse",(function(){var r,t,e,n,i,o;if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");for(r=this._buffer,e=this._length,n=_t(e/2),i=0;i1){if(!Ft(e=arguments[1]))throw new TypeError(k("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",e))}else e=0;if(Rt(r)){if(e+(o=r.length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(t=kf(r)?r._buffer:r,u=n.byteOffset+e*Ff,t.buffer===n.buffer&&t.byteOffsetu){for(i=new ln(t.length),a=0;a=this._length)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%u`.",e));n[e]=r?1:0}})),U(If.prototype,"slice",(function(r,t){var e,n,i,o,a,u;if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(o=this._buffer,a=this._length,0===arguments.length)r=0,t=a;else{if(!Vt(r))throw new TypeError(k("invalid argument. First argument must be an integer. Value: `%s`.",r));if(r<0&&(r+=a)<0&&(r=0),1===arguments.length)t=a;else{if(!Vt(t))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));t<0?(t+=a)<0&&(t=0):t>a&&(t=a)}}for(e=ri&&(t=i)}}return r>=i?(i=0,e=n.byteLength):r>=t?(i=0,e=n.byteOffset+r*Ff):(i=t-r,e=n.byteOffset+r*Ff),new this.constructor(n.buffer,e,i<0?0:i)})),U(If.prototype,"toLocaleString",(function(r,t){var e,n,i,o,a;if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(0===arguments.length)n=[];else{if(!Nt(r)&&!Wt(r))throw new TypeError(k("invalid argument. First argument must be a string or an array of strings. Value: `%s`.",r));n=r}if(arguments.length<2)e={};else{if(!Pt(t))throw new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t));e=t}for(o=this._buffer,i=[],a=0;a=e)return{done:!0};return{value:Ht(i[o]),done:!1}})),U(r,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(r,_e,(function(){return t.values()})),r})),U(If.prototype,"with",(function(r,t){var e,n;if(!kf(this))throw new TypeError("invalid invocation. `this` is not a boolean array.");if(!Vt(r))throw new TypeError(k("invalid argument. First argument must be an integer. Value: `%s`.",r));if(n=this._length,r<0&&(r+=n),r<0||r>=n)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%s`.",r));if(!Gt(t))throw new TypeError(k("invalid argument. Second argument must be a boolean. Value: `%s`.",t));return(e=new this.constructor(this._buffer))._buffer[r]=t?1:0,e}));var Of=[Fe,ce,af,wn,ff,kn,hf,ln,sf,wf,Af,If],Rf=["float64","float32","int32","uint32","int16","uint16","int8","uint8","uint8c","complex64","complex128","bool"],Bf=Rf.length;function Mf(r){var t;if(or(r))return"generic";if(fr(r))return null;for(t=0;t0)for(s=0;s0)for(h=0;h=0;i--)e[i]=n,n*=r[i];return e}(r)}function ul(r,t,e,n,i,o){var a,u,f,l,s;for(a=r.length,u=1,s=0;s=u&&(i=u-1);else if("wrap"===o)i<0?(i+=u)<0&&0!==(i%=u)&&(i+=u):i>=u&&(i-=u)>=u&&(i%=u);else if("normalize"===o&&i<0&&(i+=u),i<0||i>=u)throw new RangeError(k("invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.",u,i));if(f=e,ol(n)){for(s=0;s=0;s--)i-=l=i%r[s],i/=r[s],f+=l*t[s];return f}function fl(r,t){return t>0?0:(1-r)*t}U(al,"assign",(function(r,t,e){return ol(t)?function(r,t){var e,n;for(e=1,n=0;n=0;n--)t[n]=e,e*=r[n];return t}(r,e)}));var ll=3;function sl(r,t,e,n){var i,o,a,u,f,l,s;if(r<=0)return t;if((u=Pf(t)).accessorProtocol)return function(r,t,e,n){var i,o,a,u,f,l,s,c;for(i=t.data,a=t.accessors[0],o=t.accessors[1],s=_t(r/2),l=(f=n)+(r-1)*e,c=0;c0)for(s=0;s=0;o--)n.push(e[o]);t.push(n)}return t}function kl(r){var t,e;for(t=[],e=0;e=0;e--)t.push(r[e]);return t}function Ol(r){var t,e;for(t=[],e=0;e=st?"int8":r>=qr?"int16":r>=Ir?"int32":"float64":r<=lt?"int8":r<=zr?"int16":r<=Lr?"int32":"float64"}function zl(r,t){var e,n,i,o;for(e=hn(r),n=hn(t),i=[],o=0;ou)throw new Error("invalid arguments. Insufficient values to satisfy mask array.")}else if("strict_broadcast"===n){if(1!==u&&Eu(t)!==u)throw new Error("invalid arguments. Number of values does not equal the number of falsy values in the mask array.")}else if("non_strict"===n&&Eu(t)>u)throw new Error("invalid arguments. Insufficient values to satisfy mask array.");return i=un(r),o=un(t),a=un(e),i.accessorProtocol||o.accessorProtocol||a.accessorProtocol?gi(i.dtype)&&gi(a.dtype)?(function(r,t,e){var n,i,o,a,u;for(n=t.data,i=t.accessors[0],a=e.length,o=0,u=0;u=0&&au)throw new Error("invalid arguments. Insufficient values to satisfy mask array.")}else if("strict_broadcast"===n){if(1!==u&&ju(t)!==u)throw new Error("invalid arguments. Number of values does not equal the number of truthy values in the mask array.")}else if("non_strict"===n&&ju(t)>u)throw new Error("invalid arguments. Insufficient values to satisfy mask array.");return i=un(r),o=un(t),a=un(e),i.accessorProtocol||o.accessorProtocol||a.accessorProtocol?gi(i.dtype)&&gi(a.dtype)?(function(r,t,e){var n,i,o,a,u;for(n=t.data,i=t.accessors[0],a=e.length,o=0,u=0;ut?t:r}function rs(r,t){var e=t+1;return r<0?((r+=e)<0&&0!==(r%=e)&&(r+=e),r):r>t?((r-=e)>t&&(r%=e),r):r}function ts(r,t){return r<0?(r+=t+1)<0?-1:r:r>t?-1:r}function es(r){var t,e,n;if(!Rt(r))throw new TypeError(k("invalid argument. Must provide an array-like object. Value: `%s`.",r));return n=Mf(r),Hu(r)&&(t=rf(n)),e=r.length,void 0===t?function(t){var n;for(n=0;n=0&&a=0&&it)throw new RangeError(k("invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.",t,r));return e},throw:function(r,t){if(r<0||r>t)throw new RangeError(k("invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.",t,r));return r}};function us(r){if(!os(r))throw new TypeError(k("invalid argument. First argument must be a recognized index mode. Value: `%s`.",r));return as[r]}function fs(r,t,e,n){var i,o,a,u,f,l;if(t.length>0)if(e.length===t.length)o=1;else{if(1!==e.length)throw new Error(k("invalid argument. The third argument must be broadcast compatible with the second argument. Array shape: (%d). Desired shape: (%d).",e.length,t.length));o=0}return i=us(n),a=r.length-1,u=un(r),f=un(t),l=un(e),u.accessorProtocol||f.accessorProtocol||l.accessorProtocol?gi(u.dtype)&&gi(l.dtype)?(function(r,t,e,n,i,o){var a,u,f,l,s,c;for(a=t.data,u=t.accessors[0],l=2*n,f=0,s=0;st)throw new RangeError(k("invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.",t,r));return n}),"factory",us);var ls=Array.prototype.slice;function ss(r,t,e){var n;return function(r,t){return"function"==typeof r[t]}(r,"slice")?r.slice(t,e):(n=un(r)).accessorProtocol?function(r,t,e){var n,i,o,a;for(n=r.data,i=r.accessors[0],o=[],a=t;aa?i.push(n[a][o]):i.push(t.call(e,[o,a]));n.push(i)}return n}));var gs={};function ys(r,t,e){var n,i,o,a,u,f,l;for(i=hn(r),o=hn(t),n=us(e),u=r.length-1,a=[],f=0;f=u&&f<=u+t?a.push(n.call(i,[u,f])):ft?r:t;for(n=Et,o=0;on||i===n&&0===i&&ws(i))&&(n=i)}return n}(a[0],a[1],a[2]),s=bs(a[0],g),f=bs(a[1],g),l=bs(a[2],g),o=hn(r),n=hn(t),i=hn(e),p=0,c=0,h=0,u=[],m=0;m1?arguments[1]:js))return No(r);if(null===(e=qf(t)))throw new TypeError(k("invalid argument. Second argument must be a recognized data type. Value: `%s`.",t));return new e(r)}function Ls(r,t,e,n,i){var o,a;for(o=i,a=0;a=0;o--)if(t.call(e,i(n,o),o,n))return!0;return!1}(n,t,e):function(r,t,e){var n;for(n=r.length-1;n>=0;n--)if(t.call(e,r[n],n,r))return!0;return!1}(r,t,e)})),C(Rs,"anyHasOwnProp",(function(r,t){return Y(r)?function(r,t){var e,n;for(e=hn(r),n=0;n=r.length)return;return hn(r)(r,t)})),C(Rs,"at2d",(function(r,t,e){var n,i;if(i=r.length,t<0&&(t+=i),!(t<0||t>=i||(i=(n=r[t]).length,e<0&&(e+=i),e<0||e>=i)))return n[e]})),C(Rs,"at3d",(function(r,t,e,n){var i,o,a;if(a=r.length,t<0&&(t+=a),!(t<0||t>=a||(a=(i=r[t]).length,e<0&&(e+=a),e<0||e>=a||(a=(o=i[e]).length,n<0&&(n+=a),n<0||n>=a))))return o[n]})),C(Rs,"at4d",(function(r,t,e,n,i){var o,a,u,f,l;for(a=[t,e,n,i],o=r,f=0;f=u)return;o=o[l]}return o})),C(Rs,"at5d",(function(r,t,e,n,i,o){var a,u,f,l,s;for(u=[t,e,n,i,o],a=r,l=0;l=f)return;a=a[s]}return a})),C(Rs,"atnd",(function(r,t){var e,n,i,o,a;for(n=[t],o=2;o=i)return;e=e[a]}return e})),C(Rs,"banded",Bo),C(Rs,"bifurcateEntries",(function(r,t){var e,n,i,o,a,u;if(i=r.length,t.length!==i)throw new RangeError("invalid argument. The first and second arguments must have the same length.");if(0===i)return[];for(e=hn(r),n=hn(t),o=[[],[]],u=0;u=0;o--)if(!t.call(e,i(n,o),o,n))return!1;return!0}(n,t,e):function(r,t,e){var n;for(n=r.length-1;n>=0;n--)if(!t.call(e,r[n],n,r))return!1;return!0}(r,t,e)})),C(Rs,"fancySlice",Wf),C(Rs,"fancySliceAssign",Qf),C(Rs,"fill",(function(r,t,e,n){var i;return function(r,t){return"function"==typeof r[t]}(r,"fill")?r.fill(t,e,n):(e<0&&(e+=r.length)<0&&(e=0),n<0?n+=r.length:n>r.length&&(n=r.length),(i=un(r)).accessorProtocol?function(r,t,e,n){var i,o,a;for(i=r.data,o=r.accessors[1],a=e;ar.length&&(e=r.length),(o=un(r)).accessorProtocol?function(r,t,e,n,i){var o,a,u,f;for(o=r.data,a=r.accessors[0],u=r.accessors[1],f=t;fr.length&&(e=r.length-1);return Ml(r)?function(r,t,e){var n,i;for(n=hn(r),i=e;i>=0;i--)if(t===n(r,i))return i;return-1}(r,t,e):function(r,t,e){var n;for(n=e;n>=0;n--)if(t===r[n])return n;return-1}(r,t,e)})),C(Rs,"lastIndexOfSameValue",(function(r,t,e){if(e<0){if((e+=r.length)<0)return-1}else e>r.length&&(e=r.length-1);return Ml(r)?di(r)?function(r,t,e){var n,i,o,a;if(!ye(t))return-1;for(n=wu(r,0),i=Pe(t),o=Ne(t),a=2*e;a>=0;a-=2)if(ni(n[a],i)&&ni(n[a+1],o))return a/2;return-1}(r,t,e):an(r)?function(r,t,e){var n,i,o;if(!Gt(t))return-1;for(n=sn(r,0),i=t?1:0,o=e;o>=0;o--)if(n[o]===i)return o;return-1}(r,t,e):function(r,t,e){var n,i;for(n=hn(r),i=e;i>=0;i--)if(ni(t,n(r,i)))return i;return-1}(r,t,e):function(r,t,e){var n;for(n=e;n>=0;n--)if(ni(t,r[n]))return n;return-1}(r,t,e)})),C(Rs,"linspace",(function(r,t,e){var n,i,o,a;if(0===e)return[];for(o=(t-r)/(i=e-1),n=[r],a=1;a=0;h--)p-=s=p%n[h],p/=n[h],f[h]=s;for(a=[],h=0;h=0;o--)if(t.call(e,i(n,o),o,n))return!1;return!0}(n,t,e):function(r,t,e){var n;for(n=r.length-1;n>=0;n--)if(t.call(e,r[n],n,r))return!1;return!0}(r,t,e)})),C(Rs,"nulls",(function(r){return Io(null,r)})),C(Rs,"oneTo",Ql),C(Rs,"ones",(function(r){return Io(1,r)})),C(Rs,"ones2d",(function(r){return Oo(1,r)})),C(Rs,"ones3d",(function(r){return Zf(1,r)})),C(Rs,"ones4d",(function(r){return Kf(1,r)})),C(Rs,"ones5d",(function(r){return rl(1,r)})),C(Rs,"onesnd",(function(r){return el(1,r)})),C(Rs,"place",Zl),C(Rs,"put",fs),C(Rs,"quaternary2d",(function(r,t,e){var n,i,o,a,u,f,l,s,c,h,p,g,y,m;if(n=t[1],i=t[0],!(n<=0||i<=0))for(h=r[0],p=r[1],g=r[2],y=r[3],m=r[4],a=0;a=e)return r;for(i=t,n=t+1;n=0;i--)n.push(e(t,i));return n}(t):function(r){var t,e;for(t=[],e=r.length-1;e>=0;e--)t.push(r[e]);return t}(r)})),C(Rs,"unary2d",(function(r,t,e){var n,i,o,a,u,f,l,s;if(n=t[1],i=t[0],!(n<=0||i<=0))for(l=r[0],s=r[1],a=0;a4&&(i=arguments[4]),c=r[0],h=r[1],f=0;f4&&(i=arguments[4]),y=r[0],m=r[1],s=0;s4&&(i=arguments[4]),w=r[0],b=r[1],h=0;h4&&(i=arguments[4]),T=r[0],x=r[1],g=0;g1?arguments[1]:ac))return No(r);if(null===(t=ic(n)))throw new TypeError(k("invalid argument. Second argument must be a supported data type. Value: `%s`.",n));return i=ec(n),a=t*r,"complex128"===n&&(a+=8),e=(o=rc(a)).byteOffset,"complex128"===n&&(Ft(e/t)||(e+=8)),new i(o.buffer,e,r)}:function(r){return arguments.length>1?ks(r,arguments[1]):ks(r)};var uc=oc;var fc=8;function lc(r,t,e,n,i){var o,a,u,f;if(r<=0)return e;if((u=Pf(e)).accessorProtocol)return function(r,t,e,n,i){var o,a,u,f;for(o=e.data,a=e.accessors[1],u=i,f=0;f0)for(f=0;fa.byteLength-r)throw new RangeError(k("invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.",u));a=new qs(a,r,u)}}return U(this,"_buffer",a),U(this,"_length",a.byteLength/t),U(this,"_isLE",i),this}return t=ic(r),e=function(r){return bc(r)+"ArrayFE"}(r),n=Ac[r],i=Vc[r],U(o,"BYTES_PER_ELEMENT",t),U(o,"name",e),U(o,"from",(function(n,o){var u,f,l,s,c,h,p,g,y,m,d;if(!ue(this))throw new TypeError("invalid invocation. `this` context must be a constructor.");if(!a(this))throw new TypeError(k("invalid invocation. `this` is not %s %s.",Sc[r[0]],e));if(null===(f=jc(n))||!pi(f))throw new TypeError(k("invalid argument. First argument must be a supported byte order. Value: `%s`.",n));if(c=kc(f),(l=arguments.length)>2){if(!ue(s=arguments[2]))throw new TypeError(k("invalid argument. Third argument must be a function. Value: `%s`.",s));l>3&&(u=arguments[3])}if(Rt(o)){if(s){for(m=o.length,y=o.get&&o.set?H("default"):z("default"),p=(h=new this(f,m))._buffer,d=0;d=o))return this._buffer[n](i*t,this._isLE)})),Te(o.prototype,"buffer",(function(){return this._buffer.buffer})),Te(o.prototype,"byteLength",(function(){return this._buffer.byteLength})),Te(o.prototype,"byteOffset",(function(){return this._buffer.byteOffset})),U(o.prototype,"BYTES_PER_ELEMENT",o.BYTES_PER_ELEMENT),U(o.prototype,"every",(function(i,o){var a,f;if(!u(this))throw new TypeError(k("invalid invocation. `this` is not %s %s.",Sc[r[0]],e));if(!ue(i))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",i));for(a=this._buffer,f=0;f=this._length))return this._buffer[n](i*t,this._isLE)})),U(o.prototype,"includes",(function(i,o){var a,f;if(!u(this))throw new TypeError(k("invalid invocation. `this` is not %s %s.",Sc[r[0]],e));if(arguments.length>1){if(!Vt(o))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",o));o<0&&(o+=this._length)<0&&(o=0)}else o=0;for(a=this._buffer,f=o;f1){if(!Vt(o))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",o));o<0&&(o+=this._length)<0&&(o=0)}else o=0;for(a=this._buffer,f=o;f0){if(!Nt(i))throw new TypeError(k("invalid argument. First argument must be a string. Value: `%s`.",i));f=i}else f=",";for(o=[],a=this._buffer,l=0;l1){if(!Vt(o))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",o));o>=this._length?o=this._length-1:o<0&&(o+=this._length)}else o=this._length-1;for(a=this._buffer,f=o;f>=0;f--)if(a[n](f*t,this._isLE)===i)return f;return-1})),Te(o.prototype,"length",(function(){return this._length})),U(o.prototype,"map",(function(o,a){var f,l,s,c,h;if(!u(this))throw new TypeError(k("invalid invocation. `this` is not %s %s.",Sc[r[0]],e));if(!ue(o))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",o));for(s=this._buffer,f=(l=new this.constructor(Lc(this._isLE),this._length))._buffer,c=0;c1)l=o,s=0;else{if(0===f)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");l=a[n](0*t,this._isLE),s=1}for(;s1)l=o,s=f-1;else{if(0===f)throw new Error("invalid operation. If not provided an initial value, an array must contain at least one element.");l=a[n]((f-1)*t,this._isLE),s=f-2}for(;s>=0;s--)l=i(l,a[n](s*t,this._isLE),s,this);return l})),U(o.prototype,"set",(function(n){var o,a,f,l,s,c,h,p;if(!u(this))throw new TypeError(k("invalid invocation. `this` is not %s %s.",Sc[r[0]],e));if(f=this._buffer,arguments.length>1){if(!Ft(a=arguments[1]))throw new TypeError(k("invalid argument. Index argument must be a nonnegative integer. Value: `%s`.",a))}else a=0;if(Rt(n)){if(a+(c=n.length)>this._length)throw new RangeError("invalid arguments. Target array lacks sufficient storage to accommodate source values.");if(s=(o=n).get&&o.set?H("default"):z("default"),p=f.byteOffset+a*t,o.buffer===f.buffer&&o.byteOffsetp){for(l=[],h=0;h=this._length)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%u`.",a));f[i](a*t,n,this._isLE)}})),U(o.prototype,"some",(function(i,o){var a,f;if(!u(this))throw new TypeError(k("invalid invocation. `this` is not %s %s.",Sc[r[0]],e));if(!ue(i))throw new TypeError(k("invalid argument. First argument must be a function. Value: `%s`.",i));for(a=this._buffer,f=0;f=l)throw new RangeError(k("invalid argument. Index argument is out-of-bounds. Value: `%s`.",n));return(f=new this.constructor(Lc(this._isLE),a.buffer))._buffer[i](n*t,o,this._isLE),f})),o;function a(r){return r===o}function u(r){return"object"==typeof r&&null!==r&&(r.constructor.name===e||function(r,t){var e=typeof t;if(null===t||"object"!==e&&"function"!==e)throw new TypeError(k("invalid argument. Second argument must be either an object (except null) or a function. Value: `%s`.",t));return e=typeof r,null!==r&&("object"===e||"function"===e)&&wc.call(t,r)}(r,o.prototype))&&r.BYTES_PER_ELEMENT===t}function f(r,e,n){var o,a,u;for(o=e.length,a=e.get&&e.set?H("default"):z("default"),u=0;u2?arguments[2]:Gc))return Io(t,r);if(null===(n=qf(e)))throw new TypeError(k("invalid argument. Third argument must be a recognized data type. Value: `%s`.",e));return sc(r,t,i=new n(r),1),i}function Jc(){}var Qc="foo"===Jc.name;var Xc=[Fe,ce,af,wn,ff,kn,hf,ln,sf],Zc=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"],Kc=yr()?Ji(Fe):rh;function rh(){}Kc="TypedArray"===function(r){if(!1===ue(r))throw new TypeError(k("invalid argument. Must provide a function. Value: `%s`.",r));return Qc?r.name:sr.exec(r.toString())[1]}(Kc)?Kc:rh;var th=[Af,wf],eh=["Complex64Array","Complex128Array"];function nh(r){return r instanceof If||"BooleanArray"===cr(r)}function ih(r,t){if("function"!=typeof t)throw new TypeError(k("invalid argument. Second argument must be callable. Value: `%s`.",t));return r instanceof t}var oh=[[dr,"Float64Array"],[Tr,"Float32Array"],[Mr,"Int32Array"],[jr,"Uint32Array"],[Jr,"Int16Array"],[Yr,"Uint16Array"],[gt,"Int8Array"],[et,"Uint8Array"],[ut,"Uint8ClampedArray"],[Me,"Complex64Array"],[qe,"Complex128Array"],[Xe,"BooleanArray"]];function ah(r){var t,e;for(e=0;e=r.length)return{done:!0};return{value:r[i],done:!1}})),U(t,"return",(function(r){if(n=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(t,_e,(function(){return e.iterator()})),t})),U(lh.prototype,"last",(function(){if(this._length)return this._last})),Te(lh.prototype,"length",(function(){return this._length})),U(lh.prototype,"pop",(function(){var r;return this._length&&(r=this._last.value,this._last._prev?(this._last=this._last._prev,this._last._next=null):(this._first=null,this._last=null),this._length-=1),r})),U(lh.prototype,"push",(function(r){var t;return t=new fh(r),0===this._length?(this._first=t,this._last=t):(t._prev=this._last,this._last._next=t,this._last=t),this._length+=1,this})),U(lh.prototype,"remove",(function(r){var t,e;if(r===this._first)return this.shift();if(r===this._last)return this.pop();for(t=r.value,e=this._first;e!==this._last&&e!==r;)e=e._next;if(e===this._last)throw new Error("invalid argument. The list does not contain the provided list node.");return r._prev._next=r._next,r._next._prev=r._prev,this._length-=1,t})),U(lh.prototype,"shift",(function(){var r;return this._length&&(r=this._first.value,this._first._next?(this._first=this._first._next,this._first._prev=null):(this._first=null,this._last=null),this._length-=1),r})),U(lh.prototype,"toArray",(function(){var r,t,e;for(t=[],r=this._first,e=0;e1?new ph(r,arguments[1]):new ph(r);if(!Rt(r))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if("generic"===(n=tn(r))||null===n)if(r.length>0)if(Gt(o=hn(r)(r,0)))i="bool";else{if(!Vt(o))throw new TypeError("invalid argument. First argument must be a valid index array.");i="int"}else i="int";else if("int32"===n)i="int";else if("uint8"===n)i="mask";else{if("bool"!==n)throw new TypeError("invalid argument. First argument must be a valid index array.");i="bool"}if(t={persist:!1},arguments.length>1&&(e=function(r,t){return Xi(t)?tr(t,"persist")&&(r.persist=t.persist,!Gt(r.persist))?new TypeError(k("invalid option. `%s` option must be a boolean. Option: `%s`.","persist",r.persist)):null:new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t))}(t,arguments[1]),e))throw e;return sh.push({id:(hh+=1).toString(),ref:this,data:r,type:i,dtype:n,persist:t.persist}),U(this,"_node",sh.last()),Hl(this,"_invalidated",!1),this}U(ph,"name","ArrayIndex"),U(ph,"free",(function(r){var t,e;return null!==(t=ch(r))&&(U((e=t.value).ref,"_invalidated",!0),sh.remove(t),e.data=null,!0)})),U(ph,"get",(function(r){var t,e,n;return null===(t=ch(r))?null:(e={data:(n=t.value).data,type:n.type,dtype:n.dtype},n.persist||ph.free(r),e)})),Te(ph.prototype,"data",(function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.data})),Te(ph.prototype,"dtype",(function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.dtype})),Te(ph.prototype,"id",(function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.id})),Te(ph.prototype,"isCached",(function(){return!this._invalidated})),Te(ph.prototype,"type",(function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return this._node.value.type})),U(ph.prototype,"toString",(function(){if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return"ArrayIndex<"+this._node.value.id+">"})),U(ph.prototype,"toJSON",(function(){var r;if(this._invalidated)throw new Error("invalid operation. This array index instance has already been freed and can no longer be used.");return{type:"ArrayIndex",data:"generic"===(r=this._node.value).dtype||null===r.dtype?Y(r.data)?gu(r.data):r.data:uh(r.data)}}));var gh={float64:dr,float32:Tr,complex128:qe,complex64:Me};function yh(r){return gh[r]||null}function mh(r,t,e,n,i){var o,a,u;if(0===n)return r;if(1===n)return r[0]=i?e:t,r;for(r[0]=t,a=(e-t)/(o=i?n-1:n),u=1;u3&&(o=vh(n,arguments[3])))throw o;if("generic"===n.dtype)return l?function(r,t,e,n,i,o){var a,u,f,l,s,c,h,p,g,y,m,d,v;if(0===i)return[];if(u=0,"float64"===r?(l=t,c=0):"complex64"===r?(u+=1,l=xe(t),c=Ve(t)):(l=Pe(t),c=Ne(t)),"float64"===e?(s=n,h=0):"complex64"===e?(u+=1,s=xe(n),h=Ve(n)):(s=Pe(n),h=Ne(n)),a=2===u?ge:fe,1===i)return o?[new a(s,h)]:[new a(l,c)];for(f=[new a(l,c)],y=(s-l)/(d=o?i-1:i),m=(h-c)/d,v=1;v3&&(i=vh(n,arguments[3])))throw i;if(null===(f=tn(e))&&(f="generic"),"complex64"===f)return dh(Ae(e,0),o,r,a,t,e.length,n.endpoint),e;if("complex128"===f)return dh(je(e,0),o,r,a,t,e.length,n.endpoint),e;if(u){if("generic"===f)return function(r,t,e,n,i,o,a){var u,f,l,s,c,h,p,g,y,m,d,v;if(0===o)return r;if(f=0,"float64"===t?(l=e,c=0):"complex64"===t?(f+=1,l=xe(e),c=Ve(e)):(l=Pe(e),c=Ne(e)),"float64"===n?(s=i,h=0):"complex64"===n?(f+=1,s=xe(i),h=Ve(i)):(s=Pe(i),h=Ne(i)),u=2===f?ge:fe,g=r.data,p=r.accessors[1],1===o)return p(g,0,a?new u(s,h):new u(l,c)),r;for(p(g,0,new u(l,c)),y=(s-l)/(d=a?o-1:o),m=(h-c)/d,v=1;v1){if(!ue(f=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be a function. Value: `%s`.",f));u>2&&(o=arguments[2])}if(Rt(i)){if(f){for(p=i.length,h=i.get&&i.set?H("default"):z("default"),s=(l=new this(p))._buffer,g=0;g=Mh&&r<=Bh?"float32":"float64":r>-Rh&&r=st?"int8":r>=qr?"int16":r>=Ir?"int32":"float64":r<=Zr?"uint8":r<=Nr?"uint16":r<=Vr?"uint32":"float64":r>-Rh&&r1){if("generic"===(t=arguments[1]))return Ql(r)}else t=Zh;return Ql.assign(ks(r,t),1,0)}var rp=new fe(1,0),tp=new ge(1,0),ep=As.get("dtypes.default");var np=new fe(1,0),ip=new ge(1,0);var op=["strict","non_strict","strict_broadcast","broadcast","repeat"],ap=yn(op);function up(r,t,e){var n,i,o,a;if(!Rt(r))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!Rt(t))throw new TypeError(k("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));if(!Rt(e))throw new TypeError(k("invalid argument. Third argument must be an array-like object. Value: `%s`.",e));if(n={mode:"repeat"},arguments.length>3&&(i=function(r,t){return Xi(t)?tr(t,"mode")&&(r.mode=t.mode,!ap(r.mode))?new TypeError(k('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"mode",op.join('", "'),r.mode)):null:new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t))}(n,arguments[3]),i))throw i;if(o=tn(r)||"generic",!po(a=tn(e)||"generic",o))throw new TypeError(k("invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].",a,o));return gi(o)&&mo(a)&&(e=Jf(e,o)),Zl(r,t,e,n.mode)}var fp=0x40000000000000,lp=1.4426950407214463,sp=1.6751713164886512e-10,cp=2146435072,hp=1048576,pp=1072693248,gp=[0,0];function yp(r){var t,e,n,i,o,a,u,f,l,s,c,h,p;if(An(r)||r<0)return NaN;if(Dn.assign(r,gp,1,0),i=0|gp[0],o=gp[1],p=0,i=cp?r+r:i===pp&&0===o?0:(p+=(i>>20)-ma|0,c=p+=(h=(i&=$a)+614244&hp|0)>>20|0,n=.5*(f=(r=ya(r,i|h^pp))-1)*f,l=function(r){var t,e,n,i,o,a;return t=(o=(i=(n=r/(2+r))*n)*i)*(0===(a=o)?.3999999999940942:.3999999999940942+a*(.22222198432149784+.15313837699209373*a)),e=i*function(r){return 0===r?.6666666666666735:.6666666666666735+r*(.2857142874366239+r*(.1818357216161805+.14798198605116586*r))}(o),n*(.5*r*r+(e+t))}(f),e=((u=f-(a=$o(a=f-n,0))-n+l)+a)*sp+u*lp,(e+=c-(s=c+(t=a*lp))+t)+(t=s))}var mp={bool:1,float64:8,float32:4,int16:2,int32:4,int8:1,uint16:2,uint32:4,uint8:1,uint8c:1,complex64:8,complex128:16},dp=As.get("dtypes.default"),vp=ec("complex64"),wp=ec("complex128"),bp=ec("bool");function Ep(r){return r instanceof vp}function _p(r){return r instanceof wp}function Tp(r){return r instanceof bp}function xp(r){var t,e,n,i;if(n={highWaterMark:9007199254740992},arguments.length&&(i=function(r,t){return Xi(t)?tr(t,"highWaterMark")&&(r.highWaterMark=t.highWaterMark,!Ft(r.highWaterMark))?new TypeError(k("invalid option. `%s` option must be a nonnegative integer. Option: `%s`.","highWaterMark",r.highWaterMark)):null:new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t))}(n,r),i))throw i;return e=function(r){var t,e;for(t=[],e=0;e0){for(t=_t(yp(r.byteLength)),a=e.length-1,u=t,t=An(a)||An(u)?NaN:a===Et||u===Et?Et:a===u&&0===a?Oh(a)?a:u:an.highWaterMark?null:(i=new Ns(r),t+=r,i)}((An(u=i)||Do(u)||0===u?u:(u<0?(u=-u,f=-1):f=1,(l=yp(u))===Ba?u:(l=-1===f?_t(l):qu(l))>Oa?wr:f*su(2,l)))*mp[o]),null===a?a:new r(a,0,i))}function a(){var r,t,e,n,i,a,u,f,l,s;if(null===(e=ec(t=(r=arguments.length)&&Nt(arguments[r-1])?arguments[r-=1]:dp)))throw new TypeError(k("invalid argument. Must provide a recognized data type. Value: `%s`.",t));if(r<=0)return new e(0);if(Ft(arguments[0]))return o(e,arguments[0],t);if(Rt(arguments[0])){if(f=(n=arguments[0]).length,(s=n)instanceof Af||"Complex128Array"===cr(s)?n=je(n,0):!function(r){return r instanceof wf||"Complex64Array"===cr(r)}(n)?nh(n)?n=sn(n,0):gi(t)&&(f/=2):n=Ae(n,0),null===(i=o(e,f,t)))return i;if(_p(i)||Ep(i)||Tp(i))return i.set(n),i;for(u=hn(n),a=hs(i),l=0;l3&&(i=function(r,t){return Xi(t)?tr(t,"mode")&&(r.mode=t.mode,!os(r.mode))?new TypeError(k('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"mode",is().join('", "'),r.mode)):null:new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t))}(n,arguments[3]),i))throw i;if(o=tn(r)||"generic",!po(a=tn(e)||"generic",o))throw new TypeError(k("invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].",a,o));return gi(o)&&mo(a)&&(e=Jf(e,o)),fs(r,t,e,n.mode)}var Fp={Float64Array:dr,Float32Array:Tr,Int32Array:Mr,Uint32Array:jr,Int16Array:Jr,Uint16Array:Yr,Int8Array:gt,Uint8Array:et,Uint8ClampedArray:ut,Complex64Array:Me,Complex128Array:qe,BooleanArray:Xe};function jp(r,t){var e=t[0];return It(e)&&(r.push(e.length),jp(r,e)),r}function kp(r,t,e,n,i){var o,a,u;for(o=t[e],u=0;u2&&(n=function(r,t){return Xi(t)?tr(t,"mode")&&(r.mode=t.mode,!os(r.mode))?new TypeError(k('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"mode",is().join('", "'),r.mode)):null:new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t))}(e,arguments[2]),n))throw n;return"generic"===(i=tn(r))||null===i?ys(r,t,e.mode):ys.assign(r,t,e.mode,ks(t.length,i),1,0)}var Np=eval;var Cp,Up="undefined"==typeof Proxy?null:Proxy;Cp=function(){var r;try{Np('"use strict"; var handler = { "get": function get( t, n ) { return t[ n ] * 100; } }; var target = { "beep": 3.14 }; var p = new Proxy( target, handler ); var x = p.beep; if ( x !== 314 ) { throw new Error( "native Proxy is not supported." ); }'),r=!0}catch(t){r=!1}return r}()?Up:function(r){return r};var Dp=Cp,Yp=ue(Object.assign),Wp=Object.assign,zp=void 0!==Object.getOwnPropertySymbols,qp=$i.getOwnPropertySymbols;var $p,Gp=zp?function(r){return qp($i(r))}:function(){return[]};function Hp(r){var t,e,n;for(t=qi(r),e=Gp(r),n=0;n]+>\s*/;function hg(r){return Nt(r)&&cg.test(r)}var pg=void 0!==String.prototype.trim,gg=String.prototype.trim;var yg=/^[\u0020\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]*([\S\s]*?)[\u0020\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]*$/;var mg=pg&&""===gg.call(" \n\t\r\n\f\v            \u2028\u2029   \ufeff")&&"᠎"===gg.call("᠎")?function(r){return gg.call(r)}:function(r){return ai(r,yg,"$1")};function dg(r,t){var e,n=t.get((e=mg(r)).substring(11,e.length-1));if(null===n)throw new Error(k("invalid operation. Unable to resolve array index. Value: `%s`.",r));return n}function vg(r,t,e){var n,i;if(-1===(i=ts(n=parseInt(r,10),t-1))){if(e)throw new RangeError(k("invalid operation. Index exceeds array bounds."));return n}return i}function wg(r){return ai(r,/^invalid arguments?/,"invalid operation")}var bg=/(?:\s*-\s*)(?=\d+)(\d+)$/,Eg=/(?:\s*\/\s*)(?=\d*\.?\d+)(\d*\.?\d+)$/;function _g(r,t,e,n){var i;if("end"===r)return t;if(i=r.match(bg)){if((r=t-parseInt(i[1],10))<0){if(n)return-2;r=0}return r}return(i=r.match(Eg))?(r=parseFloat(i[1]))<1?n?-2:-1:_t(e&&t>0&&1!==r?(t-1)/r:t/r):-1}var Tg=/\s*:\s*/,xg=/^[-+]?[0-9]+$/,Vg=/^end/;function Ag(r,t,e){var n,i,o;if((i=(n=mg(r).split(Tg)).length)<2||i>3)return{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};if(3===i)if(0===(o=n[2]).length)n[2]=1;else{if(!1===xg.test(o))return{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};if(0===(o=parseInt(o,10)))return{code:"ERR_SLICE_INVALID_INCREMENT"};n[2]=o}else n.push(1);if(0===(o=n[0]).length)n[2]<0&&t>0?n[0]=t-1:n[0]=0;else if(Vg.test(o)){if((o=_g(o,t,n[2]<0,e))<0)return-2===o?{code:"ERR_SLICE_OUT_OF_BOUNDS"}:{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};n[2]<0&&o>=t&&(o-=1),n[0]=o}else{if(!xg.test(o))return{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};if((o=parseInt(o,10))<0){if((o=t+o)<0){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};o=0}}else if(o>=t){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};o=n[2]<0?t-1:t}n[0]=o}if(0===(o=n[1]).length)n[2]<0?n[1]=null:n[1]=t;else if(Vg.test(o)){if((o=_g(o,t,n[2]<0,e))<0)return-2===o?{code:"ERR_SLICE_OUT_OF_BOUNDS"}:{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};n[1]=o}else{if(!xg.test(o))return{code:"ERR_SLICE_INVALID_SUBSEQUENCE"};if((o=parseInt(o,10))<0){if((o=t+o)<0)if(n[2]>0){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};o=0}else{if(e&&o<-1)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};o=null}}else if(o>t){if(e)return{code:"ERR_SLICE_OUT_OF_BOUNDS"};o=t}n[1]=o}return 0===t?new Wu(0,0,n[2]):new Wu(n[0],n[1],n[2])}var Sg="Slice(",Fg=3,jg=/\s*,\s*/,kg=/^-?[0-9]+$/;var Lg=void 0!==String.prototype.startsWith;var Ig,Og=String.prototype.startsWith;Ig=Lg?function(r,t,e){var n;return n=e<0?r.length+e:e,0===t.length||!(n<0||n+t.length>r.length)&&Og.call(r,t,n)}:function(r,t,e){var n,i;if(n=e<0?r.length+e:e,0===t.length)return!0;if(n<0||n+t.length>r.length)return!1;for(i=0;i=0&&f.length<=Lt||Rt(e)))throw new TypeError(k("invalid argument. First argument must be array-like. Value: `%s`.",e));var f;if(Kp){if(n=Jp({},r),arguments.length>1&&(i=rg(n,arguments[1])))throw i;return u={ref:e,dtype:a=(o=un(e)).dtype||"",getter:o.accessors[0],setter:o.accessors[1],preSetElement:Xp(a),postGetArray:Zp(t,n),cache:n.cache,strict:n.strict,validator:ug(a),array2fancy:t,ctor:new Dp(e.constructor||Array,{construct:fg(t,n)})},new Dp(e,{get:Ng(u),set:Ug(u)})}return console.warn("WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available."),e}}var Yg=Dg();U(Yg,"factory",Dg),U(Yg,"idx",ph);var Wg=As.get("dtypes.default"),zg=ec("complex64"),qg=ec("complex128"),$g=ec("bool");var Gg={complex128:qe,complex64:Me};function Hg(r){return Gg[r]||null}var Jg=As.get("dtypes.complex_floating_point");var Qg={int16:Jr,int32:Mr,int8:gt,uint16:Yr,uint32:jr,uint8:et,uint8c:ut};var Xg=As.get("dtypes.real");var Zg={float64:dr,float32:Tr,int16:Jr,int32:Mr,int8:gt,uint16:Yr,uint32:jr,uint8:et,uint8c:ut};var Kg={float64:dr,float32:Tr};var ry={int16:Jr,int32:Mr,int8:gt};var ty={uint16:Yr,uint32:jr,uint8:et,uint8c:ut};var ey=As.get("dtypes.default");function ny(r){var t;if(!Ft(r))throw new TypeError(k("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",r));if(arguments.length>1){if("generic"===(t=arguments[1]))return _u(r)}else t=ey;return _u.assign(ks(r,t),1,0)}var iy={};C(iy,"MAX_ARRAY_LENGTH",Lt),C(iy,"MAX_TYPED_ARRAY_LENGTH",Ot);var oy={};return C(oy,"base",Rs),C(oy,"BooleanArray",Xe),C(oy,"ArrayBuffer",Ns),C(oy,"byteOrders",hi),C(oy,"cartesianPower",(function(r,t){if(!Rt(r))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!Ft(t))throw new TypeError(k("invalid argument. Second argument must be a nonnegative integer. Value: `%s`.",t));return cu(r,t)})),C(oy,"cartesianProduct",(function(r,t){if(!Rt(r))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!Rt(t))throw new TypeError(k("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));return hu(r,t)})),C(oy,"cartesianSquare",(function(r){if(!Rt(r))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",r));return pu(r)})),C(oy,"Complex64Array",Me),C(oy,"Complex128Array",qe),C(oy,"convert",Jf),C(oy,"convertSame",(function(r,t){var e=tn(t);if(null===e)throw new TypeError(k("invalid argument. Second argument must have a recognized/supported data type. Type: `%s`. Value: `%s`.",e,t));return Jf(r,e)})),C(oy,"ctors",qf),C(oy,"DataView",qs),C(oy,"datespace",(function(r,t,e,n){var i,o,a,u,f,l,s,c,h;if(o=100,a=!0,i={round:"floor"},r=Js(r,"Start"),t=Js(t,"Stop"),arguments.length>2){if(3===arguments.length?Pt(e)?i=e:(o=e,a=!1):(i=n,o=e),0===o)return[];if(!St(o)||o<0)throw new TypeError(k("invalid argument. Length must be a positive integer. Value: `%s`.",o));if(a){if(!Pt(i))throw new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",i));if(tr(i,"round")){if(!Nt(i.round))throw new TypeError(k("invalid option. `%s` option must be a string. Option: `%s`.","round",i.round));if(-1===Hs.indexOf(i.round))throw new Error(k('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"round",Hs.join('", "'),i.round))}}}switch(i.round){case"round":l=$s;break;case"ceil":l=qu;break;default:l=_t}for(f=o-1,c=(t.getTime()-r.getTime())/f,s=r,(u=new Array(o))[0]=s,s=s.getTime(),h=1;h1&&(t=arguments[1]),uc(r.length,t)})),C(oy,"filled",(function(){var r,t,e,n,i,o,a;if(t=arguments.length,(t-=1)>=0&&Nt(arguments[t])?(e=arguments[t],t-=1):e=gc,null===(n=qf(e)))throw new TypeError(k("invalid argument. Must provide a recognized data type. Value: `%s`.",e));if("generic"===e){if(t<=0)return[];if(r=arguments[0],a=arguments[1],1===t){if(Ft(a)?o=a:Rt(a)&&(o=a.length),void 0!==o)return Io(r,o);if(Mt(a))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(Pt(a)){if(!1===pc)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",a));if(!ue(a[_e]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(!ue((a=a[_e]()).next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));return function(r,t){var e;for(e=[];!r.next().done;)e.push(t);return e}(a,r)}throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a))}if(Mt(a))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a))}if(t<=0)return new n(0);if(1===t)if(Rt(a=arguments[1]))i=new n(a.length);else if(Mt(a))i=new n(a);else if(Ft(a))i=new n(a);else{if(!Pt(a))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(!1===pc)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",a));if(!ue(a[_e]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));if(!ue((a=a[_e]()).next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",a));i=new n(hc(a))}else i=2===t?new n(arguments[1],arguments[2]):new n(arguments[1],arguments[2],arguments[3]);return i.length>0&&(r=arguments[0],gi(e)?function(r,t){var e;for(e=0;e1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(null===(i=qf(e)))throw new TypeError(k("invalid argument. Must provide a recognized data type. Value: `%s`.",e));return new i(0)}if(t<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(ue(arguments[t-=1]))if(ue(arguments[t-1])){if(r=arguments[t],n=arguments[t-=1],0===t)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else n=arguments[t];else{if(!(t>=2))throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(r=arguments[t],!ue(n=arguments[t-=1]))throw new TypeError(k("invalid argument. Callback argument must be a function. Value: `%s`.",n))}if((t-=1)>=0&&Nt(arguments[t])?(e=arguments[t],t-=1):e=vc,null===(i=qf(e)))throw new TypeError(k("invalid argument. Must provide a recognized data type. Value: `%s`.",e));if("generic"===e){if(u=arguments[0],0===t){if(Ft(u)?a=u:Rt(u)&&(a=u.length),void 0!==a)return Xf(a,n,r);if(Mt(u))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(Pt(u)){if(!1===dc)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",u));if(!ue(u[_e]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u));if(!ue((u=u[_e]()).next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u));return function(r,t,e){var n,i;for(n=[],i=-1;!r.next().done;)i+=1,n.push(t.call(e,i));return n}(u,n,r)}throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u))}if(Mt(u))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u))}if(0===t)if(Rt(u=arguments[0]))o=new i(u.length);else if(Mt(u))o=new i(u);else if(Ft(u))o=new i(u);else{if(!Pt(u))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u));if(!1===dc)throw new TypeError(k("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",u));if(!ue(u[_e]))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u));if(!ue((u=u[_e]()).next))throw new TypeError(k("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",u));o=new i(hc(u))}else o=1===t?new i(arguments[0],arguments[1]):new i(arguments[0],arguments[1],arguments[2]);return o.length>0&&(gi(e)||si(e)?function(r,t,e){var n;for(n=0;n1)if(Rt(arguments[1])){if(n=arguments[1],arguments.length>2){if(!ue(e=arguments[2]))throw new TypeError(k("invalid argument. Callback argument must be a function. Value: `%s`.",e));t=arguments[3]}}else{if(!ue(e=arguments[1]))throw new TypeError(k("invalid argument. Callback argument must be a function. Value: `%s`.",e));t=arguments[2]}if(!cc(r))throw new TypeError(k("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",r));if(u=-1,void 0===n){if(n=[],e){for(;u+=1,!(f=r.next()).done;)n.push(e.call(t,f.value,u));return n}for(;!(f=r.next()).done;)n.push(f.value);return n}if(i=n.length,a=tn(n),o=Y(n)?Q(a):$(a),e){for(;u2&&(e=arguments[2]),n="number"==typeof t?"complex128"===e?new fe(t,0):"complex64"===e?new ge(t,0):t:t,Hc(r.length,n,e)})),C(oy,"incrspace",(function(r,t,e){var n;if(!yt(r)||An(r))throw new TypeError(k("invalid argument. Start must be numeric. Value: `%s`.",r));if(!yt(t)||An(t))throw new TypeError(k("invalid argument. Stop must be numeric. Value: `%s`.",t));if(arguments.length<3)n=1;else if(!yt(n=e)||An(n))throw new TypeError(k("invalid argument. Increment must be numeric. Value: `%s`.",n));if(qu((t-r)/n)>Vr)throw new RangeError("invalid arguments. Generated array exceeds maximum array length.");return Bl(r,t,n)})),C(oy,"ArrayIndex",ph),C(oy,"Int8Array",gt),C(oy,"Int16Array",Jr),C(oy,"Int32Array",Mr),C(oy,"linspace",Eh),C(oy,"littleEndianFactory",kh),C(oy,"Float32ArrayLE",Lh),C(oy,"Float64ArrayLE",Ih),C(oy,"logspace",(function(r,t,e){if(!yt(r)||An(r))throw new TypeError(k("invalid argument. Exponent of start value must be numeric. Value: `%s`.",r));if(!yt(t)||An(t))throw new TypeError(k("invalid argument. Exponent of stop value must be numeric. Value: `%s`.",t));if(arguments.length<3)e=10;else if(!Ft(e))throw new TypeError(k("invalid argument. Length must be a nonnegative integer. Value: `%s`.",e));return Nl(r,t,e)})),C(oy,"minDataType",Nh),C(oy,"mostlySafeCasts",co),C(oy,"mskfilter",Ch),C(oy,"mskput",(function(r,t,e){var n,i,o,a;if(!Rt(r))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(!Rt(t))throw new TypeError(k("invalid argument. Second argument must be an array-like object. Value: `%s`.",t));if(!Rt(e))throw new TypeError(k("invalid argument. Third argument must be an array-like object. Value: `%s`.",e));if(n={mode:"repeat"},arguments.length>3&&(i=function(r,t){return Xi(t)?tr(t,"mode")&&(r.mode=t.mode,!Dh(r.mode))?new TypeError(k('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"mode",Uh.join('", "'),r.mode)):null:new TypeError(k("invalid argument. Options argument must be an object. Value: `%s`.",t))}(n,arguments[3]),i))throw i;if(o=tn(r)||"generic",!po(a=tn(e)||"generic",o))throw new TypeError(k("invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].",a,o));return gi(o)&&mo(a)&&(e=Jf(e,o)),$l(r,t,e,n.mode)})),C(oy,"mskreject",Yh),C(oy,"nans",(function(r){var t;if(arguments.length>1){if(!$h(t=arguments[1]))throw new TypeError(k('invalid argument. Second argument must be one of the following: "%s". Value: `%s`.',qh.join('", "'),t))}else t=Gh;return Hc(r,"complex128"===t?Wh:"complex64"===t?zh:NaN,t)})),C(oy,"nansLike",(function(r){var t,e;if(null===(t=tn(r)))throw new TypeError(k("invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.",r));if(arguments.length>1){if(t=arguments[1],-1===Qh.indexOf(t))throw new TypeError(k('invalid argument. Second argument must be one of the following: "%s". Value: `%s`.',Qh.join('", "'),t))}else if(-1===Qh.indexOf(t))throw new TypeError(k('invalid argument. First argument must be one of the following data types: "%s". Value: `%s`.',Qh.join('", "'),t));return e="complex128"===t?Hh:"complex64"===t?Jh:NaN,Hc(r.length,e,t)})),C(oy,"nextDataType",(function(r){return 0===arguments.length?function(){var r,t,e,n;for(e={},t=(r=qi(Xh)).length,n=0;n1&&(t=arguments[1]),Kh(r.length,t)})),C(oy,"ones",(function(r){var t;return Hc(r,"complex128"===(t=arguments.length>1?arguments[1]:ep)?rp:"complex64"===t?tp:1,t)})),C(oy,"onesLike",(function(r){var t,e;if(null===(t=tn(r)))throw new TypeError(k("invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.",r));return arguments.length>1&&(t=arguments[1]),e="complex128"===t?np:"complex64"===t?ip:1,Hc(r.length,e,t)})),C(oy,"place",up),C(oy,"typedarraypool",Vp),C(oy,"promotionRules",(function(r,t){var e;return 0===arguments.length?function(){var r,t,e,n,i,o,a,u,f;for(e={},t=(r=qi(Ap)).length,f=0;f1&&(t.length=kp(e,t,1,r,e>2)),t})),C(oy,"SharedArrayBuffer",Mp),C(oy,"slice",(function(r){var t,e;if(!Rt(r))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",r));if(arguments.length>1){if(!Vt(t=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be an integer. Value: `%s`.",t));if(arguments.length>2){if(!Vt(e=arguments[2]))throw new TypeError(k("invalid argument. Third argument must be an integer. Value: `%s`.",e))}else e=r.length}else t=0,e=r.length;return ss(r,t,e)})),C(oy,"take",Pp),C(oy,"circarray2iterator",(function r(t){var e,n,i,o,a,u,f,l,s,c;if(!Rt(t))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(o={iter:1e308,dir:1},arguments.length>1)if(Xi(arguments[1])){if(n=arguments[1],arguments.length>2){if(!ue(f=arguments[2]))throw new TypeError(k("invalid argument. Callback argument must be a function. Value: `%s`.",f));e=arguments[3]}if(tr(n,"iter")&&(o.iter=n.iter,!Ft(n.iter)))throw new TypeError(k("invalid option. `%s` option must be a nonnegative integer. Option: `%s`.","iter",n.iter));if(tr(n,"dir")&&(o.dir=n.dir,1!==n.dir&&-1!==n.dir))throw new TypeError(k("invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.","dir",n.dir))}else{if(!ue(f=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be either a function or an options object. Value: `%s`.",f));e=arguments[2]}return i=0,a={},f?1===o.dir?(c=-1,U(a,"next",(function(){if(c=(c+1)%t.length,i+=1,u||i>o.iter||0===t.length)return{done:!0};return{value:f.call(e,l(t,c),c,i,t),done:!1}}))):(c=t.length,U(a,"next",(function(){(c-=1)<0&&(c+=t.length);if(i+=1,u||i>o.iter||0===t.length)return{done:!0};return{value:f.call(e,l(t,c),c,i,t),done:!1}}))):1===o.dir?(c=-1,U(a,"next",(function(){if(c=(c+1)%t.length,i+=1,u||i>o.iter||0===t.length)return{done:!0};return{value:l(t,c),done:!1}}))):(c=t.length,U(a,"next",(function(){(c-=1)<0&&(c+=t.length);if(i+=1,u||i>o.iter||0===t.length)return{done:!0};return{value:l(t,c),done:!1}}))),U(a,"return",(function(r){if(u=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(a,_e,(function(){if(f)return r(t,o,f,e);return r(t,o)})),s=tn(t),l=Y(t)?H(s):z(s),a})),C(oy,"array2fancy",Yg),C(oy,"array2iterator",(function r(t){var e,n,i,o,a,u,f;if(!Rt(t))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(arguments.length>1){if(!ue(o=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be a function. Value: `%s`.",o));e=arguments[2]}return f=-1,U(n={},"next",o?function(){if(f+=1,i||f>=t.length)return{done:!0};return{value:o.call(e,a(t,f),f,t),done:!1}}:function(){if(f+=1,i||f>=t.length)return{done:!0};return{value:a(t,f),done:!1}}),U(n,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(n,_e,(function(){if(o)return r(t,o,e);return r(t)})),u=tn(t),a=Y(t)?H(u):z(u),n})),C(oy,"array2iteratorRight",(function r(t){var e,n,i,o,a,u,f,l;if(!Rt(t))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(arguments.length>1){if(!ue(o=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be a function. Value: `%s`.",o));e=arguments[2]}return a=t.length,l=a,U(n={},"next",o?function(){if(l+=t.length-a-1,a=t.length,i||l<0)return i=!0,{done:!0};return{value:o.call(e,u(t,l),l,t),done:!1}}:function(){if(l+=t.length-a-1,a=t.length,i||l<0)return i=!0,{done:!0};return{value:u(t,l),done:!1}}),U(n,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(n,_e,(function(){if(o)return r(t,o,e);return r(t)})),f=tn(t),u=Y(t)?H(f):z(f),n})),C(oy,"typedarray2json",uh),C(oy,"sparsearray2iterator",(function r(t){var e,n,i,o,a,u,f;if(!Rt(t))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(arguments.length>1){if(!ue(o=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be a function. Value: `%s`.",o));e=arguments[2]}return f=-1,U(n={},"next",o?function(){var r;if(i)return{done:!0};r=t.length,f+=1;for(;f=r)return i=!0,{done:!0};return{value:o.call(e,a(t,f),f,t),done:!1}}:function(){var r;if(i)return{done:!0};r=t.length,f+=1;for(;f=r)return i=!0,{done:!0};return{value:a(t,f),done:!1}}),U(n,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(n,_e,(function(){if(o)return r(t,o,e);return r(t)})),u=tn(t),a=Y(t)?H(u):z(u),n})),C(oy,"sparsearray2iteratorRight",(function r(t){var e,n,i,o,a,u,f,l;if(!Rt(t))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(arguments.length>1){if(!ue(o=arguments[1]))throw new TypeError(k("invalid argument. Second argument must be a function. Value: `%s`.",o));e=arguments[2]}return a=t.length,l=a,U(n={},"next",o?function(){if(i)return{done:!0};l+=t.length-a-1,a=t.length;for(;l>=0&&void 0===u(t,l);)l-=1;if(l<0)return i=!0,{done:!0};return{value:o.call(e,u(t,l),l,t),done:!1}}:function(){if(i)return{done:!0};l+=t.length-a-1,a=t.length;for(;l>=0&&void 0===u(t,l);)l-=1;if(l<0)return i=!0,{done:!0};return{value:u(t,l),done:!1}}),U(n,"return",(function(r){if(i=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(n,_e,(function(){if(o)return r(t,o,e);return r(t)})),f=tn(t),u=Y(t)?H(f):z(f),n})),C(oy,"stridedarray2iterator",(function r(t,e,n,i){var o,a,u,f,l,s,c,h;if(!Ft(t))throw new TypeError(k("invalid argument. First argument must be a nonnegative integer. Value: `%s`.",t));if(!Rt(e))throw new TypeError(k("invalid argument. Second argument must be an array-like object. Value: `%s`.",e));if(!Vt(n))throw new TypeError(k("invalid argument. Third argument must be an integer. Value: `%s`.",n));if(!Ft(i))throw new TypeError(k("invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.",i));if(arguments.length>4){if(!ue(f=arguments[4]))throw new TypeError(k("invalid argument. Fifth argument must be a function. Value: `%s`.",f));o=arguments[5]}return l=i,h=-1,U(a={},"next",f?function(){var r;if(h+=1,u||h>=t)return{done:!0};return r=f.call(o,s(e,l),l,h,e),l+=n,{value:r,done:!1}}:function(){var r;if(h+=1,u||h>=t)return{done:!0};return r=s(e,l),l+=n,{value:r,done:!1}}),U(a,"return",(function(r){if(u=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(a,_e,(function(){if(f)return r(t,e,n,i,f,o);return r(t,e,n,i)})),c=tn(e),s=Y(e)?H(c):z(c),a})),C(oy,"arrayview2iterator",(function r(t){var e,n,i,o,a,u,f,l,s,c;if(!Rt(t))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(1===(i=arguments.length))n=0,f=t.length;else if(2===i)ue(arguments[1])?(n=0,u=arguments[1]):n=arguments[1],f=t.length;else if(3===i)ue(arguments[1])?(n=0,f=t.length,u=arguments[1],e=arguments[2]):ue(arguments[2])?(n=arguments[1],f=t.length,u=arguments[2]):(n=arguments[1],f=arguments[2]);else{if(n=arguments[1],f=arguments[2],!ue(u=arguments[3]))throw new TypeError(k("invalid argument. Fourth argument must be a function. Value: `%s`.",u));e=arguments[4]}if(!Vt(n))throw new TypeError(k("invalid argument. Second argument must be either an integer (starting index) or a function. Value: `%s`.",n));if(!Vt(f))throw new TypeError(k("invalid argument. Third argument must be either an integer (ending index) or a function. Value: `%s`.",f));return f<0?(f=t.length+f)<0&&(f=0):f>t.length&&(f=t.length),n<0&&(n=t.length+n)<0&&(n=0),c=n-1,U(o={},"next",u?function(){if(c+=1,a||c>=f)return{done:!0};return{value:u.call(e,l(t,c),c,c-n,t),done:!1}}:function(){if(c+=1,a||c>=f)return{done:!0};return{value:l(t,c),done:!1}}),U(o,"return",(function(r){if(a=!0,arguments.length)return{value:r,done:!0};return{done:!0}})),_e&&U(o,_e,(function(){if(u)return r(t,n,f,u,e);return r(t,n,f)})),s=tn(t),l=Y(t)?H(s):z(s),o})),C(oy,"arrayview2iteratorRight",(function r(t){var e,n,i,o,a,u,f,l,s,c;if(!Rt(t))throw new TypeError(k("invalid argument. First argument must be an array-like object. Value: `%s`.",t));if(1===(i=arguments.length))n=0,f=t.length;else if(2===i)ue(arguments[1])?(n=0,u=arguments[1]):n=arguments[1],f=t.length;else if(3===i)ue(arguments[1])?(n=0,f=t.length,u=arguments[1],e=arguments[2]):ue(arguments[2])?(n=arguments[1],f=t.length,u=arguments[2]):(n=arguments[1],f=arguments[2]);else{if(n=arguments[1],f=arguments[2],!ue(u=arguments[3]))throw new TypeError(k("invalid argument. Fourth argument must be a function. Value: `%s`.",u));e=arguments[4]}if(!Vt(n))throw new TypeError(k("invalid argument. Second argument must be either an integer (starting view index) or a function. Value: `%s`.",n));if(!Vt(f))throw new TypeError(k("invalid argument. Third argument must be either an integer (ending view index) or a function. Value: `%s`.",f));return f<0?(f=t.length+f)<0&&(f=0):f>t.length&&(f=t.length),n<0&&(n=t.length+n)<0&&(n=0),c=f,U(o={},"next",u?function(){if(c-=1,a||c1&&(t=arguments[1]),ny(r.length,t)})),C(oy,"zeros",ks),C(oy,"zerosLike",(function(r){var t=tn(r);if(null===t)throw new TypeError(k("invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.",r));return arguments.length>1&&(t=arguments[1]),ks(r.length,t)})),C(oy,"constants",iy),oy})); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 000000000..d51088755 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../node_modules/@stdlib/utils/define-property/lib/define_property.js","../node_modules/@stdlib/utils/define-property/lib/builtin.js","../node_modules/@stdlib/string/base/format-interpolate/lib/is_number.js","../node_modules/@stdlib/string/base/format-interpolate/lib/zero_pad.js","../node_modules/@stdlib/string/base/format-interpolate/lib/format_integer.js","../node_modules/@stdlib/string/base/format-interpolate/lib/format_double.js","../node_modules/@stdlib/string/base/format-interpolate/lib/space_pad.js","../node_modules/@stdlib/string/base/format-interpolate/lib/main.js","../node_modules/@stdlib/string/base/format-interpolate/lib/is_string.js","../node_modules/@stdlib/string/base/format-tokenize/lib/main.js","../node_modules/@stdlib/string/format/lib/main.js","../node_modules/@stdlib/string/format/lib/is_string.js","../node_modules/@stdlib/utils/define-property/lib/polyfill.js","../node_modules/@stdlib/utils/define-property/lib/index.js","../node_modules/@stdlib/utils/define-property/lib/has_define_property_support.js","../node_modules/@stdlib/utils/define-read-only-property/lib/main.js","../node_modules/@stdlib/utils/define-nonenumerable-read-only-property/lib/main.js","../base/assert/is-accessor-array/lib/main.js","../base/getter/lib/main.js","../base/setter/lib/main.js","../base/accessor-getter/lib/main.js","../base/accessor-setter/lib/main.js","../node_modules/@stdlib/assert/has-tostringtag-support/lib/main.js","../node_modules/@stdlib/assert/has-symbol-support/lib/main.js","../node_modules/@stdlib/utils/native-class/lib/tostring.js","../node_modules/@stdlib/assert/has-own-property/lib/main.js","../node_modules/@stdlib/symbol/ctor/lib/main.js","../node_modules/@stdlib/utils/native-class/lib/tostringtag.js","../node_modules/@stdlib/utils/native-class/lib/index.js","../node_modules/@stdlib/utils/native-class/lib/polyfill.js","../node_modules/@stdlib/utils/native-class/lib/main.js","../node_modules/@stdlib/assert/is-array/lib/main.js","../node_modules/@stdlib/assert/tools/array-function/lib/main.js","../node_modules/@stdlib/assert/is-object-like/lib/main.js","../node_modules/@stdlib/assert/is-buffer/lib/main.js","../node_modules/@stdlib/regexp/function-name/lib/main.js","../node_modules/@stdlib/assert/is-object-like/lib/index.js","../node_modules/@stdlib/regexp/function-name/lib/regexp.js","../node_modules/@stdlib/utils/constructor-name/lib/main.js","../node_modules/@stdlib/regexp/function-name/lib/index.js","../dtype/lib/ctor2dtype.js","../node_modules/@stdlib/assert/is-float64array/lib/main.js","../node_modules/@stdlib/assert/has-float64array-support/lib/float64array.js","../node_modules/@stdlib/assert/has-float64array-support/lib/main.js","../float64/lib/main.js","../float64/lib/index.js","../float64/lib/polyfill.js","../node_modules/@stdlib/assert/is-float32array/lib/main.js","../node_modules/@stdlib/constants/float64/pinf/lib/index.js","../node_modules/@stdlib/assert/has-float32array-support/lib/float32array.js","../node_modules/@stdlib/assert/has-float32array-support/lib/main.js","../float32/lib/main.js","../float32/lib/index.js","../float32/lib/polyfill.js","../node_modules/@stdlib/assert/is-uint32array/lib/main.js","../node_modules/@stdlib/constants/uint32/max/lib/index.js","../node_modules/@stdlib/assert/has-uint32array-support/lib/uint32array.js","../node_modules/@stdlib/assert/has-uint32array-support/lib/main.js","../uint32/lib/main.js","../uint32/lib/index.js","../uint32/lib/polyfill.js","../node_modules/@stdlib/assert/is-int32array/lib/main.js","../node_modules/@stdlib/constants/int32/max/lib/index.js","../node_modules/@stdlib/constants/int32/min/lib/index.js","../node_modules/@stdlib/assert/has-int32array-support/lib/int32array.js","../node_modules/@stdlib/assert/has-int32array-support/lib/main.js","../int32/lib/main.js","../int32/lib/index.js","../int32/lib/polyfill.js","../node_modules/@stdlib/assert/is-uint16array/lib/main.js","../node_modules/@stdlib/constants/uint16/max/lib/index.js","../node_modules/@stdlib/assert/has-uint16array-support/lib/uint16array.js","../node_modules/@stdlib/assert/has-uint16array-support/lib/main.js","../uint16/lib/main.js","../uint16/lib/index.js","../uint16/lib/polyfill.js","../node_modules/@stdlib/assert/is-int16array/lib/main.js","../node_modules/@stdlib/constants/int16/max/lib/index.js","../node_modules/@stdlib/constants/int16/min/lib/index.js","../node_modules/@stdlib/assert/has-int16array-support/lib/int16array.js","../node_modules/@stdlib/assert/has-int16array-support/lib/main.js","../int16/lib/main.js","../int16/lib/index.js","../int16/lib/polyfill.js","../node_modules/@stdlib/assert/is-uint8array/lib/main.js","../node_modules/@stdlib/constants/uint8/max/lib/index.js","../node_modules/@stdlib/assert/has-uint8array-support/lib/uint8array.js","../node_modules/@stdlib/assert/has-uint8array-support/lib/main.js","../uint8/lib/main.js","../uint8/lib/index.js","../uint8/lib/polyfill.js","../node_modules/@stdlib/assert/is-uint8clampedarray/lib/main.js","../node_modules/@stdlib/assert/has-uint8clampedarray-support/lib/uint8clampedarray.js","../node_modules/@stdlib/assert/has-uint8clampedarray-support/lib/main.js","../uint8c/lib/main.js","../uint8c/lib/index.js","../uint8c/lib/polyfill.js","../node_modules/@stdlib/assert/is-int8array/lib/main.js","../node_modules/@stdlib/constants/int8/max/lib/index.js","../node_modules/@stdlib/constants/int8/min/lib/index.js","../node_modules/@stdlib/assert/has-int8array-support/lib/int8array.js","../node_modules/@stdlib/assert/has-int8array-support/lib/main.js","../int8/lib/main.js","../int8/lib/index.js","../int8/lib/polyfill.js","../node_modules/@stdlib/assert/is-number/lib/primitive.js","../node_modules/@stdlib/number/ctor/lib/main.js","../node_modules/@stdlib/assert/is-number/lib/tostring.js","../node_modules/@stdlib/assert/is-number/lib/object.js","../node_modules/@stdlib/assert/is-number/lib/try2serialize.js","../node_modules/@stdlib/assert/is-number/lib/main.js","../node_modules/@stdlib/assert/is-number/lib/index.js","../node_modules/@stdlib/constants/float64/ninf/lib/index.js","../node_modules/@stdlib/math/base/special/floor/lib/main.js","../node_modules/@stdlib/math/base/assert/is-integer/lib/main.js","../node_modules/@stdlib/assert/is-integer/lib/integer.js","../node_modules/@stdlib/assert/is-integer/lib/primitive.js","../node_modules/@stdlib/assert/is-integer/lib/object.js","../node_modules/@stdlib/assert/is-integer/lib/main.js","../node_modules/@stdlib/assert/is-nonnegative-integer/lib/primitive.js","../node_modules/@stdlib/assert/is-nonnegative-integer/lib/object.js","../node_modules/@stdlib/assert/is-nonnegative-integer/lib/main.js","../node_modules/@stdlib/assert/is-integer/lib/index.js","../node_modules/@stdlib/assert/is-nonnegative-integer/lib/index.js","../node_modules/@stdlib/constants/array/max-array-length/lib/index.js","../node_modules/@stdlib/assert/is-array-like-object/lib/main.js","../node_modules/@stdlib/constants/array/max-typed-array-length/lib/index.js","../node_modules/@stdlib/assert/is-collection/lib/main.js","../node_modules/@stdlib/assert/is-arraybuffer/lib/main.js","../node_modules/@stdlib/assert/is-object/lib/main.js","../node_modules/@stdlib/assert/is-string/lib/primitive.js","../node_modules/@stdlib/assert/is-string/lib/valueof.js","../node_modules/@stdlib/assert/is-string/lib/object.js","../node_modules/@stdlib/assert/is-string/lib/try2valueof.js","../node_modules/@stdlib/assert/is-string/lib/main.js","../node_modules/@stdlib/assert/is-string/lib/index.js","../node_modules/@stdlib/assert/is-string-array/lib/index.js","../node_modules/@stdlib/utils/type-of/lib/fixtures/re.js","../node_modules/@stdlib/assert/is-boolean/lib/primitive.js","../node_modules/@stdlib/boolean/ctor/lib/main.js","../node_modules/@stdlib/assert/is-boolean/lib/tostring.js","../node_modules/@stdlib/assert/is-boolean/lib/object.js","../node_modules/@stdlib/assert/is-boolean/lib/try2serialize.js","../node_modules/@stdlib/assert/is-boolean/lib/main.js","../node_modules/@stdlib/assert/is-boolean/lib/index.js","../node_modules/@stdlib/utils/global/lib/self.js","../node_modules/@stdlib/utils/global/lib/window.js","../node_modules/@stdlib/utils/global/lib/global.js","../node_modules/@stdlib/utils/global/lib/global_this.js","../node_modules/@stdlib/utils/type-of/lib/fixtures/nodelist.js","../node_modules/@stdlib/utils/global/lib/main.js","../node_modules/@stdlib/utils/global/lib/codegen.js","../node_modules/@stdlib/utils/type-of/lib/fixtures/typedarray.js","../node_modules/@stdlib/utils/type-of/lib/index.js","../node_modules/@stdlib/utils/type-of/lib/check.js","../node_modules/@stdlib/utils/type-of/lib/polyfill.js","../node_modules/@stdlib/utils/type-of/lib/main.js","../node_modules/@stdlib/assert/is-function/lib/main.js","../node_modules/@stdlib/complex/float64/ctor/lib/main.js","../node_modules/@stdlib/complex/float64/ctor/lib/tostring.js","../node_modules/@stdlib/complex/float64/ctor/lib/tojson.js","../node_modules/@stdlib/number/float64/base/to-float32/lib/main.js","../node_modules/@stdlib/array/float32/lib/main.js","../node_modules/@stdlib/array/float32/lib/index.js","../node_modules/@stdlib/array/float32/lib/polyfill.js","../node_modules/@stdlib/number/float64/base/to-float32/lib/polyfill.js","../node_modules/@stdlib/number/float64/base/to-float32/lib/index.js","../node_modules/@stdlib/complex/float32/ctor/lib/main.js","../node_modules/@stdlib/assert/is-complex-like/lib/main.js","../node_modules/@stdlib/math/base/assert/is-even/lib/main.js","../node_modules/@stdlib/complex/float32/ctor/lib/tostring.js","../node_modules/@stdlib/complex/float32/ctor/lib/tojson.js","../base/assert/is-complex64array/lib/main.js","../base/assert/is-complex128array/lib/main.js","../node_modules/@stdlib/assert/has-iterator-symbol-support/lib/main.js","../node_modules/@stdlib/symbol/iterator/lib/main.js","../node_modules/@stdlib/utils/define-nonenumerable-read-only-accessor/lib/main.js","../node_modules/@stdlib/complex/float32/real/lib/main.js","../node_modules/@stdlib/complex/float32/imag/lib/main.js","../node_modules/@stdlib/strided/base/reinterpret-complex64/lib/main.js","../node_modules/@stdlib/array/float64/lib/main.js","../node_modules/@stdlib/array/float64/lib/index.js","../node_modules/@stdlib/array/float64/lib/polyfill.js","../node_modules/@stdlib/strided/base/reinterpret-complex128/lib/main.js","../complex64/lib/from_iterator.js","../complex64/lib/main.js","../complex64/lib/from_array.js","../node_modules/@stdlib/complex/float64/real/lib/main.js","../node_modules/@stdlib/complex/float64/imag/lib/main.js","../complex128/lib/from_iterator.js","../complex64/lib/from_iterator_map.js","../complex128/lib/main.js","../complex128/lib/from_array.js","../bool/lib/from_iterator.js","../complex128/lib/from_iterator_map.js","../bool/lib/main.js","../bool/lib/from_array.js","../bool/lib/from_iterator_map.js","../dtype/lib/ctors.js","../dtype/lib/dtypes.js","../dtype/lib/main.js","../base/accessors/lib/main.js","../base/accessor/lib/main.js","../node_modules/@stdlib/utils/define-nonenumerable-read-write-accessor/lib/main.js","../base/assert/is-booleanarray/lib/main.js","../base/arraylike2object/lib/main.js","../node_modules/@stdlib/array/uint8/lib/main.js","../node_modules/@stdlib/array/uint8/lib/index.js","../node_modules/@stdlib/array/uint8/lib/polyfill.js","../node_modules/@stdlib/strided/base/reinterpret-boolean/lib/main.js","../base/any/lib/main.js","../base/resolve-getter/lib/main.js","../node_modules/@stdlib/assert/has-property/lib/main.js","../base/assert/contains/lib/main.js","../base/assert/contains/lib/factory.js","../node_modules/@stdlib/math/base/assert/is-nanf/lib/main.js","../base/assert/contains/lib/index.js","../node_modules/@stdlib/constants/float32/sign-mask/lib/index.js","../node_modules/@stdlib/array/uint32/lib/main.js","../node_modules/@stdlib/array/uint32/lib/index.js","../node_modules/@stdlib/array/uint32/lib/polyfill.js","../node_modules/@stdlib/number/float32/base/to-word/lib/main.js","../node_modules/@stdlib/math/base/special/abs/lib/main.js","../node_modules/@stdlib/number/float32/base/ulp-difference/lib/main.js","../node_modules/@stdlib/number/float32/base/assert/is-almost-equal/lib/main.js","../node_modules/@stdlib/math/base/assert/is-nan/lib/main.js","../node_modules/@stdlib/constants/float64/high-word-sign-mask/lib/index.js","../node_modules/@stdlib/array/uint16/lib/main.js","../node_modules/@stdlib/array/uint16/lib/index.js","../node_modules/@stdlib/assert/is-little-endian/lib/main.js","../node_modules/@stdlib/array/uint16/lib/polyfill.js","../node_modules/@stdlib/assert/is-little-endian/lib/ctors.js","../node_modules/@stdlib/number/float64/base/to-words/lib/indices.js","../node_modules/@stdlib/number/float64/base/to-words/lib/assign.js","../node_modules/@stdlib/number/float64/base/to-words/lib/main.js","../node_modules/@stdlib/number/float64/base/to-words/lib/index.js","../node_modules/@stdlib/number/float64/base/ulp-difference/lib/main.js","../node_modules/@stdlib/number/float64/base/assert/is-almost-equal/lib/main.js","../node_modules/@stdlib/complex/float32/reim/lib/main.js","../node_modules/@stdlib/complex/float64/reim/lib/main.js","../node_modules/@stdlib/assert/is-almost-equal/lib/main.js","../node_modules/@stdlib/complex/float32/base/assert/is-almost-equal/lib/main.js","../node_modules/@stdlib/complex/float64/base/assert/is-almost-equal/lib/main.js","../base/assert/has-almost-equal-values/lib/main.js","../base/assert/has-equal-values/lib/main.js","../node_modules/@stdlib/number/float64/base/assert/is-same-value/lib/main.js","../node_modules/@stdlib/assert/is-same-value/lib/main.js","../node_modules/@stdlib/complex/float64/base/assert/is-same-value/lib/main.js","../base/assert/has-same-values/lib/main.js","../node_modules/@stdlib/string/base/replace/lib/main.js","../dtypes/lib/main.js","../base/assert/is-boolean-data-type/lib/main.js","../byte-orders/lib/main.js","../base/assert/is-byte-order/lib/main.js","../base/assert/is-complex-floating-point-data-type/lib/main.js","../base/assert/is-complex-typed-array/lib/main.js","../base/assert/is-data-type/lib/main.js","../base/assert/is-floating-point-data-type/lib/main.js","../base/assert/is-integer-data-type/lib/main.js","../node_modules/@stdlib/utils/keys/lib/builtin.js","../node_modules/@stdlib/utils/keys/lib/has_builtin.js","../node_modules/@stdlib/assert/is-arguments/lib/detect.js","../node_modules/@stdlib/assert/is-arguments/lib/main.js","../node_modules/@stdlib/assert/is-nan/lib/primitive.js","../node_modules/@stdlib/assert/is-nan/lib/object.js","../node_modules/@stdlib/assert/is-nan/lib/main.js","../node_modules/@stdlib/assert/is-nan/lib/index.js","../node_modules/@stdlib/assert/is-enumerable-property/lib/native.js","../node_modules/@stdlib/assert/is-enumerable-property/lib/has_string_enumerability_bug.js","../node_modules/@stdlib/assert/is-enumerable-property/lib/main.js","../node_modules/@stdlib/assert/is-arguments/lib/index.js","../node_modules/@stdlib/assert/is-arguments/lib/polyfill.js","../node_modules/@stdlib/utils/keys/lib/builtin_wrapper.js","../node_modules/@stdlib/utils/keys/lib/has_enumerable_prototype_bug.js","../node_modules/@stdlib/utils/noop/lib/main.js","../node_modules/@stdlib/utils/keys/lib/has_non_enumerable_properties_bug.js","../node_modules/@stdlib/utils/index-of/lib/main.js","../node_modules/@stdlib/utils/keys/lib/is_constructor_prototype.js","../node_modules/@stdlib/utils/keys/lib/window.js","../node_modules/@stdlib/utils/keys/lib/has_automation_equality_bug.js","../node_modules/@stdlib/utils/keys/lib/has_window.js","../node_modules/@stdlib/utils/keys/lib/main.js","../node_modules/@stdlib/utils/keys/lib/has_arguments_bug.js","../node_modules/@stdlib/utils/keys/lib/polyfill.js","../node_modules/@stdlib/utils/keys/lib/is_constructor_prototype_wrapper.js","../node_modules/@stdlib/utils/get-prototype-of/lib/detect.js","../node_modules/@stdlib/object/ctor/lib/main.js","../node_modules/@stdlib/utils/get-prototype-of/lib/native.js","../node_modules/@stdlib/utils/get-prototype-of/lib/polyfill.js","../node_modules/@stdlib/utils/get-prototype-of/lib/proto.js","../node_modules/@stdlib/utils/get-prototype-of/lib/main.js","../node_modules/@stdlib/assert/is-plain-object/lib/main.js","../node_modules/@stdlib/strided/dtypes/lib/main.js","../node_modules/@stdlib/ndarray/dtypes/lib/main.js","../node_modules/@stdlib/ndarray/dtypes/lib/enum.js","../node_modules/@stdlib/ndarray/dtypes/lib/index.js","../node_modules/@stdlib/ndarray/dtypes/lib/assign.js","../node_modules/@stdlib/strided/dtypes/lib/enum.js","../node_modules/@stdlib/strided/dtypes/lib/index.js","../node_modules/@stdlib/strided/dtypes/lib/assign.js","../node_modules/@stdlib/strided/base/dtype-enum2str/lib/main.js","../node_modules/@stdlib/utils/object-inverse/lib/main.js","../node_modules/@stdlib/strided/base/dtype-str2enum/lib/main.js","../node_modules/@stdlib/strided/base/dtype-resolve-str/lib/main.js","../mostly-safe-casts/lib/main.js","../base/assert/is-mostly-safe-data-type-cast/lib/main.js","../base/assert/is-numeric-data-type/lib/main.js","../safe-casts/lib/main.js","../base/assert/is-real-data-type/lib/main.js","../base/assert/is-real-floating-point-data-type/lib/main.js","../base/assert/is-safe-data-type-cast/lib/main.js","../same-kind-casts/lib/main.js","../base/assert/is-same-kind-data-type-cast/lib/main.js","../base/assert/is-signed-integer-data-type/lib/main.js","../base/assert/is-unsigned-integer-data-type/lib/main.js","../base/assert/lib/index.js","../node_modules/@stdlib/math/base/special/fast/max/lib/main.js","../node_modules/@stdlib/math/base/special/fast/min/lib/main.js","../base/filled/lib/main.js","../base/filled2d/lib/main.js","../base/zeros2d/lib/main.js","../base/assert/has-equal-values-indexed/lib/main.js","../base/assert/is-sorted-ascending/lib/main.js","../base/banded/lib/index.js","../base/binarynd/lib/main.js","../base/copy-indexed/lib/main.js","../base/zeros/lib/main.js","../base/broadcast-array/lib/main.js","../node_modules/@stdlib/math/base/assert/is-odd/lib/main.js","../node_modules/@stdlib/math/base/assert/is-infinite/lib/main.js","../base/banded/filled2d-by/lib/main.js","../base/banded/to-compact/lib/main.js","../node_modules/@stdlib/math/base/special/sqrt/lib/main.js","../node_modules/@stdlib/number/float64/base/set-low-word/lib/low.js","../node_modules/@stdlib/number/float64/base/set-low-word/lib/main.js","../node_modules/@stdlib/number/uint32/base/to-int32/lib/main.js","../node_modules/@stdlib/constants/float64/high-word-abs-mask/lib/index.js","../node_modules/@stdlib/number/float64/base/from-words/lib/indices.js","../node_modules/@stdlib/number/float64/base/get-high-word/lib/high.js","../node_modules/@stdlib/number/float64/base/get-high-word/lib/main.js","../node_modules/@stdlib/number/float64/base/from-words/lib/main.js","../node_modules/@stdlib/math/base/special/copysign/lib/main.js","../node_modules/@stdlib/math/base/special/pow/lib/y_is_huge.js","../node_modules/@stdlib/number/float64/base/set-high-word/lib/high.js","../node_modules/@stdlib/number/float64/base/set-high-word/lib/main.js","../node_modules/@stdlib/constants/float64/exponent-bias/lib/index.js","../node_modules/@stdlib/constants/float64/num-high-word-significand-bits/lib/index.js","../node_modules/@stdlib/math/base/special/pow/lib/log2ax.js","../node_modules/@stdlib/math/base/special/pow/lib/logx.js","../node_modules/@stdlib/constants/float64/max-base2-exponent/lib/index.js","../node_modules/@stdlib/constants/float64/max-base2-exponent-subnormal/lib/index.js","../node_modules/@stdlib/constants/float64/min-base2-exponent-subnormal/lib/index.js","../node_modules/@stdlib/constants/float64/smallest-normal/lib/index.js","../node_modules/@stdlib/number/float64/base/normalize/lib/assign.js","../node_modules/@stdlib/number/float64/base/normalize/lib/index.js","../node_modules/@stdlib/number/float64/base/normalize/lib/main.js","../node_modules/@stdlib/constants/float64/high-word-exponent-mask/lib/index.js","../node_modules/@stdlib/math/base/special/ldexp/lib/main.js","../node_modules/@stdlib/number/float64/base/exponent/lib/main.js","../node_modules/@stdlib/constants/float64/ln-two/lib/index.js","../node_modules/@stdlib/constants/float64/high-word-significand-mask/lib/index.js","../node_modules/@stdlib/math/base/special/pow/lib/pow2.js","../node_modules/@stdlib/math/base/special/pow/lib/main.js","../node_modules/@stdlib/math/base/special/pow/lib/y_is_infinite.js","../node_modules/@stdlib/math/base/special/pow/lib/x_is_zero.js","../node_modules/@stdlib/math/base/special/pow/lib/polyval_w.js","../node_modules/@stdlib/math/base/special/pow/lib/polyval_l.js","../node_modules/@stdlib/math/base/special/pow/lib/polyval_p.js","../base/cartesian-power/lib/main.js","../base/cartesian-product/lib/main.js","../base/cartesian-square/lib/main.js","../base/copy/lib/main.js","../node_modules/@stdlib/array/base/assert/is-complex128array/lib/main.js","../node_modules/@stdlib/array/base/assert/is-complex64array/lib/main.js","../node_modules/@stdlib/strided/base/reinterpret-complex/lib/main.js","../base/count-falsy/lib/main.js","../base/zero-to/lib/main.js","../base/zero-to/lib/assign.js","../base/count-ifs/lib/main.js","../node_modules/@stdlib/number/float64/base/assert/is-same-value-zero/lib/main.js","../node_modules/@stdlib/assert/is-same-value-zero/lib/main.js","../node_modules/@stdlib/complex/float64/base/assert/is-same-value-zero/lib/main.js","../base/count-truthy/lib/main.js","../base/cuany/lib/assign.js","../base/cuany/lib/main.js","../base/cuevery/lib/assign.js","../base/cuevery/lib/main.js","../base/cunone/lib/assign.js","../base/cunone/lib/main.js","../node_modules/@stdlib/utils/define-read-write-accessor/lib/main.js","../base/every/lib/main.js","../node_modules/@stdlib/slice/ctor/lib/main.js","../node_modules/@stdlib/assert/is-null/lib/main.js","../node_modules/@stdlib/assert/is-undefined/lib/main.js","../node_modules/@stdlib/slice/base/normalize-slice/lib/main.js","../node_modules/@stdlib/slice/base/normalize-slice/lib/error_out_of_bounds.js","../base/zero-to/lib/index.js","../base/cuany/lib/index.js","../base/cuevery/lib/index.js","../base/cunone/lib/index.js","../node_modules/@stdlib/math/base/special/ceil/lib/main.js","../node_modules/@stdlib/slice/base/length/lib/main.js","../node_modules/@stdlib/array/base/assert/is-accessor-array/lib/main.js","../node_modules/@stdlib/array/base/getter/lib/main.js","../node_modules/@stdlib/array/base/setter/lib/main.js","../node_modules/@stdlib/array/base/accessor-getter/lib/main.js","../node_modules/@stdlib/array/base/accessor-setter/lib/main.js","../node_modules/@stdlib/array/dtype/lib/ctor2dtype.js","../node_modules/@stdlib/array/int32/lib/main.js","../node_modules/@stdlib/array/int32/lib/index.js","../node_modules/@stdlib/array/int32/lib/polyfill.js","../node_modules/@stdlib/array/int16/lib/main.js","../node_modules/@stdlib/array/int16/lib/index.js","../node_modules/@stdlib/array/int16/lib/polyfill.js","../node_modules/@stdlib/array/uint8c/lib/main.js","../node_modules/@stdlib/array/uint8c/lib/index.js","../node_modules/@stdlib/array/uint8c/lib/polyfill.js","../node_modules/@stdlib/array/int8/lib/main.js","../node_modules/@stdlib/array/int8/lib/index.js","../node_modules/@stdlib/array/int8/lib/polyfill.js","../node_modules/@stdlib/array/complex64/lib/from_iterator.js","../node_modules/@stdlib/array/complex64/lib/main.js","../node_modules/@stdlib/array/complex64/lib/from_array.js","../node_modules/@stdlib/array/complex128/lib/from_iterator.js","../node_modules/@stdlib/array/complex64/lib/from_iterator_map.js","../node_modules/@stdlib/array/complex128/lib/main.js","../node_modules/@stdlib/array/complex128/lib/from_array.js","../node_modules/@stdlib/array/bool/lib/from_iterator.js","../node_modules/@stdlib/array/complex128/lib/from_iterator_map.js","../node_modules/@stdlib/array/bool/lib/main.js","../node_modules/@stdlib/array/bool/lib/from_array.js","../node_modules/@stdlib/array/bool/lib/from_iterator_map.js","../node_modules/@stdlib/array/dtype/lib/ctors.js","../node_modules/@stdlib/array/dtype/lib/dtypes.js","../node_modules/@stdlib/array/dtype/lib/main.js","../node_modules/@stdlib/array/base/arraylike2object/lib/main.js","../node_modules/@stdlib/blas/base/gcopy/lib/accessors.js","../node_modules/@stdlib/blas/base/gcopy/lib/main.js","../node_modules/@stdlib/blas/base/gcopy/lib/ndarray.js","../base/fancy-slice/lib/main.js","../node_modules/@stdlib/blas/base/gcopy/lib/index.js","../ctors/lib/ctors.js","../ctors/lib/main.js","../convert/lib/main.js","../base/fancy-slice-assign/lib/main.js","../base/filled-by/lib/main.js","../base/filled3d/lib/main.js","../base/filled4d/lib/main.js","../base/filled5d/lib/main.js","../base/fillednd/lib/main.js","../base/fillednd-by/lib/main.js","../node_modules/@stdlib/ndarray/base/numel/lib/main.js","../node_modules/@stdlib/ndarray/base/assert/is-column-major-string/lib/main.js","../node_modules/@stdlib/ndarray/base/shape2strides/lib/main.js","../node_modules/@stdlib/ndarray/base/vind2bind/lib/main.js","../node_modules/@stdlib/strided/base/stride2offset/lib/main.js","../node_modules/@stdlib/ndarray/base/shape2strides/lib/index.js","../node_modules/@stdlib/ndarray/base/shape2strides/lib/assign.js","../node_modules/@stdlib/blas/ext/base/grev/lib/ndarray.js","../node_modules/@stdlib/blas/ext/base/grev/lib/accessors.js","../node_modules/@stdlib/blas/ext/base/grev/lib/main.js","../node_modules/@stdlib/blas/ext/base/grev/lib/index.js","../base/flatten/lib/assign.js","../base/flatten/lib/main.js","../base/flatten/lib/index.js","../base/flatten-by/lib/assign.js","../base/flatten-by/lib/main.js","../base/flatten2d/lib/main.js","../base/flatten2d-by/lib/main.js","../base/flatten3d/lib/main.js","../base/flatten3d-by/lib/main.js","../base/flatten4d/lib/main.js","../base/flatten4d-by/lib/main.js","../base/flatten5d/lib/main.js","../base/flatten5d-by/lib/main.js","../base/fliplr2d/lib/main.js","../base/fliplr3d/lib/main.js","../base/fliplr4d/lib/main.js","../base/flipud2d/lib/main.js","../base/flipud3d/lib/main.js","../base/flipud4d/lib/main.js","../base/incrspace/lib/main.js","../node_modules/@stdlib/assert/is-accessor-array/lib/main.js","../node_modules/@stdlib/assert/is-undefined-or-null/lib/main.js","../base/logspace/lib/main.js","../base/map2d/lib/main.js","../base/map3d/lib/main.js","../base/map4d/lib/main.js","../base/map5d/lib/main.js","../base/min-signed-integer-dtype/lib/main.js","../base/mskfilter/lib/main.js","../base/mskfilter-map/lib/main.js","../base/mskput/lib/main.js","../base/mskreject/lib/main.js","../node_modules/@stdlib/utils/define-nonenumerable-property/lib/main.js","../base/none/lib/main.js","../base/one-to/lib/main.js","../base/one-to/lib/assign.js","../base/place/lib/main.js","../node_modules/@stdlib/ndarray/base/clamp-index/lib/main.js","../node_modules/@stdlib/ndarray/base/wrap-index/lib/main.js","../node_modules/@stdlib/ndarray/base/normalize-index/lib/main.js","../node_modules/@stdlib/array/base/assert/contains/lib/factory.js","../base/flatten-by/lib/index.js","../base/flatten2d/lib/index.js","../base/flatten2d/lib/assign.js","../base/flatten2d-by/lib/index.js","../base/flatten2d-by/lib/assign.js","../base/flatten3d/lib/index.js","../base/flatten3d/lib/assign.js","../base/flatten3d-by/lib/index.js","../base/flatten3d-by/lib/assign.js","../base/flatten4d/lib/index.js","../base/flatten4d/lib/assign.js","../base/flatten4d-by/lib/index.js","../base/flatten4d-by/lib/assign.js","../base/flatten5d/lib/index.js","../base/flatten5d/lib/assign.js","../base/flatten5d-by/lib/index.js","../base/flatten5d-by/lib/assign.js","../base/map2d/lib/index.js","../base/map2d/lib/assign.js","../base/map3d/lib/index.js","../base/map3d/lib/assign.js","../base/map4d/lib/index.js","../base/map4d/lib/assign.js","../base/map5d/lib/index.js","../base/map5d/lib/assign.js","../base/mskfilter/lib/index.js","../base/mskfilter/lib/assign.js","../base/mskfilter-map/lib/index.js","../base/mskfilter-map/lib/assign.js","../base/mskreject/lib/index.js","../base/mskreject/lib/assign.js","../base/one-to/lib/index.js","../node_modules/@stdlib/array/base/assert/contains/lib/index.js","../node_modules/@stdlib/array/base/assert/contains/lib/main.js","../node_modules/@stdlib/ndarray/index-modes/lib/main.js","../node_modules/@stdlib/ndarray/index-modes/lib/index.js","../node_modules/@stdlib/ndarray/index-modes/lib/enum.js","../node_modules/@stdlib/ndarray/base/assert/is-index-mode/lib/main.js","../node_modules/@stdlib/ndarray/base/ind/lib/factory.js","../base/put/lib/main.js","../node_modules/@stdlib/ndarray/base/ind/lib/index.js","../node_modules/@stdlib/ndarray/base/ind/lib/main.js","../base/slice/lib/main.js","../base/reshape/lib/main.js","../base/resolve-setter/lib/main.js","../base/symmetric/lib/index.js","../base/symmetric/filled2d-by/lib/main.js","../base/symmetric-banded/lib/index.js","../base/take/lib/main.js","../base/symmetric-banded/filled2d-by/lib/main.js","../base/symmetric-banded/to-compact/lib/main.js","../base/take/lib/index.js","../base/take/lib/assign.js","../base/take2d/lib/main.js","../base/unarynd/lib/main.js","../node_modules/@stdlib/math/base/assert/is-positive-zero/lib/main.js","../base/where/lib/resolve_stride.js","../base/where/lib/main.js","../node_modules/@stdlib/math/base/special/maxn/lib/main.js","../base/where/lib/assign.js","../base/where/lib/numel.js","../base/with/lib/main.js","../base/with/lib/assign.js","../defaults/lib/main.js","../base/where/lib/index.js","../base/with/lib/index.js","../defaults/lib/get.js","../defaults/lib/index.js","../zeros/lib/main.js","../base/without/lib/assign.js","../base/without/lib/main.js","../base/without/lib/index.js","../base/lib/index.js","../base/any-by/lib/main.js","../base/any-by-right/lib/main.js","../base/any-has-own-property/lib/main.js","../base/any-has-property/lib/main.js","../base/any-is-entry/lib/main.js","../base/any-is-entry-in/lib/main.js","../base/at/lib/main.js","../base/at2d/lib/main.js","../base/at3d/lib/main.js","../base/at4d/lib/main.js","../base/at5d/lib/main.js","../base/atnd/lib/main.js","../base/bifurcate-entries/lib/main.js","../base/bifurcate-entries-by/lib/main.js","../base/bifurcate-indices/lib/main.js","../base/bifurcate-indices-by/lib/main.js","../base/bifurcate-values/lib/main.js","../base/bifurcate-values-by/lib/main.js","../base/binary2d/lib/main.js","../base/binary3d/lib/main.js","../base/binary4d/lib/main.js","../base/binary5d/lib/main.js","../base/broadcasted-binary2d/lib/main.js","../base/broadcasted-binary3d/lib/main.js","../base/broadcasted-binary4d/lib/main.js","../base/broadcasted-binary5d/lib/main.js","../base/broadcasted-quaternary2d/lib/main.js","../base/broadcasted-quaternary3d/lib/main.js","../base/broadcasted-quaternary4d/lib/main.js","../base/broadcasted-quaternary5d/lib/main.js","../base/broadcasted-quinary2d/lib/main.js","../base/broadcasted-quinary4d/lib/main.js","../base/broadcasted-ternary2d/lib/main.js","../base/broadcasted-ternary3d/lib/main.js","../base/broadcasted-ternary4d/lib/main.js","../base/broadcasted-ternary5d/lib/main.js","../base/broadcasted-unary2d/lib/main.js","../base/broadcasted-unary3d/lib/main.js","../base/broadcasted-unary4d/lib/main.js","../base/broadcasted-unary5d/lib/main.js","../base/count-if/lib/main.js","../base/count-same-value/lib/main.js","../base/count-same-value-zero/lib/main.js","../base/dedupe/lib/main.js","../base/entries2objects/lib/main.js","../base/entries2views/lib/main.js","../node_modules/@stdlib/utils/define-read-only-accessor/lib/main.js","../base/every-by/lib/main.js","../base/every-by-right/lib/main.js","../base/fill/lib/main.js","../base/fill-by/lib/main.js","../base/filled2d-by/lib/main.js","../base/filled3d-by/lib/main.js","../base/filled4d-by/lib/main.js","../base/filled5d-by/lib/main.js","../base/filter/lib/main.js","../base/first/lib/main.js","../base/fliplr5d/lib/main.js","../base/flipud5d/lib/main.js","../base/from-strided/lib/main.js","../base/group-entries/lib/main.js","../base/group-entries-by/lib/main.js","../base/group-indices/lib/main.js","../base/group-indices-by/lib/main.js","../base/group-values/lib/main.js","../base/group-values-by/lib/main.js","../base/group-values-on-key/lib/main.js","../base/index-of/lib/main.js","../base/index-of-same-value/lib/main.js","../base/indices-complement/lib/main.js","../base/join/lib/main.js","../base/last/lib/main.js","../base/last-index-of/lib/main.js","../base/last-index-of-same-value/lib/main.js","../base/linspace/lib/main.js","../base/linspace2d/lib/main.js","../base/min-unsigned-integer-dtype/lib/main.js","../base/mskbinary2d/lib/main.js","../base/mskbinary3d/lib/main.js","../base/mskbinary4d/lib/main.js","../base/mskbinary5d/lib/main.js","../base/mskfilter2/lib/main.js","../base/mskfiltern/lib/main.js","../base/mskunary2d/lib/main.js","../base/mskunary3d/lib/main.js","../base/mskunary4d/lib/main.js","../base/mskunary5d/lib/main.js","../base/n-cartesian-product/lib/main.js","../base/nested2objects/lib/main.js","../base/nested2views/lib/main.js","../base/none-by/lib/main.js","../base/none-by-right/lib/main.js","../base/nulls/lib/main.js","../base/ones/lib/main.js","../base/ones2d/lib/main.js","../base/ones3d/lib/main.js","../base/ones4d/lib/main.js","../base/ones5d/lib/main.js","../base/onesnd/lib/main.js","../base/quaternary2d/lib/main.js","../base/quaternary3d/lib/main.js","../base/quaternary4d/lib/main.js","../base/quaternary5d/lib/main.js","../base/quinary2d/lib/main.js","../base/quinary3d/lib/main.js","../base/quinary4d/lib/main.js","../base/quinary5d/lib/main.js","../base/reject/lib/main.js","../base/rekey/lib/main.js","../base/rekey-views/lib/main.js","../base/remove-at/lib/main.js","../base/reverse/lib/main.js","../base/scatter-filled/lib/main.js","../base/scattered/lib/main.js","../base/strided2array2d/lib/main.js","../base/strided2array3d/lib/main.js","../base/strided2array4d/lib/main.js","../base/strided2array5d/lib/main.js","../base/take-indexed/lib/main.js","../base/take-indexed2/lib/main.js","../base/take3d/lib/main.js","../base/ternary2d/lib/main.js","../base/ternary3d/lib/main.js","../base/ternary4d/lib/main.js","../base/ternary5d/lib/main.js","../base/to-accessor-array/lib/main.js","../base/to-deduped/lib/main.js","../base/to-reversed/lib/main.js","../base/unary2d/lib/main.js","../base/unary2d-by/lib/main.js","../base/unary3d/lib/main.js","../base/unary3d-by/lib/main.js","../base/unary4d/lib/main.js","../base/unary4d-by/lib/main.js","../base/unary5d/lib/main.js","../base/unary5d-by/lib/main.js","../base/unitspace/lib/main.js","../base/zeros3d/lib/main.js","../base/zeros4d/lib/main.js","../base/zeros5d/lib/main.js","../base/zerosnd/lib/main.js","../base/zip/lib/main.js","../base/zip2object/lib/main.js","../base/zip2objects/lib/main.js","../base/zip2views/lib/main.js","../node_modules/@stdlib/assert/has-arraybuffer-support/lib/arraybuffer.js","../node_modules/@stdlib/assert/has-arraybuffer-support/lib/main.js","../buffer/lib/main.js","../buffer/lib/index.js","../buffer/lib/polyfill.js","../node_modules/@stdlib/assert/is-dataview/lib/main.js","../node_modules/@stdlib/array/buffer/lib/main.js","../node_modules/@stdlib/array/buffer/lib/index.js","../node_modules/@stdlib/array/buffer/lib/polyfill.js","../node_modules/@stdlib/assert/has-dataview-support/lib/dataview.js","../dataview/lib/main.js","../dataview/lib/index.js","../node_modules/@stdlib/assert/has-dataview-support/lib/main.js","../dataview/lib/polyfill.js","../node_modules/@stdlib/math/base/special/round/lib/main.js","../datespace/lib/main.js","../node_modules/@stdlib/assert/has-node-buffer-support/lib/buffer.js","../node_modules/@stdlib/buffer/ctor/lib/main.js","../node_modules/@stdlib/buffer/ctor/lib/index.js","../node_modules/@stdlib/assert/has-node-buffer-support/lib/main.js","../node_modules/@stdlib/buffer/ctor/lib/polyfill.js","../node_modules/@stdlib/buffer/alloc-unsafe/lib/index.js","../node_modules/@stdlib/buffer/alloc-unsafe/lib/has_alloc_unsafe.js","../node_modules/@stdlib/buffer/alloc-unsafe/lib/main.js","../node_modules/@stdlib/buffer/alloc-unsafe/lib/polyfill.js","../typed-ctors/lib/ctors.js","../typed-ctors/lib/main.js","../node_modules/@stdlib/ndarray/base/bytes-per-element/lib/main.js","../empty/lib/main.js","../empty/lib/index.js","../empty/lib/is_buffer_uint8array.js","../empty/lib/polyfill.js","../node_modules/@stdlib/blas/ext/base/gfill/lib/ndarray.js","../node_modules/@stdlib/blas/ext/base/gfill/lib/accessors.js","../node_modules/@stdlib/blas/ext/base/gfill/lib/main.js","../node_modules/@stdlib/assert/is-iterator-like/lib/main.js","../node_modules/@stdlib/iter/length/lib/main.js","../node_modules/@stdlib/blas/ext/base/gfill/lib/index.js","../filled/lib/main.js","../node_modules/@stdlib/blas/ext/base/gfill-by/lib/ndarray.js","../node_modules/@stdlib/blas/ext/base/gfill-by/lib/accessors.js","../node_modules/@stdlib/blas/ext/base/gfill-by/lib/main.js","../node_modules/@stdlib/blas/ext/base/gfill-by/lib/index.js","../filled-by/lib/main.js","../node_modules/@stdlib/assert/is-prototype-of/lib/main.js","../node_modules/@stdlib/string/base/capitalize/lib/main.js","../fixed-endian-factory/lib/from_iterator.js","../fixed-endian-factory/lib/main.js","../node_modules/@stdlib/string/base/lowercase/lib/main.js","../fixed-endian-factory/lib/from_iterator_map.js","../fixed-endian-float32/lib/main.js","../fixed-endian-float64/lib/main.js","../node_modules/@stdlib/complex/dtype/lib/ctor2dtype.js","../node_modules/@stdlib/complex/ctors/lib/ctors.js","../node_modules/@stdlib/complex/ctors/lib/main.js","../node_modules/@stdlib/complex/dtype/lib/dtypes.js","../node_modules/@stdlib/complex/dtype/lib/ctors.js","../node_modules/@stdlib/complex/dtypes/lib/main.js","../node_modules/@stdlib/complex/dtype/lib/main.js","../from-scalar/lib/main.js","../full/lib/main.js","../node_modules/@stdlib/assert/has-function-name-support/lib/foo.js","../node_modules/@stdlib/utils/function-name/lib/main.js","../node_modules/@stdlib/assert/has-function-name-support/lib/main.js","../node_modules/@stdlib/assert/is-typed-array/lib/ctors.js","../node_modules/@stdlib/assert/is-typed-array/lib/main.js","../node_modules/@stdlib/assert/is-complex-typed-array/lib/ctors.js","../node_modules/@stdlib/assert/is-booleanarray/lib/main.js","../node_modules/@stdlib/assert/instance-of/lib/main.js","../to-json/lib/ctors.js","../to-json/lib/type.js","../to-json/lib/main.js","../node_modules/@stdlib/assert/is-complex-typed-array/lib/main.js","../node_modules/@stdlib/dstructs/linked-list/lib/node.js","../node_modules/@stdlib/dstructs/linked-list/lib/main.js","../index/lib/cache.js","../index/lib/find.js","../index/lib/id.js","../index/lib/main.js","../index/lib/defaults.js","../index/lib/validate.js","../typed-float-ctors/lib/ctors.js","../typed-float-ctors/lib/main.js","../linspace/lib/typed_real.js","../linspace/lib/typed_complex.js","../linspace/lib/validate.js","../linspace/lib/main.js","../linspace/lib/generic_complex.js","../linspace/lib/generic_real.js","../node_modules/@stdlib/utils/inherit/lib/validate.js","../linspace/lib/index.js","../linspace/lib/assign.js","../linspace/lib/accessors_complex.js","../linspace/lib/accessors_real.js","../node_modules/@stdlib/utils/inherit/lib/native.js","../node_modules/@stdlib/utils/inherit/lib/polyfill.js","../node_modules/@stdlib/utils/inherit/lib/detect.js","../little-endian-factory/lib/main.js","../little-endian-factory/lib/from_iterator_map.js","../little-endian-factory/lib/from_iterator.js","../node_modules/@stdlib/utils/inherit/lib/main.js","../little-endian-float32/lib/main.js","../little-endian-float64/lib/main.js","../node_modules/@stdlib/math/base/assert/is-negative-zero/lib/main.js","../node_modules/@stdlib/constants/float32/smallest-subnormal/lib/index.js","../node_modules/@stdlib/constants/float32/max-safe-integer/lib/index.js","../node_modules/@stdlib/constants/float32/min-safe-integer/lib/index.js","../min-dtype/lib/main.js","../mskfilter/lib/main.js","../mskput/lib/validate.js","../mskreject/lib/main.js","../nans/lib/main.js","../nans-like/lib/main.js","../one-to/lib/main.js","../ones/lib/main.js","../ones-like/lib/main.js","../place/lib/validate.js","../place/lib/main.js","../place/lib/defaults.js","../node_modules/@stdlib/math/base/special/log2/lib/main.js","../node_modules/@stdlib/math/base/special/kernel-log1p/lib/main.js","../node_modules/@stdlib/math/base/special/kernel-log1p/lib/polyval_p.js","../node_modules/@stdlib/math/base/special/kernel-log1p/lib/polyval_q.js","../pool/lib/factory.js","../pool/lib/defaults.js","../pool/lib/validate.js","../pool/lib/pool.js","../node_modules/@stdlib/assert/is-typed-array-like/lib/main.js","../node_modules/@stdlib/math/base/special/min/lib/main.js","../node_modules/@stdlib/math/base/special/ceil2/lib/main.js","../node_modules/@stdlib/assert/is-complex128array/lib/main.js","../node_modules/@stdlib/assert/is-complex64array/lib/main.js","../pool/lib/main.js","../pool/lib/index.js","../put/lib/main.js","../put/lib/defaults.js","../put/lib/validate.js","../reviver/lib/ctors.js","../shape/lib/main.js","../node_modules/@stdlib/assert/is-sharedarraybuffer/lib/main.js","../node_modules/@stdlib/assert/has-sharedarraybuffer-support/lib/sharedarraybuffer.js","../shared-buffer/lib/main.js","../shared-buffer/lib/index.js","../node_modules/@stdlib/assert/has-sharedarraybuffer-support/lib/main.js","../shared-buffer/lib/polyfill.js","../take/lib/main.js","../take/lib/defaults.js","../take/lib/validate.js","../node_modules/@stdlib/utils/eval/lib/index.js","../node_modules/@stdlib/proxy/ctor/lib/main.js","../node_modules/@stdlib/proxy/ctor/lib/index.js","../node_modules/@stdlib/assert/has-proxy-support/lib/main.js","../node_modules/@stdlib/proxy/ctor/lib/polyfill.js","../node_modules/@stdlib/object/assign/lib/has_object_assign.js","../node_modules/@stdlib/object/assign/lib/builtin.js","../node_modules/@stdlib/utils/property-symbols/lib/has_builtin.js","../node_modules/@stdlib/utils/property-symbols/lib/builtin.js","../node_modules/@stdlib/utils/property-symbols/lib/index.js","../node_modules/@stdlib/object/assign/lib/index.js","../node_modules/@stdlib/utils/property-symbols/lib/polyfill.js","../node_modules/@stdlib/utils/enumerable-properties/lib/main.js","../node_modules/@stdlib/object/assign/lib/polyfill.js","../to-fancy/lib/set_element_wrapper.js","../to-fancy/lib/get_array_wrapper.js","../to-fancy/lib/has_proxy_support.js","../to-fancy/lib/validate.js","../node_modules/@stdlib/assert/is-method-in/lib/main.js","../to-fancy/lib/validator.js","../to-fancy/lib/ctor.js","../to-fancy/lib/re_integer.js","../to-fancy/lib/is_integer_string.js","../to-fancy/lib/re_array_index.js","../to-fancy/lib/is_array_index_string.js","../node_modules/@stdlib/string/base/trim/lib/has_builtin.js","../node_modules/@stdlib/string/base/trim/lib/builtin.js","../node_modules/@stdlib/string/base/trim/lib/polyfill.js","../node_modules/@stdlib/string/base/trim/lib/index.js","../node_modules/@stdlib/string/base/trim/lib/check.js","../node_modules/@stdlib/string/base/trim/lib/main.js","../to-fancy/lib/prop2array.js","../to-fancy/lib/resolve_index.js","../to-fancy/lib/error_message.js","../node_modules/@stdlib/slice/base/seq2slice/lib/re_end_minus.js","../node_modules/@stdlib/slice/base/seq2slice/lib/re_end_divide.js","../node_modules/@stdlib/slice/base/seq2slice/lib/resolve_end.js","../node_modules/@stdlib/slice/base/seq2slice/lib/re_colon_sep.js","../node_modules/@stdlib/slice/base/seq2slice/lib/re_integer.js","../node_modules/@stdlib/slice/base/seq2slice/lib/re_end.js","../node_modules/@stdlib/slice/base/seq2slice/lib/main.js","../node_modules/@stdlib/slice/base/seq2slice/lib/error_invalid_subsequence.js","../node_modules/@stdlib/slice/base/seq2slice/lib/error_invalid_increment.js","../node_modules/@stdlib/slice/base/seq2slice/lib/error_out_of_bounds.js","../node_modules/@stdlib/slice/base/str2slice/lib/main.js","../node_modules/@stdlib/string/base/starts-with/lib/has_builtin.js","../node_modules/@stdlib/string/base/starts-with/lib/builtin.js","../node_modules/@stdlib/string/base/starts-with/lib/index.js","../node_modules/@stdlib/string/base/starts-with/lib/main.js","../node_modules/@stdlib/string/base/starts-with/lib/polyfill.js","../to-fancy/lib/re_subseq.js","../to-fancy/lib/prop2slice.js","../to-fancy/lib/get.js","../to-fancy/lib/get_element.js","../to-fancy/lib/get_value.js","../to-fancy/lib/get_elements.js","../to-fancy/lib/get_slice.js","../to-fancy/lib/set_value.js","../to-fancy/lib/set.js","../to-fancy/lib/set_element.js","../to-fancy/lib/set_elements.js","../to-fancy/lib/set_slice.js","../to-fancy/lib/factory.js","../to-fancy/lib/defaults.js","../node_modules/@stdlib/assert/is-array-like/lib/main.js","../to-fancy/lib/main.js","../to-fancy/lib/index.js","../typed/lib/main.js","../typed-complex-ctors/lib/ctors.js","../typed-complex-ctors/lib/main.js","../typed-complex/lib/main.js","../typed-integer-ctors/lib/ctors.js","../typed-real/lib/main.js","../typed-real-ctors/lib/ctors.js","../typed-real-float-ctors/lib/ctors.js","../typed-signed-integer-ctors/lib/ctors.js","../typed-unsigned-integer-ctors/lib/ctors.js","../zero-to/lib/main.js","../node_modules/@stdlib/constants/array/lib/index.js","../lib/index.js","../cartesian-power/lib/main.js","../cartesian-product/lib/main.js","../cartesian-square/lib/main.js","../convert-same/lib/main.js","../empty-like/lib/main.js","../from-iterator/lib/main.js","../full-like/lib/main.js","../incrspace/lib/main.js","../logspace/lib/main.js","../mskput/lib/main.js","../mskput/lib/defaults.js","../next-dtype/lib/main.js","../one-to-like/lib/main.js","../promotion-rules/lib/main.js","../reviver/lib/main.js","../slice/lib/main.js","../to-circular-iterator/lib/main.js","../to-iterator/lib/main.js","../to-iterator-right/lib/main.js","../to-sparse-iterator/lib/main.js","../to-sparse-iterator-right/lib/main.js","../to-strided-iterator/lib/main.js","../to-view-iterator/lib/main.js","../to-view-iterator-right/lib/main.js","../typed-complex-dtypes/lib/main.js","../typed-dtypes/lib/main.js","../typed-float-dtypes/lib/main.js","../typed-integer-ctors/lib/main.js","../typed-integer-dtypes/lib/main.js","../typed-real-ctors/lib/main.js","../typed-real-dtypes/lib/main.js","../typed-real-float-ctors/lib/main.js","../typed-real-float-dtypes/lib/main.js","../typed-signed-integer-ctors/lib/main.js","../typed-signed-integer-dtypes/lib/main.js","../typed-unsigned-integer-ctors/lib/main.js","../typed-unsigned-integer-dtypes/lib/main.js","../zero-to-like/lib/main.js","../zeros-like/lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Object.defineProperty === 'function' ) ? Object.defineProperty : null;\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Defines (or modifies) an object property.\n*\n* ## Notes\n*\n* - Property descriptors come in two flavors: **data descriptors** and **accessor descriptors**. A data descriptor is a property that has a value, which may or may not be writable. An accessor descriptor is a property described by a getter-setter function pair. A descriptor must be one of these two flavors and cannot be both.\n*\n* @name defineProperty\n* @type {Function}\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Object} descriptor - property descriptor\n* @param {boolean} [descriptor.configurable=false] - boolean indicating if property descriptor can be changed and if the property can be deleted from the provided object\n* @param {boolean} [descriptor.enumerable=false] - boolean indicating if the property shows up when enumerating object properties\n* @param {boolean} [descriptor.writable=false] - boolean indicating if the value associated with the property can be changed with an assignment operator\n* @param {*} [descriptor.value] - property value\n* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the property value.\n* @param {(Function|void)} [descriptor.set=undefined] - function which serves as a setter for the property, or, if no setter, undefined. When assigning a property value, a setter function is called with one argument (the value being assigned to the property) and with the `this` context set to the object through which the property is assigned.\n* @throws {TypeError} first argument must be an object\n* @throws {TypeError} third argument must be an object\n* @throws {Error} property descriptor cannot have both a value and a setter and/or getter\n* @returns {Object} object with added property\n*\n* @example\n* var obj = {};\n*\n* defineProperty( obj, 'foo', {\n* 'value': 'bar'\n* });\n*\n* var str = obj.foo;\n* // returns 'bar'\n*/\nvar defineProperty = Object.defineProperty;\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a number primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* @example\n* var bool = isNumber( NaN );\n* // returns true\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns false\n*/\nfunction isNumber( value ) {\n\treturn ( typeof value === 'number' ); // NOTE: we inline the `isNumber.isPrimitive` function from `@stdlib/assert/is-number` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Tests if a string starts with a minus sign (`-`).\n*\n* @private\n* @param {string} str - input string\n* @returns {boolean} boolean indicating if a string starts with a minus sign (`-`)\n*/\nfunction startsWithMinus( str ) {\n\treturn str[ 0 ] === '-';\n}\n\n/**\n* Returns a string of `n` zeros.\n*\n* @private\n* @param {number} n - number of zeros\n* @returns {string} string of zeros\n*/\nfunction zeros( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += '0';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with zeros to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction zeroPad( str, width, right ) {\n\tvar negative = false;\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tif ( startsWithMinus( str ) ) {\n\t\tnegative = true;\n\t\tstr = str.substr( 1 );\n\t}\n\tstr = ( right ) ?\n\t\tstr + zeros( pad ) :\n\t\tzeros( pad ) + str;\n\tif ( negative ) {\n\t\tstr = '-' + str;\n\t}\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default zeroPad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isNumber from './is_number.js';\nimport zeroPad from './zero_pad.js';\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as an integer.\n*\n* @private\n* @param {Object} token - token object\n* @throws {Error} must provide a valid integer\n* @returns {string} formatted token argument\n*/\nfunction formatInteger( token ) {\n\tvar base;\n\tvar out;\n\tvar i;\n\n\tswitch ( token.specifier ) {\n\tcase 'b':\n\t\t// Case: %b (binary)\n\t\tbase = 2;\n\t\tbreak;\n\tcase 'o':\n\t\t// Case: %o (octal)\n\t\tbase = 8;\n\t\tbreak;\n\tcase 'x':\n\tcase 'X':\n\t\t// Case: %x, %X (hexadecimal)\n\t\tbase = 16;\n\t\tbreak;\n\tcase 'd':\n\tcase 'i':\n\tcase 'u':\n\tdefault:\n\t\t// Case: %d, %i, %u (decimal)\n\t\tbase = 10;\n\t\tbreak;\n\t}\n\tout = token.arg;\n\ti = parseInt( out, 10 );\n\tif ( !isFinite( i ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\tif ( !isNumber( out ) ) {\n\t\t\tthrow new Error( 'invalid integer. Value: ' + out );\n\t\t}\n\t\ti = 0;\n\t}\n\tif ( i < 0 && ( token.specifier === 'u' || base !== 10 ) ) {\n\t\ti = 0xffffffff + i + 1;\n\t}\n\tif ( i < 0 ) {\n\t\tout = ( -i ).toString( base );\n\t\tif ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tout = '-' + out;\n\t} else {\n\t\tout = i.toString( base );\n\t\tif ( !i && !token.precision ) {\n\t\t\tout = '';\n\t\t} else if ( token.precision ) {\n\t\t\tout = zeroPad( out, token.precision, token.padRight );\n\t\t}\n\t\tif ( token.sign ) {\n\t\t\tout = token.sign + out;\n\t\t}\n\t}\n\tif ( base === 16 ) {\n\t\tif ( token.alternate ) {\n\t\t\tout = '0x' + out;\n\t\t}\n\t\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\t\tuppercase.call( out ) :\n\t\t\tlowercase.call( out );\n\t}\n\tif ( base === 8 ) {\n\t\tif ( token.alternate && out.charAt( 0 ) !== '0' ) {\n\t\t\tout = '0' + out;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\n// NOTE: for the following, we explicitly avoid using stdlib packages in this particular package in order to avoid circular dependencies.\nvar abs = Math.abs; // eslint-disable-line stdlib/no-builtin-math\nvar lowercase = String.prototype.toLowerCase;\nvar uppercase = String.prototype.toUpperCase;\nvar replace = String.prototype.replace;\n\n\n// VARIABLES //\n\nvar RE_EXP_POS_DIGITS = /e\\+(\\d)$/;\nvar RE_EXP_NEG_DIGITS = /e-(\\d)$/;\nvar RE_ONLY_DIGITS = /^(\\d+)$/;\nvar RE_DIGITS_BEFORE_EXP = /^(\\d+)e/;\nvar RE_TRAILING_PERIOD_ZERO = /\\.0$/;\nvar RE_PERIOD_ZERO_EXP = /\\.0*e/;\nvar RE_ZERO_BEFORE_EXP = /(\\..*[^0])0*e/;\n\n\n// MAIN //\n\n/**\n* Formats a token object argument as a floating-point number.\n*\n* @private\n* @param {number} f - parsed number\n* @param {Object} token - token object\n* @throws {Error} must provide a valid floating-point number\n* @returns {string} formatted token argument\n*/\nfunction formatDouble( f, token ) {\n\tvar digits;\n\tvar out;\n\n\tswitch ( token.specifier ) {\n\tcase 'e':\n\tcase 'E':\n\t\tout = f.toExponential( token.precision );\n\t\tbreak;\n\tcase 'f':\n\tcase 'F':\n\t\tout = f.toFixed( token.precision );\n\t\tbreak;\n\tcase 'g':\n\tcase 'G':\n\t\tif ( abs( f ) < 0.0001 ) {\n\t\t\tdigits = token.precision;\n\t\t\tif ( digits > 0 ) {\n\t\t\t\tdigits -= 1;\n\t\t\t}\n\t\t\tout = f.toExponential( digits );\n\t\t} else {\n\t\t\tout = f.toPrecision( token.precision );\n\t\t}\n\t\tif ( !token.alternate ) {\n\t\t\tout = replace.call( out, RE_ZERO_BEFORE_EXP, '$1e' );\n\t\t\tout = replace.call( out, RE_PERIOD_ZERO_EXP, 'e' );\n\t\t\tout = replace.call( out, RE_TRAILING_PERIOD_ZERO, '' );\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tthrow new Error( 'invalid double notation. Value: ' + token.specifier );\n\t}\n\tout = replace.call( out, RE_EXP_POS_DIGITS, 'e+0$1' );\n\tout = replace.call( out, RE_EXP_NEG_DIGITS, 'e-0$1' );\n\tif ( token.alternate ) {\n\t\tout = replace.call( out, RE_ONLY_DIGITS, '$1.' );\n\t\tout = replace.call( out, RE_DIGITS_BEFORE_EXP, '$1.e' );\n\t}\n\tif ( f >= 0 && token.sign ) {\n\t\tout = token.sign + out;\n\t}\n\tout = ( token.specifier === uppercase.call( token.specifier ) ) ?\n\t\tuppercase.call( out ) :\n\t\tlowercase.call( out );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatDouble;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Returns `n` spaces.\n*\n* @private\n* @param {number} n - number of spaces\n* @returns {string} string of spaces\n*/\nfunction spaces( n ) {\n\tvar out = '';\n\tvar i;\n\tfor ( i = 0; i < n; i++ ) {\n\t\tout += ' ';\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Pads a token with spaces to the specified width.\n*\n* @private\n* @param {string} str - token argument\n* @param {number} width - token width\n* @param {boolean} [right=false] - boolean indicating whether to pad to the right\n* @returns {string} padded token argument\n*/\nfunction spacePad( str, width, right ) {\n\tvar pad = width - str.length;\n\tif ( pad < 0 ) {\n\t\treturn str;\n\t}\n\tstr = ( right ) ?\n\t\tstr + spaces( pad ) :\n\t\tspaces( pad ) + str;\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default spacePad;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport formatInteger from './format_integer.js';\nimport isString from './is_string.js';\nimport isNumber from './is_number.js';\nimport formatDouble from './format_double.js';\nimport spacePad from './space_pad.js';\nimport zeroPad from './zero_pad.js';\n\n\n// VARIABLES //\n\nvar fromCharCode = String.fromCharCode;\nvar isArray = Array.isArray; // NOTE: We use the global `Array.isArray` function here instead of `@stdlib/assert/is-array` to avoid circular dependencies.\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating whether a value is `NaN`.\n*\n* @private\n* @param {*} value - input value\n* @returns {boolean} boolean indicating whether a value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 4 );\n* // returns false\n*/\nfunction isnan( value ) { // explicitly define a function here instead of `@stdlib/math/base/assert/is-nan` in order to avoid circular dependencies\n\treturn ( value !== value );\n}\n\n/**\n* Initializes token object with properties of supplied format identifier object or default values if not present.\n*\n* @private\n* @param {Object} token - format identifier object\n* @returns {Object} token object\n*/\nfunction initialize( token ) {\n\tvar out = {};\n\tout.specifier = token.specifier;\n\tout.precision = ( token.precision === void 0 ) ? 1 : token.precision;\n\tout.width = token.width;\n\tout.flags = token.flags || '';\n\tout.mapping = token.mapping;\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates string from a token array by interpolating values.\n*\n* @param {Array} tokens - string parts and format identifier objects\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be an array\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var tokens = [ 'beep ', { 'specifier': 's' } ];\n* var out = formatInterpolate( tokens, 'boop' );\n* // returns 'beep boop'\n*/\nfunction formatInterpolate( tokens ) {\n\tvar hasPeriod;\n\tvar flags;\n\tvar token;\n\tvar flag;\n\tvar num;\n\tvar out;\n\tvar pos;\n\tvar f;\n\tvar i;\n\tvar j;\n\n\tif ( !isArray( tokens ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be an array. Value: `' + tokens + '`.' );\n\t}\n\tout = '';\n\tpos = 1;\n\tfor ( i = 0; i < tokens.length; i++ ) {\n\t\ttoken = tokens[ i ];\n\t\tif ( isString( token ) ) {\n\t\t\tout += token;\n\t\t} else {\n\t\t\thasPeriod = token.precision !== void 0;\n\t\t\ttoken = initialize( token );\n\t\t\tif ( !token.specifier ) {\n\t\t\t\tthrow new TypeError( 'invalid argument. Token is missing `specifier` property. Index: `'+ i +'`. Value: `' + token + '`.' );\n\t\t\t}\n\t\t\tif ( token.mapping ) {\n\t\t\t\tpos = token.mapping;\n\t\t\t}\n\t\t\tflags = token.flags;\n\t\t\tfor ( j = 0; j < flags.length; j++ ) {\n\t\t\t\tflag = flags.charAt( j );\n\t\t\t\tswitch ( flag ) {\n\t\t\t\tcase ' ':\n\t\t\t\t\ttoken.sign = ' ';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '+':\n\t\t\t\t\ttoken.sign = '+';\n\t\t\t\t\tbreak;\n\t\t\t\tcase '-':\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t\tbreak;\n\t\t\t\tcase '0':\n\t\t\t\t\ttoken.padZeros = flags.indexOf( '-' ) < 0; // NOTE: We use built-in `Array.prototype.indexOf` here instead of `@stdlib/assert/contains` in order to avoid circular dependencies.\n\t\t\t\t\tbreak;\n\t\t\t\tcase '#':\n\t\t\t\t\ttoken.alternate = true;\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error( 'invalid flag: ' + flag );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( token.width === '*' ) {\n\t\t\t\ttoken.width = parseInt( arguments[ pos ], 10 );\n\t\t\t\tpos += 1;\n\t\t\t\tif ( isnan( token.width ) ) {\n\t\t\t\t\tthrow new TypeError( 'the argument for * width at position ' + pos + ' is not a number. Value: `' + token.width + '`.' );\n\t\t\t\t}\n\t\t\t\tif ( token.width < 0 ) {\n\t\t\t\t\ttoken.padRight = true;\n\t\t\t\t\ttoken.width = -token.width;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasPeriod ) {\n\t\t\t\tif ( token.precision === '*' ) {\n\t\t\t\t\ttoken.precision = parseInt( arguments[ pos ], 10 );\n\t\t\t\t\tpos += 1;\n\t\t\t\t\tif ( isnan( token.precision ) ) {\n\t\t\t\t\t\tthrow new TypeError( 'the argument for * precision at position ' + pos + ' is not a number. Value: `' + token.precision + '`.' );\n\t\t\t\t\t}\n\t\t\t\t\tif ( token.precision < 0 ) {\n\t\t\t\t\t\ttoken.precision = 1;\n\t\t\t\t\t\thasPeriod = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\ttoken.arg = arguments[ pos ];\n\t\t\tswitch ( token.specifier ) {\n\t\t\tcase 'b':\n\t\t\tcase 'o':\n\t\t\tcase 'x':\n\t\t\tcase 'X':\n\t\t\tcase 'd':\n\t\t\tcase 'i':\n\t\t\tcase 'u':\n\t\t\t\t// Case: %b (binary), %o (octal), %x, %X (hexadecimal), %d, %i (decimal), %u (unsigned decimal)\n\t\t\t\tif ( hasPeriod ) {\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatInteger( token );\n\t\t\t\tbreak;\n\t\t\tcase 's':\n\t\t\t\t// Case: %s (string)\n\t\t\t\ttoken.maxWidth = ( hasPeriod ) ? token.precision : -1;\n\t\t\t\ttoken.arg = String( token.arg );\n\t\t\t\tbreak;\n\t\t\tcase 'c':\n\t\t\t\t// Case: %c (character)\n\t\t\t\tif ( !isnan( token.arg ) ) {\n\t\t\t\t\tnum = parseInt( token.arg, 10 );\n\t\t\t\t\tif ( num < 0 || num > 127 ) {\n\t\t\t\t\t\tthrow new Error( 'invalid character code. Value: ' + token.arg );\n\t\t\t\t\t}\n\t\t\t\t\ttoken.arg = ( isnan( num ) ) ? String( token.arg ) : fromCharCode( num ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'e':\n\t\t\tcase 'E':\n\t\t\tcase 'f':\n\t\t\tcase 'F':\n\t\t\tcase 'g':\n\t\t\tcase 'G':\n\t\t\t\t// Case: %e, %E (scientific notation), %f, %F (decimal floating point), %g, %G (uses the shorter of %e/E or %f/F)\n\t\t\t\tif ( !hasPeriod ) {\n\t\t\t\t\ttoken.precision = 6;\n\t\t\t\t}\n\t\t\t\tf = parseFloat( token.arg );\n\t\t\t\tif ( !isFinite( f ) ) { // NOTE: We use the global `isFinite` function here instead of `@stdlib/math/base/assert/is-finite` in order to avoid circular dependencies.\n\t\t\t\t\tif ( !isNumber( token.arg ) ) {\n\t\t\t\t\t\tthrow new Error( 'invalid floating-point number. Value: ' + out );\n\t\t\t\t\t}\n\t\t\t\t\t// Case: NaN, Infinity, or -Infinity\n\t\t\t\t\tf = token.arg;\n\t\t\t\t\ttoken.padZeros = false;\n\t\t\t\t}\n\t\t\t\ttoken.arg = formatDouble( f, token );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'invalid specifier: ' + token.specifier );\n\t\t\t}\n\t\t\t// Fit argument into field width...\n\t\t\tif ( token.maxWidth >= 0 && token.arg.length > token.maxWidth ) {\n\t\t\t\ttoken.arg = token.arg.substring( 0, token.maxWidth );\n\t\t\t}\n\t\t\tif ( token.padZeros ) {\n\t\t\t\ttoken.arg = zeroPad( token.arg, token.width || token.precision, token.padRight ); // eslint-disable-line max-len\n\t\t\t} else if ( token.width ) {\n\t\t\t\ttoken.arg = spacePad( token.arg, token.width, token.padRight );\n\t\t\t}\n\t\t\tout += token.arg || '';\n\t\t\tpos += 1;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default formatInterpolate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE = /%(?:([1-9]\\d*)\\$)?([0 +\\-#]*)(\\*|\\d+)?(?:(\\.)(\\*|\\d+)?)?[hlL]?([%A-Za-z])/g;\n\n\n// FUNCTIONS //\n\n/**\n* Parses a delimiter.\n*\n* @private\n* @param {Array} match - regular expression match\n* @returns {Object} delimiter token object\n*/\nfunction parse( match ) {\n\tvar token = {\n\t\t'mapping': ( match[ 1 ] ) ? parseInt( match[ 1 ], 10 ) : void 0,\n\t\t'flags': match[ 2 ],\n\t\t'width': match[ 3 ],\n\t\t'precision': match[ 5 ],\n\t\t'specifier': match[ 6 ]\n\t};\n\tif ( match[ 4 ] === '.' && match[ 5 ] === void 0 ) {\n\t\ttoken.precision = '1';\n\t}\n\treturn token;\n}\n\n\n// MAIN //\n\n/**\n* Tokenizes a string into an array of string parts and format identifier objects.\n*\n* @param {string} str - input string\n* @returns {Array} tokens\n*\n* @example\n* var tokens = formatTokenize( 'Hello %s!' );\n* // returns [ 'Hello ', {...}, '!' ]\n*/\nfunction formatTokenize( str ) {\n\tvar content;\n\tvar tokens;\n\tvar match;\n\tvar prev;\n\n\ttokens = [];\n\tprev = 0;\n\tmatch = RE.exec( str );\n\twhile ( match ) {\n\t\tcontent = str.slice( prev, RE.lastIndex - match[ 0 ].length );\n\t\tif ( content.length ) {\n\t\t\ttokens.push( content );\n\t\t}\n\t\t// Check for an escaped percent sign `%%`...\n\t\tif ( match[ 6 ] === '%' ) {\n\t\t\ttokens.push( '%' );\n\t\t} else {\n\t\t\ttokens.push( parse( match ) );\n\t\t}\n\t\tprev = RE.lastIndex;\n\t\tmatch = RE.exec( str );\n\t}\n\tcontent = str.slice( prev );\n\tif ( content.length ) {\n\t\ttokens.push( content );\n\t}\n\treturn tokens;\n}\n\n\n// EXPORTS //\n\nexport default formatTokenize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport interpolate from './../../base/format-interpolate';\nimport tokenize from './../../base/format-tokenize';\nimport isString from './is_string.js';\n\n\n// MAIN //\n\n/**\n* Inserts supplied variable values into a format string.\n*\n* @param {string} str - input string\n* @param {Array} ...args - variable values\n* @throws {TypeError} first argument must be a string\n* @throws {Error} invalid flags\n* @returns {string} formatted string\n*\n* @example\n* var str = format( 'Hello %s!', 'world' );\n* // returns 'Hello world!'\n*\n* @example\n* var str = format( 'Pi: ~%.2f', 3.141592653589793 );\n* // returns 'Pi: ~3.14'\n*/\nfunction format( str ) {\n\tvar args;\n\tvar i;\n\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );\n\t}\n\targs = [ tokenize( str ) ];\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn interpolate.apply( null, args );\n}\n\n\n// EXPORTS //\n\nexport default format;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' ); // NOTE: we inline the `isString.isPrimitive` function from `@stdlib/assert/is-string` in order to avoid circular dependencies.\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-underscore-dangle, no-proto */\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar objectProtoype = Object.prototype;\nvar toStr = objectProtoype.toString;\nvar defineGetter = objectProtoype.__defineGetter__;\nvar defineSetter = objectProtoype.__defineSetter__;\nvar lookupGetter = objectProtoype.__lookupGetter__;\nvar lookupSetter = objectProtoype.__lookupSetter__;\n\n\n// MAIN //\n\n/**\n* Defines (or modifies) an object property.\n*\n* ## Notes\n*\n* - Property descriptors come in two flavors: **data descriptors** and **accessor descriptors**. A data descriptor is a property that has a value, which may or may not be writable. An accessor descriptor is a property described by a getter-setter function pair. A descriptor must be one of these two flavors and cannot be both.\n*\n* @param {Object} obj - object on which to define the property\n* @param {string} prop - property name\n* @param {Object} descriptor - property descriptor\n* @param {boolean} [descriptor.configurable=false] - boolean indicating if property descriptor can be changed and if the property can be deleted from the provided object\n* @param {boolean} [descriptor.enumerable=false] - boolean indicating if the property shows up when enumerating object properties\n* @param {boolean} [descriptor.writable=false] - boolean indicating if the value associated with the property can be changed with an assignment operator\n* @param {*} [descriptor.value] - property value\n* @param {(Function|void)} [descriptor.get=undefined] - function which serves as a getter for the property, or, if no getter, undefined. When the property is accessed, a getter function is called without arguments and with the `this` context set to the object through which the property is accessed (which may not be the object on which the property is defined due to inheritance). The return value will be used as the property value.\n* @param {(Function|void)} [descriptor.set=undefined] - function which serves as a setter for the property, or, if no setter, undefined. When assigning a property value, a setter function is called with one argument (the value being assigned to the property) and with the `this` context set to the object through which the property is assigned.\n* @throws {TypeError} first argument must be an object\n* @throws {TypeError} third argument must be an object\n* @throws {Error} property descriptor cannot have both a value and a setter and/or getter\n* @returns {Object} object with added property\n*\n* @example\n* var obj = {};\n*\n* defineProperty( obj, 'foo', {\n* 'value': 'bar'\n* });\n*\n* var str = obj.foo;\n* // returns 'bar'\n*/\nfunction defineProperty( obj, prop, descriptor ) {\n\tvar prototype;\n\tvar hasValue;\n\tvar hasGet;\n\tvar hasSet;\n\n\tif ( typeof obj !== 'object' || obj === null || toStr.call( obj ) === '[object Array]' ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) );\n\t}\n\tif ( typeof descriptor !== 'object' || descriptor === null || toStr.call( descriptor ) === '[object Array]' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Property descriptor must be an object. Value: `%s`.', descriptor ) );\n\t}\n\thasValue = ( 'value' in descriptor );\n\tif ( hasValue ) {\n\t\tif (\n\t\t\tlookupGetter.call( obj, prop ) ||\n\t\t\tlookupSetter.call( obj, prop )\n\t\t) {\n\t\t\t// Override `__proto__` to avoid touching inherited accessors:\n\t\t\tprototype = obj.__proto__;\n\t\t\tobj.__proto__ = objectProtoype;\n\n\t\t\t// Delete property as existing getters/setters prevent assigning value to specified property:\n\t\t\tdelete obj[ prop ];\n\t\t\tobj[ prop ] = descriptor.value;\n\n\t\t\t// Restore original prototype:\n\t\t\tobj.__proto__ = prototype;\n\t\t} else {\n\t\t\tobj[ prop ] = descriptor.value;\n\t\t}\n\t}\n\thasGet = ( 'get' in descriptor );\n\thasSet = ( 'set' in descriptor );\n\n\tif ( hasValue && ( hasGet || hasSet ) ) {\n\t\tthrow new Error( 'invalid argument. Cannot specify one or more accessors and a value or writable attribute in the property descriptor.' );\n\t}\n\n\tif ( hasGet && defineGetter ) {\n\t\tdefineGetter.call( obj, prop, descriptor.get );\n\t}\n\tif ( hasSet && defineSetter ) {\n\t\tdefineSetter.call( obj, prop, descriptor.set );\n\t}\n\treturn obj;\n}\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Define (or modify) an object property.\n*\n* @module @stdlib/utils/define-property\n*\n* @example\n* import defineProperty from '@stdlib/utils/define-property';\n*\n* var obj = {};\n* defineProperty( obj, 'foo', {\n* 'value': 'bar',\n* 'writable': false,\n* 'configurable': false,\n* 'enumerable': false\n* });\n* obj.foo = 'boop'; // => throws\n*/\n\n// MODULES //\n\nimport hasDefinePropertySupport from './has_define_property_support.js';\nimport builtin from './builtin.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar defineProperty;\nif ( hasDefinePropertySupport() ) {\n\tdefineProperty = builtin;\n} else {\n\tdefineProperty = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default defineProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './define_property.js';\n\n\n// MAIN //\n\n/**\n* Tests for `Object.defineProperty` support.\n*\n* @private\n* @returns {boolean} boolean indicating if an environment has `Object.defineProperty` support\n*\n* @example\n* var bool = hasDefinePropertySupport();\n* // returns \n*/\nfunction hasDefinePropertySupport() {\n\t// Test basic support...\n\ttry {\n\t\tdefineProperty( {}, 'x', {} );\n\t\treturn true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default hasDefinePropertySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a read-only property.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* var obj = {};\n*\n* setReadOnly( obj, 'foo', 'bar' );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setReadOnly( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': value\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setReadOnly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a non-enumerable read-only property.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* var obj = {};\n*\n* setNonEnumerableReadOnly( obj, 'foo', 'bar' );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setNonEnumerableReadOnly( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'writable': false,\n\t\t'value': value\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setNonEnumerableReadOnly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar TYPE = 'function';\n\n\n// MAIN //\n\n/**\n* Tests if an array-like object supports the accessor (get/set) protocol.\n*\n* @param {Object} value - value to test\n* @returns {boolean} boolean indicating whether a value is an accessor array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isAccessorArray( new Complex128Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isAccessorArray( [] );\n* // returns false\n*/\nfunction isAccessorArray( value ) {\n\treturn ( typeof value.get === TYPE && typeof value.set === TYPE ); // eslint-disable-line valid-typeof\n}\n\n\n// EXPORTS //\n\nexport default isAccessorArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar GETTERS = {\n\t'float64': getFloat64,\n\t'float32': getFloat32,\n\t'int32': getInt32,\n\t'int16': getInt16,\n\t'int8': getInt8,\n\t'uint32': getUint32,\n\t'uint16': getUint16,\n\t'uint8': getUint8,\n\t'uint8c': getUint8c,\n\t'generic': getGeneric,\n\t'default': getArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an element from a `Float64Array`.\n*\n* @private\n* @param {Float64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getFloat64( arr, 2 );\n* // returns 3.0\n*/\nfunction getFloat64( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Float32Array`.\n*\n* @private\n* @param {Float32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Float32Array from '@stdlib/array/float32';\n*\n* var arr = new Float32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getFloat32( arr, 2 );\n* // returns 3.0\n*/\nfunction getFloat32( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int32Array`.\n*\n* @private\n* @param {Int32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var arr = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt32( arr, 2 );\n* // returns 3\n*/\nfunction getInt32( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int16Array`.\n*\n* @private\n* @param {Int16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int16Array from '@stdlib/array/int16';\n*\n* var arr = new Int16Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt16( arr, 2 );\n* // returns 3\n*/\nfunction getInt16( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int8Array`.\n*\n* @private\n* @param {Int8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var arr = new Int8Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt8( arr, 2 );\n* // returns 3\n*/\nfunction getInt8( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint32Array`.\n*\n* @private\n* @param {Uint32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var arr = new Uint32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint32( arr, 2 );\n* // returns 3\n*/\nfunction getUint32( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint16Array`.\n*\n* @private\n* @param {Uint16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint16Array from '@stdlib/array/uint16';\n*\n* var arr = new Uint16Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint16( arr, 2 );\n* // returns 3\n*/\nfunction getUint16( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint8Array`.\n*\n* @private\n* @param {Uint8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var arr = new Uint8Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint8( arr, 2 );\n* // returns 3\n*/\nfunction getUint8( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint8ClampedArray`.\n*\n* @private\n* @param {Uint8ClampedArray} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint8ClampedArray from '@stdlib/array/uint8c';\n*\n* var arr = new Uint8ClampedArray( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint8c( arr, 2 );\n* // returns 3\n*/\nfunction getUint8c( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a generic `Array`.\n*\n* @private\n* @param {Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var v = getGeneric( arr, 2 );\n* // returns 3\n*/\nfunction getGeneric( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an indexed array-like object.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var v = getArrayLike( arr, 2 );\n* // returns 3\n*/\nfunction getArrayLike( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an indexed array-like object.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 2 );\n* // returns 3\n*/\nfunction getter( dtype ) {\n\tvar f = GETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn GETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar SETTERS = {\n\t'float64': setFloat64,\n\t'float32': setFloat32,\n\t'int32': setInt32,\n\t'int16': setInt16,\n\t'int8': setInt8,\n\t'uint32': setUint32,\n\t'uint16': setUint16,\n\t'uint8': setUint8,\n\t'uint8c': setUint8c,\n\t'generic': setGeneric,\n\t'default': setArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Sets an element in a `Float64Array`.\n*\n* @private\n* @param {Float64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( 4 );\n*\n* setFloat64( arr, 2, 3.0 );\n*\n* var v = arr[ 2 ];\n* // returns 3.0\n*/\nfunction setFloat64( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Float32Array`.\n*\n* @private\n* @param {Float32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Float32Array from '@stdlib/array/float32';\n*\n* var arr = new Float32Array( 4 );\n*\n* setFloat32( arr, 2, 3.0 );\n*\n* var v = arr[ 2 ];\n* // returns 3.0\n*/\nfunction setFloat32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int32Array`.\n*\n* @private\n* @param {Int32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var arr = new Int32Array( 4 );\n*\n* setInt32( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int16Array`.\n*\n* @private\n* @param {Int16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int16Array from '@stdlib/array/int16';\n*\n* var arr = new Int16Array( 4 );\n*\n* setInt16( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt16( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int8Array`.\n*\n* @private\n* @param {Int8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var arr = new Int8Array( 4 );\n*\n* setInt8( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt8( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint32Array`.\n*\n* @private\n* @param {Uint32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var arr = new Uint32Array( 4 );\n*\n* setUint32( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint16Array`.\n*\n* @private\n* @param {Uint16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint16Array from '@stdlib/array/uint16';\n*\n* var arr = new Uint16Array( 4 );\n*\n* setUint16( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint16( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint8Array`.\n*\n* @private\n* @param {Uint8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var arr = new Uint8Array( 4 );\n*\n* setUint8( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint8( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint8ClampedArray`.\n*\n* @private\n* @param {Uint8ClampedArray} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint8ClampedArray from '@stdlib/array/uint8c';\n*\n* var arr = new Uint8ClampedArray( 4 );\n*\n* setUint8c( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint8c( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a generic `Array`.\n*\n* @private\n* @param {Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* setGeneric( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setGeneric( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an indexed array-like object.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* setArrayLike( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setArrayLike( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for setting an element in an indexed array-like object.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var set = setter( dtype( arr ) );\n* set( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setter( dtype ) {\n\tvar f = SETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn SETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar GETTERS = {\n\t'complex128': getComplex128,\n\t'complex64': getComplex64,\n\t'default': getArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an element from a `Complex128Array`.\n*\n* @private\n* @param {Complex128Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex128( arr, 1 );\n* // returns \n*\n* var re = real( v );\n* // returns 3.0\n*\n* var im = imag( v );\n* // returns 4.0\n*/\nfunction getComplex128( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from a `Complex64Array`.\n*\n* @private\n* @param {Complex64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex64( arr, 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getComplex64( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from an array-like object supporting the get/set protocol.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* function get( idx ) {\n* return arr[ idx ];\n* }\n*\n* function set( value, idx ) {\n* arr[ idx ] = value;\n* }\n*\n* arr.get = get;\n* arr.set = set;\n*\n* var v = getArrayLike( arr, 2 );\n* // returns 3\n*/\nfunction getArrayLike( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getter( dtype ) {\n\tvar f = GETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn GETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar SETTERS = {\n\t'complex128': setComplex128,\n\t'complex64': setComplex64,\n\t'default': setArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Sets an element in a `Complex128Array`.\n*\n* @private\n* @param {Complex128Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );\n*\n* setComplex128( arr, 1, new Complex128( 10.0, 11.0 ) );\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = real( v );\n* // returns 10.0\n*\n* var im = imag( v );\n* // returns 11.0\n*/\nfunction setComplex128( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n/**\n* Sets an element in a `Complex64Array`.\n*\n* @private\n* @param {Complex64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* setComplex64( arr, 1, new Complex64( 10.0, 11.0 ) );\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 11.0\n*/\nfunction setComplex64( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n/**\n* Sets an element in an array-like object supporting the get/set protocol.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* function get( idx ) {\n* return arr[ idx ];\n* }\n*\n* function set( value, idx ) {\n* arr[ idx ] = value;\n* }\n*\n* arr.get = get;\n* arr.set = set;\n*\n* setArrayLike( arr, 2, 10 );\n*\n* var v = arr[ 2 ];\n* // returns 10\n*/\nfunction setArrayLike( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for setting an element in an array-like object supporting the get/set protocol.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var set = setter( dtype( arr ) );\n* set( arr, 1, new Complex64( 10.0, 11.0 ) );\n*\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 11.0\n*/\nfunction setter( dtype ) {\n\tvar f = SETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn SETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasSymbols from './../../has-symbol-support';\n\n\n// VARIABLES //\n\nvar FLG = hasSymbols();\n\n\n// MAIN //\n\n/**\n* Tests for native `Symbol.toStringTag` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Symbol.toStringTag` support\n*\n* @example\n* var bool = hasToStringTagSupport();\n* // returns \n*/\nfunction hasToStringTagSupport() {\n\treturn ( FLG && typeof Symbol.toStringTag === 'symbol' );\n}\n\n\n// EXPORTS //\n\nexport default hasToStringTagSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests for native `Symbol` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Symbol` support\n*\n* @example\n* var bool = hasSymbolSupport();\n* // returns \n*/\nfunction hasSymbolSupport() {\n\treturn (\n\t\ttypeof Symbol === 'function' &&\n\t\ttypeof Symbol( 'foo' ) === 'symbol'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default hasSymbolSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar toStr = Object.prototype.toString;\n\n\n// EXPORTS //\n\nexport default toStr;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\nvar has = Object.prototype.hasOwnProperty;\n\n\n// MAIN //\n\n/**\n* Tests if an object has a specified property.\n*\n* @param {*} value - value to test\n* @param {*} property - property to test\n* @returns {boolean} boolean indicating if an object has a specified property\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = hasOwnProp( beep, 'boop' );\n* // returns true\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = hasOwnProp( beep, 'bap' );\n* // returns false\n*/\nfunction hasOwnProp( value, property ) {\n\tif (\n\t\tvalue === void 0 ||\n\t\tvalue === null\n\t) {\n\t\treturn false;\n\t}\n\treturn has.call( value, property );\n}\n\n\n// EXPORTS //\n\nexport default hasOwnProp;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar Sym = ( typeof Symbol === 'function' ) ? Symbol : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Sym;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Symbol from '@stdlib/symbol/ctor';\n\n\n// MAIN //\n\nvar toStrTag = ( typeof Symbol === 'function' ) ? Symbol.toStringTag : '';\n\n\n// EXPORTS //\n\nexport default toStrTag;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return a string value indicating a specification defined classification of an object.\n*\n* @module @stdlib/utils/native-class\n*\n* @example\n* import nativeClass from '@stdlib/utils/native-class';\n*\n* var str = nativeClass( 'a' );\n* // returns '[object String]'\n*\n* str = nativeClass( 5 );\n* // returns '[object Number]'\n*\n* function Beep() {\n* return this;\n* }\n* str = nativeClass( new Beep() );\n* // returns '[object Object]'\n*/\n\n// MODULES //\n\nimport hasToStringTag from '@stdlib/assert/has-tostringtag-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar main;\nif ( hasToStringTag() ) {\n\tmain = polyfill;\n} else {\n\tmain = builtin;\n}\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport toStringTag from './tostringtag.js';\nimport toStr from './tostring.js';\n\n\n// MAIN //\n\n/**\n* Returns a string value indicating a specification defined classification of an object in environments supporting `Symbol.toStringTag`.\n*\n* @param {*} v - input value\n* @returns {string} string value indicating a specification defined classification of the input value\n*\n* @example\n* var str = nativeClass( 'a' );\n* // returns '[object String]'\n*\n* @example\n* var str = nativeClass( 5 );\n* // returns '[object Number]'\n*\n* @example\n* function Beep() {\n* return this;\n* }\n* var str = nativeClass( new Beep() );\n* // returns '[object Object]'\n*/\nfunction nativeClass( v ) {\n\tvar isOwn;\n\tvar tag;\n\tvar out;\n\n\tif ( v === null || v === void 0 ) {\n\t\treturn toStr.call( v );\n\t}\n\ttag = v[ toStringTag ];\n\tisOwn = hasOwnProp( v, toStringTag );\n\n\t// Attempt to override the `toStringTag` property. For built-ins having a `Symbol.toStringTag` property (e.g., `JSON`, `Math`, etc), the `Symbol.toStringTag` property is read-only (e.g., , so we need to wrap in a `try/catch`.\n\ttry {\n\t\tv[ toStringTag ] = void 0;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn toStr.call( v );\n\t}\n\tout = toStr.call( v );\n\n\tif ( isOwn ) {\n\t\tv[ toStringTag ] = tag;\n\t} else {\n\t\tdelete v[ toStringTag ];\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default nativeClass;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport toStr from './tostring.js';\n\n\n// MAIN //\n\n/**\n* Returns a string value indicating a specification defined classification (via the internal property `[[Class]]`) of an object.\n*\n* @param {*} v - input value\n* @returns {string} string value indicating a specification defined classification of the input value\n*\n* @example\n* var str = nativeClass( 'a' );\n* // returns '[object String]'\n*\n* @example\n* var str = nativeClass( 5 );\n* // returns '[object Number]'\n*\n* @example\n* function Beep() {\n* return this;\n* }\n* var str = nativeClass( new Beep() );\n* // returns '[object Object]'\n*/\nfunction nativeClass( v ) {\n\treturn toStr.call( v );\n}\n\n\n// EXPORTS //\n\nexport default nativeClass;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar f;\n\n\n// FUNCTIONS //\n\n/**\n* Tests if a value is an array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an array\n*\n* @example\n* var bool = isArray( [] );\n* // returns true\n*\n* @example\n* var bool = isArray( {} );\n* // returns false\n*/\nfunction isArray( value ) {\n\treturn ( nativeClass( value ) === '[object Array]' );\n}\n\n\n// MAIN //\n\nif ( Array.isArray ) {\n\tf = Array.isArray;\n} else {\n\tf = isArray;\n}\n\n\n// EXPORTS //\n\nexport default f;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from './../../../is-array';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a function which tests if every element in an array passes a test condition.\n*\n* @param {Function} predicate - function to apply\n* @throws {TypeError} must provide a function\n* @returns {Function} an array function\n*\n* @example\n* import isOdd from '@stdlib/assert/is-odd';\n*\n* var arr1 = [ 1, 3, 5, 7 ];\n* var arr2 = [ 3, 5, 8 ];\n*\n* var validate = arrayfcn( isOdd );\n*\n* var bool = validate( arr1 );\n* // returns true\n*\n* bool = validate( arr2 );\n* // returns false\n*/\nfunction arrayfcn( predicate ) {\n\tif ( typeof predicate !== 'function' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a function. Value: `%s`.', predicate ) );\n\t}\n\treturn every;\n\n\t/**\n\t* Tests if every element in an array passes a test condition.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating whether a value is an array for which all elements pass a test condition\n\t*/\n\tfunction every( value ) {\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isArray( value ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tlen = value.length;\n\t\tif ( len === 0 ) {\n\t\t\treturn false;\n\t\t}\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( predicate( value[ i ] ) === false ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default arrayfcn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is object-like.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is object-like\n*\n* @example\n* var bool = isObjectLike( {} );\n* // returns true\n*\n* @example\n* var bool = isObjectLike( [] );\n* // returns true\n*\n* @example\n* var bool = isObjectLike( null );\n* // returns false\n*/\nfunction isObjectLike( value ) {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === 'object'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isObjectLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObjectLike from './../../is-object-like';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Buffer instance.\n*\n* @param {*} value - value to validate\n* @returns {boolean} boolean indicating if a value is a Buffer instance\n*\n* @example\n* var v = isBuffer( new Buffer( 'beep' ) );\n* // returns true\n*\n* @example\n* var v = isBuffer( new Buffer( [1,2,3,4] ) );\n* // returns true\n*\n* @example\n* var v = isBuffer( {} );\n* // returns false\n*\n* @example\n* var v = isBuffer( [] );\n* // returns false\n*/\nfunction isBuffer( value ) {\n\treturn (\n\t\tisObjectLike( value ) &&\n\t\t(\n\t\t\t// eslint-disable-next-line no-underscore-dangle\n\t\t\tvalue._isBuffer || // for envs missing Object.prototype.constructor (e.g., Safari 5-7)\n\t\t\t(\n\t\t\t\tvalue.constructor &&\n\n\t\t\t\t// WARNING: `typeof` is not a foolproof check, as certain envs consider RegExp and NodeList instances to be functions\n\t\t\t\ttypeof value.constructor.isBuffer === 'function' &&\n\t\t\t\tvalue.constructor.isBuffer( value )\n\t\t\t)\n\t\t)\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isBuffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a regular expression to capture everything that is not a space immediately after the `function` keyword and before the first left parenthesis.\n*\n* @returns {RegExp} regular expression\n*\n* @example\n* var RE_FUNCTION_NAME = reFunctionName();\n*\n* function fname( fcn ) {\n* return RE_FUNCTION_NAME.exec( fcn.toString() )[ 1 ];\n* }\n*\n* var fn = fname( Math.sqrt );\n* // returns 'sqrt'\n*\n* fn = fname( Int8Array );\n* // returns 'Int8Array'\n*\n* fn = fname( Object.prototype.toString );\n* // returns 'toString'\n*\n* fn = fname( function(){} );\n* // returns ''\n*/\nfunction reFunctionName() {\n\treturn /^\\s*function\\s*([^(]*)/i;\n}\n\n\n// EXPORTS //\n\nexport default reFunctionName;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is object-like.\n*\n* @module @stdlib/assert/is-object-like\n*\n* @example\n* import isObjectLike from '@stdlib/assert/is-object-like';\n*\n* var bool = isObjectLike( {} );\n* // returns true\n*\n* bool = isObjectLike( [] );\n* // returns true\n*\n* bool = isObjectLike( null );\n* // returns false\n*\n* @example\n* import { isObjectLikeArray as isObjectLike } from '@stdlib/assert/is-object-like';\n*\n* var bool = isObjectLike( [ {}, [] ] );\n* // returns true\n*\n* bool = isObjectLike( [ {}, '3.0' ] );\n* // returns false\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport arrayfun from './../../tools/array-function';\nimport main from './main.js';\n\n\n// VARIABLES //\n\nvar isObjectLikeArray = arrayfun( main );\n\n\n// MAIN //\n\nsetReadOnly( main, 'isObjectLikeArray', isObjectLikeArray );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport reFunctionName from './main.js';\n\n\n// MAIN //\n\n/**\n* Captures everything that is not a space immediately after the `function` keyword and before the first left parenthesis.\n*\n* Regular expression: `/^\\s*function\\s*([^(]*)/i`\n*\n* - `/^\\s*`\n* - Match zero or more spaces at beginning\n*\n* - `function`\n* - Match the word `function`\n*\n* - `\\s*`\n* - Match zero or more spaces after the word `function`\n*\n* - `()`\n* - Capture\n*\n* - `[^(]*`\n* - Match anything except a left parenthesis `(` zero or more times\n*\n* - `/i`\n* - ignore case\n*\n* @constant\n* @type {RegExp}\n* @default /^\\s*function\\s*([^(]*)/i\n*/\nvar RE_FUNCTION_NAME = reFunctionName();\n\n\n// EXPORTS //\n\nexport default RE_FUNCTION_NAME;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from './../../native-class';\nimport { REGEXP as RE } from '@stdlib/regexp/function-name';\nimport isBuffer from '@stdlib/assert/is-buffer';\n\n\n// MAIN //\n\n/**\n* Determines the name of a value's constructor.\n*\n* @param {*} v - input value\n* @returns {string} name of a value's constructor\n*\n* @example\n* var v = constructorName( 'a' );\n* // returns 'String'\n*\n* @example\n* var v = constructorName( 5 );\n* // returns 'Number'\n*\n* @example\n* var v = constructorName( null );\n* // returns 'Null'\n*\n* @example\n* var v = constructorName( undefined );\n* // returns 'Undefined'\n*\n* @example\n* var v = constructorName( function noop() {} );\n* // returns 'Function'\n*/\nfunction constructorName( v ) {\n\tvar match;\n\tvar name;\n\tvar ctor;\n\tname = nativeClass( v ).slice( 8, -1 );\n\tif ( (name === 'Object' || name === 'Error') && v.constructor ) {\n\t\tctor = v.constructor;\n\t\tif ( typeof ctor.name === 'string' ) {\n\t\t\treturn ctor.name;\n\t\t}\n\t\tmatch = RE.exec( ctor.toString() );\n\t\tif ( match ) {\n\t\t\treturn match[ 1 ];\n\t\t}\n\t}\n\tif ( isBuffer( v ) ) {\n\t\treturn 'Buffer';\n\t}\n\treturn name;\n}\n\n\n// EXPORTS //\n\nexport default constructorName;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Regular expression to capture everything that is not a space immediately after the `function` keyword and before the first left parenthesis.\n*\n* @module @stdlib/regexp/function-name\n*\n* @example\n* import reFunctionName from '@stdlib/regexp/function-name';\n* var RE_FUNCTION_NAME = reFunctionName();\n*\n* function fname( fcn ) {\n* return RE_FUNCTION_NAME.exec( fcn.toString() )[ 1 ];\n* }\n*\n* var fn = fname( Math.sqrt );\n* // returns 'sqrt'\n*\n* fn = fname( Int8Array );\n* // returns 'Int8Array'\n*\n* fn = fname( Object.prototype.toString );\n* // returns 'toString'\n*\n* fn = fname( function(){} );\n* // returns ''\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport REGEXP from './regexp.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'REGEXP', REGEXP );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Mapping from array constructors to data types...\nvar ctor2dtypes = {\n\t'Float32Array': 'float32',\n\t'Float64Array': 'float64',\n\t'Array': 'generic',\n\t'Int16Array': 'int16',\n\t'Int32Array': 'int32',\n\t'Int8Array': 'int8',\n\t'Uint16Array': 'uint16',\n\t'Uint32Array': 'uint32',\n\t'Uint8Array': 'uint8',\n\t'Uint8ClampedArray': 'uint8c',\n\t'Complex64Array': 'complex64',\n\t'Complex128Array': 'complex128',\n\t'BooleanArray': 'bool'\n};\n\n\n// EXPORTS //\n\nexport default ctor2dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasFloat64Array = ( typeof Float64Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Float64Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Float64Array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var bool = isFloat64Array( new Float64Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isFloat64Array( [] );\n* // returns false\n*/\nfunction isFloat64Array( value ) {\n\treturn (\n\t\t( hasFloat64Array && value instanceof Float64Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Float64Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isFloat64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Float64Array === 'function' ) ? Float64Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFloat64Array from './../../is-float64array';\nimport GlobalFloat64Array from './float64array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Float64Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Float64Array` support\n*\n* @example\n* var bool = hasFloat64ArraySupport();\n* // returns \n*/\nfunction hasFloat64ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalFloat64Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalFloat64Array( [ 1.0, 3.14, -3.14, NaN ] );\n\t\tbool = (\n\t\t\tisFloat64Array( arr ) &&\n\t\t\tarr[ 0 ] === 1.0 &&\n\t\t\tarr[ 1 ] === 3.14 &&\n\t\t\tarr[ 2 ] === -3.14 &&\n\t\t\tarr[ 3 ] !== arr[ 3 ]\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasFloat64ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float64Array === 'function' ) ? Float64Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in the platform byte order.\n*\n* @module @stdlib/array/float64\n*\n* @example\n* import ctor from '@stdlib/array/float64';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasFloat64ArraySupport from '@stdlib/assert/has-float64array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat64ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of double-precision floating-point numbers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasFloat32Array = ( typeof Float32Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Float32Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Float32Array\n*\n* @example\n* import Float32Array from '@stdlib/array/float32';\n*\n* var bool = isFloat32Array( new Float32Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isFloat32Array( [] );\n* // returns false\n*/\nfunction isFloat32Array( value ) {\n\treturn (\n\t\t( hasFloat32Array && value instanceof Float32Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Float32Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isFloat32Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Double-precision floating-point positive infinity.\n*\n* @module @stdlib/constants/float64/pinf\n* @type {number}\n*\n* @example\n* import FLOAT64_PINF from '@stdlib/constants/float64/pinf';\n* // returns Infinity\n*/\n\n\n// MAIN //\n\n/**\n* Double-precision floating-point positive infinity.\n*\n* ## Notes\n*\n* Double-precision floating-point positive infinity has the bit sequence\n*\n* ```binarystring\n* 0 11111111111 00000000000000000000 00000000000000000000000000000000\n* ```\n*\n* @constant\n* @type {number}\n* @default Number.POSITIVE_INFINITY\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_PINF = Number.POSITIVE_INFINITY; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default FLOAT64_PINF;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Float32Array === 'function' ) ? Float32Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFloat32Array from './../../is-float32array';\nimport PINF from '@stdlib/constants/float64/pinf';\nimport GlobalFloat32Array from './float32array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Float32Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Float32Array` support\n*\n* @example\n* var bool = hasFloat32ArraySupport();\n* // returns \n*/\nfunction hasFloat32ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalFloat32Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalFloat32Array( [ 1.0, 3.14, -3.14, 5.0e40 ] );\n\t\tbool = (\n\t\t\tisFloat32Array( arr ) &&\n\t\t\tarr[ 0 ] === 1.0 &&\n\t\t\tarr[ 1 ] === 3.140000104904175 &&\n\t\t\tarr[ 2 ] === -3.140000104904175 &&\n\t\t\tarr[ 3 ] === PINF\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasFloat32ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float32Array === 'function' ) ? Float32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order.\n*\n* @module @stdlib/array/float32\n*\n* @example\n* import ctor from '@stdlib/array/float32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasFloat32ArraySupport from '@stdlib/assert/has-float32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of single-precision floating-point numbers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasUint32Array = ( typeof Uint32Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Uint32Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Uint32Array\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var bool = isUint32Array( new Uint32Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isUint32Array( [] );\n* // returns false\n*/\nfunction isUint32Array( value ) {\n\treturn (\n\t\t( hasUint32Array && value instanceof Uint32Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Uint32Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isUint32Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum unsigned 32-bit integer.\n*\n* @module @stdlib/constants/uint32/max\n* @type {uinteger32}\n*\n* @example\n* import UINT32_MAX from '@stdlib/constants/uint32/max';\n* // returns 4294967295\n*/\n\n\n// MAIN //\n\n/**\n* Maximum unsigned 32-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* 2^{32} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 11111111111111111111111111111111\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 4294967295\n*/\nvar UINT32_MAX = 4294967295;\n\n\n// EXPORTS //\n\nexport default UINT32_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Uint32Array === 'function' ) ? Uint32Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUint32Array from './../../is-uint32array';\nimport UINT32_MAX from '@stdlib/constants/uint32/max';\nimport GlobalUint32Array from './uint32array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Uint32Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Uint32Array` support\n*\n* @example\n* var bool = hasUint32ArraySupport();\n* // returns \n*/\nfunction hasUint32ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalUint32Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = [ 1, 3.14, -3.14, UINT32_MAX+1, UINT32_MAX+2 ];\n\t\tarr = new GlobalUint32Array( arr );\n\t\tbool = (\n\t\t\tisUint32Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === UINT32_MAX-2 && // truncation and wrap around\n\t\t\tarr[ 3 ] === 0 && // wrap around\n\t\t\tarr[ 4 ] === 1 // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasUint32ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint32Array === 'function' ) ? Uint32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 32-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint32\n*\n* @example\n* import ctor from '@stdlib/array/uint32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint32ArraySupport from '@stdlib/assert/has-uint32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 32-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasInt32Array = ( typeof Int32Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is an Int32Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an Int32Array\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var bool = isInt32Array( new Int32Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isInt32Array( [] );\n* // returns false\n*/\nfunction isInt32Array( value ) {\n\treturn (\n\t\t( hasInt32Array && value instanceof Int32Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Int32Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInt32Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum signed 32-bit integer.\n*\n* @module @stdlib/constants/int32/max\n* @type {integer32}\n*\n* @example\n* import INT32_MAX from '@stdlib/constants/int32/max';\n* // returns 2147483647\n*/\n\n\n// MAIN //\n\n/**\n* Maximum signed 32-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* 2^{31} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 01111111111111111111111111111111\n* ```\n*\n* @constant\n* @type {integer32}\n* @default 2147483647\n*/\nvar INT32_MAX = 2147483647|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT32_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Minimum signed 32-bit integer.\n*\n* @module @stdlib/constants/int32/min\n* @type {integer32}\n*\n* @example\n* import INT32_MIN from '@stdlib/constants/int32/min';\n* // returns -2147483648\n*/\n\n\n// MAIN //\n\n/**\n* Minimum signed 32-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* -(2^{31})\n* ```\n*\n* which corresponds to the two's complement bit sequence\n*\n* ```binarystring\n* 10000000000000000000000000000000\n* ```\n*\n* @constant\n* @type {integer32}\n* @default -2147483648\n*/\nvar INT32_MIN = -2147483648|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT32_MIN;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Int32Array === 'function' ) ? Int32Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInt32Array from './../../is-int32array';\nimport INT32_MAX from '@stdlib/constants/int32/max';\nimport INT32_MIN from '@stdlib/constants/int32/min';\nimport GlobalInt32Array from './int32array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Int32Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Int32Array` support\n*\n* @example\n* var bool = hasInt32ArraySupport();\n* // returns \n*/\nfunction hasInt32ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalInt32Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalInt32Array( [ 1, 3.14, -3.14, INT32_MAX+1 ] );\n\t\tbool = (\n\t\t\tisInt32Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === -3 && // truncation\n\t\t\tarr[ 3 ] === INT32_MIN // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasInt32ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int32Array === 'function' ) ? Int32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 32-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int32\n*\n* @example\n* import ctor from '@stdlib/array/int32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt32ArraySupport from '@stdlib/assert/has-int32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 32-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasUint16Array = ( typeof Uint16Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Uint16Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Uint16Array\n*\n* @example\n* import Uint16Array from '@stdlib/array/uint16';\n*\n* var bool = isUint16Array( new Uint16Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isUint16Array( [] );\n* // returns false\n*/\nfunction isUint16Array( value ) {\n\treturn (\n\t\t( hasUint16Array && value instanceof Uint16Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Uint16Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isUint16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum unsigned 16-bit integer.\n*\n* @module @stdlib/constants/uint16/max\n* @type {integer32}\n*\n* @example\n* import UINT16_MAX from '@stdlib/constants/uint16/max';\n* // returns 65535\n*/\n\n\n// MAIN //\n\n/**\n* Maximum unsigned 16-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* 2^{16} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 1111111111111111\n* ```\n*\n* @constant\n* @type {integer32}\n* @default 65535\n*/\nvar UINT16_MAX = 65535|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default UINT16_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Uint16Array === 'function' ) ? Uint16Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUint16Array from './../../is-uint16array';\nimport UINT16_MAX from '@stdlib/constants/uint16/max';\nimport GlobalUint16Array from './uint16array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Uint16Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Uint16Array` support\n*\n* @example\n* var bool = hasUint16ArraySupport();\n* // returns \n*/\nfunction hasUint16ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalUint16Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = [ 1, 3.14, -3.14, UINT16_MAX+1, UINT16_MAX+2 ];\n\t\tarr = new GlobalUint16Array( arr );\n\t\tbool = (\n\t\t\tisUint16Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === UINT16_MAX-2 && // truncation and wrap around\n\t\t\tarr[ 3 ] === 0 && // wrap around\n\t\t\tarr[ 4 ] === 1 // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasUint16ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint16\n*\n* @example\n* import ctor from '@stdlib/array/uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert/has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasInt16Array = ( typeof Int16Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is an Int16Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an Int16Array\n*\n* @example\n* import Int16Array from '@stdlib/array/int16';\n*\n* var bool = isInt16Array( new Int16Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isInt16Array( [] );\n* // returns false\n*/\nfunction isInt16Array( value ) {\n\treturn (\n\t\t( hasInt16Array && value instanceof Int16Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Int16Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInt16Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum signed 16-bit integer.\n*\n* @module @stdlib/constants/int16/max\n* @type {integer32}\n*\n* @example\n* import INT16_MAX from '@stdlib/constants/int16/max';\n* // returns 32767\n*/\n\n\n// MAIN //\n\n/**\n* Maximum signed 16-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* 2^{15} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 0111111111111111\n* ```\n*\n* @constant\n* @type {integer32}\n* @default 32767\n*/\nvar INT16_MAX = 32767|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT16_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Minimum signed 16-bit integer.\n*\n* @module @stdlib/constants/int16/min\n* @type {integer32}\n*\n* @example\n* import INT16_MIN from '@stdlib/constants/int16/min';\n* // returns -32768\n*/\n\n\n// MAIN //\n\n/**\n* Minimum signed 16-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* -(2^{15})\n* ```\n*\n* which corresponds to the two's complement bit sequence\n*\n* ```binarystring\n* 1000000000000000\n* ```\n*\n* @constant\n* @type {integer32}\n* @default -32768\n*/\nvar INT16_MIN = -32768|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT16_MIN;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Int16Array === 'function' ) ? Int16Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInt16Array from './../../is-int16array';\nimport INT16_MAX from '@stdlib/constants/int16/max';\nimport INT16_MIN from '@stdlib/constants/int16/min';\nimport GlobalInt16Array from './int16array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Int16Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Int16Array` support\n*\n* @example\n* var bool = hasInt16ArraySupport();\n* // returns \n*/\nfunction hasInt16ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalInt16Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalInt16Array( [ 1, 3.14, -3.14, INT16_MAX+1 ] );\n\t\tbool = (\n\t\t\tisInt16Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === -3 && // truncation\n\t\t\tarr[ 3 ] === INT16_MIN // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasInt16ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int16Array === 'function' ) ? Int16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 16-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int16\n*\n* @example\n* import ctor from '@stdlib/array/int16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt16ArraySupport from '@stdlib/assert/has-int16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 16-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasUint8Array = ( typeof Uint8Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Uint8Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Uint8Array\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var bool = isUint8Array( new Uint8Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isUint8Array( [] );\n* // returns false\n*/\nfunction isUint8Array( value ) {\n\treturn (\n\t\t( hasUint8Array && value instanceof Uint8Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Uint8Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isUint8Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum unsigned 8-bit integer.\n*\n* @module @stdlib/constants/uint8/max\n* @type {integer32}\n*\n* @example\n* import UINT8_MAX from '@stdlib/constants/uint8/max';\n* // returns 255\n*/\n\n\n// MAIN //\n\n/**\n* Maximum unsigned 8-bit integer.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* 2^{8} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 11111111\n* ```\n*\n* @constant\n* @type {integer32}\n* @default 255\n*/\nvar UINT8_MAX = 255|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default UINT8_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Uint8Array === 'function' ) ? Uint8Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUint8Array from './../../is-uint8array';\nimport UINT8_MAX from '@stdlib/constants/uint8/max';\nimport GlobalUint8Array from './uint8array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Uint8Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Uint8Array` support\n*\n* @example\n* var bool = hasUint8ArraySupport();\n* // returns \n*/\nfunction hasUint8ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalUint8Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = [ 1, 3.14, -3.14, UINT8_MAX+1, UINT8_MAX+2 ];\n\t\tarr = new GlobalUint8Array( arr );\n\t\tbool = (\n\t\t\tisUint8Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === UINT8_MAX-2 && // truncation and wrap around\n\t\t\tarr[ 3 ] === 0 && // wrap around\n\t\t\tarr[ 4 ] === 1 // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasUint8ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint8Array === 'function' ) ? Uint8Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint8\n*\n* @example\n* import ctor from '@stdlib/array/uint8';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint8ArraySupport from '@stdlib/assert/has-uint8array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint8ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 8-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasUint8ClampedArray = ( typeof Uint8ClampedArray === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Uint8ClampedArray.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Uint8ClampedArray\n*\n* @example\n* import Uint8ClampedArray from '@stdlib/array/uint8c';\n*\n* var bool = isUint8ClampedArray( new Uint8ClampedArray( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isUint8ClampedArray( [] );\n* // returns false\n*/\nfunction isUint8ClampedArray( value ) {\n\treturn (\n\t\t( hasUint8ClampedArray && value instanceof Uint8ClampedArray ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Uint8ClampedArray]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isUint8ClampedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Uint8ClampedArray === 'function' ) ? Uint8ClampedArray : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isUint8ClampedArray from './../../is-uint8clampedarray';\nimport GlobalUint8ClampedArray from './uint8clampedarray.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Uint8ClampedArray` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Uint8ClampedArray` support\n*\n* @example\n* var bool = hasUint8ClampedArraySupport();\n* // returns \n*/\nfunction hasUint8ClampedArraySupport() { // eslint-disable-line id-length\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalUint8ClampedArray !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalUint8ClampedArray( [ -1, 0, 1, 3.14, 4.99, 255, 256 ] );\n\t\tbool = (\n\t\t\tisUint8ClampedArray( arr ) &&\n\t\t\tarr[ 0 ] === 0 && // clamped\n\t\t\tarr[ 1 ] === 0 &&\n\t\t\tarr[ 2 ] === 1 &&\n\t\t\tarr[ 3 ] === 3 && // round to nearest\n\t\t\tarr[ 4 ] === 5 && // round to nearest\n\t\t\tarr[ 5 ] === 255 &&\n\t\t\tarr[ 6 ] === 255 // clamped\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasUint8ClampedArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint8ClampedArray === 'function' ) ? Uint8ClampedArray : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order clamped to 0-255.\n*\n* @module @stdlib/array/uint8c\n*\n* @example\n* import ctor from '@stdlib/array/uint8c';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint8ClampedArraySupport from '@stdlib/assert/has-uint8clampedarray-support'; // eslint-disable-line id-length\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint8ClampedArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 8-bit unsigned integers in the platform byte order clamped to 0-255.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasInt8Array = ( typeof Int8Array === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is an Int8Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an Int8Array\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var bool = isInt8Array( new Int8Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isInt8Array( [] );\n* // returns false\n*/\nfunction isInt8Array( value ) {\n\treturn (\n\t\t( hasInt8Array && value instanceof Int8Array ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object Int8Array]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInt8Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum signed 8-bit integer.\n*\n* @module @stdlib/constants/int8/max\n* @type {integer32}\n*\n* @example\n* import INT8_MAX from '@stdlib/constants/int8/max';\n* // returns 127\n*/\n\n\n// MAIN //\n\n/**\n* Maximum signed 8-bit integer.\n*\n* ## Notes\n*\n* The number is given by\n*\n* ```tex\n* 2^{7} - 1\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 01111111\n* ```\n*\n* @constant\n* @type {integer32}\n* @default 127\n*/\nvar INT8_MAX = 127|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT8_MAX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Minimum signed 8-bit integer.\n*\n* @module @stdlib/constants/int8/min\n* @type {integer32}\n*\n* @example\n* import INT8_MIN from '@stdlib/constants/int8/min';\n* // returns -128\n*/\n\n\n// MAIN //\n\n/**\n* Minimum signed 8-bit integer.\n*\n* ## Notes\n*\n* The number is given by\n*\n* ```tex\n* -(2^{7})\n* ```\n*\n* which corresponds to the two's complement bit sequence\n*\n* ```binarystring\n* 10000000\n* ```\n*\n* @constant\n* @type {integer32}\n* @default -128\n*/\nvar INT8_MIN = -128|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default INT8_MIN;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Int8Array === 'function' ) ? Int8Array : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInt8Array from './../../is-int8array';\nimport INT8_MAX from '@stdlib/constants/int8/max';\nimport INT8_MIN from '@stdlib/constants/int8/min';\nimport GlobalInt8Array from './int8array.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Int8Array` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Int8Array` support\n*\n* @example\n* var bool = hasInt8ArraySupport();\n* // returns \n*/\nfunction hasInt8ArraySupport() {\n\tvar bool;\n\tvar arr;\n\n\tif ( typeof GlobalInt8Array !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tarr = new GlobalInt8Array( [ 1, 3.14, -3.14, INT8_MAX+1 ] );\n\t\tbool = (\n\t\t\tisInt8Array( arr ) &&\n\t\t\tarr[ 0 ] === 1 &&\n\t\t\tarr[ 1 ] === 3 && // truncation\n\t\t\tarr[ 2 ] === -3 && // truncation\n\t\t\tarr[ 3 ] === INT8_MIN // wrap around\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasInt8ArraySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int8Array === 'function' ) ? Int8Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 8-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int8\n*\n* @example\n* import ctor from '@stdlib/array/int8';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt8ArraySupport from '@stdlib/assert/has-int8array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt8ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 8-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a number primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* @example\n* var bool = isNumber( NaN );\n* // returns true\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns false\n*/\nfunction isNumber( value ) {\n\treturn ( typeof value === 'number' );\n}\n\n\n// EXPORTS //\n\nexport default isNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// EXPORTS //\n\nexport default Number; // eslint-disable-line stdlib/require-globals\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Number from '@stdlib/number/ctor';\n\n\n// MAIN //\n\n// eslint-disable-next-line stdlib/no-redeclare\nvar toString = Number.prototype.toString; // non-generic\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasToStringTag from './../../has-tostringtag-support';\nimport nativeClass from '@stdlib/utils/native-class';\nimport Number from '@stdlib/number/ctor';\nimport test from './try2serialize.js';\n\n\n// VARIABLES //\n\nvar FLG = hasToStringTag();\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number object\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns false\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns true\n*/\nfunction isNumber( value ) {\n\tif ( typeof value === 'object' ) {\n\t\tif ( value instanceof Number ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( FLG ) {\n\t\t\treturn test( value );\n\t\t}\n\t\treturn ( nativeClass( value ) === '[object Number]' );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\n\n\n// MAIN //\n\n/**\n* Attempts to serialize a value to a string.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value can be serialized\n*/\nfunction test( value ) {\n\ttry {\n\t\ttoString.call( value );\n\t\treturn true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default test;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a number\n*\n* @example\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* @example\n* var bool = isNumber( new Number( 3.14 ) );\n* // returns true\n*\n* @example\n* var bool = isNumber( NaN );\n* // returns true\n*\n* @example\n* var bool = isNumber( null );\n* // returns false\n*/\nfunction isNumber( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isNumber;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is a number.\n*\n* @module @stdlib/assert/is-number\n*\n* @example\n* import isNumber from '@stdlib/assert/is-number';\n*\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* bool = isNumber( new Number( 3.14 ) );\n* // returns true\n*\n* bool = isNumber( NaN );\n* // returns true\n*\n* bool = isNumber( null );\n* // returns false\n*\n* @example\n* import { isPrimitive as isNumber } from '@stdlib/assert/is-number';\n*\n* var bool = isNumber( 3.14 );\n* // returns true\n*\n* bool = isNumber( NaN );\n* // returns true\n*\n* bool = isNumber( new Number( 3.14 ) );\n* // returns false\n*\n* @example\n* import { isObject as isNumber } from '@stdlib/assert/is-number';\n*\n* var bool = isNumber( 3.14 );\n* // returns false\n*\n* bool = isNumber( new Number( 3.14 ) );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Double-precision floating-point negative infinity.\n*\n* @module @stdlib/constants/float64/ninf\n* @type {number}\n*\n* @example\n* import FLOAT64_NINF from '@stdlib/constants/float64/ninf';\n* // returns -Infinity\n*/\n\n// MODULES //\n\nimport Number from '@stdlib/number/ctor';\n\n\n// MAIN //\n\n/**\n* Double-precision floating-point negative infinity.\n*\n* ## Notes\n*\n* Double-precision floating-point negative infinity has the bit sequence\n*\n* ```binarystring\n* 1 11111111111 00000000000000000000 00000000000000000000000000000000\n* ```\n*\n* @constant\n* @type {number}\n* @default Number.NEGATIVE_INFINITY\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_NINF = Number.NEGATIVE_INFINITY;\n\n\n// EXPORTS //\n\nexport default FLOAT64_NINF;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: implementation (?)\n\n/**\n* Rounds a double-precision floating-point number toward negative infinity.\n*\n* @param {number} x - input value\n* @returns {number} rounded value\n*\n* @example\n* var v = floor( -4.2 );\n* // returns -5.0\n*\n* @example\n* var v = floor( 9.99999 );\n* // returns 9.0\n*\n* @example\n* var v = floor( 0.0 );\n* // returns 0.0\n*\n* @example\n* var v = floor( NaN );\n* // returns NaN\n*/\nvar floor = Math.floor; // eslint-disable-line stdlib/no-builtin-math\n\n\n// EXPORTS //\n\nexport default floor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from './../../../../base/special/floor';\n\n\n// MAIN //\n\n/**\n* Tests if a finite double-precision floating-point number is an integer.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is an integer\n*\n* @example\n* var bool = isInteger( 1.0 );\n* // returns true\n*\n* @example\n* var bool = isInteger( 3.14 );\n* // returns false\n*/\nfunction isInteger( x ) {\n\treturn (floor(x) === x);\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport PINF from '@stdlib/constants/float64/pinf';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport isInt from '@stdlib/math/base/assert/is-integer';\n\n\n// MAIN //\n\n/**\n* Tests if a number primitive is an integer value.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a number primitive is an integer value\n*/\nfunction isInteger( value ) {\n\treturn (\n\t\tvalue < PINF &&\n\t\tvalue > NINF &&\n\t\tisInt( value )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from './../../is-number';\nimport isInt from './integer.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number primitive having an integer value.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive having an integer value\n*\n* @example\n* var bool = isInteger( -3.0 );\n* // returns true\n*\n* @example\n* var bool = isInteger( new Number( -3.0 ) );\n* // returns false\n*/\nfunction isInteger( value ) {\n\treturn (\n\t\tisNumber( value ) &&\n\t\tisInt( value )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isObject as isNumber } from './../../is-number';\nimport isInt from './integer.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number object having an integer value.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number object having an integer value\n*\n* @example\n* var bool = isInteger( 3.0 );\n* // returns false\n*\n* @example\n* var bool = isInteger( new Number( 3.0 ) );\n* // returns true\n*/\nfunction isInteger( value ) {\n\treturn (\n\t\tisNumber( value ) &&\n\t\tisInt( value.valueOf() )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an integer.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an integer\n*\n* @example\n* var bool = isInteger( 5.0 );\n* // returns true\n*\n* @example\n* var bool = isInteger( new Number( 5.0 ) );\n* // returns true\n*\n* @example\n* var bool = isInteger( -3.14 );\n* // returns false\n*\n* @example\n* var bool = isInteger( null );\n* // returns false\n*/\nfunction isInteger( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isInteger } from './../../is-integer';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number primitive having a nonnegative integer value.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number primitive having a nonnegative integer value\n*\n* @example\n* var bool = isNonNegativeInteger( 3.0 );\n* // returns true\n*\n* @example\n* var bool = isNonNegativeInteger( new Number( 3.0 ) );\n* // returns false\n*/\nfunction isNonNegativeInteger( value ) {\n\treturn (\n\t\tisInteger( value ) &&\n\t\tvalue >= 0\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isNonNegativeInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isObject as isInteger } from './../../is-integer';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number object having a nonnegative integer value.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number object having a nonnegative integer value\n*\n* @example\n* var bool = isNonNegativeInteger( 3.0 );\n* // returns false\n*\n* @example\n* var bool = isNonNegativeInteger( new Number( 3.0 ) );\n* // returns true\n*/\nfunction isNonNegativeInteger( value ) {\n\treturn (\n\t\tisInteger( value ) &&\n\t\tvalue.valueOf() >= 0\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isNonNegativeInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a nonnegative integer.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a nonnegative integer\n*\n* @example\n* var bool = isNonNegativeInteger( 5.0 );\n* // returns true\n*\n* @example\n* var bool = isNonNegativeInteger( new Number( 5.0 ) );\n* // returns true\n*\n* @example\n* var bool = isNonNegativeInteger( -5.0 );\n* // returns false\n*\n* @example\n* var bool = isNonNegativeInteger( 3.14 );\n* // returns false\n*\n* @example\n* var bool = isNonNegativeInteger( null );\n* // returns false\n*/\nfunction isNonNegativeInteger( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isNonNegativeInteger;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is an integer.\n*\n* @module @stdlib/assert/is-integer\n*\n* @example\n* import isInteger from '@stdlib/assert/is-integer';\n*\n* var bool = isInteger( 5.0 );\n* // returns true\n*\n* bool = isInteger( new Number( 5.0 ) );\n* // returns true\n*\n* bool = isInteger( -3.14 );\n* // returns false\n*\n* bool = isInteger( null );\n* // returns false\n*\n* @example\n* // Use interface to check for integer primitives...\n* import { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\n*\n* var bool = isInteger( -3.0 );\n* // returns true\n*\n* bool = isInteger( new Number( -3.0 ) );\n* // returns false\n*\n* @example\n* // Use interface to check for integer objects...\n* import { isObject as isInteger } from '@stdlib/assert/is-integer';\n*\n* var bool = isInteger( 3.0 );\n* // returns false\n*\n* bool = isInteger( new Number( 3.0 ) );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is a nonnegative integer.\n*\n* @module @stdlib/assert/is-nonnegative-integer\n*\n* @example\n* import isNonNegativeInteger from '@stdlib/assert/is-nonnegative-integer';\n*\n* var bool = isNonNegativeInteger( 5.0 );\n* // returns true\n*\n* bool = isNonNegativeInteger( new Number( 5.0 ) );\n* // returns true\n*\n* bool = isNonNegativeInteger( -5.0 );\n* // returns false\n*\n* bool = isNonNegativeInteger( 3.14 );\n* // returns false\n*\n* bool = isNonNegativeInteger( null );\n* // returns false\n*\n* @example\n* import { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\n*\n* var bool = isNonNegativeInteger( 3.0 );\n* // returns true\n*\n* bool = isNonNegativeInteger( new Number( 3.0 ) );\n* // returns false\n*\n* @example\n* import { isObject as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\n*\n* var bool = isNonNegativeInteger( 3.0 );\n* // returns false\n*\n* bool = isNonNegativeInteger( new Number( 3.0 ) );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Maximum length of a generic array.\n*\n* @module @stdlib/constants/array/max-array-length\n*\n* @example\n* import MAX_ARRAY_LENGTH from '@stdlib/constants/array/max-array-length';\n* // returns 4294967295\n*/\n\n// MAIN //\n\n/**\n* Maximum length of a generic array.\n*\n* ```tex\n* 2^{32} - 1\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 4294967295\n*/\nvar MAX_ARRAY_LENGTH = 4294967295>>>0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default MAX_ARRAY_LENGTH;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport MAX_LENGTH from '@stdlib/constants/array/max-array-length';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array-like object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is an array-like object\n*\n* @example\n* var bool = isArrayLikeObject( [] );\n* // returns true\n*\n* @example\n* var bool = isArrayLikeObject( { 'length': 10 } );\n* // returns true\n*\n* @example\n* var bool = isArrayLikeObject( 'beep' );\n* // returns false\n*/\nfunction isArrayLikeObject( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof value.length === 'number' &&\n\t\tisInteger( value.length ) &&\n\t\tvalue.length >= 0 &&\n\t\tvalue.length <= MAX_LENGTH\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isArrayLikeObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum length of a typed array.\n*\n* @module @stdlib/constants/array/max-typed-array-length\n*\n* @example\n* import MAX_TYPED_ARRAY_LENGTH from '@stdlib/constants/array/max-typed-array-length';\n* // returns 9007199254740991\n*/\n\n// MAIN //\n\n/**\n* Maximum length of a typed array.\n*\n* ```tex\n* 2^{53} - 1\n* ```\n*\n* @constant\n* @type {number}\n* @default 9007199254740991\n*/\nvar MAX_TYPED_ARRAY_LENGTH = 9007199254740991;\n\n\n// EXPORTS //\n\nexport default MAX_TYPED_ARRAY_LENGTH;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport MAX_LENGTH from '@stdlib/constants/array/max-typed-array-length';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a collection.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is a collection\n*\n* @example\n* var bool = isCollection( [] );\n* // returns true\n*\n* @example\n* var bool = isCollection( {} );\n* // returns false\n*/\nfunction isCollection( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof value.length === 'number' &&\n\t\tisInteger( value.length ) &&\n\t\tvalue.length >= 0 &&\n\t\tvalue.length <= MAX_LENGTH\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isCollection;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasArrayBuffer = ( typeof ArrayBuffer === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is an ArrayBuffer.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an ArrayBuffer\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var bool = isArrayBuffer( new ArrayBuffer( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isArrayBuffer( [] );\n* // returns false\n*/\nfunction isArrayBuffer( value ) {\n\treturn (\n\t\t( hasArrayBuffer && value instanceof ArrayBuffer ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object ArrayBuffer]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isArrayBuffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from './../../is-array';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an object; e.g., `{}`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is an object\n*\n* @example\n* var bool = isObject( {} );\n* // returns true\n*\n* @example\n* var bool = isObject( null );\n* // returns false\n*/\nfunction isObject( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t!isArray( value )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a string primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string primitive\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns false\n*/\nfunction isString( value ) {\n\treturn ( typeof value === 'string' );\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// eslint-disable-next-line stdlib/no-redeclare\nvar valueOf = String.prototype.valueOf; // non-generic\n\n\n// EXPORTS //\n\nexport default valueOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasToStringTag from './../../has-tostringtag-support';\nimport nativeClass from '@stdlib/utils/native-class';\nimport test from './try2valueof.js';\n\n\n// VARIABLES //\n\nvar FLG = hasToStringTag();\n\n\n// MAIN //\n\n/**\n* Tests if a value is a string object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a string object\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns true\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns false\n*/\nfunction isString( value ) {\n\tif ( typeof value === 'object' ) {\n\t\tif ( value instanceof String ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( FLG ) {\n\t\t\treturn test( value );\n\t\t}\n\t\treturn ( nativeClass( value ) === '[object String]' );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport valueOf from './valueof.js'; // eslint-disable-line stdlib/no-redeclare\n\n\n// MAIN //\n\n/**\n* Attempts to extract a string value.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a string can be extracted\n*/\nfunction test( value ) {\n\ttry {\n\t\tvalueOf.call( value );\n\t\treturn true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default test;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a string.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a string\n*\n* @example\n* var bool = isString( new String( 'beep' ) );\n* // returns true\n*\n* @example\n* var bool = isString( 'beep' );\n* // returns true\n*/\nfunction isString( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is a string.\n*\n* @module @stdlib/assert/is-string\n*\n* @example\n* import isString from '@stdlib/assert/is-string';\n*\n* var bool = isString( 'beep' );\n* // returns true\n*\n* bool = isString( new String( 'beep' ) );\n* // returns true\n*\n* bool = isString( 5 );\n* // returns false\n*\n* @example\n* import { isObject as isString } from '@stdlib/assert/is-string';\n*\n* var bool = isString( new String( 'beep' ) );\n* // returns true\n*\n* bool = isString( 'beep' );\n* // returns false\n*\n* @example\n* import { isPrimitive as isString } from '@stdlib/assert/is-string';\n*\n* var bool = isString( 'beep' );\n* // returns true\n*\n* bool = isString( new String( 'beep' ) );\n* // returns false\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of strings.\n*\n* @module @stdlib/assert/is-string-array\n*\n* @example\n* import isStringArray from '@stdlib/assert/is-string-array';\n*\n* var bool = isStringArray( [ 'abc', 'def' ] );\n* // returns true\n*\n* bool = isStringArray( [ 'abc', 123 ] );\n* // returns false\n*\n* @example\n* import { primitives as isStringArray } from '@stdlib/assert/is-string-array';\n*\n* var bool = isStringArray( [ 'abc', 'def' ] );\n* // returns true\n*\n* bool = isStringArray( [ 'abc', new String( 'def' ) ] );\n* // returns false\n*\n* @example\n* import { objects as isStringArray } from '@stdlib/assert/is-string-array';\n*\n* var bool = isStringArray( [ new String( 'abc' ), new String( 'def' ) ] );\n* // returns true\n*\n* bool = isStringArray( [ new String( 'abc' ), 'def' ] );\n* // returns false\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport arrayfun from './../../tools/array-function';\nimport isString from './../../is-string';\n\n\n// VARIABLES //\n\nvar isPrimitiveArray = arrayfun( isString.isPrimitive );\nvar isObjectArray = arrayfun( isString.isObject );\n\n\n// MAIN //\n\nvar isStringArray = arrayfun( isString );\nsetReadOnly( isStringArray, 'primitives', isPrimitiveArray );\nsetReadOnly( isStringArray, 'objects', isObjectArray );\n\n\n// EXPORTS //\n\nexport default isStringArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nvar RE = /./;\n\n\n// EXPORTS //\n\nexport default RE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is a boolean primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a boolean primitive\n*\n* @example\n* var bool = isBoolean( true );\n* // returns true\n*\n* @example\n* var bool = isBoolean( false );\n* // returns true\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n*\n* var bool = isBoolean( new Boolean( true ) );\n* // returns false\n*/\nfunction isBoolean( value ) {\n\treturn ( typeof value === 'boolean' );\n}\n\n\n// EXPORTS //\n\nexport default isBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a boolean.\n*\n* @name Boolean\n* @constructor\n* @type {Function}\n* @param {*} value - input value\n* @returns {(boolean|Boolean)} boolean\n*\n* @example\n* var b = Boolean( null );\n* // returns false\n*\n* b = Boolean( [] );\n* // returns true\n*\n* b = Boolean( {} );\n* // returns true\n*\n* @example\n* var b = new Boolean( false );\n* // returns \n*/\nvar Bool = Boolean; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// eslint-disable-next-line stdlib/no-redeclare\nvar toString = Boolean.prototype.toString; // non-generic\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasToStringTag from './../../has-tostringtag-support';\nimport nativeClass from '@stdlib/utils/native-class';\nimport Boolean from '@stdlib/boolean/ctor';\nimport test from './try2serialize.js';\n\n\n// VARIABLES //\n\nvar FLG = hasToStringTag();\n\n\n// MAIN //\n\n/**\n* Tests if a value is a boolean object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a boolean object\n*\n* @example\n* var bool = isBoolean( true );\n* // returns false\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n*\n* var bool = isBoolean( new Boolean( false ) );\n* // returns true\n*/\nfunction isBoolean( value ) {\n\tif ( typeof value === 'object' ) {\n\t\tif ( value instanceof Boolean ) {\n\t\t\treturn true;\n\t\t}\n\t\tif ( FLG ) {\n\t\t\treturn test( value );\n\t\t}\n\t\treturn ( nativeClass( value ) === '[object Boolean]' );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport toString from './tostring.js'; // eslint-disable-line stdlib/no-redeclare\n\n\n// MAIN //\n\n/**\n* Attempts to serialize a value to a string.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value can be serialized\n*/\nfunction test( value ) {\n\ttry {\n\t\ttoString.call( value );\n\t\treturn true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default test;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a boolean.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a boolean\n*\n* @example\n* var bool = isBoolean( false );\n* // returns true\n*\n* @example\n* var bool = isBoolean( true );\n* // returns true\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n*\n* var bool = isBoolean( new Boolean( false ) );\n* // returns true\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n*\n* var bool = isBoolean( new Boolean( true ) );\n* // returns true\n*/\nfunction isBoolean( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isBoolean;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is a boolean.\n*\n* @module @stdlib/assert/is-boolean\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n* import isBoolean from '@stdlib/assert/is-boolean';\n*\n* var bool = isBoolean( false );\n* // returns true\n*\n* bool = isBoolean( new Boolean( false ) );\n* // returns true\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n* import { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\n*\n* var bool = isBoolean( false );\n* // returns true\n*\n* bool = isBoolean( new Boolean( true ) );\n* // returns false\n*\n* @example\n* import Boolean from '@stdlib/boolean/ctor';\n* import { isObject as isBoolean } from '@stdlib/assert/is-boolean';\n*\n* var bool = isBoolean( true );\n* // returns false\n*\n* bool = isBoolean( new Boolean( false ) );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar obj = ( typeof self === 'object' ) ? self : null;\n\n\n// EXPORTS //\n\nexport default obj;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar obj = ( typeof window === 'object' ) ? window : null;\n\n\n// EXPORTS //\n\nexport default obj;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar obj = ( typeof global === 'object' ) ? global : null;\n\n\n// EXPORTS //\n\nexport default obj;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar obj = ( typeof globalThis === 'object' ) ? globalThis : null; // eslint-disable-line no-undef\n\n\n// EXPORTS //\n\nexport default obj;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getGlobal from './../../../global';\n\n\n// MAIN //\n\nvar root = getGlobal();\nvar nodeList = root.document && root.document.childNodes;\n\n\n// EXPORTS //\n\nexport default nodeList;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport format from '@stdlib/string/format';\nimport getThis from './codegen.js';\nimport Self from './self.js';\nimport Win from './window.js';\nimport Global from './global.js';\nimport GlobalThis from './global_this.js';\n\n\n// MAIN //\n\n/**\n* Returns the global object.\n*\n* ## Notes\n*\n* - Using code generation is the **most** reliable way to resolve the global object; however, doing so is likely to violate content security policies (CSPs) in, e.g., Chrome Apps and elsewhere.\n*\n* @param {boolean} [codegen=false] - boolean indicating whether to use code generation to resolve the global object\n* @throws {TypeError} must provide a boolean\n* @throws {Error} unable to resolve global object\n* @returns {Object} global object\n*\n* @example\n* var g = getGlobal();\n* // returns {...}\n*/\nfunction getGlobal( codegen ) {\n\tif ( arguments.length ) {\n\t\tif ( !isBoolean( codegen ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a boolean. Value: `%s`.', codegen ) );\n\t\t}\n\t\tif ( codegen ) {\n\t\t\treturn getThis();\n\t\t}\n\t\t// Fall through...\n\t}\n\t// Case: 2020 revision of ECMAScript standard\n\tif ( GlobalThis ) {\n\t\treturn GlobalThis;\n\t}\n\t// Case: browsers and web workers\n\tif ( Self ) {\n\t\treturn Self;\n\t}\n\t// Case: browsers\n\tif ( Win ) {\n\t\treturn Win;\n\t}\n\t// Case: Node.js\n\tif ( Global ) {\n\t\treturn Global;\n\t}\n\t// Case: unknown\n\tthrow new Error( 'unexpected error. Unable to resolve global object.' );\n}\n\n\n// EXPORTS //\n\nexport default getGlobal;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the global object using code generation.\n*\n* @private\n* @returns {Object} global object\n*/\nfunction getGlobal() {\n\treturn new Function( 'return this;' )(); // eslint-disable-line no-new-func, stdlib/require-globals\n}\n\n\n// EXPORTS //\n\nexport default getGlobal;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\nvar typedarray = Int8Array; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default typedarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Determine a value's type.\n*\n* @module @stdlib/utils/type-of\n*\n* @example\n* import typeOf from '@stdlib/utils/type-of';\n*\n* var str = typeOf( 'a' );\n* // returns 'string'\n*\n* str = typeOf( 5 );\n* // returns 'number'\n*/\n\n// MODULES //\n\nimport usePolyfill from './check.js';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar main = ( usePolyfill() ) ? polyfill : builtin;\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport RE from './fixtures/re.js';\nimport nodeList from './fixtures/nodelist.js';\nimport typedarray from './fixtures/typedarray.js';\n\n\n// MAIN //\n\n/**\n* Checks whether a polyfill is needed when using the `typeof` operator.\n*\n* @private\n* @returns {boolean} boolean indicating whether a polyfill is needed\n*/\nfunction check() {\n\tif (\n\t\t// Chrome 1-12 returns 'function' for regular expression instances (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof):\n\t\ttypeof RE === 'function' ||\n\n\t\t// Safari 8 returns 'object' for typed array and weak map constructors (underscore #1929):\n\t\ttypeof typedarray === 'object' ||\n\n\t\t// PhantomJS 1.9 returns 'function' for `NodeList` instances (underscore #2236):\n\t\ttypeof nodeList === 'function'\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default check;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctorName from './../../constructor-name';\n\n\n// MAIN //\n\n/**\n* Determines a value's type.\n*\n* @param {*} v - input value\n* @returns {string} string indicating the value's type\n*/\nfunction typeOf( v ) {\n\treturn ctorName( v ).toLowerCase();\n}\n\n\n// EXPORTS //\n\nexport default typeOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctorName from './../../constructor-name';\n\n\n// NOTES //\n\n/*\n* Built-in `typeof` operator behavior:\n*\n* ```text\n* typeof null => 'object'\n* typeof undefined => 'undefined'\n* typeof 'a' => 'string'\n* typeof 5 => 'number'\n* typeof NaN => 'number'\n* typeof true => 'boolean'\n* typeof false => 'boolean'\n* typeof {} => 'object'\n* typeof [] => 'object'\n* typeof function foo(){} => 'function'\n* typeof function* foo(){} => 'object'\n* typeof Symbol() => 'symbol'\n* ```\n*\n*/\n\n\n// MAIN //\n\n/**\n* Determines a value's type.\n*\n* @param {*} v - input value\n* @returns {string} string indicating the value's type\n*/\nfunction typeOf( v ) {\n\tvar type;\n\n\t// Address `typeof null` => `object` (see http://wiki.ecmascript.org/doku.php?id=harmony:typeof_null):\n\tif ( v === null ) {\n\t\treturn 'null';\n\t}\n\ttype = typeof v;\n\n\t// If the `typeof` operator returned something other than `object`, we are done. Otherwise, we need to check for an internal class name or search for a constructor.\n\tif ( type === 'object' ) {\n\t\treturn ctorName( v ).toLowerCase();\n\t}\n\treturn type;\n}\n\n\n// EXPORTS //\n\nexport default typeOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport typeOf from '@stdlib/utils/type-of';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a function.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a function\n*\n* @example\n* function beep() {\n* return 'beep';\n* }\n*\n* var bool = isFunction( beep );\n* // returns true\n*/\nfunction isFunction( value ) {\n\t// Note: cannot use `typeof` directly, as various browser engines incorrectly return `'function'` when operating on non-function objects, such as regular expressions and NodeLists.\n\treturn ( typeOf( value ) === 'function' );\n}\n\n\n// EXPORTS //\n\nexport default isFunction;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport defineProperty from '@stdlib/utils/define-property';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport format from '@stdlib/string/format';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 128-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex128} 128-bit complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex128( real, imag ) {\n\tif ( !( this instanceof Complex128 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': real\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': imag\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex128.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex128.prototype, 'BYTES_PER_ELEMENT', 8 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex128.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 16\n*/\nsetReadOnly( Complex128.prototype, 'byteLength', 16 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex128.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex128` instance.\n*\n* @name toJSON\n* @memberof Complex128.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex128', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex128.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex128;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex128';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar fround = ( typeof Math.fround === 'function' ) ? Math.fround : null; // eslint-disable-line stdlib/no-builtin-math\n\n\n// EXPORTS //\n\nexport default fround;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float32Array === 'function' ) ? Float32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in the platform byte order.\n*\n* @module @stdlib/array/float32\n*\n* @example\n* import ctor from '@stdlib/array/float32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasFloat32ArraySupport from '@stdlib/assert/has-float32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of single-precision floating-point numbers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float32Array from '@stdlib/array/float32';\n\n\n// VARIABLES //\n\nvar FLOAT32_VIEW = new Float32Array( 1 );\n\n\n// MAIN //\n\n/**\n* Converts a double-precision floating-point number to the nearest single-precision floating-point number.\n*\n* @param {number} x - double-precision floating-point number\n* @returns {number} nearest single-precision floating-point number\n*\n* @example\n* var y = float64ToFloat32( 1.337 );\n* // returns 1.3370000123977661\n*/\nfunction float64ToFloat32( x ) {\n\tFLOAT32_VIEW[ 0 ] = x;\n\treturn FLOAT32_VIEW[ 0 ];\n}\n\n\n// EXPORTS //\n\nexport default float64ToFloat32;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Convert a double-precision floating-point number to the nearest single-precision floating-point number.\n*\n* @module @stdlib/number/float64/base/to-float32\n*\n* @example\n* import float64ToFloat32 from '@stdlib/number/float64/base/to-float32';\n*\n* var y = float64ToFloat32( 1.337 );\n* // returns 1.3370000123977661\n*/\n\n// MODULES //\n\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar float64ToFloat32;\nif ( typeof builtin === 'function' ) {\n\tfloat64ToFloat32 = builtin;\n} else {\n\tfloat64ToFloat32 = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default float64ToFloat32;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport defineProperty from '@stdlib/utils/define-property';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport float64ToFloat32 from '@stdlib/number/float64/base/to-float32';\nimport format from '@stdlib/string/format';\nimport toStr from './tostring.js';\nimport toJSON from './tojson.js';\n\n\n// MAIN //\n\n/**\n* 64-bit complex number constructor.\n*\n* @constructor\n* @param {number} real - real component\n* @param {number} imag - imaginary component\n* @throws {TypeError} must invoke using the `new` keyword\n* @throws {TypeError} real component must be a number\n* @throws {TypeError} imaginary component must be a number\n* @returns {Complex64} 64-bit complex number\n*\n* @example\n* var z = new Complex64( 5.0, 3.0 );\n* // returns \n*/\nfunction Complex64( real, imag ) {\n\tif ( !( this instanceof Complex64 ) ) {\n\t\tthrow new TypeError( 'invalid invocation. Constructor must be called with the `new` keyword.' );\n\t}\n\tif ( !isNumber( real ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Real component must be a number. Value: `%s`.', real ) );\n\t}\n\tif ( !isNumber( imag ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Imaginary component must be a number. Value: `%s`.', imag ) );\n\t}\n\tdefineProperty( this, 're', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': float64ToFloat32( real )\n\t});\n\tdefineProperty( this, 'im', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'writable': false,\n\t\t'value': float64ToFloat32( imag )\n\t});\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var nbytes = Complex64.BYTES_PER_ELEMENT;\n* // returns 4\n*/\nsetReadOnly( Complex64, 'BYTES_PER_ELEMENT', 4 );\n\n/**\n* Size (in bytes) of each component.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64.prototype\n* @type {integer}\n* @returns {integer} size of each component\n*\n* @example\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var nbytes = z.BYTES_PER_ELEMENT;\n* // returns 4\n*/\nsetReadOnly( Complex64.prototype, 'BYTES_PER_ELEMENT', 4 );\n\n/**\n* Length (in bytes) of a complex number.\n*\n* @name byteLength\n* @memberof Complex64.prototype\n* @type {integer}\n* @returns {integer} byte length\n*\n* @example\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var nbytes = z.byteLength;\n* // returns 8\n*/\nsetReadOnly( Complex64.prototype, 'byteLength', 8 );\n\n/**\n* Serializes a complex number as a string.\n*\n* @name toString\n* @memberof Complex64.prototype\n* @type {Function}\n* @returns {string} serialized complex number\n*\n* @example\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var str = z.toString();\n* // returns '5 + 3i'\n*/\nsetReadOnly( Complex64.prototype, 'toString', toStr );\n\n/**\n* Serializes a complex number as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Complex64` instance.\n*\n* @name toJSON\n* @memberof Complex64.prototype\n* @type {Function}\n* @returns {Object} serialized complex number\n*\n* @example\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var obj = z.toJSON();\n* // returns { 'type': 'Complex64', 're': 5.0, 'im': 3.0 }\n*/\nsetReadOnly( Complex64.prototype, 'toJSON', toJSON );\n\n\n// EXPORTS //\n\nexport default Complex64;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a complex number-like object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex number-like object.\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var x = new Complex128( 4.0, 2.0 );\n* var bool = isComplexLike( x );\n* // returns true\n*\n* x = new Complex64( 4.0, 2.0 );\n* bool = isComplexLike( x );\n* // returns true\n*/\nfunction isComplexLike( value ) {\n\tif ( value instanceof Complex128 || value instanceof Complex64 ) {\n\t\treturn true;\n\t}\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof value.re === 'number' &&\n\t\ttypeof value.im === 'number'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplexLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInteger from './../../../../base/assert/is-integer';\n\n\n// MAIN //\n\n/**\n* Tests if a finite numeric value is an even number.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is an even number\n*\n* @example\n* var bool = isEven( 5.0 );\n* // returns false\n*\n* @example\n* var bool = isEven( -2.0 );\n* // returns true\n*\n* @example\n* var bool = isEven( 0.0 );\n* // returns true\n*\n* @example\n* var bool = isEven( NaN );\n* // returns false\n*/\nfunction isEven( x ) {\n\treturn isInteger( x/2.0 );\n}\n\n\n// EXPORTS //\n\nexport default isEven;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Serializes a complex number as a string.\n*\n* @private\n* @returns {string} serialized complex number\n*/\nfunction toString() { // eslint-disable-line stdlib/no-redeclare\n\t/* eslint-disable no-invalid-this */\n\tvar str = '' + this.re;\n\tif ( this.im < 0 ) {\n\t\tstr += ' - ' + (-this.im);\n\t} else {\n\t\tstr += ' + ' + this.im;\n\t}\n\tstr += 'i';\n\treturn str;\n}\n\n\n// EXPORTS //\n\nexport default toString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Serializes a complex number as a JSON object.\n*\n* @private\n* @returns {Object} JSON representation\n*/\nfunction toJSON() {\n\t/* eslint-disable no-invalid-this */\n\tvar out = {};\n\tout.type = 'Complex64';\n\tout.re = this.re;\n\tout.im = this.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toJSON;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = 8; // 4 bytes per float32 x (1 real + 1 imag component)\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `Complex64Array`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Complex64Array`\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n*\n* var bool = isComplex64Array( new Complex64Array( 10 ) );\n* // returns true\n*\n* bool = isComplex64Array( [] );\n* // returns false\n*/\nfunction isComplex64Array( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex64Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex64array`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Complex64Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = 16; // 8 bytes per float64 x (1 real + 1 imag component)\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `Complex128Array`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Complex128Array`\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isComplex128Array( new Complex128Array( 10 ) );\n* // returns true\n*\n* bool = isComplex128Array( [] );\n* // returns false\n*/\nfunction isComplex128Array( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex128Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex128array`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Complex128Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex128Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasOwnProp from './../../has-own-property';\nimport Symbol from '@stdlib/symbol/ctor';\n\n\n// MAIN //\n\n/**\n* Tests for native `Symbol.iterator` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Symbol.iterator` support\n*\n* @example\n* var bool = hasIteratorSymbolSupport();\n* // returns \n*/\nfunction hasIteratorSymbolSupport() {\n\treturn (\n\t\ttypeof Symbol === 'function' &&\n\t\ttypeof Symbol( 'foo' ) === 'symbol' &&\n\t\thasOwnProp( Symbol, 'iterator' ) &&\n\t\ttypeof Symbol.iterator === 'symbol'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default hasIteratorSymbolSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\n\n\n// MAIN //\n\n/**\n* Iterator symbol.\n*\n* @name IteratorSymbol\n* @constant\n* @type {(symbol|null)}\n*\n* @example\n* function iterator() {\n* var it;\n* var i;\n*\n* i = -1;\n*\n* it = {};\n* it.next = next;\n* it.return = done;\n*\n* if ( IteratorSymbol ) {\n* it[ IteratorSymbol ] = iterator;\n* }\n* return it;\n*\n* function next() {\n* i += 1;\n* return {\n* 'value': i,\n* 'done': false\n* };\n* }\n*\n* function done( value ) {\n* if ( arguments.length === 0 ) {\n* return {\n* 'done': true\n* };\n* }\n* return {\n* 'value': value,\n* 'done': true\n* };\n* }\n* }\n*\n* var obj = iterator();\n*/\nvar IteratorSymbol = ( hasIteratorSymbolSupport() ) ? Symbol.iterator : null;\n\n\n// EXPORTS //\n\nexport default IteratorSymbol;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a non-enumerable read-only accessor.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Function} getter - accessor\n*\n* @example\n* function getter() {\n* return 'bar';\n* }\n*\n* var obj = {};\n*\n* setNonEnumerableReadOnlyAccessor( obj, 'foo', getter );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setNonEnumerableReadOnlyAccessor( obj, prop, getter ) { // eslint-disable-line id-length\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'get': getter\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setNonEnumerableReadOnlyAccessor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Returns the real component of a single-precision complex floating-point number.\n*\n* @param {Complex} z - complex number\n* @returns {number} real component\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var re = real( z );\n* // returns 5.0\n*/\nfunction real( z ) {\n\treturn z.re;\n}\n\n\n// EXPORTS //\n\nexport default real;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Returns the imaginary component of a single-precision complex floating-point number.\n*\n* @param {Complex} z - complex number\n* @returns {number} imaginary component\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var im = imag( z );\n* // returns 3.0\n*/\nfunction imag( z ) {\n\treturn z.im;\n}\n\n\n// EXPORTS //\n\nexport default imag;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float32Array from '@stdlib/array/float32';\n\n\n// MAIN //\n\n/**\n* Reinterprets a `Complex64Array` as a `Float32Array`.\n*\n* @param {Complex64Array} x - input array\n* @param {NonNegativeInteger} offset - starting index\n* @returns {Float32Array} `Float32Array` view\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n*\n* var x = new Complex64Array( 10 );\n*\n* var out = reinterpret( x, 0 );\n* // returns \n*\n* var bool = ( out.buffer === x.buffer );\n* // returns true\n*/\nfunction reinterpret( x, offset ) {\n\treturn new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), 2*(x.length-offset) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default reinterpret;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Float64Array === 'function' ) ? Float64Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in the platform byte order.\n*\n* @module @stdlib/array/float64\n*\n* @example\n* import ctor from '@stdlib/array/float64';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasFloat64ArraySupport from '@stdlib/assert/has-float64array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasFloat64ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of double-precision floating-point numbers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from '@stdlib/array/float64';\n\n\n// MAIN //\n\n/**\n* Reinterprets a `Complex128Array` as a `Float64Array`.\n*\n* @param {Complex128Array} x - input array\n* @param {NonNegativeInteger} offset - starting index\n* @returns {Float64Array} `Float64Array` view\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var x = new Complex128Array( 10 );\n*\n* var out = reinterpret( x, 0 );\n* // returns \n*\n* var bool = ( out.buffer === x.buffer );\n* // returns true\n*/\nfunction reinterpret( x, offset ) {\n\treturn new Float64Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), 2*(x.length-offset) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default reinterpret;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tz = v.value;\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( realf( z ), imagf( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/* eslint-disable no-restricted-syntax, max-lines, no-invalid-this */\n\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isArray from '@stdlib/assert/is-array';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport isFunction from '@stdlib/assert/is-function';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport isEven from '@stdlib/math/base/assert/is-even';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport isComplex64Array from './../../base/assert/is-complex64array';\nimport isComplex128Array from './../../base/assert/is-complex128array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Float32Array from './../../float32';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport format from '@stdlib/string/format';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport floor from '@stdlib/math/base/special/floor';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Float32Array.BYTES_PER_ELEMENT * 2;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a complex typed array.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*/\nfunction isComplexArray( value ) {\n\treturn (\n\t\tvalue instanceof Complex64Array ||\n\t\t(\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex64Array' ||\n\t\t\t\tvalue.constructor.name === 'Complex128Array'\n\t\t\t) &&\n\t\t\ttypeof value._length === 'number' && // eslint-disable-line no-underscore-dangle\n\n\t\t\t// NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks...\n\t\t\ttypeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle\n\t\t)\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a complex typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array constructor\n*/\nfunction isComplexArrayConstructor( value ) {\n\treturn (\n\t\tvalue === Complex64Array ||\n\n\t\t// NOTE: weaker test in order to avoid a circular dependency with Complex128Array...\n\t\tvalue.name === 'Complex128Array'\n\t);\n}\n\n/**\n* Retrieves a complex number from a complex number array buffer.\n*\n* @private\n* @param {Float32Array} buf - array buffer\n* @param {NonNegativeInteger} idx - element index\n* @returns {Complex64} complex number\n*/\nfunction getComplex64( buf, idx ) {\n\tidx *= 2;\n\treturn new Complex64( buf[ idx ], buf[ idx+1 ] );\n}\n\n\n// MAIN //\n\n/**\n* 64-bit complex number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `8`\n* @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `8`\n* @throws {TypeError} view length must be a positive multiple of `8`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex64Array} complex number array\n*\n* @example\n* var arr = new Complex64Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Complex64Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Complex64Array( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Complex64Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Complex64Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex64Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Complex64Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Complex64Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Complex64Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Complex64Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Complex64Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Complex64Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Float32Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\tif ( isNonNegativeInteger( arguments[0] ) ) {\n\t\t\tbuf = new Float32Array( arguments[0]*2 );\n\t\t} else if ( isCollection( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tlen = buf.length;\n\n\t\t\t// If provided a \"generic\" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to \"normal\" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number...\n\t\t\tif ( len && isArray( buf ) && isComplexLike( buf[0] ) ) {\n\t\t\t\tbuf = fromArray( new Float32Array( len*2 ), buf );\n\t\t\t\tif ( buf === null ) {\n\t\t\t\t\t// We failed and we are now forced to allocate a new array :-(\n\t\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t\t}\n\t\t\t\t\t// We failed, so fall back to directly setting values...\n\t\t\t\t\tbuf = new Float32Array( arguments[0] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( isComplex64Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret64( buf, 0 );\n\t\t\t\t} else if ( isComplex128Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret128( buf, 0 );\n\t\t\t\t} else if ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tbuf = new Float32Array( buf );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf );\n\t\t} else if ( isObject( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tif ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = buf[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); // FIXME: `buf` is what is returned from above, NOT the original value\n\t\t\t}\n\t\t\tbuf = fromIterator( buf );\n\t\t\tif ( buf instanceof Error ) {\n\t\t\t\tthrow buf;\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arguments[0] ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf, byteOffset, len*2 );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length/2 );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64Array\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var nbytes = Complex64Array.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex64Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex64Array\n* @readonly\n* @type {string}\n* @default 'Complex64Array'\n*\n* @example\n* var str = Complex64Array.name;\n* // returns 'Complex64Array'\n*/\nsetReadOnly( Complex64Array, 'name', 'Complex64Array' );\n\n/**\n* Creates a new 64-bit complex number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Complex64Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex64Array} 64-bit complex number array\n*\n* @example\n* var arr = Complex64Array.from( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function clbk( v ) {\n* return new Complex64( realf(v)*2.0, imagf(v)*2.0 );\n* }\n*\n* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*/\nsetReadOnly( Complex64Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar flg;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isComplexArray( src ) ) {\n\t\tlen = src.length;\n\t\tif ( clbk ) {\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, src.get( i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = realf( v );\n\t\t\t\t\tbuf[ j+1 ] = imagf( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\t// Note: array contents affect how we iterate over a provided data source. If only complex number objects, we can extract real and imaginary components. Otherwise, for non-complex number arrays (e.g., `Float64Array`, etc), we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component.\n\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\t// Detect whether we've been provided an array which returns complex number objects...\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tif ( !isComplexLike( get( src, i ) ) ) {\n\t\t\t\t\tflg = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If an array does not contain only complex number objects, then we assume interleaved real and imaginary components...\n\t\t\tif ( flg ) {\n\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. First argument must have a length which is a multiple of %u. Length: `%u`.', 2, len ) );\n\t\t\t\t}\n\t\t\t\tout = new this( len/2 );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ i ] = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\t// If an array contains only complex number objects, then we need to extract real and imaginary components...\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = realf( v );\n\t\t\t\t\tbuf[ j+1 ] = imagf( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length / 2;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 64-bit complex number array from a variable number of arguments.\n*\n* @name of\n* @memberof Complex64Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} 64-bit complex number array\n*\n* @example\n* var arr = Complex64Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Complex64Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide an integer\n* @returns {(Complex64|void)} array element\n*\n* @example\n* var arr = new Complex64Array( 10 );\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var z = arr.at( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 9.0, -9.0 ], 9 );\n*\n* z = arr.at( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*\n* z = arr.at( -1 );\n* // returns \n*\n* re = realf( z );\n* // returns 9.0\n*\n* im = imagf( z );\n* // returns -9.0\n*\n* z = arr.at( 100 );\n* // returns undefined\n*\n* z = arr.at( -100 );\n* // returns undefined\n*/\nsetReadOnly( Complex64Array.prototype, 'at', function at( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex64( this._buffer, idx );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 80\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex64Array.prototype, 'BYTES_PER_ELEMENT', Complex64Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} modified array\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 4 );\n*\n* // Set the array elements:\n* arr.set( new Complex64( 1.0, 1.0 ), 0 );\n* arr.set( new Complex64( 2.0, 2.0 ), 1 );\n* arr.set( new Complex64( 3.0, 3.0 ), 2 );\n* arr.set( new Complex64( 4.0, 4.0 ), 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* // Get the last array element:\n* var z = arr.get( 3 );\n*\n* var re = realf( z );\n* // returns 2.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex64Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target*2, start*2 );\n\t} else {\n\t\tthis._buffer.copyWithin( target*2, start*2, arguments[2]*2 );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = [\n* new Complex64( 1.0, 1.0 ),\n* new Complex64( 2.0, 2.0 ),\n* new Complex64( 3.0, 3.0 )\n* ];\n* arr = new Complex64Array( arr );\n*\n* // Create an iterator:\n* var it = arr.entries();\n*\n* // Iterate over the key-value pairs...\n* var v = it.next().value;\n* // returns [ 0, ]\n*\n* v = it.next().value;\n* // returns [ 1, ]\n*\n* v = it.next().value;\n* // returns [ 2, ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, getComplex64( buf, i ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, getComplex64( buf, i ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Complex64Array} modified array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.fill( new Complex64( 1.0, 1.0 ), 1 );\n*\n* var z = arr.get( 1 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 1.0\n*\n* z = arr.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tre = realf( value );\n\tim = imagf( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tidx = 2*i;\n\t\tbuf[ idx ] = re;\n\t\tbuf[ idx+1 ] = im;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 1\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 2.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex64Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\tout.push( z );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex64|void)} array element or undefined\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.find( predicate );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var idx = arr.findIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( Complex64Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex64|void)} array element or undefined\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.findLast( predicate );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var idx = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Complex64Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Complex64Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tfcn.call( thisArg, z, i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(Complex64|void)} array element\n*\n* @example\n* var arr = new Complex64Array( 10 );\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*\n* z = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( Complex64Array.prototype, 'get', function get( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex64( this._buffer, idx );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a provided value\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var bool = arr.includes( new Complex64( 3.0, -3.0 ) );\n* // returns true\n*\n* bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 );\n* // returns false\n*\n* bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 10 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) );\n* // returns 2\n*\n* idx = arr.indexOf( new Complex64( 3.0, -3.0 ), 3 );\n* // returns -1\n*\n* idx = arr.indexOf( new Complex64( 4.0, -4.0 ), -3 );\n* // returns -1\n*/\nsetReadOnly( Complex64Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.join();\n* // returns '1 + 1i,2 + 2i'\n*\n* str = arr.join( '/' );\n* // returns '1 + 1i/2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'join', function join( separator ) {\n\tvar out;\n\tvar buf;\n\tvar sep;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tsep = ',';\n\t} else if ( isString( separator ) ) {\n\t\tsep = separator;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toString() );\n\t}\n\treturn out.join( sep );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex] - index at which to start searching backward (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 3.0, -3.0 ], 4 );\n*\n* var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) );\n* // returns 4\n*\n* idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ), 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( new Complex64( 5.0, -5.0 ), 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), -3 );\n* // returns 1\n*/\nsetReadOnly( Complex64Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function scale( v, i ) {\n* return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 2\n*\n* var im = imagf( z );\n* // returns -2\n*/\nsetReadOnly( Complex64Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fcn.call( thisArg, getComplex64( buf, i ), i, this );\n\t\tif ( isComplexLike( v ) ) {\n\t\t\toutbuf[ 2*i ] = realf( v );\n\t\t\toutbuf[ (2*i)+1 ] = imagf( v );\n\t\t} else if ( isArrayLikeObject( v ) && v.length === 2 ) {\n\t\t\toutbuf[ 2*i ] = v[ 0 ];\n\t\t\toutbuf[ (2*i)+1 ] = v[ 1 ];\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t}\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import caddf from '@stdlib/complex/float32/base/add';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduce( caddf );\n* // returns \n*\n* var re = realf( z );\n* // returns 6.0\n*\n* var im = imagf( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex64( buf, 0 );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tv = getComplex64( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import caddf from '@stdlib/complex/float32/base/add';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduceRight( caddf );\n* // returns \n*\n* var re = realf( z );\n* // returns 6.0\n*\n* var im = imagf( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len-1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex64( buf, len-1 );\n\t\ti = len-2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tv = getComplex64( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} reversed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ (2*i) ];\n\t\tbuf[ (2*i) ] = buf[ (2*j) ];\n\t\tbuf[ (2*j) ] = tmp;\n\t\ttmp = buf[ (2*i)+1 ];\n\t\tbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t\tbuf[ (2*j)+1 ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'set', function set( value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tidx *= 2;\n\t\tbuf[ idx ] = realf( value );\n\t\tbuf[ idx+1 ] = imagf( value );\n\t\treturn;\n\t}\n\tif ( isComplexArray( value ) ) {\n\t\tN = value._length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tsbuf = value._buffer;\n\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Float32Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tidx *= 2;\n\t\tj = 0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\tidx += 2; // stride\n\t\t\tj += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// Detect whether we've been provided an array of complex numbers...\n\t\tN = value.length;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tif ( !isComplexLike( value[ i ] ) ) {\n\t\t\t\tflg = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// If an array does not contain only complex numbers, then we assume interleaved real and imaginary components...\n\t\tif ( flg ) {\n\t\t\tif ( !isEven( N ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', N ) );\n\t\t\t}\n\t\t\tif ( idx+(N/2) > this._length ) {\n\t\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t\t}\n\t\t\tsbuf = value;\n\n\t\t\t// Check for overlapping memory...\n\t\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\t\tif (\n\t\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t\t(\n\t\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// We need to copy source values...\n\t\t\t\ttmp = new Float32Array( N );\n\t\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\t\ttmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays\n\t\t\t\t}\n\t\t\t\tsbuf = tmp;\n\t\t\t}\n\t\t\tidx *= 2;\n\t\t\tN /= 2;\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\t\tidx += 2; // stride\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// If an array contains only complex numbers, then we need to extract real and imaginary components...\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tidx *= 2;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tv = value[ i ];\n\t\t\tbuf[ idx ] = realf( v );\n\t\t\tbuf[ idx+1 ] = imagf( v );\n\t\t\tidx += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.', value ) );\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 5.0\n*\n* im = imagf( z );\n* // returns -5.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* z = out.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'slice', function slice( start, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar idx;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tstart = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( start < end ) {\n\t\toutlen = end - start;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\tidx = 2*(i+start);\n\t\toutbuf[ 2*i ] = buf[ idx ];\n\t\toutbuf[ (2*i)+1 ] = buf[ idx+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, getComplex64( buf, i ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} sorted array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = realf( a );\n* re2 = realf( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imagf( a );\n* im2 = imagf( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex64( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = 2 * i;\n\t\tbuf[ j ] = realf( tmp[i] );\n\t\tbuf[ j+1 ] = imagf( tmp[i] );\n\t}\n\treturn this;\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} [begin=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} subarray\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var z = subarr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 5.0\n*\n* im = imagf( z );\n* // returns -5.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* z = subarr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + (begin*BYTES_PER_ELEMENT);\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toLocaleString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} reversed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = len - i - 1;\n\t\toutbuf[ (2*i) ] = buf[ (2*j) ];\n\t\toutbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} sorted array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = realf( a );\n* re2 = realf( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imagf( a );\n* im2 = imagf( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex64( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\treturn new Complex64Array( tmp );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toString() );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns \n*\n* var re = realf( v );\n* // returns 1.0\n*\n* var im = imagf( v );\n* // returns -1.0\n*\n* v = iter.next().value;\n* // returns \n*\n* re = realf( v );\n* // returns 2.0\n*\n* im = imagf( v );\n* // returns -2.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': getComplex64( buf, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {ComplexLike} value - new value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a complex number\n* @returns {Complex64Array} new typed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.with( 0, new Complex64( 4.0, 4.0 ) );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 4.0\n*\n* var im = imagf( z );\n* // returns 4.0\n*/\nsetReadOnly( Complex64Array.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tbuf[ 2*index ] = realf( value );\n\tbuf[ (2*index)+1 ] = imagf( value );\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Complex64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\n\n\n// MAIN //\n\n/**\n* Returns a strided array of real and imaginary components.\n*\n* @private\n* @param {Float32Array} buf - output array\n* @param {Array} arr - array containing complex numbers\n* @returns {(Float32Array|null)} output array or null\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tlen = arr.length;\n\tj = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = arr[ i ];\n\t\tif ( !isComplexLike( v ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tbuf[ j ] = realf( v );\n\t\tbuf[ j+1 ] = imagf( v );\n\t\tj += 2; // stride\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Returns the real component of a double-precision complex floating-point number.\n*\n* @param {Complex} z - complex number\n* @returns {number} real component\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var re = real( z );\n* // returns 5.0\n*/\nfunction real( z ) {\n\treturn z.re;\n}\n\n\n// EXPORTS //\n\nexport default real;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Returns the imaginary component of a double-precision complex floating-point number.\n*\n* @param {Complex} z - complex number\n* @returns {number} imaginary component\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var im = imag( z );\n* // returns 3.0\n*/\nfunction imag( z ) {\n\treturn z.im;\n}\n\n\n// EXPORTS //\n\nexport default imag;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport format from '@stdlib/string/format';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tz = v.value;\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( real( z ), imag( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tz = clbk.call( thisArg, v.value, i );\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( realf( z ), imagf( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/* eslint-disable no-restricted-syntax, max-lines, no-invalid-this */\n\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isArray from '@stdlib/assert/is-array';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport isString from '@stdlib/assert/is-string';\nimport isFunction from '@stdlib/assert/is-function';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport isEven from '@stdlib/math/base/assert/is-even';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport isComplex64Array from './../../base/assert/is-complex64array';\nimport isComplex128Array from './../../base/assert/is-complex128array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Float64Array from './../../float64';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport floor from '@stdlib/math/base/special/floor';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Float64Array.BYTES_PER_ELEMENT * 2;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a complex typed array.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*/\nfunction isComplexArray( value ) {\n\treturn (\n\t\tvalue instanceof Complex128Array ||\n\t\t(\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex64Array' ||\n\t\t\t\tvalue.constructor.name === 'Complex128Array'\n\t\t\t) &&\n\t\t\ttypeof value._length === 'number' && // eslint-disable-line no-underscore-dangle\n\n\t\t\t// NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks...\n\t\t\ttypeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle\n\t\t)\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a complex typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array constructor\n*/\nfunction isComplexArrayConstructor( value ) {\n\treturn (\n\t\tvalue === Complex128Array ||\n\n\t\t// NOTE: weaker test in order to avoid a circular dependency with Complex64Array...\n\t\tvalue.name === 'Complex64Array'\n\t);\n}\n\n/**\n* Retrieves a complex number from a complex number array buffer.\n*\n* @private\n* @param {Float64Array} buf - array buffer\n* @param {NonNegativeInteger} idx - element index\n* @returns {Complex128} complex number\n*/\nfunction getComplex128( buf, idx ) {\n\tidx *= 2;\n\treturn new Complex128( buf[ idx ], buf[ idx+1 ] );\n}\n\n\n// MAIN //\n\n/**\n* 128-bit complex number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `16`\n* @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `16`\n* @throws {TypeError} view length must be a positive multiple of `16`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex128Array} complex number array\n*\n* @example\n* var arr = new Complex128Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Complex128Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Complex128Array( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex128Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex128Array( buf, 16 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 64 );\n* var arr = new Complex128Array( buf, 16, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Complex128Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Complex128Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Complex128Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Complex128Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Complex128Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Complex128Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Float64Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\tif ( isNonNegativeInteger( arguments[0] ) ) {\n\t\t\tbuf = new Float64Array( arguments[0]*2 );\n\t\t} else if ( isCollection( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tlen = buf.length;\n\n\t\t\t// If provided a \"generic\" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to \"normal\" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number...\n\t\t\tif ( len && isArray( buf ) && isComplexLike( buf[0] ) ) {\n\t\t\t\tbuf = fromArray( new Float64Array( len*2 ), buf );\n\t\t\t\tif ( buf === null ) {\n\t\t\t\t\t// We failed and we are now forced to allocate a new array :-(\n\t\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t\t}\n\t\t\t\t\t// We failed, so fall back to directly setting values...\n\t\t\t\t\tbuf = new Float64Array( arguments[0] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( isComplex64Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret64( buf, 0 );\n\t\t\t\t} else if ( isComplex128Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret128( buf, 0 );\n\t\t\t\t} else if ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tbuf = new Float64Array( buf );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf );\n\t\t} else if ( isObject( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tif ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = buf[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = fromIterator( buf );\n\t\t\tif ( buf instanceof Error ) {\n\t\t\t\tthrow buf;\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arguments[0] ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf, byteOffset, len*2 );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length/2 );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128Array\n* @readonly\n* @type {PositiveInteger}\n* @default 16\n*\n* @example\n* var nbytes = Complex128Array.BYTES_PER_ELEMENT;\n* // returns 16\n*/\nsetReadOnly( Complex128Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128Array\n* @readonly\n* @type {string}\n* @default 'Complex128Array'\n*\n* @example\n* var name = Complex128Array.name;\n* // returns 'Complex128Array'\n*/\nsetReadOnly( Complex128Array, 'name', 'Complex128Array' );\n\n/**\n* Creates a new 128-bit complex number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Complex128Array\n* @type {Function}\n* @param {(Collection|Object)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex128Array} 128-bit complex number array\n*\n* @example\n* var arr = Complex128Array.from( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function clbk( v ) {\n* return new Complex128( real(v)*2.0, imag(v)*2.0 );\n* }\n*\n* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*/\nsetReadOnly( Complex128Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar flg;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isComplexArray( src ) ) {\n\t\tlen = src.length;\n\t\tif ( clbk ) {\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, src.get( i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = real( v );\n\t\t\t\t\tbuf[ j+1 ] = imag( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\t// Note: array contents affect how we iterate over a provided data source. If only complex number objects, we can extract real and imaginary components. Otherwise, for non-complex number arrays (e.g., `Float64Array`, etc), we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component.\n\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\t// Detect whether we've been provided an array which returns complex number objects...\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tif ( !isComplexLike( get( src, i ) ) ) {\n\t\t\t\t\tflg = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If an array does not contain only complex number objects, then we assume interleaved real and imaginary components...\n\t\t\tif ( flg ) {\n\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. First argument must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tout = new this( len/2 );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ i ] = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\t// If an array contains only complex number objects, then we need to extract real and imaginary components...\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = real( v );\n\t\t\t\t\tbuf[ j+1 ] = imag( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length / 2;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 128-bit complex number array from a variable number of arguments.\n*\n* @name of\n* @memberof Complex128Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} 128-bit complex number array\n*\n* @example\n* var arr = Complex128Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Complex128Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide an integer\n* @returns {(Complex128|void)} array element\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 10 );\n*\n* var z = arr.at( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 9.0, -9.0 ], 9 );\n*\n* z = arr.at( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*\n* z = arr.at( -1 );\n* // returns \n*\n* re = real( z );\n* // returns 9.0\n*\n* im = imag( z );\n* // returns -9.0\n*\n* z = arr.at( 100 );\n* // returns undefined\n*\n* z = arr.at( -100 );\n* // returns undefined\n*/\nsetReadOnly( Complex128Array.prototype, 'at', function at( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex128( this._buffer, idx );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 160\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 16\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 16\n*/\nsetReadOnly( Complex128Array.prototype, 'BYTES_PER_ELEMENT', Complex128Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} modified array\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 4 );\n*\n* // Set the array elements:\n* arr.set( new Complex128( 1.0, 1.0 ), 0 );\n* arr.set( new Complex128( 2.0, 2.0 ), 1 );\n* arr.set( new Complex128( 3.0, 3.0 ), 2 );\n* arr.set( new Complex128( 4.0, 4.0 ), 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* // Get the last array element:\n* var z = arr.get( 3 );\n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target*2, start*2 );\n\t} else {\n\t\tthis._buffer.copyWithin( target*2, start*2, arguments[2]*2 );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = [\n* new Complex128( 1.0, 1.0 ),\n* new Complex128( 2.0, 2.0 ),\n* new Complex128( 3.0, 3.0 )\n* ];\n* arr = new Complex128Array( arr );\n*\n* // Create an iterator:\n* var it = arr.entries();\n*\n* // Iterate over the key-value pairs...\n* var v = it.next().value;\n* // returns [ 0, ]\n*\n* v = it.next().value;\n* // returns [ 1, ]\n*\n* v = it.next().value;\n* // returns [ 2, ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'entries', function entries() {\n\tvar buffer;\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuffer = this._buffer;\n\tlen = this._length;\n\n\t// Initialize the iteration indices:\n\ti = -1;\n\tj = -2;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\tvar z;\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tj += 2;\n\t\tz = new Complex128( buffer[ j ], buffer[ j+1 ] );\n\t\treturn {\n\t\t\t'value': [ i, z ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, getComplex128( buf, i ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Complex128Array} modified array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.fill( new Complex128( 1.0, 1.0 ), 1 );\n*\n* var z = arr.get( 1 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns 1.0\n*\n* z = arr.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tre = real( value );\n\tim = imag( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tidx = 2*i;\n\t\tbuf[ idx ] = re;\n\t\tbuf[ idx+1 ] = im;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 1\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\tout.push( z );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex128|void)} array element or undefined\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.find( predicate );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var idx = arr.findIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( Complex128Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex128|void)} array element or undefined\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.findLast( predicate );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var idx = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Complex128Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Complex128Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tfcn.call( thisArg, z, i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(Complex128|void)} array element\n*\n* @example\n* var arr = new Complex128Array( 10 );\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*\n* z = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( Complex128Array.prototype, 'get', function get( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex128( this._buffer, idx );\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a provided value\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var bool = arr.includes( new Complex128( 3.0, -3.0 ) );\n* // returns true\n*\n* bool = arr.includes( new Complex128( 3.0, -3.0 ), 3 );\n* // returns false\n*\n* bool = arr.includes( new Complex128( 4.0, -4.0 ), -3 );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var idx = arr.indexOf( new Complex128( 3.0, -3.0 ) );\n* // returns 2\n*\n* idx = arr.indexOf( new Complex128( 3.0, -3.0 ), 3 );\n* // returns -1\n*\n* idx = arr.indexOf( new Complex128( 4.0, -4.0 ), -3 );\n* // returns 3\n*/\nsetReadOnly( Complex128Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.join();\n* // returns '1 + 1i,2 + 2i'\n*\n* str = arr.join( '/' );\n* // returns '1 + 1i/2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'join', function join( separator ) {\n\tvar out;\n\tvar buf;\n\tvar sep;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tsep = ',';\n\t} else if ( isString( separator ) ) {\n\t\tsep = separator;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toString() );\n\t}\n\treturn out.join( sep );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex] - index at which to start searching backward (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 3.0, -3.0 ], 4 );\n*\n* var idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ) );\n* // returns 4\n*\n* idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ), 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( new Complex128( 5.0, -5.0 ), 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), -3 );\n* // returns 1\n*/\nsetReadOnly( Complex128Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function scale( v, i ) {\n* return new Complex128( 2.0*real( v ), 2.0*imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns -2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fcn.call( thisArg, getComplex128( buf, i ), i, this );\n\t\tif ( isComplexLike( v ) ) {\n\t\t\toutbuf[ 2*i ] = real( v );\n\t\t\toutbuf[ (2*i)+1 ] = imag( v );\n\t\t} else if ( isArrayLikeObject( v ) && v.length === 2 ) {\n\t\t\toutbuf[ 2*i ] = v[ 0 ];\n\t\t\toutbuf[ (2*i)+1 ] = v[ 1 ];\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t}\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import cadd from '@stdlib/complex/float64/base/add';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduce( cadd );\n* // returns \n*\n* var re = real( z );\n* // returns 6.0\n*\n* var im = imag( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex128( buf, 0 );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tv = getComplex128( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import cadd from '@stdlib/complex/float64/base/add';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduceRight( cadd );\n* // returns \n*\n* var re = real( z );\n* // returns 6.0\n*\n* var im = imag( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len-1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex128( buf, len-1 );\n\t\ti = len-2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tv = getComplex128( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} reversed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ (2*i) ];\n\t\tbuf[ (2*i) ] = buf[ (2*j) ];\n\t\tbuf[ (2*j) ] = tmp;\n\t\ttmp = buf[ (2*i)+1 ];\n\t\tbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t\tbuf[ (2*j)+1 ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended.\n*\n* @name set\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'set', function set( value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tidx *= 2;\n\t\tbuf[ idx ] = real( value );\n\t\tbuf[ idx+1 ] = imag( value );\n\t\treturn;\n\t}\n\tif ( isComplexArray( value ) ) {\n\t\tN = value._length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tsbuf = value._buffer;\n\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Float64Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tidx *= 2;\n\t\tj = 0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\tidx += 2; // stride\n\t\t\tj += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// Detect whether we've been provided an array of complex numbers...\n\t\tN = value.length;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tif ( !isComplexLike( value[ i ] ) ) {\n\t\t\t\tflg = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// If an array does not contain only complex numbers, then we assume interleaved real and imaginary components...\n\t\tif ( flg ) {\n\t\t\tif ( !isEven( N ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', N ) );\n\t\t\t}\n\t\t\tif ( idx+(N/2) > this._length ) {\n\t\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t\t}\n\t\t\tsbuf = value;\n\n\t\t\t// Check for overlapping memory...\n\t\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\t\tif (\n\t\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t\t(\n\t\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// We need to copy source values...\n\t\t\t\ttmp = new Float64Array( N );\n\t\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t\t}\n\t\t\t\tsbuf = tmp;\n\t\t\t}\n\t\t\tidx *= 2;\n\t\t\tN /= 2;\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\t\tidx += 2; // stride\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// If an array contains only complex numbers, then we need to extract real and imaginary components...\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tidx *= 2;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tv = value[ i ];\n\t\t\tbuf[ idx ] = real( v );\n\t\t\tbuf[ idx+1 ] = imag( v );\n\t\t\tidx += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.', value ) );\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 5.0\n*\n* im = imag( z );\n* // returns -5.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* z = out.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'slice', function slice( start, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar idx;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tstart = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( start < end ) {\n\t\toutlen = end - start;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\tidx = 2*(i+start);\n\t\toutbuf[ 2*i ] = buf[ idx ];\n\t\toutbuf[ (2*i)+1 ] = buf[ idx+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, getComplex128( buf, i ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} sorted array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = real( a );\n* re2 = real( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imag( a );\n* im2 = imag( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex128( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = 2 * i;\n\t\tbuf[ j ] = real( tmp[i] );\n\t\tbuf[ j+1 ] = imag( tmp[i] );\n\t}\n\treturn this;\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} [begin=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} subarray\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var z = subarr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 5.0\n*\n* im = imag( z );\n* // returns -5.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* z = subarr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toLocaleString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} reversed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = len - i - 1;\n\t\toutbuf[ (2*i) ] = buf[ (2*j) ];\n\t\toutbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} sorted array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = real( a );\n* re2 = real( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imag( a );\n* im2 = imag( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex128( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\treturn new Complex128Array( tmp );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toString() );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns \n*\n* var re = real( v );\n* // returns 1.0\n*\n* var im = imag( v );\n* // returns -1.0\n*\n* v = iter.next().value;\n* // returns \n*\n* re = real( v );\n* // returns 2.0\n*\n* im = imag( v );\n* // returns -2.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': getComplex128( buf, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {ComplexLike} value - new value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a complex number\n* @returns {Complex128Array} new typed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.with( 0, new Complex128( 4.0, 4.0 ) );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 4.0\n*\n* var im = imag( z );\n* // returns 4.0\n*/\nsetReadOnly( Complex128Array.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tbuf[ 2*index ] = real( value );\n\tbuf[ (2*index)+1 ] = imag( value );\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Complex128Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns a strided array of real and imaginary components.\n*\n* @private\n* @param {Float64Array} buf - output array\n* @param {Array} arr - array containing complex numbers\n* @returns {(Float64Array|null)} output array or null\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tlen = arr.length;\n\tj = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = arr[ i ];\n\t\tif ( !isComplexLike( v ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tbuf[ j ] = real( v );\n\t\tbuf[ j+1 ] = imag( v );\n\t\tj += 2; // stride\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( Boolean( v.value ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport format from '@stdlib/string/format';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tz = clbk.call( thisArg, v.value, i );\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( real( z ), imag( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Uint8Array from './../../uint8';\nimport Boolean from '@stdlib/boolean/ctor';\nimport getter from './../../base/getter';\nimport floor from '@stdlib/math/base/special/floor';\nimport accessorGetter from './../../base/accessor-getter';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint8Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `BooleanArray`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `BooleanArray`\n*/\nfunction isBooleanArray( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'BooleanArray' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a boolean typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a boolean typed array constructor\n*/\nfunction isBooleanArrayConstructor( value ) {\n\treturn ( value === BooleanArray );\n}\n\n\n// MAIN //\n\n/**\n* Boolean array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new BooleanArray( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new BooleanArray( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 16\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new BooleanArray( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction BooleanArray() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof BooleanArray) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new BooleanArray();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new BooleanArray( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new BooleanArray( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new BooleanArray( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint8Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tbuf = fromArray( new Uint8Array( arg.length ), arg );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tbuf = new Uint8Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var nbytes = BooleanArray.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof BooleanArray\n* @readonly\n* @type {string}\n* @default 'BooleanArray'\n*\n* @example\n* var str = BooleanArray.name;\n* // returns 'BooleanArray'\n*/\nsetReadOnly( BooleanArray, 'name', 'BooleanArray' );\n\n/**\n* Creates a new boolean array from an array-like object or an iterable.\n*\n* @name from\n* @memberof BooleanArray\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.from( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return !v;\n* }\n*\n* var arr = BooleanArray.from( [ true, false ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( BooleanArray, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = Boolean( clbk.call( thisArg, get( src, i ), i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new boolean array from a variable number of arguments.\n*\n* @name of\n* @memberof BooleanArray\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.of( true, true, true, true );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( BooleanArray, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide an integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.at( 0 );\n* // returns true\n*\n* v = arr.at( -1 );\n* // returns true\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'at', function at( idx ) {\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tif ( idx < 0 ) {\n\t\tidx += len;\n\t}\n\tif ( idx < 0 || idx >= len ) {\n\t\treturn;\n\t}\n\treturn Boolean( buf[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray.prototype, 'BYTES_PER_ELEMENT', BooleanArray.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 4 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n* arr.set( true, 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr.get( 2 );\n* // returns true\n*\n* v = arr.get( 3 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, true ]\n*\n* v = it.next().value;\n* // returns [ 1, false ]\n*\n* v = it.next().value;\n* // returns [ 2, true ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, Boolean( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.fill( true, 1 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar val;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tif ( value ) {\n\t\tval = 1;\n\t} else {\n\t\tval = 0;\n\t}\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = val;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* function predicate( v ) {\n* return ( v === true );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.find( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findIndex( predicate );\n* // returns 0\n*/\nsetReadOnly( BooleanArray.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLast( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( BooleanArray.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, Boolean( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'get', function get( idx ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn Boolean( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var bool = arr.includes( true );\n* // returns true\n*\n* bool = arr.includes( false, 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.indexOf( true );\n* // returns 0\n*\n* idx = arr.indexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.indexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.join();\n* // returns 'true,false,true'\n*\n* str = arr.join( '|' );\n* // returns 'true|false|true'\n*/\nsetReadOnly( BooleanArray.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.lastIndexOf( true );\n* // returns 4\n*\n* idx = arr.lastIndexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} new boolean array\n*\n* @example\n* function invert( v ) {\n* return !v;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.map( invert );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns false\n*\n* z = out.get( 1 );\n* // returns true\n*\n* z = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = Boolean( fcn.call( thisArg, Boolean( buf[ i ] ), i, this ) );\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduce( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduceRight( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(Collection|BooleanArray|*)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isCollection( value ) ) {\n\t\tN = value.length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tif ( isBooleanArray( value ) ) {\n\t\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\t} else {\n\t\t\tsbuf = value;\n\t\t}\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Uint8Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = ( sbuf[ i ] ) ? 1 : 0;\n\t\t}\n\t\treturn;\n\t}\n\tif ( idx >= this._length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t}\n\tbuf[ idx ] = ( value ) ? 1 : 0;\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var bool = out.get( 0 );\n* // returns true\n*\n* bool = out.get( len-1 );\n* // returns true\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* bool = out.get( 0 );\n* // returns false\n*\n* bool = out.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( false, 0 );\n* arr.set( true, 1 );\n* arr.set( false, 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.sort( compare );\n*\n* var v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort();\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {BooleanArray} subarray\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr.get( 0 );\n* // returns true\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr.get( 0 );\n* // returns false\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toLocaleString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( Boolean( buf[ i ] ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*\n* v = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ i ];\n\t}\n\tif ( arguments.length === 0 ) {\n\t\toutbuf.sort();\n\t\treturn out;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\toutbuf.sort( compare );\n\treturn out;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns true\n*\n* v = iter.next().value;\n* // returns false\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': Boolean( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {boolean} value - new value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a boolean\n* @returns {BooleanArray} new typed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.with( 0, false );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a boolean. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tif ( value ) {\n\t\tbuf[ index ] = 1;\n\t} else {\n\t\tbuf[ index ] = 0;\n\t}\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default BooleanArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Fills an output array with \"boolean\" values.\n*\n* @private\n* @param {Uint8Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint8Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = Boolean( arr[ i ] );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( Boolean( clbk.call( thisArg, v.value, i ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Uint32Array from './../../uint32';\nimport Int32Array from './../../int32';\nimport Uint16Array from './../../uint16';\nimport Int16Array from './../../int16';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Int8Array from './../../int8';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\n// Note: order should match `dtypes` order\nvar CTORS = [\n\tFloat64Array,\n\tFloat32Array,\n\tInt32Array,\n\tUint32Array,\n\tInt16Array,\n\tUint16Array,\n\tInt8Array,\n\tUint8Array,\n\tUint8ClampedArray,\n\tComplex64Array,\n\tComplex128Array,\n\tBooleanArray\n];\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Note: order should match `ctors` order\nvar DTYPES = [\n\t'float64',\n\t'float32',\n\t'int32',\n\t'uint32',\n\t'int16',\n\t'uint16',\n\t'int8',\n\t'uint8',\n\t'uint8c',\n\t'complex64',\n\t'complex128',\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isBuffer from '@stdlib/assert/is-buffer';\nimport isArray from '@stdlib/assert/is-array';\nimport constructorName from '@stdlib/utils/constructor-name';\nimport ctor2dtype from './ctor2dtype.js';\nimport CTORS from './ctors.js';\nimport DTYPES from './dtypes.js';\n\n\n// VARIABLES //\n\nvar NTYPES = DTYPES.length;\n\n\n// MAIN //\n\n/**\n* Returns the data type of an array.\n*\n* @param {*} value - input value\n* @returns {(string|null)} data type\n*\n* @example\n* var dt = dtype( [ 1, 2, 3 ] );\n* // returns 'generic'\n*\n* var dt = dtype( 'beep' );\n* // returns null\n*/\nfunction dtype( value ) {\n\tvar i;\n\tif ( isArray( value ) ) {\n\t\treturn 'generic';\n\t}\n\tif ( isBuffer( value ) ) {\n\t\treturn null;\n\t}\n\tfor ( i = 0; i < NTYPES; i++ ) {\n\t\tif ( value instanceof CTORS[ i ] ) {\n\t\t\treturn DTYPES[ i ];\n\t\t}\n\t}\n\t// If the above failed, fall back to a more robust (and significantly slower) means for resolving underlying data types:\n\treturn ctor2dtype[ constructorName( value ) ] || null;\n}\n\n\n// EXPORTS //\n\nexport default dtype;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport getter from './../../../base/getter';\nimport setter from './../../../base/setter';\nimport accessorGetter from './../../../base/accessor-getter';\nimport accessorSetter from './../../../base/accessor-setter';\nimport dtype from './../../../dtype';\n\n\n// MAIN //\n\n/**\n* Returns element accessors for a provided array-like object.\n*\n* ## Notes\n*\n* - The returned object has the following properties:\n*\n* - **accessorProtocol**: `boolean` indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements).\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing accessor data\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var obj = accessors( x );\n* // returns {...}\n*\n* var bool = obj.accessorProtocol;\n* // returns false\n*\n* var fcns = obj.accessors;\n* // returns [ , ]\n*\n* var v = fcns[ 0 ]( x, 2 );\n* // returns 3\n*/\nfunction accessors( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default accessors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadWriteAccessor from '@stdlib/utils/define-nonenumerable-read-write-accessor';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport accessors from './../../../base/accessors';\nimport isCollection from '@stdlib/assert/is-collection';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Sets the length of an array-like object.\n*\n* @private\n* @param {NonNegativeInteger} len - length\n*/\nfunction setLength( len ) {\n\tthis._buffer.length = len;\n}\n\n/**\n* Returns the length of an array-like object.\n*\n* @private\n* @returns {NonNegativeInteger} length\n*/\nfunction getLength() {\n\treturn this._buffer.length;\n}\n\n\n// MAIN //\n\n/**\n* Creates a minimal array-like object supporting the accessor protocol from another array-like object.\n*\n* @constructor\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {AccessorArray} accessor array instance\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nfunction AccessorArray( arr ) {\n\tvar o;\n\tif ( !(this instanceof AccessorArray) ) {\n\t\treturn new AccessorArray( arr );\n\t}\n\tif ( !isCollection( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\to = accessors( arr );\n\tthis._buffer = arr;\n\tthis._getter = o.accessors[ 0 ];\n\tthis._setter = o.accessors[ 1 ];\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof AccessorArray\n* @readonly\n* @type {string}\n* @default 'AccessorArray'\n*\n* @example\n* var name = AccessorArray.name;\n* // returns 'AccessorArray'\n*/\nsetReadOnly( AccessorArray, 'name', 'AccessorArray' );\n\n/**\n* Read/write accessor for getting/setting the number of elements.\n*\n* @name length\n* @memberof AccessorArray.prototype\n* @type {NonNegativeInteger}\n*/\nsetReadWriteAccessor( AccessorArray.prototype, 'length', getLength, setLength );\n\n/**\n* Returns an element.\n*\n* @name get\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @returns {*} element\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*/\nsetReadOnly( AccessorArray.prototype, 'get', function get( idx ) {\n\treturn this._getter( this._buffer, idx );\n});\n\n/**\n* Sets one or more elements.\n*\n* @name set\n* @memberof AccessorArray.prototype\n* @type {Function}\n* @param {*} value - value to set\n* @param {integer} [idx] - element index\n* @returns {void}\n*\n* @example\n* var arr = new AccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* arr.set( 5, 0 );\n*\n* v = arr.get( 0 );\n* // returns 5\n*/\nsetReadOnly( AccessorArray.prototype, 'set', function set( value, idx ) {\n\tif ( arguments.length < 2 ) {\n\t\tthis._setter( this._buffer, 0, value );\n\t\treturn;\n\t}\n\tthis._setter( this._buffer, idx, value );\n});\n\n\n// EXPORTS //\n\nexport default AccessorArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a non-enumerable read-write accessor.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Function} getter - get accessor\n* @param {Function} setter - set accessor\n*\n* @example\n* function getter() {\n* return name + ' foo';\n* }\n*\n* function setter( v ) {\n* name = v;\n* }\n*\n* var name = 'bar';\n* var obj = {};\n*\n* setNonEnumerableReadWriteAccessor( obj, 'foo', getter, setter );\n*\n* var v = obj.foo;\n* // returns 'bar foo'\n*\n* obj.foo = 'beep';\n*\n* v = obj.foo;\n* // returns 'beep foo'\n*/\nfunction setNonEnumerableReadWriteAccessor( obj, prop, getter, setter ) { // eslint-disable-line id-length\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'get': getter,\n\t\t'set': setter\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setNonEnumerableReadWriteAccessor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = 1; // 1 bytes per uint8\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `BooleanArray`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `BooleanArray`\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var bool = isBooleanArray( new BooleanArray( 10 ) );\n* // returns true\n*\n* bool = isBooleanArray( [] );\n* // returns false\n*/\nfunction isBooleanArray( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `BooleanArray` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-booleanarray`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'BooleanArray' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isBooleanArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport getter from './../../../base/getter';\nimport setter from './../../../base/setter';\nimport accessorGetter from './../../../base/accessor-getter';\nimport accessorSetter from './../../../base/accessor-setter';\nimport dtype from './../../../dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint8Array === 'function' ) ? Uint8Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint8\n*\n* @example\n* import ctor from '@stdlib/array/uint8';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint8ArraySupport from '@stdlib/assert/has-uint8array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint8ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 8-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array/uint8';\n\n\n// MAIN //\n\n/**\n* Reinterprets a `BooleanArray` as a `Uint8Array`.\n*\n* @param {BooleanArray} x - input array\n* @param {NonNegativeInteger} offset - starting index\n* @returns {Uint8Array} `Uint8Array` view\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var x = new BooleanArray( 10 );\n*\n* var out = reinterpret( x, 0 );\n* // returns \n*\n* var bool = ( out.buffer === x.buffer );\n* // returns true\n*/\nfunction reinterpret( x, offset ) {\n\treturn new Uint8Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default reinterpret;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in an array is truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether at least one element is truthy\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = internal( x );\n* // returns false\n*/\nfunction internal( x ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( x[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in an array is truthy.\n*\n* @private\n* @param {Object} x - input array object\n* @returns {boolean} boolean indicating whether at least one element is truthy\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n*\n* var out = accessors( x );\n* // returns false\n*/\nfunction accessors( x ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( get( data, i ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in an array is truthy.\n*\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether at least one element is truthy\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = any( x );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = any( x );\n* // returns false\n*/\nfunction any( x ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\treturn internal( reinterpret128( x, 0 ) );\n\t\t}\n\t\tif ( isComplex64Array( x ) ) {\n\t\t\treturn internal( reinterpret64( x, 0 ) );\n\t\t}\n\t\t// If provided a boolean array, reinterpret as typed array and test for truthiness...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn internal( reinterpretBoolean( x, 0 ) );\n\t\t}\n\t\treturn accessors( obj );\n\t}\n\treturn internal( x );\n}\n\n\n// EXPORTS //\n\nexport default any;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../base/accessor-getter';\nimport getter from './../../../base/getter';\nimport dtype from './../../../dtype';\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an array-like object.\n*\n* @param {Collection} x - input array\n* @returns {Function} accessor\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var get = resolveGetter( arr );\n* var v = get( arr, 2 );\n* // returns 3\n*/\nfunction resolveGetter( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessorGetter( dt );\n\t}\n\treturn getter( dt );\n}\n\n\n// EXPORTS //\n\nexport default resolveGetter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if an object has a specified property, either own or inherited.\n*\n* @param {*} value - value to test\n* @param {*} property - property to test\n* @returns {boolean} boolean indicating if an object has a specified property\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = hasProp( beep, 'boop' );\n* // returns true\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = hasProp( beep, 'bap' );\n* // returns false\n*/\nfunction hasProp( value, property ) {\n\tif ( value === void 0 || value === null ) {\n\t\treturn false;\n\t}\n\tif ( typeof property === 'symbol' ) {\n\t\treturn property in Object( value );\n\t}\n\treturn ( String( property ) in Object( value ) );\n}\n\n\n// EXPORTS //\n\nexport default hasProp;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../../base/accessor-getter';\nimport getter from './../../../../base/getter';\nimport dtype from './../../../../dtype';\n\n\n// MAIN //\n\n/**\n* Tests if an array contains a provided search value.\n*\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {boolean} boolean indicating if an array contains a search value\n*\n* @example\n* var out = contains( [ 1, 2, 3 ], 2 );\n* // returns true\n*/\nfunction contains( x, value ) {\n\tvar len;\n\tvar get;\n\tvar dt;\n\tvar i;\n\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Resolve an accessor for retrieving input array elements:\n\tif ( isAccessorArray( x ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\t// Get the number of elements over which to iterate:\n\tlen = x.length;\n\n\t// Loop over the elements...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( get( x, i ) === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default contains;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../../base/accessor-getter';\nimport dtype from './../../../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a function to tests if an array contains a provided search value.\n*\n* @param {Collection} x - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {Function} function to test if an array contains a search value\n*\n* @example\n* var contains = factory( [ 1, 2, 3 ] );\n* // returns \n*\n* var bool = contains( 2 );\n* // returns true\n*/\nfunction factory( x ) {\n\tvar get;\n\tvar len;\n\tvar dt;\n\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', x ) );\n\t}\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Resolve an accessor for retrieving input array elements:\n\tif ( isAccessorArray( x ) ) {\n\t\tget = accessorGetter( dt );\n\t}\n\t// Get the number of elements over which to iterate:\n\tlen = x.length;\n\n\treturn ( get === void 0 ) ? contains : accessors;\n\t/**\n\t* Tests if an array contains a provided search value.\n\t*\n\t* @private\n\t* @param {*} value - search value\n\t* @returns {boolean} boolean indicating if an array contains a search value\n\t*\n\t* @example\n\t* var out = contains( [ 1, 2, 3 ], 2 );\n\t* // returns true\n\t*/\n\tfunction contains( value ) {\n\t\tvar i;\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( x[ i ] === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t* Tests if an array contains a provided search value.\n\t*\n\t* @private\n\t* @param {*} value - search value\n\t* @returns {boolean} boolean indicating if an array contains a search value\n\t*/\n\tfunction accessors( value ) {\n\t\tvar i;\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( get( x, i ) === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if a single-precision floating-point numeric value is `NaN`.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is `NaN`\n*\n* @example\n* var bool = isnanf( NaN );\n* // returns true\n*\n* @example\n* var bool = isnanf( 7.0 );\n* // returns false\n*/\nfunction isnanf( x ) {\n\treturn ( x !== x );\n}\n\n\n// EXPORTS //\n\nexport default isnanf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if an array contains a provided search value.\n*\n* @module @stdlib/array/base/assert/contains\n*\n* @example\n* import contains from '@stdlib/array/base/assert/contains';\n*\n* var out = contains( [ 1, 2, 3 ], 2 );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"factory\": \"main.factory\" }\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Mask for the sign bit of a single-precision floating-point number.\n*\n* @module @stdlib/constants/float32/sign-mask\n* @type {uinteger32}\n*\n* @example\n* import FLOAT32_SIGN_MASK from '@stdlib/constants/float32/sign-mask';\n* // returns 2147483648\n*/\n\n\n// MAIN //\n\n/**\n* Mask for the sign bit of a single-precision floating-point number.\n*\n* ## Notes\n*\n* The mask for the sign bit of a single-precision floating-point number is an unsigned 32-bit integer with the value \\\\( 2147483648 \\\\), which corresponds to the bit sequence\n*\n* ```binarystring\n* 1 00000000 00000000000000000000000\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 0x80000000\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT32_SIGN_MASK = 0x80000000>>>0;\n\n\n// EXPORTS //\n\nexport default FLOAT32_SIGN_MASK;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint32Array === 'function' ) ? Uint32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 32-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint32\n*\n* @example\n* import ctor from '@stdlib/array/uint32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint32ArraySupport from '@stdlib/assert/has-uint32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 32-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float32Array from '@stdlib/array/float32';\nimport Uint32Array from '@stdlib/array/uint32';\n\n\n// VARIABLES //\n\nvar FLOAT32_VIEW = new Float32Array( 1.0 );\nvar UINT32_VIEW = new Uint32Array( FLOAT32_VIEW.buffer );\n\n\n// MAIN //\n\n/**\n* Returns an unsigned 32-bit integer corresponding to the IEEE 754 binary representation of a single-precision floating-point number.\n*\n* @param {number} x - single-precision floating-point number\n* @returns {unsigned32} unsigned 32-bit integer\n*\n* @example\n* import float64ToFloat32 from '@stdlib/number/float64/base/to-float32';\n*\n* var f32 = float64ToFloat32( 1.337 );\n* // returns 1.3370000123977661\n*\n* var w = toWordf( f32 ); // => 0 01111111 01010110010001011010001\n* // returns 1068180177\n*/\nfunction toWordf( x ) {\n\tFLOAT32_VIEW[ 0 ] = x;\n\treturn UINT32_VIEW[ 0 ];\n}\n\n\n// EXPORTS //\n\nexport default toWordf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Computes the absolute value of a double-precision floating-point number `x`.\n*\n* @param {number} x - input value\n* @returns {number} absolute value\n*\n* @example\n* var v = abs( -1.0 );\n* // returns 1.0\n*\n* @example\n* var v = abs( 2.0 );\n* // returns 2.0\n*\n* @example\n* var v = abs( 0.0 );\n* // returns 0.0\n*\n* @example\n* var v = abs( -0.0 );\n* // returns 0.0\n*\n* @example\n* var v = abs( NaN );\n* // returns NaN\n*/\nfunction abs( x ) {\n\treturn Math.abs( x ); // eslint-disable-line stdlib/no-builtin-math\n}\n\n\n// EXPORTS //\n\nexport default abs;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnanf from '@stdlib/math/base/assert/is-nanf';\nimport SIGN_MASK from '@stdlib/constants/float32/sign-mask';\nimport toWordf from './../../../../float32/base/to-word';\nimport abs from '@stdlib/math/base/special/abs';\n\n\n// FUNCTIONS //\n\n/**\n* Converts an unsigned 32-bit integer corresponding to the IEEE 754 binary representation of a single-precision floating-point number to a lexicographically ordered integer.\n*\n* @private\n* @param {unsigned32} word - unsigned 32-bit integer\n* @returns {integer} lexicographically ordered integer\n*/\nfunction monotoneKey( word ) {\n\tif ( word & SIGN_MASK ) { // x < 0\n\t\treturn ( ~word + 1 ); // two's-complement negation\n\t}\n\t// x >= 0\n\treturn ( word | SIGN_MASK ) >>> 0; // push +0 to just above -0\n}\n\n\n// MAIN //\n\n/**\n* Computes the number of representable single-precision floating-point values that separate two single-precision floating-point numbers along the real number line.\n*\n* ## Notes\n*\n* - Adjacent single-precision floating-point numbers differ by 1 ulp (unit in the last place).\n* - Signed zeros differ only in the sign bit but are considered numerically equal, and thus their ULP difference is 0.\n*\n* @param {number} x - first value\n* @param {number} y - second value\n* @returns {number} result\n*\n* @example\n* import EPS from '@stdlib/constants/float32/eps';\n*\n* var d = ulpdiff( 1.0, 1.0+EPS );\n* // returns 1.0\n*\n* d = ulpdiff( 1.0+EPS, 1.0 );\n* // returns 1.0\n*\n* d = ulpdiff( 1.0, 1.0+EPS+EPS );\n* // returns 2.0\n*\n* d = ulpdiff( 1.0, NaN );\n* // returns NaN\n*\n* d = ulpdiff( NaN, 1.0 );\n* // returns NaN\n*\n* d = ulpdiff( NaN, NaN );\n* // returns NaN\n*/\nfunction ulpdiff( x, y ) {\n\tvar wx;\n\tvar wy;\n\n\tif ( isnanf( x ) || isnanf( y ) ) {\n\t\treturn NaN;\n\t}\n\t// Convert input values to unsigned 32-bit integers corresponding to the IEEE 754 binary representation of single-precision floating-point numbers:\n\twx = toWordf( x );\n\twy = toWordf( y );\n\n\t// Convert the words to lexicographically ordered integers:\n\twx = monotoneKey( wx );\n\twy = monotoneKey( wy );\n\n\t// Return a double as a result, which can exactly represent the ULP difference for all representable single-precision floating-point numbers:\n\treturn abs( wx - wy );\n}\n\n\n// EXPORTS //\n\nexport default ulpdiff;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport f32 from './../../../../../float64/base/to-float32';\nimport ulpdiff from './../../../../../float32/base/ulp-difference';\n\n\n// MAIN //\n\n/**\n* Tests if two single-precision floating-point numbers are approximately equal within a specified number of ULPs (units in the last place).\n*\n* ## Notes\n*\n* - The function returns `false` if either input value is `NaN`.\n* - The function does not distinguish between `-0` and `+0`, treating them as equal.\n*\n* @param {number} a - first input value\n* @param {number} b - second input value\n* @param {number} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating whether two single-precision floating-point numbers are approximately equal within a specified number of ULPs\n*\n* @example\n* import EPS from '@stdlib/constants/float32/eps';\n*\n* var bool = isAlmostEqualf( 1.0, 1.0+EPS, 1 );\n* // returns true\n*\n* bool = isAlmostEqualf( 1.0+EPS, 1.0, 1 );\n* // returns true\n*\n* bool = isAlmostEqualf( 1.0, 1.0+EPS+EPS, 1 );\n* // returns false\n*\n* bool = isAlmostEqualf( 1.0, 1.0+EPS, 0 );\n* // returns false\n*\n* bool = isAlmostEqualf( 0.0, -0.0, 0 );\n* // returns true\n*\n* bool = isAlmostEqualf( 1.0, NaN, 1 );\n* // returns false\n*\n* bool = isAlmostEqualf( NaN, NaN, 1 );\n* // returns false\n*/\nfunction isAlmostEqualf( a, b, maxULP ) {\n\treturn ulpdiff( f32( a ), f32( b ) ) <= maxULP;\n}\n\n\n// EXPORTS //\n\nexport default isAlmostEqualf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if a double-precision floating-point numeric value is `NaN`.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 7.0 );\n* // returns false\n*/\nfunction isnan( x ) {\n\treturn ( x !== x );\n}\n\n\n// EXPORTS //\n\nexport default isnan;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* High word mask for the sign bit of a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/high-word-sign-mask\n* @type {uinteger32}\n*\n* @example\n* import FLOAT64_HIGH_WORD_SIGN_MASK from '@stdlib/constants/float64/high-word-sign-mask';\n* // returns 2147483648\n*/\n\n\n// MAIN //\n\n/**\n* High word mask for the sign bit of a double-precision floating-point number.\n*\n* ## Notes\n*\n* The high word mask for the sign bit of a double-precision floating-point number is an unsigned 32-bit integer with the value \\\\( 2147483648 \\\\), which corresponds to the bit sequence\n*\n* ```binarystring\n* 1 00000000000 00000000000000000000\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 0x80000000\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_HIGH_WORD_SIGN_MASK = 0x80000000>>>0; // eslint-disable-line id-length\n\n\n// EXPORTS //\n\nexport default FLOAT64_HIGH_WORD_SIGN_MASK;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order.\n*\n* @module @stdlib/array/uint16\n*\n* @example\n* import ctor from '@stdlib/array/uint16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint16ArraySupport from '@stdlib/assert/has-uint16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctors from './ctors.js';\n\n\n// VARIABLES //\n\nvar bool;\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if an environment is little endian.\n*\n* @private\n* @returns {boolean} boolean indicating if an environment is little endian\n*\n* @example\n* var bool = isLittleEndian();\n* // returns \n*/\nfunction isLittleEndian() {\n\tvar uint16view;\n\tvar uint8view;\n\n\tuint16view = new ctors[ 'uint16' ]( 1 );\n\n\t/*\n\t* Set the uint16 view to a value having distinguishable lower and higher order words.\n\t*\n\t* 4660 => 0x1234 => 0x12 0x34 => '00010010 00110100' => (0x12,0x34) == (18,52)\n\t*/\n\tuint16view[ 0 ] = 0x1234;\n\n\t// Create a uint8 view on top of the uint16 buffer:\n\tuint8view = new ctors[ 'uint8' ]( uint16view.buffer );\n\n\t// If little endian, the least significant byte will be first...\n\treturn ( uint8view[ 0 ] === 0x34 );\n}\n\n\n// MAIN //\n\nbool = isLittleEndian();\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 16-bit unsigned integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint8Array from '@stdlib/array/uint8';\nimport Uint16Array from '@stdlib/array/uint16';\n\n\n// MAIN //\n\nvar ctors = {\n\t'uint16': Uint16Array,\n\t'uint8': Uint8Array\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isLittleEndian from '@stdlib/assert/is-little-endian';\n\n\n// MAIN //\n\nvar indices;\nvar HIGH;\nvar LOW;\n\nif ( isLittleEndian === true ) {\n\tHIGH = 1; // second index\n\tLOW = 0; // first index\n} else {\n\tHIGH = 0; // first index\n\tLOW = 1; // second index\n}\nindices = {\n\t'HIGH': HIGH,\n\t'LOW': LOW\n};\n\n\n// EXPORTS //\n\nexport default indices;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float64Array from '@stdlib/array/float64';\nimport indices from './indices.js';\n\n\n// VARIABLES //\n\nvar FLOAT64_VIEW = new Float64Array( 1 );\nvar UINT32_VIEW = new Uint32Array( FLOAT64_VIEW.buffer );\n\nvar HIGH = indices.HIGH;\nvar LOW = indices.LOW;\n\n\n// MAIN //\n\n/**\n* Splits a double-precision floating-point number into a higher order word (unsigned 32-bit integer) and a lower order word (unsigned 32-bit integer).\n*\n* ## Notes\n*\n* ```text\n* float64 (64 bits)\n* f := fraction (significand/mantissa) (52 bits)\n* e := exponent (11 bits)\n* s := sign bit (1 bit)\n*\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Float64 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Uint32 | Uint32 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* ```\n*\n* If little endian (more significant bits last):\n*\n* ```text\n* <-- lower higher -->\n* | f7 f6 f5 f4 f3 f2 e2 | f1 |s| e1 |\n* ```\n*\n* If big endian (more significant bits first):\n*\n* ```text\n* <-- higher lower -->\n* |s| e1 e2 | f1 f2 f3 f4 f5 f6 f7 |\n* ```\n*\n* In which Uint32 can we find the higher order bits? If little endian, the second; if big endian, the first.\n*\n* ## References\n*\n* - [Open Group][1]\n*\n* [1]: http://pubs.opengroup.org/onlinepubs/9629399/chap14.htm\n*\n* @private\n* @param {number} x - input value\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var out = new Uint32Array( 2 );\n*\n* var w = toWords( 3.14e201, out, 1, 0 );\n* // returns [ 1774486211, 2479577218 ]\n*\n* var bool = ( w === out );\n* // returns true\n*/\nfunction toWords( x, out, stride, offset ) {\n\tFLOAT64_VIEW[ 0 ] = x;\n\tout[ offset ] = UINT32_VIEW[ HIGH ];\n\tout[ offset + stride ] = UINT32_VIEW[ LOW ];\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toWords;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fcn from './assign.js';\n\n\n// MAIN //\n\n/**\n* Splits a double-precision floating-point number into a higher order word (unsigned 32-bit integer) and a lower order word (unsigned 32-bit integer).\n*\n* @param {number} x - input value\n* @returns {Array} output array\n*\n* @example\n* var w = toWords( 3.14e201 );\n* // returns [ 1774486211, 2479577218 ]\n*/\nfunction toWords( x ) {\n\treturn fcn( x, [ 0>>>0, 0>>>0 ], 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default toWords;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Split a double-precision floating-point number into a higher order word (unsigned 32-bit integer) and a lower order word (unsigned 32-bit integer).\n*\n* @module @stdlib/number/float64/base/to-words\n*\n* @example\n* import toWords from '@stdlib/number/float64/base/to-words';\n*\n* var w = toWords( 3.14e201 );\n* // returns [ 1774486211, 2479577218 ]\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n* import toWords from '@stdlib/number/float64/base/to-words';\n*\n* var out = new Uint32Array( 2 );\n*\n* var w = toWords.assign( 3.14e201, out, 1, 0 );\n* // returns [ 1774486211, 2479577218 ]\n*\n* var bool = ( w === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport SIGN_MASK from '@stdlib/constants/float64/high-word-sign-mask';\nimport { assign as toWords } from './../../../../float64/base/to-words';\nimport Uint32Array from '@stdlib/array/uint32';\n\n\n// VARIABLES //\n\nvar WX = new Uint32Array( 2 ); // WARNING: not thread safe\nvar WY = new Uint32Array( 2 );\nvar WZ = new Uint32Array( 2 );\n\n// 2^32:\nvar TWO_32 = 4294967296;\n\n\n// FUNCTIONS //\n\n/**\n* Converts the high and low words of a double-precision floating-point number to a lexicographically ordered integer.\n*\n* ## Notes\n*\n* - This function mutates the input array.\n*\n* @private\n* @param {Array} words - high and low words\n* @returns {Array} input array\n*/\nfunction monotoneKey( words ) {\n\tif ( words[ 0 ]&SIGN_MASK ) { // x < 0\n\t\twords = negate( words ); // maps -∞ to 0\n\t} else { // x >= 0\n\t\twords[ 0 ] |= SIGN_MASK; // push +0 to just above -0\n\t}\n\treturn words;\n}\n\n/**\n* Perform two's-complement negation.\n*\n* ## Notes\n*\n* - This function mutates the input array.\n*\n* @private\n* @param {Array} words - high and low words\n* @returns {Array} input array\n*/\nfunction negate( words ) {\n\twords[ 0 ] = ~words[ 0 ];\n\twords[ 1 ] = ~words[ 1 ];\n\twords[ 1 ] += 1;\n\n\t// Handle the carry into the high word...\n\tif ( words[ 1 ] === 0 ) {\n\t\twords[ 0 ] += 1;\n\t}\n\treturn words;\n}\n\n/**\n* Returns the ordering of two double-precision floating-point numbers according to their lexicographically ordered high and low words.\n*\n* @private\n* @param {Array} wa - high and low words for first value\n* @param {Array} wb - high and low words for second value\n* @returns {integer} relative ordering\n*/\nfunction compare( wa, wb ) {\n\tif ( wa[ 0 ] > wb[ 0 ] ) {\n\t\treturn 1;\n\t}\n\tif ( wa[ 0 ] < wb[ 0 ] ) {\n\t\treturn -1;\n\t}\n\tif ( wa[ 1 ] > wb[ 1 ] ) {\n\t\treturn 1;\n\t}\n\tif ( wa[ 1 ] < wb[ 1 ] ) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n\n/**\n* Performs double-word subtraction.\n*\n* @private\n* @param {Array} wa - high and low words for first value\n* @param {Array} wb - high and low words for second value\n* @param {Array} wc - output array\n* @returns {Array} output array\n*/\nfunction subtract( wa, wb, wc ) {\n\tvar ha;\n\tvar hb;\n\tvar la;\n\tvar lb;\n\n\tha = wa[ 0 ];\n\tla = wa[ 1 ];\n\thb = wb[ 0 ];\n\tlb = wb[ 1 ];\n\n\tif ( la >= lb ) {\n\t\twc[ 0 ] = ha - hb;\n\t\twc[ 1 ] = la - lb;\n\t} else {\n\t\twc[ 0 ] = ( ha - hb - 1 ); // wrap\n\t\twc[ 1 ] = ( la + TWO_32 ) - lb; // borrow\n\t}\n\treturn wc;\n}\n\n\n// MAIN //\n\n/**\n* Computes the number of representable double-precision floating-point values that separate two double-precision floating-point numbers along the real number line.\n*\n* ## Notes\n*\n* - Adjacent double-precision floating-point numbers differ by 1 ulp (unit in the last place).\n* - Signed zeros differ only in the sign bit but are considered numerically equal, and thus their ULP difference is 0.\n*\n* @param {number} x - first value\n* @param {number} y - second value\n* @returns {number} result\n*\n* @example\n* import EPS from '@stdlib/constants/float64/eps';\n*\n* var d = ulpdiff( 1.0, 1.0+EPS );\n* // returns 1.0\n*\n* d = ulpdiff( 1.0+EPS, 1.0 );\n* // returns 1.0\n*\n* d = ulpdiff( 1.0, 1.0+EPS+EPS );\n* // returns 2.0\n*\n* d = ulpdiff( 1.0, NaN );\n* // returns NaN\n*\n* d = ulpdiff( NaN, 1.0 );\n* // returns NaN\n*\n* d = ulpdiff( NaN, NaN );\n* // returns NaN\n*/\nfunction ulpdiff( x, y ) {\n\tvar ord;\n\tvar wx;\n\tvar wy;\n\tvar wz;\n\tif ( isnan( x ) || isnan( y ) ) {\n\t\treturn NaN;\n\t}\n\t// Convert input values to high and low words:\n\twx = toWords( x, WX, 1, 0 );\n\twy = toWords( y, WY, 1, 0 );\n\n\t// Convert the values to lexicographically ordered integers:\n\twx = monotoneKey( wx );\n\twy = monotoneKey( wy );\n\n\t// Determine the relative ordering of the two values so that we always subtract the smaller value from the larger value and ensure that the result is always >= 0:\n\tord = compare( wx, wy );\n\n\t// Perform subtraction...\n\tif ( ord === 0 ) {\n\t\t// Identical encoding:\n\t\treturn 0;\n\t}\n\tif ( ord === 1 ) {\n\t\twz = subtract( wx, wy, WZ );\n\t} else { // ord === -1\n\t\twz = subtract( wy, wx, WZ );\n\t}\n\t// Return a double as a result, which is fine for ≤2^53 ulps:\n\treturn ( wz[ 0 ]*TWO_32 ) + wz[ 1 ];\n}\n\n\n// EXPORTS //\n\nexport default ulpdiff;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ulpdiff from './../../../../../float64/base/ulp-difference';\n\n\n// MAIN //\n\n/**\n* Tests if two double-precision floating-point numbers are approximately equal within a specified number of ULPs (units in the last place).\n*\n* ## Notes\n*\n* - The function returns `false` if either input value is `NaN`.\n* - The function does not distinguish between `-0` and `+0`, treating them as equal.\n*\n* @param {number} a - first input value\n* @param {number} b - second input value\n* @param {number} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating whether two double-precision floating-point numbers are approximately equal within a specified number of ULPs\n*\n* @example\n* import EPS from '@stdlib/constants/float64/eps';\n*\n* var bool = isAlmostEqual( 1.0, 1.0+EPS, 1 );\n* // returns true\n*\n* bool = isAlmostEqual( 1.0+EPS, 1.0, 1 );\n* // returns true\n*\n* bool = isAlmostEqual( 1.0, 1.0+EPS+EPS, 1 );\n* // returns false\n*\n* bool = isAlmostEqual( 1.0, 1.0+EPS, 0 );\n* // returns false\n*\n* bool = isAlmostEqual( 0.0, -0.0, 0 );\n* // returns true\n*\n* bool = isAlmostEqual( 1.0, NaN, 1 );\n* // returns false\n*\n* bool = isAlmostEqual( NaN, NaN, 1 );\n* // returns false\n*/\nfunction isAlmostEqual( a, b, maxULP ) {\n\treturn ulpdiff( a, b ) <= maxULP;\n}\n\n\n// EXPORTS //\n\nexport default isAlmostEqual;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float32Array from '@stdlib/array/float32';\n\n\n// MAIN //\n\n/**\n* Returns the real and imaginary components of a single-precision complex floating-point number.\n*\n* @param {Complex64} z - complex number\n* @returns {Float32Array} real and imaginary components\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var z = new Complex64( 5.0, 3.0 );\n*\n* var out = reim( z );\n* // returns [ 5.0, 3.0 ]\n*/\nfunction reim( z ) {\n\tvar out = new Float32Array( 2 );\n\tout[ 0 ] = z.re;\n\tout[ 1 ] = z.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default reim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from '@stdlib/array/float64';\n\n\n// MAIN //\n\n/**\n* Returns the real and imaginary components of a double-precision complex floating-point number.\n*\n* @param {Complex128} z - complex number\n* @returns {Float64Array} real and imaginary components\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z = new Complex128( 5.0, 3.0 );\n*\n* var out = reim( z );\n* // returns [ 5.0, 3.0 ]\n*/\nfunction reim( z ) {\n\tvar out = new Float64Array( 2 );\n\tout[ 0 ] = z.re;\n\tout[ 1 ] = z.im;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default reim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAlmostEqualComplex64 from '@stdlib/complex/float32/base/assert/is-almost-equal';\nimport isAlmostEqualComplex128 from '@stdlib/complex/float64/base/assert/is-almost-equal';\nimport { isPrimitive as isNumber } from './../../is-number';\nimport isAlmostEqualF64 from '@stdlib/number/float64/base/assert/is-almost-equal';\nimport isComplexLike from './../../is-complex-like';\n\n\n// MAIN //\n\n/**\n* Tests if two arguments are approximately equal within a specified number of ULPs (units in the last place).\n*\n* ## Notes\n*\n* - The function returns `false` if either input value is `NaN` or, in the case of complex numbers, if either the real or imaginary component is `NaN`.\n* - The function does not distinguish between `-0` and `+0`, treating them as equal.\n*\n* @param {*} a - first input value\n* @param {*} b - second input value\n* @param {NonNegativeInteger} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating whether two arguments are approximately equal within a specified number of ULPs\n*\n* @example\n* import EPS from '@stdlib/constants/float64/eps';\n*\n* var bool = isAlmostEqual( 1.0, 1.0+EPS, 0 );\n* // returns false\n*\n* bool = isAlmostEqual( 1.0, 1.0+EPS, 1 );\n* // returns true\n*\n* bool = isAlmostEqual( {}, {}, 0 );\n* // returns false\n*\n* bool = isAlmostEqual( -0.0, 0.0, 0 );\n* // returns true\n*\n* bool = isAlmostEqual( NaN, NaN, 0 );\n* // returns false\n*\n* bool = isAlmostEqual( [], [], 1 );\n* // returns false\n*/\nfunction isAlmostEqual( a, b, maxULP ) {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\tif ( isNumber( a ) && isNumber( b ) ) {\n\t\treturn isAlmostEqualF64( a, b, maxULP );\n\t}\n\tif ( isComplexLike( a ) && isComplexLike( b ) ) {\n\t\tif ( a.BYTES_PER_ELEMENT === 4 && b.BYTES_PER_ELEMENT === 4 ) {\n\t\t\treturn isAlmostEqualComplex64( a, b, maxULP );\n\t\t}\n\t\treturn isAlmostEqualComplex128( a, b, maxULP );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isAlmostEqual;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAlmostEqualF32 from '@stdlib/number/float32/base/assert/is-almost-equal';\nimport reimf from './../../../../../float32/reim';\n\n\n// MAIN //\n\n/**\n* Tests whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs (units in the last place).\n*\n* ## Notes\n*\n* - The function returns `false` if either input value has a `NaN` real or imaginary component.\n* - The function does not distinguish between `-0` and `+0`, treating them as equal.\n*\n* @param {Complex64} z1 - first complex number\n* @param {Complex64} z2 - second complex number\n* @param {number} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating whether two single-precision complex floating-point numbers are approximately equal within a specified number of ULPs\n*\n* @example\n* import EPS from '@stdlib/constants/float32/eps';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var z1 = new Complex64( 1.0, 3.0 );\n* var z2 = new Complex64( 1.0+EPS, 3.0 );\n*\n* var bool = isAlmostEqualf( z1, z2, 0 );\n* // returns false\n*\n* bool = isAlmostEqualf( z1, z2, 1 );\n* // returns true\n*/\nfunction isAlmostEqualf( z1, z2, maxULP ) {\n\tvar parts1 = reimf( z1 );\n\tvar parts2 = reimf( z2 );\n\treturn (\n\t\tisAlmostEqualF32( parts1[ 0 ], parts2[ 0 ], maxULP ) &&\n\t\tisAlmostEqualF32( parts1[ 1 ], parts2[ 1 ], maxULP )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isAlmostEqualf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAlmostEqualF64 from '@stdlib/number/float64/base/assert/is-almost-equal';\nimport reim from './../../../../../float64/reim';\n\n\n// MAIN //\n\n/**\n* Tests whether two double-precision complex floating-point numbers are approximately equal within a specified number of ULPs (units in the last place).\n*\n* ## Notes\n*\n* - The function returns `false` if either input value has a `NaN` real or imaginary component.\n* - The function does not distinguish between `-0` and `+0`, treating them as equal.\n*\n* @param {Complex128} z1 - first complex number\n* @param {Complex128} z2 - second complex number\n* @param {number} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating whether two double-precision complex floating-point numbers are approximately equal within a specified number of ULPs\n*\n* @example\n* import EPS from '@stdlib/constants/float64/eps';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z1 = new Complex128( 1.0, 3.0 );\n* var z2 = new Complex128( 1.0+EPS, 3.0 );\n*\n* var bool = isAlmostEqual( z1, z2, 0 );\n* // returns false\n*\n* bool = isAlmostEqual( z1, z2, 1 );\n* // returns true\n*/\nfunction isAlmostEqual( z1, z2, maxULP ) {\n\tvar parts1 = reim( z1 );\n\tvar parts2 = reim( z2 );\n\treturn (\n\t\tisAlmostEqualF64( parts1[ 0 ], parts2[ 0 ], maxULP ) &&\n\t\tisAlmostEqualF64( parts1[ 1 ], parts2[ 1 ], maxULP )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isAlmostEqual;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isAlmostEqualF32 from '@stdlib/number/float32/base/assert/is-almost-equal';\nimport isAlmostEqualF64 from '@stdlib/number/float64/base/assert/is-almost-equal';\nimport isAlmostEqual from '@stdlib/assert/is-almost-equal';\n\n\n// FUNCTIONS //\n\n/**\n* Tests if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place).\n*\n* @private\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {NonNegativeInteger} maxULP - maximum allowed ULP difference\n* @param {Function} fcn - function which tests approximate equality\n* @returns {boolean} boolean indicating if both arrays have respective elements which are approximately equal\n*\n* @example\n* import base from '@stdlib/number/float64/base/assert/is-almost-equal';\n*\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y, 1, base );\n* // returns true\n*\n* @example\n* import base from '@stdlib/number/float64/base/assert/is-almost-equal';\n*\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y, 1, base );\n* // returns false\n*/\nfunction internal( x, y, maxULP, fcn ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !fcn( x[ i ], y[ i ], maxULP ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place).\n*\n* @private\n* @param {Object} x - first input array object\n* @param {Object} y - second input array object\n* @param {NonNegativeInteger} maxULP - maximum allowed ULP difference\n* @param {Function} fcn - function which tests approximate equality\n* @returns {boolean} boolean indicating if both arrays have respective elements which are approximately equal\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import assert from '@stdlib/assert/is-almost-equal';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y, 0, assert );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import assert from '@stdlib/assert/is-almost-equal';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y, 1, assert );\n* // returns false\n*/\nfunction accessors( x, y, maxULP, fcn ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yget;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyget = y.accessors[ 0 ];\n\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( !fcn( xget( xdata, i ), yget( ydata, i ), maxULP ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests if two arrays have respective elements which are approximately equal within a specified number of ULPs (units in the last place).\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {NonNegativeInteger} maxULP - maximum allowed ULP difference\n* @returns {boolean} boolean indicating if both arrays have respective elements which are approximately equal\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasAlmostEqualValues( x, y, 0 );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasAlmostEqualValues( x, y, 1 );\n* // returns false\n*/\nfunction hasAlmostEqualValues( x, y, maxULP ) {\n\tvar FLG;\n\tvar xo;\n\tvar yo;\n\tvar xr;\n\tvar yr;\n\n\tif ( x.length !== y.length ) {\n\t\treturn false;\n\t}\n\txo = arraylike2object( x );\n\tyo = arraylike2object( y );\n\tif ( xo.accessorProtocol || yo.accessorProtocol ) {\n\t\tFLG = 2;\n\n\t\t// If provided boolean arrays, reinterpret the arrays to avoid using accessors to access array elements...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\tif ( isBooleanArray( y ) ) {\n\t\t\t\treturn internal( reinterpretBoolean( x, 0 ), reinterpretBoolean( y, 0 ), maxULP, isAlmostEqualF64 ); // eslint-disable-line max-len\n\t\t\t}\n\t\t\treturn accessors( xo, yo, maxULP, isAlmostEqual ); // general accessors should always use general comparison\n\t\t}\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\txr = reinterpret128( x, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\txr = reinterpret64( x, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( isComplex128Array( y ) ) {\n\t\t\tyr = reinterpret128( y, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( y ) ) {\n\t\t\tyr = reinterpret64( y, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( FLG === 0 ) {\n\t\t\t// Determine whether we should use double-precision or single-precision comparison...\n\t\t\tif ( xr.BYTES_PER_ELEMENT === 8 || yr.BYTES_PER_ELEMENT === 8 ) {\n\t\t\t\treturn internal( xr, yr, maxULP, isAlmostEqualF64 );\n\t\t\t}\n\t\t\treturn internal( xr, yr, maxULP, isAlmostEqualF32 );\n\t\t}\n\t\treturn accessors( xo, yo, maxULP, isAlmostEqual ); // general accessors should always use general comparison\n\t}\n\t// Determine whether we should use double-precision or single-precision comparison...\n\tif ( x.BYTES_PER_ELEMENT === 4 && y.BYTES_PER_ELEMENT === 4 ) {\n\t\treturn internal( x, y, maxULP, isAlmostEqualF32 );\n\t}\n\treturn internal( x, y, maxULP, isAlmostEqual ); // default to general comparison\n}\n\n\n// EXPORTS //\n\nexport default hasAlmostEqualValues;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Tests if two arrays have equal values.\n*\n* @private\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @returns {boolean} boolean indicating if both arrays have equal values\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y );\n* // returns false\n*/\nfunction internal( x, y ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( x[ i ] !== y[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests if two arrays have equal values.\n*\n* @private\n* @param {Object} x - first input array object\n* @param {Object} y - second input array object\n* @returns {boolean} boolean indicating if both arrays have equal values\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y );\n* // returns false\n*/\nfunction accessors( x, y ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yget;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyget = y.accessors[ 0 ];\n\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( xget( xdata, i ) !== yget( ydata, i ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests if two arrays have equal values.\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @returns {boolean} boolean indicating if both arrays have equal values\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasEqualValues( x, y );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasEqualValues( x, y );\n* // returns false\n*/\nfunction hasEqualValues( x, y ) {\n\tvar FLG;\n\tvar xo;\n\tvar yo;\n\tvar xr;\n\tvar yr;\n\n\tif ( x.length !== y.length ) {\n\t\treturn false;\n\t}\n\txo = arraylike2object( x );\n\tyo = arraylike2object( y );\n\tif ( xo.accessorProtocol || yo.accessorProtocol ) {\n\t\tFLG = 2;\n\n\t\t// If provided boolean arrays, reinterpret the arrays to avoid using accessors to access array elements...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\tif ( isBooleanArray( y ) ) {\n\t\t\t\treturn internal( reinterpretBoolean( x, 0 ), reinterpretBoolean( y, 0 ) ); // eslint-disable-line max-len\n\t\t\t}\n\t\t\treturn accessors( xo, yo );\n\t\t}\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\txr = reinterpret128( x, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\txr = reinterpret64( x, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( isComplex128Array( y ) ) {\n\t\t\tyr = reinterpret128( y, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( y ) ) {\n\t\t\tyr = reinterpret64( y, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( FLG === 0 ) {\n\t\t\treturn internal( xr, yr );\n\t\t}\n\t\treturn accessors( xo, yo );\n\t}\n\treturn internal( x, y );\n}\n\n\n// EXPORTS //\n\nexport default hasEqualValues;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if two double-precision floating-point numbers are the same value.\n*\n* ## Notes\n*\n* - The function implements the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {number} a - first input value\n* @param {number} b - second input value\n* @returns {boolean} boolean indicating whether two double-precision floating-point numbers are the same value\n*\n* @example\n* var bool = isSameValue( 3.14, 3.14 );\n* // returns true\n*\n* @example\n* var bool = isSameValue( -0.0, -0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValue( -0.0, 0.0 );\n* // returns false\n*\n* @example\n* var bool = isSameValue( NaN, NaN );\n* // returns true\n*/\nfunction isSameValue( a, b ) {\n\tif ( a === b ) {\n\t\tif ( a === 0.0 ) {\n\t\t\treturn 1.0 / a === 1.0 / b; // handles +-0\n\t\t}\n\t\treturn true;\n\t}\n\treturn ( a !== a && b !== b ); // handles NaNs\n}\n\n\n// EXPORTS //\n\nexport default isSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isSameComplexValue from '@stdlib/complex/float64/base/assert/is-same-value';\nimport isComplexLike from './../../is-complex-like';\n\n\n// MAIN //\n\n/**\n* Tests if two arguments are the same value.\n*\n* ## Notes\n*\n* - The function implements the [SameValue Algorithm][ecma-262-same-value-algorithm] (as specified in ECMAScript 5), with support for complex number objects.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {*} a - first input value\n* @param {*} b - second input value\n* @returns {boolean} boolean indicating whether two arguments are the same value\n*\n* @example\n* var bool = isSameValue( true, true );\n* // returns true\n*\n* @example\n* var bool = isSameValue( 3.14, 3.14 );\n* // returns true\n*\n* @example\n* var bool = isSameValue( {}, {} );\n* // returns false\n*\n* @example\n* var bool = isSameValue( -0.0, -0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValue( -0.0, 0.0 );\n* // returns false\n*\n* @example\n* var bool = isSameValue( NaN, NaN );\n* // returns true\n*\n* @example\n* var bool = isSameValue( [], [] );\n* // returns false\n*/\nfunction isSameValue( a, b ) {\n\tif ( a === b ) {\n\t\tif ( a === 0.0 ) {\n\t\t\treturn 1.0 / a === 1.0 / b; // handles +-0\n\t\t}\n\t\treturn true;\n\t}\n\tif ( a !== a && b !== b ) { // handles NaNs\n\t\treturn true;\n\t}\n\tif ( isComplexLike( a ) && isComplexLike( b ) ) {\n\t\treturn isSameComplexValue( a, b );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isSame from '@stdlib/number/float64/base/assert/is-same-value';\nimport reim from './../../../../../float64/reim';\n\n\n// MAIN //\n\n/**\n* Tests whether two double-precision complex floating-point numbers are the same value.\n*\n* ## Notes\n*\n* - The function implements the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {Complex128} z1 - first complex number\n* @param {Complex128} z2 - second complex number\n* @returns {boolean} result\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z1 = new Complex128( 5.0, 3.0 );\n* var z2 = new Complex128( 5.0, 3.0 );\n*\n* var v = isSameValue( z1, z2 );\n* // returns true\n*/\nfunction isSameValue( z1, z2 ) {\n\tvar parts1 = reim( z1 );\n\tvar parts2 = reim( z2 );\n\treturn (\n\t\tisSame( parts1[ 0 ], parts2[ 0 ] ) &&\n\t\tisSame( parts1[ 1 ], parts2[ 1 ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isSameValue from '@stdlib/assert/is-same-value';\n\n\n// FUNCTIONS //\n\n/**\n* Tests if two arrays have the same values.\n*\n* @private\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @returns {boolean} boolean indicating if both arrays have the same values\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, y );\n* // returns false\n*/\nfunction internal( x, y ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !isSameValue( x[ i ], y[ i ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests if two arrays have the same values.\n*\n* @private\n* @param {Object} x - first input array object\n* @param {Object} y - second input array object\n* @returns {boolean} boolean indicating if both arrays have the same values\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n* var y = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, y );\n* // returns false\n*/\nfunction accessors( x, y ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yget;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyget = y.accessors[ 0 ];\n\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( !isSameValue( xget( xdata, i ), yget( ydata, i ) ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests if two arrays have the same values.\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @returns {boolean} boolean indicating if both arrays have the same values\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasSameValues( x, y );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasSameValues( x, y );\n* // returns false\n*/\nfunction hasSameValues( x, y ) {\n\tvar FLG;\n\tvar xo;\n\tvar yo;\n\tvar xr;\n\tvar yr;\n\n\tif ( x.length !== y.length ) {\n\t\treturn false;\n\t}\n\txo = arraylike2object( x );\n\tyo = arraylike2object( y );\n\tif ( xo.accessorProtocol || yo.accessorProtocol ) {\n\t\tFLG = 2;\n\n\t\t// If provided boolean arrays, reinterpret the arrays to avoid using accessors to access array elements...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\tif ( isBooleanArray( y ) ) {\n\t\t\t\treturn internal( reinterpretBoolean( x, 0 ), reinterpretBoolean( y, 0 ) );\n\t\t\t}\n\t\t\treturn accessors( xo, yo );\n\t\t}\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\txr = reinterpret128( x, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\txr = reinterpret64( x, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( isComplex128Array( y ) ) {\n\t\t\tyr = reinterpret128( y, 0 );\n\t\t\tFLG -= 1;\n\t\t} else if ( isComplex64Array( y ) ) {\n\t\t\tyr = reinterpret64( y, 0 );\n\t\t\tFLG -= 1;\n\t\t}\n\t\tif ( FLG === 0 ) {\n\t\t\treturn internal( xr, yr );\n\t\t}\n\t\treturn accessors( xo, yo );\n\t}\n\treturn internal( x, y );\n}\n\n\n// EXPORTS //\n\nexport default hasSameValues;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Replaces search occurrences with a replacement string.\n*\n* @param {string} str - input string\n* @param {RegExp} search - search expression\n* @param {(string|Function)} newval - replacement value or function\n* @returns {string} new string containing replacement(s)\n*\n* @example\n* var str = 'Hello World';\n* var out = replace( str, /world/i, 'Mr. President' );\n* // returns 'Hello Mr. President'\n*\n* @example\n* import capitalize from '@stdlib/string/base/capitalize';\n*\n* var str = 'Oranges and lemons say the bells of St. Clement\\'s';\n*\n* function replacer( match, p1 ) {\n* return capitalize( p1 );\n* }\n*\n* var out = replace( str, /([^\\s]*)/gi, replacer );\n* // returns 'Oranges And Lemons Say The Bells Of St. Clement\\'s'\n*/\nfunction replace( str, search, newval ) {\n\treturn str.replace( search, newval );\n}\n\n\n// EXPORTS //\n\nexport default replace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string/base/replace';\nimport DTYPES from './dtypes.json';\n\n\n// VARIABLES //\n\nvar RE_SUFFIX = /_and_generic$/;\n\n\n// MAIN //\n\n/**\n* Returns a list of array data types.\n*\n* @param {string} [kind] - data type kind\n* @returns {StringArray} list of array data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'float32', 'float64', ... ]\n*\n* @example\n* var list = dtypes( 'floating_point' );\n* // returns [...]\n*/\nfunction dtypes() {\n\tvar kind;\n\tvar out;\n\tvar FLG;\n\tif ( arguments.length === 0 ) {\n\t\treturn DTYPES.all.slice();\n\t}\n\tFLG = false;\n\tkind = arguments[ 0 ];\n\tif ( RE_SUFFIX.test( kind ) ) {\n\t\tkind = replace( kind, RE_SUFFIX, '' );\n\t\tif ( kind !== 'all' && kind !== 'index' ) {\n\t\t\tFLG = true;\n\t\t}\n\t}\n\tout = DTYPES[ kind ];\n\tout = ( out ) ? out.slice() : [];\n\tif ( FLG && out.length > 0 ) {\n\t\tout.push( 'generic' );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array boolean data type.\n*\n* @name isBooleanDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array boolean data type\n*\n* @example\n* var bool = isBooleanDataType( 'bool' );\n* // returns true\n*\n* bool = isBooleanDataType( 'complex64' );\n* // returns false\n*\n* bool = isBooleanDataType( 'complex128' );\n* // returns false\n*\n* bool = isBooleanDataType( 'float32' );\n* // returns false\n*\n* bool = isBooleanDataType( 'float64' );\n* // returns false\n*\n* bool = isBooleanDataType( 'generic' );\n* // returns false\n*\n* bool = isBooleanDataType( 'int16' );\n* // returns false\n*\n* bool = isBooleanDataType( 'int32' );\n* // returns false\n*\n* bool = isBooleanDataType( 'int8' );\n* // returns false\n*\n* bool = isBooleanDataType( 'uint16' );\n* // returns false\n*\n* bool = isBooleanDataType( 'uint32' );\n* // returns false\n*\n* bool = isBooleanDataType( 'uint8' );\n* // returns false\n*\n* bool = isBooleanDataType( 'uint8c' );\n* // returns false\n*\n* bool = isBooleanDataType( 'foo' );\n* // returns false\n*/\nvar isBooleanDataType = contains( dtypes( 'boolean' ) );\n\n\n// EXPORTS //\n\nexport default isBooleanDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ORDERS from './orders.json';\n\n\n// MAIN //\n\n/**\n* Returns a list of byte orders.\n*\n* @returns {StringArray} list of byte orders\n*\n* @example\n* var list = orders();\n* // e.g., returns [ 'little-endian', 'big-endian' ]\n*/\nfunction orders() {\n\treturn ORDERS.slice();\n}\n\n\n// EXPORTS //\n\nexport default orders;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport byteOrders from './../../../../byte-orders';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array byte order.\n*\n* @name isByteOrder\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array byte order\n*\n* @example\n* var bool = isByteOrder( 'little-endian' );\n* // returns true\n*\n* bool = isByteOrder( 'big-endian' );\n* // returns true\n*\n* bool = isByteOrder( 'foo' );\n* // returns false\n*/\nvar isByteOrder = contains( byteOrders() );\n\n\n// EXPORTS //\n\nexport default isByteOrder;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array complex-valued floating-point data type.\n*\n* @name isComplexFloatingPointDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array complex-valued floating-point data type\n*\n* @example\n* var bool = isComplexFloatingPointDataType( 'complex64' );\n* // returns true\n*\n* bool = isComplexFloatingPointDataType( 'complex128' );\n* // returns true\n*\n* bool = isComplexFloatingPointDataType( 'float32' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'float64' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'generic' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'int16' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'int32' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'int8' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'uint16' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'uint32' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'uint8' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'uint8c' );\n* // returns false\n*\n* bool = isComplexFloatingPointDataType( 'foo' );\n* // returns false\n*/\nvar isComplexFloatingPointDataType = contains( dtypes( 'complex_floating_point' ) ); // eslint-disable-line id-length\n\n\n// EXPORTS //\n\nexport default isComplexFloatingPointDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar C64_BYTES_PER_ELEMENT = 8; // 4 bytes per float32 x (1 real + 1 imag component)\nvar C128_BYTES_PER_ELEMENT = 16; // 8 bytes per float64 x (1 real + 1 imag component)\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a complex typed array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isComplexTypedArray( new Complex128Array( 10 ) );\n* // returns true\n*\n* bool = isComplexTypedArray( [] );\n* // returns false\n*/\nfunction isComplexTypedArray( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex128Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex-typed-array`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t(\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex128Array' &&\n\t\t\t\tvalue.BYTES_PER_ELEMENT === C128_BYTES_PER_ELEMENT\n\t\t\t) ||\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex64Array' &&\n\t\t\t\tvalue.BYTES_PER_ELEMENT === C64_BYTES_PER_ELEMENT\n\t\t\t)\n\t\t)\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplexTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array data type.\n*\n* @name isDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array data type\n*\n* @example\n* var bool = isDataType( 'float32' );\n* // returns true\n*\n* bool = isDataType( 'float64' );\n* // returns true\n*\n* bool = isDataType( 'generic' );\n* // returns true\n*\n* bool = isDataType( 'int16' );\n* // returns true\n*\n* bool = isDataType( 'int32' );\n* // returns true\n*\n* bool = isDataType( 'int8' );\n* // returns true\n*\n* bool = isDataType( 'uint16' );\n* // returns true\n*\n* bool = isDataType( 'uint32' );\n* // returns true\n*\n* bool = isDataType( 'uint8' );\n* // returns true\n*\n* bool = isDataType( 'uint8c' );\n* // returns true\n*\n* bool = isDataType( 'foo' );\n* // returns false\n*/\nvar isDataType = contains( dtypes() );\n\n\n// EXPORTS //\n\nexport default isDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array floating-point data type.\n*\n* @name isFloatingPointDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array floating-point data type\n*\n* @example\n* var bool = isFloatingPointDataType( 'float32' );\n* // returns true\n*\n* bool = isFloatingPointDataType( 'float64' );\n* // returns true\n*\n* bool = isFloatingPointDataType( 'generic' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'int16' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'int32' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'int8' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'uint16' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'uint32' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'uint8' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'uint8c' );\n* // returns false\n*\n* bool = isFloatingPointDataType( 'foo' );\n* // returns false\n*/\nvar isFloatingPointDataType = contains( dtypes( 'floating_point' ) );\n\n\n// EXPORTS //\n\nexport default isFloatingPointDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array integer data type.\n*\n* @name isIntegerDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array integer data type\n*\n* @example\n* var bool = isIntegerDataType( 'float32' );\n* // returns false\n*\n* bool = isIntegerDataType( 'float64' );\n* // returns false\n*\n* bool = isIntegerDataType( 'generic' );\n* // returns false\n*\n* bool = isIntegerDataType( 'int16' );\n* // returns true\n*\n* bool = isIntegerDataType( 'int32' );\n* // returns true\n*\n* bool = isIntegerDataType( 'int8' );\n* // returns true\n*\n* bool = isIntegerDataType( 'uint16' );\n* // returns true\n*\n* bool = isIntegerDataType( 'uint32' );\n* // returns true\n*\n* bool = isIntegerDataType( 'uint8' );\n* // returns true\n*\n* bool = isIntegerDataType( 'uint8c' );\n* // returns true\n*\n* bool = isIntegerDataType( 'foo' );\n* // returns false\n*/\nvar isIntegerDataType = contains( dtypes( 'integer' ) );\n\n\n// EXPORTS //\n\nexport default isIntegerDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of an object's own enumerable property names.\n*\n* ## Notes\n*\n* - In contrast to the built-in `Object.keys()`, this function returns an empty array if provided `undefined` or `null`, rather than throwing an error.\n*\n* @private\n* @param {*} value - input object\n* @returns {Array} a list of own enumerable property names\n*\n* @example\n* var obj = {\n* 'beep': 'boop',\n* 'foo': 3.14\n* };\n*\n* var k = keys( obj );\n* // e.g., returns [ 'beep', 'foo' ]\n*/\nfunction keys( value ) {\n\treturn Object.keys( Object( value ) );\n}\n\n\n// EXPORTS //\n\nexport default keys;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar bool = ( typeof Object.keys !== 'undefined' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArguments from './main.js';\n\n\n// VARIABLES //\n\nvar bool;\n\n\n// FUNCTIONS //\n\n/**\n* Detects whether an environment returns the expected internal class of the `arguments` object.\n*\n* @private\n* @returns {boolean} boolean indicating whether an environment behaves as expected\n*\n* @example\n* var bool = detect();\n* // returns \n*/\nfunction detect() {\n\treturn isArguments( arguments );\n}\n\n\n// MAIN //\n\nbool = detect();\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// MAIN //\n\n/**\n* Tests whether a value is an `arguments` object.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is an `arguments` object\n*\n* @example\n* function foo() {\n* return arguments;\n* }\n*\n* var bool = isArguments( foo() );\n* // returns true\n*\n* @example\n* var bool = isArguments( [] );\n* // returns false\n*/\nfunction isArguments( value ) {\n\treturn ( nativeClass( value ) === '[object Arguments]' );\n}\n\n\n// EXPORTS //\n\nexport default isArguments;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from './../../is-number';\nimport isNan from '@stdlib/math/base/assert/is-nan';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a `NaN` number primitive.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `NaN` number primitive\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( 3.14 );\n* // returns false\n*\n* @example\n* var bool = isnan( new Number( NaN ) );\n* // returns false\n*/\nfunction isnan( value ) {\n\treturn (\n\t\tisNumber( value ) &&\n\t\tisNan( value )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isnan;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isObject as isNumber } from './../../is-number';\nimport isNan from '@stdlib/math/base/assert/is-nan';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a number object having a value of `NaN`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a number object having a value of `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns false\n*\n* @example\n* var bool = isnan( new Number( NaN ) );\n* // returns true\n*/\nfunction isnan( value ) {\n\treturn (\n\t\tisNumber( value ) &&\n\t\tisNan( value.valueOf() )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isnan;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\n/**\n* Tests if a value is `NaN`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is `NaN`\n*\n* @example\n* var bool = isnan( NaN );\n* // returns true\n*\n* @example\n* var bool = isnan( new Number( NaN ) );\n* // returns true\n*\n* @example\n* var bool = isnan( 3.14 );\n* // returns false\n*\n* @example\n* var bool = isnan( null );\n* // returns false\n*/\nfunction isnan( value ) {\n\treturn ( isPrimitive( value ) || isObject( value ) );\n}\n\n\n// EXPORTS //\n\nexport default isnan;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is `NaN`.\n*\n* @module @stdlib/assert/is-nan\n*\n* @example\n* import isnan from '@stdlib/assert/is-nan';\n*\n* var bool = isnan( NaN );\n* // returns true\n*\n* bool = isnan( new Number( NaN ) );\n* // returns true\n*\n* bool = isnan( 3.14 );\n* // returns false\n*\n* bool = isnan( null );\n* // returns false\n*\n* @example\n* import { isPrimitive as isnan } from '@stdlib/assert/is-nan';\n*\n* var bool = isnan( NaN );\n* // returns true\n*\n* bool = isnan( 3.14 );\n* // returns false\n*\n* bool = isnan( new Number( NaN ) );\n* // returns false\n*\n* @example\n* import { isObject as isnan } from '@stdlib/assert/is-nan';\n*\n* var bool = isnan( NaN );\n* // returns false\n*\n* bool = isnan( new Number( NaN ) );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport isPrimitive from './primitive.js';\nimport isObject from './object.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'isPrimitive', isPrimitive );\nsetReadOnly( main, 'isObject', isObject );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if an object's own property is enumerable.\n*\n* @private\n* @name isEnumerableProperty\n* @type {Function}\n* @param {*} value - value to test\n* @param {*} property - property to test\n* @returns {boolean} boolean indicating if an object property is enumerable\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = isEnumerableProperty( beep, 'boop' );\n* // returns true\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = isEnumerableProperty( beep, 'hasOwnProperty' );\n* // returns false\n*/\nvar isEnumerableProperty = Object.prototype.propertyIsEnumerable;\n\n\n// EXPORTS //\n\nexport default isEnumerableProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isEnum from './native.js';\n\n\n// VARIABLES //\n\nvar bool;\n\n\n// FUNCTIONS //\n\n/**\n* Detects whether an environment has a bug where String indices are not detected as \"enumerable\" properties. Observed in Node v0.10.\n*\n* @private\n* @returns {boolean} boolean indicating whether an environment has the bug\n*/\nfunction detect() {\n\treturn !isEnum.call( 'beep', '0' );\n}\n\n\n// MAIN //\n\nbool = detect();\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isString from './../../is-string';\nimport { isPrimitive as isnan } from './../../is-nan';\nimport { isPrimitive as isInteger } from './../../is-integer';\nimport isEnum from './native.js';\nimport hasStringEnumBug from './has_string_enumerability_bug.js';\n\n\n// MAIN //\n\n/**\n* Tests if an object's own property is enumerable.\n*\n* @param {*} value - value to test\n* @param {*} property - property to test\n* @returns {boolean} boolean indicating if an object property is enumerable\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = isEnumerableProperty( beep, 'boop' );\n* // returns true\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = isEnumerableProperty( beep, 'hasOwnProperty' );\n* // returns false\n*/\nfunction isEnumerableProperty( value, property ) {\n\tvar bool;\n\tif (\n\t\tvalue === void 0 ||\n\t\tvalue === null\n\t) {\n\t\treturn false;\n\t}\n\tbool = isEnum.call( value, property );\n\tif ( !bool && hasStringEnumBug && isString( value ) ) {\n\t\t// Note: we only check for indices, as properties attached to a `String` object are properly detected as enumerable above.\n\t\tproperty = +property;\n\t\treturn (\n\t\t\t!isnan( property ) &&\n\t\t\tisInteger( property ) &&\n\t\t\tproperty >= 0 &&\n\t\t\tproperty < value.length\n\t\t);\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default isEnumerableProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a value is an `arguments` object.\n*\n* @module @stdlib/assert/is-arguments\n*\n* @example\n* import isArguments from '@stdlib/assert/is-arguments';\n*\n* function foo() {\n* return arguments;\n* }\n*\n* var bool = isArguments( foo() );\n* // returns true\n*\n* bool = isArguments( [] );\n* // returns false\n*/\n\n// MODULES //\n\nimport hasArgumentsClass from './detect.js';\nimport main from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar isArguments;\nif ( hasArgumentsClass ) {\n\tisArguments = main;\n} else {\n\tisArguments = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default isArguments;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasOwnProp from './../../has-own-property';\nimport isEnumerableProperty from './../../is-enumerable-property';\nimport isArray from './../../is-array';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport MAX_LENGTH from '@stdlib/constants/uint32/max';\n\n\n// MAIN //\n\n/**\n* Tests whether a value is an `arguments` object.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is an `arguments` object\n*\n* @example\n* function foo() {\n* return arguments;\n* }\n*\n* var bool = isArguments( foo() );\n* // returns true\n*\n* @example\n* var bool = isArguments( [] );\n* // returns false\n*/\nfunction isArguments( value ) {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === 'object' &&\n\t\t!isArray( value ) &&\n\t\ttypeof value.length === 'number' &&\n\t\tisInteger( value.length ) &&\n\t\tvalue.length >= 0 &&\n\t\tvalue.length <= MAX_LENGTH &&\n\t\thasOwnProp( value, 'callee' ) &&\n\t\t!isEnumerableProperty( value, 'callee' )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isArguments;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArguments from '@stdlib/assert/is-arguments';\nimport builtin from './builtin.js';\n\n\n// VARIABLES //\n\nvar slice = Array.prototype.slice;\n\n\n// MAIN //\n\n/**\n* Returns an array of an object's own enumerable property names.\n*\n* @private\n* @param {*} value - input object\n* @returns {Array} a list of own enumerable property names\n*\n* @example\n* var obj = {\n* 'beep': 'boop',\n* 'foo': 3.14\n* };\n*\n* var k = keys( obj );\n* // e.g., returns [ 'beep', 'foo' ]\n*/\nfunction keys( value ) {\n\tif ( isArguments( value ) ) {\n\t\treturn builtin( slice.call( value ) );\n\t}\n\treturn builtin( value );\n}\n\n\n// EXPORTS //\n\nexport default keys;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isEnumerableProperty from '@stdlib/assert/is-enumerable-property';\nimport noop from './../../noop';\n\n\n// MAIN //\n\n// Note: certain environments treat an object's prototype as enumerable, which, as a matter of convention, it shouldn't be...\nvar bool = isEnumerableProperty( noop, 'prototype' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* No operation.\n*\n* @example\n* noop();\n* // ...does nothing.\n*/\nfunction noop() {\n\t// Empty function...\n}\n\n\n// EXPORTS //\n\nexport default noop;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isEnumerableProperty from '@stdlib/assert/is-enumerable-property';\n\n\n// VARIABLES //\n\nvar obj = {\n\t'toString': null\n};\n\n\n// MAIN //\n\n// Note: certain environments don't allow enumeration of overwritten properties which are considered non-enumerable...\nvar bool = !isEnumerableProperty( obj, 'toString' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from '@stdlib/assert/is-nan';\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @param {ArrayLike} arr - array-like object\n* @param {*} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (if negative, the start index is determined relative to last element)\n* @throws {TypeError} must provide an array-like object\n* @throws {TypeError} third argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = [ 4, 3, 2, 1 ];\n* var idx = indexOf( arr, 3 );\n* // returns 1\n*\n* @example\n* var arr = [ 4, 3, 2, 1 ];\n* var idx = indexOf( arr, 5 );\n* // returns -1\n*\n* @example\n* // Using a `fromIndex`:\n* var arr = [ 1, 2, 3, 4, 5, 2, 6 ];\n* var idx = indexOf( arr, 2, 3 );\n* // returns 5\n*\n* @example\n* // `fromIndex` which exceeds `array` length:\n* var arr = [ 1, 2, 3, 4, 2, 5 ];\n* var idx = indexOf( arr, 2, 10 );\n* // returns -1\n*\n* @example\n* // Negative `fromIndex`:\n* var arr = [ 1, 2, 3, 4, 5, 2, 6, 2 ];\n* var idx = indexOf( arr, 2, -4 );\n* // returns 5\n*\n* idx = indexOf( arr, 2, -1 );\n* // returns 7\n*\n* @example\n* // Negative `fromIndex` exceeding input `array` length:\n* var arr = [ 1, 2, 3, 4, 5, 2, 6 ];\n* var idx = indexOf( arr, 2, -10 );\n* // returns 1\n*\n* @example\n* // Array-like objects:\n* var str = 'bebop';\n* var idx = indexOf( str, 'o' );\n* // returns 3\n*/\nfunction indexOf( arr, searchElement, fromIndex ) {\n\tvar len;\n\tvar i;\n\tif ( !isCollection( arr ) && !isString( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', arr ) );\n\t}\n\tlen = arr.length;\n\tif ( len === 0 ) {\n\t\treturn -1;\n\t}\n\tif ( arguments.length === 3 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= 0 ) {\n\t\t\tif ( fromIndex >= len ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\ti = fromIndex;\n\t\t} else {\n\t\t\ti = len + fromIndex;\n\t\t\tif ( i < 0 ) {\n\t\t\t\ti = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\ti = 0;\n\t}\n\t// Check for `NaN`...\n\tif ( isnan( searchElement ) ) {\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tif ( isnan( arr[i] ) ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tif ( arr[ i ] === searchElement ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t}\n\treturn -1;\n}\n\n\n// EXPORTS //\n\nexport default indexOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests whether a value equals the prototype of its constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value equals the prototype of its constructor\n*/\nfunction isConstructorPrototype( value ) {\n\treturn ( value.constructor && value.constructor.prototype === value );\n}\n\n\n// EXPORTS //\n\nexport default isConstructorPrototype;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar w = ( typeof window === 'undefined' ) ? void 0 : window;\n\n\n// EXPORTS //\n\nexport default w;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport indexOf from './../../index-of';\nimport typeOf from './../../type-of';\nimport isConstructorPrototype from './is_constructor_prototype.js';\nimport EXCLUDED_KEYS from './excluded_keys.json';\nimport win from './window.js';\n\n\n// VARIABLES //\n\nvar bool;\n\n\n// FUNCTIONS //\n\n/**\n* Determines whether an environment throws when comparing to the prototype of a value's constructor (e.g., [IE9][1]).\n*\n* [1]: https://stackoverflow.com/questions/7688070/why-is-comparing-the-constructor-property-of-two-windows-unreliable\n*\n* @private\n* @returns {boolean} boolean indicating whether an environment is buggy\n*/\nfunction check() {\n\tvar k;\n\tif ( typeOf( win ) === 'undefined' ) {\n\t\treturn false;\n\t}\n\tfor ( k in win ) { // eslint-disable-line guard-for-in\n\t\ttry {\n\t\t\tif (\n\t\t\t\tindexOf( EXCLUDED_KEYS, k ) === -1 &&\n\t\t\t\thasOwnProp( win, k ) &&\n\t\t\t\twin[ k ] !== null &&\n\t\t\t\ttypeOf( win[ k ] ) === 'object'\n\t\t\t) {\n\t\t\t\tisConstructorPrototype( win[ k ] );\n\t\t\t}\n\t\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\nbool = check();\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar bool = ( typeof window !== 'undefined' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasArgumentsBug from './has_arguments_bug.js';\nimport HAS_BUILTIN from './has_builtin.js';\nimport builtin from './builtin.js';\nimport wrapper from './builtin_wrapper.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\n/**\n* Returns an array of an object's own enumerable property names.\n*\n* @name keys\n* @type {Function}\n* @param {*} value - input object\n* @returns {Array} a list of own enumerable property names\n*\n* @example\n* var obj = {\n* 'beep': 'boop',\n* 'foo': 3.14\n* };\n*\n* var k = keys( obj );\n* // e.g., returns [ 'beep', 'foo' ]\n*/\nvar keys;\nif ( HAS_BUILTIN ) {\n\tif ( hasArgumentsBug() ) {\n\t\tkeys = wrapper;\n\t} else {\n\t\tkeys = builtin;\n\t}\n} else {\n\tkeys = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default keys;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport keys from './builtin.js';\n\n\n// FUNCTIONS //\n\n/**\n* Tests the built-in `Object.keys()` implementation when provided `arguments`.\n*\n* @private\n* @returns {boolean} boolean indicating whether the built-in implementation returns the expected number of keys\n*/\nfunction test() {\n\treturn ( keys( arguments ) || '' ).length !== 2;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether the built-in `Object.keys()` implementation supports providing `arguments` as an input value.\n*\n* ## Notes\n*\n* - Safari 5.0 does **not** support `arguments` as an input value.\n*\n* @private\n* @returns {boolean} boolean indicating whether a built-in implementation supports `arguments`\n*/\nfunction check() {\n\treturn test( 1, 2 );\n}\n\n\n// EXPORTS //\n\nexport default check;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObjectLike from '@stdlib/assert/is-object-like';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport isArguments from '@stdlib/assert/is-arguments';\nimport HAS_ENUM_PROTO_BUG from './has_enumerable_prototype_bug.js';\nimport HAS_NON_ENUM_PROPS_BUG from './has_non_enumerable_properties_bug.js';\nimport isConstructorPrototype from './is_constructor_prototype_wrapper.js';\nimport NON_ENUMERABLE from './non_enumerable.json';\n\n\n// MAIN //\n\n/**\n* Returns an array of an object's own enumerable property names.\n*\n* @private\n* @param {*} value - input object\n* @returns {Array} a list of own enumerable property names\n*\n* @example\n* var obj = {\n* 'beep': 'boop',\n* 'foo': 3.14\n* };\n*\n* var k = keys( obj );\n* // e.g., returns [ 'beep', 'foo' ]\n*/\nfunction keys( value ) {\n\tvar skipConstructor;\n\tvar skipPrototype;\n\tvar isFcn;\n\tvar out;\n\tvar k;\n\tvar p;\n\tvar i;\n\n\tout = [];\n\tif ( isArguments( value ) ) {\n\t\t// Account for environments which treat `arguments` differently...\n\t\tfor ( i = 0; i < value.length; i++ ) {\n\t\t\tout.push( i.toString() );\n\t\t}\n\t\t// Note: yes, we are precluding the `arguments` array-like object from having other enumerable properties; however, this should (1) be very rare and (2) not be encouraged (e.g., doing something like `arguments.a = 'b'`; in certain engines directly manipulating the `arguments` value results in automatic de-optimization).\n\t\treturn out;\n\t}\n\tif ( typeof value === 'string' ) {\n\t\t// Account for environments which do not treat string character indices as \"own\" properties...\n\t\tif ( value.length > 0 && !hasOwnProp( value, '0' ) ) {\n\t\t\tfor ( i = 0; i < value.length; i++ ) {\n\t\t\t\tout.push( i.toString() );\n\t\t\t}\n\t\t}\n\t} else {\n\t\tisFcn = ( typeof value === 'function' );\n\t\tif ( isFcn === false && !isObjectLike( value ) ) {\n\t\t\treturn out;\n\t\t}\n\t\tskipPrototype = ( HAS_ENUM_PROTO_BUG && isFcn );\n\t}\n\tfor ( k in value ) {\n\t\tif ( !( skipPrototype && k === 'prototype' ) && hasOwnProp( value, k ) ) {\n\t\t\tout.push( String( k ) );\n\t\t}\n\t}\n\tif ( HAS_NON_ENUM_PROPS_BUG ) {\n\t\tskipConstructor = isConstructorPrototype( value );\n\t\tfor ( i = 0; i < NON_ENUMERABLE.length; i++ ) {\n\t\t\tp = NON_ENUMERABLE[ i ];\n\t\t\tif ( !( skipConstructor && p === 'constructor' ) && hasOwnProp( value, p ) ) {\n\t\t\t\tout.push( String( p ) );\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default keys;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasAutomationEqualityBug from './has_automation_equality_bug.js';\nimport isConstructorPrototype from './is_constructor_prototype.js';\nimport HAS_WINDOW from './has_window.js';\n\n\n// MAIN //\n\n/**\n* Wraps the test for constructor prototype equality to accommodate buggy environments (e.g., environments which throw when testing equality).\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value equals the prototype of its constructor\n*/\nfunction wrapper( value ) {\n\tif ( HAS_WINDOW === false && !hasAutomationEqualityBug ) {\n\t\treturn isConstructorPrototype( value );\n\t}\n\ttry {\n\t\treturn isConstructorPrototype( value );\n\t} catch ( error ) { // eslint-disable-line no-unused-vars\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default wrapper;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert/is-function';\nimport builtin from './native.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar getProto;\nif ( isFunction( Object.getPrototypeOf ) ) {\n\tgetProto = builtin;\n} else {\n\tgetProto = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default getProto;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an object.\n*\n* @name Object\n* @constructor\n* @type {Function}\n* @param {*} value - input value\n* @returns {Object} object\n*\n* @example\n* var o = new Object( null );\n* // returns {}\n*\n* @example\n* var o = new Object( 5.0 );\n* // returns \n*\n* @example\n* var o = new Object( 'beep' );\n* // returns \n*\n* @example\n* var o1 = {};\n*\n* var o2 = new Object( o1 );\n* // returns {}\n*\n* var bool = ( o1 === o2 );\n* // returns true\n*/\nvar Obj = Object; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default Obj;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar getProto = Object.getPrototypeOf;\n\n\n// EXPORTS //\n\nexport default getProto;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from './../../native-class';\nimport Object from '@stdlib/object/ctor';\nimport getProto from './proto.js';\n\n\n// MAIN //\n\n/**\n* Returns the prototype of a provided object.\n*\n* @private\n* @param {Object} obj - input object\n* @returns {(Object|null)} prototype\n*/\nfunction getPrototypeOf( obj ) {\n\tvar proto = getProto( obj );\n\tif ( proto || proto === null ) {\n\t\treturn proto;\n\t}\n\tif ( nativeClass( obj.constructor ) === '[object Function]' ) {\n\t\t// May break if the constructor has been tampered with...\n\t\treturn obj.constructor.prototype;\n\t}\n\tif ( obj instanceof Object ) {\n\t\treturn Object.prototype;\n\t}\n\t// Return `null` for objects created via `Object.create( null )`. Also return `null` for cross-realm objects on browsers that lack `__proto__` support, such as IE < 11.\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default getPrototypeOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Returns the value of the `__proto__` property.\n*\n* @private\n* @param {Object} obj - input object\n* @returns {*} value of `__proto__` property\n*/\nfunction getProto( obj ) {\n\t// eslint-disable-next-line no-proto\n\treturn obj.__proto__;\n}\n\n\n// EXPORTS //\n\nexport default getProto;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Object from '@stdlib/object/ctor';\nimport getProto from './detect.js';\n\n\n// MAIN //\n\n/**\n* Returns the prototype of a provided object.\n*\n* @param {*} value - input value\n* @returns {(Object|null)} prototype\n*\n* @example\n* var proto = getPrototypeOf( {} );\n* // returns {}\n*/\nfunction getPrototypeOf( value ) {\n\tif (\n\t\tvalue === null ||\n\t\tvalue === void 0\n\t) {\n\t\treturn null;\n\t}\n\t// In order to ensure consistent ES5/ES6 behavior, cast input value to an object (strings, numbers, booleans); ES5 `Object.getPrototypeOf` throws when provided primitives and ES6 `Object.getPrototypeOf` casts:\n\tvalue = Object( value );\n\n\treturn getProto( value );\n}\n\n\n// EXPORTS //\n\nexport default getPrototypeOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from './../../is-object';\nimport isFunction from './../../is-function';\nimport getPrototypeOf from '@stdlib/utils/get-prototype-of';\nimport hasOwnProp from './../../has-own-property';\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar objectPrototype = Object.prototype;\n\n\n// FUNCTIONS //\n\n/**\n* Tests that an object only has own properties.\n*\n* @private\n* @param {Object} obj - value to test\n* @returns {boolean} boolean indicating if an object only has own properties\n*/\nfunction ownProps( obj ) {\n\tvar key;\n\n\t// NOTE: possibility of perf boost if key enumeration order is known (see http://stackoverflow.com/questions/18531624/isplainobject-thing).\n\tfor ( key in obj ) {\n\t\tif ( !hasOwnProp( obj, key ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests if a value is a plain object.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a plain object\n*\n* @example\n* var bool = isPlainObject( {} );\n* // returns true\n*\n* @example\n* var bool = isPlainObject( null );\n* // returns false\n*/\nfunction isPlainObject( value ) {\n\tvar proto;\n\n\t// Screen for obvious non-objects...\n\tif ( !isObject( value ) ) {\n\t\treturn false;\n\t}\n\t// Objects with no prototype (e.g., `Object.create( null )`) are plain...\n\tproto = getPrototypeOf( value );\n\tif ( !proto ) {\n\t\treturn true;\n\t}\n\t// Objects having a prototype are plain if and only if they are constructed with a global `Object` function and the prototype points to the prototype of a plain object...\n\treturn (\n\t\t// Cannot have own `constructor` property:\n\t\t!hasOwnProp( value, 'constructor' ) &&\n\n\t\t// Prototype `constructor` property must be a function (see also https://bugs.jquery.com/ticket/9897 and http://stackoverflow.com/questions/18531624/isplainobject-thing):\n\t\thasOwnProp( proto, 'constructor' ) &&\n\t\tisFunction( proto.constructor ) &&\n\t\tnativeClass( proto.constructor ) === '[object Function]' &&\n\n\t\t// Test for object-specific method:\n\t\thasOwnProp( proto, 'isPrototypeOf' ) &&\n\t\tisFunction( proto.isPrototypeOf ) &&\n\n\t\t(\n\t\t\t// Test if the prototype matches the global `Object` prototype (same realm):\n\t\t\tproto === objectPrototype ||\n\n\t\t\t// Test that all properties are own properties (cross-realm; *most* likely a plain object):\n\t\t\townProps( value )\n\t\t)\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isPlainObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport DTYPES from './dtypes.json';\n\n\n// MAIN //\n\n/**\n* Returns a list of strided array data type strings.\n*\n* @returns {StringArray} list of strided array data type strings\n*\n* @example\n* var list = dtypes();\n* // returns [...]\n*/\nfunction dtypes() {\n\treturn DTYPES.slice();\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string/base/replace';\nimport DTYPES from './dtypes.json';\n\n\n// VARIABLES //\n\nvar RE_SUFFIX = /_and_generic$/;\n\n\n// MAIN //\n\n/**\n* Returns a list of ndarray data types.\n*\n* @param {string} [kind] - data type kind\n* @returns {StringArray} list of ndarray data types\n*\n* @example\n* var list = dtypes();\n* // returns [...]\n*\n* @example\n* var list = dtypes( 'floating_point' );\n* // returns [...]\n*/\nfunction dtypes() {\n\tvar kind;\n\tvar out;\n\tvar FLG;\n\tif ( arguments.length === 0 ) {\n\t\treturn DTYPES.all.slice();\n\t}\n\tFLG = false;\n\tkind = arguments[ 0 ];\n\tif ( RE_SUFFIX.test( kind ) ) {\n\t\tkind = replace( kind, RE_SUFFIX, '' );\n\t\tif ( kind !== 'all' && kind !== 'index' ) {\n\t\t\tFLG = true;\n\t\t}\n\t}\n\tout = DTYPES[ kind ];\n\tout = ( out ) ? out.slice() : [];\n\tif ( FLG && out.length > 0 ) {\n\t\tout.push( 'generic' );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable stdlib/empty-line-before-comment */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an object mapping supported data type strings to enumeration constants.\n*\n* ## Notes\n*\n* - Downstream consumers of this mapping should **not** rely on specific integer values (e.g., `INT8 == 0`). Instead, the object should be used in an opaque manner.\n* - The main purpose of this function is JavaScript and C inter-operation of ndarray objects. While certain dtypes, such as \"generic\" and \"binary\", have special behavior in JavaScript, they do not have a direct complement in C.\n*\n* @private\n* @returns {Object} object mapping supported dtypes to enumeration constants\n*\n* @example\n* var table = enumeration();\n* // returns \n*/\nfunction enumeration() {\n\t// NOTE: the following should match the C `dtypes.h` enumeration!!!!\n\treturn {\n\t\t// Boolean data types:\n\t\t'bool': 0,\n\n\t\t// Integer data types:\n\t\t'int8': 1,\n\t\t'uint8': 2,\n\t\t'uint8c': 3,\n\t\t'int16': 4,\n\t\t'uint16': 5,\n\t\t'int32': 6,\n\t\t'uint32': 7,\n\t\t'int64': 8,\n\t\t'uint64': 9,\n\t\t// 'int128': 10, // uncomment once supported\n\t\t// 'uint128': 11,\n\t\t// 'int256': 12,\n\t\t// 'uint256': 13,\n\n\t\t// Floating-point data types:\n\t\t'float16': 10,\n\t\t// 'bfloat16': 15,\n\t\t'float32': 11,\n\t\t'float64': 12,\n\t\t// 'float128': 18, // uncomment once supported\n\n\t\t// Complex floating-point number data types:\n\t\t'complex32': 13,\n\t\t'complex64': 14,\n\t\t'complex128': 15,\n\n\t\t// Data type for \"binary\" data (i.e., data stored in a Node.js `Buffer` object):\n\t\t'binary': 16,\n\n\t\t// Data type for \"generic\" JavaScript values (objects):\n\t\t'generic': 17,\n\n\t\t// Define a signaling value which is guaranteed not to be a valid type enumeration value:\n\t\t'notype': 18,\n\n\t\t// Indicate the start of user defined type numbers (leaving room for type growth above):\n\t\t'userdefined_type': 256\n\t};\n}\n\n\n// EXPORTS //\n\nexport default enumeration;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return a list of ndarray data types.\n*\n* @module @stdlib/ndarray/dtypes\n*\n* @example\n* import dtypes from '@stdlib/ndarray/dtypes';\n*\n* var list = dtypes();\n* // returns [...]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport enumeration from './enum.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'enum', enumeration );\nassign( main, enumeration() );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\nimport objectKeys from '@stdlib/utils/keys';\n\n\n// MAIN //\n\n/**\n* Copies all enumerable own properties from a source object to a target object as enumerable read-only properties.\n*\n* @private\n* @param {Object} target - target object\n* @param {Object} source - source object\n* @returns {Object} modified target object\n*\n* @example\n* var source = {\n* 'beep': 'boop'\n* };\n* var target = {};\n*\n* var out = assign( target, source );\n* // returns \n*\n* var bool = ( out === target );\n* // returns true\n*\n* var v = target.beep;\n* // returns 'boop'\n*/\nfunction assign( target, source ) {\n\tvar keys;\n\tvar k;\n\tvar i;\n\n\tkeys = objectKeys( source );\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tsetReadOnly( target, k, source[ k ] );\n\t}\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { enum as ndtypes } from '@stdlib/ndarray/dtypes';\n\n\n// VARIABLES //\n\nvar dt = ndtypes();\n\n\n// MAIN //\n\n/**\n* Returns an object mapping supported data strings to enumeration constants for purposes of C inter-operation.\n*\n* ## Notes\n*\n* - Downstream consumers of this mapping should **not** rely on specific integer values (e.g., `INT8 == 0`). Instead, the object should be used in an opaque manner.\n* - The main purpose of this function is JavaScript and C inter-operation of strided arrays.\n*\n* @private\n* @returns {Object} object mapping supported data strings strings to enumeration constants\n*\n* @example\n* var table = enumeration();\n* // returns \n*/\nfunction enumeration() {\n\t// NOTE: the returned object should match the C `dtypes.h` enumeration!!!!\n\treturn {\n\t\t'bool': dt[ 'bool' ],\n\n\t\t'int8': dt[ 'int8' ],\n\t\t'uint8': dt[ 'uint8' ],\n\t\t'uint8c': dt[ 'uint8c' ],\n\t\t'int16': dt[ 'int16' ],\n\t\t'uint16': dt[ 'uint16' ],\n\t\t'int32': dt[ 'int32' ],\n\t\t'uint32': dt[ 'uint32' ],\n\t\t'int64': dt[ 'int64' ],\n\t\t'uint64': dt[ 'uint64' ],\n\n\t\t'float32': dt[ 'float32' ],\n\t\t'float64': dt[ 'float64' ],\n\n\t\t'complex64': dt[ 'complex64' ],\n\t\t'complex128': dt[ 'complex128' ],\n\n\t\t'binary': dt[ 'binary' ],\n\n\t\t'generic': dt[ 'generic' ],\n\n\t\t'notype': dt[ 'notype' ],\n\n\t\t'userdefined_type': dt[ 'userdefined_type' ]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default enumeration;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return a list of strided array data types.\n*\n* @module @stdlib/strided/dtypes\n*\n* @example\n* import dtypes from '@stdlib/strided/dtypes';\n*\n* var list = dtypes();\n* // returns [...]\n*\n* @example\n* import { enum as enumeration } from '@stdlib/strided/dtypes';\n*\n* var table = enumeration();\n* // returns {...}\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport enumeration from './enum.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'enum', enumeration );\nassign( main, enumeration() );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\nimport objectKeys from '@stdlib/utils/keys';\n\n\n// MAIN //\n\n/**\n* Copies all enumerable own properties from a source object to a target object as enumerable read-only properties.\n*\n* @private\n* @param {Object} target - target object\n* @param {Object} source - source object\n* @returns {Object} modified target object\n*\n* @example\n* var source = {\n* 'beep': 'boop'\n* };\n* var target = {};\n*\n* var out = assign( target, source );\n* // returns \n*\n* var bool = ( out === target );\n* // returns true\n*\n* var v = target.beep;\n* // returns 'boop'\n*/\nfunction assign( target, source ) {\n\tvar keys;\n\tvar k;\n\tvar i;\n\n\tkeys = objectKeys( source );\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tk = keys[ i ];\n\t\tsetReadOnly( target, k, source[ k ] );\n\t}\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectInverse from '@stdlib/utils/object-inverse';\nimport { enum as enumeration } from './../../../dtypes';\n\n\n// VARIABLES //\n\nvar hash = objectInverse( enumeration(), {\n\t'duplicates': false\n});\n\n\n// MAIN //\n\n/**\n* Returns the data type string associated with a strided array data type enumeration constant.\n*\n* @param {integer} dtype - data type enumeration constant\n* @returns {(string|null)} data type string or null\n*\n* @example\n* import str2enum from '@stdlib/strided/base/dtype-str2enum';\n*\n* var v = str2enum( 'float64' );\n* // returns \n*\n* var dt = enum2str( v );\n* // returns 'float64'\n*/\nfunction enum2str( dtype ) {\n\tvar v = hash[ dtype ];\n\treturn ( typeof v === 'string' ) ? v : null; // note: we include this guard to prevent walking the prototype chain\n}\n\n\n// EXPORTS //\n\nexport default enum2str;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from './../../keys';\nimport isArray from '@stdlib/assert/is-array';\nimport isObject from '@stdlib/assert/is-plain-object';\nimport isObjectLike from '@stdlib/assert/is-object-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Inverts an object, such that keys become values and values become keys.\n*\n* @param {ObjectLike} obj - input object\n* @param {Options} [opts] - function options\n* @param {boolean} [opts.duplicates=true] - boolean indicating whether to store duplicate keys\n* @throws {TypeError} first argument must be object-like\n* @throws {TypeError} second argument must an an object\n* @throws {TypeError} must provide valid options\n* @returns {Object} inverted object\n*\n* @example\n* var out = invert({\n* 'a': 'beep',\n* 'b': 'boop'\n* });\n* // returns { 'beep': 'a', 'boop': 'b' }\n*\n* @example\n* var out = invert({\n* 'a': 'beep',\n* 'b': 'beep'\n* });\n* // returns { 'beep': [ 'a', 'b' ] }\n*\n* @example\n* var obj = {};\n* obj.a = 'beep';\n* obj.b = 'boop';\n* obj.c = 'beep'; // inserted after `a`\n*\n* var out = invert( obj, {\n* 'duplicates': false\n* });\n* // returns { 'beep': 'c', 'boop': 'b' }\n*/\nfunction invert( obj, opts ) {\n\tvar allowDupes = true;\n\tvar keys;\n\tvar len;\n\tvar key;\n\tvar val;\n\tvar out;\n\tvar v;\n\tvar i;\n\tif ( !isObjectLike( obj ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object (except null). Value: `%s`.', obj ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\tif ( hasOwnProp( opts, 'duplicates' ) ) {\n\t\t\tallowDupes = opts.duplicates;\n\t\t\tif ( !isBoolean( allowDupes ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'duplicates', allowDupes ) );\n\t\t\t}\n\t\t}\n\t}\n\tkeys = objectKeys( obj );\n\tlen = keys.length;\n\tout = {};\n\tif ( allowDupes ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tkey = keys[ i ];\n\t\t\tval = obj[ key ];\n\t\t\tif ( !hasOwnProp( out, val ) ) {\n\t\t\t\tout[ val ] = key;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tv = out[ val ];\n\t\t\tif ( isArray( v ) ) {\n\t\t\t\tout[ val ].push( key );\n\t\t\t} else {\n\t\t\t\tout[ val ] = [ v, key ];\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tkey = keys[ i ];\n\t\t\tout[ obj[ key ] ] = key;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default invert;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { enum as enumeration } from './../../../dtypes';\n\n\n// VARIABLES //\n\nvar ENUM = enumeration();\n\n\n// MAIN //\n\n/**\n* Returns the enumeration constant associated with a strided array data type string.\n*\n* ## Notes\n*\n* - Downstream consumers of this function should **not** rely on specific integer values (e.g., `INT8 == 0`). Instead, the function should be used in an opaque manner.\n*\n* @param {string} dtype - data type string\n* @returns {(integer|null)} integer value or null\n*\n* @example\n* var v = str2enum( 'int8' );\n* // returns \n*/\nfunction str2enum( dtype ) {\n\tvar v = ENUM[ dtype ];\n\treturn ( typeof v === 'number' ) ? v : null; // note: we include this guard to prevent walking the prototype chain\n}\n\n\n// EXPORTS //\n\nexport default str2enum;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport enum2str from './../../../base/dtype-enum2str';\nimport str2enum from './../../../base/dtype-str2enum';\n\n\n// MAIN //\n\n/**\n* Returns the data type string associated with a supported strided array data type value.\n*\n* @param {*} dtype - data type value\n* @returns {(string|null)} data type string or null\n*\n* @example\n* import str2enum from '@stdlib/strided/base/dtype-str2enum';\n*\n* var v = resolve( str2enum( 'float64' ) );\n* // returns 'float64'\n*/\nfunction resolve( dtype ) {\n\tvar t = ( typeof dtype );\n\tif ( t === 'string' ) {\n\t\treturn ( str2enum( dtype ) === null ) ? null : dtype;\n\t}\n\tif ( t === 'number' ) {\n\t\treturn enum2str( dtype );\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default resolve;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport resolve from '@stdlib/strided/base/dtype-resolve-str';\nimport CASTS from './data.json';\n\n\n// VARIABLES //\n\nvar TABLE;\n\n\n// FUNCTIONS //\n\n/**\n* Generates a full table of casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateFullTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = CASTS[ dt1 ];\n\t\ttmp = {};\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\ttmp[ dt2 ] = o[ dt2 ];\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n/**\n* Generates a table of casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = CASTS[ dt1 ];\n\t\ttmp = [];\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\tif ( o[ dt2 ] === 1 ) {\n\t\t\t\ttmp.push( dt2 );\n\t\t\t}\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a list of array data types to which a provided array data type can be safely cast and, for floating-point data types, can be downcast.\n*\n* @param {*} [dtype] - array data type value\n* @returns {(Object|StringArray|null)} list of array data types or null\n*\n* @example\n* var list = mostlySafeCasts( 'float32' );\n* // returns [...]\n*/\nfunction mostlySafeCasts( dtype ) {\n\tif ( arguments.length === 0 ) {\n\t\treturn generateFullTable();\n\t}\n\tif ( TABLE === void 0 ) {\n\t\t// Lazily generate table...\n\t\tTABLE = generateTable();\n\t}\n\tdtype = resolve( dtype );\n\tif ( hasOwnProp( TABLE, dtype ) ) {\n\t\treturn TABLE[ dtype ].slice();\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default mostlySafeCasts;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport casts from './../../../../mostly-safe-casts';\n\n\n// VARIABLES //\n\nvar TABLE = casts();\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a provided array data type can be safely cast or, for floating-point data types, downcast to another array data type.\n*\n* @param {string} from - array data type\n* @param {string} to - array data type\n* @returns {boolean} boolean indicating if a data type can be cast to another data type\n*\n* @example\n* var bool = isMostlySafeCast( 'float32', 'float64' );\n* // returns true\n*\n* bool = isMostlySafeCast( 'float64', 'int32' );\n* // returns false\n*/\nfunction isMostlySafeCast( from, to ) {\n\tif ( from === to ) {\n\t\treturn true;\n\t}\n\treturn ( TABLE[ from ][ to ] > 0 );\n}\n\n\n// EXPORTS //\n\nexport default isMostlySafeCast;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array numeric data type.\n*\n* @name isNumericDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array numeric data type\n*\n* @example\n* var bool = isNumericDataType( 'float32' );\n* // returns true\n*\n* bool = isNumericDataType( 'float64' );\n* // returns true\n*\n* bool = isNumericDataType( 'generic' );\n* // returns false\n*\n* bool = isNumericDataType( 'int16' );\n* // returns true\n*\n* bool = isNumericDataType( 'int32' );\n* // returns true\n*\n* bool = isNumericDataType( 'int8' );\n* // returns true\n*\n* bool = isNumericDataType( 'uint16' );\n* // returns true\n*\n* bool = isNumericDataType( 'uint32' );\n* // returns true\n*\n* bool = isNumericDataType( 'uint8' );\n* // returns true\n*\n* bool = isNumericDataType( 'uint8c' );\n* // returns true\n*\n* bool = isNumericDataType( 'foo' );\n* // returns false\n*/\nvar isNumericDataType = contains( dtypes( 'numeric' ) );\n\n\n// EXPORTS //\n\nexport default isNumericDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport resolve from '@stdlib/strided/base/dtype-resolve-str';\nimport SAFE_CASTS from './safe_casts.json';\n\n\n// VARIABLES //\n\nvar TABLE;\n\n\n// FUNCTIONS //\n\n/**\n* Generates a full table of safe casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateFullTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( SAFE_CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = SAFE_CASTS[ dt1 ];\n\t\ttmp = {};\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\ttmp[ dt2 ] = o[ dt2 ];\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n/**\n* Generates a table of safe casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( SAFE_CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = SAFE_CASTS[ dt1 ];\n\t\ttmp = [];\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\tif ( o[ dt2 ] === 1 ) {\n\t\t\t\ttmp.push( dt2 );\n\t\t\t}\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a list of array data types to which a provided array data type can be safely cast.\n*\n* @param {*} [dtype] - array data type value\n* @returns {(Object|StringArray|null)} list of array data types or null\n*\n* @example\n* var list = safeCasts( 'float32' );\n* // returns [...]\n*/\nfunction safeCasts( dtype ) {\n\tif ( arguments.length === 0 ) {\n\t\treturn generateFullTable();\n\t}\n\tif ( TABLE === void 0 ) {\n\t\t// Lazily generate table...\n\t\tTABLE = generateTable();\n\t}\n\tdtype = resolve( dtype );\n\tif ( hasOwnProp( TABLE, dtype ) ) {\n\t\treturn TABLE[ dtype ].slice();\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default safeCasts;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array real-valued data type.\n*\n* @name isRealDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array real-valued data type\n*\n* @example\n* var bool = isRealDataType( 'float32' );\n* // returns true\n*\n* bool = isRealDataType( 'float64' );\n* // returns true\n*\n* bool = isRealDataType( 'complex128' );\n* // returns false\n*\n* bool = isRealDataType( 'generic' );\n* // returns false\n*\n* bool = isRealDataType( 'int16' );\n* // returns true\n*\n* bool = isRealDataType( 'int32' );\n* // returns true\n*\n* bool = isRealDataType( 'int8' );\n* // returns true\n*\n* bool = isRealDataType( 'uint16' );\n* // returns true\n*\n* bool = isRealDataType( 'uint32' );\n* // returns true\n*\n* bool = isRealDataType( 'uint8' );\n* // returns true\n*\n* bool = isRealDataType( 'uint8c' );\n* // returns true\n*\n* bool = isRealDataType( 'foo' );\n* // returns false\n*/\nvar isRealDataType = contains( dtypes( 'real' ) );\n\n\n// EXPORTS //\n\nexport default isRealDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array real-valued floating-point data type.\n*\n* @name isRealFloatingPointDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array real-valued floating-point data type\n*\n* @example\n* var bool = isRealFloatingPointDataType( 'float32' );\n* // returns true\n*\n* bool = isRealFloatingPointDataType( 'float64' );\n* // returns true\n*\n* bool = isRealFloatingPointDataType( 'generic' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'int16' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'int32' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'int8' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'uint16' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'uint32' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'uint8' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'uint8c' );\n* // returns false\n*\n* bool = isRealFloatingPointDataType( 'foo' );\n* // returns false\n*/\nvar isRealFloatingPointDataType = contains( dtypes( 'real_floating_point' ) ); // eslint-disable-line id-length\n\n\n// EXPORTS //\n\nexport default isRealFloatingPointDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport safeCasts from './../../../../safe-casts';\n\n\n// VARIABLES //\n\nvar TABLE = safeCasts();\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a provided array data type can be safely cast to another array data type.\n*\n* @param {string} from - array data type\n* @param {string} to - array data type\n* @returns {boolean} boolean indicating if a data type can be safely cast to another data type\n*\n* @example\n* var bool = isSafeCast( 'float32', 'float64' );\n* // returns true\n*\n* bool = isSafeCast( 'float64', 'int32' );\n* // returns false\n*/\nfunction isSafeCast( from, to ) {\n\tif ( from === to ) {\n\t\treturn true;\n\t}\n\treturn ( TABLE[ from ][ to ] > 0 );\n}\n\n\n// EXPORTS //\n\nexport default isSafeCast;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport resolve from '@stdlib/strided/base/dtype-resolve-str';\nimport SAME_KIND_CASTS from './same_kind_casts.json';\n\n\n// VARIABLES //\n\nvar TABLE;\n\n\n// FUNCTIONS //\n\n/**\n* Generates a full table of same \"kind\" casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateFullTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( SAME_KIND_CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = SAME_KIND_CASTS[ dt1 ];\n\t\ttmp = {};\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\ttmp[ dt2 ] = o[ dt2 ];\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n/**\n* Generates a table of same \"kind\" casts for each array data type.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( SAME_KIND_CASTS );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = SAME_KIND_CASTS[ dt1 ];\n\t\ttmp = [];\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\tif ( o[ dt2 ] === 1 ) {\n\t\t\t\ttmp.push( dt2 );\n\t\t\t}\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a list of array data types to which a provided array data type can be safely cast or cast within the same \"kind\".\n*\n* @param {*} [dtype] - array data type value\n* @returns {(Object|StringArray|null)} list of array data types or null\n*\n* @example\n* var list = sameKindCasts( 'float32' );\n* // returns [...]\n*/\nfunction sameKindCasts( dtype ) {\n\tif ( arguments.length === 0 ) {\n\t\treturn generateFullTable();\n\t}\n\tif ( TABLE === void 0 ) {\n\t\t// Lazily generate table...\n\t\tTABLE = generateTable();\n\t}\n\tdtype = resolve( dtype );\n\tif ( hasOwnProp( TABLE, dtype ) ) {\n\t\treturn TABLE[ dtype ].slice();\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default sameKindCasts;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport sameKindCasts from './../../../../same-kind-casts';\n\n\n// VARIABLES //\n\nvar TABLE = sameKindCasts();\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a provided array data type can be safely cast to, or is of the same \"kind\" as, another array data type.\n*\n* @param {string} from - array data type\n* @param {string} to - array data type\n* @returns {boolean} boolean indicating if a data type can be cast to another data type\n*\n* @example\n* var bool = isSameKindCast( 'float32', 'float64' );\n* // returns true\n*\n* bool = isSameKindCast( 'uint16', 'int16' );\n* // returns false\n*/\nfunction isSameKindCast( from, to ) {\n\tif ( from === to ) {\n\t\treturn true;\n\t}\n\treturn ( TABLE[ from ][ to ] > 0 );\n}\n\n\n// EXPORTS //\n\nexport default isSameKindCast;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array signed integer data type.\n*\n* @name isSignedIntegerDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array signed integer data type\n*\n* @example\n* var bool = isSignedIntegerDataType( 'float32' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'float64' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'generic' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'int16' );\n* // returns true\n*\n* bool = isSignedIntegerDataType( 'int32' );\n* // returns true\n*\n* bool = isSignedIntegerDataType( 'int8' );\n* // returns true\n*\n* bool = isSignedIntegerDataType( 'uint16' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'uint32' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'uint8' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'uint8c' );\n* // returns false\n*\n* bool = isSignedIntegerDataType( 'foo' );\n* // returns false\n*/\nvar isSignedIntegerDataType = contains( dtypes( 'signed_integer' ) );\n\n\n// EXPORTS //\n\nexport default isSignedIntegerDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../../../base/assert/contains';\nimport dtypes from './../../../../dtypes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported array unsigned integer data type.\n*\n* @name isUnsignedIntegerDataType\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported array unsigned integer data type\n*\n* @example\n* var bool = isUnsignedIntegerDataType( 'float32' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'float64' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'generic' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'int16' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'int32' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'int8' );\n* // returns false\n*\n* bool = isUnsignedIntegerDataType( 'uint16' );\n* // returns true\n*\n* bool = isUnsignedIntegerDataType( 'uint32' );\n* // returns true\n*\n* bool = isUnsignedIntegerDataType( 'uint8' );\n* // returns true\n*\n* bool = isUnsignedIntegerDataType( 'uint8c' );\n* // returns true\n*\n* bool = isUnsignedIntegerDataType( 'foo' );\n* // returns false\n*/\nvar isUnsignedIntegerDataType = contains( dtypes( 'unsigned_integer' ) );\n\n\n// EXPORTS //\n\nexport default isUnsignedIntegerDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name contains\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/contains}\n*/\nimport contains from './../../../base/assert/contains';\nsetReadOnly( ns, 'contains', contains );\n\n/**\n* @name hasAlmostEqualValues\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/has-almost-equal-values}\n*/\nimport hasAlmostEqualValues from './../../../base/assert/has-almost-equal-values';\nsetReadOnly( ns, 'hasAlmostEqualValues', hasAlmostEqualValues );\n\n/**\n* @name hasEqualValues\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/has-equal-values}\n*/\nimport hasEqualValues from './../../../base/assert/has-equal-values';\nsetReadOnly( ns, 'hasEqualValues', hasEqualValues );\n\n/**\n* @name hasEqualValuesIndexed\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/has-equal-values-indexed}\n*/\nimport hasEqualValuesIndexed from './../../../base/assert/has-equal-values-indexed';\nsetReadOnly( ns, 'hasEqualValuesIndexed', hasEqualValuesIndexed );\n\n/**\n* @name hasSameValues\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/has-same-values}\n*/\nimport hasSameValues from './../../../base/assert/has-same-values';\nsetReadOnly( ns, 'hasSameValues', hasSameValues );\n\n/**\n* @name isAccessorArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-accessor-array}\n*/\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nsetReadOnly( ns, 'isAccessorArray', isAccessorArray );\n\n/**\n* @name isBooleanDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-boolean-data-type}\n*/\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nsetReadOnly( ns, 'isBooleanDataType', isBooleanDataType );\n\n/**\n* @name isBooleanArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-booleanarray}\n*/\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nsetReadOnly( ns, 'isBooleanArray', isBooleanArray );\n\n/**\n* @name isByteOrder\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-byte-order}\n*/\nimport isByteOrder from './../../../base/assert/is-byte-order';\nsetReadOnly( ns, 'isByteOrder', isByteOrder );\n\n/**\n* @name isComplexFloatingPointDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-complex-floating-point-data-type}\n*/\nimport isComplexFloatingPointDataType from './../../../base/assert/is-complex-floating-point-data-type';\nsetReadOnly( ns, 'isComplexFloatingPointDataType', isComplexFloatingPointDataType );\n\n/**\n* @name isComplexTypedArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-complex-typed-array}\n*/\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nsetReadOnly( ns, 'isComplexTypedArray', isComplexTypedArray );\n\n/**\n* @name isComplex64Array\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-complex64array}\n*/\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nsetReadOnly( ns, 'isComplex64Array', isComplex64Array );\n\n/**\n* @name isComplex128Array\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-complex128array}\n*/\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nsetReadOnly( ns, 'isComplex128Array', isComplex128Array );\n\n/**\n* @name isDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-data-type}\n*/\nimport isDataType from './../../../base/assert/is-data-type';\nsetReadOnly( ns, 'isDataType', isDataType );\n\n/**\n* @name isFloatingPointDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-floating-point-data-type}\n*/\nimport isFloatingPointDataType from './../../../base/assert/is-floating-point-data-type';\nsetReadOnly( ns, 'isFloatingPointDataType', isFloatingPointDataType );\n\n/**\n* @name isIntegerDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-integer-data-type}\n*/\nimport isIntegerDataType from './../../../base/assert/is-integer-data-type';\nsetReadOnly( ns, 'isIntegerDataType', isIntegerDataType );\n\n/**\n* @name isMostlySafeDataTypeCast\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-mostly-safe-data-type-cast}\n*/\nimport isMostlySafeDataTypeCast from './../../../base/assert/is-mostly-safe-data-type-cast';\nsetReadOnly( ns, 'isMostlySafeDataTypeCast', isMostlySafeDataTypeCast );\n\n/**\n* @name isNumericDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-numeric-data-type}\n*/\nimport isNumericDataType from './../../../base/assert/is-numeric-data-type';\nsetReadOnly( ns, 'isNumericDataType', isNumericDataType );\n\n/**\n* @name isRealDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-real-data-type}\n*/\nimport isRealDataType from './../../../base/assert/is-real-data-type';\nsetReadOnly( ns, 'isRealDataType', isRealDataType );\n\n/**\n* @name isRealFloatingPointDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-real-floating-point-data-type}\n*/\nimport isRealFloatingPointDataType from './../../../base/assert/is-real-floating-point-data-type';\nsetReadOnly( ns, 'isRealFloatingPointDataType', isRealFloatingPointDataType );\n\n/**\n* @name isSafeDataTypeCast\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-safe-data-type-cast}\n*/\nimport isSafeDataTypeCast from './../../../base/assert/is-safe-data-type-cast';\nsetReadOnly( ns, 'isSafeDataTypeCast', isSafeDataTypeCast );\n\n/**\n* @name isSameKindDataTypeCast\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-same-kind-data-type-cast}\n*/\nimport isSameKindDataTypeCast from './../../../base/assert/is-same-kind-data-type-cast';\nsetReadOnly( ns, 'isSameKindDataTypeCast', isSameKindDataTypeCast );\n\n/**\n* @name isSignedIntegerDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-signed-integer-data-type}\n*/\nimport isSignedIntegerDataType from './../../../base/assert/is-signed-integer-data-type';\nsetReadOnly( ns, 'isSignedIntegerDataType', isSignedIntegerDataType );\n\n/**\n* @name isSortedAscending\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-sorted-ascending}\n*/\nimport isSortedAscending from './../../../base/assert/is-sorted-ascending';\nsetReadOnly( ns, 'isSortedAscending', isSortedAscending );\n\n/**\n* @name isUnsignedIntegerDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/assert/is-unsigned-integer-data-type}\n*/\nimport isUnsignedIntegerDataType from './../../../base/assert/is-unsigned-integer-data-type';\nsetReadOnly( ns, 'isUnsignedIntegerDataType', isUnsignedIntegerDataType );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the maximum value.\n*\n* @param {number} x - first number\n* @param {number} y - second number\n* @returns {number} maximum value\n*\n* @example\n* var v = max( 3.14, 4.2 );\n* // returns 4.2\n*\n* @example\n* var v = max( 3.14, NaN );\n* // returns NaN\n*\n* @example\n* var v = max( NaN, 3.14 );\n* // returns 3.14\n*\n* @example\n* var v = max( -0.0, +0.0 );\n* // returns +0.0\n*\n* @example\n* var v = max( +0.0, -0.0 );\n* // returns -0.0\n*/\nfunction max( x, y ) {\n\tif ( x > y ) {\n\t\treturn x;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default max;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the minimum value.\n*\n* @param {number} x - first number\n* @param {number} y - second number\n* @returns {number} minimum value\n*\n* @example\n* var v = min( 3.14, 4.2 );\n* // returns 3.14\n*\n* @example\n* var v = min( 3.14, NaN );\n* // returns NaN\n*\n* @example\n* var v = min( NaN, 3.14 );\n* // returns 3.14\n*\n* @example\n* var v = min( -0.0, +0.0 );\n* // returns +0.0\n*\n* @example\n* var v = min( +0.0, -0.0 );\n* // returns -0.0\n*/\nfunction min( x, y ) {\n\tif ( x < y ) {\n\t\treturn x;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default min;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled \"generic\" array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeInteger} len - array length\n* @returns {Array} filled array\n*\n* @example\n* var out = filled( 0.0, 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*\n* @example\n* var out = filled( 'beep', 3 );\n* // returns [ 'beep', 'beep', 'beep' ]\n*/\nfunction filled( value, len ) {\n\tvar arr;\n\tvar i;\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tarr.push( value );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional nested array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = filled2d( 0.0, [ 1, 3 ] );\n* // returns [ [ 0.0, 0.0, 0.0 ] ]\n*\n* @example\n* var out = filled2d( 'beep', [ 3, 1 ] );\n* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ]\n*/\nfunction filled2d( value, shape ) {\n\tvar arr;\n\tvar S0;\n\tvar S1;\n\tvar i;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < S1; i++ ) {\n\t\tarr.push( filled( value, S0 ) );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled2d from './../../../base/filled2d';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled two-dimensional nested array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {ArrayArray} filled array\n*\n* @example\n* var out = zeros2d( [ 1, 3 ] );\n* // returns [ [ 0.0, 0.0, 0.0 ] ]\n*/\nfunction zeros2d( shape ) {\n\treturn filled2d( 0.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default zeros2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if two indexed arrays have equal values.\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @returns {boolean} boolean indicating if both arrays have equal values\n*\n* @example\n* var x = [ 0, 0, 1, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasEqualValuesIndexed( x, y );\n* // returns true\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n* var y = [ 0, 0, 1, 0 ];\n*\n* var out = hasEqualValuesIndexed( x, y );\n* // returns false\n*/\nfunction hasEqualValuesIndexed( x, y ) {\n\tvar i;\n\tif ( x.length !== y.length ) {\n\t\treturn false;\n\t}\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( x[ i ] !== y[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default hasEqualValuesIndexed;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../../base/accessor-getter';\nimport getter from './../../../../base/getter';\nimport dtype from './../../../../dtype';\n\n\n// MAIN //\n\n/**\n* Tests if an array is sorted in ascending order.\n*\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating if an array is sorted in ascending order\n*\n* @example\n* var out = isSortedAscending( [ 1, 2, 3 ] );\n* // returns true\n*\n* @example\n* var out = isSortedAscending( [ 3, 2, 1 ] );\n* // returns false\n*\n* @example\n* var out = isSortedAscending( [ 3, 3, 3 ] );\n* // returns true\n*\n* @example\n* var out = isSortedAscending( [ 3 ] );\n* // returns true\n*\n* @example\n* var out = isSortedAscending( [] );\n* // returns false\n*\n* @example\n* var out = isSortedAscending( [ 1, 3, 2 ] );\n* // returns false\n*/\nfunction isSortedAscending( x ) {\n\tvar len;\n\tvar get;\n\tvar dt;\n\tvar v1;\n\tvar v2;\n\tvar i;\n\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Resolve an accessor for retrieving input array elements:\n\tif ( isAccessorArray( x ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\t// Get the number of elements over which to iterate:\n\tlen = x.length;\n\n\t// Check for an empty array:\n\tif ( len === 0 ) {\n\t\treturn false;\n\t}\n\t// Loop over the elements...\n\tv1 = get( x, 0 );\n\tfor ( i = 1; i < len; i++ ) {\n\t\tv2 = get( x, i );\n\t\tif ( v1 > v2 ) {\n\t\t\treturn false;\n\t\t}\n\t\tv1 = v2;\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default isSortedAscending;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/*\n* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name filled2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/banded/filled2d-by}\n*/\nimport filled2dBy from './../../../base/banded/filled2d-by';\nsetReadOnly( ns, 'filled2dBy', filled2dBy );\n\n/**\n* @name toCompact\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/banded/to-compact}\n*/\nimport toCompact from './../../../base/banded/to-compact';\nsetReadOnly( ns, 'toCompact', toCompact );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Recursively applies a binary callback.\n*\n* @private\n* @param {ArrayLikeObject} x - input array\n* @param {ArrayLikeObject} y - input array\n* @param {ArrayLikeObject} z - output array\n* @param {NonNegativeInteger} ndims - number of dimensions\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} dim - dimension index\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*/\nfunction recurse( x, y, z, ndims, shape, dim, fcn ) {\n\tvar S;\n\tvar d;\n\tvar i;\n\n\tS = shape[ dim ];\n\n\t// Check whether we've reached the innermost dimension:\n\td = dim + 1;\n\n\tif ( d === ndims ) {\n\t\t// Apply the provided callback...\n\t\tfor ( i = 0; i < S; i++ ) {\n\t\t\tz[ i ] = fcn( x[ i ], y[ i ] );\n\t\t}\n\t\treturn;\n\t}\n\t// Continue recursing into the nested arrays...\n\tfor ( i = 0; i < S; i++ ) {\n\t\trecurse( x[ i ], y[ i ], z[ i ], ndims, shape, d, fcn );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two n-dimensional nested input arrays and assigns results to elements in an n-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add';\n* import onesnd from '@stdlib/array/base/onesnd';\n* import zerosnd from '@stdlib/array/base/zerosnd';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = onesnd( shape );\n* var y = onesnd( shape );\n* var z = zerosnd( shape );\n*\n* binarynd( [ x, y, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ]\n*/\nfunction binarynd( arrays, shape, fcn ) {\n\treturn recurse( arrays[ 0 ], arrays[ 1 ], arrays[ 2 ], shape.length, shape, 0, fcn ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default binarynd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies the elements of an indexed array-like object to a new \"generic\" array.\n*\n* @param {Collection} x - input array\n* @returns {Array} output array\n*\n* @example\n* var out = copy( [ 1, 2, 3 ] );\n* // returns [ 1, 2, 3 ]\n*/\nfunction copy( x ) {\n\tvar out;\n\tvar len;\n\tvar i;\n\n\tlen = x.length;\n\tout = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tout.push( x[ i ] ); // use `Array#push` to ensure \"fast\" elements\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default copy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled \"generic\" array.\n*\n* @param {NonNegativeInteger} len - array length\n* @returns {Array} output array\n*\n* @example\n* var out = zeros( 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction zeros( len ) {\n\treturn filled( 0.0, len );\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport copy from './../../../base/copy-indexed';\nimport zeros from './../../../base/zeros';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Broadcasts an array to a specified shape.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} inShape - input array shape\n* @param {NonNegativeIntegerArray} outShape - output array shape\n* @throws {Error} input array cannot have more dimensions than the desired shape\n* @throws {Error} input array dimension sizes must be `1` or equal to the corresponding dimension in the provided output shape\n* @throws {Error} input array and desired shape must be broadcast compatible\n* @returns {Object} broadcast object\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = broadcastArray( x, [ 2 ], [ 2, 2 ] );\n* // returns {...}\n*\n* var shape = out.shape;\n* // returns [ 2, 2 ]\n*\n* var strides = out.strides;\n* // returns [ 0, 1 ]\n*\n* var ref = out.ref;\n* // returns [ 1, 2 ]\n*\n* var bool = ( x === ref );\n* // returns true\n*\n* var data = out.data;\n* // returns [ [ 1, 2 ] ]\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = broadcastArray( x, [ 2 ], [ 2, 1, 2 ] );\n* // returns {...}\n*\n* var data = out.data;\n* // returns [ [ [ 1, 2 ] ] ]\n*\n* var strides = out.strides;\n* // returns [ 0, 0, 1 ]\n*\n* @example\n* var x = [ [ 1 ], [ 2 ] ];\n*\n* var out = broadcastArray( x, [ 2, 1 ], [ 3, 2, 2 ] );\n* // returns {...}\n*\n* var data = out.data;\n* // returns [ [ [ 1 ], [ 2 ] ] ]\n*\n* var strides = out.strides;\n* // returns [ 0, 1, 0 ]\n*/\nfunction broadcastArray( x, inShape, outShape ) {\n\tvar data;\n\tvar dim;\n\tvar st;\n\tvar N;\n\tvar M;\n\tvar d;\n\tvar i;\n\tvar j;\n\n\tN = outShape.length;\n\tM = inShape.length;\n\tif ( N < M ) {\n\t\tthrow new Error( 'invalid argument. Cannot broadcast an array to a shape having fewer dimensions. Arrays can only be broadcasted to shapes having the same or more dimensions.' );\n\t}\n\t// Prepend additional dimensions...\n\tdata = x;\n\tfor ( i = M; i < N; i++ ) {\n\t\tdata = [ data ];\n\t}\n\n\t// Initialize a strides array:\n\tst = zeros( N );\n\n\t// Determine the output array strides...\n\tfor ( i = N-1; i >= 0; i-- ) {\n\t\tj = M - N + i;\n\t\tif ( j < 0 ) {\n\t\t\t// Prepended singleton dimension; stride is zero...\n\t\t\tcontinue;\n\t\t}\n\t\td = inShape[ j ];\n\t\tdim = outShape[ i ];\n\t\tif ( dim !== 0 && dim < d ) {\n\t\t\tthrow new Error( format( 'invalid argument. Input array cannot be broadcast to the specified shape, as the specified shape has a dimension whose size is less than the size of the corresponding dimension in the input array. Array shape: (%s). Desired shape: (%s). Dimension: %u.', copy( inShape ).join( ', ' ), copy( outShape ).join( ', ' ), i ) );\n\t\t}\n\t\tif ( d === dim ) {\n\t\t\t// As the dimension sizes are equal, the stride is one, meaning that each element in the array should be iterated over as normal...\n\t\t\tst[ i ] = 1;\n\t\t} else if ( d === 1 ) {\n\t\t\t// In order to broadcast a dimension, we set the stride for that dimension to zero...\n\t\t\tst[ i ] = 0;\n\t\t} else {\n\t\t\t// At this point, we know that `dim > d` and that `d` does not equal `1` (e.g., `dim=3` and `d=2`); in which case, the shapes are considered incompatible (even for desired shapes which are multiples of array dimensions, as might be desired when \"tiling\" an array; e.g., `dim=4` and `d=2`)...\n\t\t\tthrow new Error( format( 'invalid argument. Input array and the specified shape are broadcast incompatible. Array shape: (%s). Desired shape: (%s). Dimension: %u.', copy( inShape ).join( ', ' ), copy( outShape ).join( ', ' ), i ) );\n\t\t}\n\t}\n\t// Return broadcast results:\n\treturn {\n\t\t'ref': x, // reference to the original input array\n\t\t'data': data, // broadcasted array\n\t\t'shape': copy( outShape ), // copy in order to prevent mutation\n\t\t'strides': st\n\t};\n}\n\n\n// EXPORTS //\n\nexport default broadcastArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isEven from './../../../../base/assert/is-even';\n\n\n// MAIN //\n\n/**\n* Tests if a finite double-precision floating-point number is an odd number.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is an odd number\n*\n* @example\n* var bool = isOdd( 5.0 );\n* // returns true\n*\n* @example\n* var bool = isOdd( -2.0 );\n* // returns false\n*\n* @example\n* var bool = isOdd( 0.0 );\n* // returns false\n*\n* @example\n* var bool = isOdd( NaN );\n* // returns false\n*/\nfunction isOdd( x ) {\n\t// Check sign to prevent overflow...\n\tif ( x > 0.0 ) {\n\t\treturn isEven( x-1.0 );\n\t}\n\treturn isEven( x+1.0 );\n}\n\n\n// EXPORTS //\n\nexport default isOdd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport PINF from '@stdlib/constants/float64/pinf';\nimport NINF from '@stdlib/constants/float64/ninf';\n\n\n// MAIN //\n\n/**\n* Tests if a double-precision floating-point numeric value is infinite.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is infinite\n*\n* @example\n* var bool = isInfinite( Infinity );\n* // returns true\n*\n* @example\n* var bool = isInfinite( -Infinity );\n* // returns true\n*\n* @example\n* var bool = isInfinite( 5.0 );\n* // returns false\n*\n* @example\n* var bool = isInfinite( NaN );\n* // returns false\n*/\nfunction isInfinite( x ) {\n\treturn (x === PINF || x === NINF);\n}\n\n\n// EXPORTS //\n\nexport default isInfinite;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional banded nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} ku - number of super-diagonals\n* @param {NonNegativeInteger} kl - number of sub-diagonals\n* @param {*} fill - fill value for values outside the band\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 3, 3 ], 1, 1, 0, clbk );\n* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 4, 4 ], 1, 1, 0, clbk );\n* // returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 4, 4 ], 2, 1, 0, clbk );\n* // returns [ [ 0, 1, 2, 0 ], [ 1, 2, 3, 4 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 4, 4 ], 0, 2, 0, clbk );\n* // returns [ [ 0, 0, 0, 0 ], [ 1, 2, 0, 0 ], [ 2, 3, 4, 0 ], [ 0, 4, 5, 6 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 3, 4 ], 1, 1, 0, clbk );\n* // returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( [ 4, 3 ], 1, 1, 0, clbk );\n* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ], [ 0, 0, 5 ] ]\n*/\nfunction filled2dBy( shape, ku, kl, fill, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\n\tS1 = shape[ 0 ]; // rows\n\tS0 = shape[ 1 ]; // columns\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ta0 = [];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t// Check whether we are within the band...\n\t\t\tif (\n\t\t\t\t( i0 >= i1 && i0 <= i1+ku ) || // super-diagonals\n\t\t\t\t( i0 <= i1 && i1 <= i0+kl ) // sub-diagonals\n\t\t\t) {\n\t\t\t\ta0.push( clbk.call( thisArg, [ i1, i0 ] ) );\n\t\t\t}\n\t\t\t// Otherwise, we are outside the band...\n\t\t\telse {\n\t\t\t\ta0.push( fill );\n\t\t\t}\n\t\t}\n\t\tarr.push( a0 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport max from '@stdlib/math/base/special/fast/max';\nimport min from '@stdlib/math/base/special/fast/min';\nimport zeros2d from './../../../../base/zeros2d';\n\n\n// MAIN //\n\n/**\n* Converts a two-dimensional banded nested array to compact banded storage.\n*\n* @param {Array} arr - input two-dimensional array\n* @param {NonNegativeInteger} ku - number of super-diagonals\n* @param {NonNegativeInteger} kl - number of sub-diagonals\n* @param {boolean} colexicographic - specifies whether to store diagonals in colexicographic access order\n* @returns {Array} output array\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 3, 12, 4 ],\n* [ 0, 5, 13 ]\n* ];\n*\n* var out = toCompact( M, 1, 1, false );\n* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ], [ 3, 5, 0 ] ]\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 3, 12, 4 ],\n* [ 0, 5, 13 ]\n* ];\n*\n* var out = toCompact( M, 1, 1, true );\n* // returns [ [ 0, 11, 3 ], [ 2, 12, 5 ], [ 4, 13, 0 ] ]\n*/\nfunction toCompact( arr, ku, kl, colexicographic ) {\n\tvar out;\n\tvar to;\n\tvar M;\n\tvar N;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tM = arr.length;\n\tN = arr[ 0 ].length;\n\n\t// Check whether to store diagonals along the columns...\n\tif ( colexicographic ) {\n\t\tout = zeros2d( [ N, ku+kl+1 ] );\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tto = out[ j ];\n\t\t\tk = ku - j;\n\t\t\tfor ( i = max( 0, j-ku ); i < min( M, j+kl+1 ); i++ ) {\n\t\t\t\tto[ k+i ] = arr[ i ][ j ];\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\t// Store diagonals along the rows...\n\tout = zeros2d( [ ku+kl+1, N ] );\n\tfor ( j = 0; j < N; j++ ) {\n\t\tk = ku - j;\n\t\tfor ( i = max( 0, j-ku ); i < min( M, j+kl+1 ); i++ ) {\n\t\t\tout[ k+i ][ j ] = arr[ i ][ j ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toCompact;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Compute the principal square root of a double-precision floating-point number.\n*\n* @type {Function}\n* @param {number} x - input value\n* @returns {number} principal square root\n*\n* @example\n* var v = sqrt( 4.0 );\n* // returns 2.0\n*\n* v = sqrt( 9.0 );\n* // returns 3.0\n*\n* v = sqrt( 0.0 );\n* // returns 0.0\n*\n* v = sqrt( -4.0 );\n* // returns NaN\n*\n* v = sqrt( NaN );\n* // returns NaN\n*/\nvar sqrt = Math.sqrt; // eslint-disable-line stdlib/no-builtin-math\n\n\n// EXPORTS //\n\nexport default sqrt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isLittleEndian from '@stdlib/assert/is-little-endian';\n\n\n// MAIN //\n\nvar LOW;\nif ( isLittleEndian === true ) {\n\tLOW = 0; // first index\n} else {\n\tLOW = 1; // second index\n}\n\n\n// EXPORTS //\n\nexport default LOW;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float64Array from '@stdlib/array/float64';\nimport LOW from './low.js';\n\n\n// VARIABLES //\n\nvar FLOAT64_VIEW = new Float64Array( 1 );\nvar UINT32_VIEW = new Uint32Array( FLOAT64_VIEW.buffer );\n\n\n// MAIN //\n\n/**\n* Sets the less significant 32 bits of a double-precision floating-point number.\n*\n* ## Notes\n*\n* ```text\n* float64 (64 bits)\n* f := fraction (significand/mantissa) (52 bits)\n* e := exponent (11 bits)\n* s := sign bit (1 bit)\n*\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Float64 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Uint32 | Uint32 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* ```\n*\n* If little endian (more significant bits last):\n*\n* ```text\n* <-- lower higher -->\n* | f7 f6 f5 f4 f3 f2 e2 | f1 |s| e1 |\n* ```\n*\n* If big endian (more significant bits first):\n*\n* ```text\n* <-- higher lower -->\n* |s| e1 e2 | f1 f2 f3 f4 f5 f6 f7 |\n* ```\n*\n* In which Uint32 can we find the lower order bits? If little endian, the first; if big endian, the second.\n*\n* ## References\n*\n* - [Open Group][1]\n*\n* [1]: http://pubs.opengroup.org/onlinepubs/9629399/chap14.htm\n*\n* @param {number} x - double\n* @param {uinteger32} low - unsigned 32-bit integer to replace the lower order word of `x`\n* @returns {number} double having the same higher order word as `x`\n*\n* @example\n* var low = 5 >>> 0; // => 00000000000000000000000000000101\n*\n* var x = 3.14e201; // => 0 11010011100 01001000001011000011 10010011110010110101100010000010\n*\n* var y = setLowWord( x, low ); // => 0 11010011100 01001000001011000011 00000000000000000000000000000101\n* // returns 3.139998651394392e+201\n*\n* @example\n* import PINF from '@stdlib/constants/float64/pinf';\n* import NINF from '@stdlib/constants/float64/ninf';\n*\n* var low = 12345678;\n*\n* var y = setLowWord( PINF, low );\n* // returns NaN\n*\n* y = setLowWord( NINF, low );\n* // returns NaN\n*\n* y = setLowWord( NaN, low );\n* // returns NaN\n*/\nfunction setLowWord( x, low ) {\n\tFLOAT64_VIEW[ 0 ] = x;\n\tUINT32_VIEW[ LOW ] = ( low >>> 0 ); // identity bit shift to ensure integer\n\treturn FLOAT64_VIEW[ 0 ];\n}\n\n\n// EXPORTS //\n\nexport default setLowWord;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts an unsigned 32-bit integer to a signed 32-bit integer.\n*\n* @param {uinteger32} x - unsigned 32-bit integer\n* @returns {integer32} signed 32-bit integer\n*\n* @example\n* import float64ToUint32 from '@stdlib/number/float64/base/to-uint32';\n* var y = uint32ToInt32( float64ToUint32( 4294967295 ) );\n* // returns -1\n*\n* @example\n* import float64ToUint32 from '@stdlib/number/float64/base/to-uint32';\n* var y = uint32ToInt32( float64ToUint32( 3 ) );\n* // returns 3\n*/\nfunction uint32ToInt32( x ) {\n\t// NOTE: we could also use typed-arrays to achieve the same end.\n\treturn x|0; // asm type annotation\n}\n\n\n// EXPORTS //\n\nexport default uint32ToInt32;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* High word mask for excluding the sign bit of a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/high-word-abs-mask\n* @type {uinteger32}\n*\n* @example\n* import FLOAT64_HIGH_WORD_ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\n* // returns 2147483647\n*/\n\n\n// MAIN //\n\n/**\n* High word mask for excluding the sign bit of a double-precision floating-point number.\n*\n* ## Notes\n*\n* The high word mask for excluding the sign bit of a double-precision floating-point number is an unsigned 32-bit integer with the value \\\\( 2147483647 \\\\), which corresponds to the bit sequence\n*\n* ```binarystring\n* 0 11111111111 11111111111111111111\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 0x7fffffff\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_HIGH_WORD_ABS_MASK = 0x7fffffff>>>0; // eslint-disable-line id-length\n\n\n// EXPORTS //\n\nexport default FLOAT64_HIGH_WORD_ABS_MASK;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isLittleEndian from '@stdlib/assert/is-little-endian';\n\n\n// MAIN //\n\nvar indices;\nvar HIGH;\nvar LOW;\n\nif ( isLittleEndian === true ) {\n\tHIGH = 1; // second index\n\tLOW = 0; // first index\n} else {\n\tHIGH = 0; // first index\n\tLOW = 1; // second index\n}\nindices = {\n\t'HIGH': HIGH,\n\t'LOW': LOW\n};\n\n\n// EXPORTS //\n\nexport default indices;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isLittleEndian from '@stdlib/assert/is-little-endian';\n\n\n// MAIN //\n\nvar HIGH;\nif ( isLittleEndian === true ) {\n\tHIGH = 1; // second index\n} else {\n\tHIGH = 0; // first index\n}\n\n\n// EXPORTS //\n\nexport default HIGH;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float64Array from '@stdlib/array/float64';\nimport HIGH from './high.js';\n\n\n// VARIABLES //\n\nvar FLOAT64_VIEW = new Float64Array( 1 );\nvar UINT32_VIEW = new Uint32Array( FLOAT64_VIEW.buffer );\n\n\n// MAIN //\n\n/**\n* Returns an unsigned 32-bit integer corresponding to the more significant 32 bits of a double-precision floating-point number.\n*\n* ## Notes\n*\n* ```text\n* float64 (64 bits)\n* f := fraction (significand/mantissa) (52 bits)\n* e := exponent (11 bits)\n* s := sign bit (1 bit)\n*\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Float64 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Uint32 | Uint32 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* ```\n*\n* If little endian (more significant bits last):\n*\n* ```text\n* <-- lower higher -->\n* | f7 f6 f5 f4 f3 f2 e2 | f1 |s| e1 |\n* ```\n*\n* If big endian (more significant bits first):\n*\n* ```text\n* <-- higher lower -->\n* |s| e1 e2 | f1 f2 f3 f4 f5 f6 f7 |\n* ```\n*\n* In which Uint32 can we find the higher order bits? If little endian, the second; if big endian, the first.\n*\n* ## References\n*\n* - [Open Group][1]\n*\n* [1]: http://pubs.opengroup.org/onlinepubs/9629399/chap14.htm\n*\n* @param {number} x - input value\n* @returns {uinteger32} higher order word\n*\n* @example\n* var w = getHighWord( 3.14e201 ); // => 01101001110001001000001011000011\n* // returns 1774486211\n*/\nfunction getHighWord( x ) {\n\tFLOAT64_VIEW[ 0 ] = x;\n\treturn UINT32_VIEW[ HIGH ];\n}\n\n\n// EXPORTS //\n\nexport default getHighWord;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float64Array from '@stdlib/array/float64';\nimport indices from './indices.js';\n\n\n// VARIABLES //\n\nvar FLOAT64_VIEW = new Float64Array( 1 );\nvar UINT32_VIEW = new Uint32Array( FLOAT64_VIEW.buffer );\n\nvar HIGH = indices.HIGH;\nvar LOW = indices.LOW;\n\n\n// MAIN //\n\n/**\n* Creates a double-precision floating-point number from a higher order word (unsigned 32-bit integer) and a lower order word (unsigned 32-bit integer).\n*\n* ## Notes\n*\n* ```text\n* float64 (64 bits)\n* f := fraction (significand/mantissa) (52 bits)\n* e := exponent (11 bits)\n* s := sign bit (1 bit)\n*\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Float64 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Uint32 | Uint32 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* ```\n*\n* If little endian (more significant bits last):\n*\n* ```text\n* <-- lower higher -->\n* | f7 f6 f5 f4 f3 f2 e2 | f1 |s| e1 |\n* ```\n*\n* If big endian (more significant bits first):\n*\n* ```text\n* <-- higher lower -->\n* |s| e1 e2 | f1 f2 f3 f4 f5 f6 f7 |\n* ```\n*\n* In which Uint32 should we place the higher order bits? If little endian, the second; if big endian, the first.\n*\n* ## References\n*\n* - [Open Group][1]\n*\n* [1]: http://pubs.opengroup.org/onlinepubs/9629399/chap14.htm\n*\n* @param {uinteger32} high - higher order word (unsigned 32-bit integer)\n* @param {uinteger32} low - lower order word (unsigned 32-bit integer)\n* @returns {number} floating-point number\n*\n* @example\n* var v = fromWords( 1774486211, 2479577218 );\n* // returns 3.14e201\n*\n* @example\n* var v = fromWords( 3221823995, 1413754136 );\n* // returns -3.141592653589793\n*\n* @example\n* var v = fromWords( 0, 0 );\n* // returns 0.0\n*\n* @example\n* var v = fromWords( 2147483648, 0 );\n* // returns -0.0\n*\n* @example\n* var v = fromWords( 2146959360, 0 );\n* // returns NaN\n*\n* @example\n* var v = fromWords( 2146435072, 0 );\n* // returns Infinity\n*\n* @example\n* var v = fromWords( 4293918720, 0 );\n* // returns -Infinity\n*/\nfunction fromWords( high, low ) {\n\tUINT32_VIEW[ HIGH ] = high;\n\tUINT32_VIEW[ LOW ] = low;\n\treturn FLOAT64_VIEW[ 0 ];\n}\n\n\n// EXPORTS //\n\nexport default fromWords;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport SIGN_MASK from '@stdlib/constants/float64/high-word-sign-mask';\nimport ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\nimport toWords from '@stdlib/number/float64/base/to-words';\nimport getHighWord from '@stdlib/number/float64/base/get-high-word';\nimport fromWords from '@stdlib/number/float64/base/from-words';\n\n\n// VARIABLES //\n\n// High/low words workspace:\nvar WORDS = [ 0, 0 ];\n\n\n// MAIN //\n\n/**\n* Returns a double-precision floating-point number with the magnitude of `x` and the sign of `y`.\n*\n* @param {number} x - number from which to derive a magnitude\n* @param {number} y - number from which to derive a sign\n* @returns {number} a double-precision floating-point number\n*\n* @example\n* var z = copysign( -3.14, 10.0 );\n* // returns 3.14\n*\n* @example\n* var z = copysign( 3.14, -1.0 );\n* // returns -3.14\n*\n* @example\n* var z = copysign( 1.0, -0.0 );\n* // returns -1.0\n*\n* @example\n* var z = copysign( -3.14, -0.0 );\n* // returns -3.14\n*\n* @example\n* var z = copysign( -0.0, 1.0 );\n* // returns 0.0\n*/\nfunction copysign( x, y ) {\n\tvar hx;\n\tvar hy;\n\n\t// Split `x` into higher and lower order words:\n\ttoWords.assign( x, WORDS, 1, 0 );\n\thx = WORDS[ 0 ];\n\n\t// Turn off the sign bit of `x`:\n\thx &= ABS_MASK;\n\n\t// Extract the higher order word from `y`:\n\thy = getHighWord( y );\n\n\t// Leave only the sign bit of `y` turned on:\n\thy &= SIGN_MASK;\n\n\t// Copy the sign bit of `y` to `x`:\n\thx |= hy;\n\n\t// Return a new value having the same magnitude as `x`, but with the sign of `y`:\n\treturn fromWords( hx, WORDS[ 1 ] );\n}\n\n\n// EXPORTS //\n\nexport default copysign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\nimport getHighWord from '@stdlib/number/float64/base/get-high-word';\n\n\n// VARIABLES //\n\n// 0x3fefffff = 1072693247 => 0 01111111110 11111111111111111111 => biased exponent: 1022 = -1+1023 => 2^-1\nvar HIGH_MAX_NEAR_UNITY = 0x3fefffff|0; // asm type annotation\n\nvar HUGE = 1.0e300;\nvar TINY = 1.0e-300;\n\n\n// MAIN //\n\n/**\n* Evaluates the exponential function when \\\\(|y| > 2^64\\\\).\n*\n* @private\n* @param {number} x - base\n* @param {number} y - exponent\n* @returns {number} overflow or underflow result\n*\n* @example\n* var v = pow( 9.0, 3.6893488147419103e19 );\n* // returns Infinity\n*\n* @example\n* var v = pow( -3.14, -3.6893488147419103e19 );\n* // returns 0.0\n*/\nfunction pow( x, y ) {\n\tvar ahx;\n\tvar hx;\n\n\thx = getHighWord( x );\n\tahx = (hx & ABS_MASK);\n\n\tif ( ahx <= HIGH_MAX_NEAR_UNITY ) {\n\t\tif ( y < 0 ) {\n\t\t\t// Signal overflow...\n\t\t\treturn HUGE * HUGE;\n\t\t}\n\t\t// Signal underflow...\n\t\treturn TINY * TINY;\n\t}\n\t// `x` has a biased exponent greater than or equal to `0`...\n\n\tif ( y > 0 ) {\n\t\t// Signal overflow...\n\t\treturn HUGE * HUGE;\n\t}\n\t// Signal underflow...\n\treturn TINY * TINY;\n}\n\n\n// EXPORTS //\n\nexport default pow;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isLittleEndian from '@stdlib/assert/is-little-endian';\n\n\n// MAIN //\n\nvar HIGH;\nif ( isLittleEndian === true ) {\n\tHIGH = 1; // second index\n} else {\n\tHIGH = 0; // first index\n}\n\n\n// EXPORTS //\n\nexport default HIGH;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float64Array from '@stdlib/array/float64';\nimport HIGH from './high.js';\n\n\n// VARIABLES //\n\nvar FLOAT64_VIEW = new Float64Array( 1 );\nvar UINT32_VIEW = new Uint32Array( FLOAT64_VIEW.buffer );\n\n\n// MAIN //\n\n/**\n* Sets the more significant 32 bits of a double-precision floating-point number.\n*\n* ## Notes\n*\n* ```text\n* float64 (64 bits)\n* f := fraction (significand/mantissa) (52 bits)\n* e := exponent (11 bits)\n* s := sign bit (1 bit)\n*\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Float64 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* | Uint32 | Uint32 |\n* |-------- -------- -------- -------- -------- -------- -------- --------|\n* ```\n*\n* If little endian (more significant bits last):\n*\n* ```text\n* <-- lower higher -->\n* | f7 f6 f5 f4 f3 f2 e2 | f1 |s| e1 |\n* ```\n*\n* If big endian (more significant bits first):\n*\n* ```text\n* <-- higher lower -->\n* |s| e1 e2 | f1 f2 f3 f4 f5 f6 f7 |\n* ```\n*\n* In which Uint32 can we find the higher order bits? If little endian, the second; if big endian, the first.\n*\n* ## References\n*\n* - [Open Group][1]\n*\n* [1]: http://pubs.opengroup.org/onlinepubs/9629399/chap14.htm\n*\n* @param {number} x - double\n* @param {uinteger32} high - unsigned 32-bit integer to replace the higher order word of `x`\n* @returns {number} double having the same lower order word as `x`\n*\n* @example\n* var high = 5 >>> 0; // => 0 00000000000 00000000000000000101\n*\n* var y = setHighWord( 3.14e201, high ); // => 0 00000000000 0000000000000000010110010011110010110101100010000010\n* // returns 1.18350528745e-313\n*\n* @example\n* import PINF from '@stdlib/constants/float64/pinf'; // => 0 11111111111 00000000000000000000 00000000000000000000000000000000\n*\n* var high = 1072693248 >>> 0; // => 0 01111111111 00000000000000000000\n*\n* // Set the higher order bits of `+infinity` to return `1`:\n* var y = setHighWord( PINF, high ); // => 0 01111111111 0000000000000000000000000000000000000000000000000000\n* // returns 1.0\n*/\nfunction setHighWord( x, high ) {\n\tFLOAT64_VIEW[ 0 ] = x;\n\tUINT32_VIEW[ HIGH ] = ( high >>> 0 ); // identity bit shift to ensure integer\n\treturn FLOAT64_VIEW[ 0 ];\n}\n\n\n// EXPORTS //\n\nexport default setHighWord;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* The bias of a double-precision floating-point number's exponent.\n*\n* @module @stdlib/constants/float64/exponent-bias\n* @type {integer32}\n*\n* @example\n* import FLOAT64_EXPONENT_BIAS from '@stdlib/constants/float64/exponent-bias';\n* // returns 1023\n*/\n\n\n// MAIN //\n\n/**\n* Bias of a double-precision floating-point number's exponent.\n*\n* ## Notes\n*\n* The bias can be computed via\n*\n* ```tex\n* \\mathrm{bias} = 2^{k-1} - 1\n* ```\n*\n* where \\\\(k\\\\) is the number of bits in the exponent; here, \\\\(k = 11\\\\).\n*\n* @constant\n* @type {integer32}\n* @default 1023\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_EXPONENT_BIAS = 1023|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default FLOAT64_EXPONENT_BIAS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Number of significand bits in the high word of a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/num-high-word-significand-bits\n* @type {integer32}\n*\n* @example\n* import FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS from '@stdlib/constants/float64/num-high-word-significand-bits';\n* // returns 20\n*/\n\n\n// MAIN //\n\n/**\n* Number of significand bits in the high word of a double-precision floating-point number.\n*\n* @constant\n* @type {integer32}\n* @default 20\n*/\nvar FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS = 20|0; // eslint-disable-line id-length\n\n\n// EXPORTS //\n\nexport default FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getHighWord from '@stdlib/number/float64/base/get-high-word';\nimport setLowWord from '@stdlib/number/float64/base/set-low-word';\nimport setHighWord from '@stdlib/number/float64/base/set-high-word';\nimport BIAS from '@stdlib/constants/float64/exponent-bias';\nimport HIGH_NUM_SIGNIFICAND_BITS from '@stdlib/constants/float64/num-high-word-significand-bits';\nimport polyvalL from './polyval_l.js';\n\n\n// VARIABLES //\n\n// 0x000fffff = 1048575 => 0 00000000000 11111111111111111111\nvar HIGH_SIGNIFICAND_MASK = 0x000fffff|0; // asm type annotation\n\n// 0x00100000 = 1048576 => 0 00000000001 00000000000000000000 => biased exponent: 1 = -1022+1023 => 2^-1022\nvar HIGH_MIN_NORMAL_EXP = 0x00100000|0; // asm type annotation\n\n// 0x3ff00000 = 1072693248 => 0 01111111111 00000000000000000000 => biased exponent: 1023 = 0+1023 => 2^0 = 1\nvar HIGH_BIASED_EXP_0 = 0x3ff00000|0; // asm type annotation\n\n// 0x20000000 = 536870912 => 0 01000000000 00000000000000000000 => biased exponent: 512 = -511+1023\nvar HIGH_BIASED_EXP_NEG_512 = 0x20000000|0; // asm type annotation\n\n// 0x00080000 = 524288 => 0 00000000000 10000000000000000000\nvar HIGH_SIGNIFICAND_HALF = 0x00080000|0; // asm type annotation\n\nvar TWO53 = 9007199254740992.0;\t// 0x43400000, 0x00000000\n\n// 2/(3*LN2)\nvar CP = 9.61796693925975554329e-01; // 0x3FEEC709, 0xDC3A03FD\n\n// (float)CP\nvar CP_HI = 9.61796700954437255859e-01; // 0x3FEEC709, 0xE0000000\n\n// Low: CP_HI\nvar CP_LO = -7.02846165095275826516e-09; // 0xBE3E2FE0, 0x145B01F5\n\nvar BP = [\n\t1.0,\n\t1.5\n];\nvar DP_HI = [\n\t0.0,\n\t5.84962487220764160156e-01 // 0x3FE2B803, 0x40000000\n];\nvar DP_LO = [\n\t0.0,\n\t1.35003920212974897128e-08 // 0x3E4CFDEB, 0x43CFD006\n];\n\n\n// MAIN //\n\n/**\n* Computes \\\\(\\operatorname{log2}(ax)\\\\).\n*\n* @private\n* @param {Array} out - output array\n* @param {number} ax - absolute value of `x`\n* @param {number} ahx - high word of `ax`\n* @returns {Array} output array containing a tuple comprised of high and low parts\n*\n* @example\n* var t = log2ax( [ 0.0, 0.0 ], 9.0, 1075970048 ); // => [ t1, t2 ]\n* // returns [ 3.169923782348633, 0.0000012190936795504075 ]\n*/\nfunction log2ax( out, ax, ahx ) {\n\tvar tmp;\n\tvar ss; // `hs + ls`\n\tvar s2; // `ss` squared\n\tvar hs;\n\tvar ls;\n\tvar ht;\n\tvar lt;\n\tvar bp; // `BP` constant\n\tvar dp; // `DP` constant\n\tvar hp;\n\tvar lp;\n\tvar hz;\n\tvar lz;\n\tvar t1;\n\tvar t2;\n\tvar t;\n\tvar r;\n\tvar u;\n\tvar v;\n\tvar n;\n\tvar j;\n\tvar k;\n\n\tn = 0|0; // asm type annotation\n\n\t// Check if `x` is subnormal...\n\tif ( ahx < HIGH_MIN_NORMAL_EXP ) {\n\t\tax *= TWO53;\n\t\tn -= 53|0; // asm type annotation\n\t\tahx = getHighWord( ax );\n\t}\n\t// Extract the unbiased exponent of `x`:\n\tn += ((ahx >> HIGH_NUM_SIGNIFICAND_BITS) - BIAS)|0; // asm type annotation\n\n\t// Isolate the significand bits of `x`:\n\tj = (ahx & HIGH_SIGNIFICAND_MASK)|0; // asm type annotation\n\n\t// Normalize `ahx` by setting the (biased) exponent to `1023`:\n\tahx = (j | HIGH_BIASED_EXP_0)|0; // asm type annotation\n\n\t// Determine the interval of `|x|` by comparing significand bits...\n\n\t// |x| < sqrt(3/2)\n\tif ( j <= 0x3988E ) { // 0 00000000000 00111001100010001110\n\t\tk = 0;\n\t}\n\t// |x| < sqrt(3)\n\telse if ( j < 0xBB67A ) { // 0 00000000000 10111011011001111010\n\t\tk = 1;\n\t}\n\t// |x| >= sqrt(3)\n\telse {\n\t\tk = 0;\n\t\tn += 1|0; // asm type annotation\n\t\tahx -= HIGH_MIN_NORMAL_EXP;\n\t}\n\t// Load the normalized high word into `|x|`:\n\tax = setHighWord( ax, ahx );\n\n\t// Compute `ss = hs + ls = (x-1)/(x+1)` or `(x-1.5)/(x+1.5)`:\n\tbp = BP[ k ]; // BP[0] = 1.0, BP[1] = 1.5\n\tu = ax - bp; // (x-1) || (x-1.5)\n\tv = 1.0 / (ax + bp); // 1/(x+1) || 1/(x+1.5)\n\tss = u * v;\n\ths = setLowWord( ss, 0 ); // set all low word (less significant significand) bits to 0s\n\n\t// Compute `ht = ax + bp` (via manipulation, i.e., bit flipping, of the high word):\n\ttmp = ((ahx>>1) | HIGH_BIASED_EXP_NEG_512) + HIGH_SIGNIFICAND_HALF;\n\ttmp += (k << 18); // `(k<<18)` can be considered the word equivalent of `1.0` or `1.5`\n\tht = setHighWord( 0.0, tmp );\n\tlt = ax - (ht - bp);\n\tls = v * ( ( u - (hs*ht) ) - ( hs*lt ) );\n\n\t// Compute `log(ax)`...\n\n\ts2 = ss * ss;\n\tr = s2 * s2 * polyvalL( s2 );\n\tr += ls * (hs + ss);\n\ts2 = hs * hs;\n\tht = 3.0 + s2 + r;\n\tht = setLowWord( ht, 0 );\n\tlt = r - ((ht-3.0) - s2);\n\n\t// u+v = ss*(1+...):\n\tu = hs * ht;\n\tv = ( ls*ht ) + ( lt*ss );\n\n\t// 2/(3LN2) * (ss+...):\n\thp = u + v;\n\thp = setLowWord( hp, 0 );\n\tlp = v - (hp - u);\n\thz = CP_HI * hp; // CP_HI+CP_LO = 2/(3*LN2)\n\tlz = ( CP_LO*hp ) + ( lp*CP ) + DP_LO[ k ];\n\n\t// log2(ax) = (ss+...)*2/(3*LN2) = n + dp + hz + lz\n\tdp = DP_HI[ k ];\n\tt = n;\n\tt1 = ((hz+lz) + dp) + t; // log2(ax)\n\tt1 = setLowWord( t1, 0 );\n\tt2 = lz - (((t1-t) - dp) - hz);\n\n\tout[ 0 ] = t1;\n\tout[ 1 ] = t2;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default log2ax;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setLowWord from '@stdlib/number/float64/base/set-low-word';\nimport polyvalW from './polyval_w.js';\n\n\n// VARIABLES //\n\n// 1/LN2\nvar INV_LN2 = 1.44269504088896338700e+00; // 0x3FF71547, 0x652B82FE\n\n// High (24 bits): 1/LN2\nvar INV_LN2_HI = 1.44269502162933349609e+00; // 0x3FF71547, 0x60000000\n\n// Low: 1/LN2\nvar INV_LN2_LO = 1.92596299112661746887e-08; // 0x3E54AE0B, 0xF85DDF44\n\n\n// MAIN //\n\n/**\n* Computes \\\\(\\operatorname{log}(x)\\\\) assuming \\\\(|1-x|\\\\) is small and using the approximation \\\\(x - x^2/2 + x^3/3 - x^4/4\\\\).\n*\n* @private\n* @param {Array} out - output array\n* @param {number} ax - absolute value of `x`\n* @returns {Array} output array containing a tuple comprised of high and low parts\n*\n* @example\n* var t = logx( [ 0.0, 0.0 ], 9.0 ); // => [ t1, t2 ]\n* // returns [ -1265.7236328125, -0.0008163940840404393 ]\n*/\nfunction logx( out, ax ) {\n\tvar t2;\n\tvar t1;\n\tvar t;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tt = ax - 1.0; // `t` has `20` trailing zeros\n\tw = t * t * polyvalW( t );\n\tu = INV_LN2_HI * t; // `INV_LN2_HI` has `21` significant bits\n\tv = ( t*INV_LN2_LO ) - ( w*INV_LN2 );\n\tt1 = u + v;\n\tt1 = setLowWord( t1, 0 );\n\tt2 = v - (t1 - u);\n\n\tout[ 0 ] = t1;\n\tout[ 1 ] = t2;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default logx;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* The maximum biased base 2 exponent for a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/max-base2-exponent\n* @type {integer32}\n*\n* @example\n* import FLOAT64_MAX_BASE2_EXPONENT from '@stdlib/constants/float64/max-base2-exponent';\n* // returns 1023\n*/\n\n\n// MAIN //\n\n/**\n* The maximum biased base 2 exponent for a double-precision floating-point number.\n*\n* ```text\n* 11111111110 => 2046 - BIAS = 1023\n* ```\n*\n* where `BIAS = 1023`.\n*\n* @constant\n* @type {integer32}\n* @default 1023\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_MAX_BASE2_EXPONENT = 1023|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default FLOAT64_MAX_BASE2_EXPONENT;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* The maximum biased base 2 exponent for a subnormal double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/max-base2-exponent-subnormal\n* @type {integer32}\n*\n* @example\n* import FLOAT64_MAX_BASE2_EXPONENT_SUBNORMAL from '@stdlib/constants/float64/max-base2-exponent-subnormal';\n* // returns -1023\n*/\n\n\n// MAIN //\n\n/**\n* The maximum biased base 2 exponent for a subnormal double-precision floating-point number.\n*\n* ```text\n* 00000000000 => 0 - BIAS = -1023\n* ```\n*\n* where `BIAS = 1023`.\n*\n* @constant\n* @type {integer32}\n* @default -1023\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_MAX_BASE2_EXPONENT_SUBNORMAL = -1023|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default FLOAT64_MAX_BASE2_EXPONENT_SUBNORMAL;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* The minimum biased base 2 exponent for a subnormal double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/min-base2-exponent-subnormal\n* @type {integer32}\n*\n* @example\n* import FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL from '@stdlib/constants/float64/min-base2-exponent-subnormal';\n* // returns -1074\n*/\n\n\n// MAIN //\n\n/**\n* The minimum biased base 2 exponent for a subnormal double-precision floating-point number.\n*\n* ```text\n* -(BIAS+(52-1)) = -(1023+51) = -1074\n* ```\n*\n* where `BIAS = 1023` and `52` is the number of digits in the significand.\n*\n* @constant\n* @type {integer32}\n* @default -1074\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL = -1074|0; // asm type annotation\n\n\n// EXPORTS //\n\nexport default FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Smallest positive double-precision floating-point normal number.\n*\n* @module @stdlib/constants/float64/smallest-normal\n* @type {number}\n*\n* @example\n* import FLOAT64_SMALLEST_NORMAL from '@stdlib/constants/float64/smallest-normal';\n* // returns 2.2250738585072014e-308\n*/\n\n\n// MAIN //\n\n/**\n* The smallest positive double-precision floating-point normal number.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* \\frac{1}{2^{1023-1}}\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 0 00000000001 00000000000000000000 00000000000000000000000000000000\n* ```\n*\n* @constant\n* @type {number}\n* @default 2.2250738585072014e-308\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_SMALLEST_NORMAL = 2.2250738585072014e-308;\n\n\n// EXPORTS //\n\nexport default FLOAT64_SMALLEST_NORMAL;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport FLOAT64_SMALLEST_NORMAL from '@stdlib/constants/float64/smallest-normal';\nimport isInfinite from '@stdlib/math/base/assert/is-infinite';\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport abs from '@stdlib/math/base/special/abs';\n\n\n// VARIABLES //\n\n// (1<<52)\nvar SCALAR = 4503599627370496;\n\n\n// MAIN //\n\n/**\n* Returns a normal number `y` and exponent `exp` satisfying \\\\(x = y \\cdot 2^\\mathrm{exp}\\\\) and assigns results to a provided output array.\n*\n* @param {number} x - input value\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import pow from '@stdlib/math/base/special/pow';\n*\n* var out = normalize( 3.14e-319, [ 0.0, 0 ], 1, 0 );\n* // returns [ 1.4141234400356668e-303, -52 ]\n*\n* var y = out[ 0 ];\n* var exp = out[ 1 ];\n*\n* var bool = ( y*pow(2.0,exp) === 3.14e-319 );\n* // returns true\n*\n* @example\n* var out = normalize( 0.0, [ 0.0, 0 ], 1, 0 );\n* // returns [ 0.0, 0 ];\n*\n* @example\n* import PINF from '@stdlib/constants/float64/pinf';\n*\n* var out = normalize( PINF, [ 0.0, 0 ], 1, 0 );\n* // returns [ Infinity, 0 ]\n*\n* @example\n* import NINF from '@stdlib/constants/float64/ninf';\n*\n* var out = normalize( NINF, [ 0.0, 0 ], 1, 0 );\n* // returns [ -Infinity, 0 ]\n*\n* @example\n* var out = normalize( NaN, [ 0.0, 0 ], 1, 0 );\n* // returns [ NaN, 0 ]\n*/\nfunction normalize( x, out, stride, offset ) {\n\tif ( isnan( x ) || isInfinite( x ) ) {\n\t\tout[ offset ] = x;\n\t\tout[ offset + stride ] = 0;\n\t\treturn out;\n\t}\n\tif ( x !== 0.0 && abs( x ) < FLOAT64_SMALLEST_NORMAL ) {\n\t\tout[ offset ] = x * SCALAR;\n\t\tout[ offset + stride ] = -52;\n\t\treturn out;\n\t}\n\tout[ offset ] = x;\n\tout[ offset + stride ] = 0;\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return a normal number `y` and exponent `exp` satisfying \\\\(x = y \\cdot 2^\\mathrm{exp}\\\\).\n*\n* @module @stdlib/number/float64/base/normalize\n*\n* @example\n* import normalize from '@stdlib/number/float64/base/normalize';\n* import pow from '@stdlib/math/base/special/pow';\n*\n* var out = normalize( 3.14e-319 );\n* // returns [ 1.4141234400356668e-303, -52 ]\n*\n* var y = out[ 0 ];\n* var exp = out[ 1 ];\n*\n* var bool = ( y*pow(2.0, exp) === 3.14e-319 );\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import normalize from '@stdlib/number/float64/base/normalize';\n*\n* var out = new Float64Array( 2 );\n*\n* var v = normalize.assign( 3.14e-319, out, 1, 0 );\n* // returns [ 1.4141234400356668e-303, -52 ]\n*\n* var bool = ( v === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fcn from './assign.js';\n\n\n// MAIN //\n\n/**\n* Returns a normal number `y` and exponent `exp` satisfying \\\\(x = y \\cdot 2^\\mathrm{exp}\\\\).\n*\n* @param {number} x - input value\n* @returns {NumberArray} output array\n*\n* @example\n* import pow from '@stdlib/math/base/special/pow';\n*\n* var out = normalize( 3.14e-319 );\n* // returns [ 1.4141234400356668e-303, -52 ]\n*\n* var y = out[ 0 ];\n* var exp = out[ 1 ];\n*\n* var bool = ( y*pow(2.0,exp) === 3.14e-319 );\n* // returns true\n*\n* @example\n* var out = normalize( 0.0 );\n* // returns [ 0.0, 0 ]\n*\n* @example\n* import PINF from '@stdlib/constants/float64/pinf';\n*\n* var out = normalize( PINF );\n* // returns [ Infinity, 0 ]\n*\n* @example\n* import NINF from '@stdlib/constants/float64/ninf';\n*\n* var out = normalize( NINF );\n* // returns [ -Infinity, 0 ]\n*\n* @example\n* var out = normalize( NaN );\n* // returns [ NaN, 0 ]\n*/\nfunction normalize( x ) {\n\treturn fcn( x, [ 0.0, 0 ], 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default normalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* High word mask for the exponent of a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/high-word-exponent-mask\n* @type {uinteger32}\n*\n* @example\n* import FLOAT64_HIGH_WORD_EXPONENT_MASK from '@stdlib/constants/float64/high-word-exponent-mask';\n* // returns 2146435072\n*/\n\n\n// MAIN //\n\n/**\n* High word mask for the exponent of a double-precision floating-point number.\n*\n* ## Notes\n*\n* The high word mask for the exponent of a double-precision floating-point number is an unsigned 32-bit integer with the value \\\\( 2146435072 \\\\), which corresponds to the bit sequence\n*\n* ```binarystring\n* 0 11111111111 00000000000000000000\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 0x7ff00000\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_HIGH_WORD_EXPONENT_MASK = 0x7ff00000;\n\n\n// EXPORTS //\n\nexport default FLOAT64_HIGH_WORD_EXPONENT_MASK;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// NOTES //\n\n/*\n* => ldexp: load exponent (see [The Open Group]{@link http://pubs.opengroup.org/onlinepubs/9699919799/functions/ldexp.html} and [cppreference]{@link http://en.cppreference.com/w/c/numeric/math/ldexp}).\n*/\n\n\n// MODULES //\n\nimport PINF from '@stdlib/constants/float64/pinf';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport BIAS from '@stdlib/constants/float64/exponent-bias';\nimport MAX_EXPONENT from '@stdlib/constants/float64/max-base2-exponent';\nimport MAX_SUBNORMAL_EXPONENT from '@stdlib/constants/float64/max-base2-exponent-subnormal';\nimport MIN_SUBNORMAL_EXPONENT from '@stdlib/constants/float64/min-base2-exponent-subnormal';\nimport isnan from './../../../../base/assert/is-nan';\nimport isInfinite from './../../../../base/assert/is-infinite';\nimport copysign from './../../../../base/special/copysign';\nimport { assign as normalize } from '@stdlib/number/float64/base/normalize';\nimport floatExp from '@stdlib/number/float64/base/exponent';\nimport toWords from '@stdlib/number/float64/base/to-words';\nimport fromWords from '@stdlib/number/float64/base/from-words';\n\n\n// VARIABLES //\n\n// 1/(1<<52) = 1/(2**52) = 1/4503599627370496\nvar TWO52_INV = 2.220446049250313e-16;\n\n// Exponent all 0s: 1 00000000000 11111111111111111111 => 2148532223\nvar CLEAR_EXP_MASK = 0x800fffff>>>0; // asm type annotation\n\n// Normalization workspace:\nvar FRAC = [ 0.0, 0.0 ];\n\n// High/low words workspace:\nvar WORDS = [ 0, 0 ];\n\n\n// MAIN //\n\n/**\n* Multiplies a double-precision floating-point number by an integer power of two.\n*\n* @param {number} frac - fraction\n* @param {integer} exp - exponent\n* @returns {number} double-precision floating-point number\n*\n* @example\n* var x = ldexp( 0.5, 3 ); // => 0.5 * 2^3 = 0.5 * 8\n* // returns 4.0\n*\n* @example\n* var x = ldexp( 4.0, -2 ); // => 4 * 2^(-2) = 4 * (1/4)\n* // returns 1.0\n*\n* @example\n* var x = ldexp( 0.0, 20 );\n* // returns 0.0\n*\n* @example\n* var x = ldexp( -0.0, 39 );\n* // returns -0.0\n*\n* @example\n* var x = ldexp( NaN, -101 );\n* // returns NaN\n*\n* @example\n* var x = ldexp( Infinity, 11 );\n* // returns Infinity\n*\n* @example\n* var x = ldexp( -Infinity, -118 );\n* // returns -Infinity\n*/\nfunction ldexp( frac, exp ) {\n\tvar high;\n\tvar m;\n\tif (\n\t\texp === 0 ||\n\t\tfrac === 0.0 || // handles +-0\n\t\tisnan( frac ) ||\n\t\tisInfinite( frac )\n\t) {\n\t\treturn frac;\n\t}\n\t// Normalize the input fraction:\n\tnormalize( frac, FRAC, 1, 0 );\n\tfrac = FRAC[ 0 ];\n\texp += FRAC[ 1 ];\n\n\t// Extract the exponent from `frac` and add it to `exp`:\n\texp += floatExp( frac );\n\n\t// Check for underflow/overflow...\n\tif ( exp < MIN_SUBNORMAL_EXPONENT ) {\n\t\treturn copysign( 0.0, frac );\n\t}\n\tif ( exp > MAX_EXPONENT ) {\n\t\tif ( frac < 0.0 ) {\n\t\t\treturn NINF;\n\t\t}\n\t\treturn PINF;\n\t}\n\t// Check for a subnormal and scale accordingly to retain precision...\n\tif ( exp <= MAX_SUBNORMAL_EXPONENT ) {\n\t\texp += 52;\n\t\tm = TWO52_INV;\n\t} else {\n\t\tm = 1.0;\n\t}\n\t// Split the fraction into higher and lower order words:\n\ttoWords.assign( frac, WORDS, 1, 0 );\n\thigh = WORDS[ 0 ];\n\n\t// Clear the exponent bits within the higher order word:\n\thigh &= CLEAR_EXP_MASK;\n\n\t// Set the exponent bits to the new exponent:\n\thigh |= ((exp+BIAS) << 20);\n\n\t// Create a new floating-point number:\n\treturn m * fromWords( high, WORDS[ 1 ] );\n}\n\n\n// EXPORTS //\n\nexport default ldexp;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getHighWord from './../../../../float64/base/get-high-word';\nimport EXP_MASK from '@stdlib/constants/float64/high-word-exponent-mask';\nimport BIAS from '@stdlib/constants/float64/exponent-bias';\n\n\n// MAIN //\n\n/**\n* Returns an integer corresponding to the unbiased exponent of a double-precision floating-point number.\n*\n* @param {number} x - input value\n* @returns {integer32} unbiased exponent\n*\n* @example\n* var exp = exponent( 3.14e-307 ); // => 2**-1019 ~ 1e-307\n* // returns -1019\n*\n* @example\n* var exp = exponent( -3.14 );\n* // returns 1\n*\n* @example\n* var exp = exponent( 0.0 );\n* // returns -1023\n*\n* @example\n* var exp = exponent( NaN );\n* // returns 1024\n*/\nfunction exponent( x ) {\n\t// Extract from the input value a higher order word (unsigned 32-bit integer) which contains the exponent:\n\tvar high = getHighWord( x );\n\n\t// Apply a mask to isolate only the exponent bits and then shift off all bits which are part of the fraction:\n\thigh = ( high & EXP_MASK ) >>> 20;\n\n\t// Remove the bias and return:\n\treturn (high - BIAS)|0; // asm type annotation\n}\n\n\n// EXPORTS //\n\nexport default exponent;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Natural logarithm of `2`.\n*\n* @module @stdlib/constants/float64/ln-two\n* @type {number}\n*\n* @example\n* import LN2 from '@stdlib/constants/float64/ln-two';\n* // returns 0.6931471805599453\n*/\n\n\n// MAIN //\n\n/**\n* Natural logarithm of `2`.\n*\n* ```tex\n* \\ln 2\n* ```\n*\n* @constant\n* @type {number}\n* @default 0.6931471805599453\n*/\nvar LN2 = 6.93147180559945309417232121458176568075500134360255254120680009493393621969694715605863326996418687542001481021e-01; // eslint-disable-line max-len\n\n\n// EXPORTS //\n\nexport default LN2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* High word mask for the significand of a double-precision floating-point number.\n*\n* @module @stdlib/constants/float64/high-word-significand-mask\n* @type {uinteger32}\n*\n* @example\n* import FLOAT64_HIGH_WORD_SIGNIFICAND_MASK from '@stdlib/constants/float64/high-word-significand-mask';\n* // returns 1048575\n*/\n\n\n// MAIN //\n\n/**\n* High word mask for the significand of a double-precision floating-point number.\n*\n* ## Notes\n*\n* The high word mask for the significand of a double-precision floating-point number is an unsigned 32-bit integer with the value \\\\( 1048575 \\\\), which corresponds to the bit sequence\n*\n* ```binarystring\n* 0 00000000000 11111111111111111111\n* ```\n*\n* @constant\n* @type {uinteger32}\n* @default 0x000fffff\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT64_HIGH_WORD_SIGNIFICAND_MASK = 0x000fffff;\n\n\n// EXPORTS //\n\nexport default FLOAT64_HIGH_WORD_SIGNIFICAND_MASK;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getHighWord from '@stdlib/number/float64/base/get-high-word';\nimport setHighWord from '@stdlib/number/float64/base/set-high-word';\nimport setLowWord from '@stdlib/number/float64/base/set-low-word';\nimport uint32ToInt32 from '@stdlib/number/uint32/base/to-int32';\nimport ldexp from './../../../../base/special/ldexp';\nimport LN2 from '@stdlib/constants/float64/ln-two';\nimport BIAS from '@stdlib/constants/float64/exponent-bias';\nimport ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\nimport HIGH_SIGNIFICAND_MASK from '@stdlib/constants/float64/high-word-significand-mask';\nimport HIGH_NUM_SIGNIFICAND_BITS from '@stdlib/constants/float64/num-high-word-significand-bits';\nimport polyvalP from './polyval_p.js';\n\n\n// VARIABLES //\n\n// 0x00100000 = 1048576 => 0 00000000001 00000000000000000000 => biased exponent: 1 = -1022+1023 => 2^-1022\nvar HIGH_MIN_NORMAL_EXP = 0x00100000|0; // asm type annotation\n\n// 0x3fe00000 = 1071644672 => 0 01111111110 00000000000000000000 => biased exponent: 1022 = -1+1023 => 2^-1\nvar HIGH_BIASED_EXP_NEG_1 = 0x3fe00000|0; // asm type annotation\n\n// High: LN2\nvar LN2_HI = 6.93147182464599609375e-01; // 0x3FE62E43, 0x00000000\n\n// Low: LN2\nvar LN2_LO = -1.90465429995776804525e-09; // 0xBE205C61, 0x0CA86C39\n\n\n// MAIN //\n\n/**\n* Computes \\\\(2^{\\mathrm{hp} + \\mathrm{lp}\\\\).\n*\n* @private\n* @param {number} j - high word of `hp + lp`\n* @param {number} hp - first power summand\n* @param {number} lp - second power summand\n* @returns {number} function value\n*\n* @example\n* var z = pow2( 1065961648, -0.3398475646972656, -0.000002438187359100815 );\n* // returns ~0.79\n*/\nfunction pow2( j, hp, lp ) {\n\tvar tmp;\n\tvar t1;\n\tvar t;\n\tvar r;\n\tvar u;\n\tvar v;\n\tvar w;\n\tvar z;\n\tvar n;\n\tvar i;\n\tvar k;\n\n\ti = (j & ABS_MASK)|0; // asm type annotation\n\tk = ((i>>HIGH_NUM_SIGNIFICAND_BITS) - BIAS)|0; // asm type annotation\n\tn = 0;\n\n\t// `|z| > 0.5`, set `n = z+0.5`\n\tif ( i > HIGH_BIASED_EXP_NEG_1 ) {\n\t\tn = (j + (HIGH_MIN_NORMAL_EXP>>(k+1)))>>>0; // asm type annotation\n\t\tk = (((n & ABS_MASK)>>HIGH_NUM_SIGNIFICAND_BITS) - BIAS)|0; // new k for n\n\t\ttmp = ((n & ~(HIGH_SIGNIFICAND_MASK >> k)))>>>0; // asm type annotation\n\t\tt = setHighWord( 0.0, tmp );\n\t\tn = (((n & HIGH_SIGNIFICAND_MASK)|HIGH_MIN_NORMAL_EXP) >> (HIGH_NUM_SIGNIFICAND_BITS-k))>>>0; // eslint-disable-line max-len\n\t\tif ( j < 0 ) {\n\t\t\tn = -n;\n\t\t}\n\t\thp -= t;\n\t}\n\tt = lp + hp;\n\tt = setLowWord( t, 0 );\n\tu = t * LN2_HI;\n\tv = ( (lp - (t-hp))*LN2 ) + ( t*LN2_LO );\n\tz = u + v;\n\tw = v - (z - u);\n\tt = z * z;\n\tt1 = z - ( t*polyvalP( t ) );\n\tr = ( (z*t1) / (t1-2.0) ) - ( w + (z*w) );\n\tz = 1.0 - (r - z);\n\tj = getHighWord( z );\n\tj = uint32ToInt32( j );\n\tj += (n << HIGH_NUM_SIGNIFICAND_BITS)>>>0; // asm type annotation\n\n\t// Check for subnormal output...\n\tif ( (j>>HIGH_NUM_SIGNIFICAND_BITS) <= 0 ) {\n\t\tz = ldexp( z, n );\n\t} else {\n\t\tz = setHighWord( z, j );\n\t}\n\treturn z;\n}\n\n\n// EXPORTS //\n\nexport default pow2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from './../../../../base/assert/is-nan';\nimport isOdd from './../../../../base/assert/is-odd';\nimport isInfinite from './../../../../base/assert/is-infinite';\nimport isInteger from './../../../../base/assert/is-integer';\nimport sqrt from './../../../../base/special/sqrt';\nimport abs from './../../../../base/special/abs';\nimport toWords from '@stdlib/number/float64/base/to-words';\nimport setLowWord from '@stdlib/number/float64/base/set-low-word';\nimport uint32ToInt32 from '@stdlib/number/uint32/base/to-int32';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport PINF from '@stdlib/constants/float64/pinf';\nimport ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\nimport xIsZero from './x_is_zero.js';\nimport yIsHuge from './y_is_huge.js';\nimport yIsInfinite from './y_is_infinite.js';\nimport log2ax from './log2ax.js';\nimport logx from './logx.js';\nimport pow2 from './pow2.js';\n\n\n// VARIABLES //\n\n// 0x3fefffff = 1072693247 => 0 01111111110 11111111111111111111 => biased exponent: 1022 = -1+1023 => 2^-1\nvar HIGH_MAX_NEAR_UNITY = 0x3fefffff|0; // asm type annotation\n\n// 0x41e00000 = 1105199104 => 0 10000011110 00000000000000000000 => biased exponent: 1054 = 31+1023 => 2^31\nvar HIGH_BIASED_EXP_31 = 0x41e00000|0; // asm type annotation\n\n// 0x43f00000 = 1139802112 => 0 10000111111 00000000000000000000 => biased exponent: 1087 = 64+1023 => 2^64\nvar HIGH_BIASED_EXP_64 = 0x43f00000|0; // asm type annotation\n\n// 0x40900000 = 1083179008 => 0 10000001001 00000000000000000000 => biased exponent: 1033 = 10+1023 => 2^10 = 1024\nvar HIGH_BIASED_EXP_10 = 0x40900000|0; // asm type annotation\n\n// 0x3ff00000 = 1072693248 => 0 01111111111 00000000000000000000 => biased exponent: 1023 = 0+1023 => 2^0 = 1\nvar HIGH_BIASED_EXP_0 = 0x3ff00000|0; // asm type annotation\n\n// 0x4090cc00 = 1083231232 => 0 10000001001 00001100110000000000\nvar HIGH_1075 = 0x4090cc00|0; // asm type annotation\n\n// 0xc090cc00 = 3230714880 => 1 10000001001 00001100110000000000\nvar HIGH_NEG_1075 = 0xc090cc00>>>0; // asm type annotation\n\nvar HIGH_NUM_NONSIGN_BITS = 31|0; // asm type annotation\n\nvar HUGE = 1.0e300;\nvar TINY = 1.0e-300;\n\n// -(1024-log2(ovfl+.5ulp))\nvar OVT = 8.0085662595372944372e-17;\n\n// High/low words workspace:\nvar WORDS = [ 0|0, 0|0 ];\n\n// Log workspace:\nvar LOG_WORKSPACE = [ 0.0, 0.0 ];\n\n\n// MAIN //\n\n/**\n* Evaluates the exponential function.\n*\n* ## Method\n*\n* 1. Let \\\\(x = 2^n (1+f)\\\\).\n*\n* 2. Compute \\\\(\\operatorname{log2}(x)\\\\) as\n*\n* ```tex\n* \\operatorname{log2}(x) = w_1 + w_2\n* ```\n*\n* where \\\\(w_1\\\\) has \\\\(53 - 24 = 29\\\\) bit trailing zeros.\n*\n* 3. Compute\n*\n* ```tex\n* y \\cdot \\operatorname{log2}(x) = n + y^\\prime\n* ```\n*\n* by simulating multi-precision arithmetic, where \\\\(|y^\\prime| \\leq 0.5\\\\).\n*\n* 4. Return\n*\n* ```tex\n* x^y = 2^n e^{y^\\prime \\cdot \\mathrm{log2}}\n* ```\n*\n* ## Special Cases\n*\n* ```tex\n* \\begin{align*}\n* x^{\\mathrm{NaN}} &= \\mathrm{NaN} & \\\\\n* (\\mathrm{NaN})^y &= \\mathrm{NaN} & \\\\\n* 1^y &= 1 & \\\\\n* x^0 &= 1 & \\\\\n* x^1 &= x & \\\\\n* (\\pm 0)^\\infty &= +0 & \\\\\n* (\\pm 0)^{-\\infty} &= +\\infty & \\\\\n* (+0)^y &= +0 & \\mathrm{if}\\ y > 0 \\\\\n* (+0)^y &= +\\infty & \\mathrm{if}\\ y < 0 \\\\\n* (-0)^y &= -\\infty & \\mathrm{if}\\ y\\ \\mathrm{is\\ an\\ odd\\ integer\\ and}\\ y < 0 \\\\\n* (-0)^y &= +\\infty & \\mathrm{if}\\ y\\ \\mathrm{is\\ not\\ an\\ odd\\ integer\\ and}\\ y < 0 \\\\\n* (-0)^y &= -0 & \\mathrm{if}\\ y\\ \\mathrm{is\\ an\\ odd\\ integer\\ and}\\ y > 0 \\\\\n* (-0)^y &= +0 & \\mathrm{if}\\ y\\ \\mathrm{is\\ not\\ an\\ odd\\ integer\\ and}\\ y > 0 \\\\\n* (-1)^{\\pm\\infty} &= \\mathrm{NaN} & \\\\\n* x^{\\infty} &= +\\infty & |x| > 1 \\\\\n* x^{\\infty} &= +0 & |x| < 1 \\\\\n* x^{-\\infty} &= +0 & |x| > 1 \\\\\n* x^{-\\infty} &= +\\infty & |x| < 1 \\\\\n* (-\\infty)^y &= (-0)^y & \\\\\n* \\infty^y &= +0 & y < 0 \\\\\n* \\infty^y &= +\\infty & y > 0 \\\\\n* x^y &= \\mathrm{NaN} & \\mathrm{if}\\ y\\ \\mathrm{is\\ not\\ a\\ finite\\ integer\\ and}\\ x < 0\n* \\end{align*}\n* ```\n*\n* ## Notes\n*\n* - \\\\(\\operatorname{pow}(x,y)\\\\) returns \\\\(x^y\\\\) nearly rounded. In particular, \\\\(\\operatorname{pow}(<\\mathrm{integer}>,<\\mathrm{integer}>)\\\\) **always** returns the correct integer, provided the value is representable.\n* - The hexadecimal values shown in the source code are the intended values for used constants. Decimal values may be used, provided the compiler will accurately convert decimal to binary in order to produce the hexadecimal values.\n*\n* @param {number} x - base\n* @param {number} y - exponent\n* @returns {number} function value\n*\n* @example\n* var v = pow( 2.0, 3.0 );\n* // returns 8.0\n*\n* @example\n* var v = pow( 4.0, 0.5 );\n* // returns 2.0\n*\n* @example\n* var v = pow( 100.0, 0.0 );\n* // returns 1.0\n*\n* @example\n* var v = pow( 3.141592653589793, 5.0 );\n* // returns ~306.0197\n*\n* @example\n* var v = pow( 3.141592653589793, -0.2 );\n* // returns ~0.7954\n*\n* @example\n* var v = pow( NaN, 3.0 );\n* // returns NaN\n*\n* @example\n* var v = pow( 5.0, NaN );\n* // returns NaN\n*\n* @example\n* var v = pow( NaN, NaN );\n* // returns NaN\n*/\nfunction pow( x, y ) {\n\tvar ahx; // absolute value high word `x`\n\tvar ahy; // absolute value high word `y`\n\tvar ax; // absolute value `x`\n\tvar hx; // high word `x`\n\tvar lx; // low word `x`\n\tvar hy; // high word `y`\n\tvar ly; // low word `y`\n\tvar sx; // sign `x`\n\tvar sy; // sign `y`\n\tvar y1;\n\tvar hp;\n\tvar lp;\n\tvar t;\n\tvar z; // y prime\n\tvar j;\n\tvar i;\n\tif ( isnan( x ) || isnan( y ) ) {\n\t\treturn NaN;\n\t}\n\t// Split `y` into high and low words:\n\ttoWords.assign( y, WORDS, 1, 0 );\n\thy = WORDS[ 0 ];\n\tly = WORDS[ 1 ];\n\n\t// Special cases `y`...\n\tif ( ly === 0 ) {\n\t\tif ( y === 0.0 ) {\n\t\t\treturn 1.0;\n\t\t}\n\t\tif ( y === 1.0 ) {\n\t\t\treturn x;\n\t\t}\n\t\tif ( y === -1.0 ) {\n\t\t\treturn 1.0 / x;\n\t\t}\n\t\tif ( y === 0.5 ) {\n\t\t\treturn sqrt( x );\n\t\t}\n\t\tif ( y === -0.5 ) {\n\t\t\treturn 1.0 / sqrt( x );\n\t\t}\n\t\tif ( y === 2.0 ) {\n\t\t\treturn x * x;\n\t\t}\n\t\tif ( y === 3.0 ) {\n\t\t\treturn x * x * x;\n\t\t}\n\t\tif ( y === 4.0 ) {\n\t\t\tx *= x;\n\t\t\treturn x * x;\n\t\t}\n\t\tif ( isInfinite( y ) ) {\n\t\t\treturn yIsInfinite( x, y );\n\t\t}\n\t}\n\t// Split `x` into high and low words:\n\ttoWords.assign( x, WORDS, 1, 0 );\n\thx = WORDS[ 0 ];\n\tlx = WORDS[ 1 ];\n\n\t// Special cases `x`...\n\tif ( lx === 0 ) {\n\t\tif ( hx === 0 ) {\n\t\t\treturn xIsZero( x, y );\n\t\t}\n\t\tif ( x === 1.0 ) {\n\t\t\treturn 1.0;\n\t\t}\n\t\tif (\n\t\t\tx === -1.0 &&\n\t\t\tisOdd( y )\n\t\t) {\n\t\t\treturn -1.0;\n\t\t}\n\t\tif ( isInfinite( x ) ) {\n\t\t\tif ( x === NINF ) {\n\t\t\t\t// `pow( 1/x, -y )`\n\t\t\t\treturn pow( -0.0, -y );\n\t\t\t}\n\t\t\tif ( y < 0.0 ) {\n\t\t\t\treturn 0.0;\n\t\t\t}\n\t\t\treturn PINF;\n\t\t}\n\t}\n\tif (\n\t\tx < 0.0 &&\n\t\tisInteger( y ) === false\n\t) {\n\t\t// Signal NaN...\n\t\treturn (x-x)/(x-x);\n\t}\n\tax = abs( x );\n\n\t// Remove the sign bits (i.e., get absolute values):\n\tahx = (hx & ABS_MASK)|0; // asm type annotation\n\tahy = (hy & ABS_MASK)|0; // asm type annotation\n\n\t// Extract the sign bits:\n\tsx = (hx >>> HIGH_NUM_NONSIGN_BITS)|0; // asm type annotation\n\tsy = (hy >>> HIGH_NUM_NONSIGN_BITS)|0; // asm type annotation\n\n\t// Determine the sign of the result...\n\tif ( sx && isOdd( y ) ) {\n\t\tsx = -1.0;\n\t} else {\n\t\tsx = 1.0;\n\t}\n\t// Case 1: `|y|` is huge...\n\n\t// |y| > 2^31\n\tif ( ahy > HIGH_BIASED_EXP_31 ) {\n\t\t// `|y| > 2^64`, then must over- or underflow...\n\t\tif ( ahy > HIGH_BIASED_EXP_64 ) {\n\t\t\treturn yIsHuge( x, y );\n\t\t}\n\t\t// Over- or underflow if `x` is not close to unity...\n\n\t\tif ( ahx < HIGH_MAX_NEAR_UNITY ) {\n\t\t\t// y < 0\n\t\t\tif ( sy === 1 ) {\n\t\t\t\t// Signal overflow...\n\t\t\t\treturn sx * HUGE * HUGE;\n\t\t\t}\n\t\t\t// Signal underflow...\n\t\t\treturn sx * TINY * TINY;\n\t\t}\n\t\tif ( ahx > HIGH_BIASED_EXP_0 ) {\n\t\t\t// y > 0\n\t\t\tif ( sy === 0 ) {\n\t\t\t\t// Signal overflow...\n\t\t\t\treturn sx * HUGE * HUGE;\n\t\t\t}\n\t\t\t// Signal underflow...\n\t\t\treturn sx * TINY * TINY;\n\t\t}\n\t\t// At this point, `|1-x|` is tiny (`<= 2^-20`). Suffice to compute `log(x)` by `x - x^2/2 + x^3/3 - x^4/4`.\n\t\tt = logx( LOG_WORKSPACE, ax );\n\t}\n\t// Case 2: `|y|` is not huge...\n\telse {\n\t\tt = log2ax( LOG_WORKSPACE, ax, ahx );\n\t}\n\t// Split `y` into `y1 + y2` and compute `(y1+y2) * (t1+t2)`...\n\ty1 = setLowWord( y, 0 );\n\tlp = ( (y-y1)*t[0] ) + ( y*t[1] );\n\thp = y1 * t[0];\n\tz = lp + hp;\n\n\t// Note: *can* be more performant to use `getHighWord` and `getLowWord` directly, but using `toWords` looks cleaner.\n\ttoWords.assign( z, WORDS, 1, 0 );\n\tj = uint32ToInt32( WORDS[0] );\n\ti = uint32ToInt32( WORDS[1] );\n\n\t// z >= 1024\n\tif ( j >= HIGH_BIASED_EXP_10 ) {\n\t\t// z > 1024\n\t\tif ( ((j-HIGH_BIASED_EXP_10)|i) !== 0 ) {\n\t\t\t// Signal overflow...\n\t\t\treturn sx * HUGE * HUGE;\n\t\t}\n\t\tif ( (lp+OVT) > (z-hp) ) {\n\t\t\t// Signal overflow...\n\t\t\treturn sx * HUGE * HUGE;\n\t\t}\n\t}\n\t// z <= -1075\n\telse if ( (j&ABS_MASK) >= HIGH_1075 ) {\n\t\t// z < -1075\n\t\tif ( ((j-HIGH_NEG_1075)|i) !== 0 ) {\n\t\t\t// Signal underflow...\n\t\t\treturn sx * TINY * TINY;\n\t\t}\n\t\tif ( lp <= (z-hp) ) {\n\t\t\t// Signal underflow...\n\t\t\treturn sx * TINY * TINY;\n\t\t}\n\t}\n\t// Compute `2^(hp+lp)`...\n\tz = pow2( j, hp, lp );\n\n\treturn sx * z;\n}\n\n\n// EXPORTS //\n\nexport default pow;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport abs from './../../../../base/special/abs';\nimport PINF from '@stdlib/constants/float64/pinf';\n\n\n// MAIN //\n\n/**\n* Evaluates the exponential function when \\\\( y = \\pm \\infty\\\\).\n*\n* @private\n* @param {number} x - base\n* @param {number} y - exponent\n* @returns {number} function value\n*\n* @example\n* var v = pow( -1.0, Infinity );\n* // returns NaN\n*\n* @example\n* var v = pow( -1.0, -Infinity );\n* // returns NaN\n*\n* @example\n* var v = pow( 1.0, Infinity );\n* // returns 1.0\n*\n* @example\n* var v = pow( 1.0, -Infinity );\n* // returns 1.0\n*\n* @example\n* var v = pow( 0.5, Infinity );\n* // returns 0.0\n*\n* @example\n* var v = pow( 0.5, -Infinity );\n* // returns Infinity\n*\n* @example\n* var v = pow( 1.5, -Infinity );\n* // returns 0.0\n*\n* @example\n* var v = pow( 1.5, Infinity );\n* // returns Infinity\n*/\nfunction pow( x, y ) {\n\tif ( x === -1.0 ) {\n\t\t// Julia (0.4.2) and Python (2.7.9) return `1.0` (WTF???). JavaScript (`Math.pow`), R, and libm return `NaN`. We choose `NaN`, as the value is indeterminate; i.e., we cannot determine whether `y` is odd, even, or somewhere in between.\n\t\treturn (x-x)/(x-x); // signal NaN\n\t}\n\tif ( x === 1.0 ) {\n\t\treturn 1.0;\n\t}\n\t// (|x| > 1 && y === NINF) || (|x| < 1 && y === PINF)\n\tif ( (abs(x) < 1.0) === (y === PINF) ) {\n\t\treturn 0.0;\n\t}\n\t// (|x| > 1 && y === PINF) || (|x| < 1 && y === NINF)\n\treturn PINF;\n}\n\n\n// EXPORTS //\n\nexport default pow;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/s_pow.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isOdd from './../../../../base/assert/is-odd';\nimport copysign from './../../../../base/special/copysign';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport PINF from '@stdlib/constants/float64/pinf';\n\n\n// MAIN //\n\n/**\n* Evaluates the exponential function when \\\\(|x| = 0\\\\).\n*\n* @private\n* @param {number} x - base\n* @param {number} y - exponent\n* @returns {number} function value\n*\n* @example\n* var v = pow( 0.0, 2 );\n* // returns 0.0\n*\n* @example\n* var v = pow( -0.0, -9 );\n* // returns -Infinity\n*\n* @example\n* var v = pow( 0.0, -9 );\n* // returns Infinity\n*\n* @example\n* var v = pow( -0.0, 9 );\n* // returns 0.0\n*\n* @example\n* var v = pow( 0.0, -Infinity );\n* // returns Infinity\n*\n* @example\n* var v = pow( 0.0, Infinity );\n* // returns 0.0\n*/\nfunction pow( x, y ) {\n\tif ( y === NINF ) {\n\t\treturn PINF;\n\t}\n\tif ( y === PINF ) {\n\t\treturn 0.0;\n\t}\n\tif ( y > 0.0 ) {\n\t\tif ( isOdd( y ) ) {\n\t\t\treturn x; // handles +-0\n\t\t}\n\t\treturn 0.0;\n\t}\n\t// y < 0.0\n\tif ( isOdd( y ) ) {\n\t\treturn copysign( PINF, x ); // handles +-0\n\t}\n\treturn PINF;\n}\n\n\n// EXPORTS //\n\nexport default pow;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* This is a generated file. Do not edit directly. */\n'use strict';\n\n// MAIN //\n\n/**\n* Evaluates a polynomial.\n*\n* ## Notes\n*\n* - The implementation uses [Horner's rule][horners-method] for efficient computation.\n*\n* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method\n*\n* @private\n* @param {number} x - value at which to evaluate the polynomial\n* @returns {number} evaluated polynomial\n*/\nfunction evalpoly( x ) {\n\tif ( x === 0.0 ) {\n\t\treturn 0.5;\n\t}\n\treturn 0.5 + (x * (-0.3333333333333333 + (x * 0.25)));\n}\n\n\n// EXPORTS //\n\nexport default evalpoly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* This is a generated file. Do not edit directly. */\n'use strict';\n\n// MAIN //\n\n/**\n* Evaluates a polynomial.\n*\n* ## Notes\n*\n* - The implementation uses [Horner's rule][horners-method] for efficient computation.\n*\n* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method\n*\n* @private\n* @param {number} x - value at which to evaluate the polynomial\n* @returns {number} evaluated polynomial\n*/\nfunction evalpoly( x ) {\n\tif ( x === 0.0 ) {\n\t\treturn 0.5999999999999946;\n\t}\n\treturn 0.5999999999999946 + (x * (0.4285714285785502 + (x * (0.33333332981837743 + (x * (0.272728123808534 + (x * (0.23066074577556175 + (x * 0.20697501780033842))))))))); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default evalpoly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* This is a generated file. Do not edit directly. */\n'use strict';\n\n// MAIN //\n\n/**\n* Evaluates a polynomial.\n*\n* ## Notes\n*\n* - The implementation uses [Horner's rule][horners-method] for efficient computation.\n*\n* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method\n*\n* @private\n* @param {number} x - value at which to evaluate the polynomial\n* @returns {number} evaluated polynomial\n*/\nfunction evalpoly( x ) {\n\tif ( x === 0.0 ) {\n\t\treturn 0.16666666666666602;\n\t}\n\treturn 0.16666666666666602 + (x * (-0.0027777777777015593 + (x * (0.00006613756321437934 + (x * (-0.0000016533902205465252 + (x * 4.1381367970572385e-8))))))); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default evalpoly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport pow from '@stdlib/math/base/special/pow';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian power.\n*\n* ## Notes\n*\n* - The Cartesian power is an n-fold Cartesian product involving a single array. The main insight of this implementation is that the n-fold Cartesian product can be represented as an n-dimensional array stored in row-major order. As such, we can\n*\n* - Compute the total number of tuples, which is simply the size of the provided array (set) raised to the specified power `n`. For n-dimensional arrays, this is the equivalent of computing the product of array dimensions to determine the total number of elements.\n* - Initialize an array for storing indices for indexing into the provided array. For n-dimensional arrays, the index array is equivalent to an array of subscripts for indexing into each dimension.\n* - For the outermost loop, treat the loop index as a linear index into an n-dimensional array and resolve the corresponding subscripts.\n* - Continue iterating until all tuples have been generated.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} n - power\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = cartesianPower( x, 2 );\n* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]\n*/\nfunction cartesianPower( x, n ) {\n\tvar get;\n\tvar out;\n\tvar tmp;\n\tvar idx;\n\tvar len;\n\tvar N;\n\tvar s;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tN = x.length;\n\tif ( N <= 0 || n <= 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve an array element accessor:\n\tget = resolveGetter( x );\n\n\t// Compute the total number of ordered tuples:\n\tlen = pow( N, n );\n\n\t// Initialize a list of indices for indexing into the array (equivalent to ndarray subscripts):\n\tidx = [];\n\tfor ( i = 0; i < n; i++ ) {\n\t\tidx.push( 0 );\n\t}\n\t// Compute the n-fold Cartesian product...\n\tout = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\t// Resolve a linear index to array indices (logic is equivalent to what is found in ndarray/base/ind2sub for an ndarray stored in row-major order; see https://github.com/stdlib-js/stdlib/blob/215ca5355f3404f15996fd0ced58a98e46f22be6/lib/node_modules/%40stdlib/ndarray/base/ind2sub/lib/assign.js)...\n\t\tk = i;\n\t\tfor ( j = n-1; j >= 0; j-- ) {\n\t\t\ts = k % N;\n\t\t\tk -= s;\n\t\t\tk /= N;\n\t\t\tidx[ j ] = s;\n\t\t}\n\t\t// Generate the next ordered tuple...\n\t\ttmp = [];\n\t\tfor ( j = 0; j < n; j++ ) {\n\t\t\ttmp.push( get( x, idx[ j ] ) );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default cartesianPower;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian product.\n*\n* @param {Collection} x1 - first input array\n* @param {Collection} x2 - second input array\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x1 = [ 1, 2, 3 ];\n* var x2 = [ 4, 5 ];\n*\n* var out = cartesianProduct( x1, x2 );\n* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ]\n*/\nfunction cartesianProduct( x1, x2 ) {\n\tvar get1;\n\tvar get2;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tget1 = resolveGetter( x1 );\n\tget2 = resolveGetter( x2 );\n\n\tM = x1.length;\n\tN = x2.length;\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tv = get1( x1, i );\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tout.push( [ v, get2( x2, j ) ] );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default cartesianProduct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian square.\n*\n* @param {Collection} x - input array\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = cartesianSquare( x );\n* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]\n*/\nfunction cartesianSquare( x ) {\n\tvar get;\n\tvar out;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tget = resolveGetter( x );\n\tN = x.length;\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tv = get( x, i );\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tout.push( [ v, get( x, j ) ] );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default cartesianSquare;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Copies the elements of an array-like object to a new \"generic\" array.\n*\n* @param {Collection} x - input array\n* @returns {Array} output array\n*\n* @example\n* var out = copy( [ 1, 2, 3 ] );\n* // returns [ 1, 2, 3 ]\n*/\nfunction copy( x ) {\n\tvar out;\n\tvar len;\n\tvar get;\n\tvar i;\n\n\t// Resolve an accessor for retrieving input array elements:\n\tget = resolveGetter( x );\n\n\t// Get the number of elements to copy:\n\tlen = x.length;\n\n\t// Loop over the elements...\n\tout = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tout.push( get( x, i ) ); // ensure \"fast\" elements\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default copy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = 16; // 8 bytes per float64 x (1 real + 1 imag component)\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `Complex128Array`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Complex128Array`\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isComplex128Array( new Complex128Array( 10 ) );\n* // returns true\n*\n* bool = isComplex128Array( [] );\n* // returns false\n*/\nfunction isComplex128Array( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex128Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex128array`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Complex128Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex128Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = 8; // 4 bytes per float32 x (1 real + 1 imag component)\n\n\n// MAIN //\n\n/**\n* Returns a boolean indicating if a value is a `Complex64Array`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `Complex64Array`\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n*\n* var bool = isComplex64Array( new Complex64Array( 10 ) );\n* // returns true\n*\n* bool = isComplex64Array( [] );\n* // returns false\n*/\nfunction isComplex64Array( value ) {\n\t// Note: the following is not robust and that is intentional. In this case, we are seeking a lower cost way to reasonably determine whether an input value is a `Complex64Array` in order to avoid walking the prototype chain and resolving constructors, which is necessary for robust identification of cross-realm instances. For more robust validation, see `@stdlib/assert/is-complex64array`.\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'Complex64Array' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from '@stdlib/array/base/assert/is-complex128array';\nimport isComplex64Array from '@stdlib/array/base/assert/is-complex64array';\nimport reinterpret128 from './../../../base/reinterpret-complex128';\nimport reinterpret64 from './../../../base/reinterpret-complex64';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Reinterprets a complex-valued floating-point array as a real-valued floating-point array having the same precision.\n*\n* @param {(Complex128Array|Complex64Array)} x - input array\n* @param {NonNegativeInteger} offset - starting index\n* @throws {TypeError} first argument must be a supported complex-valued floating-point array\n* @returns {(Float64Array|Float32Array)} real-valued floating-point array view\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var x = new Complex128Array( 10 );\n*\n* var out = reinterpret( x, 0 );\n* // returns \n*\n* var bool = ( out.buffer === x.buffer );\n* // returns true\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n*\n* var x = new Complex64Array( 10 );\n*\n* var out = reinterpret( x, 0 );\n* // returns \n*\n* var bool = ( out.buffer === x.buffer );\n* // returns true\n*/\nfunction reinterpret( x, offset ) {\n\tif ( isComplex128Array( x ) ) {\n\t\treturn reinterpret128( x, offset );\n\t}\n\tif ( isComplex64Array( x ) ) {\n\t\treturn reinterpret64( x, offset );\n\t}\n\t// Note: intentionally throw here to catch the scenario in which we add, e.g., a Complex32Array and need to explicitly add support here...\n\tthrow new TypeError( format( 'invalid argument. First argument must be a complex-valued floating-point array. Value: `%s`.', x ) );\n}\n\n\n// EXPORTS //\n\nexport default reinterpret;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport reinterpretComplex from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of falsy values in an indexed array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of falsy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x );\n* // returns 2\n*/\nfunction indexed( x ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !x[ i ] ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of falsy values in an accessor array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of falsy values\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x );\n* // returns 2\n*/\nfunction accessors( x ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !get( x, i ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of falsy values in a complex array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of falsy values\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 5.0, 6.0 ] );\n*\n* var n = complex( x );\n* // returns 2\n*/\nfunction complex( x ) {\n\tvar view;\n\tvar n;\n\tvar i;\n\n\tview = reinterpretComplex( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( view[ i ] === 0.0 && view[ i+1 ] === 0.0 ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of falsy values in an array.\n*\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of falsy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countFalsy( x );\n* // returns 2\n*/\nfunction countFalsy( x ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn indexed( reinterpretBoolean( x, 0 ) );\n\t\t}\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x );\n\t\t}\n\t\treturn accessors( x );\n\t}\n\treturn indexed( x );\n}\n\n\n// EXPORTS //\n\nexport default countFalsy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero.\n*\n* @param {number} n - number of elements\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = zeroTo( 6 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*/\nfunction zeroTo( n ) {\n\tvar arr;\n\tvar i;\n\n\tarr = [];\n\tif ( n <= 0 ) {\n\t\treturn arr;\n\t}\n\tfor ( i = 0; i < n; i++ ) {\n\t\tarr.push( i );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default zeroTo;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n\n\n// FUNCTIONS //\n\n/**\n* Fills an indexed array with linearly spaced numeric elements which increment by 1 starting from zero.\n*\n* @private\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = indexed( out, 1, 0 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = indexed( out, -1, out.length-1 );\n* // returns [ 5, 4, 3, 2, 1, 0 ]\n*/\nfunction indexed( out, stride, offset ) {\n\tvar v;\n\tvar i;\n\n\ti = offset;\n\tv = 0;\n\twhile ( i >= 0 && i < out.length ) {\n\t\tout[ i ] = v;\n\t\ti += stride;\n\t\tv += 1;\n\t}\n\treturn out;\n}\n\n/**\n* Fills a complex number array with linearly spaced numeric elements which increment by 1 starting from zero.\n*\n* @private\n* @param {(Complex128Array|Complex64Array)} out - output complex number array\n* @param {(Float64Array|Float32Array)} data - output array data\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {(Complex128Array|Complex64Array)} output array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\n*\n* var out = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );\n* // returns \n*\n* var data = reinterpret128( out, 0 );\n* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]\n*\n* var arr = complex( out, data, 1, 0 );\n* // returns \n*\n* var bool = ( arr === out );\n* // returns true\n*\n* data = reinterpret128( out, 0 );\n* returns [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ]\n*/\nfunction complex( out, data, stride, offset ) {\n\tvar v;\n\tvar s;\n\tvar i;\n\n\ts = stride * 2;\n\ti = offset * 2;\n\tv = 0.0;\n\twhile ( i >= 0 && i < data.length ) {\n\t\tdata[ i ] = v; // real component\n\t\tdata[ i+1 ] = 0.0; // imaginary component\n\t\ti += s;\n\t\tv += 1.0;\n\t}\n\treturn out;\n}\n\n/**\n* Fills an accessor array with linearly spaced numeric elements which increment by 1 starting from zero.\n*\n* @private\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n\n* var out = toAccessorArray( [ 0, 0, 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( out ), 1, 0 );\n*\n* var bool = ( arr === out );\n* // returns true\n*\n* var v = out.get( 0 );\n* // returns 0\n*\n* v = out.get( out.length-1 );\n* // returns 5\n*/\nfunction accessors( out, stride, offset ) {\n\tvar data;\n\tvar set;\n\tvar v;\n\tvar i;\n\n\tdata = out.data;\n\tset = out.accessors[ 1 ];\n\n\ti = offset;\n\tv = 0;\n\twhile ( i >= 0 && i < data.length ) {\n\t\tset( data, i, v );\n\t\ti += stride;\n\t\tv += 1;\n\t}\n\treturn data;\n}\n\n\n// MAIN //\n\n/**\n* Fills an array with linearly spaced numeric elements which increment by 1 starting from zero.\n*\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = assign( out, 1, 0 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = assign( out, -1, out.length-1 );\n* // returns [ 5, 4, 3, 2, 1, 0 ]\n*/\nfunction assign( out, stride, offset ) {\n\tvar obj = arraylike2object( out );\n\tif ( obj.accessorProtocol ) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and only set the real components...\n\t\tif ( obj.dtype === 'complex128' ) {\n\t\t\treturn complex( out, reinterpret128( out, 0 ), stride, offset );\n\t\t}\n\t\tif ( obj.dtype === 'complex64' ) {\n\t\t\treturn complex( out, reinterpret64( out, 0 ), stride, offset );\n\t\t}\n\t\treturn accessors( obj, stride, offset );\n\t}\n\treturn indexed( out, stride, offset );\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\nimport zeroTo from './../../../base/zero-to';\n\n\n// FUNCTIONS //\n\n/**\n* Returns an array of indices corresponding to the elements of an input array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Array} idx - list of indices\n* @param {Function} predicate - predicate function\n* @returns {Array} updated list of indices\n*\n* @example\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import zeroTo from '@stdlib/array/base/zero-to';\n*\n* function predicate( v ) {\n* return ( v > 0 );\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ -1, 2, 3, -4, 5 ] ) );\n* var idx = zeroTo( 5 );\n*\n* var out = accessors( x, idx, predicate );\n* // returns [ 1, 2, 4 ]\n*/\nfunction accessors( x, idx, predicate ) {\n\tvar buf;\n\tvar get;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tbuf = x.data;\n\tget = x.accessors[ 0 ];\n\n\tk = 0;\n\tfor ( i = 0; i < idx.length; i++ ) {\n\t\tj = idx[ i ];\n\t\tif ( predicate( get( buf, j ), j, buf ) ) {\n\t\t\tidx[ k ] = j;\n\t\t\tk += 1;\n\t\t}\n\t}\n\tidx.length = k;\n\treturn idx;\n}\n\n/**\n* Returns an array of indices corresponding to the elements of an input array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Array} idx - list of indices\n* @param {Function} predicate - predicate function\n* @returns {Array} updated list of indices\n*\n* @example\n* import zeroTo from '@stdlib/array/base/zero-to';\n*\n* function predicate( v ) {\n* return ( v > 0 );\n* }\n*\n* var x = [ -1, 2, 3, -4, 5 ];\n* var idx = zeroTo( 5 );\n*\n* var out = indexed( x, idx, predicate );\n* // returns [ 1, 2, 4 ]\n*/\nfunction indexed( x, idx, predicate ) {\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tk = 0;\n\tfor ( i = 0; i < idx.length; i++ ) {\n\t\tj = idx[ i ];\n\t\tif ( predicate( x[ j ], j, x ) ) {\n\t\t\tidx[ k ] = j;\n\t\t\tk += 1;\n\t\t}\n\t}\n\tidx.length = k;\n\treturn idx;\n}\n\n\n// MAIN //\n\n/**\n* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`.\n*\n* @param {Collection} x0 - first input array\n* @param {Function} predicate0 - first predicate function\n* @param {Collection} [x1] - second input array\n* @param {Function} [predicate1] - second predicate function\n* @param {Collection} [x2] - third input array\n* @param {Function} [predicate2] - third predicate function\n* @param {...(Collection|Function)} [args] - additional input arrays and predicate functions\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate0( value ) {\n* return ( value > 0 );\n* }\n*\n* function predicate1( value ) {\n* return ( value < 3 );\n* }\n*\n* var x0 = [ 0, 1, 0, 1, 2 ];\n* var x1 = [ 2, 3, 1, 2, 5 ];\n*\n* var n = countIfs( x0, predicate0, x1, predicate1 );\n* // returns 1\n*/\nfunction countIfs() {\n\tvar predicates;\n\tvar arrays;\n\tvar len;\n\tvar idx;\n\tvar x;\n\tvar i;\n\n\tarrays = [];\n\tpredicates = [];\n\tfor ( i = 0; i < arguments.length; i += 2 ) {\n\t\tarrays.push( arraylike2object( arguments[ i ] ) );\n\t\tpredicates.push( arguments[ i+1 ] );\n\t}\n\n\tlen = arguments[ 0 ].length;\n\tidx = zeroTo( len );\n\tfor ( i = 0; i < arrays.length; i++ ) {\n\t\tx = arrays[ i ];\n\t\tif ( x.accessorProtocol ) {\n\t\t\tidx = accessors( x, idx, predicates[ i ] );\n\t\t} else {\n\t\t\tidx = indexed( x.data, idx, predicates[ i ] );\n\t\t}\n\t}\n\treturn idx.length;\n}\n\n\n// EXPORTS //\n\nexport default countIfs;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if two double-precision floating-point numbers are the same value.\n*\n* ## Notes\n*\n* - The function implements the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016.\n* - In contrast to the strict equality operator `===`, `NaNs` are considered the same value.\n*\n* @param {number} a - first input value\n* @param {number} b - second input value\n* @returns {boolean} boolean indicating whether two double-precision floating-point numbers are the same value\n*\n* @example\n* var bool = isSameValueZero( 3.14, 3.14 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( -0.0, -0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( -0.0, 0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( NaN, NaN );\n* // returns true\n*/\nfunction isSameValueZero( a, b ) {\n\treturn ( a === b ) || ( a !== a && b !== b ); // handles NaNs\n}\n\n\n// EXPORTS //\n\nexport default isSameValueZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isSameComplexValueZero from '@stdlib/complex/float64/base/assert/is-same-value-zero';\nimport isComplexLike from './../../is-complex-like';\n\n\n// MAIN //\n\n/**\n* Tests if two arguments are the same value.\n*\n* ## Notes\n*\n* - The function implements the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016, and includes support for complex number objects.\n* - In contrast to the strict equality operator `===`, `NaNs` are considered the same value.\n*\n* @param {*} a - first input value\n* @param {*} b - second input value\n* @returns {boolean} boolean indicating whether two arguments are the same value\n*\n* @example\n* var bool = isSameValueZero( true, true );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( 3.14, 3.14 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( {}, {} );\n* // returns false\n*\n* @example\n* var bool = isSameValueZero( -0.0, -0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( -0.0, 0.0 );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( NaN, NaN );\n* // returns true\n*\n* @example\n* var bool = isSameValueZero( [], [] );\n* // returns false\n*/\nfunction isSameValueZero( a, b ) {\n\tif ( ( a === b ) || ( a !== a && b !== b ) ) { // handles NaNs\n\t\treturn true;\n\t}\n\tif ( isComplexLike( a ) && isComplexLike( b ) ) {\n\t\treturn isSameComplexValueZero( a, b );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isSameValueZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isSame from '@stdlib/number/float64/base/assert/is-same-value-zero';\nimport reim from './../../../../../float64/reim';\n\n\n// MAIN //\n\n/**\n* Tests whether two double-precision complex floating-point numbers are the same value.\n*\n* ## Notes\n*\n* - The function implements the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016.\n* - In contrast to the strict equality operator `===`, `NaNs` are considered the same value.\n*\n* @param {Complex128} z1 - first complex number\n* @param {Complex128} z2 - second complex number\n* @returns {boolean} result\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var z1 = new Complex128( 5.0, 3.0 );\n* var z2 = new Complex128( 5.0, 3.0 );\n*\n* var v = isSameValueZero( z1, z2 );\n* // returns true\n*/\nfunction isSameValueZero( z1, z2 ) {\n\tvar parts1 = reim( z1 );\n\tvar parts2 = reim( z2 );\n\treturn (\n\t\tisSame( parts1[ 0 ], parts2[ 0 ] ) &&\n\t\tisSame( parts1[ 1 ], parts2[ 1 ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isSameValueZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport reinterpretComplex from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of truthy values in an indexed array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* var x = [ 0, 1, 0, 1 ];\n*\n* var n = indexed( x );\n* // returns 2\n*/\nfunction indexed( x ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( x[ i ] ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of truthy values in an accessor array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1 ] );\n*\n* var n = accessors( x );\n* // returns 2\n*/\nfunction accessors( x ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( get( x, i ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of truthy values in a complex array.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var n = complex( x );\n* // returns 2\n*/\nfunction complex( x ) {\n\tvar view;\n\tvar n;\n\tvar i;\n\n\tview = reinterpretComplex( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( view[ i ] || view[ i+1 ] ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of truthy values in an array.\n*\n* @param {Collection} x - input array\n* @returns {NonNegativeInteger} number of truthy values\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countTruthy( x );\n* // returns 3\n*/\nfunction countTruthy( x ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn indexed( reinterpretBoolean( x, 0 ) );\n\t\t}\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x );\n\t\t}\n\t\treturn accessors( x );\n\t}\n\treturn indexed( x );\n}\n\n\n// EXPORTS //\n\nexport default countTruthy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Cumulatively tests whether at least one element in an indexed array is truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ false, false, true, false, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = indexed( x, y, 2, 0 );\n* // returns [ false, null, false, null, true, null, true, null, true, null ]\n*/\nfunction indexed( x, y, stride, offset ) {\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tflg = false;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === false && x[ i ] ) {\n\t\t\tflg = true;\n\t\t}\n\t\ty[ io ] = flg;\n\t\tio += stride;\n\t}\n\treturn y;\n}\n\n/**\n* Cumulatively tests whether at least one element in a provided accessor array is truthy.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ false, false, true, false, false ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );\n*\n* var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns false\n*\n* v = y.get( 2 );\n* // returns false\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns true\n*\n* v = y.get( 8 );\n* // returns true\n*/\nfunction accessors( x, y, stride, offset ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyset = y.accessors[ 1 ];\n\n\tflg = false;\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( flg === false && xget( xdata, i ) ) {\n\t\t\tflg = true;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether at least one element in a provided complex number array is truthy.\n*\n* @private\n* @param {Collection} x - array containing interleaved real and imaginary components\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );\n*\n* var arr = complex( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns false\n*\n* v = y.get( 2 );\n* // returns false\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns true\n*\n* v = y.get( 8 );\n* // returns true\n*/\nfunction complex( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = false;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( flg === false && ( x[ i ] || x[ i+1 ] ) ) {\n\t\t\tflg = true;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether at least one element in a provided boolean array is truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 0, 0, 1, 1, 0 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );\n*\n* var arr = boolean( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns false\n*\n* v = y.get( 2 );\n* // returns false\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns true\n*\n* v = y.get( 8 );\n* // returns true\n*/\nfunction boolean( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = false;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === false && x[ i ] ) {\n\t\t\tflg = true;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether at least one element in an array is truthy and assigns results to a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ false, false, true, false, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = assign( x, y, 2, 0 );\n* // returns [ false, null, false, null, true, null, true, null, true, null ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\nfunction assign( x, y, stride, offset ) {\n\tvar xo = arraylike2object( x );\n\tvar yo = arraylike2object( y );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tyo.accessorProtocol\n\t) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\tcomplex( reinterpret128( x, 0 ), yo, stride, offset );\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\tcomplex( reinterpret64( x, 0 ), yo, stride, offset );\n\t\t} else if ( isBooleanArray( x ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), yo, stride, offset );\n\t\t} else {\n\t\t\taccessors( xo, yo, stride, offset );\n\t\t}\n\t\treturn y;\n\t}\n\tindexed( x, y, stride, offset );\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether at least one element in a provided array is truthy.\n*\n* @param {Collection} x - input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ false, false, true, false, false ];\n*\n* var y = cuany( x );\n* // returns [ false, false, true, true, true ]\n*/\nfunction cuany( x ) {\n\tvar y = filled( false, x.length );\n\treturn assign( x, y, 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default cuany;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Cumulatively tests whether every element in an indexed array is truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ true, true, true, false, true ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = indexed( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*/\nfunction indexed( x, y, stride, offset ) {\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === true && !x[ i ] ) {\n\t\t\tflg = false;\n\t\t}\n\t\ty[ io ] = flg;\n\t\tio += stride;\n\t}\n\treturn y;\n}\n\n/**\n* Cumulatively tests whether every element in a provided accessor array is truthy.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ true, true, true, false, true ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );\n*\n* var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction accessors( x, y, stride, offset ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyset = y.accessors[ 1 ];\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( flg === true && !xget( xdata, i ) ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether every element in a provided complex number array is truthy.\n*\n* @private\n* @param {Collection} x - array containing interleaved real and imaginary components\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] );\n*\n* var arr = complex( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction complex( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( flg === true && !( x[ i ] || x[ i+1 ] ) ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether every element in a provided boolean array is truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 1, 1, 0, 1 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] );\n*\n* var arr = boolean( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction boolean( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === true && !x[ i ] ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether every element in an array is truthy and assigns results to a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ true, true, true, false, true ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = assign( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\nfunction assign( x, y, stride, offset ) {\n\tvar xo = arraylike2object( x );\n\tvar yo = arraylike2object( y );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tyo.accessorProtocol\n\t) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\tcomplex( reinterpret128( x, 0 ), yo, stride, offset );\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\tcomplex( reinterpret64( x, 0 ), yo, stride, offset );\n\t\t} else if ( isBooleanArray( x ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), yo, stride, offset );\n\t\t} else {\n\t\t\taccessors( xo, yo, stride, offset );\n\t\t}\n\t\treturn y;\n\t}\n\tindexed( x, y, stride, offset );\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether every element in a provided array is truthy.\n*\n* @param {Collection} x - input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ true, true, true, false, true ];\n*\n* var y = cuevery( x );\n* // returns [ true, true, true, false, false ];\n*/\nfunction cuevery( x ) {\n\tvar y = filled( true, x.length );\n\treturn assign( x, y, 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default cuevery;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Cumulatively tests whether every element in an indexed array is falsy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ false, false, false, true, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = indexed( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*/\nfunction indexed( x, y, stride, offset ) {\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === true && x[ i ] ) {\n\t\t\tflg = false;\n\t\t}\n\t\ty[ io ] = flg;\n\t\tio += stride;\n\t}\n\treturn y;\n}\n\n/**\n* Cumulatively tests whether every element in a provided accessor array is falsy.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ false, false, false, true, false ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );\n*\n* var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction accessors( x, y, stride, offset ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyset = y.accessors[ 1 ];\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( flg === true && xget( xdata, i ) ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether every element in a provided complex number array is falsy.\n*\n* @private\n* @param {Collection} x - array containing interleaved real and imaginary components\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] );\n*\n* var arr = complex( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction complex( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( flg === true && ( x[ i ] || x[ i+1 ] ) ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n/**\n* Cumulatively tests whether every element in a provided boolean array is falsy.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 0, 0, 0, 1, 0 ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, true, null ] );\n*\n* var arr = boolean( x, arraylike2object( y ), 2, 0 );\n*\n* var v = y.get( 0 );\n* // returns true\n*\n* v = y.get( 2 );\n* // returns true\n*\n* v = y.get( 4 );\n* // returns true\n*\n* v = y.get( 6 );\n* // returns false\n*\n* v = y.get( 8 );\n* // returns false\n*/\nfunction boolean( x, y, stride, offset ) {\n\tvar ydata;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tyset = y.accessors[ 1 ];\n\tydata = y.data;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( flg === true && x[ i ] ) {\n\t\t\tflg = false;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether every element in an array is falsy and assigns results to a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ false, false, false, true, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = assign( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\nfunction assign( x, y, stride, offset ) {\n\tvar xo = arraylike2object( x );\n\tvar yo = arraylike2object( y );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tyo.accessorProtocol\n\t) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\tcomplex( reinterpret128( x, 0 ), yo, stride, offset );\n\t\t} else if ( isComplex64Array( x ) ) {\n\t\t\tcomplex( reinterpret64( x, 0 ), yo, stride, offset );\n\t\t} else if ( isBooleanArray( x ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), yo, stride, offset );\n\t\t} else {\n\t\t\taccessors( xo, yo, stride, offset );\n\t\t}\n\t\treturn y;\n\t}\n\tindexed( x, y, stride, offset );\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether every element in a provided array is falsy.\n*\n* @param {Collection} x - input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ false, false, false, true, false ];\n*\n* var y = cunone( x );\n* // returns [ true, true, true, false, false ]\n*/\nfunction cunone( x ) {\n\tvar y = filled( true, x.length );\n\treturn assign( x, y, 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default cunone;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a read-write accessor.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Function} getter - get accessor\n* @param {Function} setter - set accessor\n*\n* @example\n* function getter() {\n* return name + ' foo';\n* }\n*\n* function setter( v ) {\n* name = v;\n* }\n*\n* var name = 'bar';\n* var obj = {};\n*\n* setReadWriteAccessor( obj, 'foo', getter, setter );\n*\n* var v = obj.foo;\n* // returns 'bar foo'\n*\n* obj.foo = 'beep';\n*\n* v = obj.foo;\n* // returns 'beep foo'\n*/\nfunction setReadWriteAccessor( obj, prop, getter, setter ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'get': getter,\n\t\t'set': setter\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setReadWriteAccessor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether all elements in an array are truthy.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether all elements are truthy\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internal( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 4 ];\n*\n* var out = internal( x );\n* // returns false\n*/\nfunction internal( x ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !x[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in a complex number array are truthy.\n*\n* @private\n* @param {Collection} x - underlying data buffer\n* @returns {boolean} boolean indicating whether all elements are truthy\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internalComplex( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 4 ];\n*\n* var out = internalComplex( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 0 ];\n*\n* var out = internalComplex( x );\n* // returns false\n*/\nfunction internalComplex( x ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( !( x[ i ] || x[ i+1 ] ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array are truthy.\n*\n* @private\n* @param {Object} x - input array object\n* @returns {boolean} boolean indicating whether all elements are truthy\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) );\n*\n* var out = accessors( x );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 0, 4 ] ) );\n*\n* var out = accessors( x );\n* // returns false\n*/\nfunction accessors( x ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( !get( data, i ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array are truthy.\n*\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether all elements are truthy\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = every( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 4 ];\n*\n* var out = every( x );\n* // returns false\n*/\nfunction every( x ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be truthy if at least one component is non-zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\treturn internalComplex( reinterpret128( x, 0 ) );\n\t\t}\n\t\tif ( isComplex64Array( x ) ) {\n\t\t\treturn internalComplex( reinterpret64( x, 0 ) );\n\t\t}\n\t\t// If provided a boolean array, reinterpret as a typed array and test each element...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn internal( reinterpretBoolean( x, 0 ) );\n\t\t}\n\t\treturn accessors( obj );\n\t}\n\treturn internal( x );\n}\n\n\n// EXPORTS //\n\nexport default every;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isNull from '@stdlib/assert/is-null';\nimport isUndefined from '@stdlib/assert/is-undefined';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an input argument is valid.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether the argument is valid\n*\n* @example\n* var bool = isValid( 3 );\n* // returns true\n*\n* bool = isValid( null );\n* // returns true\n*\n* bool = isValid( void 0 );\n* // returns true\n*\n* bool = isValid( '3' );\n* // returns false\n*/\nfunction isValid( value ) {\n\treturn ( isInteger( value ) || isNull( value ) || isUndefined( value ) );\n}\n\n\n// MAIN //\n\n/**\n* Slice constructor.\n*\n* @constructor\n* @param {(integer|null|void)} [start] - starting index (inclusive)\n* @param {(integer|null|void)} stop - ending index (exclusive)\n* @param {(integer|null|void)} [step] - index increment\n* @throws {TypeError} first argument must be an integer, null, or undefined\n* @throws {TypeError} second argument must be an integer, null, or undefined\n* @throws {TypeError} third argument must be an integer, null, or undefined\n* @throws {RangeError} third argument cannot be zero\n* @returns {Slice} Slice instance\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var start = s.start;\n* // returns null\n*\n* var stop = s.stop;\n* // returns 10\n*\n* var step = s.step;\n* // returns null\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var start = s.start;\n* // returns 3\n*\n* var stop = s.stop;\n* // returns 10\n*\n* var step = s.step;\n* // returns null\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var start = s.start;\n* // returns 3\n*\n* var stop = s.stop;\n* // returns 10\n*\n* var step = s.step;\n* // returns 2\n*/\nfunction Slice() {\n\tvar nargs;\n\tvar start;\n\tvar stop;\n\tvar step;\n\n\tnargs = arguments.length;\n\tif ( nargs === 0 ) {\n\t\tstart = null;\n\t\tstop = null;\n\t\tstep = null;\n\t} else if ( nargs === 1 ) {\n\t\tstart = null;\n\t\tstop = arguments[ 0 ];\n\t\tstep = null;\n\t} else if ( nargs === 2 ) {\n\t\tstart = arguments[ 0 ];\n\t\tstop = arguments[ 1 ];\n\t\tstep = null;\n\t} else {\n\t\tstart = arguments[ 0 ];\n\t\tstop = arguments[ 1 ];\n\t\tstep = arguments[ 2 ];\n\t}\n\tif ( !( this instanceof Slice ) ) {\n\t\treturn new Slice( start, stop, step );\n\t}\n\tif ( !isValid( start ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer, null, or undefined. Value: `%s`.', start ) );\n\t}\n\tif ( !isValid( stop ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer, null, or undefined. Value: `%s`.', stop ) );\n\t}\n\tif ( !isValid( step ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer, null, or undefined. Value: `%s`.', step ) );\n\t} else if ( step === 0 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Third argument cannot be zero. Value: `%s`.', step ) );\n\t}\n\tthis._start = ( start === void 0 ) ? null : start;\n\tthis._stop = ( stop === void 0 ) ? null : stop;\n\tthis._step = ( step === void 0 ) ? null : step;\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Slice\n* @readonly\n* @type {string}\n* @default 'Slice'\n*\n* @example\n* var str = Slice.name;\n* // returns 'Slice'\n*/\nsetReadOnly( Slice, 'name', 'Slice' );\n\n/**\n* Returns the slice's starting index.\n*\n* @name start\n* @memberof Slice.prototype\n* @readonly\n* @type {(integer|null)}\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var start = s.start;\n* // returns null\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var start = s.start;\n* // returns 3\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var start = s.start;\n* // returns 3\n*/\nsetReadOnlyAccessor( Slice.prototype, 'start', function get() {\n\treturn this._start;\n});\n\n/**\n* Returns the slice's ending index.\n*\n* @name stop\n* @memberof Slice.prototype\n* @readonly\n* @type {(integer|null)}\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var stop = s.stop;\n* // returns 10\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var stop = s.stop;\n* // returns 10\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var stop = s.stop;\n* // returns 10\n*/\nsetReadOnlyAccessor( Slice.prototype, 'stop', function get() {\n\treturn this._stop;\n});\n\n/**\n* Returns the slice's index increment.\n*\n* @name step\n* @memberof Slice.prototype\n* @readonly\n* @type {(integer|null)}\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var step = s.step;\n* // returns null\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var step = s.step;\n* // returns null\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var step = s.step;\n* // returns 2\n*/\nsetReadOnlyAccessor( Slice.prototype, 'step', function get() {\n\treturn this._step;\n});\n\n/**\n* Serializes a slice to a string.\n*\n* @name toString\n* @memberof Slice.prototype\n* @type {Function}\n* @returns {string} serialized Slice\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var str = s.toString();\n* // returns 'Slice(null,10,null)'\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var str = s.toString();\n* // returns 'Slice(3,10,null)'\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var str = s.toString();\n* // returns 'Slice(3,10,2)'\n*/\nsetReadOnly( Slice.prototype, 'toString', function toString() {\n\treturn 'Slice('+this._start+','+this._stop+','+this.step+')';\n});\n\n/**\n* Serializes a slice as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `Slice` instance.\n*\n* @name toJSON\n* @memberof Slice.prototype\n* @type {Function}\n* @returns {Object} serialized Slice\n*\n* @example\n* var s = new Slice( 10 );\n* // returns \n*\n* var o = s.toJSON();\n* // returns { 'type': 'Slice', 'data': [ null, 10, null ] }\n*\n* @example\n* var s = new Slice( 3, 10 );\n* // returns \n*\n* var o = s.toJSON();\n* // returns { 'type': 'Slice', 'data': [ 3, 10, null ] }\n*\n* @example\n* var s = new Slice( 3, 10, 2 );\n* // returns \n*\n* var o = s.toJSON();\n* // returns { 'type': 'Slice', 'data': [ 3, 10, 2 ] }\n*/\nsetReadOnly( Slice.prototype, 'toJSON', function toJSON() {\n\treturn {\n\t\t'type': 'Slice',\n\t\t'data': [\n\t\t\tthis._start,\n\t\t\tthis._stop,\n\t\t\tthis._step\n\t\t]\n\t};\n});\n\n\n// EXPORTS //\n\nexport default Slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is `null`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is null\n*\n* @example\n* var bool = isNull( null );\n* // returns true\n*\n* bool = isNull( true );\n* // returns false\n*/\nfunction isNull( value ) {\n\treturn value === null;\n}\n\n\n// EXPORTS //\n\nexport default isNull;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is `undefined`.\n*\n* ## Notes\n*\n* - In older browsers, `undefined` is a global which can be overridden. `void`, however, is an operator which **cannot** be overridden. Consequently, better to use `void` to check for `undefined`. See [Stack Overflow][1].\n*\n* [1]: http://stackoverflow.com/a/19369078/2225624\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is undefined\n*\n* @example\n* var bool = isUndefined( undefined );\n* // returns true\n*\n* bool = isUndefined( null );\n* // returns false\n*/\nfunction isUndefined( value ) {\n\treturn value === void 0;\n}\n\n\n// EXPORTS //\n\nexport default isUndefined;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Slice from './../../../ctor';\nimport eOutOfBounds from './error_out_of_bounds.js';\n\n\n// MAIN //\n\n/**\n* Returns a normalized Slice object.\n*\n* @param {Slice} slice - input slice\n* @param {NonNegativeInteger} len - maximum number of elements allowed in a slice\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @returns {(Slice|ErrorObject)} slice object or an error object\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var s = normalizeSlice( new Slice(), 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var s = normalizeSlice( new Slice( null, 20, 2 ), 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 2\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var s = normalizeSlice( new Slice( -5, -1, 1 ), 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 5\n*\n* v = s.stop;\n* // returns 9\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var s = normalizeSlice( new Slice( -5, null, -1 ), 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 5\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*/\nfunction normalizeSlice( slice, len, strict ) {\n\tvar start;\n\tvar stop;\n\tvar step;\n\n\tstart = slice.start;\n\tstop = slice.stop;\n\tstep = slice.step;\n\n\t// If necessary, set the default increment...\n\tif ( step === null ) {\n\t\tstep = 1;\n\t}\n\n\t// Case: start is not specified\n\tif ( start === null ) {\n\t\t// If the step is positive, we default to the first index...\n\t\tif ( step > 0 ) {\n\t\t\tstart = 0;\n\t\t}\n\t\t// If the step is negative, we default to the last index (inclusive)...\n\t\telse {\n\t\t\tstart = len - 1;\n\t\t}\n\t}\n\t// Case: start is negative and should be resolved relative to the last index\n\telse if ( start < 0 ) {\n\t\tstart = len + start;\n\n\t\t// Check whether start still exceeds the index bounds...\n\t\tif ( start < 0 ) {\n\t\t\tif ( strict ) {\n\t\t\t\treturn eOutOfBounds();\n\t\t\t}\n\t\t\t// Clamp to the first index (inclusive):\n\t\t\tstart = 0;\n\t\t}\n\t}\n\t// Case: start exceeds index bounds\n\telse if ( start >= len ) {\n\t\tif ( strict ) {\n\t\t\treturn eOutOfBounds();\n\t\t}\n\t\t// If the increment is negative, clamp to the last index (inclusive)...\n\t\tif ( step < 0 ) {\n\t\t\tstart = len - 1;\n\t\t}\n\t\t// If the increment is positive, clamp to the \"index\" following the last index...\n\t\telse {\n\t\t\tstart = len;\n\t\t}\n\t}\n\n\t// Case: stop is not specified\n\tif ( stop === null ) {\n\t\t// If the step is positive, we default to just beyond the last index, as the stopping index is exclusive...\n\t\tif ( step > 0 ) {\n\t\t\tstop = len;\n\t\t}\n\t\t// If the step is negative, we default to a sentinel value indicating that one should iterate through the first index when decrementing...\n\t\telse {\n\t\t\tstop = null;\n\t\t}\n\t}\n\t// Case: stop is negative and should be resolved relative to the last index\n\telse if ( stop < 0 ) {\n\t\tstop = len + stop;\n\n\t\t// Check whether stop still exceeds the index bounds...\n\t\tif ( stop < 0 ) {\n\t\t\t// If the step is positive, we should clamp to the first index, as Slice(x,0,step) is an empty slice regardless of `x`...\n\t\t\tif ( step > 0 ) {\n\t\t\t\tif ( strict ) {\n\t\t\t\t\treturn eOutOfBounds();\n\t\t\t\t}\n\t\t\t\tstop = 0;\n\t\t\t}\n\t\t\t// If the step is negative, we default to just beyond the first index (using a sentinel value), as the stopping index is exclusive, thus indicating to iterate through the first index when decrementing...\n\t\t\telse {\n\t\t\t\tif ( strict && stop < -1 ) {\n\t\t\t\t\treturn eOutOfBounds();\n\t\t\t\t}\n\t\t\t\tstop = null;\n\t\t\t}\n\t\t}\n\t}\n\t// Case: stop exceeds index bounds\n\telse if ( stop > len ) {\n\t\tif ( strict ) {\n\t\t\treturn eOutOfBounds();\n\t\t}\n\t\t// Clamp to just beyond the last index, as the stopping index is exclusive:\n\t\tstop = len;\n\t}\n\n\t// Return a normalized slice:\n\treturn new Slice( start, stop, step );\n}\n\n\n// EXPORTS //\n\nexport default normalizeSlice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an error object for a slice which exceeds index bounds.\n*\n* @private\n* @returns {Object} error object\n*/\nfunction error() {\n\treturn {\n\t\t'code': 'ERR_SLICE_OUT_OF_BOUNDS'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default error;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Generate a linearly spaced numeric array whose elements increment by 1 starting from zero.\n*\n* @module @stdlib/array/base/zero-to\n*\n* @example\n* import zeroTo from '@stdlib/array/base/zero-to';\n*\n* var arr = zeroTo( 6 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*\n* @example\n* import zeroTo from '@stdlib/array/base/zero-to';\n*\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n* var arr = zeroTo.assign( out, 1, 0 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*\n* var bool = ( out === arr );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Cumulatively test whether at least one element in a provided array is truthy.\n*\n* @module @stdlib/array/base/cuany\n*\n* @example\n* import cuany from '@stdlib/array/base/cuany';\n*\n* var x = [ false, false, true, false, false ];\n*\n* var y = cuany( x );\n* // returns [ false, false, true, true, true ]\n*\n* @example\n* import cuany from '@stdlib/array/base/cuany';\n*\n* var x = [ false, false, true, false, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var arr = cuany.assign( x, y, 2, 0 );\n* // returns [ false, null, false, null, true, null, true, null, true, null ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Cumulatively test whether every element in a provided array is truthy.\n*\n* @module @stdlib/array/base/cuevery\n*\n* @example\n* import cuevery from '@stdlib/array/base/cuevery';\n*\n* var x = [ true, true, true, false, true ]\n*\n* var y = cuevery( x );\n* // returns [ true, true, true, false, false ]\n*\n* @example\n* import cuevery from '@stdlib/array/base/cuevery';\n*\n* var x = [ true, true, true, false, true ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var arr = cuevery.assign( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Cumulatively test whether every element in a provided array is falsy.\n*\n* @module @stdlib/array/base/cunone\n*\n* @example\n* import cunone from '@stdlib/array/base/cunone';\n*\n* var x = [ false, false, false, true, false ]\n*\n* var y = cunone( x );\n* // returns [ true, true, true, false, false ]\n*\n* @example\n* import cunone from '@stdlib/array/base/cunone';\n*\n* var x = [ false, false, false, true, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var arr = cunone.assign( x, y, 2, 0 );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: implementation (?)\n\n/**\n* Rounds a double-precision floating-point number toward positive infinity.\n*\n* @param {number} x - input value\n* @returns {number} rounded value\n*\n* @example\n* var v = ceil( -4.2 );\n* // returns -4.0\n*\n* @example\n* var v = ceil( 9.99999 );\n* // returns 10.0\n*\n* @example\n* var v = ceil( 0.0 );\n* // returns 0.0\n*\n* @example\n* var v = ceil( NaN );\n* // returns NaN\n*/\nvar ceil = Math.ceil; // eslint-disable-line stdlib/no-builtin-math\n\n\n// EXPORTS //\n\nexport default ceil;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ceil from '@stdlib/math/base/special/ceil';\n\n\n// MAIN //\n\n/**\n* Returns the number of elements in a normalized slice.\n*\n* @param {Slice} slice - normalized Slice object\n* @returns {NonNegativeInteger} number of elements\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n* import normalizeSlice from '@stdlib/slice/base/normalize-slice';\n*\n* var s = new Slice( 2, null, 1 );\n* // returns \n*\n* var v = sliceLength( normalizeSlice( s, 10, false ) );\n* // returns 8\n*\n* v = sliceLength( normalizeSlice( s, 11, false ) );\n* // returns 9\n*\n* v = sliceLength( normalizeSlice( s, 5, false ) );\n* // returns 3\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n* import normalizeSlice from '@stdlib/slice/base/normalize-slice';\n*\n* var s = new Slice( 2, null, 2 );\n* // returns \n*\n* var v = sliceLength( normalizeSlice( s, 10, false ) );\n* // returns 4\n*\n* v = sliceLength( normalizeSlice( s, 11, false ) );\n* // returns 5\n*\n* v = sliceLength( normalizeSlice( s, 5, false ) );\n* // returns 2\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n* import normalizeSlice from '@stdlib/slice/base/normalize-slice';\n*\n* var s = new Slice( -1, null, -2 );\n*\n* var v = sliceLength( normalizeSlice( s, 10, false ) );\n* // returns 5\n*\n* v = sliceLength( normalizeSlice( s, 11, false ) );\n* // returns 6\n*\n* v = sliceLength( normalizeSlice( s, 5, false ) );\n* // returns 3\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n* import normalizeSlice from '@stdlib/slice/base/normalize-slice';\n*\n* var s = new Slice( 3, 5, -1 );\n*\n* var v = sliceLength( normalizeSlice( s, 10, false ) );\n* // returns 0\n*\n* v = sliceLength( normalizeSlice( s, 11, false ) );\n* // returns 0\n*\n* v = sliceLength( normalizeSlice( s, 5, false ) );\n* // returns 0\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n* import normalizeSlice from '@stdlib/slice/base/normalize-slice';\n*\n* var s = new Slice( 5, 3, 1 );\n*\n* var v = sliceLength( normalizeSlice( s, 10, false ) );\n* // returns 0\n*\n* v = sliceLength( normalizeSlice( s, 11, false ) );\n* // returns 0\n*\n* v = sliceLength( normalizeSlice( s, 5, false ) );\n* // returns 0\n*/\nfunction sliceLength( slice ) {\n\tvar inc;\n\tvar x1;\n\tvar x2;\n\n\tx1 = slice.start;\n\tx2 = slice.stop;\n\tinc = slice.step;\n\n\t// For a normalized slice, stop should only be `null` when the increment is negative...\n\tif ( x2 === null ) {\n\t\tx2 = -1; // set to -1 to ensure that the first element is included\n\t}\n\tif (\n\t\t// If the increment is positive, the slice is empty whenever the starting index is greater than or equal to the stopping index:\n\t\t( inc > 0 && x1 >= x2 ) ||\n\n\t\t// If the increment is negative, the slice is empty whenever the starting index is less than or equal to the stopping index:\n\t\t( inc < 0 && x1 <= x2 )\n\t) {\n\t\treturn 0;\n\t}\n\treturn ceil( ( x2 - x1 ) / inc );\n}\n\n\n// EXPORTS //\n\nexport default sliceLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar TYPE = 'function';\n\n\n// MAIN //\n\n/**\n* Tests if an array-like object supports the accessor (get/set) protocol.\n*\n* @param {Object} value - value to test\n* @returns {boolean} boolean indicating whether a value is an accessor array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isAccessorArray( new Complex128Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isAccessorArray( [] );\n* // returns false\n*/\nfunction isAccessorArray( value ) {\n\treturn ( typeof value.get === TYPE && typeof value.set === TYPE ); // eslint-disable-line valid-typeof\n}\n\n\n// EXPORTS //\n\nexport default isAccessorArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar GETTERS = {\n\t'float64': getFloat64,\n\t'float32': getFloat32,\n\t'int32': getInt32,\n\t'int16': getInt16,\n\t'int8': getInt8,\n\t'uint32': getUint32,\n\t'uint16': getUint16,\n\t'uint8': getUint8,\n\t'uint8c': getUint8c,\n\t'generic': getGeneric,\n\t'default': getArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an element from a `Float64Array`.\n*\n* @private\n* @param {Float64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getFloat64( arr, 2 );\n* // returns 3.0\n*/\nfunction getFloat64( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Float32Array`.\n*\n* @private\n* @param {Float32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Float32Array from '@stdlib/array/float32';\n*\n* var arr = new Float32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getFloat32( arr, 2 );\n* // returns 3.0\n*/\nfunction getFloat32( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int32Array`.\n*\n* @private\n* @param {Int32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var arr = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt32( arr, 2 );\n* // returns 3\n*/\nfunction getInt32( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int16Array`.\n*\n* @private\n* @param {Int16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int16Array from '@stdlib/array/int16';\n*\n* var arr = new Int16Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt16( arr, 2 );\n* // returns 3\n*/\nfunction getInt16( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an `Int8Array`.\n*\n* @private\n* @param {Int8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var arr = new Int8Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getInt8( arr, 2 );\n* // returns 3\n*/\nfunction getInt8( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint32Array`.\n*\n* @private\n* @param {Uint32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var arr = new Uint32Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint32( arr, 2 );\n* // returns 3\n*/\nfunction getUint32( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint16Array`.\n*\n* @private\n* @param {Uint16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint16Array from '@stdlib/array/uint16';\n*\n* var arr = new Uint16Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint16( arr, 2 );\n* // returns 3\n*/\nfunction getUint16( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint8Array`.\n*\n* @private\n* @param {Uint8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var arr = new Uint8Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint8( arr, 2 );\n* // returns 3\n*/\nfunction getUint8( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a `Uint8ClampedArray`.\n*\n* @private\n* @param {Uint8ClampedArray} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Uint8ClampedArray from '@stdlib/array/uint8c';\n*\n* var arr = new Uint8ClampedArray( [ 1, 2, 3, 4 ] );\n*\n* var v = getUint8c( arr, 2 );\n* // returns 3\n*/\nfunction getUint8c( arr, idx ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from a generic `Array`.\n*\n* @private\n* @param {Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var v = getGeneric( arr, 2 );\n* // returns 3\n*/\nfunction getGeneric( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n/**\n* Returns an element from an indexed array-like object.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var v = getArrayLike( arr, 2 );\n* // returns 3\n*/\nfunction getArrayLike( arr, idx ) {\n\treturn arr[ idx ];\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an indexed array-like object.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 2 );\n* // returns 3\n*/\nfunction getter( dtype ) {\n\tvar f = GETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn GETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar SETTERS = {\n\t'float64': setFloat64,\n\t'float32': setFloat32,\n\t'int32': setInt32,\n\t'int16': setInt16,\n\t'int8': setInt8,\n\t'uint32': setUint32,\n\t'uint16': setUint16,\n\t'uint8': setUint8,\n\t'uint8c': setUint8c,\n\t'generic': setGeneric,\n\t'default': setArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Sets an element in a `Float64Array`.\n*\n* @private\n* @param {Float64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( 4 );\n*\n* setFloat64( arr, 2, 3.0 );\n*\n* var v = arr[ 2 ];\n* // returns 3.0\n*/\nfunction setFloat64( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Float32Array`.\n*\n* @private\n* @param {Float32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Float32Array from '@stdlib/array/float32';\n*\n* var arr = new Float32Array( 4 );\n*\n* setFloat32( arr, 2, 3.0 );\n*\n* var v = arr[ 2 ];\n* // returns 3.0\n*/\nfunction setFloat32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int32Array`.\n*\n* @private\n* @param {Int32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var arr = new Int32Array( 4 );\n*\n* setInt32( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int16Array`.\n*\n* @private\n* @param {Int16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int16Array from '@stdlib/array/int16';\n*\n* var arr = new Int16Array( 4 );\n*\n* setInt16( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt16( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an `Int8Array`.\n*\n* @private\n* @param {Int8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var arr = new Int8Array( 4 );\n*\n* setInt8( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setInt8( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint32Array`.\n*\n* @private\n* @param {Uint32Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint32Array from '@stdlib/array/uint32';\n*\n* var arr = new Uint32Array( 4 );\n*\n* setUint32( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint32( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint16Array`.\n*\n* @private\n* @param {Uint16Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint16Array from '@stdlib/array/uint16';\n*\n* var arr = new Uint16Array( 4 );\n*\n* setUint16( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint16( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint8Array`.\n*\n* @private\n* @param {Uint8Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var arr = new Uint8Array( 4 );\n*\n* setUint8( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint8( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a `Uint8ClampedArray`.\n*\n* @private\n* @param {Uint8ClampedArray} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {number} value - value to set\n*\n* @example\n* import Uint8ClampedArray from '@stdlib/array/uint8c';\n*\n* var arr = new Uint8ClampedArray( 4 );\n*\n* setUint8c( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setUint8c( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in a generic `Array`.\n*\n* @private\n* @param {Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* setGeneric( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setGeneric( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n/**\n* Sets an element in an indexed array-like object.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* setArrayLike( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setArrayLike( arr, idx, value ) {\n\tarr[ idx ] = value;\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for setting an element in an indexed array-like object.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var set = setter( dtype( arr ) );\n* set( arr, 2, 3 );\n*\n* var v = arr[ 2 ];\n* // returns 3\n*/\nfunction setter( dtype ) {\n\tvar f = SETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn SETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar GETTERS = {\n\t'complex128': getComplex128,\n\t'complex64': getComplex64,\n\t'default': getArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an element from a `Complex128Array`.\n*\n* @private\n* @param {Complex128Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex128( arr, 1 );\n* // returns \n*\n* var re = real( v );\n* // returns 3.0\n*\n* var im = imag( v );\n* // returns 4.0\n*/\nfunction getComplex128( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from a `Complex64Array`.\n*\n* @private\n* @param {Complex64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {number} element value\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var v = getComplex64( arr, 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getComplex64( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n/**\n* Returns an element from an array-like object supporting the get/set protocol.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element value\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* function get( idx ) {\n* return arr[ idx ];\n* }\n*\n* function set( value, idx ) {\n* arr[ idx ] = value;\n* }\n*\n* arr.get = get;\n* arr.set = set;\n*\n* var v = getArrayLike( arr, 2 );\n* // returns 3\n*/\nfunction getArrayLike( arr, idx ) {\n\treturn arr.get( idx );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for retrieving an element from an array-like object supporting the get/set protocol.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var get = getter( dtype( arr ) );\n* var v = get( arr, 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 3.0\n*\n* var im = imagf( v );\n* // returns 4.0\n*/\nfunction getter( dtype ) {\n\tvar f = GETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn GETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar SETTERS = {\n\t'complex128': setComplex128,\n\t'complex64': setComplex64,\n\t'default': setArrayLike\n};\n\n\n// FUNCTIONS //\n\n/**\n* Sets an element in a `Complex128Array`.\n*\n* @private\n* @param {Complex128Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( [ 1, 2, 3, 4 ] );\n*\n* setComplex128( arr, 1, new Complex128( 10.0, 11.0 ) );\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = real( v );\n* // returns 10.0\n*\n* var im = imag( v );\n* // returns 11.0\n*/\nfunction setComplex128( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n/**\n* Sets an element in a `Complex64Array`.\n*\n* @private\n* @param {Complex64Array} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* setComplex64( arr, 1, new Complex64( 10.0, 11.0 ) );\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 11.0\n*/\nfunction setComplex64( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n/**\n* Sets an element in an array-like object supporting the get/set protocol.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n*\n* @example\n* var arr = [ 1, 2, 3, 4 ];\n*\n* function get( idx ) {\n* return arr[ idx ];\n* }\n*\n* function set( value, idx ) {\n* arr[ idx ] = value;\n* }\n*\n* arr.get = get;\n* arr.set = set;\n*\n* setArrayLike( arr, 2, 10 );\n*\n* var v = arr[ 2 ];\n* // returns 10\n*/\nfunction setArrayLike( arr, idx, value ) {\n\tarr.set( value, idx );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for setting an element in an array-like object supporting the get/set protocol.\n*\n* @param {string} dtype - array dtype\n* @returns {Function} accessor\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import dtype from '@stdlib/array/dtype';\n*\n* var arr = new Complex64Array( [ 1, 2, 3, 4 ] );\n*\n* var set = setter( dtype( arr ) );\n* set( arr, 1, new Complex64( 10.0, 11.0 ) );\n*\n* var v = arr.get( 1 );\n* // returns \n*\n* var re = realf( v );\n* // returns 10.0\n*\n* var im = imagf( v );\n* // returns 11.0\n*/\nfunction setter( dtype ) {\n\tvar f = SETTERS[ dtype ];\n\tif ( typeof f === 'function' ) {\n\t\treturn f;\n\t}\n\treturn SETTERS.default;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Mapping from array constructors to data types...\nvar ctor2dtypes = {\n\t'Float32Array': 'float32',\n\t'Float64Array': 'float64',\n\t'Array': 'generic',\n\t'Int16Array': 'int16',\n\t'Int32Array': 'int32',\n\t'Int8Array': 'int8',\n\t'Uint16Array': 'uint16',\n\t'Uint32Array': 'uint32',\n\t'Uint8Array': 'uint8',\n\t'Uint8ClampedArray': 'uint8c',\n\t'Complex64Array': 'complex64',\n\t'Complex128Array': 'complex128',\n\t'BooleanArray': 'bool'\n};\n\n\n// EXPORTS //\n\nexport default ctor2dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int32Array === 'function' ) ? Int32Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 32-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int32\n*\n* @example\n* import ctor from '@stdlib/array/int32';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt32ArraySupport from '@stdlib/assert/has-int32array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt32ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 32-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int16Array === 'function' ) ? Int16Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 16-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int16\n*\n* @example\n* import ctor from '@stdlib/array/int16';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt16ArraySupport from '@stdlib/assert/has-int16array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt16ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 16-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Uint8ClampedArray === 'function' ) ? Uint8ClampedArray : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order clamped to 0-255.\n*\n* @module @stdlib/array/uint8c\n*\n* @example\n* import ctor from '@stdlib/array/uint8c';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasUint8ClampedArraySupport from '@stdlib/assert/has-uint8clampedarray-support'; // eslint-disable-line id-length\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasUint8ClampedArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of 8-bit unsigned integers in the platform byte order clamped to 0-255.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof Int8Array === 'function' ) ? Int8Array : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array constructor which returns a typed array representing an array of twos-complement 8-bit signed integers in the platform byte order.\n*\n* @module @stdlib/array/int8\n*\n* @example\n* import ctor from '@stdlib/array/int8';\n*\n* var arr = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasInt8ArraySupport from '@stdlib/assert/has-int8array-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasInt8ArraySupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Typed array which represents an array of twos-complement 8-bit signed integers in the platform byte order.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tz = v.value;\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( realf( z ), imagf( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/* eslint-disable no-restricted-syntax, max-lines, no-invalid-this */\n\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isArray from '@stdlib/assert/is-array';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport isFunction from '@stdlib/assert/is-function';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport isEven from '@stdlib/math/base/assert/is-even';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport isComplex64Array from './../../base/assert/is-complex64array';\nimport isComplex128Array from './../../base/assert/is-complex128array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Float32Array from './../../float32';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport format from '@stdlib/string/format';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport floor from '@stdlib/math/base/special/floor';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Float32Array.BYTES_PER_ELEMENT * 2;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a complex typed array.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*/\nfunction isComplexArray( value ) {\n\treturn (\n\t\tvalue instanceof Complex64Array ||\n\t\t(\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex64Array' ||\n\t\t\t\tvalue.constructor.name === 'Complex128Array'\n\t\t\t) &&\n\t\t\ttypeof value._length === 'number' && // eslint-disable-line no-underscore-dangle\n\n\t\t\t// NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks...\n\t\t\ttypeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle\n\t\t)\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a complex typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array constructor\n*/\nfunction isComplexArrayConstructor( value ) {\n\treturn (\n\t\tvalue === Complex64Array ||\n\n\t\t// NOTE: weaker test in order to avoid a circular dependency with Complex128Array...\n\t\tvalue.name === 'Complex128Array'\n\t);\n}\n\n/**\n* Retrieves a complex number from a complex number array buffer.\n*\n* @private\n* @param {Float32Array} buf - array buffer\n* @param {NonNegativeInteger} idx - element index\n* @returns {Complex64} complex number\n*/\nfunction getComplex64( buf, idx ) {\n\tidx *= 2;\n\treturn new Complex64( buf[ idx ], buf[ idx+1 ] );\n}\n\n\n// MAIN //\n\n/**\n* 64-bit complex number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `8`\n* @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `8`\n* @throws {TypeError} view length must be a positive multiple of `8`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex64Array} complex number array\n*\n* @example\n* var arr = new Complex64Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Complex64Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Complex64Array( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Complex64Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Complex64Array( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex64Array( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Complex64Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Complex64Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Complex64Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Complex64Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Complex64Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Complex64Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Float32Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\tif ( isNonNegativeInteger( arguments[0] ) ) {\n\t\t\tbuf = new Float32Array( arguments[0]*2 );\n\t\t} else if ( isCollection( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tlen = buf.length;\n\n\t\t\t// If provided a \"generic\" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to \"normal\" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number...\n\t\t\tif ( len && isArray( buf ) && isComplexLike( buf[0] ) ) {\n\t\t\t\tbuf = fromArray( new Float32Array( len*2 ), buf );\n\t\t\t\tif ( buf === null ) {\n\t\t\t\t\t// We failed and we are now forced to allocate a new array :-(\n\t\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t\t}\n\t\t\t\t\t// We failed, so fall back to directly setting values...\n\t\t\t\t\tbuf = new Float32Array( arguments[0] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( isComplex64Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret64( buf, 0 );\n\t\t\t\t} else if ( isComplex128Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret128( buf, 0 );\n\t\t\t\t} else if ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tbuf = new Float32Array( buf );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf );\n\t\t} else if ( isObject( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tif ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = buf[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) ); // FIXME: `buf` is what is returned from above, NOT the original value\n\t\t\t}\n\t\t\tbuf = fromIterator( buf );\n\t\t\tif ( buf instanceof Error ) {\n\t\t\t\tthrow buf;\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arguments[0] ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Float32Array( buf, byteOffset, len*2 );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length/2 );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64Array\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var nbytes = Complex64Array.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex64Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex64Array\n* @readonly\n* @type {string}\n* @default 'Complex64Array'\n*\n* @example\n* var str = Complex64Array.name;\n* // returns 'Complex64Array'\n*/\nsetReadOnly( Complex64Array, 'name', 'Complex64Array' );\n\n/**\n* Creates a new 64-bit complex number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Complex64Array\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex64Array} 64-bit complex number array\n*\n* @example\n* var arr = Complex64Array.from( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function clbk( v ) {\n* return new Complex64( realf(v)*2.0, imagf(v)*2.0 );\n* }\n*\n* var arr = Complex64Array.from( [ new Complex64( 1.0, 1.0 ) ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*/\nsetReadOnly( Complex64Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar flg;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isComplexArray( src ) ) {\n\t\tlen = src.length;\n\t\tif ( clbk ) {\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, src.get( i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = realf( v );\n\t\t\t\t\tbuf[ j+1 ] = imagf( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\t// Note: array contents affect how we iterate over a provided data source. If only complex number objects, we can extract real and imaginary components. Otherwise, for non-complex number arrays (e.g., `Float64Array`, etc), we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component.\n\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\t// Detect whether we've been provided an array which returns complex number objects...\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tif ( !isComplexLike( get( src, i ) ) ) {\n\t\t\t\t\tflg = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If an array does not contain only complex number objects, then we assume interleaved real and imaginary components...\n\t\t\tif ( flg ) {\n\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. First argument must have a length which is a multiple of %u. Length: `%u`.', 2, len ) );\n\t\t\t\t}\n\t\t\t\tout = new this( len/2 );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ i ] = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\t// If an array contains only complex number objects, then we need to extract real and imaginary components...\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = realf( v );\n\t\t\t\t\tbuf[ j+1 ] = imagf( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length / 2;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 64-bit complex number array from a variable number of arguments.\n*\n* @name of\n* @memberof Complex64Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} 64-bit complex number array\n*\n* @example\n* var arr = Complex64Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Complex64Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide an integer\n* @returns {(Complex64|void)} array element\n*\n* @example\n* var arr = new Complex64Array( 10 );\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var z = arr.at( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 9.0, -9.0 ], 9 );\n*\n* z = arr.at( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*\n* z = arr.at( -1 );\n* // returns \n*\n* re = realf( z );\n* // returns 9.0\n*\n* im = imagf( z );\n* // returns -9.0\n*\n* z = arr.at( 100 );\n* // returns undefined\n*\n* z = arr.at( -100 );\n* // returns undefined\n*/\nsetReadOnly( Complex64Array.prototype, 'at', function at( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex64( this._buffer, idx );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 80\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 8\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 8\n*/\nsetReadOnly( Complex64Array.prototype, 'BYTES_PER_ELEMENT', Complex64Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} modified array\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 4 );\n*\n* // Set the array elements:\n* arr.set( new Complex64( 1.0, 1.0 ), 0 );\n* arr.set( new Complex64( 2.0, 2.0 ), 1 );\n* arr.set( new Complex64( 3.0, 3.0 ), 2 );\n* arr.set( new Complex64( 4.0, 4.0 ), 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* // Get the last array element:\n* var z = arr.get( 3 );\n*\n* var re = realf( z );\n* // returns 2.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex64Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target*2, start*2 );\n\t} else {\n\t\tthis._buffer.copyWithin( target*2, start*2, arguments[2]*2 );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = [\n* new Complex64( 1.0, 1.0 ),\n* new Complex64( 2.0, 2.0 ),\n* new Complex64( 3.0, 3.0 )\n* ];\n* arr = new Complex64Array( arr );\n*\n* // Create an iterator:\n* var it = arr.entries();\n*\n* // Iterate over the key-value pairs...\n* var v = it.next().value;\n* // returns [ 0, ]\n*\n* v = it.next().value;\n* // returns [ 1, ]\n*\n* v = it.next().value;\n* // returns [ 2, ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, getComplex64( buf, i ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, getComplex64( buf, i ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Complex64Array} modified array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.fill( new Complex64( 1.0, 1.0 ), 1 );\n*\n* var z = arr.get( 1 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 1.0\n*\n* z = arr.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tre = realf( value );\n\tim = imagf( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tidx = 2*i;\n\t\tbuf[ idx ] = re;\n\t\tbuf[ idx+1 ] = im;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 1\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 2.0\n*\n* var im = imagf( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex64Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\tout.push( z );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex64|void)} array element or undefined\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.find( predicate );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var idx = arr.findIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( Complex64Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex64|void)} array element or undefined\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.findLast( predicate );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var idx = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Complex64Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex64( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Complex64Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex64( buf, i );\n\t\tfcn.call( thisArg, z, i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(Complex64|void)} array element\n*\n* @example\n* var arr = new Complex64Array( 10 );\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*\n* z = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( Complex64Array.prototype, 'get', function get( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex64( this._buffer, idx );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a provided value\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var bool = arr.includes( new Complex64( 3.0, -3.0 ) );\n* // returns true\n*\n* bool = arr.includes( new Complex64( 3.0, -3.0 ), 3 );\n* // returns false\n*\n* bool = arr.includes( new Complex64( 4.0, -4.0 ), -3 );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 10 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var idx = arr.indexOf( new Complex64( 3.0, -3.0 ) );\n* // returns 2\n*\n* idx = arr.indexOf( new Complex64( 3.0, -3.0 ), 3 );\n* // returns -1\n*\n* idx = arr.indexOf( new Complex64( 4.0, -4.0 ), -3 );\n* // returns -1\n*/\nsetReadOnly( Complex64Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.join();\n* // returns '1 + 1i,2 + 2i'\n*\n* str = arr.join( '/' );\n* // returns '1 + 1i/2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'join', function join( separator ) {\n\tvar out;\n\tvar buf;\n\tvar sep;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tsep = ',';\n\t} else if ( isString( separator ) ) {\n\t\tsep = separator;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toString() );\n\t}\n\treturn out.join( sep );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex] - index at which to start searching backward (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 3.0, -3.0 ], 4 );\n*\n* var idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ) );\n* // returns 4\n*\n* idx = arr.lastIndexOf( new Complex64( 3.0, -3.0 ), 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( new Complex64( 5.0, -5.0 ), 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( new Complex64( 2.0, -2.0 ), -3 );\n* // returns 1\n*/\nsetReadOnly( Complex64Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tre = realf( searchElement );\n\tim = imagf( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Complex64Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex64Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Complex64Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function scale( v, i ) {\n* return new Complex64( 2.0*realf( v ), 2.0*imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 2\n*\n* var im = imagf( z );\n* // returns -2\n*/\nsetReadOnly( Complex64Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fcn.call( thisArg, getComplex64( buf, i ), i, this );\n\t\tif ( isComplexLike( v ) ) {\n\t\t\toutbuf[ 2*i ] = realf( v );\n\t\t\toutbuf[ (2*i)+1 ] = imagf( v );\n\t\t} else if ( isArrayLikeObject( v ) && v.length === 2 ) {\n\t\t\toutbuf[ 2*i ] = v[ 0 ];\n\t\t\toutbuf[ (2*i)+1 ] = v[ 1 ];\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t}\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import caddf from '@stdlib/complex/float32/base/add';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduce( caddf );\n* // returns \n*\n* var re = realf( z );\n* // returns 6.0\n*\n* var im = imagf( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex64( buf, 0 );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tv = getComplex64( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import caddf from '@stdlib/complex/float32/base/add';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduceRight( caddf );\n* // returns \n*\n* var re = realf( z );\n* // returns 6.0\n*\n* var im = imagf( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len-1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex64( buf, len-1 );\n\t\ti = len-2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tv = getComplex64( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} reversed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ (2*i) ];\n\t\tbuf[ (2*i) ] = buf[ (2*j) ];\n\t\tbuf[ (2*j) ] = tmp;\n\t\ttmp = buf[ (2*i)+1 ];\n\t\tbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t\tbuf[ (2*j)+1 ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 0.0\n*\n* var im = imagf( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns -1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'set', function set( value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tidx *= 2;\n\t\tbuf[ idx ] = realf( value );\n\t\tbuf[ idx+1 ] = imagf( value );\n\t\treturn;\n\t}\n\tif ( isComplexArray( value ) ) {\n\t\tN = value._length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tsbuf = value._buffer;\n\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Float32Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tidx *= 2;\n\t\tj = 0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\tidx += 2; // stride\n\t\t\tj += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// Detect whether we've been provided an array of complex numbers...\n\t\tN = value.length;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tif ( !isComplexLike( value[ i ] ) ) {\n\t\t\t\tflg = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// If an array does not contain only complex numbers, then we assume interleaved real and imaginary components...\n\t\tif ( flg ) {\n\t\t\tif ( !isEven( N ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', N ) );\n\t\t\t}\n\t\t\tif ( idx+(N/2) > this._length ) {\n\t\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t\t}\n\t\t\tsbuf = value;\n\n\t\t\t// Check for overlapping memory...\n\t\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\t\tif (\n\t\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t\t(\n\t\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// We need to copy source values...\n\t\t\t\ttmp = new Float32Array( N );\n\t\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\t\ttmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays\n\t\t\t\t}\n\t\t\t\tsbuf = tmp;\n\t\t\t}\n\t\t\tidx *= 2;\n\t\t\tN /= 2;\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\t\tidx += 2; // stride\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// If an array contains only complex numbers, then we need to extract real and imaginary components...\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tidx *= 2;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tv = value[ i ];\n\t\t\tbuf[ idx ] = realf( v );\n\t\t\tbuf[ idx+1 ] = imagf( v );\n\t\t\tidx += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.', value ) );\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} complex number array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 5.0\n*\n* im = imagf( z );\n* // returns -5.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* z = out.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'slice', function slice( start, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar idx;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tstart = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( start < end ) {\n\t\toutlen = end - start;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\tidx = 2*(i+start);\n\t\toutbuf[ 2*i ] = buf[ idx ];\n\t\toutbuf[ (2*i)+1 ] = buf[ idx+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function predicate( v ) {\n* return ( realf( v ) === imagf( v ) );\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, getComplex64( buf, i ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} sorted array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = realf( a );\n* re2 = realf( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imagf( a );\n* im2 = imagf( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex64( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = 2 * i;\n\t\tbuf[ j ] = realf( tmp[i] );\n\t\tbuf[ j+1 ] = imagf( tmp[i] );\n\t}\n\treturn this;\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} [begin=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} subarray\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var z = subarr.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 5.0\n*\n* im = imagf( z );\n* // returns -5.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* z = subarr.get( 0 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + (begin*BYTES_PER_ELEMENT);\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toLocaleString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex64Array} reversed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 3.0\n*\n* var im = imagf( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 1.0\n*\n* im = imagf( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex64Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = len - i - 1;\n\t\toutbuf[ (2*i) ] = buf[ (2*j) ];\n\t\toutbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex64Array} sorted array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = realf( a );\n* re2 = realf( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imagf( a );\n* im2 = imagf( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 1.0\n*\n* var im = imagf( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = realf( z );\n* // returns 2.0\n*\n* im = imagf( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = realf( z );\n* // returns 3.0\n*\n* im = imagf( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex64Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex64( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\treturn new Complex64Array( tmp );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex64Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex64( buf, i ).toString() );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* var arr = new Complex64Array( 2 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns \n*\n* var re = realf( v );\n* // returns 1.0\n*\n* var im = imagf( v );\n* // returns -1.0\n*\n* v = iter.next().value;\n* // returns \n*\n* re = realf( v );\n* // returns 2.0\n*\n* im = imagf( v );\n* // returns -2.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex64Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': getComplex64( buf, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Complex64Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {ComplexLike} value - new value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a complex number\n* @returns {Complex64Array} new typed array\n*\n* @example\n* import realf from '@stdlib/complex/float32/real';\n* import imagf from '@stdlib/complex/float32/imag';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n*\n* var arr = new Complex64Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.with( 0, new Complex64( 4.0, 4.0 ) );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = realf( z );\n* // returns 4.0\n*\n* var im = imagf( z );\n* // returns 4.0\n*/\nsetReadOnly( Complex64Array.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tbuf[ 2*index ] = realf( value );\n\tbuf[ (2*index)+1 ] = imagf( value );\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Complex64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\n\n\n// MAIN //\n\n/**\n* Returns a strided array of real and imaginary components.\n*\n* @private\n* @param {Float32Array} buf - output array\n* @param {Array} arr - array containing complex numbers\n* @returns {(Float32Array|null)} output array or null\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tlen = arr.length;\n\tj = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = arr[ i ];\n\t\tif ( !isComplexLike( v ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tbuf[ j ] = realf( v );\n\t\tbuf[ j+1 ] = imagf( v );\n\t\tj += 2; // stride\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport format from '@stdlib/string/format';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tz = v.value;\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( real( z ), imag( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. An iterator must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tz = clbk.call( thisArg, v.value, i );\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( realf( z ), imagf( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/* eslint-disable no-restricted-syntax, max-lines, no-invalid-this */\n\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isArray from '@stdlib/assert/is-array';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport isString from '@stdlib/assert/is-string';\nimport isFunction from '@stdlib/assert/is-function';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport isEven from '@stdlib/math/base/assert/is-even';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport isComplex64Array from './../../base/assert/is-complex64array';\nimport isComplex128Array from './../../base/assert/is-complex128array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Float64Array from './../../float64';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport floor from '@stdlib/math/base/special/floor';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Float64Array.BYTES_PER_ELEMENT * 2;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a complex typed array.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*/\nfunction isComplexArray( value ) {\n\treturn (\n\t\tvalue instanceof Complex128Array ||\n\t\t(\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\t(\n\t\t\t\tvalue.constructor.name === 'Complex64Array' ||\n\t\t\t\tvalue.constructor.name === 'Complex128Array'\n\t\t\t) &&\n\t\t\ttypeof value._length === 'number' && // eslint-disable-line no-underscore-dangle\n\n\t\t\t// NOTE: we don't perform a more rigorous test here for a typed array for performance reasons, as robustly checking for a typed array instance could require walking the prototype tree and performing relatively expensive constructor checks...\n\t\t\ttypeof value._buffer === 'object' // eslint-disable-line no-underscore-dangle\n\t\t)\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a complex typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array constructor\n*/\nfunction isComplexArrayConstructor( value ) {\n\treturn (\n\t\tvalue === Complex128Array ||\n\n\t\t// NOTE: weaker test in order to avoid a circular dependency with Complex64Array...\n\t\tvalue.name === 'Complex64Array'\n\t);\n}\n\n/**\n* Retrieves a complex number from a complex number array buffer.\n*\n* @private\n* @param {Float64Array} buf - array buffer\n* @param {NonNegativeInteger} idx - element index\n* @returns {Complex128} complex number\n*/\nfunction getComplex128( buf, idx ) {\n\tidx *= 2;\n\treturn new Complex128( buf[ idx ], buf[ idx+1 ] );\n}\n\n\n// MAIN //\n\n/**\n* 128-bit complex number array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {RangeError} ArrayBuffer byte length must be a multiple of `16`\n* @throws {RangeError} array-like object and typed array input arguments must have a length which is a multiple of two\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} byte offset must be a multiple of `16`\n* @throws {TypeError} view length must be a positive multiple of `16`\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex128Array} complex number array\n*\n* @example\n* var arr = new Complex128Array();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Complex128Array( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Complex128Array( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex128Array( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Complex128Array( buf, 16 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 64 );\n* var arr = new Complex128Array( buf, 16, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction Complex128Array() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof Complex128Array) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new Complex128Array();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new Complex128Array( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new Complex128Array( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new Complex128Array( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Float64Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\tif ( isNonNegativeInteger( arguments[0] ) ) {\n\t\t\tbuf = new Float64Array( arguments[0]*2 );\n\t\t} else if ( isCollection( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tlen = buf.length;\n\n\t\t\t// If provided a \"generic\" array, peak at the first value, and, if the value is a complex number, try to process as an array of complex numbers, falling back to \"normal\" typed array initialization if we fail and ensuring consistency if the first value had not been a complex number...\n\t\t\tif ( len && isArray( buf ) && isComplexLike( buf[0] ) ) {\n\t\t\t\tbuf = fromArray( new Float64Array( len*2 ), buf );\n\t\t\t\tif ( buf === null ) {\n\t\t\t\t\t// We failed and we are now forced to allocate a new array :-(\n\t\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t\t}\n\t\t\t\t\t// We failed, so fall back to directly setting values...\n\t\t\t\t\tbuf = new Float64Array( arguments[0] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif ( isComplex64Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret64( buf, 0 );\n\t\t\t\t} else if ( isComplex128Array( buf ) ) {\n\t\t\t\t\tbuf = reinterpret128( buf, 0 );\n\t\t\t\t} else if ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object and typed array arguments must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tbuf = new Float64Array( buf );\n\t\t\t}\n\t\t} else if ( isArrayBuffer( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( !isInteger( buf.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf );\n\t\t} else if ( isObject( arguments[0] ) ) {\n\t\t\tbuf = arguments[ 0 ];\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tif ( !isFunction( buf[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = buf[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbuf = fromIterator( buf );\n\t\t\tif ( buf instanceof Error ) {\n\t\t\t\tthrow buf;\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arguments[0] ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Byte offset must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tlen = buf.byteLength - byteOffset;\n\t\t\tif ( !isInteger( len/BYTES_PER_ELEMENT ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, len ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Float64Array( buf, byteOffset, len*2 );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length/2 );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128Array\n* @readonly\n* @type {PositiveInteger}\n* @default 16\n*\n* @example\n* var nbytes = Complex128Array.BYTES_PER_ELEMENT;\n* // returns 16\n*/\nsetReadOnly( Complex128Array, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof Complex128Array\n* @readonly\n* @type {string}\n* @default 'Complex128Array'\n*\n* @example\n* var name = Complex128Array.name;\n* // returns 'Complex128Array'\n*/\nsetReadOnly( Complex128Array, 'name', 'Complex128Array' );\n\n/**\n* Creates a new 128-bit complex number array from an array-like object or an iterable.\n*\n* @name from\n* @memberof Complex128Array\n* @type {Function}\n* @param {(Collection|Object)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {TypeError} an iterator must return either a two element array containing real and imaginary components or a complex number\n* @throws {TypeError} when provided an iterator, a callback must return either a two element array containing real and imaginary components or a complex number\n* @returns {Complex128Array} 128-bit complex number array\n*\n* @example\n* var arr = Complex128Array.from( [ 1.0, -1.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function clbk( v ) {\n* return new Complex128( real(v)*2.0, imag(v)*2.0 );\n* }\n*\n* var arr = Complex128Array.from( [ new Complex128( 1.0, 1.0 ) ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*/\nsetReadOnly( Complex128Array, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar flg;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isComplexArray( src ) ) {\n\t\tlen = src.length;\n\t\tif ( clbk ) {\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, src.get( i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = real( v );\n\t\t\t\t\tbuf[ j+1 ] = imag( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\t// Note: array contents affect how we iterate over a provided data source. If only complex number objects, we can extract real and imaginary components. Otherwise, for non-complex number arrays (e.g., `Float64Array`, etc), we assume a strided array where real and imaginary components are interleaved. In the former case, we expect a callback to return real and imaginary components (possibly as a complex number). In the latter case, we expect a callback to return *either* a real or imaginary component.\n\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\t// Detect whether we've been provided an array which returns complex number objects...\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tif ( !isComplexLike( get( src, i ) ) ) {\n\t\t\t\t\tflg = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If an array does not contain only complex number objects, then we assume interleaved real and imaginary components...\n\t\t\tif ( flg ) {\n\t\t\t\tif ( !isEven( len ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. First argument must have a length which is a multiple of two. Length: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tout = new this( len/2 );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ i ] = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\t// If an array contains only complex number objects, then we need to extract real and imaginary components...\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tv = clbk.call( thisArg, get( src, i ), i );\n\t\t\t\tif ( isComplexLike( v ) ) {\n\t\t\t\t\tbuf[ j ] = real( v );\n\t\t\t\t\tbuf[ j+1 ] = imag( v );\n\t\t\t\t} else if ( isArrayLikeObject( v ) && v.length >= 2 ) {\n\t\t\t\t\tbuf[ j ] = v[ 0 ];\n\t\t\t\t\tbuf[ j+1 ] = v[ 1 ];\n\t\t\t\t} else {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t\t\t}\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tif ( tmp instanceof Error ) {\n\t\t\tthrow tmp;\n\t\t}\n\t\tlen = tmp.length / 2;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new 128-bit complex number array from a variable number of arguments.\n*\n* @name of\n* @memberof Complex128Array\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} 128-bit complex number array\n*\n* @example\n* var arr = Complex128Array.of( 1.0, 1.0, 1.0, 1.0 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( Complex128Array, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isComplexArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide an integer\n* @returns {(Complex128|void)} array element\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 10 );\n*\n* var z = arr.at( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 9.0, -9.0 ], 9 );\n*\n* z = arr.at( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*\n* z = arr.at( -1 );\n* // returns \n*\n* re = real( z );\n* // returns 9.0\n*\n* im = imag( z );\n* // returns -9.0\n*\n* z = arr.at( 100 );\n* // returns undefined\n*\n* z = arr.at( -100 );\n* // returns undefined\n*/\nsetReadOnly( Complex128Array.prototype, 'at', function at( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx < 0 ) {\n\t\tidx += this._length;\n\t}\n\tif ( idx < 0 || idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex128( this._buffer, idx );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 160\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 16\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 16\n*/\nsetReadOnly( Complex128Array.prototype, 'BYTES_PER_ELEMENT', Complex128Array.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} modified array\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 4 );\n*\n* // Set the array elements:\n* arr.set( new Complex128( 1.0, 1.0 ), 0 );\n* arr.set( new Complex128( 2.0, 2.0 ), 1 );\n* arr.set( new Complex128( 3.0, 3.0 ), 2 );\n* arr.set( new Complex128( 4.0, 4.0 ), 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* // Get the last array element:\n* var z = arr.get( 3 );\n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target*2, start*2 );\n\t} else {\n\t\tthis._buffer.copyWithin( target*2, start*2, arguments[2]*2 );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = [\n* new Complex128( 1.0, 1.0 ),\n* new Complex128( 2.0, 2.0 ),\n* new Complex128( 3.0, 3.0 )\n* ];\n* arr = new Complex128Array( arr );\n*\n* // Create an iterator:\n* var it = arr.entries();\n*\n* // Iterate over the key-value pairs...\n* var v = it.next().value;\n* // returns [ 0, ]\n*\n* v = it.next().value;\n* // returns [ 1, ]\n*\n* v = it.next().value;\n* // returns [ 2, ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'entries', function entries() {\n\tvar buffer;\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuffer = this._buffer;\n\tlen = this._length;\n\n\t// Initialize the iteration indices:\n\ti = -1;\n\tj = -2;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\tvar z;\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tj += 2;\n\t\tz = new Complex128( buffer[ j ], buffer[ j+1 ] );\n\t\treturn {\n\t\t\t'value': [ i, z ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, getComplex128( buf, i ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Complex128Array} modified array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.fill( new Complex128( 1.0, 1.0 ), 1 );\n*\n* var z = arr.get( 1 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns 1.0\n*\n* z = arr.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tre = real( value );\n\tim = imag( value );\n\tfor ( i = start; i < end; i++ ) {\n\t\tidx = 2*i;\n\t\tbuf[ idx ] = re;\n\t\tbuf[ idx+1 ] = im;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 1\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns 2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\tout.push( z );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex128|void)} array element or undefined\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.find( predicate );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var idx = arr.findIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( Complex128Array.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {(Complex128|void)} array element or undefined\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.findLast( predicate );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn z;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var idx = arr.findLastIndex( predicate );\n* // returns 1\n*/\nsetReadOnly( Complex128Array.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tz = getComplex128( buf, i );\n\t\tif ( predicate.call( thisArg, z, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( Complex128Array.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\tvar z;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tz = getComplex128( buf, i );\n\t\tfcn.call( thisArg, z, i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(Complex128|void)} array element\n*\n* @example\n* var arr = new Complex128Array( 10 );\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*\n* z = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( Complex128Array.prototype, 'get', function get( idx ) {\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn getComplex128( this._buffer, idx );\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof Complex128Array.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new Complex128Array( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( Complex128Array.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a provided value\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var bool = arr.includes( new Complex128( 3.0, -3.0 ) );\n* // returns true\n*\n* bool = arr.includes( new Complex128( 3.0, -3.0 ), 3 );\n* // returns false\n*\n* bool = arr.includes( new Complex128( 4.0, -4.0 ), -3 );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var idx = arr.indexOf( new Complex128( 3.0, -3.0 ) );\n* // returns 2\n*\n* idx = arr.indexOf( new Complex128( 3.0, -3.0 ), 3 );\n* // returns -1\n*\n* idx = arr.indexOf( new Complex128( 4.0, -4.0 ), -3 );\n* // returns 3\n*/\nsetReadOnly( Complex128Array.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.join();\n* // returns '1 + 1i,2 + 2i'\n*\n* str = arr.join( '/' );\n* // returns '1 + 1i/2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'join', function join( separator ) {\n\tvar out;\n\tvar buf;\n\tvar sep;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tsep = ',';\n\t} else if ( isString( separator ) ) {\n\t\tsep = separator;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toString() );\n\t}\n\treturn out.join( sep );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {ComplexLike} searchElement - element to find\n* @param {integer} [fromIndex] - index at which to start searching backward (inclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a complex number\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 3.0, -3.0 ], 4 );\n*\n* var idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ) );\n* // returns 4\n*\n* idx = arr.lastIndexOf( new Complex128( 3.0, -3.0 ), 3 );\n* // returns 2\n*\n* idx = arr.lastIndexOf( new Complex128( 5.0, -5.0 ), 3 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( new Complex128( 2.0, -2.0 ), -3 );\n* // returns 1\n*/\nsetReadOnly( Complex128Array.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar idx;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isComplexLike( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a complex number. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tidx = 2 * i;\n\t\tif ( re === buf[ idx ] && im === buf[ idx+1 ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function scale( v, i ) {\n* return new Complex128( 2.0*real( v ), 2.0*imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var out = arr.map( scale );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 2.0\n*\n* var im = imag( z );\n* // returns -2.0\n*/\nsetReadOnly( Complex128Array.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = fcn.call( thisArg, getComplex128( buf, i ), i, this );\n\t\tif ( isComplexLike( v ) ) {\n\t\t\toutbuf[ 2*i ] = real( v );\n\t\t\toutbuf[ (2*i)+1 ] = imag( v );\n\t\t} else if ( isArrayLikeObject( v ) && v.length === 2 ) {\n\t\t\toutbuf[ 2*i ] = v[ 0 ];\n\t\t\toutbuf[ (2*i)+1 ] = v[ 1 ];\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', v ) );\n\t\t}\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import cadd from '@stdlib/complex/float64/base/add';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduce( cadd );\n* // returns \n*\n* var re = real( z );\n* // returns 6.0\n*\n* var im = imag( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex128( buf, 0 );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tv = getComplex128( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import cadd from '@stdlib/complex/float64/base/add';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var z = arr.reduceRight( cadd );\n* // returns \n*\n* var re = real( z );\n* // returns 6.0\n*\n* var im = imag( z );\n* // returns 6.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar acc;\n\tvar len;\n\tvar v;\n\tvar i;\n\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len-1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = getComplex128( buf, len-1 );\n\t\ti = len-2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tv = getComplex128( buf, i );\n\t\tacc = reducer( acc, v, i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} reversed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ (2*i) ];\n\t\tbuf[ (2*i) ] = buf[ (2*j) ];\n\t\tbuf[ (2*j) ] = tmp;\n\t\ttmp = buf[ (2*i)+1 ];\n\t\tbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t\tbuf[ (2*j)+1 ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, real or complex, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values as intended.\n*\n* @name set\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {(Collection|Complex|ComplexArray)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be either a complex number, an array-like object, or a complex number array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} array-like objects must have a length which is a multiple of two\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 10 );\n*\n* var z = arr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 0.0\n*\n* var im = imag( z );\n* // returns 0.0\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n*\n* z = arr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns -1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'set', function set( value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar flg;\n\tvar N;\n\tvar v;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tidx *= 2;\n\t\tbuf[ idx ] = real( value );\n\t\tbuf[ idx+1 ] = imag( value );\n\t\treturn;\n\t}\n\tif ( isComplexArray( value ) ) {\n\t\tN = value._length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tsbuf = value._buffer;\n\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Float64Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tidx *= 2;\n\t\tj = 0;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\tidx += 2; // stride\n\t\t\tj += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// Detect whether we've been provided an array of complex numbers...\n\t\tN = value.length;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tif ( !isComplexLike( value[ i ] ) ) {\n\t\t\t\tflg = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t// If an array does not contain only complex numbers, then we assume interleaved real and imaginary components...\n\t\tif ( flg ) {\n\t\t\tif ( !isEven( N ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid argument. Array-like object arguments must have a length which is a multiple of two. Length: `%u`.', N ) );\n\t\t\t}\n\t\t\tif ( idx+(N/2) > this._length ) {\n\t\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t\t}\n\t\t\tsbuf = value;\n\n\t\t\t// Check for overlapping memory...\n\t\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\t\tif (\n\t\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t\t(\n\t\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// We need to copy source values...\n\t\t\t\ttmp = new Float64Array( N );\n\t\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\t\ttmp[ i ] = sbuf[ i ];\n\t\t\t\t}\n\t\t\t\tsbuf = tmp;\n\t\t\t}\n\t\t\tidx *= 2;\n\t\t\tN /= 2;\n\t\t\tj = 0;\n\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\tbuf[ idx ] = sbuf[ j ];\n\t\t\t\tbuf[ idx+1 ] = sbuf[ j+1 ];\n\t\t\t\tidx += 2; // stride\n\t\t\t\tj += 2; // stride\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\t// If an array contains only complex numbers, then we need to extract real and imaginary components...\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tidx *= 2;\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tv = value[ i ];\n\t\t\tbuf[ idx ] = real( v );\n\t\t\tbuf[ idx+1 ] = imag( v );\n\t\t\tidx += 2; // stride\n\t\t}\n\t\treturn;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be either a complex number, an array-like object, or a complex number array. Value: `%s`.', value ) );\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex128Array} complex number array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 5.0\n*\n* im = imag( z );\n* // returns -5.0\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* z = out.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'slice', function slice( start, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar idx;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tstart = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( start < end ) {\n\t\toutlen = end - start;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\tidx = 2*(i+start);\n\t\toutbuf[ 2*i ] = buf[ idx ];\n\t\toutbuf[ (2*i)+1 ] = buf[ idx+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function predicate( v ) {\n* return ( real( v ) === imag( v ) );\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, getComplex128( buf, i ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} sorted array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = real( a );\n* re2 = real( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imag( a );\n* im2 = imag( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'sort', function sort( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex128( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = 2 * i;\n\t\tbuf[ j ] = real( tmp[i] );\n\t\tbuf[ j+1 ] = imag( tmp[i] );\n\t}\n\treturn this;\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} [begin=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {Complex64Array} subarray\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 5 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n* arr.set( [ 3.0, -3.0 ], 2 );\n* arr.set( [ 4.0, -4.0 ], 3 );\n* arr.set( [ 5.0, -5.0 ], 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var z = subarr.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 5.0\n*\n* im = imag( z );\n* // returns -5.0\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* z = subarr.get( 0 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = subarr.get( len-1 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toLocaleString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Complex128Array} reversed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 3.0\n*\n* var im = imag( z );\n* // returns 3.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns 2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 1.0\n*\n* im = imag( z );\n* // returns 1.0\n*/\nsetReadOnly( Complex128Array.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\tvar j;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = len - i - 1;\n\t\toutbuf[ (2*i) ] = buf[ (2*j) ];\n\t\toutbuf[ (2*i)+1 ] = buf[ (2*j)+1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {Function} compareFcn - comparison function\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be a function\n* @returns {Complex128Array} sorted array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n*\n* function compare( a, b ) {\n* var re1;\n* var re2;\n* var im1;\n* var im2;\n* re1 = real( a );\n* re2 = real( b );\n* if ( re1 < re2 ) {\n* return -1;\n* }\n* if ( re1 > re2 ) {\n* return 1;\n* }\n* im1 = imag( a );\n* im2 = imag( b );\n* if ( im1 < im2 ) {\n* return -1;\n* }\n* if ( im1 > im2 ) {\n* return 1;\n* }\n* return 0;\n* }\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 3.0, -3.0 ], 0 );\n* arr.set( [ 1.0, -1.0 ], 1 );\n* arr.set( [ 2.0, -2.0 ], 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 1.0\n*\n* var im = imag( z );\n* // returns -1.0\n*\n* z = out.get( 1 );\n* // returns \n*\n* re = real( z );\n* // returns 2.0\n*\n* im = imag( z );\n* // returns -2.0\n*\n* z = out.get( 2 );\n* // returns \n*\n* re = real( z );\n* // returns 3.0\n*\n* im = imag( z );\n* // returns -3.0\n*/\nsetReadOnly( Complex128Array.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar tmp;\n\tvar buf;\n\tvar len;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\ttmp = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\ttmp.push( getComplex128( buf, i ) );\n\t}\n\ttmp.sort( compareFcn );\n\treturn new Complex128Array( tmp );\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {string} string representation\n*\n* @example\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n*\n* var str = arr.toString();\n* // returns '1 + 1i,2 + 2i'\n*/\nsetReadOnly( Complex128Array.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( getComplex128( buf, i ).toString() );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a complex number array\n* @returns {Iterator} iterator\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* var arr = new Complex128Array( 2 );\n*\n* arr.set( [ 1.0, -1.0 ], 0 );\n* arr.set( [ 2.0, -2.0 ], 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns \n*\n* var re = real( v );\n* // returns 1.0\n*\n* var im = imag( v );\n* // returns -1.0\n*\n* v = iter.next().value;\n* // returns \n*\n* re = real( v );\n* // returns 2.0\n*\n* im = imag( v );\n* // returns -2.0\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( Complex128Array.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': getComplex128( buf, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof Complex128Array.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {ComplexLike} value - new value\n* @throws {TypeError} `this` must be a complex number array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a complex number\n* @returns {Complex128Array} new typed array\n*\n* @example\n* import real from '@stdlib/complex/float64/real';\n* import imag from '@stdlib/complex/float64/imag';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var arr = new Complex128Array( 3 );\n*\n* arr.set( [ 1.0, 1.0 ], 0 );\n* arr.set( [ 2.0, 2.0 ], 1 );\n* arr.set( [ 3.0, 3.0 ], 2 );\n*\n* var out = arr.with( 0, new Complex128( 4.0, 4.0 ) );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns \n*\n* var re = real( z );\n* // returns 4.0\n*\n* var im = imag( z );\n* // returns 4.0\n*/\nsetReadOnly( Complex128Array.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\tif ( !isComplexArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a complex number array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isComplexLike( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a complex number. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tbuf[ 2*index ] = real( value );\n\tbuf[ (2*index)+1 ] = imag( value );\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default Complex128Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns a strided array of real and imaginary components.\n*\n* @private\n* @param {Float64Array} buf - output array\n* @param {Array} arr - array containing complex numbers\n* @returns {(Float64Array|null)} output array or null\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\tvar j;\n\n\tlen = arr.length;\n\tj = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = arr[ i ];\n\t\tif ( !isComplexLike( v ) ) {\n\t\t\treturn null;\n\t\t}\n\t\tbuf[ j ] = real( v );\n\t\tbuf[ j+1 ] = imag( v );\n\t\tj += 2; // stride\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( Boolean( v.value ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport format from '@stdlib/string/format';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {(Array|TypeError)} array or an error\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar z;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tz = clbk.call( thisArg, v.value, i );\n\t\tif ( isArrayLikeObject( z ) && z.length >= 2 ) {\n\t\t\tout.push( z[ 0 ], z[ 1 ] );\n\t\t} else if ( isComplexLike( z ) ) {\n\t\t\tout.push( real( z ), imag( z ) );\n\t\t} else {\n\t\t\treturn new TypeError( format( 'invalid argument. Callback must return either a two-element array containing real and imaginary components or a complex number. Value: `%s`.', z ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { primitives as isStringArray } from '@stdlib/assert/is-string-array';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport Uint8Array from './../../uint8';\nimport Boolean from '@stdlib/boolean/ctor';\nimport getter from './../../base/getter';\nimport floor from '@stdlib/math/base/special/floor';\nimport accessorGetter from './../../base/accessor-getter';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\nimport fromArray from './from_array.js';\n\n\n// VARIABLES //\n\nvar BYTES_PER_ELEMENT = Uint8Array.BYTES_PER_ELEMENT;\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\n\n\n// FUNCTIONS //\n\n/**\n* Returns a boolean indicating if a value is a `BooleanArray`.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a `BooleanArray`\n*/\nfunction isBooleanArray( value ) {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\tvalue.constructor.name === 'BooleanArray' &&\n\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t);\n}\n\n/**\n* Returns a boolean indicating if a value is a boolean typed array constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a boolean typed array constructor\n*/\nfunction isBooleanArrayConstructor( value ) {\n\treturn ( value === BooleanArray );\n}\n\n\n// MAIN //\n\n/**\n* Boolean array constructor.\n*\n* @constructor\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} if provided only a single argument, must provide a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new BooleanArray( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new BooleanArray( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 16\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new BooleanArray( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 8\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new BooleanArray( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction BooleanArray() {\n\tvar byteOffset;\n\tvar nargs;\n\tvar buf;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( !(this instanceof BooleanArray) ) {\n\t\tif ( nargs === 0 ) {\n\t\t\treturn new BooleanArray();\n\t\t}\n\t\tif ( nargs === 1 ) {\n\t\t\treturn new BooleanArray( arguments[0] );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\treturn new BooleanArray( arguments[0], arguments[1] );\n\t\t}\n\t\treturn new BooleanArray( arguments[0], arguments[1], arguments[2] );\n\t}\n\t// Create the underlying data buffer...\n\tif ( nargs === 0 ) {\n\t\tbuf = new Uint8Array( 0 ); // backward-compatibility\n\t} else if ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isCollection( arg ) ) {\n\t\t\tbuf = fromArray( new Uint8Array( arg.length ), arg );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tbuf = new Uint8Array( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( fromIterator( buf ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else {\n\t\tbuf = arguments[ 0 ];\n\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tbyteOffset = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t}\n\t\tif ( nargs === 2 ) {\n\t\t\tbuf = new Uint8Array( buf, byteOffset );\n\t\t} else {\n\t\t\tlen = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t}\n\t\t\tif ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) );\n\t\t\t}\n\t\t\tbuf = new Uint8Array( buf, byteOffset, len );\n\t\t}\n\t}\n\tsetReadOnly( this, '_buffer', buf );\n\tsetReadOnly( this, '_length', buf.length );\n\n\treturn this;\n}\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var nbytes = BooleanArray.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof BooleanArray\n* @readonly\n* @type {string}\n* @default 'BooleanArray'\n*\n* @example\n* var str = BooleanArray.name;\n* // returns 'BooleanArray'\n*/\nsetReadOnly( BooleanArray, 'name', 'BooleanArray' );\n\n/**\n* Creates a new boolean array from an array-like object or an iterable.\n*\n* @name from\n* @memberof BooleanArray\n* @type {Function}\n* @param {(Collection|Iterable)} src - array-like object or iterable\n* @param {Function} [clbk] - callback to invoke for each source element\n* @param {*} [thisArg] - context\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an array-like object or an iterable\n* @throws {TypeError} second argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.from( [ true, false ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* function clbk( v ) {\n* return !v;\n* }\n*\n* var arr = BooleanArray.from( [ true, false ], clbk );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nsetReadOnly( BooleanArray, 'from', function from( src ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar clbk;\n\tvar out;\n\tvar buf;\n\tvar tmp;\n\tvar get;\n\tvar len;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs > 1 ) {\n\t\tclbk = arguments[ 1 ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t\tif ( nargs > 2 ) {\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( isCollection( src ) ) {\n\t\tif ( clbk ) {\n\t\t\tlen = src.length;\n\t\t\tif ( src.get && src.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ i ] = Boolean( clbk.call( thisArg, get( src, i ), i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\treturn new this( src );\n\t}\n\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { // eslint-disable-line max-len\n\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\tif ( !isFunction( buf.next ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t}\n\t\tif ( clbk ) {\n\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t} else {\n\t\t\ttmp = fromIterator( buf );\n\t\t}\n\t\tlen = tmp.length;\n\t\tout = new this( len );\n\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tbuf[ i ] = tmp[ i ];\n\t\t}\n\t\treturn out;\n\t}\n\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n});\n\n/**\n* Creates a new boolean array from a variable number of arguments.\n*\n* @name of\n* @memberof BooleanArray\n* @type {Function}\n* @param {...*} element - array elements\n* @throws {TypeError} `this` context must be a constructor\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = BooleanArray.of( true, true, true, true );\n* // returns \n*\n* var len = arr.length;\n* // returns 4\n*/\nsetReadOnly( BooleanArray, 'of', function of() {\n\tvar args;\n\tvar i;\n\tif ( !isFunction( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t}\n\tif ( !isBooleanArrayConstructor( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\targs = [];\n\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\targs.push( arguments[ i ] );\n\t}\n\treturn new this( args );\n});\n\n/**\n* Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices.\n*\n* @name at\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide an integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.at( 0 );\n* // returns true\n*\n* v = arr.at( -1 );\n* // returns true\n*\n* v = arr.at( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'at', function at( idx ) {\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t}\n\tlen = this._length;\n\tbuf = this._buffer;\n\tif ( idx < 0 ) {\n\t\tidx += len;\n\t}\n\tif ( idx < 0 || idx >= len ) {\n\t\treturn;\n\t}\n\treturn Boolean( buf[ idx ] );\n});\n\n/**\n* Pointer to the underlying data buffer.\n*\n* @name buffer\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {ArrayBuffer}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var buf = arr.buffer;\n* // returns \n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'buffer', function get() {\n\treturn this._buffer.buffer;\n});\n\n/**\n* Size (in bytes) of the array.\n*\n* @name byteLength\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteLength = arr.byteLength;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteLength', function get() {\n\treturn this._buffer.byteLength;\n});\n\n/**\n* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n*\n* @name byteOffset\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var byteOffset = arr.byteOffset;\n* // returns 0\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'byteOffset', function get() {\n\treturn this._buffer.byteOffset;\n});\n\n/**\n* Size (in bytes) of each array element.\n*\n* @name BYTES_PER_ELEMENT\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {PositiveInteger}\n* @default 1\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var nbytes = arr.BYTES_PER_ELEMENT;\n* // returns 1\n*/\nsetReadOnly( BooleanArray.prototype, 'BYTES_PER_ELEMENT', BooleanArray.BYTES_PER_ELEMENT );\n\n/**\n* Copies a sequence of elements within the array to the position starting at `target`.\n*\n* @name copyWithin\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} target - index at which to start copying elements\n* @param {integer} start - source index at which to copy elements from\n* @param {integer} [end] - source index at which to stop copying elements from\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 4 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n* arr.set( true, 3 );\n*\n* // Copy the first two elements to the last two elements:\n* arr.copyWithin( 2, 0, 2 );\n*\n* var v = arr.get( 2 );\n* // returns true\n*\n* v = arr.get( 3 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'copyWithin', function copyWithin( target, start ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\t// FIXME: prefer a functional `copyWithin` implementation which addresses lack of universal browser support (e.g., IE11 and Safari) or ensure that typed arrays are polyfilled\n\tif ( arguments.length === 2 ) {\n\t\tthis._buffer.copyWithin( target, start );\n\t} else {\n\t\tthis._buffer.copyWithin( target, start, arguments[2] );\n\t}\n\treturn this;\n});\n\n/**\n* Returns an iterator for iterating over array key-value pairs.\n*\n* @name entries\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var it = arr.entries();\n*\n* var v = it.next().value;\n* // returns [ 0, true ]\n*\n* v = it.next().value;\n* // returns [ 1, false ]\n*\n* v = it.next().value;\n* // returns [ 2, true ]\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'entries', function entries() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar buf;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': [ i, Boolean( buf[ i ] ) ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.entries();\n\t}\n});\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @name every\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n*\n* var bool = arr.every( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'every', function every( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( !predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n});\n\n/**\n* Returns a modified typed array filled with a fill value.\n*\n* @name fill\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} value - fill value\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end] - ending index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {BooleanArray} modified array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.fill( true, 1 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'fill', function fill( value, start, end ) {\n\tvar buf;\n\tvar len;\n\tvar val;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', value ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( start < 0 ) {\n\t\t\tstart += len;\n\t\t\tif ( start < 0 ) {\n\t\t\t\tstart = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t} else {\n\t\t\tend = len;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = len;\n\t}\n\tif ( value ) {\n\t\tval = 1;\n\t} else {\n\t\tval = 0;\n\t}\n\tfor ( i = start; i < end; i++ ) {\n\t\tbuf[ i ] = val;\n\t}\n\treturn this;\n});\n\n/**\n* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n*\n* @name filter\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} boolean array\n*\n* @example\n* function predicate( v ) {\n* return ( v === true );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.filter( predicate );\n* // returns \n*\n* var len = out.length;\n* // returns 2\n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'filter', function filter( predicate, thisArg ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\tvar v;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn new this.constructor( out );\n});\n\n/**\n* Returns the first element in an array for which a predicate function returns a truthy value.\n*\n* @name find\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.find( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'find', function find( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the first element in an array for which a predicate function returns a truthy value.\n*\n* @name findIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findIndex( predicate );\n* // returns 0\n*/\nsetReadOnly( BooleanArray.prototype, 'findIndex', function findIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLast\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {(boolean|void)} array element or undefined\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLast( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'findLast', function findLast( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn v;\n\t\t}\n\t}\n});\n\n/**\n* Returns the index of the last element in an array for which a predicate function returns a truthy value.\n*\n* @name findLastIndex\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {integer} index or -1\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var v = arr.findLastIndex( predicate );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'findLastIndex', function findLastIndex( predicate, thisArg ) {\n\tvar buf;\n\tvar v;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = this._length-1; i >= 0; i-- ) {\n\t\tv = Boolean( buf[ i ] );\n\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Invokes a function once for each array element.\n*\n* @name forEach\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - function to invoke\n* @param {*} [thisArg] - function invocation context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n*\n* @example\n* function log( v, i ) {\n* console.log( '%s: %s', i, v.toString() );\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.forEach( log );\n*/\nsetReadOnly( BooleanArray.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tfcn.call( thisArg, Boolean( buf[ i ] ), i, this );\n\t}\n});\n\n/**\n* Returns an array element.\n*\n* @name get\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {NonNegativeInteger} idx - element index\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {(boolean|void)} array element\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 100 );\n* // returns undefined\n*/\nsetReadOnly( BooleanArray.prototype, 'get', function get( idx ) {\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isNonNegativeInteger( idx ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t}\n\tif ( idx >= this._length ) {\n\t\treturn;\n\t}\n\treturn Boolean( this._buffer[ idx ] );\n});\n\n/**\n* Returns a boolean indicating whether an array includes a provided value.\n*\n* @name includes\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - search element\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {boolean} boolean indicating whether an array includes a value\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var bool = arr.includes( true );\n* // returns true\n*\n* bool = arr.includes( false, 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Returns the first index at which a given element can be found.\n*\n* @name indexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex=0] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( true, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.indexOf( true );\n* // returns 0\n*\n* idx = arr.indexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.indexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfromIndex = 0;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Returns a new string by concatenating all array elements.\n*\n* @name join\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {string} [separator=','] - element separator\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.join();\n* // returns 'true,false,true'\n*\n* str = arr.join( '|' );\n* // returns 'true|false|true'\n*/\nsetReadOnly( BooleanArray.prototype, 'join', function join( separator ) {\n\tvar buf;\n\tvar out;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length > 0 ) {\n\t\tif ( !isString( separator ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t}\n\t} else {\n\t\tseparator = ',';\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( separator );\n});\n\n/**\n* Returns an iterator for iterating over each index key in a typed array.\n*\n* @name keys\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.keys();\n*\n* var v = iter.next().value;\n* // returns 0\n*\n* v = iter.next().value;\n* // returns 1\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'keys', function keys() {\n\tvar self;\n\tvar iter;\n\tvar len;\n\tvar FLG;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': i,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.keys();\n\t}\n});\n\n/**\n* Returns the last index at which a given element can be found.\n*\n* @name lastIndexOf\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {boolean} searchElement - element to find\n* @param {integer} [fromIndex] - starting index (inclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a boolean value\n* @throws {TypeError} second argument must be an integer\n* @returns {integer} index or -1\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( true, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var idx = arr.lastIndexOf( true );\n* // returns 4\n*\n* idx = arr.lastIndexOf( false, 2 );\n* // returns -1\n*\n* idx = arr.lastIndexOf( false, -3 );\n* // returns -1\n*/\nsetReadOnly( BooleanArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isBoolean( searchElement ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a boolean. Value: `%s`.', searchElement ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t}\n\t\tif ( fromIndex >= this._length ) {\n\t\t\tfromIndex = this._length - 1;\n\t\t} else if ( fromIndex < 0 ) {\n\t\t\tfromIndex += this._length;\n\t\t}\n\t} else {\n\t\tfromIndex = this._length - 1;\n\t}\n\tbuf = this._buffer;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( searchElement === Boolean( buf[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n});\n\n/**\n* Number of array elements.\n*\n* @name length\n* @memberof BooleanArray.prototype\n* @readonly\n* @type {NonNegativeInteger}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var len = arr.length;\n* // returns 10\n*/\nsetReadOnlyAccessor( BooleanArray.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Returns a new array with each element being the result of a provided callback function.\n*\n* @name map\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} new boolean array\n*\n* @example\n* function invert( v ) {\n* return !v;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.map( invert );\n* // returns \n*\n* var z = out.get( 0 );\n* // returns false\n*\n* z = out.get( 1 );\n* // returns true\n*\n* z = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'map', function map( fcn, thisArg ) {\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( fcn ) ) {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a function. Value: `%s`.', fcn );\n\t}\n\tbuf = this._buffer;\n\tout = new this.constructor( this._length );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\toutbuf[ i ] = Boolean( fcn.call( thisArg, Boolean( buf[ i ] ), i, this ) );\n\t}\n\treturn out;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduce\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduce( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = 0;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ 0 ] );\n\t\ti = 1;\n\t}\n\tfor ( ; i < len; i++ ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n*\n* @name reduceRight\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} reducer - callback function\n* @param {*} [initialValue] - initial value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {Error} if not provided an initial value, the array must have at least one element\n* @returns {*} accumulated result\n*\n* @example\n* function reducer( acc, v ) {\n* if ( v ) {\n* return acc + 1;\n* }\n* return acc;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.reduceRight( reducer, 0 );\n* // returns 2\n*/\nsetReadOnly( BooleanArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\tvar buf;\n\tvar len;\n\tvar acc;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( reducer ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length > 1 ) {\n\t\tacc = initialValue;\n\t\ti = len - 1;\n\t} else {\n\t\tif ( len === 0 ) {\n\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t}\n\t\tacc = Boolean( buf[ len-1 ] );\n\t\ti = len - 2;\n\t}\n\tfor ( ; i >= 0; i-- ) {\n\t\tacc = reducer( acc, Boolean( buf[ i ] ), i, this );\n\t}\n\treturn acc;\n});\n\n/**\n* Reverses an array in-place.\n*\n* @name reverse\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.reverse();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'reverse', function reverse() {\n\tvar buf;\n\tvar tmp;\n\tvar len;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tN = floor( len / 2 );\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = len - i - 1;\n\t\ttmp = buf[ i ];\n\t\tbuf[ i ] = buf[ j ];\n\t\tbuf[ j ] = tmp;\n\t}\n\treturn this;\n});\n\n/**\n* Sets an array element.\n*\n* ## Notes\n*\n* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n*\n* In the other overlapping scenario,\n*\n* ```text\n* buf: ---------------------\n* src: ---------------------\n* ```\n*\n* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n*\n* @name set\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(Collection|BooleanArray|*)} value - value(s)\n* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} index argument must be a nonnegative integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n* @returns {void}\n*\n* @example\n* var arr = new BooleanArray( 10 );\n*\n* var v = arr.get( 0 );\n* // returns false\n*\n* arr.set( [ true, false ], 0 );\n*\n* v = arr.get( 0 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'set', function set( value ) {\n\tvar sbuf;\n\tvar idx;\n\tvar buf;\n\tvar tmp;\n\tvar N;\n\tvar i;\n\tvar j;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length > 1 ) {\n\t\tidx = arguments[ 1 ];\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t} else {\n\t\tidx = 0;\n\t}\n\tif ( isCollection( value ) ) {\n\t\tN = value.length;\n\t\tif ( idx+N > this._length ) {\n\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t}\n\t\tif ( isBooleanArray( value ) ) {\n\t\t\tsbuf = value._buffer; // eslint-disable-line no-underscore-dangle\n\t\t} else {\n\t\t\tsbuf = value;\n\t\t}\n\t\t// Check for overlapping memory...\n\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\tif (\n\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t(\n\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t)\n\t\t) {\n\t\t\t// We need to copy source values...\n\t\t\ttmp = new Uint8Array( sbuf.length );\n\t\t\tfor ( i = 0; i < sbuf.length; i++ ) {\n\t\t\t\ttmp[ i ] = sbuf[ i ]; // TODO: handle accessor arrays\n\t\t\t}\n\t\t\tsbuf = tmp;\n\t\t}\n\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\tbuf[ idx ] = ( sbuf[ i ] ) ? 1 : 0;\n\t\t}\n\t\treturn;\n\t}\n\tif ( idx >= this._length ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t}\n\tbuf[ idx ] = ( value ) ? 1 : 0;\n});\n\n/**\n* Copies a portion of a typed array to a new typed array.\n*\n* @name slice\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be integer\n* @throws {TypeError} second argument must be integer\n* @returns {BooleanArray} boolean array\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var out = arr.slice();\n* // returns \n*\n* var len = out.length;\n* // returns 5\n*\n* var bool = out.get( 0 );\n* // returns true\n*\n* bool = out.get( len-1 );\n* // returns true\n*\n* out = arr.slice( 1, -2 );\n* // returns \n*\n* len = out.length;\n* // returns 2\n*\n* bool = out.get( 0 );\n* // returns false\n*\n* bool = out.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'slice', function slice( begin, end ) {\n\tvar outlen;\n\tvar outbuf;\n\tvar out;\n\tvar buf;\n\tvar len;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin < end ) {\n\t\toutlen = end - begin;\n\t} else {\n\t\toutlen = 0;\n\t}\n\tout = new this.constructor( outlen );\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < outlen; i++ ) {\n\t\toutbuf[ i ] = buf[ i+begin ];\n\t}\n\treturn out;\n});\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @name some\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function execution context\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function predicate( v ) {\n* return v === true;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( false, 0 );\n* arr.set( true, 1 );\n* arr.set( false, 2 );\n*\n* var bool = arr.some( predicate );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'some', function some( predicate, thisArg ) {\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isFunction( predicate ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t}\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( predicate.call( thisArg, Boolean( buf[ i ] ), i, this ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n});\n\n/**\n* Sorts an array in-place.\n*\n* @name sort\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* arr.sort( compare );\n*\n* var v = arr.get( 0 );\n* // returns true\n*\n* v = arr.get( 1 );\n* // returns true\n*\n* v = arr.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'sort', function sort( compareFcn ) {\n\tvar buf;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tif ( arguments.length === 0 ) {\n\t\tbuf.sort();\n\t\treturn this;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\tbuf.sort( compare );\n\treturn this;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Creates a new typed array view over the same underlying `ArrayBuffer` and with the same underlying data type as the host array.\n*\n* @name subarray\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} [begin] - start index (inclusive)\n* @param {integer} [end] - end index (exclusive)\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {TypeError} second argument must be an integer\n* @returns {BooleanArray} subarray\n*\n* @example\n* var arr = new BooleanArray( 5 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n* arr.set( false, 3 );\n* arr.set( true, 4 );\n*\n* var subarr = arr.subarray();\n* // returns \n*\n* var len = subarr.length;\n* // returns 5\n*\n* var bool = subarr.get( 0 );\n* // returns true\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*\n* subarr = arr.subarray( 1, -2 );\n* // returns \n*\n* len = subarr.length;\n* // returns 2\n*\n* bool = subarr.get( 0 );\n* // returns false\n*\n* bool = subarr.get( len-1 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'subarray', function subarray( begin, end ) {\n\tvar offset;\n\tvar buf;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tbuf = this._buffer;\n\tlen = this._length;\n\tif ( arguments.length === 0 ) {\n\t\tbegin = 0;\n\t\tend = len;\n\t} else {\n\t\tif ( !isInteger( begin ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', begin ) );\n\t\t}\n\t\tif ( begin < 0 ) {\n\t\t\tbegin += len;\n\t\t\tif ( begin < 0 ) {\n\t\t\t\tbegin = 0;\n\t\t\t}\n\t\t}\n\t\tif ( arguments.length === 1 ) {\n\t\t\tend = len;\n\t\t} else {\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t\tif ( end < 0 ) {\n\t\t\t\tend += len;\n\t\t\t\tif ( end < 0 ) {\n\t\t\t\t\tend = 0;\n\t\t\t\t}\n\t\t\t} else if ( end > len ) {\n\t\t\t\tend = len;\n\t\t\t}\n\t\t}\n\t}\n\tif ( begin >= len ) {\n\t\tlen = 0;\n\t\toffset = buf.byteLength;\n\t} else if ( begin >= end ) {\n\t\tlen = 0;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t} else {\n\t\tlen = end - begin;\n\t\toffset = buf.byteOffset + ( begin*BYTES_PER_ELEMENT );\n\t}\n\treturn new this.constructor( buf.buffer, offset, ( len < 0 ) ? 0 : len );\n});\n\n/**\n* Serializes an array as a locale-specific string.\n*\n* @name toLocaleString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {(string|Array)} [locales] - locale identifier(s)\n* @param {Object} [options] - configuration options\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a string or an array of strings\n* @throws {TypeError} options argument must be an object\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toLocaleString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toLocaleString', function toLocaleString( locales, options ) {\n\tvar opts;\n\tvar loc;\n\tvar out;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( arguments.length === 0 ) {\n\t\tloc = [];\n\t} else if ( isString( locales ) || isStringArray( locales ) ) {\n\t\tloc = locales;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string or an array of strings. Value: `%s`.', locales ) );\n\t}\n\tif ( arguments.length < 2 ) {\n\t\topts = {};\n\t} else if ( isObject( options ) ) {\n\t\topts = options;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tbuf = this._buffer;\n\tout = [];\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( Boolean( buf[ i ] ).toLocaleString( loc, opts ) );\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns a new typed array containing the elements in reversed order.\n*\n* @name toReversed\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {BooleanArray} reversed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( false, 2 );\n*\n* var out = arr.toReversed();\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*\n* v = out.get( 1 );\n* // returns false\n*\n* v = out.get( 2 );\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'toReversed', function toReversed() {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ len - i - 1 ];\n\t}\n\treturn out;\n});\n\n/**\n* Returns a new typed array containing the elements in sorted order.\n*\n* @name toSorted\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {Function} [compareFcn] - comparison function\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be a function\n* @returns {BooleanArray} sorted array\n*\n* @example\n* function compare( a, b ) {\n* if ( a === false ) {\n* if ( b === false ) {\n* return 0;\n* }\n* return 1;\n* }\n* if ( b === true ) {\n* return 0;\n* }\n* return -1;\n* }\n*\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.sort( compare );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns true\n*\n* v = out.get( 1 );\n* // returns true\n*\n* v = out.get( 2 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'toSorted', function toSorted( compareFcn ) {\n\tvar outbuf;\n\tvar out;\n\tvar len;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tlen = this._length;\n\tout = new this.constructor( len );\n\tbuf = this._buffer;\n\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tfor ( i = 0; i < len; i++ ) {\n\t\toutbuf[ i ] = buf[ i ];\n\t}\n\tif ( arguments.length === 0 ) {\n\t\toutbuf.sort();\n\t\treturn out;\n\t}\n\tif ( !isFunction( compareFcn ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', compareFcn ) );\n\t}\n\toutbuf.sort( compare );\n\treturn out;\n\n\t/**\n\t* Comparison function for sorting.\n\t*\n\t* @private\n\t* @param {boolean} a - first boolean value for comparison\n\t* @param {boolean} b - second boolean value for comparison\n\t* @returns {number} comparison result\n\t*/\n\tfunction compare( a, b ) {\n\t\treturn compareFcn( Boolean( a ), Boolean( b ) );\n\t}\n});\n\n/**\n* Serializes an array as a string.\n*\n* @name toString\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {string} string representation\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var str = arr.toString();\n* // returns 'true,false,true'\n*/\nsetReadOnly( BooleanArray.prototype, 'toString', function toString() {\n\tvar out;\n\tvar buf;\n\tvar i;\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tout = [];\n\tbuf = this._buffer;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tif ( buf[i] ) {\n\t\t\tout.push( 'true' );\n\t\t} else {\n\t\t\tout.push( 'false' );\n\t\t}\n\t}\n\treturn out.join( ',' );\n});\n\n/**\n* Returns an iterator for iterating over each value in a typed array.\n*\n* @name values\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @throws {TypeError} `this` must be a boolean array\n* @returns {Iterator} iterator\n*\n* @example\n* var arr = new BooleanArray( 2 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n*\n* var iter = arr.values();\n*\n* var v = iter.next().value;\n* // returns true\n*\n* v = iter.next().value;\n* // returns false\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nsetReadOnly( BooleanArray.prototype, 'values', function values() {\n\tvar iter;\n\tvar self;\n\tvar len;\n\tvar FLG;\n\tvar buf;\n\tvar i;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tself = this;\n\tbuf = this._buffer;\n\tlen = this._length;\n\n\t// Initialize an iteration index:\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\n\tif ( ITERATOR_SYMBOL ) {\n\t\tsetReadOnly( iter, ITERATOR_SYMBOL, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= len ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': Boolean( buf[ i ] ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.values();\n\t}\n});\n\n/**\n* Returns a new typed array with the element at a provided index replaced with a provided value.\n*\n* @name with\n* @memberof BooleanArray.prototype\n* @type {Function}\n* @param {integer} index - element index\n* @param {boolean} value - new value\n* @throws {TypeError} `this` must be a boolean array\n* @throws {TypeError} first argument must be an integer\n* @throws {RangeError} index argument is out-of-bounds\n* @throws {TypeError} second argument must be a boolean\n* @returns {BooleanArray} new typed array\n*\n* @example\n* var arr = new BooleanArray( 3 );\n*\n* arr.set( true, 0 );\n* arr.set( false, 1 );\n* arr.set( true, 2 );\n*\n* var out = arr.with( 0, false );\n* // returns \n*\n* var v = out.get( 0 );\n* // returns false\n*/\nsetReadOnly( BooleanArray.prototype, 'with', function copyWith( index, value ) {\n\tvar buf;\n\tvar out;\n\tvar len;\n\n\tif ( !isBooleanArray( this ) ) {\n\t\tthrow new TypeError( 'invalid invocation. `this` is not a boolean array.' );\n\t}\n\tif ( !isInteger( index ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t}\n\tlen = this._length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t}\n\tif ( index < 0 || index >= len ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t}\n\tif ( !isBoolean( value ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a boolean. Value: `%s`.', value ) );\n\t}\n\tout = new this.constructor( this._buffer );\n\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\tif ( value ) {\n\t\tbuf[ index ] = 1;\n\t} else {\n\t\tbuf[ index ] = 0;\n\t}\n\treturn out;\n});\n\n\n// EXPORTS //\n\nexport default BooleanArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Fills an output array with \"boolean\" values.\n*\n* @private\n* @param {Uint8Array} buf - output array\n* @param {Array} arr - input array\n* @returns {Uint8Array} output array\n*/\nfunction fromArray( buf, arr ) {\n\tvar len;\n\tvar i;\n\n\tlen = arr.length;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tbuf[ i ] = Boolean( arr[ i ] );\n\t}\n\treturn buf;\n}\n\n\n// EXPORTS //\n\nexport default fromArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Boolean from '@stdlib/boolean/ctor';\n\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( Boolean( clbk.call( thisArg, v.value, i ) ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Uint32Array from './../../uint32';\nimport Int32Array from './../../int32';\nimport Uint16Array from './../../uint16';\nimport Int16Array from './../../int16';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Int8Array from './../../int8';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\n// Note: order should match `dtypes` order\nvar CTORS = [\n\tFloat64Array,\n\tFloat32Array,\n\tInt32Array,\n\tUint32Array,\n\tInt16Array,\n\tUint16Array,\n\tInt8Array,\n\tUint8Array,\n\tUint8ClampedArray,\n\tComplex64Array,\n\tComplex128Array,\n\tBooleanArray\n];\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Note: order should match `ctors` order\nvar DTYPES = [\n\t'float64',\n\t'float32',\n\t'int32',\n\t'uint32',\n\t'int16',\n\t'uint16',\n\t'int8',\n\t'uint8',\n\t'uint8c',\n\t'complex64',\n\t'complex128',\n\t'bool'\n];\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isBuffer from '@stdlib/assert/is-buffer';\nimport isArray from '@stdlib/assert/is-array';\nimport constructorName from '@stdlib/utils/constructor-name';\nimport ctor2dtype from './ctor2dtype.js';\nimport CTORS from './ctors.js';\nimport DTYPES from './dtypes.js';\n\n\n// VARIABLES //\n\nvar NTYPES = DTYPES.length;\n\n\n// MAIN //\n\n/**\n* Returns the data type of an array.\n*\n* @param {*} value - input value\n* @returns {(string|null)} data type\n*\n* @example\n* var dt = dtype( [ 1, 2, 3 ] );\n* // returns 'generic'\n*\n* var dt = dtype( 'beep' );\n* // returns null\n*/\nfunction dtype( value ) {\n\tvar i;\n\tif ( isArray( value ) ) {\n\t\treturn 'generic';\n\t}\n\tif ( isBuffer( value ) ) {\n\t\treturn null;\n\t}\n\tfor ( i = 0; i < NTYPES; i++ ) {\n\t\tif ( value instanceof CTORS[ i ] ) {\n\t\t\treturn DTYPES[ i ];\n\t\t}\n\t}\n\t// If the above failed, fall back to a more robust (and significantly slower) means for resolving underlying data types:\n\treturn ctor2dtype[ constructorName( value ) ] || null;\n}\n\n\n// EXPORTS //\n\nexport default dtype;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport getter from './../../../base/getter';\nimport setter from './../../../base/setter';\nimport accessorGetter from './../../../base/accessor-getter';\nimport accessorSetter from './../../../base/accessor-setter';\nimport dtype from './../../../dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies values from `x` into `y`.\n*\n* @private\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Object} x - input array object\n* @param {Collection} x.data - input array data\n* @param {Array} x.accessors - array element accessors\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Object} y - output array object\n* @param {Collection} y.data - output array data\n* @param {Array} y.accessors - array element accessors\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @returns {Object} output array object\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n*\n* function setter( data, idx, value ) {\n* data.set( value, idx );\n* }\n*\n* function getter( data, idx ) {\n* return data.get( idx );\n* }\n*\n* var x = {\n* 'data': new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ),\n* 'accessors': [ getter, setter ]\n* };\n*\n* var y = {\n* 'data': new Complex64Array( [ 5.0, 6.0, 7.0, 8.0 ] ),\n* 'accessors': [ getter, setter ]\n* };\n*\n* gcopy( x.data.length, x, 1, 0, y, 1, 0 );\n*\n* var view = reinterpret64( y.data, 0 );\n* // view => [ 1.0, 2.0, 3.0, 4.0 ]\n*/\nfunction gcopy( N, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar xbuf;\n\tvar ybuf;\n\tvar set;\n\tvar get;\n\tvar ix;\n\tvar iy;\n\tvar i;\n\n\t// Cache references to array data:\n\txbuf = x.data;\n\tybuf = y.data;\n\n\t// Cache a reference to the element accessors:\n\tget = x.accessors[ 0 ];\n\tset = y.accessors[ 1 ];\n\n\tix = offsetX;\n\tiy = offsetY;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tset( ybuf, iy, get( xbuf, ix ) );\n\t\tix += strideX;\n\t\tiy += strideY;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default gcopy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from '@stdlib/array/base/arraylike2object';\nimport accessors from './accessors.js';\n\n\n// VARIABLES //\n\nvar M = 8;\n\n\n// MAIN //\n\n/**\n* Copies values from `x` into `y`.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {Collection} y - output array\n* @param {integer} strideY - `y` stride length\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n* var y = [ 6.0, 7.0, 8.0, 9.0, 10.0 ];\n*\n* gcopy( x.length, x, 1, y, 1 );\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\nfunction gcopy( N, x, strideX, y, strideY ) {\n\tvar ix;\n\tvar iy;\n\tvar ox;\n\tvar oy;\n\tvar m;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tox = arraylike2object( x );\n\toy = arraylike2object( y );\n\tif ( ox.accessorProtocol || oy.accessorProtocol ) {\n\t\tif ( strideX < 0 ) {\n\t\t\tix = (1-N) * strideX;\n\t\t} else {\n\t\t\tix = 0;\n\t\t}\n\t\tif ( strideY < 0 ) {\n\t\t\tiy = (1-N) * strideY;\n\t\t} else {\n\t\t\tiy = 0;\n\t\t}\n\t\taccessors( N, ox, strideX, ix, oy, strideY, iy );\n\t\treturn oy.data;\n\t}\n\t// Use unrolled loops if both strides are equal to `1`...\n\tif ( strideX === 1 && strideY === 1 ) {\n\t\tm = N % M;\n\n\t\t// If we have a remainder, run a clean-up loop...\n\t\tif ( m > 0 ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\ty[ i ] = x[ i ];\n\t\t\t}\n\t\t}\n\t\tif ( N < M ) {\n\t\t\treturn y;\n\t\t}\n\t\tfor ( i = m; i < N; i += M ) {\n\t\t\ty[ i ] = x[ i ];\n\t\t\ty[ i+1 ] = x[ i+1 ];\n\t\t\ty[ i+2 ] = x[ i+2 ];\n\t\t\ty[ i+3 ] = x[ i+3 ];\n\t\t\ty[ i+4 ] = x[ i+4 ];\n\t\t\ty[ i+5 ] = x[ i+5 ];\n\t\t\ty[ i+6 ] = x[ i+6 ];\n\t\t\ty[ i+7 ] = x[ i+7 ];\n\t\t}\n\t\treturn y;\n\t}\n\tif ( strideX < 0 ) {\n\t\tix = (1-N) * strideX;\n\t} else {\n\t\tix = 0;\n\t}\n\tif ( strideY < 0 ) {\n\t\tiy = (1-N) * strideY;\n\t} else {\n\t\tiy = 0;\n\t}\n\tfor ( i = 0; i < N; i++ ) {\n\t\ty[ iy ] = x[ ix ];\n\t\tix += strideX;\n\t\tiy += strideY;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default gcopy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from '@stdlib/array/base/arraylike2object';\nimport accessors from './accessors.js';\n\n\n// VARIABLES //\n\nvar M = 8;\n\n\n// MAIN //\n\n/**\n* Copies values from `x` into `y`.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Collection} y - output array\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n* var y = [ 6.0, 7.0, 8.0, 9.0, 10.0 ];\n*\n* gcopy( x.length, x, 1, 0, y, 1, 0 );\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\nfunction gcopy( N, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar ix;\n\tvar iy;\n\tvar ox;\n\tvar oy;\n\tvar m;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn y;\n\t}\n\tox = arraylike2object( x );\n\toy = arraylike2object( y );\n\tif ( ox.accessorProtocol || oy.accessorProtocol ) {\n\t\taccessors( N, ox, strideX, offsetX, oy, strideY, offsetY );\n\t\treturn oy.data;\n\t}\n\tix = offsetX;\n\tiy = offsetY;\n\n\t// Use unrolled loops if both strides are equal to `1`...\n\tif ( strideX === 1 && strideY === 1 ) {\n\t\tm = N % M;\n\n\t\t// If we have a remainder, run a clean-up loop...\n\t\tif ( m > 0 ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\ty[ iy ] = x[ ix ];\n\t\t\t\tix += strideX;\n\t\t\t\tiy += strideY;\n\t\t\t}\n\t\t}\n\t\tif ( N < M ) {\n\t\t\treturn y;\n\t\t}\n\t\tfor ( i = m; i < N; i += M ) {\n\t\t\ty[ iy ] = x[ ix ];\n\t\t\ty[ iy+1 ] = x[ ix+1 ];\n\t\t\ty[ iy+2 ] = x[ ix+2 ];\n\t\t\ty[ iy+3 ] = x[ ix+3 ];\n\t\t\ty[ iy+4 ] = x[ ix+4 ];\n\t\t\ty[ iy+5 ] = x[ ix+5 ];\n\t\t\ty[ iy+6 ] = x[ ix+6 ];\n\t\t\ty[ iy+7 ] = x[ ix+7 ];\n\t\t\tix += M;\n\t\t\tiy += M;\n\t\t}\n\t\treturn y;\n\t}\n\tfor ( i = 0; i < N; i++ ) {\n\t\ty[ iy ] = x[ ix ];\n\t\tix += strideX;\n\t\tiy += strideY;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default gcopy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeSlice from '@stdlib/slice/base/normalize-slice';\nimport sliceLength from '@stdlib/slice/base/length';\nimport zeros from './../../../base/zeros';\nimport dtype from './../../../dtype';\nimport { ndarray as gcopy } from '@stdlib/blas/base/gcopy';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a shallow copy of a portion of an array.\n*\n* @param {Collection} x - input array\n* @param {Slice} s - slice object\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {RangeError} slice exceeds array bounds\n* @returns {Collection} output array\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var x = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n*\n* var s = new Slice( null, null, -2 );\n* // returns \n*\n* var y = slice( x, s, false );\n* // returns [ 8, 6, 4, 2 ]\n*\n* var out = ( y === x );\n* // returns false\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n* import Slice from '@stdlib/slice/ctor';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] );\n*\n* var s = new Slice( null, null, -2 );\n* // returns \n*\n* var y = slice( x, s, false );\n* // returns [ 8, 6, 4, 2 ]\n*\n* var out = ( y === x );\n* // returns false\n*/\nfunction slice( x, s, strict ) {\n\tvar out;\n\tvar len;\n\tvar ns;\n\tvar dt;\n\tvar N;\n\n\tlen = x.length;\n\n\t// Normalize the slice object base on the array length:\n\tns = normalizeSlice( s, len, true );\n\n\t// Check whether the slice exceeds the array bounds...\n\tif ( ns.code ) {\n\t\tif ( strict ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Slice exceeds array bounds. Array length: %d.', len ) );\n\t\t}\n\t\t// Normalize again, this time allowing for out-of-bounds indices:\n\t\tns = normalizeSlice( s, len, false );\n\t}\n\t// Compute the slice length:\n\tN = sliceLength( ns );\n\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Allocate an output array:\n\tif ( dt === 'generic' || dt === null ) { // note: if we were provided an \"exotic\" array object, fallback to always returning a \"generic\" array\n\t\tout = zeros( N );\n\t} else {\n\t\tout = new x.constructor( N ); // note: this should accommodate array species which inherit from built-in/known constructors and we assume that all constructors support providing a length argument\n\t}\n\t// Copy elements to the output array:\n\tgcopy( N, x, ns.step, ns.start, out, 1, 0 );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* BLAS level 1 routine to copy values from `x` into `y`.\n*\n* @module @stdlib/blas/base/gcopy\n*\n* @example\n* import gcopy from '@stdlib/blas/base/gcopy';\n*\n* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n* var y = [ 6.0, 7.0, 8.0, 9.0, 10.0 ];\n*\n* gcopy( x.length, x, 1, y, 1 );\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*\n* @example\n* import gcopy from '@stdlib/blas/base/gcopy';\n*\n* var x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];\n* var y = [ 6.0, 7.0, 8.0, 9.0, 10.0 ];\n*\n* gcopy.ndarray( x.length, x, 1, 0, y, 1, 0 );\n* // y => [ 1.0, 2.0, 3.0, 4.0, 5.0 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'float64': Float64Array,\n\t'float32': Float32Array,\n\t'generic': Array, // TODO: replace with `stdlib` pkg\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array,\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray,\n\t'complex64': Complex64Array,\n\t'complex128': Complex128Array,\n\t'bool': BooleanArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns an array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport getType from './../../dtype';\nimport ctors from './../../ctors';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport gcopy from '@stdlib/blas/base/gcopy';\nimport copy from './../../base/copy';\nimport resolveGetter from './../../base/resolve-getter';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether a data type is a single-precision complex floating-point number data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} boolean indicating whether a provided data type is a single-precision complex floating-point number data type\n*\n* @example\n* var bool = isComplex64( 'float64' );\n* // returns false\n*\n* @example\n* var bool = isComplex64( 'complex64' );\n* // returns true\n*/\nfunction isComplex64( dtype ) {\n\treturn ( dtype === 'complex64' );\n}\n\n/**\n* Tests whether a data type is a double-precision complex floating-point number data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} boolean indicating whether a provided data type is a double-precision complex floating-point number data type\n*\n* @example\n* var bool = isComplex128( 'float64' );\n* // returns false\n*\n* @example\n* var bool = isComplex128( 'complex128' );\n* // returns true\n*/\nfunction isComplex128( dtype ) {\n\treturn ( dtype === 'complex128' );\n}\n\n/**\n* Tests whether a data type is a boolean data type.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {boolean} boolean indicating whether a provided data type is a boolean data type\n*\n* @example\n* var bool = isBool( 'bool' );\n* // returns true\n*\n* @example\n* var bool = isBool( 'complex128' );\n* // returns false\n*/\nfunction isBool( dtype ) {\n\treturn ( dtype === 'bool' );\n}\n\n\n// MAIN //\n\n/**\n* Converts an array to an array of a different data type.\n*\n* @param {Collection} x - array to convert\n* @param {string} dtype - output data type\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be a recognized array data type\n* @returns {(Array|TypedArray|ComplexArray)} output array\n*\n* @example\n* var arr = [ 1.0, 2.0, 3.0, 4.0 ];\n*\n* var out = convert( arr, 'float64' );\n* // returns [ 1.0, 2.0, 3.0, 4.0 ]\n*/\nfunction convert( x, dtype ) {\n\tvar isc64;\n\tvar ctor;\n\tvar xbuf;\n\tvar obuf;\n\tvar get;\n\tvar out;\n\tvar len;\n\tvar t;\n\tvar i;\n\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\t// If the output data type is \"generic\", our task is relatively straightforward...\n\tif ( dtype === 'generic' ) {\n\t\treturn copy( x );\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a recognized array data type. Value: `%s`.', dtype ) );\n\t}\n\t// Cache the input array length:\n\tlen = x.length;\n\n\t// Get the input array data type:\n\tt = getType( x );\n\tisc64 = isComplex64( t );\n\n\t// Create the output array:\n\tout = new ctor( len );\n\n\t// As the output data type is not \"generic\", we need to explicitly handle complex number input arrays...\n\tif ( isc64 || isComplex128( t ) ) {\n\t\tif ( isc64 ) {\n\t\t\txbuf = reinterpret64( x, 0 );\n\t\t} else {\n\t\t\txbuf = reinterpret128( x, 0 );\n\t\t}\n\t\t// Check whether the output data type is a complex number data type...\n\t\tif ( isComplex64( dtype ) ) { // cmplx => cmplx\n\t\t\tobuf = reinterpret64( out, 0 );\n\t\t\tgcopy( len*2, xbuf, 1, obuf, 1 );\n\t\t\treturn out;\n\t\t}\n\t\tif ( isComplex128( dtype ) ) { // cmplx => cmplx\n\t\t\tobuf = reinterpret128( out, 0 );\n\t\t\tgcopy( len*2, xbuf, 1, obuf, 1 );\n\t\t\treturn out;\n\t\t}\n\t\t// Check whether the output data type is a boolean data type...\n\t\tif ( isBool( dtype ) ) { // cmplx => bool\n\t\t\tobuf = reinterpretBoolean( out, 0 );\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t// A complex number is only falsy when both the real and imaginary components are zero...\n\t\t\t\tif ( xbuf[ 2*i ] || xbuf[ (2*i)+1 ] ) {\n\t\t\t\t\tobuf[ i ] = 1;\n\t\t\t\t} else {\n\t\t\t\t\tobuf[ i ] = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\t// We assume that the output data type is a real number data type, given that we're looking to convert a provided complex number array; in which case, we'll only extract the real components from the complex number input array...\n\t\tgcopy( len, xbuf, 2, out, 1 ); // cmplx => real\n\t\treturn out;\n\t}\n\t// Check whether the input array is a boolean array...\n\tif ( isBool( t ) ) {\n\t\txbuf = reinterpretBoolean( x, 0 );\n\n\t\t// Check whether the output data type is a boolean data type...\n\t\tif ( isBool( dtype ) ) { // bool => bool\n\t\t\tobuf = reinterpretBoolean( out, 0 );\n\t\t\tgcopy( len, xbuf, 1, obuf, 1 );\n\t\t\treturn out;\n\t\t}\n\t\t// Check whether the output data type is a complex number data type...\n\t\tif ( isComplex64( dtype ) ) { // bool => cmplx\n\t\t\tobuf = reinterpret64( out, 0 );\n\t\t\tgcopy( len, xbuf, 1, obuf, 2 );\n\t\t\treturn out;\n\t\t}\n\t\tif ( isComplex128( dtype ) ) { // bool => cmplx\n\t\t\tobuf = reinterpret128( out, 0 );\n\t\t\tgcopy( len, xbuf, 1, obuf, 2 );\n\t\t\treturn out;\n\t\t}\n\t\tgcopy( len, xbuf, 1, out, 1 ); // bool => real\n\t\treturn out;\n\t}\n\t// Check whether we need to explicitly handle complex number output arrays...\n\tisc64 = isComplex64( dtype );\n\tif ( isc64 || isComplex128( dtype ) ) {\n\t\tif ( isc64 ) {\n\t\t\tobuf = reinterpret64( out, 0 );\n\t\t} else {\n\t\t\tobuf = reinterpret128( out, 0 );\n\t\t}\n\t\t// We assume that the input data type is a real number data type, given that we're looking to convert to a complex number array; in which case, we'll only set the real components... (WARNING: we're assuming that the output array has been zero-initialized! The imaginary components should be zero!)\n\t\tgcopy( len, x, 1, obuf, 2 ); // real => cmplx\n\t\treturn out;\n\t}\n\t// Check whether the output data type is a boolean data type...\n\tif ( isBool( dtype ) ) {\n\t\tobuf = reinterpretBoolean( out, 0 );\n\t\tget = resolveGetter( x );\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( get( x, i ) ) {\n\t\t\t\tobuf[ i ] = 1;\n\t\t\t} else {\n\t\t\t\tobuf[ i ] = 0;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\t// At this point, we're no longer handling complex number or boolean arrays, so we'll just assume that we can perform a straightforward copy...\n\tgcopy( len, x, 1, out, 1 ); // note: `gcopy` is assumed to support arrays using accessors\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default convert;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isMostlySafeCast from './../../../base/assert/is-mostly-safe-data-type-cast';\nimport isRealDataType from './../../../base/assert/is-real-data-type';\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport normalizeSlice from '@stdlib/slice/base/normalize-slice';\nimport sliceLength from '@stdlib/slice/base/length';\nimport dtype from './../../../dtype';\nimport convert from './../../../convert';\nimport { ndarray as gcopy } from '@stdlib/blas/base/gcopy';\nimport format from '@stdlib/string/format';\n\n\n// MODULES //\n\n/**\n* Assigns element values from a broadcasted input array to corresponding elements in an output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {Slice} s - slice object\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {RangeError} slice exceeds array bounds\n* @throws {Error} input array must be broadcast compatible with an output array view\n* @throws {TypeError} input array cannot be safely cast to the output array data type\n* @returns {Collection} output array\n*\n* @example\n* import Slice from '@stdlib/slice/ctor';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 0, 0, 0, 0, 0, 0, 0, 0 ];\n*\n* var s = new Slice( null, null, -2 );\n* // returns \n*\n* var out = sliceAssign( x, y, s, false );\n* // returns [ 0, 4, 0, 3, 0, 2, 0, 1 ]\n*\n* var bool = ( out === y );\n* // returns true\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n* import Slice from '@stdlib/slice/ctor';\n*\n* var x = new Int32Array( [ 5 ] );\n* var y = new Int32Array( [ 0, 0, 0, 0, 0, 0, 0, 0 ] );\n*\n* var s = new Slice( null, null, -2 );\n* // returns \n*\n* var out = sliceAssign( x, y, s, false );\n* // returns [ 0, 5, 0, 5, 0, 5, 0, 5 ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction sliceAssign( x, y, s, strict ) {\n\tvar xlen;\n\tvar ylen;\n\tvar xdt;\n\tvar ydt;\n\tvar ns;\n\tvar xs;\n\tvar N;\n\n\txdt = dtype( x ) || 'generic';\n\tydt = dtype( y ) || 'generic';\n\n\txlen = x.length;\n\tylen = y.length;\n\n\t// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the output data type is floating-point...\n\tif ( !isMostlySafeCast( xdt, ydt ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Input array values cannot be safely cast to the output array data type. Data types: [%s, %s].', xdt, ydt ) );\n\t}\n\t// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...\n\tif ( isComplexDataType( ydt ) && isRealDataType( xdt ) ) {\n\t\tx = convert( x, ydt );\n\t}\n\t// Normalize the slice object base on the output array length:\n\tns = normalizeSlice( s, ylen, true );\n\n\t// Check whether the slice exceeds the array bounds...\n\tif ( ns.code ) {\n\t\tif ( strict ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Slice exceeds array bounds. Array length: %d.', ylen ) );\n\t\t}\n\t\t// Normalize again, this time allowing for out-of-bounds indices:\n\t\tns = normalizeSlice( s, ylen, false );\n\t}\n\t// Compute the slice length:\n\tN = sliceLength( ns );\n\n\t// Broadcast the input array:\n\tif ( xlen === 1 ) {\n\t\txs = 0;\n\t} else if ( xlen === N ) {\n\t\txs = 1;\n\t} else {\n\t\tthrow new Error( format( 'invalid argument. Input array and the output array slice are broadcast incompatible. Array length: %u. Desired length: %u.', xlen, N ) );\n\t}\n\t// Copy elements to the output array:\n\tgcopy( N, x, xs, 0, y, ns.step, ns.start );\n\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default sliceAssign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled \"generic\" array according to a provided callback function.\n*\n* @param {NonNegativeInteger} len - array length\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filledBy( 3, constantFunction( 'beep' ) );\n* // returns [ 'beep', 'beep', 'beep' ]\n*/\nfunction filledBy( len, clbk, thisArg ) {\n\tvar arr;\n\tvar i;\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tarr.push( clbk.call( thisArg, i ) );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a filled three-dimensional nested array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = filled3d( 0.0, [ 1, 1, 3 ] );\n* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ]\n*\n* @example\n* var out = filled3d( 'beep', [ 1, 3, 1 ] );\n* // returns [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ]\n*/\nfunction filled3d( value, shape ) {\n\tvar out;\n\tvar a1;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i2;\n\tvar i1;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tout = [];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = [];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta1.push( filled( value, S0 ) );\n\t\t}\n\t\tout.push( a1 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default filled3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a filled four-dimensional nested array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = filled4d( 0.0, [ 1, 1, 1, 3 ] );\n* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ]\n*\n* @example\n* var out = filled4d( 'beep', [ 1, 1, 3, 1 ] );\n* // returns [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ]\n*/\nfunction filled4d( value, shape ) {\n\tvar out;\n\tvar a1;\n\tvar a2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tout = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta1.push( filled( value, S0 ) );\n\t\t\t}\n\t\t\ta2.push( a1 );\n\t\t}\n\t\tout.push( a2 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default filled4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a filled five-dimensional nested array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = filled5d( 0.0, [ 1, 1, 1, 1, 3 ] );\n* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ]\n*\n* @example\n* var out = filled5d( 'beep', [ 1, 1, 1, 3, 1 ] );\n* // returns [ [ [ [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ] ] ] ]\n*/\nfunction filled5d( value, shape ) {\n\tvar out;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tout = [];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = [];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = [];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = [];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta1.push( filled( value, S0 ) );\n\t\t\t\t}\n\t\t\t\ta2.push( a1 );\n\t\t\t}\n\t\t\ta3.push( a2 );\n\t\t}\n\t\tout.push( a3 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default filled5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// FUNCTIONS //\n\n/**\n* Recursive fills an array.\n*\n* @private\n* @param {*} value - fill value\n* @param {NonNegativeInteger} ndims - number of dimensions\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} dim - dimension index\n* @param {Array} out - output array\n* @returns {Array} output array\n*/\nfunction recurse( value, ndims, shape, dim, out ) {\n\tvar S;\n\tvar d;\n\tvar i;\n\n\tS = shape[ dim ];\n\n\t// Check whether we're filling the last dimension:\n\td = dim + 1;\n\tif ( d === ndims ) {\n\t\treturn filled( value, S );\n\t}\n\n\t// Fill nested dimensions...\n\tfor ( i = 0; i < S; i++ ) {\n\t\tout.push( recurse( value, ndims, shape, d, [] ) );\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a filled n-dimensional nested array.\n*\n* @param {*} value - fill value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = fillednd( 0.0, [ 3 ] );\n* // returns [ 0.0, 0.0, 0.0 ]\n*\n* @example\n* var out = fillednd( 0.0, [ 1, 3 ] );\n* // returns [ [ 0.0, 0.0, 0.0 ] ]\n*\n* @example\n* var out = fillednd( 'beep', [ 3, 1 ] );\n* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ]\n*/\nfunction fillednd( value, shape ) {\n\treturn recurse( value, shape.length, shape, 0, [] );\n}\n\n\n// EXPORTS //\n\nexport default fillednd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Recursive fills an array.\n*\n* @private\n* @param {NonNegativeInteger} ndims - number of dimensions\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} dim - dimension index\n* @param {NonNegativeIntegerArray} indices - outer array element indices\n* @param {Array} out - output array\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} output array\n*/\nfunction recurse( ndims, shape, dim, indices, out, clbk, thisArg ) {\n\tvar idx;\n\tvar FLG;\n\tvar S;\n\tvar d;\n\tvar i;\n\n\t// Check whether we're filling the last dimension:\n\td = dim + 1;\n\tFLG = ( d === ndims );\n\n\tS = shape[ dim ];\n\tfor ( i = 0; i < S; i++ ) {\n\t\tidx = indices.slice(); // we explicitly copy in order to avoid potential mutation when calling `clbk`\n\t\tidx.push( i );\n\t\tif ( FLG ) {\n\t\t\tout.push( clbk.call( thisArg, idx ) );\n\t\t} else {\n\t\t\tout.push( recurse( ndims, shape, d, idx, [], clbk, thisArg ) );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filledndBy( [ 3, 1 ], constantFunction( 'beep' ) );\n* // returns [ [ 'beep' ], [ 'beep' ], [ 'beep' ] ]\n*/\nfunction filledndBy( shape, clbk, thisArg ) {\n\treturn recurse( shape.length, shape, 0, [], [], clbk, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default filledndBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the number of elements in an array.\n*\n* @param {(NonNegativeIntegerArray|EmptyArray)} shape - array shape\n* @returns {NonNegativeInteger} number of elements\n*\n* @example\n* var n = numel( [ 3, 3, 3 ] );\n* // returns 27\n*/\nfunction numel( shape ) {\n\tvar ndims;\n\tvar n;\n\tvar i;\n\n\tndims = shape.length;\n\tif ( ndims === 0 ) {\n\t\treturn 0;\n\t}\n\tn = 1;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tn *= shape[ i ];\n\t}\n\treturn n;\n}\n\n\n// EXPORTS //\n\nexport default numel;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests whether an input value is the string representing column-major order.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean result\n*\n* @example\n* var bool = isColumnMajorString( 'column-major' );\n* // returns true\n*\n* bool = isColumnMajorString( 'row-major' );\n* // returns false\n*\n* bool = isColumnMajorString( 'foo' );\n* // returns false\n*/\nfunction isColumnMajorString( v ) {\n\treturn ( v === 'column-major' );\n}\n\n\n// EXPORTS //\n\nexport default isColumnMajorString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from './../../../base/assert/is-column-major-string';\n\n\n// FUNCTIONS //\n\n/**\n* Generates a stride array from an array shape (row-major).\n*\n* @private\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} array strides\n*/\nfunction rowmajor( shape ) {\n\tvar ndims;\n\tvar out;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tout = [];\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tout.push( 0 );\n\t}\n\ts = 1;\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\tout[ i ] = s;\n\t\ts *= shape[ i ];\n\t}\n\treturn out;\n}\n\n/**\n* Generates a stride array from an array shape (column-major).\n*\n* @private\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} array strides\n*/\nfunction columnmajor( shape ) {\n\tvar out;\n\tvar s;\n\tvar i;\n\n\tout = [];\n\ts = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tout.push( s );\n\t\ts *= shape[ i ];\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates a stride array from an array shape.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {Array} array strides\n*\n* @example\n* var s = shape2strides( [ 3, 2 ], 'row-major' );\n* // returns [ 2, 1 ]\n*\n* s = shape2strides( [ 3, 2 ], 'column-major' );\n* // returns [ 1, 3 ]\n*/\nfunction shape2strides( shape, order ) {\n\tif ( isColumnMajor( order ) ) {\n\t\treturn columnmajor( shape );\n\t}\n\treturn rowmajor( shape );\n}\n\n\n// EXPORTS //\n\nexport default shape2strides;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from './../../../base/assert/is-column-major-string';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Converts a linear index in an array view to a linear index in an underlying data buffer.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - stride array\n* @param {NonNegativeInteger} offset - location of the first indexed value **based** on the stride array\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {integer} idx - linear index in an array view\n* @param {string} mode - specifies how to handle a linear index which exceeds array dimensions\n* @throws {RangeError} linear index must not exceed array dimensions\n* @returns {NonNegativeInteger} linear index in an underlying data buffer\n*\n* @example\n* var shape = [ 3, 3 ];\n* var strides = [ -3, 1 ];\n* var offset = 6;\n* var order = 'row-major';\n* var mode = 'throw';\n*\n* var ind = vind2bind( shape, strides, offset, order, 1, mode );\n* // returns 7\n*/\nfunction vind2bind( shape, strides, offset, order, idx, mode ) {\n\tvar ndims;\n\tvar len;\n\tvar ind;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\tlen = 1;\n\tfor ( i = 0; i < ndims; i++ ) {\n\t\tlen *= shape[ i ];\n\t}\n\tif ( mode === 'clamp' ) {\n\t\tif ( idx < 0 ) {\n\t\t\tidx = 0;\n\t\t} else if ( idx >= len ) {\n\t\t\tidx = len - 1;\n\t\t}\n\t} else if ( mode === 'wrap' ) {\n\t\tif ( idx < 0 ) {\n\t\t\tidx += len; // slight optimization to avoid modulo arithmetic when |idx| <= len\n\t\t\tif ( idx < 0 ) {\n\t\t\t\tidx %= len;\n\t\t\t\tif ( idx !== 0 ) {\n\t\t\t\t\tidx += len;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ( idx >= len ) {\n\t\t\tidx -= len; // slight optimization to avoid modulo arithmetic when len < idx <= 2*len\n\t\t\tif ( idx >= len ) {\n\t\t\t\tidx %= len;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif ( mode === 'normalize' && idx < 0 ) {\n\t\t\tidx += len;\n\t\t}\n\t\tif ( idx < 0 || idx >= len ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Linear index must not exceed array dimensions. Number of array elements: `%u`. Value: `%d`.', len, idx ) );\n\t\t}\n\t}\n\t// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...\n\tind = offset;\n\tif ( isColumnMajor( order ) ) {\n\t\tfor ( i = 0; i < ndims; i++ ) {\n\t\t\ts = idx % shape[ i ];\n\t\t\tidx -= s;\n\t\t\tidx /= shape[ i ];\n\t\t\tind += s * strides[ i ];\n\t\t}\n\t\treturn ind;\n\t}\n\t// Case: row-major\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\ts = idx % shape[ i ];\n\t\tidx -= s;\n\t\tidx /= shape[ i ];\n\t\tind += s * strides[ i ];\n\t}\n\treturn ind;\n}\n\n\n// EXPORTS //\n\nexport default vind2bind;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the index offset which specifies the location of the first indexed value in a strided array.\n*\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {integer} stride - index increment\n* @returns {NonNegativeInteger} offset - offset\n*\n* @example\n* var offset = stride2offset( 10, -10 );\n* // returns 90\n*/\nfunction stride2offset( N, stride ) {\n\tif ( stride > 0 ) {\n\t\treturn 0;\n\t}\n\treturn ( 1 - N ) * stride;\n}\n\n\n// EXPORTS //\n\nexport default stride2offset;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Generate a stride array from an array shape.\n*\n* @module @stdlib/ndarray/base/shape2strides\n*\n* @example\n* import shape2strides from '@stdlib/ndarray/base/shape2strides';\n*\n* var strides = shape2strides( [ 3, 2 ], 'row-major' );\n* // returns [ 2, 1 ]\n*\n* strides = shape2strides( [ 3, 2 ], 'column-major' );\n* // returns [ 1, 3 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isColumnMajor from './../../../base/assert/is-column-major-string';\n\n\n// FUNCTIONS //\n\n/**\n* Generates a stride array from an array shape (row-major).\n*\n* @private\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} array strides\n*/\nfunction rowmajor( shape, out ) {\n\tvar ndims;\n\tvar s;\n\tvar i;\n\n\tndims = shape.length;\n\ts = 1;\n\tfor ( i = ndims-1; i >= 0; i-- ) {\n\t\tout[ i ] = s;\n\t\ts *= shape[ i ];\n\t}\n\treturn out;\n}\n\n/**\n* Generates a stride array from an array shape (column-major).\n*\n* @private\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} array strides\n*/\nfunction columnmajor( shape, out ) {\n\tvar s;\n\tvar i;\n\n\ts = 1;\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tout[ i ] = s;\n\t\ts *= shape[ i ];\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Generates a stride array from an array shape.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {(Array|TypedArray|Object)} out - output object\n* @returns {(Array|TypedArray|Object)} array strides\n*\n* @example\n* var strides = [ 0, 0 ];\n*\n* var out = shape2strides( [ 3, 2 ], 'row-major', strides );\n* // returns [ 2, 1 ]\n*\n* var bool = ( out === strides );\n* // returns true\n*\n* out = shape2strides( [ 3, 2 ], 'column-major', strides );\n* // returns [ 1, 3 ]\n*/\nfunction shape2strides( shape, order, out ) {\n\tif ( isColumnMajor( order ) ) {\n\t\treturn columnmajor( shape, out );\n\t}\n\treturn rowmajor( shape, out );\n}\n\n\n// EXPORTS //\n\nexport default shape2strides;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math/base/special/floor';\nimport arraylike2object from '@stdlib/array/base/arraylike2object';\nimport accessors from './accessors.js';\n\n\n// VARIABLES //\n\nvar M = 3;\n\n\n// MAIN //\n\n/**\n* Reverses a strided array in-place.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {NumericArray} input array\n*\n* @example\n* var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];\n*\n* grev( 3, x, 1, x.length-3 );\n* // x => [ 1.0, -2.0, 3.0, -6.0, 5.0, -4.0 ]\n*/\nfunction grev( N, x, strideX, offsetX ) {\n\tvar tmp;\n\tvar ix;\n\tvar iy;\n\tvar o;\n\tvar m;\n\tvar n;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn x;\n\t}\n\to = arraylike2object( x );\n\tif ( o.accessorProtocol ) {\n\t\taccessors( N, o, strideX, offsetX );\n\t\treturn o.data;\n\t}\n\tn = floor( N/2 );\n\tix = offsetX;\n\n\t// Use loop unrolling if the stride is equal to `1`...\n\tif ( strideX === 1 ) {\n\t\tm = n % M;\n\t\tiy = ix + N - 1;\n\n\t\t// If we have a remainder, run a clean-up loop...\n\t\tif ( m > 0 ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\ttmp = x[ ix ];\n\t\t\t\tx[ ix ] = x[ iy ];\n\t\t\t\tx[ iy ] = tmp;\n\t\t\t\tix += strideX;\n\t\t\t\tiy -= strideX;\n\t\t\t}\n\t\t}\n\t\tif ( n < M ) {\n\t\t\treturn x;\n\t\t}\n\t\tfor ( i = m; i < n; i += M ) {\n\t\t\ttmp = x[ ix ];\n\t\t\tx[ ix ] = x[ iy ];\n\t\t\tx[ iy ] = tmp;\n\n\t\t\ttmp = x[ ix+1 ];\n\t\t\tx[ ix+1 ] = x[ iy-1 ];\n\t\t\tx[ iy-1 ] = tmp;\n\n\t\t\ttmp = x[ ix+2 ];\n\t\t\tx[ ix+2 ] = x[ iy-2 ];\n\t\t\tx[ iy-2 ] = tmp;\n\n\t\t\tix += M;\n\t\t\tiy -= M;\n\t\t}\n\t\treturn x;\n\t}\n\tiy = ix + ( ( N - 1 ) * strideX );\n\tfor ( i = 0; i < n; i++ ) {\n\t\ttmp = x[ ix ];\n\t\tx[ ix ] = x[ iy ];\n\t\tx[ iy ] = tmp;\n\t\tix += strideX;\n\t\tiy -= strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default grev;\n","\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math/base/special/floor';\n\n\n// MAIN //\n\n/**\n* Reverses a strided array in-place.\n*\n* @private\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Object} x - input array object\n* @param {Collection} x.data - input array data\n* @param {Array} x.accessors - array element accessors\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {Object} input array object\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n*\n* function setter( data, idx, value ) {\n* data.set( value, idx );\n* }\n*\n* function getter( data, idx ) {\n* return data.get( idx );\n* }\n*\n* var data = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );\n*\n* var x = {\n* 'data': data,\n* 'accessors': [ getter, setter ]\n* };\n*\n* grev( data.length, x, 1, 0 );\n*\n* var view = reinterpret64( x.data, 0 );\n* // view => [ -1.0, -3.0, 4.0, 0.0, 3.0, -5.0, -2.0, 1.0 ]\n*/\nfunction grev( N, x, strideX, offsetX ) {\n\tvar xbuf;\n\tvar set;\n\tvar get;\n\tvar tmp;\n\tvar ix;\n\tvar iy;\n\tvar n;\n\tvar i;\n\n\t// Cache reference to array data:\n\txbuf = x.data;\n\n\t// Cache a reference to the element accessors:\n\tget = x.accessors[ 0 ];\n\tset = x.accessors[ 1 ];\n\n\tn = floor( N/2 );\n\tix = offsetX;\n\tiy = ix + ( ( N - 1 ) * strideX );\n\tfor ( i = 0; i < n; i++ ) {\n\t\ttmp = get( xbuf, ix );\n\t\tset( xbuf, ix, get( xbuf, iy ) );\n\t\tset( xbuf, iy, tmp );\n\t\tix += strideX;\n\t\tiy -= strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default grev;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport stride2offset from '@stdlib/strided/base/stride2offset';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\n/**\n* Reverses a strided array in-place.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NumericArray} x - input array\n* @param {integer} strideX - stride length\n* @returns {NumericArray} input array\n*\n* @example\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* grev( x.length, x, 1 );\n* // x => [ -3.0, -1.0, 0.0, 4.0, -5.0, 3.0, 1.0, -2.0 ]\n*/\nfunction grev( N, x, strideX ) {\n\treturn ndarray( N, x, strideX, stride2offset( N, strideX ) );\n}\n\n\n// EXPORTS //\n\nexport default grev;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Reverse a strided array in-place.\n*\n* @module @stdlib/blas/ext/base/grev\n*\n* @example\n* import grev from '@stdlib/blas/ext/base/grev';\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* grev( x.length, x, 1 );\n* // x => [ -3.0, -1.0, 0.0, 4.0, -5.0, 3.0, 1.0, -2.0 ]\n*\n* @example\n* import grev from '@stdlib/blas/ext/base/grev';\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* grev( x.length, x, 1, 0 );\n* // x => [ -3.0, -1.0, 0.0, 4.0, -5.0, 3.0, 1.0, -2.0 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray/base/shape2strides';\nimport vind2bind from '@stdlib/ndarray/base/vind2bind';\nimport numel from '@stdlib/ndarray/base/numel';\nimport grev from '@stdlib/blas/ext/base/grev';\nimport zeros from './../../../base/zeros';\n\n\n// VARIABLES //\n\nvar MODE = 'throw';\n\n\n// FUNCTIONS //\n\n/**\n* Copies a specified number of array elements to a provided array.\n*\n* @private\n* @param {Array} x - input array\n* @param {NonNegativeInteger} N - number of elements to copy\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0 ];\n* copy( x, 3, out, 1, 0 );\n*\n* var o = out;\n* // returns [ 1, 2, 3 ]\n*/\nfunction copy( x, N, out, stride, offset ) {\n\tvar i;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout[ offset ] = x[ i ];\n\t\toffset += stride;\n\t}\n}\n\n/**\n* Recursively flattens an array in lexicographic order.\n*\n* @private\n* @param {Array} x - array to flatten\n* @param {NonNegativeInteger} ndims - number of dimensions in the input array\n* @param {NonNegativeIntegerArray} shape - shape of the input array\n* @param {NonNegativeInteger} dim - dimension index\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {NonNegativeInteger} offset for next output array element\n*/\nfunction recurseLexicographic( x, ndims, shape, dim, out, stride, offset ) {\n\tvar FLG;\n\tvar S;\n\tvar d;\n\tvar i;\n\n\t// Check whether we've reached the last dimension:\n\td = dim + 1;\n\tFLG = ( d === ndims );\n\n\tS = shape[ dim ];\n\tfor ( i = 0; i < S; i++ ) {\n\t\tif ( FLG ) {\n\t\t\tout[ offset ] = x[ i ];\n\t\t\toffset += stride;\n\t\t} else {\n\t\t\toffset = recurseLexicographic( x[ i ], ndims, shape, d, out, stride, offset ); // eslint-disable-line max-len\n\t\t}\n\t}\n\treturn offset;\n}\n\n/**\n* Flattens an array in colexicographic order.\n*\n* @private\n* @param {Array} x - array to flatten\n* @param {NonNegativeInteger} ndims - number of dimensions in the input array\n* @param {NonNegativeIntegerArray} shape - shape of the input array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n*/\nfunction flattenColexicographic( x, ndims, shape, out, stride, offset ) {\n\tvar len;\n\tvar tmp;\n\tvar ord;\n\tvar sh;\n\tvar sx;\n\tvar j;\n\tvar i;\n\n\t// Note that, in contrast to lexicographic iteration, we cannot readily define a straightforward recursive definition for colexicographic iteration. Accordingly, we have to perform a workaround in which we first flatten in lexicographic order and then perform an out-of-place transposition to return an array in colexicographic order.\n\n\t// Determine how many elements will be in the output array:\n\tlen = numel( shape );\n\n\t// For input arrays having an arbitrary number of dimensions, first flatten in lexicographic order:\n\ttmp = zeros( len );\n\trecurseLexicographic( x, ndims, shape, 0, tmp, 1, 0 );\n\n\t// Define the memory layout:\n\tord = 'row-major';\n\n\t// Generate a stride array for lexicographic order:\n\tsx = shape2strides( shape, ord );\n\n\t// Reverse the dimensions and strides (i.e., define the shape and strides of the transpose):\n\tsh = zeros( ndims );\n\tcopy( shape, ndims, sh, 1, 0 );\n\tgrev( ndims, sh, 1 );\n\tgrev( ndims, sx, 1 );\n\n\t// Iterate over each element based on the linear **view** index (note: this has negative performance implications due to lack of data locality)...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = vind2bind( sh, sx, 0, ord, i, MODE );\n\t\tout[ offset ] = tmp[ j ];\n\t\toffset += stride;\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Flattens an n-dimensional nested array and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten( x, shape, colexicographic, out, stride, offset ) {\n\tvar ndims = shape.length;\n\tif ( ndims === 0 ) { // 0-dimensional array\n\t\treturn out;\n\t}\n\tif ( ndims === 1 ) { // 1-dimensional array\n\t\t// For 1-dimensional arrays, we can perform a simple copy:\n\t\tcopy( x, shape[ 0 ], out, stride, offset );\n\t\treturn out;\n\t}\n\tif ( colexicographic ) {\n\t\tflattenColexicographic( x, ndims, shape, out, stride, offset );\n\t\treturn out;\n\t}\n\trecurseLexicographic( x, ndims, shape, 0, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport numel from '@stdlib/ndarray/base/numel';\nimport zeros from './../../../base/zeros';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Flattens an n-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @returns {Array} flattened array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten( x, shape, colexicographic ) {\n\tvar out = zeros( numel( shape ) );\n\treturn assign( x, shape, colexicographic, out, 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default flatten;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten an n-dimensional nested array.\n*\n* @module @stdlib/array/base/flatten\n*\n* @example\n* import flatten from '@stdlib/array/base/flatten';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import flatten from '@stdlib/array/base/flatten';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten( x, [ 2, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten from '@stdlib/array/base/flatten';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten.assign( x, [ 2, 2 ], true, out, 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MODULES //\n\nimport shape2strides from '@stdlib/ndarray/base/shape2strides';\nimport vind2bind from '@stdlib/ndarray/base/vind2bind';\nimport numel from '@stdlib/ndarray/base/numel';\nimport grev from '@stdlib/blas/ext/base/grev';\nimport zeros from './../../../base/zeros';\nimport copy from './../../../base/copy-indexed';\n\n\n// VARIABLES //\n\nvar MODE = 'throw';\n\n\n// FUNCTIONS //\n\n/**\n* Copies a specified number of array elements to a provided array according to a callback function.\n*\n* @private\n* @param {Array} x - input array\n* @param {NonNegativeInteger} N - number of elements to copy\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0 ];\n* copyBy( x, 3, out, 1, 0, scale );\n*\n* var o = out;\n* // returns [ 2, 4, 6 ]\n*/\nfunction copyBy( x, N, out, stride, offset, clbk, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout[ offset ] = clbk.call( thisArg, x[ i ], [ i ], x );\n\t\toffset += stride;\n\t}\n}\n\n/**\n* Recursively flattens an array in lexicographic order.\n*\n* @private\n* @param {Array} orig - original input array\n* @param {Array} x - array to flatten\n* @param {NonNegativeInteger} ndims - number of dimensions in the input array\n* @param {NonNegativeIntegerArray} shape - shape of the input array\n* @param {NonNegativeInteger} dim - dimension index\n* @param {NonNegativeIntegerArray} indices - outer array element indices\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {NonNegativeInteger} offset for next output array element\n*/\nfunction recurseLexicographic( orig, x, ndims, shape, dim, indices, out, stride, offset, clbk, thisArg ) { // eslint-disable-line max-params\n\tvar FLG;\n\tvar idx;\n\tvar S;\n\tvar d;\n\tvar i;\n\n\t// Check whether we've reached the last dimension:\n\td = dim + 1;\n\tFLG = ( d === ndims );\n\n\tS = shape[ dim ];\n\tfor ( i = 0; i < S; i++ ) {\n\t\tidx = indices.slice(); // we explicitly copy in order to avoid potential mutation when calling `clbk`\n\t\tidx.push( i );\n\t\tif ( FLG ) {\n\t\t\tout[ offset ] = clbk.call( thisArg, x[ i ], idx, orig );\n\t\t\toffset += stride;\n\t\t} else {\n\t\t\toffset = recurseLexicographic( orig, x[ i ], ndims, shape, d, idx, out, stride, offset, clbk, thisArg );\n\t\t}\n\t}\n\treturn offset;\n}\n\n/**\n* Flattens an array in colexicographic order.\n*\n* @private\n* @param {Array} x - array to flatten\n* @param {NonNegativeInteger} ndims - number of dimensions in the input array\n* @param {NonNegativeIntegerArray} shape - shape of the input array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n*/\nfunction flattenColexicographic( x, ndims, shape, out, stride, offset, clbk, thisArg ) {\n\tvar len;\n\tvar tmp;\n\tvar ord;\n\tvar sh;\n\tvar sx;\n\tvar j;\n\tvar i;\n\n\t// Note that, in contrast to lexicographic iteration, we cannot readily define a straightforward recursive definition for colexicographic iteration. Accordingly, we have to perform a workaround in which we first flatten in lexicographic order and then perform an out-of-place transposition to return an array in colexicographic order.\n\n\t// Determine how many elements will be in the output array:\n\tlen = numel( shape );\n\n\t// For input arrays having an arbitrary number of dimensions, first flatten in lexicographic order:\n\ttmp = zeros( len );\n\trecurseLexicographic( x, x, ndims, shape, 0, [], tmp, 1, 0, clbk, thisArg );\n\n\t// Define the memory layout:\n\tord = 'row-major';\n\n\t// Generate a stride array for lexicographic order:\n\tsx = shape2strides( shape, ord );\n\n\t// Reverse the dimensions and strides (i.e., define the shape and strides of the transpose):\n\tsh = copy( shape );\n\tgrev( ndims, sh, 1 );\n\tgrev( ndims, sx, 1 );\n\n\t// Iterate over each element based on the linear **view** index (note: this has negative performance implications due to lack of data locality)...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tj = vind2bind( sh, sx, 0, ord, i, MODE );\n\t\tout[ offset ] = tmp[ j ];\n\t\toffset += stride;\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Flattens an n-dimensional nested array according to a callback function and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flattenBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) {\n\tvar ndims = shape.length;\n\tif ( ndims === 0 ) { // 0-dimensional array\n\t\treturn out;\n\t}\n\tif ( ndims === 1 ) { // 1-dimensional array\n\t\t// For 1-dimensional arrays, we can perform simple iteration:\n\t\tcopyBy( x, shape[ 0 ], out, stride, offset, clbk, thisArg );\n\t\treturn out;\n\t}\n\tif ( colexicographic ) {\n\t\tflattenColexicographic( x, ndims, shape, out, stride, offset, clbk, thisArg );\n\t\treturn out;\n\t}\n\trecurseLexicographic( x, x, ndims, shape, 0, [], out, stride, offset, clbk, thisArg );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flattenBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport numel from '@stdlib/ndarray/base/numel';\nimport zeros from './../../../base/zeros';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Flattens an n-dimensional nested array according to a callback function.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} flattened array\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flattenBy( x, shape, colexicographic, clbk, thisArg ) {\n\tvar out = zeros( numel( shape ) );\n\treturn assign( x, shape, colexicographic, out, 1, 0, clbk, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default flattenBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a two-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @returns {Array} flattened array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten2d( x, shape, colexicographic ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar a0;\n\n\t// Extract loop variables:\n\tS0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tout.push( x[ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ta0 = x[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tout.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a two-dimensional nested array according to a callback function.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} flattened array\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten2dBy( x, shape, colexicographic, clbk, thisArg ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar a0;\n\n\t// Extract loop variables:\n\tS0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tout.push( clbk.call( thisArg, x[ i1 ][ i0 ], [ i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ta0 = x[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tout.push( clbk.call( thisArg, a0[ i0 ], [ i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a three-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @returns {Array} flattened array\n*\n* @example\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten3d( x, shape, colexicographic ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar a0;\n\tvar a1;\n\n\t// Extract loop variables:\n\tS0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tout.push( x[ i2 ][ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = x[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta0 = a1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tout.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a three-dimensional nested array according to a callback function.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} flattened array\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten3dBy( x, shape, colexicographic, clbk, thisArg ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar a0;\n\tvar a1;\n\n\t// Extract loop variables:\n\tS0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tout.push( clbk.call( thisArg, x[ i2 ][ i1 ][ i0 ], [ i2, i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = x[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta0 = a1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tout.push( clbk.call( thisArg, a0[ i0 ], [ i2, i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten3dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a four-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @returns {Array} flattened array\n*\n* @example\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten4d( x, shape, colexicographic ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\n\t// Extract loop variables:\n\tS0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tout.push( x[ i3 ][ i2 ][ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = x[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = a2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tout.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a four-dimensional nested array according to a callback function.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} flattened array\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten4dBy( x, shape, colexicographic, clbk, thisArg ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\n\t// Extract loop variables:\n\tS0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tout.push( clbk.call( thisArg, x[ i3 ][ i2 ][ i1 ][ i0 ], [ i3, i2, i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = x[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = a2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tout.push( clbk.call( thisArg, a0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten4dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a five-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @returns {Array} flattened array\n*\n* @example\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten5d( x, shape, colexicographic ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\n\t// Extract loop variables:\n\tS0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\t\t\t\t\t\tout.push( x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ] ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = x[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = a3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = a2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tout.push( a0[ i0 ] ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth, max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a five-dimensional nested array according to a callback function.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} flattened array\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten5dBy( x, shape, colexicographic, clbk, thisArg ) {\n\tvar out;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\n\t// Extract loop variables:\n\tS0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Initialize an output array:\n\tout = [];\n\n\t// Iterate over the array dimensions...\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\t\t\t\t\t\tout.push( clbk.call( thisArg, x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ], [ i4, i3, i2, i1, i0 ], x ) ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = x[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = a3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = a2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tout.push( clbk.call( thisArg, a0[ i0 ], [ i4, i3, i2, i1, i0 ], x ) ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten5dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the last dimension of a two-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject} x - nested input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ];\n*\n* var out = fliplr2d( x );\n* // returns [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ]\n*/\nfunction fliplr2d( x ) {\n\tvar out;\n\tvar x0;\n\tvar y0;\n\tvar i1;\n\tvar i0;\n\n\tout = [];\n\tfor ( i1 = 0; i1 < x.length; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = [];\n\t\tfor ( i0 = x0.length-1; i0 >= 0; i0-- ) {\n\t\t\ty0.push( x0[ i0 ] );\n\t\t}\n\t\tout.push( y0 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fliplr2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fliplr2d from './../../../base/fliplr2d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the last dimension of a three-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>} x - nested input array\n* @returns {Array>} output array\n*\n* @example\n* var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ];\n*\n* var out = fliplr3d( x );\n* // returns [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ]\n*/\nfunction fliplr3d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( fliplr2d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fliplr3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fliplr3d from './../../../base/fliplr3d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the last dimension of a four-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>>} x - nested input array\n* @returns {Array>>} output array\n*\n* @example\n* var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ];\n*\n* var out = fliplr4d( x );\n* // returns [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ]\n*/\nfunction fliplr4d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( fliplr3d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fliplr4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the first dimension of a two-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject} x - nested input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ];\n*\n* var out = flipud2d( x );\n* // returns [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ]\n*/\nfunction flipud2d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = x.length-1; i >= 0; i-- ) {\n\t\tout.push( x[ i ] );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flipud2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport flipud2d from './../../../base/flipud2d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the second-to-last dimension of a three-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>} x - nested input array\n* @returns {Array>} output array\n*\n* @example\n* var x = [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ];\n*\n* var out = flipud3d( x );\n* // returns [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ]\n*/\nfunction flipud3d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( flipud2d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flipud3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport flipud3d from './../../../base/flipud3d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the second-to-last dimension of a four-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>>} x - nested input array\n* @returns {Array>>} output array\n*\n* @example\n* var x = [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ];\n*\n* var out = flipud4d( x );\n* // returns [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ]\n*/\nfunction flipud4d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( flipud3d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flipud4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ceil from '@stdlib/math/base/special/ceil';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array according to a provided increment.\n*\n* @param {number} x1 - first array value\n* @param {number} x2 - array element bound\n* @param {number} increment - increment\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = incrspace( 0, 11, 2 );\n* // returns [ 0, 2, 4, 6, 8, 10 ]\n*/\nfunction incrspace( x1, x2, increment ) {\n\tvar arr;\n\tvar len;\n\tvar i;\n\n\tlen = ceil( ( x2-x1 ) / increment );\n\tif ( len <= 1 ) {\n\t\treturn [ x1 ];\n\t}\n\tarr = [ x1 ];\n\tfor ( i = 1; i < len; i++ ) {\n\t\tarr.push( x1 + (increment*i) );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default incrspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from './../../is-collection';\nimport isFunction from './../../is-function';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array-like object supporting the accessor (get/set) protocol.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is an accessor array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isAccessorArray( new Complex128Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isAccessorArray( [] );\n* // returns false\n*\n* @example\n* var bool = isAccessorArray( {} );\n* // returns false\n*/\nfunction isAccessorArray( value ) {\n\treturn (\n\t\tisCollection( value ) &&\n\t\tisFunction( value.get ) &&\n\t\tisFunction( value.set )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isAccessorArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Tests if a value is `undefined` or `null`.\n*\n* ## Notes\n*\n* - In older browsers, `undefined` is a global which can be overridden. `void`, however, is an operator which **cannot** be overridden. Consequently, better to use `void` to check for `undefined`. See [Stack Overflow][1].\n*\n* [1]: http://stackoverflow.com/a/19369078/2225624\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is undefined\n*\n* @example\n* var bool = isUndefinedOrNull( undefined );\n* // returns true\n*\n* bool = isUndefinedOrNull( null );\n* // returns true\n*\n* bool = isUndefinedOrNull( false );\n* // returns false\n*/\nfunction isUndefinedOrNull( value ) {\n\treturn ( value === void 0 || value === null );\n}\n\n\n// EXPORTS //\n\nexport default isUndefinedOrNull;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport pow from '@stdlib/math/base/special/pow';\n\n\n// MAIN //\n\n/**\n* Generates a logarithmically spaced numeric array.\n*\n* @param {number} a - exponent of start value\n* @param {number} b - exponent of end value\n* @param {NonNegativeInteger} len - length of output array\n* @returns {Array} logarithmically spaced numeric array\n*\n* @example\n* var arr = logspace( 0, 2, 6 );\n* // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ]\n*/\nfunction logspace( a, b, len ) {\n\tvar arr;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Calculate the increment:\n\tN = len - 1;\n\td = ( b-a ) / N;\n\n\t// Build the output array...\n\tarr = [ pow( 10, a ) ];\n\tfor ( i = 1; i < N; i++ ) {\n\t\tarr.push( pow( 10, a+(d*i) ) );\n\t}\n\tarr.push( pow( 10, b ) );\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default logspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a new two-dimensional nested output array.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = map2d( x, shape, scale );\n* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*/\nfunction map2d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar y;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\ty = [];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = [];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i1, i0 ], x ) );\n\t\t}\n\t\ty.push( y0 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a new three-dimensional nested output array.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = map3d( x, shape, scale );\n* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*/\nfunction map3d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar y;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\ty = [];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = [];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = [];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i2, i1, i0 ], x ) );\n\t\t\t}\n\t\t\ty1.push( y0 );\n\t\t}\n\t\ty.push( y1 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a new five-dimensional nested output array.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = map5d( x, shape, scale );\n* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*/\nfunction map5d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar x3;\n\tvar y3;\n\tvar y;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\ty = [];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = [];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = [];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = [];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = [];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i4, i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t\t}\n\t\t\t\t\ty1.push( y0 );\n\t\t\t\t}\n\t\t\t\ty2.push( y1 );\n\t\t\t}\n\t\t\ty3.push( y2 );\n\t\t}\n\t\ty.push( y3 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport INT8_MIN from '@stdlib/constants/int8/min';\nimport INT16_MIN from '@stdlib/constants/int16/min';\nimport INT32_MIN from '@stdlib/constants/int32/min';\nimport INT8_MAX from '@stdlib/constants/int8/max';\nimport INT16_MAX from '@stdlib/constants/int16/max';\nimport INT32_MAX from '@stdlib/constants/int32/max';\n\n\n// MAIN //\n\n/**\n* Returns the minimum array data type for storing a provided signed integer value.\n*\n* @param {integer} value - scalar value\n* @returns {string} array data type\n*\n* @example\n* var dt = minSignedIntegerDataType( 9999 );\n* // returns 'int16'\n*\n* @example\n* var dt = minSignedIntegerDataType( 3 );\n* // returns 'int8'\n*/\nfunction minSignedIntegerDataType( value ) {\n\tif ( value < 0 ) {\n\t\tif ( value >= INT8_MIN ) {\n\t\t\treturn 'int8';\n\t\t}\n\t\tif ( value >= INT16_MIN ) {\n\t\t\treturn 'int16';\n\t\t}\n\t\tif ( value >= INT32_MIN ) {\n\t\t\treturn 'int32';\n\t\t}\n\t\treturn 'float64';\n\t}\n\tif ( value <= INT8_MAX ) {\n\t\treturn 'int8';\n\t}\n\tif ( value <= INT16_MAX ) {\n\t\treturn 'int16';\n\t}\n\tif ( value <= INT32_MAX ) {\n\t\treturn 'int32';\n\t}\n\treturn 'float64';\n}\n\n\n// EXPORTS //\n\nexport default minSignedIntegerDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns a new array by applying a mask to a provided input array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*/\nfunction mskfilter( x, mask ) {\n\tvar xget;\n\tvar mget;\n\tvar out;\n\tvar i;\n\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tmget = resolveGetter( mask );\n\n\t// Extract each desired element from the provided array...\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mget( mask, i ) ) {\n\t\t\tout.push( xget( x, i ) ); // use `Array#push` to ensure \"fast\" elements\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default mskfilter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns a new array after applying a mask and a callback function to a provided input array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* function scale( val ) {\n* return 10 * val;\n* }\n*\n* var y = mskfilterMap( x, mask, scale );\n* // returns [ 20, 40 ]\n*/\nfunction mskfilterMap( x, mask, clbk, thisArg ) {\n\tvar xget;\n\tvar mget;\n\tvar out;\n\tvar i;\n\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tmget = resolveGetter( mask );\n\n\t// Extract each desired element from the provided array...\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mget( mask, i ) ) {\n\t\t\tout.push( clbk.call( thisArg, xget( x, i ), i, x ) ); // use `Array#push` to ensure \"fast\" elements\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default mskfilterMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpretComplex from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport countFalsy from './../../../base/count-falsy';\n\n\n// FUNCTIONS //\n\n/**\n* Replaces elements in an indexed array with provided values.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = [ 20, 30 ];\n*\n* var out = indexed( x, mask, values );\n* // returns [ 1, 20, 30, 4 ]\n*/\nfunction indexed( x, mask, values ) {\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !mask[ i ] ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tiv = ( iv+1 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n/**\n* Replaces elements of an accessor array with provided values.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} mask - mask array object\n* @param {Object} values - values object\n* @returns {Collection} input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var mask = toAccessorArray( [ 1, 0, 0, 1 ] );\n* var values = toAccessorArray( [ 20, 30 ] );\n*\n* var out = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( values ) );\n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* v = x.get( 1 );\n* // returns 20\n*/\nfunction accessors( x, mask, values ) {\n\tvar xdata;\n\tvar mdata;\n\tvar vdata;\n\tvar xset;\n\tvar mget;\n\tvar vget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\txdata = x.data;\n\tmdata = mask.data;\n\tvdata = values.data;\n\n\txset = x.accessors[ 1 ];\n\tmget = mask.accessors[ 0 ];\n\tvget = values.accessors[ 0 ];\n\n\tN = vdata.length;\n\tiv = 0;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( !mget( mdata, i ) ) {\n\t\t\txset( xdata, i, vget( vdata, iv ) );\n\t\t\tiv = ( iv+1 ) % N;\n\t\t}\n\t}\n\treturn xdata;\n}\n\n/**\n* Replaces elements in a complex array with provided values.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} mask - mask array object\n* @param {Collection} values - real-valued floating-point values array view\n* @returns {Collection} input array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n*\n* var mask = [ 0, 1, 0, 1 ];\n* var values = new Float64Array( [ 10.0, 20.0, 50.0, 60.0 ] );\n*\n* var out = complex( x, arraylike2object( mask ), values );\n* // returns [ 10.0, 20.0, 3.0, 4.0, 50.0, 60.0, 7.0, 8.0 ]\n*/\nfunction complex( x, mask, values ) {\n\tvar mdata;\n\tvar mget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( !mget( mdata, i/2 ) ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tx[ i+1 ] = values[ iv+1 ];\n\t\t\tiv = ( iv+2 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n/**\n* Replaces elements in a boolean array with provided values.\n*\n* @private\n* @param {Uint8Array} x - input array\n* @param {Object} mask - mask array object\n* @param {Uint8Array} values - values to set\n* @returns {Uint8Array} input array\n*\n* @example\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = new Uint8Array( [ 1, 1 ] );\n*\n* var out = boolean( x, arraylike2object( mask ), values );\n* // returns [ 1, 1, 1, 1 ]\n*/\nfunction boolean( x, mask, values ) {\n\tvar mdata;\n\tvar mget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !mget( mdata, i ) ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tiv = ( i+1 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n\n// MAIN //\n\n/**\n* Replaces elements of an array with provided values according to a provided mask array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @param {string} mode - string specifying behavior when the number of values does not equal the number of falsy mask values\n* @throws {Error} insufficient values to satisfy mask array\n* @throws {Error} number of values does not equal the number of falsy mask values\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = [ 20, 30 ];\n*\n* var out = mskput( x, mask, values, 'strict' );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = [ 30 ];\n*\n* var out = mskput( x, mask, values, 'strict_broadcast' );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 0, 1, 0 ];\n* var values = [ 20, 30 ];\n*\n* var out = mskput( x, mask, values, 'repeat' );\n* // returns [ 20, 30, 3, 20 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction mskput( x, mask, values, mode ) {\n\tvar xo;\n\tvar mo;\n\tvar vo;\n\tvar M;\n\n\tM = values.length;\n\tif ( mode === 'strict' ) {\n\t\tif ( countFalsy( mask ) !== M ) {\n\t\t\tthrow new Error( 'invalid arguments. Number of values does not equal the number of falsy values in the mask array.' );\n\t\t}\n\t} else if ( mode === 'broadcast' ) {\n\t\tif ( M !== 1 && countFalsy( mask ) > M ) {\n\t\t\tthrow new Error( 'invalid arguments. Insufficient values to satisfy mask array.' );\n\t\t}\n\t} else if ( mode === 'strict_broadcast' ) {\n\t\tif ( M !== 1 && countFalsy( mask ) !== M ) {\n\t\t\tthrow new Error( 'invalid arguments. Number of values does not equal the number of falsy values in the mask array.' );\n\t\t}\n\t} else if ( mode === 'non_strict' ) {\n\t\tif ( countFalsy( mask ) > M ) {\n\t\t\tthrow new Error( 'invalid arguments. Insufficient values to satisfy mask array.' );\n\t\t}\n\t}\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\tvo = arraylike2object( values );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\tvo.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support select dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif ( isComplexDataType( xo.dtype ) && isComplexDataType( vo.dtype ) ) {\n\t\t\tcomplex( reinterpretComplex( x, 0 ), mo, reinterpretComplex( values, 0 ) ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\tif ( isBooleanDataType( xo.dtype ) && isBooleanDataType( vo.dtype ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( values, 0 ) ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\taccessors( xo, mo, vo );\n\t\treturn x;\n\t}\n\tindexed( x, mask, values );\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default mskput;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns a new array by applying a mask to a provided input array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskreject( x, mask );\n* // returns [ 1, 3 ]\n*/\nfunction mskreject( x, mask ) {\n\tvar xget;\n\tvar mget;\n\tvar out;\n\tvar i;\n\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tmget = resolveGetter( mask );\n\n\t// Extract each desired element from the provided array...\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !mget( mask, i ) ) {\n\t\t\tout.push( xget( x, i ) ); // use `Array#push` to ensure \"fast\" elements\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default mskreject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a non-enumerable property.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {*} value - value to set\n*\n* @example\n* import objectKeys from '@stdlib/utils/keys';\n*\n* var obj = {};\n*\n* setNonEnumerableProperty( obj, 'foo', 'bar' );\n*\n* var v = obj.foo;\n* // returns 'bar'\n*\n* var keys = objectKeys( obj );\n* // returns []\n*/\nfunction setNonEnumerableProperty( obj, prop, value ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': true,\n\t\t'enumerable': false,\n\t\t'writable': true,\n\t\t'value': value\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setNonEnumerableProperty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether all elements in an array are falsy.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether all elements are falsy\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = internal( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 4 ];\n*\n* var out = internal( x );\n* // returns false\n*/\nfunction internal( x ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( x[ i ] ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array are falsy.\n*\n* @private\n* @param {Object} x - input array object\n* @returns {boolean} boolean indicating whether all elements are falsy\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n*\n* var out = accessors( x );\n* // returns true\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 0, 4 ] ) );\n*\n* var out = accessors( x );\n* // returns false\n*/\nfunction accessors( x ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( get( data, i ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array are falsy.\n*\n* @param {Collection} x - input array\n* @returns {boolean} boolean indicating whether all elements are falsy\n*\n* @example\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = none( x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 0, 4 ];\n*\n* var out = none( x );\n* // returns false\n*/\nfunction none( x ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and test interleaved real and imaginary components, where we consider a complex number to be falsy if both components are zero...\n\t\tif ( isComplex128Array( x ) ) {\n\t\t\treturn internal( reinterpret128( x, 0 ) );\n\t\t}\n\t\tif ( isComplex64Array( x ) ) {\n\t\t\treturn internal( reinterpret64( x, 0 ) );\n\t\t}\n\t\t// If provided a boolean array, reinterpret as a typed array and test whether all elements are false...\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn internal( reinterpretBoolean( x, 0 ) );\n\t\t}\n\t\treturn accessors( obj );\n\t}\n\treturn internal( x );\n}\n\n\n// EXPORTS //\n\nexport default none;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from one.\n*\n* @param {number} n - number of elements\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = oneTo( 6 );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*/\nfunction oneTo( n ) {\n\tvar arr;\n\tvar i;\n\n\tarr = [];\n\tif ( n <= 0 ) {\n\t\treturn arr;\n\t}\n\tfor ( i = 1; i < n+1; i++ ) {\n\t\tarr.push( i );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default oneTo;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplex128Array from './../../../base/assert/is-complex128array';\nimport isComplex64Array from './../../../base/assert/is-complex64array';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n\n\n// FUNCTIONS //\n\n/**\n* Fills an indexed array with linearly spaced numeric elements which increment by 1 starting from one.\n*\n* @private\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = indexed( out, 1, 0 );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = indexed( out, -1, out.length-1 );\n* // returns [ 6, 5, 4, 3, 2, 1 ]\n*/\nfunction indexed( out, stride, offset ) {\n\tvar v;\n\tvar i;\n\n\ti = offset;\n\tv = 1;\n\twhile ( i >= 0 && i < out.length ) {\n\t\tout[ i ] = v;\n\t\ti += stride;\n\t\tv += 1;\n\t}\n\treturn out;\n}\n\n/**\n* Fills a complex number array with linearly spaced numeric elements which increment by 1 starting from one.\n*\n* @private\n* @param {(Complex128Array|Complex64Array)} out - output complex number array\n* @param {(Float64Array|Float32Array)} data - output array data\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {(Complex128Array|Complex64Array)} output array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\n*\n* var out = new Complex128Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );\n* // returns \n*\n* var data = reinterpret128( out, 0 );\n* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]\n*\n* var arr = complex( out, data, 1, 0 );\n* // returns \n*\n* var bool = ( arr === out );\n* // returns true\n*\n* data = reinterpret128( out, 0 );\n* returns [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ]\n*/\nfunction complex( out, data, stride, offset ) {\n\tvar v;\n\tvar s;\n\tvar i;\n\n\ts = stride * 2;\n\ti = offset * 2;\n\tv = 1.0;\n\twhile ( i >= 0 && i < data.length ) {\n\t\tdata[ i ] = v; // real component\n\t\tdata[ i+1 ] = 0.0; // imaginary component\n\t\ti += s;\n\t\tv += 1.0;\n\t}\n\treturn out;\n}\n\n/**\n* Fills an accessor array with linearly spaced numeric elements which increment by 1 starting from one.\n*\n* @private\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n\n* var out = toAccessorArray( [ 0, 0, 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( out ), 1, 0 );\n*\n* var bool = ( arr === out );\n* // returns true\n*\n* var v = out.get( 0 );\n* // returns 1\n*\n* v = out.get( out.length-1 );\n* // returns 6\n*/\nfunction accessors( out, stride, offset ) {\n\tvar data;\n\tvar set;\n\tvar v;\n\tvar i;\n\n\tdata = out.data;\n\tset = out.accessors[ 1 ];\n\n\ti = offset;\n\tv = 1;\n\twhile ( i >= 0 && i < data.length ) {\n\t\tset( data, i, v );\n\t\ti += stride;\n\t\tv += 1;\n\t}\n\treturn data;\n}\n\n\n// MAIN //\n\n/**\n* Fills an array with linearly spaced numeric elements which increment by 1 starting from one.\n*\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = assign( out, 1, 0 );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*\n* @example\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n*\n* var arr = assign( out, -1, out.length-1 );\n* // returns [ 6, 5, 4, 3, 2, 1 ]\n*/\nfunction assign( out, stride, offset ) {\n\tvar obj = arraylike2object( out );\n\tif ( obj.accessorProtocol ) {\n\t\t// If provided a complex number array, reinterpret as a real typed array and only set the real components...\n\t\tif ( isComplex128Array( out ) ) {\n\t\t\treturn complex( out, reinterpret128( out, 0 ), stride, offset );\n\t\t}\n\t\tif ( isComplex64Array( out ) ) {\n\t\t\treturn complex( out, reinterpret64( out, 0 ), stride, offset );\n\t\t}\n\t\treturn accessors( obj, stride, offset );\n\t}\n\treturn indexed( out, stride, offset );\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpretComplex from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport countTruthy from './../../../base/count-truthy';\n\n\n// FUNCTIONS //\n\n/**\n* Replaces elements in an indexed array with provided values.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 1, 1, 0 ];\n* var values = [ 20, 30 ];\n*\n* var out = indexed( x, mask, values );\n* // returns [ 1, 20, 30, 4 ]\n*/\nfunction indexed( x, mask, values ) {\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mask[ i ] ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tiv = ( iv+1 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n/**\n* Replaces elements of an accessor array with provided values.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} mask - mask array object\n* @param {Object} values - values object\n* @returns {Collection} input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var mask = toAccessorArray( [ 0, 1, 1, 0 ] );\n* var values = toAccessorArray( [ 20, 30 ] );\n*\n* var out = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( values ) );\n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* v = x.get( 1 );\n* // returns 20\n*/\nfunction accessors( x, mask, values ) {\n\tvar xdata;\n\tvar mdata;\n\tvar vdata;\n\tvar xset;\n\tvar mget;\n\tvar vget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\txdata = x.data;\n\tmdata = mask.data;\n\tvdata = values.data;\n\n\txset = x.accessors[ 1 ];\n\tmget = mask.accessors[ 0 ];\n\tvget = values.accessors[ 0 ];\n\n\tN = vdata.length;\n\tiv = 0;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\txset( xdata, i, vget( vdata, iv ) );\n\t\t\tiv = ( iv+1 ) % N;\n\t\t}\n\t}\n\treturn xdata;\n}\n\n/**\n* Replaces elements in a complex array with provided values.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} mask - mask array object\n* @param {Collection} values - real-valued floating-point values array view\n* @returns {Collection} input array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n*\n* var mask = [ 1, 0, 1, 0 ];\n* var values = new Float64Array( [ 10.0, 20.0, 50.0, 60.0 ] );\n*\n* var out = complex( x, arraylike2object( mask ), values );\n* // returns [ 10.0, 20.0, 3.0, 4.0, 50.0, 60.0, 7.0, 8.0 ]\n*/\nfunction complex( x, mask, values ) {\n\tvar mdata;\n\tvar mget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i += 2 ) {\n\t\tif ( mget( mdata, i/2 ) ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tx[ i+1 ] = values[ iv+1 ];\n\t\t\tiv = ( iv+2 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n/**\n* Replaces elements in a boolean array with provided values.\n*\n* @private\n* @param {Uint8Array} x - input array\n* @param {Object} mask - mask array object\n* @param {Uint8Array} values - values to set\n* @returns {Uint8Array} input array\n*\n* @example\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var x = new Uint8Array( [ 0, 1, 1, 0 ] );\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = new Uint8Array( [ 1, 1 ] );\n*\n* var out = boolean( x, arraylike2object( mask ), values );\n* // returns [ 1, 1, 1, 1 ]\n*/\nfunction boolean( x, mask, values ) {\n\tvar mdata;\n\tvar mget;\n\tvar iv;\n\tvar N;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tN = values.length;\n\tiv = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tx[ i ] = values[ iv ];\n\t\t\tiv = ( i+1 ) % N;\n\t\t}\n\t}\n\treturn x;\n}\n\n\n// MAIN //\n\n/**\n* Replaces elements of an array with provided values according to a provided mask array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @param {string} mode - string specifying behavior when the number of values does not equal the number of truthy mask values\n* @throws {Error} insufficient values to satisfy mask array\n* @throws {Error} number of values does not equal the number of truthy mask values\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 1, 1, 0 ];\n* var values = [ 20, 30 ];\n*\n* var out = place( x, mask, values, 'strict' );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 1, 1, 0 ];\n* var values = [ 30 ];\n*\n* var out = place( x, mask, values, 'strict_broadcast' );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 1, 0, 1 ];\n* var values = [ 20, 30 ];\n*\n* var out = place( x, mask, values, 'repeat' );\n* // returns [ 20, 30, 3, 20 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction place( x, mask, values, mode ) {\n\tvar xo;\n\tvar mo;\n\tvar vo;\n\tvar M;\n\n\tM = values.length;\n\tif ( mode === 'strict' ) {\n\t\tif ( countTruthy( mask ) !== M ) {\n\t\t\tthrow new Error( 'invalid arguments. Number of values does not equal the number of truthy values in the mask array.' );\n\t\t}\n\t} else if ( mode === 'broadcast' ) {\n\t\tif ( M !== 1 && countTruthy( mask ) > M ) {\n\t\t\tthrow new Error( 'invalid arguments. Insufficient values to satisfy mask array.' );\n\t\t}\n\t} else if ( mode === 'strict_broadcast' ) {\n\t\tif ( M !== 1 && countTruthy( mask ) !== M ) {\n\t\t\tthrow new Error( 'invalid arguments. Number of values does not equal the number of truthy values in the mask array.' );\n\t\t}\n\t} else if ( mode === 'non_strict' ) {\n\t\tif ( countTruthy( mask ) > M ) {\n\t\t\tthrow new Error( 'invalid arguments. Insufficient values to satisfy mask array.' );\n\t\t}\n\t}\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\tvo = arraylike2object( values );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\tvo.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support select dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif ( isComplexDataType( xo.dtype ) && isComplexDataType( vo.dtype ) ) {\n\t\t\tcomplex( reinterpretComplex( x, 0 ), mo, reinterpretComplex( values, 0 ) ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\tif ( isBooleanDataType( xo.dtype ) && isBooleanDataType( vo.dtype ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( values, 0 ) ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\taccessors( xo, mo, vo );\n\t\treturn x;\n\t}\n\tindexed( x, mask, values );\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default place;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Restricts an index to the interval `[0,max]`.\n*\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @returns {NonNegativeInteger} index\n*\n* @example\n* var idx = clampIndex( -1, 10 );\n* // returns 0\n*\n* idx = clampIndex( 15, 10 );\n* // returns 10\n*\n* idx = clampIndex( 5, 10 );\n* // returns 5\n*/\nfunction clampIndex( idx, max ) {\n\tif ( idx < 0 ) {\n\t\treturn 0;\n\t}\n\tif ( idx > max ) {\n\t\treturn max;\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default clampIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Wraps an index on the interval `[0,max]`.\n*\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @returns {NonNegativeInteger} index\n*\n* @example\n* var idx = wrapIndex( -1, 10 );\n* // returns 10\n*\n* idx = wrapIndex( 13, 10 );\n* // returns 2\n*\n* idx = wrapIndex( 6, 10 );\n* // returns 6\n*/\nfunction wrapIndex( idx, max ) {\n\tvar mp1 = max + 1;\n\tif ( idx < 0 ) {\n\t\tidx += mp1; // slight optimization to avoid modulo arithmetic when |idx| <= max+1\n\t\tif ( idx < 0 ) {\n\t\t\tidx %= mp1;\n\t\t\tif ( idx !== 0 ) {\n\t\t\t\tidx += mp1;\n\t\t\t}\n\t\t}\n\t\treturn idx;\n\t}\n\tif ( idx > max ) {\n\t\tidx -= mp1; // slight optimization to avoid modulo arithmetic when max+1 < idx <= 2*(max+1)\n\t\tif ( idx > max ) {\n\t\t\tidx %= mp1;\n\t\t}\n\t\treturn idx;\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default wrapIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Normalizes an index to the interval `[0,max]`.\n*\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @returns {integer} index\n*\n* @example\n* var idx = normalizeIndex( -2, 10 );\n* // returns 9\n*\n* idx = normalizeIndex( 15, 10 );\n* // returns -1\n*\n* idx = normalizeIndex( 5, 10 );\n* // returns 5\n*/\nfunction normalizeIndex( idx, max ) {\n\tif ( idx < 0 ) {\n\t\tidx += max + 1;\n\t\tif ( idx < 0 ) {\n\t\t\treturn -1;\n\t\t}\n\t\treturn idx;\n\t}\n\tif ( idx > max ) {\n\t\treturn -1;\n\t}\n\treturn idx;\n}\n\n\n// EXPORTS //\n\nexport default normalizeIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../../base/accessor-getter';\nimport dtype from './../../../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a function to tests if an array contains a provided search value.\n*\n* @param {Collection} x - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {Function} function to test if an array contains a search value\n*\n* @example\n* var contains = factory( [ 1, 2, 3 ] );\n* // returns \n*\n* var bool = contains( 2 );\n* // returns true\n*/\nfunction factory( x ) {\n\tvar get;\n\tvar len;\n\tvar dt;\n\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', x ) );\n\t}\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Resolve an accessor for retrieving input array elements:\n\tif ( isAccessorArray( x ) ) {\n\t\tget = accessorGetter( dt );\n\t}\n\t// Get the number of elements over which to iterate:\n\tlen = x.length;\n\n\treturn ( get === void 0 ) ? contains : accessors;\n\t/**\n\t* Tests if an array contains a provided search value.\n\t*\n\t* @private\n\t* @param {*} value - search value\n\t* @returns {boolean} boolean indicating if an array contains a search value\n\t*\n\t* @example\n\t* var out = contains( [ 1, 2, 3 ], 2 );\n\t* // returns true\n\t*/\n\tfunction contains( value ) {\n\t\tvar i;\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( x[ i ] === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t* Tests if an array contains a provided search value.\n\t*\n\t* @private\n\t* @param {*} value - search value\n\t* @returns {boolean} boolean indicating if an array contains a search value\n\t*/\n\tfunction accessors( value ) {\n\t\tvar i;\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( get( x, i ) === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten an n-dimensional nested array according to a callback function.\n*\n* @module @stdlib/array/base/flatten-by\n*\n* @example\n* import flattenBy from '@stdlib/array/base/flatten-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import flattenBy from '@stdlib/array/base/flatten-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flattenBy( x, [ 2, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flattenBy from '@stdlib/array/base/flatten-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flattenBy.assign( x, [ 2, 2 ], true, out, 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a two-dimensional nested array.\n*\n* @module @stdlib/array/base/flatten2d\n*\n* @example\n* import flatten2d from '@stdlib/array/base/flatten2d';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import flatten2d from '@stdlib/array/base/flatten2d';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten2d from '@stdlib/array/base/flatten2d';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten2d.assign( x, [ 2, 2 ], true, out, 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a two-dimensional nested array and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2d( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten2d( x, shape, colexicographic, out, stride, offset ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar a0;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tout[ io ] = x[ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\tio += stride;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ta0 = x[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tout[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a two-dimensional nested array according to a callback function.\n*\n* @module @stdlib/array/base/flatten2d-by\n*\n* @example\n* import flatten2dBy from '@stdlib/array/base/flatten2d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import flatten2dBy from '@stdlib/array/base/flatten2d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten2dBy from '@stdlib/array/base/flatten2d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten2dBy( x, [ 2, 2 ], true, out, 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a two-dimensional nested array according to a callback function and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], false, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var out = flatten2dBy( x, [ 2, 2 ], true, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten2dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) { // eslint-disable-line max-len\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar a0;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 1 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tout[ io ] = clbk.call( thisArg, x[ i1 ][ i0 ], [ i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\tio += stride;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ta0 = x[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tout[ io ] = clbk.call( thisArg, a0[ i0 ], [ i1, i0 ], x ); // equivalent to storing in row-major (C-style) order\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a three-dimensional nested array.\n*\n* @module @stdlib/array/base/flatten3d\n*\n* @example\n* import flatten3d from '@stdlib/array/base/flatten3d';\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import flatten3d from '@stdlib/array/base/flatten3d';\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten3d from '@stdlib/array/base/flatten3d';\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten3d.assign( x, [ 2, 1, 2 ], true, out, 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*\n* var bool = ( y === out );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a three-dimensional nested array and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], false, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3d( x, [ 2, 1, 2 ], true, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten3d( x, shape, colexicographic, out, stride, offset ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar a0;\n\tvar a1;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tout[ io ] = x[ i2 ][ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\tio += stride;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = x[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta0 = a1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tout[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order\n\t\t\t\tio += stride;\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a three-dimensional nested array according to a callback function.\n*\n* @module @stdlib/array/base/flatten3d-by\n*\n* @example\n* import flatten3dBy from '@stdlib/array/base/flatten3d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import flatten3dBy from '@stdlib/array/base/flatten3d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten3dBy from '@stdlib/array/base/flatten3d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten3dBy.assign( x, [ 2, 1, 2 ], true, out, 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* var bool = ( y === out );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a three-dimensional nested array according to a callback function and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], false, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ 1, 2 ] ], [ [ 3, 4 ] ] ];\n*\n* var out = flatten3dBy( x, [ 2, 1, 2 ], true, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten3dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar a0;\n\tvar a1;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 2 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tout[ io ] = clbk.call( thisArg, x[ i2 ][ i1 ][ i0 ], [ i2, i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\tio += stride;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = x[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta0 = a1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tout[ io ] = clbk.call( thisArg, a0[ i0 ], [ i2, i1, i0 ], x ); // equivalent to storing in row-major (C-style) order\n\t\t\t\tio += stride;\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten3dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a four-dimensional nested array.\n*\n* @module @stdlib/array/base/flatten4d\n*\n* @example\n* import flatten4d from '@stdlib/array/base/flatten4d';\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import flatten4d from '@stdlib/array/base/flatten4d';\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten4d from '@stdlib/array/base/flatten4d';\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten4d.assign( x, [ 2, 1, 1, 2 ], true, out, 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a four-dimensional nested array and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4d( x, [ 2, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten4d( x, shape, colexicographic, out, stride, offset ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tout[ io ] = x[ i3 ][ i2 ][ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\tio += stride;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = x[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = a2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tout[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order\n\t\t\t\t\tio += stride;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a four-dimensional nested array according to a callback function.\n*\n* @module @stdlib/array/base/flatten4d-by\n*\n* @example\n* import flatten4dBy from '@stdlib/array/base/flatten4d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import flatten4dBy from '@stdlib/array/base/flatten4d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten4dBy from '@stdlib/array/base/flatten4d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten4dBy.assign( x, [ 2, 1, 1, 2 ], true, out, 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a four-dimensional nested array according to a callback function and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ 1, 2 ] ] ], [ [ [ 3, 4 ] ] ] ];\n*\n* var out = flatten4dBy( x, [ 2, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten4dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 3 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tout[ io ] = clbk.call( thisArg, x[ i3 ][ i2 ][ i1 ][ i0 ], [ i3, i2, i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\tio += stride;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = x[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = a2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tout[ io ] = clbk.call( thisArg, a0[ i0 ], [ i3, i2, i1, i0 ], x ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t\tio += stride;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten4dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a five-dimensional nested array.\n*\n* @module @stdlib/array/base/flatten5d\n*\n* @example\n* import flatten5d from '@stdlib/array/base/flatten5d';\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import flatten5d from '@stdlib/array/base/flatten5d';\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true );\n* // returns [ 1, 3, 2, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten5d from '@stdlib/array/base/flatten5d';\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten5d.assign( x, [ 2, 1, 1, 1, 2 ], true, out, 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a five-dimensional nested array and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 2, 3, 4 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5d( x, [ 2, 1, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0 );\n* // returns [ 1, 3, 2, 4 ]\n*/\nfunction flatten5d( x, shape, colexicographic, out, stride, offset ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\t\t\t\t\t\tout[ io ] = x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ]; // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\t\tio += stride;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = x[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = a3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = a2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tout[ io ] = a0[ i0 ]; // equivalent to storing in row-major (C-style) order\n\t\t\t\t\t\tio += stride;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Flatten a five-dimensional nested array according to a callback function.\n*\n* @module @stdlib/array/base/flatten5d-by\n*\n* @example\n* import flatten5dBy from '@stdlib/array/base/flatten5d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import flatten5dBy from '@stdlib/array/base/flatten5d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import flatten5dBy from '@stdlib/array/base/flatten5d-by';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = new Float64Array( 4 );\n* var y = flatten5dBy.assign( x, [ 2, 1, 1, 1, 2 ], true, out, 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth, max-len */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Flattens a five-dimensional nested array according to a callback function and assigns elements to a provided output array.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length (i.e., the input array is **not** a ragged array).\n*\n* @param {Array>>>} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether to flatten array values in colexicographic order\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array index offset\n* @param {Function} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], false, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 4, 6, 8 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function scale( v ) {\n* return v * 2;\n* }\n*\n* var x = [ [ [ [ [ 1, 2 ] ] ] ], [ [ [ [ 3, 4 ] ] ] ] ];\n*\n* var out = flatten5dBy( x, [ 2, 1, 1, 1, 2 ], true, new Float64Array( 4 ), 1, 0, scale );\n* // returns [ 2, 6, 4, 8 ]\n*/\nfunction flatten5dBy( x, shape, colexicographic, out, stride, offset, clbk, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\tvar io;\n\n\t// Extract loop variables:\n\tS0 = shape[ 4 ]; // for nested arrays, the last dimensions have the fastest changing indices\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Iterate over the array dimensions...\n\tio = offset;\n\tif ( colexicographic ) {\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\t\t\t\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\t\t\t\t\t\tout[ io ] = clbk.call( thisArg, x[ i4 ][ i3 ][ i2 ][ i1 ][ i0 ], [ i4, i3, i2, i1, i0 ], x ); // equivalent to storing in column-major (Fortran-style) order\n\t\t\t\t\t\t\tio += stride;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = x[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = a3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = a2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta0 = a1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tout[ io ] = clbk.call( thisArg, a0[ i0 ], [ i4, i3, i2, i1, i0 ], x ); // equivalent to storing in row-major (C-style) order\n\t\t\t\t\t\tio += stride;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flatten5dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a two-dimensional nested input array and assign results to elements in a new two-dimensional nested output array.\n*\n* @module @stdlib/array/base/map2d\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import map2d from '@stdlib/array/base/map2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = map2d( x, shape, scale );\n* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import map2d from '@stdlib/array/base/map2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = zeros2d( shape );\n*\n* var out = map2d.assign( x, y, shape, scale );\n* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = zeros2d( shape );\n*\n* var out = map2d( x, y, shape, scale );\n* // returns [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map2d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i1, i0 ], x );\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a three-dimensional nested input array and assign results to elements in a new three-dimensional nested output array.\n*\n* @module @stdlib/array/base/map3d\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import map3d from '@stdlib/array/base/map3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = map3d( x, shape, scale );\n* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import map3d from '@stdlib/array/base/map3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = zeros3d( shape );\n*\n* var out = map3d.assign( x, y, shape, scale );\n* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = zeros3d( shape );\n*\n* var out = map3d( x, y, shape, scale );\n* // returns [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map3d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i2, i1, i0 ], x );\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array/base/map4d\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import map4d from '@stdlib/array/base/map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import map4d from '@stdlib/array/base/map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a five-dimensional nested input array and assign results to elements in a new five-dimensional nested output array.\n*\n* @module @stdlib/array/base/map5d\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import map5d from '@stdlib/array/base/map5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = map5d( x, shape, scale );\n* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import map5d from '@stdlib/array/base/map5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = zeros5d( shape );\n*\n* var out = map5d.assign( x, y, shape, scale );\n* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = zeros5d( shape );\n*\n* var out = map5d( x, y, shape, scale );\n* // returns [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map5d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar x3;\n\tvar y3;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i4, i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array/base/mskfilter\n*\n* @example\n* import mskfilter from '@stdlib/array/base/mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import mskfilter from '@stdlib/array/base/mskfilter';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilter.assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array.\n*\n* @private\n* @param {Collection} x - input array\n* @param {IntegerArray} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n*\n* var arr = indexed( x, mask, out, 1, 0 );\n* // returns [ 2, 4, 0, 0 ]\n*/\nfunction indexed( x, mask, out, stride, offset ) {\n\tvar io;\n\tvar i;\n\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mask[ i ] ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} mask - mask array object\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var mask = toAccessorArray( [ 0, 1, 0, 1 ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 2\n*\n* v = arr.get( 1 );\n* // returns 4\n*/\nfunction accessors( x, mask, out, stride, offset ) {\n\tvar xdata;\n\tvar mdata;\n\tvar odata;\n\tvar xget;\n\tvar mget;\n\tvar oset;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tmdata = mask.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\tmget = mask.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\toset( odata, io, xget( xdata, i ) );\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn odata;\n}\n\n/**\n* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Float64Array( 8 );\n*\n* var arr = complex( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 3.0, 4.0, 7.0, 8.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 0, 1, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 2, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask and a callback function to a provided input array.\n*\n* @module @stdlib/array/base/mskfilter-map\n*\n* @example\n* import mskfilterMap from '@stdlib/array/base/mskfilter-map';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* function scale( val ) {\n* return 10 * val;\n* }\n*\n* var y = mskfilterMap( x, mask, scale );\n* // returns [ 20, 40 ]\n*\n* @example\n* import mskfilterMap from '@stdlib/array/base/mskfilter-map';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* function scale( val ) {\n* return 10 * val;\n* }\n*\n* var out = [ 0, 0 ];\n* var arr = mskfilterMap.assign( x, mask, out, 1, 0, scale );\n* // returns [ 20, 40 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Applies a mask and a callback function to an indexed array and assigns results to elements in an indexed output array.\n*\n* @private\n* @param {Collection} x - input array\n* @param {IntegerArray} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - function to apply\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n*\n* function scale( x ) {\n* return x * 10;\n* }\n*\n* var arr = indexed( x, mask, out, 1, 0, scale );\n* // returns [ 20, 40, 0, 0 ]\n*/\nfunction indexed( x, mask, out, stride, offset, clbk, thisArg ) {\n\tvar io;\n\tvar i;\n\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mask[ i ] ) {\n\t\t\tout[ io ] = clbk.call( thisArg, x[ i ], i, x );\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask and a callback function to an input accessor array and assigns results to elements in an output accessor array.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} mask - mask array object\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - function to apply\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var mask = toAccessorArray( [ 0, 1, 0, 1 ] );\n*\n* function scale( x ) {\n* return x * 10;\n* }\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0, scale );\n*\n* var v = arr.get( 0 );\n* // returns 20\n*\n* v = arr.get( 1 );\n* // returns 40\n*/\nfunction accessors( x, mask, out, stride, offset, clbk, thisArg ) {\n\tvar xdata;\n\tvar mdata;\n\tvar odata;\n\tvar xget;\n\tvar mget;\n\tvar oset;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tmdata = mask.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\tmget = mask.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( mget( mdata, i ) ) {\n\t\t\toset( odata, io, clbk.call( thisArg, xget( xdata, i ), i, xdata ) );\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn odata;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask and a callback function to a provided input array and assigns results to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} clbk - function to apply\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* function scale( x ) {\n* return x * 10;\n* }\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0, scale );\n* // returns [ 20, 40 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset, clbk, thisArg ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\taccessors( xo, mo, oo, stride, offset, clbk, thisArg );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset, clbk, thisArg );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a mask to a provided input array.\n*\n* @module @stdlib/array/base/mskreject\n*\n* @example\n* import mskreject from '@stdlib/array/base/mskreject';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskreject( x, mask );\n* // returns [ 1, 3 ]\n*\n* @example\n* import mskreject from '@stdlib/array/base/mskreject';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = mskreject.assign( x, mask, out, 1, 0 );\n* // returns [ 1, 3 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\n\n\n// FUNCTIONS //\n\n/**\n* Applies a mask to an indexed array and assigns unmasked values to elements in an indexed output array.\n*\n* @private\n* @param {Collection} x - input array\n* @param {IntegerArray} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n*\n* var arr = indexed( x, mask, out, 1, 0 );\n* // returns [ 1, 3, 0, 0 ]\n*/\nfunction indexed( x, mask, out, stride, offset ) {\n\tvar io;\n\tvar i;\n\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !mask[ i ] ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to an accessor array and assigns unmasked values to elements in an accessor output array.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} mask - mask array object\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var mask = toAccessorArray( [ 0, 1, 0, 1 ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), arraylike2object( mask ), arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* v = arr.get( 1 );\n* // returns 3\n*/\nfunction accessors( x, mask, out, stride, offset ) {\n\tvar xdata;\n\tvar mdata;\n\tvar odata;\n\tvar xget;\n\tvar mget;\n\tvar oset;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tmdata = mask.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\tmget = mask.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( !mget( mdata, i ) ) {\n\t\t\toset( odata, io, xget( xdata, i ) );\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn odata;\n}\n\n/**\n* Applies a mask to a complex array and assigns unmasked values to elements in a complex output array.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Float64Array( 8 );\n*\n* var arr = complex( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 1.0, 2.0, 5.0, 6.0, 0.0, 0.0, 0.0, 0.0 ]\n*/\nfunction complex( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( !mget( mdata, i ) ) {\n\t\t\tj = i * 2;\n\t\t\tout[ io ] = x[ j ];\n\t\t\tout[ io+1 ] = x[ j+1 ];\n\t\t\tio += so;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Applies a mask to a boolean array and assigns unmasked values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean input array view\n* @param {Object} mask - mask array object\n* @param {Collection} out - boolean output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( mask ), out, 1, 0 );\n* // returns [ 1, 0, 0, 0 ]\n*/\nfunction boolean( x, mask, out, stride, offset ) {\n\tvar mdata;\n\tvar mget;\n\tvar io;\n\tvar i;\n\n\tmdata = mask.data;\n\tmget = mask.accessors[ 0 ];\n\n\tio = offset;\n\tfor ( i = 0; i < mdata.length; i++ ) {\n\t\tif ( !mget( mdata, i ) ) {\n\t\t\tout[ io ] = x[ i ];\n\t\t\tio += stride;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Applies a mask to a provided input array and assigns unmasked values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = [ 0, 0 ];\n* var arr = assign( x, mask, out, 1, 0 );\n* // returns [ 1, 3 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, mask, out, stride, offset ) {\n\tvar xo;\n\tvar mo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tmo = arraylike2object( mask );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tmo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), mo, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), mo, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, mo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, mask, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Generate a linearly spaced numeric array whose elements increment by 1 starting from one.\n*\n* @module @stdlib/array/base/one-to\n*\n* @example\n* import oneTo from '@stdlib/array/base/one-to';\n*\n* var arr = oneTo( 6 );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*\n* @example\n* import oneTo from '@stdlib/array/base/one-to';\n*\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n* var arr = oneTo.assign( out, 1, 0 );\n* // returns [ 1, 2, 3, 4, 5, 6 ]\n*\n* var bool = ( out === arr );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if an array contains a provided search value.\n*\n* @module @stdlib/array/base/assert/contains\n*\n* @example\n* import contains from '@stdlib/array/base/assert/contains';\n*\n* var out = contains( [ 1, 2, 3 ], 2 );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n\n// exports: { \"factory\": \"main.factory\" }\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../../base/assert/is-accessor-array';\nimport accessorGetter from './../../../../base/accessor-getter';\nimport getter from './../../../../base/getter';\nimport dtype from './../../../../dtype';\n\n\n// MAIN //\n\n/**\n* Tests if an array contains a provided search value.\n*\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {boolean} boolean indicating if an array contains a search value\n*\n* @example\n* var out = contains( [ 1, 2, 3 ], 2 );\n* // returns true\n*/\nfunction contains( x, value ) {\n\tvar len;\n\tvar get;\n\tvar dt;\n\tvar i;\n\n\t// Resolve the input array data type:\n\tdt = dtype( x );\n\n\t// Resolve an accessor for retrieving input array elements:\n\tif ( isAccessorArray( x ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\t// Get the number of elements over which to iterate:\n\tlen = x.length;\n\n\t// Loop over the elements...\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( get( x, i ) === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default contains;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport MODES from './modes.json';\n\n\n// MAIN //\n\n/**\n* Returns a list of ndarray index modes.\n*\n* @returns {StringArray} list of ndarray index modes\n*\n* @example\n* var list = modes();\n* // returns [ 'throw', 'normalize', 'clamp', 'wrap' ]\n*/\nfunction modes() {\n\treturn MODES.slice();\n}\n\n\n// EXPORTS //\n\nexport default modes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return a list of ndarray index modes.\n*\n* @module @stdlib/ndarray/index-modes\n*\n* @example\n* import modes from '@stdlib/ndarray/index-modes';\n*\n* var list = modes();\n* // returns [ 'throw', 'normalize', 'clamp', 'wrap' ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport modes from './main.js';\nimport enumeration from './enum.js';\n\n\n// MAIN //\n\nsetReadOnly( modes, 'enum', enumeration );\n\n\n// EXPORTS //\n\nexport default modes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an object mapping supported index modes to integer values for purposes of C inter-operation.\n*\n* ## Notes\n*\n* - Downstream consumers of this mapping should **not** rely on specific integer values (e.g., `throw == 1`). Instead, the object should be used in an opaque manner.\n* - The main purpose of this function is JavaScript and C inter-operation of ndarray objects.\n*\n* @returns {Object} object mapping supported index modes to integer values\n*\n* @example\n* var table = enumerated();\n* // returns \n*/\nfunction enumerated() {\n\t// NOTE: the following should match the C `index_modes.h` enumeration!!!!\n\treturn {\n\t\t'throw': 1,\n\t\t'clamp': 2,\n\t\t'wrap': 3,\n\t\t'normalize': 4\n\t};\n}\n\n\n// EXPORTS //\n\nexport default enumerated;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from '@stdlib/array/base/assert/contains';\nimport modes from './../../../../index-modes';\n\n\n// MAIN //\n\n/**\n* Tests whether an input value is a supported ndarray index mode.\n*\n* @name isIndexMode\n* @type {Function}\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating whether an input value is a supported ndarray index mode\n*\n* @example\n* var bool = isIndexMode( 'wrap' );\n* // returns true\n*\n* bool = isIndexMode( 'clamp' );\n* // returns true\n*\n* bool = isIndexMode( 'throw' );\n* // returns true\n*\n* bool = isIndexMode( 'foo' );\n* // returns false\n*/\nvar isIndexMode = contains( modes() );\n\n\n// EXPORTS //\n\nexport default isIndexMode;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport clampIndex from './../../../base/clamp-index';\nimport wrapIndex from './../../../base/wrap-index';\nimport normalize from './../../../base/normalize-index';\nimport isIndexMode from './../../../base/assert/is-index-mode';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar TABLE = {\n\t'wrap': wrapIndex,\n\t'clamp': clampIndex,\n\t'normalize': normalizeIndex,\n\t'throw': throwIfOutOfBounds\n};\n\n\n// FUNCTIONS //\n\n/**\n* Returns an index if within bounds and throw an error otherwise.\n*\n* @private\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @throws {RangeError} index out-of-bounds\n* @returns {integer} index\n*\n* @example\n* var idx = throwIfOutOfBounds( 2, 9 );\n* // returns 2\n*\n* idx = throwIfOutOfBounds( 10, 9 );\n* // throws \n*\n* idx = throwIfOutOfBounds( -1, 9 );\n* // throws \n*/\nfunction throwIfOutOfBounds( idx, max ) {\n\tif ( idx < 0 || idx > max ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.', max, idx ) );\n\t}\n\treturn idx;\n}\n\n/**\n* Normalizes an index before performing a strict bounds check.\n*\n* @private\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @throws {RangeError} index out-of-bounds\n* @returns {integer} index\n*\n* @example\n* var idx = normalizeIndex( 1, 10 );\n* // returns 1\n*\n* idx = normalizeIndex( -4, 10 );\n* // returns 7\n*\n* idx = normalizeIndex( -100, 10 );\n* // throws \n*/\nfunction normalizeIndex( idx, max ) {\n\tvar index = normalize( idx, max );\n\tif ( index < 0 || index > max ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.', max, idx ) );\n\t}\n\treturn index;\n}\n\n\n// MAIN //\n\n/**\n* Returns a function for returning an index according to a provided index mode.\n*\n* @param {string} mode - specifies how to handle an out-of-bounds index\n* @throws {TypeError} first argument must be a recognized index mode\n* @returns {Function} function for returning an index\n*\n* @example\n* var ind = factory( 'clamp' );\n*\n* var idx = ind( 2, 9 );\n* // returns 2\n*\n* idx = ind( 10, 9 );\n* // returns 9\n*\n* idx = ind( -1, 9 );\n* // returns 0\n*\n* @example\n* var ind = factory( 'wrap' );\n*\n* var idx = ind( 2, 9 );\n* // returns 2\n*\n* idx = ind( 10, 9 );\n* // returns 0\n*\n* idx = ind( -1, 9 );\n* // returns 9\n*\n* @example\n* var ind = factory( 'throw' );\n*\n* var idx = ind( 2, 9 );\n* // returns 2\n*\n* idx = ind( 10, 9 );\n* // throws \n*\n* idx = ind( -1, 9 );\n* // throws \n*\n* @example\n* var ind = factory( 'normalize' );\n*\n* var idx = ind( 1, 10 );\n* // returns 1\n*\n* idx = ind( -4, 10 );\n* // returns 7\n*\n* idx = ind( -100, 10 );\n* // throws \n*/\nfunction factory( mode ) {\n\tif ( !isIndexMode( mode ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a recognized index mode. Value: `%s`.', mode ) );\n\t}\n\treturn TABLE[ mode ];\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpretComplex from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport { factory as ind } from '@stdlib/ndarray/base/ind';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Replaces elements in an indexed array with provided values.\n*\n* @private\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {Collection} values - values to set\n* @param {NonNegativeInteger} stride - index stride for accessing elements in `values`\n* @param {Function} getIndex - function for resolving an array index\n* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive)\n* @returns {Collection} input array\n*\n* @example\n* import { factory as ind } from '@stdlib/ndarray/base/ind';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 3, 1, 2, 0 ];\n* var values = [ 5, 6, 7, 8 ];\n*\n* var getIndex = ind( 'throw' );\n*\n* var out = indexed( x, indices, values, 1, getIndex, x.length-1 );\n* // returns [ 8, 6, 7, 5 ]\n*/\nfunction indexed( x, indices, values, stride, getIndex, maxIndex ) {\n\tvar iv;\n\tvar i;\n\tvar j;\n\n\tiv = 0;\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\tj = getIndex( indices[ i ], maxIndex );\n\t\tx[ j ] = values[ iv ];\n\t\tiv += stride;\n\t}\n\treturn x;\n}\n\n/**\n* Replaces specified elements of an accessor array with provided values.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} indices - index object\n* @param {Object} values - values object\n* @param {NonNegativeInteger} stride - index stride for accessing elements in `values`\n* @param {Function} getIndex - function for resolving an array index\n* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive)\n* @returns {Collection} input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import { factory as ind } from '@stdlib/ndarray/base/ind';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var indices = toAccessorArray( [ 1, 2 ] );\n* var values = toAccessorArray( [ 20, 30 ] );\n*\n* var getIndex = ind( 'throw' );\n*\n* var out = accessors( arraylike2object( x ), arraylike2object( indices ), arraylike2object( values ), 1, getIndex, x.length-1 );\n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* v = x.get( 1 );\n* // returns 20\n*/\nfunction accessors( x, indices, values, stride, getIndex, maxIndex ) {\n\tvar xdata;\n\tvar idata;\n\tvar vdata;\n\tvar xset;\n\tvar iget;\n\tvar vget;\n\tvar iv;\n\tvar i;\n\tvar j;\n\n\txdata = x.data;\n\tidata = indices.data;\n\tvdata = values.data;\n\n\txset = x.accessors[ 1 ];\n\tiget = indices.accessors[ 0 ];\n\tvget = values.accessors[ 0 ];\n\n\tiv = 0;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), maxIndex );\n\t\txset( xdata, j, vget( vdata, iv ) );\n\t\tiv += stride;\n\t}\n\treturn xdata;\n}\n\n/**\n* Replaces elements in a complex array with provided values.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} indices - index array object\n* @param {Collection} values - real-valued floating-point values array view\n* @param {NonNegativeInteger} stride - index stride for accessing elements in `values`\n* @param {Function} getIndex - function for resolving an array index\n* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive)\n* @returns {Collection} input array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import { factory as ind } from '@stdlib/ndarray/base/ind';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n*\n* var indices = [ 0, 2 ];\n* var values = new Float64Array( [ 10.0, 20.0, 50.0, 60.0 ] );\n*\n* var getIndex = ind( 'throw' );\n*\n* var out = complex( x, arraylike2object( indices ), values, 1, getIndex, x.length-1 );\n* // returns [ 10.0, 20.0, 3.0, 4.0, 50.0, 60.0, 7.0, 8.0 ]\n*/\nfunction complex( x, indices, values, stride, getIndex, maxIndex ) {\n\tvar idata;\n\tvar iget;\n\tvar iv;\n\tvar sv;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tidata = indices.data;\n\tiget = indices.accessors[ 0 ];\n\n\tsv = stride * 2; // note: multiply by 2, as real-valued values array consists of interleaved real and imaginary components\n\tiv = 0;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), maxIndex );\n\t\tk = j * 2;\n\t\tx[ k ] = values[ iv ];\n\t\tx[ k+1 ] = values[ iv+1 ];\n\t\tiv += sv;\n\t}\n\treturn x;\n}\n\n/**\n* Replaces elements in a boolean array with provided values.\n*\n* @private\n* @param {Uint8Array} x - input array\n* @param {Object} indices - index array object\n* @param {Uint8Array} values - values to set\n* @param {NonNegativeInteger} stride - index stride for accessing elements in `values`\n* @param {Function} getIndex - function for resolving an array index\n* @param {NonNegativeInteger} maxIndex - maximum array index (inclusive)\n* @returns {Uint8Array} input array\n*\n* @example\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n* import Uint8Array from '@stdlib/array/uint8';\n* import { factory as ind } from '@stdlib/ndarray/base/ind';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n*\n* var indices = [ 3, 1, 2, 0 ];\n* var values = new Uint8Array( [ 0, 1, 1, 0 ] );\n*\n* var getIndex = ind( 'throw' );\n*\n* var out = boolean( x, arraylike2object( indices ), values, 1, getIndex, x.length-1 );\n* // returns [ 0, 1, 1, 0 ]\n*/\nfunction boolean( x, indices, values, stride, getIndex, maxIndex ) {\n\tvar idata;\n\tvar iget;\n\tvar iv;\n\tvar i;\n\tvar j;\n\n\tidata = indices.data;\n\tiget = indices.accessors[ 0 ];\n\n\tiv = 0;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), maxIndex );\n\t\tx[ j ] = values[ iv ];\n\t\tiv += stride;\n\t}\n\treturn x;\n}\n\n\n// MAIN //\n\n/**\n* Replaces specified elements of an array with provided values.\n*\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {Collection} values - values to set\n* @param {string} mode - index mode\n* @throws {Error} third argument must be broadcast compatible with the second argument\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 1, 2 ];\n* var values = [ 20, 30 ];\n*\n* var out = put( x, indices, values, 'throw' );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 1, 2 ];\n* var values = [ 30 ];\n*\n* var out = put( x, indices, values, 'throw' );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction put( x, indices, values, mode ) {\n\tvar getIndex;\n\tvar stride;\n\tvar max;\n\tvar xo;\n\tvar io;\n\tvar vo;\n\n\t// Broadcast the `values` array...\n\tif ( indices.length > 0 ) { // note: this allows `indices` to be empty and `values` to be non-empty (and not broadcast compatible with `indices`) to allow the potential use case where having an empty `indices` array is expected behavior and you don't want to trigger an exception simply because `values` has elements\n\t\t// Note that this effectively in-lines logic from `@stdlib/array/base/broadcast-array` in order to avoid unnecessary object creation...\n\t\tif ( values.length === indices.length ) {\n\t\t\tstride = 1;\n\t\t} else if ( values.length === 1 ) {\n\t\t\tstride = 0;\n\t\t} else {\n\t\t\tthrow new Error( format( 'invalid argument. The third argument must be broadcast compatible with the second argument. Array shape: (%d). Desired shape: (%d).', values.length, indices.length ) );\n\t\t}\n\t}\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = x.length - 1;\n\n\txo = arraylike2object( x );\n\tio = arraylike2object( indices );\n\tvo = arraylike2object( values );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tio.accessorProtocol ||\n\t\tvo.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support select dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif ( isComplexDataType( xo.dtype ) && isComplexDataType( vo.dtype ) ) {\n\t\t\tcomplex( reinterpretComplex( x, 0 ), io, reinterpretComplex( values, 0 ), stride, getIndex, max ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\tif ( isBooleanDataType( xo.dtype ) && isBooleanDataType( vo.dtype ) ) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), io, reinterpretBoolean( values, 0 ), stride, getIndex, max ); // eslint-disable-line max-len\n\t\t\treturn x;\n\t\t}\n\t\taccessors( xo, io, vo, stride, getIndex, max );\n\t\treturn x;\n\t}\n\tindexed( x, indices, values, stride, getIndex, max );\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default put;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return an index given an index mode.\n*\n* @module @stdlib/ndarray/base/ind\n*\n* @example\n* import ind from '@stdlib/ndarray/base/ind';\n*\n* var idx = ind( -1, 10, 'wrap' );\n* // returns 10\n*\n* idx = ind( 14, 10, 'wrap' );\n* // returns 3\n*\n* idx = ind( 6, 10, 'wrap' );\n* // returns 6\n*\n* @example\n* import ind from '@stdlib/ndarray/base/ind';\n*\n* var idx = ind( -1, 10, 'clamp' );\n* // returns 0\n*\n* idx = ind( 14, 10, 'clamp' );\n* // returns 10\n*\n* idx = ind( 6, 10, 'clamp' );\n* // returns 6\n*\n* @example\n* import ind from '@stdlib/ndarray/base/ind';\n*\n* var idx = ind( 1, 10, 'throw' );\n* // returns 1\n*\n* idx = ind( 14, 10, 'throw' );\n* // throws \n*\n* idx = ind( -1, 10, 'throw' );\n* // throws \n*\n* @example\n* import ind from '@stdlib/ndarray/base/ind';\n*\n* var idx = ind( 1, 10, 'normalize' );\n* // returns 1\n*\n* idx = ind( -4, 10, 'normalize' );\n* // returns 7\n*\n* idx = ind( -100, 10, 'normalize' );\n* // throws \n*\n* @example\n* import ind from '@stdlib/ndarray/base/ind';\n*\n* var fcn = ind.factory( 'clamp' );\n*\n* var idx = fcn( -1, 10 );\n* // returns 0\n*\n* idx = fcn( 14, 10 );\n* // returns 10\n*\n* idx = fcn( 6, 10 );\n* // returns 6\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport factory from './factory.js';\nimport main from './main.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport clampIndex from './../../../base/clamp-index';\nimport wrapIndex from './../../../base/wrap-index';\nimport normalizeIndex from './../../../base/normalize-index';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an index given an index mode.\n*\n* @param {integer} idx - index\n* @param {NonNegativeInteger} max - maximum index\n* @param {string} mode - specifies how to handle an index outside the interval `[0,max]`\n* @throws {RangeError} index out-of-bounds\n* @returns {integer} index\n*\n* @example\n* var idx = ind( 2, 9, 'clamp' );\n* // returns 2\n*\n* idx = ind( 10, 9, 'clamp' );\n* // returns 9\n*\n* idx = ind( -1, 9, 'clamp' );\n* // returns 0\n*\n* @example\n* var idx = ind( 2, 9, 'wrap' );\n* // returns 2\n*\n* idx = ind( 10, 9, 'wrap' );\n* // returns 0\n*\n* idx = ind( -1, 9, 'wrap' );\n* // returns 9\n*\n* @example\n* var idx = ind( 2, 9, 'throw' );\n* // returns 2\n*\n* idx = ind( 10, 9, 'throw' );\n* // throws \n*\n* idx = ind( -1, 9, 'throw' );\n* // throws \n*\n* @example\n* var idx = ind( 1, 10, 'normalize' );\n* // returns 1\n*\n* idx = ind( -4, 10, 'normalize' );\n* // returns 7\n*\n* idx = ind( -100, 10, 'normalize' );\n* // throws \n*/\nfunction ind( idx, max, mode ) {\n\tvar index;\n\tif ( mode === 'clamp' ) {\n\t\treturn clampIndex( idx, max );\n\t}\n\tif ( mode === 'wrap' ) {\n\t\treturn wrapIndex( idx, max );\n\t}\n\tindex = idx;\n\tif ( mode === 'normalize' ) {\n\t\tindex = normalizeIndex( index, max );\n\t}\n\tif ( index < 0 || index > max ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.', max, idx ) );\n\t}\n\treturn index;\n}\n\n\n// EXPORTS //\n\nexport default ind;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// VARIABLES //\n\nvar arraySlice = Array.prototype.slice;\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'slice' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns a shallow copy of a portion of an array using the `Array#slice` built-in.\n*\n* @private\n* @param {Collection} x - input array\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = builtin( x, 1, 3 );\n* // returns [ 2, 3 ]\n*/\nfunction builtin( x, start, end ) {\n\treturn arraySlice.call( x, start, end );\n}\n\n/**\n* Returns a shallow copy of a portion of an accessor array.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {Array} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) );\n*\n* var out = accessors( x, 1, 3 );\n* // returns [ 2, 3 ]\n*/\nfunction accessors( x, start, end ) {\n\tvar data;\n\tvar get;\n\tvar out;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\tout = [];\n\tfor ( i = start; i < end; i++ ) {\n\t\tout.push( get( data, i ) );\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a shallow copy of a portion of an array.\n*\n* @param {Collection} x - input array\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = slice( x, 1, 3 );\n* // returns [ 2, 3 ]\n*\n* var bool = ( out === x );\n* // returns false\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var out = slice( x, 1, 3 );\n* // returns [ 2, 3 ]\n*\n* var bool = ( out === x );\n* // returns false\n*/\nfunction slice( x, start, end ) {\n\tvar obj;\n\tif ( hasMethod( x, 'slice' ) ) {\n\t\treturn x.slice( start, end );\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, start, end );\n\t}\n\t// Assume we can use the built-in `Array#slice` method to copy elements to a generic array:\n\treturn builtin( x, start, end );\n}\n\n\n// EXPORTS //\n\nexport default slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport flatten from './../../../base/flatten';\nimport slice from './../../../base/slice';\n\n\n// FUNCTIONS //\n\n/**\n* Recursive reshapes an array.\n*\n* @private\n* @param {Array} array - input n-dimensional nested array\n* @param {NonNegativeInteger} ndims - number of dimensions\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} dim - dimension index\n* @param {NonNegativeInteger} index - sub-array index\n* @returns {Array} output m-dimensional nested array\n*/\nfunction recurse( array, ndims, shape, dim, index ) {\n\tvar stepSize;\n\tvar subArray;\n\tvar out;\n\tvar d;\n\tvar S;\n\tvar i;\n\n\tS = shape[ dim ];\n\tif ( dim === ndims - 1 ) {\n\t\treturn slice( array, index, index + S );\n\t}\n\n\td = dim + 1;\n\tstepSize = 1;\n\tfor ( i = d; i < shape.length; i++ ) {\n\t\tstepSize *= shape[ i ];\n\t}\n\n\tout = [];\n\tfor ( i = 0; i < S; i++ ) {\n\t\tsubArray = recurse( array, ndims, shape, d, index );\n\t\tout.push( subArray );\n\t\tindex += stepSize;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Reshape a nested array into another nested array having a desired shape.\n*\n* @param {Array} x - input nested array\n* @param {NonNegativeIntegerArray} fromShape - shape of the input array\n* @param {NonNegativeIntegerArray} toShape - shape of the output array\n* @param {boolean} colexicographic - specifies whether to reshape the array in colexicographic order\n* @returns {Array} output nested array\n*\n* @example\n* var x = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ];\n*\n* var out = reshape( x, [ 2, 3 ], [ 3, 2 ], false );\n* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]\n*/\nfunction reshape( x, fromShape, toShape, colexicographic ) {\n\tvar f = flatten( x, fromShape, colexicographic );\n\treturn recurse( f, toShape.length, toShape, 0, 0 );\n}\n\n\n// EXPORTS //\n\nexport default reshape;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport accessorSetter from './../../../base/accessor-setter';\nimport setter from './../../../base/setter';\nimport dtype from './../../../dtype';\n\n\n// MAIN //\n\n/**\n* Returns an accessor function for setting an element in an array-like object.\n*\n* @param {Collection} x - input array\n* @returns {Function} accessor\n*\n* @example\n* import resolveGetter from '@stdlib/array/base/resolve-getter';\n*\n* var arr = [ 1, 2, 3, 4 ];\n*\n* var set = resolveSetter( arr );\n* // returns \n*\n* set( arr, 2, 10 );\n*\n* var get = resolveGetter( arr );\n* // returns \n*\n* var v = get( arr, 2 );\n* // returns 10\n*/\nfunction resolveSetter( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessorSetter( dt );\n\t}\n\treturn setter( dt );\n}\n\n\n// EXPORTS //\n\nexport default resolveSetter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/*\n* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name filled2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/symmetric/filled2d-by}\n*/\nimport filled2dBy from './../../../base/symmetric/filled2d-by';\nsetReadOnly( ns, 'filled2dBy', filled2dBy );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional symmetric nested array according to a provided callback function.\n*\n* @param {NonNegativeInteger} N - number of rows and columns\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( 3, clbk );\n* // returns [ [ 0, 1, 2 ], [ 1, 2, 3 ], [ 2, 3, 4 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( 4, clbk );\n* // returns [ [ 0, 1, 2, 3 ], [ 1, 2, 3, 4 ], [ 2, 3, 4, 5 ], [ 3, 4, 5, 6 ] ]\n*/\nfunction filled2dBy( N, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar i;\n\tvar j;\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\ta0 = [];\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tif ( i > j ) {\n\t\t\t\ta0.push( arr[ j ][ i ] );\n\t\t\t} else {\n\t\t\t\ta0.push( clbk.call( thisArg, [ i, j ] ) );\n\t\t\t}\n\t\t}\n\t\tarr.push( a0 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/*\n* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name filled2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/symmetric-banded/filled2d-by}\n*/\nimport filled2dBy from './../../../base/symmetric-banded/filled2d-by';\nsetReadOnly( ns, 'filled2dBy', filled2dBy );\n\n/**\n* @name toCompact\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/symmetric-banded/to-compact}\n*/\nimport toCompact from './../../../base/symmetric-banded/to-compact';\nsetReadOnly( ns, 'toCompact', toCompact );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport { factory as ind } from '@stdlib/ndarray/base/ind';\n\n\n// MAIN //\n\n/**\n* Takes elements from an array.\n*\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {string} mode - index mode\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var y = take( x, indices, 'throw' );\n* // returns [ 4, 2, 3, 1 ]\n*/\nfunction take( x, indices, mode ) {\n\tvar getIndex;\n\tvar xget;\n\tvar iget;\n\tvar out;\n\tvar max;\n\tvar i;\n\tvar j;\n\n\t// Resolve an accessor for retrieving array elements:\n\txget = resolveGetter( x );\n\tiget = resolveGetter( indices );\n\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = x.length - 1;\n\n\t// Extract each desired element from the provided array...\n\tout = [];\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\tj = getIndex( iget( indices, i ), max );\n\t\tout.push( xget( x, j ) ); // use `Array#push` to ensure \"fast\" elements\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default take;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional symmetric banded nested array according to a provided callback function.\n*\n* @param {NonNegativeInteger} N - number of rows and columns\n* @param {NonNegativeInteger} k - number of super-/sub-diagonals\n* @param {*} fill - fill value for values outside the band\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( 3, 1, 0, clbk );\n* // returns [ [ 0, 1, 0 ], [ 1, 2, 3 ], [ 0, 3, 4 ] ]\n*\n* @example\n* function clbk( indices ) {\n* return indices[ 0 ] + indices[ 1 ];\n* }\n*\n* var out = filled2dBy( 4, 1, 0, clbk );\n* // returns [ [ 0, 1, 0, 0 ], [ 1, 2, 3, 0 ], [ 0, 3, 4, 5 ], [ 0, 0, 5, 6 ] ]\n*/\nfunction filled2dBy( N, k, fill, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar i;\n\tvar j;\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\ta0 = [];\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\t// Check whether we are within the band in the upper triangle...\n\t\t\tif ( j >= i && j <= i+k ) {\n\t\t\t\ta0.push( clbk.call( thisArg, [ i, j ] ) );\n\t\t\t}\n\t\t\t// Check whether we can take advantage of symmetry...\n\t\t\telse if ( j < i ) {\n\t\t\t\ta0.push( arr[ j ][ i ] );\n\t\t\t}\n\t\t\t// Otherwise, we are outside the band in the upper triangle...\n\t\t\telse {\n\t\t\t\ta0.push( fill );\n\t\t\t}\n\t\t}\n\t\tarr.push( a0 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport max from '@stdlib/math/base/special/fast/max';\nimport min from '@stdlib/math/base/special/fast/min';\nimport zeros2d from './../../../../base/zeros2d';\n\n\n// MAIN //\n\n/**\n* Converts a two-dimensional symmetric banded nested array to compact banded storage.\n*\n* @param {string} uplo - specifies whether to reference the upper or lower triangular part of the input array\n* @param {Array} arr - input two-dimensional array\n* @param {NonNegativeInteger} k - number of super-/sub-diagonals\n* @param {boolean} colexicographic - specifies whether to store diagonals in colexicographic access order\n* @returns {Array} output array\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 2, 12, 4 ],\n* [ 0, 4, 13 ]\n* ];\n*\n* var out = toCompact( 'upper', M, 1, false );\n* // returns [ [ 0, 2, 4 ], [ 11, 12, 13 ] ]\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 2, 12, 4 ],\n* [ 0, 4, 13 ]\n* ];\n*\n* var out = toCompact( 'lower', M, 1, false );\n* // returns [ [ 11, 12, 13 ], [ 2, 4, 0 ] ]\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 2, 12, 4 ],\n* [ 0, 4, 13 ]\n* ];\n*\n* var out = toCompact( 'upper', M, 1, true );\n* // returns [ [ 11, 2 ], [ 12, 4 ], [ 13, 0 ] ]\n*\n* @example\n* var M = [\n* [ 11, 2, 0 ],\n* [ 2, 12, 4 ],\n* [ 0, 4, 13 ]\n* ];\n*\n* var out = toCompact( 'lower', M, 1, true );\n* // returns [ [ 0, 11 ], [ 2, 12 ], [ 4, 13 ] ]\n*/\nfunction toCompact( uplo, arr, k, colexicographic ) {\n\tvar out;\n\tvar to;\n\tvar ta;\n\tvar m;\n\tvar i;\n\tvar j;\n\tvar o;\n\n\tm = arr.length;\n\n\t// Check whether to store diagonals along the columns...\n\tif ( colexicographic ) {\n\t\tout = zeros2d( [ m, k+1 ] );\n\t\tif ( uplo === 'upper' ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\tto = out[ i ];\n\t\t\t\tta = arr[ i ];\n\t\t\t\tfor ( j = i; j < min( m, i+k+1 ); j++ ) {\n\t\t\t\t\tto[ j-i ] = ta[ j ];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\t// uplo === 'lower'\n\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\tto = out[ i ];\n\t\t\tta = arr[ i ];\n\t\t\to = max( 0, k-i );\n\t\t\tfor ( j = max( 0, i-k ); j <= i; j++ ) {\n\t\t\t\tto[ o ] = ta[ j ];\n\t\t\t\to += 1;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\t// Store diagonals along the rows...\n\tout = zeros2d( [ k+1, m ] );\n\tif ( uplo === 'upper' ) {\n\t\tfor ( j = 0; j < m; j++ ) {\n\t\t\to = k - j;\n\t\t\tfor ( i = max( 0, j-k ); i <= j; i++ ) {\n\t\t\t\tout[ o+i ][ j ] = arr[ i ][ j ];\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\t// uplo === 'lower'\n\tfor ( j = 0; j < m; j++ ) {\n\t\to = -j;\n\t\tfor ( i = j; i < min( m, j+k+1 ); i++ ) {\n\t\t\tout[ o+i ][ j ] = arr[ i ][ j ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default toCompact;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Take elements from an array.\n*\n* @module @stdlib/array/base/take\n*\n* @example\n* import take from '@stdlib/array/base/take';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 0, 0, 1, 1, 3, 3 ];\n* var y = take( x, indices, 'throw' );\n* // returns [ 1, 1, 2, 2, 4, 4 ]\n*\n* @example\n* import take from '@stdlib/array/base/take';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0, 0, 0, 0 ];\n* var indices = [ 0, 0, 1, 1, 3, 3 ];\n*\n* var arr = take.assign( x, indices, 'throw', out, 1, 0 );\n* // returns [ 1, 1, 2, 2, 4, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport { factory as ind } from '@stdlib/ndarray/base/ind';\n\n\n// FUNCTIONS //\n\n/**\n* Takes elements from an indexed array and assigns the values to elements in an indexed output array.\n*\n* @private\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {string} mode - index mode\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n*\n* var arr = indexed( x, indices, 'throw', out, 1, 0 );\n* // returns [ 4, 2, 3, 1 ]\n*/\nfunction indexed( x, indices, mode, out, stride, offset ) {\n\tvar getIndex;\n\tvar max;\n\tvar io;\n\tvar i;\n\tvar j;\n\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = x.length - 1;\n\n\t// Extract each desired element from the provided array...\n\tio = offset;\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\tj = getIndex( indices[ i ], max );\n\t\tout[ io ] = x[ j ];\n\t\tio += stride;\n\t}\n\treturn out;\n}\n\n/**\n* Takes elements from an accessor array and assigns the values to elements in an accessor output array.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} indices - index array object\n* @param {string} mode - index mode\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var indices = toAccessorArray( [ 3, 1, 2, 0 ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), arraylike2object( indices ), 'throw', arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 4\n*/\nfunction accessors( x, indices, mode, out, stride, offset ) {\n\tvar getIndex;\n\tvar xdata;\n\tvar idata;\n\tvar odata;\n\tvar xget;\n\tvar iget;\n\tvar oset;\n\tvar max;\n\tvar io;\n\tvar i;\n\tvar j;\n\n\txdata = x.data;\n\tidata = indices.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\tiget = indices.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = xdata.length - 1;\n\n\t// Extract each desired element from the provided array...\n\tio = offset;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), max );\n\t\toset( odata, io, xget( xdata, j ) );\n\t\tio += stride;\n\t}\n\treturn odata;\n}\n\n/**\n* Takes elements from a complex array and assigns the values to elements in a complex output array.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {Object} indices - index array object\n* @param {string} mode - index mode\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n* var indices = [ 0, 0, 1, 1 ];\n*\n* var out = new Float64Array( 8 );\n*\n* var arr = complex( x, arraylike2object( indices ), 'throw', out, 1, 0 );\n* // returns [ 1.0, 2.0, 1.0, 2.0, 3.0, 4.0, 3.0, 4.0 ]\n*/\nfunction complex( x, indices, mode, out, stride, offset ) {\n\tvar getIndex;\n\tvar idata;\n\tvar iget;\n\tvar max;\n\tvar io;\n\tvar so;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tidata = indices.data;\n\tiget = indices.accessors[ 0 ];\n\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = ( x.length/2 ) - 1; // resolve the length of the original complex array\n\n\t// Extract each desired element from the provided array...\n\tso = stride * 2; // note: multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), max );\n\t\tk = j * 2;\n\t\tout[ io ] = x[ k ];\n\t\tout[ io+1 ] = x[ k+1 ];\n\t\tio += so;\n\t}\n\treturn out;\n}\n\n/**\n* Takes elements from a boolean array and assigns the values to elements in a boolean output array.\n*\n* @private\n* @param {Collection} x - boolean value input array view\n* @param {Object} indices - index array object\n* @param {string} mode - index mode\n* @param {Collection} out - boolean value output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Uint8Array( [ 1, 0, 0, 1 ] );\n* var indices = [ 0, 0, 1, 1 ];\n*\n* var out = new Uint8Array( 4 );\n*\n* var arr = boolean( x, arraylike2object( indices ), 'throw', out, 1, 0 );\n* // returns [ 1, 1, 0, 0 ]\n*/\nfunction boolean( x, indices, mode, out, stride, offset ) {\n\tvar getIndex;\n\tvar idata;\n\tvar iget;\n\tvar max;\n\tvar io;\n\tvar i;\n\tvar j;\n\n\tidata = indices.data;\n\tiget = indices.accessors[ 0 ];\n\n\t// Resolve a function for returning an index according to the specified index mode:\n\tgetIndex = ind( mode );\n\n\t// Resolve the maximum index:\n\tmax = x.length - 1;\n\n\t// Extract each desired element from the provided array...\n\tio = offset;\n\tfor ( i = 0; i < idata.length; i++ ) {\n\t\tj = getIndex( iget( idata, i ), max );\n\t\tout[ io ] = x[ j ];\n\t\tio += stride;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Takes elements from an array and assigns the values to elements in a provided output array.\n*\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {string} mode - index mode\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var arr = assign( x, indices, 'throw', out, 1, 0 );\n* // returns [ 4, 2, 3, 1 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, indices, mode, out, stride, offset ) {\n\tvar xo;\n\tvar io;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\tio = arraylike2object( indices );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\tio.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), io, mode, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tboolean( reinterpretBoolean( x, 0 ), io, mode, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, io, mode, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, indices, mode, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport { factory as indexFunction } from '@stdlib/ndarray/base/ind';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar NDIMS = 2;\n\n\n// MAIN //\n\n/**\n* Takes elements from a two-dimensional nested array.\n*\n* ## Notes\n*\n* - The function does **not** deep copy nested array elements.\n*\n* @param {ArrayLikeObject} x - input array\n* @param {NonNegativeIntegerArray} indices - list of indices\n* @param {integer} dimension - dimension along which to take elements\n* @param {string} mode - index mode specifying how to handle an index which is out-of-bounds\n* @throws {RangeError} third argument exceeds the number of dimensions\n* @throws {TypeError} fourth argument must be a recognized index mode\n* @returns {(Array|Array)} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var indices = [ 1, 1, 0, 0, -1, -1 ];\n*\n* var y = take2d( x, indices, 1, 'normalize' );\n* // returns [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ]\n*/\nfunction take2d( x, indices, dimension, mode ) {\n\tvar lastIndex;\n\tvar out;\n\tvar dim;\n\tvar ind;\n\tvar idx;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\n\tdim = normalizeIndex( dimension, NDIMS-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Third argument exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', NDIMS, dimension ) );\n\t}\n\tind = indexFunction( mode );\n\tout = [];\n\tif ( dim === 0 ) {\n\t\tlastIndex = x.length - 1;\n\t\tfor ( i1 = 0; i1 < indices.length; i1++ ) {\n\t\t\tidx = ind( indices[ i1 ], lastIndex );\n\t\t\tout.push( x[ idx ] );\n\t\t}\n\t\treturn out;\n\t}\n\t// Case: dim === 1\n\tfor ( i1 = 0; i1 < x.length; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = [];\n\t\tlastIndex = x0.length - 1;\n\t\tfor ( i0 = 0; i0 < indices.length; i0++ ) {\n\t\t\tidx = ind( indices[ i0 ], lastIndex );\n\t\t\ty0.push( x0[ idx ] );\n\t\t}\n\t\tout.push( y0 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default take2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Recursively applies a unary callback.\n*\n* @private\n* @param {ArrayLikeObject} x - input array\n* @param {ArrayLikeObject} y - output array\n* @param {NonNegativeInteger} ndims - number of dimensions\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {NonNegativeInteger} dim - dimension index\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*/\nfunction recurse( x, y, ndims, shape, dim, fcn ) {\n\tvar S;\n\tvar d;\n\tvar i;\n\n\tS = shape[ dim ];\n\n\t// Check whether we've reached the innermost dimension:\n\td = dim + 1;\n\n\tif ( d === ndims ) {\n\t\t// Apply the provided callback...\n\t\tfor ( i = 0; i < S; i++ ) {\n\t\t\ty[ i ] = fcn( x[ i ] );\n\t\t}\n\t\treturn;\n\t}\n\t// Continue recursing into the nested arrays...\n\tfor ( i = 0; i < S; i++ ) {\n\t\trecurse( x[ i ], y[ i ], ndims, shape, d, fcn );\n\t}\n}\n\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in an n-dimensional nested input array and assigns results to elements in an n-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import onesnd from '@stdlib/array/base/onesnd';\n* import zerosnd from '@stdlib/array/base/zerosnd';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = onesnd( shape );\n* var y = zerosnd( shape );\n*\n* unarynd( [ x, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*/\nfunction unarynd( arrays, shape, fcn ) {\n\treturn recurse( arrays[ 0 ], arrays[ 1 ], shape.length, shape, 0, fcn );\n}\n\n\n// EXPORTS //\n\nexport default unarynd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport PINF from '@stdlib/constants/float64/pinf';\n\n\n// MAIN //\n\n/**\n* Tests if a double-precision floating-point numeric value is positive zero.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is positive zero\n*\n* @example\n* var bool = isPositiveZero( 0.0 );\n* // returns true\n*\n* @example\n* var bool = isPositiveZero( -0.0 );\n* // returns false\n*/\nfunction isPositiveZero( x ) {\n\treturn (x === 0.0 && 1.0/x === PINF);\n}\n\n\n// EXPORTS //\n\nexport default isPositiveZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Resolves a stride length for broadcasting a one-dimensional array.\n*\n* @private\n* @param {NonNegativeInteger} M - input array length\n* @param {NonNegativeInteger} N - output array length\n* @throws {Error} input arrays must be broadcast compatible\n* @returns {NonNegativeInteger} stride length\n*/\nfunction resolveStride( M, N ) {\n\t// Note that this effectively in-lines logic from `@stdlib/array/base/broadcast-array` in order to avoid unnecessary object creation...\n\tif ( M === 1 ) {\n\t\treturn 0;\n\t}\n\tif ( M === N ) {\n\t\treturn 1;\n\t}\n\tthrow new Error( 'invalid arguments. Input arguments are not broadcast compatible.' );\n}\n\n\n// EXPORTS //\n\nexport default resolveStride;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport maxn from '@stdlib/math/base/special/maxn';\nimport resolveStride from './resolve_stride.js';\n\n\n// MAIN //\n\n/**\n* Takes elements from either one of two arrays depending on a condition.\n*\n* @param {Collection} condition - indicator array\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @throws {Error} input arrays must be broadcast compatible\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n*\n* var condition = [ true, false, true, false ];\n*\n* var z = where( condition, x, y );\n* // returns [ 1, 6, 3, 8 ]\n*/\nfunction where( condition, x, y ) {\n\tvar xget;\n\tvar yget;\n\tvar cget;\n\tvar lens;\n\tvar out;\n\tvar sx;\n\tvar sy;\n\tvar sc;\n\tvar ix;\n\tvar iy;\n\tvar ic;\n\tvar N;\n\tvar v;\n\tvar i;\n\n\t// Cache the lengths of the input arrays:\n\tlens = [ condition.length, x.length, y.length ];\n\n\t// Check whether we can avoid doing any further work...\n\tif ( lens[ 0 ] === 0 ) {\n\t\t// E.g., `where( [], [ 1, 2 ], [ 3, 4 ] )`\n\t\treturn [];\n\t}\n\t// Compute the output array length:\n\tN = maxn( lens[ 0 ], lens[ 1 ], lens[ 2 ] );\n\n\t// Broadcast the arrays by computing strides:\n\tsc = resolveStride( lens[ 0 ], N );\n\tsx = resolveStride( lens[ 1 ], N );\n\tsy = resolveStride( lens[ 2 ], N );\n\n\t// Resolve accessors for retrieving array elements:\n\tcget = resolveGetter( condition );\n\txget = resolveGetter( x );\n\tyget = resolveGetter( y );\n\n\t// Initialize indices:\n\tic = 0;\n\tix = 0;\n\tiy = 0;\n\n\t// Extract each desired element from a provided array...\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( cget( condition, ic ) ) {\n\t\t\tv = xget( x, ix );\n\t\t} else {\n\t\t\tv = yget( y, iy );\n\t\t}\n\t\tout.push( v ); // use `Array#push` to ensure \"fast\" elements\n\t\tic += sc;\n\t\tix += sx;\n\t\tiy += sy;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default where;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isPositiveZero from './../../../../base/assert/is-positive-zero';\nimport isnan from './../../../../base/assert/is-nan';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport PINF from '@stdlib/constants/float64/pinf';\n\n\n// MAIN //\n\n/**\n* Returns the maximum value.\n*\n* @param {number} [x] - first number\n* @param {number} [y] - second number\n* @param {...number} [args] - numbers\n* @returns {number} maximum value\n*\n* @example\n* var v = maxn( 3.14, 4.2 );\n* // returns 4.2\n*\n* @example\n* var v = maxn( 5.9, 3.14, 4.2 );\n* // returns 5.9\n*\n* @example\n* var v = maxn( 3.14, NaN );\n* // returns NaN\n*\n* @example\n* var v = maxn( +0.0, -0.0 );\n* // returns +0.0\n*/\nfunction maxn( x, y ) {\n\tvar len;\n\tvar m;\n\tvar v;\n\tvar i;\n\n\tlen = arguments.length;\n\tif ( len === 2 ) {\n\t\tif ( isnan( x ) || isnan( y ) ) {\n\t\t\treturn NaN;\n\t\t}\n\t\tif ( x === PINF || y === PINF ) {\n\t\t\treturn PINF;\n\t\t}\n\t\tif ( x === y && x === 0.0 ) {\n\t\t\tif ( isPositiveZero( x ) ) {\n\t\t\t\treturn x;\n\t\t\t}\n\t\t\treturn y;\n\t\t}\n\t\tif ( x > y ) {\n\t\t\treturn x;\n\t\t}\n\t\treturn y;\n\t}\n\tm = NINF;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = arguments[ i ];\n\t\tif ( isnan( v ) || v === PINF ) {\n\t\t\treturn v;\n\t\t}\n\t\tif ( v > m ) {\n\t\t\tm = v;\n\t\t} else if (\n\t\t\tv === m &&\n\t\t\tv === 0.0 &&\n\t\t\tisPositiveZero( v )\n\t\t) {\n\t\t\tm = v;\n\t\t}\n\t}\n\treturn m;\n}\n\n\n// EXPORTS //\n\nexport default maxn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpretCmplx from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBool from '@stdlib/strided/base/reinterpret-boolean';\nimport resolveStride from './resolve_stride.js';\nimport numel from './numel.js';\n\n\n// FUNCTIONS //\n\n/**\n* Takes elements from either one indexed array or another depending on a condition and assigns the values to elements in an indexed output array.\n*\n* @private\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {Collection} condition - indicator array\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @throws {Error} input arrays must be broadcast compatible with the output array\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var condition = [ true, false, true, false ];\n*\n* var arr = indexed( out.length, condition, x, y, out, 1, 0 );\n* // returns [ 1, 6, 3, 8 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction indexed( N, condition, x, y, out, stride, offset ) {\n\tvar sx;\n\tvar sy;\n\tvar sc;\n\tvar ix;\n\tvar iy;\n\tvar ic;\n\tvar io;\n\tvar i;\n\n\t// Broadcast the arrays by computing strides:\n\tsc = resolveStride( condition.length, N );\n\tsx = resolveStride( x.length, N );\n\tsy = resolveStride( y.length, N );\n\n\t// Initialize indices:\n\tic = 0;\n\tix = 0;\n\tiy = 0;\n\tio = offset;\n\n\t// Extract each desired element from a provided array...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout[ io ] = ( condition[ ic ] ) ? x[ ix ] : y[ iy ];\n\t\tic += sc;\n\t\tix += sx;\n\t\tiy += sy;\n\t\tio += stride;\n\t}\n\treturn out;\n}\n\n/**\n* Takes elements from either one accessor array or another depending on a condition and assigns the values to elements in an accessor output array.\n*\n* @private\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {Object} condition - condition array object\n* @param {Object} x - first input array object\n* @param {Object} y - second input array object\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var y = toAccessorArray( [ 5, 6, 7, 8 ] );\n*\n* var condition = toAccessorArray( [ true, false, true, false ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( out.length, arraylike2object( condition ), arraylike2object( x ), arraylike2object( y ), arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 1\n*\n* v = arr.get( 1 );\n* // returns 6\n*/\nfunction accessors( N, condition, x, y, out, stride, offset ) {\n\tvar xdata;\n\tvar ydata;\n\tvar cdata;\n\tvar odata;\n\tvar xget;\n\tvar yget;\n\tvar cget;\n\tvar oset;\n\tvar sx;\n\tvar sy;\n\tvar sc;\n\tvar ix;\n\tvar iy;\n\tvar ic;\n\tvar io;\n\tvar i;\n\n\tcdata = condition.data;\n\txdata = x.data;\n\tydata = y.data;\n\todata = out.data;\n\n\tcget = condition.accessors[ 0 ];\n\txget = x.accessors[ 0 ];\n\tyget = y.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\t// Broadcast the arrays by computing strides:\n\tsc = resolveStride( cdata.length, N );\n\tsx = resolveStride( xdata.length, N );\n\tsy = resolveStride( ydata.length, N );\n\n\t// Initialize indices:\n\tic = 0;\n\tix = 0;\n\tiy = 0;\n\tio = offset;\n\n\t// Extract each desired element from a provided array...\n\tfor ( i = 0; i < N; i++ ) {\n\t\toset( odata, io, ( cget( cdata, ic ) ) ? xget( xdata, ix ) : yget( ydata, iy ) ); // eslint-disable-line max-len\n\t\tic += sc;\n\t\tix += sx;\n\t\tiy += sy;\n\t\tio += stride;\n\t}\n\treturn odata;\n}\n\n/**\n* Takes elements from either one complex array or another depending on a condition and assigns the values to elements in a complex output array.\n*\n* @private\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {Object} condition - condition array object\n* @param {Collection} x - first real-valued floating-point input array view\n* @param {Collection} y - second real-valued floating-point input array view\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );\n* var y = new Float64Array( [ 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 ] );\n*\n* var condition = [ true, false, true, false ];\n*\n* var out = new Float64Array( 8 );\n*\n* var arr = complex( 4, arraylike2object( condition ), x, y, out, 1, 0 );\n* // returns [ 1.0, 2.0, 11.0, 12.0, 5.0, 6.0, 15.0, 16.0 ]\n*/\nfunction complex( N, condition, x, y, out, stride, offset ) {\n\tvar cdata;\n\tvar cget;\n\tvar sx;\n\tvar sy;\n\tvar sc;\n\tvar so;\n\tvar ix;\n\tvar iy;\n\tvar ic;\n\tvar io;\n\tvar i;\n\n\tcdata = condition.data;\n\tcget = condition.accessors[ 0 ];\n\n\t// Broadcast the arrays by computing strides (note: multiply strides by 2 for complex array arguments, as a real-valued array view consists of interleaved real and imaginary components):\n\tsc = resolveStride( cdata.length, N );\n\tsx = resolveStride( x.length/2, N ) * 2;\n\tsy = resolveStride( y.length/2, N ) * 2;\n\tso = stride * 2;\n\n\t// Initialize indices:\n\tic = 0;\n\tix = 0;\n\tiy = 0;\n\tio = offset * 2; // note: account for interleaved real and imaginary components\n\n\t// Extract each desired element from a provided array...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( cget( cdata, ic ) ) {\n\t\t\tout[ io ] = x[ ix ];\n\t\t\tout[ io+1 ] = x[ ix+1 ];\n\t\t} else {\n\t\t\tout[ io ] = y[ iy ];\n\t\t\tout[ io+1 ] = y[ iy+1 ];\n\t\t}\n\t\tic += sc;\n\t\tix += sx;\n\t\tiy += sy;\n\t\tio += so;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Takes elements from either one of two arrays depending on a condition and assigns the values to elements in a provided output array.\n*\n* @param {Collection} condition - indicator array\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @throws {Error} input arrays must be broadcast compatible with the output array\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var condition = [ true, false, true, false ];\n*\n* var arr = assign( condition, x, y, out, 1, 0 );\n* // returns [ 1, 6, 3, 8 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( condition, x, y, out, stride, offset ) {\n\tvar co;\n\tvar xo;\n\tvar yo;\n\tvar oo;\n\tvar N;\n\n\t// Check whether we can avoid doing any work...\n\tif ( condition.length === 0 ) {\n\t\treturn out;\n\t}\n\t// Compute the number of indexed elements in the output array:\n\tN = numel( out.length, stride, offset );\n\n\tco = arraylike2object( condition );\n\tif ( isBooleanDataType( co.dtype ) ) {\n\t\tcondition = reinterpretBool( condition, 0 );\n\t\tco = arraylike2object( condition );\n\t}\n\txo = arraylike2object( x );\n\tyo = arraylike2object( y );\n\too = arraylike2object( out );\n\tif (\n\t\tco.accessorProtocol ||\n\t\txo.accessorProtocol ||\n\t\tyo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\t// Note: we only explicitly special case a select number of same dtype-to-dtype combinations, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tco.accessorProtocol === false &&\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( yo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tindexed( N, condition, reinterpretBool( x, 0 ), reinterpretBool( y, 0 ), reinterpretBool( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( yo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( N, co, reinterpretCmplx( x, 0 ), reinterpretCmplx( y, 0 ), reinterpretCmplx( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( N, co, xo, yo, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( N, condition, x, y, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ceil from '@stdlib/math/base/special/ceil';\n\n\n// MAIN //\n\n/**\n* Computes the number of indexed elements in a strided array.\n*\n* @private\n* @param {NonNegativeInteger} len - array length\n* @param {integer} stride - array stride\n* @param {NonNegativeInteger} offset - array offset\n* @returns {NonNegativeInteger} number of indexed elements\n*\n* @example\n* var N = numel( 10, -2, 9 );\n* // returns 5\n*\n* N = numel( 10, -2, 8 );\n* // returns 5\n*\n* N = numel( 10, -2, 7 );\n* // returns 4\n*\n* N = numel( 10, -2, 6 );\n* // returns 4\n*\n* N = numel( 10, -2, 5 );\n* // returns 3\n*\n* @example\n* var N = numel( 10, -3, 9 );\n* // returns 4\n*\n* N = numel( 10, -3, 8 );\n* // returns 3\n*\n* N = numel( 10, -3, 7 );\n* // returns 3\n*\n* N = numel( 10, -3, 6 );\n* // returns 3\n*\n* N = numel( 10, -3, 5 );\n* // returns 2\n*\n* @example\n* var N = numel( 10, 2, 0 );\n* // returns 5\n*\n* N = numel( 10, 2, 1 );\n* // returns 5\n*\n* N = numel( 10, 2, 2 );\n* // returns 4\n*\n* N = numel( 10, 2, 3 );\n* // returns 4\n*\n* @example\n* var N = numel( 10, 3, 0 );\n* // returns 4\n*\n* N = numel( 10, 3, 1 );\n* // returns 3\n*\n* N = numel( 10, 3, 2 );\n* // returns 3\n*\n* N = numel( 10, 3, 3 );\n* // returns 3\n*/\nfunction numel( len, stride, offset ) {\n\tif ( stride < 0 ) {\n\t\treturn ceil( (offset+1) / -stride );\n\t}\n\treturn ceil( (len-offset) / stride );\n}\n\n\n// EXPORTS //\n\nexport default numel;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport slice from './../../../base/slice';\nimport resolveSetter from './../../../base/resolve-setter';\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'map' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n\n// MAIN //\n\n/**\n* Returns a new array with the element at the specified index replaced with a provided value.\n*\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @param {*} value - replacement value\n* @throws {RangeError} second argument must not exceed array bounds\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var v = arrayWith( x, 0, 5 );\n* // returns [ 5, 2, 3, 4 ]\n*\n* v = arrayWith( x, 1, 6 );\n* // returns [ 1, 6, 3, 4 ]\n*\n* v = arrayWith( x, -2, 7 );\n* // returns [ 1, 2, 7, 4 ]\n*/\nfunction arrayWith( x, index, value ) {\n\tvar out;\n\tvar set;\n\tif ( hasMethod( x, 'with' ) ) {\n\t\treturn x.with( index, value );\n\t}\n\tindex = normalizeIndex( index, x.length-1 );\n\tif ( index < 0 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) );\n\t}\n\tout = slice( x, 0, x.length );\n\tset = resolveSetter( out );\n\tset( out, index, value );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default arrayWith;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport Boolean from '@stdlib/boolean/ctor';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Copies elements from one array to another array and sets the element at the specified index to a provided value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @param {*} value - replacement value\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var arr = indexed( x, 0, 5, out, 1, 0 );\n* // returns [ 5, 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction indexed( x, index, value, out, stride, offset ) {\n\tvar io;\n\tvar i;\n\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout[ io ] = x[ i ];\n\t\tio += stride;\n\t}\n\tout[ offset+(index*stride) ] = value;\n\treturn out;\n}\n\n/**\n* Copies elements from one accessor array to another accessor array and sets the element at the specified index to a provided value.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} index - element index\n* @param {*} value - replacement value\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), 0, 5, arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 5\n*/\nfunction accessors( x, index, value, out, stride, offset ) {\n\tvar xdata;\n\tvar odata;\n\tvar xget;\n\tvar oset;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\toset( odata, io, xget( xdata, i ) );\n\t\tio += stride;\n\t}\n\toset( odata, offset+(index*stride), value );\n\treturn odata;\n}\n\n/**\n* Copies elements from one complex array to another complex array and sets the element at the specified index to a provided value.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {integer} index - element index\n* @param {ComplexLike} value - replacement value\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = new Float64Array( 4 );\n* var arr = complex( x, 0, new Complex128( 5.0, 6.0 ), out, 1, 0 );\n* // returns [ 5.0, 6.0, 3.0, 4.0 ]\n*/\nfunction complex( x, index, value, out, stride, offset ) {\n\tvar so;\n\tvar io;\n\tvar i;\n\tvar j;\n\n\tso = stride * 2; // multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < x.length/2; i++ ) {\n\t\tj = i * 2;\n\t\tout[ io ] = x[ j ];\n\t\tout[ io+1 ] = x[ j+1 ];\n\t\tio += so;\n\t}\n\tio = ( offset+(index*stride) ) * 2;\n\tout[ io ] = real( value );\n\tout[ io+1 ] = imag( value );\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Copies elements from one array to another array and sets the element at the specified index to a provided value.\n*\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @param {*} value - replacement value\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @throws {RangeError} second argument must not exceed array bounds\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var arr = assign( x, 0, 5, out, 1, 0 );\n* // returns [ 5, 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, index, value, out, stride, offset ) {\n\tvar xo;\n\tvar oo;\n\n\tindex = normalizeIndex( index, x.length-1 );\n\tif ( index < 0 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) );\n\t}\n\txo = arraylike2object( x );\n\too = arraylike2object( out );\n\tif ( xo.accessorProtocol || oo.accessorProtocol ) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype ) &&\n\t\t\tisComplexLike( value )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), index, value, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tindexed( reinterpretBoolean( x, 0 ), index, Boolean( value ), reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, index, value, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, index, value, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default array settings.\n*\n* @returns {Object} defaults\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t// Data types:\n\t\t'dtypes': {\n\t\t\t'default': 'float64',\n\t\t\t'numeric': 'float64',\n\t\t\t'real': 'float64',\n\t\t\t'floating_point': 'float64',\n\t\t\t'real_floating_point': 'float64',\n\t\t\t'complex_floating_point': 'complex128',\n\t\t\t'integer': 'int32',\n\t\t\t'signed_integer': 'int32',\n\t\t\t'unsigned_integer': 'uint32',\n\t\t\t'boolean': 'bool',\n\t\t\t'index': 'int32',\n\t\t\t'integer_index': 'int32',\n\t\t\t'boolean_index': 'bool',\n\t\t\t'mask_index': 'uint8'\n\t\t}\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Take elements from either one of two arrays depending on a condition.\n*\n* @module @stdlib/array/base/where\n*\n* @example\n* import where from '@stdlib/array/base/where';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n*\n* var condition = [ true, false, true, false ];\n*\n* var z = where( condition, x, y );\n* // returns [ 1, 6, 3, 8 ]\n*\n* @example\n* import where from '@stdlib/array/base/where';\n*\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var condition = [ true, false, true, false ];\n*\n* var arr = where.assign( condition, x, y, out, 1, 0 );\n* // returns [ 1, 6, 3, 8 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a new array with the element at the specified index replaced with a provided value.\n*\n* @module @stdlib/array/base/with\n*\n* @example\n* import arrayWith from '@stdlib/array/base/with';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var v = arrayWith( x, 0, 5 );\n* // returns [ 5, 2, 3, 4 ]\n*\n* v = arrayWith( x, -2, -1 );\n* // returns [ 1, 2, -1, 4 ]\n*\n* @example\n* import arrayWith from '@stdlib/array/base/with';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0, 0 ];\n* var arr = arrayWith.assign( x, 0, 5, out, 1, 0 );\n* // returns [ 5, 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defaults from './main.js';\n\n\n// VARIABLES //\n\nvar DEFAULTS = defaults();\nvar HASH = {\n\t'dtypes.default': DEFAULTS.dtypes.default,\n\t'dtypes.numeric': DEFAULTS.dtypes.numeric,\n\t'dtypes.real': DEFAULTS.dtypes.real,\n\t'dtypes.floating_point': DEFAULTS.dtypes.floating_point,\n\t'dtypes.real_floating_point': DEFAULTS.dtypes.real_floating_point,\n\t'dtypes.complex_floating_point': DEFAULTS.dtypes.complex_floating_point,\n\t'dtypes.integer': DEFAULTS.dtypes.integer,\n\t'dtypes.signed_integer': DEFAULTS.dtypes.signed_integer,\n\t'dtypes.unsigned_integer': DEFAULTS.dtypes.unsigned_integer,\n\t'dtypes.boolean': DEFAULTS.dtypes.boolean,\n\t'dtypes.index': DEFAULTS.dtypes.index,\n\t'dtypes.integer_index': DEFAULTS.dtypes.integer_index,\n\t'dtypes.boolean_index': DEFAULTS.dtypes.boolean_index,\n\t'dtypes.mask_index': DEFAULTS.dtypes.mask_index\n};\n\n\n// MAIN //\n\n/**\n* Returns a default array setting.\n*\n* @param {string} name - setting name\n* @returns {*} default setting or null\n*\n* @example\n* var v = get( 'dtypes.default' );\n* // returns \n*/\nfunction get( name ) {\n\tvar v = HASH[ name ];\n\treturn ( v === void 0 ) ? null : v;\n}\n\n\n// EXPORTS //\n\nexport default get;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return default array settings.\n*\n* @module @stdlib/array/defaults\n*\n* @example\n* import defaults from '@stdlib/array/defaults';\n*\n* var o = defaults();\n* // returns {...}\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport get from './get.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'get', get );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport ctors from './../../ctors';\nimport gzeros from './../../base/zeros';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled array having a specified length.\n*\n* @param {NonNegativeInteger} length - array length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = zeros( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = zeros( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*/\nfunction zeros( length ) {\n\tvar dtype;\n\tvar ctor;\n\tif ( !isNonNegativeInteger( length ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', length ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tif ( dtype === 'generic' ) {\n\t\treturn gzeros( length );\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\treturn new ctor( length ); // WARNING: we assume that, apart from 'generic', the constructors for supported array data types are zero-filled by default\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../../base/assert/is-boolean-data-type';\nimport arraylike2object from './../../../base/arraylike2object';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Copies every element from one array to another array, except for the element at a specified index.\n*\n* @private\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0 ];\n* var arr = indexed( x, 0, out, 1, 0 );\n* // returns [ 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction indexed( x, index, out, stride, offset ) {\n\tvar io;\n\tvar i;\n\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( i === index ) {\n\t\t\tcontinue;\n\t\t}\n\t\tout[ io ] = x[ i ];\n\t\tio += stride;\n\t}\n\treturn out;\n}\n\n/**\n* Copies every element from one accessor array to another accessor array, except for the element at a specified index.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} index - element index\n* @param {Object} out - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), 0, arraylike2object( out ), 1, 0 );\n*\n* var v = arr.get( 0 );\n* // returns 2\n*/\nfunction accessors( x, index, out, stride, offset ) {\n\tvar xdata;\n\tvar odata;\n\tvar xget;\n\tvar oset;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( i === index ) {\n\t\t\tcontinue;\n\t\t}\n\t\toset( odata, io, xget( xdata, i ) );\n\t\tio += stride;\n\t}\n\treturn odata;\n}\n\n/**\n* Copies every element from one complex array to another complex array, except for the element at a specified index.\n*\n* @private\n* @param {Collection} x - real-valued floating-point input array view\n* @param {integer} index - element index\n* @param {Collection} out - real-valued floating-point output array view\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @returns {Collection} output array view\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );\n*\n* var out = new Float64Array( 2 );\n* var arr = complex( x, 0, out, 1, 0 );\n* // returns [ 3.0, 4.0 ]\n*/\nfunction complex( x, index, out, stride, offset ) {\n\tvar so;\n\tvar io;\n\tvar i;\n\tvar j;\n\n\tso = stride * 2; // multiply by 2, as real-valued array consists of interleaved real and imaginary components\n\tio = offset * 2;\n\tfor ( i = 0; i < x.length/2; i++ ) {\n\t\tif ( i === index ) {\n\t\t\tcontinue;\n\t\t}\n\t\tj = i * 2;\n\t\tout[ io ] = x[ j ];\n\t\tout[ io+1 ] = x[ j+1 ];\n\t\tio += so;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Copies every element from one array to another array, except for the element at a specified index.\n*\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @param {Collection} out - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @throws {RangeError} second argument must not exceed array bounds\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0 ];\n* var arr = assign( x, 0, out, 1, 0 );\n* // returns [ 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\nfunction assign( x, index, out, stride, offset ) {\n\tvar xo;\n\tvar oo;\n\n\tindex = normalizeIndex( index, x.length-1 );\n\tif ( index < 0 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) );\n\t}\n\txo = arraylike2object( x );\n\too = arraylike2object( out );\n\tif ( xo.accessorProtocol || oo.accessorProtocol ) {\n\t\t// Note: we only explicitly support a limited set of dtype-to-dtype pairs, as this function should not be concerned with casting rules, etc. That is left to userland...\n\t\tif (\n\t\t\tisComplexDataType( xo.dtype ) &&\n\t\t\tisComplexDataType( oo.dtype )\n\t\t) {\n\t\t\tcomplex( reinterpret( x, 0 ), index, reinterpret( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\tif (\n\t\t\tisBooleanDataType( xo.dtype ) &&\n\t\t\tisBooleanDataType( oo.dtype )\n\t\t) {\n\t\t\tindexed( reinterpretBoolean( x, 0 ), index, reinterpretBoolean( out, 0 ), stride, offset ); // eslint-disable-line max-len\n\t\t\treturn out;\n\t\t}\n\t\taccessors( xo, index, oo, stride, offset );\n\t\treturn out;\n\t}\n\tindexed( x, index, out, stride, offset );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport zeros from './../../../zeros';\nimport dtype from './../../../dtype';\nimport format from '@stdlib/string/format';\nimport assign from './assign.js';\n\n\n// MAIN //\n\n/**\n* Returns a new array containing every element from an input array, except for the element at a specified index.\n*\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @throws {RangeError} second argument must not exceed array bounds\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var v = without( x, 0 );\n* // returns [ 2, 3, 4 ]\n*\n* v = without( x, 1 );\n* // returns [ 1, 3, 4 ]\n*\n* v = without( x, -2 );\n* // returns [ 1, 2, 4 ]\n*/\nfunction without( x, index ) {\n\tvar out;\n\n\tindex = normalizeIndex( index, x.length-1 );\n\tif ( index < 0 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%d`.', index ) );\n\t}\n\tout = zeros( x.length-1, dtype( x ) || 'generic' );\n\tassign( x, index, out, 1, 0 );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default without;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return a new array containing every element from an input array, except for the element at a specified index.\n*\n* @module @stdlib/array/base/without\n*\n* @example\n* import without from '@stdlib/array/base/without';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var v = without( x, 0 );\n* // returns [ 2, 3, 4 ]\n*\n* v = without( x, -2 );\n* // returns [ 1, 2, 4 ]\n*\n* @example\n* import without from '@stdlib/array/base/without';\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = [ 0, 0, 0 ];\n* var arr = without.assign( x, 0, out, 1, 0 );\n* // returns [ 2, 3, 4 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/*\n* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name AccessorArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/accessor}\n*/\nimport AccessorArray from './../../base/accessor';\nsetReadOnly( ns, 'AccessorArray', AccessorArray );\n\n/**\n* @name accessorGetter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/accessor-getter}\n*/\nimport accessorGetter from './../../base/accessor-getter';\nsetReadOnly( ns, 'accessorGetter', accessorGetter );\n\n/**\n* @name accessorSetter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/accessor-setter}\n*/\nimport accessorSetter from './../../base/accessor-setter';\nsetReadOnly( ns, 'accessorSetter', accessorSetter );\n\n/**\n* @name accessors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/accessors}\n*/\nimport accessors from './../../base/accessors';\nsetReadOnly( ns, 'accessors', accessors );\n\n/**\n* @name any\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any}\n*/\nimport any from './../../base/any';\nsetReadOnly( ns, 'any', any );\n\n/**\n* @name anyBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-by}\n*/\nimport anyBy from './../../base/any-by';\nsetReadOnly( ns, 'anyBy', anyBy );\n\n/**\n* @name anyByRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-by-right}\n*/\nimport anyByRight from './../../base/any-by-right';\nsetReadOnly( ns, 'anyByRight', anyByRight );\n\n/**\n* @name anyHasOwnProp\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-has-own-property}\n*/\nimport anyHasOwnProp from './../../base/any-has-own-property';\nsetReadOnly( ns, 'anyHasOwnProp', anyHasOwnProp );\n\n/**\n* @name anyHasProp\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-has-property}\n*/\nimport anyHasProp from './../../base/any-has-property';\nsetReadOnly( ns, 'anyHasProp', anyHasProp );\n\n/**\n* @name anyIsEntry\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-is-entry}\n*/\nimport anyIsEntry from './../../base/any-is-entry';\nsetReadOnly( ns, 'anyIsEntry', anyIsEntry );\n\n/**\n* @name anyIsEntryIn\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/any-is-entry-in}\n*/\nimport anyIsEntryIn from './../../base/any-is-entry-in';\nsetReadOnly( ns, 'anyIsEntryIn', anyIsEntryIn );\n\n/**\n* @name arraylike2object\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/arraylike2object}\n*/\nimport arraylike2object from './../../base/arraylike2object';\nsetReadOnly( ns, 'arraylike2object', arraylike2object );\n\n/**\n* @name assert\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/assert}\n*/\nimport assert from './../../base/assert';\nsetReadOnly( ns, 'assert', assert );\n\n/**\n* @name at\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/at}\n*/\nimport at from './../../base/at';\nsetReadOnly( ns, 'at', at );\n\n/**\n* @name at2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/at2d}\n*/\nimport at2d from './../../base/at2d';\nsetReadOnly( ns, 'at2d', at2d );\n\n/**\n* @name at3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/at3d}\n*/\nimport at3d from './../../base/at3d';\nsetReadOnly( ns, 'at3d', at3d );\n\n/**\n* @name at4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/at4d}\n*/\nimport at4d from './../../base/at4d';\nsetReadOnly( ns, 'at4d', at4d );\n\n/**\n* @name at5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/at5d}\n*/\nimport at5d from './../../base/at5d';\nsetReadOnly( ns, 'at5d', at5d );\n\n/**\n* @name atnd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/atnd}\n*/\nimport atnd from './../../base/atnd';\nsetReadOnly( ns, 'atnd', atnd );\n\n/**\n* @name banded\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/banded}\n*/\nimport banded from './../../base/banded';\nsetReadOnly( ns, 'banded', banded );\n\n/**\n* @name bifurcateEntries\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-entries}\n*/\nimport bifurcateEntries from './../../base/bifurcate-entries';\nsetReadOnly( ns, 'bifurcateEntries', bifurcateEntries );\n\n/**\n* @name bifurcateEntriesBy\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-entries-by}\n*/\nimport bifurcateEntriesBy from './../../base/bifurcate-entries-by';\nsetReadOnly( ns, 'bifurcateEntriesBy', bifurcateEntriesBy );\n\n/**\n* @name bifurcateIndices\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-indices}\n*/\nimport bifurcateIndices from './../../base/bifurcate-indices';\nsetReadOnly( ns, 'bifurcateIndices', bifurcateIndices );\n\n/**\n* @name bifurcateIndicesBy\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-indices-by}\n*/\nimport bifurcateIndicesBy from './../../base/bifurcate-indices-by';\nsetReadOnly( ns, 'bifurcateIndicesBy', bifurcateIndicesBy );\n\n/**\n* @name bifurcateValues\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-values}\n*/\nimport bifurcateValues from './../../base/bifurcate-values';\nsetReadOnly( ns, 'bifurcateValues', bifurcateValues );\n\n/**\n* @name bifurcateValuesBy\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/bifurcate-values-by}\n*/\nimport bifurcateValuesBy from './../../base/bifurcate-values-by';\nsetReadOnly( ns, 'bifurcateValuesBy', bifurcateValuesBy );\n\n/**\n* @name binary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/binary2d}\n*/\nimport binary2d from './../../base/binary2d';\nsetReadOnly( ns, 'binary2d', binary2d );\n\n/**\n* @name binary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/binary3d}\n*/\nimport binary3d from './../../base/binary3d';\nsetReadOnly( ns, 'binary3d', binary3d );\n\n/**\n* @name binary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/binary4d}\n*/\nimport binary4d from './../../base/binary4d';\nsetReadOnly( ns, 'binary4d', binary4d );\n\n/**\n* @name binary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/binary5d}\n*/\nimport binary5d from './../../base/binary5d';\nsetReadOnly( ns, 'binary5d', binary5d );\n\n/**\n* @name binarynd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/binarynd}\n*/\nimport binarynd from './../../base/binarynd';\nsetReadOnly( ns, 'binarynd', binarynd );\n\n/**\n* @name broadcastArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcast-array}\n*/\nimport broadcastArray from './../../base/broadcast-array';\nsetReadOnly( ns, 'broadcastArray', broadcastArray );\n\n/**\n* @name bbinary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-binary2d}\n*/\nimport bbinary2d from './../../base/broadcasted-binary2d';\nsetReadOnly( ns, 'bbinary2d', bbinary2d );\n\n/**\n* @name bbinary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-binary3d}\n*/\nimport bbinary3d from './../../base/broadcasted-binary3d';\nsetReadOnly( ns, 'bbinary3d', bbinary3d );\n\n/**\n* @name bbinary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-binary4d}\n*/\nimport bbinary4d from './../../base/broadcasted-binary4d';\nsetReadOnly( ns, 'bbinary4d', bbinary4d );\n\n/**\n* @name bbinary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-binary5d}\n*/\nimport bbinary5d from './../../base/broadcasted-binary5d';\nsetReadOnly( ns, 'bbinary5d', bbinary5d );\n\n/**\n* @name bquaternary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quaternary2d}\n*/\nimport bquaternary2d from './../../base/broadcasted-quaternary2d';\nsetReadOnly( ns, 'bquaternary2d', bquaternary2d );\n\n/**\n* @name bquaternary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quaternary3d}\n*/\nimport bquaternary3d from './../../base/broadcasted-quaternary3d';\nsetReadOnly( ns, 'bquaternary3d', bquaternary3d );\n\n/**\n* @name bquaternary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quaternary4d}\n*/\nimport bquaternary4d from './../../base/broadcasted-quaternary4d';\nsetReadOnly( ns, 'bquaternary4d', bquaternary4d );\n\n/**\n* @name bquaternary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quaternary5d}\n*/\nimport bquaternary5d from './../../base/broadcasted-quaternary5d';\nsetReadOnly( ns, 'bquaternary5d', bquaternary5d );\n\n/**\n* @name bquinary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quinary2d}\n*/\nimport bquinary2d from './../../base/broadcasted-quinary2d';\nsetReadOnly( ns, 'bquinary2d', bquinary2d );\n\n/**\n* @name bquinary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-quinary4d}\n*/\nimport bquinary4d from './../../base/broadcasted-quinary4d';\nsetReadOnly( ns, 'bquinary4d', bquinary4d );\n\n/**\n* @name bternary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-ternary2d}\n*/\nimport bternary2d from './../../base/broadcasted-ternary2d';\nsetReadOnly( ns, 'bternary2d', bternary2d );\n\n/**\n* @name bternary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-ternary3d}\n*/\nimport bternary3d from './../../base/broadcasted-ternary3d';\nsetReadOnly( ns, 'bternary3d', bternary3d );\n\n/**\n* @name bternary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-ternary4d}\n*/\nimport bternary4d from './../../base/broadcasted-ternary4d';\nsetReadOnly( ns, 'bternary4d', bternary4d );\n\n/**\n* @name bternary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-ternary5d}\n*/\nimport bternary5d from './../../base/broadcasted-ternary5d';\nsetReadOnly( ns, 'bternary5d', bternary5d );\n\n/**\n* @name bunary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-unary2d}\n*/\nimport bunary2d from './../../base/broadcasted-unary2d';\nsetReadOnly( ns, 'bunary2d', bunary2d );\n\n/**\n* @name bunary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-unary3d}\n*/\nimport bunary3d from './../../base/broadcasted-unary3d';\nsetReadOnly( ns, 'bunary3d', bunary3d );\n\n/**\n* @name bunary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-unary4d}\n*/\nimport bunary4d from './../../base/broadcasted-unary4d';\nsetReadOnly( ns, 'bunary4d', bunary4d );\n\n/**\n* @name bunary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/broadcasted-unary5d}\n*/\nimport bunary5d from './../../base/broadcasted-unary5d';\nsetReadOnly( ns, 'bunary5d', bunary5d );\n\n/**\n* @name cartesianPower\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cartesian-power}\n*/\nimport cartesianPower from './../../base/cartesian-power';\nsetReadOnly( ns, 'cartesianPower', cartesianPower );\n\n/**\n* @name cartesianProduct\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cartesian-product}\n*/\nimport cartesianProduct from './../../base/cartesian-product';\nsetReadOnly( ns, 'cartesianProduct', cartesianProduct );\n\n/**\n* @name cartesianSquare\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cartesian-square}\n*/\nimport cartesianSquare from './../../base/cartesian-square';\nsetReadOnly( ns, 'cartesianSquare', cartesianSquare );\n\n/**\n* @name copy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/copy}\n*/\nimport copy from './../../base/copy';\nsetReadOnly( ns, 'copy', copy );\n\n/**\n* @name copyIndexed\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/copy-indexed}\n*/\nimport copyIndexed from './../../base/copy-indexed';\nsetReadOnly( ns, 'copyIndexed', copyIndexed );\n\n/**\n* @name countFalsy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-falsy}\n*/\nimport countFalsy from './../../base/count-falsy';\nsetReadOnly( ns, 'countFalsy', countFalsy );\n\n/**\n* @name countIf\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-if}\n*/\nimport countIf from './../../base/count-if';\nsetReadOnly( ns, 'countIf', countIf );\n\n/**\n* @name countIfs\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-ifs}\n*/\nimport countIfs from './../../base/count-ifs';\nsetReadOnly( ns, 'countIfs', countIfs );\n\n/**\n* @name countSameValue\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-same-value}\n*/\nimport countSameValue from './../../base/count-same-value';\nsetReadOnly( ns, 'countSameValue', countSameValue );\n\n/**\n* @name countSameValueZero\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-same-value-zero}\n*/\nimport countSameValueZero from './../../base/count-same-value-zero';\nsetReadOnly( ns, 'countSameValueZero', countSameValueZero );\n\n/**\n* @name countTruthy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/count-truthy}\n*/\nimport countTruthy from './../../base/count-truthy';\nsetReadOnly( ns, 'countTruthy', countTruthy );\n\n/**\n* @name cuany\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cuany}\n*/\nimport cuany from './../../base/cuany';\nsetReadOnly( ns, 'cuany', cuany );\n\n/**\n* @name cuevery\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cuevery}\n*/\nimport cuevery from './../../base/cuevery';\nsetReadOnly( ns, 'cuevery', cuevery );\n\n/**\n* @name cunone\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/cunone}\n*/\nimport cunone from './../../base/cunone';\nsetReadOnly( ns, 'cunone', cunone );\n\n/**\n* @name dedupe\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/dedupe}\n*/\nimport dedupe from './../../base/dedupe';\nsetReadOnly( ns, 'dedupe', dedupe );\n\n/**\n* @name entries2objects\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/entries2objects}\n*/\nimport entries2objects from './../../base/entries2objects';\nsetReadOnly( ns, 'entries2objects', entries2objects );\n\n/**\n* @name entries2views\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/entries2views}\n*/\nimport entries2views from './../../base/entries2views';\nsetReadOnly( ns, 'entries2views', entries2views );\n\n/**\n* @name every\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/every}\n*/\nimport every from './../../base/every';\nsetReadOnly( ns, 'every', every );\n\n/**\n* @name everyBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/every-by}\n*/\nimport everyBy from './../../base/every-by';\nsetReadOnly( ns, 'everyBy', everyBy );\n\n/**\n* @name everyByRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/every-by-right}\n*/\nimport everyByRight from './../../base/every-by-right';\nsetReadOnly( ns, 'everyByRight', everyByRight );\n\n/**\n* @name fancySlice\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fancy-slice}\n*/\nimport fancySlice from './../../base/fancy-slice';\nsetReadOnly( ns, 'fancySlice', fancySlice );\n\n/**\n* @name fancySliceAssign\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fancy-slice-assign}\n*/\nimport fancySliceAssign from './../../base/fancy-slice-assign';\nsetReadOnly( ns, 'fancySliceAssign', fancySliceAssign );\n\n/**\n* @name fill\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fill}\n*/\nimport fill from './../../base/fill';\nsetReadOnly( ns, 'fill', fill );\n\n/**\n* @name fillBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fill-by}\n*/\nimport fillBy from './../../base/fill-by';\nsetReadOnly( ns, 'fillBy', fillBy );\n\n/**\n* @name filled\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled}\n*/\nimport filled from './../../base/filled';\nsetReadOnly( ns, 'filled', filled );\n\n/**\n* @name filledBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled-by}\n*/\nimport filledBy from './../../base/filled-by';\nsetReadOnly( ns, 'filledBy', filledBy );\n\n/**\n* @name filled2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled2d}\n*/\nimport filled2d from './../../base/filled2d';\nsetReadOnly( ns, 'filled2d', filled2d );\n\n/**\n* @name filled2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled2d-by}\n*/\nimport filled2dBy from './../../base/filled2d-by';\nsetReadOnly( ns, 'filled2dBy', filled2dBy );\n\n/**\n* @name filled3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled3d}\n*/\nimport filled3d from './../../base/filled3d';\nsetReadOnly( ns, 'filled3d', filled3d );\n\n/**\n* @name filled3dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled3d-by}\n*/\nimport filled3dBy from './../../base/filled3d-by';\nsetReadOnly( ns, 'filled3dBy', filled3dBy );\n\n/**\n* @name filled4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled4d}\n*/\nimport filled4d from './../../base/filled4d';\nsetReadOnly( ns, 'filled4d', filled4d );\n\n/**\n* @name filled4dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled4d-by}\n*/\nimport filled4dBy from './../../base/filled4d-by';\nsetReadOnly( ns, 'filled4dBy', filled4dBy );\n\n/**\n* @name filled5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled5d}\n*/\nimport filled5d from './../../base/filled5d';\nsetReadOnly( ns, 'filled5d', filled5d );\n\n/**\n* @name filled5dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filled5d-by}\n*/\nimport filled5dBy from './../../base/filled5d-by';\nsetReadOnly( ns, 'filled5dBy', filled5dBy );\n\n/**\n* @name fillednd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fillednd}\n*/\nimport fillednd from './../../base/fillednd';\nsetReadOnly( ns, 'fillednd', fillednd );\n\n/**\n* @name filledndBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fillednd-by}\n*/\nimport filledndBy from './../../base/fillednd-by';\nsetReadOnly( ns, 'filledndBy', filledndBy );\n\n/**\n* @name filter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/filter}\n*/\nimport filter from './../../base/filter';\nsetReadOnly( ns, 'filter', filter );\n\n/**\n* @name first\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/first}\n*/\nimport first from './../../base/first';\nsetReadOnly( ns, 'first', first );\n\n/**\n* @name flatten\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten}\n*/\nimport flatten from './../../base/flatten';\nsetReadOnly( ns, 'flatten', flatten );\n\n/**\n* @name flattenBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten-by}\n*/\nimport flattenBy from './../../base/flatten-by';\nsetReadOnly( ns, 'flattenBy', flattenBy );\n\n/**\n* @name flatten2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten2d}\n*/\nimport flatten2d from './../../base/flatten2d';\nsetReadOnly( ns, 'flatten2d', flatten2d );\n\n/**\n* @name flatten2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten2d-by}\n*/\nimport flatten2dBy from './../../base/flatten2d-by';\nsetReadOnly( ns, 'flatten2dBy', flatten2dBy );\n\n/**\n* @name flatten3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten3d}\n*/\nimport flatten3d from './../../base/flatten3d';\nsetReadOnly( ns, 'flatten3d', flatten3d );\n\n/**\n* @name flatten3dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten3d-by}\n*/\nimport flatten3dBy from './../../base/flatten3d-by';\nsetReadOnly( ns, 'flatten3dBy', flatten3dBy );\n\n/**\n* @name flatten4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten4d}\n*/\nimport flatten4d from './../../base/flatten4d';\nsetReadOnly( ns, 'flatten4d', flatten4d );\n\n/**\n* @name flatten4dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten4d-by}\n*/\nimport flatten4dBy from './../../base/flatten4d-by';\nsetReadOnly( ns, 'flatten4dBy', flatten4dBy );\n\n/**\n* @name flatten5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten5d}\n*/\nimport flatten5d from './../../base/flatten5d';\nsetReadOnly( ns, 'flatten5d', flatten5d );\n\n/**\n* @name flatten5dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flatten5d-by}\n*/\nimport flatten5dBy from './../../base/flatten5d-by';\nsetReadOnly( ns, 'flatten5dBy', flatten5dBy );\n\n/**\n* @name fliplr2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fliplr2d}\n*/\nimport fliplr2d from './../../base/fliplr2d';\nsetReadOnly( ns, 'fliplr2d', fliplr2d );\n\n/**\n* @name fliplr3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fliplr3d}\n*/\nimport fliplr3d from './../../base/fliplr3d';\nsetReadOnly( ns, 'fliplr3d', fliplr3d );\n\n/**\n* @name fliplr4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fliplr4d}\n*/\nimport fliplr4d from './../../base/fliplr4d';\nsetReadOnly( ns, 'fliplr4d', fliplr4d );\n\n/**\n* @name fliplr5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/fliplr5d}\n*/\nimport fliplr5d from './../../base/fliplr5d';\nsetReadOnly( ns, 'fliplr5d', fliplr5d );\n\n/**\n* @name flipud2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flipud2d}\n*/\nimport flipud2d from './../../base/flipud2d';\nsetReadOnly( ns, 'flipud2d', flipud2d );\n\n/**\n* @name flipud3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flipud3d}\n*/\nimport flipud3d from './../../base/flipud3d';\nsetReadOnly( ns, 'flipud3d', flipud3d );\n\n/**\n* @name flipud4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flipud4d}\n*/\nimport flipud4d from './../../base/flipud4d';\nsetReadOnly( ns, 'flipud4d', flipud4d );\n\n/**\n* @name flipud5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/flipud5d}\n*/\nimport flipud5d from './../../base/flipud5d';\nsetReadOnly( ns, 'flipud5d', flipud5d );\n\n/**\n* @name strided2array\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/from-strided}\n*/\nimport strided2array from './../../base/from-strided';\nsetReadOnly( ns, 'strided2array', strided2array );\n\n/**\n* @name getter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/getter}\n*/\nimport getter from './../../base/getter';\nsetReadOnly( ns, 'getter', getter );\n\n/**\n* @name groupEntries\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-entries}\n*/\nimport groupEntries from './../../base/group-entries';\nsetReadOnly( ns, 'groupEntries', groupEntries );\n\n/**\n* @name groupEntriesBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-entries-by}\n*/\nimport groupEntriesBy from './../../base/group-entries-by';\nsetReadOnly( ns, 'groupEntriesBy', groupEntriesBy );\n\n/**\n* @name groupIndices\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-indices}\n*/\nimport groupIndices from './../../base/group-indices';\nsetReadOnly( ns, 'groupIndices', groupIndices );\n\n/**\n* @name groupIndicesBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-indices-by}\n*/\nimport groupIndicesBy from './../../base/group-indices-by';\nsetReadOnly( ns, 'groupIndicesBy', groupIndicesBy );\n\n/**\n* @name groupValues\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-values}\n*/\nimport groupValues from './../../base/group-values';\nsetReadOnly( ns, 'groupValues', groupValues );\n\n/**\n* @name groupValuesBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-values-by}\n*/\nimport groupValuesBy from './../../base/group-values-by';\nsetReadOnly( ns, 'groupValuesBy', groupValuesBy );\n\n/**\n* @name groupValuesOnKey\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/group-values-on-key}\n*/\nimport groupValuesOnKey from './../../base/group-values-on-key';\nsetReadOnly( ns, 'groupValuesOnKey', groupValuesOnKey );\n\n/**\n* @name incrspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/incrspace}\n*/\nimport incrspace from './../../base/incrspace';\nsetReadOnly( ns, 'incrspace', incrspace );\n\n/**\n* @name indexOf\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/index-of}\n*/\nimport indexOf from './../../base/index-of';\nsetReadOnly( ns, 'indexOf', indexOf );\n\n/**\n* @name indexOfSameValue\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/index-of-same-value}\n*/\nimport indexOfSameValue from './../../base/index-of-same-value';\nsetReadOnly( ns, 'indexOfSameValue', indexOfSameValue );\n\n/**\n* @name indicesComplement\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/indices-complement}\n*/\nimport indicesComplement from './../../base/indices-complement';\nsetReadOnly( ns, 'indicesComplement', indicesComplement );\n\n/**\n* @name join\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/join}\n*/\nimport join from './../../base/join';\nsetReadOnly( ns, 'join', join );\n\n/**\n* @name last\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/last}\n*/\nimport last from './../../base/last';\nsetReadOnly( ns, 'last', last );\n\n/**\n* @name lastIndexOf\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/last-index-of}\n*/\nimport lastIndexOf from './../../base/last-index-of';\nsetReadOnly( ns, 'lastIndexOf', lastIndexOf );\n\n/**\n* @name lastIndexOfSameValue\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/last-index-of-same-value}\n*/\nimport lastIndexOfSameValue from './../../base/last-index-of-same-value';\nsetReadOnly( ns, 'lastIndexOfSameValue', lastIndexOfSameValue );\n\n/**\n* @name linspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/linspace}\n*/\nimport linspace from './../../base/linspace';\nsetReadOnly( ns, 'linspace', linspace );\n\n/**\n* @name linspace2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/linspace2d}\n*/\nimport linspace2d from './../../base/linspace2d';\nsetReadOnly( ns, 'linspace2d', linspace2d );\n\n/**\n* @name logspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/logspace}\n*/\nimport logspace from './../../base/logspace';\nsetReadOnly( ns, 'logspace', logspace );\n\n/**\n* @name map2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/map2d}\n*/\nimport map2d from './../../base/map2d';\nsetReadOnly( ns, 'map2d', map2d );\n\n/**\n* @name map3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/map3d}\n*/\nimport map3d from './../../base/map3d';\nsetReadOnly( ns, 'map3d', map3d );\n\n/**\n* @name map4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/map4d}\n*/\nimport map4d from './../../base/map4d';\nsetReadOnly( ns, 'map4d', map4d );\n\n/**\n* @name map5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/map5d}\n*/\nimport map5d from './../../base/map5d';\nsetReadOnly( ns, 'map5d', map5d );\n\n/**\n* @name minSignedIntegerDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/min-signed-integer-dtype}\n*/\nimport minSignedIntegerDataType from './../../base/min-signed-integer-dtype';\nsetReadOnly( ns, 'minSignedIntegerDataType', minSignedIntegerDataType );\n\n/**\n* @name minUnsignedIntegerDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/min-unsigned-integer-dtype}\n*/\nimport minUnsignedIntegerDataType from './../../base/min-unsigned-integer-dtype';\nsetReadOnly( ns, 'minUnsignedIntegerDataType', minUnsignedIntegerDataType );\n\n/**\n* @name mskbinary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskbinary2d}\n*/\nimport mskbinary2d from './../../base/mskbinary2d';\nsetReadOnly( ns, 'mskbinary2d', mskbinary2d );\n\n/**\n* @name mskbinary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskbinary3d}\n*/\nimport mskbinary3d from './../../base/mskbinary3d';\nsetReadOnly( ns, 'mskbinary3d', mskbinary3d );\n\n/**\n* @name mskbinary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskbinary4d}\n*/\nimport mskbinary4d from './../../base/mskbinary4d';\nsetReadOnly( ns, 'mskbinary4d', mskbinary4d );\n\n/**\n* @name mskbinary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskbinary5d}\n*/\nimport mskbinary5d from './../../base/mskbinary5d';\nsetReadOnly( ns, 'mskbinary5d', mskbinary5d );\n\n/**\n* @name mskfilter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskfilter}\n*/\nimport mskfilter from './../../base/mskfilter';\nsetReadOnly( ns, 'mskfilter', mskfilter );\n\n/**\n* @name mskfilterMap\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskfilter-map}\n*/\nimport mskfilterMap from './../../base/mskfilter-map';\nsetReadOnly( ns, 'mskfilterMap', mskfilterMap );\n\n/**\n* @name mskfilter2\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskfilter2}\n*/\nimport mskfilter2 from './../../base/mskfilter2';\nsetReadOnly( ns, 'mskfilter2', mskfilter2 );\n\n/**\n* @name mskfiltern\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskfiltern}\n*/\nimport mskfiltern from './../../base/mskfiltern';\nsetReadOnly( ns, 'mskfiltern', mskfiltern );\n\n/**\n* @name mskput\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskput}\n*/\nimport mskput from './../../base/mskput';\nsetReadOnly( ns, 'mskput', mskput );\n\n/**\n* @name mskreject\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskreject}\n*/\nimport mskreject from './../../base/mskreject';\nsetReadOnly( ns, 'mskreject', mskreject );\n\n/**\n* @name mskunary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskunary2d}\n*/\nimport mskunary2d from './../../base/mskunary2d';\nsetReadOnly( ns, 'mskunary2d', mskunary2d );\n\n/**\n* @name mskunary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskunary3d}\n*/\nimport mskunary3d from './../../base/mskunary3d';\nsetReadOnly( ns, 'mskunary3d', mskunary3d );\n\n/**\n* @name mskunary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskunary4d}\n*/\nimport mskunary4d from './../../base/mskunary4d';\nsetReadOnly( ns, 'mskunary4d', mskunary4d );\n\n/**\n* @name mskunary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/mskunary5d}\n*/\nimport mskunary5d from './../../base/mskunary5d';\nsetReadOnly( ns, 'mskunary5d', mskunary5d );\n\n/**\n* @name nCartesianProduct\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/n-cartesian-product}\n*/\nimport nCartesianProduct from './../../base/n-cartesian-product';\nsetReadOnly( ns, 'nCartesianProduct', nCartesianProduct );\n\n/**\n* @name nested2objects\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/nested2objects}\n*/\nimport nested2objects from './../../base/nested2objects';\nsetReadOnly( ns, 'nested2objects', nested2objects );\n\n/**\n* @name nested2views\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/nested2views}\n*/\nimport nested2views from './../../base/nested2views';\nsetReadOnly( ns, 'nested2views', nested2views );\n\n/**\n* @name none\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/none}\n*/\nimport none from './../../base/none';\nsetReadOnly( ns, 'none', none );\n\n/**\n* @name noneBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/none-by}\n*/\nimport noneBy from './../../base/none-by';\nsetReadOnly( ns, 'noneBy', noneBy );\n\n/**\n* @name noneByRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/none-by-right}\n*/\nimport noneByRight from './../../base/none-by-right';\nsetReadOnly( ns, 'noneByRight', noneByRight );\n\n/**\n* @name nulls\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/nulls}\n*/\nimport nulls from './../../base/nulls';\nsetReadOnly( ns, 'nulls', nulls );\n\n/**\n* @name oneTo\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/one-to}\n*/\nimport oneTo from './../../base/one-to';\nsetReadOnly( ns, 'oneTo', oneTo );\n\n/**\n* @name ones\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ones}\n*/\nimport ones from './../../base/ones';\nsetReadOnly( ns, 'ones', ones );\n\n/**\n* @name ones2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ones2d}\n*/\nimport ones2d from './../../base/ones2d';\nsetReadOnly( ns, 'ones2d', ones2d );\n\n/**\n* @name ones3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ones3d}\n*/\nimport ones3d from './../../base/ones3d';\nsetReadOnly( ns, 'ones3d', ones3d );\n\n/**\n* @name ones4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ones4d}\n*/\nimport ones4d from './../../base/ones4d';\nsetReadOnly( ns, 'ones4d', ones4d );\n\n/**\n* @name ones5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ones5d}\n*/\nimport ones5d from './../../base/ones5d';\nsetReadOnly( ns, 'ones5d', ones5d );\n\n/**\n* @name onesnd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/onesnd}\n*/\nimport onesnd from './../../base/onesnd';\nsetReadOnly( ns, 'onesnd', onesnd );\n\n/**\n* @name place\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/place}\n*/\nimport place from './../../base/place';\nsetReadOnly( ns, 'place', place );\n\n/**\n* @name put\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/put}\n*/\nimport put from './../../base/put';\nsetReadOnly( ns, 'put', put );\n\n/**\n* @name quaternary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quaternary2d}\n*/\nimport quaternary2d from './../../base/quaternary2d';\nsetReadOnly( ns, 'quaternary2d', quaternary2d );\n\n/**\n* @name quaternary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quaternary3d}\n*/\nimport quaternary3d from './../../base/quaternary3d';\nsetReadOnly( ns, 'quaternary3d', quaternary3d );\n\n/**\n* @name quaternary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quaternary4d}\n*/\nimport quaternary4d from './../../base/quaternary4d';\nsetReadOnly( ns, 'quaternary4d', quaternary4d );\n\n/**\n* @name quaternary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quaternary5d}\n*/\nimport quaternary5d from './../../base/quaternary5d';\nsetReadOnly( ns, 'quaternary5d', quaternary5d );\n\n/**\n* @name quinary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quinary2d}\n*/\nimport quinary2d from './../../base/quinary2d';\nsetReadOnly( ns, 'quinary2d', quinary2d );\n\n/**\n* @name quinary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quinary3d}\n*/\nimport quinary3d from './../../base/quinary3d';\nsetReadOnly( ns, 'quinary3d', quinary3d );\n\n/**\n* @name quinary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quinary4d}\n*/\nimport quinary4d from './../../base/quinary4d';\nsetReadOnly( ns, 'quinary4d', quinary4d );\n\n/**\n* @name quinary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/quinary5d}\n*/\nimport quinary5d from './../../base/quinary5d';\nsetReadOnly( ns, 'quinary5d', quinary5d );\n\n/**\n* @name reject\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/reject}\n*/\nimport reject from './../../base/reject';\nsetReadOnly( ns, 'reject', reject );\n\n/**\n* @name rekey\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/rekey}\n*/\nimport rekey from './../../base/rekey';\nsetReadOnly( ns, 'rekey', rekey );\n\n/**\n* @name rekeyViews\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/rekey-views}\n*/\nimport rekeyViews from './../../base/rekey-views';\nsetReadOnly( ns, 'rekeyViews', rekeyViews );\n\n/**\n* @name removeAt\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/remove-at}\n*/\nimport removeAt from './../../base/remove-at';\nsetReadOnly( ns, 'removeAt', removeAt );\n\n/**\n* @name reshape\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/reshape}\n*/\nimport reshape from './../../base/reshape';\nsetReadOnly( ns, 'reshape', reshape );\n\n/**\n* @name resolveGetter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/resolve-getter}\n*/\nimport resolveGetter from './../../base/resolve-getter';\nsetReadOnly( ns, 'resolveGetter', resolveGetter );\n\n/**\n* @name resolveSetter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/resolve-setter}\n*/\nimport resolveSetter from './../../base/resolve-setter';\nsetReadOnly( ns, 'resolveSetter', resolveSetter );\n\n/**\n* @name reverse\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/reverse}\n*/\nimport reverse from './../../base/reverse';\nsetReadOnly( ns, 'reverse', reverse );\n\n/**\n* @name scatterFilled\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/scatter-filled}\n*/\nimport scatterFilled from './../../base/scatter-filled';\nsetReadOnly( ns, 'scatterFilled', scatterFilled );\n\n/**\n* @name scattered\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/scattered}\n*/\nimport scattered from './../../base/scattered';\nsetReadOnly( ns, 'scattered', scattered );\n\n/**\n* @name setter\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/setter}\n*/\nimport setter from './../../base/setter';\nsetReadOnly( ns, 'setter', setter );\n\n/**\n* @name slice\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/slice}\n*/\nimport slice from './../../base/slice';\nsetReadOnly( ns, 'slice', slice );\n\n/**\n* @name strided2array2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/strided2array2d}\n*/\nimport strided2array2d from './../../base/strided2array2d';\nsetReadOnly( ns, 'strided2array2d', strided2array2d );\n\n/**\n* @name strided2array3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/strided2array3d}\n*/\nimport strided2array3d from './../../base/strided2array3d';\nsetReadOnly( ns, 'strided2array3d', strided2array3d );\n\n/**\n* @name strided2array4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/strided2array4d}\n*/\nimport strided2array4d from './../../base/strided2array4d';\nsetReadOnly( ns, 'strided2array4d', strided2array4d );\n\n/**\n* @name strided2array5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/strided2array5d}\n*/\nimport strided2array5d from './../../base/strided2array5d';\nsetReadOnly( ns, 'strided2array5d', strided2array5d );\n\n/**\n* @name symmetric\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/symmetric}\n*/\nimport symmetric from './../../base/symmetric';\nsetReadOnly( ns, 'symmetric', symmetric );\n\n/**\n* @name symmetricBanded\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base/symmetric-banded}\n*/\nimport symmetricBanded from './../../base/symmetric-banded';\nsetReadOnly( ns, 'symmetricBanded', symmetricBanded );\n\n/**\n* @name take\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/take}\n*/\nimport take from './../../base/take';\nsetReadOnly( ns, 'take', take );\n\n/**\n* @name takeIndexed\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/take-indexed}\n*/\nimport takeIndexed from './../../base/take-indexed';\nsetReadOnly( ns, 'takeIndexed', takeIndexed );\n\n/**\n* @name takeIndexed2\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/take-indexed2}\n*/\nimport takeIndexed2 from './../../base/take-indexed2';\nsetReadOnly( ns, 'takeIndexed2', takeIndexed2 );\n\n/**\n* @name take2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/take2d}\n*/\nimport take2d from './../../base/take2d';\nsetReadOnly( ns, 'take2d', take2d );\n\n/**\n* @name take3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/take3d}\n*/\nimport take3d from './../../base/take3d';\nsetReadOnly( ns, 'take3d', take3d );\n\n/**\n* @name ternary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ternary2d}\n*/\nimport ternary2d from './../../base/ternary2d';\nsetReadOnly( ns, 'ternary2d', ternary2d );\n\n/**\n* @name ternary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ternary3d}\n*/\nimport ternary3d from './../../base/ternary3d';\nsetReadOnly( ns, 'ternary3d', ternary3d );\n\n/**\n* @name ternary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ternary4d}\n*/\nimport ternary4d from './../../base/ternary4d';\nsetReadOnly( ns, 'ternary4d', ternary4d );\n\n/**\n* @name ternary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/ternary5d}\n*/\nimport ternary5d from './../../base/ternary5d';\nsetReadOnly( ns, 'ternary5d', ternary5d );\n\n/**\n* @name toAccessorArray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/to-accessor-array}\n*/\nimport toAccessorArray from './../../base/to-accessor-array';\nsetReadOnly( ns, 'toAccessorArray', toAccessorArray );\n\n/**\n* @name toDeduped\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/to-deduped}\n*/\nimport toDeduped from './../../base/to-deduped';\nsetReadOnly( ns, 'toDeduped', toDeduped );\n\n/**\n* @name toReversed\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/to-reversed}\n*/\nimport toReversed from './../../base/to-reversed';\nsetReadOnly( ns, 'toReversed', toReversed );\n\n/**\n* @name unary2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary2d}\n*/\nimport unary2d from './../../base/unary2d';\nsetReadOnly( ns, 'unary2d', unary2d );\n\n/**\n* @name unary2dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary2d-by}\n*/\nimport unary2dBy from './../../base/unary2d-by';\nsetReadOnly( ns, 'unary2dBy', unary2dBy );\n\n/**\n* @name unary3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary3d}\n*/\nimport unary3d from './../../base/unary3d';\nsetReadOnly( ns, 'unary3d', unary3d );\n\n/**\n* @name unary3dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary3d-by}\n*/\nimport unary3dBy from './../../base/unary3d-by';\nsetReadOnly( ns, 'unary3dBy', unary3dBy );\n\n/**\n* @name unary4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary4d}\n*/\nimport unary4d from './../../base/unary4d';\nsetReadOnly( ns, 'unary4d', unary4d );\n\n/**\n* @name unary4dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary4d-by}\n*/\nimport unary4dBy from './../../base/unary4d-by';\nsetReadOnly( ns, 'unary4dBy', unary4dBy );\n\n/**\n* @name unary5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary5d}\n*/\nimport unary5d from './../../base/unary5d';\nsetReadOnly( ns, 'unary5d', unary5d );\n\n/**\n* @name unary5dBy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unary5d-by}\n*/\nimport unary5dBy from './../../base/unary5d-by';\nsetReadOnly( ns, 'unary5dBy', unary5dBy );\n\n/**\n* @name unarynd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unarynd}\n*/\nimport unarynd from './../../base/unarynd';\nsetReadOnly( ns, 'unarynd', unarynd );\n\n/**\n* @name unitspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/unitspace}\n*/\nimport unitspace from './../../base/unitspace';\nsetReadOnly( ns, 'unitspace', unitspace );\n\n/**\n* @name where\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/where}\n*/\nimport where from './../../base/where';\nsetReadOnly( ns, 'where', where );\n\n/**\n* @name arrayWith\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/with}\n*/\nimport arrayWith from './../../base/with';\nsetReadOnly( ns, 'arrayWith', arrayWith );\n\n/**\n* @name without\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/without}\n*/\nimport without from './../../base/without';\nsetReadOnly( ns, 'without', without );\n\n/**\n* @name zeroTo\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zero-to}\n*/\nimport zeroTo from './../../base/zero-to';\nsetReadOnly( ns, 'zeroTo', zeroTo );\n\n/**\n* @name zeros\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zeros}\n*/\nimport zeros from './../../base/zeros';\nsetReadOnly( ns, 'zeros', zeros );\n\n/**\n* @name zeros2d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zeros2d}\n*/\nimport zeros2d from './../../base/zeros2d';\nsetReadOnly( ns, 'zeros2d', zeros2d );\n\n/**\n* @name zeros3d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zeros3d}\n*/\nimport zeros3d from './../../base/zeros3d';\nsetReadOnly( ns, 'zeros3d', zeros3d );\n\n/**\n* @name zeros4d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zeros4d}\n*/\nimport zeros4d from './../../base/zeros4d';\nsetReadOnly( ns, 'zeros4d', zeros4d );\n\n/**\n* @name zeros5d\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zeros5d}\n*/\nimport zeros5d from './../../base/zeros5d';\nsetReadOnly( ns, 'zeros5d', zeros5d );\n\n/**\n* @name zerosnd\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zerosnd}\n*/\nimport zerosnd from './../../base/zerosnd';\nsetReadOnly( ns, 'zerosnd', zerosnd );\n\n/**\n* @name zip\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zip}\n*/\nimport zip from './../../base/zip';\nsetReadOnly( ns, 'zip', zip );\n\n/**\n* @name zip2object\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zip2object}\n*/\nimport zip2object from './../../base/zip2object';\nsetReadOnly( ns, 'zip2object', zip2object );\n\n/**\n* @name zip2objects\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zip2objects}\n*/\nimport zip2objects from './../../base/zip2objects';\nsetReadOnly( ns, 'zip2objects', zip2objects );\n\n/**\n* @name zip2views\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/base/zip2views}\n*/\nimport zip2views from './../../base/zip2views';\nsetReadOnly( ns, 'zip2views', zip2views );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'some' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = anyBy( x, isPositive );\n* // returns true\n*/\nfunction anyBy( x, predicate, thisArg ) {\n\tvar obj;\n\tif ( hasMethod( x, 'some' ) ) {\n\t\treturn x.some( predicate, thisArg );\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default anyBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = x.length-1; i >= 0; i-- ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 1, 0 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = data.length-1; i >= 0; i-- ) {\n\t\tif ( predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in an array passes a test implemented by a predicate function, while iterating from right to left.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether at least one element passes a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 1, 0 ];\n*\n* var out = anyByRight( x, isPositive );\n* // returns true\n*/\nfunction anyByRight( x, predicate, thisArg ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default anyByRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in a provided indexed array has a specified own property.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = indexed( [ o1, o2, o3 ], 'b' );\n* // returns true\n*\n* bool = indexed( [ o1, o2, o3 ], 'd' );\n* // returns false\n*\n* bool = indexed( [ o1, o2, o3 ], 'toString' );\n* // returns false\n*/\nfunction indexed( arr, prop ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( hasOwnProp( arr[ i ], prop ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in a provided accessor array has a specified own property.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b' );\n* // returns true\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd' );\n* // returns false\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'toString' );\n* // returns false\n*/\nfunction accessors( arr, prop ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( arr );\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( hasOwnProp( get( arr, i ), prop ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in a provided array has a specified own property.\n*\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = anyHasOwnProp( [ o1, o2, o3 ], 'b' );\n* // returns true\n*\n* bool = anyHasOwnProp( [ o1, o2, o3 ], 'd' );\n* // returns false\n*\n* bool = anyHasOwnProp( [ o1, o2, o3 ], 'toString' );\n* // returns false\n*/\nfunction anyHasOwnProp( arr, prop ) {\n\tif ( isAccessorArray( arr ) ) {\n\t\treturn accessors( arr, prop );\n\t}\n\treturn indexed( arr, prop );\n}\n\n\n// EXPORTS //\n\nexport default anyHasOwnProp;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport hasProp from '@stdlib/assert/has-property';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in a provided indexed array has a specified property, either own or inherited.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = indexed( [ o1, o2, o3 ], 'b' );\n* // returns true\n*\n* bool = indexed( [ o1, o2, o3 ], 'd' );\n* // returns false\n*\n* bool = indexed( [ o1, o2, o3 ], 'toString' );\n* // returns true\n*/\nfunction indexed( arr, prop ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( hasProp( arr[ i ], prop ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in a provided accessor array has a specified property, either own or inherited.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b' );\n* // returns true\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd' );\n* // returns false\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'toString' );\n* // returns true\n*/\nfunction accessors( arr, prop ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( arr );\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( hasProp( get( arr, i ), prop ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in a provided array has a specified property, either own or inherited.\n*\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = anyHasProp( [ o1, o2, o3 ], 'b' );\n* // returns true\n*\n* bool = anyHasProp( [ o1, o2, o3 ], 'd' );\n* // returns false\n*\n* bool = anyHasProp( [ o1, o2, o3 ], 'toString' );\n* // returns true\n*/\nfunction anyHasProp( arr, prop ) {\n\tif ( isAccessorArray( arr ) ) {\n\t\treturn accessors( arr, prop );\n\t}\n\treturn indexed( arr, prop );\n}\n\n\n// EXPORTS //\n\nexport default anyHasProp;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in a provided indexed array has a specified own property key-value pair.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = indexed( [ o1, o2, o3 ], 'b', 2 );\n* // returns true\n*\n* bool = indexed( [ o1, o2, o3 ], 'b', 3 );\n* // returns false\n*\n* bool = indexed( [ o1, o2, o3 ], 'd', 0 );\n* // returns false\n*/\nfunction indexed( arr, prop, value ) {\n\tvar v;\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tv = arr[ i ];\n\t\tif ( hasOwnProp( v, prop ) && v[ prop ] === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in a provided accessor array has a specified own property key-value pair.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 2 );\n* // returns true\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 3 );\n* // returns false\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd', 0 );\n* // returns false\n*/\nfunction accessors( arr, prop, value ) {\n\tvar get;\n\tvar v;\n\tvar i;\n\n\tget = resolveGetter( arr );\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tv = get( arr, i );\n\t\tif ( hasOwnProp( v, prop ) && v[ prop ] === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in a provided array has a specified own property key-value pair.\n*\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = anyIsEntry( [ o1, o2, o3 ], 'b', 2 );\n* // returns true\n*\n* bool = anyIsEntry( [ o1, o2, o3 ], 'b', 3 );\n* // returns false\n*\n* bool = anyIsEntry( [ o1, o2, o3 ], 'd', 0 );\n* // returns false\n*/\nfunction anyIsEntry( arr, prop, value ) {\n\tif ( isAccessorArray( arr ) ) {\n\t\treturn accessors( arr, prop, value );\n\t}\n\treturn indexed( arr, prop, value );\n}\n\n\n// EXPORTS //\n\nexport default anyIsEntry;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport hasProp from '@stdlib/assert/has-property';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether at least one element in a provided indexed array has a specified property key-value pair, either own or inherited.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = indexed( [ o1, o2, o3 ], 'b', 2 );\n* // returns true\n*\n* bool = indexed( [ o1, o2, o3 ], 'b', 3 );\n* // returns false\n*\n* bool = indexed( [ o1, o2, o3 ], 'd', 0 );\n* // returns false\n*/\nfunction indexed( arr, prop, value ) {\n\tvar v;\n\tvar i;\n\tif ( value === void 0 ) {\n\t\tfor ( i = 0; i < arr.length; i++ ) {\n\t\t\tv = arr[ i ];\n\t\t\tif ( hasProp( v, prop ) && v[ prop ] === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( arr[ i ][ prop ] === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n/**\n* Tests whether at least one element in a provided accessor array has a specified property key-value pair, either own or inherited.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 2 );\n* // returns true\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'b', 3 );\n* // returns false\n*\n* bool = accessors( toAccessorArray( [ o1, o2, o3 ] ), 'd', 0 );\n* // returns false\n*/\nfunction accessors( arr, prop, value ) {\n\tvar get;\n\tvar v;\n\tvar i;\n\n\tget = resolveGetter( arr );\n\tif ( value === void 0 ) {\n\t\tfor ( i = 0; i < arr.length; i++ ) {\n\t\t\tv = get( arr, i );\n\t\t\tif ( hasProp( v, prop ) && v[ prop ] === value ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tif ( get( arr, i )[ prop ] === value ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether at least one element in a provided array has a specified property key-value pair, either own or inherited.\n*\n* @param {Collection} arr - input array\n* @param {(string|symbol|number)} prop - property\n* @param {*} value - property value\n* @returns {boolean} result\n*\n* @example\n* var o1 = {\n* 'a': 1\n* };\n* var o2 = {\n* 'b': 2\n* };\n* var o3 = {\n* 'c': 3\n* };\n*\n* var bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 2 );\n* // returns true\n*\n* bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 3 );\n* // returns false\n*\n* bool = anyIsEntryIn( [ o1, o2, o3 ], 'd', 0 );\n* // returns false\n*/\nfunction anyIsEntryIn( arr, prop, value ) {\n\tif ( isAccessorArray( arr ) ) {\n\t\treturn accessors( arr, prop, value );\n\t}\n\treturn indexed( arr, prop, value );\n}\n\n\n// EXPORTS //\n\nexport default anyIsEntryIn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'map' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n\n// MAIN //\n\n/**\n* Returns an element from an array.\n*\n* @param {Collection} x - input array\n* @param {integer} index - element index\n* @returns {*} array element\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var v = at( x, 0 );\n* // returns 1\n*\n* v = at( x, 1 );\n* // returns 2\n*\n* v = at( x, -2 );\n* // returns 3\n*/\nfunction at( x, index ) {\n\tvar get;\n\tif ( hasMethod( x, 'at' ) ) {\n\t\treturn x.at( index );\n\t}\n\tif ( index < 0 ) {\n\t\tindex += x.length;\n\t\tif ( index < 0 ) {\n\t\t\treturn;\n\t\t}\n\t} else if ( index >= x.length ) {\n\t\treturn;\n\t}\n\tget = resolveGetter( x );\n\treturn get( x, index );\n}\n\n\n// EXPORTS //\n\nexport default at;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an element from a two-dimensional nested array.\n*\n* @param {ArrayLikeObject} x - input array\n* @param {integer} i0 - first dimension index\n* @param {integer} i1 - second dimension index\n* @returns {*} nested array element\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var v = at2d( x, 0, 1 );\n* // returns 2\n*\n* v = at2d( x, 1, 0 );\n* // returns 3\n*\n* v = at2d( x, -2, -2 );\n* // returns 1\n*/\nfunction at2d( x, i0, i1 ) {\n\tvar x0;\n\tvar N;\n\n\tN = x.length;\n\tif ( i0 < 0 ) {\n\t\ti0 += N;\n\t}\n\tif ( i0 < 0 || i0 >= N ) {\n\t\treturn;\n\t}\n\tx0 = x[ i0 ];\n\tN = x0.length;\n\tif ( i1 < 0 ) {\n\t\ti1 += N;\n\t}\n\tif ( i1 < 0 || i1 >= N ) {\n\t\treturn;\n\t}\n\treturn x0[ i1 ];\n}\n\n\n// EXPORTS //\n\nexport default at2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an element from a three-dimensional nested array.\n*\n* @param {ArrayLikeObject>} x - input array\n* @param {integer} i0 - first dimension index\n* @param {integer} i1 - second dimension index\n* @param {integer} i2 - third dimension index\n* @returns {*} nested array element\n*\n* @example\n* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ];\n*\n* var v = at3d( x, 0, 0, 1 );\n* // returns 2\n*\n* v = at3d( x, 0, 1, 0 );\n* // returns 3\n*\n* v = at3d( x, 0, -2, -2 );\n* // returns 1\n*/\nfunction at3d( x, i0, i1, i2 ) {\n\tvar x0;\n\tvar x1;\n\tvar N;\n\n\tN = x.length;\n\tif ( i0 < 0 ) {\n\t\ti0 += N;\n\t}\n\tif ( i0 < 0 || i0 >= N ) {\n\t\treturn;\n\t}\n\tx0 = x[ i0 ];\n\tN = x0.length;\n\tif ( i1 < 0 ) {\n\t\ti1 += N;\n\t}\n\tif ( i1 < 0 || i1 >= N ) {\n\t\treturn;\n\t}\n\tx1 = x0[ i1 ];\n\tN = x1.length;\n\tif ( i2 < 0 ) {\n\t\ti2 += N;\n\t}\n\tif ( i2 < 0 || i2 >= N ) {\n\t\treturn;\n\t}\n\treturn x1[ i2 ];\n}\n\n\n// EXPORTS //\n\nexport default at3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an element from a four-dimensional nested array.\n*\n* @param {ArrayLikeObject>>} x - input array\n* @param {integer} i0 - first dimension index\n* @param {integer} i1 - second dimension index\n* @param {integer} i2 - third dimension index\n* @param {integer} i3 - fourth dimension index\n* @returns {*} nested array element\n*\n* @example\n* var x = [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ];\n*\n* var v = at4d( x, 0, 0, 0, 1 );\n* // returns 2\n*\n* v = at4d( x, 0, 0, 1, 0 );\n* // returns 3\n*\n* v = at4d( x, 0, 0, -2, -2 );\n* // returns 1\n*/\nfunction at4d( x, i0, i1, i2, i3 ) {\n\tvar value;\n\tvar idx;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tidx = [ i0, i1, i2, i3 ];\n\tvalue = x;\n\tfor ( i = 0; i < idx.length; i++ ) {\n\t\tj = idx[ i ];\n\t\tN = value.length;\n\t\tif ( j < 0 ) {\n\t\t\tj += N;\n\t\t}\n\t\tif ( j < 0 || j >= N ) {\n\t\t\treturn;\n\t\t}\n\t\tvalue = value[ j ];\n\t}\n\treturn value;\n}\n\n\n// EXPORTS //\n\nexport default at4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an element from a five-dimensional nested array.\n*\n* @param {ArrayLikeObject>>>} x - input array\n* @param {integer} i0 - first dimension index\n* @param {integer} i1 - second dimension index\n* @param {integer} i2 - third dimension index\n* @param {integer} i3 - fourth dimension index\n* @param {integer} i4 - fifth dimension index\n* @returns {*} nested array element\n*\n* @example\n* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ] ] ] ] ];\n*\n* var v = at5d( x, 0, 0, 0, 0, 1 );\n* // returns 2\n*\n* v = at5d( x, 0, 0, 0, 1, 0 );\n* // returns 3\n*\n* v = at5d( x, 0, 0, 0, -2, -2 );\n* // returns 1\n*/\nfunction at5d( x, i0, i1, i2, i3, i4 ) {\n\tvar value;\n\tvar idx;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tidx = [ i0, i1, i2, i3, i4 ];\n\tvalue = x;\n\tfor ( i = 0; i < idx.length; i++ ) {\n\t\tj = idx[ i ];\n\t\tN = value.length;\n\t\tif ( j < 0 ) {\n\t\t\tj += N;\n\t\t}\n\t\tif ( j < 0 || j >= N ) {\n\t\t\treturn;\n\t\t}\n\t\tvalue = value[ j ];\n\t}\n\treturn value;\n}\n\n\n// EXPORTS //\n\nexport default at5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an element from an n-dimensional nested array.\n*\n* @param {ArrayLikeObject} x - input array\n* @param {integer} i0 - first dimension index\n* @param {...integer} indices - dimension indices\n* @returns {*} nested array element\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n*\n* var v = atnd( x, 0, 1 );\n* // returns 2\n*\n* v = atnd( x, 1, 0 );\n* // returns 3\n*\n* v = atnd( x, -2, -2 );\n* // returns 1\n*/\nfunction atnd( x, i0 ) {\n\tvar value;\n\tvar idx;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tidx = [ i0 ];\n\tfor ( i = 2; i < arguments.length; i++ ) {\n\t\tidx.push( arguments[ i ] );\n\t}\n\tvalue = x;\n\tfor ( i = 0; i < idx.length; i++ ) {\n\t\tj = idx[ i ];\n\t\tN = value.length;\n\t\tif ( j < 0 ) {\n\t\t\tj += N;\n\t\t}\n\t\tif ( j < 0 || j >= N ) {\n\t\t\treturn;\n\t\t}\n\t\tvalue = value[ j ];\n\t}\n\treturn value;\n}\n\n\n// EXPORTS //\n\nexport default atnd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits array element entries into two groups.\n*\n* @param {Collection} x - input array\n* @param {Collection} filter - array indicating which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {ArrayArray} results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var filter = [ true, true, false, true ];\n*\n* var out = bifurcateEntries( x, filter );\n* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ]\n*/\nfunction bifurcateEntries( x, filter ) {\n\tvar xget;\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( filter.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tgget = resolveGetter( filter );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = xget( x, i );\n\t\tg = gget( filter, i );\n\t\tif ( g ) {\n\t\t\tout[ 0 ].push( [ i, v ] );\n\t\t} else {\n\t\t\tout[ 1 ].push( [ i, v ] );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateEntries;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits element entries into two groups according to a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - predicate function execution context\n* @returns {Object} group results\n*\n* @example\n* function predicate( v ) {\n* return v[ 0 ] === 'b';\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = bifurcateEntriesBy( x, predicate );\n* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ]\n*/\nfunction bifurcateEntriesBy( x, predicate, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = get( x, i );\n\t\tif ( predicate.call( thisArg, v, i, x ) ) {\n\t\t\tout[ 0 ].push( [ i, v ] );\n\t\t} else {\n\t\t\tout[ 1 ].push( [ i, v ] );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateEntriesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits array element indices into two groups.\n*\n* @param {Collection} x - input array\n* @param {Collection} filter - array indicating which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {ArrayArray} results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var filter = [ true, true, false, true ];\n*\n* var out = bifurcateIndices( x, filter );\n* // returns [ [ 0, 1, 3 ], [ 2 ] ]\n*/\nfunction bifurcateIndices( x, filter ) {\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( filter.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve accessors for retrieving array elements:\n\tgget = resolveGetter( filter );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tg = gget( filter, i );\n\t\tif ( g ) {\n\t\t\tout[ 0 ].push( i );\n\t\t} else {\n\t\t\tout[ 1 ].push( i );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateIndices;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits element indices into two groups according to a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - predicate function execution context\n* @returns {Object} group results\n*\n* @example\n* function predicate( v ) {\n* return v[ 0 ] === 'b';\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = bifurcateIndicesBy( x, predicate );\n* // returns [ [ 0, 1, 3 ], [ 2 ] ]\n*/\nfunction bifurcateIndicesBy( x, predicate, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tout[ 0 ].push( i );\n\t\t} else {\n\t\t\tout[ 1 ].push( i );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateIndicesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits array element values into two groups.\n*\n* @param {Collection} x - input array\n* @param {Collection} filter - array indicating which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {ArrayArray} results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var filter = [ true, true, false, true ];\n*\n* var out = bifurcateValues( x, filter );\n* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]\n*/\nfunction bifurcateValues( x, filter ) {\n\tvar xget;\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( filter.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tgget = resolveGetter( filter );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = xget( x, i );\n\t\tg = gget( filter, i );\n\t\tif ( g ) {\n\t\t\tout[ 0 ].push( v );\n\t\t} else {\n\t\t\tout[ 1 ].push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateValues;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Splits element values into two groups according to a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - predicate function execution context\n* @returns {Object} group results\n*\n* @example\n* function predicate( v ) {\n* return v[ 0 ] === 'b';\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = bifurcateValuesBy( x, predicate );\n* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]\n*/\nfunction bifurcateValuesBy( x, predicate, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = [ [], [] ];\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = get( x, i );\n\t\tif ( predicate.call( thisArg, v, i, x ) ) {\n\t\t\tout[ 0 ].push( v );\n\t\t} else {\n\t\t\tout[ 1 ].push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default bifurcateValuesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = ones2d( shape );\n* var z = zeros2d( shape );\n*\n* binary2d( [ x, y, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ]\n*/\nfunction binary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tz0 = z[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default binary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 2, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = ones3d( shape );\n* var z = zeros3d( shape );\n*\n* binary3d( [ x, y, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ]\n*/\nfunction binary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar z0;\n\tvar z1;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tz1 = z[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default binary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 1, 2, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = ones4d( shape );\n* var z = zeros4d( shape );\n*\n* binary4d( [ x, y, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ]\n*/\nfunction binary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tz2 = z[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default binary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 1, 1, 2, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = ones5d( shape );\n* var z = zeros5d( shape );\n*\n* binary5d( [ x, y, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ]\n*/\nfunction binary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar z3;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tz3 = z[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default binary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shapes = [\n* [ 1, 2 ],\n* [ 2, 1 ],\n* [ 2, 2 ]\n* ];\n*\n* var x = ones2d( shapes[ 0 ] );\n* var y = ones2d( shapes[ 1 ] );\n* var z = zeros2d( shapes[ 2 ] );\n*\n* bbinary2d( [ x, y, z ], shapes, add );\n*\n* console.log( z );\n* // => [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ]\n*/\nfunction bbinary2d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dy0;\n\tvar dy1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar j0;\n\tvar j1;\n\tvar k0;\n\tvar k1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tsh = shapes[ 2 ];\n\tS0 = sh[ 1 ];\n\tS1 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 1 ];\n\tdx1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 1 ];\n\tdy1 = st[ 0 ];\n\n\tz = arrays[ 2 ];\n\n\tj1 = 0;\n\tk1 = 0;\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tj0 = 0;\n\t\tk0 = 0;\n\t\tx0 = x[ j1 ];\n\t\ty0 = y[ k1 ];\n\t\tz0 = z[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tz0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] );\n\t\t\tj0 += dx0;\n\t\t\tk0 += dy0;\n\t\t}\n\t\tj1 += dx1;\n\t\tk1 += dy1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bbinary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shapes = [\n* [ 1, 1, 2 ],\n* [ 2, 1, 1 ],\n* [ 2, 2, 2 ]\n* ];\n*\n* var x = ones3d( shapes[ 0 ] );\n* var y = ones3d( shapes[ 1 ] );\n* var z = zeros3d( shapes[ 2 ] );\n*\n* bbinary3d( [ x, y, z ], shapes, add );\n*\n* console.log( z );\n* // => [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ]\n*/\nfunction bbinary3d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar z0;\n\tvar z1;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tsh = shapes[ 2 ];\n\tS0 = sh[ 2 ];\n\tS1 = sh[ 1 ];\n\tS2 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 2 ];\n\tdx1 = st[ 1 ];\n\tdx2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 2 ];\n\tdy1 = st[ 1 ];\n\tdy2 = st[ 0 ];\n\n\tz = arrays[ 2 ];\n\n\tj2 = 0;\n\tk2 = 0;\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tj1 = 0;\n\t\tk1 = 0;\n\t\tx1 = x[ j2 ];\n\t\ty1 = y[ k2 ];\n\t\tz1 = z[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tj0 = 0;\n\t\t\tk0 = 0;\n\t\t\tx0 = x1[ j1 ];\n\t\t\ty0 = y1[ k1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tz0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] );\n\t\t\t\tj0 += dx0;\n\t\t\t\tk0 += dy0;\n\t\t\t}\n\t\t\tj1 += dx1;\n\t\t\tk1 += dy1;\n\t\t}\n\t\tj2 += dx2;\n\t\tk2 += dy2;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bbinary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shapes = [\n* [ 1, 1, 1, 2 ],\n* [ 1, 2, 1, 1 ],\n* [ 1, 2, 2, 2 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = ones4d( shapes[ 1 ] );\n* var z = zeros4d( shapes[ 2 ] );\n*\n* bbinary4d( [ x, y, z ], shapes, add );\n*\n* console.log( z );\n* // => [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ]\n*/\nfunction bbinary4d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tsh = shapes[ 2 ];\n\tS0 = sh[ 3 ];\n\tS1 = sh[ 2 ];\n\tS2 = sh[ 1 ];\n\tS3 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 3 ];\n\tdx1 = st[ 2 ];\n\tdx2 = st[ 1 ];\n\tdx3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 3 ];\n\tdy1 = st[ 2 ];\n\tdy2 = st[ 1 ];\n\tdy3 = st[ 0 ];\n\n\tz = arrays[ 2 ];\n\n\tj3 = 0;\n\tk3 = 0;\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tj2 = 0;\n\t\tk2 = 0;\n\t\tx2 = x[ j3 ];\n\t\ty2 = y[ k3 ];\n\t\tz2 = z[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tj1 = 0;\n\t\t\tk1 = 0;\n\t\t\tx1 = x2[ j2 ];\n\t\t\ty1 = y2[ k2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tj0 = 0;\n\t\t\t\tk0 = 0;\n\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tz0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] );\n\t\t\t\t\tj0 += dx0;\n\t\t\t\t\tk0 += dy0;\n\t\t\t\t}\n\t\t\t\tj1 += dx1;\n\t\t\t\tk1 += dy1;\n\t\t\t}\n\t\t\tj2 += dx2;\n\t\t\tk2 += dy2;\n\t\t}\n\t\tj3 += dx3;\n\t\tk3 += dy3;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bbinary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two broadcasted input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing two input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shapes = [\n* [ 1, 1, 1, 1, 2 ],\n* [ 1, 1, 2, 1, 1 ],\n* [ 1, 1, 2, 2, 2 ]\n* ];\n*\n* var x = ones5d( shapes[ 0 ] );\n* var y = ones5d( shapes[ 1 ] );\n* var z = zeros5d( shapes[ 2 ] );\n*\n* bbinary5d( [ x, y, z ], shapes, add );\n*\n* console.log( z );\n* // => [ [ [ [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ], [ [ 2.0, 2.0 ], [ 2.0, 2.0 ] ] ] ] ]\n*/\nfunction bbinary5d( arrays, shapes, fcn ) { // eslint-disable-line max-statements\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dx4;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dy4;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar j4;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar k4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar z3;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\n\tsh = shapes[ 2 ];\n\tS0 = sh[ 4 ];\n\tS1 = sh[ 3 ];\n\tS2 = sh[ 2 ];\n\tS3 = sh[ 1 ];\n\tS4 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 4 ];\n\tdx1 = st[ 3 ];\n\tdx2 = st[ 2 ];\n\tdx3 = st[ 1 ];\n\tdx4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 4 ];\n\tdy1 = st[ 3 ];\n\tdy2 = st[ 2 ];\n\tdy3 = st[ 1 ];\n\tdy4 = st[ 0 ];\n\n\tz = arrays[ 2 ];\n\n\tj4 = 0;\n\tk4 = 0;\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tj3 = 0;\n\t\tk3 = 0;\n\t\tx3 = x[ j4 ];\n\t\ty3 = y[ k4 ];\n\t\tz3 = z[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tj2 = 0;\n\t\t\tk2 = 0;\n\t\t\tx2 = x3[ j3 ];\n\t\t\ty2 = y3[ k3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tj1 = 0;\n\t\t\t\tk1 = 0;\n\t\t\t\tx1 = x2[ j2 ];\n\t\t\t\ty1 = y2[ k2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tj0 = 0;\n\t\t\t\t\tk0 = 0;\n\t\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tz0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ] );\n\t\t\t\t\t\tj0 += dx0;\n\t\t\t\t\t\tk0 += dy0;\n\t\t\t\t\t}\n\t\t\t\t\tj1 += dx1;\n\t\t\t\t\tk1 += dy1;\n\t\t\t\t}\n\t\t\t\tj2 += dx2;\n\t\t\t\tk2 += dy2;\n\t\t\t}\n\t\t\tj3 += dx3;\n\t\t\tk3 += dy3;\n\t\t}\n\t\tj4 += dx4;\n\t\tk4 += dy4;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bbinary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* var shapes = [\n* [ 1, 2 ],\n* [ 2, 1 ],\n* [ 1, 1 ],\n* [ 2, 2 ],\n* [ 2, 2 ]\n* ];\n*\n* var x = ones2d( shapes[ 0 ] );\n* var y = ones2d( shapes[ 1 ] );\n* var z = ones2d( shapes[ 2 ] );\n* var w = ones2d( shapes[ 3 ] );\n* var out = zeros2d( shapes[ 4 ] );\n*\n* bquaternary2d( [ x, y, z, w, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ]\n*/\nfunction bquaternary2d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dy0;\n\tvar dy1;\n\tvar dz0;\n\tvar dz1;\n\tvar dw0;\n\tvar dw1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar j0;\n\tvar j1;\n\tvar k0;\n\tvar k1;\n\tvar m0;\n\tvar m1;\n\tvar n0;\n\tvar n1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\n\tsh = shapes[ 4 ];\n\tS0 = sh[ 1 ];\n\tS1 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 1 ];\n\tdx1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 1 ];\n\tdy1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 1 ];\n\tdz1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 1 ];\n\tdw1 = st[ 0 ];\n\n\tu = arrays[ 4 ];\n\n\tj1 = 0;\n\tk1 = 0;\n\tm1 = 0;\n\tn1 = 0;\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tj0 = 0;\n\t\tk0 = 0;\n\t\tm0 = 0;\n\t\tn0 = 0;\n\t\tx0 = x[ j1 ];\n\t\ty0 = y[ k1 ];\n\t\tz0 = z[ m1 ];\n\t\tw0 = w[ n1 ];\n\t\tu0 = u[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tu0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] );\n\t\t\tj0 += dx0;\n\t\t\tk0 += dy0;\n\t\t\tm0 += dz0;\n\t\t\tn0 += dw0;\n\t\t}\n\t\tj1 += dx1;\n\t\tk1 += dy1;\n\t\tm1 += dz1;\n\t\tn1 += dw1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquaternary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* var shapes = [\n* [ 1, 1, 3 ],\n* [ 3, 1, 1 ],\n* [ 1, 3, 1 ],\n* [ 3, 3, 3 ],\n* [ 3, 3, 3 ]\n* ];\n*\n* var x = ones3d( shapes[ 0 ] );\n* var y = ones3d( shapes[ 1 ] );\n* var z = ones3d( shapes[ 2 ] );\n* var w = ones3d( shapes[ 3 ] );\n* var out = zeros3d( shapes[ 4 ] );\n*\n* bquaternary3d( [ x, y, z, w, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ]\n*/\nfunction bquaternary3d( arrays, shapes, fcn ) { // eslint-disable-line max-statements\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dw0;\n\tvar dw1;\n\tvar dw2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar n0;\n\tvar n1;\n\tvar n2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar z0;\n\tvar z1;\n\tvar w0;\n\tvar w1;\n\tvar u0;\n\tvar u1;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\n\tsh = shapes[ 4 ];\n\tS0 = sh[ 2 ];\n\tS1 = sh[ 1 ];\n\tS2 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 2 ];\n\tdx1 = st[ 1 ];\n\tdx2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 2 ];\n\tdy1 = st[ 1 ];\n\tdy2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 2 ];\n\tdz1 = st[ 1 ];\n\tdz2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 2 ];\n\tdw1 = st[ 1 ];\n\tdw2 = st[ 0 ];\n\n\tu = arrays[ 4 ];\n\n\tj2 = 0;\n\tk2 = 0;\n\tm2 = 0;\n\tn2 = 0;\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tj1 = 0;\n\t\tk1 = 0;\n\t\tm1 = 0;\n\t\tn1 = 0;\n\t\tx1 = x[ j2 ];\n\t\ty1 = y[ k2 ];\n\t\tz1 = z[ m2 ];\n\t\tw1 = w[ n2 ];\n\t\tu1 = u[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tj0 = 0;\n\t\t\tk0 = 0;\n\t\t\tm0 = 0;\n\t\t\tn0 = 0;\n\t\t\tx0 = x1[ j1 ];\n\t\t\ty0 = y1[ k1 ];\n\t\t\tz0 = z1[ m1 ];\n\t\t\tw0 = w1[ n1 ];\n\t\t\tu0 = u1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tu0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] );\n\t\t\t\tj0 += dx0;\n\t\t\t\tk0 += dy0;\n\t\t\t\tm0 += dz0;\n\t\t\t\tn0 += dw0;\n\t\t\t}\n\t\t\tj1 += dx1;\n\t\t\tk1 += dy1;\n\t\t\tm1 += dz1;\n\t\t\tn1 += dw1;\n\t\t}\n\t\tj2 += dx2;\n\t\tk2 += dy2;\n\t\tm2 += dz2;\n\t\tn2 += dw2;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquaternary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* var shapes = [\n* [ 1, 3, 1, 1 ],\n* [ 1, 1, 3, 1 ],\n* [ 1, 1, 1, 3 ],\n* [ 1, 1, 1, 1 ],\n* [ 1, 3, 3, 3 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = ones4d( shapes[ 1 ] );\n* var z = ones4d( shapes[ 2 ] );\n* var w = ones4d( shapes[ 3 ] );\n* var out = zeros4d( shapes[ 4 ] );\n*\n* bquaternary4d( [ x, y, z, w, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ]\n*/\nfunction bquaternary4d( arrays, shapes, fcn ) { // eslint-disable-line max-statements\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dz3;\n\tvar dw0;\n\tvar dw1;\n\tvar dw2;\n\tvar dw3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar n0;\n\tvar n1;\n\tvar n2;\n\tvar n3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar w0;\n\tvar w1;\n\tvar w2;\n\tvar u0;\n\tvar u1;\n\tvar u2;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\n\tsh = shapes[ 4 ];\n\tS0 = sh[ 3 ];\n\tS1 = sh[ 2 ];\n\tS2 = sh[ 1 ];\n\tS3 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 3 ];\n\tdx1 = st[ 2 ];\n\tdx2 = st[ 1 ];\n\tdx3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 3 ];\n\tdy1 = st[ 2 ];\n\tdy2 = st[ 1 ];\n\tdy3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 3 ];\n\tdz1 = st[ 2 ];\n\tdz2 = st[ 1 ];\n\tdz3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 3 ];\n\tdw1 = st[ 2 ];\n\tdw2 = st[ 1 ];\n\tdw3 = st[ 0 ];\n\n\tu = arrays[ 4 ];\n\n\tj3 = 0;\n\tk3 = 0;\n\tm3 = 0;\n\tn3 = 0;\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tj2 = 0;\n\t\tk2 = 0;\n\t\tm2 = 0;\n\t\tn2 = 0;\n\t\tx2 = x[ j3 ];\n\t\ty2 = y[ k3 ];\n\t\tz2 = z[ m3 ];\n\t\tw2 = w[ n3 ];\n\t\tu2 = u[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tj1 = 0;\n\t\t\tk1 = 0;\n\t\t\tm1 = 0;\n\t\t\tn1 = 0;\n\t\t\tx1 = x2[ j2 ];\n\t\t\ty1 = y2[ k2 ];\n\t\t\tz1 = z2[ m2 ];\n\t\t\tw1 = w2[ n2 ];\n\t\t\tu1 = u2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tj0 = 0;\n\t\t\t\tk0 = 0;\n\t\t\t\tm0 = 0;\n\t\t\t\tn0 = 0;\n\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\tz0 = z1[ m1 ];\n\t\t\t\tw0 = w1[ n1 ];\n\t\t\t\tu0 = u1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tu0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] );\n\t\t\t\t\tj0 += dx0;\n\t\t\t\t\tk0 += dy0;\n\t\t\t\t\tm0 += dz0;\n\t\t\t\t\tn0 += dw0;\n\t\t\t\t}\n\t\t\t\tj1 += dx1;\n\t\t\t\tk1 += dy1;\n\t\t\t\tm1 += dz1;\n\t\t\t\tn1 += dw1;\n\t\t\t}\n\t\t\tj2 += dx2;\n\t\t\tk2 += dy2;\n\t\t\tm2 += dz2;\n\t\t\tn2 += dw2;\n\t\t}\n\t\tj3 += dx3;\n\t\tk3 += dy3;\n\t\tm3 += dz3;\n\t\tn3 += dw3;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquaternary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* var shapes = [\n* [ 1, 1, 3, 1, 1 ],\n* [ 1, 1, 1, 3, 1 ],\n* [ 1, 1, 1, 1, 3 ],\n* [ 1, 1, 1, 1, 1 ],\n* [ 1, 1, 3, 3, 3 ]\n* ];\n*\n* var x = ones5d( shapes[ 0 ] );\n* var y = ones5d( shapes[ 1 ] );\n* var z = ones5d( shapes[ 2 ] );\n* var w = ones5d( shapes[ 3 ] );\n* var out = zeros5d( shapes[ 4 ] );\n*\n* bquaternary5d( [ x, y, z, w, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ], [ [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ], [ 4.0, 4.0, 4.0 ] ] ] ] ]\n*/\nfunction bquaternary5d( arrays, shapes, fcn ) { // eslint-disable-line max-statements\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dx4;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dy4;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dz3;\n\tvar dz4;\n\tvar dw0;\n\tvar dw1;\n\tvar dw2;\n\tvar dw3;\n\tvar dw4;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar j4;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar k4;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar m4;\n\tvar n0;\n\tvar n1;\n\tvar n2;\n\tvar n3;\n\tvar n4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar z3;\n\tvar w0;\n\tvar w1;\n\tvar w2;\n\tvar w3;\n\tvar u0;\n\tvar u1;\n\tvar u2;\n\tvar u3;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\n\tsh = shapes[ 4 ];\n\tS0 = sh[ 4 ];\n\tS1 = sh[ 3 ];\n\tS2 = sh[ 2 ];\n\tS3 = sh[ 1 ];\n\tS4 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 4 ];\n\tdx1 = st[ 3 ];\n\tdx2 = st[ 2 ];\n\tdx3 = st[ 1 ];\n\tdx4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 4 ];\n\tdy1 = st[ 3 ];\n\tdy2 = st[ 2 ];\n\tdy3 = st[ 1 ];\n\tdy4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 4 ];\n\tdz1 = st[ 3 ];\n\tdz2 = st[ 2 ];\n\tdz3 = st[ 1 ];\n\tdz4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 4 ];\n\tdw1 = st[ 3 ];\n\tdw2 = st[ 2 ];\n\tdw3 = st[ 1 ];\n\tdw4 = st[ 0 ];\n\n\tu = arrays[ 4 ];\n\n\tj4 = 0;\n\tk4 = 0;\n\tm4 = 0;\n\tn4 = 0;\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tj3 = 0;\n\t\tk3 = 0;\n\t\tm3 = 0;\n\t\tn3 = 0;\n\t\tx3 = x[ j4 ];\n\t\ty3 = y[ k4 ];\n\t\tz3 = z[ m4 ];\n\t\tw3 = w[ n4 ];\n\t\tu3 = u[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tj2 = 0;\n\t\t\tk2 = 0;\n\t\t\tm2 = 0;\n\t\t\tn2 = 0;\n\t\t\tx2 = x3[ j3 ];\n\t\t\ty2 = y3[ k3 ];\n\t\t\tz2 = z3[ m3 ];\n\t\t\tw2 = w3[ n3 ];\n\t\t\tu2 = u3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tj1 = 0;\n\t\t\t\tk1 = 0;\n\t\t\t\tm1 = 0;\n\t\t\t\tn1 = 0;\n\t\t\t\tx1 = x2[ j2 ];\n\t\t\t\ty1 = y2[ k2 ];\n\t\t\t\tz1 = z2[ m2 ];\n\t\t\t\tw1 = w2[ n2 ];\n\t\t\t\tu1 = u2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tj0 = 0;\n\t\t\t\t\tk0 = 0;\n\t\t\t\t\tm0 = 0;\n\t\t\t\t\tn0 = 0;\n\t\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\t\tz0 = z1[ m1 ];\n\t\t\t\t\tw0 = w1[ n1 ];\n\t\t\t\t\tu0 = u1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tu0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ] );\n\t\t\t\t\t\tj0 += dx0;\n\t\t\t\t\t\tk0 += dy0;\n\t\t\t\t\t\tm0 += dz0;\n\t\t\t\t\t\tn0 += dw0;\n\t\t\t\t\t}\n\t\t\t\t\tj1 += dx1;\n\t\t\t\t\tk1 += dy1;\n\t\t\t\t\tm1 += dz1;\n\t\t\t\t\tn1 += dw1;\n\t\t\t\t}\n\t\t\t\tj2 += dx2;\n\t\t\t\tk2 += dy2;\n\t\t\t\tm2 += dz2;\n\t\t\t\tn2 += dw2;\n\t\t\t}\n\t\t\tj3 += dx3;\n\t\t\tk3 += dy3;\n\t\t\tm3 += dz3;\n\t\t\tn3 += dw3;\n\t\t}\n\t\tj4 += dx4;\n\t\tk4 += dy4;\n\t\tm4 += dz4;\n\t\tn4 += dw4;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquaternary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function add( x, y, z, w, v ) {\n* return x + y + z + w + v;\n* }\n*\n* var shapes = [\n* [ 1, 2 ],\n* [ 2, 1 ],\n* [ 1, 1 ],\n* [ 2, 2 ],\n* [ 1, 1 ],\n* [ 2, 2 ]\n* ];\n*\n* var x = ones2d( shapes[ 0 ] );\n* var y = ones2d( shapes[ 1 ] );\n* var z = ones2d( shapes[ 2 ] );\n* var w = ones2d( shapes[ 3 ] );\n* var v = ones2d( shapes[ 4 ] );\n* var out = zeros2d( shapes[ 5 ] );\n*\n* bquinary2d( [ x, y, z, w, v, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ]\n*/\nfunction bquinary2d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dy0;\n\tvar dy1;\n\tvar dz0;\n\tvar dz1;\n\tvar dw0;\n\tvar dw1;\n\tvar du0;\n\tvar du1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar j0;\n\tvar j1;\n\tvar k0;\n\tvar k1;\n\tvar m0;\n\tvar m1;\n\tvar n0;\n\tvar n1;\n\tvar p0;\n\tvar p1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar v0;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tsh = shapes[ 5 ];\n\tS0 = sh[ 1 ];\n\tS1 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 1 ];\n\tdx1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 1 ];\n\tdy1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 1 ];\n\tdz1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 1 ];\n\tdw1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 4 ], shapes[ 4 ], sh );\n\tu = o.data;\n\tst = o.strides;\n\tdu0 = st[ 1 ];\n\tdu1 = st[ 0 ];\n\n\tv = arrays[ 5 ];\n\n\tj1 = 0;\n\tk1 = 0;\n\tm1 = 0;\n\tn1 = 0;\n\tp1 = 0;\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tj0 = 0;\n\t\tk0 = 0;\n\t\tm0 = 0;\n\t\tn0 = 0;\n\t\tp0 = 0;\n\t\tx0 = x[ j1 ];\n\t\ty0 = y[ k1 ];\n\t\tz0 = z[ m1 ];\n\t\tw0 = w[ n1 ];\n\t\tu0 = u[ p1 ];\n\t\tv0 = v[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tv0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ], u0[ p0 ] );\n\t\t\tj0 += dx0;\n\t\t\tk0 += dy0;\n\t\t\tm0 += dz0;\n\t\t\tn0 += dw0;\n\t\t\tp0 += du0;\n\t\t}\n\t\tj1 += dx1;\n\t\tk1 += dy1;\n\t\tm1 += dz1;\n\t\tn1 += dw1;\n\t\tp1 += du1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquinary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function add( x, y, z, w, v ) {\n* return x + y + z + w + v;\n* }\n*\n* var shapes = [\n* [ 1, 1, 1, 2 ],\n* [ 1, 1, 2, 1 ],\n* [ 1, 1, 2, 2 ],\n* [ 1, 2, 1, 1 ],\n* [ 2, 2, 2, 2 ],\n* [ 2, 2, 2, 2 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = ones4d( shapes[ 1 ] );\n* var z = ones4d( shapes[ 2 ] );\n* var w = ones4d( shapes[ 3 ] );\n* var v = ones4d( shapes[ 4 ] );\n* var out = zeros4d( shapes[ 5 ] );\n*\n* bquinary4d( [ x, y, z, w, v, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ], [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ]\n*/\nfunction bquinary4d( arrays, shapes, fcn ) { // eslint-disable-line max-statements\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dz3;\n\tvar dw0;\n\tvar dw1;\n\tvar dw2;\n\tvar dw3;\n\tvar du0;\n\tvar du1;\n\tvar du2;\n\tvar du3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar n0;\n\tvar n1;\n\tvar n2;\n\tvar n3;\n\tvar p0;\n\tvar p1;\n\tvar p2;\n\tvar p3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar w0;\n\tvar w1;\n\tvar w2;\n\tvar u0;\n\tvar u1;\n\tvar u2;\n\tvar v0;\n\tvar v1;\n\tvar v2;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tsh = shapes[ 5 ];\n\tS0 = sh[ 3 ];\n\tS1 = sh[ 2 ];\n\tS2 = sh[ 1 ];\n\tS3 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 3 ];\n\tdx1 = st[ 2 ];\n\tdx2 = st[ 1 ];\n\tdx3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 3 ];\n\tdy1 = st[ 2 ];\n\tdy2 = st[ 1 ];\n\tdy3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 3 ];\n\tdz1 = st[ 2 ];\n\tdz2 = st[ 1 ];\n\tdz3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 3 ], shapes[ 3 ], sh );\n\tw = o.data;\n\tst = o.strides;\n\tdw0 = st[ 3 ];\n\tdw1 = st[ 2 ];\n\tdw2 = st[ 1 ];\n\tdw3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 4 ], shapes[ 4 ], sh );\n\tu = o.data;\n\tst = o.strides;\n\tdu0 = st[ 3 ];\n\tdu1 = st[ 2 ];\n\tdu2 = st[ 1 ];\n\tdu3 = st[ 0 ];\n\n\tv = arrays[ 5 ];\n\n\tj3 = 0;\n\tk3 = 0;\n\tm3 = 0;\n\tn3 = 0;\n\tp3 = 0;\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tj2 = 0;\n\t\tk2 = 0;\n\t\tm2 = 0;\n\t\tn2 = 0;\n\t\tp2 = 0;\n\t\tx2 = x[ j3 ];\n\t\ty2 = y[ k3 ];\n\t\tz2 = z[ m3 ];\n\t\tw2 = w[ n3 ];\n\t\tu2 = u[ p3 ];\n\t\tv2 = v[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tj1 = 0;\n\t\t\tk1 = 0;\n\t\t\tm1 = 0;\n\t\t\tn1 = 0;\n\t\t\tp1 = 0;\n\t\t\tx1 = x2[ j2 ];\n\t\t\ty1 = y2[ k2 ];\n\t\t\tz1 = z2[ m2 ];\n\t\t\tw1 = w2[ n2 ];\n\t\t\tu1 = u2[ p2 ];\n\t\t\tv1 = v2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tj0 = 0;\n\t\t\t\tk0 = 0;\n\t\t\t\tm0 = 0;\n\t\t\t\tn0 = 0;\n\t\t\t\tp0 = 0;\n\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\tz0 = z1[ m1 ];\n\t\t\t\tw0 = w1[ n1 ];\n\t\t\t\tu0 = u1[ p1 ];\n\t\t\t\tv0 = v1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tv0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ], w0[ n0 ], u0[ p0 ] ); // eslint-disable-line max-len\n\t\t\t\t\tj0 += dx0;\n\t\t\t\t\tk0 += dy0;\n\t\t\t\t\tm0 += dz0;\n\t\t\t\t\tn0 += dw0;\n\t\t\t\t\tp0 += du0;\n\t\t\t\t}\n\t\t\t\tj1 += dx1;\n\t\t\t\tk1 += dy1;\n\t\t\t\tm1 += dz1;\n\t\t\t\tn1 += dw1;\n\t\t\t\tp1 += du1;\n\t\t\t}\n\t\t\tj2 += dx2;\n\t\t\tk2 += dy2;\n\t\t\tm2 += dz2;\n\t\t\tn2 += dw2;\n\t\t\tp2 += du2;\n\t\t}\n\t\tj3 += dx3;\n\t\tk3 += dy3;\n\t\tm3 += dz3;\n\t\tn3 += dw3;\n\t\tp3 += du3;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bquinary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import add from '@stdlib/number/float64/base/add3';\n*\n* var shapes = [\n* [ 1, 2 ],\n* [ 2, 1 ],\n* [ 1, 1 ],\n* [ 2, 2 ]\n* ];\n*\n* var x = ones2d( shapes[ 0 ] );\n* var y = ones2d( shapes[ 1 ] );\n* var z = ones2d( shapes[ 2 ] );\n* var out = zeros2d( shapes[ 3 ] );\n*\n* bternary2d( [ x, y, z, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ]\n*/\nfunction bternary2d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dy0;\n\tvar dy1;\n\tvar dz0;\n\tvar dz1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar j0;\n\tvar j1;\n\tvar k0;\n\tvar k1;\n\tvar m0;\n\tvar m1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tsh = shapes[ 3 ];\n\tS0 = sh[ 1 ];\n\tS1 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 1 ];\n\tdx1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 1 ];\n\tdy1 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 1 ];\n\tdz1 = st[ 0 ];\n\n\tw = arrays[ 3 ];\n\n\tj1 = 0;\n\tk1 = 0;\n\tm1 = 0;\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tj0 = 0;\n\t\tk0 = 0;\n\t\tm0 = 0;\n\t\tx0 = x[ j1 ];\n\t\ty0 = y[ k1 ];\n\t\tz0 = z[ m1 ];\n\t\tw0 = w[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tw0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] );\n\t\t\tj0 += dx0;\n\t\t\tk0 += dy0;\n\t\t\tm0 += dz0;\n\t\t}\n\t\tj1 += dx1;\n\t\tk1 += dy1;\n\t\tm1 += dz1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bternary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import add from '@stdlib/number/float64/base/add3';\n*\n* var shapes = [\n* [ 1, 2, 1 ],\n* [ 2, 1, 1 ],\n* [ 1, 1, 2 ],\n* [ 2, 2, 2 ]\n* ];\n*\n* var x = ones3d( shapes[ 0 ] );\n* var y = ones3d( shapes[ 1 ] );\n* var z = ones3d( shapes[ 2 ] );\n* var out = zeros3d( shapes[ 3 ] );\n*\n* bternary3d( [ x, y, z, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] , [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ]\n*/\nfunction bternary3d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar z0;\n\tvar z1;\n\tvar sh;\n\tvar st;\n\tvar w0;\n\tvar w1;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tsh = shapes[ 3 ];\n\tS0 = sh[ 2 ];\n\tS1 = sh[ 1 ];\n\tS2 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 2 ];\n\tdx1 = st[ 1 ];\n\tdx2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 2 ];\n\tdy1 = st[ 1 ];\n\tdy2 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 2 ];\n\tdz1 = st[ 1 ];\n\tdz2 = st[ 0 ];\n\n\tw = arrays[ 3 ];\n\tj2 = 0;\n\tk2 = 0;\n\tm2 = 0;\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tj1 = 0;\n\t\tk1 = 0;\n\t\tm1 = 0;\n\t\tx1 = x[ j2 ];\n\t\ty1 = y[ k2 ];\n\t\tz1 = z[ m2 ];\n\t\tw1 = w[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tj0 = 0;\n\t\t\tk0 = 0;\n\t\t\tm0 = 0;\n\t\t\tx0 = x1[ j1 ];\n\t\t\ty0 = y1[ k1 ];\n\t\t\tz0 = z1[ m1 ];\n\t\t\tw0 = w1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tw0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] );\n\t\t\t\tj0 += dx0;\n\t\t\t\tk0 += dy0;\n\t\t\t\tm0 += dz0;\n\t\t\t}\n\t\t\tj1 += dx1;\n\t\t\tk1 += dy1;\n\t\t\tm1 += dz1;\n\t\t}\n\t\tj2 += dx2;\n\t\tk2 += dy2;\n\t\tm2 += dz2;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bternary3d;\n","/* eslint-disable max-statements */\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import add from '@stdlib/number/float64/base/add3';\n*\n* var shapes = [\n* [ 1, 2, 1, 1 ],\n* [ 2, 1, 1, 1 ],\n* [ 1, 1, 2, 1 ],\n* [ 2, 2, 2, 2 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = ones4d( shapes[ 1 ] );\n* var z = ones4d( shapes[ 2 ] );\n* var out = zeros4d( shapes[ 3 ] );\n*\n* bternary4d( [ x, y, z, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ], [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ], [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ]\n*/\nfunction bternary4d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dz3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar sh;\n\tvar st;\n\tvar w0;\n\tvar w1;\n\tvar w2;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tsh = shapes[ 3 ];\n\tS0 = sh[ 3 ];\n\tS1 = sh[ 2 ];\n\tS2 = sh[ 1 ];\n\tS3 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 3 ];\n\tdx1 = st[ 2 ];\n\tdx2 = st[ 1 ];\n\tdx3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 3 ];\n\tdy1 = st[ 2 ];\n\tdy2 = st[ 1 ];\n\tdy3 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 3 ];\n\tdz1 = st[ 2 ];\n\tdz2 = st[ 1 ];\n\tdz3 = st[ 0 ];\n\n\tw = arrays[ 3 ];\n\tj3 = 0;\n\tk3 = 0;\n\tm3 = 0;\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tj2 = 0;\n\t\tk2 = 0;\n\t\tm2 = 0;\n\t\tx2 = x[ j3 ];\n\t\ty2 = y[ k3 ];\n\t\tz2 = z[ m3 ];\n\t\tw2 = w[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tj1 = 0;\n\t\t\tk1 = 0;\n\t\t\tm1 = 0;\n\t\t\tx1 = x2[ j2 ];\n\t\t\ty1 = y2[ k2 ];\n\t\t\tz1 = z2[ m2 ];\n\t\t\tw1 = w2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tj0 = 0;\n\t\t\t\tk0 = 0;\n\t\t\t\tm0 = 0;\n\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\tz0 = z1[ m1 ];\n\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tw0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] );\n\t\t\t\t\tj0 += dx0;\n\t\t\t\t\tk0 += dy0;\n\t\t\t\t\tm0 += dz0;\n\t\t\t\t}\n\t\t\t\tj1 += dx1;\n\t\t\t\tk1 += dy1;\n\t\t\t\tm1 += dz1;\n\t\t\t}\n\t\t\tj2 += dx2;\n\t\t\tk2 += dy2;\n\t\t\tm2 += dz2;\n\t\t}\n\t\tj3 += dx3;\n\t\tk3 += dy3;\n\t\tm3 += dz3;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bternary4d;\n","/* eslint-disable max-statements */\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import add from '@stdlib/number/float64/base/add3';\n\n* var shapes = [\n* [ 1, 2, 1, 1, 1 ],\n* [ 2, 1, 1, 1, 1 ],\n* [ 1, 1, 1, 1, 1 ],\n* [ 2, 2, 1, 1, 1 ]\n* ];\n*\n* var x = ones5d( shapes[ 0 ] );\n* var y = ones5d( shapes[ 1 ] );\n* var z = ones5d( shapes[ 2 ] );\n* var out = zeros5d( shapes[ 3 ] );\n*\n* bternary5d( [ x, y, z, out ], shapes, add );\n*\n* console.log( out );\n* // => [ [ [ [ [ 3.0 ] ] ], [ [ [ 3.0 ] ] ] ], [ [ [ [ 3.0 ] ] ], [ [ [ 3.0 ] ] ] ] ]\n*/\nfunction bternary5d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dx4;\n\tvar dy0;\n\tvar dy1;\n\tvar dy2;\n\tvar dy3;\n\tvar dy4;\n\tvar dz0;\n\tvar dz1;\n\tvar dz2;\n\tvar dz3;\n\tvar dz4;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar j4;\n\tvar k0;\n\tvar k1;\n\tvar k2;\n\tvar k3;\n\tvar k4;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar m4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar z3;\n\tvar sh;\n\tvar st;\n\tvar w0;\n\tvar w1;\n\tvar w2;\n\tvar w3;\n\tvar o;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tsh = shapes[ 3 ];\n\tS0 = sh[ 4 ];\n\tS1 = sh[ 3 ];\n\tS2 = sh[ 2 ];\n\tS3 = sh[ 1 ];\n\tS4 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 4 ];\n\tdx1 = st[ 3 ];\n\tdx2 = st[ 2 ];\n\tdx3 = st[ 1 ];\n\tdx4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 1 ], shapes[ 1 ], sh );\n\ty = o.data;\n\tst = o.strides;\n\tdy0 = st[ 4 ];\n\tdy1 = st[ 3 ];\n\tdy2 = st[ 2 ];\n\tdy3 = st[ 1 ];\n\tdy4 = st[ 0 ];\n\n\to = broadcastArray( arrays[ 2 ], shapes[ 2 ], sh );\n\tz = o.data;\n\tst = o.strides;\n\tdz0 = st[ 4 ];\n\tdz1 = st[ 3 ];\n\tdz2 = st[ 2 ];\n\tdz3 = st[ 1 ];\n\tdz4 = st[ 0 ];\n\n\tw = arrays[ 3 ];\n\tj4 = 0;\n\tk4 = 0;\n\tm4 = 0;\n\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tj3 = 0;\n\t\tk3 = 0;\n\t\tm3 = 0;\n\t\tx3 = x[ j4 ];\n\t\ty3 = y[ k4 ];\n\t\tz3 = z[ m4 ];\n\t\tw3 = w[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tj2 = 0;\n\t\t\tk2 = 0;\n\t\t\tm2 = 0;\n\t\t\tx2 = x3[ j3 ];\n\t\t\ty2 = y3[ k3 ];\n\t\t\tz2 = z3[ m3 ];\n\t\t\tw2 = w3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tj1 = 0;\n\t\t\t\tk1 = 0;\n\t\t\t\tm1 = 0;\n\t\t\t\tx1 = x2[ j2 ];\n\t\t\t\ty1 = y2[ k2 ];\n\t\t\t\tz1 = z2[ m2 ];\n\t\t\t\tw1 = w2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tj0 = 0;\n\t\t\t\t\tk0 = 0;\n\t\t\t\t\tm0 = 0;\n\t\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\t\ty0 = y1[ k1 ];\n\t\t\t\t\tz0 = z1[ m1 ];\n\t\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tw0[ i0 ] = fcn( x0[ j0 ], y0[ k0 ], z0[ m0 ] );\n\t\t\t\t\t\tj0 += dx0;\n\t\t\t\t\t\tk0 += dy0;\n\t\t\t\t\t\tm0 += dz0;\n\t\t\t\t\t}\n\t\t\t\t\tj1 += dx1;\n\t\t\t\t\tk1 += dy1;\n\t\t\t\t\tm1 += dz1;\n\t\t\t\t}\n\t\t\t\tj2 += dx2;\n\t\t\t\tk2 += dy2;\n\t\t\t\tm2 += dz2;\n\t\t\t}\n\t\t\tj3 += dx3;\n\t\t\tk3 += dy3;\n\t\t\tm3 += dz3;\n\t\t}\n\t\tj4 += dx4;\n\t\tk4 += dy4;\n\t\tm4 += dz4;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bternary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a two-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shapes = [\n* [ 1, 2 ],\n* [ 2, 2 ]\n* ];\n*\n* var x = ones2d( shapes[ 0 ] );\n* var y = zeros2d( shapes[ 1 ] );\n*\n* bunary2d( [ x, y ], shapes, scale );\n*\n* console.log( y );\n* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*/\nfunction bunary2d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar j0;\n\tvar j1;\n\tvar x0;\n\tvar y0;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\n\tsh = shapes[ 1 ];\n\tS0 = sh[ 1 ];\n\tS1 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 1 ];\n\tdx1 = st[ 0 ];\n\n\ty = arrays[ 1 ];\n\n\tj1 = 0;\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tj0 = 0;\n\t\tx0 = x[ j1 ];\n\t\ty0 = y[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\ty0[ i0 ] = fcn( x0[ j0 ] );\n\t\t\tj0 += dx0;\n\t\t}\n\t\tj1 += dx1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bunary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a three-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shapes = [\n* [ 1, 1, 2 ],\n* [ 1, 2, 2 ]\n* ];\n*\n* var x = ones3d( shapes[ 0 ] );\n* var y = zeros3d( shapes[ 1 ] );\n*\n* bunary3d( [ x, y ], shapes, scale );\n*\n* console.log( y );\n* // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*/\nfunction bunary3d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\n\tsh = shapes[ 1 ];\n\tS0 = sh[ 2 ];\n\tS1 = sh[ 1 ];\n\tS2 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 2 ];\n\tdx1 = st[ 1 ];\n\tdx2 = st[ 0 ];\n\n\ty = arrays[ 1 ];\n\tj2 = 0;\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tj1 = 0;\n\t\tx1 = x[ j2 ];\n\t\ty1 = y[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tj0 = 0;\n\t\t\tx0 = x1[ j1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\ty0[ i0 ] = fcn( x0[ j0 ] );\n\t\t\t\tj0 += dx0;\n\t\t\t}\n\t\t\tj1 += dx1;\n\t\t}\n\t\tj2 += dx2;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bunary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shapes = [\n* [ 1, 1, 1, 2 ],\n* [ 1, 1, 2, 2 ]\n* ];\n*\n* var x = ones4d( shapes[ 0 ] );\n* var y = zeros4d( shapes[ 1 ] );\n*\n* bunary4d( [ x, y ], shapes, scale );\n*\n* console.log( y );\n* // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction bunary4d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\n\tsh = shapes[ 1 ];\n\tS0 = sh[ 3 ];\n\tS1 = sh[ 2 ];\n\tS2 = sh[ 1 ];\n\tS3 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 3 ];\n\tdx1 = st[ 2 ];\n\tdx2 = st[ 1 ];\n\tdx3 = st[ 0 ];\n\n\ty = arrays[ 1 ];\n\tj3 = 0;\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tj2 = 0;\n\t\tx2 = x[ j3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tj1 = 0;\n\t\t\tx1 = x2[ j2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tj0 = 0;\n\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn( x0[ j0 ] );\n\t\t\t\t\tj0 += dx0;\n\t\t\t\t}\n\t\t\t\tj1 += dx1;\n\t\t\t}\n\t\t\tj2 += dx2;\n\t\t}\n\t\tj3 += dx3;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bunary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport broadcastArray from './../../../base/broadcast-array';\n\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a broadcasted nested input array and assigns results to elements in a five-dimensional nested output array.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {ArrayLikeObject} shapes - array shapes\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shapes = [\n* [ 1, 1, 1, 1, 2 ],\n* [ 1, 1, 1, 2, 2 ]\n* ];\n*\n* var x = ones5d( shapes[ 0 ] );\n* var y = zeros5d( shapes[ 1 ] );\n*\n* bunary5d( [ x, y ], shapes, scale );\n*\n* console.log( y );\n* // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*/\nfunction bunary5d( arrays, shapes, fcn ) {\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dx4;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar j0;\n\tvar j1;\n\tvar j2;\n\tvar j3;\n\tvar j4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar sh;\n\tvar st;\n\tvar o;\n\tvar x;\n\tvar y;\n\n\tsh = shapes[ 1 ];\n\tS0 = sh[ 4 ];\n\tS1 = sh[ 3 ];\n\tS2 = sh[ 2 ];\n\tS3 = sh[ 1 ];\n\tS4 = sh[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\to = broadcastArray( arrays[ 0 ], shapes[ 0 ], sh );\n\tx = o.data;\n\tst = o.strides;\n\tdx0 = st[ 4 ];\n\tdx1 = st[ 3 ];\n\tdx2 = st[ 2 ];\n\tdx3 = st[ 1 ];\n\tdx4 = st[ 0 ];\n\n\ty = arrays[ 1 ];\n\tj4 = 0;\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tj3 = 0;\n\t\tx3 = x[ j4 ];\n\t\ty3 = y[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tj2 = 0;\n\t\t\tx2 = x3[ j3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tj1 = 0;\n\t\t\t\tx1 = x2[ j2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tj0 = 0;\n\t\t\t\t\tx0 = x1[ j1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\ty0[ i0 ] = fcn( x0[ j0 ] );\n\t\t\t\t\t\tj0 += dx0;\n\t\t\t\t\t}\n\t\t\t\t\tj1 += dx1;\n\t\t\t\t}\n\t\t\t\tj2 += dx2;\n\t\t\t}\n\t\t\tj3 += dx3;\n\t\t}\n\t\tj4 += dx4;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default bunary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of elements in an indexed array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, predicate, {} );\n* // returns 3\n*/\nfunction indexed( x, predicate, thisArg ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} thisArg - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, predicate, {} );\n* // returns 3\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( x, i ), i, x ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - predicate function\n* @param {*} [thisArg] - predicate function evaluation context\n* @returns {NonNegativeInteger} result\n*\n* @example\n* function predicate( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countIf( x, predicate );\n* // returns 3\n*/\nfunction countIf( x, predicate, thisArg ) {\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, predicate, thisArg );\n\t}\n\treturn indexed( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default countIf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport isSameValue from '@stdlib/assert/is-same-value';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of elements in an array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = indexed( x, 1 );\n* // returns 3\n*/\nfunction indexed( x, value ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValue( x[ i ], value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a provided value\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 1, 0, 1, 1 ] );\n*\n* var n = accessors( x, 1 );\n* // returns 3\n*/\nfunction accessors( x, value ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValue( get( x, i ), value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var n = complex( x, new Complex128( 1.0, 2.0 ) );\n* // returns 1\n*/\nfunction complex( x, value ) {\n\tvar view;\n\tvar re;\n\tvar im;\n\tvar n;\n\tvar i;\n\n\tif ( !isComplexLike( value ) ) {\n\t\treturn 0;\n\t}\n\tre = real( value );\n\tim = imag( value );\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( isSameValue( view[ i ], re ) && isSameValue( view[ i+1 ], im ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a boolean array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var x = new BooleanArray( [ true, false, true, false, true ] );\n*\n* var n = boolean( x, true );\n* // returns 3\n*/\nfunction boolean( x, value ) {\n\tvar view;\n\tvar n;\n\tvar v;\n\tvar i;\n\n\tif ( !isBoolean( value ) ) {\n\t\treturn 0;\n\t}\n\tview = reinterpretBoolean( x, 0 );\n\n\tv = ( value ) ? 1 : 0;\n\tn = 0;\n\tfor ( i = 0; i < view.length; i++ ) {\n\t\tif ( view[ i ] === v ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that are equal to a specified value.\n*\n* ## Notes\n*\n* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var x = [ 0, 1, 0, 1, 1 ];\n*\n* var n = countSameValue( x, 1 );\n* // returns 3\n*/\nfunction countSameValue( x, value ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, value );\n\t\t}\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn boolean( x, value );\n\t\t}\n\t\treturn accessors( x, value );\n\t}\n\treturn indexed( x, value );\n}\n\n\n// EXPORTS //\n\nexport default countSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\nimport isSameValueZero from '@stdlib/assert/is-same-value-zero';\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of elements in an indexed array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var x = [ 0, 0, 1, 0, 1 ];\n*\n* var n = indexed( x, 0 );\n* // returns 3\n*/\nfunction indexed( x, value ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValueZero( x[ i ], value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 0, 0, 1, 0, 1 ] );\n*\n* var n = accessors( x, 0 );\n* // returns 3\n*/\nfunction accessors( x, value ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValueZero( get( x, i ), value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var n = complex( x, new Complex128( 1.0, 2.0 ) );\n* // returns 1\n*/\nfunction complex( x, value ) {\n\tvar view;\n\tvar re;\n\tvar im;\n\tvar n;\n\tvar i;\n\n\tif ( !isComplexLike( value ) ) {\n\t\treturn 0;\n\t}\n\tre = real( value );\n\tim = imag( value );\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( isSameValueZero( view[ i ], re ) && isSameValueZero( view[ i+1 ], im ) ) { // eslint-disable-line max-len\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a boolean array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var x = new BooleanArray( [ true, false, true, false, true ] );\n*\n* var n = boolean( x, true );\n* // returns 3\n*/\nfunction boolean( x, value ) {\n\tvar view;\n\tvar n;\n\tvar v;\n\tvar i;\n\n\tif ( !isBoolean( value ) ) {\n\t\treturn 0;\n\t}\n\tview = reinterpretBoolean( x, 0 );\n\n\tv = ( value ) ? 1 : 0;\n\tn = 0;\n\tfor ( i = 0; i < view.length; i++ ) {\n\t\tif ( view[ i ] === v ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that are equal to a specified value.\n*\n* ## Notes\n*\n* - The function uses the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016.\n* - In contrast to an implementation based on the strict equality operator `===`, the function treats `NaNs` as the same value.\n*\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* import countSameValueZero from '@stdlib/array/base/count-same-value-zero';\n*\n* var x = [ 0, 0, 1, 0, 1 ];\n*\n* var n = countSameValueZero( x, 1 );\n* // returns 2\n*/\nfunction countSameValueZero( x, value ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, value );\n\t\t}\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn boolean( x, value );\n\t\t}\n\t\treturn accessors( x, value );\n\t}\n\treturn indexed( x, value );\n}\n\n\n// EXPORTS //\n\nexport default countSameValueZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from '@stdlib/math/base/assert/is-nan';\n\n\n// FUNCTIONS //\n\n/**\n* De-duplicates values in-place.\n*\n* @private\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @returns {Array} input array\n*\n* @example\n* var x = [ 1, 1, 2, 3, 3 ];\n*\n* var y = dedupeInPlace( x, 1 );\n* // returns [ 1, 2, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ];\n*\n* var y = dedupeInPlace( x, 2 );\n* // returns [ 1, 1, 2, 1, 1, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*/\nfunction dedupeInPlace( x, limit ) {\n\tvar count;\n\tvar prev;\n\tvar len;\n\tvar ptr;\n\tvar v;\n\tvar i;\n\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn x;\n\t}\n\tprev = x[ 0 ];\n\tcount = 1;\n\tptr = 1;\n\tfor ( i = 1; i < len; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( v === prev ) {\n\t\t\tcount += 1;\n\t\t\tif ( count <= limit ) {\n\t\t\t\tx[ ptr ] = prev;\n\t\t\t\tptr += 1;\n\t\t\t}\n\t\t} else {\n\t\t\tprev = v;\n\t\t\tcount = 1;\n\t\t\tx[ ptr ] = prev;\n\t\t\tptr += 1;\n\t\t}\n\t}\n\tx.length = ptr;\n\treturn x;\n}\n\n/**\n* De-duplicates values in-place, treating `NaN` values as equal.\n*\n* @private\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @returns {Array} input array\n*\n* @example\n* var x = [ 1, 1, 2, NaN, NaN, 3, 3 ];\n*\n* var y = dedupeEqualNaNs( x, 1 );\n* // returns [ 1, 2, NaN, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, NaN, NaN, NaN, 3, 3 ];\n*\n* var y = dedupeEqualNaNs( x, 2 );\n* // returns [ 1, 1, 2, 1, 1, NaN, NaN, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*/\nfunction dedupeEqualNaNs( x, limit ) {\n\tvar count;\n\tvar prev;\n\tvar len;\n\tvar ptr;\n\tvar FLG;\n\tvar v;\n\tvar i;\n\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn x;\n\t}\n\tFLG = false;\n\tprev = x[ 0 ];\n\tif ( isnan( prev ) ) {\n\t\tFLG = true;\n\t}\n\tcount = 1;\n\tptr = 1;\n\tfor ( i = 1; i < len; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( v === prev || ( FLG && isnan( v ) ) ) {\n\t\t\tcount += 1;\n\t\t\tif ( count <= limit ) {\n\t\t\t\tx[ ptr ] = prev;\n\t\t\t\tptr += 1;\n\t\t\t}\n\t\t} else {\n\t\t\tprev = v;\n\t\t\tcount = 1;\n\t\t\tx[ ptr ] = prev;\n\t\t\tptr += 1;\n\t\t\tFLG = false;\n\t\t\tif ( isnan( prev ) ) {\n\t\t\t\tFLG = true;\n\t\t\t}\n\t\t}\n\t}\n\tx.length = ptr;\n\treturn x;\n}\n\n\n// MAIN //\n\n/**\n* Removes consecutive duplicated values.\n*\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @param {boolean} equalNaNs - boolean indicating whether NaNs should be considered equal\n* @returns {Array} de-duplicated values\n*\n* @example\n* var x = [ 1, 1, 2, 3, 3 ];\n*\n* var y = dedupe( x, 1, false );\n* // returns [ 1, 2, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ];\n*\n* var y = dedupe( x, 2, false );\n* // returns [ 1, 1, 2, 1, 1, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*/\nfunction dedupe( x, limit, equalNaNs ) {\n\tif ( equalNaNs ) {\n\t\treturn dedupeEqualNaNs( x, limit );\n\t}\n\treturn dedupeInPlace( x, limit );\n}\n\n\n// EXPORTS //\n\nexport default dedupe;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Convert array entries to an array of objects.\n*\n* ## Notes\n*\n* - The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value.\n*\n* @param {Collection} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3 ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = entries2objects( x, fields );\n* // returns [ { 'x': 0, 'y': 1 }, { 'x': 1, 'y': 2 }, { 'x': 2, 'y': 3 } ]\n*/\nfunction entries2objects( arr, fields ) {\n\tvar get;\n\tvar out;\n\tvar obj;\n\tvar N;\n\tvar i;\n\tvar k;\n\tvar v;\n\n\tN = arr.length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\tget = resolveGetter( fields );\n\tk = get( fields, 0 );\n\tv = get( fields, 1 );\n\n\tget = resolveGetter( arr );\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tobj = {};\n\t\tobj[ k ] = i;\n\t\tobj[ v ] = get( arr, i );\n\t\tout.push( obj );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default entries2objects;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-read-only-accessor';\nimport setReadWriteAccessor from '@stdlib/utils/define-read-write-accessor';\nimport resolveGetter from './../../../base/resolve-getter';\nimport accessors from './../../../base/accessors';\n\n\n// MAIN //\n\n/**\n* Converts array entries to an array of composite views.\n*\n* ## Notes\n*\n* - The list of field names should be a two-element array where the first element corresponds to the field name of input array element index and the second element corresponds to the field name of the input array element value.\n* - For each element of the returned array, the index view field is read-only and cannot be mutated.\n*\n* @param {Collection} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3 ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = entries2views( x, fields );\n* // returns [ , , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 0, 'y': 1 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v2 = out[ 2 ].toJSON();\n* // returns { 'x': 2, 'y': 3 }\n*\n* // Mutate the input array:\n* x[ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 0, 'y': 5 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 1, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ 5, 'beep', 3 ]\n*/\nfunction entries2views( arr, fields ) {\n\tvar fget;\n\tvar get;\n\tvar set;\n\tvar acc;\n\tvar out;\n\tvar N;\n\tvar k;\n\tvar v;\n\tvar i;\n\n\tN = arr.length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Resolve element accessors:\n\tacc = accessors( arr ).accessors;\n\tget = acc[ 0 ];\n\tset = acc[ 1 ];\n\n\t// Cache field names:\n\tfget = resolveGetter( fields );\n\tk = fget( fields, 0 );\n\tv = fget( fields, 1 );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( i ) {\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field:\n\tsetReadOnlyAccessor( Datum.prototype, k, getIndex );\n\tsetReadWriteAccessor( Datum.prototype, v, getValue, setValue );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout.push( new Datum( i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Returns the entry index.\n\t*\n\t* @private\n\t* @returns {*} result\n\t*/\n\tfunction getIndex() {\n\t\treturn this._i;\n\t}\n\n\t/**\n\t* Returns the value associated with a field.\n\t*\n\t* @private\n\t* @returns {*} result\n\t*/\n\tfunction getValue() {\n\t\treturn get( arr, this._i );\n\t}\n\n\t/**\n\t* Sets the value associated with a field.\n\t*\n\t* @private\n\t* @param {*} value - value to set\n\t*/\n\tfunction setValue( value ) {\n\t\tset( arr, this._i, value );\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\n\t\tout = {};\n\t\tout[ k ] = this[ k ];\n\t\tout[ v ] = this[ v ];\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default entries2views;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\n\n\n// MAIN //\n\n/**\n* Defines a read-only accessor.\n*\n* @param {Object} obj - object on which to define the property\n* @param {(string|symbol)} prop - property name\n* @param {Function} getter - accessor\n*\n* @example\n* function getter() {\n* return 'bar';\n* }\n*\n* var obj = {};\n*\n* setReadOnlyAccessor( obj, 'foo', getter );\n*\n* try {\n* obj.foo = 'boop';\n* } catch ( err ) {\n* console.error( err.message );\n* }\n*/\nfunction setReadOnlyAccessor( obj, prop, getter ) {\n\tdefineProperty( obj, prop, {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'get': getter\n\t});\n}\n\n\n// EXPORTS //\n\nexport default setReadOnlyAccessor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'every' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( !predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = everyBy( x, isPositive );\n* // returns true\n*/\nfunction everyBy( x, predicate, thisArg ) {\n\tvar obj;\n\tif ( hasMethod( x, 'every' ) ) {\n\t\treturn x.every( predicate, thisArg );\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default everyBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = x.length-1; i >= 0; i-- ) {\n\t\tif ( !predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = data.length-1; i >= 0; i-- ) {\n\t\tif ( !predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array pass a test implemented by a predicate function, iterating from right to left.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether all elements pass a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = everyByRight( x, isPositive );\n* // returns true\n*/\nfunction everyByRight( x, predicate, thisArg ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default everyByRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'fill' );\n* // e.g., returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Fills all elements within a portion of an indexed array with a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - fill value\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = indexed( x, 5, 1, 3 );\n* // returns [ 1, 5, 5, 4 ]\n*/\nfunction indexed( x, value, start, end ) {\n\tvar i;\n\tfor ( i = start; i < end; i++ ) {\n\t\tx[ i ] = value;\n\t}\n\treturn x;\n}\n\n/**\n* Fills all elements within a portion of an accessor array with a specified value.\n*\n* @private\n* @param {Object} x - input array object\n* @param {*} value - fill value\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {AccessorArray} modified input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var obj = arraylike2object( x );\n*\n* var out = accessors( obj, 5, 1, 3 );\n* // returns \n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* v = x.get( 1 );\n* // returns 5\n*\n* v = x.get( 2 );\n* // returns 5\n*\n* v = x.get( 3 );\n* // returns 4\n*/\nfunction accessors( x, value, start, end ) {\n\tvar data;\n\tvar set;\n\tvar i;\n\n\tdata = x.data;\n\tset = x.accessors[ 1 ];\n\tfor ( i = start; i < end; i++ ) {\n\t\tset( data, i, value );\n\t}\n\treturn data;\n}\n\n\n// MAIN //\n\n/**\n* Fills all elements within a portion of an array with a specified value.\n*\n* @param {Collection} x - input array\n* @param {*} value - fill value\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = fill( x, 5, 1, 3 );\n* // returns [ 1, 5, 5, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var out = fill( x, 5, 1, 3 );\n* // returns [ 1, 5, 5, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction fill( x, value, start, end ) {\n\tvar obj;\n\tif ( hasMethod( x, 'fill' ) ) {\n\t\treturn x.fill( value, start, end );\n\t}\n\tif ( start < 0 ) {\n\t\tstart += x.length;\n\t\tif ( start < 0 ) {\n\t\t\tstart = 0;\n\t\t}\n\t}\n\tif ( end < 0 ) {\n\t\tend += x.length; // if `end` is still negative, that is fine, as `x` will be returned un-mutated\n\t} else if ( end > x.length ) {\n\t\tend = x.length;\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, value, start, end );\n\t}\n\treturn indexed( x, value, start, end );\n}\n\n\n// EXPORTS //\n\nexport default fill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Fills all elements within a portion of an indexed array according to a callback function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @param {Function} fcn - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {Array} output array\n*\n* @example\n* function fcn() {\n* return 5;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = indexed( x, 1, 3, fcn, {} );\n* // returns [ 1, 5, 5, 4 ]\n*/\nfunction indexed( x, start, end, fcn, thisArg ) {\n\tvar i;\n\tfor ( i = start; i < end; i++ ) {\n\t\tx[ i ] = fcn.call( thisArg, x[ i ], i, x );\n\t}\n\treturn x;\n}\n\n/**\n* Fills all elements within a portion of an accessor array according to a callback function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @param {Function} fcn - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {AccessorArray} modified input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function fcn() {\n* return 5;\n* }\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n* var obj = arraylike2object( x );\n*\n* var out = accessors( obj, 1, 3, fcn, {} );\n* // returns \n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* v = x.get( 1 );\n* // returns 5\n*\n* v = x.get( 2 );\n* // returns 5\n*\n* v = x.get( 3 );\n* // returns 4\n*/\nfunction accessors( x, start, end, fcn, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar set;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\tset = x.accessors[ 1 ];\n\tfor ( i = start; i < end; i++ ) {\n\t\tset( data, i, fcn.call( thisArg, get( data, i ), i, data ) );\n\t}\n\treturn data;\n}\n\n\n// MAIN //\n\n/**\n* Fills all elements within a portion of an array according to a callback function.\n*\n* @param {Collection} x - input array\n* @param {integer} start - starting index (inclusive)\n* @param {integer} end - ending index (exclusive)\n* @param {Function} fcn - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Collection} output array\n*\n* @example\n* function fcn() {\n* return 5;\n* }\n*\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = fillBy( x, 1, 3, fcn );\n* // returns [ 1, 5, 5, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* function fcn() {\n* return 5;\n* }\n*\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var out = fillBy( x, 1, 3, fcn );\n* // returns [ 1, 5, 5, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction fillBy( x, start, end, fcn, thisArg ) {\n\tvar obj;\n\tif ( start < 0 ) {\n\t\tstart += x.length;\n\t\tif ( start < 0 ) {\n\t\t\tstart = 0;\n\t\t}\n\t}\n\tif ( end < 0 ) {\n\t\tend += x.length; // if `end` is still negative, that is fine, as `x` will be returned un-mutated\n\t} else if ( end > x.length ) {\n\t\tend = x.length;\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, start, end, fcn, thisArg );\n\t}\n\treturn indexed( x, start, end, fcn, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default fillBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled two-dimensional nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filled2dBy( [ 1, 3 ], constantFunction( 'beep' ) );\n* // returns [ [ 'beep', 'beep', 'beep' ] ]\n*/\nfunction filled2dBy( shape, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar S0;\n\tvar S1;\n\tvar i;\n\tvar j;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i = 0; i < S1; i++ ) {\n\t\ta0 = [];\n\t\tfor ( j = 0; j < S0; j++ ) {\n\t\t\ta0.push( clbk.call( thisArg, [ i, j ] ) );\n\t\t}\n\t\tarr.push( a0 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled three-dimensional nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filled3dBy( [ 1, 1, 3 ], constantFunction( 'beep' ) );\n* // returns [ [ [ 'beep', 'beep', 'beep' ] ] ]\n*/\nfunction filled3dBy( shape, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar a1;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\ta1 = [];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\ta0 = [];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\ta0.push( clbk.call( thisArg, [ i2, i1, i0 ] ) );\n\t\t\t}\n\t\t\ta1.push( a0 );\n\t\t}\n\t\tarr.push( a1 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled3dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled four-dimensional nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filled4dBy( [ 1, 1, 1, 3 ], constantFunction( 'beep' ) );\n* // returns [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ]\n*/\nfunction filled4dBy( shape, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\ta2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\ta1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\ta0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ta0.push( clbk.call( thisArg, [ i3, i2, i1, i0 ] ) );\n\t\t\t\t}\n\t\t\t\ta1.push( a0 );\n\t\t\t}\n\t\t\ta2.push( a1 );\n\t\t}\n\t\tarr.push( a2 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled4dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a filled five-dimensional nested array according to a provided callback function.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback function execution context\n* @returns {Array} filled array\n*\n* @example\n* import constantFunction from '@stdlib/utils/constant-function';\n*\n* var out = filled5dBy( [ 1, 1, 1, 1, 3 ], constantFunction( 'beep' ) );\n* // returns [ [ [ [ [ 'beep', 'beep', 'beep' ] ] ] ] ]\n*/\nfunction filled5dBy( shape, clbk, thisArg ) {\n\tvar arr;\n\tvar a0;\n\tvar a1;\n\tvar a2;\n\tvar a3;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\n\t// Manually push elements in order to ensure \"fast\" elements...\n\tarr = [];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\ta3 = [];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\ta2 = [];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\ta1 = [];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\ta0 = [];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\ta0.push( clbk.call( thisArg, [ i4, i3, i2, i1, i0 ] ) );\n\t\t\t\t\t}\n\t\t\t\t\ta1.push( a0 );\n\t\t\t\t}\n\t\t\t\ta2.push( a1 );\n\t\t\t}\n\t\t\ta3.push( a2 );\n\t\t}\n\t\tarr.push( a3 );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filled5dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'filter' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {Array} output array\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, -2, -3, 4 ];\n*\n* var out = internal( x, isPositive );\n* // returns [ 1, 4 ]\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( predicate.call( thisArg, v, i, x ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {Array} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 1, -2, -3, 4 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns [ 1, 4 ]\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tout = [];\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tv = get( data, i );\n\t\tif ( predicate.call( thisArg, v, i, data ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a shallow copy of an array containing only those elements which pass a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {Collection} output array\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, -2, -3, 4 ];\n*\n* var out = filter( x, isPositive );\n* // returns [ 1, 4 ]\n*/\nfunction filter( x, predicate, thisArg ) {\n\tvar obj;\n\tif ( hasMethod( x, 'filter' ) ) {\n\t\treturn x.filter( predicate, thisArg );\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default filter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns the first element of an array-like object.\n*\n* @param {Collection} arr - input array\n* @returns {*} - first element\n*\n* @example\n* var out = first( [ 1, 2, 3 ] );\n* // returns 1\n*/\nfunction first( arr ) {\n\tvar get;\n\n\tif ( arr.length === 0 ) {\n\t\treturn;\n\t}\n\t// Resolve an accessor for retrieving input array elements:\n\tget = resolveGetter( arr );\n\n\t// Return the first element:\n\treturn get( arr, 0 );\n}\n\n\n// EXPORTS //\n\nexport default first;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fliplr4d from './../../../base/fliplr4d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the last dimension of a five-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>>>} x - nested input array\n* @returns {Array>>>} output array\n*\n* @example\n* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ];\n*\n* var out = fliplr5d( x );\n* // returns [ [ [ [ [ 2, 1 ], [ 4, 3 ], [ 6, 5 ] ] ] ] ]\n*/\nfunction fliplr5d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( fliplr4d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fliplr5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport flipud4d from './../../../base/flipud4d';\n\n\n// MAIN //\n\n/**\n* Reverses the order of elements along the second-to-last dimension of a five-dimensional nested input array.\n*\n* ## Notes\n*\n* - The function does **not** perform a deep copy of nested array elements.\n*\n* @param {ArrayLikeObject>>>} x - nested input array\n* @returns {Array>>>} output array\n*\n* @example\n* var x = [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ];\n*\n* var out = flipud5d( x );\n* // returns [ [ [ [ [ 5, 6 ], [ 3, 4 ], [ 1, 2 ] ] ] ] ]\n*/\nfunction flipud5d( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( flipud4d( x[ i ] ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default flipud5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Converts a strided array to a non-strided generic array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified number of elements, index stride, and index offset.\n*\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} stride - index stride\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array( 3, x, 2, 0 );\n* // returns [ 1, 3, 5 ]\n*/\nfunction strided2array( N, x, stride, offset ) {\n\tvar out;\n\tvar get;\n\tvar ix;\n\tvar i;\n\n\t// Resolve an accessor function for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Copy strided elements to a dense non-strided array...\n\tix = offset;\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout.push( get( x, ix ) );\n\t\tix += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default strided2array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups element entries as arrays associated with distinct keys.\n*\n* @param {Collection} x - input array\n* @param {Collection} groups - array defining which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {Object} group results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var groups = [ 'b', 'b', 'f', 'b' ];\n*\n* var out = groupEntries( x, groups );\n* // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] }\n*/\nfunction groupEntries( x, groups ) {\n\tvar xget;\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( groups.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tgget = resolveGetter( groups );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = xget( x, i );\n\t\tg = gget( groups, i ).toString();\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( [ i, v ] );\n\t\t} else {\n\t\t\tout[ g ] = [ [ i, v ] ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupEntries;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups element entries according to an indicator function.\n*\n* @param {Collection} x - input array\n* @param {Function} indicator - indicator function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - indicator function execution context\n* @returns {Object} group results\n*\n* @example\n* function indicator( v ) {\n* return v[ 0 ];\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = groupEntriesBy( x, indicator );\n* // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] }\n*/\nfunction groupEntriesBy( x, indicator, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = get( x, i );\n\t\tg = indicator.call( thisArg, v, i, x );\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( [ i, v ] );\n\t\t} else {\n\t\t\tout[ g ] = [ [ i, v ] ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupEntriesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups element indices as arrays associated with distinct keys.\n*\n* @param {Collection} x - input array\n* @param {Collection} groups - array defining which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {Object} group results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var groups = [ 'b', 'b', 'f', 'b' ];\n*\n* var out = groupIndices( x, groups );\n* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] }\n*/\nfunction groupIndices( x, groups ) {\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( groups.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\t// Resolve accessors for retrieving array elements:\n\tgget = resolveGetter( groups );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tg = gget( groups, i ).toString();\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( i );\n\t\t} else {\n\t\t\tout[ g ] = [ i ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupIndices;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups element indices according to an indicator function.\n*\n* @param {Collection} x - input array\n* @param {Function} indicator - indicator function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - indicator function execution context\n* @returns {Object} group results\n*\n* @example\n* function indicator( v ) {\n* return v[ 0 ];\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = groupIndicesBy( x, indicator );\n* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] }\n*/\nfunction groupIndicesBy( x, indicator, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tg = indicator.call( thisArg, get( x, i ), i, x );\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( i );\n\t\t} else {\n\t\t\tout[ g ] = [ i ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupIndicesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups elements as arrays associated with distinct keys.\n*\n* @param {Collection} x - input array\n* @param {Collection} groups - array defining which group an element in the input array belongs to\n* @throws {RangeError} must provide arrays having the same length\n* @returns {Object} group results\n*\n* @example\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n* var groups = [ 'b', 'b', 'f', 'b' ];\n*\n* var out = groupValues( x, groups );\n* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] }\n*/\nfunction groupValues( x, groups ) {\n\tvar xget;\n\tvar gget;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\tif ( groups.length !== len ) {\n\t\tthrow new RangeError( 'invalid argument. The first and second arguments must have the same length.' );\n\t}\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tgget = resolveGetter( groups );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = xget( x, i );\n\t\tg = gget( groups, i ).toString();\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( v );\n\t\t} else {\n\t\t\tout[ g ] = [ v ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupValues;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups element values according to an indicator function.\n*\n* @param {Collection} x - input array\n* @param {Function} indicator - indicator function specifying which group an element in the input collection belongs to\n* @param {*} [thisArg] - indicator function execution context\n* @returns {Object} group results\n*\n* @example\n* function indicator( v ) {\n* return v[ 0 ];\n* }\n*\n* var x = [ 'beep', 'boop', 'foo', 'bar' ];\n*\n* var out = groupValuesBy( x, indicator );\n* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] }\n*/\nfunction groupValuesBy( x, indicator, thisArg ) {\n\tvar get;\n\tvar len;\n\tvar out;\n\tvar g;\n\tvar o;\n\tvar v;\n\tvar i;\n\n\t// Get the number of elements to group:\n\tlen = x.length;\n\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = get( x, i );\n\t\tg = indicator.call( thisArg, v, i, x );\n\t\to = out[ g ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( v );\n\t\t} else {\n\t\t\tout[ g ] = [ v ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupValuesBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Groups the elements of an array according to a specified property name.\n*\n* @param {Collection} x - input array\n* @param {(string|symbol|number)} key - property name whose values are used to determine groups\n* @returns {Object} group results\n*\n* @example\n* var x = [\n* {\n* 'x': 1,\n* 'y': 2\n* },\n* {\n* 'x': 1,\n* 'y': 3\n* }\n* ];\n*\n* var out = groupValuesOnKey( x, 'y' );\n* // returns { '2': [ { 'x': 1, 'y': 2 } ], '3': [ { 'x': 1, 'y': 3 } ] }\n*/\nfunction groupValuesOnKey( x, key ) {\n\tvar get;\n\tvar out;\n\tvar o;\n\tvar v;\n\tvar i;\n\tvar k;\n\n\t// Resolve an accessor for retrieving array elements:\n\tget = resolveGetter( x );\n\n\t// Loop over the elements and assign each to a group...\n\tout = {};\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tv = get( x, i );\n\t\tk = v[ key ];\n\t\to = out[ k ];\n\t\tif ( isArray( o ) ) {\n\t\t\to.push( v );\n\t\t} else {\n\t\t\tout[ k ] = [ v ];\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default groupValuesOnKey;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from '@stdlib/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'indexOf' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns the index of the first element which equals a provided search element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = internal( x, 2, 0 );\n* // returns 1\n*/\nfunction internal( x, searchElement, fromIndex ) {\n\tvar i;\n\tfor ( i = fromIndex; i < x.length; i++ ) {\n\t\tif ( searchElement === x[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the first element which equals a provided search element.\n*\n* @private\n* @param {Object} x - input array object\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var idx = accessors( x, 2, 0 );\n* // returns 1\n*/\nfunction accessors( x, searchElement, fromIndex ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( x );\n\tfor ( i = fromIndex; i < x.length; i++ ) {\n\t\tif ( searchElement === get( x, i ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n\n// MAIN //\n\n/**\n* Returns the index of the first element which equals a provided search element.\n*\n* ## Notes\n*\n* - If unable to find an element which equals a provided search element, the function returns `-1`.\n*\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {integer} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = indexOf( x, 2, 0 );\n* // returns 1\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var idx = indexOf( x, 2, 0 );\n* // returns 1\n*/\nfunction indexOf( x, searchElement, fromIndex ) {\n\tif ( hasMethod( x, 'indexOf' ) ) {\n\t\treturn x.indexOf( searchElement, fromIndex );\n\t}\n\tif ( fromIndex < 0 ) {\n\t\tfromIndex += x.length;\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex = 0;\n\t\t}\n\t}\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, searchElement, fromIndex );\n\t}\n\treturn internal( x, searchElement, fromIndex );\n}\n\n\n// EXPORTS //\n\nexport default indexOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from '@stdlib/assert/is-accessor-array';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport resolveGetter from './../../../base/resolve-getter';\nimport isSameValue from '@stdlib/assert/is-same-value';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// FUNCTIONS //\n\n/**\n* Returns the index of the first element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = indexed( x, 2, 0 );\n* // returns 1\n*/\nfunction indexed( x, searchElement, fromIndex ) {\n\tvar i;\n\tfor ( i = fromIndex; i < x.length; i++ ) {\n\t\tif ( isSameValue( searchElement, x[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the first element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array object\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var idx = accessors( x, 2, 0 );\n* // returns 1\n*/\nfunction accessors( x, searchElement, fromIndex ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( x );\n\tfor ( i = fromIndex; i < x.length; i++ ) {\n\t\tif ( isSameValue( searchElement, get( x, i ) ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the first element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var idx = complex( x, new Complex128( 3.0, 4.0 ), 1 );\n* // returns 2\n*/\nfunction complex( x, searchElement, fromIndex ) {\n\tvar view;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexLike( searchElement ) ) {\n\t\treturn -1;\n\t}\n\tview = reinterpret( x, 0 );\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tfor ( i = fromIndex*2; i < view.length; i += 2 ) {\n\t\tif ( isSameValue( view[ i ], re ) && isSameValue( view[ i+1 ], im ) ) {\n\t\t\treturn i / 2;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the first element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var x = new BooleanArray( [ true, false, true, false, true ] );\n*\n* var idx = boolean( x, true, 1 );\n* // returns 2\n*/\nfunction boolean( x, searchElement, fromIndex ) {\n\tvar view;\n\tvar v;\n\tvar i;\n\tif ( !isBoolean( searchElement ) ) {\n\t\treturn -1;\n\t}\n\tview = reinterpretBoolean( x, 0 );\n\tv = ( searchElement ) ? 1 : 0;\n\tfor ( i = fromIndex; i < view.length; i++ ) {\n\t\tif ( view[ i ] === v ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n\n// MAIN //\n\n/**\n* Returns the index of the first element which equals a provided search element according to the same value algorithm.\n*\n* ## Notes\n*\n* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n* - If unable to find an element which equals a provided search element, the function returns `-1`.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {integer} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = indexOfSameValue( x, 2, 0 );\n* // returns 1\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var idx = indexOfSameValue( x, 2, 0 );\n* // returns 1\n*/\nfunction indexOfSameValue( x, searchElement, fromIndex ) {\n\tif ( fromIndex < 0 ) {\n\t\tfromIndex += x.length;\n\t\tif ( fromIndex < 0 ) {\n\t\t\tfromIndex = 0;\n\t\t}\n\t}\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, searchElement, fromIndex );\n\t\t}\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn boolean( x, searchElement, fromIndex );\n\t\t}\n\t\treturn accessors( x, searchElement, fromIndex );\n\t}\n\treturn indexed( x, searchElement, fromIndex );\n}\n\n\n// EXPORTS //\n\nexport default indexOfSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the complement of a list of array indices.\n*\n* @param {NonNegativeInteger} N - array length\n* @param {NonNegativeIntegerArray} indices - list of indices\n* @returns {NonNegativeIntegerArray} indices complement\n*\n* @example\n* var idx = indicesComplement( 5, [ 1, 2 ] );\n* // returns [ 0, 3, 4 ]\n*/\nfunction indicesComplement( N, indices ) {\n\tvar hash;\n\tvar out;\n\tvar i;\n\n\thash = {};\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\thash[ indices[ i ] ] = true;\n\t}\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tif ( hash[ i ] === void 0 ) {\n\t\t\tout.push( i );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default indicesComplement;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\nimport isUndefinedOrNull from '@stdlib/assert/is-undefined-or-null';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'join' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns a string created by joining elements in an accessor array using a specified separator.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} separator - separator\n* @returns {string} output string\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = arraylike2object( toAccessorArray( [ 1, 2, 3, 4 ] ) );\n*\n* var out = accessors( x, ',' );\n* // returns '1,2,3,4'\n*/\nfunction accessors( x, separator ) {\n\tvar data;\n\tvar out;\n\tvar get;\n\tvar N;\n\tvar v;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tN = data.length - 1;\n\tout = '';\n\tfor ( i = 0; i <= N; i++ ) {\n\t\tv = get( data, i );\n\t\tif ( !isUndefinedOrNull( v ) ) {\n\t\t\tout += String( v );\n\t\t}\n\t\tif ( i < N ) {\n\t\t\tout += separator;\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Returns a string created by manually joining array elements using a specified separator.\n*\n* @private\n* @param {Object} x - input array object\n* @param {integer} separator - separator\n* @returns {string} output string\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = indexed( x, ',' );\n* // returns '1,2,3,4'\n*/\nfunction indexed( x, separator ) {\n\tvar out;\n\tvar N;\n\tvar v;\n\tvar i;\n\n\tN = x.length - 1;\n\tout = '';\n\tfor ( i = 0; i <= N; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( !isUndefinedOrNull( v ) ) {\n\t\t\tout += String( v );\n\t\t}\n\t\tif ( i < N ) {\n\t\t\tout += separator;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a string created by joining array elements using a specified separator.\n*\n* @param {Collection} x - input array\n* @param {integer} separator - separator\n* @returns {string} output string\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = join( x, ',' );\n* // returns '1,2,3,4'\n*\n* @example\n* var x = [ 1, 2, 3, null, undefined, 4 ];\n*\n* var out = join( x, '-' );\n* // returns '1-2-3---4'\n*/\nfunction join( x, separator ) {\n\tvar obj;\n\tif ( hasMethod( x, 'join' ) ) {\n\t\treturn x.join( separator );\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, separator );\n\t}\n\treturn indexed( x, separator );\n}\n\n\n// EXPORTS //\n\nexport default join;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns the last element of an array-like object.\n*\n* @param {Collection} arr - input array\n* @returns {*} - last element\n*\n* @example\n* var out = last( [ 1, 2, 3 ] );\n* // returns 3\n*/\nfunction last( arr ) {\n\tvar get;\n\tvar idx;\n\n\t// Resolve an accessor for retrieving input array elements:\n\tget = resolveGetter( arr );\n\n\t// Resolve the last index:\n\tidx = arr.length - 1;\n\n\t// Return the last element:\n\tif ( idx < 0 ) {\n\t\treturn;\n\t}\n\treturn get( arr, idx );\n}\n\n\n// EXPORTS //\n\nexport default last;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from '@stdlib/assert/is-accessor-array';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'lastIndexOf' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns the index of the last element which equals a provided search element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = internal( x, 2, 3 );\n* // returns 1\n*/\nfunction internal( x, searchElement, fromIndex ) {\n\tvar i;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( searchElement === x[ i ] ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the last element which equals a provided search element.\n*\n* @private\n* @param {Object} x - input array object\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var idx = accessors( x, 2, 3 );\n* // returns 1\n*/\nfunction accessors( x, searchElement, fromIndex ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( x );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( searchElement === get( x, i ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n\n// MAIN //\n\n/**\n* Returns the index of the last element which equals a provided search element.\n*\n* ## Notes\n*\n* - If unable to find an element which equals a provided search element, the function returns `-1`.\n*\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {integer} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = lastIndexOf( x, 2, 3 );\n* // returns 1\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var idx = lastIndexOf( x, 2, 3 );\n* // returns 1\n*/\nfunction lastIndexOf( x, searchElement, fromIndex ) {\n\tif ( hasMethod( x, 'lastIndexOf' ) ) {\n\t\treturn x.lastIndexOf( searchElement, fromIndex );\n\t}\n\tif ( fromIndex < 0 ) {\n\t\tfromIndex += x.length;\n\t\tif ( fromIndex < 0 ) {\n\t\t\treturn -1;\n\t\t}\n\t} else if ( fromIndex > x.length ) {\n\t\tfromIndex = x.length - 1;\n\t}\n\tif ( isAccessorArray( x ) ) {\n\t\treturn accessors( x, searchElement, fromIndex );\n\t}\n\treturn internal( x, searchElement, fromIndex );\n}\n\n\n// EXPORTS //\n\nexport default lastIndexOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from '@stdlib/assert/is-accessor-array';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport reinterpret from '@stdlib/strided/base/reinterpret-complex';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport isComplexTypedArray from './../../../base/assert/is-complex-typed-array';\nimport isBooleanArray from './../../../base/assert/is-booleanarray';\nimport resolveGetter from './../../../base/resolve-getter';\nimport isSameValue from '@stdlib/assert/is-same-value';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\n\n\n// FUNCTIONS //\n\n/**\n* Returns the index of the last element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = indexed( x, 2, 3 );\n* // returns 1\n*/\nfunction indexed( x, searchElement, fromIndex ) {\n\tvar i;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( isSameValue( searchElement, x[ i ] ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the last element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Object} x - input array object\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var idx = accessors( x, 2, 3 );\n* // returns 1\n*/\nfunction accessors( x, searchElement, fromIndex ) {\n\tvar get;\n\tvar i;\n\n\tget = resolveGetter( x );\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( isSameValue( searchElement, get( x, i ) ) ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the last element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var idx = complex( x, new Complex128( 3.0, 4.0 ), 3 );\n* // returns 2\n*/\nfunction complex( x, searchElement, fromIndex ) {\n\tvar view;\n\tvar re;\n\tvar im;\n\tvar i;\n\tif ( !isComplexLike( searchElement ) ) {\n\t\treturn -1;\n\t}\n\tview = reinterpret( x, 0 );\n\tre = real( searchElement );\n\tim = imag( searchElement );\n\tfor ( i = fromIndex*2; i >= 0; i -= 2 ) {\n\t\tif ( isSameValue( view[ i ], re ) && isSameValue( view[ i+1 ], im ) ) {\n\t\t\treturn i / 2;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n* Returns the index of the last element which equals a provided search element according to the same value algorithm.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {NonNegativeInteger} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var x = new BooleanArray( [ true, false, true, false, true ] );\n*\n* var idx = boolean( x, true, 3 );\n* // returns 2\n*/\nfunction boolean( x, searchElement, fromIndex ) {\n\tvar view;\n\tvar v;\n\tvar i;\n\tif ( !isBoolean( searchElement ) ) {\n\t\treturn -1;\n\t}\n\tview = reinterpretBoolean( x, 0 );\n\tv = ( searchElement ) ? 1 : 0;\n\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\tif ( view[ i ] === v ) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n\n// MAIN //\n\n/**\n* Returns the index of the last element which equals a provided search element according to the same value algorithm.\n*\n* ## Notes\n*\n* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.\n* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.\n* - If unable to find an element which equals a provided search element, the function returns `-1`.\n*\n* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12\n*\n* @param {Collection} x - input array\n* @param {*} searchElement - search element\n* @param {integer} fromIndex - starting index (inclusive)\n* @returns {integer} index\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var idx = lastIndexOfSameValue( x, 2, 3 );\n* // returns 1\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var idx = lastIndexOfSameValue( x, 2, 3 );\n* // returns 1\n*/\nfunction lastIndexOfSameValue( x, searchElement, fromIndex ) {\n\tif ( fromIndex < 0 ) {\n\t\tfromIndex += x.length;\n\t\tif ( fromIndex < 0 ) {\n\t\t\treturn -1;\n\t\t}\n\t} else if ( fromIndex > x.length ) {\n\t\tfromIndex = x.length - 1;\n\t}\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, searchElement, fromIndex );\n\t\t}\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn boolean( x, searchElement, fromIndex );\n\t\t}\n\t\treturn accessors( x, searchElement, fromIndex );\n\t}\n\treturn indexed( x, searchElement, fromIndex );\n}\n\n\n// EXPORTS //\n\nexport default lastIndexOfSameValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array.\n*\n* @param {number} x1 - first array value\n* @param {number} x2 - last array value\n* @param {NonNegativeInteger} len - length of output array\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = linspace( 0, 100, 6 );\n* // returns [ 0, 20, 40, 60, 80, 100 ]\n*/\nfunction linspace( x1, x2, len ) {\n\tvar arr;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Calculate the increment:\n\tN = len - 1;\n\td = ( x2-x1 ) / N;\n\n\t// Build the output array...\n\tarr = [ x1 ];\n\tfor ( i = 1; i < N; i++ ) {\n\t\tarr.push( x1 + (d*i) );\n\t}\n\tarr.push( x2 );\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced two-dimensional nested numeric array.\n*\n* @param {number} start - first array value\n* @param {number} stop - last array value\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {boolean} colexicographic - specifies whether generated array values should be stored in colexicographic order\n* @returns {Array} linearly spaced two-dimensional nested numeric array\n*\n* @example\n* var x = linspace2d( 0, 100, [ 2, 3 ], false );\n* // returns [ [ 0, 20, 40 ], [ 60, 80, 100 ] ]\n*\n* x = linspace2d( 0, 100, [ 2, 3 ], true );\n* // returns [ [ 0, 40, 80 ], [ 20, 60, 100 ] ]\n*/\nfunction linspace2d( start, stop, shape, colexicographic ) {\n\tvar inc0;\n\tvar inc1;\n\tvar out;\n\tvar tmp;\n\tvar idx;\n\tvar s0;\n\tvar i0;\n\tvar s1;\n\tvar i1;\n\tvar d;\n\tvar n;\n\n\ts0 = shape[ 1 ];\n\ts1 = shape[ 0 ];\n\n\tn = s0 * s1;\n\tif ( n === 0 ) {\n\t\treturn [];\n\t}\n\td = ( stop - start ) / ( n - 1 );\n\tif ( colexicographic ) {\n\t\tinc0 = s1; // index increment for the innermost loop\n\t\tinc1 = 1 - ( s0 * inc0 ); // index increment for the outermost loop\n\t} else {\n\t\tinc0 = 1; // index increment for the innermost loop\n\t\tinc1 = 0; // index increment for the outermost loop\n\t}\n\tout = [];\n\tidx = 0;\n\tfor ( i1 = 0; i1 < s1; i1++ ) {\n\t\ttmp = [];\n\t\tfor ( i0 = 0; i0 < s0; i0++ ) {\n\t\t\ttmp.push( start + ( idx * d ) );\n\t\t\tidx += inc0;\n\t\t}\n\t\tout.push( tmp );\n\t\tidx += inc1;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport UINT8_MAX from '@stdlib/constants/uint8/max';\nimport UINT16_MAX from '@stdlib/constants/uint16/max';\nimport UINT32_MAX from '@stdlib/constants/uint32/max';\n\n\n// MAIN //\n\n/**\n* Returns the minimum array data type for storing a provided unsigned integer value.\n*\n* @param {uinteger} value - scalar value\n* @returns {string} array data type\n*\n* @example\n* var dt = minUnsignedIntegerDataType( 9999 );\n* // returns 'uint16'\n*\n* @example\n* var dt = minUnsignedIntegerDataType( 3 );\n* // returns 'uint8'\n*/\nfunction minUnsignedIntegerDataType( value ) { // eslint-disable-line id-length\n\tif ( value <= UINT8_MAX ) {\n\t\treturn 'uint8';\n\t}\n\tif ( value <= UINT16_MAX ) {\n\t\treturn 'uint16';\n\t}\n\tif ( value <= UINT32_MAX ) {\n\t\treturn 'uint32';\n\t}\n\treturn 'float64';\n}\n\n\n// EXPORTS //\n\nexport default minUnsignedIntegerDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two two-dimensional nested input arrays according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = ones2d( shape );\n* var z = zeros2d( shape );\n*\n* var mask = [ [ 0, 1 ], [ 0, 0 ] ];\n*\n* mskbinary2d( [ x, y, mask, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ]\n*/\nfunction mskbinary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar m0;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar m;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 3 ];\n\tm = arrays[ 2 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tz0 = z[ i1 ];\n\t\tm0 = m[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskbinary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two three-dimensional nested input arrays according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 2, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = ones3d( shape );\n* var z = zeros3d( shape );\n*\n* var mask = [\n* [ [ 0, 1 ], [ 0, 0 ] ],\n* [ [ 1, 0 ], [ 0, 1 ] ]\n* ];\n*\n* mskbinary3d( [ x, y, mask, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ], [ [ 0.0, 2.0 ], [ 2.0, 0.0 ] ] ]\n*/\nfunction mskbinary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar m0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar m1;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar m;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 3 ];\n\tm = arrays[ 2 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tz1 = z[ i2 ];\n\t\tm1 = m[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tm0 = m1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskbinary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two four-dimensional nested input arrays according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = ones4d( shape );\n* var z = zeros4d( shape );\n*\n* var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ];\n*\n* mskbinary4d( [ x, y, mask, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ]\n*/\nfunction mskbinary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar m;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tm = arrays[ 2 ];\n\tz = arrays[ 3 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tz2 = z[ i3 ];\n\t\tm2 = m[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tm1 = m2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tm0 = m1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskbinary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a binary callback to elements in two five-dimensional nested input arrays according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing two input nested arrays, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - binary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import add from '@stdlib/number/float64/base/add';\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = ones5d( shape );\n* var z = zeros5d( shape );\n*\n* var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ];\n*\n* mskbinary5d( [ x, y, mask, z ], shape, add );\n*\n* console.log( z );\n* // => [ [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ] ]\n*/\nfunction mskbinary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar z0;\n\tvar z1;\n\tvar z2;\n\tvar z3;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar m;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tm = arrays[ 2 ];\n\tz = arrays[ 3 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tz3 = z[ i4 ];\n\t\tm3 = m[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tm2 = m3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tm1 = m2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tm0 = m1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\t\t\tz0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskbinary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns new arrays by applying a mask to two provided input arrays in a single pass.\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {Collection} mask - mask array\n* @returns {Array} output arrays\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = mskfilter2( x, y, mask );\n* // returns [ [ 2, 4 ], [ 6, 8 ] ]\n*/\nfunction mskfilter2( x, y, mask ) {\n\tvar xget;\n\tvar yget;\n\tvar mget;\n\tvar o1;\n\tvar o2;\n\tvar i;\n\n\t// Resolve accessors for retrieving array elements:\n\txget = resolveGetter( x );\n\tyget = resolveGetter( y );\n\tmget = resolveGetter( mask );\n\n\t// Extract each desired element from the provided arrays...\n\to1 = [];\n\to2 = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( mget( mask, i ) ) {\n\t\t\to1.push( xget( x, i ) ); // use `Array#push` to ensure \"fast\" elements\n\t\t\to2.push( yget( y, i ) );\n\t\t}\n\t}\n\treturn [ o1, o2 ];\n}\n\n\n// EXPORTS //\n\nexport default mskfilter2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Returns new arrays by applying a mask to one or more provided input arrays in a single pass.\n*\n* @param {Collection} x - first input array\n* @param {Collection} [...arrays] - additional input arrays\n* @param {Collection} mask - mask array\n* @returns {Array} output arrays\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var out = mskfiltern( x, y, mask );\n* // returns [ [ 2, 4 ], [ 6, 8 ] ]\n*/\nfunction mskfiltern() {\n\tvar getters;\n\tvar arrays;\n\tvar nargs;\n\tvar mget;\n\tvar mask;\n\tvar out;\n\tvar i;\n\tvar j;\n\n\tnargs = arguments.length;\n\tnargs -= 1;\n\n\t// Resolve the mask array and its associated accessor:\n\tmask = arguments[ nargs ];\n\tmget = resolveGetter( mask );\n\n\t// Resolve accessors for retrieving array elements and initialize the output arrays...\n\tgetters = [];\n\tarrays = [];\n\tout = [];\n\tfor ( i = 0; i < nargs; i++ ) {\n\t\tarrays.push( arguments[ i ] );\n\t\tgetters.push( resolveGetter( arrays[ i ] ) );\n\t\tout.push( [] );\n\t}\n\t// Extract each desired element from the provided arrays...\n\tfor ( i = 0; i < mask.length; i++ ) {\n\t\tif ( mget( mask, i ) ) {\n\t\t\tfor ( j = 0; j < nargs; j++ ) {\n\t\t\t\tout[ j ].push( getters[ j ]( arrays[ j ], i ) ); // use `Array#push` to ensure \"fast\" elements\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default mskfiltern;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a two-dimensional nested input array according to elements in a two-dimensional nested mask array and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = zeros2d( shape );\n*\n* var mask = [ [ 0, 1 ], [ 0, 0 ] ];\n*\n* mskunary2d( [ x, mask, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ]\n*/\nfunction mskunary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar m0;\n\tvar x;\n\tvar y;\n\tvar m;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 2 ];\n\tm = arrays[ 1 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tm0 = m[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskunary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a three-dimensional nested input array according to elements in a three-dimensional nested mask array and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = zeros3d( shape );\n*\n* var mask = [ [ [ 0, 1 ], [ 0, 0 ] ] ];\n*\n* mskunary3d( [ x, mask, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ]\n*/\nfunction mskunary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar m0;\n\tvar m1;\n\tvar x;\n\tvar y;\n\tvar m;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 2 ];\n\tm = arrays[ 1 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tm1 = m[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tm0 = m1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskunary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a four-dimensional nested input array according to elements in a four-dimensional nested mask array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ];\n*\n* mskunary4d( [ x, mask, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction mskunary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar x;\n\tvar y;\n\tvar m;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 2 ];\n\tm = arrays[ 1 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tm2 = m[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tm1 = m2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tm0 = m1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskunary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-depth */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a five-dimensional nested input array according to elements in a five-dimensional nested mask array and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array, an input nested mask array, and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = zeros5d( shape );\n*\n* var mask = [ [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ] ];\n*\n* mskunary5d( [ x, mask, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ [ [ 10.0, 0.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*/\nfunction mskunary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar m0;\n\tvar m1;\n\tvar m2;\n\tvar m3;\n\tvar x;\n\tvar y;\n\tvar m;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 2 ];\n\tm = arrays[ 1 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tm3 = m[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tm2 = m3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tm1 = m2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tm0 = m1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tif ( m0[ i0 ] === 0 ) {\n\t\t\t\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default mskunary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns the n-fold Cartesian product.\n*\n* ## Notes\n*\n* - The main insight of this implementation is that the n-fold Cartesian product can be presented as an n-dimensional array stored in row-major order. As such, we can\n*\n* - Compute the total number of tuples, which is simply the product of the size of each provided array (set). For n-dimensional arrays, this is the equivalent of computing the product of array dimensions to determine the total number of elements.\n* - Initialize an array for storing indices for indexing into each provided array. For n-dimensional arrays, the index array is equivalent to an array of subscripts for indexing into each dimension.\n* - For the outermost loop, treat the loop index as a linear index into an n-dimensional array and resolve the corresponding subscripts.\n* - Continue iterating until all tuples have been generated.\n*\n* @param {ArrayLikeObject} x1 - first input array\n* @param {ArrayLikeObject} x2 - second input array\n* @param {ArrayLikeObject} [...args] - additional input arrays\n* @returns {Array} list of ordered tuples comprising the n-fold Cartesian product\n*\n* @example\n* var x1 = [ 1, 2, 3 ];\n* var x2 = [ 4, 5 ];\n*\n* var out = nCartesianProduct( x1, x2 );\n* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ]\n*/\nfunction nCartesianProduct( x1, x2 ) {\n\tvar nargs;\n\tvar dims;\n\tvar arr;\n\tvar out;\n\tvar tmp;\n\tvar arg;\n\tvar idx;\n\tvar N;\n\tvar s;\n\tvar i;\n\tvar j;\n\tvar k;\n\n\tnargs = arguments.length;\n\n\t// Initialize the list of arrays:\n\tarr = [ x1, x2 ];\n\n\t// Initialize the list of array dimensions (equivalent to ndarray shape):\n\tdims = [ x1.length, x2.length ];\n\n\t// Initialize a list of indices for indexing into each array (equivalent to ndarray subscripts):\n\tidx = [ 0, 0 ];\n\n\t// Compute the total number of ordered tuples:\n\tN = dims[ 0 ] * dims[ 1 ];\n\n\t// Update loop variables for any additional arrays...\n\tfor ( i = 2; i < nargs; i++ ) {\n\t\targ = arguments[ i ];\n\t\tarr.push( arg );\n\t\tdims.push( arg.length );\n\t\tidx.push( 0 );\n\t\tN *= dims[ i ];\n\t}\n\t// Compute the n-fold Cartesian product...\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\t// Resolve a linear index to array indices (logic is equivalent to what is found in ndarray/base/ind2sub for an ndarray stored in row-major order; see https://github.com/stdlib-js/stdlib/blob/215ca5355f3404f15996fd0ced58a98e46f22be6/lib/node_modules/%40stdlib/ndarray/base/ind2sub/lib/assign.js)...\n\t\tk = i;\n\t\tfor ( j = nargs-1; j >= 0; j-- ) {\n\t\t\ts = k % dims[ j ];\n\t\t\tk -= s;\n\t\t\tk /= dims[ j ];\n\t\t\tidx[ j ] = s;\n\t\t}\n\t\t// Generate the next ordered tuple...\n\t\ttmp = [];\n\t\tfor ( j = 0; j < nargs; j++ ) {\n\t\t\ttmp.push( arr[ j ][ idx[ j ] ] );\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default nCartesianProduct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport copy from './../../../base/copy';\n\n\n// MAIN //\n\n/**\n* Converts each nested array to an object.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length.\n* - The number of provided array labels should equal the length of each nested array.\n*\n* @param {Collection} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2objects( x, fields );\n* // returns [ { 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 } ]\n*/\nfunction nested2objects( arr, fields ) {\n\tvar names;\n\tvar oget;\n\tvar get;\n\tvar out;\n\tvar obj;\n\tvar tmp;\n\tvar M;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\t// Resolve the accessor for the outer array:\n\toget = resolveGetter( arr );\n\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Copy the list of fields to an indexed array to avoid repeated accessor calls:\n\tnames = copy( fields );\n\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\ttmp = oget( arr, i );\n\t\tget = resolveGetter( tmp );\n\t\tobj = {};\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tobj[ names[ j ] ] = get( tmp, j );\n\t\t}\n\t\tout.push( obj );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default nested2objects;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setNonEnumerable from '@stdlib/utils/define-nonenumerable-property';\nimport setReadWriteAccessor from '@stdlib/utils/define-read-write-accessor';\nimport resolveGetter from './../../../base/resolve-getter';\nimport accessors from './../../../base/accessors';\nimport copy from './../../../base/copy';\n\n\n// MAIN //\n\n/**\n* Converts each nested array to a composite view.\n*\n* ## Notes\n*\n* - The function assumes that all nested arrays have the same length.\n* - The number of provided array labels should equal the length of each nested array.\n* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other.\n*\n* @param {Collection} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tif ( predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = noneBy( x, isPositive );\n* // returns true\n*/\nfunction noneBy( x, predicate, thisArg ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default noneBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = internal( x, isPositive );\n* // returns true\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar i;\n\tfor ( i = x.length-1; i >= 0; i-- ) {\n\t\tif ( predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 0, 0, 0, 0 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns true\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tfor ( i = data.length-1; i >= 0; i-- ) {\n\t\tif ( predicate.call( thisArg, get( data, i ), i, data ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// MAIN //\n\n/**\n* Tests whether all elements in an array fail a test implemented by a predicate function, iterating from right to left.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {boolean} boolean indicating whether all elements fail a test\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 0 ];\n*\n* var out = noneByRight( x, isPositive );\n* // returns true\n*/\nfunction noneByRight( x, predicate, thisArg ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default noneByRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a \"generic\" array filled with null values.\n*\n* @param {NonNegativeInteger} len - array length\n* @returns {Array} output array\n*\n* @example\n* var out = nulls( 3 );\n* // returns [ null, null, null ]\n*/\nfunction nulls( len ) {\n\treturn filled( null, len );\n}\n\n\n// EXPORTS //\n\nexport default nulls;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\n\n\n// MAIN //\n\n/**\n* Returns a \"generic\" array filled with ones.\n*\n* @param {NonNegativeInteger} len - array length\n* @returns {Array} output array\n*\n* @example\n* var out = ones( 3 );\n* // returns [ 1.0, 1.0, 1.0 ]\n*/\nfunction ones( len ) {\n\treturn filled( 1.0, len );\n}\n\n\n// EXPORTS //\n\nexport default ones;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled2d from './../../../base/filled2d';\n\n\n// MAIN //\n\n/**\n* Returns a two-dimensional nested array filled with ones.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {ArrayArray} filled array\n*\n* @example\n* var out = ones2d( [ 1, 3 ] );\n* // returns [ [ 1.0, 1.0, 1.0 ] ]\n*/\nfunction ones2d( shape ) {\n\treturn filled2d( 1.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default ones2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled3d from './../../../base/filled3d';\n\n\n// MAIN //\n\n/**\n* Returns a three-dimensional nested array filled with ones.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = ones3d( [ 1, 1, 3 ] );\n* // returns [ [ [ 1.0, 1.0, 1.0 ] ] ]\n*/\nfunction ones3d( shape ) {\n\treturn filled3d( 1.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default ones3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled4d from './../../../base/filled4d';\n\n\n// MAIN //\n\n/**\n* Returns a four-dimensional nested array filled with ones.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = ones4d( [ 1, 1, 1, 3 ] );\n* // returns [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ]\n*/\nfunction ones4d( shape ) {\n\treturn filled4d( 1.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default ones4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled5d from './../../../base/filled5d';\n\n\n// MAIN //\n\n/**\n* Returns a five-dimensional nested array filled with ones.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = ones5d( [ 1, 1, 1, 1, 3 ] );\n* // returns [ [ [ [ [ 1.0, 1.0, 1.0 ] ] ] ] ]\n*/\nfunction ones5d( shape ) {\n\treturn filled5d( 1.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default ones5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fillednd from './../../../base/fillednd';\n\n\n// MAIN //\n\n/**\n* Returns an n-dimensional nested array filled with ones.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = onesnd( [ 3 ] );\n* // returns [ 1.0, 1.0, 1.0 ]\n*\n* @example\n* var out = onesnd( [ 1, 3 ] );\n* // returns [ [ 1.0, 1.0, 1.0 ] ]\n*/\nfunction onesnd( shape ) {\n\treturn fillednd( 1.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default onesnd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = ones2d( shape );\n* var z = ones2d( shape );\n* var w = ones2d( shape );\n* var out = zeros2d( shape );\n*\n* quaternary2d( [ x, y, z, w, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ]\n*/\nfunction quaternary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar v0;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar v;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tv = arrays[ 4 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tz0 = z[ i1 ];\n\t\tw0 = w[ i1 ];\n\t\tv0 = v[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quaternary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = ones3d( shape );\n* var z = ones3d( shape );\n* var w = ones3d( shape );\n* var out = zeros3d( shape );\n*\n* quaternary3d( [ x, y, z, w, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ]\n*/\nfunction quaternary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar v1;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar v;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tv = arrays[ 4 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tz1 = z[ i2 ];\n\t\tw1 = w[ i2 ];\n\t\tv1 = v[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tw0 = w1[ i1 ];\n\t\t\tv0 = v1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quaternary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = ones4d( shape );\n* var z = ones4d( shape );\n* var w = ones4d( shape );\n* var out = zeros4d( shape );\n*\n* quaternary4d( [ x, y, z, w, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ]\n*/\nfunction quaternary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar v1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar v2;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar v;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tv = arrays[ 4 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tz2 = z[ i3 ];\n\t\tw2 = w[ i3 ];\n\t\tv2 = v[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tw1 = w2[ i2 ];\n\t\t\tv1 = v2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\tv0 = v1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quaternary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quaternary callback to elements in four five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>} arrays - array-like object containing four input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quaternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add4';\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = ones5d( shape );\n* var z = ones5d( shape );\n* var w = ones5d( shape );\n* var out = zeros5d( shape );\n*\n* quaternary5d( [ x, y, z, w, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] ] ] ]\n*/\nfunction quaternary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar v1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar v2;\n\tvar x3;\n\tvar y3;\n\tvar z3;\n\tvar w3;\n\tvar v3;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar v;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tv = arrays[ 4 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tz3 = z[ i4 ];\n\t\tw3 = w[ i4 ];\n\t\tv3 = v[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tw2 = w3[ i3 ];\n\t\t\tv2 = v3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tw1 = w2[ i2 ];\n\t\t\t\tv1 = v2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\t\tv0 = v1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ] ); // eslint-disable-line max-len\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quaternary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n* import add from '@stdlib/number/float64/base/add5';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = ones2d( shape );\n* var z = ones2d( shape );\n* var w = ones2d( shape );\n* var v = ones2d( shape );\n* var out = zeros2d( shape );\n*\n* quinary2d( [ x, y, z, w, v, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ]\n*/\nfunction quinary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar v0;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tu = arrays[ 4 ];\n\tv = arrays[ 5 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tz0 = z[ i1 ];\n\t\tw0 = w[ i1 ];\n\t\tu0 = u[ i1 ];\n\t\tv0 = v[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quinary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n* import add from '@stdlib/number/float64/base/add5';\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = ones3d( shape );\n* var z = ones3d( shape );\n* var w = ones3d( shape );\n* var v = ones3d( shape );\n* var out = zeros3d( shape );\n*\n* quinary3d( [ x, y, z, w, v, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ]\n*/\nfunction quinary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar u1;\n\tvar v1;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tu = arrays[ 4 ];\n\tv = arrays[ 5 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tz1 = z[ i2 ];\n\t\tw1 = w[ i2 ];\n\t\tu1 = u[ i2 ];\n\t\tv1 = v[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tw0 = w1[ i1 ];\n\t\t\tu0 = u1[ i1 ];\n\t\t\tv0 = v1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] ); // eslint-disable-line max-len\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quinary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n* import add from '@stdlib/number/float64/base/add5';\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = ones4d( shape );\n* var z = ones4d( shape );\n* var w = ones4d( shape );\n* var v = ones4d( shape );\n* var out = zeros4d( shape );\n*\n* quinary4d( [ x, y, z, w, v, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ]\n*/\nfunction quinary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar u1;\n\tvar v1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar u2;\n\tvar v2;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tu = arrays[ 4 ];\n\tv = arrays[ 5 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tz2 = z[ i3 ];\n\t\tw2 = w[ i3 ];\n\t\tu2 = u[ i3 ];\n\t\tv2 = v[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tw1 = w2[ i2 ];\n\t\t\tu1 = u2[ i2 ];\n\t\t\tv1 = v2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\tu0 = u1[ i1 ];\n\t\t\t\tv0 = v1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quinary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a quinary callback to elements in five five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>>} arrays - array-like object containing five input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - quinary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n* import add from '@stdlib/number/float64/base/add5';\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = ones5d( shape );\n* var z = ones5d( shape );\n* var w = ones5d( shape );\n* var v = ones5d( shape );\n* var out = zeros5d( shape );\n*\n* quinary5d( [ x, y, z, w, v, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] ] ] ]\n*/\nfunction quinary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar u0;\n\tvar v0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar u1;\n\tvar v1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar u2;\n\tvar v2;\n\tvar x3;\n\tvar y3;\n\tvar z3;\n\tvar w3;\n\tvar u3;\n\tvar v3;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\tvar u;\n\tvar v;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tu = arrays[ 4 ];\n\tv = arrays[ 5 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tz3 = z[ i4 ];\n\t\tw3 = w[ i4 ];\n\t\tu3 = u[ i4 ];\n\t\tv3 = v[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tw2 = w3[ i3 ];\n\t\t\tu2 = u3[ i3 ];\n\t\t\tv2 = v3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tw1 = w2[ i2 ];\n\t\t\t\tu1 = u2[ i2 ];\n\t\t\t\tv1 = v2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\t\tu0 = u1[ i1 ];\n\t\t\t\t\tv0 = v1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tv0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ], w0[ i0 ], u0[ i0 ] ); // eslint-disable-line max-len\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default quinary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {Array} output array\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, -2, -3, 4 ];\n*\n* var out = internal( x, isPositive );\n* // returns [ -2, -3 ]\n*/\nfunction internal( x, predicate, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( !predicate.call( thisArg, v, i, x ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {Array} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = arraylike2object( toAccessorArray( [ 1, -2, -3, 4 ] ) );\n*\n* var out = accessors( x, isPositive );\n* // returns [ -2, -3 ]\n*/\nfunction accessors( x, predicate, thisArg ) {\n\tvar data;\n\tvar get;\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tout = [];\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tv = get( data, i );\n\t\tif ( !predicate.call( thisArg, v, i, data ) ) {\n\t\t\tout.push( v );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a shallow copy of an array containing only those elements which fail a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {Collection} output array\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 1, -2, -3, 4 ];\n*\n* var out = reject( x, isPositive );\n* // returns [ -2, -3 ]\n*/\nfunction reject( x, predicate, thisArg ) {\n\tvar obj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj, predicate, thisArg );\n\t}\n\treturn internal( x, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default reject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Copies and renames specified keys for every element in a provided array.\n*\n* ## Notes\n*\n* - The function only copies and renames those keys which are present in a provided mapping object. Any keys which are not present in the provided mapping object, but are present in the original objects, are omitted during object creation.\n* - The function assumes that each object has the keys specified in a provided mapping object.\n* - The function performs shallow copies of key values.\n*\n* @param {ArrayLikeObject} arr - input array\n* @param {Object} mapping - object mapping existing keys to new key names\n* @returns {Array} output array\n*\n* @example\n* var x = [\n* {\n* 'x': 1,\n* 'y': 2\n* },\n* {\n* 'x': 3,\n* 'y': 4\n* }\n* ];\n* var mapping = {\n* 'x': 'a',\n* 'y': 'b'\n* };\n*\n* var out = rekey( x, mapping );\n* // returns [ { 'a': 1, 'b': 2 }, { 'a': 3, 'b': 4 } ]\n*/\nfunction rekey( arr, mapping ) {\n\tvar okeys;\n\tvar nkeys;\n\tvar get;\n\tvar out;\n\tvar obj;\n\tvar tmp;\n\tvar M;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\t// Resolve the list of old key names:\n\tokeys = objectKeys( mapping );\n\tN = okeys.length;\n\n\t// Resolve the list of new key names:\n\tnkeys = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tnkeys.push( mapping[ okeys[ i ] ] );\n\t}\n\n\tget = resolveGetter( arr );\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\ttmp = get( arr, i );\n\t\tobj = {};\n\t\tfor ( j = 0; j < N; j++ ) {\n\t\t\tobj[ nkeys[ j ] ] = tmp[ okeys[ j ] ];\n\t\t}\n\t\tout.push( obj );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default rekey;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils/define-read-write-accessor';\nimport resolveGetter from './../../../base/resolve-getter';\nimport objectKeys from '@stdlib/utils/keys';\n\n\n// MAIN //\n\n/**\n* Returns an array containing views with renamed keys for every element in a provided array.\n*\n* ## Notes\n*\n* - The function returns views having only those keys which are present in a provided mapping object. Any keys which are not present in the provided mapping object, but are present in the original objects, are omitted during view creation.\n* - The function assumes that each object has the keys specified in a provided mapping object.\n* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either an array element or a view will mutate the other.\n*\n* @param {ArrayLikeObject} arr - input array\n* @param {Object} mapping - object mapping existing keys to new key names\n* @returns {Array} output array\n*\n* @example\n* var x = [\n* {\n* 'x': 1,\n* 'y': 2\n* },\n* {\n* 'x': 3,\n* 'y': 4\n* }\n* ];\n* var mapping = {\n* 'x': 'a',\n* 'y': 'b'\n* };\n*\n* var out = rekeyViews( x, mapping );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'a': 1, 'b': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'a': 3, 'b': 4 }\n*\n* // Mutate the first element in the input array:\n* x[ 0 ].x = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'a': 5, 'b': 2 }\n*\n* // Set a view property:\n* out[ 1 ].b = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'a': 3, 'b': 'beep' }\n*\n* var y = x.slice();\n* // returns [ { 'x': 5, 'y': 2 }, { 'x': 3, 'y': 'beep' } ]\n*/\nfunction rekeyViews( arr, mapping ) {\n\tvar getter;\n\tvar okeys;\n\tvar nkeys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\t// Resolve the list of old key names:\n\tokeys = objectKeys( mapping );\n\tN = okeys.length;\n\n\t// Resolve the list of new key names:\n\tnkeys = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tnkeys.push( mapping[ okeys[ i ] ] );\n\t}\n\t// Resolve the accessor for the input array:\n\tgetter = resolveGetter( arr );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( i ) {\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, nkeys[ i ], getValue( okeys[ i ] ), setValue( okeys[ i ] ) ); // eslint-disable-line max-len\n\t}\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {string} key - field name\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( key ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\treturn getter( arr, this._i )[ key ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {string} key - field name\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( key ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tgetter( arr, this._i )[ key ] = value;\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = nkeys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default rekeyViews;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Removes an element from an array.\n*\n* @param {Array} x - input array\n* @param {integer} index - element index\n* @returns {Array} mutated input array\n*\n* @example\n* var x = [ 1, 1, 2, 3, 3 ];\n*\n* var y = removeAt( x, -3 );\n* // returns [ 1, 1, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns true\n*/\nfunction removeAt( x, index ) {\n\tvar len;\n\tvar i;\n\tvar j;\n\n\tlen = x.length;\n\tif ( index < 0 ) {\n\t\tindex += len;\n\t\tif ( index < 0 ) {\n\t\t\treturn x;\n\t\t}\n\t} else if ( index >= len ) {\n\t\treturn x;\n\t}\n\tj = index;\n\tfor ( i = index+1; i < len; i++ ) {\n\t\tx[ j ] = x[ i ];\n\t\tj += 1;\n\t}\n\tx.length = j;\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default removeAt;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\nimport floor from '@stdlib/math/base/special/floor';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'reverse' );\n* // returns true\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Reverses an array in-place.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internal( x );\n* // returns [ 4, 3, 2, 1 ]\n*/\nfunction internal( x ) {\n\tvar tmp;\n\tvar N;\n\tvar M;\n\tvar i;\n\tvar j;\n\n\tN = floor( x.length/2 );\n\tM = x.length - 1;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = M - i;\n\t\ttmp = x[ i ];\n\t\tx[ i ] = x[ j ];\n\t\tx[ j ] = tmp;\n\t}\n\treturn x;\n}\n\n/**\n* Reverses an array in-place.\n*\n* @private\n* @param {Object} x - input array object\n* @returns {Collection} input array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* var out = accessors( arraylike2object( x ) );\n*\n* v = x.get( 0 );\n* // returns 4\n*/\nfunction accessors( x ) {\n\tvar data;\n\tvar get;\n\tvar set;\n\tvar tmp;\n\tvar N;\n\tvar M;\n\tvar i;\n\tvar j;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\tset = x.accessors[ 1 ];\n\n\tN = floor( data.length/2 );\n\tM = data.length - 1;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tj = M - i;\n\t\ttmp = get( data, i );\n\t\tset( data, i, get( data, j ) );\n\t\tset( data, j, tmp );\n\t}\n\treturn data;\n}\n\n\n// MAIN //\n\n/**\n* Reverses an array in-place.\n*\n* @param {Collection} x - input array\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = reverse( x );\n* // returns [ 4, 3, 2, 1 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var out = reverse( x );\n* // returns [ 4, 3, 2, 1 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction reverse( x ) {\n\tvar obj;\n\tif ( hasMethod( x, 'reverse' ) ) {\n\t\treturn x.reverse();\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj );\n\t}\n\treturn internal( x );\n}\n\n\n// EXPORTS //\n\nexport default reverse;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled from './../../../base/filled';\nimport put from './../../../base/put';\n\n\n// MAIN //\n\n/**\n* Scatters a list of provided values to specified indices in a new filled \"generic\" array.\n*\n* @param {*} fill - fill value\n* @param {NonNegativeInteger} len - output array length\n* @param {IntegerArray} indices - list of indices\n* @param {Collection} values - values to scatter\n* @param {string} mode - index mode\n* @throws {Error} third argument must be broadcast compatible with the second argument\n* @returns {Array} output array\n*\n* @example\n* var indices = [ 1, 2 ];\n* var values = [ 20, 30 ];\n*\n* var out = scatterFilled( null, 4, indices, values, 'throw' );\n* // returns [ null, 20, 30, null ]\n*\n* @example\n* var indices = [ 1, 2 ];\n* var values = [ 30 ];\n*\n* var out = scatterFilled( null, 4, indices, values, 'throw' );\n* // returns [ null, 30, 30, null ]\n*/\nfunction scatterFilled( fill, len, indices, values, mode ) {\n\treturn put( filled( fill, len ), indices, values, mode );\n}\n\n\n// EXPORTS //\n\nexport default scatterFilled;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport zeros from './../../../base/zeros';\nimport put from './../../../base/put';\n\n\n// MAIN //\n\n/**\n* Scatters a list of provided values to specified indices in a new zero-filled \"generic\" array.\n*\n* @param {NonNegativeInteger} len - output array length\n* @param {IntegerArray} indices - list of indices\n* @param {Collection} values - values to scatter\n* @param {string} mode - index mode\n* @throws {Error} third argument must be broadcast compatible with the second argument\n* @returns {Array} output array\n*\n* @example\n* var indices = [ 1, 2 ];\n* var values = [ 20, 30 ];\n*\n* var out = scattered( 4, indices, values, 'throw' );\n* // returns [ 0, 20, 30, 0 ]\n*\n* @example\n* var indices = [ 1, 2 ];\n* var values = [ 30 ];\n*\n* var out = scattered( 4, indices, values, 'throw' );\n* // returns [ 0, 30, 30, 0 ]\n*/\nfunction scattered( len, indices, values, mode ) {\n\treturn put( zeros( len ), indices, values, mode );\n}\n\n\n// EXPORTS //\n\nexport default scattered;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Converts a strided array to a two-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - dimension strides\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array} two-dimensional nested array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array2d( x, [ 3, 2 ], [ 2, 1 ], 0 );\n* // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array2d( x, [ 3, 2 ], [ 1, 3 ], 0 );\n* // returns [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ]\n*/\nfunction strided2array2d( x, shape, strides, offset ) {\n\tvar get;\n\tvar out;\n\tvar tmp;\n\tvar dx0;\n\tvar dx1;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar ix;\n\n\tget = resolveGetter( x );\n\n\tS1 = shape[ 0 ];\n\tS0 = shape[ 1 ];\n\n\tdx1 = strides[ 0 ];\n\tdx0 = strides[ 1 ];\n\n\tout = [];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\ttmp = [];\n\t\tix = offset + ( dx1*i1 );\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\ttmp.push( get( x, ix ) );\n\t\t\tix += dx0;\n\t\t}\n\t\tout.push( tmp );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default strided2array2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Converts a strided array to a three-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - dimension strides\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array>} three-dimensional nested array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 );\n* // returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ]\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 );\n* // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ]\n*/\nfunction strided2array3d( x, shape, strides, offset ) {\n\tvar get;\n\tvar out;\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar ix1;\n\tvar ix0;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar t2;\n\tvar t1;\n\n\tget = resolveGetter( x );\n\n\tS2 = shape[ 0 ];\n\tS1 = shape[ 1 ];\n\tS0 = shape[ 2 ];\n\n\tdx2 = strides[ 0 ];\n\tdx1 = strides[ 1 ];\n\tdx0 = strides[ 2 ];\n\n\tout = [];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tt2 = [];\n\t\tix1 = offset + ( dx2*i2 );\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tt1 = [];\n\t\t\tix0 = ix1 + ( dx1*i1 );\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tt1.push( get( x, ix0 ) );\n\t\t\t\tix0 += dx0;\n\t\t\t}\n\t\t\tt2.push( t1 );\n\t\t}\n\t\tout.push( t2 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default strided2array3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Converts a strided array to a four-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - dimension strides\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array>>} four-dimensional nested array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 6, 6, 2, 1 ], 0 );\n* // returns [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ]\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array4d( x, [ 1, 1, 3, 2 ], [ 1, 1, 1, 3 ], 0 );\n* // returns [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ]\n*/\nfunction strided2array4d( x, shape, strides, offset ) {\n\tvar get;\n\tvar out;\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar ix2;\n\tvar ix1;\n\tvar ix0;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar t3;\n\tvar t2;\n\tvar t1;\n\n\tget = resolveGetter( x );\n\n\tS3 = shape[ 0 ];\n\tS2 = shape[ 1 ];\n\tS1 = shape[ 2 ];\n\tS0 = shape[ 3 ];\n\n\tdx3 = strides[ 0 ];\n\tdx2 = strides[ 1 ];\n\tdx1 = strides[ 2 ];\n\tdx0 = strides[ 3 ];\n\n\tout = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tt3 = [];\n\t\tix2 = offset + ( dx3*i3 );\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tt2 = [];\n\t\t\tix1 = ix2 + ( dx2*i2 );\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tt1 = [];\n\t\t\t\tix0 = ix1 + ( dx1*i1 );\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tt1.push( get( x, ix0 ) );\n\t\t\t\t\tix0 += dx0;\n\t\t\t\t}\n\t\t\t\tt2.push( t1 );\n\t\t\t}\n\t\t\tt3.push( t2 );\n\t\t}\n\t\tout.push( t3 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default strided2array4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\n\n\n// MAIN //\n\n/**\n* Converts a strided array to a five-dimensional nested array.\n*\n* ## Notes\n*\n* - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - dimension strides\n* @param {NonNegativeInteger} offset - index of the first indexed value in the input array\n* @returns {Array>>>} five-dimensional nested array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 6, 6, 6, 2, 1 ], 0 );\n* // returns [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ]\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var arr = strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 1, 1, 1, 1, 3 ], 0 );\n* // returns [ [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] ]\n*/\nfunction strided2array5d( x, shape, strides, offset ) {\n\tvar get;\n\tvar out;\n\tvar dx0;\n\tvar dx1;\n\tvar dx2;\n\tvar dx3;\n\tvar dx4;\n\tvar ix3;\n\tvar ix2;\n\tvar ix1;\n\tvar ix0;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar t4;\n\tvar t3;\n\tvar t2;\n\tvar t1;\n\n\tget = resolveGetter( x );\n\n\tS4 = shape[ 0 ];\n\tS3 = shape[ 1 ];\n\tS2 = shape[ 2 ];\n\tS1 = shape[ 3 ];\n\tS0 = shape[ 4 ];\n\n\tdx4 = strides[ 0 ];\n\tdx3 = strides[ 1 ];\n\tdx2 = strides[ 2 ];\n\tdx1 = strides[ 3 ];\n\tdx0 = strides[ 4 ];\n\n\tout = [];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tt4 = [];\n\t\tix3 = offset + ( dx4*i4 );\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tt3 = [];\n\t\t\tix2 = ix3 + ( dx3*i3 );\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tt2 = [];\n\t\t\t\tix1 = ix2 + ( dx2*i2 );\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tt1 = [];\n\t\t\t\t\tix0 = ix1 + ( dx1*i1 );\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tt1.push( get( x, ix0 ) );\n\t\t\t\t\t\tix0 += dx0;\n\t\t\t\t\t}\n\t\t\t\t\tt2.push( t1 );\n\t\t\t\t}\n\t\t\t\tt3.push( t2 );\n\t\t\t}\n\t\t\tt4.push( t3 );\n\t\t}\n\t\tout.push( t4 );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default strided2array5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Takes elements from an indexed array.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeIntegerArray} indices - list of indices\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var y = take( x, indices );\n* // returns [ 4, 2, 3, 1 ]\n*/\nfunction take( x, indices ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\tout.push( x[ indices[ i ] ] ); // use `Array#push` to ensure \"fast\" elements\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default take;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Takes elements from two indexed arrays in a single pass.\n*\n* @param {Collection} x - first input array\n* @param {Collection} y - second input array\n* @param {NonNegativeIntegerArray} indices - list of indices\n* @returns {Array} output arrays\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var y = [ 5, 6, 7, 8 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var out = take2( x, y, indices );\n* // returns [ [ 4, 2, 3, 1 ], [ 8, 6, 7, 5 ] ]\n*/\nfunction take2( x, y, indices ) {\n\tvar o1;\n\tvar o2;\n\tvar i;\n\n\to1 = [];\n\to2 = [];\n\tfor ( i = 0; i < indices.length; i++ ) {\n\t\to1.push( x[ indices[ i ] ] ); // use `Array#push` to ensure \"fast\" elements\n\t\to2.push( y[ indices[ i ] ] );\n\t}\n\treturn [ o1, o2 ];\n}\n\n\n// EXPORTS //\n\nexport default take2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport { factory as indexFunction } from '@stdlib/ndarray/base/ind';\nimport take2d from './../../../base/take2d';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar NDIMS = 3;\n\n\n// MAIN //\n\n/**\n* Takes elements from a three-dimensional nested array.\n*\n* ## Notes\n*\n* - The function does **not** deep copy nested array elements.\n*\n* @param {ArrayLikeObject} x - input array\n* @param {NonNegativeIntegerArray} indices - list of indices\n* @param {integer} dimension - dimension along which to take elements\n* @param {string} mode - index mode specifying how to handle an index which is out-of-bounds\n* @throws {RangeError} third argument exceeds the number of dimensions\n* @throws {TypeError} fourth argument must be a recognized index mode\n* @returns {(Array|Array)} output array\n*\n* @example\n* var x = [ [ [ 1, 2 ], [ 3, 4 ] ] ];\n* var indices = [ 1, 1, 0, 0, -1, -1 ];\n*\n* var y = take3d( x, indices, 2, 'normalize' );\n* // returns [ [ [ 2, 2, 1, 1, 2, 2 ], [ 4, 4, 3, 3, 4, 4 ] ] ]\n*/\nfunction take3d( x, indices, dimension, mode ) {\n\tvar lastIndex;\n\tvar out;\n\tvar dim;\n\tvar ind;\n\tvar idx;\n\tvar i;\n\n\tdim = normalizeIndex( dimension, NDIMS-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Third argument exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', NDIMS, dimension ) );\n\t}\n\tout = [];\n\tif ( dim === 0 ) {\n\t\tind = indexFunction( mode );\n\t\tlastIndex = x.length - 1;\n\t\tfor ( i = 0; i < indices.length; i++ ) {\n\t\t\tidx = ind( indices[ i ], lastIndex );\n\t\t\tout.push( x[ idx ] );\n\t\t}\n\t\treturn out;\n\t}\n\t// Case: dim > 0\n\tdim = dimension - 1;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tout.push( take2d( x[ i ], indices, dim, mode ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default take3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add3';\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = ones2d( shape );\n* var z = ones2d( shape );\n* var out = zeros2d( shape );\n*\n* ternary2d( [ x, y, z, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ]\n*/\nfunction ternary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tz0 = z[ i1 ];\n\t\tw0 = w[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tw0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default ternary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add3';\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = ones3d( shape );\n* var z = ones3d( shape );\n* var out = zeros3d( shape );\n*\n* ternary3d( [ x, y, z, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ]\n*/\nfunction ternary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tz1 = z[ i2 ];\n\t\tw1 = w[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tz0 = z1[ i1 ];\n\t\t\tw0 = w1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tw0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default ternary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add3';\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = ones4d( shape );\n* var z = ones4d( shape );\n* var out = zeros4d( shape );\n*\n* ternary4d( [ x, y, z, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ]\n*/\nfunction ternary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tz2 = z[ i3 ];\n\t\tw2 = w[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tz1 = z2[ i2 ];\n\t\t\tw1 = w2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tw0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default ternary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a ternary callback to elements in three five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>>>} arrays - array-like object containing three input nested arrays and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - ternary callback\n* @returns {void}\n*\n* @example\n* import add from '@stdlib/number/float64/base/add3';\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = ones5d( shape );\n* var z = ones5d( shape );\n* var out = zeros5d( shape );\n*\n* ternary5d( [ x, y, z, out ], shape, add );\n*\n* console.log( out );\n* // => [ [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] ]\n*/\nfunction ternary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar y0;\n\tvar z0;\n\tvar w0;\n\tvar x1;\n\tvar y1;\n\tvar z1;\n\tvar w1;\n\tvar x2;\n\tvar y2;\n\tvar z2;\n\tvar w2;\n\tvar x3;\n\tvar y3;\n\tvar z3;\n\tvar w3;\n\tvar x;\n\tvar y;\n\tvar z;\n\tvar w;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tz = arrays[ 2 ];\n\tw = arrays[ 3 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tz3 = z[ i4 ];\n\t\tw3 = w[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tz2 = z3[ i3 ];\n\t\t\tw2 = w3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tz1 = z2[ i2 ];\n\t\t\t\tw1 = w2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tz0 = z1[ i1 ];\n\t\t\t\t\tw0 = w1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tw0[ i0 ] = fcn( x0[ i0 ], y0[ i0 ], z0[ i0 ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default ternary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isAccessorArray from './../../../base/assert/is-accessor-array';\nimport AccessorArray from './../../../base/accessor';\n\n\n// MAIN //\n\n/**\n* Converts an array-like object to a minimal array-like object supporting the accessor protocol.\n*\n* ## Notes\n*\n* - If a provided array-like object already supports the accessor protocol, the function returns the provided array-like object; otherwise, the function wraps the provided value in a object which uses accessors for getting and setting elements.\n*\n* @param {Collection} arr - input array\n* @throws {TypeError} must provide an array-like object\n* @returns {(Collection|AccessorArray)} array-like object supporting the accessor protocol\n*\n* @example\n* var o = toAccessorArray( [ 1, 2, 3 ] );\n* // returns \n*\n* var v = o.get( 0 );\n* // returns 1\n*/\nfunction toAccessorArray( arr ) {\n\tif ( arr && typeof arr === 'object' && isAccessorArray( arr ) ) {\n\t\treturn arr;\n\t}\n\treturn new AccessorArray( arr );\n}\n\n\n// EXPORTS //\n\nexport default toAccessorArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from '@stdlib/math/base/assert/is-nan';\n\n\n// FUNCTIONS //\n\n/**\n* Copies de-duplicated values to a new array.\n*\n* @private\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 1, 2, 3, 3 ];\n*\n* var y = dedupeCopy( x, 1 );\n* // returns [ 1, 2, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ];\n*\n* var y = dedupeCopy( x, 2 );\n* // returns [ 1, 1, 2, 1, 1, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*/\nfunction dedupeCopy( x, limit ) {\n\tvar count;\n\tvar prev;\n\tvar len;\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tprev = NaN; // we leverage the fact that `NaN` is not equal to anything, including itself, to handle the initial condition\n\tcount = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( v === prev ) {\n\t\t\tcount += 1;\n\t\t\tif ( count <= limit ) {\n\t\t\t\tout.push( prev );\n\t\t\t}\n\t\t} else {\n\t\t\tprev = v;\n\t\t\tcount = 1;\n\t\t\tout.push( prev );\n\t\t}\n\t}\n\treturn out;\n}\n\n/**\n* Copies de-duplicated values to a new array, treating `NaN` values as equal.\n*\n* @private\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 1, 2, NaN, NaN, 3, 3 ];\n*\n* var y = dedupeEqualNaNs( x, 1 );\n* // returns [ 1, 2, NaN, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, NaN, NaN, NaN, 3, 3 ];\n*\n* var y = dedupeEqualNaNs( x, 2 );\n* // returns [ 1, 1, 2, 1, 1, NaN, NaN, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*/\nfunction dedupeEqualNaNs( x, limit ) {\n\tvar count;\n\tvar prev;\n\tvar len;\n\tvar out;\n\tvar FLG;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\tlen = x.length;\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tFLG = false;\n\tprev = NaN; // we leverage the fact that `NaN` is not equal to anything, including itself, to handle the initial condition\n\tcount = 0;\n\tfor ( i = 0; i < len; i++ ) {\n\t\tv = x[ i ];\n\t\tif ( v === prev || ( FLG && isnan( v ) ) ) {\n\t\t\tcount += 1;\n\t\t\tif ( count <= limit ) {\n\t\t\t\tout.push( prev );\n\t\t\t}\n\t\t} else {\n\t\t\tprev = v;\n\t\t\tcount = 1;\n\t\t\tout.push( prev );\n\t\t\tFLG = false;\n\t\t\tif ( isnan( prev ) ) {\n\t\t\t\tFLG = true;\n\t\t\t}\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Copies elements to a new \"generic\" array after removing consecutive duplicated values.\n*\n* @param {Array} x - input array\n* @param {PositiveInteger} limit - number of allowed consecutive duplicates\n* @param {boolean} equalNaNs - boolean indicating whether NaNs should be considered equal\n* @returns {Array} de-duplicated values\n*\n* @example\n* var x = [ 1, 1, 2, 3, 3 ];\n*\n* var y = dedupe( x, 1, false );\n* // returns [ 1, 2, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*\n* @example\n* var x = [ 1, 1, 1, 2, 1, 1, 3, 3 ];\n*\n* var y = dedupe( x, 2, false );\n* // returns [ 1, 1, 2, 1, 1, 3, 3 ]\n*\n* var bool = ( x === y );\n* // returns false\n*/\nfunction dedupe( x, limit, equalNaNs ) {\n\tif ( equalNaNs ) {\n\t\treturn dedupeEqualNaNs( x, limit );\n\t}\n\treturn dedupeCopy( x, limit );\n}\n\n\n// EXPORTS //\n\nexport default dedupe;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an object has a specified method.\n*\n* @private\n* @param {Object} obj - input object\n* @param {string} method - method name\n* @returns {boolean} boolean indicating whether an object has a specified method\n*\n* @example\n* var bool = hasMethod( [], 'beep' );\n* // returns false\n*/\nfunction hasMethod( obj, method ) {\n\treturn ( typeof obj[ method ] === 'function' );\n}\n\n/**\n* Returns a new array with elements in reverse order.\n*\n* @private\n* @param {Collection} x - input array\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = internal( x );\n* // returns [ 4, 3, 2, 1 ]\n*/\nfunction internal( x ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = x.length-1; i >= 0; i-- ) {\n\t\tout.push( x[ i ] );\n\t}\n\treturn out;\n}\n\n/**\n* Returns a new array with elements in reverse order.\n*\n* @private\n* @param {Object} x - input array object\n* @returns {Array} output array\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var x = toAccessorArray( [ 1, 2, 3, 4 ] );\n*\n* var v = x.get( 0 );\n* // returns 1\n*\n* var out = accessors( arraylike2object( x ) );\n* // returns [ 4, 3, 2, 1 ]\n*/\nfunction accessors( x ) {\n\tvar data;\n\tvar get;\n\tvar out;\n\tvar i;\n\n\tdata = x.data;\n\tget = x.accessors[ 0 ];\n\n\tout = [];\n\tfor ( i = data.length-1; i >= 0; i-- ) {\n\t\tout.push( get( data, i ) );\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns a new array with elements in reverse order.\n*\n* @param {Collection} x - input array\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = toReversed( x );\n* // returns [ 4, 3, 2, 1 ]\n*\n* var bool = ( out === x );\n* // returns false\n*/\nfunction toReversed( x ) {\n\tvar obj;\n\tif ( hasMethod( x, 'toReversed' ) ) {\n\t\treturn x.toReversed();\n\t}\n\tobj = arraylike2object( x );\n\tif ( obj.accessorProtocol ) {\n\t\treturn accessors( obj );\n\t}\n\treturn internal( x );\n}\n\n\n// EXPORTS //\n\nexport default toReversed;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a two-dimensional nested input array and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = zeros2d( shape );\n*\n* unary2d( [ x, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ]\n*/\nfunction unary2d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar x;\n\tvar y;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary2d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary function to each element retrieved from a two-dimensional nested input array according to a callback function and assigns results to elements in a two-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - unary function to apply to callback return values\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {void}\n*\n* @example\n* import ones2d from '@stdlib/array/base/ones2d';\n* import zeros2d from '@stdlib/array/base/zeros2d';\n*\n* function accessor( v ) {\n* return v - 2.0;\n* }\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 2, 2 ];\n*\n* var x = ones2d( shape );\n* var y = zeros2d( shape );\n*\n* unary2dBy( [ x, y ], shape, scale, accessor );\n*\n* console.log( y );\n* // => [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ]\n*/\nfunction unary2dBy( arrays, shape, fcn, clbk ) {\n\tvar thisArg;\n\tvar S0;\n\tvar S1;\n\tvar i0;\n\tvar i1;\n\tvar x0;\n\tvar y0;\n\tvar x;\n\tvar y;\n\tvar v;\n\n\tS0 = shape[ 1 ];\n\tS1 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 ) {\n\t\treturn;\n\t}\n\tif ( arguments.length > 4 ) {\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\tx0 = x[ i1 ];\n\t\ty0 = y[ i1 ];\n\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\tv = clbk.call( thisArg, x0[ i0 ], [ i1, i0 ], [ x, y ] );\n\t\t\tif ( v !== void 0 ) {\n\t\t\t\ty0[ i0 ] = fcn( v );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary2dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a three-dimensional nested input array and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = zeros3d( shape );\n*\n* unary3d( [ x, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ]\n*/\nfunction unary3d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar x;\n\tvar y;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary function to each element retrieved from a three-dimensional nested input array according to a callback function and assigns results to elements in a three-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - unary function to apply to callback return values\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {void}\n*\n* @example\n* import ones3d from '@stdlib/array/base/ones3d';\n* import zeros3d from '@stdlib/array/base/zeros3d';\n*\n* function accessor( v ) {\n* return v - 2.0;\n* }\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 2, 2 ];\n*\n* var x = ones3d( shape );\n* var y = zeros3d( shape );\n*\n* unary3dBy( [ x, y ], shape, scale, accessor );\n*\n* console.log( y );\n* // => [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ]\n*/\nfunction unary3dBy( arrays, shape, fcn, clbk ) {\n\tvar thisArg;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar x0;\n\tvar x1;\n\tvar y0;\n\tvar y1;\n\tvar x;\n\tvar y;\n\tvar v;\n\n\tS0 = shape[ 2 ];\n\tS1 = shape[ 1 ];\n\tS2 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 ) {\n\t\treturn;\n\t}\n\tif ( arguments.length > 4 ) {\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\tx1 = x[ i2 ];\n\t\ty1 = y[ i2 ];\n\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\tx0 = x1[ i1 ];\n\t\t\ty0 = y1[ i1 ];\n\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\tv = clbk.call( thisArg, x0[ i0 ], [ i2, i1, i0 ], [ x, y ] );\n\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\ty0[ i0 ] = fcn( v );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary3dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* unary4d( [ x, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction unary4d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar x;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary function to each element retrieved from a four-dimensional nested input array according to a callback function and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - unary function to apply to callback return values\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {void}\n*\n* @example\n* import ones4d from '@stdlib/array/base/ones4d';\n* import zeros4d from '@stdlib/array/base/zeros4d';\n*\n* function accessor( v ) {\n* return v - 2.0;\n* }\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* unary4dBy( [ x, y ], shape, scale, accessor );\n*\n* console.log( y );\n* // => [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ]\n*/\nfunction unary4dBy( arrays, shape, fcn, clbk ) {\n\tvar thisArg;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar x;\n\tvar y;\n\tvar v;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn;\n\t}\n\tif ( arguments.length > 4 ) {\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\tv = clbk.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], [ x, y ] ); // eslint-disable-line max-len\n\t\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\t\ty0[ i0 ] = fcn( v );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary4dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary callback to elements in a five-dimensional nested input array and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject>>} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Callback} fcn - unary callback\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = zeros5d( shape );\n*\n* unary5d( [ x, y ], shape, scale );\n*\n* console.log( y );\n* // => [ [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] ]\n*/\nfunction unary5d( arrays, shape, fcn ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar x;\n\tvar y;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\ty0[ i0 ] = fcn( x0[ i0 ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n/* eslint-disable max-depth */\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a unary function to each element retrieved from a five-dimensional nested input array according to a callback function and assigns results to elements in a five-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} arrays - array-like object containing one input nested array and one output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - unary function to apply to callback return values\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - callback execution context\n* @returns {void}\n*\n* @example\n* import ones5d from '@stdlib/array/base/ones5d';\n* import zeros5d from '@stdlib/array/base/zeros5d';\n*\n* function accessor( v ) {\n* return v - 2.0;\n* }\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 1, 2, 2 ];\n*\n* var x = ones5d( shape );\n* var y = zeros5d( shape );\n*\n* unary5dBy( [ x, y ], shape, scale, accessor );\n*\n* console.log( y );\n* // => [ [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ] ]\n*/\nfunction unary5dBy( arrays, shape, fcn, clbk ) {\n\tvar thisArg;\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar S4;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar i4;\n\tvar x0;\n\tvar x1;\n\tvar x2;\n\tvar x3;\n\tvar y0;\n\tvar y1;\n\tvar y2;\n\tvar y3;\n\tvar x;\n\tvar y;\n\tvar v;\n\n\tS0 = shape[ 4 ];\n\tS1 = shape[ 3 ];\n\tS2 = shape[ 2 ];\n\tS3 = shape[ 1 ];\n\tS4 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 || S4 <= 0 ) {\n\t\treturn;\n\t}\n\tif ( arguments.length > 4 ) {\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tx = arrays[ 0 ];\n\ty = arrays[ 1 ];\n\tfor ( i4 = 0; i4 < S4; i4++ ) {\n\t\tx3 = x[ i4 ];\n\t\ty3 = y[ i4 ];\n\t\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\t\tx2 = x3[ i3 ];\n\t\t\ty2 = y3[ i3 ];\n\t\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\t\tx1 = x2[ i2 ];\n\t\t\t\ty1 = y2[ i2 ];\n\t\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\t\tv = clbk.call( thisArg, x0[ i0 ], [ i4, i3, i2, i1, i0 ], [ x, y ] ); // eslint-disable-line max-len\n\t\t\t\t\t\tif ( v !== void 0 ) {\n\t\t\t\t\t\t\ty0[ i0 ] = fcn( v );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default unary5dBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1.\n*\n* @param {number} x1 - first array value\n* @param {number} x2 - array element bound\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = unitspace( 0, 6 );\n* // returns [ 0, 1, 2, 3, 4, 5 ]\n*/\nfunction unitspace( x1, x2 ) {\n\tvar arr;\n\tvar len;\n\tvar i;\n\n\tlen = x2 - x1;\n\tif ( len <= 1 ) {\n\t\treturn [ x1 ];\n\t}\n\tarr = [ x1 ];\n\tfor ( i = 1; i < len; i++ ) {\n\t\tarr.push( x1 + i );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default unitspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled3d from './../../../base/filled3d';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled three-dimensional nested array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = zeros3d( [ 1, 1, 3 ] );\n* // returns [ [ [ 0.0, 0.0, 0.0 ] ] ]\n*/\nfunction zeros3d( shape ) {\n\treturn filled3d( 0.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default zeros3d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled4d from './../../../base/filled4d';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled four-dimensional nested array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = zeros4d( [ 1, 1, 1, 3 ] );\n* // returns [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ]\n*/\nfunction zeros4d( shape ) {\n\treturn filled4d( 0.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default zeros4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport filled5d from './../../../base/filled5d';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled five-dimensional nested array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = zeros5d( [ 1, 1, 1, 1, 3 ] );\n* // returns [ [ [ [ [ 0.0, 0.0, 0.0 ] ] ] ] ]\n*/\nfunction zeros5d( shape ) {\n\treturn filled5d( 0.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default zeros5d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport fillednd from './../../../base/fillednd';\n\n\n// MAIN //\n\n/**\n* Returns a zero-filled n-dimensional nested array.\n*\n* @param {NonNegativeIntegerArray} shape - array shape\n* @returns {Array} filled array\n*\n* @example\n* var out = zerosnd( [ 3 ] );\n* // returns [ 0.0, 0.0, 0.0 ]\n*\n* @example\n* var out = zerosnd( [ 1, 3 ] );\n* // returns [ [ 0.0, 0.0, 0.0 ] ]\n*/\nfunction zerosnd( shape ) {\n\treturn fillednd( 0.0, shape );\n}\n\n\n// EXPORTS //\n\nexport default zerosnd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport copy from './../../../base/copy';\n\n\n// MAIN //\n\n/**\n* Zips one or more arrays.\n*\n* ## Notes\n*\n* - The function assumes that the list of arrays to be zipped all have the same length.\n*\n* @param {Collection} arrays - list of arrays to be zipped\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3 ];\n* var y = [ 'a', 'b', 'c' ];\n*\n* var z = zip( [ x, y ] );\n* // returns [ [ 1, 'a' ], [ 2, 'b' ], [ 3, 'c' ] ]\n*/\nfunction zip( arrays ) {\n\tvar getters;\n\tvar list;\n\tvar out;\n\tvar arr;\n\tvar M;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tM = arrays.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\tlist = copy( arrays );\n\tN = list[ 0 ].length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\tgetters = [];\n\tfor ( j = 0; j < M; j++ ) {\n\t\tgetters.push( resolveGetter( list[ j ] ) );\n\t}\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tarr = [];\n\t\tfor ( j = 0; j < M; j++ ) {\n\t\t\tarr.push( getters[ j ]( list[ j ], i ) );\n\t\t}\n\t\tout.push( arr );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default zip;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from './../../../base/arraylike2object';\n\n\n// FUNCTIONS //\n\n/**\n* Zips accessor arrays to an object.\n*\n* @private\n* @param {Object} properties - properties object\n* @param {Object} values - values object\n* @returns {Object} result\n*\n* @example\n* import toAccessorArray from '@stdlib/array/base/to-accessor-array';\n* import arraylike2object from '@stdlib/array/base/arraylike2object';\n*\n* var props = toAccessorArray( [ 'a', 'b', 'c' ] );\n* var values = toAccessorArray( [ 1, 2, 3 ] );\n*\n* var obj = accessors( arraylike2object( props ), arraylike2object( values ) );\n* // returns { 'a': 1, 'b': 2, 'c': 3 }\n*/\nfunction accessors( properties, values ) {\n\tvar pdata;\n\tvar vdata;\n\tvar pget;\n\tvar vget;\n\tvar out;\n\tvar i;\n\n\tpdata = properties.data;\n\tpget = properties.accessors[ 0 ];\n\n\tvdata = values.data;\n\tvget = values.accessors[ 0 ];\n\n\tout = {};\n\tfor ( i = 0; i < pdata.length; i++ ) {\n\t\tout[ pget( pdata, i ) ] = vget( vdata, i );\n\t}\n\treturn out;\n}\n\n/**\n* Zips indexed collections to an object.\n*\n* @private\n* @param {Collection} properties - list of properties\n* @param {Collection} values - list of values\n* @returns {Object} result\n*\n* @example\n* var props = [ 'a', 'b', 'c' ];\n* var values = [ 1, 2, 3 ];\n*\n* var obj = indexed( props, values );\n* // returns { 'a': 1, 'b': 2, 'c': 3 }\n*/\nfunction indexed( properties, values ) {\n\tvar out;\n\tvar i;\n\n\tout = {};\n\tfor ( i = 0; i < properties.length; i++ ) {\n\t\tout[ properties[ i ] ] = values[ i ];\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Creates an object from a provided list of properties and a provided list of corresponding values.\n*\n* @param {Collection} properties - list of properties\n* @param {Collection} values - list of values\n* @returns {Object} result\n*\n* @example\n* var props = [ 'a', 'b', 'c' ];\n* var values = [ 1, 2, 3 ];\n*\n* var obj = zip2object( props, values );\n* // returns { 'a': 1, 'b': 2, 'c': 3 }\n*/\nfunction zip2object( properties, values ) {\n\tvar o1 = arraylike2object( properties );\n\tvar o2 = arraylike2object( values );\n\n\tif ( o1.accessorProtocol || o2.accessorProtocol ) {\n\t\treturn accessors( o1, o2 );\n\t}\n\treturn indexed( properties, values );\n}\n\n\n// EXPORTS //\n\nexport default zip2object;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveGetter from './../../../base/resolve-getter';\nimport copy from './../../../base/copy';\n\n\n// MAIN //\n\n/**\n* Zips one or more arrays to an array of objects.\n*\n* ## Notes\n*\n* - The function assumes that the list of arrays to be zipped all have the same length.\n* - The number of provided array labels should equal the number of arrays to be zipped.\n*\n* @param {Collection} arrays - list of arrays to be zipped\n* @param {ArrayLikeObject} labels - list of array labels\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3 ];\n* var y = [ 'a', 'b', 'c' ];\n*\n* var labels = [ 'x', 'y' ];\n*\n* var z = zip2objects( [ x, y ], labels );\n* // returns [ { 'x': 1, 'y': 'a' }, { 'x': 2, 'y': 'b' }, { 'x': 3, 'y': 'c' } ]\n*/\nfunction zip2objects( arrays, labels ) {\n\tvar getters;\n\tvar list;\n\tvar keys;\n\tvar get;\n\tvar out;\n\tvar obj;\n\tvar M;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tM = arrays.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\tlist = copy( arrays );\n\tN = list[ 0 ].length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\tgetters = [];\n\n\tget = resolveGetter( labels );\n\tkeys = [];\n\tfor ( j = 0; j < M; j++ ) {\n\t\tgetters.push( resolveGetter( list[ j ] ) );\n\t\tkeys.push( get( labels, j ) );\n\t}\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tobj = {};\n\t\tfor ( j = 0; j < M; j++ ) {\n\t\t\tobj[ keys[ j ] ] = getters[ j ]( list[ j ], i );\n\t\t}\n\t\tout.push( obj );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default zip2objects;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setNonEnumerableReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadWriteAccessor from '@stdlib/utils/define-read-write-accessor';\nimport accessors from './../../../base/accessors';\nimport copy from './../../../base/copy';\n\n\n// MAIN //\n\n/**\n* Zips one or more arrays to an array of composite views.\n*\n* ## Notes\n*\n* - The function assumes that the list of arrays to be zipped all have the same length.\n* - The list of provided array labels should equal the number of arrays to be zipped.\n* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either an input array or a view will mutate the other.\n*\n* @param {Collection} arrays - list of arrays to be zipped\n* @param {ArrayLikeObject} labels - list of array labels\n* @returns {Array} output array\n*\n* @example\n* var x = [ 1, 2, 3 ];\n* var y = [ 'a', 'b', 'c' ];\n*\n* var labels = [ 'x', 'y' ];\n*\n* var z = zip2views( [ x, y ], labels );\n* // returns [ , , ]\n*\n* var v0 = z[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 'a' }\n*\n* var v1 = z[ 1 ].toJSON();\n* // returns { 'x': 2, 'y': 'b' }\n*\n* var v2 = z[ 2 ].toJSON();\n* // returns { 'x': 3, 'y': 'c' }\n*\n* // Mutate one of the input arrays:\n* x[ 0 ] = 5;\n*\n* v0 = z[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 'a' }\n*\n* // Set a view property:\n* z[ 1 ].y = 'beep';\n*\n* v1 = z[ 1 ].toJSON();\n* // returns { 'x': 2, 'y': 'beep' }\n*\n* var y1 = y.slice();\n* // returns [ 'a', 'beep', 'c' ]\n*/\nfunction zip2views( arrays, labels ) {\n\tvar getter;\n\tvar setter;\n\tvar list;\n\tvar keys;\n\tvar out;\n\tvar acc;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arrays.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\tlist = copy( arrays );\n\tN = list[ 0 ].length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Resolve element accessors...\n\tacc = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tacc.push( accessors( list[ i ] ).accessors );\n\t}\n\t// Create a copy of provided labels to prevent external mutation:\n\tkeys = copy( labels );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view of zipped elements.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( i ) {\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define read/write accessors for each label...\n\tfor ( i = 0; i < M; i++ ) {\n\t\tgetter = getValue( list[ i ], acc[ i ][ 0 ] );\n\t\tsetter = setValue( list[ i ], acc[ i ][ 1 ] );\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getter, setter );\n\t}\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < N; i++ ) {\n\t\tout.push( new Datum( i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Returns an accessor for returning the value associated with a label.\n\t*\n\t* @private\n\t* @param {Collection} arr - input array\n\t* @param {Function} getter - array element accessor\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( arr, getter ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a label.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\treturn getter( arr, this._i ); // eslint-disable-line no-invalid-this\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a label.\n\t*\n\t* @private\n\t* @param {Collection} arr - input array\n\t* @param {Function} setter - array element accessor\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( arr, setter ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a label.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tsetter( arr, this._i, value ); // eslint-disable-line no-invalid-this\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < M; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ]; // eslint-disable-line no-invalid-this\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default zip2views;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof ArrayBuffer === 'function' ) ? ArrayBuffer : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayBuffer from './../../is-arraybuffer';\nimport Float64Array from '@stdlib/array/float64';\nimport GlobalArrayBuffer from './arraybuffer.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `ArrayBuffer` support.\n*\n* @returns {boolean} boolean indicating if an environment has `ArrayBuffer` support\n*\n* @example\n* var bool = hasArrayBufferSupport();\n* // returns \n*/\nfunction hasArrayBufferSupport() {\n\tvar bool;\n\tvar view;\n\tvar buf;\n\n\tif ( typeof GlobalArrayBuffer !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tbuf = new GlobalArrayBuffer( 16 );\n\t\tbool = ( isArrayBuffer( buf ) && typeof GlobalArrayBuffer.isView === 'function' );\n\t\tif ( bool ) {\n\t\t\tview = new Float64Array( buf );\n\t\t\tview[ 0 ] = -3.14;\n\t\t\tview[ 1 ] = NaN;\n\t\t\tbool = (\n\t\t\t\tbool &&\n\t\t\t\tGlobalArrayBuffer.isView( view ) &&\n\t\t\t\tbuf.byteLength === 16 &&\n\t\t\t\tview[ 0 ] === -3.14 &&\n\t\t\t\tview[ 1 ] !== view[ 1 ]\n\t\t\t);\n\t\t}\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasArrayBufferSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof ArrayBuffer === 'function' ) ? ArrayBuffer : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.\n*\n* @module @stdlib/array/buffer\n*\n* @example\n* import ctor from '@stdlib/array/buffer';\n*\n* var buf = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasArrayBufferSupport from '@stdlib/assert/has-arraybuffer-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasArrayBufferSupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasDataView = ( typeof DataView === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a `DataView`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a DataView\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n* import DataView from '@stdlib/array/dataview';\n*\n* var bool = isDataView( new DataView( new ArrayBuffer( 10 ) ) );\n* // returns true\n*\n* @example\n* var bool = isDataView( [] );\n* // returns false\n*/\nfunction isDataView( value ) {\n\treturn (\n\t\t( hasDataView && value instanceof DataView ) || // eslint-disable-line stdlib/require-globals\n\t\tnativeClass( value ) === '[object DataView]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isDataView;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof ArrayBuffer === 'function' ) ? ArrayBuffer : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.\n*\n* @module @stdlib/array/buffer\n*\n* @example\n* import ctor from '@stdlib/array/buffer';\n*\n* var buf = new ctor( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasArrayBufferSupport from '@stdlib/assert/has-arraybuffer-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasArrayBufferSupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Constructor which returns an object used to represent a generic, fixed-length raw binary data buffer.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof DataView === 'function' ) ? DataView : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof DataView === 'function' ) ? DataView : void 0; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Constructor which returns a data view representing a provided array buffer.\n*\n* @module @stdlib/array/dataview\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n* import DataView from '@stdlib/array/dataview';\n*\n* var buf = new ArrayBuffer( 10 );\n* // returns \n*\n* var dv = new DataView( buf );\n* // returns \n*/\n\n// MODULES //\n\nimport hasDataViewSupport from '@stdlib/assert/has-dataview-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasDataViewSupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isDataView from './../../is-dataview';\nimport ArrayBuffer from '@stdlib/array/buffer';\nimport GlobalDataView from './dataview.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `DataView` support.\n*\n* @returns {boolean} boolean indicating if an environment has `DataView` support\n*\n* @example\n* var bool = hasDataViewSupport();\n* // returns \n*/\nfunction hasDataViewSupport() {\n\tvar bool;\n\tvar view;\n\tvar buf;\n\n\tif ( typeof GlobalDataView !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tbuf = new ArrayBuffer( 24 );\n\t\tview = new GlobalDataView( buf, 8 );\n\t\tbool = ( isDataView( view ) && typeof view.getFloat64 === 'function' && typeof view.setFloat64 === 'function' );\n\t\tif ( bool ) {\n\t\t\tview.setFloat64( 0, -3.14 );\n\t\t\tview.setFloat64( 8, NaN );\n\t\t\tbool = (\n\t\t\t\tbool &&\n\t\t\t\tview.buffer === buf &&\n\t\t\t\tview.byteLength === 16 &&\n\t\t\t\tview.byteOffset === 8 &&\n\t\t\t\tview.getFloat64( 0 ) === -3.14 &&\n\t\t\t\tview.getFloat64( 8 ) !== view.getFloat64( 8 )\n\t\t\t);\n\t\t}\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasDataViewSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write polyfill\n\n// MAIN //\n\n/**\n* Constructor which returns a data view representing a provided array buffer.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Rounds a numeric value to the nearest integer.\n*\n* @param {number} x - input value\n* @returns {number} function value\n*\n* @example\n* var v = round( -4.2 );\n* // returns -4.0\n*\n* @example\n* var v = round( -4.5 );\n* // returns -4.0\n*\n* @example\n* var v = round( -4.6 );\n* // returns -5.0\n*\n* @example\n* var v = round( 9.99999 );\n* // returns 10.0\n*\n* @example\n* var v = round( 9.5 );\n* // returns 10.0\n*\n* @example\n* var v = round( 9.2 );\n* // returns 9.0\n*\n* @example\n* var v = round( 0.0 );\n* // returns 0.0\n*\n* @example\n* var v = round( -0.0 );\n* // returns -0.0\n*\n* @example\n* var v = round( Infinity );\n* // returns Infinity\n*\n* @example\n* var v = round( -Infinity );\n* // returns -Infinity\n*\n* @example\n* var v = round( NaN );\n* // returns NaN\n*/\nvar round = Math.round; // eslint-disable-line stdlib/no-builtin-math\n\n\n// EXPORTS //\n\nexport default round;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport isInteger from '@stdlib/assert/is-integer';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport isObject from '@stdlib/assert/is-object';\nimport format from '@stdlib/string/format';\nimport floor from '@stdlib/math/base/special/floor';\nimport round from '@stdlib/math/base/special/round';\nimport ceil from '@stdlib/math/base/special/ceil';\n\n\n// VARIABLES //\n\nvar timestamp = /^\\d{10}$|^\\d{13}$/;\nvar rounders = [ 'floor', 'ceil', 'round' ];\n\n\n// FUNCTIONS //\n\n/**\n* Validates a date parameter.\n*\n* @private\n* @param {*} value - value to be validated\n* @param {string} name - name to be used in error messages\n* @throws {TypeError} value must either be a date string, Date object, Unix timestamp, or JavaScript timestamp\n* @throws {Error} numeric date must be either a Unix or JavaScript timestamp\n* @returns {Date} validated date\n*/\nfunction validDate( value, name ) {\n\tvar type;\n\n\ttype = typeof value;\n\tif ( type === 'string' ) {\n\t\tvalue = Date.parse( value );\n\t\tif ( value !== value ) {\n\t\t\tthrow new Error( format( 'invalid argument. Unable to parse %s date.', name.toLowerCase() ) );\n\t\t}\n\t\tvalue = new Date( value );\n\t}\n\tif ( type === 'number' ) {\n\t\tif ( !timestamp.test( value ) ) {\n\t\t\tthrow new Error( format( 'invalid argument. Numeric %s date must be either a Unix or JavaScript timestamp.', name.toLowerCase() ) );\n\t\t}\n\t\tif ( value.toString().length === 10 ) {\n\t\t\tvalue *= 1000; // sec to ms\n\t\t}\n\t\tvalue = new Date( value );\n\t}\n\tif ( !(value instanceof Date) ) {\n\t\tthrow new TypeError( format( 'invalid argument. %s date must either be a date string, Date object, Unix timestamp, or JavaScript timestamp.', name ) );\n\t}\n\treturn value;\n}\n\n\n// MAIN //\n\n/**\n* Generates an array of linearly spaced dates.\n*\n* @param {(Date|number|string)} start - start time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string\n* @param {(Date|number|string)} stop - stop time as either a `Date` object, Unix timestamp, JavaScript timestamp, or date string\n* @param {number} [length] - output array length (default: 100)\n* @param {Object} [options] - function options\n* @param {string} [options.round] - specifies how sub-millisecond times should be rounded: [ 'floor', 'ceil', 'round' ] (default: 'floor' )\n* @throws {TypeError} length argument must a positive integer\n* @throws {Error} must provide valid options\n* @returns {Array} array of dates\n*\n* @example\n* var stop = '2014-12-02T07:00:54.973Z';\n* var start = new Date( stop ) - 60000;\n*\n* var arr = datespace( start, stop, 6 );\n* // returns [...]\n*\n* @example\n* // Equivalent of Math.ceil():\n* var arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'ceil' } );\n* // returns [...]\n*\n* // Equivalent of Math.round():\n* arr = datespace( 1417503655000, 1417503655001, 3, { 'round': 'round' } );\n* // returns [...]\n*/\nfunction datespace( start, stop, length, options ) {\n\tvar opts;\n\tvar len;\n\tvar flg;\n\tvar arr;\n\tvar end;\n\tvar fcn;\n\tvar tmp;\n\tvar d;\n\tvar i;\n\n\tlen = 100;\n\tflg = true;\n\topts = {\n\t\t'round': 'floor'\n\t};\n\tstart = validDate( start, 'Start' );\n\tstop = validDate( stop, 'Stop' );\n\tif ( arguments.length > 2 ) {\n\t\tif ( arguments.length === 3 ) {\n\t\t\tif ( isObject( length ) ) {\n\t\t\t\topts = length;\n\t\t\t} else {\n\t\t\t\tlen = length;\n\n\t\t\t\t// Turn off checking the options object...\n\t\t\t\tflg = false;\n\t\t\t}\n\t\t} else {\n\t\t\topts = options;\n\t\t\tlen = length;\n\t\t}\n\t\tif ( len === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( !isInteger( len ) || len < 0 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t\tif ( flg ) {\n\t\t\tif ( !isObject( opts ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t\t}\n\t\t\tif ( hasOwnProp( opts, 'round' ) ) {\n\t\t\t\tif ( !isString( opts.round ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'round', opts.round ) );\n\t\t\t\t}\n\t\t\t\tif ( rounders.indexOf( opts.round ) === -1 ) {\n\t\t\t\t\tthrow new Error( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'round', rounders.join( '\", \"' ), opts.round ) );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tswitch ( opts.round ) {\n\tcase 'round':\n\t\tfcn = round;\n\t\tbreak;\n\tcase 'ceil':\n\t\tfcn = ceil;\n\t\tbreak;\n\tcase 'floor':\n\tdefault:\n\t\tfcn = floor;\n\t\tbreak;\n\t}\n\n\t// Calculate the increment...\n\tend = len - 1;\n\td = ( stop.getTime() - start.getTime() ) / end;\n\n\t// Build the output array...\n\tarr = new Array( len );\n\ttmp = start;\n\tarr[ 0 ] = tmp;\n\ttmp = tmp.getTime();\n\tfor ( i = 1; i < end; i++ ) {\n\t\ttmp += d;\n\t\tarr[ i ] = new Date( fcn( tmp ) );\n\t}\n\tarr[ end ] = stop;\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default datespace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof Buffer === 'function' ) ? Buffer : null; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = require( 'buffer' ).Buffer; // eslint-disable-line stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Buffer constructor.\n*\n* @module @stdlib/buffer/ctor\n*\n* @example\n* import ctor from '@stdlib/buffer/ctor';\n*\n* var b = new ctor( [ 1, 2, 3, 4 ] );\n* // returns \n*/\n\n// MODULES //\n\nimport hasNodeBufferSupport from '@stdlib/assert/has-node-buffer-support';\nimport main from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasNodeBufferSupport() ) {\n\tctor = main;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isBuffer from './../../is-buffer';\nimport GlobalBuffer from './buffer.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `Buffer` support.\n*\n* @returns {boolean} boolean indicating if an environment has `Buffer` support\n*\n* @example\n* var bool = hasNodeBufferSupport();\n* // returns \n*/\nfunction hasNodeBufferSupport() {\n\tvar bool;\n\tvar b;\n\n\tif ( typeof GlobalBuffer !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tif ( typeof GlobalBuffer.from === 'function' ) {\n\t\t\tb = GlobalBuffer.from( [ 1, 2, 3, 4 ] );\n\t\t} else {\n\t\t\tb = new GlobalBuffer( [ 1, 2, 3, 4 ] ); // Note: this is deprecated behavior starting in Node v6 (see https://nodejs.org/api/buffer.html#buffer_new_buffer_array)\n\t\t}\n\t\tbool = (\n\t\t\tisBuffer( b ) &&\n\t\t\tb[ 0 ] === 1 &&\n\t\t\tb[ 1 ] === 2 &&\n\t\t\tb[ 2 ] === 3 &&\n\t\t\tb[ 3 ] === 4\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasNodeBufferSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// TODO: write (browser) polyfill\n\n// MAIN //\n\n/**\n* Buffer constructor.\n*\n* @throws {Error} not implemented\n*/\nfunction polyfill() {\n\tthrow new Error( 'not implemented' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Allocate a buffer having a specified number of bytes.\n*\n* @module @stdlib/buffer/alloc-unsafe\n*\n* @example\n* import allocUnsafe from '@stdlib/buffer/alloc-unsafe';\n*\n* var buf = allocUnsafe( 10 );\n* // returns \n*/\n\n// MODULES //\n\nimport hasAllocUnsafe from './has_alloc_unsafe.js';\nimport main from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar allocUnsafe;\nif ( hasAllocUnsafe ) {\n\tallocUnsafe = main;\n} else {\n\tallocUnsafe = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default allocUnsafe;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert/is-function';\nimport Buffer from './../../ctor';\n\n\n// MAIN //\n\nvar bool = isFunction( Buffer.allocUnsafe );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isNonNegativeInteger from '@stdlib/assert/is-nonnegative-integer';\nimport format from '@stdlib/string/format';\nimport Buffer from './../../ctor';\n\n\n// MAIN //\n\n/**\n* Allocates a buffer having a specified number of bytes.\n*\n* ## Notes\n*\n* - The underlying memory of returned `Buffer` instances is not initialized. Memory contents are unknown and may contain sensitive data.\n* - When the size is less than half the pool size (specified on the `Buffer` constructor), memory is allocated from the `Buffer` pool for faster allocation of new `Buffer` instances.\n*\n* @param {NonNegativeInteger} size - number of bytes to allocate\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {Buffer} new `Buffer` instance\n*\n* @example\n* var buf = allocUnsafe( 10 );\n* // returns \n*/\nfunction allocUnsafe( size ) {\n\tif ( !isNonNegativeInteger( size ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', size ) );\n\t}\n\treturn Buffer.allocUnsafe( size );\n}\n\n\n// EXPORTS //\n\nexport default allocUnsafe;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isNonNegativeInteger from '@stdlib/assert/is-nonnegative-integer';\nimport format from '@stdlib/string/format';\nimport Buffer from './../../ctor';\n\n\n// MAIN //\n\n/**\n* Allocates a buffer having a specified number of bytes.\n*\n* ## Notes\n*\n* - The underlying memory of returned `Buffer` instances is not initialized. Memory contents are unknown and may contain sensitive data.\n* - When the size is less than half the pool size (specified on the `Buffer` constructor), memory is allocated from the `Buffer` pool for faster allocation of new `Buffer` instances.\n*\n* @param {NonNegativeInteger} size - number of bytes to allocate\n* @throws {TypeError} must provide a nonnegative integer\n* @returns {Buffer} new `Buffer` instance\n*\n* @example\n* var buf = allocUnsafe( 10 );\n* // returns \n*/\nfunction allocUnsafe( size ) {\n\tif ( !isNonNegativeInteger( size ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', size ) );\n\t}\n\treturn new Buffer( size );\n}\n\n\n// EXPORTS //\n\nexport default allocUnsafe;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'float64': Float64Array,\n\t'float32': Float32Array,\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array,\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray,\n\t'complex64': Complex64Array,\n\t'complex128': Complex128Array,\n\t'bool': BooleanArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BYTES_PER_ELEMENT from './bytes_per_element.json';\n\n\n// MAIN //\n\n/**\n* Returns the number of bytes per element provided an underlying array data type.\n*\n* @param {string} dtype - data type\n* @returns {(NonNegativeInteger|null)} number of bytes per element\n*\n* @example\n* var nbytes = bytesPerElement( 'float64' );\n* // returns 8\n*\n* nbytes = bytesPerElement( 'generic' );\n* // returns null\n*/\nfunction bytesPerElement( dtype ) {\n\treturn BYTES_PER_ELEMENT[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default bytesPerElement;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport allocUnsafe from '@stdlib/buffer/alloc-unsafe';\nimport ctors from './../../typed-ctors';\nimport zeros from './../../base/zeros';\nimport bytesPerElement from '@stdlib/ndarray/base/bytes-per-element';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized array having a specified length.\n*\n* @param {NonNegativeInteger} length - array length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = empty( 2 );\n* // returns \n*\n* @example\n* var arr = empty( 2, 'float32' );\n* // returns \n*/\nfunction empty( length ) {\n\tvar nbytes;\n\tvar offset;\n\tvar dtype;\n\tvar ctor;\n\tvar buf;\n\tvar out;\n\tvar nb;\n\n\tif ( !isNonNegativeInteger( length ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', length ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tif ( dtype === 'generic' ) {\n\t\treturn zeros( length );\n\t}\n\tnbytes = bytesPerElement( dtype );\n\tif ( nbytes === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a supported data type. Value: `%s`.', dtype ) );\n\t}\n\t// Resolve typed array constructor:\n\tctor = ctors( dtype );\n\n\t// Compute the number of bytes to allocate:\n\tnb = nbytes * length;\n\tif ( dtype === 'complex128' ) {\n\t\tnb += 8; // Note: need to allocate additional bytes to ensure alignment\n\t}\n\t// Allocate binary buffer:\n\tbuf = allocUnsafe( nb );\n\n\t// Resolve the byte offset:\n\toffset = buf.byteOffset;\n\tif ( dtype === 'complex128' ) {\n\t\tif ( !isNonNegativeInteger( offset/nbytes ) ) {\n\t\t\toffset += 8; // Note: ensure alignment\n\t\t}\n\t}\n\t// Reinterpret the binary buffer:\n\tout = new ctor( buf.buffer, offset, length );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default empty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Create an uninitialized array having a specified length.\n*\n* @module @stdlib/array/empty\n*\n* @example\n* import empty from '@stdlib/array/empty';\n*\n* var arr = empty( 2 );\n* // returns \n*\n* @example\n* import empty from '@stdlib/array/empty';\n*\n* var arr = empty( 2, 'float32' );\n* // returns \n*/\n\n// MODULES //\n\nimport isBufferUint8Array from './is_buffer_uint8array.js';\nimport main from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar empty;\nif ( isBufferUint8Array() ) {\n\tempty = main;\n} else {\n\tempty = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default empty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport allocUnsafe from '@stdlib/buffer/alloc-unsafe';\nimport isUint8Array from '@stdlib/assert/is-uint8array';\n\n\n// MAIN //\n\n/**\n* Checks whether an environment supports Node.js buffer instances which inherit from `Uint8Array`.\n*\n* @private\n* @returns {boolean} boolean indicating whether an environment supports Node.js buffer instances inheriting from `Uint8Array`\n*\n* @example\n* var bool = check();\n* // returns \n*/\nfunction check() {\n\tvar buf = allocUnsafe( 1 );\n\treturn isUint8Array( buf );\n}\n\n\n// EXPORTS //\n\nexport default check;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport zeros from './../../zeros';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized array having a specified length.\n*\n* @private\n* @param {NonNegativeInteger} length - array length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = empty( 2 );\n* // returns \n*\n* @example\n* var arr = empty( 2, 'float32' );\n* // returns \n*/\nfunction empty( length ) {\n\tif ( arguments.length > 1 ) {\n\t\treturn zeros( length, arguments[ 1 ] );\n\t}\n\treturn zeros( length );\n}\n\n\n// EXPORTS //\n\nexport default empty;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from '@stdlib/array/base/arraylike2object';\nimport accessors from './accessors.js';\n\n\n// VARIABLES //\n\nvar M = 8;\n\n\n// MAIN //\n\n/**\n* Fills a strided array with a specified scalar constant.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {*} alpha - scalar constant\n* @param {Collection} x - input array\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];\n*\n* gfill( 3, 5.0, x, 1, x.length-3 );\n* // x => [ 1.0, -2.0, 3.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfill( N, alpha, x, strideX, offsetX ) {\n\tvar ix;\n\tvar m;\n\tvar o;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn x;\n\t}\n\to = arraylike2object( x );\n\tif ( o.accessorProtocol ) {\n\t\taccessors( N, alpha, o, strideX, offsetX );\n\t\treturn o.data;\n\t}\n\tix = offsetX;\n\n\t// Use loop unrolling if the stride is equal to `1`...\n\tif ( strideX === 1 ) {\n\t\tm = N % M;\n\n\t\t// If we have a remainder, run a clean-up loop...\n\t\tif ( m > 0 ) {\n\t\t\tfor ( i = 0; i < m; i++ ) {\n\t\t\t\tx[ ix ] = alpha;\n\t\t\t\tix += strideX;\n\t\t\t}\n\t\t}\n\t\tif ( N < M ) {\n\t\t\treturn x;\n\t\t}\n\t\tfor ( i = m; i < N; i += M ) {\n\t\t\tx[ ix ] = alpha;\n\t\t\tx[ ix+1 ] = alpha;\n\t\t\tx[ ix+2 ] = alpha;\n\t\t\tx[ ix+3 ] = alpha;\n\t\t\tx[ ix+4 ] = alpha;\n\t\t\tx[ ix+5 ] = alpha;\n\t\t\tx[ ix+6 ] = alpha;\n\t\t\tx[ ix+7 ] = alpha;\n\t\t\tix += M;\n\t\t}\n\t\treturn x;\n\t}\n\tfor ( i = 0; i < N; i++ ) {\n\t\tx[ ix ] = alpha;\n\t\tix += strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default gfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills a strided array with a specified scalar constant.\n*\n* @private\n* @param {PositiveInteger} N - number of indexed elements\n* @param {*} alpha - scalar constant\n* @param {Object} x - input array object\n* @param {Collection} x.data - input array data\n* @param {Array} x.accessors - array element accessors\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {Object} input array object\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n*\n* function setter( data, idx, value ) {\n* data.set( value, idx );\n* }\n*\n* var data = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );\n*\n* var x = {\n* 'data': data,\n* 'accessors': [ null, setter ]\n* };\n*\n* var alpha = new Complex64( 5.0, 5.0 );\n*\n* gfill( data.length, alpha, x, 1, 0 );\n*\n* var view = reinterpret64( x.data, 0 );\n* // returns [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfill( N, alpha, x, strideX, offsetX ) {\n\tvar xbuf;\n\tvar set;\n\tvar ix;\n\tvar i;\n\n\t// Cache reference to array data:\n\txbuf = x.data;\n\n\t// Cache a reference to the element accessor:\n\tset = x.accessors[ 1 ];\n\n\tix = offsetX;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tset( xbuf, ix, alpha );\n\t\tix += strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default gfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport stride2offset from '@stdlib/strided/base/stride2offset';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\n/**\n* Fills a strided array with a specified scalar constant.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {*} alpha - scalar constant\n* @param {Collection} x - input array\n* @param {integer} strideX - stride length\n* @returns {Collection} input array\n*\n* @example\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfill( x.length, 5.0, x, 1 );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfill( N, alpha, x, strideX ) {\n\treturn ndarray( N, alpha, x, strideX, stride2offset( N, strideX ) );\n}\n\n\n// EXPORTS //\n\nexport default gfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from './../../is-function';\n\n\n// MAIN //\n\n/**\n* Tests if a value is iterator-like.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is iterator-like\n*\n* @example\n* var it = {\n* 'next': function noop() {}\n* };\n* var bool = isIteratorLike( it );\n* // returns true\n*\n* @example\n* var bool = isIteratorLike( {} );\n* // returns false\n*\n* @example\n* var bool = isIteratorLike( null );\n* // returns false\n*/\nfunction isIteratorLike( value ) {\n\tvar t = typeof value;\n\treturn (\n\t\tvalue !== null &&\n\t\t( t === 'object' || t === 'function' ) &&\n\t\tisFunction( value.next )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isIteratorLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isIteratorLike from '@stdlib/assert/is-iterator-like';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Consumes an iterator and returns the number of iterated values (i.e., the iterator length).\n*\n* @param {Iterator} iterator - input iterator\n* @throws {TypeError} must provide an iterator\n* @returns {NonNegativeInteger} iterator length\n*\n* @example\n* import array2iterator from '@stdlib/array/to-iterator';\n*\n* var it = array2iterator( [ 0, 0, 0, 0, 1 ] );\n*\n* var v = iterLength( it );\n* // returns 5\n*/\nfunction iterLength( iterator ) {\n\tvar count;\n\tvar v;\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an iterator. Value: `%s`.', iterator ) );\n\t}\n\tcount = 0;\n\twhile ( true ) {\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\treturn count;\n\t\t}\n\t\tcount += 1;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default iterLength;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Fill a strided array with a specified scalar constant.\n*\n* @module @stdlib/blas/ext/base/gfill\n*\n* @example\n* import gfill from '@stdlib/blas/ext/base/gfill';\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfill( x.length, 5.0, x, 1 );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*\n* @example\n* import gfill from '@stdlib/blas/ext/base/gfill';\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfill.ndarray( x.length, 5.0, x, 1, 0 );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../base/assert/is-boolean-data-type';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport ctors from './../../ctors';\nimport gfill from '@stdlib/blas/ext/base/gfill';\nimport filled from './../../base/filled';\nimport reinterpretBool from '@stdlib/strided/base/reinterpret-boolean';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport iterLength from '@stdlib/iter/length';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterator} it - iterator\n* @param {*} value - fill value\n* @returns {Array} filled array\n*/\nfunction filledIterator( it, value ) {\n\tvar arr;\n\tvar v;\n\n\tarr = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tarr.push( value );\n\t}\n\treturn arr;\n}\n\n/**\n* Fills an array exposing accessors for getting and setting array elements.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {*} value - fill value\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, value ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( value, i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array.\n*\n* @param {*} [value] - fill value\n* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} must provide a recognized data type\n* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable\n* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = filledarray();\n* // returns \n*\n* @example\n* var arr = filledarray( 1.0, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, 2, 'generic' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1.0, [ 0.5, 0.5 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = filledarray( 1, [ 5, -3 ], 'int32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1.0, arr1 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' );\n* var arr2 = filledarray( 1, arr1, 'uint32' );\n* // returns [ 1, 1 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 'float32' );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8 );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarray( 1.0, buf, 8, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1.0, buf, 8, 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarray( 1, buf, 8, 2, 'int32' );\n* // returns [ 1, 1 ]\n*/\nfunction filledarray() {\n\tvar value;\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tnargs -= 1;\n\tif ( nargs >= 0 && isString( arguments[ nargs ] ) ) {\n\t\tdtype = arguments[ nargs ];\n\t\tnargs -= 1;\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\tif ( dtype === 'generic' ) {\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn [];\n\t\t}\n\t\tvalue = arguments[ 0 ];\n\t\targ = arguments[ 1 ];\n\t\tif ( nargs === 1 ) {\n\t\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\t\tlen = arg;\n\t\t\t} else if ( isCollection( arg ) ) {\n\t\t\t\tlen = arg.length;\n\t\t\t}\n\t\t\tif ( len !== void 0 ) {\n\t\t\t\treturn filled( value, len );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t\t}\n\t\t\tif ( isObject( arg ) ) {\n\t\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledIterator( arg, value );\n\t\t\t}\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 1 ];\n\t\tif ( isCollection( arg ) ) {\n\t\t\tarr = new ctor( arg.length );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isNonNegativeInteger( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else if ( nargs === 2 ) {\n\t\tarr = new ctor( arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[1], arguments[2], arguments[3] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tvalue = arguments[ 0 ];\n\t\tif ( isComplexDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, value );\n\t\t} else if ( isBooleanDataType( dtype ) ) {\n\t\t\tgfill( arr.length, ( value ) ? 1 : 0, reinterpretBool( arr, 0 ), 1 ); // eslint-disable-line max-len\n\t\t} else {\n\t\t\tgfill( arr.length, value, arr, 1 );\n\t\t}\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default filledarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport arraylike2object from '@stdlib/array/base/arraylike2object';\nimport accessors from './accessors.js';\n\n\n// MAIN //\n\n/**\n* Fills a strided array according to a provided callback function.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - execution context\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* gfillBy( 3, x, 1, x.length-3, fill );\n* // x => [ 1.0, -2.0, 3.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfillBy( N, x, strideX, offsetX, clbk, thisArg ) {\n\tvar ix;\n\tvar o;\n\tvar i;\n\n\tif ( N <= 0 ) {\n\t\treturn x;\n\t}\n\to = arraylike2object( x );\n\tif ( o.accessorProtocol ) {\n\t\taccessors( N, o, strideX, offsetX, clbk, thisArg );\n\t\treturn o.data;\n\t}\n\tix = offsetX;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tx[ ix ] = clbk.call( thisArg, x[ ix ], i, ix, x );\n\t\tix += strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default gfillBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills a strided array according to a provided callback function.\n*\n* @private\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Object} x - input array object\n* @param {Collection} x.data - input array data\n* @param {Array} x.accessors - array element accessors\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @param {Callback} clbk - callback function\n* @param {*} thisArg - execution context\n* @returns {Object} input array object\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n* import Complex64 from '@stdlib/complex/float32/ctor';\n* import reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\n*\n* function setter( data, idx, value ) {\n* data.set( value, idx );\n* }\n*\n* function getter( data, idx ) {\n* return data.get( idx );\n* }\n*\n* var data = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );\n*\n* var x = {\n* 'data': data,\n* 'accessors': [ getter, setter ]\n* };\n*\n* function clbk() {\n* return new Complex64( 5.0, 5.0 );\n* }\n*\n* gfillBy( data.length, x, 1, 0, clbk, void 0 );\n*\n* var view = reinterpret64( x.data, 0 );\n* // view => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfillBy( N, x, strideX, offsetX, clbk, thisArg ) {\n\tvar xbuf;\n\tvar set;\n\tvar get;\n\tvar ix;\n\tvar i;\n\n\t// Cache reference to array data:\n\txbuf = x.data;\n\n\t// Cache a reference to the element accessors:\n\tget = x.accessors[ 0 ];\n\tset = x.accessors[ 1 ];\n\n\tix = offsetX;\n\tfor ( i = 0; i < N; i++ ) {\n\t\tset( xbuf, ix, clbk.call( thisArg, get( xbuf, ix ), i, ix, x ) );\n\t\tix += strideX;\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nexport default gfillBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport stride2offset from '@stdlib/strided/base/stride2offset';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\n/**\n* Fills a strided array according to a provided callback function.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Collection} x - input array\n* @param {integer} strideX - stride length\n* @param {Callback} clbk - callback function\n* @param {*} [thisArg] - execution context\n* @returns {Collection} input array\n*\n* @example\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* gfillBy( x.length, x, 1, fill );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\nfunction gfillBy( N, x, strideX, clbk, thisArg ) {\n\treturn ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg );\n}\n\n\n// EXPORTS //\n\nexport default gfillBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Fill a strided array according to a provided callback function.\n*\n* @module @stdlib/blas/ext/base/gfill-by\n*\n* @example\n* import gfillBy from '@stdlib/blas/ext/base/gfill-by';\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfillBy( x.length, x, 1, fill );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*\n* @example\n* import gfillBy from '@stdlib/blas/ext/base/gfill-by';\n*\n* function fill() {\n* return 5.0;\n* }\n*\n* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];\n*\n* gfillBy.ndarray( x.length, x, 1, 0, fill );\n* // x => [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport ndarray from './ndarray.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isBooleanDataType from './../../base/assert/is-boolean-data-type';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport ctors from './../../ctors';\nimport gfillBy from '@stdlib/blas/ext/base/gfill-by';\nimport filledArray from './../../base/filled-by';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport iterLength from '@stdlib/iter/length';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterable} it - iterator\n* @param {Callback} clbk - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {Array} filled array\n*/\nfunction filledArrayIterator( it, clbk, thisArg ) {\n\tvar arr;\n\tvar i;\n\tvar v;\n\n\tarr = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tarr.push( clbk.call( thisArg, i ) );\n\t}\n\treturn arr;\n}\n\n/**\n* Fills an array exposing accessors for getting and setting array elements.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {Callback} clbk - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, clbk, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( clbk.call( thisArg, i ), i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array according to a provided callback function.\n*\n* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"float64\"] - data type\n* @param {Callback} [clbk] - callback to invoke\n* @param {*} [thisArg] - callback execution context\n* @throws {TypeError} must provide a recognized data type\n* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable\n* @throws {TypeError} callback argument must be a function.\n* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array)} array or typed array\n*\n* @example\n* var arr = filledarrayBy();\n* // returns \n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'generic', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1;\n* }\n*\n* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk );\n* // returns [ 1, 1 ]\n*\n* @example\n* function clbk1() {\n* return 10;\n* }\n*\n* function clbk2() {\n* return 1.0;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, clbk2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk1() {\n* return 1.0;\n* }\n*\n* function clbk2() {\n* return 2;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 );\n* // returns [ 2, 2 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 'float32', clbk );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, clbk );\n* // returns [ 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* function clbk() {\n* return 1;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk );\n* // returns [ 1, 1 ]\n*/\nfunction filledarrayBy() {\n\tvar thisArg;\n\tvar nargs;\n\tvar dtype;\n\tvar clbk;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\n\t// If we weren't provided any arguments, return an empty array...\n\tif ( nargs === 0 ) {\n\t\tctor = ctors( DEFAULT_DTYPE );\n\t\treturn new ctor( 0 );\n\t}\n\t// Check if we were provided a dtype as the first argument...\n\tdtype = arguments[ 0 ];\n\tif ( isString( dtype ) ) {\n\t\t// Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)...\n\t\tif ( nargs > 1 ) {\n\t\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t\t}\n\t\t// Return an empty array having the specified dtype:\n\t\treturn new ctor( 0 );\n\t}\n\t// For all other supported invocations, we need at least two arguments...\n\tif ( nargs < 2 ) {\n\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t}\n\t// At this point, we need to do some argument juggling...\n\tnargs -= 1; // henceforth, the number of available arguments is `nargs+1`\n\n\t// Determine whether the last argument is a callback or \"this\" context...\n\tif ( isFunction( arguments[ nargs ] ) ) {\n\t\t// If the last argument is a function, we need to check the next-to-last argument, and, if the next-to-last argument is a function, assume that the next-to-last argument is the callback and the last argument is a \"this\" context...\n\t\tif ( isFunction( arguments[ nargs-1 ] ) ) {\n\t\t\tthisArg = arguments[ nargs ];\n\t\t\tnargs -= 1;\n\t\t\tclbk = arguments[ nargs ];\n\n\t\t\t// Check if we were provided only a callback and a \"this\" context..\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t\t\t}\n\t\t} else {\n\t\t\t// \"this\" context is left undefined...\n\t\t\tclbk = arguments[ nargs ];\n\t\t}\n\t}\n\t// If we were provided 3 or more arguments and the last argument was not a function, assume that we were provided a callback and a \"this\" context...\n\telse if ( nargs >= 2 ) {\n\t\tthisArg = arguments[ nargs ];\n\t\tnargs -= 1;\n\t\tclbk = arguments[ nargs ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t}\n\t// If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments...\n\telse {\n\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t}\n\t// Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument...\n\tnargs -= 1;\n\tif ( nargs >= 0 && isString( arguments[ nargs ] ) ) {\n\t\tdtype = arguments[ nargs ];\n\t\tnargs -= 1;\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\t// At this point, we've resolved the output array data type, and now we can actually create the output array...\n\tif ( dtype === 'generic' ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( nargs === 0 ) {\n\t\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\t\tlen = arg;\n\t\t\t} else if ( isCollection( arg ) ) {\n\t\t\t\tlen = arg.length;\n\t\t\t}\n\t\t\tif ( len !== void 0 ) {\n\t\t\t\treturn filledArray( len, clbk, thisArg );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t\t}\n\t\t\tif ( isObject( arg ) ) {\n\t\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledArrayIterator( arg, clbk, thisArg );\n\t\t\t}\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t}\n\tif ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 0 ];\n\t\tif ( isCollection( arg ) ) {\n\t\t\tarr = new ctor( arg.length );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isNonNegativeInteger( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else if ( nargs === 1 ) {\n\t\tarr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, clbk, thisArg );\n\t\t} else {\n\t\t\tgfillBy( arr.length, arr, 1, callback );\n\t\t}\n\t}\n\treturn arr;\n\n\t/**\n\t* Callback which wraps a provided callback and is invoked for each array element.\n\t*\n\t* @private\n\t* @param {*} value - element value\n\t* @param {NonNegativeInteger} aidx - array index\n\t* @param {NonNegativeInteger} sidx - strided index\n\t* @param {Collection} array - input array/collection\n\t* @returns {*} callback return value\n\t*/\n\tfunction callback( value, aidx ) {\n\t\treturn clbk.call( thisArg, aidx );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default filledarrayBy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar isProtoOf = Object.prototype.isPrototypeOf;\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Tests if an object's prototype chain contains a provided prototype.\n*\n* @param {*} value - value to test\n* @param {(Object|Function)} proto - prototype\n* @throws {TypeError} second argument must be an object and not null\n* @returns {boolean} boolean indicating if a provided prototype exists in a prototype chain\n*\n* @example\n* import inherit from '@stdlib/utils/inherit';\n*\n* function Foo() {\n* return this;\n* }\n*\n* function Bar() {\n* return this;\n* }\n* inherit( Bar, Foo );\n*\n* var bar = new Bar();\n*\n* var bool = isPrototypeOf( bar, Foo.prototype );\n* // returns true\n*/\nfunction isPrototypeOf( value, proto ) { // eslint-disable-line stdlib/no-redeclare\n\tvar type = typeof proto;\n\tif (\n\t\tproto === null ||\n\t\t(type !== 'object' && type !== 'function')\n\t) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either an object (except null) or a function. Value: `%s`.', proto ) );\n\t}\n\ttype = typeof value;\n\tif (\n\t\tvalue === null ||\n\t\t(type !== 'object' && type !== 'function')\n\t) {\n\t\treturn false;\n\t}\n\treturn isProtoOf.call( proto, value );\n}\n\n\n// EXPORTS //\n\nexport default isPrototypeOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Capitalizes the first character in a string.\n*\n* @param {string} str - input string\n* @returns {string} capitalized string\n*\n* @example\n* var out = capitalize( 'last man standing' );\n* // returns 'Last man standing'\n*\n* @example\n* var out = capitalize( 'presidential election' );\n* // returns 'Presidential election'\n*\n* @example\n* var out = capitalize( 'javaScript' );\n* // returns 'JavaScript'\n*\n* @example\n* var out = capitalize( 'Hidden Treasures' );\n* // returns 'Hidden Treasures'\n*/\nfunction capitalize( str ) {\n\tif ( str === '' ) {\n\t\treturn '';\n\t}\n\treturn str.charAt( 0 ).toUpperCase() + str.slice( 1 );\n}\n\n\n// EXPORTS //\n\nexport default capitalize;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len, no-restricted-syntax, no-invalid-this, max-lines */\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport isByteOrder from './../../base/assert/is-byte-order';\nimport lowercase from '@stdlib/string/base/lowercase';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isPrototypeOf from '@stdlib/assert/is-prototype-of'; // eslint-disable-line stdlib/no-redeclare\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport ArrayBuffer from './../../buffer';\nimport DataView from './../../dataview';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport { factory as contains } from './../../base/assert/contains';\nimport bytesPerElement from '@stdlib/ndarray/base/bytes-per-element';\nimport capitalize from '@stdlib/string/base/capitalize';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar LITTLE_ENDIAN = 'little-endian';\nvar BIG_ENDIAN = 'big-endian';\nvar DTYPES = [ 'float64', 'float32', 'int32', 'int16', 'uint32', 'uint16' ];\nvar DTYPE2SET = {\n\t'float64': 'setFloat64',\n\t'float32': 'setFloat32',\n\t'int32': 'setInt32',\n\t'int16': 'setInt16',\n\t'uint32': 'setUint32',\n\t'uint16': 'setUint16'\n};\nvar DTYPE2GET = {\n\t'float64': 'getFloat64',\n\t'float32': 'getFloat32',\n\t'int32': 'getInt32',\n\t'int16': 'getInt16',\n\t'uint32': 'getUint32',\n\t'uint16': 'getUint16'\n};\nvar CHAR2ARTICLE = {\n\t'c': 'a',\n\t'f': 'a',\n\t'i': 'an',\n\t'u': 'a',\n\t'b': 'a'\n};\nvar isDataType = contains( DTYPES );\n\n\n// FUNCTIONS //\n\n/**\n* Normalizes a byte order value.\n*\n* @private\n* @param {*} value - byte order\n* @returns {(string|null)} normalized byte order\n*/\nfunction byteOrder( value ) {\n\treturn ( isString( value ) ) ? lowercase( value ) : null;\n}\n\n/**\n* Tests whether a provided byte order is little-endian byte order.\n*\n* @private\n* @param {string} value - byte order\n* @returns {boolean} boolean indicating whether a byte order is little-endian byte order\n*/\nfunction isLittleEndian( value ) {\n\treturn ( value === LITTLE_ENDIAN );\n}\n\n/**\n* Resolves a byte order string from a boolean flag.\n*\n* @private\n* @param {boolean} isLE - flag indicating whether an array is little-endian\n* @returns {string} resolved byte order\n*/\nfunction flag2byteOrder( isLE ) {\n\treturn ( isLE ) ? LITTLE_ENDIAN : BIG_ENDIAN;\n}\n\n/**\n* Converts a data type string to a constructor name.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {string} constructor name\n*\n* @example\n* var n = dtype2ctor( 'float64' );\n* // returns 'Float64ArrayFE'\n*\n* @example\n* var n = dtype2ctor( 'int32' );\n* // returns 'Int32ArrayFE'\n*/\nfunction dtype2ctor( dtype ) {\n\treturn capitalize( dtype ) + 'ArrayFE';\n}\n\n\n// MAIN //\n\n/**\n* Returns a typed array constructor for creating typed arrays having a specified byte order.\n*\n* @param {string} dtype - typed array data type\n* @throws {TypeError} first argument must be a supported data type\n* @returns {Function} typed array constructor\n*\n* @example\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var arr = new Float64ArrayFE( 'little-endian' );\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var arr = new Float64ArrayFE( 'little-endian', 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayFE( 'little-endian', buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayFE( 'little-endian', buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayFE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayFE( 'little-endian', buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) { // eslint-disable-line max-lines-per-function, stdlib/jsdoc-require-throws-tags\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar GETTER;\n\tvar SETTER;\n\n\tif ( !isDataType( dtype ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a supported data type. Value: `%s`.', dtype ) );\n\t}\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tGETTER = DTYPE2GET[ dtype ];\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in a specified byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {string} endianness - byte order\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} first argument must be a supported byte order\n\t* @throws {TypeError} if provided only two arguments, the second argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @throws {RangeError} byte offset must be a multiple of the data type size\n\t* @throws {TypeError} view length must be a positive multiple of the data type size\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar byteOffset;\n\t\tvar endianness;\n\t\tvar nargs;\n\t\tvar isLE;\n\t\tvar buf;\n\t\tvar len;\n\t\tvar arg;\n\t\tvar tmp;\n\n\t\tnargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs < 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\tif ( nargs === 3 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2], arguments[3] );\n\t\t}\n\t\tendianness = byteOrder( arguments[ 0 ] );\n\t\tif ( endianness === null || !isByteOrder( endianness ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a supported byte order. Value: `%s`.', arguments[ 0 ] ) );\n\t\t}\n\t\tisLE = isLittleEndian( endianness );\n\n\t\tnargs -= 1;\n\n\t\t// Create the underlying data buffer...\n\t\tif ( nargs === 0 ) {\n\t\t\tbuf = new DataView( new ArrayBuffer( 0 ) ); // backward-compatibility\n\t\t} else if ( nargs === 1 ) {\n\t\t\targ = arguments[ nargs ];\n\t\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\t\tbuf = new DataView( new ArrayBuffer( arg*BYTES_PER_ELEMENT ) );\n\t\t\t} else if ( isCollection( arg ) ) {\n\t\t\t\tbuf = fromArray( new DataView( new ArrayBuffer( arg.length*BYTES_PER_ELEMENT ) ), arg, isLE );\n\t\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\t\tbuf = new DataView( arg );\n\t\t\t\tif ( !isNonNegativeInteger( arg.byteLength/BYTES_PER_ELEMENT ) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) );\n\t\t\t\t}\n\t\t\t} else if ( isObject( arg ) ) {\n\t\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tbuf = arg[ ITERATOR_SYMBOL ]();\n\t\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t\tbuf = fromArray( new DataView( new ArrayBuffer( tmp.length*BYTES_PER_ELEMENT ) ), tmp, isLE );\n\t\t\t} else {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t} else {\n\t\t\tbuf = arguments[ 1 ];\n\t\t\tif ( !isArrayBuffer( buf ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide an ArrayBuffer. Value: `%s`.', buf ) );\n\t\t\t}\n\t\t\tbyteOffset = arguments[ 2 ];\n\t\t\tif ( !isNonNegativeInteger( byteOffset ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.', byteOffset ) );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\tbuf = new DataView( buf, byteOffset );\n\t\t\t} else {\n\t\t\t\tlen = arguments[ 3 ];\n\t\t\t\tif ( !isNonNegativeInteger( len ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t\t\t\t}\n\t\t\t\tlen *= BYTES_PER_ELEMENT;\n\t\t\t\tif ( len > (buf.byteLength-byteOffset) ) {\n\t\t\t\t\tthrow new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len ) );\n\t\t\t\t}\n\t\t\t\tbuf = new DataView( buf, byteOffset, len );\n\t\t\t}\n\t\t}\n\t\tsetReadOnly( this, '_buffer', buf );\n\t\tsetReadOnly( this, '_length', buf.byteLength/BYTES_PER_ELEMENT );\n\t\tsetReadOnly( this, '_isLE', isLE );\n\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {string} endianness - byte order\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be a supported byte order\n\t* @throws {TypeError} second argument must be an array-like object or an iterable\n\t* @throws {TypeError} third argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( endianness, src ) {\n\t\tvar thisArg;\n\t\tvar order;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar isLE;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\torder = byteOrder( endianness );\n\t\tif ( order === null || !isByteOrder( order ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a supported byte order. Value: `%s`.', endianness ) );\n\t\t}\n\t\tisLE = isLittleEndian( order );\n\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 2 ) {\n\t\t\tclbk = arguments[ 2 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 3 ) {\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( order, len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), isLE );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( order, src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( order, len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], isLE );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {string} endianness - byte order\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be a supported byte order\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of( endianness ) {\n\t\tvar order;\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\torder = byteOrder( endianness );\n\t\tif ( order === null || !isByteOrder( order ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a supported byte order. Value: `%s`.', endianness ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( order, args );\n\t});\n\n\t/**\n\t* Returns an array element located at integer position (index) `i`, with support for both nonnegative and negative integer indices.\n\t*\n\t* @private\n\t* @name at\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {integer} idx - element index\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} must provide an integer\n\t* @returns {(*|void)} array element\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'at', function at( idx ) {\n\t\tvar len;\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide an integer. Value: `%s`.', idx ) );\n\t\t}\n\t\tlen = this._length;\n\t\tif ( idx < 0 ) {\n\t\t\tidx += len;\n\t\t}\n\t\tif ( idx < 0 || idx >= len ) {\n\t\t\treturn;\n\t\t}\n\t\treturn this._buffer[ GETTER ]( idx * BYTES_PER_ELEMENT, this._isLE );\n\t});\n\n\t/**\n\t* Pointer to the underlying data buffer.\n\t*\n\t* @private\n\t* @name buffer\n\t* @memberof TypedArray.prototype\n\t* @readonly\n\t* @type {ArrayBuffer}\n\t*/\n\tsetReadOnlyAccessor( TypedArray.prototype, 'buffer', function get() {\n\t\treturn this._buffer.buffer;\n\t});\n\n\t/**\n\t* Size (in bytes) of the array.\n\t*\n\t* @private\n\t* @name byteLength\n\t* @memberof TypedArray.prototype\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnlyAccessor( TypedArray.prototype, 'byteLength', function get() {\n\t\treturn this._buffer.byteLength;\n\t});\n\n\t/**\n\t* Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`.\n\t*\n\t* @private\n\t* @name byteOffset\n\t* @memberof TypedArray.prototype\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnlyAccessor( TypedArray.prototype, 'byteOffset', function get() {\n\t\treturn this._buffer.byteOffset;\n\t});\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray.prototype\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'BYTES_PER_ELEMENT', TypedArray.BYTES_PER_ELEMENT );\n\n\t/**\n\t* Tests whether all elements in an array pass a test implemented by a predicate function.\n\t*\n\t* @private\n\t* @name every\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} predicate - predicate function\n\t* @param {*} [thisArg] - predicate function execution context\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a function\n\t* @returns {boolean} boolean indicating whether all elements pass a test\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'every', function every( predicate, thisArg ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( predicate ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tif ( !predicate.call( thisArg, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t});\n\n\t/**\n\t* Returns a new array containing the elements of an array which pass a test implemented by a predicate function.\n\t*\n\t* @private\n\t* @name filter\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} predicate - test function\n\t* @param {*} [thisArg] - predicate function execution context\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a function\n\t* @returns {TypedArray} typed array\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'filter', function filter( predicate, thisArg ) {\n\t\tvar buf;\n\t\tvar out;\n\t\tvar i;\n\t\tvar v;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( predicate ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tout = [];\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tv = buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE );\n\t\t\tif ( predicate.call( thisArg, v, i, this ) ) {\n\t\t\t\tout.push( v );\n\t\t\t}\n\t\t}\n\t\treturn new this.constructor( flag2byteOrder( this._isLE ), out );\n\t});\n\n\t/**\n\t* Invokes a function once for each array element.\n\t*\n\t* @private\n\t* @name forEach\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} fcn - function to invoke\n\t* @param {*} [thisArg] - function invocation context\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a function\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'forEach', function forEach( fcn, thisArg ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tfcn.call( thisArg, buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE ), i, this );\n\t\t}\n\t});\n\n\t/**\n\t* Returns an array element.\n\t*\n\t* @private\n\t* @name get\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {NonNegativeInteger} idx - element index\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} must provide a nonnegative integer\n\t* @returns {(*|void)} array element\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'get', function get( idx ) {\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) );\n\t\t}\n\t\tif ( idx >= this._length ) {\n\t\t\treturn;\n\t\t}\n\t\treturn this._buffer[ GETTER ]( idx*BYTES_PER_ELEMENT, this._isLE );\n\t});\n\n\t/**\n\t* Returns a boolean indicating whether an array includes a provided value.\n\t*\n\t* @private\n\t* @name includes\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {*} searchElement - search element\n\t* @param {integer} [fromIndex=0] - starting index (inclusive)\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} second argument must be an integer\n\t* @returns {boolean} boolean indicating whether an array includes a provided value\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'includes', function includes( searchElement, fromIndex ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( arguments.length > 1 ) {\n\t\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t\t}\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex += this._length;\n\t\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\t\tfromIndex = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfromIndex = 0;\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\t\tif ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t});\n\n\t/**\n\t* Returns the index of the first occurrence of a given element.\n\t*\n\t* @private\n\t* @name indexOf\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {*} searchElement - element to search for\n\t* @param {integer} [fromIndex=0] - starting index (inclusive)\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} second argument must be an integer\n\t* @returns {integer} index or -1\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'indexOf', function indexOf( searchElement, fromIndex ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( arguments.length > 1 ) {\n\t\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t\t}\n\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\tfromIndex += this._length;\n\t\t\t\tif ( fromIndex < 0 ) {\n\t\t\t\t\tfromIndex = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfromIndex = 0;\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = fromIndex; i < this._length; i++ ) {\n\t\t\tif ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t});\n\n\t/**\n\t* Returns a new string by concatenating all array elements.\n\t*\n\t* @private\n\t* @name join\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {string} [separator=','] - element separator\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a string\n\t* @returns {string} joined string\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'join', function join( separator ) {\n\t\tvar out;\n\t\tvar buf;\n\t\tvar sep;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( arguments.length > 0 ) {\n\t\t\tif ( !isString( separator ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', separator ) );\n\t\t\t}\n\t\t\tsep = separator;\n\t\t} else {\n\t\t\tsep = ',';\n\t\t}\n\t\tout = [];\n\t\tbuf = this._buffer;\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tout.push( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) );\n\t\t}\n\t\treturn out.join( sep );\n\t});\n\n\t/**\n\t* Returns the index of the last occurrence of a given element.\n\t*\n\t* @private\n\t* @name lastIndexOf\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {*} searchElement - element to search for\n\t* @param {integer} [fromIndex] - starting index (inclusive)\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} second argument must be an integer\n\t* @returns {integer} index or -1\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'lastIndexOf', function lastIndexOf( searchElement, fromIndex ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[ 0 ] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( arguments.length > 1 ) {\n\t\t\tif ( !isInteger( fromIndex ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', fromIndex ) );\n\t\t\t}\n\t\t\tif ( fromIndex >= this._length ) {\n\t\t\t\tfromIndex = this._length - 1;\n\t\t\t} else if ( fromIndex < 0 ) {\n\t\t\t\tfromIndex += this._length;\n\t\t\t}\n\t\t} else {\n\t\t\tfromIndex = this._length - 1;\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = fromIndex; i >= 0; i-- ) {\n\t\t\tif ( buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ) === searchElement ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t});\n\n\t/**\n\t* Number of array elements.\n\t*\n\t* @private\n\t* @name length\n\t* @memberof TypedArray.prototype\n\t* @readonly\n\t* @type {NonNegativeInteger}\n\t*/\n\tsetReadOnlyAccessor( TypedArray.prototype, 'length', function get() {\n\t\treturn this._length;\n\t});\n\n\t/**\n\t* Returns a new array with each element being the result of a provided callback function.\n\t*\n\t* @private\n\t* @name map\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} fcn - function to invoke\n\t* @param {*} [thisArg] - function invocation context\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a function\n\t* @returns {TypedArray} new typed array\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'map', function map( fcn, thisArg ) {\n\t\tvar obuf;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar i;\n\t\tvar v;\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tout = new this.constructor( flag2byteOrder( this._isLE ), this._length );\n\t\tobuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tv = fcn.call( thisArg, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this );\n\t\t\tobuf[ SETTER ]( i * BYTES_PER_ELEMENT, v, this._isLE );\n\t\t}\n\t\treturn out;\n\t});\n\n\t/**\n\t* Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.\n\t*\n\t* @private\n\t* @name reduce\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} reducer - callback function\n\t* @param {*} [initialValue] - initial value\n\t* @throws {TypeError} `this` must be a typed array\n\t* @throws {Error} if not provided an initial value, the array must have at least one element\n\t* @returns {*} accumulated result\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'reduce', function reduce( reducer, initialValue ) {\n\t\tvar buf;\n\t\tvar len;\n\t\tvar acc;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( reducer ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tlen = this._length;\n\t\tif ( arguments.length > 1 ) {\n\t\t\tacc = initialValue;\n\t\t\ti = 0;\n\t\t} else {\n\t\t\tif ( len === 0 ) {\n\t\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t\t}\n\t\t\tacc = buf[ GETTER ]( 0 * BYTES_PER_ELEMENT, this._isLE );\n\t\t\ti = 1;\n\t\t}\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tacc = reducer( acc, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this );\n\t\t}\n\t\treturn acc;\n\t});\n\n\t/**\n\t* Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion.\n\t*\n\t* @private\n\t* @name reduceRight\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} reducer - callback function\n\t* @param {*} [initialValue] - initial value\n\t* @throws {TypeError} `this` must be a typed array\n\t* @throws {Error} if not provided an initial value, the array must have at least one element\n\t* @returns {*} accumulated result\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'reduceRight', function reduceRight( reducer, initialValue ) {\n\t\tvar buf;\n\t\tvar len;\n\t\tvar acc;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( reducer ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', reducer ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tlen = this._length;\n\t\tif ( arguments.length > 1 ) {\n\t\t\tacc = initialValue;\n\t\t\ti = len - 1;\n\t\t} else {\n\t\t\tif ( len === 0 ) {\n\t\t\t\tthrow new Error( 'invalid operation. If not provided an initial value, an array must contain at least one element.' );\n\t\t\t}\n\t\t\tacc = buf[ GETTER ]( ( len - 1 ) * BYTES_PER_ELEMENT, this._isLE );\n\t\t\ti = len - 2;\n\t\t}\n\t\tfor ( ; i >= 0; i-- ) {\n\t\t\tacc = reducer( acc, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this );\n\t\t}\n\t\treturn acc;\n\t});\n\n\t/**\n\t* Sets an array element.\n\t*\n\t* ## Notes\n\t*\n\t* - When provided a typed array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario:\n\t*\n\t* ```text\n\t* buf: ---------------------\n\t* src: ---------------------\n\t* ```\n\t*\n\t* In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array.\n\t*\n\t* In the other overlapping scenario,\n\t*\n\t* ```text\n\t* buf: ---------------------\n\t* src: ---------------------\n\t* ```\n\t*\n\t* by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended.\n\t*\n\t* @private\n\t* @name set\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {(Collection|TypedArray|*)} value - value(s)\n\t* @param {NonNegativeInteger} [i=0] - element index at which to start writing values\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} index argument must be a nonnegative integer\n\t* @throws {RangeError} index argument is out-of-bounds\n\t* @throws {RangeError} target array lacks sufficient storage to accommodate source values\n\t* @returns {void}\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'set', function set( value ) {\n\t\tvar sbuf;\n\t\tvar idx;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar N;\n\t\tvar i;\n\t\tvar j;\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tif ( arguments.length > 1 ) {\n\t\t\tidx = arguments[ 1 ];\n\t\t\tif ( !isNonNegativeInteger( idx ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) );\n\t\t\t}\n\t\t} else {\n\t\t\tidx = 0;\n\t\t}\n\t\tif ( isCollection( value ) ) {\n\t\t\tN = value.length;\n\t\t\tif ( idx+N > this._length ) {\n\t\t\t\tthrow new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' );\n\t\t\t}\n\t\t\tsbuf = value;\n\t\t\tif ( sbuf.get && sbuf.set ) {\n\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t} else {\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\t// Check for overlapping memory...\n\t\t\tj = buf.byteOffset + (idx*BYTES_PER_ELEMENT);\n\t\t\tif (\n\t\t\t\tsbuf.buffer === buf.buffer &&\n\t\t\t\t(\n\t\t\t\t\tsbuf.byteOffset < j &&\n\t\t\t\t\tsbuf.byteOffset+sbuf.byteLength > j\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// We need to copy source values...\n\t\t\t\ttmp = [];\n\t\t\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\t\t\ttmp.push( get( value, i ) );\n\t\t\t\t}\n\t\t\t\tsbuf = tmp;\n\t\t\t\tget = getter( 'default' );\n\t\t\t}\n\t\t\tfor ( i = 0; i < N; idx++, i++ ) {\n\t\t\t\tbuf[ SETTER ]( idx*BYTES_PER_ELEMENT, get( sbuf, i ), this._isLE );\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif ( idx >= this._length ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) );\n\t\t}\n\t\tbuf[ SETTER ]( idx*BYTES_PER_ELEMENT, value, this._isLE );\n\t});\n\n\t/**\n\t* Tests whether at least one element in the typed array passes a test implemented by a predicate function.\n\t*\n\t* @private\n\t* @name some\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {Function} predicate - predicate function\n\t* @param {*} [thisArg] - predicate function execution context\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be a function\n\t* @returns {boolean} boolean indicating whether at least one element passes a test\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'some', function some( predicate, thisArg ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isFunction( predicate ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) );\n\t\t}\n\t\tbuf = this._buffer;\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tif ( predicate.call( thisArg, buf[ GETTER ]( i * BYTES_PER_ELEMENT, this._isLE ), i, this ) ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t});\n\n\t/**\n\t* Serializes an array as a string.\n\t*\n\t* @private\n\t* @name toString\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @returns {string} string representation\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'toString', function toString() {\n\t\tvar out;\n\t\tvar buf;\n\t\tvar i;\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tout = [];\n\t\tbuf = this._buffer;\n\t\tfor ( i = 0; i < this._length; i++ ) {\n\t\t\tout.push( buf[ GETTER ]( i*BYTES_PER_ELEMENT, this._isLE ) );\n\t\t}\n\t\treturn out.join( ',' );\n\t});\n\n\t/**\n\t* Returns a new typed array with the element at a provided index replaced with a provided value.\n\t*\n\t* @private\n\t* @name with\n\t* @memberof TypedArray.prototype\n\t* @type {Function}\n\t* @param {integer} index - element index\n\t* @param {number} value - new value\n\t* @throws {TypeError} `this` must be a typed array instance\n\t* @throws {TypeError} first argument must be an integer\n\t* @throws {RangeError} index argument is out-of-bounds\n\t* @returns {TypedArray} new typed array\n\t*/\n\tsetReadOnly( TypedArray.prototype, 'with', function copyWith( index, value ) {\n\t\tvar outbuf;\n\t\tvar buf;\n\t\tvar out;\n\t\tvar len;\n\n\t\tif ( !isTypedArray( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tif ( !isInteger( index ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an integer. Value: `%s`.', index ) );\n\t\t}\n\t\tlen = this._length;\n\t\tbuf = this._buffer;\n\t\tif ( index < 0 ) {\n\t\t\tindex += len;\n\t\t}\n\t\tif ( index < 0 || index >= len ) {\n\t\t\tthrow new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%s`.', index ) );\n\t\t}\n\t\tout = new this.constructor( flag2byteOrder( this._isLE ), buf.buffer );\n\t\toutbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\toutbuf[ SETTER ]( index * BYTES_PER_ELEMENT, value, this._isLE );\n\t\treturn out;\n\t});\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array\n\t*/\n\tfunction isTypedArray( value ) {\n\t\treturn (\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\t(\n\t\t\t\tvalue.constructor.name === CTOR_NAME ||\n\t\t\t\tisPrototypeOf( value, TypedArray.prototype )\n\t\t\t) &&\n\t\t\tvalue.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT\n\t\t);\n\t}\n\n\t/**\n\t* Fills an output DataView with array values.\n\t*\n\t* @private\n\t* @param {DataView} view - output data view\n\t* @param {Array} arr - input array\n\t* @param {boolean} isLE - boolean indicating whether to store values in little-endian byte order\n\t* @returns {DataView} output data view\n\t*/\n\tfunction fromArray( view, arr, isLE ) {\n\t\tvar len;\n\t\tvar get;\n\t\tvar i;\n\n\t\tlen = arr.length;\n\t\tif ( arr.get && arr.set ) {\n\t\t\tget = accessorGetter( 'default' );\n\t\t} else {\n\t\t\tget = getter( 'default' );\n\t\t}\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tview[ SETTER ]( i*BYTES_PER_ELEMENT, get( arr, i ), isLE );\n\t\t}\n\t\treturn view;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Converts a string to lowercase.\n*\n* @param {string} str - string to convert\n* @returns {string} lowercase string\n*\n* @example\n* var str = lowercase( 'bEEp' );\n* // returns 'beep'\n*/\nfunction lowercase( str ) {\n\treturn str.toLowerCase();\n}\n\n\n// EXPORTS //\n\nexport default lowercase;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './../../fixed-endian-factory';\n\n\n// MAIN //\n\n/**\n* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in a specified byte order.\n*\n* @name Float32ArrayFE\n* @constructor\n* @type {Function}\n* @param {string} endianness - byte order\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} first argument must be a supported byte order\n* @throws {TypeError} if provided only two arguments, the second argument must be a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float32ArrayFE} typed array instance\n*\n* @example\n* var arr = new Float32ArrayFE( 'little-endian' );\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float32ArrayFE( 'little-endian', 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Float32ArrayFE( 'little-endian', [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 8 );\n* var arr = new Float32ArrayFE( 'little-endian', buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 8 );\n* var arr = new Float32ArrayFE( 'little-endian', buf, 4 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float32ArrayFE( 'little-endian', buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nvar Float32ArrayFE = factory( 'float32' );\n\n\n// EXPORTS //\n\nexport default Float32ArrayFE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './../../fixed-endian-factory';\n\n\n// MAIN //\n\n/**\n* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in a specified byte order.\n*\n* @name Float64ArrayFE\n* @constructor\n* @type {Function}\n* @param {string} endianness - byte order\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} first argument must be a supported byte order\n* @throws {TypeError} if provided only two arguments, the second argument must be a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float64ArrayFE} typed array instance\n*\n* @example\n* var arr = new Float64ArrayFE( 'little-endian' );\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float64ArrayFE( 'little-endian', 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Float64ArrayFE( 'little-endian', [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayFE( 'little-endian', buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayFE( 'little-endian', buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayFE( 'little-endian', buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nvar Float64ArrayFE = factory( 'float64' );\n\n\n// EXPORTS //\n\nexport default Float64ArrayFE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n// Mapping from complex number constructors to data types...\nvar ctor2dtypes = {\n\t'Complex64': 'complex64',\n\t'Complex128': 'complex128'\n};\n\n\n// EXPORTS //\n\nexport default ctor2dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64 from './../../float32/ctor';\nimport Complex128 from './../../float64/ctor';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'complex64': Complex64,\n\t'complex128': Complex128\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a complex number constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'complex128' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'complex' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dtypes from './../../dtypes';\n\n\n// MAIN //\n\nvar DTYPES = dtypes();\n\n\n// EXPORTS //\n\nexport default DTYPES;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctors from './../../ctors';\nimport DTYPES from './dtypes.js';\n\n\n// MAIN //\n\nvar CTORS = [];\nvar i;\nfor ( i = 0; i < DTYPES.length; i++ ) {\n\tCTORS.push( ctors( DTYPES[ i ] ) );\n}\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport DTYPES from './dtypes.json';\n\n\n// MAIN //\n\n/**\n* Returns a list of complex number data types.\n*\n* @returns {StringArray} list of complex number data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'complex64', 'complex128' ]\n*/\nfunction dtypes() {\n\treturn DTYPES.slice();\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport constructorName from '@stdlib/utils/constructor-name';\nimport ctor2dtype from './ctor2dtype.js';\nimport CTORS from './ctors.js';\nimport DTYPES from './dtypes.js';\n\n\n// VARIABLES //\n\nvar NTYPES = DTYPES.length;\n\n\n// MAIN //\n\n/**\n* Returns the data type of a complex number.\n*\n* @param {*} value - input value\n* @returns {(string|null)} data type\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var dt = dtype( new Complex128( 1.0, 2.0 ) );\n* // returns 'complex128'\n*\n* var dt = dtype( 'beep' );\n* // returns null\n*/\nfunction dtype( value ) {\n\tvar i;\n\tfor ( i = 0; i < NTYPES; i++ ) {\n\t\tif ( value instanceof CTORS[ i ] ) {\n\t\t\treturn DTYPES[ i ];\n\t\t}\n\t}\n\t// If the above failed, fall back to a more robust (and significantly slower) means for resolving underlying data types:\n\treturn ctor2dtype[ constructorName( value ) ] || null;\n}\n\n\n// EXPORTS //\n\nexport default dtype;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport accessorSetter from './../../base/accessor-setter';\nimport setter from './../../base/setter';\nimport zeros from './../../zeros';\nimport dtype from '@stdlib/complex/dtype';\nimport defaults from './../../defaults';\n\n\n// VARIABLES //\n\nvar DEFAULT_REAL = defaults.get( 'dtypes.real_floating_point' );\nvar DEFAULT_CMPLX = defaults.get( 'dtypes.complex_floating_point' );\nvar DEFAULT_BOOL = defaults.get( 'dtypes.boolean' );\n\n\n// MAIN //\n\n/**\n* Returns a single-element array containing a provided scalar value.\n*\n* ## Notes\n*\n* - If a `dtype` option is not provided and `value`\n*\n* - is a number, the default data type is the default real-valued floating-point data type.\n* - is a boolean, the default data type is the default boolean data type.\n* - is a complex number object of a known complex data type, the data type is the same as the provided value.\n* - is a complex number object of an unknown complex data type, the default data type is the default complex-valued floating-point data type.\n* - is any other value type, the default data type is `'generic'`.\n*\n* @param {*} value - scalar value\n* @param {string} dtype - output array data type\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {Collection} output array\n*\n* @example\n* var x = scalar2array( 1.0 );\n* // returns [ 1.0 ]\n*\n* @example\n* var x = scalar2array( 1.0, 'float32' );\n* // returns [ 1.0 ]\n*/\nfunction scalar2array( value ) {\n\tvar flg;\n\tvar out;\n\tvar set;\n\tvar dt;\n\tvar v;\n\n\tflg = isNumber( value );\n\tif ( arguments.length < 2 ) {\n\t\tif ( flg ) {\n\t\t\tdt = DEFAULT_REAL;\n\t\t} else if ( isBoolean( value ) ) {\n\t\t\tdt = DEFAULT_BOOL;\n\t\t} else if ( isComplexLike( value ) ) {\n\t\t\tdt = dtype( value );\n\t\t\tif ( dt === null ) {\n\t\t\t\tdt = DEFAULT_CMPLX;\n\t\t\t}\n\t\t} else {\n\t\t\tdt = 'generic';\n\t\t}\n\t} else {\n\t\tdt = arguments[ 1 ];\n\t}\n\tout = zeros( 1, dt ); // delegate dtype validation to `zeros`\n\tif ( flg && isComplexDataType( dt ) ) {\n\t\tv = [ value, 0.0 ]; // note: we're assuming that the ComplexXXArray setter accepts an array of interleaved real and imaginary components\n\t} else {\n\t\tv = value;\n\t}\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tset( out, 0, v );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default scalar2array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport ctors from './../../ctors';\nimport afill from './../../base/filled';\nimport gfill from '@stdlib/blas/ext/base/gfill';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Creates a filled array having a specified length.\n*\n* @param {NonNegativeInteger} length - array length\n* @param {*} value - fill value\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} third argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = full( 2, 1.0 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = full( 2, 1.0, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*/\nfunction full( length, value ) {\n\tvar dtype;\n\tvar ctor;\n\tvar out;\n\tif ( !isNonNegativeInteger( length ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', length ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tdtype = arguments[ 2 ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tif ( dtype === 'generic' ) {\n\t\treturn afill( value, length );\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\tout = new ctor( length );\n\n\t// TODO: revisit the following, as using `gfill` is not the most performant, especially for large arrays. We have two options: (1) use a native add-on which delegates to an appropriate C function which performs the loop or (2) use @stdlib/blas/ext/base/(d|s|c|z)fill functions which use native add-ons. The latter option is not great, as we only get perf boosts for large arrays for a select number of dtypes. The former option is more work, as we may need to write a bespoke add-on for handling the argument signature and the various types that `value` can assume (e.g., number, complex, etc). If we had a generic strided `copy` package with an add-on, we could wrap the value as a single element strided array with a stride of `0` and copy from `x` to `y`, and thus would not need to write a bespoke add-on. Note, however, that calling into a native add-on is not free. For shorter arrays, we'll likely observe a perf hit in Node.js. For now, we focus on just getting something working...\n\tgfill( length, value, out, 1 );\n\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default full;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Dummy function.\n*\n* @private\n*/\nfunction foo() {\n\t// No-op...\n}\n\n\n// EXPORTS //\n\nexport default foo;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert/is-function';\nimport hasFunctionNameSupport from '@stdlib/assert/has-function-name-support';\nimport format from '@stdlib/string/format';\nimport { REGEXP as RE } from '@stdlib/regexp/function-name';\n\n\n// VARIABLES //\n\nvar isFunctionNameSupported = hasFunctionNameSupport();\n\n\n// MAIN //\n\n/**\n* Returns the name of a function.\n*\n* @param {Function} fcn - input function\n* @throws {TypeError} must provide a function\n* @returns {string} function name\n*\n* @example\n* var v = functionName( Math.sqrt );\n* // returns 'sqrt'\n*\n* @example\n* var v = functionName( function foo(){} );\n* // returns 'foo'\n*\n* @example\n* var v = functionName( function(){} );\n* // returns '' || 'anonymous'\n*\n* @example\n* var v = functionName( String );\n* // returns 'String'\n*/\nfunction functionName( fcn ) {\n\t// TODO: add support for generator functions?\n\tif ( isFunction( fcn ) === false ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a function. Value: `%s`.', fcn ) );\n\t}\n\tif ( isFunctionNameSupported ) {\n\t\treturn fcn.name;\n\t}\n\treturn RE.exec( fcn.toString() )[ 1 ];\n}\n\n\n// EXPORTS //\n\nexport default functionName;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport foo from './foo.js';\n\n\n// MAIN //\n\n/**\n* Tests for native function `name` support.\n*\n* @returns {boolean} boolean indicating if an environment has function `name` support\n*\n* @example\n* var bool = hasFunctionNameSupport();\n* // returns \n*/\nfunction hasFunctionNameSupport() {\n\treturn ( foo.name === 'foo' );\n}\n\n\n// EXPORTS //\n\nexport default hasFunctionNameSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Int8Array from '@stdlib/array/int8';\nimport Uint8Array from '@stdlib/array/uint8';\nimport Uint8ClampedArray from '@stdlib/array/uint8c';\nimport Int16Array from '@stdlib/array/int16';\nimport Uint16Array from '@stdlib/array/uint16';\nimport Int32Array from '@stdlib/array/int32';\nimport Uint32Array from '@stdlib/array/uint32';\nimport Float32Array from '@stdlib/array/float32';\nimport Float64Array from '@stdlib/array/float64';\n\n\n// MAIN //\n\nvar CTORS = [\n\tFloat64Array,\n\tFloat32Array,\n\tInt32Array,\n\tUint32Array,\n\tInt16Array,\n\tUint16Array,\n\tInt8Array,\n\tUint8Array,\n\tUint8ClampedArray\n];\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctorName from '@stdlib/utils/constructor-name';\nimport fcnName from '@stdlib/utils/function-name';\nimport getPrototypeOf from '@stdlib/utils/get-prototype-of';\nimport hasFloat64ArraySupport from './../../has-float64array-support';\nimport Float64Array from '@stdlib/array/float64';\nimport CTORS from './ctors.js';\nimport NAMES from './names.json';\n\n\n// VARIABLES //\n\n// Abstract `TypedArray` class:\nvar TypedArray = ( hasFloat64ArraySupport() ) ? getPrototypeOf( Float64Array ) : Dummy; // eslint-disable-line max-len\n\n// Ensure abstract typed array class has expected name:\nTypedArray = ( fcnName( TypedArray ) === 'TypedArray' ) ? TypedArray : Dummy;\n\n\n// FUNCTIONS //\n\n/**\n* Dummy constructor.\n*\n* @private\n*/\nfunction Dummy() {} // eslint-disable-line no-empty-function\n\n\n// MAIN //\n\n/**\n* Tests if a value is a typed array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a typed array\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var bool = isTypedArray( new Int8Array( 10 ) );\n* // returns true\n*/\nfunction isTypedArray( value ) {\n\tvar v;\n\tvar i;\n\n\tif ( typeof value !== 'object' || value === null ) {\n\t\treturn false;\n\t}\n\t// Check for the abstract class...\n\tif ( value instanceof TypedArray ) {\n\t\treturn true;\n\t}\n\t// Check for typed array objects from the same realm (same Node.js `vm` or same `Window` object)...\n\tfor ( i = 0; i < CTORS.length; i++ ) {\n\t\tif ( value instanceof CTORS[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\t// Walk the prototype tree until we find an object having a desired class...\n\twhile ( value ) {\n\t\tv = ctorName( value );\n\t\tfor ( i = 0; i < NAMES.length; i++ ) {\n\t\t\tif ( NAMES[ i ] === v ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tvalue = getPrototypeOf( value );\n\t}\n\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64Array from '@stdlib/array/complex64';\nimport Complex128Array from '@stdlib/array/complex128';\n\n\n// MAIN //\n\nvar CTORS = [\n\tComplex128Array,\n\tComplex64Array\n];\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport BooleanArray from '@stdlib/array/bool';\nimport constructorName from '@stdlib/utils/constructor-name';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a BooleanArray.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether a value is a BooleanArray\n*\n* @example\n* import BooleanArray from '@stdlib/array/bool';\n*\n* var bool = isBooleanArray( new BooleanArray( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isBooleanArray( [] );\n* // returns false\n*/\nfunction isBooleanArray( value ) {\n\treturn (\n\t\tvalue instanceof BooleanArray ||\n\t\tconstructorName( value ) === 'BooleanArray'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isBooleanArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Tests whether a value has in its prototype chain a specified constructor as a prototype property.\n*\n* @param {*} value - value to test\n* @param {Function} constructor - constructor to test against\n* @throws {TypeError} constructor must be callable\n* @returns {boolean} boolean indicating whether a value is an instance of a provided constructor\n*\n* @example\n* var bool = instanceOf( [], Array );\n* // returns true\n*\n* @example\n* var bool = instanceOf( {}, Object ); // exception\n* // returns true\n*\n* @example\n* var bool = instanceOf( 'beep', String );\n* // returns false\n*\n* @example\n* var bool = instanceOf( null, Object );\n* // returns false\n*\n* @example\n* var bool = instanceOf( 5, Object );\n* // returns false\n*/\nfunction instanceOf( value, constructor ) {\n\t// TODO: replace with `isCallable` check\n\tif ( typeof constructor !== 'function' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be callable. Value: `%s`.', constructor ) );\n\t}\n\treturn ( value instanceof constructor );\n}\n\n\n// EXPORTS //\n\nexport default instanceOf;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Int8Array from './../../int8';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Int16Array from './../../int16';\nimport Uint16Array from './../../uint16';\nimport Int32Array from './../../int32';\nimport Uint32Array from './../../uint32';\nimport Float32Array from './../../float32';\nimport Float64Array from './../../float64';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\nvar CTORS = [\n\t[ Float64Array, 'Float64Array' ],\n\t[ Float32Array, 'Float32Array' ],\n\t[ Int32Array, 'Int32Array' ],\n\t[ Uint32Array, 'Uint32Array' ],\n\t[ Int16Array, 'Int16Array' ],\n\t[ Uint16Array, 'Uint16Array' ],\n\t[ Int8Array, 'Int8Array' ],\n\t[ Uint8Array, 'Uint8Array' ],\n\t[ Uint8ClampedArray, 'Uint8ClampedArray' ],\n\t[ Complex64Array, 'Complex64Array' ],\n\t[ Complex128Array, 'Complex128Array' ],\n\t[ BooleanArray, 'BooleanArray' ]\n];\n\n\n// EXPORTS //\n\nexport default CTORS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport instanceOf from '@stdlib/assert/instance-of';\nimport ctorName from '@stdlib/utils/constructor-name';\nimport getPrototypeOf from '@stdlib/utils/get-prototype-of';\nimport CTORS from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns the typed array type.\n*\n* @private\n* @param {TypedArray} arr - typed array\n* @returns {(string|void)} typed array type\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( 5 );\n* var str = typeName( arr );\n* // returns 'Float64Array'\n*/\nfunction typeName( arr ) {\n\tvar v;\n\tvar i;\n\n\t// Check for typed array objects from the same realm (same Node.js `vm` or same `Window` object)...\n\tfor ( i = 0; i < CTORS.length; i++ ) {\n\t\tif ( instanceOf( arr, CTORS[ i ][ 0 ] ) ) {\n\t\t\treturn CTORS[ i ][ 1 ];\n\t\t}\n\t}\n\t// Walk the prototype tree until we find an object having a desired native class...\n\twhile ( arr ) {\n\t\tv = ctorName( arr );\n\t\tfor ( i = 0; i < CTORS.length; i++ ) {\n\t\t\tif ( v === CTORS[ i ][ 1 ] ) {\n\t\t\t\treturn CTORS[ i ][ 1 ];\n\t\t\t}\n\t\t}\n\t\tarr = getPrototypeOf( arr );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default typeName;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert/is-typed-array';\nimport isComplexTypedArray from '@stdlib/assert/is-complex-typed-array';\nimport isBooleanArray from '@stdlib/assert/is-booleanarray';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport format from '@stdlib/string/format';\nimport typeName from './type.js';\n\n\n// MAIN //\n\n/**\n* Returns a JSON representation of a typed array.\n*\n* ## Notes\n*\n* - We build a JSON object representing a typed array similar to how Node.js `Buffer` objects are represented. See [Buffer][1].\n*\n* [1]: https://nodejs.org/api/buffer.html#buffer_buf_tojson\n*\n* @param {TypedArray} arr - typed array to serialize\n* @throws {TypeError} first argument must be a typed array\n* @returns {Object} JSON representation\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var arr = new Float64Array( [ 5.0, 3.0 ] );\n* var json = typedarray2json( arr );\n* // returns { 'type': 'Float64Array', 'data': [ 5.0, 3.0 ] }\n*/\nfunction typedarray2json( arr ) {\n\tvar data;\n\tvar out;\n\tvar i;\n\n\tif ( isTypedArray( arr ) ) {\n\t\tdata = arr;\n\t} else if ( isComplexTypedArray( arr ) ) {\n\t\tif ( arr.BYTES_PER_ELEMENT === 8 ) {\n\t\t\tdata = reinterpret64( arr, 0 );\n\t\t} else { // arr.BYTES_PER_ELEMENT === 16\n\t\t\tdata = reinterpret128( arr, 0 );\n\t\t}\n\t} else if ( isBooleanArray( arr ) ) {\n\t\tdata = reinterpretBoolean( arr, 0 );\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a typed array. Value: `%s`.', arr ) );\n\t}\n\tout = {\n\t\t'type': typeName( arr ),\n\t\t'data': []\n\t};\n\tfor ( i = 0; i < data.length; i++ ) {\n\t\tout.data.push( data[ i ] );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default typedarray2json;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ctorName from '@stdlib/utils/constructor-name';\nimport getPrototypeOf from '@stdlib/utils/get-prototype-of';\nimport CTORS from './ctors.js';\nimport NAMES from './names.json';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a complex typed array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is a complex typed array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isComplexTypedArray( new Complex128Array( 10 ) );\n* // returns true\n*/\nfunction isComplexTypedArray( value ) {\n\tvar v;\n\tvar i;\n\n\tif ( typeof value !== 'object' || value === null ) {\n\t\treturn false;\n\t}\n\t// Check for complex typed array objects from the same realm (same Node.js `vm` or same `Window` object)...\n\tfor ( i = 0; i < CTORS.length; i++ ) {\n\t\tif ( value instanceof CTORS[ i ] ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\t// Walk the prototype tree until we find an object having a desired class...\n\twhile ( value ) {\n\t\tv = ctorName( value );\n\t\tfor ( i = 0; i < NAMES.length; i++ ) {\n\t\t\tif ( NAMES[ i ] === v ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tvalue = getPrototypeOf( value );\n\t}\n\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isComplexTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from '@stdlib/utils/define-property';\n\n\n// MAIN //\n\n/**\n* List node constructor.\n*\n* @private\n* @constructor\n* @param {*} value - node value\n* @returns {Node} Node instance\n*\n* @example\n* var node = new Node( 'foo' );\n* // returns \n*/\nfunction Node( value ) { // eslint-disable-line stdlib/no-redeclare\n\t// Why a getter? Because some of the list APIs will return the list \"node\", not the value. In which case, the node API is no longer private and we have to guard against users mucking about (deleting, updating, etc) with property values (in particular, the `next` property).\n\tdefineProperty( this, 'next', {\n\t\t'configurable': false,\n\t\t'enumerable': true,\n\t\t'get': function get() { // eslint-disable-line no-restricted-syntax\n\t\t\treturn this._next;\n\t\t}\n\t});\n\tthis.value = value;\n\n\tdefineProperty( this, '_next', {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'writable': true,\n\t\t'value': null\n\t});\n\n\t// NOTE: strictly speaking, we should not be keeping back-references in a singly-linked list; however, doing so allows us to more efficiently add, remove, and insert list values.\n\tdefineProperty( this, '_prev', {\n\t\t'configurable': false,\n\t\t'enumerable': false,\n\t\t'writable': true,\n\t\t'value': null\n\t});\n\n\treturn this;\n}\n\n\n// EXPORTS //\n\nexport default Node;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport Node from './node.js'; // eslint-disable-line stdlib/no-redeclare\n\n\n// MAIN //\n\n/**\n* Linked list constructor.\n*\n* @constructor\n* @returns {LinkedList} linked list instance\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Remove the last value:\n* var v = list.pop();\n* // returns 'bar'\n*\n* // Add a new value to the list:\n* list.push( 'beep' );\n*\n* // Remove the first value:\n* v = list.shift();\n* // returns 'foo'\n*/\nfunction LinkedList() {\n\tif ( !(this instanceof LinkedList) ) {\n\t\treturn new LinkedList();\n\t}\n\tthis._length = 0;\n\tthis._first = null;\n\tthis._last = null;\n\treturn this;\n}\n\n/**\n* Clears the list.\n*\n* @name clear\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {LinkedList} list instance\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Peek at the first value:\n* var v = list.first().value;\n* // returns 'foo'\n*\n* // Examine the list length:\n* var len = list.length;\n* // returns 2\n*\n* // Clear all list items:\n* list.clear();\n*\n* // Peek at the first value:\n* v = list.first();\n* // returns undefined\n*\n* // Examine the list length:\n* len = list.length;\n* // returns 0\n*/\nsetReadOnly( LinkedList.prototype, 'clear', function clear() {\n\tthis._length = 0;\n\tthis._first = null;\n\tthis._last = null;\n\treturn this;\n});\n\n/**\n* Returns the first list node.\n*\n* @name first\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {(Node|void)} list node\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Peek at the first value:\n* var v = list.first().value;\n* // returns 'foo'\n*/\nsetReadOnly( LinkedList.prototype, 'first', function first() {\n\tif ( this._length ) {\n\t\treturn this._first;\n\t}\n});\n\n/**\n* Inserts a value into the list **after** a provided list node.\n*\n* @name insert\n* @memberof LinkedList.prototype\n* @type {Function}\n* @param {Node} node - node after which to insert the value\n* @param {*} value - value to insert\n* @throws {Error} must provide a node belonging to the list\n* @returns {LinkedList} list instance\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' ).push( 'beep' );\n*\n* // Determine the list length:\n* var len = list.length;\n* // returns 3\n*\n* // Get the second node:\n* var node = list.first().next;\n*\n* // Insert a value after the second node:\n* list.insert( node, 'boop' );\n*\n* // Determine the list length:\n* len = list.length;\n* // returns 4\n*/\nsetReadOnly( LinkedList.prototype, 'insert', function insert( node, value ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar n;\n\n\t// Case: last node (equivalent to `push()`)\n\tif ( node === this._last ) {\n\t\treturn this.push( value );\n\t}\n\t// Unfortunately, we need to check whether we have been provided a node belonging to our list by walking the list. If we don't, we could erroneously increment the list length. This means our runtime goes from the theoretical O(1) to O(N).\n\tn = this._first;\n\twhile ( n !== this._last && n !== node ) {\n\t\tn = n._next;\n\t}\n\t// Check if we iterated through the entire list:\n\tif ( n === this._last ) {\n\t\tthrow new Error( 'invalid argument. The list does not contain the provided list node.' );\n\t}\n\t// Create a new list node:\n\tn = new Node( value );\n\n\t// Update pointers:\n\tnode._next._prev = n;\n\tn._next = node._next;\n\n\tnode._next = n;\n\tn._prev = node;\n\n\t// Increment the list length:\n\tthis._length += 1;\n\n\treturn this;\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Returns an iterator for iterating over a list.\n*\n* ## Notes\n*\n* - In order to prevent confusion arising from list mutation during iteration, a returned iterator **always** iterates over a list \"snapshot\", which is defined as the list of elements at the time of this method's invocation.\n*\n* @name iterator\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {Iterator} iterator\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Create an iterator:\n* var it = list.iterator();\n*\n* // Iterate over the list...\n* var v = it.next().value;\n* // returns 'foo'\n*\n* v = it.next().value;\n* // returns 'bar'\n*\n* var bool = it.next().done;\n* // returns true\n*/\nsetReadOnly( LinkedList.prototype, 'iterator', function iterator() {\n\tvar values;\n\tvar iter;\n\tvar self;\n\tvar FLG;\n\tvar i;\n\n\tself = this;\n\n\t// Initialize the iteration index:\n\ti = -1;\n\n\t// Create a copy of list values (necessary in order to \"snapshot\" the list; otherwise, values could come and go between calls to `next`):\n\tvalues = this.toArray();\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tsetReadOnly( iter, 'next', next );\n\tsetReadOnly( iter, 'return', end );\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next() {\n\t\ti += 1;\n\t\tif ( FLG || i >= values.length ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': values[ i ],\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\treturn self.iterator();\n\t}\n});\n\n/**\n* Returns the last node.\n*\n* @name last\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {(Node|void)} list node\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Peek at the last value:\n* var v = list.last().value;\n* // returns 'bar'\n*/\nsetReadOnly( LinkedList.prototype, 'last', function last() {\n\tif ( this._length ) {\n\t\treturn this._last;\n\t}\n});\n\n/**\n* List length.\n*\n* @name length\n* @memberof LinkedList.prototype\n* @type {NonNegativeInteger}\n*\n* @example\n* var list = new LinkedList();\n*\n* // Examine the initial list length:\n* var len = list.length;\n* // returns 0\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Retrieve the current list length:\n* len = list.length;\n* // returns 2\n*/\nsetReadOnlyAccessor( LinkedList.prototype, 'length', function get() {\n\treturn this._length;\n});\n\n/**\n* Removes a value from the end of the list.\n*\n* @name pop\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {(*|void)} removed value\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Remove the last value:\n* var v = list.pop();\n* // returns 'bar'\n*\n* // Add a new value to the list:\n* list.push( 'beep' );\n*\n* // Remove the last value:\n* v = list.pop();\n* // returns 'beep'\n*/\nsetReadOnly( LinkedList.prototype, 'pop', function pop() {\n\t/* eslint-disable no-underscore-dangle */\n\tvar value;\n\tif ( this._length ) {\n\t\t// Retrieve the last value:\n\t\tvalue = this._last.value;\n\n\t\t// Check whether we have a new \"tail\" or whether we have emptied the list...\n\t\tif ( this._last._prev ) {\n\t\t\tthis._last = this._last._prev;\n\t\t\tthis._last._next = null;\n\t\t} else {\n\t\t\t// List is empty:\n\t\t\tthis._first = null;\n\t\t\tthis._last = null;\n\t\t}\n\t\t// Decrement the list length:\n\t\tthis._length -= 1;\n\t}\n\treturn value;\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Adds a value to the end of the list.\n*\n* @name push\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {LinkedList} list instance\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Remove the last value:\n* var v = list.pop();\n* // returns 'bar'\n*\n* // Add a new value to the list:\n* list.push( 'beep' );\n*\n* // Remove the last value:\n* v = list.pop();\n* // returns 'beep'\n*/\nsetReadOnly( LinkedList.prototype, 'push', function push( value ) {\n\tvar node;\n\n\t// Create a new list node:\n\tnode = new Node( value );\n\n\t// Check whether the list is currently empty...\n\tif ( this._length === 0 ) {\n\t\t// This is the only list node, making it both the first and last node:\n\t\tthis._first = node;\n\t\tthis._last = node;\n\t} else {\n\t\t// Link the new node to the previous last node:\n\t\tnode._prev = this._last; // eslint-disable-line no-underscore-dangle\n\n\t\t// Link the previous last node to the new node:\n\t\tthis._last._next = node; // eslint-disable-line no-underscore-dangle\n\n\t\t// Update the pointer for the last node:\n\t\tthis._last = node;\n\t}\n\t// Increment the list length:\n\tthis._length += 1;\n\n\treturn this;\n});\n\n/**\n* Removes a list node from the list.\n*\n* @name remove\n* @memberof LinkedList.prototype\n* @type {Function}\n* @param {Node} node - node to remove\n* @throws {Error} must provide a node belonging to the list\n* @returns {(*|void)} removed value\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' ).push( 'beep' );\n*\n* // Determine the list length:\n* var len = list.length;\n* // returns 3\n*\n* // Get the second node:\n* var node = list.first().next;\n*\n* // Remove the second node:\n* var v = list.remove( node );\n* // returns 'bar'\n*\n* // Determine the list length:\n* len = list.length;\n* // returns 2\n*/\nsetReadOnly( LinkedList.prototype, 'remove', function remove( node ) {\n\t/* eslint-disable no-underscore-dangle */\n\tvar value;\n\tvar n;\n\n\t// Case: first node (equivalent to `shift()`)\n\tif ( node === this._first ) {\n\t\treturn this.shift();\n\t}\n\t// Case: last node (equivalent to `pop()`)\n\tif ( node === this._last ) {\n\t\treturn this.pop();\n\t}\n\t// Retrieve the node value:\n\tvalue = node.value;\n\n\t// Unfortunately, we need to check whether we have been provided a node belonging to our list by walking the list. If we don't, we could erroneously decrement the list length. This means our runtime goes from the theoretical O(1) to O(N).\n\tn = this._first;\n\twhile ( n !== this._last && n !== node ) {\n\t\tn = n._next;\n\t}\n\t// Check if we iterated through the entire list:\n\tif ( n === this._last ) {\n\t\tthrow new Error( 'invalid argument. The list does not contain the provided list node.' );\n\t}\n\t// Update pointers:\n\tnode._prev._next = node._next;\n\tnode._next._prev = node._prev;\n\n\t// Decrement the list length:\n\tthis._length -= 1;\n\n\treturn value;\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Removes a value from the beginning of the list.\n*\n* @name shift\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {(*|void)} removed value\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Remove the first value:\n* var v = list.shift();\n* // returns 'foo'\n*\n* // Add a new value to the list:\n* list.push( 'beep' );\n*\n* // Remove the first value:\n* v = list.shift();\n* // returns 'bar'\n*/\nsetReadOnly( LinkedList.prototype, 'shift', function shift() {\n\t/* eslint-disable no-underscore-dangle */\n\tvar value;\n\tif ( this._length ) {\n\t\t// Retrieve the first value:\n\t\tvalue = this._first.value;\n\n\t\t// Check whether we have a new \"head\" or whether we have emptied the list...\n\t\tif ( this._first._next ) {\n\t\t\tthis._first = this._first._next;\n\t\t\tthis._first._prev = null;\n\t\t} else {\n\t\t\t// List is empty:\n\t\t\tthis._first = null;\n\t\t\tthis._last = null;\n\t\t}\n\t\t// Decrement the list length:\n\t\tthis._length -= 1;\n\t}\n\treturn value;\n\n\t/* eslint-enable no-underscore-dangle */\n});\n\n/**\n* Returns an array of list values.\n*\n* @name toArray\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {Array} list values\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Get an array of list values:\n* var vals = list.toArray();\n* // returns [ 'foo', 'bar' ]\n*/\nsetReadOnly( LinkedList.prototype, 'toArray', function toArray() {\n\tvar node;\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tnode = this._first;\n\tfor ( i = 0; i < this._length; i++ ) {\n\t\tout.push( node.value );\n\t\tnode = node.next;\n\t}\n\treturn out;\n});\n\n/**\n* Serializes a list as JSON.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying a `LinkedList` instance.\n*\n* @name toJSON\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {Object} serialized list\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the list:\n* list.push( 'foo' ).push( 'bar' );\n*\n* // Serialize to JSON:\n* var o = list.toJSON();\n* // returns { 'type': 'linked-list', 'data': [ 'foo', 'bar' ] }\n*/\nsetReadOnly( LinkedList.prototype, 'toJSON', function toJSON() {\n\tvar out = {};\n\tout.type = 'linked-list';\n\tout.data = this.toArray();\n\treturn out;\n});\n\n/**\n* Adds a value to the beginning of the list.\n*\n* @name unshift\n* @memberof LinkedList.prototype\n* @type {Function}\n* @returns {LinkedList} list instance\n*\n* @example\n* var list = new LinkedList();\n*\n* // Add values to the beginning of the list:\n* list.unshift( 'foo' ).unshift( 'bar' );\n*\n* // Remove the last value:\n* var v = list.pop();\n* // returns 'foo'\n*\n* // Add a new value to the beginning of the list:\n* list.unshift( 'beep' );\n*\n* // Remove the last value:\n* v = list.pop();\n* // returns 'bar'\n*/\nsetReadOnly( LinkedList.prototype, 'unshift', function unshift( value ) {\n\tvar node;\n\n\t// Create a new list node:\n\tnode = new Node( value );\n\n\t// Check whether the list is currently empty...\n\tif ( this._length === 0 ) {\n\t\t// This is the only list node, making it both the first and last node:\n\t\tthis._first = node;\n\t\tthis._last = node;\n\t} else {\n\t\t// Link the new node to the previous first node:\n\t\tnode._next = this._first; // eslint-disable-line no-underscore-dangle\n\n\t\t// Link the previous first node to the new node:\n\t\tthis._first._prev = node; // eslint-disable-line no-underscore-dangle\n\n\t\t// Update the pointer for the first node:\n\t\tthis._first = node;\n\t}\n\t// Increment the list length:\n\tthis._length += 1;\n\n\treturn this;\n});\n\n\n// EXPORTS //\n\nexport default LinkedList;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport LinkedList from '@stdlib/dstructs/linked-list';\n\n\n// MAIN //\n\n/**\n* Cache for storing index arrays.\n*\n* @private\n* @name cache\n* @type {LinkedList}\n*/\nvar cache = new LinkedList(); // note: created as a linked list to allow for more efficient removal of expired index arrays\n\n\n// EXPORTS //\n\nexport default cache;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport cache from './cache.js';\n\n\n// MAIN //\n\n/**\n* Returns an array index object associated with a specified identifier.\n*\n* @private\n* @param {*} id - identifier\n* @returns {(Node|null)} array index object\n*/\nfunction find( id ) { // eslint-disable-line stdlib/no-redeclare\n\tvar node = cache.first();\n\twhile ( node ) {\n\t\tif ( node.value.id === id ) {\n\t\t\treturn node;\n\t\t}\n\t\tnode = node.next;\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default find;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar COUNTER = -1; // TODO: consider another approach for unique identifier generation. For most cases, this should suffice; however, it is possible that two different libraries, both relying on separate copies of this package, may trigger id collisions in the event that instantiated instances were to interact (e.g., a consumer attempting to free an instance instantiated by another copy of the package, etc).\n\n\n// MAIN //\n\n/**\n* Generates a new identifier.\n*\n* @private\n* @returns {string} identifier\n*\n* @example\n* var v = id();\n* // returns \n*/\nfunction id() {\n\tCOUNTER += 1;\n\treturn COUNTER.toString();\n}\n\n\n// EXPORTS //\n\nexport default id;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setNonEnumerable from '@stdlib/utils/define-nonenumerable-property';\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport array2json from './../../to-json';\nimport dtype from './../../dtype';\nimport copy from './../../base/copy';\nimport resolveGetter from './../../base/resolve-getter';\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\nimport cache from './cache.js';\nimport findArrayIndex from './find.js';\nimport generateId from './id.js';\n\n\n// MAIN //\n\n/**\n* Array index constructor.\n*\n* @constructor\n* @param {Collection} x - input array\n* @param {Options} [options] - function options\n* @param {boolean} [options.persist=false] - boolean indicating whether to continue persisting an index object after first usage\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} first argument must be a valid index array\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayIndex} ArrayIndex instance\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var x = new Uint8Array( [ 1, 0, 1, 0 ] );\n*\n* var idx = new ArrayIndex( x );\n* // returns \n*/\nfunction ArrayIndex( x ) {\n\tvar opts;\n\tvar err;\n\tvar get;\n\tvar dt;\n\tvar t;\n\tvar v;\n\tif ( !(this instanceof ArrayIndex) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new ArrayIndex( x, arguments[ 1 ] );\n\t\t}\n\t\treturn new ArrayIndex( x );\n\t}\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tdt = dtype( x );\n\n\t// When provided a \"generic\" array or an array of an unknown data type, attempt to infer the type of index array...\n\tif ( dt === 'generic' || dt === null ) {\n\t\tif ( x.length > 0 ) {\n\t\t\tget = resolveGetter( x );\n\t\t\tv = get( x, 0 );\n\n\t\t\t// Infer the \"type\" of index array from the first element...\n\t\t\tif ( isBoolean( v ) ) {\n\t\t\t\tt = 'bool';\n\t\t\t} else if ( isInteger( v ) ) {\n\t\t\t\tt = 'int';\n\t\t\t} else {\n\t\t\t\tthrow new TypeError( 'invalid argument. First argument must be a valid index array.' );\n\t\t\t}\n\t\t} else {\n\t\t\tt = 'int';\n\t\t}\n\t} else if ( dt === 'int32' ) {\n\t\tt = 'int';\n\t} else if ( dt === 'uint8' ) {\n\t\tt = 'mask';\n\t} else if ( dt === 'bool' ) {\n\t\tt = 'bool';\n\t} else {\n\t\tthrow new TypeError( 'invalid argument. First argument must be a valid index array.' );\n\t}\n\t// Resolve index options:\n\topts = defaults();\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, arguments[ 1 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Add the array index to the index cache:\n\tcache.push({\n\t\t'id': generateId(),\n\t\t'ref': this,\n\t\t'data': x,\n\t\t'type': t,\n\t\t'dtype': dt,\n\t\t'persist': opts.persist\n\t});\n\n\t// Store a reference to the cache node:\n\tsetReadOnly( this, '_node', cache.last() );\n\n\t// Initialize a boolean flag indicating whether an array index object has been invalidated (i.e., freed):\n\tsetNonEnumerable( this, '_invalidated', false );\n\n\treturn this;\n}\n\n/**\n* Constructor name.\n*\n* @name name\n* @memberof ArrayIndex\n* @readonly\n* @type {string}\n* @default 'ArrayIndex'\n*\n* @example\n* var str = ArrayIndex.name;\n* // returns 'ArrayIndex'\n*/\nsetReadOnly( ArrayIndex, 'name', 'ArrayIndex' );\n\n/**\n* Frees an array index object associated with a provided identifier.\n*\n* @name free\n* @memberof ArrayIndex\n* @type {Function}\n* @param {string} id - identifier\n* @returns {boolean} boolean indicating whether an array index object was successfully freed\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), {\n* 'persist': true\n* });\n* // returns \n*\n* // ...\n*\n* var out = ArrayIndex.free( idx.id );\n* // returns true\n*/\nsetReadOnly( ArrayIndex, 'free', function free( id ) {\n\tvar node;\n\tvar v;\n\n\t// Retrieve the array index object with the specified identifier:\n\tnode = findArrayIndex( id );\n\tif ( node === null ) {\n\t\treturn false;\n\t}\n\tv = node.value;\n\n\t// Invalidate the array instance object:\n\tsetReadOnly( v.ref, '_invalidated', true );\n\n\t// Remove the array instance from the cache:\n\tcache.remove( node );\n\n\t// Remove the reference to the original array:\n\tv.data = null;\n\n\treturn true;\n});\n\n/**\n* Returns the array associated with a provided identifier.\n*\n* @name get\n* @memberof ArrayIndex\n* @type {Function}\n* @param {string} id - identifier\n* @returns {(Object|null)} object containing array index data\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), {\n* 'persist': true\n* });\n* // returns \n*\n* // ...\n*\n* var o = ArrayIndex.get( idx.id );\n* // returns {...}\n*\n* var d = o.data;\n* // returns [ 1, 0, 1, 0 ]\n*\n* var t = o.type;\n* // returns 'mask'\n*\n* var dt = o.dtype;\n* // returns 'uint8'\n*/\nsetReadOnly( ArrayIndex, 'get', function get( id ) {\n\tvar node;\n\tvar out;\n\tvar v;\n\n\t// Retrieve the array index object with the specified identifier:\n\tnode = findArrayIndex( id );\n\tif ( node === null ) {\n\t\treturn null;\n\t}\n\tv = node.value;\n\n\t// Assemble the output object:\n\tout = {\n\t\t'data': v.data,\n\t\t'type': v.type,\n\t\t'dtype': v.dtype\n\t};\n\n\t// If the array index object should not be persisted, go ahead and remove the object from the cache...\n\tif ( !v.persist ) {\n\t\tArrayIndex.free( id ); // note: this should come last, after having retrieved all desired array index node data\n\t}\n\treturn out;\n});\n\n/**\n* Returns the underlying array data of an array index object.\n*\n* @name data\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {Collection}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var v = idx.data;\n* // returns [ 1, 0, 1, 0 ]\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'data', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.data;\n});\n\n/**\n* Returns the underlying array data type of an array index object.\n*\n* @name dtype\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var t = idx.dtype;\n* // returns 'uint8'\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'dtype', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.dtype;\n});\n\n/**\n* Returns the identifier associated with an array index object.\n*\n* @name id\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var id = idx.id;\n* // returns \n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'id', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.id;\n});\n\n/**\n* Returns a boolean indicating if an array index is actively cached.\n*\n* @name isCached\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {boolean}\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var out = idx.isCached;\n* // returns true\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'isCached', function get() {\n\treturn !this._invalidated;\n});\n\n/**\n* Returns the type of an array index object.\n*\n* @name type\n* @memberof ArrayIndex.prototype\n* @readonly\n* @type {string}\n* @throws {Error} array index is no longer valid\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var t = idx.type;\n* // returns 'mask'\n*/\nsetReadOnlyAccessor( ArrayIndex.prototype, 'type', function get() {\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\treturn this._node.value.type;\n});\n\n/**\n* Serializes an array index object to a string.\n*\n* @name toString\n* @memberof ArrayIndex.prototype\n* @type {Function}\n* @throws {Error} array index is no longer valid\n* @returns {string} serialized array index object\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var str = idx.toString();\n* // e.g., 'ArrayIndex<0>'\n*/\nsetReadOnly( ArrayIndex.prototype, 'toString', function toString() {\n\tvar v;\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\tv = this._node.value;\n\treturn 'ArrayIndex<' + v.id + '>';\n});\n\n/**\n* Serializes an array index object as a JSON object.\n*\n* ## Notes\n*\n* - `JSON.stringify()` implicitly calls this method when stringifying an `ArrayIndex` instance.\n*\n* @name toJSON\n* @memberof ArrayIndex.prototype\n* @type {Function}\n* @throws {Error} array index is no longer valid\n* @returns {Object} serialized array index object\n*\n* @example\n* import Uint8Array from '@stdlib/array/uint8';\n*\n* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) );\n* // returns \n*\n* var o = idx.toJSON();\n* // returns { 'type': 'ArrayIndex', 'data': { 'type': 'Uint8Array', 'data': [ 1, 0, 1, 0 ] } }\n*/\nsetReadOnly( ArrayIndex.prototype, 'toJSON', function toJSON() {\n\tvar v;\n\tvar o;\n\tif ( this._invalidated ) {\n\t\tthrow new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' );\n\t}\n\tv = this._node.value;\n\tif ( v.dtype === 'generic' || v.dtype === null ) {\n\t\tif ( isAccessorArray( v.data ) ) {\n\t\t\to = copy( v.data );\n\t\t} else {\n\t\t\to = v.data;\n\t\t}\n\t} else {\n\t\to = array2json( v.data );\n\t}\n\treturn {\n\t\t'type': 'ArrayIndex',\n\t\t'data': o\n\t};\n});\n\n\n// EXPORTS //\n\nexport default ArrayIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} defaults\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'persist': false\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {boolean} [options.persist] - boolean indicating whether to continue persisting an index object after first usage\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'persist': false\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'persist' ) ) {\n\t\topts.persist = options.persist;\n\t\tif ( !isBoolean( opts.persist ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'persist', opts.persist ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Complex128Array from './../../complex128';\nimport Complex64Array from './../../complex64';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'float64': Float64Array,\n\t'float32': Float32Array,\n\t'complex128': Complex128Array,\n\t'complex64': Complex64Array\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a floating-point typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array.\n*\n* @private\n* @param {TypedArray} out - output array\n* @param {number} start - start of interval\n* @param {number} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {TypedArray} linearly spaced array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var out = new Float64Array( 6 );\n* var arr = linspace( out, 0, 100, out.length, true );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var out = new Float64Array( 5 );\n* var arr = linspace( out, 0, 100, out.length, false );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*/\nfunction linspace( out, start, stop, len, endpoint ) {\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tout[ 0 ] = stop;\n\t\t} else {\n\t\t\tout[ 0 ] = start;\n\t\t}\n\t\treturn out;\n\t}\n\tout[ 0 ] = start;\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tout[ i ] = start + (d*i);\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tout[ N ] = stop;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number sequence over a specified interval and assigns the results to a provided output array strided view.\n*\n* @private\n* @param {(Float32Array|Float64Array)} out - output array strided view\n* @param {string} dt1 - start value data type\n* @param {(number|ComplexLike)} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {(Float32Array|Float64Array)} complex number array view\n*/\nfunction linspace( out, dt1, start, dt2, stop, len, endpoint ) {\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\tvar j;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tout[ 0 ] = re2;\n\t\t\tout[ 1 ] = im2;\n\t\t} else {\n\t\t\tout[ 0 ] = re1;\n\t\t\tout[ 1 ] = im1;\n\t\t}\n\t\treturn out;\n\t}\n\tout[ 0 ] = re1;\n\tout[ 1 ] = im1;\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate linearly spaced complex numbers:\n\tj = 2;\n\tfor ( i = 1; i < N; i++ ) {\n\t\tout[ j ] = re1 + (dr*i);\n\t\tout[ j+1 ] = im1 + (di*i);\n\t\tj += 2;\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tout[ j ] = re2;\n\t\tout[ j+1 ] = im2;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.dtype] - output array data type\n* @param {boolean} [options.endpoint] - boolean indicating whether the `stop` value in the output array\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'endpoint': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\topts.dtype = options.dtype;\n\t\tif ( !isString( opts.dtype ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'dtype', opts.dtype ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'endpoint' ) ) {\n\t\topts.endpoint = options.endpoint;\n\t\tif ( !isBoolean( opts.endpoint ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'endpoint', opts.endpoint ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport dtype from '@stdlib/complex/dtype';\nimport ctors from './../../typed-float-ctors';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport DEFAULTS from './../../defaults';\nimport format from '@stdlib/string/format';\nimport genreal from './generic_real.js';\nimport gencmplx from './generic_complex.js';\nimport typedreal from './typed_real.js';\nimport typedcmplx from './typed_complex.js';\nimport validate from './validate.js';\nimport defaults from './defaults.json';\n\n\n// VARIABLES //\n\nvar DEFAULT_COMPLEX_DTYPE = DEFAULTS.get( 'dtypes.complex_floating_point' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced array over a specified interval.\n*\n* @param {(number|ComplexLike)} start - start of interval\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {Options} [options] - options\n* @param {string} [options.dtype] - output array data type\n* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array\n* @throws {TypeError} first argument must be either a real or complex number\n* @throws {TypeError} second argument must be either a real or complex number\n* @throws {TypeError} third argument must be a nonnegative integer\n* @throws {TypeError} last argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} the output array data type must be a complex number data type or \"generic\" when either `start` or `stop` is a complex number\n* @throws {TypeError} the output array data type must be a real or complex floating-point number data type or \"generic\"\n* @returns {(Array|TypedArray|ComplexArray)} linearly spaced array\n*\n* @example\n* var arr = linspace( 0, 100, 6, {\n* 'dtype': 'generic'\n* });\n* // returns [ 0, 20, 40, 60, 80, 100 ]\n*/\nfunction linspace( start, stop, len ) {\n\tvar opts;\n\tvar ctor;\n\tvar err;\n\tvar out;\n\tvar dt1;\n\tvar dt2;\n\tvar flg;\n\n\tif ( typeof start === 'object' ) {\n\t\tdt1 = dtype( start );\n\t\tif ( dt1 === null ) {\n\t\t\tif ( !isComplexLike( start ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t\t\t}\n\t\t\tdt1 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( start ) || isnan( start ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t} else {\n\t\tdt1 = 'float64';\n\t}\n\tif ( typeof stop === 'object' ) {\n\t\tdt2 = dtype( stop );\n\t\tif ( dt2 === null ) {\n\t\t\tif ( !isComplexLike( stop ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t\t\t}\n\t\t\tdt2 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( stop ) || isnan( stop ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t} else {\n\t\tdt2 = 'float64';\n\t}\n\tif ( !isNonNegativeInteger( len ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%s`.', len ) );\n\t}\n\topts = {\n\t\t'endpoint': defaults.endpoint\n\t};\n\tif ( dt1 === dt2 ) {\n\t\topts.dtype = dt1; // one of 'float64' || 'complex64' || 'complex128'\n\t} else {\n\t\t// If dtypes are different, then at least one is a complex number. According to type promotion rules, for all possible dtype permutations, the default output data type should be 'complex128'...\n\t\topts.dtype = DEFAULT_COMPLEX_DTYPE;\n\t}\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tif ( opts.dtype === 'generic' ) {\n\t\tif ( flg ) {\n\t\t\treturn gencmplx( dt1, start, dt2, stop, len, opts.endpoint );\n\t\t}\n\t\treturn genreal( start, stop, len, opts.endpoint );\n\t}\n\tctor = ctors( opts.dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a real or complex floating-point data type or \"generic\". Option: `%s`.', 'dtype', opts.dtype ) );\n\t}\n\tout = new ctor( len );\n\tif ( opts.dtype === 'complex64' ) {\n\t\ttypedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( opts.dtype === 'complex128' ) {\n\t\ttypedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( flg ) {\n\t\tthrow new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array data type must be a complex number data type or \"generic\".' );\n\t}\n\treturn typedreal( out, start, stop, len, opts.endpoint );\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number array over a specified interval.\n*\n* @private\n* @param {string} dt1 - start value data type\n* @param {(number|ComplexLike)} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Array} linearly spaced array\n*/\nfunction linspace( dt1, start, dt2, stop, len, endpoint ) {\n\tvar cmplx;\n\tvar isf32;\n\tvar arr;\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar re;\n\tvar im;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\tisf32 = 0;\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Determine which complex number constructor to use according to type promotion rules:\n\tif ( isf32 === 2 ) {\n\t\tcmplx = Complex64;\n\t} else {\n\t\tcmplx = Complex128;\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\treturn [ new cmplx( re2, im2 ) ];\n\t\t}\n\t\treturn [ new cmplx( re1, im1 ) ];\n\t}\n\tarr = [ new cmplx( re1, im1 ) ];\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tre = re1 + (dr*i);\n\t\tim = im1 + (di*i);\n\t\tarr.push( new cmplx( re, im ) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tarr.push( new cmplx( re2, im2 ) );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced array over a specified interval.\n*\n* @private\n* @param {number} start - start of interval\n* @param {number} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Array} linearly spaced array\n*\n* @example\n* var arr = linspace( 0, 100, 6, true );\n* // returns [ 0, 20, 40, 60, 80, 100 ]\n*\n* @example\n* var arr = linspace( 0, 100, 5, false );\n* // returns [ 0, 20, 40, 60, 80 ]\n*/\nfunction linspace( start, stop, len, endpoint ) {\n\tvar arr;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn [];\n\t}\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\treturn [ stop ];\n\t\t}\n\t\treturn [ start ];\n\t}\n\tarr = [ start ];\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tarr.push( start + (d*i) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tarr.push( stop );\n\t}\n\treturn arr;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Tests that a value is a valid constructor.\n*\n* @private\n* @param {*} value - value to test\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var ctor = function ctor() {};\n*\n* var err = validate( ctor );\n* // returns null\n*\n* err = validate( null );\n* // returns \n*/\nfunction validate( value ) {\n\tvar type = typeof value;\n\tif (\n\t\tvalue === null ||\n\t\t(type !== 'object' && type !== 'function')\n\t) {\n\t\treturn new TypeError( format( 'invalid argument. A provided constructor must be either an object (except null) or a function. Value: `%s`.', value ) );\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Generate a linearly spaced array.\n*\n* @module @stdlib/array/linspace\n*\n* @example\n* import linspace from '@stdlib/array/linspace';\n*\n* var arr = linspace( 0, 100, 6 );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* @example\n* import linspace from '@stdlib/array/linspace';\n*\n* var arr = linspace( 0, 100, 5, {\n* 'endpoint': false\n* });\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import linspace from '@stdlib/array/linspace';\n*\n* var arr = new Float64Array( 6 );\n* var out = linspace.assign( 0, 100, out );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n* import linspace from '@stdlib/array/linspace';\n*\n* var arr = new Float64Array( 5 );\n* var out = linspace.assign( 0, 100, out, {\n* 'endpoint': false\n* });\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ]\n*\n* var bool = ( arr === out );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport isCollection from '@stdlib/assert/is-collection';\nimport format from '@stdlib/string/format';\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport dtype from '@stdlib/complex/dtype';\nimport adtype from './../../dtype';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport arraylike2object from './../../base/arraylike2object';\nimport acccmplx from './accessors_complex.js';\nimport accreal from './accessors_real.js';\nimport typedcmplx from './typed_complex.js';\nimport typedreal from './typed_real.js';\nimport validate from './validate.js';\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array.\n*\n* @param {(number|ComplexLike)} start - start of interval\n* @param {(number|ComplexLike)} stop - end of interval\n* @param {Collection} out - output array\n* @param {Options} [options] - options\n* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array\n* @throws {TypeError} first argument must be either a real or complex number\n* @throws {TypeError} second argument must be either a real or complex number\n* @throws {TypeError} third argument must be an array-like object\n* @throws {TypeError} last argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} the output array data type must be a complex number data type or \"generic\" when either `start` or `stop` is a complex number\n* @returns {Collection} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var out = new Float64Array( 6 );\n* var arr = linspace( 0, 100, out );\n* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ]\n*/\nfunction linspace( start, stop, out ) {\n\tvar opts;\n\tvar err;\n\tvar dt1;\n\tvar dt2;\n\tvar flg;\n\tvar odt;\n\tvar o;\n\n\tif ( typeof start === 'object' ) {\n\t\tdt1 = dtype( start );\n\t\tif ( dt1 === null ) {\n\t\t\tif ( !isComplexLike( start ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t\t\t}\n\t\t\tdt1 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( start ) || isnan( start ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) );\n\t} else {\n\t\tdt1 = 'float64';\n\t}\n\tif ( typeof stop === 'object' ) {\n\t\tdt2 = dtype( stop );\n\t\tif ( dt2 === null ) {\n\t\t\tif ( !isComplexLike( stop ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t\t\t}\n\t\t\tdt2 = 'complex128';\n\t\t}\n\t\tflg = true;\n\t} else if ( !isNumber( stop ) || isnan( stop ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) );\n\t} else {\n\t\tdt2 = 'float64';\n\t}\n\tif ( !isCollection( out ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', out ) );\n\t}\n\topts = {\n\t\t'endpoint': defaults.endpoint\n\t};\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\todt = adtype( out );\n\tif ( odt === null ) {\n\t\todt = 'generic';\n\t}\n\tif ( odt === 'complex64' ) {\n\t\ttypedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( odt === 'complex128' ) {\n\t\ttypedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len\n\t\treturn out;\n\t}\n\tif ( flg ) {\n\t\tif ( odt === 'generic' ) {\n\t\t\to = arraylike2object( out );\n\t\t\tacccmplx( o, dt1, start, dt2, stop, out.length, opts.endpoint );\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array must be a complex number array or a \"generic\" array-like object.' );\n\t}\n\to = arraylike2object( out );\n\tif ( o.accessorProtocol ) {\n\t\taccreal( o, start, stop, out.length, opts.endpoint );\n\t\treturn out;\n\t}\n\ttypedreal( out, start, stop, out.length, opts.endpoint );\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport real from '@stdlib/complex/float64/real';\nimport imag from '@stdlib/complex/float64/imag';\nimport realf from '@stdlib/complex/float32/real';\nimport imagf from '@stdlib/complex/float32/imag';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced complex number sequence over a specified interval and assigns results to a provided output array.\n*\n* @private\n* @param {Object} out - output array object\n* @param {ArrayLikeObject} out.data - output array data\n* @param {Array} out.accessors - array element accessors\n* @param {string} dt1 - start value data type\n* @param {ComplexLike} start - start of interval\n* @param {string} dt2 - stop value data type\n* @param {ComplexLike} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Object} output array object\n*/\nfunction linspace( out, dt1, start, dt2, stop, len, endpoint ) {\n\tvar cmplx;\n\tvar isf32;\n\tvar re1;\n\tvar re2;\n\tvar im1;\n\tvar im2;\n\tvar set;\n\tvar buf;\n\tvar re;\n\tvar im;\n\tvar dr;\n\tvar di;\n\tvar N;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\tisf32 = 0;\n\tif ( dt1 === 'float64' ) {\n\t\tre1 = start;\n\t\tim1 = 0.0;\n\t} else if ( dt1 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre1 = realf( start );\n\t\tim1 = imagf( start );\n\t} else {\n\t\tre1 = real( start );\n\t\tim1 = imag( start );\n\t}\n\tif ( dt2 === 'float64' ) {\n\t\tre2 = stop;\n\t\tim2 = 0.0;\n\t} else if ( dt2 === 'complex64' ) {\n\t\tisf32 += 1;\n\t\tre2 = realf( stop );\n\t\tim2 = imagf( stop );\n\t} else {\n\t\tre2 = real( stop );\n\t\tim2 = imag( stop );\n\t}\n\t// Determine which complex number constructor to use according to type promotion rules:\n\tif ( isf32 === 2 ) {\n\t\tcmplx = Complex64;\n\t} else {\n\t\tcmplx = Complex128;\n\t}\n\t// Cache array object references:\n\tbuf = out.data;\n\tset = out.accessors[ 1 ];\n\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tset( buf, 0, new cmplx( re2, im2 ) );\n\t\t} else {\n\t\t\tset( buf, 0, new cmplx( re1, im1 ) );\n\t\t}\n\t\treturn out;\n\t}\n\tset( buf, 0, new cmplx( re1, im1 ) );\n\n\t// Calculate the increments:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\tdr = ( re2-re1 ) / N;\n\tdi = ( im2-im1 ) / N;\n\n\t// Generate the linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tre = re1 + (dr*i);\n\t\tim = im1 + (di*i);\n\t\tset( buf, i, new cmplx( re, im ) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tset( buf, N, new cmplx( re2, im2 ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array.\n*\n* @private\n* @param {Object} out - output array object\n* @param {ArrayLikeObject} out.data - output array data\n* @param {Array} out.accessors - array element accessors\n* @param {number} start - start of interval\n* @param {number} stop - end of interval\n* @param {NonNegativeInteger} len - length of output array\n* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array\n* @returns {Object} output array object\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function set( buf, i, v ) {\n* buf[ i ] = v * 2.0;\n* }\n*\n* var out = new Float64Array( 6 );\n* var obj = {\n* 'data': out,\n* 'accessors': [ null, set ]\n* };\n* linspace( obj, 0, 100, out.length, true );\n*\n* var arr = obj.data;\n* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0, 200.0 ]\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* function set( buf, i, v ) {\n* buf[ i ] = v * 2.0;\n* }\n*\n* var out = new Float64Array( 5 );\n* var obj = {\n* 'data': out,\n* 'accessors': [ null, set ]\n* };\n* linspace( obj, 0, 100, out.length, false );\n*\n* var arr = obj.data;\n* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0 ]\n*/\nfunction linspace( out, start, stop, len, endpoint ) {\n\tvar buf;\n\tvar set;\n\tvar N;\n\tvar d;\n\tvar i;\n\n\tif ( len === 0 ) {\n\t\treturn out;\n\t}\n\t// Cache array object references:\n\tbuf = out.data;\n\tset = out.accessors[ 1 ];\n\n\t// Set the first value:\n\tif ( len === 1 ) {\n\t\tif ( endpoint ) {\n\t\t\tset( buf, 0, stop );\n\t\t} else {\n\t\t\tset( buf, 0, start );\n\t\t}\n\t\treturn out;\n\t}\n\tset( buf, 0, start );\n\n\t// Calculate the increment:\n\tif ( endpoint ) {\n\t\tN = len - 1;\n\t} else {\n\t\tN = len;\n\t}\n\td = ( stop-start ) / N;\n\n\t// Generate linearly spaced values:\n\tfor ( i = 1; i < N; i++ ) {\n\t\tset( buf, i, start + (d*i) );\n\t}\n\t// Check whether to include the `stop` value in the output array:\n\tif ( endpoint ) {\n\t\tset( buf, N, stop );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default linspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// EXPORTS //\n\nexport default Object.create;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// FUNCTIONS //\n\n/**\n* Dummy constructor.\n*\n* @private\n*/\nfunction Ctor() {\n\t// Empty...\n}\n\n\n// MAIN //\n\n/**\n* An `Object.create` shim for older JavaScript engines.\n*\n* @private\n* @param {Object} proto - prototype\n* @returns {Object} created object\n*\n* @example\n* var obj = createObject( Object.prototype );\n* // returns {}\n*/\nfunction createObject( proto ) {\n\tCtor.prototype = proto;\n\treturn new Ctor();\n}\n\n\n// EXPORTS //\n\nexport default createObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport builtin from './native.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar createObject;\nif ( typeof builtin === 'function' ) {\n\tcreateObject = builtin;\n} else {\n\tcreateObject = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default createObject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len, no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport isObject from '@stdlib/assert/is-object';\nimport isFunction from '@stdlib/assert/is-function';\nimport hasIteratorSymbolSupport from '@stdlib/assert/has-iterator-symbol-support';\nimport ITERATOR_SYMBOL from '@stdlib/symbol/iterator';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport getter from './../../base/getter';\nimport accessorGetter from './../../base/accessor-getter';\nimport inherits from '@stdlib/utils/inherit';\nimport fixedEndianFactory from './../../fixed-endian-factory';\nimport bytesPerElement from '@stdlib/ndarray/base/bytes-per-element';\nimport capitalize from '@stdlib/string/base/capitalize';\nimport format from '@stdlib/string/format';\nimport fromIterator from './from_iterator.js';\nimport fromIteratorMap from './from_iterator_map.js';\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar BYTE_ORDER = 'little-endian';\nvar DTYPE2SET = {\n\t'float64': 'setFloat64',\n\t'float32': 'setFloat32',\n\t'int32': 'setInt32',\n\t'int16': 'setInt16',\n\t'uint32': 'setUint32',\n\t'uint16': 'setUint16'\n};\nvar CHAR2ARTICLE = {\n\t'c': 'a',\n\t'f': 'a',\n\t'i': 'an',\n\t'u': 'a',\n\t'b': 'a'\n};\n\n\n// FUNCTIONS //\n\n/**\n* Converts a data type string to a constructor name.\n*\n* @private\n* @param {string} dtype - data type\n* @returns {string} constructor name\n*\n* @example\n* var n = dtype2ctor( 'float64' );\n* // returns 'Float64ArrayLE'\n*\n* @example\n* var n = dtype2ctor( 'int32' );\n* // returns 'Int32ArrayLE'\n*/\nfunction dtype2ctor( dtype ) {\n\treturn capitalize( dtype ) + 'ArrayLE';\n}\n\n\n// MAIN //\n\n/**\n* Returns a typed array constructor for creating typed arrays stored in little-endian byte order.\n*\n* @param {string} dtype - typed array data type\n* @throws {TypeError} first argument must be a supported data type\n* @returns {Function} typed array constructor\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var Float64ArrayLE = factory( 'float64' );\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nfunction factory( dtype ) {\n\tvar BYTES_PER_ELEMENT;\n\tvar CTOR_NAME;\n\tvar SETTER;\n\tvar parent;\n\n\t// Defer `dtype` validation to `fixedEndianFactory`:\n\tparent = fixedEndianFactory( dtype );\n\n\tBYTES_PER_ELEMENT = bytesPerElement( dtype );\n\tCTOR_NAME = dtype2ctor( dtype );\n\tSETTER = DTYPE2SET[ dtype ];\n\n\t/**\n\t* Typed array constructor which returns a typed array representing an array of values in little-endian byte order.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n\t* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n\t* @param {NonNegativeInteger} [length] - view length\n\t* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n\t* @throws {TypeError} byte offset must be a nonnegative integer\n\t* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tfunction TypedArray() {\n\t\tvar nargs = arguments.length;\n\t\tif ( !(this instanceof TypedArray) ) {\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\treturn new TypedArray();\n\t\t\t}\n\t\t\tif ( nargs === 1 ) {\n\t\t\t\treturn new TypedArray( arguments[0] );\n\t\t\t}\n\t\t\tif ( nargs === 2 ) {\n\t\t\t\treturn new TypedArray( arguments[0], arguments[1] );\n\t\t\t}\n\t\t\treturn new TypedArray( arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\tif ( nargs === 0 ) {\n\t\t\tparent.call( this, BYTE_ORDER );\n\t\t} else if ( nargs === 1 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0] );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1] );\n\t\t} else if ( nargs === 3 ) {\n\t\t\tparent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] );\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t* Size (in bytes) of each array element.\n\t*\n\t* @private\n\t* @name BYTES_PER_ELEMENT\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {PositiveInteger}\n\t*/\n\tsetReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT );\n\n\t/**\n\t* Constructor name.\n\t*\n\t* @private\n\t* @name name\n\t* @memberof TypedArray\n\t* @readonly\n\t* @type {string}\n\t*/\n\tsetReadOnly( TypedArray, 'name', CTOR_NAME );\n\n\t/**\n\t* Creates a new typed array from an array-like object or an iterable.\n\t*\n\t* @private\n\t* @name from\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {(Collection|Iterable)} src - array-like object or iterable\n\t* @param {Function} [clbk] - callback to invoke for each source element\n\t* @param {*} [thisArg] - context\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @throws {TypeError} first argument must be an array-like object or an iterable\n\t* @throws {TypeError} second argument must be a function\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'from', function from( src ) {\n\t\tvar thisArg;\n\t\tvar nargs;\n\t\tvar clbk;\n\t\tvar out;\n\t\tvar buf;\n\t\tvar tmp;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\tnargs = arguments.length;\n\t\tif ( nargs > 1 ) {\n\t\t\tclbk = arguments[ 1 ];\n\t\t\tif ( !isFunction( clbk ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );\n\t\t\t}\n\t\t\tif ( nargs > 2 ) {\n\t\t\t\tthisArg = arguments[ 2 ];\n\t\t\t}\n\t\t}\n\t\tif ( isCollection( src ) ) {\n\t\t\tif ( clbk ) {\n\t\t\t\tlen = src.length;\n\t\t\t\tif ( src.get && src.set ) {\n\t\t\t\t\tget = accessorGetter( 'default' );\n\t\t\t\t} else {\n\t\t\t\t\tget = getter( 'default' );\n\t\t\t\t}\n\t\t\t\tout = new this( len );\n\t\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true );\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\treturn new this( src );\n\t\t}\n\t\tif ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) {\n\t\t\tbuf = src[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( buf.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t\t\t}\n\t\t\tif ( clbk ) {\n\t\t\t\ttmp = fromIteratorMap( buf, clbk, thisArg );\n\t\t\t} else {\n\t\t\t\ttmp = fromIterator( buf );\n\t\t\t}\n\t\t\tlen = tmp.length;\n\t\t\tout = new this( len );\n\t\t\tbuf = out._buffer; // eslint-disable-line no-underscore-dangle\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tbuf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) );\n\t});\n\n\t/**\n\t* Creates a new typed array from a variable number of arguments.\n\t*\n\t* @private\n\t* @name of\n\t* @memberof TypedArray\n\t* @type {Function}\n\t* @param {...*} element - array elements\n\t* @throws {TypeError} `this` context must be a constructor\n\t* @throws {TypeError} `this` must be a typed array constructor\n\t* @returns {TypedArray} typed array instance\n\t*/\n\tsetReadOnly( TypedArray, 'of', function of() {\n\t\tvar args;\n\t\tvar i;\n\t\tif ( !isFunction( this ) ) {\n\t\t\tthrow new TypeError( 'invalid invocation. `this` context must be a constructor.' );\n\t\t}\n\t\tif ( !isTypedArrayConstructor( this ) ) {\n\t\t\tthrow new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) );\n\t\t}\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn new this( args );\n\t});\n\n\t// Inherit from the parent constructor:\n\tinherits( TypedArray, parent );\n\n\treturn TypedArray;\n\n\t/**\n\t* Returns a boolean indicating if a value is a typed array constructor.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating if a value is a typed array constructor\n\t*/\n\tfunction isTypedArrayConstructor( value ) {\n\t\treturn ( value === TypedArray );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @param {Function} clbk - callback to invoke for each iterated value\n* @param {*} thisArg - invocation context\n* @returns {Array} output array\n*/\nfunction fromIteratorMap( it, clbk, thisArg ) {\n\tvar out;\n\tvar v;\n\tvar i;\n\n\tout = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tout.push( clbk.call( thisArg, v.value, i ) );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIteratorMap;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of iterated values.\n*\n* @private\n* @param {Object} it - iterator\n* @returns {Array} output array\n*/\nfunction fromIterator( it ) {\n\tvar out;\n\tvar v;\n\n\tout = [];\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tout.push( v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default fromIterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport defineProperty from './../../define-property';\nimport format from '@stdlib/string/format';\nimport validate from './validate.js';\nimport createObject from './detect.js';\n\n\n// MAIN //\n\n/**\n* Implements prototypical inheritance by replacing the prototype of one constructor with the prototype of another constructor.\n*\n* ## Notes\n*\n* - This implementation is not designed to work with ES2015/ES6 classes. For ES2015/ES6 classes, use `class` with `extends`.\n* - For reference, see [node#3455](https://github.com/nodejs/node/pull/3455), [node#4179](https://github.com/nodejs/node/issues/4179), [node#3452](https://github.com/nodejs/node/issues/3452), and [node commit](https://github.com/nodejs/node/commit/29da8cf8d7ab8f66b9091ab22664067d4468461e#diff-3deb3f32958bb937ae05c6f3e4abbdf5).\n*\n* @param {(Object|Function)} ctor - constructor which will inherit\n* @param {(Object|Function)} superCtor - super (parent) constructor\n* @throws {TypeError} first argument must be either an object or a function which can inherit\n* @throws {TypeError} second argument must be either an object or a function from which a constructor can inherit\n* @throws {TypeError} second argument must have an inheritable prototype\n* @returns {(Object|Function)} child constructor\n*\n* @example\n* function Foo() {\n* return this;\n* }\n* Foo.prototype.beep = function beep() {\n* return 'boop';\n* };\n*\n* function Bar() {\n* Foo.call( this );\n* return this;\n* }\n* inherit( Bar, Foo );\n*\n* var bar = new Bar();\n* var v = bar.beep();\n* // returns 'boop'\n*/\nfunction inherit( ctor, superCtor ) {\n\tvar err = validate( ctor );\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\terr = validate( superCtor );\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( typeof superCtor.prototype === 'undefined' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must have a prototype from which another object can inherit. Value: `%s`.', superCtor.prototype ) );\n\t}\n\t// Create a prototype which inherits from the parent prototype:\n\tctor.prototype = createObject( superCtor.prototype );\n\n\t// Set the constructor to refer to the child constructor:\n\tdefineProperty( ctor.prototype, 'constructor', {\n\t\t'configurable': true,\n\t\t'enumerable': false,\n\t\t'writable': true,\n\t\t'value': ctor\n\t});\n\n\treturn ctor;\n}\n\n\n// EXPORTS //\n\nexport default inherit;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './../../little-endian-factory';\n\n\n// MAIN //\n\n/**\n* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in little-endian byte order.\n*\n* @name Float32ArrayLE\n* @constructor\n* @type {Function}\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float32ArrayLE} typed array instance\n*\n* @example\n* var arr = new Float32ArrayLE();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float32ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Float32ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 8 );\n* var arr = new Float32ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 8 );\n* var arr = new Float32ArrayLE( buf, 4 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float32ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nvar Float32ArrayLE = factory( 'float32' );\n\n\n// EXPORTS //\n\nexport default Float32ArrayLE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './../../little-endian-factory';\n\n\n// MAIN //\n\n/**\n* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in little-endian byte order.\n*\n* @name Float64ArrayLE\n* @constructor\n* @type {Function}\n* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @throws {TypeError} if provided only one argument, the argument must be a valid argument\n* @throws {TypeError} byte offset must be a nonnegative integer\n* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements\n* @returns {Float64ArrayLE} typed array instance\n*\n* @example\n* var arr = new Float64ArrayLE();\n* // returns \n*\n* var len = arr.length;\n* // returns 0\n*\n* @example\n* var arr = new Float64ArrayLE( 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = new Float64ArrayLE( buf, 8 );\n* // returns \n*\n* var len = arr.length;\n* // returns 1\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = new Float64ArrayLE( buf, 8, 2 );\n* // returns \n*\n* var len = arr.length;\n* // returns 2\n*/\nvar Float64ArrayLE = factory( 'float64' );\n\n\n// EXPORTS //\n\nexport default Float64ArrayLE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport NINF from '@stdlib/constants/float64/ninf';\n\n\n// MAIN //\n\n/**\n* Tests if a double-precision floating-point numeric value is negative zero.\n*\n* @param {number} x - value to test\n* @returns {boolean} boolean indicating whether the value is negative zero\n*\n* @example\n* var bool = isNegativeZero( -0.0 );\n* // returns true\n*\n* @example\n* var bool = isNegativeZero( 0.0 );\n* // returns false\n*/\nfunction isNegativeZero( x ) {\n\treturn (x === 0.0 && 1.0/x === NINF);\n}\n\n\n// EXPORTS //\n\nexport default isNegativeZero;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Smallest positive single-precision floating-point subnormal number.\n*\n* @module @stdlib/constants/float32/smallest-subnormal\n* @type {number}\n*\n* @example\n* import FLOAT32_SMALLEST_SUBNORMAL from '@stdlib/constants/float32/smallest-subnormal';\n* // returns 1.401298464324817e-45\n*/\n\n\n// MAIN //\n\n/**\n* Smallest positive single-precision floating-point subnormal number.\n*\n* ## Notes\n*\n* The number has the value\n*\n* ```tex\n* \\frac{1}{2^{127-1} 2^{23}}\n* ```\n*\n* which corresponds to the bit sequence\n*\n* ```binarystring\n* 0 00000000 00000000000000000000001\n* ```\n*\n* @constant\n* @type {number}\n* @default 1.401298464324817e-45\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT32_SMALLEST_SUBNORMAL = 1.401298464324817e-45;\n\n\n// EXPORTS //\n\nexport default FLOAT32_SMALLEST_SUBNORMAL;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Maximum safe single-precision floating-point integer.\n*\n* @module @stdlib/constants/float32/max-safe-integer\n* @type {number}\n*\n* @example\n* import FLOAT32_MAX_SAFE_INTEGER from '@stdlib/constants/float32/max-safe-integer';\n* // returns 16777215\n*/\n\n\n// MAIN //\n\n/**\n* Maximum safe single-precision floating-point integer.\n*\n* ## Notes\n*\n* The maximum safe integer is given by\n*\n* ```tex\n* 2^{24} - 1\n* ```\n*\n* @constant\n* @type {number}\n* @default 16777215\n* @see [Safe Integers]{@link http://www.2ality.com/2013/10/safe-integers.html}\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT32_MAX_SAFE_INTEGER = 16777215;\n\n\n// EXPORTS //\n\nexport default FLOAT32_MAX_SAFE_INTEGER;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Minimum safe single-precision floating-point integer.\n*\n* @module @stdlib/constants/float32/min-safe-integer\n* @type {number}\n*\n* @example\n* import FLOAT32_MIN_SAFE_INTEGER from '@stdlib/constants/float32/min-safe-integer';\n* // returns -16777215\n*/\n\n\n// MAIN //\n\n/**\n* Minimum safe single-precision floating-point integer.\n*\n* ## Notes\n*\n* The minimum safe integer is given by\n*\n* ```tex\n* -(2^{24} - 1)\n* ```\n*\n* @constant\n* @type {number}\n* @default -16777215\n* @see [Safe Integers]{@link http://www.2ality.com/2013/10/safe-integers.html}\n* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985}\n*/\nvar FLOAT32_MIN_SAFE_INTEGER = -16777215;\n\n\n// EXPORTS //\n\nexport default FLOAT32_MIN_SAFE_INTEGER;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport isNegativeZero from '@stdlib/math/base/assert/is-negative-zero';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport PINF from '@stdlib/constants/float64/pinf';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport FLOAT32_SMALLEST_SUBNORMAL from '@stdlib/constants/float32/smallest-subnormal'; // eslint-disable-line id-length\nimport FLOAT32_MAX_SAFE_INTEGER from '@stdlib/constants/float32/max-safe-integer';\nimport FLOAT32_MIN_SAFE_INTEGER from '@stdlib/constants/float32/min-safe-integer';\nimport INT8_MIN from '@stdlib/constants/int8/min';\nimport INT16_MIN from '@stdlib/constants/int16/min';\nimport INT32_MIN from '@stdlib/constants/int32/min';\nimport UINT8_MAX from '@stdlib/constants/uint8/max';\nimport UINT16_MAX from '@stdlib/constants/uint16/max';\nimport UINT32_MAX from '@stdlib/constants/uint32/max';\n\n\n// FUNCTIONS //\n\n/**\n* Returns the minimum floating-point array data type of the closest \"kind\" necessary for storing a provided scalar.\n*\n* @private\n* @param {number} value - real value\n* @returns {string} array data type\n*/\nfunction minFloatDataType( value ) {\n\tif ( value !== value || value === PINF || value === NINF ) {\n\t\treturn 'float32';\n\t}\n\tif ( isInteger( value ) ) {\n\t\tif ( value >= FLOAT32_MIN_SAFE_INTEGER && value <= FLOAT32_MAX_SAFE_INTEGER ) { // eslint-disable-line max-len\n\t\t\treturn 'float32';\n\t\t}\n\t\treturn 'float64';\n\t}\n\t// Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float32`...\n\tif (\n\t\tvalue > -FLOAT32_SMALLEST_SUBNORMAL &&\n\t\tvalue < FLOAT32_SMALLEST_SUBNORMAL\n\t) {\n\t\treturn 'float64';\n\t}\n\t// Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)...\n\treturn 'float32';\n}\n\n\n// MAIN //\n\n/**\n* Returns the minimum array data type of the closest \"kind\" necessary for storing a provided scalar value.\n*\n* @param {*} value - scalar value\n* @returns {string} array data type\n*\n* @example\n* var dt = minDataType( 3.141592653589793 );\n* // returns 'float32'\n*\n* @example\n* var dt = minDataType( 3 );\n* // returns 'uint8'\n*/\nfunction minDataType( value ) {\n\tif ( !isNumber( value ) ) {\n\t\tif ( isBoolean( value ) ) {\n\t\t\treturn 'bool';\n\t\t}\n\t\tif ( isComplexLike( value ) ) {\n\t\t\tif ( minFloatDataType( value.re ) === 'float64' || minFloatDataType( value.im ) === 'float64' ) {\n\t\t\t\treturn 'complex128';\n\t\t\t}\n\t\t\treturn 'complex64';\n\t\t}\n\t\treturn 'generic';\n\t}\n\tif ( value !== value || value === PINF || value === NINF ) {\n\t\treturn 'float32';\n\t}\n\tif ( isInteger( value ) ) {\n\t\tif ( value === 0 && isNegativeZero( value ) ) {\n\t\t\treturn 'float32';\n\t\t}\n\t\tif ( value < 0 ) {\n\t\t\tif ( value >= INT8_MIN ) {\n\t\t\t\treturn 'int8';\n\t\t\t}\n\t\t\tif ( value >= INT16_MIN ) {\n\t\t\t\treturn 'int16';\n\t\t\t}\n\t\t\tif ( value >= INT32_MIN ) {\n\t\t\t\treturn 'int32';\n\t\t\t}\n\t\t\treturn 'float64';\n\t\t}\n\t\tif ( value <= UINT8_MAX ) {\n\t\t\treturn 'uint8';\n\t\t}\n\t\tif ( value <= UINT16_MAX ) {\n\t\t\treturn 'uint16';\n\t\t}\n\t\tif ( value <= UINT32_MAX ) {\n\t\t\treturn 'uint32';\n\t\t}\n\t\treturn 'float64';\n\t}\n\t// Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float32`...\n\tif (\n\t\tvalue > -FLOAT32_SMALLEST_SUBNORMAL &&\n\t\tvalue < FLOAT32_SMALLEST_SUBNORMAL\n\t) {\n\t\treturn 'float64';\n\t}\n\t// Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)...\n\treturn 'float32';\n}\n\n\n// EXPORTS //\n\nexport default minDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/mskfilter';\nimport countTruthy from './../../base/count-truthy';\nimport zeros from './../../zeros';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a new array by applying a mask to a provided input array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {Error} must provide collections of equal length\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskfilter( x, mask );\n* // returns [ 2, 4 ]\n*/\nfunction mskfilter( x, mask ) {\n\tvar dt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( mask ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) );\n\t}\n\tif ( x.length !== mask.length ) {\n\t\tthrow new Error( format( 'invalid arguments. Must provide equal length array-like objects.' ) );\n\t}\n\tdt = dtype( x );\n\tif ( dt === 'generic' || dt === null ) {\n\t\treturn base( x, mask );\n\t}\n\treturn base.assign( x, mask, zeros( countTruthy( mask ), dt ), 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default mskfilter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { factory as contains } from './../../base/assert/contains';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar MODES = [\n\t'strict',\n\t'non_strict',\n\t'strict_broadcast',\n\t'broadcast',\n\t'repeat'\n];\nvar isMode = contains( MODES );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.mode] - mode option\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'mode': 'strict'\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\topts.mode = options.mode;\n\t\tif ( !isMode( opts.mode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'mode', MODES.join( '\", \"' ), opts.mode ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/mskreject';\nimport countFalsy from './../../base/count-falsy';\nimport zeros from './../../zeros';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a new array by applying a mask to a provided input array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {Error} must provide collections of equal length\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskreject( x, mask );\n* // returns [ 1, 3 ]\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n* var mask = [ 0, 1, 0, 1 ];\n*\n* var y = mskreject( x, mask );\n* // returns [ 1, 3 ]\n*/\nfunction mskreject( x, mask ) {\n\tvar dt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( mask ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) );\n\t}\n\tif ( x.length !== mask.length ) {\n\t\tthrow new Error( format( 'invalid arguments. Must provide equal length array-like objects.' ) );\n\t}\n\tdt = dtype( x );\n\tif ( dt === 'generic' || dt === null ) {\n\t\treturn base( x, mask );\n\t}\n\treturn base.assign( x, mask, zeros( countFalsy( mask ), dt ), 1, 0 );\n}\n\n\n// EXPORTS //\n\nexport default mskreject;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { factory as contains } from './../../base/assert/contains';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport full from './../../full';\nimport defaults from './../../defaults';\nimport dtypes from './../../dtypes';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar Z128 = new Complex128( NaN, NaN );\nvar Z64 = new Complex64( NaN, NaN );\nvar DTYPES = dtypes( 'floating_point_and_generic' );\nvar isValidDType = contains( DTYPES );\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.real_floating_point' );\n\n\n// MAIN //\n\n/**\n* Creates an array filled with NaNs and having a specified length.\n*\n* @param {NonNegativeInteger} length - array length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a supported data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = nans( 2 );\n* // returns [ NaN, NaN ]\n*\n* @example\n* var arr = nans( 2, 'float32' );\n* // returns [ NaN, NaN ]\n*/\nfunction nans( length ) {\n\tvar dtype;\n\tvar value;\n\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t\tif ( !isValidDType( dtype ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be one of the following: \"%s\". Value: `%s`.', DTYPES.join( '\", \"' ), dtype ) );\n\t\t}\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tif ( dtype === 'complex128' ) {\n\t\tvalue = Z128;\n\t} else if ( dtype === 'complex64' ) {\n\t\tvalue = Z64;\n\t} else {\n\t\tvalue = NaN;\n\t}\n\treturn full( length, value, dtype );\n}\n\n\n// EXPORTS //\n\nexport default nans;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dtype from './../../dtype';\nimport full from './../../full';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar Z128 = new Complex128( NaN, NaN );\nvar Z64 = new Complex64( NaN, NaN );\nvar DTYPES = [ 'float64', 'float32', 'complex128', 'complex64', 'generic' ];\n\n\n// MAIN //\n\n/**\n* Creates an array filled with NaNs and having the same length and data type as a provided input array.\n*\n* @param {(Array|TypedArray|ComplexArray)} x - input array\n* @param {string} [dtype] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a supported data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = nansLike( [ 0.0, 0.0 ] );\n* // returns [ NaN, NaN ]\n*\n* @example\n* var arr = nansLike( [ 0.0, 0.0 ], 'float32' );\n* // returns [ NaN, NaN ]\n*/\nfunction nansLike( x ) {\n\tvar dt;\n\tvar v;\n\n\tdt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t\tif ( DTYPES.indexOf( dt ) === -1 ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be one of the following: \"%s\". Value: `%s`.', DTYPES.join( '\", \"' ), dt ) );\n\t\t}\n\t} else if ( DTYPES.indexOf( dt ) === -1 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be one of the following data types: \"%s\". Value: `%s`.', DTYPES.join( '\", \"' ), dt ) );\n\t}\n\tif ( dt === 'complex128' ) {\n\t\tv = Z128;\n\t} else if ( dt === 'complex64' ) {\n\t\tv = Z64;\n\t} else {\n\t\tv = NaN;\n\t}\n\treturn full( x.length, v, dt );\n}\n\n\n// EXPORTS //\n\nexport default nansLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport base from './../../base/one-to';\nimport zeros from './../../zeros';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from one.\n*\n* @param {NonNegativeInteger} n - number of elements\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = oneTo( 2 );\n* // returns [ 1.0, 2.0 ]\n*\n* @example\n* var arr = oneTo( 2, 'float32' );\n* // returns [ 1.0, 2.0 ]\n*/\nfunction oneTo( n ) {\n\tvar dtype;\n\tif ( !isNonNegativeInteger( n ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', n ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t\tif ( dtype === 'generic' ) {\n\t\t\treturn base( n );\n\t\t}\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\treturn base.assign( zeros( n, dtype ), 1, 0 ); // defer dtype validation to `zeros`\n}\n\n\n// EXPORTS //\n\nexport default oneTo;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport full from './../../full';\nimport defaults from './../../defaults';\n\n\n// VARIABLES //\n\nvar Z128 = new Complex128( 1.0, 0.0 );\nvar Z64 = new Complex64( 1.0, 0.0 );\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Creates an array filled with ones and having a specified length.\n*\n* @param {NonNegativeInteger} length - array length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = ones( 2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = ones( 2, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*/\nfunction ones( length ) {\n\tvar dtype;\n\tvar value;\n\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tif ( dtype === 'complex128' ) {\n\t\tvalue = Z128;\n\t} else if ( dtype === 'complex64' ) {\n\t\tvalue = Z64;\n\t} else {\n\t\tvalue = 1;\n\t}\n\treturn full( length, value, dtype );\n}\n\n\n// EXPORTS //\n\nexport default ones;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dtype from './../../dtype';\nimport full from './../../full';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar Z128 = new Complex128( 1.0, 0.0 );\nvar Z64 = new Complex64( 1.0, 0.0 );\n\n\n// MAIN //\n\n/**\n* Creates an array filled with ones and having the same length and data type as a provided input array.\n*\n* @param {(Array|TypedArray|ComplexArray)} x - input array\n* @param {string} [dtype] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = onesLike( [ 0.0, 0.0 ] );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = onesLike( [ 0.0, 0.0 ], 'float32' );\n* // returns [ 1.0, 1.0 ]\n*/\nfunction onesLike( x ) {\n\tvar dt;\n\tvar v;\n\n\tdt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t}\n\tif ( dt === 'complex128' ) {\n\t\tv = Z128;\n\t} else if ( dt === 'complex64' ) {\n\t\tv = Z64;\n\t} else {\n\t\tv = 1.0;\n\t}\n\treturn full( x.length, v, dt );\n}\n\n\n// EXPORTS //\n\nexport default onesLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { factory as contains } from './../../base/assert/contains';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar MODES = [\n\t'strict',\n\t'non_strict',\n\t'strict_broadcast',\n\t'broadcast',\n\t'repeat'\n];\nvar isMode = contains( MODES );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.mode] - mode option\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'mode': 'strict'\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\topts.mode = options.mode;\n\t\tif ( !isMode( opts.mode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'mode', MODES.join( '\", \"' ), opts.mode ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isMostlySafeCast from './../../base/assert/is-mostly-safe-data-type-cast';\nimport isRealDataType from './../../base/assert/is-real-data-type';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/place';\nimport dtype from './../../dtype';\nimport convert from './../../convert';\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Replaces elements of an array with provided values according to a provided mask array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @param {Options} [options] - function options\n* @param {string} [options.mode='repeat'] - string specifying behavior when the number of values does not equal the number of truthy mask values\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {TypeError} third argument must be a collection\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @throws {Error} insufficient values to satisfy mask array\n* @throws {Error} number of values does not equal the number of truthy mask values\n* @throws {TypeError} third argument cannot be safely cast to the data type of the first argument\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 1, 1, 0 ];\n* var values = [ 20, 30 ];\n*\n* var out = place( x, mask, values );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 1, 1, 0 ];\n* var values = [ 30 ];\n*\n* var out = place( x, mask, values );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 1, 0, 1 ];\n* var values = [ 20, 30 ];\n*\n* var out = place( x, mask, values );\n* // returns [ 20, 30, 3, 20 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction place( x, mask, values ) {\n\tvar opts;\n\tvar err;\n\tvar xdt;\n\tvar vdt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( mask ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) );\n\t}\n\tif ( !isCollection( values ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', values ) );\n\t}\n\topts = defaults();\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\txdt = dtype( x ) || 'generic';\n\tvdt = dtype( values ) || 'generic';\n\n\t// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the input array data type is floating-point...\n\tif ( !isMostlySafeCast( vdt, xdt ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].', vdt, xdt ) );\n\t}\n\t// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...\n\tif ( isComplexDataType( xdt ) && isRealDataType( vdt ) ) {\n\t\tvalues = convert( values, xdt );\n\t}\n\t// Replace values in the input array:\n\treturn base( x, mask, values, opts.mode );\n}\n\n\n// EXPORTS //\n\nexport default place;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'mode': 'repeat'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/e_log2.c}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getHighWord from '@stdlib/number/float64/base/get-high-word';\nimport setHighWord from '@stdlib/number/float64/base/set-high-word';\nimport setLowWord from '@stdlib/number/float64/base/set-low-word';\nimport toWords from '@stdlib/number/float64/base/to-words';\nimport isnan from './../../../../base/assert/is-nan';\nimport ABS_MASK from '@stdlib/constants/float64/high-word-abs-mask';\nimport HIGH_SIGNIFICAND_MASK from '@stdlib/constants/float64/high-word-significand-mask';\nimport BIAS from '@stdlib/constants/float64/exponent-bias';\nimport NINF from '@stdlib/constants/float64/ninf';\nimport kernelLog1p from './../../../../base/special/kernel-log1p';\n\n\n// VARIABLES //\n\nvar TWO54 = 1.80143985094819840000e+16; // 0x43500000, 0x00000000\nvar IVLN2HI = 1.44269504072144627571e+00; // 0x3ff71547, 0x65200000\nvar IVLN2LO = 1.67517131648865118353e-10; // 0x3de705fc, 0x2eefa200\n\n// 0x7ff00000 = 2146435072 => 0 11111111111 00000000000000000000 => biased exponent: 2047 = 1023+1023 => 2^1023\nvar HIGH_MAX_NORMAL_EXP = 0x7ff00000|0; // asm type annotation\n\n// 0x00100000 = 1048576 => 0 00000000001 00000000000000000000 => biased exponent: 1 = -1022+1023 => 2^-1022\nvar HIGH_MIN_NORMAL_EXP = 0x00100000|0; // asm type annotation\n\n// 0x3ff00000 = 1072693248 => 0 01111111111 00000000000000000000 => biased exponent: 1023 = 0+1023 => 2^0 = 1\nvar HIGH_BIASED_EXP_0 = 0x3ff00000|0; // asm type annotation\n\n// High/low words workspace:\nvar WORDS = [ 0|0, 0|0 ];\n\n\n// MAIN //\n\n/**\n* Evaluates the binary logarithm (base two).\n*\n* @param {NonNegativeNumber} x - input value\n* @returns {number} function value\n*\n* @example\n* var v = log2( 4.0 );\n* // returns 2.0\n*\n* @example\n* var v = log2( 8.0 );\n* // returns 3.0\n*\n* @example\n* var v = log2( 0.0 );\n* // returns -Infinity\n*\n* @example\n* var v = log2( Infinity );\n* // returns Infinity\n*\n* @example\n* var v = log2( NaN );\n* // returns NaN\n*\n* @example\n* var v = log2( -4.0 );\n* // returns NaN\n*/\nfunction log2( x ) {\n\tvar valHi;\n\tvar valLo;\n\tvar hfsq;\n\tvar hx;\n\tvar lx;\n\tvar hi;\n\tvar lo;\n\tvar f;\n\tvar R;\n\tvar w;\n\tvar y;\n\tvar i;\n\tvar k;\n\n\tif ( isnan( x ) || x < 0.0 ) {\n\t\treturn NaN;\n\t}\n\ttoWords.assign( x, WORDS, 1, 0 );\n\thx = WORDS[ 0 ] | 0; // asm type annotation\n\tlx = WORDS[ 1 ];\n\tk = 0|0; // asm type annotation\n\tif ( hx < HIGH_MIN_NORMAL_EXP ) {\n\t\t// Case: x < 2**-1022\n\t\tif ( ( (hx&ABS_MASK) | lx ) === 0 ) {\n\t\t\treturn NINF;\n\t\t}\n\t\tk -= 54|0; // asm type annotation\n\n\t\t// Subnormal number, scale up x:\n\t\tx *= TWO54;\n\t\thx = getHighWord( x ) | 0; // asm type annotation\n\t}\n\tif ( hx >= HIGH_MAX_NORMAL_EXP ) {\n\t\treturn x + x;\n\t}\n\t// Case: log(1) = +0\n\tif ( hx === HIGH_BIASED_EXP_0 && lx === 0 ) {\n\t\treturn 0.0;\n\t}\n\tk += ( (hx>>20) - BIAS )|0; // asm type annotation\n\thx &= HIGH_SIGNIFICAND_MASK;\n\ti = ( ( hx+0x95f64 ) & HIGH_MIN_NORMAL_EXP )|0; // asm type annotation\n\n\t// Normalize x or x/2...\n\tx = setHighWord( x, hx|(i^HIGH_BIASED_EXP_0) );\n\tk += (i>>20)|0; // asm type annotation\n\ty = k;\n\tf = x - 1.0;\n\thfsq = 0.5 * f * f;\n\tR = kernelLog1p( f );\n\n\t/*\n\t* Notes:\n\t*\n\t* - `f-hfsq` must (for args near `1`) be evaluated in extra precision to avoid a large cancellation when `x` is near `sqrt(2)` or `1/sqrt(2)`.This is fairly efficient since `f-hfsq` only depends on `f`, so can be evaluated in parallel with `R`. Not combining `hfsq` with `R` also keeps `R` small (though not as small as a true `lo` term would be), so that extra precision is not needed for terms involving `R`.\n\t* - When implemented in C, compiler bugs involving extra precision used to break Dekker's theorem for spitting `f-hfsq` as `hi+lo`. These problems are now automatically avoided as a side effect of the optimization of combining the Dekker splitting step with the clear-low-bits step.\n\t* - `y` must (for args near `sqrt(2)` and `1/sqrt(2)`) be added in extra precision to avoid a very large cancellation when `x` is very near these values. Unlike the above cancellations, this problem is specific to base `2`. It is strange that adding `+-1` is so much harder than adding `+-ln2` or `+-log10_2`.\n\t* - This implementation uses Dekker's theorem to normalize `y+val_hi`, so, when implemented in C, compiler bugs may reappear in some configurations.\n\t* - The multi-precision calculations for the multiplications are routine.\n\t*/\n\thi = f - hfsq;\n\thi = setLowWord( hi, 0 );\n\tlo = ( f - hi ) - hfsq + R;\n\tvalHi = hi * IVLN2HI;\n\tvalLo = ( ( lo + hi ) * IVLN2LO ) + ( lo * IVLN2HI );\n\n\tw = y + valHi;\n\tvalLo += ( y - w ) + valHi;\n\tvalHi = w;\n\n\treturn valLo + valHi;\n}\n\n\n// EXPORTS //\n\nexport default log2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*\n*\n* ## Notice\n*\n* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/k_log.h}. The implementation follows the original, but has been modified for JavaScript.\n*\n* ```text\n* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\n*\n* Developed at SunPro, a Sun Microsystems, Inc. business.\n* Permission to use, copy, modify, and distribute this\n* software is freely granted, provided that this notice\n* is preserved.\n* ```\n*/\n\n'use strict';\n\n// MODULES //\n\nimport polyvalP from './polyval_p.js';\nimport polyvalQ from './polyval_q.js';\n\n\n// MAIN //\n\n/**\n* Evaluates a correction term for double-precision base-2 and base-10 logarithms when `1+f` is in `[√2/2, √2]`.\n*\n* ## Method\n*\n* This function is a helper function for computing logarithms in base \\\\(e\\\\), and what follows describes the overall strategy for doing so. The argument reduction and adding the final term of the polynomial are done by the caller for increased accuracy when different bases are used.\n*\n* 1. Argument Reduction. Find \\\\(k\\\\) and \\\\(f\\\\) such that\n*\n* ```tex\n* x = 2^k \\cdot (1+f)\n* ```\n*\n* where \\\\(\\sqrt(2)/2 < 1+f < \\sqrt(2)\\\\).\n*\n* 2. Approximation of \\\\(\\operatorname{log}(1+f)\\\\). Let\n*\n* ```tex\n* \\begin{align*}\n* s &= \\frac{f}{2+f} \\\\\n* &= 2s + \\frac{2}{3} s^3 + \\frac{2}{5} s^5 + \\ldots \\\\\n* &= 2s + s R\n* \\end{align*}\n* ```\n*\n* based on\n*\n* ```tex\n* \\operatorname{log}(1+f) &= \\operatorname{log}(1+s) - \\operatorname{log}(1-s)\n* ```\n*\n* We use a special Reme algorithm on \\\\(\\[0,0.1716]\\\\) to generate a polynomial of degree \\\\(14\\\\) to approximate \\\\(R\\\\). The maximum error of this polynomial approximation is bounded by \\\\(2^{-58.45}\\\\). In other words,\n*\n* ```tex\n* R(z) ~ L_{g1} s^2 + L_{g2} s^4 + L_{g3} s^6 + L_{g4} s^8 + L_{g5} s^{10} + L_{g6} s^{12} + L_{g7} s^{14}\n* ```\n*\n* where the values of \\\\(L_{g1}\\\\) to \\\\(L_{g7}\\\\) are the polynomial coefficients used in the program below and\n*\n* ```tex\n* L_{g1} s^2 + \\ldots + L_{g7} s^{14} - R(z) \\leq 2^{-58.45}\n* ```\n*\n* Note that\n*\n* ```tex\n* 2s = f - s \\cdot f = f - h_{fsq} + (s \\cdot h_{fsq})\n* ```\n*\n* where \\\\(h_{fsq} = f^{2}/2\\\\).\n*\n* In order to guarantee an error in \\\\(\\operatorname{log}\\\\) below 1 ulp, we compute \\\\(\\operatorname{log}\\\\) by\n*\n* ```tex\n* \\begin{align*}\n* \\operatorname{log}(1+f) &= f - s (f - R) & \\textrm{(if f is not too large)} \\\\\n* \\operatorname{log}(1+f) &= f - (h_{fsq} - s (h_{fsq}+R)) & \\textrm{(better accuracy)}\n* \\end{align*}\n*\n* 3. Finally,\n*\n* ```tex\n* \\begin{align*}\n* \\operatorname{log}(x) &= k \\cdot \\operatorname{ln2} + \\operatorname{log}(1+f) \\\\\n* &= k \\cdot \\operatorname{ln2}_{hi} + (f-(h_{fsq}-(s \\cdot (h_{fsq}+R) + k \\cdot \\operatorname{ln2}_{lo})))\n* \\end{align*}\n* ```\n*\n* Here, \\\\(\\operatorname{ln2}\\\\) is split into two floating point numbers:\n*\n* ```tex\n* \\operatorname{ln2} = \\operatorname{ln2}_{hi} + \\operatorname{ln2}_{lo}\n* ```\n*\n* where \\\\(n \\cdot \\operatorname{ln2}_{hi}\\\\) is always exact for \\\\(|n| < 2000\\\\).\n*\n* @param {number} f - input value\n* @returns {number} function value\n*\n* @example\n* var v = kernelLog1p( 1.0 );\n* // returns ~0.1931\n*\n* @example\n* var v = kernelLog1p( 1.4142135623730951 );\n* // returns ~0.4672\n*\n* @example\n* var v = kernelLog1p( NaN );\n* // returns NaN\n*/\nfunction kernelLog1p( f ) {\n\tvar hfsq;\n\tvar t1;\n\tvar t2;\n\tvar s;\n\tvar z;\n\tvar R;\n\tvar w;\n\n\ts = f / ( 2.0 + f );\n\tz = s * s;\n\tw = z * z;\n\tt1 = w * polyvalP( w );\n\tt2 = z * polyvalQ( w );\n\tR = t2 + t1;\n\thfsq = 0.5 * f * f;\n\treturn s * ( hfsq + R );\n}\n\n\n// EXPORTS //\n\nexport default kernelLog1p;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* This is a generated file. Do not edit directly. */\n'use strict';\n\n// MAIN //\n\n/**\n* Evaluates a polynomial.\n*\n* ## Notes\n*\n* - The implementation uses [Horner's rule][horners-method] for efficient computation.\n*\n* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method\n*\n* @private\n* @param {number} x - value at which to evaluate the polynomial\n* @returns {number} evaluated polynomial\n*/\nfunction evalpoly( x ) {\n\tif ( x === 0.0 ) {\n\t\treturn 0.3999999999940942;\n\t}\n\treturn 0.3999999999940942 + (x * (0.22222198432149784 + (x * 0.15313837699209373))); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default evalpoly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* This is a generated file. Do not edit directly. */\n'use strict';\n\n// MAIN //\n\n/**\n* Evaluates a polynomial.\n*\n* ## Notes\n*\n* - The implementation uses [Horner's rule][horners-method] for efficient computation.\n*\n* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method\n*\n* @private\n* @param {number} x - value at which to evaluate the polynomial\n* @returns {number} evaluated polynomial\n*/\nfunction evalpoly( x ) {\n\tif ( x === 0.0 ) {\n\t\treturn 0.6666666666666735;\n\t}\n\treturn 0.6666666666666735 + (x * (0.2857142874366239 + (x * (0.1818357216161805 + (x * 0.14798198605116586))))); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default evalpoly;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isTypedArrayLike from '@stdlib/assert/is-typed-array-like';\nimport isArrayBuffer from '@stdlib/assert/is-arraybuffer';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isComplex64Array from '@stdlib/assert/is-complex64array';\nimport isComplex128Array from '@stdlib/assert/is-complex128array';\nimport isBooleanArray from '@stdlib/assert/is-booleanarray';\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport setReadOnlyAccessor from '@stdlib/utils/define-nonenumerable-read-only-accessor';\nimport ctors from './../../typed-ctors';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport resolveGetter from './../../base/resolve-getter';\nimport resolveSetter from './../../base/resolve-setter';\nimport ARRAY_DEFAULTS from './../../defaults';\nimport format from '@stdlib/string/format';\nimport ArrayBuffer from './../../buffer';\nimport ceil from '@stdlib/math/base/special/ceil';\nimport floor from '@stdlib/math/base/special/floor';\nimport ceil2 from '@stdlib/math/base/special/ceil2';\nimport log2 from '@stdlib/math/base/special/log2';\nimport min from '@stdlib/math/base/special/min';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\nimport createPool from './pool.js';\nimport BYTES_PER_ELEMENT from './bytes_per_element.json';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = ARRAY_DEFAULTS.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// FUNCTIONS //\n\n/**\n* Tests whether an array is a single-precision complex floating-point number array.\n*\n* @private\n* @param {Collection} arr - input array\n* @returns {boolean} boolean indicating whether an input array is a single-precision complex floating-point number array\n*/\nfunction isCmplx64Array( arr ) {\n\treturn ( arr instanceof Complex64Array );\n}\n\n/**\n* Tests whether an array is a double-precision complex floating-point number array.\n*\n* @private\n* @param {Collection} arr - input array\n* @returns {boolean} boolean indicating whether an input array is a double-precision complex floating-point number array\n*/\nfunction isCmplx128Array( arr ) {\n\treturn ( arr instanceof Complex128Array );\n}\n\n/**\n* Tests whether an array is a boolean array.\n*\n* @private\n* @param {Collection} arr - input array\n* @returns {boolean} boolean indicating whether an input array is a boolean array\n*/\nfunction isBoolArray( arr ) {\n\treturn ( arr instanceof BooleanArray );\n}\n\n\n// MAIN //\n\n/**\n* Creates a typed array pool.\n*\n* @param {Options} [options] - pool options\n* @param {NonNegativeInteger} [options.highWaterMark] - maximum total memory which can be allocated\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {Function} allocator\n*\n* @example\n* var typedarraypool = factory();\n*\n* // Allocate an array of doubles:\n* var arr = typedarraypool( 5, 'float64' );\n* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ]\n*\n* arr[ 0 ] = 3.14;\n* arr[ 1 ] = 3.14;\n*\n* // ...\n*\n* // Free the allocated memory to be used in a future allocation:\n* typedarraypool.free( arr );\n*/\nfunction factory( options ) {\n\tvar nbytes;\n\tvar pool;\n\tvar opts;\n\tvar err;\n\n\topts = defaults();\n\tif ( arguments.length ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tpool = createPool( ceil( log2( opts.highWaterMark ) ) );\n\tnbytes = 0;\n\n\tsetReadOnly( malloc, 'malloc', malloc ); // circular reference\n\tsetReadOnly( malloc, 'calloc', calloc );\n\tsetReadOnly( malloc, 'free', free );\n\tsetReadOnly( malloc, 'clear', clear );\n\tsetReadOnly( malloc, 'highWaterMark', opts.highWaterMark );\n\tsetReadOnlyAccessor( malloc, 'nbytes', getBytes );\n\n\treturn malloc;\n\n\t/**\n\t* Returns the number of allocated bytes.\n\t*\n\t* @private\n\t* @returns {NonNegativeInteger} number of allocated bytes\n\t*/\n\tfunction getBytes() {\n\t\treturn nbytes;\n\t}\n\n\t/**\n\t* Returns an array buffer.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} n - number of bytes\n\t* @returns {(ArrayBuffer|null)} array buffer or null\n\t*/\n\tfunction arraybuffer( n ) {\n\t\tvar buf;\n\t\tvar i;\n\n\t\t// Convert the number of bytes to an index in our pool table:\n\t\ti = log2( n );\n\n\t\t// If we already have an available array buffer, use it...\n\t\tif ( i < pool.length && pool[ i ].length ) {\n\t\t\treturn pool[ i ].pop();\n\t\t}\n\t\t// Before allocating a new array buffer, ensure that we have not exceeded the maximum number of bytes we are allowed to allocate...\n\t\tif ( nbytes+n > opts.highWaterMark ) {\n\t\t\treturn null;\n\t\t}\n\t\tbuf = new ArrayBuffer( n );\n\n\t\t// Update the running counter of allocated bytes:\n\t\tnbytes += n;\n\n\t\treturn buf;\n\t}\n\n\t/**\n\t* Returns a typed array.\n\t*\n\t* @private\n\t* @param {Function} ctor - typed array constructor\n\t* @param {NonNegativeInteger} len - view length\n\t* @param {string} dtype - data type\n\t* @returns {(TypedArray|null)} typed array or null\n\t*/\n\tfunction typedarray( ctor, len, dtype ) {\n\t\tvar buf;\n\t\tif ( len === 0 ) {\n\t\t\treturn new ctor( 0 );\n\t\t}\n\t\tbuf = arraybuffer( ceil2( len )*BYTES_PER_ELEMENT[ dtype ] );\n\t\tif ( buf === null ) {\n\t\t\treturn buf;\n\t\t}\n\t\treturn new ctor( buf, 0, len );\n\t}\n\n\t/**\n\t* Returns an uninitialized typed array.\n\t*\n\t* ## Notes\n\t*\n\t* - Memory is **not** initialized.\n\t* - Memory is lazily allocated.\n\t* - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory).\n\t*\n\t* @private\n\t* @param {(NonNegativeInteger|Collection)} [arg] - an array length or an array-like object\n\t* @param {string} [dtype=\"float64\"] - data type\n\t* @throws {TypeError} must provide a valid array length or an array-like object\n\t* @throws {TypeError} must provide a recognized data type\n\t* @returns {(TypedArray|null)} typed array or null\n\t*/\n\tfunction malloc() {\n\t\tvar nargs;\n\t\tvar dtype;\n\t\tvar ctor;\n\t\tvar arr;\n\t\tvar out;\n\t\tvar set;\n\t\tvar get;\n\t\tvar len;\n\t\tvar i;\n\n\t\tnargs = arguments.length;\n\t\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\t\tnargs -= 1;\n\t\t\tdtype = arguments[ nargs ];\n\t\t} else {\n\t\t\tdtype = DEFAULT_DTYPE;\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t\t}\n\t\tif ( nargs <= 0 ) {\n\t\t\treturn new ctor( 0 );\n\t\t}\n\t\t// Check if provided a typed array length...\n\t\tif ( isNonNegativeInteger( arguments[ 0 ] ) ) {\n\t\t\treturn typedarray( ctor, arguments[ 0 ], dtype );\n\t\t}\n\t\t// Check if provided an array-like object containing data elements...\n\t\tif ( isCollection( arguments[ 0 ] ) ) {\n\t\t\tarr = arguments[ 0 ];\n\t\t\tlen = arr.length;\n\t\t\tif ( isComplex128Array( arr ) ) {\n\t\t\t\tarr = reinterpret128( arr, 0 );\n\t\t\t} else if ( isComplex64Array( arr ) ) {\n\t\t\t\tarr = reinterpret64( arr, 0 );\n\t\t\t} else if ( isBooleanArray( arr ) ) {\n\t\t\t\tarr = reinterpretBoolean( arr, 0 );\n\t\t\t} else if ( isComplexDataType( dtype ) ) {\n\t\t\t\t// Assume we've been provided an array of interleaved real and imaginary components...\n\t\t\t\tlen /= 2;\n\t\t\t}\n\t\t\tout = typedarray( ctor, len, dtype );\n\t\t\tif ( out === null ) {\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\tif ( isCmplx128Array( out ) || isCmplx64Array( out ) || isBoolArray( out ) ) {\n\t\t\t\tout.set( arr );\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\t// Resolve element accessors in order to account for the possibility that `arr` is a complex number array. As we don't prohibit other \"unsafe\" casts (e.g., providing a `Float64Array` and specifying a `dtype` of `uint8`), we don't prohibit providing a complex number array and specifying a real `dtype`. The results will probably be unexpected/gibberish, but I am not sure we should be overly pedantic in ensuring users don't do ill-advised things...\n\t\t\tget = resolveGetter( arr );\n\t\t\tset = resolveSetter( out );\n\t\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\t\tset( out, i, get( arr, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array length or an array-like object. Value: `%s`.', arguments[ 0 ] ) );\n\t}\n\n\t/**\n\t* Returns a zero-initialized typed array.\n\t*\n\t* ## Notes\n\t*\n\t* - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory).\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} [len=0] - array length\n\t* @param {string} [dtype=\"float64\"] - data type\n\t* @throws {TypeError} must provide a valid array length\n\t* @throws {TypeError} must provide a recognized data type\n\t* @returns {(TypedArray|null)} typed array or null\n\t*/\n\tfunction calloc() {\n\t\tvar nargs;\n\t\tvar out;\n\t\tvar tmp;\n\t\tvar i;\n\n\t\tnargs = arguments.length;\n\t\tif ( nargs === 0 ) {\n\t\t\tout = malloc();\n\t\t} else if ( nargs === 1 ) {\n\t\t\tout = malloc( arguments[ 0 ] );\n\t\t} else {\n\t\t\tout = malloc( arguments[ 0 ], arguments[ 1 ] );\n\t\t}\n\t\tif ( out !== null ) {\n\t\t\t// Initialize the memory...\n\t\t\tif ( isCmplx128Array( out ) ) {\n\t\t\t\ttmp = reinterpret128( out, 0 );\n\t\t\t} else if ( isCmplx64Array( out ) ) {\n\t\t\t\ttmp = reinterpret64( out, 0 );\n\t\t\t} else if ( isBoolArray( out ) ) {\n\t\t\t\ttmp = reinterpretBoolean( out, 0 );\n\t\t\t} else {\n\t\t\t\ttmp = out;\n\t\t\t}\n\t\t\tfor ( i = 0; i < tmp.length; i++ ) {\n\t\t\t\ttmp[ i ] = 0.0;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n\n\t/**\n\t* Frees a typed array or typed array buffer.\n\t*\n\t* ## Notes\n\t*\n\t* - Implicitly, we support providing non-internally allocated arrays and array buffer (e.g., \"freeing\" a typed array allocated in userland); however, the freed array buffer is likely to have excess capacity when compared to other members in its pool.\n\t*\n\t* @private\n\t* @param {(TypedArray|ArrayBuffer)} buf - typed array or array buffer to free\n\t* @throws {TypeError} must provide a typed array or typed array buffer\n\t* @returns {boolean} boolean indicating whether the typed array or array buffer was successfully freed\n\t*/\n\tfunction free( buf ) {\n\t\tvar n;\n\t\tvar p;\n\t\tvar i;\n\t\tif ( isTypedArrayLike( buf ) && buf.buffer ) {\n\t\t\tbuf = buf.buffer;\n\t\t} else if ( !isArrayBuffer( buf ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a typed array or ArrayBuffer. Value: `%s`.', buf ) );\n\t\t}\n\t\tif ( buf.byteLength > 0 ) {\n\t\t\tn = floor( log2( buf.byteLength ) );\n\n\t\t\t// Prohibit \"freeing\" array buffers which would potentially allow users to circumvent high water mark limits:\n\t\t\tn = min( pool.length-1, n );\n\n\t\t\t// Ensure that we do not attempt to free the same buffer more than once...\n\t\t\tp = pool[ n ];\n\t\t\tfor ( i = 0; i < p.length; i++ ) {\n\t\t\t\tif ( p[ i ] === buf ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Add the buffer to our pool of free buffers:\n\t\t\tp.push( buf );\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t* Clears the typed array pool allowing garbage collection of previously allocated (and currently free) array buffers.\n\t*\n\t* @private\n\t*/\n\tfunction clear() {\n\t\tvar i;\n\t\tfor ( i = 0; i < pool.length; i++ ) {\n\t\t\tpool[ i ].length = 0;\n\t\t}\n\t\tnbytes = 0;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'highWaterMark': 9007199254740992\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {NonNegativeInteger} [options.highWaterMark] - maximum total memory which can be allocated\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'highWaterMark': 1024\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegativeInteger( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Initializes a cache for pooled typed array buffers.\n*\n* @private\n* @param {NonNegativeInteger} n - base-2 logarithm of the maximum typed array size\n* @returns {ArrayArray} initialized cache\n*/\nfunction pool( n ) {\n\tvar out;\n\tvar i;\n\n\tout = [];\n\tfor ( i = 0; i < n+1; i++ ) {\n\t\tout.push( [] );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default pool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from './../../is-nonnegative-integer';\nimport MAX from '@stdlib/constants/array/max-typed-array-length';\n\n\n// MAIN //\n\n/**\n* Tests if a value is typed-array-like.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is typed-array-like\n*\n* @example\n* var arr = {\n* 'BYTES_PER_ELEMENT': 8,\n* 'length': 10,\n* 'byteOffset': 0,\n* 'byteLength': 10\n* };\n* var val = isTypedArrayLike( arr );\n* // returns true\n*\n* @example\n* import Int8Array from '@stdlib/array/int8';\n*\n* var val = isTypedArrayLike( new Int8Array( 4 ) );\n* // returns true\n*\n* @example\n* var val = isTypedArrayLike( [] );\n* // returns false\n*\n* @example\n* var val = isTypedArrayLike( {} );\n* // returns false\n*\n* @example\n* var val = isTypedArrayLike( null );\n* // returns false\n*\n* @example\n* var val = isTypedArrayLike( 'beep' );\n* // returns false\n*/\nfunction isTypedArrayLike( value ) {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === 'object' &&\n\t\tisNonNegativeInteger( value.length ) &&\n\t\tvalue.length <= MAX &&\n\t\ttypeof value.BYTES_PER_ELEMENT === 'number' &&\n\t\ttypeof value.byteOffset === 'number' &&\n\t\ttypeof value.byteLength === 'number'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isTypedArrayLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isNegativeZero from './../../../../base/assert/is-negative-zero';\nimport isnan from './../../../../base/assert/is-nan';\nimport NINF from '@stdlib/constants/float64/ninf';\n\n\n// MAIN //\n\n/**\n* Returns the minimum value.\n*\n* @param {number} x - first number\n* @param {number} y - second number\n* @returns {number} minimum value\n*\n* @example\n* var v = min( 3.14, 4.2 );\n* // returns 3.14\n*\n* @example\n* var v = min( 3.14, NaN );\n* // returns NaN\n*\n* @example\n* var v = min( +0.0, -0.0 );\n* // returns -0.0\n*/\nfunction min( x, y ) {\n\tif ( isnan( x ) || isnan( y ) ) {\n\t\treturn NaN;\n\t}\n\tif ( x === NINF || y === NINF ) {\n\t\treturn NINF;\n\t}\n\tif ( x === y && x === 0.0 ) {\n\t\tif ( isNegativeZero( x ) ) {\n\t\t\treturn x;\n\t\t}\n\t\treturn y;\n\t}\n\tif ( x < y ) {\n\t\treturn x;\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default min;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isnan from './../../../../base/assert/is-nan';\nimport isInfinite from './../../../../base/assert/is-infinite';\nimport pow from './../../../../base/special/pow';\nimport floor from './../../../../base/special/floor';\nimport ceil from './../../../../base/special/ceil';\nimport log2 from './../../../../base/special/log2';\nimport MAX_EXP from '@stdlib/constants/float64/max-base2-exponent';\nimport MIN_EXP_SUBNORMAL from '@stdlib/constants/float64/min-base2-exponent-subnormal';\nimport PINF from '@stdlib/constants/float64/pinf';\n\n\n// MAIN //\n\n/**\n* Rounds a numeric value to the nearest power of two toward positive infinity.\n*\n* @param {number} x - input value\n* @returns {number} rounded value\n*\n* @example\n* var v = ceil2( 3.141592653589793 );\n* // returns 4.0\n*\n* @example\n* var v = ceil2( 9.0 );\n* // returns 16.0\n*\n* @example\n* var v = ceil2( -0.314 );\n* // returns -0.25\n*/\nfunction ceil2( x ) {\n\tvar sign;\n\tvar p;\n\tif (\n\t\tisnan( x ) ||\n\t\tisInfinite( x ) ||\n\t\tx === 0.0\n\t) {\n\t\treturn x;\n\t}\n\tif ( x < 0 ) {\n\t\tx = -x;\n\t\tsign = -1.0;\n\t} else {\n\t\tsign = 1.0;\n\t}\n\t// Solve the equation `2^p = x` for `p`:\n\tp = log2( x );\n\n\t// If provided the smallest subnormal, no rounding possible:\n\tif ( p === MIN_EXP_SUBNORMAL ) {\n\t\treturn x;\n\t}\n\t// Determine a power of two which rounds the input value toward positive infinity:\n\tif ( sign === -1.0 ) {\n\t\tp = floor( p );\n\t} else {\n\t\tp = ceil( p );\n\t}\n\t// Handle overflow:\n\tif ( p > MAX_EXP ) {\n\t\treturn PINF;\n\t}\n\treturn sign * pow( 2.0, p );\n}\n\n\n// EXPORTS //\n\nexport default ceil2;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex128Array from '@stdlib/array/complex128';\nimport constructorName from '@stdlib/utils/constructor-name';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Complex128Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Complex128Array\n*\n* @example\n* import Complex128Array from '@stdlib/array/complex128';\n*\n* var bool = isComplex128Array( new Complex128Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isComplex128Array( [] );\n* // returns false\n*/\nfunction isComplex128Array( value ) {\n\treturn (\n\t\tvalue instanceof Complex128Array ||\n\t\tconstructorName( value ) === 'Complex128Array'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex128Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex64Array from '@stdlib/array/complex64';\nimport constructorName from '@stdlib/utils/constructor-name';\n\n\n// MAIN //\n\n/**\n* Tests if a value is a Complex64Array.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a Complex64Array\n*\n* @example\n* import Complex64Array from '@stdlib/array/complex64';\n*\n* var bool = isComplex64Array( new Complex64Array( 10 ) );\n* // returns true\n*\n* @example\n* var bool = isComplex64Array( [] );\n* // returns false\n*/\nfunction isComplex64Array( value ) {\n\treturn (\n\t\tvalue instanceof Complex64Array ||\n\t\tconstructorName( value ) === 'Complex64Array'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isComplex64Array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './factory.js';\n\n\n// MAIN //\n\n/**\n* Returns an uninitialized typed array.\n*\n* ## Notes\n*\n* - Memory is **not** initialized.\n* - Memory is lazily allocated.\n* - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory).\n*\n* @name typedarraypool\n* @type {Function}\n* @param {(NonNegativeInteger|ArrayLikeObject)} [arg] - an array length or an array-like object\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} must provide a valid array length or an array-like object\n* @throws {TypeError} must provide a recognized data type\n* @returns {(TypedArray|null)} typed array or null\n*\n* @example\n* // Allocate an array of doubles:\n* var arr = typedarraypool( 5, 'float64' );\n* // e.g., returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ]\n*\n* arr[ 0 ] = 3.14;\n* arr[ 1 ] = 3.14;\n*\n* // ...\n*\n* // Free the allocated memory to be used in a future allocation:\n* typedarraypool.free( arr );\n*/\nvar typedarraypool = factory();\n\n\n// EXPORTS //\n\nexport default typedarraypool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Typed array pool.\n*\n* @module @stdlib/array/pool\n*\n* @example\n* import typedarraypool from '@stdlib/array/pool';\n*\n* // Allocate an array of doubles:\n* var arr = typedarraypool( 5, 'float64' );\n* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ]\n*\n* arr[ 0 ] = 3.14;\n* arr[ 1 ] = 3.14;\n*\n* // ...\n*\n* // Free the allocated memory to be used in a future allocation:\n* typedarraypool.free( arr );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isMostlySafeCast from './../../base/assert/is-mostly-safe-data-type-cast';\nimport isRealDataType from './../../base/assert/is-real-data-type';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/put';\nimport dtype from './../../dtype';\nimport convert from './../../convert';\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Replaces specified elements of an array with provided values.\n*\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {Collection} values - values to set\n* @param {Options} [options] - function options\n* @param {string} [options.mode='normalize'] - index mode\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {TypeError} third argument must be a collection\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @throws {Error} third argument must be broadcast compatible with the second argument\n* @throws {TypeError} third argument cannot be safely cast to the data type of the first argument\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 1, 2 ];\n* var values = [ 20, 30 ];\n*\n* var out = put( x, indices, values );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var indices = [ 1, 2 ];\n* var values = [ 30 ];\n*\n* var out = put( x, indices, values );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction put( x, indices, values ) {\n\tvar opts;\n\tvar err;\n\tvar xdt;\n\tvar vdt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( indices ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', indices ) );\n\t}\n\tif ( !isCollection( values ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', values ) );\n\t}\n\topts = defaults();\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\txdt = dtype( x ) || 'generic';\n\tvdt = dtype( values ) || 'generic';\n\n\t// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the input array data type is floating-point...\n\tif ( !isMostlySafeCast( vdt, xdt ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].', vdt, xdt ) );\n\t}\n\t// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...\n\tif ( isComplexDataType( xdt ) && isRealDataType( vdt ) ) {\n\t\tvalues = convert( values, xdt );\n\t}\n\t// Replace values in the input array:\n\treturn base( x, indices, values, opts.mode );\n}\n\n\n// EXPORTS //\n\nexport default put;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'mode': 'normalize'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport isIndexMode from '@stdlib/ndarray/base/assert/is-index-mode';\nimport modes from '@stdlib/ndarray/index-modes';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.mode] - index mode\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'mode': 'normalize'\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\topts.mode = options.mode;\n\t\tif ( !isIndexMode( opts.mode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'mode', modes().join( '\", \"' ), opts.mode ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\nimport Complex64Array from './../../complex64';\nimport Complex128Array from './../../complex128';\nimport BooleanArray from './../../bool';\n\n\n// MAIN //\n\nvar ctors = {\n\t'Float64Array': Float64Array,\n\t'Float32Array': Float32Array,\n\t'Int32Array': Int32Array,\n\t'Uint32Array': Uint32Array,\n\t'Int16Array': Int16Array,\n\t'Uint16Array': Uint16Array,\n\t'Int8Array': Int8Array,\n\t'Uint8Array': Uint8Array,\n\t'Uint8ClampedArray': Uint8ClampedArray,\n\t'Complex64Array': Complex64Array,\n\t'Complex128Array': Complex128Array,\n\t'BooleanArray': BooleanArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArrayLikeObject from '@stdlib/assert/is-array-like-object';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Recursively (and eagerly) attempts to resolve nested array dimensions.\n*\n* @private\n* @param {Array} shape - output array\n* @param {ArrayLikeObject} arr - array\n* @returns {Array} shape array\n*/\nfunction recurse( shape, arr ) {\n\tvar v = arr[ 0 ];\n\tif ( isArrayLikeObject( v ) ) {\n\t\tshape.push( v.length );\n\t\trecurse( shape, v );\n\t}\n\treturn shape;\n}\n\n/**\n* Recursively verifies that all nested arrays have consistent dimensions.\n*\n* @private\n* @param {PositiveInteger} ndims - number of dimensions\n* @param {Array} shape - shape array\n* @param {NonNegativeInteger} d - dimension\n* @param {ArrayLikeObject} arr - array element to verify\n* @param {boolean} flg - boolean indicating whether to continue recursing\n* @returns {NonNegativeInteger} number of consistent dimensions\n*/\nfunction check( ndims, shape, d, arr, flg ) {\n\tvar len;\n\tvar v;\n\tvar i;\n\n\t// Get the size of the current dimension:\n\tlen = shape[ d ];\n\n\t// Ensure that each array element is an array of the same size:\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tv = arr[ i ];\n\n\t\t// If the array element is not an array or is not the same size, we have found an inconsistent dimension:\n\t\tif ( !isArrayLikeObject( v ) || v.length !== len ) {\n\t\t\t// `d` is one more than the index of the last consistent dimension and thus equal to the number of consistent dimensions:\n\t\t\treturn d;\n\t\t}\n\t\t// Recursively examine nested elements:\n\t\tif ( flg ) {\n\t\t\tv = check( ndims, shape, d+1, v, d+1 < ndims-1 );\n\t\t\tif ( v < ndims ) {\n\t\t\t\t// Propagate the number of consistent dimensions up the recursion chain...\n\t\t\t\treturn v;\n\t\t\t}\n\t\t}\n\t}\n\treturn ndims;\n}\n\n\n// MAIN //\n\n/**\n* Determines (nested) array dimensions.\n*\n* @param {ArrayLikeObject} arr - array\n* @throws {TypeError} must provide an array\n* @returns {Array} array shape\n*\n* @example\n* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ];\n*\n* var shape = arrayShape( arr );\n* // returns [ 3, 3 ]\n*\n* @example\n* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ];\n*\n* var shape = arrayShape( arr );\n* // returns [ 3 ]\n*\n* @example\n* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], null ];\n*\n* var shape = arrayShape( arr );\n* // returns [ 3 ]\n*/\nfunction arrayShape( arr ) {\n\tvar shape;\n\tvar ndims;\n\n\tif ( !isArrayLikeObject( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) );\n\t}\n\t// Initialize the shape/dimensions array:\n\tshape = [ arr.length ];\n\n\t// Eagerly determine array dimensions:\n\trecurse( shape, arr );\n\tndims = shape.length;\n\n\t// Check that all array element dimensions are consistent:\n\tif ( ndims > 1 ) {\n\t\t// If `check()` returns a value less than `ndims`, trim off the inconsistent dimensions:\n\t\tshape.length = check( ndims, shape, 1, arr, ndims > 2 );\n\t}\n\treturn shape;\n}\n\n\n// EXPORTS //\n\nexport default arrayShape;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport nativeClass from '@stdlib/utils/native-class';\n\n\n// VARIABLES //\n\nvar hasSharedArrayBuffer = ( typeof SharedArrayBuffer === 'function' ); // eslint-disable-line stdlib/require-globals\n\n\n// MAIN //\n\n/**\n* Tests if a value is a `SharedArrayBuffer`.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating whether value is a `SharedArrayBuffer`\n*\n* @example\n* import SharedArrayBuffer from '@stdlib/array/shared-buffer';\n*\n* try {\n* var bool = isSharedArrayBuffer( new SharedArrayBuffer( 10 ) );\n* // returns true\n* } catch ( err ) {\n* console.log( 'Environment does not support SharedArrayBuffers.' );\n* }\n*\n* @example\n* var bool = isSharedArrayBuffer( [] );\n* // returns false\n*/\nfunction isSharedArrayBuffer( value ) {\n\treturn (\n\t\t( hasSharedArrayBuffer && value instanceof SharedArrayBuffer ) || // eslint-disable-line stdlib/require-globals, no-undef\n\t\tnativeClass( value ) === '[object SharedArrayBuffer]'\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isSharedArrayBuffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar main = ( typeof SharedArrayBuffer === 'function' ) ? SharedArrayBuffer : null; // eslint-disable-line no-undef, stdlib/require-globals\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar ctor = ( typeof SharedArrayBuffer === 'function' ) ? SharedArrayBuffer : null; // eslint-disable-line stdlib/require-globals, no-undef\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Constructor returning an object used to represent a generic, fixed-length raw binary data buffer which can be used to create views of shared memory.\n*\n* @module @stdlib/array/shared-buffer\n*\n* @example\n* import ctor from '@stdlib/array/shared-buffer';\n*\n* var buf;\n* try {\n* buf = new ctor( 10 );\n* // returns \n* } catch ( err ) {\n* console.log( 'Environment does not support SharedArrayBuffers.' );\n* }\n*/\n\n// MODULES //\n\nimport hasSharedArrayBufferSupport from '@stdlib/assert/has-sharedarraybuffer-support'; // eslint-disable-line id-length\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar ctor;\nif ( hasSharedArrayBufferSupport() ) {\n\tctor = builtin;\n} else {\n\tctor = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default ctor;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isSharedArrayBuffer from './../../is-sharedarraybuffer';\nimport GlobalSharedArrayBuffer from './sharedarraybuffer.js';\n\n\n// MAIN //\n\n/**\n* Tests for native `SharedArrayBuffer` support.\n*\n* @returns {boolean} boolean indicating if an environment has `SharedArrayBuffer` support\n*\n* @example\n* var bool = hasSharedArrayBufferSupport();\n* // returns \n*/\nfunction hasSharedArrayBufferSupport() { // eslint-disable-line id-length\n\tvar bool;\n\tvar b1;\n\tvar b2;\n\n\tif ( typeof GlobalSharedArrayBuffer !== 'function' ) {\n\t\treturn false;\n\t}\n\t// Test basic support...\n\ttry {\n\t\tb1 = new GlobalSharedArrayBuffer( 16 );\n\t\tb2 = b1.slice( 4, 8 );\n\t\tbool = (\n\t\t\tisSharedArrayBuffer( b1 ) &&\n\t\t\tisSharedArrayBuffer( b2 ) &&\n\t\t\tb1.byteLength === 16 &&\n\t\t\tb2.byteLength === 4\n\t\t);\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasSharedArrayBufferSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Constructor returning an object used to represent a generic, fixed-length raw binary data buffer which can be used to create views of shared memory.\n*\n* @param {NonNegativeInteger} size - number of bytes\n* @throws {Error} not implemented\n*/\nfunction polyfill( size ) { // eslint-disable-line no-unused-vars\n\tthrow new Error( 'not supported. The current environment does not support SharedArrayBuffers, and, unfortunately, SharedArrayBuffers cannot be polyfilled. For shared memory applications, upgrade your runtime environment to one which supports SharedArrayBuffers.' );\n}\n\n\n// EXPORTS //\n\nexport default polyfill;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/take';\nimport zeros from './../../zeros';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Takes elements from an array.\n*\n* @param {Collection} x - input array\n* @param {IntegerArray} indices - list of indices\n* @param {Options} [options] - function options\n* @param {string} [options.mode='normalize'] - index mode\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n* var indices = [ 3, 1, 2, 0 ];\n*\n* var y = take( x, indices );\n* // returns [ 4, 2, 3, 1 ]\n*/\nfunction take( x, indices ) {\n\tvar opts;\n\tvar err;\n\tvar dt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( indices ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', indices ) );\n\t}\n\topts = defaults();\n\tif ( arguments.length > 2 ) {\n\t\terr = validate( opts, arguments[ 2 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\tdt = dtype( x );\n\tif ( dt === 'generic' || dt === null ) {\n\t\treturn base( x, indices, opts.mode );\n\t}\n\treturn base.assign( x, indices, opts.mode, zeros( indices.length, dt ), 1, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default take;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'mode': 'normalize'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport isIndexMode from '@stdlib/ndarray/base/assert/is-index-mode';\nimport modes from '@stdlib/ndarray/index-modes';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.mode] - index mode\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'mode': 'normalize'\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\topts.mode = options.mode;\n\t\tif ( !isIndexMode( opts.mode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'mode', modes().join( '\", \"' ), opts.mode ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Alias for `eval` global.\n*\n* @module @stdlib/utils/eval\n*\n* @example\n* import evil from '@stdlib/utils/eval';\n*\n* var v = evil( '5*4*3*2*1' );\n* // returns 120\n*/\n\n// MODULES //\n\nvar evil = eval; // eslint-disable-line no-eval\n\n\n// EXPORTS //\n\nexport default evil;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a proxied object.\n*\n* @name Proxy\n* @constructor\n* @type {Function}\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nvar proxy = ( typeof Proxy === 'undefined' ) ? null : Proxy; // eslint-disable-line stdlib/require-globals, node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Proxy object.\n*\n* @module @stdlib/proxy/ctor\n*\n* @example\n* import Proxy from '@stdlib/proxy/ctor';\n*\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\n\n// MODULES //\n\nimport hasProxySupport from '@stdlib/assert/has-proxy-support';\nimport builtin from './main.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar proxy;\nif ( hasProxySupport() ) {\n\tproxy = builtin;\n} else {\n\tproxy = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport evil from '@stdlib/utils/eval';\n\n\n// MAIN //\n\n/**\n* Tests for native `Proxy` support.\n*\n* @returns {boolean} boolean indicating if an environment has native `Proxy` support\n*\n* @example\n* var bool = hasProxySupport();\n* // returns \n*/\nfunction hasProxySupport() {\n\tvar bool;\n\ttry {\n\t\tevil( '\"use strict\"; var handler = { \"get\": function get( t, n ) { return t[ n ] * 100; } }; var target = { \"beep\": 3.14 }; var p = new Proxy( target, handler ); var x = p.beep; if ( x !== 314 ) { throw new Error( \"native Proxy is not supported.\" ); }' );\n\t\tbool = true;\n\t} catch ( err ) { // eslint-disable-line no-unused-vars\n\t\tbool = false;\n\t}\n\treturn bool;\n}\n\n\n// EXPORTS //\n\nexport default hasProxySupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Proxy polyfill.\n*\n* @private\n* @param {Object} target - target object to wrap\n* @param {Object} handlers - object whose properties are functions defining proxy behavior\n* @returns {Object} proxied object\n*\n* @example\n* function get( obj, prop ) {\n* return obj[ prop ] * 2.0;\n* }\n*\n* var handlers = {\n* 'get': get\n* };\n*\n* var p = new Proxy( {}, handlers );\n*\n* p.a = 3.14;\n*\n* var x = p.a;\n* // returns 6.28\n*/\nfunction Proxy( target ) {\n\t// TODO: polyfill implementation\n\treturn target;\n}\n\n\n// EXPORTS //\n\nexport default Proxy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert/is-function';\n\n\n// MAIN //\n\nvar bool = isFunction( Object.assign ); // eslint-disable-line node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Copies own enumerable properties from source objects to a target object.\n*\n* ## Notes\n*\n* - If a property key is present in multiple sources, the property from the last source that defines the key prevails.\n* - The target object is mutated.\n* - Both string and symbol properties are copied.\n*\n* @name assign\n* @type {Function}\n* @param {Object} target - target object\n* @param {...Object} source - source object(s)\n* @throws {TypeError} first argument must not be null or undefined\n* @returns {Object} target object\n*\n* @example\n* var obj1 = {\n* 'a': 'beep'\n* };\n* var obj2 = {\n* 'b': 'boop'\n* };\n*\n* var out = assign( obj1, obj2 );\n* // returns { 'a': 'beep', 'b': 'boop' }\n*/\nvar assign = Object.assign; // eslint-disable-line node/no-unsupported-features/es-builtins\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar bool = ( typeof Object.getOwnPropertySymbols !== 'undefined' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Object from '@stdlib/object/ctor';\n\n\n// VARIABLES //\n\nvar propertySymbols = Object.getOwnPropertySymbols;\n\n\n// MAIN //\n\n/**\n* Returns an array of an object's own symbol properties.\n*\n* ## Notes\n*\n* - In contrast to the built-in `Object.getOwnPropertySymbols()`, this function returns an empty array if provided `undefined` or `null`, rather than throwing an error.\n*\n* @private\n* @param {*} value - input object\n* @returns {Array} a list of own symbol properties\n*\n* @example\n* var symbols = getOwnPropertySymbols( {} );\n*/\nfunction getOwnPropertySymbols( value ) {\n\treturn propertySymbols( Object( value ) );\n}\n\n\n// EXPORTS //\n\nexport default getOwnPropertySymbols;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Return an array of an object's own symbol properties.\n*\n* @module @stdlib/utils/property-symbols\n*\n* @example\n* import getOwnPropertySymbols from '@stdlib/utils/property-symbols';\n*\n* var symbols = getOwnPropertySymbols( {} );\n*/\n\n// MODULES //\n\nimport HAS_BUILTIN from './has_builtin.js';\nimport builtin from './builtin.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar main;\nif ( HAS_BUILTIN ) {\n\tmain = builtin;\n} else {\n\tmain = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Copy enumerable own properties from one or more source objects to a target object.\n*\n* @module @stdlib/object/assign\n*\n* @example\n* import assign from '@stdlib/object/assign';\n*\n* var out = assign( {}, { 'foo': 'bar' }, { 'baz': 'beep' } );\n* // returns { 'foo': 'bar', 'baz': 'beep' }\n*/\n\n// MODULES //\n\nimport hasObjectAssign from './has_object_assign.js';\nimport main from './builtin.js';\nimport polyfill from './polyfill.js';\n\n\n// MAIN //\n\nvar assign;\nif ( hasObjectAssign ) {\n\tassign = main;\n} else {\n\tassign = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array of an object's own symbol properties.\n*\n* ## Notes\n*\n* - In contrast to the built-in `Object.getOwnPropertySymbols()`, this function returns an empty array if provided `undefined` or `null`, rather than throwing an error.\n*\n* @private\n* @param {*} value - input object\n* @returns {EmptyArray} a list of own symbol properties\n*\n* @example\n* var symbols = getOwnPropertySymbols( {} );\n* // returns []\n*/\nfunction getOwnPropertySymbols() {\n\treturn [];\n}\n\n\n// EXPORTS //\n\nexport default getOwnPropertySymbols;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport keys from './../../keys';\nimport propertySymbols from './../../property-symbols';\nimport isEnumerable from '@stdlib/assert/is-enumerable-property';\n\n\n// MAIN //\n\n/**\n* Returns an array of an object's own enumerable property names and symbols.\n*\n* @param {*} value - input object\n* @returns {Array} a list of own property enumerable names and symbols\n*\n* @example\n* var obj = {\n* 'beep': 'boop',\n* 'foo': 3.14\n* };\n*\n* var props = enumerableProperties( obj );\n* // e.g., returns [ 'beep', 'foo' ]\n*/\nfunction enumerableProperties( value ) {\n\tvar out;\n\tvar tmp;\n\tvar i;\n\n\tout = keys( value );\n\ttmp = propertySymbols( value );\n\tfor ( i = 0; i < tmp.length; i++ ) {\n\t\tif ( isEnumerable( value, tmp[ i ] ) ) {\n\t\t\tout.push( tmp[ i ] );\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default enumerableProperties;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport enumerableProperties from '@stdlib/utils/enumerable-properties';\nimport Object from './../../ctor';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Copies own enumerable properties from source objects to a target object.\n*\n* ## Notes\n*\n* - If a property key is present in multiple sources, the property from the last source that defines the key prevails.\n* - The target object is mutated.\n* - Both string and symbol properties are copied.\n*\n* @param {Object} target - target object\n* @param {...Object} source - source object(s)\n* @throws {TypeError} first argument must not be null or undefined\n* @returns {Object} target object\n*\n* @example\n* var obj1 = {\n* 'a': 'beep'\n* };\n* var obj2 = {\n* 'b': 'boop'\n* };\n*\n* var out = assign( obj1, obj2 );\n* // returns { 'a': 'beep', 'b': 'boop' }\n*/\nfunction assign( target ) {\n\tvar source;\n\tvar keys;\n\tvar key;\n\tvar len;\n\tvar to;\n\tvar i;\n\tvar j;\n\tif ( target === void 0 || target === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a non-null object. Value: `%s`.', target ) );\n\t}\n\tto = Object( target );\n\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\tsource = arguments[ i ];\n\t\tif ( source === void 0 || source === null ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tkeys = enumerableProperties( Object( source ) );\n\t\tlen = keys.length;\n\t\tfor ( j = 0; j < len; j++ ) {\n\t\t\tkey = keys[ j ];\n\t\t\tto[ key ] = source[ key ];\n\t\t}\n\t}\n\treturn to;\n}\n\n\n// EXPORTS //\n\nexport default assign;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\n\n\n// FUNCTIONS //\n\n/**\n* Normalizes values assigned to complex number arrays.\n*\n* @private\n* @param {*} value - input value\n* @returns {(ComplexLike|*)} output value\n*/\nfunction wrapComplex( value ) {\n\t// Wrap real-valued scalars as valid input arguments to complex number arrays...\n\tif ( isNumber( value ) ) {\n\t\treturn [ value, 0.0 ]; // note: we're assuming that a ComplexXXArray setter accepts an array of interleaved real and imaginary components\n\t}\n\t// For everything other than a real-valued scalar, we delegate validation to the target complex number array:\n\treturn value;\n}\n\n\n// MAIN //\n\n/**\n* Returns a wrapper function for processing scalar input values before assignment.\n*\n* @private\n* @param {string} dtype - array data type\n* @returns {(Function|null)} wrapper function or null\n*/\nfunction wrapper( dtype ) {\n\tif ( isComplexDataType( dtype ) ) {\n\t\treturn wrapComplex;\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default wrapper;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a wrapper function for processing arrays after retrieval.\n*\n* @private\n* @param {Function} array2fancy - function for creating a proxied array\n* @param {Object} opts - options\n* @param {boolean} opts.strict - boolean indicating whether to perform strict bounds checking\n* @param {Function} opts.cache - cache for resolving array index objects\n* @returns {Function} wrapper function\n*/\nfunction wrapper( array2fancy, opts ) {\n\treturn wrap;\n\n\t/**\n\t* Returns a proxied array.\n\t*\n\t* @private\n\t* @param {Array} x - input array\n\t* @returns {Array} proxied array\n\t*/\n\tfunction wrap( x ) {\n\t\treturn array2fancy( x, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default wrapper;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Proxy from '@stdlib/proxy/ctor';\n\n\n// MAIN //\n\n/**\n* Boolean indicating if an environment has Proxy support.\n*\n* @private\n* @name hasSupport\n* @type {boolean}\n*/\nvar hasSupport = ( typeof Proxy === 'function' ); // NOTE: cannot use `@stdlib/assert/has-proxy-support` here, as that API uses code evaluation and might violate CSPs; consequently, this is a relatively weak check for proxy support\n\n\n// EXPORTS //\n\nexport default hasSupport;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isObject from '@stdlib/assert/is-plain-object';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport isMethodIn from '@stdlib/assert/is-method-in';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking\n* @param {Function} [options.cache] - cache for resolving array index objects\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'strict': false\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'strict' ) ) {\n\t\topts.strict = options.strict;\n\t\tif ( !isBoolean( opts.strict ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', opts.strict ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'cache' ) ) {\n\t\topts.cache = options.cache;\n\t\tif ( !isMethodIn( opts.cache, 'get' ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option is missing a `%s` method. Option: `%s`.', 'cache', 'get', opts.cache ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default validate;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from './../../is-function';\nimport Object from '@stdlib/object/ctor';\n\n\n// MAIN //\n\n/**\n* Tests if an object has a specified method name, either own or inherited.\n*\n* @param {*} value - value to test\n* @param {*} property - property to test\n* @returns {boolean} boolean indicating if an object has a specified method name\n*\n* @example\n* var beep = {\n* 'boop': true\n* };\n*\n* var bool = isMethodIn( beep, 'toString' );\n* // returns true\n*\n* bool = isMethodIn( beep, 'boop' );\n* // returns false\n*/\nfunction isMethodIn( value, property ) {\n\tif ( value === void 0 || value === null ) {\n\t\treturn false;\n\t}\n\tvalue = Object( value );\n\tif ( typeof property !== 'symbol' ) {\n\t\tproperty = String( property );\n\t}\n\treturn (\n\t\t( property in value ) &&\n\t\tisFunction( value[ property ] )\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isMethodIn;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport { isPrimitive as isBoolean } from '@stdlib/assert/is-boolean';\nimport isComplexLike from '@stdlib/assert/is-complex-like';\nimport isRealFloatingDataType from './../../base/assert/is-real-floating-point-data-type';\nimport isUnsignedIntegerDataType from './../../base/assert/is-unsigned-integer-data-type';\nimport isSignedIntegerDataType from './../../base/assert/is-signed-integer-data-type';\nimport isBooleanDataType from './../../base/assert/is-boolean-data-type';\nimport isSafeCast from './../../base/assert/is-safe-data-type-cast';\nimport minDataType from './../../min-dtype';\nimport minSignedIntegerDataType from './../../base/min-signed-integer-dtype';\nimport complexDataType from '@stdlib/complex/dtype';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a \"generic\" or unknown data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {null} null\n*\n* @example\n* var err = validateGeneric( 3, 'generic' );\n* // returns null\n*/\nfunction validateGeneric() {\n\treturn null;\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a boolean data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateBoolean( true, 'bool' );\n* // returns null\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var err = validateBoolean( new Complex128( 5.0, 6.0 ), 'bool' );\n* // returns \n*/\nfunction validateBoolean( value, dtype ) {\n\tif ( isBoolean( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a real-valued floating-point data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateRealFloating( 3.14, 'float64' );\n* // returns null\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var err = validateRealFloating( new Complex128( 5.0, 6.0 ), 'float64' );\n* // returns \n*/\nfunction validateRealFloating( value, dtype ) {\n\tif ( isNumber( value ) ) {\n\t\treturn null;\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a complex-valued floating-point data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* import Complex128 from '@stdlib/complex/float64/ctor';\n*\n* var err = validateComplexFloating( new Complex128( 5.0, 6.0 ), 'complex128' );\n* // returns null\n*\n* @example\n* var err = validateComplexFloating( {}, 'complex128' );\n* // returns \n*/\nfunction validateComplexFloating( value, dtype ) {\n\tif ( isNumber( value ) || isComplexLike( value ) ) {\n\t\treturn null;\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having a signed integer data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateSignedInteger( 3, 'int32' );\n* // returns null\n*\n* @example\n* var err = validateSignedInteger( 3.14, 'int32' );\n* // returns \n*/\nfunction validateSignedInteger( value, dtype ) {\n\tvar vdt;\n\tif ( isNumber( value ) ) {\n\t\tif ( !isInteger( value ) ) {\n\t\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', minDataType( value ), dtype ) );\n\t\t}\n\t\tvdt = minSignedIntegerDataType( value );\n\t\tif ( isSafeCast( vdt, dtype ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) );\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n/**\n* Verifies whether a provided value can be safely assigned to an element in an array having an unsigned integer data type.\n*\n* @private\n* @param {*} value - input value\n* @param {string} dtype - array data type\n* @returns {(Error|null)} error object or null\n*\n* @example\n* var err = validateUnsignedInteger( 3, 'uint32' );\n* // returns null\n*\n* @example\n* var err = validateUnsignedInteger( -3, 'uint32' );\n* // returns \n*/\nfunction validateUnsignedInteger( value, dtype ) {\n\tvar vdt;\n\tif ( isNumber( value ) ) {\n\t\tvdt = minDataType( value ); // note: we rely on data type resolution to handle the case where `value` is a non-integer value. In that case, `vdt` will resolve to a floating-point data type and `isSafeCast` will evaluate to `false`\n\t\tif ( isSafeCast( vdt, dtype ) ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) );\n\t}\n\tif ( isComplexLike( value ) ) {\n\t\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) );\n\t}\n\treturn new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) );\n}\n\n\n// MAIN //\n\n/**\n* Returns a validation function for verifying whether a provided value can be safely assigned to an element in an array having a specified data type.\n*\n* @private\n* @param {string} dtype - array data type\n* @returns {Function} validation function\n*\n* @example\n* var fcn = validator( 'int32' );\n*\n* var err = fcn( 3, 'int32' );\n* // returns null\n*\n* err = fcn( 3.14, 'int32' );\n* // returns \n*/\nfunction validator( dtype ) {\n\tif ( dtype === 'generic' || dtype === '' ) {\n\t\treturn validateGeneric;\n\t}\n\tif ( isRealFloatingDataType( dtype ) ) {\n\t\treturn validateRealFloating;\n\t}\n\tif ( isUnsignedIntegerDataType( dtype ) ) {\n\t\treturn validateUnsignedInteger;\n\t}\n\tif ( isSignedIntegerDataType( dtype ) ) {\n\t\treturn validateSignedInteger;\n\t}\n\tif ( isBooleanDataType( dtype ) ) {\n\t\treturn validateBoolean;\n\t}\n\t// Case: isComplexDataType( dtype ) === true\n\treturn validateComplexFloating;\n}\n\n\n// EXPORTS //\n\nexport default validator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns a trap for constructing new array instances.\n*\n* @private\n* @param {Function} array2fancy - function for creating a proxied array\n* @param {Object} opts - options\n* @param {boolean} opts.strict - boolean indicating whether to perform strict bounds checking\n* @param {Function} opts.cache - cache for resolving array index objects\n* @returns {Function} handler\n*/\nfunction factory( array2fancy, opts ) {\n\treturn constructor;\n\n\t/**\n\t* Trap for constructing new array instances.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {Array} args - list of constructor arguments\n\t* @param {Object} newTarget - constructor that was originally called\n\t* @returns {*} new instance\n\t*/\n\tfunction constructor( target, args ) {\n\t\tvar x;\n\t\tvar a;\n\n\t\ta = args;\n\t\tswitch ( a.length ) {\n\t\tcase 0:\n\t\t\tx = new target();\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tx = new target( a[0] );\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tx = new target( a[0], a[1] );\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tx = new target( a[0], a[1], a[2] );\n\t\t\tbreak;\n\t\tcase 4:\n\t\t\tx = new target( a[0], a[1], a[2], a[3] );\n\t\t\tbreak;\n\t\tcase 5:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4] );\n\t\t\tbreak;\n\t\tcase 6:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5] );\n\t\t\tbreak;\n\t\tcase 7:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6] );\n\t\t\tbreak;\n\t\tcase 8:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7] );\n\t\t\tbreak;\n\t\tcase 9:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8] ); // eslint-disable-line max-len\n\t\t\tbreak;\n\t\tcase 10:\n\t\t\tx = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9] ); // eslint-disable-line max-len\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t// Fallback to using `apply`; however, some constructors may error if the constructor is not callable (i.e., if a constructor always requires `new`):\n\t\t\tx = target.apply( null, a );\n\t\t}\n\t\treturn array2fancy( x, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is an integer string.\n*\n* @private\n* @name RE_INTEGER\n* @type {RegExp}\n*\n* @example\n* var bool = RE_INTEGER.test( '10' );\n* // returns true\n*\n* @example\n* var bool = RE_INTEGER.test( '-1' );\n* // returns true\n*\n* @example\n* var bool = RE_INTEGER.test( '0:10:2' );\n* // returns false\n*/\nvar RE_INTEGER = /^-?[0-9]+$/;\n\n\n// EXPORTS //\n\nexport default RE_INTEGER;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport RE_INTEGER from './re_integer.js';\n\n\n// MAIN //\n\n/**\n* Tests if an indexing expression is an integer.\n*\n* @private\n* @param {(string|symbol)} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isIntegerString( '1' );\n* // returns true\n*\n* @example\n* var out = isIntegerString( ':' );\n* // returns false\n*/\nfunction isIntegerString( prop ) {\n\treturn ( isString( prop ) && RE_INTEGER.test( prop ) );\n}\n\n\n// EXPORTS //\n\nexport default isIntegerString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is a serialized array index.\n*\n* @private\n* @name RE_ARRAY_INDEX\n* @type {RegExp}\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( 'ArrayIndex<0>' );\n* // returns true\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( '0' );\n* // returns false\n*\n* @example\n* var bool = RE_ARRAY_INDEX.test( 'Slice(0,10,2)' );\n* // returns false\n*/\nvar RE_ARRAY_INDEX = /\\s*ArrayIndex<[^>]+>\\s*/;\n\n\n// EXPORTS //\n\nexport default RE_ARRAY_INDEX;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport RE_ARRAY_INDEX from './re_array_index.js';\n\n\n// MAIN //\n\n/**\n* Tests if an indexing expression is a serialized array index.\n*\n* @private\n* @param {(string|symbol)} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isArrayIndexString( 'ArrayIndex<0>' );\n* // returns true\n*\n* @example\n* var out = isArrayIndexString( ':' );\n* // returns false\n*/\nfunction isArrayIndexString( prop ) {\n\treturn ( isString( prop ) && RE_ARRAY_INDEX.test( prop ) );\n}\n\n\n// EXPORTS //\n\nexport default isArrayIndexString;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar bool = ( typeof String.prototype.trim !== 'undefined' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar trim = String.prototype.trim;\n\n\n// EXPORTS //\n\nexport default trim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from './../../../base/replace';\n\n\n// VARIABLES //\n\n// The following regular expression should suffice to polyfill (most?) all environments.\nvar RE = /^[\\u0020\\f\\n\\r\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]*([\\S\\s]*?)[\\u0020\\f\\n\\r\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]*$/;\n\n\n// MAIN //\n\n/**\n* Trims whitespace characters from the beginning and end of a string.\n*\n* @private\n* @param {string} str - input string\n* @returns {string} trimmed string\n*\n* @example\n* var out = trim( ' Whitespace ' );\n* // returns 'Whitespace'\n*\n* @example\n* var out = trim( '\\t\\t\\tTabs\\t\\t\\t' );\n* // returns 'Tabs'\n*\n* @example\n* var out = trim( '\\n\\n\\nNew Lines\\n\\n\\n' );\n* // returns 'New Lines'\n*/\nfunction trim( str ) {\n\treturn replace( str, RE, '$1' );\n}\n\n\n// EXPORTS //\n\nexport default trim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Trim whitespace characters from the beginning and end of a string.\n*\n* @module @stdlib/string/base/trim\n*\n* @example\n* import trim from '@stdlib/string/base/trim';\n*\n* var out = trim( ' Whitespace ' );\n* // returns 'Whitespace'\n*\n* out = trim( '\\t\\t\\tTabs\\t\\t\\t' );\n* // returns 'Tabs'\n*\n* out = trim( '\\n\\n\\nNew Lines\\n\\n\\n' );\n* // returns 'New Lines'\n*/\n\n// MODULES //\n\nimport HAS_BUILTIN from './has_builtin.js';\nimport check from './check.js';\nimport polyfill from './polyfill.js';\nimport main from './main.js';\n\n\n// MAIN //\n\nvar trim;\nif ( HAS_BUILTIN && check() ) {\n\ttrim = main;\n} else {\n\ttrim = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default trim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport trim from './builtin.js';\n\n\n// VARIABLES //\n\nvar str1 = ' \\n\\t\\r\\n\\f\\v\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff';\nvar str2 = '\\u180e';\n\n\n// MAIN //\n\n/**\n* Tests the built-in `String.prototype.trim()` implementation when provided whitespace.\n*\n* ## Notes\n*\n* - For context, see . In short, we can only rely on the built-in `trim` method when it does not consider the Mongolian space separator as whitespace.\n*\n* @private\n* @returns {boolean} boolean indicating whether the built-in implementation returns the expected value\n*\n* @example\n* var b = test();\n* // returns \n*/\nfunction test() {\n\treturn ( trim.call( str1 ) === '' ) && ( trim.call( str2 ) === str2 );\n}\n\n\n// EXPORTS //\n\nexport default test;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport builtin from './builtin.js';\n\n\n// MAIN //\n\n/**\n* Trims whitespace characters from the beginning and end of a string.\n*\n* @param {string} str - input string\n* @returns {string} trimmed string\n*\n* @example\n* var out = trim( ' Whitespace ' );\n* // returns 'Whitespace'\n*\n* @example\n* var out = trim( '\\t\\t\\tTabs\\t\\t\\t' );\n* // returns 'Tabs'\n*\n* @example\n* var out = trim( '\\n\\n\\nNew Lines\\n\\n\\n' );\n* // returns 'New Lines'\n*/\nfunction trim( str ) {\n\treturn builtin.call( str );\n}\n\n\n// EXPORTS //\n\nexport default trim;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport trim from '@stdlib/string/base/trim';\nimport format from '@stdlib/string/format';\n\n\n// FUNCTIONS //\n\n/**\n* Extracts an array index identifier from an array index indexing expression.\n*\n* @private\n* @param {string} str - input string\n* @returns {string} identifier\n*\n* @example\n* var str = 'ArrayIndex<0>';\n*\n* var id = getIdentifier( str );\n* // returns '0'\n*/\nfunction getIdentifier( str ) {\n\treturn str.substring( 11, str.length-1 ); // ArrayIndex => XX\n}\n\n\n// MAIN //\n\n/**\n* Converts an indexing expression to an array index.\n*\n* @private\n* @param {string} property - property name\n* @param {Object} cache - cache for resolving array index objects\n* @throws {Error} invalid array index\n* @returns {(Object|null)} index object (or null)\n*/\nfunction prop2array( property, cache ) {\n\tvar o = cache.get( getIdentifier( trim( property ) ) );\n\tif ( o === null ) {\n\t\tthrow new Error( format( 'invalid operation. Unable to resolve array index. Value: `%s`.', property ) );\n\t}\n\treturn o;\n}\n\n\n// EXPORTS //\n\nexport default prop2array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray/base/normalize-index';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Resolves an integer index from an integer string.\n*\n* @private\n* @param {string} str - integer string\n* @param {NonNegativeInteger} max - index upper bound (exclusive)\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {RangeError} index exceeds array bounds\n* @returns {integer} integer index\n*\n* @example\n* var idx = resolveIndex( '-1', 10, false );\n* // returns 9\n*\n* @example\n* var idx = resolveIndex( '-20', 10, false );\n* // returns -20\n*/\nfunction resolveIndex( str, max, strict ) {\n\tvar idx;\n\tvar i;\n\n\tidx = parseInt( str, 10 );\n\ti = normalizeIndex( idx, max-1 );\n\tif ( i === -1 ) {\n\t\tif ( strict ) {\n\t\t\tthrow new RangeError( format( 'invalid operation. Index exceeds array bounds.' ) );\n\t\t}\n\t\t// Return the non-normalized index, as this should fallback to default property handling and returning \"undefined\":\n\t\treturn idx;\n\t}\n\treturn i;\n}\n\n\n// EXPORTS //\n\nexport default resolveIndex;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport replace from '@stdlib/string/base/replace';\n\n\n// MAIN //\n\n/**\n* Returns an updated error message for trapped errors.\n*\n* @private\n* @param {string} msg - error message\n* @returns {string} updated message\n*/\nfunction errMessage( msg ) {\n\treturn replace( msg, /^invalid arguments?/, 'invalid operation' );\n}\n\n\n// EXPORTS //\n\nexport default errMessage;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Matches a subtraction operation following an 'end' character sequence.\n*\n* Regular expression: `/(?:\\s*-\\s*)(?=\\d+)(\\d+)?$/`\n*\n* - `(?:\\s*-\\s*)`\n*\n* - capture but do not remember a minus sign surrounded by any amount of whitespace\n*\n* - `(?=\\d+)`\n*\n* - but only match when the minus sign is followed by one or more digits\n*\n* - `(\\d+)`\n*\n* - capture one or more digits\n*\n* - `$`\n*\n* - end of input\n*\n* @private\n* @name RE_END_MINUS\n* @type {RegExp}\n*\n* @example\n* var m = 'end-2'.match( RE_END_MINUS );\n* // returns [...]\n*\n* var v = m[ 1 ];\n* // returns '2'\n*\n* m = 'end - 2'.match( RE_END_MINUS );\n* // returns [...]\n*\n* v = m[ 1 ];\n* // returns '2'\n*\n* m = 'end - 2.4'.match( RE_END_MINUS );\n* // returns null\n*/\nvar RE_END_MINUS = /(?:\\s*-\\s*)(?=\\d+)(\\d+)$/;\n\n\n// EXPORTS //\n\nexport default RE_END_MINUS;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Matches a division operation following an 'end' character sequence.\n*\n* Regular expression: `/(?:\\s*\\/\\s*)(?=\\d*\\.?\\d+)(\\d*\\.?\\d+)?$/`\n*\n* - `(?:\\s*\\/\\s*)`\n*\n* - capture but do not remember a divide sign surrounded by any amount of whitespace\n*\n* - `(?=\\d*\\.?\\d+)`\n*\n* - but only match when the minus divide is followed by one or more digits\n*\n* - `(\\d*\\.?\\d+)`\n*\n* - capture one or more digits\n*\n* - `$`\n*\n* - end of input\n*\n* @private\n* @name RE_END_DIVIDE\n* @type {RegExp}\n*\n* @example\n* var m = 'end/2'.match( RE_END_DIVIDE );\n* // returns [...]\n*\n* var v = m[ 1 ];\n* // returns '2'\n*\n* m = 'end / 2'.match( RE_END_DIVIDE );\n* // returns [...]\n*\n* v = m[ 1 ];\n* // returns '2'\n*\n* m = 'end / 2.4'.match( RE_END_DIVIDE );\n* // returns [...]\n*\n* v = m[ 1 ];\n* // returns '2.4'\n*/\nvar RE_END_DIVIDE = /(?:\\s*\\/\\s*)(?=\\d*\\.?\\d+)(\\d*\\.?\\d+)$/;\n\n\n// EXPORTS //\n\nexport default RE_END_DIVIDE;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport floor from '@stdlib/math/base/special/floor';\nimport RE_END_MINUS from './re_end_minus.js';\nimport RE_END_DIVIDE from './re_end_divide.js';\n\n\n// MAIN //\n\n/**\n* Resolves an \"end\" index.\n*\n* ## Notes\n*\n* - The function returns `-1` if provided an invalid character sequence.\n* - The function returns `-2` if the resolved end index is out-of-bounds.\n*\n* @private\n* @param {string} v - character sequence containing the \"end\" keyword\n* @param {NonNegativeInteger} len - maximum number of elements allowed in the slice\n* @param {boolean} decrement - boolean indicating whether a subsequence has a negative decrement\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @returns {NonNegativeInteger} end index (exclusive)\n*\n* @example\n* var idx = resolveEnd( 'end', 10, false, false );\n* // returns 10\n*\n* idx = resolveEnd( 'end', 10, true, false );\n* // returns 10\n*\n* @example\n* var idx = resolveEnd( 'end-1', 10, false, false );\n* // returns 9\n*\n* idx = resolveEnd( 'end-1', 10, true, false );\n* // returns 9\n*\n* @example\n* var idx = resolveEnd( 'end-2', 10, false, false );\n* // returns 8\n*\n* idx = resolveEnd( 'end-2', 10, true, false );\n* // returns 8\n*\n* @example\n* var idx = resolveEnd( 'end/2', 10, false, false );\n* // returns 5\n*\n* idx = resolveEnd( 'end/2', 10, true, false );\n* // returns 4\n*\n* @example\n* var idx = resolveEnd( 'end/2', 11, false, false );\n* // returns 5\n*\n* idx = resolveEnd( 'end/2', 11, true, false );\n* // returns 5\n*\n* @example\n* var idx = resolveEnd( 'end/3', 10, false, false );\n* // returns 3\n*\n* idx = resolveEnd( 'end/3', 10, true, false );\n* // returns 3\n*\n* @example\n* var idx = resolveEnd( 'end/3', 11, false, false );\n* // returns 3\n*\n* idx = resolveEnd( 'end/3', 11, true, false );\n* // returns 3\n*\n* @example\n* var idx = resolveEnd( 'end/4', 10, false, false );\n* // returns 2\n*\n* idx = resolveEnd( 'end/4', 10, true, false );\n* // returns 2\n*\n* @example\n* var idx = resolveEnd( 'end/4', 11, false, false );\n* // returns 2\n*\n* idx = resolveEnd( 'end/4', 11, true, false );\n* // returns 2\n*\n* @example\n* var idx = resolveEnd( 'end/5', 10, false, false );\n* // returns 2\n*\n* idx = resolveEnd( 'end/5', 10, true, false );\n* // returns 1\n*\n* @example\n* var idx = resolveEnd( 'end/5', 11, false, false );\n* // returns 2\n*\n* idx = resolveEnd( 'end/5', 11, true, false );\n* // returns 2\n*\n* @example\n* var idx = resolveEnd( 'end-20', 10, false, false );\n* // returns 0\n*\n* idx = resolveEnd( 'end-20', 10, true, false );\n* // returns 0\n*\n* idx = resolveEnd( 'end-20', 10, true, true );\n* // returns -2\n*\n* @example\n* var idx = resolveEnd( 'end*2', 10, false, false );\n* // returns -1\n*\n* idx = resolveEnd( 'end*2', 10, true, false );\n* // returns -1\n*\n* @example\n* var idx = resolveEnd( 'end+1', 10, false, false );\n* // returns -1\n*\n* idx = resolveEnd( 'end+1', 10, true, false );\n* // returns -1\n*\n* @example\n* var idx = resolveEnd( 'end/0.5', 10, false, false );\n* // returns -1\n*\n* idx = resolveEnd( 'end/0.5', 10, true, false );\n* // returns -1\n*\n* idx = resolveEnd( 'end/0.5', 10, true, true );\n* // returns -2\n*/\nfunction resolveEnd( v, len, decrement, strict ) {\n\tvar tmp;\n\n\t// Check for the simple case where \"end\" refers to the last index (exclusive)...\n\tif ( v === 'end' ) {\n\t\treturn len;\n\t}\n\t// Check for a subtraction operation (e.g., `end-2`)...\n\ttmp = v.match( RE_END_MINUS );\n\tif ( tmp ) {\n\t\tv = len - parseInt( tmp[ 1 ], 10 );\n\n\t\t// If the computed index exceeds the index bounds, clamp to the first index...\n\t\tif ( v < 0 ) {\n\t\t\tif ( strict ) {\n\t\t\t\treturn -2; // return out-of-bounds error code\n\t\t\t}\n\t\t\tv = 0;\n\t\t}\n\t\treturn v;\n\t}\n\t// Check for a division operation (e.g., `end/2`)...\n\ttmp = v.match( RE_END_DIVIDE );\n\tif ( tmp ) {\n\t\tv = parseFloat( tmp[ 1 ] );\n\t\tif ( v < 1.0 ) {\n\t\t\treturn ( strict ) ? -2 : -1; // if `end/x > end`, then need to return out-of-bounds error code\n\t\t}\n\t\t// Handle division differently for increasing and decreasing increments in order to preserve the `:n + n: = :` identity and to satisfy user expectation that symmetry be maintained. The main issue being that, e.g., given a length 10 subsequence, `end/2` will yield `5`. Hence, `:end/2 + end/2: = :5 + :5 = :` (i.e., the first five elements (0,1,2,3,4) and the second five elements (5,6,7,8,9)); however, if increasing and decreasing are treated the same, `:end/2:-1 + end/2::-1 = :5:-1 + 5::-1 = :`, but the elements are not the same (i.e., the first elements (9,8,7,6) and the second elements (5,4,3,2,1)), due to the non-inclusive aspect of `j` in `i:j:k`. The slight adjustment (`len-1`) yields `:4:-1 + 4::-1 = :` and the slices (9,8,7,6,5) and (4,3,2,1,0), which better matches user expectation. For a length 11 subsequence, we get (0,1,2,3,4) and (5,6,7,8,9,10) for an increasing increment and (10,9,8,7,6) and (5,4,3,2,1,0), which seems fine given asymmetry in both cases.\n\t\tif ( decrement && len > 0 && v !== 1.0 ) { // note: avoid violating `end/1 = end` identity\n\t\t\treturn floor( (len-1) / v );\n\t\t}\n\t\treturn floor( len / v );\n\t}\n\t// The use of \"end\" includes invalid/unsupported operations...\n\treturn -1;\n}\n\n\n// EXPORTS //\n\nexport default resolveEnd;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Matches a character sequence for a colon separator used within a provided subsequence string.\n*\n* Regular expression: `\\s*:\\s*`\n*\n* - `\\s*`\n*\n* - match zero or more whitespace characters\n*\n* - `:`\n*\n* - match the colon character exactly\n*\n* - `\\s*`\n*\n* - match zero or more whitespace characters\n*\n* ## Notes\n*\n* - The regular expression allows for whitespace to surround the `:` character in subsequence strings (e.g., '2 : 4 : 1' vs '2:4:1').\n*\n* @private\n* @name RE_COLON_SEP\n* @type {RegExp}\n*\n* @example\n* var parts = ':'.split( RE_COLON_SEP );\n* // returns [ '', '' ]\n*\n* parts = ' : '.split( RE_COLON_SEP );\n* // returns [ '', '' ]\n*/\nvar RE_COLON_SEP = /\\s*:\\s*/;\n\n\n// EXPORTS //\n\nexport default RE_COLON_SEP;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Matches a character sequence for an integer value.\n*\n* Regular expression: `/^[-+]?\\d+$/`\n*\n* - `^`\n*\n* - start of input\n*\n* - `[-+]?`\n*\n* - match a minus or plus sign (if present)\n*\n* - `\\d+`\n*\n* - match one or more digits\n*\n* - `$`\n*\n* - end of input\n*\n* @private\n* @name RE_INTEGER\n* @type {RegExp}\n*\n* @example\n* var bool = RE_INTEGER.test( '123' );\n* // returns true\n*\n* bool = RE_INTEGER.test( '12.3' );\n* // returns false\n*/\nvar RE_INTEGER = /^[-+]?[0-9]+$/;\n\n\n// EXPORTS //\n\nexport default RE_INTEGER;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Matches a character sequence which begins with 'end'.\n*\n* Regular expression: `/^end/`\n*\n* - `^`\n*\n* - start of input\n*\n* - `end`\n*\n* - match the character sequence 'end'\n*\n* @private\n* @name RE_END\n* @type {RegExp}\n*\n* @example\n* var bool = RE_END.test( 'end' );\n* // returns true\n*\n* bool = RE_END.test( 'foo end' );\n* // returns false\n*/\nvar RE_END = /^end/;\n\n\n// EXPORTS //\n\nexport default RE_END;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Slice from './../../../ctor';\nimport trim from '@stdlib/string/base/trim';\nimport resolveEnd from './resolve_end.js';\nimport RE_COLON_SEP from './re_colon_sep.js';\nimport RE_INTEGER from './re_integer.js';\nimport RE_END from './re_end.js';\nimport eInvalidSubsequence from './error_invalid_subsequence.js';\nimport eOutOfBounds from './error_out_of_bounds.js';\nimport eInvalidIncrement from './error_invalid_increment.js';\n\n\n// MAIN //\n\n/**\n* Converts a subsequence string to a Slice object.\n*\n* ## Notes\n*\n* - A subsequence string has the following format:\n*\n* ```text\n* ::\n* ```\n*\n* where\n*\n* - If an `increment` is not specified, the default increment is `1`. An increment of zero is **not** allowed.\n* - The `start` index is **inclusive**.\n* - The `stop` index is **exclusive**.\n* - Both `start` and `stop` indices are _optional_. If not provided, `start` and `stop` default to index extremes. Which extremes correspond to which index depends on whether the `increment` is positive or negative.\n* - Both `start` and `stop` can be negative; in which case, the corresponding index is resolved by subtracting the respective value from the provided length `len`.\n* - Both `start` and `stop` can use the `end` keyword (e.g., `end-2::2`, `end-3:`, etc), which supports basic subtraction and division.\n* - The `end` keyword resolves to the provided length `len`. Thus, `:-1` is equivalent to `:end-1`, `:-2` is equivalent to `:end-2`, and so on and so forth. The exception is when performing a division operation when the `increment` is less than zero; in which case, `end` is equal to `len-1` in order to preserve user expectations when `end/d` equals a whole number and slicing from right-to-left. The result from a division operation is **rounded down** to the nearest integer value.\n*\n* - When `strict` is `false`, the resolved slice start is clamped to the slice index bounds (i.e., `[0, len)`).\n*\n* - When `strict` is `false`, the resolved slice end is upper bound clamped to `len` (i.e., one greater than the last possible index).\n*\n* - When the increment is negative, the resolved slice end value may be `null`, thus indicating that a non-empty slice should include the first index.\n*\n* - The function ensures that results satisfy the convention that `:n` combined with `n:` is equivalent to `:` (i.e., selecting all elements).\n*\n* - When `len` is zero, the function always returns a Slice object equivalent to `0:0:`.\n*\n* - The function returns an error object if provided an invalid subsequence string.\n*\n* - If `strict` is `true`, the function returns an error object if provided a subsequence string which exceeds index bounds.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} len - maximum number of elements allowed in the slice\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @returns {(Slice|Object)} Slice object or an error object\n*\n* @example\n* var s = seq2slice( '0:10:1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( '::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 9\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( ':0:-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 9\n*\n* v = s.stop;\n* // returns 0\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( '4::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 4\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( '::', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( ':end:', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( 'end::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 9\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( 'end-2::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 8\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( 'end/2::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 4\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( 'end:end/2:-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 9\n*\n* v = s.stop;\n* // returns 4\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( ':end/2:-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 9\n*\n* v = s.stop;\n* // returns 4\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( ':end/2:1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 5\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( ':end/3', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 3\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( 'end/3::-1', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 3\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( 'end/3::', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 3\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( 'end/3::', 9, false );\n* // returns \n*\n* var v = s.start;\n* // returns 3\n*\n* v = s.stop;\n* // returns 9\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( 'end/3::-1', 9, false );\n* // returns \n*\n* var v = s.start;\n* // returns 2\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns -1\n*\n* @example\n* var s = seq2slice( '5:5', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 5\n*\n* v = s.stop;\n* // returns 5\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( '5:5', 0, false );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 0\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = seq2slice( 'end:', 10, false );\n* // returns \n*\n* var v = s.start;\n* // returns 10\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*/\nfunction seq2slice( str, len, strict ) {\n\tvar parts;\n\tvar N;\n\tvar v;\n\n\tparts = trim( str ).split( RE_COLON_SEP );\n\tN = parts.length;\n\n\t// Disallow providing standalone components (e.g., '1', 'end', etc) and strings having too many components (e.g., '1:2:3:4')...\n\tif ( N < 2 || N > 3 ) {\n\t\treturn eInvalidSubsequence();\n\t}\n\n\t/* Increment */\n\n\t// Process the increment...\n\tif ( N === 3 ) {\n\t\tv = parts[ 2 ];\n\t\tif ( v.length === 0 ) { // empty increment\n\t\t\tparts[ 2 ] = 1; // default increment\n\t\t} else {\n\t\t\tif ( RE_INTEGER.test( v ) === false ) {\n\t\t\t\treturn eInvalidSubsequence();\n\t\t\t}\n\t\t\tv = parseInt( v, 10 );\n\t\t\tif ( v === 0 ) {\n\t\t\t\treturn eInvalidIncrement(); // increment cannot be zero\n\t\t\t}\n\t\t\tparts[ 2 ] = v;\n\t\t}\n\t} else {\n\t\tparts.push( 1 ); // default increment\n\t}\n\n\t/* Starting Index */\n\n\t// Process the starting index...\n\tv = parts[ 0 ];\n\n\t// Case: empty starting index\n\tif ( v.length === 0 ) {\n\t\t// If the increment is negative, we need to iterate from the last index...\n\t\tif ( parts[ 2 ] < 0 && len > 0 ) {\n\t\t\tparts[ 0 ] = len - 1;\n\t\t} else {\n\t\t\tparts[ 0 ] = 0; // default starting index (inclusive)\n\t\t}\n\t}\n\t// Case: use of the \"end\" keyword\n\telse if ( RE_END.test( v ) ) {\n\t\tv = resolveEnd( v, len, parts[ 2 ] < 0, strict );\n\t\tif ( v < 0 ) {\n\t\t\tif ( v === -2 ) {\n\t\t\t\treturn eOutOfBounds();\n\t\t\t}\n\t\t\treturn eInvalidSubsequence();\n\t\t}\n\t\tif ( parts[ 2 ] < 0 && v >= len ) {\n\t\t\tv -= 1; // clamp to the last index\n\t\t}\n\t\tparts[ 0 ] = v;\n\t}\n\t// Case: integer character sequence\n\telse if ( RE_INTEGER.test( v ) ) {\n\t\tv = parseInt( v, 10 );\n\n\t\t// Check whether we need to resolve the starting index relative to the last index...\n\t\tif ( v < 0 ) {\n\t\t\tv = len + v;\n\n\t\t\t// If the computed index exceeds the index bounds, clamp to the first index...\n\t\t\tif ( v < 0 ) {\n\t\t\t\tif ( strict ) {\n\t\t\t\t\treturn eOutOfBounds();\n\t\t\t\t}\n\t\t\t\tv = 0;\n\t\t\t}\n\t\t}\n\t\t// If the index exceeds the index bounds, clamp to the starting index...\n\t\telse if ( v >= len ) {\n\t\t\tif ( strict ) {\n\t\t\t\treturn eOutOfBounds();\n\t\t\t}\n\t\t\t// If the increment is negative, clamp to the last index (inclusive)...\n\t\t\tif ( parts[ 2 ] < 0 ) {\n\t\t\t\tv = len - 1;\n\t\t\t}\n\t\t\t// If the increment is positive, clamp to the \"index\" following the last index...\n\t\t\telse {\n\t\t\t\tv = len;\n\t\t\t}\n\t\t}\n\t\tparts[ 0 ] = v;\n\t}\n\t// Case: invalid/unsupported characters/operations\n\telse {\n\t\treturn eInvalidSubsequence();\n\t}\n\n\t/* Ending Index */\n\n\t// Processing the ending index...\n\tv = parts[ 1 ];\n\n\t// Case: empty ending index\n\tif ( v.length === 0 ) {\n\t\t// If the increment is negative, we need to iterate toward the first index...\n\t\tif ( parts[ 2 ] < 0 ) {\n\t\t\tparts[ 1 ] = null;\n\t\t} else {\n\t\t\tparts[ 1 ] = len; // default ending index (exclusive)\n\t\t}\n\t}\n\t// Case: use of the \"end\" keyword\n\telse if ( RE_END.test( v ) ) {\n\t\tv = resolveEnd( v, len, parts[ 2 ] < 0, strict );\n\t\tif ( v < 0 ) {\n\t\t\tif ( v === -2 ) {\n\t\t\t\treturn eOutOfBounds();\n\t\t\t}\n\t\t\treturn eInvalidSubsequence();\n\t\t}\n\t\tparts[ 1 ] = v;\n\t}\n\t// Case: integer character sequence\n\telse if ( RE_INTEGER.test( v ) ) {\n\t\tv = parseInt( v, 10 );\n\n\t\t// Check whether we need to resolve the starting index relative to the last index...\n\t\tif ( v < 0 ) {\n\t\t\tv = len + v;\n\n\t\t\t// Check whether the computed index exceeds the index bounds...\n\t\t\tif ( v < 0 ) {\n\t\t\t\t// If the increment is positive, clamp the ending index to the first index (exclusive)...\n\t\t\t\tif ( parts[ 2 ] > 0 ) {\n\t\t\t\t\tif ( strict ) {\n\t\t\t\t\t\treturn eOutOfBounds();\n\t\t\t\t\t}\n\t\t\t\t\tv = 0;\n\t\t\t\t} else {\n\t\t\t\t\t// If the increment is negative, the ending index should resolve to the first index (inclusive)...\n\t\t\t\t\tif ( strict && v < -1 ) {\n\t\t\t\t\t\treturn eOutOfBounds();\n\t\t\t\t\t}\n\t\t\t\t\tv = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// If the index exceeds the index bounds, clamp to the last \"index\" (exclusive)...\n\t\telse if ( v > len ) {\n\t\t\tif ( strict ) {\n\t\t\t\treturn eOutOfBounds();\n\t\t\t}\n\t\t\tv = len;\n\t\t}\n\t\tparts[ 1 ] = v;\n\t}\n\t// Case: invalid/unsupported characters/operations\n\telse {\n\t\treturn eInvalidSubsequence();\n\t}\n\n\t// Handle empty slice (note: this is at the end rather than at the beginning in order to ensure that `start` and `stop` are always validated)...\n\tif ( len === 0 ) {\n\t\treturn new Slice( 0, 0, parts[ 2 ] );\n\t}\n\n\treturn new Slice( parts[ 0 ], parts[ 1 ], parts[ 2 ] );\n}\n\n\n// EXPORTS //\n\nexport default seq2slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an error object for an invalid subsequence string.\n*\n* @private\n* @returns {Object} error object\n*/\nfunction error() {\n\treturn {\n\t\t'code': 'ERR_SLICE_INVALID_SUBSEQUENCE'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default error;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an error object for a subsequence string containing a zero increment.\n*\n* @private\n* @returns {Object} error object\n*/\nfunction error() {\n\treturn {\n\t\t'code': 'ERR_SLICE_INVALID_INCREMENT'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default error;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an error object for a subsequence string resolving to a slice which exceeds index bounds.\n*\n* @private\n* @returns {Object} error object\n*/\nfunction error() {\n\treturn {\n\t\t'code': 'ERR_SLICE_OUT_OF_BOUNDS'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default error;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport trim from '@stdlib/string/base/trim';\nimport Slice from './../../../ctor';\n\n\n// VARIABLES //\n\nvar PREFIX = 'Slice(';\nvar NARGS = 3;\n\n/**\n* Regular expression matching the slice argument separator.\n*\n* @private\n* @name RE_SEP\n* @type {RegExp}\n*/\nvar RE_SEP = /\\s*,\\s*/;\n\n/**\n* Regular expression matching an integer value.\n*\n* @private\n* @name RE_INTEGER\n* @type {RegExp}\n*/\nvar RE_INTEGER = /^-?[0-9]+$/;\n\n\n// MAIN //\n\n/**\n* Parses a string-serialized Slice object.\n*\n* ## Notes\n*\n* - The function returns `null` if provided an invalid string.\n*\n* @param {string} str - input string\n* @returns {(Slice|null)} Slice object (or null)\n*\n* @example\n* var s = str2slice( 'Slice(null,null,null)' );\n* // returns \n*\n* var v = s.start;\n* // returns null\n*\n* v = s.stop;\n* // returns null\n*\n* v = s.step;\n* // returns null\n*\n* @example\n* var s = str2slice( 'Slice(0,10,1)' );\n* // returns \n*\n* var v = s.start;\n* // returns 0\n*\n* v = s.stop;\n* // returns 10\n*\n* v = s.step;\n* // returns 1\n*\n* @example\n* var s = str2slice( 'Slice(foo,bar)' );\n* // returns null\n*/\nfunction str2slice( str ) {\n\tvar args;\n\tvar arg;\n\tvar n;\n\tvar v;\n\tvar i;\n\tif ( str.substring( 0, PREFIX.length ) !== PREFIX ) {\n\t\treturn null;\n\t}\n\tn = str.length - 1;\n\tif ( str[ n ] !== ')' ) {\n\t\treturn null;\n\t}\n\tstr = trim( str.substring( PREFIX.length, n ) );\n\tstr = str.split( RE_SEP );\n\tif ( str.length !== NARGS ) {\n\t\treturn null;\n\t}\n\targs = [];\n\tfor ( i = 0; i < NARGS; i++ ) {\n\t\tv = str[ i ];\n\t\tif ( v === 'null' ) {\n\t\t\targ = null;\n\t\t} else if ( RE_INTEGER.test( v ) ) {\n\t\t\targ = parseInt( v, 10 );\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t\targs.push( arg );\n\t}\n\treturn new Slice( args[ 0 ], args[ 1 ], args[ 2 ] );\n}\n\n\n// EXPORTS //\n\nexport default str2slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar bool = ( typeof String.prototype.startsWith !== 'undefined' );\n\n\n// EXPORTS //\n\nexport default bool;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\nvar startsWith = String.prototype.startsWith;\n\n\n// EXPORTS //\n\nexport default startsWith;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* Test if a string starts with the characters of another string.\n*\n* @module @stdlib/string/base/starts-with\n*\n* @example\n* import startsWith from '@stdlib/string/base/starts-with';\n*\n* var str = 'Fair is foul, and foul is fair, hover through fog and filthy air';\n* var bool = startsWith( str, 'Fair', 0 );\n* // returns true\n*\n* bool = startsWith( str, 'fair', 0 );\n* // returns false\n*\n* bool = startsWith( str, 'foul', 8 );\n* // returns true\n*\n* bool = startsWith( str, 'filthy', -10 );\n* // returns true\n*/\n\n// MODULES //\n\nimport HAS_BUILTIN from './has_builtin.js';\nimport polyfill from './polyfill.js';\nimport main from './main.js';\n\n\n// MAIN //\n\nvar startsWith;\nif ( HAS_BUILTIN ) {\n\tstartsWith = main;\n} else {\n\tstartsWith = polyfill;\n}\n\n\n// EXPORTS //\n\nexport default startsWith;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport builtin from './builtin.js';\n\n\n// MAIN //\n\n/**\n* Tests if a string starts with the characters of another string.\n*\n* @param {string} str - input string\n* @param {string} search - search string\n* @param {integer} position - position at which to start searching\n* @returns {boolean} boolean indicating if the input string starts with the search string\n*\n* @example\n* var bool = startsWith( 'Remember the story I used to tell you when you were a boy?', 'Remember', 0 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'Remember the story I used to tell you when you were a boy?', 'Remember, remember', 0 );\n* // returns false\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'To be', 0 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'to be', 0 );\n* // returns false\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'to be', 14 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'quest', -9 );\n* // returns true\n*/\nfunction startsWith( str, search, position ) {\n\tvar pos;\n\tif ( position < 0 ) {\n\t\tpos = str.length + position;\n\t} else {\n\t\tpos = position;\n\t}\n\tif ( search.length === 0 ) {\n\t\treturn true;\n\t}\n\tif (\n\t\tpos < 0 ||\n\t\tpos + search.length > str.length\n\t) {\n\t\treturn false;\n\t}\n\treturn builtin.call( str, search, pos );\n}\n\n\n// EXPORTS //\n\nexport default startsWith;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Tests if a string starts with the characters of another string.\n*\n* @private\n* @param {string} str - input string\n* @param {string} search - search string\n* @param {integer} position - position at which to start searching\n* @returns {boolean} boolean indicating if the input string starts with the search string\n*\n* @example\n* var bool = startsWith( 'Remember the story I used to tell you when you were a boy?', 'Remember', 0 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'Remember the story I used to tell you when you were a boy?', 'Remember, remember', 0 );\n* // returns false\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'To be', 0 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'to be', 0 );\n* // returns false\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'to be', 14 );\n* // returns true\n*\n* @example\n* var bool = startsWith( 'To be, or not to be, that is the question.', 'quest', -9 );\n* // returns true\n*/\nfunction startsWith( str, search, position ) {\n\tvar pos;\n\tvar i;\n\tif ( position < 0 ) {\n\t\tpos = str.length + position;\n\t} else {\n\t\tpos = position;\n\t}\n\tif ( search.length === 0 ) {\n\t\treturn true;\n\t}\n\tif (\n\t\tpos < 0 ||\n\t\tpos + search.length > str.length\n\t) {\n\t\treturn false;\n\t}\n\tfor ( i = 0; i < search.length; i++ ) {\n\t\tif ( str.charCodeAt( pos + i ) !== search.charCodeAt( i ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default startsWith;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Regular expression for testing whether a string is a subsequence string.\n*\n* @private\n* @name RE_SUBSEQ\n* @type {RegExp}\n*\n* @example\n* var bool = RE_SUBSEQ.test( '0:10:2' );\n* // returns true\n*\n* @example\n* var bool = RE_SUBSEQ.test( '0' );\n* // returns false\n*\n* @example\n* var bool = RE_SUBSEQ.test( 'Slice(0,10,2)' );\n* // returns false\n*/\nvar RE_SUBSEQ = /:/;\n\n\n// EXPORTS //\n\nexport default RE_SUBSEQ;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport trim from '@stdlib/string/base/trim';\nimport seq2slice from '@stdlib/slice/base/seq2slice';\nimport str2slice from '@stdlib/slice/base/str2slice';\nimport startsWith from '@stdlib/string/base/starts-with';\nimport format from '@stdlib/string/format';\nimport RE_SUBSEQ from './re_subseq.js';\n\n\n// FUNCTIONS //\n\n/**\n* Tests if an indexing expression is a serialized Slice object.\n*\n* @private\n* @param {string} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isSlice( 'Slice(null,null,1)' );\n* // returns true\n*\n* @example\n* var out = isSlice( ':' );\n* // returns false\n*/\nfunction isSlice( prop ) {\n\treturn (\n\t\tprop[ 0 ] === 'S' &&\n\t\tstartsWith( prop, 'Slice(', 0 ) &&\n\t\tprop[ prop.length-1 ] === ')'\n\t);\n}\n\n/**\n* Tests if an indexing expression is a subsequence.\n*\n* @private\n* @param {string} prop - property name\n* @returns {boolean} result\n*\n* @example\n* var out = isSubsequence( '::-2' );\n* // returns true\n*\n* @example\n* var out = isSubsequence( '-2' );\n* // returns false\n*/\nfunction isSubsequence( prop ) {\n\t// TODO: consider whether to make this check more robust (e.g., should we actually throw if someone tries to access `foo:bar`? If we make this check more exact, how would we distinguish between a non-existent `foo:bar` property and an actual error in the subsequence string?)\n\treturn RE_SUBSEQ.test( prop );\n}\n\n/**\n* Parses a serialized Slice object.\n*\n* @private\n* @param {string} raw - original unprocessed input string\n* @param {string} str - serialized Slice object\n* @throws {Error} invalid slice operation\n* @returns {Slice} Slice object\n*\n* @example\n* var s = parseSlice( ' Slice(null,null,1) ', 'Slice(null,null,1)' );\n* // returns \n*/\nfunction parseSlice( raw, str ) {\n\tvar s = str2slice( str );\n\tif ( s === null ) {\n\t\tthrow new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) );\n\t}\n\treturn s;\n}\n\n/**\n* Parses a subsequence string.\n*\n* @private\n* @param {string} raw - original unprocessed input string\n* @param {string} str - subsequence string\n* @param {NonNegativeInteger} max - index upper bound\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {Slice} Slice object\n*\n* @example\n* var s = parseSubsequence( ' ::-2 ', '::-2', 10, false );\n* // returns \n*/\nfunction parseSubsequence( raw, str, max, strict ) {\n\tvar s = seq2slice( str, max, true );\n\tif ( s.code ) {\n\t\tif ( s.code === 'ERR_SLICE_INVALID_INCREMENT' ) {\n\t\t\tthrow new Error( format( 'invalid operation. A subsequence increment must be a non-zero integer. Value: `%s`.', raw ) );\n\t\t}\n\t\tif ( s.code === 'ERR_SLICE_INVALID_SUBSEQUENCE' ) {\n\t\t\tthrow new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) );\n\t\t}\n\t\t// NOTE: the following error check must come last due to fall-through when in non-strict mode...\n\t\tif ( s.code === 'ERR_SLICE_OUT_OF_BOUNDS' ) {\n\t\t\tif ( strict ) {\n\t\t\t\tthrow new RangeError( format( 'invalid operation. Slice exceeds array bounds.' ) );\n\t\t\t}\n\t\t\t// Repeat parsing, this time allowing for out-of-bounds slices:\n\t\t\ts = seq2slice( str, max, false );\n\t\t}\n\t}\n\treturn s;\n}\n\n\n// MAIN //\n\n/**\n* Converts an indexing expression to a Slice object.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property name\n* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {(Slice|null)} slice object (or null)\n*/\nfunction prop2slice( target, property, strict ) {\n\tvar prop = trim( property );\n\tif ( isSlice( prop ) ) {\n\t\treturn parseSlice( property, prop );\n\t}\n\tif ( isSubsequence( prop ) ) {\n\t\treturn parseSubsequence( property, prop, target.length, strict );\n\t}\n\t// Everything else (including undefined/non-existent properties):\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default prop2slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport hasProperty from '@stdlib/assert/has-property';\nimport isIntegerString from './is_integer_string.js';\nimport isArrayIndexString from './is_array_index_string.js';\nimport getElements from './get_elements.js';\nimport getElement from './get_element.js';\nimport getValue from './get_value.js';\nimport getSlice from './get_slice.js';\n\n\n// MAIN //\n\n/**\n* Returns a trap for retrieving property values.\n*\n* @private\n* @param {Object} ctx - context object\n* @param {Function} ctx.getter - accessor for retrieving array elements\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.ctor - proxied array constructor\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @param {Object} ctx.cache - cache for resolving array index objects\n* @returns {Function} handler\n*/\nfunction factory( ctx ) {\n\treturn get;\n\n\t/**\n\t* Trap for retrieving property values.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {(string|symbol)} property - property name\n\t* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n\t* @throws {Error} invalid slice operation\n\t* @throws {RangeError} slice exceeds array bounds\n\t* @throws {RangeError} index exceeds array bounds\n\t* @returns {*} result\n\t*/\n\tfunction get( target, property, receiver ) {\n\t\tif ( isIntegerString( property ) ) {\n\t\t\treturn getElement( target, property, ctx );\n\t\t}\n\t\tif ( hasProperty( target, property ) || !isString( property ) ) {\n\t\t\treturn getValue( target, property, receiver, ctx );\n\t\t}\n\t\tif ( isArrayIndexString( property ) ) {\n\t\t\treturn getElements( target, property, ctx );\n\t\t}\n\t\treturn getSlice( target, property, ctx );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveIndex from './resolve_index.js';\n\n\n// MAIN //\n\n/**\n* Returns the element associated with a specified index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {Object} ctx - context object\n* @param {Function} ctx.getter - accessor for retrieving array elements\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @throws {RangeError} index exceeds array bounds\n* @returns {*} result\n*/\nfunction getElement( target, property, ctx ) {\n\treturn ctx.getter( target, resolveIndex( property, target.length, ctx.strict ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default getElement;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert/is-function';\n\n\n// MAIN //\n\n/**\n* Returns the property value associated with a specified property.\n*\n* @private\n* @param {Object} target - target object\n* @param {(string|symbol)} property - property\n* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n* @param {Object} ctx - context object\n* @param {Function} ctx.ctor - proxied array constructor\n* @returns {*} result\n*/\nfunction getValue( target, property, receiver, ctx ) {\n\tvar value = target[ property ];\n\tif ( isFunction( value ) ) {\n\t\tif ( value === target.constructor ) {\n\t\t\treturn ctx.ctor;\n\t\t}\n\t\treturn wrapper;\n\t}\n\treturn value;\n\n\t/**\n\t* Method wrapper.\n\t*\n\t* @private\n\t* @returns {*} results\n\t*/\n\tfunction wrapper() {\n\t\tvar args;\n\t\tvar i;\n\n\t\targs = [];\n\t\tfor ( i = 0; i < arguments.length; i++ ) {\n\t\t\targs.push( arguments[ i ] );\n\t\t}\n\t\treturn value.apply( ( this === receiver ) ? target : this, args ); // eslint-disable-line no-invalid-this\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport take from './../../take';\nimport mskfilter from './../../mskfilter';\nimport mskreject from './../../mskreject';\nimport format from '@stdlib/string/format';\nimport prop2array from './prop2array.js';\n\n\n// MAIN //\n\n/**\n* Returns the elements specified by an array index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {Object} ctx - context object\n* @param {Object} ctx.cache - cache for resolving array index objects\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @throws {Error} invalid array index\n* @throws {RangeError} index exceeds array bounds\n* @returns {Collection} result\n*/\nfunction getElements( target, property, ctx ) {\n\tvar idx = prop2array( property, ctx.cache );\n\tif ( idx.type === 'int' ) {\n\t\treturn ctx.postGetArray( take( target, idx.data ) );\n\t}\n\tif ( idx.type === 'bool' ) {\n\t\treturn ctx.postGetArray( mskfilter( target, idx.data ) );\n\t}\n\tif ( idx.type === 'mask' ) {\n\t\treturn ctx.postGetArray( mskreject( target, idx.data ) );\n\t}\n\tthrow new Error( format( 'invalid operation. Unrecognized array index type. Value: `%s`.', idx.type ) );\n}\n\n\n// EXPORTS //\n\nexport default getElements;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport slice from './../../base/fancy-slice';\nimport errMessage from './error_message.js';\nimport prop2slice from './prop2slice.js';\n\n\n// MAIN //\n\n/**\n* Returns a copy.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property name\n* @param {Object} ctx - context object\n* @param {Function} ctx.postGetArray - function to process a retrieved array\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @returns {(Collection|void)} result\n*/\nfunction getSlice( target, property, ctx ) {\n\tvar s = prop2slice( target, property, ctx.strict );\n\tif ( s === null ) {\n\t\t// Ensure consistency with normal array behavior by returning `undefined` for any \"unrecognized\" property name:\n\t\treturn;\n\t}\n\ttry {\n\t\treturn ctx.postGetArray( slice( target, s, ctx.strict ) );\n\t} catch ( err ) {\n\t\t// In principle, we should only error when in \"strict\" mode and a slice exceeds array bounds...\n\t\tthrow new err.constructor( errMessage( err.message ) );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default getSlice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets the value associated with a specified property.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - property\n* @param {*} value - new value\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setValue( target, property, value ) {\n\ttarget[ property ] = value;\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default setValue;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport hasProperty from '@stdlib/assert/has-property';\nimport isIntegerString from './is_integer_string.js';\nimport isArrayIndexString from './is_array_index_string.js';\nimport setElements from './set_elements.js';\nimport setElement from './set_element.js';\nimport setValue from './set_value.js';\nimport setSlice from './set_slice.js';\n\n\n// MAIN //\n\n/**\n* Returns a trap for setting property values.\n*\n* @private\n* @param {Object} ctx - context object\n* @param {string} ctx.dtype - array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.validator - function for validating new values\n* @param {Function} ctx.setter - accessor for setting array elements\n* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary)\n* @returns {Function} handler\n*/\nfunction factory( ctx ) {\n\treturn set;\n\n\t/**\n\t* Trap for setting property values.\n\t*\n\t* @private\n\t* @param {Object} target - target object\n\t* @param {(string|symbol)} property - property name\n\t* @param {*} value - new value\n\t* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n\t* @throws {Error} invalid slice operation\n\t* @throws {Error} assigned value must be broadcast compatible with output array view\n\t* @throws {TypeError} assigned value cannot be safely cast to the output array data type\n\t* @throws {TypeError} slice exceeds array bounds\n\t* @throws {TypeError} index exceeds array bounds\n\t* @returns {boolean} boolean indicating whether assignment succeeded\n\t*/\n\tfunction set( target, property, value, receiver ) {\n\t\tvar out;\n\n\t\t// Note that we need to check for an integer string *before* checking for an own property, as we want to explicitly handle *all* indexed properties, not just negative integers, in order to perform assignment validation...\n\t\tif ( isIntegerString( property ) ) {\n\t\t\treturn setElement( target, property, value, ctx );\n\t\t}\n\t\tif ( hasProperty( target, property ) || !isString( property ) ) {\n\t\t\treturn setValue( target, property, value, ctx );\n\t\t}\n\t\tif ( isArrayIndexString( property ) ) {\n\t\t\treturn setElements( target, property, value, ctx );\n\t\t}\n\t\tout = setSlice( target, property, value, receiver, ctx );\n\t\tif ( out ) {\n\t\t\treturn out;\n\t\t}\n\t\t// If we were unsuccessful (e.g., due to an invalid subsequence, etc), set the \"property\" in the same way as would any normal property (e.g., if an indexing expression is an invalid subsequence, assign as would a regular property: `i = 'a:b:c'` => `x[i] = 1` => `v = x[i]` => `v === 1`):\n\t\treturn setValue( target, property, value, ctx );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveIndex from './resolve_index.js';\n\n\n// MAIN //\n\n/**\n* Sets the element associated with a specified index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {*} value - new value\n* @param {Object} ctx - context object\n* @param {Function} ctx.setter - accessor for setting array elements\n* @param {string} ctx.dtype - target array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.validator - function for validating new values\n* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary)\n* @throws {TypeError} assigned value cannot be safely cast to the target array data type\n* @throws {TypeError} target array must have a supported data type\n* @throws {RangeError} index exceeds array bounds\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setElement( target, property, value, ctx ) {\n\tvar err;\n\tvar v;\n\n\terr = ctx.validator( value, ctx.dtype );\n\tif ( err ) {\n\t\tthrow err;\n\t}\n\tif ( ctx.preSetElement ) {\n\t\tv = ctx.preSetElement( value );\n\t} else {\n\t\tv = value;\n\t}\n\tctx.setter( target, resolveIndex( property, target.length, ctx.strict ), v ); // eslint-disable-line max-len\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default setElement;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isMostlySafeCast from './../../base/assert/is-mostly-safe-data-type-cast';\nimport isRealDataType from './../../base/assert/is-real-data-type';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isCollection from '@stdlib/assert/is-collection';\nimport scalar2array from './../../from-scalar';\nimport dtype from './../../dtype';\nimport put from './../../put';\nimport place from './../../place';\nimport convert from './../../convert';\nimport { assign as where } from './../../base/where';\nimport format from '@stdlib/string/format';\nimport prop2array from './prop2array.js';\nimport errMessage from './error_message.js';\n\n\n// MAIN //\n\n/**\n* Replaces the elements specified by an array index.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - index string\n* @param {*} value - new value(s)\n* @param {Object} ctx - context object\n* @param {string} ctx.dtype - array data type\n* @param {Object} ctx.cache - cache for resolving array index objects\n* @param {Function} ctx.validator - function for validating new values\n* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary)\n* @throws {Error} invalid array index\n* @throws {RangeError} index exceeds array bounds\n* @throws {Error} assigned value must be broadcast compatible with target array selection\n* @throws {TypeError} assigned value cannot be safely cast to the target array data type\n* @throws {TypeError} target array must have a supported data type\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setElements( target, property, value, ctx ) {\n\tvar tdt;\n\tvar vdt;\n\tvar idx;\n\tvar err;\n\tvar v;\n\n\tidx = prop2array( property, ctx.cache );\n\ttdt = ctx.dtype || 'generic';\n\tif ( isCollection( value ) ) {\n\t\t// When handling collections, we delegate to implementation APIs (see below) to perform argument validation (e.g., ensuring a (mostly) safe cast, broadcast compatibility, etc), so we just reassign the value here:\n\t\tv = value;\n\t} else {\n\t\t// When provided a \"scalar\", we need to check whether the value can be safely cast to the target array data type:\n\t\terr = ctx.validator( value, tdt );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\tif ( ctx.preSetElement ) {\n\t\t\tv = ctx.preSetElement( value );\n\t\t} else {\n\t\t\tv = value;\n\t\t}\n\t\t// As the scalar can be safely cast, convert the scalar to an array having the same data type as the target array to allow for broadcasting during assignment:\n\t\tv = scalar2array( v, tdt );\n\t\tvdt = tdt;\n\t}\n\tif ( idx.type === 'int' ) {\n\t\ttry {\n\t\t\tput( target, idx.data, v ); // note: defer to `put` for ensuring a mostly safe cast\n\t\t} catch ( err ) {\n\t\t\tthrow new err.constructor( errMessage( err.message ) );\n\t\t}\n\t\treturn true;\n\t}\n\tif ( idx.type === 'bool' ) {\n\t\ttry {\n\t\t\tplace( target, idx.data, v, {\n\t\t\t\t'mode': 'strict_broadcast'\n\t\t\t});\n\t\t} catch ( err ) {\n\t\t\tthrow new err.constructor( errMessage( err.message ) );\n\t\t}\n\t\treturn true;\n\t}\n\tif ( vdt === void 0 ) {\n\t\tvdt = dtype( value ) || 'generic';\n\t}\n\t// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the target array data type is floating-point...\n\tif ( !isMostlySafeCast( vdt, tdt ) ) {\n\t\tthrow new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, tdt ) );\n\t}\n\t// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...\n\tif ( isComplexDataType( tdt ) && isRealDataType( vdt ) ) {\n\t\tv = convert( v, tdt );\n\t}\n\tif ( idx.type === 'mask' ) {\n\t\t// NOTE: we intentionally deviate from boolean array indexing here and interpret the mask as applying to both the target and values array, thus requiring that the assigned value array be broadcast compatible with the target array and NOT just the selected elements as in boolean array indexing\n\t\ttry {\n\t\t\twhere( idx.data, target, v, target, 1, 0 );\n\t\t} catch ( err ) {\n\t\t\tthrow new err.constructor( errMessage( err.message ) );\n\t\t}\n\t\treturn true;\n\t}\n\tthrow new Error( format( 'invalid operation. Unrecognized array index type. Value: `%s`.', idx.type ) );\n}\n\n\n// EXPORTS //\n\nexport default setElements;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport sliceAssign from './../../base/fancy-slice-assign';\nimport scalar2array from './../../from-scalar';\nimport prop2slice from './prop2slice.js';\nimport errMessage from './error_message.js';\n\n\n// MAIN //\n\n/**\n* Sets element values belonging to the array view specified by an indexing expression.\n*\n* @private\n* @param {Object} target - target object\n* @param {string} property - indexing expression\n* @param {*} value - new value\n* @param {Object} receiver - the proxy object or an object inheriting from the proxy\n* @param {Object} ctx - context object\n* @param {string} ctx.dtype - array data type\n* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking\n* @param {Function} ctx.validator - function for validating new values\n* @throws {Error} invalid slice operation\n* @throws {RangeError} slice exceeds array bounds\n* @throws {Error} assigned value must be broadcast compatible with target array view\n* @throws {TypeError} assigned value cannot be safely cast to the target array data type\n* @throws {TypeError} target array must have a supported data type\n* @returns {boolean} boolean indicating whether assignment succeeded\n*/\nfunction setSlice( target, property, value, receiver, ctx ) {\n\tvar err;\n\tvar s;\n\tvar v;\n\n\ts = prop2slice( target, property, ctx.strict );\n\tif ( s === null ) {\n\t\t// If unable to parse the property as an indexing expression, signal that we were unable to perform slice assignment:\n\t\treturn false;\n\t}\n\tif ( isCollection( value ) ) {\n\t\t// When handling collections, we delegate to `sliceAssign` (see below) to perform argument validation (e.g., ensuring a (mostly) safe cast, broadcast compatibility, etc), so we just reassign the value here:\n\t\tv = value;\n\t} else {\n\t\t// When provided a \"scalar\", we need to check whether the value can be safely cast to the target array data type:\n\t\terr = ctx.validator( value, ctx.dtype );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\t// As the scalar can be safely cast, convert the scalar to an array having the same data type as the target array to allow for broadcasting during slice assignment:\n\t\tv = scalar2array( value, ctx.dtype || 'generic' );\n\t}\n\ttry {\n\t\tsliceAssign( v, receiver, s, ctx.strict );\n\t} catch ( err ) {\n\t\tthrow new err.constructor( errMessage( err.message ) );\n\t}\n\treturn true;\n}\n\n\n// EXPORTS //\n\nexport default setSlice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport isArrayLike from '@stdlib/assert/is-array-like';\nimport Proxy from '@stdlib/proxy/ctor';\nimport arraylike2object from './../../base/arraylike2object';\nimport assign from '@stdlib/object/assign';\nimport format from '@stdlib/string/format';\nimport setElementWrapper from './set_element_wrapper.js';\nimport getArrayWrapper from './get_array_wrapper.js';\nimport hasProxySupport from './has_proxy_support.js';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\nimport validator from './validator.js';\nimport ctor from './ctor.js';\nimport get from './get.js';\nimport set from './set.js';\n\n\n// MAIN //\n\n/**\n* Returns a function for converting an array to an object supporting fancy indexing.\n*\n* @param {Options} options - function options\n* @param {boolean} [options.strict=false] - boolean indicating whether to enforce strict bounds checking by default\n* @param {Function} [options.cache] - default cache for resolving array index objects\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {Function} function for converting an array to an object supporting fancy indexing\n*\n* @example\n* var array2fancy = factory();\n*\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\nfunction factory() {\n\tvar OPTIONS;\n\tvar err;\n\n\tOPTIONS = defaults();\n\tif ( arguments.length ) {\n\t\terr = validate( OPTIONS, arguments[ 0 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\treturn array2fancy;\n\n\t/**\n\t* Converts an array to an object supporting fancy indexing.\n\t*\n\t* @private\n\t* @param {ArrayLike} x - input array\n\t* @param {Options} [options] - function options\n\t* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking\n\t* @param {Function} [options.cache] - cache for resolving array index objects\n\t* @throws {TypeError} first argument must be array-like\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {ArrayLike} fancy array\n\t*\n\t* @example\n\t* var x = [ 1, 2, 3, 4, 5, 6 ];\n\t*\n\t* var y = array2fancy( x );\n\t* // returns \n\t*\n\t* var z = y[ '1::2' ];\n\t* // returns [ 2, 4, 6 ]\n\t*\n\t* var len = z.length;\n\t* // returns 3\n\t*\n\t* var v = z[ 0 ];\n\t* // returns 2\n\t*\n\t* v = z[ 1 ];\n\t* // returns 4\n\t*\n\t* v = z[ 2 ];\n\t* // returns 6\n\t*/\n\tfunction array2fancy( x ) {\n\t\tvar opts;\n\t\tvar err;\n\t\tvar arr;\n\t\tvar dt;\n\t\tvar o;\n\t\tif ( !isArrayLike( x ) && !isCollection( x ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be array-like. Value: `%s`.', x ) );\n\t\t}\n\t\tif ( hasProxySupport ) {\n\t\t\topts = assign( {}, OPTIONS );\n\t\t\tif ( arguments.length > 1 ) {\n\t\t\t\terr = validate( opts, arguments[ 1 ] );\n\t\t\t\tif ( err ) {\n\t\t\t\t\tthrow err;\n\t\t\t\t}\n\t\t\t}\n\t\t\tarr = arraylike2object( x );\n\t\t\tdt = arr.dtype || '';\n\t\t\to = {\n\t\t\t\t'ref': x,\n\t\t\t\t'dtype': dt,\n\t\t\t\t'getter': arr.accessors[ 0 ],\n\t\t\t\t'setter': arr.accessors[ 1 ],\n\t\t\t\t'preSetElement': setElementWrapper( dt ),\n\t\t\t\t'postGetArray': getArrayWrapper( array2fancy, opts ),\n\t\t\t\t'cache': opts.cache,\n\t\t\t\t'strict': opts.strict,\n\t\t\t\t'validator': validator( dt ),\n\t\t\t\t'array2fancy': array2fancy,\n\t\t\t\t'ctor': new Proxy( x.constructor || Array, {\n\t\t\t\t\t'construct': ctor( array2fancy, opts )\n\t\t\t\t})\n\t\t\t};\n\t\t\treturn new Proxy( x, {\n\t\t\t\t'get': get( o ),\n\t\t\t\t'set': set( o )\n\t\t\t});\n\t\t}\n\t\t// TODO: replace with `@stdlib/console/warn` (or equivalent once available)\n\t\tconsole.warn( 'WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available.' ); // eslint-disable-line no-console\n\t\treturn x;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default factory;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ArrayIndex from './../../index';\n\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'cache': ArrayIndex,\n\t\t'strict': false\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isInteger from '@stdlib/math/base/assert/is-integer';\nimport MAX_LENGTH from '@stdlib/constants/array/max-array-length';\n\n\n// MAIN //\n\n/**\n* Tests if a value is array-like.\n*\n* @param {*} value - value to test\n* @returns {boolean} boolean indicating if a value is array-like\n*\n* @example\n* var bool = isArrayLike( [] );\n* // returns true\n*\n* @example\n* var bool = isArrayLike( { 'length': 10 } );\n* // returns true\n*/\nfunction isArrayLike( value ) {\n\treturn (\n\t\tvalue !== void 0 &&\n\t\tvalue !== null &&\n\t\ttypeof value !== 'function' &&\n\t\ttypeof value.length === 'number' &&\n\t\tisInteger( value.length ) &&\n\t\tvalue.length >= 0 &&\n\t\tvalue.length <= MAX_LENGTH\n\t);\n}\n\n\n// EXPORTS //\n\nexport default isArrayLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport factory from './factory.js';\n\n\n// MAIN //\n\n/**\n* Converts an array to an object supporting fancy indexing.\n*\n* @name array2fancy\n* @type {Function}\n* @param {ArrayLike} x - input array\n* @param {Options} [options] - function options\n* @param {boolean} [options.strict=false] - boolean indicating whether to enforce strict bounds checking\n* @param {Function} [options.cache] - cache for resolving array index objects\n* @throws {TypeError} first argument must be array-like\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayLike} fancy array\n*\n* @example\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\nvar array2fancy = factory();\n\n\n// EXPORTS //\n\nexport default array2fancy;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an array to an object supporting fancy indexing.\n*\n* @module @stdlib/array/to-fancy\n*\n* @example\n* import array2fancy from '@stdlib/array/to-fancy';\n*\n* var x = [ 1, 2, 3, 4, 5, 6 ];\n*\n* var y = array2fancy( x );\n* // returns \n*\n* var z = y[ '1::2' ];\n* // returns [ 2, 4, 6 ]\n*\n* var len = z.length;\n* // returns 3\n*\n* var v = z[ 0 ];\n* // returns 2\n*\n* v = z[ 1 ];\n* // returns 4\n*\n* v = z[ 2 ];\n* // returns 6\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport ArrayIndex from './../../index';\nimport main from './main.js';\nimport factory from './factory.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'factory', factory );\nsetReadOnly( main, 'idx', ArrayIndex );\n\n\n// EXPORTS //\n\nexport default main;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport ctors from './../../typed-ctors';\nimport reinterpret128 from '@stdlib/strided/base/reinterpret-complex128';\nimport reinterpret64 from '@stdlib/strided/base/reinterpret-complex64';\nimport reinterpretBoolean from '@stdlib/strided/base/reinterpret-boolean';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\nvar Complex64Array = ctors( 'complex64' );\nvar Complex128Array = ctors( 'complex128' );\nvar BooleanArray = ctors( 'bool' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} must provide a recognized data type\n* @returns {(ComplexArray|TypedArray)} typed array\n*\n* @example\n* var arr = typedarray();\n* // returns \n*\n* @example\n* var arr = typedarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = typedarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = typedarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = typedarray( [ 5, 3 ], 'int32' );\n* var arr2 = typedarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = typedarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = typedarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction typedarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\tvar arg;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\targ = arguments[ 0 ];\n\n\t\t// Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances...\n\t\tif ( arg instanceof Complex64Array ) {\n\t\t\targ = reinterpret64( arg, 0 );\n\t\t} else if ( arg instanceof Complex128Array ) {\n\t\t\targ = reinterpret128( arg, 0 );\n\t\t} else if ( arg instanceof BooleanArray ) {\n\t\t\targ = reinterpretBoolean( arg, 0 );\n\t\t}\n\t\treturn new ctor( arg );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default typedarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Complex128Array from './../../complex128';\nimport Complex64Array from './../../complex64';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'complex128': Complex128Array,\n\t'complex64': Complex64Array\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a complex typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'complex128' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport ctors from './../../typed-complex-ctors';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.complex_floating_point' );\n\n\n// MAIN //\n\n/**\n* Creates a complex number typed array.\n*\n* @param {(NonNegativeInteger|ComplexArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"complex128\"] - data type\n* @throws {TypeError} must provide a recognized data type\n* @returns {ComplexArray} typed array\n*\n* @example\n* var arr = complexarray();\n* // returns \n*\n* @example\n* var arr = complexarray( 2 );\n* // returns \n*\n* @example\n* var arr = complexarray( 2, 'complex64' );\n* // returns \n*\n* @example\n* var arr = complexarray( [ 0.5, 0.5 ] );\n* // returns \n*\n* @example\n* var arr = complexarray( [ 5.0, -3.0 ], 'complex64' );\n* // returns \n*\n* @example\n* var arr1 = complexarray( [ 5.0, 3.0 ], 'complex64' );\n* var arr2 = complexarray( arr1 );\n* // returns \n*\n* @example\n* var arr1 = complexarray( [ 5.0, 3.0 ], 'complex128' );\n* var arr2 = complexarray( arr1, 'complex64' );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = complexarray( buf );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = complexarray( buf, 'complex64' );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = complexarray( buf, 16 );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = complexarray( buf, 16, 'complex64' );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 64 );\n* var arr = complexarray( buf, 16, 2 );\n* // returns \n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 64 );\n* var arr = complexarray( buf, 16, 2, 'complex64' );\n* // returns \n*/\nfunction complexarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\treturn new ctor( arguments[0] );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default complexarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array,\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isString } from '@stdlib/assert/is-string';\nimport ctors from './../../typed-ctors';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.real' );\n\n\n// MAIN //\n\n/**\n* Creates a typed array.\n*\n* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} must provide a recognized data type\n* @returns {TypedArray} typed array\n*\n* @example\n* var arr = realarray();\n* // returns \n*\n* @example\n* var arr = realarray( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = realarray( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = realarray( [ 0.5, 0.5 ] );\n* // returns [ 0.5, 0.5 ]\n*\n* @example\n* var arr = realarray( [ 5, -3 ], 'int32' );\n* // returns [ 5, -3 ]\n*\n* @example\n* var arr1 = realarray( [ 5, 3 ], 'int32' );\n* var arr2 = realarray( arr1 );\n* // returns [ 5.0, 3.0 ]\n*\n* @example\n* var arr1 = realarray( [ 5, 3 ], 'int32' );\n* var arr2 = realarray( arr1, 'uint32' );\n* // returns [ 5, 3 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = realarray( buf );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = realarray( buf, 'float32' );\n* // returns [ 0.0, 0.0, 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = realarray( buf, 8 );\n* // returns [ 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = realarray( buf, 8, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = realarray( buf, 8, 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* import ArrayBuffer from '@stdlib/array/buffer';\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = realarray( buf, 8, 2, 'int32' );\n* // returns [ 0, 0 ]\n*/\nfunction realarray() {\n\tvar nargs;\n\tvar dtype;\n\tvar ctor;\n\n\tnargs = arguments.length;\n\tif ( nargs && isString( arguments[ nargs-1 ] ) ) {\n\t\tnargs -= 1;\n\t\tdtype = arguments[ nargs ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\tif ( nargs <= 0 ) {\n\t\treturn new ctor( 0 );\n\t}\n\tif ( nargs === 1 ) {\n\t\treturn new ctor( arguments[0] );\n\t}\n\tif ( nargs === 2 ) {\n\t\treturn new ctor( arguments[0], arguments[1] );\n\t}\n\treturn new ctor( arguments[0], arguments[1], arguments[2] );\n}\n\n\n// EXPORTS //\n\nexport default realarray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'float64': Float64Array,\n\t'float32': Float32Array,\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array,\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Float64Array from './../../float64';\nimport Float32Array from './../../float32';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'float64': Float64Array,\n\t'float32': Float32Array\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Int16Array from './../../int16';\nimport Int32Array from './../../int32';\nimport Int8Array from './../../int8';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport Uint16Array from './../../uint16';\nimport Uint32Array from './../../uint32';\nimport Uint8Array from './../../uint8';\nimport Uint8ClampedArray from './../../uint8c';\n\n\n// MAIN //\n\n// Mapping from data types to constructors...\nvar ctors = {\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray\n};\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport base from './../../base/zero-to';\nimport zeros from './../../zeros';\nimport defaults from './../../defaults';\nimport format from '@stdlib/string/format';\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero.\n*\n* @param {NonNegativeInteger} n - number of elements\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = zeroTo( 2 );\n* // returns [ 0.0, 1.0 ]\n*\n* @example\n* var arr = zeroTo( 2, 'float32' );\n* // returns [ 0.0, 1.0 ]\n*/\nfunction zeroTo( n ) {\n\tvar dtype;\n\tif ( !isNonNegativeInteger( n ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', n ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t\tif ( dtype === 'generic' ) {\n\t\t\treturn base( n );\n\t\t}\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\treturn base.assign( zeros( n, dtype ), 1, 0 ); // defer dtype validation to `zeros`\n}\n\n\n// EXPORTS //\n\nexport default zeroTo;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name MAX_ARRAY_LENGTH\n* @memberof ns\n* @readonly\n* @constant\n* @type {number}\n* @see {@link module:@stdlib/constants/array/max-array-length}\n*/\nimport MAX_ARRAY_LENGTH from './../../array/max-array-length';\nsetReadOnly( ns, 'MAX_ARRAY_LENGTH', MAX_ARRAY_LENGTH );\n\n/**\n* @name MAX_TYPED_ARRAY_LENGTH\n* @memberof ns\n* @readonly\n* @constant\n* @type {number}\n* @see {@link module:@stdlib/constants/array/max-typed-array-length}\n*/\nimport MAX_TYPED_ARRAY_LENGTH from './../../array/max-typed-array-length';\nsetReadOnly( ns, 'MAX_TYPED_ARRAY_LENGTH', MAX_TYPED_ARRAY_LENGTH );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.\n*/\n\n/*\n* The following modules are intentionally not exported: generic\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-read-only-property';\n\n\n// MAIN //\n\n/**\n* Top-level namespace.\n*\n* @namespace ns\n*/\nvar ns = {};\n\n/**\n* @name base\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/array/base}\n*/\nimport base from './../base';\nsetReadOnly( ns, 'base', base );\n\n/**\n* @name BooleanArray\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/bool}\n*/\nimport BooleanArray from './../bool';\nsetReadOnly( ns, 'BooleanArray', BooleanArray );\n\n/**\n* @name ArrayBuffer\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/buffer}\n*/\nimport ArrayBuffer from './../buffer';\nsetReadOnly( ns, 'ArrayBuffer', ArrayBuffer );\n\n/**\n* @name byteOrders\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/byte-orders}\n*/\nimport byteOrders from './../byte-orders';\nsetReadOnly( ns, 'byteOrders', byteOrders );\n\n/**\n* @name cartesianPower\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/cartesian-power}\n*/\nimport cartesianPower from './../cartesian-power';\nsetReadOnly( ns, 'cartesianPower', cartesianPower );\n\n/**\n* @name cartesianProduct\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/cartesian-product}\n*/\nimport cartesianProduct from './../cartesian-product';\nsetReadOnly( ns, 'cartesianProduct', cartesianProduct );\n\n/**\n* @name cartesianSquare\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/cartesian-square}\n*/\nimport cartesianSquare from './../cartesian-square';\nsetReadOnly( ns, 'cartesianSquare', cartesianSquare );\n\n/**\n* @name Complex64Array\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/complex64}\n*/\nimport Complex64Array from './../complex64';\nsetReadOnly( ns, 'Complex64Array', Complex64Array );\n\n/**\n* @name Complex128Array\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/complex128}\n*/\nimport Complex128Array from './../complex128';\nsetReadOnly( ns, 'Complex128Array', Complex128Array );\n\n/**\n* @name convert\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/convert}\n*/\nimport convert from './../convert';\nsetReadOnly( ns, 'convert', convert );\n\n/**\n* @name convertSame\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/convert-same}\n*/\nimport convertSame from './../convert-same';\nsetReadOnly( ns, 'convertSame', convertSame );\n\n/**\n* @name ctors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/ctors}\n*/\nimport ctors from './../ctors';\nsetReadOnly( ns, 'ctors', ctors );\n\n/**\n* @name DataView\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/dataview}\n*/\nimport DataView from './../dataview';\nsetReadOnly( ns, 'DataView', DataView );\n\n/**\n* @name datespace\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/datespace}\n*/\nimport datespace from './../datespace';\nsetReadOnly( ns, 'datespace', datespace );\n\n/**\n* @name defaults\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/defaults}\n*/\nimport defaults from './../defaults';\nsetReadOnly( ns, 'defaults', defaults );\n\n/**\n* @name dtype\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/dtype}\n*/\nimport dtype from './../dtype';\nsetReadOnly( ns, 'dtype', dtype );\n\n/**\n* @name dtypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/dtypes}\n*/\nimport dtypes from './../dtypes';\nsetReadOnly( ns, 'dtypes', dtypes );\n\n/**\n* @name empty\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/empty}\n*/\nimport empty from './../empty';\nsetReadOnly( ns, 'empty', empty );\n\n/**\n* @name emptyLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/empty-like}\n*/\nimport emptyLike from './../empty-like';\nsetReadOnly( ns, 'emptyLike', emptyLike );\n\n/**\n* @name filled\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/filled}\n*/\nimport filled from './../filled';\nsetReadOnly( ns, 'filled', filled );\n\n/**\n* @name filledBy\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/filled-by}\n*/\nimport filledBy from './../filled-by';\nsetReadOnly( ns, 'filledBy', filledBy );\n\n/**\n* @name fixedEndianFactory\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/fixed-endian-factory}\n*/\nimport fixedEndianFactory from './../fixed-endian-factory';\nsetReadOnly( ns, 'fixedEndianFactory', fixedEndianFactory );\n\n/**\n* @name Float32ArrayFE\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/fixed-endian-float32}\n*/\nimport Float32ArrayFE from './../fixed-endian-float32';\nsetReadOnly( ns, 'Float32ArrayFE', Float32ArrayFE );\n\n/**\n* @name Float64ArrayFE\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/fixed-endian-float64}\n*/\nimport Float64ArrayFE from './../fixed-endian-float64';\nsetReadOnly( ns, 'Float64ArrayFE', Float64ArrayFE );\n\n/**\n* @name Float32Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/float32}\n*/\nimport Float32Array from './../float32';\nsetReadOnly( ns, 'Float32Array', Float32Array );\n\n/**\n* @name Float64Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/float64}\n*/\nimport Float64Array from './../float64';\nsetReadOnly( ns, 'Float64Array', Float64Array );\n\n/**\n* @name iterator2array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/from-iterator}\n*/\nimport iterator2array from './../from-iterator';\nsetReadOnly( ns, 'iterator2array', iterator2array );\n\n/**\n* @name scalar2array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/from-scalar}\n*/\nimport scalar2array from './../from-scalar';\nsetReadOnly( ns, 'scalar2array', scalar2array );\n\n/**\n* @name full\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/full}\n*/\nimport full from './../full';\nsetReadOnly( ns, 'full', full );\n\n/**\n* @name fullLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/full-like}\n*/\nimport fullLike from './../full-like';\nsetReadOnly( ns, 'fullLike', fullLike );\n\n/**\n* @name incrspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/incrspace}\n*/\nimport incrspace from './../incrspace';\nsetReadOnly( ns, 'incrspace', incrspace );\n\n/**\n* @name ArrayIndex\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/index}\n*/\nimport ArrayIndex from './../index';\nsetReadOnly( ns, 'ArrayIndex', ArrayIndex );\n\n/**\n* @name Int8Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/int8}\n*/\nimport Int8Array from './../int8';\nsetReadOnly( ns, 'Int8Array', Int8Array );\n\n/**\n* @name Int16Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/int16}\n*/\nimport Int16Array from './../int16';\nsetReadOnly( ns, 'Int16Array', Int16Array );\n\n/**\n* @name Int32Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/int32}\n*/\nimport Int32Array from './../int32';\nsetReadOnly( ns, 'Int32Array', Int32Array );\n\n/**\n* @name linspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/linspace}\n*/\nimport linspace from './../linspace';\nsetReadOnly( ns, 'linspace', linspace );\n\n/**\n* @name littleEndianFactory\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/little-endian-factory}\n*/\nimport littleEndianFactory from './../little-endian-factory';\nsetReadOnly( ns, 'littleEndianFactory', littleEndianFactory );\n\n/**\n* @name Float32ArrayLE\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/little-endian-float32}\n*/\nimport Float32ArrayLE from './../little-endian-float32';\nsetReadOnly( ns, 'Float32ArrayLE', Float32ArrayLE );\n\n/**\n* @name Float64ArrayLE\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/little-endian-float64}\n*/\nimport Float64ArrayLE from './../little-endian-float64';\nsetReadOnly( ns, 'Float64ArrayLE', Float64ArrayLE );\n\n/**\n* @name logspace\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/logspace}\n*/\nimport logspace from './../logspace';\nsetReadOnly( ns, 'logspace', logspace );\n\n/**\n* @name minDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/min-dtype}\n*/\nimport minDataType from './../min-dtype';\nsetReadOnly( ns, 'minDataType', minDataType );\n\n/**\n* @name mostlySafeCasts\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/mostly-safe-casts}\n*/\nimport mostlySafeCasts from './../mostly-safe-casts';\nsetReadOnly( ns, 'mostlySafeCasts', mostlySafeCasts );\n\n/**\n* @name mskfilter\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/mskfilter}\n*/\nimport mskfilter from './../mskfilter';\nsetReadOnly( ns, 'mskfilter', mskfilter );\n\n/**\n* @name mskput\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/mskput}\n*/\nimport mskput from './../mskput';\nsetReadOnly( ns, 'mskput', mskput );\n\n/**\n* @name mskreject\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/mskreject}\n*/\nimport mskreject from './../mskreject';\nsetReadOnly( ns, 'mskreject', mskreject );\n\n/**\n* @name nans\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/nans}\n*/\nimport nans from './../nans';\nsetReadOnly( ns, 'nans', nans );\n\n/**\n* @name nansLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/nans-like}\n*/\nimport nansLike from './../nans-like';\nsetReadOnly( ns, 'nansLike', nansLike );\n\n/**\n* @name nextDataType\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/next-dtype}\n*/\nimport nextDataType from './../next-dtype';\nsetReadOnly( ns, 'nextDataType', nextDataType );\n\n/**\n* @name oneTo\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/one-to}\n*/\nimport oneTo from './../one-to';\nsetReadOnly( ns, 'oneTo', oneTo );\n\n/**\n* @name oneToLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/one-to-like}\n*/\nimport oneToLike from './../one-to-like';\nsetReadOnly( ns, 'oneToLike', oneToLike );\n\n/**\n* @name ones\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/ones}\n*/\nimport ones from './../ones';\nsetReadOnly( ns, 'ones', ones );\n\n/**\n* @name onesLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/ones-like}\n*/\nimport onesLike from './../ones-like';\nsetReadOnly( ns, 'onesLike', onesLike );\n\n/**\n* @name place\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/place}\n*/\nimport place from './../place';\nsetReadOnly( ns, 'place', place );\n\n/**\n* @name typedarraypool\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/pool}\n*/\nimport typedarraypool from './../pool';\nsetReadOnly( ns, 'typedarraypool', typedarraypool );\n\n/**\n* @name promotionRules\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/promotion-rules}\n*/\nimport promotionRules from './../promotion-rules';\nsetReadOnly( ns, 'promotionRules', promotionRules );\n\n/**\n* @name put\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/put}\n*/\nimport put from './../put';\nsetReadOnly( ns, 'put', put );\n\n/**\n* @name typedarrayReviver\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/reviver}\n*/\nimport typedarrayReviver from './../reviver';\nsetReadOnly( ns, 'typedarrayReviver', typedarrayReviver );\n\n/**\n* @name safeCasts\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/safe-casts}\n*/\nimport safeCasts from './../safe-casts';\nsetReadOnly( ns, 'safeCasts', safeCasts );\n\n/**\n* @name sameKindCasts\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/same-kind-casts}\n*/\nimport sameKindCasts from './../same-kind-casts';\nsetReadOnly( ns, 'sameKindCasts', sameKindCasts );\n\n/**\n* @name shape\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/shape}\n*/\nimport shape from './../shape';\nsetReadOnly( ns, 'shape', shape );\n\n/**\n* @name SharedArrayBuffer\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/shared-buffer}\n*/\nimport SharedArrayBuffer from './../shared-buffer';\nsetReadOnly( ns, 'SharedArrayBuffer', SharedArrayBuffer );\n\n/**\n* @name slice\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/slice}\n*/\nimport slice from './../slice';\nsetReadOnly( ns, 'slice', slice );\n\n/**\n* @name take\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/take}\n*/\nimport take from './../take';\nsetReadOnly( ns, 'take', take );\n\n/**\n* @name circarray2iterator\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-circular-iterator}\n*/\nimport circarray2iterator from './../to-circular-iterator';\nsetReadOnly( ns, 'circarray2iterator', circarray2iterator );\n\n/**\n* @name array2fancy\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-fancy}\n*/\nimport array2fancy from './../to-fancy';\nsetReadOnly( ns, 'array2fancy', array2fancy );\n\n/**\n* @name array2iterator\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-iterator}\n*/\nimport array2iterator from './../to-iterator';\nsetReadOnly( ns, 'array2iterator', array2iterator );\n\n/**\n* @name array2iteratorRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-iterator-right}\n*/\nimport array2iteratorRight from './../to-iterator-right';\nsetReadOnly( ns, 'array2iteratorRight', array2iteratorRight );\n\n/**\n* @name typedarray2json\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-json}\n*/\nimport typedarray2json from './../to-json';\nsetReadOnly( ns, 'typedarray2json', typedarray2json );\n\n/**\n* @name sparsearray2iterator\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-sparse-iterator}\n*/\nimport sparsearray2iterator from './../to-sparse-iterator';\nsetReadOnly( ns, 'sparsearray2iterator', sparsearray2iterator );\n\n/**\n* @name sparsearray2iteratorRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-sparse-iterator-right}\n*/\nimport sparsearray2iteratorRight from './../to-sparse-iterator-right';\nsetReadOnly( ns, 'sparsearray2iteratorRight', sparsearray2iteratorRight );\n\n/**\n* @name stridedarray2iterator\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-strided-iterator}\n*/\nimport stridedarray2iterator from './../to-strided-iterator';\nsetReadOnly( ns, 'stridedarray2iterator', stridedarray2iterator );\n\n/**\n* @name arrayview2iterator\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-view-iterator}\n*/\nimport arrayview2iterator from './../to-view-iterator';\nsetReadOnly( ns, 'arrayview2iterator', arrayview2iterator );\n\n/**\n* @name arrayview2iteratorRight\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/to-view-iterator-right}\n*/\nimport arrayview2iteratorRight from './../to-view-iterator-right';\nsetReadOnly( ns, 'arrayview2iteratorRight', arrayview2iteratorRight );\n\n/**\n* @name typedarray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed}\n*/\nimport typedarray from './../typed';\nsetReadOnly( ns, 'typedarray', typedarray );\n\n/**\n* @name complexarray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-complex}\n*/\nimport complexarray from './../typed-complex';\nsetReadOnly( ns, 'complexarray', complexarray );\n\n/**\n* @name complexarrayCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-complex-ctors}\n*/\nimport complexarrayCtors from './../typed-complex-ctors';\nsetReadOnly( ns, 'complexarrayCtors', complexarrayCtors );\n\n/**\n* @name complexarrayDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-complex-dtypes}\n*/\nimport complexarrayDataTypes from './../typed-complex-dtypes';\nsetReadOnly( ns, 'complexarrayDataTypes', complexarrayDataTypes );\n\n/**\n* @name typedarrayCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-ctors}\n*/\nimport typedarrayCtors from './../typed-ctors';\nsetReadOnly( ns, 'typedarrayCtors', typedarrayCtors );\n\n/**\n* @name typedarrayDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-dtypes}\n*/\nimport typedarrayDataTypes from './../typed-dtypes';\nsetReadOnly( ns, 'typedarrayDataTypes', typedarrayDataTypes );\n\n/**\n* @name floatarrayCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-float-ctors}\n*/\nimport floatarrayCtors from './../typed-float-ctors';\nsetReadOnly( ns, 'floatarrayCtors', floatarrayCtors );\n\n/**\n* @name floatarrayDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-float-dtypes}\n*/\nimport floatarrayDataTypes from './../typed-float-dtypes';\nsetReadOnly( ns, 'floatarrayDataTypes', floatarrayDataTypes );\n\n/**\n* @name intarrayCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-integer-ctors}\n*/\nimport intarrayCtors from './../typed-integer-ctors';\nsetReadOnly( ns, 'intarrayCtors', intarrayCtors );\n\n/**\n* @name intarrayDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-integer-dtypes}\n*/\nimport intarrayDataTypes from './../typed-integer-dtypes';\nsetReadOnly( ns, 'intarrayDataTypes', intarrayDataTypes );\n\n/**\n* @name realarray\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-real}\n*/\nimport realarray from './../typed-real';\nsetReadOnly( ns, 'realarray', realarray );\n\n/**\n* @name realarrayCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-real-ctors}\n*/\nimport realarrayCtors from './../typed-real-ctors';\nsetReadOnly( ns, 'realarrayCtors', realarrayCtors );\n\n/**\n* @name realarrayDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-real-dtypes}\n*/\nimport realarrayDataTypes from './../typed-real-dtypes';\nsetReadOnly( ns, 'realarrayDataTypes', realarrayDataTypes );\n\n/**\n* @name realarrayFloatCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-real-float-ctors}\n*/\nimport realarrayFloatCtors from './../typed-real-float-ctors';\nsetReadOnly( ns, 'realarrayFloatCtors', realarrayFloatCtors );\n\n/**\n* @name realarrayFloatDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-real-float-dtypes}\n*/\nimport realarrayFloatDataTypes from './../typed-real-float-dtypes';\nsetReadOnly( ns, 'realarrayFloatDataTypes', realarrayFloatDataTypes );\n\n/**\n* @name intarraySignedCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-signed-integer-ctors}\n*/\nimport intarraySignedCtors from './../typed-signed-integer-ctors';\nsetReadOnly( ns, 'intarraySignedCtors', intarraySignedCtors );\n\n/**\n* @name intarraySignedDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-signed-integer-dtypes}\n*/\nimport intarraySignedDataTypes from './../typed-signed-integer-dtypes';\nsetReadOnly( ns, 'intarraySignedDataTypes', intarraySignedDataTypes );\n\n/**\n* @name intarrayUnsignedCtors\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-unsigned-integer-ctors}\n*/\nimport intarrayUnsignedCtors from './../typed-unsigned-integer-ctors';\nsetReadOnly( ns, 'intarrayUnsignedCtors', intarrayUnsignedCtors );\n\n/**\n* @name intarrayUnsignedDataTypes\n* @memberof ns\n* @readonly\n* @type {Function}\n* @see {@link module:@stdlib/array/typed-unsigned-integer-dtypes}\n*/\nimport intarrayUnsignedDataTypes from './../typed-unsigned-integer-dtypes';\nsetReadOnly( ns, 'intarrayUnsignedDataTypes', intarrayUnsignedDataTypes );\n\n/**\n* @name Uint8Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/uint8}\n*/\nimport Uint8Array from './../uint8';\nsetReadOnly( ns, 'Uint8Array', Uint8Array );\n\n/**\n* @name Uint8ClampedArray\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/uint8c}\n*/\nimport Uint8ClampedArray from './../uint8c';\nsetReadOnly( ns, 'Uint8ClampedArray', Uint8ClampedArray );\n\n/**\n* @name Uint16Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/uint16}\n*/\nimport Uint16Array from './../uint16';\nsetReadOnly( ns, 'Uint16Array', Uint16Array );\n\n/**\n* @name Uint32Array\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/uint32}\n*/\nimport Uint32Array from './../uint32';\nsetReadOnly( ns, 'Uint32Array', Uint32Array );\n\n/**\n* @name zeroTo\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/zero-to}\n*/\nimport zeroTo from './../zero-to';\nsetReadOnly( ns, 'zeroTo', zeroTo );\n\n/**\n* @name zeroToLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/zero-to-like}\n*/\nimport zeroToLike from './../zero-to-like';\nsetReadOnly( ns, 'zeroToLike', zeroToLike );\n\n/**\n* @name zeros\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/zeros}\n*/\nimport zeros from './../zeros';\nsetReadOnly( ns, 'zeros', zeros );\n\n/**\n* @name zerosLike\n* @memberof ns\n* @readonly\n* @constructor\n* @see {@link module:@stdlib/array/zeros-like}\n*/\nimport zerosLike from './../zeros-like';\nsetReadOnly( ns, 'zerosLike', zerosLike );\n\n/**\n* @name constants\n* @memberof ns\n* @readonly\n* @type {Namespace}\n* @see {@link module:@stdlib/constants/array}\n*/\nimport constants from '@stdlib/constants/array';\nsetReadOnly( ns, 'constants', constants );\n\n\n// EXPORTS //\n\nexport default ns;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport base from './../../base/cartesian-power';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian power.\n*\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} n - power\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a nonnegative integer\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = cartesianPower( x, 2 );\n* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]\n*/\nfunction cartesianPower( x, n ) {\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isNonNegativeInteger( n ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', n ) );\n\t}\n\treturn base( x, n );\n}\n\n\n// EXPORTS //\n\nexport default cartesianPower;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/cartesian-product';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian product.\n*\n* @param {Collection} x1 - first input array\n* @param {Collection} x2 - second input array\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x1 = [ 1, 2, 3 ];\n* var x2 = [ 4, 5 ];\n*\n* var out = cartesianProduct( x1, x2 );\n* // returns [ [ 1, 4 ], [ 1, 5 ], [ 2, 4 ], [ 2, 5 ], [ 3, 4 ], [ 3, 5 ] ]\n*/\nfunction cartesianProduct( x1, x2 ) {\n\tif ( !isCollection( x1 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x1 ) );\n\t}\n\tif ( !isCollection( x2 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', x2 ) );\n\t}\n\treturn base( x1, x2 );\n}\n\n\n// EXPORTS //\n\nexport default cartesianProduct;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/cartesian-square';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns the Cartesian square.\n*\n* @param {Collection} x - input array\n* @throws {TypeError} first argument must be a collection\n* @returns {Array} list of ordered tuples comprising the Cartesian product\n*\n* @example\n* var x = [ 1, 2 ];\n*\n* var out = cartesianSquare( x );\n* // returns [ [ 1, 1 ], [ 1, 2 ], [ 2, 1 ], [ 2, 2 ] ]\n*/\nfunction cartesianSquare( x ) {\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\treturn base( x );\n}\n\n\n// EXPORTS //\n\nexport default cartesianSquare;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport getType from './../../dtype';\nimport convert from './../../convert';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Converts an array to the same data type as a second input array.\n*\n* @param {Collection} x - array to convert\n* @param {(Array|TypedArray|ComplexArray)} y - array having the desired output data type\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must have a recognized data type\n* @returns {(Array|TypedArray|ComplexArray)} output array\n*\n* @example\n* import Float64Array from '@stdlib/array/float64';\n*\n* var x = [ 1.0, 2.0, 3.0, 4.0 ];\n* var y = new Float64Array( 0 );\n*\n* var out = convertSame( x, y );\n* // returns [ 1.0, 2.0, 3.0, 4.0 ]\n*/\nfunction convertSame( x, y ) {\n\tvar dtype = getType( y );\n\tif ( dtype === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must have a recognized/supported data type. Type: `%s`. Value: `%s`.', dtype, y ) );\n\t}\n\treturn convert( x, dtype );\n}\n\n\n// EXPORTS //\n\nexport default convertSame;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dtype from './../../dtype';\nimport empty from './../../empty';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Creates an uninitialized array having the same length and data type as a provided input array.\n*\n* @param {(Array|TypedArray|ComplexArray)} x - input array\n* @param {string} [dtype] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = emptyLike( [ 0.0, 0.0 ] );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = emptyLike( [ 0.0, 0.0 ], 'float32' );\n* // returns \n*/\nfunction emptyLike( x ) {\n\tvar dt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t}\n\treturn empty( x.length, dt );\n}\n\n\n// EXPORTS //\n\nexport default emptyLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isIteratorLike from '@stdlib/assert/is-iterator-like';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport accessorSetter from './../../base/accessor-setter';\nimport setter from './../../base/setter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Creates (or fills) an array from an iterator.\n*\n* @param {Iterator} iterator - source iterator\n* @param {Collection} [out] - output array\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} iterator argument must be an iterator\n* @throws {TypeError} callback argument must be a function\n* @returns {Collection} output array\n*\n* @example\n* import randu from '@stdlib/random/iter/randu';\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\nimport dtype from './../../dtype';\nimport full from './../../full';\nimport Complex128 from '@stdlib/complex/float64/ctor';\nimport Complex64 from '@stdlib/complex/float32/ctor';\n\n\n// MAIN //\n\n/**\n* Creates a filled array having the same length and data type as a provided input array.\n*\n* @param {(Array|TypedArray|ComplexArray)} x - input array\n* @param {number} value - fill value\n* @param {string} [dtype] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} third argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = fullLike( [ 0.0, 0.0 ], 1.0 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var arr = fullLike( [ 0.0, 0.0 ], 1.0, 'float32' );\n* // returns [ 1.0, 1.0 ]\n*/\nfunction fullLike( x, value ) {\n\tvar dt;\n\tvar v;\n\n\tdt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 2 ) {\n\t\tdt = arguments[ 2 ];\n\t}\n\tif ( typeof value === 'number' ) {\n\t\tif ( dt === 'complex128' ) {\n\t\t\tv = new Complex128( value, 0.0 );\n\t\t} else if ( dt === 'complex64' ) {\n\t\t\tv = new Complex64( value, 0.0 );\n\t\t} else {\n\t\t\tv = value;\n\t\t}\n\t} else {\n\t\tv = value;\n\t}\n\treturn full( x.length, v, dt );\n}\n\n\n// EXPORTS //\n\nexport default fullLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport ceil from '@stdlib/math/base/special/ceil';\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport format from '@stdlib/string/format';\nimport MAX_LENGTH from '@stdlib/constants/uint32/max';\nimport gen from './../../base/incrspace';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array using a provided increment.\n*\n* @param {number} x1 - first array value\n* @param {number} x2 - array element bound\n* @param {number} [increment=1] - increment\n* @throws {TypeError} first argument must be numeric\n* @throws {TypeError} second argument must be numeric\n* @throws {TypeError} third argument must be numeric\n* @throws {RangeError} length of created array must be less than `4294967295` (`2**32 - 1`)\n* @returns {Array} linearly spaced numeric array\n*\n* @example\n* var arr = incrspace( 0, 11, 2 );\n* // returns [ 0, 2, 4, 6, 8, 10 ]\n*/\nfunction incrspace( x1, x2, increment ) {\n\tvar len;\n\tvar inc;\n\tif ( !isNumber( x1 ) || isnan( x1 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Start must be numeric. Value: `%s`.', x1 ) );\n\t}\n\tif ( !isNumber( x2 ) || isnan( x2 ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Stop must be numeric. Value: `%s`.', x2 ) );\n\t}\n\tif ( arguments.length < 3 ) {\n\t\tinc = 1;\n\t} else {\n\t\tinc = increment;\n\t\tif ( !isNumber( inc ) || isnan( inc ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Increment must be numeric. Value: `%s`.', inc ) );\n\t\t}\n\t}\n\tlen = ceil( ( x2-x1 ) / inc );\n\tif ( len > MAX_LENGTH ) {\n\t\tthrow new RangeError( 'invalid arguments. Generated array exceeds maximum array length.' );\n\t}\n\treturn gen( x1, x2, inc );\n}\n\n\n// EXPORTS //\n\nexport default incrspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport { isPrimitive as isNumber } from '@stdlib/assert/is-number';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport format from '@stdlib/string/format';\nimport isnan from '@stdlib/math/base/assert/is-nan';\nimport gen from './../../base/logspace';\n\n\n// MAIN //\n\n/**\n* Generates a logarithmically spaced numeric array.\n*\n* @param {number} a - exponent of start value\n* @param {number} b - exponent of end value\n* @param {NonNegativeInteger} [len=10] - length of output array\n* @throws {TypeError} first argument must be numeric\n* @throws {TypeError} second argument must be numeric\n* @throws {TypeError} third argument must be a nonnegative integer\n* @returns {Array} logarithmically spaced numeric array\n*\n* @example\n* var arr = logspace( 0, 2, 6 );\n* // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ]\n*/\nfunction logspace( a, b, len ) {\n\tif ( !isNumber( a ) || isnan( a ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Exponent of start value must be numeric. Value: `%s`.', a ) );\n\t}\n\tif ( !isNumber( b ) || isnan( b ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Exponent of stop value must be numeric. Value: `%s`.', b ) );\n\t}\n\tif ( arguments.length < 3 ) {\n\t\tlen = 10;\n\t} else if ( !isNonNegativeInteger( len ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) );\n\t}\n\treturn gen( a, b, len );\n}\n\n\n// EXPORTS //\n\nexport default logspace;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isMostlySafeCast from './../../base/assert/is-mostly-safe-data-type-cast';\nimport isRealDataType from './../../base/assert/is-real-data-type';\nimport isComplexDataType from './../../base/assert/is-complex-floating-point-data-type';\nimport isCollection from '@stdlib/assert/is-collection';\nimport base from './../../base/mskput';\nimport dtype from './../../dtype';\nimport convert from './../../convert';\nimport format from '@stdlib/string/format';\nimport defaults from './defaults.js';\nimport validate from './validate.js';\n\n\n// MAIN //\n\n/**\n* Replaces elements of an array with provided values according to a provided mask array.\n*\n* @param {Collection} x - input array\n* @param {Collection} mask - mask array\n* @param {Collection} values - values to set\n* @param {Options} [options] - function options\n* @param {string} [options.mode='repeat'] - string specifying behavior when the number of values does not equal the number of falsy mask values\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be a collection\n* @throws {TypeError} third argument must be a collection\n* @throws {TypeError} options argument must be an object\n* @throws {Error} must provide valid options\n* @throws {Error} insufficient values to satisfy mask array\n* @throws {Error} number of values does not equal the number of falsy mask values\n* @throws {TypeError} third argument cannot be safely cast to the data type of the first argument\n* @returns {Collection} input array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = [ 20, 30 ];\n*\n* var out = mskput( x, mask, values );\n* // returns [ 1, 20, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 1, 0, 0, 1 ];\n* var values = [ 30 ];\n*\n* var out = mskput( x, mask, values );\n* // returns [ 1, 30, 30, 4 ]\n*\n* var bool = ( out === x );\n* // returns true\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var mask = [ 0, 0, 1, 0 ];\n* var values = [ 20, 30 ];\n*\n* var out = mskput( x, mask, values );\n* // returns [ 20, 30, 3, 20 ]\n*\n* var bool = ( out === x );\n* // returns true\n*/\nfunction mskput( x, mask, values ) {\n\tvar opts;\n\tvar err;\n\tvar xdt;\n\tvar vdt;\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( !isCollection( mask ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) );\n\t}\n\tif ( !isCollection( values ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', values ) );\n\t}\n\topts = defaults();\n\tif ( arguments.length > 3 ) {\n\t\terr = validate( opts, arguments[ 3 ] );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\txdt = dtype( x ) || 'generic';\n\tvdt = dtype( values ) || 'generic';\n\n\t// Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the input array data type is floating-point...\n\tif ( !isMostlySafeCast( vdt, xdt ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].', vdt, xdt ) );\n\t}\n\t// When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array...\n\tif ( isComplexDataType( xdt ) && isRealDataType( vdt ) ) {\n\t\tvalues = convert( values, xdt );\n\t}\n\t// Replace values in the input array:\n\treturn base( x, mask, values, opts.mode );\n}\n\n\n// EXPORTS //\n\nexport default mskput;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns default options.\n*\n* @private\n* @returns {Object} default options\n*\n* @example\n* var o = defaults();\n* // returns {...}\n*/\nfunction defaults() {\n\treturn {\n\t\t'mode': 'repeat'\n\t};\n}\n\n\n// EXPORTS //\n\nexport default defaults;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport NEXT_DTYPES from './next_dtypes.json';\n\n\n// FUNCTIONS //\n\n/**\n* Generates a table.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( NEXT_DTYPES );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tout[ dtypes[i] ] = NEXT_DTYPES[ dtypes[i] ];\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns the next larger array data type of the same kind.\n*\n* @param {string} [dtype] - array data type\n* @returns {(Object|string|integer|null)} next larger data type(s) or null\n*\n* @example\n* var dt = nextDataType( 'float32' );\n* // returns 'float64'\n*/\nfunction nextDataType( dtype ) {\n\tif ( arguments.length === 0 ) {\n\t\treturn generateTable();\n\t}\n\tif ( hasOwnProp( NEXT_DTYPES, dtype ) ) {\n\t\treturn NEXT_DTYPES[ dtype ];\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default nextDataType;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport oneTo from './../../one-to';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array.\n*\n* @param {(TypedArray|Array|ComplexArray)} x - input array\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = oneToLike( [ 0.0, 0.0 ] );\n* // returns [ 1.0, 2.0 ]\n*\n* @example\n* var arr = oneToLike( [ 0.0, 0.0 ], 'float32' );\n* // returns [ 1.0, 2.0 ]\n*/\nfunction oneToLike( x ) {\n\tvar dt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t}\n\treturn oneTo( x.length, dt );\n}\n\n\n// EXPORTS //\n\nexport default oneToLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport objectKeys from '@stdlib/utils/keys';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport resolve from '@stdlib/strided/base/dtype-resolve-str';\nimport PROMOTION_RULES from './promotion_rules.json';\n\n\n// FUNCTIONS //\n\n/**\n* Generates a full table of promotion rules.\n*\n* @private\n* @returns {Object} table\n*/\nfunction generateFullTable() {\n\tvar dtypes;\n\tvar ntypes;\n\tvar out;\n\tvar tmp;\n\tvar dt1;\n\tvar dt2;\n\tvar o;\n\tvar j;\n\tvar i;\n\n\tout = {};\n\tdtypes = objectKeys( PROMOTION_RULES );\n\tntypes = dtypes.length;\n\tfor ( i = 0; i < ntypes; i++ ) {\n\t\tdt1 = dtypes[ i ];\n\t\to = PROMOTION_RULES[ dt1 ];\n\t\ttmp = {};\n\t\tfor ( j = 0; j < ntypes; j++ ) {\n\t\t\tdt2 = dtypes[ j ];\n\t\t\ttmp[ dt2 ] = o[ dt2 ];\n\t\t}\n\t\tout[ dt1 ] = tmp;\n\t}\n\treturn out;\n}\n\n\n// MAIN //\n\n/**\n* Returns the array data type with the smallest size and closest \"kind\" to which array data types can be safely cast.\n*\n* @param {*} [dtype1] - array data type value\n* @param {*} [dtype2] - array data type value\n* @returns {(Object|integer|string|null)} promotion rule(s) or null\n*\n* @example\n* var table = promotionRules();\n* // returns {...}\n*\n* @example\n* var dt = promotionRules( 'float32', 'uint32' );\n* // returns 'float64'\n*\n* @example\n* var dt = promotionRules( 'float32', 'foo' );\n* // returns null\n*/\nfunction promotionRules( dtype1, dtype2 ) {\n\tvar o;\n\tif ( arguments.length === 0 ) {\n\t\treturn generateFullTable();\n\t}\n\tdtype1 = resolve( dtype1 );\n\tif ( hasOwnProp( PROMOTION_RULES, dtype1 ) ) {\n\t\to = PROMOTION_RULES[ dtype1 ];\n\t\tdtype2 = resolve( dtype2 );\n\t\tif ( hasOwnProp( o, dtype2 ) ) {\n\t\t\treturn o[ dtype2 ];\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default promotionRules;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isArray from '@stdlib/assert/is-array';\nimport ctors from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Revives a JSON-serialized typed array.\n*\n* @param {string} key - key\n* @param {*} value - value\n* @returns {(*|TypedArray)} value or typed array\n*\n* @example\n* import parseJSON from '@stdlib/utils/parse-json';\n*\n* var str = '{\"type\":\"Float64Array\",\"data\":[5,3]}';\n*\n* var arr = parseJSON( str, reviveTypedArray );\n* // returns [ 5.0, 3.0 ]\n*/\nfunction reviveTypedArray( key, value ) {\n\tvar ctor;\n\tif (\n\t\tvalue &&\n\t\tvalue.type &&\n\t\tisArray( value.data )\n\t) {\n\t\tctor = ctors[ value.type ];\n\t\tif ( ctor ) {\n\t\t\treturn new ctor( value.data );\n\t\t}\n\t}\n\treturn value;\n}\n\n\n// EXPORTS //\n\nexport default reviveTypedArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport base from './../../base/slice';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns a shallow copy of a portion of an array.\n*\n* @param {Collection} x - input array\n* @param {integer} [start=0] - starting index (inclusive)\n* @param {integer} [end=x.length] - ending index (exclusive)\n* @throws {TypeError} first argument must be a collection\n* @throws {TypeError} second argument must be an integer\n* @throws {TypeError} third argument must be an integer\n* @returns {Collection} output array\n*\n* @example\n* var x = [ 1, 2, 3, 4 ];\n*\n* var out = slice( x, 1, 3 );\n* // returns [ 2, 3 ]\n*\n* var bool = ( out === x );\n* // returns false\n*\n* @example\n* import Int32Array from '@stdlib/array/int32';\n*\n* var x = new Int32Array( [ 1, 2, 3, 4 ] );\n*\n* var out = slice( x, 1, 3 );\n* // returns [ 2, 3 ]\n*\n* var bool = ( out === x );\n* // returns false\n*/\nfunction slice( x ) {\n\tvar start;\n\tvar end;\n\n\tif ( !isCollection( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tstart = arguments[ 1 ];\n\t\tif ( !isInteger( start ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) );\n\t\t}\n\t\tif ( arguments.length > 2 ) {\n\t\t\tend = arguments[ 2 ];\n\t\t\tif ( !isInteger( end ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) );\n\t\t\t}\n\t\t} else {\n\t\t\tend = x.length;\n\t\t}\n\t} else {\n\t\tstart = 0;\n\t\tend = x.length;\n\t}\n\treturn base( x, start, end );\n}\n\n\n// EXPORTS //\n\nexport default slice;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport hasOwnProp from '@stdlib/assert/has-own-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isObject from '@stdlib/assert/is-plain-object';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which repeatedly iterates over each element in an array-like object.\n*\n* @param {Collection} src - input value\n* @param {Options} [options] - function options\n* @param {NonNegativeInteger} [options.iter] - number of iterations\n* @param {integer} [options.dir=1] - iteration direction\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @throws {TypeError} callback argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = circarray2iterator( [ 1, 2, 3, 4 ] );\n*\n* var v = iter.next().value;\n* // returns 1\n*\n* v = iter.next().value;\n* // returns 2\n*\n* v = iter.next().value;\n* // returns 3\n*\n* // ...\n*/\nfunction circarray2iterator( src ) {\n\tvar thisArg;\n\tvar options;\n\tvar count;\n\tvar opts;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = {\n\t\t'iter': 1e308, // ~infinity\n\t\t'dir': 1 // left to right iteration\n\t};\n\tif ( arguments.length > 1 ) {\n\t\tif ( isObject( arguments[ 1 ] ) ) {\n\t\t\toptions = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t\tif ( hasOwnProp( options, 'iter' ) ) {\n\t\t\t\topts.iter = options.iter;\n\t\t\t\tif ( !isNonNegativeInteger( options.iter ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', options.iter ) );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\t\t\topts.dir = options.dir;\n\t\t\t\tif ( options.dir !== 1 && options.dir !== -1 ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', options.dir ) );\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either a function or an options object. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tcount = 0;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tif ( opts.dir === 1 ) {\n\t\t\ti = -1;\n\t\t\tsetReadOnly( iter, 'next', next1a );\n\t\t} else {\n\t\t\ti = src.length;\n\t\t\tsetReadOnly( iter, 'next', next1b );\n\t\t}\n\t} else if ( opts.dir === 1 ) {\n\t\ti = -1;\n\t\tsetReadOnly( iter, 'next', next2a );\n\t} else {\n\t\ti = src.length;\n\t\tsetReadOnly( iter, 'next', next2b );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1a() {\n\t\ti = (i+1) % src.length;\n\t\tcount += 1;\n\t\tif ( FLG || count > opts.iter || src.length === 0 ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, count, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1b() {\n\t\ti -= 1;\n\t\tif ( i < 0 ) {\n\t\t\ti += src.length;\n\t\t}\n\t\tcount += 1;\n\t\tif ( FLG || count > opts.iter || src.length === 0 ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, count, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2a() {\n\t\ti = (i+1) % src.length;\n\t\tcount += 1;\n\t\tif ( FLG || count > opts.iter || src.length === 0 ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2b() {\n\t\ti -= 1;\n\t\tif ( i < 0 ) {\n\t\t\ti += src.length;\n\t\t}\n\t\tcount += 1;\n\t\tif ( FLG || count > opts.iter || src.length === 0 ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn circarray2iterator( src, opts, fcn, thisArg );\n\t\t}\n\t\treturn circarray2iterator( src, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default circarray2iterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates over each element in an array-like object.\n*\n* @param {Collection} src - input value\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = array2iterator( [ 1, 2, 3, 4 ] );\n*\n* var v = iter.next().value;\n* // returns 1\n*\n* v = iter.next().value;\n* // returns 2\n*\n* v = iter.next().value;\n* // returns 3\n*\n* // ...\n*/\nfunction array2iterator( src ) {\n\tvar thisArg;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tfcn = arguments[ 1 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 2 ];\n\t}\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\ti += 1;\n\t\tif ( FLG || i >= src.length ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\ti += 1;\n\t\tif ( FLG || i >= src.length ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn array2iterator( src, fcn, thisArg );\n\t\t}\n\t\treturn array2iterator( src );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default array2iterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates from right to left over each element in an array-like object.\n*\n* ## Notes\n*\n* - For dynamic array resizing, the only behavior made intentionally consistent with iterating from left to right is when elements are pushed onto the beginning (end) of an array. In other words, iterating from left to right combined with `[].push()` is consistent with iterating from right to left combined with `[].unshift()`.\n*\n* @param {Collection} src - input value\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = array2iteratorRight( [ 1, 2, 3, 4 ] );\n*\n* var v = iter.next().value;\n* // returns 4\n*\n* v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 2\n*\n* // ...\n*/\nfunction array2iteratorRight( src ) {\n\tvar thisArg;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar len;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tfcn = arguments[ 1 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 2 ];\n\t}\n\tlen = src.length;\n\ti = len;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\ti += src.length - len - 1; // accounts for a dynamic array\n\t\tlen = src.length;\n\t\tif ( FLG || i < 0 ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\ti += src.length - len - 1; // accounts for a dynamic array\n\t\tlen = src.length;\n\t\tif ( FLG || i < 0 ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn array2iteratorRight( src, fcn, thisArg );\n\t\t}\n\t\treturn array2iteratorRight( src );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default array2iteratorRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates over each element in a sparse array-like object.\n*\n* @param {Collection} src - input value\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = sparsearray2iterator( [ 1, , 3, 4 ] );\n*\n* var v = iter.next().value;\n* // returns 1\n*\n* v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 4\n*/\nfunction sparsearray2iterator( src ) {\n\tvar thisArg;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tfcn = arguments[ 1 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 2 ];\n\t}\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\tvar len;\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tlen = src.length;\n\t\ti += 1;\n\t\twhile ( i < len && get( src, i ) === void 0 ) {\n\t\t\ti += 1;\n\t\t}\n\t\tif ( i >= len ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\tvar len;\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tlen = src.length;\n\t\ti += 1;\n\t\twhile ( i < len && get( src, i ) === void 0 ) {\n\t\t\ti += 1;\n\t\t}\n\t\tif ( i >= len ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn sparsearray2iterator( src, fcn, thisArg );\n\t\t}\n\t\treturn sparsearray2iterator( src );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default sparsearray2iterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates from right to left over each element in a sparse array-like object.\n*\n* ## Notes\n*\n* - For dynamic array resizing, the only behavior made intentionally consistent with iterating from left to right is when elements are pushed onto the beginning (end) of an array. In other words, iterating from left to right combined with `[].push()` is consistent with iterating from right to left combined with `[].unshift()`.\n*\n* @param {Collection} src - input value\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = sparsearray2iteratorRight( [ 1, , 3, 4 ] );\n*\n* var v = iter.next().value;\n* // returns 4\n*\n* v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 1\n*/\nfunction sparsearray2iteratorRight( src ) {\n\tvar thisArg;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar len;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tfcn = arguments[ 1 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 2 ];\n\t}\n\tlen = src.length;\n\ti = len;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\ti += src.length - len - 1; // accounts for a dynamic array\n\t\tlen = src.length;\n\t\twhile ( i >= 0 && get( src, i ) === void 0 ) {\n\t\t\ti -= 1;\n\t\t}\n\t\tif ( i < 0 ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\ti += src.length - len - 1; // accounts for a dynamic array\n\t\tlen = src.length;\n\t\twhile ( i >= 0 && get( src, i ) === void 0 ) {\n\t\t\ti -= 1;\n\t\t}\n\t\tif ( i < 0 ) {\n\t\t\tFLG = true;\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn sparsearray2iteratorRight( src, fcn, thisArg );\n\t\t}\n\t\treturn sparsearray2iteratorRight( src );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default sparsearray2iteratorRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert/is-nonnegative-integer';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates over elements in an array-like object according to specified stride parameters.\n*\n* @param {NonNegativeInteger} N - number of values to iterate\n* @param {Collection} src - input value\n* @param {integer} stride - stride length\n* @param {NonNegativeInteger} offset - starting index\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be an array-like object\n* @throws {TypeError} third argument must be an integer\n* @throws {TypeError} fourth argument must be a nonnegative integer\n* @throws {TypeError} fifth argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var values = [ 1, 2, 3, 4, 5, 6, 7, 8 ];\n*\n* var N = 4;\n* var stride = -2;\n* var offset = 6;\n*\n* var iter = stridedarray2iterator( N, values, stride, offset );\n*\n* var v = iter.next().value;\n* // returns 7\n*\n* v = iter.next().value;\n* // returns 5\n*\n* v = iter.next().value;\n* // returns 3\n*\n* // ...\n*/\nfunction stridedarray2iterator( N, src, stride, offset ) {\n\tvar thisArg;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar idx;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isNonNegativeInteger( N ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tif ( !isInteger( stride ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) );\n\t}\n\tif ( !isNonNegativeInteger( offset ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) );\n\t}\n\tif ( arguments.length > 4 ) {\n\t\tfcn = arguments[ 4 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 5 ];\n\t}\n\tidx = offset;\n\ti = -1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\tvar v;\n\t\ti += 1;\n\t\tif ( FLG || i >= N ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tv = fcn.call( thisArg, get( src, idx ), idx, i, src );\n\t\tidx += stride;\n\t\treturn {\n\t\t\t'value': v,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\tvar v;\n\t\ti += 1;\n\t\tif ( FLG || i >= N ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tv = get( src, idx );\n\t\tidx += stride;\n\t\treturn {\n\t\t\t'value': v,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn stridedarray2iterator( N, src, stride, offset, fcn, thisArg ); // eslint-disable-line max-len\n\t\t}\n\t\treturn stridedarray2iterator( N, src, stride, offset );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default stridedarray2iterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates over each element in an array-like object view.\n*\n* @param {Collection} src - input value\n* @param {integer} [begin=0] - starting index (inclusive)\n* @param {integer} [end=src.length] - ending index (non-inclusive)\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be either an integer (starting index) or a function\n* @throws {TypeError} third argument must be either an integer (ending index) or a function\n* @throws {TypeError} fourth argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = arrayview2iterator( [ 1, 2, 3, 4 ], 1, 3 );\n*\n* var v = iter.next().value;\n* // returns 2\n*\n* v = iter.next().value;\n* // returns 3\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nfunction arrayview2iterator( src ) {\n\tvar thisArg;\n\tvar begin;\n\tvar nargs;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar end;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 1 ) {\n\t\tbegin = 0;\n\t\tend = src.length;\n\t} else if ( nargs === 2 ) {\n\t\tif ( isFunction( arguments[ 1 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 1 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 1 ];\n\t\t}\n\t\tend = src.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 1 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = src.length;\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tthisArg = arguments[ 2 ];\n\t\t} else if ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = arguments[ 1 ];\n\t\t\tend = src.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 1 ];\n\t\t\tend = arguments[ 2 ];\n\t\t}\n\t} else { // nargs >= 4\n\t\tbegin = arguments[ 1 ];\n\t\tend = arguments[ 2 ];\n\t\tfcn = arguments[ 3 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (ending index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = src.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > src.length ) {\n\t\tend = src.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = src.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\ti = begin - 1;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', finish );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\ti += 1;\n\t\tif ( FLG || i >= end ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, i-begin, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\ti += 1;\n\t\tif ( FLG || i >= end ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction finish( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn arrayview2iterator( src, begin, end, fcn, thisArg );\n\t\t}\n\t\treturn arrayview2iterator( src, begin, end );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default arrayview2iterator;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils/define-nonenumerable-read-only-property';\nimport isFunction from '@stdlib/assert/is-function';\nimport isCollection from '@stdlib/assert/is-collection';\nimport { isPrimitive as isInteger } from '@stdlib/assert/is-integer';\nimport isAccessorArray from './../../base/assert/is-accessor-array';\nimport iteratorSymbol from '@stdlib/symbol/iterator';\nimport accessorGetter from './../../base/accessor-getter';\nimport getter from './../../base/getter';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates from right to left over each element in an array-like object view.\n*\n* @param {Collection} src - input value\n* @param {integer} [begin=0] - starting **view** index (inclusive)\n* @param {integer} [end=src.length] - ending **view** index (non-inclusive)\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} second argument must be either an integer (starting index) or a function\n* @throws {TypeError} third argument must be either an integer (ending index) or a function\n* @throws {TypeError} fourth argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 3 );\n*\n* var v = iter.next().value;\n* // returns 3\n*\n* v = iter.next().value;\n* // returns 2\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nfunction arrayview2iteratorRight( src ) {\n\tvar thisArg;\n\tvar begin;\n\tvar nargs;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar end;\n\tvar get;\n\tvar dt;\n\tvar i;\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\tnargs = arguments.length;\n\tif ( nargs === 1 ) {\n\t\tbegin = 0;\n\t\tend = src.length;\n\t} else if ( nargs === 2 ) {\n\t\tif ( isFunction( arguments[ 1 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tfcn = arguments[ 1 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 1 ];\n\t\t}\n\t\tend = src.length;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isFunction( arguments[ 1 ] ) ) {\n\t\t\tbegin = 0;\n\t\t\tend = src.length;\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tthisArg = arguments[ 2 ];\n\t\t} else if ( isFunction( arguments[ 2 ] ) ) {\n\t\t\tbegin = arguments[ 1 ];\n\t\t\tend = src.length;\n\t\t\tfcn = arguments[ 2 ];\n\t\t} else {\n\t\t\tbegin = arguments[ 1 ];\n\t\t\tend = arguments[ 2 ];\n\t\t}\n\t} else { // nargs >= 4\n\t\tbegin = arguments[ 1 ];\n\t\tend = arguments[ 2 ];\n\t\tfcn = arguments[ 3 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 4 ];\n\t}\n\tif ( !isInteger( begin ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be either an integer (starting view index) or a function. Value: `%s`.', begin ) );\n\t}\n\tif ( !isInteger( end ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Third argument must be either an integer (ending view index) or a function. Value: `%s`.', end ) );\n\t}\n\tif ( end < 0 ) {\n\t\tend = src.length + end;\n\t\tif ( end < 0 ) {\n\t\t\tend = 0;\n\t\t}\n\t} else if ( end > src.length ) {\n\t\tend = src.length;\n\t}\n\tif ( begin < 0 ) {\n\t\tbegin = src.length + begin;\n\t\tif ( begin < 0 ) {\n\t\t\tbegin = 0;\n\t\t}\n\t}\n\ti = end;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', finish );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\t// Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc):\n\tdt = dtype( src );\n\tif ( isAccessorArray( src ) ) {\n\t\tget = accessorGetter( dt );\n\t} else {\n\t\tget = getter( dt );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\ti -= 1;\n\t\tif ( FLG || i < begin ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': fcn.call( thisArg, get( src, i ), i, end-i-1, src ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\ti -= 1;\n\t\tif ( FLG || i < begin ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'value': get( src, i ),\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction finish( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn arrayview2iteratorRight( src, begin, end, fcn, thisArg );\n\t\t}\n\t\treturn arrayview2iteratorRight( src, begin, end );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default arrayview2iteratorRight;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of complex typed array data types.\n*\n* @returns {StringArray} list of complex typed array data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'complex64', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'complex_floating_point' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array data types.\n*\n* @returns {StringArray} list of typed array data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'float32', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'typed' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array floating-point data types.\n*\n* @returns {StringArray} list of typed array floating-point data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'float32', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'floating_point' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns an integer-valued typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'int32' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'int' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array integer data types.\n*\n* @returns {StringArray} list of typed array integer data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'int16', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'integer' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array real-valued data types.\n*\n* @returns {StringArray} list of typed array data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'float32', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'real' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a real-valued floating-point typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array real-valued floating-point data types.\n*\n* @returns {StringArray} list of typed array real-valued floating-point data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'float32', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'real_floating_point' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns a signed integer typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'int32' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'int' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array signed integer data types.\n*\n* @returns {StringArray} list of typed array signed integer data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'int16', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'signed_integer' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport table from './ctors.js';\n\n\n// MAIN //\n\n/**\n* Returns an unsigned integer typed array constructor.\n*\n* @param {string} dtype - data type\n* @returns {(Function|null)} constructor or null\n*\n* @example\n* var ctor = ctors( 'uint32' );\n* // returns \n*\n* @example\n* var ctor = ctors( 'uint' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\treturn table[ dtype ] || null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport dt from './../../dtypes';\n\n\n// MAIN //\n\n/**\n* Returns a list of typed array unsigned integer data types.\n*\n* @returns {StringArray} list of typed array unsigned integer data types\n*\n* @example\n* var list = dtypes();\n* // e.g., returns [ 'uint16', ... ]\n*/\nfunction dtypes() {\n\treturn dt( 'unsigned_integer' );\n}\n\n\n// EXPORTS //\n\nexport default dtypes;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport zeroTo from './../../zero-to';\nimport dtype from './../../dtype';\nimport format from '@stdlib/string/format';\n\n\n// MAIN //\n\n/**\n* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array.\n*\n* @param {(TypedArray|Array|ComplexArray)} x - input array\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = zeroToLike( [ 0.0, 0.0 ] );\n* // returns [ 0.0, 1.0 ]\n*\n* @example\n* var arr = zeroToLike( [ 0.0, 0.0 ], 'float32' );\n* // returns [ 0.0, 1.0 ]\n*/\nfunction zeroToLike( x ) {\n\tvar dt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t}\n\treturn zeroTo( x.length, dt );\n}\n\n\n// EXPORTS //\n\nexport default zeroToLike;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport format from '@stdlib/string/format';\nimport dtype from './../../dtype';\nimport zeros from './../../zeros';\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled array having the same length and data type as a provided input array.\n*\n* @param {(Array|TypedArray|ComplexArray)} x - input array\n* @param {string} [dtype] - data type\n* @throws {TypeError} first argument must be an array or typed array\n* @throws {TypeError} second argument must be a recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = zerosLike( [ 0.0, 0.0 ] );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = zerosLike( [ 0.0, 0.0 ], 'float32' );\n* // returns [ 0.0, 0.0 ]\n*/\nfunction zerosLike( x ) {\n\tvar dt = dtype( x ); // delegate input argument validation to dtype resolution\n\tif ( dt === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdt = arguments[ 1 ];\n\t}\n\treturn zeros( x.length, dt );\n}\n\n\n// EXPORTS //\n\nexport default zerosLike;\n"],"names":["main","Object","defineProperty","isNumber","value","zeros","n","i","out","zeroPad","str","width","right","negative","pad","length","startsWithMinus","substr","lowercase","String","prototype","toLowerCase","uppercase","toUpperCase","formatInteger","token","base","specifier","arg","parseInt","isFinite","Error","toString","precision","padRight","sign","alternate","call","charAt","abs","Math","replace","RE_EXP_POS_DIGITS","RE_EXP_NEG_DIGITS","RE_ONLY_DIGITS","RE_DIGITS_BEFORE_EXP","RE_TRAILING_PERIOD_ZERO","RE_PERIOD_ZERO_EXP","RE_ZERO_BEFORE_EXP","formatDouble","f","digits","toExponential","toFixed","toPrecision","spaces","fromCharCode","isArray","Array","isnan","initialize","flags","mapping","formatInterpolate","tokens","hasPeriod","flag","num","pos","j","TypeError","padZeros","indexOf","arguments","maxWidth","parseFloat","substring","RE","parse","match","formatTokenize","content","prev","exec","slice","lastIndex","push","format","args","tokenize","interpolate","apply","objectProtoype","toStr","defineGetter","__defineGetter__","defineSetter","__defineSetter__","lookupGetter","__lookupGetter__","lookupSetter","__lookupSetter__","err","hasDefinePropertySupport","builtin","obj","prop","descriptor","hasValue","hasGet","hasSet","__proto__","get","set","defineProperty$1","setReadOnly","configurable","enumerable","writable","setNonEnumerableReadOnly","TYPE","isAccessorArray","GETTERS","float64","arr","idx","float32","int32","int16","int8","uint32","uint16","uint8","uint8c","generic","default","getter","dtype","SETTERS","setter","complex128","complex64","FLG","Symbol","hasToStringTagSupport","toStringTag","has","hasOwnProperty","hasOwnProp","property","Sym","toStrTag","nativeClass","hasToStringTag","v","isOwn","tag","main$h","arrayfcn","predicate","len","isObjectLike","isBuffer","_isBuffer","constructor","reFunctionName","arrayfun","RE_FUNCTION_NAME","constructorName","name","ctor","REGEXP","ctor2dtypes","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray","Complex64Array","Complex128Array","BooleanArray","hasFloat64Array","hasFloat64ArraySupport","bool","GlobalFloat64Array","NaN","Float64Array$2","hasFloat32Array","FLOAT64_PINF","Number","POSITIVE_INFINITY","hasFloat32ArraySupport","GlobalFloat32Array","PINF","Float32Array$2","hasUint32Array","UINT32_MAX","hasUint32ArraySupport","GlobalUint32Array","Uint32Array$2","hasInt32Array","INT32_MAX","INT32_MIN","hasInt32ArraySupport","GlobalInt32Array","Int32Array$2","hasUint16Array","UINT16_MAX","hasUint16ArraySupport","GlobalUint16Array","Uint16Array$2","hasInt16Array","INT16_MAX","INT16_MIN","hasInt16ArraySupport","GlobalInt16Array","Int16Array$2","hasUint8Array","isUint8Array","UINT8_MAX","hasUint8ArraySupport","GlobalUint8Array","Uint8Array$2","hasUint8ClampedArray","hasUint8ClampedArraySupport","GlobalUint8ClampedArray","Uint8ClampedArray$2","hasInt8Array","INT8_MAX","INT8_MIN","hasInt8ArraySupport","GlobalInt8Array","Int8Array$2","main$7","test","isPrimitive","isObject","FLOAT64_NINF","NEGATIVE_INFINITY","floor","isInteger","x","NINF","isInt","valueOf","isNonNegativeInteger","MAX_ARRAY_LENGTH","isArrayLikeObject","MAX_LENGTH","MAX_TYPED_ARRAY_LENGTH","isCollection","hasArrayBuffer","ArrayBuffer","isArrayBuffer","isString","isPrimitiveArray","isObjectArray","isStringArray","isBoolean","Bool","Boolean","self","window","global","globalThis","root","codegen","Function","GlobalThis","Self","Win","Global","getGlobal","nodeList","document","childNodes","typedarray","ctorName","type","isFunction","typeOf","Complex128","real","imag","this","re","im","fround","Float32Array$1","FLOAT32_VIEW","f32","Complex64","float64ToFloat32","isComplexLike","isEven","BYTES_PER_ELEMENT","isComplex64Array","isComplex128Array","hasIteratorSymbolSupport","iterator","IteratorSymbol","setNonEnumerableReadOnlyAccessor","z","reinterpret","offset","buffer","byteOffset","Float64Array$1","fromIterator","it","next","done","realf","imagf","HAS_ITERATOR_SYMBOL","isComplexArray","_length","_buffer","isComplexArrayConstructor","getComplex64","buf","nargs","fromArray","RangeError","reinterpret64","reinterpret128","byteLength","ITERATOR_SYMBOL","src","thisArg","clbk","tmp","flg","accessorGetter","fromIteratorMap","target","start","copyWithin","iter","entries","end","fcn","searchElement","fromIndex","separator","sep","join","keys","outbuf","reducer","initialValue","acc","N","sbuf","outlen","compareFcn","sort","begin","locales","options","opts","loc","toLocaleString","values","index","getComplex128","isBooleanArray","isBooleanArrayConstructor","val","a","b","CTORS","DTYPES","NTYPES","ctor2dtype","accessors","dt","accessorProtocol","accessorSetter","AccessorArray","o","_getter","_setter","setNonEnumerableReadWriteAccessor","arraylike2object","data","Uint8Array$1","internal","resolveGetter","hasProp","contains","factory","isnanf","FLOAT32_SIGN_MASK","Uint32Array$1","UINT32_VIEW","toWordf","monotoneKey","word","SIGN_MASK","isAlmostEqualf","maxULP","y","wx","wy","FLOAT64_HIGH_WORD_SIGN_MASK","uint16view","Uint16Array$1","ctors","HIGH","LOW","IS_LITTLE_ENDIAN","isLittleEndian","indices$3","FLOAT64_VIEW","indices","toWords","stride","assign","WX","WY","WZ","TWO_32","words","negate","subtract","wa","wb","wc","ha","hb","la","lb","isAlmostEqual","ord","wz","reim","isAlmostEqualF64","z1","z2","parts1","reimf","parts2","isAlmostEqualF32","isAlmostEqualComplex64","isAlmostEqualComplex128","xdata","ydata","xget","yget","isSameValue","isSame","search","newval","RE_SUFFIX","dtypes","kind","all","isBooleanDataType","orders","ORDERS","isByteOrder","byteOrders","isComplexFloatingPointDataType","C64_BYTES_PER_ELEMENT","C128_BYTES_PER_ELEMENT","isComplexTypedArray","isDataType","isFloatingPointDataType","isIntegerDataType","isArguments","bool$h","detect","hasArgumentsClass","isNan","isEnumerableProperty","propertyIsEnumerable","hasStringEnumBug","isEnum","isArguments$1","isConstructorPrototype","w","hasAutomationEqualityBug","k","win","EXCLUDED_KEYS","check","HAS_BUILTIN","skipConstructor","skipPrototype","isFcn","p","HAS_ENUM_PROTO_BUG","HAS_NON_ENUM_PROPS_BUG","HAS_WINDOW","error","NON_ENUMERABLE","getProto","main$5","Obj","getPrototypeOf","proto","getProto$1","objectPrototype","isPlainObject","isPrototypeOf","key","ownProps","enumeration","int64","uint64","float16","complex32","binary","notype","userdefined_type","source","objectKeys","hash","allowDupes","duplicates","objectInverse","ENUM","resolve","t","str2enum","enum2str","TABLE","mostlySafeCasts","ntypes","dt1","dt2","CASTS","generateFullTable","generateTable","casts","isMostlySafeCast","from","to","isNumericDataType","isRealDataType","isRealFloatingPointDataType","safeCasts","SAFE_CASTS","isSafeCast","sameKindCasts","SAME_KIND_CASTS","isSignedIntegerDataType","isUnsignedIntegerDataType","ns","max","min","filled","filled2d","shape","S0","S1","zeros2d","xo","yo","xr","yr","reinterpretBoolean","isMostlySafeDataTypeCast","isSafeDataTypeCast","v1","v2","recurse","ndims","dim","S","d","copy","broadcastArray","inShape","outShape","st","M","ref","strides","isOdd","isInfinite","ku","kl","fill","a0","i0","i1","colexicographic","sqrt","LOW$3","setLowWord","low","uint32ToInt32","FLOAT64_HIGH_WORD_ABS_MASK","HIGH$5","getHighWord","indices$1","fromWords","high","WORDS","copysign","hx","hy","ABS_MASK","HIGH_MAX_NEAR_UNITY","HUGE","TINY","HIGH$1","setHighWord","FLOAT64_EXPONENT_BIAS","FLOAT64_NUM_HIGH_WORD_SIGNIFICAND_BITS","HIGH_SIGNIFICAND_MASK","HIGH_MIN_NORMAL_EXP","HIGH_BIASED_EXP_0","HIGH_BIASED_EXP_NEG_512","HIGH_SIGNIFICAND_HALF","TWO53","CP","CP_HI","CP_LO","BP","DP_HI","DP_LO","INV_LN2","INV_LN2_HI","INV_LN2_LO","FLOAT64_MAX_BASE2_EXPONENT","FLOAT64_MAX_BASE2_EXPONENT_SUBNORMAL","FLOAT64_MIN_BASE2_EXPONENT_SUBNORMAL","FLOAT64_SMALLEST_NORMAL","SCALAR","normalize","FLOAT64_HIGH_WORD_EXPONENT_MASK","TWO52_INV","CLEAR_EXP_MASK","FRAC","ldexp","frac","exp","m","EXP_MASK","BIAS","floatExp","MIN_SUBNORMAL_EXPONENT","MAX_EXPONENT","MAX_SUBNORMAL_EXPONENT","LN2","FLOAT64_HIGH_WORD_SIGNIFICAND_MASK","HIGH_BIASED_EXP_NEG_1","LN2_HI","LN2_LO","HIGH_BIASED_EXP_31","HIGH_BIASED_EXP_64","HIGH_BIASED_EXP_10","HIGH_1075","HIGH_NEG_1075","HIGH_NUM_NONSIGN_BITS","OVT","LOG_WORKSPACE","pow","ahx","ahy","ax","sx","sy","y1","hp","lp","yIsInfinite","xIsZero","yIsHuge","t2","t1","u","logx","ss","s2","hs","ls","ht","bp","dp","hz","lz","r","HIGH_NUM_SIGNIFICAND_BITS","log2ax","pow2","cartesianPower","s","cartesianProduct","x1","x2","get1","get2","cartesianSquare","indexed","countFalsy","view","reinterpretComplex","complex","zeroTo","isSameValueZero","countTruthy","yset","io","boolean","cuany","cuevery","cunone","setReadWriteAccessor","internalComplex","isValid","isNull","isUndefined","Slice","stop","step","_start","_stop","_step","normalizeSlice","strict","code","ceil","sliceLength","inc","Int32Array$1","Int16Array$1","Uint8ClampedArray$1","Int8Array$1","gcopy","strideX","offsetX","strideY","offsetY","xbuf","ybuf","ix","iy","ox","oy","ndarray","table","isComplex64","isComplex128","isBool","convert","isc64","obuf","getType","sliceAssign","xlen","ylen","xdt","ydt","xs","isComplexDataType","filledBy","filled3d","a1","S2","i2","filled4d","a2","S3","i3","filled5d","a3","S4","i4","fillednd","numel","isColumnMajorString","shape2strides","order","isColumnMajor","columnmajor","rowmajor","vind2bind","mode","ind","stride2offset","grev","MODE","recurseLexicographic","flatten","sh","flattenColexicographic","orig","flattenBy","copyBy","flatten2d","flatten2dBy","flatten3d","flatten3dBy","flatten4d","flatten4dBy","flatten5d","flatten5dBy","fliplr2d","x0","y0","fliplr3d","fliplr4d","flipud2d","flipud3d","flipud4d","incrspace","increment","isUndefinedOrNull","logspace","map2d","map3d","map4d","y2","map5d","x3","y3","minSignedIntegerDataType","mskfilter","mask","mget","mskfilterMap","mskput","mo","vo","mdata","iv","vdata","xset","vget","mskreject","setNonEnumerableProperty","oneTo","place","clampIndex","wrapIndex","mp1","normalizeIndex","oo","so","odata","oset","modes","MODES","throw","clamp","wrap","isIndexMode","put","getIndex","maxIndex","idata","iget","sv","arraySlice","method","hasMethod","array","stepSize","subArray","resolveSetter","take","uplo","ta","NDIMS","take2d","dimension","indexFunction","isPositiveZero","resolveStride","where","condition","cget","lens","sc","ic","maxn","co","reinterpretBool","cdata","reinterpretCmplx","arrayWith","with","defaults","numeric","floating_point","real_floating_point","complex_floating_point","integer","signed_integer","unsigned_integer","integer_index","boolean_index","mask_index","DEFAULTS","HASH","DEFAULT_DTYPE","gzeros","without","some","assert","at","banded","filter","gget","arrays","z0","z3","shapes","dx0","dx1","dy0","dy1","j0","j1","k0","k1","dx2","dy2","j2","k2","dx3","dy3","j3","k3","dx4","dy4","j4","k4","dz0","dz1","dw0","dw1","m0","m1","n0","n1","w0","u0","dz2","dw2","m2","n2","w1","u1","dz3","dw3","m3","n3","w2","u2","dz4","dw4","m4","n4","w3","u3","du0","du1","p0","p1","v0","du2","du3","p2","p3","copyIndexed","predicates","limit","equalNaNs","count","ptr","dedupeEqualNaNs","dedupeInPlace","fields","fget","Datum","setReadOnlyAccessor","_i","every","fancySlice","fancySliceAssign","groups","g","indicator","lastIndexOf","inc0","inc1","s0","s1","o1","o2","getters","dims","names","oget","setNonEnumerable","getValue","setValue","_arr","_get","_set","_updateCache","v3","okeys","nkeys","fromShape","toShape","reverse","ix1","ix0","ix2","t3","ix3","t4","symmetric","symmetricBanded","dedupeCopy","toReversed","list","properties","pdata","pget","labels","hasArrayBufferSupport","GlobalArrayBuffer","isView","ArrayBuffer$2","hasDataView","DataView","ArrayBuffer$1","GlobalDataView","getFloat64","setFloat64","hasDataViewSupport","DataView$1","round","timestamp","rounders","validDate","Date","Buffer","require$$0","GlobalBuffer","hasNodeBufferSupport","Buffer$1","allocUnsafe$1","allocUnsafe","size","bytesPerElement","empty","nbytes","nb","empty$1","gfill","alpha","isIteratorLike","iterLength","gfillBy","isProtoOf","capitalize","LITTLE_ENDIAN","BIG_ENDIAN","DTYPE2SET","DTYPE2GET","CHAR2ARTICLE","c","byteOrder","flag2byteOrder","isLE","CTOR_NAME","GETTER","SETTER","TypedArray","endianness","dtype2ctor","isTypedArrayConstructor","isTypedArray","_isLE","Float32ArrayFE","Float64ArrayFE","DEFAULT_REAL","DEFAULT_CMPLX","DEFAULT_BOOL","scalar2array","full","afill","foo","isFunctionNameSupported","Dummy","fcnName","instanceOf","typeName","typedarray2json","NAMES","Node","_next","LinkedList","_first","_last","node","_prev","toArray","iteratorSymbol","shift","pop","cache","find","id","first","COUNTER","ArrayIndex","persist","validate","last","findArrayIndex","remove","free","_invalidated","_node","array2json","linspace","endpoint","re1","re2","im1","im2","dr","di","DEFAULT_COMPLEX_DTYPE","cmplx","isf32","gencmplx","genreal","typedcmplx","typedreal","odt","adtype","acccmplx","accreal","create","Ctor","createObject$1","BYTE_ORDER","parent","fixedEndianFactory","superCtor","createObject","inherits","Float32ArrayLE","Float64ArrayLE","isNegativeZero","FLOAT32_SMALLEST_SUBNORMAL","FLOAT32_MAX_SAFE_INTEGER","FLOAT32_MIN_SAFE_INTEGER","minFloatDataType","minDataType","isMode","Z128","Z64","isValidDType","vdt","TWO54","IVLN2HI","IVLN2LO","HIGH_MAX_NORMAL_EXP","log2","valHi","valLo","hfsq","lx","hi","lo","R","polyvalQ","kernelLog1p","ARRAY_DEFAULTS","isCmplx64Array","isCmplx128Array","isBoolArray","pool","highWaterMark","createPool","malloc","MAX","arraybuffer","MIN_EXP_SUBNORMAL","MAX_EXP","typedarraypool","hasSharedArrayBuffer","SharedArrayBuffer","isSharedArrayBuffer","b1","b2","GlobalSharedArrayBuffer","hasSharedArrayBufferSupport","SharedArrayBuffer$1","evil","eval","proxy","Proxy","hasProxySupport","Proxy$1","getOwnPropertySymbols","propertySymbols","enumerableProperties","isEnumerable","hasObjectAssign","assign$1","wrapComplex","wrapper","array2fancy","hasSupport","validateGeneric","validateBoolean","validateRealFloating","complexDataType","validateComplexFloating","validateSignedInteger","validateUnsignedInteger","validator","isRealFloatingDataType","RE_INTEGER","isIntegerString","RE_ARRAY_INDEX","isArrayIndexString","trim","trim$1","prop2array","resolveIndex","errMessage","msg","RE_END_MINUS","RE_END_DIVIDE","resolveEnd","decrement","RE_COLON_SEP","RE_END","seq2slice","parts","split","PREFIX","NARGS","RE_SEP","startsWith","position","charCodeAt","startsWith$1","RE_SUBSEQ","parseSlice","raw","str2slice","prop2slice","isSlice","isSubsequence","parseSubsequence","ctx","receiver","getElement","hasProperty","postGetArray","getElements","message","getSlice","preSetElement","setElement","tdt","setElements","setSlice","OPTIONS","setElementWrapper","getArrayWrapper","construct","console","warn","getTime","filledIterator","filledAccessors","filledArray","filledArrayIterator","aidx","gen","littleEndianFactory","NEXT_DTYPES","dtype1","dtype2","PROMOTION_RULES","circarray2iterator","dir","array2iterator","array2iteratorRight","sparsearray2iterator","sparsearray2iteratorRight","stridedarray2iterator","arrayview2iterator","arrayview2iteratorRight","complexarrayCtors","typedarrayCtors","floatarrayCtors","constants"],"mappings":";4QAsBA,IAAIA,EAA0C,mBAA1BC,OAAOC,eAAkCD,OAAOC,eAAiB,KCiCrF,IAAIA,EAAiBD,OAAOC,eCjB5B,SAASC,EAAUC,GAClB,MAA0B,iBAAVA,CACjB,CCAA,SAASC,EAAOC,GACf,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CAcA,SAASC,EAASC,EAAKC,EAAOC,GAC7B,IAAIC,GAAW,EACXC,EAAMH,EAAQD,EAAIK,OACtB,OAAKD,EAAM,IAnCZ,SAA0BJ,GACzB,MAAoB,MAAbA,EAAK,EACb,CAoCMM,CAAiBN,KACrBG,GAAW,EACXH,EAAMA,EAAIO,OAAQ,IAEnBP,EAAM,EACLA,EAAML,EAAOS,GACbT,EAAOS,GAAQJ,EACXG,IACJH,EAAM,IAAMA,IAVLA,CAaT,CCpDA,IAAIQ,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAajC,SAASC,EAAeC,GACvB,IAAIC,EACAlB,EACAD,EAEJ,OAASkB,EAAME,WACf,IAAK,IAEJD,EAAO,EACP,MACD,IAAK,IAEJA,EAAO,EACP,MACD,IAAK,IACL,IAAK,IAEJA,EAAO,GACP,MAID,QAECA,EAAO,GAKR,GAFAlB,EAAMiB,EAAMG,IACZrB,EAAIsB,SAAUrB,EAAK,KACbsB,SAAUvB,GAAM,CACrB,IAAMJ,EAAUK,GACf,MAAM,IAAIuB,MAAO,2BAA6BvB,GAE/CD,EAAI,CACJ,CAkCD,OAjCKA,EAAI,IAA2B,MAApBkB,EAAME,WAA8B,KAATD,KAC1CnB,EAAI,WAAaA,EAAI,GAEjBA,EAAI,GACRC,IAASD,GAAIyB,SAAUN,GAClBD,EAAMQ,YACVzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR,EAAMS,WAE5C1B,EAAM,IAAMA,IAEZA,EAAMD,EAAEyB,SAAUN,GACZnB,GAAMkB,EAAMQ,UAENR,EAAMQ,YACjBzB,EAAMC,EAASD,EAAKiB,EAAMQ,UAAWR,EAAMS,WAF3C1B,EAAM,GAIFiB,EAAMU,OACV3B,EAAMiB,EAAMU,KAAO3B,IAGP,KAATkB,IACCD,EAAMW,YACV5B,EAAM,KAAOA,GAEdA,EAAQiB,EAAME,YAAcL,EAAUe,KAAMZ,EAAME,WACjDL,EAAUe,KAAM7B,GAChBU,EAAUmB,KAAM7B,IAEJ,IAATkB,GACCD,EAAMW,WAAiC,MAApB5B,EAAI8B,OAAQ,KACnC9B,EAAM,IAAMA,GAGPA,CACR,CCtFA,IAAI+B,EAAMC,KAAKD,IACXrB,EAAYC,OAAOC,UAAUC,YAC7BC,EAAYH,OAAOC,UAAUG,YAC7BkB,EAAUtB,OAAOC,UAAUqB,QAK3BC,EAAoB,WACpBC,EAAoB,UACpBC,EAAiB,UACjBC,EAAuB,UACvBC,EAA0B,OAC1BC,EAAqB,QACrBC,EAAqB,gBAczB,SAASC,EAAcC,EAAGzB,GACzB,IAAI0B,EACA3C,EAEJ,OAASiB,EAAME,WACf,IAAK,IACL,IAAK,IACJnB,EAAM0C,EAAEE,cAAe3B,EAAMQ,WAC7B,MACD,IAAK,IACL,IAAK,IACJzB,EAAM0C,EAAEG,QAAS5B,EAAMQ,WACvB,MACD,IAAK,IACL,IAAK,IACCM,EAAKW,GAAM,OACfC,EAAS1B,EAAMQ,WACD,IACbkB,GAAU,GAEX3C,EAAM0C,EAAEE,cAAeD,IAEvB3C,EAAM0C,EAAEI,YAAa7B,EAAMQ,WAEtBR,EAAMW,YACX5B,EAAMiC,EAAQJ,KAAM7B,EAAKwC,EAAoB,OAC7CxC,EAAMiC,EAAQJ,KAAM7B,EAAKuC,EAAoB,KAC7CvC,EAAMiC,EAAQJ,KAAM7B,EAAKsC,EAAyB,KAEnD,MACD,QACC,MAAM,IAAIf,MAAO,mCAAqCN,EAAME,WAc7D,OAZAnB,EAAMiC,EAAQJ,KAAM7B,EAAKkC,EAAmB,SAC5ClC,EAAMiC,EAAQJ,KAAM7B,EAAKmC,EAAmB,SACvClB,EAAMW,YACV5B,EAAMiC,EAAQJ,KAAM7B,EAAKoC,EAAgB,OACzCpC,EAAMiC,EAAQJ,KAAM7B,EAAKqC,EAAsB,SAE3CK,GAAK,GAAKzB,EAAMU,OACpB3B,EAAMiB,EAAMU,KAAO3B,GAEpBA,EAAQiB,EAAME,YAAcL,EAAUe,KAAMZ,EAAME,WACjDL,EAAUe,KAAM7B,GAChBU,EAAUmB,KAAM7B,EAElB,CCpEA,SAAS+C,EAAQjD,GAChB,IACIC,EADAC,EAAM,GAEV,IAAMD,EAAI,EAAGA,EAAID,EAAGC,IACnBC,GAAO,IAER,OAAOA,CACR,CCJA,IAAIgD,EAAerC,OAAOqC,aACtBC,EAAUC,MAAMD,QAoBpB,SAASE,EAAOvD,GACf,OAASA,GAAUA,CACpB,CASA,SAASwD,EAAYnC,GACpB,IAAIjB,EAAM,CAAA,EAMV,OALAA,EAAImB,UAAYF,EAAME,UACtBnB,EAAIyB,eAAkC,IAApBR,EAAMQ,UAAyB,EAAIR,EAAMQ,UAC3DzB,EAAIG,MAAQc,EAAMd,MAClBH,EAAIqD,MAAQpC,EAAMoC,OAAS,GAC3BrD,EAAIsD,QAAUrC,EAAMqC,QACbtD,CACR,CAmBA,SAASuD,EAAmBC,GAC3B,IAAIC,EACAJ,EACApC,EACAyC,EACAC,EACA3D,EACA4D,EACAlB,EACA3C,EACA8D,EDnDc3D,EAAKC,EAAOC,EAC1BE,ECoDJ,IAAM2C,EAASO,GACd,MAAM,IAAIM,UAAW,8DAAgEN,EAAS,MAI/F,IAFAxD,EAAM,GACN4D,EAAM,EACA7D,EAAI,EAAGA,EAAIyD,EAAOjD,OAAQR,IAE/B,GADAkB,EAAQuC,EAAQzD,GC1ES,iBD2EVkB,EACdjB,GAAOiB,MACD,CAGN,GAFAwC,OAAgC,IAApBxC,EAAMQ,YAClBR,EAAQmC,EAAYnC,IACRE,UACX,MAAM,IAAI2C,UAAW,oEAAqE/D,EAAG,cAAgBkB,EAAQ,MAMtH,IAJKA,EAAMqC,UACVM,EAAM3C,EAAMqC,SAEbD,EAAQpC,EAAMoC,MACRQ,EAAI,EAAGA,EAAIR,EAAM9C,OAAQsD,IAE9B,OADAH,EAAOL,EAAMvB,OAAQ+B,IAErB,IAAK,IACJ5C,EAAMU,KAAO,IACb,MACD,IAAK,IACJV,EAAMU,KAAO,IACb,MACD,IAAK,IACJV,EAAMS,UAAW,EACjBT,EAAM8C,UAAW,EACjB,MACD,IAAK,IACJ9C,EAAM8C,SAAWV,EAAMW,QAAS,KAAQ,EACxC,MACD,IAAK,IACJ/C,EAAMW,WAAY,EAClB,MACD,QACC,MAAM,IAAIL,MAAO,iBAAmBmC,GAGtC,GAAqB,MAAhBzC,EAAMd,MAAgB,CAG1B,GAFAc,EAAMd,MAAQkB,SAAU4C,UAAWL,GAAO,IAC1CA,GAAO,EACFT,EAAOlC,EAAMd,OACjB,MAAM,IAAI2D,UAAW,wCAA0CF,EAAM,6BAA+B3C,EAAMd,MAAQ,MAE9Gc,EAAMd,MAAQ,IAClBc,EAAMS,UAAW,EACjBT,EAAMd,OAASc,EAAMd,MAEtB,CACD,GAAKsD,GACqB,MAApBxC,EAAMQ,UAAoB,CAG9B,GAFAR,EAAMQ,UAAYJ,SAAU4C,UAAWL,GAAO,IAC9CA,GAAO,EACFT,EAAOlC,EAAMQ,WACjB,MAAM,IAAIqC,UAAW,4CAA8CF,EAAM,6BAA+B3C,EAAMQ,UAAY,MAEtHR,EAAMQ,UAAY,IACtBR,EAAMQ,UAAY,EAClBgC,GAAY,EAEb,CAGF,OADAxC,EAAMG,IAAM6C,UAAWL,GACd3C,EAAME,WACf,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IAECsC,IACJxC,EAAM8C,UAAW,GAElB9C,EAAMG,IAAMJ,EAAeC,GAC3B,MACD,IAAK,IAEJA,EAAMiD,SAAW,EAAgBjD,EAAMQ,WAAa,EACpDR,EAAMG,IAAMT,OAAQM,EAAMG,KAC1B,MACD,IAAK,IAEJ,IAAM+B,EAAOlC,EAAMG,KAAQ,CAE1B,IADAuC,EAAMtC,SAAUJ,EAAMG,IAAK,KAChB,GAAKuC,EAAM,IACrB,MAAM,IAAIpC,MAAO,kCAAoCN,EAAMG,KAE5DH,EAAMG,IAAQ+B,EAAOQ,GAAUhD,OAAQM,EAAMG,KAAQ4B,EAAcW,EACnE,CACD,MACD,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IACL,IAAK,IAMJ,GAJMF,IACLxC,EAAMQ,UAAY,GAEnBiB,EAAIyB,WAAYlD,EAAMG,MAChBE,SAAUoB,GAAM,CACrB,IAAM/C,EAAUsB,EAAMG,KACrB,MAAM,IAAIG,MAAO,yCAA2CvB,GAG7D0C,EAAIzB,EAAMG,IACVH,EAAM8C,UAAW,CACjB,CACD9C,EAAMG,IAAMqB,EAAcC,EAAGzB,GAC7B,MACD,QACC,MAAM,IAAIM,MAAO,sBAAwBN,EAAME,WAG3CF,EAAMiD,UAAY,GAAKjD,EAAMG,IAAIb,OAASU,EAAMiD,WACpDjD,EAAMG,IAAMH,EAAMG,IAAIgD,UAAW,EAAGnD,EAAMiD,WAEtCjD,EAAM8C,SACV9C,EAAMG,IAAMnB,EAASgB,EAAMG,IAAKH,EAAMd,OAASc,EAAMQ,UAAWR,EAAMS,UAC3DT,EAAMd,QACjBc,EAAMG,KDpLSlB,ECoLOe,EAAMG,IDpLRjB,ECoLac,EAAMd,MDpLZC,ECoLmBa,EAAMS,SDnLnDpB,YAAMH,EAAQD,EAAIK,QACX,EACHL,EAERA,EAAM,EACLA,EAAM6C,EAAQzC,GACdyC,EAAQzC,GAAQJ,IC+KfF,GAAOiB,EAAMG,KAAO,GACpBwC,GAAO,CACP,CAEF,OAAO5D,CACR,CEvNA,IAAIqE,EAAK,6EAYT,SAASC,EAAOC,GACf,IAAItD,EAAQ,CACXqC,QAAaiB,EAAO,GAAQlD,SAAUkD,EAAO,GAAK,SAAO,EACzDlB,MAASkB,EAAO,GAChBpE,MAASoE,EAAO,GAChB9C,UAAa8C,EAAO,GACpBpD,UAAaoD,EAAO,IAKrB,MAHoB,MAAfA,EAAO,SAA8B,IAAfA,EAAO,KACjCtD,EAAMQ,UAAY,KAEZR,CACR,CAeA,SAASuD,EAAgBtE,GACxB,IAAIuE,EACAjB,EACAe,EACAG,EAKJ,IAHAlB,EAAS,GACTkB,EAAO,EACPH,EAAQF,EAAGM,KAAMzE,GACTqE,IACPE,EAAUvE,EAAI0E,MAAOF,EAAML,EAAGQ,UAAYN,EAAO,GAAIhE,SACxCA,QACZiD,EAAOsB,KAAML,GAGM,MAAfF,EAAO,GACXf,EAAOsB,KAAM,KAEbtB,EAAOsB,KAAMR,EAAOC,IAErBG,EAAOL,EAAGQ,UACVN,EAAQF,EAAGM,KAAMzE,GAMlB,OAJAuE,EAAUvE,EAAI0E,MAAOF,IACRnE,QACZiD,EAAOsB,KAAML,GAEPjB,CACR,CC3CA,SAASuB,EAAQ7E,GAChB,IAAI8E,EACAjF,EAEJ,GCf0B,iBDeVG,EACf,MAAM,IAAI4D,UAAWiB,EAAQ,kEAAmE7E,IAGjG,IADA8E,EAAO,CAAEC,EAAU/E,IACbH,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAClCiF,EAAKF,KAAMb,UAAWlE,IAEvB,OAAOmF,EAAYC,MAAO,KAAMH,EACjC,CE7BA,ICkBItF,EDlBA0F,EAAiB3F,OAAOmB,UACxByE,EAAQD,EAAe5D,SACvB8D,EAAeF,EAAeG,iBAC9BC,EAAeJ,EAAeK,iBAC9BC,EAAeN,EAAeO,iBAC9BC,EAAeR,EAAeS,iBCiBjCnG,ECdD,WAEC,IAEC,OADAA,EAAgB,CAAE,EAAE,IAAK,CAAA,IAClB,CACP,CAAC,MAAQoG,GACT,OAAO,CACP,CACF,CDGKC,GACaC,EDqBlB,SAAyBC,EAAKC,EAAMC,GACnC,IAAIvF,EACAwF,EACAC,EACAC,EAEJ,GAAoB,iBAARL,GAA4B,OAARA,GAAsC,mBAAtBZ,EAAMxD,KAAMoE,GAC3D,MAAM,IAAInC,UAAWiB,EAAQ,mEAAoEkB,IAElG,GAA2B,iBAAfE,GAA0C,OAAfA,GAAoD,mBAA7Bd,EAAMxD,KAAMsE,GACzE,MAAM,IAAIrC,UAAWiB,EAAQ,wEAAyEoB,IAyBvG,IAvBAC,EAAa,UAAWD,KAGtBT,EAAa7D,KAAMoE,EAAKC,IACxBN,EAAa/D,KAAMoE,EAAKC,IAGxBtF,EAAYqF,EAAIM,UAChBN,EAAIM,UAAYnB,SAGTa,EAAKC,GACZD,EAAKC,GAASC,EAAWvG,MAGzBqG,EAAIM,UAAY3F,GAEhBqF,EAAKC,GAASC,EAAWvG,OAG3ByG,EAAW,QAASF,EACpBG,EAAW,QAASH,EAEfC,IAAcC,GAAUC,GAC5B,MAAM,IAAI/E,MAAO,wHASlB,OANK8E,GAAUf,GACdA,EAAazD,KAAMoE,EAAKC,EAAMC,EAAWK,KAErCF,GAAUd,GACdA,EAAa3D,KAAMoE,EAAKC,EAAMC,EAAWM,KAEnCR,CACR,EC3DA,IAAAS,EAAehH,EEZf,SAASiH,EAAaV,EAAKC,EAAMtG,GAChCF,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASA,GAEX,CCPA,SAASmH,EAA0Bd,EAAKC,EAAMtG,GAC7CF,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASA,GAEX,CC9BA,IAAIoH,EAAO,WAqBX,SAASC,EAAiBrH,GACzB,cAAgBA,EAAM4G,MAAQQ,UAAepH,EAAM6G,MAAQO,CAC5D,CCvBA,IAAIE,EAAU,CACbC,QAgCD,SAAqBC,EAAKC,GACzB,OAAOD,EAAKC,EACb,EAjCCC,QAmDD,SAAqBF,EAAKC,GACzB,OAAOD,EAAKC,EACb,EApDCE,MAsED,SAAmBH,EAAKC,GACvB,OAAOD,EAAKC,EACb,EAvECG,MAyFD,SAAmBJ,EAAKC,GACvB,OAAOD,EAAKC,EACb,EA1FCI,KA4GD,SAAkBL,EAAKC,GACtB,OAAOD,EAAKC,EACb,EA7GCK,OA+HD,SAAoBN,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAhICM,OAkJD,SAAoBP,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAnJCO,MAqKD,SAAmBR,EAAKC,GACvB,OAAOD,EAAKC,EACb,EAtKCQ,OAwLD,SAAoBT,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAzLCS,QAyMD,SAAqBV,EAAKC,GACzB,OAAOD,EAAKC,EACb,EA1MCU,QA0ND,SAAuBX,EAAKC,GAC3B,OAAOD,EAAKC,EACb,GAoBA,SAASW,EAAQC,GAChB,IAAIvF,EAAIwE,EAASe,GACjB,MAAkB,mBAANvF,EACJA,EAEDwE,EAAQa,OAChB,CCjQA,IAAIG,EAAU,CACbf,QAkCD,SAAqBC,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EAnCC0H,QAuDD,SAAqBF,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EAxDC2H,MA4ED,SAAmBH,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EA7EC4H,MAiGD,SAAmBJ,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EAlGC6H,KAsHD,SAAkBL,EAAKC,EAAKzH,GAC3BwH,EAAKC,GAAQzH,CACd,EAvHC8H,OA2ID,SAAoBN,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EA5IC+H,OAgKD,SAAoBP,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EAjKCgI,MAqLD,SAAmBR,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EAtLCiI,OA0MD,SAAoBT,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EA3MCkI,QA6ND,SAAqBV,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EA9NCmI,QAgPD,SAAuBX,EAAKC,EAAKzH,GAChCwH,EAAKC,GAAQzH,CACd,GAsBA,SAASuI,EAAQF,GAChB,IAAIvF,EAAIwF,EAASD,GACjB,MAAkB,mBAANvF,EACJA,EAEDwF,EAAQH,OAChB,CCzRA,IAAIb,EAAU,CACbkB,WAgCD,SAAwBhB,EAAKC,GAC5B,OAAOD,EAAIZ,IAAKa,EACjB,EAjCCgB,UA2DD,SAAuBjB,EAAKC,GAC3B,OAAOD,EAAIZ,IAAKa,EACjB,EA5DCU,QAuFD,SAAuBX,EAAKC,GAC3B,OAAOD,EAAIZ,IAAKa,EACjB,GA6BA,SAASW,EAAQC,GAChB,IAAIvF,EAAIwE,EAASe,GACjB,MAAkB,mBAANvF,EACJA,EAEDwE,EAAQa,OAChB,CC/HA,IAAIG,EAAU,CACbE,WAkCD,SAAwBhB,EAAKC,EAAKzH,GACjCwH,EAAIX,IAAK7G,EAAOyH,EACjB,EAnCCgB,UA+DD,SAAuBjB,EAAKC,EAAKzH,GAChCwH,EAAIX,IAAK7G,EAAOyH,EACjB,EAhECU,QA6FD,SAAuBX,EAAKC,EAAKzH,GAChCwH,EAAIX,IAAK7G,EAAOyH,EACjB,GAgCA,SAASc,EAAQF,GAChB,IAAIvF,EAAIwF,EAASD,GACjB,MAAkB,mBAANvF,EACJA,EAEDwF,EAAQH,OAChB,CCnIA,IAAIO,ECMgB,mBAAXC,QACoB,iBAApBA,OAAQ,ODOjB,SAASC,IACR,OAASF,GAAqC,iBAAvBC,OAAOE,WAC/B,CErBA,IAAIpD,EAAQ5F,OAAOmB,UAAUY,SCA7B,IAAIkH,GAAMjJ,OAAOmB,UAAU+H,eA4B3B,SAASC,GAAYhJ,EAAOiJ,GAC3B,OACCjJ,SAKM8I,GAAI7G,KAAMjC,EAAOiJ,EACzB,CCpCA,IAAIC,GAA0B,mBAAXP,OAA0BA,YAAS,ECKlDQ,GAA+B,mBAAXR,GAA0BA,GAAOE,YAAc,GCiCvE,IAAAO,GATKC,ICDL,SAAsBC,GACrB,IAAIC,EACAC,EACApJ,EAEJ,GAAKkJ,QACJ,OAAO7D,EAAMxD,KAAMqH,GAEpBE,EAAMF,EAAGT,IACTU,EAAQP,GAAYM,EAAGT,IAGvB,IACCS,EAAGT,SAAgB,CACnB,CAAC,MAAQ3C,GACT,OAAOT,EAAMxD,KAAMqH,EACnB,CAQD,OAPAlJ,EAAMqF,EAAMxD,KAAMqH,GAEbC,EACJD,EAAGT,IAAgBW,SAEZF,EAAGT,IAEJzI,CACR,EC3BA,SAAsBkJ,GACrB,OAAO7D,EAAMxD,KAAMqH,EACpB,ECYA,IAAAG,GATKnG,MAAMD,QACNC,MAAMD,QARX,SAAkBrD,GACjB,MAAkC,mBAAzBoJ,GAAapJ,EACvB,ECCA,SAAS0J,GAAUC,GAClB,GAA0B,mBAAdA,EACX,MAAM,IAAIzF,UAAWiB,EAAQ,0DAA2DwE,IAEzF,OASA,SAAgB3J,GACf,IAAI4J,EACAzJ,EACJ,IAAMkD,GAASrD,GACd,OAAO,EAGR,GAAa,KADb4J,EAAM5J,EAAMW,QAEX,OAAO,EAER,IAAMR,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,IAAiC,IAA5BwJ,EAAW3J,EAAOG,IACtB,OAAO,EAGT,OAAO,CACP,CACF,CCzCA,SAAS0J,GAAc7J,GACtB,OACW,OAAVA,GACiB,iBAAVA,CAET,CCMA,SAAS8J,GAAU9J,GAClB,OACC6J,GAAc7J,KAGbA,EAAM+J,WAEL/J,EAAMgK,aAGgC,mBAA/BhK,EAAMgK,YAAYF,UACzB9J,EAAMgK,YAAYF,SAAU9J,GAIhC,CClBA,SAASiK,KACR,MAAO,yBACR,CCaAlD,EAAAnH,GAAA,oBALAsK,GAAAtK,KCFA,IAAIuK,GFPI,0BGQR,SAASC,GAAiBd,GACzB,IAAI3E,EACA0F,EACAC,EAEJ,IAAe,YADfD,EAAOjB,GAAaE,GAAItE,MAAO,GAAI,KACC,UAATqF,IAAqBf,EAAEU,YAAc,CAE/D,GAA0B,iBAD1BM,EAAOhB,EAAEU,aACQK,KAChB,OAAOC,EAAKD,KAGb,GADA1F,EAAQF,GAAGM,KAAMuF,EAAK1I,YAErB,OAAO+C,EAAO,EAEf,CACD,OAAKmF,GAAUR,GACP,SAEDe,CACR,CCnBAtD,EAAAnH,GAAA,SAAA2K,IChCA,IAAIC,GAAc,CACjBC,aAAgB,UAChBC,aAAgB,UAChBpH,MAAS,UACTqH,WAAc,QACdC,WAAc,QACdC,UAAa,OACbC,YAAe,SACfC,YAAe,SACfC,WAAc,QACdC,kBAAqB,SACrBC,eAAkB,YAClBC,gBAAmB,aACnBC,aAAgB,QCTbC,GAA4C,mBAAjBX,aCL/B,IAAI9K,GAAiC,mBAAjB8K,aAAgCA,aAAe,KCenE,SAASY,KACR,IAAIC,EACA/D,EFSoBxH,EEPxB,GAAmC,mBAAvBwL,GACX,OAAO,EAGR,IACChE,EAAM,IAAIgE,GAAoB,CAAE,EAAK,MAAO,KAAMC,MFE3BzL,EEANwH,EADjB+D,GFGEF,IAAmBrL,aAAiB0K,cACb,0BAAzBtB,GAAapJ,KEFC,IAAbwH,EAAK,IACQ,OAAbA,EAAK,KACS,OAAdA,EAAK,IACLA,EAAK,IAAQA,EAAK,EAEnB,CAAC,MAAQtB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCpCA,IAAIjB,GAAiC,mBAAjBI,aAAgCA,kBAAe,EC6BnE,IAAAgB,GATKJ,KACGlF,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJIgK,GAA4C,mBAAjBlB,aCuB/B,IAAImB,GAAeC,OAAOC,kBC5BtBlM,GAAiC,mBAAjB6K,aAAgCA,aAAe,KCgBnE,SAASsB,KACR,IAAIR,EACA/D,EHQoBxH,EGNxB,GAAmC,mBAAvBgM,GACX,OAAO,EAGR,IACCxE,EAAM,IAAIwE,GAAoB,CAAE,EAAK,MAAO,KAAM,OHC3BhM,EGCNwH,EADjB+D,GHEEI,IAAmB3L,aAAiByK,cACb,0BAAzBrB,GAAapJ,KGDC,IAAbwH,EAAK,IACQ,oBAAbA,EAAK,KACS,oBAAdA,EAAK,IACLA,EAAK,KAAQyE,EAEd,CAAC,MAAQ/F,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCrCA,IAAIjB,GAAiC,mBAAjBG,aAAgCA,kBAAe,EC6BnE,IAAAyB,GATKH,KACG3F,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJIwK,GAA0C,mBAAhBpB,YC4B9B,IAAIqB,GAAa,WCjCbxM,GAAgC,mBAAhBmL,YAA+BA,YAAc,KCgBjE,SAASsB,KACR,IAAId,EACA/D,EHQmBxH,EGNvB,GAAkC,mBAAtBsM,GACX,OAAO,EAGR,IAEC9E,EAAM,IAAI8E,GADV9E,EAAM,CAAE,EAAG,MAAO,KAAM4E,GAAW,EAAGA,GAAW,IHC3BpM,EGENwH,EADhB+D,GHCEY,IAAkBnM,aAAiB+K,aACZ,yBAAzB3B,GAAapJ,KGAC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,IACLA,EAAK,KAAQ4E,GAAW,GACX,IAAb5E,EAAK,IACQ,IAAbA,EAAK,EAEN,CAAC,MAAQtB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCvCA,IAAIjB,GAAgC,mBAAhBS,YAA+BA,iBAAc,EC6BjE,IAAAwB,GATKF,KACGjG,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJI6K,GAAwC,mBAAf5B,WC4B7B,IAAI6B,GAAY,WCAZC,IAAY,WCjCZ9M,GAA+B,mBAAfgL,WAA8BA,WAAa,KCiB/D,SAAS+B,KACR,IAAIpB,EACA/D,EJOkBxH,EILtB,GAAiC,mBAArB4M,GACX,OAAO,EAGR,IACCpF,EAAM,IAAIoF,GAAkB,CAAE,EAAG,MAAO,KAAMH,GAAU,IJAnCzM,EIENwH,EADf+D,GJCEiB,IAAiBxM,aAAiB4K,YACX,wBAAzBxB,GAAapJ,KIAC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,KACS,IAAdA,EAAK,IACLA,EAAK,KAAQkF,EAEd,CAAC,MAAQxG,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCtCA,IAAIjB,GAA+B,mBAAfM,WAA8BA,gBAAa,EC6B/D,IAAAiC,GATKF,KACGvG,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJImL,GAA0C,mBAAhBhC,YC4B9B,IAAIiC,GAAa,MCjCbnN,GAAgC,mBAAhBkL,YAA+BA,YAAc,KCgBjE,SAASkC,KACR,IAAIzB,EACA/D,EHQmBxH,EGNvB,GAAkC,mBAAtBiN,GACX,OAAO,EAGR,IAECzF,EAAM,IAAIyF,GADVzF,EAAM,CAAE,EAAG,MAAO,KAAMuF,GAAW,EAAGA,GAAW,IHC3B/M,EGENwH,EADhB+D,GHCEuB,IAAkB9M,aAAiB8K,aACZ,yBAAzB1B,GAAapJ,KGAC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,IACLA,EAAK,KAAQuF,GAAW,GACX,IAAbvF,EAAK,IACQ,IAAbA,EAAK,EAEN,CAAC,MAAQtB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCvCA,IAAIjB,GAAgC,mBAAhBQ,YAA+BA,iBAAc,EC6BjE,IAAAoC,GATKF,KACG5G,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJIwL,GAAwC,mBAAfxC,WC4B7B,IAAIyC,GAAY,MCAZC,IAAY,MCjCZzN,GAA+B,mBAAf+K,WAA8BA,WAAa,KCiB/D,SAAS2C,KACR,IAAI/B,EACA/D,EJOkBxH,EILtB,GAAiC,mBAArBuN,GACX,OAAO,EAGR,IACC/F,EAAM,IAAI+F,GAAkB,CAAE,EAAG,MAAO,KAAMH,GAAU,IJAnCpN,EIENwH,EADf+D,GJCE4B,IAAiBnN,aAAiB2K,YACX,wBAAzBvB,GAAapJ,KIAC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,KACS,IAAdA,EAAK,IACLA,EAAK,KAAQ6F,EAEd,CAAC,MAAQnH,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCtCA,IAAIjB,GAA+B,mBAAfK,WAA8BA,gBAAa,EC6B/D,IAAA6C,GATKF,KACGlH,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJI8L,GAAwC,mBAAfzC,WAqB7B,SAAS0C,GAAc1N,GACtB,OACGyN,IAAiBzN,aAAiBgL,YACX,wBAAzB5B,GAAapJ,EAEf,CCEA,IAAI2N,GAAY,ICjCZ/N,GAA+B,mBAAfoL,WAA8BA,WAAa,KCgB/D,SAAS4C,KACR,IAAIrC,EACA/D,EAEJ,GAAiC,mBAArBqG,GACX,OAAO,EAGR,IAGCtC,EACCmC,GAFDlG,EAAM,IAAIqG,GADVrG,EAAM,CAAE,EAAG,MAAO,KAAMmG,GAAU,EAAGA,GAAU,MAIjC,IAAbnG,EAAK,IACQ,IAAbA,EAAK,IACLA,EAAK,KAAQmG,GAAU,GACV,IAAbnG,EAAK,IACQ,IAAbA,EAAK,EAEN,CAAC,MAAQtB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCvCA,IAAIjB,GAA+B,mBAAfU,WAA8BA,gBAAa,EC6B/D,IAAA8C,GATKF,KACGxH,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJIoM,GAAsD,mBAAtB9C,kBCLpC,IAAIrL,GAAsC,mBAAtBqL,kBAAqCA,kBAAoB,KCe7E,SAAS+C,KACR,IAAIzC,EACA/D,EFSyBxH,EEP7B,GAAwC,mBAA5BiO,GACX,OAAO,EAGR,IACCzG,EAAM,IAAIyG,GAAyB,EAAG,EAAG,EAAG,EAAG,KAAM,KAAM,IAAK,MFEpCjO,EEANwH,EADtB+D,GFGEwC,IAAwB/N,aAAiBiL,mBAClB,+BAAzB7B,GAAapJ,KEFC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,IACQ,IAAbA,EAAK,IACQ,IAAbA,EAAK,IACQ,IAAbA,EAAK,IACQ,MAAbA,EAAK,IACQ,MAAbA,EAAK,EAEN,CAAC,MAAQtB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCvCA,IAAIjB,GAAsC,mBAAtBW,kBAAqCA,uBAAoB,EC6B7E,IAAAiD,GATKF,KACG5H,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJIwM,GAAsC,mBAAdtD,UC4B5B,IAAIuD,GAAW,ICAXC,IAAW,ICjCXzO,GAA8B,mBAAdiL,UAA6BA,UAAY,KCiB7D,SAASyD,KACR,IAAI/C,EACA/D,EJOiBxH,EILrB,GAAgC,mBAApBuO,GACX,OAAO,EAGR,IACC/G,EAAM,IAAI+G,GAAiB,CAAE,EAAG,MAAO,KAAMH,GAAS,IJAlCpO,EIENwH,EADd+D,GJCE4C,IAAgBnO,aAAiB6K,WACV,uBAAzBzB,GAAapJ,KIAC,IAAbwH,EAAK,IACQ,IAAbA,EAAK,KACS,IAAdA,EAAK,IACLA,EAAK,KAAQ6G,EAEd,CAAC,MAAQnI,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CCtCA,IAAIjB,GAA8B,mBAAdO,UAA6BA,eAAY,EC6B7D,IAAA2D,GATKF,KACGlI,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECOA,SAAS5B,GAAUC,GAClB,MAA0B,iBAAVA,CACjB,CClBA,IAAAyO,GAAe5C,OCMXjK,GAAWiK,GAAO7K,UAAUY,SCEhC,IAAI8G,GAAMW,IAmBV,SAAStJ,GAAUC,GAClB,MAAsB,iBAAVA,IACNA,aAAiB6L,KAGjBnD,GCpBP,SAAe1I,GACd,IAEC,OADA4B,GAASK,KAAMjC,IACR,CACP,CAAC,MAAQkG,GACT,OAAO,CACP,CACF,CDcUwI,CAAM1O,GAEoB,oBAAzBoJ,GAAapJ,IAGxB,CEVA,SAASD,GAAUC,GAClB,OAAS2O,GAAa3O,IAAW4O,GAAU5O,EAC5C,CCoBA+G,EAAAnH,GAAA,cAAA+O,IACA5H,EAAAnH,GAAA,WAAAgP,ICnBA,IAAIC,GAAehD,GAAOiD,kBCVtBC,GAAQ3M,KAAK2M,MCHjB,SAASC,GAAWC,GACnB,OAAQF,GAAME,KAAOA,CACtB,CCPA,SAASD,GAAWhP,GACnB,OACCA,EAAQiM,IACRjM,EAAQkP,IACRC,GAAOnP,EAET,CCAA,SAASgP,GAAWhP,GACnB,OACCD,GAAUC,IACVmP,GAAOnP,EAET,CCLA,SAASgP,GAAWhP,GACnB,OACCD,GAAUC,IACVmP,GAAOnP,EAAMoP,UAEf,CCGA,SAASJ,GAAWhP,GACnB,OAAS2O,GAAa3O,IAAW4O,GAAU5O,EAC5C,CCXA,SAASqP,GAAsBrP,GAC9B,OACCgP,GAAWhP,IACXA,GAAS,CAEX,CCLA,SAASqP,GAAsBrP,GAC9B,OACCgP,GAAWhP,IACXA,EAAMoP,WAAa,CAErB,CCQA,SAASC,GAAsBrP,GAC9B,OAAS2O,GAAa3O,IAAW4O,GAAU5O,EAC5C,CCeA+G,EAAAnH,GAAA,cAAA+O,IACA5H,EAAAnH,GAAA,WAAAgP,ICAA7H,EAAAnH,GAAA,cAAA+O,IACA5H,EAAAnH,GAAA,WAAAgP,IC9BA,IAAIU,GAAmB,WCGvB,SAASC,GAAmBvP,GAC3B,MACkB,iBAAVA,GACG,OAAVA,GACwB,iBAAjBA,EAAMW,QACbqO,GAAWhP,EAAMW,SACjBX,EAAMW,QAAU,GAChBX,EAAMW,QAAU6O,EAElB,CCZA,IAAIC,GAAyB,iBCD7B,SAASC,GAAc1P,GACtB,MACkB,iBAAVA,GACG,OAAVA,GACwB,iBAAjBA,EAAMW,QACbqO,GAAWhP,EAAMW,SACjBX,EAAMW,QAAU,GAChBX,EAAMW,QAAU6O,EAElB,CCxBA,IAAIG,GAA0C,mBAAhBC,YAqB9B,SAASC,GAAe7P,GACvB,OACG2P,IAAkB3P,aAAiB4P,aACZ,yBAAzBxG,GAAapJ,EAEf,CCZA,SAAS4O,GAAU5O,GAClB,MACkB,iBAAVA,GACG,OAAVA,IACCqD,GAASrD,EAEZ,CCbA,SAAS8P,GAAU9P,GAClB,MAA0B,iBAAVA,CACjB,CCfA,IAAIoP,GAAUrO,OAAOC,UAAUoO,QCQ/B,IAAI1G,GAAMW,IAmBV,SAASyG,GAAU9P,GAClB,MAAsB,iBAAVA,IACNA,aAAiBe,SAGjB2H,GCnBP,SAAe1I,GACd,IAEC,OADAoP,GAAQnN,KAAMjC,IACP,CACP,CAAC,MAAQkG,GACT,OAAO,CACP,CACF,CDaUwI,CAAM1O,GAEoB,oBAAzBoJ,GAAapJ,IAGxB,CEjBA,SAAS8P,GAAU9P,GAClB,OAAS2O,GAAa3O,IAAW4O,GAAU5O,EAC5C,CCsBA+G,EAAAnH,GAAA,cAAA+O,IACA5H,EAAAnH,GAAA,WAAAgP,ICLA,IAAAmB,GAAA7F,GAAA4F,GAAAnB,aACAqB,GAAA9F,GAAA4F,GAAAlB,UAKAqB,GAAA/F,GAAA4F,IACA/I,EAAAkJ,GAAA,aAAAF,IACAhJ,EAAAkJ,GAAA,UAAAD,IClDA,IAAIvL,GAAK,ICoBT,SAASyL,GAAWlQ,GACnB,MAA0B,kBAAVA,CACjB,CCGA,IAAImQ,GAAOC,QCxBPxO,GAAWwO,QAAQpP,UAAUY,SCSjC,IAAI8G,GAAMW,IAqBV,SAAS6G,GAAWlQ,GACnB,MAAsB,iBAAVA,IACNA,aAAiBoQ,KAGjB1H,GCtBP,SAAe1I,GACd,IAEC,OADA4B,GAASK,KAAMjC,IACR,CACP,CAAC,MAAQkG,GACT,OAAO,CACP,CACF,CDgBUwI,CAAM1O,GAEoB,qBAAzBoJ,GAAapJ,IAGxB,CERA,SAASkQ,GAAWlQ,GACnB,OAAS2O,GAAa3O,IAAW4O,GAAU5O,EAC5C,CCUA+G,EAAAnH,GAAA,cAAA+O,IACA5H,EAAAnH,GAAA,WAAAgP,IC7CA,IAAIvI,GAAwB,iBAATgK,KAAsBA,KAAO,KCA5ChK,GAA0B,iBAAXiK,OAAwBA,OAAS,KCAhDjK,GAA0B,iBAAXkK,OAAwBA,OAAS,KCAhDlK,GAA8B,iBAAfmK,WAA4BA,WAAa,KCK5D,IAAIC,GCsBJ,SAAoBC,GACnB,GAAKrM,UAAU1D,OAAS,CACvB,IAAMuP,GAAWQ,GAChB,MAAM,IAAIxM,UAAWiB,EAAQ,yDAA0DuL,IAExF,GAAKA,EACJ,OC1BK,IAAIC,SAAU,eAAd,ED6BN,CAED,GAAKC,GACJ,OAAOA,GAGR,GAAKC,GACJ,OAAOA,GAGR,GAAKC,GACJ,OAAOA,GAGR,GAAKC,GACJ,OAAOA,GAGR,MAAM,IAAIpP,MAAO,qDAClB,CDlDWqP,GACPC,GAAWR,GAAKS,UAAYT,GAAKS,SAASC,WGR1CC,GAAavG,UCwBjB,IAAIjL,GCNY,mBAAP6E,IAGe,iBAAf2M,IAGa,mBAAbH,GCXT,SAAiB3H,GAChB,OAAO+H,GAAU/H,GAAIrI,aACtB,ECqBA,SAAiBqI,GAChB,IAAIgI,EAGJ,OAAW,OAANhI,EACG,OAKM,YAHdgI,SAAchI,GAIN+H,GAAU/H,GAAIrI,cAEfqQ,CACR,EC7BA,SAASC,GAAYvR,GAEpB,MAA6B,aAApBwR,GAAQxR,EAClB,CCGA,SAASyR,GAAYC,EAAMC,GAC1B,KAAQC,gBAAgBH,IACvB,MAAM,IAAIvN,UAAW,0EAEtB,IAAMnE,GAAU2R,GACf,MAAM,IAAIxN,UAAWiB,EAAQ,kEAAmEuM,IAEjG,IAAM3R,GAAU4R,GACf,MAAM,IAAIzN,UAAWiB,EAAQ,uEAAwEwM,IActG,OAZA7R,EAAgB8R,KAAM,KAAM,CAC3B5K,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAAS0R,IAEV5R,EAAgB8R,KAAM,KAAM,CAC3B5K,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAAS2R,IAEHC,IACR,CAcA7K,EAAa0K,GAAY,oBAAqB,GAgBnCtK,EAAEsK,GAAWzQ,UAAW,oBAAqB,GAgB7CmG,EAAEsK,GAAWzQ,UAAW,aAAc,IAgBtCmG,EAAEsK,GAAWzQ,UAAW,YC1GnC,WAEC,IAAIV,EAAM,GAAKsR,KAAKC,GAOpB,OANKD,KAAKE,GAAK,EACdxR,GAAO,OAAUsR,KAAKE,GAEtBxR,GAAO,MAAQsR,KAAKE,GAErBxR,GAAO,GAER,IDoHW6G,EAAEsK,GAAWzQ,UAAW,UE9HnC,WAEC,IAAIZ,EAAM,CACVA,KAAW,cAGX,OAFAA,EAAIyR,GAAKD,KAAKC,GACdzR,EAAI0R,GAAKF,KAAKE,GACP1R,CACR,ICXA,IAAI2R,GAAkC,mBAAhB3P,KAAK2P,OAA0B3P,KAAK2P,OAAS,KCA/DzH,GAAiC,mBAAjBG,aAAgCA,kBAAe,EC6BnE,IAAAuH,GATKjG,KACG3F,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJIsQ,GAAe,IAAIxH,GAAc,GCuBrC,IAAAyH,GATwB,mBAAZ9L,GACQA,GDApB,SAA2B6I,GAE1B,OADAgD,GAAc,GAAMhD,EACbgD,GAAc,EACtB,EEGA,SAASE,GAAWT,EAAMC,GACzB,KAAQC,gBAAgBO,IACvB,MAAM,IAAIjO,UAAW,0EAEtB,IAAMnE,GAAU2R,GACf,MAAM,IAAIxN,UAAWiB,EAAQ,kEAAmEuM,IAEjG,IAAM3R,GAAU4R,GACf,MAAM,IAAIzN,UAAWiB,EAAQ,uEAAwEwM,IActG,OAZA7R,EAAgB8R,KAAM,KAAM,CAC3B5K,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASoS,GAAkBV,KAE5B5R,EAAgB8R,KAAM,KAAM,CAC3B5K,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASoS,GAAkBT,KAErBC,IACR,CCzBA,SAASS,GAAerS,GACvB,OAAKA,aAAiByR,IAAczR,aAAiBmS,IAInC,iBAAVnS,GACG,OAAVA,GACoB,iBAAbA,EAAM6R,IACO,iBAAb7R,EAAM8R,EAEf,CCPA,SAASQ,GAAQrD,GAChB,OAAOD,GAAWC,EAAE,EACrB,CFkCAlI,EAAaoL,GAAW,oBAAqB,GAgBlChL,EAAEgL,GAAUnR,UAAW,oBAAqB,GAgB5CmG,EAAEgL,GAAUnR,UAAW,aAAc,GAgBrCmG,EAAEgL,GAAUnR,UAAW,YG3GlC,WAEC,IAAIV,EAAM,GAAKsR,KAAKC,GAOpB,OANKD,KAAKE,GAAK,EACdxR,GAAO,OAAUsR,KAAKE,GAEtBxR,GAAO,MAAQsR,KAAKE,GAErBxR,GAAO,GAER,IHqHW6G,EAAEgL,GAAUnR,UAAW,UI/HlC,WAEC,IAAIZ,EAAM,CACVA,KAAW,aAGX,OAFAA,EAAIyR,GAAKD,KAAKC,GACdzR,EAAI0R,GAAKF,KAAKE,GACP1R,CACR,ICXA,IAAImS,GAAoB,EAoBxB,SAASC,GAAkBxS,GAE1B,MACkB,iBAAVA,GACG,OAAVA,GAC2B,mBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMuS,oBAAsBA,EAE9B,CC5BA,IAAIA,GAAoB,GAoBxB,SAASE,GAAmBzS,GAE3B,MACkB,iBAAVA,GACG,OAAVA,GAC2B,oBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMuS,oBAAsBA,EAE9B,CCbA,SAASG,KACR,MACmB,mBAAX/J,IACoB,iBAApBA,GAAQ,QACfK,GAAYL,GAAQ,aACO,iBAApBA,GAAOgK,QAEhB,CC6BA,IAAIC,GAAmBF,KAA+B/J,OAAOgK,SAAW,KCxBxE,SAASE,GAAkCxM,EAAKC,EAAM8B,GACrDtI,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdL,IAAOwB,GAET,CCrBA,SAASsJ,GAAMoB,GACd,OAAOA,EAAEjB,EACV,CCFA,SAASF,GAAMmB,GACd,OAAOA,EAAEhB,EACV,CCSA,SAASiB,GAAa9D,EAAG+D,GACxB,OAAO,IAAIvI,GAAcwE,EAAEgE,OAAQhE,EAAEiE,WAAYjE,EAAEsD,kBAAkBS,EAAS,GAAG/D,EAAEtO,OAAOqS,GAC3F,CCzBA,IAAI1I,GAAiC,mBAAjBI,aAAgCA,kBAAe,EC6BnE,IAAAyI,GATK7H,KACGlF,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECcA,SAASoR,GAAa9D,EAAG+D,GACxB,OAAO,IAAItI,GAAcuE,EAAEgE,OAAQhE,EAAEiE,WAAYjE,EAAEsD,kBAAkBS,EAAS,GAAG/D,EAAEtO,OAAOqS,GAC3F,CCTA,SAASI,GAAcC,GACtB,IAAIjT,EACAkJ,EACAwJ,EAGJ,IADA1S,EAAM,KAELkJ,EAAI+J,EAAGC,QACAC,MAIP,GAAKhE,GADLuD,EAAIxJ,EAAEtJ,QACyB8S,EAAEnS,QAAU,EAC1CP,EAAI8E,KAAM4N,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAI5O,UAAWiB,EAAQ,kJAAmJ2N,IAFjL1S,EAAI8E,KAAMsO,GAAOV,GAAKW,GAAOX,GAG7B,CAEF,OAAO1S,CACR,CCAA,IAAAmS,GAAA,EAAA9H,GAAA8H,kBACAmB,GAAAhB,KAYA,SAAAiB,GAAA3T,GACA,OACAA,aAAAkL,IAEA,iBAAAlL,GACA,OAAAA,IAEA,mBAAAA,EAAAgK,YAAAK,MACA,oBAAArK,EAAAgK,YAAAK,OAEA,iBAAArK,EAAA4T,SAGA,iBAAA5T,EAAA6T,OAGA,CASA,SAAAC,GAAA9T,GACA,OACAA,IAAAkL,IAGA,oBAAAlL,EAAAqK,IAEA,CAUA,SAAA0J,GAAAC,EAAAvM,GAEA,OAAA,IAAA0K,GAAA6B,EADAvM,GAAA,GACAuM,EAAAvM,EAAA,GACA,CAyEA,SAAAyD,KACA,IAAAgI,EACAe,EACAD,EACApK,EAGA,GADAqK,EAAA5P,UAAA1D,SACAiR,gBAAA1G,IACA,OAAA,IAAA+I,EACA,IAAA/I,GAEA,IAAA+I,EACA,IAAA/I,GAAA7G,UAAA,IAEA,IAAA4P,EACA,IAAA/I,GAAA7G,UAAA,GAAAA,UAAA,IAEA,IAAA6G,GAAA7G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAA4P,EACAD,EAAA,IAAAvJ,GAAA,QACA,GAAA,IAAAwJ,EACA,GAAA5E,GAAAhL,UAAA,IACA2P,EAAA,IAAAvJ,GAAA,EAAApG,UAAA,SACA,GAAAqL,GAAArL,UAAA,IAKA,IAHAuF,GADAoK,EAAA3P,UAAA,IACA1D,SAGA0C,GAAA2Q,IAAA3B,GAAA2B,EAAA,KAEA,GADAA,ECxLA,SAAoBA,EAAKxM,GACxB,IAAIoC,EACAN,EACAnJ,EACA8D,EAIJ,IAFA2F,EAAMpC,EAAI7G,OACVsD,EAAI,EACE9D,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,IAAMkS,GADN/I,EAAI9B,EAAKrH,IAER,OAAO,KAER6T,EAAK/P,GAAMuP,GAAOlK,GAClB0K,EAAK/P,EAAE,GAAMwP,GAAOnK,GACpBrF,GAAK,CACL,CACD,OAAO+P,CACR,CDsKAE,CAAA,IAAAzJ,GAAA,EAAAb,GAAAoK,GACA,OAAAA,EAAA,CAEA,IAAA1B,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,6GAAAyE,IAGAoK,EAAA,IAAAvJ,GAAApG,UAAA,GACA,MACA,CACA,GAAAmO,GAAAwB,GACAA,EAAAI,GAAAJ,EAAA,QACA,GAAAvB,GAAAuB,GACAA,EAAAK,GAAAL,EAAA,QACA,IAAA1B,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,6HAAAyE,IAEAoK,EAAA,IAAAvJ,GAAAuJ,EACA,MACA,GAAAnE,GAAAxL,UAAA,IAAA,CAEA,IAAA2K,IADAgF,EAAA3P,UAAA,IACAiQ,WAAA/B,IACA,MAAA,IAAA4B,WAAAhP,EAAA,yFAAAoN,GAAAyB,EAAAM,aAEAN,EAAA,IAAAvJ,GAAAuJ,EACA,KAAA,KAAApF,GAAAvK,UAAA,IAkBA,MAAA,IAAAH,UAAAiB,EAAA,qHAAAd,UAAA,KAhBA,GADA2P,EAAA3P,UAAA,IACA,IAAAqP,GACA,MAAA,IAAAxP,UAAAiB,EAAA,mJAAA6O,IAEA,IAAAzC,GAAAyC,EAAAO,KACA,MAAA,IAAArQ,UAAAiB,EAAA,qHAAA6O,IAGA,IAAAzC,IADAyC,EAAAA,EAAAO,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,qHAAA6O,IAGA,IADAA,EAAAZ,GAAAY,cACArS,MACA,MAAAqS,EAEAA,EAAA,IAAAvJ,GAAAuJ,EAGA,KACA,CAEA,IAAAnE,GADAmE,EAAA3P,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA6O,IAGA,IAAA3E,GADA6D,EAAA7O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA+N,IAEA,IAAAlE,GAAAkE,EAAAX,IACA,MAAA,IAAA4B,WAAAhP,EAAA,uEAAAoN,GAAAW,IAEA,GAAA,IAAAe,EAAA,CAEA,IAAAjF,IADApF,EAAAoK,EAAAM,WAAApB,GACAX,IACA,MAAA,IAAA4B,WAAAhP,EAAA,oGAAAoN,GAAA3I,IAEAoK,EAAA,IAAAvJ,GAAAuJ,EAAAd,EACA,KAAA,CAEA,IAAA7D,GADAzF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAA2I,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAAhP,EAAA,iJAAAyE,EAAA2I,KAEAyB,EAAA,IAAAvJ,GAAAuJ,EAAAd,EAAA,EAAAtJ,EACA,CACA,CAIA,OAHA7C,EAAA6K,KAAA,UAAAoC,GACAjN,EAAA6K,KAAA,UAAAoC,EAAArT,OAAA,GAEAiR,IACA,CEzQA,SAASF,GAAMoB,GACd,OAAOA,EAAEjB,EACV,CCFA,SAASF,GAAMmB,GACd,OAAOA,EAAEhB,EACV,CCEA,SAASsB,GAAcC,GACtB,IAAIjT,EACAkJ,EACAwJ,EAGJ,IADA1S,EAAM,KAELkJ,EAAI+J,EAAGC,QACAC,MAIP,GAAKhE,GADLuD,EAAIxJ,EAAEtJ,QACyB8S,EAAEnS,QAAU,EAC1CP,EAAI8E,KAAM4N,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAI5O,UAAWiB,EAAQ,kJAAmJ2N,IAFjL1S,EAAI8E,KAAMwM,GAAMoB,GAAKnB,GAAMmB,GAG3B,CAEF,OAAO1S,CACR,CJ+PA2G,EAAAmE,GAAA,oBAAAqH,IAeAxL,EAAAmE,GAAA,OAAA,kBAmDA/D,EAAA+D,GAAA,QAAA,SAAAsJ,GACA,IAAAC,EACAR,EACAS,EACAtU,EACA4T,EACAW,EACA/N,EACAgD,EACAgL,EACAtL,EACAnJ,EACA8D,EACA,IAAAsN,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA4P,GAAAlC,MACA,MAAA,IAAA1N,UAAA,6DAGA,IADA+P,EAAA5P,UAAA1D,QACA,EAAA,CAEA,IAAA4Q,GADAmD,EAAArQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAuP,IAEAT,EAAA,IACAQ,EAAApQ,UAAA,GAEA,CACA,GAAAsP,GAAAa,GAAA,CAEA,GADA5K,EAAA4K,EAAA7T,OACA+T,EAAA,CAIA,IAFAV,GADA5T,EAAA,IAAAwR,KAAAhI,IACAiK,QACA5P,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAAkS,GADA/I,EAAAoL,EAAAzS,KAAAwS,EAAAD,EAAA5N,IAAAzG,GAAAA,IAEA6T,EAAA/P,GAAAuP,GAAAlK,GACA0K,EAAA/P,EAAA,GAAAwP,GAAAnK,OACA,MAAAiG,GAAAjG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHA0K,EAAA/P,GAAAqF,EAAA,GACA0K,EAAA/P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAwR,KAAA4C,EACA,CACA,GAAA9E,GAAA8E,GAAA,CACA,GAAAE,EAAA,CAUA,IAPA9K,EAAA4K,EAAA7T,OAEAiG,EADA4N,EAAA5N,KAAA4N,EAAA3N,IACAgO,EAAA,WAEAzM,EAAA,WAGAjI,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA,IAAAkS,GAAAzL,EAAA4N,EAAArU,IAAA,CACAyU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,+FAAA,EAAAyE,IAIA,IADAoK,GADA5T,EAAA,IAAAwR,KAAAhI,EAAA,IACAiK,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAuU,EAAAzS,KAAAwS,EAAA7N,EAAA4N,EAAArU,GAAAA,GAEA,OAAAC,CACA,CAKA,IAFA4T,GADA5T,EAAA,IAAAwR,KAAAhI,IACAiK,QACA5P,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAAkS,GADA/I,EAAAoL,EAAAzS,KAAAwS,EAAA7N,EAAA4N,EAAArU,GAAAA,IAEA6T,EAAA/P,GAAAuP,GAAAlK,GACA0K,EAAA/P,EAAA,GAAAwP,GAAAnK,OACA,MAAAiG,GAAAjG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHA0K,EAAA/P,GAAAqF,EAAA,GACA0K,EAAA/P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAwR,KAAA4C,EACA,CACA,GAAA5F,GAAA4F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,6FAAAqP,IAOA,GAJAG,EADAD,EK/bA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIrU,EACAkJ,EACAwJ,EACA3S,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI+J,EAAGC,QACAC,MAKP,GAFApT,GAAK,EAEAoP,GADLuD,EAAI4B,EAAKzS,KAAMwS,EAASnL,EAAEtJ,MAAOG,KACF2S,EAAEnS,QAAU,EAC1CP,EAAI8E,KAAM4N,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAI5O,UAAWiB,EAAQ,+IAAgJ2N,IAF9K1S,EAAI8E,KAAMsO,GAAOV,GAAKW,GAAOX,GAG7B,CAEF,OAAO1S,CACR,CLwaA0U,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAEAW,aAAAhT,MACA,MAAAgT,EAKA,IADAX,GADA5T,EAAA,IAAAwR,KADAhI,EAAA+K,EAAAhU,OAAA,IAEAkT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAwU,EAAAxU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAqP,GACA,IAoBAzN,EAAAmE,GAAA,MAAA,WACA,IAAA9F,EACAjF,EACA,IAAAoR,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA4P,GAAAlC,MACA,MAAA,IAAA1N,UAAA,6DAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAyR,KAAAxM,EACA,IAuDA+B,EAAA+D,GAAAlK,UAAA,MAAA,SAAAyG,GACA,IAAAkM,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA8K,GAAAvH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAKA,GAHAA,EAAA,IACAA,GAAAmK,KAAAgC,WAEAnM,EAAA,GAAAA,GAAAmK,KAAAgC,SAGA,OAAAG,GAAAnC,KAAAiC,QAAApM,EACA,IAgBAoL,GAAA3H,GAAAlK,UAAA,UAAA,WACA,OAAA4Q,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAA3H,GAAAlK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAS,UACA,IAgBAzB,GAAA3H,GAAAlK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAX,UACA,IAiBA/L,EAAA+D,GAAAlK,UAAA,oBAAAkK,GAAAqH,mBAuCAxL,EAAAmE,GAAAlK,UAAA,cAAA,SAAA+T,EAAAC,GACA,IAAArB,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAQA,OALA,IAAAG,UAAA1D,OACAiR,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,EAAA,EAAA3Q,UAAA,IAEAuN,IACA,IAqCAzK,EAAA+D,GAAAlK,UAAA,WAAA,WACA,IAAAqP,EACA6E,EACAtL,EACAoK,EACAtL,EACAvI,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAiBA,OAfAmM,EAAAuB,KACAoC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAA,CAAAG,EAAA4T,GAAAC,EAAA7T,IACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAA8E,SACA,IAjDAD,CAkDA,IA+BAnO,EAAAmE,GAAAlK,UAAA,SAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,IAAAwJ,EAAA1H,KAAAwS,EAAAV,GAAAC,EAAA7T,GAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA2CA7K,EAAAmE,GAAAlK,UAAA,QAAA,SAAAhB,EAAAgV,EAAAI,GACA,IAAApB,EACApK,EACAnC,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAArS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,0EAAAnF,IAIA,GAFAgU,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAgG,GACA,MAAA,IAAA9Q,UAAAiB,EAAA,qEAAA6P,IAQA,GANAA,EAAA,IACAA,GAAApL,GACA,IACAoL,EAAA,GAGA3Q,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,oEAAAiQ,IAEAA,EAAA,IACAA,GAAAxL,GACA,IACAwL,EAAA,GAGAA,EAAAxL,IACAwL,EAAAxL,EAEA,MACAwL,EAAAxL,CAEA,MACAoL,EAAA,EACAI,EAAAxL,EAIA,IAFAiI,EAAA2B,GAAAxT,GACA8R,EAAA2B,GAAAzT,GACAG,EAAA6U,EAAA7U,EAAAiV,EAAAjV,IAEA6T,EADAvM,EAAA,EAAAtH,GACA0R,EACAmC,EAAAvM,EAAA,GAAAqK,EAEA,OAAAF,IACA,IA2CA7K,EAAAmE,GAAAlK,UAAA,UAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA5T,EACAD,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAqK,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA2S,EAAAiB,GAAAC,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,OACAxR,EAAA8E,KAAA4N,GAGA,OAAA,IAAAlB,KAAA5H,YAAA5J,EACA,IAsCA2G,EAAAmE,GAAAlK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADA2S,EAAAiB,GAAAC,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAkB,CAGA,IAgCA/L,EAAAmE,GAAAlK,UAAA,aAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADA2S,EAAAiB,GAAAC,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IAsCA4G,EAAAmE,GAAAlK,UAAA,YAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADA2S,EAAAiB,GAAAC,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAkB,CAGA,IAgCA/L,EAAAmE,GAAAlK,UAAA,iBAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADA2S,EAAAiB,GAAAC,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IA4BA4G,EAAAmE,GAAAlK,UAAA,WAAA,SAAAqU,EAAAZ,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAAiB,EAAA,oEAAAkQ,IAGA,IADArB,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA2S,EAAAiB,GAAAC,EAAA7T,GACAkV,EAAApT,KAAAwS,EAAA3B,EAAA3S,EAAAyR,KAEA,IAyCAzK,EAAA+D,GAAAlK,UAAA,OAAA,SAAAyG,GACA,IAAAkM,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmL,GAAA5H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAmK,KAAAgC,SAGA,OAAAG,GAAAnC,KAAAiC,QAAApM,EACA,IAmCAV,EAAAmE,GAAAlK,UAAA,YAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAA,EAGA,OAAA,CACA,IAmCAV,EAAAmE,GAAAlK,UAAA,WAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyBAgH,EAAA+D,GAAAlK,UAAA,QAAA,SAAAwU,GACA,IAAApV,EACA4T,EACAyB,EACAtV,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA8U,EAAA,QACA,KAAA3F,GAAA0F,GAGA,MAAA,IAAAtR,UAAAiB,EAAA,kEAAAqQ,IAFAC,EAAAD,CAGA,CAGA,IAFApV,EAAA,GACA4T,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA6O,GAAAC,EAAA7T,GAAAyB,YAEA,OAAAxB,EAAAsV,KAAAD,EACA,IA4BAtO,EAAA+D,GAAAlK,UAAA,QAAA,WACA,IAAAqP,EACA6E,EACAtL,EACAlB,EACAvI,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAgBA,OAdAmM,EAAAuB,KACAhI,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAAG,EACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsF,MACA,IAjDAT,CAkDA,IAsCAnO,EAAAmE,GAAAlK,UAAA,eAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAKA,IAHA/B,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,GAAA,EAAAA,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAgBA0S,GAAA3H,GAAAlK,UAAA,UAAA,WACA,OAAA4Q,KAAAgC,OACA,IAyCA7M,EAAAmE,GAAAlK,UAAA,OAAA,SAAAqU,EAAAZ,GACA,IAAAmB,EACA5B,EACA5T,EACAD,EACAmJ,EACA,IAAAqK,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAAiB,EAAA,oEAAAkQ,IAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADAxV,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAgC,UACAC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAAkS,GADA/I,EAAA+L,EAAApT,KAAAwS,EAAAV,GAAAC,EAAA7T,GAAAA,EAAAyR,OAEAgE,EAAA,EAAAzV,GAAAqT,GAAAlK,GACAsM,EAAA,EAAAzV,EAAA,GAAAsT,GAAAnK,OACA,KAAAiG,GAAAjG,IAAA,IAAAA,EAAA3I,OAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAsM,EAAA,EAAAzV,GAAAmJ,EAAA,GACAsM,EAAA,EAAAzV,EAAA,GAAAmJ,EAAA,EAGA,CAEA,OAAAlJ,CACA,IAmCA2G,EAAAmE,GAAAlK,UAAA,UAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACA+B,EACAnM,EAEAzJ,EAEA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAAhC,GAAAC,EAAA,GACA7T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IAEA4V,EAAAF,EAAAE,EADAhC,GAAAC,EAAA7T,GACAA,EAAAyR,MAEA,OAAAmE,CACA,IAmCAhP,EAAAmE,GAAAlK,UAAA,eAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACA+B,EACAnM,EAEAzJ,EAEA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAAhC,GAAAC,EAAApK,EAAA,GACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IAEA4V,EAAAF,EAAAE,EADAhC,GAAAC,EAAA7T,GACAA,EAAAyR,MAEA,OAAAmE,CACA,IAmDA5O,EAAA+D,GAAAlK,UAAA,WAAA,WACA,IAAAgT,EACAW,EACA/K,EACAoM,EACA7V,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAKA,IAHA0F,EAAAgI,KAAAgC,QACAI,EAAApC,KAAAiC,QACAmC,EAAAjH,GAAAnF,EAAA,GACAzJ,EAAA,EAAAA,EAAA6V,EAAA7V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAwU,EAAAX,EAAA,EAAA7T,GACA6T,EAAA,EAAA7T,GAAA6T,EAAA,EAAA/P,GACA+P,EAAA,EAAA/P,GAAA0Q,EACAA,EAAAX,EAAA,EAAA7T,EAAA,GACA6T,EAAA,EAAA7T,EAAA,GAAA6T,EAAA,EAAA/P,EAAA,GACA+P,EAAA,EAAA/P,EAAA,GAAA0Q,EAEA,OAAA/C,IACA,IAgEAzK,EAAA+D,GAAAlK,UAAA,OAAA,SAAAhB,GAEA,IAAAiW,EACAxO,EACAuM,EACAW,EACAC,EACAoB,EACA1M,EACAnJ,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAGA,GADA8P,EAAApC,KAAAiC,QACAxP,UAAA1D,OAAA,GAEA,IAAA0O,GADA5H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAA4K,GAAArS,GAAA,CACA,GAAAyH,GAAAmK,KAAAgC,QACA,MAAA,IAAAO,WAAAhP,EAAA,kEAAAsC,IAKA,OAFAuM,EADAvM,GAAA,GACA+L,GAAAxT,QACAgU,EAAAvM,EAAA,GAAAgM,GAAAzT,GAEA,CACA,GAAA2T,GAAA3T,GAAA,CAEA,GAAAyH,GADAuO,EAAAhW,EAAA4T,SACAhC,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAAjW,EAAA6T,QAGA5P,EAAA+P,EAAAd,WAAAzL,EAAA8K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAAjP,GACAgS,EAAA/C,WAAA+C,EAAA3B,WAAArQ,EAEA,CAGA,IADA0Q,EAAA,IAAAlK,GAAAwL,EAAAtV,QACAR,EAAA,EAAAA,EAAA8V,EAAAtV,OAAAR,IACAwU,EAAAxU,GAAA8V,EAAA9V,GAEA8V,EAAAtB,CACA,CAGA,IAFAlN,GAAA,EACAxD,EAAA,EACA9D,EAAA,EAAAA,EAAA6V,EAAA7V,IACA6T,EAAAvM,GAAAwO,EAAAhS,GACA+P,EAAAvM,EAAA,GAAAwO,EAAAhS,EAAA,GACAwD,GAAA,EACAxD,GAAA,CAGA,KAhCA,CAiCA,IAAAyL,GAAA1P,GA2DA,MAAA,IAAAkE,UAAAiB,EAAA,kIAAAnF,IAxDA,IADAgW,EAAAhW,EAAAW,OACAR,EAAA,EAAAA,EAAA6V,EAAA7V,IACA,IAAAkS,GAAArS,EAAAG,IAAA,CACAyU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA0D,GACA,MAAA,IAAA7B,WAAAhP,EAAA,6GAAA6Q,IAEA,GAAAvO,EAAAuO,EAAA,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAAjW,EAGAiE,EAAA+P,EAAAd,WAAAzL,EAAA8K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAAjP,GACAgS,EAAA/C,WAAA+C,EAAA3B,WAAArQ,EAEA,CAGA,IADA0Q,EAAA,IAAAlK,GAAAuL,GACA7V,EAAA,EAAAA,EAAA6V,EAAA7V,IACAwU,EAAAxU,GAAA8V,EAAA9V,GAEA8V,EAAAtB,CACA,CAIA,IAHAlN,GAAA,EACAuO,GAAA,EACA/R,EAAA,EACA9D,EAAA,EAAAA,EAAA6V,EAAA7V,IACA6T,EAAAvM,GAAAwO,EAAAhS,GACA+P,EAAAvM,EAAA,GAAAwO,EAAAhS,EAAA,GACAwD,GAAA,EACAxD,GAAA,EAEA,MACA,CAEA,GAAAwD,EAAAuO,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAGA,IADA1M,GAAA,EACAtH,EAAA,EAAAA,EAAA6V,EAAA7V,IACAmJ,EAAAtJ,EAAAG,GACA6T,EAAAvM,GAAA+L,GAAAlK,GACA0K,EAAAvM,EAAA,GAAAgM,GAAAnK,GACA7B,GAAA,CAxDA,CA+DA,IA2EAV,EAAAmE,GAAAlK,UAAA,SAAA,SAAAgU,EAAAI,GACA,IAAAc,EACAN,EACAxV,EACAqH,EACAuM,EACApK,EACAzJ,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACAqU,EAAA,EACAI,EAAAxL,MACA,CACA,IAAAoF,GAAAgG,GACA,MAAA,IAAA9Q,UAAAiB,EAAA,oEAAA6P,IAQA,GANAA,EAAA,IACAA,GAAApL,GACA,IACAoL,EAAA,GAGA,IAAA3Q,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAQA,IANAsM,EADAlB,EAAAI,EACAA,EAAAJ,EAEA,EAGAY,GADAxV,EAAA,IAAAwR,KAAA5H,YAAAkM,IACArC,QACA1T,EAAA,EAAAA,EAAA+V,EAAA/V,IACAsH,EAAA,GAAAtH,EAAA6U,GACAY,EAAA,EAAAzV,GAAA6T,EAAAvM,GACAmO,EAAA,EAAAzV,EAAA,GAAA6T,EAAAvM,EAAA,GAEA,OAAArH,CACA,IA+BA2G,EAAAmE,GAAAlK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,GAAAwJ,EAAA1H,KAAAwS,EAAAV,GAAAC,EAAA7T,GAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA6EAzK,EAAA+D,GAAAlK,UAAA,QAAA,SAAAmV,GACA,IAAAxB,EACAX,EACApK,EACAzJ,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAKA,IAHAnC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAe,EAAA,GACAxU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAwU,EAAAzP,KAAA6O,GAAAC,EAAA7T,IAGA,IADAwU,EAAAyB,KAAAD,GACAhW,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAEA6T,EADA/P,EAAA,EAAA9D,GACAqT,GAAAmB,EAAAxU,IACA6T,EAAA/P,EAAA,GAAAwP,GAAAkB,EAAAxU,IAEA,OAAAyR,IACA,IA2EA7K,EAAAmE,GAAAlK,UAAA,YAAA,SAAAqV,EAAAjB,GACA,IAAApC,EACAgB,EACApK,EACA,IAAA+J,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACA0V,EAAA,EACAjB,EAAAxL,MACA,CACA,IAAAoF,GAAAqH,GACA,MAAA,IAAAnS,UAAAiB,EAAA,oEAAAkR,IAQA,GANAA,EAAA,IACAA,GAAAzM,GACA,IACAyM,EAAA,GAGA,IAAAhS,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAWA,OAVAyM,GAAAzM,GACAA,EAAA,EACAoJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACAxL,EAAA,EACAoJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEA3I,EAAAwL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAA5H,YAAAgK,EAAAf,OAAAD,EAAApJ,EAAA,EAAA,EAAAA,EACA,IAwBA7C,EAAAmE,GAAAlK,UAAA,kBAAA,SAAAsV,EAAAC,GACA,IAAAC,EACAC,EACArW,EACA4T,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA8V,EAAA,OACA,KAAA3G,GAAAwG,KAAArG,GAAAqG,GAGA,MAAA,IAAApS,UAAAiB,EAAA,yFAAAmR,IAFAG,EAAAH,CAGA,CACA,GAAAjS,UAAA1D,OAAA,EACA6V,EAAA,CAAA,MACA,KAAA5H,GAAA2H,GAGA,MAAA,IAAArS,UAAAiB,EAAA,qEAAAoR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA6O,GAAAC,EAAA7T,GAAAuW,eAAAD,EAAAD,IAEA,OAAApW,EAAAsV,KAAA,IACA,IAmDAvO,EAAA+D,GAAAlK,UAAA,cAAA,WACA,IAAA4U,EACAxV,EACAwJ,EACAoK,EACA7T,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAMA,IAJA0F,EAAAgI,KAAAgC,QACAxT,EAAA,IAAAwR,KAAA5H,YAAAJ,GACAoK,EAAApC,KAAAiC,QACA+B,EAAAxV,EAAAyT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAyV,EAAA,EAAAzV,GAAA6T,EAAA,EAAA/P,GACA2R,EAAA,EAAAzV,EAAA,GAAA6T,EAAA,EAAA/P,EAAA,GAEA,OAAA7D,CACA,IA6EA+G,EAAA+D,GAAAlK,UAAA,YAAA,SAAAmV,GACA,IAAAxB,EACAX,EACApK,EACAzJ,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAKA,IAHAnC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAe,EAAA,GACAxU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAwU,EAAAzP,KAAA6O,GAAAC,EAAA7T,IAGA,OADAwU,EAAAyB,KAAAD,GACA,IAAAjL,GAAAyJ,EACA,IAoBAxN,EAAA+D,GAAAlK,UAAA,YAAA,WACA,IAAAZ,EACA4T,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,IAFA9D,EAAA,GACA4T,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA6O,GAAAC,EAAA7T,GAAAyB,YAEA,OAAAxB,EAAAsV,KAAA,IACA,IA0CAvO,EAAA+D,GAAAlK,UAAA,UAAA,WACA,IAAAkU,EACA7E,EACAzG,EACAlB,EACAsL,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAiBA,OAfAmM,EAAAuB,KACAoC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAA+T,GAAAC,EAAA7T,GACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsG,QACA,IAjDAzB,CAkDA,IAuCAnO,EAAAmE,GAAAlK,UAAA,QAAA,SAAA4V,EAAA5W,GACA,IAAAgU,EACA5T,EACAwJ,EACA,IAAA+J,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA8K,GAAA4H,GACA,MAAA,IAAA1S,UAAAiB,EAAA,oEAAAyR,IAMA,GAJAhN,EAAAgI,KAAAgC,QACAgD,EAAA,IACAA,GAAAhN,GAEAgN,EAAA,GAAAA,GAAAhN,EACA,MAAA,IAAAuK,WAAAhP,EAAA,kEAAAyR,IAEA,IAAAvE,GAAArS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,2EAAAnF,IAMA,OAHAgU,GADA5T,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAiC,UACAA,SACA,EAAA+C,GAAApD,GAAAxT,GACAgU,EAAA,EAAA4C,EAAA,GAAAnD,GAAAzT,GACAI,CACA,IM15FA,IAAAmS,GAAA,EAAA7H,GAAA6H,kBACAmB,GAAAhB,KAYA,SAAAiB,GAAA3T,GACA,OACAA,aAAAmL,IAEA,iBAAAnL,GACA,OAAAA,IAEA,mBAAAA,EAAAgK,YAAAK,MACA,oBAAArK,EAAAgK,YAAAK,OAEA,iBAAArK,EAAA4T,SAGA,iBAAA5T,EAAA6T,OAGA,CASA,SAAAC,GAAA9T,GACA,OACAA,IAAAmL,IAGA,mBAAAnL,EAAAqK,IAEA,CAUA,SAAAwM,GAAA7C,EAAAvM,GAEA,OAAA,IAAAgK,GAAAuC,EADAvM,GAAA,GACAuM,EAAAvM,EAAA,GACA,CAyEA,SAAA0D,KACA,IAAA+H,EACAe,EACAD,EACApK,EAGA,GADAqK,EAAA5P,UAAA1D,SACAiR,gBAAAzG,IACA,OAAA,IAAA8I,EACA,IAAA9I,GAEA,IAAA8I,EACA,IAAA9I,GAAA9G,UAAA,IAEA,IAAA4P,EACA,IAAA9I,GAAA9G,UAAA,GAAAA,UAAA,IAEA,IAAA8G,GAAA9G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAA4P,EACAD,EAAA,IAAAtJ,GAAA,QACA,GAAA,IAAAuJ,EACA,GAAA5E,GAAAhL,UAAA,IACA2P,EAAA,IAAAtJ,GAAA,EAAArG,UAAA,SACA,GAAAqL,GAAArL,UAAA,IAKA,IAHAuF,GADAoK,EAAA3P,UAAA,IACA1D,SAGA0C,GAAA2Q,IAAA3B,GAAA2B,EAAA,KAEA,GADAA,ECxLA,SAAoBA,EAAKxM,GACxB,IAAIoC,EACAN,EACAnJ,EACA8D,EAIJ,IAFA2F,EAAMpC,EAAI7G,OACVsD,EAAI,EACE9D,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,IAAMkS,GADN/I,EAAI9B,EAAKrH,IAER,OAAO,KAER6T,EAAK/P,GAAMyN,GAAMpI,GACjB0K,EAAK/P,EAAE,GAAM0N,GAAMrI,GACnBrF,GAAK,CACL,CACD,OAAO+P,CACR,CDsKAE,CAAA,IAAAxJ,GAAA,EAAAd,GAAAoK,GACA,OAAAA,EAAA,CAEA,IAAA1B,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,6GAAAyE,IAGAoK,EAAA,IAAAtJ,GAAArG,UAAA,GACA,MACA,CACA,GAAAmO,GAAAwB,GACAA,EAAAI,GAAAJ,EAAA,QACA,GAAAvB,GAAAuB,GACAA,EAAAK,GAAAL,EAAA,QACA,IAAA1B,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,6HAAAyE,IAEAoK,EAAA,IAAAtJ,GAAAsJ,EACA,MACA,GAAAnE,GAAAxL,UAAA,IAAA,CAEA,IAAA2K,IADAgF,EAAA3P,UAAA,IACAiQ,WAAA/B,IACA,MAAA,IAAA4B,WAAAhP,EAAA,yFAAAoN,GAAAyB,EAAAM,aAEAN,EAAA,IAAAtJ,GAAAsJ,EACA,KAAA,KAAApF,GAAAvK,UAAA,IAkBA,MAAA,IAAAH,UAAAiB,EAAA,qHAAAd,UAAA,KAhBA,GADA2P,EAAA3P,UAAA,IACA,IAAAqP,GACA,MAAA,IAAAxP,UAAAiB,EAAA,mJAAA6O,IAEA,IAAAzC,GAAAyC,EAAAO,KACA,MAAA,IAAArQ,UAAAiB,EAAA,qHAAA6O,IAGA,IAAAzC,IADAyC,EAAAA,EAAAO,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,qHAAA6O,IAGA,IADAA,EAAAZ,GAAAY,cACArS,MACA,MAAAqS,EAEAA,EAAA,IAAAtJ,GAAAsJ,EAGA,KACA,CAEA,IAAAnE,GADAmE,EAAA3P,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA6O,IAGA,IAAA3E,GADA6D,EAAA7O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA+N,IAEA,IAAAlE,GAAAkE,EAAAX,IACA,MAAA,IAAA4B,WAAAhP,EAAA,uEAAAoN,GAAAW,IAEA,GAAA,IAAAe,EAAA,CAEA,IAAAjF,IADApF,EAAAoK,EAAAM,WAAApB,GACAX,IACA,MAAA,IAAA4B,WAAAhP,EAAA,oGAAAoN,GAAA3I,IAEAoK,EAAA,IAAAtJ,GAAAsJ,EAAAd,EACA,KAAA,CAEA,IAAA7D,GADAzF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAA2I,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAAhP,EAAA,iJAAAyE,EAAA2I,KAEAyB,EAAA,IAAAtJ,GAAAsJ,EAAAd,EAAA,EAAAtJ,EACA,CACA,CAIA,OAHA7C,EAAA6K,KAAA,UAAAoC,GACAjN,EAAA6K,KAAA,UAAAoC,EAAArT,OAAA,GAEAiR,IACA,CEzQA,SAASwB,GAAcC,GACtB,IAAIjT,EACAkJ,EAGJ,IADAlJ,EAAM,KAELkJ,EAAI+J,EAAGC,QACAC,MAGPnT,EAAI8E,KAAMkL,GAAS9G,EAAEtJ,QAEtB,OAAOI,CACR,CF2QA2G,EAAAoE,GAAA,oBAAAoH,IAeAxL,EAAAoE,GAAA,OAAA,mBAmDAhE,EAAAgE,GAAA,QAAA,SAAAqJ,GACA,IAAAC,EACAR,EACAS,EACAtU,EACA4T,EACAW,EACA/N,EACAgD,EACAgL,EACAtL,EACAnJ,EACA8D,EACA,IAAAsN,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA4P,GAAAlC,MACA,MAAA,IAAA1N,UAAA,6DAGA,IADA+P,EAAA5P,UAAA1D,QACA,EAAA,CAEA,IAAA4Q,GADAmD,EAAArQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAuP,IAEAT,EAAA,IACAQ,EAAApQ,UAAA,GAEA,CACA,GAAAsP,GAAAa,GAAA,CAEA,GADA5K,EAAA4K,EAAA7T,OACA+T,EAAA,CAIA,IAFAV,GADA5T,EAAA,IAAAwR,KAAAhI,IACAiK,QACA5P,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAAkS,GADA/I,EAAAoL,EAAAzS,KAAAwS,EAAAD,EAAA5N,IAAAzG,GAAAA,IAEA6T,EAAA/P,GAAAyN,GAAApI,GACA0K,EAAA/P,EAAA,GAAA0N,GAAArI,OACA,MAAAiG,GAAAjG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHA0K,EAAA/P,GAAAqF,EAAA,GACA0K,EAAA/P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAwR,KAAA4C,EACA,CACA,GAAA9E,GAAA8E,GAAA,CACA,GAAAE,EAAA,CAUA,IAPA9K,EAAA4K,EAAA7T,OAEAiG,EADA4N,EAAA5N,KAAA4N,EAAA3N,IACAgO,EAAA,WAEAzM,EAAA,WAGAjI,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA,IAAAkS,GAAAzL,EAAA4N,EAAArU,IAAA,CACAyU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,gGAAAyE,IAIA,IADAoK,GADA5T,EAAA,IAAAwR,KAAAhI,EAAA,IACAiK,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAuU,EAAAzS,KAAAwS,EAAA7N,EAAA4N,EAAArU,GAAAA,GAEA,OAAAC,CACA,CAKA,IAFA4T,GADA5T,EAAA,IAAAwR,KAAAhI,IACAiK,QACA5P,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAAkS,GADA/I,EAAAoL,EAAAzS,KAAAwS,EAAA7N,EAAA4N,EAAArU,GAAAA,IAEA6T,EAAA/P,GAAAyN,GAAApI,GACA0K,EAAA/P,EAAA,GAAA0N,GAAArI,OACA,MAAAiG,GAAAjG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHA0K,EAAA/P,GAAAqF,EAAA,GACA0K,EAAA/P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAwR,KAAA4C,EACA,CACA,GAAA5F,GAAA4F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,6FAAAqP,IAOA,GAJAG,EADAD,EG/bA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIrU,EACAkJ,EACAwJ,EACA3S,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI+J,EAAGC,QACAC,MAKP,GAFApT,GAAK,EAEAoP,GADLuD,EAAI4B,EAAKzS,KAAMwS,EAASnL,EAAEtJ,MAAOG,KACF2S,EAAEnS,QAAU,EAC1CP,EAAI8E,KAAM4N,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAI5O,UAAWiB,EAAQ,+IAAgJ2N,IAF9K1S,EAAI8E,KAAMwM,GAAMoB,GAAKnB,GAAMmB,GAG3B,CAEF,OAAO1S,CACR,CHwaA0U,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAEAW,aAAAhT,MACA,MAAAgT,EAKA,IADAX,GADA5T,EAAA,IAAAwR,KADAhI,EAAA+K,EAAAhU,OAAA,IAEAkT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAwU,EAAAxU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAqP,GACA,IAoBAzN,EAAAoE,GAAA,MAAA,WACA,IAAA/F,EACAjF,EACA,IAAAoR,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA4P,GAAAlC,MACA,MAAA,IAAA1N,UAAA,6DAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAyR,KAAAxM,EACA,IAwDA+B,EAAAgE,GAAAnK,UAAA,MAAA,SAAAyG,GACA,IAAAkM,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA8K,GAAAvH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAKA,GAHAA,EAAA,IACAA,GAAAmK,KAAAgC,WAEAnM,EAAA,GAAAA,GAAAmK,KAAAgC,SAGA,OAAAiD,GAAAjF,KAAAiC,QAAApM,EACA,IAgBAoL,GAAA1H,GAAAnK,UAAA,UAAA,WACA,OAAA4Q,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAA1H,GAAAnK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAS,UACA,IAgBAzB,GAAA1H,GAAAnK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAX,UACA,IAiBA/L,EAAAgE,GAAAnK,UAAA,oBAAAmK,GAAAoH,mBAuCAxL,EAAAoE,GAAAnK,UAAA,cAAA,SAAA+T,EAAAC,GACA,IAAArB,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAQA,OALA,IAAAG,UAAA1D,OACAiR,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,EAAA,EAAA3Q,UAAA,IAEAuN,IACA,IAqCAzK,EAAAgE,GAAAnK,UAAA,WAAA,WACA,IAAAiS,EACA5C,EACA6E,EACAtL,EACAlB,EACAvI,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAkBA,OAhBAmM,EAAAuB,KACAqB,EAAArB,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EACA8D,GAAA,EAIA8C,EADAmO,EAAA,CAAA,EACA,QAcA,WACA,IAAApC,EAEA,GADA3S,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAKA,OADAT,EAAA,IAAArB,GAAAwB,EADAhP,GAAA,GACAgP,EAAAhP,EAAA,IACA,CACAjE,MAAA,CAAAG,EAAA2S,GACAS,MAAA,EAEA,IA3BAxM,EAAAmO,EAAA,UAoCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA7CAgB,IACAxN,EAAAmO,EAAAX,IAoDA,WACA,OAAAlE,EAAA8E,SACA,IApDAD,CAqDA,IA+BAnO,EAAAoE,GAAAnK,UAAA,SAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,IAAAwJ,EAAA1H,KAAAwS,EAAAoC,GAAA7C,EAAA7T,GAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA2CA7K,EAAAoE,GAAAnK,UAAA,QAAA,SAAAhB,EAAAgV,EAAAI,GACA,IAAApB,EACApK,EACAnC,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAArS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,0EAAAnF,IAIA,GAFAgU,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAgG,GACA,MAAA,IAAA9Q,UAAAiB,EAAA,qEAAA6P,IAQA,GANAA,EAAA,IACAA,GAAApL,GACA,IACAoL,EAAA,GAGA3Q,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,oEAAAiQ,IAEAA,EAAA,IACAA,GAAAxL,GACA,IACAwL,EAAA,GAGAA,EAAAxL,IACAwL,EAAAxL,EAEA,MACAwL,EAAAxL,CAEA,MACAoL,EAAA,EACAI,EAAAxL,EAIA,IAFAiI,EAAAH,GAAA1R,GACA8R,EAAAH,GAAA3R,GACAG,EAAA6U,EAAA7U,EAAAiV,EAAAjV,IAEA6T,EADAvM,EAAA,EAAAtH,GACA0R,EACAmC,EAAAvM,EAAA,GAAAqK,EAEA,OAAAF,IACA,IA2CA7K,EAAAoE,GAAAnK,UAAA,UAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA5T,EACAD,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAqK,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA2S,EAAA+D,GAAA7C,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,OACAxR,EAAA8E,KAAA4N,GAGA,OAAA,IAAAlB,KAAA5H,YAAA5J,EACA,IAqCA2G,EAAAoE,GAAAnK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADA2S,EAAA+D,GAAA7C,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAkB,CAGA,IA+BA/L,EAAAoE,GAAAnK,UAAA,aAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADA2S,EAAA+D,GAAA7C,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IAqCA4G,EAAAoE,GAAAnK,UAAA,YAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADA2S,EAAA+D,GAAA7C,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAkB,CAGA,IA+BA/L,EAAAoE,GAAAnK,UAAA,iBAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADA2S,EAAA+D,GAAA7C,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IA4BA4G,EAAAoE,GAAAnK,UAAA,WAAA,SAAAqU,EAAAZ,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAAiB,EAAA,oEAAAkQ,IAGA,IADArB,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA2S,EAAA+D,GAAA7C,EAAA7T,GACAkV,EAAApT,KAAAwS,EAAA3B,EAAA3S,EAAAyR,KAEA,IAyCAzK,EAAAgE,GAAAnK,UAAA,OAAA,SAAAyG,GACA,IAAAkM,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmL,GAAA5H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAmK,KAAAgC,SAGA,OAAAiD,GAAAjF,KAAAiC,QAAApM,EACA,IAgBAoL,GAAA1H,GAAAnK,UAAA,UAAA,WACA,OAAA4Q,KAAAgC,OACA,IAmCA7M,EAAAoE,GAAAnK,UAAA,YAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAA,EAGA,OAAA,CACA,IAmCAV,EAAAoE,GAAAnK,UAAA,WAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyBAgH,EAAAgE,GAAAnK,UAAA,QAAA,SAAAwU,GACA,IAAApV,EACA4T,EACAyB,EACAtV,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA8U,EAAA,QACA,KAAA3F,GAAA0F,GAGA,MAAA,IAAAtR,UAAAiB,EAAA,kEAAAqQ,IAFAC,EAAAD,CAGA,CAGA,IAFApV,EAAA,GACA4T,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA2R,GAAA7C,EAAA7T,GAAAyB,YAEA,OAAAxB,EAAAsV,KAAAD,EACA,IA4BAtO,EAAAgE,GAAAnK,UAAA,QAAA,WACA,IAAAqP,EACA6E,EACAtL,EACAlB,EACAvI,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAgBA,OAdAmM,EAAAuB,KACAhI,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAAG,EACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsF,MACA,IAjDAT,CAkDA,IAsCAnO,EAAAoE,GAAAnK,UAAA,eAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAKA,IAHA/B,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,GAAA,EAAAA,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyCA4G,EAAAoE,GAAAnK,UAAA,OAAA,SAAAqU,EAAAZ,GACA,IAAAmB,EACA5B,EACA5T,EACAD,EACAmJ,EACA,IAAAqK,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAAiB,EAAA,oEAAAkQ,IAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADAxV,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAgC,UACAC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAAkS,GADA/I,EAAA+L,EAAApT,KAAAwS,EAAAoC,GAAA7C,EAAA7T,GAAAA,EAAAyR,OAEAgE,EAAA,EAAAzV,GAAAuR,GAAApI,GACAsM,EAAA,EAAAzV,EAAA,GAAAwR,GAAArI,OACA,KAAAiG,GAAAjG,IAAA,IAAAA,EAAA3I,OAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAsM,EAAA,EAAAzV,GAAAmJ,EAAA,GACAsM,EAAA,EAAAzV,EAAA,GAAAmJ,EAAA,EAGA,CAEA,OAAAlJ,CACA,IAmCA2G,EAAAoE,GAAAnK,UAAA,UAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACA+B,EACAnM,EAEAzJ,EAEA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAAc,GAAA7C,EAAA,GACA7T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IAEA4V,EAAAF,EAAAE,EADAc,GAAA7C,EAAA7T,GACAA,EAAAyR,MAEA,OAAAmE,CACA,IAmCAhP,EAAAoE,GAAAnK,UAAA,eAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACA+B,EACAnM,EAEAzJ,EAEA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAAc,GAAA7C,EAAApK,EAAA,GACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IAEA4V,EAAAF,EAAAE,EADAc,GAAA7C,EAAA7T,GACAA,EAAAyR,MAEA,OAAAmE,CACA,IAmDA5O,EAAAgE,GAAAnK,UAAA,WAAA,WACA,IAAAgT,EACAW,EACA/K,EACAoM,EACA7V,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAKA,IAHA0F,EAAAgI,KAAAgC,QACAI,EAAApC,KAAAiC,QACAmC,EAAAjH,GAAAnF,EAAA,GACAzJ,EAAA,EAAAA,EAAA6V,EAAA7V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAwU,EAAAX,EAAA,EAAA7T,GACA6T,EAAA,EAAA7T,GAAA6T,EAAA,EAAA/P,GACA+P,EAAA,EAAA/P,GAAA0Q,EACAA,EAAAX,EAAA,EAAA7T,EAAA,GACA6T,EAAA,EAAA7T,EAAA,GAAA6T,EAAA,EAAA/P,EAAA,GACA+P,EAAA,EAAA/P,EAAA,GAAA0Q,EAEA,OAAA/C,IACA,IAgEAzK,EAAAgE,GAAAnK,UAAA,OAAA,SAAAhB,GAEA,IAAAiW,EACAxO,EACAuM,EACAW,EACAC,EACAoB,EACA1M,EACAnJ,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAGA,GADA8P,EAAApC,KAAAiC,QACAxP,UAAA1D,OAAA,GAEA,IAAA0O,GADA5H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAA4K,GAAArS,GAAA,CACA,GAAAyH,GAAAmK,KAAAgC,QACA,MAAA,IAAAO,WAAAhP,EAAA,kEAAAsC,IAKA,OAFAuM,EADAvM,GAAA,GACAiK,GAAA1R,QACAgU,EAAAvM,EAAA,GAAAkK,GAAA3R,GAEA,CACA,GAAA2T,GAAA3T,GAAA,CAEA,GAAAyH,GADAuO,EAAAhW,EAAA4T,SACAhC,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAAjW,EAAA6T,QAGA5P,EAAA+P,EAAAd,WAAAzL,EAAA8K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAAjP,GACAgS,EAAA/C,WAAA+C,EAAA3B,WAAArQ,EAEA,CAGA,IADA0Q,EAAA,IAAAjK,GAAAuL,EAAAtV,QACAR,EAAA,EAAAA,EAAA8V,EAAAtV,OAAAR,IACAwU,EAAAxU,GAAA8V,EAAA9V,GAEA8V,EAAAtB,CACA,CAGA,IAFAlN,GAAA,EACAxD,EAAA,EACA9D,EAAA,EAAAA,EAAA6V,EAAA7V,IACA6T,EAAAvM,GAAAwO,EAAAhS,GACA+P,EAAAvM,EAAA,GAAAwO,EAAAhS,EAAA,GACAwD,GAAA,EACAxD,GAAA,CAGA,KAhCA,CAiCA,IAAAyL,GAAA1P,GA2DA,MAAA,IAAAkE,UAAAiB,EAAA,kIAAAnF,IAxDA,IADAgW,EAAAhW,EAAAW,OACAR,EAAA,EAAAA,EAAA6V,EAAA7V,IACA,IAAAkS,GAAArS,EAAAG,IAAA,CACAyU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA0D,GACA,MAAA,IAAA7B,WAAAhP,EAAA,6GAAA6Q,IAEA,GAAAvO,EAAAuO,EAAA,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAAjW,EAGAiE,EAAA+P,EAAAd,WAAAzL,EAAA8K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAAjP,GACAgS,EAAA/C,WAAA+C,EAAA3B,WAAArQ,EAEA,CAGA,IADA0Q,EAAA,IAAAjK,GAAAsL,GACA7V,EAAA,EAAAA,EAAA6V,EAAA7V,IACAwU,EAAAxU,GAAA8V,EAAA9V,GAEA8V,EAAAtB,CACA,CAIA,IAHAlN,GAAA,EACAuO,GAAA,EACA/R,EAAA,EACA9D,EAAA,EAAAA,EAAA6V,EAAA7V,IACA6T,EAAAvM,GAAAwO,EAAAhS,GACA+P,EAAAvM,EAAA,GAAAwO,EAAAhS,EAAA,GACAwD,GAAA,EACAxD,GAAA,EAEA,MACA,CAEA,GAAAwD,EAAAuO,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAGA,IADA1M,GAAA,EACAtH,EAAA,EAAAA,EAAA6V,EAAA7V,IACAmJ,EAAAtJ,EAAAG,GACA6T,EAAAvM,GAAAiK,GAAApI,GACA0K,EAAAvM,EAAA,GAAAkK,GAAArI,GACA7B,GAAA,CAxDA,CA+DA,IA2EAV,EAAAoE,GAAAnK,UAAA,SAAA,SAAAgU,EAAAI,GACA,IAAAc,EACAN,EACAxV,EACAqH,EACAuM,EACApK,EACAzJ,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACAqU,EAAA,EACAI,EAAAxL,MACA,CACA,IAAAoF,GAAAgG,GACA,MAAA,IAAA9Q,UAAAiB,EAAA,oEAAA6P,IAQA,GANAA,EAAA,IACAA,GAAApL,GACA,IACAoL,EAAA,GAGA,IAAA3Q,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAQA,IANAsM,EADAlB,EAAAI,EACAA,EAAAJ,EAEA,EAGAY,GADAxV,EAAA,IAAAwR,KAAA5H,YAAAkM,IACArC,QACA1T,EAAA,EAAAA,EAAA+V,EAAA/V,IACAsH,EAAA,GAAAtH,EAAA6U,GACAY,EAAA,EAAAzV,GAAA6T,EAAAvM,GACAmO,EAAA,EAAAzV,EAAA,GAAA6T,EAAAvM,EAAA,GAEA,OAAArH,CACA,IA+BA2G,EAAAoE,GAAAnK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,GAAAwJ,EAAA1H,KAAAwS,EAAAoC,GAAA7C,EAAA7T,GAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA6EAzK,EAAAgE,GAAAnK,UAAA,QAAA,SAAAmV,GACA,IAAAxB,EACAX,EACApK,EACAzJ,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAKA,IAHAnC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAe,EAAA,GACAxU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAwU,EAAAzP,KAAA2R,GAAA7C,EAAA7T,IAGA,IADAwU,EAAAyB,KAAAD,GACAhW,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAEA6T,EADA/P,EAAA,EAAA9D,GACAuR,GAAAiD,EAAAxU,IACA6T,EAAA/P,EAAA,GAAA0N,GAAAgD,EAAAxU,IAEA,OAAAyR,IACA,IA2EA7K,EAAAoE,GAAAnK,UAAA,YAAA,SAAAqV,EAAAjB,GACA,IAAApC,EACAgB,EACApK,EACA,IAAA+J,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACA0V,EAAA,EACAjB,EAAAxL,MACA,CACA,IAAAoF,GAAAqH,GACA,MAAA,IAAAnS,UAAAiB,EAAA,oEAAAkR,IAQA,GANAA,EAAA,IACAA,GAAAzM,GACA,IACAyM,EAAA,GAGA,IAAAhS,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAWA,OAVAyM,GAAAzM,GACAA,EAAA,EACAoJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACAxL,EAAA,EACAoJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEA3I,EAAAwL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAA5H,YAAAgK,EAAAf,OAAAD,EAAApJ,EAAA,EAAA,EAAAA,EACA,IAwBA7C,EAAAoE,GAAAnK,UAAA,kBAAA,SAAAsV,EAAAC,GACA,IAAAC,EACAC,EACArW,EACA4T,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA8V,EAAA,OACA,KAAA3G,GAAAwG,KAAArG,GAAAqG,GAGA,MAAA,IAAApS,UAAAiB,EAAA,yFAAAmR,IAFAG,EAAAH,CAGA,CACA,GAAAjS,UAAA1D,OAAA,EACA6V,EAAA,CAAA,MACA,KAAA5H,GAAA2H,GAGA,MAAA,IAAArS,UAAAiB,EAAA,qEAAAoR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA2R,GAAA7C,EAAA7T,GAAAuW,eAAAD,EAAAD,IAEA,OAAApW,EAAAsV,KAAA,IACA,IAmDAvO,EAAAgE,GAAAnK,UAAA,cAAA,WACA,IAAA4U,EACAxV,EACAwJ,EACAoK,EACA7T,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAMA,IAJA0F,EAAAgI,KAAAgC,QACAxT,EAAA,IAAAwR,KAAA5H,YAAAJ,GACAoK,EAAApC,KAAAiC,QACA+B,EAAAxV,EAAAyT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAyV,EAAA,EAAAzV,GAAA6T,EAAA,EAAA/P,GACA2R,EAAA,EAAAzV,EAAA,GAAA6T,EAAA,EAAA/P,EAAA,GAEA,OAAA7D,CACA,IA6EA+G,EAAAgE,GAAAnK,UAAA,YAAA,SAAAmV,GACA,IAAAxB,EACAX,EACApK,EACAzJ,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAKA,IAHAnC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAe,EAAA,GACAxU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAwU,EAAAzP,KAAA2R,GAAA7C,EAAA7T,IAGA,OADAwU,EAAAyB,KAAAD,GACA,IAAAhL,GAAAwJ,EACA,IAoBAxN,EAAAgE,GAAAnK,UAAA,YAAA,WACA,IAAAZ,EACA4T,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,IAFA9D,EAAA,GACA4T,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA2R,GAAA7C,EAAA7T,GAAAyB,YAEA,OAAAxB,EAAAsV,KAAA,IACA,IA0CAvO,EAAAgE,GAAAnK,UAAA,UAAA,WACA,IAAAkU,EACA7E,EACAzG,EACAlB,EACAsL,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAiBA,OAfAmM,EAAAuB,KACAoC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAA6W,GAAA7C,EAAA7T,GACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsG,QACA,IAjDAzB,CAkDA,IAuCAnO,EAAAoE,GAAAnK,UAAA,QAAA,SAAA4V,EAAA5W,GACA,IAAAgU,EACA5T,EACAwJ,EACA,IAAA+J,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA8K,GAAA4H,GACA,MAAA,IAAA1S,UAAAiB,EAAA,oEAAAyR,IAMA,GAJAhN,EAAAgI,KAAAgC,QACAgD,EAAA,IACAA,GAAAhN,GAEAgN,EAAA,GAAAA,GAAAhN,EACA,MAAA,IAAAuK,WAAAhP,EAAA,kEAAAyR,IAEA,IAAAvE,GAAArS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,2EAAAnF,IAMA,OAHAgU,GADA5T,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAiC,UACAA,SACA,EAAA+C,GAAAlF,GAAA1R,GACAgU,EAAA,EAAA4C,EAAA,GAAAjF,GAAA3R,GACAI,CACA,IIr6FA,IAAAmS,GAAAvH,GAAAuH,kBACAmB,GAAAhB,KAYA,SAAAoE,GAAA9W,GACA,MACA,iBAAAA,GACA,OAAAA,GACA,iBAAAA,EAAAgK,YAAAK,MACArK,EAAAuS,oBAAAA,EAEA,CASA,SAAAwE,GAAA/W,GACA,OAAAA,IAAAoL,EACA,CAoEA,SAAAA,KACA,IAAA8H,EACAe,EACAD,EACApK,EACApI,EAGA,GADAyS,EAAA5P,UAAA1D,SACAiR,gBAAAxG,IACA,OAAA,IAAA6I,EACA,IAAA7I,GAEA,IAAA6I,EACA,IAAA7I,GAAA/G,UAAA,IAEA,IAAA4P,EACA,IAAA7I,GAAA/G,UAAA,GAAAA,UAAA,IAEA,IAAA+G,GAAA/G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAA4P,EACAD,EAAA,IAAAhJ,GAAA,QACA,GAAA,IAAAiJ,EAEA,GAAA5E,GADA7N,EAAA6C,UAAA,IAEA2P,EAAA,IAAAhJ,GAAAxJ,QACA,GAAAkO,GAAAlO,GACAwS,EC9IA,SAAoBA,EAAKxM,GACxB,IAAIoC,EACAzJ,EAGJ,IADAyJ,EAAMpC,EAAI7G,OACJR,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB6T,EAAK7T,GAAMiQ,GAAS5I,EAAKrH,IAE1B,OAAO6T,CACR,CDqIAE,CAAA,IAAAlJ,GAAAxJ,EAAAb,QAAAa,QACA,GAAAqO,GAAArO,GACAwS,EAAA,IAAAhJ,GAAAxJ,OACA,KAAAoN,GAAApN,GAaA,MAAA,IAAA0C,UAAAiB,EAAA,qHAAA3D,IAZA,IAAA,IAAAkS,GACA,MAAA,IAAAxP,UAAAiB,EAAA,mJAAA3D,IAEA,IAAA+P,GAAA/P,EAAA+S,KACA,MAAA,IAAArQ,UAAAiB,EAAA,qHAAA3D,IAGA,IAAA+P,IADAyC,EAAAxS,EAAA+S,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,qHAAA3D,IAEAwS,EAAA,IAAAhJ,GAAAoI,GAAAY,GAGA,KACA,CAEA,IAAAnE,GADAmE,EAAA3P,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA6O,IAGA,IAAA3E,GADA6D,EAAA7O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA+N,IAEA,GAAA,IAAAe,EACAD,EAAA,IAAAhJ,GAAAgJ,EAAAd,OACA,CAEA,IAAA7D,GADAzF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAA2I,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAAhP,EAAA,iJAAAyE,EAAA2I,KAEAyB,EAAA,IAAAhJ,GAAAgJ,EAAAd,EAAAtJ,EACA,CACA,CAIA,OAHA7C,EAAA6K,KAAA,UAAAoC,GACAjN,EAAA6K,KAAA,UAAAoC,EAAArT,QAEAiR,IACA,CAeA7K,EAAAqE,GAAA,oBAAAmH,IAeAxL,EAAAqE,GAAA,OAAA,gBAmCAjE,EAAAiE,GAAA,QAAA,SAAAoJ,GACA,IAAAC,EACAR,EACAS,EACAtU,EACA4T,EACAW,EACA/N,EACAgD,EACAzJ,EACA,IAAAoR,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA6S,GAAAnF,MACA,MAAA,IAAA1N,UAAA,sDAGA,IADA+P,EAAA5P,UAAA1D,QACA,EAAA,CAEA,IAAA4Q,GADAmD,EAAArQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAuP,IAEAT,EAAA,IACAQ,EAAApQ,UAAA,GAEA,CACA,GAAAqL,GAAA8E,GAAA,CACA,GAAAE,EAAA,CASA,IARA9K,EAAA4K,EAAA7T,OAEAiG,EADA4N,EAAA5N,KAAA4N,EAAA3N,IACAgO,EAAA,WAEAzM,EAAA,WAGA4L,GADA5T,EAAA,IAAAwR,KAAAhI,IACAiK,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAiQ,GAAAsE,EAAAzS,KAAAwS,EAAA7N,EAAA4N,EAAArU,GAAAA,IAEA,OAAAC,CACA,CACA,OAAA,IAAAwR,KAAA4C,EACA,CACA,GAAA5F,GAAA4F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,6FAAAqP,IAUA,IAPAG,EADAD,EE1SA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIrU,EACAkJ,EACAnJ,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI+J,EAAGC,QACAC,MAGPpT,GAAK,EACLC,EAAI8E,KAAMkL,GAASsE,EAAKzS,KAAMwS,EAASnL,EAAEtJ,MAAOG,KAEjD,OAAOC,CACR,CF2RA0U,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAIAA,GADA5T,EAAA,IAAAwR,KADAhI,EAAA+K,EAAAhU,SAEAkT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAwU,EAAAxU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAqP,GACA,IAoBAzN,EAAAqE,GAAA,MAAA,WACA,IAAAhG,EACAjF,EACA,IAAAoR,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA6S,GAAAnF,MACA,MAAA,IAAA1N,UAAA,sDAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAyR,KAAAxM,EACA,IA6BA+B,EAAAiE,GAAApK,UAAA,MAAA,SAAAyG,GACA,IAAAuM,EACApK,EAEA,IAAAkN,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAA8K,GAAAvH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAOA,GALAmC,EAAAgI,KAAAgC,QACAI,EAAApC,KAAAiC,QACApM,EAAA,IACAA,GAAAmC,KAEAnC,EAAA,GAAAA,GAAAmC,GAGA,OAAAwG,GAAA4D,EAAAvM,GACA,IAgBAoL,GAAAzH,GAAApK,UAAA,UAAA,WACA,OAAA4Q,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAAzH,GAAApK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAS,UACA,IAgBAzB,GAAAzH,GAAApK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAX,UACA,IAiBA/L,EAAAiE,GAAApK,UAAA,oBAAAoK,GAAAmH,mBA+BAxL,EAAAqE,GAAApK,UAAA,cAAA,SAAA+T,EAAAC,GACA,IAAA8B,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAQA,OALA,IAAAG,UAAA1D,OACAiR,KAAAiC,QAAAoB,WAAAF,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAAF,EAAAC,EAAA3Q,UAAA,IAEAuN,IACA,IAgCAzK,EAAAiE,GAAApK,UAAA,WAAA,WACA,IAAAqP,EACA6E,EACAtL,EACAoK,EACAtL,EACAvI,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAiBA,OAfAmM,EAAAuB,KACAoC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAA,CAAAG,EAAAiQ,GAAA4D,EAAA7T,KACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAA8E,SACA,IAjDAD,CAkDA,IA4BAnO,EAAAqE,GAAApK,UAAA,SAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,IAAAwJ,EAAA1H,KAAAwS,EAAArE,GAAA4D,EAAA7T,IAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA+BA7K,EAAAqE,GAAApK,UAAA,QAAA,SAAAhB,EAAAgV,EAAAI,GACA,IAAApB,EACApK,EACAoN,EACA7W,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAgM,GAAAlQ,GACA,MAAA,IAAAkE,UAAAiB,EAAA,mEAAAnF,IAIA,GAFAgU,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAgG,GACA,MAAA,IAAA9Q,UAAAiB,EAAA,qEAAA6P,IAQA,GANAA,EAAA,IACAA,GAAApL,GACA,IACAoL,EAAA,GAGA3Q,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,oEAAAiQ,IAEAA,EAAA,IACAA,GAAAxL,GACA,IACAwL,EAAA,GAGAA,EAAAxL,IACAwL,EAAAxL,EAEA,MACAwL,EAAAxL,CAEA,MACAoL,EAAA,EACAI,EAAAxL,EAOA,IAJAoN,EADAhX,EACA,EAEA,EAEAG,EAAA6U,EAAA7U,EAAAiV,EAAAjV,IACA6T,EAAA7T,GAAA6W,EAEA,OAAApF,IACA,IAqCA7K,EAAAqE,GAAApK,UAAA,UAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA5T,EACAD,EACAmJ,EAEA,IAAAwN,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAqK,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAmJ,EAAA8G,GAAA4D,EAAA7T,IACAwJ,EAAA1H,KAAAwS,EAAAnL,EAAAnJ,EAAAyR,OACAxR,EAAA8E,KAAAoE,GAGA,OAAA,IAAAsI,KAAA5H,YAAA5J,EACA,IA4BA2G,EAAAqE,GAAApK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA1K,EACAnJ,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADAmJ,EAAA8G,GAAA4D,EAAA7T,IACAwJ,EAAA1H,KAAAwS,EAAAnL,EAAAnJ,EAAAyR,MACA,OAAAtI,CAGA,IA4BAvC,EAAAqE,GAAApK,UAAA,aAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA1K,EACAnJ,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADAmJ,EAAA8G,GAAA4D,EAAA7T,IACAwJ,EAAA1H,KAAAwS,EAAAnL,EAAAnJ,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IA4BA4G,EAAAqE,GAAApK,UAAA,YAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA1K,EACAnJ,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADAmJ,EAAA8G,GAAA4D,EAAA7T,IACAwJ,EAAA1H,KAAAwS,EAAAnL,EAAAnJ,EAAAyR,MACA,OAAAtI,CAGA,IA4BAvC,EAAAqE,GAAApK,UAAA,iBAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA1K,EACAnJ,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADAmJ,EAAA8G,GAAA4D,EAAA7T,IACAwJ,EAAA1H,KAAAwS,EAAAnL,EAAAnJ,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IA0BA4G,EAAAqE,GAAApK,UAAA,WAAA,SAAAqU,EAAAZ,GACA,IAAAT,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAAiB,EAAA,oEAAAkQ,IAGA,IADArB,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAkV,EAAApT,KAAAwS,EAAArE,GAAA4D,EAAA7T,IAAAA,EAAAyR,KAEA,IA2BAzK,EAAAiE,GAAApK,UAAA,OAAA,SAAAyG,GACA,IAAAqP,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAmL,GAAA5H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAmK,KAAAgC,SAGA,OAAAxD,GAAAwB,KAAAiC,QAAApM,GACA,IA8BAV,EAAAqE,GAAApK,UAAA,YAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAgM,GAAAoF,GACA,MAAA,IAAApR,UAAAiB,EAAA,mEAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAGA,IADAvB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IACA,GAAAmV,IAAAlF,GAAA4D,EAAA7T,IACA,OAAA,EAGA,OAAA,CACA,IAiCA4G,EAAAqE,GAAApK,UAAA,WAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAgM,GAAAoF,GACA,MAAA,IAAApR,UAAAiB,EAAA,mEAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAGA,IADAvB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IACA,GAAAmV,IAAAlF,GAAA4D,EAAA7T,IACA,OAAAA,EAGA,OAAA,CACA,IA0BAgH,EAAAiE,GAAApK,UAAA,QAAA,SAAAwU,GACA,IAAAxB,EACA5T,EACAD,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,GAAAG,UAAA1D,OAAA,GACA,IAAAmP,GAAA0F,GACA,MAAA,IAAAtR,UAAAiB,EAAA,kEAAAqQ,SAGAA,EAAA,IAIA,IAFAxB,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA6T,EAAA7T,GACAC,EAAA8E,KAAA,QAEA9E,EAAA8E,KAAA,SAGA,OAAA9E,EAAAsV,KAAAF,EACA,IA4BArO,EAAAiE,GAAApK,UAAA,QAAA,WACA,IAAAqP,EACA6E,EACAtL,EACAlB,EACAvI,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAgBA,OAdAmM,EAAAuB,KACAhI,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAAG,EACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsF,MACA,IAjDAT,CAkDA,IAiCAnO,EAAAqE,GAAApK,UAAA,eAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAgM,GAAAoF,GACA,MAAA,IAAApR,UAAAiB,EAAA,mEAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAGA,IADAI,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,GAAA,EAAAA,IACA,GAAAmV,IAAAlF,GAAA4D,EAAA7T,IACA,OAAAA,EAGA,OAAA,CACA,IAgBA0S,GAAAzH,GAAApK,UAAA,UAAA,WACA,OAAA4Q,KAAAgC,OACA,IAqCA7M,EAAAqE,GAAApK,UAAA,OAAA,SAAAqU,EAAAZ,GACA,IAAAmB,EACAxV,EACA4T,EACA7T,EACA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAA,oEAAAmR,GAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADAxV,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAgC,UACAC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAyV,EAAAzV,GAAAiQ,GAAAiF,EAAApT,KAAAwS,EAAArE,GAAA4D,EAAA7T,IAAAA,EAAAyR,OAEA,OAAAxR,CACA,IA+BA2G,EAAAqE,GAAApK,UAAA,UAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACApK,EACAmM,EACA5V,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAA3F,GAAA4D,EAAA,IACA7T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IACA4V,EAAAF,EAAAE,EAAA3F,GAAA4D,EAAA7T,IAAAA,EAAAyR,MAEA,OAAAmE,CACA,IA+BAhP,EAAAqE,GAAApK,UAAA,eAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACApK,EACAmM,EACA5V,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAA3F,GAAA4D,EAAApK,EAAA,IACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IACA4V,EAAAF,EAAAE,EAAA3F,GAAA4D,EAAA7T,IAAAA,EAAAyR,MAEA,OAAAmE,CACA,IA8BA5O,EAAAiE,GAAApK,UAAA,WAAA,WACA,IAAAgT,EACAW,EACA/K,EACAoM,EACA7V,EACA8D,EAEA,IAAA6S,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAKA,IAHA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAoC,EAAAjH,GAAAnF,EAAA,GACAzJ,EAAA,EAAAA,EAAA6V,EAAA7V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAwU,EAAAX,EAAA7T,GACA6T,EAAA7T,GAAA6T,EAAA/P,GACA+P,EAAA/P,GAAA0Q,EAEA,OAAA/C,IACA,IA+CAzK,EAAAiE,GAAApK,UAAA,OAAA,SAAAhB,GACA,IAAAiW,EACAxO,EACAuM,EACAW,EACAqB,EACA7V,EACA8D,EACA,IAAA6S,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAGA,GADA8P,EAAApC,KAAAiC,QACAxP,UAAA1D,OAAA,GAEA,IAAA0O,GADA5H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAAiI,GAAA1P,GAAA,CAEA,GAAAyH,GADAuO,EAAAhW,EAAAW,QACAiR,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FASA,GANA8B,EADAa,GAAA9W,GACAA,EAAA6T,QAEA7T,EAGAiE,EAAA+P,EAAAd,WAAAzL,EAAA8K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAAjP,GACAgS,EAAA/C,WAAA+C,EAAA3B,WAAArQ,EAEA,CAGA,IADA0Q,EAAA,IAAA3J,GAAAiL,EAAAtV,QACAR,EAAA,EAAAA,EAAA8V,EAAAtV,OAAAR,IACAwU,EAAAxU,GAAA8V,EAAA9V,GAEA8V,EAAAtB,CACA,CACA,IAAAxU,EAAA,EAAAA,EAAA6V,EAAAvO,IAAAtH,IACA6T,EAAAvM,GAAAwO,EAAA9V,GAAA,EAAA,CAGA,KA9BA,CA+BA,GAAAsH,GAAAmK,KAAAgC,QACA,MAAA,IAAAO,WAAAhP,EAAA,kEAAAsC,IAEAuM,EAAAvM,GAAA,EAAA,EAAA,CAJA,CAKA,IAgDAV,EAAAqE,GAAApK,UAAA,SAAA,SAAAqV,EAAAjB,GACA,IAAAc,EACAN,EACAxV,EACA4T,EACApK,EACAzJ,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACA0V,EAAA,EACAjB,EAAAxL,MACA,CACA,IAAAoF,GAAAqH,GACA,MAAA,IAAAnS,UAAAiB,EAAA,oEAAAkR,IAQA,GANAA,EAAA,IACAA,GAAAzM,GACA,IACAyM,EAAA,GAGA,IAAAhS,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAQA,IANAsM,EADAG,EAAAjB,EACAA,EAAAiB,EAEA,EAGAT,GADAxV,EAAA,IAAAwR,KAAA5H,YAAAkM,IACArC,QACA1T,EAAA,EAAAA,EAAA+V,EAAA/V,IACAyV,EAAAzV,GAAA6T,EAAA7T,EAAAkW,GAEA,OAAAjW,CACA,IA4BA2G,EAAAqE,GAAApK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,GAAAwJ,EAAA1H,KAAAwS,EAAArE,GAAA4D,EAAA7T,IAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA4CAzK,EAAAiE,GAAApK,UAAA,QAAA,SAAAmV,GACA,IAAAnC,EAEA,IAAA8C,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAGA,GADA8P,EAAApC,KAAAiC,QACA,IAAAxP,UAAA1D,OAEA,OADAqT,EAAAoC,OACAxE,KAEA,IAAAL,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAGA,OADAnC,EAAAoC,MAWA,SAAAa,EAAAC,GACA,OAAAf,EAAA/F,GAAA6G,GAAA7G,GAAA8G,GACA,IAZAtF,IAaA,IAgDA7K,EAAAqE,GAAApK,UAAA,YAAA,SAAAqV,EAAAjB,GACA,IAAApC,EACAgB,EACApK,EAEA,IAAAkN,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACA0V,EAAA,EACAjB,EAAAxL,MACA,CACA,IAAAoF,GAAAqH,GACA,MAAA,IAAAnS,UAAAiB,EAAA,oEAAAkR,IAQA,GANAA,EAAA,IACAA,GAAAzM,GACA,IACAyM,EAAA,GAGA,IAAAhS,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAWA,OAVAyM,GAAAzM,GACAA,EAAA,EACAoJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACAxL,EAAA,EACAoJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEA3I,EAAAwL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAA5H,YAAAgK,EAAAf,OAAAD,EAAApJ,EAAA,EAAA,EAAAA,EACA,IAyBA7C,EAAAqE,GAAApK,UAAA,kBAAA,SAAAsV,EAAAC,GACA,IAAAC,EACAC,EACArW,EACA4T,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,GAAA,IAAAG,UAAA1D,OACA8V,EAAA,OACA,KAAA3G,GAAAwG,KAAArG,GAAAqG,GAGA,MAAA,IAAApS,UAAAiB,EAAA,yFAAAmR,IAFAG,EAAAH,CAGA,CACA,GAAAjS,UAAA1D,OAAA,EACA6V,EAAA,CAAA,MACA,KAAA5H,GAAA2H,GAGA,MAAA,IAAArS,UAAAiB,EAAA,qEAAAoR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAAkL,GAAA4D,EAAA7T,IAAAuW,eAAAD,EAAAD,IAEA,OAAApW,EAAAsV,KAAA,IACA,IA8BAvO,EAAAiE,GAAApK,UAAA,cAAA,WACA,IAAA4U,EACAxV,EACAwJ,EACAoK,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAMA,IAJA0F,EAAAgI,KAAAgC,QACAxT,EAAA,IAAAwR,KAAA5H,YAAAJ,GACAoK,EAAApC,KAAAiC,QACA+B,EAAAxV,EAAAyT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAyV,EAAAzV,GAAA6T,EAAApK,EAAAzJ,EAAA,GAEA,OAAAC,CACA,IA6CA+G,EAAAiE,GAAApK,UAAA,YAAA,SAAAmV,GACA,IAAAP,EACAxV,EACAwJ,EACAoK,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAMA,IAJA0F,EAAAgI,KAAAgC,QACAxT,EAAA,IAAAwR,KAAA5H,YAAAJ,GACAoK,EAAApC,KAAAiC,QACA+B,EAAAxV,EAAAyT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAyV,EAAAzV,GAAA6T,EAAA7T,GAEA,GAAA,IAAAkE,UAAA1D,OAEA,OADAiV,EAAAQ,OACAhW,EAEA,IAAAmR,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAGA,OADAP,EAAAQ,MAWA,SAAAa,EAAAC,GACA,OAAAf,EAAA/F,GAAA6G,GAAA7G,GAAA8G,GACA,IAZA9W,CAaA,IAqBA+G,EAAAiE,GAAApK,UAAA,YAAA,WACA,IAAAZ,EACA4T,EACA7T,EACA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAIA,IAFA9D,EAAA,GACA4T,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA6T,EAAA7T,GACAC,EAAA8E,KAAA,QAEA9E,EAAA8E,KAAA,SAGA,OAAA9E,EAAAsV,KAAA,IACA,IA4BAvO,EAAAiE,GAAApK,UAAA,UAAA,WACA,IAAAkU,EACA7E,EACAzG,EACAlB,EACAsL,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAiBA,OAfAmM,EAAAuB,KACAoC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAAoQ,GAAA4D,EAAA7T,IACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsG,QACA,IAjDAzB,CAkDA,IA6BAnO,EAAAqE,GAAApK,UAAA,QAAA,SAAA4V,EAAA5W,GACA,IACAI,EACAwJ,EAEA,IAAAkN,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAA8K,GAAA4H,GACA,MAAA,IAAA1S,UAAAiB,EAAA,oEAAAyR,IAMA,GAJAhN,EAAAgI,KAAAgC,QACAgD,EAAA,IACAA,GAAAhN,GAEAgN,EAAA,GAAAA,GAAAhN,EACA,MAAA,IAAAuK,WAAAhP,EAAA,kEAAAyR,IAEA,IAAA1G,GAAAlQ,GACA,MAAA,IAAAkE,UAAAiB,EAAA,oEAAAnF,IASA,OAPAI,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAiC,UACAA,QAEA+C,GADA5W,EACA,EAEA,EAEAI,CACA,IG/4EA,IAAI+W,GAAQ,CACXzM,GACAD,GACAG,GACAG,GACAJ,GACAG,GACAD,GACAG,GACAC,GACAC,GACAC,GACAC,IC5BGgM,GAAS,CACZ,UACA,UACA,QACA,SACA,QACA,SACA,OACA,QACA,SACA,YACA,aACA,QCHGC,GAASD,GAAOzW,OAkBpB,SAAS0H,GAAOrI,GACf,IAAIG,EACJ,GAAKkD,GAASrD,GACb,MAAO,UAER,GAAK8J,GAAU9J,GACd,OAAO,KAER,IAAMG,EAAI,EAAGA,EAAIkX,GAAQlX,IACxB,GAAKH,aAAiBmX,GAAOhX,GAC5B,OAAOiX,GAAQjX,GAIjB,OAAOmX,GAAYlN,GAAiBpK,KAAa,IAClD,CCNA,SAASuX,GAAWtI,GACnB,IAAIuI,EAAKnP,GAAO4G,GAChB,OAAK5H,EAAiB4H,GACd,CACNwI,kBAAoB,EACpBF,UAAa,CACZ1C,EAAgB2C,GAChBE,EAAgBF,KAIZ,CACNC,kBAAoB,EACpBF,UAAa,CACZnP,EAAQoP,GACRjP,EAAQiP,IAGX,CCNA,SAASG,GAAenQ,GACvB,IAAIoQ,EACJ,KAAOhG,gBAAgB+F,IACtB,OAAO,IAAIA,GAAenQ,GAE3B,IAAMkI,GAAclI,GACnB,MAAM,IAAItD,UAAWiB,EAAQ,oEAAqEqC,IAMnG,OAJAoQ,EAAIL,GAAW/P,GACfoK,KAAKiC,QAAUrM,EACfoK,KAAKiG,QAAUD,EAAEL,UAAW,GAC5B3F,KAAKkG,QAAUF,EAAEL,UAAW,GACrB3F,IACR,CAeA7K,EAAa4Q,GAAe,OAAQ,iBC1CpC,SAA4CtR,EAAKC,EAAM8B,EAAQG,GAC9DzI,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdL,IAAOwB,EACPvB,IAAO0B,GAET,CD4CoBwP,CAAEJ,GAAc3W,UAAW,UA3D/C,WACC,OAAO4Q,KAAKiC,QAAQlT,MACrB,IAZA,SAAoBiJ,GACnBgI,KAAKiC,QAAQlT,OAASiJ,CACvB,IAqFWzC,EAAEwQ,GAAc3W,UAAW,OAAO,SAAcyG,GAC1D,OAAOmK,KAAKiG,QAASjG,KAAKiC,QAASpM,EACpC,IAwBAV,EAAa4Q,GAAc3W,UAAW,OAAO,SAAchB,EAAOyH,GAC5DpD,UAAU1D,OAAS,EACvBiR,KAAKkG,QAASlG,KAAKiC,QAAS,EAAG7T,GAGhC4R,KAAKkG,QAASlG,KAAKiC,QAASpM,EAAKzH,EAClC,IExIA,IAAIuS,GAAoB,EAoBxB,SAASuE,GAAgB9W,GAExB,MACkB,iBAAVA,GACG,OAAVA,GAC2B,iBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMuS,oBAAsBA,EAE9B,CCGA,SAASyF,GAAkB/I,GAC1B,IAAIuI,EAAKnP,GAAO4G,GAChB,OAAK5H,EAAiB4H,GACd,CACNgJ,KAAQhJ,EACR5G,MAASmP,EACTC,kBAAoB,EACpBF,UAAa,CACZ1C,EAAgB2C,GAChBE,EAAgBF,KAIZ,CACNS,KAAQhJ,EACR5G,MAASmP,EACTC,kBAAoB,EACpBF,UAAa,CACZnP,EAAQoP,GACRjP,EAAQiP,IAGX,CCrDA,IAAIlN,GAA+B,mBAAfU,WAA8BA,gBAAa,EC6B/D,IAAAkN,GATKtK,KACGxH,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECcA,SAASoR,GAAa9D,EAAG+D,GACxB,OAAO,IAAIhI,GAAYiE,EAAEgE,OAAQhE,EAAEiE,WAAYjE,EAAEsD,kBAAkBS,EAAS/D,EAAEtO,OAAOqS,EACtF,CCKA,SAASmF,GAAUlJ,GAClB,IAAI9O,EACJ,IAAMA,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1B,GAAK8O,EAAG9O,GACP,OAAO,EAGT,OAAO,CACR,CCjBA,SAASiY,GAAenJ,GACvB,IAAIuI,EAAKnP,GAAO4G,GAChB,OAAK5H,EAAiB4H,GACd4F,EAAgB2C,GAEjBpP,EAAQoP,EAChB,CCJA,SAASa,GAASrY,EAAOiJ,GACxB,OAAKjJ,UAGoB,iBAAbiJ,EACJA,KAAYpJ,OAAQG,GAEnBe,OAAQkI,KAAcpJ,OAAQG,GACxC,CCZA,SAASsY,GAAUrJ,EAAGjP,GACrB,IAAI4J,EACAhD,EACA4Q,EACArX,EAeJ,IAZAqX,EAAKnP,GAAO4G,GAIXrI,EADIS,EAAiB4H,GACf4F,EAAgB2C,GAEhBpP,EAAQoP,GAGf5N,EAAMqF,EAAEtO,OAGFR,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAKyG,EAAKqI,EAAG9O,KAAQH,EACpB,OAAO,EAGT,OAAO,CACR,CCrBA,SAASuY,GAAStJ,GACjB,IAAIrI,EACAgD,EACA4N,EAEJ,IAAM9H,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,oEAAqE8J,IAYnG,OATAuI,EAAKnP,GAAO4G,GAGP5H,EAAiB4H,KACrBrI,EAAMiO,EAAgB2C,IAGvB5N,EAAMqF,EAAEtO,YAES,IAARiG,EAYT,SAAmB5G,GAClB,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAK8O,EAAG9O,KAAQH,EACf,OAAO,EAGT,OAAO,CACP,EAQD,SAAoBA,GACnB,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAKyG,EAAKqI,EAAG9O,KAAQH,EACpB,OAAO,EAGT,OAAO,CACP,CACF,CChEA,SAASwY,GAAQvJ,GAChB,OAASA,GAAMA,CAChB,CCGAlI,EAAAnH,GAAA,UAAA2Y,ICSA,IAAIE,GAAoB,WC5BpBnO,GAAgC,mBAAhBS,YAA+BA,iBAAc,EC6BjE,IAAA2N,GATKrM,KACGjG,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECHIsQ,GAAe,IAAIxH,GAAc,GACjCkO,GAAc,IAAI5N,GAAakH,GAAagB,QAoBhD,SAAS2F,GAAS3J,GAEjB,OADAgD,GAAc,GAAMhD,EACb0J,GAAa,EACrB,CCJA,SAASxW,GAAK8M,GACb,OAAO7M,KAAKD,IAAK8M,EAClB,CCbA,SAAS4J,GAAaC,GACrB,OAAKA,EAAOC,GACM,GAAPD,GAGFA,EAAOC,MAAgB,CACjC,CCsBA,SAASC,GAAgB/B,EAAGC,EAAG+B,GAC9B,ODeiBhK,ECfDiD,GAAK+E,GDeDiC,ECfMhH,GAAKgF,IDmB1BsB,GAAQvJ,IAAOuJ,GAAQU,GACpBzN,KAGR0N,EAAKP,GAAS3J,GACdmK,EAAKR,GAASM,GAOP/W,IAJPgX,EAAKN,GAAaM,KAClBC,EAAKP,GAAaO,QC5BsBH,EDezC,IAAkBhK,EAAGiK,EAChBC,EACAC,CChBL,CC/BA,SAAS7V,GAAO0L,GACf,OAASA,GAAMA,CAChB,CCYA,IAAIoK,GAA8B,WC5B9B/O,GAAgC,mBAAhBQ,YAA+BA,iBAAc,EC6BjE,ICRKwO,GDQLC,GATKvM,KACG5G,GEdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECHI6X,GAAQ,CACXzR,OAAU+C,GACV9C,MAASgD,KFgBTsO,GAAa,IAAIE,GAAiB,OAAE,IAOxB,GAAM,KAiBnB,IG1CIC,GACAC,GHyCJC,GAX6B,KAHhB,IAAIH,GAAgB,MAAEF,GAAWrG,QAGzB,IG5BG,IAAnB2G,IACJH,GAAO,EACPC,GAAM,IAEND,GAAO,EACPC,GAAM,GAUP,IAAAG,GARU,CACTJ,KAAQA,GACRC,IAAOA,ICXJI,GAAe,IAAIpP,GAAc,GACjCiO,GAAc,IAAI5N,GAAa+O,GAAa7G,QAE5CwG,GAAOM,GAAQN,KACfC,GAAMK,GAAQL,IA+DlB,SAASM,GAAS/K,EAAG7O,EAAK6Z,EAAQjH,GAIjC,OAHA8G,GAAc,GAAM7K,EACpB7O,EAAK4S,GAAW2F,GAAac,IAC7BrZ,EAAK4S,EAASiH,GAAWtB,GAAae,IAC/BtZ,CACR,CChEA,SAAS4Z,GAAS/K,GACjB,OAAOoG,GAAKpG,EAAG,CAAE,EAAO,GAAS,EAAG,EACrC,CCcAlI,EAAAnH,GAAA,SAAAsa,ICvBA,IAAIC,GAAK,IAAIpP,GAAa,GACtBqP,GAAK,IAAIrP,GAAa,GACtBsP,GAAK,IAAItP,GAAa,GAGtBuP,GAAS,WAgBb,SAASzB,GAAa0B,GAMrB,OALKA,EAAO,GAAIxB,GACfwB,EAkBF,SAAiBA,GAChBA,EAAO,IAAOA,EAAO,GACrBA,EAAO,IAAOA,EAAO,GACrBA,EAAO,IAAO,EAGM,IAAfA,EAAO,KACXA,EAAO,IAAO,GAEf,OAAOA,CACR,CA5BUC,CAAQD,GAEhBA,EAAO,IAAOxB,GAERwB,CACR,CA0DA,SAASE,GAAUC,EAAIC,EAAIC,GAC1B,IAAIC,EACAC,EACAC,EACAC,EAcJ,OAZAH,EAAKH,EAAI,GACTK,EAAKL,EAAI,GACTI,EAAKH,EAAI,GAGJI,IAFLC,EAAKL,EAAI,KAGRC,EAAI,GAAMC,EAAKC,EACfF,EAAI,GAAMG,EAAKC,IAEfJ,EAAI,GAAQC,EAAKC,EAAK,EACtBF,EAAI,GAAQG,EAAKT,GAAWU,GAEtBJ,CACR,CCvEA,SAASK,GAAehE,EAAGC,EAAG+B,GAC7B,OD4GoBC,EC5GDhC,GDiHd3T,GALY0L,EC5GDgI,IDiHG1T,GAAO2V,GAClBzN,KAGR0N,EAAKa,GAAS/K,EAAGkL,GAAI,EAAG,GACxBf,EAAKY,GAASd,EAAGkB,GAAI,EAAG,GAGxBjB,EAAKN,GAAaM,GAClBC,EAAKP,GAAaO,GAhGGuB,EAmGFvB,EAGN,IAHb8B,GAnGiBR,EAmGFvB,GAlGN,GAAMwB,EAAI,GACX,EAEHD,EAAI,GAAMC,EAAI,IACV,EAEJD,EAAI,GAAMC,EAAI,GACX,EAEHD,EAAI,GAAMC,EAAI,IACV,EAEF,GA2FC,GAGPQ,EADY,IAARD,EACCT,GAAUtB,EAAIC,EAAIiB,IAElBI,GAAUrB,EAAID,EAAIkB,KAGX,GAAIC,GAAWa,EAAI,MC1INlC,ED4G3B,IAAkBhK,EAAGiK,EAChBgC,EACA/B,EACAC,EACA+B,EAtFaT,EAAIC,CCzBtB,CCzBA,SAASS,GAAMtI,GACd,IAAI1S,EAAM,IAAIqK,GAAc,GAG5B,OAFArK,EAAK,GAAM0S,EAAEjB,GACbzR,EAAK,GAAM0S,EAAEhB,GACN1R,CACR,CCLA,SAASgb,GAAMtI,GACd,IAAI1S,EAAM,IAAIsK,GAAc,GAG5B,OAFAtK,EAAK,GAAM0S,EAAEjB,GACbzR,EAAK,GAAM0S,EAAEhB,GACN1R,CACR,CCmBA,SAAS6a,GAAehE,EAAGC,EAAG+B,GAC7B,OAAKhC,IAAMC,IAGNnX,GAAUkX,IAAOlX,GAAUmX,GACxBmE,GAAkBpE,EAAGC,EAAG+B,MAE3B5G,GAAe4E,KAAO5E,GAAe6E,MACZ,IAAxBD,EAAE1E,mBAAmD,IAAxB2E,EAAE3E,kBCnBtC,SAAyB+I,EAAIC,EAAItC,GAChC,IAAIuC,EAASC,GAAOH,GAChBI,EAASD,GAAOF,GACpB,OACCI,GAAkBH,EAAQ,GAAKE,EAAQ,GAAKzC,IAC5C0C,GAAkBH,EAAQ,GAAKE,EAAQ,GAAKzC,EAE9C,CDaU2C,CAAwB3E,EAAGC,EAAG+B,GEpBxC,SAAwBqC,EAAIC,EAAItC,GAC/B,IAAIuC,EAASJ,GAAME,GACfI,EAASN,GAAMG,GACnB,OACCF,GAAkBG,EAAQ,GAAKE,EAAQ,GAAKzC,IAC5CoC,GAAkBG,EAAQ,GAAKE,EAAQ,GAAKzC,EAE9C,CFeS4C,CAAyB5E,EAAGC,EAAG+B,IAGxC,CGfA,SAASd,GAAUlJ,EAAGiK,EAAGD,EAAQ5D,GAChC,IAAIlV,EACJ,IAAMA,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1B,IAAMkV,EAAKpG,EAAG9O,GAAK+Y,EAAG/Y,GAAK8Y,GAC1B,OAAO,EAGT,OAAO,CACR,CAkCA,SAAS1B,GAAWtI,EAAGiK,EAAGD,EAAQ5D,GACjC,IAAIyG,EACAC,EACAC,EACAC,EACA9b,EAQJ,IANA2b,EAAQ7M,EAAEgJ,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO/M,EAAEsI,UAAW,GACpB0E,EAAO/C,EAAE3B,UAAW,GAEdpX,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,IAC9B,IAAMkV,EAAK2G,EAAMF,EAAO3b,GAAK8b,EAAMF,EAAO5b,GAAK8Y,GAC9C,OAAO,EAGT,OAAO,CACR,CCtEA,SAASd,GAAUlJ,EAAGiK,GACrB,IAAI/Y,EACJ,IAAMA,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1B,GAAK8O,EAAG9O,KAAQ+Y,EAAG/Y,GAClB,OAAO,EAGT,OAAO,CACR,CA8BA,SAASoX,GAAWtI,EAAGiK,GACtB,IAAI4C,EACAC,EACAC,EACAC,EACA9b,EAQJ,IANA2b,EAAQ7M,EAAEgJ,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO/M,EAAEsI,UAAW,GACpB0E,EAAO/C,EAAE3B,UAAW,GAEdpX,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,IAC9B,GAAK6b,EAAMF,EAAO3b,KAAQ8b,EAAMF,EAAO5b,GACtC,OAAO,EAGT,OAAO,CACR,CC5DA,SAAS+b,GAAajF,EAAGC,GACxB,OAAKD,IAAMC,EACC,IAAND,GACG,EAAMA,GAAM,EAAMC,EAIlBD,GAAMA,GAAKC,GAAMA,CAC3B,CCUA,SAASgF,GAAajF,EAAGC,GACxB,OAAKD,IAAMC,EACC,IAAND,GACG,EAAMA,GAAM,EAAMC,EAItBD,GAAMA,GAAKC,GAAMA,MAGjB7E,GAAe4E,KAAO5E,GAAe6E,MC7BjBqE,ED8BMrE,EC7B3BsE,EAASJ,GD6BenE,GC5BxByE,EAASN,GAAMG,GAElBY,GAAQX,EAAQ,GAAKE,EAAQ,KAC7BS,GAAQX,EAAQ,GAAKE,EAAQ,KAL/B,IAA0BH,EACrBC,EACAE,CD+BL,CE5BA,SAASvD,GAAUlJ,EAAGiK,GACrB,IAAI/Y,EACJ,IAAMA,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1B,IAAM+b,GAAajN,EAAG9O,GAAK+Y,EAAG/Y,IAC7B,OAAO,EAGT,OAAO,CACR,CA8BA,SAASoX,GAAWtI,EAAGiK,GACtB,IAAI4C,EACAC,EACAC,EACAC,EACA9b,EAQJ,IANA2b,EAAQ7M,EAAEgJ,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO/M,EAAEsI,UAAW,GACpB0E,EAAO/C,EAAE3B,UAAW,GAEdpX,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,IAC9B,IAAM+b,GAAaF,EAAMF,EAAO3b,GAAK8b,EAAMF,EAAO5b,IACjD,OAAO,EAGT,OAAO,CACR,CClEA,SAASkC,GAAS/B,EAAK8b,EAAQC,GAC9B,OAAO/b,EAAI+B,QAAS+Z,EAAQC,EAC7B,m6BCrBIC,GAAY,gBAmBhB,SAASC,KACR,IAAIC,EACApc,EACAsI,EACJ,OAA0B,IAArBrE,UAAU1D,OACPyW,GAAOqF,IAAIzX,SAEnB0D,GAAM,EACN8T,EAAOnY,UAAW,GACbiY,GAAU5N,KAAM8N,IAEN,SADdA,EAAOna,GAASma,EAAMF,GAAW,MACD,UAATE,IACtB9T,GAAM,GAIRtI,GADAA,EAAMgX,GAAQoF,IACEpc,EAAI4E,QAAU,GACzB0D,GAAOtI,EAAIO,OAAS,GACxBP,EAAI8E,KAAM,WAEJ9E,EACR,CCWA,IAAIsc,GAAoBpE,GAAUiE,GAAQ,8CC3C1C,SAASI,KACR,OAAOC,GAAO5X,OACf,CCQA,IAAI6X,GAAcvE,GAAUwE,MC8BxBC,GAAiCzE,GAAUiE,GAAQ,2BCtDnDS,GAAwB,EACxBC,GAAyB,GAoB7B,SAASC,GAAqBld,GAE7B,MACkB,iBAAVA,GACG,OAAVA,IAG6B,oBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMuS,oBAAsB0K,IAGD,mBAA3Bjd,EAAMgK,YAAYK,MAClBrK,EAAMuS,oBAAsByK,GAIhC,CCWA,IAAIG,GAAa7E,GAAUiE,MCAvBa,GAA0B9E,GAAUiE,GAAQ,mBCA5Cc,GAAoB/E,GAAUiE,GAAQ,YC5B1C,SAAS5G,GAAM3V,GACd,OAAOH,OAAO8V,KAAM9V,OAAQG,GAC7B,CCtBA,ICKIuL,GDLAA,QAAgC,IAAhB1L,OAAO8V,KEwB3B,SAAS2H,GAAatd,GACrB,MAAkC,uBAAzBoJ,GAAapJ,EACvB,CDCIud,GAPJ,WACC,OAAOD,GAAajZ,UACrB,CAKOmZ,GAKP,IAAAC,GAAelS,GERf,SAAShI,GAAOvD,GACf,OACCD,GAAUC,IACV0d,GAAO1d,EAET,CCTA,SAASuD,GAAOvD,GACf,OACCD,GAAUC,IACV0d,GAAO1d,EAAMoP,UAEf,CCGA,SAAS7L,GAAOvD,GACf,OAAS2O,GAAa3O,IAAW4O,GAAU5O,EAC5C,CCoBA+G,EAAAnH,GAAA,cAAA+O,IACA5H,EAAAnH,GAAA,WAAAgP,ICzBA,IAAI+O,GAAuB9d,OAAOmB,UAAU4c,qBCE5C,IAAAC,IAXSC,GAAO7b,KAAM,OAAQ,KCe9B,SAAS0b,GAAsB3d,EAAOiJ,GACrC,IAAIsC,EACJ,OACCvL,YAKDuL,EAAOuS,GAAO7b,KAAMjC,EAAOiJ,KACb4U,IAAoB/N,GAAU9P,IAIzCuD,GAFF0F,GAAYA,IAGX+F,GAAW/F,IACXA,GAAY,GACZA,EAAWjJ,EAAMW,OAGZ4K,EACR,CChBA,IAAAwS,GATKN,GACU7d,GCAf,SAAsBI,GACrB,OACW,OAAVA,GACiB,iBAAVA,IACNqD,GAASrD,IACc,iBAAjBA,EAAMW,QACbqO,GAAWhP,EAAMW,SACjBX,EAAMW,QAAU,GAChBX,EAAMW,QAAU6O,IAChBxG,GAAYhJ,EAAO,YAClB2d,GAAsB3d,EAAO,SAEhC,EClCIgF,GAAQ1B,MAAMtC,UAAUgE,MCC5B,IAAIuG,GAAOoS,ICFX,WAEA,GDAuC,aEMnCpS,IAAQoS,GARF,CACT/b,SAAY,MAO0B,YCiDvC,SAASwC,GAASoD,EAAK8N,EAAeC,GACrC,IAAI3L,EACAzJ,EACJ,IAAMuP,GAAclI,KAAUsI,GAAUtI,GACvC,MAAM,IAAItD,UAAWiB,EAAQ,8EAA+EqC,IAG7G,GAAa,KADboC,EAAMpC,EAAI7G,QAET,OAAQ,EAET,GAA0B,IAArB0D,UAAU1D,OAAe,CAC7B,IAAMqO,GAAWuG,GAChB,MAAM,IAAIrR,UAAWiB,EAAQ,oEAAqEoQ,IAEnG,GAAKA,GAAa,EAAI,CACrB,GAAKA,GAAa3L,EACjB,OAAQ,EAETzJ,EAAIoV,CACP,MACGpV,EAAIyJ,EAAM2L,GACD,IACRpV,EAAI,EAGR,MACEA,EAAI,EAGL,GAAKoD,GAAO+R,IACX,KAAQnV,EAAIyJ,EAAKzJ,IAChB,GAAKoD,GAAOiE,EAAIrH,IACf,OAAOA,OAIT,KAAQA,EAAIyJ,EAAKzJ,IAChB,GAAKqH,EAAKrH,KAAQmV,EACjB,OAAOnV,EAIV,OAAQ,CACT,CClGA,SAAS6d,GAAwBhe,GAChC,OAASA,EAAMgK,aAAehK,EAAMgK,YAAYhJ,YAAchB,CAC/D,6PCTIie,GAAwB,oBAAX3N,YAA2B,EAASA,OCqDrD,IAAA4N,GA9BA,WACC,IAAIC,EACJ,GAAuB,cAAlB3M,GAAQ4M,IACZ,OAAO,EAER,IAAMD,KAAKC,GACV,KAEmC,IAAjCha,GAASia,GAAeF,IACxBnV,GAAYoV,GAAKD,IACJ,OAAbC,GAAKD,IACkB,WAAvB3M,GAAQ4M,GAAKD,KAEbH,GAAwBI,GAAKD,GAE9B,CAAC,MAAQjY,GACT,OAAO,CACP,CAEF,OAAO,CACR,CAKOoY,GChDH/S,GAA2B,oBAAX+E,WC0BhBqF,oHAKFA,GAJG4I,GChBL,WACC,OAA8C,KAArC5I,GAAMtR,YAAe,IAAK1D,MACpC,CAgBQ+N,CAAM,EAAG,GVFjB,SAAe1O,GACd,OAAKsd,GAAatd,GACVoG,GAASpB,GAAM/C,KAAMjC,IAEtBoG,GAASpG,EACjB,ESDSoG,GEJT,SAAepG,GACd,IAAIwe,EACAC,EACAC,EACAte,EACA+d,EACAQ,EACAxe,EAGJ,GADAC,EAAM,GACDkd,GAAatd,GAAU,CAE3B,IAAMG,EAAI,EAAGA,EAAIH,EAAMW,OAAQR,IAC9BC,EAAI8E,KAAM/E,EAAEyB,YAGb,OAAOxB,CACP,CACD,GAAsB,iBAAVJ,GAEX,GAAKA,EAAMW,OAAS,IAAMqI,GAAYhJ,EAAO,KAC5C,IAAMG,EAAI,EAAGA,EAAIH,EAAMW,OAAQR,IAC9BC,EAAI8E,KAAM/E,EAAEyB,gBAGR,CAEN,IAAe,IADf8c,EAA2B,mBAAV1e,KACQ6J,GAAc7J,GACtC,OAAOI,EAERqe,EAAkBG,IAAsBF,CACxC,CACD,IAAMP,KAAKne,EACFye,GAAuB,cAANN,IAAuBnV,GAAYhJ,EAAOme,IAClE/d,EAAI8E,KAAMnE,OAAQod,IAGpB,GAAKU,GAEJ,IADAL,ECnDF,SAAkBxe,GACjB,IAAoB,IAAf8e,KAAyBZ,GAC7B,OAAOF,GAAwBhe,GAEhC,IACC,OAAOge,GAAwBhe,EAC/B,CAAC,MAAQ+e,GACT,OAAO,CACP,CACF,CD0CoBf,CAAwBhe,GACpCG,EAAI,EAAGA,EAAI6e,GAAere,OAAQR,IACvCwe,EAAIK,GAAgB7e,GACZqe,GAAyB,gBAANG,IAAyB3V,GAAYhJ,EAAO2e,IACtEve,EAAI8E,KAAMnE,OAAQ4d,IAIrB,OAAOve,CACR,EFlCA,IIjCI6e,GJiCJC,GAAevJ,GKVXwJ,GAAMtf,OC9BNof,GAAWpf,OAAOuf,eFSrBH,GADI1N,GAAY1R,OAAOuf,gBACZhZ,GGKZ,SAAyBC,GACxB,IAAIgZ,ECVL,SAAmBhZ,GAElB,OAAOA,EAAIM,SACZ,CDOasY,CAAU5Y,GACtB,OAAKgZ,GAAmB,OAAVA,EACNA,EAEgC,sBAAnCjW,GAAa/C,EAAI2D,aAEd3D,EAAI2D,YAAYhJ,UAEnBqF,aAAexG,GACZA,GAAOmB,UAGR,IACR,EHXA,IAAAse,GAAeL,GKDf,SAASG,GAAgBpf,GACxB,OACCA,QAGO,MAGRA,EAAQH,GAAQG,GAETif,GAAUjf,GAClB,CClBA,IAAIuf,GAAkB1f,OAAOmB,UAyC7B,SAASwe,GAAexf,GACvB,IAAIqf,EAGJ,QAAMzQ,GAAU5O,OAIhBqf,EAAQD,GAAgBpf,MAOtBgJ,GAAYhJ,EAAO,gBAGpBgJ,GAAYqW,EAAO,gBACnB9N,GAAY8N,EAAMrV,cACmB,sBAArCZ,GAAaiW,EAAMrV,cAGnBhB,GAAYqW,EAAO,kBACnB9N,GAAY8N,EAAMI,iBAIjBJ,IAAUE,IAzDb,SAAmBlZ,GAClB,IAAIqZ,EAGJ,IAAMA,KAAOrZ,EACZ,IAAM2C,GAAY3C,EAAKqZ,GACtB,OAAO,EAGT,OAAO,CACR,CAkDGC,CAAU3f,IAGb,2ICtEA,SAASuc,KACR,OAAOnF,GAAOpS,OACf,6iCCVIsX,GAAY,gBAmBhB,SAASC,KACR,IAAIC,EACApc,EACAsI,EACJ,OAA0B,IAArBrE,UAAU1D,OACPyW,GAAOqF,IAAIzX,SAEnB0D,GAAM,EACN8T,EAAOnY,UAAW,GACbiY,GAAU5N,KAAM8N,IAEN,SADdA,EAAOna,GAASma,EAAMF,GAAW,MACD,UAATE,IACtB9T,GAAM,GAIRtI,GADAA,EAAMgX,GAAQoF,IACEpc,EAAI4E,QAAU,GACzB0D,GAAOtI,EAAIO,OAAS,GACxBP,EAAI8E,KAAM,WAEJ9E,EACR,CC7BA,SAASwf,KAER,MAAO,CAENrU,KAAQ,EAGR1D,KAAQ,EACRG,MAAS,EACTC,OAAU,EACVL,MAAS,EACTG,OAAU,EACVJ,MAAS,EACTG,OAAU,EACV+X,MAAS,EACTC,OAAU,EAOVC,QAAW,GAEXrY,QAAW,GACXH,QAAW,GAIXyY,UAAa,GACbvX,UAAa,GACbD,WAAc,GAGdyX,OAAU,GAGV/X,QAAW,GAGXgY,OAAU,GAGVC,iBAAoB,IAEtB,CC1CApZ,EAAAnH,GAAA,OAAAggB,ICSA,SAAiB7K,EAAQqL,GACxB,IAAIzK,EACAwI,EACAhe,EAGJ,IADAwV,EAAO0K,GAAYD,GACbjgB,EAAI,EAAGA,EAAIwV,EAAKhV,OAAQR,IAE7B4G,EAAagO,EADboJ,EAAIxI,EAAMxV,GACcigB,EAAQjC,GAGlC,CDnBAjE,CAAAta,GDFQ,CAEN2L,KAAQ,EAGR1D,KAAQ,EACRG,MAAS,EACTC,OAAU,EACVL,MAAS,EACTG,OAAU,EACVJ,MAAS,EACTG,OAAU,EACV+X,MAAS,EACTC,OAAU,EAOVC,QAAW,GAEXrY,QAAW,GACXH,QAAW,GAIXyY,UAAa,GACbvX,UAAa,GACbD,WAAc,GAGdyX,OAAU,GAGV/X,QAAW,GAGXgY,OAAU,GAGVC,iBAAoB,MGvDtB,IAAI3I,GHcI,CAENjM,KAAQ,EAGR1D,KAAQ,EACRG,MAAS,EACTC,OAAU,EACVL,MAAS,EACTG,OAAU,EACVJ,MAAS,EACTG,OAAU,EACV+X,MAAS,EACTC,OAAU,EAOVC,QAAW,GAEXrY,QAAW,GACXH,QAAW,GAIXyY,UAAa,GACbvX,UAAa,GACbD,WAAc,GAGdyX,OAAU,GAGV/X,QAAW,GAGXgY,OAAU,GAGVC,iBAAoB,KGnCtB,SAASP,KAER,MAAO,CACNrU,KAAQiM,GAAY,KAEpB3P,KAAQ2P,GAAY,KACpBxP,MAASwP,GAAa,MACtBvP,OAAUuP,GAAc,OACxB5P,MAAS4P,GAAa,MACtBzP,OAAUyP,GAAc,OACxB7P,MAAS6P,GAAa,MACtB1P,OAAU0P,GAAc,OACxBqI,MAASrI,GAAa,MACtBsI,OAAUtI,GAAc,OAExB9P,QAAW8P,GAAe,QAC1BjQ,QAAWiQ,GAAe,QAE1B/O,UAAa+O,GAAiB,UAC9BhP,WAAcgP,GAAkB,WAEhCyI,OAAUzI,GAAc,OAExBtP,QAAWsP,GAAe,QAE1B0I,OAAU1I,GAAc,OAExB2I,iBAAoB3I,GAAwB,iBAE9C,CC5BAzQ,EAAAnH,GAAA,OAAAggB,ICGA,SAAiB7K,EAAQqL,GACxB,IAAIzK,EACAwI,EACAhe,EAGJ,IADAwV,EAAO0K,GAAYD,GACbjgB,EAAI,EAAGA,EAAIwV,EAAKhV,OAAQR,IAE7B4G,EAAagO,EADboJ,EAAIxI,EAAMxV,GACcigB,EAAQjC,GAGlC,CDbAjE,CAAAta,GAAAggB,MErBA,IAAIU,GCyCJ,SAAiBja,EAAKmQ,GACrB,IACIb,EACA/L,EACA8V,EACA1I,EACA5W,EACAkJ,EACAnJ,EAPAogB,GAAa,EAQjB,IAAM1W,GAAcxD,GACnB,MAAM,IAAInC,UAAWiB,EAAQ,iFAAkFkB,IAEhH,GAAKhC,UAAU1D,OAAS,EAAI,CAC3B,IAAMiO,GAAU4H,GACf,MAAM,IAAItS,UAAWiB,EAAQ,qEAAsEqR,IAEpG,GAAKxN,GAAYwN,EAAM,gBAEhBtG,GADNqQ,EAAa/J,EAAKgK,YAEjB,MAAM,IAAItc,UAAWiB,EAAQ,+DAAgE,aAAcob,GAG7G,CAID,GAFA3W,GADA+L,EAAO0K,GAAYha,IACR1F,OACXP,EAAM,CAAA,EACDmgB,EACJ,IAAMpgB,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAGf6I,GAAY5I,EADlB4W,EAAM3Q,EADNqZ,EAAM/J,EAAMxV,MAMZmJ,EAAIlJ,EAAK4W,GACJ3T,GAASiG,GACblJ,EAAK4W,GAAM9R,KAAMwa,GAEjBtf,EAAK4W,GAAQ,CAAE1N,EAAGoW,IAPlBtf,EAAK4W,GAAQ0I,OAWf,IAAMvf,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAErBC,EAAKiG,EADLqZ,EAAM/J,EAAMxV,KACQuf,EAGtB,OAAOtf,CACR,CDzFWqgB,CAAeb,KAAe,CACxCY,YAAc,IEFf,IAAIE,GAAOd,KCaX,SAASe,GAAStY,GACjB,IAAIuY,SAAavY,EACjB,MAAW,WAANuY,EAC2B,ODGjC,SAAmBvY,GAClB,IAAIiB,EAAIoX,GAAMrY,GACd,MAAsB,iBAANiB,EAAmBA,EAAI,IACxC,CCNWuX,CAAUxY,GAAqB,KAAOA,EAErC,WAANuY,EHKN,SAAmBvY,GAClB,IAAIiB,EAAIgX,GAAMjY,GACd,MAAsB,iBAANiB,EAAmBA,EAAI,IACxC,CGPSwX,CAAUzY,GAEX,IACR,KCnBI0Y,wpDAsFJ,SAASC,GAAiB3Y,GACzB,OAA0B,IAArBhE,UAAU1D,OA5EhB,WACC,IAAI4b,EACA0E,EACA7gB,EACAuU,EACAuM,EACAC,EACAvJ,EACA3T,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN6gB,GADA1E,EAAS8D,GAAYe,KACLzgB,OACVR,EAAI,EAAGA,EAAI8gB,EAAQ9gB,IAAM,CAI9B,IAHA+gB,EAAM3E,EAAQpc,GACdyX,EAAIwJ,GAAOF,GACXvM,EAAM,CAAA,EACA1Q,EAAI,EAAGA,EAAIgd,EAAQhd,IAExB0Q,EADAwM,EAAM5E,EAAQtY,IACD2T,EAAGuJ,GAEjB/gB,EAAK8gB,GAAQvM,CACb,CACD,OAAOvU,CACR,CAoDSihB,SAEO,IAAVN,KAEJA,GAhDF,WACC,IAAIxE,EACA0E,EACA7gB,EACAuU,EACAuM,EACAC,EACAvJ,EACA3T,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN6gB,GADA1E,EAAS8D,GAAYe,KACLzgB,OACVR,EAAI,EAAGA,EAAI8gB,EAAQ9gB,IAAM,CAI9B,IAHA+gB,EAAM3E,EAAQpc,GACdyX,EAAIwJ,GAAOF,GACXvM,EAAM,GACA1Q,EAAI,EAAGA,EAAIgd,EAAQhd,IAEN,IAAb2T,EADLuJ,EAAM5E,EAAQtY,KAEb0Q,EAAIzP,KAAMic,GAGZ/gB,EAAK8gB,GAAQvM,CACb,CACD,OAAOvU,CACR,CAqBUkhB,IAETjZ,EAAQsY,GAAStY,GACZW,GAAY+X,GAAO1Y,GAChB0Y,GAAO1Y,GAAQrD,QAEhB,KACR,CCtGA,IAAI+b,GAAQQ,KAmBZ,SAASC,GAAkBC,EAAMC,GAChC,OAAKD,IAASC,GAGLX,GAAOU,GAAQC,GAAO,CAChC,CCmBA,ICxCIX,GDwCAY,GAAoBrJ,GAAUiE,GAAQ,YEGtCqF,GAAiBtJ,GAAUiE,GAAQ,SCHnCsF,GAA8BvJ,GAAUiE,GAAQ,6qDF8CpD,SAASuF,GAAWzZ,GACnB,OAA0B,IAArBhE,UAAU1D,OA5EhB,WACC,IAAI4b,EACA0E,EACA7gB,EACAuU,EACAuM,EACAC,EACAvJ,EACA3T,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN6gB,GADA1E,EAAS8D,GAAY0B,KACLphB,OACVR,EAAI,EAAGA,EAAI8gB,EAAQ9gB,IAAM,CAI9B,IAHA+gB,EAAM3E,EAAQpc,GACdyX,EAAImK,GAAYb,GAChBvM,EAAM,CAAA,EACA1Q,EAAI,EAAGA,EAAIgd,EAAQhd,IAExB0Q,EADAwM,EAAM5E,EAAQtY,IACD2T,EAAGuJ,GAEjB/gB,EAAK8gB,GAAQvM,CACb,CACD,OAAOvU,CACR,CAoDSihB,SAEO,IAAVN,KAEJA,GAhDF,WACC,IAAIxE,EACA0E,EACA7gB,EACAuU,EACAuM,EACAC,EACAvJ,EACA3T,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN6gB,GADA1E,EAAS8D,GAAY0B,KACLphB,OACVR,EAAI,EAAGA,EAAI8gB,EAAQ9gB,IAAM,CAI9B,IAHA+gB,EAAM3E,EAAQpc,GACdyX,EAAImK,GAAYb,GAChBvM,EAAM,GACA1Q,EAAI,EAAGA,EAAIgd,EAAQhd,IAEN,IAAb2T,EADLuJ,EAAM5E,EAAQtY,KAEb0Q,EAAIzP,KAAMic,GAGZ/gB,EAAK8gB,GAAQvM,CACb,CACD,OAAOvU,CACR,CAqBUkhB,IAETjZ,EAAQsY,GAAStY,GACZW,GAAY+X,GAAO1Y,GAChB0Y,GAAO1Y,GAAQrD,QAEhB,KACR,CGtGA,IAAI+b,GAAQe,KAmBZ,SAASE,GAAYP,EAAMC,GAC1B,OAAKD,IAASC,GAGLX,GAAOU,GAAQC,GAAO,CAChC,KCrBIX,wpDAsFJ,SAASkB,GAAe5Z,GACvB,OAA0B,IAArBhE,UAAU1D,OA5EhB,WACC,IAAI4b,EACA0E,EACA7gB,EACAuU,EACAuM,EACAC,EACAvJ,EACA3T,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN6gB,GADA1E,EAAS8D,GAAY6B,KACLvhB,OACVR,EAAI,EAAGA,EAAI8gB,EAAQ9gB,IAAM,CAI9B,IAHA+gB,EAAM3E,EAAQpc,GACdyX,EAAIsK,GAAiBhB,GACrBvM,EAAM,CAAA,EACA1Q,EAAI,EAAGA,EAAIgd,EAAQhd,IAExB0Q,EADAwM,EAAM5E,EAAQtY,IACD2T,EAAGuJ,GAEjB/gB,EAAK8gB,GAAQvM,CACb,CACD,OAAOvU,CACR,CAoDSihB,SAEO,IAAVN,KAEJA,GAhDF,WACC,IAAIxE,EACA0E,EACA7gB,EACAuU,EACAuM,EACAC,EACAvJ,EACA3T,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN6gB,GADA1E,EAAS8D,GAAY6B,KACLvhB,OACVR,EAAI,EAAGA,EAAI8gB,EAAQ9gB,IAAM,CAI9B,IAHA+gB,EAAM3E,EAAQpc,GACdyX,EAAIsK,GAAiBhB,GACrBvM,EAAM,GACA1Q,EAAI,EAAGA,EAAIgd,EAAQhd,IAEN,IAAb2T,EADLuJ,EAAM5E,EAAQtY,KAEb0Q,EAAIzP,KAAMic,GAGZ/gB,EAAK8gB,GAAQvM,CACb,CACD,OAAOvU,CACR,CAqBUkhB,IAETjZ,EAAQsY,GAAStY,GACZW,GAAY+X,GAAO1Y,GAChB0Y,GAAO1Y,GAAQrD,QAEhB,KACR,CCtGA,IAAI+b,GAAQkB,KC2CZ,IAAIE,GAA0B7J,GAAUiE,GAAQ,mBCAhD,IAAI6F,GAA4B9J,GAAUiE,GAAQ,qBClClD8F,GAAA,CAAA,ECaA,SAASC,GAAKrT,EAAGiK,GAChB,OAAKjK,EAAIiK,EACDjK,EAEDiK,CACR,CCLA,SAASqJ,GAAKtT,EAAGiK,GAChB,OAAKjK,EAAIiK,EACDjK,EAEDiK,CACR,CCjBA,SAASsJ,GAAQxiB,EAAO4J,GACvB,IAAIpC,EACArH,EAIJ,IADAqH,EAAM,GACArH,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBqH,EAAItC,KAAMlF,GAEX,OAAOwH,CACR,CCLA,SAASib,GAAUziB,EAAO0iB,GACzB,IAAIlb,EACAmb,EACAC,EACAziB,EAOJ,IALAwiB,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZlb,EAAM,GACArH,EAAI,EAAGA,EAAIyiB,EAAIziB,IACpBqH,EAAItC,KAAMsd,GAAQxiB,EAAO2iB,IAE1B,OAAOnb,CACR,CCpBA,SAASqb,GAASH,GACjB,OAAOD,GAAU,EAAKC,EACvB,CLOA3b,EAAAsb,GAAA,WAAA/J,IAUAvR,EAAAsb,GAAA,wBxEgGA,SAA+BpT,EAAGiK,EAAGD,GACpC,IAAIvQ,EACAoa,EACAC,EACAC,EACAC,EAEJ,OAAKhU,EAAEtO,SAAWuY,EAAEvY,SAGpBmiB,EAAK9K,GAAkB/I,GACvB8T,EAAK/K,GAAkBkB,GAClB4J,EAAGrL,kBAAoBsL,EAAGtL,kBAC9B/O,EAAM,EAGDoO,GAAgB7H,GACf6H,GAAgBoC,GACbf,GAAU+K,GAAoBjU,EAAG,GAAKiU,GAAoBhK,EAAG,GAAKD,EAAQoC,IAE3E9D,GAAWuL,EAAIC,EAAI9J,EAAQgC,KAG9BxI,GAAmBxD,IACvB+T,EAAK3O,GAAgBpF,EAAG,GACxBvG,GAAO,GACI8J,GAAkBvD,KAC7B+T,EAAK5O,GAAenF,EAAG,GACvBvG,GAAO,GAEH+J,GAAmByG,IACvB+J,EAAK5O,GAAgB6E,EAAG,GACxBxQ,GAAO,GACI8J,GAAkB0G,KAC7B+J,EAAK7O,GAAe8E,EAAG,GACvBxQ,GAAO,GAEK,IAARA,EAE0B,IAAzBsa,EAAGzQ,mBAAoD,IAAzB0Q,EAAG1Q,kBAC9B4F,GAAU6K,EAAIC,EAAIhK,EAAQoC,IAE3BlD,GAAU6K,EAAIC,EAAIhK,EAAQ0C,IAE3BpE,GAAWuL,EAAIC,EAAI9J,EAAQgC,MAGN,IAAxBhM,EAAEsD,mBAAmD,IAAxB2G,EAAE3G,kBAC5B4F,GAAUlJ,EAAGiK,EAAGD,EAAQ0C,IAEzBxD,GAAUlJ,EAAGiK,EAAGD,EAAQgC,IAChC,IwEzIAlU,EAAAsb,GAAA,kBvEwEA,SAAyBpT,EAAGiK,GAC3B,IAAIxQ,EACAoa,EACAC,EACAC,EACAC,EAEJ,OAAKhU,EAAEtO,SAAWuY,EAAEvY,SAGpBmiB,EAAK9K,GAAkB/I,GACvB8T,EAAK/K,GAAkBkB,GAClB4J,EAAGrL,kBAAoBsL,EAAGtL,kBAC9B/O,EAAM,EAGDoO,GAAgB7H,GACf6H,GAAgBoC,GACbf,GAAU+K,GAAoBjU,EAAG,GAAKiU,GAAoBhK,EAAG,IAE9D3B,GAAWuL,EAAIC,IAGlBtQ,GAAmBxD,IACvB+T,EAAK3O,GAAgBpF,EAAG,GACxBvG,GAAO,GACI8J,GAAkBvD,KAC7B+T,EAAK5O,GAAenF,EAAG,GACvBvG,GAAO,GAEH+J,GAAmByG,IACvB+J,EAAK5O,GAAgB6E,EAAG,GACxBxQ,GAAO,GACI8J,GAAkB0G,KAC7B+J,EAAK7O,GAAe8E,EAAG,GACvBxQ,GAAO,GAEK,IAARA,EACGyP,GAAU6K,EAAIC,GAEf1L,GAAWuL,EAAIC,KAEhB5K,GAAUlJ,EAAGiK,GACrB,IuEzGAnS,EAAAsb,GAAA,yBMjCA,SAAgCpT,EAAGiK,GAClC,IAAI/Y,EACJ,GAAK8O,EAAEtO,SAAWuY,EAAEvY,OACnB,OAAO,EAER,IAAMR,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1B,GAAK8O,EAAG9O,KAAQ+Y,EAAG/Y,GAClB,OAAO,EAGT,OAAO,CACR,INgCA4G,EAAAsb,GAAA,iBnEqDA,SAAwBpT,EAAGiK,GAC1B,IAAIxQ,EACAoa,EACAC,EACAC,EACAC,EAEJ,OAAKhU,EAAEtO,SAAWuY,EAAEvY,SAGpBmiB,EAAK9K,GAAkB/I,GACvB8T,EAAK/K,GAAkBkB,GAClB4J,EAAGrL,kBAAoBsL,EAAGtL,kBAC9B/O,EAAM,EAGDoO,GAAgB7H,GACf6H,GAAgBoC,GACbf,GAAU+K,GAAoBjU,EAAG,GAAKiU,GAAoBhK,EAAG,IAE9D3B,GAAWuL,EAAIC,IAGlBtQ,GAAmBxD,IACvB+T,EAAK3O,GAAgBpF,EAAG,GACxBvG,GAAO,GACI8J,GAAkBvD,KAC7B+T,EAAK5O,GAAenF,EAAG,GACvBvG,GAAO,GAEH+J,GAAmByG,IACvB+J,EAAK5O,GAAgB6E,EAAG,GACxBxQ,GAAO,GACI8J,GAAkB0G,KAC7B+J,EAAK7O,GAAe8E,EAAG,GACvBxQ,GAAO,GAEK,IAARA,EACGyP,GAAU6K,EAAIC,GAEf1L,GAAWuL,EAAIC,KAEhB5K,GAAUlJ,EAAGiK,GACrB,ImEtFAnS,EAAAsb,GAAA,kBAAAhb,GAUAN,EAAAsb,GAAA,oBAAA3F,IAUA3V,EAAAsb,GAAA,iBAAAvL,IAUA/P,EAAAsb,GAAA,cAAAxF,IAUA9V,EAAAsb,GAAA,iCAAAtF,IAUAhW,EAAAsb,GAAA,sBAAAnF,IAUAnW,EAAAsb,GAAA,mBAAA7P,IAUAzL,EAAAsb,GAAA,oBAAA5P,IAUA1L,EAAAsb,GAAA,aAAAlF,IAUApW,EAAAsb,GAAA,0BAAAjF,IAUArW,EAAAsb,GAAA,oBAAAhF,IAUAtW,EAAAsb,GAAA,2BAAAc,IAUApc,EAAAsb,GAAA,oBAAAV,IAUA5a,EAAAsb,GAAA,iBAAAT,IAUA7a,EAAAsb,GAAA,8BAAAR,IAUA9a,EAAAsb,GAAA,qBAAAe,IAUArc,EAAAsb,GAAA,0BHlNA,SAAyBZ,EAAMC,GAC9B,OAAKD,IAASC,GAGLX,GAAOU,GAAQC,GAAO,CAChC,IGuNA3a,EAAAsb,GAAA,0BAAAF,IAUApb,EAAAsb,GAAA,qBOxNA,SAA4BpT,GAC3B,IAAIrF,EACAhD,EACA4Q,EACA6L,EACAC,EACAnjB,EAeJ,GAZAqX,EAAKnP,GAAO4G,GAIXrI,EADIS,EAAiB4H,GACf4F,EAAgB2C,GAEhBpP,EAAQoP,GAMF,KAHb5N,EAAMqF,EAAEtO,QAIP,OAAO,EAIR,IADA0iB,EAAKzc,EAAKqI,EAAG,GACP9O,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,GAAKkjB,GADLC,EAAK1c,EAAKqI,EAAG9O,IAEZ,OAAO,EAERkjB,EAAKC,CACL,CACD,OAAO,CACR,IPgMAvc,EAAAsb,GAAA,4BAAAD,IQ1PA,IAAAC,GAAA,CAAA,ECDA,SAASkB,GAAStU,EAAGiK,EAAGpG,EAAG0Q,EAAOd,EAAOe,EAAKpO,GAC7C,IAAIqO,EACAC,EACAxjB,EAOJ,GALAujB,EAAIhB,EAAOe,IAGXE,EAAIF,EAAM,KAECD,EAQX,IAAMrjB,EAAI,EAAGA,EAAIujB,EAAGvjB,IACnBojB,GAAStU,EAAG9O,GAAK+Y,EAAG/Y,GAAK2S,EAAG3S,GAAKqjB,EAAOd,EAAOiB,EAAGtO,QAPlD,IAAMlV,EAAI,EAAGA,EAAIujB,EAAGvjB,IACnB2S,EAAG3S,GAAMkV,EAAKpG,EAAG9O,GAAK+Y,EAAG/Y,GAQ5B,CCxBA,SAASyjB,GAAM3U,GACd,IAAI7O,EACAwJ,EACAzJ,EAIJ,IAFAyJ,EAAMqF,EAAEtO,OACRP,EAAM,GACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBC,EAAI8E,KAAM+J,EAAG9O,IAEd,OAAOC,CACR,CCNA,SAASH,GAAO2J,GACf,OAAO4Y,GAAQ,EAAK5Y,EACrB,CC8CA,SAASia,GAAgB5U,EAAG6U,EAASC,GACpC,IAAI9L,EACAwL,EACAO,EACAhO,EACAiO,EACAN,EACAxjB,EACA8D,EAIJ,IAFA+R,EAAI+N,EAASpjB,SACbsjB,EAAIH,EAAQnjB,QAEX,MAAM,IAAIgB,MAAO,gKAIlB,IADAsW,EAAOhJ,EACD9O,EAAI8jB,EAAG9jB,EAAI6V,EAAG7V,IACnB8X,EAAO,CAAEA,GAOV,IAHA+L,EAAK/jB,GAAO+V,GAGN7V,EAAI6V,EAAE,EAAG7V,GAAK,EAAGA,IAEtB,MADA8D,EAAIggB,EAAIjO,EAAI7V,GACH,GAAT,CAMA,GAFAwjB,EAAIG,EAAS7f,GAEA,KADbwf,EAAMM,EAAU5jB,KACEsjB,EAAME,EACvB,MAAM,IAAIhiB,MAAOwD,EAAQ,8PAA+Pye,GAAME,GAAUpO,KAAM,MAAQkO,GAAMG,GAAWrO,KAAM,MAAQvV,IAEtV,GAAKwjB,IAAMF,EAEVO,EAAI7jB,GAAM,MACJ,IAAW,IAANwjB,EAKX,MAAM,IAAIhiB,MAAOwD,EAAQ,2IAA4Iye,GAAME,GAAUpO,KAAM,MAAQkO,GAAMG,GAAWrO,KAAM,MAAQvV,IAHlO6jB,EAAI7jB,GAAM,CAIV,CAfA,CAkBF,MAAO,CACN+jB,IAAOjV,EACPgJ,KAAQA,EACRyK,MAASkB,GAAMG,GACfI,QAAWH,EAEb,CC1FA,SAASI,GAAOnV,GAEf,OACQqD,GADHrD,EAAI,EACOA,EAAE,EAEHA,EAAE,EAClB,CCLA,SAASoV,GAAYpV,GACpB,OAAQA,IAAMhD,IAAQgD,IAAMC,EAC7B,CNNAnI,EAAAsb,GAAA,cOmCA,SAAqBK,EAAO4B,EAAIC,EAAIC,EAAM9P,EAAMD,GAC/C,IAAIjN,EACAid,EACA9B,EACAC,EACA8B,EACAC,EAOJ,IALA/B,EAAKF,EAAO,GACZC,EAAKD,EAAO,GAGZlb,EAAM,GACAmd,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAE7B,IADAF,EAAK,GACCC,EAAK,EAAGA,EAAK/B,EAAI+B,IAGnBA,GAAMC,GAAMD,GAAMC,EAAGL,GACrBI,GAAMC,GAAMA,GAAMD,EAAGH,EAEvBE,EAAGvf,KAAMwP,EAAKzS,KAAMwS,EAAS,CAAEkQ,EAAID,KAInCD,EAAGvf,KAAMsf,GAGXhd,EAAItC,KAAMuf,EACV,CACD,OAAOjd,CACR,IPxDAT,EAAAsb,GAAA,aQEA,SAAoB7a,EAAK8c,EAAIC,EAAIK,GAChC,IAAIxkB,EACAshB,EACAuC,EACAjO,EACA7V,EACA8D,EACAka,EAMJ,GAJA8F,EAAIzc,EAAI7G,OACRqV,EAAIxO,EAAK,GAAI7G,OAGRikB,EAAkB,CAEtB,IADAxkB,EAAMyiB,GAAS,CAAE7M,EAAGsO,EAAGC,EAAG,IACpBtgB,EAAI,EAAGA,EAAI+R,EAAG/R,IAGnB,IAFAyd,EAAKthB,EAAK6D,GACVka,EAAImG,EAAKrgB,EACH9D,EAAImiB,GAAK,EAAGre,EAAEqgB,GAAMnkB,EAAIoiB,GAAK0B,EAAGhgB,EAAEsgB,EAAG,GAAKpkB,IAC/CuhB,EAAIvD,EAAEhe,GAAMqH,EAAKrH,GAAK8D,GAGxB,OAAO7D,CACP,CAGD,IADAA,EAAMyiB,GAAS,CAAEyB,EAAGC,EAAG,EAAGvO,IACpB/R,EAAI,EAAGA,EAAI+R,EAAG/R,IAEnB,IADAka,EAAImG,EAAKrgB,EACH9D,EAAImiB,GAAK,EAAGre,EAAEqgB,GAAMnkB,EAAIoiB,GAAK0B,EAAGhgB,EAAEsgB,EAAG,GAAKpkB,IAC/CC,EAAK+d,EAAEhe,GAAK8D,GAAMuD,EAAKrH,GAAK8D,GAG9B,OAAO7D,CACR,IC9CA,IAAIykB,GAAOziB,KAAKyiB,KCRhBC,IATwB,IAAnBlL,GACE,EAEA,ECFHE,GAAe,IAAIpP,GAAc,GACjCiO,GAAc,IAAI5N,GAAa+O,GAAa7G,QAwEhD,SAAS8R,GAAY9V,EAAG+V,GAGvB,OAFAlL,GAAc,GAAM7K,EACpB0J,GAAae,IAAUsL,IAAQ,EACxBlL,GAAc,EACtB,CCpEA,SAASmL,GAAehW,GAEvB,OAAS,EAAFA,CACR,CCSA,ICtBIwK,GACAC,GDqBAwL,GAA6B,WEbjCC,IATwB,IAAnBvL,GACG,EAEA,ECFJE,GAAe,IAAIpP,GAAc,GACjCiO,GAAc,IAAI5N,GAAa+O,GAAa7G,QAoDhD,SAASmS,GAAanW,GAErB,OADA6K,GAAc,GAAM7K,EACb0J,GAAac,GACrB,EFtDwB,IAAnBG,IACJH,GAAO,EACPC,GAAM,IAEND,GAAO,EACPC,GAAM,GAUP,IAAA2L,GARU,CACT5L,KAAQA,GACRC,IAAOA,IGXJI,GAAe,IAAIpP,GAAc,GACjCiO,GAAc,IAAI5N,GAAa+O,GAAa7G,QAE5CwG,GAAOM,GAAQN,KACfC,GAAMK,GAAQL,IA6ElB,SAAS4L,GAAWC,EAAMP,GAGzB,OAFArM,GAAac,IAAS8L,EACtB5M,GAAae,IAAQsL,EACdlL,GAAc,EACtB,CClFA,IAAI0L,GAAQ,CAAE,EAAG,GAgCjB,SAASC,GAAUxW,EAAGiK,GACrB,IAAIwM,EACAC,EAmBJ,OAhBA3L,GAAQE,OAAQjL,EAAGuW,GAAO,EAAG,GAC7BE,EAAKF,GAAO,GAGZE,GAAME,GAGND,EAAKP,GAAalM,GASXoM,GAHPI,GAHAC,GAAM5M,GAMgByM,GAAO,GAC9B,CC3CA,IAAIK,GAAsB,WAEtBC,GAAO,MACPC,GAAO,OCTX,IAAAC,IATwB,IAAnBpM,GACG,EAEA,ECFJE,GAAe,IAAIpP,GAAc,GACjCiO,GAAc,IAAI5N,GAAa+O,GAAa7G,QAgEhD,SAASgT,GAAahX,EAAGsW,GAGxB,OAFAzL,GAAc,GAAM7K,EACpB0J,GAAac,IAAW8L,IAAS,EAC1BzL,GAAc,EACtB,CC9CA,IAAIoM,GAAwB,KCXxBC,GAAyC,GCM7C,IAAIC,GAAwB,QAGxBC,GAAsB,QAGtBC,GAAoB,WAGpBC,GAA0B,UAG1BC,GAAwB,OAExBC,GAAQ,iBAGRC,GAAK,kBAGLC,GAAQ,kBAGRC,IAAS,qBAETC,GAAK,CACR,EACA,KAEGC,GAAQ,CACX,EACA,mBAEGC,GAAQ,CACX,EACA,sBCvCD,IAAIC,GAAU,mBAGVC,GAAa,mBAGbC,GAAa,sBCDjB,IAAIC,GAA6B,KCA7BC,IAAuC,KCAvCC,IAAuC,KCQvCC,GAA0B,uBCzB1BC,GAAS,iBA8Cb,SAASC,GAAWvY,EAAG7O,EAAK6Z,EAAQjH,GACnC,OAAKzP,GAAO0L,IAAOoV,GAAYpV,IAC9B7O,EAAK4S,GAAW/D,EAChB7O,EAAK4S,EAASiH,GAAW,EAClB7Z,GAEG,IAAN6O,GAAa9M,GAAK8M,GAAMqY,IAC5BlnB,EAAK4S,GAAW/D,EAAIsY,GACpBnnB,EAAK4S,EAASiH,IAAY,GACnB7Z,IAERA,EAAK4S,GAAW/D,EAChB7O,EAAK4S,EAASiH,GAAW,EAClB7Z,EACR,CC/BA2G,GCKA,SAAoBkI,GACnB,OAAOoG,GAAKpG,EAAG,CAAE,EAAK,GAAK,EAAG,EAC/B,GDPA,SAAAiL,IEVA,IAAIuN,GAAkC,WCHtC,IAAIC,GAAY,qBAGZC,GAAiB,WAGjBC,GAAO,CAAE,EAAK,GAGdpC,GAAQ,CAAE,EAAG,GAwCjB,SAASqC,GAAOC,EAAMC,GACrB,IAAIxC,EACAyC,EACJ,OACS,IAARD,GACS,IAATD,GACAvkB,GAAOukB,IACPzD,GAAYyD,GAELA,GAGRN,GAAWM,EAAMF,GAAM,EAAG,GAC1BE,EAAOF,GAAM,GACbG,GAAOH,GAAM,GAGbG,GC9DD,SAAmB9Y,GAElB,IAAIsW,EAAOH,GAAanW,GAMxB,OAHAsW,GAASA,EAAO0C,MAAe,IAGhBC,GAAM,CACtB,CDqDQC,CAAUL,GAGZC,EAAMK,GACH3C,GAAU,EAAKqC,GAElBC,EAAMM,GACLP,EAAO,EACJ5Y,GAEDjD,IAGH8b,GAAOO,IACXP,GAAO,GACPC,EAAIN,IAEJM,EAAI,EAGLhO,GAAQE,OAAQ4N,EAAMtC,GAAO,EAAG,GAChCD,EAAOC,GAAO,GAGdD,GAAQoC,GAMDK,EAAI1C,GAHXC,GAAUwC,EAAIG,IAAS,GAGK1C,GAAO,KACpC,CEnGA,IAAI+C,GAAM,kBCKNC,GAAqC,QCEzC,IAAInC,GAAsB,QAGtBoC,GAAwB,WAGxBC,GAAS,kBAGTC,IAAU,qBCFd,IAAI9C,GAAsB,WAGtB+C,GAAqB,WAGrBC,GAAqB,WAGrBC,GAAqB,WAGrBxC,GAAoB,WAGpByC,GAAY,WAGZC,GAAgB,WAEhBC,GAAwB,GAExBnD,GAAO,MACPC,GAAO,OAGPmD,GAAM,qBAGN1D,GAAQ,CAAE,EAAK,GAGf2D,GAAgB,CAAE,EAAK,GAwG3B,SAASC,GAAKna,EAAGiK,GAChB,IAAImQ,EACAC,EACAC,EACA7D,EAEAC,EAEA6D,EACAC,EACAC,EACAC,EACAC,EACAhJ,EACA9N,EACA7O,EACA9D,EACJ,GAAKoD,GAAO0L,IAAO1L,GAAO2V,GACzB,OAAOzN,IAQR,GALAuO,GAAQE,OAAQhB,EAAGsM,GAAO,EAAG,GAC7BG,EAAKH,GAAO,GAIA,IAHPA,GAAO,GAGI,CACf,GAAW,IAANtM,EACJ,OAAO,EAER,GAAW,IAANA,EACJ,OAAOjK,EAER,IAAY,IAAPiK,EACJ,OAAO,EAAMjK,EAEd,GAAW,KAANiK,EACJ,OAAO2L,GAAM5V,GAEd,IAAY,KAAPiK,EACJ,OAAO,EAAM2L,GAAM5V,GAEpB,GAAW,IAANiK,EACJ,OAAOjK,EAAIA,EAEZ,GAAW,IAANiK,EACJ,OAAOjK,EAAIA,EAAIA,EAEhB,GAAW,IAANiK,EAEJ,OADAjK,GAAKA,GACMA,EAEZ,GAAKoV,GAAYnL,GAChB,OCpLH,SAAcjK,EAAGiK,GAChB,OAAY,IAAPjK,GAEIA,EAAEA,IAAIA,EAAEA,GAEN,IAANA,EACG,EAGF9M,GAAI8M,GAAK,IAAUiK,IAAMjN,IACvB,EAGDA,EACR,CDsKU4d,CAAa5a,EAAGiK,EAExB,CAOD,GALAc,GAAQE,OAAQjL,EAAGuW,GAAO,EAAG,GAC7BE,EAAKF,GAAO,GAIA,IAHPA,GAAO,GAGI,CACf,GAAY,IAAPE,EACJ,OEvLH,SAAczW,EAAGiK,GAChB,OAAKA,IAAMhK,GACHjD,GAEHiN,IAAMjN,GACH,EAEHiN,EAAI,EACHkL,GAAOlL,GACJjK,EAED,EAGHmV,GAAOlL,GACJuM,GAAUxZ,GAAMgD,GAEjBhD,EACR,CFqKU6d,CAAS7a,EAAGiK,GAEpB,GAAW,IAANjK,EACJ,OAAO,EAER,IACQ,IAAPA,GACAmV,GAAOlL,GAEP,OAAQ,EAET,GAAKmL,GAAYpV,GAChB,OAAKA,IAAMC,GAEHka,IAAM,GAAMlQ,GAEfA,EAAI,EACD,EAEDjN,EAER,CACD,GACCgD,EAAI,IACe,IAAnBD,GAAWkK,GAGX,OAAQjK,EAAEA,IAAIA,EAAEA,GAqBjB,GAnBAsa,EAAKpnB,GAAK8M,GAGVoa,EAAO3D,EAAKE,GAAU,EACtB0D,EAAO3D,EAAKC,GAAU,EAItB6D,EAAM9D,IAAOsD,GAAuB,EAInCO,GALDA,EAAM9D,IAAOuD,GAAuB,IAIzB7E,GAAOlL,IACX,EAED,EAKDoQ,EAAMV,GAAqB,CAE/B,GAAKU,EAAMT,GACV,OpBnPH,SAAc5Z,EAAGiK,GAOhB,OAHKkM,GAAanW,GACN2W,KAEAC,GACN3M,EAAI,EAED4M,GAAOA,GAGRC,GAAOA,GAIV7M,EAAI,EAED4M,GAAOA,GAGRC,GAAOA,EACf,CoB4NUgE,CAAS9a,EAAGiK,GAIpB,GAAKmQ,EAAMxD,GAEV,OAAY,IAAP4D,EAEGD,EAAK1D,GAAOA,GAGb0D,EAAKzD,GAAOA,GAEpB,GAAKsD,EAAM/C,GAEV,OAAY,IAAPmD,EAEGD,EAAK1D,GAAOA,GAGb0D,EAAKzD,GAAOA,GAGpBnF,Ed3QF,SAAexgB,EAAKmpB,GACnB,IAAIS,EACAC,EACArJ,EACA3C,EACAiM,EACA5gB,EiBpCc2F,EjBgDlB,OATAgP,GADA2C,EAAI2I,EAAK,GACD3I,GiBtCG,KADO3R,EjBuCI2R,GiBrCd,GAED,GAAO3R,GAAgC,IAAJA,EAAtB,oBjBwCpB+a,GAHA1gB,EAAMsX,EAAEsG,GAAiBjJ,EAAE+I,MAE3BiD,EAAKlF,GADLkF,GAFAC,EAAIjD,GAAarG,GAERtX,EACY,IACN4gB,GAEf9pB,EAAK,GAAM6pB,EACX7pB,EAAK,GAAM4pB,EACJ5pB,CACR,CcwPM+pB,CAAMhB,GAAeI,EACzB,MAGA3I,Ef5OF,SAAiBxgB,EAAKmpB,EAAIF,GACzB,IAAI1U,EACAyV,EACAC,EACAC,EACAC,EACAC,EAEAC,EACAC,EACAf,EAEAgB,EACAC,EACAX,EACAD,EACApJ,EACAiK,EACAX,EACA5gB,EACApJ,EACA+D,EACAka,EmBvFclP,EnByKlB,OAhFA/O,EAAI,EAGCmpB,EAAMhD,KAEVnmB,GAAK,GACLmpB,EAAMjE,GAFNmE,GAAM9C,KAKPvmB,IAAOmpB,GAAOyB,IAA6B5C,GAAM,EAMjDmB,GAHAplB,EAAKolB,EAAMjD,GAAuB,GAGvBE,GAAmB,EAKzBriB,GAAK,OACTka,EAAI,EAGKla,EAAI,OACbka,EAAI,GAIJA,EAAI,EACJje,GAAK,EACLmpB,GAAOhD,IAURiE,EAAKvF,GADLqF,GAFAF,GAJAX,EAAKtD,GAAasD,EAAIF,KAGtBoB,EAAK5D,GAAI1I,MAET7U,EAAI,GAAOigB,EAAKkB,IAEK,GAGrB9V,GAAQ0U,GAAK,EAAK9C,IAA2BC,GAE7CgE,EAAKvE,GAAa,EADlBtR,GAAQwJ,GAAK,IAQb0M,GADAR,EAAKD,EAAKA,GACDC,GmB7IE,KADOpb,EnB8IMob,GmB5IhB,kBAED,kBAAsBpb,GAAK,kBAAsBA,GAAK,mBAAuBA,GAAK,iBAAqBA,GAAK,mBAA2B,mBAAJA,OnB8I1Iub,EAAKzF,GADLyF,EAAK,GADLH,EAAKC,EAAKA,IADVO,IANAN,EAAKjhB,GAAQ4gB,EAAKI,EAAGE,EAAUF,GAD1Bf,GAAMiB,EAAKC,OAOLH,EAAKF,IAGK,GASrBT,EAAK5E,GADL4E,GAJAO,EAAII,EAAKE,IACTlhB,EAAMihB,EAAGC,GAJJK,GAAML,EAAG,EAAOH,IAIAD,GAIA,GAErBO,EAAKhE,GAAQgD,EAQbK,GAPAY,EAAOhE,GAAM+C,GAFRrgB,GAAKqgB,EAAKO,IAEUxD,GAAOK,GAAO5I,MAMvC8L,EAAKlF,GADLkF,EAAOU,EAAGC,GAFVF,EAAK5D,GAAO3I,KACZyC,EAAI1gB,GAEiB,IACL0gB,EAAK8J,EAAMC,GAE3BvqB,EAAK,GAAM6pB,EACX7pB,EAAK,GAAM4pB,EACJ5pB,CACR,CemIM2qB,CAAQ5B,GAAeI,EAAIF,GAchC,GARAvW,GAFA8W,GAAQ1Q,GADRwQ,EAAK3E,GAAY7L,EAAG,KACN0H,EAAE,GAAS1H,EAAE0H,EAAE,KAC7B+I,EAAKD,EAAK9I,EAAE,IAIZ5G,GAAQE,OAAQpH,EAAG0S,GAAO,EAAG,GAC7BvhB,EAAIghB,GAAeO,GAAM,IACzBrlB,EAAI8kB,GAAeO,GAAM,IAGpBvhB,GAAK6kB,GAAqB,CAE9B,GAAoC,IAA7B7kB,EAAE6kB,GAAoB3oB,GAE5B,OAAOqpB,EAAK1D,GAAOA,GAEpB,GAAM8D,EAAGV,GAAQpW,EAAE6W,EAElB,OAAOH,EAAK1D,GAAOA,EAEpB,MAEI,IAAM7hB,EAAE2hB,KAAamD,GAAY,CAErC,GAA+B,IAAxB9kB,EAAE+kB,GAAe7oB,GAEvB,OAAOqpB,EAAKzD,GAAOA,GAEpB,GAAK6D,GAAO9W,EAAE6W,EAEb,OAAOH,EAAKzD,GAAOA,EAEpB,CAID,OAFAjT,EDxSD,SAAe7O,EAAG0lB,EAAIC,GACrB,IACIK,EACArJ,EAEAsJ,EACA5gB,EACA2U,EACAnL,EACA5S,EACAC,EACAge,EMtDclP,EN4FlB,OAnCAkP,IADAhe,EAAK8D,EAAI2hB,GAAU,IACVkF,IAA6B5C,GAAM,EAC5ChoB,EAAI,EAGCC,EAAIsoB,KAIR7H,EAAIqF,GAAa,IAHjB/lB,EAAK+D,GAAKoiB,IAAsBlI,EAAE,KAAO,KAE3BiI,KADdjI,IAAOje,EAAI0lB,KAAWkF,IAA6B5C,GAAM,OACX,GAE9ChoB,GAAOA,EAAIkmB,GAAuBC,KAAyByE,GAA0B3M,IAAM,EACtFla,EAAI,IACR/D,GAAKA,GAENypB,GAAM/I,GAaP3c,EAAIghB,GADJhhB,EAAImhB,GADJtS,EAAI,IALJA,GAFAoX,GADAtJ,EAAImE,GADJnE,EAAIgJ,EAAKD,EACU,IACXjB,KACRpf,GAAOsgB,GAAMhJ,EAAE+I,IAAKpB,GAAU3H,EAAE+H,MAIhCsB,EAAKnX,GADL8N,EAAI9N,EAAIA,IM7EG,KADO7D,EN+EK2R,GM7Ef,mBAED,mBAAuB3R,GAA+BA,GAAK,qBAA0BA,GAAsC,sBAAJA,EAA5B,wBAA9D,yBN4EpBgb,EAAG,KAHnBhM,EAAI3U,GAAKwJ,EAAIoX,IAGsBpX,EAAEmL,GACtBnL,MAGf7O,GAAM/D,GAAK4qB,KAA6B,IAG/BA,IAA8B,EAClCjD,GAAO/U,EAAG5S,GAEV+lB,GAAanT,EAAG7O,EAGtB,CCsPK+mB,CAAM/mB,EAAG0lB,EAAIC,GAEVJ,EAAK1W,CACb,CMxUA,SAASmY,GAAgBhc,EAAG/O,GAC3B,IAAI0G,EACAxG,EACAuU,EACAlN,EACAmC,EACAoM,EACAkV,EACA/qB,EACA8D,EACAka,EAGJ,IADAnI,EAAI/G,EAAEtO,SACI,GAAKT,GAAK,EACnB,MAAO,GAUR,IAPA0G,EAAMwR,GAAenJ,GAGrBrF,EAAMwf,GAAKpT,EAAG9V,GAGduH,EAAM,GACAtH,EAAI,EAAGA,EAAID,EAAGC,IACnBsH,EAAIvC,KAAM,GAIX,IADA9E,EAAM,GACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAG3B,IADAge,EAAIhe,EACE8D,EAAI/D,EAAE,EAAG+D,GAAK,EAAGA,IAEtBka,GADA+M,EAAI/M,EAAInI,EAERmI,GAAKnI,EACLvO,EAAKxD,GAAMinB,EAIZ,IADAvW,EAAM,GACA1Q,EAAI,EAAGA,EAAI/D,EAAG+D,IACnB0Q,EAAIzP,KAAM0B,EAAKqI,EAAGxH,EAAKxD,KAExB7D,EAAI8E,KAAMyP,EACV,CACD,OAAOvU,CACR,CCvDA,SAAS+qB,GAAkBC,EAAIC,GAC9B,IAAIC,EACAC,EACAnrB,EACA6jB,EACAjO,EACA1M,EACAnJ,EACA8D,EAQJ,IANAqnB,EAAOlT,GAAegT,GACtBG,EAAOnT,GAAeiT,GAEtBpH,EAAImH,EAAGzqB,OACPqV,EAAIqV,EAAG1qB,OACPP,EAAM,GACAD,EAAI,EAAGA,EAAI8jB,EAAG9jB,IAEnB,IADAmJ,EAAIgiB,EAAMF,EAAIjrB,GACR8D,EAAI,EAAGA,EAAI+R,EAAG/R,IACnB7D,EAAI8E,KAAM,CAAEoE,EAAGiiB,EAAMF,EAAIpnB,KAG3B,OAAO7D,CACR,CCzBA,SAASorB,GAAiBvc,GACzB,IAAIrI,EACAxG,EACA4V,EACA1M,EACAnJ,EACA8D,EAKJ,IAHA2C,EAAMwR,GAAenJ,GACrB+G,EAAI/G,EAAEtO,OACNP,EAAM,GACAD,EAAI,EAAGA,EAAI6V,EAAG7V,IAEnB,IADAmJ,EAAI1C,EAAKqI,EAAG9O,GACN8D,EAAI,EAAGA,EAAI+R,EAAG/R,IACnB7D,EAAI8E,KAAM,CAAEoE,EAAG1C,EAAKqI,EAAGhL,KAGzB,OAAO7D,CACR,CCpBA,SAASwjB,GAAM3U,GACd,IAAI7O,EACAwJ,EACAhD,EACAzG,EAUJ,IAPAyG,EAAMwR,GAAenJ,GAGrBrF,EAAMqF,EAAEtO,OAGRP,EAAM,GACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBC,EAAI8E,KAAM0B,EAAKqI,EAAG9O,IAEnB,OAAOC,CACR,CCjCA,IAAImS,GAAoB,GAoBxB,SAASE,GAAmBzS,GAE3B,MACkB,iBAAVA,GACG,OAAVA,GAC2B,oBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMuS,oBAAsBA,EAE9B,CC5BA,IAAIA,GAAoB,EAoBxB,SAASC,GAAkBxS,GAE1B,MACkB,iBAAVA,GACG,OAAVA,GAC2B,mBAA3BA,EAAMgK,YAAYK,MAClBrK,EAAMuS,oBAAsBA,EAE9B,CCWA,SAASQ,GAAa9D,EAAG+D,GACxB,GAAKP,GAAmBxD,GACvB,OAAOoF,GAAgBpF,EAAG+D,GAE3B,GAAKR,GAAkBvD,GACtB,OAAOmF,GAAenF,EAAG+D,GAG1B,MAAM,IAAI9O,UAAWiB,EAAQ,+FAAgG8J,GAC9H,CCzBA,SAASwc,GAASxc,GACjB,IAAI/O,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACpB8O,EAAG9O,KACRD,GAAK,GAGP,OAAOA,CACR,CA+EA,SAASwrB,GAAYzc,GACpB,OAAK5H,EAAiB4H,GAChB6H,GAAgB7H,GACbwc,GAASvI,GAAoBjU,EAAG,IAEnCiO,GAAqBjO,GApC5B,SAAkBA,GACjB,IAAI0c,EACAzrB,EACAC,EAKJ,IAHAwrB,EAAOC,GAAoB3c,EAAG,GAE9B/O,EAAI,EACEC,EAAI,EAAGA,EAAIwrB,EAAKhrB,OAAQR,GAAK,EACf,IAAdwrB,EAAMxrB,IAA+B,IAAhBwrB,EAAMxrB,EAAE,KACjCD,GAAK,GAGP,OAAOA,CACR,CAuBU2rB,CAAS5c,GApEnB,SAAoBA,GACnB,IAAIrI,EACA1G,EACAC,EAKJ,IAHAyG,EAAMwR,GAAenJ,GAErB/O,EAAI,EACEC,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACpByG,EAAKqI,EAAG9O,KACbD,GAAK,GAGP,OAAOA,CACR,CAwDSqX,CAAWtI,GAEZwc,GAASxc,EACjB,CClHA,SAAS6c,GAAQ5rB,GAChB,IAAIsH,EACArH,EAGJ,GADAqH,EAAM,GACDtH,GAAK,EACT,OAAOsH,EAER,IAAMrH,EAAI,EAAGA,EAAID,EAAGC,IACnBqH,EAAItC,KAAM/E,GAEX,OAAOqH,CACR,CCiDA,SAASqkB,GAASzrB,EAAK6X,EAAMgC,EAAQjH,GACpC,IAAI1J,EACA4hB,EACA/qB,EAKJ,IAHA+qB,EAAa,EAATjR,EACJ9Z,EAAa,EAAT6S,EACJ1J,EAAI,EACInJ,GAAK,GAAKA,EAAI8X,EAAKtX,QAC1BsX,EAAM9X,GAAMmJ,EACZ2O,EAAM9X,EAAE,GAAM,EACdA,GAAK+qB,EACL5hB,GAAK,EAEN,OAAOlJ,CACR,CCxDA,SAASmX,GAAWtI,EAAGxH,EAAKkC,GAC3B,IAAIqK,EACApN,EACAzG,EACA8D,EACAka,EAMJ,IAJAnK,EAAM/E,EAAEgJ,KACRrR,EAAMqI,EAAEsI,UAAW,GAEnB4G,EAAI,EACEhe,EAAI,EAAGA,EAAIsH,EAAI9G,OAAQR,IAEvBwJ,EAAW/C,EAAKoN,EADrB/P,EAAIwD,EAAKtH,IACsB8D,EAAG+P,KACjCvM,EAAK0W,GAAMla,EACXka,GAAK,GAIP,OADA1W,EAAI9G,OAASwd,EACN1W,CACR,CAwBA,SAASgkB,GAASxc,EAAGxH,EAAKkC,GACzB,IAAIxJ,EACA8D,EACAka,EAGJ,IADAA,EAAI,EACEhe,EAAI,EAAGA,EAAIsH,EAAI9G,OAAQR,IAEvBwJ,EAAWsF,EADhBhL,EAAIwD,EAAKtH,IACe8D,EAAGgL,KAC1BxH,EAAK0W,GAAMla,EACXka,GAAK,GAIP,OADA1W,EAAI9G,OAASwd,EACN1W,CACR,CC7DA,SAASskB,GAAiB9U,EAAGC,GAC5B,OAASD,IAAMC,GAASD,GAAMA,GAAKC,GAAMA,CAC1C,CCgBA,SAAS6U,GAAiB9U,EAAGC,GAC5B,OAAOD,IAAMC,GAASD,GAAMA,GAAKC,GAAMA,MAGlC7E,GAAe4E,KAAO5E,GAAe6E,MCvBbqE,EDwBMrE,ECvB/BsE,EAASJ,GDuBmBnE,GCtB5ByE,EAASN,GAAMG,GAElBY,GAAQX,EAAQ,GAAKE,EAAQ,KAC7BS,GAAQX,EAAQ,GAAKE,EAAQ,KAL/B,IAA8BH,EACzBC,EACAE,CDyBL,CE/BA,SAAS+P,GAASxc,GACjB,IAAI/O,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrB8O,EAAG9O,KACPD,GAAK,GAGP,OAAOA,CACR,CA+EA,SAAS8rB,GAAa/c,GACrB,OAAK5H,EAAiB4H,GAChB6H,GAAgB7H,GACbwc,GAASvI,GAAoBjU,EAAG,IAEnCiO,GAAqBjO,GApC5B,SAAkBA,GACjB,IAAI0c,EACAzrB,EACAC,EAKJ,IAHAwrB,EAAOC,GAAoB3c,EAAG,GAE9B/O,EAAI,EACEC,EAAI,EAAGA,EAAIwrB,EAAKhrB,OAAQR,GAAK,GAC7BwrB,EAAMxrB,IAAOwrB,EAAMxrB,EAAE,MACzBD,GAAK,GAGP,OAAOA,CACR,CAuBU2rB,CAAS5c,GApEnB,SAAoBA,GACnB,IAAIrI,EACA1G,EACAC,EAKJ,IAHAyG,EAAMwR,GAAenJ,GAErB/O,EAAI,EACEC,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrByG,EAAKqI,EAAG9O,KACZD,GAAK,GAGP,OAAOA,CACR,CAwDSqX,CAAWtI,GAEZwc,GAASxc,EACjB,CCiBA,SAAS4c,GAAS5c,EAAGiK,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA/rB,EAOJ,IALA8rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,GAAK,GAClB,IAARyU,IAAmB3F,EAAG9O,IAAO8O,EAAG9O,EAAE,MACtCyU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,EAEP,OAAO8B,CACR,CAiFA,SAAS7B,GAAQjL,EAAGiK,EAAGe,EAAQjH,GAC9B,IAAI8P,EAAK9K,GAAkB/I,GACvB8T,EAAK/K,GAAkBkB,GAC3B,OACC4J,EAAGrL,kBACHsL,EAAGtL,kBAGEhF,GAAmBxD,GACvB4c,GAASxX,GAAgBpF,EAAG,GAAK8T,EAAI9I,EAAQjH,GAClCR,GAAkBvD,GAC7B4c,GAASzX,GAAenF,EAAG,GAAK8T,EAAI9I,EAAQjH,GACjC8D,GAAgB7H,GAxD9B,SAAkBA,EAAGiK,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA/rB,EAOJ,IALA8rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,KACb,IAARyU,GAAiB3F,EAAG9O,KACxByU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAqCGkS,CAASjJ,GAAoBjU,EAAG,GAAK8T,EAAI9I,EAAQjH,GAhLpD,SAAoB/D,EAAGiK,EAAGe,EAAQjH,GACjC,IAAI8I,EACAC,EACAC,EACAiQ,EACArX,EACAsX,EACA/rB,EAUJ,IARA2b,EAAQ7M,EAAEgJ,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO/M,EAAEsI,UAAW,GACpB0U,EAAO/S,EAAE3B,UAAW,GAEpB3C,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,KACjB,IAARyU,GAAiBoH,EAAMF,EAAO3b,KAClCyU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAyJG1C,CAAWuL,EAAIC,EAAI9I,EAAQjH,GAErBkG,IAvOT,SAAkBjK,EAAGiK,EAAGe,EAAQjH,GAC/B,IAAI4B,EACAsX,EACA/rB,EAIJ,IAFAyU,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,KACb,IAARyU,GAAiB3F,EAAG9O,KACxByU,GAAM,GAEPsE,EAAGgT,GAAOtX,EACVsX,GAAMjS,CAGR,CA0NCwR,CAASxc,EAAGiK,EAAGe,EAAQjH,GAChBkG,EACR,CCrPA,SAASkT,GAAOnd,GAEf,OAAOiL,GAAQjL,EADPuT,IAAQ,EAAOvT,EAAEtO,QACJ,EAAG,EACzB,CCwHA,SAASkrB,GAAS5c,EAAGiK,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA/rB,EAOJ,IALA8rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,GAAK,GAClB,IAARyU,GAAmB3F,EAAG9O,IAAO8O,EAAG9O,EAAE,KACtCyU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,EAEP,OAAO8B,CACR,CAiFA,SAAS7B,GAAQjL,EAAGiK,EAAGe,EAAQjH,GAC9B,IAAI8P,EAAK9K,GAAkB/I,GACvB8T,EAAK/K,GAAkBkB,GAC3B,OACC4J,EAAGrL,kBACHsL,EAAGtL,kBAGEhF,GAAmBxD,GACvB4c,GAASxX,GAAgBpF,EAAG,GAAK8T,EAAI9I,EAAQjH,GAClCR,GAAkBvD,GAC7B4c,GAASzX,GAAenF,EAAG,GAAK8T,EAAI9I,EAAQjH,GACjC8D,GAAgB7H,GAxD9B,SAAkBA,EAAGiK,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA/rB,EAOJ,IALA8rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,KACb,IAARyU,GAAiB3F,EAAG9O,KACxByU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAqCGkS,CAASjJ,GAAoBjU,EAAG,GAAK8T,EAAI9I,EAAQjH,GAhLpD,SAAoB/D,EAAGiK,EAAGe,EAAQjH,GACjC,IAAI8I,EACAC,EACAC,EACAiQ,EACArX,EACAsX,EACA/rB,EAUJ,IARA2b,EAAQ7M,EAAEgJ,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO/M,EAAEsI,UAAW,GACpB0U,EAAO/S,EAAE3B,UAAW,GAEpB3C,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,KACjB,IAARyU,GAAiBoH,EAAMF,EAAO3b,KAClCyU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAyJG1C,CAAWuL,EAAIC,EAAI9I,EAAQjH,GAErBkG,IAvOT,SAAkBjK,EAAGiK,EAAGe,EAAQjH,GAC/B,IAAI4B,EACAsX,EACA/rB,EAIJ,IAFAyU,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,KACb,IAARyU,GAAiB3F,EAAG9O,KACxByU,GAAM,GAEPsE,EAAGgT,GAAOtX,EACVsX,GAAMjS,CAGR,CA0NCwR,CAASxc,EAAGiK,EAAGe,EAAQjH,GAChBkG,EACR,CCrPA,SAASmT,GAASpd,GAEjB,OAAOiL,GAAQjL,EADPuT,IAAQ,EAAMvT,EAAEtO,QACH,EAAG,EACzB,CCwHA,SAASkrB,GAAS5c,EAAGiK,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA/rB,EAOJ,IALA8rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,GAAK,GAClB,IAARyU,IAAkB3F,EAAG9O,IAAO8O,EAAG9O,EAAE,MACrCyU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,EAEP,OAAO8B,CACR,CAiFA,SAAS7B,GAAQjL,EAAGiK,EAAGe,EAAQjH,GAC9B,IAAI8P,EAAK9K,GAAkB/I,GACvB8T,EAAK/K,GAAkBkB,GAC3B,OACC4J,EAAGrL,kBACHsL,EAAGtL,kBAGEhF,GAAmBxD,GACvB4c,GAASxX,GAAgBpF,EAAG,GAAK8T,EAAI9I,EAAQjH,GAClCR,GAAkBvD,GAC7B4c,GAASzX,GAAenF,EAAG,GAAK8T,EAAI9I,EAAQjH,GACjC8D,GAAgB7H,GAxD9B,SAAkBA,EAAGiK,EAAGe,EAAQjH,GAC/B,IAAI+I,EACAkQ,EACArX,EACAsX,EACA/rB,EAOJ,IALA8rB,EAAO/S,EAAE3B,UAAW,GACpBwE,EAAQ7C,EAAEjB,KAEVrD,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,KACb,IAARyU,GAAgB3F,EAAG9O,KACvByU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAqCGkS,CAASjJ,GAAoBjU,EAAG,GAAK8T,EAAI9I,EAAQjH,GAhLpD,SAAoB/D,EAAGiK,EAAGe,EAAQjH,GACjC,IAAI8I,EACAC,EACAC,EACAiQ,EACArX,EACAsX,EACA/rB,EAUJ,IARA2b,EAAQ7M,EAAEgJ,KACV8D,EAAQ7C,EAAEjB,KAEV+D,EAAO/M,EAAEsI,UAAW,GACpB0U,EAAO/S,EAAE3B,UAAW,GAEpB3C,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,KACjB,IAARyU,GAAgBoH,EAAMF,EAAO3b,KACjCyU,GAAM,GAEPqX,EAAMlQ,EAAOmQ,EAAItX,GACjBsX,GAAMjS,CAGR,CAyJG1C,CAAWuL,EAAIC,EAAI9I,EAAQjH,GAErBkG,IAvOT,SAAkBjK,EAAGiK,EAAGe,EAAQjH,GAC/B,IAAI4B,EACAsX,EACA/rB,EAIJ,IAFAyU,GAAM,EACNsX,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,KACb,IAARyU,GAAgB3F,EAAG9O,KACvByU,GAAM,GAEPsE,EAAGgT,GAAOtX,EACVsX,GAAMjS,CAGR,CA0NCwR,CAASxc,EAAGiK,EAAGe,EAAQjH,GAChBkG,EACR,CCrPA,SAASoT,GAAQrd,GAEhB,OAAOiL,GAAQjL,EADPuT,IAAQ,EAAMvT,EAAEtO,QACH,EAAG,EACzB,CCcA,SAAS4rB,GAAsBlmB,EAAKC,EAAM8B,EAAQG,GACjDzI,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdL,IAAOwB,EACPvB,IAAO0B,GAET,CCZA,SAAS4P,GAAUlJ,GAClB,IAAI9O,EACJ,IAAMA,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1B,IAAM8O,EAAG9O,GACR,OAAO,EAGT,OAAO,CACR,CA2BA,SAASqsB,GAAiBvd,GACzB,IAAI9O,EACJ,IAAMA,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,GAAK,EAC/B,IAAQ8O,EAAG9O,KAAO8O,EAAG9O,EAAE,GACtB,OAAO,EAGT,OAAO,CACR,CCzCA,SAASssB,GAASzsB,GACjB,OAASgP,GAAWhP,ICtBrB,SAAiBA,GAChB,OAAiB,OAAVA,CACR,CDoBgC0sB,CAAQ1sB,IEhBxC,SAAsBA,GACrB,YAAiB,IAAVA,CACR,CFcmD2sB,CAAa3sB,EAChE,CAyDA,SAAS4sB,KACR,IAAI3Y,EACAe,EACA6X,EACAC,EAoBJ,GAjBe,KADf7Y,EAAQ5P,UAAU1D,SAEjBqU,EAAQ,KACR6X,EAAO,KACPC,EAAO,MACc,IAAV7Y,GACXe,EAAQ,KACR6X,EAAOxoB,UAAW,GAClByoB,EAAO,MACc,IAAV7Y,GACXe,EAAQ3Q,UAAW,GACnBwoB,EAAOxoB,UAAW,GAClByoB,EAAO,OAEP9X,EAAQ3Q,UAAW,GACnBwoB,EAAOxoB,UAAW,GAClByoB,EAAOzoB,UAAW,MAEXuN,gBAAgBgb,IACvB,OAAO,IAAIA,GAAO5X,EAAO6X,EAAMC,GAEhC,IAAML,GAASzX,GACd,MAAM,IAAI9Q,UAAWiB,EAAQ,wFAAyF6P,IAEvH,IAAMyX,GAASI,GACd,MAAM,IAAI3oB,UAAWiB,EAAQ,yFAA0F0nB,IAExH,IAAMJ,GAASK,GACd,MAAM,IAAI5oB,UAAWiB,EAAQ,wFAAyF2nB,IAChH,GAAc,IAATA,EACX,MAAM,IAAI3Y,WAAYhP,EAAQ,gEAAiE2nB,IAKhG,OAHAlb,KAAKmb,YAAqB,IAAV/X,EAAqB,KAAOA,EAC5CpD,KAAKob,WAAmB,IAATH,EAAoB,KAAOA,EAC1Cjb,KAAKqb,WAAmB,IAATH,EAAoB,KAAOA,EACnClb,IACR,CG3DA,SAASsb,GAAgBloB,EAAO4E,EAAKujB,GACpC,IAAInY,EACA6X,EACAC,EAYJ,GAVA9X,EAAQhQ,EAAMgQ,MACd6X,EAAO7nB,EAAM6nB,KAIC,QAHdC,EAAO9nB,EAAM8nB,QAIZA,EAAO,GAIO,OAAV9X,EAGHA,EADI8X,EAAO,EACH,EAIAljB,EAAM,OAIX,GAAKoL,EAAQ,GAIjB,IAHAA,EAAQpL,EAAMoL,GAGD,EAAI,CAChB,GAAKmY,EACJ,MCnGI,CACNC,KAAQ,2BDqGPpY,EAAQ,CACR,OAGG,GAAKA,GAASpL,EAAM,CACxB,GAAKujB,EACJ,MC5GK,CACNC,KAAQ,2BD+GPpY,EADI8X,EAAO,EACHljB,EAAM,EAINA,CAET,CAGD,GAAc,OAATijB,EAGHA,EADIC,EAAO,EACJljB,EAIA,UAIJ,GAAKijB,EAAO,GAIhB,IAHAA,EAAOjjB,EAAMijB,GAGD,EAEX,GAAKC,EAAO,EAAI,CACf,GAAKK,EACJ,MC5IG,CACNC,KAAQ,2BD6INP,EAAO,CACP,KAEI,CACJ,GAAKM,GAAUN,GAAQ,EACtB,MCnJG,CACNO,KAAQ,2BDoJNP,EAAO,IACP,OAIE,GAAKA,EAAOjjB,EAAM,CACtB,GAAKujB,EACJ,MC5JK,CACNC,KAAQ,2BD8JRP,EAAOjjB,CACP,CAGD,OAAO,IAAIgjB,GAAO5X,EAAO6X,EAAMC,EAChC,CE9IA/lB,EAAAnH,GAAA,UnB8HA,SAAiBQ,EAAK6Z,EAAQjH,GAC7B,IAAI3M,EAAM2R,GAAkB5X,GAC5B,OAAKiG,EAAIoR,iBAEW,eAAdpR,EAAIgC,MACDwjB,GAASzrB,EAAKiU,GAAgBjU,EAAK,GAAK6Z,EAAQjH,GAErC,cAAd3M,EAAIgC,MACDwjB,GAASzrB,EAAKgU,GAAehU,EAAK,GAAK6Z,EAAQjH,GAlDzD,SAAoB5S,EAAK6Z,EAAQjH,GAChC,IAAIiF,EACApR,EACAyC,EACAnJ,EAOJ,IALA8X,EAAO7X,EAAI6X,KACXpR,EAAMzG,EAAImX,UAAW,GAErBpX,EAAI6S,EACJ1J,EAAI,EACInJ,GAAK,GAAKA,EAAI8X,EAAKtX,QAC1BkG,EAAKoR,EAAM9X,EAAGmJ,GACdnJ,GAAK8Z,EACL3Q,GAAK,EAEN,OAAO2O,CACR,CAmCSV,CAAWlR,EAAK4T,EAAQjH,GAzIjC,SAAkB5S,EAAK6Z,EAAQjH,GAC9B,IAAI1J,EACAnJ,EAIJ,IAFAA,EAAI6S,EACJ1J,EAAI,EACInJ,GAAK,GAAKA,EAAIC,EAAIO,QACzBP,EAAKD,GAAMmJ,EACXnJ,GAAK8Z,EACL3Q,GAAK,EAEN,OAAOlJ,CACR,CA+HQqrB,CAASrrB,EAAK6Z,EAAQjH,EAC9B,IoB1IAjM,EAAAnH,GAAA,SAAAsa,ICAAnT,EAAAnH,GAAA,SAAAsa,ICAAnT,EAAAnH,GAAA,SAAAsa,IRsHAnT,EAAa6lB,GAAO,OAAQ,SA+BT/Z,GAAE+Z,GAAM5rB,UAAW,SAAS,WAC9C,OAAO4Q,KAAKmb,MACb,IA+BmBla,GAAE+Z,GAAM5rB,UAAW,QAAQ,WAC7C,OAAO4Q,KAAKob,KACb,IA+BmBna,GAAE+Z,GAAM5rB,UAAW,QAAQ,WAC7C,OAAO4Q,KAAKqb,KACb,IA+BW9lB,EAAEylB,GAAM5rB,UAAW,YAAY,WACzC,MAAO,SAAS4Q,KAAKmb,OAAO,IAAInb,KAAKob,MAAM,IAAIpb,KAAKkb,KAAK,GAC1D,IAmCW3lB,EAAEylB,GAAM5rB,UAAW,UAAU,WACvC,MAAO,CACNsQ,KAAQ,QACR2G,KAAQ,CACPrG,KAAKmb,OACLnb,KAAKob,MACLpb,KAAKqb,OAGR,IS9SA,IAAII,GAAOjrB,KAAKirB,KCkEhB,SAASC,GAAatoB,GACrB,IAAIuoB,EACAnC,EACAC,EAUJ,OARAD,EAAKpmB,EAAMgQ,MAKC,QAJZqW,EAAKrmB,EAAM6nB,QAKVxB,GAAM,IAJPkC,EAAMvoB,EAAM8nB,MAQH,GAAK1B,GAAMC,GAGjBkC,EAAM,GAAKnC,GAAMC,EAEZ,EAEDgC,IAAQhC,EAAKD,GAAOmC,EAC5B,CC/GA,IAAInmB,GAAO,WAqBX,SAASC,GAAiBrH,GACzB,cAAgBA,EAAM4G,MAAQQ,WAAepH,EAAM6G,MAAQO,EAC5D,CCvBA,IAAIE,GAAU,CACbC,QAgCD,SAAqBC,EAAKC,GACzB,OAAOD,EAAKC,EACb,EAjCCC,QAmDD,SAAqBF,EAAKC,GACzB,OAAOD,EAAKC,EACb,EApDCE,MAsED,SAAmBH,EAAKC,GACvB,OAAOD,EAAKC,EACb,EAvECG,MAyFD,SAAmBJ,EAAKC,GACvB,OAAOD,EAAKC,EACb,EA1FCI,KA4GD,SAAkBL,EAAKC,GACtB,OAAOD,EAAKC,EACb,EA7GCK,OA+HD,SAAoBN,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAhICM,OAkJD,SAAoBP,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAnJCO,MAqKD,SAAmBR,EAAKC,GACvB,OAAOD,EAAKC,EACb,EAtKCQ,OAwLD,SAAoBT,EAAKC,GACxB,OAAOD,EAAKC,EACb,EAzLCS,QAyMD,SAAqBV,EAAKC,GACzB,OAAOD,EAAKC,EACb,EA1MCU,QA0ND,SAAuBX,EAAKC,GAC3B,OAAOD,EAAKC,EACb,GAoBA,SAASW,GAAQC,GAChB,IAAIvF,EAAIwE,GAASe,GACjB,MAAkB,mBAANvF,EACJA,EAEDwE,GAAQa,OAChB,CCjQA,IAAIG,GAAU,CACbf,QAkCD,SAAqBC,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EAnCC0H,QAuDD,SAAqBF,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EAxDC2H,MA4ED,SAAmBH,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EA7EC4H,MAiGD,SAAmBJ,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EAlGC6H,KAsHD,SAAkBL,EAAKC,EAAKzH,GAC3BwH,EAAKC,GAAQzH,CACd,EAvHC8H,OA2ID,SAAoBN,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EA5IC+H,OAgKD,SAAoBP,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EAjKCgI,MAqLD,SAAmBR,EAAKC,EAAKzH,GAC5BwH,EAAKC,GAAQzH,CACd,EAtLCiI,OA0MD,SAAoBT,EAAKC,EAAKzH,GAC7BwH,EAAKC,GAAQzH,CACd,EA3MCkI,QA6ND,SAAqBV,EAAKC,EAAKzH,GAC9BwH,EAAKC,GAAQzH,CACd,EA9NCmI,QAgPD,SAAuBX,EAAKC,EAAKzH,GAChCwH,EAAKC,GAAQzH,CACd,GAsBA,SAASuI,GAAQF,GAChB,IAAIvF,EAAIwF,GAASD,GACjB,MAAkB,mBAANvF,EACJA,EAEDwF,GAAQH,OAChB,CCzRA,IAAIb,GAAU,CACbkB,WAgCD,SAAwBhB,EAAKC,GAC5B,OAAOD,EAAIZ,IAAKa,EACjB,EAjCCgB,UA2DD,SAAuBjB,EAAKC,GAC3B,OAAOD,EAAIZ,IAAKa,EACjB,EA5DCU,QAuFD,SAAuBX,EAAKC,GAC3B,OAAOD,EAAIZ,IAAKa,EACjB,GA6BA,SAASW,GAAQC,GAChB,IAAIvF,EAAIwE,GAASe,GACjB,MAAkB,mBAANvF,EACJA,EAEDwE,GAAQa,OAChB,CC/HA,IAAIG,GAAU,CACbE,WAkCD,SAAwBhB,EAAKC,EAAKzH,GACjCwH,EAAIX,IAAK7G,EAAOyH,EACjB,EAnCCgB,UA+DD,SAAuBjB,EAAKC,EAAKzH,GAChCwH,EAAIX,IAAK7G,EAAOyH,EACjB,EAhECU,QA6FD,SAAuBX,EAAKC,EAAKzH,GAChCwH,EAAIX,IAAK7G,EAAOyH,EACjB,GAgCA,SAASc,GAAQF,GAChB,IAAIvF,EAAIwF,GAASD,GACjB,MAAkB,mBAANvF,EACJA,EAEDwF,GAAQH,OAChB,CCvIA,IAAIqC,GAAc,CACjBC,aAAgB,UAChBC,aAAgB,UAChBpH,MAAS,UACTqH,WAAc,QACdC,WAAc,QACdC,UAAa,OACbC,YAAe,SACfC,YAAe,SACfC,WAAc,QACdC,kBAAqB,SACrBC,eAAkB,YAClBC,gBAAmB,aACnBC,aAAgB,QCdbd,GAA+B,mBAAfM,WAA8BA,gBAAa,EC6B/D,IAAA4iB,GATK7gB,KACGvG,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECTI2I,GAA+B,mBAAfK,WAA8BA,gBAAa,EC6B/D,IAAA8iB,GATKngB,KACGlH,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECTI2I,GAAsC,mBAAtBW,kBAAqCA,uBAAoB,EC6B7E,IAAAyiB,GATK1f,KACG5H,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECTI2I,GAA8B,mBAAdO,UAA6BA,eAAY,EC6B7D,IAAA8iB,GATKrf,KACGlI,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECOA,SAASyR,GAAcC,GACtB,IAAIjT,EACAkJ,EACAwJ,EAGJ,IADA1S,EAAM,KAELkJ,EAAI+J,EAAGC,QACAC,MAIP,GAAKhE,GADLuD,EAAIxJ,EAAEtJ,QACyB8S,EAAEnS,QAAU,EAC1CP,EAAI8E,KAAM4N,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAI5O,UAAWiB,EAAQ,kJAAmJ2N,IAFjL1S,EAAI8E,KAAMsO,GAAOV,GAAKW,GAAOX,GAG7B,CAEF,OAAO1S,CACR,CCAA,IAAAmS,GAAA,EAAA9H,GAAA8H,kBACAmB,GAAAhB,KAYA,SAAAiB,GAAA3T,GACA,OACAA,aAAAkL,IAEA,iBAAAlL,GACA,OAAAA,IAEA,mBAAAA,EAAAgK,YAAAK,MACA,oBAAArK,EAAAgK,YAAAK,OAEA,iBAAArK,EAAA4T,SAGA,iBAAA5T,EAAA6T,OAGA,CASA,SAAAC,GAAA9T,GACA,OACAA,IAAAkL,IAGA,oBAAAlL,EAAAqK,IAEA,CAUA,SAAA0J,GAAAC,EAAAvM,GAEA,OAAA,IAAA0K,GAAA6B,EADAvM,GAAA,GACAuM,EAAAvM,EAAA,GACA,CAyEA,SAAAyD,KACA,IAAAgI,EACAe,EACAD,EACApK,EAGA,GADAqK,EAAA5P,UAAA1D,SACAiR,gBAAA1G,IACA,OAAA,IAAA+I,EACA,IAAA/I,GAEA,IAAA+I,EACA,IAAA/I,GAAA7G,UAAA,IAEA,IAAA4P,EACA,IAAA/I,GAAA7G,UAAA,GAAAA,UAAA,IAEA,IAAA6G,GAAA7G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAA4P,EACAD,EAAA,IAAAvJ,GAAA,QACA,GAAA,IAAAwJ,EACA,GAAA5E,GAAAhL,UAAA,IACA2P,EAAA,IAAAvJ,GAAA,EAAApG,UAAA,SACA,GAAAqL,GAAArL,UAAA,IAKA,IAHAuF,GADAoK,EAAA3P,UAAA,IACA1D,SAGA0C,GAAA2Q,IAAA3B,GAAA2B,EAAA,KAEA,GADAA,ECxLA,SAAoBA,EAAKxM,GACxB,IAAIoC,EACAN,EACAnJ,EACA8D,EAIJ,IAFA2F,EAAMpC,EAAI7G,OACVsD,EAAI,EACE9D,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,IAAMkS,GADN/I,EAAI9B,EAAKrH,IAER,OAAO,KAER6T,EAAK/P,GAAMuP,GAAOlK,GAClB0K,EAAK/P,EAAE,GAAMwP,GAAOnK,GACpBrF,GAAK,CACL,CACD,OAAO+P,CACR,CDsKAE,CAAA,IAAAzJ,GAAA,EAAAb,GAAAoK,GACA,OAAAA,EAAA,CAEA,IAAA1B,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,6GAAAyE,IAGAoK,EAAA,IAAAvJ,GAAApG,UAAA,GACA,MACA,CACA,GAAAmO,GAAAwB,GACAA,EAAAI,GAAAJ,EAAA,QACA,GAAAvB,GAAAuB,GACAA,EAAAK,GAAAL,EAAA,QACA,IAAA1B,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,6HAAAyE,IAEAoK,EAAA,IAAAvJ,GAAAuJ,EACA,MACA,GAAAnE,GAAAxL,UAAA,IAAA,CAEA,IAAA2K,IADAgF,EAAA3P,UAAA,IACAiQ,WAAA/B,IACA,MAAA,IAAA4B,WAAAhP,EAAA,yFAAAoN,GAAAyB,EAAAM,aAEAN,EAAA,IAAAvJ,GAAAuJ,EACA,KAAA,KAAApF,GAAAvK,UAAA,IAkBA,MAAA,IAAAH,UAAAiB,EAAA,qHAAAd,UAAA,KAhBA,GADA2P,EAAA3P,UAAA,IACA,IAAAqP,GACA,MAAA,IAAAxP,UAAAiB,EAAA,mJAAA6O,IAEA,IAAAzC,GAAAyC,EAAAO,KACA,MAAA,IAAArQ,UAAAiB,EAAA,qHAAA6O,IAGA,IAAAzC,IADAyC,EAAAA,EAAAO,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,qHAAA6O,IAGA,IADAA,EAAAZ,GAAAY,cACArS,MACA,MAAAqS,EAEAA,EAAA,IAAAvJ,GAAAuJ,EAGA,KACA,CAEA,IAAAnE,GADAmE,EAAA3P,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA6O,IAGA,IAAA3E,GADA6D,EAAA7O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA+N,IAEA,IAAAlE,GAAAkE,EAAAX,IACA,MAAA,IAAA4B,WAAAhP,EAAA,uEAAAoN,GAAAW,IAEA,GAAA,IAAAe,EAAA,CAEA,IAAAjF,IADApF,EAAAoK,EAAAM,WAAApB,GACAX,IACA,MAAA,IAAA4B,WAAAhP,EAAA,oGAAAoN,GAAA3I,IAEAoK,EAAA,IAAAvJ,GAAAuJ,EAAAd,EACA,KAAA,CAEA,IAAA7D,GADAzF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAA2I,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAAhP,EAAA,iJAAAyE,EAAA2I,KAEAyB,EAAA,IAAAvJ,GAAAuJ,EAAAd,EAAA,EAAAtJ,EACA,CACA,CAIA,OAHA7C,EAAA6K,KAAA,UAAAoC,GACAjN,EAAA6K,KAAA,UAAAoC,EAAArT,OAAA,GAEAiR,IACA,CErQA,SAASwB,GAAcC,GACtB,IAAIjT,EACAkJ,EACAwJ,EAGJ,IADA1S,EAAM,KAELkJ,EAAI+J,EAAGC,QACAC,MAIP,GAAKhE,GADLuD,EAAIxJ,EAAEtJ,QACyB8S,EAAEnS,QAAU,EAC1CP,EAAI8E,KAAM4N,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAI5O,UAAWiB,EAAQ,kJAAmJ2N,IAFjL1S,EAAI8E,KAAMwM,GAAMoB,GAAKnB,GAAMmB,GAG3B,CAEF,OAAO1S,CACR,CF+PA2G,EAAAmE,GAAA,oBAAAqH,IAeAxL,EAAAmE,GAAA,OAAA,kBAmDA/D,EAAA+D,GAAA,QAAA,SAAAsJ,GACA,IAAAC,EACAR,EACAS,EACAtU,EACA4T,EACAW,EACA/N,EACAgD,EACAgL,EACAtL,EACAnJ,EACA8D,EACA,IAAAsN,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA4P,GAAAlC,MACA,MAAA,IAAA1N,UAAA,6DAGA,IADA+P,EAAA5P,UAAA1D,QACA,EAAA,CAEA,IAAA4Q,GADAmD,EAAArQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAuP,IAEAT,EAAA,IACAQ,EAAApQ,UAAA,GAEA,CACA,GAAAsP,GAAAa,GAAA,CAEA,GADA5K,EAAA4K,EAAA7T,OACA+T,EAAA,CAIA,IAFAV,GADA5T,EAAA,IAAAwR,KAAAhI,IACAiK,QACA5P,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAAkS,GADA/I,EAAAoL,EAAAzS,KAAAwS,EAAAD,EAAA5N,IAAAzG,GAAAA,IAEA6T,EAAA/P,GAAAuP,GAAAlK,GACA0K,EAAA/P,EAAA,GAAAwP,GAAAnK,OACA,MAAAiG,GAAAjG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHA0K,EAAA/P,GAAAqF,EAAA,GACA0K,EAAA/P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAwR,KAAA4C,EACA,CACA,GAAA9E,GAAA8E,GAAA,CACA,GAAAE,EAAA,CAUA,IAPA9K,EAAA4K,EAAA7T,OAEAiG,EADA4N,EAAA5N,KAAA4N,EAAA3N,IACAgO,GAAA,WAEAzM,GAAA,WAGAjI,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA,IAAAkS,GAAAzL,EAAA4N,EAAArU,IAAA,CACAyU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,+FAAA,EAAAyE,IAIA,IADAoK,GADA5T,EAAA,IAAAwR,KAAAhI,EAAA,IACAiK,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAuU,EAAAzS,KAAAwS,EAAA7N,EAAA4N,EAAArU,GAAAA,GAEA,OAAAC,CACA,CAKA,IAFA4T,GADA5T,EAAA,IAAAwR,KAAAhI,IACAiK,QACA5P,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAAkS,GADA/I,EAAAoL,EAAAzS,KAAAwS,EAAA7N,EAAA4N,EAAArU,GAAAA,IAEA6T,EAAA/P,GAAAuP,GAAAlK,GACA0K,EAAA/P,EAAA,GAAAwP,GAAAnK,OACA,MAAAiG,GAAAjG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHA0K,EAAA/P,GAAAqF,EAAA,GACA0K,EAAA/P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAwR,KAAA4C,EACA,CACA,GAAA5F,GAAA4F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,6FAAAqP,IAOA,GAJAG,EADAD,EG/bA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIrU,EACAkJ,EACAwJ,EACA3S,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI+J,EAAGC,QACAC,MAKP,GAFApT,GAAK,EAEAoP,GADLuD,EAAI4B,EAAKzS,KAAMwS,EAASnL,EAAEtJ,MAAOG,KACF2S,EAAEnS,QAAU,EAC1CP,EAAI8E,KAAM4N,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAI5O,UAAWiB,EAAQ,+IAAgJ2N,IAF9K1S,EAAI8E,KAAMsO,GAAOV,GAAKW,GAAOX,GAG7B,CAEF,OAAO1S,CACR,CHwaA0U,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAEAW,aAAAhT,MACA,MAAAgT,EAKA,IADAX,GADA5T,EAAA,IAAAwR,KADAhI,EAAA+K,EAAAhU,OAAA,IAEAkT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAwU,EAAAxU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAqP,GACA,IAoBAzN,EAAAmE,GAAA,MAAA,WACA,IAAA9F,EACAjF,EACA,IAAAoR,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA4P,GAAAlC,MACA,MAAA,IAAA1N,UAAA,6DAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAyR,KAAAxM,EACA,IAuDA+B,EAAA+D,GAAAlK,UAAA,MAAA,SAAAyG,GACA,IAAAkM,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA8K,GAAAvH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAKA,GAHAA,EAAA,IACAA,GAAAmK,KAAAgC,WAEAnM,EAAA,GAAAA,GAAAmK,KAAAgC,SAGA,OAAAG,GAAAnC,KAAAiC,QAAApM,EACA,IAgBAoL,GAAA3H,GAAAlK,UAAA,UAAA,WACA,OAAA4Q,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAA3H,GAAAlK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAS,UACA,IAgBAzB,GAAA3H,GAAAlK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAX,UACA,IAiBA/L,EAAA+D,GAAAlK,UAAA,oBAAAkK,GAAAqH,mBAuCAxL,EAAAmE,GAAAlK,UAAA,cAAA,SAAA+T,EAAAC,GACA,IAAArB,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAQA,OALA,IAAAG,UAAA1D,OACAiR,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,EAAA,EAAA3Q,UAAA,IAEAuN,IACA,IAqCAzK,EAAA+D,GAAAlK,UAAA,WAAA,WACA,IAAAqP,EACA6E,EACAtL,EACAoK,EACAtL,EACAvI,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAiBA,OAfAmM,EAAAuB,KACAoC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAA,CAAAG,EAAA4T,GAAAC,EAAA7T,IACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAA8E,SACA,IAjDAD,CAkDA,IA+BAnO,EAAAmE,GAAAlK,UAAA,SAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,IAAAwJ,EAAA1H,KAAAwS,EAAAV,GAAAC,EAAA7T,GAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA2CA7K,EAAAmE,GAAAlK,UAAA,QAAA,SAAAhB,EAAAgV,EAAAI,GACA,IAAApB,EACApK,EACAnC,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAArS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,0EAAAnF,IAIA,GAFAgU,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAgG,GACA,MAAA,IAAA9Q,UAAAiB,EAAA,qEAAA6P,IAQA,GANAA,EAAA,IACAA,GAAApL,GACA,IACAoL,EAAA,GAGA3Q,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,oEAAAiQ,IAEAA,EAAA,IACAA,GAAAxL,GACA,IACAwL,EAAA,GAGAA,EAAAxL,IACAwL,EAAAxL,EAEA,MACAwL,EAAAxL,CAEA,MACAoL,EAAA,EACAI,EAAAxL,EAIA,IAFAiI,EAAA2B,GAAAxT,GACA8R,EAAA2B,GAAAzT,GACAG,EAAA6U,EAAA7U,EAAAiV,EAAAjV,IAEA6T,EADAvM,EAAA,EAAAtH,GACA0R,EACAmC,EAAAvM,EAAA,GAAAqK,EAEA,OAAAF,IACA,IA2CA7K,EAAAmE,GAAAlK,UAAA,UAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA5T,EACAD,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAqK,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA2S,EAAAiB,GAAAC,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,OACAxR,EAAA8E,KAAA4N,GAGA,OAAA,IAAAlB,KAAA5H,YAAA5J,EACA,IAsCA2G,EAAAmE,GAAAlK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADA2S,EAAAiB,GAAAC,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAkB,CAGA,IAgCA/L,EAAAmE,GAAAlK,UAAA,aAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADA2S,EAAAiB,GAAAC,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IAsCA4G,EAAAmE,GAAAlK,UAAA,YAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADA2S,EAAAiB,GAAAC,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAkB,CAGA,IAgCA/L,EAAAmE,GAAAlK,UAAA,iBAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADA2S,EAAAiB,GAAAC,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IA4BA4G,EAAAmE,GAAAlK,UAAA,WAAA,SAAAqU,EAAAZ,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAAiB,EAAA,oEAAAkQ,IAGA,IADArB,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA2S,EAAAiB,GAAAC,EAAA7T,GACAkV,EAAApT,KAAAwS,EAAA3B,EAAA3S,EAAAyR,KAEA,IAyCAzK,EAAA+D,GAAAlK,UAAA,OAAA,SAAAyG,GACA,IAAAkM,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmL,GAAA5H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAmK,KAAAgC,SAGA,OAAAG,GAAAnC,KAAAiC,QAAApM,EACA,IAmCAV,EAAAmE,GAAAlK,UAAA,YAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAA,EAGA,OAAA,CACA,IAmCAV,EAAAmE,GAAAlK,UAAA,WAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyBAgH,EAAA+D,GAAAlK,UAAA,QAAA,SAAAwU,GACA,IAAApV,EACA4T,EACAyB,EACAtV,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA8U,EAAA,QACA,KAAA3F,GAAA0F,GAGA,MAAA,IAAAtR,UAAAiB,EAAA,kEAAAqQ,IAFAC,EAAAD,CAGA,CAGA,IAFApV,EAAA,GACA4T,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA6O,GAAAC,EAAA7T,GAAAyB,YAEA,OAAAxB,EAAAsV,KAAAD,EACA,IA4BAtO,EAAA+D,GAAAlK,UAAA,QAAA,WACA,IAAAqP,EACA6E,EACAtL,EACAlB,EACAvI,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAgBA,OAdAmM,EAAAuB,KACAhI,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAAG,EACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsF,MACA,IAjDAT,CAkDA,IAsCAnO,EAAAmE,GAAAlK,UAAA,eAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAKA,IAHA/B,EAAA2B,GAAA8B,GACAxD,EAAA2B,GAAA6B,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,GAAA,EAAAA,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAgBA0S,GAAA3H,GAAAlK,UAAA,UAAA,WACA,OAAA4Q,KAAAgC,OACA,IAyCA7M,EAAAmE,GAAAlK,UAAA,OAAA,SAAAqU,EAAAZ,GACA,IAAAmB,EACA5B,EACA5T,EACAD,EACAmJ,EACA,IAAAqK,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAAiB,EAAA,oEAAAkQ,IAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADAxV,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAgC,UACAC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAAkS,GADA/I,EAAA+L,EAAApT,KAAAwS,EAAAV,GAAAC,EAAA7T,GAAAA,EAAAyR,OAEAgE,EAAA,EAAAzV,GAAAqT,GAAAlK,GACAsM,EAAA,EAAAzV,EAAA,GAAAsT,GAAAnK,OACA,KAAAiG,GAAAjG,IAAA,IAAAA,EAAA3I,OAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAsM,EAAA,EAAAzV,GAAAmJ,EAAA,GACAsM,EAAA,EAAAzV,EAAA,GAAAmJ,EAAA,EAGA,CAEA,OAAAlJ,CACA,IAmCA2G,EAAAmE,GAAAlK,UAAA,UAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACA+B,EACAnM,EAEAzJ,EAEA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAAhC,GAAAC,EAAA,GACA7T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IAEA4V,EAAAF,EAAAE,EADAhC,GAAAC,EAAA7T,GACAA,EAAAyR,MAEA,OAAAmE,CACA,IAmCAhP,EAAAmE,GAAAlK,UAAA,eAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACA+B,EACAnM,EAEAzJ,EAEA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAAhC,GAAAC,EAAApK,EAAA,GACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IAEA4V,EAAAF,EAAAE,EADAhC,GAAAC,EAAA7T,GACAA,EAAAyR,MAEA,OAAAmE,CACA,IAmDA5O,EAAA+D,GAAAlK,UAAA,WAAA,WACA,IAAAgT,EACAW,EACA/K,EACAoM,EACA7V,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAKA,IAHA0F,EAAAgI,KAAAgC,QACAI,EAAApC,KAAAiC,QACAmC,EAAAjH,GAAAnF,EAAA,GACAzJ,EAAA,EAAAA,EAAA6V,EAAA7V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAwU,EAAAX,EAAA,EAAA7T,GACA6T,EAAA,EAAA7T,GAAA6T,EAAA,EAAA/P,GACA+P,EAAA,EAAA/P,GAAA0Q,EACAA,EAAAX,EAAA,EAAA7T,EAAA,GACA6T,EAAA,EAAA7T,EAAA,GAAA6T,EAAA,EAAA/P,EAAA,GACA+P,EAAA,EAAA/P,EAAA,GAAA0Q,EAEA,OAAA/C,IACA,IAgEAzK,EAAA+D,GAAAlK,UAAA,OAAA,SAAAhB,GAEA,IAAAiW,EACAxO,EACAuM,EACAW,EACAC,EACAoB,EACA1M,EACAnJ,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAGA,GADA8P,EAAApC,KAAAiC,QACAxP,UAAA1D,OAAA,GAEA,IAAA0O,GADA5H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAA4K,GAAArS,GAAA,CACA,GAAAyH,GAAAmK,KAAAgC,QACA,MAAA,IAAAO,WAAAhP,EAAA,kEAAAsC,IAKA,OAFAuM,EADAvM,GAAA,GACA+L,GAAAxT,QACAgU,EAAAvM,EAAA,GAAAgM,GAAAzT,GAEA,CACA,GAAA2T,GAAA3T,GAAA,CAEA,GAAAyH,GADAuO,EAAAhW,EAAA4T,SACAhC,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAAjW,EAAA6T,QAGA5P,EAAA+P,EAAAd,WAAAzL,EAAA8K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAAjP,GACAgS,EAAA/C,WAAA+C,EAAA3B,WAAArQ,EAEA,CAGA,IADA0Q,EAAA,IAAAlK,GAAAwL,EAAAtV,QACAR,EAAA,EAAAA,EAAA8V,EAAAtV,OAAAR,IACAwU,EAAAxU,GAAA8V,EAAA9V,GAEA8V,EAAAtB,CACA,CAGA,IAFAlN,GAAA,EACAxD,EAAA,EACA9D,EAAA,EAAAA,EAAA6V,EAAA7V,IACA6T,EAAAvM,GAAAwO,EAAAhS,GACA+P,EAAAvM,EAAA,GAAAwO,EAAAhS,EAAA,GACAwD,GAAA,EACAxD,GAAA,CAGA,KAhCA,CAiCA,IAAAyL,GAAA1P,GA2DA,MAAA,IAAAkE,UAAAiB,EAAA,kIAAAnF,IAxDA,IADAgW,EAAAhW,EAAAW,OACAR,EAAA,EAAAA,EAAA6V,EAAA7V,IACA,IAAAkS,GAAArS,EAAAG,IAAA,CACAyU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA0D,GACA,MAAA,IAAA7B,WAAAhP,EAAA,6GAAA6Q,IAEA,GAAAvO,EAAAuO,EAAA,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAAjW,EAGAiE,EAAA+P,EAAAd,WAAAzL,EAAA8K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAAjP,GACAgS,EAAA/C,WAAA+C,EAAA3B,WAAArQ,EAEA,CAGA,IADA0Q,EAAA,IAAAlK,GAAAuL,GACA7V,EAAA,EAAAA,EAAA6V,EAAA7V,IACAwU,EAAAxU,GAAA8V,EAAA9V,GAEA8V,EAAAtB,CACA,CAIA,IAHAlN,GAAA,EACAuO,GAAA,EACA/R,EAAA,EACA9D,EAAA,EAAAA,EAAA6V,EAAA7V,IACA6T,EAAAvM,GAAAwO,EAAAhS,GACA+P,EAAAvM,EAAA,GAAAwO,EAAAhS,EAAA,GACAwD,GAAA,EACAxD,GAAA,EAEA,MACA,CAEA,GAAAwD,EAAAuO,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAGA,IADA1M,GAAA,EACAtH,EAAA,EAAAA,EAAA6V,EAAA7V,IACAmJ,EAAAtJ,EAAAG,GACA6T,EAAAvM,GAAA+L,GAAAlK,GACA0K,EAAAvM,EAAA,GAAAgM,GAAAnK,GACA7B,GAAA,CAxDA,CA+DA,IA2EAV,EAAAmE,GAAAlK,UAAA,SAAA,SAAAgU,EAAAI,GACA,IAAAc,EACAN,EACAxV,EACAqH,EACAuM,EACApK,EACAzJ,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACAqU,EAAA,EACAI,EAAAxL,MACA,CACA,IAAAoF,GAAAgG,GACA,MAAA,IAAA9Q,UAAAiB,EAAA,oEAAA6P,IAQA,GANAA,EAAA,IACAA,GAAApL,GACA,IACAoL,EAAA,GAGA,IAAA3Q,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAQA,IANAsM,EADAlB,EAAAI,EACAA,EAAAJ,EAEA,EAGAY,GADAxV,EAAA,IAAAwR,KAAA5H,YAAAkM,IACArC,QACA1T,EAAA,EAAAA,EAAA+V,EAAA/V,IACAsH,EAAA,GAAAtH,EAAA6U,GACAY,EAAA,EAAAzV,GAAA6T,EAAAvM,GACAmO,EAAA,EAAAzV,EAAA,GAAA6T,EAAAvM,EAAA,GAEA,OAAArH,CACA,IA+BA2G,EAAAmE,GAAAlK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,GAAAwJ,EAAA1H,KAAAwS,EAAAV,GAAAC,EAAA7T,GAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA6EAzK,EAAA+D,GAAAlK,UAAA,QAAA,SAAAmV,GACA,IAAAxB,EACAX,EACApK,EACAzJ,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAKA,IAHAnC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAe,EAAA,GACAxU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAwU,EAAAzP,KAAA6O,GAAAC,EAAA7T,IAGA,IADAwU,EAAAyB,KAAAD,GACAhW,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAEA6T,EADA/P,EAAA,EAAA9D,GACAqT,GAAAmB,EAAAxU,IACA6T,EAAA/P,EAAA,GAAAwP,GAAAkB,EAAAxU,IAEA,OAAAyR,IACA,IA2EA7K,EAAAmE,GAAAlK,UAAA,YAAA,SAAAqV,EAAAjB,GACA,IAAApC,EACAgB,EACApK,EACA,IAAA+J,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACA0V,EAAA,EACAjB,EAAAxL,MACA,CACA,IAAAoF,GAAAqH,GACA,MAAA,IAAAnS,UAAAiB,EAAA,oEAAAkR,IAQA,GANAA,EAAA,IACAA,GAAAzM,GACA,IACAyM,EAAA,GAGA,IAAAhS,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAWA,OAVAyM,GAAAzM,GACAA,EAAA,EACAoJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACAxL,EAAA,EACAoJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEA3I,EAAAwL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAA5H,YAAAgK,EAAAf,OAAAD,EAAApJ,EAAA,EAAA,EAAAA,EACA,IAwBA7C,EAAAmE,GAAAlK,UAAA,kBAAA,SAAAsV,EAAAC,GACA,IAAAC,EACAC,EACArW,EACA4T,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA8V,EAAA,OACA,KAAA3G,GAAAwG,KAAArG,GAAAqG,GAGA,MAAA,IAAApS,UAAAiB,EAAA,yFAAAmR,IAFAG,EAAAH,CAGA,CACA,GAAAjS,UAAA1D,OAAA,EACA6V,EAAA,CAAA,MACA,KAAA5H,GAAA2H,GAGA,MAAA,IAAArS,UAAAiB,EAAA,qEAAAoR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA6O,GAAAC,EAAA7T,GAAAuW,eAAAD,EAAAD,IAEA,OAAApW,EAAAsV,KAAA,IACA,IAmDAvO,EAAA+D,GAAAlK,UAAA,cAAA,WACA,IAAA4U,EACAxV,EACAwJ,EACAoK,EACA7T,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAMA,IAJA0F,EAAAgI,KAAAgC,QACAxT,EAAA,IAAAwR,KAAA5H,YAAAJ,GACAoK,EAAApC,KAAAiC,QACA+B,EAAAxV,EAAAyT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAyV,EAAA,EAAAzV,GAAA6T,EAAA,EAAA/P,GACA2R,EAAA,EAAAzV,EAAA,GAAA6T,EAAA,EAAA/P,EAAA,GAEA,OAAA7D,CACA,IA6EA+G,EAAA+D,GAAAlK,UAAA,YAAA,SAAAmV,GACA,IAAAxB,EACAX,EACApK,EACAzJ,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAKA,IAHAnC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAe,EAAA,GACAxU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAwU,EAAAzP,KAAA6O,GAAAC,EAAA7T,IAGA,OADAwU,EAAAyB,KAAAD,GACA,IAAAjL,GAAAyJ,EACA,IAoBAxN,EAAA+D,GAAAlK,UAAA,YAAA,WACA,IAAAZ,EACA4T,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,IAFA9D,EAAA,GACA4T,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA6O,GAAAC,EAAA7T,GAAAyB,YAEA,OAAAxB,EAAAsV,KAAA,IACA,IA0CAvO,EAAA+D,GAAAlK,UAAA,UAAA,WACA,IAAAkU,EACA7E,EACAzG,EACAlB,EACAsL,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAiBA,OAfAmM,EAAAuB,KACAoC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAA+T,GAAAC,EAAA7T,GACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsG,QACA,IAjDAzB,CAkDA,IAuCAnO,EAAAmE,GAAAlK,UAAA,QAAA,SAAA4V,EAAA5W,GACA,IAAAgU,EACA5T,EACAwJ,EACA,IAAA+J,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA8K,GAAA4H,GACA,MAAA,IAAA1S,UAAAiB,EAAA,oEAAAyR,IAMA,GAJAhN,EAAAgI,KAAAgC,QACAgD,EAAA,IACAA,GAAAhN,GAEAgN,EAAA,GAAAA,GAAAhN,EACA,MAAA,IAAAuK,WAAAhP,EAAA,kEAAAyR,IAEA,IAAAvE,GAAArS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,2EAAAnF,IAMA,OAHAgU,GADA5T,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAiC,UACAA,SACA,EAAA+C,GAAApD,GAAAxT,GACAgU,EAAA,EAAA4C,EAAA,GAAAnD,GAAAzT,GACAI,CACA,II15FA,IAAAmS,GAAA,EAAA7H,GAAA6H,kBACAmB,GAAAhB,KAYA,SAAAiB,GAAA3T,GACA,OACAA,aAAAmL,IAEA,iBAAAnL,GACA,OAAAA,IAEA,mBAAAA,EAAAgK,YAAAK,MACA,oBAAArK,EAAAgK,YAAAK,OAEA,iBAAArK,EAAA4T,SAGA,iBAAA5T,EAAA6T,OAGA,CASA,SAAAC,GAAA9T,GACA,OACAA,IAAAmL,IAGA,mBAAAnL,EAAAqK,IAEA,CAUA,SAAAwM,GAAA7C,EAAAvM,GAEA,OAAA,IAAAgK,GAAAuC,EADAvM,GAAA,GACAuM,EAAAvM,EAAA,GACA,CAyEA,SAAA0D,KACA,IAAA+H,EACAe,EACAD,EACApK,EAGA,GADAqK,EAAA5P,UAAA1D,SACAiR,gBAAAzG,IACA,OAAA,IAAA8I,EACA,IAAA9I,GAEA,IAAA8I,EACA,IAAA9I,GAAA9G,UAAA,IAEA,IAAA4P,EACA,IAAA9I,GAAA9G,UAAA,GAAAA,UAAA,IAEA,IAAA8G,GAAA9G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAA4P,EACAD,EAAA,IAAAtJ,GAAA,QACA,GAAA,IAAAuJ,EACA,GAAA5E,GAAAhL,UAAA,IACA2P,EAAA,IAAAtJ,GAAA,EAAArG,UAAA,SACA,GAAAqL,GAAArL,UAAA,IAKA,IAHAuF,GADAoK,EAAA3P,UAAA,IACA1D,SAGA0C,GAAA2Q,IAAA3B,GAAA2B,EAAA,KAEA,GADAA,ECxLA,SAAoBA,EAAKxM,GACxB,IAAIoC,EACAN,EACAnJ,EACA8D,EAIJ,IAFA2F,EAAMpC,EAAI7G,OACVsD,EAAI,EACE9D,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,IAAMkS,GADN/I,EAAI9B,EAAKrH,IAER,OAAO,KAER6T,EAAK/P,GAAMyN,GAAMpI,GACjB0K,EAAK/P,EAAE,GAAM0N,GAAMrI,GACnBrF,GAAK,CACL,CACD,OAAO+P,CACR,CDsKAE,CAAA,IAAAxJ,GAAA,EAAAd,GAAAoK,GACA,OAAAA,EAAA,CAEA,IAAA1B,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,6GAAAyE,IAGAoK,EAAA,IAAAtJ,GAAArG,UAAA,GACA,MACA,CACA,GAAAmO,GAAAwB,GACAA,EAAAI,GAAAJ,EAAA,QACA,GAAAvB,GAAAuB,GACAA,EAAAK,GAAAL,EAAA,QACA,IAAA1B,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,6HAAAyE,IAEAoK,EAAA,IAAAtJ,GAAAsJ,EACA,MACA,GAAAnE,GAAAxL,UAAA,IAAA,CAEA,IAAA2K,IADAgF,EAAA3P,UAAA,IACAiQ,WAAA/B,IACA,MAAA,IAAA4B,WAAAhP,EAAA,yFAAAoN,GAAAyB,EAAAM,aAEAN,EAAA,IAAAtJ,GAAAsJ,EACA,KAAA,KAAApF,GAAAvK,UAAA,IAkBA,MAAA,IAAAH,UAAAiB,EAAA,qHAAAd,UAAA,KAhBA,GADA2P,EAAA3P,UAAA,IACA,IAAAqP,GACA,MAAA,IAAAxP,UAAAiB,EAAA,mJAAA6O,IAEA,IAAAzC,GAAAyC,EAAAO,KACA,MAAA,IAAArQ,UAAAiB,EAAA,qHAAA6O,IAGA,IAAAzC,IADAyC,EAAAA,EAAAO,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,qHAAA6O,IAGA,IADAA,EAAAZ,GAAAY,cACArS,MACA,MAAAqS,EAEAA,EAAA,IAAAtJ,GAAAsJ,EAGA,KACA,CAEA,IAAAnE,GADAmE,EAAA3P,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA6O,IAGA,IAAA3E,GADA6D,EAAA7O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA+N,IAEA,IAAAlE,GAAAkE,EAAAX,IACA,MAAA,IAAA4B,WAAAhP,EAAA,uEAAAoN,GAAAW,IAEA,GAAA,IAAAe,EAAA,CAEA,IAAAjF,IADApF,EAAAoK,EAAAM,WAAApB,GACAX,IACA,MAAA,IAAA4B,WAAAhP,EAAA,oGAAAoN,GAAA3I,IAEAoK,EAAA,IAAAtJ,GAAAsJ,EAAAd,EACA,KAAA,CAEA,IAAA7D,GADAzF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAA2I,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAAhP,EAAA,iJAAAyE,EAAA2I,KAEAyB,EAAA,IAAAtJ,GAAAsJ,EAAAd,EAAA,EAAAtJ,EACA,CACA,CAIA,OAHA7C,EAAA6K,KAAA,UAAAoC,GACAjN,EAAA6K,KAAA,UAAAoC,EAAArT,OAAA,GAEAiR,IACA,CEzQA,SAASwB,GAAcC,GACtB,IAAIjT,EACAkJ,EAGJ,IADAlJ,EAAM,KAELkJ,EAAI+J,EAAGC,QACAC,MAGPnT,EAAI8E,KAAMkL,GAAS9G,EAAEtJ,QAEtB,OAAOI,CACR,CF2QA2G,EAAAoE,GAAA,oBAAAoH,IAeAxL,EAAAoE,GAAA,OAAA,mBAmDAhE,EAAAgE,GAAA,QAAA,SAAAqJ,GACA,IAAAC,EACAR,EACAS,EACAtU,EACA4T,EACAW,EACA/N,EACAgD,EACAgL,EACAtL,EACAnJ,EACA8D,EACA,IAAAsN,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA4P,GAAAlC,MACA,MAAA,IAAA1N,UAAA,6DAGA,IADA+P,EAAA5P,UAAA1D,QACA,EAAA,CAEA,IAAA4Q,GADAmD,EAAArQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAuP,IAEAT,EAAA,IACAQ,EAAApQ,UAAA,GAEA,CACA,GAAAsP,GAAAa,GAAA,CAEA,GADA5K,EAAA4K,EAAA7T,OACA+T,EAAA,CAIA,IAFAV,GADA5T,EAAA,IAAAwR,KAAAhI,IACAiK,QACA5P,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAAkS,GADA/I,EAAAoL,EAAAzS,KAAAwS,EAAAD,EAAA5N,IAAAzG,GAAAA,IAEA6T,EAAA/P,GAAAyN,GAAApI,GACA0K,EAAA/P,EAAA,GAAA0N,GAAArI,OACA,MAAAiG,GAAAjG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHA0K,EAAA/P,GAAAqF,EAAA,GACA0K,EAAA/P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAwR,KAAA4C,EACA,CACA,GAAA9E,GAAA8E,GAAA,CACA,GAAAE,EAAA,CAUA,IAPA9K,EAAA4K,EAAA7T,OAEAiG,EADA4N,EAAA5N,KAAA4N,EAAA3N,IACAgO,GAAA,WAEAzM,GAAA,WAGAjI,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA,IAAAkS,GAAAzL,EAAA4N,EAAArU,IAAA,CACAyU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA1I,GACA,MAAA,IAAAuK,WAAAhP,EAAA,gGAAAyE,IAIA,IADAoK,GADA5T,EAAA,IAAAwR,KAAAhI,EAAA,IACAiK,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAuU,EAAAzS,KAAAwS,EAAA7N,EAAA4N,EAAArU,GAAAA,GAEA,OAAAC,CACA,CAKA,IAFA4T,GADA5T,EAAA,IAAAwR,KAAAhI,IACAiK,QACA5P,EAAA,EACA9D,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAAA,CAEA,GAAAkS,GADA/I,EAAAoL,EAAAzS,KAAAwS,EAAA7N,EAAA4N,EAAArU,GAAAA,IAEA6T,EAAA/P,GAAAyN,GAAApI,GACA0K,EAAA/P,EAAA,GAAA0N,GAAArI,OACA,MAAAiG,GAAAjG,IAAAA,EAAA3I,QAAA,GAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHA0K,EAAA/P,GAAAqF,EAAA,GACA0K,EAAA/P,EAAA,GAAAqF,EAAA,EAGA,CACArF,GAAA,CACA,CACA,OAAA7D,CACA,CACA,OAAA,IAAAwR,KAAA4C,EACA,CACA,GAAA5F,GAAA4F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,6FAAAqP,IAOA,GAJAG,EADAD,EG/bA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIrU,EACAkJ,EACAwJ,EACA3S,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI+J,EAAGC,QACAC,MAKP,GAFApT,GAAK,EAEAoP,GADLuD,EAAI4B,EAAKzS,KAAMwS,EAASnL,EAAEtJ,MAAOG,KACF2S,EAAEnS,QAAU,EAC1CP,EAAI8E,KAAM4N,EAAG,GAAKA,EAAG,QACf,KAAKT,GAAeS,GAG1B,OAAO,IAAI5O,UAAWiB,EAAQ,+IAAgJ2N,IAF9K1S,EAAI8E,KAAMwM,GAAMoB,GAAKnB,GAAMmB,GAG3B,CAEF,OAAO1S,CACR,CHwaA0U,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAEAW,aAAAhT,MACA,MAAAgT,EAKA,IADAX,GADA5T,EAAA,IAAAwR,KADAhI,EAAA+K,EAAAhU,OAAA,IAEAkT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAwU,EAAAxU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAqP,GACA,IAoBAzN,EAAAoE,GAAA,MAAA,WACA,IAAA/F,EACAjF,EACA,IAAAoR,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA4P,GAAAlC,MACA,MAAA,IAAA1N,UAAA,6DAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAyR,KAAAxM,EACA,IAwDA+B,EAAAgE,GAAAnK,UAAA,MAAA,SAAAyG,GACA,IAAAkM,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA8K,GAAAvH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAKA,GAHAA,EAAA,IACAA,GAAAmK,KAAAgC,WAEAnM,EAAA,GAAAA,GAAAmK,KAAAgC,SAGA,OAAAiD,GAAAjF,KAAAiC,QAAApM,EACA,IAgBAoL,GAAA1H,GAAAnK,UAAA,UAAA,WACA,OAAA4Q,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAA1H,GAAAnK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAS,UACA,IAgBAzB,GAAA1H,GAAAnK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAX,UACA,IAiBA/L,EAAAgE,GAAAnK,UAAA,oBAAAmK,GAAAoH,mBAuCAxL,EAAAoE,GAAAnK,UAAA,cAAA,SAAA+T,EAAAC,GACA,IAAArB,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAQA,OALA,IAAAG,UAAA1D,OACAiR,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAA,EAAAF,EAAA,EAAAC,EAAA,EAAA3Q,UAAA,IAEAuN,IACA,IAqCAzK,EAAAgE,GAAAnK,UAAA,WAAA,WACA,IAAAiS,EACA5C,EACA6E,EACAtL,EACAlB,EACAvI,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAkBA,OAhBAmM,EAAAuB,KACAqB,EAAArB,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EACA8D,GAAA,EAIA8C,EADAmO,EAAA,CAAA,EACA,QAcA,WACA,IAAApC,EAEA,GADA3S,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAKA,OADAT,EAAA,IAAArB,GAAAwB,EADAhP,GAAA,GACAgP,EAAAhP,EAAA,IACA,CACAjE,MAAA,CAAAG,EAAA2S,GACAS,MAAA,EAEA,IA3BAxM,EAAAmO,EAAA,UAoCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA7CAgB,IACAxN,EAAAmO,EAAAX,IAoDA,WACA,OAAAlE,EAAA8E,SACA,IApDAD,CAqDA,IA+BAnO,EAAAoE,GAAAnK,UAAA,SAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,IAAAwJ,EAAA1H,KAAAwS,EAAAoC,GAAA7C,EAAA7T,GAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA2CA7K,EAAAoE,GAAAnK,UAAA,QAAA,SAAAhB,EAAAgV,EAAAI,GACA,IAAApB,EACApK,EACAnC,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAArS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,0EAAAnF,IAIA,GAFAgU,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAgG,GACA,MAAA,IAAA9Q,UAAAiB,EAAA,qEAAA6P,IAQA,GANAA,EAAA,IACAA,GAAApL,GACA,IACAoL,EAAA,GAGA3Q,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,oEAAAiQ,IAEAA,EAAA,IACAA,GAAAxL,GACA,IACAwL,EAAA,GAGAA,EAAAxL,IACAwL,EAAAxL,EAEA,MACAwL,EAAAxL,CAEA,MACAoL,EAAA,EACAI,EAAAxL,EAIA,IAFAiI,EAAAH,GAAA1R,GACA8R,EAAAH,GAAA3R,GACAG,EAAA6U,EAAA7U,EAAAiV,EAAAjV,IAEA6T,EADAvM,EAAA,EAAAtH,GACA0R,EACAmC,EAAAvM,EAAA,GAAAqK,EAEA,OAAAF,IACA,IA2CA7K,EAAAoE,GAAAnK,UAAA,UAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA5T,EACAD,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAqK,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA2S,EAAA+D,GAAA7C,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,OACAxR,EAAA8E,KAAA4N,GAGA,OAAA,IAAAlB,KAAA5H,YAAA5J,EACA,IAqCA2G,EAAAoE,GAAAnK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADA2S,EAAA+D,GAAA7C,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAkB,CAGA,IA+BA/L,EAAAoE,GAAAnK,UAAA,aAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADA2S,EAAA+D,GAAA7C,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IAqCA4G,EAAAoE,GAAAnK,UAAA,YAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADA2S,EAAA+D,GAAA7C,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAkB,CAGA,IA+BA/L,EAAAoE,GAAAnK,UAAA,iBAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADA2S,EAAA+D,GAAA7C,EAAA7T,GACAwJ,EAAA1H,KAAAwS,EAAA3B,EAAA3S,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IA4BA4G,EAAAoE,GAAAnK,UAAA,WAAA,SAAAqU,EAAAZ,GACA,IAAAT,EACA7T,EACA2S,EACA,IAAAa,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAAiB,EAAA,oEAAAkQ,IAGA,IADArB,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA2S,EAAA+D,GAAA7C,EAAA7T,GACAkV,EAAApT,KAAAwS,EAAA3B,EAAA3S,EAAAyR,KAEA,IAyCAzK,EAAAgE,GAAAnK,UAAA,OAAA,SAAAyG,GACA,IAAAkM,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmL,GAAA5H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAmK,KAAAgC,SAGA,OAAAiD,GAAAjF,KAAAiC,QAAApM,EACA,IAgBAoL,GAAA1H,GAAAnK,UAAA,UAAA,WACA,OAAA4Q,KAAAgC,OACA,IAmCA7M,EAAAoE,GAAAnK,UAAA,YAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAA,EAGA,OAAA,CACA,IAmCAV,EAAAoE,GAAAnK,UAAA,WAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAKA,IAHA1D,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyBAgH,EAAAgE,GAAAnK,UAAA,QAAA,SAAAwU,GACA,IAAApV,EACA4T,EACAyB,EACAtV,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA8U,EAAA,QACA,KAAA3F,GAAA0F,GAGA,MAAA,IAAAtR,UAAAiB,EAAA,kEAAAqQ,IAFAC,EAAAD,CAGA,CAGA,IAFApV,EAAA,GACA4T,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA2R,GAAA7C,EAAA7T,GAAAyB,YAEA,OAAAxB,EAAAsV,KAAAD,EACA,IA4BAtO,EAAAgE,GAAAnK,UAAA,QAAA,WACA,IAAAqP,EACA6E,EACAtL,EACAlB,EACAvI,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAgBA,OAdAmM,EAAAuB,KACAhI,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAAG,EACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsF,MACA,IAjDAT,CAkDA,IAsCAnO,EAAAoE,GAAAnK,UAAA,eAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACAvM,EACAoK,EACAC,EACA3R,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAmO,GAAAiD,GACA,MAAA,IAAApR,UAAAiB,EAAA,0EAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAKA,IAHA/B,EAAAH,GAAA4D,GACAxD,EAAAH,GAAA2D,GACAtB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,GAAA,EAAAA,IAEA,GAAA0R,IAAAmC,EADAvM,EAAA,EAAAtH,IACA2R,IAAAkC,EAAAvM,EAAA,GACA,OAAAtH,EAGA,OAAA,CACA,IAyCA4G,EAAAoE,GAAAnK,UAAA,OAAA,SAAAqU,EAAAZ,GACA,IAAAmB,EACA5B,EACA5T,EACAD,EACAmJ,EACA,IAAAqK,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAAiB,EAAA,oEAAAkQ,IAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADAxV,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAgC,UACAC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GAAAkS,GADA/I,EAAA+L,EAAApT,KAAAwS,EAAAoC,GAAA7C,EAAA7T,GAAAA,EAAAyR,OAEAgE,EAAA,EAAAzV,GAAAuR,GAAApI,GACAsM,EAAA,EAAAzV,EAAA,GAAAwR,GAAArI,OACA,KAAAiG,GAAAjG,IAAA,IAAAA,EAAA3I,OAIA,MAAA,IAAAuD,UAAAiB,EAAA,+IAAAmE,IAHAsM,EAAA,EAAAzV,GAAAmJ,EAAA,GACAsM,EAAA,EAAAzV,EAAA,GAAAmJ,EAAA,EAGA,CAEA,OAAAlJ,CACA,IAmCA2G,EAAAoE,GAAAnK,UAAA,UAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACA+B,EACAnM,EAEAzJ,EAEA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAAc,GAAA7C,EAAA,GACA7T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IAEA4V,EAAAF,EAAAE,EADAc,GAAA7C,EAAA7T,GACAA,EAAAyR,MAEA,OAAAmE,CACA,IAmCAhP,EAAAoE,GAAAnK,UAAA,eAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACA+B,EACAnM,EAEAzJ,EAEA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAAc,GAAA7C,EAAApK,EAAA,GACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IAEA4V,EAAAF,EAAAE,EADAc,GAAA7C,EAAA7T,GACAA,EAAAyR,MAEA,OAAAmE,CACA,IAmDA5O,EAAAgE,GAAAnK,UAAA,WAAA,WACA,IAAAgT,EACAW,EACA/K,EACAoM,EACA7V,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAKA,IAHA0F,EAAAgI,KAAAgC,QACAI,EAAApC,KAAAiC,QACAmC,EAAAjH,GAAAnF,EAAA,GACAzJ,EAAA,EAAAA,EAAA6V,EAAA7V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAwU,EAAAX,EAAA,EAAA7T,GACA6T,EAAA,EAAA7T,GAAA6T,EAAA,EAAA/P,GACA+P,EAAA,EAAA/P,GAAA0Q,EACAA,EAAAX,EAAA,EAAA7T,EAAA,GACA6T,EAAA,EAAA7T,EAAA,GAAA6T,EAAA,EAAA/P,EAAA,GACA+P,EAAA,EAAA/P,EAAA,GAAA0Q,EAEA,OAAA/C,IACA,IAgEAzK,EAAAgE,GAAAnK,UAAA,OAAA,SAAAhB,GAEA,IAAAiW,EACAxO,EACAuM,EACAW,EACAC,EACAoB,EACA1M,EACAnJ,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAGA,GADA8P,EAAApC,KAAAiC,QACAxP,UAAA1D,OAAA,GAEA,IAAA0O,GADA5H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAA4K,GAAArS,GAAA,CACA,GAAAyH,GAAAmK,KAAAgC,QACA,MAAA,IAAAO,WAAAhP,EAAA,kEAAAsC,IAKA,OAFAuM,EADAvM,GAAA,GACAiK,GAAA1R,QACAgU,EAAAvM,EAAA,GAAAkK,GAAA3R,GAEA,CACA,GAAA2T,GAAA3T,GAAA,CAEA,GAAAyH,GADAuO,EAAAhW,EAAA4T,SACAhC,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAAjW,EAAA6T,QAGA5P,EAAA+P,EAAAd,WAAAzL,EAAA8K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAAjP,GACAgS,EAAA/C,WAAA+C,EAAA3B,WAAArQ,EAEA,CAGA,IADA0Q,EAAA,IAAAjK,GAAAuL,EAAAtV,QACAR,EAAA,EAAAA,EAAA8V,EAAAtV,OAAAR,IACAwU,EAAAxU,GAAA8V,EAAA9V,GAEA8V,EAAAtB,CACA,CAGA,IAFAlN,GAAA,EACAxD,EAAA,EACA9D,EAAA,EAAAA,EAAA6V,EAAA7V,IACA6T,EAAAvM,GAAAwO,EAAAhS,GACA+P,EAAAvM,EAAA,GAAAwO,EAAAhS,EAAA,GACAwD,GAAA,EACAxD,GAAA,CAGA,KAhCA,CAiCA,IAAAyL,GAAA1P,GA2DA,MAAA,IAAAkE,UAAAiB,EAAA,kIAAAnF,IAxDA,IADAgW,EAAAhW,EAAAW,OACAR,EAAA,EAAAA,EAAA6V,EAAA7V,IACA,IAAAkS,GAAArS,EAAAG,IAAA,CACAyU,GAAA,EACA,KACA,CAGA,GAAAA,EAAA,CACA,IAAAtC,GAAA0D,GACA,MAAA,IAAA7B,WAAAhP,EAAA,6GAAA6Q,IAEA,GAAAvO,EAAAuO,EAAA,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAMA,GAJA8B,EAAAjW,EAGAiE,EAAA+P,EAAAd,WAAAzL,EAAA8K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAAjP,GACAgS,EAAA/C,WAAA+C,EAAA3B,WAAArQ,EAEA,CAGA,IADA0Q,EAAA,IAAAjK,GAAAsL,GACA7V,EAAA,EAAAA,EAAA6V,EAAA7V,IACAwU,EAAAxU,GAAA8V,EAAA9V,GAEA8V,EAAAtB,CACA,CAIA,IAHAlN,GAAA,EACAuO,GAAA,EACA/R,EAAA,EACA9D,EAAA,EAAAA,EAAA6V,EAAA7V,IACA6T,EAAAvM,GAAAwO,EAAAhS,GACA+P,EAAAvM,EAAA,GAAAwO,EAAAhS,EAAA,GACAwD,GAAA,EACAxD,GAAA,EAEA,MACA,CAEA,GAAAwD,EAAAuO,EAAApE,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FAGA,IADA1M,GAAA,EACAtH,EAAA,EAAAA,EAAA6V,EAAA7V,IACAmJ,EAAAtJ,EAAAG,GACA6T,EAAAvM,GAAAiK,GAAApI,GACA0K,EAAAvM,EAAA,GAAAkK,GAAArI,GACA7B,GAAA,CAxDA,CA+DA,IA2EAV,EAAAoE,GAAAnK,UAAA,SAAA,SAAAgU,EAAAI,GACA,IAAAc,EACAN,EACAxV,EACAqH,EACAuM,EACApK,EACAzJ,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACAqU,EAAA,EACAI,EAAAxL,MACA,CACA,IAAAoF,GAAAgG,GACA,MAAA,IAAA9Q,UAAAiB,EAAA,oEAAA6P,IAQA,GANAA,EAAA,IACAA,GAAApL,GACA,IACAoL,EAAA,GAGA,IAAA3Q,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAQA,IANAsM,EADAlB,EAAAI,EACAA,EAAAJ,EAEA,EAGAY,GADAxV,EAAA,IAAAwR,KAAA5H,YAAAkM,IACArC,QACA1T,EAAA,EAAAA,EAAA+V,EAAA/V,IACAsH,EAAA,GAAAtH,EAAA6U,GACAY,EAAA,EAAAzV,GAAA6T,EAAAvM,GACAmO,EAAA,EAAAzV,EAAA,GAAA6T,EAAAvM,EAAA,GAEA,OAAArH,CACA,IA+BA2G,EAAAoE,GAAAnK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,GAAAwJ,EAAA1H,KAAAwS,EAAAoC,GAAA7C,EAAA7T,GAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA6EAzK,EAAAgE,GAAAnK,UAAA,QAAA,SAAAmV,GACA,IAAAxB,EACAX,EACApK,EACAzJ,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAKA,IAHAnC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAe,EAAA,GACAxU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAwU,EAAAzP,KAAA2R,GAAA7C,EAAA7T,IAGA,IADAwU,EAAAyB,KAAAD,GACAhW,EAAA,EAAAA,EAAAyJ,EAAAzJ,IAEA6T,EADA/P,EAAA,EAAA9D,GACAuR,GAAAiD,EAAAxU,IACA6T,EAAA/P,EAAA,GAAA0N,GAAAgD,EAAAxU,IAEA,OAAAyR,IACA,IA2EA7K,EAAAoE,GAAAnK,UAAA,YAAA,SAAAqV,EAAAjB,GACA,IAAApC,EACAgB,EACApK,EACA,IAAA+J,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACA0V,EAAA,EACAjB,EAAAxL,MACA,CACA,IAAAoF,GAAAqH,GACA,MAAA,IAAAnS,UAAAiB,EAAA,oEAAAkR,IAQA,GANAA,EAAA,IACAA,GAAAzM,GACA,IACAyM,EAAA,GAGA,IAAAhS,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAWA,OAVAyM,GAAAzM,GACAA,EAAA,EACAoJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACAxL,EAAA,EACAoJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEA3I,EAAAwL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAA5H,YAAAgK,EAAAf,OAAAD,EAAApJ,EAAA,EAAA,EAAAA,EACA,IAwBA7C,EAAAoE,GAAAnK,UAAA,kBAAA,SAAAsV,EAAAC,GACA,IAAAC,EACAC,EACArW,EACA4T,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,GAAA,IAAAG,UAAA1D,OACA8V,EAAA,OACA,KAAA3G,GAAAwG,KAAArG,GAAAqG,GAGA,MAAA,IAAApS,UAAAiB,EAAA,yFAAAmR,IAFAG,EAAAH,CAGA,CACA,GAAAjS,UAAA1D,OAAA,EACA6V,EAAA,CAAA,MACA,KAAA5H,GAAA2H,GAGA,MAAA,IAAArS,UAAAiB,EAAA,qEAAAoR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA2R,GAAA7C,EAAA7T,GAAAuW,eAAAD,EAAAD,IAEA,OAAApW,EAAAsV,KAAA,IACA,IAmDAvO,EAAAgE,GAAAnK,UAAA,cAAA,WACA,IAAA4U,EACAxV,EACAwJ,EACAoK,EACA7T,EACA8D,EACA,IAAA0P,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAMA,IAJA0F,EAAAgI,KAAAgC,QACAxT,EAAA,IAAAwR,KAAA5H,YAAAJ,GACAoK,EAAApC,KAAAiC,QACA+B,EAAAxV,EAAAyT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAyV,EAAA,EAAAzV,GAAA6T,EAAA,EAAA/P,GACA2R,EAAA,EAAAzV,EAAA,GAAA6T,EAAA,EAAA/P,EAAA,GAEA,OAAA7D,CACA,IA6EA+G,EAAAgE,GAAAnK,UAAA,YAAA,SAAAmV,GACA,IAAAxB,EACAX,EACApK,EACAzJ,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAAqN,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAKA,IAHAnC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAe,EAAA,GACAxU,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAwU,EAAAzP,KAAA2R,GAAA7C,EAAA7T,IAGA,OADAwU,EAAAyB,KAAAD,GACA,IAAAhL,GAAAwJ,EACA,IAoBAxN,EAAAgE,GAAAnK,UAAA,YAAA,WACA,IAAAZ,EACA4T,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAIA,IAFA9D,EAAA,GACA4T,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAA2R,GAAA7C,EAAA7T,GAAAyB,YAEA,OAAAxB,EAAAsV,KAAA,IACA,IA0CAvO,EAAAgE,GAAAnK,UAAA,UAAA,WACA,IAAAkU,EACA7E,EACAzG,EACAlB,EACAsL,EACA7T,EACA,IAAAwT,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAiBA,OAfAmM,EAAAuB,KACAoC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAA6W,GAAA7C,EAAA7T,GACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsG,QACA,IAjDAzB,CAkDA,IAuCAnO,EAAAoE,GAAAnK,UAAA,QAAA,SAAA4V,EAAA5W,GACA,IAAAgU,EACA5T,EACAwJ,EACA,IAAA+J,GAAA/B,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA8K,GAAA4H,GACA,MAAA,IAAA1S,UAAAiB,EAAA,oEAAAyR,IAMA,GAJAhN,EAAAgI,KAAAgC,QACAgD,EAAA,IACAA,GAAAhN,GAEAgN,EAAA,GAAAA,GAAAhN,EACA,MAAA,IAAAuK,WAAAhP,EAAA,kEAAAyR,IAEA,IAAAvE,GAAArS,GACA,MAAA,IAAAkE,UAAAiB,EAAA,2EAAAnF,IAMA,OAHAgU,GADA5T,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAiC,UACAA,SACA,EAAA+C,GAAAlF,GAAA1R,GACAgU,EAAA,EAAA4C,EAAA,GAAAjF,GAAA3R,GACAI,CACA,IIr6FA,IAAAmS,GAAAvH,GAAAuH,kBACAmB,GAAAhB,KAYA,SAAAoE,GAAA9W,GACA,MACA,iBAAAA,GACA,OAAAA,GACA,iBAAAA,EAAAgK,YAAAK,MACArK,EAAAuS,oBAAAA,EAEA,CASA,SAAAwE,GAAA/W,GACA,OAAAA,IAAAoL,EACA,CAoEA,SAAAA,KACA,IAAA8H,EACAe,EACAD,EACApK,EACApI,EAGA,GADAyS,EAAA5P,UAAA1D,SACAiR,gBAAAxG,IACA,OAAA,IAAA6I,EACA,IAAA7I,GAEA,IAAA6I,EACA,IAAA7I,GAAA/G,UAAA,IAEA,IAAA4P,EACA,IAAA7I,GAAA/G,UAAA,GAAAA,UAAA,IAEA,IAAA+G,GAAA/G,UAAA,GAAAA,UAAA,GAAAA,UAAA,IAGA,GAAA,IAAA4P,EACAD,EAAA,IAAAhJ,GAAA,QACA,GAAA,IAAAiJ,EAEA,GAAA5E,GADA7N,EAAA6C,UAAA,IAEA2P,EAAA,IAAAhJ,GAAAxJ,QACA,GAAAkO,GAAAlO,GACAwS,EC9IA,SAAoBA,EAAKxM,GACxB,IAAIoC,EACAzJ,EAGJ,IADAyJ,EAAMpC,EAAI7G,OACJR,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB6T,EAAK7T,GAAMiQ,GAAS5I,EAAKrH,IAE1B,OAAO6T,CACR,CDqIAE,CAAA,IAAAlJ,GAAAxJ,EAAAb,QAAAa,QACA,GAAAqO,GAAArO,GACAwS,EAAA,IAAAhJ,GAAAxJ,OACA,KAAAoN,GAAApN,GAaA,MAAA,IAAA0C,UAAAiB,EAAA,qHAAA3D,IAZA,IAAA,IAAAkS,GACA,MAAA,IAAAxP,UAAAiB,EAAA,mJAAA3D,IAEA,IAAA+P,GAAA/P,EAAA+S,KACA,MAAA,IAAArQ,UAAAiB,EAAA,qHAAA3D,IAGA,IAAA+P,IADAyC,EAAAxS,EAAA+S,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,qHAAA3D,IAEAwS,EAAA,IAAAhJ,GAAAoI,GAAAY,GAGA,KACA,CAEA,IAAAnE,GADAmE,EAAA3P,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,wEAAA6O,IAGA,IAAA3E,GADA6D,EAAA7O,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,4EAAA+N,IAEA,GAAA,IAAAe,EACAD,EAAA,IAAAhJ,GAAAgJ,EAAAd,OACA,CAEA,IAAA7D,GADAzF,EAAAvF,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,uEAAAyE,IAEA,GAAAA,EAAA2I,GAAAyB,EAAAM,WAAApB,EACA,MAAA,IAAAiB,WAAAhP,EAAA,iJAAAyE,EAAA2I,KAEAyB,EAAA,IAAAhJ,GAAAgJ,EAAAd,EAAAtJ,EACA,CACA,CAIA,OAHA7C,EAAA6K,KAAA,UAAAoC,GACAjN,EAAA6K,KAAA,UAAAoC,EAAArT,QAEAiR,IACA,CAeA7K,EAAAqE,GAAA,oBAAAmH,IAeAxL,EAAAqE,GAAA,OAAA,gBAmCAjE,EAAAiE,GAAA,QAAA,SAAAoJ,GACA,IAAAC,EACAR,EACAS,EACAtU,EACA4T,EACAW,EACA/N,EACAgD,EACAzJ,EACA,IAAAoR,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA6S,GAAAnF,MACA,MAAA,IAAA1N,UAAA,sDAGA,IADA+P,EAAA5P,UAAA1D,QACA,EAAA,CAEA,IAAA4Q,GADAmD,EAAArQ,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,qEAAAuP,IAEAT,EAAA,IACAQ,EAAApQ,UAAA,GAEA,CACA,GAAAqL,GAAA8E,GAAA,CACA,GAAAE,EAAA,CASA,IARA9K,EAAA4K,EAAA7T,OAEAiG,EADA4N,EAAA5N,KAAA4N,EAAA3N,IACAgO,GAAA,WAEAzM,GAAA,WAGA4L,GADA5T,EAAA,IAAAwR,KAAAhI,IACAiK,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAiQ,GAAAsE,EAAAzS,KAAAwS,EAAA7N,EAAA4N,EAAArU,GAAAA,IAEA,OAAAC,CACA,CACA,OAAA,IAAAwR,KAAA4C,EACA,CACA,GAAA5F,GAAA4F,IAAAd,IAAAnC,GAAAiD,EAAAD,KAAA,CAEA,IAAAhD,IADAyC,EAAAQ,EAAAD,OACAjB,MACA,MAAA,IAAApP,UAAAiB,EAAA,6FAAAqP,IAUA,IAPAG,EADAD,EE1SA,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIrU,EACAkJ,EACAnJ,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI+J,EAAGC,QACAC,MAGPpT,GAAK,EACLC,EAAI8E,KAAMkL,GAASsE,EAAKzS,KAAMwS,EAASnL,EAAEtJ,MAAOG,KAEjD,OAAOC,CACR,CF2RA0U,CAAAd,EAAAU,EAAAD,GAEArB,GAAAY,GAIAA,GADA5T,EAAA,IAAAwR,KADAhI,EAAA+K,EAAAhU,SAEAkT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACA6T,EAAA7T,GAAAwU,EAAAxU,GAEA,OAAAC,CACA,CACA,MAAA,IAAA8D,UAAAiB,EAAA,6FAAAqP,GACA,IAoBAzN,EAAAqE,GAAA,MAAA,WACA,IAAAhG,EACAjF,EACA,IAAAoR,GAAAK,MACA,MAAA,IAAA1N,UAAA,6DAEA,IAAA6S,GAAAnF,MACA,MAAA,IAAA1N,UAAA,sDAGA,IADAkB,EAAA,GACAjF,EAAA,EAAAA,EAAAkE,UAAA1D,OAAAR,IACAiF,EAAAF,KAAAb,UAAAlE,IAEA,OAAA,IAAAyR,KAAAxM,EACA,IA6BA+B,EAAAiE,GAAApK,UAAA,MAAA,SAAAyG,GACA,IAAAuM,EACApK,EAEA,IAAAkN,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAA8K,GAAAvH,GACA,MAAA,IAAAvD,UAAAiB,EAAA,0DAAAsC,IAOA,GALAmC,EAAAgI,KAAAgC,QACAI,EAAApC,KAAAiC,QACApM,EAAA,IACAA,GAAAmC,KAEAnC,EAAA,GAAAA,GAAAmC,GAGA,OAAAwG,GAAA4D,EAAAvM,GACA,IAgBAoL,GAAAzH,GAAApK,UAAA,UAAA,WACA,OAAA4Q,KAAAiC,QAAAZ,MACA,IAgBAJ,GAAAzH,GAAApK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAS,UACA,IAgBAzB,GAAAzH,GAAApK,UAAA,cAAA,WACA,OAAA4Q,KAAAiC,QAAAX,UACA,IAiBA/L,EAAAiE,GAAApK,UAAA,oBAAAoK,GAAAmH,mBA+BAxL,EAAAqE,GAAApK,UAAA,cAAA,SAAA+T,EAAAC,GACA,IAAA8B,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAQA,OALA,IAAAG,UAAA1D,OACAiR,KAAAiC,QAAAoB,WAAAF,EAAAC,GAEApD,KAAAiC,QAAAoB,WAAAF,EAAAC,EAAA3Q,UAAA,IAEAuN,IACA,IAgCAzK,EAAAiE,GAAApK,UAAA,WAAA,WACA,IAAAqP,EACA6E,EACAtL,EACAoK,EACAtL,EACAvI,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAiBA,OAfAmM,EAAAuB,KACAoC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAA,CAAAG,EAAAiQ,GAAA4D,EAAA7T,KACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAA8E,SACA,IAjDAD,CAkDA,IA4BAnO,EAAAqE,GAAApK,UAAA,SAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,IAAAwJ,EAAA1H,KAAAwS,EAAArE,GAAA4D,EAAA7T,IAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA+BA7K,EAAAqE,GAAApK,UAAA,QAAA,SAAAhB,EAAAgV,EAAAI,GACA,IAAApB,EACApK,EACAoN,EACA7W,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAgM,GAAAlQ,GACA,MAAA,IAAAkE,UAAAiB,EAAA,mEAAAnF,IAIA,GAFAgU,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAgG,GACA,MAAA,IAAA9Q,UAAAiB,EAAA,qEAAA6P,IAQA,GANAA,EAAA,IACAA,GAAApL,GACA,IACAoL,EAAA,GAGA3Q,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,oEAAAiQ,IAEAA,EAAA,IACAA,GAAAxL,GACA,IACAwL,EAAA,GAGAA,EAAAxL,IACAwL,EAAAxL,EAEA,MACAwL,EAAAxL,CAEA,MACAoL,EAAA,EACAI,EAAAxL,EAOA,IAJAoN,EADAhX,EACA,EAEA,EAEAG,EAAA6U,EAAA7U,EAAAiV,EAAAjV,IACA6T,EAAA7T,GAAA6W,EAEA,OAAApF,IACA,IAqCA7K,EAAAqE,GAAApK,UAAA,UAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA5T,EACAD,EACAmJ,EAEA,IAAAwN,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAIA,IAFAqK,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAmJ,EAAA8G,GAAA4D,EAAA7T,IACAwJ,EAAA1H,KAAAwS,EAAAnL,EAAAnJ,EAAAyR,OACAxR,EAAA8E,KAAAoE,GAGA,OAAA,IAAAsI,KAAA5H,YAAA5J,EACA,IA4BA2G,EAAAqE,GAAApK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA1K,EACAnJ,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADAmJ,EAAA8G,GAAA4D,EAAA7T,IACAwJ,EAAA1H,KAAAwS,EAAAnL,EAAAnJ,EAAAyR,MACA,OAAAtI,CAGA,IA4BAvC,EAAAqE,GAAApK,UAAA,aAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA1K,EACAnJ,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IAEA,GADAmJ,EAAA8G,GAAA4D,EAAA7T,IACAwJ,EAAA1H,KAAAwS,EAAAnL,EAAAnJ,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IA4BA4G,EAAAqE,GAAApK,UAAA,YAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA1K,EACAnJ,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADAmJ,EAAA8G,GAAA4D,EAAA7T,IACAwJ,EAAA1H,KAAAwS,EAAAnL,EAAAnJ,EAAAyR,MACA,OAAAtI,CAGA,IA4BAvC,EAAAqE,GAAApK,UAAA,iBAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA1K,EACAnJ,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAAyR,KAAAgC,QAAA,EAAAzT,GAAA,EAAAA,IAEA,GADAmJ,EAAA8G,GAAA4D,EAAA7T,IACAwJ,EAAA1H,KAAAwS,EAAAnL,EAAAnJ,EAAAyR,MACA,OAAAzR,EAGA,OAAA,CACA,IA0BA4G,EAAAqE,GAAApK,UAAA,WAAA,SAAAqU,EAAAZ,GACA,IAAAT,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAAiB,EAAA,oEAAAkQ,IAGA,IADArB,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAkV,EAAApT,KAAAwS,EAAArE,GAAA4D,EAAA7T,IAAAA,EAAAyR,KAEA,IA2BAzK,EAAAiE,GAAApK,UAAA,OAAA,SAAAyG,GACA,IAAAqP,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAmL,GAAA5H,GACA,MAAA,IAAAvD,UAAAiB,EAAA,qEAAAsC,IAEA,KAAAA,GAAAmK,KAAAgC,SAGA,OAAAxD,GAAAwB,KAAAiC,QAAApM,GACA,IA8BAV,EAAAqE,GAAApK,UAAA,YAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAgM,GAAAoF,GACA,MAAA,IAAApR,UAAAiB,EAAA,mEAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAGA,IADAvB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IACA,GAAAmV,IAAAlF,GAAA4D,EAAA7T,IACA,OAAA,EAGA,OAAA,CACA,IAiCA4G,EAAAqE,GAAApK,UAAA,WAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAgM,GAAAoF,GACA,MAAA,IAAApR,UAAAiB,EAAA,mEAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,EAAA,IACAA,GAAA3D,KAAAgC,SACA,IACA2B,EAAA,EAGA,MACAA,EAAA,EAGA,IADAvB,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,EAAAyR,KAAAgC,QAAAzT,IACA,GAAAmV,IAAAlF,GAAA4D,EAAA7T,IACA,OAAAA,EAGA,OAAA,CACA,IA0BAgH,EAAAiE,GAAApK,UAAA,QAAA,SAAAwU,GACA,IAAAxB,EACA5T,EACAD,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,GAAAG,UAAA1D,OAAA,GACA,IAAAmP,GAAA0F,GACA,MAAA,IAAAtR,UAAAiB,EAAA,kEAAAqQ,SAGAA,EAAA,IAIA,IAFAxB,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA6T,EAAA7T,GACAC,EAAA8E,KAAA,QAEA9E,EAAA8E,KAAA,SAGA,OAAA9E,EAAAsV,KAAAF,EACA,IA4BArO,EAAAiE,GAAApK,UAAA,QAAA,WACA,IAAAqP,EACA6E,EACAtL,EACAlB,EACAvI,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAgBA,OAdAmM,EAAAuB,KACAhI,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAAG,EACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsF,MACA,IAjDAT,CAkDA,IAiCAnO,EAAAqE,GAAApK,UAAA,eAAA,SAAAsU,EAAAC,GACA,IAAAvB,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAgM,GAAAoF,GACA,MAAA,IAAApR,UAAAiB,EAAA,mEAAAmQ,IAEA,GAAAjR,UAAA1D,OAAA,EAAA,CACA,IAAAqO,GAAAuG,GACA,MAAA,IAAArR,UAAAiB,EAAA,qEAAAoQ,IAEAA,GAAA3D,KAAAgC,QACA2B,EAAA3D,KAAAgC,QAAA,EACA2B,EAAA,IACAA,GAAA3D,KAAAgC,QAEA,MACA2B,EAAA3D,KAAAgC,QAAA,EAGA,IADAI,EAAApC,KAAAiC,QACA1T,EAAAoV,EAAApV,GAAA,EAAAA,IACA,GAAAmV,IAAAlF,GAAA4D,EAAA7T,IACA,OAAAA,EAGA,OAAA,CACA,IAgBA0S,GAAAzH,GAAApK,UAAA,UAAA,WACA,OAAA4Q,KAAAgC,OACA,IAqCA7M,EAAAqE,GAAApK,UAAA,OAAA,SAAAqU,EAAAZ,GACA,IAAAmB,EACAxV,EACA4T,EACA7T,EACA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA8D,GACA,MAAA,IAAAnR,UAAA,oEAAAmR,GAKA,IAHArB,EAAApC,KAAAiC,QAEA+B,GADAxV,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAgC,UACAC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAyV,EAAAzV,GAAAiQ,GAAAiF,EAAApT,KAAAwS,EAAArE,GAAA4D,EAAA7T,IAAAA,EAAAyR,OAEA,OAAAxR,CACA,IA+BA2G,EAAAqE,GAAApK,UAAA,UAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACApK,EACAmM,EACA5V,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAA,MACA,CACA,GAAA,IAAAyJ,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAA3F,GAAA4D,EAAA,IACA7T,EAAA,CACA,CACA,KAAAA,EAAAyJ,EAAAzJ,IACA4V,EAAAF,EAAAE,EAAA3F,GAAA4D,EAAA7T,IAAAA,EAAAyR,MAEA,OAAAmE,CACA,IA+BAhP,EAAAqE,GAAApK,UAAA,eAAA,SAAA6U,EAAAC,GACA,IAAA9B,EACApK,EACAmM,EACA5V,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAAsE,GACA,MAAA,IAAA3R,UAAAiB,EAAA,oEAAA0Q,IAIA,GAFA7B,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAvP,UAAA1D,OAAA,EACAoV,EAAAD,EACA3V,EAAAyJ,EAAA,MACA,CACA,GAAA,IAAAA,EACA,MAAA,IAAAjI,MAAA,oGAEAoU,EAAA3F,GAAA4D,EAAApK,EAAA,IACAzJ,EAAAyJ,EAAA,CACA,CACA,KAAAzJ,GAAA,EAAAA,IACA4V,EAAAF,EAAAE,EAAA3F,GAAA4D,EAAA7T,IAAAA,EAAAyR,MAEA,OAAAmE,CACA,IA8BA5O,EAAAiE,GAAApK,UAAA,WAAA,WACA,IAAAgT,EACAW,EACA/K,EACAoM,EACA7V,EACA8D,EAEA,IAAA6S,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAKA,IAHA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACAoC,EAAAjH,GAAAnF,EAAA,GACAzJ,EAAA,EAAAA,EAAA6V,EAAA7V,IACA8D,EAAA2F,EAAAzJ,EAAA,EACAwU,EAAAX,EAAA7T,GACA6T,EAAA7T,GAAA6T,EAAA/P,GACA+P,EAAA/P,GAAA0Q,EAEA,OAAA/C,IACA,IA+CAzK,EAAAiE,GAAApK,UAAA,OAAA,SAAAhB,GACA,IAAAiW,EACAxO,EACAuM,EACAW,EACAqB,EACA7V,EACA8D,EACA,IAAA6S,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAGA,GADA8P,EAAApC,KAAAiC,QACAxP,UAAA1D,OAAA,GAEA,IAAA0O,GADA5H,EAAApD,UAAA,IAEA,MAAA,IAAAH,UAAAiB,EAAA,+EAAAsC,SAGAA,EAAA,EAEA,GAAAiI,GAAA1P,GAAA,CAEA,GAAAyH,GADAuO,EAAAhW,EAAAW,QACAiR,KAAAgC,QACA,MAAA,IAAAO,WAAA,0FASA,GANA8B,EADAa,GAAA9W,GACAA,EAAA6T,QAEA7T,EAGAiE,EAAA+P,EAAAd,WAAAzL,EAAA8K,GAEA0D,EAAAhD,SAAAe,EAAAf,QAEAgD,EAAA/C,WAAAjP,GACAgS,EAAA/C,WAAA+C,EAAA3B,WAAArQ,EAEA,CAGA,IADA0Q,EAAA,IAAA3J,GAAAiL,EAAAtV,QACAR,EAAA,EAAAA,EAAA8V,EAAAtV,OAAAR,IACAwU,EAAAxU,GAAA8V,EAAA9V,GAEA8V,EAAAtB,CACA,CACA,IAAAxU,EAAA,EAAAA,EAAA6V,EAAAvO,IAAAtH,IACA6T,EAAAvM,GAAAwO,EAAA9V,GAAA,EAAA,CAGA,KA9BA,CA+BA,GAAAsH,GAAAmK,KAAAgC,QACA,MAAA,IAAAO,WAAAhP,EAAA,kEAAAsC,IAEAuM,EAAAvM,GAAA,EAAA,EAAA,CAJA,CAKA,IAgDAV,EAAAqE,GAAApK,UAAA,SAAA,SAAAqV,EAAAjB,GACA,IAAAc,EACAN,EACAxV,EACA4T,EACApK,EACAzJ,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACA0V,EAAA,EACAjB,EAAAxL,MACA,CACA,IAAAoF,GAAAqH,GACA,MAAA,IAAAnS,UAAAiB,EAAA,oEAAAkR,IAQA,GANAA,EAAA,IACAA,GAAAzM,GACA,IACAyM,EAAA,GAGA,IAAAhS,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAQA,IANAsM,EADAG,EAAAjB,EACAA,EAAAiB,EAEA,EAGAT,GADAxV,EAAA,IAAAwR,KAAA5H,YAAAkM,IACArC,QACA1T,EAAA,EAAAA,EAAA+V,EAAA/V,IACAyV,EAAAzV,GAAA6T,EAAA7T,EAAAkW,GAEA,OAAAjW,CACA,IA4BA2G,EAAAqE,GAAApK,UAAA,QAAA,SAAA2I,EAAA8K,GACA,IAAAT,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAAqN,GAAA5H,GACA,MAAA,IAAAzF,UAAAiB,EAAA,oEAAAwE,IAGA,IADAqK,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA,GAAAwJ,EAAA1H,KAAAwS,EAAArE,GAAA4D,EAAA7T,IAAAA,EAAAyR,MACA,OAAA,EAGA,OAAA,CACA,IA4CAzK,EAAAiE,GAAApK,UAAA,QAAA,SAAAmV,GACA,IAAAnC,EAEA,IAAA8C,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAGA,GADA8P,EAAApC,KAAAiC,QACA,IAAAxP,UAAA1D,OAEA,OADAqT,EAAAoC,OACAxE,KAEA,IAAAL,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAGA,OADAnC,EAAAoC,MAWA,SAAAa,EAAAC,GACA,OAAAf,EAAA/F,GAAA6G,GAAA7G,GAAA8G,GACA,IAZAtF,IAaA,IAgDA7K,EAAAqE,GAAApK,UAAA,YAAA,SAAAqV,EAAAjB,GACA,IAAApC,EACAgB,EACApK,EAEA,IAAAkN,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAIA,GAFA8P,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QACA,IAAAvP,UAAA1D,OACA0V,EAAA,EACAjB,EAAAxL,MACA,CACA,IAAAoF,GAAAqH,GACA,MAAA,IAAAnS,UAAAiB,EAAA,oEAAAkR,IAQA,GANAA,EAAA,IACAA,GAAAzM,GACA,IACAyM,EAAA,GAGA,IAAAhS,UAAA1D,OACAyU,EAAAxL,MACA,CACA,IAAAoF,GAAAoG,GACA,MAAA,IAAAlR,UAAAiB,EAAA,qEAAAiQ,IAEAA,EAAA,GACAA,GAAAxL,GACA,IACAwL,EAAA,GAEAA,EAAAxL,IACAwL,EAAAxL,EAEA,CACA,CAWA,OAVAyM,GAAAzM,GACAA,EAAA,EACAoJ,EAAAgB,EAAAM,YACA+B,GAAAjB,GACAxL,EAAA,EACAoJ,EAAAgB,EAAAd,WAAAmD,EAAA9D,KAEA3I,EAAAwL,EAAAiB,EACArD,EAAAgB,EAAAd,WAAAmD,EAAA9D,IAEA,IAAAX,KAAA5H,YAAAgK,EAAAf,OAAAD,EAAApJ,EAAA,EAAA,EAAAA,EACA,IAyBA7C,EAAAqE,GAAApK,UAAA,kBAAA,SAAAsV,EAAAC,GACA,IAAAC,EACAC,EACArW,EACA4T,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,GAAA,IAAAG,UAAA1D,OACA8V,EAAA,OACA,KAAA3G,GAAAwG,KAAArG,GAAAqG,GAGA,MAAA,IAAApS,UAAAiB,EAAA,yFAAAmR,IAFAG,EAAAH,CAGA,CACA,GAAAjS,UAAA1D,OAAA,EACA6V,EAAA,CAAA,MACA,KAAA5H,GAAA2H,GAGA,MAAA,IAAArS,UAAAiB,EAAA,qEAAAoR,IAFAC,EAAAD,CAGA,CAGA,IAFAvC,EAAApC,KAAAiC,QACAzT,EAAA,GACAD,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACAC,EAAA8E,KAAAkL,GAAA4D,EAAA7T,IAAAuW,eAAAD,EAAAD,IAEA,OAAApW,EAAAsV,KAAA,IACA,IA8BAvO,EAAAiE,GAAApK,UAAA,cAAA,WACA,IAAA4U,EACAxV,EACAwJ,EACAoK,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAMA,IAJA0F,EAAAgI,KAAAgC,QACAxT,EAAA,IAAAwR,KAAA5H,YAAAJ,GACAoK,EAAApC,KAAAiC,QACA+B,EAAAxV,EAAAyT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAyV,EAAAzV,GAAA6T,EAAApK,EAAAzJ,EAAA,GAEA,OAAAC,CACA,IA6CA+G,EAAAiE,GAAApK,UAAA,YAAA,SAAAmV,GACA,IAAAP,EACAxV,EACAwJ,EACAoK,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAMA,IAJA0F,EAAAgI,KAAAgC,QACAxT,EAAA,IAAAwR,KAAA5H,YAAAJ,GACAoK,EAAApC,KAAAiC,QACA+B,EAAAxV,EAAAyT,QACA1T,EAAA,EAAAA,EAAAyJ,EAAAzJ,IACAyV,EAAAzV,GAAA6T,EAAA7T,GAEA,GAAA,IAAAkE,UAAA1D,OAEA,OADAiV,EAAAQ,OACAhW,EAEA,IAAAmR,GAAA4E,GACA,MAAA,IAAAjS,UAAAiB,EAAA,oEAAAgR,IAGA,OADAP,EAAAQ,MAWA,SAAAa,EAAAC,GACA,OAAAf,EAAA/F,GAAA6G,GAAA7G,GAAA8G,GACA,IAZA9W,CAaA,IAqBA+G,EAAAiE,GAAApK,UAAA,YAAA,WACA,IAAAZ,EACA4T,EACA7T,EACA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAIA,IAFA9D,EAAA,GACA4T,EAAApC,KAAAiC,QACA1T,EAAA,EAAAA,EAAAyR,KAAAgC,QAAAzT,IACA6T,EAAA7T,GACAC,EAAA8E,KAAA,QAEA9E,EAAA8E,KAAA,SAGA,OAAA9E,EAAAsV,KAAA,IACA,IA4BAvO,EAAAiE,GAAApK,UAAA,UAAA,WACA,IAAAkU,EACA7E,EACAzG,EACAlB,EACAsL,EACA7T,EAEA,IAAA2W,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAiBA,OAfAmM,EAAAuB,KACAoC,EAAApC,KAAAiC,QACAjK,EAAAgI,KAAAgC,QAGAzT,GAAA,EAIA4G,EADAmO,EAAA,CAAA,EACA,QAcA,WAEA,GADA/U,GAAA,EACAuI,GAAAvI,GAAAyJ,EACA,MAAA,CACA2J,MAAA,GAGA,MAAA,CACAvT,MAAAoQ,GAAA4D,EAAA7T,IACAoT,MAAA,EAEA,IAxBAxM,EAAAmO,EAAA,UAiCA,SAAAlV,GAEA,GADA0I,GAAA,EACArE,UAAA1D,OACA,MAAA,CACAX,MAAAA,EACAuT,MAAA,GAGA,MAAA,CACAA,MAAA,EAEA,IA1CAgB,IACAxN,EAAAmO,EAAAX,IAiDA,WACA,OAAAlE,EAAAsG,QACA,IAjDAzB,CAkDA,IA6BAnO,EAAAqE,GAAApK,UAAA,QAAA,SAAA4V,EAAA5W,GACA,IACAI,EACAwJ,EAEA,IAAAkN,GAAAlF,MACA,MAAA,IAAA1N,UAAA,sDAEA,IAAA8K,GAAA4H,GACA,MAAA,IAAA1S,UAAAiB,EAAA,oEAAAyR,IAMA,GAJAhN,EAAAgI,KAAAgC,QACAgD,EAAA,IACAA,GAAAhN,GAEAgN,EAAA,GAAAA,GAAAhN,EACA,MAAA,IAAAuK,WAAAhP,EAAA,kEAAAyR,IAEA,IAAA1G,GAAAlQ,GACA,MAAA,IAAAkE,UAAAiB,EAAA,oEAAAnF,IASA,OAPAI,EAAA,IAAAwR,KAAA5H,YAAA4H,KAAAiC,UACAA,QAEA+C,GADA5W,EACA,EAEA,EAEAI,CACA,IG/4EA,IAAI+W,GAAQ,CACXzM,GACAD,GACAG,GACAG,GACAJ,GACAG,GACAD,GACAG,GACAC,GACAC,GACAC,GACAC,IC5BGgM,GAAS,CACZ,UACA,UACA,QACA,SACA,QACA,SACA,OACA,QACA,SACA,YACA,aACA,QCHGC,GAASD,GAAOzW,OAkBpB,SAAS0H,GAAOrI,GACf,IAAIG,EACJ,GAAKkD,GAASrD,GACb,MAAO,UAER,GAAK8J,GAAU9J,GACd,OAAO,KAER,IAAMG,EAAI,EAAGA,EAAIkX,GAAQlX,IACxB,GAAKH,aAAiBmX,GAAOhX,GAC5B,OAAOiX,GAAQjX,GAIjB,OAAOmX,GAAYlN,GAAiBpK,KAAa,IAClD,CCZA,SAASgY,GAAkB/I,GAC1B,IAAIuI,EAAKnP,GAAO4G,GAChB,OAAK5H,GAAiB4H,GACd,CACNgJ,KAAQhJ,EACR5G,MAASmP,EACTC,kBAAoB,EACpBF,UAAa,CACZ1C,GAAgB2C,GAChBE,GAAgBF,KAIZ,CACNS,KAAQhJ,EACR5G,MAASmP,EACTC,kBAAoB,EACpBF,UAAa,CACZnP,GAAQoP,GACRjP,GAAQiP,IAGX,CCRA,SAASoW,GAAO5X,EAAG/G,EAAG4e,EAASC,EAAS5U,EAAG6U,EAASC,GACnD,IAAIC,EACAC,EACArnB,EACAD,EACAunB,EACAC,EACAjuB,EAYJ,IATA8tB,EAAOhf,EAAEgJ,KACTiW,EAAOhV,EAAEjB,KAGTrR,EAAMqI,EAAEsI,UAAW,GACnB1Q,EAAMqS,EAAE3B,UAAW,GAEnB4W,EAAKL,EACLM,EAAKJ,EACC7tB,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB0G,EAAKqnB,EAAME,EAAIxnB,EAAKqnB,EAAME,IAC1BA,GAAMN,EACNO,GAAML,EAEP,OAAO9e,CACR,CChEA,IAAIgV,GAAI,EAsBR,SAAS2J,GAAO5X,EAAG/G,EAAG4e,EAAS3U,EAAG6U,GACjC,IAAII,EACAC,EACAC,EACAC,EACAtG,EACA7nB,EAEJ,GAAK6V,GAAK,EACT,OAAOkD,EAIR,GAFAmV,EAAKrW,GAAkB/I,GACvBqf,EAAKtW,GAAkBkB,GAClBmV,EAAG5W,kBAAoB6W,EAAG7W,iBAY9B,OADAF,GAAWvB,EAAGqY,EAAIR,EATjBM,EADIN,EAAU,GACR,EAAE7X,GAAK6X,EAER,EAOyBS,EAAIP,EAJlCK,EADIL,EAAU,GACR,EAAE/X,GAAK+X,EAER,GAGCO,EAAGrW,KAGX,GAAiB,IAAZ4V,GAA6B,IAAZE,EAAgB,CAIrC,IAHA/F,EAAIhS,EAAIiO,IAGC,EACR,IAAM9jB,EAAI,EAAGA,EAAI6nB,EAAG7nB,IACnB+Y,EAAG/Y,GAAM8O,EAAG9O,GAGd,GAAK6V,EAAIiO,GACR,OAAO/K,EAER,IAAM/Y,EAAI6nB,EAAG7nB,EAAI6V,EAAG7V,GAAK8jB,GACxB/K,EAAG/Y,GAAM8O,EAAG9O,GACZ+Y,EAAG/Y,EAAE,GAAM8O,EAAG9O,EAAE,GAChB+Y,EAAG/Y,EAAE,GAAM8O,EAAG9O,EAAE,GAChB+Y,EAAG/Y,EAAE,GAAM8O,EAAG9O,EAAE,GAChB+Y,EAAG/Y,EAAE,GAAM8O,EAAG9O,EAAE,GAChB+Y,EAAG/Y,EAAE,GAAM8O,EAAG9O,EAAE,GAChB+Y,EAAG/Y,EAAE,GAAM8O,EAAG9O,EAAE,GAChB+Y,EAAG/Y,EAAE,GAAM8O,EAAG9O,EAAE,GAEjB,OAAO+Y,CACP,CAWD,IATCiV,EADIN,EAAU,GACR,EAAE7X,GAAK6X,EAER,EAGLO,EADIL,EAAU,GACR,EAAE/X,GAAK+X,EAER,EAEA5tB,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB+Y,EAAGkV,GAAOnf,EAAGkf,GACbA,GAAMN,EACNO,GAAML,EAEP,OAAO7U,CACR,CC1FA,IAAI+K,GAAI,EAwBR,SAAS2J,GAAO5X,EAAG/G,EAAG4e,EAASC,EAAS5U,EAAG6U,EAASC,GACnD,IAAIG,EACAC,EACAC,EACAC,EACAtG,EACA7nB,EAEJ,GAAK6V,GAAK,EACT,OAAOkD,EAIR,GAFAmV,EAAKrW,GAAkB/I,GACvBqf,EAAKtW,GAAkBkB,GAClBmV,EAAG5W,kBAAoB6W,EAAG7W,iBAE9B,OADAF,GAAWvB,EAAGqY,EAAIR,EAASC,EAASQ,EAAIP,EAASC,GAC1CM,EAAGrW,KAMX,GAJAkW,EAAKL,EACLM,EAAKJ,EAGY,IAAZH,GAA6B,IAAZE,EAAgB,CAIrC,IAHA/F,EAAIhS,EAAIiO,IAGC,EACR,IAAM9jB,EAAI,EAAGA,EAAI6nB,EAAG7nB,IACnB+Y,EAAGkV,GAAOnf,EAAGkf,GACbA,GAAMN,EACNO,GAAML,EAGR,GAAK/X,EAAIiO,GACR,OAAO/K,EAER,IAAM/Y,EAAI6nB,EAAG7nB,EAAI6V,EAAG7V,GAAK8jB,GACxB/K,EAAGkV,GAAOnf,EAAGkf,GACbjV,EAAGkV,EAAG,GAAMnf,EAAGkf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMnf,EAAGkf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMnf,EAAGkf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMnf,EAAGkf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMnf,EAAGkf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMnf,EAAGkf,EAAG,GAClBjV,EAAGkV,EAAG,GAAMnf,EAAGkf,EAAG,GAClBA,GAAMlK,GACNmK,GAAMnK,GAEP,OAAO/K,CACP,CACD,IAAM/Y,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB+Y,EAAGkV,GAAOnf,EAAGkf,GACbA,GAAMN,EACNO,GAAML,EAEP,OAAO7U,CACR,CCrCA,SAASlU,GAAOiK,EAAGic,EAAGiC,GACrB,IAAI/sB,EACAwJ,EACAyY,EACA7K,EACAxB,EAQJ,IAHAqM,EAAK6K,GAAgBhC,EAHrBthB,EAAMqF,EAAEtO,QAGqB,IAGrBysB,KAAO,CACd,GAAKD,EACJ,MAAM,IAAIhZ,WAAYhP,EAAQ,kEAAmEyE,IAGlGyY,EAAK6K,GAAgBhC,EAAGthB,GAAK,EAC7B,CAgBD,OAdAoM,EAAIsX,GAAajL,GAOhBjiB,EADW,aAHZoX,EAAKnP,GAAO4G,KAGoB,OAAPuI,EAClBvX,GAAO+V,GAEP,IAAI/G,EAAEjF,YAAagM,GAG1B4X,GAAO5X,EAAG/G,EAAGoT,EAAGyK,KAAMzK,EAAGrN,MAAO5U,EAAK,EAAG,GAEjCA,CACR,CCrDA2G,EAAAnH,GAAA,UAAA2uB,ICdA,IAAI/U,GAAQ,CACXjS,QAAWmD,GACXhD,QAAW+C,GACXvC,QAAW5E,MACXsE,MAAS+C,GACThD,MAASiD,GACT/C,KAAQgD,GACR9C,OAAU+C,GACVhD,OAAUiD,GACV/C,MAASgD,GACT/C,OAAUgD,GACVxC,UAAayC,GACb1C,WAAc2C,GACdI,KAAQH,ICXT,SAASoO,GAAOnR,GACf,OAAOmmB,GAAOnmB,IAAW,IAC1B,CCQA,SAASomB,GAAapmB,GACrB,MAAmB,cAAVA,CACV,CAiBA,SAASqmB,GAAcrmB,GACtB,MAAmB,eAAVA,CACV,CAiBA,SAASsmB,GAAQtmB,GAChB,MAAmB,SAAVA,CACV,CAoBA,SAASumB,GAAS3f,EAAG5G,GACpB,IAAIwmB,EACAvkB,EACA2jB,EACAa,EACAloB,EACAxG,EACAwJ,EACAgX,EACAzgB,EAEJ,IAAMuP,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,8EAA+E8J,IAG7G,GAAe,YAAV5G,EACJ,OAAOub,GAAM3U,GAGd,GAAc,QADd3E,EAAOkP,GAAOnR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,uFAAwFkD,IAatH,GAVAuB,EAAMqF,EAAEtO,OAIRkuB,EAAQJ,GADR7N,EAAImO,GAAS9f,IAIb7O,EAAM,IAAIkK,EAAMV,GAGXilB,GAASH,GAAc9N,GAAM,CAOjC,GALCqN,EADIY,EACGza,GAAenF,EAAG,GAElBoF,GAAgBpF,EAAG,GAGtBwf,GAAapmB,GAGjB,OADAulB,GAAW,EAAJhkB,EAAOqkB,EAAM,EADpBa,EAAO1a,GAAehU,EAAK,GACE,GACtBA,EAER,GAAKsuB,GAAcrmB,GAGlB,OADAulB,GAAW,EAAJhkB,EAAOqkB,EAAM,EADpBa,EAAOza,GAAgBjU,EAAK,GACC,GACtBA,EAGR,GAAKuuB,GAAQtmB,GAAU,CAEtB,IADAymB,EAAO5L,GAAoB9iB,EAAK,GAC1BD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAEhB8tB,EAAM,EAAE9tB,IAAO8tB,EAAO,EAAE9tB,EAAG,GAC/B2uB,EAAM3uB,GAAM,EAEZ2uB,EAAM3uB,GAAM,EAGd,OAAOC,CACP,CAGD,OADAwtB,GAAOhkB,EAAKqkB,EAAM,EAAG7tB,EAAK,GACnBA,CACP,CAED,GAAKuuB,GAAQ/N,GAIZ,OAHAqN,EAAO/K,GAAoBjU,EAAG,GAGzB0f,GAAQtmB,IAEZulB,GAAOhkB,EAAKqkB,EAAM,EADlBa,EAAO5L,GAAoB9iB,EAAK,GACL,GACpBA,GAGHquB,GAAapmB,IAEjBulB,GAAOhkB,EAAKqkB,EAAM,EADlBa,EAAO1a,GAAehU,EAAK,GACA,GACpBA,GAEHsuB,GAAcrmB,IAElBulB,GAAOhkB,EAAKqkB,EAAM,EADlBa,EAAOza,GAAgBjU,EAAK,GACD,GACpBA,IAERwtB,GAAOhkB,EAAKqkB,EAAM,EAAG7tB,EAAK,GACnBA,GAIR,IADAyuB,EAAQJ,GAAapmB,KACPqmB,GAAcrmB,GAQ3B,OADAulB,GAAOhkB,EAAKqF,EAAG,EALd6f,EADID,EACGza,GAAehU,EAAK,GAEpBiU,GAAgBjU,EAAK,GAGL,GACjBA,EAGR,GAAKuuB,GAAQtmB,GAAU,CAGtB,IAFAymB,EAAO5L,GAAoB9iB,EAAK,GAChCwG,EAAMwR,GAAenJ,GACf9O,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAChByG,EAAKqI,EAAG9O,GACZ2uB,EAAM3uB,GAAM,EAEZ2uB,EAAM3uB,GAAM,EAGd,OAAOC,CACP,CAGD,OADAwtB,GAAOhkB,EAAKqF,EAAG,EAAG7O,EAAK,GAChBA,CACR,CCxJA,SAAS4uB,GAAa/f,EAAGiK,EAAGgS,EAAGiC,GAC9B,IAAI8B,EACAC,EACAC,EACAC,EACA/M,EACAgN,EACArZ,EASJ,GAPAmZ,EAAM9mB,GAAO4G,IAAO,UACpBmgB,EAAM/mB,GAAO6Q,IAAO,UAEpB+V,EAAOhgB,EAAEtO,OACTuuB,EAAOhW,EAAEvY,QAGH6gB,GAAkB2N,EAAKC,GAC5B,MAAM,IAAIlrB,UAAWiB,EAAQ,kHAAmHgqB,EAAKC,IAUtJ,GAPKE,GAAmBF,IAASxN,GAAgBuN,KAChDlgB,EAAI2f,GAAS3f,EAAGmgB,KAGjB/M,EAAK6K,GAAgBhC,EAAGgE,GAAM,IAGtB9B,KAAO,CACd,GAAKD,EACJ,MAAM,IAAIhZ,WAAYhP,EAAQ,kEAAmE+pB,IAGlG7M,EAAK6K,GAAgBhC,EAAGgE,GAAM,EAC9B,CAKD,GAHAlZ,EAAIsX,GAAajL,GAGH,IAAT4M,EACJI,EAAK,MACC,IAAKJ,IAASjZ,EAGpB,MAAM,IAAIrU,MAAOwD,EAAQ,6HAA8H8pB,EAAMjZ,IAF7JqZ,EAAK,CAGL,CAID,OAFAzB,GAAO5X,EAAG/G,EAAGogB,EAAI,EAAGnW,EAAGmJ,EAAGyK,KAAMzK,EAAGrN,OAE5BkE,CACR,CC3FA,SAASqW,GAAU3lB,EAAK8K,EAAMD,GAC7B,IAAIjN,EACArH,EAIJ,IADAqH,EAAM,GACArH,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBqH,EAAItC,KAAMwP,EAAKzS,KAAMwS,EAAStU,IAE/B,OAAOqH,CACR,CCJA,SAASgoB,GAAUxvB,EAAO0iB,GACzB,IAAItiB,EACAqvB,EACA9M,EACAC,EACA8M,EACAC,EACAhL,EAQJ,IANAhC,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZtiB,EAAM,GACAuvB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB8K,EAAGvqB,KAAMsd,GAAQxiB,EAAO2iB,IAEzBviB,EAAI8E,KAAMuqB,EACV,CACD,OAAOrvB,CACR,CCvBA,SAASwvB,GAAU5vB,EAAO0iB,GACzB,IAAItiB,EACAqvB,EACAI,EACAlN,EACAC,EACA8M,EACAI,EACAnL,EACAgL,EACAI,EASJ,IAPApN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZtiB,EAAM,GACA2vB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB8K,EAAGvqB,KAAMsd,GAAQxiB,EAAO2iB,IAEzBkN,EAAG3qB,KAAMuqB,EACT,CACDrvB,EAAI8E,KAAM2qB,EACV,CACD,OAAOzvB,CACR,CC/BA,SAAS4vB,GAAUhwB,EAAO0iB,GACzB,IAAItiB,EACAqvB,EACAI,EACAI,EACAtN,EACAC,EACA8M,EACAI,EACAI,EACAvL,EACAgL,EACAI,EACAI,EAUJ,IARAxN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZtiB,EAAM,GACA+vB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB8K,EAAGvqB,KAAMsd,GAAQxiB,EAAO2iB,IAEzBkN,EAAG3qB,KAAMuqB,EACT,CACDQ,EAAG/qB,KAAM2qB,EACT,CACDzvB,EAAI8E,KAAM+qB,EACV,CACD,OAAO7vB,CACR,CC3CA,SAASmjB,GAASvjB,EAAOwjB,EAAOd,EAAOe,EAAKrjB,GAC3C,IAAIsjB,EACAC,EACAxjB,EAMJ,GAJAujB,EAAIhB,EAAOe,IAGXE,EAAIF,EAAM,KACCD,EACV,OAAOhB,GAAQxiB,EAAO0jB,GAIvB,IAAMvjB,EAAI,EAAGA,EAAIujB,EAAGvjB,IACnBC,EAAI8E,KAAMqe,GAASvjB,EAAOwjB,EAAOd,EAAOiB,EAAG,KAE5C,OAAOvjB,CACR,CAwBA,SAASgwB,GAAUpwB,EAAO0iB,GACzB,OAAOa,GAASvjB,EAAO0iB,EAAM/hB,OAAQ+hB,EAAO,EAAG,GAChD,CC/CA,SAASa,GAASC,EAAOd,EAAOe,EAAK1J,EAAS3Z,EAAKsU,EAAMD,GACxD,IAAIhN,EACAiB,EACAgb,EACAC,EACAxjB,EAOJ,IAHAuI,GADAib,EAAIF,EAAM,KACID,EAEdE,EAAIhB,EAAOe,GACLtjB,EAAI,EAAGA,EAAIujB,EAAGvjB,KACnBsH,EAAMsS,EAAQ/U,SACVE,KAAM/E,GACLuI,EACJtI,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAAShN,IAE9BrH,EAAI8E,KAAMqe,GAASC,EAAOd,EAAOiB,EAAGlc,EAAK,GAAIiN,EAAMD,IAGrD,OAAOrU,CACR,CCzBA,SAASiwB,GAAO3N,GACf,IAAIc,EACAtjB,EACAC,EAGJ,GAAe,KADfqjB,EAAQd,EAAM/hB,QAEb,OAAO,EAGR,IADAT,EAAI,EACEC,EAAI,EAAGA,EAAIqjB,EAAOrjB,IACvBD,GAAKwiB,EAAOviB,GAEb,OAAOD,CACR,CCRA,SAASowB,GAAqBhnB,GAC7B,MAAe,iBAANA,CACV,CCmDA,SAASinB,GAAe7N,EAAO8N,GAC9B,OAAKC,GAAeD,GAhCrB,SAAsB9N,GACrB,IAAItiB,EACA8qB,EACA/qB,EAIJ,IAFAC,EAAM,GACN8qB,EAAI,EACE/qB,EAAI,EAAGA,EAAIuiB,EAAM/hB,OAAQR,IAC9BC,EAAI8E,KAAMgmB,GACVA,GAAKxI,EAAOviB,GAEb,OAAOC,CACR,CAqBSswB,CAAahO,GA3DtB,SAAmBA,GAClB,IAAIc,EACApjB,EACA8qB,EACA/qB,EAIJ,IAFAqjB,EAAQd,EAAM/hB,OACdP,EAAM,GACAD,EAAI,EAAGA,EAAIqjB,EAAOrjB,IACvBC,EAAI8E,KAAM,GAGX,IADAgmB,EAAI,EACE/qB,EAAIqjB,EAAM,EAAGrjB,GAAK,EAAGA,IAC1BC,EAAKD,GAAM+qB,EACXA,GAAKxI,EAAOviB,GAEb,OAAOC,CACR,CA4CQuwB,CAAUjO,EAClB,CC9CA,SAASkO,GAAWlO,EAAOyB,EAASnR,EAAQwd,EAAO/oB,EAAKopB,GACvD,IAAIrN,EACA5Z,EACAknB,EACA5F,EACA/qB,EAIJ,IAFAqjB,EAAQd,EAAM/hB,OACdiJ,EAAM,EACAzJ,EAAI,EAAGA,EAAIqjB,EAAOrjB,IACvByJ,GAAO8Y,EAAOviB,GAEf,GAAc,UAAT0wB,EACCppB,EAAM,EACVA,EAAM,EACKA,GAAOmC,IAClBnC,EAAMmC,EAAM,QAEP,GAAc,SAATinB,EACNppB,EAAM,GACVA,GAAOmC,GACI,GAEG,KADbnC,GAAOmC,KAENnC,GAAOmC,GAGEnC,GAAOmC,IAClBnC,GAAOmC,IACKA,IACXnC,GAAOmC,QAOT,GAHc,cAATinB,GAAwBppB,EAAM,IAClCA,GAAOmC,GAEHnC,EAAM,GAAKA,GAAOmC,EACtB,MAAM,IAAIuK,WAAYhP,EAAQ,gHAAiHyE,EAAKnC,IAKtJ,GADAqpB,EAAM9d,EACDyd,GAAeD,GAAU,CAC7B,IAAMrwB,EAAI,EAAGA,EAAIqjB,EAAOrjB,IAEvBsH,GADAyjB,EAAIzjB,EAAMib,EAAOviB,GAEjBsH,GAAOib,EAAOviB,GACd2wB,GAAO5F,EAAI/G,EAAShkB,GAErB,OAAO2wB,CACP,CAED,IAAM3wB,EAAIqjB,EAAM,EAAGrjB,GAAK,EAAGA,IAE1BsH,GADAyjB,EAAIzjB,EAAMib,EAAOviB,GAEjBsH,GAAOib,EAAOviB,GACd2wB,GAAO5F,EAAI/G,EAAShkB,GAErB,OAAO2wB,CACR,CC7EA,SAASC,GAAe/a,EAAGiE,GAC1B,OAAKA,EAAS,EACN,GAEC,EAAIjE,GAAMiE,CACpB,CCMAlT,EAAAnH,GAAA,UCgDA,SAAwB8iB,EAAO8N,EAAOpwB,GACrC,OAAKqwB,GAAeD,GApCrB,SAAsB9N,EAAOtiB,GAC5B,IAAI8qB,EACA/qB,EAGJ,IADA+qB,EAAI,EACE/qB,EAAI,EAAGA,EAAIuiB,EAAM/hB,OAAQR,IAC9BC,EAAKD,GAAM+qB,EACXA,GAAKxI,EAAOviB,GAEb,OAAOC,CACR,CA2BSswB,CAAahO,EAAOtiB,GA3D7B,SAAmBsiB,EAAOtiB,GACzB,IACI8qB,EACA/qB,EAIJ,IADA+qB,EAAI,EACE/qB,EAFEuiB,EAAM/hB,OAEE,EAAGR,GAAK,EAAGA,IAC1BC,EAAKD,GAAM+qB,EACXA,GAAKxI,EAAOviB,GAEb,OAAOC,CACR,CAiDQuwB,CAAUjO,EAAOtiB,EACzB,ICpEA,IAAI6jB,GAAI,EAoBR,SAAS+M,GAAMhb,EAAG/G,EAAG4e,EAASC,GAC7B,IAAInZ,EACAwZ,EACAC,EACAxW,EACAoQ,EACA9nB,EACAC,EAEJ,GAAK6V,GAAK,EACT,OAAO/G,EAGR,IADA2I,EAAII,GAAkB/I,IACfwI,iBAEN,OCCF,SAAezB,EAAG/G,EAAG4e,EAASC,GAC7B,IAAIG,EACApnB,EACAD,EACA+N,EACAwZ,EACAC,EACAluB,EACAC,EAYJ,IATA8tB,EAAOhf,EAAEgJ,KAGTrR,EAAMqI,EAAEsI,UAAW,GACnB1Q,EAAMoI,EAAEsI,UAAW,GAEnBrX,EAAI6O,GAAOiH,EAAE,GAEboY,GADAD,EAAKL,IACS9X,EAAI,GAAM6X,EAClB1tB,EAAI,EAAGA,EAAID,EAAGC,IACnBwU,EAAM/N,EAAKqnB,EAAME,GACjBtnB,EAAKonB,EAAME,EAAIvnB,EAAKqnB,EAAMG,IAC1BvnB,EAAKonB,EAAMG,EAAIzZ,GACfwZ,GAAMN,EACNO,GAAMP,CAGR,CD9BEtW,CAAWvB,EAAG4B,EAAGiW,EAASC,GACnBlW,EAAEK,KAMV,GAJA/X,EAAI6O,GAAOiH,EAAE,GACbmY,EAAKL,EAGY,IAAZD,EAAgB,CAKpB,GAHAO,EAAKD,EAAKnY,EAAI,GADdgS,EAAI9nB,EAAI+jB,IAIC,EACR,IAAM9jB,EAAI,EAAGA,EAAI6nB,EAAG7nB,IACnBwU,EAAM1F,EAAGkf,GACTlf,EAAGkf,GAAOlf,EAAGmf,GACbnf,EAAGmf,GAAOzZ,EACVwZ,GAAMN,EACNO,GAAMP,EAGR,GAAK3tB,EAAI+jB,GACR,OAAOhV,EAER,IAAM9O,EAAI6nB,EAAG7nB,EAAID,EAAGC,GAAK8jB,GACxBtP,EAAM1F,EAAGkf,GACTlf,EAAGkf,GAAOlf,EAAGmf,GACbnf,EAAGmf,GAAOzZ,EAEVA,EAAM1F,EAAGkf,EAAG,GACZlf,EAAGkf,EAAG,GAAMlf,EAAGmf,EAAG,GAClBnf,EAAGmf,EAAG,GAAMzZ,EAEZA,EAAM1F,EAAGkf,EAAG,GACZlf,EAAGkf,EAAG,GAAMlf,EAAGmf,EAAG,GAClBnf,EAAGmf,EAAG,GAAMzZ,EAEZwZ,GAAMlK,GACNmK,GAAMnK,GAEP,OAAOhV,CACP,CAED,IADAmf,EAAKD,GAASnY,EAAI,GAAM6X,EAClB1tB,EAAI,EAAGA,EAAID,EAAGC,IACnBwU,EAAM1F,EAAGkf,GACTlf,EAAGkf,GAAOlf,EAAGmf,GACbnf,EAAGmf,GAAOzZ,EACVwZ,GAAMN,EACNO,GAAMP,EAEP,OAAO5e,CACR,CExEA,SAAS+hB,GAAMhb,EAAG/G,EAAG4e,GACpB,OAAOU,GAASvY,EAAG/G,EAAG4e,EAASkD,GAAe/a,EAAG6X,GAClD,CCOA9mB,EAAAnH,GAAA,UAAA2uB,ICpBA,IAAI0C,GAAO,QAwBX,SAASrN,GAAM3U,EAAG+G,EAAG5V,EAAK6Z,EAAQjH,GACjC,IAAI7S,EACJ,IAAMA,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBC,EAAK4S,GAAW/D,EAAG9O,GACnB6S,GAAUiH,CAEZ,CAeA,SAASiX,GAAsBjiB,EAAGuU,EAAOd,EAAOe,EAAKrjB,EAAK6Z,EAAQjH,GACjE,IAAItK,EACAgb,EACAC,EACAxjB,EAOJ,IAHAuI,GADAib,EAAIF,EAAM,KACID,EAEdE,EAAIhB,EAAOe,GACLtjB,EAAI,EAAGA,EAAIujB,EAAGvjB,IACduI,GACJtI,EAAK4S,GAAW/D,EAAG9O,GACnB6S,GAAUiH,GAEVjH,EAASke,GAAsBjiB,EAAG9O,GAAKqjB,EAAOd,EAAOiB,EAAGvjB,EAAK6Z,EAAQjH,GAGvE,OAAOA,CACR,CAqFA,SAASme,GAASliB,EAAGyT,EAAOkC,EAAiBxkB,EAAK6Z,EAAQjH,GACzD,IAAIwQ,EAAQd,EAAM/hB,OAClB,OAAe,IAAV6iB,EACGpjB,EAEO,IAAVojB,GAEJI,GAAM3U,EAAGyT,EAAO,GAAKtiB,EAAK6Z,EAAQjH,GAC3B5S,GAEHwkB,GAlFN,SAAiC3V,EAAGuU,EAAOd,EAAOtiB,EAAK6Z,EAAQjH,GAC9D,IAAIpJ,EACA+K,EACAuG,EACAkW,EACA5H,EACAvlB,EACA9D,EAwBJ,IAfA+wB,GAAsBjiB,EAAGuU,EAAOd,EAAO,EADvC/N,EAAM1U,GAHN2J,EAAMymB,GAAO3N,IAIkC,EAAG,GAMlD8G,EAAK+G,GAAe7N,EAHpBxH,EAAM,aAON0I,GAAMlB,EAAOc,EADb4N,EAAKnxB,GAAOujB,GACY,EAAG,GAC3BwN,GAAMxN,EAAO4N,EAAI,GACjBJ,GAAMxN,EAAOgG,EAAI,GAGXrpB,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB8D,EAAI2sB,GAAWQ,EAAI5H,EAAI,EAAGtO,EAAK/a,EAAG8wB,IAClC7wB,EAAK4S,GAAW2B,EAAK1Q,GACrB+O,GAAUiH,CAEZ,CA+CEoX,CAAwBpiB,EAAGuU,EAAOd,EAAOtiB,EAAK6Z,EAAQjH,GAC/C5S,IAER8wB,GAAsBjiB,EAAGuU,EAAOd,EAAO,EAAGtiB,EAAK6Z,EAAQjH,GAChD5S,EACR,CChJA,SAAS+wB,GAASliB,EAAGyT,EAAOkC,GAE3B,OAAO1K,GAAQjL,EAAGyT,EAAOkC,EADf3kB,GAAOowB,GAAO3N,IACuB,EAAG,EACnD,CCQA3b,EAAAnH,GAAA,SAAAsa,IC9BA,IAAI+W,GAAO,QAuDX,SAASC,GAAsBI,EAAMriB,EAAGuU,EAAOd,EAAOe,EAAK1J,EAAS3Z,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GAC9F,IAAI/L,EACAjB,EACAic,EACAC,EACAxjB,EAOJ,IAHAuI,GADAib,EAAIF,EAAM,KACID,EAEdE,EAAIhB,EAAOe,GACLtjB,EAAI,EAAGA,EAAIujB,EAAGvjB,KACnBsH,EAAMsS,EAAQ/U,SACVE,KAAM/E,GACLuI,GACJtI,EAAK4S,GAAW0B,EAAKzS,KAAMwS,EAASxF,EAAG9O,GAAKsH,EAAK6pB,GACjDte,GAAUiH,GAEVjH,EAASke,GAAsBI,EAAMriB,EAAG9O,GAAKqjB,EAAOd,EAAOiB,EAAGlc,EAAKrH,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GAGhG,OAAOzB,CACR,CAgGA,SAASue,GAAWtiB,EAAGyT,EAAOkC,EAAiBxkB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GACzE,IAAI+O,EAAQd,EAAM/hB,OAClB,OAAe,IAAV6iB,EACGpjB,EAEO,IAAVojB,GArJN,SAAiBvU,EAAG+G,EAAG5V,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GACjD,IAAItU,EACJ,IAAMA,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBC,EAAK4S,GAAW0B,EAAKzS,KAAMwS,EAASxF,EAAG9O,GAAK,CAAEA,GAAK8O,GACnD+D,GAAUiH,CAEZ,CAiJEuX,CAAQviB,EAAGyT,EAAO,GAAKtiB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GAC3CrU,GAEHwkB,GA3FN,SAAiC3V,EAAGuU,EAAOd,EAAOtiB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GAC5E,IAAI7K,EACA+K,EACAuG,EACAkW,EACA5H,EACAvlB,EACA9D,EAuBJ,IAdA+wB,GAAsBjiB,EAAGA,EAAGuU,EAAOd,EAAO,EAAG,GAD7C/N,EAAM1U,GAHN2J,EAAMymB,GAAO3N,IAIyC,EAAG,EAAGhO,EAAMD,GAMlE+U,EAAK+G,GAAe7N,EAHpBxH,EAAM,aAON8V,GAAMxN,EADN4N,EAAKxN,GAAMlB,GACM,GACjBsO,GAAMxN,EAAOgG,EAAI,GAGXrpB,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB8D,EAAI2sB,GAAWQ,EAAI5H,EAAI,EAAGtO,EAAK/a,EAAG8wB,IAClC7wB,EAAK4S,GAAW2B,EAAK1Q,GACrB+O,GAAUiH,CAEZ,CAyDEoX,CAAwBpiB,EAAGuU,EAAOd,EAAOtiB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GAC7DrU,IAER8wB,GAAsBjiB,EAAGA,EAAGuU,EAAOd,EAAO,EAAG,GAAItiB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GACrErU,EACR,CCjKA,SAASmxB,GAAWtiB,EAAGyT,EAAOkC,EAAiBlQ,EAAMD,GAEpD,OAAOyF,GAAQjL,EAAGyT,EAAOkC,EADf3kB,GAAOowB,GAAO3N,IACuB,EAAG,EAAGhO,EAAMD,EAC5D,CCpBA,SAASgd,GAAWxiB,EAAGyT,EAAOkC,GAC7B,IAAIxkB,EACAuiB,EACAC,EACA8B,EACAC,EACAF,EAUJ,GAPA9B,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZtiB,EAAM,GAGDwkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBvkB,EAAI8E,KAAM+J,EAAG0V,GAAMD,IAGrB,OAAOtkB,CACP,CACD,IAAMukB,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKxV,EAAG0V,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAI8E,KAAMuf,EAAIC,IAGhB,OAAOtkB,CACR,CCrBA,SAASsxB,GAAaziB,EAAGyT,EAAOkC,EAAiBlQ,EAAMD,GACtD,IAAIrU,EACAuiB,EACAC,EACA8B,EACAC,EACAF,EAUJ,GAPA9B,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZtiB,EAAM,GAGDwkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBvkB,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAASxF,EAAG0V,GAAMD,GAAM,CAAEC,EAAID,GAAMzV,IAG3D,OAAO7O,CACP,CACD,IAAMukB,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKxV,EAAG0V,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAASgQ,EAAIC,GAAM,CAAEC,EAAID,GAAMzV,IAGtD,OAAO7O,CACR,CCzCA,SAASuxB,GAAW1iB,EAAGyT,EAAOkC,GAC7B,IAAIxkB,EACAuiB,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAlL,EACAgL,EAWJ,GARA9M,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZtiB,EAAM,GAGDwkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtBvvB,EAAI8E,KAAM+J,EAAG0gB,GAAMhL,GAAMD,IAI5B,OAAOtkB,CACP,CACD,IAAMuvB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKxgB,EAAG0gB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAI8E,KAAMuf,EAAIC,IAIjB,OAAOtkB,CACR,CC5BA,SAASwxB,GAAa3iB,EAAGyT,EAAOkC,EAAiBlQ,EAAMD,GACtD,IAAIrU,EACAuiB,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAlL,EACAgL,EAWJ,GARA9M,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZtiB,EAAM,GAGDwkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtBvvB,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAASxF,EAAG0gB,GAAMhL,GAAMD,GAAM,CAAEiL,EAAIhL,EAAID,GAAMzV,IAItE,OAAO7O,CACP,CACD,IAAMuvB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKxgB,EAAG0gB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAASgQ,EAAIC,GAAM,CAAEiL,EAAIhL,EAAID,GAAMzV,IAI3D,OAAO7O,CACR,CCpDA,SAASyxB,GAAW5iB,EAAGyT,EAAOkC,GAC7B,IAAIxkB,EACAuiB,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAtL,EACAgL,EACAI,EAYJ,GATAlN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZtiB,EAAM,GAGDwkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB3vB,EAAI8E,KAAM+J,EAAG8gB,GAAMJ,GAAMhL,GAAMD,IAKnC,OAAOtkB,CACP,CACD,IAAM2vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK5gB,EAAG8gB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAI8E,KAAMuf,EAAIC,IAKlB,OAAOtkB,CACR,CCrCA,SAAS0xB,GAAa7iB,EAAGyT,EAAOkC,EAAiBlQ,EAAMD,GACtD,IAAIrU,EACAuiB,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAtL,EACAgL,EACAI,EAYJ,GATAlN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZtiB,EAAM,GAGDwkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB3vB,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAASxF,EAAG8gB,GAAMJ,GAAMhL,GAAMD,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMzV,IAKjF,OAAO7O,CACP,CACD,IAAM2vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK5gB,EAAG8gB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAASgQ,EAAIC,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMzV,IAKhE,OAAO7O,CACR,CC3DA,SAAS2xB,GAAW9iB,EAAGyT,EAAOkC,GAC7B,IAAIxkB,EACAuiB,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA1L,EACAgL,EACAI,EACAI,EAaJ,GAVAtN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZtiB,EAAM,GAGDwkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB/vB,EAAI8E,KAAM+J,EAAGkhB,GAAMJ,GAAMJ,GAAMhL,GAAMD,IAM1C,OAAOtkB,CACP,CACD,IAAM+vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKhhB,EAAGkhB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAI8E,KAAMuf,EAAIC,IAMnB,OAAOtkB,CACR,CChDA,SAAS4xB,GAAa/iB,EAAGyT,EAAOkC,EAAiBlQ,EAAMD,GACtD,IAAIrU,EACAuiB,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA1L,EACAgL,EACAI,EACAI,EAaJ,GAVAtN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZtiB,EAAM,GAGDwkB,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB/vB,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAASxF,EAAGkhB,GAAMJ,GAAMJ,GAAMhL,GAAMD,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMzV,IAM5F,OAAO7O,CACP,CACD,IAAM+vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKhhB,EAAGkhB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAASgQ,EAAIC,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMzV,IAMrE,OAAO7O,CACR,CC9EA,SAAS6xB,GAAUhjB,GAClB,IAAI7O,EACA8xB,EACAC,EACAxN,EACAD,EAGJ,IADAtkB,EAAM,GACAukB,EAAK,EAAGA,EAAK1V,EAAEtO,OAAQgkB,IAAO,CAGnC,IADAwN,EAAK,GACCzN,GAFNwN,EAAKjjB,EAAG0V,IAEMhkB,OAAO,EAAG+jB,GAAM,EAAGA,IAChCyN,EAAGjtB,KAAMgtB,EAAIxN,IAEdtkB,EAAI8E,KAAMitB,EACV,CACD,OAAO/xB,CACR,CCZA,SAASgyB,GAAUnjB,GAClB,IAAI7O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1BC,EAAI8E,KAAM+sB,GAAUhjB,EAAG9O,KAExB,OAAOC,CACR,CCTA,SAASiyB,GAAUpjB,GAClB,IAAI7O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1BC,EAAI8E,KAAMktB,GAAUnjB,EAAG9O,KAExB,OAAOC,CACR,CCdA,SAASkyB,GAAUrjB,GAClB,IAAI7O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI8O,EAAEtO,OAAO,EAAGR,GAAK,EAAGA,IAC7BC,EAAI8E,KAAM+J,EAAG9O,IAEd,OAAOC,CACR,CCJA,SAASmyB,GAAUtjB,GAClB,IAAI7O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1BC,EAAI8E,KAAMotB,GAAUrjB,EAAG9O,KAExB,OAAOC,CACR,CCTA,SAASoyB,GAAUvjB,GAClB,IAAI7O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1BC,EAAI8E,KAAMqtB,GAAUtjB,EAAG9O,KAExB,OAAOC,CACR,CCbA,SAASqyB,GAAWrH,EAAIC,EAAIqH,GAC3B,IAAIlrB,EACAoC,EACAzJ,EAGJ,IADAyJ,EAAMyjB,IAAQhC,EAAGD,GAAOsH,KACZ,EACX,MAAO,CAAEtH,GAGV,IADA5jB,EAAM,CAAE4jB,GACFjrB,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBqH,EAAItC,KAAMkmB,EAAMsH,EAAUvyB,GAE3B,OAAOqH,CACR,CCLA,SAASH,GAAiBrH,GACzB,OACC0P,GAAc1P,IACduR,GAAYvR,EAAM4G,MAClB2K,GAAYvR,EAAM6G,IAEpB,CCZA,SAAS8rB,GAAmB3yB,GAC3B,OAAA,MAASA,CACV,CCLA,SAAS4yB,GAAU3b,EAAGC,EAAGtN,GACxB,IAAIpC,EACAwO,EACA2N,EACAxjB,EAEJ,GAAa,IAARyJ,EACJ,MAAO,GAQR,IAJA+Z,GAAMzM,EAAED,IADRjB,EAAIpM,EAAM,GAIVpC,EAAM,CAAE4hB,GAAK,GAAInS,IACX9W,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBqH,EAAItC,KAAMkkB,GAAK,GAAInS,EAAG0M,EAAExjB,IAGzB,OADAqH,EAAItC,KAAMkkB,GAAK,GAAIlS,IACZ1P,CACR,CCfA,SAASqrB,GAAO5jB,EAAGyT,EAAOrN,EAAKZ,GAC9B,IAAIkO,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACAjZ,EAKJ,IAHAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZxJ,EAAI,GACEyL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAuN,EAAKjjB,EAAG0V,GACRwN,EAAK,GACCzN,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAGjtB,KAAMmQ,EAAIpT,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEC,EAAID,GAAMzV,IAEnDiK,EAAEhU,KAAMitB,EACR,CACD,OAAOjZ,CACR,CCrBA,SAAS4Z,GAAO7jB,EAAGyT,EAAOrN,EAAKZ,GAC9B,IAAIkO,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA/G,EACA1B,EACAxQ,EAMJ,IAJAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZxJ,EAAI,GACEyW,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAvE,EAAKnc,EAAG0gB,GACRjG,EAAK,GACC/E,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAK,GACCzN,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAGjtB,KAAMmQ,EAAIpT,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEiL,EAAIhL,EAAID,GAAMzV,IAEvDya,EAAGxkB,KAAMitB,EACT,CACDjZ,EAAEhU,KAAMwkB,EACR,CACD,OAAOxQ,CACR,CC/BA,SAAS6Z,GAAO9jB,EAAGyT,EAAOrN,EAAKZ,GAC9B,IAAIkO,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACAC,EACA/G,EACA1B,EACA2B,EACA2H,EACA9Z,EAOJ,IALAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZxJ,EAAI,GACE6W,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA1E,EAAKpc,EAAG8gB,GACRiD,EAAK,GACCrD,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAK,GACC/E,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAK,GACCzN,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAGjtB,KAAMmQ,EAAIpT,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMzV,IAE3Dya,EAAGxkB,KAAMitB,EACT,CACDa,EAAG9tB,KAAMwkB,EACT,CACDxQ,EAAEhU,KAAM8tB,EACR,CACD,OAAO9Z,CACR,CCzCA,SAAS+Z,GAAOhkB,EAAGyT,EAAOrN,EAAKZ,GAC9B,IAAIkO,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACAC,EACA/G,EACA1B,EACA2B,EACA2H,EACAE,EACAC,EACAja,EAQJ,IANAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GACZxJ,EAAI,GACEiX,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA+C,EAAKjkB,EAAGkhB,GACRgD,EAAK,GACCpD,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA1E,EAAK6H,EAAInD,GACTiD,EAAK,GACCrD,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAK,GACC/E,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAK,GACCzN,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAGjtB,KAAMmQ,EAAIpT,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMzV,IAE/Dya,EAAGxkB,KAAMitB,EACT,CACDa,EAAG9tB,KAAMwkB,EACT,CACDyJ,EAAGjuB,KAAM8tB,EACT,CACD9Z,EAAEhU,KAAMiuB,EACR,CACD,OAAOja,CACR,CCjDA,SAASka,GAA0BpzB,GAClC,OAAKA,EAAQ,EACPA,GAASqO,GACN,OAEHrO,GAASqN,GACN,QAEHrN,GAAS0M,GACN,QAED,UAEH1M,GAASoO,GACN,OAEHpO,GAASoN,GACN,QAEHpN,GAASyM,GACN,QAED,SACR,CC5BA,SAAS4mB,GAAWpkB,EAAGqkB,GACtB,IAAItX,EACAuX,EACAnzB,EACAD,EAQJ,IALA6b,EAAO5D,GAAenJ,GACtBskB,EAAOnb,GAAekb,GAGtBlzB,EAAM,GACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrBozB,EAAMD,EAAMnzB,IAChBC,EAAI8E,KAAM8W,EAAM/M,EAAG9O,IAGrB,OAAOC,CACR,CCZA,SAASozB,GAAcvkB,EAAGqkB,EAAM5e,EAAMD,GACrC,IAAIuH,EACAuX,EACAnzB,EACAD,EAQJ,IALA6b,EAAO5D,GAAenJ,GACtBskB,EAAOnb,GAAekb,GAGtBlzB,EAAM,GACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrBozB,EAAMD,EAAMnzB,IAChBC,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAASuH,EAAM/M,EAAG9O,GAAKA,EAAG8O,IAGjD,OAAO7O,CACR,CCgMA,SAASqzB,GAAQxkB,EAAGqkB,EAAM3c,EAAQka,GACjC,IAAI/N,EACA4Q,EACAC,EACA1P,EAGJ,GADAA,EAAItN,EAAOhW,OACG,WAATkwB,GACJ,GAAKnF,GAAY4H,KAAWrP,EAC3B,MAAM,IAAItiB,MAAO,yGAEZ,GAAc,cAATkvB,GACX,GAAW,IAAN5M,GAAWyH,GAAY4H,GAASrP,EACpC,MAAM,IAAItiB,MAAO,sEAEZ,GAAc,qBAATkvB,GACX,GAAW,IAAN5M,GAAWyH,GAAY4H,KAAWrP,EACtC,MAAM,IAAItiB,MAAO,yGAEZ,GAAc,eAATkvB,GACNnF,GAAY4H,GAASrP,EACzB,MAAM,IAAItiB,MAAO,iEAMnB,OAHAmhB,EAAK9K,GAAkB/I,GACvBykB,EAAK1b,GAAkBsb,GACvBK,EAAK3b,GAAkBrB,GAEtBmM,EAAGrL,kBACHic,EAAGjc,kBACHkc,EAAGlc,iBAGE6X,GAAmBxM,EAAGza,QAAWinB,GAAmBqE,EAAGtrB,QAnJ9D,SAAkB4G,EAAGqkB,EAAM3c,GAC1B,IAAIid,EACAL,EACAM,EACA7d,EACA7V,EAOJ,IALAyzB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBvB,EAAIW,EAAOhW,OACXkzB,EAAK,EACC1zB,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,GAAK,EACzBozB,EAAMK,EAAOzzB,EAAE,KACpB8O,EAAG9O,GAAMwW,EAAQkd,GACjB5kB,EAAG9O,EAAE,GAAMwW,EAAQkd,EAAG,GACtBA,GAAOA,EAAG,GAAM7d,EAInB,CAgIG6V,CAASD,GAAoB3c,EAAG,GAAKykB,EAAI9H,GAAoBjV,EAAQ,IAC9D1H,GAEHyN,GAAmBoG,EAAGza,QAAWqU,GAAmBiX,EAAGtrB,QA5G9D,SAAkB4G,EAAGqkB,EAAM3c,GAC1B,IAAIid,EACAL,EACAM,EACA7d,EACA7V,EAOJ,IALAyzB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBvB,EAAIW,EAAOhW,OACXkzB,EAAK,EACC1zB,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACpBozB,EAAMK,EAAOzzB,KAClB8O,EAAG9O,GAAMwW,EAAQkd,GACjBA,GAAO1zB,EAAE,GAAM6V,EAIlB,CA0FGmW,CAASjJ,GAAoBjU,EAAG,GAAKykB,EAAIxQ,GAAoBvM,EAAQ,IAC9D1H,IA5MV,SAAoBA,EAAGqkB,EAAM3c,GAC5B,IAAImF,EACA8X,EACAE,EACAC,EACAR,EACAS,EACAH,EACA7d,EACA7V,EAYJ,IAVA2b,EAAQ7M,EAAEgJ,KACV2b,EAAQN,EAAKrb,KACb6b,EAAQnd,EAAOsB,KAEf8b,EAAO9kB,EAAEsI,UAAW,GACpBgc,EAAOD,EAAK/b,UAAW,GACvByc,EAAOrd,EAAOY,UAAW,GAEzBvB,EAAI8d,EAAMnzB,OACVkzB,EAAK,EACC1zB,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,IACxBozB,EAAMK,EAAOzzB,KAClB4zB,EAAMjY,EAAO3b,EAAG6zB,EAAMF,EAAOD,IAC7BA,GAAOA,EAAG,GAAM7d,EAInB,CAkLEuB,CAAWuL,EAAI4Q,EAAIC,GACZ1kB,IAzPT,SAAkBA,EAAGqkB,EAAM3c,GAC1B,IAAIkd,EACA7d,EACA7V,EAIJ,IAFA6V,EAAIW,EAAOhW,OACXkzB,EAAK,EACC1zB,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACpBmzB,EAAMnzB,KACX8O,EAAG9O,GAAMwW,EAAQkd,GACjBA,GAAOA,EAAG,GAAM7d,EAInB,CA6OCyV,CAASxc,EAAGqkB,EAAM3c,GACX1H,EACR,CCtQA,SAASglB,GAAWhlB,EAAGqkB,GACtB,IAAItX,EACAuX,EACAnzB,EACAD,EAQJ,IALA6b,EAAO5D,GAAenJ,GACtBskB,EAAOnb,GAAekb,GAGtBlzB,EAAM,GACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACpBozB,EAAMD,EAAMnzB,IACjBC,EAAI8E,KAAM8W,EAAM/M,EAAG9O,IAGrB,OAAOC,CACR,CCZA,SAAS8zB,GAA0B7tB,EAAKC,EAAMtG,GAC7CF,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASA,GAEX,CCFA,SAASmY,GAAUlJ,GAClB,IAAI9O,EACJ,IAAMA,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1B,GAAK8O,EAAG9O,GACP,OAAO,EAGT,OAAO,CACR,CC5BA,SAASg0B,GAAOj0B,GACf,IAAIsH,EACArH,EAGJ,GADAqH,EAAM,GACDtH,GAAK,EACT,OAAOsH,EAER,IAAMrH,EAAI,EAAGA,EAAID,EAAE,EAAGC,IACrBqH,EAAItC,KAAM/E,GAEX,OAAOqH,CACR,CCmDA,SAASqkB,GAASzrB,EAAK6X,EAAMgC,EAAQjH,GACpC,IAAI1J,EACA4hB,EACA/qB,EAKJ,IAHA+qB,EAAa,EAATjR,EACJ9Z,EAAa,EAAT6S,EACJ1J,EAAI,EACInJ,GAAK,GAAKA,EAAI8X,EAAKtX,QAC1BsX,EAAM9X,GAAMmJ,EACZ2O,EAAM9X,EAAE,GAAM,EACdA,GAAK+qB,EACL5hB,GAAK,EAEN,OAAOlJ,CACR,CCmJA,SAASg0B,GAAOnlB,EAAGqkB,EAAM3c,EAAQka,GAChC,IAAI/N,EACA4Q,EACAC,EACA1P,EAGJ,GADAA,EAAItN,EAAOhW,OACG,WAATkwB,GACJ,GAAK7E,GAAasH,KAAWrP,EAC5B,MAAM,IAAItiB,MAAO,0GAEZ,GAAc,cAATkvB,GACX,GAAW,IAAN5M,GAAW+H,GAAasH,GAASrP,EACrC,MAAM,IAAItiB,MAAO,sEAEZ,GAAc,qBAATkvB,GACX,GAAW,IAAN5M,GAAW+H,GAAasH,KAAWrP,EACvC,MAAM,IAAItiB,MAAO,0GAEZ,GAAc,eAATkvB,GACN7E,GAAasH,GAASrP,EAC1B,MAAM,IAAItiB,MAAO,iEAMnB,OAHAmhB,EAAK9K,GAAkB/I,GACvBykB,EAAK1b,GAAkBsb,GACvBK,EAAK3b,GAAkBrB,GAEtBmM,EAAGrL,kBACHic,EAAGjc,kBACHkc,EAAGlc,iBAGE6X,GAAmBxM,EAAGza,QAAWinB,GAAmBqE,EAAGtrB,QAnJ9D,SAAkB4G,EAAGqkB,EAAM3c,GAC1B,IAAIid,EACAL,EACAM,EACA7d,EACA7V,EAOJ,IALAyzB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBvB,EAAIW,EAAOhW,OACXkzB,EAAK,EACC1zB,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,GAAK,EAC1BozB,EAAMK,EAAOzzB,EAAE,KACnB8O,EAAG9O,GAAMwW,EAAQkd,GACjB5kB,EAAG9O,EAAE,GAAMwW,EAAQkd,EAAG,GACtBA,GAAOA,EAAG,GAAM7d,EAInB,CAgIG6V,CAASD,GAAoB3c,EAAG,GAAKykB,EAAI9H,GAAoBjV,EAAQ,IAC9D1H,GAEHyN,GAAmBoG,EAAGza,QAAWqU,GAAmBiX,EAAGtrB,QA5G9D,SAAkB4G,EAAGqkB,EAAM3c,GAC1B,IAAIid,EACAL,EACAM,EACA7d,EACA7V,EAOJ,IALAyzB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBvB,EAAIW,EAAOhW,OACXkzB,EAAK,EACC1zB,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrBozB,EAAMK,EAAOzzB,KACjB8O,EAAG9O,GAAMwW,EAAQkd,GACjBA,GAAO1zB,EAAE,GAAM6V,EAIlB,CA0FGmW,CAASjJ,GAAoBjU,EAAG,GAAKykB,EAAIxQ,GAAoBvM,EAAQ,IAC9D1H,IA5MV,SAAoBA,EAAGqkB,EAAM3c,GAC5B,IAAImF,EACA8X,EACAE,EACAC,EACAR,EACAS,EACAH,EACA7d,EACA7V,EAYJ,IAVA2b,EAAQ7M,EAAEgJ,KACV2b,EAAQN,EAAKrb,KACb6b,EAAQnd,EAAOsB,KAEf8b,EAAO9kB,EAAEsI,UAAW,GACpBgc,EAAOD,EAAK/b,UAAW,GACvByc,EAAOrd,EAAOY,UAAW,GAEzBvB,EAAI8d,EAAMnzB,OACVkzB,EAAK,EACC1zB,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,IACzBozB,EAAMK,EAAOzzB,KACjB4zB,EAAMjY,EAAO3b,EAAG6zB,EAAMF,EAAOD,IAC7BA,GAAOA,EAAG,GAAM7d,EAInB,CAkLEuB,CAAWuL,EAAI4Q,EAAIC,GACZ1kB,IAzPT,SAAkBA,EAAGqkB,EAAM3c,GAC1B,IAAIkd,EACA7d,EACA7V,EAIJ,IAFA6V,EAAIW,EAAOhW,OACXkzB,EAAK,EACC1zB,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrBmzB,EAAMnzB,KACV8O,EAAG9O,GAAMwW,EAAQkd,GACjBA,GAAOA,EAAG,GAAM7d,EAInB,CA6OCyV,CAASxc,EAAGqkB,EAAM3c,GACX1H,EACR,CCxQA,SAASolB,GAAY5sB,EAAK6a,GACzB,OAAK7a,EAAM,EACH,EAEHA,EAAM6a,EACHA,EAED7a,CACR,CCRA,SAAS6sB,GAAW7sB,EAAK6a,GACxB,IAAIiS,EAAMjS,EAAM,EAChB,OAAK7a,EAAM,IACVA,GAAO8sB,GACI,GAEG,KADb9sB,GAAO8sB,KAEN9sB,GAAO8sB,GAGF9sB,GAEHA,EAAM6a,IACV7a,GAAO8sB,GACIjS,IACV7a,GAAO8sB,GAED9sB,GAEDA,CACR,CCpBA,SAAS+sB,GAAgB/sB,EAAK6a,GAC7B,OAAK7a,EAAM,GACVA,GAAO6a,EAAM,GACF,GACF,EAEF7a,EAEHA,EAAM6a,GACF,EAEF7a,CACR,CCNA,SAAS8Q,GAAStJ,GACjB,IAAIrI,EACAgD,EACA4N,EAEJ,IAAM9H,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,oEAAqE8J,IAYnG,OATAuI,EAAKnP,GAAO4G,GAGP5H,GAAiB4H,KACrBrI,EAAMiO,GAAgB2C,IAGvB5N,EAAMqF,EAAEtO,YAES,IAARiG,EAYT,SAAmB5G,GAClB,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAK8O,EAAG9O,KAAQH,EACf,OAAO,EAGT,OAAO,CACP,EAQD,SAAoBA,GACnB,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAKyG,EAAKqI,EAAG9O,KAAQH,EACpB,OAAO,EAGT,OAAO,CACP,CACF,CCxBA+G,EAAAnH,GAAA,SAAAsa,ICZAnT,EAAAnH,GAAA,UCXA,SAAoBqP,EAAGyT,EAAOkC,EAAiBxkB,EAAK6Z,EAAQjH,GAC3D,IAAI2P,EACAC,EACA8B,EACAC,EACAF,EACAyH,EAQJ,GALAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBvkB,EAAK8rB,GAAOjd,EAAG0V,GAAMD,GACrBwH,GAAMjS,EAGR,OAAO7Z,CACP,CACD,IAAMukB,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKxV,EAAG0V,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAK8rB,GAAOzH,EAAIC,GAChBwH,GAAMjS,EAGR,OAAO7Z,CACR,ICRA2G,EAAAnH,GAAA,UCbA,SAAsBqP,EAAGyT,EAAOkC,EAAiBxkB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GAC3E,IAAIkO,EACAC,EACA8B,EACAC,EACAF,EACAyH,EAQJ,GALAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBvkB,EAAK8rB,GAAOxX,EAAKzS,KAAMwS,EAASxF,EAAG0V,GAAMD,GAAM,CAAEC,EAAID,GAAMzV,GAC3Did,GAAMjS,EAGR,OAAO7Z,CACP,CACD,IAAMukB,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKxV,EAAG0V,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAK8rB,GAAOxX,EAAKzS,KAAMwS,EAASgQ,EAAIC,GAAM,CAAEC,EAAID,GAAMzV,GACtDid,GAAMjS,EAGR,OAAO7Z,CACR,IC/BA2G,EAAAnH,GAAA,UCVA,SAAoBqP,EAAGyT,EAAOkC,EAAiBxkB,EAAK6Z,EAAQjH,GAC3D,IAAI2P,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAlL,EACAgL,EACAvD,EASJ,GANAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtBvvB,EAAK8rB,GAAOjd,EAAG0gB,GAAMhL,GAAMD,GAC3BwH,GAAMjS,EAIT,OAAO7Z,CACP,CACD,IAAMuvB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKxgB,EAAG0gB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAK8rB,GAAOzH,EAAIC,GAChBwH,GAAMjS,EAIT,OAAO7Z,CACR,IClBA2G,EAAAnH,GAAA,UCVA,SAAsBqP,EAAGyT,EAAOkC,EAAiBxkB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GAC3E,IAAIkO,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAlL,EACAgL,EACAvD,EASJ,GANAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtBvvB,EAAK8rB,GAAOxX,EAAKzS,KAAMwS,EAASxF,EAAG0gB,GAAMhL,GAAMD,GAAM,CAAEiL,EAAIhL,EAAID,GAAMzV,GACrEid,GAAMjS,EAIT,OAAO7Z,CACP,CACD,IAAMuvB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKxgB,EAAG0gB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAK8rB,GAAOxX,EAAKzS,KAAMwS,EAASgQ,EAAIC,GAAM,CAAEiL,EAAIhL,EAAID,GAAMzV,GAC1Did,GAAMjS,EAIT,OAAO7Z,CACR,ICzCA2G,EAAAnH,GAAA,UCXA,SAAoBqP,EAAGyT,EAAOkC,EAAiBxkB,EAAK6Z,EAAQjH,GAC3D,IAAI2P,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAtL,EACAgL,EACAI,EACA3D,EAUJ,GAPAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB3vB,EAAK8rB,GAAOjd,EAAG8gB,GAAMJ,GAAMhL,GAAMD,GACjCwH,GAAMjS,EAKV,OAAO7Z,CACP,CACD,IAAM2vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK5gB,EAAG8gB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAK8rB,GAAOzH,EAAIC,GAChBwH,GAAMjS,EAKV,OAAO7Z,CACR,IC1BA2G,EAAAnH,GAAA,UCXA,SAAsBqP,EAAGyT,EAAOkC,EAAiBxkB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GAC3E,IAAIkO,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAtL,EACAgL,EACAI,EACA3D,EAUJ,GAPAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB3vB,EAAK8rB,GAAOxX,EAAKzS,KAAMwS,EAASxF,EAAG8gB,GAAMJ,GAAMhL,GAAMD,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMzV,GAC/Eid,GAAMjS,EAKV,OAAO7Z,CACP,CACD,IAAM2vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAK5gB,EAAG8gB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAK8rB,GAAOxX,EAAKzS,KAAMwS,EAASgQ,EAAIC,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMzV,GAC9Did,GAAMjS,EAKV,OAAO7Z,CACR,IClDA2G,EAAAnH,GAAA,UCTA,SAAoBqP,EAAGyT,EAAOkC,EAAiBxkB,EAAK6Z,EAAQjH,GAC3D,IAAI2P,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA1L,EACAgL,EACAI,EACAI,EACA/D,EAWJ,GARAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB/vB,EAAK8rB,GAAOjd,EAAGkhB,GAAMJ,GAAMJ,GAAMhL,GAAMD,GACvCwH,GAAMjS,EAMX,OAAO7Z,CACP,CACD,IAAM+vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKhhB,EAAGkhB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAK8rB,GAAOzH,EAAIC,GAChBwH,GAAMjS,EAMX,OAAO7Z,CACR,ICrCA2G,EAAAnH,GAAA,UCXA,SAAsBqP,EAAGyT,EAAOkC,EAAiBxkB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GAC3E,IAAIkO,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA1L,EACAgL,EACAI,EACAI,EACA/D,EAWJ,GARAvJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZwJ,EAAKlZ,EACA4R,EAAkB,CACtB,IAAMF,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB,IAAMgL,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB,IAAMI,EAAK,EAAGA,EAAKD,EAAIC,IACtB/vB,EAAK8rB,GAAOxX,EAAKzS,KAAMwS,EAASxF,EAAGkhB,GAAMJ,GAAMJ,GAAMhL,GAAMD,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMzV,GACzFid,GAAMjS,EAMX,OAAO7Z,CACP,CACD,IAAM+vB,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKhhB,EAAGkhB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAEtB,IADAF,EAAKI,EAAIF,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAEtB,IADAF,EAAKgL,EAAI9K,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBtkB,EAAK8rB,GAAOxX,EAAKzS,KAAMwS,EAASgQ,EAAIC,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMzV,GAClEid,GAAMjS,EAMX,OAAO7Z,CACR,ICtDA2G,EAAAnH,GAAA,UCdA,SAAgBqP,EAAGiK,EAAGwJ,EAAOrN,EAAKZ,GACjC,IAAIkO,EACAC,EACA8B,EACAC,EACAuN,EACAC,EAIJ,GAFAxP,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACPC,GAAM,GAAKC,GAAM,EACrB,OAAO1J,EAER,IAAMyL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAKjjB,EAAG0V,GACRwN,EAAKjZ,EAAGyL,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAIpT,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEC,EAAID,GAAMzV,GAGtD,OAAOiK,CACR,ICPAnS,EAAAnH,GAAA,UCdA,SAAgBqP,EAAGiK,EAAGwJ,EAAOrN,EAAKZ,GACjC,IAAIkO,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA/G,EACA1B,EAKJ,GAHA/G,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,EAChC,OAAOxW,EAER,IAAMyW,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKnc,EAAG0gB,GACRjG,EAAKxQ,EAAGyW,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAIpT,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEiL,EAAIhL,EAAID,GAAMzV,GAI3D,OAAOiK,CACR,IChBAnS,EAAAnH,GAAA,UCdA,SAAgBqP,EAAGiK,EAAGwJ,EAAOrN,EAAKZ,GACjC,IAAIkO,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACAC,EACA/G,EACA1B,EACA2B,EACA2H,EAMJ,GAJArQ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,EAC3C,OAAO5W,EAER,IAAM6W,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAKpc,EAAG8gB,GACRiD,EAAK9Z,EAAG6W,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAIpT,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAMzV,GAKhE,OAAOiK,CACR,ICzBAnS,EAAAnH,GAAA,UCdA,SAAgBqP,EAAGiK,EAAGwJ,EAAOrN,EAAKZ,GACjC,IAAIkO,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACAC,EACA/G,EACA1B,EACA2B,EACA2H,EACAE,EACAC,EAOJ,GALAxQ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,EACtD,OAAOhX,EAER,IAAMiX,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA+C,EAAKjkB,EAAGkhB,GACRgD,EAAKja,EAAGiX,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAIpT,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAMzV,GAMrE,OAAOiK,CACR,IC9CAnS,EAAAnH,GAAA,UCgLA,SAAiBqP,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACtC,IAAI8P,EACA4Q,EACAe,EAKJ,OAHA3R,EAAK9K,GAAkB/I,GACvBykB,EAAK1b,GAAkBsb,GACvBmB,EAAKzc,GAAkB5X,GAEtB0iB,EAAGrL,kBACHic,EAAGjc,kBACHgd,EAAGhd,iBAIF6X,GAAmBxM,EAAGza,QACtBinB,GAAmBmF,EAAGpsB,QA1GzB,SAAkB4G,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACvC,IAAI4gB,EACAL,EACArH,EACAwI,EACAv0B,EACA8D,EAOJ,IALA2vB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBmd,EAAc,EAATza,EACLiS,EAAc,EAATlZ,EACC7S,EAAI,EAAGA,EAAIyzB,EAAMjzB,OAAQR,IACzBozB,EAAMK,EAAOzzB,KACjB8D,EAAQ,EAAJ9D,EACJC,EAAK8rB,GAAOjd,EAAGhL,GACf7D,EAAK8rB,EAAG,GAAMjd,EAAGhL,EAAE,GACnBioB,GAAMwI,EAIT,CAsFG7I,CAAS9Y,GAAa9D,EAAG,GAAKykB,EAAI3gB,GAAa3S,EAAK,GAAK6Z,EAAQjH,GAC1D5S,GAGPsc,GAAmBoG,EAAGza,QACtBqU,GAAmB+X,EAAGpsB,QAlEzB,SAAkB4G,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACvC,IAAI4gB,EACAL,EACArH,EACA/rB,EAMJ,IAJAyzB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvB2U,EAAKlZ,EACC7S,EAAI,EAAGA,EAAIyzB,EAAMjzB,OAAQR,IACzBozB,EAAMK,EAAOzzB,KACjBC,EAAK8rB,GAAOjd,EAAG9O,GACf+rB,GAAMjS,EAIT,CAmDGkS,CAASjJ,GAAoBjU,EAAG,GAAKykB,EAAIxQ,GAAoB9iB,EAAK,GAAK6Z,EAAQjH,GACxE5S,IAvKV,SAAoB6O,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACzC,IAAI8I,EACA8X,EACAe,EACA3Y,EACAuX,EACAqB,EACA1I,EACA/rB,EAWJ,IATA2b,EAAQ7M,EAAEgJ,KACV2b,EAAQN,EAAKrb,KACb0c,EAAQv0B,EAAI6X,KAEZ+D,EAAO/M,EAAEsI,UAAW,GACpBgc,EAAOD,EAAK/b,UAAW,GACvBqd,EAAOx0B,EAAImX,UAAW,GAEtB2U,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,IACzBozB,EAAMK,EAAOzzB,KACjBy0B,EAAMD,EAAOzI,EAAIlQ,EAAMF,EAAO3b,IAC9B+rB,GAAMjS,EAIT,CA+IE1C,CAAWuL,EAAI4Q,EAAIe,EAAIxa,EAAQjH,GACxB5S,IAnNT,SAAkB6O,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACvC,IAAIkZ,EACA/rB,EAGJ,IADA+rB,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrBmzB,EAAMnzB,KACVC,EAAK8rB,GAAOjd,EAAG9O,GACf+rB,GAAMjS,EAIT,CAyMCwR,CAASxc,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACxB5S,EACR,ICzMA2G,EAAAnH,GAAA,UC6FA,SAAiBqP,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GACpD,IAAIqO,EACA4Q,EACAe,EAKJ,OAHA3R,EAAK9K,GAAkB/I,GACvBykB,EAAK1b,GAAkBsb,GACvBmB,EAAKzc,GAAkB5X,GAEtB0iB,EAAGrL,kBACHic,EAAGjc,kBACHgd,EAAGhd,kBArEL,SAAoBxI,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GACvD,IAAIqH,EACA8X,EACAe,EACA3Y,EACAuX,EACAqB,EACA1I,EACA/rB,EAWJ,IATA2b,EAAQ7M,EAAEgJ,KACV2b,EAAQN,EAAKrb,KACb0c,EAAQv0B,EAAI6X,KAEZ+D,EAAO/M,EAAEsI,UAAW,GACpBgc,EAAOD,EAAK/b,UAAW,GACvBqd,EAAOx0B,EAAImX,UAAW,GAEtB2U,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,IACzBozB,EAAMK,EAAOzzB,KACjBy0B,EAAMD,EAAOzI,EAAIxX,EAAKzS,KAAMwS,EAASuH,EAAMF,EAAO3b,GAAKA,EAAG2b,IAC1DoQ,GAAMjS,EAIT,CA6CE1C,CAAWuL,EAAI4Q,EAAIe,EAAIxa,EAAQjH,EAAQ0B,EAAMD,GACtCrU,IAvHT,SAAkB6O,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GACrD,IAAIyX,EACA/rB,EAGJ,IADA+rB,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrBmzB,EAAMnzB,KACVC,EAAK8rB,GAAOxX,EAAKzS,KAAMwS,EAASxF,EAAG9O,GAAKA,EAAG8O,GAC3Cid,GAAMjS,EAIT,CA6GCwR,CAASxc,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,EAAQ0B,EAAMD,GACtCrU,EACR,ICvHA2G,EAAAnH,GAAA,UCgLA,SAAiBqP,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACtC,IAAI8P,EACA4Q,EACAe,EAKJ,OAHA3R,EAAK9K,GAAkB/I,GACvBykB,EAAK1b,GAAkBsb,GACvBmB,EAAKzc,GAAkB5X,GAEtB0iB,EAAGrL,kBACHic,EAAGjc,kBACHgd,EAAGhd,iBAIF6X,GAAmBxM,EAAGza,QACtBinB,GAAmBmF,EAAGpsB,QA1GzB,SAAkB4G,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACvC,IAAI4gB,EACAL,EACArH,EACAwI,EACAv0B,EACA8D,EAOJ,IALA2vB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvBmd,EAAc,EAATza,EACLiS,EAAc,EAATlZ,EACC7S,EAAI,EAAGA,EAAIyzB,EAAMjzB,OAAQR,IACxBozB,EAAMK,EAAOzzB,KAClB8D,EAAQ,EAAJ9D,EACJC,EAAK8rB,GAAOjd,EAAGhL,GACf7D,EAAK8rB,EAAG,GAAMjd,EAAGhL,EAAE,GACnBioB,GAAMwI,EAIT,CAsFG7I,CAAS9Y,GAAa9D,EAAG,GAAKykB,EAAI3gB,GAAa3S,EAAK,GAAK6Z,EAAQjH,GAC1D5S,GAGPsc,GAAmBoG,EAAGza,QACtBqU,GAAmB+X,EAAGpsB,QAlEzB,SAAkB4G,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACvC,IAAI4gB,EACAL,EACArH,EACA/rB,EAMJ,IAJAyzB,EAAQN,EAAKrb,KACbsb,EAAOD,EAAK/b,UAAW,GAEvB2U,EAAKlZ,EACC7S,EAAI,EAAGA,EAAIyzB,EAAMjzB,OAAQR,IACxBozB,EAAMK,EAAOzzB,KAClBC,EAAK8rB,GAAOjd,EAAG9O,GACf+rB,GAAMjS,EAIT,CAmDGkS,CAASjJ,GAAoBjU,EAAG,GAAKykB,EAAIxQ,GAAoB9iB,EAAK,GAAK6Z,EAAQjH,GACxE5S,IAvKV,SAAoB6O,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACzC,IAAI8I,EACA8X,EACAe,EACA3Y,EACAuX,EACAqB,EACA1I,EACA/rB,EAWJ,IATA2b,EAAQ7M,EAAEgJ,KACV2b,EAAQN,EAAKrb,KACb0c,EAAQv0B,EAAI6X,KAEZ+D,EAAO/M,EAAEsI,UAAW,GACpBgc,EAAOD,EAAK/b,UAAW,GACvBqd,EAAOx0B,EAAImX,UAAW,GAEtB2U,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,IACxBozB,EAAMK,EAAOzzB,KAClBy0B,EAAMD,EAAOzI,EAAIlQ,EAAMF,EAAO3b,IAC9B+rB,GAAMjS,EAIT,CA+IE1C,CAAWuL,EAAI4Q,EAAIe,EAAIxa,EAAQjH,GACxB5S,IAnNT,SAAkB6O,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACvC,IAAIkZ,EACA/rB,EAGJ,IADA+rB,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACpBmzB,EAAMnzB,KACXC,EAAK8rB,GAAOjd,EAAG9O,GACf+rB,GAAMjS,EAIT,CAyMCwR,CAASxc,EAAGqkB,EAAMlzB,EAAK6Z,EAAQjH,GACxB5S,EACR,ICvNA2G,EAAAnH,GAAA,UrCgIA,SAAiBQ,EAAK6Z,EAAQjH,GAC7B,IAAI3M,EAAM2R,GAAkB5X,GAC5B,OAAKiG,EAAIoR,iBAEHhF,GAAmBrS,GAChByrB,GAASzrB,EAAKiU,GAAgBjU,EAAK,GAAK6Z,EAAQjH,GAEnDR,GAAkBpS,GACfyrB,GAASzrB,EAAKgU,GAAehU,EAAK,GAAK6Z,EAAQjH,GAlDzD,SAAoB5S,EAAK6Z,EAAQjH,GAChC,IAAIiF,EACApR,EACAyC,EACAnJ,EAOJ,IALA8X,EAAO7X,EAAI6X,KACXpR,EAAMzG,EAAImX,UAAW,GAErBpX,EAAI6S,EACJ1J,EAAI,EACInJ,GAAK,GAAKA,EAAI8X,EAAKtX,QAC1BkG,EAAKoR,EAAM9X,EAAGmJ,GACdnJ,GAAK8Z,EACL3Q,GAAK,EAEN,OAAO2O,CACR,CAmCSV,CAAWlR,EAAK4T,EAAQjH,GAzIjC,SAAkB5S,EAAK6Z,EAAQjH,GAC9B,IAAI1J,EACAnJ,EAIJ,IAFAA,EAAI6S,EACJ1J,EAAI,EACInJ,GAAK,GAAKA,EAAIC,EAAIO,QACzBP,EAAKD,GAAMmJ,EACXnJ,GAAK8Z,EACL3Q,GAAK,EAEN,OAAOlJ,CACR,CA+HQqrB,CAASrrB,EAAK6Z,EAAQjH,EAC9B,IsCvJAjM,GCAA,SAAmBkI,EAAGjP,GACrB,IAAI4J,EACAhD,EACA4Q,EACArX,EAeJ,IAZAqX,EAAKnP,GAAO4G,GAIXrI,EADIS,GAAiB4H,GACf4F,GAAgB2C,GAEhBpP,GAAQoP,GAGf5N,EAAMqF,EAAEtO,OAGFR,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB,GAAKyG,EAAKqI,EAAG9O,KAAQH,EACpB,OAAO,EAGT,OAAO,CACR,GDzBA,UAAAuY,gDELA,SAASsc,KACR,OAAOC,GAAM9vB,OACd,CCGA+B,EAAA8tB,GAAA,QCLA,WAEC,MAAO,CACNE,MAAS,EACTC,MAAS,EACTC,KAAQ,EACRzN,UAAa,EAEf,ICKA,IAAI0N,GAAc5c,GAAUuc,MClBxB9T,GAAQ,CACXkU,KAAQX,GACRU,MAASX,GACT7M,UAoDD,SAAyB/f,EAAK6a,GAC7B,IAAI1L,EAAQ4Q,GAAW/f,EAAK6a,GAC5B,GAAK1L,EAAQ,GAAKA,EAAQ0L,EACzB,MAAM,IAAInO,WAAYhP,EAAQ,yFAA0Fmd,EAAK7a,IAE9H,OAAOmP,CACR,EAzDCme,MAyBD,SAA6BttB,EAAK6a,GACjC,GAAK7a,EAAM,GAAKA,EAAM6a,EACrB,MAAM,IAAInO,WAAYhP,EAAQ,yFAA0Fmd,EAAK7a,IAE9H,OAAOA,CACR,GAuFA,SAAS8Q,GAASsY,GACjB,IAAMqE,GAAarE,GAClB,MAAM,IAAI3sB,UAAWiB,EAAQ,iFAAkF0rB,IAEhH,OAAO9P,GAAO8P,EACf,CC6GA,SAASsE,GAAKlmB,EAAG8K,EAASpD,EAAQka,GACjC,IAAIuE,EACAnb,EACAqI,EACAQ,EACAoJ,EACAyH,EAGJ,GAAK5Z,EAAQpZ,OAAS,EAErB,GAAKgW,EAAOhW,SAAWoZ,EAAQpZ,OAC9BsZ,EAAS,MACH,IAAuB,IAAlBtD,EAAOhW,OAGlB,MAAM,IAAIgB,MAAOwD,EAAQ,sIAAuIwR,EAAOhW,OAAQoZ,EAAQpZ,SAFvLsZ,EAAS,CAGT,CAWF,OARAmb,EAAWtE,GAAKD,GAGhBvO,EAAMrT,EAAEtO,OAAS,EAEjBmiB,EAAK9K,GAAkB/I,GACvBid,EAAKlU,GAAkB+B,GACvB4Z,EAAK3b,GAAkBrB,GAEtBmM,EAAGrL,kBACHyU,EAAGzU,kBACHkc,EAAGlc,iBAGE6X,GAAmBxM,EAAGza,QAAWinB,GAAmBqE,EAAGtrB,QA7I9D,SAAkB4G,EAAG8K,EAASpD,EAAQsD,EAAQmb,EAAUC,GACvD,IAAIC,EACAC,EACA1B,EACA2B,EACAr1B,EAEAge,EAOJ,IALAmX,EAAQvb,EAAQ9B,KAChBsd,EAAOxb,EAAQxC,UAAW,GAE1Bie,EAAc,EAATvb,EACL4Z,EAAK,EACC1zB,EAAI,EAAGA,EAAIm1B,EAAM30B,OAAQR,IAG9B8O,EADAkP,EAAQ,EADJiX,EAAUG,EAAMD,EAAOn1B,GAAKk1B,IAEvB1e,EAAQkd,GACjB5kB,EAAGkP,EAAE,GAAMxH,EAAQkd,EAAG,GACtBA,GAAM2B,CAGR,CAwHG3J,CAASD,GAAoB3c,EAAG,GAAKid,EAAIN,GAAoBjV,EAAQ,GAAKsD,EAAQmb,EAAU9S,GACrFrT,GAEHyN,GAAmBoG,EAAGza,QAAWqU,GAAmBiX,EAAGtrB,QA9F9D,SAAkB4G,EAAG8K,EAASpD,EAAQsD,EAAQmb,EAAUC,GACvD,IAAIC,EACAC,EACA1B,EACA1zB,EAOJ,IAJAm1B,EAAQvb,EAAQ9B,KAChBsd,EAAOxb,EAAQxC,UAAW,GAE1Bsc,EAAK,EACC1zB,EAAI,EAAGA,EAAIm1B,EAAM30B,OAAQR,IAE9B8O,EADImmB,EAAUG,EAAMD,EAAOn1B,GAAKk1B,IACvB1e,EAAQkd,GACjBA,GAAM5Z,CAGR,CA8EGkS,CAASjJ,GAAoBjU,EAAG,GAAKid,EAAIhJ,GAAoBvM,EAAQ,GAAKsD,EAAQmb,EAAU9S,GACrFrT,IA1MV,SAAoBA,EAAG8K,EAASpD,EAAQsD,EAAQmb,EAAUC,GACzD,IAAIvZ,EACAwZ,EACAxB,EACAC,EACAwB,EACAvB,EACAH,EACA1zB,EAYJ,IATA2b,EAAQ7M,EAAEgJ,KACVqd,EAAQvb,EAAQ9B,KAChB6b,EAAQnd,EAAOsB,KAEf8b,EAAO9kB,EAAEsI,UAAW,GACpBge,EAAOxb,EAAQxC,UAAW,GAC1Byc,EAAOrd,EAAOY,UAAW,GAEzBsc,EAAK,EACC1zB,EAAI,EAAGA,EAAIm1B,EAAM30B,OAAQR,IAE9B4zB,EAAMjY,EADFsZ,EAAUG,EAAMD,EAAOn1B,GAAKk1B,GAChBrB,EAAMF,EAAOD,IAC7BA,GAAM5Z,CAGR,CAkLE1C,CAAWuL,EAAIoJ,EAAIyH,EAAI1Z,EAAQmb,EAAU9S,GAClCrT,IA3PT,SAAkBA,EAAG8K,EAASpD,EAAQsD,EAAQmb,EAAUC,GACvD,IAAIxB,EACA1zB,EAIJ,IADA0zB,EAAK,EACC1zB,EAAI,EAAGA,EAAI4Z,EAAQpZ,OAAQR,IAEhC8O,EADImmB,EAAUrb,EAAS5Z,GAAKk1B,IACnB1e,EAAQkd,GACjBA,GAAM5Z,CAGR,CAiPCwR,CAASxc,EAAG8K,EAASpD,EAAQsD,EAAQmb,EAAU9S,GACxCrT,EACR,CCxNAlI,GClBA,SAAcU,EAAK6a,EAAKuO,GACvB,IAAIja,EACJ,GAAc,UAATia,EACJ,OAAOwD,GAAY5sB,EAAK6a,GAEzB,GAAc,SAATuO,EACJ,OAAOyD,GAAW7sB,EAAK6a,GAMxB,GAJA1L,EAAQnP,EACM,cAATopB,IACJja,EAAQ4d,GAAgB5d,EAAO0L,IAE3B1L,EAAQ,GAAKA,EAAQ0L,EACzB,MAAM,IAAInO,WAAYhP,EAAQ,yFAA0Fmd,EAAK7a,IAE9H,OAAOmP,CACR,GDEA,UAAA2B,IEtEA,IAAIkd,GAAanyB,MAAMtC,UAAUgE,MA4GjC,SAASA,GAAOiK,EAAG+F,EAAOI,GACzB,IAAI/O,EACJ,OAzFD,SAAoBA,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CAuFMC,CAAW1mB,EAAG,SACXA,EAAEjK,MAAOgQ,EAAOI,IAExB/O,EAAM2R,GAAkB/I,IACfwI,iBApDV,SAAoBxI,EAAG+F,EAAOI,GAC7B,IAAI6C,EACArR,EACAxG,EACAD,EAKJ,IAHA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GACnBnX,EAAM,GACAD,EAAI6U,EAAO7U,EAAIiV,EAAKjV,IACzBC,EAAI8E,KAAM0B,EAAKqR,EAAM9X,IAEtB,OAAOC,CACR,CAwCSmX,CAAWlR,EAAK2O,EAAOI,GA3EhC,SAAkBnG,EAAG+F,EAAOI,GAC3B,OAAOqgB,GAAWxzB,KAAMgN,EAAG+F,EAAOI,EACnC,CA4EQhP,CAAS6I,EAAG+F,EAAOI,EAC3B,CC3GA,SAASmO,GAASqS,EAAOpS,EAAOd,EAAOe,EAAK7M,GAC3C,IAAIif,EACAC,EACA11B,EACAujB,EACAD,EACAvjB,EAGJ,GADAujB,EAAIhB,EAAOe,GACNA,IAAQD,EAAQ,EACpB,OAAOxe,GAAO4wB,EAAOhf,EAAOA,EAAQ8M,GAKrC,IADAmS,EAAW,EACL11B,EAFNwjB,EAAIF,EAAM,EAEGtjB,EAAIuiB,EAAM/hB,OAAQR,IAC9B01B,GAAYnT,EAAOviB,GAIpB,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAIujB,EAAGvjB,IACnB21B,EAAWvS,GAASqS,EAAOpS,EAAOd,EAAOiB,EAAG/M,GAC5CxW,EAAI8E,KAAM4wB,GACVlf,GAASif,EAEV,OAAOz1B,CACR,CCbA,SAAS21B,GAAe9mB,GACvB,IAAIuI,EAAKnP,GAAO4G,GAChB,OAAK5H,EAAiB4H,GACdyI,EAAgBF,GAEjBjP,EAAQiP,EAChB,CCtBA,IAAA6K,GAAA,CAAA,EAUAtb,EAAAsb,GAAA,cCAA,SAAqBrM,EAAGtB,EAAMD,GAC7B,IAAIjN,EACAid,EACAtkB,EACA8D,EAIJ,IADAuD,EAAM,GACArH,EAAI,EAAGA,EAAI6V,EAAG7V,IAAM,CAEzB,IADAskB,EAAK,GACCxgB,EAAI,EAAGA,EAAI+R,EAAG/R,IACd9D,EAAI8D,EACRwgB,EAAGvf,KAAMsC,EAAKvD,GAAK9D,IAEnBskB,EAAGvf,KAAMwP,EAAKzS,KAAMwS,EAAS,CAAEtU,EAAG8D,KAGpCuD,EAAItC,KAAMuf,EACV,CACD,OAAOjd,CACR,IC9BA,IAAA6a,GAAA,CAAA,ECOA,SAAS2T,GAAM/mB,EAAG8K,EAAS8W,GAC1B,IAAIuE,EACApZ,EACAuZ,EACAn1B,EACAkiB,EACAniB,EACA8D,EAcJ,IAXA+X,EAAO5D,GAAenJ,GACtBsmB,EAAOnd,GAAe2B,GAGtBqb,EAAWtE,GAAKD,GAGhBvO,EAAMrT,EAAEtO,OAAS,EAGjBP,EAAM,GACAD,EAAI,EAAGA,EAAI4Z,EAAQpZ,OAAQR,IAChC8D,EAAImxB,EAAUG,EAAMxb,EAAS5Z,GAAKmiB,GAClCliB,EAAI8E,KAAM8W,EAAM/M,EAAGhL,IAEpB,OAAO7D,CACR,CDvBA2G,EAAAsb,GAAA,cEEA,SAAqBrM,EAAGmI,EAAGqG,EAAM9P,EAAMD,GACtC,IAAIjN,EACAid,EACAtkB,EACA8D,EAIJ,IADAuD,EAAM,GACArH,EAAI,EAAGA,EAAI6V,EAAG7V,IAAM,CAEzB,IADAskB,EAAK,GACCxgB,EAAI,EAAGA,EAAI+R,EAAG/R,IAEdA,GAAK9D,GAAK8D,GAAK9D,EAAEge,EACrBsG,EAAGvf,KAAMwP,EAAKzS,KAAMwS,EAAS,CAAEtU,EAAG8D,KAGzBA,EAAI9D,EACbskB,EAAGvf,KAAMsC,EAAKvD,GAAK9D,IAInBskB,EAAGvf,KAAMsf,GAGXhd,EAAItC,KAAMuf,EACV,CACD,OAAOjd,CACR,IFnBAT,EAAAsb,GAAA,aGsBA,SAAoB4T,EAAMzuB,EAAK2W,EAAGyG,GACjC,IAAIxkB,EACAshB,EACAwU,EACAlO,EACA7nB,EACA8D,EACA2T,EAKJ,GAHAoQ,EAAIxgB,EAAI7G,OAGHikB,EAAkB,CAEtB,GADAxkB,EAAMyiB,GAAS,CAAEmF,EAAG7J,EAAE,IACR,UAAT8X,EAAmB,CACvB,IAAM91B,EAAI,EAAGA,EAAI6nB,EAAG7nB,IAGnB,IAFAuhB,EAAKthB,EAAKD,GACV+1B,EAAK1uB,EAAKrH,GACJ8D,EAAI9D,EAAG8D,EAAIse,GAAKyF,EAAG7nB,EAAEge,EAAE,GAAKla,IACjCyd,EAAIzd,EAAE9D,GAAM+1B,EAAIjyB,GAGlB,OAAO7D,CACP,CAED,IAAMD,EAAI,EAAGA,EAAI6nB,EAAG7nB,IAInB,IAHAuhB,EAAKthB,EAAKD,GACV+1B,EAAK1uB,EAAKrH,GACVyX,EAAI0K,GAAK,EAAGnE,EAAEhe,GACR8D,EAAIqe,GAAK,EAAGniB,EAAEge,GAAKla,GAAK9D,EAAG8D,IAChCyd,EAAI9J,GAAMse,EAAIjyB,GACd2T,GAAK,EAGP,OAAOxX,CACP,CAGD,GADAA,EAAMyiB,GAAS,CAAE1E,EAAE,EAAG6J,IACR,UAATiO,EAAmB,CACvB,IAAMhyB,EAAI,EAAGA,EAAI+jB,EAAG/jB,IAEnB,IADA2T,EAAIuG,EAAIla,EACF9D,EAAImiB,GAAK,EAAGre,EAAEka,GAAKhe,GAAK8D,EAAG9D,IAChCC,EAAKwX,EAAEzX,GAAK8D,GAAMuD,EAAKrH,GAAK8D,GAG9B,OAAO7D,CACP,CAED,IAAM6D,EAAI,EAAGA,EAAI+jB,EAAG/jB,IAEnB,IADA2T,GAAK3T,EACC9D,EAAI8D,EAAG9D,EAAIoiB,GAAKyF,EAAG/jB,EAAEka,EAAE,GAAKhe,IACjCC,EAAKwX,EAAEzX,GAAK8D,GAAMuD,EAAKrH,GAAK8D,GAG9B,OAAO7D,CACR,IC3EA2G,EAAAnH,GAAA,UCsNA,SAAiBqP,EAAG8K,EAAS8W,EAAMzwB,EAAK6Z,EAAQjH,GAC/C,IAAI8P,EACAoJ,EACAuI,EAKJ,OAHA3R,EAAK9K,GAAkB/I,GACvBid,EAAKlU,GAAkB+B,GACvB0a,EAAKzc,GAAkB5X,GAEtB0iB,EAAGrL,kBACHyU,EAAGzU,kBACHgd,EAAGhd,iBAIF6X,GAAmBxM,EAAGza,QACtBinB,GAAmBmF,EAAGpsB,QA9HzB,SAAkB4G,EAAG8K,EAAS8W,EAAMzwB,EAAK6Z,EAAQjH,GAChD,IAAIoiB,EACAE,EACAC,EACAjT,EACA4J,EACAwI,EACAv0B,EAEAge,EAcJ,IAZAmX,EAAQvb,EAAQ9B,KAChBsd,EAAOxb,EAAQxC,UAAW,GAG1B6d,EAAWtE,GAAKD,GAGhBvO,EAAQrT,EAAEtO,OAAO,EAAM,EAGvB+zB,EAAc,EAATza,EACLiS,EAAc,EAATlZ,EACC7S,EAAI,EAAGA,EAAIm1B,EAAM30B,OAAQR,IAE9Bge,EAAQ,EADJiX,EAAUG,EAAMD,EAAOn1B,GAAKmiB,GAEhCliB,EAAK8rB,GAAOjd,EAAGkP,GACf/d,EAAK8rB,EAAG,GAAMjd,EAAGkP,EAAE,GACnB+N,GAAMwI,CAGR,CAiGG7I,CAAS9Y,GAAa9D,EAAG,GAAKid,EAAI2E,EAAM9d,GAAa3S,EAAK,GAAK6Z,EAAQjH,GAChE5S,GAGPsc,GAAmBoG,EAAGza,QACtBqU,GAAmB+X,EAAGpsB,QA5EzB,SAAkB4G,EAAG8K,EAAS8W,EAAMzwB,EAAK6Z,EAAQjH,GAChD,IAAIoiB,EACAE,EACAC,EACAjT,EACA4J,EACA/rB,EACA8D,EAaJ,IAXAqxB,EAAQvb,EAAQ9B,KAChBsd,EAAOxb,EAAQxC,UAAW,GAG1B6d,EAAWtE,GAAKD,GAGhBvO,EAAMrT,EAAEtO,OAAS,EAGjBurB,EAAKlZ,EACC7S,EAAI,EAAGA,EAAIm1B,EAAM30B,OAAQR,IAC9B8D,EAAImxB,EAAUG,EAAMD,EAAOn1B,GAAKmiB,GAChCliB,EAAK8rB,GAAOjd,EAAGhL,GACfioB,GAAMjS,CAGR,CAoDGkS,CAASjJ,GAAoBjU,EAAG,GAAKid,EAAI2E,EAAM3N,GAAoB9iB,EAAK,GAAK6Z,EAAQjH,GAC9E5S,IArMV,SAAoB6O,EAAG8K,EAAS8W,EAAMzwB,EAAK6Z,EAAQjH,GAClD,IAAIoiB,EACAtZ,EACAwZ,EACAX,EACA3Y,EACAuZ,EACAX,EACAtS,EACA4J,EACA/rB,EAmBJ,IAhBA2b,EAAQ7M,EAAEgJ,KACVqd,EAAQvb,EAAQ9B,KAChB0c,EAAQv0B,EAAI6X,KAEZ+D,EAAO/M,EAAEsI,UAAW,GACpBge,EAAOxb,EAAQxC,UAAW,GAC1Bqd,EAAOx0B,EAAImX,UAAW,GAGtB6d,EAAWtE,GAAKD,GAGhBvO,EAAMxG,EAAMnb,OAAS,EAGrBurB,EAAKlZ,EACC7S,EAAI,EAAGA,EAAIm1B,EAAM30B,OAAQR,IAE9By0B,EAAMD,EAAOzI,EAAIlQ,EAAMF,EADnBsZ,EAAUG,EAAMD,EAAOn1B,GAAKmiB,KAEhC4J,GAAMjS,CAGR,CAoKE1C,CAAWuL,EAAIoJ,EAAI2E,EAAM4D,EAAIxa,EAAQjH,GAC9B5S,IAxPT,SAAkB6O,EAAG8K,EAAS8W,EAAMzwB,EAAK6Z,EAAQjH,GAChD,IAAIoiB,EACA9S,EACA4J,EACA/rB,EACA8D,EAUJ,IAPAmxB,EAAWtE,GAAKD,GAGhBvO,EAAMrT,EAAEtO,OAAS,EAGjBurB,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI4Z,EAAQpZ,OAAQR,IAChC8D,EAAImxB,EAAUrb,EAAS5Z,GAAKmiB,GAC5BliB,EAAK8rB,GAAOjd,EAAGhL,GACfioB,GAAMjS,CAGR,CAqOCwR,CAASxc,EAAG8K,EAAS8W,EAAMzwB,EAAK6Z,EAAQjH,GACjC5S,EACR,ICpRA,IAAI+1B,GAAQ,EA2BZ,SAASC,GAAQnnB,EAAG8K,EAASsc,EAAWxF,GACvC,IAAI5rB,EACA7E,EACAqjB,EACAqN,EACArpB,EACAid,EACAC,EACAuN,EACAC,EAGJ,IAAc,KADd1O,EAAM+Q,GAAgB6B,EAAWF,GAAM,IAEtC,MAAM,IAAIhiB,WAAYhP,EAAQ,4GAA6GgxB,GAAOE,IAInJ,GAFAvF,EAAMwF,GAAezF,GACrBzwB,EAAM,GACO,IAARqjB,EAAY,CAEhB,IADAxe,EAAYgK,EAAEtO,OAAS,EACjBgkB,EAAK,EAAGA,EAAK5K,EAAQpZ,OAAQgkB,IAClCld,EAAMqpB,EAAK/W,EAAS4K,GAAM1f,GAC1B7E,EAAI8E,KAAM+J,EAAGxH,IAEd,OAAOrH,CACP,CAED,IAAMukB,EAAK,EAAGA,EAAK1V,EAAEtO,OAAQgkB,IAAO,CAInC,IAFAwN,EAAK,GACLltB,GAFAitB,EAAKjjB,EAAG0V,IAEOhkB,OAAS,EAClB+jB,EAAK,EAAGA,EAAK3K,EAAQpZ,OAAQ+jB,IAClCjd,EAAMqpB,EAAK/W,EAAS2K,GAAMzf,GAC1BktB,EAAGjtB,KAAMgtB,EAAIzqB,IAEdrH,EAAI8E,KAAMitB,EACV,CACD,OAAO/xB,CACR,CC3DA,SAASmjB,GAAStU,EAAGiK,EAAGsK,EAAOd,EAAOe,EAAKpO,GAC1C,IAAIqO,EACAC,EACAxjB,EAOJ,GALAujB,EAAIhB,EAAOe,IAGXE,EAAIF,EAAM,KAECD,EAQX,IAAMrjB,EAAI,EAAGA,EAAIujB,EAAGvjB,IACnBojB,GAAStU,EAAG9O,GAAK+Y,EAAG/Y,GAAKqjB,EAAOd,EAAOiB,EAAGtO,QAP1C,IAAMlV,EAAI,EAAGA,EAAIujB,EAAGvjB,IACnB+Y,EAAG/Y,GAAMkV,EAAKpG,EAAG9O,GAQpB,CCdA,SAASo2B,GAAgBtnB,GACxB,OAAc,IAANA,GAAa,EAAIA,IAAMhD,EAChC,CCZA,SAASuqB,GAAevS,EAAGjO,GAE1B,GAAW,IAANiO,EACJ,OAAO,EAER,GAAKA,IAAMjO,EACV,OAAO,EAER,MAAM,IAAIrU,MAAO,mEAClB,CCOA,SAAS80B,GAAOC,EAAWznB,EAAGiK,GAC7B,IAAI8C,EACAC,EACA0a,EACAC,EACAx2B,EACAopB,EACAC,EACAoN,EACA1I,EACAC,EACA0I,EACA9gB,EACA1M,EACAnJ,EAMJ,GAAmB,KAHnBy2B,EAAO,CAAEF,EAAU/1B,OAAQsO,EAAEtO,OAAQuY,EAAEvY,SAG5B,GAEV,MAAO,GAsBR,IAnBAqV,EClBD,SAAe/G,EAAGiK,GACjB,IAAItP,EACAoe,EACA1e,EACAnJ,EAGJ,GAAa,KADbyJ,EAAMvF,UAAU1D,QAEf,OAAK4C,GAAO0L,IAAO1L,GAAO2V,GAClBzN,IAEHwD,IAAMhD,IAAQiN,IAAMjN,GACjBA,GAEHgD,IAAMiK,GAAW,IAANjK,EACVsnB,GAAgBtnB,GACbA,EAEDiK,EAEHjK,EAAIiK,EACDjK,EAEDiK,EAGR,IADA8O,EAAI9Y,GACE/O,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAAM,CAE3B,GAAKoD,GADL+F,EAAIjF,UAAWlE,KACImJ,IAAM2C,GACxB,OAAO3C,GAEHA,EAAI0e,GAGR1e,IAAM0e,GACA,IAAN1e,GACAitB,GAAgBjtB,MAJhB0e,EAAI1e,EAQL,CACD,OAAO0e,CACR,CDxBK+O,CAAMH,EAAM,GAAKA,EAAM,GAAKA,EAAM,IAGtCC,EAAKL,GAAeI,EAAM,GAAK5gB,GAC/BwT,EAAKgN,GAAeI,EAAM,GAAK5gB,GAC/ByT,EAAK+M,GAAeI,EAAM,GAAK5gB,GAG/B2gB,EAAOve,GAAese,GACtB1a,EAAO5D,GAAenJ,GACtBgN,EAAO7D,GAAec,GAGtB4d,EAAK,EACL3I,EAAK,EACLC,EAAK,EAGLhuB,EAAM,GACAD,EAAI,EAAGA,EAAI6V,EAAG7V,IAElBmJ,EADIqtB,EAAMD,EAAWI,GACjB9a,EAAM/M,EAAGkf,GAETlS,EAAM/C,EAAGkV,GAEdhuB,EAAI8E,KAAMoE,GACVwtB,GAAMD,EACN1I,GAAM3E,EACN4E,GAAM3E,EAEP,OAAOrpB,CACR,CE3CA,SAASqrB,GAASzV,EAAG0gB,EAAWznB,EAAGiK,EAAG9Y,EAAK6Z,EAAQjH,GAClD,IAAIwW,EACAC,EACAoN,EACA1I,EACAC,EACA0I,EACA5K,EACA/rB,EAcJ,IAXA02B,EAAKL,GAAeE,EAAU/1B,OAAQqV,GACtCwT,EAAKgN,GAAevnB,EAAEtO,OAAQqV,GAC9ByT,EAAK+M,GAAetd,EAAEvY,OAAQqV,GAG9B8gB,EAAK,EACL3I,EAAK,EACLC,EAAK,EACLlC,EAAKlZ,EAGC7S,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBC,EAAK8rB,GAASwK,EAAWI,GAAS7nB,EAAGkf,GAAOjV,EAAGkV,GAC/C0I,GAAMD,EACN1I,GAAM3E,EACN4E,GAAM3E,EACNyC,GAAMjS,EAEP,OAAO7Z,CACR,CAuLA,SAAS8Z,GAAQwc,EAAWznB,EAAGiK,EAAG9Y,EAAK6Z,EAAQjH,GAC9C,IAAIgkB,EACAlU,EACAC,EACA0R,EACAze,EAGJ,OAA0B,IAArB0gB,EAAU/1B,OACPP,GAGR4V,EC/LD,SAAgBpM,EAAKqQ,EAAQjH,GAC5B,OACQqa,GADHpT,EAAS,GACCjH,EAAO,IAAMiH,GAEdrQ,EAAIoJ,GAAUiH,EAC7B,CD0LKoW,CAAOjwB,EAAIO,OAAQsZ,EAAQjH,GAE/BgkB,EAAKhf,GAAkB0e,GAClBha,GAAmBsa,EAAG3uB,SAE1B2uB,EAAKhf,GADL0e,EAAYO,GAAiBP,EAAW,KAGzC5T,EAAK9K,GAAkB/I,GACvB8T,EAAK/K,GAAkBkB,GACvBub,EAAKzc,GAAkB5X,GAEtB42B,EAAGvf,kBACHqL,EAAGrL,kBACHsL,EAAGtL,kBACHgd,EAAGhd,kBAIsB,IAAxBuf,EAAGvf,kBACHiF,GAAmBoG,EAAGza,QACtBqU,GAAmBqG,EAAG1a,QACtBqU,GAAmB+X,EAAGpsB,QAEtBojB,GAASzV,EAAG0gB,EAAWO,GAAiBhoB,EAAG,GAAKgoB,GAAiB/d,EAAG,GAAK+d,GAAiB72B,EAAK,GAAK6Z,EAAQjH,GACrG5S,GAGPkvB,GAAmBxM,EAAGza,QACtBinB,GAAmBvM,EAAG1a,QACtBinB,GAAmBmF,EAAGpsB,QAlHzB,SAAkB2N,EAAG0gB,EAAWznB,EAAGiK,EAAG9Y,EAAK6Z,EAAQjH,GAClD,IAAIkkB,EACAP,EACAnN,EACAC,EACAoN,EACAnC,EACAvG,EACAC,EACA0I,EACA5K,EACA/rB,EAkBJ,IAhBA+2B,EAAQR,EAAUze,KAClB0e,EAAOD,EAAUnf,UAAW,GAG5Bsf,EAAKL,GAAeU,EAAMv2B,OAAQqV,GAClCwT,EAAsC,EAAjCgN,GAAevnB,EAAEtO,OAAO,EAAGqV,GAChCyT,EAAsC,EAAjC+M,GAAetd,EAAEvY,OAAO,EAAGqV,GAChC0e,EAAc,EAATza,EAGL6c,EAAK,EACL3I,EAAK,EACLC,EAAK,EACLlC,EAAc,EAATlZ,EAGC7S,EAAI,EAAGA,EAAI6V,EAAG7V,IACdw2B,EAAMO,EAAOJ,IACjB12B,EAAK8rB,GAAOjd,EAAGkf,GACf/tB,EAAK8rB,EAAG,GAAMjd,EAAGkf,EAAG,KAEpB/tB,EAAK8rB,GAAOhT,EAAGkV,GACfhuB,EAAK8rB,EAAG,GAAMhT,EAAGkV,EAAG,IAErB0I,GAAMD,EACN1I,GAAM3E,EACN4E,GAAM3E,EACNyC,GAAMwI,CAGR,CAyEG7I,CAAS7V,EAAGghB,EAAIG,GAAkBloB,EAAG,GAAKkoB,GAAkBje,EAAG,GAAKie,GAAkB/2B,EAAK,GAAK6Z,EAAQjH,GACjG5S,IAlMV,SAAoB4V,EAAG0gB,EAAWznB,EAAGiK,EAAG9Y,EAAK6Z,EAAQjH,GACpD,IAAI8I,EACAC,EACAmb,EACAvC,EACA3Y,EACAC,EACA0a,EACA/B,EACApL,EACAC,EACAoN,EACA1I,EACAC,EACA0I,EACA5K,EACA/rB,EAwBJ,IAtBA+2B,EAAQR,EAAUze,KAClB6D,EAAQ7M,EAAEgJ,KACV8D,EAAQ7C,EAAEjB,KACV0c,EAAQv0B,EAAI6X,KAEZ0e,EAAOD,EAAUnf,UAAW,GAC5ByE,EAAO/M,EAAEsI,UAAW,GACpB0E,EAAO/C,EAAE3B,UAAW,GACpBqd,EAAOx0B,EAAImX,UAAW,GAGtBsf,EAAKL,GAAeU,EAAMv2B,OAAQqV,GAClCwT,EAAKgN,GAAe1a,EAAMnb,OAAQqV,GAClCyT,EAAK+M,GAAeza,EAAMpb,OAAQqV,GAGlC8gB,EAAK,EACL3I,EAAK,EACLC,EAAK,EACLlC,EAAKlZ,EAGC7S,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBy0B,EAAMD,EAAOzI,EAAMyK,EAAMO,EAAOJ,GAAS9a,EAAMF,EAAOqS,GAAOlS,EAAMF,EAAOqS,IAC1E0I,GAAMD,EACN1I,GAAM3E,EACN4E,GAAM3E,EACNyC,GAAMjS,CAGR,CAoJE1C,CAAWvB,EAAGghB,EAAIlU,EAAIC,EAAI0R,EAAIxa,EAAQjH,GAC/B5S,IAERqrB,GAASzV,EAAG0gB,EAAWznB,EAAGiK,EAAG9Y,EAAK6Z,EAAQjH,GACnC5S,GACR,CE1PA,SAASg3B,GAAWnoB,EAAG2H,EAAO5W,GAC7B,IAAII,EAEJ,GA/BD,SAAoBiG,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CA6BMC,CAAW1mB,EAAG,QAClB,OAAOA,EAAEooB,KAAMzgB,EAAO5W,GAGvB,IADA4W,EAAQ4d,GAAgB5d,EAAO3H,EAAEtO,OAAO,IAC3B,EACZ,MAAM,IAAIwT,WAAYhP,EAAQ,kEAAmEyR,IAKlG,OAFMmf,GADN31B,EAAM4E,GAAOiK,EAAG,EAAGA,EAAEtO,QAErBkG,CAAKzG,EAAKwW,EAAO5W,GACVI,CACR,CC7BA,SAASqrB,GAASxc,EAAG2H,EAAO5W,EAAOI,EAAK6Z,EAAQjH,GAC/C,IAAIkZ,EACA/rB,EAGJ,IADA+rB,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1BC,EAAK8rB,GAAOjd,EAAG9O,GACf+rB,GAAMjS,EAGP,OADA7Z,EAAK4S,EAAQ4D,EAAMqD,GAAYja,EACxBI,CACR,CCvCA,SAASk3B,KACR,MAAO,CAEN/a,OAAU,CACTpU,QAAW,UACXovB,QAAW,UACX7lB,KAAQ,UACR8lB,eAAkB,UAClBC,oBAAuB,UACvBC,uBAA0B,aAC1BC,QAAW,QACXC,eAAkB,QAClBC,iBAAoB,SACpB1L,QAAW,OACXvV,MAAS,QACTkhB,cAAiB,QACjBC,cAAiB,OACjBC,WAAc,SAGjB,CCUAjxB,EAAAnH,GAAA,SAAAsa,ICHAnT,EAAAnH,GAAA,UHgIA,SAAiBqP,EAAG2H,EAAO5W,EAAOI,EAAK6Z,EAAQjH,GAC9C,IAAI8P,EACA2R,EAGJ,IADA7d,EAAQ4d,GAAgB5d,EAAO3H,EAAEtO,OAAO,IAC3B,EACZ,MAAM,IAAIwT,WAAYhP,EAAQ,kEAAmEyR,IAIlG,OAFAkM,EAAK9K,GAAkB/I,GACvBwlB,EAAKzc,GAAkB5X,GAClB0iB,EAAGrL,kBAAoBgd,EAAGhd,iBAG7B6X,GAAmBxM,EAAGza,QACtBinB,GAAmBmF,EAAGpsB,QACtBgK,GAAerS,IA5DlB,SAAkBiP,EAAG2H,EAAO5W,EAAOI,EAAK6Z,EAAQjH,GAC/C,IAAI0hB,EACAxI,EACA/rB,EACA8D,EAIJ,IAFAywB,EAAc,EAATza,EACLiS,EAAc,EAATlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAO,EAAGR,IAC5B8D,EAAQ,EAAJ9D,EACJC,EAAK8rB,GAAOjd,EAAGhL,GACf7D,EAAK8rB,EAAG,GAAMjd,EAAGhL,EAAE,GACnBioB,GAAMwI,EAGPt0B,EADA8rB,EAAiC,GAA1BlZ,EAAQ4D,EAAMqD,IACTvI,GAAM1R,GAClBI,EAAK8rB,EAAG,GAAMva,GAAM3R,EAErB,CA4CG6rB,CAAS9Y,GAAa9D,EAAG,GAAK2H,EAAO5W,EAAO+S,GAAa3S,EAAK,GAAK6Z,EAAQjH,GACpE5S,GAGPsc,GAAmBoG,EAAGza,QACtBqU,GAAmB+X,EAAGpsB,QAEtBojB,GAASvI,GAAoBjU,EAAG,GAAK2H,EAAOxG,GAASpQ,GAASkjB,GAAoB9iB,EAAK,GAAK6Z,EAAQjH,GAC7F5S,IAnHV,SAAoB6O,EAAG2H,EAAO5W,EAAOI,EAAK6Z,EAAQjH,GACjD,IAAI8I,EACA6Y,EACA3Y,EACA4Y,EACA1I,EACA/rB,EASJ,IAPA2b,EAAQ7M,EAAEgJ,KACV0c,EAAQv0B,EAAI6X,KAEZ+D,EAAO/M,EAAEsI,UAAW,GACpBqd,EAAOx0B,EAAImX,UAAW,GAEtB2U,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,IAC9By0B,EAAMD,EAAOzI,EAAIlQ,EAAMF,EAAO3b,IAC9B+rB,GAAMjS,EAEP2a,EAAMD,EAAO3hB,EAAQ4D,EAAMqD,EAASja,EAErC,CAgGEuX,CAAWuL,EAAIlM,EAAO5W,EAAOy0B,EAAIxa,EAAQjH,GAClC5S,IAERqrB,GAASxc,EAAG2H,EAAO5W,EAAOI,EAAK6Z,EAAQjH,GAChC5S,EACR,II/LA,IAAI63B,GHKI,CAEN1b,OAAU,CACTpU,QAAW,UACXovB,QAAW,UACX7lB,KAAQ,UACR8lB,eAAkB,UAClBC,oBAAuB,UACvBC,uBAA0B,aAC1BC,QAAW,QACXC,eAAkB,QAClBC,iBAAoB,SACpB1L,QAAW,OACXvV,MAAS,QACTkhB,cAAiB,QACjBC,cAAiB,OACjBC,WAAc,UGpBbE,GAAO,CACV,iBAAkBD,GAAS1b,OAAOpU,QAClC,iBAAkB8vB,GAAS1b,OAAOgb,QAClC,cAAeU,GAAS1b,OAAO7K,KAC/B,wBAAyBumB,GAAS1b,OAAOib,eACzC,6BAA8BS,GAAS1b,OAAOkb,oBAC9C,gCAAiCQ,GAAS1b,OAAOmb,uBACjD,iBAAkBO,GAAS1b,OAAOob,QAClC,wBAAyBM,GAAS1b,OAAOqb,eACzC,0BAA2BK,GAAS1b,OAAOsb,iBAC3C,iBAAkBI,GAAS1b,OAAO4P,QAClC,eAAgB8L,GAAS1b,OAAO3F,MAChC,uBAAwBqhB,GAAS1b,OAAOub,cACxC,uBAAwBG,GAAS1b,OAAOwb,cACxC,oBAAqBE,GAAS1b,OAAOyb,YCDtCjxB,EAAAnH,GAAA,ODiBA,SAAcyK,GACb,IAAIf,EAAI4uB,GAAM7tB,GACd,YAAe,IAANf,EAAiB,KAAOA,CAClC,IE9BA,IAAI6uB,GAAgBb,GAAS1wB,IAAK,kBAsBlC,SAAS3G,GAAOU,GACf,IAAI0H,EACAiC,EACJ,IAAM+E,GAAsB1O,GAC3B,MAAM,IAAIuD,UAAWiB,EAAQ,+EAAgFxE,IAO9G,GAAe,aAJd0H,EADIhE,UAAU1D,OAAS,EACf0D,UAAW,GAEX8zB,IAGR,OAAOC,GAAQz3B,GAGhB,GAAc,QADd2J,EAAOkP,GAAOnR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,iFAAkFkD,IAEhH,OAAO,IAAIiC,EAAM3J,EAClB,CClBA,SAAS8qB,GAASxc,EAAG2H,EAAOxW,EAAK6Z,EAAQjH,GACxC,IAAIkZ,EACA/rB,EAGJ,IADA+rB,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrBA,IAAMyW,IAGXxW,EAAK8rB,GAAOjd,EAAG9O,GACf+rB,GAAMjS,GAEP,OAAO7Z,CACR,CAmHA,SAAS8Z,GAAQjL,EAAG2H,EAAOxW,EAAK6Z,EAAQjH,GACvC,IAAI8P,EACA2R,EAGJ,IADA7d,EAAQ4d,GAAgB5d,EAAO3H,EAAEtO,OAAO,IAC3B,EACZ,MAAM,IAAIwT,WAAYhP,EAAQ,kEAAmEyR,IAIlG,OAFAkM,EAAK9K,GAAkB/I,GACvBwlB,EAAKzc,GAAkB5X,GAClB0iB,EAAGrL,kBAAoBgd,EAAGhd,iBAG7B6X,GAAmBxM,EAAGza,QACtBinB,GAAmBmF,EAAGpsB,QA1DzB,SAAkB4G,EAAG2H,EAAOxW,EAAK6Z,EAAQjH,GACxC,IAAI0hB,EACAxI,EACA/rB,EACA8D,EAIJ,IAFAywB,EAAc,EAATza,EACLiS,EAAc,EAATlZ,EACC7S,EAAI,EAAGA,EAAI8O,EAAEtO,OAAO,EAAGR,IACvBA,IAAMyW,IAGX3S,EAAQ,EAAJ9D,EACJC,EAAK8rB,GAAOjd,EAAGhL,GACf7D,EAAK8rB,EAAG,GAAMjd,EAAGhL,EAAE,GACnBioB,GAAMwI,EAGR,CA0CG7I,CAAS9Y,GAAa9D,EAAG,GAAK2H,EAAO7D,GAAa3S,EAAK,GAAK6Z,EAAQjH,GAC7D5S,GAGPsc,GAAmBoG,EAAGza,QACtBqU,GAAmB+X,EAAGpsB,QAEtBojB,GAASvI,GAAoBjU,EAAG,GAAK2H,EAAOsM,GAAoB9iB,EAAK,GAAK6Z,EAAQjH,GAC3E5S,IAlHV,SAAoB6O,EAAG2H,EAAOxW,EAAK6Z,EAAQjH,GAC1C,IAAI8I,EACA6Y,EACA3Y,EACA4Y,EACA1I,EACA/rB,EASJ,IAPA2b,EAAQ7M,EAAEgJ,KACV0c,EAAQv0B,EAAI6X,KAEZ+D,EAAO/M,EAAEsI,UAAW,GACpBqd,EAAOx0B,EAAImX,UAAW,GAEtB2U,EAAKlZ,EACC7S,EAAI,EAAGA,EAAI2b,EAAMnb,OAAQR,IACzBA,IAAMyW,IAGXge,EAAMD,EAAOzI,EAAIlQ,EAAMF,EAAO3b,IAC9B+rB,GAAMjS,EAGR,CA6FE1C,CAAWuL,EAAIlM,EAAO6d,EAAIxa,EAAQjH,GAC3B5S,IAERqrB,GAASxc,EAAG2H,EAAOxW,EAAK6Z,EAAQjH,GACzB5S,EACR,CClKA,SAASi4B,GAASppB,EAAG2H,GACpB,IAAIxW,EAGJ,IADAwW,EAAQ4d,GAAgB5d,EAAO3H,EAAEtO,OAAO,IAC3B,EACZ,MAAM,IAAIwT,WAAYhP,EAAQ,kEAAmEyR,IAIlG,OADAsD,GAAQjL,EAAG2H,EADXxW,EAAMH,GAAOgP,EAAEtO,OAAO,EAAG0H,GAAO4G,IAAO,WAChB,EAAG,GACnB7O,CACR,CCHA2G,EAAAnH,GAAA,SAAAsa,ICtBA,IAAAmI,GAAA,CAAA,EAUAtb,EAAAsb,GAAA,gBAAA1K,IAUA5Q,EAAAsb,GAAA,iBAAAxN,GAUA9N,EAAAsb,GAAA,iBAAA3K,GAUA3Q,EAAAsb,GAAA,YAAA9K,IAUAxQ,EAAAsb,GAAA,O7WsCA,SAAcpT,GACb,IAAI5I,EAAM2R,GAAkB/I,GAC5B,OAAK5I,EAAIoR,iBAEHhF,GAAmBxD,GAChBkJ,GAAU9D,GAAgBpF,EAAG,IAEhCuD,GAAkBvD,GACfkJ,GAAU/D,GAAenF,EAAG,IAG/B6H,GAAgB7H,GACbkJ,GAAU+K,GAAoBjU,EAAG,IAjD3C,SAAoBA,GACnB,IAAIgJ,EACArR,EACAzG,EAKJ,IAHA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEbpX,EAAI,EAAGA,EAAI8X,EAAKtX,OAAQR,IAC7B,GAAKyG,EAAKqR,EAAM9X,GACf,OAAO,EAGT,OAAO,CACR,CAqCSoX,CAAWlR,GAEZ8R,GAAUlJ,EAClB,I6W7CAlI,EAAAsb,GAAA,SCuCA,SAAgBpT,EAAGtF,EAAW8K,GAC7B,IAAIpO,EACJ,OA9FD,SAAoBA,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CA4FMC,CAAW1mB,EAAG,QACXA,EAAEqpB,KAAM3uB,EAAW8K,IAE3BpO,EAAM2R,GAAkB/I,IACfwI,iBA3CV,SAAoBxI,EAAGtF,EAAW8K,GACjC,IAAIwD,EACArR,EACAzG,EAKJ,IAHA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEbpX,EAAI,EAAGA,EAAI8X,EAAKtX,OAAQR,IAC7B,GAAKwJ,EAAU1H,KAAMwS,EAAS7N,EAAKqR,EAAM9X,GAAKA,EAAG8X,GAChD,OAAO,EAGT,OAAO,CACR,CA8BSV,CAAWlR,EAAKsD,EAAW8K,GA5EpC,SAAmBxF,EAAGtF,EAAW8K,GAChC,IAAItU,EACJ,IAAMA,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1B,GAAKwJ,EAAU1H,KAAMwS,EAASxF,EAAG9O,GAAKA,EAAG8O,GACxC,OAAO,EAGT,OAAO,CACR,CAsEQkJ,CAAUlJ,EAAGtF,EAAW8K,EAChC,IDvCA1N,EAAAsb,GAAA,cESA,SAAqBpT,EAAGtF,EAAW8K,GAClC,IAAIpO,EAAM2R,GAAkB/I,GAC5B,OAAK5I,EAAIoR,iBAvCV,SAAoBxI,EAAGtF,EAAW8K,GACjC,IAAIwD,EACArR,EACAzG,EAKJ,IAHA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEbpX,EAAI8X,EAAKtX,OAAO,EAAGR,GAAK,EAAGA,IAChC,GAAKwJ,EAAU1H,KAAMwS,EAAS7N,EAAKqR,EAAM9X,GAAKA,EAAG8X,GAChD,OAAO,EAGT,OAAO,CACR,CA0BSV,CAAWlR,EAAKsD,EAAW8K,GAxEpC,SAAmBxF,EAAGtF,EAAW8K,GAChC,IAAItU,EACJ,IAAMA,EAAI8O,EAAEtO,OAAO,EAAGR,GAAK,EAAGA,IAC7B,GAAKwJ,EAAU1H,KAAMwS,EAASxF,EAAG9O,GAAKA,EAAG8O,GACxC,OAAO,EAGT,OAAO,CACR,CAkEQkJ,CAAUlJ,EAAGtF,EAAW8K,EAChC,IFLA1N,EAAAsb,GAAA,iBGwBA,SAAwB7a,EAAKlB,GAC5B,OAAKe,EAAiBG,GA5CvB,SAAoBA,EAAKlB,GACxB,IAAIM,EACAzG,EAGJ,IADAyG,EAAMwR,GAAe5Q,GACfrH,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAK6I,GAAYpC,EAAKY,EAAKrH,GAAKmG,GAC/B,OAAO,EAGT,OAAO,CACR,CAkCSiR,CAAW/P,EAAKlB,GArFzB,SAAkBkB,EAAKlB,GACtB,IAAInG,EACJ,IAAMA,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAK6I,GAAYxB,EAAKrH,GAAKmG,GAC1B,OAAO,EAGT,OAAO,CACR,CA+EQmlB,CAASjkB,EAAKlB,EACtB,IHnBAS,EAAAsb,GAAA,cIcA,SAAqB7a,EAAKlB,GACzB,OAAKe,EAAiBG,GA5CvB,SAAoBA,EAAKlB,GACxB,IAAIM,EACAzG,EAGJ,IADAyG,EAAMwR,GAAe5Q,GACfrH,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAKkY,GAASzR,EAAKY,EAAKrH,GAAKmG,GAC5B,OAAO,EAGT,OAAO,CACR,CAkCSiR,CAAW/P,EAAKlB,GArFzB,SAAkBkB,EAAKlB,GACtB,IAAInG,EACJ,IAAMA,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAKkY,GAAS7Q,EAAKrH,GAAKmG,GACvB,OAAO,EAGT,OAAO,CACR,CA+EQmlB,CAASjkB,EAAKlB,EACtB,IJTAS,EAAAsb,GAAA,cKWA,SAAqB7a,EAAKlB,EAAMtG,GAC/B,OAAKqH,EAAiBG,GA/CvB,SAAoBA,EAAKlB,EAAMtG,GAC9B,IAAI4G,EACA0C,EACAnJ,EAGJ,IADAyG,EAAMwR,GAAe5Q,GACfrH,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAE5B,GAAK6I,GADLM,EAAI1C,EAAKY,EAAKrH,GACMmG,IAAUgD,EAAGhD,KAAWtG,EAC3C,OAAO,EAGT,OAAO,CACR,CAmCSuX,CAAW/P,EAAKlB,EAAMtG,GA3F/B,SAAkBwH,EAAKlB,EAAMtG,GAC5B,IAAIsJ,EACAnJ,EACJ,IAAMA,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAE5B,GAAK6I,GADLM,EAAI9B,EAAKrH,GACWmG,IAAUgD,EAAGhD,KAAWtG,EAC3C,OAAO,EAGT,OAAO,CACR,CAmFQyrB,CAASjkB,EAAKlB,EAAMtG,EAC5B,ILNA+G,EAAAsb,GAAA,gBMiBA,SAAuB7a,EAAKlB,EAAMtG,GACjC,OAAKqH,EAAiBG,GAvDvB,SAAoBA,EAAKlB,EAAMtG,GAC9B,IAAI4G,EACA0C,EACAnJ,EAGJ,GADAyG,EAAMwR,GAAe5Q,QACN,IAAVxH,EAAmB,CACvB,IAAMG,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAE5B,GAAKkY,GADL/O,EAAI1C,EAAKY,EAAKrH,GACGmG,IAAUgD,EAAGhD,KAAWtG,EACxC,OAAO,EAGT,OAAO,CACP,CACD,IAAMG,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAKyG,EAAKY,EAAKrH,GAAKmG,KAAWtG,EAC9B,OAAO,EAGT,OAAO,CACR,CAmCSuX,CAAW/P,EAAKlB,EAAMtG,GA3G/B,SAAkBwH,EAAKlB,EAAMtG,GAC5B,IAAIsJ,EACAnJ,EACJ,QAAe,IAAVH,EAAmB,CACvB,IAAMG,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAE5B,GAAKkY,GADL/O,EAAI9B,EAAKrH,GACQmG,IAAUgD,EAAGhD,KAAWtG,EACxC,OAAO,EAGT,OAAO,CACP,CACD,IAAMG,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5B,GAAKqH,EAAKrH,GAAKmG,KAAWtG,EACzB,OAAO,EAGT,OAAO,CACR,CA2FQyrB,CAASjkB,EAAKlB,EAAMtG,EAC5B,INZA+G,EAAAsb,GAAA,mBAAArK,IAUAjR,EAAAsb,GAAA,SAAAkW,IAUAxxB,EAAAsb,GAAA,MO3GA,SAAapT,EAAG2H,GAEf,GA5BD,SAAoBvQ,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CA0BMC,CAAW1mB,EAAG,MAClB,OAAOA,EAAEupB,GAAI5hB,GAEd,GAAKA,EAAQ,GAEZ,IADAA,GAAS3H,EAAEtO,QACE,EACZ,YAEK,GAAKiW,GAAS3H,EAAEtO,OACtB,OAGD,OADMyX,GAAenJ,EACdrI,CAAKqI,EAAG2H,EAChB,IPsGA7P,EAAAsb,GAAA,QQhJA,SAAepT,EAAGyV,EAAIC,GACrB,IAAIuN,EACAlc,EAMJ,GAJAA,EAAI/G,EAAEtO,OACD+jB,EAAK,IACTA,GAAM1O,KAEF0O,EAAK,GAAKA,GAAM1O,IAIrBA,GADAkc,EAAKjjB,EAAGyV,IACD/jB,OACFgkB,EAAK,IACTA,GAAM3O,GAEF2O,EAAK,GAAKA,GAAM3O,IAGrB,OAAOkc,EAAIvN,EACZ,IRsIA5d,EAAAsb,GAAA,QSzJA,SAAepT,EAAGyV,EAAIC,EAAIgL,GACzB,IAAIuC,EACA9G,EACApV,EAMJ,GAJAA,EAAI/G,EAAEtO,OACD+jB,EAAK,IACTA,GAAM1O,KAEF0O,EAAK,GAAKA,GAAM1O,IAIrBA,GADAkc,EAAKjjB,EAAGyV,IACD/jB,OACFgkB,EAAK,IACTA,GAAM3O,GAEF2O,EAAK,GAAKA,GAAM3O,IAIrBA,GADAoV,EAAK8G,EAAIvN,IACFhkB,OACFgvB,EAAK,IACTA,GAAM3Z,GAEF2Z,EAAK,GAAKA,GAAM3Z,KAGrB,OAAOoV,EAAIuE,EACZ,ITsIA5oB,EAAAsb,GAAA,QUlKA,SAAepT,EAAGyV,EAAIC,EAAIgL,EAAII,GAC7B,IAAI/vB,EACAyH,EACAuO,EACA7V,EACA8D,EAIJ,IAFAwD,EAAM,CAAEid,EAAIC,EAAIgL,EAAII,GACpB/vB,EAAQiP,EACF9O,EAAI,EAAGA,EAAIsH,EAAI9G,OAAQR,IAAM,CAMlC,GALA8D,EAAIwD,EAAKtH,GACT6V,EAAIhW,EAAMW,OACLsD,EAAI,IACRA,GAAK+R,GAED/R,EAAI,GAAKA,GAAK+R,EAClB,OAEDhW,EAAQA,EAAOiE,EACf,CACD,OAAOjE,CACR,IVuJA+G,EAAAsb,GAAA,QW3KA,SAAepT,EAAGyV,EAAIC,EAAIgL,EAAII,EAAII,GACjC,IAAInwB,EACAyH,EACAuO,EACA7V,EACA8D,EAIJ,IAFAwD,EAAM,CAAEid,EAAIC,EAAIgL,EAAII,EAAII,GACxBnwB,EAAQiP,EACF9O,EAAI,EAAGA,EAAIsH,EAAI9G,OAAQR,IAAM,CAMlC,GALA8D,EAAIwD,EAAKtH,GACT6V,EAAIhW,EAAMW,OACLsD,EAAI,IACRA,GAAK+R,GAED/R,EAAI,GAAKA,GAAK+R,EAClB,OAEDhW,EAAQA,EAAOiE,EACf,CACD,OAAOjE,CACR,IXgKA+G,EAAAsb,GAAA,QYxLA,SAAepT,EAAGyV,GACjB,IAAI1kB,EACAyH,EACAuO,EACA7V,EACA8D,EAGJ,IADAwD,EAAM,CAAEid,GACFvkB,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAClCsH,EAAIvC,KAAMb,UAAWlE,IAGtB,IADAH,EAAQiP,EACF9O,EAAI,EAAGA,EAAIsH,EAAI9G,OAAQR,IAAM,CAMlC,GALA8D,EAAIwD,EAAKtH,GACT6V,EAAIhW,EAAMW,OACLsD,EAAI,IACRA,GAAK+R,GAED/R,EAAI,GAAKA,GAAK+R,EAClB,OAEDhW,EAAQA,EAAOiE,EACf,CACD,OAAOjE,CACR,IZ0KA+G,EAAAsb,GAAA,SAAAoW,IAUA1xB,EAAAsb,GAAA,oBa5MA,SAA2BpT,EAAGypB,GAC7B,IAAI1c,EACA2c,EACA/uB,EACAxJ,EAEAkJ,EACAnJ,EAIJ,GADAyJ,EAAMqF,EAAEtO,OACH+3B,EAAO/3B,SAAWiJ,EACtB,MAAM,IAAIuK,WAAY,+EAEvB,GAAa,IAARvK,EACJ,MAAO,GAQR,IALAoS,EAAO5D,GAAenJ,GACtB0pB,EAAOvgB,GAAesgB,GAGtBt4B,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI0S,EAAM/M,EAAG9O,GACTw4B,EAAMD,EAAQv4B,GAEjBC,EAAK,GAAI8E,KAAM,CAAE/E,EAAGmJ,IAEpBlJ,EAAK,GAAI8E,KAAM,CAAE/E,EAAGmJ,IAGtB,OAAOlJ,CACR,IbqLA2G,EAAAsb,GAAA,sBcnNA,SAA6BpT,EAAGtF,EAAW8K,GAC1C,IAAI7N,EACAgD,EACAxJ,EACAkJ,EACAnJ,EAIJ,GAAa,KADbyJ,EAAMqF,EAAEtO,QAEP,MAAO,GAOR,IAJAiG,EAAMwR,GAAenJ,GAGrB7O,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI1C,EAAKqI,EAAG9O,GACPwJ,EAAU1H,KAAMwS,EAASnL,EAAGnJ,EAAG8O,GACnC7O,EAAK,GAAI8E,KAAM,CAAE/E,EAAGmJ,IAEpBlJ,EAAK,GAAI8E,KAAM,CAAE/E,EAAGmJ,IAGtB,OAAOlJ,CACR,IdmMA2G,EAAAsb,GAAA,oBehOA,SAA2BpT,EAAGypB,GAC7B,IAAIC,EACA/uB,EACAxJ,EAEAD,EAIJ,GADAyJ,EAAMqF,EAAEtO,OACH+3B,EAAO/3B,SAAWiJ,EACtB,MAAM,IAAIuK,WAAY,+EAEvB,GAAa,IAARvK,EACJ,MAAO,GAOR,IAJA+uB,EAAOvgB,GAAesgB,GAGtBt4B,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACjBw4B,EAAMD,EAAQv4B,GAEjBC,EAAK,GAAI8E,KAAM/E,GAEfC,EAAK,GAAI8E,KAAM/E,GAGjB,OAAOC,CACR,If6MA2G,EAAAsb,GAAA,sBgBvOA,SAA6BpT,EAAGtF,EAAW8K,GAC1C,IAAI7N,EACAgD,EACAxJ,EACAD,EAIJ,GAAa,KADbyJ,EAAMqF,EAAEtO,QAEP,MAAO,GAOR,IAJAiG,EAAMwR,GAAenJ,GAGrB7O,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAChBwJ,EAAU1H,KAAMwS,EAAS7N,EAAKqI,EAAG9O,GAAKA,EAAG8O,GAC7C7O,EAAK,GAAI8E,KAAM/E,GAEfC,EAAK,GAAI8E,KAAM/E,GAGjB,OAAOC,CACR,IhByNA2G,EAAAsb,GAAA,mBiBpPA,SAA0BpT,EAAGypB,GAC5B,IAAI1c,EACA2c,EACA/uB,EACAxJ,EAEAkJ,EACAnJ,EAIJ,GADAyJ,EAAMqF,EAAEtO,OACH+3B,EAAO/3B,SAAWiJ,EACtB,MAAM,IAAIuK,WAAY,+EAEvB,GAAa,IAARvK,EACJ,MAAO,GAQR,IALAoS,EAAO5D,GAAenJ,GACtB0pB,EAAOvgB,GAAesgB,GAGtBt4B,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI0S,EAAM/M,EAAG9O,GACTw4B,EAAMD,EAAQv4B,GAEjBC,EAAK,GAAI8E,KAAMoE,GAEflJ,EAAK,GAAI8E,KAAMoE,GAGjB,OAAOlJ,CACR,IjB6NA2G,EAAAsb,GAAA,qBkB3PA,SAA4BpT,EAAGtF,EAAW8K,GACzC,IAAI7N,EACAgD,EACAxJ,EACAkJ,EACAnJ,EAIJ,GAAa,KADbyJ,EAAMqF,EAAEtO,QAEP,MAAO,GAOR,IAJAiG,EAAMwR,GAAenJ,GAGrB7O,EAAM,CAAE,GAAI,IACND,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI1C,EAAKqI,EAAG9O,GACPwJ,EAAU1H,KAAMwS,EAASnL,EAAGnJ,EAAG8O,GACnC7O,EAAK,GAAI8E,KAAMoE,GAEflJ,EAAK,GAAI8E,KAAMoE,GAGjB,OAAOlJ,CACR,IlB2OA2G,EAAAsb,GAAA,YmBhQA,SAAmBuW,EAAQlW,EAAOrN,GACjC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACA0G,EACA5pB,EACAiK,EACApG,EAIJ,GAFA6P,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAMtB,IAHA3T,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAKjjB,EAAG0V,GACRwN,EAAKjZ,EAAGyL,GACRkU,EAAK/lB,EAAG6R,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAGjC,InB8OA3d,EAAAsb,GAAA,YoB1QA,SAAmBuW,EAAQlW,EAAOrN,GACjC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACA9G,EACA+G,EACAzI,EACAmP,EACAvd,EACArM,EACAiK,EACApG,EAKJ,GAHA6P,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAMjC,IAHAzgB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKnc,EAAG0gB,GACRjG,EAAKxQ,EAAGyW,GACRrU,EAAKxI,EAAG6c,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAIlC,IpB6OA3d,EAAAsb,GAAA,YqBpRA,SAAmBuW,EAAQlW,EAAOrN,GACjC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA6F,EACAvd,EACAC,EACAtM,EACAiK,EACApG,EAMJ,GAJA6P,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAM5C,IAHA7gB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA1E,EAAKpc,EAAG8gB,GACRiD,EAAK9Z,EAAG6W,GACRxU,EAAKzI,EAAGid,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAKnC,IrB4OA3d,EAAAsb,GAAA,YsB9RA,SAAmBuW,EAAQlW,EAAOrN,GACjC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACA0F,EACAvd,EACAC,EACAud,EACA7pB,EACAiK,EACApG,EAOJ,GALA6P,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAMvD,IAHAjhB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA+C,EAAKjkB,EAAGkhB,GACRgD,EAAKja,EAAGiX,GACR2I,EAAKhmB,EAAGqd,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTxU,EAAKud,EAAI/I,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAMpC,ItB2OA3d,EAAAsb,GAAA,Y3PjQA,SAAmBuW,EAAQlW,EAAOrN,GACjC,OAAOkO,GAASqV,EAAQ,GAAKA,EAAQ,GAAKA,EAAQ,GAAKlW,EAAM/hB,OAAQ+hB,EAAO,EAAGrN,EAChF,I2PyQAtO,EAAAsb,GAAA,iBAAAwB,IAUA9c,EAAAsb,GAAA,auBvTA,SAAoBuW,EAAQG,EAAQ1jB,GACnC,IAAI2jB,EACAC,EACAC,EACAC,EACAxW,EACAC,EACA8B,EACAC,EACAyU,EACAC,EACAC,EACAC,EACArH,EACAC,EACA0G,EACAzH,EACApN,EACApM,EACA3I,EACAiK,EACApG,EAKJ,GAFA6P,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAmBtB,IAfA3T,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GAEVlR,EAAI8lB,EAAQ,GAEZS,EAAK,EACLE,EAAK,EACC5U,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAM7B,IALAyU,EAAK,EACLE,EAAK,EACLpH,EAAKjjB,EAAGoqB,GACRlH,EAAKjZ,EAAGqgB,GACRV,EAAK/lB,EAAG6R,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,IAC9BF,GAAMJ,EACNM,GAAMJ,EAEPG,GAAMJ,EACNM,GAAMJ,CACN,CACF,IvBsQApyB,EAAAsb,GAAA,awBjUA,SAAoBuW,EAAQG,EAAQ1jB,GACnC,IAAI2jB,EACAC,EACAO,EACAN,EACAC,EACAM,EACA9W,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAyJ,EACAC,EACAK,EACAJ,EACAC,EACAI,EACAzH,EACA9G,EACA+G,EACAzI,EACAmP,EACAvd,EACA8V,EACApN,EACApM,EACA3I,EACAiK,EACApG,EAMJ,GAHA6P,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAqBjC,IAjBAzgB,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GAEVlR,EAAI8lB,EAAQ,GAEZc,EAAK,EACLC,EAAK,EACChK,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA0J,EAAK,EACLE,EAAK,EACLnO,EAAKnc,EAAGyqB,GACRhQ,EAAKxQ,EAAGygB,GACRre,EAAKxI,EAAG6c,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAM7B,IALAyU,EAAK,EACLE,EAAK,EACLpH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,IAC9BF,GAAMJ,EACNM,GAAMJ,EAEPG,GAAMJ,EACNM,GAAMJ,CACN,CACDO,GAAMF,EACNG,GAAMF,CACN,CACF,IxB2PA1yB,EAAAsb,GAAA,ayB3UA,SAAoBuW,EAAQG,EAAQ1jB,GACnC,IAAI2jB,EACAC,EACAO,EACAI,EACAV,EACAC,EACAM,EACAI,EACAlX,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAqJ,EACAC,EACAK,EACAI,EACAR,EACAC,EACAI,EACAI,EACA7H,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA6F,EACAvd,EACAC,EACA6V,EACApN,EACApM,EACA3I,EACAiK,EACApG,EAOJ,GAJA6P,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,GACTtB,EAAKsB,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAuB5C,IAnBA7gB,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GACV4V,EAAM5V,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GACV6V,EAAM7V,EAAI,GAEVlR,EAAI8lB,EAAQ,GAEZkB,EAAK,EACLC,EAAK,EACChK,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA2J,EAAK,EACLC,EAAK,EACLtO,EAAKpc,EAAG6qB,GACR9G,EAAK9Z,EAAG6gB,GACRxe,EAAKzI,EAAGid,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA0J,EAAK,EACLE,EAAK,EACLnO,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAI2G,GACTre,EAAKC,EAAIoU,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAM7B,IALAyU,EAAK,EACLE,EAAK,EACLpH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,IAC9BF,GAAMJ,EACNM,GAAMJ,EAEPG,GAAMJ,EACNM,GAAMJ,CACN,CACDO,GAAMF,EACNG,GAAMF,CACN,CACDK,GAAMF,EACNG,GAAMF,CACN,CACF,IzBgPA9yB,EAAAsb,GAAA,a0BrVA,SAAoBuW,EAAQG,EAAQ1jB,GACnC,IAAI2jB,EACAC,EACAO,EACAI,EACAI,EACAd,EACAC,EACAM,EACAI,EACAI,EACAtX,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACAiJ,EACAC,EACAK,EACAI,EACAI,EACAZ,EACAC,EACAI,EACAI,EACAI,EACAjI,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACA0F,EACAvd,EACAC,EACAud,EACA1H,EACApN,EACApM,EACA3I,EACAiK,EACApG,EAQJ,GALA6P,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,GACTtB,EAAKsB,EAAI,GACTlB,EAAKkB,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAyBvD,IArBAjhB,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GACV4V,EAAM5V,EAAI,GACVgW,EAAMhW,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GACV6V,EAAM7V,EAAI,GACViW,EAAMjW,EAAI,GAEVlR,EAAI8lB,EAAQ,GAEZsB,EAAK,EACLC,EAAK,EACChK,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA2J,EAAK,EACLC,EAAK,EACL7G,EAAKjkB,EAAGirB,GACR/G,EAAKja,EAAGihB,GACRrB,EAAKhmB,EAAGqd,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA2J,EAAK,EACLC,EAAK,EACLtO,EAAK6H,EAAI4G,GACT9G,EAAKG,EAAI4G,GACTxe,EAAKud,EAAI/I,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAM7B,IALA0J,EAAK,EACLE,EAAK,EACLnO,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAI2G,GACTre,EAAKC,EAAIoU,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAM7B,IALAyU,EAAK,EACLE,EAAK,EACLpH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAIqJ,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmU,EAAInU,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,IAC9BF,GAAMJ,EACNM,GAAMJ,EAEPG,GAAMJ,EACNM,GAAMJ,CACN,CACDO,GAAMF,EACNG,GAAMF,CACN,CACDK,GAAMF,EACNG,GAAMF,CACN,CACDK,GAAMF,EACNG,GAAMF,CACN,CACF,I1BqOAlzB,EAAAsb,GAAA,iB2B3VA,SAAwBuW,EAAQG,EAAQ1jB,GACvC,IAAI2jB,EACAC,EACAC,EACAC,EACAiB,EACAC,EACAC,EACAC,EACA5X,EACAC,EACA8B,EACAC,EACAyU,EACAC,EACAC,EACAC,EACAiB,EACAC,EACAC,EACAC,EACAzI,EACAC,EACA0G,EACA+B,EACAC,EACAzJ,EACApN,EACApM,EACA3I,EACAiK,EACApG,EACAmL,EACAiM,EAKJ,GAFAvH,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAiCtB,IA7BA3T,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GAGV/F,GADArG,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENqiB,GADAtW,EAAKpM,EAAEuM,SACG,GACVoW,EAAMvW,EAAI,GAEVkG,EAAI0O,EAAQ,GAEZS,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACChW,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAU7B,IATAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLxI,EAAKjjB,EAAGoqB,GACRlH,EAAKjZ,EAAGqgB,GACRV,EAAK/lB,EAAG2nB,GACRG,EAAK3c,EAAG0c,GACRE,EAAK3Q,EAAGvF,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmW,EAAInW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,GAAMI,EAAIF,IAClDtB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EAEPjB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,CACN,CACF,I3BwQAxzB,EAAAsb,GAAA,iB4BrWA,SAAwBuW,EAAQG,EAAQ1jB,GACvC,IAAI2jB,EACAC,EACAO,EACAN,EACAC,EACAM,EACAW,EACAC,EACAS,EACAR,EACAC,EACAQ,EACApY,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAyJ,EACAC,EACAK,EACAJ,EACAC,EACAI,EACAa,EACAC,EACAO,EACAN,EACAC,EACAM,EACA/I,EACA9G,EACA+G,EACAzI,EACAmP,EACAvd,EACAsf,EACAM,EACAL,EACAM,EACA/J,EACApN,EACApM,EACA3I,EACAiK,EACApG,EACAmL,EACAiM,EAMJ,GAHAvH,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAqCjC,IAjCAzgB,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GACV8W,EAAM9W,EAAI,GAGV/F,GADArG,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENqiB,GADAtW,EAAKpM,EAAEuM,SACG,GACVoW,EAAMvW,EAAI,GACV+W,EAAM/W,EAAI,GAEVkG,EAAI0O,EAAQ,GAEZc,EAAK,EACLC,EAAK,EACLqB,EAAK,EACLC,EAAK,EACCtL,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLvP,EAAKnc,EAAGyqB,GACRhQ,EAAKxQ,EAAGygB,GACRre,EAAKxI,EAAGkoB,GACRE,EAAKjd,EAAGgd,GACRE,EAAKjR,EAAGyF,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAU7B,IATAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLxI,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAImf,GACTG,EAAKM,EAAIP,GACTE,EAAKM,EAAIxW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmW,EAAInW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,GAAMI,EAAIF,IAClDtB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EAEPjB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,CACN,CACDb,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,EACNG,GAAMF,CACN,CACF,I5B+OAh0B,EAAAsb,GAAA,iB6B/WA,SAAwBuW,EAAQG,EAAQ1jB,GACvC,IAAI2jB,EACAC,EACAO,EACAI,EACAV,EACAC,EACAM,EACAI,EACAO,EACAC,EACAS,EACAM,EACAd,EACAC,EACAQ,EACAM,EACA1Y,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAqJ,EACAC,EACAK,EACAI,EACAR,EACAC,EACAI,EACAI,EACAS,EACAC,EACAO,EACAM,EACAZ,EACAC,EACAM,EACAM,EACArJ,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA6F,EACAvd,EACAC,EACAqf,EACAM,EACAM,GACAX,GACAM,GACAM,GACArK,GACApN,GACApM,GACA3I,GACAiK,GACApG,GACAmL,GACAiM,GAOJ,GAJAvH,GADAyO,GAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,GAAI,GACT1B,EAAK0B,GAAI,GACTtB,EAAKsB,GAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAyC5C,IArCA7gB,IADA2I,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAEN+gB,GADAhV,GAAKpM,GAAEuM,SACG,GACV8U,EAAMjV,GAAI,GACVwV,EAAMxV,GAAI,GACV4V,EAAM5V,GAAI,GAGV9K,IADAtB,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENihB,GADAlV,GAAKpM,GAAEuM,SACG,GACVgV,EAAMnV,GAAI,GACVyV,EAAMzV,GAAI,GACV6V,EAAM7V,GAAI,GAGVlR,IADA8E,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENmiB,GADApW,GAAKpM,GAAEuM,SACG,GACVkW,EAAMrW,GAAI,GACV8W,EAAM9W,GAAI,GACVoX,EAAMpX,GAAI,GAGV/F,IADArG,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENqiB,GADAtW,GAAKpM,GAAEuM,SACG,GACVoW,EAAMvW,GAAI,GACV+W,EAAM/W,GAAI,GACVqX,EAAMrX,GAAI,GAEVkG,GAAI0O,EAAQ,GAEZkB,EAAK,EACLC,EAAK,EACLuB,EAAK,EACLC,EAAK,EACCxL,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA2J,EAAK,EACLC,EAAK,EACLqB,EAAK,EACLC,EAAK,EACL5P,EAAKpc,GAAG6qB,GACR9G,EAAK9Z,GAAG6gB,GACRxe,EAAKzI,GAAGwoB,GACRE,GAAKvd,GAAGsd,GACRE,GAAKvR,GAAG6F,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLvP,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAI2G,GACTre,EAAKC,EAAIyf,GACTE,EAAKM,GAAIP,GACTE,GAAKM,GAAI9L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAU7B,IATAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLxI,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAImf,GACTG,EAAKM,EAAIP,GACTE,GAAKM,GAAIxW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmW,GAAInW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,GAAMI,EAAIF,IAClDtB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EAEPjB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,CACN,CACDb,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,EACNG,GAAMF,CACN,CACDjB,GAAMF,EACNG,GAAMF,EACNyB,GAAMF,EACNG,GAAMF,CACN,CACF,I7BsNAt0B,EAAAsb,GAAA,iB8BzXA,SAAwBuW,EAAQG,EAAQ1jB,GACvC,IAAI2jB,EACAC,EACAO,EACAI,EACAI,EACAd,EACAC,EACAM,EACAI,EACAI,EACAG,EACAC,EACAS,EACAM,EACAM,EACApB,EACAC,EACAQ,EACAM,EACAM,EACAhZ,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACAiJ,EACAC,EACAK,EACAI,EACAI,EACAZ,EACAC,EACAI,EACAI,EACAI,EACAK,EACAC,EACAO,EACAM,EACAM,EACAlB,EACAC,EACAM,EACAM,EACAM,EACA3J,EACA9G,GACAC,GACA6H,GACAf,GACAzI,GACAsJ,GACAG,GACA0F,GACAvd,GACAC,GACAud,GACA8B,GACAM,GACAM,GACAM,GACAjB,GACAM,GACAM,GACAM,GACA3K,GACApN,GACApM,GACA3I,GACAiK,GACApG,GACAmL,GACAiM,GAQJ,GALAvH,GADAyO,GAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,GAAI,GACT1B,EAAK0B,GAAI,GACTtB,EAAKsB,GAAI,GACTlB,EAAKkB,GAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GA6CvD,IAzCAjhB,IADA2I,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAEN+gB,GADAhV,GAAKpM,GAAEuM,SACG,GACV8U,EAAMjV,GAAI,GACVwV,EAAMxV,GAAI,GACV4V,EAAM5V,GAAI,GACVgW,EAAMhW,GAAI,GAGV9K,IADAtB,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENihB,GADAlV,GAAKpM,GAAEuM,SACG,GACVgV,EAAMnV,GAAI,GACVyV,EAAMzV,GAAI,GACV6V,EAAM7V,GAAI,GACViW,EAAMjW,GAAI,GAGVlR,IADA8E,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENmiB,GADApW,GAAKpM,GAAEuM,SACG,GACVkW,EAAMrW,GAAI,GACV8W,EAAM9W,GAAI,GACVoX,EAAMpX,GAAI,GACV0X,EAAM1X,GAAI,GAGV/F,IADArG,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENqiB,GADAtW,GAAKpM,GAAEuM,SACG,GACVoW,EAAMvW,GAAI,GACV+W,EAAM/W,GAAI,GACVqX,EAAMrX,GAAI,GACV2X,EAAM3X,GAAI,GAEVkG,GAAI0O,EAAQ,GAEZsB,EAAK,EACLC,EAAK,EACLyB,EAAK,EACLC,EAAK,EACC1L,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA2J,EAAK,EACLC,EAAK,EACLuB,EAAK,EACLC,EAAK,EACLrI,GAAKjkB,GAAGirB,GACR/G,GAAKja,GAAGihB,GACRrB,GAAKhmB,GAAG8oB,GACRE,GAAK7d,GAAG4d,GACRE,GAAK7R,GAAGiG,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA2J,EAAK,EACLC,EAAK,EACLqB,EAAK,EACLC,EAAK,EACL5P,GAAK6H,GAAI4G,GACT9G,GAAKG,GAAI4G,GACTxe,GAAKud,GAAIwC,GACTE,GAAKM,GAAIP,GACTE,GAAKM,GAAIhM,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAU7B,IATA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLvP,GAAKC,GAAIqO,GACThQ,GAAKsJ,GAAI2G,GACTre,GAAKC,GAAIyf,GACTE,GAAKM,GAAIP,GACTE,GAAKM,GAAI9L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAU7B,IATAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLxI,EAAK9G,GAAIiO,GACTlH,GAAKzI,GAAI6P,GACTV,GAAKvd,GAAImf,GACTG,GAAKM,GAAIP,GACTE,GAAKM,GAAIxW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBmW,GAAInW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,GAAImH,GAAMT,GAAI2B,GAAMI,GAAIF,IAClDtB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EAEPjB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,CACN,CACDb,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,EACNG,GAAMF,CACN,CACDjB,GAAMF,EACNG,GAAMF,EACNyB,GAAMF,EACNG,GAAMF,CACN,CACDnB,GAAMF,EACNG,GAAMF,EACN2B,GAAMF,EACNG,GAAMF,CACN,CACF,I9B6LA50B,EAAAsb,GAAA,c+B9XA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAC,EACAC,EACAiB,EACAC,EACAC,EACAC,EACAyB,EACAC,EACAtZ,EACAC,EACA8B,EACAC,EACAyU,EACAC,EACAC,EACAC,EACAiB,EACAC,EACAC,EACAC,EACAuB,EACAC,EACAjK,EACAC,EACA0G,EACA+B,EACAC,EACAuB,EACAhL,EACApN,EACApM,EACA3I,EACAiK,EACApG,EACAmL,EACAiM,EACA5gB,EAKJ,GAFAqZ,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAwCtB,IApCA3T,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GAGV/F,GADArG,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENqiB,GADAtW,EAAKpM,EAAEuM,SACG,GACVoW,EAAMvW,EAAI,GAGVkG,GADAtS,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+jB,GADAhY,EAAKpM,EAAEuM,SACG,GACV8X,EAAMjY,EAAI,GAEV1a,EAAIsvB,EAAQ,GAEZS,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLwB,EAAK,EACCxX,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAY7B,IAXAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLwB,EAAK,EACLhK,EAAKjjB,EAAGoqB,GACRlH,EAAKjZ,EAAGqgB,GACRV,EAAK/lB,EAAG2nB,GACRG,EAAK3c,EAAG0c,GACRE,EAAK3Q,EAAGiS,GACRC,EAAK9yB,EAAGqb,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,GAAMI,EAAIF,GAAMG,EAAIqB,IAC5D9C,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EACN4B,GAAMF,EAEP3C,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EACN4B,GAAMF,CACN,CACF,I/B0RAl1B,EAAAsb,GAAA,cgCxYA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAO,EACAI,EACAV,EACAC,EACAM,EACAI,EACAO,EACAC,EACAS,EACAM,EACAd,EACAC,EACAQ,EACAM,EACAW,EACAC,EACAI,EACAC,EACA3Z,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAqJ,EACAC,EACAK,EACAI,EACAR,EACAC,EACAI,EACAI,EACAS,EACAC,EACAO,EACAM,EACAZ,EACAC,EACAM,EACAM,EACAW,EACAC,EACAI,EACAC,EACAtK,EACA9G,EACAC,EACA8G,GACAzI,GACAsJ,GACA6F,GACAvd,GACAC,GACAqf,GACAM,GACAM,GACAX,GACAM,GACAM,GACAW,GACA/Y,GACAC,GACA8N,GACApN,GACApM,GACA3I,GACAiK,GACApG,GACAmL,GACAiM,GACA5gB,GAOJ,GAJAqZ,GADAyO,GAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,GAAI,GACT1B,EAAK0B,GAAI,GACTtB,EAAKsB,GAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAkD5C,IA9CA7gB,IADA2I,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAEN+gB,GADAhV,GAAKpM,GAAEuM,SACG,GACV8U,EAAMjV,GAAI,GACVwV,EAAMxV,GAAI,GACV4V,EAAM5V,GAAI,GAGV9K,IADAtB,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENihB,GADAlV,GAAKpM,GAAEuM,SACG,GACVgV,EAAMnV,GAAI,GACVyV,EAAMzV,GAAI,GACV6V,EAAM7V,GAAI,GAGVlR,IADA8E,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENmiB,GADApW,GAAKpM,GAAEuM,SACG,GACVkW,EAAMrW,GAAI,GACV8W,EAAM9W,GAAI,GACVoX,EAAMpX,GAAI,GAGV/F,IADArG,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENqiB,GADAtW,GAAKpM,GAAEuM,SACG,GACVoW,EAAMvW,GAAI,GACV+W,EAAM/W,GAAI,GACVqX,EAAMrX,GAAI,GAGVkG,IADAtS,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAEN+jB,GADAhY,GAAKpM,GAAEuM,SACG,GACV8X,EAAMjY,GAAI,GACVqY,EAAMrY,GAAI,GACVsY,EAAMtY,GAAI,GAEV1a,GAAIsvB,EAAQ,GAEZkB,EAAK,EACLC,EAAK,EACLuB,EAAK,EACLC,EAAK,EACLiB,EAAK,EACCzM,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAY7B,IAXA2J,EAAK,EACLC,EAAK,EACLqB,EAAK,EACLC,EAAK,EACLsB,EAAK,EACLlR,EAAKpc,GAAG6qB,GACR9G,GAAK9Z,GAAG6gB,GACRxe,GAAKzI,GAAGwoB,GACRE,GAAKvd,GAAGsd,GACRE,GAAKvR,GAAGsS,GACRlZ,GAAKha,GAAGymB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAY7B,IAXA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLwB,EAAK,EACL/Q,EAAKC,EAAIqO,GACThQ,GAAKsJ,GAAI2G,GACTre,GAAKC,GAAIyf,GACTE,GAAKM,GAAIP,GACTE,GAAKM,GAAIc,GACTlZ,GAAKC,GAAIqM,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAY7B,IAXAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLE,EAAK,EACLwB,EAAK,EACLhK,EAAK9G,EAAIiO,GACTlH,GAAKzI,GAAI6P,GACTV,GAAKvd,GAAImf,GACTG,GAAKM,GAAIP,GACTE,GAAKM,GAAIgB,GACTC,GAAK/Y,GAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,GAAI1X,GAAOrP,EAAK6c,EAAIkH,GAAMjH,GAAImH,GAAMT,GAAI2B,GAAMI,GAAIF,GAAMG,GAAIqB,IAC5D9C,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EACN4B,GAAMF,EAEP3C,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EACNM,GAAMJ,EACN4B,GAAMF,CACN,CACDvC,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,EACNG,GAAMF,EACNwB,GAAMF,CACN,CACDvC,GAAMF,EACNG,GAAMF,EACNyB,GAAMF,EACNG,GAAMF,EACNmB,GAAMF,CACN,CACF,IhCgNAv1B,EAAAsb,GAAA,ciCzZA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAC,EACAC,EACAiB,EACAC,EACA1X,EACAC,EACA8B,EACAC,EACAyU,EACAC,EACAC,EACAC,EACAiB,EACAC,EACAvI,EACAC,EACA0G,EACA+B,EACAxJ,EACApN,EACApM,EACA3I,EACAiK,EACApG,EACAmL,EAKJ,GAFA0E,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,KACJzO,GAAM,GAAKC,GAAM,GA0BtB,IAtBA3T,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GAEV/F,EAAI2a,EAAQ,GAEZS,EAAK,EACLE,EAAK,EACLkB,EAAK,EACC9V,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAQ7B,IAPAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLtI,EAAKjjB,EAAGoqB,GACRlH,EAAKjZ,EAAGqgB,GACRV,EAAK/lB,EAAG2nB,GACRG,EAAK3c,EAAG0G,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,IACxCpB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EAEPf,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,CACN,CACF,IjCuVAtzB,EAAAsb,GAAA,ckCnaA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAO,EACAN,EACAC,EACAM,EACAW,EACAC,EACAS,EACAnY,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAyJ,EACAC,EACAK,EACAJ,EACAC,EACAI,EACAa,EACAC,EACAO,EACA9I,EACA9G,EACA+G,EACAzI,EACAmP,EACAvd,EACA8V,EACApN,EACA4W,EACAM,EACAtjB,EACA3I,EACAiK,EACApG,EACAmL,EAMJ,GAHA0E,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GA4BjC,IAxBAzgB,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GACV8W,EAAM9W,EAAI,GAEV/F,EAAI2a,EAAQ,GACZc,EAAK,EACLC,EAAK,EACLqB,EAAK,EACCrL,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLrP,EAAKnc,EAAGyqB,GACRhQ,EAAKxQ,EAAGygB,GACRre,EAAKxI,EAAGkoB,GACRE,EAAKjd,EAAG0R,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAQ7B,IAPAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLtI,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAImf,GACTG,EAAKM,EAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,IACxCpB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EAEPf,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,CACN,CACDX,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,CACN,CACF,IlCsUA/zB,EAAAsb,GAAA,cmC5aA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAO,EACAI,EACAV,EACAC,EACAM,EACAI,EACAO,EACAC,EACAS,EACAM,EACAzY,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAqJ,EACAC,EACAK,EACAI,EACAR,EACAC,EACAI,EACAI,EACAS,EACAC,EACAO,EACAM,EACApJ,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA6F,EACAvd,EACAC,EACA6V,EACApN,EACA4W,EACAM,EACAM,EACA5jB,EACA3I,EACAiK,EACApG,EACAmL,EAOJ,GAJA0E,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,GACTtB,EAAKsB,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GA+B5C,IA3BA7gB,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GACV4V,EAAM5V,EAAI,GAGV9K,GADAtB,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENihB,GADAlV,EAAKpM,EAAEuM,SACG,GACVgV,EAAMnV,EAAI,GACVyV,EAAMzV,EAAI,GACV6V,EAAM7V,EAAI,GAGVlR,GADA8E,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAENmiB,GADApW,EAAKpM,EAAEuM,SACG,GACVkW,EAAMrW,EAAI,GACV8W,EAAM9W,EAAI,GACVoX,EAAMpX,EAAI,GAEV/F,EAAI2a,EAAQ,GACZkB,EAAK,EACLC,EAAK,EACLuB,EAAK,EACCvL,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA2J,EAAK,EACLC,EAAK,EACLqB,EAAK,EACL3P,EAAKpc,EAAG6qB,GACR9G,EAAK9Z,EAAG6gB,GACRxe,EAAKzI,EAAGwoB,GACRE,EAAKvd,EAAG8R,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLrP,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAI2G,GACTre,EAAKC,EAAIyf,GACTE,EAAKM,EAAI7L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAQ7B,IAPAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLtI,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAImf,GACTG,EAAKM,EAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,IACxCpB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EAEPf,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,CACN,CACDX,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,CACN,CACDhB,GAAMF,EACNG,GAAMF,EACNyB,GAAMF,CACN,CACF,InCmTAr0B,EAAAsb,GAAA,coCtbA,SAAqBuW,EAAQG,EAAQ1jB,GACpC,IAAI2jB,EACAC,EACAO,EACAI,EACAI,EACAd,EACAC,EACAM,EACAI,EACAI,EACAG,EACAC,EACAS,EACAM,EACAM,EACA/Y,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACAiJ,EACAC,EACAK,EACAI,EACAI,EACAZ,EACAC,EACAI,EACAI,EACAI,EACAK,EACAC,EACAO,EACAM,EACAM,EACA1J,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACA0F,EACAvd,EACAC,EACAud,GACA1H,GACApN,GACA4W,GACAM,GACAM,GACAM,GACAlkB,GACA3I,GACAiK,GACApG,GACAmL,GAQJ,GALA0E,GADAyO,GAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,GAAI,GACT1B,EAAK0B,GAAI,GACTtB,EAAKsB,GAAI,GACTlB,EAAKkB,GAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAmCvD,IA/BAjhB,IADA2I,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAEN+gB,GADAhV,GAAKpM,GAAEuM,SACG,GACV8U,EAAMjV,GAAI,GACVwV,EAAMxV,GAAI,GACV4V,EAAM5V,GAAI,GACVgW,EAAMhW,GAAI,GAGV9K,IADAtB,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENihB,GADAlV,GAAKpM,GAAEuM,SACG,GACVgV,EAAMnV,GAAI,GACVyV,EAAMzV,GAAI,GACV6V,EAAM7V,GAAI,GACViW,EAAMjW,GAAI,GAGVlR,IADA8E,GAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,KACxCnZ,KAENmiB,GADApW,GAAKpM,GAAEuM,SACG,GACVkW,EAAMrW,GAAI,GACV8W,EAAM9W,GAAI,GACVoX,EAAMpX,GAAI,GACV0X,EAAM1X,GAAI,GAEV/F,GAAI2a,EAAQ,GACZsB,EAAK,EACLC,EAAK,EACLyB,EAAK,EAECzL,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA2J,EAAK,EACLC,EAAK,EACLuB,EAAK,EACLpI,EAAKjkB,GAAGirB,GACR/G,EAAKja,GAAGihB,GACRrB,GAAKhmB,GAAG8oB,GACRE,GAAK7d,GAAGkS,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA2J,EAAK,EACLC,EAAK,EACLqB,EAAK,EACL3P,EAAK6H,EAAI4G,GACT9G,EAAKG,EAAI4G,GACTxe,EAAKud,GAAIwC,GACTE,GAAKM,GAAI/L,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAQ7B,IAPA0J,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLrP,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAI2G,GACTre,EAAKC,EAAIyf,GACTE,GAAKM,GAAI7L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAQ7B,IAPAyU,EAAK,EACLE,EAAK,EACLkB,EAAK,EACLtI,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI6P,GACTV,EAAKvd,EAAImf,GACTG,GAAKM,GAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,GAAIlW,GAAOrP,EAAK6c,EAAIkH,GAAMjH,EAAImH,GAAMT,EAAI2B,IACxCpB,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,EAEPf,GAAMJ,EACNM,GAAMJ,EACNsB,GAAMJ,CACN,CACDX,GAAMF,EACNG,GAAMF,EACNuB,GAAMF,CACN,CACDhB,GAAMF,EACNG,GAAMF,EACNyB,GAAMF,CACN,CACDlB,GAAMF,EACNG,GAAMF,EACN2B,GAAMF,CACN,CACF,IpCgSA30B,EAAAsb,GAAA,YqClcA,SAAmBuW,EAAQG,EAAQ1jB,GAClC,IAAI2jB,EACAC,EACAtW,EACAC,EACA8B,EACAC,EACAyU,EACAC,EACAnH,EACAC,EACAf,EACApN,EACApM,EACA3I,EACAiK,EAKJ,GAFAyJ,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAYtB,IARA3T,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GAEV9K,EAAI0f,EAAQ,GAEZS,EAAK,EACC1U,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAI7B,IAHAyU,EAAK,EACLlH,EAAKjjB,EAAGoqB,GACRlH,EAAKjZ,EAAGyL,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIkH,IACpBA,GAAMJ,EAEPK,GAAMJ,CACN,CACF,IrCkaAlyB,EAAAsb,GAAA,YsC5cA,SAAmBuW,EAAQG,EAAQ1jB,GAClC,IAAI2jB,EACAC,EACAO,EACA7W,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAyJ,EACAC,EACAK,EACAxH,EACA9G,EACA+G,EACAzI,EACA0H,EACApN,EACApM,EACA3I,EACAiK,EAMJ,GAHAyJ,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAYjC,IARAzgB,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GAEV9K,EAAI0f,EAAQ,GACZc,EAAK,EACC/J,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA0J,EAAK,EACLjO,EAAKnc,EAAGyqB,GACRhQ,EAAKxQ,EAAGyW,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAI7B,IAHAyU,EAAK,EACLlH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIkH,IACpBA,GAAMJ,EAEPK,GAAMJ,CACN,CACDS,GAAMF,CACN,CACF,ItC+ZAzyB,EAAAsb,GAAA,YuCtdA,SAAmBuW,EAAQG,EAAQ1jB,GAClC,IAAI2jB,EACAC,EACAO,EACAI,EACAjX,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAqJ,EACAC,EACAK,EACAI,EACA5H,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA5B,EACApN,EACApM,EACA3I,EACAiK,EAOJ,GAJAyJ,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,GACTtB,EAAKsB,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAa5C,IATA7gB,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GACV4V,EAAM5V,EAAI,GAEV9K,EAAI0f,EAAQ,GACZkB,EAAK,EACC/J,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA2J,EAAK,EACLrO,EAAKpc,EAAG6qB,GACR9G,EAAK9Z,EAAG6W,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA0J,EAAK,EACLjO,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAI7B,IAHAyU,EAAK,EACLlH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIkH,IACpBA,GAAMJ,EAEPK,GAAMJ,CACN,CACDS,GAAMF,CACN,CACDM,GAAMF,CACN,CACF,IvC2ZA7yB,EAAAsb,GAAA,YwCheA,SAAmBuW,EAAQG,EAAQ1jB,GAClC,IAAI2jB,EACAC,EACAO,EACAI,EACAI,EACArX,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACAiJ,EACAC,EACAK,EACAI,EACAI,EACAhI,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACA/B,EACApN,EACApM,EACA3I,EACAiK,EAQJ,GALAyJ,GADAyO,EAAK2H,EAAQ,IACJ,GACTnW,EAAKwO,EAAI,GACT1B,EAAK0B,EAAI,GACTtB,EAAKsB,EAAI,GACTlB,EAAKkB,EAAI,KACJzO,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAcvD,IAVAjhB,GADA2I,EAAIiM,GAAgB+U,EAAQ,GAAKG,EAAQ,GAAK3H,IACxCnZ,KAEN+gB,GADAhV,EAAKpM,EAAEuM,SACG,GACV8U,EAAMjV,EAAI,GACVwV,EAAMxV,EAAI,GACV4V,EAAM5V,EAAI,GACVgW,EAAMhW,EAAI,GAEV9K,EAAI0f,EAAQ,GACZsB,EAAK,EACC/J,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA2J,EAAK,EACL5G,EAAKjkB,EAAGirB,GACR/G,EAAKja,EAAGiX,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA2J,EAAK,EACLrO,EAAK6H,EAAI4G,GACT9G,EAAKG,EAAIpD,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAI7B,IAHA0J,EAAK,EACLjO,EAAKC,EAAIqO,GACThQ,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAI7B,IAHAyU,EAAK,EACLlH,EAAK9G,EAAIiO,GACTlH,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIkH,IACpBA,GAAMJ,EAEPK,GAAMJ,CACN,CACDS,GAAMF,CACN,CACDM,GAAMF,CACN,CACDM,GAAMF,CACN,CACF,IxCuZAjzB,EAAAsb,GAAA,iBAAA4I,IAUAlkB,EAAAsb,GAAA,mBAAA8I,IAUApkB,EAAAsb,GAAA,kBAAAmJ,IAUAzkB,EAAAsb,GAAA,OAAAuB,IAUA7c,EAAAsb,GAAA,cAAAoa,IAUA11B,EAAAsb,GAAA,aAAAqJ,IAUA3kB,EAAAsb,GAAA,WyCxeA,SAAkBpT,EAAGtF,EAAW8K,GAC/B,OAAKpN,EAAiB4H,GAtCvB,SAAoBA,EAAGtF,EAAW8K,GACjC,IAAI7N,EACA1G,EACAC,EAKJ,IAHAyG,EAAMwR,GAAenJ,GAErB/O,EAAI,EACEC,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrBwJ,EAAU1H,KAAMwS,EAAS7N,EAAKqI,EAAG9O,GAAKA,EAAG8O,KAC7C/O,GAAK,GAGP,OAAOA,CACR,CAyBSqX,CAAWtI,EAAGtF,EAAW8K,GAzElC,SAAkBxF,EAAGtF,EAAW8K,GAC/B,IAAIvU,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrBwJ,EAAU1H,KAAMwS,EAASxF,EAAG9O,GAAKA,EAAG8O,KACxC/O,GAAK,GAGP,OAAOA,CACR,CAgEQurB,CAASxc,EAAGtF,EAAW8K,EAC/B,IzC6eA1N,EAAAsb,GAAA,YrMzdA,WACC,IAAIqa,EACA9D,EAEAnxB,EACAwH,EACA9O,EAIJ,IAFAy4B,EAAS,GACT8D,EAAa,GACPv8B,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,GAAK,EACvCy4B,EAAO1zB,KAAM8S,GAAkB3T,UAAWlE,KAC1Cu8B,EAAWx3B,KAAMb,UAAWlE,EAAE,IAK/B,IADAsH,EAAMqkB,GADAznB,UAAW,GAAI1D,QAEfR,EAAI,EAAGA,EAAIy4B,EAAOj4B,OAAQR,IAG9BsH,GAFDwH,EAAI2pB,EAAQz4B,IACLsX,iBACAF,GAAWtI,EAAGxH,EAAKi1B,EAAYv8B,IAE/BsrB,GAASxc,EAAEgJ,KAAMxQ,EAAKi1B,EAAYv8B,IAG1C,OAAOsH,EAAI9G,MACZ,IqMycAoG,EAAAsb,GAAA,kB0C7aA,SAAyBpT,EAAGjP,GAC3B,OAAKqH,EAAiB4H,GAChBiO,GAAqBjO,GAtF5B,SAAkBA,EAAGjP,GACpB,IAAI2rB,EACA9Z,EACAC,EACA5R,EACAC,EAEJ,IAAMkS,GAAerS,GACpB,OAAO,EAQR,IANA6R,EAAKH,GAAM1R,GACX8R,EAAKH,GAAM3R,GAEX2rB,EAAO5Y,GAAa9D,EAAG,GAEvB/O,EAAI,EACEC,EAAI,EAAGA,EAAIwrB,EAAKhrB,OAAQR,GAAK,EAC7B+b,GAAayP,EAAMxrB,GAAK0R,IAAQqK,GAAayP,EAAMxrB,EAAE,GAAK2R,KAC9D5R,GAAK,GAGP,OAAOA,CACR,CAiEU2rB,CAAS5c,EAAGjP,GAEf8W,GAAgB7H,GAjDvB,SAAkBA,EAAGjP,GACpB,IAAI2rB,EACAzrB,EACAoJ,EACAnJ,EAEJ,IAAM+P,GAAWlQ,GAChB,OAAO,EAMR,IAJA2rB,EAAOzI,GAAoBjU,EAAG,GAE9B3F,EAAI,EAAY,EAAI,EACpBpJ,EAAI,EACEC,EAAI,EAAGA,EAAIwrB,EAAKhrB,OAAQR,IACxBwrB,EAAMxrB,KAAQmJ,IAClBpJ,GAAK,GAGP,OAAOA,CACR,CA+BUisB,CAASld,EAAGjP,GA3HtB,SAAoBiP,EAAGjP,GACtB,IAAI4G,EACA1G,EACAC,EAKJ,IAHAyG,EAAMwR,GAAenJ,GAErB/O,EAAI,EACEC,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrB+b,GAAatV,EAAKqI,EAAG9O,GAAKH,KAC9BE,GAAK,GAGP,OAAOA,CACR,CA+GSqX,CAAWtI,EAAGjP,GA1JvB,SAAkBiP,EAAGjP,GACpB,IAAIE,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrB+b,GAAajN,EAAG9O,GAAKH,KACzBE,GAAK,GAGP,OAAOA,CACR,CAiJQurB,CAASxc,EAAGjP,EACpB,I1C4aA+G,EAAAsb,GAAA,sB2CvbA,SAA6BpT,EAAGjP,GAC/B,OAAKqH,EAAiB4H,GAChBiO,GAAqBjO,GAtF5B,SAAkBA,EAAGjP,GACpB,IAAI2rB,EACA9Z,EACAC,EACA5R,EACAC,EAEJ,IAAMkS,GAAerS,GACpB,OAAO,EAQR,IANA6R,EAAKH,GAAM1R,GACX8R,EAAKH,GAAM3R,GAEX2rB,EAAO5Y,GAAa9D,EAAG,GAEvB/O,EAAI,EACEC,EAAI,EAAGA,EAAIwrB,EAAKhrB,OAAQR,GAAK,EAC7B4rB,GAAiBJ,EAAMxrB,GAAK0R,IAAQka,GAAiBJ,EAAMxrB,EAAE,GAAK2R,KACtE5R,GAAK,GAGP,OAAOA,CACR,CAiEU2rB,CAAS5c,EAAGjP,GAEf8W,GAAgB7H,GAjDvB,SAAkBA,EAAGjP,GACpB,IAAI2rB,EACAzrB,EACAoJ,EACAnJ,EAEJ,IAAM+P,GAAWlQ,GAChB,OAAO,EAMR,IAJA2rB,EAAOzI,GAAoBjU,EAAG,GAE9B3F,EAAI,EAAY,EAAI,EACpBpJ,EAAI,EACEC,EAAI,EAAGA,EAAIwrB,EAAKhrB,OAAQR,IACxBwrB,EAAMxrB,KAAQmJ,IAClBpJ,GAAK,GAGP,OAAOA,CACR,CA+BUisB,CAASld,EAAGjP,GA3HtB,SAAoBiP,EAAGjP,GACtB,IAAI4G,EACA1G,EACAC,EAKJ,IAHAyG,EAAMwR,GAAenJ,GAErB/O,EAAI,EACEC,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrB4rB,GAAiBnlB,EAAKqI,EAAG9O,GAAKH,KAClCE,GAAK,GAGP,OAAOA,CACR,CA+GSqX,CAAWtI,EAAGjP,GA1JvB,SAAkBiP,EAAGjP,GACpB,IAAIE,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrB4rB,GAAiB9c,EAAG9O,GAAKH,KAC7BE,GAAK,GAGP,OAAOA,CACR,CAiJQurB,CAASxc,EAAGjP,EACpB,I3CsbA+G,EAAAsb,GAAA,cAAA2J,IAUAjlB,EAAAsb,GAAA,QAAA+J,IAUArlB,EAAAsb,GAAA,UAAAgK,IAUAtlB,EAAAsb,GAAA,SAAAiK,IAUAvlB,EAAAsb,GAAA,U4CrfA,SAAiBpT,EAAG0tB,EAAOC,GAC1B,OAAKA,EAzEN,SAA0B3tB,EAAG0tB,GAC5B,IAAIE,EACA/3B,EACA8E,EACAkzB,EACAp0B,EACAY,EACAnJ,EAGJ,GAAa,KADbyJ,EAAMqF,EAAEtO,QAEP,OAAOsO,EASR,IAPAvG,GAAM,EAEDnF,GADLuB,EAAOmK,EAAG,MAETvG,GAAM,GAEPm0B,EAAQ,EACRC,EAAM,EACA38B,EAAI,EAAGA,EAAIyJ,EAAKzJ,KACrBmJ,EAAI2F,EAAG9O,MACI2E,GAAU4D,GAAOnF,GAAO+F,IAClCuzB,GAAS,IACKF,IACb1tB,EAAG6tB,GAAQh4B,EACXg4B,GAAO,IAGRh4B,EAAOwE,EACPuzB,EAAQ,EACR5tB,EAAG6tB,GAAQh4B,EACXg4B,GAAO,EACPp0B,GAAM,EACDnF,GAAOuB,KACX4D,GAAM,IAKT,OADAuG,EAAEtO,OAASm8B,EACJ7tB,CACR,CAiCS8tB,CAAiB9tB,EAAG0tB,GAtI7B,SAAwB1tB,EAAG0tB,GAC1B,IAAIE,EACA/3B,EACA8E,EACAkzB,EACAxzB,EACAnJ,EAGJ,GAAa,KADbyJ,EAAMqF,EAAEtO,QAEP,OAAOsO,EAKR,IAHAnK,EAAOmK,EAAG,GACV4tB,EAAQ,EACRC,EAAM,EACA38B,EAAI,EAAGA,EAAIyJ,EAAKzJ,KACrBmJ,EAAI2F,EAAG9O,MACI2E,GACV+3B,GAAS,IACKF,IACb1tB,EAAG6tB,GAAQh4B,EACXg4B,GAAO,IAGRh4B,EAAOwE,EACPuzB,EAAQ,EACR5tB,EAAG6tB,GAAQh4B,EACXg4B,GAAO,GAIT,OADA7tB,EAAEtO,OAASm8B,EACJ7tB,CACR,CAwGQ+tB,CAAe/tB,EAAG0tB,EAC1B,I5C0fA51B,EAAAsb,GAAA,mB6C3oBA,SAA0B7a,EAAKy1B,GAC9B,IAAIr2B,EACAxG,EACAiG,EACA2P,EACA7V,EACAge,EACA7U,EAGJ,IADA0M,EAAIxO,EAAI7G,QACC,EACR,MAAO,GAQR,IALAwd,GADAvX,EAAMwR,GAAe6kB,IACZA,EAAQ,GACjB3zB,EAAI1C,EAAKq2B,EAAQ,GAEjBr2B,EAAMwR,GAAe5Q,GACrBpH,EAAM,GACAD,EAAI,EAAGA,EAAI6V,EAAG7V,KACnBkG,EAAM,CAAA,GACD8X,GAAMhe,EACXkG,EAAKiD,GAAM1C,EAAKY,EAAKrH,GACrBC,EAAI8E,KAAMmB,GAEX,OAAOjG,CACR,I7C2nBA2G,EAAAsb,GAAA,iB8CtnBA,SAAwB7a,EAAKy1B,GAC5B,IAAIC,EACAt2B,EACAC,EACAkP,EACA3V,EACA4V,EACAmI,EACA7U,EACAnJ,EAGJ,IADA6V,EAAIxO,EAAI7G,QACC,EACR,MAAO,GAqBR,SAASw8B,EAAOh9B,GAEf,OADAgH,EAA0ByK,KAAM,KAAMzR,GAC/ByR,IACP,CAWD,IAhCAmE,EAAMwB,GAAW/P,GAAM+P,UACvB3Q,EAAMmP,EAAK,GACXlP,EAAMkP,EAAK,GAGXmnB,EAAO9kB,GAAe6kB,GACtB9e,EAAI+e,EAAMD,EAAQ,GAClB3zB,EAAI4zB,EAAMD,EAAQ,GClDnB,SAA8B52B,EAAKC,EAAM8B,GACxCtI,EAAgBuG,EAAKC,EAAM,CAC1BU,cAAgB,EAChBC,YAAc,EACdL,IAAOwB,GAET,CD6DCg1B,CAAqBD,EAAMn8B,UAAWmd,GAmBtC,WACC,OAAOvM,KAAKyrB,EACZ,IApBD9Q,GAAsB4Q,EAAMn8B,UAAWsI,GA4BvC,WACC,OAAO1C,EAAKY,EAAKoK,KAAKyrB,GACtB,IAQD,SAAmBr9B,GAClB6G,EAAKW,EAAKoK,KAAKyrB,GAAIr9B,EACnB,IArCDmH,EAA0Bg2B,EAAMn8B,UAAW,UA6C3C,WACC,IAAIZ,EAKJ,OAHAA,EAAM,CAAA,EACNA,EAAK+d,GAAMvM,KAAMuM,GACjB/d,EAAKkJ,GAAMsI,KAAMtI,GACVlJ,CACP,IAjDDA,EAAM,GACAD,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBC,EAAI8E,KAAM,IAAIi4B,EAAOh9B,IAEtB,OAAOC,CA8CR,I9C+hBA2G,EAAAsb,GAAA,SzL7iBA,SAAgBpT,GACf,IAAI5I,EAAM2R,GAAkB/I,GAC5B,OAAK5I,EAAIoR,iBAEHhF,GAAmBxD,GAChBud,GAAiBnY,GAAgBpF,EAAG,IAEvCuD,GAAkBvD,GACfud,GAAiBpY,GAAenF,EAAG,IAGtC6H,GAAgB7H,GACbkJ,GAAU+K,GAAoBjU,EAAG,IAjD3C,SAAoBA,GACnB,IAAIgJ,EACArR,EACAzG,EAKJ,IAHA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEbpX,EAAI,EAAGA,EAAI8X,EAAKtX,OAAQR,IAC7B,IAAMyG,EAAKqR,EAAM9X,GAChB,OAAO,EAGT,OAAO,CACR,CAqCSoX,CAAWlR,GAEZ8R,GAAUlJ,EAClB,IyLsiBAlI,EAAAsb,GAAA,WgD/kBA,SAAkBpT,EAAGtF,EAAW8K,GAC/B,IAAIpO,EACJ,OA9FD,SAAoBA,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CA4FMC,CAAW1mB,EAAG,SACXA,EAAEquB,MAAO3zB,EAAW8K,IAE5BpO,EAAM2R,GAAkB/I,IACfwI,iBA3CV,SAAoBxI,EAAGtF,EAAW8K,GACjC,IAAIwD,EACArR,EACAzG,EAKJ,IAHA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEbpX,EAAI,EAAGA,EAAI8X,EAAKtX,OAAQR,IAC7B,IAAMwJ,EAAU1H,KAAMwS,EAAS7N,EAAKqR,EAAM9X,GAAKA,EAAG8X,GACjD,OAAO,EAGT,OAAO,CACR,CA8BSV,CAAWlR,EAAKsD,EAAW8K,GA5EpC,SAAmBxF,EAAGtF,EAAW8K,GAChC,IAAItU,EACJ,IAAMA,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1B,IAAMwJ,EAAU1H,KAAMwS,EAASxF,EAAG9O,GAAKA,EAAG8O,GACzC,OAAO,EAGT,OAAO,CACR,CAsEQkJ,CAAUlJ,EAAGtF,EAAW8K,EAChC,IhD+kBA1N,EAAAsb,GAAA,gBiD7mBA,SAAuBpT,EAAGtF,EAAW8K,GACpC,IAAIpO,EAAM2R,GAAkB/I,GAC5B,OAAK5I,EAAIoR,iBAvCV,SAAoBxI,EAAGtF,EAAW8K,GACjC,IAAIwD,EACArR,EACAzG,EAKJ,IAHA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEbpX,EAAI8X,EAAKtX,OAAO,EAAGR,GAAK,EAAGA,IAChC,IAAMwJ,EAAU1H,KAAMwS,EAAS7N,EAAKqR,EAAM9X,GAAKA,EAAG8X,GACjD,OAAO,EAGT,OAAO,CACR,CA0BSV,CAAWlR,EAAKsD,EAAW8K,GAxEpC,SAAmBxF,EAAGtF,EAAW8K,GAChC,IAAItU,EACJ,IAAMA,EAAI8O,EAAEtO,OAAO,EAAGR,GAAK,EAAGA,IAC7B,IAAMwJ,EAAU1H,KAAMwS,EAASxF,EAAG9O,GAAKA,EAAG8O,GACzC,OAAO,EAGT,OAAO,CACR,CAkEQkJ,CAAUlJ,EAAGtF,EAAW8K,EAChC,IjDinBA1N,EAAAsb,GAAA,aAAAkb,IAUAx2B,EAAAsb,GAAA,mBAAAmb,IAUAz2B,EAAAsb,GAAA,QkD1mBA,SAAepT,EAAGjP,EAAOgV,EAAOI,GAC/B,IAAI/O,EACJ,OA3GD,SAAoBA,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CAyGMC,CAAW1mB,EAAG,QACXA,EAAEuV,KAAMxkB,EAAOgV,EAAOI,IAEzBJ,EAAQ,IACZA,GAAS/F,EAAEtO,QACE,IACZqU,EAAQ,GAGLI,EAAM,EACVA,GAAOnG,EAAEtO,OACEyU,EAAMnG,EAAEtO,SACnByU,EAAMnG,EAAEtO,SAET0F,EAAM2R,GAAkB/I,IACfwI,iBA9DV,SAAoBxI,EAAGjP,EAAOgV,EAAOI,GACpC,IAAI6C,EACApR,EACA1G,EAIJ,IAFA8X,EAAOhJ,EAAEgJ,KACTpR,EAAMoI,EAAEsI,UAAW,GACbpX,EAAI6U,EAAO7U,EAAIiV,EAAKjV,IACzB0G,EAAKoR,EAAM9X,EAAGH,GAEf,OAAOiY,CACR,CAoDSV,CAAWlR,EAAKrG,EAAOgV,EAAOI,GAvGvC,SAAkBnG,EAAGjP,EAAOgV,EAAOI,GAClC,IAAIjV,EACJ,IAAMA,EAAI6U,EAAO7U,EAAIiV,EAAKjV,IACzB8O,EAAG9O,GAAMH,EAEV,OAAOiP,CACR,CAmGQwc,CAASxc,EAAGjP,EAAOgV,EAAOI,GAClC,IlD+lBArO,EAAAsb,GAAA,UmDnnBA,SAAiBpT,EAAG+F,EAAOI,EAAKC,EAAKZ,GACpC,IAAIpO,EAaJ,OAZK2O,EAAQ,IACZA,GAAS/F,EAAEtO,QACE,IACZqU,EAAQ,GAGLI,EAAM,EACVA,GAAOnG,EAAEtO,OACEyU,EAAMnG,EAAEtO,SACnByU,EAAMnG,EAAEtO,SAET0F,EAAM2R,GAAkB/I,IACfwI,iBAtEV,SAAoBxI,EAAG+F,EAAOI,EAAKC,EAAKZ,GACvC,IAAIwD,EACArR,EACAC,EACA1G,EAKJ,IAHA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GACnB1Q,EAAMoI,EAAEsI,UAAW,GACbpX,EAAI6U,EAAO7U,EAAIiV,EAAKjV,IACzB0G,EAAKoR,EAAM9X,EAAGkV,EAAIpT,KAAMwS,EAAS7N,EAAKqR,EAAM9X,GAAKA,EAAG8X,IAErD,OAAOA,CACR,CA0DSV,CAAWlR,EAAK2O,EAAOI,EAAKC,EAAKZ,GApH1C,SAAkBxF,EAAG+F,EAAOI,EAAKC,EAAKZ,GACrC,IAAItU,EACJ,IAAMA,EAAI6U,EAAO7U,EAAIiV,EAAKjV,IACzB8O,EAAG9O,GAAMkV,EAAIpT,KAAMwS,EAASxF,EAAG9O,GAAKA,EAAG8O,GAExC,OAAOA,CACR,CAgHQwc,CAASxc,EAAG+F,EAAOI,EAAKC,EAAKZ,EACrC,InD2mBA1N,EAAAsb,GAAA,SAAAG,IAUAzb,EAAAsb,GAAA,WAAAkN,IAUAxoB,EAAAsb,GAAA,WAAAI,IAUA1b,EAAAsb,GAAA,coD5wBA,SAAqBK,EAAOhO,EAAMD,GACjC,IAAIjN,EACAid,EACA9B,EACAC,EACAziB,EACA8D,EAOJ,IALA0e,EAAKD,EAAO,GACZE,EAAKF,EAAO,GAGZlb,EAAM,GACArH,EAAI,EAAGA,EAAIyiB,EAAIziB,IAAM,CAE1B,IADAskB,EAAK,GACCxgB,EAAI,EAAGA,EAAI0e,EAAI1e,IACpBwgB,EAAGvf,KAAMwP,EAAKzS,KAAMwS,EAAS,CAAEtU,EAAG8D,KAEnCuD,EAAItC,KAAMuf,EACV,CACD,OAAOjd,CACR,IpDiwBAT,EAAAsb,GAAA,WAAAmN,IAUAzoB,EAAAsb,GAAA,cqDhyBA,SAAqBK,EAAOhO,EAAMD,GACjC,IAAIjN,EACAid,EACAgL,EACA9M,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EAQJ,IANAhN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GAGZlb,EAAM,GACAmoB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAE7B,IADAF,EAAK,GACCC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBD,EAAGvf,KAAMwP,EAAKzS,KAAMwS,EAAS,CAAEkb,EAAIhL,EAAID,KAExC+K,EAAGvqB,KAAMuf,EACT,CACDjd,EAAItC,KAAMuqB,EACV,CACD,OAAOjoB,CACR,IrD6wBAT,EAAAsb,GAAA,WAAAuN,IAUA7oB,EAAAsb,GAAA,csDpzBA,SAAqBK,EAAOhO,EAAMD,GACjC,IAAIjN,EACAid,EACAgL,EACAI,EACAlN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EASJ,IAPApN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GAGZlb,EAAM,GACAuoB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAE7B,IADAF,EAAK,GACCC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBD,EAAGvf,KAAMwP,EAAKzS,KAAMwS,EAAS,CAAEsb,EAAIJ,EAAIhL,EAAID,KAE5C+K,EAAGvqB,KAAMuf,EACT,CACDoL,EAAG3qB,KAAMuqB,EACT,CACDjoB,EAAItC,KAAM2qB,EACV,CACD,OAAOroB,CACR,ItDyxBAT,EAAAsb,GAAA,WAAA2N,IAUAjpB,EAAAsb,GAAA,cuDx0BA,SAAqBK,EAAOhO,EAAMD,GACjC,IAAIjN,EACAid,EACAgL,EACAI,EACAI,EACAtN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EAUJ,IARAxN,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,GAGZlb,EAAM,GACA2oB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACCF,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAE7B,IADAF,EAAK,GACC9K,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAE7B,IADAF,EAAK,GACCC,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBD,EAAGvf,KAAMwP,EAAKzS,KAAMwS,EAAS,CAAE0b,EAAIJ,EAAIJ,EAAIhL,EAAID,KAEhD+K,EAAGvqB,KAAMuf,EACT,CACDoL,EAAG3qB,KAAMuqB,EACT,CACDQ,EAAG/qB,KAAM2qB,EACT,CACDroB,EAAItC,KAAM+qB,EACV,CACD,OAAOzoB,CACR,IvDqyBAT,EAAAsb,GAAA,WAAA+N,IAUArpB,EAAAsb,GAAA,c7HpzBA,SAAqBK,EAAOhO,EAAMD,GACjC,OAAO8O,GAASb,EAAM/hB,OAAQ+hB,EAAO,EAAG,GAAI,GAAIhO,EAAMD,EACvD,I6H4zBA1N,EAAAsb,GAAA,UwD1vBA,SAAiBpT,EAAGtF,EAAW8K,GAC9B,IAAIpO,EACJ,OAvGD,SAAoBA,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CAqGMC,CAAW1mB,EAAG,UACXA,EAAEypB,OAAQ/uB,EAAW8K,IAE7BpO,EAAM2R,GAAkB/I,IACfwI,iBA/CV,SAAoBxI,EAAGtF,EAAW8K,GACjC,IAAIwD,EACArR,EACAxG,EACAkJ,EACAnJ,EAMJ,IAJA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEnBnX,EAAM,GACAD,EAAI,EAAGA,EAAI8X,EAAKtX,OAAQR,IAC7BmJ,EAAI1C,EAAKqR,EAAM9X,GACVwJ,EAAU1H,KAAMwS,EAASnL,EAAGnJ,EAAG8X,IACnC7X,EAAI8E,KAAMoE,GAGZ,OAAOlJ,CACR,CA8BSmX,CAAWlR,EAAKsD,EAAW8K,GArFpC,SAAmBxF,EAAGtF,EAAW8K,GAChC,IAAIrU,EACAkJ,EACAnJ,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1BmJ,EAAI2F,EAAG9O,GACFwJ,EAAU1H,KAAMwS,EAASnL,EAAGnJ,EAAG8O,IACnC7O,EAAI8E,KAAMoE,GAGZ,OAAOlJ,CACR,CA0EQ+X,CAAUlJ,EAAGtF,EAAW8K,EAChC,IxD0vBA1N,EAAAsb,GAAA,SyD/2BA,SAAgB7a,GAGf,GAAoB,IAAfA,EAAI7G,OAOT,OAHMyX,GAAe5Q,EAGdZ,CAAKY,EAAK,EAClB,IzD82BAT,EAAAsb,GAAA,UAAA8O,IAUApqB,EAAAsb,GAAA,YAAAkP,IAUAxqB,EAAAsb,GAAA,YAAAoP,IAUA1qB,EAAAsb,GAAA,cAAAqP,IAUA3qB,EAAAsb,GAAA,YAAAsP,IAUA5qB,EAAAsb,GAAA,cAAAuP,IAUA7qB,EAAAsb,GAAA,YAAAwP,IAUA9qB,EAAAsb,GAAA,cAAAyP,IAUA/qB,EAAAsb,GAAA,YAAA0P,IAUAhrB,EAAAsb,GAAA,cAAA2P,IAUAjrB,EAAAsb,GAAA,WAAA4P,IAUAlrB,EAAAsb,GAAA,WAAA+P,IAUArrB,EAAAsb,GAAA,WAAAgQ,IAUAtrB,EAAAsb,GAAA,Y0Dr/BA,SAAmBpT,GAClB,IAAI7O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1BC,EAAI8E,KAAMmtB,GAAUpjB,EAAG9O,KAExB,OAAOC,CACR,I1Ds/BA2G,EAAAsb,GAAA,WAAAiQ,IAUAvrB,EAAAsb,GAAA,WAAAkQ,IAUAxrB,EAAAsb,GAAA,WAAAmQ,IAUAzrB,EAAAsb,GAAA,Y2D7hCA,SAAmBpT,GAClB,IAAI7O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1BC,EAAI8E,KAAMstB,GAAUvjB,EAAG9O,KAExB,OAAOC,CACR,I3D8hCA2G,EAAAsb,GAAA,iB4DpiCA,SAAwBrM,EAAG/G,EAAGgL,EAAQjH,GACrC,IAAI5S,EACAwG,EACAunB,EACAhuB,EAQJ,IALAyG,EAAMwR,GAAenJ,GAGrBkf,EAAKnb,EACL5S,EAAM,GACAD,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBC,EAAI8E,KAAM0B,EAAKqI,EAAGkf,IAClBA,GAAMlU,EAEP,OAAO7Z,CACR,I5D6hCA2G,EAAAsb,GAAA,SAAAja,GAUArB,EAAAsb,GAAA,gB6D3jCA,SAAuBpT,EAAGwuB,GACzB,IAAIzhB,EACA2c,EACA/uB,EACAxJ,EACAs9B,EACA9lB,EACAtO,EACAnJ,EAIJ,GADAyJ,EAAMqF,EAAEtO,OACH88B,EAAO98B,SAAWiJ,EACtB,MAAM,IAAIuK,WAAY,+EAQvB,IALA6H,EAAO5D,GAAenJ,GACtB0pB,EAAOvgB,GAAeqlB,GAGtBr9B,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI0S,EAAM/M,EAAG9O,GAEbyX,EAAIxX,EADJs9B,EAAI/E,EAAM8E,EAAQt9B,GAAIyB,YAEjByB,GAASuU,GACbA,EAAE1S,KAAM,CAAE/E,EAAGmJ,IAEblJ,EAAKs9B,GAAM,CAAE,CAAEv9B,EAAGmJ,IAGpB,OAAOlJ,CACR,I7DqiCA2G,EAAAsb,GAAA,kB8DlkCA,SAAyBpT,EAAG0uB,EAAWlpB,GACtC,IAAI7N,EACAgD,EACAxJ,EACAs9B,EACA9lB,EACAtO,EACAnJ,EAUJ,IAPAyJ,EAAMqF,EAAEtO,OAGRiG,EAAMwR,GAAenJ,GAGrB7O,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI1C,EAAKqI,EAAG9O,GAEZyX,EAAIxX,EADJs9B,EAAIC,EAAU17B,KAAMwS,EAASnL,EAAGnJ,EAAG8O,IAE9B5L,GAASuU,GACbA,EAAE1S,KAAM,CAAE/E,EAAGmJ,IAEblJ,EAAKs9B,GAAM,CAAE,CAAEv9B,EAAGmJ,IAGpB,OAAOlJ,CACR,I9DgjCA2G,EAAAsb,GAAA,gB+D/kCA,SAAuBpT,EAAGwuB,GACzB,IAAI9E,EACA/uB,EACAxJ,EACAs9B,EACA9lB,EACAzX,EAIJ,GADAyJ,EAAMqF,EAAEtO,OACH88B,EAAO98B,SAAWiJ,EACtB,MAAM,IAAIuK,WAAY,+EAOvB,IAJAwkB,EAAOvgB,GAAeqlB,GAGtBr9B,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAErByX,EAAIxX,EADJs9B,EAAI/E,EAAM8E,EAAQt9B,GAAIyB,YAEjByB,GAASuU,GACbA,EAAE1S,KAAM/E,GAERC,EAAKs9B,GAAM,CAAEv9B,GAGf,OAAOC,CACR,I/D6jCA2G,EAAAsb,GAAA,kBgEtlCA,SAAyBpT,EAAG0uB,EAAWlpB,GACtC,IAAI7N,EACAgD,EACAxJ,EACAs9B,EACA9lB,EACAzX,EAUJ,IAPAyJ,EAAMqF,EAAEtO,OAGRiG,EAAMwR,GAAenJ,GAGrB7O,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IAErByX,EAAIxX,EADJs9B,EAAIC,EAAU17B,KAAMwS,EAAS7N,EAAKqI,EAAG9O,GAAKA,EAAG8O,IAExC5L,GAASuU,GACbA,EAAE1S,KAAM/E,GAERC,EAAKs9B,GAAM,CAAEv9B,GAGf,OAAOC,CACR,IhEskCA2G,EAAAsb,GAAA,eiEnmCA,SAAsBpT,EAAGwuB,GACxB,IAAIzhB,EACA2c,EACA/uB,EACAxJ,EACAs9B,EACA9lB,EACAtO,EACAnJ,EAIJ,GADAyJ,EAAMqF,EAAEtO,OACH88B,EAAO98B,SAAWiJ,EACtB,MAAM,IAAIuK,WAAY,+EAQvB,IALA6H,EAAO5D,GAAenJ,GACtB0pB,EAAOvgB,GAAeqlB,GAGtBr9B,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI0S,EAAM/M,EAAG9O,GAEbyX,EAAIxX,EADJs9B,EAAI/E,EAAM8E,EAAQt9B,GAAIyB,YAEjByB,GAASuU,GACbA,EAAE1S,KAAMoE,GAERlJ,EAAKs9B,GAAM,CAAEp0B,GAGf,OAAOlJ,CACR,IjE6kCA2G,EAAAsb,GAAA,iBkE1mCA,SAAwBpT,EAAG0uB,EAAWlpB,GACrC,IAAI7N,EACAgD,EACAxJ,EACAs9B,EACA9lB,EACAtO,EACAnJ,EAUJ,IAPAyJ,EAAMqF,EAAEtO,OAGRiG,EAAMwR,GAAenJ,GAGrB7O,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBmJ,EAAI1C,EAAKqI,EAAG9O,GAEZyX,EAAIxX,EADJs9B,EAAIC,EAAU17B,KAAMwS,EAASnL,EAAGnJ,EAAG8O,IAE9B5L,GAASuU,GACbA,EAAE1S,KAAMoE,GAERlJ,EAAKs9B,GAAM,CAAEp0B,GAGf,OAAOlJ,CACR,IlEwlCA2G,EAAAsb,GAAA,oBmEhnCA,SAA2BpT,EAAGyQ,GAC7B,IAAI9Y,EACAxG,EACAwX,EACAtO,EACAnJ,EACAge,EAOJ,IAJAvX,EAAMwR,GAAenJ,GAGrB7O,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAG1ByX,EAAIxX,EADJ+d,GADA7U,EAAI1C,EAAKqI,EAAG9O,IACLuf,IAEFrc,GAASuU,GACbA,EAAE1S,KAAMoE,GAERlJ,EAAK+d,GAAM,CAAE7U,GAGf,OAAOlJ,CACR,InEkmCA2G,EAAAsb,GAAA,YAAAoQ,IAUA1rB,EAAAsb,GAAA,WoEljCA,SAAkBpT,EAAGqG,EAAeC,GACnC,OAzFD,SAAoBlP,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CAuFMC,CAAW1mB,EAAG,WACXA,EAAE7K,QAASkR,EAAeC,IAE7BA,EAAY,IAChBA,GAAatG,EAAEtO,QACE,IAChB4U,EAAY,GAGTlO,GAAiB4H,GApDvB,SAAoBA,EAAGqG,EAAeC,GACrC,IAAI3O,EACAzG,EAGJ,IADAyG,EAAMwR,GAAenJ,GACf9O,EAAIoV,EAAWpV,EAAI8O,EAAEtO,OAAQR,IAClC,GAAKmV,IAAkB1O,EAAKqI,EAAG9O,GAC9B,OAAOA,EAGT,OAAQ,CACT,CA0CSoX,CAAWtI,EAAGqG,EAAeC,GAhFtC,SAAmBtG,EAAGqG,EAAeC,GACpC,IAAIpV,EACJ,IAAMA,EAAIoV,EAAWpV,EAAI8O,EAAEtO,OAAQR,IAClC,GAAKmV,IAAkBrG,EAAG9O,GACzB,OAAOA,EAGT,OAAQ,CACT,CA0EQgY,CAAUlJ,EAAGqG,EAAeC,GACpC,IpE8iCAxO,EAAAsb,GAAA,oBqE5/BA,SAA2BpT,EAAGqG,EAAeC,GAO5C,OANKA,EAAY,IAChBA,GAAatG,EAAEtO,QACE,IAChB4U,EAAY,GAGTlO,GAAiB4H,GAChBiO,GAAqBjO,GA9F5B,SAAkBA,EAAGqG,EAAeC,GACnC,IAAIoW,EACA9Z,EACAC,EACA3R,EACJ,IAAMkS,GAAeiD,GACpB,OAAQ,EAKT,IAHAqW,EAAO5Y,GAAa9D,EAAG,GACvB4C,EAAKH,GAAM4D,GACXxD,EAAKH,GAAM2D,GACLnV,EAAc,EAAVoV,EAAapV,EAAIwrB,EAAKhrB,OAAQR,GAAK,EAC5C,GAAK+b,GAAayP,EAAMxrB,GAAK0R,IAAQqK,GAAayP,EAAMxrB,EAAE,GAAK2R,GAC9D,OAAO3R,EAAI,EAGb,OAAQ,CACT,CA8EU0rB,CAAS5c,EAAGqG,EAAeC,GAE9BuB,GAAgB7H,GA7DvB,SAAkBA,EAAGqG,EAAeC,GACnC,IAAIoW,EACAriB,EACAnJ,EACJ,IAAM+P,GAAWoF,GAChB,OAAQ,EAIT,IAFAqW,EAAOzI,GAAoBjU,EAAG,GAC9B3F,EAAI,EAAoB,EAAI,EACtBnJ,EAAIoV,EAAWpV,EAAIwrB,EAAKhrB,OAAQR,IACrC,GAAKwrB,EAAMxrB,KAAQmJ,EAClB,OAAOnJ,EAGT,OAAQ,CACT,CA+CUgsB,CAASld,EAAGqG,EAAeC,GAjIrC,SAAoBtG,EAAGqG,EAAeC,GACrC,IAAI3O,EACAzG,EAGJ,IADAyG,EAAMwR,GAAenJ,GACf9O,EAAIoV,EAAWpV,EAAI8O,EAAEtO,OAAQR,IAClC,GAAK+b,GAAa5G,EAAe1O,EAAKqI,EAAG9O,IACxC,OAAOA,EAGT,OAAQ,CACT,CAwHSoX,CAAWtI,EAAGqG,EAAeC,GA9JtC,SAAkBtG,EAAGqG,EAAeC,GACnC,IAAIpV,EACJ,IAAMA,EAAIoV,EAAWpV,EAAI8O,EAAEtO,OAAQR,IAClC,GAAK+b,GAAa5G,EAAerG,EAAG9O,IACnC,OAAOA,EAGT,OAAQ,CACT,CAwJQsrB,CAASxc,EAAGqG,EAAeC,EACnC,IrEq/BAxO,EAAAsb,GAAA,qBsEzqCA,SAA4BrM,EAAG+D,GAC9B,IAAIuG,EACAlgB,EACAD,EAGJ,IADAmgB,EAAO,CAAA,EACDngB,EAAI,EAAGA,EAAI4Z,EAAQpZ,OAAQR,IAChCmgB,EAAMvG,EAAS5Z,KAAQ,EAGxB,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI6V,EAAG7V,SACA,IAAdmgB,EAAMngB,IACVC,EAAI8E,KAAM/E,GAGZ,OAAOC,CACR,ItEmqCA2G,EAAAsb,GAAA,QuElkCA,SAAepT,EAAGuG,GACjB,IAAInP,EACJ,OAxGD,SAAoBA,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CAsGMC,CAAW1mB,EAAG,QACXA,EAAEyG,KAAMF,IAEhBnP,EAAM2R,GAAkB/I,IACfwI,iBAvFV,SAAoBxI,EAAGuG,GACtB,IAAIyC,EACA7X,EACAwG,EACAoP,EACA1M,EACAnJ,EAOJ,IALA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEnBvB,EAAIiC,EAAKtX,OAAS,EAClBP,EAAM,GACAD,EAAI,EAAGA,GAAK6V,EAAG7V,IAEdwyB,GADNrpB,EAAI1C,EAAKqR,EAAM9X,MAEdC,GAAOW,OAAQuI,IAEXnJ,EAAI6V,IACR5V,GAAOoV,GAGT,OAAOpV,CACR,CAiESmX,CAAWlR,EAAKmP,GAjDzB,SAAkBvG,EAAGuG,GACpB,IAAIpV,EACA4V,EACA1M,EACAnJ,EAIJ,IAFA6V,EAAI/G,EAAEtO,OAAS,EACfP,EAAM,GACAD,EAAI,EAAGA,GAAK6V,EAAG7V,IAEdwyB,GADNrpB,EAAI2F,EAAG9O,MAENC,GAAOW,OAAQuI,IAEXnJ,EAAI6V,IACR5V,GAAOoV,GAGT,OAAOpV,CACR,CAiCQqrB,CAASxc,EAAGuG,EACpB,IvEkkCAzO,EAAAsb,GAAA,QwEzrCA,SAAe7a,GACd,IAAIZ,EACAa,EASJ,GANAb,EAAMwR,GAAe5Q,MAGrBC,EAAMD,EAAI7G,OAAS,GAGR,GAGX,OAAOiG,EAAKY,EAAKC,EAClB,IxEorCAV,EAAAsb,GAAA,eyEpmCA,SAAsBpT,EAAGqG,EAAeC,GACvC,GAzFD,SAAoBlP,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CAuFMC,CAAW1mB,EAAG,eAClB,OAAOA,EAAE2uB,YAAatoB,EAAeC,GAEtC,GAAKA,EAAY,GAEhB,IADAA,GAAatG,EAAEtO,QACE,EAChB,OAAQ,OAEE4U,EAAYtG,EAAEtO,SACzB4U,EAAYtG,EAAEtO,OAAS,GAExB,OAAK0G,GAAiB4H,GAtDvB,SAAoBA,EAAGqG,EAAeC,GACrC,IAAI3O,EACAzG,EAGJ,IADAyG,EAAMwR,GAAenJ,GACf9O,EAAIoV,EAAWpV,GAAK,EAAGA,IAC5B,GAAKmV,IAAkB1O,EAAKqI,EAAG9O,GAC9B,OAAOA,EAGT,OAAQ,CACT,CA4CSoX,CAAWtI,EAAGqG,EAAeC,GAlFtC,SAAmBtG,EAAGqG,EAAeC,GACpC,IAAIpV,EACJ,IAAMA,EAAIoV,EAAWpV,GAAK,EAAGA,IAC5B,GAAKmV,IAAkBrG,EAAG9O,GACzB,OAAOA,EAGT,OAAQ,CACT,CA4EQgY,CAAUlJ,EAAGqG,EAAeC,EACpC,IzE8lCAxO,EAAAsb,GAAA,wB0E9iCA,SAA+BpT,EAAGqG,EAAeC,GAChD,GAAKA,EAAY,GAEhB,IADAA,GAAatG,EAAEtO,QACE,EAChB,OAAQ,OAEE4U,EAAYtG,EAAEtO,SACzB4U,EAAYtG,EAAEtO,OAAS,GAExB,OAAK0G,GAAiB4H,GAChBiO,GAAqBjO,GAhG5B,SAAkBA,EAAGqG,EAAeC,GACnC,IAAIoW,EACA9Z,EACAC,EACA3R,EACJ,IAAMkS,GAAeiD,GACpB,OAAQ,EAKT,IAHAqW,EAAO5Y,GAAa9D,EAAG,GACvB4C,EAAKH,GAAM4D,GACXxD,EAAKH,GAAM2D,GACLnV,EAAc,EAAVoV,EAAapV,GAAK,EAAGA,GAAK,EACnC,GAAK+b,GAAayP,EAAMxrB,GAAK0R,IAAQqK,GAAayP,EAAMxrB,EAAE,GAAK2R,GAC9D,OAAO3R,EAAI,EAGb,OAAQ,CACT,CAgFU0rB,CAAS5c,EAAGqG,EAAeC,GAE9BuB,GAAgB7H,GA/DvB,SAAkBA,EAAGqG,EAAeC,GACnC,IAAIoW,EACAriB,EACAnJ,EACJ,IAAM+P,GAAWoF,GAChB,OAAQ,EAIT,IAFAqW,EAAOzI,GAAoBjU,EAAG,GAC9B3F,EAAI,EAAoB,EAAI,EACtBnJ,EAAIoV,EAAWpV,GAAK,EAAGA,IAC5B,GAAKwrB,EAAMxrB,KAAQmJ,EAClB,OAAOnJ,EAGT,OAAQ,CACT,CAiDUgsB,CAASld,EAAGqG,EAAeC,GAnIrC,SAAoBtG,EAAGqG,EAAeC,GACrC,IAAI3O,EACAzG,EAGJ,IADAyG,EAAMwR,GAAenJ,GACf9O,EAAIoV,EAAWpV,GAAK,EAAGA,IAC5B,GAAK+b,GAAa5G,EAAe1O,EAAKqI,EAAG9O,IACxC,OAAOA,EAGT,OAAQ,CACT,CA0HSoX,CAAWtI,EAAGqG,EAAeC,GAhKtC,SAAkBtG,EAAGqG,EAAeC,GACnC,IAAIpV,EACJ,IAAMA,EAAIoV,EAAWpV,GAAK,EAAGA,IAC5B,GAAK+b,GAAa5G,EAAerG,EAAG9O,IACnC,OAAOA,EAGT,OAAQ,CACT,CA0JQsrB,CAASxc,EAAGqG,EAAeC,EACnC,I1EqiCAxO,EAAAsb,GAAA,Y2E1tCA,SAAmB+I,EAAIC,EAAIzhB,GAC1B,IAAIpC,EACAwO,EACA2N,EACAxjB,EAEJ,GAAa,IAARyJ,EACJ,MAAO,GAQR,IAJA+Z,GAAM0H,EAAGD,IADTpV,EAAIpM,EAAM,GAIVpC,EAAM,CAAE4jB,GACFjrB,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBqH,EAAItC,KAAMkmB,EAAMzH,EAAExjB,GAGnB,OADAqH,EAAItC,KAAMmmB,GACH7jB,CACR,I3EgtCAT,EAAAsb,GAAA,c4EhuCA,SAAqBrN,EAAO6X,EAAMnK,EAAOkC,GACxC,IAAIiZ,EACAC,EACA19B,EACAuU,EACAlN,EACAs2B,EACArZ,EACAsZ,EACArZ,EACAhB,EACAzjB,EAMJ,GAAW,KADXA,GAHA69B,EAAKrb,EAAO,KACZsb,EAAKtb,EAAO,KAIX,MAAO,GAYR,IAVAiB,GAAMkJ,EAAO7X,IAAY9U,EAAI,GACxB0kB,EAEJkZ,EAAO,EAAMC,GADbF,EAAOG,IAGPH,EAAO,EACPC,EAAO,GAER19B,EAAM,GACNqH,EAAM,EACAkd,EAAK,EAAGA,EAAKqZ,EAAIrZ,IAAO,CAE7B,IADAhQ,EAAM,GACA+P,EAAK,EAAGA,EAAKqZ,EAAIrZ,IACtB/P,EAAIzP,KAAM8P,EAAUvN,EAAMkc,GAC1Blc,GAAOo2B,EAERz9B,EAAI8E,KAAMyP,GACVlN,GAAOq2B,CACP,CACD,OAAO19B,CACR,I5EksCA2G,EAAAsb,GAAA,WAAAuQ,IAUA7rB,EAAAsb,GAAA,QAAAwQ,IAUA9rB,EAAAsb,GAAA,QAAAyQ,IAUA/rB,EAAAsb,GAAA,QAAA0Q,IAUAhsB,EAAAsb,GAAA,QAAA4Q,IAUAlsB,EAAAsb,GAAA,2BAAA+Q,IAUArsB,EAAAsb,GAAA,8B6EjyCA,SAAqCriB,GACpC,OAAKA,GAAS2N,GACN,QAEH3N,GAAS+M,GACN,SAEH/M,GAASoM,GACN,SAED,SACR,I7EgyCArF,EAAAsb,GAAA,e8ElyCA,SAAsBuW,EAAQlW,EAAOrN,GACpC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACA0G,EACA2B,EACAvrB,EACAiK,EACApG,EACAkV,EAIJ,GAFArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAOtB,IAJA3T,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAKjjB,EAAG0V,GACRwN,EAAKjZ,EAAGyL,GACRkU,EAAK/lB,EAAG6R,GACR6V,EAAKxS,EAAGrD,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,IAIlC,I9E0wCA3d,EAAAsb,GAAA,e+EzyCA,SAAsBuW,EAAQlW,EAAOrN,GACpC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA0G,EACA2B,EACApP,EACA1B,EACApO,EACAmf,EACAxrB,EACAiK,EACApG,EACAkV,EAKJ,GAHArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAOjC,IAJAzgB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKnc,EAAG0gB,GACRjG,EAAKxQ,EAAGyW,GACRrU,EAAKxI,EAAG6c,GACR8K,EAAKzS,EAAG2H,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,IAKnC,I/EowCA3d,EAAAsb,GAAA,egFtzCA,SAAsBuW,EAAQlW,EAAOrN,GACpC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA6F,EACAvd,EACAC,EACAif,EACAC,EACAO,EACA/rB,EACAiK,EACApG,EACAkV,EAMJ,GAJArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAO5C,IAJA7gB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA1E,EAAKpc,EAAG8gB,GACRiD,EAAK9Z,EAAG6W,GACRxU,EAAKzI,EAAGid,GACRiL,EAAKhT,EAAG+H,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACT8K,EAAKO,EAAIrL,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,IAMpC,IhFowCA3d,EAAAsb,GAAA,eiF9zCA,SAAsBuW,EAAQlW,EAAOrN,GACpC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACA0F,EACAvd,EACAC,EACAud,EACA0B,EACAC,EACAO,EACAM,EACArsB,EACAiK,EACApG,EACAkV,EAOJ,GALArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAOvD,IAJAjhB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA+C,EAAKjkB,EAAGkhB,GACRgD,EAAKja,EAAGiX,GACR2I,EAAKhmB,EAAGqd,GACRmL,EAAKtT,EAAGmI,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTxU,EAAKud,EAAI/I,GACTiL,EAAKM,EAAIvL,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACT8K,EAAKO,EAAIrL,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRmU,EAAInU,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,IAOrC,IjF+vCA3d,EAAAsb,GAAA,YAAAgR,IAUAtsB,EAAAsb,GAAA,eAAAmR,IAUAzsB,EAAAsb,GAAA,ckFv2CA,SAAqBpT,EAAGiK,EAAGoa,GAC1B,IAAItX,EACAC,EACAsX,EACA0K,EACAC,EACA/9B,EAUJ,IAPA6b,EAAO5D,GAAenJ,GACtBgN,EAAO7D,GAAec,GACtBqa,EAAOnb,GAAekb,GAGtB2K,EAAK,GACLC,EAAK,GACC/9B,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IACrBozB,EAAMD,EAAMnzB,KAChB89B,EAAG/4B,KAAM8W,EAAM/M,EAAG9O,IAClB+9B,EAAGh5B,KAAM+W,EAAM/C,EAAG/Y,KAGpB,MAAO,CAAE89B,EAAIC,EACd,IlF01CAn3B,EAAAsb,GAAA,cmFj3CA,WACC,IAAI8b,EACAvF,EACA3kB,EACAsf,EACAD,EACAlzB,EACAD,EACA8D,EAaJ,IAXAgQ,EAAQ5P,UAAU1D,OAKlB4yB,EAAOnb,GADPkb,EAAOjvB,UAHP4P,GAAS,IAOTkqB,EAAU,GACVvF,EAAS,GACTx4B,EAAM,GACAD,EAAI,EAAGA,EAAI8T,EAAO9T,IACvBy4B,EAAO1zB,KAAMb,UAAWlE,IACxBg+B,EAAQj5B,KAAMkT,GAAewgB,EAAQz4B,KACrCC,EAAI8E,KAAM,IAGX,IAAM/E,EAAI,EAAGA,EAAImzB,EAAK3yB,OAAQR,IAC7B,GAAKozB,EAAMD,EAAMnzB,GAChB,IAAM8D,EAAI,EAAGA,EAAIgQ,EAAOhQ,IACvB7D,EAAK6D,GAAIiB,KAAMi5B,EAASl6B,GAAK20B,EAAQ30B,GAAK9D,IAI7C,OAAOC,CACR,InFw1CA2G,EAAAsb,GAAA,SAAAoR,IAUA1sB,EAAAsb,GAAA,YAAA4R,IAUAltB,EAAAsb,GAAA,coFp4CA,SAAqBuW,EAAQlW,EAAOrN,GACnC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACAqI,EACAvrB,EACAiK,EACA8O,EAIJ,GAFArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAMtB,IAHA3T,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAKjjB,EAAG0V,GACRwN,EAAKjZ,EAAGyL,GACR6V,EAAKxS,EAAGrD,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRyN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,IAIxB,IpFg3CA3d,EAAAsb,GAAA,cqF94CA,SAAqBuW,EAAQlW,EAAOrN,GACnC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACA9G,EACA+G,EACAzI,EACA8Q,EACAC,EACAxrB,EACAiK,EACA8O,EAKJ,GAHArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAMjC,IAHAzgB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKnc,EAAG0gB,GACRjG,EAAKxQ,EAAGyW,GACR8K,EAAKzS,EAAG2H,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRyN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,IAKzB,IrF+2CA3d,EAAAsb,GAAA,csFx5CA,SAAqBuW,EAAQlW,EAAOrN,GACnC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACAwH,EACAC,EACAO,EACA/rB,EACAiK,EACA8O,EAMJ,GAJArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAM5C,IAHA7gB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA1E,EAAKpc,EAAG8gB,GACRiD,EAAK9Z,EAAG6W,GACRiL,EAAKhT,EAAG+H,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACT8K,EAAKO,EAAIrL,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRyN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,IAM1B,ItF82CA3d,EAAAsb,GAAA,cuFh6CA,SAAqBuW,EAAQlW,EAAOrN,GACnC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACAqH,EACAC,EACAO,EACAM,EACArsB,EACAiK,EACA8O,EAOJ,GALArF,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAMvD,IAHAjhB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ5Q,EAAI4Q,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA+C,EAAKjkB,EAAGkhB,GACRgD,EAAKja,EAAGiX,GACRmL,EAAKtT,EAAGmI,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTiL,EAAKM,EAAIvL,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAItB,IAHAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACT8K,EAAKO,EAAIrL,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAItB,IAHAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACT6V,EAAKC,EAAI9V,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACJ,IAAb8V,EAAI9V,KACRyN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,IAO3B,IvF22CA3d,EAAAsb,GAAA,qBwFp7CA,SAA4B+I,EAAIC,GAC/B,IAAIpX,EACAmqB,EACA52B,EACApH,EACAuU,EACAnT,EACAiG,EACAuO,EACAkV,EACA/qB,EACA8D,EACAka,EAiBJ,IAfAlK,EAAQ5P,UAAU1D,OAGlB6G,EAAM,CAAE4jB,EAAIC,GAMZ5jB,EAAM,CAAE,EAAG,GAGXuO,GANAooB,EAAO,CAAEhT,EAAGzqB,OAAQ0qB,EAAG1qB,SAMb,GAAMy9B,EAAM,GAGhBj+B,EAAI,EAAGA,EAAI8T,EAAO9T,IACvBqB,EAAM6C,UAAWlE,GACjBqH,EAAItC,KAAM1D,GACV48B,EAAKl5B,KAAM1D,EAAIb,QACf8G,EAAIvC,KAAM,GACV8Q,GAAKooB,EAAMj+B,GAIZ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI6V,EAAG7V,IAAM,CAGzB,IADAge,EAAIhe,EACE8D,EAAIgQ,EAAM,EAAGhQ,GAAK,EAAGA,IAE1Bka,GADA+M,EAAI/M,EAAIigB,EAAMn6B,GAEdka,GAAKigB,EAAMn6B,GACXwD,EAAKxD,GAAMinB,EAIZ,IADAvW,EAAM,GACA1Q,EAAI,EAAGA,EAAIgQ,EAAOhQ,IACvB0Q,EAAIzP,KAAMsC,EAAKvD,GAAKwD,EAAKxD,KAE1B7D,EAAI8E,KAAMyP,EACV,CACD,OAAOvU,CACR,IxFu4CA2G,EAAAsb,GAAA,kByF77CA,SAAyB7a,EAAKy1B,GAC7B,IAAIoB,EACAC,EACA13B,EACAxG,EACAiG,EACAsO,EACAsP,EACAjO,EACA7V,EACA8D,EAGJ,IADAggB,EAAIzc,EAAI7G,QACC,EACR,MAAO,GAMR,IADAqV,GAFAsoB,EAAOlmB,GAAe5Q,IAEZA,EAAK,GAAI7G,QACV,EACR,MAAO,GAMR,IAHA09B,EAAQza,GAAMqZ,GAEd78B,EAAM,GACAD,EAAI,EAAGA,EAAI8jB,EAAG9jB,IAAM,CAIzB,IAFAyG,EAAMwR,GADNzD,EAAM2pB,EAAM92B,EAAKrH,IAEjBkG,EAAM,CAAA,EACApC,EAAI,EAAGA,EAAI+R,EAAG/R,IACnBoC,EAAKg4B,EAAOp6B,IAAQ2C,EAAK+N,EAAK1Q,GAE/B7D,EAAI8E,KAAMmB,EACV,CACD,OAAOjG,CACR,IzFk6CA2G,EAAAsb,GAAA,gB0F36CA,SAAuB7a,EAAKy1B,GAC3B,IAAIqB,EACA3oB,EACAvV,EACA6jB,EACAjO,EACA7V,EAGJ,IADA8jB,EAAIzc,EAAI7G,QACC,EACR,MAAO,GAIR,GAFA29B,EAAOlmB,GAAe5Q,IACtBwO,EAAIsoB,EAAM92B,EAAK,GAAI7G,QACV,EACR,MAAO,GAeR,SAASw8B,EAAO31B,EAAKrH,GACpB,IAAI4V,EAAMwB,GAAW/P,GAAM+P,UAK3B,OAJAgnB,GAAkB3sB,KAAM,OAAQpK,GAChC+2B,GAAkB3sB,KAAM,OAAQmE,EAAK,IACrCwoB,GAAkB3sB,KAAM,OAAQmE,EAAK,IACrC5O,EAA0ByK,KAAM,KAAMzR,GAC/ByR,IACP,CAGD,IAtBA+D,EAAOiO,GAAMqZ,GAsBP98B,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBosB,GAAsB4Q,EAAMn8B,UAAW2U,EAAMxV,GAAKq+B,EAAUr+B,GAAKs+B,EAAUt+B,IAW5E,IAPAgH,EAA0Bg2B,EAAMn8B,UAAW,gBAiB3C,WACC,IAAI+U,EACAmO,GAEJA,EAAMoa,EAAM92B,EAAKoK,KAAKyrB,OACTzrB,KAAK8sB,OACjB3oB,EAAMwB,GAAW2M,GAAM3M,UACvB3F,KAAK8sB,KAAOxa,EACZtS,KAAK+sB,KAAO5oB,EAAK,GACjBnE,KAAKgtB,KAAO7oB,EAAK,GAElB,IAzBD5O,EAA0Bg2B,EAAMn8B,UAAW,UA6E3C,WACC,IAAIZ,EACA+d,EACAhe,EAGJ,IADAC,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAI6V,EAAG7V,IAEnBC,EADA+d,EAAIxI,EAAMxV,IACCyR,KAAMuM,GAElB,OAAO/d,CACP,IArFDA,EAAM,GACAD,EAAI,EAAGA,EAAI8jB,EAAG9jB,IACnBC,EAAI8E,KAAM,IAAIi4B,EAAOmB,EAAM92B,EAAKrH,GAAKA,IAEtC,OAAOC,EA2BP,SAASo+B,EAAU/2B,GAClB,OAQA,WAEC,OADAmK,KAAKitB,eACEjtB,KAAK+sB,KAAM/sB,KAAK8sB,KAAMj3B,EAC7B,CACD,CASD,SAASg3B,EAAUh3B,GAClB,OAQA,SAAczH,GACb4R,KAAKitB,eACLjtB,KAAKgtB,KAAMhtB,KAAK8sB,KAAMj3B,EAAKzH,EAC3B,CACD,CAoBF,I1F4yCA+G,EAAAsb,GAAA,QhFp4CA,SAAepT,GACd,IAAI5I,EAAM2R,GAAkB/I,GAC5B,OAAK5I,EAAIoR,iBAEHhF,GAAmBxD,GAChBkJ,GAAU9D,GAAgBpF,EAAG,IAEhCuD,GAAkBvD,GACfkJ,GAAU/D,GAAenF,EAAG,IAG/B6H,GAAgB7H,GACbkJ,GAAU+K,GAAoBjU,EAAG,IAjD3C,SAAoBA,GACnB,IAAIgJ,EACArR,EACAzG,EAKJ,IAHA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEbpX,EAAI,EAAGA,EAAI8X,EAAKtX,OAAQR,IAC7B,GAAKyG,EAAKqR,EAAM9X,GACf,OAAO,EAGT,OAAO,CACR,CAqCSoX,CAAWlR,GAEZ8R,GAAUlJ,EAClB,IgF63CAlI,EAAAsb,GAAA,U2Fv5CA,SAAiBpT,EAAGtF,EAAW8K,GAC9B,IAAIpO,EAAM2R,GAAkB/I,GAC5B,OAAK5I,EAAIoR,iBAvCV,SAAoBxI,EAAGtF,EAAW8K,GACjC,IAAIwD,EACArR,EACAzG,EAKJ,IAHA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEbpX,EAAI,EAAGA,EAAI8X,EAAKtX,OAAQR,IAC7B,GAAKwJ,EAAU1H,KAAMwS,EAAS7N,EAAKqR,EAAM9X,GAAKA,EAAG8X,GAChD,OAAO,EAGT,OAAO,CACR,CA0BSV,CAAWlR,EAAKsD,EAAW8K,GAxEpC,SAAmBxF,EAAGtF,EAAW8K,GAChC,IAAItU,EACJ,IAAMA,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1B,GAAKwJ,EAAU1H,KAAMwS,EAASxF,EAAG9O,GAAKA,EAAG8O,GACxC,OAAO,EAGT,OAAO,CACR,CAkEQkJ,CAAUlJ,EAAGtF,EAAW8K,EAChC,I3F25CA1N,EAAAsb,GAAA,e4Fj6CA,SAAsBpT,EAAGtF,EAAW8K,GACnC,IAAIpO,EAAM2R,GAAkB/I,GAC5B,OAAK5I,EAAIoR,iBAvCV,SAAoBxI,EAAGtF,EAAW8K,GACjC,IAAIwD,EACArR,EACAzG,EAKJ,IAHA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEbpX,EAAI8X,EAAKtX,OAAO,EAAGR,GAAK,EAAGA,IAChC,GAAKwJ,EAAU1H,KAAMwS,EAAS7N,EAAKqR,EAAM9X,GAAKA,EAAG8X,GAChD,OAAO,EAGT,OAAO,CACR,CA0BSV,CAAWlR,EAAKsD,EAAW8K,GAxEpC,SAAmBxF,EAAGtF,EAAW8K,GAChC,IAAItU,EACJ,IAAMA,EAAI8O,EAAEtO,OAAO,EAAGR,GAAK,EAAGA,IAC7B,GAAKwJ,EAAU1H,KAAMwS,EAASxF,EAAG9O,GAAKA,EAAG8O,GACxC,OAAO,EAGT,OAAO,CACR,CAkEQkJ,CAAUlJ,EAAGtF,EAAW8K,EAChC,I5Fq6CA1N,EAAAsb,GAAA,S6Fz/CA,SAAgBzY,GACf,OAAO4Y,GAAQ,KAAM5Y,EACtB,I7FigDA7C,EAAAsb,GAAA,QAAA8R,IAUAptB,EAAAsb,GAAA,Q8F7gDA,SAAezY,GACd,OAAO4Y,GAAQ,EAAK5Y,EACrB,I9FqhDA7C,EAAAsb,GAAA,U+FvhDA,SAAiBK,GAChB,OAAOD,GAAU,EAAKC,EACvB,I/F+hDA3b,EAAAsb,GAAA,UgGjiDA,SAAiBK,GAChB,OAAO8M,GAAU,EAAK9M,EACvB,IhGyiDA3b,EAAAsb,GAAA,UiG3iDA,SAAiBK,GAChB,OAAOkN,GAAU,EAAKlN,EACvB,IjGmjDA3b,EAAAsb,GAAA,UkGrjDA,SAAiBK,GAChB,OAAOsN,GAAU,EAAKtN,EACvB,IlG6jDA3b,EAAAsb,GAAA,UmG3jDA,SAAiBK,GAChB,OAAO0N,GAAU,EAAK1N,EACvB,InGmkDA3b,EAAAsb,GAAA,QAAA+R,IAUArtB,EAAAsb,GAAA,MAAA8S,IAUApuB,EAAAsb,GAAA,gBoG9kDA,SAAuBuW,EAAQlW,EAAOrN,GACrC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACA0G,EACA+B,EACAwB,EACAntB,EACAiK,EACApG,EACAmL,EACA3U,EAIJ,GAFAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAQtB,IALA3T,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZtvB,EAAIsvB,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAMtB,IALAuN,EAAKjjB,EAAG0V,GACRwN,EAAKjZ,EAAGyL,GACRkU,EAAK/lB,EAAG6R,GACRiW,EAAK3c,EAAG0G,GACRyX,EAAK9yB,EAAGqb,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAGrD,IpGojDA3d,EAAAsb,GAAA,gBqGxlDA,SAAuBuW,EAAQlW,EAAOrN,GACrC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA0G,EACA+B,EACAwB,EACAhR,EACA1B,EACApO,EACA4f,EACA7X,EACApU,EACAiK,EACApG,EACAmL,EACA3U,EAKJ,GAHAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAQjC,IALAzgB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZtvB,EAAIsvB,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALAvE,EAAKnc,EAAG0gB,GACRjG,EAAKxQ,EAAGyW,GACRrU,EAAKxI,EAAG6c,GACRuL,EAAKjd,EAAG0R,GACRtM,EAAK/Z,EAAGqmB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAMtB,IALAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAItD,IrG+iDA3d,EAAAsb,GAAA,gBsGlmDA,SAAuBuW,EAAQlW,EAAOrN,GACrC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACAC,EACA0G,EACA+B,EACAwB,EACAhR,EACA1B,EACApO,EACA4f,EACA7X,EACAgI,EACA2H,EACAzX,EACAigB,EACAlY,EACArU,EACAiK,EACApG,EACAmL,EACA3U,EAMJ,GAJAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAQ5C,IALA7gB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZtvB,EAAIsvB,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALA1E,EAAKpc,EAAG8gB,GACRiD,EAAK9Z,EAAG6W,GACRxU,EAAKzI,EAAGid,GACRyL,EAAKvd,EAAG8R,GACRzM,EAAKha,EAAGymB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACTtM,EAAKC,EAAIqM,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAMtB,IALAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAKvD,ItG0iDA3d,EAAAsb,GAAA,gBuG5mDA,SAAuBuW,EAAQlW,EAAOrN,GACrC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACAC,EACA0G,EACA+B,EACAwB,EACAhR,EACA1B,EACApO,EACA4f,EACA7X,EACAgI,EACA2H,EACAzX,EACAigB,EACAlY,EACA4P,EACAC,EACA2F,EACAgD,EACAgD,EACA7vB,EACAiK,EACApG,EACAmL,EACA3U,EAOJ,GALAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAQvD,IALAjhB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZtvB,EAAIsvB,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALA+C,EAAKjkB,EAAGkhB,GACRgD,EAAKja,EAAGiX,GACR2I,EAAKhmB,EAAGqd,GACR2L,EAAK7d,EAAGkS,GACR2O,EAAKx1B,EAAG6mB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTxU,EAAKud,EAAI/I,GACTyL,EAAKM,EAAI/L,GACTzM,EAAKwb,EAAI/O,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAMtB,IALAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACTtM,EAAKC,EAAIqM,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAMtB,IALAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAMxD,IvGqiDA3d,EAAAsb,GAAA,awGrnDA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACA0G,EACA+B,EACAC,EACAuB,EACAntB,EACAiK,EACApG,EACAmL,EACAiM,EACA5gB,EAIJ,GAFAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAStB,IANA3T,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZ1O,EAAI0O,EAAQ,GACZtvB,EAAIsvB,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAOtB,IANAuN,EAAKjjB,EAAG0V,GACRwN,EAAKjZ,EAAGyL,GACRkU,EAAK/lB,EAAG6R,GACRiW,EAAK3c,EAAG0G,GACRkW,EAAK3Q,EAAGvF,GACRyX,EAAK9yB,EAAGqb,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAAMmW,EAAInW,GAG/D,IxGulDA3d,EAAAsb,GAAA,ayG/nDA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA0G,EACA+B,EACAC,EACAuB,EACAhR,EACA1B,EACApO,EACA4f,EACAC,EACA9X,EACApU,EACAiK,EACApG,EACAmL,EACAiM,EACA5gB,EAKJ,GAHAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GASjC,IANAzgB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZ1O,EAAI0O,EAAQ,GACZtvB,EAAIsvB,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANAvE,EAAKnc,EAAG0gB,GACRjG,EAAKxQ,EAAGyW,GACRrU,EAAKxI,EAAG6c,GACRuL,EAAKjd,EAAG0R,GACRwL,EAAKjR,EAAGyF,GACRtM,EAAK/Z,EAAGqmB,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAOtB,IANAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTkW,EAAKM,EAAIxW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAAMmW,EAAInW,GAIhE,IzGglDA3d,EAAAsb,GAAA,a0GzoDA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACAC,EACA0G,EACA+B,EACAC,EACAuB,EACAhR,EACA1B,EACApO,EACA4f,EACAC,EACA9X,EACAgI,EACA2H,EACAzX,EACAigB,EACAC,EACAnY,EACArU,EACAiK,EACApG,EACAmL,EACAiM,EACA5gB,EAMJ,GAJAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAS5C,IANA7gB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZ1O,EAAI0O,EAAQ,GACZtvB,EAAIsvB,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANA1E,EAAKpc,EAAG8gB,GACRiD,EAAK9Z,EAAG6W,GACRxU,EAAKzI,EAAGid,GACRyL,EAAKvd,EAAG8R,GACR0L,EAAKvR,EAAG6F,GACRzM,EAAKha,EAAGymB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACTwL,EAAKM,EAAI9L,GACTtM,EAAKC,EAAIqM,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAOtB,IANAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTkW,EAAKM,EAAIxW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAAMmW,EAAInW,GAKjE,I1GykDA3d,EAAAsb,GAAA,a2GnpDA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACAC,EACA0G,EACA+B,EACAC,EACAuB,EACAhR,EACA1B,EACApO,EACA4f,EACAC,EACA9X,EACAgI,EACA2H,EACAzX,EACAigB,EACAC,EACAnY,EACA4P,EACAC,EACA2F,EACAgD,EACAC,EACA+C,EACA7vB,EACAiK,EACApG,EACAmL,EACAiM,EACA5gB,EAOJ,GALAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GASvD,IANAjhB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACZ1O,EAAI0O,EAAQ,GACZtvB,EAAIsvB,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANA+C,EAAKjkB,EAAGkhB,GACRgD,EAAKja,EAAGiX,GACR2I,EAAKhmB,EAAGqd,GACR2L,EAAK7d,EAAGkS,GACR4L,EAAK7R,EAAGiG,GACR2O,EAAKx1B,EAAG6mB,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTxU,EAAKud,EAAI/I,GACTyL,EAAKM,EAAI/L,GACT0L,EAAKM,EAAIhM,GACTzM,EAAKwb,EAAI/O,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAOtB,IANAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACTwL,EAAKM,EAAI9L,GACTtM,EAAKC,EAAIqM,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAOtB,IANAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACTkW,EAAKM,EAAIxW,GACTyX,EAAK/Y,EAAIsB,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB0X,EAAI1X,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAAMkW,EAAIlW,GAAMmW,EAAInW,GAMlE,I3GkkDA3d,EAAAsb,GAAA,U4GtlDA,SAAiBpT,EAAGtF,EAAW8K,GAC9B,IAAIpO,EAAM2R,GAAkB/I,GAC5B,OAAK5I,EAAIoR,iBA3CV,SAAoBxI,EAAGtF,EAAW8K,GACjC,IAAIwD,EACArR,EACAxG,EACAkJ,EACAnJ,EAMJ,IAJA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEnBnX,EAAM,GACAD,EAAI,EAAGA,EAAI8X,EAAKtX,OAAQR,IAC7BmJ,EAAI1C,EAAKqR,EAAM9X,GACTwJ,EAAU1H,KAAMwS,EAASnL,EAAGnJ,EAAG8X,IACpC7X,EAAI8E,KAAMoE,GAGZ,OAAOlJ,CACR,CA0BSmX,CAAWlR,EAAKsD,EAAW8K,GAjFpC,SAAmBxF,EAAGtF,EAAW8K,GAChC,IAAIrU,EACAkJ,EACAnJ,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1BmJ,EAAI2F,EAAG9O,GACDwJ,EAAU1H,KAAMwS,EAASnL,EAAGnJ,EAAG8O,IACpC7O,EAAI8E,KAAMoE,GAGZ,OAAOlJ,CACR,CAsEQ+X,CAAUlJ,EAAGtF,EAAW8K,EAChC,I5G0lDA1N,EAAAsb,GAAA,S6GhqDA,SAAgB7a,EAAK9D,GACpB,IAAIq7B,EACAC,EACAp4B,EACAxG,EACAiG,EACAsO,EACAsP,EACAjO,EACA7V,EACA8D,EAGJ,IADAggB,EAAIzc,EAAI7G,QACC,EACR,MAAO,GAQR,IAJAqV,GADA+oB,EAAQ1e,GAAY3c,IACV/C,OAGVq+B,EAAQ,GACF7+B,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB6+B,EAAM95B,KAAMxB,EAASq7B,EAAO5+B,KAK7B,IAFAyG,EAAMwR,GAAe5Q,GACrBpH,EAAM,GACAD,EAAI,EAAGA,EAAI8jB,EAAG9jB,IAAM,CAGzB,IAFAwU,EAAM/N,EAAKY,EAAKrH,GAChBkG,EAAM,CAAA,EACApC,EAAI,EAAGA,EAAI+R,EAAG/R,IACnBoC,EAAK24B,EAAO/6B,IAAQ0Q,EAAKoqB,EAAO96B,IAEjC7D,EAAI8E,KAAMmB,EACV,CACD,OAAOjG,CACR,I7GqoDA2G,EAAAsb,GAAA,c8GjpDA,SAAqB7a,EAAK9D,GACzB,IAAI0E,EACA22B,EACAC,EACA5+B,EACA6jB,EACAjO,EACA7V,EAGJ,IADA8jB,EAAIzc,EAAI7G,QACC,EACR,MAAO,GAQR,IALAo+B,EAAQ1e,GAAY3c,GACpBsS,EAAI+oB,EAAMp+B,OAGVq+B,EAAQ,GACF7+B,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB6+B,EAAM95B,KAAMxB,EAASq7B,EAAO5+B,KAc7B,SAASg9B,EAAOh9B,GAEf,OADAgH,EAA0ByK,KAAM,KAAMzR,GAC/ByR,IACP,CAGD,IAjBAxJ,EAASgQ,GAAe5Q,GAiBlBrH,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBosB,GAAsB4Q,EAAMn8B,UAAWg+B,EAAO7+B,GAAKq+B,EAAUO,EAAO5+B,IAAOs+B,EAAUM,EAAO5+B,KAQ7F,IAJAgH,EAA0Bg2B,EAAMn8B,UAAW,UAyD3C,WACC,IAAIZ,EACA+d,EACAhe,EAGJ,IADAC,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAI6V,EAAG7V,IAEnBC,EADA+d,EAAI6gB,EAAO7+B,IACAyR,KAAMuM,GAElB,OAAO/d,CACP,IAjEDA,EAAM,GACAD,EAAI,EAAGA,EAAI8jB,EAAG9jB,IACnBC,EAAI8E,KAAM,IAAIi4B,EAAOh9B,IAEtB,OAAOC,EASP,SAASo+B,EAAU9e,GAClB,OAQA,WACC,OAAOtX,EAAQZ,EAAKoK,KAAKyrB,IAAM3d,EAC/B,CACD,CASD,SAAS+e,EAAU/e,GAClB,OAQA,SAAc1f,GACboI,EAAQZ,EAAKoK,KAAKyrB,IAAM3d,GAAQ1f,CAChC,CACD,CAoBF,I9GyiDA+G,EAAAsb,GAAA,Y+G1sDA,SAAmBpT,EAAG2H,GACrB,IAAIhN,EACAzJ,EACA8D,EAGJ,GADA2F,EAAMqF,EAAEtO,OACHiW,EAAQ,GAEZ,IADAA,GAAShN,GACI,EACZ,OAAOqF,OAEF,GAAK2H,GAAShN,EACpB,OAAOqF,EAGR,IADAhL,EAAI2S,EACEzW,EAAIyW,EAAM,EAAGzW,EAAIyJ,EAAKzJ,IAC3B8O,EAAGhL,GAAMgL,EAAG9O,GACZ8D,GAAK,EAGN,OADAgL,EAAEtO,OAASsD,EACJgL,CACR,I/G+rDAlI,EAAAsb,GAAA,W7BrqDA,SAAkBpT,EAAGgwB,EAAWC,EAASta,GAExC,OAAOrB,GADC4N,GAASliB,EAAGgwB,EAAWra,GACZsa,EAAQv+B,OAAQu+B,EAAS,EAAG,EAChD,I6B4qDAn4B,EAAAsb,GAAA,gBAAAjK,IAUArR,EAAAsb,GAAA,gBAAA0T,IAUAhvB,EAAAsb,GAAA,WgH9nDA,SAAkBpT,GACjB,IAAI5I,EACJ,OAhHD,SAAoBA,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CA8GMC,CAAW1mB,EAAG,WACXA,EAAEkwB,WAEV94B,EAAM2R,GAAkB/I,IACfwI,iBA5DV,SAAoBxI,GACnB,IAAIgJ,EACArR,EACAC,EACA8N,EACAqB,EACAiO,EACA9jB,EACA8D,EAQJ,IANAgU,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GACnB1Q,EAAMoI,EAAEsI,UAAW,GAEnBvB,EAAIjH,GAAOkJ,EAAKtX,OAAO,GACvBsjB,EAAIhM,EAAKtX,OAAS,EACZR,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB8D,EAAIggB,EAAI9jB,EACRwU,EAAM/N,EAAKqR,EAAM9X,GACjB0G,EAAKoR,EAAM9X,EAAGyG,EAAKqR,EAAMhU,IACzB4C,EAAKoR,EAAMhU,EAAG0Q,GAEf,OAAOsD,CACR,CAsCSV,CAAWlR,GApGpB,SAAmB4I,GAClB,IAAI0F,EACAqB,EACAiO,EACA9jB,EACA8D,EAIJ,IAFA+R,EAAIjH,GAAOE,EAAEtO,OAAO,GACpBsjB,EAAIhV,EAAEtO,OAAS,EACTR,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB8D,EAAIggB,EAAI9jB,EACRwU,EAAM1F,EAAG9O,GACT8O,EAAG9O,GAAM8O,EAAGhL,GACZgL,EAAGhL,GAAM0Q,EAEV,OAAO1F,CACR,CAsFQkJ,CAAUlJ,EAClB,IhH8nDAlI,EAAAsb,GAAA,iBiH7uDA,SAAwBmC,EAAM5a,EAAKmQ,EAASpD,EAAQka,GACnD,OAAOsE,GAAK3S,GAAQgC,EAAM5a,GAAOmQ,EAASpD,EAAQka,EACnD,IjHqvDA9pB,EAAAsb,GAAA,akHxvDA,SAAoBzY,EAAKmQ,EAASpD,EAAQka,GACzC,OAAOsE,GAAKl1B,GAAO2J,GAAOmQ,EAASpD,EAAQka,EAC5C,IlHgwDA9pB,EAAAsb,GAAA,SAAA9Z,GAUAxB,EAAAsb,GAAA,QAAArd,IAUA+B,EAAAsb,GAAA,mBmHtxDA,SAA0BpT,EAAGyT,EAAOyB,EAASnR,GAC5C,IAAIpM,EACAxG,EACAuU,EACAqkB,EACAC,EACAtW,EACAC,EACA8B,EACAC,EACAwJ,EAWJ,IATAvnB,EAAMwR,GAAenJ,GAErB2T,EAAKF,EAAO,GACZC,EAAKD,EAAO,GAEZuW,EAAM9U,EAAS,GACf6U,EAAM7U,EAAS,GAEf/jB,EAAM,GACAukB,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAhQ,EAAM,GACNwZ,EAAKnb,EAAWimB,EAAItU,EACdD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtB/P,EAAIzP,KAAM0B,EAAKqI,EAAGkf,IAClBA,GAAM6K,EAEP54B,EAAI8E,KAAMyP,EACV,CACD,OAAOvU,CACR,InHiwDA2G,EAAAsb,GAAA,mBoHhyDA,SAA0BpT,EAAGyT,EAAOyB,EAASnR,GAC5C,IAAIpM,EACAxG,EACA44B,EACAC,EACAO,EACA4F,EACAC,EACA1c,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACA3F,EACAC,EAaJ,IAXArjB,EAAMwR,GAAenJ,GAErBygB,EAAKhN,EAAO,GACZE,EAAKF,EAAO,GACZC,EAAKD,EAAO,GAEZ8W,EAAMrV,EAAS,GACf8U,EAAM9U,EAAS,GACf6U,EAAM7U,EAAS,GAEf/jB,EAAM,GACAuvB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA3F,EAAK,GACLoV,EAAMpsB,EAAWwmB,EAAI7J,EACfhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAsF,EAAK,GACLoV,EAAMD,EAAQnG,EAAItU,EACZD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBuF,EAAG/kB,KAAM0B,EAAKqI,EAAGowB,IACjBA,GAAOrG,EAERhP,EAAG9kB,KAAM+kB,EACT,CACD7pB,EAAI8E,KAAM8kB,EACV,CACD,OAAO5pB,CACR,IpH+vDA2G,EAAAsb,GAAA,mBqH1yDA,SAA0BpT,EAAGyT,EAAOyB,EAASnR,GAC5C,IAAIpM,EACAxG,EACA44B,EACAC,EACAO,EACAI,EACA0F,EACAF,EACAC,EACA1c,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAwP,EACAvV,EACAC,EAeJ,IAbArjB,EAAMwR,GAAenJ,GAErB6gB,EAAKpN,EAAO,GACZgN,EAAKhN,EAAO,GACZE,EAAKF,EAAO,GACZC,EAAKD,EAAO,GAEZkX,EAAMzV,EAAS,GACfqV,EAAMrV,EAAS,GACf8U,EAAM9U,EAAS,GACf6U,EAAM7U,EAAS,GAEf/jB,EAAM,GACA2vB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAwP,EAAK,GACLD,EAAMtsB,EAAW4mB,EAAI7J,EACfJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA3F,EAAK,GACLoV,EAAME,EAAQ9F,EAAI7J,EACZhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAsF,EAAK,GACLoV,EAAMD,EAAQnG,EAAItU,EACZD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBuF,EAAG/kB,KAAM0B,EAAKqI,EAAGowB,IACjBA,GAAOrG,EAERhP,EAAG9kB,KAAM+kB,EACT,CACDsV,EAAGr6B,KAAM8kB,EACT,CACD5pB,EAAI8E,KAAMq6B,EACV,CACD,OAAOn/B,CACR,IrH6vDA2G,EAAAsb,GAAA,mBsHpzDA,SAA0BpT,EAAGyT,EAAOyB,EAASnR,GAC5C,IAAIpM,EACAxG,EACA44B,EACAC,EACAO,EACAI,EACAI,EACAwF,EACAF,EACAF,EACAC,EACA1c,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACAsP,EACAF,EACAvV,EACAC,EAiBJ,IAfArjB,EAAMwR,GAAenJ,GAErBihB,EAAKxN,EAAO,GACZoN,EAAKpN,EAAO,GACZgN,EAAKhN,EAAO,GACZE,EAAKF,EAAO,GACZC,EAAKD,EAAO,GAEZsX,EAAM7V,EAAS,GACfyV,EAAMzV,EAAS,GACfqV,EAAMrV,EAAS,GACf8U,EAAM9U,EAAS,GACf6U,EAAM7U,EAAS,GAEf/jB,EAAM,GACA+vB,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAsP,EAAK,GACLD,EAAMxsB,EAAWgnB,EAAI7J,EACfJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFAwP,EAAK,GACLD,EAAME,EAAQ5F,EAAI7J,EACZJ,EAAK,EAAGA,EAAKD,EAAIC,IAAO,CAG7B,IAFA3F,EAAK,GACLoV,EAAME,EAAQ9F,EAAI7J,EACZhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAAO,CAG7B,IAFAsF,EAAK,GACLoV,EAAMD,EAAQnG,EAAItU,EACZD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBuF,EAAG/kB,KAAM0B,EAAKqI,EAAGowB,IACjBA,GAAOrG,EAERhP,EAAG9kB,KAAM+kB,EACT,CACDsV,EAAGr6B,KAAM8kB,EACT,CACDyV,EAAGv6B,KAAMq6B,EACT,CACDn/B,EAAI8E,KAAMu6B,EACV,CACD,OAAOr/B,CACR,ItH2vDA2G,EAAAsb,GAAA,YAAAqd,IAUA34B,EAAAsb,GAAA,kBAAAsd,IAUA54B,EAAAsb,GAAA,OAAA2T,IAUAjvB,EAAAsb,GAAA,euH52DA,SAAepT,EAAG8K,GACjB,IAAI3Z,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAI4Z,EAAQpZ,OAAQR,IAChCC,EAAI8E,KAAM+J,EAAG8K,EAAS5Z,KAEvB,OAAOC,CACR,IvH62DA2G,EAAAsb,GAAA,gBwHp3DA,SAAgBpT,EAAGiK,EAAGa,GACrB,IAAIkkB,EACAC,EACA/9B,EAIJ,IAFA89B,EAAK,GACLC,EAAK,GACC/9B,EAAI,EAAGA,EAAI4Z,EAAQpZ,OAAQR,IAChC89B,EAAG/4B,KAAM+J,EAAG8K,EAAS5Z,KACrB+9B,EAAGh5B,KAAMgU,EAAGa,EAAS5Z,KAEtB,MAAO,CAAE89B,EAAIC,EACd,IxHk3DAn3B,EAAAsb,GAAA,SAAA+T,IAUArvB,EAAAsb,GAAA,UyHr3DA,SAAiBpT,EAAG8K,EAASsc,EAAWxF,GACvC,IAAI5rB,EACA7E,EACAqjB,EACAqN,EACArpB,EACAtH,EAGJ,IAAc,KADdsjB,EAAM+Q,GAAgB6B,EAAWF,IAEhC,MAAM,IAAIhiB,WAAYhP,EAAQ,4GArCpB,EAqCwIkxB,IAGnJ,GADAj2B,EAAM,GACO,IAARqjB,EAAY,CAGhB,IAFAqN,EAAMwF,GAAezF,GACrB5rB,EAAYgK,EAAEtO,OAAS,EACjBR,EAAI,EAAGA,EAAI4Z,EAAQpZ,OAAQR,IAChCsH,EAAMqpB,EAAK/W,EAAS5Z,GAAK8E,GACzB7E,EAAI8E,KAAM+J,EAAGxH,IAEd,OAAOrH,CACP,CAGD,IADAqjB,EAAM4S,EAAY,EACZl2B,EAAI,EAAGA,EAAI8O,EAAEtO,OAAQR,IAC1BC,EAAI8E,KAAMkxB,GAAQnnB,EAAG9O,GAAK4Z,EAAS0J,EAAKoN,IAEzC,OAAOzwB,CACR,IzHm2DA2G,EAAAsb,GAAA,a0Hr4DA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACA0G,EACA+B,EACA3rB,EACAiK,EACApG,EACAmL,EAIJ,GAFA0E,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAOtB,IAJA3T,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAKjjB,EAAG0V,GACRwN,EAAKjZ,EAAGyL,GACRkU,EAAK/lB,EAAG6R,GACRiW,EAAK3c,EAAG0G,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAG3C,I1H+2DA3d,EAAAsb,GAAA,a2H/4DA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACAC,EACA0G,EACA+B,EACAxP,EACA1B,EACApO,EACA4f,EACAjsB,EACAiK,EACApG,EACAmL,EAKJ,GAHA0E,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAOjC,IAJAzgB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKnc,EAAG0gB,GACRjG,EAAKxQ,EAAGyW,GACRrU,EAAKxI,EAAG6c,GACRuL,EAAKjd,EAAG0R,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAI5C,I3H42DA3d,EAAAsb,GAAA,a4Hz5DA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACAC,EACA0G,EACA+B,EACAxP,EACA1B,EACApO,EACA4f,EACA7P,EACA2H,EACAzX,EACAigB,EACAvsB,EACAiK,EACApG,EACAmL,EAMJ,GAJA0E,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAO5C,IAJA7gB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA1E,EAAKpc,EAAG8gB,GACRiD,EAAK9Z,EAAG6W,GACRxU,EAAKzI,EAAGid,GACRyL,EAAKvd,EAAG8R,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAK7C,I5Hy2DA3d,EAAAsb,GAAA,a6Hn6DA,SAAoBuW,EAAQlW,EAAOrN,GAClC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACAC,EACA0G,EACA+B,EACAxP,EACA1B,EACApO,EACA4f,EACA7P,EACA2H,EACAzX,EACAigB,EACAtI,EACAC,EACA2F,EACAgD,EACA7sB,EACAiK,EACApG,EACAmL,EAOJ,GALA0E,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAO5C,IAJA7gB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACZ9lB,EAAI8lB,EAAQ,GACZ3a,EAAI2a,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA+C,EAAKjkB,EAAGkhB,GACRgD,EAAKja,EAAGiX,GACR2I,EAAKhmB,EAAGqd,GACR2L,EAAK7d,EAAGkS,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACTxU,EAAKud,EAAI/I,GACTyL,EAAKM,EAAI/L,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAKtB,IAJAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACTrU,EAAKC,EAAIoU,GACTuL,EAAKM,EAAI7L,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAKtB,IAJAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACTkU,EAAKvd,EAAIqJ,GACTiW,EAAKM,EAAIvW,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtBkW,EAAIlW,GAAOrP,EAAK6c,EAAIxN,GAAMyN,EAAIzN,GAAMmU,EAAInU,GAM9C,I7Hs2DA3d,EAAAsb,GAAA,mB8Hl7DA,SAA0B7a,GACzB,OAAKA,GAAsB,iBAARA,GAAoBH,EAAiBG,GAChDA,EAED,IAAImQ,GAAenQ,EAC3B,I9Hu7DAT,EAAAsb,GAAA,a+H1zDA,SAAiBpT,EAAG0tB,EAAOC,GAC1B,OAAKA,EAnEN,SAA0B3tB,EAAG0tB,GAC5B,IAAIE,EACA/3B,EACA8E,EACAxJ,EACAsI,EACAY,EACAnJ,EAIJ,GAFAC,EAAM,GAEO,KADbwJ,EAAMqF,EAAEtO,QAEP,OAAOP,EAKR,IAHAsI,GAAM,EACN5D,EAAO2G,IACPoxB,EAAQ,EACF18B,EAAI,EAAGA,EAAIyJ,EAAKzJ,KACrBmJ,EAAI2F,EAAG9O,MACI2E,GAAU4D,GAAOnF,GAAO+F,IAClCuzB,GAAS,IACKF,GACbv8B,EAAI8E,KAAMJ,IAGXA,EAAOwE,EACPuzB,EAAQ,EACRz8B,EAAI8E,KAAMJ,GACV4D,GAAM,EACDnF,GAAOuB,KACX4D,GAAM,IAIT,OAAOtI,CACR,CAiCS28B,CAAiB9tB,EAAG0tB,GA7H7B,SAAqB1tB,EAAG0tB,GACvB,IAAIE,EACA/3B,EACA8E,EACAxJ,EACAkJ,EACAnJ,EAIJ,GAFAC,EAAM,GAEO,KADbwJ,EAAMqF,EAAEtO,QAEP,OAAOP,EAIR,IAFA0E,EAAO2G,IACPoxB,EAAQ,EACF18B,EAAI,EAAGA,EAAIyJ,EAAKzJ,KACrBmJ,EAAI2F,EAAG9O,MACI2E,GACV+3B,GAAS,IACKF,GACbv8B,EAAI8E,KAAMJ,IAGXA,EAAOwE,EACPuzB,EAAQ,EACRz8B,EAAI8E,KAAMJ,IAGZ,OAAO1E,CACR,CAkGQw/B,CAAY3wB,EAAG0tB,EACvB,I/H+zDA51B,EAAAsb,GAAA,cgI53DA,SAAqBpT,GACpB,IAAI5I,EACJ,OAnFD,SAAoBA,EAAKqvB,GACxB,MAAkC,mBAAlBrvB,EAAKqvB,EACtB,CAiFMC,CAAW1mB,EAAG,cACXA,EAAE4wB,cAEVx5B,EAAM2R,GAAkB/I,IACfwI,iBAxCV,SAAoBxI,GACnB,IAAIgJ,EACArR,EACAxG,EACAD,EAMJ,IAJA8X,EAAOhJ,EAAEgJ,KACTrR,EAAMqI,EAAEsI,UAAW,GAEnBnX,EAAM,GACAD,EAAI8X,EAAKtX,OAAO,EAAGR,GAAK,EAAGA,IAChCC,EAAI8E,KAAM0B,EAAKqR,EAAM9X,IAEtB,OAAOC,CACR,CA2BSmX,CAAWlR,GAvEpB,SAAmB4I,GAClB,IAAI7O,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI8O,EAAEtO,OAAO,EAAGR,GAAK,EAAGA,IAC7BC,EAAI8E,KAAM+J,EAAG9O,IAEd,OAAOC,CACR,CAgEQ+X,CAAUlJ,EAClB,IhI43DAlI,EAAAsb,GAAA,WiI18DA,SAAkBuW,EAAQlW,EAAOrN,GAChC,IAAIsN,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACAljB,EACAiK,EAIJ,GAFAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAKtB,IAFA3T,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAKjjB,EAAG0V,GACRwN,EAAKjZ,EAAGyL,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,GAGvB,IjI47DA3d,EAAAsb,GAAA,akI98DA,SAAoBuW,EAAQlW,EAAOrN,EAAKX,GACvC,IAAID,EACAkO,EACAC,EACA8B,EACAC,EACAuN,EACAC,EACAljB,EACAiK,EACA5P,EAIJ,GAFAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,KACPC,GAAM,GAAKC,GAAM,GAQtB,IALKve,UAAU1D,OAAS,IACvB8T,EAAUpQ,UAAW,IAEtB4K,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNjU,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAKjjB,EAAG0V,GACRwN,EAAKjZ,EAAGyL,GACFD,EAAK,EAAGA,EAAK/B,EAAI+B,SAEX,KADXpb,EAAIoL,EAAKzS,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEC,EAAID,GAAM,CAAEzV,EAAGiK,OAElDiZ,EAAIzN,GAAOrP,EAAK/L,GAIpB,IlIw7DAvC,EAAAsb,GAAA,WmI99DA,SAAkBuW,EAAQlW,EAAOrN,GAChC,IAAIsN,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACA9G,EACA+G,EACAzI,EACAza,EACAiK,EAKJ,GAHAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAKjC,IAFAzgB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKnc,EAAG0gB,GACRjG,EAAKxQ,EAAGyW,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,GAIxB,InIu8DA3d,EAAAsb,GAAA,aoIl+DA,SAAoBuW,EAAQlW,EAAOrN,EAAKX,GACvC,IAAID,EACAkO,EACAC,EACA8M,EACAhL,EACAC,EACAgL,EACAuC,EACA9G,EACA+G,EACAzI,EACAza,EACAiK,EACA5P,EAKJ,GAHAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAQjC,IALKrrB,UAAU1D,OAAS,IACvB8T,EAAUpQ,UAAW,IAEtB4K,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNjJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKnc,EAAG0gB,GACRjG,EAAKxQ,EAAGyW,GACFhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,SAEX,KADXpb,EAAIoL,EAAKzS,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEiL,EAAIhL,EAAID,GAAM,CAAEzV,EAAGiK,OAEtDiZ,EAAIzN,GAAOrP,EAAK/L,GAKrB,IpIm8DAvC,EAAAsb,GAAA,WqIl/DA,SAAkBuW,EAAQlW,EAAOrN,GAChC,IAAIsN,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA/jB,EACAiK,EAMJ,GAJAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAK5C,IAFA7gB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAKpc,EAAG8gB,GACRiD,EAAK9Z,EAAG6W,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,GAKzB,IrIk9DA3d,EAAAsb,GAAA,asIt/DA,SAAoBuW,EAAQlW,EAAOrN,EAAKX,GACvC,IAAID,EACAkO,EACAC,EACA8M,EACAI,EACApL,EACAC,EACAgL,EACAI,EACAmC,EACA9G,EACAC,EACA8G,EACAzI,EACAsJ,EACA/jB,EACAiK,EACA5P,EAMJ,GAJAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAQ5C,IALKzrB,UAAU1D,OAAS,IACvB8T,EAAUpQ,UAAW,IAEtB4K,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACN7I,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAKpc,EAAG8gB,GACRiD,EAAK9Z,EAAG6W,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,SAEX,KADXpb,EAAIoL,EAAKzS,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEqL,EAAIJ,EAAIhL,EAAID,GAAM,CAAEzV,EAAGiK,OAE1DiZ,EAAIzN,GAAOrP,EAAK/L,GAMtB,ItI88DAvC,EAAAsb,GAAA,WuItgEA,SAAkBuW,EAAQlW,EAAOrN,GAChC,IAAIsN,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACAlkB,EACAiK,EAOJ,GALAyJ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAKvD,IAFAjhB,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA+C,EAAKjkB,EAAGkhB,GACRgD,EAAKja,EAAGiX,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,IACtByN,EAAIzN,GAAOrP,EAAK6c,EAAIxN,GAM1B,IvI69DA3d,EAAAsb,GAAA,awIzgEA,SAAoBuW,EAAQlW,EAAOrN,EAAKX,GACvC,IAAID,EACAkO,EACAC,EACA8M,EACAI,EACAI,EACAxL,EACAC,EACAgL,EACAI,EACAI,EACA+B,EACA9G,EACAC,EACA6H,EACAf,EACAzI,EACAsJ,EACAG,EACAlkB,EACAiK,EACA5P,EAOJ,GALAqZ,EAAKD,EAAO,GACZE,EAAKF,EAAO,GACZgN,EAAKhN,EAAO,GACZoN,EAAKpN,EAAO,GACZwN,EAAKxN,EAAO,KACPC,GAAM,GAAKC,GAAM,GAAK8M,GAAM,GAAKI,GAAM,GAAKI,GAAM,GAQvD,IALK7rB,UAAU1D,OAAS,IACvB8T,EAAUpQ,UAAW,IAEtB4K,EAAI2pB,EAAQ,GACZ1f,EAAI0f,EAAQ,GACNzI,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA+C,EAAKjkB,EAAGkhB,GACRgD,EAAKja,EAAGiX,GACFJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFA1E,EAAK6H,EAAInD,GACTiD,EAAKG,EAAIpD,GACHJ,EAAK,EAAGA,EAAKD,EAAIC,IAGtB,IAFAvE,EAAKC,EAAIsE,GACTjG,EAAKsJ,EAAIrD,GACHhL,EAAK,EAAGA,EAAK/B,EAAI+B,IAGtB,IAFAuN,EAAK9G,EAAIzG,GACTwN,EAAKzI,EAAI/E,GACHD,EAAK,EAAGA,EAAK/B,EAAI+B,SAEX,KADXpb,EAAIoL,EAAKzS,KAAMwS,EAASyd,EAAIxN,GAAM,CAAEyL,EAAIJ,EAAIJ,EAAIhL,EAAID,GAAM,CAAEzV,EAAGiK,OAE9DiZ,EAAIzN,GAAOrP,EAAK/L,GAOvB,IxIw9DAvC,EAAAsb,GAAA,WlBp/DA,SAAkBuW,EAAQlW,EAAOrN,GAChC,OAAOkO,GAASqV,EAAQ,GAAKA,EAAQ,GAAKlW,EAAM/hB,OAAQ+hB,EAAO,EAAGrN,EACnE,IkB4/DAtO,EAAAsb,GAAA,ayIvjEA,SAAoB+I,EAAIC,GACvB,IAAI7jB,EACAoC,EACAzJ,EAGJ,IADAyJ,EAAMyhB,EAAKD,IACC,EACX,MAAO,CAAEA,GAGV,IADA5jB,EAAM,CAAE4jB,GACFjrB,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBqH,EAAItC,KAAMkmB,EAAKjrB,GAEhB,OAAOqH,CACR,IzImjEAT,EAAAsb,GAAA,QAAAoU,IAUA1vB,EAAAsb,GAAA,YAAA+U,IAUArwB,EAAAsb,GAAA,UAAAgW,IAUAtxB,EAAAsb,GAAA,SAAAyJ,IAUA/kB,EAAAsb,GAAA,QAAApiB,IAUA8G,EAAAsb,GAAA,UAAAQ,IAUA9b,EAAAsb,GAAA,W0IznEA,SAAkBK,GACjB,OAAO8M,GAAU,EAAK9M,EACvB,I1IioEA3b,EAAAsb,GAAA,W2InoEA,SAAkBK,GACjB,OAAOkN,GAAU,EAAKlN,EACvB,I3I2oEA3b,EAAAsb,GAAA,W4I7oEA,SAAkBK,GACjB,OAAOsN,GAAU,EAAKtN,EACvB,I5IqpEA3b,EAAAsb,GAAA,W6InpEA,SAAkBK,GACjB,OAAO0N,GAAU,EAAK1N,EACvB,I7I2pEA3b,EAAAsb,GAAA,O8IzpEA,SAAcuW,GACb,IAAIuF,EACA2B,EACA1/B,EACAoH,EACAyc,EACAjO,EACA7V,EACA8D,EAGJ,IADAggB,EAAI2U,EAAOj4B,QACF,EACR,MAAO,GAIR,IADAqV,GADA8pB,EAAOlc,GAAMgV,IACH,GAAIj4B,QACL,EACR,MAAO,GAGR,IADAw9B,EAAU,GACJl6B,EAAI,EAAGA,EAAIggB,EAAGhgB,IACnBk6B,EAAQj5B,KAAMkT,GAAe0nB,EAAM77B,KAGpC,IADA7D,EAAM,GACAD,EAAI,EAAGA,EAAI6V,EAAG7V,IAAM,CAEzB,IADAqH,EAAM,GACAvD,EAAI,EAAGA,EAAIggB,EAAGhgB,IACnBuD,EAAItC,KAAMi5B,EAASl6B,GAAK67B,EAAM77B,GAAK9D,IAEpCC,EAAI8E,KAAMsC,EACV,CACD,OAAOpH,CACR,I9ImoEA2G,EAAAsb,GAAA,c+InmEA,SAAqB0d,EAAYppB,GAChC,IAAIsnB,EAAKjmB,GAAkB+nB,GACvB7B,EAAKlmB,GAAkBrB,GAE3B,OAAKsnB,EAAGxmB,kBAAoBymB,EAAGzmB,iBApEhC,SAAoBsoB,EAAYppB,GAC/B,IAAIqpB,EACAlM,EACAmM,EACAjM,EACA5zB,EACAD,EASJ,IAPA6/B,EAAQD,EAAW9nB,KACnBgoB,EAAOF,EAAWxoB,UAAW,GAE7Buc,EAAQnd,EAAOsB,KACf+b,EAAOrd,EAAOY,UAAW,GAEzBnX,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAI6/B,EAAMr/B,OAAQR,IAC9BC,EAAK6/B,EAAMD,EAAO7/B,IAAQ6zB,EAAMF,EAAO3zB,GAExC,OAAOC,CACR,CAkDSmX,CAAW0mB,EAAIC,GAjCxB,SAAkB6B,EAAYppB,GAC7B,IAAIvW,EACAD,EAGJ,IADAC,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAI4/B,EAAWp/B,OAAQR,IACnCC,EAAK2/B,EAAY5/B,IAAQwW,EAAQxW,GAElC,OAAOC,CACR,CA0BQqrB,CAASsU,EAAYppB,EAC7B,I/IqmEA5P,EAAAsb,GAAA,egJzqEA,SAAsBuW,EAAQsH,GAC7B,IAAI/B,EACA2B,EACAnqB,EACA/O,EACAxG,EACAiG,EACA4d,EACAjO,EACA7V,EACA8D,EAGJ,IADAggB,EAAI2U,EAAOj4B,QACF,EACR,MAAO,GAIR,IADAqV,GADA8pB,EAAOlc,GAAMgV,IACH,GAAIj4B,QACL,EACR,MAAO,GAMR,IAJAw9B,EAAU,GAEVv3B,EAAMwR,GAAe8nB,GACrBvqB,EAAO,GACD1R,EAAI,EAAGA,EAAIggB,EAAGhgB,IACnBk6B,EAAQj5B,KAAMkT,GAAe0nB,EAAM77B,KACnC0R,EAAKzQ,KAAM0B,EAAKs5B,EAAQj8B,IAGzB,IADA7D,EAAM,GACAD,EAAI,EAAGA,EAAI6V,EAAG7V,IAAM,CAEzB,IADAkG,EAAM,CAAA,EACApC,EAAI,EAAGA,EAAIggB,EAAGhgB,IACnBoC,EAAKsP,EAAM1R,IAAQk6B,EAASl6B,GAAK67B,EAAM77B,GAAK9D,GAE7CC,EAAI8E,KAAMmB,EACV,CACD,OAAOjG,CACR,IhJ6oEA2G,EAAAsb,GAAA,aiJxpEA,SAAoBuW,EAAQsH,GAC3B,IAAI93B,EACAG,EACAu3B,EACAnqB,EACAvV,EACA2V,EACAkO,EACAjO,EACA7V,EAGJ,IADA8jB,EAAI2U,EAAOj4B,QACF,EACR,MAAO,GAIR,IADAqV,GADA8pB,EAAOlc,GAAMgV,IACH,GAAIj4B,QACL,EACR,MAAO,GAIR,IADAoV,EAAM,GACA5V,EAAI,EAAGA,EAAI8jB,EAAG9jB,IACnB4V,EAAI7Q,KAAMqS,GAAWuoB,EAAM3/B,IAAMoX,WAclC,SAAS4lB,EAAOh9B,GAEf,OADAgH,EAA0ByK,KAAM,KAAMzR,GAC/ByR,IACP,CAGD,IAjBA+D,EAAOiO,GAAMsc,GAiBP//B,EAAI,EAAGA,EAAI8jB,EAAG9jB,IACnBiI,EAASo2B,EAAUsB,EAAM3/B,GAAK4V,EAAK5V,GAAK,IACxCoI,EAASk2B,EAAUqB,EAAM3/B,GAAK4V,EAAK5V,GAAK,IACxCosB,GAAsB4Q,EAAMn8B,UAAW2U,EAAMxV,GAAKiI,EAAQG,GAO3D,IAJApB,EAA0Bg2B,EAAMn8B,UAAW,UA2D3C,WACC,IAAIZ,EACA+d,EACAhe,EAGJ,IADAC,EAAM,CAAA,EACAD,EAAI,EAAGA,EAAI8jB,EAAG9jB,IAEnBC,EADA+d,EAAIxI,EAAMxV,IACCyR,KAAMuM,GAElB,OAAO/d,CACP,IAnEDA,EAAM,GACAD,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBC,EAAI8E,KAAM,IAAIi4B,EAAOh9B,IAEtB,OAAOC,EAUP,SAASo+B,EAAUh3B,EAAKY,GACvB,OAQA,WACC,OAAOA,EAAQZ,EAAKoK,KAAKyrB,GACzB,CACD,CAUD,SAASoB,EAAUj3B,EAAKe,GACvB,OAQA,SAAcvI,GACbuI,EAAQf,EAAKoK,KAAKyrB,GAAIr9B,EACtB,CACD,CAoBF,IC9KA,IAAIJ,GAAgC,mBAAhBgQ,YAA+BA,YAAc,KCgBjE,SAASuwB,KACR,IAAI50B,EACAogB,EACA3X,EAEJ,GAAkC,mBAAtBosB,GACX,OAAO,EAGR,KAEC70B,EAASsE,GADTmE,EAAM,IAAIosB,GAAmB,MACwC,mBAA7BA,GAAkBC,WAEzD1U,EAAO,IAAIjhB,GAAcsJ,IACnB,IAAO,KACb2X,EAAM,GAAMlgB,IACZF,EACCA,GACA60B,GAAkBC,OAAQ1U,IACP,KAAnB3X,EAAIM,aACW,OAAfqX,EAAM,IACNA,EAAM,IAAQA,EAAM,GAGtB,CAAC,MAAQzlB,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CC5CA,IAAIjB,GAAgC,mBAAhBsF,YAA+BA,iBAAc,EC6BjE,IAAA0wB,GATKH,KACG/5B,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECJA,IAAI4+B,GAAoC,mBAAbC,SCL3B,IAAIl2B,GAAgC,mBAAhBsF,YAA+BA,iBAAc,EC6BjE,IAAA6wB,GATKN,KACG/5B,GCdR,WACC,MAAM,IAAIzE,MAAO,kBAClB,ECTI/B,GAA6B,mBAAb4gC,SAA4BA,SAAW,KCA3D,ICuBIl2B,GDvBAA,GAA6B,mBAAbk2B,SAA4BA,cAAW,EC2B1Dl2B,GCXD,WACC,IAAIiB,EACAogB,EACA3X,EPQgBhU,EONpB,GAA+B,mBAAnB0gC,GACX,OAAO,EAGR,IACC1sB,EAAM,IAAIpE,GAAa,IACvB+b,EAAO,IAAI+U,GAAgB1sB,EAAK,GPAbhU,EOCE2rB,GAArBpgB,GPCEg1B,IAAevgC,aAAiBwgC,UACT,sBAAzBp3B,GAAapJ,KOF6C,mBAApB2rB,EAAKgV,YAAwD,mBAApBhV,EAAKiV,cAEnFjV,EAAKiV,WAAY,GAAI,MACrBjV,EAAKiV,WAAY,EAAGn1B,KACpBF,EACCA,GACAogB,EAAK1Y,SAAWe,GACI,KAApB2X,EAAKrX,YACe,IAApBqX,EAAKzY,aACqB,OAA1ByY,EAAKgV,WAAY,IACjBhV,EAAKgV,WAAY,IAAQhV,EAAKgV,WAAY,GAG5C,CAAC,MAAQz6B,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CDrBKs1B,GACGz6B,GElBR,WACC,MAAM,IAAIzE,MAAO,kBAClB,EFwBA,IAAAm/B,GAAex2B,GGiBXy2B,GAAQ3+B,KAAK2+B,MCtCbC,GAAY,oBACZC,GAAW,CAAE,QAAS,OAAQ,SAelC,SAASC,GAAWlhC,EAAOqK,GAC1B,IAAIiH,EAGJ,GAAc,YADdA,SAActR,GACW,CAExB,IADAA,EAAQmhC,KAAKz8B,MAAO1E,KACLA,EACd,MAAM,IAAI2B,MAAOwD,EAAQ,6CAA8CkF,EAAKpJ,gBAE7EjB,EAAQ,IAAImhC,KAAMnhC,EAClB,CACD,GAAc,WAATsR,EAAoB,CACxB,IAAM0vB,GAAUtyB,KAAM1O,GACrB,MAAM,IAAI2B,MAAOwD,EAAQ,mFAAoFkF,EAAKpJ,gBAElF,KAA5BjB,EAAM4B,WAAWjB,SACrBX,GAAS,KAEVA,EAAQ,IAAImhC,KAAMnhC,EAClB,CACD,KAAOA,aAAiBmhC,MACvB,MAAM,IAAIj9B,UAAWiB,EAAQ,gHAAiHkF,IAE/I,OAAOrK,CACR,CCpDA,IAAIJ,GAA2B,mBAAXwhC,OAA0BA,OAAS,KCAvD,ICmBI92B,GDnBAA,GAAO+2B,EAAoBD,OCuB9B92B,GCRD,WACC,IAAIiB,EACA2L,EAEJ,GAA6B,mBAAjBoqB,GACX,OAAO,EAGR,IAMC/1B,EACCzB,GALAoN,EADiC,mBAAtBoqB,GAAa7f,KACpB6f,GAAa7f,KAAM,CAAE,EAAG,EAAG,EAAG,IAE9B,IAAI6f,GAAc,CAAE,EAAG,EAAG,EAAG,MAItB,IAAXpqB,EAAG,IACQ,IAAXA,EAAG,IACQ,IAAXA,EAAG,IACQ,IAAXA,EAAG,EAEJ,CAAC,MAAQhR,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CDpBKg2B,GACG3hC,GEdR,WACC,MAAM,IAAI+B,MAAO,kBAClB,EFoBA,IAAA6/B,GAAel3B,GGAf,IAAAm3B,GCvBWlwB,GAAY6vB,GAAOM,aCiB9B,SAAsBC,GACrB,IAAMtyB,GAAsBsyB,GAC3B,MAAM,IAAIz9B,UAAWiB,EAAQ,qEAAsEw8B,IAEpG,OAAOP,GAAOM,YAAaC,EAC5B,ECLA,SAAsBA,GACrB,IAAMtyB,GAAsBsyB,GAC3B,MAAM,IAAIz9B,UAAWiB,EAAQ,qEAAsEw8B,IAEpG,OAAO,IAAIP,GAAQO,EACpB,ECXA,IAAInoB,GAAQ,CACXjS,QAAWmD,GACXhD,QAAW+C,GACX7C,MAAS+C,GACThD,MAASiD,GACT/C,KAAQgD,GACR9C,OAAU+C,GACVhD,OAAUiD,GACV/C,MAASgD,GACT/C,OAAUgD,GACVxC,UAAayC,GACb1C,WAAc2C,GACdI,KAAQH,ICVT,SAASoO,GAAOnR,GACf,OAAOmmB,GAAOnmB,IAAW,IAC1B,2OCHA,SAASu5B,GAAiBv5B,GACzB,OAAOkK,GAAmBlK,IAAW,IACtC,CCTA,ICcIw5B,GDdA1J,GAAgBb,GAAS1wB,IAAK,kBCgBjCi7B,GCTOn0B,GADGg0B,GAAa,IFgBxB,SAAgB/gC,GACf,IAAImhC,EACA9uB,EACA3K,EACAiC,EACA0J,EAEA+tB,EAEJ,IAAM1yB,GAAsB1O,GAC3B,MAAM,IAAIuD,UAAWiB,EAAQ,+EAAgFxE,IAO9G,GAAe,aAJd0H,EADIhE,UAAU1D,OAAS,EACf0D,UAAW,GAEX8zB,IAGR,OAAOl4B,GAAOU,GAGf,GAAgB,QADhBmhC,EAASF,GAAiBv5B,IAEzB,MAAM,IAAInE,UAAWiB,EAAQ,gFAAiFkD,IAuB/G,OApBAiC,EAAOkP,GAAOnR,GAGd05B,EAAKD,EAASnhC,EACC,eAAV0H,IACJ05B,GAAM,GAMP/uB,GAHAgB,EAAM0tB,GAAaK,IAGN7uB,WACE,eAAV7K,IACEgH,GAAsB2D,EAAO8uB,KAClC9uB,GAAU,IAIN,IAAI1I,EAAM0J,EAAIf,OAAQD,EAAQrS,EAGrC,EGxDA,SAAgBA,GACf,OAAK0D,UAAU1D,OAAS,EAChBV,GAAOU,EAAQ0D,UAAW,IAE3BpE,GAAOU,EACf,EFOA,IAAAqhC,GAAeH,GG7Bf,IAAI5d,GAAI,EAqBR,SAASge,GAAOjsB,EAAGksB,EAAOjzB,EAAG4e,EAASC,GACrC,IAAIK,EACAnG,EACApQ,EACAzX,EAEJ,GAAK6V,GAAK,EACT,OAAO/G,EAGR,IADA2I,EAAII,GAAkB/I,IACfwI,iBAEN,OCHF,SAAgBzB,EAAGksB,EAAOjzB,EAAG4e,EAASC,GACrC,IAAIG,EACApnB,EACAsnB,EACAhuB,EASJ,IANA8tB,EAAOhf,EAAEgJ,KAGTpR,EAAMoI,EAAEsI,UAAW,GAEnB4W,EAAKL,EACC3tB,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB0G,EAAKonB,EAAME,EAAI+T,GACf/T,GAAMN,CAGR,CDhBEtW,CAAWvB,EAAGksB,EAAOtqB,EAAGiW,EAASC,GAC1BlW,EAAEK,KAKV,GAHAkW,EAAKL,EAGY,IAAZD,EAAgB,CAIpB,IAHA7F,EAAIhS,EAAIiO,IAGC,EACR,IAAM9jB,EAAI,EAAGA,EAAI6nB,EAAG7nB,IACnB8O,EAAGkf,GAAO+T,EACV/T,GAAMN,EAGR,GAAK7X,EAAIiO,GACR,OAAOhV,EAER,IAAM9O,EAAI6nB,EAAG7nB,EAAI6V,EAAG7V,GAAK8jB,GACxBhV,EAAGkf,GAAO+T,EACVjzB,EAAGkf,EAAG,GAAM+T,EACZjzB,EAAGkf,EAAG,GAAM+T,EACZjzB,EAAGkf,EAAG,GAAM+T,EACZjzB,EAAGkf,EAAG,GAAM+T,EACZjzB,EAAGkf,EAAG,GAAM+T,EACZjzB,EAAGkf,EAAG,GAAM+T,EACZjzB,EAAGkf,EAAG,GAAM+T,EACZ/T,GAAMlK,GAEP,OAAOhV,CACP,CACD,IAAM9O,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB8O,EAAGkf,GAAO+T,EACV/T,GAAMN,EAEP,OAAO5e,CACR,CEtDA,SAASgzB,GAAOjsB,EAAGksB,EAAOjzB,EAAG4e,GAC5B,OAAOU,GAASvY,EAAGksB,EAAOjzB,EAAG4e,EAASkD,GAAe/a,EAAG6X,GACzD,CCGA,SAASsU,GAAgBniC,GACxB,IAAI4gB,SAAW5gB,EACf,OACW,OAAVA,IACQ,WAAN4gB,GAAwB,aAANA,IACpBrP,GAAYvR,EAAMsT,KAEpB,CCZA,SAAS8uB,GAAYzvB,GACpB,IAAIkqB,EAEJ,IAAMsF,GAAgBxvB,GACrB,MAAM,IAAIzO,UAAWiB,EAAQ,2DAA4DwN,IAG1F,IADAkqB,EAAQ,IACO,CAEd,GADIlqB,EAASW,OACNC,KACN,OAAOspB,EAERA,GAAS,CACT,CACF,CCNA91B,EAAAnH,GAAA,UAAA2uB,ICRA,IAAI7a,GAAsBhB,KACtBylB,GAAgBb,GAAS1wB,IAAK,kBCKlC,SAASy7B,GAASrsB,EAAG/G,EAAG4e,EAASC,EAASpZ,EAAMD,GAC/C,IAAI0Z,EACAvW,EACAzX,EAEJ,GAAK6V,GAAK,EACT,OAAO/G,EAGR,IADA2I,EAAII,GAAkB/I,IACfwI,iBAEN,OCKF,SAAkBzB,EAAG/G,EAAG4e,EAASC,EAASpZ,EAAMD,GAC/C,IAAIwZ,EACApnB,EACAD,EACAunB,EACAhuB,EAUJ,IAPA8tB,EAAOhf,EAAEgJ,KAGTrR,EAAMqI,EAAEsI,UAAW,GACnB1Q,EAAMoI,EAAEsI,UAAW,GAEnB4W,EAAKL,EACC3tB,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB0G,EAAKonB,EAAME,EAAIzZ,EAAKzS,KAAMwS,EAAS7N,EAAKqnB,EAAME,GAAMhuB,EAAGguB,EAAIlf,IAC3Dkf,GAAMN,CAGR,CD1BEtW,CAAWvB,EAAG4B,EAAGiW,EAASC,EAASpZ,EAAMD,GAClCmD,EAAEK,KAGV,IADAkW,EAAKL,EACC3tB,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB8O,EAAGkf,GAAOzZ,EAAKzS,KAAMwS,EAASxF,EAAGkf,GAAMhuB,EAAGguB,EAAIlf,GAC9Ckf,GAAMN,EAEP,OAAO5e,CACR,CEpBA,SAASozB,GAASrsB,EAAG/G,EAAG4e,EAASnZ,EAAMD,GACtC,OAAO8Z,GAASvY,EAAG/G,EAAG4e,EAASkD,GAAe/a,EAAG6X,GAAWnZ,EAAMD,EACnE,CCSA1N,EAAAnH,GAAA,UAAA2uB,ICjBA,IAAI7a,GAAsBhB,KACtBylB,GAAgBb,GAAS1wB,IAAK,kBCrBlC,IAAI07B,GAAYziC,OAAOmB,UAAUye,cCsBjC,SAAS8iB,GAAYjiC,GACpB,MAAa,KAARA,EACG,GAEDA,EAAI4B,OAAQ,GAAIf,cAAgBb,EAAI0E,MAAO,EACnD,CCpBA,SAASoO,GAAcC,GACtB,IAAIjT,EACAkJ,EAGJ,IADAlJ,EAAM,KAELkJ,EAAI+J,EAAGC,QACAC,MAGPnT,EAAI8E,KAAMoE,EAAEtJ,OAEb,OAAOI,CACR,CCUA,IAAIsT,GAAsBhB,KACtB8vB,GAAgB,gBAChBC,GAAa,aAEbC,GAAY,CACfn7B,QAAW,aACXG,QAAW,aACXC,MAAS,WACTC,MAAS,WACTE,OAAU,YACVC,OAAU,aAEP46B,GAAY,CACfp7B,QAAW,aACXG,QAAW,aACXC,MAAS,WACTC,MAAS,WACTE,OAAU,YACVC,OAAU,aAEP66B,GAAe,CAClBC,EAAK,IACL//B,EAAK,IACL3C,EAAK,KACL+pB,EAAK,IACLhT,EAAK,KAEFiG,GAAa7E,GAxBJ,CAAE,UAAW,UAAW,QAAS,QAAS,SAAU,WAoCjE,SAASwqB,GAAW9iC,GACnB,OAAS8P,GAAU9P,GAAuBA,EC3D/BiB,cD2DyC,IACrD,CASA,SAAS2Y,GAAgB5Z,GACxB,OAASA,IAAUwiC,EACpB,CASA,SAASO,GAAgBC,GACxB,OAAO,EAAWR,GAAgBC,EACnC,CA8FA,SAASlqB,GAASlQ,GACjB,IAAIkK,EACA0wB,EACAC,EACAC,EAEJ,IAAMhmB,GAAY9U,GACjB,MAAM,IAAInE,UAAWiB,EAAQ,+EAAgFkD,IAwB9G,SAAS+6B,IACR,IAAIlwB,EACAmwB,EACApvB,EACA+uB,EACAhvB,EACApK,EACApI,EACAmT,EAGJ,GADAV,EAAQ5P,UAAU1D,SACXiR,gBAAgBwxB,GACtB,OAAKnvB,EAAQ,EACL,IAAImvB,EAAY/+B,UAAU,IAEnB,IAAV4P,EACG,IAAImvB,EAAY/+B,UAAU,GAAIA,UAAU,IAEjC,IAAV4P,EACG,IAAImvB,EAAY/+B,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAEvD,IAAI++B,EAAY/+B,UAAU,GAAIA,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAG5E,GAAoB,QADpBg/B,EAAaP,GAAWz+B,UAAW,OACNwY,GAAawmB,GACzC,MAAM,IAAIn/B,UAAWiB,EAAQ,gFAAiFd,UAAW,KAO1H,GALA2+B,EAAOppB,GAAgBypB,GAKR,KAHfpvB,GAAS,GAIRD,EAAM,IAAIwsB,GAAU,IAAI5wB,GAAa,SAC/B,GAAe,IAAVqE,EAEX,GAAK5E,GADL7N,EAAM6C,UAAW4P,IAEhBD,EAAM,IAAIwsB,GAAU,IAAI5wB,GAAapO,EAAI+Q,SACnC,GAAK7C,GAAclO,GACzBwS,EAAME,EAAW,IAAIssB,GAAU,IAAI5wB,GAAapO,EAAIb,OAAO4R,IAAuB/Q,EAAKwhC,QACjF,GAAKnzB,GAAerO,IAE1B,GADAwS,EAAM,IAAIwsB,GAAUh/B,IACd6N,GAAsB7N,EAAI8S,WAAW/B,GAC1C,MAAM,IAAI4B,WAAYhP,EAAQ,yFAA0FoN,EAAmByB,EAAIM,iBAE1I,KAAK1F,GAAUpN,GAcrB,MAAM,IAAI0C,UAAWiB,EAAQ,qHAAsH3D,IAbnJ,IAA6B,IAAxBkS,GACJ,MAAM,IAAIxP,UAAWiB,EAAQ,mJAAoJ3D,IAElL,IAAM+P,GAAY/P,EAAK+S,KACtB,MAAM,IAAIrQ,UAAWiB,EAAQ,qHAAsH3D,IAGpJ,IAAM+P,IADNyC,EAAMxS,EAAK+S,OACWjB,MACrB,MAAM,IAAIpP,UAAWiB,EAAQ,qHAAsH3D,IAEpJmT,EAAMvB,GAAcY,GACpBA,EAAME,EAAW,IAAIssB,GAAU,IAAI5wB,GAAa+E,EAAIhU,OAAO4R,IAAuBoC,EAAKquB,EAGvF,KACK,CAEN,IAAMnzB,GADNmE,EAAM3P,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,8DAA+D6O,IAG7F,IAAM3E,GADN6D,EAAa7O,UAAW,IAEvB,MAAM,IAAIH,UAAWiB,EAAQ,4EAA6E+N,IAE3G,GAAe,IAAVe,EACJD,EAAM,IAAIwsB,GAAUxsB,EAAKd,OACnB,CAEN,IAAM7D,GADNzF,EAAMvF,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,uEAAwEyE,IAGtG,IADAA,GAAO2I,GACKyB,EAAIM,WAAWpB,EAC1B,MAAM,IAAIiB,WAAYhP,EAAQ,iJAAkJyE,IAEjLoK,EAAM,IAAIwsB,GAAUxsB,EAAKd,EAAYtJ,EACrC,CACD,CAKD,OAJA7C,EAAa6K,KAAM,UAAWoC,GAC9BjN,EAAa6K,KAAM,UAAWoC,EAAIM,WAAW/B,GAC7CxL,EAAa6K,KAAM,QAASoxB,GAErBpxB,IACP,CAs0BD,OAr7BAW,EAAoBqvB,GAAiBv5B,GACrC46B,EAvFD,SAAqB56B,GACpB,OAAOk6B,GAAYl6B,GAAU,SAC9B,CAqFai7B,CAAYj7B,GACxB66B,EAASP,GAAWt6B,GACpB86B,EAAST,GAAWr6B,GAuHpBtB,EAAaq8B,EAAY,oBAAqB7wB,GAW9CxL,EAAaq8B,EAAY,OAAQH,GAoBjCl8B,EAAaq8B,EAAY,QAAQ,SAAeC,EAAY7uB,GAC3D,IAAIC,EACA+b,EACAvc,EACAS,EACAsuB,EACA5iC,EACA4T,EACAW,EACA/N,EACAgD,EACAzJ,EACJ,IAAMoR,GAAYK,MACjB,MAAM,IAAI1N,UAAW,6DAEtB,IAAMq/B,EAAyB3xB,MAC9B,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAGpG,GAAe,QADfzS,EAAQsS,GAAWO,MACKxmB,GAAa2T,GACpC,MAAM,IAAItsB,UAAWiB,EAAQ,gFAAiFk+B,IAK/G,GAHAL,EAAOppB,GAAgB4W,IAEvBvc,EAAQ5P,UAAU1D,QACL,EAAI,CAEhB,IAAM4Q,GADNmD,EAAOrQ,UAAW,IAEjB,MAAM,IAAIH,UAAWiB,EAAQ,oEAAqEuP,IAE9FT,EAAQ,IACZQ,EAAUpQ,UAAW,GAEtB,CACD,GAAKqL,GAAc8E,GAAQ,CAC1B,GAAKE,EAAO,CASX,IARA9K,EAAM4K,EAAI7T,OAETiG,EADI4N,EAAI5N,KAAO4N,EAAI3N,IACbgO,EAAgB,WAEhBzM,EAAQ,WAGf4L,GADA5T,EAAM,IAAIwR,KAAM4e,EAAO5mB,IACbiK,QACJ1T,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB6T,EAAKmvB,GAAUhjC,EAAEoS,EAAmBmC,EAAKzS,KAAMwS,EAAS7N,EAAK4N,EAAKrU,GAAKA,GAAK6iC,GAE7E,OAAO5iC,CACP,CACD,OAAO,IAAIwR,KAAM4e,EAAOhc,EACxB,CACD,GAAK5F,GAAU4F,IAASd,IAAuBnC,GAAYiD,EAAKD,KAAsB,CAErF,IAAMhD,IADNyC,EAAMQ,EAAKD,OACWjB,MACrB,MAAM,IAAIpP,UAAWiB,EAAQ,8FAA+FqP,IAU7H,IAPCG,EADID,EE5YR,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIrU,EACAkJ,EACAnJ,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI+J,EAAGC,QACAC,MAGPpT,GAAK,EACLC,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAASnL,EAAEtJ,MAAOG,IAExC,OAAOC,CACR,CF6XU0U,CAAiBd,EAAKU,EAAMD,GAE5BrB,GAAcY,GAIrBA,GADA5T,EAAM,IAAIwR,KAAM4e,EADhB5mB,EAAM+K,EAAIhU,SAEAkT,QACJ1T,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB6T,EAAKmvB,GAAUhjC,EAAEoS,EAAmBoC,EAAKxU,GAAK6iC,GAE/C,OAAO5iC,CACP,CACD,MAAM,IAAI8D,UAAWiB,EAAQ,8FAA+FqP,GAC9H,IAgBCzN,EAAaq8B,EAAY,MAAM,SAAaC,GAC3C,IAAI7S,EACAprB,EACAjF,EACJ,IAAMoR,GAAYK,MACjB,MAAM,IAAI1N,UAAW,6DAEtB,IAAMq/B,EAAyB3xB,MAC9B,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAGpG,GAAe,QADfzS,EAAQsS,GAAWO,MACKxmB,GAAa2T,GACpC,MAAM,IAAItsB,UAAWiB,EAAQ,gFAAiFk+B,IAG/G,IADAj+B,EAAO,GACDjF,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAClCiF,EAAKF,KAAMb,UAAWlE,IAEvB,OAAO,IAAIyR,KAAM4e,EAAOprB,EAC1B,IAcC2B,EAAaq8B,EAAWpiC,UAAW,MAAM,SAAayG,GACrD,IAAImC,EACJ,IAAM45B,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,IAAMj0B,GAAWvH,GAChB,MAAM,IAAIvD,UAAWiB,EAAQ,0DAA2DsC,IAMzF,GAJAmC,EAAMgI,KAAKgC,QACNnM,EAAM,IACVA,GAAOmC,KAEHnC,EAAM,GAAKA,GAAOmC,GAGvB,OAAOgI,KAAKiC,QAASqvB,GAAUz7B,EAAM8K,EAAmBX,KAAK6xB,MAC/D,IAWCrG,GAAqBgG,EAAWpiC,UAAW,UAAU,WACpD,OAAO4Q,KAAKiC,QAAQZ,MACtB,IAWCmqB,GAAqBgG,EAAWpiC,UAAW,cAAc,WACxD,OAAO4Q,KAAKiC,QAAQS,UACtB,IAWC8oB,GAAqBgG,EAAWpiC,UAAW,cAAc,WACxD,OAAO4Q,KAAKiC,QAAQX,UACtB,IAWCnM,EAAaq8B,EAAWpiC,UAAW,oBAAqBoiC,EAAW7wB,mBAenExL,EAAaq8B,EAAWpiC,UAAW,SAAS,SAAgB2I,EAAW8K,GACtE,IAAIT,EACA7T,EAEJ,IAAMqjC,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,IAAM1xB,GAAY5H,GACjB,MAAM,IAAIzF,UAAWiB,EAAQ,oEAAqEwE,IAGnG,IADAqK,EAAMpC,KAAKiC,QACL1T,EAAI,EAAGA,EAAIyR,KAAKgC,QAASzT,IAC9B,IAAMwJ,EAAU1H,KAAMwS,EAAST,EAAKkvB,GAAU/iC,EAAIoS,EAAmBX,KAAK6xB,OAAStjC,EAAGyR,MACrF,OAAO,EAGT,OAAO,CACT,IAeC7K,EAAaq8B,EAAWpiC,UAAW,UAAU,SAAiB2I,EAAW8K,GACxE,IAAIT,EACA5T,EACAD,EACAmJ,EAEJ,IAAMk6B,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,IAAM1xB,GAAY5H,GACjB,MAAM,IAAIzF,UAAWiB,EAAQ,oEAAqEwE,IAInG,IAFAqK,EAAMpC,KAAKiC,QACXzT,EAAM,GACAD,EAAI,EAAGA,EAAIyR,KAAKgC,QAASzT,IAC9BmJ,EAAI0K,EAAKkvB,GAAU/iC,EAAEoS,EAAmBX,KAAK6xB,OACxC95B,EAAU1H,KAAMwS,EAASnL,EAAGnJ,EAAGyR,OACnCxR,EAAI8E,KAAMoE,GAGZ,OAAO,IAAIsI,KAAK5H,YAAa+4B,GAAgBnxB,KAAK6xB,OAASrjC,EAC7D,IAcC2G,EAAaq8B,EAAWpiC,UAAW,WAAW,SAAkBqU,EAAKZ,GACpE,IAAIT,EACA7T,EAEJ,IAAMqjC,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,IAAM1xB,GAAY8D,GACjB,MAAM,IAAInR,UAAWiB,EAAQ,oEAAqEkQ,IAGnG,IADArB,EAAMpC,KAAKiC,QACL1T,EAAI,EAAGA,EAAIyR,KAAKgC,QAASzT,IAC9BkV,EAAIpT,KAAMwS,EAAST,EAAKkvB,GAAU/iC,EAAEoS,EAAmBX,KAAK6xB,OAAStjC,EAAGyR,KAE3E,IAcC7K,EAAaq8B,EAAWpiC,UAAW,OAAO,SAAcyG,GACvD,IAAM+7B,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,IAAM5zB,GAAsB5H,GAC3B,MAAM,IAAIvD,UAAWiB,EAAQ,qEAAsEsC,IAEpG,KAAKA,GAAOmK,KAAKgC,SAGjB,OAAOhC,KAAKiC,QAASqvB,GAAUz7B,EAAI8K,EAAmBX,KAAK6xB,MAC7D,IAeC18B,EAAaq8B,EAAWpiC,UAAW,YAAY,SAAmBsU,EAAeC,GAChF,IAAIvB,EACA7T,EAEJ,IAAMqjC,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,GAAK5+B,UAAU1D,OAAS,EAAI,CAC3B,IAAMqO,GAAWuG,GAChB,MAAM,IAAIrR,UAAWiB,EAAQ,qEAAsEoQ,IAE/FA,EAAY,IAChBA,GAAa3D,KAAKgC,SACD,IAChB2B,EAAY,EAGjB,MACGA,EAAY,EAGb,IADAvB,EAAMpC,KAAKiC,QACL1T,EAAIoV,EAAWpV,EAAIyR,KAAKgC,QAASzT,IACtC,GAAK6T,EAAKkvB,GAAU/iC,EAAIoS,EAAmBX,KAAK6xB,SAAYnuB,EAC3D,OAAO,EAGT,OAAO,CACT,IAeCvO,EAAaq8B,EAAWpiC,UAAW,WAAW,SAAkBsU,EAAeC,GAC9E,IAAIvB,EACA7T,EAEJ,IAAMqjC,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,GAAK5+B,UAAU1D,OAAS,EAAI,CAC3B,IAAMqO,GAAWuG,GAChB,MAAM,IAAIrR,UAAWiB,EAAQ,qEAAsEoQ,IAE/FA,EAAY,IAChBA,GAAa3D,KAAKgC,SACD,IAChB2B,EAAY,EAGjB,MACGA,EAAY,EAGb,IADAvB,EAAMpC,KAAKiC,QACL1T,EAAIoV,EAAWpV,EAAIyR,KAAKgC,QAASzT,IACtC,GAAK6T,EAAKkvB,GAAU/iC,EAAIoS,EAAmBX,KAAK6xB,SAAYnuB,EAC3D,OAAOnV,EAGT,OAAQ,CACV,IAcC4G,EAAaq8B,EAAWpiC,UAAW,QAAQ,SAAewU,GACzD,IAAIpV,EACA4T,EACAyB,EACAtV,EAEJ,IAAMqjC,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,GAAK5+B,UAAU1D,OAAS,EAAI,CAC3B,IAAMmP,GAAU0F,GACf,MAAM,IAAItR,UAAWiB,EAAQ,kEAAmEqQ,IAEjGC,EAAMD,CACT,MACGC,EAAM,IAIP,IAFArV,EAAM,GACN4T,EAAMpC,KAAKiC,QACL1T,EAAI,EAAGA,EAAIyR,KAAKgC,QAASzT,IAC9BC,EAAI8E,KAAM8O,EAAKkvB,GAAU/iC,EAAIoS,EAAmBX,KAAK6xB,QAEtD,OAAOrjC,EAAIsV,KAAMD,EACnB,IAeC1O,EAAaq8B,EAAWpiC,UAAW,eAAe,SAAsBsU,EAAeC,GACtF,IAAIvB,EACA7T,EAEJ,IAAMqjC,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAO,IAAO46B,IAEtG,GAAK5+B,UAAU1D,OAAS,EAAI,CAC3B,IAAMqO,GAAWuG,GAChB,MAAM,IAAIrR,UAAWiB,EAAQ,qEAAsEoQ,IAE/FA,GAAa3D,KAAKgC,QACtB2B,EAAY3D,KAAKgC,QAAU,EAChB2B,EAAY,IACvBA,GAAa3D,KAAKgC,QAEtB,MACG2B,EAAY3D,KAAKgC,QAAU,EAG5B,IADAI,EAAMpC,KAAKiC,QACL1T,EAAIoV,EAAWpV,GAAK,EAAGA,IAC5B,GAAK6T,EAAKkvB,GAAU/iC,EAAIoS,EAAmBX,KAAK6xB,SAAYnuB,EAC3D,OAAOnV,EAGT,OAAQ,CACV,IAWCi9B,GAAqBgG,EAAWpiC,UAAW,UAAU,WACpD,OAAO4Q,KAAKgC,OACd,IAeC7M,EAAaq8B,EAAWpiC,UAAW,OAAO,SAAcqU,EAAKZ,GAC5D,IAAIqa,EACA1uB,EACA4T,EACA7T,EACAmJ,EACJ,IAAMk6B,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,IAAM1xB,GAAY8D,GACjB,MAAM,IAAInR,UAAWiB,EAAQ,oEAAqEkQ,IAKnG,IAHArB,EAAMpC,KAAKiC,QAEXib,GADA1uB,EAAM,IAAIwR,KAAK5H,YAAa+4B,GAAgBnxB,KAAK6xB,OAAS7xB,KAAKgC,UACpDC,QACL1T,EAAI,EAAGA,EAAIyR,KAAKgC,QAASzT,IAC9BmJ,EAAI+L,EAAIpT,KAAMwS,EAAST,EAAKkvB,GAAU/iC,EAAIoS,EAAmBX,KAAK6xB,OAAStjC,EAAGyR,MAC9Ekd,EAAMqU,GAAUhjC,EAAIoS,EAAmBjJ,EAAGsI,KAAK6xB,OAEhD,OAAOrjC,CACT,IAeC2G,EAAaq8B,EAAWpiC,UAAW,UAAU,SAAiB6U,EAASC,GACtE,IAAI9B,EACApK,EACAmM,EACA5V,EAEJ,IAAMqjC,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,IAAM1xB,GAAYsE,GACjB,MAAM,IAAI3R,UAAWiB,EAAQ,oEAAqE0Q,IAInG,GAFA7B,EAAMpC,KAAKiC,QACXjK,EAAMgI,KAAKgC,QACNvP,UAAU1D,OAAS,EACvBoV,EAAMD,EACN3V,EAAI,MACE,CACN,GAAa,IAARyJ,EACJ,MAAM,IAAIjI,MAAO,oGAElBoU,EAAM/B,EAAKkvB,GAAU,EAAI3wB,EAAmBX,KAAK6xB,OACjDtjC,EAAI,CACJ,CACD,KAAQA,EAAIyJ,EAAKzJ,IAChB4V,EAAMF,EAASE,EAAK/B,EAAKkvB,GAAU/iC,EAAIoS,EAAmBX,KAAK6xB,OAAStjC,EAAGyR,MAE5E,OAAOmE,CACT,IAeChP,EAAaq8B,EAAWpiC,UAAW,eAAe,SAAsB6U,EAASC,GAChF,IAAI9B,EACApK,EACAmM,EACA5V,EAEJ,IAAMqjC,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,IAAM1xB,GAAYsE,GACjB,MAAM,IAAI3R,UAAWiB,EAAQ,oEAAqE0Q,IAInG,GAFA7B,EAAMpC,KAAKiC,QACXjK,EAAMgI,KAAKgC,QACNvP,UAAU1D,OAAS,EACvBoV,EAAMD,EACN3V,EAAIyJ,EAAM,MACJ,CACN,GAAa,IAARA,EACJ,MAAM,IAAIjI,MAAO,oGAElBoU,EAAM/B,EAAKkvB,IAAYt5B,EAAM,GAAM2I,EAAmBX,KAAK6xB,OAC3DtjC,EAAIyJ,EAAM,CACV,CACD,KAAQzJ,GAAK,EAAGA,IACf4V,EAAMF,EAASE,EAAK/B,EAAKkvB,GAAU/iC,EAAIoS,EAAmBX,KAAK6xB,OAAStjC,EAAGyR,MAE5E,OAAOmE,CACT,IAqCChP,EAAaq8B,EAAWpiC,UAAW,OAAO,SAAchB,GACvD,IAAIiW,EACAxO,EACAuM,EACAW,EACA/N,EACAoP,EACA7V,EACA8D,EACJ,IAAMu/B,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAGpG,GADAjvB,EAAMpC,KAAKiC,QACNxP,UAAU1D,OAAS,GAEvB,IAAM0O,GADN5H,EAAMpD,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,+EAAgFsC,SAG9GA,EAAM,EAEP,GAAKiI,GAAc1P,GAAnB,CAEC,GAAKyH,GADLuO,EAAIhW,EAAMW,QACGiR,KAAKgC,QACjB,MAAM,IAAIO,WAAY,0FAUvB,GANCvN,GAFDqP,EAAOjW,GACG4G,KAAOqP,EAAKpP,IACfgO,EAAgB,WAEhBzM,EAAQ,WAGfnE,EAAI+P,EAAId,WAAczL,EAAI8K,EAEzB0D,EAAKhD,SAAWe,EAAIf,QAEnBgD,EAAK/C,WAAajP,GAClBgS,EAAK/C,WAAW+C,EAAK3B,WAAarQ,EAElC,CAGD,IADA0Q,EAAM,GACAxU,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBwU,EAAIzP,KAAM0B,EAAK5G,EAAOG,IAEvB8V,EAAOtB,EACP/N,EAAMwB,EAAQ,UACd,CACD,IAAMjI,EAAI,EAAGA,EAAI6V,EAAGvO,IAAOtH,IAC1B6T,EAAKmvB,GAAU17B,EAAI8K,EAAmB3L,EAAKqP,EAAM9V,GAAKyR,KAAK6xB,MAG5D,KAhCD,CAiCA,GAAKh8B,GAAOmK,KAAKgC,QAChB,MAAM,IAAIO,WAAYhP,EAAQ,kEAAmEsC,IAElGuM,EAAKmvB,GAAU17B,EAAI8K,EAAmBvS,EAAO4R,KAAK6xB,MAJjD,CAKH,IAeC18B,EAAaq8B,EAAWpiC,UAAW,QAAQ,SAAe2I,EAAW8K,GACpE,IAAIT,EACA7T,EAEJ,IAAMqjC,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,IAAM1xB,GAAY5H,GACjB,MAAM,IAAIzF,UAAWiB,EAAQ,oEAAqEwE,IAGnG,IADAqK,EAAMpC,KAAKiC,QACL1T,EAAI,EAAGA,EAAIyR,KAAKgC,QAASzT,IAC9B,GAAKwJ,EAAU1H,KAAMwS,EAAST,EAAKkvB,GAAU/iC,EAAIoS,EAAmBX,KAAK6xB,OAAStjC,EAAGyR,MACpF,OAAO,EAGT,OAAO,CACT,IAYC7K,EAAaq8B,EAAWpiC,UAAW,YAAY,WAC9C,IAAIZ,EACA4T,EACA7T,EACJ,IAAMqjC,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAIpG,IAFA7iC,EAAM,GACN4T,EAAMpC,KAAKiC,QACL1T,EAAI,EAAGA,EAAIyR,KAAKgC,QAASzT,IAC9BC,EAAI8E,KAAM8O,EAAKkvB,GAAU/iC,EAAEoS,EAAmBX,KAAK6xB,QAEpD,OAAOrjC,EAAIsV,KAAM,IACnB,IAgBC3O,EAAaq8B,EAAWpiC,UAAW,QAAQ,SAAmB4V,EAAO5W,GACpE,IACIgU,EACA5T,EACAwJ,EAEJ,IAAM45B,EAAc5xB,MACnB,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAEpG,IAAMj0B,GAAW4H,GAChB,MAAM,IAAI1S,UAAWiB,EAAQ,oEAAqEyR,IAOnG,GALAhN,EAAMgI,KAAKgC,QACXI,EAAMpC,KAAKiC,QACN+C,EAAQ,IACZA,GAAShN,GAELgN,EAAQ,GAAKA,GAAShN,EAC1B,MAAM,IAAIuK,WAAYhP,EAAQ,kEAAmEyR,IAKlG,OAHAxW,EAAM,IAAIwR,KAAK5H,YAAa+4B,GAAgBnxB,KAAK6xB,OAASzvB,EAAIf,SACjDY,QACLsvB,GAAUvsB,EAAQrE,EAAmBvS,EAAO4R,KAAK6xB,OAClDrjC,CACT,IAEQgjC,EASP,SAASG,EAAyBvjC,GACjC,OAASA,IAAUojC,CACnB,CASD,SAASI,EAAcxjC,GACtB,MACkB,iBAAVA,GACG,OAAVA,IAECA,EAAMgK,YAAYK,OAAS44B,GHnnC/B,SAAwBjjC,EAAOqf,GAC9B,IAAI/N,SAAc+N,EAClB,GACW,OAAVA,GACU,WAAT/N,GAA8B,aAATA,EAEtB,MAAM,IAAIpN,UAAWiB,EAAQ,uGAAwGka,IAGtI,OADA/N,SAActR,EAEH,OAAVA,IACU,WAATsR,GAA8B,aAATA,IAIhBgxB,GAAUrgC,KAAMod,EAAOrf,EAC/B,CGomCIyf,CAAezf,EAAOojC,EAAWpiC,aAElChB,EAAMuS,oBAAsBA,CAE7B,CAWD,SAAS2B,EAAWyX,EAAMnkB,EAAKw7B,GAC9B,IAAIp5B,EACAhD,EACAzG,EAQJ,IANAyJ,EAAMpC,EAAI7G,OAETiG,EADIY,EAAIZ,KAAOY,EAAIX,IACbgO,EAAgB,WAEhBzM,EAAQ,WAETjI,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrBwrB,EAAMwX,GAAUhjC,EAAEoS,EAAmB3L,EAAKY,EAAKrH,GAAK6iC,GAErD,OAAOrX,CACP,CACF,CG1mCA,IAAI+X,GAAiBnrB,GAAS,WCA1BorB,GAAiBprB,GAAS,WCvE9B,IAAI/N,GAAc,CACjB2H,UAAa,YACbV,WAAc,cCIX+H,GAAQ,CACX/Q,UAAa0J,GACb3J,WAAciJ,ICUf,SAAS+H,GAAOnR,GACf,OAAOmmB,GAAOnmB,IAAW,IAC1B,CChBA,ICEIlI,GDFAiX,8BEUWpS,QDTXmS,GAAQ,GAEZ,IAAMhX,GAAI,EAAGA,GAAIiX,GAAOzW,OAAQR,KAC/BgX,GAAMjS,KAAMsU,GAAOpC,GAAQjX,MED5B,IAAIkX,GAASD,GAAOzW,OAoBpB,SAAS0H,GAAOrI,GACf,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAIkX,GAAQlX,IACxB,GAAKH,aAAiBmX,GAAOhX,GAC5B,OAAOiX,GAAQjX,GAIjB,OAAOmX,GAAYlN,GAAiBpK,KAAa,IAClD,CCvBA,IAAI4jC,GAAetM,GAAS1wB,IAAK,8BAC7Bi9B,GAAgBvM,GAAS1wB,IAAK,iCAC9Bk9B,GAAexM,GAAS1wB,IAAK,kBA+BjC,SAASm9B,GAAc/jC,GACtB,IAAI4U,EACAxU,EAEAoX,EACAlO,EA+BJ,OA7BAsL,EAAM7U,GAAUC,GACXqE,UAAU1D,OAAS,EAClBiU,EACJ4C,EAAKosB,GACM1zB,GAAWlQ,GACtBwX,EAAKssB,GACMzxB,GAAerS,GAEd,QADZwX,EAAKnP,GAAOrI,MAEXwX,EAAKqsB,IAGNrsB,EAAK,UAGNA,EAAKnT,UAAW,GAEjBjE,EAAMH,GAAO,EAAGuX,GAEflO,EADIsL,GAAO0a,GAAmB9X,GAC1B,CAAExX,EAAO,GAETA,GAEAqH,EAAiBjH,GACfsX,EAAgBF,GAEhBjP,EAAQiP,IAEVpX,EAAK,EAAGkJ,GACNlJ,CACR,CC1EA,IAAI+3B,GAAgBb,GAAS1wB,IAAK,kBAuBlC,SAASo9B,GAAMrjC,EAAQX,GACtB,IAAIqI,EACAiC,EACAlK,EACJ,IAAMiP,GAAsB1O,GAC3B,MAAM,IAAIuD,UAAWiB,EAAQ,+EAAgFxE,IAO9G,GAAe,aAJd0H,EADIhE,UAAU1D,OAAS,EACf0D,UAAW,GAEX8zB,IAGR,OAAO8L,GAAOjkC,EAAOW,GAGtB,GAAc,QADd2J,EAAOkP,GAAOnR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,gFAAiFkD,IAO/G,OAFA45B,GAAOthC,EAAQX,EAHfI,EAAM,IAAIkK,EAAM3J,GAGW,GAEpBP,CACR,CCvDA,SAAS8jC,KAET,CCGA,IAAIC,GCOmB,QAAbD,GAAI75B,KCFd,IAAI8M,GAAQ,CACXzM,GACAD,GACAG,GACAG,GACAJ,GACAG,GACAD,GACAG,GACAC,0ICVGm4B,GAAe93B,KAA6B8T,GAAgB1U,IAAiB05B,GAajF,SAASA,KAAU,CAVnBhB,GAAyC,eHqBzC,SAAuB/tB,GAEtB,IAA2B,IAAtB9D,GAAY8D,GAChB,MAAM,IAAInR,UAAWiB,EAAQ,0DAA2DkQ,IAEzF,OAAK8uB,GACG9uB,EAAIhL,KAEL5F,GAAGM,KAAMsQ,EAAIzT,YAAc,EACnC,CG9BeyiC,CAASjB,IAAkCA,GAAagB,GCTvE,IAAIjtB,GAAQ,CACXhM,GACAD,4CCcD,SAAS4L,GAAgB9W,GACxB,OACCA,aAAiBoL,IACY,iBAA7BhB,GAAiBpK,EAEnB,CCMA,SAASskC,GAAYtkC,EAAOgK,GAE3B,GAA4B,mBAAhBA,EACX,MAAM,IAAI9F,UAAWiB,EAAQ,mEAAoE6E,IAElG,OAAShK,aAAiBgK,CAC3B,CCvBA,IAAImN,GAAQ,CACX,CAAEzM,GAAc,gBAChB,CAAED,GAAc,gBAChB,CAAEG,GAAY,cACd,CAAEG,GAAa,eACf,CAAEJ,GAAY,cACd,CAAEG,GAAa,eACf,CAAED,GAAW,aACb,CAAEG,GAAY,cACd,CAAEC,GAAmB,qBACrB,CAAEC,GAAgB,kBAClB,CAAEC,GAAiB,mBACnB,CAAEC,GAAc,iBCNjB,SAASm5B,GAAU/8B,GAClB,IAAI8B,EACAnJ,EAGJ,IAAMA,EAAI,EAAGA,EAAIgX,GAAMxW,OAAQR,IAC9B,GAAKmkC,GAAY98B,EAAK2P,GAAOhX,GAAK,IACjC,OAAOgX,GAAOhX,GAAK,GAIrB,KAAQqH,GAAM,CAEb,IADA8B,EAAI+H,GAAU7J,GACRrH,EAAI,EAAGA,EAAIgX,GAAMxW,OAAQR,IAC9B,GAAKmJ,IAAM6N,GAAOhX,GAAK,GACtB,OAAOgX,GAAOhX,GAAK,GAGrBqH,EAAM4X,GAAgB5X,EACtB,CACF,CCVA,SAASg9B,GAAiBh9B,GACzB,IAAIyQ,EACA7X,EACAD,EAEJ,GNKD,SAAuBH,GACtB,IAAIsJ,EACAnJ,EAEJ,GAAsB,iBAAVH,GAAgC,OAAVA,EACjC,OAAO,EAGR,GAAKA,aAAiBojC,GACrB,OAAO,EAGR,IAAMjjC,EAAI,EAAGA,EAAIgX,GAAMxW,OAAQR,IAC9B,GAAKH,aAAiBmX,GAAOhX,GAC5B,OAAO,EAIT,KAAQH,GAAQ,CAEf,IADAsJ,EAAI+H,GAAUrR,GACRG,EAAI,EAAGA,EAAIskC,GAAM9jC,OAAQR,IAC9B,GAAKskC,GAAOtkC,KAAQmJ,EACnB,OAAO,EAGTtJ,EAAQof,GAAgBpf,EACxB,CAED,OAAO,CACR,CMlCMwjC,CAAch8B,GAClByQ,EAAOzQ,OACD,GCnBR,SAA8BxH,GAC7B,IAAIsJ,EACAnJ,EAEJ,GAAsB,iBAAVH,GAAgC,OAAVA,EACjC,OAAO,EAGR,IAAMG,EAAI,EAAGA,EAAIgX,GAAMxW,OAAQR,IAC9B,GAAKH,aAAiBmX,GAAOhX,GAC5B,OAAO,EAIT,KAAQH,GAAQ,CAEf,IADAsJ,EAAI+H,GAAUrR,GACRG,EAAI,EAAGA,EAAIskC,GAAM9jC,OAAQR,IAC9B,GAAKskC,GAAOtkC,KAAQmJ,EACnB,OAAO,EAGTtJ,EAAQof,GAAgBpf,EACxB,CAED,OAAO,CACR,CDNakd,CAAqB1V,GAE/ByQ,EAD8B,IAA1BzQ,EAAI+K,kBACD6B,GAAe5M,EAAK,GAEpB6M,GAAgB7M,EAAK,OAEvB,KAAKsP,GAAgBtP,GAG3B,MAAM,IAAItD,UAAWiB,EAAQ,6DAA8DqC,IAF3FyQ,EAAOiL,GAAoB1b,EAAK,EAGhC,CAKD,IAJApH,EAAM,CACLkR,KAAQizB,GAAU/8B,GAClByQ,KAAQ,IAEH9X,EAAI,EAAGA,EAAI8X,EAAKtX,OAAQR,IAC7BC,EAAI6X,KAAK/S,KAAM+S,EAAM9X,IAEtB,OAAOC,CACR,CEzCA,SAASskC,GAAM1kC,GA0Bd,OAxBAF,EAAgB8R,KAAM,OAAQ,CAC7B5K,cAAgB,EAChBC,YAAc,EACdL,IAAO,WACN,OAAOgL,KAAK+yB,KACZ,IAEF/yB,KAAK5R,MAAQA,EAEbF,EAAgB8R,KAAM,QAAS,CAC9B5K,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAAS,OAIVF,EAAgB8R,KAAM,QAAS,CAC9B5K,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAAS,OAGH4R,IACR,CCXA,SAASgzB,KACR,OAAOhzB,gBAAgBgzB,IAGvBhzB,KAAKgC,QAAU,EACfhC,KAAKizB,OAAS,KACdjzB,KAAKkzB,MAAQ,KACNlzB,MALC,IAAIgzB,EAMb,CAmCWz9B,EAAEy9B,GAAW5jC,UAAW,SAAS,WAI3C,OAHA4Q,KAAKgC,QAAU,EACfhC,KAAKizB,OAAS,KACdjzB,KAAKkzB,MAAQ,KACNlzB,IACR,IAoBWzK,EAAEy9B,GAAW5jC,UAAW,SAAS,WAC3C,GAAK4Q,KAAKgC,QACT,OAAOhC,KAAKizB,MAEd,IAiCA99B,EAAa69B,GAAW5jC,UAAW,UAAU,SAAiB+jC,EAAM/kC,GAEnE,IAAIE,EAGJ,GAAK6kC,IAASnzB,KAAKkzB,MAClB,OAAOlzB,KAAK1M,KAAMlF,GAInB,IADAE,EAAI0R,KAAKizB,OACD3kC,IAAM0R,KAAKkzB,OAAS5kC,IAAM6kC,GACjC7kC,EAAIA,EAAEykC,MAGP,GAAKzkC,IAAM0R,KAAKkzB,MACf,MAAM,IAAInjC,MAAO,uEAelB,OAZAzB,EAAI,IAAIwkC,GAAM1kC,GAGd+kC,EAAKJ,MAAMK,MAAQ9kC,EACnBA,EAAEykC,MAAQI,EAAKJ,MAEfI,EAAKJ,MAAQzkC,EACbA,EAAE8kC,MAAQD,EAGVnzB,KAAKgC,SAAW,EAEThC,IAGR,IAiCWzK,EAAEy9B,GAAW5jC,UAAW,YAAY,WAC9C,IAAI2V,EACAzB,EACA7E,EACA3H,EACAvI,EAiBJ,OAfAkQ,EAAOuB,KAGPzR,GAAK,EAGLwW,EAAS/E,KAAKqzB,UAIdl+B,EADAmO,EAAO,CAAA,EACY,QAanB,WAEC,GADA/U,GAAK,EACAuI,GAAOvI,GAAKwW,EAAOhW,OACvB,MAAO,CACN4S,MAAQ,GAGV,MAAO,CACNvT,MAAS2W,EAAQxW,GACjBoT,MAAQ,EAET,IAvBDxM,EAAamO,EAAM,UAgCnB,SAAclV,GAEb,GADA0I,GAAM,EACDrE,UAAU1D,OACd,MAAO,CACNX,MAASA,EACTuT,MAAQ,GAGV,MAAO,CACNA,MAAQ,EAET,IA1CI2xB,IACJn+B,EAAamO,EAAMgwB,IAiDpB,WACC,OAAO70B,EAAKsC,UACZ,IAjDMuC,CAkDR,IAoBW/N,EAAEy9B,GAAW5jC,UAAW,QAAQ,WAC1C,GAAK4Q,KAAKgC,QACT,OAAOhC,KAAKkzB,KAEd,IAuBmBjyB,GAAE+xB,GAAW5jC,UAAW,UAAU,WACpD,OAAO4Q,KAAKgC,OACb,IA2BWzM,EAAEy9B,GAAW5jC,UAAW,OAAO,WAEzC,IAAIhB,EAiBJ,OAhBK4R,KAAKgC,UAET5T,EAAQ4R,KAAKkzB,MAAM9kC,MAGd4R,KAAKkzB,MAAME,OACfpzB,KAAKkzB,MAAQlzB,KAAKkzB,MAAME,MACxBpzB,KAAKkzB,MAAMH,MAAQ,OAGnB/yB,KAAKizB,OAAS,KACdjzB,KAAKkzB,MAAQ,MAGdlzB,KAAKgC,SAAW,GAEV5T,CAGR,IA2BWmH,EAAEy9B,GAAW5jC,UAAW,QAAQ,SAAehB,GACzD,IAAI+kC,EAuBJ,OApBAA,EAAO,IAAIL,GAAM1kC,GAGK,IAAjB4R,KAAKgC,SAEThC,KAAKizB,OAASE,EACdnzB,KAAKkzB,MAAQC,IAGbA,EAAKC,MAAQpzB,KAAKkzB,MAGlBlzB,KAAKkzB,MAAMH,MAAQI,EAGnBnzB,KAAKkzB,MAAQC,GAGdnzB,KAAKgC,SAAW,EAEThC,IACR,IAiCWzK,EAAEy9B,GAAW5jC,UAAW,UAAU,SAAiB+jC,GAE7D,IAAI/kC,EACAE,EAGJ,GAAK6kC,IAASnzB,KAAKizB,OAClB,OAAOjzB,KAAKuzB,QAGb,GAAKJ,IAASnzB,KAAKkzB,MAClB,OAAOlzB,KAAKwzB,MAOb,IAJAplC,EAAQ+kC,EAAK/kC,MAGbE,EAAI0R,KAAKizB,OACD3kC,IAAM0R,KAAKkzB,OAAS5kC,IAAM6kC,GACjC7kC,EAAIA,EAAEykC,MAGP,GAAKzkC,IAAM0R,KAAKkzB,MACf,MAAM,IAAInjC,MAAO,uEASlB,OANAojC,EAAKC,MAAML,MAAQI,EAAKJ,MACxBI,EAAKJ,MAAMK,MAAQD,EAAKC,MAGxBpzB,KAAKgC,SAAW,EAET5T,CAGR,IA2BWmH,EAAEy9B,GAAW5jC,UAAW,SAAS,WAE3C,IAAIhB,EAiBJ,OAhBK4R,KAAKgC,UAET5T,EAAQ4R,KAAKizB,OAAO7kC,MAGf4R,KAAKizB,OAAOF,OAChB/yB,KAAKizB,OAASjzB,KAAKizB,OAAOF,MAC1B/yB,KAAKizB,OAAOG,MAAQ,OAGpBpzB,KAAKizB,OAAS,KACdjzB,KAAKkzB,MAAQ,MAGdlzB,KAAKgC,SAAW,GAEV5T,CAGR,IAoBWmH,EAAEy9B,GAAW5jC,UAAW,WAAW,WAC7C,IAAI+jC,EACA3kC,EACAD,EAIJ,IAFAC,EAAM,GACN2kC,EAAOnzB,KAAKizB,OACN1kC,EAAI,EAAGA,EAAIyR,KAAKgC,QAASzT,IAC9BC,EAAI8E,KAAM6/B,EAAK/kC,OACf+kC,EAAOA,EAAKzxB,KAEb,OAAOlT,CACR,IAwBW+G,EAAEy9B,GAAW5jC,UAAW,UAAU,WAC5C,IAAIZ,EAAM,CACVA,KAAW,eAEX,OADAA,EAAI6X,KAAOrG,KAAKqzB,UACT7kC,CACR,IA2BW+G,EAAEy9B,GAAW5jC,UAAW,WAAW,SAAkBhB,GAC/D,IAAI+kC,EAuBJ,OApBAA,EAAO,IAAIL,GAAM1kC,GAGK,IAAjB4R,KAAKgC,SAEThC,KAAKizB,OAASE,EACdnzB,KAAKkzB,MAAQC,IAGbA,EAAKJ,MAAQ/yB,KAAKizB,OAGlBjzB,KAAKizB,OAAOG,MAAQD,EAGpBnzB,KAAKizB,OAASE,GAGfnzB,KAAKgC,SAAW,EAEThC,IACR,ICpoBA,IAAIyzB,GAAQ,IAAIT,GCAhB,SAASU,GAAMC,GAEd,IADA,IAAIR,EAAOM,GAAMG,QACTT,GAAO,CACd,GAAKA,EAAK/kC,MAAMulC,KAAOA,EACtB,OAAOR,EAERA,EAAOA,EAAKzxB,IACZ,CACD,OAAO,IACR,CCrBA,IAAImyB,IAAW,EC4Cf,SAASC,GAAYz2B,GACpB,IAAIuH,EACAtQ,EAEAsR,EACAoJ,EACAtX,EACJ,KAAOsI,gBAAgB8zB,IACtB,OAAKrhC,UAAU1D,OAAS,EAChB,IAAI+kC,GAAYz2B,EAAG5K,UAAW,IAE/B,IAAIqhC,GAAYz2B,GAExB,IAAMS,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,8EAA+E8J,IAK7G,GAAY,aAHZuI,EAAKnP,GAAO4G,KAGoB,OAAPuI,EACxB,GAAKvI,EAAEtO,OAAS,EAKf,GAAKuP,GAHL5G,EADM8O,GAAenJ,EACjBrI,CAAKqI,EAAG,IAIX2R,EAAI,WACE,KAAK5R,GAAW1F,GAGtB,MAAM,IAAIpF,UAAW,iEAFrB0c,EAAI,KAGJ,MAEDA,EAAI,WAEC,GAAY,UAAPpJ,EACXoJ,EAAI,WACE,GAAY,UAAPpJ,EACXoJ,EAAI,WACE,IAAY,SAAPpJ,EAGX,MAAM,IAAItT,UAAW,iEAFrB0c,EAAI,MAGJ,CAGD,GADApK,EC9EO,CACNmvB,SAAW,GD8EPthC,UAAU1D,OAAS,IACvBuF,EEhEF,SAAmBsQ,EAAMD,GACxB,OAAM3H,GAAU2H,GAGXvN,GAAYuN,EAAS,aACzBC,EAAKmvB,QAAUpvB,EAAQovB,SACjBz1B,GAAWsG,EAAKmvB,UACd,IAAIzhC,UAAWiB,EAAQ,+DAAgE,UAAWqR,EAAKmvB,UAGzG,KARC,IAAIzhC,UAAWiB,EAAQ,qEAAsEoR,GAStG,CFqDQqvB,CAAUpvB,EAAMnS,UAAW,IAC5B6B,GACJ,MAAMA,EAmBR,OAfAm/B,GAAMngC,KAAK,CACVqgC,IDlFDE,IAAW,GACI7jC,WCkFdsiB,IAAOtS,KACPqG,KAAQhJ,EACRqC,KAAQsP,EACRvY,MAASmP,EACTmuB,QAAWnvB,EAAKmvB,UAIjB5+B,EAAa6K,KAAM,QAASyzB,GAAMQ,QAGlCtH,GAAkB3sB,KAAM,gBAAgB,GAEjCA,IACR,CAeA7K,EAAa2+B,GAAY,OAAQ,cAwBtBv+B,EAAEu+B,GAAY,QAAQ,SAAeH,GAC/C,IAAIR,EACAz7B,EAIJ,OAAc,QADdy7B,EAAOe,GAAgBP,MAOvBx+B,GAHAuC,EAAIy7B,EAAK/kC,OAGMkkB,IAAK,gBAAgB,GAGpCmhB,GAAMU,OAAQhB,GAGdz7B,EAAE2O,KAAO,MAEF,EACR,IAiCW9Q,EAAEu+B,GAAY,OAAO,SAAcH,GAC7C,IAAIR,EACA3kC,EACAkJ,EAIJ,OAAc,QADdy7B,EAAOe,GAAgBP,IAEf,MAKRnlC,EAAM,CACL6X,MAJD3O,EAAIy7B,EAAK/kC,OAIEiY,KACV3G,KAAQhI,EAAEgI,KACVjJ,MAASiB,EAAEjB,OAINiB,EAAEq8B,SACPD,GAAWM,KAAMT,GAEXnlC,EACR,IAoBmByS,GAAE6yB,GAAW1kC,UAAW,QAAQ,WAClD,GAAK4Q,KAAKq0B,aACT,MAAM,IAAItkC,MAAO,kGAElB,OAAOiQ,KAAKs0B,MAAMlmC,MAAMiY,IACzB,IAoBmBpF,GAAE6yB,GAAW1kC,UAAW,SAAS,WACnD,GAAK4Q,KAAKq0B,aACT,MAAM,IAAItkC,MAAO,kGAElB,OAAOiQ,KAAKs0B,MAAMlmC,MAAMqI,KACzB,IAoBmBwK,GAAE6yB,GAAW1kC,UAAW,MAAM,WAChD,GAAK4Q,KAAKq0B,aACT,MAAM,IAAItkC,MAAO,kGAElB,OAAOiQ,KAAKs0B,MAAMlmC,MAAMulC,EACzB,IAmBmB1yB,GAAE6yB,GAAW1kC,UAAW,YAAY,WACtD,OAAQ4Q,KAAKq0B,YACd,IAoBmBpzB,GAAE6yB,GAAW1kC,UAAW,QAAQ,WAClD,GAAK4Q,KAAKq0B,aACT,MAAM,IAAItkC,MAAO,kGAElB,OAAOiQ,KAAKs0B,MAAMlmC,MAAMsR,IACzB,IAoBWnK,EAAEu+B,GAAW1kC,UAAW,YAAY,WAE9C,GAAK4Q,KAAKq0B,aACT,MAAM,IAAItkC,MAAO,kGAGlB,MAAO,cADHiQ,KAAKs0B,MAAMlmC,MACUulC,GAAK,GAC/B,IAwBWp+B,EAAEu+B,GAAW1kC,UAAW,UAAU,WAC5C,IAAIsI,EAEJ,GAAKsI,KAAKq0B,aACT,MAAM,IAAItkC,MAAO,kGAYlB,MAAO,CACN2P,KAAQ,aACR2G,KAXgB,aADjB3O,EAAIsI,KAAKs0B,MAAMlmC,OACRqI,OAAmC,OAAZiB,EAAEjB,MAC1BhB,EAAiBiC,EAAE2O,MACnB2L,GAAMta,EAAE2O,MAER3O,EAAE2O,KAGHkuB,GAAY78B,EAAE2O,MAMpB,IG7ZA,IAAIuB,GAAQ,CACXjS,QAAWmD,GACXhD,QAAW+C,GACXjC,WAAc2C,GACd1C,UAAayC,ICMd,SAASsO,GAAOnR,GACf,OAAOmmB,GAAOnmB,IAAW,IAC1B,CCIA,SAAS+9B,GAAUhmC,EAAK4U,EAAO6X,EAAMjjB,EAAKy8B,GACzC,IAAIrwB,EACA2N,EACAxjB,EAEJ,GAAa,IAARyJ,EACJ,OAAOxJ,EAGR,GAAa,IAARwJ,EAMJ,OAJCxJ,EAAK,GADDimC,EACOxZ,EAEA7X,EAEL5U,EAaR,IAXAA,EAAK,GAAM4U,EAQX2O,GAAMkJ,EAAK7X,IAJVgB,EADIqwB,EACAz8B,EAAM,EAENA,GAKCzJ,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBC,EAAKD,GAAM6U,EAAS2O,EAAExjB,EAMvB,OAHKkmC,IACJjmC,EAAK4V,GAAM6W,GAELzsB,CACR,CCxCA,SAASgmC,GAAUhmC,EAAK8gB,EAAKlM,EAAOmM,EAAK0L,EAAMjjB,EAAKy8B,GACnD,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA3wB,EACA7V,EACA8D,EAEJ,GAAa,IAAR2F,EACJ,OAAOxJ,EAuBR,GArBa,YAAR8gB,GACJolB,EAAMtxB,EACNwxB,EAAM,GACa,cAARtlB,GACXolB,EAAM9yB,GAAOwB,GACbwxB,EAAM/yB,GAAOuB,KAEbsxB,EAAM50B,GAAMsD,GACZwxB,EAAM70B,GAAMqD,IAEA,YAARmM,GACJolB,EAAM1Z,EACN4Z,EAAM,GACa,cAARtlB,GACXolB,EAAM/yB,GAAOqZ,GACb4Z,EAAMhzB,GAAOoZ,KAEb0Z,EAAM70B,GAAMmb,GACZ4Z,EAAM90B,GAAMkb,IAGA,IAARjjB,EAQJ,OAPKy8B,GACJjmC,EAAK,GAAMmmC,EACXnmC,EAAK,GAAMqmC,IAEXrmC,EAAK,GAAMkmC,EACXlmC,EAAK,GAAMomC,GAELpmC,EAgBR,IAdAA,EAAK,GAAMkmC,EACXlmC,EAAK,GAAMomC,EAQXE,GAAOH,EAAID,IAJVtwB,EADIqwB,EACAz8B,EAAM,EAENA,GAGL+8B,GAAOF,EAAID,GAAQxwB,EAGnB/R,EAAI,EACE9D,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBC,EAAK6D,GAAMqiC,EAAOI,EAAGvmC,EACrBC,EAAK6D,EAAE,GAAMuiC,EAAOG,EAAGxmC,EACvB8D,GAAK,EAON,OAJKoiC,IACJjmC,EAAK6D,GAAMsiC,EACXnmC,EAAK6D,EAAE,GAAMwiC,GAEPrmC,CACR,CC9DA,SAASwlC,GAAUpvB,EAAMD,GACxB,OAAM3H,GAAU2H,GAGXvN,GAAYuN,EAAS,WACzBC,EAAKnO,MAAQkO,EAAQlO,OACfyH,GAAU0G,EAAKnO,QACb,IAAInE,UAAWiB,EAAQ,8DAA+D,QAASqR,EAAKnO,QAGxGW,GAAYuN,EAAS,cACzBC,EAAK6vB,SAAW9vB,EAAQ8vB,UAClBn2B,GAAWsG,EAAK6vB,WACd,IAAIniC,UAAWiB,EAAQ,+DAAgE,WAAYqR,EAAK6vB,WAG1G,KAdC,IAAIniC,UAAWiB,EAAQ,qEAAsEoR,GAetG,WC1BIqwB,GAAwB3O,GAASrxB,IAAK,iCA6B1C,SAASw/B,GAAUpxB,EAAO6X,EAAMjjB,GAC/B,IAAI4M,EACAlM,EACApE,EACA9F,EACA8gB,EACAC,EACAvM,EAEJ,GAAsB,iBAAVI,EAAqB,CAEhC,GAAa,QADbkM,EAAM7Y,GAAO2M,IACO,CACnB,IAAM3C,GAAe2C,GACpB,MAAM,IAAI9Q,UAAWiB,EAAQ,yFAA0F6P,IAExHkM,EAAM,YACN,CACDtM,GAAM,CACR,KAAQ,KAAM7U,GAAUiV,IAAWzR,GAAOyR,GACxC,MAAM,IAAI9Q,UAAWiB,EAAQ,yFAA0F6P,IAEvHkM,EAAM,SACN,CACD,GAAqB,iBAAT2L,EAAoB,CAE/B,GAAa,QADb1L,EAAM9Y,GAAOwkB,IACO,CACnB,IAAMxa,GAAewa,GACpB,MAAM,IAAI3oB,UAAWiB,EAAQ,0FAA2F0nB,IAEzH1L,EAAM,YACN,CACDvM,GAAM,CACR,KAAQ,KAAM7U,GAAU8sB,IAAUtpB,GAAOspB,GACvC,MAAM,IAAI3oB,UAAWiB,EAAQ,0FAA2F0nB,IAExH1L,EAAM,SACN,CACD,IAAM9R,GAAsBzF,GAC3B,MAAM,IAAI1F,UAAWiB,EAAQ,+EAAgFyE,IAW9G,IATA4M,EAAO,CACN6vB,SAAY/O,KAGPjvB,MADD6Y,IAAQC,EACCD,EAGA0lB,GAETviC,UAAU1D,OAAS,IACvBuF,EAAM0/B,GAAUpvB,EAAMnS,UAAW,KAEhC,MAAM6B,EAGR,GAAoB,YAAfsQ,EAAKnO,MACT,OAAKuM,ECnFP,SAAmBsM,EAAKlM,EAAOmM,EAAK0L,EAAMjjB,EAAKy8B,GAC9C,IAAIQ,EACAC,EACAt/B,EACA8+B,EACAC,EACAC,EACAC,EACA50B,EACAC,EACA40B,EACAC,EACA3wB,EACA7V,EAEJ,GAAa,IAARyJ,EACJ,MAAO,GAgCR,GA9BAk9B,EAAQ,EACK,YAAR5lB,GACJolB,EAAMtxB,EACNwxB,EAAM,GACa,cAARtlB,GACX4lB,GAAS,EACTR,EAAM9yB,GAAOwB,GACbwxB,EAAM/yB,GAAOuB,KAEbsxB,EAAM50B,GAAMsD,GACZwxB,EAAM70B,GAAMqD,IAEA,YAARmM,GACJolB,EAAM1Z,EACN4Z,EAAM,GACa,cAARtlB,GACX2lB,GAAS,EACTP,EAAM/yB,GAAOqZ,GACb4Z,EAAMhzB,GAAOoZ,KAEb0Z,EAAM70B,GAAMmb,GACZ4Z,EAAM90B,GAAMkb,IAIZga,EADc,IAAVC,EACI30B,GAEAV,GAGI,IAAR7H,EACJ,OAAKy8B,EACG,CAAE,IAAIQ,EAAON,EAAKE,IAEnB,CAAE,IAAII,EAAOP,EAAKE,IAc1B,IAZAh/B,EAAM,CAAE,IAAIq/B,EAAOP,EAAKE,IAQxBE,GAAOH,EAAID,IAJVtwB,EADIqwB,EACAz8B,EAAM,EAENA,GAGL+8B,GAAOF,EAAID,GAAQxwB,EAGb7V,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB0R,EAAKy0B,EAAOI,EAAGvmC,EACf2R,EAAK00B,EAAOG,EAAGxmC,EACfqH,EAAItC,KAAM,IAAI2hC,EAAOh1B,EAAIC,IAM1B,OAHKu0B,GACJ7+B,EAAItC,KAAM,IAAI2hC,EAAON,EAAKE,IAEpBj/B,CACR,CDQUu/B,CAAU7lB,EAAKlM,EAAOmM,EAAK0L,EAAMjjB,EAAK4M,EAAK6vB,UExFrD,SAAmBrxB,EAAO6X,EAAMjjB,EAAKy8B,GACpC,IAAI7+B,EACAwO,EACA2N,EACAxjB,EAEJ,GAAa,IAARyJ,EACJ,MAAO,GAGR,GAAa,IAARA,EACJ,OAAKy8B,EACG,CAAExZ,GAEH,CAAE7X,GAaV,IAXAxN,EAAM,CAAEwN,GAQR2O,GAAMkJ,EAAK7X,IAJVgB,EADIqwB,EACAz8B,EAAM,EAENA,GAKCzJ,EAAI,EAAGA,EAAI6V,EAAG7V,IACnBqH,EAAItC,KAAM8P,EAAS2O,EAAExjB,GAMtB,OAHKkmC,GACJ7+B,EAAItC,KAAM2nB,GAEJrlB,CACR,CFuDSw/B,CAAShyB,EAAO6X,EAAMjjB,EAAK4M,EAAK6vB,UAGxC,GAAc,QADd/7B,EAAOkP,GAAOhD,EAAKnO,QAElB,MAAM,IAAInE,UAAWiB,EAAQ,6GAA8G,QAASqR,EAAKnO,QAG1J,GADAjI,EAAM,IAAIkK,EAAMV,GACI,cAAf4M,EAAKnO,MAET,OADA4+B,GAAY7yB,GAAehU,EAAK,GAAK8gB,EAAKlM,EAAOmM,EAAK0L,EAAMjjB,EAAK4M,EAAK6vB,UAC/DjmC,EAER,GAAoB,eAAfoW,EAAKnO,MAET,OADA4+B,GAAY5yB,GAAgBjU,EAAK,GAAK8gB,EAAKlM,EAAOmM,EAAK0L,EAAMjjB,EAAK4M,EAAK6vB,UAChEjmC,EAER,GAAKwU,EACJ,MAAM,IAAI1Q,UAAW,4JAEtB,OAAOgjC,GAAW9mC,EAAK4U,EAAO6X,EAAMjjB,EAAK4M,EAAK6vB,SAC/C,CG1GA,SAAST,GAAU5lC,GAClB,IAAIsR,SAActR,EAClB,OACW,OAAVA,GACU,WAATsR,GAA8B,aAATA,EAEf,IAAIpN,UAAWiB,EAAQ,8GAA+GnF,IAEvI,IACR,CCqBA+G,EAAAnH,GAAA,UCRA,SAAmBoV,EAAO6X,EAAMzsB,GAC/B,IAAIoW,EACAtQ,EACAgb,EACAC,EACAvM,EACAuyB,EACAvvB,EAEJ,GAAsB,iBAAV5C,EAAqB,CAEhC,GAAa,QADbkM,EAAM7Y,GAAO2M,IACO,CACnB,IAAM3C,GAAe2C,GACpB,MAAM,IAAI9Q,UAAWiB,EAAQ,yFAA0F6P,IAExHkM,EAAM,YACN,CACDtM,GAAM,CACR,KAAQ,KAAM7U,GAAUiV,IAAWzR,GAAOyR,GACxC,MAAM,IAAI9Q,UAAWiB,EAAQ,yFAA0F6P,IAEvHkM,EAAM,SACN,CACD,GAAqB,iBAAT2L,EAAoB,CAE/B,GAAa,QADb1L,EAAM9Y,GAAOwkB,IACO,CACnB,IAAMxa,GAAewa,GACpB,MAAM,IAAI3oB,UAAWiB,EAAQ,0FAA2F0nB,IAEzH1L,EAAM,YACN,CACDvM,GAAM,CACR,KAAQ,KAAM7U,GAAU8sB,IAAUtpB,GAAOspB,GACvC,MAAM,IAAI3oB,UAAWiB,EAAQ,0FAA2F0nB,IAExH1L,EAAM,SACN,CACD,IAAMzR,GAActP,GACnB,MAAM,IAAI8D,UAAWiB,EAAQ,8EAA+E/E,IAK7G,GAHAoW,EAAO,CACN6vB,SAAY/O,IAERjzB,UAAU1D,OAAS,IACvBuF,EAAM0/B,GAAUpvB,EAAMnS,UAAW,KAEhC,MAAM6B,EAOR,GAHa,QADbihC,EAAMC,GAAQhnC,MAEb+mC,EAAM,WAEM,cAARA,EAEJ,OADAF,GAAY7yB,GAAehU,EAAK,GAAK8gB,EAAKlM,EAAOmM,EAAK0L,EAAMzsB,EAAIO,OAAQ6V,EAAK6vB,UACtEjmC,EAER,GAAa,eAAR+mC,EAEJ,OADAF,GAAY5yB,GAAgBjU,EAAK,GAAK8gB,EAAKlM,EAAOmM,EAAK0L,EAAMzsB,EAAIO,OAAQ6V,EAAK6vB,UACvEjmC,EAER,GAAKwU,EAAM,CACV,GAAa,YAARuyB,EAGJ,OCnFH,SAAmB/mC,EAAK8gB,EAAKlM,EAAOmM,EAAK0L,EAAMjjB,EAAKy8B,GACnD,IAAIQ,EACAC,EACAR,EACAC,EACAC,EACAC,EACA5/B,EACAmN,EAGA0yB,EACAC,EACA3wB,EACA7V,EAEJ,GAAa,IAARyJ,EACJ,OAAOxJ,EAoCR,GAlCA0mC,EAAQ,EACK,YAAR5lB,GACJolB,EAAMtxB,EACNwxB,EAAM,GACa,cAARtlB,GACX4lB,GAAS,EACTR,EAAM9yB,GAAOwB,GACbwxB,EAAM/yB,GAAOuB,KAEbsxB,EAAM50B,GAAMsD,GACZwxB,EAAM70B,GAAMqD,IAEA,YAARmM,GACJolB,EAAM1Z,EACN4Z,EAAM,GACa,cAARtlB,GACX2lB,GAAS,EACTP,EAAM/yB,GAAOqZ,GACb4Z,EAAMhzB,GAAOoZ,KAEb0Z,EAAM70B,GAAMmb,GACZ4Z,EAAM90B,GAAMkb,IAIZga,EADc,IAAVC,EACI30B,GAEAV,GAGTuC,EAAM5T,EAAI6X,KACVpR,EAAMzG,EAAImX,UAAW,GAGR,IAAR3N,EAMJ,OAJC/C,EAAKmN,EAAK,EADNqyB,EACS,IAAIQ,EAAON,EAAKE,GAEhB,IAAII,EAAOP,EAAKE,IAEvBpmC,EAcR,IAZAyG,EAAKmN,EAAK,EAAG,IAAI6yB,EAAOP,EAAKE,IAQ7BE,GAAOH,EAAID,IAJVtwB,EADIqwB,EACAz8B,EAAM,EAENA,GAGL+8B,GAAOF,EAAID,GAAQxwB,EAGb7V,EAAI,EAAGA,EAAI6V,EAAG7V,IAGnB0G,EAAKmN,EAAK7T,EAAG,IAAI0mC,EAFZP,EAAOI,EAAGvmC,EACVqmC,EAAOG,EAAGxmC,IAIXkmC,GACJx/B,EAAKmN,EAAKgC,EAAG,IAAI6wB,EAAON,EAAKE,GAG/B,CDDGY,CADAzvB,EAAII,GAAkB5X,GACT8gB,EAAKlM,EAAOmM,EAAK0L,EAAMzsB,EAAIO,OAAQ6V,EAAK6vB,UAC9CjmC,EAER,MAAM,IAAI8D,UAAW,iKACrB,CAED,OADA0T,EAAII,GAAkB5X,IACfqX,kBElER,SAAmBrX,EAAK4U,EAAO6X,EAAMjjB,EAAKy8B,GACzC,IAAIryB,EACAnN,EACAmP,EACA2N,EACAxjB,EAEJ,GAAa,IAARyJ,EACJ,OAAOxJ,EAOR,GAJA4T,EAAM5T,EAAI6X,KACVpR,EAAMzG,EAAImX,UAAW,GAGR,IAAR3N,EAMJ,OAJC/C,EAAKmN,EAAK,EADNqyB,EACSxZ,EAEA7X,GAEP5U,EAaR,IAXAyG,EAAKmN,EAAK,EAAGgB,GAQb2O,GAAMkJ,EAAK7X,IAJVgB,EADIqwB,EACAz8B,EAAM,EAENA,GAKCzJ,EAAI,EAAGA,EAAI6V,EAAG7V,IACnB0G,EAAKmN,EAAK7T,EAAG6U,EAAS2O,EAAExjB,GAGpBkmC,GACJx/B,EAAKmN,EAAKgC,EAAG6W,EAGf,CFyBEya,CAAS1vB,EAAG5C,EAAO6X,EAAMzsB,EAAIO,OAAQ6V,EAAK6vB,UACnCjmC,IAER8mC,GAAW9mC,EAAK4U,EAAO6X,EAAMzsB,EAAIO,OAAQ6V,EAAK6vB,UACvCjmC,EACR,IGvHe,IAAAgG,GAAAvG,OAAO0nC,OCKtB,SAASC,KAET,CCSA,IAAAC,GATwB,mBAAZrhC,GACIA,GDehB,SAAuBiZ,GAEtB,OADAmoB,GAAKxmC,UAAYqe,EACV,IAAImoB,EACZ,EELA,IAAI9zB,GAAsBhB,KACtBg1B,GAAa,gBACbhF,GAAY,CACfn7B,QAAW,aACXG,QAAW,aACXC,MAAS,WACTC,MAAS,WACTE,OAAU,YACVC,OAAU,aAEP66B,GAAe,CAClBC,EAAK,IACL//B,EAAK,IACL3C,EAAK,KACL+pB,EAAK,IACLhT,EAAK,KAkGN,SAASqB,GAASlQ,GACjB,IAAIkK,EACA0wB,EACAE,EACAwE,EAsBJ,SAASvE,IACR,IAAInvB,EAAQ5P,UAAU1D,OACtB,OAAOiR,gBAAgBwxB,GAYR,IAAVnvB,EACJ0zB,EAAO1lC,KAAM2P,KAAM81B,IACE,IAAVzzB,EACX0zB,EAAO1lC,KAAM2P,KAAM81B,GAAYrjC,UAAU,IACpB,IAAV4P,EACX0zB,EAAO1lC,KAAM2P,KAAM81B,GAAYrjC,UAAU,GAAIA,UAAU,IAClC,IAAV4P,GACX0zB,EAAO1lC,KAAM2P,KAAM81B,GAAYrjC,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAE/DuN,MApBS,IAAVqC,EACG,IAAImvB,EAEG,IAAVnvB,EACG,IAAImvB,EAAY/+B,UAAU,IAEnB,IAAV4P,EACG,IAAImvB,EAAY/+B,UAAU,GAAIA,UAAU,IAEzC,IAAI++B,EAAY/+B,UAAU,GAAIA,UAAU,GAAIA,UAAU,GAY9D,CAuID,OAlLAsjC,EAASC,GAAoBv/B,GAE7BkK,EAAoBqvB,GAAiBv5B,GACrC46B,EAvFD,SAAqB56B,GACpB,OAAOk6B,GAAYl6B,GAAU,SAC9B,CAqFai7B,CAAYj7B,GACxB86B,EAAST,GAAWr6B,GAkDpBtB,EAAaq8B,EAAY,oBAAqB7wB,GAW9CxL,EAAaq8B,EAAY,OAAQH,GAkBjCl8B,EAAaq8B,EAAY,QAAQ,SAAe5uB,GAC/C,IAAIC,EACAR,EACAS,EACAtU,EACA4T,EACAW,EACA/N,EACAgD,EACAzJ,EACJ,IAAMoR,GAAYK,MACjB,MAAM,IAAI1N,UAAW,6DAEtB,IAAMq/B,EAAyB3xB,MAC9B,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAGpG,IADAhvB,EAAQ5P,UAAU1D,QACL,EAAI,CAEhB,IAAM4Q,GADNmD,EAAOrQ,UAAW,IAEjB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsEuP,IAE/FT,EAAQ,IACZQ,EAAUpQ,UAAW,GAEtB,CACD,GAAKqL,GAAc8E,GAAQ,CAC1B,GAAKE,EAAO,CASX,IARA9K,EAAM4K,EAAI7T,OAETiG,EADI4N,EAAI5N,KAAO4N,EAAI3N,IACbgO,EAAgB,WAEhBzM,EAAQ,WAGf4L,GADA5T,EAAM,IAAIwR,KAAMhI,IACNiK,QACJ1T,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB6T,EAAKmvB,GAAUhjC,EAAEoS,EAAmBmC,EAAKzS,KAAMwS,EAAS7N,EAAK4N,EAAKrU,GAAKA,IAAK,GAE7E,OAAOC,CACP,CACD,OAAO,IAAIwR,KAAM4C,EACjB,CACD,GAAK5F,GAAU4F,IAASd,IAAuBnC,GAAYiD,EAAKD,KAAsB,CAErF,IAAMhD,IADNyC,EAAMQ,EAAKD,OACWjB,MACrB,MAAM,IAAIpP,UAAWiB,EAAQ,6FAA8FqP,IAU5H,IAPCG,EADID,ECvQR,SAA0BrB,EAAIqB,EAAMD,GACnC,IAAIrU,EACAkJ,EACAnJ,EAIJ,IAFAC,EAAM,GACND,GAAK,IAEJmJ,EAAI+J,EAAGC,QACAC,MAGPpT,GAAK,EACLC,EAAI8E,KAAMwP,EAAKzS,KAAMwS,EAASnL,EAAEtJ,MAAOG,IAExC,OAAOC,CACR,CDwPU0U,CAAiBd,EAAKU,EAAMD,GE1QtC,SAAuBpB,GACtB,IAAIjT,EACAkJ,EAGJ,IADAlJ,EAAM,KAELkJ,EAAI+J,EAAGC,QACAC,MAGPnT,EAAI8E,KAAMoE,EAAEtJ,OAEb,OAAOI,CACR,CF+PUgT,CAAcY,GAIrBA,GADA5T,EAAM,IAAIwR,KADVhI,EAAM+K,EAAIhU,SAEAkT,QACJ1T,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB6T,EAAKmvB,GAAUhjC,EAAEoS,EAAmBoC,EAAKxU,IAAK,GAE/C,OAAOC,CACP,CACD,MAAM,IAAI8D,UAAWiB,EAAQ,6FAA8FqP,GAC7H,IAcCzN,EAAaq8B,EAAY,MAAM,WAC9B,IAAIh+B,EACAjF,EACJ,IAAMoR,GAAYK,MACjB,MAAM,IAAI1N,UAAW,6DAEtB,IAAMq/B,EAAyB3xB,MAC9B,MAAM,IAAI1N,UAAWiB,EAAQ,2CAA4Cy9B,GAAcv6B,EAAM,IAAM46B,IAGpG,IADA79B,EAAO,GACDjF,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAClCiF,EAAKF,KAAMb,UAAWlE,IAEvB,OAAO,IAAIyR,KAAMxM,EACnB,IGjRA,SAAkBkF,EAAMu9B,GACvB,IAAI3hC,EAAM0/B,GAAUt7B,GACpB,GAAKpE,EACJ,MAAMA,EAGP,GADAA,EAAM0/B,GAAUiC,GAEf,MAAM3hC,EAEP,QAAoC,IAAxB2hC,EAAU7mC,UACrB,MAAM,IAAIkD,UAAWiB,EAAQ,8GAA+G0iC,EAAU7mC,YAGvJsJ,EAAKtJ,UAAY8mC,GAAcD,EAAU7mC,WAGzClB,EAAgBwK,EAAKtJ,UAAW,cAAe,CAC9CgG,cAAgB,EAChBC,YAAc,EACdC,UAAY,EACZlH,MAASsK,GAIX,CH4PCy9B,CAAU3E,EAAYuE,GAEfvE,EASP,SAASG,EAAyBvjC,GACjC,OAASA,IAAUojC,CACnB,CACF,CIrQA,IAAI4E,GAAiBzvB,GAAS,WCA1B0vB,GAAiB1vB,GAAS,WCnD9B,SAAS2vB,GAAgBj5B,GACxB,OAAc,IAANA,GAAa,EAAIA,IAAMC,EAChC,CCaA,IAAIi5B,GAA6B,qBCL7BC,GAA2B,SCA3BC,IAA4B,SCFhC,SAASC,GAAkBtoC,GAC1B,OAAKA,GAAUA,GAASA,IAAUiM,IAAQjM,IAAUkP,GAC5C,UAEHF,GAAWhP,GACVA,GAASqoC,IAA4BroC,GAASooC,GAC3C,UAED,UAIPpoC,GAASmoC,IACTnoC,EAAQmoC,GAED,UAGD,SACR,CAmBA,SAASI,GAAavoC,GACrB,OAAMD,GAAUC,GAYXA,GAAUA,GAASA,IAAUiM,IAAQjM,IAAUkP,GAC5C,UAEHF,GAAWhP,GACA,IAAVA,GAAekoC,GAAgBloC,GAC5B,UAEHA,EAAQ,EACPA,GAASqO,GACN,OAEHrO,GAASqN,GACN,QAEHrN,GAAS0M,GACN,QAED,UAEH1M,GAAS2N,GACN,QAEH3N,GAAS+M,GACN,SAEH/M,GAASoM,GACN,SAED,UAIPpM,GAASmoC,IACTnoC,EAAQmoC,GAED,UAGD,UAjDDj4B,GAAWlQ,GACR,OAEHqS,GAAerS,GACmB,YAAjCsoC,GAAkBtoC,EAAM6R,KAAuD,YAAjCy2B,GAAkBtoC,EAAM8R,IACnE,aAED,YAED,SAyCT,CCjFA,SAASuhB,GAAWpkB,EAAGqkB,GACtB,IAAI9b,EACJ,IAAM9H,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,8EAA+E8J,IAE7G,IAAMS,GAAc4jB,GACnB,MAAM,IAAIpvB,UAAWiB,EAAQ,+EAAgFmuB,IAE9G,GAAKrkB,EAAEtO,SAAW2yB,EAAK3yB,OACtB,MAAM,IAAIgB,MAAOwD,EAAQ,qEAG1B,MAAY,aADZqS,EAAKnP,GAAO4G,KACoB,OAAPuI,EACjBlW,GAAM2N,EAAGqkB,GAEVhyB,GAAK4Y,OAAQjL,EAAGqkB,EAAMrzB,GAAO+rB,GAAasH,GAAQ9b,GAAM,EAAG,EACnE,CC5CA,IAAIsd,GAAQ,CACX,SACA,aACA,mBACA,YACA,UAEG0T,GAASlwB,GAAUwc,ICqBvB,SAASb,GAAWhlB,EAAGqkB,GACtB,IAAI9b,EACJ,IAAM9H,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,8EAA+E8J,IAE7G,IAAMS,GAAc4jB,GACnB,MAAM,IAAIpvB,UAAWiB,EAAQ,+EAAgFmuB,IAE9G,GAAKrkB,EAAEtO,SAAW2yB,EAAK3yB,OACtB,MAAM,IAAIgB,MAAOwD,EAAQ,qEAG1B,MAAY,aADZqS,EAAKnP,GAAO4G,KACoB,OAAPuI,EACjBlW,GAAM2N,EAAGqkB,GAEVhyB,GAAK4Y,OAAQjL,EAAGqkB,EAAMrzB,GAAOyrB,GAAY4H,GAAQ9b,GAAM,EAAG,EAClE,CCzCA,IAAIixB,GAAO,IAAIh3B,GAAYhG,IAAKA,KAC5Bi9B,GAAM,IAAIv2B,GAAW1G,IAAKA,KAC1B2L,GAASmF,GAAQ,8BACjBosB,GAAerwB,GAAUlB,IACzB+gB,GAAgBb,GAAS1wB,IAAK,8BCNlC,IAAI6hC,GAAO,IAAIh3B,GAAYhG,IAAKA,KAC5Bi9B,GAAM,IAAIv2B,GAAW1G,IAAKA,KAC1B2L,GAAS,CAAE,UAAW,UAAW,aAAc,YAAa,sMCFhE,IAAI+gB,GAAgBb,GAAS1wB,IAAK,kBAsBlC,SAASutB,GAAOj0B,GACf,IAAImI,EACJ,IAAMgH,GAAsBnP,GAC3B,MAAM,IAAIgE,UAAWiB,EAAQ,+EAAgFjF,IAE9G,GAAKmE,UAAU1D,OAAS,GAEvB,GAAe,aADf0H,EAAQhE,UAAW,IAElB,OAAO/C,GAAMpB,QAGdmI,EAAQ8vB,GAET,OAAO72B,GAAK4Y,OAAQja,GAAOC,EAAGmI,GAAS,EAAG,EAC3C,CCrCA,IAAIogC,GAAO,IAAIh3B,GAAY,EAAK,GAC5Bi3B,GAAM,IAAIv2B,GAAW,EAAK,GAC1BgmB,GAAgBb,GAAS1wB,IAAK,kBCDlC,IAAI6hC,GAAO,IAAIh3B,GAAY,EAAK,GAC5Bi3B,GAAM,IAAIv2B,GAAW,EAAK,GCF9B,IAAI2iB,GAAQ,CACX,SACA,aACA,mBACA,YACA,UAEG0T,GAASlwB,GAAUwc,ICqDvB,SAASV,GAAOnlB,EAAGqkB,EAAM3c,GACxB,IAAIH,EACAtQ,EACAipB,EACAyZ,EACJ,IAAMl5B,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,8EAA+E8J,IAE7G,IAAMS,GAAc4jB,GACnB,MAAM,IAAIpvB,UAAWiB,EAAQ,+EAAgFmuB,IAE9G,IAAM5jB,GAAciH,GACnB,MAAM,IAAIzS,UAAWiB,EAAQ,8EAA+EwR,IAG7G,GADAH,ECvEO,CACNqa,KAAQ,UDuEJxsB,UAAU1D,OAAS,IACvBuF,ED7CF,SAAmBsQ,EAAMD,GACxB,OAAM3H,GAAU2H,GAGXvN,GAAYuN,EAAS,UACzBC,EAAKqa,KAAOta,EAAQsa,MACd2X,GAAQhyB,EAAKqa,OACX,IAAI3sB,UAAWiB,EAAQ,gFAAiF,OAAQ2vB,GAAMpf,KAAM,QAAUc,EAAKqa,OAG7I,KARC,IAAI3sB,UAAWiB,EAAQ,qEAAsEoR,GAStG,CCkCQqvB,CAAUpvB,EAAMnS,UAAW,IAC5B6B,GACJ,MAAMA,EAOR,GAJAipB,EAAM9mB,GAAO4G,IAAO,WAIduS,GAHNonB,EAAMvgC,GAAOsO,IAAY,UAGIwY,GAC5B,MAAM,IAAIjrB,UAAWiB,EAAQ,6GAA8GyjC,EAAKzZ,IAOjJ,OAJKG,GAAmBH,IAASvN,GAAgBgnB,KAChDjyB,EAASiY,GAASjY,EAAQwY,IAGpB7tB,GAAM2N,EAAGqkB,EAAM3c,EAAQH,EAAKqa,KACpC,CE1EA,IAAIgY,GAAQ,iBACRC,GAAU,mBACVC,GAAU,uBAGVC,GAAsB,WAGtB3iB,GAAsB,QAGtBC,GAAoB,WAGpBd,GAAQ,CAAE,EAAK,GAmCnB,SAASyjB,GAAMh6B,GACd,IAAIi6B,EACAC,EACAC,EACA1jB,EACA2jB,EACAC,EACAC,EACAzmC,EACA0mC,EACAvrB,EACA/E,EACA/Y,EACAge,EAEJ,GAAK5a,GAAO0L,IAAOA,EAAI,EACtB,OAAOxD,IAMR,GAJAuO,GAAQE,OAAQjL,EAAGuW,GAAO,EAAG,GAC7BE,EAAkB,EAAbF,GAAO,GACZ6jB,EAAK7jB,GAAO,GACZrH,EAAI,EACCuH,EAAKW,GAAsB,CAE/B,GAAgC,IAAxBX,EAAGE,GAAYyjB,GACtB,OAAOn6B,GAERiP,GAAK,GAILuH,EAAwB,EAAnBN,GADLnW,GAAK45B,GAEL,CACD,OAAKnjB,GAAMsjB,GACH/5B,EAAIA,EAGPyW,IAAOY,IAA4B,IAAP+iB,EACzB,GAERlrB,IAAQuH,GAAI,IAAMwC,GAAO,EAOzBhP,EADAiF,IAJAhe,GADAulB,GAAMU,IACK,OAAYC,GAAsB,IAIpC,GAAI,EAGb+iB,EAAO,IADPtmC,GAHAmM,EAAIgX,GAAahX,EAAGyW,EAAIvlB,EAAEmmB,KAGlB,GACSxjB,EACjB0mC,EChBD,SAAsB1mC,GACrB,IACImnB,EACAD,EACAkB,EACApY,EAEAmL,ECxGchP,EDiHlB,OAJAgb,GADAhM,GADAnL,GADAoY,EAAIpoB,GAAM,EAAMA,IACRooB,GACApY,IC3GG,KADO7D,ED6GCgP,GC3GX,kBAED,kBAAsBhP,GAAK,mBAA2B,mBAAJA,ID0GzD+a,EAAKlX,EE9GN,SAAmB7D,GAClB,OAAW,IAANA,EACG,kBAED,kBAAsBA,GAAK,kBAAsBA,GAAK,kBAA0B,mBAAJA,GACpF,CFyGUw6B,CAAUxrB,GAGZiN,GADA,GAAMpoB,EAAIA,GADbknB,EAAKC,GAGV,CDDKyf,CAAa5mC,GAejBqmC,IAFAI,EAAOzmC,GADPwmC,EAAKvkB,GADLukB,EAAKxmC,EAAIsmC,EACY,IACHA,EAAOI,GAERF,GAAOP,GAAcQ,EAAKT,IAG3CK,GAAWjwB,GADX+E,EAAI/E,GAHJgwB,EAAQI,EAAKR,KAIQI,IACrBA,EAAQjrB,GAGT,yHIpHIka,GAAgBwR,GAAe/iC,IAAK,kBACpCsE,GAAiBsO,GAAO,aACxBrO,GAAkBqO,GAAO,cACzBpO,GAAeoO,GAAO,QAY1B,SAASowB,GAAgBpiC,GACxB,OAASA,aAAe0D,EACzB,CASA,SAAS2+B,GAAiBriC,GACzB,OAASA,aAAe2D,EACzB,CASA,SAAS2+B,GAAatiC,GACrB,OAASA,aAAe4D,EACzB,CA6BA,SAASmN,GAAShC,GACjB,IAAIurB,EACAiI,EACAvzB,EACAtQ,EAGJ,GADAsQ,EChGO,CACNwzB,cAAiB,kBDgGb3lC,UAAU1D,SACduF,EElFF,SAAmBsQ,EAAMD,GACxB,OAAM3H,GAAU2H,GAGXvN,GAAYuN,EAAS,mBACzBC,EAAKwzB,cAAgBzzB,EAAQyzB,eACvB36B,GAAsBmH,EAAKwzB,gBACzB,IAAI9lC,UAAWiB,EAAQ,2EAA4E,gBAAiBqR,EAAKwzB,gBAG3H,KARC,IAAI9lC,UAAWiB,EAAQ,qEAAsEoR,GAStG,CFuEQqvB,CAAUpvB,EAAMD,GACjBrQ,GACJ,MAAMA,EAaR,OAVA6jC,EG3GD,SAAe7pC,GACd,IAAIE,EACAD,EAGJ,IADAC,EAAM,GACAD,EAAI,EAAGA,EAAID,EAAE,EAAGC,IACrBC,EAAI8E,KAAM,IAEX,OAAO9E,CACR,CHkGQ6pC,CAAY5c,GAAM4b,GAAMzyB,EAAKwzB,iBACpClI,EAAS,EAET/6B,EAAamjC,EAAQ,SAAUA,GAC/BnjC,EAAamjC,EAAQ,UAiKrB,WACC,IAAIj2B,EACA7T,EACAuU,EACAxU,EAEJ8T,EAAQ5P,UAAU1D,OAEjBP,EADc,IAAV6T,EACEi2B,IACe,IAAVj2B,EACLi2B,EAAQ7lC,UAAW,IAEnB6lC,EAAQ7lC,UAAW,GAAKA,UAAW,IAE1C,GAAa,OAARjE,EAWJ,IARCuU,EADIk1B,GAAiBzpC,GACfiU,GAAgBjU,EAAK,GAChBwpC,GAAgBxpC,GACrBgU,GAAehU,EAAK,GACf0pC,GAAa1pC,GAClB8iB,GAAoB9iB,EAAK,GAEzBA,EAEDD,EAAI,EAAGA,EAAIwU,EAAIhU,OAAQR,IAC5BwU,EAAKxU,GAAM,EAGb,OAAOC,CACP,IA9LD2G,EAAamjC,EAAQ,QA4MrB,SAAel2B,GACd,IAAI9T,EACAye,EACAxe,EACJ,GI3RyBH,EJ2RFgU,EIzRb,OAAVhU,GACiB,iBAAVA,GACPqP,GAAsBrP,EAAMW,SAC5BX,EAAMW,QAAUwpC,IACmB,iBAA5BnqC,EAAMuS,mBACe,iBAArBvS,EAAMkT,YACe,iBAArBlT,EAAMsU,YJmRmBN,EAAIf,OACnCe,EAAMA,EAAIf,YACJ,IAAMpD,GAAemE,GAC3B,MAAM,IAAI9P,UAAWiB,EAAQ,4EAA6E6O,II9R7G,IAA2BhU,EJgSzB,GAAKgU,EAAIM,WAAa,EAAI,CAQzB,IAPApU,EAAI6O,GAAOk6B,GAAMj1B,EAAIM,aKnTVrF,ELsTF86B,EAAKppC,OAAO,EKtTPuY,ELsTUhZ,EAAxBA,EKrTGqD,GAAO0L,IAAO1L,GAAO2V,GAClBzN,IAEHwD,IAAMC,IAAQgK,IAAMhK,GACjBA,GAEHD,IAAMiK,GAAW,IAANjK,EACVi5B,GAAgBj5B,GACbA,EAEDiK,EAEHjK,EAAIiK,EACDjK,EAEDiK,ELySLyF,EAAIorB,EAAM7pC,GACJC,EAAI,EAAGA,EAAIwe,EAAEhe,OAAQR,IAC1B,GAAKwe,EAAGxe,KAAQ6T,EACf,OAAO,EAIT2K,EAAEzZ,KAAM8O,EACR,CKjUH,IAAc/E,EAAGiK,ELkUf,OAAO,CACP,IArODnS,EAAamjC,EAAQ,SA4OrB,WACC,IAAI/pC,EACJ,IAAMA,EAAI,EAAGA,EAAI4pC,EAAKppC,OAAQR,IAC7B4pC,EAAM5pC,GAAIQ,OAAS,EAEpBmhC,EAAS,CACT,IAjPD/6B,EAAamjC,EAAQ,gBAAiB1zB,EAAKwzB,eAC3C5M,GAAqB8M,EAAQ,UAU7B,WACC,OAAOpI,CACP,IAVMoI,EAmDP,SAAS94B,EAAY9G,EAAMV,EAAKvB,GAC/B,IAAI2L,EMjJU/E,EACXlN,EACA4c,ENgJH,OAAa,IAAR/U,EACG,IAAIU,EAAM,IAElB0J,EArCD,SAAsB9T,GACrB,IAAI8T,EACA7T,EAMJ,OAHAA,EAAI8oC,GAAM/oC,IAGD6pC,EAAKppC,QAAUopC,EAAM5pC,GAAIQ,OAC1BopC,EAAM5pC,GAAIilC,MAGbtD,EAAO5hC,EAAIsW,EAAKwzB,cACb,MAERh2B,EAAM,IAAIpE,GAAa1P,GAGvB4hC,GAAU5hC,EAEH8T,EACP,CAgBMo2B,EMjJN7mC,GAJc0L,ENqJYrF,IMhJ1Bya,GAAYpV,IACN,IAANA,EAEOA,GAEHA,EAAI,GACRA,GAAKA,EACLlN,GAAQ,GAERA,EAAO,GAGR4c,EAAIsqB,GAAMh6B,MAGCo7B,GACHp7B,GAIP0P,GADc,IAAV5c,EACAgN,GAAO4P,GAEP0O,GAAM1O,IAGF2rB,GACDr+B,GAEDlK,EAAOqnB,GAAK,EAAKzK,KNoHSpM,GAAmBlK,IACtC,OAAR2L,EACGA,EAED,IAAI1J,EAAM0J,EAAK,EAAGpK,GACzB,CAkBD,SAASsgC,IACR,IAAIj2B,EACA5L,EACAiC,EACA9C,EACApH,EACAyG,EACAD,EACAgD,EACAzJ,EO9LsBH,EPwM1B,GAAc,QADdsK,EAAOkP,GAJNnR,GAHD4L,EAAQ5P,UAAU1D,SACJmP,GAAUzL,UAAW4P,EAAM,IAEhC5P,UADR4P,GAAS,GAGDkkB,KAIR,MAAM,IAAIj0B,UAAWiB,EAAQ,sEAAuEkD,IAErG,GAAK4L,GAAS,EACb,OAAO,IAAI3J,EAAM,GAGlB,GAAK+E,GAAsBhL,UAAW,IACrC,OAAO+M,EAAY9G,EAAMjG,UAAW,GAAKgE,GAG1C,GAAKqH,GAAcrL,UAAW,IAAQ,CAcrC,GAZAuF,GADApC,EAAMnD,UAAW,IACP1D,QOrNeX,EPsNDwH,aOpNR2D,IACY,oBAA7Bf,GAAiBpK,GPoNfwH,EAAM6M,GAAgB7M,EAAK,IQvN/B,SAA2BxH,GAC1B,OACCA,aAAiBkL,IACY,mBAA7Bd,GAAiBpK,EAEnB,CRmNewS,CAAkBhL,GAElBsP,GAAgBtP,GAC3BA,EAAM0b,GAAoB1b,EAAK,GACpB8nB,GAAmBjnB,KAE9BuB,GAAO,GALPpC,EAAM4M,GAAe5M,EAAK,GAQd,QADbpH,EAAMgR,EAAY9G,EAAMV,EAAKvB,IAE5B,OAAOjI,EAER,GAAKypC,GAAiBzpC,IAASwpC,GAAgBxpC,IAAS0pC,GAAa1pC,GAEpE,OADAA,EAAIyG,IAAKW,GACFpH,EAKR,IAFAwG,EAAMwR,GAAe5Q,GACrBX,EAAMkvB,GAAe31B,GACfD,EAAI,EAAGA,EAAIyJ,EAAKzJ,IACrB0G,EAAKzG,EAAKD,EAAGyG,EAAKY,EAAKrH,IAExB,OAAOC,CACP,CACD,MAAM,IAAI8D,UAAWiB,EAAQ,wGAAyGd,UAAW,IACjJ,CAoGF,CSxUA,IAAIkmC,GAAiBhyB,KCPrBxR,EAAAnH,GAAA,UAAA2Y,w2FC2BA,SAAS4c,GAAKlmB,EAAG8K,EAASpD,GACzB,IAAIH,EACAtQ,EACAipB,EACAyZ,EACJ,IAAMl5B,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,8EAA+E8J,IAE7G,IAAMS,GAAcqK,GACnB,MAAM,IAAI7V,UAAWiB,EAAQ,+EAAgF4U,IAE9G,IAAMrK,GAAciH,GACnB,MAAM,IAAIzS,UAAWiB,EAAQ,8EAA+EwR,IAG7G,GADAH,EC1DO,CACNqa,KAAQ,aD0DJxsB,UAAU1D,OAAS,IACvBuF,EE3CF,SAAmBsQ,EAAMD,GACxB,OAAM3H,GAAU2H,GAGXvN,GAAYuN,EAAS,UACzBC,EAAKqa,KAAOta,EAAQsa,MACdqE,GAAa1e,EAAKqa,OAChB,IAAI3sB,UAAWiB,EAAQ,gFAAiF,OAAQ0vB,KAAQnf,KAAM,QAAUc,EAAKqa,OAG/I,KARC,IAAI3sB,UAAWiB,EAAQ,qEAAsEoR,GAStG,CFgCQqvB,CAAUpvB,EAAMnS,UAAW,IAC5B6B,GACJ,MAAMA,EAOR,GAJAipB,EAAM9mB,GAAO4G,IAAO,WAIduS,GAHNonB,EAAMvgC,GAAOsO,IAAY,UAGIwY,GAC5B,MAAM,IAAIjrB,UAAWiB,EAAQ,6GAA8GyjC,EAAKzZ,IAOjJ,OAJKG,GAAmBH,IAASvN,GAAgBgnB,KAChDjyB,EAASiY,GAASjY,EAAQwY,IAGpB7tB,GAAM2N,EAAG8K,EAASpD,EAAQH,EAAKqa,KACvC,CGzEA,IAAIrX,GAAQ,CACX9O,aAAgBA,GAChBD,aAAgBA,GAChBG,WAAcA,GACdG,YAAeA,GACfJ,WAAcA,GACdG,YAAeA,GACfD,UAAaA,GACbG,WAAcA,GACdC,kBAAqBA,GACrBC,eAAkBA,GAClBC,gBAAmBA,GACnBC,aAAgBA,ICdjB,SAASmY,GAASb,EAAOlb,GACxB,IAAI8B,EAAI9B,EAAK,GAKb,OAJK+H,GAAmBjG,KACvBoZ,EAAMxd,KAAMoE,EAAE3I,QACd4iB,GAASb,EAAOpZ,IAEVoZ,CACR,CAaA,SAASpE,GAAOkF,EAAOd,EAAOiB,EAAGnc,EAAKoN,GACrC,IAAIhL,EACAN,EACAnJ,EAMJ,IAHAyJ,EAAM8Y,EAAOiB,GAGPxjB,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAAM,CAIlC,IAAMoP,GAHNjG,EAAI9B,EAAKrH,KAGuBmJ,EAAE3I,SAAWiJ,EAE5C,OAAO+Z,EAGR,GAAK/O,IACJtL,EAAIgV,GAAOkF,EAAOd,EAAOiB,EAAE,EAAGra,EAAGqa,EAAE,EAAIH,EAAM,IACpCA,EAER,OAAOla,CAGT,CACD,OAAOka,CACR,CCxDA,IAAIgnB,GAAsD,mBAAtBC,kBAyBpC,SAASC,GAAqB1qC,GAC7B,OACGwqC,IAAwBxqC,aAAiByqC,mBAClB,+BAAzBrhC,GAAapJ,EAEf,CCnCA,IAAIJ,GAAsC,mBAAtB6qC,kBAAqCA,kBAAoB,KCA7E,ICwBIngC,GDxBAA,GAAsC,mBAAtBmgC,kBAAqCA,kBAAoB,KC4B5EngC,GCbD,WACC,IAAIiB,EACAo/B,EACAC,EAEJ,GAAwC,mBAA5BC,GACX,OAAO,EAGR,IAECD,GADAD,EAAK,IAAIE,GAAyB,KAC1B7lC,MAAO,EAAG,GAClBuG,EACCm/B,GAAqBC,IACrBD,GAAqBE,IACH,KAAlBD,EAAGr2B,YACe,IAAlBs2B,EAAGt2B,UAEJ,CAAC,MAAQpO,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CDZKu/B,GACG1kC,GEpBR,SAAmBu7B,GAClB,MAAM,IAAIhgC,MAAO,sPAClB,EF0BA,IAAAopC,GAAezgC,GGHf,SAAS0rB,GAAM/mB,EAAG8K,GACjB,IAAIvD,EACAtQ,EACAsR,EACJ,IAAM9H,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,8EAA+E8J,IAE7G,IAAMS,GAAcqK,GACnB,MAAM,IAAI7V,UAAWiB,EAAQ,+EAAgF4U,IAG9G,GADAvD,EC9BO,CACNqa,KAAQ,aD8BJxsB,UAAU1D,OAAS,IACvBuF,EEfF,SAAmBsQ,EAAMD,GACxB,OAAM3H,GAAU2H,GAGXvN,GAAYuN,EAAS,UACzBC,EAAKqa,KAAOta,EAAQsa,MACdqE,GAAa1e,EAAKqa,OAChB,IAAI3sB,UAAWiB,EAAQ,gFAAiF,OAAQ0vB,KAAQnf,KAAM,QAAUc,EAAKqa,OAG/I,KARC,IAAI3sB,UAAWiB,EAAQ,qEAAsEoR,GAStG,CFIQqvB,CAAUpvB,EAAMnS,UAAW,IAC5B6B,GACJ,MAAMA,EAIR,MAAY,aADZsR,EAAKnP,GAAO4G,KACoB,OAAPuI,EACjBlW,GAAM2N,EAAG8K,EAASvD,EAAKqa,MAExBvvB,GAAK4Y,OAAQjL,EAAG8K,EAASvD,EAAKqa,KAAM5wB,GAAO8Z,EAAQpZ,OAAQ6W,GAAM,EAAG,EAC5E,CGzCA,IAAIwzB,GAAOC,KCcX,ICKIC,GDLAA,GAA2B,oBAAVC,MAA0B,KAAOA,MCSrDD,GCrBD,WACC,IAAI3/B,EACJ,IACCy/B,GAAM,wPACNz/B,GAAO,CACP,CAAC,MAAQrF,GACTqF,GAAO,CACP,CACD,OAAOA,CACR,CDSK6/B,GACIhlC,GETT,SAAgB2O,GAEf,OAAOA,CACR,EFcA,IAAAs2B,GAAeH,GGpCX3/B,GAAOgG,GAAY1R,OAAOqa,QCsB1BA,GAASra,OAAOqa,OC3BhB3O,QAAiD,IAAjC1L,OAAOyrC,sBCKvBC,GAAkB1rC,GAAOyrC,sBCuB7B,ICTIpxB,GDSJqxB,GATKhtB,GDKL,SAAgCve,GAC/B,OAAOurC,GAAiB1rC,GAAQG,GACjC,EGXA,WACC,MAAO,EACR,ECKA,SAASwrC,GAAsBxrC,GAC9B,IAAII,EACAuU,EACAxU,EAIJ,IAFAC,EAAMuV,GAAM3V,GACZ2U,EAAM42B,GAAiBvrC,GACjBG,EAAI,EAAGA,EAAIwU,EAAIhU,OAAQR,IACvBsrC,GAAczrC,EAAO2U,EAAKxU,KAC9BC,EAAI8E,KAAMyP,EAAKxU,IAGjB,OAAOC,CACR,CFdC8Z,GADIwxB,GACK9rC,GGWV,SAAiBmV,GAChB,IAAIqL,EACAzK,EACA+J,EACA9V,EACA8X,EACAvhB,EACA8D,EACJ,GAAK8Q,QACJ,MAAM,IAAI7Q,UAAWiB,EAAQ,2EAA4E4P,IAG1G,IADA2M,EAAK7hB,GAAQkV,GACP5U,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAElC,GAAKigB,OADLA,EAAS/b,UAAWlE,IAOpB,IADAyJ,GADA+L,EAAO61B,GAAsB3rC,GAAQugB,KAC1Bzf,OACLsD,EAAI,EAAGA,EAAI2F,EAAK3F,IAErByd,EADAhC,EAAM/J,EAAM1R,IACAmc,EAAQV,GAGtB,OAAOgC,CACR,EH7BA,IAAAiqB,GAAezxB,GIhBf,SAAS0xB,GAAa5rC,GAErB,OAAKD,GAAUC,GACP,CAAEA,EAAO,GAGVA,CACR,CAYA,SAAS6rC,GAASxjC,GACjB,OAAKinB,GAAmBjnB,GAChBujC,GAED,IACR,CC3BA,SAASC,GAASC,EAAat1B,GAC9B,OASA,SAAevH,GACd,OAAO68B,EAAa78B,EAAGuH,EACvB,CACF,CCXA,IAAIu1B,GAAgC,mBAAVZ,GCiB1B,SAASvF,GAAUpvB,EAAMD,GACxB,OAAM3H,GAAU2H,GAGXvN,GAAYuN,EAAS,YACzBC,EAAK2W,OAAS5W,EAAQ4W,QAChBjd,GAAWsG,EAAK2W,SACd,IAAIjpB,UAAWiB,EAAQ,+DAAgE,SAAUqR,EAAK2W,UAG1GnkB,GAAYuN,EAAS,WACzBC,EAAK6uB,MAAQ9uB,EAAQ8uB,MChBFrlC,EDiBDwW,EAAK6uB,MCjBGp8B,EDiBI,MChB1BjJ,UAGLA,EAAQH,GAAQG,GACS,iBAAbiJ,IACXA,EAAWlI,OAAQkI,IAGjBA,KAAYjJ,GACduR,GAAYvR,EAAOiJ,MDWb,KAHE,IAAI/E,UAAWiB,EAAQ,sEAAuE,QAAS,MAAOqR,EAAK6uB,QAXpH,IAAInhC,UAAWiB,EAAQ,qEAAsEoR,ICPtG,IAAqBvW,EAAOiJ,CDsB5B,CEjBA,SAAS+iC,KACR,OAAO,IACR,CAoBA,SAASC,GAAiBjsC,EAAOqI,GAChC,OAAK6H,GAAWlQ,GACR,KAED,IAAIkE,UAAWiB,EAAQ,sHAAuHnF,EAAOqI,GAC7J,CAoBA,SAAS6jC,GAAsBlsC,EAAOqI,GACrC,OAAKtI,GAAUC,GACP,KAEHqS,GAAerS,GACZ,IAAIkE,UAAWiB,EAAQ,+GAAgHgnC,GAAiBnsC,GAASqI,IAElK,IAAInE,UAAWiB,EAAQ,sHAAuHnF,EAAOqI,GAC7J,CAoBA,SAAS+jC,GAAyBpsC,EAAOqI,GACxC,OAAKtI,GAAUC,IAAWqS,GAAerS,GACjC,KAED,IAAIkE,UAAWiB,EAAQ,sHAAuHnF,EAAOqI,GAC7J,CAkBA,SAASgkC,GAAuBrsC,EAAOqI,GACtC,IAAIugC,EACJ,OAAK7oC,GAAUC,GACRgP,GAAWhP,GAIZgiB,GADL4mB,EAAMxV,GAA0BpzB,GACVqI,GACd,KAED,IAAInE,UAAWiB,EAAQ,+GAAgHyjC,EAAKvgC,IAN3I,IAAInE,UAAWiB,EAAQ,+GAAgHojC,GAAavoC,GAASqI,IAQjKgK,GAAerS,GACZ,IAAIkE,UAAWiB,EAAQ,+GAAgHgnC,GAAiBnsC,GAASqI,IAElK,IAAInE,UAAWiB,EAAQ,sHAAuHnF,EAAOqI,GAC7J,CAkBA,SAASikC,GAAyBtsC,EAAOqI,GACxC,IAAIugC,EACJ,OAAK7oC,GAAUC,GAETgiB,GADL4mB,EAAML,GAAavoC,GACGqI,GACd,KAED,IAAInE,UAAWiB,EAAQ,+GAAgHyjC,EAAKvgC,IAE/IgK,GAAerS,GACZ,IAAIkE,UAAWiB,EAAQ,+GAAgHgnC,GAAiBnsC,GAASqI,IAElK,IAAInE,UAAWiB,EAAQ,sHAAuHnF,EAAOqI,GAC7J,CAqBA,SAASkkC,GAAWlkC,GACnB,MAAe,YAAVA,GAAiC,KAAVA,EACpB2jC,GAEHQ,GAAwBnkC,GACrB6jC,GAEH9pB,GAA2B/Z,GACxBikC,GAEHnqB,GAAyB9Z,GACtBgkC,GAEH3vB,GAAmBrU,GAChB4jC,GAGDG,EACR,CC3MA,SAAS7zB,GAASuzB,EAAat1B,GAC9B,OAWA,SAAsBzB,EAAQ3P,GAC7B,IAAI6J,EACAgI,EAGJ,QADAA,EAAI7R,GACOzE,QACX,KAAK,EACJsO,EAAI,IAAI8F,EACR,MACD,KAAK,EACJ9F,EAAI,IAAI8F,EAAQkC,EAAE,IAClB,MACD,KAAK,EACJhI,EAAI,IAAI8F,EAAQkC,EAAE,GAAIA,EAAE,IACxB,MACD,KAAK,EACJhI,EAAI,IAAI8F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAC9B,MACD,KAAK,EACJhI,EAAI,IAAI8F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IACpC,MACD,KAAK,EACJhI,EAAI,IAAI8F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAC1C,MACD,KAAK,EACJhI,EAAI,IAAI8F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAChD,MACD,KAAK,EACJhI,EAAI,IAAI8F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IACtD,MACD,KAAK,EACJhI,EAAI,IAAI8F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAC5D,MACD,KAAK,EACJhI,EAAI,IAAI8F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IAClE,MACD,KAAK,GACJhI,EAAI,IAAI8F,EAAQkC,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,GAAIA,EAAE,IACxE,MACD,QAEChI,EAAI8F,EAAOxP,MAAO,KAAM0R,GAEzB,OAAO60B,EAAa78B,EAAGuH,EACvB,CACF,CChDA,IAAIi2B,GAAa,aCEjB,SAASC,GAAiBpmC,GACzB,OAASwJ,GAAUxJ,IAAUmmC,GAAW/9B,KAAMpI,EAC/C,CCJA,IAAIqmC,GAAiB,0BCErB,SAASC,GAAoBtmC,GAC5B,OAASwJ,GAAUxJ,IAAUqmC,GAAej+B,KAAMpI,EACnD,CCvBA,IAAIiF,QAA0C,IAA1BxK,OAAOC,UAAU6rC,KCAjCA,GAAO9rC,OAAOC,UAAU6rC,KCM5B,IAAIpoC,GAAK,+KC8BT,IAAAqoC,GATKvuB,ICD2B,KAAtBsuB,GAAK5qC,KArBJ,mDACA,MAoB+B4qC,GAAK5qC,KApBpC,KCiBX,SAAe3B,GACd,OAAO8F,GAAQnE,KAAM3B,EACtB,EHKA,SAAeA,GACd,OAAO+B,GAAS/B,EAAKmE,GAAI,KAC1B,EIGA,SAASsoC,GAAY9jC,EAAUo8B,GAC9B,IAjBuB/kC,EAiBnBsX,EAAIytB,EAAMz+B,KAjBStG,EAiBWusC,GAAM5jC,IAhB7BzE,UAAW,GAAIlE,EAAIK,OAAO,IAiBrC,GAAW,OAANiX,EACJ,MAAM,IAAIjW,MAAOwD,EAAQ,iEAAkE8D,IAE5F,OAAO2O,CACR,CCjBA,SAASo1B,GAAc1sC,EAAKgiB,EAAK6K,GAChC,IAAI1lB,EACAtH,EAIJ,IAAY,KADZA,EAAIq0B,GADJ/sB,EAAMhG,SAAUnB,EAAK,IACIgiB,EAAI,IACb,CACf,GAAK6K,EACJ,MAAM,IAAIhZ,WAAYhP,EAAQ,mDAG/B,OAAOsC,CACP,CACD,OAAOtH,CACR,CC1BA,SAAS8sC,GAAYC,GACpB,OAAO7qC,GAAS6qC,EAAK,sBAAuB,oBAC7C,CC2BA,IAAIC,GAAe,2BCGfC,GAAgB,wCCyFpB,SAASC,GAAY/jC,EAAGM,EAAK0jC,EAAWngB,GACvC,IAAIxY,EAGJ,GAAW,QAANrL,EACJ,OAAOM,EAIR,GADA+K,EAAMrL,EAAE3E,MAAOwoC,IACJ,CAIV,IAHA7jC,EAAIM,EAAMnI,SAAUkT,EAAK,GAAK,KAGrB,EAAI,CACZ,GAAKwY,EACJ,OAAQ,EAET7jB,EAAI,CACJ,CACD,OAAOA,CACP,CAGD,OADAqL,EAAMrL,EAAE3E,MAAOyoC,MAEd9jC,EAAI/E,WAAYoQ,EAAK,KACZ,EACD,GAAc,GAAK,EAInB5F,GADHu+B,GAAa1jC,EAAM,GAAW,IAANN,GACbM,EAAI,GAAKN,EAEXM,EAAMN,IAGb,CACT,CCzIA,IAAIikC,GAAe,UCAfd,GAAa,gBCRbe,GAAS,OCiSb,SAASC,GAAWntC,EAAKsJ,EAAKujB,GAC7B,IAAIugB,EACA13B,EACA1M,EAMJ,IAHA0M,GADA03B,EAAQb,GAAMvsC,GAAMqtC,MAAOJ,KACjB5sC,QAGD,GAAKqV,EAAI,EACjB,MC5TM,CACNoX,KAAQ,iCDiUT,GAAW,IAANpX,EAEJ,GAAkB,KADlB1M,EAAIokC,EAAO,IACJ/sC,OACN+sC,EAAO,GAAM,MACP,CACN,IAA8B,IAAzBjB,GAAW/9B,KAAMpF,GACrB,MCxUI,CACN8jB,KAAQ,iCD0UP,GAAW,KADX9jB,EAAI7H,SAAU6H,EAAG,KAEhB,ME5UI,CACN8jB,KAAQ,+BF6UPsgB,EAAO,GAAMpkC,CACb,MAEDokC,EAAMxoC,KAAM,GASb,GAAkB,KAHlBoE,EAAIokC,EAAO,IAGJ/sC,OAED+sC,EAAO,GAAM,GAAK9jC,EAAM,EAC5B8jC,EAAO,GAAM9jC,EAAM,EAEnB8jC,EAAO,GAAM,OAIV,GAAKF,GAAO9+B,KAAMpF,GAAM,CAE5B,IADAA,EAAI+jC,GAAY/jC,EAAGM,EAAK8jC,EAAO,GAAM,EAAGvgB,IAC/B,EACR,OAAY,IAAP7jB,EGtWA,CACN8jB,KAAQ,2BFDF,CACNA,KAAQ,iCD0WHsgB,EAAO,GAAM,GAAKpkC,GAAKM,IAC3BN,GAAK,GAENokC,EAAO,GAAMpkC,CACb,KAEI,KAAKmjC,GAAW/9B,KAAMpF,GAiC1B,MClZM,CACN8jB,KAAQ,iCDoXR,IAHA9jB,EAAI7H,SAAU6H,EAAG,KAGR,GAIR,IAHAA,EAAIM,EAAMN,GAGD,EAAI,CACZ,GAAK6jB,EACJ,MG3XG,CACNC,KAAQ,2BH4XN9jB,EAAI,CACJ,OAGG,GAAKA,GAAKM,EAAM,CACpB,GAAKujB,EACJ,MGnYI,CACNC,KAAQ,2BHsYN9jB,EADIokC,EAAO,GAAM,EACb9jC,EAAM,EAINA,CAEL,CACD8jC,EAAO,GAAMpkC,CAKb,CAQD,GAAkB,KAHlBA,EAAIokC,EAAO,IAGJ/sC,OAED+sC,EAAO,GAAM,EACjBA,EAAO,GAAM,KAEbA,EAAO,GAAM9jC,OAIV,GAAK4jC,GAAO9+B,KAAMpF,GAAM,CAE5B,IADAA,EAAI+jC,GAAY/jC,EAAGM,EAAK8jC,EAAO,GAAM,EAAGvgB,IAC/B,EACR,OAAY,IAAP7jB,EGvaA,CACN8jB,KAAQ,2BFDF,CACNA,KAAQ,iCD2aRsgB,EAAO,GAAMpkC,CACb,KAEI,KAAKmjC,GAAW/9B,KAAMpF,GAmC1B,MCldM,CACN8jB,KAAQ,iCDkbR,IAHA9jB,EAAI7H,SAAU6H,EAAG,KAGR,GAIR,IAHAA,EAAIM,EAAMN,GAGD,EAER,GAAKokC,EAAO,GAAM,EAAI,CACrB,GAAKvgB,EACJ,MG3bE,CACNC,KAAQ,2BH4bL9jB,EAAI,CACT,KAAW,CAEN,GAAK6jB,GAAU7jB,GAAK,EACnB,MGjcE,CACN8jB,KAAQ,2BHkcL9jB,EAAI,IACJ,OAIE,GAAKA,EAAIM,EAAM,CACnB,GAAKujB,EACJ,MG1cI,CACNC,KAAQ,2BH2cP9jB,EAAIM,CACJ,CACD8jC,EAAO,GAAMpkC,CAKb,CAGD,OAAa,IAARM,EACG,IAAIgjB,GAAO,EAAG,EAAG8gB,EAAO,IAGzB,IAAI9gB,GAAO8gB,EAAO,GAAKA,EAAO,GAAKA,EAAO,GAClD,CI5dA,IAAIE,GAAS,SACTC,GAAQ,EASRC,GAAS,UASTrB,GAAa,aCzBjB,IAAIlhC,QAAgD,IAAhCxK,OAAOC,UAAU+sC,WCArC,IC6BIA,GD7BAA,GAAahtC,OAAOC,UAAU+sC,WC+BjCA,GADIxvB,GCOL,SAAqBje,EAAK8b,EAAQ4xB,GACjC,IAAIhqC,EAMJ,OAJCA,EADIgqC,EAAW,EACT1tC,EAAIK,OAASqtC,EAEbA,EAEgB,IAAlB5xB,EAAOzb,UAIXqD,EAAM,GACNA,EAAMoY,EAAOzb,OAASL,EAAIK,SAIpByF,GAAQnE,KAAM3B,EAAK8b,EAAQpY,EACnC,ECrBA,SAAqB1D,EAAK8b,EAAQ4xB,GACjC,IAAIhqC,EACA7D,EAMJ,GAJC6D,EADIgqC,EAAW,EACT1tC,EAAIK,OAASqtC,EAEbA,EAEgB,IAAlB5xB,EAAOzb,OACX,OAAO,EAER,GACCqD,EAAM,GACNA,EAAMoY,EAAOzb,OAASL,EAAIK,OAE1B,OAAO,EAER,IAAMR,EAAI,EAAGA,EAAIic,EAAOzb,OAAQR,IAC/B,GAAKG,EAAI2tC,WAAYjqC,EAAM7D,KAAQic,EAAO6xB,WAAY9tC,GACrD,OAAO,EAGT,OAAO,CACR,EFjBA,IAAA+tC,GAAeH,GGpBXI,GAAY,IC+ChB,SAASC,GAAYC,EAAK/tC,GACzB,IAAI4qB,EPGL,SAAoB5qB,GACnB,IAAI8E,EACA5D,EACAtB,EACAoJ,EACAnJ,EACJ,GAAKG,EAAIkE,UAAW,EAAGopC,GAAOjtC,UAAaitC,GAC1C,OAAO,KAGR,GAAkB,MAAbttC,EADLJ,EAAII,EAAIK,OAAS,GAEhB,OAAO,KAIR,IADAL,GADAA,EAAMusC,GAAMvsC,EAAIkE,UAAWopC,GAAOjtC,OAAQT,KAChCytC,MAAOG,KACRntC,SAAWktC,GACnB,OAAO,KAGR,IADAzoC,EAAO,GACDjF,EAAI,EAAGA,EAAI0tC,GAAO1tC,IAAM,CAE7B,GAAW,UADXmJ,EAAIhJ,EAAKH,IAERqB,EAAM,SACA,KAAKirC,GAAW/9B,KAAMpF,GAG5B,OAAO,KAFP9H,EAAMC,SAAU6H,EAAG,GAGnB,CACDlE,EAAKF,KAAM1D,EACX,CACD,OAAO,IAAIorB,GAAOxnB,EAAM,GAAKA,EAAM,GAAKA,EAAM,GAC/C,COlCSkpC,CAAWhuC,GACnB,GAAW,OAAN4qB,EACJ,MAAM,IAAIvpB,MAAOwD,EAAQ,+DAAgEkpC,IAE1F,OAAOnjB,CACR,CAqDA,SAASqjB,GAAYx5B,EAAQ9L,EAAUkkB,GACtC,IAAI7mB,EAAOumC,GAAM5jC,GACjB,OAtGD,SAAkB3C,GACjB,MACe,MAAdA,EAAM,IACNynC,GAAYznC,EAAM,SAAU,IACF,MAA1BA,EAAMA,EAAK3F,OAAO,EAEpB,CAgGM6tC,CAASloC,GACN8nC,GAAYnlC,EAAU3C,GAhF/B,SAAwBA,GAEvB,OAAO6nC,GAAUz/B,KAAMpI,EACxB,CA+EMmoC,CAAenoC,GAxCrB,SAA2B+nC,EAAK/tC,EAAKgiB,EAAK6K,GACzC,IAAIjC,EAAIuiB,GAAWntC,EAAKgiB,GAAK,GAC7B,GAAK4I,EAAEkC,KAAO,CACb,GAAgB,gCAAXlC,EAAEkC,KACN,MAAM,IAAIzrB,MAAOwD,EAAQ,sFAAuFkpC,IAEjH,GAAgB,kCAAXnjB,EAAEkC,KACN,MAAM,IAAIzrB,MAAOwD,EAAQ,+DAAgEkpC,IAG1F,GAAgB,4BAAXnjB,EAAEkC,KAAqC,CAC3C,GAAKD,EACJ,MAAM,IAAIhZ,WAAYhP,EAAQ,mDAG/B+lB,EAAIuiB,GAAWntC,EAAKgiB,GAAK,EACzB,CACD,CACD,OAAO4I,CACR,CAsBSwjB,CAAkBzlC,EAAU3C,EAAMyO,EAAOpU,OAAQwsB,GAGlD,IACR,CC/GA,SAAS5U,GAASo2B,GACjB,OAcA,SAAc55B,EAAQ9L,EAAU2lC,GAC/B,GAAKlC,GAAiBzjC,GACrB,OCxBH,SAAqB8L,EAAQ9L,EAAU0lC,GACtC,OAAOA,EAAIvmC,OAAQ2M,EAAQi4B,GAAc/jC,EAAU8L,EAAOpU,OAAQguC,EAAIxhB,QACvE,CDsBU0hB,CAAY95B,EAAQ9L,EAAU0lC,GAEtC,GAAKG,GAAa/5B,EAAQ9L,KAAe6G,GAAU7G,GAClD,OE5BH,SAAmB8L,EAAQ9L,EAAU2lC,EAAUD,GAC9C,IAAI3uC,EAAQ+U,EAAQ9L,GACpB,OAAKsI,GAAYvR,GACXA,IAAU+U,EAAO/K,YACd2kC,EAAIrkC,KAYb,WACC,IAAIlF,EACAjF,EAGJ,IADAiF,EAAO,GACDjF,EAAI,EAAGA,EAAIkE,UAAU1D,OAAQR,IAClCiF,EAAKF,KAAMb,UAAWlE,IAEvB,OAAOH,EAAMuF,MAASqM,OAASg9B,EAAa75B,EAASnD,KAAMxM,EAC3D,EAjBMpF,CAkBR,CFEUw+B,CAAUzpB,EAAQ9L,EAAU2lC,EAAUD,GAE9C,GAAK/B,GAAoB3jC,GACxB,OGzBH,SAAsB8L,EAAQ9L,EAAU0lC,GACvC,IAAIlnC,EAAMslC,GAAY9jC,EAAU0lC,EAAItJ,OACpC,GAAkB,QAAb59B,EAAI6J,KACR,OAAOq9B,EAAII,aAAc/Y,GAAMjhB,EAAQtN,EAAIwQ,OAE5C,GAAkB,SAAbxQ,EAAI6J,KACR,OAAOq9B,EAAII,aAAc1b,GAAWte,EAAQtN,EAAIwQ,OAEjD,GAAkB,SAAbxQ,EAAI6J,KACR,OAAOq9B,EAAII,aAAc9a,GAAWlf,EAAQtN,EAAIwQ,OAEjD,MAAM,IAAItW,MAAOwD,EAAQ,iEAAkEsC,EAAI6J,MAChG,CHaU09B,CAAaj6B,EAAQ9L,EAAU0lC,GAEvC,OI7BF,SAAmB55B,EAAQ9L,EAAU0lC,GACpC,IAAIzjB,EAAIqjB,GAAYx5B,EAAQ9L,EAAU0lC,EAAIxhB,QAC1C,GAAW,OAANjC,EAIL,IACC,OAAOyjB,EAAII,aAAc/pC,GAAO+P,EAAQmW,EAAGyjB,EAAIxhB,QAC/C,CAAC,MAAQjnB,GAET,MAAM,IAAIA,EAAI8D,YAAaijC,GAAY/mC,EAAI+oC,SAC3C,CACF,CJiBSC,CAAUn6B,EAAQ9L,EAAU0lC,EACnC,CACF,CK1CA,SAASlQ,GAAU1pB,EAAQ9L,EAAUjJ,GAEpC,OADA+U,EAAQ9L,GAAajJ,GACd,CACR,CCYA,SAASuY,GAASo2B,GACjB,OAiBA,SAAc55B,EAAQ9L,EAAUjJ,EAAO4uC,GACtC,IAAIxuC,EAGJ,GAAKssC,GAAiBzjC,GACrB,OCxBH,SAAqB8L,EAAQ9L,EAAUjJ,EAAO2uC,GAC7C,IAAIzoC,EACAoD,EAGJ,GADApD,EAAMyoC,EAAIpC,UAAWvsC,EAAO2uC,EAAItmC,OAE/B,MAAMnC,EAQP,OALCoD,EADIqlC,EAAIQ,cACJR,EAAIQ,cAAenvC,GAEnBA,EAEL2uC,EAAIpmC,OAAQwM,EAAQi4B,GAAc/jC,EAAU8L,EAAOpU,OAAQguC,EAAIxhB,QAAU7jB,IAClE,CACR,CDSU8lC,CAAYr6B,EAAQ9L,EAAUjJ,EAAO2uC,GAE7C,GAAKG,GAAa/5B,EAAQ9L,KAAe6G,GAAU7G,GAClD,OAAOw1B,GAAU1pB,EAAQ9L,EAAUjJ,GAEpC,GAAK4sC,GAAoB3jC,GACxB,OEjBH,SAAsB8L,EAAQ9L,EAAUjJ,EAAO2uC,GAC9C,IAAIU,EACAzG,EACAnhC,EACAvB,EACAoD,EAIJ,GAFA7B,EAAMslC,GAAY9jC,EAAU0lC,EAAItJ,OAChCgK,EAAMV,EAAItmC,OAAS,UACdqH,GAAc1P,GAElBsJ,EAAItJ,MACE,CAGN,GADAkG,EAAMyoC,EAAIpC,UAAWvsC,EAAOqvC,GAE3B,MAAMnpC,EAQPoD,EAAIy6B,GALHz6B,EADIqlC,EAAIQ,cACJR,EAAIQ,cAAenvC,GAEnBA,EAGgBqvC,GACrBzG,EAAMyG,CACN,CACD,GAAkB,QAAb5nC,EAAI6J,KAAiB,CACzB,IACC6jB,GAAKpgB,EAAQtN,EAAIwQ,KAAM3O,EACvB,CAAC,MAAQpD,GACT,MAAM,IAAIA,EAAI8D,YAAaijC,GAAY/mC,EAAI+oC,SAC3C,CACD,OAAO,CACP,CACD,GAAkB,SAAbxnC,EAAI6J,KAAkB,CAC1B,IACC8iB,GAAOrf,EAAQtN,EAAIwQ,KAAM3O,EAAG,CAC3BunB,KAAQ,oBAET,CAAC,MAAQ3qB,GACT,MAAM,IAAIA,EAAI8D,YAAaijC,GAAY/mC,EAAI+oC,SAC3C,CACD,OAAO,CACP,CAKD,QAJa,IAARrG,IACJA,EAAMvgC,GAAOrI,IAAW,YAGnBwhB,GAAkBonB,EAAKyG,GAC5B,MAAM,IAAInrC,UAAWiB,EAAQ,+GAAgHyjC,EAAKyG,IAMnJ,GAHK/f,GAAmB+f,IAASztB,GAAgBgnB,KAChDt/B,EAAIslB,GAAStlB,EAAG+lC,IAEC,SAAb5nC,EAAI6J,KAAkB,CAE1B,IACCmlB,GAAOhvB,EAAIwQ,KAAMlD,EAAQzL,EAAGyL,EAAQ,EAAG,EACvC,CAAC,MAAQ7O,GACT,MAAM,IAAIA,EAAI8D,YAAaijC,GAAY/mC,EAAI+oC,SAC3C,CACD,OAAO,CACP,CACD,MAAM,IAAIttC,MAAOwD,EAAQ,iEAAkEsC,EAAI6J,MAChG,CFjDUg+B,CAAav6B,EAAQ9L,EAAUjJ,EAAO2uC,GAG9C,GADAvuC,EG3BF,SAAmB2U,EAAQ9L,EAAUjJ,EAAO4uC,EAAUD,GACrD,IAAIzoC,EACAglB,EACA5hB,EAGJ,GAAW,QADX4hB,EAAIqjB,GAAYx5B,EAAQ9L,EAAU0lC,EAAIxhB,SAGrC,OAAO,EAER,GAAKzd,GAAc1P,GAElBsJ,EAAItJ,MACE,CAGN,GADAkG,EAAMyoC,EAAIpC,UAAWvsC,EAAO2uC,EAAItmC,OAE/B,MAAMnC,EAGPoD,EAAIy6B,GAAc/jC,EAAO2uC,EAAItmC,OAAS,UACtC,CACD,IACC2mB,GAAa1lB,EAAGslC,EAAU1jB,EAAGyjB,EAAIxhB,OACjC,CAAC,MAAQjnB,GACT,MAAM,IAAIA,EAAI8D,YAAaijC,GAAY/mC,EAAI+oC,SAC3C,CACD,OAAO,CACR,CHDQM,CAAUx6B,EAAQ9L,EAAUjJ,EAAO4uC,EAAUD,GAC9CvuC,EACJ,OAAOA,EAGR,OAAOq+B,GAAU1pB,EAAQ9L,EAAUjJ,EACnC,CACF,CIVA,SAASuY,KACR,IAAIi3B,EACAtpC,EAGJ,GADAspC,ECxCO,CACNnK,MAASK,GACTvY,QAAU,GDuCN9oB,UAAU1D,SACduF,EAAM0/B,GAAU4J,EAASnrC,UAAW,KAEnC,MAAM6B,EAGR,OAoCA,SAAS4lC,EAAa78B,GACrB,IAAIuH,EACAtQ,EACAsB,EACAgQ,EACAI,EACJ,KErFoB5X,EFqFDiP,EEnFnBjP,SAEiB,mBAAVA,GACiB,iBAAjBA,EAAMW,QACbqO,GAAWhP,EAAMW,SACjBX,EAAMW,QAAU,GAChBX,EAAMW,QAAU6O,IF6EWE,GAAcT,IACxC,MAAM,IAAI/K,UAAWiB,EAAQ,oEAAqE8J,IEtFrG,IAAsBjP,EFwFpB,GAAKorC,GAAkB,CAEtB,GADA50B,EAAO0D,GAAQ,GAAIs1B,GACdnrC,UAAU1D,OAAS,IACvBuF,EAAM0/B,GAAUpvB,EAAMnS,UAAW,KAEhC,MAAM6B,EAoBR,OAfA0R,EAAI,CACHsM,IAAOjV,EACP5G,MAHDmP,GADAhQ,EAAMwQ,GAAkB/I,IACf5G,OAAS,GAIjBD,OAAUZ,EAAI+P,UAAW,GACzBhP,OAAUf,EAAI+P,UAAW,GACzB43B,cAAiBM,GAAmBj4B,GACpCu3B,aAAgBW,GAAiB5D,EAAat1B,GAC9C6uB,MAAS7uB,EAAK6uB,MACdlY,OAAU3W,EAAK2W,OACfof,UAAaA,GAAW/0B,GACxBs0B,YAAeA,EACfxhC,KAAQ,IAAI6gC,GAAOl8B,EAAEjF,aAAe1G,MAAO,CAC1CqsC,UAAarlC,GAAMwhC,EAAat1B,MAG3B,IAAI20B,GAAOl8B,EAAG,CACpBrI,IAAOA,GAAKgR,GACZ/Q,IAAOA,GAAK+Q,IAEb,CAGD,OADAg4B,QAAQC,KAAM,8HACP5gC,CACP,CACF,CGtGA,IAAI68B,GAAcvzB,KCHlBxR,EAAAnH,GAAA,UAAA2Y,IACAxR,EAAAnH,GAAA,MAAA8lC,IC3BA,IAAIvN,GAAgBb,GAAS1wB,IAAK,kBAC9BsE,GAAiBsO,GAAO,aACxBrO,GAAkBqO,GAAO,cACzBpO,GAAeoO,GAAO,QCP1B,IAAIA,GAAQ,CACXhR,WAAc2C,GACd1C,UAAayC,ICUd,SAASsO,GAAOnR,GACf,OAAOmmB,GAAOnmB,IAAW,IAC1B,CCbA,IAAI8vB,GAAgBb,GAAS1wB,IAAK,iCCIlC,IAAI4S,GAAQ,CACX5R,MAAS+C,GACThD,MAASiD,GACT/C,KAAQgD,GACR9C,OAAU+C,GACVhD,OAAUiD,GACV/C,MAASgD,GACT/C,OAAUgD,ICXX,IAAIktB,GAAgBb,GAAS1wB,IAAK,eCMlC,IAAI4S,GAAQ,CACXjS,QAAWmD,GACXhD,QAAW+C,GACX7C,MAAS+C,GACThD,MAASiD,GACT/C,KAAQgD,GACR9C,OAAU+C,GACVhD,OAAUiD,GACV/C,MAASgD,GACT/C,OAAUgD,IChBX,IAAIuO,GAAQ,CACXjS,QAAWmD,GACXhD,QAAW+C,ICDZ,IAAI+O,GAAQ,CACX5R,MAAS+C,GACThD,MAASiD,GACT/C,KAAQgD,ICFT,IAAI2O,GAAQ,CACXzR,OAAU+C,GACVhD,OAAUiD,GACV/C,MAASgD,GACT/C,OAAUgD,ICJX,IAAIktB,GAAgBb,GAAS1wB,IAAK,kBAsBlC,SAASklB,GAAQ5rB,GAChB,IAAImI,EACJ,IAAMgH,GAAsBnP,GAC3B,MAAM,IAAIgE,UAAWiB,EAAQ,+EAAgFjF,IAE9G,GAAKmE,UAAU1D,OAAS,GAEvB,GAAe,aADf0H,EAAQhE,UAAW,IAElB,OAAO/C,GAAMpB,QAGdmI,EAAQ8vB,GAET,OAAO72B,GAAK4Y,OAAQja,GAAOC,EAAGmI,GAAS,EAAG,EAC3C,CC/BA,IAAAga,GAAA,CAAA,EAWAtb,EAAAsb,GAAA,mBAAA/S,IAWAvI,EAAAsb,GAAA,yBAAA5S,IClBI,IAAA4S,GAAK,CAAG,SAUZtb,EAAasb,GAAI,OAAQ/gB,IAUzByF,EAAasb,GAAI,eAAgBjX,IAUjCrE,EAAasb,GAAI,cAAezS,IAUhC7I,EAAasb,GAAI,aAAcvF,IAU/B/V,EAAasb,GAAI,kBC7CjB,SAAyBpT,EAAG/O,GAC3B,IAAMwP,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,8EAA+E8J,IAE7G,IAAMI,GAAsBnP,GAC3B,MAAM,IAAIgE,UAAWiB,EAAQ,gFAAiFjF,IAE/G,OAAOoB,GAAM2N,EAAG/O,EACjB,ID+CA6G,EAAasb,GAAI,oBEvDjB,SAA2B+I,EAAIC,GAC9B,IAAM3b,GAAc0b,GACnB,MAAM,IAAIlnB,UAAWiB,EAAQ,8EAA+EimB,IAE7G,IAAM1b,GAAc2b,GACnB,MAAM,IAAInnB,UAAWiB,EAAQ,+EAAgFkmB,IAE9G,OAAO/pB,GAAM8pB,EAAIC,EAClB,IFyDAtkB,EAAasb,GAAI,mBGpEjB,SAA0BpT,GACzB,IAAMS,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,8EAA+E8J,IAE7G,OAAO3N,GAAM2N,EACd,IHyEAlI,EAAasb,GAAI,iBAAkBnX,IAUnCnE,EAAasb,GAAI,kBAAmBlX,IAUpCpE,EAAasb,GAAI,UAAWuM,IAU5B7nB,EAAasb,GAAI,eIvGjB,SAAsBpT,EAAGiK,GACxB,IAAI7Q,EAAQ0mB,GAAS7V,GACrB,GAAe,OAAV7Q,EACJ,MAAM,IAAInE,UAAWiB,EAAQ,yGAA0GkD,EAAO6Q,IAE/I,OAAO0V,GAAS3f,EAAG5G,EACpB,IJ2GAtB,EAAasb,GAAI,QAAS7I,IAU1BzS,EAAasb,GAAI,WAAYme,IAU7Bz5B,EAAasb,GAAI,apNzEjB,SAAoBrN,EAAO6X,EAAMlsB,EAAQ4V,GACxC,IAAIC,EACA5M,EACAgL,EACApN,EACA4N,EACAC,EACAV,EACAgP,EACAxjB,EASJ,GAPAyJ,EAAM,IACNgL,GAAM,EACN4B,EAAO,CACNuqB,MAAS,SAEV/rB,EAAQksB,GAAWlsB,EAAO,SAC1B6X,EAAOqU,GAAWrU,EAAM,QACnBxoB,UAAU1D,OAAS,EAAI,CAc3B,GAb0B,IAArB0D,UAAU1D,OACTiO,GAAUjO,GACd6V,EAAO7V,GAEPiJ,EAAMjJ,EAGNiU,GAAM,IAGP4B,EAAOD,EACP3M,EAAMjJ,GAEM,IAARiJ,EACJ,MAAO,GAER,IAAMoF,GAAWpF,IAASA,EAAM,EAC/B,MAAM,IAAI1F,UAAWiB,EAAQ,oEAAqEyE,IAEnG,GAAKgL,EAAM,CACV,IAAMhG,GAAU4H,GACf,MAAM,IAAItS,UAAWiB,EAAQ,qEAAsEqR,IAEpG,GAAKxN,GAAYwN,EAAM,SAAY,CAClC,IAAM1G,GAAU0G,EAAKuqB,OACpB,MAAM,IAAI78B,UAAWiB,EAAQ,8DAA+D,QAASqR,EAAKuqB,QAE3G,IAAyC,IAApCE,GAAS78B,QAASoS,EAAKuqB,OAC3B,MAAM,IAAIp/B,MAAOwD,EAAQ,gFAAiF,QAAS87B,GAASvrB,KAAM,QAAUc,EAAKuqB,OAElJ,CACD,CACD,CACD,OAASvqB,EAAKuqB,OACd,IAAK,QACJ1rB,EAAM0rB,GACN,MACD,IAAK,OACJ1rB,EAAMgY,GACN,MAED,QACChY,EAAMtG,GAaP,IARAqG,EAAMxL,EAAM,EACZ+Z,GAAMkJ,EAAKijB,UAAY96B,EAAM86B,WAAc16B,EAI3CT,EAAMK,GADNxN,EAAM,IAAIlE,MAAOsG,IAEZ,GAAM+K,EACXA,EAAMA,EAAIm7B,UACJ3vC,EAAI,EAAGA,EAAIiV,EAAKjV,IACrBwU,GAAOgP,EACPnc,EAAKrH,GAAM,IAAIghC,KAAM9rB,EAAKV,IAG3B,OADAnN,EAAK4N,GAAQyX,EACNrlB,CACR,IoNGAT,EAAasb,GAAI,WAAYiV,IAU7BvwB,EAAasb,GAAI,QAASha,IAU1BtB,EAAasb,GAAI,SAAU9F,IAU3BxV,EAAasb,GAAI,QAASwf,IAU1B96B,EAAasb,GAAI,aKxLjB,SAAoBpT,GACnB,IAAIuI,EAAKnP,GAAO4G,GAChB,GAAY,OAAPuI,EACJ,MAAM,IAAItT,UAAWiB,EAAQ,8GAA+G8J,IAK7I,OAHK5K,UAAU1D,OAAS,IACvB6W,EAAKnT,UAAW,IAEVw9B,GAAO5yB,EAAEtO,OAAQ6W,EACzB,ILyLAzQ,EAAasb,GAAI,U7L5DjB,WACC,IAAIriB,EACAiU,EACA5L,EACAiC,EACA9C,EACAoC,EACApI,EAWJ,GATAyS,EAAQ5P,UAAU1D,QAClBsT,GAAS,IACK,GAAKnE,GAAUzL,UAAW4P,KACvC5L,EAAQhE,UAAW4P,GACnBA,GAAS,GAET5L,EAAQ8vB,GAGK,QADd7tB,EAAOkP,GAAOnR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,sEAAuEkD,IAErG,GAAe,YAAVA,EAAsB,CAC1B,GAAK4L,GAAS,EACb,MAAO,GAIR,GAFAjU,EAAQqE,UAAW,GACnB7C,EAAM6C,UAAW,GACF,IAAV4P,EAAc,CAMlB,GALK5E,GAAsB7N,GAC1BoI,EAAMpI,EACKkO,GAAclO,KACzBoI,EAAMpI,EAAIb,aAEE,IAARiJ,EACJ,OAAO4Y,GAAQxiB,EAAO4J,GAEvB,GAAKiG,GAAerO,GACnB,MAAM,IAAIG,MAAO,qFAElB,GAAKiN,GAAUpN,GAAQ,CACtB,IAA6B,IAAxBkS,GACJ,MAAM,IAAIxP,UAAWiB,EAAQ,sIAAuI3D,IAErK,IAAM+P,GAAY/P,EAAK+S,KACtB,MAAM,IAAIrQ,UAAWiB,EAAQ,wGAAyG3D,IAGvI,IAAM+P,IADN/P,EAAMA,EAAK+S,OACWjB,MACrB,MAAM,IAAIpP,UAAWiB,EAAQ,wGAAyG3D,IAEvI,OA7KJ,SAAyB6R,EAAIrT,GAC5B,IAAIwH,EAIJ,IADAA,EAAM,IAED6L,EAAGC,OACAC,MAGP/L,EAAItC,KAAMlF,GAEX,OAAOwH,CACR,CAgKWuoC,CAAgBvuC,EAAKxB,EAC5B,CACD,MAAM,IAAIkE,UAAWiB,EAAQ,wGAAyG3D,GACzI,CAAS,GAAKqO,GAAerO,GAC1B,MAAM,IAAIG,MAAO,qFAElB,MAAM,IAAIuC,UAAWiB,EAAQ,wGAAyG3D,GACtI,CACD,GAAKyS,GAAS,EACb,OAAO,IAAI3J,EAAM,GAElB,GAAe,IAAV2J,EAEJ,GAAKvE,GADLlO,EAAM6C,UAAW,IAEhBmD,EAAM,IAAI8C,EAAM9I,EAAIb,aACd,GAAKkP,GAAerO,GAC1BgG,EAAM,IAAI8C,EAAM9I,QACV,GAAK6N,GAAsB7N,GACjCgG,EAAM,IAAI8C,EAAM9I,OACV,KAAKoN,GAAUpN,GAarB,MAAM,IAAI0C,UAAWiB,EAAQ,wGAAyG3D,IAZtI,IAA6B,IAAxBkS,GACJ,MAAM,IAAIxP,UAAWiB,EAAQ,sIAAuI3D,IAErK,IAAM+P,GAAY/P,EAAK+S,KACtB,MAAM,IAAIrQ,UAAWiB,EAAQ,wGAAyG3D,IAGvI,IAAM+P,IADN/P,EAAMA,EAAK+S,OACWjB,MACrB,MAAM,IAAIpP,UAAWiB,EAAQ,wGAAyG3D,IAEvIgG,EAAM,IAAI8C,EAAM83B,GAAY5gC,GAG5B,MAEDgG,EADqB,IAAVyM,EACL,IAAI3J,EAAMjG,UAAU,GAAIA,UAAU,IAElC,IAAIiG,EAAMjG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IAYvD,OAVKmD,EAAI7G,OAAS,IACjBX,EAAQqE,UAAW,GACdirB,GAAmBjnB,GA/L1B,SAA0Bb,EAAKxH,GAC9B,IAAIG,EACJ,IAAMA,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5BqH,EAAIX,IAAK7G,EAAOG,EAGlB,CA0LG6vC,CAAiBxoC,EAAKxH,GACX0c,GAAmBrU,GAC9B45B,GAAOz6B,EAAI7G,OAAQ,EAAY,EAAI,EAAGs2B,GAAiBzvB,EAAK,GAAK,GAEjEy6B,GAAOz6B,EAAI7G,OAAQX,EAAOwH,EAAK,IAG1BA,CACR,I6L9BAT,EAAasb,GAAI,YxLJjB,WACC,IAAI5N,EACAR,EACA5L,EACAqM,EACApK,EACA9C,EACAoC,EACApI,EAKJ,GAAe,KAHfyS,EAAQ5P,UAAU1D,QAKjB,OAAO,IADP2J,EAAOkP,GAAO2e,KACG,GAIlB,GAAKroB,GADLzH,EAAQhE,UAAW,IACM,CAExB,GAAK4P,EAAQ,EACZ,MAAM,IAAI/P,UAAW,6FAGtB,GAAc,QADdoG,EAAOkP,GAAOnR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,sEAAuEkD,IAGrG,OAAO,IAAIiC,EAAM,EACjB,CAED,GAAK2J,EAAQ,EACZ,MAAM,IAAI/P,UAAW,6FAMtB,GAAKqN,GAAYlN,UAHjB4P,GAAS,IAKR,GAAK1C,GAAYlN,UAAW4P,EAAM,KAMjC,GALAQ,EAAUpQ,UAAW4P,GAErBS,EAAOrQ,UADP4P,GAAS,GAIM,IAAVA,EACJ,MAAM,IAAI/P,UAAW,kGAItBwQ,EAAOrQ,UAAW4P,OAIf,MAAKA,GAAS,GAUlB,MAAM,IAAI/P,UAAW,6FANrB,GAHAuQ,EAAUpQ,UAAW4P,IAGf1C,GADNmD,EAAOrQ,UADP4P,GAAS,IAGR,MAAM,IAAI/P,UAAWiB,EAAQ,uEAAwEuP,GAMtG,CAUD,IARAT,GAAS,IACK,GAAKnE,GAAUzL,UAAW4P,KACvC5L,EAAQhE,UAAW4P,GACnBA,GAAS,GAET5L,EAAQ8vB,GAGK,QADd7tB,EAAOkP,GAAOnR,IAEb,MAAM,IAAInE,UAAWiB,EAAQ,sEAAuEkD,IAGrG,GAAe,YAAVA,EAAsB,CAE1B,GADA7G,EAAM6C,UAAW,GACF,IAAV4P,EAAc,CAMlB,GALK5E,GAAsB7N,GAC1BoI,EAAMpI,EACKkO,GAAclO,KACzBoI,EAAMpI,EAAIb,aAEE,IAARiJ,EACJ,OAAOqmC,GAAarmC,EAAK8K,EAAMD,GAEhC,GAAK5E,GAAerO,GACnB,MAAM,IAAIG,MAAO,qFAElB,GAAKiN,GAAUpN,GAAQ,CACtB,IAA6B,IAAxBkS,GACJ,MAAM,IAAIxP,UAAWiB,EAAQ,sIAAuI3D,IAErK,IAAM+P,GAAY/P,EAAK+S,KACtB,MAAM,IAAIrQ,UAAWiB,EAAQ,wGAAyG3D,IAGvI,IAAM+P,IADN/P,EAAMA,EAAK+S,OACWjB,MACrB,MAAM,IAAIpP,UAAWiB,EAAQ,wGAAyG3D,IAEvI,OAvSJ,SAA8B6R,EAAIqB,EAAMD,GACvC,IAAIjN,EACArH,EAKJ,IAFAqH,EAAM,GACNrH,GAAK,GAEAkT,EAAGC,OACAC,MAGPpT,GAAK,EACLqH,EAAItC,KAAMwP,EAAKzS,KAAMwS,EAAStU,IAE/B,OAAOqH,CACR,CAuRW0oC,CAAqB1uC,EAAKkT,EAAMD,EACvC,CACD,MAAM,IAAIvQ,UAAWiB,EAAQ,wGAAyG3D,GACzI,CAAS,GAAKqO,GAAerO,GAC1B,MAAM,IAAIG,MAAO,qFAElB,MAAM,IAAIuC,UAAWiB,EAAQ,wGAAyG3D,GACtI,CACD,GAAe,IAAVyS,EAEJ,GAAKvE,GADLlO,EAAM6C,UAAW,IAEhBmD,EAAM,IAAI8C,EAAM9I,EAAIb,aACd,GAAKkP,GAAerO,GAC1BgG,EAAM,IAAI8C,EAAM9I,QACV,GAAK6N,GAAsB7N,GACjCgG,EAAM,IAAI8C,EAAM9I,OACV,KAAKoN,GAAUpN,GAarB,MAAM,IAAI0C,UAAWiB,EAAQ,wGAAyG3D,IAZtI,IAA6B,IAAxBkS,GACJ,MAAM,IAAIxP,UAAWiB,EAAQ,sIAAuI3D,IAErK,IAAM+P,GAAY/P,EAAK+S,KACtB,MAAM,IAAIrQ,UAAWiB,EAAQ,wGAAyG3D,IAGvI,IAAM+P,IADN/P,EAAMA,EAAK+S,OACWjB,MACrB,MAAM,IAAIpP,UAAWiB,EAAQ,wGAAyG3D,IAEvIgG,EAAM,IAAI8C,EAAM83B,GAAY5gC,GAG5B,MAEDgG,EADqB,IAAVyM,EACL,IAAI3J,EAAMjG,UAAU,GAAIA,UAAU,IAElC,IAAIiG,EAAMjG,UAAU,GAAIA,UAAU,GAAIA,UAAU,IASvD,OAPKmD,EAAI7G,OAAS,IACZ2uB,GAAmBjnB,IAAWqU,GAAmBrU,GAjTxD,SAA0Bb,EAAKkN,EAAMD,GACpC,IAAItU,EACJ,IAAMA,EAAI,EAAGA,EAAIqH,EAAI7G,OAAQR,IAC5BqH,EAAIX,IAAK6N,EAAKzS,KAAMwS,EAAStU,GAAKA,EAGpC,CA4SG6vC,CAAiBxoC,EAAKkN,EAAMD,GAE5B4tB,GAAS76B,EAAI7G,OAAQ6G,EAAK,GAe5B,SAAmBxH,EAAOmwC,GACzB,OAAOz7B,EAAKzS,KAAMwS,EAAS07B,EAC3B,KAdM3oC,CAeR,IwLtJAT,EAAasb,GAAI,qBAAsBulB,IAUvC7gC,EAAasb,GAAI,iBAAkBqhB,IAUnC38B,EAAasb,GAAI,iBAAkBshB,IAUnC58B,EAAasb,GAAI,eAAgB5X,IAUjC1D,EAAasb,GAAI,eAAgB3X,IAUjC3D,EAAasb,GAAI,kBM/PjB,WACC,IAAI1P,EACA8B,EACAY,EACAjV,EACAwJ,EACA/C,EACA2Q,EACArX,EACAmJ,EAGJ,GADAqJ,EAAWtO,UAAW,GACjBA,UAAU1D,OAAS,EACvB,GAAK+O,GAAcrL,UAAW,KAE7B,GADAjE,EAAMiE,UAAW,GACZA,UAAU1D,OAAS,EAAI,CAE3B,IAAM4Q,GADN8D,EAAMhR,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,uEAAwEkQ,IAEtGZ,EAAUpQ,UAAW,EACrB,MACK,CAEN,IAAMkN,GADN8D,EAAMhR,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,uEAAwEkQ,IAEtGZ,EAAUpQ,UAAW,EACrB,CAEF,IAAM89B,GAAgBxvB,GACrB,MAAM,IAAIzO,UAAWiB,EAAQ,kGAAmGwN,IAGjI,GADAxS,GAAK,OACQ,IAARC,EAAiB,CAErB,GADAA,EAAM,GACDiV,EAAM,CACV,KACClV,GAAK,IACLmJ,EAAIqJ,EAASW,QACNC,MAGPnT,EAAI8E,KAAMmQ,EAAIpT,KAAMwS,EAASnL,EAAEtJ,MAAOG,IAEvC,OAAOC,CACP,CACD,OACCkJ,EAAIqJ,EAASW,QACNC,MAGPnT,EAAI8E,KAAMoE,EAAEtJ,OAEb,OAAOI,CACP,CAQD,GAPAwJ,EAAMxJ,EAAIO,OACV6W,EAAKnP,GAAOjI,GAEXyG,EADIQ,EAAiBjH,GACfsX,EAAgBF,GAEhBjP,EAAQiP,GAEVnC,EAAM,CACV,KAAQlV,EAAIyJ,EAAI,IACfzJ,GAAK,IACLmJ,EAAIqJ,EAASW,QACNC,OAGP1M,EAAKzG,EAAKD,EAAGkV,EAAIpT,KAAMwS,EAASnL,EAAEtJ,MAAOG,IAE1C,OAAOC,CACP,CACD,KAAQD,EAAIyJ,EAAI,IACfzJ,GAAK,IACLmJ,EAAIqJ,EAASW,QACNC,OAGP1M,EAAKzG,EAAKD,EAAGmJ,EAAEtJ,OAEhB,OAAOI,CACR,INsLA2G,EAAasb,GAAI,eAAgB0hB,IAUjCh9B,EAAasb,GAAI,OAAQ2hB,IAUzBj9B,EAAasb,GAAI,YOnSjB,SAAmBpT,EAAGjP,GACrB,IAAIwX,EACAlO,EAGJ,GAAY,QADZkO,EAAKnP,GAAO4G,IAEX,MAAM,IAAI/K,UAAWiB,EAAQ,8GAA+G8J,IAgB7I,OAdK5K,UAAU1D,OAAS,IACvB6W,EAAKnT,UAAW,IAIfiF,EAFoB,iBAAVtJ,EACC,eAAPwX,EACA,IAAI/F,GAAYzR,EAAO,GACT,cAAPwX,EACP,IAAIrF,GAAWnS,EAAO,GAEtBA,EAGDA,EAEEgkC,GAAM/0B,EAAEtO,OAAQ2I,EAAGkO,EAC3B,IPsRAzQ,EAAasb,GAAI,aQ9SjB,SAAoB+I,EAAIC,EAAIqH,GAC3B,IACInF,EACJ,IAAMxtB,GAAUqrB,IAAQ7nB,GAAO6nB,GAC9B,MAAM,IAAIlnB,UAAWiB,EAAQ,wDAAyDimB,IAEvF,IAAMrrB,GAAUsrB,IAAQ9nB,GAAO8nB,GAC9B,MAAM,IAAInnB,UAAWiB,EAAQ,uDAAwDkmB,IAEtF,GAAKhnB,UAAU1D,OAAS,EACvB4sB,EAAM,OAGN,IAAMxtB,GADNwtB,EAAMmF,IACmBnvB,GAAOgqB,GAC/B,MAAM,IAAIrpB,UAAWiB,EAAQ,4DAA6DooB,IAI5F,GADMF,IAAQhC,EAAGD,GAAOmC,GACb/d,GACV,MAAM,IAAI2E,WAAY,oEAEvB,OAAOi8B,GAAKhlB,EAAIC,EAAIkC,EACrB,IRkSAxmB,EAAasb,GAAI,aAAcqjB,IAU/B3+B,EAAasb,GAAI,YAAaxX,IAU9B9D,EAAasb,GAAI,aAAc1X,IAU/B5D,EAAasb,GAAI,aAAczX,IAU/B7D,EAAasb,GAAI,WAAY+jB,IAU7Br/B,EAAasb,GAAI,sBAAuBguB,IAUxCtpC,EAAasb,GAAI,iBAAkB2lB,IAUnCjhC,EAAasb,GAAI,iBAAkB4lB,IAUnClhC,EAAasb,GAAI,YS1YjB,SAAmBpL,EAAGC,EAAGtN,GACxB,IAAM7J,GAAUkX,IAAO1T,GAAO0T,GAC7B,MAAM,IAAI/S,UAAWiB,EAAQ,0EAA2E8R,IAEzG,IAAMlX,GAAUmX,IAAO3T,GAAO2T,GAC7B,MAAM,IAAIhT,UAAWiB,EAAQ,yEAA0E+R,IAExG,GAAK7S,UAAU1D,OAAS,EACvBiJ,EAAM,QACA,IAAMyF,GAAsBzF,GAClC,MAAM,IAAI1F,UAAWiB,EAAQ,uEAAwEyE,IAEtG,OAAOwmC,GAAKn5B,EAAGC,EAAGtN,EACnB,ITuYA7C,EAAasb,GAAI,cAAekmB,IAUhCxhC,EAAasb,GAAI,kBAAmBrB,IAUpCja,EAAasb,GAAI,YAAagR,IAU9BtsB,EAAasb,GAAI,UUtYjB,SAAiBpT,EAAGqkB,EAAM3c,GACzB,IAAIH,EACAtQ,EACAipB,EACAyZ,EACJ,IAAMl5B,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,8EAA+E8J,IAE7G,IAAMS,GAAc4jB,GACnB,MAAM,IAAIpvB,UAAWiB,EAAQ,+EAAgFmuB,IAE9G,IAAM5jB,GAAciH,GACnB,MAAM,IAAIzS,UAAWiB,EAAQ,8EAA+EwR,IAG7G,GADAH,ECvEO,CACNqa,KAAQ,UDuEJxsB,UAAU1D,OAAS,IACvBuF,EhI7CF,SAAmBsQ,EAAMD,GACxB,OAAM3H,GAAU2H,GAGXvN,GAAYuN,EAAS,UACzBC,EAAKqa,KAAOta,EAAQsa,MACd2X,GAAQhyB,EAAKqa,OACX,IAAI3sB,UAAWiB,EAAQ,gFAAiF,OAAQ2vB,GAAMpf,KAAM,QAAUc,EAAKqa,OAG7I,KARC,IAAI3sB,UAAWiB,EAAQ,qEAAsEoR,GAStG,CgIkCQqvB,CAAUpvB,EAAMnS,UAAW,IAC5B6B,GACJ,MAAMA,EAOR,GAJAipB,EAAM9mB,GAAO4G,IAAO,WAIduS,GAHNonB,EAAMvgC,GAAOsO,IAAY,UAGIwY,GAC5B,MAAM,IAAIjrB,UAAWiB,EAAQ,6GAA8GyjC,EAAKzZ,IAOjJ,OAJKG,GAAmBH,IAASvN,GAAgBgnB,KAChDjyB,EAASiY,GAASjY,EAAQwY,IAGpB7tB,GAAM2N,EAAGqkB,EAAM3c,EAAQH,EAAKqa,KACpC,IV8WA9pB,EAAasb,GAAI,YAAa4R,IAU9BltB,EAAasb,GAAI,QpHzbjB,SAAe1hB,GACd,IAAI0H,EAGJ,GAAKhE,UAAU1D,OAAS,GAEvB,IAAMgoC,GADNtgC,EAAQhE,UAAW,IAElB,MAAM,IAAIH,UAAWiB,EAAQ,qFAAsFiS,GAAO1B,KAAM,QAAUrN,SAG3IA,EAAQ8vB,GAST,OAAO6L,GAAMrjC,EAPE,eAAV0H,EACIogC,GACa,cAAVpgC,EACHqgC,GAEAj9B,IAEmBpD,EAC7B,IoH+aAtB,EAAasb,GAAI,YnHvcjB,SAAmBpT,GAClB,IAAIuI,EACAlO,EAGJ,GAAY,QADZkO,EAAKnP,GAAO4G,IAEX,MAAM,IAAI/K,UAAWiB,EAAQ,8GAA+G8J,IAE7I,GAAK5K,UAAU1D,OAAS,GAEvB,GADA6W,EAAKnT,UAAW,IACe,IAA1B+S,GAAOhT,QAASoT,GACpB,MAAM,IAAItT,UAAWiB,EAAQ,qFAAsFiS,GAAO1B,KAAM,QAAU8B,SAErI,IAA+B,IAA1BJ,GAAOhT,QAASoT,GAC3B,MAAM,IAAItT,UAAWiB,EAAQ,+FAAgGiS,GAAO1B,KAAM,QAAU8B,IASrJ,OANClO,EADW,eAAPkO,EACAixB,GACc,cAAPjxB,EACPkxB,GAEAj9B,IAEEu4B,GAAM/0B,EAAEtO,OAAQ2I,EAAGkO,EAC3B,ImHybAzQ,EAAasb,GAAI,gBYzcjB,SAAuBha,GACtB,OAA0B,IAArBhE,UAAU1D,OA7BhB,WACC,IAAI4b,EACA0E,EACA7gB,EACAD,EAKJ,IAHAC,EAAM,CAAA,EAEN6gB,GADA1E,EAAS8D,GAAYiwB,KACL3vC,OACVR,EAAI,EAAGA,EAAI8gB,EAAQ9gB,IACxBC,EAAKmc,EAAOpc,IAAOmwC,GAAa/zB,EAAOpc,IAExC,OAAOC,CACR,CAiBSkhB,GAEHtY,GAAYsnC,GAAajoC,GACtBioC,GAAajoC,GAEd,IACR,IZ2cAtB,EAAasb,GAAI,QAAS8R,IAU1BptB,EAAasb,GAAI,aa9ejB,SAAoBpT,GACnB,IAAIuI,EAAKnP,GAAO4G,GAChB,GAAY,OAAPuI,EACJ,MAAM,IAAItT,UAAWiB,EAAQ,8GAA+G8J,IAK7I,OAHK5K,UAAU1D,OAAS,IACvB6W,EAAKnT,UAAW,IAEV8vB,GAAOllB,EAAEtO,OAAQ6W,EACzB,Ib+eAzQ,EAAasb,GAAI,QjHhfjB,SAAe1hB,GACd,IAAI0H,EAeJ,OAAO27B,GAAMrjC,EAPE,gBAJd0H,EADIhE,UAAU1D,OAAS,EACf0D,UAAW,GAEX8zB,IAGAsQ,GACa,cAAVpgC,EACHqgC,GAEA,EAEmBrgC,EAC7B,IiHyeAtB,EAAasb,GAAI,YhH1fjB,SAAmBpT,GAClB,IAAIuI,EACAlO,EAGJ,GAAY,QADZkO,EAAKnP,GAAO4G,IAEX,MAAM,IAAI/K,UAAWiB,EAAQ,8GAA+G8J,IAY7I,OAVK5K,UAAU1D,OAAS,IACvB6W,EAAKnT,UAAW,IAGhBiF,EADW,eAAPkO,EACAixB,GACc,cAAPjxB,EACPkxB,GAEA,EAEE1E,GAAM/0B,EAAEtO,OAAQ2I,EAAGkO,EAC3B,IgHifAzQ,EAAasb,GAAI,QAAS+R,IAU1BrtB,EAAasb,GAAI,iBAAkBkoB,IAUnCxjC,EAAasb,GAAI,kBczfjB,SAAyBkuB,EAAQC,GAChC,IAAI54B,EACJ,OAA0B,IAArBvT,UAAU1D,OAnDhB,WACC,IAAI4b,EACA0E,EACA7gB,EACAuU,EACAuM,EACAC,EACAvJ,EACA3T,EACA9D,EAKJ,IAHAC,EAAM,CAAA,EAEN6gB,GADA1E,EAAS8D,GAAYowB,KACL9vC,OACVR,EAAI,EAAGA,EAAI8gB,EAAQ9gB,IAAM,CAI9B,IAHA+gB,EAAM3E,EAAQpc,GACdyX,EAAI64B,GAAiBvvB,GACrBvM,EAAM,CAAA,EACA1Q,EAAI,EAAGA,EAAIgd,EAAQhd,IAExB0Q,EADAwM,EAAM5E,EAAQtY,IACD2T,EAAGuJ,GAEjB/gB,EAAK8gB,GAAQvM,CACb,CACD,OAAOvU,CACR,CA2BSihB,IAERkvB,EAAS5vB,GAAS4vB,GACbvnC,GAAYynC,GAAiBF,IAG5BvnC,GAFL4O,EAAI64B,GAAiBF,GACrBC,EAAS7vB,GAAS6vB,IAEV54B,EAAG44B,GAGL,KACR,IdqfAzpC,EAAasb,GAAI,MAAO8S,IAUxBpuB,EAAasb,GAAI,qBevjBjB,SAA2B3C,EAAK1f,GAC/B,IAAIsK,EACJ,OACCtK,GACAA,EAAMsR,MACNjO,GAASrD,EAAMiY,QAEf3N,EAAOkP,GAAOxZ,EAAMsR,OAEZ,IAAIhH,EAAMtK,EAAMiY,MAGlBjY,CACR,IfojBA+G,EAAasb,GAAI,YAAaP,IAU9B/a,EAAasb,GAAI,gBAAiBJ,IAUlClb,EAAasb,GAAI,SzF/gBjB,SAAqB7a,GACpB,IAAIkb,EACAc,EAEJ,IAAMjU,GAAmB/H,GACxB,MAAM,IAAItD,UAAWiB,EAAQ,oEAAqEqC,IAcnG,OARA+b,GAHAb,EAAQ,CAAElb,EAAI7G,QAGE6G,IAChBgc,EAAQd,EAAM/hB,QAGD,IAEZ+hB,EAAM/hB,OAAS2d,GAAOkF,EAAOd,EAAO,EAAGlb,EAAKgc,EAAQ,IAE9Cd,CACR,IyFqgBA3b,EAAasb,GAAI,oBAAqBooB,IAUtC1jC,EAAasb,GAAI,SgBvlBjB,SAAgBpT,GACf,IAAI+F,EACAI,EAEJ,IAAM1F,GAAcT,GACnB,MAAM,IAAI/K,UAAWiB,EAAQ,8EAA+E8J,IAE7G,GAAK5K,UAAU1D,OAAS,EAAI,CAE3B,IAAMqO,GADNgG,EAAQ3Q,UAAW,IAElB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsE6P,IAEpG,GAAK3Q,UAAU1D,OAAS,GAEvB,IAAMqO,GADNoG,EAAM/Q,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,oEAAqEiQ,SAGnGA,EAAMnG,EAAEtO,MAEX,MACEqU,EAAQ,EACRI,EAAMnG,EAAEtO,OAET,OAAOW,GAAM2N,EAAG+F,EAAOI,EACxB,IhBwkBArO,EAAasb,GAAI,OAAQ2T,IAUzBjvB,EAAasb,GAAI,sBiBrmBjB,SAASquB,EAAoBl8B,GAC5B,IAAIC,EACA8B,EACAsmB,EACArmB,EACAtB,EACAxM,EACA2M,EACAzO,EACA4Q,EACArX,EACJ,IAAMuP,GAAc8E,GACnB,MAAM,IAAItQ,UAAWiB,EAAQ,8EAA+EqP,IAM7G,GAJAgC,EAAO,CACNtB,KAAQ,MACRy7B,IAAO,GAEHtsC,UAAU1D,OAAS,EACvB,GAAKiO,GAAUvK,UAAW,IAAQ,CAEjC,GADAkS,EAAUlS,UAAW,GAChBA,UAAU1D,OAAS,EAAI,CAE3B,IAAM4Q,GADN8D,EAAMhR,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,uEAAwEkQ,IAEtGZ,EAAUpQ,UAAW,EACrB,CACD,GAAK2E,GAAYuN,EAAS,UACzBC,EAAKtB,KAAOqB,EAAQrB,MACd7F,GAAsBkH,EAAQrB,OACnC,MAAM,IAAIhR,UAAWiB,EAAQ,2EAA4E,OAAQoR,EAAQrB,OAG3H,GAAKlM,GAAYuN,EAAS,SACzBC,EAAKm6B,IAAMp6B,EAAQo6B,IACE,IAAhBp6B,EAAQo6B,MAA8B,IAAjBp6B,EAAQo6B,KACjC,MAAM,IAAIzsC,UAAWiB,EAAQ,wEAAyE,MAAOoR,EAAQo6B,KAG1H,KAAS,CAEN,IAAMp/B,GADN8D,EAAMhR,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,iGAAkGkQ,IAEhIZ,EAAUpQ,UAAW,EACrB,CAkCF,OAhCAw4B,EAAQ,EAGR3nB,EAAO,CAAA,EACFG,EACc,IAAbmB,EAAKm6B,KACTxwC,GAAK,EACL4G,EAAamO,EAAM,QAiCrB,WAGC,GAFA/U,GAAKA,EAAE,GAAKqU,EAAI7T,OAChBk8B,GAAS,EACJn0B,GAAOm0B,EAAQrmB,EAAKtB,MAAuB,IAAfV,EAAI7T,OACpC,MAAO,CACN4S,MAAQ,GAGV,MAAO,CACNvT,MAASqV,EAAIpT,KAAMwS,EAAS7N,EAAK4N,EAAKrU,GAAKA,EAAG08B,EAAOroB,GACrDjB,MAAQ,EAET,MA3CCpT,EAAIqU,EAAI7T,OACRoG,EAAamO,EAAM,QAkDrB,YACC/U,GAAK,GACI,IACRA,GAAKqU,EAAI7T,QAGV,GADAk8B,GAAS,EACJn0B,GAAOm0B,EAAQrmB,EAAKtB,MAAuB,IAAfV,EAAI7T,OACpC,MAAO,CACN4S,MAAQ,GAGV,MAAO,CACNvT,MAASqV,EAAIpT,KAAMwS,EAAS7N,EAAK4N,EAAKrU,GAAKA,EAAG08B,EAAOroB,GACrDjB,MAAQ,EAET,KA/DwB,IAAbiD,EAAKm6B,KAChBxwC,GAAK,EACL4G,EAAamO,EAAM,QAqEpB,WAGC,GAFA/U,GAAKA,EAAE,GAAKqU,EAAI7T,OAChBk8B,GAAS,EACJn0B,GAAOm0B,EAAQrmB,EAAKtB,MAAuB,IAAfV,EAAI7T,OACpC,MAAO,CACN4S,MAAQ,GAGV,MAAO,CACNvT,MAAS4G,EAAK4N,EAAKrU,GACnBoT,MAAQ,EAET,MA/EApT,EAAIqU,EAAI7T,OACRoG,EAAamO,EAAM,QAsFpB,YACC/U,GAAK,GACI,IACRA,GAAKqU,EAAI7T,QAGV,GADAk8B,GAAS,EACJn0B,GAAOm0B,EAAQrmB,EAAKtB,MAAuB,IAAfV,EAAI7T,OACpC,MAAO,CACN4S,MAAQ,GAGV,MAAO,CACNvT,MAAS4G,EAAK4N,EAAKrU,GACnBoT,MAAQ,EAET,KAnGDxM,EAAamO,EAAM,UA4GnB,SAAclV,GAEb,GADA0I,GAAM,EACDrE,UAAU1D,OACd,MAAO,CACNX,MAASA,EACTuT,MAAQ,GAGV,MAAO,CACNA,MAAQ,EAET,IApHI2xB,IACJn+B,EAAamO,EAAMgwB,IA2HpB,WACC,GAAK7vB,EACJ,OAAOq7B,EAAoBl8B,EAAKgC,EAAMnB,EAAKZ,GAE5C,OAAOi8B,EAAoBl8B,EAAKgC,EAChC,IA7HDgB,EAAKnP,GAAOmM,GAEX5N,EADIS,EAAiBmN,GACfK,EAAgB2C,GAEhBpP,EAAQoP,GAERtC,CAwHR,IjBuaAnO,EAAasb,GAAI,cAAeypB,IAUhC/kC,EAAasb,GAAI,kBkBjoBjB,SAASuuB,EAAgBp8B,GACxB,IAAIC,EACAS,EACAxM,EACA2M,EACAzO,EACA4Q,EACArX,EACJ,IAAMuP,GAAc8E,GACnB,MAAM,IAAItQ,UAAWiB,EAAQ,8EAA+EqP,IAE7G,GAAKnQ,UAAU1D,OAAS,EAAI,CAE3B,IAAM4Q,GADN8D,EAAMhR,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsEkQ,IAEpGZ,EAAUpQ,UAAW,EACrB,CAuBD,OAtBAlE,GAAK,EAKJ4G,EAFDmO,EAAO,CAAA,EAEa,OADfG,EA0BL,WAEC,GADAlV,GAAK,EACAuI,GAAOvI,GAAKqU,EAAI7T,OACpB,MAAO,CACN4S,MAAQ,GAGV,MAAO,CACNvT,MAASqV,EAAIpT,KAAMwS,EAAS7N,EAAK4N,EAAKrU,GAAKA,EAAGqU,GAC9CjB,MAAQ,EAET,EAQD,WAEC,GADApT,GAAK,EACAuI,GAAOvI,GAAKqU,EAAI7T,OACpB,MAAO,CACN4S,MAAQ,GAGV,MAAO,CACNvT,MAAS4G,EAAK4N,EAAKrU,GACnBoT,MAAQ,EAET,GAnDDxM,EAAamO,EAAM,UA4DnB,SAAclV,GAEb,GADA0I,GAAM,EACDrE,UAAU1D,OACd,MAAO,CACNX,MAASA,EACTuT,MAAQ,GAGV,MAAO,CACNA,MAAQ,EAET,IApEI2xB,IACJn+B,EAAamO,EAAMgwB,IA2EpB,WACC,GAAK7vB,EACJ,OAAOu7B,EAAgBp8B,EAAKa,EAAKZ,GAElC,OAAOm8B,EAAgBp8B,EACvB,IA7EDgD,EAAKnP,GAAOmM,GAEX5N,EADIS,EAAiBmN,GACfK,EAAgB2C,GAEhBpP,EAAQoP,GAERtC,CAwER,IlB2hBAnO,EAAasb,GAAI,uBmBvoBjB,SAASwuB,EAAqBr8B,GAC7B,IAAIC,EACAS,EACAxM,EACA2M,EACAzL,EACAhD,EACA4Q,EACArX,EACJ,IAAMuP,GAAc8E,GACnB,MAAM,IAAItQ,UAAWiB,EAAQ,8EAA+EqP,IAE7G,GAAKnQ,UAAU1D,OAAS,EAAI,CAE3B,IAAM4Q,GADN8D,EAAMhR,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsEkQ,IAEpGZ,EAAUpQ,UAAW,EACrB,CAwBD,OAvBAuF,EAAM4K,EAAI7T,OACVR,EAAIyJ,EAKH7C,EAFDmO,EAAO,CAAA,EAEa,OADfG,EA0BL,WAGC,GAFAlV,GAAKqU,EAAI7T,OAASiJ,EAAM,EACxBA,EAAM4K,EAAI7T,OACL+H,GAAOvI,EAAI,EAEf,OADAuI,GAAM,EACC,CACN6K,MAAQ,GAGV,MAAO,CACNvT,MAASqV,EAAIpT,KAAMwS,EAAS7N,EAAK4N,EAAKrU,GAAKA,EAAGqU,GAC9CjB,MAAQ,EAET,EAQD,WAGC,GAFApT,GAAKqU,EAAI7T,OAASiJ,EAAM,EACxBA,EAAM4K,EAAI7T,OACL+H,GAAOvI,EAAI,EAEf,OADAuI,GAAM,EACC,CACN6K,MAAQ,GAGV,MAAO,CACNvT,MAAS4G,EAAK4N,EAAKrU,GACnBoT,MAAQ,EAET,GAvDDxM,EAAamO,EAAM,UAgEnB,SAAclV,GAEb,GADA0I,GAAM,EACDrE,UAAU1D,OACd,MAAO,CACNX,MAASA,EACTuT,MAAQ,GAGV,MAAO,CACNA,MAAQ,EAET,IAxEI2xB,IACJn+B,EAAamO,EAAMgwB,IA+EpB,WACC,GAAK7vB,EACJ,OAAOw7B,EAAqBr8B,EAAKa,EAAKZ,GAEvC,OAAOo8B,EAAqBr8B,EAC5B,IAjFDgD,EAAKnP,GAAOmM,GAEX5N,EADIS,EAAiBmN,GACfK,EAAgB2C,GAEhBpP,EAAQoP,GAERtC,CA4ER,InB2hBAnO,EAAasb,GAAI,kBAAmBmiB,IAUpCz9B,EAAasb,GAAI,wBoBjqBjB,SAASyuB,EAAsBt8B,GAC9B,IAAIC,EACAS,EACAxM,EACA2M,EACAzO,EACA4Q,EACArX,EACJ,IAAMuP,GAAc8E,GACnB,MAAM,IAAItQ,UAAWiB,EAAQ,8EAA+EqP,IAE7G,GAAKnQ,UAAU1D,OAAS,EAAI,CAE3B,IAAM4Q,GADN8D,EAAMhR,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsEkQ,IAEpGZ,EAAUpQ,UAAW,EACrB,CAuBD,OAtBAlE,GAAK,EAKJ4G,EAFDmO,EAAO,CAAA,EAEa,OADfG,EA0BL,WACC,IAAIzL,EACJ,GAAKlB,EACJ,MAAO,CACN6K,MAAQ,GAGV3J,EAAM4K,EAAI7T,OACVR,GAAK,EACL,KAAQA,EAAIyJ,QAAyB,IAAlBhD,EAAK4N,EAAKrU,IAC5BA,GAAK,EAEN,GAAKA,GAAKyJ,EAET,OADAlB,GAAM,EACC,CACN6K,MAAQ,GAGV,MAAO,CACNvT,MAASqV,EAAIpT,KAAMwS,EAAS7N,EAAK4N,EAAKrU,GAAKA,EAAGqU,GAC9CjB,MAAQ,EAET,EAQD,WACC,IAAI3J,EACJ,GAAKlB,EACJ,MAAO,CACN6K,MAAQ,GAGV3J,EAAM4K,EAAI7T,OACVR,GAAK,EACL,KAAQA,EAAIyJ,QAAyB,IAAlBhD,EAAK4N,EAAKrU,IAC5BA,GAAK,EAEN,GAAKA,GAAKyJ,EAET,OADAlB,GAAM,EACC,CACN6K,MAAQ,GAGV,MAAO,CACNvT,MAAS4G,EAAK4N,EAAKrU,GACnBoT,MAAQ,EAET,GAzEDxM,EAAamO,EAAM,UAkFnB,SAAclV,GAEb,GADA0I,GAAM,EACDrE,UAAU1D,OACd,MAAO,CACNX,MAASA,EACTuT,MAAQ,GAGV,MAAO,CACNA,MAAQ,EAET,IA1FI2xB,IACJn+B,EAAamO,EAAMgwB,IAiGpB,WACC,GAAK7vB,EACJ,OAAOy7B,EAAsBt8B,EAAKa,EAAKZ,GAExC,OAAOq8B,EAAsBt8B,EAC7B,IAnGDgD,EAAKnP,GAAOmM,GAEX5N,EADIS,EAAiBmN,GACfK,EAAgB2C,GAEhBpP,EAAQoP,GAERtC,CA8FR,IpBqiBAnO,EAAasb,GAAI,6BqBvqBjB,SAAS0uB,EAA2Bv8B,GACnC,IAAIC,EACAS,EACAxM,EACA2M,EACAzL,EACAhD,EACA4Q,EACArX,EACJ,IAAMuP,GAAc8E,GACnB,MAAM,IAAItQ,UAAWiB,EAAQ,8EAA+EqP,IAE7G,GAAKnQ,UAAU1D,OAAS,EAAI,CAE3B,IAAM4Q,GADN8D,EAAMhR,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsEkQ,IAEpGZ,EAAUpQ,UAAW,EACrB,CAwBD,OAvBAuF,EAAM4K,EAAI7T,OACVR,EAAIyJ,EAKH7C,EAFDmO,EAAO,CAAA,EAEa,OADfG,EA0BL,WACC,GAAK3M,EACJ,MAAO,CACN6K,MAAQ,GAGVpT,GAAKqU,EAAI7T,OAASiJ,EAAM,EACxBA,EAAM4K,EAAI7T,OACV,KAAQR,GAAK,QAAuB,IAAlByG,EAAK4N,EAAKrU,IAC3BA,GAAK,EAEN,GAAKA,EAAI,EAER,OADAuI,GAAM,EACC,CACN6K,MAAQ,GAGV,MAAO,CACNvT,MAASqV,EAAIpT,KAAMwS,EAAS7N,EAAK4N,EAAKrU,GAAKA,EAAGqU,GAC9CjB,MAAQ,EAET,EAQD,WACC,GAAK7K,EACJ,MAAO,CACN6K,MAAQ,GAGVpT,GAAKqU,EAAI7T,OAASiJ,EAAM,EACxBA,EAAM4K,EAAI7T,OACV,KAAQR,GAAK,QAAuB,IAAlByG,EAAK4N,EAAKrU,IAC3BA,GAAK,EAEN,GAAKA,EAAI,EAER,OADAuI,GAAM,EACC,CACN6K,MAAQ,GAGV,MAAO,CACNvT,MAAS4G,EAAK4N,EAAKrU,GACnBoT,MAAQ,EAET,GAvEDxM,EAAamO,EAAM,UAgFnB,SAAclV,GAEb,GADA0I,GAAM,EACDrE,UAAU1D,OACd,MAAO,CACNX,MAASA,EACTuT,MAAQ,GAGV,MAAO,CACNA,MAAQ,EAET,IAxFI2xB,IACJn+B,EAAamO,EAAMgwB,IA+FpB,WACC,GAAK7vB,EACJ,OAAO07B,EAA2Bv8B,EAAKa,EAAKZ,GAE7C,OAAOs8B,EAA2Bv8B,EAClC,IAjGDgD,EAAKnP,GAAOmM,GAEX5N,EADIS,EAAiBmN,GACfK,EAAgB2C,GAEhBpP,EAAQoP,GAERtC,CA4FR,IrB2iBAnO,EAAasb,GAAI,yBsBrqBjB,SAAS2uB,EAAuBh7B,EAAGxB,EAAKyF,EAAQjH,GAC/C,IAAIyB,EACAS,EACAxM,EACA2M,EACA5N,EACAb,EACA4Q,EACArX,EACJ,IAAMkP,GAAsB2G,GAC3B,MAAM,IAAI9R,UAAWiB,EAAQ,+EAAgF6Q,IAE9G,IAAMtG,GAAc8E,GACnB,MAAM,IAAItQ,UAAWiB,EAAQ,+EAAgFqP,IAE9G,IAAMxF,GAAWiL,GAChB,MAAM,IAAI/V,UAAWiB,EAAQ,oEAAqE8U,IAEnG,IAAM5K,GAAsB2D,GAC3B,MAAM,IAAI9O,UAAWiB,EAAQ,gFAAiF6N,IAE/G,GAAK3O,UAAU1D,OAAS,EAAI,CAE3B,IAAM4Q,GADN8D,EAAMhR,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,oEAAqEkQ,IAEnGZ,EAAUpQ,UAAW,EACrB,CAwBD,OAvBAoD,EAAMuL,EACN7S,GAAK,EAKJ4G,EAFDmO,EAAO,CAAA,EAEa,OADfG,EA0BL,WACC,IAAI/L,EAEJ,GADAnJ,GAAK,EACAuI,GAAOvI,GAAK6V,EAChB,MAAO,CACNzC,MAAQ,GAKV,OAFAjK,EAAI+L,EAAIpT,KAAMwS,EAAS7N,EAAK4N,EAAK/M,GAAOA,EAAKtH,EAAGqU,GAChD/M,GAAOwS,EACA,CACNja,MAASsJ,EACTiK,MAAQ,EAET,EAQD,WACC,IAAIjK,EAEJ,GADAnJ,GAAK,EACAuI,GAAOvI,GAAK6V,EAChB,MAAO,CACNzC,MAAQ,GAKV,OAFAjK,EAAI1C,EAAK4N,EAAK/M,GACdA,GAAOwS,EACA,CACNja,MAASsJ,EACTiK,MAAQ,EAET,GAzDDxM,EAAamO,EAAM,UAkEnB,SAAclV,GAEb,GADA0I,GAAM,EACDrE,UAAU1D,OACd,MAAO,CACNX,MAASA,EACTuT,MAAQ,GAGV,MAAO,CACNA,MAAQ,EAET,IA1EI2xB,IACJn+B,EAAamO,EAAMgwB,IAiFpB,WACC,GAAK7vB,EACJ,OAAO27B,EAAuBh7B,EAAGxB,EAAKyF,EAAQjH,EAAQqC,EAAKZ,GAE5D,OAAOu8B,EAAuBh7B,EAAGxB,EAAKyF,EAAQjH,EAC9C,IAnFDwE,EAAKnP,GAAOmM,GAEX5N,EADIS,EAAiBmN,GACfK,EAAgB2C,GAEhBpP,EAAQoP,GAERtC,CA8ER,ItB8iBAnO,EAAasb,GAAI,sBuB1rBjB,SAAS4uB,EAAoBz8B,GAC5B,IAAIC,EACA4B,EACApC,EACAiB,EACAxM,EACA2M,EACAD,EACAxO,EACA4Q,EACArX,EACJ,IAAMuP,GAAc8E,GACnB,MAAM,IAAItQ,UAAWiB,EAAQ,8EAA+EqP,IAG7G,GAAe,KADfP,EAAQ5P,UAAU1D,QAEjB0V,EAAQ,EACRjB,EAAMZ,EAAI7T,YACJ,GAAe,IAAVsT,EACN1C,GAAYlN,UAAW,KAC3BgS,EAAQ,EACRhB,EAAMhR,UAAW,IAEjBgS,EAAQhS,UAAW,GAEpB+Q,EAAMZ,EAAI7T,YACJ,GAAe,IAAVsT,EACN1C,GAAYlN,UAAW,KAC3BgS,EAAQ,EACRjB,EAAMZ,EAAI7T,OACV0U,EAAMhR,UAAW,GACjBoQ,EAAUpQ,UAAW,IACVkN,GAAYlN,UAAW,KAClCgS,EAAQhS,UAAW,GACnB+Q,EAAMZ,EAAI7T,OACV0U,EAAMhR,UAAW,KAEjBgS,EAAQhS,UAAW,GACnB+Q,EAAM/Q,UAAW,QAEZ,CAIN,GAHAgS,EAAQhS,UAAW,GACnB+Q,EAAM/Q,UAAW,IAEXkN,GADN8D,EAAMhR,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsEkQ,IAEpGZ,EAAUpQ,UAAW,EACrB,CACD,IAAM2K,GAAWqH,GAChB,MAAM,IAAInS,UAAWiB,EAAQ,2GAA4GkR,IAE1I,IAAMrH,GAAWoG,GAChB,MAAM,IAAIlR,UAAWiB,EAAQ,wGAAyGiQ,IAsCvI,OApCKA,EAAM,GACVA,EAAMZ,EAAI7T,OAASyU,GACR,IACVA,EAAM,GAEIA,EAAMZ,EAAI7T,SACrByU,EAAMZ,EAAI7T,QAEN0V,EAAQ,IACZA,EAAQ7B,EAAI7T,OAAS0V,GACR,IACZA,EAAQ,GAGVlW,EAAIkW,EAAQ,EAKXtP,EAFDmO,EAAO,CAAA,EAEa,OADfG,EA0BL,WAEC,GADAlV,GAAK,EACAuI,GAAOvI,GAAKiV,EAChB,MAAO,CACN7B,MAAQ,GAGV,MAAO,CACNvT,MAASqV,EAAIpT,KAAMwS,EAAS7N,EAAK4N,EAAKrU,GAAKA,EAAGA,EAAEkW,EAAO7B,GACvDjB,MAAQ,EAET,EAQD,WAEC,GADApT,GAAK,EACAuI,GAAOvI,GAAKiV,EAChB,MAAO,CACN7B,MAAQ,GAGV,MAAO,CACNvT,MAAS4G,EAAK4N,EAAKrU,GACnBoT,MAAQ,EAET,GAnDDxM,EAAamO,EAAM,UA4DnB,SAAiBlV,GAEhB,GADA0I,GAAM,EACDrE,UAAU1D,OACd,MAAO,CACNX,MAASA,EACTuT,MAAQ,GAGV,MAAO,CACNA,MAAQ,EAET,IApEI2xB,IACJn+B,EAAamO,EAAMgwB,IA2EpB,WACC,GAAK7vB,EACJ,OAAO47B,EAAoBz8B,EAAK6B,EAAOjB,EAAKC,EAAKZ,GAElD,OAAOw8B,EAAoBz8B,EAAK6B,EAAOjB,EACvC,IA7EDoC,EAAKnP,GAAOmM,GAEX5N,EADIS,EAAiBmN,GACfK,EAAgB2C,GAEhBpP,EAAQoP,GAERtC,CAwER,IvBiiBAnO,EAAasb,GAAI,2BwBpsBjB,SAAS6uB,EAAyB18B,GACjC,IAAIC,EACA4B,EACApC,EACAiB,EACAxM,EACA2M,EACAD,EACAxO,EACA4Q,EACArX,EACJ,IAAMuP,GAAc8E,GACnB,MAAM,IAAItQ,UAAWiB,EAAQ,8EAA+EqP,IAG7G,GAAe,KADfP,EAAQ5P,UAAU1D,QAEjB0V,EAAQ,EACRjB,EAAMZ,EAAI7T,YACJ,GAAe,IAAVsT,EACN1C,GAAYlN,UAAW,KAC3BgS,EAAQ,EACRhB,EAAMhR,UAAW,IAEjBgS,EAAQhS,UAAW,GAEpB+Q,EAAMZ,EAAI7T,YACJ,GAAe,IAAVsT,EACN1C,GAAYlN,UAAW,KAC3BgS,EAAQ,EACRjB,EAAMZ,EAAI7T,OACV0U,EAAMhR,UAAW,GACjBoQ,EAAUpQ,UAAW,IACVkN,GAAYlN,UAAW,KAClCgS,EAAQhS,UAAW,GACnB+Q,EAAMZ,EAAI7T,OACV0U,EAAMhR,UAAW,KAEjBgS,EAAQhS,UAAW,GACnB+Q,EAAM/Q,UAAW,QAEZ,CAIN,GAHAgS,EAAQhS,UAAW,GACnB+Q,EAAM/Q,UAAW,IAEXkN,GADN8D,EAAMhR,UAAW,IAEhB,MAAM,IAAIH,UAAWiB,EAAQ,qEAAsEkQ,IAEpGZ,EAAUpQ,UAAW,EACrB,CACD,IAAM2K,GAAWqH,GAChB,MAAM,IAAInS,UAAWiB,EAAQ,gHAAiHkR,IAE/I,IAAMrH,GAAWoG,GAChB,MAAM,IAAIlR,UAAWiB,EAAQ,6GAA8GiQ,IAsC5I,OApCKA,EAAM,GACVA,EAAMZ,EAAI7T,OAASyU,GACR,IACVA,EAAM,GAEIA,EAAMZ,EAAI7T,SACrByU,EAAMZ,EAAI7T,QAEN0V,EAAQ,IACZA,EAAQ7B,EAAI7T,OAAS0V,GACR,IACZA,EAAQ,GAGVlW,EAAIiV,EAKHrO,EAFDmO,EAAO,CAAA,EAEa,OADfG,EA0BL,WAEC,GADAlV,GAAK,EACAuI,GAAOvI,EAAIkW,EACf,MAAO,CACN9C,MAAQ,GAGV,MAAO,CACNvT,MAASqV,EAAIpT,KAAMwS,EAAS7N,EAAK4N,EAAKrU,GAAKA,EAAGiV,EAAIjV,EAAE,EAAGqU,GACvDjB,MAAQ,EAET,EAQD,WAEC,GADApT,GAAK,EACAuI,GAAOvI,EAAIkW,EACf,MAAO,CACN9C,MAAQ,GAGV,MAAO,CACNvT,MAAS4G,EAAK4N,EAAKrU,GACnBoT,MAAQ,EAET,GAnDDxM,EAAamO,EAAM,UA4DnB,SAAiBlV,GAEhB,GADA0I,GAAM,EACDrE,UAAU1D,OACd,MAAO,CACNX,MAASA,EACTuT,MAAQ,GAGV,MAAO,CACNA,MAAQ,EAET,IApEI2xB,IACJn+B,EAAamO,EAAMgwB,IA2EpB,WACC,GAAK7vB,EACJ,OAAO67B,EAAyB18B,EAAK6B,EAAOjB,EAAKC,EAAKZ,GAEvD,OAAOy8B,EAAyB18B,EAAK6B,EAAOjB,EAC5C,IA7EDoC,EAAKnP,GAAOmM,GAEX5N,EADIS,EAAiBmN,GACfK,EAAgB2C,GAEhBpP,EAAQoP,GAERtC,CAwER,IxB2iBAnO,EAAasb,GAAI,cZjpBjB,WACC,IAAIpO,EACA5L,EACAiC,EACA9I,EAUJ,GAAc,QADd8I,EAAOkP,GAJNnR,GAHD4L,EAAQ5P,UAAU1D,SACJmP,GAAUzL,UAAW4P,EAAM,IAEhC5P,UADR4P,GAAS,GAGDkkB,KAIR,MAAM,IAAIj0B,UAAWiB,EAAQ,sEAAuEkD,IAErG,OAAK4L,GAAS,EACN,IAAI3J,EAAM,GAEH,IAAV2J,IACJzS,EAAM6C,UAAW,cAGG6G,GACnB1J,EAAM4S,GAAe5S,EAAK,GACfA,aAAe2J,GAC1B3J,EAAM6S,GAAgB7S,EAAK,GAChBA,aAAe4J,KAC1B5J,EAAM0hB,GAAoB1hB,EAAK,IAEzB,IAAI8I,EAAM9I,IAEH,IAAVyS,EACG,IAAI3J,EAAMjG,UAAU,GAAIA,UAAU,IAEnC,IAAIiG,EAAMjG,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD,IYsnBA0C,EAAasb,GAAI,gBTjqBjB,WACC,IAAIpO,EACA5L,EACAiC,EAUJ,GAAc,QADdA,EAAOkP,GAJNnR,GAHD4L,EAAQ5P,UAAU1D,SACJmP,GAAUzL,UAAW4P,EAAM,IAEhC5P,UADR4P,GAAS,GAGDkkB,KAIR,MAAM,IAAIj0B,UAAWiB,EAAQ,sEAAuEkD,IAErG,OAAK4L,GAAS,EACN,IAAI3J,EAAM,GAEH,IAAV2J,EACG,IAAI3J,EAAMjG,UAAU,IAEb,IAAV4P,EACG,IAAI3J,EAAMjG,UAAU,GAAIA,UAAU,IAEnC,IAAIiG,EAAMjG,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD,ISipBA0C,EAAasb,GAAI,oBAAqB8uB,IAUtCpqC,EAAasb,GAAI,yByBtwBjB,WACC,OAAO7K,GAAI,yBACZ,IzB8wBAzQ,EAAasb,GAAI,kBAAmB+uB,IAUpCrqC,EAAasb,GAAI,uB0B1xBjB,WACC,OAAO7K,GAAI,QACZ,I1BkyBAzQ,EAAasb,GAAI,kBAAmBgvB,IAUpCtqC,EAAasb,GAAI,uB2B9yBjB,WACC,OAAO7K,GAAI,iBACZ,I3BszBAzQ,EAAasb,GAAI,iB4BnzBjB,SAAgBha,GACf,OAAOmmB,GAAOnmB,IAAW,IAC1B,I5B2zBAtB,EAAasb,GAAI,qB6Bl0BjB,WACC,OAAO7K,GAAI,UACZ,I7B00BAzQ,EAAasb,GAAI,aP3vBjB,WACC,IAAIpO,EACA5L,EACAiC,EAUJ,GAAc,QADdA,EAAOkP,GAJNnR,GAHD4L,EAAQ5P,UAAU1D,SACJmP,GAAUzL,UAAW4P,EAAM,IAEhC5P,UADR4P,GAAS,GAGDkkB,KAIR,MAAM,IAAIj0B,UAAWiB,EAAQ,sEAAuEkD,IAErG,OAAK4L,GAAS,EACN,IAAI3J,EAAM,GAEH,IAAV2J,EACG,IAAI3J,EAAMjG,UAAU,IAEb,IAAV4P,EACG,IAAI3J,EAAMjG,UAAU,GAAIA,UAAU,IAEnC,IAAIiG,EAAMjG,UAAU,GAAIA,UAAU,GAAIA,UAAU,GACxD,IO2uBA0C,EAAasb,GAAI,kB8Bj1BjB,SAAgBha,GACf,OAAOmmB,GAAOnmB,IAAW,IAC1B,I9By1BAtB,EAAasb,GAAI,sB+Bh2BjB,WACC,OAAO7K,GAAI,OACZ,I/Bw2BAzQ,EAAasb,GAAI,uBgCr2BjB,SAAgBha,GACf,OAAOmmB,GAAOnmB,IAAW,IAC1B,IhC62BAtB,EAAasb,GAAI,2BiCp3BjB,WACC,OAAO7K,GAAI,sBACZ,IjC43BAzQ,EAAasb,GAAI,uBkCz3BjB,SAAgBha,GACf,OAAOmmB,GAAOnmB,IAAW,IAC1B,IlCi4BAtB,EAAasb,GAAI,2BmCx4BjB,WACC,OAAO7K,GAAI,iBACZ,InCg5BAzQ,EAAasb,GAAI,yBoC74BjB,SAAgBha,GACf,OAAOmmB,GAAOnmB,IAAW,IAC1B,IpCq5BAtB,EAAasb,GAAI,6BqC55BjB,WACC,OAAO7K,GAAI,mBACZ,IrCo6BAzQ,EAAasb,GAAI,aAAcrX,IAU/BjE,EAAasb,GAAI,oBAAqBpX,IAUtClE,EAAasb,GAAI,cAAevX,IAUhC/D,EAAasb,GAAI,cAAetX,IAUhChE,EAAasb,GAAI,SAAUyJ,IAU3B/kB,EAAasb,GAAI,csC98BjB,SAAqBpT,GACpB,IAAIuI,EAAKnP,GAAO4G,GAChB,GAAY,OAAPuI,EACJ,MAAM,IAAItT,UAAWiB,EAAQ,8GAA+G8J,IAK7I,OAHK5K,UAAU1D,OAAS,IACvB6W,EAAKnT,UAAW,IAEVynB,GAAQ7c,EAAEtO,OAAQ6W,EAC1B,ItC+8BAzQ,EAAasb,GAAI,QAASpiB,IAU1B8G,EAAasb,GAAI,auCl+BjB,SAAoBpT,GACnB,IAAIuI,EAAKnP,GAAO4G,GAChB,GAAY,OAAPuI,EACJ,MAAM,IAAItT,UAAWiB,EAAQ,8GAA+G8J,IAK7I,OAHK5K,UAAU1D,OAAS,IACvB6W,EAAKnT,UAAW,IAEVpE,GAAOgP,EAAEtO,OAAQ6W,EACzB,IvCm+BAzQ,EAAasb,GAAI,YAAaivB","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,41,42,43,47,48,49,50,54,55,56,57,61,62,63,64,65,69,70,71,72,76,77,78,79,80,84,85,86,87,91,92,93,97,98,99,100,101,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,174,175,176,177,178,179,180,181,182,183,187,188,203,206,207,208,209,212,215,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,245,246,247,249,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,316,317,328,329,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,372,373,374,379,380,381,389,391,392,393,394,395,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,440,451,452,453,454,455,456,457,458,459,460,461,482,483,494,499,500,501,502,535,536,537,538,539,540,541,543,544,558,561,622,721,722,726,727,728,729,730,733,735,737,738,739,740,741,742,743,744,745,748,753,754,755,756,757,758,760,761,762,763,765,766,769,773,774,775,776,777,778,779,782,783,784,785,786,787,788,789,793,794,795,810,815,816,817,821,824,825,826,827,840,841,842,843,848,849,850,851,852,860,861,864,869,870,871,872,873,874,875,876,877,878,879,880,881,882,887,894,895,896,897,898,899,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,933,947]} \ No newline at end of file diff --git a/index/README.md b/index/README.md deleted file mode 100644 index bb0479fc1..000000000 --- a/index/README.md +++ /dev/null @@ -1,487 +0,0 @@ - - -# ArrayIndex - -> Array index constructor. - - - -
- -In JavaScript, only strings and symbols are valid property names. When providing values for property names which are not strings or symbols, the values are serialized to strings **prior to** attempting to access property values. For example, the following - -```javascript -// Create an array: -var x = [ 1, 2, 3, 4 ]; - -// Define a list of indices for elements we want to retrieve from `x`: -var y = [ 0, 2 ]; - -// Attempt to retrieve the desired elements: -var v = x[ y ]; // => desired: [ 1, 3 ] -// returns undefined -``` - -is equivalent to - -```javascript -var x = [ 1, 2, 3, 4 ]; -var y = [ 0, 2 ]; - -var v = x[ y.toString() ]; -// returns undefined - -// ...which is equivalent to: -v = x[ '0,2' ]; -// returns undefined -``` - -Accordingly, in order to circumvent built-in property access behavior and support non-traditional access patterns, one can leverage [`Proxy`][@stdlib/proxy/ctor] objects which allow one to intercept property access and to perform transformations before attempting to access elements in a target object. - -To support the access pattern shown in the example above, one can leverage built-in string serialization behavior to reconstruct the original property value provided prior to serialization. The `ArrayIndex` constructor described below provides one such mechanism. - -Specifically, instantiated `ArrayIndex` objects are assigned a unique identifier and stored in a local cache. When provided as property values to `ArrayIndex` consumers, instantiated objects serialize to a string containing their unique identifier. `ArrayIndex` consumers can then parse the serialized string to obtain the unique identifier and subsequently recover the original array from the local cache. - -
- - - - - -
- -## Usage - -```javascript -var ArrayIndex = require( '@stdlib/array/index' ); -``` - - - -#### ArrayIndex( x\[, options] ) - -Wraps a provided array as an array index object. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var idx = new ArrayIndex( x ); -// returns -``` - -The constructor accepts the following arguments: - -- **x**: input array. -- **options**: function options. - -The constructor accepts the following options: - -- **persist**: boolean indicating whether to continue persisting an index object after first usage. Default: `false`. - -By default, an `ArrayIndex` is invalidated and removed from an internal cache immediately after a consumer resolves the underlying data associated with an `ArrayIndex` instance using the [`ArrayIndex.get()`](#static-method-get) static method. Immediate invalidation and cache removal ensures that references to the underlying array are not the source of memory leaks. - -One may, however, want to reuse an `ArrayIndex` instance to avoid additional memory allocation. In order to persist an `ArrayIndex` and prevent automatic cache invalidation, set the `persist` option to `true`. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var idx = new ArrayIndex( x, { - 'persist': true -}); -// returns - -// ... - -var o = ArrayIndex.get( idx.id ); -// returns {...} - -// ... - -o = ArrayIndex.get( idx.id ); -// returns {...} - -// ... - -// Explicitly free the array index: -ArrayIndex.free( idx.id ); -``` - -In order to **prevent** memory leaks when working with persisted `ArrayIndex` instances, one **must** remember to manually free persisted instances using the [`ArrayIndex.free()`](#static-method-free) method. - -* * * - -### Properties - - - -#### ArrayIndex.name - -String value of the `ArrayIndex` constructor name. - -```javascript -var str = ArrayIndex.name; -// returns 'ArrayIndex' -``` - - - -#### ArrayIndex.prototype.data - -**Read-only** property returning the underlying array associated with an `ArrayIndex` instance. - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); - -var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -// returns - -var v = idx.data; -// returns [ 1, 0, 1, 0 ] -``` - - - -#### ArrayIndex.prototype.dtype - -**Read-only** property returning the data type of the underlying array associated with an `ArrayIndex` instance. - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); - -var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -// returns - -var dt = idx.dtype; -// returns 'uint8' -``` - - - -#### ArrayIndex.prototype.id - -**Read-only** property returning the unique identifier associated with an `ArrayIndex` instance. - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); - -var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -// returns - -var id = idx.id; -// returns -``` - -The identifier should be used by `ArrayIndex` consumers to resolve the underlying data associated with an `ArrayIndex` instance. - - - -#### ArrayIndex.prototype.isCached - -**Read-only** property returning a boolean indicating whether an `ArrayIndex` instance is actively cached. - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); - -var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -// returns - -var out = idx.isCached; -// returns true -``` - - - -#### ArrayIndex.prototype.type - -**Read-only** property returning the array index type. - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); - -var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -// returns - -var t = idx.type; -// returns 'mask' -``` - -The following array index types are supported: - -- **mask**: mask array, in which a value of zero indicates to include a respective element and a value of one indicates to exclude a respective element. A mask array is the complement of a boolean array. -- **bool**: boolean array, in which a value of `true` indicates to include a respective element and a value of `false` indicates to exclude a respective element. A boolean array is the complement of a mask array. -- **int**: integer array, in which each element is an index indicating the position of an element to include. Elements are **not** required to be unique (i.e., more than element may resolve to the same position). - -* * * - -### Methods - - - -#### ArrayIndex.free( id ) - -Frees the `ArrayIndex` associated with a provided identifier. - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); - -var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), { - 'persist': true -}); -// returns - -// ... - -var out = ArrayIndex.free( idx.id ); -// returns true -``` - -Once an `ArrayIndex` is freed, the instance is invalid and can no longer be used. Any subsequent `ArrayIndex` operations (i.e., property and method access) will raise an exception. - - - -#### ArrayIndex.get( id ) - -Returns the array associated with the `ArrayIndex` having a provided identifier. - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); - -var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), { - 'persist': true -}); -// returns - -// ... - -var o = ArrayIndex.get( idx.id ); -// returns {...} - -var d = o.data; -// returns [ 1, 0, 1, 0 ] - -var t = o.type; -// returns 'mask' - -var dt = o.dtype; -// returns 'uint8' -``` - -The returned object has the following properties: - -- **data**: the underlying array associated with the `ArrayIndex` identified by the provided `id`. -- **type**: the type of array index. One of the following: `'int'`, `'bool'`, or `'mask'`. -- **dtype**: the data type of the underlying array. - -If the `ArrayIndex` associated with a provided identifier was not explicitly persisted, calling this method will cause the `ArrayIndex` to be invalidated and removed from an internal cache. Any subsequent instance operations (i.e., property and method access) will raise an exception. - - - -#### ArrayIndex.prototype.toString() - -Serializes an `ArrayIndex` as a string. - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); - -var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -// returns - -var str = idx.toString(); -// e.g., 'ArrayIndex<0>' -``` - -An `ArrayIndex` is intended to be an opaque object used by objects supporting "fancy" indexing (e.g., [fancy arrays][@stdlib/array/to-fancy]). As such, when serialized as a string, a serialized `ArrayIndex` includes only the unique identifier associated with the respective instance. - - - -#### ArrayIndex.prototype.toJSON() - -Serializes an `ArrayIndex` as a [JSON][json] object. - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); - -var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -// returns - -var o = idx.toJSON(); -// returns { 'type': 'ArrayIndex', 'data': { 'type': 'Uint8Array', 'data': [ 1, 0, 1, 0 ] } } -``` - -`JSON.stringify()` implicitly calls this method when stringifying an `ArrayIndex` instance. - -
- - - - - -* * * - -
- -## Notes - -- `ArrayIndex` instances have no explicit functionality; however, they are used by ["fancy" arrays][@stdlib/array/to-fancy] and other packages for element retrieval and assignment. - -- Because `ArrayIndex` instances leverage an internal cache implementing the **singleton pattern**, one **must** be sure to use the same `ArrayIndex` constructor as `ArrayIndex` consumers. If one uses a different `ArrayIndex` constructor, the consumer will **not** be able to resolve the original wrapped array, as the consumer will attempt to resolve an `ArrayIndex` instance in the wrong internal cache. - -- Because non-persisted `ArrayIndex` instances are freed after first use, in order to avoid holding onto memory and to allow garbage collection, one should avoid scenarios in which an `ArrayIndex` is never used. For example, - - ```javascript - var Uint8Array = require( '@stdlib/array/uint8' ); - - var data = new Uint8Array( [ 1, 0, 0, 0 ] ); - var idx = new ArrayIndex( data ); - - var o; - if ( data[ 0 ] === 0 ) { - // Do something with `idx`... - o = ArrayIndex.get( idx.id ); - - // ... - } - ``` - - will leak memory as `idx` is only consumed within an `if` block which never evaluates. In such scenarios, one should either refactor to avoid inadvertently holding onto memory or explicitly free the `ArrayIndex`. - - ```javascript - var Uint8Array = require( '@stdlib/array/uint8' ); - - var data = new Uint8Array( [ 1, 0, 0, 0 ] ); - var idx = new ArrayIndex( data ); - - var o; - if ( data[ 0 ] === 0 ) { - // Do something with `idx`... - o = ArrayIndex.get( idx.id ); - - // ... - } else { - ArrayIndex.free( idx.id ); - } - ``` - -
- - - - - -* * * - -
- -## Examples - - - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); -var Int32Array = require( '@stdlib/array/int32' ); -var BooleanArray = require( '@stdlib/array/bool' ); -var ArrayIndex = require( '@stdlib/array/index' ); - -var x = new Uint8Array( [ 1, 0, 1, 0 ] ); -var i = new ArrayIndex( x ); -// returns - -var o = ArrayIndex.get( i.id ); -// returns {...} - -console.log( 'Type: %s. Data type: %s.', o.type, o.dtype ); - -x = [ true, false, true, false ]; -i = new ArrayIndex( x ); -// returns - -o = ArrayIndex.get( i.id ); -// returns {...} - -console.log( 'Type: %s. Data type: %s.', o.type, o.dtype ); - -x = new BooleanArray( [ true, false, true, false ] ); -i = new ArrayIndex( x ); -// returns - -o = ArrayIndex.get( i.id ); -// returns {...} - -console.log( 'Type: %s. Data type: %s.', o.type, o.dtype ); - -x = new Int32Array( [ 1, 3, 4, 7 ] ); -i = new ArrayIndex( x ); -// returns - -o = ArrayIndex.get( i.id ); -// returns {...} - -console.log( 'Type: %s. Data type: %s.', o.type, o.dtype ); - -x = [ 1, 3, 4, 7 ]; -i = new ArrayIndex( x ); -// returns - -o = ArrayIndex.get( i.id ); -// returns {...} - -console.log( 'Type: %s. Data type: %s.', o.type, o.dtype ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/index/benchmark/benchmark.data.js b/index/benchmark/benchmark.data.js deleted file mode 100644 index b1ff83013..000000000 --- a/index/benchmark/benchmark.data.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var pkg = require( './../package.json' ).name; -var ArrayIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg+':data', function benchmark( b ) { - var values; - var opts; - var v; - var i; - - opts = { - 'persist': true - }; - - values = [ - new ArrayIndex( [ 1, 2, 3 ], opts ), - new ArrayIndex( [ 5, 6, 7 ], opts ), - new ArrayIndex( [ true, false, true ], opts ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ].data; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( v ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/index/benchmark/benchmark.dtype.js b/index/benchmark/benchmark.dtype.js deleted file mode 100644 index 5a9eea9f0..000000000 --- a/index/benchmark/benchmark.dtype.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var ArrayIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype', function benchmark( b ) { - var values; - var opts; - var v; - var i; - - opts = { - 'persist': true - }; - - values = [ - new ArrayIndex( [ 1, 2, 3 ], opts ), - new ArrayIndex( [ 5, 6, 7 ], opts ), - new ArrayIndex( [ true, false, true ], opts ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ].dtype; - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( v ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/index/benchmark/benchmark.get.js b/index/benchmark/benchmark.get.js deleted file mode 100644 index 0bdb0bde0..000000000 --- a/index/benchmark/benchmark.get.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var pkg = require( './../package.json' ).name; -var ArrayIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg+':get', function benchmark( b ) { - var values; - var opts; - var v; - var i; - - opts = { - 'persist': true - }; - - values = [ - ( new ArrayIndex( [ 1, 2, 3 ], opts ) ).id, - ( new ArrayIndex( [ 5, 6, 7 ], opts ) ).id, - ( new ArrayIndex( [ true, false, true ], opts ) ).id - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = ArrayIndex.get( values[ i%values.length ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( v ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/index/benchmark/benchmark.id.js b/index/benchmark/benchmark.id.js deleted file mode 100644 index 010e132e0..000000000 --- a/index/benchmark/benchmark.id.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var ArrayIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg+':id', function benchmark( b ) { - var values; - var opts; - var v; - var i; - - opts = { - 'persist': true - }; - - values = [ - new ArrayIndex( [ 1, 2, 3 ], opts ), - new ArrayIndex( [ 5, 6, 7 ], opts ), - new ArrayIndex( [ true, false, true ], opts ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ].id; - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( v ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/index/benchmark/benchmark.is_cached.js b/index/benchmark/benchmark.is_cached.js deleted file mode 100644 index c4bccf034..000000000 --- a/index/benchmark/benchmark.is_cached.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var ArrayIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg+':isCached', function benchmark( b ) { - var values; - var opts; - var v; - var i; - - opts = { - 'persist': true - }; - - values = [ - new ArrayIndex( [ 1, 2, 3 ], opts ), - new ArrayIndex( [ 5, 6, 7 ], opts ), - new ArrayIndex( [ true, false, true ], opts ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ].isCached; - if ( typeof v !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( v ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/index/benchmark/benchmark.js b/index/benchmark/benchmark.js deleted file mode 100644 index 14c89bce3..000000000 --- a/index/benchmark/benchmark.js +++ /dev/null @@ -1,84 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var pkg = require( './../package.json' ).name; -var ArrayIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ 1, 2, 3 ], - [ 5, 6, 7 ], - [ true, false, true ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = new ArrayIndex( values[ i%values.length ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !instanceOf( v, ArrayIndex ) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var values; - var idx; - var v; - var i; - - idx = ArrayIndex; - - values = [ - [ 1, 2, 3 ], - [ 5, 6, 7 ], - [ true, false, true ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = idx( values[ i%values.length ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !instanceOf( v, ArrayIndex ) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/index/benchmark/benchmark.to_json.js b/index/benchmark/benchmark.to_json.js deleted file mode 100644 index 3c99ab764..000000000 --- a/index/benchmark/benchmark.to_json.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var pkg = require( './../package.json' ).name; -var ArrayIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toJSON:len=3', function benchmark( b ) { - var values; - var opts; - var v; - var i; - - opts = { - 'persist': true - }; - - values = [ - new ArrayIndex( [ 1, 2, 3 ], opts ), - new ArrayIndex( [ 5, 6, 7 ], opts ), - new ArrayIndex( [ true, false, true ], opts ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ].toJSON(); - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isPlainObject( v ) ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/index/benchmark/benchmark.to_string.js b/index/benchmark/benchmark.to_string.js deleted file mode 100644 index e973acb3e..000000000 --- a/index/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var ArrayIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString:len=3', function benchmark( b ) { - var values; - var opts; - var v; - var i; - - opts = { - 'persist': true - }; - - values = [ - new ArrayIndex( [ 1, 2, 3 ], opts ), - new ArrayIndex( [ 5, 6, 7 ], opts ), - new ArrayIndex( [ true, false, true ], opts ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ].toString(); - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( v ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/index/benchmark/benchmark.type.js b/index/benchmark/benchmark.type.js deleted file mode 100644 index fa3f11e4e..000000000 --- a/index/benchmark/benchmark.type.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var ArrayIndex = require( './../lib' ); - - -// MAIN // - -bench( pkg+':type', function benchmark( b ) { - var values; - var opts; - var v; - var i; - - opts = { - 'persist': true - }; - - values = [ - new ArrayIndex( [ 1, 2, 3 ], opts ), - new ArrayIndex( [ 5, 6, 7 ], opts ), - new ArrayIndex( [ true, false, true ], opts ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = values[ i%values.length ].type; - if ( typeof v !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( v ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/index/docs/repl.txt b/index/docs/repl.txt deleted file mode 100644 index b4442db9f..000000000 --- a/index/docs/repl.txt +++ /dev/null @@ -1,203 +0,0 @@ - -{{alias}}( x[, options] ) - Wraps a provided array as an array index object. - - Array index instances have no explicit functionality; however, they are used - by "fancy" arrays for element retrieval and assignment. - - By default, an instance is invalidated and removed from an internal cache - immediately after a consumer resolves the underlying data associated with an - instance using the `get` static method. Immediate invalidation and cache - removal ensures that references to the underlying array are not the source - of memory leaks. - - Because instances leverage an internal cache implementing the Singleton - pattern, one must be sure to use the same constructor as consumers. If one - uses a different constructor, the consumer will *not* be able to resolve the - original wrapped array, as the consumer will attempt to resolve an instance - in the wrong internal cache. - - Because non-persisted instances are freed after first use, in order to avoid - holding onto memory and to allow garbage collection, one should avoid - scenarios in which an instance is never used. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - options: Object (optional) - Function options. - - options.persist: boolean (optional) - Boolean indicating whether to continue persisting an index object after - first usage. Default: false. - - Returns - ------- - out: ArrayIndex - ArrayIndex instance. - - Examples - -------- - > var idx = new {{alias}}( [ 1, 2, 3, 4 ] ); - - -{{alias}}.free( id ) - Frees the instance associated with a provided identifier. - - Parameters - ---------- - id: string - Instance identifier. - - Returns - ------- - out: boolean - Boolean indicating whether an instance was successfully freed. - - Examples - -------- - > var idx = new {{alias}}( [ 1, 2, 3, 4 ] ); - > {{alias}}.free( idx.id ) - - - -{{alias}}.get( id ) - Returns the array associated with the instance having a provided identifier. - - Parameters - ---------- - id: string - Instance identifier. - - Returns - ------- - out: Object - Object containing array data. - - out.data: Array|TypedArray|Object - The underlying array associated with the provided identifier. - - out.type: string - The type of array index. - - out.dtype: string - The data type of the underlying array. - - Examples - -------- - > var idx = new {{alias}}( [ 1, 2, 3, 4 ] ); - > {{alias}}.get( idx.id ) - {...} - - -{{alias}}.prototype.data - Read-only property returning the underlying index array. - - Returns - ------- - out: Array|TypedArray|Object - Array data. - - Examples - -------- - > var idx = new {{alias}}( [ 1, 2, 3, 4 ] ); - > idx.data - [ 1, 2, 3, 4 ] - - -{{alias}}.prototype.dtype - Read-only property returning the underlying data type of the index array. - - Returns - ------- - out: string - Array data type. - - Examples - -------- - > var idx = new {{alias}}( [ 1, 2, 3, 4 ] ); - > idx.dtype - 'generic' - - -{{alias}}.prototype.id - Read-only property returning the unique identifier associated with an - instance. - - Returns - ------- - out: string - String identifier. - - Examples - -------- - > var idx = new {{alias}}( [ 1, 2, 3, 4 ] ); - > idx.id - - - -{{alias}}.prototype.isCached - Read-only property returning a boolean indicating whether an array index is - actively cached. - - Returns - ------- - out: boolean - Boolean indicating whether an array index is actively cached. - - Examples - -------- - > var idx = new {{alias}}( [ 1, 2, 3, 4 ] ); - > idx.isCached - true - - -{{alias}}.prototype.type - Read-only property returning the array index type. - - Returns - ------- - out: string - Array index type. - - Examples - -------- - > var idx = new {{alias}}( [ 1, 2, 3, 4 ] ); - > idx.type - - - -{{alias}}.prototype.toString() - Serializes an instance as a string. - - Returns - ------- - str: string - Serialized string. - - Examples - -------- - > var idx = new {{alias}}( [ 1, 2, 3, 4 ] ); - > idx.toString() - - - -{{alias}}.prototype.toJSON() - Serializes an instance as a JSON object. - - Returns - ------- - obj: Object - JSON object. - - Examples - -------- - > var idx = new {{alias}}( [ 1, 2, 3, 4 ] ); - > idx.toJSON() - { 'type': 'ArrayIndex', 'data': [ 1, 2, 3, 4 ] } - - See Also - -------- - diff --git a/index/docs/types/index.d.ts b/index/docs/types/index.d.ts deleted file mode 100644 index bed847396..000000000 --- a/index/docs/types/index.d.ts +++ /dev/null @@ -1,325 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { GenericBooleanIndexArray, GenericIntegerIndexArray, IndexArray, MaskArrayIndex, BooleanArrayIndex, Int32ArrayIndex, GenericBooleanArrayIndex, GenericIntegerArrayIndex, ArrayIndex, BaseIndexArrayObject, IndexArrayObject, BooleanArray } from '@stdlib/types/array'; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Boolean indicating whether to continue persisting an index object after first usage (default: `false`). - */ - persist?: boolean; -} - -/** -* Interface defining an `ArrayIndex` constructor which is both "newable" and "callable". -*/ -interface Constructor { - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var Uint8Array = require( './../../../uint8' ); - * - * var x = new Uint8Array( [ 1, 0, 1, 0 ] ); - * - * var idx = new ArrayIndex( x ); - * // returns - */ - new( x: Uint8Array, options?: Options ): MaskArrayIndex; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var BooleanArray = require( './../../../bool' ); - * - * var x = new BooleanArray( [ true, false, true, false ] ); - * - * var idx = new ArrayIndex( x ); - * // returns - */ - new( x: BooleanArray, options?: Options ): BooleanArrayIndex; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var Int32Array = require( './../../../int32' ); - * - * var x = new Int32Array( [ 1, 0, 1, 0 ] ); - * - * var idx = new ArrayIndex( x ); - * // returns - */ - new( x: Int32Array, options?: Options ): Int32ArrayIndex; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var idx = new ArrayIndex( x ); - * // returns - */ - new( x: GenericIntegerIndexArray, options?: Options ): GenericIntegerArrayIndex; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var x = [ true, false, true, false ]; - * - * var idx = new ArrayIndex( x ); - * // returns - */ - new( x: GenericBooleanIndexArray, options?: Options ): GenericBooleanArrayIndex; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var Uint8Array = require( './../../../uint8' ); - * - * var x = new Uint8Array( [ 1, 0, 1, 0 ] ); - * - * var idx = new ArrayIndex( x ); - * // returns - */ - new( x: IndexArray, options?: Options ): ArrayIndex; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var Uint8Array = require( './../../../uint8' ); - * - * var x = new Uint8Array( [ 1, 0, 1, 0 ] ); - * - * var idx = ArrayIndex( x ); - * // returns - */ - ( x: Uint8Array, options?: Options ): MaskArrayIndex; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var BooleanArray = require( './../../../bool' ); - * - * var x = new BooleanArray( [ true, false, true, false ] ); - * - * var idx = ArrayIndex( x ); - * // returns - */ - ( x: BooleanArray, options?: Options ): BooleanArrayIndex; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var Int32Array = require( './../../../int32' ); - * - * var x = new Int32Array( [ 1, 0, 1, 0 ] ); - * - * var idx = ArrayIndex( x ); - * // returns - */ - ( x: Int32Array, options?: Options ): Int32ArrayIndex; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var idx = ArrayIndex( x ); - * // returns - */ - ( x: GenericIntegerIndexArray, options?: Options ): GenericIntegerArrayIndex; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var x = [ true, false, true, false ]; - * - * var idx = ArrayIndex( x ); - * // returns - */ - ( x: GenericBooleanIndexArray, options?: Options ): GenericBooleanArrayIndex; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var Uint8Array = require( './../../../uint8' ); - * - * var x = new Uint8Array( [ 1, 0, 1, 0 ] ); - * - * var idx = ArrayIndex( x ); - * // returns - */ - ( x: IndexArray, options?: Options ): ArrayIndex; - - /** - * String value of the constructor name. - */ - name: 'ArrayIndex'; - - /** - * Frees the `ArrayIndex` associated with a provided identifier. - * - * @param id - identifier - * @returns boolean indicating whether an `ArrayIndex` was successfully freed - * - * @example - * var Uint8Array = require( './../../../uint8' ); - * - * var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), { - * 'persist': true - * }); - * // returns - * - * // ... - * - * var out = ArrayIndex.free( idx.id ); - * // returns true - */ - free( id: string ): boolean; - - /** - * Returns the array associated with a provided identifier. - * - * @param id - identifier - * @returns object containing array index data - * - * @example - * var Uint8Array = require( './../../../uint8' ); - * - * var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), { - * 'persist': true - * }); - * // returns - * - * // ... - * - * var o = ArrayIndex.get( idx.id ); - * // returns {...} - * - * var d = o.data; - * // returns [ 1, 0, 1, 0 ] - * - * var t = o.type; - * // returns 'mask' - * - * var dt = o.dtype; - * // returns 'uint8' - */ - get( id: string ): T | null; -} - -/** -* Array index constructor. -* -* @param x - input array -* @param options - function options -* @param options.persist - boolean indicating whether to continue persisting an index object after first usage -* @returns ArrayIndex instance -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 1, 0, 1, 0 ] ); -* -* var idx = new ArrayIndex( x ); -* // returns -*/ -declare var ctor: Constructor; - - -// EXPORTS // - -export = ctor; diff --git a/index/docs/types/test.ts b/index/docs/types/test.ts deleted file mode 100644 index cd02d860a..000000000 --- a/index/docs/types/test.ts +++ /dev/null @@ -1,195 +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. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import BooleanArray = require( './../../../bool' ); -import ArrayIndex = require( './index' ); - - -// TESTS // - -// The function returns an array index... -{ - const x = [ 1, 2, 3, 4 ]; - const y = [ true, false, true, false ]; - const z = new Uint8Array( [ 1, 0, 1, 0 ] ); - const w = new Int32Array( [ 1, 2, 3, 4 ] ); - const v = new BooleanArray( [ true, false, true, false ] ); - - new ArrayIndex( x ); // $ExpectType GenericIntegerArrayIndex - new ArrayIndex( y ); // $ExpectType GenericBooleanArrayIndex - new ArrayIndex( z ); // $ExpectType MaskArrayIndex - new ArrayIndex( w ); // $ExpectType Int32ArrayIndex - new ArrayIndex( v ); // $ExpectType BooleanArrayIndex - - new ArrayIndex( x, { 'persist': true } ); // $ExpectType GenericIntegerArrayIndex - new ArrayIndex( y, { 'persist': true } ); // $ExpectType GenericBooleanArrayIndex - new ArrayIndex( z, { 'persist': true } ); // $ExpectType MaskArrayIndex - new ArrayIndex( w, { 'persist': true } ); // $ExpectType Int32ArrayIndex - new ArrayIndex( v, { 'persist': true } ); // $ExpectType BooleanArrayIndex - - ArrayIndex( x ); // $ExpectType GenericIntegerArrayIndex - ArrayIndex( y ); // $ExpectType GenericBooleanArrayIndex - ArrayIndex( z ); // $ExpectType MaskArrayIndex - ArrayIndex( w ); // $ExpectType Int32ArrayIndex - ArrayIndex( v ); // $ExpectType BooleanArrayIndex - - ArrayIndex( x, { 'persist': true } ); // $ExpectType GenericIntegerArrayIndex - ArrayIndex( y, { 'persist': true } ); // $ExpectType GenericBooleanArrayIndex - ArrayIndex( z, { 'persist': true } ); // $ExpectType MaskArrayIndex - ArrayIndex( w, { 'persist': true } ); // $ExpectType Int32ArrayIndex - ArrayIndex( v, { 'persist': true } ); // $ExpectType BooleanArrayIndex -} - -// The compiler throws an error if the function is provided first argument which is not a valid collection... -{ - ArrayIndex( 'abc' ); // $ExpectError - ArrayIndex( 1 ); // $ExpectError - ArrayIndex( null ); // $ExpectError - ArrayIndex( void 0 ); // $ExpectError - ArrayIndex( true ); // $ExpectError - ArrayIndex( false ); // $ExpectError - ArrayIndex( {} ); // $ExpectError - ArrayIndex( [ {} ] ); // $ExpectError - ArrayIndex( ( x: number ): number => x ); // $ExpectError - - ArrayIndex( 'abc', {} ); // $ExpectError - ArrayIndex( 1, {} ); // $ExpectError - ArrayIndex( null, {} ); // $ExpectError - ArrayIndex( void 0, {} ); // $ExpectError - ArrayIndex( true, {} ); // $ExpectError - ArrayIndex( false, {} ); // $ExpectError - ArrayIndex( {}, {} ); // $ExpectError - ArrayIndex( [ {} ], {} ); // $ExpectError - ArrayIndex( ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided second argument which is not an object... -{ - const x = [ 1, 2, 3, 4 ]; - - ArrayIndex( x, 'abc' ); // $ExpectError - ArrayIndex( x, 1 ); // $ExpectError - ArrayIndex( x, null ); // $ExpectError - ArrayIndex( x, true ); // $ExpectError - ArrayIndex( x, false ); // $ExpectError - ArrayIndex( x, [ {} ] ); // $ExpectError - ArrayIndex( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided `persist` option which is not a boolean... -{ - const x = [ 1, 2, 3, 4 ]; - - ArrayIndex( x, { 'persist': 'abc' } ); // $ExpectError - ArrayIndex( x, { 'persist': 1 } ); // $ExpectError - ArrayIndex( x, { 'persist': null } ); // $ExpectError - ArrayIndex( x, { 'persist': {} } ); // $ExpectError - ArrayIndex( x, { 'persist': [] } ); // $ExpectError - ArrayIndex( x, { 'persist': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4 ]; - - ArrayIndex(); // $ExpectError - ArrayIndex( x, {}, {} ); // $ExpectError -} - -// Attached to the main export is a `free` function which returns a boolean... -{ - ArrayIndex.free( '0' ); // $ExpectType boolean -} - -// The compiler throws an error if the `free` method is provided first argument which is not a string... -{ - ArrayIndex.free( 1 ); // $ExpectError - ArrayIndex.free( null ); // $ExpectError - ArrayIndex.free( void 0 ); // $ExpectError - ArrayIndex.free( true ); // $ExpectError - ArrayIndex.free( false ); // $ExpectError - ArrayIndex.free( {} ); // $ExpectError - ArrayIndex.free( [] ); // $ExpectError - ArrayIndex.free( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `free` method is provided an unsupported number of arguments... -{ - ArrayIndex.free(); // $ExpectError - ArrayIndex.free( '0', {} ); // $ExpectError -} - -// Attached to the main export is a `get` function which returns array object data... -{ - ArrayIndex.get( '0' ); // $ExpectType IndexArrayObject | null -} - -// The compiler throws an error if the `get` method is provided first argument which is not a string... -{ - ArrayIndex.get( 1 ); // $ExpectError - ArrayIndex.get( null ); // $ExpectError - ArrayIndex.get( void 0 ); // $ExpectError - ArrayIndex.get( true ); // $ExpectError - ArrayIndex.get( false ); // $ExpectError - ArrayIndex.get( {} ); // $ExpectError - ArrayIndex.get( [] ); // $ExpectError - ArrayIndex.get( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `get` method is provided an unsupported number of arguments... -{ - ArrayIndex.get(); // $ExpectError - ArrayIndex.get( '0', {} ); // $ExpectError -} - -// An array index has a `dtype` property which returns a string... -{ - const x = new ArrayIndex( [ 1, 2, 3, 4 ] ); - - x.dtype; // $ExpectType "generic" -} - -// An array index has an `id` property which returns a string... -{ - const x = new ArrayIndex( [ 1, 2, 3, 4 ] ); - - x.id; // $ExpectType string -} - -// An array index has a `type` property which returns a string... -{ - const x = new ArrayIndex( [ 1, 2, 3, 4 ] ); - - x.type; // $ExpectType "int" -} - -// An array index has a `data` property which returns a collection... -{ - const x = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); - - x.data; // $ExpectType Uint8Array -} - -// An array index has an `isCached` property which returns a boolean... -{ - const x = new ArrayIndex( [ 1, 2, 3, 4 ] ); - - x.isCached; // $ExpectType boolean -} diff --git a/index/examples/index.js b/index/examples/index.js deleted file mode 100644 index 3adfc357a..000000000 --- a/index/examples/index.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -var Uint8Array = require( './../../uint8' ); -var Int32Array = require( './../../int32' ); -var BooleanArray = require( './../../bool' ); -var ArrayIndex = require( './../lib' ); - -var x = new Uint8Array( [ 1, 0, 1, 0 ] ); -var i = new ArrayIndex( x ); -// returns - -var o = ArrayIndex.get( i.id ); -// returns {...} - -console.log( 'Type: %s. Data type: %s.', o.type, o.dtype ); - -x = [ true, false, true, false ]; -i = new ArrayIndex( x ); -// returns - -o = ArrayIndex.get( i.id ); -// returns {...} - -console.log( 'Type: %s. Data type: %s.', o.type, o.dtype ); - -x = new BooleanArray( [ true, false, true, false ] ); -i = new ArrayIndex( x ); -// returns - -o = ArrayIndex.get( i.id ); -// returns {...} - -console.log( 'Type: %s. Data type: %s.', o.type, o.dtype ); - -x = new Int32Array( [ 1, 3, 4, 7 ] ); -i = new ArrayIndex( x ); -// returns - -o = ArrayIndex.get( i.id ); -// returns {...} - -console.log( 'Type: %s. Data type: %s.', o.type, o.dtype ); - -x = [ 1, 3, 4, 7 ]; -i = new ArrayIndex( x ); -// returns - -o = ArrayIndex.get( i.id ); -// returns {...} - -console.log( 'Type: %s. Data type: %s.', o.type, o.dtype ); diff --git a/index/lib/cache.js b/index/lib/cache.js deleted file mode 100644 index 4da407f3c..000000000 --- a/index/lib/cache.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var LinkedList = require( '@stdlib/dstructs/linked-list' ); - - -// MAIN // - -/** -* Cache for storing index arrays. -* -* @private -* @name cache -* @type {LinkedList} -*/ -var cache = new LinkedList(); // note: created as a linked list to allow for more efficient removal of expired index arrays - - -// EXPORTS // - -module.exports = cache; diff --git a/index/lib/cache_gc.js b/index/lib/cache_gc.js deleted file mode 100644 index b3160110a..000000000 --- a/index/lib/cache_gc.js +++ /dev/null @@ -1,59 +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. -*/ - -'use strict'; - -// MODULES // - -var cache = require( './cache.js' ); - - -// MAIN // - -/** -* Performs garbage collection on the index cache. -* -* @private -* @returns {Object} garbage collection results -*/ -function gc() { - var node; - var N; - var M; - var v; - - node = cache.first(); - N = cache.length; - while ( node ) { - v = node.value; - if ( !v.persist ) { - cache.remove( node ); - } - node = node.next; - } - M = cache.length; - return { - 'size': M, - 'removed': N - M - }; -} - - -// EXPORTS // - -module.exports = gc; diff --git a/index/lib/defaults.js b/index/lib/defaults.js deleted file mode 100644 index 44fa8dc10..000000000 --- a/index/lib/defaults.js +++ /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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns default options. -* -* @private -* @returns {Object} defaults -* -* @example -* var o = defaults(); -* // returns {...} -*/ -function defaults() { - return { - 'persist': false - }; -} - - -// EXPORTS // - -module.exports = defaults; diff --git a/index/lib/find.js b/index/lib/find.js deleted file mode 100644 index 3e14813f1..000000000 --- a/index/lib/find.js +++ /dev/null @@ -1,49 +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. -*/ - -'use strict'; - -// MODULES // - -var cache = require( './cache.js' ); - - -// MAIN // - -/** -* Returns an array index object associated with a specified identifier. -* -* @private -* @param {*} id - identifier -* @returns {(Node|null)} array index object -*/ -function find( id ) { // eslint-disable-line stdlib/no-redeclare - var node = cache.first(); - while ( node ) { - if ( node.value.id === id ) { - return node; - } - node = node.next; - } - return null; -} - - -// EXPORTS // - -module.exports = find; diff --git a/index/lib/id.js b/index/lib/id.js deleted file mode 100644 index 64b99b46b..000000000 --- a/index/lib/id.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -// VARIABLES // - -var COUNTER = -1; // TODO: consider another approach for unique identifier generation. For most cases, this should suffice; however, it is possible that two different libraries, both relying on separate copies of this package, may trigger id collisions in the event that instantiated instances were to interact (e.g., a consumer attempting to free an instance instantiated by another copy of the package, etc). - - -// MAIN // - -/** -* Generates a new identifier. -* -* @private -* @returns {string} identifier -* -* @example -* var v = id(); -* // returns -*/ -function id() { - COUNTER += 1; - return COUNTER.toString(); -} - - -// EXPORTS // - -module.exports = id; diff --git a/index/lib/index.js b/index/lib/index.js deleted file mode 100644 index 6c5586d89..000000000 --- a/index/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Array index constructor. -* -* @module @stdlib/array/index -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* var ArrayIndex = require( '@stdlib/array/index' ); -* -* var x = new Uint8Array( [ 1, 0, 1, 0 ] ); -* -* var idx = new ArrayIndex( x ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/index/lib/main.js b/index/lib/main.js deleted file mode 100644 index 7b857b20f..000000000 --- a/index/lib/main.js +++ /dev/null @@ -1,450 +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. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var isAccessorArray = require( './../../base/assert/is-accessor-array' ); -var array2json = require( './../../to-json' ); -var dtype = require( './../../dtype' ); -var copy = require( './../../base/copy' ); -var resolveGetter = require( './../../base/resolve-getter' ); -var format = require( '@stdlib/string/format' ); -var defaults = require( './defaults.js' ); -var validate = require( './validate.js' ); -var cache = require( './cache.js' ); -var findArrayIndex = require( './find.js' ); -var generateId = require( './id.js' ); - - -// MAIN // - -/** -* Array index constructor. -* -* @constructor -* @param {Collection} x - input array -* @param {Options} [options] - function options -* @param {boolean} [options.persist=false] - boolean indicating whether to continue persisting an index object after first usage -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} first argument must be a valid index array -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {ArrayIndex} ArrayIndex instance -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var x = new Uint8Array( [ 1, 0, 1, 0 ] ); -* -* var idx = new ArrayIndex( x ); -* // returns -*/ -function ArrayIndex( x ) { - var opts; - var err; - var get; - var dt; - var t; - var v; - if ( !(this instanceof ArrayIndex) ) { - if ( arguments.length > 1 ) { - return new ArrayIndex( x, arguments[ 1 ] ); - } - return new ArrayIndex( x ); - } - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) ); - } - dt = dtype( x ); - - // When provided a "generic" array or an array of an unknown data type, attempt to infer the type of index array... - if ( dt === 'generic' || dt === null ) { - if ( x.length > 0 ) { - get = resolveGetter( x ); - v = get( x, 0 ); - - // Infer the "type" of index array from the first element... - if ( isBoolean( v ) ) { - t = 'bool'; - } else if ( isInteger( v ) ) { - t = 'int'; - } else { - throw new TypeError( 'invalid argument. First argument must be a valid index array.' ); - } - } else { - t = 'int'; - } - } else if ( dt === 'int32' ) { - t = 'int'; - } else if ( dt === 'uint8' ) { - t = 'mask'; - } else if ( dt === 'bool' ) { - t = 'bool'; - } else { - throw new TypeError( 'invalid argument. First argument must be a valid index array.' ); - } - // Resolve index options: - opts = defaults(); - if ( arguments.length > 1 ) { - err = validate( opts, arguments[ 1 ] ); - if ( err ) { - throw err; - } - } - // Add the array index to the index cache: - cache.push({ - 'id': generateId(), - 'ref': this, - 'data': x, - 'type': t, - 'dtype': dt, - 'persist': opts.persist - }); - - // Store a reference to the cache node: - setReadOnly( this, '_node', cache.last() ); - - // Initialize a boolean flag indicating whether an array index object has been invalidated (i.e., freed): - setNonEnumerable( this, '_invalidated', false ); - - return this; -} - -/** -* Constructor name. -* -* @name name -* @memberof ArrayIndex -* @readonly -* @type {string} -* @default 'ArrayIndex' -* -* @example -* var str = ArrayIndex.name; -* // returns 'ArrayIndex' -*/ -setReadOnly( ArrayIndex, 'name', 'ArrayIndex' ); - -/** -* Frees an array index object associated with a provided identifier. -* -* @name free -* @memberof ArrayIndex -* @type {Function} -* @param {string} id - identifier -* @returns {boolean} boolean indicating whether an array index object was successfully freed -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), { -* 'persist': true -* }); -* // returns -* -* // ... -* -* var out = ArrayIndex.free( idx.id ); -* // returns true -*/ -setReadOnly( ArrayIndex, 'free', function free( id ) { - var node; - var v; - - // Retrieve the array index object with the specified identifier: - node = findArrayIndex( id ); - if ( node === null ) { - return false; - } - v = node.value; - - // Invalidate the array instance object: - setReadOnly( v.ref, '_invalidated', true ); - - // Remove the array instance from the cache: - cache.remove( node ); - - // Remove the reference to the original array: - v.data = null; - - return true; -}); - -/** -* Returns the array associated with a provided identifier. -* -* @name get -* @memberof ArrayIndex -* @type {Function} -* @param {string} id - identifier -* @returns {(Object|null)} object containing array index data -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ), { -* 'persist': true -* }); -* // returns -* -* // ... -* -* var o = ArrayIndex.get( idx.id ); -* // returns {...} -* -* var d = o.data; -* // returns [ 1, 0, 1, 0 ] -* -* var t = o.type; -* // returns 'mask' -* -* var dt = o.dtype; -* // returns 'uint8' -*/ -setReadOnly( ArrayIndex, 'get', function get( id ) { - var node; - var out; - var v; - - // Retrieve the array index object with the specified identifier: - node = findArrayIndex( id ); - if ( node === null ) { - return null; - } - v = node.value; - - // Assemble the output object: - out = { - 'data': v.data, - 'type': v.type, - 'dtype': v.dtype - }; - - // If the array index object should not be persisted, go ahead and remove the object from the cache... - if ( !v.persist ) { - ArrayIndex.free( id ); // note: this should come last, after having retrieved all desired array index node data - } - return out; -}); - -/** -* Returns the underlying array data of an array index object. -* -* @name data -* @memberof ArrayIndex.prototype -* @readonly -* @type {Collection} -* @throws {Error} array index is no longer valid -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -* // returns -* -* var v = idx.data; -* // returns [ 1, 0, 1, 0 ] -*/ -setReadOnlyAccessor( ArrayIndex.prototype, 'data', function get() { - if ( this._invalidated ) { - throw new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' ); - } - return this._node.value.data; -}); - -/** -* Returns the underlying array data type of an array index object. -* -* @name dtype -* @memberof ArrayIndex.prototype -* @readonly -* @type {string} -* @throws {Error} array index is no longer valid -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -* // returns -* -* var t = idx.dtype; -* // returns 'uint8' -*/ -setReadOnlyAccessor( ArrayIndex.prototype, 'dtype', function get() { - if ( this._invalidated ) { - throw new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' ); - } - return this._node.value.dtype; -}); - -/** -* Returns the identifier associated with an array index object. -* -* @name id -* @memberof ArrayIndex.prototype -* @readonly -* @type {string} -* @throws {Error} array index is no longer valid -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -* // returns -* -* var id = idx.id; -* // returns -*/ -setReadOnlyAccessor( ArrayIndex.prototype, 'id', function get() { - if ( this._invalidated ) { - throw new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' ); - } - return this._node.value.id; -}); - -/** -* Returns a boolean indicating if an array index is actively cached. -* -* @name isCached -* @memberof ArrayIndex.prototype -* @readonly -* @type {boolean} -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -* // returns -* -* var out = idx.isCached; -* // returns true -*/ -setReadOnlyAccessor( ArrayIndex.prototype, 'isCached', function get() { - return !this._invalidated; -}); - -/** -* Returns the type of an array index object. -* -* @name type -* @memberof ArrayIndex.prototype -* @readonly -* @type {string} -* @throws {Error} array index is no longer valid -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -* // returns -* -* var t = idx.type; -* // returns 'mask' -*/ -setReadOnlyAccessor( ArrayIndex.prototype, 'type', function get() { - if ( this._invalidated ) { - throw new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' ); - } - return this._node.value.type; -}); - -/** -* Serializes an array index object to a string. -* -* @name toString -* @memberof ArrayIndex.prototype -* @type {Function} -* @throws {Error} array index is no longer valid -* @returns {string} serialized array index object -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -* // returns -* -* var str = idx.toString(); -* // e.g., 'ArrayIndex<0>' -*/ -setReadOnly( ArrayIndex.prototype, 'toString', function toString() { - var v; - if ( this._invalidated ) { - throw new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' ); - } - v = this._node.value; - return 'ArrayIndex<' + v.id + '>'; -}); - -/** -* Serializes an array index object as a JSON object. -* -* ## Notes -* -* - `JSON.stringify()` implicitly calls this method when stringifying an `ArrayIndex` instance. -* -* @name toJSON -* @memberof ArrayIndex.prototype -* @type {Function} -* @throws {Error} array index is no longer valid -* @returns {Object} serialized array index object -* -* @example -* var Uint8Array = require( '@stdlib/array/uint8' ); -* -* var idx = new ArrayIndex( new Uint8Array( [ 1, 0, 1, 0 ] ) ); -* // returns -* -* var o = idx.toJSON(); -* // returns { 'type': 'ArrayIndex', 'data': { 'type': 'Uint8Array', 'data': [ 1, 0, 1, 0 ] } } -*/ -setReadOnly( ArrayIndex.prototype, 'toJSON', function toJSON() { - var v; - var o; - if ( this._invalidated ) { - throw new Error( 'invalid operation. This array index instance has already been freed and can no longer be used.' ); - } - v = this._node.value; - if ( v.dtype === 'generic' || v.dtype === null ) { - if ( isAccessorArray( v.data ) ) { - o = copy( v.data ); - } else { - o = v.data; - } - } else { - o = array2json( v.data ); - } - return { - 'type': 'ArrayIndex', - 'data': o - }; -}); - - -// EXPORTS // - -module.exports = ArrayIndex; diff --git a/index/lib/validate.js b/index/lib/validate.js deleted file mode 100644 index 75d3a46aa..000000000 --- a/index/lib/validate.js +++ /dev/null @@ -1,66 +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. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert/is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {boolean} [options.persist] - boolean indicating whether to continue persisting an index object after first usage -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'persist': false -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'persist' ) ) { - opts.persist = options.persist; - if ( !isBoolean( opts.persist ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'persist', opts.persist ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/index/package.json b/index/package.json deleted file mode 100644 index e3241bb6f..000000000 --- a/index/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/index", - "version": "0.0.0", - "description": "Array index constructor.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "fancy", - "indexing", - "index", - "vector", - "slice", - "constructor", - "ctor" - ] -} diff --git a/index/test/test.js b/index/test/test.js deleted file mode 100644 index 1827b4de2..000000000 --- a/index/test/test.js +++ /dev/null @@ -1,1317 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var Uint8Array = require( './../../uint8' ); -var Int32Array = require( './../../int32' ); -var Float64Array = require( './../../float64' ); -var BooleanArray = require( './../../bool' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var array2json = require( './../../to-json' ); -var ArrayIndex = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ArrayIndex, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function is a constructor', function test( t ) { - var x; - - x = new ArrayIndex( [ 1, 2, 3 ] ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = new ArrayIndex( [ true, false, true ] ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = new ArrayIndex( toAccessorArray( [ 1, 2, 3 ] ) ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = new ArrayIndex( new Uint8Array( [ 1, 0, 1 ] ) ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = new ArrayIndex( new BooleanArray( [ 1, 0, 1 ] ) ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = new ArrayIndex( new Int32Array( [ 1, 0, 1 ] ) ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function is a constructor (options)', function test( t ) { - var x; - - x = new ArrayIndex( [ 1, 2, 3 ], {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = new ArrayIndex( [ true, false, true ], {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = new ArrayIndex( toAccessorArray( [ 1, 2, 3 ] ), {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = new ArrayIndex( new Uint8Array( [ 1, 0, 1 ] ), {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = new ArrayIndex( new BooleanArray( [ 1, 0, 1 ] ), {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = new ArrayIndex( new Int32Array( [ 1, 0, 1 ] ), {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not require the `new` keyword', function test( t ) { - var idx; - var x; - - idx = ArrayIndex; - - x = idx( [ 1, 2, 3 ] ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = idx( [ true, false, true ] ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = idx( toAccessorArray( [ 1, 2, 3 ] ) ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = idx( new Uint8Array( [ 1, 0, 1 ] ) ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = idx( new BooleanArray( [ 1, 0, 1 ] ) ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = idx( new Int32Array( [ 1, 0, 1 ] ) ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function does not require the `new` keyword (options)', function test( t ) { - var idx; - var x; - - idx = ArrayIndex; - - x = idx( [ 1, 2, 3 ], {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = idx( [ true, false, true ], {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = idx( toAccessorArray( [ 1, 2, 3 ] ), {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = idx( new Uint8Array( [ 1, 0, 1 ] ), {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = idx( new BooleanArray( [ 1, 0, 1 ] ), {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - x = idx( new Int32Array( [ 1, 0, 1 ] ), {} ); - t.strictEqual( instanceOf( x, ArrayIndex ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = new ArrayIndex( value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = new ArrayIndex( value, {} ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a valid index array', function test( t ) { - var values; - var i; - - values = [ - [ 'a', 'b', 'c' ], - new Float64Array( [ 1.0, 2.0, 3.0 ] ), - [ 1.5, 2.5, 3.5 ], - [ null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = new ArrayIndex( value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a valid index array (options)', function test( t ) { - var values; - var i; - - values = [ - [ 'a', 'b', 'c' ], - new Float64Array( [ 1.0, 2.0, 3.0 ] ), - [ 1.5, 2.5, 3.5 ], - [ null ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = new ArrayIndex( value, {} ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = new ArrayIndex( [ 1, 2, 3 ], value ); // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function throws an error if provided an invalid option', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = new ArrayIndex( [ 1, 2, 3 ], { // eslint-disable-line no-unused-vars - 'persist': value - }); - }; - } -}); - -tape( 'the function returns an instance having a `data` property which returns the underlying index array', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.data, x, 'returns expected value' ); - - x = []; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.data, x, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.data, x, 'returns expected value' ); - - x = new Uint8Array( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.data, x, 'returns expected value' ); - - x = new BooleanArray( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.data, x, 'returns expected value' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.data, x, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.data, x, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an instance having a `data` property which throws an error if an instance has been invalidated', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = []; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new Uint8Array( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new BooleanArray( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - t.end(); - - function invalidated( idx ) { - return function invalidated() { - var v = idx.data; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an instance having a `dtype` property which returns the underlying index array data type', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.dtype, 'generic', 'returns expected value' ); - - x = []; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.dtype, 'generic', 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.dtype, null, 'returns expected value' ); - - x = new Uint8Array( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.dtype, 'uint8', 'returns expected value' ); - - x = new BooleanArray( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.dtype, 'bool', 'returns expected value' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.dtype, 'generic', 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.dtype, 'int32', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an instance having a `dtype` property which throws an error if an instance has been invalidated', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = []; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new Uint8Array( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new BooleanArray( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - t.end(); - - function invalidated( idx ) { - return function invalidated() { - var v = idx.dtype; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an instance having an `id` property which returns the array index identifier', function test( t ) { - var obj; - var idx; - var x; - var i; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - t.strictEqual( isString( idx.id ), true, 'returns expected value' ); - - x = []; - idx = new ArrayIndex( x ); - - t.strictEqual( isString( idx.id ), true, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( isString( idx.id ), true, 'returns expected value' ); - - x = new Uint8Array( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( isString( idx.id ), true, 'returns expected value' ); - - x = new BooleanArray( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( isString( idx.id ), true, 'returns expected value' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - t.strictEqual( isString( idx.id ), true, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( isString( idx.id ), true, 'returns expected value' ); - - // Should assign unique identifiers... - obj = {}; - for ( i = 0; i < 100; i++ ) { - idx = new ArrayIndex( [ 1, 2, 3 ] ); - if ( obj[ idx.id ] === void 0 ) { - obj[ idx.id ] = true; - } else { - t.fail( 'should not return a duplicate id: ' + idx.id ); - } - } - t.end(); -}); - -tape( 'the function returns an instance having an `id` property which throws an error if an instance has been invalidated', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = []; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new Uint8Array( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new BooleanArray( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - t.end(); - - function invalidated( idx ) { - return function invalidated() { - var v = idx.id; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an instance having an `isCached` property which returns a boolean indicating whether an array index is actively cached', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - ArrayIndex.get( idx.id ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x, { - 'persist': true - }); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - ArrayIndex.get( idx.id ); - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - ArrayIndex.get( idx.id ); - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - ArrayIndex.get( idx.id ); - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - ArrayIndex.get( idx.id ); - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - ArrayIndex.free( idx.id ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an instance having a `type` property which returns the array index type', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.type, 'int', 'returns expected value' ); - - x = []; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.type, 'int', 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.type, 'int', 'returns expected value' ); - - x = new Uint8Array( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.type, 'mask', 'returns expected value' ); - - x = new BooleanArray( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.type, 'bool', 'returns expected value' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.type, 'bool', 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.type, 'int', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an instance having a `type` property which throws an error if an instance has been invalidated', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = []; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new Uint8Array( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new BooleanArray( [ 0, 1, 0, 1 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - t.end(); - - function invalidated( idx ) { - return function invalidated() { - var v = idx.type; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an instance having a custom `toString` method', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - t.strictEqual( /ArrayIndex<[^>]+>/.test( idx.toString() ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an instance having a custom `toString` method which throws an error if an instance has been invalidated', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - t.end(); - - function invalidated( idx ) { - return function invalidated() { - idx.toString(); - }; - } -}); - -tape( 'the function returns an instance having a custom `toJSON` method', function test( t ) { - var expected; - var actual; - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - expected = { - 'type': 'ArrayIndex', - 'data': [ 1, 2, 3 ] - }; - actual = idx.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - expected = { - 'type': 'ArrayIndex', - 'data': [ true, false, true, false ] - }; - actual = idx.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - expected = { - 'type': 'ArrayIndex', - 'data': [ 1, 2, 3 ] - }; - actual = idx.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Uint8Array( [ 1, 0, 1, 0 ] ); - idx = new ArrayIndex( x ); - - expected = { - 'type': 'ArrayIndex', - 'data': array2json( x ) - }; - actual = idx.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new BooleanArray( [ 1, 0, 1, 0 ] ); - idx = new ArrayIndex( x ); - - expected = { - 'type': 'ArrayIndex', - 'data': array2json( x ) - }; - actual = idx.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - idx = new ArrayIndex( x ); - - expected = { - 'type': 'ArrayIndex', - 'data': array2json( x ) - }; - actual = idx.toJSON(); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an instance having a custom `toJSON` method which throws an error if an instance has been invalidated', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - ArrayIndex.get( idx.id ); - t.throws( invalidated( idx ), Error, 'throws an error' ); - - t.end(); - - function invalidated( idx ) { - return function invalidated() { - idx.toJSON(); - }; - } -}); - -tape( 'attached to the constructor is a `name` property', function test( t ) { - t.strictEqual( ArrayIndex.name, 'ArrayIndex', 'returns expected value' ); - t.end(); -}); - -tape( 'attached to the constructor is a `free` method to free an actively cached index array (non-persisted)', function test( t ) { - var actual; - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x, { - 'persist': false - }); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = new BooleanArray( [ 1, 0, 1, 0 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = new Uint8Array( [ 1, 0, 1, 0 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a `free` method to free an actively cached index array (persisted)', function test( t ) { - var actual; - var opts; - var idx; - var x; - - opts = { - 'persist': true - }; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x, opts ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x, opts ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x, opts ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = new BooleanArray( [ 1, 0, 1, 0 ] ); - idx = new ArrayIndex( x, opts ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = new Uint8Array( [ 1, 0, 1, 0 ] ); - idx = new ArrayIndex( x, opts ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x, opts ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - actual = ArrayIndex.free( idx.id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a `free` method which returns `false` if an index array has already been freed', function test( t ) { - var actual; - var idx; - var id; - var x; - - // Generic: - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - id = idx.id; - actual = ArrayIndex.free( id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - actual = ArrayIndex.free( id ); - t.strictEqual( actual, false, 'returns expected value' ); - - // Generic (persisted): - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x, { - 'persist': true - }); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - id = idx.id; - actual = ArrayIndex.free( id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - actual = ArrayIndex.free( id ); - t.strictEqual( actual, false, 'returns expected value' ); - - // Accessor: - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - id = idx.id; - actual = ArrayIndex.free( id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - actual = ArrayIndex.free( id ); - t.strictEqual( actual, false, 'returns expected value' ); - - // Boolean: - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - id = idx.id; - actual = ArrayIndex.free( id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - actual = ArrayIndex.free( id ); - t.strictEqual( actual, false, 'returns expected value' ); - - // Boolean: - x = new BooleanArray( [ true, false, true, false ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - id = idx.id; - actual = ArrayIndex.free( id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - actual = ArrayIndex.free( id ); - t.strictEqual( actual, false, 'returns expected value' ); - - // Mask: - x = new Uint8Array( [ 1, 0, 1, 0 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - id = idx.id; - actual = ArrayIndex.free( id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - actual = ArrayIndex.free( id ); - t.strictEqual( actual, false, 'returns expected value' ); - - // Integer: - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - id = idx.id; - actual = ArrayIndex.free( id ); - t.strictEqual( actual, true, 'returns expected value' ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - actual = ArrayIndex.free( id ); - t.strictEqual( actual, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a `get` method to return index array data', function test( t ) { - var expected; - var actual; - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - expected = { - 'data': x, - 'type': 'int', - 'dtype': 'generic' - }; - actual = ArrayIndex.get( idx.id ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( actual.data, x, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x, { - 'persist': true - }); - - expected = { - 'data': x, - 'type': 'int', - 'dtype': 'generic' - }; - actual = ArrayIndex.get( idx.id ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( actual.data, x, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - expected = { - 'data': x, - 'type': 'int', - 'dtype': null - }; - actual = ArrayIndex.get( idx.id ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( actual.data, x, 'returns expected value' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - expected = { - 'data': x, - 'type': 'bool', - 'dtype': 'generic' - }; - actual = ArrayIndex.get( idx.id ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( actual.data, x, 'returns expected value' ); - - x = new BooleanArray( [ 1, 0, 1, 0 ] ); - idx = new ArrayIndex( x ); - - expected = { - 'data': x, - 'type': 'bool', - 'dtype': 'bool' - }; - actual = ArrayIndex.get( idx.id ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( actual.data, x, 'returns expected value' ); - - x = new Uint8Array( [ 1, 0, 1, 0 ] ); - idx = new ArrayIndex( x ); - - expected = { - 'data': x, - 'type': 'mask', - 'dtype': 'uint8' - }; - actual = ArrayIndex.get( idx.id ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( actual.data, x, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - expected = { - 'data': x, - 'type': 'int', - 'dtype': 'int32' - }; - actual = ArrayIndex.get( idx.id ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.strictEqual( actual.data, x, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a `get` method which frees non-persisted index arrays', function test( t ) { - var idx; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - ArrayIndex.get( idx.id ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x, { - 'persist': false - }); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - ArrayIndex.get( idx.id ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a `get` method which does not free persisted index arrays', function test( t ) { - var idx; - var x; - var i; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x, { - 'persist': true - }); - - t.strictEqual( idx.isCached, true, 'returns expected value' ); - - for ( i = 0; i < 100; i++ ) { - ArrayIndex.get( idx.id ); - t.strictEqual( idx.isCached, true, 'returns expected value' ); - } - ArrayIndex.free( idx.id ); - t.strictEqual( idx.isCached, false, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the constructor is a `get` method which returns `null` if unable to resolve an index array', function test( t ) { - var actual; - var idx; - var id; - var x; - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x ); - - id = idx.id; - ArrayIndex.free( id ); - actual = ArrayIndex.get( id ); - t.strictEqual( actual, null, 'returns expected value' ); - - x = [ 1, 2, 3 ]; - idx = new ArrayIndex( x, { - 'persist': true - }); - - id = idx.id; - ArrayIndex.free( id ); - actual = ArrayIndex.get( id ); - t.strictEqual( actual, null, 'returns expected value' ); - - x = toAccessorArray( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - id = idx.id; - ArrayIndex.free( id ); - actual = ArrayIndex.get( id ); - t.strictEqual( actual, null, 'returns expected value' ); - - x = [ true, false, true, false ]; - idx = new ArrayIndex( x ); - - id = idx.id; - ArrayIndex.free( id ); - actual = ArrayIndex.get( id ); - t.strictEqual( actual, null, 'returns expected value' ); - - x = new BooleanArray( [ 1, 0, 1, 0 ] ); - idx = new ArrayIndex( x ); - - id = idx.id; - ArrayIndex.free( id ); - actual = ArrayIndex.get( id ); - t.strictEqual( actual, null, 'returns expected value' ); - - x = new Uint8Array( [ 1, 0, 1, 0 ] ); - idx = new ArrayIndex( x ); - - id = idx.id; - ArrayIndex.free( id ); - actual = ArrayIndex.get( id ); - t.strictEqual( actual, null, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3 ] ); - idx = new ArrayIndex( x ); - - id = idx.id; - ArrayIndex.free( id ); - actual = ArrayIndex.get( id ); - t.strictEqual( actual, null, 'returns expected value' ); - - actual = ArrayIndex.get( '??beep_boop_foo_bar!!' ); - t.strictEqual( actual, null, 'returns expected value' ); - - t.end(); -}); diff --git a/index/test/test.validate.js b/index/test/test.validate.js deleted file mode 100644 index ccc8296af..000000000 --- a/index/test/test.validate.js +++ /dev/null @@ -1,126 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if not provided an options object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[i] ); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `persist` option which is not a boolean', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'persist': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns `null` if all options are valid', function test( t ) { - var expected; - var options; - var opts; - var err; - - options = { - 'persist': true - }; - opts = {}; - - expected = { - 'persist': true - }; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function ignores unrecognized options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': 'boop', - 'foo': 5, - 'bar': {} - }; - - opts = {}; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, {}, 'returns expected value' ); - - t.end(); -}); diff --git a/int16/README.md b/int16/README.md deleted file mode 100644 index 57c6ce948..000000000 --- a/int16/README.md +++ /dev/null @@ -1,1473 +0,0 @@ - - -# Int16Array - -> [Typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of twos-complement 16-bit signed integers in the platform byte order. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Int16Array = require( '@stdlib/array/int16' ); -``` - -#### Int16Array() - -A [typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of twos-complement 16-bit signed integers in the platform byte order. - - - -```javascript -var arr = new Int16Array(); -// returns -``` - -#### Int16Array( length ) - -Returns a [typed array][mdn-typed-array] having a specified length. - - - -```javascript -var arr = new Int16Array( 5 ); -// returns [ 0, 0, 0, 0, 0 ] -``` - -#### Int16Array( typedarray ) - -Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - - - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 5.0, 5.0, 5.0 ] ); -var arr2 = new Int16Array( arr1 ); -// returns [ 5, 5, 5 ] -``` - -#### Int16Array( obj ) - -Creates a [typed array][mdn-typed-array] from an array-like `object` or iterable. - - - -```javascript -var arr = new Int16Array( [ 5.0, 5.0, 5.0 ] ); -// returns [ 5, 5, 5 ] -``` - -#### Int16Array( buffer\[, byteOffset\[, length]] ) - -Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 8 ); -var arr = new Int16Array( buf, 0, 4 ); -// returns [ 0, 0, 0, 0 ] -``` - -* * * - -### Properties - - - -#### Int16Array.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var nbytes = Int16Array.BYTES_PER_ELEMENT; -// returns 2 -``` - - - -#### Int16Array.name - -[Typed array][mdn-typed-array] constructor name. - - - -```javascript -var str = Int16Array.name; -// returns 'Int16Array' -``` - - - -#### Int16Array.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Int16Array( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Int16Array.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Int16Array( 5 ); -var byteLength = arr.byteLength; -// returns 10 -``` - - - -#### Int16Array.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the [typed array][mdn-typed-array] from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var arr = new Int16Array( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Int16Array.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var arr = new Int16Array( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 2 -``` - - - -#### Int16Array.prototype.length - -**Read-only** property which returns the number of view elements. - - - -```javascript -var arr = new Int16Array( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Int16Array.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like `object` or an iterable. - -```javascript -var arr = Int16Array.from( [ 1, 2 ] ); -// returns [ 1, 2 ] -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2; -} - -var arr = Int16Array.from( [ 1, 2 ], mapFcn ); -// returns [ 2, 4 ] -``` - -A callback function is provided two arguments: - -- `value`: source value. -- `index`: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr = Int16Array.from( [ 1, 2 ], mapFcn, ctx ); -// returns [ 2, 4 ] - -var n = ctx.count; -// returns 2 -``` - - - -#### Int16Array.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Int16Array.of( 1, 2 ); -// returns [ 1, 2 ] -``` - - - -#### Int16Array.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within an array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 3 ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( 3, 0, 2 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( -2, -5, -3 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - - - -#### Int16Array.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - - - -```javascript -var arr = new Int16Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.entries(); - -// Iterate over key-value pairs... -var v = it.next().value; -// returns [ 0, 1 ] - -v = it.next().value; -// returns [ 1, 2 ] - -var bool = it.next().done; -// returns true -``` - - - -#### Int16Array.prototype.every( predicate\[, thisArg] ) - -Tests whether all array elements pass a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v <= 1 ); -} - -var arr = new Int16Array( [ 1, 2 ] ); - -var bool = arr.every( predicate ); -// returns false -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 1 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int16Array( [ 1, 2 ] ); - -var bool = arr.every( predicate, ctx ); -// returns true - -var n = ctx.count; -// returns 2 -``` - - - -#### Int16Array.prototype.fill( value\[, start\[, end]] ) - -Fills an array from a `start` index to an `end` index (non-inclusive) with a provided `value`. - - - -```javascript -var arr = new Int16Array( 2 ); - -// Set all array elements to the same value: -arr.fill( 2 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 2 - -// Set all array elements starting from the first index to the same value: -arr.fill( 3, 1 ); - -v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 3 - -// Set all array elements, except the last element, to the same value: -arr.fill( 4, 0, arr.length-1 ); - -v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 3 -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr = new Int16Array( 2 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( 2, -arr.length, -1 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 0 -``` - - - -#### Int16Array.prototype.filter( predicate\[, thisArg] ) - -Creates a new array (of the same data type as the host array) which includes those elements for which a `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [ 2, 3 ] -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns an empty array. - - - -```javascript -function predicate( v ) { - return ( v >= 10 ); -} - -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [] -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Int16Array.prototype.find( predicate\[, thisArg] ) - -Returns the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v > 2 ); -} - -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns 3 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `undefined`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns undefined -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v > 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate, ctx ); -// returns 3 - -var n = ctx.count; -// returns 3 -``` - - - -#### Int16Array.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 3 ); -} - -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns 2 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `-1`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns -1 -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 3 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate, ctx ); -// returns 2 - -var n = ctx.count; -// returns 3 -``` - - - -#### Int16Array.prototype.forEach( fcn\[, thisArg] ) - -Invokes a callback for each array element. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var str = ''; - -function fcn( v, i ) { - str += i + ':' + v; - if ( i < arr.length-1 ) { - str += ' '; - } -} - -arr.forEach( fcn ); - -console.log( str ); -// => '0:1 1:2 2:3' -``` - -The callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn() { - this.count += 1; -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int16Array( [ 1, 2, 3 ] ); - -arr.forEach( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Int16Array.prototype.includes( searchElement\[, fromIndex] ) - -Returns a `boolean` indicating whether an array includes a search element. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 3 ); -// returns true - -bool = arr.includes( 0 ); -// returns false -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, 1 ); -// returns false -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, -2 ); -// returns false -``` - - - -#### Int16Array.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the index of the first array element strictly equal to a search element. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 3 ); -// returns 2 - -idx = arr.indexOf( 0 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, 1 ); -// returns -1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, -2 ); -// returns -1 -``` - - - -#### Int16Array.prototype.join( \[separator] ) - -Serializes an array by joining all array elements as a string. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var str = arr.join(); -// returns '1,2,3' -``` - -By default, the method delineates array elements using a comma `,`. To specify a custom separator, provide a `separator` string. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var str = arr.join( '|' ); -// returns '1|2|3' -``` - - - -#### Int16Array.prototype.keys() - -Returns an iterator for iterating over array keys. - - - -```javascript -var arr = new Int16Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.keys(); - -// Iterate over keys... -var v = it.next().value; -// returns 0 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - - - -#### Int16Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the index of the last array element strictly equal to a search element, iterating from right to left. - - - -```javascript -var arr = new Int16Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0 ); -// returns 3 - -idx = arr.lastIndexOf( 3 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = -1`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Int16Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, 2 ); -// returns 1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Int16Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, -3 ); -// returns 1 -``` - - - -#### Int16Array.prototype.map( fcn\[, thisArg] ) - -Maps each array element to an element in a new array having the same data type as the host array. - - - -```javascript -function fcn( v ) { - return v * 2; -} - -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn ); -// returns [ 2, 4, 6 ] -``` - -A callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Int16Array.prototype.reduce( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int16Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn ); -// returns 12 -``` - -If not provided an initial value, the method invokes a provided function with the first array element as the first argument and the second array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the first array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int16Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Int16Array.prototype.reduceRight( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result, iterating from right to left. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int16Array( [ 2, 1, 3 ] ); - -var v = arr.reduceRight( fcn ); -// returns 8 -``` - -If not provided an initial value, the method invokes a provided function with the last array element as the first argument and the second-to-last array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the last array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int16Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Int16Array.prototype.reverse() - -Reverses an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Int16Array( [ 2, 0, 3 ] ); - -// Reverse the array: -arr.reverse(); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 0 - -v = arr[ 2 ]; -// returns 2 -``` - - - -#### Int16Array.prototype.set( arr\[, offset] ) - -Sets array elements. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the first two array elements: -arr.set( [ 4, 5 ] ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the last two array elements: -arr.set( [ 4, 5 ], 1 ); - -var v = arr[ 1 ]; -// returns 4 - -v = arr[ 2 ]; -// returns 5 -``` - - - -#### Int16Array.prototype.slice( \[begin\[, end]] ) - -Copies array elements to a new array with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice(); - -var bool = ( arr1 === arr2 ); -// returns false - -bool = ( arr1.buffer === arr2.buffer ); -// returns false - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 - -v = arr2[ 2 ]; -// returns 3 -``` - -By default, the method copies elements beginning with the first array element. To specify an alternative array index at which to begin copying, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 2 - -v = arr2[ 1 ]; -// returns 3 -``` - -By default, the method copies all array elements after `begin`. To specify an alternative array index at which to end copying, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 0, 2 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( -arr1.length, -1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - - - -#### Int16Array.prototype.some( predicate\[, thisArg] ) - -Tests whether at least one array element passes a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr = new Int16Array( [ 1, 2 ] ); - -var bool = arr.some( predicate ); -// returns true -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int16Array( [ 1, 1 ] ); - -var bool = arr.some( predicate, ctx ); -// returns false - -var n = ctx.count; -// returns 2 -``` - - - -#### Int16Array.prototype.sort( \[compareFunction] ) - -Sorts an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Int16Array( [ 2, 3, 0 ] ); - -// Sort the array (in ascending order): -arr.sort(); - -var v = arr[ 0 ]; -// returns 0 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 3 -``` - -By default, the method sorts array elements in ascending order. To impose a custom order, provide a `compareFunction`. - - - -```javascript -function descending( a, b ) { - return b - a; -} - -var arr = new Int16Array( [ 2, 3, 0 ] ); - -// Sort the array (in descending order): -arr.sort( descending ); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 0 -``` - -The comparison function is provided two array elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: - -- If the comparison function returns a value **less** than zero, then the method sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). -- If the comparison function returns a value **greater** than zero, then the method sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). -- If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. - - - -#### Int16Array.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray(); -// returns [ 1, 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 1 ); -// returns [ 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 0, 2 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( -arr1.length, -1 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -If the method is unable to resolve indices to a non-empty array subsequence, the method returns an empty typed array. - - - -```javascript -var arr1 = new Int16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 10, -1 ); -// returns [] -``` - - - -#### Int16Array.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific `string`. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var str = arr.toLocaleString(); -// returns '1,2,3' -``` - - - -#### Int16Array.prototype.toString() - -Serializes an array as a `string`. - - - -```javascript -var arr = new Int16Array( [ 1, 2, 3 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - - - -#### Int16Array.prototype.values() - -Returns an iterator for iterating over array elements. - - - -```javascript -var arr = new Int16Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.values(); - -// Iterate over array elements... -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -var bool = it.next().done; -// returns true -``` - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( '@stdlib/array/int16' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/int16/benchmark/benchmark.copy_within.js b/int16/benchmark/benchmark.copy_within.js deleted file mode 100644 index b6f867732..000000000 --- a/int16/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 255; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.copy_within.length.js b/int16/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index b0f5e42d6..000000000 --- a/int16/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 255; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.data.js b/int16/benchmark/benchmark.data.js deleted file mode 100644 index 4ced13981..000000000 --- a/int16/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Int16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Int16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.entries.js b/int16/benchmark/benchmark.entries.js deleted file mode 100644 index b0427cb1f..000000000 --- a/int16/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Int16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.every.js b/int16/benchmark/benchmark.every.js deleted file mode 100644 index 67572362e..000000000 --- a/int16/benchmark/benchmark.every.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/int16/benchmark/benchmark.every.length.js b/int16/benchmark/benchmark.every.length.js deleted file mode 100644 index a94be9da6..000000000 --- a/int16/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.fill.js b/int16/benchmark/benchmark.fill.js deleted file mode 100644 index 145d1ef88..000000000 --- a/int16/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.fill.length.js b/int16/benchmark/benchmark.fill.length.js deleted file mode 100644 index b18ef85a6..000000000 --- a/int16/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.filter.js b/int16/benchmark/benchmark.filter.js deleted file mode 100644 index 14a278ee0..000000000 --- a/int16/benchmark/benchmark.filter.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/int16/benchmark/benchmark.filter.length.js b/int16/benchmark/benchmark.filter.length.js deleted file mode 100644 index ac3e84419..000000000 --- a/int16/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.find.js b/int16/benchmark/benchmark.find.js deleted file mode 100644 index 293ae5915..000000000 --- a/int16/benchmark/benchmark.find.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/int16/benchmark/benchmark.find.length.js b/int16/benchmark/benchmark.find.length.js deleted file mode 100644 index da60e8cc8..000000000 --- a/int16/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.find_index.js b/int16/benchmark/benchmark.find_index.js deleted file mode 100644 index 475627ee6..000000000 --- a/int16/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/int16/benchmark/benchmark.find_index.length.js b/int16/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 6a9ed79c5..000000000 --- a/int16/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.for_each.js b/int16/benchmark/benchmark.for_each.js deleted file mode 100644 index fe74266ae..000000000 --- a/int16/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Int16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Int16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/int16/benchmark/benchmark.for_each.length.js b/int16/benchmark/benchmark.for_each.length.js deleted file mode 100644 index b1c240689..000000000 --- a/int16/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Int16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.from.js b/int16/benchmark/benchmark.from.js deleted file mode 100644 index 74ad4ec0b..000000000 --- a/int16/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Int16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt16Array( arr ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Int16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt16Array( arr ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt16Array( arr ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt16Array( arr ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt16Array( arr ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt16Array( arr ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/int16/benchmark/benchmark.includes.js b/int16/benchmark/benchmark.includes.js deleted file mode 100644 index 62c3d8dde..000000000 --- a/int16/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.includes.length.js b/int16/benchmark/benchmark.includes.length.js deleted file mode 100644 index d69dfe988..000000000 --- a/int16/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.index_of.js b/int16/benchmark/benchmark.index_of.js deleted file mode 100644 index bab8a1a73..000000000 --- a/int16/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Int16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.index_of.length.js b/int16/benchmark/benchmark.index_of.length.js deleted file mode 100644 index c2258f754..000000000 --- a/int16/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.join.js b/int16/benchmark/benchmark.join.js deleted file mode 100644 index 6f68e402d..000000000 --- a/int16/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.join.length.js b/int16/benchmark/benchmark.join.length.js deleted file mode 100644 index 4d4344de3..000000000 --- a/int16/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.js b/int16/benchmark/benchmark.js deleted file mode 100644 index b7de8c215..000000000 --- a/int16/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isInt16Array( arr ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.keys.js b/int16/benchmark/benchmark.keys.js deleted file mode 100644 index 5affbd12b..000000000 --- a/int16/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.last_index_of.js b/int16/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 00d3186a2..000000000 --- a/int16/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Int16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.last_index_of.length.js b/int16/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index aa69337dc..000000000 --- a/int16/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.length.js b/int16/benchmark/benchmark.length.js deleted file mode 100644 index e61203ec7..000000000 --- a/int16/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isInt16Array( arr ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.map.js b/int16/benchmark/benchmark.map.js deleted file mode 100644 index 4405af654..000000000 --- a/int16/benchmark/benchmark.map.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/int16/benchmark/benchmark.map.length.js b/int16/benchmark/benchmark.map.length.js deleted file mode 100644 index 2b3c70f8a..000000000 --- a/int16/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.of.js b/int16/benchmark/benchmark.of.js deleted file mode 100644 index 837f9e3c7..000000000 --- a/int16/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt16Array( arr ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.properties.js b/int16/benchmark/benchmark.properties.js deleted file mode 100644 index 2a061fcd7..000000000 --- a/int16/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.reduce.js b/int16/benchmark/benchmark.reduce.js deleted file mode 100644 index c377afa44..000000000 --- a/int16/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/int16/benchmark/benchmark.reduce.length.js b/int16/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 3320230b9..000000000 --- a/int16/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.reduce_right.js b/int16/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 130699931..000000000 --- a/int16/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/int16/benchmark/benchmark.reduce_right.length.js b/int16/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 524c9acdc..000000000 --- a/int16/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.reverse.js b/int16/benchmark/benchmark.reverse.js deleted file mode 100644 index d831070b3..000000000 --- a/int16/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.reverse.length.js b/int16/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 28d248155..000000000 --- a/int16/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.set.js b/int16/benchmark/benchmark.set.js deleted file mode 100644 index 419bb419d..000000000 --- a/int16/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Int16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Int16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Int16Array( 2 ); - buf = new Int16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.set.length.js b/int16/benchmark/benchmark.set.length.js deleted file mode 100644 index a5ba2d8f4..000000000 --- a/int16/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Int16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.slice.js b/int16/benchmark/benchmark.slice.js deleted file mode 100644 index a4d7f8108..000000000 --- a/int16/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.slice.length.js b/int16/benchmark/benchmark.slice.length.js deleted file mode 100644 index 891f92d36..000000000 --- a/int16/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.some.js b/int16/benchmark/benchmark.some.js deleted file mode 100644 index 336fd6567..000000000 --- a/int16/benchmark/benchmark.some.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/int16/benchmark/benchmark.some.length.js b/int16/benchmark/benchmark.some.length.js deleted file mode 100644 index 075491234..000000000 --- a/int16/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.sort.js b/int16/benchmark/benchmark.sort.js deleted file mode 100644 index d9a420e77..000000000 --- a/int16/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 randi = require( '@stdlib/random/base/randi' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.sort.length.js b/int16/benchmark/benchmark.sort.length.js deleted file mode 100644 index cc05c62ac..000000000 --- a/int16/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Int16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.subarray.js b/int16/benchmark/benchmark.subarray.js deleted file mode 100644 index a0833f739..000000000 --- a/int16/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.subarray.length.js b/int16/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 8501c8da7..000000000 --- a/int16/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt16Array = require( '@stdlib/assert/is-int16array' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt16Array( out ) ) { - b.fail( 'should return an Int16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.to_locale_string.js b/int16/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 9e0bd74bc..000000000 --- a/int16/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.to_locale_string.length.js b/int16/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index c1e688775..000000000 --- a/int16/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.to_string.js b/int16/benchmark/benchmark.to_string.js deleted file mode 100644 index 6e6d5d95a..000000000 --- a/int16/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/benchmark/benchmark.to_string.length.js b/int16/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 306e398d4..000000000 --- a/int16/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/int16/benchmark/benchmark.values.js b/int16/benchmark/benchmark.values.js deleted file mode 100644 index a34f4ca63..000000000 --- a/int16/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Int16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int16/docs/repl.txt b/int16/docs/repl.txt deleted file mode 100644 index 152c10488..000000000 --- a/int16/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of twos-complement 16-bit signed integers in the platform byte order. - - Returns - ------- - out: Int16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Int16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Int16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Int16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Int16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Int16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Int16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Int16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Int16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Int16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Int16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Int16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Int16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Int16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Int16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Int16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/int16/docs/types/index.d.ts b/int16/docs/types/index.d.ts deleted file mode 100644 index 950399b3a..000000000 --- a/int16/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of twos-complement 16-bit signed integers in the platform byte order. -*/ -export = Int16Array; diff --git a/int16/docs/types/test.ts b/int16/docs/types/test.ts deleted file mode 100644 index 1b7bd5174..000000000 --- a/int16/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Int16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Int16Array( 10 ); // $ExpectType Int16Array - new Int16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Int16Array -} - -// The constructor function has to be invoked with `new`... -{ - Int16Array( 10 ); // $ExpectError - Int16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/int16/examples/index.js b/int16/examples/index.js deleted file mode 100644 index d0978bec8..000000000 --- a/int16/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/int16/lib/index.js b/int16/lib/index.js deleted file mode 100644 index 47ac1ab7f..000000000 --- a/int16/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of twos-complement 16-bit signed integers in the platform byte order. -* -* @module @stdlib/array/int16 -* -* @example -* var ctor = require( '@stdlib/array/int16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasInt16ArraySupport = require( '@stdlib/assert/has-int16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasInt16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/int16/lib/main.js b/int16/lib/main.js deleted file mode 100644 index 39cbaf0c6..000000000 --- a/int16/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof Int16Array === 'function' ) ? Int16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/int16/lib/polyfill.js b/int16/lib/polyfill.js deleted file mode 100644 index d7261e19f..000000000 --- a/int16/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of twos-complement 16-bit signed integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/int16/package.json b/int16/package.json deleted file mode 100644 index b205cdf25..000000000 --- a/int16/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/int16", - "version": "0.0.0", - "description": "Int16Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "int16array", - "int16", - "int16_t", - "integer", - "int", - "signed", - "short" - ] -} diff --git a/int16/test/test.copy_within.js b/int16/test/test.copy_within.js deleted file mode 100644 index 357839c70..000000000 --- a/int16/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasProp = require( '@stdlib/assert/has-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Int16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Int16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Int16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Int16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Int16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/int16/test/test.js b/int16/test/test.js deleted file mode 100644 index 134b0e053..000000000 --- a/int16/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasInt16ArraySupport = require( '@stdlib/assert/has-int16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasInt16Arrays = hasInt16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Int16Array`, the export is an alias for `Int16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-int16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasInt16Arrays ) { - t.strictEqual( ctor, Int16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Int16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-int16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/int16/test/test.polyfill.js b/int16/test/test.polyfill.js deleted file mode 100644 index 9d6fcb190..000000000 --- a/int16/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests diff --git a/int32/README.md b/int32/README.md deleted file mode 100644 index 264a4ef2c..000000000 --- a/int32/README.md +++ /dev/null @@ -1,1473 +0,0 @@ - - -# Int32Array - -> [Typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of twos-complement 32-bit signed integers in the platform byte order. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Int32Array = require( '@stdlib/array/int32' ); -``` - -#### Int32Array() - -A [typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of twos-complement 32-bit signed integers in the platform byte order. - - - -```javascript -var arr = new Int32Array(); -// returns -``` - -#### Int32Array( length ) - -Returns a [typed array][mdn-typed-array] having a specified length. - - - -```javascript -var arr = new Int32Array( 5 ); -// returns [ 0, 0, 0, 0, 0 ] -``` - -#### Int32Array( typedarray ) - -Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - - - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 5.0, 5.0, 5.0 ] ); -var arr2 = new Int32Array( arr1 ); -// returns [ 5, 5, 5 ] -``` - -#### Int32Array( obj ) - -Creates a [typed array][mdn-typed-array] from an array-like `object` or iterable. - - - -```javascript -var arr = new Int32Array( [ 5.0, 5.0, 5.0 ] ); -// returns [ 5, 5, 5 ] -``` - -#### Int32Array( buffer\[, byteOffset\[, length]] ) - -Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 16 ); -var arr = new Int32Array( buf, 0, 4 ); -// returns [ 0, 0, 0, 0 ] -``` - -* * * - -### Properties - - - -#### Int32Array.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var nbytes = Int32Array.BYTES_PER_ELEMENT; -// returns 4 -``` - - - -#### Int32Array.name - -[Typed array][mdn-typed-array] constructor name. - - - -```javascript -var str = Int32Array.name; -// returns 'Int32Array' -``` - - - -#### Int32Array.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Int32Array( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Int32Array.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Int32Array( 5 ); -var byteLength = arr.byteLength; -// returns 20 -``` - - - -#### Int32Array.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the [typed array][mdn-typed-array] from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var arr = new Int32Array( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Int32Array.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var arr = new Int32Array( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 4 -``` - - - -#### Int32Array.prototype.length - -**Read-only** property which returns the number of view elements. - - - -```javascript -var arr = new Int32Array( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Int32Array.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like `object` or an iterable. - -```javascript -var arr = Int32Array.from( [ 1, 2 ] ); -// returns [ 1, 2 ] -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2; -} - -var arr = Int32Array.from( [ 1, 2 ], mapFcn ); -// returns [ 2, 4 ] -``` - -A callback function is provided two arguments: - -- `value`: source value. -- `index`: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr = Int32Array.from( [ 1, 2 ], mapFcn, ctx ); -// returns [ 2, 4 ] - -var n = ctx.count; -// returns 2 -``` - - - -#### Int32Array.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Int32Array.of( 1, 2 ); -// returns [ 1, 2 ] -``` - - - -#### Int32Array.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within an array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 3 ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( 3, 0, 2 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( -2, -5, -3 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - - - -#### Int32Array.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - - - -```javascript -var arr = new Int32Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.entries(); - -// Iterate over key-value pairs... -var v = it.next().value; -// returns [ 0, 1 ] - -v = it.next().value; -// returns [ 1, 2 ] - -var bool = it.next().done; -// returns true -``` - - - -#### Int32Array.prototype.every( predicate\[, thisArg] ) - -Tests whether all array elements pass a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v <= 1 ); -} - -var arr = new Int32Array( [ 1, 2 ] ); - -var bool = arr.every( predicate ); -// returns false -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 1 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int32Array( [ 1, 2 ] ); - -var bool = arr.every( predicate, ctx ); -// returns true - -var n = ctx.count; -// returns 2 -``` - - - -#### Int32Array.prototype.fill( value\[, start\[, end]] ) - -Fills an array from a `start` index to an `end` index (non-inclusive) with a provided `value`. - - - -```javascript -var arr = new Int32Array( 2 ); - -// Set all array elements to the same value: -arr.fill( 2 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 2 - -// Set all array elements starting from the first index to the same value: -arr.fill( 3, 1 ); - -v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 3 - -// Set all array elements, except the last element, to the same value: -arr.fill( 4, 0, arr.length-1 ); - -v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 3 -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr = new Int32Array( 2 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( 2, -arr.length, -1 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 0 -``` - - - -#### Int32Array.prototype.filter( predicate\[, thisArg] ) - -Creates a new array (of the same data type as the host array) which includes those elements for which a `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [ 2, 3 ] -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns an empty array. - - - -```javascript -function predicate( v ) { - return ( v >= 10 ); -} - -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [] -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Int32Array.prototype.find( predicate\[, thisArg] ) - -Returns the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v > 2 ); -} - -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns 3 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `undefined`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns undefined -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v > 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate, ctx ); -// returns 3 - -var n = ctx.count; -// returns 3 -``` - - - -#### Int32Array.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 3 ); -} - -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns 2 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `-1`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns -1 -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 3 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate, ctx ); -// returns 2 - -var n = ctx.count; -// returns 3 -``` - - - -#### Int32Array.prototype.forEach( fcn\[, thisArg] ) - -Invokes a callback for each array element. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var str = ''; - -function fcn( v, i ) { - str += i + ':' + v; - if ( i < arr.length-1 ) { - str += ' '; - } -} - -arr.forEach( fcn ); - -console.log( str ); -// => '0:1 1:2 2:3' -``` - -The callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn() { - this.count += 1; -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int32Array( [ 1, 2, 3 ] ); - -arr.forEach( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Int32Array.prototype.includes( searchElement\[, fromIndex] ) - -Returns a `boolean` indicating whether an array includes a search element. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 3 ); -// returns true - -bool = arr.includes( 0 ); -// returns false -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, 1 ); -// returns false -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, -2 ); -// returns false -``` - - - -#### Int32Array.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the index of the first array element strictly equal to a search element. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 3 ); -// returns 2 - -idx = arr.indexOf( 0 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, 1 ); -// returns -1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, -2 ); -// returns -1 -``` - - - -#### Int32Array.prototype.join( \[separator] ) - -Serializes an array by joining all array elements as a string. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var str = arr.join(); -// returns '1,2,3' -``` - -By default, the method delineates array elements using a comma `,`. To specify a custom separator, provide a `separator` string. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var str = arr.join( '|' ); -// returns '1|2|3' -``` - - - -#### Int32Array.prototype.keys() - -Returns an iterator for iterating over array keys. - - - -```javascript -var arr = new Int32Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.keys(); - -// Iterate over keys... -var v = it.next().value; -// returns 0 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - - - -#### Int32Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the index of the last array element strictly equal to a search element, iterating from right to left. - - - -```javascript -var arr = new Int32Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0 ); -// returns 3 - -idx = arr.lastIndexOf( 3 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = -1`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Int32Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, 2 ); -// returns 1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Int32Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, -3 ); -// returns 1 -``` - - - -#### Int32Array.prototype.map( fcn\[, thisArg] ) - -Maps each array element to an element in a new array having the same data type as the host array. - - - -```javascript -function fcn( v ) { - return v * 2; -} - -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn ); -// returns [ 2, 4, 6 ] -``` - -A callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Int32Array.prototype.reduce( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int32Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn ); -// returns 12 -``` - -If not provided an initial value, the method invokes a provided function with the first array element as the first argument and the second array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the first array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int32Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Int32Array.prototype.reduceRight( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result, iterating from right to left. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int32Array( [ 2, 1, 3 ] ); - -var v = arr.reduceRight( fcn ); -// returns 8 -``` - -If not provided an initial value, the method invokes a provided function with the last array element as the first argument and the second-to-last array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the last array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int32Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Int32Array.prototype.reverse() - -Reverses an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Int32Array( [ 2, 0, 3 ] ); - -// Reverse the array: -arr.reverse(); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 0 - -v = arr[ 2 ]; -// returns 2 -``` - - - -#### Int32Array.prototype.set( arr\[, offset] ) - -Sets array elements. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the first two array elements: -arr.set( [ 4, 5 ] ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the last two array elements: -arr.set( [ 4, 5 ], 1 ); - -var v = arr[ 1 ]; -// returns 4 - -v = arr[ 2 ]; -// returns 5 -``` - - - -#### Int32Array.prototype.slice( \[begin\[, end]] ) - -Copies array elements to a new array with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice(); - -var bool = ( arr1 === arr2 ); -// returns false - -bool = ( arr1.buffer === arr2.buffer ); -// returns false - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 - -v = arr2[ 2 ]; -// returns 3 -``` - -By default, the method copies elements beginning with the first array element. To specify an alternative array index at which to begin copying, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 2 - -v = arr2[ 1 ]; -// returns 3 -``` - -By default, the method copies all array elements after `begin`. To specify an alternative array index at which to end copying, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 0, 2 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( -arr1.length, -1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - - - -#### Int32Array.prototype.some( predicate\[, thisArg] ) - -Tests whether at least one array element passes a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr = new Int32Array( [ 1, 2 ] ); - -var bool = arr.some( predicate ); -// returns true -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int32Array( [ 1, 1 ] ); - -var bool = arr.some( predicate, ctx ); -// returns false - -var n = ctx.count; -// returns 2 -``` - - - -#### Int32Array.prototype.sort( \[compareFunction] ) - -Sorts an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Int32Array( [ 2, 3, 0 ] ); - -// Sort the array (in ascending order): -arr.sort(); - -var v = arr[ 0 ]; -// returns 0 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 3 -``` - -By default, the method sorts array elements in ascending order. To impose a custom order, provide a `compareFunction`. - - - -```javascript -function descending( a, b ) { - return b - a; -} - -var arr = new Int32Array( [ 2, 3, 0 ] ); - -// Sort the array (in descending order): -arr.sort( descending ); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 0 -``` - -The comparison function is provided two array elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: - -- If the comparison function returns a value **less** than zero, then the method sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). -- If the comparison function returns a value **greater** than zero, then the method sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). -- If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. - - - -#### Int32Array.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray(); -// returns [ 1, 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 1 ); -// returns [ 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 0, 2 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( -arr1.length, -1 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -If the method is unable to resolve indices to a non-empty array subsequence, the method returns an empty typed array. - - - -```javascript -var arr1 = new Int32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 10, -1 ); -// returns [] -``` - - - -#### Int32Array.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific `string`. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var str = arr.toLocaleString(); -// returns '1,2,3' -``` - - - -#### Int32Array.prototype.toString() - -Serializes an array as a `string`. - - - -```javascript -var arr = new Int32Array( [ 1, 2, 3 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - - - -#### Int32Array.prototype.values() - -Returns an iterator for iterating over array elements. - - - -```javascript -var arr = new Int32Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.values(); - -// Iterate over array elements... -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -var bool = it.next().done; -// returns true -``` - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( '@stdlib/array/int32' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/int32/benchmark/benchmark.copy_within.js b/int32/benchmark/benchmark.copy_within.js deleted file mode 100644 index 3a07bc954..000000000 --- a/int32/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 255; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.copy_within.length.js b/int32/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 4216daa8f..000000000 --- a/int32/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 255; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.data.js b/int32/benchmark/benchmark.data.js deleted file mode 100644 index 0bee1465d..000000000 --- a/int32/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Int32Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Int32Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.entries.js b/int32/benchmark/benchmark.entries.js deleted file mode 100644 index a858f7905..000000000 --- a/int32/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Int32Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.every.js b/int32/benchmark/benchmark.every.js deleted file mode 100644 index de59ee238..000000000 --- a/int32/benchmark/benchmark.every.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/int32/benchmark/benchmark.every.length.js b/int32/benchmark/benchmark.every.length.js deleted file mode 100644 index a6834093c..000000000 --- a/int32/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.fill.js b/int32/benchmark/benchmark.fill.js deleted file mode 100644 index 9a4992c80..000000000 --- a/int32/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.fill.length.js b/int32/benchmark/benchmark.fill.length.js deleted file mode 100644 index f94e0b75a..000000000 --- a/int32/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.filter.js b/int32/benchmark/benchmark.filter.js deleted file mode 100644 index 8bc01e999..000000000 --- a/int32/benchmark/benchmark.filter.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/int32/benchmark/benchmark.filter.length.js b/int32/benchmark/benchmark.filter.length.js deleted file mode 100644 index 450af2846..000000000 --- a/int32/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.find.js b/int32/benchmark/benchmark.find.js deleted file mode 100644 index f37b3af40..000000000 --- a/int32/benchmark/benchmark.find.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/int32/benchmark/benchmark.find.length.js b/int32/benchmark/benchmark.find.length.js deleted file mode 100644 index eff795928..000000000 --- a/int32/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.find_index.js b/int32/benchmark/benchmark.find_index.js deleted file mode 100644 index 7099aa08b..000000000 --- a/int32/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/int32/benchmark/benchmark.find_index.length.js b/int32/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 172815ce6..000000000 --- a/int32/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.for_each.js b/int32/benchmark/benchmark.for_each.js deleted file mode 100644 index 08f29c706..000000000 --- a/int32/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Int32Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Int32Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/int32/benchmark/benchmark.for_each.length.js b/int32/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 5cd5e5c94..000000000 --- a/int32/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Int32Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.from.js b/int32/benchmark/benchmark.from.js deleted file mode 100644 index c32f489ec..000000000 --- a/int32/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Int32Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int32Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt32Array( arr ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Int32Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int32Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt32Array( arr ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int32Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt32Array( arr ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int32Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt32Array( arr ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int32Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt32Array( arr ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int32Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt32Array( arr ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/int32/benchmark/benchmark.includes.js b/int32/benchmark/benchmark.includes.js deleted file mode 100644 index 144ca93de..000000000 --- a/int32/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.includes.length.js b/int32/benchmark/benchmark.includes.length.js deleted file mode 100644 index d9a6c8d41..000000000 --- a/int32/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.index_of.js b/int32/benchmark/benchmark.index_of.js deleted file mode 100644 index 45d65f02b..000000000 --- a/int32/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Int32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.index_of.length.js b/int32/benchmark/benchmark.index_of.length.js deleted file mode 100644 index cdf1ca436..000000000 --- a/int32/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.join.js b/int32/benchmark/benchmark.join.js deleted file mode 100644 index d4cbe4078..000000000 --- a/int32/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.join.length.js b/int32/benchmark/benchmark.join.length.js deleted file mode 100644 index 24ef4d7ba..000000000 --- a/int32/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.js b/int32/benchmark/benchmark.js deleted file mode 100644 index 9def7bbf8..000000000 --- a/int32/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isInt32Array( arr ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.keys.js b/int32/benchmark/benchmark.keys.js deleted file mode 100644 index 1b086405a..000000000 --- a/int32/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.last_index_of.js b/int32/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 77a474e34..000000000 --- a/int32/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Int32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.last_index_of.length.js b/int32/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 1d5b5ae37..000000000 --- a/int32/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.length.js b/int32/benchmark/benchmark.length.js deleted file mode 100644 index 4589cca81..000000000 --- a/int32/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isInt32Array( arr ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.map.js b/int32/benchmark/benchmark.map.js deleted file mode 100644 index 49b37a12c..000000000 --- a/int32/benchmark/benchmark.map.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/int32/benchmark/benchmark.map.length.js b/int32/benchmark/benchmark.map.length.js deleted file mode 100644 index 56053bebd..000000000 --- a/int32/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.of.js b/int32/benchmark/benchmark.of.js deleted file mode 100644 index dce80d0f2..000000000 --- a/int32/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int32Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt32Array( arr ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.properties.js b/int32/benchmark/benchmark.properties.js deleted file mode 100644 index 16ed29291..000000000 --- a/int32/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.reduce.js b/int32/benchmark/benchmark.reduce.js deleted file mode 100644 index 43b87c964..000000000 --- a/int32/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/int32/benchmark/benchmark.reduce.length.js b/int32/benchmark/benchmark.reduce.length.js deleted file mode 100644 index cc066bfc7..000000000 --- a/int32/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.reduce_right.js b/int32/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 381181cd7..000000000 --- a/int32/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/int32/benchmark/benchmark.reduce_right.length.js b/int32/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 941a868cd..000000000 --- a/int32/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.reverse.js b/int32/benchmark/benchmark.reverse.js deleted file mode 100644 index 3f9cd876d..000000000 --- a/int32/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.reverse.length.js b/int32/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 6c00fb153..000000000 --- a/int32/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.set.js b/int32/benchmark/benchmark.set.js deleted file mode 100644 index 0f1b764f3..000000000 --- a/int32/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Int32Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Int32Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Int32Array( 2 ); - buf = new Int32Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.set.length.js b/int32/benchmark/benchmark.set.length.js deleted file mode 100644 index 312069bab..000000000 --- a/int32/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Int32Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.slice.js b/int32/benchmark/benchmark.slice.js deleted file mode 100644 index 4d68a9301..000000000 --- a/int32/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.slice.length.js b/int32/benchmark/benchmark.slice.length.js deleted file mode 100644 index 8ef4b3ee6..000000000 --- a/int32/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.some.js b/int32/benchmark/benchmark.some.js deleted file mode 100644 index a4c82f141..000000000 --- a/int32/benchmark/benchmark.some.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/int32/benchmark/benchmark.some.length.js b/int32/benchmark/benchmark.some.length.js deleted file mode 100644 index 686b1612a..000000000 --- a/int32/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.sort.js b/int32/benchmark/benchmark.sort.js deleted file mode 100644 index 976caea09..000000000 --- a/int32/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 randi = require( '@stdlib/random/base/randi' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.sort.length.js b/int32/benchmark/benchmark.sort.length.js deleted file mode 100644 index 3c70f9d11..000000000 --- a/int32/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Int32Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.subarray.js b/int32/benchmark/benchmark.subarray.js deleted file mode 100644 index 1dbc01041..000000000 --- a/int32/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.subarray.length.js b/int32/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 0fc2921e7..000000000 --- a/int32/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt32Array( out ) ) { - b.fail( 'should return an Int32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.to_locale_string.js b/int32/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 32c7d3940..000000000 --- a/int32/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.to_locale_string.length.js b/int32/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index ec49e474a..000000000 --- a/int32/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.to_string.js b/int32/benchmark/benchmark.to_string.js deleted file mode 100644 index f5fa1e9fb..000000000 --- a/int32/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/benchmark/benchmark.to_string.length.js b/int32/benchmark/benchmark.to_string.length.js deleted file mode 100644 index b679840b8..000000000 --- a/int32/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/int32/benchmark/benchmark.values.js b/int32/benchmark/benchmark.values.js deleted file mode 100644 index 8132a04ce..000000000 --- a/int32/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Int32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int32/docs/repl.txt b/int32/docs/repl.txt deleted file mode 100644 index cbd8ccea9..000000000 --- a/int32/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of twos-complement 32-bit signed integers in the platform byte order. - - Returns - ------- - out: Int32Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Int32Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Int32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int16}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Int32Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Int32Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Int32Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Int32Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 4 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Int32Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 20 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 4 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Int32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Int32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Int32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Int32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Int32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Int32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Int32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Int32Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/int32/docs/types/index.d.ts b/int32/docs/types/index.d.ts deleted file mode 100644 index a32b46f20..000000000 --- a/int32/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of twos-complement 32-bit signed integers in the platform byte order. -*/ -export = Int32Array; diff --git a/int32/docs/types/test.ts b/int32/docs/types/test.ts deleted file mode 100644 index a9b2ec5a9..000000000 --- a/int32/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Int32Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Int32Array( 10 ); // $ExpectType Int32Array - new Int32Array( [ 2, 5, 5, 7 ] ); // $ExpectType Int32Array -} - -// The constructor function has to be invoked with `new`... -{ - Int32Array( 10 ); // $ExpectError - Int32Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/int32/examples/index.js b/int32/examples/index.js deleted file mode 100644 index d0978bec8..000000000 --- a/int32/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/int32/lib/index.js b/int32/lib/index.js deleted file mode 100644 index 2fec71ce6..000000000 --- a/int32/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of twos-complement 32-bit signed integers in the platform byte order. -* -* @module @stdlib/array/int32 -* -* @example -* var ctor = require( '@stdlib/array/int32' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasInt32ArraySupport = require( '@stdlib/assert/has-int32array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasInt32ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/int32/lib/main.js b/int32/lib/main.js deleted file mode 100644 index 4961b03e5..000000000 --- a/int32/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof Int32Array === 'function' ) ? Int32Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/int32/lib/polyfill.js b/int32/lib/polyfill.js deleted file mode 100644 index 36b07a65d..000000000 --- a/int32/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of twos-complement 32-bit signed integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/int32/package.json b/int32/package.json deleted file mode 100644 index 23dfacc1b..000000000 --- a/int32/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/int32", - "version": "0.0.0", - "description": "Int32Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "int32array", - "int32", - "int32_t", - "integer", - "int", - "signed", - "long" - ] -} diff --git a/int32/test/test.copy_within.js b/int32/test/test.copy_within.js deleted file mode 100644 index 4e137ffbd..000000000 --- a/int32/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasProp = require( '@stdlib/assert/has-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Int32Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Int32Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Int32Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Int32Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Int32Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int32Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int32Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int32Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int32Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int32Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int32Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int32Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int32Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/int32/test/test.js b/int32/test/test.js deleted file mode 100644 index f8d200eeb..000000000 --- a/int32/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasInt32ArraySupport = require( '@stdlib/assert/has-int32array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasInt32Arrays = hasInt32ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Int32Array`, the export is an alias for `Int32Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-int32array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasInt32Arrays ) { - t.strictEqual( ctor, Int32Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Int32Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-int32array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/int32/test/test.polyfill.js b/int32/test/test.polyfill.js deleted file mode 100644 index 9d6fcb190..000000000 --- a/int32/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests diff --git a/int8/README.md b/int8/README.md deleted file mode 100644 index c1fe0b540..000000000 --- a/int8/README.md +++ /dev/null @@ -1,1473 +0,0 @@ - - -# Int8Array - -> [Typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of twos-complement 8-bit signed integers in the platform byte order. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Int8Array = require( '@stdlib/array/int8' ); -``` - -#### Int8Array() - -A [typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of twos-complement 8-bit signed integers in the platform byte order. - - - -```javascript -var arr = new Int8Array(); -// returns -``` - -#### Int8Array( length ) - -Returns a [typed array][mdn-typed-array] having a specified length. - - - -```javascript -var arr = new Int8Array( 5 ); -// returns [ 0, 0, 0, 0, 0 ] -``` - -#### Int8Array( typedarray ) - -Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - - - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 5.0, 5.0, 5.0 ] ); -var arr2 = new Int8Array( arr1 ); -// returns [ 5, 5, 5 ] -``` - -#### Int8Array( obj ) - -Creates a [typed array][mdn-typed-array] from an array-like `object` or iterable. - - - -```javascript -var arr = new Int8Array( [ 5.0, 5.0, 5.0 ] ); -// returns [ 5, 5, 5 ] -``` - -#### Int8Array( buffer\[, byteOffset\[, length]] ) - -Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 4 ); -var arr = new Int8Array( buf, 0, 4 ); -// returns [ 0, 0, 0, 0 ] -``` - -* * * - -### Properties - - - -#### Int8Array.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var nbytes = Int8Array.BYTES_PER_ELEMENT; -// returns 1 -``` - - - -#### Int8Array.name - -[Typed array][mdn-typed-array] constructor name. - - - -```javascript -var str = Int8Array.name; -// returns 'Int8Array' -``` - - - -#### Int8Array.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Int8Array( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Int8Array.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Int8Array( 5 ); -var byteLength = arr.byteLength; -// returns 5 -``` - - - -#### Int8Array.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the [typed array][mdn-typed-array] from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var arr = new Int8Array( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Int8Array.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var arr = new Int8Array( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 1 -``` - - - -#### Int8Array.prototype.length - -**Read-only** property which returns the number of view elements. - - - -```javascript -var arr = new Int8Array( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Int8Array.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like `object` or an iterable. - -```javascript -var arr = Int8Array.from( [ 1, 2 ] ); -// returns [ 1, 2 ] -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2; -} - -var arr = Int8Array.from( [ 1, 2 ], mapFcn ); -// returns [ 2, 4 ] -``` - -A callback function is provided two arguments: - -- `value`: source value. -- `index`: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr = Int8Array.from( [ 1, 2 ], mapFcn, ctx ); -// returns [ 2, 4 ] - -var n = ctx.count; -// returns 2 -``` - - - -#### Int8Array.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Int8Array.of( 1, 2 ); -// returns [ 1, 2 ] -``` - - - -#### Int8Array.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within an array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 3 ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( 3, 0, 2 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( -2, -5, -3 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - - - -#### Int8Array.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - - - -```javascript -var arr = new Int8Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.entries(); - -// Iterate over key-value pairs... -var v = it.next().value; -// returns [ 0, 1 ] - -v = it.next().value; -// returns [ 1, 2 ] - -var bool = it.next().done; -// returns true -``` - - - -#### Int8Array.prototype.every( predicate\[, thisArg] ) - -Tests whether all array elements pass a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v <= 1 ); -} - -var arr = new Int8Array( [ 1, 2 ] ); - -var bool = arr.every( predicate ); -// returns false -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 1 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int8Array( [ 1, 2 ] ); - -var bool = arr.every( predicate, ctx ); -// returns true - -var n = ctx.count; -// returns 2 -``` - - - -#### Int8Array.prototype.fill( value\[, start\[, end]] ) - -Fills an array from a `start` index to an `end` index (non-inclusive) with a provided `value`. - - - -```javascript -var arr = new Int8Array( 2 ); - -// Set all array elements to the same value: -arr.fill( 2 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 2 - -// Set all array elements starting from the first index to the same value: -arr.fill( 3, 1 ); - -v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 3 - -// Set all array elements, except the last element, to the same value: -arr.fill( 4, 0, arr.length-1 ); - -v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 3 -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr = new Int8Array( 2 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( 2, -arr.length, -1 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 0 -``` - - - -#### Int8Array.prototype.filter( predicate\[, thisArg] ) - -Creates a new array (of the same data type as the host array) which includes those elements for which a `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [ 2, 3 ] -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns an empty array. - - - -```javascript -function predicate( v ) { - return ( v >= 10 ); -} - -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [] -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Int8Array.prototype.find( predicate\[, thisArg] ) - -Returns the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v > 2 ); -} - -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns 3 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `undefined`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns undefined -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v > 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate, ctx ); -// returns 3 - -var n = ctx.count; -// returns 3 -``` - - - -#### Int8Array.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 3 ); -} - -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns 2 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `-1`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns -1 -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 3 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate, ctx ); -// returns 2 - -var n = ctx.count; -// returns 3 -``` - - - -#### Int8Array.prototype.forEach( fcn\[, thisArg] ) - -Invokes a callback for each array element. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var str = ''; - -function fcn( v, i ) { - str += i + ':' + v; - if ( i < arr.length-1 ) { - str += ' '; - } -} - -arr.forEach( fcn ); - -console.log( str ); -// => '0:1 1:2 2:3' -``` - -The callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn() { - this.count += 1; -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int8Array( [ 1, 2, 3 ] ); - -arr.forEach( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Int8Array.prototype.includes( searchElement\[, fromIndex] ) - -Returns a `boolean` indicating whether an array includes a search element. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 3 ); -// returns true - -bool = arr.includes( 0 ); -// returns false -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, 1 ); -// returns false -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, -2 ); -// returns false -``` - - - -#### Int8Array.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the index of the first array element strictly equal to a search element. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 3 ); -// returns 2 - -idx = arr.indexOf( 0 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, 1 ); -// returns -1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, -2 ); -// returns -1 -``` - - - -#### Int8Array.prototype.join( \[separator] ) - -Serializes an array by joining all array elements as a string. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var str = arr.join(); -// returns '1,2,3' -``` - -By default, the method delineates array elements using a comma `,`. To specify a custom separator, provide a `separator` string. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var str = arr.join( '|' ); -// returns '1|2|3' -``` - - - -#### Int8Array.prototype.keys() - -Returns an iterator for iterating over array keys. - - - -```javascript -var arr = new Int8Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.keys(); - -// Iterate over keys... -var v = it.next().value; -// returns 0 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - - - -#### Int8Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the index of the last array element strictly equal to a search element, iterating from right to left. - - - -```javascript -var arr = new Int8Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0 ); -// returns 3 - -idx = arr.lastIndexOf( 3 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = -1`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Int8Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, 2 ); -// returns 1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Int8Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, -3 ); -// returns 1 -``` - - - -#### Int8Array.prototype.map( fcn\[, thisArg] ) - -Maps each array element to an element in a new array having the same data type as the host array. - - - -```javascript -function fcn( v ) { - return v * 2; -} - -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn ); -// returns [ 2, 4, 6 ] -``` - -A callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Int8Array.prototype.reduce( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int8Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn ); -// returns 12 -``` - -If not provided an initial value, the method invokes a provided function with the first array element as the first argument and the second array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the first array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int8Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Int8Array.prototype.reduceRight( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result, iterating from right to left. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int8Array( [ 2, 1, 3 ] ); - -var v = arr.reduceRight( fcn ); -// returns 8 -``` - -If not provided an initial value, the method invokes a provided function with the last array element as the first argument and the second-to-last array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the last array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Int8Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Int8Array.prototype.reverse() - -Reverses an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Int8Array( [ 2, 0, 3 ] ); - -// Reverse the array: -arr.reverse(); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 0 - -v = arr[ 2 ]; -// returns 2 -``` - - - -#### Int8Array.prototype.set( arr\[, offset] ) - -Sets array elements. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the first two array elements: -arr.set( [ 4, 5 ] ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the last two array elements: -arr.set( [ 4, 5 ], 1 ); - -var v = arr[ 1 ]; -// returns 4 - -v = arr[ 2 ]; -// returns 5 -``` - - - -#### Int8Array.prototype.slice( \[begin\[, end]] ) - -Copies array elements to a new array with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice(); - -var bool = ( arr1 === arr2 ); -// returns false - -bool = ( arr1.buffer === arr2.buffer ); -// returns false - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 - -v = arr2[ 2 ]; -// returns 3 -``` - -By default, the method copies elements beginning with the first array element. To specify an alternative array index at which to begin copying, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 2 - -v = arr2[ 1 ]; -// returns 3 -``` - -By default, the method copies all array elements after `begin`. To specify an alternative array index at which to end copying, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 0, 2 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( -arr1.length, -1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - - - -#### Int8Array.prototype.some( predicate\[, thisArg] ) - -Tests whether at least one array element passes a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr = new Int8Array( [ 1, 2 ] ); - -var bool = arr.some( predicate ); -// returns true -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Int8Array( [ 1, 1 ] ); - -var bool = arr.some( predicate, ctx ); -// returns false - -var n = ctx.count; -// returns 2 -``` - - - -#### Int8Array.prototype.sort( \[compareFunction] ) - -Sorts an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Int8Array( [ 2, 3, 0 ] ); - -// Sort the array (in ascending order): -arr.sort(); - -var v = arr[ 0 ]; -// returns 0 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 3 -``` - -By default, the method sorts array elements in ascending order. To impose a custom order, provide a `compareFunction`. - - - -```javascript -function descending( a, b ) { - return b - a; -} - -var arr = new Int8Array( [ 2, 3, 0 ] ); - -// Sort the array (in descending order): -arr.sort( descending ); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 0 -``` - -The comparison function is provided two array elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: - -- If the comparison function returns a value **less** than zero, then the method sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). -- If the comparison function returns a value **greater** than zero, then the method sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). -- If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. - - - -#### Int8Array.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray(); -// returns [ 1, 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 1 ); -// returns [ 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 0, 2 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( -arr1.length, -1 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -If the method is unable to resolve indices to a non-empty array subsequence, the method returns an empty typed array. - - - -```javascript -var arr1 = new Int8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 10, -1 ); -// returns [] -``` - - - -#### Int8Array.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific `string`. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var str = arr.toLocaleString(); -// returns '1,2,3' -``` - - - -#### Int8Array.prototype.toString() - -Serializes an array as a `string`. - - - -```javascript -var arr = new Int8Array( [ 1, 2, 3 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - - - -#### Int8Array.prototype.values() - -Returns an iterator for iterating over array elements. - - - -```javascript -var arr = new Int8Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.values(); - -// Iterate over array elements... -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -var bool = it.next().done; -// returns true -``` - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( '@stdlib/array/int8' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/int8/benchmark/benchmark.copy_within.js b/int8/benchmark/benchmark.copy_within.js deleted file mode 100644 index 60156d265..000000000 --- a/int8/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.copy_within.length.js b/int8/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 1a00aacc2..000000000 --- a/int8/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.data.js b/int8/benchmark/benchmark.data.js deleted file mode 100644 index a4dda02b7..000000000 --- a/int8/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Int8Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Int8Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.entries.js b/int8/benchmark/benchmark.entries.js deleted file mode 100644 index b830a69ea..000000000 --- a/int8/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Int8Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.every.js b/int8/benchmark/benchmark.every.js deleted file mode 100644 index 40a8642cb..000000000 --- a/int8/benchmark/benchmark.every.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/int8/benchmark/benchmark.every.length.js b/int8/benchmark/benchmark.every.length.js deleted file mode 100644 index a0229bdb8..000000000 --- a/int8/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.fill.js b/int8/benchmark/benchmark.fill.js deleted file mode 100644 index da6d595a0..000000000 --- a/int8/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.fill.length.js b/int8/benchmark/benchmark.fill.length.js deleted file mode 100644 index e81e99fbe..000000000 --- a/int8/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.filter.js b/int8/benchmark/benchmark.filter.js deleted file mode 100644 index 3ea9329bd..000000000 --- a/int8/benchmark/benchmark.filter.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/int8/benchmark/benchmark.filter.length.js b/int8/benchmark/benchmark.filter.length.js deleted file mode 100644 index bfabe84c2..000000000 --- a/int8/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.find.js b/int8/benchmark/benchmark.find.js deleted file mode 100644 index 470dd8da8..000000000 --- a/int8/benchmark/benchmark.find.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/int8/benchmark/benchmark.find.length.js b/int8/benchmark/benchmark.find.length.js deleted file mode 100644 index 5abbeee83..000000000 --- a/int8/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.find_index.js b/int8/benchmark/benchmark.find_index.js deleted file mode 100644 index 7b6e03291..000000000 --- a/int8/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/int8/benchmark/benchmark.find_index.length.js b/int8/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 05cfd05e4..000000000 --- a/int8/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Float32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0.0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.for_each.js b/int8/benchmark/benchmark.for_each.js deleted file mode 100644 index c88177eae..000000000 --- a/int8/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Int8Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Int8Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/int8/benchmark/benchmark.for_each.length.js b/int8/benchmark/benchmark.for_each.length.js deleted file mode 100644 index 09f039189..000000000 --- a/int8/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Int8Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.from.js b/int8/benchmark/benchmark.from.js deleted file mode 100644 index 0708827be..000000000 --- a/int8/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Int8Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int8Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt8Array( arr ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Int8Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int8Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt8Array( arr ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int8Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt8Array( arr ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int8Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt8Array( arr ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int8Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt8Array( arr ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int8Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt8Array( arr ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/int8/benchmark/benchmark.includes.js b/int8/benchmark/benchmark.includes.js deleted file mode 100644 index 78e6a65f1..000000000 --- a/int8/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.includes.length.js b/int8/benchmark/benchmark.includes.length.js deleted file mode 100644 index 3aa2aaa71..000000000 --- a/int8/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.index_of.js b/int8/benchmark/benchmark.index_of.js deleted file mode 100644 index d638435a7..000000000 --- a/int8/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Int8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.index_of.length.js b/int8/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 6cf9936b4..000000000 --- a/int8/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.join.js b/int8/benchmark/benchmark.join.js deleted file mode 100644 index 2f0ddb4f8..000000000 --- a/int8/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.join.length.js b/int8/benchmark/benchmark.join.length.js deleted file mode 100644 index 93d779a5e..000000000 --- a/int8/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.js b/int8/benchmark/benchmark.js deleted file mode 100644 index 74ef7986f..000000000 --- a/int8/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isInt8Array( arr ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.keys.js b/int8/benchmark/benchmark.keys.js deleted file mode 100644 index dfdeb1dc4..000000000 --- a/int8/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.last_index_of.js b/int8/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 00b9448c5..000000000 --- a/int8/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Int8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.last_index_of.length.js b/int8/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 12efaf1ac..000000000 --- a/int8/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.length.js b/int8/benchmark/benchmark.length.js deleted file mode 100644 index f3fb41458..000000000 --- a/int8/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isInt8Array( arr ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.map.js b/int8/benchmark/benchmark.map.js deleted file mode 100644 index ff3dfb1bb..000000000 --- a/int8/benchmark/benchmark.map.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/int8/benchmark/benchmark.map.length.js b/int8/benchmark/benchmark.map.length.js deleted file mode 100644 index e44b72129..000000000 --- a/int8/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.of.js b/int8/benchmark/benchmark.of.js deleted file mode 100644 index 53a479408..000000000 --- a/int8/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Int8Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isInt8Array( arr ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.properties.js b/int8/benchmark/benchmark.properties.js deleted file mode 100644 index 95ef3416d..000000000 --- a/int8/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.reduce.js b/int8/benchmark/benchmark.reduce.js deleted file mode 100644 index 6dc489b5f..000000000 --- a/int8/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/int8/benchmark/benchmark.reduce.length.js b/int8/benchmark/benchmark.reduce.length.js deleted file mode 100644 index ed2dff614..000000000 --- a/int8/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.reduce_right.js b/int8/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 5c5d499d9..000000000 --- a/int8/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/int8/benchmark/benchmark.reduce_right.length.js b/int8/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index ec8826e46..000000000 --- a/int8/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.reverse.js b/int8/benchmark/benchmark.reverse.js deleted file mode 100644 index 513401797..000000000 --- a/int8/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.reverse.length.js b/int8/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 01d44fd38..000000000 --- a/int8/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.set.js b/int8/benchmark/benchmark.set.js deleted file mode 100644 index 0072330a5..000000000 --- a/int8/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Int8Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Int8Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Int8Array( 2 ); - buf = new Int8Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.set.length.js b/int8/benchmark/benchmark.set.length.js deleted file mode 100644 index bce7b9156..000000000 --- a/int8/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Int8Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.slice.js b/int8/benchmark/benchmark.slice.js deleted file mode 100644 index 3fa057a3f..000000000 --- a/int8/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.slice.length.js b/int8/benchmark/benchmark.slice.length.js deleted file mode 100644 index c28a6871e..000000000 --- a/int8/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.some.js b/int8/benchmark/benchmark.some.js deleted file mode 100644 index 40ca80b82..000000000 --- a/int8/benchmark/benchmark.some.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/int8/benchmark/benchmark.some.length.js b/int8/benchmark/benchmark.some.length.js deleted file mode 100644 index 6805fd547..000000000 --- a/int8/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.sort.js b/int8/benchmark/benchmark.sort.js deleted file mode 100644 index ea9a380e3..000000000 --- a/int8/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 randi = require( '@stdlib/random/base/randi' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.sort.length.js b/int8/benchmark/benchmark.sort.length.js deleted file mode 100644 index e58533fad..000000000 --- a/int8/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Int8Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.subarray.js b/int8/benchmark/benchmark.subarray.js deleted file mode 100644 index 8ee2e1533..000000000 --- a/int8/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.subarray.length.js b/int8/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 86eda65e9..000000000 --- a/int8/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isInt8Array = require( '@stdlib/assert/is-int8array' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isInt8Array( out ) ) { - b.fail( 'should return an Int8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.to_locale_string.js b/int8/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 510a36933..000000000 --- a/int8/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.to_locale_string.length.js b/int8/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 4c75af033..000000000 --- a/int8/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.to_string.js b/int8/benchmark/benchmark.to_string.js deleted file mode 100644 index ab4aebc3d..000000000 --- a/int8/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/benchmark/benchmark.to_string.length.js b/int8/benchmark/benchmark.to_string.length.js deleted file mode 100644 index f63ab08db..000000000 --- a/int8/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Int8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/int8/benchmark/benchmark.values.js b/int8/benchmark/benchmark.values.js deleted file mode 100644 index 1849e01da..000000000 --- a/int8/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Int8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Int8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/int8/docs/repl.txt b/int8/docs/repl.txt deleted file mode 100644 index 34aaafef5..000000000 --- a/int8/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of twos-complement 8-bit signed integers in the platform byte order. - - Returns - ------- - out: Int8Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Int8Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Int8Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Int8Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Int8Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 4 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Int8Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Int8Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 1 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Int8Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 5 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 1 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Int8Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Int8Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Int8Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Int8Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Int8Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Int8Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Int8Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Int8Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/int8/docs/types/index.d.ts b/int8/docs/types/index.d.ts deleted file mode 100644 index 2d20dc4de..000000000 --- a/int8/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of twos-complement 8-bit signed integers in the platform byte order. -*/ -export = Int8Array; diff --git a/int8/docs/types/test.ts b/int8/docs/types/test.ts deleted file mode 100644 index 35398aa68..000000000 --- a/int8/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Int8Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Int8Array( 10 ); // $ExpectType Int8Array - new Int8Array( [ 2, 5, 5, 7 ] ); // $ExpectType Int8Array -} - -// The constructor function has to be invoked with `new`... -{ - Int8Array( 10 ); // $ExpectError - Int8Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/int8/examples/index.js b/int8/examples/index.js deleted file mode 100644 index d0978bec8..000000000 --- a/int8/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/int8/lib/index.js b/int8/lib/index.js deleted file mode 100644 index ebb4b16cd..000000000 --- a/int8/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of twos-complement 8-bit signed integers in the platform byte order. -* -* @module @stdlib/array/int8 -* -* @example -* var ctor = require( '@stdlib/array/int8' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasInt8ArraySupport = require( '@stdlib/assert/has-int8array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasInt8ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/int8/lib/main.js b/int8/lib/main.js deleted file mode 100644 index 667410e03..000000000 --- a/int8/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof Int8Array === 'function' ) ? Int8Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/int8/lib/polyfill.js b/int8/lib/polyfill.js deleted file mode 100644 index cd3f2fb00..000000000 --- a/int8/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of twos-complement 8-bit signed integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/int8/package.json b/int8/package.json deleted file mode 100644 index 8202e1db2..000000000 --- a/int8/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/int8", - "version": "0.0.0", - "description": "Int8Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "int8array", - "int8", - "int8_t", - "integer", - "int", - "signed", - "byte" - ] -} diff --git a/int8/test/test.copy_within.js b/int8/test/test.copy_within.js deleted file mode 100644 index dda6a6761..000000000 --- a/int8/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasProp = require( '@stdlib/assert/has-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Int8Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Int8Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Int8Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Int8Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Int8Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int8Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int8Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int8Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int8Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int8Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int8Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int8Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Int8Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/int8/test/test.js b/int8/test/test.js deleted file mode 100644 index f9477153b..000000000 --- a/int8/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasInt8ArraySupport = require( '@stdlib/assert/has-int8array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasInt8Arrays = hasInt8ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Int8Array`, the export is an alias for `Int8Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-int8array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasInt8Arrays ) { - t.strictEqual( ctor, Int8Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Int8Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-int8array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/int8/test/test.polyfill.js b/int8/test/test.polyfill.js deleted file mode 100644 index 9d6fcb190..000000000 --- a/int8/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 3d8015cc9..000000000 --- a/lib/index.js +++ /dev/null @@ -1,955 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/* -* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name. -*/ - -/* -* The following modules are intentionally not exported: generic -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-read-only-property' ); - - -// MAIN // - -/** -* Top-level namespace. -* -* @namespace ns -*/ -var ns = {}; - -/** -* @name base -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/array/base} -*/ -setReadOnly( ns, 'base', require( './../base' ) ); - -/** -* @name BooleanArray -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/bool} -*/ -setReadOnly( ns, 'BooleanArray', require( './../bool' ) ); - -/** -* @name ArrayBuffer -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/buffer} -*/ -setReadOnly( ns, 'ArrayBuffer', require( './../buffer' ) ); - -/** -* @name byteOrders -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/byte-orders} -*/ -setReadOnly( ns, 'byteOrders', require( './../byte-orders' ) ); - -/** -* @name cartesianPower -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/cartesian-power} -*/ -setReadOnly( ns, 'cartesianPower', require( './../cartesian-power' ) ); - -/** -* @name cartesianProduct -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/cartesian-product} -*/ -setReadOnly( ns, 'cartesianProduct', require( './../cartesian-product' ) ); - -/** -* @name cartesianSquare -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/cartesian-square} -*/ -setReadOnly( ns, 'cartesianSquare', require( './../cartesian-square' ) ); - -/** -* @name Complex64Array -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/complex64} -*/ -setReadOnly( ns, 'Complex64Array', require( './../complex64' ) ); - -/** -* @name Complex128Array -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/complex128} -*/ -setReadOnly( ns, 'Complex128Array', require( './../complex128' ) ); - -/** -* @name convert -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/convert} -*/ -setReadOnly( ns, 'convert', require( './../convert' ) ); - -/** -* @name convertSame -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/convert-same} -*/ -setReadOnly( ns, 'convertSame', require( './../convert-same' ) ); - -/** -* @name ctors -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/ctors} -*/ -setReadOnly( ns, 'ctors', require( './../ctors' ) ); - -/** -* @name DataView -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/dataview} -*/ -setReadOnly( ns, 'DataView', require( './../dataview' ) ); - -/** -* @name datespace -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/datespace} -*/ -setReadOnly( ns, 'datespace', require( './../datespace' ) ); - -/** -* @name defaults -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/defaults} -*/ -setReadOnly( ns, 'defaults', require( './../defaults' ) ); - -/** -* @name dtype -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/dtype} -*/ -setReadOnly( ns, 'dtype', require( './../dtype' ) ); - -/** -* @name dtypes -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/dtypes} -*/ -setReadOnly( ns, 'dtypes', require( './../dtypes' ) ); - -/** -* @name empty -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/empty} -*/ -setReadOnly( ns, 'empty', require( './../empty' ) ); - -/** -* @name emptyLike -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/empty-like} -*/ -setReadOnly( ns, 'emptyLike', require( './../empty-like' ) ); - -/** -* @name filled -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/filled} -*/ -setReadOnly( ns, 'filled', require( './../filled' ) ); - -/** -* @name filledBy -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/filled-by} -*/ -setReadOnly( ns, 'filledBy', require( './../filled-by' ) ); - -/** -* @name fixedEndianFactory -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/fixed-endian-factory} -*/ -setReadOnly( ns, 'fixedEndianFactory', require( './../fixed-endian-factory' ) ); - -/** -* @name Float32ArrayFE -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/fixed-endian-float32} -*/ -setReadOnly( ns, 'Float32ArrayFE', require( './../fixed-endian-float32' ) ); - -/** -* @name Float64ArrayFE -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/fixed-endian-float64} -*/ -setReadOnly( ns, 'Float64ArrayFE', require( './../fixed-endian-float64' ) ); - -/** -* @name Float32Array -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/float32} -*/ -setReadOnly( ns, 'Float32Array', require( './../float32' ) ); - -/** -* @name Float64Array -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/float64} -*/ -setReadOnly( ns, 'Float64Array', require( './../float64' ) ); - -/** -* @name iterator2array -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/from-iterator} -*/ -setReadOnly( ns, 'iterator2array', require( './../from-iterator' ) ); - -/** -* @name scalar2array -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/from-scalar} -*/ -setReadOnly( ns, 'scalar2array', require( './../from-scalar' ) ); - -/** -* @name full -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/full} -*/ -setReadOnly( ns, 'full', require( './../full' ) ); - -/** -* @name fullLike -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/full-like} -*/ -setReadOnly( ns, 'fullLike', require( './../full-like' ) ); - -/** -* @name incrspace -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/incrspace} -*/ -setReadOnly( ns, 'incrspace', require( './../incrspace' ) ); - -/** -* @name ArrayIndex -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/index} -*/ -setReadOnly( ns, 'ArrayIndex', require( './../index' ) ); - -/** -* @name Int8Array -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/int8} -*/ -setReadOnly( ns, 'Int8Array', require( './../int8' ) ); - -/** -* @name Int16Array -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/int16} -*/ -setReadOnly( ns, 'Int16Array', require( './../int16' ) ); - -/** -* @name Int32Array -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/int32} -*/ -setReadOnly( ns, 'Int32Array', require( './../int32' ) ); - -/** -* @name linspace -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/linspace} -*/ -setReadOnly( ns, 'linspace', require( './../linspace' ) ); - -/** -* @name littleEndianFactory -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/little-endian-factory} -*/ -setReadOnly( ns, 'littleEndianFactory', require( './../little-endian-factory' ) ); - -/** -* @name Float32ArrayLE -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/little-endian-float32} -*/ -setReadOnly( ns, 'Float32ArrayLE', require( './../little-endian-float32' ) ); - -/** -* @name Float64ArrayLE -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/little-endian-float64} -*/ -setReadOnly( ns, 'Float64ArrayLE', require( './../little-endian-float64' ) ); - -/** -* @name logspace -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/logspace} -*/ -setReadOnly( ns, 'logspace', require( './../logspace' ) ); - -/** -* @name minDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/min-dtype} -*/ -setReadOnly( ns, 'minDataType', require( './../min-dtype' ) ); - -/** -* @name mostlySafeCasts -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/mostly-safe-casts} -*/ -setReadOnly( ns, 'mostlySafeCasts', require( './../mostly-safe-casts' ) ); - -/** -* @name mskfilter -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/mskfilter} -*/ -setReadOnly( ns, 'mskfilter', require( './../mskfilter' ) ); - -/** -* @name mskput -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/mskput} -*/ -setReadOnly( ns, 'mskput', require( './../mskput' ) ); - -/** -* @name mskreject -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/mskreject} -*/ -setReadOnly( ns, 'mskreject', require( './../mskreject' ) ); - -/** -* @name nans -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/nans} -*/ -setReadOnly( ns, 'nans', require( './../nans' ) ); - -/** -* @name nansLike -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/nans-like} -*/ -setReadOnly( ns, 'nansLike', require( './../nans-like' ) ); - -/** -* @name nextDataType -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/next-dtype} -*/ -setReadOnly( ns, 'nextDataType', require( './../next-dtype' ) ); - -/** -* @name oneTo -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/one-to} -*/ -setReadOnly( ns, 'oneTo', require( './../one-to' ) ); - -/** -* @name oneToLike -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/one-to-like} -*/ -setReadOnly( ns, 'oneToLike', require( './../one-to-like' ) ); - -/** -* @name ones -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/ones} -*/ -setReadOnly( ns, 'ones', require( './../ones' ) ); - -/** -* @name onesLike -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/ones-like} -*/ -setReadOnly( ns, 'onesLike', require( './../ones-like' ) ); - -/** -* @name place -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/place} -*/ -setReadOnly( ns, 'place', require( './../place' ) ); - -/** -* @name typedarraypool -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/pool} -*/ -setReadOnly( ns, 'typedarraypool', require( './../pool' ) ); - -/** -* @name promotionRules -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/promotion-rules} -*/ -setReadOnly( ns, 'promotionRules', require( './../promotion-rules' ) ); - -/** -* @name put -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/put} -*/ -setReadOnly( ns, 'put', require( './../put' ) ); - -/** -* @name typedarrayReviver -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/reviver} -*/ -setReadOnly( ns, 'typedarrayReviver', require( './../reviver' ) ); - -/** -* @name safeCasts -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/safe-casts} -*/ -setReadOnly( ns, 'safeCasts', require( './../safe-casts' ) ); - -/** -* @name sameKindCasts -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/same-kind-casts} -*/ -setReadOnly( ns, 'sameKindCasts', require( './../same-kind-casts' ) ); - -/** -* @name shape -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/shape} -*/ -setReadOnly( ns, 'shape', require( './../shape' ) ); - -/** -* @name SharedArrayBuffer -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/shared-buffer} -*/ -setReadOnly( ns, 'SharedArrayBuffer', require( './../shared-buffer' ) ); - -/** -* @name slice -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/slice} -*/ -setReadOnly( ns, 'slice', require( './../slice' ) ); - -/** -* @name take -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/take} -*/ -setReadOnly( ns, 'take', require( './../take' ) ); - -/** -* @name circarray2iterator -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/to-circular-iterator} -*/ -setReadOnly( ns, 'circarray2iterator', require( './../to-circular-iterator' ) ); - -/** -* @name array2fancy -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/to-fancy} -*/ -setReadOnly( ns, 'array2fancy', require( './../to-fancy' ) ); - -/** -* @name array2iterator -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/to-iterator} -*/ -setReadOnly( ns, 'array2iterator', require( './../to-iterator' ) ); - -/** -* @name array2iteratorRight -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/to-iterator-right} -*/ -setReadOnly( ns, 'array2iteratorRight', require( './../to-iterator-right' ) ); - -/** -* @name typedarray2json -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/to-json} -*/ -setReadOnly( ns, 'typedarray2json', require( './../to-json' ) ); - -/** -* @name sparsearray2iterator -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/to-sparse-iterator} -*/ -setReadOnly( ns, 'sparsearray2iterator', require( './../to-sparse-iterator' ) ); - -/** -* @name sparsearray2iteratorRight -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/to-sparse-iterator-right} -*/ -setReadOnly( ns, 'sparsearray2iteratorRight', require( './../to-sparse-iterator-right' ) ); - -/** -* @name stridedarray2iterator -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/to-strided-iterator} -*/ -setReadOnly( ns, 'stridedarray2iterator', require( './../to-strided-iterator' ) ); - -/** -* @name arrayview2iterator -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/to-view-iterator} -*/ -setReadOnly( ns, 'arrayview2iterator', require( './../to-view-iterator' ) ); - -/** -* @name arrayview2iteratorRight -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/to-view-iterator-right} -*/ -setReadOnly( ns, 'arrayview2iteratorRight', require( './../to-view-iterator-right' ) ); - -/** -* @name typedarray -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed} -*/ -setReadOnly( ns, 'typedarray', require( './../typed' ) ); - -/** -* @name complexarray -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-complex} -*/ -setReadOnly( ns, 'complexarray', require( './../typed-complex' ) ); - -/** -* @name complexarrayCtors -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-complex-ctors} -*/ -setReadOnly( ns, 'complexarrayCtors', require( './../typed-complex-ctors' ) ); - -/** -* @name complexarrayDataTypes -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-complex-dtypes} -*/ -setReadOnly( ns, 'complexarrayDataTypes', require( './../typed-complex-dtypes' ) ); - -/** -* @name typedarrayCtors -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-ctors} -*/ -setReadOnly( ns, 'typedarrayCtors', require( './../typed-ctors' ) ); - -/** -* @name typedarrayDataTypes -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-dtypes} -*/ -setReadOnly( ns, 'typedarrayDataTypes', require( './../typed-dtypes' ) ); - -/** -* @name floatarrayCtors -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-float-ctors} -*/ -setReadOnly( ns, 'floatarrayCtors', require( './../typed-float-ctors' ) ); - -/** -* @name floatarrayDataTypes -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-float-dtypes} -*/ -setReadOnly( ns, 'floatarrayDataTypes', require( './../typed-float-dtypes' ) ); - -/** -* @name intarrayCtors -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-integer-ctors} -*/ -setReadOnly( ns, 'intarrayCtors', require( './../typed-integer-ctors' ) ); - -/** -* @name intarrayDataTypes -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-integer-dtypes} -*/ -setReadOnly( ns, 'intarrayDataTypes', require( './../typed-integer-dtypes' ) ); - -/** -* @name realarray -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-real} -*/ -setReadOnly( ns, 'realarray', require( './../typed-real' ) ); - -/** -* @name realarrayCtors -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-real-ctors} -*/ -setReadOnly( ns, 'realarrayCtors', require( './../typed-real-ctors' ) ); - -/** -* @name realarrayDataTypes -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-real-dtypes} -*/ -setReadOnly( ns, 'realarrayDataTypes', require( './../typed-real-dtypes' ) ); - -/** -* @name realarrayFloatCtors -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-real-float-ctors} -*/ -setReadOnly( ns, 'realarrayFloatCtors', require( './../typed-real-float-ctors' ) ); - -/** -* @name realarrayFloatDataTypes -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-real-float-dtypes} -*/ -setReadOnly( ns, 'realarrayFloatDataTypes', require( './../typed-real-float-dtypes' ) ); - -/** -* @name intarraySignedCtors -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-signed-integer-ctors} -*/ -setReadOnly( ns, 'intarraySignedCtors', require( './../typed-signed-integer-ctors' ) ); - -/** -* @name intarraySignedDataTypes -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-signed-integer-dtypes} -*/ -setReadOnly( ns, 'intarraySignedDataTypes', require( './../typed-signed-integer-dtypes' ) ); - -/** -* @name intarrayUnsignedCtors -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-unsigned-integer-ctors} -*/ -setReadOnly( ns, 'intarrayUnsignedCtors', require( './../typed-unsigned-integer-ctors' ) ); - -/** -* @name intarrayUnsignedDataTypes -* @memberof ns -* @readonly -* @type {Function} -* @see {@link module:@stdlib/array/typed-unsigned-integer-dtypes} -*/ -setReadOnly( ns, 'intarrayUnsignedDataTypes', require( './../typed-unsigned-integer-dtypes' ) ); - -/** -* @name Uint8Array -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/uint8} -*/ -setReadOnly( ns, 'Uint8Array', require( './../uint8' ) ); - -/** -* @name Uint8ClampedArray -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/uint8c} -*/ -setReadOnly( ns, 'Uint8ClampedArray', require( './../uint8c' ) ); - -/** -* @name Uint16Array -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/uint16} -*/ -setReadOnly( ns, 'Uint16Array', require( './../uint16' ) ); - -/** -* @name Uint32Array -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/uint32} -*/ -setReadOnly( ns, 'Uint32Array', require( './../uint32' ) ); - -/** -* @name zeroTo -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/zero-to} -*/ -setReadOnly( ns, 'zeroTo', require( './../zero-to' ) ); - -/** -* @name zeroToLike -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/zero-to-like} -*/ -setReadOnly( ns, 'zeroToLike', require( './../zero-to-like' ) ); - -/** -* @name zeros -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/zeros} -*/ -setReadOnly( ns, 'zeros', require( './../zeros' ) ); - -/** -* @name zerosLike -* @memberof ns -* @readonly -* @constructor -* @see {@link module:@stdlib/array/zeros-like} -*/ -setReadOnly( ns, 'zerosLike', require( './../zeros-like' ) ); - -/** -* @name constants -* @memberof ns -* @readonly -* @type {Namespace} -* @see {@link module:@stdlib/constants/array} -*/ -setReadOnly( ns, 'constants', require( '@stdlib/constants/array' ) ); - - -// EXPORTS // - -module.exports = ns; diff --git a/linspace/README.md b/linspace/README.md deleted file mode 100644 index f163f6616..000000000 --- a/linspace/README.md +++ /dev/null @@ -1,329 +0,0 @@ - - -# linspace - -> Generate a linearly spaced array over a specified interval. - -
- -## Usage - -```javascript -var linspace = require( '@stdlib/array/linspace' ); -``` - -#### linspace( start, stop, length\[, options] ) - -Generates a linearly spaced array over a specified interval. - -```javascript -var arr = linspace( 0.0, 100.0, 6 ); -// returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] -``` - -If `length` is `0`, the function returns an empty array. - -```javascript -var arr = linspace( 0.0, 100.0, 0 ); -// returns [] -``` - -If `length` is `1`, the function returns an array containing `stop`, but not `start`, when `endpoint` is `true`; otherwise, the function returns an array containing `start`, but not `stop`. - -```javascript -var arr = linspace( 0.0, 100.0, 1 ); -// returns [ 100.0 ] - -arr = linspace( 0.0, 100.0, 1, { - 'endpoint': true -}); -// returns [ 100.0 ] - -arr = linspace( 0.0, 100.0, 1, { - 'endpoint': false -}); -// returns [ 0.0 ] -``` - -For real-valued `start` and `stop`, if `start` is less than `stop`, the output array will contain ascending values, and, if `start` is greater than `stop`, the output array will contain descending values. - -```javascript -var arr = linspace( 0.0, -100.0, 6 ); -// returns [ 0.0, -20.0, -40.0, -60.0, -80.0, -100.0 ] -``` - -The function accepts the following `options`: - -- **dtype**: output array data type. Must be a [floating-point data type][@stdlib/array/typed-float-dtypes] or `'generic'`. If both `start` and `stop` are the same type (either `'float64'`, `'complex64'`, or `'complex128'`), the default output array data type is the same type as the input values (either `'float64'`, `'complex64'`, or `'complex128'`, respectively). Otherwise, the default output array data type is `'complex128'`. -- **endpoint**: `boolean` indicating whether to include the `stop` value in the output array. If `false`, the function generates `length + 1` linearly spaced values over the interval `[start, stop]` and only writes `length` values to the output array, thus excluding `stop` from the output array. Accordingly, for a fixed `length`, the spacing between adjacent values in the output array changes depending on the value of `endpoint`. Default: `true`. - -By default, the function generates a linearly spaced array over the closed interval `[start, stop]`. To generate linearly spaced values over the half-open interval `[start, stop)`, set the `endpoint` option to `false`. - -```javascript -var opts = { - 'endpoint': false -}; -var arr = linspace( 0.0, 100.0, 5, opts ); -// returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ] -``` - -When both `start` and `stop` are real-valued, the default output array data type is `'float64'`. To return an output array having a different data type, set the `dtype` option. - -```javascript -var opts = { - 'dtype': 'generic' -}; -var arr = linspace( 0, 100, 6, opts ); -// returns [ 0, 20, 40, 60, 80, 100 ] -``` - -When either `start` or `stop` is a complex number, the default output array data type is `'complex128'`. To return an output array having a different data type, set the `dtype` option. - - - -```javascript -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var opts = { - 'dtype': 'generic' -}; - -var start = new Complex128( 0.0, 0.0 ); -var stop = new Complex128( 100.0, 10.0 ); - -var arr = linspace( start, stop, 6, opts ); -// returns [ , , , , , ] - -var z = arr[ 0 ]; -// returns - -var re = real( z ); -// returns 0.0 - -var im = imag( z ); -// returns 0.0 - -z = arr[ 1 ]; -// returns - -re = real( z ); -// returns 20.0 - -im = imag( z ); -// returns 2.0 - -// ... -``` - -#### linspace.assign( start, stop, out\[, options] ) - -Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var out = new Float64Array( 6 ); -var arr = linspace.assign( 0.0, 100.0, out ); -// returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - -var bool = ( arr === out ); -// returns true -``` - -If the provided output array is empty, the function returns the provided output array unchanged. - -```javascript -var arr = linspace.assign( 0.0, 100.0, [] ); -// returns [] -``` - -If the provided output array contains a single element, the function writes the `stop` value, but not `start`, when `endpoint` is `true`; otherwise, the function writes the `start` value, but not `stop`. - -```javascript -var arr = linspace.assign( 0.0, 100.0, [ -10.0 ] ); -// returns [ 100.0 ] - -arr = linspace.assign( 0.0, 100.0, [ -10.0 ], { - 'endpoint': true -}); -// returns [ 100.0 ] - -arr = linspace.assign( 0.0, 100.0, [ -10.0 ], { - 'endpoint': false -}); -// returns [ 0.0 ] -``` - -For real-valued `start` and `stop`, if `start` is less than `stop`, the output array will contain ascending values, and, if `start` is greater than `stop`, the output array will contain descending values. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var out = new Float64Array( 6 ); -var arr = linspace.assign( 0.0, -100.0, out ); -// returns [ 0.0, -20.0, -40.0, -60.0, -80.0, -100.0 ] -``` - -The function accepts the following `options`: - -- **endpoint**: `boolean` indicating whether to include the `stop` value in the output array. If `false`, the function generates `N + 1` linearly spaced values (where `N` is the length of the provided output array) over the interval `[start, stop]` and only writes `N` values to the output array, thus excluding `stop` from the output array. Accordingly, for a fixed `N`, the spacing between adjacent values in the output array changes depending on the value of `endpoint`. Default: `true`. - -By default, the function generates a linearly spaced array over the closed interval `[start, stop]`. To generate linearly spaced values over the half-open interval `[start, stop)`, set the `endpoint` option to `false`. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var opts = { - 'endpoint': false -}; - -var out = new Float64Array( 5 ); -var arr = linspace.assign( 0.0, 100.0, out, opts ); -// returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ] -``` - -
- - - -
- -## Notes - -- For `M >= 2`, the spacing between values is computed as - - ```text - delta = (stop-start) / (M-1) - ``` - - where `M` is the number of values to generate. Accordingly, values may not be evenly spaced due to floating-point rounding errors. - -- When the output array length is greater than `1` and `endpoint` is `true`, the output array is guaranteed to include the `start` and `stop` values. Beware, however, that values between `start` and `stop` are subject to floating-point rounding errors. Hence, - - ```javascript - var arr = linspace( 0.0, 1.0, 3 ); - // returns [ 0.0, ~0.5, 1.0 ] - ``` - - where `arr[1]` is only guaranteed to be approximately equal to `0.5`. If you desire more control over element precision, consider using [`roundn`][@stdlib/math/base/special/roundn]: - - ```javascript - var roundn = require( '@stdlib/math/base/special/roundn' ); - - // Create an array subject to floating-point rounding errors: - var arr = linspace( 0.0, 1.0, 3, { - 'dtype': 'generic' - }); - - // Round each value to the nearest hundredth: - var i; - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = roundn( arr[ i ], -2 ); - } - console.log( arr ); - // => [ 0.0, 0.5, 1.0 ] - ``` - -- For both functions, if both `start` and `stop` are real-valued, the output array data type may be any [floating-point data type][@stdlib/array/typed-float-dtypes] or `'generic'`. However, if either `start` or `stop` are complex numbers, the output array type must be a [complex floating-point data type][@stdlib/array/typed-complex-dtypes] or `'generic'`. - -- While the `assign` method accepts any array-like object for the output array when both `start` and `stop` are real-valued, providing an integer-valued typed array (e.g., [`Int32Array`][@stdlib/array/int32], etc) is not encouraged due to potential rounding errors during value generation and assignment and, thus, irregular spacing between adjacent values. Instead, consider using [`incrspace`][@stdlib/array/incrspace]. - -- When writing to a complex floating-point output array, real-valued `start` and `stop` values are treated as complex numbers having a real component equaling the provided value and having an imaginary component equaling `0`. - -- When generating linearly spaced complex floating-point numbers, the real and imaginary components are generated separately (i.e., real components are generated over the interval `[real(start), real(stop)]` and imaginary components are generated over the interval `[imag(start), imag(stop)]`). - -
- - - -
- -## Examples - - - -```javascript -var linspace = require( '@stdlib/array/linspace' ); - -// Define function options: -var opts = { - 'dtype': 'generic' -}; - -// Create arrays of varying lengths... -var out = linspace( 0, 10, 10, opts ); -console.log( out ); - -out = linspace( 0, 10, 11, opts ); -console.log( out ); - -out = linspace( 0, 10, 21, opts ); -console.log( out ); - -// Create an array with decremented values: -out = linspace( 10, 0, 11, opts ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/linspace/benchmark/benchmark.assign.complex128_complex.length.js b/linspace/benchmark/benchmark.assign.complex128_complex.length.js deleted file mode 100644 index 2d29a17d4..000000000 --- a/linspace/benchmark/benchmark.assign.complex128_complex.length.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Complex128Array = require( './../../complex128' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Complex128Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x1; - var x2; - var v; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:assign:dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.assign.complex128_real.length.js b/linspace/benchmark/benchmark.assign.complex128_real.length.js deleted file mode 100644 index 6eeee8c8a..000000000 --- a/linspace/benchmark/benchmark.assign.complex128_real.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Complex128Array = require( './../../complex128' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Complex128Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:assign:dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.assign.complex64_complex.length.js b/linspace/benchmark/benchmark.assign.complex64_complex.length.js deleted file mode 100644 index 467633c92..000000000 --- a/linspace/benchmark/benchmark.assign.complex64_complex.length.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Complex64Array = require( './../../complex64' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Complex64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x1; - var x2; - var v; - var i; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:assign:dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.assign.complex64_real.length.js b/linspace/benchmark/benchmark.assign.complex64_real.length.js deleted file mode 100644 index 97f7fc09a..000000000 --- a/linspace/benchmark/benchmark.assign.complex64_real.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Complex64Array = require( './../../complex64' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Complex64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:assign:dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.assign.float32_real.length.js b/linspace/benchmark/benchmark.assign.float32_real.length.js deleted file mode 100644 index 6cd47491a..000000000 --- a/linspace/benchmark/benchmark.assign.float32_real.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Float32Array = require( './../../float32' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Float32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:assign:dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.assign.float64_real.length.js b/linspace/benchmark/benchmark.assign.float64_real.length.js deleted file mode 100644 index fbf643c65..000000000 --- a/linspace/benchmark/benchmark.assign.float64_real.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Float64Array = require( './../../float64' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = new Float64Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:assign:dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.assign.generic_complex.length.js b/linspace/benchmark/benchmark.assign.generic_complex.length.js deleted file mode 100644 index 5e8a64490..000000000 --- a/linspace/benchmark/benchmark.assign.generic_complex.length.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var zeros = require( './../../base/zeros' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x1; - var x2; - var v; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:assign:dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.assign.generic_real.length.js b/linspace/benchmark/benchmark.assign.generic_real.length.js deleted file mode 100644 index e00e9148e..000000000 --- a/linspace/benchmark/benchmark.assign.generic_real.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var zeros = require( './../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var out = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:assign:dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.assign.js b/linspace/benchmark/benchmark.assign.js deleted file mode 100644 index cababf24c..000000000 --- a/linspace/benchmark/benchmark.assign.js +++ /dev/null @@ -1,227 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var zeros = require( './../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::real:assign:dtype=float64', function benchmark( b ) { - var out; - var v; - var i; - - out = new Float64Array( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:assign:dtype=float32', function benchmark( b ) { - var out; - var v; - var i; - - out = new Float32Array( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:assign:dtype=generic', function benchmark( b ) { - var out; - var v; - var i; - - out = zeros( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:assign:dtype=generic', function benchmark( b ) { - var out; - var x1; - var x2; - var v; - var i; - - out = zeros( 10 ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:assign:dtype=complex128', function benchmark( b ) { - var out; - var v; - var i; - - out = new Complex128Array( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:assign:dtype=complex128', function benchmark( b ) { - var out; - var x1; - var x2; - var v; - var i; - - out = new Complex128Array( 10 ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:assign:dtype=complex64', function benchmark( b ) { - var out; - var v; - var i; - - out = new Complex64Array( 10 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( 0.0, 100.0, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:assign:dtype=complex64', function benchmark( b ) { - var out; - var x1; - var x2; - var v; - var i; - - out = new Complex64Array( 10 ); - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace.assign( x1, x2, out ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/linspace/benchmark/benchmark.complex128_complex.length.js b/linspace/benchmark/benchmark.complex128_complex.length.js deleted file mode 100644 index 0f7355ef8..000000000 --- a/linspace/benchmark/benchmark.complex128_complex.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'complex128' - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.complex128_real.length.js b/linspace/benchmark/benchmark.complex128_real.length.js deleted file mode 100644 index dd99221a9..000000000 --- a/linspace/benchmark/benchmark.complex128_real.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.complex64_complex.length.js b/linspace/benchmark/benchmark.complex64_complex.length.js deleted file mode 100644 index 7645306a4..000000000 --- a/linspace/benchmark/benchmark.complex64_complex.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'complex64' - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.complex64_real.length.js b/linspace/benchmark/benchmark.complex64_real.length.js deleted file mode 100644 index 555079cbe..000000000 --- a/linspace/benchmark/benchmark.complex64_real.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.default_complex.length.js b/linspace/benchmark/benchmark.default_complex.length.js deleted file mode 100644 index c62d1ea6d..000000000 --- a/linspace/benchmark/benchmark.default_complex.length.js +++ /dev/null @@ -1,99 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x1; - var x2; - var v; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::default,complex:len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.default_real.length.js b/linspace/benchmark/benchmark.default_real.length.js deleted file mode 100644 index 3f6c47f1e..000000000 --- a/linspace/benchmark/benchmark.default_real.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::default,real:len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.float32_real.length.js b/linspace/benchmark/benchmark.float32_real.length.js deleted file mode 100644 index 6060169cc..000000000 --- a/linspace/benchmark/benchmark.float32_real.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.float64_real.length.js b/linspace/benchmark/benchmark.float64_real.length.js deleted file mode 100644 index c872cad4e..000000000 --- a/linspace/benchmark/benchmark.float64_real.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.generic_complex.length.js b/linspace/benchmark/benchmark.generic_complex.length.js deleted file mode 100644 index fb184b7fa..000000000 --- a/linspace/benchmark/benchmark.generic_complex.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'generic' - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::complex:dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.generic_real.length.js b/linspace/benchmark/benchmark.generic_real.length.js deleted file mode 100644 index edfc25d1d..000000000 --- a/linspace/benchmark/benchmark.generic_real.length.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, len, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+'::real:dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/linspace/benchmark/benchmark.js b/linspace/benchmark/benchmark.js deleted file mode 100644 index 79dd2a47d..000000000 --- a/linspace/benchmark/benchmark.js +++ /dev/null @@ -1,281 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var pkg = require( './../package.json' ).name; -var linspace = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::default,real', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::default,complex', function benchmark( b ) { - var x1; - var x2; - var v; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, 10 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=float64', function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'float64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=float32', function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'float32' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=generic', function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'generic' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:dtype=generic', function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'generic' - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=complex128', function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'complex128' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:dtype=complex128', function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'complex128' - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::real:dtype=complex64', function benchmark( b ) { - var opts; - var v; - var i; - - opts = { - 'dtype': 'complex64' - }; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( 0.0, 100.0, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::complex:dtype=complex64', function benchmark( b ) { - var opts; - var x1; - var x2; - var v; - var i; - - opts = { - 'dtype': 'complex64' - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = linspace( x1, x2, 10, opts ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array-like object' ); - } - } - b.toc(); - if ( !isArrayLikeObject( v ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/linspace/docs/repl.txt b/linspace/docs/repl.txt deleted file mode 100644 index 1428197cb..000000000 --- a/linspace/docs/repl.txt +++ /dev/null @@ -1,130 +0,0 @@ - -{{alias}}( start, stop, length[, options] ) - Generates a linearly spaced array over a specified interval. - - If the specified length is zero, the function returns an empty array. - - If the specified length is one, the function returns an array containing - `stop`, but not `start`, when `endpoint` is true; otherwise, the function - returns an array containing `start`, but not `stop`. - - For real-valued `start` and `stop`, if `start` is less than `stop`, the - output array will contain ascending values, and, if `start` is greater than - `stop`, the output array will contain descending values. - - When the output array length is greater than one and `endpoint` is true, the - output array is guaranteed to include the `start` and `stop` values. Beware, - however, that values between `start` and `stop` are subject to floating- - point rounding errors. - - If both `start` and `stop` are real-valued, the output array data type may - be any floating-point data type or 'generic'. However, if either `start` or - `stop` are complex numbers, the output array type must be a complex - floating-point data type or 'generic'. - - When writing to a complex floating-point output array, real-valued `start` - and `stop` values are treated as complex numbers having a real component - equaling the provided value and having an imaginary component equaling zero. - - When generating linearly spaced complex floating-point numbers, the real and - imaginary components are generated separately. - - Parameters - ---------- - start: number|ComplexLike - Start of interval. - - stop: number|ComplexLike - End of interval. - - length: integer - Length of output array. - - options: Object (optional) - Options. - - options.dtype: string (optional) - Output array data type. Must be a floating-point data type or 'generic'. - If both `start` and `stop` are the same type (either 'float64', - 'complex64', or 'complex128'), the default output array data type is - the same type as the input values (either 'float64', 'complex64', or - 'complex128', respectively). Otherwise, the default output array data - type is 'complex128'. - - options.endpoint: boolean (optional) - Boolean indicating whether to include the `stop` value in the output - array. If false, the function generates `length + 1` linearly spaced - values over the interval `[start, stop]` and only writes `length` values - to the output array, thus excluding `stop` from the output array. - Accordingly, for a fixed `length`, the spacing between adjacent values - in the output array changes depending on the value of `endpoint`. - Default: true. - - Returns - ------- - arr: Array - Linearly spaced array. - - Examples - -------- - > var arr = {{alias}}( 0.0, 100.0, 6 ) - [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - > arr = {{alias}}( 0.0, 100.0, 5, { 'endpoint': false } ) - [ 0.0, 20.0, 40.0, 60.0, 80.0 ] - > arr = {{alias}}( 0.0, 100.0, 6, { 'dtype': 'generic' } ) - [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - - -{{alias}}.assign( start, stop, out[, options] ) - Generates a linearly spaced sequence over a specified interval and assigns - the results to a provided output array. - - If the provided output array is empty, the function returns the provided - output array unchanged. - - If the provided output array contains a single element, the function writes - the `stop` value, but not `start`, when `endpoint` is true; otherwise, the - function writes the `start` value, but not `stop`. - - Parameters - ---------- - start: number|ComplexLike - Start of interval. - - stop: number|ComplexLike - End of interval. - - out: ArrayLikeObject - Output array. - - options: Object (optional) - Options. - - options.endpoint: boolean (optional) - Boolean indicating whether to include the `stop` value in the output - array. If false, the function generates `N+1` linearly spaced values - (where `N` is the length of the provided output array) over the interval - `[start, stop]` and only writes `N` values to the output array, thus - excluding `stop` from the output array. Accordingly, for a fixed `N`, - the spacing between adjacent values in the output array changes - depending on the value of `endpoint`. Default: true. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var arr = [ 0, 0, 0, 0, 0, 0 ]; - > var out = {{alias}}.assign( 0, 100, arr ) - [ 0, 20, 40, 60, 80, 100 ] - > var bool = ( arr === out ) - true - > arr = [ 0, 0, 0, 0, 0 ]; - > out = {{alias}}.assign( 0, 100, arr, { 'endpoint': false } ) - [ 0, 20, 40, 60, 80 ] - - See Also - -------- - diff --git a/linspace/docs/types/index.d.ts b/linspace/docs/types/index.d.ts deleted file mode 100644 index f9ad48474..000000000 --- a/linspace/docs/types/index.d.ts +++ /dev/null @@ -1,670 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { FloatingPointDataType as DataType, ArrayLike, FloatOrComplexTypedArray, Complex64Array, Complex128Array } from '@stdlib/types/array'; -import { ComplexLike, Complex64, Complex128 } from '@stdlib/types/complex'; - -/** -* Interface describing function options. -*/ -interface BaseOptions { - /** - * Boolean indicating whether to include the `stop` value in the output array. - * - * ## Notes - * - * - If `false`, the function generates `length + 1` linearly spaced values over the interval `[start, stop]` and only writes `length` values to the output array, thus excluding `stop` from the output array. Accordingly, for a fixed `length`, the spacing between adjacent values in the output array changes depending on the value of `endpoint`. - */ - endpoint?: boolean; -} - -/** -* Interface describing function options. -*/ -interface Options extends BaseOptions { - /** - * Output array data type. - * - * ## Notes - * - * - Must be a floating-point data type or `'generic'`. - * - If both `start` and `stop` are the same type (either `'float64'`, `'complex64'`, or `'complex128'`), the default output array data type is the same type as the input values (either `'float64'`, `'complex64'`, or `'complex128'`, respectively). Otherwise, the default output array data type is `'complex128'`. - */ - dtype?: DataType; -} - -/** -* Interface describing function options. -*/ -interface Float64Options extends BaseOptions { - /** - * Output array data type. - */ - dtype: 'float64'; -} - -/** -* Interface describing function options. -*/ -interface Float32Options extends BaseOptions { - /** - * Output array data type. - */ - dtype: 'float32'; -} - -/** -* Interface describing function options. -*/ -interface Complex128Options extends BaseOptions { - /** - * Output array data type. - */ - dtype: 'complex128'; -} - -/** -* Interface describing function options. -*/ -interface Complex64Options extends BaseOptions { - /** - * Output array data type. - */ - dtype: 'complex64'; -} - -/** -* Interface describing function options. -*/ -interface GenericOptions extends BaseOptions { - /** - * Output array data type. - */ - dtype: 'generic'; -} - -/** -* Interface describing `linspace`. -*/ -interface Linspace { - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var arr = linspace( 0.0, 100.0, 6 ); - * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - * - * @example - * var opts = { - * 'dtype': 'float64' - * }; - * var arr = linspace( 0.0, 100.0, 6, opts ); - * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - */ - ( start: number, stop: number, len: number, options?: BaseOptions | Float64Options ): Float64Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var opts = { - * 'dtype': 'float32' - * }; - * var arr = linspace( 0.0, 100.0, 6 ); - * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - */ - ( start: number, stop: number, len: number, options: Float32Options ): Float32Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var opts = { - * 'dtype': 'generic' - * }; - * var arr = linspace( 0.0, 100.0, 6 ); - * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - */ - ( start: number, stop: number, len: number, options: GenericOptions ): Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * var start = new Complex64( 0.0, 0.0 ); - * var stop = new Complex64( 100.0, 10.0 ); - * - * var arr = linspace( start, stop, 6 ); - * // returns - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * var start = new Complex64( 0.0, 0.0 ); - * var stop = new Complex64( 100.0, 10.0 ); - * - * var opts = { - * 'dtype': 'complex64' - * }; - * var arr = linspace( start, stop, 6, opts ); - * // returns - */ - ( start: Complex64, stop: Complex64, len: number, options?: Complex64Options ): Complex64Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * var start = new Complex64( 0.0, 0.0 ); - * var stop = new Complex64( 100.0, 10.0 ); - * - * var opts = { - * 'dtype': 'complex64' - * }; - * var arr = linspace( start, stop, 6, opts ); - * // returns - */ - ( start: number | ComplexLike, stop: number | ComplexLike, len: number, options: Complex64Options ): Complex64Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * var start = new Complex64( 0.0, 0.0 ); - * var stop = new Complex64( 100.0, 10.0 ); - * - * var opts = { - * 'dtype': 'generic' - * }; - * var arr = linspace( start, stop, 6, opts ); - * // returns [...] - */ - ( start: Complex64, stop: Complex64, len: number, options: GenericOptions ): Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var start = new Complex128( 0.0, 0.0 ); - * var stop = new Complex128( 100.0, 10.0 ); - * - * var opts = { - * 'dtype': 'generic' - * }; - * var arr = linspace( start, stop, 6, opts ); - * // returns [...] - */ - ( start: ComplexLike, stop: number | ComplexLike, len: number, options: GenericOptions ): Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var start = new Complex128( 0.0, 0.0 ); - * var stop = new Complex128( 100.0, 10.0 ); - * - * var opts = { - * 'dtype': 'generic' - * }; - * var arr = linspace( start, stop, 6, opts ); - * // returns [...] - */ - ( start: number | ComplexLike, stop: ComplexLike, len: number, options: GenericOptions ): Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var start = new Complex128( 0.0, 0.0 ); - * var stop = 100.0; - * - * var arr = linspace( start, stop, 6 ); - * // returns - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var start = new Complex128( 0.0, 0.0 ); - * var stop = 100.0; - * - * var opts = { - * 'dtype': 'complex128' - * }; - * var arr = linspace( start, stop, 6, opts ); - * // returns - */ - ( start: ComplexLike, stop: number | ComplexLike, len: number, options?: Complex128Options ): Complex128Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var start = 0.0; - * var stop = new Complex128( 100.0, 10.0 ); - * - * var arr = linspace( start, stop, 6 ); - * // returns - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var start = 0.0; - * var stop = new Complex128( 100.0, 10.0 ); - * - * var opts = { - * 'dtype': 'complex128' - * }; - * var arr = linspace( start, stop, 6, opts ); - * // returns - */ - ( start: number | ComplexLike, stop: ComplexLike, len: number, options?: Complex128Options ): Complex128Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var start = 0.0; - * var stop = 100.0; - * - * var opts = { - * 'dtype': 'complex128' - * }; - * var arr = linspace( start, stop, 6, opts ); - * // returns - */ - ( start: number, stop: number, len: number, options: Complex128Options ): Complex128Array; - - /** - * Generates a linearly spaced array over a specified interval. - * - * @param start - start of interval - * @param stop - end of interval - * @param len - length of output array - * @param options - function options - * @param options.dtype - output array data type - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns linearly spaced array - * - * @example - * var arr = linspace( 0.0, 100.0, 6 ); - * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - */ - ( start: number | ComplexLike, stop: number | ComplexLike, len: number, options?: Options ): FloatOrComplexTypedArray; - - /** - * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. - * - * @param start - start of interval - * @param stop - end of interval - * @param out - output array - * @param options - function options - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns output array - * - * @example - * var Float64Array = require( './../../../float64' ); - * - * var out = new Float64Array( 6 ); - * var arr = linspace.assign( 0.0, 100.0, out ); - * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - */ - assign( start: number, stop: number, out: Float64Array, options?: BaseOptions ): Float64Array; - - /** - * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. - * - * @param start - start of interval - * @param stop - end of interval - * @param out - output array - * @param options - function options - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns output array - * - * @example - * var Float32Array = require( './../../../float32' ); - * - * var out = new Float32Array( 6 ); - * var arr = linspace.assign( 0.0, 100.0, out ); - * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - */ - assign( start: number, stop: number, out: Float32Array, options?: BaseOptions ): Float32Array; - - /** - * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. - * - * @param start - start of interval - * @param stop - end of interval - * @param out - output array - * @param options - function options - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns output array - * - * @example - * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; - * var arr = linspace.assign( 0.0, 100.0, out ); - * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - */ - assign( start: number, stop: number, out: Array, options?: BaseOptions ): Array; - - /** - * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. - * - * @param start - start of interval - * @param stop - end of interval - * @param out - output array - * @param options - function options - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns output array - * - * @example - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * var start = new Complex64( 0.0, 0.0 ); - * var stop = new Complex64( 100.0, 10.0 ); - * - * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; - * var arr = linspace.assign( start, stop, out ); - * // returns [...] - */ - assign( start: Complex64, stop: Complex64, out: Array, options?: BaseOptions ): Array; - - /** - * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. - * - * @param start - start of interval - * @param stop - end of interval - * @param out - output array - * @param options - function options - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns output array - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var start = new Complex128( 0.0, 0.0 ); - * var stop = new Complex128( 100.0, 10.0 ); - * - * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; - * var arr = linspace.assign( start, stop, out ); - * // returns [...] - */ - assign( start: ComplexLike, stop: number | ComplexLike, out: Array, options?: BaseOptions ): Array; - - /** - * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. - * - * @param start - start of interval - * @param stop - end of interval - * @param out - output array - * @param options - function options - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns output array - * - * @example - * var Complex128 = require( '@stdlib/complex/float64/ctor' ); - * - * var start = new Complex128( 0.0, 0.0 ); - * var stop = new Complex128( 100.0, 10.0 ); - * - * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; - * var arr = linspace.assign( start, stop, out ); - * // returns [...] - */ - assign( start: number | ComplexLike, stop: ComplexLike, out: Array, options?: BaseOptions ): Array; - - /** - * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. - * - * @param start - start of interval - * @param stop - end of interval - * @param out - output array - * @param options - function options - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns output array - * - * @example - * var Complex128Array = require( './../../../complex128' ); - * - * var out = new Complex128Array( 6 ); - * var arr = linspace.assign( 0.0, 100.0, out ); - * // returns - */ - assign( start: number | ComplexLike, stop: number | ComplexLike, out: Complex128Array, options?: BaseOptions ): Complex128Array; - - /** - * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. - * - * @param start - start of interval - * @param stop - end of interval - * @param out - output array - * @param options - function options - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns output array - * - * @example - * var Complex64Array = require( './../../../complex64' ); - * - * var out = new Complex64Array( 6 ); - * var arr = linspace.assign( 0.0, 100.0, out ); - * // returns - */ - assign( start: number | ComplexLike, stop: number | ComplexLike, out: Complex64Array, options?: BaseOptions ): Complex64Array; - - /** - * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. - * - * @param start - start of interval - * @param stop - end of interval - * @param out - output array - * @param options - function options - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns output array - * - * @example - * var Float64Array = require( './../../../float64' ); - * - * var out = new Float64Array( 6 ); - * var arr = linspace.assign( 0.0, 100.0, out ); - * // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] - */ - assign( start: number, stop: number, out: ArrayLike, options?: BaseOptions ): ArrayLike; - - /** - * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. - * - * @param start - start of interval - * @param stop - end of interval - * @param out - output array - * @param options - function options - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns output array - * - * @example - * var Float64Array = require( './../../../float64' ); - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * var start = new Complex64( 0.0, 0.0 ); - * var stop = new Complex64( 100.0, 10.0 ); - * - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * var arr = linspace.assign( start, stop, out ); - * // returns [...] - */ - assign( start: ComplexLike, stop: number | ComplexLike, out: ArrayLike, options?: BaseOptions ): ArrayLike; - - /** - * Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. - * - * @param start - start of interval - * @param stop - end of interval - * @param out - output array - * @param options - function options - * @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array - * @returns output array - * - * @example - * var Float64Array = require( './../../../float64' ); - * var Complex64 = require( '@stdlib/complex/float32/ctor' ); - * - * var start = new Complex64( 0.0, 0.0 ); - * var stop = new Complex64( 100.0, 10.0 ); - * - * var out = [ 0, 0, 0, 0, 0, 0 ]; - * var arr = linspace.assign( start, stop, out ); - * // returns [...] - */ - assign( start: number | ComplexLike, stop: ComplexLike, out: ArrayLike, options?: BaseOptions ): ArrayLike; -} - -/** -* Generates a linearly spaced array over a specified interval. -* -* @param start - start of interval -* @param stop - end of interval -* @param len - length of output array -* @param options - function options -* @param options.dtype - output array data type -* @param options.endpoint - `boolean` indicating whether to include the `stop` value in the output array -* @returns linearly spaced array -* -* @example -* var arr = linspace( 0.0, 100.0, 6 ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] -* -* @example -* var Float32Array = require( '@stdlib/array/float32' ); -* -* var arr = new Float32Array( 6 ); -* var out = linspace.assign( 0.0, 100.0, arr ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ -declare var linspace: Linspace; - - -// EXPORTS // - -export = linspace; diff --git a/linspace/docs/types/test.ts b/linspace/docs/types/test.ts deleted file mode 100644 index 9e6638f9f..000000000 --- a/linspace/docs/types/test.ts +++ /dev/null @@ -1,390 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 Complex64 = require( '@stdlib/complex/float32/ctor' ); -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import linspace = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - linspace( 0, 11, 20 ); // $ExpectType Float64Array - - linspace( 0, 11, 20, { 'endpoint': true } ); // $ExpectType Float64Array - linspace( 0, 11, 20, { 'endpoint': false } ); // $ExpectType Float64Array - - linspace( 0, 11, 20, { 'dtype': 'float64' } ); // $ExpectType Float64Array - linspace( 0, 11, 20, { 'dtype': 'float32' } ); // $ExpectType Float32Array - linspace( 0, 11, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( 0, 11, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( 0, 11, 20, { 'dtype': 'generic' } ); // $ExpectType number[] - - const z1 = new Complex64( 0.0, 0.0 ); - const z2 = new Complex64( 100.0, 10.0 ); - const z3 = new Complex128( 0.0, 0.0 ); - const z4 = new Complex128( 100.0, 10.0 ); - - linspace( z1, 11, 20 ); // $ExpectType Complex128Array - linspace( 0, z2, 20 ); // $ExpectType Complex128Array - linspace( z1, z2, 20 ); // $ExpectType Complex64Array - - linspace( z1, z4, 20 ); // $ExpectType Complex128Array - linspace( z3, z2, 20 ); // $ExpectType Complex128Array - - linspace( 0, z4, 20 ); // $ExpectType Complex128Array - linspace( z3, 11, 20 ); // $ExpectType Complex128Array - linspace( z3, z4, 20 ); // $ExpectType Complex128Array - - linspace( z1, 11, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z1, 11, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z1, 11, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( 0, z2, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( 0, z2, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( 0, z2, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( z1, z2, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z1, z2, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z1, z2, 20, { 'dtype': 'generic' } ); // $ExpectType Complex64[] - - linspace( z1, z4, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z1, z4, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z1, z4, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( z3, z2, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z3, z2, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z3, z2, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( z3, 11, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z3, 11, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z3, 11, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( 0, z4, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( 0, z4, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( 0, z4, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] - - linspace( z3, z4, 20, { 'dtype': 'complex64' } ); // $ExpectType Complex64Array - linspace( z3, z4, 20, { 'dtype': 'complex128' } ); // $ExpectType Complex128Array - linspace( z3, z4, 20, { 'dtype': 'generic' } ); // $ExpectType Complex128[] -} - -// The compiler throws an error if the function is not provided a number or complex number for the first argument... -{ - const z = new Complex64( 1.0, 2.0 ); - - linspace( true, 10, 100 ); // $ExpectError - linspace( false, 10, 100 ); // $ExpectError - linspace( '5', 10, 100 ); // $ExpectError - linspace( [], 10, 100 ); // $ExpectError - linspace( {}, 10, 100 ); // $ExpectError - linspace( ( x: number ): number => x, 10, 100 ); // $ExpectError - - linspace( true, 10, 100, {} ); // $ExpectError - linspace( false, 10, 100, {} ); // $ExpectError - linspace( '5', 10, 100, {} ); // $ExpectError - linspace( [], 10, 100, {} ); // $ExpectError - linspace( {}, 10, 100, {} ); // $ExpectError - linspace( ( x: number ): number => x, 10, 100, {} ); // $ExpectError - - linspace( true, z, 100 ); // $ExpectError - linspace( false, z, 100 ); // $ExpectError - linspace( '5', z, 100 ); // $ExpectError - linspace( [], z, 100 ); // $ExpectError - linspace( {}, z, 100 ); // $ExpectError - linspace( ( x: number ): number => x, z, 100 ); // $ExpectError - - linspace( true, z, 100, {} ); // $ExpectError - linspace( false, z, 100, {} ); // $ExpectError - linspace( '5', z, 100, {} ); // $ExpectError - linspace( [], z, 100, {} ); // $ExpectError - linspace( {}, z, 100, {} ); // $ExpectError - linspace( ( x: number ): number => x, z, 100, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a number or complex number for the second argument... -{ - const z = new Complex64( 1.0, 2.0 ); - - linspace( 0, true, 100 ); // $ExpectError - linspace( 0, false, 100 ); // $ExpectError - linspace( 0, '5', 100 ); // $ExpectError - linspace( 0, [], 100 ); // $ExpectError - linspace( 0, {}, 100 ); // $ExpectError - linspace( 0, ( x: number ): number => x, 100 ); // $ExpectError - - linspace( 0, true, 100, {} ); // $ExpectError - linspace( 0, false, 100, {} ); // $ExpectError - linspace( 0, '5', 100, {} ); // $ExpectError - linspace( 0, [], 100, {} ); // $ExpectError - linspace( 0, {}, 100, {} ); // $ExpectError - linspace( 0, ( x: number ): number => x, 100, {} ); // $ExpectError - - linspace( z, true, 100 ); // $ExpectError - linspace( z, false, 100 ); // $ExpectError - linspace( z, '5', 100 ); // $ExpectError - linspace( z, [], 100 ); // $ExpectError - linspace( z, {}, 100 ); // $ExpectError - linspace( z, ( x: number ): number => x, 100 ); // $ExpectError - - linspace( z, true, 100, {} ); // $ExpectError - linspace( z, false, 100, {} ); // $ExpectError - linspace( z, '5', 100, {} ); // $ExpectError - linspace( z, [], 100, {} ); // $ExpectError - linspace( z, {}, 100, {} ); // $ExpectError - linspace( z, ( x: number ): number => x, 100, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a number for the third argument... -{ - linspace( 2, 20, '5' ); // $ExpectError - linspace( 3, 20, true ); // $ExpectError - linspace( 4, 20, false ); // $ExpectError - linspace( 2, 20, null ); // $ExpectError - linspace( 2, 20, [] ); // $ExpectError - linspace( 2, 20, {} ); // $ExpectError - linspace( 9, 20, ( x: number ): number => x ); // $ExpectError - - linspace( 2, 20, '5', {} ); // $ExpectError - linspace( 3, 20, true, {} ); // $ExpectError - linspace( 4, 20, false, {} ); // $ExpectError - linspace( 2, 20, null, {} ); // $ExpectError - linspace( 2, 20, [], {} ); // $ExpectError - linspace( 2, 20, {}, {} ); // $ExpectError - linspace( 9, 20, ( x: number ): number => x, {} ); // $ExpectError -} - -// The compiler throws an error if the function is not provided an object for the fourth argument... -{ - linspace( 2, 20, 100, '5' ); // $ExpectError - linspace( 3, 20, 100, true ); // $ExpectError - linspace( 4, 20, 100, false ); // $ExpectError - linspace( 2, 20, 100, [] ); // $ExpectError - linspace( 9, 20, 100, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid `dtype` option... -{ - linspace( 2, 20, 100, { 'dtype': '5' } ); // $ExpectError - linspace( 2, 20, 100, { 'dtype': 5 } ); // $ExpectError - linspace( 3, 20, 100, { 'dtype': true } ); // $ExpectError - linspace( 4, 20, 100, { 'dtype': false } ); // $ExpectError - linspace( 2, 20, 100, { 'dtype': [] } ); // $ExpectError - linspace( 2, 20, 100, { 'dtype': {} } ); // $ExpectError - linspace( 9, 20, 100, { 'dtype': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is not provided a valid `endpoint` option... -{ - linspace( 2, 20, 100, { 'endpoint': '5' } ); // $ExpectError - linspace( 2, 20, 100, { 'endpoint': 5 } ); // $ExpectError - linspace( 2, 20, 100, { 'endpoint': [] } ); // $ExpectError - linspace( 2, 20, 100, { 'endpoint': {} } ); // $ExpectError - linspace( 9, 20, 100, { 'endpoint': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - linspace(); // $ExpectError - linspace( 3 ); // $ExpectError - linspace( 3, 10 ); // $ExpectError - linspace( 3, 10, 100, {}, null ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns an output array... -{ - const o1 = new Float64Array( 10 ); - const o2 = new Float32Array( 10 ); - const o3 = [ 1, 2, 3, 4 ]; - const o4 = new Complex128Array( 10 ); - const o5 = new Complex64Array( 10 ); - - linspace.assign( 0, 11, o1 ); // $ExpectType Float64Array - - linspace.assign( 0, 11, o1, { 'endpoint': true } ); // $ExpectType Float64Array - linspace.assign( 0, 11, o1, { 'endpoint': false } ); // $ExpectType Float64Array - - linspace.assign( 0, 11, o2 ); // $ExpectType Float32Array - linspace.assign( 0, 11, o3 ); // $ExpectType number[] - linspace.assign( 0, 11, o4 ); // $ExpectType Complex128Array - linspace.assign( 0, 11, o5 ); // $ExpectType Complex64Array - - const z1 = new Complex64( 0.0, 0.0 ); - const z2 = new Complex64( 100.0, 10.0 ); - const z3 = new Complex128( 0.0, 0.0 ); - const z4 = new Complex128( 100.0, 10.0 ); - - linspace.assign( z1, 11, o5 ); // $ExpectType Complex64Array - linspace.assign( 0, z2, o5 ); // $ExpectType Complex64Array - linspace.assign( z1, z2, o5 ); // $ExpectType Complex64Array - - linspace.assign( z1, z4, o5 ); // $ExpectType Complex64Array - linspace.assign( z3, z2, o5 ); // $ExpectType Complex64Array - - linspace.assign( 0, z4, o5 ); // $ExpectType Complex64Array - linspace.assign( z3, 11, o5 ); // $ExpectType Complex64Array - linspace.assign( z3, z4, o5 ); // $ExpectType Complex64Array - - linspace.assign( z1, 11, o4 ); // $ExpectType Complex128Array - linspace.assign( 0, z2, o4 ); // $ExpectType Complex128Array - linspace.assign( z1, z2, o4 ); // $ExpectType Complex128Array - - linspace.assign( z1, z4, o4 ); // $ExpectType Complex128Array - linspace.assign( z3, z2, o4 ); // $ExpectType Complex128Array - - linspace.assign( 0, z4, o4 ); // $ExpectType Complex128Array - linspace.assign( z3, 11, o4 ); // $ExpectType Complex128Array - linspace.assign( z3, z4, o4 ); // $ExpectType Complex128Array - - linspace.assign( z1, 11, o3 ); // $ExpectType Complex128[] - linspace.assign( 0, z2, o3 ); // $ExpectType Complex128[] - linspace.assign( z1, z2, o3 ); // $ExpectType Complex64[] - - linspace.assign( z1, z4, o3 ); // $ExpectType Complex128[] - linspace.assign( z3, z2, o3 ); // $ExpectType Complex128[] - - linspace.assign( 0, z4, o3 ); // $ExpectType Complex128[] - linspace.assign( z3, 11, o3 ); // $ExpectType Complex128[] - linspace.assign( z3, z4, o3 ); // $ExpectType Complex128[] -} - -// The compiler throws an error if the `assign` method is not provided a number or complex number for the first argument... -{ - const z = new Complex64( 1.0, 2.0 ); - const o1 = new Float64Array( 10 ); - const o2 = new Complex128Array( 10 ); - - linspace.assign( true, 10, o1 ); // $ExpectError - linspace.assign( false, 10, o1 ); // $ExpectError - linspace.assign( '5', 10, o1 ); // $ExpectError - linspace.assign( [], 10, o1 ); // $ExpectError - linspace.assign( {}, 10, o1 ); // $ExpectError - linspace.assign( ( x: number ): number => x, 10, o1 ); // $ExpectError - - linspace.assign( true, 10, o1, {} ); // $ExpectError - linspace.assign( false, 10, o1, {} ); // $ExpectError - linspace.assign( '5', 10, o1, {} ); // $ExpectError - linspace.assign( [], 10, o1, {} ); // $ExpectError - linspace.assign( {}, 10, o1, {} ); // $ExpectError - linspace.assign( ( x: number ): number => x, 10, o1, {} ); // $ExpectError - - linspace.assign( true, z, o2 ); // $ExpectError - linspace.assign( false, z, o2 ); // $ExpectError - linspace.assign( '5', z, o2 ); // $ExpectError - linspace.assign( [], z, o2 ); // $ExpectError - linspace.assign( {}, z, o2 ); // $ExpectError - linspace.assign( ( x: number ): number => x, z, o2 ); // $ExpectError - - linspace.assign( true, z, o2, {} ); // $ExpectError - linspace.assign( false, z, o2, {} ); // $ExpectError - linspace.assign( '5', z, o2, {} ); // $ExpectError - linspace.assign( [], z, o2, {} ); // $ExpectError - linspace.assign( {}, z, o2, {} ); // $ExpectError - linspace.assign( ( x: number ): number => x, z, o2, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is not provided a number or complex number for the second argument... -{ - const z = new Complex64( 1.0, 2.0 ); - const o1 = new Float64Array( 10 ); - const o2 = new Complex128Array( 10 ); - - linspace.assign( 0, true, o1 ); // $ExpectError - linspace.assign( 0, false, o1 ); // $ExpectError - linspace.assign( 0, '5', o1 ); // $ExpectError - linspace.assign( 0, [], o1 ); // $ExpectError - linspace.assign( 0, {}, o1 ); // $ExpectError - linspace.assign( 0, ( x: number ): number => x, o1 ); // $ExpectError - - linspace.assign( 0, true, o1, {} ); // $ExpectError - linspace.assign( 0, false, o1, {} ); // $ExpectError - linspace.assign( 0, '5', o1, {} ); // $ExpectError - linspace.assign( 0, [], o1, {} ); // $ExpectError - linspace.assign( 0, {}, o1, {} ); // $ExpectError - linspace.assign( 0, ( x: number ): number => x, o1, {} ); // $ExpectError - - linspace.assign( z, true, o2 ); // $ExpectError - linspace.assign( z, false, o2 ); // $ExpectError - linspace.assign( z, '5', o2 ); // $ExpectError - linspace.assign( z, [], o2 ); // $ExpectError - linspace.assign( z, {}, o2 ); // $ExpectError - linspace.assign( z, ( x: number ): number => x, o2 ); // $ExpectError - - linspace.assign( z, true, o2, {} ); // $ExpectError - linspace.assign( z, false, o2, {} ); // $ExpectError - linspace.assign( z, '5', o2, {} ); // $ExpectError - linspace.assign( z, [], o2, {} ); // $ExpectError - linspace.assign( z, {}, o2, {} ); // $ExpectError - linspace.assign( z, ( x: number ): number => x, o2, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is not provided an array-like object for the third argument... -{ - const z = new Complex64( 1.0, 2.0 ); - - linspace.assign( 0, 10, true ); // $ExpectError - linspace.assign( 0, 10, false ); // $ExpectError - linspace.assign( 0, 10, 5 ); // $ExpectError - linspace.assign( 0, 10, {} ); // $ExpectError - - linspace.assign( 0, 10, true, {} ); // $ExpectError - linspace.assign( 0, 10, false, {} ); // $ExpectError - linspace.assign( 0, 10, 5, {} ); // $ExpectError - linspace.assign( 0, 10, {}, {} ); // $ExpectError - - linspace.assign( z, z, true ); // $ExpectError - linspace.assign( z, z, false ); // $ExpectError - linspace.assign( z, z, 5 ); // $ExpectError - linspace.assign( z, z, {} ); // $ExpectError - - linspace.assign( z, z, true, {} ); // $ExpectError - linspace.assign( z, z, false, {} ); // $ExpectError - linspace.assign( z, z, 5, {} ); // $ExpectError - linspace.assign( z, z, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is not provided an object for the fourth argument... -{ - linspace.assign( 2, 20, [], '5' ); // $ExpectError - linspace.assign( 3, 20, [], true ); // $ExpectError - linspace.assign( 4, 20, [], false ); // $ExpectError - linspace.assign( 2, 20, [], [] ); // $ExpectError - linspace.assign( 9, 20, [], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is not provided a valid `endpoint` option... -{ - const out = new Float64Array( 10 ); - - linspace.assign( 2, 20, out, { 'endpoint': '5' } ); // $ExpectError - linspace.assign( 2, 20, out, { 'endpoint': 5 } ); // $ExpectError - linspace.assign( 2, 20, out, { 'endpoint': [] } ); // $ExpectError - linspace.assign( 2, 20, out, { 'endpoint': {} } ); // $ExpectError - linspace.assign( 9, 20, out, { 'endpoint': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - linspace.assign(); // $ExpectError - linspace.assign( 3 ); // $ExpectError - linspace.assign( 3, 10 ); // $ExpectError - linspace.assign( 3, 10, [], {}, null ); // $ExpectError -} diff --git a/linspace/examples/index.js b/linspace/examples/index.js deleted file mode 100644 index 0b0c3dfda..000000000 --- a/linspace/examples/index.js +++ /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. -*/ - -'use strict'; - -var linspace = require( './../lib' ); - -// Define function options: -var opts = { - 'dtype': 'generic' -}; - -// Create arrays of varying lengths... -var out = linspace( 0, 10, 10, opts ); -console.log( out ); - -out = linspace( 0, 10, 11, opts ); -console.log( out ); - -out = linspace( 0, 10, 21, opts ); -console.log( out ); - -// Create an array with decremented values: -out = linspace( 10, 0, 11, opts ); -console.log( out ); diff --git a/linspace/lib/accessors_complex.js b/linspace/lib/accessors_complex.js deleted file mode 100644 index e8e910c7f..000000000 --- a/linspace/lib/accessors_complex.js +++ /dev/null @@ -1,136 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - - -// MAIN // - -/** -* Generates a linearly spaced complex number sequence over a specified interval and assigns results to a provided output array. -* -* @private -* @param {Object} out - output array object -* @param {ArrayLikeObject} out.data - output array data -* @param {Array} out.accessors - array element accessors -* @param {string} dt1 - start value data type -* @param {ComplexLike} start - start of interval -* @param {string} dt2 - stop value data type -* @param {ComplexLike} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {Object} output array object -*/ -function linspace( out, dt1, start, dt2, stop, len, endpoint ) { - var cmplx; - var isf32; - var re1; - var re2; - var im1; - var im2; - var set; - var buf; - var re; - var im; - var dr; - var di; - var N; - var i; - - if ( len === 0 ) { - return out; - } - isf32 = 0; - if ( dt1 === 'float64' ) { - re1 = start; - im1 = 0.0; - } else if ( dt1 === 'complex64' ) { - isf32 += 1; - re1 = realf( start ); - im1 = imagf( start ); - } else { - re1 = real( start ); - im1 = imag( start ); - } - if ( dt2 === 'float64' ) { - re2 = stop; - im2 = 0.0; - } else if ( dt2 === 'complex64' ) { - isf32 += 1; - re2 = realf( stop ); - im2 = imagf( stop ); - } else { - re2 = real( stop ); - im2 = imag( stop ); - } - // Determine which complex number constructor to use according to type promotion rules: - if ( isf32 === 2 ) { - cmplx = Complex64; - } else { - cmplx = Complex128; - } - // Cache array object references: - buf = out.data; - set = out.accessors[ 1 ]; - - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - set( buf, 0, new cmplx( re2, im2 ) ); - } else { - set( buf, 0, new cmplx( re1, im1 ) ); - } - return out; - } - set( buf, 0, new cmplx( re1, im1 ) ); - - // Calculate the increments: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - dr = ( re2-re1 ) / N; - di = ( im2-im1 ) / N; - - // Generate the linearly spaced values: - for ( i = 1; i < N; i++ ) { - re = re1 + (dr*i); - im = im1 + (di*i); - set( buf, i, new cmplx( re, im ) ); - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - set( buf, N, new cmplx( re2, im2 ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/linspace/lib/accessors_real.js b/linspace/lib/accessors_real.js deleted file mode 100644 index 788e6d41b..000000000 --- a/linspace/lib/accessors_real.js +++ /dev/null @@ -1,117 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Generates a linearly spaced sequence over a specified interval and assigns results to a provided output array. -* -* @private -* @param {Object} out - output array object -* @param {ArrayLikeObject} out.data - output array data -* @param {Array} out.accessors - array element accessors -* @param {number} start - start of interval -* @param {number} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {Object} output array object -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function set( buf, i, v ) { -* buf[ i ] = v * 2.0; -* } -* -* var out = new Float64Array( 6 ); -* var obj = { -* 'data': out, -* 'accessors': [ null, set ] -* }; -* linspace( obj, 0, 100, out.length, true ); -* -* var arr = obj.data; -* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0, 200.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* function set( buf, i, v ) { -* buf[ i ] = v * 2.0; -* } -* -* var out = new Float64Array( 5 ); -* var obj = { -* 'data': out, -* 'accessors': [ null, set ] -* }; -* linspace( obj, 0, 100, out.length, false ); -* -* var arr = obj.data; -* // returns [ 0.0, 40.0, 80.0, 120.0, 160.0 ] -*/ -function linspace( out, start, stop, len, endpoint ) { - var buf; - var set; - var N; - var d; - var i; - - if ( len === 0 ) { - return out; - } - // Cache array object references: - buf = out.data; - set = out.accessors[ 1 ]; - - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - set( buf, 0, stop ); - } else { - set( buf, 0, start ); - } - return out; - } - set( buf, 0, start ); - - // Calculate the increment: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - d = ( stop-start ) / N; - - // Generate linearly spaced values: - for ( i = 1; i < N; i++ ) { - set( buf, i, start + (d*i) ); - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - set( buf, N, stop ); - } - return out; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/linspace/lib/assign.js b/linspace/lib/assign.js deleted file mode 100644 index b9bafb06f..000000000 --- a/linspace/lib/assign.js +++ /dev/null @@ -1,147 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var isCollection = require( '@stdlib/assert/is-collection' ); -var format = require( '@stdlib/string/format' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var dtype = require( '@stdlib/complex/dtype' ); -var adtype = require( './../../dtype' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var arraylike2object = require( './../../base/arraylike2object' ); -var acccmplx = require( './accessors_complex.js' ); -var accreal = require( './accessors_real.js' ); -var typedcmplx = require( './typed_complex.js' ); -var typedreal = require( './typed_real.js' ); -var validate = require( './validate.js' ); -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array. -* -* @param {(number|ComplexLike)} start - start of interval -* @param {(number|ComplexLike)} stop - end of interval -* @param {Collection} out - output array -* @param {Options} [options] - options -* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array -* @throws {TypeError} first argument must be either a real or complex number -* @throws {TypeError} second argument must be either a real or complex number -* @throws {TypeError} third argument must be an array-like object -* @throws {TypeError} last argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} the output array data type must be a complex number data type or "generic" when either `start` or `stop` is a complex number -* @returns {Collection} output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var out = new Float64Array( 6 ); -* var arr = linspace( 0, 100, out ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] -*/ -function linspace( start, stop, out ) { - var opts; - var err; - var dt1; - var dt2; - var flg; - var odt; - var o; - - if ( typeof start === 'object' ) { - dt1 = dtype( start ); - if ( dt1 === null ) { - if ( !isComplexLike( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); - } - dt1 = 'complex128'; - } - flg = true; - } else if ( !isNumber( start ) || isnan( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); - } else { - dt1 = 'float64'; - } - if ( typeof stop === 'object' ) { - dt2 = dtype( stop ); - if ( dt2 === null ) { - if ( !isComplexLike( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); - } - dt2 = 'complex128'; - } - flg = true; - } else if ( !isNumber( stop ) || isnan( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); - } else { - dt2 = 'float64'; - } - if ( !isCollection( out ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', out ) ); - } - opts = { - 'endpoint': defaults.endpoint - }; - if ( arguments.length > 3 ) { - err = validate( opts, arguments[ 3 ] ); - if ( err ) { - throw err; - } - } - odt = adtype( out ); - if ( odt === null ) { - odt = 'generic'; - } - if ( odt === 'complex64' ) { - typedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len - return out; - } - if ( odt === 'complex128' ) { - typedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, out.length, opts.endpoint ); // eslint-disable-line max-len - return out; - } - if ( flg ) { - if ( odt === 'generic' ) { - o = arraylike2object( out ); - acccmplx( o, dt1, start, dt2, stop, out.length, opts.endpoint ); - return out; - } - throw new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array must be a complex number array or a "generic" array-like object.' ); - } - o = arraylike2object( out ); - if ( o.accessorProtocol ) { - accreal( o, start, stop, out.length, opts.endpoint ); - return out; - } - typedreal( out, start, stop, out.length, opts.endpoint ); - return out; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/linspace/lib/defaults.json b/linspace/lib/defaults.json deleted file mode 100644 index 0afc16c6a..000000000 --- a/linspace/lib/defaults.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "endpoint": true -} diff --git a/linspace/lib/generic_complex.js b/linspace/lib/generic_complex.js deleted file mode 100644 index d0c9e0525..000000000 --- a/linspace/lib/generic_complex.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - - -// MAIN // - -/** -* Generates a linearly spaced complex number array over a specified interval. -* -* @private -* @param {string} dt1 - start value data type -* @param {(number|ComplexLike)} start - start of interval -* @param {string} dt2 - stop value data type -* @param {(number|ComplexLike)} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {Array} linearly spaced array -*/ -function linspace( dt1, start, dt2, stop, len, endpoint ) { - var cmplx; - var isf32; - var arr; - var re1; - var re2; - var im1; - var im2; - var re; - var im; - var dr; - var di; - var N; - var i; - - if ( len === 0 ) { - return []; - } - isf32 = 0; - if ( dt1 === 'float64' ) { - re1 = start; - im1 = 0.0; - } else if ( dt1 === 'complex64' ) { - isf32 += 1; - re1 = realf( start ); - im1 = imagf( start ); - } else { - re1 = real( start ); - im1 = imag( start ); - } - if ( dt2 === 'float64' ) { - re2 = stop; - im2 = 0.0; - } else if ( dt2 === 'complex64' ) { - isf32 += 1; - re2 = realf( stop ); - im2 = imagf( stop ); - } else { - re2 = real( stop ); - im2 = imag( stop ); - } - // Determine which complex number constructor to use according to type promotion rules: - if ( isf32 === 2 ) { - cmplx = Complex64; - } else { - cmplx = Complex128; - } - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - return [ new cmplx( re2, im2 ) ]; - } - return [ new cmplx( re1, im1 ) ]; - } - arr = [ new cmplx( re1, im1 ) ]; - - // Calculate the increments: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - dr = ( re2-re1 ) / N; - di = ( im2-im1 ) / N; - - // Generate linearly spaced values: - for ( i = 1; i < N; i++ ) { - re = re1 + (dr*i); - im = im1 + (di*i); - arr.push( new cmplx( re, im ) ); - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - arr.push( new cmplx( re2, im2 ) ); - } - return arr; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/linspace/lib/generic_real.js b/linspace/lib/generic_real.js deleted file mode 100644 index dcebef373..000000000 --- a/linspace/lib/generic_real.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Generates a linearly spaced array over a specified interval. -* -* @private -* @param {number} start - start of interval -* @param {number} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {Array} linearly spaced array -* -* @example -* var arr = linspace( 0, 100, 6, true ); -* // returns [ 0, 20, 40, 60, 80, 100 ] -* -* @example -* var arr = linspace( 0, 100, 5, false ); -* // returns [ 0, 20, 40, 60, 80 ] -*/ -function linspace( start, stop, len, endpoint ) { - var arr; - var N; - var d; - var i; - - if ( len === 0 ) { - return []; - } - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - return [ stop ]; - } - return [ start ]; - } - arr = [ start ]; - - // Calculate the increment: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - d = ( stop-start ) / N; - - // Generate linearly spaced values: - for ( i = 1; i < N; i++ ) { - arr.push( start + (d*i) ); - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - arr.push( stop ); - } - return arr; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/linspace/lib/index.js b/linspace/lib/index.js deleted file mode 100644 index d233a13e8..000000000 --- a/linspace/lib/index.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Generate a linearly spaced array. -* -* @module @stdlib/array/linspace -* -* @example -* var linspace = require( '@stdlib/array/linspace' ); -* -* var arr = linspace( 0, 100, 6 ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] -* -* @example -* var linspace = require( '@stdlib/array/linspace' ); -* -* var arr = linspace( 0, 100, 5, { -* 'endpoint': false -* }); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var linspace = require( '@stdlib/array/linspace' ); -* -* var arr = new Float64Array( 6 ); -* var out = linspace.assign( 0, 100, out ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] -* -* var bool = ( arr === out ); -* // returns true -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var linspace = require( '@stdlib/array/linspace' ); -* -* var arr = new Float64Array( 5 ); -* var out = linspace.assign( 0, 100, out, { -* 'endpoint': false -* }); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ] -* -* var bool = ( arr === out ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/linspace/lib/main.js b/linspace/lib/main.js deleted file mode 100644 index 49568277c..000000000 --- a/linspace/lib/main.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 isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var dtype = require( '@stdlib/complex/dtype' ); -var ctors = require( './../../typed-float-ctors' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var DEFAULTS = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); -var genreal = require( './generic_real.js' ); -var gencmplx = require( './generic_complex.js' ); -var typedreal = require( './typed_real.js' ); -var typedcmplx = require( './typed_complex.js' ); -var validate = require( './validate.js' ); -var defaults = require( './defaults.json' ); - - -// VARIABLES // - -var DEFAULT_COMPLEX_DTYPE = DEFAULTS.get( 'dtypes.complex_floating_point' ); - - -// MAIN // - -/** -* Generates a linearly spaced array over a specified interval. -* -* @param {(number|ComplexLike)} start - start of interval -* @param {(number|ComplexLike)} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {Options} [options] - options -* @param {string} [options.dtype] - output array data type -* @param {boolean} [options.endpoint=true] - boolean indicating whether to include the `stop` value in the output array -* @throws {TypeError} first argument must be either a real or complex number -* @throws {TypeError} second argument must be either a real or complex number -* @throws {TypeError} third argument must be a nonnegative integer -* @throws {TypeError} last argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} the output array data type must be a complex number data type or "generic" when either `start` or `stop` is a complex number -* @throws {TypeError} the output array data type must be a real or complex floating-point number data type or "generic" -* @returns {(Array|TypedArray|ComplexArray)} linearly spaced array -* -* @example -* var arr = linspace( 0, 100, 6, { -* 'dtype': 'generic' -* }); -* // returns [ 0, 20, 40, 60, 80, 100 ] -*/ -function linspace( start, stop, len ) { - var opts; - var ctor; - var err; - var out; - var dt1; - var dt2; - var flg; - - if ( typeof start === 'object' ) { - dt1 = dtype( start ); - if ( dt1 === null ) { - if ( !isComplexLike( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); - } - dt1 = 'complex128'; - } - flg = true; - } else if ( !isNumber( start ) || isnan( start ) ) { - throw new TypeError( format( 'invalid argument. First argument must be either a real or complex number. Value: `%s`.', start ) ); - } else { - dt1 = 'float64'; - } - if ( typeof stop === 'object' ) { - dt2 = dtype( stop ); - if ( dt2 === null ) { - if ( !isComplexLike( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); - } - dt2 = 'complex128'; - } - flg = true; - } else if ( !isNumber( stop ) || isnan( stop ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a real or complex number. Value: `%s`.', stop ) ); - } else { - dt2 = 'float64'; - } - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%s`.', len ) ); - } - opts = { - 'endpoint': defaults.endpoint - }; - if ( dt1 === dt2 ) { - opts.dtype = dt1; // one of 'float64' || 'complex64' || 'complex128' - } else { - // If dtypes are different, then at least one is a complex number. According to type promotion rules, for all possible dtype permutations, the default output data type should be 'complex128'... - opts.dtype = DEFAULT_COMPLEX_DTYPE; - } - if ( arguments.length > 3 ) { - err = validate( opts, arguments[ 3 ] ); - if ( err ) { - throw err; - } - } - if ( opts.dtype === 'generic' ) { - if ( flg ) { - return gencmplx( dt1, start, dt2, stop, len, opts.endpoint ); - } - return genreal( start, stop, len, opts.endpoint ); - } - ctor = ctors( opts.dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid option. `%s` option must be a real or complex floating-point data type or "generic". Option: `%s`.', 'dtype', opts.dtype ) ); - } - out = new ctor( len ); - if ( opts.dtype === 'complex64' ) { - typedcmplx( reinterpret64( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len - return out; - } - if ( opts.dtype === 'complex128' ) { - typedcmplx( reinterpret128( out, 0 ), dt1, start, dt2, stop, len, opts.endpoint ); // eslint-disable-line max-len - return out; - } - if ( flg ) { - throw new TypeError( 'invalid arguments. If either of the first two arguments are complex numbers, the output array data type must be a complex number data type or "generic".' ); - } - return typedreal( out, start, stop, len, opts.endpoint ); -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/linspace/lib/typed_complex.js b/linspace/lib/typed_complex.js deleted file mode 100644 index 3dfaf84cb..000000000 --- a/linspace/lib/typed_complex.js +++ /dev/null @@ -1,119 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - - -// MAIN // - -/** -* Generates a linearly spaced complex number sequence over a specified interval and assigns the results to a provided output array strided view. -* -* @private -* @param {(Float32Array|Float64Array)} out - output array strided view -* @param {string} dt1 - start value data type -* @param {(number|ComplexLike)} start - start of interval -* @param {string} dt2 - stop value data type -* @param {(number|ComplexLike)} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {(Float32Array|Float64Array)} complex number array view -*/ -function linspace( out, dt1, start, dt2, stop, len, endpoint ) { - var re1; - var re2; - var im1; - var im2; - var dr; - var di; - var N; - var i; - var j; - - if ( len === 0 ) { - return out; - } - if ( dt1 === 'float64' ) { - re1 = start; - im1 = 0.0; - } else if ( dt1 === 'complex64' ) { - re1 = realf( start ); - im1 = imagf( start ); - } else { - re1 = real( start ); - im1 = imag( start ); - } - if ( dt2 === 'float64' ) { - re2 = stop; - im2 = 0.0; - } else if ( dt2 === 'complex64' ) { - re2 = realf( stop ); - im2 = imagf( stop ); - } else { - re2 = real( stop ); - im2 = imag( stop ); - } - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - out[ 0 ] = re2; - out[ 1 ] = im2; - } else { - out[ 0 ] = re1; - out[ 1 ] = im1; - } - return out; - } - out[ 0 ] = re1; - out[ 1 ] = im1; - - // Calculate the increments: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - dr = ( re2-re1 ) / N; - di = ( im2-im1 ) / N; - - // Generate linearly spaced complex numbers: - j = 2; - for ( i = 1; i < N; i++ ) { - out[ j ] = re1 + (dr*i); - out[ j+1 ] = im1 + (di*i); - j += 2; - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - out[ j ] = re2; - out[ j+1 ] = im2; - } - return out; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/linspace/lib/typed_real.js b/linspace/lib/typed_real.js deleted file mode 100644 index 8acf2da33..000000000 --- a/linspace/lib/typed_real.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Generates a linearly spaced sequence over a specified interval and assigns the results to a provided output array. -* -* @private -* @param {TypedArray} out - output array -* @param {number} start - start of interval -* @param {number} stop - end of interval -* @param {NonNegativeInteger} len - length of output array -* @param {boolean} endpoint - boolean indicating whether to include `stop` in the output array -* @returns {TypedArray} linearly spaced array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var out = new Float64Array( 6 ); -* var arr = linspace( out, 0, 100, out.length, true ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0, 100.0 ] -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var out = new Float64Array( 5 ); -* var arr = linspace( out, 0, 100, out.length, false ); -* // returns [ 0.0, 20.0, 40.0, 60.0, 80.0 ] -*/ -function linspace( out, start, stop, len, endpoint ) { - var N; - var d; - var i; - - if ( len === 0 ) { - return out; - } - // Set the first value: - if ( len === 1 ) { - if ( endpoint ) { - out[ 0 ] = stop; - } else { - out[ 0 ] = start; - } - return out; - } - out[ 0 ] = start; - - // Calculate the increment: - if ( endpoint ) { - N = len - 1; - } else { - N = len; - } - d = ( stop-start ) / N; - - // Generate linearly spaced values: - for ( i = 1; i < N; i++ ) { - out[ i ] = start + (d*i); - } - // Check whether to include the `stop` value in the output array: - if ( endpoint ) { - out[ N ] = stop; - } - return out; -} - - -// EXPORTS // - -module.exports = linspace; diff --git a/linspace/lib/validate.js b/linspace/lib/validate.js deleted file mode 100644 index f048eccc7..000000000 --- a/linspace/lib/validate.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert/is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.dtype] - output array data type -* @param {boolean} [options.endpoint] - boolean indicating whether the `stop` value in the output array -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'endpoint': true -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'dtype' ) ) { - opts.dtype = options.dtype; - if ( !isString( opts.dtype ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'dtype', opts.dtype ) ); - } - } - if ( hasOwnProp( options, 'endpoint' ) ) { - opts.endpoint = options.endpoint; - if ( !isBoolean( opts.endpoint ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'endpoint', opts.endpoint ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/linspace/package.json b/linspace/package.json deleted file mode 100644 index 89f3d9f6c..000000000 --- a/linspace/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/linspace", - "version": "0.0.0", - "description": "Generate a linearly spaced array over a specified interval.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdmath", - "utilities", - "utils", - "mathematics", - "math", - "generic", - "array", - "matlab", - "linear", - "linspace" - ] -} diff --git a/linspace/test/fixtures/complex_strided.js b/linspace/test/fixtures/complex_strided.js deleted file mode 100644 index 3cd07ebbf..000000000 --- a/linspace/test/fixtures/complex_strided.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); - - -// MAIN // - -/** -* Converts an array of complex number objects to a interleaved strided array. -* -* @private -* @param {Array} arr - input array -* @returns {Array} output array -*/ -function toStrided( arr ) { - var out; - var z; - var i; - - out = []; - for ( i = 0; i < arr.length; i++ ) { - z = arr[ i ]; - if ( isComplex64( z ) ) { - out.push( realf( z ), imagf( z ) ); - } else { - out.push( real( z ), imag( z ) ); - } - } - return out; -} - - -// EXPORTS // - -module.exports = toStrided; diff --git a/linspace/test/test.assign.js b/linspace/test/test.assign.js deleted file mode 100644 index 42be670b3..000000000 --- a/linspace/test/test.assign.js +++ /dev/null @@ -1,3533 +0,0 @@ -/* eslint-disable max-lines, max-len */ - -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var everyBy = require( '@stdlib/utils/every-by' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var zeros = require( './../../base/zeros' ); -var toStrided = require( './fixtures/complex_strided.js' ); -var linspace = require( './../lib/assign.js' ); - - -// FUNCTIONS // - -/** -* Returns an array-like object which uses accessors. -* -* @private -* @param {NonNegativeInteger} len - array length -* @returns {ArrayLikeObject} array-like object -*/ -function AccessorArray( len ) { - var self = this; - this.data = zeros( len ); - this.length = len; - this.set = setter; - this.get = getter; - return this; - - function setter( value, idx ) { - self.data[ idx ] = value; - } - - function getter( idx ) { - return self.data[ idx ]; - } -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof linspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a real or complex number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( value, 10, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if the first argument is not a real or complex number (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( value, 10, new Float64Array( 10 ), {} ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a real or complex number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, value, new Float64Array( 10 ) ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a real or complex number (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, value, new Float64Array( 10 ), {} ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not an array-like object (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if the fourth argument is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid option', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, new Float64Array( 10 ), { - 'endpoint': value - }); - }; - } -}); - -tape( 'the function throws an error if provided one or more complex number arguments and the data type of the output array is not a complex number data type or "generic"', function test( t ) { - var values; - var x1; - var x2; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - values = [ - new Float64Array( 10 ), - new Float32Array( 10 ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( x1, x2, value ); - }; - } -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (dtype=float64)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new Float64Array( 0 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float64Array( out.length ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (dtype=float32)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new Float32Array( 0 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float32Array( out.length ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - - out = new Complex128Array( 0 ); - actual = linspace( 0, 10, out ); - expected = new Float64Array( out.length*2 ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - - out = new Complex64Array( 0 ); - actual = linspace( 0, 10, out ); - expected = new Float32Array( out.length*2 ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - - out = zeros( 0 ); - actual = linspace( 0, 10, out ); - expected = []; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (complex; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 0 ); - actual = linspace( x1, x2, out ); - expected = []; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns the output array unchanged (accessor array)', function test( t ) { - var expected; - var actual; - var out; - - out = new AccessorArray( 0 ); - actual = linspace( 0, 10, out ); - expected = zeros( out.length ); - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64)', function test( t ) { - var expected; - var actual; - var out; - - out = new Float64Array( 1 ); - actual = linspace( 0, 10, out ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32)', function test( t ) { - var expected; - var actual; - var out; - - out = new Float32Array( 1 ); - actual = linspace( 0, 10, out ); - expected = new Float32Array( [ 10.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - - out = new Complex128Array( 1 ); - actual = linspace( 0, 10, out ); - expected = new Float64Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - - out = new Complex64Array( 1 ); - actual = linspace( 0, 10, out ); - expected = new Float32Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - - out = zeros( 1 ); - actual = linspace( 0, 10, out ); - expected = [ 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - out = zeros( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = zeros( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; accessor array)', function test( t ) { - var expected; - var actual; - var out; - - out = new AccessorArray( 1 ); - actual = linspace( 0, 10, out ); - expected = [ 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new Float64Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new Float32Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float32Array( [ 10.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new Complex128Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float64Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new Complex64Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float32Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = zeros( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = [ 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - opts = { - 'endpoint': true - }; - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - opts = { - 'endpoint': true - }; - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; accessor array; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': true - }; - out = new AccessorArray( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = [ 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex; accessor array; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new Float64Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float64Array( [ 0.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new Float32Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float32Array( [ 0.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new Complex128Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new Complex64Array( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = new Float32Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = zeros( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = [ 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = zeros( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - - opts = { - 'endpoint': false - }; - out = new AccessorArray( 1 ); - actual = linspace( 0, 10, out, opts ); - expected = [ 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex64( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - out = new AccessorArray( 1 ); - actual = linspace( x1, x2, out, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( isComplex128( actual.data[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = 0.0; - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = new Float64Array( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ x1, 5.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, 5.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ x1, 2.0, 4.0, 6.0, 8.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, 8.0, 6.0, 4.0, 2.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x2, x2, out, opts ); - expected = new Float64Array( [ x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=float64)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - opts = { - 'dtype': 'float64' - }; - - out = new Float64Array( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ x1, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 6 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 6 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 6 ); - actual = linspace( x2, x2, out, opts ); - expected = new Float64Array( [ x2, x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - out = new Float64Array( 5 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=float32)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - out = new Float32Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ x1, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float32Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ x2, x1 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float32Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float32Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float32Array( 6 ); - actual = linspace( x2, x2, out ); - expected = new Float32Array( [ x2, x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = new Float32Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - out = new Float32Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - out = zeros( 2 ); - actual = linspace( x1, x2, out ); - expected =[ x1, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out ); - expected =[ x2, x1 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out ); - expected =[ x1, -3.0, -1.0, 1.0, 3.0, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out ); - expected =[ x2, 3.0, 1.0, -1.0, -3.0, x1 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x2, out ); - expected =[ x2, x2, x2, x2, x2, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = 0.0; - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = zeros( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = [ x1, 5.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 5.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = [ x1, 2.0, 4.0, 6.0, 8.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 8.0, 6.0, 4.0, 2.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x2, out, opts ); - expected = [ x2, x2, x2, x2, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out ); - expected =[ x1, x2 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out ); - expected =[ x2, x1 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out ); - expected =[ x1, -3.0, -1.0, 1.0, 3.0, x2 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out ); - expected =[ x2, 3.0, 1.0, -1.0, -3.0, x1 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x2, out ); - expected =[ x2, x2, x2, x2, x2, x2 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual.data[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual.data[ actual.length-1 ], x2, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual.data[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual.data[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = 0.0; - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = [ x1, 5.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 5.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = [ x1, 2.0, 4.0, 6.0, 8.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 8.0, 6.0, 4.0, 2.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x2, out, opts ); - expected = [ x2, x2, x2, x2, x2 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( actual.data, expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual.data[ 0 ], x1, 'returns expected value' ); - t.notEqual( actual.data[ actual.length-1 ], x2, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( actual.data[ 0 ], x2, 'returns expected value' ); - t.notEqual( actual.data[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), 5.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, 0.0, 5.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float64Array( [ x2, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ x2, 0.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), x2, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ x2, 0.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - out = zeros( 2 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), x2, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out ); - expected = [ x2, 0.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out ); - expected = [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = zeros( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = [ realf( x1 ), imagf( x1 ), 5.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 0.0, 5.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = [ realf( x1 ), imagf( x1 ), 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), x2, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out ); - expected = [ x2, 0.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out ); - expected = [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; accessor array; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = [ realf( x1 ), imagf( x1 ), 5.0, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 0.0, 5.0, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = [ realf( x1 ), imagf( x1 ), 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = [ x2, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ x1, 0.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ x1, 0.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), x1, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - out = zeros( 2 ); - actual = linspace( x1, x2, out ); - expected = [ x1, 0.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), x1, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out ); - expected = [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out ); - expected = [ x1, 0.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), x1, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out ); - expected = [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var out; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 10.0, 10.0 ); - - opts = { - 'endpoint': false - }; - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), 5.0, 5.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 5.0, 5.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), 2.0, 2.0, 4.0, 4.0, 6.0, 6.0, 8.0, 8.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 8.0, 8.0, 6.0, 6.0, 4.0, 4.0, 2.0, 2.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - out = zeros( 2 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; accessor array)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=generic)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - out = zeros( 2 ); - actual = linspace( x1, x2, out ); - expected = [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 2 ); - actual = linspace( x2, x1, out ); - expected = [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x1, x2, out ); - expected = [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 6 ); - actual = linspace( x2, x1, out ); - expected = [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = zeros( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; accessor arrays)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - out = new AccessorArray( 2 ); - actual = linspace( x1, x2, out ); - expected = [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 2 ); - actual = linspace( x2, x1, out ); - expected = [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x1, x2, out ); - expected = [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 6 ); - actual = linspace( x2, x1, out ); - expected = [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ]; - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual.data ), expected, 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = new AccessorArray( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isArrayLikeObject( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.strictEqual( everyBy( actual.data, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual.data ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex-like; dtype=complex64)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = { - 're': -5.0, - 'im': -5.0 - }; - x2 = { - 're': 5.0, - 'im': 5.0 - }; - - out = new Complex64Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = new Complex64Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex-like; dtype=complex128)', function test( t ) { - var expected; - var actual; - var out; - var x1; - var x2; - - x1 = { - 're': -5.0, - 'im': -5.0 - }; - x2 = { - 're': 5.0, - 'im': 5.0 - }; - - out = new Complex128Array( 2 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 2 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x1, x2, out ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 6 ); - actual = linspace( x2, x1, out ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x1, x2, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - out = new Complex128Array( 5 ); - actual = linspace( x2, x1, out ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual, out, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); diff --git a/linspace/test/test.js b/linspace/test/test.js deleted file mode 100644 index d083066c8..000000000 --- a/linspace/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 linspace = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof linspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof linspace.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/linspace/test/test.main.js b/linspace/test/test.main.js deleted file mode 100644 index b7c4f16ba..000000000 --- a/linspace/test/test.main.js +++ /dev/null @@ -1,3267 +0,0 @@ -/* eslint-disable max-lines, max-len */ - -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var isComplex128 = require( '@stdlib/assert/is-complex128' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var isFloat32Array = require( '@stdlib/assert/is-float32array' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var everyBy = require( '@stdlib/utils/every-by' ); -var naryFunction = require( '@stdlib/utils/nary-function' ); -var toStrided = require( './fixtures/complex_strided.js' ); -var linspace = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof linspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a real or complex number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( value, 10, 10 ); - }; - } -}); - -tape( 'the function throws an error if the first argument is not a real or complex number (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( value, 10, 10, {} ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a real or complex number', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, value, 10 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a real or complex number (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - false, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, value, 10, {} ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, value ); - }; - } -}); - -tape( 'the function throws an error if the third argument is not a nonnegative integer (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, value, {} ); - }; - } -}); - -tape( 'the function throws an error if the fourth argument is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid option', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, 10, { - 'endpoint': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized/unsupported data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'foo', - 'bar', - 'beep', - 'boop', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( 0, 10, 10, { - 'dtype': value - }); - }; - } -}); - -tape( 'the function throws an error if provided one or more complex number arguments and the output data type is not a complex number data type or "generic"', function test( t ) { - var values; - var x1; - var x2; - var i; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - values = [ - 'float64', - 'float32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - linspace( x1, x2, 10, { - 'dtype': value - }); - }; - } -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (default; real)', function test( t ) { - var expected; - var actual; - - actual = linspace( 0, 10, 0 ); - expected = new Float64Array( [] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (default; mixed)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = 0.0; - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 0 ); - expected = new Float64Array( [] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 0 ); - expected = new Float64Array( [] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (default; complex)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 0 ); - expected = new Float64Array( [] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (default; complex64)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 0 ); - expected = new Float32Array( [] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (default; complex-like)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - actual = linspace( x1, x2, 0 ); - expected = new Float64Array( [] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (dtype=float64)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float64', - 'endpoint': false - }; - actual = linspace( 0, 10, 0, opts ); - expected = new Float64Array( [] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (dtype=float32)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float32', - 'endpoint': true - }; - actual = linspace( 0, 10, 0, opts ); - expected = new Float32Array( [] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex128' - }; - actual = linspace( 0, 10, 0, opts ); - expected = new Float64Array( [] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex64' - }; - actual = linspace( 0, 10, 0, opts ); - expected = new Float32Array( [] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'generic' - }; - actual = linspace( 0, 10, 0, opts ); - expected = []; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `0`, the function returns an empty array (complex; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 0, opts ); - expected = []; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; real)', function test( t ) { - var expected; - var actual; - - actual = linspace( 0, 10, 1 ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; mixed)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = 0.0; - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1 ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 1 ); - expected = new Float64Array( [ 100.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1 ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex64)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1 ); - expected = new Float32Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex-like)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - actual = linspace( x1, x2, 1 ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float64' - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float32' - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 10.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex128' - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex64' - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'generic' - }; - actual = linspace( 0, 10, 1, opts ); - expected = [ 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - opts = { - 'dtype': 'generic' - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; real; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'endpoint': true - }; - - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; mixed; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = 0.0; - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 100.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex64; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float32Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex-like; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': true - }; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 100.0, 10.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float64', - 'endpoint': true - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 10.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float32', - 'endpoint': true - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 10.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex128', - 'endpoint': true - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex64', - 'endpoint': true - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 10.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - actual = linspace( 0, 10, 1, opts ); - expected = [ 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 10.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=true)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': true - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 1, opts ); - expected = [ 100.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; real; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'endpoint': false - }; - - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 0.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; mixed; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = 0.0; - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - x1 = new Complex128( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex64; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = new Float32Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (default; complex-like; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'endpoint': false - }; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - actual = linspace( x1, x2, 1, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float64; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float64', - 'endpoint': false - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 0.0 ] ); - - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=float32; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'float32', - 'endpoint': false - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 0.0 ] ); - - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex128; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex128', - 'endpoint': false - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float64Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (dtype=complex64; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'complex64', - 'endpoint': false - }; - actual = linspace( 0, 10, 1, opts ); - expected = new Float32Array( [ 0.0, 0.0 ] ); - - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (real; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - actual = linspace( 0, 10, 1, opts ); - expected = [ 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex64; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex64( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex128; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - x1 = new Complex128( 0.0, 0.0 ); - x2 = new Complex128( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (complex-like; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - x1 = { - 're': 0.0, - 'im': 0.0 - }; - x2 = { - 're': 100.0, - 'im': 10.0 - }; - - actual = linspace( x1, x2, 1, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - x1 = 0.0; - x2 = new Complex64( 100.0, 10.0 ); - - actual = linspace( x1, x2, 1, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if the specified output array length is `1`, the function returns an array containing a single element (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 100.0; - - actual = linspace( x1, x2, 1, opts ); - expected = [ 0.0, 0.0 ]; - - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( isComplex128( actual[ 0 ] ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; real)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - actual = linspace( x1, x2, 2 ); - expected = new Float64Array( [ x1, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float64Array( [ x2, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float64Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float64Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 6 ); - expected = new Float64Array( [ x2, x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; real; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = 0.0; - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ x1, 5.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ x2, 5.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - expected = new Float64Array( [ x1, 2.0, 4.0, 6.0, 8.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - expected = new Float64Array( [ x2, 8.0, 6.0, 4.0, 2.0 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 5, opts ); - expected = new Float64Array( [ x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=float64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - opts = { - 'dtype': 'float64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ x1, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ x2, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 6, opts ); - expected = new Float64Array( [ x2, x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=float32)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - opts = { - 'dtype': 'float32' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ x1, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ x2, x1 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ x1, -3.0, -1.0, 1.0, 3.0, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ x2, 3.0, 1.0, -1.0, -3.0, x1 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 6, opts ); - expected = new Float32Array( [ x2, x2, x2, x2, x2, x2 ] ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isFloat32Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = 5.0; - - opts = { - 'dtype': 'generic' - }; - - actual = linspace( x1, x2, 2, opts ); - expected =[ x1, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected =[ x2, x1 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected =[ x1, -3.0, -1.0, 1.0, 3.0, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected =[ x2, 3.0, 1.0, -1.0, -3.0, x1 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 6, opts ); - expected =[ x2, x2, x2, x2, x2, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (real; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = 0.0; - x2 = 10.0; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ x1, 5.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ x2, 5.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - expected = [ x1, 2.0, 4.0, 6.0, 8.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - expected = [ x2, 8.0, 6.0, 4.0, 2.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x2, x2, 5, opts ); - expected = [ x2, x2, x2, x2, x2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x2, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], x1, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; mixed)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - actual = linspace( x1, x2, 2 ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float64Array( [ x2, 0.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float64Array( [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; mixed; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 10.0; - - opts = { - 'endpoint': false - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), 5.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ x2, 0.0, 5.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - expected = new Float64Array( [ x2, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - opts = { - 'dtype': 'complex128' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ x2, 0.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - opts = { - 'dtype': 'complex64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), x2, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ x2, 0.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = 5.0; - - opts = { - 'dtype': 'generic' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ realf( x1 ), imagf( x1 ), x2, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ x2, 0.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -4.0, -1.0, -3.0, 1.0, -2.0, 3.0, -1.0, x2, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = [ x2, 0.0, 3.0, -1.0, 1.0, -2.0, -1.0, -3.0, -3.0, -4.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = 10.0; - - opts = { - 'dtype': 'generic', - 'endpoint': false - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ realf( x1 ), imagf( x1 ), 5.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ x2, 0.0, 5.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - expected = [ realf( x1 ), imagf( x1 ), 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - expected = [ x2, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], x2, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x2, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; mixed)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - actual = linspace( x1, x2, 2 ); - expected = new Float64Array( [ x1, 0.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float64Array( [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex128' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ x1, 0.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ x1, 0.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), x1, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (mixed; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = -5.0; - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'generic' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ x1, 0.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ realf( x2 ), imagf( x2 ), x1, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = [ x1, 0.0, -3.0, 1.0, -1.0, 2.0, 1.0, 3.0, 3.0, 4.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 4.0, 1.0, 3.0, -1.0, 2.0, -3.0, 1.0, x1, 0.0 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], x1, 'returns expected value' ); - t.strictEqual( actual[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], x1, 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; complex; endpoint=false)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( 0.0, 0.0 ); - x2 = new Complex64( 10.0, 10.0 ); - - opts = { - 'endpoint': false - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), 5.0, 5.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 5.0, 5.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), 2.0, 2.0, 4.0, 4.0, 6.0, 6.0, 8.0, 8.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 8.0, 8.0, 6.0, 6.0, 4.0, 4.0, 2.0, 2.0 ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.notEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; complex64)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - actual = linspace( x1, x2, 2 ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex128' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex64; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex64( -5.0, -5.0 ); - x2 = new Complex64( 5.0, 5.0 ); - - opts = { - 'dtype': 'generic' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ realf( x1 ), imagf( x1 ), realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ realf( x2 ), imagf( x2 ), realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = [ realf( x1 ), imagf( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, realf( x2 ), imagf( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = [ realf( x2 ), imagf( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, realf( x1 ), imagf( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex64, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], realf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imagf( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], realf( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imagf( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; complex128)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - actual = linspace( x1, x2, 2 ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - opts = { - 'dtype': 'complex128' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex128; dtype=generic)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = new Complex128( -5.0, -5.0 ); - x2 = new Complex128( 5.0, 5.0 ); - - opts = { - 'dtype': 'generic' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - t.deepEqual( toStrided( actual ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - t.strictEqual( everyBy( actual, naryFunction( isComplex128, 1 ) ), true, 'returns expected value' ); - - actual = toStrided( actual ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (default; complex-like)', function test( t ) { - var expected; - var actual; - var x1; - var x2; - - x1 = { - 're': -5.0, - 'im': -5.0 - }; - x2 = { - 're': 5.0, - 'im': 5.0 - }; - - actual = linspace( x1, x2, 2 ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2 ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6 ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6 ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5 ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex-like; dtype=complex64)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = { - 're': -5.0, - 'im': -5.0 - }; - x2 = { - 're': 5.0, - 'im': 5.0 - }; - - opts = { - 'dtype': 'complex64' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float32Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float32Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret64( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex64Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret64( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a linearly spaced array (complex-like; dtype=complex128)', function test( t ) { - var expected; - var actual; - var opts; - var x1; - var x2; - - x1 = { - 're': -5.0, - 'im': -5.0 - }; - x2 = { - 're': 5.0, - 'im': 5.0 - }; - - opts = { - 'dtype': 'complex128' - }; - - actual = linspace( x1, x2, 2, opts ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 2, opts ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 2, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 6, opts ); - expected = new Float64Array( [ real( x1 ), imag( x1 ), -3.0, -3.0, -1.0, -1.0, 1.0, 1.0, 3.0, 3.0, real( x2 ), imag( x2 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x2, x1, 6, opts ); - expected = new Float64Array( [ real( x2 ), imag( x2 ), 3.0, 3.0, 1.0, 1.0, -1.0, -1.0, -3.0, -3.0, real( x1 ), imag( x1 ) ] ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 6, 'returns expected value' ); - t.deepEqual( reinterpret128( actual, 0 ), expected, 'returns expected value' ); - - actual = linspace( x1, x2, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x2 ), 'returns expected value' ); - - actual = linspace( x2, x1, 5, opts ); - t.strictEqual( isComplex128Array( actual ), true, 'returns expected value' ); - t.strictEqual( actual.length, 5, 'returns expected value' ); - - actual = reinterpret128( actual, 0 ); - t.strictEqual( actual[ 0 ], real( x2 ), 'returns expected value' ); - t.strictEqual( actual[ 1 ], imag( x2 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-2 ], real( x1 ), 'returns expected value' ); - t.strictEqual( actual[ actual.length-1 ], imag( x1 ), 'returns expected value' ); - - t.end(); -}); diff --git a/linspace/test/test.validate.js b/linspace/test/test.validate.js deleted file mode 100644 index 572ce5f93..000000000 --- a/linspace/test/test.validate.js +++ /dev/null @@ -1,154 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if not provided an options object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[i] ); - t.equal( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `dtype` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'dtype': values[i] - }); - t.equal( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided an `endpoint` option which is not a string', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'endpoint': values[i] - }); - t.equal( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns `null` if all options are valid', function test( t ) { - var expected; - var options; - var opts; - var err; - - options = { - 'dtype': 'float64', - 'endpoint': false - }; - opts = {}; - - expected = { - 'dtype': 'float64', - 'endpoint': false - }; - - err = validate( opts, options ); - - t.equal( err, null, 'returns expected value' ); - t.deepEqual( opts, expected, 'extracts options' ); - - t.end(); -}); - -tape( 'the function ignores unrecognized options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': 'boop', - 'foo': 5, - 'bar': {} - }; - - opts = {}; - - err = validate( opts, options ); - - t.equal( err, null, 'returns expected value' ); - t.deepEqual( opts, {}, 'ignores unrecognized options' ); - - t.end(); -}); diff --git a/little-endian-factory/README.md b/little-endian-factory/README.md deleted file mode 100644 index 954928b38..000000000 --- a/little-endian-factory/README.md +++ /dev/null @@ -1,498 +0,0 @@ - - -# littleEndianFactory - -> Return a typed array constructor for creating typed arrays stored in little-endian byte order. - - - -
- -In contrast to the built-in typed array constructors which store values according to the host platform byte order, the typed array constructors returned by the factory function always access elements in little-endian byte order. Such enforcement can be particularly advantageous when working with memory buffers which do not necessarily follow host platform byte order, such as [WebAssembly memory][@stdlib/wasm/memory]. - -
- - - - - -
- -## Usage - -```javascript -var littleEndianFactory = require( '@stdlib/array/little-endian-factory' ); -``` - -#### littleEndianFactory( dtype ) - -Returns a typed array constructor for creating typed arrays having a specified [data type][@stdlib/array/typed-dtypes] and stored in little-endian byte order. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); -// returns - -var Float32ArrayLE = littleEndianFactory( 'float32' ); -// returns -``` - -* * * - -### Typed Array Constructor - -#### TypedArrayLE() - -A typed array constructor which returns a typed array representing an array of values in little-endian byte order. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE(); -// returns -``` - -#### TypedArrayLE( length ) - -Returns a typed array having a specified length. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( 5 ); -// returns -``` - -#### TypedArrayLE( typedarray ) - -Creates a typed array from another typed array. - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr1 = new Float32Array( [ 0.5, 0.5, 0.5 ] ); -var arr2 = new Float64ArrayLE( arr1 ); -// returns - -var v = arr2.get( 0 ); -// returns 0.5 -``` - -#### TypedArrayLE( obj ) - -Creates a typed array from an array-like object or iterable. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( [ 0.5, 0.5, 0.5 ] ); -// returns - -var v = arr.get( 0 ); -// returns 0.5 -``` - -#### TypedArrayLE( buffer\[, byteOffset\[, length]] ) - -Returns a typed array view of an [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var buf = new ArrayBuffer( 32 ); -var arr = new Float64ArrayLE( buf, 0, 4 ); -// returns -``` - -* * * - -### Typed Array Properties - - - -#### TypedArrayLE.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var nbytes = Float64ArrayLE.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### TypedArrayLE.name - -Typed array constructor name. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var str = Float64ArrayLE.name; -// returns 'Float64ArrayLE' -``` - - - -#### TypedArrayLE.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the typed array. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### TypedArrayLE.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the typed array. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( 5 ); -var byteLength = arr.byteLength; -// returns 40 -``` - - - -#### TypedArrayLE.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the typed array from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### TypedArrayLE.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### TypedArrayLE.prototype.length - -**Read-only** property which returns the number of view elements. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Typed Array Methods - - - -#### TypedArrayLE.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like object or an iterable. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = Float64ArrayLE.from( [ 1.0, -1.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2.0; -} - -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = Float64ArrayLE.from( [ 1.0, -1.0 ], mapFcn ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 -``` - -A callback function is provided two arguments: - -- **value**: source value. -- **index**: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2.0; -} - -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var ctx = { - 'count': 0 -}; - -var arr = Float64ArrayLE.from( [ 1.0, -1.0 ], mapFcn, ctx ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 - -var n = ctx.count; -// returns 2 -``` - - - -#### TypedArrayLE.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = Float64ArrayLE.of( 1.0, -1.0 ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - - - -#### TypedArrayLE.prototype.get( i ) - -Returns an array element located at a nonnegative integer position (index) `i`. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( 10 ); - -// Set the first element: -arr.set( 1.0, 0 ); - -// Get the first element: -var v = arr.get( 0 ); -// returns 1.0 -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( 10 ); - -var v = arr.get( 100 ); -// returns undefined -``` - - - -#### TypedArrayLE.prototype.set( arr\[, offset] ) - -Sets array elements. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( [ 1.0, 2.0, 3.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 - -v = arr.get( 1 ); -// returns 2.0 - -// Set the first two array elements: -arr.set( [ 4.0, 5.0 ] ); - -v = arr.get( 0 ); -// returns 4.0 - -v = arr.get( 1 ); -// returns 5.0 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( [ 1.0, 2.0, 3.0 ] ); -// returns - -// Set the last two array elements: -arr.set( [ 4.0, 5.0 ], 1 ); - -var v = arr.get( 1 ); -// returns 4.0 - -v = arr.get( 2 ); -// returns 5.0 -``` - -A few notes: - -- If `i` is out-of-bounds, the method throws an error. -- If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error. -- If provided a typed array which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range. - - - -#### TypedArrayLE.prototype.toString() - -Serializes an array as a string. - -```javascript -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -var arr = new Float64ArrayLE( [ 1.0, 2.0, 3.0 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - -
- - - - - -
- -* * * - -## Notes - -- While returned constructors _strive_ to maintain (but do not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: - - - Constructors **not** require the `new` operator. - - Accessing array elements using bracket syntax (e.g., `X[i]`) is **not** supported. Instead, one **must** use the `.get()` method. - -
- - - - - -
- -* * * - -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var logEach = require( '@stdlib/console/log-each' ); -var littleEndianFactory = require( '@stdlib/array/little-endian-factory' ); - -var Float64ArrayLE = littleEndianFactory( 'float64' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayLE( 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayLE( arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer, 8, 2 ); -logEach( '%s', out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/little-endian-factory/benchmark/benchmark.from.js b/little-endian-factory/benchmark/benchmark.from.js deleted file mode 100644 index 36f98f53d..000000000 --- a/little-endian-factory/benchmark/benchmark.from.js +++ /dev/null @@ -1,311 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return v * 2.0; - } -}); diff --git a/little-endian-factory/benchmark/benchmark.get.js b/little-endian-factory/benchmark/benchmark.get.js deleted file mode 100644 index 7ceb453c9..000000000 --- a/little-endian-factory/benchmark/benchmark.get.js +++ /dev/null @@ -1,62 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayLE( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-factory/benchmark/benchmark.instantiation.js b/little-endian-factory/benchmark/benchmark.instantiation.js deleted file mode 100644 index dd3f342ef..000000000 --- a/little-endian-factory/benchmark/benchmark.instantiation.js +++ /dev/null @@ -1,253 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var ArrayBuffer = require( './../../buffer' ); -var Float64Array = require( './../../float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Returns an "iterable" object. -* -* @private -* @returns {Object} iterable object -*/ -function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } -} - - -// MAIN // - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float64ArrayLE; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-factory/benchmark/benchmark.js b/little-endian-factory/benchmark/benchmark.js deleted file mode 100644 index 619c1f968..000000000 --- a/little-endian-factory/benchmark/benchmark.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = factory( 'float64' ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-factory/benchmark/benchmark.of.js b/little-endian-factory/benchmark/benchmark.of.js deleted file mode 100644 index 538e39a01..000000000 --- a/little-endian-factory/benchmark/benchmark.of.js +++ /dev/null @@ -1,74 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of.apply( Float64ArrayLE, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-factory/benchmark/benchmark.property_access.js b/little-endian-factory/benchmark/benchmark.property_access.js deleted file mode 100644 index c0fea37c8..000000000 --- a/little-endian-factory/benchmark/benchmark.property_access.js +++ /dev/null @@ -1,127 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-factory/benchmark/benchmark.set.js b/little-endian-factory/benchmark/benchmark.set.js deleted file mode 100644 index 3e6c9eca0..000000000 --- a/little-endian-factory/benchmark/benchmark.set.js +++ /dev/null @@ -1,124 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../float64' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+'::number:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float64ArrayLE( values ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-factory/benchmark/benchmark.set.length.js b/little-endian-factory/benchmark/benchmark.set.length.js deleted file mode 100644 index 33a1322b6..000000000 --- a/little-endian-factory/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,115 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randu = require( '@stdlib/random/array/randu' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - - arr1 = randu( len ); - arr2 = randu( len ); - arr3 = randu( len ); - arr1 = new Float64ArrayLE( arr1 ); - - values = [ - new Float64ArrayLE( arr2 ), - new Float64ArrayLE( arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/little-endian-factory/benchmark/benchmark.to_string.js b/little-endian-factory/benchmark/benchmark.to_string.js deleted file mode 100644 index dc823451c..000000000 --- a/little-endian-factory/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayLE( [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-factory/benchmark/benchmark.to_string.length.js b/little-endian-factory/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 8d799aada..000000000 --- a/little-endian-factory/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,99 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// VARIABLES // - -var Float64ArrayLE = factory( 'float64' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayLE( zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/little-endian-factory/examples/index.js b/little-endian-factory/examples/index.js deleted file mode 100644 index 77cd3bba6..000000000 --- a/little-endian-factory/examples/index.js +++ /dev/null @@ -1,44 +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. -*/ - -'use strict'; - -var Float64Array = require( './../../float64' ); -var logEach = require( '@stdlib/console/log-each' ); -var factory = require( './../lib' ); - -var Float64ArrayLE = factory( 'float64' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayLE( 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayLE( arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/little-endian-factory/lib/from_iterator.js b/little-endian-factory/lib/from_iterator.js deleted file mode 100644 index c1adb5d9a..000000000 --- a/little-endian-factory/lib/from_iterator.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/little-endian-factory/lib/from_iterator_map.js b/little-endian-factory/lib/from_iterator_map.js deleted file mode 100644 index 9a6e354eb..000000000 --- a/little-endian-factory/lib/from_iterator_map.js +++ /dev/null @@ -1,53 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @param {Function} clbk - callback to invoke for each iterated value -* @param {*} thisArg - invocation context -* @returns {Array} output array -*/ -function fromIteratorMap( it, clbk, thisArg ) { - var out; - var v; - var i; - - out = []; - i = -1; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - i += 1; - out.push( clbk.call( thisArg, v.value, i ) ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIteratorMap; diff --git a/little-endian-factory/lib/index.js b/little-endian-factory/lib/index.js deleted file mode 100644 index b01ede482..000000000 --- a/little-endian-factory/lib/index.js +++ /dev/null @@ -1,106 +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. -*/ - -'use strict'; - -/** -* Return a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @module @stdlib/array/little-endian-factory -* -* @example -* var factory = require( '@stdlib/array/little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var factory = require( '@stdlib/array/little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var factory = require( '@stdlib/array/little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var factory = require( '@stdlib/array/little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var factory = require( '@stdlib/array/little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var factory = require( '@stdlib/array/little-endian-factory' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/little-endian-factory/lib/main.js b/little-endian-factory/lib/main.js deleted file mode 100644 index 8f006f19d..000000000 --- a/little-endian-factory/lib/main.js +++ /dev/null @@ -1,359 +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. -*/ - -/* eslint-disable max-len, no-restricted-syntax, no-invalid-this */ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert/is-collection' ); -var isObject = require( '@stdlib/assert/is-object' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var getter = require( './../../base/getter' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var inherits = require( '@stdlib/utils/inherit' ); -var fixedEndianFactory = require( './../../fixed-endian-factory' ); -var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); -var capitalize = require( '@stdlib/string/base/capitalize' ); -var format = require( '@stdlib/string/format' ); -var fromIterator = require( './from_iterator.js' ); -var fromIteratorMap = require( './from_iterator_map.js' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var BYTE_ORDER = 'little-endian'; -var DTYPE2SET = { - 'float64': 'setFloat64', - 'float32': 'setFloat32', - 'int32': 'setInt32', - 'int16': 'setInt16', - 'uint32': 'setUint32', - 'uint16': 'setUint16' -}; -var CHAR2ARTICLE = { - 'c': 'a', - 'f': 'a', - 'i': 'an', - 'u': 'a', - 'b': 'a' -}; - - -// FUNCTIONS // - -/** -* Converts a data type string to a constructor name. -* -* @private -* @param {string} dtype - data type -* @returns {string} constructor name -* -* @example -* var n = dtype2ctor( 'float64' ); -* // returns 'Float64ArrayLE' -* -* @example -* var n = dtype2ctor( 'int32' ); -* // returns 'Int32ArrayLE' -*/ -function dtype2ctor( dtype ) { - return capitalize( dtype ) + 'ArrayLE'; -} - - -// MAIN // - -/** -* Returns a typed array constructor for creating typed arrays stored in little-endian byte order. -* -* @param {string} dtype - typed array data type -* @throws {TypeError} first argument must be a supported data type -* @returns {Function} typed array constructor -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float64ArrayLE = factory( 'float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var Float64ArrayLE = factory( 'float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -function factory( dtype ) { - var BYTES_PER_ELEMENT; - var CTOR_NAME; - var SETTER; - var parent; - - // Defer `dtype` validation to `fixedEndianFactory`: - parent = fixedEndianFactory( dtype ); - - BYTES_PER_ELEMENT = bytesPerElement( dtype ); - CTOR_NAME = dtype2ctor( dtype ); - SETTER = DTYPE2SET[ dtype ]; - - /** - * Typed array constructor which returns a typed array representing an array of values in little-endian byte order. - * - * @private - * @constructor - * @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable - * @param {NonNegativeInteger} [byteOffset=0] - byte offset - * @param {NonNegativeInteger} [length] - view length - * @throws {TypeError} if provided only one argument, the argument must be a valid argument - * @throws {TypeError} byte offset must be a nonnegative integer - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @returns {TypedArray} typed array instance - */ - function TypedArray() { - var nargs = arguments.length; - if ( !(this instanceof TypedArray) ) { - if ( nargs === 0 ) { - return new TypedArray(); - } - if ( nargs === 1 ) { - return new TypedArray( arguments[0] ); - } - if ( nargs === 2 ) { - return new TypedArray( arguments[0], arguments[1] ); - } - return new TypedArray( arguments[0], arguments[1], arguments[2] ); - } - if ( nargs === 0 ) { - parent.call( this, BYTE_ORDER ); - } else if ( nargs === 1 ) { - parent.call( this, BYTE_ORDER, arguments[0] ); - } else if ( nargs === 2 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1] ); - } else if ( nargs === 3 ) { - parent.call( this, BYTE_ORDER, arguments[0], arguments[1], arguments[2] ); - } - return this; - } - - /** - * Size (in bytes) of each array element. - * - * @private - * @name BYTES_PER_ELEMENT - * @memberof TypedArray - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( TypedArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - - /** - * Constructor name. - * - * @private - * @name name - * @memberof TypedArray - * @readonly - * @type {string} - */ - setReadOnly( TypedArray, 'name', CTOR_NAME ); - - /** - * Creates a new typed array from an array-like object or an iterable. - * - * @private - * @name from - * @memberof TypedArray - * @type {Function} - * @param {(Collection|Iterable)} src - array-like object or iterable - * @param {Function} [clbk] - callback to invoke for each source element - * @param {*} [thisArg] - context - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @throws {TypeError} first argument must be an array-like object or an iterable - * @throws {TypeError} second argument must be a function - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'from', function from( src ) { - var thisArg; - var nargs; - var clbk; - var out; - var buf; - var tmp; - var get; - var len; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - nargs = arguments.length; - if ( nargs > 1 ) { - clbk = arguments[ 1 ]; - if ( !isFunction( clbk ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) ); - } - if ( nargs > 2 ) { - thisArg = arguments[ 2 ]; - } - } - if ( isCollection( src ) ) { - if ( clbk ) { - len = src.length; - if ( src.get && src.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, clbk.call( thisArg, get( src, i ), i ), true ); - } - return out; - } - return new this( src ); - } - if ( isObject( src ) && HAS_ITERATOR_SYMBOL && isFunction( src[ ITERATOR_SYMBOL ] ) ) { - buf = src[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); - } - if ( clbk ) { - tmp = fromIteratorMap( buf, clbk, thisArg ); - } else { - tmp = fromIterator( buf ); - } - len = tmp.length; - out = new this( len ); - buf = out._buffer; // eslint-disable-line no-underscore-dangle - for ( i = 0; i < len; i++ ) { - buf[ SETTER ]( i*BYTES_PER_ELEMENT, tmp[ i ], true ); - } - return out; - } - throw new TypeError( format( 'invalid argument. First argument must be an array-like object or an iterable. Value: `%s`.', src ) ); - }); - - /** - * Creates a new typed array from a variable number of arguments. - * - * @private - * @name of - * @memberof TypedArray - * @type {Function} - * @param {...*} element - array elements - * @throws {TypeError} `this` context must be a constructor - * @throws {TypeError} `this` must be a typed array constructor - * @returns {TypedArray} typed array instance - */ - setReadOnly( TypedArray, 'of', function of() { - var args; - var i; - if ( !isFunction( this ) ) { - throw new TypeError( 'invalid invocation. `this` context must be a constructor.' ); - } - if ( !isTypedArrayConstructor( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not %s %s.', CHAR2ARTICLE[ dtype[0] ], CTOR_NAME ) ); - } - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return new this( args ); - }); - - // Inherit from the parent constructor: - inherits( TypedArray, parent ); - - return TypedArray; - - /** - * Returns a boolean indicating if a value is a typed array constructor. - * - * @private - * @param {*} value - value to test - * @returns {boolean} boolean indicating if a value is a typed array constructor - */ - function isTypedArrayConstructor( value ) { - return ( value === TypedArray ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/little-endian-factory/package.json b/little-endian-factory/package.json deleted file mode 100644 index 3e002c4cc..000000000 --- a/little-endian-factory/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/little-endian-factory", - "version": "0.0.0", - "description": "Return a typed array constructor for creating typed arrays stored in little-endian byte order.", - "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", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "factory", - "endian", - "little-endian", - "byte-order" - ] -} diff --git a/little-endian-factory/test/test.js b/little-endian-factory/test/test.js deleted file mode 100644 index 99d011d0b..000000000 --- a/little-endian-factory/test/test.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests diff --git a/little-endian-float32/README.md b/little-endian-float32/README.md deleted file mode 100644 index fe74781c3..000000000 --- a/little-endian-float32/README.md +++ /dev/null @@ -1,454 +0,0 @@ - - -# Float32ArrayLE - -> Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in little-endian byte order. - - - -
- -In contrast to the [`Float32Array`][@stdlib/array/float32] typed array constructor which stores values according to the host platform byte order, the `Float32ArrayLE` constructor always accesses elements in little-endian byte order. Such enforcement can be particularly advantageous when working with memory buffers which do not necessarily follow host platform byte order, such as [WebAssembly memory][@stdlib/wasm/memory]. - -
- - - - - -
- -## Usage - -```javascript -var Float32ArrayLE = require( '@stdlib/array/little-endian-float32' ); -``` - -#### Float32ArrayLE() - -A typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in little-endian byte order. - -```javascript -var arr = new Float32ArrayLE(); -// returns -``` - -#### Float32ArrayLE( length ) - -Returns a typed array having a specified length. - -```javascript -var arr = new Float32ArrayLE( 5 ); -// returns -``` - -#### Float32ArrayLE( typedarray ) - -Creates a typed array from another typed array. - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 0.5, 0.5, 0.5 ] ); -var arr2 = new Float32ArrayLE( arr1 ); -// returns - -var v = arr2.get( 0 ); -// returns 0.5 -``` - -#### Float32ArrayLE( obj ) - -Creates a typed array from an array-like object or iterable. - -```javascript -var arr = new Float32ArrayLE( [ 0.5, 0.5, 0.5 ] ); -// returns - -var v = arr.get( 0 ); -// returns 0.5 -``` - -#### Float32ArrayLE( buffer\[, byteOffset\[, length]] ) - -Returns a typed array view of an [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 32 ); -var arr = new Float32ArrayLE( buf, 0, 4 ); -// returns -``` - -* * * - -### Properties - - - -#### Float32ArrayLE.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var nbytes = Float32ArrayLE.BYTES_PER_ELEMENT; -// returns 4 -``` - - - -#### Float32ArrayLE.name - -Typed array constructor name. - -```javascript -var str = Float32ArrayLE.name; -// returns 'Float32ArrayLE' -``` - - - -#### Float32ArrayLE.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the typed array. - -```javascript -var arr = new Float32ArrayLE( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Float32ArrayLE.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the typed array. - -```javascript -var arr = new Float32ArrayLE( 5 ); -var byteLength = arr.byteLength; -// returns 20 -``` - - - -#### Float32ArrayLE.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the typed array from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var arr = new Float32ArrayLE( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Float32ArrayLE.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var arr = new Float32ArrayLE( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 4 -``` - - - -#### Float32ArrayLE.prototype.length - -**Read-only** property which returns the number of view elements. - -```javascript -var arr = new Float32ArrayLE( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Float32ArrayLE.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like object or an iterable. - -```javascript -var arr = Float32ArrayLE.from( [ 1.0, -1.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2.0; -} - -var arr = Float32ArrayLE.from( [ 1.0, -1.0 ], mapFcn ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 -``` - -A callback function is provided two arguments: - -- **value**: source value. -- **index**: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2.0; -} - -var ctx = { - 'count': 0 -}; - -var arr = Float32ArrayLE.from( [ 1.0, -1.0 ], mapFcn, ctx ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 - -var n = ctx.count; -// returns 2 -``` - - - -#### Float32ArrayLE.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Float32ArrayLE.of( 1.0, -1.0 ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - - - -#### Float32ArrayLE.prototype.get( i ) - -Returns an array element located at a nonnegative integer position (index) `i`. - -```javascript -var arr = new Float32ArrayLE( 10 ); - -// Set the first element: -arr.set( 1.0, 0 ); - -// Get the first element: -var v = arr.get( 0 ); -// returns 1.0 -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var arr = new Float32ArrayLE( 10 ); - -var v = arr.get( 100 ); -// returns undefined -``` - - - -#### Float32ArrayLE.prototype.set( arr\[, offset] ) - -Sets array elements. - -```javascript -var arr = new Float32ArrayLE( [ 1.0, 2.0, 3.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 - -v = arr.get( 1 ); -// returns 2.0 - -// Set the first two array elements: -arr.set( [ 4.0, 5.0 ] ); - -v = arr.get( 0 ); -// returns 4.0 - -v = arr.get( 1 ); -// returns 5.0 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - -```javascript -var arr = new Float32ArrayLE( [ 1.0, 2.0, 3.0 ] ); -// returns - -// Set the last two array elements: -arr.set( [ 4.0, 5.0 ], 1 ); - -var v = arr.get( 1 ); -// returns 4.0 - -v = arr.get( 2 ); -// returns 5.0 -``` - -A few notes: - -- If `i` is out-of-bounds, the method throws an error. -- If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error. -- If provided a typed array which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range. - - - -#### Float32ArrayLE.prototype.toString() - -Serializes an array as a string. - -```javascript -var arr = new Float32ArrayLE( [ 1.0, 2.0, 3.0 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - -
- - - - - -
- -* * * - -## Notes - -- While a `Float32ArrayLE` _strives_ to maintain (but does not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: - - - The constructor does **not** require the `new` operator. - - Accessing array elements using bracket syntax (e.g., `X[i]`) is **not** supported. Instead, one **must** use the `.get()` method. - -
- - - - - -
- -* * * - -## Examples - - - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); -var logEach = require( '@stdlib/console/log-each' ); -var Float32ArrayLE = require( '@stdlib/array/little-endian-float32' ); - -// Create a typed array by specifying a length: -var out = new Float32ArrayLE( 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float32ArrayLE( arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float32ArrayLE( arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float32ArrayLE( arr.buffer, 8, 2 ); -logEach( '%s', out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/little-endian-float32/benchmark/benchmark.from.js b/little-endian-float32/benchmark/benchmark.from.js deleted file mode 100644 index c0d15d5fa..000000000 --- a/little-endian-float32/benchmark/benchmark.from.js +++ /dev/null @@ -1,310 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float32Array = require( './../../float32' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayLE = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayLE.from( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayLE.from( createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayLE.from( createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return v * 2.0; - } -}); diff --git a/little-endian-float32/benchmark/benchmark.get.js b/little-endian-float32/benchmark/benchmark.get.js deleted file mode 100644 index 753a76288..000000000 --- a/little-endian-float32/benchmark/benchmark.get.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float32ArrayLE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float32ArrayLE( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-float32/benchmark/benchmark.js b/little-endian-float32/benchmark/benchmark.js deleted file mode 100644 index 7d6c5c80b..000000000 --- a/little-endian-float32/benchmark/benchmark.js +++ /dev/null @@ -1,346 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var ArrayBuffer = require( './../../buffer' ); -var Float32Array = require( './../../float32' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayLE = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// FUNCTIONS // - -/** -* Returns an "iterable" object. -* -* @private -* @returns {Object} iterable object -*/ -function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } -} - - -// MAIN // - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayLE(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float32ArrayLE; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayLE( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float32Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayLE( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayLE( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float32ArrayLE( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float32ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-float32/benchmark/benchmark.of.js b/little-endian-float32/benchmark/benchmark.of.js deleted file mode 100644 index d0d1b40a9..000000000 --- a/little-endian-float32/benchmark/benchmark.of.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayLE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayLE.of(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float32ArrayLE.of.apply( Float32ArrayLE, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float32ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-float32/benchmark/benchmark.set.js b/little-endian-float32/benchmark/benchmark.set.js deleted file mode 100644 index ee3e8e93e..000000000 --- a/little-endian-float32/benchmark/benchmark.set.js +++ /dev/null @@ -1,119 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float32Array = require( './../../float32' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayLE = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::number:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float32ArrayLE( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float32ArrayLE( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float32Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float32ArrayLE( values ); - buf = new Float32Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-float32/benchmark/benchmark.set.length.js b/little-endian-float32/benchmark/benchmark.set.length.js deleted file mode 100644 index 052841da0..000000000 --- a/little-endian-float32/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randu = require( '@stdlib/random/array/randu' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayLE = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - - arr1 = randu( len ); - arr2 = randu( len ); - arr3 = randu( len ); - arr1 = new Float32ArrayLE( arr1 ); - - values = [ - new Float32ArrayLE( arr2 ), - new Float32ArrayLE( arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/little-endian-float32/benchmark/benchmark.to_string.js b/little-endian-float32/benchmark/benchmark.to_string.js deleted file mode 100644 index 198b9663c..000000000 --- a/little-endian-float32/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayLE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float32ArrayLE( [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-float32/benchmark/benchmark.to_string.length.js b/little-endian-float32/benchmark/benchmark.to_string.length.js deleted file mode 100644 index ef68cdaed..000000000 --- a/little-endian-float32/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var Float32ArrayLE = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float32ArrayLE( zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/little-endian-float32/examples/index.js b/little-endian-float32/examples/index.js deleted file mode 100644 index bbfb36c68..000000000 --- a/little-endian-float32/examples/index.js +++ /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. -*/ - -'use strict'; - -var Float32Array = require( './../../float32' ); -var logEach = require( '@stdlib/console/log-each' ); -var Float32ArrayLE = require( './../lib' ); - -// Create a typed array by specifying a length: -var out = new Float32ArrayLE( 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float32ArrayLE( arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float32ArrayLE( arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float32Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float32ArrayLE( arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/little-endian-float32/lib/index.js b/little-endian-float32/lib/index.js deleted file mode 100644 index 11337b3d3..000000000 --- a/little-endian-float32/lib/index.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in little-endian byte order. -* -* @module @stdlib/array/little-endian-float32 -* -* @example -* var Float32ArrayLE = require( '@stdlib/array/little-endian-float32' ); -* -* var arr = new Float32ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float32ArrayLE = require( '@stdlib/array/little-endian-float32' ); -* -* var arr = new Float32ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float32ArrayLE = require( '@stdlib/array/little-endian-float32' ); -* -* var arr = new Float32ArrayLE( [ 1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float32ArrayLE = require( '@stdlib/array/little-endian-float32' ); -* -* var buf = new ArrayBuffer( 8 ); -* var arr = new Float32ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float32ArrayLE = require( '@stdlib/array/little-endian-float32' ); -* -* var buf = new ArrayBuffer( 8 ); -* var arr = new Float32ArrayLE( buf, 4 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float32ArrayLE = require( '@stdlib/array/little-endian-float32' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float32ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/little-endian-float32/lib/main.js b/little-endian-float32/lib/main.js deleted file mode 100644 index 08b3a9d07..000000000 --- a/little-endian-float32/lib/main.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var factory = require( './../../little-endian-factory' ); - - -// MAIN // - -/** -* Typed array constructor which returns a typed array representing an array of single-precision floating-point numbers in little-endian byte order. -* -* @name Float32ArrayLE -* @constructor -* @type {Function} -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {TypeError} if provided only one argument, the argument must be a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @returns {Float32ArrayLE} typed array instance -* -* @example -* var arr = new Float32ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float32ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Float32ArrayLE( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 8 ); -* var arr = new Float32ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 8 ); -* var arr = new Float32ArrayLE( buf, 4 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float32ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -var Float32ArrayLE = factory( 'float32' ); - - -// EXPORTS // - -module.exports = Float32ArrayLE; diff --git a/little-endian-float32/package.json b/little-endian-float32/package.json deleted file mode 100644 index afda44120..000000000 --- a/little-endian-float32/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/little-endian-float32", - "version": "0.0.0", - "description": "Float32Array in little-endian byte order.", - "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", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "float32array", - "float32", - "float", - "single-precision", - "ieee754", - "endian", - "little-endian", - "byte-order" - ] -} diff --git a/little-endian-float32/test/test.js b/little-endian-float32/test/test.js deleted file mode 100644 index fc72bbf88..000000000 --- a/little-endian-float32/test/test.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests diff --git a/little-endian-float64/README.md b/little-endian-float64/README.md deleted file mode 100644 index 93b9fd7e6..000000000 --- a/little-endian-float64/README.md +++ /dev/null @@ -1,454 +0,0 @@ - - -# Float64ArrayLE - -> Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in little-endian byte order. - - - -
- -In contrast to the [`Float64Array`][@stdlib/array/float64] typed array constructor which stores values according to the host platform byte order, the `Float64ArrayLE` constructor always accesses elements in little-endian byte order. Such enforcement can be particularly advantageous when working with memory buffers which do not necessarily follow host platform byte order, such as [WebAssembly memory][@stdlib/wasm/memory]. - -
- - - - - -
- -## Usage - -```javascript -var Float64ArrayLE = require( '@stdlib/array/little-endian-float64' ); -``` - -#### Float64ArrayLE() - -A typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in little-endian byte order. - -```javascript -var arr = new Float64ArrayLE(); -// returns -``` - -#### Float64ArrayLE( length ) - -Returns a typed array having a specified length. - -```javascript -var arr = new Float64ArrayLE( 5 ); -// returns -``` - -#### Float64ArrayLE( typedarray ) - -Creates a typed array from another typed array. - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 0.5, 0.5, 0.5 ] ); -var arr2 = new Float64ArrayLE( arr1 ); -// returns - -var v = arr2.get( 0 ); -// returns 0.5 -``` - -#### Float64ArrayLE( obj ) - -Creates a typed array from an array-like object or iterable. - -```javascript -var arr = new Float64ArrayLE( [ 0.5, 0.5, 0.5 ] ); -// returns - -var v = arr.get( 0 ); -// returns 0.5 -``` - -#### Float64ArrayLE( buffer\[, byteOffset\[, length]] ) - -Returns a typed array view of an [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 32 ); -var arr = new Float64ArrayLE( buf, 0, 4 ); -// returns -``` - -* * * - -### Properties - - - -#### Float64ArrayLE.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var nbytes = Float64ArrayLE.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### Float64ArrayLE.name - -Typed array constructor name. - -```javascript -var str = Float64ArrayLE.name; -// returns 'Float64ArrayLE' -``` - - - -#### Float64ArrayLE.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the typed array. - -```javascript -var arr = new Float64ArrayLE( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Float64ArrayLE.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the typed array. - -```javascript -var arr = new Float64ArrayLE( 5 ); -var byteLength = arr.byteLength; -// returns 40 -``` - - - -#### Float64ArrayLE.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the typed array from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var arr = new Float64ArrayLE( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Float64ArrayLE.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var arr = new Float64ArrayLE( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 8 -``` - - - -#### Float64ArrayLE.prototype.length - -**Read-only** property which returns the number of view elements. - -```javascript -var arr = new Float64ArrayLE( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Float64ArrayLE.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like object or an iterable. - -```javascript -var arr = Float64ArrayLE.from( [ 1.0, -1.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2.0; -} - -var arr = Float64ArrayLE.from( [ 1.0, -1.0 ], mapFcn ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 -``` - -A callback function is provided two arguments: - -- **value**: source value. -- **index**: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2.0; -} - -var ctx = { - 'count': 0 -}; - -var arr = Float64ArrayLE.from( [ 1.0, -1.0 ], mapFcn, ctx ); -// returns - -var v = arr.get( 0 ); -// returns 2.0 - -var n = ctx.count; -// returns 2 -``` - - - -#### Float64ArrayLE.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Float64ArrayLE.of( 1.0, -1.0 ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 -``` - - - -#### Float64ArrayLE.prototype.get( i ) - -Returns an array element located at a nonnegative integer position (index) `i`. - -```javascript -var arr = new Float64ArrayLE( 10 ); - -// Set the first element: -arr.set( 1.0, 0 ); - -// Get the first element: -var v = arr.get( 0 ); -// returns 1.0 -``` - -If provided an out-of-bounds index, the method returns `undefined`. - -```javascript -var arr = new Float64ArrayLE( 10 ); - -var v = arr.get( 100 ); -// returns undefined -``` - - - -#### Float64ArrayLE.prototype.set( arr\[, offset] ) - -Sets array elements. - -```javascript -var arr = new Float64ArrayLE( [ 1.0, 2.0, 3.0 ] ); -// returns - -var v = arr.get( 0 ); -// returns 1.0 - -v = arr.get( 1 ); -// returns 2.0 - -// Set the first two array elements: -arr.set( [ 4.0, 5.0 ] ); - -v = arr.get( 0 ); -// returns 4.0 - -v = arr.get( 1 ); -// returns 5.0 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - -```javascript -var arr = new Float64ArrayLE( [ 1.0, 2.0, 3.0 ] ); -// returns - -// Set the last two array elements: -arr.set( [ 4.0, 5.0 ], 1 ); - -var v = arr.get( 1 ); -// returns 4.0 - -v = arr.get( 2 ); -// returns 5.0 -``` - -A few notes: - -- If `i` is out-of-bounds, the method throws an error. -- If a target array cannot accommodate all values (i.e., the length of source array plus `i` exceeds the target array length), the method throws an error. -- If provided a typed array which shares an [`ArrayBuffer`][@stdlib/array/buffer] with the target array, the method will intelligently copy the source range to the destination range. - - - -#### Float64ArrayLE.prototype.toString() - -Serializes an array as a string. - -```javascript -var arr = new Float64ArrayLE( [ 1.0, 2.0, 3.0 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - -
- - - - - -
- -* * * - -## Notes - -- While a `Float64ArrayLE` _strives_ to maintain (but does not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: - - - The constructor does **not** require the `new` operator. - - Accessing array elements using bracket syntax (e.g., `X[i]`) is **not** supported. Instead, one **must** use the `.get()` method. - -
- - - - - -
- -* * * - -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var logEach = require( '@stdlib/console/log-each' ); -var Float64ArrayLE = require( '@stdlib/array/little-endian-float64' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayLE( 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayLE( arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer, 8, 2 ); -logEach( '%s', out ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/little-endian-float64/benchmark/benchmark.from.js b/little-endian-float64/benchmark/benchmark.from.js deleted file mode 100644 index b3693ee3d..000000000 --- a/little-endian-float64/benchmark/benchmark.from.js +++ /dev/null @@ -1,310 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../float64' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayLE = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 5 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from:len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( buf, clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v * 2.0; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable() ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } -}); - -bench( pkg+'::iterable,clbk:from:len=5', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.from( createIterable(), clbk ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - var it = { - 'next': next, - 'i': 0, - 'N': 5 - }; - return it; - - function next() { - it.i += 1; - if ( it.i <= it.N ) { - return { - 'value': 1.0 - }; - } - return { - 'done': true - }; - } - } - } - - function clbk( v ) { - return v * 2.0; - } -}); diff --git a/little-endian-float64/benchmark/benchmark.get.js b/little-endian-float64/benchmark/benchmark.get.js deleted file mode 100644 index 127c09523..000000000 --- a/little-endian-float64/benchmark/benchmark.get.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Float64ArrayLE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':get', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = []; - for ( i = 0; i < 10; i++ ) { - arr.push( i ); - } - arr = new Float64ArrayLE( arr ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.get( i%N ); - if ( typeof v !== 'number' ) { - b.fail( 'should return a number' ); - } - } - b.toc(); - if ( !isNumber( v ) ) { - b.fail( 'should return a number' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-float64/benchmark/benchmark.js b/little-endian-float64/benchmark/benchmark.js deleted file mode 100644 index d4195834d..000000000 --- a/little-endian-float64/benchmark/benchmark.js +++ /dev/null @@ -1,346 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var ArrayBuffer = require( './../../buffer' ); -var Float64Array = require( './../../float64' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayLE = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// FUNCTIONS // - -/** -* Returns an "iterable" object. -* -* @private -* @returns {Object} iterable object -*/ -function createIterable() { - var out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - return { - 'done': true - }; - } -} - - -// MAIN // - -bench( pkg+'::instantiation,new', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,no_new', function benchmark( b ) { - var ctor; - var arr; - var i; - - ctor = Float64ArrayLE; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ctor(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,length', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,typed_array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Float64Array( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,array', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = []; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,iterable', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( createIterable() ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::instantiation,arraybuffer,byte_offset,length', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new ArrayBuffer( 8 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new Float64ArrayLE( buf, 8, 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Float64ArrayLE(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-float64/benchmark/benchmark.of.js b/little-endian-float64/benchmark/benchmark.of.js deleted file mode 100644 index ca9ef9107..000000000 --- a/little-endian-float64/benchmark/benchmark.of.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayLE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of(); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':len=5', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1.0, 1.0, 1.0, 1.0, 1.0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Float64ArrayLE.of.apply( Float64ArrayLE, buf ); - if ( arr.length !== 5 ) { - b.fail( 'should have length 5' ); - } - } - b.toc(); - if ( !(arr instanceof Float64ArrayLE) ) { - b.fail( 'should return an instance' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-float64/benchmark/benchmark.set.js b/little-endian-float64/benchmark/benchmark.set.js deleted file mode 100644 index 3b3fa10c0..000000000 --- a/little-endian-float64/benchmark/benchmark.set.js +++ /dev/null @@ -1,119 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( './../../float64' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayLE = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::number:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ (i+1)%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - arr = new Float64ArrayLE( values ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( [ values[ (i+1)%N ] ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var arr; - var buf; - var N; - var v; - var i; - - values = new Float64Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - arr = new Float64ArrayLE( values ); - buf = new Float64Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-float64/benchmark/benchmark.set.length.js b/little-endian-float64/benchmark/benchmark.set.length.js deleted file mode 100644 index 885f756b4..000000000 --- a/little-endian-float64/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randu = require( '@stdlib/random/array/randu' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayLE = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr3; - var N; - - arr1 = randu( len ); - arr2 = randu( len ); - arr3 = randu( len ); - arr1 = new Float64ArrayLE( arr1 ); - - values = [ - new Float64ArrayLE( arr2 ), - new Float64ArrayLE( arr3 ) - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr1.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/little-endian-float64/benchmark/benchmark.to_string.js b/little-endian-float64/benchmark/benchmark.to_string.js deleted file mode 100644 index c3ebf9c28..000000000 --- a/little-endian-float64/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,50 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayLE = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Float64ArrayLE( [ 1.0, 2.0, 2.0, 1.0 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/little-endian-float64/benchmark/benchmark.to_string.length.js b/little-endian-float64/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 3eb236fab..000000000 --- a/little-endian-float64/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../zero-to' ); -var pkg = require( './../package.json' ).name; -var Float64ArrayLE = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Float64ArrayLE( zeroTo( len ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/little-endian-float64/examples/index.js b/little-endian-float64/examples/index.js deleted file mode 100644 index d6ca2a4b6..000000000 --- a/little-endian-float64/examples/index.js +++ /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. -*/ - -'use strict'; - -var Float64Array = require( './../../float64' ); -var logEach = require( '@stdlib/console/log-each' ); -var Float64ArrayLE = require( './../lib' ); - -// Create a typed array by specifying a length: -var out = new Float64ArrayLE( 3 ); -logEach( '%s', out ); - -// Create a typed array from an array: -var arr = [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ]; -out = new Float64ArrayLE( arr ); -logEach( '%s', out ); - -// Create a typed array from an array buffer: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer ); -logEach( '%s', out ); - -// Create a typed array from an array buffer view: -arr = new Float64Array( [ 1.0, -1.0, -3.14, 3.14, 0.5, 0.5 ] ); // host byte order -out = new Float64ArrayLE( arr.buffer, 8, 2 ); -logEach( '%s', out ); diff --git a/little-endian-float64/lib/index.js b/little-endian-float64/lib/index.js deleted file mode 100644 index 310b93fbe..000000000 --- a/little-endian-float64/lib/index.js +++ /dev/null @@ -1,94 +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. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in little-endian byte order. -* -* @module @stdlib/array/little-endian-float64 -* -* @example -* var Float64ArrayLE = require( '@stdlib/array/little-endian-float64' ); -* -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var Float64ArrayLE = require( '@stdlib/array/little-endian-float64' ); -* -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var Float64ArrayLE = require( '@stdlib/array/little-endian-float64' ); -* -* var arr = new Float64ArrayLE( [ 1.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float64ArrayLE = require( '@stdlib/array/little-endian-float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float64ArrayLE = require( '@stdlib/array/little-endian-float64' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var Float64ArrayLE = require( '@stdlib/array/little-endian-float64' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/little-endian-float64/lib/main.js b/little-endian-float64/lib/main.js deleted file mode 100644 index 100fe67c5..000000000 --- a/little-endian-float64/lib/main.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var factory = require( './../../little-endian-factory' ); - - -// MAIN // - -/** -* Typed array constructor which returns a typed array representing an array of double-precision floating-point numbers in little-endian byte order. -* -* @name Float64ArrayLE -* @constructor -* @type {Function} -* @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @throws {TypeError} if provided only one argument, the argument must be a valid argument -* @throws {TypeError} byte offset must be a nonnegative integer -* @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements -* @returns {Float64ArrayLE} typed array instance -* -* @example -* var arr = new Float64ArrayLE(); -* // returns -* -* var len = arr.length; -* // returns 0 -* -* @example -* var arr = new Float64ArrayLE( 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var arr = new Float64ArrayLE( [ 1.0, 2.0 ] ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf ); -* // returns -* -* var len = arr.length; -* // returns 2 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = new Float64ArrayLE( buf, 8 ); -* // returns -* -* var len = arr.length; -* // returns 1 -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = new Float64ArrayLE( buf, 8, 2 ); -* // returns -* -* var len = arr.length; -* // returns 2 -*/ -var Float64ArrayLE = factory( 'float64' ); - - -// EXPORTS // - -module.exports = Float64ArrayLE; diff --git a/little-endian-float64/package.json b/little-endian-float64/package.json deleted file mode 100644 index 98f666f5f..000000000 --- a/little-endian-float64/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/little-endian-float64", - "version": "0.0.0", - "description": "Float64Array in little-endian byte order.", - "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", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "float64array", - "float64", - "double", - "double-precision", - "ieee754", - "endian", - "little-endian", - "byte-order" - ] -} diff --git a/little-endian-float64/test/test.js b/little-endian-float64/test/test.js deleted file mode 100644 index fc72bbf88..000000000 --- a/little-endian-float64/test/test.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests diff --git a/logspace/README.md b/logspace/README.md deleted file mode 100644 index 17a927b8d..000000000 --- a/logspace/README.md +++ /dev/null @@ -1,112 +0,0 @@ - - -# Logspace - -> Generate a logarithmically spaced numeric array. - -
- -## Usage - -```javascript -var logspace = require( '@stdlib/array/logspace' ); -``` - -#### logspace( a, b\[, length] ) - -Generates a logarithmically spaced numeric `array` between `10^a` and `10^b`. If a `length` is not provided, the default output `array` length is `10`. - -```javascript -var arr = logspace( 0, 2, 6 ); -// returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] -``` - -
- - - -
- -## Notes - -- The output `array` includes the values `10^a` and `10^b`. **Beware** of floating point errors, including for the first and last `array` elements. - -
- - - -
- -## Examples - - - -```javascript -var logspace = require( '@stdlib/array/logspace' ); -var out; - -// Default behavior: -out = logspace( 0, 3 ); -console.log( out.join( '\n' ) ); - -// Specify length: -out = logspace( 0, 3, 100 ); -console.log( out.join( '\n' ) ); - -// Create an array with decremented values: -out = logspace( 3, 0, 10 ); -console.log( out.join( '\n' ) ); -``` - -
- - - - - - - - - - - - - - diff --git a/logspace/benchmark/benchmark.js b/logspace/benchmark/benchmark.js deleted file mode 100644 index 3eebc43fc..000000000 --- a/logspace/benchmark/benchmark.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var logspace = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var x2; - var i; - var v; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x2 = randu()*100.0; - v = logspace( 0.0, x2 ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/logspace/benchmark/benchmark.length.js b/logspace/benchmark/benchmark.length.js deleted file mode 100644 index caff56d56..000000000 --- a/logspace/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randu = require( '@stdlib/random/base/randu' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var logspace = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x2; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x2 = randu() * 10.0; - v = logspace( 0.0, x2, len ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/logspace/docs/repl.txt b/logspace/docs/repl.txt deleted file mode 100644 index 998aaba1e..000000000 --- a/logspace/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( a, b[, length] ) - Generates a logarithmically spaced numeric array between `10^a` and `10^b`. - - If a `length` is not provided, the default output array length is `10`. - - The output array includes the values `10^a` and `10^b`. - - Parameters - ---------- - a: number - Exponent of start value. - - b: number - Exponent of end value. - - length: integer (optional) - Length of output array. Default: `10`. - - Returns - ------- - arr: Array - Logarithmically spaced numeric array. - - Examples - -------- - > var arr = {{alias}}( 0, 2, 6 ) - [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] - - See Also - -------- - diff --git a/logspace/docs/types/index.d.ts b/logspace/docs/types/index.d.ts deleted file mode 100644 index 43c506c42..000000000 --- a/logspace/docs/types/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Generates a logarithmically spaced numeric array. -* -* @param a - exponent of start value -* @param b - exponent of end value -* @param len - length of output array (default: 10) -* @throws third argument must be a nonnegative integer -* @returns logarithmically spaced numeric array -* -* @example -* var arr = logspace( 0, 2, 6 ); -* // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] -*/ -declare function logspace( a: number, b: number, len?: number ): Array; - - -// EXPORTS // - -export = logspace; diff --git a/logspace/docs/types/test.ts b/logspace/docs/types/test.ts deleted file mode 100644 index 9c33c4256..000000000 --- a/logspace/docs/types/test.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 logspace = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers... -{ - logspace( 0, 11, 20 ); // $ExpectType number[] - logspace( 0, 10 ); // $ExpectType number[] -} - -// The compiler throws an error if the function is provided values other than two numbers for the first two parameters... -{ - logspace( true, 10 ); // $ExpectError - logspace( false, 10 ); // $ExpectError - logspace( '5', 10 ); // $ExpectError - logspace( [], 10 ); // $ExpectError - logspace( {}, 10 ); // $ExpectError - logspace( ( x: number ): number => x, 10 ); // $ExpectError - - logspace( 9, true ); // $ExpectError - logspace( 9, false ); // $ExpectError - logspace( 5, '5' ); // $ExpectError - logspace( 8, [] ); // $ExpectError - logspace( 9, {} ); // $ExpectError - logspace( 8, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a value other than a number for the third parameter... -{ - logspace( 3, 20, true ); // $ExpectError - logspace( 4, 20, false ); // $ExpectError - logspace( 2, 20, '5' ); // $ExpectError - logspace( 2, 20, [] ); // $ExpectError - logspace( 9, 20, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - logspace(); // $ExpectError - logspace( 3 ); // $ExpectError -} diff --git a/logspace/examples/index.js b/logspace/examples/index.js deleted file mode 100644 index 47be033d8..000000000 --- a/logspace/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 logspace = require( './../lib' ); -var out; - -// Default behavior: -console.log( '\nDefault:' ); -out = logspace( 0, 3 ); -console.log( out.join( '\n' ) ); - -// Specify length: -console.log( '\nLength 100:' ); -out = logspace( 0, 3, 100 ); -console.log( out.join( '\n' ) ); - -// Create an array with decremented values: -console.log( '\nDecremented:' ); -out = logspace( 3, 0, 10 ); -console.log( out.join( '\n' ) ); diff --git a/logspace/lib/index.js b/logspace/lib/index.js deleted file mode 100644 index 66d4ca5aa..000000000 --- a/logspace/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Generate a logarithmically spaced numeric array. -* -* @module @stdlib/array/logspace -* -* @example -* var logspace = require( '@stdlib/array/logspace' ); -* -* var arr = logspace( 0, 2, 6 ); -* // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/logspace/lib/main.js b/logspace/lib/main.js deleted file mode 100644 index fa95841bc..000000000 --- a/logspace/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string/format' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var gen = require( './../../base/logspace' ); - - -// MAIN // - -/** -* Generates a logarithmically spaced numeric array. -* -* @param {number} a - exponent of start value -* @param {number} b - exponent of end value -* @param {NonNegativeInteger} [len=10] - length of output array -* @throws {TypeError} first argument must be numeric -* @throws {TypeError} second argument must be numeric -* @throws {TypeError} third argument must be a nonnegative integer -* @returns {Array} logarithmically spaced numeric array -* -* @example -* var arr = logspace( 0, 2, 6 ); -* // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ] -*/ -function logspace( a, b, len ) { - if ( !isNumber( a ) || isnan( a ) ) { - throw new TypeError( format( 'invalid argument. Exponent of start value must be numeric. Value: `%s`.', a ) ); - } - if ( !isNumber( b ) || isnan( b ) ) { - throw new TypeError( format( 'invalid argument. Exponent of stop value must be numeric. Value: `%s`.', b ) ); - } - if ( arguments.length < 3 ) { - len = 10; - } else if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Length must be a nonnegative integer. Value: `%s`.', len ) ); - } - return gen( a, b, len ); -} - - -// EXPORTS // - -module.exports = logspace; diff --git a/logspace/package.json b/logspace/package.json deleted file mode 100644 index 3d415862a..000000000 --- a/logspace/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/logspace", - "version": "0.0.0", - "description": "Generate a logarithmically spaced numeric array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdmath", - "mathematics", - "math", - "utilities", - "utils", - "generic", - "array", - "matlab", - "linear", - "log", - "logarithmic" - ] -} diff --git a/logspace/test/test.js b/logspace/test/test.js deleted file mode 100644 index fc66a95cd..000000000 --- a/logspace/test/test.js +++ /dev/null @@ -1,154 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 logspace = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof logspace, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if the first argument is not a numeric value', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - logspace( value, 10 ); - }; - } -}); - -tape( 'the function throws an error if the second argument is not a numeric value', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - logspace( 0, value ); - }; - } -}); - -tape( 'the function throws an error if the `length` value is not a numeric value', function test( t ) { - var values; - var i; - - values = [ - '5', - null, - true, - void 0, - NaN, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - logspace( 0, 10, value ); - }; - } -}); - -tape( 'the function returns a logarithmically spaced array', function test( t ) { - var expected; - var actual; - var a; - var b; - - a = 0; - b = 3; - - // Default behavior: - actual = logspace( a, b ); - t.strictEqual( actual.length, 10 ); - t.strictEqual( actual[0], 1 ); - t.strictEqual( actual[actual.length-1], 1000 ); - - // Specify the length: - actual = logspace( a, b, 10 ); - t.strictEqual( actual.length, 10 ); - t.strictEqual( actual[0], 1 ); - t.strictEqual( actual[actual.length-1], 1000 ); - - // Verify correct values: - actual = logspace( a, b, 4 ); - expected = [ 1, 10, 100, 1000 ]; - - t.deepEqual( actual, expected ); - - // Decrement: - actual = logspace( b, a, 4 ); - expected = [ 1000, 100, 10, 1 ]; - - t.deepEqual( actual, expected ); - t.end(); -}); - -tape( 'if the length is set to `0`, the function returns an empty array', function test( t ) { - t.deepEqual( logspace(0, 10, 0), [] ); - t.end(); -}); diff --git a/min-dtype/README.md b/min-dtype/README.md deleted file mode 100644 index f1b5f8280..000000000 --- a/min-dtype/README.md +++ /dev/null @@ -1,152 +0,0 @@ - - -# Minimum Data Type - -> Determine the minimum array [data type][@stdlib/array/dtypes] of the closest "kind" necessary for storing a provided scalar value. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var minDataType = require( '@stdlib/array/min-dtype' ); -``` - -#### minDataType( value ) - -Returns the minimum array [data type][@stdlib/array/dtypes] of the closest "kind" necessary for storing a provided scalar value. - -```javascript -var dt = minDataType( 3.141592653589793 ); -// returns 'float32' - -dt = minDataType( -3 ); -// returns 'int8' - -dt = minDataType( 3 ); -// returns 'uint8' - -dt = minDataType( '3' ); -// returns 'generic' -``` - -
- - - - - -
- -## Notes - -- The function does **not** provide precision guarantees for non-integer-valued numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) [data type][@stdlib/array/dtypes] for storing numbers having decimals. - -
- - - - - -
- -## Examples - - - -```javascript -var roundn = require( '@stdlib/math/base/special/roundn' ); -var randu = require( '@stdlib/random/base/randu' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var minDataType = require( '@stdlib/array/min-dtype' ); - -var dt; -var v; -var i; - -// Generate numbers of varying magnitudes and determine the minimum data type for each value... -for ( i = 0; i < 100; i++ ) { - v = randu() * pow( 2.0, discreteUniform( 0, 40 ) ); - if ( randu() < 0.5 ) { - v *= -1; - } - v = roundn( v, discreteUniform( -1, 0 ) ); - dt = minDataType( v ); - console.log( 'min(%d) => %s', v, dt ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/min-dtype/benchmark/benchmark.js b/min-dtype/benchmark/benchmark.js deleted file mode 100644 index d2a78a5b3..000000000 --- a/min-dtype/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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var minDataType = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var N; - var i; - - values = [ - -0.0, - 3.14, - 3.0, - -3.0, - 1.0e308, - 3.14e37, - NaN - ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = minDataType( values[ i%N ] ); - if ( typeof out !== 'string' || out === 'generic' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) || out === 'generic' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/min-dtype/benchmark/python/numpy/benchmark.py b/min-dtype/benchmark/python/numpy/benchmark.py deleted file mode 100644 index 5e5718e51..000000000 --- a/min-dtype/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.min_scalar_type.""" - -from __future__ import print_function -import timeit - -NAME = "min-dtype" -REPEATS = 3 -ITERATIONS = 1000000 - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(elapsed): - """Print benchmark results. - - # Arguments - - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(0.131009101868) - ``` - """ - rate = ITERATIONS / elapsed - - print(" ---") - print(" iterations: " + str(ITERATIONS)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(): - """Run the benchmark and print benchmark results.""" - setup = "import numpy as np; from random import random;" - stmt = "y = np.min_scalar_type(random()*1000.0)" - - t = timeit.Timer(stmt, setup=setup) - - print_version() - - for i in range(REPEATS): - print("# python::numpy::" + NAME) - elapsed = t.timeit(number=ITERATIONS) - print_results(elapsed) - print("ok " + str(i+1) + " benchmark finished") - - print_summary(REPEATS, REPEATS) - - -def main(): - """Run the benchmark.""" - benchmark() - - -if __name__ == "__main__": - main() diff --git a/min-dtype/docs/repl.txt b/min-dtype/docs/repl.txt deleted file mode 100644 index 56df9cf1c..000000000 --- a/min-dtype/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( value ) - Returns the minimum array data type of the closest "kind" necessary for - storing a provided scalar value. - - The function does *not* provide precision guarantees for non-integer-valued - numbers. In other words, the function returns the smallest possible - floating-point (i.e., inexact) data type for storing numbers having - decimals. - - Parameters - ---------- - value: any - Scalar value. - - Returns - ------- - dt: string - Array data type. - - Examples - -------- - > var dt = {{alias}}( 3.141592653589793 ) - 'float32' - > dt = {{alias}}( 3 ) - 'uint8' - > dt = {{alias}}( -3 ) - 'int8' - > dt = {{alias}}( '-3' ) - 'generic' - - See Also - -------- - diff --git a/min-dtype/docs/types/index.d.ts b/min-dtype/docs/types/index.d.ts deleted file mode 100644 index e2c68295e..000000000 --- a/min-dtype/docs/types/index.d.ts +++ /dev/null @@ -1,97 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { RealDataType, ComplexFloatingPointDataType, BooleanDataType } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value. -* -* ## Notes -* -* - The function does *not* provide precision guarantees for non-integer-valued numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals. -* -* @param value - scalar value -* @returns array data type -* -* @example -* var dt = minDataType( 3.141592653589793 ); -* // returns 'float32' -* -* @example -* var dt = minDataType( 3 ); -* // returns 'uint8' -*/ -declare function minDataType( value: number ): RealDataType; - -/** -* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value. -* -* ## Notes -* -* - The function does *not* provide precision guarantees for non-integer-valued numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals. -* -* @param value - scalar value -* @returns array data type -* -* @example -* var z = { -* 're': 3.141592653589793, -* 'im': 1.0 -* }; -* var dt = minDataType( z ); -* // returns 'complex64' -*/ -declare function minDataType( value: ComplexLike ): ComplexFloatingPointDataType; - -/** -* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value. -* -* @param value - scalar value -* @returns array data type -* -* @example -* var dt = minDataType( true ); -* // returns 'bool' -*/ -declare function minDataType( value: boolean ): BooleanDataType; - -/** -* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value. -* -* ## Notes -* -* - The function does *not* provide precision guarantees for non-integer-valued numbers. In other words, the function returns the smallest possible floating-point (i.e., inexact) data type for storing numbers having decimals. -* -* @param value - scalar value -* @returns array data type -* -* @example -* var dt = minDataType( 'beep' ); -* // returns 'generic' -*/ -declare function minDataType( value: any ): 'generic'; - - -// EXPORTS // - -export = minDataType; diff --git a/min-dtype/docs/types/test.ts b/min-dtype/docs/types/test.ts deleted file mode 100644 index 79214d61d..000000000 --- a/min-dtype/docs/types/test.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 minDataType = require( './index' ); - - -// TESTS // - -// The function returns a data type.. -{ - const z = { - 're': 1.0, - 'im': 2.0 - }; - - minDataType( 2.13 ); // $ExpectType RealDataType - minDataType( z ); // $ExpectType ComplexFloatingPointDataType - minDataType( true ); // $ExpectType "bool" - minDataType( 'beep' ); // $ExpectType "generic" -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - minDataType(); // $ExpectError - minDataType( [ 1, 2, 3 ], 3 ); // $ExpectError -} diff --git a/min-dtype/examples/index.js b/min-dtype/examples/index.js deleted file mode 100644 index d3254b8c9..000000000 --- a/min-dtype/examples/index.js +++ /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. -*/ - -'use strict'; - -var roundn = require( '@stdlib/math/base/special/roundn' ); -var randu = require( '@stdlib/random/base/randu' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var minDataType = require( './../lib' ); - -var dt; -var v; -var i; - -// Generate numbers of varying magnitudes and determine the minimum data type for each value... -for ( i = 0; i < 100; i++ ) { - v = randu() * pow( 2.0, discreteUniform( 0, 40 ) ); - if ( randu() < 0.5 ) { - v *= -1; - } - v = roundn( v, discreteUniform( -1, 0 ) ); - dt = minDataType( v ); - console.log( 'min(%d) => %s', v, dt ); -} diff --git a/min-dtype/lib/index.js b/min-dtype/lib/index.js deleted file mode 100644 index c81b6d323..000000000 --- a/min-dtype/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Determine the minimum array data type of the closest "kind" necessary for storing a provided scalar value. -* -* @module @stdlib/array/min-dtype -* -* @example -* var minDataType = require( '@stdlib/array/min-dtype' ); -* -* var dt = minDataType( 3.141592653589793 ); -* // returns 'float32' -* -* dt = minDataType( 3 ); -* // returns 'uint8' -*/ - -// MODULES // - -var minDataType = require( './main.js' ); - - -// EXPORTS // - -module.exports = minDataType; diff --git a/min-dtype/lib/main.js b/min-dtype/lib/main.js deleted file mode 100644 index 5342fcafa..000000000 --- a/min-dtype/lib/main.js +++ /dev/null @@ -1,145 +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. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isInteger = require( '@stdlib/math/base/assert/is-integer' ); -var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var PINF = require( '@stdlib/constants/float64/pinf' ); -var NINF = require( '@stdlib/constants/float64/ninf' ); -var FLOAT32_SMALLEST_SUBNORMAL = require( '@stdlib/constants/float32/smallest-subnormal' ); // eslint-disable-line id-length -var FLOAT32_MAX_SAFE_INTEGER = require( '@stdlib/constants/float32/max-safe-integer' ); -var FLOAT32_MIN_SAFE_INTEGER = require( '@stdlib/constants/float32/min-safe-integer' ); -var INT8_MIN = require( '@stdlib/constants/int8/min' ); -var INT16_MIN = require( '@stdlib/constants/int16/min' ); -var INT32_MIN = require( '@stdlib/constants/int32/min' ); -var UINT8_MAX = require( '@stdlib/constants/uint8/max' ); -var UINT16_MAX = require( '@stdlib/constants/uint16/max' ); -var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); - - -// FUNCTIONS // - -/** -* Returns the minimum floating-point array data type of the closest "kind" necessary for storing a provided scalar. -* -* @private -* @param {number} value - real value -* @returns {string} array data type -*/ -function minFloatDataType( value ) { - if ( value !== value || value === PINF || value === NINF ) { - return 'float32'; - } - if ( isInteger( value ) ) { - if ( value >= FLOAT32_MIN_SAFE_INTEGER && value <= FLOAT32_MAX_SAFE_INTEGER ) { // eslint-disable-line max-len - return 'float32'; - } - return 'float64'; - } - // Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float32`... - if ( - value > -FLOAT32_SMALLEST_SUBNORMAL && - value < FLOAT32_SMALLEST_SUBNORMAL - ) { - return 'float64'; - } - // Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)... - return 'float32'; -} - - -// MAIN // - -/** -* Returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value. -* -* @param {*} value - scalar value -* @returns {string} array data type -* -* @example -* var dt = minDataType( 3.141592653589793 ); -* // returns 'float32' -* -* @example -* var dt = minDataType( 3 ); -* // returns 'uint8' -*/ -function minDataType( value ) { - if ( !isNumber( value ) ) { - if ( isBoolean( value ) ) { - return 'bool'; - } - if ( isComplexLike( value ) ) { - if ( minFloatDataType( value.re ) === 'float64' || minFloatDataType( value.im ) === 'float64' ) { - return 'complex128'; - } - return 'complex64'; - } - return 'generic'; - } - if ( value !== value || value === PINF || value === NINF ) { - return 'float32'; - } - if ( isInteger( value ) ) { - if ( value === 0 && isNegativeZero( value ) ) { - return 'float32'; - } - if ( value < 0 ) { - if ( value >= INT8_MIN ) { - return 'int8'; - } - if ( value >= INT16_MIN ) { - return 'int16'; - } - if ( value >= INT32_MIN ) { - return 'int32'; - } - return 'float64'; - } - if ( value <= UINT8_MAX ) { - return 'uint8'; - } - if ( value <= UINT16_MAX ) { - return 'uint16'; - } - if ( value <= UINT32_MAX ) { - return 'uint32'; - } - return 'float64'; - } - // Assume that if we are provided a tiny value, we don't want to underflow to zero by storing as `float32`... - if ( - value > -FLOAT32_SMALLEST_SUBNORMAL && - value < FLOAT32_SMALLEST_SUBNORMAL - ) { - return 'float64'; - } - // Any number which reaches this point is less than the maximum single-precision floating-point number, as floating-point format supports a limited number of decimals (e.g., (1.0+EPS)*10**15 => 1000000000000000.2, which is less than ~3.4e38)... - return 'float32'; -} - - -// EXPORTS // - -module.exports = minDataType; diff --git a/min-dtype/package.json b/min-dtype/package.json deleted file mode 100644 index d14b50df2..000000000 --- a/min-dtype/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/min-dtype", - "version": "0.0.0", - "description": "Determine the minimum array data type of the closest kind necessary for storing a provided scalar value.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "scalar", - "type", - "memory", - "minimum", - "dtype", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/min-dtype/test/test.js b/min-dtype/test/test.js deleted file mode 100644 index 7dab65e18..000000000 --- a/min-dtype/test/test.js +++ /dev/null @@ -1,234 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var PINF = require( '@stdlib/constants/float64/pinf' ); -var NINF = require( '@stdlib/constants/float64/ninf' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var minDataType = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof minDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns the minimum array data type of the closest "kind" necessary for storing a provided scalar value', function test( t ) { - var expected; - var actual; - var values; - var i; - - values = [ - NaN, - 0, - 0.0, - -0.0, - 1, - -1, - 300, // >2**8 - -300, - 65537, // >2**16 - -65537, - 4294967297, // >2**32 - -4294967297, - 3.14, - -3.14, - 1.0e40, // >10**38 - -1.0e40, - -1.0e-46, // <10**-45 - 1.0e-46, - PINF, - NINF, - 'beep', - {}, - true, - false, - [], - new Complex64( 3.0, 5.0 ), - new Complex128( 3.0, 5.0 ), - new Complex64( 1.0, 1.0 ), - new Complex64( NaN, NaN ), - new Complex64( PINF, PINF ), - new Complex64( PINF, NINF ), - new Complex64( PINF, NaN ), - new Complex64( NINF, PINF ), - new Complex64( NINF, NINF ), - new Complex64( NINF, NaN ), - new Complex128( 1.0, 1.0 ), - new Complex128( NaN, NaN ), - new Complex128( PINF, PINF ), - new Complex128( PINF, NINF ), - new Complex128( PINF, NaN ), - new Complex128( NINF, PINF ), - new Complex128( NINF, NINF ), - new Complex128( NINF, NaN ), - new Complex128( -1.0e-46, 1.0 ), - new Complex128( 1.0e-46, 1.0 ), - new Complex128( 1.0, -1.0e-46 ), - new Complex128( 1.0, 1.0e-46 ), - new Complex128( -1.0e40, 1.0 ), - new Complex128( 1.0e40, 1.0 ), - new Complex128( 1.0, -1.0e40 ), - new Complex128( 1.0, 1.0e40 ), - - { - 're': 3.0, - 'im': 5.0 - }, - { - 're': 4294967297, - 'im': 5.0 - }, - { - 're': 3.0, - 'im': 4294967297 - }, - { - 're': -4294967297, - 'im': 5.0 - }, - { - 're': 3.0, - 'im': -4294967297 - }, - { - 're': -1.0e-46, - 'im': 5.0 - }, - { - 're': 3.0, - 'im': -1.0e-46 - }, - { - 're': NaN, - 'im': 5.0 - }, - { - 're': 3.0, - 'im': NaN - }, - { - 're': PINF, - 'im': 5.0 - }, - { - 're': 3.0, - 'im': PINF - }, - { - 're': NINF, - 'im': 5.0 - }, - { - 're': 3.0, - 'im': NINF - }, - { - 're': 3.14, - 'im': 5.0 - }, - { - 're': 3.0, - 'im': 3.14 - } - ]; - expected = [ - 'float32', - 'uint8', - 'uint8', - 'float32', - 'uint8', - 'int8', - 'uint16', - 'int16', - 'uint32', - 'int32', - 'float64', - 'float64', - 'float32', - 'float32', - 'float64', - 'float64', - 'float64', - 'float64', - 'float32', - 'float32', - 'generic', - 'generic', - 'bool', - 'bool', - 'generic', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex128', - 'complex128', - 'complex128', - 'complex128', - 'complex128', - 'complex128', - 'complex128', - 'complex128', - - 'complex64', - 'complex128', - 'complex128', - 'complex128', - 'complex128', - 'complex128', - 'complex128', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64', - 'complex64' - - ]; - for ( i = 0; i < values.length; i++ ) { - actual = minDataType( values[i] ); - t.strictEqual( actual, expected[ i ], 'returns expected value when provided '+values[i] ); - } - t.end(); -}); diff --git a/mostly-safe-casts/README.md b/mostly-safe-casts/README.md deleted file mode 100644 index 5e53992f1..000000000 --- a/mostly-safe-casts/README.md +++ /dev/null @@ -1,161 +0,0 @@ - - -# Mostly Safe Casts - -> Return a list of array [data types][@stdlib/array/dtypes] to which a provided array [data type][@stdlib/array/dtypes] can be safely cast and, for floating-point data types, can be downcast. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var mostlySafeCasts = require( '@stdlib/array/mostly-safe-casts' ); -``` - -#### mostlySafeCasts( \[dtype] ) - -If provided a `dtype` argument, returns a list of array [data types][@stdlib/array/dtypes] to which a provided array [data type][@stdlib/array/dtypes] can be safely cast and, for floating-point data types, can be downcast. - -```javascript -var out = mostlySafeCasts( 'float32' ); -// e.g., returns [ 'float32', 'float64', ... ] -``` - -If not provided a `dtype` argument, the function returns a casting table. - -```javascript -var out = mostlySafeCasts(); -// returns {...} - -var f32 = out[ 'float32' ]; -// returns {...} - -var v = f32[ 'float64' ]; -// returns 1 -``` - -If provided an unrecognized or unsupported `dtype`, the function returns `null`. - -```javascript -var out = mostlySafeCasts( 'foo' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var mostlySafeCasts = require( '@stdlib/array/mostly-safe-casts' ); - -// Get the list of supported array data types: -var DTYPES = dtypes(); - -// Print the list of array data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/mostly-safe-casts/benchmark/benchmark.js b/mostly-safe-casts/benchmark/benchmark.js deleted file mode 100644 index 143743970..000000000 --- a/mostly-safe-casts/benchmark/benchmark.js +++ /dev/null @@ -1,71 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var dtypes = require( './../../dtypes' ); -var pkg = require( './../package.json' ).name; -var mostlySafeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = mostlySafeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/mostly-safe-casts/docs/repl.txt b/mostly-safe-casts/docs/repl.txt deleted file mode 100644 index ffe97879c..000000000 --- a/mostly-safe-casts/docs/repl.txt +++ /dev/null @@ -1,27 +0,0 @@ - -{{alias}}( [dtype] ) - Returns a list of array data types to which a provided array data type can - be safely cast and, for floating-point data types, can be downcast. - - If not provided an array data type, the function returns a casting table. - - If provided an unrecognized array data type, the function returns `null`. - - Parameters - ---------- - dtype: any (optional) - Array data type value. - - Returns - ------- - out: Object|Array|null - Array data types to which a data type can be cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/mostly-safe-casts/docs/types/index.d.ts b/mostly-safe-casts/docs/types/index.d.ts deleted file mode 100644 index 23eab4ffa..000000000 --- a/mostly-safe-casts/docs/types/index.d.ts +++ /dev/null @@ -1,41 +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. -*/ - -// TypeScript Version: 4.1 - -/** -* Returns a list of array data types to which a provided array data type can be safely cast and, for floating-point data types, can be downcast. -* -* ## Notes -* -* - If not provided an array data type, the function returns a casting table. -* - If provided an unrecognized array data type, the function returns `null`. -* -* @param dtype - array data type value -* @returns list of array data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -declare function mostlySafeCasts( dtype?: any ): any; // FIXME: use overloads to improve this definition - - -// EXPORTS // - -export = mostlySafeCasts; diff --git a/mostly-safe-casts/docs/types/test.ts b/mostly-safe-casts/docs/types/test.ts deleted file mode 100644 index 8866c042b..000000000 --- a/mostly-safe-casts/docs/types/test.ts +++ /dev/null @@ -1,34 +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. -*/ - -import mostlySafeCasts = require( './index' ); - - -// TESTS // - -// The function returns an object, array of strings, or null... -{ - mostlySafeCasts(); // $ExpectType any - mostlySafeCasts( 'float32' ); // $ExpectType any - mostlySafeCasts( 'float' ); // $ExpectType any -} - -// The compiler throws an error if the function is provided more than one argument... -{ - mostlySafeCasts( 'float32', 123 ); // $ExpectError -} diff --git a/mostly-safe-casts/examples/index.js b/mostly-safe-casts/examples/index.js deleted file mode 100644 index 5e63a45ac..000000000 --- a/mostly-safe-casts/examples/index.js +++ /dev/null @@ -1,33 +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. -*/ - -'use strict'; - -var dtypes = require( './../../dtypes' ); -var mostlySafeCasts = require( './../lib' ); - -// Get the list of supported array data types: -var DTYPES = dtypes(); - -// Print the list of array data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/mostly-safe-casts/lib/data.json b/mostly-safe-casts/lib/data.json deleted file mode 100644 index a9bbcbc7e..000000000 --- a/mostly-safe-casts/lib/data.json +++ /dev/null @@ -1,197 +0,0 @@ -{ - "float64": { - "float64": 1, - "float32": 1, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "float32": { - "float64": 1, - "float32": 1, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "int32": { - "float64": 1, - "float32": 0, - "int32": 1, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 0, - "bool": 0, - "generic": 1 - }, - "int16": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "int8": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 1, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "uint32": { - "float64": 1, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 1, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 0, - "bool": 0, - "generic": 1 - }, - "uint16": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 0, - "int8": 0, - "uint32": 1, - "uint16": 1, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "uint8": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 0, - "uint32": 1, - "uint16": 1, - "uint8": 1, - "uint8c": 1, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "uint8c": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 0, - "uint32": 1, - "uint16": 1, - "uint8": 1, - "uint8c": 1, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "complex128": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "complex64": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "bool": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 0, - "complex64": 0, - "bool": 1, - "generic": 1 - }, - "generic": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 0, - "complex64": 0, - "bool": 0, - "generic": 1 - } -} diff --git a/mostly-safe-casts/lib/index.js b/mostly-safe-casts/lib/index.js deleted file mode 100644 index 14cbc333f..000000000 --- a/mostly-safe-casts/lib/index.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -/** -* Return a list of array data types to which a provided array data type can be safely cast and, for floating-point data types, can be downcast. -* -* @module @stdlib/array/mostly-safe-casts -* -* @example -* var mostlySafeCasts = require( '@stdlib/array/mostly-safe-casts' ); -* -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/mostly-safe-casts/lib/main.js b/mostly-safe-casts/lib/main.js deleted file mode 100644 index c0612a63a..000000000 --- a/mostly-safe-casts/lib/main.js +++ /dev/null @@ -1,135 +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. -*/ - -'use strict'; - -// MODULES // - -var objectKeys = require( '@stdlib/utils/keys' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var resolve = require( '@stdlib/strided/base/dtype-resolve-str' ); -var CASTS = require( './data.json' ); - - -// VARIABLES // - -var TABLE; - - -// FUNCTIONS // - -/** -* Generates a full table of casts for each array data type. -* -* @private -* @returns {Object} table -*/ -function generateFullTable() { - var dtypes; - var ntypes; - var out; - var tmp; - var dt1; - var dt2; - var o; - var j; - var i; - - out = {}; - dtypes = objectKeys( CASTS ); - ntypes = dtypes.length; - for ( i = 0; i < ntypes; i++ ) { - dt1 = dtypes[ i ]; - o = CASTS[ dt1 ]; - tmp = {}; - for ( j = 0; j < ntypes; j++ ) { - dt2 = dtypes[ j ]; - tmp[ dt2 ] = o[ dt2 ]; - } - out[ dt1 ] = tmp; - } - return out; -} - -/** -* Generates a table of casts for each array data type. -* -* @private -* @returns {Object} table -*/ -function generateTable() { - var dtypes; - var ntypes; - var out; - var tmp; - var dt1; - var dt2; - var o; - var j; - var i; - - out = {}; - dtypes = objectKeys( CASTS ); - ntypes = dtypes.length; - for ( i = 0; i < ntypes; i++ ) { - dt1 = dtypes[ i ]; - o = CASTS[ dt1 ]; - tmp = []; - for ( j = 0; j < ntypes; j++ ) { - dt2 = dtypes[ j ]; - if ( o[ dt2 ] === 1 ) { - tmp.push( dt2 ); - } - } - out[ dt1 ] = tmp; - } - return out; -} - - -// MAIN // - -/** -* Returns a list of array data types to which a provided array data type can be safely cast and, for floating-point data types, can be downcast. -* -* @param {*} [dtype] - array data type value -* @returns {(Object|StringArray|null)} list of array data types or null -* -* @example -* var list = mostlySafeCasts( 'float32' ); -* // returns [...] -*/ -function mostlySafeCasts( dtype ) { - if ( arguments.length === 0 ) { - return generateFullTable(); - } - if ( TABLE === void 0 ) { - // Lazily generate table... - TABLE = generateTable(); - } - dtype = resolve( dtype ); - if ( hasOwnProp( TABLE, dtype ) ) { - return TABLE[ dtype ].slice(); - } - return null; -} - - -// EXPORTS // - -module.exports = mostlySafeCasts; diff --git a/mostly-safe-casts/package.json b/mostly-safe-casts/package.json deleted file mode 100644 index 5501e85d6..000000000 --- a/mostly-safe-casts/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/mostly-safe-casts", - "version": "0.0.0", - "description": "Return a list of array data types to which a provided array data type can be safely cast and, for floating-point data types, can be downcast.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "casting", - "cast", - "rules", - "promotion", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/mostly-safe-casts/test/test.js b/mostly-safe-casts/test/test.js deleted file mode 100644 index 7e1f842fd..000000000 --- a/mostly-safe-casts/test/test.js +++ /dev/null @@ -1,75 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( './../../dtypes' ); -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var mostlySafeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mostlySafeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = mostlySafeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of array data types to which a provided array data type can be cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = mostlySafeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( mostlySafeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/mskfilter/README.md b/mskfilter/README.md deleted file mode 100644 index 71dde9e7a..000000000 --- a/mskfilter/README.md +++ /dev/null @@ -1,122 +0,0 @@ - - -# mskfilter - -> Apply a mask to a provided input array. - -
- -## Usage - -```javascript -var mskfilter = require( '@stdlib/array/mskfilter' ); -``` - -#### mskfilter( x, mask ) - -Returns a new array by applying a mask to a provided input array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -// returns [ 2, 4 ] -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. - -
- - - -
- -## Notes - -- If a `mask` array element is truthy, the corresponding element in `x` is **included** in the output array; otherwise, the corresponding element in `x` is "masked" and thus **excluded** from the output array. -- If provided an input array having a recognized [data type][@stdlib/array/dtypes], the function returns an array having the same [data type][@stdlib/array/dtypes] as the input array. Otherwise, the function **always** returns a "generic" array. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskfilter = require( '@stdlib/array/mskfilter' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20, 'generic' ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilter( x, mask ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/mskfilter/benchmark/benchmark.js b/mskfilter/benchmark/benchmark.js deleted file mode 100644 index f16ee9b5b..000000000 --- a/mskfilter/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../base/zero-to' ); -var ones = require( './../../base/ones' ); -var pkg = require( './../package.json' ).name; -var mskfilter = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = ones( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilter( x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/mskfilter/benchmark/benchmark.length.js b/mskfilter/benchmark/benchmark.length.js deleted file mode 100644 index 8d085694d..000000000 --- a/mskfilter/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../base/zero-to' ); -var ones = require( './../../base/ones' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var mskfilter = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = ones( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskfilter( x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/mskfilter/docs/repl.txt b/mskfilter/docs/repl.txt deleted file mode 100644 index 07adc4dd5..000000000 --- a/mskfilter/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input array. - - If a mask array element is truthy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` is - "masked" and thus excluded from the output array. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - mask: Array|TypedArray|Object - Mask array. - - Returns - ------- - out: Array|TypedArray|Object - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 2, 4 ] - - See Also - -------- - diff --git a/mskfilter/docs/types/index.d.ts b/mskfilter/docs/types/index.d.ts deleted file mode 100644 index 2436ebe22..000000000 --- a/mskfilter/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskfilter( x, [ 0, 1, 0, 1 ] ); -* // returns [ 2, 4 ] -*/ -declare function mskfilter( x: Collection, mask: Collection ): Collection; // FIXME: use type maps once associated PR merged - - -// EXPORTS // - -export = mskfilter; diff --git a/mskfilter/docs/types/test.ts b/mskfilter/docs/types/test.ts deleted file mode 100644 index a36fcb7c8..000000000 --- a/mskfilter/docs/types/test.ts +++ /dev/null @@ -1,57 +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. -*/ - -import mskfilter = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType Collection - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType Collection - mskfilter( [ 1, 2, 3, 4 ], [ 0, 0 ] ); // $ExpectType Collection - mskfilter( [ '1', '2', '3', '4' ], [ 0, 0 ] ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskfilter( 1, [ 0, 0 ] ); // $ExpectError - mskfilter( true, [ 0, 0 ] ); // $ExpectError - mskfilter( false, [ 0, 0 ] ); // $ExpectError - mskfilter( null, [ 0, 0 ] ); // $ExpectError - mskfilter( void 0, [ 0, 0 ] ); // $ExpectError - mskfilter( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskfilter( [], 1 ); // $ExpectError - mskfilter( [], true ); // $ExpectError - mskfilter( [], false ); // $ExpectError - mskfilter( [], null ); // $ExpectError - mskfilter( [], void 0 ); // $ExpectError - mskfilter( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskfilter(); // $ExpectError - mskfilter( [] ); // $ExpectError - mskfilter( [], [], [] ); // $ExpectError -} diff --git a/mskfilter/examples/index.js b/mskfilter/examples/index.js deleted file mode 100644 index 7918b1342..000000000 --- a/mskfilter/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var zeroTo = require( './../../zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskfilter = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20, 'generic' ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskfilter( x, mask ); -console.log( y ); diff --git a/mskfilter/lib/index.js b/mskfilter/lib/index.js deleted file mode 100644 index c9d7fe59b..000000000 --- a/mskfilter/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array/mskfilter -* -* @example -* var mskfilter = require( '@stdlib/array/mskfilter' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/mskfilter/lib/main.js b/mskfilter/lib/main.js deleted file mode 100644 index 08e11da53..000000000 --- a/mskfilter/lib/main.js +++ /dev/null @@ -1,80 +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. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert/is-collection' ); -var base = require( './../../base/mskfilter' ); -var countTruthy = require( './../../base/count-truthy' ); -var zeros = require( './../../zeros' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} second argument must be a collection -* @throws {Error} must provide collections of equal length -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskfilter( x, mask ); -* // returns [ 2, 4 ] -*/ -function mskfilter( x, mask ) { - var dt; - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) ); - } - if ( !isCollection( mask ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) ); - } - if ( x.length !== mask.length ) { - throw new Error( format( 'invalid arguments. Must provide equal length array-like objects.' ) ); - } - dt = dtype( x ); - if ( dt === 'generic' || dt === null ) { - return base( x, mask ); - } - return base.assign( x, mask, zeros( countTruthy( mask ), dt ), 1, 0 ); -} - - -// EXPORTS // - -module.exports = mskfilter; diff --git a/mskfilter/package.json b/mskfilter/package.json deleted file mode 100644 index 90ea1324e..000000000 --- a/mskfilter/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/mskfilter", - "version": "0.0.0", - "description": "Apply a mask to a provided input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index", - "mask", - "filter", - "reject" - ] -} diff --git a/mskfilter/test/test.js b/mskfilter/test/test.js deleted file mode 100644 index 7d2935b0d..000000000 --- a/mskfilter/test/test.js +++ /dev/null @@ -1,277 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var Complex64Array = require( './../../complex64' ); -var Int32Array = require( './../../int32' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var zeros = require( './../../zeros' ); -var mskfilter = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskfilter, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskfilter( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskfilter( [], value ); - }; - } -}); - -tape( 'the function throws an error if provided collections of unequal length', function test( t ) { - var values; - var i; - - values = [ - [], - [ 1 ], - [ 1, 2 ], - [ 1, 2, 3 ], - [ 1, 2, 3, 4 ], - [ 1, 2, 3, 4, 5, 6 ], - [ 1, 2, 3, 4, 5, 6, 7 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskfilter( value, zeros( 5, 'generic' ) ); - }; - } -}); - -tape( 'the function filters array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - expected = [ 2, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilter( x, mask ); - expected = [ 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - actual = mskfilter( x, mask ); - expected = [ 2, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = mskfilter( x, mask ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = toAccessorArray( [ 0, 0, 0, 1 ] ); - actual = mskfilter( x, mask ); - expected = [ 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - expected = [ 2, 4 ]; - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask ); - expected = []; - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilter( x, mask ); - expected = [ 4 ]; - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilter( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 0, 1, 0, 1 ]; - actual = mskfilter( x, mask ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - t.notEqual( actual, x, 'returns new array' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskfilter( x, mask ); - expected = new Complex64Array( [] ); - t.notEqual( actual, x, 'returns new array' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 1 ]; - actual = mskfilter( x, mask ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - t.notEqual( actual, x, 'returns new array' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskfilter( x, mask ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - t.notEqual( actual, x, 'returns new array' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskfilter( [], [] ), [], 'returns expected value' ); - t.deepEqual( mskfilter( new Int32Array( [] ), [] ), new Int32Array( [] ), 'returns expected value' ); - t.end(); -}); diff --git a/mskput/README.md b/mskput/README.md deleted file mode 100644 index f5a512853..000000000 --- a/mskput/README.md +++ /dev/null @@ -1,183 +0,0 @@ - - -# mskput - -> Replace elements of an array with provided values according to a provided mask array. - -
- -## Usage - -```javascript -var mskput = require( '@stdlib/array/mskput' ); -``` - -#### mskput( x, mask, values\[, options] ) - -Replaces elements of an array with provided values according to a provided mask array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = mskput( x, [ 1, 0, 1, 0 ], [ 20, 40 ] ); -// returns [ 1, 20, 3, 40 ] - -var bool = ( out === x ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. -- **values**: values to set. -- **options**: function options. - -The function supports the following options: - -- **mode**: string specifying behavior when the number of `values` does not equal the number of falsy `mask` values. Default: `'repeat'`. - -The function supports the following modes: - -- `'strict'`: specifies that the function must raise an exception when the number of `values` does not **exactly** equal the number of falsy `mask` values. -- `'non_strict'`: specifies that the function must raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -- `'strict_broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the number of `values` does not **exactly** equal the number of falsy `mask` values. -- `'broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -- `'repeat'`: specifies that the function must reuse provided `values` when replacing elements in `x` in order to satisfy the `mask` array. - -In broadcasting modes, the function supports broadcasting a `values` array containing a single element against the number of falsy values in the `mask` array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = mskput( x, [ 1, 0, 1, 0 ], [ 20 ], { - 'mode': 'strict_broadcast' -}); -// returns [ 1, 20, 3, 20 ] - -var bool = ( out === x ); -// returns true -``` - -In repeat mode, the function supports recycling elements in a `values` array to satisfy the number of falsy values in the `mask` array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = mskput( x, [ 0, 0, 1, 0 ], [ 20, 40 ], { - 'mode': 'repeat' -}); -// returns [ 20, 40, 3, 20 ] - -var bool = ( out === x ); -// returns true -``` - -
- - - -
- -## Notes - -- The function mutates the input array `x`. -- If a `mask` array element is falsy, the corresponding element in `x` is **replaced**; otherwise, the corresponding element in `x` is "masked" and thus left unchanged. -- The `values` array must have a [data type][@stdlib/array/dtypes] which can be [safely cast][@stdlib/array/safe-casts] to the input array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the [same kind][@stdlib/array/same-kind-casts] (e.g., element values from a `'float64'` values array can be assigned to corresponding elements in a `'float32'` input array). - -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var linspace = require( '@stdlib/array/base/linspace' ); -var mskput = require( '@stdlib/array/mskput' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate a random mask array: -var N = discreteUniform( 5, 15 ); -var mask = filledBy( N, bernoulli.factory( 0.3 ) ); -console.log( mask ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = mskput( x, mask, values ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/mskput/benchmark/benchmark.js b/mskput/benchmark/benchmark.js deleted file mode 100644 index f276a3412..000000000 --- a/mskput/benchmark/benchmark.js +++ /dev/null @@ -1,79 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../base/zero-to' ); -var zeros = require( './../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var mskput = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::no_broadcasting:len=100', function benchmark( b ) { - var mask; - var x; - var i; - var v; - - x = zeroTo( 100 ); - mask = zeros( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskput( x, mask, x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::broadcasting:len=100', function benchmark( b ) { - var mask; - var x; - var i; - var v; - - x = zeroTo( 100 ); - mask = zeros( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskput( x, mask, [ i ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/mskput/benchmark/benchmark.length.js b/mskput/benchmark/benchmark.length.js deleted file mode 100644 index 860c9d224..000000000 --- a/mskput/benchmark/benchmark.length.js +++ /dev/null @@ -1,113 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeros = require( './../../base/zeros' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var mskput = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'dtype': 'generic' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var mask; - var x; - - x = discreteUniform( len, 0, 10, opts ); - mask = zeros( len ); - values = [ - discreteUniform( len, -10, 0, opts ), - discreteUniform( len, 0, 10, opts ) - ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskput( x, mask, values[ i%values.length ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/mskput/docs/repl.txt b/mskput/docs/repl.txt deleted file mode 100644 index ddeb6756c..000000000 --- a/mskput/docs/repl.txt +++ /dev/null @@ -1,68 +0,0 @@ - -{{alias}}( x, mask, values[, options] ) - Replaces elements of an array with provided values according to a provided - mask array. - - In broadcasting modes, the function supports broadcasting a values array - containing a single element against the number of falsy values in the mask - array. - - In repeat mode, the function supports recycling elements in a values array - to satisfy the number of falsy values in the mask array. - - The function mutates the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. If a mask array element is falsy, the corresponding element - in `x` is *replaced*; otherwise, the corresponding element in `x` is - "masked" and thus left unchanged. - - values: ArrayLikeObject - Values to set. - - options: Object (optional) - Function options. - - options.mode: string (optional) - String specifying behavior when the number of values to set does not - equal the number of falsy mask values. The function supports the - following modes: - - - 'strict': specifies that the function must raise an exception when the - number of values does not *exactly* equal the number of falsy mask - values. - - 'non_strict': specifies that the function must raise an exception when - the function is provided insufficient values to satisfy the mask array. - - 'strict_broadcast': specifies that the function must broadcast a - single-element values array and otherwise raise an exception when the - number of values does not **exactly** equal the number of falsy mask - values. - - 'broadcast': specifies that the function must broadcast a single- - element values array and otherwise raise an exception when the function - is provided insufficient values to satisfy the mask array. - - 'repeat': specifies that the function must reuse provided values when - replacing elements in `x` in order to satisfy the mask array. - - Default: 'repeat'. - - Returns - ------- - out: ArrayLikeObject - Input array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x, [ 1, 0, 1, 0 ], [ 20, 40 ] ) - [ 1, 20, 3, 40 ] - > var bool = ( out === x ) - true - - See Also - -------- - diff --git a/mskput/docs/types/index.d.ts b/mskput/docs/types/index.d.ts deleted file mode 100644 index 105a9874e..000000000 --- a/mskput/docs/types/index.d.ts +++ /dev/null @@ -1,232 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; - -/** -* Mask array. -*/ -type MaskArray = Collection | AccessorArrayLike; - -/** -* Values array. -*/ -type ValuesArray = Collection | AccessorArrayLike; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Mode specifying behavior when the number of values to set does not equal the number of falsy values in the mask array. - * - * ## Notes - * - * - The function supports the following modes: - * - * - `'strict'`: specifies that the function must raise an exception when the number of `values` does not **exactly** equal the number of falsy `mask` values. - * - `'non_strict'`: specifies that the function must raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. - * - `'strict_broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the number of `values` does not **exactly** equal the number of falsy `mask` values. - * - `'broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. - * - `'repeat'`: specifies that the function must reuse provided `values` when replacing elements in `x` in order to satisfy the `mask` array. - */ - mode?: 'strict' | 'non_strict' | 'strict_broadcast' | 'broadcast' | 'repeat'; -} - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var out = mskput( x, [ 1, 0, 0, 1 ], [ 30 ] ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function mskput( x: T, mask: MaskArray, values: ValuesArray, options?: Options ): T; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = new Complex128Array( [ 20.0, 30.0, 40, 5.0 ] ); -* -* var out = mskput( x, mask, values ); -* // returns -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = new Complex128Array( [ 20.0, 30.0 ] ); -* -* var out = mskput( x, mask, values ); -* // returns -* -* var bool = ( out === x ); -* // returns true -*/ -declare function mskput( x: T, mask: MaskArray, values: ValuesArray, options?: Options ): T; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = mskput( x, [ 1, 0, 0, 1 ], [ 30 ] ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function mskput( x: Array, mask: MaskArray, values: ValuesArray, options?: Options ): Array; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values ); -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var out = mskput( x, [ 1, 0, 0, 1 ], [ 30 ] ); -* -* var bool = ( out === x ); -* // returns true -*/ -declare function mskput( x: AccessorArrayLike, mask: MaskArray, values: ValuesArray, options?: Options ): AccessorArrayLike; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = mskput( x, [ 1, 0, 0, 1 ], [ 30 ] ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function mskput( x: Collection, mask: MaskArray, values: ValuesArray, options?: Options ): Collection; - - -// EXPORTS // - -export = mskput; diff --git a/mskput/docs/types/test.ts b/mskput/docs/types/test.ts deleted file mode 100644 index ab4b54a97..000000000 --- a/mskput/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import AccessorArray = require( './../../../base/accessor' ); -import mskput = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskput( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectType number[] - mskput( new Int32Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectType Int32Array - mskput( new Complex128Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ] ); // $ExpectType Complex128Array - mskput( new Complex64Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ] ); // $ExpectType Complex64Array - mskput( new AccessorArray( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], new AccessorArray( [ 20, 30 ] ) ); // $ExpectType AccessorArrayLike -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskput( 1, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError - mskput( true, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError - mskput( false, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError - mskput( null, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError - mskput( void 0, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError - mskput( {}, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - mskput( [], 1, [ 20, 30 ] ); // $ExpectError - mskput( [], true, [ 20, 30 ] ); // $ExpectError - mskput( [], false, [ 20, 30 ] ); // $ExpectError - mskput( [], null, [ 20, 30 ] ); // $ExpectError - mskput( [], void 0, [ 20, 30 ] ); // $ExpectError - mskput( [], {}, [ 20, 30 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object... -{ - mskput( [], [ 1, 0, 0, 1 ], 1 ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], true ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], false ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], null ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], void 0 ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an object... -{ - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], '1' ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], 1 ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], true ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], false ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], null ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], [] ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': '1' } ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': 1 } ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': true } ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': false } ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': null } ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': {} } ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': [] } ); // $ExpectError - mskput( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskput(); // $ExpectError - mskput( [] ); // $ExpectError - mskput( [], [] ); // $ExpectError - mskput( [], [], [], {}, {} ); // $ExpectError -} diff --git a/mskput/examples/index.js b/mskput/examples/index.js deleted file mode 100644 index 78c40fafa..000000000 --- a/mskput/examples/index.js +++ /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. -*/ - -'use strict'; - -var filledBy = require( './../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var linspace = require( './../../base/linspace' ); -var mskput = require( './../lib' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate a random mask array: -var N = discreteUniform( 5, 15 ); -var mask = filledBy( N, bernoulli.factory( 0.3 ) ); -console.log( mask ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = mskput( x, mask, values ); -console.log( out ); diff --git a/mskput/lib/defaults.js b/mskput/lib/defaults.js deleted file mode 100644 index ae985155c..000000000 --- a/mskput/lib/defaults.js +++ /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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns default options. -* -* @private -* @returns {Object} default options -* -* @example -* var o = defaults(); -* // returns {...} -*/ -function defaults() { - return { - 'mode': 'repeat' - }; -} - - -// EXPORTS // - -module.exports = defaults; diff --git a/mskput/lib/index.js b/mskput/lib/index.js deleted file mode 100644 index d0d90b4a9..000000000 --- a/mskput/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Replace elements of an array with provided values according to a provided mask array. -* -* @module @stdlib/array/mskput -* -* @example -* var mskput = require( '@stdlib/array/mskput' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/mskput/lib/main.js b/mskput/lib/main.js deleted file mode 100644 index aaf80b55a..000000000 --- a/mskput/lib/main.js +++ /dev/null @@ -1,130 +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. -*/ - -'use strict'; - -// MODULES // - -var isMostlySafeCast = require( './../../base/assert/is-mostly-safe-data-type-cast' ); -var isRealDataType = require( './../../base/assert/is-real-data-type' ); -var isComplexDataType = require( './../../base/assert/is-complex-floating-point-data-type' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var base = require( './../../base/mskput' ); -var dtype = require( './../../dtype' ); -var convert = require( './../../convert' ); -var format = require( '@stdlib/string/format' ); -var defaults = require( './defaults.js' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} values - values to set -* @param {Options} [options] - function options -* @param {string} [options.mode='repeat'] - string specifying behavior when the number of values does not equal the number of falsy mask values -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} second argument must be a collection -* @throws {TypeError} third argument must be a collection -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @throws {Error} insufficient values to satisfy mask array -* @throws {Error} number of values does not equal the number of falsy mask values -* @throws {TypeError} third argument cannot be safely cast to the data type of the first argument -* @returns {Collection} input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 0, 0, 1 ]; -* var values = [ 30 ]; -* -* var out = mskput( x, mask, values ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 0, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = mskput( x, mask, values ); -* // returns [ 20, 30, 3, 20 ] -* -* var bool = ( out === x ); -* // returns true -*/ -function mskput( x, mask, values ) { - var opts; - var err; - var xdt; - var vdt; - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) ); - } - if ( !isCollection( mask ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) ); - } - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', values ) ); - } - opts = defaults(); - if ( arguments.length > 3 ) { - err = validate( opts, arguments[ 3 ] ); - if ( err ) { - throw err; - } - } - xdt = dtype( x ) || 'generic'; - vdt = dtype( values ) || 'generic'; - - // Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the input array data type is floating-point... - if ( !isMostlySafeCast( vdt, xdt ) ) { - throw new TypeError( format( 'invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].', vdt, xdt ) ); - } - // When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array... - if ( isComplexDataType( xdt ) && isRealDataType( vdt ) ) { - values = convert( values, xdt ); - } - // Replace values in the input array: - return base( x, mask, values, opts.mode ); -} - - -// EXPORTS // - -module.exports = mskput; diff --git a/mskput/lib/validate.js b/mskput/lib/validate.js deleted file mode 100644 index acb459514..000000000 --- a/mskput/lib/validate.js +++ /dev/null @@ -1,78 +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. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert/is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var contains = require( './../../base/assert/contains' ).factory; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var MODES = [ - 'strict', - 'non_strict', - 'strict_broadcast', - 'broadcast', - 'repeat' -]; -var isMode = contains( MODES ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.mode] - mode option -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'mode': 'strict' -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - if ( !isMode( opts.mode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'mode', MODES.join( '", "' ), opts.mode ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/mskput/package.json b/mskput/package.json deleted file mode 100644 index a3730c387..000000000 --- a/mskput/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/mskput", - "version": "0.0.0", - "description": "Replace elements of an array with provided values according to a provided mask array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "set", - "replace", - "put", - "update", - "mask", - "missing", - "na" - ] -} diff --git a/mskput/test/test.js b/mskput/test/test.js deleted file mode 100644 index f76588f8e..000000000 --- a/mskput/test/test.js +++ /dev/null @@ -1,696 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../complex64' ); -var Int32Array = require( './../../int32' ); -var BooleanArray = require( './../../bool' ); -var zeros = require( './../../zeros' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var isAccessorArray = require( '@stdlib/assert/is-accessor-array' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var mskput = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskput, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskput( value, [], [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskput( value, [], [], {} ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskput( [], value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskput( [], value, [], {} ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskput( [], [], value ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskput( [], [], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskput( [], [], [], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a valid mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskput( [], [], [], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which cannot be safely cast to the input array data type', function test( t ) { - var values; - var x; - var i; - - values = zeros( 5, 'float64' ); - - x = [ - zeros( 5, 'uint8' ), - zeros( 5, 'int8' ), - zeros( 5, 'int16' ), - zeros( 5, 'uint16' ) - ]; - for ( i = 0; i < x.length; i++ ) { - t.throws( badValue( x[ i ] ), TypeError, 'throws an error when provided ' + x[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskput( value, zeros( 5, 'generic' ), values ); - }; - } -}); - -tape( 'the function replaces elements in an array (generic)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 0, 1, 0 ]; - actual = mskput( x, mask, [ 20, 40 ] ); - expected = [ 1, 20, 3, 40 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, [ 20, 30, 40, 50 ] ); - expected = [ 20, 30, 40, 50 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - actual = mskput( x, mask, [ 20, 30, 40, 50 ] ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (generic, broadcasting)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 0, 1, 0 ]; - actual = mskput( x, mask, [ 20 ] ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, [ 20 ] ); - expected = [ 20, 20, 20, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - actual = mskput( x, mask, [ 20 ] ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, [ 100, 200 ] ); - expected = [ 100, 200, 100, 200 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (typed)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 0, 1, 0 ]; - actual = mskput( x, mask, new Int32Array( [ 20, 40 ] ) ); - expected = new Int32Array( [ 1, 20, 3, 40 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, new Int32Array( [ 20, 30, 40, 50 ] ) ); - expected = new Int32Array( [ 20, 30, 40, 50 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 1, 1, 1 ]; - actual = mskput( x, mask, new Int32Array( [ 20, 30, 40, 50 ] ) ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (typed, broadcasting)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 0, 1, 0 ]; - actual = mskput( x, mask, new Int32Array( [ 20 ] ) ); - expected = new Int32Array( [ 1, 20, 3, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, new Int32Array( [ 20 ] ) ); - expected = new Int32Array( [ 20, 20, 20, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 1, 1, 1 ]; - actual = mskput( x, mask, new Int32Array( [ 20 ] ) ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 0, 0, 0 ]; - actual = mskput( x, mask, new Int32Array( [ 100, 200 ] ) ); - expected = new Int32Array( [ 100, 200, 100, 200 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - actual = mskput( toAccessorArray( x ), mask, toAccessorArray( [ 20, 40 ] ) ); // eslint-disable-line max-len - expected = [ 1, 20, 3, 40 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = mskput( toAccessorArray( x ), mask, toAccessorArray( [ 20, 30, 40, 50 ] ) ); // eslint-disable-line max-len - expected = [ 20, 30, 40, 50 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = mskput( toAccessorArray( x ), mask, [ 20, 30, 40, 50 ] ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, broadcasting)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - actual = mskput( toAccessorArray( x ), mask, toAccessorArray( [ 20 ] ) ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = mskput( toAccessorArray( x ), mask, toAccessorArray( [ 20 ] ) ); - expected = [ 20, 20, 20, 20 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = mskput( toAccessorArray( x ), mask, toAccessorArray( [ 20 ] ) ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = mskput( toAccessorArray( x ), mask, toAccessorArray( [ 100, 200 ] ) ); // eslint-disable-line max-len - expected = [ 100, 200, 100, 200 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - values = new Complex64Array( [ 30.0, 40.0, 70.0, 80.0 ] ); - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 30.0, 40.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 70.0, 80.0 ) - ]; - actual = mskput( x, mask, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex, broadcasting)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - values = new Complex64Array( [ 100.0, 200.0 ] ); - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 100.0, 200.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 100.0, 200.0 ) - ]; - actual = mskput( x, mask, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - mask = toAccessorArray( [ 1, 0, 1, 0 ] ); - values = new BooleanArray( [ true, false ] ); - expected = [ true, true, false, true ]; - actual = mskput( x, mask, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean, broadcasting)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - mask = toAccessorArray( [ 1, 0, 0, 1 ] ); - values = new BooleanArray( [ true ] ); - expected = [ true, true, true, true ]; - actual = mskput( x, mask, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'when the "mode" is "strict", the function throws an error if provided insufficient values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200 ], { - 'mode': 'strict' - }); - } -}); - -tape( 'when the "mode" is "strict", the function throws an error if provided too many values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200, 300, 400, 500, 600 ], { - 'mode': 'strict' - }); - } -}); - -tape( 'when the "mode" is "non_strict", the function throws an error if provided insufficient values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200 ], { - 'mode': 'non_strict' - }); - } -}); - -tape( 'when the "mode" is "strict_broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of falsy values in a mask array (insufficient)', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200, 400 ], { - 'mode': 'strict_broadcast' - }); - } -}); - -tape( 'when the "mode" is "strict_broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of falsy values in a mask array (too many)', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200, 400, 500, 600, 700 ], { - 'mode': 'strict_broadcast' - }); - } -}); - -tape( 'when the "mode" is "broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of falsy values in a mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - mskput( x, mask, [ 200, 400 ], { - 'mode': 'broadcast' - }); - } -}); diff --git a/mskput/test/test.validate.js b/mskput/test/test.validate.js deleted file mode 100644 index 502392108..000000000 --- a/mskput/test/test.validate.js +++ /dev/null @@ -1,128 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if not provided an options object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[i] ); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `mode` option which is not a valid index mode', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'mode': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns `null` if all options are valid', function test( t ) { - var expected; - var options; - var opts; - var err; - - options = { - 'mode': 'strict' - }; - opts = {}; - - expected = { - 'mode': 'strict' - }; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function ignores unrecognized options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': 'boop', - 'foo': 5, - 'bar': {} - }; - - opts = {}; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, {}, 'returns expected value' ); - - t.end(); -}); diff --git a/mskreject/README.md b/mskreject/README.md deleted file mode 100644 index 953ea6229..000000000 --- a/mskreject/README.md +++ /dev/null @@ -1,122 +0,0 @@ - - -# mskreject - -> Apply a mask to a provided input array. - -
- -## Usage - -```javascript -var mskreject = require( '@stdlib/array/mskreject' ); -``` - -#### mskreject( x, mask ) - -Returns a new array by applying a mask to a provided input array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var y = mskreject( x, [ 0, 1, 0, 1 ] ); -// returns [ 1, 3 ] -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. - -
- - - -
- -## Notes - -- If a `mask` array element is falsy, the corresponding element in `x` is **included** in the output array; otherwise, the corresponding element in `x` is "masked" and thus **excluded** from the output array. -- If provided an input array having a recognized [data type][@stdlib/array/dtypes], the function returns an array having the same [data type][@stdlib/array/dtypes] as the input array. Otherwise, the function **always** returns a "generic" array. - -
- - - -
- -## Examples - - - -```javascript -var zeroTo = require( '@stdlib/array/zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskreject = require( '@stdlib/array/mskreject' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20, 'generic' ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskreject( x, mask ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/mskreject/benchmark/benchmark.js b/mskreject/benchmark/benchmark.js deleted file mode 100644 index dbc22a842..000000000 --- a/mskreject/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../base/zero-to' ); -var zeros = require( './../../base/zeros' ); -var pkg = require( './../package.json' ).name; -var mskreject = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var y; - var i; - var v; - - x = zeroTo( 100 ); - y = zeros( x.length ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskreject( x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/mskreject/benchmark/benchmark.length.js b/mskreject/benchmark/benchmark.length.js deleted file mode 100644 index 809ebfdb9..000000000 --- a/mskreject/benchmark/benchmark.length.js +++ /dev/null @@ -1,97 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var zeroTo = require( './../../base/zero-to' ); -var zeros = require( './../../base/zeros' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var mskreject = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeroTo( len ); - var y = zeros( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = mskreject( x, y ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/mskreject/docs/repl.txt b/mskreject/docs/repl.txt deleted file mode 100644 index 661b765f3..000000000 --- a/mskreject/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( x, mask ) - Returns a new array by applying a mask to a provided input array. - - If a mask array element is falsy, the corresponding element in `x` is - included in the output array; otherwise, the corresponding element in `x` is - "masked" and thus excluded from the output array. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - mask: Array|TypedArray|Object - Mask array. - - Returns - ------- - out: Array|TypedArray|Object - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 0, 1, 0, 1 ] ) - [ 1, 3 ] - - See Also - -------- - diff --git a/mskreject/docs/types/index.d.ts b/mskreject/docs/types/index.d.ts deleted file mode 100644 index c258f131d..000000000 --- a/mskreject/docs/types/index.d.ts +++ /dev/null @@ -1,43 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param x - input array -* @param mask - mask array -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = mskreject( x, [ 0, 1, 0, 1 ] ); -* // returns [ 1, 3 ] -*/ -declare function mskreject( x: Collection, mask: Collection ): Collection; // FIXME: use type maps once associated PR merged - - -// EXPORTS // - -export = mskreject; diff --git a/mskreject/docs/types/test.ts b/mskreject/docs/types/test.ts deleted file mode 100644 index 51a69f8ab..000000000 --- a/mskreject/docs/types/test.ts +++ /dev/null @@ -1,57 +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. -*/ - -import mskreject = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - mskreject( [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ] ); // $ExpectType Collection - mskreject( [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ] ); // $ExpectType Collection - mskreject( [ 1, 2, 3, 4 ], [ 0, 0, 0, 0 ] ); // $ExpectType Collection - mskreject( [ '1', '2', '3', '4' ], [ 0, 0, 0, 0 ] ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - mskreject( 1, [ 0, 0 ] ); // $ExpectError - mskreject( true, [ 0, 0 ] ); // $ExpectError - mskreject( false, [ 0, 0 ] ); // $ExpectError - mskreject( null, [ 0, 0 ] ); // $ExpectError - mskreject( void 0, [ 0, 0 ] ); // $ExpectError - mskreject( {}, [ 0, 0 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - mskreject( [], 1 ); // $ExpectError - mskreject( [], true ); // $ExpectError - mskreject( [], false ); // $ExpectError - mskreject( [], null ); // $ExpectError - mskreject( [], void 0 ); // $ExpectError - mskreject( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - mskreject(); // $ExpectError - mskreject( [] ); // $ExpectError - mskreject( [], [], [] ); // $ExpectError -} diff --git a/mskreject/examples/index.js b/mskreject/examples/index.js deleted file mode 100644 index 5cb8fb6f1..000000000 --- a/mskreject/examples/index.js +++ /dev/null @@ -1,37 +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. -*/ - -'use strict'; - -var zeroTo = require( './../../zero-to' ); -var bernoulli = require( '@stdlib/random/array/bernoulli' ); -var mskreject = require( './../lib' ); - -// Generate a linearly spaced array: -var x = zeroTo( 20, 'generic' ); -console.log( x ); - -// Generate a random mask: -var mask = bernoulli( x.length, 0.5, { - 'dtype': 'generic' -}); -console.log( mask ); - -// Filter an array using the mask: -var y = mskreject( x, mask ); -console.log( y ); diff --git a/mskreject/lib/index.js b/mskreject/lib/index.js deleted file mode 100644 index 6ab9c3334..000000000 --- a/mskreject/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Apply a mask to a provided input array. -* -* @module @stdlib/array/mskreject -* -* @example -* var mskreject = require( '@stdlib/array/mskreject' ); -* -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskreject( x, mask ); -* // returns [ 1, 3 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/mskreject/lib/main.js b/mskreject/lib/main.js deleted file mode 100644 index e23318ce0..000000000 --- a/mskreject/lib/main.js +++ /dev/null @@ -1,80 +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. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert/is-collection' ); -var base = require( './../../base/mskreject' ); -var countFalsy = require( './../../base/count-falsy' ); -var zeros = require( './../../zeros' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns a new array by applying a mask to a provided input array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} second argument must be a collection -* @throws {Error} must provide collections of equal length -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskreject( x, mask ); -* // returns [ 1, 3 ] -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var mask = [ 0, 1, 0, 1 ]; -* -* var y = mskreject( x, mask ); -* // returns [ 1, 3 ] -*/ -function mskreject( x, mask ) { - var dt; - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) ); - } - if ( !isCollection( mask ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) ); - } - if ( x.length !== mask.length ) { - throw new Error( format( 'invalid arguments. Must provide equal length array-like objects.' ) ); - } - dt = dtype( x ); - if ( dt === 'generic' || dt === null ) { - return base( x, mask ); - } - return base.assign( x, mask, zeros( countFalsy( mask ), dt ), 1, 0 ); -} - - -// EXPORTS // - -module.exports = mskreject; diff --git a/mskreject/package.json b/mskreject/package.json deleted file mode 100644 index c3d2ab2b5..000000000 --- a/mskreject/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/mskreject", - "version": "0.0.0", - "description": "Apply a mask to a provided input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index", - "mask", - "filter", - "reject" - ] -} diff --git a/mskreject/test/test.js b/mskreject/test/test.js deleted file mode 100644 index a770556b4..000000000 --- a/mskreject/test/test.js +++ /dev/null @@ -1,277 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var Complex64Array = require( './../../complex64' ); -var Int32Array = require( './../../int32' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var zeros = require( './../../zeros' ); -var mskreject = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof mskreject, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskreject( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskreject( [], value ); - }; - } -}); - -tape( 'the function throws an error if provided collections of unequal length', function test( t ) { - var values; - var i; - - values = [ - [], - [ 1 ], - [ 1, 2 ], - [ 1, 2, 3 ], - [ 1, 2, 3, 4 ], - [ 1, 2, 3, 4, 5, 6 ], - [ 1, 2, 3, 4, 5, 6, 7 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - mskreject( value, zeros( 5, 'generic' ) ); - }; - } -}); - -tape( 'the function filters array elements (generic)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - - mask = [ 0, 1, 0, 1 ]; - actual = mskreject( x, mask ); - expected = [ 1, 3 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskreject( x, mask ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 0 ]; - actual = mskreject( x, mask ); - expected = [ 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskreject( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - actual = mskreject( x, mask ); - expected = [ 1, 3 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = mskreject( x, mask ); - expected = []; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = toAccessorArray( [ 1, 1, 1, 0 ] ); - actual = mskreject( x, mask ); - expected = [ 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = mskreject( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (real typed array)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - - mask = [ 0, 1, 0, 1 ]; - actual = mskreject( x, mask ); - expected = [ 1, 3 ]; - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskreject( x, mask ); - expected = []; - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 1, 1, 1, 0 ]; - actual = mskreject( x, mask ); - expected = [ 4 ]; - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskreject( x, mask ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.notEqual( actual, x, 'returns new array' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function filters array elements (complex typed array)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - mask = [ 1, 0, 1, 0 ]; - actual = mskreject( x, mask ); - expected = new Complex64Array( [ 3.0, 4.0, 7.0, 8.0 ] ); - t.notEqual( actual, x, 'returns new array' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 1 ]; - actual = mskreject( x, mask ); - expected = new Complex64Array( [] ); - t.notEqual( actual, x, 'returns new array' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 1, 1, 1, 0 ]; - actual = mskreject( x, mask ); - expected = new Complex64Array( [ 7.0, 8.0 ] ); - t.notEqual( actual, x, 'returns new array' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - mask = [ 0, 0, 0, 0 ]; - actual = mskreject( x, mask ); - expected = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - t.notEqual( actual, x, 'returns new array' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided empty arrays', function test( t ) { - t.deepEqual( mskreject( [], [] ), [], 'returns expected value' ); - t.deepEqual( mskreject( new Int32Array( [] ), [] ), new Int32Array( [] ), 'returns expected value' ); - t.end(); -}); diff --git a/nans-like/README.md b/nans-like/README.md deleted file mode 100644 index 202b59a6c..000000000 --- a/nans-like/README.md +++ /dev/null @@ -1,162 +0,0 @@ - - -# nansLike - -> Create an array filled with NaNs and having the same length and data type as a provided array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var nansLike = require( '@stdlib/array/nans-like' ); -``` - -#### nansLike( x\[, dtype] ) - -Creates an array filled with NaNs and having the same length and data type as a provided array `x`. - -```javascript -var x = [ 1, 2, 3, 4, 5 ]; - -var arr = nansLike( x ); -// returns [ NaN, NaN, NaN, NaN, NaN ] -``` - -The function supports the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers -- `generic`: generic JavaScript values - -By default, the output array data type is inferred from the provided array `x`. To return an array having a different data type, provide a `dtype` argument. - -```javascript -var x = [ 0, 0 ]; - -var arr = nansLike( x, 'float32' ); -// returns [ NaN, NaN ] -``` - -
- - - - - -
- -## Notes - -- If the output array has a complex number data type, each element of the returned array has a real component equal to `NaN` and an imaginary component equal to `NaN`. - -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/typed-float-dtypes' ); -var zeros = require( '@stdlib/array/zeros' ); -var nansLike = require( '@stdlib/array/nans-like' ); - -// Create a zero-filled array: -var x = zeros( 4, 'complex128' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - y = nansLike( x, dt[ i ] ); - console.log( y ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/nans-like/benchmark/benchmark.js b/nans-like/benchmark/benchmark.js deleted file mode 100644 index a762e3df3..000000000 --- a/nans-like/benchmark/benchmark.js +++ /dev/null @@ -1,163 +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 bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var nansLike = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nansLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nansLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nansLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex128' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nansLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nansLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'generic' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nansLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/nans-like/benchmark/benchmark.length.complex128.js b/nans-like/benchmark/benchmark.length.complex128.js deleted file mode 100644 index ac54078e7..000000000 --- a/nans-like/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var nansLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex128' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nansLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/nans-like/benchmark/benchmark.length.complex64.js b/nans-like/benchmark/benchmark.length.complex64.js deleted file mode 100644 index c18424f73..000000000 --- a/nans-like/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var nansLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nansLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/nans-like/benchmark/benchmark.length.float32.js b/nans-like/benchmark/benchmark.length.float32.js deleted file mode 100644 index 5b97f92ed..000000000 --- a/nans-like/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var nansLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nansLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/nans-like/benchmark/benchmark.length.float64.js b/nans-like/benchmark/benchmark.length.float64.js deleted file mode 100644 index d60b4b253..000000000 --- a/nans-like/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var nansLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nansLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/nans-like/benchmark/benchmark.length.generic.js b/nans-like/benchmark/benchmark.length.generic.js deleted file mode 100644 index ab33d92d7..000000000 --- a/nans-like/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var nansLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nansLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/nans-like/docs/repl.txt b/nans-like/docs/repl.txt deleted file mode 100644 index df99cb07b..000000000 --- a/nans-like/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( x[, dtype] ) - Returns an array filled with NaNs and having the same length and data type - as a provided input array. - - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754). - - float32: single-precision floating-point numbers (IEEE 754). - - complex128: double-precision complex floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - generic: generic JavaScript values. - - Parameters - ---------- - x: TypedArray|Array - Input array. - - dtype: string (optional) - Data type. If not provided, the output array data type is inferred from - the input array. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var x = new {{alias:@stdlib/array/float64}}( 2 ); - > var y = {{alias}}( x ) - [ NaN, NaN ] - > y = {{alias}}( x, 'float32' ) - [ NaN, NaN ] - - See Also - -------- - diff --git a/nans-like/docs/types/index.d.ts b/nans-like/docs/types/index.d.ts deleted file mode 100644 index 3c73c3819..000000000 --- a/nans-like/docs/types/index.d.ts +++ /dev/null @@ -1,304 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Complex128Array, Complex64Array, AnyArray, FloatingPointDataType } from '@stdlib/types/array'; - -/** -* Data type. -*/ -type DataType = FloatingPointDataType | 'generic'; - -/** -* Creates an array filled with NaNs and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = nansLike( x, 'float64' ); -* // returns [ NaN, NaN ] -*/ -declare function nansLike( x: AnyArray, dtype: 'float64' ): Float64Array; - -/** -* Creates an array filled with NaNs and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = nansLike( x, 'float32' ); -* // returns [ NaN, NaN ] -*/ -declare function nansLike( x: AnyArray, dtype: 'float32' ): Float32Array; - -/** -* Creates an array filled with NaNs and having the same length as a provided input array. -* -* ## Notes -* -* - Each element of the returned array has a real component equal to `NaN` and an imaginary component equal to `NaN`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = nansLike( x, 'complex128' ); -* // returns -*/ -declare function nansLike( x: AnyArray, dtype: 'complex128' ): Complex128Array; - -/** -* Creates an array filled with NaNs and having the same length as a provided input array. -* -* ## Notes -* -* - Each element of the returned array has a real component equal to `NaN` and an imaginary component equal to `NaN`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = nansLike( x, 'complex64' ); -* // returns -*/ -declare function nansLike( x: AnyArray, dtype: 'complex64' ): Complex64Array; - -/** -* Creates an array filled with NaNs and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = nansLike( x, 'generic' ); -* // returns [ NaN, NaN ] -*/ -declare function nansLike( x: AnyArray, dtype: 'generic' ): Array; - -/** -* Creates an array filled with NaNs and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = nansLike( x ); -* // returns [ NaN, NaN ] -*/ -declare function nansLike( x: Float64Array, dtype?: DataType ): Float64Array; - -/** -* Creates an array filled with NaNs and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = nansLike( x ); -* // returns [ NaN, NaN ] -*/ -declare function nansLike( x: Float32Array, dtype?: DataType ): Float32Array; - -/** -* Creates an array filled with NaNs and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - Each element of the returned array has a real component equal to `NaN` and an imaginary component equal to `NaN`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex128' ); -* // returns -* -* var y = nansLike( x ); -* // returns -*/ -declare function nansLike( x: Complex128Array, dtype?: DataType ): Complex128Array; - -/** -* Creates an array filled with NaNs and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `generic`: generic JavaScript values -* -* ## Notes -* -* - Each element of the returned array has a real component equal to `NaN` and an imaginary component equal to `NaN`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex64' ); -* // returns -* -* var y = nansLike( x ); -* // returns -*/ -declare function nansLike( x: Complex64Array, dtype?: DataType ): Complex64Array; - -/** -* Creates an array filled with NaNs and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'generic' ); -* // returns [ 0, 0 ] -* -* var y = nansLike( x ); -* // returns [ NaN, NaN ] -*/ -declare function nansLike( x: Array, dtype?: DataType ): Array; - -/** -* Creates an array filled with NaNs and having the same length and data type as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = nansLike( x ); -* // returns [ NaN, NaN ] -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = nansLike( x, 'float32' ); -* // returns [ NaN, NaN ] -*/ -declare function nansLike( x: AnyArray, dtype?: DataType ): AnyArray; - - -// EXPORTS // - -export = nansLike; diff --git a/nans-like/docs/types/test.ts b/nans-like/docs/types/test.ts deleted file mode 100644 index 27fa9801b..000000000 --- a/nans-like/docs/types/test.ts +++ /dev/null @@ -1,77 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import nansLike = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - nansLike( [ 0, 0 ] ); // $ExpectType number[] - nansLike( new Float64Array( [ 0, 0 ] ) ); // $ExpectType Float64Array - nansLike( new Float32Array( [ 0, 0 ] ) ); // $ExpectType Float32Array - nansLike( new Complex128Array( [ 0, 0 ] ) ); // $ExpectType Complex128Array - nansLike( new Complex64Array( [ 0, 0 ] ) ); // $ExpectType Complex64Array - - nansLike( [ 0, 0 ], 'float64' ); // $ExpectType Float64Array - nansLike( [ 0, 0 ], 'float32' ); // $ExpectType Float32Array - nansLike( [ 0, 0 ], 'complex128' ); // $ExpectType Complex128Array - nansLike( [ 0, 0 ], 'complex64' ); // $ExpectType Complex64Array - nansLike( [ 0, 0 ], 'generic' ); // $ExpectType number[] -} - -// The compiler throws an error if the function is not provided an array or typed array for the first argument... -{ - nansLike( '5' ); // $ExpectError - nansLike( 5 ); // $ExpectError - nansLike( false ); // $ExpectError - nansLike( true ); // $ExpectError - nansLike( null ); // $ExpectError - nansLike( undefined ); // $ExpectError - nansLike( {} ); // $ExpectError - nansLike( ( x: number ): number => x ); // $ExpectError - - nansLike( '5', 'float32' ); // $ExpectError - nansLike( 5, 'float32' ); // $ExpectError - nansLike( false, 'float32' ); // $ExpectError - nansLike( true, 'float32' ); // $ExpectError - nansLike( null, 'float32' ); // $ExpectError - nansLike( undefined, 'float32' ); // $ExpectError - nansLike( {}, 'float32' ); // $ExpectError - nansLike( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - nansLike( [ 0, 0 ], '10' ); // $ExpectError - nansLike( [ 0, 0 ], 10 ); // $ExpectError - nansLike( [ 0, 0 ], false ); // $ExpectError - nansLike( [ 0, 0 ], true ); // $ExpectError - nansLike( [ 0, 0 ], null ); // $ExpectError - nansLike( [ 0, 0 ], [] ); // $ExpectError - nansLike( [ 0, 0 ], {} ); // $ExpectError - nansLike( [ 0, 0 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nansLike( [ 0, 0 ], 'float64', 1 ); // $ExpectError -} diff --git a/nans-like/examples/index.js b/nans-like/examples/index.js deleted file mode 100644 index 8eda5fd1a..000000000 --- a/nans-like/examples/index.js +++ /dev/null @@ -1,37 +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'; - -var dtypes = require( './../../typed-float-dtypes' ); -var zeros = require( './../../zeros' ); -var nansLike = require( './../lib' ); - -// Create a zero-filled array: -var x = zeros( 4, 'complex128' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - y = nansLike( x, dt[ i ] ); - console.log( y ); -} diff --git a/nans-like/lib/index.js b/nans-like/lib/index.js deleted file mode 100644 index 7c05beddb..000000000 --- a/nans-like/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Create an array filled with NaNs and having the same length and data type as a provided input array. -* -* @module @stdlib/array/nans-like -* -* @example -* var nansLike = require( '@stdlib/array/nans-like' ); -* -* var arr = nansLike( [ 0.0, 0.0 ] ); -* // returns [ NaN, NaN ] -* -* @example -* var nansLike = require( '@stdlib/array/nans-like' ); -* -* var arr = nansLike( [ 0.0, 0.0 ], 'float32' ); -* // returns [ NaN, NaN ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/nans-like/lib/main.js b/nans-like/lib/main.js deleted file mode 100644 index 9499473bb..000000000 --- a/nans-like/lib/main.js +++ /dev/null @@ -1,85 +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 dtype = require( './../../dtype' ); -var full = require( './../../full' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var Z128 = new Complex128( NaN, NaN ); -var Z64 = new Complex64( NaN, NaN ); -var DTYPES = [ 'float64', 'float32', 'complex128', 'complex64', 'generic' ]; - - -// MAIN // - -/** -* Creates an array filled with NaNs and having the same length and data type as a provided input array. -* -* @param {(Array|TypedArray|ComplexArray)} x - input array -* @param {string} [dtype] - data type -* @throws {TypeError} first argument must be an array or typed array -* @throws {TypeError} second argument must be a supported data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = nansLike( [ 0.0, 0.0 ] ); -* // returns [ NaN, NaN ] -* -* @example -* var arr = nansLike( [ 0.0, 0.0 ], 'float32' ); -* // returns [ NaN, NaN ] -*/ -function nansLike( x ) { - var dt; - var v; - - dt = dtype( x ); // delegate input argument validation to dtype resolution - if ( dt === null ) { - throw new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) ); - } - if ( arguments.length > 1 ) { - dt = arguments[ 1 ]; - if ( DTYPES.indexOf( dt ) === -1 ) { - throw new TypeError( format( 'invalid argument. Second argument must be one of the following: "%s". Value: `%s`.', DTYPES.join( '", "' ), dt ) ); - } - } else if ( DTYPES.indexOf( dt ) === -1 ) { - throw new TypeError( format( 'invalid argument. First argument must be one of the following data types: "%s". Value: `%s`.', DTYPES.join( '", "' ), dt ) ); - } - if ( dt === 'complex128' ) { - v = Z128; - } else if ( dt === 'complex64' ) { - v = Z64; - } else { - v = NaN; - } - return full( x.length, v, dt ); -} - - -// EXPORTS // - -module.exports = nansLike; diff --git a/nans-like/package.json b/nans-like/package.json deleted file mode 100644 index 1af847172..000000000 --- a/nans-like/package.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "name": "@stdlib/array/nans-like", - "version": "0.0.0", - "description": "Create an array filled with NaNs and having the same length and data type as a provided array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "generic", - "fill", - "filled", - "nans" - ] -} diff --git a/nans-like/test/test.js b/nans-like/test/test.js deleted file mode 100644 index 7b18d3f6b..000000000 --- a/nans-like/test/test.js +++ /dev/null @@ -1,309 +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 isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var nansLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nansLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - nansLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - nansLike( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'nansLike', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - nansLike( [], value ); - }; - } -}); - -tape( 'the function returns a NaN-filled array (float64)', function test( t ) { - var arr; - var x; - var i; - - x = new Float64Array( 5 ); - - arr = nansLike( x ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnan( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a NaN-filled array (dtype=float64)', function test( t ) { - var arr; - var x; - var i; - - x = new Float64Array( 5 ); - - arr = nansLike( x, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnan( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a NaN-filled array (float32)', function test( t ) { - var arr; - var x; - var i; - - x = new Float32Array( 5 ); - - arr = nansLike( x ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnanf( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a NaN-filled array (dtype=float32)', function test( t ) { - var arr; - var x; - var i; - - x = new Float64Array( 5 ); - - arr = nansLike( x, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnanf( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a NaN-filled array (complex128)', function test( t ) { - var arr; - var x; - var i; - - x = new Complex128Array( 2 ); - - arr = nansLike( x ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - arr = reinterpret128( arr, 0 ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnan( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a NaN-filled array (dtype=complex128)', function test( t ) { - var arr; - var x; - var i; - - x = new Float64Array( 2 ); - - arr = nansLike( x, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - arr = reinterpret128( arr, 0 ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnan( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a NaN-filled array (complex64)', function test( t ) { - var arr; - var x; - var i; - - x = new Complex64Array( 2 ); - - arr = nansLike( x ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - arr = reinterpret64( arr, 0 ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnanf( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a NaN-filled array (dtype=complex64)', function test( t ) { - var arr; - var x; - var i; - - x = new Float64Array( 2 ); - - arr = nansLike( x, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - arr = reinterpret64( arr, 0 ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnanf( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a NaN-filled array (generic)', function test( t ) { - var arr; - var x; - var i; - - x = [ 1, 2, 3, 4, 5 ]; - - arr = nansLike( x ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnan( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a NaN-filled array (dtype=generic)', function test( t ) { - var arr; - var x; - var i; - - x = new Float64Array( 5 ); - - arr = nansLike( x, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, x.length, 'returns expected value' ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnan( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); diff --git a/nans/README.md b/nans/README.md deleted file mode 100644 index 259772022..000000000 --- a/nans/README.md +++ /dev/null @@ -1,156 +0,0 @@ - - -# nans - -> Create an array filled with NaNs and having a specified length. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var nans = require( '@stdlib/array/nans' ); -``` - -#### nans( length\[, dtype] ) - -Creates an array filled with NaNs and having a specified length. - -```javascript -var arr = nans( 2 ); -// returns [ NaN, NaN ] -``` - -The function recognizes the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers -- `generic`: generic JavaScript values - -By default, the output array data type is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative data type, provide a `dtype` argument. - -```javascript -var arr = nans( 2, 'float32' ); -// returns [ NaN, NaN ] -``` - -
- - - - - -
- -## Notes - -- For complex number arrays, each element of the returned array has a real component equal to `NaN` and an imaginary component equal to `NaN`. - -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/typed-float-dtypes' ); -var nans = require( '@stdlib/array/nans' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = nans( 4, dt[ i ] ); - console.log( arr ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/nans/benchmark/benchmark.js b/nans/benchmark/benchmark.js deleted file mode 100644 index 30b81710b..000000000 --- a/nans/benchmark/benchmark.js +++ /dev/null @@ -1,138 +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 bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var nans = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nans( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nans( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nans( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nans( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nans( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nans( 0, 'generic' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/nans/benchmark/benchmark.length.complex128.js b/nans/benchmark/benchmark.length.complex128.js deleted file mode 100644 index caa950b07..000000000 --- a/nans/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var nans = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nans( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/nans/benchmark/benchmark.length.complex64.js b/nans/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 23f9cfeb2..000000000 --- a/nans/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var nans = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nans( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/nans/benchmark/benchmark.length.float32.js b/nans/benchmark/benchmark.length.float32.js deleted file mode 100644 index 43698243b..000000000 --- a/nans/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var nans = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nans( len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/nans/benchmark/benchmark.length.float64.js b/nans/benchmark/benchmark.length.float64.js deleted file mode 100644 index 541521b34..000000000 --- a/nans/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var nans = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nans( len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/nans/benchmark/benchmark.length.generic.js b/nans/benchmark/benchmark.length.generic.js deleted file mode 100644 index 66abaca16..000000000 --- a/nans/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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 bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var nans = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = nans( len, 'generic' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/nans/docs/repl.txt b/nans/docs/repl.txt deleted file mode 100644 index 44d0695be..000000000 --- a/nans/docs/repl.txt +++ /dev/null @@ -1,37 +0,0 @@ - -{{alias}}( length[, dtype] ) - Returns an array filled with NaNs and having a specified length. - - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754) - - float32: single-precision floating-point numbers (IEEE 754) - - complex128: double-precision complex floating-point numbers - - complex64: single-precision complex floating-point numbers - - generic: generic JavaScript values - - The default array data type is `float64`. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 2 ) - [ NaN, NaN ] - > arr = {{alias}}( 2, 'float32' ) - [ NaN, NaN ] - - See Also - -------- - diff --git a/nans/docs/types/index.d.ts b/nans/docs/types/index.d.ts deleted file mode 100644 index 4ea2823ea..000000000 --- a/nans/docs/types/index.d.ts +++ /dev/null @@ -1,131 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Complex128Array, Complex64Array, FloatingPointDataType } from '@stdlib/types/array'; - -/** -* Data type. -*/ -type DataType = FloatingPointDataType | 'generic'; - -/** -* Creates an array filled with NaNs and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = nans( 2, 'float64' ); -* // returns [ NaN, NaN ] -*/ -declare function nans( length: number, dtype: 'float64' ): Float64Array; - -/** -* Creates an array filled with NaNs and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = nans( 2, 'float32' ); -* // returns [ NaN, NaN ] -*/ -declare function nans( length: number, dtype: 'float32' ): Float32Array; - -/** -* Creates an array filled with NaNs and having a specified length. -* -* ## Notes -* -* - Each element has a real component equal to `NaN` and an imaginary component equal to `NaN`. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = nans( 2, 'complex128' ); -* // returns -*/ -declare function nans( length: number, dtype: 'complex128' ): Complex128Array; - -/** -* Creates an array filled with NaNs and having a specified length. -* -* ## Notes -* -* - Each element has a real component equal to `NaN` and an imaginary component equal to `NaN`. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = nans( 2, 'complex64' ); -* // returns -*/ -declare function nans( length: number, dtype: 'complex64' ): Complex64Array; - -/** -* Creates an array filled with NaNs and having a specified length. -* -* @param length - array length -* @param dtype - data type -* @returns filled array -* -* @example -* var arr = nans( 2, 'generic' ); -* // returns [ NaN, NaN ] -*/ -declare function nans( length: number, dtype: 'generic' ): Array; - -/** -* Creates an array filled with NaNs and having a specified length. -* -* The function recognizes the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `generic`: generic JavaScript values -* -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = nans( 2 ); -* // returns [ NaN, NaN ] -* -* @example -* var arr = nans( 2, 'float32' ); -* // returns [ NaN, NaN ] -*/ -declare function nans( length: number, dtype?: DataType ): Float64Array; - - -// EXPORTS // - -export = nans; diff --git a/nans/docs/types/test.ts b/nans/docs/types/test.ts deleted file mode 100644 index e5d2914c1..000000000 --- a/nans/docs/types/test.ts +++ /dev/null @@ -1,70 +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. -*/ - -import nans = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - nans( 10 ); // $ExpectType Float64Array - nans( 10, 'float64' ); // $ExpectType Float64Array - nans( 10, 'float32' ); // $ExpectType Float32Array - nans( 10, 'complex128' ); // $ExpectType Complex128Array - nans( 10, 'complex64' ); // $ExpectType Complex64Array - nans( 10, 'generic' ); // $ExpectType number[] -} - -// The compiler throws an error if the function is not provided a number for the first argument... -{ - nans( '5' ); // $ExpectError - nans( false ); // $ExpectError - nans( true ); // $ExpectError - nans( null ); // $ExpectError - nans( undefined ); // $ExpectError - nans( [] ); // $ExpectError - nans( {} ); // $ExpectError - nans( ( x: number ): number => x ); // $ExpectError - - nans( '5', 'float32' ); // $ExpectError - nans( false, 'float32' ); // $ExpectError - nans( true, 'float32' ); // $ExpectError - nans( null, 'float32' ); // $ExpectError - nans( undefined, 'float32' ); // $ExpectError - nans( [], 'float32' ); // $ExpectError - nans( {}, 'float32' ); // $ExpectError - nans( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - nans( 10, '10' ); // $ExpectError - nans( 10, 10 ); // $ExpectError - nans( 10, false ); // $ExpectError - nans( 10, true ); // $ExpectError - nans( 10, null ); // $ExpectError - nans( 10, [] ); // $ExpectError - nans( 10, {} ); // $ExpectError - nans( 10, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nans( 10, 'float64', 1 ); // $ExpectError -} diff --git a/nans/examples/index.js b/nans/examples/index.js deleted file mode 100644 index 9002be692..000000000 --- a/nans/examples/index.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'; - -var dtypes = require( './../../typed-float-dtypes' ); -var ones = require( './../lib' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = ones( 4, dt[ i ] ); - console.log( arr ); -} diff --git a/nans/lib/index.js b/nans/lib/index.js deleted file mode 100644 index 4b7738a68..000000000 --- a/nans/lib/index.js +++ /dev/null @@ -1,46 +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'; - -/** -* Create an array filled with NaNs and having a specified length. -* -* @module @stdlib/array/nans -* -* @example -* var nans = require( '@stdlib/array/nans' ); -* -* var arr = nans( 2 ); -* // returns [ NaN, NaN ] -* -* @example -* var nans = require( '@stdlib/array/nans' ); -* -* var arr = nans( 2, 'float32' ); -* // returns [ NaN, NaN ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/nans/lib/main.js b/nans/lib/main.js deleted file mode 100644 index 496ba17b3..000000000 --- a/nans/lib/main.js +++ /dev/null @@ -1,85 +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 contains = require( './../../base/assert/contains' ).factory; -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var full = require( './../../full' ); -var defaults = require( './../../defaults' ); -var dtypes = require( './../../dtypes' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var Z128 = new Complex128( NaN, NaN ); -var Z64 = new Complex64( NaN, NaN ); -var DTYPES = dtypes( 'floating_point_and_generic' ); -var isValidDType = contains( DTYPES ); -var DEFAULT_DTYPE = defaults.get( 'dtypes.real_floating_point' ); - - -// MAIN // - -/** -* Creates an array filled with NaNs and having a specified length. -* -* @param {NonNegativeInteger} length - array length -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be a supported data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = nans( 2 ); -* // returns [ NaN, NaN ] -* -* @example -* var arr = nans( 2, 'float32' ); -* // returns [ NaN, NaN ] -*/ -function nans( length ) { - var dtype; - var value; - - if ( arguments.length > 1 ) { - dtype = arguments[ 1 ]; - if ( !isValidDType( dtype ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be one of the following: "%s". Value: `%s`.', DTYPES.join( '", "' ), dtype ) ); - } - } else { - dtype = DEFAULT_DTYPE; - } - if ( dtype === 'complex128' ) { - value = Z128; - } else if ( dtype === 'complex64' ) { - value = Z64; - } else { - value = NaN; - } - return full( length, value, dtype ); -} - - -// EXPORTS // - -module.exports = nans; diff --git a/nans/package.json b/nans/package.json deleted file mode 100644 index aea9160dd..000000000 --- a/nans/package.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "name": "@stdlib/array/nans", - "version": "0.0.0", - "description": "Create an array filled with NaNs and having a specified length.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "generic", - "fill", - "filled", - "nans" - ] -} diff --git a/nans/test/test.js b/nans/test/test.js deleted file mode 100644 index e6a9e9804..000000000 --- a/nans/test/test.js +++ /dev/null @@ -1,223 +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 isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var nans = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nans, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - nans( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - nans( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ones', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - nans( 10, value ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var arr; - var i; - - arr = nans( 5 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnan( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64)', function test( t ) { - var arr; - var i; - - arr = nans( 5, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnan( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32)', function test( t ) { - var arr; - var i; - - arr = nans( 5, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnanf( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128)', function test( t ) { - var arr; - var i; - - arr = nans( 2, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - - arr = reinterpret128( arr, 0 ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnan( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64)', function test( t ) { - var arr; - var i; - - arr = nans( 2, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 2, 'returns expected value' ); - - arr = reinterpret64( arr, 0 ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnan( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic)', function test( t ) { - var arr; - var i; - - arr = nans( 5, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 5, 'returns expected value' ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( isnan( arr[ i ] ), true, 'returns expected value for element '+i ); - } - t.end(); -}); diff --git a/next-dtype/README.md b/next-dtype/README.md deleted file mode 100644 index 747d10907..000000000 --- a/next-dtype/README.md +++ /dev/null @@ -1,152 +0,0 @@ - - -# nextDataType - -> Return the next larger array [data type][@stdlib/array/dtypes] of the same kind. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var nextDataType = require( '@stdlib/array/next-dtype' ); -``` - -#### nextDataType( \[dtype] ) - -If provided a `dtype` argument, returns the next larger array [data type][@stdlib/array/dtypes] of the same kind. - -```javascript -var out = nextDataType( 'float32' ); -// returns 'float64' -``` - -If a [data type][@stdlib/array/dtypes] does not have a next larger [data type][@stdlib/array/dtypes] or the next larger data type is not supported, the function returns `-1`. - -```javascript -var out = nextDataType( 'complex128' ); -// returns -1 -``` - -If not provided a `dtype` argument, the function returns a table. - -```javascript -var out = nextDataType(); -// returns {...} -``` - -If provided an unrecognized or unsupported `dtype`, the function returns `null`. - -```javascript -var out = nextDataType( 'foo' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var nextDataType = require( '@stdlib/array/next-dtype' ); - -var DTYPES; -var dt; -var i; - -// Get the list of supported array data types: -DTYPES = dtypes(); - -// Print the next larger data type for each supported data type... -for ( i = 0; i < DTYPES.length; i++ ) { - dt = nextDataType( DTYPES[ i ] ); - console.log( '%s => %s', DTYPES[ i ], dt ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/next-dtype/benchmark/benchmark.js b/next-dtype/benchmark/benchmark.js deleted file mode 100644 index c98ebb889..000000000 --- a/next-dtype/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var dtypes = require( './../../dtypes' ); -var pkg = require( './../package.json' ).name; -var nextDataType = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = nextDataType(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = nextDataType( dt[ i%dt.length ] ); - if ( typeof out !== 'string' && out !== -1 ) { - b.fail( 'should return a string or -1' ); - } - } - b.toc(); - if ( !isString( out ) && out !== -1 ) { - b.fail( 'should return a string or -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/next-dtype/docs/repl.txt b/next-dtype/docs/repl.txt deleted file mode 100644 index bbd3535e0..000000000 --- a/next-dtype/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( [dtype] ) - Returns the next larger array data type of the same kind. - - If not provided a data type, the function returns a table. - - If a data type does not have a next larger data type or the next larger type - is not supported, the function returns `-1`. - - If provided an unrecognized data type, the function returns `null`. - - Parameters - ---------- - dtype: string (optional) - Array data type. - - Returns - ------- - out: Object|string|integer|null - Next larger type(s). - - Examples - -------- - > var out = {{alias}}( 'float32' ) - 'float64' - - See Also - -------- - diff --git a/next-dtype/docs/types/index.d.ts b/next-dtype/docs/types/index.d.ts deleted file mode 100644 index 8d6818d48..000000000 --- a/next-dtype/docs/types/index.d.ts +++ /dev/null @@ -1,299 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { DataType } from '@stdlib/types/array'; - -/** -* Table mapping data types to the next larger data type of the same kind. -*/ -interface Table { - /** - * Mapping of a data type to the next larger data type of the same kind. - */ - [key: string]: DataType | number; -} - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'float64' ); -* // returns -1 -*/ -declare function nextDataType( dtype: 'float64' ): number; - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'float32' ); -* // returns 'float64' -*/ -declare function nextDataType( dtype: 'float32' ): 'float64'; - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'int32' ); -* // returns -1 -*/ -declare function nextDataType( dtype: 'int32' ): number; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'int16' ); -* // returns 'int32' -*/ -declare function nextDataType( dtype: 'int16' ): 'int32'; - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'int8' ); -* // returns 'int16' -*/ -declare function nextDataType( dtype: 'int8' ): 'int16'; - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'uint32' ); -* // returns -1 -*/ -declare function nextDataType( dtype: 'uint32' ): number; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'uint16' ); -* // returns 'uint32' -*/ -declare function nextDataType( dtype: 'uint16' ): 'uint32'; - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'uint8' ); -* // returns 'uint16' -*/ -declare function nextDataType( dtype: 'uint8' ): 'uint16'; - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'uint8c' ); -* // returns 'uint16' -*/ -declare function nextDataType( dtype: 'uint8c' ): 'uint16'; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'generic' ); -* // returns -1 -*/ -declare function nextDataType( dtype: 'generic' ): number; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'bool' ); -* // returns -1 -*/ -declare function nextDataType( dtype: 'bool' ): number; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'complex128' ); -* // returns -1 -*/ -declare function nextDataType( dtype: 'complex128' ): number; // eslint-disable-line @typescript-eslint/unified-signatures - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'complex64' ); -* // returns 'complex128' -*/ -declare function nextDataType( dtype: 'complex64' ): 'complex128'; - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'complex64' ); -* // returns 'complex128' -*/ -declare function nextDataType( dtype: DataType ): DataType | number; - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* - If provided an unrecognized data type, the function returns `null`. -* -* @param dtype - array data type -* @returns next larger data type -* -* @example -* var dt = nextDataType( 'float' ); -* // returns null -*/ -declare function nextDataType( dtype: string ): null; - -/** -* Returns the next larger array data type of the same kind. -* -* ## Notes -* -* - If not provided a data type, the function returns a table. -* - If a data type does not have a next larger data type or the next larger type is not supported, the function returns `-1`. -* - If provided an unrecognized data type, the function returns `null`. -* -* @param dtype - array data type -* @returns next larger data type(s) or null -* -* @example -* var table = nextDataType(); -* // returns {...} -* -* @example -* var dt = nextDataType( 'float32' ); -* // returns 'float64' -*/ -declare function nextDataType( dtype?: DataType ): Table; - - -// EXPORTS // - -export = nextDataType; diff --git a/next-dtype/docs/types/test.ts b/next-dtype/docs/types/test.ts deleted file mode 100644 index 5f7e95e6b..000000000 --- a/next-dtype/docs/types/test.ts +++ /dev/null @@ -1,66 +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. -*/ - -import nextDataType = require( './index' ); - - -// TESTS // - -// The function returns a table when not provided an input argument.. -{ - nextDataType(); // $ExpectType Table -} - -// The function returns the next larger data type or null when provided an input argument... -{ - nextDataType( 'complex128' ); // $ExpectType number - nextDataType( 'complex64' ); // $ExpectType "complex128" - - nextDataType( 'bool' ); // $ExpectType number - - nextDataType( 'float64' ); // $ExpectType number - nextDataType( 'float32' ); // $ExpectType "float64" - - nextDataType( 'int32' ); // $ExpectType number - nextDataType( 'int16' ); // $ExpectType "int32" - nextDataType( 'int8' ); // $ExpectType "int16" - - nextDataType( 'uint32' ); // $ExpectType number - nextDataType( 'uint16' ); // $ExpectType "uint32" - nextDataType( 'uint8' ); // $ExpectType "uint16" - nextDataType( 'uint8c' ); // $ExpectType "uint16" - - nextDataType( 'generic' ); // $ExpectType number - - nextDataType( 'float' ); // $ExpectType null -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - nextDataType( 123 ); // $ExpectError - nextDataType( true ); // $ExpectError - nextDataType( false ); // $ExpectError - nextDataType( {} ); // $ExpectError - nextDataType( [] ); // $ExpectError - nextDataType( null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nextDataType( 'float32', 3 ); // $ExpectError -} diff --git a/next-dtype/examples/index.js b/next-dtype/examples/index.js deleted file mode 100644 index eca132256..000000000 --- a/next-dtype/examples/index.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../dtypes' ); -var nextDataType = require( './../lib' ); - -var DTYPES; -var dt; -var i; - -// Get the list of supported array data types: -DTYPES = dtypes(); - -// Print the next larger data type for each supported data type... -for ( i = 0; i < DTYPES.length; i++ ) { - dt = nextDataType( DTYPES[ i ] ); - console.log( '%s => %s', DTYPES[ i ], dt ); -} diff --git a/next-dtype/lib/index.js b/next-dtype/lib/index.js deleted file mode 100644 index fcbbef83f..000000000 --- a/next-dtype/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Return the next larger array data type of the same kind. -* -* @module @stdlib/array/next-dtype -* -* @example -* var nextDataType = require( '@stdlib/array/next-dtype' ); -* -* var dt = nextDataType( 'float32' ); -* // returns 'float64' -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/next-dtype/lib/main.js b/next-dtype/lib/main.js deleted file mode 100644 index e31af2b12..000000000 --- a/next-dtype/lib/main.js +++ /dev/null @@ -1,77 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var objectKeys = require( '@stdlib/utils/keys' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var NEXT_DTYPES = require( './next_dtypes.json' ); - - -// FUNCTIONS // - -/** -* Generates a table. -* -* @private -* @returns {Object} table -*/ -function generateTable() { - var dtypes; - var ntypes; - var out; - var i; - - out = {}; - dtypes = objectKeys( NEXT_DTYPES ); - ntypes = dtypes.length; - for ( i = 0; i < ntypes; i++ ) { - out[ dtypes[i] ] = NEXT_DTYPES[ dtypes[i] ]; - } - return out; -} - - -// MAIN // - -/** -* Returns the next larger array data type of the same kind. -* -* @param {string} [dtype] - array data type -* @returns {(Object|string|integer|null)} next larger data type(s) or null -* -* @example -* var dt = nextDataType( 'float32' ); -* // returns 'float64' -*/ -function nextDataType( dtype ) { - if ( arguments.length === 0 ) { - return generateTable(); - } - if ( hasOwnProp( NEXT_DTYPES, dtype ) ) { - return NEXT_DTYPES[ dtype ]; - } - return null; -} - - -// EXPORTS // - -module.exports = nextDataType; diff --git a/next-dtype/lib/next_dtypes.json b/next-dtype/lib/next_dtypes.json deleted file mode 100644 index 761b98774..000000000 --- a/next-dtype/lib/next_dtypes.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "float64": -1, - "float32": "float64", - "int32": -1, - "int16": "int32", - "int8": "int16", - "uint32": -1, - "uint16": "uint32", - "uint8": "uint16", - "uint8c": "uint16", - "generic": -1, - "bool": -1, - "complex64": "complex128", - "complex128": -1 -} diff --git a/next-dtype/package.json b/next-dtype/package.json deleted file mode 100644 index 6cfd78248..000000000 --- a/next-dtype/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/next-dtype", - "version": "0.0.0", - "description": "Return the next larger array data type of the same kind.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "casting", - "cast", - "rules", - "promotion", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/next-dtype/test/test.js b/next-dtype/test/test.js deleted file mode 100644 index b602fd571..000000000 --- a/next-dtype/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../dtypes' ); -var nextDataType = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nextDataType, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = nextDataType(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ], 'float64', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the next larger array data type of the same kind', function test( t ) { - var table; - var out; - var dt; - var i; - - table = nextDataType(); - - for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - out = nextDataType( dt ); - t.strictEqual( out, table[ dt ], 'returns expected value when provided '+dt ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( nextDataType( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/one-to-like/README.md b/one-to-like/README.md deleted file mode 100644 index d9722a35b..000000000 --- a/one-to-like/README.md +++ /dev/null @@ -1,169 +0,0 @@ - - -# oneToLike - -> Generate a linearly spaced numeric array whose elements increment by `1` starting from one and having the same length and data type as a provided input array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var oneToLike = require( '@stdlib/array/one-to-like' ); -``` - -#### oneToLike( x\[, dtype] ) - -Generates a linearly spaced numeric array whose elements increment by `1` starting from one and having the same length and data type as a provided input array `x`. - -```javascript -var arr = oneToLike( [ 0, 0, 0, 0, 0 ] ); -// returns [ 1, 2, 3, 4, 5 ] -``` - -The function recognizes the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers -- `int32`: 32-bit two's complement signed integers -- `uint32`: 32-bit unsigned integers -- `int16`: 16-bit two's complement signed integers -- `uint16`: 16-bit unsigned integers -- `int8`: 8-bit two's complement signed integers -- `uint8`: 8-bit unsigned integers -- `uint8c`: 8-bit unsigned integers clamped to `0-255` -- `generic`: generic JavaScript values - -By default, the output array data type is inferred from the provided array `x`. To return an array having a different data type, provide a `dtype` argument. - -```javascript -var arr = oneToLike( [ 0, 0, 0, 0, 0 ], 'int32' ); -// returns [ 1, 2, 3, 4, 5 ] -``` - -
- - - - - -
- -## Notes - -- For complex number arrays, each element of the returned array has an imaginary component equal to `0`. - -
- - - - - -
- -## Examples - - - -```javascript -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var oneToLike = require( '@stdlib/array/one-to-like' ); - -// Generate an array of random numbers: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 10, 100, 200, opts ); - -// Generate a linearly-spaced array: -var y = oneToLike( x ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort `y` according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, y, 1 ); - -console.log( x ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/one-to-like/benchmark/benchmark.js b/one-to-like/benchmark/benchmark.js deleted file mode 100644 index 3ddd06f36..000000000 --- a/one-to-like/benchmark/benchmark.js +++ /dev/null @@ -1,317 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex128' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8c' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'generic' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/one-to-like/benchmark/benchmark.length.complex128.js b/one-to-like/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 6b702be00..000000000 --- a/one-to-like/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex128' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/benchmark/benchmark.length.complex64.js b/one-to-like/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 06e9f8619..000000000 --- a/one-to-like/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/benchmark/benchmark.length.float32.js b/one-to-like/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9c7f7e57a..000000000 --- a/one-to-like/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/benchmark/benchmark.length.float64.js b/one-to-like/benchmark/benchmark.length.float64.js deleted file mode 100644 index 4d996a6a2..000000000 --- a/one-to-like/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/benchmark/benchmark.length.generic.js b/one-to-like/benchmark/benchmark.length.generic.js deleted file mode 100644 index 6107ad7ab..000000000 --- a/one-to-like/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/benchmark/benchmark.length.int16.js b/one-to-like/benchmark/benchmark.length.int16.js deleted file mode 100644 index 56b95d929..000000000 --- a/one-to-like/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/benchmark/benchmark.length.int32.js b/one-to-like/benchmark/benchmark.length.int32.js deleted file mode 100644 index 351813a1b..000000000 --- a/one-to-like/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/benchmark/benchmark.length.int8.js b/one-to-like/benchmark/benchmark.length.int8.js deleted file mode 100644 index b3c1e6a37..000000000 --- a/one-to-like/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/benchmark/benchmark.length.uint16.js b/one-to-like/benchmark/benchmark.length.uint16.js deleted file mode 100644 index b1a3ae845..000000000 --- a/one-to-like/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/benchmark/benchmark.length.uint32.js b/one-to-like/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 96c4f2093..000000000 --- a/one-to-like/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/benchmark/benchmark.length.uint8.js b/one-to-like/benchmark/benchmark.length.uint8.js deleted file mode 100644 index f8100c472..000000000 --- a/one-to-like/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/benchmark/benchmark.length.uint8c.js b/one-to-like/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 679202e53..000000000 --- a/one-to-like/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var oneToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8c' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/one-to-like/docs/repl.txt b/one-to-like/docs/repl.txt deleted file mode 100644 index 9db036cae..000000000 --- a/one-to-like/docs/repl.txt +++ /dev/null @@ -1,45 +0,0 @@ - -{{alias}}( x[, dtype] ) - Generates a linearly spaced numeric array whose elements increment by 1 - starting from one and having the same length and data type as a provided - input array. - - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754). - - float32: single-precision floating-point numbers (IEEE 754). - - complex128: double-precision complex floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - int32: 32-bit two's complement signed integers. - - uint32: 32-bit unsigned integers. - - int16: 16-bit two's complement signed integers. - - uint16: 16-bit unsigned integers. - - int8: 8-bit two's complement signed integers. - - uint8: 8-bit unsigned integers. - - uint8c: 8-bit unsigned integers clamped to 0-255. - - generic: generic JavaScript values. - - Parameters - ---------- - x: TypedArray|Array - Input array. - - dtype: string (optional) - Data type. If not provided, the output array data type is inferred from - the input array. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 0, 0 ] ) - [ 1, 2 ] - > arr = {{alias}}( [ 0, 0 ], 'float32' ) - [ 1.0, 2.0 ] - - See Also - -------- - diff --git a/one-to-like/docs/types/index.d.ts b/one-to-like/docs/types/index.d.ts deleted file mode 100644 index 549279518..000000000 --- a/one-to-like/docs/types/index.d.ts +++ /dev/null @@ -1,494 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Complex128Array, Complex64Array, AnyArray, NumericDataType } from '@stdlib/types/array'; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'float64' ); -* // returns [ 1.0, 2.0 ] -*/ -declare function oneToLike( x: AnyArray, dtype: 'float64' ): Float64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'float32' ); -* // returns [ 1.0, 2.0 ] -*/ -declare function oneToLike( x: AnyArray, dtype: 'float32' ): Float32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'complex128' ); -* // returns -*/ -declare function oneToLike( x: AnyArray, dtype: 'complex128' ): Complex128Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'complex64' ); -* // returns -*/ -declare function oneToLike( x: AnyArray, dtype: 'complex64' ): Complex64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'int32' ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: AnyArray, dtype: 'int32' ): Int32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'int16' ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: AnyArray, dtype: 'int16' ): Int16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'int8' ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: AnyArray, dtype: 'int8' ): Int8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'uint32' ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: AnyArray, dtype: 'uint32' ): Uint32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'uint16' ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: AnyArray, dtype: 'uint16' ): Uint16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'uint8' ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: AnyArray, dtype: 'uint8' ): Uint8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'uint8c' ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: AnyArray, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x, 'generic' ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: AnyArray, dtype: 'generic' ): Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x ); -* // returns [ 1.0, 2.0 ] -*/ -declare function oneToLike( x: Float64Array, dtype?: NumericDataType ): Float64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x ); -* // returns [ 1.0, 2.0 ] -*/ -declare function oneToLike( x: Float32Array, dtype?: NumericDataType ): Float32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex128' ); -* // returns -* -* var y = oneToLike( x ); -* // returns -*/ -declare function oneToLike( x: Complex128Array, dtype?: NumericDataType ): Complex128Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex64' ); -* // returns -* -* var y = oneToLike( x ); -* // returns -*/ -declare function oneToLike( x: Complex64Array, dtype?: NumericDataType ): Complex64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int32' ); -* // returns [ 0, 0 ] -* -* var y = oneToLike( x ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: Int32Array, dtype?: NumericDataType ): Int32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int16' ); -* // returns [ 0, 0 ] -* -* var y = oneToLike( x ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: Int16Array, dtype?: NumericDataType ): Int16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int8' ); -* // returns [ 0, 0 ] -* -* var y = oneToLike( x ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: Int8Array, dtype?: NumericDataType ): Int8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint32' ); -* // returns [ 0, 0 ] -* -* var y = oneToLike( x ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: Uint32Array, dtype?: NumericDataType ): Uint32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint16' ); -* // returns [ 0, 0 ] -* -* var y = oneToLike( x ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: Uint16Array, dtype?: NumericDataType ): Uint16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint8' ); -* // returns [ 0, 0 ] -* -* var y = oneToLike( x ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: Uint8Array, dtype?: NumericDataType ): Uint8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint8c' ); -* // returns [ 0, 0 ] -* -* var y = oneToLike( x ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: Uint8ClampedArray, dtype?: NumericDataType ): Uint8ClampedArray; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'generic' ); -* // returns [ 0, 0 ] -* -* var y = oneToLike( x ); -* // returns [ 1, 2 ] -*/ -declare function oneToLike( x: Array, dtype?: NumericDataType ): Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = oneToLike( x ); -* // returns [ 1.0, 2.0 ] -*/ -declare function oneToLike( x: AnyArray, dtype?: NumericDataType ): AnyArray; - - -// EXPORTS // - -export = oneToLike; diff --git a/one-to-like/docs/types/test.ts b/one-to-like/docs/types/test.ts deleted file mode 100644 index 6b693c955..000000000 --- a/one-to-like/docs/types/test.ts +++ /dev/null @@ -1,89 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import oneToLike = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - oneToLike( [ 0, 0 ] ); // $ExpectType number[] - oneToLike( new Float64Array( [ 0, 0 ] ) ); // $ExpectType Float64Array - oneToLike( new Float32Array( [ 0, 0 ] ) ); // $ExpectType Float32Array - oneToLike( new Complex128Array( [ 0, 0 ] ) ); // $ExpectType Complex128Array - oneToLike( new Complex64Array( [ 0, 0 ] ) ); // $ExpectType Complex64Array - oneToLike( new Int32Array( [ 0, 0 ] ) ); // $ExpectType Int32Array - oneToLike( new Int16Array( [ 0, 0 ] ) ); // $ExpectType Int16Array - oneToLike( new Int8Array( [ 0, 0 ] ) ); // $ExpectType Int8Array - oneToLike( new Uint32Array( [ 0, 0 ] ) ); // $ExpectType Uint32Array - oneToLike( new Uint16Array( [ 0, 0 ] ) ); // $ExpectType Uint16Array - oneToLike( new Uint8Array( [ 0, 0 ] ) ); // $ExpectType Uint8Array - oneToLike( new Uint8ClampedArray( [ 0, 0 ] ) ); // $ExpectType Uint8ClampedArray - - oneToLike( [ 0, 0 ], 'float64' ); // $ExpectType Float64Array - oneToLike( [ 0, 0 ], 'float32' ); // $ExpectType Float32Array - oneToLike( [ 0, 0 ], 'complex128' ); // $ExpectType Complex128Array - oneToLike( [ 0, 0 ], 'complex64' ); // $ExpectType Complex64Array - oneToLike( [ 0, 0 ], 'int32' ); // $ExpectType Int32Array - oneToLike( [ 0, 0 ], 'int16' ); // $ExpectType Int16Array - oneToLike( [ 0, 0 ], 'int8' ); // $ExpectType Int8Array - oneToLike( [ 0, 0 ], 'uint32' ); // $ExpectType Uint32Array - oneToLike( [ 0, 0 ], 'uint16' ); // $ExpectType Uint16Array - oneToLike( [ 0, 0 ], 'uint8' ); // $ExpectType Uint8Array - oneToLike( [ 0, 0 ], 'uint8c' ); // $ExpectType Uint8ClampedArray - oneToLike( [ 0, 0 ], 'generic' ); // $ExpectType number[] -} - -// The compiler throws an error if the function is not provided an array or typed array for the first argument... -{ - oneToLike( '5' ); // $ExpectError - oneToLike( false ); // $ExpectError - oneToLike( true ); // $ExpectError - oneToLike( null ); // $ExpectError - oneToLike( undefined ); // $ExpectError - oneToLike( {} ); // $ExpectError - oneToLike( ( x: number ): number => x ); // $ExpectError - - oneToLike( '5', 'float32' ); // $ExpectError - oneToLike( false, 'float32' ); // $ExpectError - oneToLike( true, 'float32' ); // $ExpectError - oneToLike( null, 'float32' ); // $ExpectError - oneToLike( undefined, 'float32' ); // $ExpectError - oneToLike( {}, 'float32' ); // $ExpectError - oneToLike( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - oneToLike( [ 0, 0 ], '10' ); // $ExpectError - oneToLike( [ 0, 0 ], 10 ); // $ExpectError - oneToLike( [ 0, 0 ], false ); // $ExpectError - oneToLike( [ 0, 0 ], true ); // $ExpectError - oneToLike( [ 0, 0 ], null ); // $ExpectError - oneToLike( [ 0, 0 ], [] ); // $ExpectError - oneToLike( [ 0, 0 ], {} ); // $ExpectError - oneToLike( [ 0, 0 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - oneToLike( [ 0, 0 ], 'float64', 1 ); // $ExpectError -} diff --git a/one-to-like/examples/index.js b/one-to-like/examples/index.js deleted file mode 100644 index d7cdb5d15..000000000 --- a/one-to-like/examples/index.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var oneToLike = require( './../lib' ); - -// Generate an array of random numbers: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 10, 100, 200, opts ); - -// Generate a linearly-spaced array: -var y = oneToLike( x ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort `y` according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, y, 1 ); - -console.log( x ); -console.log( y ); diff --git a/one-to-like/lib/index.js b/one-to-like/lib/index.js deleted file mode 100644 index bd64dffd1..000000000 --- a/one-to-like/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Generate a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @module @stdlib/array/one-to-like -* -* @example -* var oneToLike = require( '@stdlib/array/one-to-like' ); -* -* var arr = oneToLike( [ 0.0, 0.0 ] ); -* // returns [ 1.0, 2.0 ] -* -* @example -* var oneToLike = require( '@stdlib/array/one-to-like' ); -* -* var arr = oneToLike( [ 0.0, 0.0 ], 'float32' ); -* // returns [ 1.0, 2.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/one-to-like/lib/main.js b/one-to-like/lib/main.js deleted file mode 100644 index e5cf4d4a1..000000000 --- a/one-to-like/lib/main.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var oneTo = require( './../../one-to' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array. -* -* @param {(TypedArray|Array|ComplexArray)} x - input array -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} first argument must be an array or typed array -* @throws {TypeError} second argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = oneToLike( [ 0.0, 0.0 ] ); -* // returns [ 1.0, 2.0 ] -* -* @example -* var arr = oneToLike( [ 0.0, 0.0 ], 'float32' ); -* // returns [ 1.0, 2.0 ] -*/ -function oneToLike( x ) { - var dt = dtype( x ); // delegate input argument validation to dtype resolution - if ( dt === null ) { - throw new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) ); - } - if ( arguments.length > 1 ) { - dt = arguments[ 1 ]; - } - return oneTo( x.length, dt ); -} - - -// EXPORTS // - -module.exports = oneToLike; diff --git a/one-to-like/package.json b/one-to-like/package.json deleted file mode 100644 index 155a9e703..000000000 --- a/one-to-like/package.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "name": "@stdlib/array/one-to-like", - "version": "0.0.0", - "description": "Generate a linearly spaced numeric array whose elements increment by 1 starting from one and having the same length and data type as a provided input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "fill", - "filled", - "matlab", - "linear", - "linspace", - "sequence", - "increment", - "unitspace" - ] -} diff --git a/one-to-like/test/test.js b/one-to-like/test/test.js deleted file mode 100644 index 184e316ec..000000000 --- a/one-to-like/test/test.js +++ /dev/null @@ -1,524 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var oneToLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof oneToLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - oneToLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - oneToLike( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'oneToLike', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - oneToLike( [], value ); - }; - } -}); - -tape( 'the function returns a filled array (float64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float32Array( 5 ); - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - arr = oneToLike( x, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (float32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float32Array( 5 ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - arr = oneToLike( x, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (complex128)', function test( t ) { - var expected; - var arr; - var x; - - x = new Complex128Array( 4 ); - expected = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 4 ); - expected = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); - - arr = oneToLike( x, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (complex64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Complex64Array( 4 ); - expected = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 4 ); - expected = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); - - arr = oneToLike( x, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (int32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int32Array( 5 ); - expected = new Int32Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int32Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint32Array( 5 ); - expected = new Uint32Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint32Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (int16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int16Array( 5 ); - expected = new Int16Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int16Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint16Array( 5 ); - expected = new Uint16Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint16Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (int8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int8Array( 5 ); - expected = new Int8Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int8Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint8Array( 5 ); - expected = new Uint8Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint8Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint8c)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint8ClampedArray( 5 ); - expected = new Uint8ClampedArray( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint8ClampedArray( [ 1, 2, 3, 4, 5 ] ); - - arr = oneToLike( x, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (generic)', function test( t ) { - var expected; - var arr; - var x; - - x = [ 0, 0, 0, 0, 0 ]; - expected = [ 1, 2, 3, 4, 5 ]; - - arr = oneToLike( x ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = [ 1, 2, 3, 4, 5 ]; - - arr = oneToLike( x, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/one-to/README.md b/one-to/README.md deleted file mode 100644 index a767c284a..000000000 --- a/one-to/README.md +++ /dev/null @@ -1,178 +0,0 @@ - - -# oneTo - -> Generate a linearly spaced numeric array whose elements increment by `1` starting from one. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var oneTo = require( '@stdlib/array/one-to' ); -``` - -#### oneTo( n\[, dtype] ) - -Generates a linearly spaced numeric array whose elements increment by `1` starting from one. - -```javascript -var arr = oneTo( 5 ); -// returns [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -``` - -If `n == 0`, the function returns an empty array. - -```javascript -var arr = oneTo( 0 ); -// returns [] -``` - -The function recognizes the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers -- `int32`: 32-bit two's complement signed integers -- `uint32`: 32-bit unsigned integers -- `int16`: 16-bit two's complement signed integers -- `uint16`: 16-bit unsigned integers -- `int8`: 8-bit two's complement signed integers -- `uint8`: 8-bit unsigned integers -- `uint8c`: 8-bit unsigned integers clamped to `0-255` -- `generic`: generic JavaScript values - -By default, the output array data type is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative data type, provide a `dtype` argument. - -```javascript -var arr = oneTo( 5, 'int32' ); -// returns [ 1, 2, 3, 4, 5 ] -``` - -
- - - - - -
- -## Notes - -- For complex number arrays, each element of the returned array has an imaginary component equal to `0`. - -
- - - - - -
- -## Examples - - - -```javascript -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var oneTo = require( '@stdlib/array/one-to' ); - -// Generate an array of random numbers: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 10, 100, 200, opts ); - -// Generate a linearly-spaced array: -var y = oneTo( x.length, opts.dtype ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort `y` according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, y, 1 ); - -console.log( x ); -console.log( y ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/one-to/benchmark/benchmark.js b/one-to/benchmark/benchmark.js deleted file mode 100644 index 8a31d7070..000000000 --- a/one-to/benchmark/benchmark.js +++ /dev/null @@ -1,264 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( 0, 'generic' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/one-to/benchmark/benchmark.length.complex128.js b/one-to/benchmark/benchmark.length.complex128.js deleted file mode 100644 index a765a5666..000000000 --- a/one-to/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/one-to/benchmark/benchmark.length.complex64.js b/one-to/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 951f76020..000000000 --- a/one-to/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/one-to/benchmark/benchmark.length.float32.js b/one-to/benchmark/benchmark.length.float32.js deleted file mode 100644 index f44a612cd..000000000 --- a/one-to/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/one-to/benchmark/benchmark.length.float64.js b/one-to/benchmark/benchmark.length.float64.js deleted file mode 100644 index f5c9c60eb..000000000 --- a/one-to/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/one-to/benchmark/benchmark.length.generic.js b/one-to/benchmark/benchmark.length.generic.js deleted file mode 100644 index 67518efc0..000000000 --- a/one-to/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'generic' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/one-to/benchmark/benchmark.length.int16.js b/one-to/benchmark/benchmark.length.int16.js deleted file mode 100644 index 1e40b77ac..000000000 --- a/one-to/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/one-to/benchmark/benchmark.length.int32.js b/one-to/benchmark/benchmark.length.int32.js deleted file mode 100644 index ceefdd8f9..000000000 --- a/one-to/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/one-to/benchmark/benchmark.length.int8.js b/one-to/benchmark/benchmark.length.int8.js deleted file mode 100644 index 68c0dadcc..000000000 --- a/one-to/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/one-to/benchmark/benchmark.length.uint16.js b/one-to/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 2e68b3dd2..000000000 --- a/one-to/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/one-to/benchmark/benchmark.length.uint32.js b/one-to/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 0c35d2008..000000000 --- a/one-to/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/one-to/benchmark/benchmark.length.uint8.js b/one-to/benchmark/benchmark.length.uint8.js deleted file mode 100644 index b68776d41..000000000 --- a/one-to/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/one-to/benchmark/benchmark.length.uint8c.js b/one-to/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 849352cf1..000000000 --- a/one-to/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var oneTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = oneTo( len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/one-to/docs/repl.txt b/one-to/docs/repl.txt deleted file mode 100644 index d80892df6..000000000 --- a/one-to/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( n[, dtype] ) - Generates a linearly spaced numeric array whose elements increment by 1 - starting from one. - - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754). - - float32: single-precision floating-point numbers (IEEE 754). - - complex128: double-precision complex floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - int32: 32-bit two's complement signed integers. - - uint32: 32-bit unsigned integers. - - int16: 16-bit two's complement signed integers. - - uint16: 16-bit unsigned integers. - - int8: 8-bit two's complement signed integers. - - uint8: 8-bit unsigned integers. - - uint8c: 8-bit unsigned integers clamped to 0-255. - - generic: generic JavaScript values. - - The default array data type is `float64`. - - If `n` is equal to zero, the function returns an empty array. - - Parameters - ---------- - n: integer - Number of elements. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 2 ) - [ 1.0, 2.0 ] - > arr = {{alias}}( 2, 'float32' ) - [ 1.0, 2.0 ] - - See Also - -------- - diff --git a/one-to/docs/types/index.d.ts b/one-to/docs/types/index.d.ts deleted file mode 100644 index dd7b3407e..000000000 --- a/one-to/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { NumericAndGenericDataTypeMap } from '@stdlib/types/array'; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param n - number of elements -* @param dtype - data type (default: 'float64') -* @returns linearly spaced numeric array -* -* @example -* var arr = oneTo( 2 ); -* // returns [ 1.0, 2.0 ] -* -* @example -* var arr = oneTo( 2, 'float32' ); -* // returns [ 1.0, 2.0 ] -*/ -declare function oneTo = 'float64'>( n: number, dtype?: T ): NumericAndGenericDataTypeMap[T]; - - -// EXPORTS // - -export = oneTo; diff --git a/one-to/docs/types/test.ts b/one-to/docs/types/test.ts deleted file mode 100644 index 38c4d9c3d..000000000 --- a/one-to/docs/types/test.ts +++ /dev/null @@ -1,77 +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. -*/ - -import oneTo = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - oneTo( 10 ); // $ExpectType Float64Array - oneTo( 10, 'float64' ); // $ExpectType Float64Array - oneTo( 10, 'float32' ); // $ExpectType Float32Array - oneTo( 10, 'complex128' ); // $ExpectType Complex128Array - oneTo( 10, 'complex64' ); // $ExpectType Complex64Array - oneTo( 10, 'int32' ); // $ExpectType Int32Array - oneTo( 10, 'int16' ); // $ExpectType Int16Array - oneTo( 10, 'int8' ); // $ExpectType Int8Array - oneTo( 10, 'uint32' ); // $ExpectType Uint32Array - oneTo( 10, 'uint16' ); // $ExpectType Uint16Array - oneTo( 10, 'uint8' ); // $ExpectType Uint8Array - oneTo( 10, 'uint8c' ); // $ExpectType Uint8ClampedArray - oneTo( 10, 'generic' ); // $ExpectType number[] -} - -// The compiler throws an error if the function is not provided a number for the first argument... -{ - oneTo( '5' ); // $ExpectError - oneTo( false ); // $ExpectError - oneTo( true ); // $ExpectError - oneTo( null ); // $ExpectError - oneTo( undefined ); // $ExpectError - oneTo( [] ); // $ExpectError - oneTo( {} ); // $ExpectError - oneTo( ( x: number ): number => x ); // $ExpectError - - oneTo( '5', 'float32' ); // $ExpectError - oneTo( false, 'float32' ); // $ExpectError - oneTo( true, 'float32' ); // $ExpectError - oneTo( null, 'float32' ); // $ExpectError - oneTo( undefined, 'float32' ); // $ExpectError - oneTo( [], 'float32' ); // $ExpectError - oneTo( {}, 'float32' ); // $ExpectError - oneTo( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - oneTo( 10, '10' ); // $ExpectError - oneTo( 10, 10 ); // $ExpectError - oneTo( 10, false ); // $ExpectError - oneTo( 10, true ); // $ExpectError - oneTo( 10, null ); // $ExpectError - oneTo( 10, [] ); // $ExpectError - oneTo( 10, {} ); // $ExpectError - oneTo( 10, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - oneTo( 10, 'float64', 1 ); // $ExpectError -} diff --git a/one-to/examples/index.js b/one-to/examples/index.js deleted file mode 100644 index 369c77852..000000000 --- a/one-to/examples/index.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var oneTo = require( './../lib' ); - -// Generate an array of random numbers: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 10, 100, 200, opts ); - -// Generate a linearly-spaced array: -var y = oneTo( x.length, opts.dtype ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort `y` according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, y, 1 ); - -console.log( x ); -console.log( y ); diff --git a/one-to/lib/index.js b/one-to/lib/index.js deleted file mode 100644 index 7047ea892..000000000 --- a/one-to/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Generate a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @module @stdlib/array/one-to -* -* @example -* var oneTo = require( '@stdlib/array/one-to' ); -* -* var arr = oneTo( 2 ); -* // returns [ 1.0, 2.0 ] -* -* @example -* var oneTo = require( '@stdlib/array/one-to' ); -* -* var arr = oneTo( 2, 'float32' ); -* // returns [ 1.0, 2.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/one-to/lib/main.js b/one-to/lib/main.js deleted file mode 100644 index 2c8bb259b..000000000 --- a/one-to/lib/main.js +++ /dev/null @@ -1,73 +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. -*/ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var base = require( './../../base/one-to' ); -var zeros = require( './../../zeros' ); -var defaults = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// MAIN // - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from one. -* -* @param {NonNegativeInteger} n - number of elements -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = oneTo( 2 ); -* // returns [ 1.0, 2.0 ] -* -* @example -* var arr = oneTo( 2, 'float32' ); -* // returns [ 1.0, 2.0 ] -*/ -function oneTo( n ) { - var dtype; - if ( !isNonNegativeInteger( n ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', n ) ); - } - if ( arguments.length > 1 ) { - dtype = arguments[ 1 ]; - if ( dtype === 'generic' ) { - return base( n ); - } - } else { - dtype = DEFAULT_DTYPE; - } - return base.assign( zeros( n, dtype ), 1, 0 ); // defer dtype validation to `zeros` -} - - -// EXPORTS // - -module.exports = oneTo; diff --git a/one-to/package.json b/one-to/package.json deleted file mode 100644 index 286227ffc..000000000 --- a/one-to/package.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "name": "@stdlib/array/one-to", - "version": "0.0.0", - "description": "Generate a linearly spaced numeric array whose elements increment by 1 starting from one.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "fill", - "filled", - "matlab", - "linear", - "linspace", - "sequence", - "increment", - "unitspace" - ] -} diff --git a/one-to/test/test.js b/one-to/test/test.js deleted file mode 100644 index 013a21e9e..000000000 --- a/one-to/test/test.js +++ /dev/null @@ -1,396 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var oneTo = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof oneTo, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - oneTo( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - oneTo( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'oneTo', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - oneTo( 10, value ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - arr = oneTo( 5 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - arr = oneTo( 5, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); - - arr = oneTo( 5, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); - - arr = oneTo( 4, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0 ] ); - - arr = oneTo( 4, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneTo( 5, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneTo( 5, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneTo( 5, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneTo( 5, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneTo( 5, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 2, 3, 4, 5 ] ); - - arr = oneTo( 5, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 1, 2, 3, 4, 5 ] ); - - arr = oneTo( 5, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - - expected = [ 1, 2, 3, 4, 5 ]; - - arr = oneTo( 5, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if `n` is zero, the function returns an empty array', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [] ); - arr = oneTo( 0 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Float64Array( [] ); - arr = oneTo( 0, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Float32Array( [] ); - arr = oneTo( 0, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Int32Array( [] ); - arr = oneTo( 0, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Int16Array( [] ); - arr = oneTo( 0, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Int8Array( [] ); - arr = oneTo( 0, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Uint32Array( [] ); - arr = oneTo( 0, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Uint16Array( [] ); - arr = oneTo( 0, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Uint8Array( [] ); - arr = oneTo( 0, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Uint8ClampedArray( [] ); - arr = oneTo( 0, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Complex128Array( [] ); - arr = oneTo( 0, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Complex64Array( [] ); - arr = oneTo( 0, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = []; - arr = oneTo( 0, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - t.end(); -}); diff --git a/ones-like/README.md b/ones-like/README.md deleted file mode 100644 index d04a5aaff..000000000 --- a/ones-like/README.md +++ /dev/null @@ -1,169 +0,0 @@ - - -# onesLike - -> Create an array filled with ones and having the same length and data type as a provided array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var onesLike = require( '@stdlib/array/ones-like' ); -``` - -#### onesLike( x\[, dtype] ) - -Creates an array filled with ones and having the same length and data type as a provided array `x`. - -```javascript -var x = [ 1, 2, 3, 4, 5 ]; - -var arr = onesLike( x ); -// returns [ 1, 1, 1, 1, 1 ] -``` - -The function supports the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers -- `int32`: 32-bit two's complement signed integers -- `uint32`: 32-bit unsigned integers -- `int16`: 16-bit two's complement signed integers -- `uint16`: 16-bit unsigned integers -- `int8`: 8-bit two's complement signed integers -- `uint8`: 8-bit unsigned integers -- `uint8c`: 8-bit unsigned integers clamped to `0-255` -- `generic`: generic JavaScript values - -By default, the output array data type is inferred from the provided array `x`. To return an array having a different data type, provide a `dtype` argument. - -```javascript -var x = [ 0, 0 ]; - -var arr = onesLike( x, 'int32' ); -// returns [ 1, 1 ] -``` - -
- - - - - -
- -## Notes - -- If the output array has a complex number data type, each element of the returned array has a real component equal to `1` and an imaginary component equal to `0`. - -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var zeros = require( '@stdlib/array/zeros' ); -var onesLike = require( '@stdlib/array/ones-like' ); - -// Create a zero-filled array: -var x = zeros( 4, 'complex128' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - y = onesLike( x, dt[ i ] ); - console.log( y ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ones-like/benchmark/benchmark.js b/ones-like/benchmark/benchmark.js deleted file mode 100644 index d0f514403..000000000 --- a/ones-like/benchmark/benchmark.js +++ /dev/null @@ -1,317 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex128' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8c' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'generic' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/ones-like/benchmark/benchmark.length.complex128.js b/ones-like/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 7994a1570..000000000 --- a/ones-like/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex128' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/ones-like/benchmark/benchmark.length.complex64.js b/ones-like/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 4c3d88338..000000000 --- a/ones-like/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/ones-like/benchmark/benchmark.length.float32.js b/ones-like/benchmark/benchmark.length.float32.js deleted file mode 100644 index 70f773270..000000000 --- a/ones-like/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/ones-like/benchmark/benchmark.length.float64.js b/ones-like/benchmark/benchmark.length.float64.js deleted file mode 100644 index 39eb162d0..000000000 --- a/ones-like/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/ones-like/benchmark/benchmark.length.generic.js b/ones-like/benchmark/benchmark.length.generic.js deleted file mode 100644 index ed7f12fa5..000000000 --- a/ones-like/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/ones-like/benchmark/benchmark.length.int16.js b/ones-like/benchmark/benchmark.length.int16.js deleted file mode 100644 index d129ff075..000000000 --- a/ones-like/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/ones-like/benchmark/benchmark.length.int32.js b/ones-like/benchmark/benchmark.length.int32.js deleted file mode 100644 index de1e69c13..000000000 --- a/ones-like/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/ones-like/benchmark/benchmark.length.int8.js b/ones-like/benchmark/benchmark.length.int8.js deleted file mode 100644 index 96cb20ce9..000000000 --- a/ones-like/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/ones-like/benchmark/benchmark.length.uint16.js b/ones-like/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 1b4147b99..000000000 --- a/ones-like/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/ones-like/benchmark/benchmark.length.uint32.js b/ones-like/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 2000480c9..000000000 --- a/ones-like/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/ones-like/benchmark/benchmark.length.uint8.js b/ones-like/benchmark/benchmark.length.uint8.js deleted file mode 100644 index a1298b265..000000000 --- a/ones-like/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/ones-like/benchmark/benchmark.length.uint8c.js b/ones-like/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 4f4d2789d..000000000 --- a/ones-like/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var onesLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8c' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = onesLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/ones-like/docs/repl.txt b/ones-like/docs/repl.txt deleted file mode 100644 index d67ed4903..000000000 --- a/ones-like/docs/repl.txt +++ /dev/null @@ -1,45 +0,0 @@ - -{{alias}}( x[, dtype] ) - Returns an array filled with ones and having the same length and data type - as a provided input array. - - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754). - - float32: single-precision floating-point numbers (IEEE 754). - - complex128: double-precision complex floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - int32: 32-bit two's complement signed integers. - - uint32: 32-bit unsigned integers. - - int16: 16-bit two's complement signed integers. - - uint16: 16-bit unsigned integers. - - int8: 8-bit two's complement signed integers. - - uint8: 8-bit unsigned integers. - - uint8c: 8-bit unsigned integers clamped to 0-255. - - generic: generic JavaScript values. - - Parameters - ---------- - x: TypedArray|Array - Input array. - - dtype: string (optional) - Data type. If not provided, the output array data type is inferred from - the input array. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var x = new {{alias:@stdlib/array/float64}}( 2 ); - > var y = {{alias}}( x ) - [ 1.0, 1.0 ] - > y = {{alias}}( x, 'float32' ) - [ 1.0, 1.0 ] - - See Also - -------- - diff --git a/ones-like/docs/types/index.d.ts b/ones-like/docs/types/index.d.ts deleted file mode 100644 index 2b85c7692..000000000 --- a/ones-like/docs/types/index.d.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { NumericAndGenericDataTypeMap, AnyArray, TypedArray, ComplexTypedArray } from '@stdlib/types/array'; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'generic' ); -* // returns [ 0, 0 ] -* -* var y = onesLike( x ); -* // returns [ 1, 1 ] -*/ -declare function onesLike( x: Array ): Array; - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x ); -* // returns [ 1.0, 1.0 ] -*/ -declare function onesLike( x: T ): T; - -/** -* Creates an array filled with ones and having the same length as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = onesLike( x, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function onesLike>( x: AnyArray, dtype: T ): NumericAndGenericDataTypeMap[T]; - - -// EXPORTS // - -export = onesLike; diff --git a/ones-like/docs/types/test.ts b/ones-like/docs/types/test.ts deleted file mode 100644 index dd139b2e8..000000000 --- a/ones-like/docs/types/test.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import onesLike = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - onesLike( [ 0, 0 ] ); // $ExpectType number[] - onesLike( new Float64Array( [ 0, 0 ] ) ); // $ExpectType Float64Array - onesLike( new Float32Array( [ 0, 0 ] ) ); // $ExpectType Float32Array - onesLike( new Complex128Array( [ 0, 0 ] ) ); // $ExpectType Complex128Array - onesLike( new Complex64Array( [ 0, 0 ] ) ); // $ExpectType Complex64Array - onesLike( new Int32Array( [ 0, 0 ] ) ); // $ExpectType Int32Array - onesLike( new Int16Array( [ 0, 0 ] ) ); // $ExpectType Int16Array - onesLike( new Int8Array( [ 0, 0 ] ) ); // $ExpectType Int8Array - onesLike( new Uint32Array( [ 0, 0 ] ) ); // $ExpectType Uint32Array - onesLike( new Uint16Array( [ 0, 0 ] ) ); // $ExpectType Uint16Array - onesLike( new Uint8Array( [ 0, 0 ] ) ); // $ExpectType Uint8Array - onesLike( new Uint8ClampedArray( [ 0, 0 ] ) ); // $ExpectType Uint8ClampedArray - onesLike( [ 'a', 'b', 'c' ] ); // $ExpectType number[] - - onesLike( [ 0, 0 ], 'float64' ); // $ExpectType Float64Array - onesLike( [ 0, 0 ], 'float32' ); // $ExpectType Float32Array - onesLike( [ 0, 0 ], 'complex128' ); // $ExpectType Complex128Array - onesLike( [ 0, 0 ], 'complex64' ); // $ExpectType Complex64Array - onesLike( [ 0, 0 ], 'int32' ); // $ExpectType Int32Array - onesLike( [ 0, 0 ], 'int16' ); // $ExpectType Int16Array - onesLike( [ 0, 0 ], 'int8' ); // $ExpectType Int8Array - onesLike( [ 0, 0 ], 'uint32' ); // $ExpectType Uint32Array - onesLike( [ 0, 0 ], 'uint16' ); // $ExpectType Uint16Array - onesLike( [ 0, 0 ], 'uint8' ); // $ExpectType Uint8Array - onesLike( [ 0, 0 ], 'uint8c' ); // $ExpectType Uint8ClampedArray - onesLike( [ 0, 0 ], 'generic' ); // $ExpectType number[] - onesLike( new Int32Array( [ 0, 0 ] ), 'generic' ); // $ExpectType number[] - onesLike( [ 'a', 'b', 'c' ], 'generic' ); // $ExpectType number[] - onesLike( [ 'a', 'b', 'c' ], 'float64' ); // $ExpectType Float64Array -} - -// The compiler throws an error if the function is not provided an array or typed array for the first argument... -{ - onesLike( '5' ); // $ExpectError - onesLike( 5 ); // $ExpectError - onesLike( false ); // $ExpectError - onesLike( true ); // $ExpectError - onesLike( null ); // $ExpectError - onesLike( undefined ); // $ExpectError - onesLike( {} ); // $ExpectError - onesLike( ( x: number ): number => x ); // $ExpectError - - onesLike( '5', 'float32' ); // $ExpectError - onesLike( 5, 'float32' ); // $ExpectError - onesLike( false, 'float32' ); // $ExpectError - onesLike( true, 'float32' ); // $ExpectError - onesLike( null, 'float32' ); // $ExpectError - onesLike( undefined, 'float32' ); // $ExpectError - onesLike( {}, 'float32' ); // $ExpectError - onesLike( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - onesLike( [ 0, 0 ], '10' ); // $ExpectError - onesLike( [ 0, 0 ], 10 ); // $ExpectError - onesLike( [ 0, 0 ], false ); // $ExpectError - onesLike( [ 0, 0 ], true ); // $ExpectError - onesLike( [ 0, 0 ], null ); // $ExpectError - onesLike( [ 0, 0 ], [] ); // $ExpectError - onesLike( [ 0, 0 ], {} ); // $ExpectError - onesLike( [ 0, 0 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - onesLike( [ 0, 0 ], 'float64', 1 ); // $ExpectError -} diff --git a/ones-like/examples/index.js b/ones-like/examples/index.js deleted file mode 100644 index c9c657815..000000000 --- a/ones-like/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../dtypes' ); -var zeros = require( './../../zeros' ); -var onesLike = require( './../lib' ); - -// Create a zero-filled array: -var x = zeros( 4, 'complex128' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - y = onesLike( x, dt[ i ] ); - console.log( y ); -} diff --git a/ones-like/lib/index.js b/ones-like/lib/index.js deleted file mode 100644 index 968d255f3..000000000 --- a/ones-like/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an array filled with ones and having the same length and data type as a provided input array. -* -* @module @stdlib/array/ones-like -* -* @example -* var onesLike = require( '@stdlib/array/ones-like' ); -* -* var arr = onesLike( [ 0.0, 0.0 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var onesLike = require( '@stdlib/array/ones-like' ); -* -* var arr = onesLike( [ 0.0, 0.0 ], 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ones-like/lib/main.js b/ones-like/lib/main.js deleted file mode 100644 index 92bd05f7c..000000000 --- a/ones-like/lib/main.js +++ /dev/null @@ -1,79 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var dtype = require( './../../dtype' ); -var full = require( './../../full' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var Z128 = new Complex128( 1.0, 0.0 ); -var Z64 = new Complex64( 1.0, 0.0 ); - - -// MAIN // - -/** -* Creates an array filled with ones and having the same length and data type as a provided input array. -* -* @param {(Array|TypedArray|ComplexArray)} x - input array -* @param {string} [dtype] - data type -* @throws {TypeError} first argument must be an array or typed array -* @throws {TypeError} second argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = onesLike( [ 0.0, 0.0 ] ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = onesLike( [ 0.0, 0.0 ], 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -function onesLike( x ) { - var dt; - var v; - - dt = dtype( x ); // delegate input argument validation to dtype resolution - if ( dt === null ) { - throw new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) ); - } - if ( arguments.length > 1 ) { - dt = arguments[ 1 ]; - } - if ( dt === 'complex128' ) { - v = Z128; - } else if ( dt === 'complex64' ) { - v = Z64; - } else { - v = 1.0; - } - return full( x.length, v, dt ); -} - - -// EXPORTS // - -module.exports = onesLike; diff --git a/ones-like/package.json b/ones-like/package.json deleted file mode 100644 index e0fac501d..000000000 --- a/ones-like/package.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "name": "@stdlib/array/ones-like", - "version": "0.0.0", - "description": "Create an array filled with ones and having the same length and data type as a provided array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "fill", - "filled", - "ones" - ] -} diff --git a/ones-like/test/test.js b/ones-like/test/test.js deleted file mode 100644 index b7b37b7c9..000000000 --- a/ones-like/test/test.js +++ /dev/null @@ -1,524 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var onesLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof onesLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - onesLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - onesLike( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'onesLike', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - onesLike( [], value ); - }; - } -}); - -tape( 'the function returns a ones-filled array (float64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float32Array( 5 ); - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = onesLike( x, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (float32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float32Array( 5 ); - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = onesLike( x, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (complex128)', function test( t ) { - var expected; - var arr; - var x; - - x = new Complex128Array( 2 ); - expected = new Float64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 2 ); - expected = new Float64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); - - arr = onesLike( x, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (complex64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Complex64Array( 2 ); - expected = new Float32Array( [ 1.0, 0.0, 1.0, 0.0 ] ); - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 2 ); - expected = new Float32Array( [ 1.0, 0.0, 1.0, 0.0 ] ); - - arr = onesLike( x, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (int32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int32Array( 5 ); - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (uint32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint32Array( 5 ); - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (int16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int16Array( 5 ); - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (uint16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint16Array( 5 ); - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (int8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int8Array( 5 ); - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (uint8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint8Array( 5 ); - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (uint8c)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint8ClampedArray( 5 ); - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = onesLike( x, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (generic)', function test( t ) { - var expected; - var arr; - var x; - - x = [ 1, 2, 3, 4, 5 ]; - expected = [ 1, 1, 1, 1, 1 ]; - - arr = onesLike( x ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a ones-filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = [ 1, 1, 1, 1, 1 ]; - - arr = onesLike( x, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/ones/README.md b/ones/README.md deleted file mode 100644 index b690c723b..000000000 --- a/ones/README.md +++ /dev/null @@ -1,163 +0,0 @@ - - -# ones - -> Create an array filled with ones and having a specified length. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ones = require( '@stdlib/array/ones' ); -``` - -#### ones( length\[, dtype] ) - -Creates an array filled with ones and having a specified length. - -```javascript -var arr = ones( 2 ); -// returns [ 1.0, 1.0 ] -``` - -The function recognizes the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers -- `int32`: 32-bit two's complement signed integers -- `uint32`: 32-bit unsigned integers -- `int16`: 16-bit two's complement signed integers -- `uint16`: 16-bit unsigned integers -- `int8`: 8-bit two's complement signed integers -- `uint8`: 8-bit unsigned integers -- `uint8c`: 8-bit unsigned integers clamped to `0-255` -- `generic`: generic JavaScript values - -By default, the output array data type is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative data type, provide a `dtype` argument. - -```javascript -var arr = ones( 2, 'int32' ); -// returns [ 1, 1 ] -``` - -
- - - - - -
- -## Notes - -- For complex number arrays, each entry of the returned array has a real component equal to `1` and an imaginary component equal to `0`. - -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var ones = require( '@stdlib/array/ones' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = ones( 4, dt[ i ] ); - console.log( arr ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/ones/benchmark/benchmark.js b/ones/benchmark/benchmark.js deleted file mode 100644 index 06ab4ad10..000000000 --- a/ones/benchmark/benchmark.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( 0, 'generic' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/ones/benchmark/benchmark.length.complex128.js b/ones/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 1ee9afefc..000000000 --- a/ones/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/ones/benchmark/benchmark.length.complex64.js b/ones/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 1686d1af4..000000000 --- a/ones/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/ones/benchmark/benchmark.length.float32.js b/ones/benchmark/benchmark.length.float32.js deleted file mode 100644 index 590bd55f2..000000000 --- a/ones/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/ones/benchmark/benchmark.length.float64.js b/ones/benchmark/benchmark.length.float64.js deleted file mode 100644 index 21dd557bc..000000000 --- a/ones/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/ones/benchmark/benchmark.length.generic.js b/ones/benchmark/benchmark.length.generic.js deleted file mode 100644 index 19ec44d87..000000000 --- a/ones/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'generic' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/ones/benchmark/benchmark.length.int16.js b/ones/benchmark/benchmark.length.int16.js deleted file mode 100644 index e64c90f19..000000000 --- a/ones/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/ones/benchmark/benchmark.length.int32.js b/ones/benchmark/benchmark.length.int32.js deleted file mode 100644 index 0643c8c85..000000000 --- a/ones/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/ones/benchmark/benchmark.length.int8.js b/ones/benchmark/benchmark.length.int8.js deleted file mode 100644 index 42596533a..000000000 --- a/ones/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/ones/benchmark/benchmark.length.uint16.js b/ones/benchmark/benchmark.length.uint16.js deleted file mode 100644 index d35cd9b0a..000000000 --- a/ones/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/ones/benchmark/benchmark.length.uint32.js b/ones/benchmark/benchmark.length.uint32.js deleted file mode 100644 index a3482ac9a..000000000 --- a/ones/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/ones/benchmark/benchmark.length.uint8.js b/ones/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 088049db1..000000000 --- a/ones/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/ones/benchmark/benchmark.length.uint8c.js b/ones/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index e343e99db..000000000 --- a/ones/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var ones = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = ones( len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/ones/docs/repl.txt b/ones/docs/repl.txt deleted file mode 100644 index fea655d7a..000000000 --- a/ones/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( length[, dtype] ) - Returns an array filled with ones and having a specified length. - - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754). - - float32: single-precision floating-point numbers (IEEE 754). - - complex128: double-precision complex floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - int32: 32-bit two's complement signed integers. - - uint32: 32-bit unsigned integers. - - int16: 16-bit two's complement signed integers. - - uint16: 16-bit unsigned integers. - - int8: 8-bit two's complement signed integers. - - uint8: 8-bit unsigned integers. - - uint8c: 8-bit unsigned integers clamped to 0-255. - - generic: generic JavaScript values. - - The default array data type is `float64`. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 2 ) - [ 1.0, 1.0 ] - > arr = {{alias}}( 2, 'float32' ) - [ 1.0, 1.0 ] - - See Also - -------- - diff --git a/ones/docs/types/index.d.ts b/ones/docs/types/index.d.ts deleted file mode 100644 index e9da827f9..000000000 --- a/ones/docs/types/index.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { NumericAndGenericDataTypeMap } from '@stdlib/types/array'; - -/** -* Creates an array filled with ones and having a specified length. -* -* The function recognizes the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns filled array -* -* @example -* var arr = ones( 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = ones( 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -declare function ones = 'float64'>( length: number, dtype?: T ): NumericAndGenericDataTypeMap[T]; - - -// EXPORTS // - -export = ones; diff --git a/ones/docs/types/test.ts b/ones/docs/types/test.ts deleted file mode 100644 index ce2d2e1fa..000000000 --- a/ones/docs/types/test.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ones = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - ones( 10 ); // $ExpectType Float64Array - ones( 10, 'float64' ); // $ExpectType Float64Array - ones( 10, 'float32' ); // $ExpectType Float32Array - ones( 10, 'complex128' ); // $ExpectType Complex128Array - ones( 10, 'complex64' ); // $ExpectType Complex64Array - ones( 10, 'int32' ); // $ExpectType Int32Array - ones( 10, 'int16' ); // $ExpectType Int16Array - ones( 10, 'int8' ); // $ExpectType Int8Array - ones( 10, 'uint32' ); // $ExpectType Uint32Array - ones( 10, 'uint16' ); // $ExpectType Uint16Array - ones( 10, 'uint8' ); // $ExpectType Uint8Array - ones( 10, 'uint8c' ); // $ExpectType Uint8ClampedArray - ones( 10, 'generic' ); // $ExpectType number[] -} - -// The compiler throws an error if the function is not provided a number for the first argument... -{ - ones( '5' ); // $ExpectError - ones( false ); // $ExpectError - ones( true ); // $ExpectError - ones( null ); // $ExpectError - ones( undefined ); // $ExpectError - ones( [] ); // $ExpectError - ones( {} ); // $ExpectError - ones( ( x: number ): number => x ); // $ExpectError - - ones( '5', 'float32' ); // $ExpectError - ones( false, 'float32' ); // $ExpectError - ones( true, 'float32' ); // $ExpectError - ones( null, 'float32' ); // $ExpectError - ones( undefined, 'float32' ); // $ExpectError - ones( [], 'float32' ); // $ExpectError - ones( {}, 'float32' ); // $ExpectError - ones( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - ones( 10, '10' ); // $ExpectError - ones( 10, 10 ); // $ExpectError - ones( 10, false ); // $ExpectError - ones( 10, true ); // $ExpectError - ones( 10, null ); // $ExpectError - ones( 10, [] ); // $ExpectError - ones( 10, {} ); // $ExpectError - ones( 10, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ones( 10, 'float64', 1 ); // $ExpectError -} diff --git a/ones/examples/index.js b/ones/examples/index.js deleted file mode 100644 index 09ab27e4a..000000000 --- a/ones/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../dtypes' ); -var ones = require( './../lib' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = ones( 4, dt[ i ] ); - console.log( arr ); -} diff --git a/ones/lib/index.js b/ones/lib/index.js deleted file mode 100644 index 07ef57802..000000000 --- a/ones/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an array filled with ones and having a specified length. -* -* @module @stdlib/array/ones -* -* @example -* var ones = require( '@stdlib/array/ones' ); -* -* var arr = ones( 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var ones = require( '@stdlib/array/ones' ); -* -* var arr = ones( 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/ones/lib/main.js b/ones/lib/main.js deleted file mode 100644 index a7b4505df..000000000 --- a/ones/lib/main.js +++ /dev/null @@ -1,77 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var full = require( './../../full' ); -var defaults = require( './../../defaults' ); - - -// VARIABLES // - -var Z128 = new Complex128( 1.0, 0.0 ); -var Z64 = new Complex64( 1.0, 0.0 ); -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// MAIN // - -/** -* Creates an array filled with ones and having a specified length. -* -* @param {NonNegativeInteger} length - array length -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = ones( 2 ); -* // returns [ 1.0, 1.0 ] -* -* @example -* var arr = ones( 2, 'float32' ); -* // returns [ 1.0, 1.0 ] -*/ -function ones( length ) { - var dtype; - var value; - - if ( arguments.length > 1 ) { - dtype = arguments[ 1 ]; - } else { - dtype = DEFAULT_DTYPE; - } - if ( dtype === 'complex128' ) { - value = Z128; - } else if ( dtype === 'complex64' ) { - value = Z64; - } else { - value = 1; - } - return full( length, value, dtype ); -} - - -// EXPORTS // - -module.exports = ones; diff --git a/ones/package.json b/ones/package.json deleted file mode 100644 index f4dba5a30..000000000 --- a/ones/package.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "name": "@stdlib/array/ones", - "version": "0.0.0", - "description": "Create an array filled with ones and having a specified length.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "fill", - "filled", - "ones" - ] -} diff --git a/ones/test/test.js b/ones/test/test.js deleted file mode 100644 index a262d749f..000000000 --- a/ones/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var ones = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ones, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ones( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ones( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'ones', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ones( 10, value ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = ones( 5 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = ones( 5, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); - - arr = ones( 5, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 1.0, 0.0, 1.0, 0.0 ] ); - - arr = ones( 2, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 1.0, 0.0, 1.0, 0.0 ] ); - - arr = ones( 2, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = ones( 5, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); - - arr = ones( 5, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = ones( 5, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); - - arr = ones( 5, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = ones( 5, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); - - arr = ones( 5, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); - - arr = ones( 5, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - - expected = [ 1, 1, 1, 1, 1 ]; - - arr = ones( 5, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/package.json b/package.json index c4613e4de..2c6fd0970 100644 --- a/package.json +++ b/package.json @@ -3,30 +3,7 @@ "version": "0.3.3", "description": "Arrays.", "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/index.js", - "directories": { - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -35,52 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert": "github:stdlib-js/assert#main", - "@stdlib/blas": "github:stdlib-js/blas#main", - "@stdlib/boolean": "github:stdlib-js/boolean#main", - "@stdlib/buffer": "github:stdlib-js/buffer#main", - "@stdlib/complex": "github:stdlib-js/complex#main", - "@stdlib/constants": "github:stdlib-js/constants#main", - "@stdlib/dstructs": "github:stdlib-js/dstructs#main", - "@stdlib/iter": "github:stdlib-js/iter#main", - "@stdlib/math": "github:stdlib-js/math#main", - "@stdlib/ndarray": "github:stdlib-js/ndarray#main", - "@stdlib/number": "github:stdlib-js/number#main", - "@stdlib/object": "github:stdlib-js/object#main", - "@stdlib/proxy": "github:stdlib-js/proxy#main", - "@stdlib/slice": "github:stdlib-js/slice#main", - "@stdlib/strided": "github:stdlib-js/strided#main", - "@stdlib/string": "github:stdlib-js/string#main", - "@stdlib/symbol": "github:stdlib-js/symbol#main", - "@stdlib/types": "github:stdlib-js/types#main", - "@stdlib/utils": "github:stdlib-js/utils#main" - }, - "devDependencies": { - "@stdlib/bench": "github:stdlib-js/bench#main", - "@stdlib/console": "github:stdlib-js/console#main", - "@stdlib/process": "github:stdlib-js/process#main", - "@stdlib/random": "github:stdlib-js/random#main", - "proxyquire": "^2.0.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/place/README.md b/place/README.md deleted file mode 100644 index 6de5a6ee8..000000000 --- a/place/README.md +++ /dev/null @@ -1,183 +0,0 @@ - - -# place - -> Replace elements of an array with provided values according to a provided mask array. - -
- -## Usage - -```javascript -var place = require( '@stdlib/array/place' ); -``` - -#### place( x, mask, values\[, options] ) - -Replaces elements of an array with provided values according to a provided mask array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = place( x, [ 0, 1, 0, 1 ], [ 20, 40 ] ); -// returns [ 1, 20, 3, 40 ] - -var bool = ( out === x ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **mask**: mask array. -- **values**: values to set. -- **options**: function options. - -The function supports the following options: - -- **mode**: string specifying behavior when the number of `values` does not equal the number of truthy `mask` values. Default: `'repeat'`. - -The function supports the following modes: - -- `'strict'`: specifies that the function must raise an exception when the number of `values` does not **exactly** equal the number of truthy `mask` values. -- `'non_strict'`: specifies that the function must raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -- `'strict_broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the number of `values` does not **exactly** equal the number of truthy `mask` values. -- `'broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. -- `'repeat'`: specifies that the function must reuse provided `values` when replacing elements in `x` in order to satisfy the `mask` array. - -In broadcasting modes, the function supports broadcasting a `values` array containing a single element against the number of truthy values in the `mask` array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = place( x, [ 0, 1, 0, 1 ], [ 20 ], { - 'mode': 'strict_broadcast' -}); -// returns [ 1, 20, 3, 20 ] - -var bool = ( out === x ); -// returns true -``` - -In repeat mode, the function supports recycling elements in a `values` array to satisfy the number of truthy values in the `mask` array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = place( x, [ 1, 1, 0, 1 ], [ 20, 40 ], { - 'mode': 'repeat' -}); -// returns [ 20, 40, 3, 20 ] - -var bool = ( out === x ); -// returns true -``` - -
- - - -
- -## Notes - -- The function mutates the input array `x`. -- If a `mask` array element is truthy, the corresponding element in `x` is **replaced**; otherwise, the corresponding element in `x` is "masked" and thus left unchanged. -- The `values` array must have a [data type][@stdlib/array/dtypes] which can be [safely cast][@stdlib/array/safe-casts] to the input array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the [same kind][@stdlib/array/same-kind-casts] (e.g., element values from a `'float64'` values array can be assigned to corresponding elements in a `'float32'` input array). - -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var linspace = require( '@stdlib/array/base/linspace' ); -var place = require( '@stdlib/array/place' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate a random mask array: -var N = discreteUniform( 5, 15 ); -var mask = filledBy( N, bernoulli.factory( 0.3 ) ); -console.log( mask ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = place( x, mask, values ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/place/benchmark/benchmark.js b/place/benchmark/benchmark.js deleted file mode 100644 index 95280c5dd..000000000 --- a/place/benchmark/benchmark.js +++ /dev/null @@ -1,79 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../base/zero-to' ); -var ones = require( './../../base/ones' ); -var pkg = require( './../package.json' ).name; -var place = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::no_broadcasting:len=100', function benchmark( b ) { - var mask; - var x; - var i; - var v; - - x = zeroTo( 100 ); - mask = ones( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = place( x, mask, x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::broadcasting:len=100', function benchmark( b ) { - var mask; - var x; - var i; - var v; - - x = zeroTo( 100 ); - mask = ones( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = place( x, mask, [ i ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/place/benchmark/benchmark.length.js b/place/benchmark/benchmark.length.js deleted file mode 100644 index 0d1b089cf..000000000 --- a/place/benchmark/benchmark.length.js +++ /dev/null @@ -1,113 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var ones = require( './../../base/ones' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var place = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'dtype': 'generic' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var mask; - var x; - - x = discreteUniform( len, 0, 10, opts ); - mask = ones( len ); - values = [ - discreteUniform( len, -10, 0, opts ), - discreteUniform( len, 0, 10, opts ) - ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = place( x, mask, values[ i%values.length ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/place/docs/repl.txt b/place/docs/repl.txt deleted file mode 100644 index e9816ac33..000000000 --- a/place/docs/repl.txt +++ /dev/null @@ -1,68 +0,0 @@ - -{{alias}}( x, mask, values[, options] ) - Replaces elements of an array with provided values according to a provided - mask array. - - In broadcasting modes, the function supports broadcasting a values array - containing a single element against the number of truthy values in the mask - array. - - In repeat mode, the function supports recycling elements in a values array - to satisfy the number of truthy values in the mask array. - - The function mutates the input array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - mask: ArrayLikeObject - Mask array. If a mask array element is truthy, the corresponding element - in `x` is *replaced*; otherwise, the corresponding element in `x` is - "masked" and thus left unchanged. - - values: ArrayLikeObject - Values to set. - - options: Object (optional) - Function options. - - options.mode: string (optional) - String specifying behavior when the number of values to set does not - equal the number of truthy mask values. The function supports the - following modes: - - - 'strict': specifies that the function must raise an exception when the - number of values does not *exactly* equal the number of truthy mask - values. - - 'non_strict': specifies that the function must raise an exception when - the function is provided insufficient values to satisfy the mask array. - - 'strict_broadcast': specifies that the function must broadcast a - single-element values array and otherwise raise an exception when the - number of values does not **exactly** equal the number of truthy mask - values. - - 'broadcast': specifies that the function must broadcast a single- - element values array and otherwise raise an exception when the function - is provided insufficient values to satisfy the mask array. - - 'repeat': specifies that the function must reuse provided values when - replacing elements in `x` in order to satisfy the mask array. - - Default: 'repeat'. - - Returns - ------- - out: ArrayLikeObject - Input array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x, [ 0, 1, 0, 1 ], [ 20, 40 ] ) - [ 1, 20, 3, 40 ] - > var bool = ( out === x ) - true - - See Also - -------- - diff --git a/place/docs/types/index.d.ts b/place/docs/types/index.d.ts deleted file mode 100644 index 76264b761..000000000 --- a/place/docs/types/index.d.ts +++ /dev/null @@ -1,232 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; - -/** -* Mask array. -*/ -type MaskArray = Collection | AccessorArrayLike; - -/** -* Values array. -*/ -type ValuesArray = Collection | AccessorArrayLike; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Mode specifying behavior when the number of values to set does not equal the number of truthy values in the mask array. - * - * ## Notes - * - * - The function supports the following modes: - * - * - `'strict'`: specifies that the function must raise an exception when the number of `values` does not **exactly** equal the number of truthy `mask` values. - * - `'non_strict'`: specifies that the function must raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. - * - `'strict_broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the number of `values` does not **exactly** equal the number of truthy `mask` values. - * - `'broadcast'`: specifies that the function must broadcast a single-element `values` array and otherwise raise an exception when the function is provided insufficient `values` to satisfy the `mask` array. - * - `'repeat'`: specifies that the function must reuse provided `values` when replacing elements in `x` in order to satisfy the `mask` array. - */ - mode?: 'strict' | 'non_strict' | 'strict_broadcast' | 'broadcast' | 'repeat'; -} - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var out = place( x, [ 0, 1, 1, 0 ], [ 30 ] ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function place( x: T, mask: MaskArray, values: ValuesArray, options?: Options ): T; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = new Complex128Array( [ 20.0, 30.0, 40, 5.0 ] ); -* -* var out = place( x, mask, values ); -* // returns -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = new Complex128Array( [ 20.0, 30.0 ] ); -* -* var out = place( x, mask, values ); -* // returns -* -* var bool = ( out === x ); -* // returns true -*/ -declare function place( x: T, mask: MaskArray, values: ValuesArray, options?: Options ): T; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = place( x, [ 0, 1, 1, 0 ], [ 30 ] ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function place( x: Array, mask: MaskArray, values: ValuesArray, options?: Options ): Array; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values ); -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var out = place( x, [ 0, 1, 1, 0 ], [ 30 ] ); -* -* var bool = ( out === x ); -* // returns true -*/ -declare function place( x: AccessorArrayLike, mask: MaskArray, values: ValuesArray, options?: Options ): AccessorArrayLike; - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param x - input array -* @param mask - mask array -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = place( x, [ 0, 1, 1, 0 ], [ 30 ] ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function place( x: Collection, mask: MaskArray, values: ValuesArray, options?: Options ): Collection; - - -// EXPORTS // - -export = place; diff --git a/place/docs/types/test.ts b/place/docs/types/test.ts deleted file mode 100644 index 07fe278b3..000000000 --- a/place/docs/types/test.ts +++ /dev/null @@ -1,96 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import AccessorArray = require( './../../../base/accessor' ); -import place = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - place( [ 1, 2, 3, 4 ], [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectType number[] - place( new Int32Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectType Int32Array - place( new Complex128Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ] ); // $ExpectType Complex128Array - place( new Complex64Array( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ] ); // $ExpectType Complex64Array - place( new AccessorArray( [ 1, 2, 3, 4 ] ), [ 1, 0, 0, 1 ], new AccessorArray( [ 20, 30 ] ) ); // $ExpectType AccessorArrayLike -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - place( 1, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError - place( true, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError - place( false, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError - place( null, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError - place( void 0, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError - place( {}, [ 1, 0, 0, 1 ], [ 20, 30 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - place( [], 1, [ 20, 30 ] ); // $ExpectError - place( [], true, [ 20, 30 ] ); // $ExpectError - place( [], false, [ 20, 30 ] ); // $ExpectError - place( [], null, [ 20, 30 ] ); // $ExpectError - place( [], void 0, [ 20, 30 ] ); // $ExpectError - place( [], {}, [ 20, 30 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object... -{ - place( [], [ 1, 0, 0, 1 ], 1 ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], true ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], false ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], null ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], void 0 ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an object... -{ - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], '1' ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], 1 ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], true ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], false ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], null ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], [] ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid mode... -{ - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': '1' } ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': 1 } ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': true } ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': false } ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': null } ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': {} } ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': [] } ); // $ExpectError - place( [], [ 1, 0, 0, 1 ], [ 20, 30 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - place(); // $ExpectError - place( [] ); // $ExpectError - place( [], [] ); // $ExpectError - place( [], [], [], {}, {} ); // $ExpectError -} diff --git a/place/examples/index.js b/place/examples/index.js deleted file mode 100644 index 23c6b3bdd..000000000 --- a/place/examples/index.js +++ /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. -*/ - -'use strict'; - -var filledBy = require( './../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var bernoulli = require( '@stdlib/random/base/bernoulli' ); -var linspace = require( './../../base/linspace' ); -var place = require( './../lib' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate a random mask array: -var N = discreteUniform( 5, 15 ); -var mask = filledBy( N, bernoulli.factory( 0.3 ) ); -console.log( mask ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = place( x, mask, values ); -console.log( out ); diff --git a/place/lib/defaults.js b/place/lib/defaults.js deleted file mode 100644 index ae985155c..000000000 --- a/place/lib/defaults.js +++ /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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns default options. -* -* @private -* @returns {Object} default options -* -* @example -* var o = defaults(); -* // returns {...} -*/ -function defaults() { - return { - 'mode': 'repeat' - }; -} - - -// EXPORTS // - -module.exports = defaults; diff --git a/place/lib/index.js b/place/lib/index.js deleted file mode 100644 index 06db07c38..000000000 --- a/place/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Replace elements of an array with provided values according to a provided mask array. -* -* @module @stdlib/array/place -* -* @example -* var place = require( '@stdlib/array/place' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/place/lib/main.js b/place/lib/main.js deleted file mode 100644 index ab33a9106..000000000 --- a/place/lib/main.js +++ /dev/null @@ -1,130 +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. -*/ - -'use strict'; - -// MODULES // - -var isMostlySafeCast = require( './../../base/assert/is-mostly-safe-data-type-cast' ); -var isRealDataType = require( './../../base/assert/is-real-data-type' ); -var isComplexDataType = require( './../../base/assert/is-complex-floating-point-data-type' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var base = require( './../../base/place' ); -var dtype = require( './../../dtype' ); -var convert = require( './../../convert' ); -var format = require( '@stdlib/string/format' ); -var defaults = require( './defaults.js' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Replaces elements of an array with provided values according to a provided mask array. -* -* @param {Collection} x - input array -* @param {Collection} mask - mask array -* @param {Collection} values - values to set -* @param {Options} [options] - function options -* @param {string} [options.mode='repeat'] - string specifying behavior when the number of values does not equal the number of truthy mask values -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} second argument must be a collection -* @throws {TypeError} third argument must be a collection -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @throws {Error} insufficient values to satisfy mask array -* @throws {Error} number of values does not equal the number of truthy mask values -* @throws {TypeError} third argument cannot be safely cast to the data type of the first argument -* @returns {Collection} input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 0, 1, 1, 0 ]; -* var values = [ 30 ]; -* -* var out = place( x, mask, values ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var mask = [ 1, 1, 0, 1 ]; -* var values = [ 20, 30 ]; -* -* var out = place( x, mask, values ); -* // returns [ 20, 30, 3, 20 ] -* -* var bool = ( out === x ); -* // returns true -*/ -function place( x, mask, values ) { - var opts; - var err; - var xdt; - var vdt; - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) ); - } - if ( !isCollection( mask ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', mask ) ); - } - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', values ) ); - } - opts = defaults(); - if ( arguments.length > 3 ) { - err = validate( opts, arguments[ 3 ] ); - if ( err ) { - throw err; - } - } - xdt = dtype( x ) || 'generic'; - vdt = dtype( values ) || 'generic'; - - // Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the input array data type is floating-point... - if ( !isMostlySafeCast( vdt, xdt ) ) { - throw new TypeError( format( 'invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].', vdt, xdt ) ); - } - // When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array... - if ( isComplexDataType( xdt ) && isRealDataType( vdt ) ) { - values = convert( values, xdt ); - } - // Replace values in the input array: - return base( x, mask, values, opts.mode ); -} - - -// EXPORTS // - -module.exports = place; diff --git a/place/lib/validate.js b/place/lib/validate.js deleted file mode 100644 index acb459514..000000000 --- a/place/lib/validate.js +++ /dev/null @@ -1,78 +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. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert/is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var contains = require( './../../base/assert/contains' ).factory; -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var MODES = [ - 'strict', - 'non_strict', - 'strict_broadcast', - 'broadcast', - 'repeat' -]; -var isMode = contains( MODES ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.mode] - mode option -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'mode': 'strict' -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - if ( !isMode( opts.mode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'mode', MODES.join( '", "' ), opts.mode ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/place/package.json b/place/package.json deleted file mode 100644 index 98127b6ca..000000000 --- a/place/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "name": "@stdlib/array/place", - "version": "0.0.0", - "description": "Replace elements of an array with provided values according to a provided mask array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "set", - "replace", - "put", - "update", - "mask", - "missing", - "na" - ] -} diff --git a/place/test/test.js b/place/test/test.js deleted file mode 100644 index f075e97ce..000000000 --- a/place/test/test.js +++ /dev/null @@ -1,696 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../complex64' ); -var Int32Array = require( './../../int32' ); -var BooleanArray = require( './../../bool' ); -var zeros = require( './../../zeros' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var isAccessorArray = require( '@stdlib/assert/is-accessor-array' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var isComplex64 = require( '@stdlib/assert/is-complex64' ); -var place = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof place, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - place( value, [], [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - place( value, [], [], {} ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - place( [], value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - place( [], value, [], {} ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - place( [], [], value ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - place( [], [], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - place( [], [], [], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a valid mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - place( [], [], [], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which cannot be safely cast to the input array data type', function test( t ) { - var values; - var x; - var i; - - values = zeros( 5, 'float64' ); - - x = [ - zeros( 5, 'uint8' ), - zeros( 5, 'int8' ), - zeros( 5, 'int16' ), - zeros( 5, 'uint16' ) - ]; - for ( i = 0; i < x.length; i++ ) { - t.throws( badValue( x[ i ] ), TypeError, 'throws an error when provided ' + x[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - place( value, zeros( 5, 'generic' ), values ); - }; - } -}); - -tape( 'the function replaces elements in an array (generic)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 1, 0, 1 ]; - actual = place( x, mask, [ 20, 40 ] ); - expected = [ 1, 20, 3, 40 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, [ 20, 30, 40, 50 ] ); - expected = [ 20, 30, 40, 50 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - actual = place( x, mask, [ 20, 30, 40, 50 ] ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (generic, broadcasting)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 1, 0, 1 ]; - actual = place( x, mask, [ 20 ] ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, [ 20 ] ); - expected = [ 20, 20, 20, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 0, 0, 0, 0 ]; - actual = place( x, mask, [ 20 ] ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, [ 100, 200 ] ); - expected = [ 100, 200, 100, 200 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (typed)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = place( x, mask, new Int32Array( [ 20, 40 ] ) ); - expected = new Int32Array( [ 1, 20, 3, 40 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, new Int32Array( [ 20, 30, 40, 50 ] ) ); - expected = new Int32Array( [ 20, 30, 40, 50 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 0, 0, 0 ]; - actual = place( x, mask, new Int32Array( [ 20, 30, 40, 50 ] ) ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (typed, broadcasting)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 1, 0, 1 ]; - actual = place( x, mask, new Int32Array( [ 20 ] ) ); - expected = new Int32Array( [ 1, 20, 3, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, new Int32Array( [ 20 ] ) ); - expected = new Int32Array( [ 20, 20, 20, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 0, 0, 0, 0 ]; - actual = place( x, mask, new Int32Array( [ 20 ] ) ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - mask = [ 1, 1, 1, 1 ]; - actual = place( x, mask, new Int32Array( [ 100, 200 ] ) ); - expected = new Int32Array( [ 100, 200, 100, 200 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - actual = place( toAccessorArray( x ), mask, toAccessorArray( [ 20, 40 ] ) ); - expected = [ 1, 20, 3, 40 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = place( toAccessorArray( x ), mask, toAccessorArray( [ 20, 30, 40, 50 ] ) ); // eslint-disable-line max-len - expected = [ 20, 30, 40, 50 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = place( toAccessorArray( x ), mask, [ 20, 30, 40, 50 ] ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, broadcasting)', function test( t ) { - var expected; - var actual; - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - actual = place( toAccessorArray( x ), mask, toAccessorArray( [ 20 ] ) ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = place( toAccessorArray( x ), mask, toAccessorArray( [ 20 ] ) ); - expected = [ 20, 20, 20, 20 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 0, 0, 0, 0 ] ); - actual = place( toAccessorArray( x ), mask, toAccessorArray( [ 20 ] ) ); - expected = [ 1, 2, 3, 4 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - mask = toAccessorArray( [ 1, 1, 1, 1 ] ); - actual = place( toAccessorArray( x ), mask, toAccessorArray( [ 100, 200 ] ) ); // eslint-disable-line max-len - expected = [ 100, 200, 100, 200 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - values = new Complex64Array( [ 30.0, 40.0, 70.0, 80.0 ] ); - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 30.0, 40.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 70.0, 80.0 ) - ]; - actual = place( x, mask, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex, broadcasting)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - values = new Complex64Array( [ 100.0, 200.0 ] ); - expected = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 100.0, 200.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 100.0, 200.0 ) - ]; - actual = place( x, mask, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( isComplex64( v ), true, 'returns expected value' ); - t.strictEqual( realf( v ), realf( expected[ i ] ), 'returns expected value' ); - t.strictEqual( imagf( v ), imagf( expected[ i ] ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - mask = toAccessorArray( [ 0, 1, 0, 1 ] ); - values = new BooleanArray( [ true, false ] ); - expected = [ true, true, false, true ]; - actual = place( x, mask, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean, broadcasting)', function test( t ) { - var expected; - var actual; - var values; - var mask; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - mask = toAccessorArray( [ 0, 1, 1, 0 ] ); - values = new BooleanArray( [ true ] ); - expected = [ true, true, true, true ]; - actual = place( x, mask, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < mask.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'when the "mode" is "strict", the function throws an error if provided insufficient values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200 ], { - 'mode': 'strict' - }); - } -}); - -tape( 'when the "mode" is "strict", the function throws an error if provided too many values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200, 300, 400, 500, 600 ], { - 'mode': 'strict' - }); - } -}); - -tape( 'when the "mode" is "non_strict", the function throws an error if provided insufficient values to satisfy the mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200 ], { - 'mode': 'non_strict' - }); - } -}); - -tape( 'when the "mode" is "strict_broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of truthy values in a mask array (insufficient)', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200, 400 ], { - 'mode': 'strict_broadcast' - }); - } -}); - -tape( 'when the "mode" is "strict_broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of truthy values in a mask array (too many)', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200, 400, 500, 600, 700 ], { - 'mode': 'strict_broadcast' - }); - } -}); - -tape( 'when the "mode" is "broadcast", the function throws an error if provided a values array which is broadcast incompatible with the number of truthy values in a mask array', function test( t ) { - var mask; - var x; - - x = [ 1, 2, 3, 4 ]; - mask = [ 1, 1, 1, 1 ]; - - t.throws( badValue, Error, 'throws an error' ); - t.end(); - - function badValue() { - place( x, mask, [ 200, 400 ], { - 'mode': 'broadcast' - }); - } -}); diff --git a/place/test/test.validate.js b/place/test/test.validate.js deleted file mode 100644 index 502392108..000000000 --- a/place/test/test.validate.js +++ /dev/null @@ -1,128 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if not provided an options object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[i] ); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `mode` option which is not a valid index mode', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'mode': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns `null` if all options are valid', function test( t ) { - var expected; - var options; - var opts; - var err; - - options = { - 'mode': 'strict' - }; - opts = {}; - - expected = { - 'mode': 'strict' - }; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function ignores unrecognized options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': 'boop', - 'foo': 5, - 'bar': {} - }; - - opts = {}; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, {}, 'returns expected value' ); - - t.end(); -}); diff --git a/pool/README.md b/pool/README.md deleted file mode 100644 index a6b282ca0..000000000 --- a/pool/README.md +++ /dev/null @@ -1,460 +0,0 @@ - - -# typedarraypool - -> Allocate typed arrays from a typed array memory pool. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var typedarraypool = require( '@stdlib/array/pool' ); -``` - -#### typedarraypool( \[dtype] ) - -Returns an **uninitialized** [typed array][mdn-typed-array] having a specified [data type][@stdlib/array/typed-dtypes] `dtype`. - -```javascript -var arr = typedarraypool(); -// returns [] - -// ... - -typedarraypool.free( arr ); -``` - -By default, the output [typed array][mdn-typed-array] is `float64`. To specify an alternative [data type][@stdlib/array/typed-dtypes], set the `dtype` parameter. - -```javascript -var arr = typedarraypool( 'int32' ); -// returns [] - -// ... - -typedarraypool.free( arr ); -``` - -#### typedarraypool( length\[, dtype] ) - -Returns an **uninitialized** [typed array][mdn-typed-array] having a specified `length` from a [typed array][mdn-typed-array] memory pool. - -```javascript -var arr1 = typedarraypool( 5 ); -// returns - -var arr2 = typedarraypool( 5, 'uint8' ); -// returns - -// ... - -typedarraypool.free( arr1 ); -typedarraypool.free( arr2 ); -``` - -#### typedarraypool( typedarray\[, dtype] ) - -Returns a pooled [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - -```javascript -var arr1 = typedarraypool( [ 5.0, -3.0, 2.0 ] ); -// returns [ 5.0, -3.0, 2.0 ] - -var arr2 = typedarraypool( arr1 ); -// returns [ 5.0, -3.0, 2.0 ] - -var arr3 = typedarraypool( arr1, 'int32' ); -// returns [ 5, -3, 2 ] - -// ... - -typedarraypool.free( arr1 ); -typedarraypool.free( arr2 ); -typedarraypool.free( arr3 ); -``` - -#### typedarraypool( obj\[, dtype] ) - -Returns a pooled [typed array][mdn-typed-array] from an array-like `object`. - -```javascript -var arr1 = typedarraypool( [ 0.5, 0.5, 0.5 ] ); -// returns [ 0.5, 0.5, 0.5 ] - -var arr2 = typedarraypool( [ 0.5, 0.5, 0.5 ], 'float32' ); -// returns [ 0.5, 0.5, 0.5 ] - -// ... - -typedarraypool.free( arr1 ); -typedarraypool.free( arr2 ); -``` - -#### typedarraypool.malloc( \[dtype] ) - -Returns an **uninitialized** [typed array][mdn-typed-array] having a specified [data type][@stdlib/array/typed-dtypes] `dtype`. - -```javascript -var arr1 = typedarraypool.malloc(); -// returns [] - -var arr2 = typedarraypool.malloc( 'int32' ); -// returns [] - -// ... - -typedarraypool.free( arr1 ); -typedarraypool.free( arr2 ); -``` - -#### typedarraypool.malloc( length\[, dtype] ) - -Returns an **uninitialized** [typed array][mdn-typed-array] having a specified `length` from a [typed array][mdn-typed-array] memory pool. - -```javascript -var arr1 = typedarraypool.malloc( 5 ); -// returns - -var arr2 = typedarraypool.malloc( 5, 'uint8' ); -// returns - -// ... - -typedarraypool.free( arr1 ); -typedarraypool.free( arr2 ); -``` - -#### typedarraypool.malloc( typedarray\[, dtype] ) - -Returns a pooled [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - -```javascript -var arr1 = typedarraypool.malloc( [ 5.0, -3.0, 2.0 ] ); -// returns [ 5.0, -3.0, 2.0 ] - -var arr2 = typedarraypool.malloc( arr1 ); -// returns [ 5.0, -3.0, 2.0 ] - -var arr3 = typedarraypool.malloc( arr1, 'int32' ); -// returns [ 5, -3, 2 ] - -// ... - -typedarraypool.free( arr1 ); -typedarraypool.free( arr2 ); -typedarraypool.free( arr3 ); -``` - -#### typedarraypool.malloc( obj\[, dtype] ) - -Returns a pooled [typed array][mdn-typed-array] from an array-like `object`. - -```javascript -var arr1 = typedarraypool.malloc( [ 0.5, 0.5, 0.5 ] ); -// returns [ 0.5, 0.5, 0.5 ] - -var arr2 = typedarraypool.malloc( [ 0.5, 0.5, 0.5 ], 'float32' ); -// returns [ 0.5, 0.5, 0.5 ] - -// ... - -typedarraypool.free( arr1 ); -typedarraypool.free( arr2 ); -``` - -#### typedarraypool.calloc( \[dtype] ) - -Returns a **zero-initialized** [typed array][mdn-typed-array] having a specified [data type][@stdlib/array/typed-dtypes] `dtype`. - -```javascript -var arr1 = typedarraypool.calloc(); -// returns [] - -var arr2 = typedarraypool.calloc( 'int32' ); -// returns [] - -// ... - -typedarraypool.free( arr1 ); -typedarraypool.free( arr2 ); -``` - -#### typedarraypool.calloc( length\[, dtype] ) - -Returns a **zero-initialized** [typed array][mdn-typed-array] having a specified `length` from a [typed array][mdn-typed-array] memory pool. - -```javascript -var arr1 = typedarraypool.calloc( 5 ); -// returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - -var arr2 = typedarraypool.calloc( 5, 'uint8' ); -// returns [ 0, 0, 0, 0, 0 ] - -// ... - -typedarraypool.free( arr1 ); -typedarraypool.free( arr2 ); -``` - -#### typedarraypool.free( buf ) - -Frees a [typed array][mdn-typed-array] or typed array [buffer][mdn-arraybuffer] for use in a future allocation. - -```javascript -var arr = typedarraypool( 10, 'float64' ); -// returns - -// ... - -// Free the allocated typed array for use in a future allocation: -typedarraypool.free( arr ); - -// Create another typed array: -arr = typedarraypool( 10, 'float64' ); -// returns - -// ... - -// Free the allocated typed array buffer for use in a future allocation: -typedarraypool.free( arr.buffer ); -``` - -#### typedarraypool.clear() - -Clears the [typed array][mdn-typed-array] pool allowing garbage collection of previously allocated (and currently free) [array buffers][mdn-arraybuffer]. - -```javascript -var arr = typedarraypool( 10, 'float64' ); -// returns - -// ... - -typedarraypool.free( arr ); - -// ... - -// Clear all freed buffers: -typedarraypool.clear(); -``` - -#### typedarraypool.highWaterMark - -**Read-only** property returning the pool's high water mark (in bytes). - -```javascript -var limit = typedarraypool.highWaterMark; -// returns -``` - -Once a high water mark is reached, [typed array][mdn-typed-array] allocation **fails**. - -#### typedarraypool.nbytes - -**Read-only** property returning the total number of allocated bytes. - -```javascript -var arr = typedarraypool( 5, 'float64' ); - -var nbytes = typedarraypool.nbytes; -// returns -``` - -The returned value is the total **accumulated** value. Hence, anytime a pool must allocate a new [array buffer][mdn-arraybuffer] (i.e., more memory), the pool increments this value. The only time this value is decremented is when a pool is cleared. This behavior means that, while allocated buffers which are never freed may, in fact, be garbage collected, they continue to count against the high water mark limit. Accordingly, you should **always** free allocated buffers in order to prevent the pool from believing that non-freed buffers are continually in use. - -#### typedarraypool.factory( \[options] ) - -Creates a new [typed array][mdn-typed-array] pool. - -```javascript -var pool = typedarraypool.factory(); - -var arr = pool( 5, 'float64' ); -// returns - -// ... - -pool.free( arr ); -``` - -The method accepts the following `options`: - -- **highWaterMark**: maximum total memory (in bytes) which can be allocated. Default: `2^53` bytes. - -By default, the maximum total memory a pool may allocate is `2^53` bytes (approximately `1` petabyte, which, in practical terms, means a pool has **unlimited** capacity). To specify an alternative limit, set the `highWaterMark` option. - -```javascript -// Create a new typed array pool which can allocate up to 1MB: -var pool = typedarraypool.factory({ - 'highWaterMark': 1e6 -}); - -var arr = pool( 5, 'float64' ); -// returns - -// ... - -pool.free( arr ); -``` - -
- - - - - -
- -## Notes - -- Uninitialized typed arrays may contain sensitive contents. If security is paramount (e.g., if freed [typed arrays][mdn-typed-array] have been used to store sensitive contents), use `calloc`. -- An allocated [typed array][mdn-typed-array] is **guaranteed** to have an underlying [array buffer][mdn-arraybuffer] with _at least_ `N * w` bytes, where `N` is the number of [typed array][mdn-typed-array] elements and `w` is the number of bytes per element. Note, however, that the underlying [array buffer][mdn-arraybuffer] is likely to have **excess** capacity. Thus, if you create many [typed arrays][mdn-typed-array] which are held in memory and are **not** freed, you are likely to consume significantly more memory than if you had directly used [typed array][mdn-typed-array] constructors. However, if you create many [typed arrays][mdn-typed-array] which are rapidly discarded and of relatively large size, then using a [typed array][mdn-typed-array] pool can offer significant performance advantages. - -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var typedarraypool = require( '@stdlib/array/pool' ); - -// Create a typed array pool which can allocate at most 1GB: -var typedarray = typedarraypool.factory({ - 'highWaterMark': 1e9 -}); - -// Inspect the pool: -console.log( 'Max bytes: %d', typedarray.highWaterMark ); -console.log( 'nbytes: %d', typedarray.nbytes ); - -// Allocate an array for storing double-precision floating-point numbers: -var arr1 = typedarray( 5, 'float64' ); -// returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - -// Inspect the pool: -console.log( 'nbytes: %d', typedarray.nbytes ); - -// Fill the array... -var i; -for ( i = 0; i < arr1.length; i++ ) { - arr1[ i ] = randu(); -} - -// Inspect array contents: -console.log( arr1 ); - -// Free the array: -typedarray.free( arr1 ); - -// Allocate another array similar to the previous one: -var arr2 = typedarray( 5, 'float64' ); -// returns - -// Check that we have been returned a new typed array view: -console.log( arr2 === arr1 ); -// => false - -// Inspect array contents: -console.log( arr2 ); - -// Free the array: -typedarray.free( arr2 ); - -// Allocate an initialized array: -var arr3 = typedarray.calloc( 5, 'float64' ); -// returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - -// Inspect array contents: -console.log( arr3 ); - -// Free the array: -typedarray.free( arr3 ); - -// Clear the pool: -typedarray.clear(); - -// Inspect the pool: -console.log( 'nbytes: %d', typedarray.nbytes ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/pool/benchmark/benchmark.calloc.js b/pool/benchmark/benchmark.calloc.js deleted file mode 100644 index 0872d55bd..000000000 --- a/pool/benchmark/benchmark.calloc.js +++ /dev/null @@ -1,265 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':calloc', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':calloc:dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.calloc( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/pool/benchmark/benchmark.factory.js b/pool/benchmark/benchmark.factory.js deleted file mode 100644 index 544daabef..000000000 --- a/pool/benchmark/benchmark.factory.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':factory', function benchmark( b ) { - var f; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - f = typedarray.factory(); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( f ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':factory:highWaterMark', function benchmark( b ) { - var opts; - var f; - var i; - - opts = { - 'highWaterMark': 0 - }; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - opts.highWaterMark = i; - f = typedarray.factory( opts ); - if ( typeof f !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( f ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/pool/benchmark/benchmark.js b/pool/benchmark/benchmark.js deleted file mode 100644 index cda52a9c4..000000000 --- a/pool/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/pool/benchmark/benchmark.length.bool.js b/pool/benchmark/benchmark.length.bool.js deleted file mode 100644 index 0833dbc1f..000000000 --- a/pool/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,102 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=bool,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=bool,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=bool,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.length.complex128.js b/pool/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 3cd2ada60..000000000 --- a/pool/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=complex128,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=complex128,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.length.complex64.js b/pool/benchmark/benchmark.length.complex64.js deleted file mode 100644 index 3f27933b8..000000000 --- a/pool/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=complex64,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=complex64,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.length.float32.js b/pool/benchmark/benchmark.length.float32.js deleted file mode 100644 index b18c18069..000000000 --- a/pool/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=float32,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=float32,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.length.float64.js b/pool/benchmark/benchmark.length.float64.js deleted file mode 100644 index 4fa6b51d5..000000000 --- a/pool/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=float64,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=float64,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.length.int16.js b/pool/benchmark/benchmark.length.int16.js deleted file mode 100644 index 16f37d5d1..000000000 --- a/pool/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=int16,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=int16,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.length.int32.js b/pool/benchmark/benchmark.length.int32.js deleted file mode 100644 index 048aac3bb..000000000 --- a/pool/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=int32,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=int32,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.length.int8.js b/pool/benchmark/benchmark.length.int8.js deleted file mode 100644 index a513b9880..000000000 --- a/pool/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=int8,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=int8,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.length.uint16.js b/pool/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 33f98807f..000000000 --- a/pool/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=uint16,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=uint16,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.length.uint32.js b/pool/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 51fd6124c..000000000 --- a/pool/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=uint32,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=uint32,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.length.uint8.js b/pool/benchmark/benchmark.length.uint8.js deleted file mode 100644 index ecfaef73f..000000000 --- a/pool/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=uint8,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=uint8,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.length.uint8c.js b/pool/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 558127d83..000000000 --- a/pool/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {Function} fcn - allocation function -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( fcn, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = fcn( len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - typedarray.free( arr ); - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( typedarray, len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - - f = createBenchmark( typedarray.malloc, len ); - bench( pkg+':malloc:dtype=uint8c,len='+len, f ); - - f = createBenchmark( typedarray.calloc, len ); - bench( pkg+':calloc:dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/pool/benchmark/benchmark.malloc.js b/pool/benchmark/benchmark.malloc.js deleted file mode 100644 index 544824a2c..000000000 --- a/pool/benchmark/benchmark.malloc.js +++ /dev/null @@ -1,265 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':malloc', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':malloc:dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray.malloc( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/pool/docs/repl.txt b/pool/docs/repl.txt deleted file mode 100644 index a2727d64e..000000000 --- a/pool/docs/repl.txt +++ /dev/null @@ -1,333 +0,0 @@ - -{{alias}}( [dtype] ) - Returns an uninitialized typed array from a typed array memory pool. - - Memory is **uninitialized**, which means that the contents of a returned - typed array may contain sensitive contents. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|null - If the function is unable to allocate a typed array from the typed array - pool (e.g., due to insufficient memory), the function returns `null`. - - Examples - -------- - > var arr = {{alias}}() - [] - > arr = {{alias}}( 'float32' ) - [] - - -{{alias}}( length[, dtype] ) - Returns an uninitialized typed array having a specified length from a typed - array memory pool. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|null - If the function is unable to allocate a typed array from the typed array - pool (e.g., due to insufficient memory), the function returns `null`. - - Examples - -------- - > var arr = {{alias}}( 5 ) - - > arr = {{alias}}( 5, 'int32' ) - - - -{{alias}}( typedarray[, dtype] ) - Creates a pooled typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|null - If the function is unable to allocate a typed array from the typed array - pool (e.g., due to insufficient memory), the function returns `null`. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a pooled typed array from an array-like object. - - Parameters - ---------- - obj: Object - Array-like object from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|null - If the function is unable to allocate a typed array from the typed array - pool (e.g., due to insufficient memory), the function returns `null`. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}.malloc( [dtype] ) - Returns an uninitialized typed array from a typed array memory pool. - - This method shares the same security vulnerabilities mentioned above. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|null - If the function is unable to allocate a typed array from the typed array - pool (e.g., due to insufficient memory), the function returns `null`. - - Examples - -------- - > var arr = {{alias}}.malloc() - - > arr = {{alias}}.malloc( 'float32' ) - - - -{{alias}}.malloc( length[, dtype] ) - Returns a typed array having a specified length from a typed array memory - pool. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|null - If the function is unable to allocate a typed array from the typed array - pool (e.g., due to insufficient memory), the function returns `null`. - - Examples - -------- - > var arr = {{alias}}.malloc( 5 ) - - > arr = {{alias}}.malloc( 5, 'int32' ) - - - -{{alias}}.malloc( typedarray[, dtype] ) - Creates a pooled typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|null - If the function is unable to allocate a typed array from the typed array - pool (e.g., due to insufficient memory), the function returns `null`. - - Examples - -------- - > var arr1 = {{alias}}.malloc( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}.malloc( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}.malloc( obj[, dtype] ) - Creates a pooled typed array from an array-like object. - - Parameters - ---------- - obj: Object - Array-like object from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|null - If the function is unable to allocate a typed array from the typed array - pool (e.g., due to insufficient memory), the function returns `null`. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}.malloc( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}.calloc( [dtype] ) - Returns a zero-initialized typed array from a typed array memory pool. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|null - If the function is unable to allocate a typed array from the typed array - pool (e.g., due to insufficient memory), the function returns `null`. - - Examples - -------- - > var arr = {{alias}}.calloc() - [] - > arr = {{alias}}.calloc( 'float32' ) - [] - - -{{alias}}.calloc( length[, dtype] ) - Returns a zero-initialized typed array having a specified length from a - typed array memory pool. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|null - If the function is unable to allocate a typed array from the typed array - pool (e.g., due to insufficient memory), the function returns `null`. - - Examples - -------- - > var arr = {{alias}}.calloc( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}.calloc( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}.free( buf ) - Frees a typed array or typed array buffer for use in a future allocation. - - Parameters - ---------- - buf: TypedArray|ArrayBuffer - Typed array or typed array buffer to free. - - Examples - -------- - > var arr = {{alias}}( 5 ) - - > {{alias}}.free( arr ); - - -{{alias}}.clear() - Clears the typed array pool allowing garbage collection of previously - allocated (and currently free) array buffers. - - Examples - -------- - > var arr = {{alias}}( 5 ) - - > {{alias}}.free( arr ); - > {{alias}}.clear(); - - -{{alias}}.highWaterMark - Read-only property returning the pool's high water mark. - - Once a high water mark is reached, typed array allocation fails. - - Examples - -------- - > {{alias}}.highWaterMark - - - -{{alias}}.nbytes - Read-only property returning the total number of allocated bytes. - - The returned value is the total accumulated value. Hence, anytime a pool - must allocate a new array buffer (i.e., more memory), the pool increments - this value. - - The only time this value is decremented is when a pool is cleared. - - This behavior means that, while allocated buffers which are never freed may, - in fact, be garbage collected, they continue to count against the high water - mark limit. - - Accordingly, you should *always* free allocated buffers in order to prevent - the pool from believing that non-freed buffers are continually in use. - - Examples - -------- - > var arr = {{alias}}( 5 ) - - > {{alias}}.nbytes - - - -{{alias}}.factory( [options] ) - Creates a typed array pool. - - Parameters - ---------- - options: Object (optional) - Function options. - - options.highWaterMark: integer (optional) - Maximum total memory (in bytes) which can be allocated. - - Returns - ------- - fcn: Function - Function for creating typed arrays from a typed array memory pool. - - Examples - -------- - > var pool = {{alias}}.factory(); - > var arr1 = pool( 3, 'float64' ) - - - See Also - -------- - diff --git a/pool/docs/types/index.d.ts b/pool/docs/types/index.d.ts deleted file mode 100644 index ee01b0e3e..000000000 --- a/pool/docs/types/index.d.ts +++ /dev/null @@ -1,359 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike, RealOrComplexTypedArray, BooleanArray, NumericDataType as DataType } from '@stdlib/types/array'; -import ArrayBuffer = require( './../../../buffer' ); - -/** -* Typed array or null. -*/ -type TypedArrayOrNull = RealOrComplexTypedArray | BooleanArray | null; - -/** -* Interface defining pool options. -*/ -interface Options { - /** - * Maximum total memory which can be allocated. - */ - highWaterMark?: number; -} - -/** -* Pool interface. -*/ -interface Pool { - /** - * Returns an uninitialized typed array. - * - * ## Notes - * - * - Memory is **not** initialized. - * - Memory is lazily allocated. - * - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory). - * - * @param dtype - data type (default: 'float64') - * @returns typed array or null - * - * @example - * var arr = typedarraypool(); - * // returns [] - * - * @example - * var arr = typedarraypool( 'float32' ); - * // returns [] - */ - ( dtype?: DataType ): TypedArrayOrNull; - - /** - * Returns an uninitialized typed array. - * - * ## Notes - * - * - Memory is **not** initialized. - * - Memory is lazily allocated. - * - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory). - * - * @param arg - an array length or an array-like object - * @param dtype - data type (default: 'float64') - * @returns typed array or null - * - * @example - * // Allocate an array of doubles: - * var arr = typedarraypool( 5, 'float64' ); - * // e.g., returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - * - * arr[ 0 ] = 3.14; - * arr[ 1 ] = 3.14; - * - * // ... - * - * // Free the allocated memory to be used in a future allocation: - * typedarraypool.free( arr ); - * - * @example - * var arr1 = typedarraypool( [ 0.5, 0.5, 0.5 ] ); - * var arr2 = typedarraypool( arr1, 'float32' ); - * // returns [ 0.5, 0.5, 0.5 ] - * - * @example - * var arr1 = [ 0.5, 0.5, 0.5 ]; - * var arr2 = typedarraypool( arr1, 'float32' ); - * // returns [ 0.5, 0.5, 0.5 ] - */ - ( arg: number | ArrayLike, dtype?: DataType ): TypedArrayOrNull; - - /** - * Returns a zero-initialized typed array. - * - * ## Notes - * - * - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory). - * - * @param dtype - data type (default: 'float64') - * @returns typed array or null - * - * @example - * var arr1 = typedarraypool.calloc(); - * // returns [] - * - * var arr2 = typedarraypool.calloc( 'int32' ); - * // returns [] - * - * // ... - * - * typedarraypool.free( arr1 ); - * typedarraypool.free( arr2 ); - */ - calloc( dtype?: DataType ): TypedArrayOrNull; - - /** - * Returns a zero-initialized typed array. - * - * ## Notes - * - * - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory). - * - * @param length - typed array length - * @param dtype - data type (default: 'float64') - * @returns typed array or null - * - * @example - * var arr1 = typedarraypool.calloc( 5 ); - * // returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - * - * var arr2 = typedarraypool.calloc( 5, 'uint8' ); - * // returns [ 0, 0, 0, 0, 0 ] - * - * // ... - * - * typedarraypool.free( arr1 ); - * typedarraypool.free( arr2 ); - */ - calloc( length: number, dtype?: DataType ): TypedArrayOrNull; - - /** - * Returns an uninitialized typed array. - * - * ## Notes - * - * - Memory is **not** initialized. - * - Memory is lazily allocated. - * - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory). - * - * @param dtype - data type (default: 'float64') - * @returns typed array or null - * - * @example - * var arr1 = typedarraypool.malloc(); - * // returns [] - * - * var arr2 = typedarraypool.malloc( 'int32' ); - * // returns [] - * - * // ... - * - * typedarraypool.free( arr1 ); - * typedarraypool.free( arr2 ); - */ - malloc( dtype?: DataType ): TypedArrayOrNull; - - /** - * Returns an uninitialized typed array. - * - * ## Notes - * - * - Memory is **not** initialized. - * - Memory is lazily allocated. - * - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory). - * - * @param arg - an array length or an array-like object - * @param dtype - data type (default: 'float64') - * @returns typed array or null - * - * @example - * var arr1 = typedarraypool.malloc( 5 ); - * // returns - * - * var arr2 = typedarraypool.malloc( 5, 'uint8' ); - * // returns - * - * // ... - * - * typedarraypool.free( arr1 ); - * typedarraypool.free( arr2 ); - * - * @example - * var arr1 = typedarraypool.malloc( [ 5.0, -3.0, 2.0 ] ); - * // returns [ 5.0, -3.0, 2.0 ] - * - * var arr2 = typedarraypool.malloc( arr1 ); - * // returns [ 5.0, -3.0, 2.0 ] - * - * var arr3 = typedarraypool.malloc( arr1, 'int32' ); - * // returns [ 5, -3, 2 ] - * - * // ... - * - * typedarraypool.free( arr1 ); - * typedarraypool.free( arr2 ); - * typedarraypool.free( arr3 ); - * - * @example - * var arr1 = typedarraypool.malloc( [ 0.5, 0.5, 0.5 ] ); - * // returns [ 0.5, 0.5, 0.5 ] - * - * var arr2 = typedarraypool.malloc( [ 0.5, 0.5, 0.5 ], 'float32' ); - * // returns [ 0.5, 0.5, 0.5 ] - * - * // ... - * - * typedarraypool.free( arr1 ); - * typedarraypool.free( arr2 ); - */ - malloc( arg: number | ArrayLike, dtype?: DataType ): TypedArrayOrNull; - - /** - * Frees a typed array or typed array buffer for use in a future allocation. - * - * @param buf - typed array or typed array buffer to free - * - * @example - * var arr = typedarraypool( 10, 'float64' ); - * // returns - * - * // ... - * - * // Free the allocated typed array for use in a future allocation: - * typedarraypool.free( arr ); - * - * // Create another typed array: - * arr = typedarraypool( 10, 'float64' ); - * // returns - * - * // ... - * - * // Free the allocated typed array buffer for use in a future allocation: - * typedarraypool.free( arr.buffer ); - */ - free( buf: RealOrComplexTypedArray | BooleanArray | ArrayBuffer ): void; - - /** - * Clears the typed array pool allowing garbage collection of previously allocated (and currently free) array buffers. - * - * @example - * var arr = typedarraypool( 10, 'float64' ); - * // returns - * - * // ... - * - * typedarraypool.free( arr ); - * - * // ... - * - * // Clear all freed buffers: - * typedarraypool.clear(); - */ - clear(): void; - - /** - * Read-only property returning the pool's high water mark. - * - * ## Notes - * - * - Once a high water mark is reached, typed array allocation fails. - * - * @example - * var limit = typedarraypool.highWaterMark; - * // returns - */ - readonly highWaterMark: number; - - /** - * Read-only property returning the total number of allocated bytes. - * - * @example - * var arr = typedarraypool( 5, 'float64' ); - * - * var nbytes = typedarraypool.nbytes; - * // returns - */ - readonly nbytes: number; - - /** - * Creates a typed array pool. - * - * @param options - pool options - * @param options.highWaterMark - maximum total memory which can be allocated - * @throws must provide valid options - * @returns allocator - * - * @example - * var allocator = typedarraypool.factory(); - * - * // Allocate an array of doubles: - * var arr = allocator( 5, 'float64' ); - * // returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - * - * arr[ 0 ] = 3.14; - * arr[ 1 ] = 3.14; - * - * // ... - * - * // Free the allocated memory to be used in a future allocation: - * allocator.free( arr ); - */ - factory( options?: Options ): Pool; -} - -/** -* Returns an uninitialized typed array. -* -* ## Notes -* -* - Memory is **not** initialized. -* - Memory is lazily allocated. -* - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory). -* -* @param arg - an array length or an array-like object -* @param dtype - data type (default: 'float64') -* @returns typed array or null -* -* @example -* // Allocate an array of doubles: -* var arr = typedarraypool( 5, 'float64' ); -* // e.g., returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] -* -* arr[ 0 ] = 3.14; -* arr[ 1 ] = 3.14; -* -* // ... -* -* // Free the allocated memory to be used in a future allocation: -* typedarraypool.free( arr ); -*/ -declare var typedarraypool: Pool; - - -// EXPORTS // - -export = typedarraypool; diff --git a/pool/docs/types/test.ts b/pool/docs/types/test.ts deleted file mode 100644 index 4336c4264..000000000 --- a/pool/docs/types/test.ts +++ /dev/null @@ -1,193 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-empty */ -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import typedarraypool = require( './index' ); - - -// TESTS // - -// The function returns a typed array or null... -{ - typedarraypool(); // $ExpectType TypedArrayOrNull - typedarraypool( 'float32' ); // $ExpectType TypedArrayOrNull - typedarraypool( 12 ); // $ExpectType TypedArrayOrNull - typedarraypool( 12, 'int32' ); // $ExpectType TypedArrayOrNull - typedarraypool( [ 1, 2, 3 ] ); // $ExpectType TypedArrayOrNull - const arr = new Int32Array( [ 2, 5, 5, 7 ] ); - typedarraypool( arr, 'float64' ); // $ExpectType TypedArrayOrNull -} - -// The compiler throws an error if the function is provided a first argument which is neither a number nor array-like object... -{ - typedarraypool( true ); // $ExpectError - typedarraypool( false ); // $ExpectError - typedarraypool( null ); // $ExpectError - typedarraypool( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a recognized data type... -{ - typedarraypool( 4, true ); // $ExpectError - typedarraypool( 4, false ); // $ExpectError - typedarraypool( 4, null ); // $ExpectError - typedarraypool( 4, 'abc' ); // $ExpectError - typedarraypool( 4, 123 ); // $ExpectError - typedarraypool( 4, [] ); // $ExpectError - typedarraypool( 4, {} ); // $ExpectError - typedarraypool( 4, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an incorrect number of arguments... -{ - typedarraypool( 4, 'int32', {} ); // $ExpectError -} - -// Attached to the main export is a `malloc` method which returns a typed array or null... -{ - typedarraypool.malloc(); // $ExpectType TypedArrayOrNull - typedarraypool.malloc( 'float32' ); // $ExpectType TypedArrayOrNull - typedarraypool.malloc( 12 ); // $ExpectType TypedArrayOrNull - typedarraypool.malloc( 12, 'int32' ); // $ExpectType TypedArrayOrNull - typedarraypool.malloc( [ 1, 2, 3 ] ); // $ExpectType TypedArrayOrNull - const arr = new Int32Array( [ 2, 5, 5, 7 ] ); - typedarraypool.malloc( arr, 'float64' ); // $ExpectType TypedArrayOrNull -} - -// The compiler throws an error if the `malloc` method is provided a first argument which is neither a number nor array-like object... -{ - typedarraypool.malloc( true ); // $ExpectError - typedarraypool.malloc( false ); // $ExpectError - typedarraypool.malloc( null ); // $ExpectError - typedarraypool.malloc( {} ); // $ExpectError -} - -// The compiler throws an error if the `malloc` method is provided a second argument which is not a recognized data type... -{ - typedarraypool.malloc( 4, true ); // $ExpectError - typedarraypool.malloc( 4, false ); // $ExpectError - typedarraypool.malloc( 4, null ); // $ExpectError - typedarraypool.malloc( 4, 'abc' ); // $ExpectError - typedarraypool.malloc( 4, 123 ); // $ExpectError - typedarraypool.malloc( 4, [] ); // $ExpectError - typedarraypool.malloc( 4, {} ); // $ExpectError - typedarraypool.malloc( 4, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `malloc` method is provided an incorrect number of arguments... -{ - typedarraypool.malloc( 4, 'int32', {} ); // $ExpectError -} - -// Attached to the main export is a `calloc` method which returns a typed array or null... -{ - typedarraypool.calloc(); // $ExpectType TypedArrayOrNull - typedarraypool.calloc( 'float32' ); // $ExpectType TypedArrayOrNull - typedarraypool.calloc( 12 ); // $ExpectType TypedArrayOrNull - typedarraypool.calloc( 12, 'int32' ); // $ExpectType TypedArrayOrNull -} - -// The compiler throws an error if the `calloc` method is provided a first argument which is not a number... -{ - typedarraypool.calloc( 'abc' ); // $ExpectError - typedarraypool.calloc( true ); // $ExpectError - typedarraypool.calloc( false ); // $ExpectError - typedarraypool.calloc( null ); // $ExpectError - typedarraypool.calloc( {} ); // $ExpectError - typedarraypool.calloc( [] ); // $ExpectError - typedarraypool.calloc( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `calloc` method is provided a second argument which is not a recognized data type... -{ - typedarraypool.calloc( 4, true ); // $ExpectError - typedarraypool.calloc( 4, false ); // $ExpectError - typedarraypool.calloc( 4, null ); // $ExpectError - typedarraypool.calloc( 4, 'abc' ); // $ExpectError - typedarraypool.calloc( 4, 123 ); // $ExpectError - typedarraypool.calloc( 4, [] ); // $ExpectError - typedarraypool.calloc( 4, {} ); // $ExpectError - typedarraypool.calloc( 4, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `calloc` method is provided an incorrect number of arguments... -{ - typedarraypool.calloc( 4, 'int32', {} ); // $ExpectError -} - -// Attached to the main export is a `factory` method which returns a typed array pool.. -{ - typedarraypool.factory(); // $ExpectType Pool - typedarraypool.factory( { 'highWaterMark': 556 } ); // $ExpectType Pool -} - -// The compiler throws an error if the `factory` method is provided a `highWaterMark` option which is not a number... -{ - typedarraypool.factory( { 'highWaterMark': true } ); // $ExpectError - typedarraypool.factory( { 'highWaterMark': false } ); // $ExpectError - typedarraypool.factory( { 'highWaterMark': 'abc' } ); // $ExpectError - typedarraypool.factory( { 'highWaterMark': null } ); // $ExpectError - typedarraypool.factory( { 'highWaterMark': [] } ); // $ExpectError - typedarraypool.factory( { 'highWaterMark': {} } ); // $ExpectError - typedarraypool.factory( { 'highWaterMark': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an incorrect number of arguments... -{ - typedarraypool.factory( {}, {} ); // $ExpectError -} - -// Attached to the main export is a `free` method which returns void... -{ - const arr = new Int32Array( [ 2, 5, 5, 7 ] ); - typedarraypool.free( arr ); // $ExpectType void -} - -// The compiler throws an error if the `free` method is provided a first argument which is neither a typed array nor array buffer... -{ - typedarraypool.free( true ); // $ExpectError - typedarraypool.free( false ); // $ExpectError - typedarraypool.free( 123 ); // $ExpectError - typedarraypool.free( 'abc' ); // $ExpectError - typedarraypool.free( null ); // $ExpectError - typedarraypool.free( {} ); // $ExpectError - typedarraypool.free( ( x: number ): number => x ); // $ExpectError -} - -// Attached to the main export is a `clear` method which returns void... -{ - typedarraypool.clear(); // $ExpectType void -} - -// The compiler throws an error if the `clear` method is provided arguments... -{ - typedarraypool.clear( {} ); // $ExpectError - typedarraypool.clear( {}, {} ); // $ExpectError -} - -// Attached to the main export is a `highWaterMark` property... -{ - typedarraypool.highWaterMark; // $ExpectType number -} - -// Attached to the main export is a `nbytes` property... -{ - typedarraypool.nbytes; // $ExpectType number -} diff --git a/pool/examples/index.js b/pool/examples/index.js deleted file mode 100644 index 830f14a76..000000000 --- a/pool/examples/index.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var typedarraypool = require( './../lib' ); - -// Create a typed array pool which can allocate at most 1GB: -var typedarray = typedarraypool.factory({ - 'highWaterMark': 1e9 -}); - -// Inspect the pool: -console.log( 'Max bytes: %d', typedarray.highWaterMark ); -console.log( 'nbytes: %d', typedarray.nbytes ); - -// Allocate an array for storing double-precision floating-point numbers: -var arr1 = typedarray( 5, 'float64' ); -// returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - -// Inspect the pool: -console.log( 'nbytes: %d', typedarray.nbytes ); - -// Fill the array... -var i; -for ( i = 0; i < arr1.length; i++ ) { - arr1[ i ] = randu(); -} - -// Inspect array contents: -console.log( arr1 ); - -// Free the array: -typedarray.free( arr1 ); - -// Allocate another array similar to the previous one: -var arr2 = typedarray( 5, 'float64' ); -// returns - -// Check that we have been returned a new typed array view: -console.log( arr2 === arr1 ); -// => false - -// Inspect array contents: -console.log( arr2 ); - -// Free the array: -typedarray.free( arr2 ); - -// Allocate an initialized array: -var arr3 = typedarray.calloc( 5, 'float64' ); -// returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - -// Inspect array contents: -console.log( arr3 ); - -// Free the array: -typedarray.free( arr3 ); - -// Clear the pool: -typedarray.clear(); - -// Inspect the pool: -console.log( 'nbytes: %d', typedarray.nbytes ); diff --git a/pool/lib/bytes_per_element.json b/pool/lib/bytes_per_element.json deleted file mode 100644 index 91a77c1f3..000000000 --- a/pool/lib/bytes_per_element.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "bool": 1, - "float64": 8, - "float32": 4, - "int16": 2, - "int32": 4, - "int8": 1, - "uint16": 2, - "uint32": 4, - "uint8": 1, - "uint8c": 1, - "complex64": 8, - "complex128": 16 -} diff --git a/pool/lib/defaults.js b/pool/lib/defaults.js deleted file mode 100644 index a421711f8..000000000 --- a/pool/lib/defaults.js +++ /dev/null @@ -1,42 +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'; - -// MAIN // - -/** -* Returns default options. -* -* @private -* @returns {Object} default options -* -* @example -* var o = defaults(); -* // returns {...} -*/ -function defaults() { - return { - 'highWaterMark': 9007199254740992 - }; -} - - -// EXPORTS // - -module.exports = defaults; diff --git a/pool/lib/factory.js b/pool/lib/factory.js deleted file mode 100644 index 823b517f4..000000000 --- a/pool/lib/factory.js +++ /dev/null @@ -1,391 +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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isCollection = require( '@stdlib/assert/is-collection' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isComplexDataType = require( './../../base/assert/is-complex-floating-point-data-type' ); -var isComplex64Array = require( '@stdlib/assert/is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert/is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); -var ctors = require( './../../typed-ctors' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var resolveGetter = require( './../../base/resolve-getter' ); -var resolveSetter = require( './../../base/resolve-setter' ); -var ARRAY_DEFAULTS = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); -var ArrayBuffer = require( './../../buffer' ); -var ceil = require( '@stdlib/math/base/special/ceil' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var ceil2 = require( '@stdlib/math/base/special/ceil2' ); -var log2 = require( '@stdlib/math/base/special/log2' ); -var min = require( '@stdlib/math/base/special/min' ); -var defaults = require( './defaults.js' ); -var validate = require( './validate.js' ); -var createPool = require( './pool.js' ); -var BYTES_PER_ELEMENT = require( './bytes_per_element.json' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = ARRAY_DEFAULTS.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// FUNCTIONS // - -/** -* Tests whether an array is a single-precision complex floating-point number array. -* -* @private -* @param {Collection} arr - input array -* @returns {boolean} boolean indicating whether an input array is a single-precision complex floating-point number array -*/ -function isCmplx64Array( arr ) { - return ( arr instanceof Complex64Array ); -} - -/** -* Tests whether an array is a double-precision complex floating-point number array. -* -* @private -* @param {Collection} arr - input array -* @returns {boolean} boolean indicating whether an input array is a double-precision complex floating-point number array -*/ -function isCmplx128Array( arr ) { - return ( arr instanceof Complex128Array ); -} - -/** -* Tests whether an array is a boolean array. -* -* @private -* @param {Collection} arr - input array -* @returns {boolean} boolean indicating whether an input array is a boolean array -*/ -function isBoolArray( arr ) { - return ( arr instanceof BooleanArray ); -} - - -// MAIN // - -/** -* Creates a typed array pool. -* -* @param {Options} [options] - pool options -* @param {NonNegativeInteger} [options.highWaterMark] - maximum total memory which can be allocated -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {Function} allocator -* -* @example -* var typedarraypool = factory(); -* -* // Allocate an array of doubles: -* var arr = typedarraypool( 5, 'float64' ); -* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] -* -* arr[ 0 ] = 3.14; -* arr[ 1 ] = 3.14; -* -* // ... -* -* // Free the allocated memory to be used in a future allocation: -* typedarraypool.free( arr ); -*/ -function factory( options ) { - var nbytes; - var pool; - var opts; - var err; - - opts = defaults(); - if ( arguments.length ) { - err = validate( opts, options ); - if ( err ) { - throw err; - } - } - pool = createPool( ceil( log2( opts.highWaterMark ) ) ); - nbytes = 0; - - setReadOnly( malloc, 'malloc', malloc ); // circular reference - setReadOnly( malloc, 'calloc', calloc ); - setReadOnly( malloc, 'free', free ); - setReadOnly( malloc, 'clear', clear ); - setReadOnly( malloc, 'highWaterMark', opts.highWaterMark ); - setReadOnlyAccessor( malloc, 'nbytes', getBytes ); - - return malloc; - - /** - * Returns the number of allocated bytes. - * - * @private - * @returns {NonNegativeInteger} number of allocated bytes - */ - function getBytes() { - return nbytes; - } - - /** - * Returns an array buffer. - * - * @private - * @param {NonNegativeInteger} n - number of bytes - * @returns {(ArrayBuffer|null)} array buffer or null - */ - function arraybuffer( n ) { - var buf; - var i; - - // Convert the number of bytes to an index in our pool table: - i = log2( n ); - - // If we already have an available array buffer, use it... - if ( i < pool.length && pool[ i ].length ) { - return pool[ i ].pop(); - } - // Before allocating a new array buffer, ensure that we have not exceeded the maximum number of bytes we are allowed to allocate... - if ( nbytes+n > opts.highWaterMark ) { - return null; - } - buf = new ArrayBuffer( n ); - - // Update the running counter of allocated bytes: - nbytes += n; - - return buf; - } - - /** - * Returns a typed array. - * - * @private - * @param {Function} ctor - typed array constructor - * @param {NonNegativeInteger} len - view length - * @param {string} dtype - data type - * @returns {(TypedArray|null)} typed array or null - */ - function typedarray( ctor, len, dtype ) { - var buf; - if ( len === 0 ) { - return new ctor( 0 ); - } - buf = arraybuffer( ceil2( len )*BYTES_PER_ELEMENT[ dtype ] ); - if ( buf === null ) { - return buf; - } - return new ctor( buf, 0, len ); - } - - /** - * Returns an uninitialized typed array. - * - * ## Notes - * - * - Memory is **not** initialized. - * - Memory is lazily allocated. - * - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory). - * - * @private - * @param {(NonNegativeInteger|Collection)} [arg] - an array length or an array-like object - * @param {string} [dtype="float64"] - data type - * @throws {TypeError} must provide a valid array length or an array-like object - * @throws {TypeError} must provide a recognized data type - * @returns {(TypedArray|null)} typed array or null - */ - function malloc() { - var nargs; - var dtype; - var ctor; - var arr; - var out; - var set; - var get; - var len; - var i; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - // Check if provided a typed array length... - if ( isNonNegativeInteger( arguments[ 0 ] ) ) { - return typedarray( ctor, arguments[ 0 ], dtype ); - } - // Check if provided an array-like object containing data elements... - if ( isCollection( arguments[ 0 ] ) ) { - arr = arguments[ 0 ]; - len = arr.length; - if ( isComplex128Array( arr ) ) { - arr = reinterpret128( arr, 0 ); - } else if ( isComplex64Array( arr ) ) { - arr = reinterpret64( arr, 0 ); - } else if ( isBooleanArray( arr ) ) { - arr = reinterpretBoolean( arr, 0 ); - } else if ( isComplexDataType( dtype ) ) { - // Assume we've been provided an array of interleaved real and imaginary components... - len /= 2; - } - out = typedarray( ctor, len, dtype ); - if ( out === null ) { - return out; - } - if ( isCmplx128Array( out ) || isCmplx64Array( out ) || isBoolArray( out ) ) { - out.set( arr ); - return out; - } - // Resolve element accessors in order to account for the possibility that `arr` is a complex number array. As we don't prohibit other "unsafe" casts (e.g., providing a `Float64Array` and specifying a `dtype` of `uint8`), we don't prohibit providing a complex number array and specifying a real `dtype`. The results will probably be unexpected/gibberish, but I am not sure we should be overly pedantic in ensuring users don't do ill-advised things... - get = resolveGetter( arr ); - set = resolveSetter( out ); - for ( i = 0; i < len; i++ ) { - set( out, i, get( arr, i ) ); - } - return out; - } - throw new TypeError( format( 'invalid argument. First argument must be either an array length or an array-like object. Value: `%s`.', arguments[ 0 ] ) ); - } - - /** - * Returns a zero-initialized typed array. - * - * ## Notes - * - * - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory). - * - * @private - * @param {NonNegativeInteger} [len=0] - array length - * @param {string} [dtype="float64"] - data type - * @throws {TypeError} must provide a valid array length - * @throws {TypeError} must provide a recognized data type - * @returns {(TypedArray|null)} typed array or null - */ - function calloc() { - var nargs; - var out; - var tmp; - var i; - - nargs = arguments.length; - if ( nargs === 0 ) { - out = malloc(); - } else if ( nargs === 1 ) { - out = malloc( arguments[ 0 ] ); - } else { - out = malloc( arguments[ 0 ], arguments[ 1 ] ); - } - if ( out !== null ) { - // Initialize the memory... - if ( isCmplx128Array( out ) ) { - tmp = reinterpret128( out, 0 ); - } else if ( isCmplx64Array( out ) ) { - tmp = reinterpret64( out, 0 ); - } else if ( isBoolArray( out ) ) { - tmp = reinterpretBoolean( out, 0 ); - } else { - tmp = out; - } - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = 0.0; - } - } - return out; - } - - /** - * Frees a typed array or typed array buffer. - * - * ## Notes - * - * - Implicitly, we support providing non-internally allocated arrays and array buffer (e.g., "freeing" a typed array allocated in userland); however, the freed array buffer is likely to have excess capacity when compared to other members in its pool. - * - * @private - * @param {(TypedArray|ArrayBuffer)} buf - typed array or array buffer to free - * @throws {TypeError} must provide a typed array or typed array buffer - * @returns {boolean} boolean indicating whether the typed array or array buffer was successfully freed - */ - function free( buf ) { - var n; - var p; - var i; - if ( isTypedArrayLike( buf ) && buf.buffer ) { - buf = buf.buffer; - } else if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. Must provide a typed array or ArrayBuffer. Value: `%s`.', buf ) ); - } - if ( buf.byteLength > 0 ) { - n = floor( log2( buf.byteLength ) ); - - // Prohibit "freeing" array buffers which would potentially allow users to circumvent high water mark limits: - n = min( pool.length-1, n ); - - // Ensure that we do not attempt to free the same buffer more than once... - p = pool[ n ]; - for ( i = 0; i < p.length; i++ ) { - if ( p[ i ] === buf ) { - return false; - } - } - // Add the buffer to our pool of free buffers: - p.push( buf ); - } - return true; - } - - /** - * Clears the typed array pool allowing garbage collection of previously allocated (and currently free) array buffers. - * - * @private - */ - function clear() { - var i; - for ( i = 0; i < pool.length; i++ ) { - pool[ i ].length = 0; - } - nbytes = 0; - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/pool/lib/index.js b/pool/lib/index.js deleted file mode 100644 index eaac779fa..000000000 --- a/pool/lib/index.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array pool. -* -* @module @stdlib/array/pool -* -* @example -* var typedarraypool = require( '@stdlib/array/pool' ); -* -* // Allocate an array of doubles: -* var arr = typedarraypool( 5, 'float64' ); -* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] -* -* arr[ 0 ] = 3.14; -* arr[ 1 ] = 3.14; -* -* // ... -* -* // Free the allocated memory to be used in a future allocation: -* typedarraypool.free( arr ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'factory', factory ); - - -// EXPORTS // - -module.exports = main; diff --git a/pool/lib/main.js b/pool/lib/main.js deleted file mode 100644 index 8f69ee3ad..000000000 --- a/pool/lib/main.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var factory = require( './factory.js' ); - - -// MAIN // - -/** -* Returns an uninitialized typed array. -* -* ## Notes -* -* - Memory is **not** initialized. -* - Memory is lazily allocated. -* - If the function returns `null`, the function was unable to allocate a new typed array from the typed array pool (most likely due to insufficient memory). -* -* @name typedarraypool -* @type {Function} -* @param {(NonNegativeInteger|ArrayLikeObject)} [arg] - an array length or an array-like object -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} must provide a valid array length or an array-like object -* @throws {TypeError} must provide a recognized data type -* @returns {(TypedArray|null)} typed array or null -* -* @example -* // Allocate an array of doubles: -* var arr = typedarraypool( 5, 'float64' ); -* // e.g., returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] -* -* arr[ 0 ] = 3.14; -* arr[ 1 ] = 3.14; -* -* // ... -* -* // Free the allocated memory to be used in a future allocation: -* typedarraypool.free( arr ); -*/ -var typedarraypool = factory(); - - -// EXPORTS // - -module.exports = typedarraypool; diff --git a/pool/lib/pool.js b/pool/lib/pool.js deleted file mode 100644 index 5abd2872d..000000000 --- a/pool/lib/pool.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Initializes a cache for pooled typed array buffers. -* -* @private -* @param {NonNegativeInteger} n - base-2 logarithm of the maximum typed array size -* @returns {ArrayArray} initialized cache -*/ -function pool( n ) { - var out; - var i; - - out = []; - for ( i = 0; i < n+1; i++ ) { - out.push( [] ); - } - return out; -} - - -// EXPORTS // - -module.exports = pool; diff --git a/pool/lib/validate.js b/pool/lib/validate.js deleted file mode 100644 index 9e23fb15a..000000000 --- a/pool/lib/validate.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert/is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {NonNegativeInteger} [options.highWaterMark] - maximum total memory which can be allocated -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'highWaterMark': 1024 -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'highWaterMark' ) ) { - opts.highWaterMark = options.highWaterMark; - if ( !isNonNegativeInteger( opts.highWaterMark ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/pool/package.json b/pool/package.json deleted file mode 100644 index 4a3e96903..000000000 --- a/pool/package.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "name": "@stdlib/array/pool", - "version": "0.0.0", - "description": "Typed array pool.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex64array", - "complex128array", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "complex64", - "complex128", - "complex", - "clamped", - "short", - "long", - "pool", - "memory", - "mem" - ] -} diff --git a/pool/test/test.factory.js b/pool/test/test.factory.js deleted file mode 100644 index 11b6f1037..000000000 --- a/pool/test/test.factory.js +++ /dev/null @@ -1,2401 +0,0 @@ -/* eslint-disable max-lines */ - -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var randu = require( '@stdlib/random/base/randu' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a function (no options)', function test( t ) { - t.strictEqual( typeof factory(), 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function returns a function (options)', function test( t ) { - t.strictEqual( typeof factory( {} ), 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an invalid options argument', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( value ); - }; - } -}); - -tape( 'the function throws an error if provided a `highWaterMark` option which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory({ - 'highWaterMark': value - }); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var typedarraypool; - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - typedarraypool = factory(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an unrecognized data type (length)', function test( t ) { - var typedarraypool; - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - typedarraypool = factory(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( 10, value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var typedarraypool; - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - typedarraypool = factory(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var typedarraypool; - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - typedarraypool = factory(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid array length or array-like object argument (no data type argument)', function test( t ) { - var typedarraypool; - var values; - var i; - - values = [ - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - typedarraypool = factory(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( value ); - }; - } -}); - -tape( 'the function returns a function which throws an error if provided an invalid array length or array-like object argument (data type argument)', function test( t ) { - var typedarraypool; - var values; - var i; - - values = [ - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - typedarraypool = factory(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( value, 'float64' ); - }; - } -}); - -tape( 'the function returns a function which returns a typed array (default)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=float64)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=float32)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=bool)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=complex128)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=complex64)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int32)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint32)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int16)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint16)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int8)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint8)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint8c)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (default, length)', function test( t ) { - var typedarraypool = factory(); - var arr; - - arr = typedarraypool( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=float64, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=float32, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=bool, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=complex128, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=complex64, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int32, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint32, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int16, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint16, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int8, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint8, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint8c, length)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (default, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=float64, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=float32, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=bool, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - var v; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ true, false, false, true ]; - out = typedarraypool( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( v, arr[ 0 ], 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( v, arr[ 1 ], 'returns expected value' ); - - v = out.get( 2 ); - t.strictEqual( v, arr[ 2 ], 'returns expected value' ); - - v = out.get( 3 ); - t.strictEqual( v, arr[ 3 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=complex128, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - var v; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarraypool( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( real( v ), arr[ 0 ], 'returns expected value' ); - t.strictEqual( imag( v ), arr[ 1 ], 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( real( v ), arr[ 2 ], 'returns expected value' ); - t.strictEqual( imag( v ), arr[ 3 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=complex64, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - var v; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarraypool( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( realf( v ), arr[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), arr[ 1 ], 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( realf( v ), arr[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), arr[ 3 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int32, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint32, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int16, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint16, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int8, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint8, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint8c, array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = []; - out = typedarraypool( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (default, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = new Float64Array( 0 ); - out = typedarraypool( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=float64, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = new Float64Array( 0 ); - out = typedarraypool( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=float32, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = new Uint32Array( 0 ); - out = typedarraypool( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=bool, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - var v; - - typedarraypool = factory(); - - arr = new Uint8Array( 0 ); - out = typedarraypool( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Uint8Array( [ 1, 0, 0, 1 ] ); - out = typedarraypool( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( v, false, 'returns expected value' ); - - v = out.get( 2 ); - t.strictEqual( v, false, 'returns expected value' ); - - v = out.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=complex128, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - var v; - - typedarraypool = factory(); - - arr = new Float64Array( 0 ); - out = typedarraypool( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarraypool( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( real( v ), arr[ 0 ], 'returns expected value' ); - t.strictEqual( imag( v ), arr[ 1 ], 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( real( v ), arr[ 2 ], 'returns expected value' ); - t.strictEqual( imag( v ), arr[ 3 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=complex64, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - var v; - - typedarraypool = factory(); - - arr = new Float32Array( 0 ); - out = typedarraypool( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarraypool( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( realf( v ), arr[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), arr[ 1 ], 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( realf( v ), arr[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), arr[ 3 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int32, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = new Float32Array( 0 ); - out = typedarraypool( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint32, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = new Uint8ClampedArray( 0 ); - out = typedarraypool( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int16, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = new Float64Array( 0 ); - out = typedarraypool( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint16, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = new Int8Array( 0 ); - out = typedarraypool( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=int8, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = new Int16Array( 0 ); - out = typedarraypool( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint8, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = new Int32Array( 0 ); - out = typedarraypool( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a function which returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var typedarraypool; - var arr; - var out; - - typedarraypool = factory(); - - arr = new Float32Array( 0 ); - out = typedarraypool( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a `malloc` method which is a circular reference', function test( t ) { - var typedarraypool = factory(); - t.strictEqual( typedarraypool, typedarraypool.malloc, 'is circular reference' ); - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (default)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=float64)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=float32)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=bool)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=complex128)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=complex64)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=int32)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=uint32)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=int16)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=uint16)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=int8)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=uint8)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=uint8c)', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - arr = typedarraypool.calloc( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (default, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10 ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0.0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=float64, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'float64' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0.0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=float32, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'float32' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0.0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=bool, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var v; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'bool' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp.set( Boolean( i%2 ), i ); - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, false, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=complex128, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var v; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'complex128' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp.set( new Complex128( randu()*256.0, 1.0 ), i ); - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( real( v ), 0.0, 'returns expected value' ); - t.strictEqual( imag( v ), 0.0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=complex64, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var v; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'complex64' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp.set( new Complex64( randu()*256.0, 1.0 ), i ); - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( realf( v ), 0.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 0.0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=int32, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'int32' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=uint32, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'uint32' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=int16, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'int16' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=uint16, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'uint16' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=int8, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'int8' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=uint8, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'uint8' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method which returns a zero-initialized typed array (dtype=uint8c, length)', function test( t ) { - var typedarraypool; - var arr; - var tmp; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'uint8c' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method for "freeing" allocated typed arrays', function test( t ) { - var typedarraypool; - var arr; - var buf; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - arr = typedarraypool( 10, 'uint8c' ); - buf = arr.buffer; - typedarraypool.free( arr ); - - for ( i = 0; i < 10; i++ ) { - arr = typedarraypool( 10, 'uint8c' ); - t.strictEqual( arr.buffer, buf, 'returns expected value' ); - typedarraypool.free( arr ); - } - typedarraypool.clear(); - t.end(); -}); - -tape( 'attached to the returned function is a method for "freeing" allocated typed array buffers', function test( t ) { - var typedarraypool; - var arr; - var buf; - var i; - - typedarraypool = factory(); - typedarraypool.clear(); - - arr = typedarraypool( 10, 'uint8c' ); - buf = arr.buffer; - typedarraypool.free( buf ); - - for ( i = 0; i < 10; i++ ) { - arr = typedarraypool( 10, 'uint8c' ); - t.strictEqual( arr.buffer, buf, 'returns expected value' ); - typedarraypool.free( arr.buffer ); - } - typedarraypool.clear(); - t.end(); -}); - -tape( 'attached to the returned function is a method for "freeing" allocated typed arrays which does not allow for "freeing" allocated typed arrays more than once before being reallocated', function test( t ) { - var typedarraypool; - var bool; - var arr; - - typedarraypool = factory(); - typedarraypool.clear(); - - arr = typedarraypool( 10, 'uint8c' ); - bool = typedarraypool.free( arr ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = typedarraypool.free( arr ); - t.strictEqual( bool, false, 'returns expected value' ); - - typedarraypool.clear(); - t.end(); -}); - -tape( 'attached to the returned function is a method for "freeing" allocated typed array buffers which does not allow for "freeing" allocated typed array buffers more than once before being reallocated', function test( t ) { - var typedarraypool; - var bool; - var arr; - var buf; - - typedarraypool = factory(); - typedarraypool.clear(); - - arr = typedarraypool( 10, 'uint8c' ); - buf = arr.buffer; - bool = typedarraypool.free( buf ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = typedarraypool.free( buf ); - t.strictEqual( bool, false, 'returns expected value' ); - - typedarraypool.clear(); - t.end(); -}); - -tape( 'attached to the returned function is a method for "freeing" allocated typed array and typed array buffers which throws if not provided either a typed array or typed array buffer', function test( t ) { - var typedarraypool; - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - typedarraypool = factory(); - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool.free( value ); - }; - } -}); - -tape( 'attached to the returned function is a property which returns the pool\'s high water mark', function test( t ) { - var typedarraypool = factory(); - t.strictEqual( typeof typedarraypool.highWaterMark, 'number', 'has property' ); - t.end(); -}); - -tape( 'the function supports specifying a high water mark which limits the total amount of memory a pool can allocate', function test( t ) { - var typedarraypool; - var arr1; - var arr2; - - typedarraypool = factory({ - 'highWaterMark': 64 // bytes - }); - - typedarraypool.clear(); - - arr1 = typedarraypool( 8, 'float64' ); - t.strictEqual( arr1.length, 8, 'returns expected value' ); - t.strictEqual( arr1.byteLength, 64, 'returns expected value' ); - - // Specify an array length: - arr2 = typedarraypool( 1e6, 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - arr2 = typedarraypool.malloc( 1e6, 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - arr2 = typedarraypool.calloc( 1e6, 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - // Provide an array from which to copy elements: - arr2 = typedarraypool( new Float64Array( 20 ), 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - arr2 = typedarraypool.malloc( new Float64Array( 20 ), 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - arr2 = typedarraypool.calloc( new Float64Array( 20 ), 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - typedarraypool.free( arr1 ); - - // Specify an array length: - arr2 = typedarraypool( 1e6, 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - arr2 = typedarraypool.malloc( 1e6, 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - arr2 = typedarraypool.calloc( 1e6, 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - // Provide an array from which to copy elements: - arr2 = typedarraypool( new Float64Array( 20 ), 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - arr2 = typedarraypool.malloc( new Float64Array( 20 ), 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - arr2 = typedarraypool.calloc( new Float64Array( 20 ), 'float64' ); - t.strictEqual( arr2, null, 'returns expected value' ); - - // Create an array which is less than or equal to the high water mark: - arr2 = typedarraypool( 8, 'float64' ); - t.strictEqual( arr2.length, 8, 'returns expected value' ); - t.strictEqual( arr2.byteLength, 64, 'returns expected value' ); - - typedarraypool.free( arr2 ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a property which returns the total number of accumulated bytes', function test( t ) { - var typedarraypool; - var arr; - - typedarraypool = factory(); - - typedarraypool.clear(); - t.strictEqual( typedarraypool.nbytes, 0, 'returns expected value' ); - - arr = typedarraypool( 10, 'uint8' ); - t.strictEqual( typedarraypool.nbytes > 0 && typedarraypool.nbytes < typedarraypool.highWaterMark, true, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the returned function is a method for clearing a typed array pool of freed typed array buffers', function test( t ) { - var typedarraypool; - var arrs; - var i; - - typedarraypool = factory(); - - typedarraypool.clear(); - t.strictEqual( typedarraypool.nbytes, 0, 'returns expected value' ); - - arrs = new Array( 10 ); - for ( i = 0; i < arrs.length; i++ ) { - arrs[ i ] = typedarraypool( 10, 'uint8' ); - t.strictEqual( typedarraypool.nbytes > 0 && typedarraypool.nbytes < typedarraypool.highWaterMark, true, 'returns expected value' ); - } - for ( i = 0; i < arrs.length; i++ ) { - typedarraypool.free( arrs[ i ] ); - } - t.strictEqual( typedarraypool.nbytes > 0 && typedarraypool.nbytes < typedarraypool.highWaterMark, true, 'returns expected value' ); - - typedarraypool.clear(); - t.strictEqual( typedarraypool.nbytes, 0, 'returns expected value' ); - - t.end(); -}); diff --git a/pool/test/test.js b/pool/test/test.js deleted file mode 100644 index 8a07bc423..000000000 --- a/pool/test/test.js +++ /dev/null @@ -1,1935 +0,0 @@ -/* eslint-disable max-lines */ - -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var randu = require( '@stdlib/random/base/randu' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var Boolean = require( '@stdlib/boolean/ctor' ); -var real = require( '@stdlib/complex/float64/real' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var typedarraypool = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarraypool, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid array length or array-like object argument (no data type argument)', function test( t ) { - var values; - var i; - - values = [ - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid array length or array-like object argument (data type argument)', function test( t ) { - var values; - var i; - - values = [ - 3.14, - -1, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool( value, 'float64' ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarraypool(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarraypool( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarraypool( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarraypool( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarraypool( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarraypool( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarraypool( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarraypool( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarraypool( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarraypool( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarraypool( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarraypool( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarraypool( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarraypool( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarraypool( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarraypool( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarraypool( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarraypool( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarraypool( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarraypool( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarraypool( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarraypool( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarraypool( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarraypool( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarraypool( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarraypool( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr; - var out; - - arr = []; - out = typedarraypool( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr; - var out; - - arr = []; - out = typedarraypool( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr; - var out; - - arr = []; - out = typedarraypool( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var arr; - var out; - var v; - - arr = []; - out = typedarraypool( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ true, false, false, true ]; - out = typedarraypool( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( v, arr[ 0 ], 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( v, arr[ 1 ], 'returns expected value' ); - - v = out.get( 2 ); - t.strictEqual( v, arr[ 2 ], 'returns expected value' ); - - v = out.get( 3 ); - t.strictEqual( v, arr[ 3 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var arr; - var out; - var v; - - arr = []; - out = typedarraypool( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarraypool( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( real( v ), arr[ 0 ], 'returns expected value' ); - t.strictEqual( imag( v ), arr[ 1 ], 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( real( v ), arr[ 2 ], 'returns expected value' ); - t.strictEqual( imag( v ), arr[ 3 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var arr; - var out; - var v; - - arr = []; - out = typedarraypool( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarraypool( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( realf( v ), arr[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), arr[ 1 ], 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( realf( v ), arr[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), arr[ 3 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr; - var out; - - arr = []; - out = typedarraypool( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr; - var out; - - arr = []; - out = typedarraypool( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr; - var out; - - arr = []; - out = typedarraypool( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr; - var out; - - arr = []; - out = typedarraypool( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr; - var out; - - arr = []; - out = typedarraypool( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr; - var out; - - arr = []; - out = typedarraypool( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr; - var out; - - arr = []; - out = typedarraypool( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = [ 1.0, 2.0, 3.0 ]; - out = typedarraypool( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr; - var out; - - arr = new Float64Array( 0 ); - out = typedarraypool( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr; - var out; - - arr = new Float64Array( 0 ); - out = typedarraypool( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr; - var out; - - arr = new Uint32Array( 0 ); - out = typedarraypool( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var arr; - var out; - var v; - - arr = new Uint8Array( 0 ); - out = typedarraypool( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Uint8Array( [ 1, 0, 0, 1 ] ); - out = typedarraypool( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( v, true, 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( v, false, 'returns expected value' ); - - v = out.get( 2 ); - t.strictEqual( v, false, 'returns expected value' ); - - v = out.get( 3 ); - t.strictEqual( v, true, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var arr; - var out; - var v; - - arr = new Float64Array( 0 ); - out = typedarraypool( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarraypool( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( real( v ), arr[ 0 ], 'returns expected value' ); - t.strictEqual( imag( v ), arr[ 1 ], 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( real( v ), arr[ 2 ], 'returns expected value' ); - t.strictEqual( imag( v ), arr[ 3 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var arr; - var out; - var v; - - arr = new Float32Array( 0 ); - out = typedarraypool( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarraypool( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - v = out.get( 0 ); - t.strictEqual( realf( v ), arr[ 0 ], 'returns expected value' ); - t.strictEqual( imagf( v ), arr[ 1 ], 'returns expected value' ); - - v = out.get( 1 ); - t.strictEqual( realf( v ), arr[ 2 ], 'returns expected value' ); - t.strictEqual( imagf( v ), arr[ 3 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr; - var out; - - arr = new Float32Array( 0 ); - out = typedarraypool( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr; - var out; - - arr = new Uint8ClampedArray( 0 ); - out = typedarraypool( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr; - var out; - - arr = new Float64Array( 0 ); - out = typedarraypool( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr; - var out; - - arr = new Int8Array( 0 ); - out = typedarraypool( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr; - var out; - - arr = new Int16Array( 0 ); - out = typedarraypool( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr; - var out; - - arr = new Int32Array( 0 ); - out = typedarraypool( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr; - var out; - - arr = new Float32Array( 0 ); - out = typedarraypool( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 0, 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - out = typedarraypool( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - - typedarraypool.free( out ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a `malloc` method which is a circular reference', function test( t ) { - t.strictEqual( typedarraypool, typedarraypool.malloc, 'is circular reference' ); - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (default)', function test( t ) { - var arr = typedarraypool.calloc(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=float64)', function test( t ) { - var arr = typedarraypool.calloc( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=float32)', function test( t ) { - var arr = typedarraypool.calloc( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=bool)', function test( t ) { - var arr = typedarraypool.calloc( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=complex128)', function test( t ) { - var arr = typedarraypool.calloc( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=complex64)', function test( t ) { - var arr = typedarraypool.calloc( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=int32)', function test( t ) { - var arr = typedarraypool.calloc( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=uint32)', function test( t ) { - var arr = typedarraypool.calloc( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=int16)', function test( t ) { - var arr = typedarraypool.calloc( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=uint16)', function test( t ) { - var arr = typedarraypool.calloc( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=int8)', function test( t ) { - var arr = typedarraypool.calloc( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=uint8)', function test( t ) { - var arr = typedarraypool.calloc( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=uint8c)', function test( t ) { - var arr = typedarraypool.calloc( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (default, length)', function test( t ) { - var arr; - var tmp; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10 ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0.0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=float64, length)', function test( t ) { - var arr; - var tmp; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'float64' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0.0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=float32, length)', function test( t ) { - var arr; - var tmp; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'float32' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0.0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=bool, length)', function test( t ) { - var arr; - var tmp; - var v; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'bool' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp.set( Boolean( i%2 ), i ); - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( v, false, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=complex128, length)', function test( t ) { - var arr; - var tmp; - var v; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'complex128' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp.set( new Complex128( randu()*256.0, 1.0 ), i ); - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( real( v ), 0.0, 'returns expected value' ); - t.strictEqual( imag( v ), 0.0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=complex64, length)', function test( t ) { - var arr; - var tmp; - var v; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'complex64' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp.set( new Complex64( randu()*256.0, 1.0 ), i ); - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - v = arr.get( i ); - t.strictEqual( realf( v ), 0.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 0.0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=int32, length)', function test( t ) { - var arr; - var tmp; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'int32' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=uint32, length)', function test( t ) { - var arr; - var tmp; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'uint32' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=int16, length)', function test( t ) { - var arr; - var tmp; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'int16' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=uint16, length)', function test( t ) { - var arr; - var tmp; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'uint16' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=int8, length)', function test( t ) { - var arr; - var tmp; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'int8' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=uint8, length)', function test( t ) { - var arr; - var tmp; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'uint8' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method which returns a zero-initialized typed array (dtype=uint8c, length)', function test( t ) { - var arr; - var tmp; - var i; - - typedarraypool.clear(); - - tmp = typedarraypool.malloc( 10, 'uint8c' ); - for ( i = 0; i < tmp.length; i++ ) { - tmp[ i ] = randu() * 256.0; - } - typedarraypool.free( tmp ); - - arr = typedarraypool.calloc( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.notEqual( arr, tmp, 'returns a new view' ); - t.strictEqual( arr.buffer, tmp.buffer, 'same array buffer' ); - - t.strictEqual( arr.length, 10, 'returns expected value' ); - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( arr[ i ], 0, 'returns expected value' ); - } - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method for "freeing" allocated typed arrays', function test( t ) { - var arr; - var buf; - var i; - - typedarraypool.clear(); - - arr = typedarraypool( 10, 'uint8c' ); - buf = arr.buffer; - typedarraypool.free( arr ); - - for ( i = 0; i < 10; i++ ) { - arr = typedarraypool( 10, 'uint8c' ); - t.strictEqual( arr.buffer, buf, 'returns expected value' ); - typedarraypool.free( arr ); - } - typedarraypool.clear(); - t.end(); -}); - -tape( 'attached to the exported function is a method for "freeing" allocated typed array buffers', function test( t ) { - var arr; - var buf; - var i; - - typedarraypool.clear(); - - arr = typedarraypool( 10, 'uint8c' ); - buf = arr.buffer; - typedarraypool.free( buf ); - - for ( i = 0; i < 10; i++ ) { - arr = typedarraypool( 10, 'uint8c' ); - t.strictEqual( arr.buffer, buf, 'returns expected value' ); - typedarraypool.free( arr.buffer ); - } - typedarraypool.clear(); - t.end(); -}); - -tape( 'attached to the exported function is a method for "freeing" allocated typed arrays which does not allow for "freeing" allocated typed arrays more than once before being reallocated', function test( t ) { - var bool; - var arr; - - typedarraypool.clear(); - - arr = typedarraypool( 10, 'uint8c' ); - bool = typedarraypool.free( arr ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = typedarraypool.free( arr ); - t.strictEqual( bool, false, 'returns expected value' ); - - typedarraypool.clear(); - t.end(); -}); - -tape( 'attached to the exported function is a method for "freeing" allocated typed array buffers which does not allow for "freeing" allocated typed array buffers more than once before being reallocated', function test( t ) { - var bool; - var arr; - var buf; - - typedarraypool.clear(); - - arr = typedarraypool( 10, 'uint8c' ); - buf = arr.buffer; - bool = typedarraypool.free( buf ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = typedarraypool.free( buf ); - t.strictEqual( bool, false, 'returns expected value' ); - - typedarraypool.clear(); - t.end(); -}); - -tape( 'attached to the exported function is a method for "freeing" allocated typed array and typed array buffers which throws if not provided either a typed array or typed array buffer', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarraypool.free( value ); - }; - } -}); - -tape( 'attached to the exported function is a property which returns the pool\'s high water mark', function test( t ) { - t.strictEqual( typeof typedarraypool.highWaterMark, 'number', 'has property' ); - t.end(); -}); - -tape( 'attached to the exported function is a property which returns the total number of accumulated bytes', function test( t ) { - var arr; - - typedarraypool.clear(); - t.strictEqual( typedarraypool.nbytes, 0, 'returns expected value' ); - - arr = typedarraypool( 10, 'uint8' ); - t.strictEqual( typedarraypool.nbytes > 0 && typedarraypool.nbytes < typedarraypool.highWaterMark, true, 'returns expected value' ); - - typedarraypool.free( arr ); - typedarraypool.clear(); - - t.end(); -}); - -tape( 'attached to the exported function is a method for clearing a typed array pool of freed typed array buffers', function test( t ) { - var arrs; - var i; - - typedarraypool.clear(); - t.strictEqual( typedarraypool.nbytes, 0, 'returns expected value' ); - - arrs = new Array( 10 ); - for ( i = 0; i < arrs.length; i++ ) { - arrs[ i ] = typedarraypool( 10, 'uint8' ); - t.strictEqual( typedarraypool.nbytes > 0 && typedarraypool.nbytes < typedarraypool.highWaterMark, true, 'returns expected value' ); - } - for ( i = 0; i < arrs.length; i++ ) { - typedarraypool.free( arrs[ i ] ); - } - t.strictEqual( typedarraypool.nbytes > 0 && typedarraypool.nbytes < typedarraypool.highWaterMark, true, 'returns expected value' ); - - typedarraypool.clear(); - t.strictEqual( typedarraypool.nbytes, 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'attached to the exported function is a method for creating typed array memory pools', function test( t ) { - t.strictEqual( typeof typedarraypool.factory, 'function', 'has method' ); - t.end(); -}); diff --git a/promotion-rules/README.md b/promotion-rules/README.md deleted file mode 100644 index 372cf5f7e..000000000 --- a/promotion-rules/README.md +++ /dev/null @@ -1,160 +0,0 @@ - - -# Promotion Rules - -> Return the array [data type][@stdlib/array/dtypes] with the smallest size and closest "kind" to which array [data types][@stdlib/array/dtypes] can be **safely** cast. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var promotionRules = require( '@stdlib/array/promotion-rules' ); -``` - -#### promotionRules( \[dtype1, dtype2] ) - -If provided [data types][@stdlib/array/dtypes], returns the array [data type][@stdlib/array/dtypes] with the smallest size and closest "kind" to which array [data types][@stdlib/array/dtypes] can be **safely** cast. - -```javascript -var out = promotionRules( 'float32', 'uint32' ); -// returns 'float64' -``` - -If not provided [data types][@stdlib/array/dtypes], the function returns a promotion table. - -```javascript -var out = promotionRules(); -// returns {...} - -var f32 = out[ 'float32' ]; -// returns {...} - -var rule = f32[ 'uint32' ]; -// returns 'float64' -``` - -If provided an unrecognized or unsupported `dtype`, the function returns `null`. - -```javascript -var out = promotionRules( 'foo', 'generic' ); -// returns null -``` - -
- - - - - -
- -## Notes - -- If a [data type][@stdlib/array/dtypes] to which [data types][@stdlib/array/dtypes] can be safely cast does **not** exist (or is not supported), the function returns `-1`. - -
- - - - - -
- -## Examples - - - -```javascript -var cartesianProduct = require( '@stdlib/array/cartesian-product' ); -var dtypes = require( '@stdlib/array/dtypes' ); -var unzip = require( '@stdlib/utils/unzip' ); -var logEachMap = require( '@stdlib/console/log-each-map' ); -var promotionRules = require( '@stdlib/array/promotion-rules' ); - -// Get the list of supported array data types: -var dt = dtypes(); - -// Generate a list of data type pairs: -var pairs = cartesianProduct( dt, dt ); - -// Split the pairs into separate arrays: -var args = unzip( pairs ); - -// Print the promotion rule for each pair of array data types: -logEachMap( '(%s, %s) => %s', args[ 0 ], args[ 1 ], promotionRules ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/promotion-rules/benchmark/benchmark.js b/promotion-rules/benchmark/benchmark.js deleted file mode 100644 index 416474d55..000000000 --- a/promotion-rules/benchmark/benchmark.js +++ /dev/null @@ -1,77 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var dtypes = require( './../../dtypes' ); -var pkg = require( './../package.json' ).name; -var promotionRules = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = promotionRules(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtypes', function benchmark( b ) { - var out; - var dt; - var N; - var i; - var j; - var k; - - dt = dtypes(); - N = dt.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % N; - k = (i+1) % N; - out = promotionRules( dt[ j ], dt[ k ] ); - if ( typeof out !== 'string' && out !== -1 ) { - b.fail( 'should return a string or -1' ); - } - } - b.toc(); - if ( !isString( out ) && out !== -1 ) { - b.fail( 'should return a string or -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/promotion-rules/docs/repl.txt b/promotion-rules/docs/repl.txt deleted file mode 100644 index 9fbace64f..000000000 --- a/promotion-rules/docs/repl.txt +++ /dev/null @@ -1,33 +0,0 @@ - -{{alias}}( [dtype1, dtype2] ) - Returns the array data type with the smallest size and closest "kind" to - which array data types can be safely cast. - - If not provided data types, the function returns a type promotion table. - - If a data type to which data types can be safely cast does *not* exist (or - is not supported), the function returns `-1`. - - If provided an unrecognized data type, the function returns `null`. - - Parameters - ---------- - dtype1: any (optional) - Array data type. - - dtype2: any (optional) - Array data type. - - Returns - ------- - out: Object|string|integer|null - Promotion rule(s). - - Examples - -------- - > var out = {{alias}}( 'float32', 'int32' ) - 'float64' - - See Also - -------- - diff --git a/promotion-rules/docs/types/index.d.ts b/promotion-rules/docs/types/index.d.ts deleted file mode 100644 index 56b987c8f..000000000 --- a/promotion-rules/docs/types/index.d.ts +++ /dev/null @@ -1,92 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { DataType } from '@stdlib/types/array'; - -/** -* Interface describing a promotion table. -*/ -interface Table { - /** - * Data type promotion rules. - */ - [key: string]: DataType | number; -} - -/** -* Promotion rule. -*/ -type PromotionRule = DataType | number; - -/** -* Returns the array data type with the smallest size and closest "kind" to which array data types can be safely cast. -* -* @param dtype1 - array data type -* @param dtype2 - array data type -* @returns promotion rule -* -* @example -* var dt = promotionRules( 'float32', 'uint32' ); -* // returns 'float64' -* -* @example -* var dt = promotionRules( 'float32', 'foo' ); -* // returns null -*/ -declare function promotionRules( dtype1: DataType, dtype2: DataType ): PromotionRule; - -/** -* Returns the array data type with the smallest size and closest "kind" to which array data types can be safely cast. -* -* @param dtype1 - array data type -* @param dtype2 - array data type -* @returns promotion rule -* -* @example -* var dt = promotionRules( 'float32', 'foo' ); -* // returns null -* -* @example -* var dt = promotionRules( 'bar', 'float32' ); -* // returns null -* -* @example -* var dt = promotionRules( 'bar', 'foo' ); -* // returns null -*/ -declare function promotionRules( dtype1: string, dtype2: string ): null; - -/** -* Returns a type promotion table displaying array data types with the smallest size and closest "kind" to which array data types can be safely cast. -* -* @returns promotion rule table -* -* @example -* var table = promotionRules(); -* // returns {...} -*/ -declare function promotionRules(): Table; - - -// EXPORTS // - -export = promotionRules; diff --git a/promotion-rules/docs/types/test.ts b/promotion-rules/docs/types/test.ts deleted file mode 100644 index 17cd9b790..000000000 --- a/promotion-rules/docs/types/test.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 promotionRules = require( './index' ); - - -// TESTS // - -// The function returns an object when not provided any arguments... -{ - promotionRules(); // $ExpectType Table -} - -// The function returns a promoted data type promotion rule when provided recognized data types... -{ - promotionRules( 'float32', 'uint32' ); // $ExpectType PromotionRule - promotionRules( 'int32', 'generic' ); // $ExpectType PromotionRule -} - -// The function returns null when provided unrecognized data types... -{ - promotionRules( 'float32', 'foo' ); // $ExpectType null - promotionRules( 'bar', 'foo' ); // $ExpectType null - promotionRules( 'bar', 'float32' ); // $ExpectType null -} - -// The compiler throws an error if the function is provided a first argument that is not a string... -{ - promotionRules( 123, 'float64' ); // $ExpectError - promotionRules( true, 'float64' ); // $ExpectError - promotionRules( false, 'float64' ); // $ExpectError - promotionRules( null, 'float64' ); // $ExpectError - promotionRules( {}, 'float64' ); // $ExpectError - promotionRules( ( x: number ): number => x, 'float64' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a string... -{ - promotionRules( 'int32', 123 ); // $ExpectError - promotionRules( 'int32', true ); // $ExpectError - promotionRules( 'int32', false ); // $ExpectError - promotionRules( 'int32', null ); // $ExpectError - promotionRules( 'int32', {} ); // $ExpectError - promotionRules( 'int32', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than one argument... -{ - promotionRules( 'float32' ); // $ExpectError - promotionRules( 'float32', 'int32', {} ); // $ExpectError -} diff --git a/promotion-rules/examples/index.js b/promotion-rules/examples/index.js deleted file mode 100644 index a8bb2c1ae..000000000 --- a/promotion-rules/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 cartesianProduct = require( './../../cartesian-product' ); -var dtypes = require( './../../dtypes' ); -var unzip = require( '@stdlib/utils/unzip' ); -var logEachMap = require( '@stdlib/console/log-each-map' ); -var promotionRules = require( './../lib' ); - -// Get the list of supported array data types: -var dt = dtypes(); - -// Generate a list of data type pairs: -var pairs = cartesianProduct( dt, dt ); - -// Split the pairs into separate arrays: -var args = unzip( pairs ); - -// Print the promotion rule for each pair of array data types: -logEachMap( '(%s, %s) => %s', args[ 0 ], args[ 1 ], promotionRules ); diff --git a/promotion-rules/lib/index.js b/promotion-rules/lib/index.js deleted file mode 100644 index 47c372198..000000000 --- a/promotion-rules/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return the array data type with the smallest size and closest "kind" to which array data types can be safely cast. -* -* @module @stdlib/array/promotion-rules -* -* @example -* var promotionRules = require( '@stdlib/array/promotion-rules' ); -* -* var table = promotionRules(); -* // returns {...} -* -* var dt = promotionRules( 'float32', 'uint32' ); -* // returns 'float64' -* -* dt = promotionRules( 'float32', 'foo' ); -* // returns null -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/promotion-rules/lib/main.js b/promotion-rules/lib/main.js deleted file mode 100644 index aa3fd82c5..000000000 --- a/promotion-rules/lib/main.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var objectKeys = require( '@stdlib/utils/keys' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var resolve = require( '@stdlib/strided/base/dtype-resolve-str' ); -var PROMOTION_RULES = require( './promotion_rules.json' ); - - -// FUNCTIONS // - -/** -* Generates a full table of promotion rules. -* -* @private -* @returns {Object} table -*/ -function generateFullTable() { - var dtypes; - var ntypes; - var out; - var tmp; - var dt1; - var dt2; - var o; - var j; - var i; - - out = {}; - dtypes = objectKeys( PROMOTION_RULES ); - ntypes = dtypes.length; - for ( i = 0; i < ntypes; i++ ) { - dt1 = dtypes[ i ]; - o = PROMOTION_RULES[ dt1 ]; - tmp = {}; - for ( j = 0; j < ntypes; j++ ) { - dt2 = dtypes[ j ]; - tmp[ dt2 ] = o[ dt2 ]; - } - out[ dt1 ] = tmp; - } - return out; -} - - -// MAIN // - -/** -* Returns the array data type with the smallest size and closest "kind" to which array data types can be safely cast. -* -* @param {*} [dtype1] - array data type value -* @param {*} [dtype2] - array data type value -* @returns {(Object|integer|string|null)} promotion rule(s) or null -* -* @example -* var table = promotionRules(); -* // returns {...} -* -* @example -* var dt = promotionRules( 'float32', 'uint32' ); -* // returns 'float64' -* -* @example -* var dt = promotionRules( 'float32', 'foo' ); -* // returns null -*/ -function promotionRules( dtype1, dtype2 ) { - var o; - if ( arguments.length === 0 ) { - return generateFullTable(); - } - dtype1 = resolve( dtype1 ); - if ( hasOwnProp( PROMOTION_RULES, dtype1 ) ) { - o = PROMOTION_RULES[ dtype1 ]; - dtype2 = resolve( dtype2 ); - if ( hasOwnProp( o, dtype2 ) ) { - return o[ dtype2 ]; - } - } - return null; -} - - -// EXPORTS // - -module.exports = promotionRules; diff --git a/promotion-rules/lib/promotion_rules.json b/promotion-rules/lib/promotion_rules.json deleted file mode 100644 index bfa96c8f7..000000000 --- a/promotion-rules/lib/promotion_rules.json +++ /dev/null @@ -1,197 +0,0 @@ -{ - "float64": { - "float64": "float64", - "float32": "float64", - "int32": "float64", - "int16": "float64", - "int8": "float64", - "uint32": "float64", - "uint16": "float64", - "uint8": "float64", - "uint8c": "float64", - "complex64": "complex128", - "complex128": "complex128", - "bool": -1, - "generic": "generic" - }, - "float32": { - "float64": "float64", - "float32": "float32", - "int32": "float64", - "int16": "float32", - "int8": "float32", - "uint32": "float64", - "uint16": "float32", - "uint8": "float32", - "uint8c": "float32", - "complex64": "complex64", - "complex128": "complex128", - "bool": -1, - "generic": "generic" - }, - "int32": { - "float64": "float64", - "float32": "float64", - "int32": "int32", - "int16": "int32", - "int8": "int32", - "uint32": "float64", - "uint16": "int32", - "uint8": "int32", - "uint8c": "int32", - "complex64": "complex128", - "complex128": "complex128", - "bool": -1, - "generic": "generic" - }, - "int16": { - "float64": "float64", - "float32": "float32", - "int32": "int32", - "int16": "int16", - "int8": "int16", - "uint32": "float64", - "uint16": "int32", - "uint8": "int16", - "uint8c": "int16", - "complex64": "complex64", - "complex128": "complex128", - "bool": -1, - "generic": "generic" - }, - "int8": { - "float64": "float64", - "float32": "float32", - "int32": "int32", - "int16": "int16", - "int8": "int8", - "uint32": "float64", - "uint16": "int32", - "uint8": "int16", - "uint8c": "int16", - "complex64": "complex64", - "complex128": "complex128", - "bool": -1, - "generic": "generic" - }, - "uint32": { - "float64": "float64", - "float32": "float64", - "int32": "float64", - "int16": "float64", - "int8": "float64", - "uint32": "uint32", - "uint16": "uint32", - "uint8": "uint32", - "uint8c": "uint32", - "complex64": "complex128", - "complex128": "complex128", - "bool": -1, - "generic": "generic" - }, - "uint16": { - "float64": "float64", - "float32": "float32", - "int32": "int32", - "int16": "int32", - "int8": "int32", - "uint32": "uint32", - "uint16": "uint16", - "uint8": "uint16", - "uint8c": "uint16", - "complex64": "complex64", - "complex128": "complex128", - "bool": -1, - "generic": "generic" - }, - "uint8": { - "float64": "float64", - "float32": "float32", - "int32": "int32", - "int16": "int16", - "int8": "int16", - "uint32": "uint32", - "uint16": "uint16", - "uint8": "uint8", - "uint8c": "uint8", - "complex64": "complex64", - "complex128": "complex128", - "bool": -1, - "generic": "generic" - }, - "uint8c": { - "float64": "float64", - "float32": "float32", - "int32": "int32", - "int16": "int16", - "int8": "int16", - "uint32": "uint32", - "uint16": "uint16", - "uint8": "uint8", - "uint8c": "uint8", - "complex64": "complex64", - "complex128": "complex128", - "bool": -1, - "generic": "generic" - }, - "complex128": { - "float64": "complex128", - "float32": "complex128", - "int32": "complex128", - "int16": "complex128", - "int8": "complex128", - "uint32": "complex128", - "uint16": "complex128", - "uint8": "complex128", - "uint8c": "complex128", - "complex64": "complex128", - "complex128": "complex128", - "bool": -1, - "generic": "generic" - }, - "complex64": { - "float64": "complex128", - "float32": "complex64", - "int32": "complex128", - "int16": "complex64", - "int8": "complex64", - "uint32": "complex128", - "uint16": "complex64", - "uint8": "complex64", - "uint8c": "complex64", - "complex64": "complex64", - "complex128": "complex128", - "bool": -1, - "generic": "generic" - }, - "bool": { - "float64": -1, - "float32": -1, - "int32": -1, - "int16": -1, - "int8": -1, - "uint32": -1, - "uint16": -1, - "uint8": -1, - "uint8c": -1, - "complex64": -1, - "complex128": -1, - "bool": "bool", - "generic": "generic" - }, - "generic": { - "float64": "generic", - "float32": "generic", - "int32": "generic", - "int16": "generic", - "int8": "generic", - "uint32": "generic", - "uint16": "generic", - "uint8": "generic", - "uint8c": "generic", - "complex64": "generic", - "complex128": "generic", - "bool": "generic", - "generic": "generic" - } -} diff --git a/promotion-rules/package.json b/promotion-rules/package.json deleted file mode 100644 index fd27bb240..000000000 --- a/promotion-rules/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/array/promotion-rules", - "version": "0.0.0", - "description": "Return the array data type with the smallest size and closest kind to which array data types can be safely cast.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "casting", - "cast", - "convert", - "conversion", - "rules", - "promotion", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/promotion-rules/test/test.js b/promotion-rules/test/test.js deleted file mode 100644 index 81a22eb64..000000000 --- a/promotion-rules/test/test.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../dtypes' ); -var isObject = require( '@stdlib/assert/is-plain-object' ); -var promotionRules = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof promotionRules, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided data types, the function returns a table', function test( t ) { - var out = promotionRules(); - t.strictEqual( isObject( out ), true, 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'uint32' ], 'float64', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the array data type with the smallest size and closest "kind" to which array data types can be safely cast', function test( t ) { - var table; - var dt1; - var dt2; - var dt; - var j; - var i; - - table = promotionRules(); - - for ( i = 0; i < DTYPES.length; i++ ) { - dt1 = DTYPES[ i ]; - for ( j = 0; j < DTYPES.length; j++ ) { - dt2 = DTYPES[ j ]; - dt = promotionRules( dt1, dt2 ); - t.strictEqual( dt, table[ dt1 ][ dt2 ], 'returns expected value when provided ('+dt1+','+dt2+')' ); - } - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - var j; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( promotionRules( values[ i ], 'generic' ), null, 'returns expected value when provided '+values[ i ] ); - t.strictEqual( promotionRules( 'generic', values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - - j = (i+1) % values.length; - t.strictEqual( promotionRules( values[ i ], values[ j ] ), null, 'returns expected value when provided ('+values[ i ]+','+values[ j ]+')' ); - } - t.end(); -}); diff --git a/put/README.md b/put/README.md deleted file mode 100644 index 7cd6e8e3b..000000000 --- a/put/README.md +++ /dev/null @@ -1,188 +0,0 @@ - - -# put - -> Replace specified elements of an array with provided values. - -
- -## Usage - -```javascript -var put = require( '@stdlib/array/put' ); -``` - -#### put( x, indices, values\[, options] ) - -Replaces specified elements of an array with provided values. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = put( x, [ 1, 3 ], [ 20, 40 ] ); -// returns [ 1, 20, 3, 40 ] - -var bool = ( out === x ); -// returns true -``` - -The function supports the following parameters: - -- **x**: input array. -- **indices**: list of indices. -- **values**: values to set. When `indices` contains one or more elements, `values` must be broadcast [compatible][@stdlib/ndarray/base/broadcast-shapes] with `indices` (i.e., must have either one element or the same number of elements as `indices`). -- **options**: function options. - -The function supports the following options: - -- **mode**: index [mode][@stdlib/ndarray/base/ind]. Default: `'normalize'`. - -If `indices` is an empty array, the function returns the input array unchanged. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = put( x, [], [ 20, 40 ] ); -// returns [ 1, 2, 3, 4 ] -``` - -The function supports broadcasting a `values` array containing a single element against an `indices` array containing one or more elements. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = put( x, [ 1, 3 ], [ 20 ] ); -// returns [ 1, 20, 3, 20 ] -``` - -By default, the function normalizes negative integer indices to positive integer index equivalents. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = put( x, [ -3, -1 ], [ 20, 40 ] ); -// returns [ 1, 20, 3, 40 ] -``` - -To specify an alternative index [mode][@stdlib/ndarray/base/ind], provide a `mode` option. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var out = put( x, [ -10, 10 ], [ 20, 40 ], { - 'mode': 'clamp' -}); -// returns [ 20, 2, 3, 40 ] -``` - -
- - - -
- -## Notes - -- The function mutates the input array `x`. -- Because each index is only validated at the time of replacing a particular element, mutation may occur even when one or more indices are out-of-bounds, including when the index [mode][@stdlib/ndarray/base/ind] indicates to raise an exception. -- The `values` array must have a [data type][@stdlib/array/dtypes] which can be [safely cast][@stdlib/array/safe-casts] to the input array data type. Floating-point data types (both real and complex) are allowed to downcast to a lower precision data type of the [same kind][@stdlib/array/same-kind-casts] (e.g., element values from a `'float64'` values array can be assigned to corresponding elements in a `'float32'` input array). - -
- - - -
- -## Examples - - - -```javascript -var filledBy = require( '@stdlib/array/base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( '@stdlib/array/base/linspace' ); -var put = require( '@stdlib/array/put' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); -console.log( indices ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = put( x, indices, values ); -console.log( out ); -``` - -
- - - - - - - - - - - - - - diff --git a/put/benchmark/benchmark.js b/put/benchmark/benchmark.js deleted file mode 100644 index c1c504094..000000000 --- a/put/benchmark/benchmark.js +++ /dev/null @@ -1,78 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var put = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::no_broadcasting:len=100', function benchmark( b ) { - var idx; - var x; - var i; - var v; - - x = zeroTo( 100 ); - idx = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = put( x, idx, x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::broadcasting:len=100', function benchmark( b ) { - var idx; - var x; - var i; - var v; - - x = zeroTo( 100 ); - idx = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = put( x, idx, [ i ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/put/benchmark/benchmark.length.js b/put/benchmark/benchmark.length.js deleted file mode 100644 index 0f57eada7..000000000 --- a/put/benchmark/benchmark.length.js +++ /dev/null @@ -1,113 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../../base/zero-to' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var put = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'dtype': 'generic' -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var idx; - var x; - - x = discreteUniform( len, 0, 10, opts ); - idx = zeroTo( len ); - values = [ - discreteUniform( len, -10, 0, opts ), - discreteUniform( len, 0, 10, opts ) - ]; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = put( x, idx, values[ i%values.length ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/put/docs/repl.txt b/put/docs/repl.txt deleted file mode 100644 index f18926db7..000000000 --- a/put/docs/repl.txt +++ /dev/null @@ -1,57 +0,0 @@ - -{{alias}}( x, indices, values[, options] ) - Replaces specified elements of an array with provided values. - - The function supports broadcasting a `values` array containing a single - element against an `indices` array containing one or more elements. - - The function mutates the input array. - - Because each index is only validated at the time of replacing a particular - element, mutation may occur even when one or more indices are out-of-bounds, - including when the index mode indicates to raise an exception. - - If `indices` is an empty array, the function returns the input array - unchanged. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - indices: ArrayLikeObject - List of element indices. - - values: ArrayLikeObject - Values to set. When `indices` contains one or more elements, `values` - must be broadcast compatible with `indices` (i.e., must have either one - element or the same number of elements as `indices`). - - options: Object (optional) - Function options. - - options.mode: string (optional) - Specifies how to handle an index outside the interval [0, max], where - `max` is the maximum possible array index. If equal to 'throw', the - function throws an error. If equal to 'normalize', the function throws - an error if provided an out-of-bounds normalized index. If equal to - 'wrap', the function wraps around an index using modulo arithmetic. If - equal to 'clamp', the function sets an index to either 0 (minimum index) - or the maximum index. Default: 'normalize'. - - Returns - ------- - out: ArrayLikeObject - Input array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var out = {{alias}}( x, [ 1, 3 ], [ 20, 40 ] ) - [ 1, 20, 3, 40 ] - > var bool = ( out === x ) - true - - See Also - -------- - diff --git a/put/docs/types/index.d.ts b/put/docs/types/index.d.ts deleted file mode 100644 index eb81faeb0..000000000 --- a/put/docs/types/index.d.ts +++ /dev/null @@ -1,223 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { ComplexLike } from '@stdlib/types/complex'; -import { Mode } from '@stdlib/types/ndarray'; - -/** -* Index array. -*/ -type IndexArray = Collection | AccessorArrayLike; - -/** -* Values array. -*/ -type ValuesArray = Collection | AccessorArrayLike; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Index mode. - */ - mode?: Mode; -} - -/** -* Replaces specified elements of an array with provided values. -* -* @param x - input array -* @param indices - list of element indices -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var out = put( x, [ 1, 2 ], [ 30 ] ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function put( x: T, indices: IndexArray, values: ValuesArray, options?: Options ): T; - -/** -* Replaces specified elements of an array with provided values. -* -* @param x - input array -* @param indices - list of element indices -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var indices = [ 1, 2 ]; -* var values = new Complex128Array( [ 20.0, 30.0, 40, 5.0 ] ); -* -* var out = put( x, indices, values ); -* // returns -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var Complex128Array = require( '@stdlib/array/complex128' ); -* -* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -* -* var indices = [ 1, 2 ]; -* var values = new Complex128Array( [ 20.0, 30.0 ] ); -* -* var out = put( x, indices, values ); -* // returns -* -* var bool = ( out === x ); -* // returns true -*/ -declare function put( x: T, indices: IndexArray, values: ValuesArray, options?: Options ): T; - -/** -* Replaces specified elements of an array with provided values. -* -* @param x - input array -* @param indices - list of element indices -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = put( x, [ 1, 2 ], [ 30 ] ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function put( x: Array, indices: IndexArray, values: ValuesArray, options?: Options ): Array; - -/** -* Replaces specified elements of an array with provided values. -* -* @param x - input array -* @param indices - list of element indices -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values ); -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); -* -* var x = toAccessorArray( [ 1, 2, 3, 4 ] ); -* -* var out = put( x, [ 1, 2 ], [ 30 ] ); -* -* var bool = ( out === x ); -* // returns true -*/ -declare function put( x: AccessorArrayLike, indices: IndexArray, values: ValuesArray, options?: Options ): AccessorArrayLike; - -/** -* Replaces specified elements of an array with provided values. -* -* @param x - input array -* @param indices - list of element indices -* @param values - values to set -* @param options - function options -* @returns input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = put( x, [ 1, 2 ], [ 30 ] ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -declare function put( x: Collection, indices: IndexArray, values: ValuesArray, options?: Options ): Collection; - - -// EXPORTS // - -export = put; diff --git a/put/docs/types/test.ts b/put/docs/types/test.ts deleted file mode 100644 index 8b73b933d..000000000 --- a/put/docs/types/test.ts +++ /dev/null @@ -1,100 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import Complex128 = require( '@stdlib/complex/float64/ctor' ); -import AccessorArray = require( './../../../base/accessor' ); -import put = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - put( [ 1, 2, 3, 4 ], [ 1, 3 ], [ 20, 30 ] ); // $ExpectType number[] - put( [ 1, 2, 3, 4 ], [ 1, 3 ], [ 20, 30 ] ); // $ExpectType number[] - put( [ '1', '2', '3', '4' ], [ 1, 3 ], [ 20, 30 ] ); // $ExpectType (string | number)[] - put( [ 1, 2, 3, 4 ], [ 1, 3 ], [ true, true ] ); // $ExpectType (number | boolean)[] - - put( new Int32Array( [ 1, 2, 3, 4 ] ), [ 1, 3 ], [ 20, 30 ] ); // $ExpectType Int32Array - put( new Complex128Array( [ 1, 2, 3, 4 ] ), [ 1, 3 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ] ); // $ExpectType Complex128Array - put( new Complex64Array( [ 1, 2, 3, 4 ] ), [ 1, 3 ], [ new Complex128( 20, 30 ), [ 40, 50 ] ] ); // $ExpectType Complex64Array - put( new AccessorArray( [ 1, 2, 3, 4 ] ), [ 1, 3 ], new AccessorArray( [ 20, 30 ] ) ); // $ExpectType AccessorArrayLike -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - put( 1, [ 1, 3 ], [ 20, 30 ] ); // $ExpectError - put( true, [ 1, 3 ], [ 20, 30 ] ); // $ExpectError - put( false, [ 1, 3 ], [ 20, 30 ] ); // $ExpectError - put( null, [ 1, 3 ], [ 20, 30 ] ); // $ExpectError - put( void 0, [ 1, 3 ], [ 20, 30 ] ); // $ExpectError - put( {}, [ 1, 3 ], [ 20, 30 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - put( [], 1, [ 20, 30 ] ); // $ExpectError - put( [], true, [ 20, 30 ] ); // $ExpectError - put( [], false, [ 20, 30 ] ); // $ExpectError - put( [], null, [ 20, 30 ] ); // $ExpectError - put( [], void 0, [ 20, 30 ] ); // $ExpectError - put( [], {}, [ 20, 30 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object... -{ - put( [], [ 1, 3 ], 1 ); // $ExpectError - put( [], [ 1, 3 ], true ); // $ExpectError - put( [], [ 1, 3 ], false ); // $ExpectError - put( [], [ 1, 3 ], null ); // $ExpectError - put( [], [ 1, 3 ], void 0 ); // $ExpectError - put( [], [ 1, 3 ], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not an object... -{ - put( [], [ 1, 3 ], [ 20, 30 ], '1' ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], 1 ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], true ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], false ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], null ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], [] ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid index mode... -{ - put( [], [ 1, 3 ], [ 20, 30 ], { 'mode': '1' } ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], { 'mode': 1 } ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], { 'mode': true } ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], { 'mode': false } ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], { 'mode': null } ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], { 'mode': {} } ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], { 'mode': [] } ); // $ExpectError - put( [], [ 1, 3 ], [ 20, 30 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - put(); // $ExpectError - put( [] ); // $ExpectError - put( [], [] ); // $ExpectError - put( [], [], [], {}, {} ); // $ExpectError -} diff --git a/put/examples/index.js b/put/examples/index.js deleted file mode 100644 index 3d08887fc..000000000 --- a/put/examples/index.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -var filledBy = require( './../../base/filled-by' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var linspace = require( './../../base/linspace' ); -var put = require( './../lib' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate an array of random indices: -var N = discreteUniform( 5, 15 ); -var indices = filledBy( N, discreteUniform.factory( 0, x.length-1 ) ); -console.log( indices ); - -// Generate an array of random values: -var values = filledBy( N, discreteUniform.factory( 1000, 2000 ) ); -console.log( values ); - -// Update a random sample of elements in `x`: -var out = put( x, indices, values ); -console.log( out ); diff --git a/put/lib/defaults.js b/put/lib/defaults.js deleted file mode 100644 index ea2620441..000000000 --- a/put/lib/defaults.js +++ /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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns default options. -* -* @private -* @returns {Object} default options -* -* @example -* var o = defaults(); -* // returns {...} -*/ -function defaults() { - return { - 'mode': 'normalize' - }; -} - - -// EXPORTS // - -module.exports = defaults; diff --git a/put/lib/index.js b/put/lib/index.js deleted file mode 100644 index 81663e276..000000000 --- a/put/lib/index.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -/** -* Replace specified elements of an array with provided values. -* -* @module @stdlib/array/put -* -* @example -* var put = require( '@stdlib/array/put' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/put/lib/main.js b/put/lib/main.js deleted file mode 100644 index ca1bd4d64..000000000 --- a/put/lib/main.js +++ /dev/null @@ -1,117 +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. -*/ - -'use strict'; - -// MODULES // - -var isMostlySafeCast = require( './../../base/assert/is-mostly-safe-data-type-cast' ); -var isRealDataType = require( './../../base/assert/is-real-data-type' ); -var isComplexDataType = require( './../../base/assert/is-complex-floating-point-data-type' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var base = require( './../../base/put' ); -var dtype = require( './../../dtype' ); -var convert = require( './../../convert' ); -var format = require( '@stdlib/string/format' ); -var defaults = require( './defaults.js' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Replaces specified elements of an array with provided values. -* -* @param {Collection} x - input array -* @param {IntegerArray} indices - list of indices -* @param {Collection} values - values to set -* @param {Options} [options] - function options -* @param {string} [options.mode='normalize'] - index mode -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} second argument must be a collection -* @throws {TypeError} third argument must be a collection -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @throws {Error} third argument must be broadcast compatible with the second argument -* @throws {TypeError} third argument cannot be safely cast to the data type of the first argument -* @returns {Collection} input array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 1, 2 ]; -* var values = [ 20, 30 ]; -* -* var out = put( x, indices, values ); -* // returns [ 1, 20, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 1, 2 ]; -* var values = [ 30 ]; -* -* var out = put( x, indices, values ); -* // returns [ 1, 30, 30, 4 ] -* -* var bool = ( out === x ); -* // returns true -*/ -function put( x, indices, values ) { - var opts; - var err; - var xdt; - var vdt; - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) ); - } - if ( !isCollection( indices ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', indices ) ); - } - if ( !isCollection( values ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an array-like object. Value: `%s`.', values ) ); - } - opts = defaults(); - if ( arguments.length > 3 ) { - err = validate( opts, arguments[ 3 ] ); - if ( err ) { - throw err; - } - } - xdt = dtype( x ) || 'generic'; - vdt = dtype( values ) || 'generic'; - - // Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the input array data type is floating-point... - if ( !isMostlySafeCast( vdt, xdt ) ) { - throw new TypeError( format( 'invalid argument. Third argument cannot be safely cast to the input array data type. Data types: [%s, %s].', vdt, xdt ) ); - } - // When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array... - if ( isComplexDataType( xdt ) && isRealDataType( vdt ) ) { - values = convert( values, xdt ); - } - // Replace values in the input array: - return base( x, indices, values, opts.mode ); -} - - -// EXPORTS // - -module.exports = put; diff --git a/put/lib/validate.js b/put/lib/validate.js deleted file mode 100644 index 24e7153e7..000000000 --- a/put/lib/validate.js +++ /dev/null @@ -1,67 +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. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert/is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isIndexMode = require( '@stdlib/ndarray/base/assert/is-index-mode' ); -var modes = require( '@stdlib/ndarray/index-modes' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.mode] - index mode -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'mode': 'normalize' -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - if ( !isIndexMode( opts.mode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'mode', modes().join( '", "' ), opts.mode ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/put/package.json b/put/package.json deleted file mode 100644 index 4dba39bde..000000000 --- a/put/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/put", - "version": "0.0.0", - "description": "Replace specified elements of an array with provided values.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "set", - "replace", - "put", - "update" - ] -} diff --git a/put/test/test.js b/put/test/test.js deleted file mode 100644 index 73e3c7655..000000000 --- a/put/test/test.js +++ /dev/null @@ -1,904 +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. -*/ - -/* eslint-disable max-len */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var BooleanArray = require( './../../bool' ); -var zeros = require( './../../zeros' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isAccessorArray = require( '@stdlib/assert/is-accessor-array' ); -var put = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof put, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( value, [], [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( value, [], [], {} ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( [], value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( [], value, [], {} ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( [], [], value ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( [], [], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( [], [], [], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a valid index mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( [], [], [], { - 'mode': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not broadcast compatible with the second argument (generic)', function test( t ) { - var values; - var i; - - values = [ - [], - [ 1, 2, 3 ], - [ 1, 2, 3, 4 ], - [ 1, 2, 3, 4, 5 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided an array of length ' + values[ i ].length ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( [ 1, 2, 3, 4 ], [ 1, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not broadcast compatible with the second argument (typed)', function test( t ) { - var values; - var i; - - values = [ - [], - [ 1, 2, 3 ], - [ 1, 2, 3, 4 ], - [ 1, 2, 3, 4, 5 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided an array of length ' + values[ i ].length ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( new Int32Array( [ 1, 2, 3, 4 ] ), [ 1, 2 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not broadcast compatible with the second argument (accessors)', function test( t ) { - var values; - var i; - - values = [ - [], - [ 1, 2, 3 ], - [ 1, 2, 3, 4 ], - [ 1, 2, 3, 4, 5 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided an array of length ' + values[ i ].length ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( toAccessorArray( [ 1, 2, 3, 4 ] ), toAccessorArray( [ 1, 2 ] ), toAccessorArray( value ) ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which cannot be safely cast to the input array data type', function test( t ) { - var values; - var x; - var i; - - values = zeros( 5, 'float64' ); - - x = [ - zeros( 5, 'uint8' ), - zeros( 5, 'int8' ), - zeros( 5, 'int16' ), - zeros( 5, 'uint16' ) - ]; - for ( i = 0; i < x.length; i++ ) { - t.throws( badValue( x[ i ] ), TypeError, 'throws an error when provided ' + x[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - put( value, zeros( 5, 'generic' ), values ); - }; - } -}); - -tape( 'the function replaces elements in an array (generic)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 3 ]; - actual = put( x, indices, [ 20, 40 ] ); - expected = [ 1, 20, 3, 40 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 1, 3, 3 ]; - actual = put( x, indices, [ 20, 30, 40, 50 ] ); - expected = [ 1, 30, 3, 50 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 3, 2, 1, 0 ]; - actual = put( x, indices, [ 20, 30, 40, 50 ] ); - expected = [ 50, 40, 30, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = put( x, indices, [ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ] ); - expected = [ 1, 100, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (generic, broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 3 ]; - actual = put( x, indices, [ 20 ] ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 1, 3, 3 ]; - actual = put( x, indices, [ 20 ] ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 3, 2, 1, 0 ]; - actual = put( x, indices, [ 20 ] ); - expected = [ 20, 20, 20, 20 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = put( x, indices, [ 100 ] ); - expected = [ 1, 100, 3, 4 ]; - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, generic)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = toAccessorArray( [ 1, 3 ] ); - actual = put( toAccessorArray( x ), indices, toAccessorArray( [ 20, 40 ] ) ); - expected = [ 1, 20, 3, 40 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - actual = put( toAccessorArray( x ), indices, toAccessorArray( [ 20, 30, 40, 50 ] ) ); - expected = [ 1, 30, 3, 50 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = toAccessorArray( [ 3, 2, 1, 0 ] ); - actual = put( toAccessorArray( x ), indices, toAccessorArray( [ 20, 30, 40, 50 ] ) ); - expected = [ 50, 40, 30, 20 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = toAccessorArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - actual = put( toAccessorArray( x ), indices, toAccessorArray( [ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ] ) ); - expected = [ 1, 100, 3, 4 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, generic, broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = toAccessorArray( [ 1, 3 ] ); - actual = put( toAccessorArray( x ), indices, toAccessorArray( [ 20 ] ) ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - actual = put( toAccessorArray( x ), indices, toAccessorArray( [ 20 ] ) ); - expected = [ 1, 20, 3, 20 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = toAccessorArray( [ 3, 2, 1, 0 ] ); - actual = put( toAccessorArray( x ), indices, toAccessorArray( [ 20 ] ) ); - expected = [ 20, 20, 20, 20 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - indices = toAccessorArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - actual = put( toAccessorArray( x ), indices, toAccessorArray( [ 100 ] ) ); - expected = [ 1, 100, 3, 4 ]; - t.strictEqual( isAccessorArray( actual ), true, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (int32)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 3 ]; - actual = put( x, indices, new Int32Array( [ 20, 40 ] ) ); - expected = new Int32Array( [ 1, 20, 3, 40 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 1, 3, 3 ]; - actual = put( x, indices, new Int32Array( [ 20, 30, 40, 50 ] ) ); - expected = new Int32Array( [ 1, 30, 3, 50 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 3, 2, 1, 0 ]; - actual = put( x, indices, new Int32Array( [ 20, 30, 40, 50 ] ) ); - expected = new Int32Array( [ 50, 40, 30, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Upcasting: - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = put( x, indices, new Int8Array( [ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 ] ) ); - expected = new Int32Array( [ 1, 100, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (int32, broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 3 ]; - actual = put( x, indices, new Int32Array( [ 20 ] ) ); - expected = new Int32Array( [ 1, 20, 3, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 1, 3, 3 ]; - actual = put( x, indices, new Int32Array( [ 20 ] ) ); - expected = new Int32Array( [ 1, 20, 3, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 3, 2, 1, 0 ]; - actual = put( x, indices, new Int32Array( [ 20 ] ) ); - expected = new Int32Array( [ 20, 20, 20, 20 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Upcasting: - x = new Int32Array( [ 1, 2, 3, 4 ] ); - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = put( x, indices, new Int8Array( [ 100 ] ) ); - expected = new Int32Array( [ 1, 100, 3, 4 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (float64)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 1, 3 ]; - actual = put( x, indices, new Float64Array( [ 20.0, 40.0 ] ) ); - expected = new Float64Array( [ 1.0, 20.0, 3.0, 40.0 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 1, 1, 3, 3 ]; - actual = put( x, indices, new Float64Array( [ 20.0, 30.0, 40.0, 50.0 ] ) ); - expected = new Float64Array( [ 1.0, 30.0, 3.0, 50.0 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Downcast: - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 3, 2, 1, 0 ]; - actual = put( x, indices, new Float64Array( [ 20.0, 30.0, 40.0, 50.0 ] ) ); - expected = new Float32Array( [ 50.0, 40.0, 30.0, 20.0 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Upcasting: - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = put( x, indices, new Float64Array( [ 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0 ] ) ); - expected = new Complex128Array( [ 1.0, 2.0, 100.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (float64, broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 1, 3 ]; - actual = put( x, indices, new Float64Array( [ 20.0 ] ) ); - expected = new Float64Array( [ 1.0, 20.0, 3.0, 20.0 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 1, 1, 3, 3 ]; - actual = put( x, indices, new Float64Array( [ 20.0 ] ) ); - expected = new Float64Array( [ 1.0, 20.0, 3.0, 20.0 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Downcast: - x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - indices = [ 3, 2, 1, 0 ]; - actual = put( x, indices, new Float64Array( [ 20.0 ] ) ); - expected = new Float32Array( [ 20.0, 20.0, 20.0, 20.0 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - // Upcasting: - x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = put( x, indices, new Float64Array( [ 100.0 ] ) ); - expected = new Complex128Array( [ 1.0, 2.0, 100.0, 0.0, 5.0, 6.0, 7.0, 8.0 ] ); - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( isSameComplex128Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex64)', function test( t ) { - var expected; - var indices; - var actual; - var values; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = new Complex64Array( [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0 ] ); - expected = new Complex64Array( [ 1.0, 2.0, 30.0, 40.0, 5.0, 6.0, 70.0, 80.0 ] ); - actual = put( x, indices, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - // Downcast: - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = new Complex128Array( [ 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0 ] ); - expected = new Complex64Array( [ 1.0, 2.0, 30.0, 40.0, 5.0, 6.0, 70.0, 80.0 ] ); - actual = put( x, indices, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, complex64, broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - var values; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = new Complex64Array( [ 100.0, 200.0 ] ); - expected = new Complex64Array( [ 1.0, 2.0, 100.0, 200.0, 5.0, 6.0, 100.0, 200.0 ] ); - actual = put( x, indices, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - // Downcast: - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = new Complex128Array( [ 100.0, 200.0 ] ); - expected = new Complex64Array( [ 1.0, 2.0, 100.0, 200.0, 5.0, 6.0, 100.0, 200.0 ] ); - actual = put( x, indices, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean)', function test( t ) { - var expected; - var indices; - var actual; - var values; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = new BooleanArray( [ false, true, false, true ] ); - expected = [ true, true, false, true ]; - actual = put( x, indices, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < indices.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function replaces elements in an array (accessors, boolean, broadcasting)', function test( t ) { - var expected; - var indices; - var actual; - var values; - var x; - var v; - var i; - - x = new BooleanArray( [ true, false, false, true ] ); - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - values = new BooleanArray( [ true ] ); - expected = [ true, true, false, true ]; - actual = put( x, indices, values ); - - t.strictEqual( actual, x, 'returns expected value' ); - for ( i = 0; i < indices.length; i++ ) { - v = actual.get( i ); - t.strictEqual( v, expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns the input array unchanged if provided a second argument which is empty', function test( t ) { - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - actual = put( x, [], [ 5, 6, 7, 8 ] ); - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, [ 1, 2, 3, 4 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function normalizes negative indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -1, -2, -3, -4 ]; - actual = put( x, indices, [ 5, 6, 7, 8 ] ); - expected = [ 8, 7, 6, 5 ]; - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 2, 50, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - put( x, indices, [ 100 ] ); - } -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 4, 5, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - put( x, indices, [ 200 ], { - 'mode': 'throw' - }); - } -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -1, -2, -3, -4 ]; - actual = put( x, indices, [ 5, 6, 7, 8 ], { - 'mode': 'normalize' - }); - expected = [ 8, 7, 6, 5 ]; - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 2, 50, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - put( x, indices, [ 100 ], { - 'mode': 'normalize' - }); - } -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -10, 10, -5, 5 ]; - actual = put( x, indices, [ 100, 200, 300, 400 ], { - 'mode': 'clamp' - }); - expected = [ 300, 2, 3, 400 ]; - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -10, 10, -5, 5 ]; - actual = put( x, indices, [ 100, 200, 300, 400 ], { - 'mode': 'wrap' - }); - expected = [ 1, 400, 200, 300 ]; - - t.strictEqual( actual, x, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/put/test/test.validate.js b/put/test/test.validate.js deleted file mode 100644 index 5001a5e66..000000000 --- a/put/test/test.validate.js +++ /dev/null @@ -1,128 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if not provided an options object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[i] ); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `mode` option which is not a valid index mode', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'mode': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns `null` if all options are valid', function test( t ) { - var expected; - var options; - var opts; - var err; - - options = { - 'mode': 'throw' - }; - opts = {}; - - expected = { - 'mode': 'throw' - }; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function ignores unrecognized options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': 'boop', - 'foo': 5, - 'bar': {} - }; - - opts = {}; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, {}, 'returns expected value' ); - - t.end(); -}); diff --git a/reviver/README.md b/reviver/README.md deleted file mode 100644 index 3ae518054..000000000 --- a/reviver/README.md +++ /dev/null @@ -1,134 +0,0 @@ - - -# reviveTypedArray - -> Revive a JSON-serialized typed array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var reviveTypedArray = require( '@stdlib/array/reviver' ); -``` - -#### reviveTypedArray( key, value ) - -Revives a JSON-serialized typed array. - -```javascript -var parseJSON = require( '@stdlib/utils/parse-json' ); - -var str = '{"type":"Float64Array","data":[5,3]}'; - -var arr = parseJSON( str, reviveTypedArray ); -// returns [ 5.0, 3.0 ] -``` - -For details on the JSON serialization format, see [`@stdlib/array/to-json`][@stdlib/array/to-json]. - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var parseJSON = require( '@stdlib/utils/parse-json' ); -var typedarray2json = require( '@stdlib/array/to-json' ); -var reviveTypedArray = require( '@stdlib/array/reviver' ); - -var arr = new Float64Array( [ 5.0, 3.0 ] ); -var str = JSON.stringify( typedarray2json( arr ) ); -// returns '{"type":"Float64Array","data":[5,3]}' - -var out = parseJSON( str, reviveTypedArray ); -if ( out instanceof Error ) { - throw out; -} -console.log( out ); -// => [ 5.0, 3.0 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/reviver/benchmark/benchmark.js b/reviver/benchmark/benchmark.js deleted file mode 100644 index bc7a10ce6..000000000 --- a/reviver/benchmark/benchmark.js +++ /dev/null @@ -1,92 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 parseJSON = require( '@stdlib/utils/parse-json' ); -var pkg = require( './../package.json' ).name; -var reviveTypedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var str; - var o; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - str = '{"type":"Float64Array","data":['+i+','+(i+1)+']}'; - o = parseJSON( str, reviveTypedArray ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::no_reviver', function benchmark( b ) { - var str; - var o; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - str = '{"type":"Float64Array","data":['+i+','+(i+1)+']}'; - o = parseJSON( str ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::no_reviver,built-in', function benchmark( b ) { - var str; - var o; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - str = '{"type":"Float64Array","data":['+i+','+(i+1)+']}'; - o = JSON.parse( str ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/reviver/docs/repl.txt b/reviver/docs/repl.txt deleted file mode 100644 index 33cc8eac9..000000000 --- a/reviver/docs/repl.txt +++ /dev/null @@ -1,32 +0,0 @@ - -{{alias}}( key, value ) - Revives a JSON-serialized typed array. - - The serialization format for typed array is an object having the following - fields: - - - type: typed array type (e.g., "Float64Array", "Int8Array"). - - data: typed array data as an array of numbers. - - Parameters - ---------- - key: string - Key. - - value: any - Value. - - Returns - ------- - out: any - Value or typed array. - - Examples - -------- - > var str = '{"type":"Float64Array","data":[5,3]}'; - > var arr = {{alias:@stdlib/utils/parse-json}}( str, {{alias}} ) - [ 5.0, 3.0 ] - - See Also - -------- - diff --git a/reviver/docs/types/index.d.ts b/reviver/docs/types/index.d.ts deleted file mode 100644 index 118af96ab..000000000 --- a/reviver/docs/types/index.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Revives a JSON-serialized typed array. -* -* @param key - key -* @param value - value -* @returns value or typed array -* -* @example -* var parseJSON = require( '@stdlib/utils/parse-json' ); -* -* var str = '{"type":"Float64Array","data":[5,3]}'; -* -* var arr = parseJSON( str, reviveTypedArray ); -* // returns [ 5.0, 3.0 ] -*/ -declare function reviveTypedArray( key: string, value: any ): any; - - -// EXPORTS // - -export = reviveTypedArray; diff --git a/reviver/docs/types/test.ts b/reviver/docs/types/test.ts deleted file mode 100644 index 78d5d165c..000000000 --- a/reviver/docs/types/test.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 reviveTypedArray = require( './index' ); - - -// TESTS // - -// The function revives a serialized object... -{ - const o = { - 'type': 'Float64Array', - 'data': [ 5, 3 ] - }; - reviveTypedArray( 'foo', o ); // $ExpectType any -} - -// The compiler throws an error if the function is provided a first argument that is not a string... -{ - reviveTypedArray( true, 1 ); // $ExpectError - reviveTypedArray( false, 1 ); // $ExpectError - reviveTypedArray( null, 1 ); // $ExpectError - reviveTypedArray( undefined, 1 ); // $ExpectError - reviveTypedArray( 5, 1 ); // $ExpectError - reviveTypedArray( [], 1 ); // $ExpectError - reviveTypedArray( {}, 1 ); // $ExpectError - reviveTypedArray( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - reviveTypedArray(); // $ExpectError - reviveTypedArray( 'beep' ); // $ExpectError -} diff --git a/reviver/examples/index.js b/reviver/examples/index.js deleted file mode 100644 index 012449446..000000000 --- a/reviver/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( './../../float64' ); -var parseJSON = require( '@stdlib/utils/parse-json' ); -var typedarray2json = require( './../../to-json' ); -var reviveTypedArray = require( './../lib' ); - -var arr = new Float64Array( [ 5.0, 3.0 ] ); -var str = JSON.stringify( typedarray2json( arr ) ); -console.log( str ); -// => '{"type":"Float64Array","data":[5,3]}' - -var out = parseJSON( str, reviveTypedArray ); -if ( out instanceof Error ) { - throw out; -} -console.log( out ); -// => [ 5.0, 3.0 ] diff --git a/reviver/lib/ctors.js b/reviver/lib/ctors.js deleted file mode 100644 index 791afbd44..000000000 --- a/reviver/lib/ctors.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -// MODULES // - -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); - - -// MAIN // - -var ctors = { - 'Float64Array': Float64Array, - 'Float32Array': Float32Array, - 'Int32Array': Int32Array, - 'Uint32Array': Uint32Array, - 'Int16Array': Int16Array, - 'Uint16Array': Uint16Array, - 'Int8Array': Int8Array, - 'Uint8Array': Uint8Array, - 'Uint8ClampedArray': Uint8ClampedArray, - 'Complex64Array': Complex64Array, - 'Complex128Array': Complex128Array, - 'BooleanArray': BooleanArray -}; - - -// EXPORTS // - -module.exports = ctors; diff --git a/reviver/lib/index.js b/reviver/lib/index.js deleted file mode 100644 index db10e9b6e..000000000 --- a/reviver/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Revive a JSON-serialized typed array. -* -* @module @stdlib/array/reviver -* -* @example -* var parseJSON = require( '@stdlib/utils/parse-json' ); -* var reviveTypedArray = require( '@stdlib/array/reviver' ); -* -* var str = '{"type":"Float64Array","data":[5,3]}'; -* -* var arr = parseJSON( str, reviveTypedArray ); -* // returns [ 5.0, 3.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/reviver/lib/main.js b/reviver/lib/main.js deleted file mode 100644 index 625520d6f..000000000 --- a/reviver/lib/main.js +++ /dev/null @@ -1,62 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArray = require( '@stdlib/assert/is-array' ); -var ctors = require( './ctors.js' ); - - -// MAIN // - -/** -* Revives a JSON-serialized typed array. -* -* @param {string} key - key -* @param {*} value - value -* @returns {(*|TypedArray)} value or typed array -* -* @example -* var parseJSON = require( '@stdlib/utils/parse-json' ); -* -* var str = '{"type":"Float64Array","data":[5,3]}'; -* -* var arr = parseJSON( str, reviveTypedArray ); -* // returns [ 5.0, 3.0 ] -*/ -function reviveTypedArray( key, value ) { - var ctor; - if ( - value && - value.type && - isArray( value.data ) - ) { - ctor = ctors[ value.type ]; - if ( ctor ) { - return new ctor( value.data ); - } - } - return value; -} - - -// EXPORTS // - -module.exports = reviveTypedArray; diff --git a/reviver/package.json b/reviver/package.json deleted file mode 100644 index 50a78bcf3..000000000 --- a/reviver/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/reviver", - "version": "0.0.0", - "description": "Revive a JSON-serialized typed array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "typed-array", - "typed array", - "json", - "reviver", - "revive", - "unmarshal", - "deserialize", - "from", - "convert", - "parse", - "object", - "obj" - ] -} diff --git a/reviver/test/test.js b/reviver/test/test.js deleted file mode 100644 index 6efa021e9..000000000 --- a/reviver/test/test.js +++ /dev/null @@ -1,377 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var copy = require( '@stdlib/utils/copy' ); -var parseJSON = require( '@stdlib/utils/parse-json' ); -var toJSON = require( './../../to-json' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var real = require( '@stdlib/complex/float64/real' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var reviveTypedArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof reviveTypedArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'values which are not recognized as serialized typed arrays are unaffected', function test( t ) { - var expected; - var actual; - - expected = { - 'beep': 'boop' - }; - actual = parseJSON( '{"beep":"boop"}', reviveTypedArray ); - - t.deepEqual( actual, expected, 'returns expected value' ); - - // Null edge case: - actual = parseJSON( 'null', reviveTypedArray ); - t.strictEqual( actual, null, 'equals null' ); - - t.end(); -}); - -tape( 'an object must have a recognized "type" field in order to be revived', function test( t ) { - var expected; - var actual; - var json; - - json = { - 'type': 'Boop', - 'data': [ 5.0, 3.0 ] - }; - - expected = copy( json ); - actual = parseJSON( JSON.stringify( json ), reviveTypedArray ); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'an object must have a "data" field having an array value in order to be revived', function test( t ) { - var expected; - var actual; - var json; - - json = { - 'type': 'Float64Array' - }; - - expected = copy( json ); - actual = parseJSON( JSON.stringify( json ), reviveTypedArray ); - - t.deepEqual( actual, expected, 'returns expected value' ); - - json = { - 'type': 'Float64Array', - 'data': null - }; - - expected = copy( json ); - actual = parseJSON( JSON.stringify( json ), reviveTypedArray ); - - t.deepEqual( actual, expected, 'returns expected value' ); - - json = { - 'type': 'Float64Array', - 'data': '[1,2,3]' - }; - - expected = copy( json ); - actual = parseJSON( JSON.stringify( json ), reviveTypedArray ); - - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (Float64Array)', function test( t ) { - var json; - var arr; - var out; - - arr = new Float64Array( [ 5.0, 3.0 ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof Float64Array, true, 'is an instance' ); - t.strictEqual( out[ 0 ], arr[ 0 ], true, 'has expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (Float32Array)', function test( t ) { - var json; - var arr; - var out; - - arr = new Float32Array( [ 3.14, -3.14 ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof Float32Array, true, 'is an instance' ); - t.strictEqual( out[ 0 ], arr[ 0 ], true, 'has expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (BooleanArray)', function test( t ) { - var json; - var arr; - var out; - - arr = new BooleanArray( [ true, false ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof BooleanArray, true, 'is an instance' ); - t.strictEqual( out.get( 0 ), arr.get( 0 ), true, 'has expected value' ); - t.strictEqual( out.get( 1 ), arr.get( 1 ), true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (Complex64Array)', function test( t ) { - var json; - var arr; - var out; - - arr = new Complex64Array( [ 5.0, 3.0 ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof Complex64Array, true, 'is an instance' ); - t.strictEqual( realf( out.get( 0 ) ), realf( arr.get( 0 ) ), true, 'has expected value' ); - t.strictEqual( imagf( out.get( 0 ) ), imagf( arr.get( 0 ) ), true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (Complex128Array)', function test( t ) { - var json; - var arr; - var out; - - arr = new Complex128Array( [ 5.0, 3.0 ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof Complex128Array, true, 'is an instance' ); - t.strictEqual( real( out.get( 0 ) ), real( arr.get( 0 ) ), true, 'has expected value' ); - t.strictEqual( imag( out.get( 0 ) ), imag( arr.get( 0 ) ), true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (Int32Array)', function test( t ) { - var json; - var arr; - var out; - - arr = new Int32Array( [ 5, -3 ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof Int32Array, true, 'is an instance' ); - t.strictEqual( out[ 0 ], arr[ 0 ], true, 'has expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (Uint32Array)', function test( t ) { - var json; - var arr; - var out; - - arr = new Uint32Array( [ 5, 3 ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof Uint32Array, true, 'is an instance' ); - t.strictEqual( out[ 0 ], arr[ 0 ], true, 'has expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (Int16Array)', function test( t ) { - var json; - var arr; - var out; - - arr = new Int16Array( [ 5, -3 ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof Int16Array, true, 'is an instance' ); - t.strictEqual( out[ 0 ], arr[ 0 ], true, 'has expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (Uint16Array)', function test( t ) { - var json; - var arr; - var out; - - arr = new Uint16Array( [ 5, 3 ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof Uint16Array, true, 'is an instance' ); - t.strictEqual( out[ 0 ], arr[ 0 ], true, 'has expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (Int8Array)', function test( t ) { - var json; - var arr; - var out; - - arr = new Int8Array( [ 5, -3 ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof Int8Array, true, 'is an instance' ); - t.strictEqual( out[ 0 ], arr[ 0 ], true, 'has expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (Uint8Array)', function test( t ) { - var json; - var arr; - var out; - - arr = new Uint8Array( [ 5, 3 ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof Uint8Array, true, 'is an instance' ); - t.strictEqual( out[ 0 ], arr[ 0 ], true, 'has expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive a JSON-serialized typed array (Uint8ClampedArray)', function test( t ) { - var json; - var arr; - var out; - - arr = new Uint8ClampedArray( [ 5, 3 ] ); - json = JSON.stringify( toJSON( arr ) ); - - out = parseJSON( json, reviveTypedArray ); - - t.strictEqual( out instanceof Uint8ClampedArray, true, 'is an instance' ); - t.strictEqual( out[ 0 ], arr[ 0 ], true, 'has expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], true, 'has expected value' ); - - t.end(); -}); - -tape( 'the function will revive deeply nested serialized typed arrays (array)', function test( t ) { - var actual; - var ctors; - var arr; - var i; - - ctors = [ - Float64Array, - Int32Array - ]; - - arr = [ - toJSON( new Float64Array( [ 5.0, 3.0 ] ) ), - toJSON( new Int32Array( [ -2, -4 ] ) ) - ]; - - actual = parseJSON( JSON.stringify( arr ), reviveTypedArray ); - - for ( i = 0; i < arr.length; i++ ) { - t.strictEqual( actual[i] instanceof ctors[i], true, 'is an instance' ); - t.strictEqual( actual[i][0], arr[i].data[0], 'has expected value' ); - t.strictEqual( actual[i][1], arr[i].data[1], 'has expected value' ); - } - t.end(); -}); - -tape( 'the function will revive deeply nested serialized typed arrays (object)', function test( t ) { - var actual; - var json; - - json = { - 'a': { - 'b': toJSON( new Float32Array( [ 3.14, -3.14 ] ) ), - 'c': toJSON( new Uint8Array( [ 3, 5 ] ) ) - } - }; - actual = parseJSON( JSON.stringify( json ), reviveTypedArray ); - - t.strictEqual( actual.a.b instanceof Float32Array, true, 'is an instance' ); - t.strictEqual( actual.a.b[0], json.a.b.data[0], 'has expected value' ); - t.strictEqual( actual.a.b[1], json.a.b.data[1], 'has expected value' ); - - t.strictEqual( actual.a.c instanceof Uint8Array, true, 'is an instance' ); - t.strictEqual( actual.a.c[0], json.a.c.data[0], 'has expected value' ); - t.strictEqual( actual.a.c[1], json.a.c.data[1], 'has expected value' ); - - t.end(); -}); diff --git a/safe-casts/README.md b/safe-casts/README.md deleted file mode 100644 index a727f671f..000000000 --- a/safe-casts/README.md +++ /dev/null @@ -1,161 +0,0 @@ - - -# Safe Casts - -> Return a list of array [data types][@stdlib/array/dtypes] to which a provided array [data type][@stdlib/array/dtypes] can be safely cast. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var safeCasts = require( '@stdlib/array/safe-casts' ); -``` - -#### safeCasts( \[dtype] ) - -If provided a `dtype` argument, returns a list of array [data types][@stdlib/array/dtypes] to which a provided array [data type][@stdlib/array/dtypes] can be safely cast. - -```javascript -var out = safeCasts( 'float32' ); -// e.g., returns [ 'float32', 'float64', 'complex64', 'complex128', 'generic' ] -``` - -If not provided a `dtype` argument, the function returns a casting table. - -```javascript -var out = safeCasts(); -// returns {...} - -var f32 = out[ 'float32' ]; -// returns {...} - -var v = f32[ 'float64' ]; -// returns 1 -``` - -If provided an unrecognized or unsupported `dtype`, the function returns `null`. - -```javascript -var out = safeCasts( 'foo' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var safeCasts = require( '@stdlib/array/safe-casts' ); - -// Get the list of supported array data types: -var DTYPES = dtypes(); - -// Print the list of array data types to which a data type can be safely cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = safeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/safe-casts/benchmark/benchmark.js b/safe-casts/benchmark/benchmark.js deleted file mode 100644 index ca518a491..000000000 --- a/safe-casts/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var dtypes = require( './../../dtypes' ); -var pkg = require( './../package.json' ).name; -var safeCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = safeCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = safeCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/safe-casts/docs/repl.txt b/safe-casts/docs/repl.txt deleted file mode 100644 index c115c5f41..000000000 --- a/safe-casts/docs/repl.txt +++ /dev/null @@ -1,27 +0,0 @@ - -{{alias}}( [dtype] ) - Returns a list of array data types to which a provided array data type can - be safely cast. - - If not provided an array data type, the function returns a casting table. - - If provided an unrecognized array data type, the function returns `null`. - - Parameters - ---------- - dtype: any (optional) - Array data type. - - Returns - ------- - out: Object|Array|null - Array data types to which a data type can be safely cast. - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/safe-casts/docs/types/index.d.ts b/safe-casts/docs/types/index.d.ts deleted file mode 100644 index 1f9382cec..000000000 --- a/safe-casts/docs/types/index.d.ts +++ /dev/null @@ -1,101 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { DataType } from '@stdlib/types/array'; - -/** -* Table mapping data types to a list of data types to which data types can be safely cast. -*/ -interface Table { - /** - * Mapping of a data type to a list of data types to which a data type can be safely cast. - */ - [key: string]: CastingTable; -} - -/** -* Table mapping a data type to a list of data types to which a data type can be safely cast. -*/ -interface CastingTable { - /** - * Value indicating whether a data type can be safely cast to another data type. - */ - [key: string]: number; -} - -/** -* Returns a list of array data types to which a provided array data type can be safely cast. -* -* @param dtype - array data type -* @returns list of array data types -* -* @example -* var list = safeCasts( 'float32' ); -* // returns [...] -*/ -declare function safeCasts( dtype: DataType ): Array; - -/** -* Returns a list of array data types to which a provided array data type can be safely cast. -* -* ## Notes -* -* - If provided an unrecognized array data type, the function returns `null`. -* -* @param dtype - array data type -* @returns list of array data types -* -* @example -* var list = safeCasts( 'float' ); -* // returns null -*/ -declare function safeCasts( dtype: string ): null; - -/** -* Returns a list of array data types to which a provided array data type can be safely cast. -* -* ## Notes -* -* - If not provided an array data type, the function returns a casting table. -* - If provided an unrecognized array data type, the function returns `null`. -* -* @param dtype - array data type -* @returns a casting table, a list of array data types, or null -* -* @example -* var table = safeCasts(); -* // returns {...} -* -* @example -* var list = safeCasts( 'float32' ); -* // returns [...] -* -* @example -* var list = safeCasts( 'float' ); -* // returns null -*/ -declare function safeCasts( dtype?: string ): Table; - - -// EXPORTS // - -export = safeCasts; diff --git a/safe-casts/docs/types/test.ts b/safe-casts/docs/types/test.ts deleted file mode 100644 index 532163871..000000000 --- a/safe-casts/docs/types/test.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 safeCasts = require( './index' ); - - -// TESTS // - -// The function returns a casting table.. -{ - safeCasts(); // $ExpectType Table -} - -// The function returns a list of data types when provided a recognized data type... -{ - safeCasts( 'float32' ); // $ExpectType DataType[] -} - -// The function returns null when provided an unrecognized data type... -{ - safeCasts( 'float' ); // $ExpectType null -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - safeCasts( 123 ); // $ExpectError - safeCasts( true ); // $ExpectError - safeCasts( false ); // $ExpectError - safeCasts( {} ); // $ExpectError - safeCasts( [] ); // $ExpectError - safeCasts( null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - safeCasts( 'float32', 3 ); // $ExpectError -} diff --git a/safe-casts/examples/index.js b/safe-casts/examples/index.js deleted file mode 100644 index 0ba6dd906..000000000 --- a/safe-casts/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../dtypes' ); -var safeCasts = require( './../lib' ); - -// Get the list of supported array data types: -var DTYPES = dtypes(); - -// Print the list of array data types to which a data type can be safely cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = safeCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/safe-casts/lib/index.js b/safe-casts/lib/index.js deleted file mode 100644 index ff4be7f59..000000000 --- a/safe-casts/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Return a list of array data types to which a provided array data type can be safely cast. -* -* @module @stdlib/array/safe-casts -* -* @example -* var safeCasts = require( '@stdlib/array/safe-casts' ); -* -* var list = safeCasts( 'float32' ); -* // returns [...] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/safe-casts/lib/main.js b/safe-casts/lib/main.js deleted file mode 100644 index a76e21441..000000000 --- a/safe-casts/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var objectKeys = require( '@stdlib/utils/keys' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var resolve = require( '@stdlib/strided/base/dtype-resolve-str' ); -var SAFE_CASTS = require( './safe_casts.json' ); - - -// VARIABLES // - -var TABLE; - - -// FUNCTIONS // - -/** -* Generates a full table of safe casts for each array data type. -* -* @private -* @returns {Object} table -*/ -function generateFullTable() { - var dtypes; - var ntypes; - var out; - var tmp; - var dt1; - var dt2; - var o; - var j; - var i; - - out = {}; - dtypes = objectKeys( SAFE_CASTS ); - ntypes = dtypes.length; - for ( i = 0; i < ntypes; i++ ) { - dt1 = dtypes[ i ]; - o = SAFE_CASTS[ dt1 ]; - tmp = {}; - for ( j = 0; j < ntypes; j++ ) { - dt2 = dtypes[ j ]; - tmp[ dt2 ] = o[ dt2 ]; - } - out[ dt1 ] = tmp; - } - return out; -} - -/** -* Generates a table of safe casts for each array data type. -* -* @private -* @returns {Object} table -*/ -function generateTable() { - var dtypes; - var ntypes; - var out; - var tmp; - var dt1; - var dt2; - var o; - var j; - var i; - - out = {}; - dtypes = objectKeys( SAFE_CASTS ); - ntypes = dtypes.length; - for ( i = 0; i < ntypes; i++ ) { - dt1 = dtypes[ i ]; - o = SAFE_CASTS[ dt1 ]; - tmp = []; - for ( j = 0; j < ntypes; j++ ) { - dt2 = dtypes[ j ]; - if ( o[ dt2 ] === 1 ) { - tmp.push( dt2 ); - } - } - out[ dt1 ] = tmp; - } - return out; -} - - -// MAIN // - -/** -* Returns a list of array data types to which a provided array data type can be safely cast. -* -* @param {*} [dtype] - array data type value -* @returns {(Object|StringArray|null)} list of array data types or null -* -* @example -* var list = safeCasts( 'float32' ); -* // returns [...] -*/ -function safeCasts( dtype ) { - if ( arguments.length === 0 ) { - return generateFullTable(); - } - if ( TABLE === void 0 ) { - // Lazily generate table... - TABLE = generateTable(); - } - dtype = resolve( dtype ); - if ( hasOwnProp( TABLE, dtype ) ) { - return TABLE[ dtype ].slice(); - } - return null; -} - - -// EXPORTS // - -module.exports = safeCasts; diff --git a/safe-casts/lib/safe_casts.json b/safe-casts/lib/safe_casts.json deleted file mode 100644 index 43e6b95b6..000000000 --- a/safe-casts/lib/safe_casts.json +++ /dev/null @@ -1,197 +0,0 @@ -{ - "float64": { - "float64": 1, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 0, - "bool": 0, - "generic": 1 - }, - "float32": { - "float64": 1, - "float32": 1, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "int32": { - "float64": 1, - "float32": 0, - "int32": 1, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 0, - "bool": 0, - "generic": 1 - }, - "int16": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "int8": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 1, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "uint32": { - "float64": 1, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 1, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 0, - "bool": 0, - "generic": 1 - }, - "uint16": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 0, - "int8": 0, - "uint32": 1, - "uint16": 1, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "uint8": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 0, - "uint32": 1, - "uint16": 1, - "uint8": 1, - "uint8c": 1, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "uint8c": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 0, - "uint32": 1, - "uint16": 1, - "uint8": 1, - "uint8c": 1, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "complex128": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 0, - "bool": 0, - "generic": 1 - }, - "complex64": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "bool": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 0, - "complex64": 0, - "bool": 1, - "generic": 1 - }, - "generic": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 0, - "complex64": 0, - "bool": 0, - "generic": 1 - } -} diff --git a/safe-casts/package.json b/safe-casts/package.json deleted file mode 100644 index 1864b565b..000000000 --- a/safe-casts/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/safe-casts", - "version": "0.0.0", - "description": "Return a list of array data types to which a provided array data type can be safely cast.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "casting", - "cast", - "rules", - "promotion", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/safe-casts/test/test.js b/safe-casts/test/test.js deleted file mode 100644 index 4b78e70ab..000000000 --- a/safe-casts/test/test.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( './../../dtypes' ); -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var safeCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof safeCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = safeCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of array data types to which a provided array data type can be safely cast', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = safeCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( safeCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/same-kind-casts/README.md b/same-kind-casts/README.md deleted file mode 100644 index 9fee94915..000000000 --- a/same-kind-casts/README.md +++ /dev/null @@ -1,158 +0,0 @@ - - -# Same Kind Casts - -> Return a list of array [data types][@stdlib/array/dtypes] to which a provided array [data type][@stdlib/array/dtypes] can be safely cast or cast within the same "kind". - - - -
- -
- - - - - -
- -## Usage - -```javascript -var sameKindCasts = require( '@stdlib/array/same-kind-casts' ); -``` - -#### sameKindCasts( \[dtype] ) - -If provided a `dtype` argument, returns a list of array [data types][@stdlib/array/dtypes] to which a provided array [data type][@stdlib/array/dtypes] can be safely cast or cast within the same "kind" (e.g., between signed integers or between floating-point numbers). - -```javascript -var out = sameKindCasts( 'float64' ); -// e.g., returns [ 'float64', 'float32', 'complex64', 'complex128', 'generic' ] -``` - -If not provided a `dtype` argument, the function returns a casting table. - -```javascript -var out = sameKindCasts(); -// returns {...} - -var f64 = out[ 'float64' ]; -// returns {...} - -var v = f64[ 'float32' ]; -// returns 1 -``` - -If provided an unrecognized or unsupported `dtype`, the function returns `null`. - -```javascript -var out = sameKindCasts( 'foo' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var sameKindCasts = require( '@stdlib/array/same-kind-casts' ); - -// Get the list of supported array data types: -var DTYPES = dtypes(); - -// Print the list of array data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = sameKindCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/same-kind-casts/benchmark/benchmark.js b/same-kind-casts/benchmark/benchmark.js deleted file mode 100644 index e6edbee08..000000000 --- a/same-kind-casts/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var dtypes = require( './../../dtypes' ); -var pkg = require( './../package.json' ).name; -var sameKindCasts = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = sameKindCasts(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::dtype', function benchmark( b ) { - var out; - var dt; - var i; - - dt = dtypes(); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = sameKindCasts( dt[ i%dt.length ] ); - if ( out.length === 0 ) { - b.fail( 'should not be empty' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/same-kind-casts/docs/repl.txt b/same-kind-casts/docs/repl.txt deleted file mode 100644 index 6520df313..000000000 --- a/same-kind-casts/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( [dtype] ) - Returns a list of array data types to which a provided array data type can - be safely cast or cast within the same "kind". - - If not provided an array data type, the function returns a casting table. - - If provided an unrecognized array data type, the function returns `null`. - - Parameters - ---------- - dtype: any (optional) - Array data type. - - Returns - ------- - out: Object|Array|null - Array data types to which a data type can be safely cast or cast within - the same "kind". - - Examples - -------- - > var out = {{alias}}( 'float32' ) - - - See Also - -------- - diff --git a/same-kind-casts/docs/types/index.d.ts b/same-kind-casts/docs/types/index.d.ts deleted file mode 100644 index 39217b265..000000000 --- a/same-kind-casts/docs/types/index.d.ts +++ /dev/null @@ -1,101 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { DataType } from '@stdlib/types/array'; - -/** -* Table mapping data types to a list of data types to which data types can be safely cast or cast within the same "kind". -*/ -interface Table { - /** - * Mapping of a data type to a list of data types to which a data type can be safely cast or cast within the same "kind". - */ - [key: string]: CastingTable; -} - -/** -* Table mapping a data type to a list of data types to which a data type can be safely cast or cast within the same "kind". -*/ -interface CastingTable { - /** - * Value indicating whether a data type can be safely cast, or cast within the same "kind", to another data type. - */ - [key: string]: number; -} - -/** -* Returns a list of array data types to which a provided array data type can be safely cast or cast within the same "kind". -* -* @param dtype - array data type -* @returns list of array data types -* -* @example -* var list = sameKindCasts( 'float32' ); -* // returns [...] -*/ -declare function sameKindCasts( dtype: DataType ): Array; - -/** -* Returns a list of array data types to which a provided array data type can be safely cast or cast within the same "kind". -* -* ## Notes -* -* - If provided an unrecognized array data type, the function returns `null`. -* -* @param dtype - array data type -* @returns list of array data types -* -* @example -* var list = sameKindCasts( 'float' ); -* // returns null -*/ -declare function sameKindCasts( dtype: string ): null; - -/** -* Returns a list of array data types to which a provided array data type can be safely cast or cast within the same "kind". -* -* ## Notes -* -* - If not provided an array data type, the function returns a casting table. -* - If provided an unrecognized array data type, the function returns `null`. -* -* @param dtype - array data type -* @returns a table, a list of array data types, or null -* -* @example -* var table = sameKindCasts(); -* // returns {...} -* -* @example -* var list = sameKindCasts( 'float32' ); -* // returns [...] -* -* @example -* var list = sameKindCasts( 'float' ); -* // returns null -*/ -declare function sameKindCasts( dtype?: string ): Table; - - -// EXPORTS // - -export = sameKindCasts; diff --git a/same-kind-casts/docs/types/test.ts b/same-kind-casts/docs/types/test.ts deleted file mode 100644 index 818664e74..000000000 --- a/same-kind-casts/docs/types/test.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 sameKindCasts = require( './index' ); - - -// TESTS // - -/// The function returns a casting table.. -{ - sameKindCasts(); // $ExpectType Table -} - -// The function returns a list of data types when provided a recognized data type... -{ - sameKindCasts( 'float32' ); // $ExpectType DataType[] -} - -// The function returns null when provided an unrecognized data type... -{ - sameKindCasts( 'float' ); // $ExpectType null -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - sameKindCasts( 123 ); // $ExpectError - sameKindCasts( true ); // $ExpectError - sameKindCasts( false ); // $ExpectError - sameKindCasts( {} ); // $ExpectError - sameKindCasts( [] ); // $ExpectError - sameKindCasts( null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - sameKindCasts( 'float32', 3 ); // $ExpectError -} diff --git a/same-kind-casts/examples/index.js b/same-kind-casts/examples/index.js deleted file mode 100644 index a25e9a11c..000000000 --- a/same-kind-casts/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../dtypes' ); -var sameKindCasts = require( './../lib' ); - -// Get the list of supported array data types: -var DTYPES = dtypes(); - -// Print the list of array data types to which a data type can be cast... -var list; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - list = sameKindCasts( DTYPES[ i ] ); - console.log( '%s: %s', DTYPES[ i ], list.join( ', ' ) ); -} diff --git a/same-kind-casts/lib/index.js b/same-kind-casts/lib/index.js deleted file mode 100644 index bf54745f3..000000000 --- a/same-kind-casts/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Return a list of array data types to which a provided array data type can be safely cast or cast within the same "kind". -* -* @module @stdlib/array/same-kind-casts -* -* @example -* var sameKindCasts = require( '@stdlib/array/same-kind-casts' ); -* -* var list = sameKindCasts( 'float32' ); -* // returns [...] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/same-kind-casts/lib/main.js b/same-kind-casts/lib/main.js deleted file mode 100644 index 32aeea512..000000000 --- a/same-kind-casts/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var objectKeys = require( '@stdlib/utils/keys' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var resolve = require( '@stdlib/strided/base/dtype-resolve-str' ); -var SAME_KIND_CASTS = require( './same_kind_casts.json' ); - - -// VARIABLES // - -var TABLE; - - -// FUNCTIONS // - -/** -* Generates a full table of same "kind" casts for each array data type. -* -* @private -* @returns {Object} table -*/ -function generateFullTable() { - var dtypes; - var ntypes; - var out; - var tmp; - var dt1; - var dt2; - var o; - var j; - var i; - - out = {}; - dtypes = objectKeys( SAME_KIND_CASTS ); - ntypes = dtypes.length; - for ( i = 0; i < ntypes; i++ ) { - dt1 = dtypes[ i ]; - o = SAME_KIND_CASTS[ dt1 ]; - tmp = {}; - for ( j = 0; j < ntypes; j++ ) { - dt2 = dtypes[ j ]; - tmp[ dt2 ] = o[ dt2 ]; - } - out[ dt1 ] = tmp; - } - return out; -} - -/** -* Generates a table of same "kind" casts for each array data type. -* -* @private -* @returns {Object} table -*/ -function generateTable() { - var dtypes; - var ntypes; - var out; - var tmp; - var dt1; - var dt2; - var o; - var j; - var i; - - out = {}; - dtypes = objectKeys( SAME_KIND_CASTS ); - ntypes = dtypes.length; - for ( i = 0; i < ntypes; i++ ) { - dt1 = dtypes[ i ]; - o = SAME_KIND_CASTS[ dt1 ]; - tmp = []; - for ( j = 0; j < ntypes; j++ ) { - dt2 = dtypes[ j ]; - if ( o[ dt2 ] === 1 ) { - tmp.push( dt2 ); - } - } - out[ dt1 ] = tmp; - } - return out; -} - - -// MAIN // - -/** -* Returns a list of array data types to which a provided array data type can be safely cast or cast within the same "kind". -* -* @param {*} [dtype] - array data type value -* @returns {(Object|StringArray|null)} list of array data types or null -* -* @example -* var list = sameKindCasts( 'float32' ); -* // returns [...] -*/ -function sameKindCasts( dtype ) { - if ( arguments.length === 0 ) { - return generateFullTable(); - } - if ( TABLE === void 0 ) { - // Lazily generate table... - TABLE = generateTable(); - } - dtype = resolve( dtype ); - if ( hasOwnProp( TABLE, dtype ) ) { - return TABLE[ dtype ].slice(); - } - return null; -} - - -// EXPORTS // - -module.exports = sameKindCasts; diff --git a/same-kind-casts/lib/same_kind_casts.json b/same-kind-casts/lib/same_kind_casts.json deleted file mode 100644 index 0bb7bd16b..000000000 --- a/same-kind-casts/lib/same_kind_casts.json +++ /dev/null @@ -1,197 +0,0 @@ -{ - "float64": { - "float64": 1, - "float32": 1, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 0, - "bool": 0, - "generic": 1 - }, - "float32": { - "float64": 1, - "float32": 1, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "int32": { - "float64": 1, - "float32": 0, - "int32": 1, - "int16": 1, - "int8": 1, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 0, - "bool": 0, - "generic": 1 - }, - "int16": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 1, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "int8": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 1, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "uint32": { - "float64": 1, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 1, - "uint16": 1, - "uint8": 1, - "uint8c": 1, - "complex128": 1, - "complex64": 0, - "bool": 0, - "generic": 1 - }, - "uint16": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 0, - "int8": 0, - "uint32": 1, - "uint16": 1, - "uint8": 1, - "uint8c": 1, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "uint8": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 0, - "uint32": 1, - "uint16": 1, - "uint8": 1, - "uint8c": 1, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "uint8c": { - "float64": 1, - "float32": 1, - "int32": 1, - "int16": 1, - "int8": 0, - "uint32": 1, - "uint16": 1, - "uint8": 1, - "uint8c": 1, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 1 - }, - "complex128": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 0 - }, - "complex64": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 1, - "complex64": 1, - "bool": 0, - "generic": 0 - }, - "bool": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 0, - "complex64": 0, - "bool": 1, - "generic": 1 - }, - "generic": { - "float64": 0, - "float32": 0, - "int32": 0, - "int16": 0, - "int8": 0, - "uint32": 0, - "uint16": 0, - "uint8": 0, - "uint8c": 0, - "complex128": 0, - "complex64": 0, - "bool": 0, - "generic": 1 - } -} diff --git a/same-kind-casts/package.json b/same-kind-casts/package.json deleted file mode 100644 index 571738c90..000000000 --- a/same-kind-casts/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/same-kind-casts", - "version": "0.0.0", - "description": "Return a list of array data types to which a provided array data type can be safely cast or cast within the same kind.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "casting", - "cast", - "rules", - "promotion", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/same-kind-casts/test/test.js b/same-kind-casts/test/test.js deleted file mode 100644 index 513cc7f03..000000000 --- a/same-kind-casts/test/test.js +++ /dev/null @@ -1,76 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../dtypes' ); -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var sameKindCasts = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sameKindCasts, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if not provided a data type, the function returns a table', function test( t ) { - var out = sameKindCasts(); - t.strictEqual( typeof out, 'object', 'returns an object' ); - t.strictEqual( out[ 'float32' ][ 'float64' ], 1, 'returns expected value' ); - t.strictEqual( out[ 'float32' ][ 'int8' ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a list of array data types to which a provided array data type can be safely cast or cast within the same "kind"', function test( t ) { - var list; - var i; - for ( i = 0; i < DTYPES.length; i++ ) { - list = sameKindCasts( DTYPES[ i ] ); - t.strictEqual( isStringArray( list ), true, 'returns an array of strings when provided '+DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unrecognized or unsupported data type, the function returns `null`', function test( t ) { - var values; - var i; - - values = [ - 'beep', - 'boop', - 'foo', - 'bar', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( sameKindCasts( values[ i ] ), null, 'returns expected value when provided '+values[ i ] ); - } - t.end(); -}); diff --git a/shape/README.md b/shape/README.md deleted file mode 100644 index cab1913e6..000000000 --- a/shape/README.md +++ /dev/null @@ -1,226 +0,0 @@ - - -# Array Shape - -> Determine (nested) array dimensions. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var arrayShape = require( '@stdlib/array/shape' ); -``` - -#### arrayShape( arr ) - -Returns array dimensions. - -```javascript -var arr = [ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8, 9 ] -]; - -var shape = arrayShape( arr ); -// returns [ 3, 3 ] -``` - -The function **ignores** inconsistent dimensions. - -```javascript -var arr = [ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8 ] -]; - -var shape = arrayShape( arr ); -// returns [ 3 ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var arrayShape = require( '@stdlib/array/shape' ); - -var arr = [ 1, 2, 3 ]; -var shape = arrayShape( arr ); -// returns [ 3 ] - -arr = [ - [ 1 ], - [ 2 ], - [ 3 ] -]; -shape = arrayShape( arr ); -// returns [ 3, 1 ] - -arr = [ - [], - [], - [] -]; -shape = arrayShape( arr ); -// returns [ 3, 0 ] - -arr = [ - [ 1, 2, 3 ] -]; -shape = arrayShape( arr ); -// returns [ 1, 3 ] - -arr = [ - [ [ 1 ] ], - [ [ 2 ] ], - [ [ 3 ] ] -]; -shape = arrayShape( arr ); -// returns [ 3, 1, 1 ] - -arr = [ [ [ [ 1, 2, 3 ] ] ] ]; -shape = arrayShape( arr ); -// returns [ 1, 1, 1, 3 ] - -arr = [ - [ 1, 2 ], - [ 3, 4 ] -]; -shape = arrayShape( arr ); -// returns [ 2, 2 ] - -arr = [ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8, 9 ] -]; -shape = arrayShape( arr ); -// returns [ 3, 3 ] - -arr = [ - [ 1, 2, 3 ], - null, - [ 7, 8, 9 ] -]; -shape = arrayShape( arr ); -// returns [ 3 ] - -arr = [ - [ 1, 2, 3 ], - [ [ 4, 5, 6 ] ], - [ [ 7, 8, 9 ] ] -]; -shape = arrayShape( arr ); -// returns [ 3 ] - -arr = [ - [ [ 1, 2, 3 ] ], - [ 4, 5, 6 ], - [ [ 7, 8, 9 ] ] -]; -shape = arrayShape( arr ); -// returns [ 3 ] - -arr = [ - [ [ 1, 2, 3 ] ], - [ [ 4, 5, 6 ] ], - [ 7, 8, 9 ] -]; -shape = arrayShape( arr ); -// returns [ 3 ] - -arr = [ - [ [ [ 1, 2, 3 ] ] ], - [ [ 4, 5, 6 ] ], - [ [ [ 7, 8, 9 ] ] ] -]; -shape = arrayShape( arr ); -// returns [ 3, 1 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/shape/benchmark/benchmark.js b/shape/benchmark/benchmark.js deleted file mode 100644 index 8893b00a6..000000000 --- a/shape/benchmark/benchmark.js +++ /dev/null @@ -1,220 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var arrayShape = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::1d', function benchmark( b ) { - var arr; - var out; - var i; - - // 3 - arr = [ 1, 2, 3 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arrayShape( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArray( out ) || out.length !== 1 ) { - b.fail( 'should return an array of length 1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d', function benchmark( b ) { - var arr; - var out; - var i; - - // 3x3 - arr = [ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8, 9 ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arrayShape( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArray( out ) || out.length !== 2 ) { - b.fail( 'should return an array of length 2' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d', function benchmark( b ) { - var arr; - var out; - var i; - - // 3x3x3 - arr = [ - [ [ 1, 1, 1 ], [ 2, 2, 2 ], [ 3, 3, 3 ] ], - [ [ 4, 4, 4 ], [ 5, 5, 5 ], [ 6, 6, 6 ] ], - [ [ 7, 7, 7 ], [ 8, 8, 8 ], [ 9, 9, 9 ] ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arrayShape( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArray( out ) || out.length !== 3 ) { - b.fail( 'should return an array of length 3' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d', function benchmark( b ) { - var arr; - var out; - var i; - - // 3x3x3x3 - arr = [ - [ - [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ], - [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ], - [ [ 3, 3, 3 ], [ 3, 3, 3 ], [ 3, 3, 3 ] ] - ], - [ - [ [ 4, 4, 4 ], [ 4, 4, 4 ], [ 4, 4, 4 ] ], - [ [ 5, 5, 5 ], [ 5, 5, 5 ], [ 5, 5, 5 ] ], - [ [ 6, 6, 6 ], [ 6, 6, 6 ], [ 6, 6, 6 ] ] - ], - [ - [ [ 7, 7, 7 ], [ 7, 7, 7 ], [ 7, 7, 7 ] ], - [ [ 8, 8, 8 ], [ 8, 8, 8 ], [ 8, 8, 8 ] ], - [ [ 9, 9, 9 ], [ 9, 9, 9 ], [ 9, 9, 9 ] ] - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arrayShape( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArray( out ) || out.length !== 4 ) { - b.fail( 'should return an array of length 4' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d', function benchmark( b ) { - var arr; - var out; - var i; - - // 3x3x3x3x3 - arr = [ - [ - [ - [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ], - [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ], - [ [ 3, 3, 3 ], [ 3, 3, 3 ], [ 3, 3, 3 ] ] - ], - [ - [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ], - [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ], - [ [ 3, 3, 3 ], [ 3, 3, 3 ], [ 3, 3, 3 ] ] - ], - [ - [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ], - [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ], - [ [ 3, 3, 3 ], [ 3, 3, 3 ], [ 3, 3, 3 ] ] - ] - ], - [ - [ - [ [ 4, 4, 4 ], [ 4, 4, 4 ], [ 4, 4, 4 ] ], - [ [ 5, 5, 5 ], [ 5, 5, 5 ], [ 5, 5, 5 ] ], - [ [ 6, 6, 6 ], [ 6, 6, 6 ], [ 6, 6, 6 ] ] - ], - [ - [ [ 4, 4, 4 ], [ 4, 4, 4 ], [ 4, 4, 4 ] ], - [ [ 5, 5, 5 ], [ 5, 5, 5 ], [ 5, 5, 5 ] ], - [ [ 6, 6, 6 ], [ 6, 6, 6 ], [ 6, 6, 6 ] ] - ], - [ - [ [ 4, 4, 4 ], [ 4, 4, 4 ], [ 4, 4, 4 ] ], - [ [ 5, 5, 5 ], [ 5, 5, 5 ], [ 5, 5, 5 ] ], - [ [ 6, 6, 6 ], [ 6, 6, 6 ], [ 6, 6, 6 ] ] - ] - ], - [ - [ - [ [ 7, 7, 7 ], [ 7, 7, 7 ], [ 7, 7, 7 ] ], - [ [ 8, 8, 8 ], [ 8, 8, 8 ], [ 8, 8, 8 ] ], - [ [ 9, 9, 9 ], [ 9, 9, 9 ], [ 9, 9, 9 ] ] - ], - [ - [ [ 7, 7, 7 ], [ 7, 7, 7 ], [ 7, 7, 7 ] ], - [ [ 8, 8, 8 ], [ 8, 8, 8 ], [ 8, 8, 8 ] ], - [ [ 9, 9, 9 ], [ 9, 9, 9 ], [ 9, 9, 9 ] ] - ], - [ - [ [ 7, 7, 7 ], [ 7, 7, 7 ], [ 7, 7, 7 ] ], - [ [ 8, 8, 8 ], [ 8, 8, 8 ], [ 8, 8, 8 ] ], - [ [ 9, 9, 9 ], [ 9, 9, 9 ], [ 9, 9, 9 ] ] - ] - ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arrayShape( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArray( out ) || out.length !== 5 ) { - b.fail( 'should return an array of length 5' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/shape/docs/repl.txt b/shape/docs/repl.txt deleted file mode 100644 index 4f446cca4..000000000 --- a/shape/docs/repl.txt +++ /dev/null @@ -1,22 +0,0 @@ - -{{alias}}( arr ) - Determines array dimensions. - - Parameters - ---------- - arr: ArrayLikeObject - Input array. - - Returns - ------- - out: Array - Array shape. - - Examples - -------- - > var out = {{alias}}( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ) - [ 2, 3 ] - - See Also - -------- - diff --git a/shape/docs/types/index.d.ts b/shape/docs/types/index.d.ts deleted file mode 100644 index d800b46c4..000000000 --- a/shape/docs/types/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ArrayLike } from '@stdlib/types/array'; - -/** -* Determines (nested) array dimensions. -* -* @param arr - array -* @returns array shape -* -* @example -* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; -* -* var shape = arrayShape( arr ); -* // returns [ 3, 3 ] -* -* @example -* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ]; -* -* var shape = arrayShape( arr ); -* // returns [ 3 ] -* -* @example -* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], null ]; -* -* var shape = arrayShape( arr ); -* // returns [ 3 ] -*/ -declare function arrayShape( arr: ArrayLike ): Array; - - -// EXPORTS // - -export = arrayShape; diff --git a/shape/docs/types/test.ts b/shape/docs/types/test.ts deleted file mode 100644 index 811b8aa64..000000000 --- a/shape/docs/types/test.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arrayShape = require( './index' ); - - -// TESTS // - -// The function returns an array of numbers.. -{ - arrayShape( [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] ); // $ExpectType number[] -} - -// The compiler throws an error if not provided an array-like object... -{ - arrayShape( 5 ); // $ExpectError - arrayShape( false ); // $ExpectError - arrayShape( true ); // $ExpectError - arrayShape( null ); // $ExpectError - arrayShape( undefined ); // $ExpectError - arrayShape( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - arrayShape(); // $ExpectError - arrayShape( [ 1, 2, 3 ], 3 ); // $ExpectError -} diff --git a/shape/examples/index.js b/shape/examples/index.js deleted file mode 100644 index 73bf8fd1e..000000000 --- a/shape/examples/index.js +++ /dev/null @@ -1,127 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 arrayShape = require( './../lib' ); - -var arr = [ 1, 2, 3 ]; -var shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '3' - -arr = [ - [ 1 ], - [ 2 ], - [ 3 ] -]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '3x1' - -arr = [ - [], - [], - [] -]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '3x0' - -arr = [ - [ 1, 2, 3 ] -]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '1x3' - -arr = [ - [ [ 1 ] ], - [ [ 2 ] ], - [ [ 3 ] ] -]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '3x1x1' - -arr = [ [ [ [ 1, 2, 3 ] ] ] ]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '1x1x1x3' - -arr = [ - [ 1, 2 ], - [ 3, 4 ] -]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '2x2' - -arr = [ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8, 9 ] -]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '3x3' - -arr = [ - [ 1, 2, 3 ], - null, - [ 7, 8, 9 ] -]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '3' - -arr = [ - [ 1, 2, 3 ], - [ [ 4, 5, 6 ] ], - [ [ 7, 8, 9 ] ] -]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '3' - -arr = [ - [ [ 1, 2, 3 ] ], - [ 4, 5, 6 ], - [ [ 7, 8, 9 ] ] -]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '3' - -arr = [ - [ [ 1, 2, 3 ] ], - [ [ 4, 5, 6 ] ], - [ 7, 8, 9 ] -]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '3' - -arr = [ - [ [ [ 1, 2, 3 ] ] ], - [ [ 4, 5, 6 ] ], - [ [ [ 7, 8, 9 ] ] ] -]; -shape = arrayShape( arr ); -console.log( shape.join( 'x' ) ); -// => '3x1' diff --git a/shape/lib/index.js b/shape/lib/index.js deleted file mode 100644 index dd4466e93..000000000 --- a/shape/lib/index.js +++ /dev/null @@ -1,58 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Determine (nested) array dimensions. -* -* @module @stdlib/array/shape -* -* @example -* var arrayShape = require( '@stdlib/array/shape' ); -* -* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; -* -* var shape = arrayShape( arr ); -* // returns [ 3, 3 ] -* -* @example -* var arrayShape = require( '@stdlib/array/shape' ); -* -* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ]; -* -* var shape = arrayShape( arr ); -* // returns [ 3 ] -* -* @example -* var arrayShape = require( '@stdlib/array/shape' ); -* -* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], null ]; -* -* var shape = arrayShape( arr ); -* // returns [ 3 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/shape/lib/main.js b/shape/lib/main.js deleted file mode 100644 index 334df729b..000000000 --- a/shape/lib/main.js +++ /dev/null @@ -1,139 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isArrayLikeObject = require( '@stdlib/assert/is-array-like-object' ); -var format = require( '@stdlib/string/format' ); - - -// FUNCTIONS // - -/** -* Recursively (and eagerly) attempts to resolve nested array dimensions. -* -* @private -* @param {Array} shape - output array -* @param {ArrayLikeObject} arr - array -* @returns {Array} shape array -*/ -function recurse( shape, arr ) { - var v = arr[ 0 ]; - if ( isArrayLikeObject( v ) ) { - shape.push( v.length ); - recurse( shape, v ); - } - return shape; -} - -/** -* Recursively verifies that all nested arrays have consistent dimensions. -* -* @private -* @param {PositiveInteger} ndims - number of dimensions -* @param {Array} shape - shape array -* @param {NonNegativeInteger} d - dimension -* @param {ArrayLikeObject} arr - array element to verify -* @param {boolean} flg - boolean indicating whether to continue recursing -* @returns {NonNegativeInteger} number of consistent dimensions -*/ -function check( ndims, shape, d, arr, flg ) { - var len; - var v; - var i; - - // Get the size of the current dimension: - len = shape[ d ]; - - // Ensure that each array element is an array of the same size: - for ( i = 0; i < arr.length; i++ ) { - v = arr[ i ]; - - // If the array element is not an array or is not the same size, we have found an inconsistent dimension: - if ( !isArrayLikeObject( v ) || v.length !== len ) { - // `d` is one more than the index of the last consistent dimension and thus equal to the number of consistent dimensions: - return d; - } - // Recursively examine nested elements: - if ( flg ) { - v = check( ndims, shape, d+1, v, d+1 < ndims-1 ); - if ( v < ndims ) { - // Propagate the number of consistent dimensions up the recursion chain... - return v; - } - } - } - return ndims; -} - - -// MAIN // - -/** -* Determines (nested) array dimensions. -* -* @param {ArrayLikeObject} arr - array -* @throws {TypeError} must provide an array -* @returns {Array} array shape -* -* @example -* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; -* -* var shape = arrayShape( arr ); -* // returns [ 3, 3 ] -* -* @example -* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8 ] ]; -* -* var shape = arrayShape( arr ); -* // returns [ 3 ] -* -* @example -* var arr = [ [ 1, 2, 3 ], [ 4, 5, 6 ], null ]; -* -* var shape = arrayShape( arr ); -* // returns [ 3 ] -*/ -function arrayShape( arr ) { - var shape; - var ndims; - - if ( !isArrayLikeObject( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an array-like object. Value: `%s`.', arr ) ); - } - // Initialize the shape/dimensions array: - shape = [ arr.length ]; - - // Eagerly determine array dimensions: - recurse( shape, arr ); - ndims = shape.length; - - // Check that all array element dimensions are consistent: - if ( ndims > 1 ) { - // If `check()` returns a value less than `ndims`, trim off the inconsistent dimensions: - shape.length = check( ndims, shape, 1, arr, ndims > 2 ); - } - return shape; -} - - -// EXPORTS // - -module.exports = arrayShape; diff --git a/shape/package.json b/shape/package.json deleted file mode 100644 index bc213367c..000000000 --- a/shape/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/shape", - "version": "0.0.0", - "description": "Determine (nested) array dimensions.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "array", - "dims", - "dimensions", - "shape" - ] -} diff --git a/shape/test/test.js b/shape/test/test.js deleted file mode 100644 index 9b63a6192..000000000 --- a/shape/test/test.js +++ /dev/null @@ -1,378 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../float64' ); -var arrayShape = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arrayShape, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayShape( value ); - }; - } -}); - -tape( 'the function returns array dimensions (0d)', function test( t ) { - var arr; - - arr = []; - t.deepEqual( arrayShape( arr ), [ 0 ], 'returns expected value' ); - - arr = [ [] ]; - t.deepEqual( arrayShape( arr ), [ 1, 0 ], 'returns expected value' ); - - arr = [ [ [] ] ]; - t.deepEqual( arrayShape( arr ), [ 1, 1, 0 ], 'returns expected value' ); - - arr = [ [], [] ]; - t.deepEqual( arrayShape( arr ), [ 2, 0 ], 'returns expected value' ); - - arr = [ [ [] ], [ [] ] ]; - t.deepEqual( arrayShape( arr ), [ 2, 1, 0 ], 'returns expected value' ); - - arr = [ [], [], [] ]; - t.deepEqual( arrayShape( arr ), [ 3, 0 ], 'returns expected value' ); - - arr = [ [ [ [] ] ], [ [ [] ] ], [ [ [] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1, 0 ], 'returns expected value' ); - - arr = [ [ [ [ [] ] ] ], [ [ [ [] ] ] ], [ [ [ [] ] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1, 1, 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns array dimensions (0d; array-like objects)', function test( t ) { - var arr; - var x; - - arr = new Float64Array( [] ); - t.deepEqual( arrayShape( arr ), [ 0 ], 'returns expected value' ); - - x = new Float64Array( [] ); - arr = [ x ]; - t.deepEqual( arrayShape( arr ), [ 1, 0 ], 'returns expected value' ); - - arr = [ [ x ] ]; - t.deepEqual( arrayShape( arr ), [ 1, 1, 0 ], 'returns expected value' ); - - arr = [ x, x ]; - t.deepEqual( arrayShape( arr ), [ 2, 0 ], 'returns expected value' ); - - arr = [ [ x ], [ x ] ]; - t.deepEqual( arrayShape( arr ), [ 2, 1, 0 ], 'returns expected value' ); - - arr = [ x, x, x ]; - t.deepEqual( arrayShape( arr ), [ 3, 0 ], 'returns expected value' ); - - arr = [ [ [ x ] ], [ [ x ] ], [ [ x ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1, 0 ], 'returns expected value' ); - - arr = [ [ [ [ x ] ] ], [ [ [ x ] ] ], [ [ [ x ] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1, 1, 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns array dimensions (1d)', function test( t ) { - var arr; - - arr = [ 1 ]; - t.deepEqual( arrayShape( arr ), [ 1 ], 'returns expected value' ); - - arr = [ 'beep' ]; - t.deepEqual( arrayShape( arr ), [ 1 ], 'returns expected value' ); - - arr = [ 1, 2 ]; - t.deepEqual( arrayShape( arr ), [ 2 ], 'returns expected value' ); - - arr = [ 1, 2, 3 ]; - t.deepEqual( arrayShape( arr ), [ 3 ], 'returns expected value' ); - - arr = [ [ 1 ], [ 2 ], 3 ]; - t.deepEqual( arrayShape( arr ), [ 3 ], 'returns expected value' ); - - arr = [ [ 1 ], [ 2 ], null ]; - t.deepEqual( arrayShape( arr ), [ 3 ], 'returns expected value' ); - - arr = [ [ [ 1 ] ], [ [ 2 ] ], null ]; - t.deepEqual( arrayShape( arr ), [ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns array dimensions (1d; array-like object)', function test( t ) { - var arr; - - arr = new Float64Array( [ 1 ] ); - t.deepEqual( arrayShape( arr ), [ 1 ], 'returns expected value' ); - - arr = new Float64Array( [ 'beep' ] ); - t.deepEqual( arrayShape( arr ), [ 1 ], 'returns expected value' ); - - arr = new Float64Array( [ 1, 2 ] ); - t.deepEqual( arrayShape( arr ), [ 2 ], 'returns expected value' ); - - arr = new Float64Array( [ 1, 2, 3 ] ); - t.deepEqual( arrayShape( arr ), [ 3 ], 'returns expected value' ); - - arr = [ new Float64Array( [ 1 ] ), [ 2 ], 3 ]; - t.deepEqual( arrayShape( arr ), [ 3 ], 'returns expected value' ); - - arr = [ new Float64Array( [ 1 ] ), [ 2 ], null ]; - t.deepEqual( arrayShape( arr ), [ 3 ], 'returns expected value' ); - - arr = [ [ [ 1 ] ], [ new Float64Array( [ 2 ] ) ], null ]; - t.deepEqual( arrayShape( arr ), [ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns array dimensions (2d)', function test( t ) { - var arr; - - arr = [ [ 1 ] ]; - t.deepEqual( arrayShape( arr ), [ 1, 1 ], 'returns expected value' ); - - arr = [ [ 1 ], [ 2 ] ]; - t.deepEqual( arrayShape( arr ), [ 2, 1 ], 'returns expected value' ); - - arr = [ [ 1 ], [ 2 ], [ 3 ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1 ], 'returns expected value' ); - - arr = [ [ [ 1 ] ], [ [ 2 ] ], [ 3 ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1 ], 'returns expected value' ); - - arr = [ [ [ 1 ] ], [ [ 2 ] ], [ null ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1 ], 'returns expected value' ); - - arr = [ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8, 9 ] - ]; - t.deepEqual( arrayShape( arr ), [ 3, 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns array dimensions (2d; array-like objects)', function test( t ) { - var arr; - - arr = [ new Float64Array( [ 1 ] ) ]; - t.deepEqual( arrayShape( arr ), [ 1, 1 ], 'returns expected value' ); - - arr = [ new Float64Array( [ 1 ] ), [ 2 ] ]; - t.deepEqual( arrayShape( arr ), [ 2, 1 ], 'returns expected value' ); - - arr = [ [ 1 ], new Float64Array( [ 2 ] ), [ 3 ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1 ], 'returns expected value' ); - - arr = [ [ [ 1 ] ], [ new Float64Array( [ 2 ] ) ], [ 3 ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1 ], 'returns expected value' ); - - arr = [ [ new Float64Array( [ 1 ] ) ], [ [ 2 ] ], [ null ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1 ], 'returns expected value' ); - - arr = [ - new Float64Array( [ 1, 2, 3 ] ), - new Float64Array( [ 4, 5, 6 ] ), - new Float64Array( [ 7, 8, 9 ] ) - ]; - t.deepEqual( arrayShape( arr ), [ 3, 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns array dimensions (3d)', function test( t ) { - var arr; - - arr = [ [ [ 1 ] ] ]; - t.deepEqual( arrayShape( arr ), [ 1, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ 1 ] ], [ [ 2 ] ] ]; - t.deepEqual( arrayShape( arr ), [ 2, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ 1 ] ], [ [ 2 ] ], [ [ 3 ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ [ 1 ] ] ], [ [ [ 2 ] ] ], [ [ 3 ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ [ 1 ] ] ], [ [ [ 2 ] ] ], [ [ null ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1 ], 'returns expected value' ); - - arr = [ - [ [ 1, 1, 1 ], [ 2, 2, 2 ], [ 3, 3, 3 ] ], - [ [ 4, 4, 4 ], [ 5, 5, 5 ], [ 6, 6, 6 ] ], - [ [ 7, 7, 7 ], [ 8, 8, 8 ], [ 9, 9, 9 ] ] - ]; - t.deepEqual( arrayShape( arr ), [ 3, 3, 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns array dimensions (4d)', function test( t ) { - var arr; - - arr = [ [ [ [ 1 ] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 1, 1, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ [ 1 ] ] ], [ [ [ 2 ] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 2, 1, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ [ 1 ] ] ], [ [ [ 2 ] ] ], [ [ [ 3 ] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ [ [ 1 ] ] ] ], [ [ [ [ 2 ] ] ] ], [ [ [ 3 ] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ [ [ 1 ] ] ] ], [ [ [ [ 2 ] ] ] ], [ [ [ null ] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1, 1 ], 'returns expected value' ); - - arr = [ - [ - [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ], - [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ], - [ [ 3, 3, 3 ], [ 3, 3, 3 ], [ 3, 3, 3 ] ] - ], - [ - [ [ 4, 4, 4 ], [ 4, 4, 4 ], [ 4, 4, 4 ] ], - [ [ 5, 5, 5 ], [ 5, 5, 5 ], [ 5, 5, 5 ] ], - [ [ 6, 6, 6 ], [ 6, 6, 6 ], [ 6, 6, 6 ] ] - ], - [ - [ [ 7, 7, 7 ], [ 7, 7, 7 ], [ 7, 7, 7 ] ], - [ [ 8, 8, 8 ], [ 8, 8, 8 ], [ 8, 8, 8 ] ], - [ [ 9, 9, 9 ], [ 9, 9, 9 ], [ 9, 9, 9 ] ] - ] - ]; - t.deepEqual( arrayShape( arr ), [ 3, 3, 3, 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns array dimensions (5d)', function test( t ) { - var arr; - - arr = [ [ [ [ [ 1 ] ] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 1, 1, 1, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ [ [ 1 ] ] ] ], [ [ [ [ 2 ] ] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 2, 1, 1, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ [ [ 1 ] ] ] ], [ [ [ [ 2 ] ] ] ], [ [ [ [ 3 ] ] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ [ [ [ 1 ] ] ] ] ], [ [ [ [ [ 2 ] ] ] ] ], [ [ [ [ 3 ] ] ] ] ]; - t.deepEqual( arrayShape( arr ), [ 3, 1, 1, 1, 1 ], 'returns expected value' ); - - arr = [ [ [ [ [ [ 1 ] ] ] ] ], [ [ [ [ [ 2 ] ] ] ] ], [ [ [ [ null ] ] ] ] ]; // eslint-disable-line max-len - t.deepEqual( arrayShape( arr ), [ 3, 1, 1, 1, 1 ], 'returns expected value' ); - - arr = [ - [ - [ - [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ], - [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ], - [ [ 3, 3, 3 ], [ 3, 3, 3 ], [ 3, 3, 3 ] ] - ], - [ - [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ], - [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ], - [ [ 3, 3, 3 ], [ 3, 3, 3 ], [ 3, 3, 3 ] ] - ], - [ - [ [ 1, 1, 1 ], [ 1, 1, 1 ], [ 1, 1, 1 ] ], - [ [ 2, 2, 2 ], [ 2, 2, 2 ], [ 2, 2, 2 ] ], - [ [ 3, 3, 3 ], [ 3, 3, 3 ], [ 3, 3, 3 ] ] - ] - ], - [ - [ - [ [ 4, 4, 4 ], [ 4, 4, 4 ], [ 4, 4, 4 ] ], - [ [ 5, 5, 5 ], [ 5, 5, 5 ], [ 5, 5, 5 ] ], - [ [ 6, 6, 6 ], [ 6, 6, 6 ], [ 6, 6, 6 ] ] - ], - [ - [ [ 4, 4, 4 ], [ 4, 4, 4 ], [ 4, 4, 4 ] ], - [ [ 5, 5, 5 ], [ 5, 5, 5 ], [ 5, 5, 5 ] ], - [ [ 6, 6, 6 ], [ 6, 6, 6 ], [ 6, 6, 6 ] ] - ], - [ - [ [ 4, 4, 4 ], [ 4, 4, 4 ], [ 4, 4, 4 ] ], - [ [ 5, 5, 5 ], [ 5, 5, 5 ], [ 5, 5, 5 ] ], - [ [ 6, 6, 6 ], [ 6, 6, 6 ], [ 6, 6, 6 ] ] - ] - ], - [ - [ - [ [ 7, 7, 7 ], [ 7, 7, 7 ], [ 7, 7, 7 ] ], - [ [ 8, 8, 8 ], [ 8, 8, 8 ], [ 8, 8, 8 ] ], - [ [ 9, 9, 9 ], [ 9, 9, 9 ], [ 9, 9, 9 ] ] - ], - [ - [ [ 7, 7, 7 ], [ 7, 7, 7 ], [ 7, 7, 7 ] ], - [ [ 8, 8, 8 ], [ 8, 8, 8 ], [ 8, 8, 8 ] ], - [ [ 9, 9, 9 ], [ 9, 9, 9 ], [ 9, 9, 9 ] ] - ], - [ - [ [ 7, 7, 7 ], [ 7, 7, 7 ], [ 7, 7, 7 ] ], - [ [ 8, 8, 8 ], [ 8, 8, 8 ], [ 8, 8, 8 ] ], - [ [ 9, 9, 9 ], [ 9, 9, 9 ], [ 9, 9, 9 ] ] - ] - ] - ]; - t.deepEqual( arrayShape( arr ), [ 3, 3, 3, 3, 3 ], 'returns expected value' ); - - t.end(); -}); diff --git a/shared-buffer/README.md b/shared-buffer/README.md deleted file mode 100644 index f832f2db8..000000000 --- a/shared-buffer/README.md +++ /dev/null @@ -1,311 +0,0 @@ - - -# SharedArrayBuffer - -> [Constructor][mdn-sharedarraybuffer] returning an object used to represent a generic, fixed-length raw binary data buffer which can be used to create views of shared memory. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var SharedArrayBuffer = require( '@stdlib/array/shared-buffer' ); -``` - -#### SharedArrayBuffer( size ) - -Returns a [`SharedArrayBuffer`][mdn-sharedarraybuffer] having a specified number of bytes. - - - -```javascript -try { - var buf = new SharedArrayBuffer( 5 ); - // returns -} catch ( err ) { - console.log( 'Environment does not support SharedArrayBuffers.' ); -} -``` - -* * * - -### Properties - -#### SharedArrayBuffer.length - -Number of input arguments the constructor accepts. - - - -```javascript -var len = SharedArrayBuffer.length; -// returns 1 -``` - -#### SharedArrayBuffer.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [`SharedArrayBuffer`][mdn-sharedarraybuffer]. - - - -```javascript -try { - var buf = new SharedArrayBuffer( 5 ); - var byteLength = buf.byteLength; - // returns 5 -} catch ( err ) { - console.log( 'Environment does not support SharedArrayBuffers.' ); -} -``` - -* * * - -### Methods - -#### SharedArrayBuffer.prototype.slice( \[start\[, end]] ) - -Copies the bytes of a [`SharedArrayBuffer`][mdn-sharedarraybuffer] to a new [`SharedArrayBuffer`][mdn-sharedarraybuffer]. - - - -```javascript -try { - var b1 = new SharedArrayBuffer( 10 ); - - var b2 = b1.slice(); - // returns - - var bool = ( b2 === b1 ); - // returns false -} catch ( err ) { - console.log( 'Environment does not support SharedArrayBuffers.' ); -} -``` - -By default, the method copies from the beginning of the [`SharedArrayBuffer`][mdn-sharedarraybuffer]. To begin copying from a different byte index, provide a `start` argument, specifying the starting byte index (inclusive). - - - -```javascript -try { - var b1 = new SharedArrayBuffer( 10 ); - var b2 = b1.slice( 2 ); - - var nbytes = b2.byteLength; - // returns 8 -} catch ( err ) { - console.log( 'Environment does not support SharedArrayBuffers.' ); -} -``` - -If `start < 0`, the index is relative to the end of the [`SharedArrayBuffer`][mdn-sharedarraybuffer]. - - - -```javascript -try { - var b1 = new SharedArrayBuffer( 10 ); - var b2 = b1.slice( -2 ); - - var nbytes = b2.byteLength; - // returns 2 -} catch ( err ) { - console.log( 'Environment does not support SharedArrayBuffers.' ); -} -``` - -By default, the method copies to the end of the [`SharedArrayBuffer`][mdn-sharedarraybuffer]. To copy until a particular byte index, provide an `end` index, specifying the ending byte index (exclusive). - - - -```javascript -try { - var b1 = new SharedArrayBuffer( 10 ); - var b2 = b1.slice( 2, 6 ); - - var nbytes = b2.byteLength; - // returns 4 -} catch ( err ) { - console.log( 'Environment does not support SharedArrayBuffers.' ); -} -``` - -If `end < 0`, the index is relative to the end of the [`SharedArrayBuffer`][mdn-sharedarraybuffer]. - - - -```javascript -try { - var b1 = new SharedArrayBuffer( 10 ); - var b2 = b1.slice( 2, -2 ); - - var nbytes = b2.byteLength; - // returns 6 -} catch ( err ) { - console.log( 'Environment does not support SharedArrayBuffers.' ); -} -``` - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - - - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var Float64Array = require( '@stdlib/array/float64' ); -var Uint8Array = require( '@stdlib/array/uint8' ); -var toBinaryString = require( '@stdlib/number/uint8/base/to-binary-string' ); -var SharedArrayBuffer = require( '@stdlib/array/shared-buffer' ); - -function main() { - var bytes; - var buf; - var arr; - var i; - - // Create a new SharedArrayBuffer: - buf = new SharedArrayBuffer( 64 ); - - // Create a Float64 array buffer view: - arr = new Float64Array( buf.byteLength/8 ); - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; - } - - // Create a "bytes" view of the array buffer: - bytes = new Uint8Array( arr.buffer ); - - // Print the bytes: - for ( i = 0; i < bytes.length; i++ ) { - console.log( 'byte %d: %s', i, toBinaryString( bytes[ i ] ) ); - } -} - -try { - main(); -} catch ( err ) { - console.error( 'Environment does not provide SharedArrayBuffer support.' ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/shared-buffer/benchmark/benchmark.js b/shared-buffer/benchmark/benchmark.js deleted file mode 100644 index 35788a63e..000000000 --- a/shared-buffer/benchmark/benchmark.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var hasSharedArrayBufferSupport = require( '@stdlib/assert/has-sharedarraybuffer-support' ); // eslint-disable-line id-length -var isSharedArrayBuffer = require( '@stdlib/assert/is-sharedarraybuffer' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasSharedArrayBufferSupport() -}; - - -// MAIN // - -bench( pkg, opts, function benchmark( b ) { - var buf; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf = new ctor( 0 ); - if ( buf.byteLength !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isSharedArrayBuffer( buf ) ) { - b.fail( 'should return a SharedArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/shared-buffer/benchmark/benchmark.length.js b/shared-buffer/benchmark/benchmark.length.js deleted file mode 100644 index 1a546a89d..000000000 --- a/shared-buffer/benchmark/benchmark.length.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasSharedArrayBufferSupport = require( '@stdlib/assert/has-sharedarraybuffer-support' ); // eslint-disable-line id-length -var pow = require( '@stdlib/math/base/special/pow' ); -var isSharedArrayBuffer = require( '@stdlib/assert/is-sharedarraybuffer' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasSharedArrayBufferSupport() -}; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var buf; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf = new ctor( len ); - if ( buf.byteLength !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isSharedArrayBuffer( buf ) ) { - b.fail( 'should return a SharedArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, opts, f ); - } -} - -main(); diff --git a/shared-buffer/docs/repl.txt b/shared-buffer/docs/repl.txt deleted file mode 100644 index 82eed3ed8..000000000 --- a/shared-buffer/docs/repl.txt +++ /dev/null @@ -1,82 +0,0 @@ - -{{alias}}( size ) - Returns a shared array buffer having a specified number of bytes. - - A shared array buffer behaves similarly to a non-shared array buffer, except - that a shared array buffer allows creating views of memory shared between - threads. - - Buffer contents are initialized to 0. - - If an environment does not support shared array buffers, the function throws - an error. - - Parameters - ---------- - size: integer - Number of bytes. - - Returns - ------- - out: SharedArrayBuffer - A shared array buffer. - - Examples - -------- - // Assuming an environment supports SharedArrayBuffers... - > var buf = new {{alias}}( 5 ) - - - -{{alias}}.length - Number of input arguments the constructor accepts. - - Examples - -------- - > {{alias}}.length - 1 - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the array buffer. - - Examples - -------- - // Assuming an environment supports SharedArrayBuffers... - > var buf = new {{alias}}( 5 ); - > buf.byteLength - 5 - - -{{alias}}.prototype.slice( [start[, end]] ) - Copies the bytes of a shared array buffer to a new shared array buffer. - - Parameters - ---------- - start: integer (optional) - Index at which to start copying buffer contents (inclusive). If - negative, the index is relative to the end of the buffer. - - end: integer (optional) - Index at which to stop copying buffer contents (exclusive). If negative, - the index is relative to the end of the buffer. - - Returns - ------- - out: SharedArrayBuffer - A new shared array buffer whose contents have been copied from the - calling shared array buffer. - - Examples - -------- - // Assuming an environment supports SharedArrayBuffers... - > var b1 = new {{alias}}( 10 ); - > var b2 = b1.slice( 2, 6 ); - > var bool = ( b1 === b2 ) - false - > b2.byteLength - 4 - - See Also - -------- - diff --git a/shared-buffer/docs/types/index.d.ts b/shared-buffer/docs/types/index.d.ts deleted file mode 100644 index f4956e48f..000000000 --- a/shared-buffer/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Constructor returning an object used to represent a generic, fixed-length raw binary data buffer which can be used to create views of shared memory. -*/ -export = SharedArrayBuffer; diff --git a/shared-buffer/docs/types/test.ts b/shared-buffer/docs/types/test.ts deleted file mode 100644 index ea8339e6b..000000000 --- a/shared-buffer/docs/types/test.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import SharedArrayBuffer = require( './index' ); - - -// TESTS // - -// The function returns a shared array buffer instance... -{ - new SharedArrayBuffer( 10 ); // $ExpectType any -} diff --git a/shared-buffer/examples/index.js b/shared-buffer/examples/index.js deleted file mode 100644 index 4e46fed9a..000000000 --- a/shared-buffer/examples/index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var randu = require( '@stdlib/random/base/randu' ); -var Float64Array = require( './../../float64' ); -var Uint8Array = require( './../../uint8' ); -var toBinaryString = require( '@stdlib/number/uint8/base/to-binary-string' ); -var SharedArrayBuffer = require( './../lib' ); - -function main() { - var bytes; - var buf; - var arr; - var i; - - // Create a new SharedArrayBuffer: - buf = new SharedArrayBuffer( 64 ); - - // Create a Float64 array buffer view: - arr = new Float64Array( buf.byteLength/8 ); - for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; - } - - // Create a "bytes" view of the array buffer: - bytes = new Uint8Array( arr.buffer ); - - // Print the bytes: - for ( i = 0; i < bytes.length; i++ ) { - console.log( 'byte %d: %s', i, toBinaryString( bytes[ i ] ) ); - } -} - -try { - main(); -} catch ( err ) { // eslint-disable-line no-unused-vars - console.error( 'Environment does not provide SharedArrayBuffer support.' ); -} diff --git a/shared-buffer/lib/index.js b/shared-buffer/lib/index.js deleted file mode 100644 index fa92d69e5..000000000 --- a/shared-buffer/lib/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'; - -/** -* Constructor returning an object used to represent a generic, fixed-length raw binary data buffer which can be used to create views of shared memory. -* -* @module @stdlib/array/shared-buffer -* -* @example -* var ctor = require( '@stdlib/array/shared-buffer' ); -* -* var buf; -* try { -* buf = new ctor( 10 ); -* // returns -* } catch ( err ) { -* console.log( 'Environment does not support SharedArrayBuffers.' ); -* } -*/ - -// MODULES // - -var hasSharedArrayBufferSupport = require( '@stdlib/assert/has-sharedarraybuffer-support' ); // eslint-disable-line id-length -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasSharedArrayBufferSupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/shared-buffer/lib/main.js b/shared-buffer/lib/main.js deleted file mode 100644 index fa86dd95a..000000000 --- a/shared-buffer/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof SharedArrayBuffer === 'function' ) ? SharedArrayBuffer : null; // eslint-disable-line stdlib/require-globals, no-undef - - -// EXPORTS // - -module.exports = ctor; diff --git a/shared-buffer/lib/polyfill.js b/shared-buffer/lib/polyfill.js deleted file mode 100644 index 0fb9518f0..000000000 --- a/shared-buffer/lib/polyfill.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Constructor returning an object used to represent a generic, fixed-length raw binary data buffer which can be used to create views of shared memory. -* -* @param {NonNegativeInteger} size - number of bytes -* @throws {Error} not implemented -*/ -function polyfill( size ) { // eslint-disable-line no-unused-vars - throw new Error( 'not supported. The current environment does not support SharedArrayBuffers, and, unfortunately, SharedArrayBuffers cannot be polyfilled. For shared memory applications, upgrade your runtime environment to one which supports SharedArrayBuffers.' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/shared-buffer/package.json b/shared-buffer/package.json deleted file mode 100644 index 17a31beda..000000000 --- a/shared-buffer/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/array/shared-buffer", - "version": "0.0.0", - "description": "SharedArrayBuffer.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "arraybuffer", - "shared", - "memory", - "concurrency", - "parallelism", - "threading", - "buffer", - "buf", - "binary" - ] -} diff --git a/shared-buffer/test/test.js b/shared-buffer/test/test.js deleted file mode 100644 index 2282b30d4..000000000 --- a/shared-buffer/test/test.js +++ /dev/null @@ -1,182 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasSharedArrayBufferSupport = require( '@stdlib/assert/has-sharedarraybuffer-support' ); // eslint-disable-line id-length -var isFunction = require( '@stdlib/assert/is-function' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var MAX_SAFE_INTEGER = require( '@stdlib/constants/float64/max-safe-integer' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var hasProp = require( '@stdlib/assert/has-property' ); -var polyfill = require( './../lib/polyfill.js' ); -var Ctor = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasSharedArrayBufferSupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `SharedArrayBuffer`, the export is an alias for `SharedArrayBuffer`', function test( t ) { - var Foo = proxyquire( './../lib', { - '@stdlib/assert/has-sharedarraybuffer-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns built-in' ); - - if ( !opts.skip ) { - t.strictEqual( Ctor, SharedArrayBuffer, 'is alias' ); // eslint-disable-line stdlib/require-globals, no-undef - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `SharedArrayBuffer`, the export is a polyfill', function test( t ) { - var Foo = proxyquire( './../lib', { - '@stdlib/assert/has-sharedarraybuffer-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); - -tape( 'the main export is a constructor', opts, function test( t ) { - var buf = new Ctor( 10 ); - t.strictEqual( instanceOf( buf, Ctor ), true, 'returns an instance' ); - t.end(); -}); - -tape( 'the constructor length is equal to `1`', opts, function test( t ) { - t.strictEqual( Ctor.length, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the constructor throws an error if provided a value exceeding `2^53-1`', opts, function test( t ) { - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - return new Ctor( MAX_SAFE_INTEGER+1 ); - } -}); - -tape( 'the constructor returns a `SharedArrayBuffer` instance having a `byteLength` property, which returns the number of bytes in a `SharedArrayBuffer`', opts, function test( t ) { - var buf; - - t.strictEqual( hasOwnProp( Ctor.prototype, 'byteLength' ), true, 'has prototype property' ); - - buf = new Ctor( 10 ); - t.strictEqual( hasOwnProp( buf, 'byteLength' ), false, 'does not have own property' ); - t.strictEqual( hasProp( buf, 'byteLength' ), true, 'has property' ); - t.strictEqual( buf.byteLength, 10, 'returns expected value' ); - - t.end(); -}); - -tape( 'the constructor returns a `SharedArrayBuffer` instance having a `slice` method, which copies the bytes of a `SharedArrayBuffer` to a new `SharedArrayBuffer`', opts, function test( t ) { - var b1; - var b2; - - t.strictEqual( hasOwnProp( Ctor.prototype, 'slice' ), true, 'has prototype property' ); - t.strictEqual( isFunction( Ctor.prototype.slice ), true, 'has method' ); - - b1 = new Ctor( 10 ); - t.strictEqual( hasOwnProp( b1, 'slice' ), false, 'does not have own property' ); - t.strictEqual( hasProp( b1, 'slice' ), true, 'has property' ); - - b2 = b1.slice(); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, b1.byteLength, 'has same number of bytes' ); - - b2 = b1.slice( 2 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 8, 'has expected number of bytes' ); - - b2 = b1.slice( b1.byteLength + 10 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 0, 'has expected number of bytes' ); - - b2 = b1.slice( -2 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 2, 'has expected number of bytes' ); - - b2 = b1.slice( -100 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 10, 'has expected number of bytes' ); - - b2 = b1.slice( 0, 6 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 6, 'has expected number of bytes' ); - - b2 = b1.slice( 2, 6 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 4, 'has expected number of bytes' ); - - b2 = b1.slice( 0, -2 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 8, 'has expected number of bytes' ); - - b2 = b1.slice( 0, -100 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 0, 'has expected number of bytes' ); - - b2 = b1.slice( -4, -2 ); - t.strictEqual( instanceOf( b2, Ctor ), true, 'returns an instance' ); - t.notEqual( b2, b1, 'returns a new reference' ); - t.strictEqual( b2.byteLength, 2, 'has expected number of bytes' ); - - t.end(); -}); - -// TODO: add tests testing shared memory semantics/behavior diff --git a/shared-buffer/test/test.polyfill.js b/shared-buffer/test/test.polyfill.js deleted file mode 100644 index 3cc5d5420..000000000 --- a/shared-buffer/test/test.polyfill.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); diff --git a/slice/README.md b/slice/README.md deleted file mode 100644 index e4c046237..000000000 --- a/slice/README.md +++ /dev/null @@ -1,170 +0,0 @@ - - -# slice - -> Return a shallow copy of a portion of an array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var slice = require( '@stdlib/array/slice' ); -``` - -#### slice( x\[, start\[, end]] ) - -Returns a shallow copy of a portion of an array. - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var out = slice( x ); -// returns [ 1, 2, 3, 4, 5, 6 ] - -var bool = ( out === x ); -// returns false -``` - -The function accepts the following arguments: - -- **x**: input array. -- **start**: starting index (inclusive). Default: `0`. -- **end**: ending index (exclusive). Default: `x.length`. - -By default, the function returns a shallow copy beginning from the first element of the provided input array. To begin copying from an alternative element, provide a starting index (inclusive). - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var out = slice( x, 2 ); -// returns [ 3, 4, 5, 6 ] -``` - -By default, the function copies through the end of the provided input array. To copy up until a specific element, provide an ending index (exclusive). - -```javascript -var x = [ 1, 2, 3, 4, 5, 6 ]; - -var out = slice( x, 1, 4 ); -// returns [ 2, 3, 4 ] -``` - -
- - - - - -
- -## Notes - -- If provided an array-like object having a `slice` method, the function defers execution to that method and assumes that the method API has the following signature: - - ```text - x.slice( start, end ) - ``` - -- If provided an array-like object without a `slice` method, the function copies input array elements to a new generic array. - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var zeroTo = require( '@stdlib/array/zero-to' ); -var slice = require( '@stdlib/array/slice' ); - -var x = zeroTo( 6, 'float64' ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -var s = slice( x ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -s = slice( x, 0, 4 ); -// returns [ 0.0, 1.0, 2.0, 3.0 ] - -s = slice( x, 2 ); -// returns [ 2.0, 3.0, 4.0, 5.0 ] - -s = slice( x, 2, 4 ); -// returns [ 2.0, 3.0 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/slice/benchmark/benchmark.length.js b/slice/benchmark/benchmark.length.js deleted file mode 100644 index 17d4ac6cb..000000000 --- a/slice/benchmark/benchmark.length.js +++ /dev/null @@ -1,96 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var ones = require( './../../ones' ); -var pkg = require( './../package.json' ).name; -var slice = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = ones( len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = slice( x ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( out ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/slice/docs/repl.txt b/slice/docs/repl.txt deleted file mode 100644 index 687110ecb..000000000 --- a/slice/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( x[, start[, end]] ) - Returns a shallow copy of a portion of an array. - - If provided an array-like object having a `slice` method, the function - defers execution to that method and assumes that the method has the - following signature: - - x.slice( start, end ) - - If provided an array-like object without a `slice` method, the function - copies input array elements to a new generic array. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - start: integer (optional) - Starting index (inclusive). Default: 0. - - end: integer (optional) - Ending index (exclusive). Default: x.length. - - Returns - ------- - out: Array|TypedArray - Output array. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - [ 1, 2, 3, 4 ] - > out = {{alias}}( [ 1, 2, 3, 4 ], 1 ) - [ 2, 3, 4 ] - > out = {{alias}}( [ 1, 2, 3, 4 ], 1, 3 ) - [ 2, 3 ] - - See Also - -------- - diff --git a/slice/docs/types/index.d.ts b/slice/docs/types/index.d.ts deleted file mode 100644 index b0914e75e..000000000 --- a/slice/docs/types/index.d.ts +++ /dev/null @@ -1,76 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, TypedArray, ComplexTypedArray } from '@stdlib/types/array'; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -* -* var out = slice( x ); -* // returns [ 1.0, 2.0, 3.0 ] -* -* @example -* var Complex64Array = require( '@stdlib/array/complex64' ); -* -* var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* var out = slice( x ); -* // returns -*/ -declare function slice( x: T, start?: number, end?: number ): T; - -/** -* Returns a shallow copy of a portion of an array. -* -* @param x - input array -* @param start - starting index (inclusive) -* @param end - ending index (exclusive) -* @returns output array -* -* @example -* var x = [ 1, 2, 3 ]; -* -* var out = slice( x ); -* // returns [ 1, 2, 3 ] -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var out = slice( x, 0, 2 ); -* // returns [ 1, 2 ] -*/ -declare function slice( x: Collection, start?: number, end?: number ): Array; - - -// EXPORTS // - -export = slice; diff --git a/slice/docs/types/test.ts b/slice/docs/types/test.ts deleted file mode 100644 index 88cfbef81..000000000 --- a/slice/docs/types/test.ts +++ /dev/null @@ -1,127 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import slice = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - slice( [ 1, 2, 3 ] ); // $ExpectType number[] - slice( new Float64Array( [ 1, 2, 3 ] ) ); // $ExpectType Float64Array - slice( new Float32Array( [ 1, 2, 3 ] ) ); // $ExpectType Float32Array - slice( new Int32Array( [ 1, 2, 3 ] ) ); // $ExpectType Int32Array - slice( new Int16Array( [ 1, 2, 3 ] ) ); // $ExpectType Int16Array - slice( new Int8Array( [ 1, 2, 3 ] ) ); // $ExpectType Int8Array - slice( new Uint32Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint32Array - slice( new Uint16Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint16Array - slice( new Uint8Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint8Array - slice( new Uint8ClampedArray( [ 1, 2, 3 ] ) ); // $ExpectType Uint8ClampedArray - slice( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ) ); // $ExpectType Complex128Array - slice( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ) ); // $ExpectType Complex64Array - - slice( [ 1, 2, 3 ], 0 ); // $ExpectType number[] - slice( new Float64Array( [ 1, 2, 3 ] ), 0 ); // $ExpectType Float64Array - slice( new Float32Array( [ 1, 2, 3 ] ), 0 ); // $ExpectType Float32Array - slice( new Int32Array( [ 1, 2, 3 ] ), 0 ); // $ExpectType Int32Array - slice( new Int16Array( [ 1, 2, 3 ] ), 0 ); // $ExpectType Int16Array - slice( new Int8Array( [ 1, 2, 3 ] ), 0 ); // $ExpectType Int8Array - slice( new Uint32Array( [ 1, 2, 3 ] ), 0 ); // $ExpectType Uint32Array - slice( new Uint16Array( [ 1, 2, 3 ] ), 0 ); // $ExpectType Uint16Array - slice( new Uint8Array( [ 1, 2, 3 ] ), 0 ); // $ExpectType Uint8Array - slice( new Uint8ClampedArray( [ 1, 2, 3 ] ), 0 ); // $ExpectType Uint8ClampedArray - slice( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), 0 ); // $ExpectType Complex128Array - slice( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), 0 ); // $ExpectType Complex64Array - - slice( [ 1, 2, 3 ], 0, 3 ); // $ExpectType number[] - slice( new Float64Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Float64Array - slice( new Float32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Float32Array - slice( new Int32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Int32Array - slice( new Int16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Int16Array - slice( new Int8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Int8Array - slice( new Uint32Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Uint32Array - slice( new Uint16Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Uint16Array - slice( new Uint8Array( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Uint8Array - slice( new Uint8ClampedArray( [ 1, 2, 3 ] ), 0, 3 ); // $ExpectType Uint8ClampedArray - slice( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType Complex128Array - slice( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), 0, 3 ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - slice( 5 ); // $ExpectError - slice( true ); // $ExpectError - slice( false ); // $ExpectError - slice( null ); // $ExpectError - slice( void 0 ); // $ExpectError - slice( {} ); // $ExpectError - - slice( 5, 0 ); // $ExpectError - slice( true, 0 ); // $ExpectError - slice( false, 0 ); // $ExpectError - slice( null, 0 ); // $ExpectError - slice( void 0, 0 ); // $ExpectError - slice( {}, 0 ); // $ExpectError - - slice( 5, 0, 3 ); // $ExpectError - slice( true, 0, 3 ); // $ExpectError - slice( false, 0, 3 ); // $ExpectError - slice( null, 0, 3 ); // $ExpectError - slice( void 0, 0, 3 ); // $ExpectError - slice( {}, 0, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - slice( x, '5' ); // $ExpectError - slice( x, true ); // $ExpectError - slice( x, false ); // $ExpectError - slice( x, null ); // $ExpectError - slice( x, {} ); // $ExpectError - slice( x, ( x: number ): number => x ); // $ExpectError - - slice( x, '5', 3 ); // $ExpectError - slice( x, true, 3 ); // $ExpectError - slice( x, false, 3 ); // $ExpectError - slice( x, null, 3 ); // $ExpectError - slice( x, {}, 3 ); // $ExpectError - slice( x, ( x: number ): number => x, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - const x = [ 1, 2, 3 ]; - - slice( x, 0, '5' ); // $ExpectError - slice( x, 0, true ); // $ExpectError - slice( x, 0, false ); // $ExpectError - slice( x, 0, null ); // $ExpectError - slice( x, 0, {} ); // $ExpectError - slice( x, 0, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - slice(); // $ExpectError - slice( [ 1, 2, 3 ], 0, 3, {} ); // $ExpectError -} diff --git a/slice/examples/index.js b/slice/examples/index.js deleted file mode 100644 index 35e4f4522..000000000 --- a/slice/examples/index.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -var zeroTo = require( './../../zero-to' ); -var slice = require( './../lib' ); - -var x = zeroTo( 6, 'float64' ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -var s = slice( x ); -console.log( s ); -// => [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 ] - -s = slice( x, 0, 4 ); -console.log( s ); -// => [ 0.0, 1.0, 2.0, 3.0 ] - -s = slice( x, 2 ); -console.log( s ); -// => [ 2.0, 3.0, 4.0, 5.0 ] - -s = slice( x, 2, 4 ); -console.log( s ); -// => [ 2.0, 3.0 ] diff --git a/slice/lib/index.js b/slice/lib/index.js deleted file mode 100644 index 182987cca..000000000 --- a/slice/lib/index.js +++ /dev/null @@ -1,45 +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. -*/ - -'use strict'; - -/** -* Return a shallow copy of a portion of an array. -* -* @module @stdlib/array/slice -* -* @example -* var slice = require( '@stdlib/array/slice' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var out = slice( x, 1, 3 ); -* // returns [ 2, 3 ] -* -* var bool = ( out === x ); -* // returns false -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/slice/lib/main.js b/slice/lib/main.js deleted file mode 100644 index 6dffa928b..000000000 --- a/slice/lib/main.js +++ /dev/null @@ -1,92 +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. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert/is-collection' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var base = require( './../../base/slice' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns a shallow copy of a portion of an array. -* -* @param {Collection} x - input array -* @param {integer} [start=0] - starting index (inclusive) -* @param {integer} [end=x.length] - ending index (exclusive) -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} second argument must be an integer -* @throws {TypeError} third argument must be an integer -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var out = slice( x, 1, 3 ); -* // returns [ 2, 3 ] -* -* var bool = ( out === x ); -* // returns false -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* -* var out = slice( x, 1, 3 ); -* // returns [ 2, 3 ] -* -* var bool = ( out === x ); -* // returns false -*/ -function slice( x ) { - var start; - var end; - - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) ); - } - if ( arguments.length > 1 ) { - start = arguments[ 1 ]; - if ( !isInteger( start ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an integer. Value: `%s`.', start ) ); - } - if ( arguments.length > 2 ) { - end = arguments[ 2 ]; - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', end ) ); - } - } else { - end = x.length; - } - } else { - start = 0; - end = x.length; - } - return base( x, start, end ); -} - - -// EXPORTS // - -module.exports = slice; diff --git a/slice/package.json b/slice/package.json deleted file mode 100644 index ec59d4015..000000000 --- a/slice/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "name": "@stdlib/array/slice", - "version": "0.0.0", - "description": "Return a shallow copy of a portion of an array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "generic", - "copy", - "slice", - "shallow" - ] -} diff --git a/slice/test/test.js b/slice/test/test.js deleted file mode 100644 index bc341070e..000000000 --- a/slice/test/test.js +++ /dev/null @@ -1,516 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var AccessorArray = require( './../../base/accessor' ); -var Float64Array = require( './../../float64' ); -var Int32Array = require( './../../int32' ); -var isArray = require( '@stdlib/assert/is-array' ); -var isFloat64Array = require( '@stdlib/assert/is-float64array' ); -var isInt32Array = require( '@stdlib/assert/is-int32array' ); -var slice = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof slice, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a collection (nargs=1)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - slice( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a collection (nargs=2)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - slice( value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a collection (nargs=3)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - slice( value, 0, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an integer (nargs=2)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - slice( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an integer (nargs=3)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - slice( [ 1, 2, 3 ], value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not an integer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - slice( [ 1, 2, 3 ], 0, value ); - }; - } -}); - -tape( 'the function slices an array-like object (generic)', function test( t ) { - var expected; - var actual; - var x; - - x = [ 1, 2, 3 ]; - - expected = [ 1, 2, 3 ]; - actual = slice( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3 ]; - actual = slice( x, 0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3 ]; - actual = slice( x, 0, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 3 ]; - actual = slice( x, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 3 ]; - actual = slice( x, 1, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2 ]; - actual = slice( x, 1, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = slice( x, 1, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (float64)', function test( t ) { - var expected; - var actual; - var x; - - x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = slice( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = slice( x, 0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - actual = slice( x, 0, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 2.0, 3.0 ] ); - actual = slice( x, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 2.0, 3.0 ] ); - actual = slice( x, 1, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [ 2.0 ] ); - actual = slice( x, 1, -1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Float64Array( [] ); - actual = slice( x, 1, 1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isFloat64Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (int32)', function test( t ) { - var expected; - var actual; - var x; - - x = new Int32Array( [ 1, 2, 3 ] ); - - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = slice( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = slice( x, 0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1, 2, 3 ] ); - actual = slice( x, 0, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1, 2 ] ); - actual = slice( x, 0, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [ 1 ] ); - actual = slice( x, 0, x.length-2 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = new Int32Array( [] ); - actual = slice( x, 0, x.length-3 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isInt32Array( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (accessors)', function test( t ) { - var expected; - var actual; - var x; - - x = new AccessorArray( [ 1, 2, 3, 4 ] ); - - expected = [ 1, 2, 3, 4 ]; - actual = slice( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - actual = slice( x, 0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - actual = slice( x, 0, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3 ]; - actual = slice( x, 0, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 3 ]; - actual = slice( x, 1, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 3 ]; - actual = slice( x, 2, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = slice( x, 3, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function slices an array-like object (array-like)', function test( t ) { - var expected; - var actual; - var x; - - x = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - - expected = [ 1, 2, 3, 4 ]; - actual = slice( x ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - actual = slice( x, 0 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - actual = slice( x, 0, x.length ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3 ]; - actual = slice( x, 0, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 2, 3 ]; - actual = slice( x, 1, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 3 ]; - actual = slice( x, 2, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = []; - actual = slice( x, 3, x.length-1 ); - - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of length `0`', function test( t ) { - var expected; - var actual; - - expected = []; - - actual = slice( [] ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = slice( [], 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = slice( [], 0, 0 ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 000000000..f582f77f6 --- /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 000000000..224017bef --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/struct-factory/README.md b/struct-factory/README.md deleted file mode 100644 index bbbe0b711..000000000 --- a/struct-factory/README.md +++ /dev/null @@ -1,322 +0,0 @@ - - -# structFactory - -> Return a constructor for creating arrays having a fixed-width composite data type. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var structFactory = require( '@stdlib/array/struct-factory' ); -``` - -#### structFactory( arg ) - -Returns a constructor for creating arrays having a fixed-width composite data type. - -```javascript -var schema = [ - { - 'name': 'beep', - 'type': 'float64' - }, - { - 'name': 'boop', - 'type': 'int32' - } -]; -var StructArray = structFactory( schema ); -// returns -``` - -The function supports the following parameters: - -- **arg**: [`struct`][@stdlib/dstructs/struct] constructor or a [`struct`][@stdlib/dstructs/struct] schema. - -* * * - -### Array Constructor - -#### StructArray() - -TODO: add documentation of constructor - -* * * - -### Array Properties - - - -#### StructArray.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var schema = [ - { - 'name': 'foo', - 'type': 'bool' - } -]; -var StructArray = structFactory( schema ); - -var nbytes = StructArray.BYTES_PER_ELEMENT; -// returns 1 -``` - - - -#### StructArray.name - -Array constructor name. - -```javascript -var schema = [ - { - 'name': 'foo', - 'type': 'bool' - } -]; -var StructArray = structFactory( schema ); - -var str = StructArray.name; -// returns 'StructArray' -``` - - - -#### StructArray.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the array. - -```javascript -var schema = [ - { - 'name': 'foo', - 'type': 'bool' - } -]; -var StructArray = structFactory( schema ); - -var arr = new StructArray( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### StructArray.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the array. - -```javascript -var schema = [ - { - 'name': 'foo', - 'type': 'int32' - } -]; -var StructArray = structFactory( schema ); - -var arr = new StructArray( 5 ); -var byteLength = arr.byteLength; -// returns 20 -``` - - - -#### StructArray.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the array from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - -```javascript -var schema = [ - { - 'name': 'foo', - 'type': 'bool' - } -]; -var StructArray = structFactory( schema ); - -var arr = new StructArray( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### StructArray.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - -```javascript -var schema = [ - { - 'name': 'foo', - 'type': 'bool' - } -]; -var StructArray = structFactory( schema ); - -var arr = new StructArray( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 1 -``` - - - -#### StructArray.prototype.length - -**Read-only** property which returns the number of view elements. - -```javascript -var schema = [ - { - 'name': 'foo', - 'type': 'bool' - } -]; -var StructArray = structFactory( schema ); - -var arr = new StructArray( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Array Methods - -TODO: document methods - -
- - - - - -
- -* * * - -## Notes - -- While returned constructors _strive_ to maintain (but do not **guarantee**) consistency with [typed arrays][@stdlib/array/typed], significant deviations from ECMAScript-defined [typed array][@stdlib/array/typed] behavior are as follows: - - - Constructors do **not** require the `new` operator. - - Accessing array elements using bracket syntax (e.g., `X[i]`) is **not** supported. Instead, one **must** use the `.get()` method. - - Accessed array elements are a view on underlying memory. Thus, mutation of accessed elements mutates the underlying buffer. - -- Struct arrays share several similarities with generic arrays containing objects (e.g., nested property access); however, the principal difference is that struct arrays are strongly typed and backed by fixed memory. Struct arrays are particularly well-suited for zero-copy transfer of data stored in composite data types when interoperating between JavaScript and C. - -
- - - - - -
- -## Examples - - - -```javascript -var factory = require( '@stdlib/array/struct-factory' ); - -// Define a schema for a composite data type for storing a student's test scores: -var schema = [ - { - 'name': 'test_number', - 'type': 'int16' - }, - { - 'name': 'pass', - 'type': 'bool' - }, - { - 'name': 'correct', - 'type': 'int32' - }, - { - 'name': 'incorrect', - 'type': 'int32' - }, - { - 'name': 'percentage', - 'type': 'float32' - } -]; - -// Create an array constructor for creating composite data type arrays: -var TestScoreArray = factory( schema ); -console.log( 'Layout: %s', TestScoreArray.struct.layout ); - -// Create a new array for storing test scores: -var student1 = new TestScoreArray( 10 ); -console.log( 'Byte length: %d', student1.byteLength ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/struct-factory/benchmark/benchmark.js b/struct-factory/benchmark/benchmark.js deleted file mode 100644 index 4f8c12c75..000000000 --- a/struct-factory/benchmark/benchmark.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var structFactory = require( '@stdlib/dstructs/struct' ); -var pkg = require( './../package.json' ).name; -var factory = require( './../lib' ); - - -// FIXTURES // - -var schema = require( './fixtures/schema.json' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var Struct; - var v; - var i; - - Struct = structFactory( schema ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = factory( Struct ); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/struct-factory/benchmark/fixtures/schema.json b/struct-factory/benchmark/fixtures/schema.json deleted file mode 100644 index 0acce4367..000000000 --- a/struct-factory/benchmark/fixtures/schema.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "name": "beep", - "type": "float64" - }, - { - "name": "boop", - "type": "float64" - } -] diff --git a/struct-factory/examples/index.js b/struct-factory/examples/index.js deleted file mode 100644 index 9b54f446c..000000000 --- a/struct-factory/examples/index.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var factory = require( './../lib' ); - -// Define a schema for a composite data type for storing a student's test scores: -var schema = [ - { - 'name': 'test_number', - 'type': 'int16' - }, - { - 'name': 'pass', - 'type': 'bool' - }, - { - 'name': 'correct', - 'type': 'int32' - }, - { - 'name': 'incorrect', - 'type': 'int32' - }, - { - 'name': 'percentage', - 'type': 'float32' - } -]; - -// Create an array constructor for creating composite data type arrays: -var TestScoreArray = factory( schema ); -console.log( 'Layout: %s', TestScoreArray.struct.layout ); - -// Create a new array for storing test scores: -var student1 = new TestScoreArray( 10 ); -console.log( 'Byte length: %d', student1.byteLength ); - -// TODO: update example once we have added array methods, etc diff --git a/struct-factory/lib/from_array.js b/struct-factory/lib/from_array.js deleted file mode 100644 index 31fde0406..000000000 --- a/struct-factory/lib/from_array.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var getter = require( './../../base/getter' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var Uint8Array = require( './../../uint8' ); -var gcopy = require( '@stdlib/blas/base/gcopy' ).ndarray; - - -// MAIN // - -/** -* Fills an output ArrayBuffer with array values. -* -* @private -* @param {Function} Struct - struct constructor -* @param {ArrayBuffer} buf - output data buffer -* @param {Collection} arr - input array -* @throws {TypeError} an input array must contain struct instances -* @throws {TypeError} each element of an input array must be a struct instance having the expected layout -* @returns {ArrayBuffer} output data buffer -*/ -function fromArray( Struct, buf, arr ) { - var sbytes; - var bbytes; - var offset; - var layout; - var sview; - var opts; - var len; - var get; - var flg; - var nb; - var v; - var i; - - opts = { - 'format': 'layout' - }; - - len = arr.length; - if ( arr.get && arr.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - layout = Struct.layout; - nb = Struct.byteLength; - - // FIXME: add optimization for when `buf` is a StructArray having the same layout, as can just copy bytes - - bbytes = new Uint8Array( buf ); - offset = 0; - for ( i = 0; i < len; i++ ) { - v = get( arr, i ); - try { - sview = Struct.viewOf( v ); // note: this should throw if `v` is not a struct - flg = true; - } catch ( err ) { // eslint-disable-line no-unused-vars - try { - // Attempt to convert the input value to a struct instance: - v = new Struct( v ); // note: this should throw if `v` is not an object with valid fields - } catch ( err ) { // eslint-disable-line no-unused-vars - return null; - } - sview = Struct.viewOf( v ); - flg = false; - } - if ( flg && v.toString( opts ) !== layout ) { - return null; - } - sbytes = new Uint8Array( sview.buffer, sview.byteOffset, sview.byteLength ); // eslint-disable-line max-len - gcopy( nb, sbytes, 1, 0, bbytes, 1, offset ); - offset += nb; - } - return buf; -} - - -// EXPORTS // - -module.exports = fromArray; diff --git a/struct-factory/lib/from_iterator.js b/struct-factory/lib/from_iterator.js deleted file mode 100644 index b6190d003..000000000 --- a/struct-factory/lib/from_iterator.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns an array of iterated values. -* -* @private -* @param {Object} it - iterator -* @returns {Array} output array -*/ -function fromIterator( it ) { - var out; - var v; - - out = []; - while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = fromIterator; diff --git a/struct-factory/lib/index.js b/struct-factory/lib/index.js deleted file mode 100644 index 0fdfaa060..000000000 --- a/struct-factory/lib/index.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a constructor for creating arrays having a fixed-width composite data type. -* -* @module @stdlib/array/struct-factory -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var structFactory = require( '@stdlib/dstructs/struct' ); -* var factory = require( '@stdlib/array/struct-factory' ); -* -* var schema1 = [ -* { -* 'name': 're', -* 'type': 'float64' -* }, -* { -* 'name': 'im', -* 'type': 'float64' -* } -* ]; -* -* // Create a struct constructor for storing real and imaginary componenets: -* var Components = structFactory( schema1 ); -* -* var schema2 = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'value', -* 'type': 'complex128' -* }, -* { -* 'name': 'components', -* 'type': Components -* } -* ] -* } -* ]; -* -* // Create a struct constructor for storing a double-precision complex number: -* var Complex128Struct = structFactory( schema2 ); -* -* // Create an array constructor for storing complex numbers: -* var Complex128Array = factory( Complex128Struct ); -* -* // Create a new array: -* var x = new Complex128Array( 10 ); -* // returns -* -* // Retrieve the first element: -* var v1 = x.get( 0 ); -* -* // Resolve the complex number stored within the first element: -* var z1 = v1.value; -* // returns [ 0.0, 0.0 ] -* -* // Resolve the individual real and imaginary components: -* var z2 = v1.components; -* -* var re = z2.re; -* // returns 0.0 -* -* var im = z2.im; -* // returns 0.0 -* -* // Create a new complex number struct: -* var z3 = new Complex128Struct({ -* 'value': new Complex128( 3.0, 5.0 ) -* }); -* -* // Update the first element of the array: -* x.set( z3, 0 ); -* -* // As `v1` is a view on same memory as the first element, resolve the complex number stored within the element: -* var z4 = v1.value; -* // returns [ 3.0, 5.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/struct-factory/lib/main.js b/struct-factory/lib/main.js deleted file mode 100644 index 1f947b7e7..000000000 --- a/struct-factory/lib/main.js +++ /dev/null @@ -1,573 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable no-restricted-syntax, no-invalid-this, max-len, max-lines-per-function */ - -'use strict'; - -// MODULES // - -var isStructConstructorLike = require( '@stdlib/assert/is-struct-constructor-like' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isObject = require( '@stdlib/assert/is-object' ); -var isPrototypeOf = require( '@stdlib/assert/is-prototype-of' ); // eslint-disable-line stdlib/no-redeclare -var hasIteratorSymbolSupport = require( '@stdlib/assert/has-iterator-symbol-support' ); -var hasProp = require( '@stdlib/assert/has-property' ); -var contains = require( './../../base/assert/contains' ); -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var setReadOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-read-only-accessor' ); -var ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var ArrayBuffer = require( './../../buffer' ); -var Uint8Array = require( './../../uint8' ); -var getter = require( './../../base/getter' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var gcopy = require( '@stdlib/blas/base/gcopy' ).ndarray; -var structFactory = require( '@stdlib/dstructs/struct' ); -var format = require( '@stdlib/string/format' ); -var fromArray = require( './from_array.js' ); -var fromIterator = require( './from_iterator.js' ); - - -// VARIABLES // - -var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); -var CTOR_NAME = 'StructArray'; - - -// MAIN // - -/** -* Returns a constructor for creating arrays having a fixed-width composite data type. -* -* @param {(Function|Array)} arg - struct constructor or struct schema -* @throws {TypeError} first argument must be either a struct constructor or struct schema -* @returns {Function} constructor -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* var structFactory = require( '@stdlib/dstructs/struct' ); -* -* var schema1 = [ -* { -* 'name': 're', -* 'type': 'float64' -* }, -* { -* 'name': 'im', -* 'type': 'float64' -* } -* ]; -* -* // Create a struct constructor for storing real and imaginary components: -* var Components = structFactory( schema1 ); -* -* var schema2 = [ -* { -* 'type': 'union', -* 'fields': [ -* { -* 'name': 'value', -* 'type': 'complex128' -* }, -* { -* 'name': 'components', -* 'type': Components -* } -* ] -* } -* ]; -* -* // Create a struct constructor for storing a double-precision complex number: -* var Complex128Struct = structFactory( schema2 ); -* -* // Create an array constructor for storing complex numbers: -* var Complex128Array = factory( Complex128Struct ); -* -* // Create a new array: -* var x = new Complex128Array( 10 ); -* // returns -* -* // Retrieve the first element: -* var v1 = x.get( 0 ); -* -* // Resolve the complex number stored within the first element: -* var z1 = v1.value; -* // returns [ 0.0, 0.0 ] -* -* // Resolve the individual real and imaginary components: -* var z2 = v1.components; -* -* var re = z2.re; -* // returns 0.0 -* -* var im = z2.im; -* // returns 0.0 -* -* // Create a new complex number struct: -* var z3 = new Complex128Struct({ -* 'value': new Complex128( 3.0, 5.0 ) -* }); -* -* // Update the first element of the array: -* x.set( z3, 0 ); -* -* // As `v1` is a view on same memory as the first element, resolve the complex number stored within the element: -* var z4 = v1.value; -* // returns [ 3.0, 5.0 ] -*/ -function factory( arg ) { // eslint-disable-line stdlib/jsdoc-require-throws-tags - var BYTES_PER_ELEMENT; - var LAYOUT; - var FIELDS; - var Struct; - - // FIXME: add option support for strict input object validation (e.g., throw whenever non-struct properties are included on an object passed to `set`) - - if ( isCollection( arg ) ) { - Struct = structFactory( arg ); // NOTE: delegate to `structFactory` to perform input validation - } else if ( isStructConstructorLike( arg ) ) { - Struct = arg; - } else { - throw new TypeError( format( 'invalid argument. First argument must be either a struct constructor or struct schema. Value: `%s`.', arg ) ); - } - BYTES_PER_ELEMENT = Struct.byteLength; - LAYOUT = Struct.layout; // TODO: consider whether to lazily materialize the struct layout, as this could potentially be a long string (hence increased memory consumption) depending on the complexity of the struct - FIELDS = Struct.fields; - - /** - * Constructor which returns an array having a fixed-width composite data type. - * - * @private - * @constructor - * @param {(NonNegativeInteger|Collection|ArrayBuffer|Iterable)} [arg] - length, typed array, array-like object, buffer, or an iterable - * @param {NonNegativeInteger} [byteOffset=0] - byte offset - * @param {NonNegativeInteger} [length] - view length - * @throws {TypeError} must provide a valid first argument - * @throws {TypeError} second argument must be a nonnegative integer - * @throws {TypeError} third argument must be a nonnegative integer - * @throws {RangeError} must provide sufficient memory to accommodate byte offset and view length requirements - * @throws {RangeError} second argument must be a multiple of struct byte length - * @throws {RangeError} second argument must not exceeds the ArrayBuffer bounds - * @throws {TypeError} view length must be a positive multiple of struct byte length - * @throws {TypeError} an input array must contain valid elements - * @returns {StructArray} struct array instance - */ - function StructArray( arg, byteOffset, length ) { - var nargs; - var buf; - var len; - var tmp; - - nargs = arguments.length; - if ( !( this instanceof StructArray) ) { - if ( nargs === 0 ) { - return new StructArray(); - } - if ( nargs === 1 ) { - return new StructArray( arg ); - } - if ( nargs === 2 ) { - return new StructArray( arg, byteOffset ); - } - return new StructArray( arg, byteOffset, length ); - } - - // Case: new StructArray() - if ( nargs === 0 ) { - buf = new ArrayBuffer( 0 ); - len = 0; - } - // Case: new StructArray( arg ) - else if ( nargs === 1 ) { - // Case: new StructArray( length ) - if ( isNonNegativeInteger( arg ) ) { - buf = new ArrayBuffer( arg*BYTES_PER_ELEMENT ); - len = arg; - } - // Case: new StructArray( collection ) - else if ( isCollection( arg ) ) { - len = arg.length; - buf = fromArray( Struct, new ArrayBuffer( len*BYTES_PER_ELEMENT ), arg ); - if ( buf === null ) { - throw new TypeError( format( 'invalid argument. Each element of a provided input array must be a valid object or a struct instance having the same layout as elements in the desired output array.' ) ); - } - } - // Case: new StructArray( ArrayBuffer ) - else if ( isArrayBuffer( arg ) ) { - buf = arg; - len = buf.byteLength / BYTES_PER_ELEMENT; - if ( !isInteger( len ) ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer byte length must be a multiple of %u. Byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength ) ); - } - } - // Case: new StructArray( iterable ) - else if ( isObject( arg ) ) { - if ( HAS_ITERATOR_SYMBOL === false ) { - throw new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. First argument must be a length, ArrayBuffer, typed array, or array-like object. Value: `%s`.', arg ) ); - } - if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - buf = arg[ ITERATOR_SYMBOL ](); - if ( !isFunction( buf.next ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - tmp = fromIterator( buf ); - len = tmp.length; - buf = fromArray( Struct, new ArrayBuffer( len*BYTES_PER_ELEMENT ), tmp ); - if ( buf === null ) { - throw new TypeError( format( 'invalid argument. Each element of a provided input iterable must be either a valid object or a struct instance having the same layout as elements in the desired output array.' ) ); - } - } - // Case: new StructArray( ???? ) - else { - throw new TypeError( format( 'invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or an iterable. Value: `%s`.', arg ) ); - } - } - // Case: new StructArray( ArrayBuffer, byteOffset[, length] ) - else { - buf = arguments[ 0 ]; - if ( !isArrayBuffer( buf ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an ArrayBuffer. Value: `%s`.', arg ) ); - } - if ( !isNonNegativeInteger( byteOffset ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%s`.', byteOffset ) ); - } - if ( !isInteger( byteOffset/BYTES_PER_ELEMENT ) ) { - throw new RangeError( format( 'invalid argument. Second argument must be a multiple of %u. Value: `%u`.', BYTES_PER_ELEMENT, byteOffset ) ); - } - if ( byteOffset >= buf.byteLength ) { - throw new RangeError( format( 'invalid argument. Second argument exceeds the bounds of the ArrayBuffer. Value: `%s`.', byteOffset ) ); - } - // Case: new StructArray( ArrayBuffer, byteOffset ) - if ( nargs === 2 ) { - len = ( buf.byteLength - byteOffset ) / BYTES_PER_ELEMENT; - if ( !isInteger( len ) ) { - throw new RangeError( format( 'invalid argument. ArrayBuffer view byte length must be a multiple of %u. View byte length: `%u`.', BYTES_PER_ELEMENT, buf.byteLength-byteOffset ) ); - } - } - // Case: new StructArray( ArrayBuffer, byteOffset, length ) - else { - len = length; - if ( !isNonNegativeInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%s`.', len ) ); - } - if ( (len*BYTES_PER_ELEMENT) > (buf.byteLength-byteOffset) ) { - throw new RangeError( format( 'invalid arguments. ArrayBuffer has insufficient capacity. Either decrease the array length or provide a bigger buffer. Minimum capacity: `%u`.', len*BYTES_PER_ELEMENT ) ); - } - } - } - setReadOnly( this, '_buffer', buf ); - setReadOnly( this, '_byteOffset', byteOffset || 0 ); - setReadOnly( this, '_byteLength', len*BYTES_PER_ELEMENT ); - setReadOnly( this, '_length', len ); - return this; - } - - /** - * Size (in bytes) of each array element. - * - * @private - * @name BYTES_PER_ELEMENT - * @memberof StructArray - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( StructArray, 'BYTES_PER_ELEMENT', BYTES_PER_ELEMENT ); - - /** - * Constructor name. - * - * @private - * @name name - * @memberof StructArray - * @readonly - * @type {string} - */ - setReadOnly( StructArray, 'name', CTOR_NAME ); - - /** - * Element constructor. - * - * @private - * @name struct - * @memberof StructArray - * @readonly - * @type {Function} - */ - setReadOnly( StructArray, 'struct', Struct ); - - /** - * Pointer to the underlying data buffer. - * - * @private - * @name buffer - * @memberof StructArray.prototype - * @readonly - * @type {ArrayBuffer} - */ - setReadOnlyAccessor( StructArray.prototype, 'buffer', function get() { - return this._buffer; - }); - - /** - * Size (in bytes) of the array. - * - * @private - * @name byteLength - * @memberof StructArray.prototype - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnlyAccessor( StructArray.prototype, 'byteLength', function get() { - return this._byteLength; - }); - - /** - * Offset (in bytes) of the array from the start of its underlying `ArrayBuffer`. - * - * @private - * @name byteOffset - * @memberof StructArray.prototype - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnlyAccessor( StructArray.prototype, 'byteOffset', function get() { - return this._byteOffset; - }); - - /** - * Size (in bytes) of each array element. - * - * @private - * @name BYTES_PER_ELEMENT - * @memberof StructArray.prototype - * @readonly - * @type {PositiveInteger} - */ - setReadOnly( StructArray.prototype, 'BYTES_PER_ELEMENT', StructArray.BYTES_PER_ELEMENT ); - - /** - * Returns an array element. - * - * @private - * @name get - * @memberof StructArray.prototype - * @type {Function} - * @param {NonNegativeInteger} idx - element index - * @throws {TypeError} `this` must be a struct array instance - * @throws {TypeError} must provide a nonnegative integer - * @returns {(*|void)} array element - */ - setReadOnly( StructArray.prototype, 'get', function get( idx ) { - if ( !isStructArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not a %s.', CTOR_NAME ) ); - } - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Must provide a nonnegative integer. Value: `%s`.', idx ) ); - } - if ( idx >= this._length ) { - return; - } - return new Struct( this._buffer, this._byteOffset+( idx*BYTES_PER_ELEMENT ), BYTES_PER_ELEMENT ); - }); - - /** - * Number of array elements. - * - * @private - * @name length - * @memberof StructArray.prototype - * @readonly - * @type {NonNegativeInteger} - */ - setReadOnlyAccessor( StructArray.prototype, 'length', function get() { - return this._length; - }); - - /** - * Sets an array element. - * - * ## Notes - * - * - When provided a struct array, we must check whether the source array shares the same buffer as the target array and whether the underlying memory overlaps. In particular, we are concerned with the following scenario: - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * In the above, as we copy values from `src`, we will overwrite values in the `src` view, resulting in duplicated values copied into the end of `buf`, which is not intended. Hence, to avoid overwriting source values, we must **copy** source values to a temporary array. - * - * In the other overlapping scenario, - * - * ```text - * buf: --------------------- - * src: --------------------- - * ``` - * - * by the time we begin copying into the overlapping region, we are copying from the end of `src`, a non-overlapping region, which means we don't run the risk of copying copied values, rather than the original `src` values, as intended. - * - * @private - * @name set - * @memberof StructArray.prototype - * @type {Function} - * @param {(Collection|StructArray|Struct|Object)} value - value(s) - * @param {NonNegativeInteger} [i=0] - element index at which to start writing values - * @throws {TypeError} `this` must be a struct array instance - * @throws {TypeError} index argument must be a nonnegative integer - * @throws {RangeError} index argument is out-of-bounds - * @throws {RangeError} target array lacks sufficient storage to accommodate source values - * @throws {TypeError} must provide a valid object or a struct instance having the same layout as elements in the target array - * @returns {void} - */ - setReadOnly( StructArray.prototype, 'set', function set( value ) { - var bbytes; - var sbytes; - var sbuf; - var opts; - var idx; - var buf; - var tmp; - var get; - var nb; - var N; - var s; - var f; - var i; - var j; - if ( !isStructArray( this ) ) { - throw new TypeError( format( 'invalid invocation. `this` is not a %s.', CTOR_NAME ) ); - } - buf = this._buffer; - if ( arguments.length > 1 ) { - idx = arguments[ 1 ]; - if ( !isNonNegativeInteger( idx ) ) { - throw new TypeError( format( 'invalid argument. Index argument must be a nonnegative integer. Value: `%s`.', idx ) ); - } - } else { - idx = 0; - } - opts = { - 'format': 'layout' - }; - nb = Struct.byteLength; - - if ( isCollection( value ) && !contains( FIELDS, 'length' ) ) { // note: when one of the fields is 'length', we always assume that a provided value with a 'length' property is a struct and/or data object as there doesn't seem to be a surefire way to distinguish such an object from a regular array-like object (including accessor arrays) - N = value.length; - if ( idx+N > this._length ) { - throw new RangeError( 'invalid arguments. Target array lacks sufficient storage to accommodate source values.' ); - } - sbuf = value; - if ( sbuf.get && sbuf.set ) { - get = accessorGetter( 'default' ); - } else { - get = getter( 'default' ); - } - // Check for overlapping memory... - j = this._byteOffset + (idx*BYTES_PER_ELEMENT); - if ( - sbuf.buffer === buf && - ( - sbuf.byteOffset < j && - sbuf.byteOffset+sbuf.byteLength > j - ) - ) { - // FIXME: add optimization when `value` is a StructArray sharing the same buffer and having the same layout; in which case, we can simply copy `src` bytes to a temporary array and then copy those bytes into the target array, without needing to intermediate struct instance materialization - - // We need to copy source values... - tmp = []; - for ( i = 0; i < N; i++ ) { - tmp.push( get( value, i ) ); - } - sbuf = tmp; - get = getter( 'default' ); - } - for ( i = 0; i < N; idx++, i++ ) { - this.set( get( sbuf, i ), idx ); // note: this likely isn't the most performant approach, but it avoids having to replicate branching logic for handling struct instances vs data objects - } - return; - } - if ( idx >= this._length ) { - throw new RangeError( format( 'invalid argument. Index argument is out-of-bounds. Value: `%u`.', idx ) ); - } - if ( !isObject( value ) ) { - throw new TypeError( format( 'invalid argument. Must provide either a valid object or a struct instance. Value: `%s`.', value ) ); - } - // Check for a struct instance having a matching layout... - if ( value.toString( opts ) === LAYOUT ) { - // Explicitly copy the bytes of the input struct instance to the corresponding array element... - sbuf = Struct.viewOf( value ); - sbytes = new Uint8Array( sbuf.buffer, sbuf.byteOffset, nb ); - bbytes = new Uint8Array( buf, this._byteOffset+( idx*BYTES_PER_ELEMENT ), nb ); - gcopy( nb, sbytes, 1, 0, bbytes, 1, 0 ); - return; - } - // Create a struct instance view for the target element: - s = new Struct( buf, this._byteOffset+( idx*BYTES_PER_ELEMENT ), nb ); - - // Assign field values from the input object (accounting for both own and inherited properties)... - for ( i = 0; i < FIELDS.length; i++ ) { - f = FIELDS[ i ]; - if ( hasProp( value, f ) ) { - s[ f ] = value[ f ]; - } - } - }); - - /** - * Element constructor. - * - * @private - * @name struct - * @memberof StructArray.prototype - * @readonly - * @type {Function} - */ - setReadOnly( StructArray.prototype, 'struct', Struct ); - - return StructArray; - - /** - * Returns a boolean indicating if a value is a struct array. - * - * @private - * @param {*} value - value to test - * @returns {boolean} boolean indicating if a value is a struct array - */ - function isStructArray( value ) { - return ( - typeof value === 'object' && - value !== null && - ( - value.constructor.name === CTOR_NAME || - isPrototypeOf( value, StructArray.prototype ) - ) && - value.BYTES_PER_ELEMENT === BYTES_PER_ELEMENT - ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/struct-factory/package.json b/struct-factory/package.json deleted file mode 100644 index 38730a5d6..000000000 --- a/struct-factory/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@stdlib/array/struct-factory", - "version": "0.0.0", - "description": "Return a constructor for creating arrays having a fixed-width composite data type.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "factory", - "struct", - "composite" - ] -} diff --git a/struct-factory/test/test.js b/struct-factory/test/test.js deleted file mode 100644 index 786dd7a4b..000000000 --- a/struct-factory/test/test.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var factory = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -// TODO: add tests diff --git a/take/README.md b/take/README.md deleted file mode 100644 index d0ea2976f..000000000 --- a/take/README.md +++ /dev/null @@ -1,158 +0,0 @@ - - -# take - -> Take elements from an array. - -
- -## Usage - -```javascript -var take = require( '@stdlib/array/take' ); -``` - -#### take( x, indices\[, options] ) - -Takes elements from an array. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var y = take( x, [ 1, 3 ] ); -// returns [ 2, 4 ] -``` - -The function supports the following parameters: - -- **x**: input array. -- **indices**: list of indices. -- **options**: function options. - -The function supports the following options: - -- **mode**: index [mode][@stdlib/ndarray/base/ind]. Default: `'normalize'`. - -By default, the function normalizes negative integer indices to positive integer index equivalents. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var y = take( x, [ -3, -1 ] ); -// returns [ 2, 4 ] -``` - -To specify an alternative index [mode][@stdlib/ndarray/base/ind], provide a `mode` option. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var y = take( x, [ -10, 10 ], { - 'mode': 'clamp' -}); -// returns [ 1, 4 ] -``` - -
- - - -
- -## Notes - -- If `indices` is an empty array, the function returns an empty array. - - ```javascript - var x = [ 1, 2, 3, 4 ]; - - var y = take( x, [] ); - // returns [] - ``` - -- If provided an input array having a recognized [data type][@stdlib/array/dtypes], the function returns an array having the same [data type][@stdlib/array/dtypes] as the input array. Otherwise, the function **always** returns a "generic" array. - -
- - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var linspace = require( '@stdlib/array/linspace' ); -var take = require( '@stdlib/array/take' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate an array of random indices: -var indices = discreteUniform( 10, 0, x.length-1 ); -console.log( indices ); - -// Take a random sample of elements from `x`: -var y = take( x, indices ); -console.log( y ); -``` - -
- - - - - - - - - - - - - - diff --git a/take/benchmark/benchmark.js b/take/benchmark/benchmark.js deleted file mode 100644 index 8975c75da..000000000 --- a/take/benchmark/benchmark.js +++ /dev/null @@ -1,52 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeroTo = require( './../../base/zero-to' ); -var pkg = require( './../package.json' ).name; -var take = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::copy:len=100', function benchmark( b ) { - var x; - var i; - var v; - - x = zeroTo( 100 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = take( x, x ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/take/benchmark/benchmark.length.js b/take/benchmark/benchmark.length.js deleted file mode 100644 index f81872fd7..000000000 --- a/take/benchmark/benchmark.length.js +++ /dev/null @@ -1,98 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var take = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var idx = discreteUniform( len, 0, 3 ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var x; - var v; - var i; - - x = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = take( x, idx ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/take/docs/repl.txt b/take/docs/repl.txt deleted file mode 100644 index eb4e87aa8..000000000 --- a/take/docs/repl.txt +++ /dev/null @@ -1,40 +0,0 @@ - -{{alias}}( x, indices[, options] ) - Takes elements from an array. - - If `indices` is an empty array, the function returns an empty array. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - indices: ArrayLikeObject - List of element indices. - - options: Object (optional) - Function options. - - options.mode: string (optional) - Specifies how to handle an index outside the interval [0, max], where - `max` is the maximum possible array index. If equal to 'throw', the - function throws an error. If equal to 'normalize', the function throws - an error if provided an out-of-bounds normalized index. If equal to - 'wrap', the function wraps around an index using modulo arithmetic. If - equal to 'clamp', the function sets an index to either 0 (minimum index) - or the maximum index. Default: 'normalize'. - - Returns - ------- - out: Array|TypedArray - Output array. - - Examples - -------- - > var x = [ 1, 2, 3, 4 ]; - > var y = {{alias}}( x, [ 1, 3 ] ) - [ 2, 4 ] - - See Also - -------- - diff --git a/take/docs/types/index.d.ts b/take/docs/types/index.d.ts deleted file mode 100644 index c8d65c5a3..000000000 --- a/take/docs/types/index.d.ts +++ /dev/null @@ -1,247 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, Complex128Array, Complex64Array } from '@stdlib/types/array'; -import { Mode } from '@stdlib/types/ndarray'; - -/** -* Index array. -*/ -type IndexArray = Collection | AccessorArrayLike; - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Index mode. - */ - mode?: Mode; -} - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var x = zeroTo( 4, 'float64' ); -* var y = take( x, [ 1, 3 ] ); -* // returns [ 1.0, 3.0 ] -*/ -declare function take( x: Float64Array, indices: IndexArray, options?: Options ): Float64Array; - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var x = zeroTo( 4, 'float32' ); -* var y = take( x, [ 1, 3 ] ); -* // returns [ 1.0, 3.0 ] -*/ -declare function take( x: Float32Array, indices: IndexArray, options?: Options ): Float32Array; - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var x = zeroTo( 4, 'int32' ); -* var y = take( x, [ 1, 3 ] ); -* // returns [ 1, 3 ] -*/ -declare function take( x: Int32Array, indices: IndexArray, options?: Options ): Int32Array; - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var x = zeroTo( 4, 'int16' ); -* var y = take( x, [ 1, 3 ] ); -* // returns [ 1, 3 ] -*/ -declare function take( x: Int16Array, indices: IndexArray, options?: Options ): Int16Array; - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var x = zeroTo( 4, 'int8' ); -* var y = take( x, [ 1, 3 ] ); -* // returns [ 1, 3 ] -*/ -declare function take( x: Int8Array, indices: IndexArray, options?: Options ): Int8Array; - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var x = zeroTo( 4, 'uint32' ); -* var y = take( x, [ 1, 3 ] ); -* // returns [ 1, 3 ] -*/ -declare function take( x: Uint32Array, indices: IndexArray, options?: Options ): Uint32Array; - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var x = zeroTo( 4, 'uint16' ); -* var y = take( x, [ 1, 3 ] ); -* // returns [ 1, 3 ] -*/ -declare function take( x: Uint16Array, indices: IndexArray, options?: Options ): Uint16Array; - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var x = zeroTo( 4, 'uint8' ); -* var y = take( x, [ 1, 3 ] ); -* // returns [ 1, 3 ] -*/ -declare function take( x: Uint8Array, indices: IndexArray, options?: Options ): Uint8Array; - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var x = zeroTo( 4, 'uint8c' ); -* var y = take( x, [ 1, 3 ] ); -* // returns [ 1, 3 ] -*/ -declare function take( x: Uint8ClampedArray, indices: IndexArray, options?: Options ): Uint8ClampedArray; - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var x = zeroTo( 4, 'complex128' ); -* var y = take( x, [ 1, 3 ] ); -* // returns [ 1.0, 0.0, 3.0, 0.0 ] -*/ -declare function take( x: Complex128Array, indices: IndexArray, options?: Options ): Complex128Array; - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var x = zeroTo( 4, 'complex64' ); -* var y = take( x, [ 1, 3 ] ); -* // returns [ 1.0, 0.0, 3.0, 0.0 ] -*/ -declare function take( x: Complex64Array, indices: IndexArray, options?: Options ): Complex64Array; - -/** -* Takes elements from an array. -* -* @param x - input array -* @param indices - list of element indices -* @param options - function options -* @returns output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = take( x, [ 1, 3 ] ); -* // returns [ 2, 4 ] -*/ -declare function take( x: Collection | AccessorArrayLike, indices: IndexArray, options?: Options ): Array; - - -// EXPORTS // - -export = take; diff --git a/take/docs/types/test.ts b/take/docs/types/test.ts deleted file mode 100644 index 0fe1ea80c..000000000 --- a/take/docs/types/test.ts +++ /dev/null @@ -1,94 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import take = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - take( [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType number[] - take( [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType any[] - take( [ 1, 2, 3, 4 ], [ 1, 3 ] ); // $ExpectType number[] - take( [ '1', '2', '3', '4' ], [ 1, 3 ] ); // $ExpectType string[] - - take( new Float64Array( 10 ), [ 1, 3 ] ); // $ExpectType Float64Array - take( new Float32Array( 10 ), [ 1, 3 ] ); // $ExpectType Float32Array - take( new Int32Array( 10 ), [ 1, 3 ] ); // $ExpectType Int32Array - take( new Int16Array( 10 ), [ 1, 3 ] ); // $ExpectType Int16Array - take( new Int8Array( 10 ), [ 1, 3 ] ); // $ExpectType Int8Array - take( new Uint32Array( 10 ), [ 1, 3 ] ); // $ExpectType Uint32Array - take( new Uint16Array( 10 ), [ 1, 3 ] ); // $ExpectType Uint16Array - take( new Uint8Array( 10 ), [ 1, 3 ] ); // $ExpectType Uint8Array - take( new Uint8ClampedArray( 10 ), [ 1, 3 ] ); // $ExpectType Uint8ClampedArray - take( new Complex128Array( 10 ), [ 1, 3 ] ); // $ExpectType Complex128Array - take( new Complex64Array( 10 ), [ 1, 3 ] ); // $ExpectType Complex64Array -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - take( 1, [ 1, 3 ] ); // $ExpectError - take( true, [ 1, 3 ] ); // $ExpectError - take( false, [ 1, 3 ] ); // $ExpectError - take( null, [ 1, 3 ] ); // $ExpectError - take( void 0, [ 1, 3 ] ); // $ExpectError - take( {}, [ 1, 3 ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - take( [], 1 ); // $ExpectError - take( [], true ); // $ExpectError - take( [], false ); // $ExpectError - take( [], null ); // $ExpectError - take( [], void 0 ); // $ExpectError - take( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an object... -{ - take( [], [ 1, 3 ], '1' ); // $ExpectError - take( [], [ 1, 3 ], 1 ); // $ExpectError - take( [], [ 1, 3 ], true ); // $ExpectError - take( [], [ 1, 3 ], false ); // $ExpectError - take( [], [ 1, 3 ], null ); // $ExpectError - take( [], [ 1, 3 ], [] ); // $ExpectError - take( [], [ 1, 3 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` option which is not a valid index mode... -{ - take( [], [ 1, 3 ], { 'mode': '1' } ); // $ExpectError - take( [], [ 1, 3 ], { 'mode': 1 } ); // $ExpectError - take( [], [ 1, 3 ], { 'mode': true } ); // $ExpectError - take( [], [ 1, 3 ], { 'mode': false } ); // $ExpectError - take( [], [ 1, 3 ], { 'mode': null } ); // $ExpectError - take( [], [ 1, 3 ], { 'mode': {} } ); // $ExpectError - take( [], [ 1, 3 ], { 'mode': [] } ); // $ExpectError - take( [], [ 1, 3 ], { 'mode': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - take(); // $ExpectError - take( [] ); // $ExpectError - take( [], [], {}, {} ); // $ExpectError -} diff --git a/take/examples/index.js b/take/examples/index.js deleted file mode 100644 index 49fd565a5..000000000 --- a/take/examples/index.js +++ /dev/null @@ -1,35 +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. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var linspace = require( './../../linspace' ); -var take = require( './../lib' ); - -// Generate a linearly spaced array: -var x = linspace( 0, 100, 11 ); -console.log( x ); - -// Generate an array of random indices: -var indices = discreteUniform( 10, 0, x.length-1 ); -console.log( indices ); - -// Take a random sample of elements from `x`: -var y = take( x, indices ); -console.log( y ); diff --git a/take/lib/defaults.js b/take/lib/defaults.js deleted file mode 100644 index ea2620441..000000000 --- a/take/lib/defaults.js +++ /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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns default options. -* -* @private -* @returns {Object} default options -* -* @example -* var o = defaults(); -* // returns {...} -*/ -function defaults() { - return { - 'mode': 'normalize' - }; -} - - -// EXPORTS // - -module.exports = defaults; diff --git a/take/lib/index.js b/take/lib/index.js deleted file mode 100644 index ae09036bc..000000000 --- a/take/lib/index.js +++ /dev/null @@ -1,43 +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. -*/ - -'use strict'; - -/** -* Take elements from an array. -* -* @module @stdlib/array/take -* -* @example -* var take = require( '@stdlib/array/take' ); -* -* var x = [ 1, 2, 3, 4 ]; -* -* var indices = [ 0, 0, 1, 1, 3, 3 ]; -* var y = take( x, indices ); -* // returns [ 1, 1, 2, 2, 4, 4 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/take/lib/main.js b/take/lib/main.js deleted file mode 100644 index 0ebfff78c..000000000 --- a/take/lib/main.js +++ /dev/null @@ -1,81 +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. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert/is-collection' ); -var base = require( './../../base/take' ); -var zeros = require( './../../zeros' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); -var defaults = require( './defaults.js' ); -var validate = require( './validate.js' ); - - -// MAIN // - -/** -* Takes elements from an array. -* -* @param {Collection} x - input array -* @param {IntegerArray} indices - list of indices -* @param {Options} [options] - function options -* @param {string} [options.mode='normalize'] - index mode -* @throws {TypeError} first argument must be a collection -* @throws {TypeError} second argument must be a collection -* @throws {TypeError} options argument must be an object -* @throws {Error} must provide valid options -* @returns {Collection} output array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var indices = [ 3, 1, 2, 0 ]; -* -* var y = take( x, indices ); -* // returns [ 4, 2, 3, 1 ] -*/ -function take( x, indices ) { - var opts; - var err; - var dt; - if ( !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', x ) ); - } - if ( !isCollection( indices ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', indices ) ); - } - opts = defaults(); - if ( arguments.length > 2 ) { - err = validate( opts, arguments[ 2 ] ); - if ( err ) { - throw err; - } - } - dt = dtype( x ); - if ( dt === 'generic' || dt === null ) { - return base( x, indices, opts.mode ); - } - return base.assign( x, indices, opts.mode, zeros( indices.length, dt ), 1, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = take; diff --git a/take/lib/validate.js b/take/lib/validate.js deleted file mode 100644 index 24e7153e7..000000000 --- a/take/lib/validate.js +++ /dev/null @@ -1,67 +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. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert/is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isIndexMode = require( '@stdlib/ndarray/base/assert/is-index-mode' ); -var modes = require( '@stdlib/ndarray/index-modes' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {string} [options.mode] - index mode -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'mode': 'normalize' -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'mode' ) ) { - opts.mode = options.mode; - if ( !isIndexMode( opts.mode ) ) { - return new TypeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'mode', modes().join( '", "' ), opts.mode ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/take/package.json b/take/package.json deleted file mode 100644 index 208f4f032..000000000 --- a/take/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "name": "@stdlib/array/take", - "version": "0.0.0", - "description": "Take elements from an array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "utilities", - "utils", - "generic", - "array", - "take", - "extract", - "copy", - "index" - ] -} diff --git a/take/test/test.js b/take/test/test.js deleted file mode 100644 index 0c6e453cb..000000000 --- a/take/test/test.js +++ /dev/null @@ -1,419 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Complex64Array = require( './../../complex64' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var isArray = require( '@stdlib/assert/is-array' ); -var take = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof take, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - take( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - take( value, [], {} ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - take( [], value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a collection (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - take( [], value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - take( [], [], value ); - }; - } -}); - -tape( 'the function throws an error if provided a `mode` option which is not a valid index mode', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - take( [], [], { - 'mode': value - }); - }; - } -}); - -tape( 'the function takes elements from an array (generic)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ 1, 3 ]; - actual = take( x, indices ); - - expected = [ 2, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 3, 3 ]; - actual = take( x, indices ); - - expected = [ 2, 2, 4, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 3, 2, 1, 0 ]; - actual = take( x, indices ); - - expected = [ 4, 3, 2, 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]; - actual = take( x, indices ); - - expected = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from an array (accessor)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = toAccessorArray( [ 1, 2, 3, 4 ] ); - - indices = toAccessorArray( [ 1, 3 ] ); - actual = take( x, indices ); - - expected = [ 2, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = toAccessorArray( [ 1, 1, 3, 3 ] ); - actual = take( x, indices ); - - expected = [ 2, 2, 4, 4 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = toAccessorArray( [ 3, 2, 1, 0 ] ); - actual = take( x, indices ); - - expected = [ 4, 3, 2, 1 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - indices = toAccessorArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); - actual = take( x, indices ); - - expected = [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]; - t.strictEqual( isArray( actual ), true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function takes elements from an array (complex typed)', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - - indices = toAccessorArray( [ 1, 1, 3 ] ); - actual = take( x, indices ); - - expected = new Complex64Array( [ 3.0, 4.0, 3.0, 4.0, 7.0, 8.0 ] ); - t.notEqual( actual, x, 'returns different reference' ); - t.strictEqual( isSameComplex64Array( actual, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided a second argument which is empty', function test( t ) { - var x = [ 1, 2, 3, 4 ]; - t.deepEqual( take( x, [] ), [], 'returns expected value' ); - t.end(); -}); - -tape( 'by default, the function normalizes negative indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -1, -2, -3, -4 ]; - actual = take( x, indices ); - expected = [ 4, 3, 2, 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 2, 50, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices ); - } -}); - -tape( 'when the "mode" is "throw", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 4, 5, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, { - 'mode': 'throw' - }); - } -}); - -tape( 'when the "mode" is "normalize", the function normalizes negative indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -1, -2, -3, -4 ]; - actual = take( x, indices, { - 'mode': 'normalize' - }); - expected = [ 4, 3, 2, 1 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "normalize", the function throws an error if provided an out-of-bounds index', function test( t ) { - var indices; - var x; - - x = [ 1, 2, 3, 4 ]; - indices = [ 2, 50, 1, 2 ]; - - t.throws( badValue, RangeError, 'throws an error' ); - t.end(); - - function badValue() { - take( x, indices, { - 'mode': 'normalize' - }); - } -}); - -tape( 'when the "mode" is "clamp", the function clamps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -10, 10, -5, 5 ]; - actual = take( x, indices, { - 'mode': 'clamp' - }); - expected = [ 1, 4, 1, 4 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when the "mode" is "wrap", the function wraps out-of-bounds indices', function test( t ) { - var expected; - var indices; - var actual; - var x; - - x = [ 1, 2, 3, 4 ]; - - indices = [ -10, 10, -5, 5 ]; - actual = take( x, indices, { - 'mode': 'wrap' - }); - expected = [ 3, 3, 4, 2 ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/take/test/test.validate.js b/take/test/test.validate.js deleted file mode 100644 index 5001a5e66..000000000 --- a/take/test/test.validate.js +++ /dev/null @@ -1,128 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if not provided an options object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[i] ); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `mode` option which is not a valid index mode', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'mode': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns `null` if all options are valid', function test( t ) { - var expected; - var options; - var opts; - var err; - - options = { - 'mode': 'throw' - }; - opts = {}; - - expected = { - 'mode': 'throw' - }; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function ignores unrecognized options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': 'boop', - 'foo': 5, - 'bar': {} - }; - - opts = {}; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, {}, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 57cb56495..000000000 --- a/test/test.js +++ /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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var objectKeys = require( '@stdlib/utils/keys' ); -var ns = require( './../lib' ); - - -// TESTS // - -tape( 'main export is an object', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ns, 'object', 'main export is an object' ); - t.end(); -}); - -tape( 'the exported object contains key-value pairs', function test( t ) { - var keys = objectKeys( ns ); - t.equal( keys.length > 0, true, 'has keys' ); - t.end(); -}); diff --git a/to-circular-iterator/README.md b/to-circular-iterator/README.md deleted file mode 100644 index b01314249..000000000 --- a/to-circular-iterator/README.md +++ /dev/null @@ -1,324 +0,0 @@ - - -# circarray2iterator - -> Create an iterator which repeatedly iterates over the elements of an array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var circarray2iterator = require( '@stdlib/array/to-circular-iterator' ); -``` - -#### circarray2iterator( src\[, options]\[, mapFcn\[, thisArg]] ) - -Returns an iterator which repeatedly iterates over each element in an array-like `object`. - -```javascript -var it = circarray2iterator( [ 1, 2, 3, 4 ] ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 4 - -// ... -``` - -The returned iterator protocol-compliant object has the following properties: - -- **next**: function which returns an iterator protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the iterator is finished. -- **return**: function which closes an iterator and returns a single (optional) argument in an iterator protocol-compliant object. - -The function accepts the following `options`: - -- **iter**: number of iterations. Default: `1e308`. -- **dir**: iteration direction. If set to `-1`, the iterator iterates over elements from right-to-left. Default: `1`. - -To limit the number of iterations, set the `iter` option. - -```javascript -var opts = { - 'iter': 5 -}; -var it = circarray2iterator( [ 1, 2, 3, 4 ], opts ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - -To iterate over elements from right to left, set the `dir` option to `-1`. - -```javascript -var opts = { - 'dir': -1 -}; -var it = circarray2iterator( [ 1, 2, 3, 4 ], opts ); -// returns - -var v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 3 - -// ... -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function fcn( v ) { - return v * 10.0; -} - -var it = circarray2iterator( [ 1, 2, 3, 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 10.0 - -v = it.next().value; -// returns 20.0 - -v = it.next().value; -// returns 30.0 - -// ... -``` - -The invoked function is provided four arguments: - -- **value**: iterated value. -- **index**: iterated value index. -- **n**: iteration count. -- **src**: source array-like object. - -```javascript -function fcn( v, i ) { - return v * (i+1); -} - -var it = circarray2iterator( [ 1, 2, 3, 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 9 - -// ... -``` - -To set the callback function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return v * 10.0; -} - -var ctx = { - 'count': 0 -}; - -var it = circarray2iterator( [ 1, 2, 3, 4 ], fcn, ctx ); -// returns - -var v = it.next().value; -// returns 10.0 - -v = it.next().value; -// returns 20.0 - -v = it.next().value; -// returns 30.0 - -var count = ctx.count; -// returns 3 -``` - - - - - - - -
- -## Notes - -- If an environment supports `Symbol.iterator`, the returned iterator is iterable. -- If provided a generic `array`, the returned iterator does **not** ignore holes. To achieve greater performance for sparse arrays, use a custom iterator. -- A returned iterator does **not** copy a provided array-like `object`. To ensure iterable reproducibility, copy a provided array-like `object` **before** creating an iterator. Otherwise, any changes to the contents of an array-like `object` will be reflected in the returned iterator. -- In environments supporting `Symbol.iterator`, the function **explicitly** does **not** invoke an array's `@@iterator` method, regardless of whether this method is defined. To convert an array to an implementation defined iterator, invoke this method directly. -- The returned iterator supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]). - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var circarray2iterator = require( '@stdlib/array/to-circular-iterator' ); - -function scale( v, i, n ) { - return v * n; -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 10 ), randu ); - -// Create an iterator from the array which scales iterated values: -var opts = { - 'iter': arr.length * 10 -}; -var it = circarray2iterator( arr, opts, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-circular-iterator/benchmark/benchmark.js b/to-circular-iterator/benchmark/benchmark.js deleted file mode 100644 index 71c93103c..000000000 --- a/to-circular-iterator/benchmark/benchmark.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var circarray2iterator = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var iter; - var i; - - values = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - values[ 0 ] = i; - iter = circarray2iterator( values ); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = [ 1, 2, 3, 4 ]; - - iter = circarray2iterator( values ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration,map', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = [ 1, 2, 3, 4 ]; - - iter = circarray2iterator( values, transform ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v * i; - } -}); diff --git a/to-circular-iterator/docs/repl.txt b/to-circular-iterator/docs/repl.txt deleted file mode 100644 index 3de37f1a7..000000000 --- a/to-circular-iterator/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( src[, options][, mapFcn[, thisArg]] ) - Returns an iterator which repeatedly iterates over the elements of an array- - like object. - - When invoked, an input function is provided four arguments: - - - value: iterated value. - - index: iterated value index. - - n: iteration count. - - src: source array-like object. - - If an environment supports Symbol.iterator, the returned iterator is - iterable. - - If an environment supports Symbol.iterator, the function explicitly does not - invoke an array's `@@iterator` method, regardless of whether this method is - defined. To convert an array to an implementation defined iterator, invoke - this method directly. - - Parameters - ---------- - src: ArrayLikeObject - Array-like object from which to create the iterator. - - options: Object (optional) - Function options. - - options.iter: integer (optional) - Number of iterations. Default: 1e308. - - options.dir: integer (optional) - Iteration direction. If set to `-1`, an iterator iterates over elements - from right-to-left. Default: 1. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - iterator: Object - Iterator. - - iterator.next(): Function - Returns an iterator protocol-compliant object containing the next - iterated value (if one exists) and a boolean flag indicating whether the - iterator is finished. - - iterator.return( [value] ): Function - Finishes an iterator and returns a provided value. - - Examples - -------- - > var it = {{alias}}( [ 1, 2, 3, 4 ] ); - > var v = it.next().value - 1 - > v = it.next().value - 2 - - See Also - -------- - diff --git a/to-circular-iterator/docs/types/index.d.ts b/to-circular-iterator/docs/types/index.d.ts deleted file mode 100644 index 56bdb3fd0..000000000 --- a/to-circular-iterator/docs/types/index.d.ts +++ /dev/null @@ -1,158 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Interface defining function options. -*/ -interface Options { - /** - * Number of iterations. - */ - iter?: number; - - /** - * Iteration direction (default: 1). - */ - dir?: number; -} - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param n - iteration count -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, n: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param n - iteration count -* @param src - source array-like object -* @returns iterator value -*/ -type Quaternary = ( value: any, index: number, n: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param n - iteration count -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary | Quaternary; - -/** -* Returns an iterator which repeatedly iterates over each element in an array-like object. -* -* @param src - input value -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @throws must provide valid options -* @returns iterator -* -* @example -* var iter = circarray2iterator( [ 1, 2, 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 1 -* -* v = iter.next().value; -* // returns 2 -* -* v = iter.next().value; -* // returns 3 -* -* // ... -*/ -declare function circarray2iterator( src: ArrayLike, mapFcn?: MapFunction, thisArg?: any ): Iterator; - -/** -* Returns an iterator which repeatedly iterates over each element in an array-like object. -* -* @param src - input value -* @param options - function options -* @param options.iter - number of iterations -* @param options.dir - iteration direction -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @throws must provide valid options -* @returns iterator -* -* @example -* var opts = { -* 'dir': -1 -* }; -* var it = circarray2iterator( [ 1, 2, 3, 4 ], opts ); -* // returns -* -* var v = it.next().value; -* // returns 4 -* -* v = it.next().value; -* // returns 3 -* -* v = it.next().value; -* // returns 2 -*/ -declare function circarray2iterator( src: ArrayLike, options: Options, mapFcn?: MapFunction, thisArg?: any ): Iterator; - - -// EXPORTS // - -export = circarray2iterator; diff --git a/to-circular-iterator/docs/types/test.ts b/to-circular-iterator/docs/types/test.ts deleted file mode 100644 index 8252de59e..000000000 --- a/to-circular-iterator/docs/types/test.ts +++ /dev/null @@ -1,87 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 circarray2iterator = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - circarray2iterator( [ 1, 2, 3, 4 ] ); // $ExpectType Iterator - circarray2iterator( [ 1, 2, 3, 4 ], times10 ); // $ExpectType Iterator - circarray2iterator( [ 1, 2, 3, 4 ], times10, {} ); // $ExpectType Iterator -} - -// The compiler throws an error if the function is provided a first argument which is not array-like... -{ - circarray2iterator( 123 ); // $ExpectError - circarray2iterator( true ); // $ExpectError - circarray2iterator( false ); // $ExpectError - circarray2iterator( {} ); // $ExpectError - circarray2iterator( null ); // $ExpectError - circarray2iterator( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an options object or function... -{ - circarray2iterator( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], [] ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], true ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], false ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `dir` option which is not a number... -{ - circarray2iterator( [ 1, 2, 3, 4 ], { 'dir': 'abc' } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'dir': true } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'dir': false } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'dir': null } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'dir': [] } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'dir': {} } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'dir': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an `iter` option which is not a number... -{ - circarray2iterator( [ 1, 2, 3, 4 ], { 'iter': 'abc' } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'iter': true } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'iter': false } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'iter': null } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'iter': [] } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'iter': {} } ); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], { 'iter': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - circarray2iterator(); // $ExpectError - circarray2iterator( [ 1, 2, 3, 4 ], times10, {}, 123 ); // $ExpectError -} diff --git a/to-circular-iterator/examples/index.js b/to-circular-iterator/examples/index.js deleted file mode 100644 index dc4a028c6..000000000 --- a/to-circular-iterator/examples/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( './../../float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var circarray2iterator = require( './../lib' ); - -function scale( v, i, n ) { - return v * n; -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 10 ), randu ); - -// Create an iterator from the array which scales iterated values: -var opts = { - 'iter': arr.length * 10 -}; -var it = circarray2iterator( arr, opts, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} diff --git a/to-circular-iterator/lib/index.js b/to-circular-iterator/lib/index.js deleted file mode 100644 index 741cfe316..000000000 --- a/to-circular-iterator/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an iterator which repeatedly iterates over the elements of an array-like object. -* -* @module @stdlib/array/to-circular-iterator -* -* @example -* var circarray2iterator = require( '@stdlib/array/to-circular-iterator' ); -* -* var iter = circarray2iterator( [ 1, 2, 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 1 -* -* v = iter.next().value; -* // returns 2 -* -* v = iter.next().value; -* // returns 3 -* -* // ... -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-circular-iterator/lib/main.js b/to-circular-iterator/lib/main.js deleted file mode 100644 index 2cc406154..000000000 --- a/to-circular-iterator/lib/main.js +++ /dev/null @@ -1,273 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isObject = require( '@stdlib/assert/is-plain-object' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isAccessorArray = require( './../../base/assert/is-accessor-array' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var getter = require( './../../base/getter' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns an iterator which repeatedly iterates over each element in an array-like object. -* -* @param {Collection} src - input value -* @param {Options} [options] - function options -* @param {NonNegativeInteger} [options.iter] - number of iterations -* @param {integer} [options.dir=1] - iteration direction -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @throws {TypeError} callback argument must be a function -* @returns {Iterator} iterator -* -* @example -* var iter = circarray2iterator( [ 1, 2, 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 1 -* -* v = iter.next().value; -* // returns 2 -* -* v = iter.next().value; -* // returns 3 -* -* // ... -*/ -function circarray2iterator( src ) { - var thisArg; - var options; - var count; - var opts; - var iter; - var FLG; - var fcn; - var get; - var dt; - var i; - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); - } - opts = { - 'iter': 1e308, // ~infinity - 'dir': 1 // left to right iteration - }; - if ( arguments.length > 1 ) { - if ( isObject( arguments[ 1 ] ) ) { - options = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - if ( hasOwnProp( options, 'iter' ) ) { - opts.iter = options.iter; - if ( !isNonNegativeInteger( options.iter ) ) { - throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer. Option: `%s`.', 'iter', options.iter ) ); - } - } - if ( hasOwnProp( options, 'dir' ) ) { - opts.dir = options.dir; - if ( options.dir !== 1 && options.dir !== -1 ) { - throw new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', options.dir ) ); - } - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either a function or an options object. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - count = 0; - - // Create an iterator protocol-compliant object: - iter = {}; - if ( fcn ) { - if ( opts.dir === 1 ) { - i = -1; - setReadOnly( iter, 'next', next1a ); - } else { - i = src.length; - setReadOnly( iter, 'next', next1b ); - } - } else if ( opts.dir === 1 ) { - i = -1; - setReadOnly( iter, 'next', next2a ); - } else { - i = src.length; - setReadOnly( iter, 'next', next2b ); - } - setReadOnly( iter, 'return', end ); - - // If an environment supports `Symbol.iterator`, make the iterator iterable: - if ( iteratorSymbol ) { - setReadOnly( iter, iteratorSymbol, factory ); - } - // Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc): - dt = dtype( src ); - if ( isAccessorArray( src ) ) { - get = accessorGetter( dt ); - } else { - get = getter( dt ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next1a() { - i = (i+1) % src.length; - count += 1; - if ( FLG || count > opts.iter || src.length === 0 ) { - return { - 'done': true - }; - } - return { - 'value': fcn.call( thisArg, get( src, i ), i, count, src ), - 'done': false - }; - } - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next1b() { - i -= 1; - if ( i < 0 ) { - i += src.length; - } - count += 1; - if ( FLG || count > opts.iter || src.length === 0 ) { - return { - 'done': true - }; - } - return { - 'value': fcn.call( thisArg, get( src, i ), i, count, src ), - 'done': false - }; - } - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next2a() { - i = (i+1) % src.length; - count += 1; - if ( FLG || count > opts.iter || src.length === 0 ) { - return { - 'done': true - }; - } - return { - 'value': get( src, i ), - 'done': false - }; - } - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next2b() { - i -= 1; - if ( i < 0 ) { - i += src.length; - } - count += 1; - if ( FLG || count > opts.iter || src.length === 0 ) { - return { - 'done': true - }; - } - return { - 'value': get( src, i ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - if ( fcn ) { - return circarray2iterator( src, opts, fcn, thisArg ); - } - return circarray2iterator( src, opts ); - } -} - - -// EXPORTS // - -module.exports = circarray2iterator; diff --git a/to-circular-iterator/package.json b/to-circular-iterator/package.json deleted file mode 100644 index 051f67bc9..000000000 --- a/to-circular-iterator/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "@stdlib/array/to-circular-iterator", - "version": "0.0.0", - "description": "Create an iterator which repeatedly iterates over the elements of an array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "arr", - "typed-array", - "typed array", - "iterator", - "iterate", - "iteration", - "iter", - "to", - "convert", - "circular", - "circ", - "infinite", - "loop", - "repeat" - ] -} diff --git a/to-circular-iterator/test/test.js b/to-circular-iterator/test/test.js deleted file mode 100644 index 84e21c0fa..000000000 --- a/to-circular-iterator/test/test.js +++ /dev/null @@ -1,1067 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var noop = require( '@stdlib/utils/noop' ); -var circarray2iterator = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof circarray2iterator, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - circarray2iterator( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - circarray2iterator( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - circarray2iterator( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (no options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - circarray2iterator( [ 1, 2, 3, 4 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (options)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - circarray2iterator( [ 1, 2, 3, 4 ], {}, value ); - }; - } -}); - -tape( 'the function throws an error if provided an `iter` option which is not a nonnegative integer (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - circarray2iterator( [ 1, 2, 3, 4 ], { - 'iter': value - }); - }; - } -}); - -tape( 'the function throws an error if provided an `iter` option which is not a nonnegative integer (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var opts = { - 'iter': value - }; - circarray2iterator( [ 1, 2, 3, 4 ], opts, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a `dir` option which is neither `1` nor `-1` (no callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - 0, - -5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - circarray2iterator( [ 1, 2, 3, 4 ], { - 'dir': value - }); - }; - } -}); - -tape( 'the function throws an error if provided a `dir` option which is neither `1` nor `-1` (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - 0, - -5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var opts = { - 'dir': value - }; - circarray2iterator( [ 1, 2, 3, 4 ], opts, noop ); - }; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which repeatedly iterates over elements of an array-like object (array)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - } - ]; - - it = circarray2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length*2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object which repeatedly iterates over elements of an array-like object (array; options)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - } - ]; - - it = circarray2iterator( values, {} ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length*2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object which repeatedly iterates over the elements of an array-like object (array-like object)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - } - ]; - - it = circarray2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length*2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object which repeatedly iterates over elements of an array-like object (empty)', function test( t ) { - var expected; - var actual; - var values; - var it; - - values = []; - expected = [ - { - 'done': true - } - ]; - - it = circarray2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = [ it.next() ]; - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = circarray2iterator( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.done, false, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (array-like)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - - it = circarray2iterator( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.done, false, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (empty)', function test( t ) { - var expected; - var actual; - var values; - var it; - - values = []; - - it = circarray2iterator( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = [ - { - 'done': true - } - ]; - actual = [ it.next() ]; - t.deepEqual( actual, expected, 'returns expected values' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - return v; - } -}); - -tape( 'the function supports limiting the number of iterations', function test( t ) { - var expected; - var actual; - var values; - var opts; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'done': true - } - ]; - - opts = { - 'iter': 7 - }; - it = circarray2iterator( values, opts ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < opts.iter; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function supports limiting the number of iterations (callback)', function test( t ) { - var expected; - var actual; - var values; - var opts; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'value': 9, - 'done': false - }, - { - 'value': 16, - 'done': false - }, - { - 'value': 5, - 'done': false - }, - { - 'value': 12, - 'done': false - }, - { - 'value': 21, - 'done': false - }, - { - 'done': true - } - ]; - - opts = { - 'iter': 7 - }; - it = circarray2iterator( values, opts, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < opts.iter; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); - - function scale( v, i, n ) { - return v * n; - } -}); - -tape( 'the function supports specifying the iteration direction', function test( t ) { - var expected; - var actual; - var values; - var opts; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'done': true - } - ]; - - opts = { - 'iter': 7, - 'dir': -1 - }; - it = circarray2iterator( values, opts ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < opts.iter; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function supports specifying the iteration direction (callback)', function test( t ) { - var expected; - var actual; - var values; - var opts; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 6, - 'done': false - }, - { - 'value': 6, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'value': 20, - 'done': false - }, - { - 'value': 18, - 'done': false - }, - { - 'value': 14, - 'done': false - }, - { - 'done': true - } - ]; - - opts = { - 'iter': 7, - 'dir': -1 - }; - it = circarray2iterator( values, opts, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < opts.iter; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); - - function scale( v, i, n ) { - return v * n; - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var it; - var r; - - it = circarray2iterator( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument; callback)', function test( t ) { - var it; - var r; - - it = circarray2iterator( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var it; - var r; - - it = circarray2iterator( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument; callback)', function test( t ) { - var it; - var r; - - it = circarray2iterator( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable', function test( t ) { - var circarray2iterator; - var values; - var it1; - var it2; - var i; - - circarray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = circarray2iterator( values ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (callback)', function test( t ) { - var circarray2iterator; - var values; - var it1; - var it2; - var i; - - circarray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = circarray2iterator( values, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable"', function test( t ) { - var circarray2iterator; - var it; - - circarray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = circarray2iterator( [ 1, 2, 3, 4 ] ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (callback)', function test( t ) { - var circarray2iterator; - var it; - - circarray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = circarray2iterator( [ 1, 2, 3, 4 ], scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/to-fancy/README.md b/to-fancy/README.md deleted file mode 100644 index 6eb870a03..000000000 --- a/to-fancy/README.md +++ /dev/null @@ -1,619 +0,0 @@ - - -# array2fancy - -> Convert an array to an object supporting fancy indexing. - - - -
- -An array supporting **fancy indexing** is an array which supports slicing via indexing expressions for both retrieval and assignment. - -```javascript -var array2fancy = require( '@stdlib/array/to-fancy' ); - -// Create a plain array: -var x = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - -// Turn the plain array into a "fancy" array: -var y = array2fancy( x ); - -// Select the first three elements: -var v = y[ ':3' ]; -// returns [ 1, 2, 3 ] - -// Select every other element, starting from the second element: -v = y[ '1::2' ]; -// returns [ 2, 4, 6, 8 ] - -// Select every other element, in reverse order, starting with the last element: -v = y[ '::-2' ]; -// returns [ 8, 6, 4, 2 ] - -// Set all elements to the same value: -y[ ':' ] = 9; - -// Create a shallow copy by selecting all elements: -v = y[ ':' ]; -// returns [ 9, 9, 9, 9, 9, 9, 9, 9 ] -``` - -
- - - - - -
- -## Usage - -```javascript -var array2fancy = require( '@stdlib/array/to-fancy' ); -``` - -#### array2fancy( x\[, options] ) - -Converts an array to an object supporting fancy indexing. - -```javascript -var Slice = require( '@stdlib/slice/ctor' ); - -var x = [ 1, 2, 3, 4 ]; - -var y = array2fancy( x ); -// returns - -// Normal element access: -var v = y[ 0 ]; -// returns 1 - -v = y[ 1 ]; -// returns 2 - -// Using negative integers: -v = y[ -1 ]; -// returns 4 - -v = y[ -2 ]; -// returns 3 - -// Using subsequence expressions: -v = y[ '1::2' ]; -// returns [ 2, 4 ] - -// Using Slice objects: -v = y[ new Slice( 1, null, 2 ) ]; -// returns [ 2, 4 ] - -// Assignment: -y[ '1:3' ] = 5; -v = y[ ':' ]; -// returns [ 1, 5, 5, 4 ] -``` - -The function supports the following options: - -- **cache**: cache for resolving array index objects. Must have a `get` method which accepts a single argument: a string identifier associated with an array index. - - If an array index associated with a provided identifier exists, the `get` method should return an object having the following properties: - - - **data**: the underlying index array. - - **type**: the index type. Must be either `'mask'`, `'bool'`, or `'int'`. - - **dtype**: the [data type][@stdlib/array/dtypes] of the underlying array. - - If an array index is not associated with a provided identifier, the `get` method should return `null`. - - Default: [`ArrayIndex`][@stdlib/array/index]. - -- **strict**: boolean indicating whether to enforce strict bounds checking. Default: `false`. - -By default, the function returns a fancy array which does **not** enforce strict bounds checking. For example, - -```javascript -var y = array2fancy( [ 1, 2, 3, 4 ] ); - -var v = y[ 10 ]; -// returns undefined -``` - -To enforce strict bounds checking, set the `strict` option to `true`. - - - -```javascript -var y = array2fancy( [ 1, 2, 3, 4 ], { - 'strict': true -}); - -var v = y[ 10 ]; -// throws -``` - -#### array2fancy.factory( \[options] ) - -Returns a function for converting an array to an object supporting fancy indexing. - -```javascript -var fcn = array2fancy.factory(); - -var x = [ 1, 2, 3, 4 ]; - -var y = fcn( x ); -// returns - -var v = y[ ':' ]; -// returns [ 1, 2, 3, 4 ] -``` - -The function supports the following options: - -- **cache**: default cache for resolving array index objects. Must have a `get` method which accepts a single argument: a string identifier associated with an array index. - - If an array index associated with a provided identifier exists, the `get` method should return an object having the following properties: - - - **data**: the underlying index array. - - **type**: the index type. Must be either `'mask'`, `'bool'`, or `'int'`. - - **dtype**: the [data type][@stdlib/array/dtypes] of the underlying array. - - If an array index is not associated with a provided identifier, the `get` method should return `null`. - - Default: [`ArrayIndex`][@stdlib/array/index]. - -- **strict**: boolean indicating whether to enforce strict bounds checking by default. Default: `false`. - -By default, the function returns a function which, by default, does **not** enforce strict bounds checking. For example, - -```javascript -var fcn = array2fancy.factory(); - -var y = fcn( [ 1, 2, 3, 4 ] ); - -var v = y[ 10 ]; -// returns undefined -``` - -To enforce strict bounds checking by default, set the `strict` option to `true`. - - - -```javascript -var fcn = array2fancy.factory({ - 'strict': true -}); -var y = fcn( [ 1, 2, 3, 4 ] ); - -var v = y[ 10 ]; -// throws -``` - -The returned function supports the same options as above. When the returned function is provided option values, those values override the factory method defaults. - -#### array2fancy.idx( x\[, options] ) - -Wraps a provided array as an array index object. - -```javascript -var x = [ 1, 2, 3, 4 ]; - -var idx = array2fancy.idx( x ); -// returns -``` - -For documentation and usage, see [`ArrayIndex`][@stdlib/array/index]. - -
- - - - - -* * * - -
- -## Notes - -- A fancy array shares the **same** data as the provided input array. Hence, any mutations to the returned array will affect the underlying input array and vice versa. -- For operations returning a new array (e.g., when slicing or invoking an instance method), a fancy array returns a new fancy array having the same configuration as specified by `options`. -- A fancy array supports indexing using positive and negative integers (both numeric literals and strings), [`Slice`][@stdlib/slice/ctor] instances, [subsequence expressions][@stdlib/slice/seq2slice], and [index arrays][@stdlib/array/index] (boolean, mask, and integer). -- A fancy array supports all properties and methods of the input array, and, thus, a fancy array can be consumed by any API which supports array-like objects. -- Indexing expressions provide a convenient and powerful means for creating and operating on array views; however, their use does entail a performance cost. Indexing expressions are best suited for interactive use (e.g., in the [REPL][@stdlib/repl]) and scripting. For performance critical applications, prefer equivalent functional APIs supporting array-like objects. -- In older JavaScript environments which do **not** support [`Proxy`][@stdlib/proxy/ctor] objects, the use of indexing expressions is **not** supported. - -### Bounds Checking - -By default, fancy arrays do **not** enforce strict bounds checking across index expressions. The motivation for the default fancy array behavior stems from a desire to maintain parity with plain arrays; namely, the returning of `undefined` when accessing a single non-existent property. - -Accordingly, when `strict` is `false`, one may observe the following behaviors: - - - -```javascript -var x = array2fancy( [ 1, 2, 3, 4 ], { - 'strict': false -}); - -// Access a non-existent property: -var v = x[ 'foo' ]; -// returns undefined - -// Access an out-of-bounds index: -v = x[ 10 ]; -// returns undefined - -v = x[ -10 ]; -// returns undefined - -// Access an out-of-bounds slice: -v = x[ '10:' ]; -// returns [] - -// Access one or more out-of-bounds indices: -var i = array2fancy.idx( [ 10, 20 ] ); -v = x[ i ]; -// throws -``` - -When `strict` is `true`, fancy arrays normalize index behavior and consistently enforce strict bounds checking. - - - -```javascript -var x = array2fancy( [ 1, 2, 3, 4 ], { - 'strict': true -}); - -// Access a non-existent property: -var v = x[ 'foo' ]; -// returns undefined - -// Access an out-of-bounds index: -v = x[ 10 ]; -// throws - -v = x[ -10 ]; -// throws - -// Access an out-of-bounds slice: -v = x[ '10:' ]; -// throws - -// Access one or more out-of-bounds indices: -var i = array2fancy.idx( [ 10, 20 ] ); -v = x[ i ]; -// throws -``` - -### Broadcasting - -Fancy arrays support **broadcasting** in which assigned scalars and single-element arrays are repeated (without additional memory allocation) to match the length of a target array instance. - -```javascript -var y = array2fancy( [ 1, 2, 3, 4 ] ); - -// Broadcast a scalar: -y[ ':' ] = 5; -var v = y[ ':' ]; -// returns [ 5, 5, 5, 5 ] - -// Broadcast a single-element array: -y[ ':' ] = [ 6 ]; -v = y[ ':' ]; -// returns [ 6, 6, 6, 6 ] -``` - -Fancy array broadcasting follows the [same rules][@stdlib/ndarray/base/broadcast-shapes] as for [ndarrays][@stdlib/ndarray/ctor]. Consequently, when assigning arrays to slices, the array on the right-hand-side must be broadcast-compatible with number of elements in the slice. For example, each assignment expression in the following example follows broadcast rules and is thus valid. - -```javascript -var y = array2fancy( [ 1, 2, 3, 4 ] ); - -y[ ':' ] = [ 5, 6, 7, 8 ]; -var v = y[ ':' ]; -// returns [ 5, 6, 7, 8 ] - -y[ '1::2' ] = [ 9, 10 ]; -v = y[ ':' ]; -// returns [ 5, 9, 7, 10 ] - -y[ '1::2' ] = [ 11 ]; -v = y[ ':' ]; -// returns [ 5, 11, 7, 11 ] - -y[ '1::2' ] = 12; -v = y[ ':' ]; -// returns [ 5, 12, 7, 12 ] - -// Out-of-bounds slices (i.e., slices with zero elements): -y[ '10:20' ] = [ 13 ]; -v = y[ ':' ]; -// returns [ 5, 12, 7, 12 ] - -y[ '10:20' ] = 13; -v = y[ ':' ]; -// returns [ 5, 12, 7, 12 ] - -y[ '10:20' ] = []; -v = y[ ':' ]; -// returns [ 5, 12, 7, 12 ] -``` - -However, the following assignment expressions are not valid. - - - -```javascript -var y = array2fancy( [ 1, 2, 3, 4 ] ); - -y[ ':' ] = [ 5, 6 ]; -// throws - -// Out-of-bounds slice (i.e., a slice with zero elements): -y[ '10:20' ] = [ 8, 9, 10, 11 ]; -// throws -``` - -In order to broadcast a nested array element as one would a scalar, one must wrap the element in a single-element array. - -```javascript -var y = array2fancy( [ [ 1, 2 ], [ 3, 4 ] ] ); - -// Assign individual array elements: -y[ ':' ] = [ 5, 6 ]; -var v = y[ ':' ]; -// returns [ 5, 6 ] - -y = array2fancy( [ [ 1, 2 ], [ 3, 4 ] ] ); - -// Broadcast a nested array: -y[ ':' ] = [ [ 5, 6 ] ]; -v = y[ ':' ]; -// returns [ [ 5, 6 ], [ 5, 6 ] ] -``` - -### Casting - -Fancy arrays support [(mostly) safe casts][@stdlib/array/mostly-safe-casts] (i.e., any cast which can be performed without overflow or loss of precision, with the exception of floating-point arrays which are also allowed to downcast from higher precision to lower precision). - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); -var Int32Array = require( '@stdlib/array/int32' ); - -var x = new Int32Array( [ 1, 2, 3, 4 ] ); -var y = array2fancy( x ); - -// 8-bit unsigned integer values can be safely cast to 32-bit signed integer values: -y[ ':' ] = new Uint8Array( [ 5, 6, 7, 8 ] ); -``` - -When attempting to perform an unsafe cast, fancy arrays will raise an exception. - - - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); - -var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -var y = array2fancy( x ); - -// Attempt to assign a non-integer value: -y[ ':' ] = 3.14; -// throws - -// Attempt to assign a negative value: -y[ ':' ] = -3; -// throws -``` - -When assigning a real-valued scalar to a complex number array (e.g., [`Complex128Array`][@stdlib/array/complex128] or [`Complex64Array`][@stdlib/array/complex64]), a fancy array will cast the real-valued scalar to a complex number argument having an imaginary component equal to zero. - -```javascript -var Complex128Array = require( '@stdlib/array/complex128' ); -var real = require( '@stdlib/complex/float64/real' ); -var imag = require( '@stdlib/complex/float64/imag' ); - -var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); -var y = array2fancy( x ); - -// Retrieve the first element: -var v = y[ 0 ]; -// returns - -var re = real( v ); -// returns 1.0 - -var im = imag( v ); -// returns 2.0 - -// Assign a real-valued scalar to the first element: -y[ 0 ] = 9.0; - -v = y[ 0 ]; -// returns - -re = real( v ); -// returns 9.0 - -im = imag( v ); -// returns 0.0 -``` - -
- - - - - -* * * - -
- -## Examples - - - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); -var Int32Array = require( '@stdlib/array/int32' ); -var BooleanArray = require( '@stdlib/array/bool' ); -var array2fancy = require( '@stdlib/array/to-fancy' ); - -var x = [ 1, 2, 3, 4, 5, 6 ]; -var y = array2fancy( x ); -// returns - -// Slice retrieval: -var z = y[ '1::2' ]; -// returns [ 2, 4, 6 ] - -z = y[ '-2::-2' ]; -// returns [ 5, 3, 1 ] - -z = y[ '1:4' ]; -// returns [ 2, 3, 4 ] - -// Slice assignment: -y[ '4:1:-1' ] = 10; -z = y[ ':' ]; -// returns [ 1, 2, 10, 10, 10, 6 ] - -y[ '2:5' ] = [ -10, -9, -8 ]; -z = y[ ':' ]; -// returns [ 1, 2, -10, -9, -8, 6 ] - -// Array index retrieval: -var idx = array2fancy.idx; - -var i = idx( [ 1, 3, 4 ] ); // integer index array -z = y[ i ]; -// returns [ 2, -9, -8 ] - -i = idx( [ true, false, false, true, true, true ] ); // boolean array -z = y[ i ]; -// returns [ 1, -9, -8, 6 ] - -i = idx( new BooleanArray( [ true, false, false, true, true, true ] ) ); // boolean array -z = y[ i ]; -// returns [ 1, -9, -8, 6 ] - -i = idx( new Uint8Array( [ 0, 0, 1, 0, 0, 1 ] ) ); // mask array -z = y[ i ]; -// returns [ 1, 2, -9, -8 ] - -i = idx( new Int32Array( [ 0, 0, 1, 1, 2, 2 ] ) ); // integer index array -z = y[ i ]; -// returns [ 1, 1, 2, 2, -10, -10 ] - -// Array index assignment: -x = [ 1, 2, 3, 4, 5, 6 ]; -y = array2fancy( x ); - -i = idx( [ true, false, true, false, true, false ] ); // boolean array -y[ i ] = 5; -z = y[ ':' ]; -// returns [ 5, 2, 5, 4, 5, 6 ] - -i = idx( new BooleanArray( [ true, false, true, false, true, false ] ) ); // boolean array -y[ i ] = 7; -z = y[ ':' ]; -// returns [ 7, 2, 7, 4, 7, 6 ] - -i = idx( new Uint8Array( [ 1, 1, 1, 0, 0, 0 ] ) ); // mask array -y[ i ] = 8; -z = y[ ':' ]; -// returns [ 7, 2, 7, 8, 8, 8 ] - -i = idx( new Int32Array( [ 5, 3, 2 ] ) ); // integer index array -y[ i ] = [ 9, 10, 11 ]; -z = y[ ':' ]; -// returns [ 7, 2, 11, 10, 8, 9 ] - -i = idx( [ 0, 1 ] ); // integer index array -y[ i ] = -1; -z = y[ ':' ]; -// returns [ -1, -1, 11, 10, 8, 9 ] -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-fancy/benchmark/benchmark.factory.js b/to-fancy/benchmark/benchmark.factory.js deleted file mode 100644 index d1dd1a91e..000000000 --- a/to-fancy/benchmark/benchmark.factory.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var array2fancy = require( './../lib' ); - - -// MAIN // - -bench( pkg+':factory', function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = array2fancy.factory(); - if ( typeof v !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( v ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/to-fancy/benchmark/benchmark.get.js b/to-fancy/benchmark/benchmark.get.js deleted file mode 100644 index 412d65f47..000000000 --- a/to-fancy/benchmark/benchmark.get.js +++ /dev/null @@ -1,241 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var isnan = require( '@stdlib/assert/is-nan' ).isPrimitive; -var zeroTo = require( './../../zero-to' ); -var zeros = require( './../../zeros' ); -var filledarray = require( './../../filled' ); -var Slice = require( '@stdlib/slice/ctor' ); -var pkg = require( './../package.json' ).name; -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// MAIN // - -bench( pkg+'::get,positive_integers:len=1', function benchmark( b ) { - var x; - var v; - var i; - - x = array2fancy( zeroTo( 100, 'generic' ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = x[ i%x.length ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get,negative_integers:len=1', opts, function benchmark( b ) { - var x; - var v; - var i; - - x = array2fancy( zeroTo( 100, 'generic' ) ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = x[ -(i%x.length) ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get,slice:len=1', opts, function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = array2fancy( zeroTo( 100, 'generic' ) ); - values = [ - new Slice( 0, 1 ), - new Slice( 1, 2 ), - new Slice( 2, 3 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = x[ values[ i%values.length ] ]; - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isCollection( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get,subsequence:len=1', opts, function benchmark( b ) { - var values; - var x; - var v; - var i; - - x = array2fancy( zeroTo( 100, 'generic' ) ); - values = [ - ':1', - ':1:', - '0:1:1' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = x[ values[ i%values.length ] ]; - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isCollection( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get,integer_array:len=1', opts, function benchmark( b ) { - var values; - var opts; - var x; - var v; - var i; - - x = array2fancy( zeroTo( 100, 'generic' ) ); - - opts = { - 'persist': true - }; - values = [ - array2fancy.idx( [ 1 ], opts ), - array2fancy.idx( [ 2 ], opts ), - array2fancy.idx( [ 3 ], opts ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = x[ values[ i%values.length ] ]; - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isCollection( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get,mask_array:len=1', opts, function benchmark( b ) { - var values; - var opts; - var x; - var v; - var i; - - x = array2fancy( zeros( 100, 'uint8' ) ); - - opts = { - 'persist': true - }; - values = [ - array2fancy.idx( [ 1 ], opts ), - array2fancy.idx( [ 2 ], opts ), - array2fancy.idx( [ 3 ], opts ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = x[ values[ i%values.length ] ]; - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isCollection( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get,boolean_array:len=1', opts, function benchmark( b ) { - var values; - var opts; - var x; - var v; - var i; - - x = array2fancy( filledarray( true, 100, 'generic' ) ); - - opts = { - 'persist': true - }; - values = [ - array2fancy.idx( [ 1 ], opts ), - array2fancy.idx( [ 2 ], opts ), - array2fancy.idx( [ 3 ], opts ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = x[ values[ i%values.length ] ]; - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isCollection( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/to-fancy/benchmark/benchmark.js b/to-fancy/benchmark/benchmark.js deleted file mode 100644 index ae5fc80e5..000000000 --- a/to-fancy/benchmark/benchmark.js +++ /dev/null @@ -1,55 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var pkg = require( './../package.json' ).name; -var array2fancy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var v; - var i; - - values = [ - [ 1, 2, 3 ], - [ 4, 5, 6 ], - [ 7, 8, 9 ] - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = array2fancy( values[ i%values.length ] ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isCollection( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/to-fancy/benchmark/benchmark.set.js b/to-fancy/benchmark/benchmark.set.js deleted file mode 100644 index 0f3ef99f3..000000000 --- a/to-fancy/benchmark/benchmark.set.js +++ /dev/null @@ -1,195 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/assert/is-nan' ).isPrimitive; -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var zeroTo = require( './../../zero-to' ); -var Slice = require( '@stdlib/slice/ctor' ); -var pkg = require( './../package.json' ).name; -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// MAIN // - -bench( pkg+'::set,positive_integers:len=1', function benchmark( b ) { - var base; - var x; - var v; - var i; - var j; - - base = zeroTo( 100, 'generic' ); - x = array2fancy( base ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = i % x.length; - x[ j ] = i * 2; - v = base[ j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,negative_integers:len=1', opts, function benchmark( b ) { - var base; - var x; - var v; - var i; - var j; - - base = zeroTo( 100, 'generic' ); - x = array2fancy( base ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - j = -( i%x.length ) - 1; - x[ j ] = i * 2; - v = base[ base.length+j ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,slice:len=1', opts, function benchmark( b ) { - var values; - var base; - var x; - var s; - var v; - var i; - - base = zeroTo( 100, 'generic' ); - x = array2fancy( base ); - values = [ - new Slice( 0, 1 ), - new Slice( 1, 2 ), - new Slice( 2, 3 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - s = values[ i%values.length ]; - x[ s ] = i * 2; - v = base[ s.start ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,subsequence:len=1', opts, function benchmark( b ) { - var values; - var base; - var x; - var v; - var i; - - base = zeroTo( 100, 'generic' ); - x = array2fancy( base ); - values = [ - ':1', - ':1:', - '0:1:1' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - x[ values[ i%values.length ] ] = i * 2; - v = base[ 0 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,integer_array:len=1', opts, function benchmark( b ) { - var values; - var base; - var opts; - var idx; - var x; - var v; - var i; - - base = zeroTo( 100, 'generic' ); - x = array2fancy( base ); - - opts = { - 'persist': true - }; - values = [ - array2fancy.idx( [ 0 ], opts ), - array2fancy.idx( [ 1 ], opts ), - array2fancy.idx( [ 2 ], opts ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - idx = values[ i%values.length ]; - x[ idx ] = i * 2; - v = base[ i%3 ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( isnan( v ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/to-fancy/docs/repl.txt b/to-fancy/docs/repl.txt deleted file mode 100644 index ee34eda52..000000000 --- a/to-fancy/docs/repl.txt +++ /dev/null @@ -1,169 +0,0 @@ - -{{alias}}( x[, options] ) - Converts an array to an object supporting fancy indexing. - - An array supporting fancy indexing is an array which supports slicing via - indexing expressions for both retrieval and assignment. - - A fancy array shares the *same* data as the provided input array. Hence, any - mutations to the returned array will affect the underlying input array and - vice versa. - - For operations returning a new array (e.g., when slicing or invoking an - instance method), a fancy array returns a new fancy array having the same - configuration as specified by provided options. - - A fancy array supports indexing using positive and negative integers (both - numeric literals and strings), Slice instances, subsequence expressions, - mask arrays, boolean arrays, and integer arrays. - - A fancy array supports all properties and methods of the input array, and, - thus, a fancy array can be consumed by any API which supports array-like - objects. - - Indexing expressions provide a convenient and powerful means for creating - and operating on array views; however, their use does entail a performance - cost. Indexing expressions are best suited for interactive use (e.g., in the - REPL) and scripting. For performance critical applications, prefer - equivalent functional APIs supporting array-like objects. - - Fancy arrays support broadcasting in which assigned scalars and single- - element arrays are repeated (without additional memory allocation) to match - the length of a target array instance. - - Fancy array broadcasting follows the same rules as for ndarrays. - - Consequently, when assigning arrays to slices, the array on the right-hand- - side must be broadcast-compatible with number of elements in the slice. - - Fancy arrays support (mostly) safe casts (i.e., any cast which can be - performed without overflow or loss of precision, with the exception of - floating-point arrays which are also allowed to downcast from higher - precision to lower precision). - - When attempting to perform an unsafe cast, fancy arrays will raise an - exception. - - When assigning a real-valued scalar to a complex number array (e.g., - Complex128Array or Complex64Array), a fancy array will cast the real-valued - scalar to a complex number argument having an imaginary component equal to - zero. - - In older JavaScript environments which do not support Proxy objects, the use - of indexing expressions is not supported. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - options: Object (optional) - Function options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking. Default: - false. - - options.cache: Object (optional) - Cache for resolving array index objects. Must have a 'get' method which - accepts a single argument: a string identifier associated with an array - index. If an array index associated with a provided identifier exists, - the 'get' method should return an object having the following - properties: - - - data: the underlying index array. - - type: the index type. Must be either 'mask', 'bool', or 'int'. - - dtype: the data type of the underlying array. - - If an array index is not associated with a provided identifier, the - 'get' method should return `null`. - - Default: `{{alias:@stdlib/array/index}}`. - - Returns - ------- - out: Array|TypedArray|Object - Output array supporting fancy indexing. - - Examples - -------- - > var y = {{alias}}( [ 1, 2, 3, 4 ] ); - > y[ '1::2' ] - [ 2, 4 ] - > y[ '::-1' ] - [ 4, 3, 2, 1 ] - - -{{alias}}.factory( [options] ) - Returns a function for converting an array to an object supporting fancy - indexing. - - Parameters - ---------- - options: Object (optional) - Function options. - - options.strict: boolean (optional) - Boolean indicating whether to enforce strict bounds checking by default. - Default: false. - - options.cache: Object (optional) - Cache for resolving array index objects. Must have a 'get' method which - accepts a single argument: a string identifier associated with an array - index. If an array index associated with a provided identifier exists, - the 'get' method should return an object having the following - properties: - - - data: the underlying index array. - - type: the index type. Must be either 'mask', 'bool', or 'int'. - - dtype: the data type of the underlying array. - - If an array index is not associated with a provided identifier, the - 'get' method should return `null`. - - Default: `{{alias:@stdlib/array/index}}`. - - Returns - ------- - fcn: Function - Function for converting an array to an object supporting fancy indexing. - - Examples - -------- - > var f = {{alias}}.factory(); - > var y = f( [ 1, 2, 3, 4 ] ); - > y[ '1::2' ] - [ 2, 4 ] - > y[ '::-1' ] - [ 4, 3, 2, 1 ] - - -{{alias}}.idx( x[, options] ) - Wraps a provided array as an array index object. - - For documentation and usage, see `{{alias:@stdlib/array/index}}`. - - Parameters - ---------- - x: Array|TypedArray|Object - Input array. - - options: Object (optional) - Function options. - - options.persist: boolean (optional) - Boolean indicating whether to continue persisting an index object after - first usage. Default: false. - - Returns - ------- - out: ArrayIndex - ArrayIndex instance. - - Examples - -------- - > var idx = {{alias}}.idx( [ 1, 2, 3, 4 ] ); - - See Also - -------- - diff --git a/to-fancy/docs/types/index.d.ts b/to-fancy/docs/types/index.d.ts deleted file mode 100644 index 91a5cc2fb..000000000 --- a/to-fancy/docs/types/index.d.ts +++ /dev/null @@ -1,332 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, ArrayLike, AccessorArrayLike, ComplexTypedArray, TypedArray, BooleanTypedArray, IndexArrayObject } from '@stdlib/types/array'; -import ArrayIndex = require( './../../../index' ); - -/** -* Interface describing a cache for resolving array index objects. -*/ -interface Cache { - /** - * Returns an array associated with the index object having a provided identifier. - * - * @param id - identifier - * @returns index data - */ - get( id: any ): IndexArrayObject | null; -} - -/** -* Interface describing function options. -*/ -interface Options { - /** - * Boolean indicating whether to enforce strict bounds checking. - */ - strict?: boolean; - - /** - * Cache for resolving array index objects. - */ - cache?: Cache; -} - -/** -* Interface describing the main export. -*/ -interface Array2Fancy { - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array - * - * @example - * var Float64Array = require( './../../../float64' ); - * - * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1.0, 2.0, 3.0, 4.0 ] - * - * @example - * var Float32Array = require( './../../../float32' ); - * - * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1.0, 2.0, 3.0, 4.0 ] - * - * @example - * var Complex128Array = require( './../../../complex128' ); - * - * var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1.0, 2.0, 3.0, 4.0 ] - * - * @example - * var Complex64Array = require( './../../../complex64' ); - * - * var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1.0, 2.0, 3.0, 4.0 ] - * - * @example - * var Int32Array = require( './../../../int32' ); - * - * var x = new Int32Array( [ 1, 2, 3, 4 ] ); - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Int16Array = require( './../../../int16' ); - * - * var x = new Int16Array( [ 1, 2, 3, 4 ] ); - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Int8Array = require( './../../../int8' ); - * - * var x = new Int8Array( [ 1, 2, 3, 4 ] ); - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Uint32Array = require( './../../../uint32' ); - * - * var x = new Uint32Array( [ 1, 2, 3, 4 ] ); - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Uint16Array = require( './../../../uint16' ); - * - * var x = new Uint16Array( [ 1, 2, 3, 4 ] ); - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Uint8Array = require( './../../../uint8' ); - * - * var x = new Uint8Array( [ 1, 2, 3, 4 ] ); - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - * - * @example - * var Uint8ClampedArray = require( './../../../uint8c' ); - * - * var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - */ - ( x: T, options?: Options ): T; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - */ - ( x: Array, options?: Options ): Array; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array - * - * @example - * var toAccessorArray = require( './../../../base/to-accessor-array' ); - * - * var x = toAccessorArray( [ 1, 2, 3, 4 ] ); - * - * var y = array2fancy( x ); - * var v = y[ ':' ]; - */ - ( x: AccessorArrayLike, options?: Options ): AccessorArrayLike; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - */ - ( x: Collection, options?: Options ): Collection; - - /** - * Converts an array-like value to an object supporting fancy indexing. - * - * @param x - input array - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking - * @param options.cache - cache for resolving array index objects - * @returns fancy array - * - * @example - * var x = [ 1, 2, 3, 4 ]; - * - * var y = array2fancy( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - */ - ( x: ArrayLike, options?: Options ): ArrayLike; - - /** - * Returns a function for converting an array to an object supporting fancy indexing. - * - * @param options - function options - * @param options.strict - boolean indicating whether to enforce strict bounds checking by default - * @param options.cache - cache for resolving array index objects - * @returns function for converting an array to an object supporting fancy indexing - * - * @example - * var fcn = array2fancy.factory(); - * - * var x = [ 1, 2, 3, 4 ]; - * - * var y = fcn( x ); - * // returns - * - * var v = y[ ':' ]; - * // returns [ 1, 2, 3, 4 ] - */ - factory( options?: Options ): Array2Fancy; - - /** - * Array index constructor. - * - * @param x - input array - * @param options - function options - * @param options.persist - boolean indicating whether to continue persisting an index object after first usage - * @returns ArrayIndex instance - * - * @example - * var Uint8Array = require( './../../../uint8' ); - * - * var x = new Uint8Array( [ 1, 0, 1, 0 ] ); - * - * var idx = array2fancy.idx( x ); - * // returns - */ - idx: typeof ArrayIndex; -} - -/** -* Converts an array to an object supporting fancy indexing. -* -* @param x - input array -* @param options - function options -* @param options.strict - boolean indicating whether to enforce strict bounds checking -* @param options.cache - cache for resolving array index objects -* @returns fancy array -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* var y = array2fancy( x ); -* // returns -* -* var v = y[ ':' ]; -* // returns [ 1, 2, 3, 4 ] -*/ -declare var array2fancy: Array2Fancy; - - -// EXPORTS // - -export = array2fancy; diff --git a/to-fancy/docs/types/test.ts b/to-fancy/docs/types/test.ts deleted file mode 100644 index 3a3d80e72..000000000 --- a/to-fancy/docs/types/test.ts +++ /dev/null @@ -1,190 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import BooleanArray = require( './../../../bool' ); -import array2fancy = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - array2fancy( [ 1, 2, 3 ] ); // $ExpectType number[] - array2fancy( new Float64Array( [ 1, 2, 3 ] ) ); // $ExpectType Float64Array - array2fancy( new Float32Array( [ 1, 2, 3 ] ) ); // $ExpectType Float32Array - array2fancy( new Int32Array( [ 1, 2, 3 ] ) ); // $ExpectType Int32Array - array2fancy( new Int16Array( [ 1, 2, 3 ] ) ); // $ExpectType Int16Array - array2fancy( new Int8Array( [ 1, 2, 3 ] ) ); // $ExpectType Int8Array - array2fancy( new Uint32Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint32Array - array2fancy( new Uint16Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint16Array - array2fancy( new Uint8Array( [ 1, 2, 3 ] ) ); // $ExpectType Uint8Array - array2fancy( new Uint8ClampedArray( [ 1, 2, 3 ] ) ); // $ExpectType Uint8ClampedArray - array2fancy( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ) ); // $ExpectType Complex128Array - array2fancy( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ) ); // $ExpectType Complex64Array - array2fancy( new BooleanArray( [ true, false, true ] ) ); // $ExpectType BooleanArray - - const opts = { - 'strict': true - }; - array2fancy( [ 1, 2, 3 ], opts ); // $ExpectType number[] - array2fancy( new Float64Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Float64Array - array2fancy( new Float32Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Float32Array - array2fancy( new Int32Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Int32Array - array2fancy( new Int16Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Int16Array - array2fancy( new Int8Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Int8Array - array2fancy( new Uint32Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Uint32Array - array2fancy( new Uint16Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Uint16Array - array2fancy( new Uint8Array( [ 1, 2, 3 ] ), opts ); // $ExpectType Uint8Array - array2fancy( new Uint8ClampedArray( [ 1, 2, 3 ] ), opts ); // $ExpectType Uint8ClampedArray - array2fancy( new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ), opts ); // $ExpectType Complex128Array - array2fancy( new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ), opts ); // $ExpectType Complex64Array - array2fancy( new BooleanArray( [ true, false, true ] ), opts ); // $ExpectType BooleanArray -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like value... -{ - array2fancy( 5 ); // $ExpectError - array2fancy( true ); // $ExpectError - array2fancy( false ); // $ExpectError - array2fancy( null ); // $ExpectError - array2fancy( void 0 ); // $ExpectError - array2fancy( {} ); // $ExpectError - - array2fancy( 5, {} ); // $ExpectError - array2fancy( true, {} ); // $ExpectError - array2fancy( false, {} ); // $ExpectError - array2fancy( null, {} ); // $ExpectError - array2fancy( void 0, {} ); // $ExpectError - array2fancy( {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an object... -{ - const x = [ 1, 2, 3, 4 ]; - - array2fancy( x, '5' ); // $ExpectError - array2fancy( x, 5 ); // $ExpectError - array2fancy( x, true ); // $ExpectError - array2fancy( x, false ); // $ExpectError - array2fancy( x, null ); // $ExpectError - array2fancy( x, [] ); // $ExpectError - array2fancy( x, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `strict` option which is not a boolean... -{ - const x = [ 1, 2, 3, 4 ]; - - array2fancy( x, { 'strict': '5' } ); // $ExpectError - array2fancy( x, { 'strict': 5 } ); // $ExpectError - array2fancy( x, { 'strict': null } ); // $ExpectError - array2fancy( x, { 'strict': [] } ); // $ExpectError - array2fancy( x, { 'strict': {} } ); // $ExpectError - array2fancy( x, { 'strict': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `cache` option which is not valid... -{ - const x = [ 1, 2, 3, 4 ]; - - array2fancy( x, { 'cache': '5' } ); // $ExpectError - array2fancy( x, { 'cache': 5 } ); // $ExpectError - array2fancy( x, { 'cache': true } ); // $ExpectError - array2fancy( x, { 'cache': false } ); // $ExpectError - array2fancy( x, { 'cache': null } ); // $ExpectError - array2fancy( x, { 'cache': [] } ); // $ExpectError - array2fancy( x, { 'cache': {} } ); // $ExpectError - array2fancy( x, { 'cache': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - array2fancy(); // $ExpectError - array2fancy( [ 1, 2, 3 ], {}, {} ); // $ExpectError -} - -// Attached to the function is a `factory` method which returns a function... -{ - array2fancy.factory(); // $ExpectType Array2Fancy - array2fancy.factory( {} ); // $ExpectType Array2Fancy - array2fancy.factory( { 'strict': true } ); // $ExpectType Array2Fancy -} - -// The compiler throws an error if the `factory` method is provided a second argument which is not an object... -{ - array2fancy.factory( '5' ); // $ExpectError - array2fancy.factory( 5 ); // $ExpectError - array2fancy.factory( true ); // $ExpectError - array2fancy.factory( false ); // $ExpectError - array2fancy.factory( null ); // $ExpectError - array2fancy.factory( [] ); // $ExpectError - array2fancy.factory( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided a `strict` option which is not a boolean... -{ - array2fancy.factory( { 'strict': '5' } ); // $ExpectError - array2fancy.factory( { 'strict': 5 } ); // $ExpectError - array2fancy.factory( { 'strict': null } ); // $ExpectError - array2fancy.factory( { 'strict': [] } ); // $ExpectError - array2fancy.factory( { 'strict': {} } ); // $ExpectError - array2fancy.factory( { 'strict': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided a `cache` option which is not valid... -{ - array2fancy.factory( { 'cache': '5' } ); // $ExpectError - array2fancy.factory( { 'cache': 5 } ); // $ExpectError - array2fancy.factory( { 'cache': true } ); // $ExpectError - array2fancy.factory( { 'cache': false } ); // $ExpectError - array2fancy.factory( { 'cache': null } ); // $ExpectError - array2fancy.factory( { 'cache': [] } ); // $ExpectError - array2fancy.factory( { 'cache': {} } ); // $ExpectError - array2fancy.factory( { 'cache': ( x: number ): number => x } ); // $ExpectError -} - -// The compiler throws an error if the `factory` method is provided an unsupported number of arguments... -{ - array2fancy.factory( {}, {} ); // $ExpectError -} - -// Attached to the function is an `idx` method which returns an array index... -{ - const x = [ 1, 2, 3, 4 ]; - const y = [ true, false, true, false ]; - const z = new Uint8Array( [ 1, 0, 1, 0 ] ); - const w = new Int32Array( [ 1, 2, 3, 4 ] ); - const v = new BooleanArray( [ true, false, true, false ] ); - - array2fancy.idx( x ); // $ExpectType GenericIntegerArrayIndex - array2fancy.idx( x, {} ); // $ExpectType GenericIntegerArrayIndex - - array2fancy.idx( y ); // $ExpectType GenericBooleanArrayIndex - array2fancy.idx( y, {} ); // $ExpectType GenericBooleanArrayIndex - - array2fancy.idx( z ); // $ExpectType MaskArrayIndex - array2fancy.idx( z, {} ); // $ExpectType MaskArrayIndex - - array2fancy.idx( w ); // $ExpectType Int32ArrayIndex - array2fancy.idx( w, {} ); // $ExpectType Int32ArrayIndex - - array2fancy.idx( v ); // $ExpectType BooleanArrayIndex - array2fancy.idx( v, {} ); // $ExpectType BooleanArrayIndex -} diff --git a/to-fancy/examples/index.js b/to-fancy/examples/index.js deleted file mode 100644 index 8b53e31ed..000000000 --- a/to-fancy/examples/index.js +++ /dev/null @@ -1,109 +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. -*/ - -'use strict'; - -var Uint8Array = require( './../../uint8' ); -var Int32Array = require( './../../int32' ); -var BooleanArray = require( './../../bool' ); -var array2fancy = require( './../lib' ); - -var x = [ 1, 2, 3, 4, 5, 6 ]; -var y = array2fancy( x ); -// returns - -// Slice retrieval: -var z = y[ '1::2' ]; -console.log( z ); -// => [ 2, 4, 6 ] - -z = y[ '-2::-2' ]; -console.log( z ); -// => [ 5, 3, 1 ] - -z = y[ '1:4' ]; -console.log( z ); -// => [ 2, 3, 4 ] - -// Slice assignment: -y[ '4:1:-1' ] = 10; -z = y[ ':' ]; -console.log( z ); -// => [ 1, 2, 10, 10, 10, 6 ] - -y[ '2:5' ] = [ -10, -9, -8 ]; -z = y[ ':' ]; -console.log( z ); -// => [ 1, 2, -10, -9, -8, 6 ] - -// Array index retrieval: -var idx = array2fancy.idx; - -var i = idx( [ 1, 3, 4 ] ); // integer index array -z = y[ i ]; -console.log( z ); -// => [ 2, -9, -8 ] - -i = idx( [ true, false, false, true, true, true ] ); // boolean array -z = y[ i ]; -console.log( z ); -// => [ 1, -9, -8, 6 ] - -i = idx( new BooleanArray( [ true, false, false, true, true, true ] ) ); // boolean array -z = y[ i ]; -console.log( z ); -// => [ 1, -9, -8, 6 ] - -i = idx( new Uint8Array( [ 0, 0, 1, 0, 0, 1 ] ) ); // mask array -z = y[ i ]; -console.log( z ); -// => [ 1, 2, -9, -8 ] - -i = idx( new Int32Array( [ 0, 0, 1, 1, 2, 2 ] ) ); // integer index array -z = y[ i ]; -console.log( z ); -// => [ 1, 1, 2, 2, -10, -10 ] - -// Array index assignment: -x = [ 1, 2, 3, 4, 5, 6 ]; -y = array2fancy( x ); - -i = idx( [ true, false, true, false, true, false ] ); // boolean array -y[ i ] = 5; -console.log( y ); -// => [ 5, 2, 5, 4, 5, 6 ] - -i = idx( new BooleanArray( [ true, false, true, false, true, false ] ) ); // boolean array -y[ i ] = 7; -console.log( y ); -// => [ 7, 2, 7, 4, 7, 6 ] - -i = idx( new Uint8Array( [ 1, 1, 1, 0, 0, 0 ] ) ); // mask array -y[ i ] = 8; -console.log( y ); -// => [ 7, 2, 7, 8, 8, 8 ] - -i = idx( new Int32Array( [ 5, 3, 2 ] ) ); // integer index array -y[ i ] = [ 9, 10, 11 ]; -console.log( y ); -// => [ 7, 2, 11, 10, 8, 9 ] - -i = idx( [ 0, 1 ] ); // integer index array -y[ i ] = -1; -console.log( y ); -// => [ -1, -1, 11, 10, 8, 9 ] diff --git a/to-fancy/lib/ctor.js b/to-fancy/lib/ctor.js deleted file mode 100644 index 7e83cc7c9..000000000 --- a/to-fancy/lib/ctor.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a trap for constructing new array instances. -* -* @private -* @param {Function} array2fancy - function for creating a proxied array -* @param {Object} opts - options -* @param {boolean} opts.strict - boolean indicating whether to perform strict bounds checking -* @param {Function} opts.cache - cache for resolving array index objects -* @returns {Function} handler -*/ -function factory( array2fancy, opts ) { - return constructor; - - /** - * Trap for constructing new array instances. - * - * @private - * @param {Object} target - target object - * @param {Array} args - list of constructor arguments - * @param {Object} newTarget - constructor that was originally called - * @returns {*} new instance - */ - function constructor( target, args ) { - var x; - var a; - - a = args; - switch ( a.length ) { - case 0: - x = new target(); - break; - case 1: - x = new target( a[0] ); - break; - case 2: - x = new target( a[0], a[1] ); - break; - case 3: - x = new target( a[0], a[1], a[2] ); - break; - case 4: - x = new target( a[0], a[1], a[2], a[3] ); - break; - case 5: - x = new target( a[0], a[1], a[2], a[3], a[4] ); - break; - case 6: - x = new target( a[0], a[1], a[2], a[3], a[4], a[5] ); - break; - case 7: - x = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6] ); - break; - case 8: - x = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7] ); - break; - case 9: - x = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8] ); // eslint-disable-line max-len - break; - case 10: - x = new target( a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9] ); // eslint-disable-line max-len - break; - default: - // Fallback to using `apply`; however, some constructors may error if the constructor is not callable (i.e., if a constructor always requires `new`): - x = target.apply( null, a ); - } - return array2fancy( x, opts ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/to-fancy/lib/defaults.js b/to-fancy/lib/defaults.js deleted file mode 100644 index f9ef5cf88..000000000 --- a/to-fancy/lib/defaults.js +++ /dev/null @@ -1,48 +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. -*/ - -'use strict'; - -// MODULES // - -var ArrayIndex = require( './../../index' ); - - -// MAIN // - -/** -* Returns default options. -* -* @private -* @returns {Object} default options -* -* @example -* var o = defaults(); -* // returns {...} -*/ -function defaults() { - return { - 'cache': ArrayIndex, - 'strict': false - }; -} - - -// EXPORTS // - -module.exports = defaults; diff --git a/to-fancy/lib/error_message.js b/to-fancy/lib/error_message.js deleted file mode 100644 index 09d595193..000000000 --- a/to-fancy/lib/error_message.js +++ /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. -*/ - -'use strict'; - -// MODULES // - -var replace = require( '@stdlib/string/base/replace' ); - - -// MAIN // - -/** -* Returns an updated error message for trapped errors. -* -* @private -* @param {string} msg - error message -* @returns {string} updated message -*/ -function errMessage( msg ) { - return replace( msg, /^invalid arguments?/, 'invalid operation' ); -} - - -// EXPORTS // - -module.exports = errMessage; diff --git a/to-fancy/lib/factory.js b/to-fancy/lib/factory.js deleted file mode 100644 index c5896eb19..000000000 --- a/to-fancy/lib/factory.js +++ /dev/null @@ -1,170 +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. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert/is-collection' ); -var isArrayLike = require( '@stdlib/assert/is-array-like' ); -var Proxy = require( '@stdlib/proxy/ctor' ); -var arraylike2object = require( './../../base/arraylike2object' ); -var assign = require( '@stdlib/object/assign' ); -var format = require( '@stdlib/string/format' ); -var setElementWrapper = require( './set_element_wrapper.js' ); -var getArrayWrapper = require( './get_array_wrapper.js' ); -var hasProxySupport = require( './has_proxy_support.js' ); -var defaults = require( './defaults.js' ); -var validate = require( './validate.js' ); -var validator = require( './validator.js' ); -var ctor = require( './ctor.js' ); -var get = require( './get.js' ); -var set = require( './set.js' ); - - -// MAIN // - -/** -* Returns a function for converting an array to an object supporting fancy indexing. -* -* @param {Options} options - function options -* @param {boolean} [options.strict=false] - boolean indicating whether to enforce strict bounds checking by default -* @param {Function} [options.cache] - default cache for resolving array index objects -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {Function} function for converting an array to an object supporting fancy indexing -* -* @example -* var array2fancy = factory(); -* -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var y = array2fancy( x ); -* // returns -* -* var z = y[ '1::2' ]; -* // returns [ 2, 4, 6 ] -* -* var len = z.length; -* // returns 3 -* -* var v = z[ 0 ]; -* // returns 2 -* -* v = z[ 1 ]; -* // returns 4 -* -* v = z[ 2 ]; -* // returns 6 -*/ -function factory() { - var OPTIONS; - var err; - - OPTIONS = defaults(); - if ( arguments.length ) { - err = validate( OPTIONS, arguments[ 0 ] ); - if ( err ) { - throw err; - } - } - return array2fancy; - - /** - * Converts an array to an object supporting fancy indexing. - * - * @private - * @param {ArrayLike} x - input array - * @param {Options} [options] - function options - * @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking - * @param {Function} [options.cache] - cache for resolving array index objects - * @throws {TypeError} first argument must be array-like - * @throws {TypeError} options argument must be an object - * @throws {TypeError} must provide valid options - * @returns {ArrayLike} fancy array - * - * @example - * var x = [ 1, 2, 3, 4, 5, 6 ]; - * - * var y = array2fancy( x ); - * // returns - * - * var z = y[ '1::2' ]; - * // returns [ 2, 4, 6 ] - * - * var len = z.length; - * // returns 3 - * - * var v = z[ 0 ]; - * // returns 2 - * - * v = z[ 1 ]; - * // returns 4 - * - * v = z[ 2 ]; - * // returns 6 - */ - function array2fancy( x ) { - var opts; - var err; - var arr; - var dt; - var o; - if ( !isArrayLike( x ) && !isCollection( x ) ) { - throw new TypeError( format( 'invalid argument. First argument must be array-like. Value: `%s`.', x ) ); - } - if ( hasProxySupport ) { - opts = assign( {}, OPTIONS ); - if ( arguments.length > 1 ) { - err = validate( opts, arguments[ 1 ] ); - if ( err ) { - throw err; - } - } - arr = arraylike2object( x ); - dt = arr.dtype || ''; - o = { - 'ref': x, - 'dtype': dt, - 'getter': arr.accessors[ 0 ], - 'setter': arr.accessors[ 1 ], - 'preSetElement': setElementWrapper( dt ), - 'postGetArray': getArrayWrapper( array2fancy, opts ), - 'cache': opts.cache, - 'strict': opts.strict, - 'validator': validator( dt ), - 'array2fancy': array2fancy, - 'ctor': new Proxy( x.constructor || Array, { - 'construct': ctor( array2fancy, opts ) - }) - }; - return new Proxy( x, { - 'get': get( o ), - 'set': set( o ) - }); - } - // TODO: replace with `@stdlib/console/warn` (or equivalent once available) - console.warn( 'WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available.' ); // eslint-disable-line no-console - return x; - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/to-fancy/lib/get.js b/to-fancy/lib/get.js deleted file mode 100644 index 7df752c6d..000000000 --- a/to-fancy/lib/get.js +++ /dev/null @@ -1,79 +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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var hasProperty = require( '@stdlib/assert/has-property' ); -var isIntegerString = require( './is_integer_string.js' ); -var isArrayIndexString = require( './is_array_index_string.js' ); -var getElements = require( './get_elements.js' ); -var getElement = require( './get_element.js' ); -var getValue = require( './get_value.js' ); -var getSlice = require( './get_slice.js' ); - - -// MAIN // - -/** -* Returns a trap for retrieving property values. -* -* @private -* @param {Object} ctx - context object -* @param {Function} ctx.getter - accessor for retrieving array elements -* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking -* @param {Function} ctx.ctor - proxied array constructor -* @param {Function} ctx.postGetArray - function to process a retrieved array -* @param {Object} ctx.cache - cache for resolving array index objects -* @returns {Function} handler -*/ -function factory( ctx ) { - return get; - - /** - * Trap for retrieving property values. - * - * @private - * @param {Object} target - target object - * @param {(string|symbol)} property - property name - * @param {Object} receiver - the proxy object or an object inheriting from the proxy - * @throws {Error} invalid slice operation - * @throws {RangeError} slice exceeds array bounds - * @throws {RangeError} index exceeds array bounds - * @returns {*} result - */ - function get( target, property, receiver ) { - if ( isIntegerString( property ) ) { - return getElement( target, property, ctx ); - } - if ( hasProperty( target, property ) || !isString( property ) ) { - return getValue( target, property, receiver, ctx ); - } - if ( isArrayIndexString( property ) ) { - return getElements( target, property, ctx ); - } - return getSlice( target, property, ctx ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/to-fancy/lib/get_array_wrapper.js b/to-fancy/lib/get_array_wrapper.js deleted file mode 100644 index 32ee7e788..000000000 --- a/to-fancy/lib/get_array_wrapper.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Returns a wrapper function for processing arrays after retrieval. -* -* @private -* @param {Function} array2fancy - function for creating a proxied array -* @param {Object} opts - options -* @param {boolean} opts.strict - boolean indicating whether to perform strict bounds checking -* @param {Function} opts.cache - cache for resolving array index objects -* @returns {Function} wrapper function -*/ -function wrapper( array2fancy, opts ) { - return wrap; - - /** - * Returns a proxied array. - * - * @private - * @param {Array} x - input array - * @returns {Array} proxied array - */ - function wrap( x ) { - return array2fancy( x, opts ); - } -} - - -// EXPORTS // - -module.exports = wrapper; diff --git a/to-fancy/lib/get_element.js b/to-fancy/lib/get_element.js deleted file mode 100644 index 9be8b0ffa..000000000 --- a/to-fancy/lib/get_element.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -// MODULES // - -var resolveIndex = require( './resolve_index.js' ); - - -// MAIN // - -/** -* Returns the element associated with a specified index. -* -* @private -* @param {Object} target - target object -* @param {string} property - index string -* @param {Object} ctx - context object -* @param {Function} ctx.getter - accessor for retrieving array elements -* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking -* @throws {RangeError} index exceeds array bounds -* @returns {*} result -*/ -function getElement( target, property, ctx ) { - return ctx.getter( target, resolveIndex( property, target.length, ctx.strict ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = getElement; diff --git a/to-fancy/lib/get_elements.js b/to-fancy/lib/get_elements.js deleted file mode 100644 index 93c649bd0..000000000 --- a/to-fancy/lib/get_elements.js +++ /dev/null @@ -1,62 +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. -*/ - -'use strict'; - -// MODULES // - -var take = require( './../../take' ); -var mskfilter = require( './../../mskfilter' ); -var mskreject = require( './../../mskreject' ); -var format = require( '@stdlib/string/format' ); -var prop2array = require( './prop2array.js' ); - - -// MAIN // - -/** -* Returns the elements specified by an array index. -* -* @private -* @param {Object} target - target object -* @param {string} property - index string -* @param {Object} ctx - context object -* @param {Object} ctx.cache - cache for resolving array index objects -* @param {Function} ctx.postGetArray - function to process a retrieved array -* @throws {Error} invalid array index -* @throws {RangeError} index exceeds array bounds -* @returns {Collection} result -*/ -function getElements( target, property, ctx ) { - var idx = prop2array( property, ctx.cache ); - if ( idx.type === 'int' ) { - return ctx.postGetArray( take( target, idx.data ) ); - } - if ( idx.type === 'bool' ) { - return ctx.postGetArray( mskfilter( target, idx.data ) ); - } - if ( idx.type === 'mask' ) { - return ctx.postGetArray( mskreject( target, idx.data ) ); - } - throw new Error( format( 'invalid operation. Unrecognized array index type. Value: `%s`.', idx.type ) ); -} - - -// EXPORTS // - -module.exports = getElements; diff --git a/to-fancy/lib/get_slice.js b/to-fancy/lib/get_slice.js deleted file mode 100644 index 04f692848..000000000 --- a/to-fancy/lib/get_slice.js +++ /dev/null @@ -1,60 +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. -*/ - -'use strict'; - -// MODULES // - -var slice = require( './../../base/fancy-slice' ); -var errMessage = require( './error_message.js' ); -var prop2slice = require( './prop2slice.js' ); - - -// MAIN // - -/** -* Returns a copy. -* -* @private -* @param {Object} target - target object -* @param {string} property - property name -* @param {Object} ctx - context object -* @param {Function} ctx.postGetArray - function to process a retrieved array -* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking -* @throws {Error} invalid slice operation -* @throws {RangeError} slice exceeds array bounds -* @returns {(Collection|void)} result -*/ -function getSlice( target, property, ctx ) { - var s = prop2slice( target, property, ctx.strict ); - if ( s === null ) { - // Ensure consistency with normal array behavior by returning `undefined` for any "unrecognized" property name: - return; - } - try { - return ctx.postGetArray( slice( target, s, ctx.strict ) ); - } catch ( err ) { - // In principle, we should only error when in "strict" mode and a slice exceeds array bounds... - throw new err.constructor( errMessage( err.message ) ); - } -} - - -// EXPORTS // - -module.exports = getSlice; diff --git a/to-fancy/lib/get_value.js b/to-fancy/lib/get_value.js deleted file mode 100644 index 84ac3951f..000000000 --- a/to-fancy/lib/get_value.js +++ /dev/null @@ -1,70 +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. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert/is-function' ); - - -// MAIN // - -/** -* Returns the property value associated with a specified property. -* -* @private -* @param {Object} target - target object -* @param {(string|symbol)} property - property -* @param {Object} receiver - the proxy object or an object inheriting from the proxy -* @param {Object} ctx - context object -* @param {Function} ctx.ctor - proxied array constructor -* @returns {*} result -*/ -function getValue( target, property, receiver, ctx ) { - var value = target[ property ]; - if ( isFunction( value ) ) { - if ( value === target.constructor ) { - return ctx.ctor; - } - return wrapper; - } - return value; - - /** - * Method wrapper. - * - * @private - * @returns {*} results - */ - function wrapper() { - var args; - var i; - - args = []; - for ( i = 0; i < arguments.length; i++ ) { - args.push( arguments[ i ] ); - } - return value.apply( ( this === receiver ) ? target : this, args ); // eslint-disable-line no-invalid-this - } -} - - -// EXPORTS // - -module.exports = getValue; diff --git a/to-fancy/lib/has_proxy_support.js b/to-fancy/lib/has_proxy_support.js deleted file mode 100644 index 88b26b1b9..000000000 --- a/to-fancy/lib/has_proxy_support.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MODULES // - -var Proxy = require( '@stdlib/proxy/ctor' ); - - -// MAIN // - -/** -* Boolean indicating if an environment has Proxy support. -* -* @private -* @name hasSupport -* @type {boolean} -*/ -var hasSupport = ( typeof Proxy === 'function' ); // NOTE: cannot use `@stdlib/assert/has-proxy-support` here, as that API uses code evaluation and might violate CSPs; consequently, this is a relatively weak check for proxy support - - -// EXPORTS // - -module.exports = hasSupport; diff --git a/to-fancy/lib/index.js b/to-fancy/lib/index.js deleted file mode 100644 index 88895116c..000000000 --- a/to-fancy/lib/index.js +++ /dev/null @@ -1,66 +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. -*/ - -'use strict'; - -/** -* Convert an array to an object supporting fancy indexing. -* -* @module @stdlib/array/to-fancy -* -* @example -* var array2fancy = require( '@stdlib/array/to-fancy' ); -* -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var y = array2fancy( x ); -* // returns -* -* var z = y[ '1::2' ]; -* // returns [ 2, 4, 6 ] -* -* var len = z.length; -* // returns 3 -* -* var v = z[ 0 ]; -* // returns 2 -* -* v = z[ 1 ]; -* // returns 4 -* -* v = z[ 2 ]; -* // returns 6 -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var ArrayIndex = require( './../../index' ); -var main = require( './main.js' ); -var factory = require( './factory.js' ); - - -// MAIN // - -setReadOnly( main, 'factory', factory ); -setReadOnly( main, 'idx', ArrayIndex ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-fancy/lib/is_array_index_string.js b/to-fancy/lib/is_array_index_string.js deleted file mode 100644 index be512b5d2..000000000 --- a/to-fancy/lib/is_array_index_string.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var RE_ARRAY_INDEX = require( './re_array_index.js' ); - - -// MAIN // - -/** -* Tests if an indexing expression is a serialized array index. -* -* @private -* @param {(string|symbol)} prop - property name -* @returns {boolean} result -* -* @example -* var out = isArrayIndexString( 'ArrayIndex<0>' ); -* // returns true -* -* @example -* var out = isArrayIndexString( ':' ); -* // returns false -*/ -function isArrayIndexString( prop ) { - return ( isString( prop ) && RE_ARRAY_INDEX.test( prop ) ); -} - - -// EXPORTS // - -module.exports = isArrayIndexString; diff --git a/to-fancy/lib/is_integer_string.js b/to-fancy/lib/is_integer_string.js deleted file mode 100644 index 84a3d73e1..000000000 --- a/to-fancy/lib/is_integer_string.js +++ /dev/null @@ -1,51 +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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var RE_INTEGER = require( './re_integer.js' ); - - -// MAIN // - -/** -* Tests if an indexing expression is an integer. -* -* @private -* @param {(string|symbol)} prop - property name -* @returns {boolean} result -* -* @example -* var out = isIntegerString( '1' ); -* // returns true -* -* @example -* var out = isIntegerString( ':' ); -* // returns false -*/ -function isIntegerString( prop ) { - return ( isString( prop ) && RE_INTEGER.test( prop ) ); -} - - -// EXPORTS // - -module.exports = isIntegerString; diff --git a/to-fancy/lib/main.js b/to-fancy/lib/main.js deleted file mode 100644 index 024e7a741..000000000 --- a/to-fancy/lib/main.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var factory = require( './factory.js' ); - - -// MAIN // - -/** -* Converts an array to an object supporting fancy indexing. -* -* @name array2fancy -* @type {Function} -* @param {ArrayLike} x - input array -* @param {Options} [options] - function options -* @param {boolean} [options.strict=false] - boolean indicating whether to enforce strict bounds checking -* @param {Function} [options.cache] - cache for resolving array index objects -* @throws {TypeError} first argument must be array-like -* @throws {TypeError} options argument must be an object -* @throws {TypeError} must provide valid options -* @returns {ArrayLike} fancy array -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var y = array2fancy( x ); -* // returns -* -* var z = y[ '1::2' ]; -* // returns [ 2, 4, 6 ] -* -* var len = z.length; -* // returns 3 -* -* var v = z[ 0 ]; -* // returns 2 -* -* v = z[ 1 ]; -* // returns 4 -* -* v = z[ 2 ]; -* // returns 6 -*/ -var array2fancy = factory(); - - -// EXPORTS // - -module.exports = array2fancy; diff --git a/to-fancy/lib/prop2array.js b/to-fancy/lib/prop2array.js deleted file mode 100644 index 18ddd1cd8..000000000 --- a/to-fancy/lib/prop2array.js +++ /dev/null @@ -1,69 +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. -*/ - -'use strict'; - -// MODULES // - -var trim = require( '@stdlib/string/base/trim' ); -var format = require( '@stdlib/string/format' ); - - -// FUNCTIONS // - -/** -* Extracts an array index identifier from an array index indexing expression. -* -* @private -* @param {string} str - input string -* @returns {string} identifier -* -* @example -* var str = 'ArrayIndex<0>'; -* -* var id = getIdentifier( str ); -* // returns '0' -*/ -function getIdentifier( str ) { - return str.substring( 11, str.length-1 ); // ArrayIndex => XX -} - - -// MAIN // - -/** -* Converts an indexing expression to an array index. -* -* @private -* @param {string} property - property name -* @param {Object} cache - cache for resolving array index objects -* @throws {Error} invalid array index -* @returns {(Object|null)} index object (or null) -*/ -function prop2array( property, cache ) { - var o = cache.get( getIdentifier( trim( property ) ) ); - if ( o === null ) { - throw new Error( format( 'invalid operation. Unable to resolve array index. Value: `%s`.', property ) ); - } - return o; -} - - -// EXPORTS // - -module.exports = prop2array; diff --git a/to-fancy/lib/prop2slice.js b/to-fancy/lib/prop2slice.js deleted file mode 100644 index 5d01a8632..000000000 --- a/to-fancy/lib/prop2slice.js +++ /dev/null @@ -1,163 +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. -*/ - -'use strict'; - -// MODULES // - -var trim = require( '@stdlib/string/base/trim' ); -var seq2slice = require( '@stdlib/slice/base/seq2slice' ); -var str2slice = require( '@stdlib/slice/base/str2slice' ); -var startsWith = require( '@stdlib/string/base/starts-with' ); -var format = require( '@stdlib/string/format' ); -var RE_SUBSEQ = require( './re_subseq.js' ); - - -// FUNCTIONS // - -/** -* Tests if an indexing expression is a serialized Slice object. -* -* @private -* @param {string} prop - property name -* @returns {boolean} result -* -* @example -* var out = isSlice( 'Slice(null,null,1)' ); -* // returns true -* -* @example -* var out = isSlice( ':' ); -* // returns false -*/ -function isSlice( prop ) { - return ( - prop[ 0 ] === 'S' && - startsWith( prop, 'Slice(', 0 ) && - prop[ prop.length-1 ] === ')' - ); -} - -/** -* Tests if an indexing expression is a subsequence. -* -* @private -* @param {string} prop - property name -* @returns {boolean} result -* -* @example -* var out = isSubsequence( '::-2' ); -* // returns true -* -* @example -* var out = isSubsequence( '-2' ); -* // returns false -*/ -function isSubsequence( prop ) { - // TODO: consider whether to make this check more robust (e.g., should we actually throw if someone tries to access `foo:bar`? If we make this check more exact, how would we distinguish between a non-existent `foo:bar` property and an actual error in the subsequence string?) - return RE_SUBSEQ.test( prop ); -} - -/** -* Parses a serialized Slice object. -* -* @private -* @param {string} raw - original unprocessed input string -* @param {string} str - serialized Slice object -* @throws {Error} invalid slice operation -* @returns {Slice} Slice object -* -* @example -* var s = parseSlice( ' Slice(null,null,1) ', 'Slice(null,null,1)' ); -* // returns -*/ -function parseSlice( raw, str ) { - var s = str2slice( str ); - if ( s === null ) { - throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) ); - } - return s; -} - -/** -* Parses a subsequence string. -* -* @private -* @param {string} raw - original unprocessed input string -* @param {string} str - subsequence string -* @param {NonNegativeInteger} max - index upper bound -* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking -* @throws {Error} invalid slice operation -* @throws {RangeError} slice exceeds array bounds -* @returns {Slice} Slice object -* -* @example -* var s = parseSubsequence( ' ::-2 ', '::-2', 10, false ); -* // returns -*/ -function parseSubsequence( raw, str, max, strict ) { - var s = seq2slice( str, max, true ); - if ( s.code ) { - if ( s.code === 'ERR_SLICE_INVALID_INCREMENT' ) { - throw new Error( format( 'invalid operation. A subsequence increment must be a non-zero integer. Value: `%s`.', raw ) ); - } - if ( s.code === 'ERR_SLICE_INVALID_SUBSEQUENCE' ) { - throw new Error( format( 'invalid operation. Unsupported slice operation. Value: `%s`.', raw ) ); - } - // NOTE: the following error check must come last due to fall-through when in non-strict mode... - if ( s.code === 'ERR_SLICE_OUT_OF_BOUNDS' ) { - if ( strict ) { - throw new RangeError( format( 'invalid operation. Slice exceeds array bounds.' ) ); - } - // Repeat parsing, this time allowing for out-of-bounds slices: - s = seq2slice( str, max, false ); - } - } - return s; -} - - -// MAIN // - -/** -* Converts an indexing expression to a Slice object. -* -* @private -* @param {Object} target - target object -* @param {string} property - property name -* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking -* @throws {Error} invalid slice operation -* @throws {RangeError} slice exceeds array bounds -* @returns {(Slice|null)} slice object (or null) -*/ -function prop2slice( target, property, strict ) { - var prop = trim( property ); - if ( isSlice( prop ) ) { - return parseSlice( property, prop ); - } - if ( isSubsequence( prop ) ) { - return parseSubsequence( property, prop, target.length, strict ); - } - // Everything else (including undefined/non-existent properties): - return null; -} - - -// EXPORTS // - -module.exports = prop2slice; diff --git a/to-fancy/lib/re_array_index.js b/to-fancy/lib/re_array_index.js deleted file mode 100644 index 10046eaa5..000000000 --- a/to-fancy/lib/re_array_index.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Regular expression for testing whether a string is a serialized array index. -* -* @private -* @name RE_ARRAY_INDEX -* @type {RegExp} -* -* @example -* var bool = RE_ARRAY_INDEX.test( 'ArrayIndex<0>' ); -* // returns true -* -* @example -* var bool = RE_ARRAY_INDEX.test( '0' ); -* // returns false -* -* @example -* var bool = RE_ARRAY_INDEX.test( 'Slice(0,10,2)' ); -* // returns false -*/ -var RE_ARRAY_INDEX = /\s*ArrayIndex<[^>]+>\s*/; - - -// EXPORTS // - -module.exports = RE_ARRAY_INDEX; diff --git a/to-fancy/lib/re_integer.js b/to-fancy/lib/re_integer.js deleted file mode 100644 index e1ae210d5..000000000 --- a/to-fancy/lib/re_integer.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Regular expression for testing whether a string is an integer string. -* -* @private -* @name RE_INTEGER -* @type {RegExp} -* -* @example -* var bool = RE_INTEGER.test( '10' ); -* // returns true -* -* @example -* var bool = RE_INTEGER.test( '-1' ); -* // returns true -* -* @example -* var bool = RE_INTEGER.test( '0:10:2' ); -* // returns false -*/ -var RE_INTEGER = /^-?[0-9]+$/; - - -// EXPORTS // - -module.exports = RE_INTEGER; diff --git a/to-fancy/lib/re_subseq.js b/to-fancy/lib/re_subseq.js deleted file mode 100644 index 6457c3ec8..000000000 --- a/to-fancy/lib/re_subseq.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Regular expression for testing whether a string is a subsequence string. -* -* @private -* @name RE_SUBSEQ -* @type {RegExp} -* -* @example -* var bool = RE_SUBSEQ.test( '0:10:2' ); -* // returns true -* -* @example -* var bool = RE_SUBSEQ.test( '0' ); -* // returns false -* -* @example -* var bool = RE_SUBSEQ.test( 'Slice(0,10,2)' ); -* // returns false -*/ -var RE_SUBSEQ = /:/; - - -// EXPORTS // - -module.exports = RE_SUBSEQ; diff --git a/to-fancy/lib/resolve_index.js b/to-fancy/lib/resolve_index.js deleted file mode 100644 index a5861dd64..000000000 --- a/to-fancy/lib/resolve_index.js +++ /dev/null @@ -1,66 +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. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray/base/normalize-index' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Resolves an integer index from an integer string. -* -* @private -* @param {string} str - integer string -* @param {NonNegativeInteger} max - index upper bound (exclusive) -* @param {boolean} strict - boolean indicating whether to enforce strict bounds checking -* @throws {RangeError} index exceeds array bounds -* @returns {integer} integer index -* -* @example -* var idx = resolveIndex( '-1', 10, false ); -* // returns 9 -* -* @example -* var idx = resolveIndex( '-20', 10, false ); -* // returns -20 -*/ -function resolveIndex( str, max, strict ) { - var idx; - var i; - - idx = parseInt( str, 10 ); - i = normalizeIndex( idx, max-1 ); - if ( i === -1 ) { - if ( strict ) { - throw new RangeError( format( 'invalid operation. Index exceeds array bounds.' ) ); - } - // Return the non-normalized index, as this should fallback to default property handling and returning "undefined": - return idx; - } - return i; -} - - -// EXPORTS // - -module.exports = resolveIndex; diff --git a/to-fancy/lib/set.js b/to-fancy/lib/set.js deleted file mode 100644 index ca936df5c..000000000 --- a/to-fancy/lib/set.js +++ /dev/null @@ -1,90 +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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var hasProperty = require( '@stdlib/assert/has-property' ); -var isIntegerString = require( './is_integer_string.js' ); -var isArrayIndexString = require( './is_array_index_string.js' ); -var setElements = require( './set_elements.js' ); -var setElement = require( './set_element.js' ); -var setValue = require( './set_value.js' ); -var setSlice = require( './set_slice.js' ); - - -// MAIN // - -/** -* Returns a trap for setting property values. -* -* @private -* @param {Object} ctx - context object -* @param {string} ctx.dtype - array data type -* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking -* @param {Function} ctx.validator - function for validating new values -* @param {Function} ctx.setter - accessor for setting array elements -* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary) -* @returns {Function} handler -*/ -function factory( ctx ) { - return set; - - /** - * Trap for setting property values. - * - * @private - * @param {Object} target - target object - * @param {(string|symbol)} property - property name - * @param {*} value - new value - * @param {Object} receiver - the proxy object or an object inheriting from the proxy - * @throws {Error} invalid slice operation - * @throws {Error} assigned value must be broadcast compatible with output array view - * @throws {TypeError} assigned value cannot be safely cast to the output array data type - * @throws {TypeError} slice exceeds array bounds - * @throws {TypeError} index exceeds array bounds - * @returns {boolean} boolean indicating whether assignment succeeded - */ - function set( target, property, value, receiver ) { - var out; - - // Note that we need to check for an integer string *before* checking for an own property, as we want to explicitly handle *all* indexed properties, not just negative integers, in order to perform assignment validation... - if ( isIntegerString( property ) ) { - return setElement( target, property, value, ctx ); - } - if ( hasProperty( target, property ) || !isString( property ) ) { - return setValue( target, property, value, ctx ); - } - if ( isArrayIndexString( property ) ) { - return setElements( target, property, value, ctx ); - } - out = setSlice( target, property, value, receiver, ctx ); - if ( out ) { - return out; - } - // If we were unsuccessful (e.g., due to an invalid subsequence, etc), set the "property" in the same way as would any normal property (e.g., if an indexing expression is an invalid subsequence, assign as would a regular property: `i = 'a:b:c'` => `x[i] = 1` => `v = x[i]` => `v === 1`): - return setValue( target, property, value, ctx ); - } -} - - -// EXPORTS // - -module.exports = factory; diff --git a/to-fancy/lib/set_element.js b/to-fancy/lib/set_element.js deleted file mode 100644 index 63498a95e..000000000 --- a/to-fancy/lib/set_element.js +++ /dev/null @@ -1,66 +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. -*/ - -'use strict'; - -// MODULES // - -var resolveIndex = require( './resolve_index.js' ); - - -// MAIN // - -/** -* Sets the element associated with a specified index. -* -* @private -* @param {Object} target - target object -* @param {string} property - index string -* @param {*} value - new value -* @param {Object} ctx - context object -* @param {Function} ctx.setter - accessor for setting array elements -* @param {string} ctx.dtype - target array data type -* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking -* @param {Function} ctx.validator - function for validating new values -* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary) -* @throws {TypeError} assigned value cannot be safely cast to the target array data type -* @throws {TypeError} target array must have a supported data type -* @throws {RangeError} index exceeds array bounds -* @returns {boolean} boolean indicating whether assignment succeeded -*/ -function setElement( target, property, value, ctx ) { - var err; - var v; - - err = ctx.validator( value, ctx.dtype ); - if ( err ) { - throw err; - } - if ( ctx.preSetElement ) { - v = ctx.preSetElement( value ); - } else { - v = value; - } - ctx.setter( target, resolveIndex( property, target.length, ctx.strict ), v ); // eslint-disable-line max-len - return true; -} - - -// EXPORTS // - -module.exports = setElement; diff --git a/to-fancy/lib/set_element_wrapper.js b/to-fancy/lib/set_element_wrapper.js deleted file mode 100644 index c06b72160..000000000 --- a/to-fancy/lib/set_element_wrapper.js +++ /dev/null @@ -1,65 +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. -*/ - -'use strict'; - -// MODULES // - -var isComplexDataType = require( './../../base/assert/is-complex-floating-point-data-type' ); -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; - - -// FUNCTIONS // - -/** -* Normalizes values assigned to complex number arrays. -* -* @private -* @param {*} value - input value -* @returns {(ComplexLike|*)} output value -*/ -function wrapComplex( value ) { - // Wrap real-valued scalars as valid input arguments to complex number arrays... - if ( isNumber( value ) ) { - return [ value, 0.0 ]; // note: we're assuming that a ComplexXXArray setter accepts an array of interleaved real and imaginary components - } - // For everything other than a real-valued scalar, we delegate validation to the target complex number array: - return value; -} - - -// MAIN // - -/** -* Returns a wrapper function for processing scalar input values before assignment. -* -* @private -* @param {string} dtype - array data type -* @returns {(Function|null)} wrapper function or null -*/ -function wrapper( dtype ) { - if ( isComplexDataType( dtype ) ) { - return wrapComplex; - } - return null; -} - - -// EXPORTS // - -module.exports = wrapper; diff --git a/to-fancy/lib/set_elements.js b/to-fancy/lib/set_elements.js deleted file mode 100644 index fb5162080..000000000 --- a/to-fancy/lib/set_elements.js +++ /dev/null @@ -1,130 +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. -*/ - -'use strict'; - -// MODULES // - -var isMostlySafeCast = require( './../../base/assert/is-mostly-safe-data-type-cast' ); -var isRealDataType = require( './../../base/assert/is-real-data-type' ); -var isComplexDataType = require( './../../base/assert/is-complex-floating-point-data-type' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var scalar2array = require( './../../from-scalar' ); -var dtype = require( './../../dtype' ); -var put = require( './../../put' ); -var place = require( './../../place' ); -var convert = require( './../../convert' ); -var where = require( './../../base/where' ).assign; -var format = require( '@stdlib/string/format' ); -var prop2array = require( './prop2array.js' ); -var errMessage = require( './error_message.js' ); - - -// MAIN // - -/** -* Replaces the elements specified by an array index. -* -* @private -* @param {Object} target - target object -* @param {string} property - index string -* @param {*} value - new value(s) -* @param {Object} ctx - context object -* @param {string} ctx.dtype - array data type -* @param {Object} ctx.cache - cache for resolving array index objects -* @param {Function} ctx.validator - function for validating new values -* @param {(Function|null)} ctx.preSetElement - function for normalizing new values (if necessary) -* @throws {Error} invalid array index -* @throws {RangeError} index exceeds array bounds -* @throws {Error} assigned value must be broadcast compatible with target array selection -* @throws {TypeError} assigned value cannot be safely cast to the target array data type -* @throws {TypeError} target array must have a supported data type -* @returns {boolean} boolean indicating whether assignment succeeded -*/ -function setElements( target, property, value, ctx ) { - var tdt; - var vdt; - var idx; - var err; - var v; - - idx = prop2array( property, ctx.cache ); - tdt = ctx.dtype || 'generic'; - if ( isCollection( value ) ) { - // When handling collections, we delegate to implementation APIs (see below) to perform argument validation (e.g., ensuring a (mostly) safe cast, broadcast compatibility, etc), so we just reassign the value here: - v = value; - } else { - // When provided a "scalar", we need to check whether the value can be safely cast to the target array data type: - err = ctx.validator( value, tdt ); - if ( err ) { - throw err; - } - if ( ctx.preSetElement ) { - v = ctx.preSetElement( value ); - } else { - v = value; - } - // As the scalar can be safely cast, convert the scalar to an array having the same data type as the target array to allow for broadcasting during assignment: - v = scalar2array( v, tdt ); - vdt = tdt; - } - if ( idx.type === 'int' ) { - try { - put( target, idx.data, v ); // note: defer to `put` for ensuring a mostly safe cast - } catch ( err ) { - throw new err.constructor( errMessage( err.message ) ); - } - return true; - } - if ( idx.type === 'bool' ) { - try { - place( target, idx.data, v, { - 'mode': 'strict_broadcast' - }); - } catch ( err ) { - throw new err.constructor( errMessage( err.message ) ); - } - return true; - } - if ( vdt === void 0 ) { - vdt = dtype( value ) || 'generic'; - } - // Safe casts are always allowed and allow same kind casts (i.e., downcasts) only when the target array data type is floating-point... - if ( !isMostlySafeCast( vdt, tdt ) ) { - throw new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, tdt ) ); - } - // When performing a real-to-complex assignment, interpret the real-valued array as containing real components with implied imaginary components equal to zero and explicitly convert to a complex-valued array... - if ( isComplexDataType( tdt ) && isRealDataType( vdt ) ) { - v = convert( v, tdt ); - } - if ( idx.type === 'mask' ) { - // NOTE: we intentionally deviate from boolean array indexing here and interpret the mask as applying to both the target and values array, thus requiring that the assigned value array be broadcast compatible with the target array and NOT just the selected elements as in boolean array indexing - try { - where( idx.data, target, v, target, 1, 0 ); - } catch ( err ) { - throw new err.constructor( errMessage( err.message ) ); - } - return true; - } - throw new Error( format( 'invalid operation. Unrecognized array index type. Value: `%s`.', idx.type ) ); -} - - -// EXPORTS // - -module.exports = setElements; diff --git a/to-fancy/lib/set_slice.js b/to-fancy/lib/set_slice.js deleted file mode 100644 index 2f18383b1..000000000 --- a/to-fancy/lib/set_slice.js +++ /dev/null @@ -1,84 +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. -*/ - -'use strict'; - -// MODULES // - -var isCollection = require( '@stdlib/assert/is-collection' ); -var sliceAssign = require( './../../base/fancy-slice-assign' ); -var scalar2array = require( './../../from-scalar' ); -var prop2slice = require( './prop2slice.js' ); -var errMessage = require( './error_message.js' ); - - -// MAIN // - -/** -* Sets element values belonging to the array view specified by an indexing expression. -* -* @private -* @param {Object} target - target object -* @param {string} property - indexing expression -* @param {*} value - new value -* @param {Object} receiver - the proxy object or an object inheriting from the proxy -* @param {Object} ctx - context object -* @param {string} ctx.dtype - array data type -* @param {boolean} ctx.strict - boolean indicating whether to enforce strict bounds checking -* @param {Function} ctx.validator - function for validating new values -* @throws {Error} invalid slice operation -* @throws {RangeError} slice exceeds array bounds -* @throws {Error} assigned value must be broadcast compatible with target array view -* @throws {TypeError} assigned value cannot be safely cast to the target array data type -* @throws {TypeError} target array must have a supported data type -* @returns {boolean} boolean indicating whether assignment succeeded -*/ -function setSlice( target, property, value, receiver, ctx ) { - var err; - var s; - var v; - - s = prop2slice( target, property, ctx.strict ); - if ( s === null ) { - // If unable to parse the property as an indexing expression, signal that we were unable to perform slice assignment: - return false; - } - if ( isCollection( value ) ) { - // When handling collections, we delegate to `sliceAssign` (see below) to perform argument validation (e.g., ensuring a (mostly) safe cast, broadcast compatibility, etc), so we just reassign the value here: - v = value; - } else { - // When provided a "scalar", we need to check whether the value can be safely cast to the target array data type: - err = ctx.validator( value, ctx.dtype ); - if ( err ) { - throw err; - } - // As the scalar can be safely cast, convert the scalar to an array having the same data type as the target array to allow for broadcasting during slice assignment: - v = scalar2array( value, ctx.dtype || 'generic' ); - } - try { - sliceAssign( v, receiver, s, ctx.strict ); - } catch ( err ) { - throw new err.constructor( errMessage( err.message ) ); - } - return true; -} - - -// EXPORTS // - -module.exports = setSlice; diff --git a/to-fancy/lib/set_value.js b/to-fancy/lib/set_value.js deleted file mode 100644 index 1bdb801cb..000000000 --- a/to-fancy/lib/set_value.js +++ /dev/null @@ -1,40 +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. -*/ - -'use strict'; - -// MAIN // - -/** -* Sets the value associated with a specified property. -* -* @private -* @param {Object} target - target object -* @param {string} property - property -* @param {*} value - new value -* @returns {boolean} boolean indicating whether assignment succeeded -*/ -function setValue( target, property, value ) { - target[ property ] = value; - return true; -} - - -// EXPORTS // - -module.exports = setValue; diff --git a/to-fancy/lib/validate.js b/to-fancy/lib/validate.js deleted file mode 100644 index 84510e404..000000000 --- a/to-fancy/lib/validate.js +++ /dev/null @@ -1,74 +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. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert/is-plain-object' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isMethodIn = require( '@stdlib/assert/is-method-in' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Validates function options. -* -* @private -* @param {Object} opts - destination object -* @param {Options} options - function options -* @param {boolean} [options.strict] - boolean indicating whether to enforce strict bounds checking -* @param {Function} [options.cache] - cache for resolving array index objects -* @returns {(Error|null)} null or an error object -* -* @example -* var opts = {}; -* var options = { -* 'strict': false -* }; -* var err = validate( opts, options ); -* if ( err ) { -* throw err; -* } -*/ -function validate( opts, options ) { - if ( !isObject( options ) ) { - return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); - } - if ( hasOwnProp( options, 'strict' ) ) { - opts.strict = options.strict; - if ( !isBoolean( opts.strict ) ) { - return new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'strict', opts.strict ) ); - } - } - if ( hasOwnProp( options, 'cache' ) ) { - opts.cache = options.cache; - if ( !isMethodIn( opts.cache, 'get' ) ) { - return new TypeError( format( 'invalid option. `%s` option is missing a `%s` method. Option: `%s`.', 'cache', 'get', opts.cache ) ); - } - } - return null; -} - - -// EXPORTS // - -module.exports = validate; diff --git a/to-fancy/lib/validator.js b/to-fancy/lib/validator.js deleted file mode 100644 index c34b0456e..000000000 --- a/to-fancy/lib/validator.js +++ /dev/null @@ -1,241 +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. -*/ - -'use strict'; - -// MODULES // - -var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive; -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isComplexLike = require( '@stdlib/assert/is-complex-like' ); -var isRealFloatingDataType = require( './../../base/assert/is-real-floating-point-data-type' ); -var isUnsignedIntegerDataType = require( './../../base/assert/is-unsigned-integer-data-type' ); -var isSignedIntegerDataType = require( './../../base/assert/is-signed-integer-data-type' ); -var isBooleanDataType = require( './../../base/assert/is-boolean-data-type' ); -var isSafeCast = require( './../../base/assert/is-safe-data-type-cast' ); -var minDataType = require( './../../min-dtype' ); -var minSignedIntegerDataType = require( './../../base/min-signed-integer-dtype' ); -var complexDataType = require( '@stdlib/complex/dtype' ); -var format = require( '@stdlib/string/format' ); - - -// FUNCTIONS // - -/** -* Verifies whether a provided value can be safely assigned to an element in an array having a "generic" or unknown data type. -* -* @private -* @param {*} value - input value -* @param {string} dtype - array data type -* @returns {null} null -* -* @example -* var err = validateGeneric( 3, 'generic' ); -* // returns null -*/ -function validateGeneric() { - return null; -} - -/** -* Verifies whether a provided value can be safely assigned to an element in an array having a boolean data type. -* -* @private -* @param {*} value - input value -* @param {string} dtype - array data type -* @returns {(Error|null)} error object or null -* -* @example -* var err = validateBoolean( true, 'bool' ); -* // returns null -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var err = validateBoolean( new Complex128( 5.0, 6.0 ), 'bool' ); -* // returns -*/ -function validateBoolean( value, dtype ) { - if ( isBoolean( value ) ) { - return null; - } - return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) ); -} - -/** -* Verifies whether a provided value can be safely assigned to an element in an array having a real-valued floating-point data type. -* -* @private -* @param {*} value - input value -* @param {string} dtype - array data type -* @returns {(Error|null)} error object or null -* -* @example -* var err = validateRealFloating( 3.14, 'float64' ); -* // returns null -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var err = validateRealFloating( new Complex128( 5.0, 6.0 ), 'float64' ); -* // returns -*/ -function validateRealFloating( value, dtype ) { - if ( isNumber( value ) ) { - return null; - } - if ( isComplexLike( value ) ) { - return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) ); - } - return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) ); -} - -/** -* Verifies whether a provided value can be safely assigned to an element in an array having a complex-valued floating-point data type. -* -* @private -* @param {*} value - input value -* @param {string} dtype - array data type -* @returns {(Error|null)} error object or null -* -* @example -* var Complex128 = require( '@stdlib/complex/float64/ctor' ); -* -* var err = validateComplexFloating( new Complex128( 5.0, 6.0 ), 'complex128' ); -* // returns null -* -* @example -* var err = validateComplexFloating( {}, 'complex128' ); -* // returns -*/ -function validateComplexFloating( value, dtype ) { - if ( isNumber( value ) || isComplexLike( value ) ) { - return null; - } - return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) ); -} - -/** -* Verifies whether a provided value can be safely assigned to an element in an array having a signed integer data type. -* -* @private -* @param {*} value - input value -* @param {string} dtype - array data type -* @returns {(Error|null)} error object or null -* -* @example -* var err = validateSignedInteger( 3, 'int32' ); -* // returns null -* -* @example -* var err = validateSignedInteger( 3.14, 'int32' ); -* // returns -*/ -function validateSignedInteger( value, dtype ) { - var vdt; - if ( isNumber( value ) ) { - if ( !isInteger( value ) ) { - return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', minDataType( value ), dtype ) ); - } - vdt = minSignedIntegerDataType( value ); - if ( isSafeCast( vdt, dtype ) ) { - return null; - } - return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) ); - } - if ( isComplexLike( value ) ) { - return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) ); - } - return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) ); -} - -/** -* Verifies whether a provided value can be safely assigned to an element in an array having an unsigned integer data type. -* -* @private -* @param {*} value - input value -* @param {string} dtype - array data type -* @returns {(Error|null)} error object or null -* -* @example -* var err = validateUnsignedInteger( 3, 'uint32' ); -* // returns null -* -* @example -* var err = validateUnsignedInteger( -3, 'uint32' ); -* // returns -*/ -function validateUnsignedInteger( value, dtype ) { - var vdt; - if ( isNumber( value ) ) { - vdt = minDataType( value ); // note: we rely on data type resolution to handle the case where `value` is a non-integer value. In that case, `vdt` will resolve to a floating-point data type and `isSafeCast` will evaluate to `false` - if ( isSafeCast( vdt, dtype ) ) { - return null; - } - return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', vdt, dtype ) ); - } - if ( isComplexLike( value ) ) { - return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', complexDataType( value ), dtype ) ); - } - return new TypeError( format( 'invalid operation. Assigned value cannot be safely cast to the target array data type. Data types: [%s, %s].', typeof value, dtype ) ); -} - - -// MAIN // - -/** -* Returns a validation function for verifying whether a provided value can be safely assigned to an element in an array having a specified data type. -* -* @private -* @param {string} dtype - array data type -* @returns {Function} validation function -* -* @example -* var fcn = validator( 'int32' ); -* -* var err = fcn( 3, 'int32' ); -* // returns null -* -* err = fcn( 3.14, 'int32' ); -* // returns -*/ -function validator( dtype ) { - if ( dtype === 'generic' || dtype === '' ) { - return validateGeneric; - } - if ( isRealFloatingDataType( dtype ) ) { - return validateRealFloating; - } - if ( isUnsignedIntegerDataType( dtype ) ) { - return validateUnsignedInteger; - } - if ( isSignedIntegerDataType( dtype ) ) { - return validateSignedInteger; - } - if ( isBooleanDataType( dtype ) ) { - return validateBoolean; - } - // Case: isComplexDataType( dtype ) === true - return validateComplexFloating; -} - - -// EXPORTS // - -module.exports = validator; diff --git a/to-fancy/package.json b/to-fancy/package.json deleted file mode 100644 index f05f824e0..000000000 --- a/to-fancy/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "@stdlib/array/to-fancy", - "version": "0.0.0", - "description": "Convert an array to an object supporting fancy indexing.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "fancy", - "subsequence", - "subseq", - "slice", - "indexing", - "index", - "vector" - ] -} diff --git a/to-fancy/test/test.factory.js b/to-fancy/test/test.factory.js deleted file mode 100644 index 2410bfd8c..000000000 --- a/to-fancy/test/test.factory.js +++ /dev/null @@ -1,143 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Int32Array = require( './../../int32' ); -var factory = require( './../lib/factory.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory( value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid option', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - factory({ - 'strict': value - }); - }; - } -}); - -tape( 'the function returns a function which returns an array-like object', function test( t ) { - var array2fancy; - var x; - var y; - - array2fancy = factory(); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - t.strictEqual( y instanceof Array, true, 'returns expected value' ); - t.notEqual( y, x, 'different reference' ); - t.deepEqual( y, x, 'returns expected value' ); - - t.end(); -}); - -tape( 'if an environment does not support Proxy objects, the function returns a function which returns the input array (generic)', function test( t ) { - var array2fancy; - var factory; - var x; - var y; - - factory = proxyquire( './../lib/factory.js', { - './has_proxy_support.js': false - }); - array2fancy = factory(); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - t.strictEqual( y, x, 'returns expected value' ); - t.end(); -}); - -tape( 'if an environment does not support Proxy objects, the function returns a function which returns the input array (typed)', function test( t ) { - var array2fancy; - var factory; - var x; - var y; - - factory = proxyquire( './../lib/factory.js', { - './has_proxy_support.js': false - }); - array2fancy = factory(); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - t.strictEqual( y, x, 'returns expected value' ); - t.end(); -}); diff --git a/to-fancy/test/test.get.boolean_array.js b/to-fancy/test/test.get.boolean_array.js deleted file mode 100644 index bbf34b933..000000000 --- a/to-fancy/test/test.get.boolean_array.js +++ /dev/null @@ -1,430 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var Int32Array = require( './../../int32' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting boolean array indexing (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = [ 1, 2, 3, 4 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ false, false, false, false ] ); - expected = []; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ true, true, false, false ] ); - expected = [ 1, 2 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = [ 2, 3 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ true, false, true, false ] ); - expected = [ 1, 3 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting boolean array indexing (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ false, false, false, false ] ); - expected = new Int32Array( [] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ true, true, false, false ] ); - expected = new Int32Array( [ 1, 2 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Int32Array( [ 2, 3 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ true, false, true, false ] ); - expected = new Int32Array( [ 1, 3 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting boolean array indexing and returning arrays which can themselves support boolean arrays (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - var z; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = [ 1, 2, 3, 4 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( [ true, false, true, false ] ); - expected = [ 1, 3 ]; - actual = z[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( [ false, true ] ); - expected = [ 3 ]; - actual = z[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting boolean array indexing and returning arrays which can themselves support boolean arrays (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - var z; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( [ true, false, true, false ] ); - expected = new Int32Array( [ 1, 3 ] ); - actual = z[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( [ false, true ] ); - expected = new Int32Array( [ 3 ] ); - actual = z[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object which throws an error if provided a boolean array index having an incompatible number of elements (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - array2fancy.idx( [ true, false ] ), - array2fancy.idx( [ true, true, true ] ), - array2fancy.idx( [ true, false, true, false, true ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error if provided a boolean array index having an incompatible number of elements (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - array2fancy.idx( [ true, false ] ), - array2fancy.idx( [ true, true, true ] ), - array2fancy.idx( [ true, false, true, false, true ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': false - }); - expected = [ 1, 2, 3, 4 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': false - }); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': true - }); - expected = [ 1, 2, 3, 4 ]; - - actual = y[ idx ]; - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = y[ idx ]; - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': true - }); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - actual = y[ idx ]; - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = y[ idx ]; - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); diff --git a/to-fancy/test/test.get.integer_array.js b/to-fancy/test/test.get.integer_array.js deleted file mode 100644 index 0b42cbece..000000000 --- a/to-fancy/test/test.get.integer_array.js +++ /dev/null @@ -1,596 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var Int32Array = require( './../../int32' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting integer array indexing (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = [ 1, 2, 3, 4 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ 3, 1, 2, 0, 0, 1 ] ); - expected = [ 4, 2, 3, 1, 1, 2 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [] ); - expected = []; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Int32Array( [] ) ); - expected = []; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ 0, 1 ] ); - expected = [ 1, 2 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Int32Array( [ 1, 2 ] ) ); - expected = [ 2, 3 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = [ 1, 3 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Int32Array( [ -1, -3 ] ) ); - expected = [ 4, 2 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting integer array indexing (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ 3, 1, 2, 0, 0, 1 ] ); - expected = new Int32Array( [ 4, 2, 3, 1, 1, 2 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [] ); - expected = new Int32Array( [] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Int32Array( [] ) ); - expected = new Int32Array( [] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ 0, 1 ] ); - expected = new Int32Array( [ 1, 2 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Int32Array( [ 2, 3 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Int32Array( [ 1, 3 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Int32Array( [ -1, -3 ] ) ); - expected = new Int32Array( [ 4, 2 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function returns an array-like object which throws an error when provided an index which is out-of-bounds (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - array2fancy.idx( [ 10, 20 ] ), - array2fancy.idx( [ -20, -10 ] ), - array2fancy.idx( new Int32Array( [ -20] ) ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'by default, the function returns an array-like object which throws an error when provided an index which is out-of-bounds (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - array2fancy.idx( [ 10, 20 ] ), - array2fancy.idx( [ -20, -10 ] ), - array2fancy.idx( new Int32Array( [ -20] ) ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which throws an error when provided an index which is out-of-bounds (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - values = [ - array2fancy.idx( [ 10, 20 ] ), - array2fancy.idx( [ -20, -10 ] ), - array2fancy.idx( new Int32Array( [ -20] ) ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which throws an error when provided an index which is out-of-bounds (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - values = [ - array2fancy.idx( [ 10, 20 ] ), - array2fancy.idx( [ -20, -10 ] ), - array2fancy.idx( new Int32Array( [ -20] ) ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an index which is out-of-bounds (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': true - }); - - values = [ - array2fancy.idx( [ 10, 20 ] ), - array2fancy.idx( [ -20, -10 ] ), - array2fancy.idx( new Int32Array( [ -20] ) ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an index which is out-of-bounds (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': true - }); - - values = [ - array2fancy.idx( [ 10, 20 ] ), - array2fancy.idx( [ -20, -10 ] ), - array2fancy.idx( new Int32Array( [ -20] ) ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), RangeError, 'throws an error' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object supporting integer array indexing and returning arrays which themselves support integer arrays (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - var z; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = [ 1, 2, 3, 4 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( [ -4, -2 ] ); - expected = [ 1, 3 ]; - actual = z[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( new Int32Array( [ 1, 0 ] ) ); - expected = [ 3, 1 ]; - actual = z[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting integer array indexing and returning arrays which themselves support integer arrays (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - var z; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( [ -4, -2 ] ); - expected = new Int32Array( [ 1, 3 ] ); - actual = z[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( new Int32Array( [ 1, 0 ] ) ); - expected = new Int32Array( [ 3, 1 ] ); - actual = z[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': false - }); - expected = [ 1, 2, 3, 4 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': false - }); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': true - }); - expected = [ 1, 2, 3, 4 ]; - - actual = y[ idx ]; - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = y[ idx ]; - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': true - }); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - actual = y[ idx ]; - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = y[ idx ]; - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); diff --git a/to-fancy/test/test.get.integers.js b/to-fancy/test/test.get.integers.js deleted file mode 100644 index 23f094146..000000000 --- a/to-fancy/test/test.get.integers.js +++ /dev/null @@ -1,330 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var Int32Array = require( './../../int32' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element retrieval (generic, positive integers)', function test( t ) { - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - for ( i = 0; i < x.length; i++ ) { - t.strictEqual( y[ i ], x[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element retrieval (typed, positive integers)', function test( t ) { - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - for ( i = 0; i < x.length; i++ ) { - t.strictEqual( y[ i ], x[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element retrieval (generic, negative integers)', opts, function test( t ) { - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - for ( i = 0; i < x.length; i++ ) { - t.strictEqual( y[ i-x.length ], x[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element retrieval (typed, negative integers)', opts, function test( t ) { - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - for ( i = 0; i < x.length; i++ ) { - t.strictEqual( y[ i-x.length ], x[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'by default, the function returns an array-like object which returns `undefined` when provided an integer index which is out-of-bounds (generic, positive integers)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'by default, the function returns an array-like object which returns `undefined` when provided an integer index which is out-of-bounds (typed, positive integers)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'by default, the function returns an array-like object which returns `undefined` when provided an integer index which is out-of-bounds (generic, negative integers)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'by default, the function returns an array-like object which returns `undefined` when provided an integer index which is out-of-bounds (typed, negative integers)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which returns `undefined` when provided an integer index which is out-of-bounds (generic, positive integers)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which returns `undefined` when provided an integer index which is out-of-bounds (typed, positive integers)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which returns `undefined` when provided an integer index which is out-of-bounds (generic, negative integers)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which returns `undefined` when provided an integer index which is out-of-bounds (typed, negative integers)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer index which is out-of-bounds (generic, positive integers)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer index which is out-of-bounds (typed, positive integers)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer index which is out-of-bounds (generic, negative integers)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer index which is out-of-bounds (typed, negative integers)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); diff --git a/to-fancy/test/test.get.invalid.js b/to-fancy/test/test.get.invalid.js deleted file mode 100644 index ccaa52173..000000000 --- a/to-fancy/test/test.get.invalid.js +++ /dev/null @@ -1,285 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var Int32Array = require( './../../int32' ); -var Uint8Array = require( './../../uint8' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid serialized slice (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - 'Slice(a,b,c)', - 'Slice(1.5)', - 'Slice(0,1,0)' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid serialized slice (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - 'Slice(a,b,c)', - 'Slice(1.5)', - 'Slice(0,1,0)' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid subsequence indexing expression (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - 'a:b:c', - ':1.5', - '0:1:0', - ':::', - '0:1:1:2' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid subsequence indexing expression (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - 'a:b:c', - ':1.5', - '0:1:0', - ':::', - '0:1:1:2' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid serialized array index (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - 'ArrayIndex<9999999>', - 'ArrayIndex<9999999999>' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid serialized array index (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - 'ArrayIndex<9999999>', - 'ArrayIndex<9999999999>' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an unsupported array index (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'cache': { - 'get': get - } - }); - - values = [ - array2fancy.idx( [ 0, 1, 2, 3 ] ), - array2fancy.idx( [ true, false, true, false ] ), - array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } - - function get() { - return { - 'data': [], - 'type': 'beep', - 'dtype': 'generic' - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an unsupported array index (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'cache': { - 'get': get - } - }); - - values = [ - array2fancy.idx( [ 0, 1, 2, 3 ] ), - array2fancy.idx( [ true, false, true, false ] ), - array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } - - function get() { - return { - 'data': [], - 'type': 'beep', - 'dtype': 'generic' - }; - } -}); diff --git a/to-fancy/test/test.get.mask_array.js b/to-fancy/test/test.get.mask_array.js deleted file mode 100644 index ff7f6e3b4..000000000 --- a/to-fancy/test/test.get.mask_array.js +++ /dev/null @@ -1,431 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var Int32Array = require( './../../int32' ); -var Uint8Array = require( './../../uint8' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting mask array indexing (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = [ 1, 2, 3, 4 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 1, 1, 1 ] ) ); - expected = []; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = [ 1, 2 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = [ 2, 3 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = [ 1, 3 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting mask array indexing (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 1, 1, 1 ] ) ); - expected = new Int32Array( [] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Int32Array( [ 1, 2 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Int32Array( [ 2, 3 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Int32Array( [ 1, 3 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting mask array indexing and returning arrays which can themselves support mask arrays (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - var z; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = [ 1, 2, 3, 4 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = [ 1, 3 ]; - actual = z[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( new Uint8Array( [ 1, 0 ] ) ); - expected = [ 3 ]; - actual = z[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting mask array indexing and returning arrays which can themselves support mask arrays (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - var z; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Int32Array( [ 1, 3 ] ); - actual = z[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - idx = array2fancy.idx( new Uint8Array( [ 1, 0 ] ) ); - expected = new Int32Array( [ 3 ] ); - actual = z[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object which throws an error if provided a mask array index having an incompatible number of elements (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - array2fancy.idx( new Uint8Array( [ 0, 1 ] ) ), - array2fancy.idx( new Uint8Array( [ 0, 0, 0 ] ) ), - array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1, 0 ] ) ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error if provided a mask array index having an incompatible number of elements (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - array2fancy.idx( new Uint8Array( [ 0, 1 ] ) ), - array2fancy.idx( new Uint8Array( [ 0, 0, 0 ] ) ), - array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1, 0 ] ) ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error' ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': false - }); - expected = [ 1, 2, 3, 4 ]; - actual = y[ idx ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': false - }); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ idx ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (generic)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': true - }); - expected = [ 1, 2, 3, 4 ]; - - actual = y[ idx ]; - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = y[ idx ]; - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (typed)', opts, function test( t ) { - var expected; - var actual; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': true - }); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - - actual = y[ idx ]; - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = y[ idx ]; - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); diff --git a/to-fancy/test/test.get.properties.js b/to-fancy/test/test.get.properties.js deleted file mode 100644 index 63a0ca0a8..000000000 --- a/to-fancy/test/test.get.properties.js +++ /dev/null @@ -1,72 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int32Array = require( './../../int32' ); -var array2fancy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting expected property access (generic)', function test( t ) { - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - x.foo = 'a'; - x.bar = 'b'; - - y = array2fancy( x ); - - t.strictEqual( y.foo, x.foo, 'returns expected value' ); - t.strictEqual( y.bar, x.bar, 'returns expected value' ); - t.strictEqual( y.length, x.length, 'returns expected value' ); - t.strictEqual( y.beep, void 0, 'returns expected value' ); - t.strictEqual( y.boop, void 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting expected property access (typed)', function test( t ) { - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - x.foo = 'a'; - x.bar = 'b'; - - y = array2fancy( x ); - - t.strictEqual( y.foo, x.foo, 'returns expected value' ); - t.strictEqual( y.bar, x.bar, 'returns expected value' ); - t.strictEqual( y.length, x.length, 'returns expected value' ); - t.strictEqual( y.beep, void 0, 'returns expected value' ); - t.strictEqual( y.boop, void 0, 'returns expected value' ); - - t.end(); -}); diff --git a/to-fancy/test/test.get.slice.js b/to-fancy/test/test.get.slice.js deleted file mode 100644 index bb9db4c69..000000000 --- a/to-fancy/test/test.get.slice.js +++ /dev/null @@ -1,437 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var Slice = require( '@stdlib/slice/ctor' ); -var Int32Array = require( './../../int32' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting slices (generic)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice(); - expected = [ 1, 2, 3, 4 ]; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( 2 ); - expected = [ 1, 2 ]; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( 1, 3 ); - expected = [ 2, 3 ]; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( null, null, 2 ); - expected = [ 1, 3 ]; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( -1, null, -2 ); - expected = [ 4, 2 ]; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slices (typed)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( 2 ); - expected = new Int32Array( [ 1, 2 ] ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( 1, 3 ); - expected = new Int32Array( [ 2, 3 ] ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( null, null, 2 ); - expected = new Int32Array( [ 1, 3 ] ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( -1, null, -2 ); - expected = new Int32Array( [ 4, 2 ] ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function returns an array-like object which returns an empty array when provided a slice which is out-of-bounds (generic)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = []; - - s = new Slice( 10, 20 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( -20, -10 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( -20 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function returns an array-like object which returns an empty array when provided a slice which is out-of-bounds (typed)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [] ); - - s = new Slice( 10, 20 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( -20, -10 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( -20 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which returns an empty array when provided a slice which is out-of-bounds (generic)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - expected = []; - - s = new Slice( 10, 20 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( -20, -10 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( -20 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which returns an empty array when provided a slice which is out-of-bounds (typed)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - expected = new Int32Array( [] ); - - s = new Slice( 10, 20 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( -20, -10 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = new Slice( -20 ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided a slice which is out-of-bounds (generic)', opts, function test( t ) { - var x; - var y; - var s; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - s = new Slice( x.length+i, x.length+10 ); - t.throws( badValue( s ), RangeError, 'throws an error when provided ' + s ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided a slice which is out-of-bounds (typed)', opts, function test( t ) { - var x; - var y; - var s; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - s = new Slice( x.length+i, x.length+10 ); - t.throws( badValue( s ), RangeError, 'throws an error when provided ' + s ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'the function returns an array-like object supporting slices which can themselves support slices (typed)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var z; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - s = new Slice( null, null, 2 ); - expected = new Int32Array( [ 1, 3 ] ); - actual = z[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - s = new Slice( null, null, -1 ); - expected = new Int32Array( [ 3, 1 ] ); - actual = z[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slices which can themselves support slices (generic)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var z; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice(); - expected = [ 1, 2, 3, 4 ]; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - s = new Slice( null, null, 2 ); - expected = [ 1, 3 ]; - actual = z[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - s = new Slice( null, null, -1 ); - expected = [ 3, 1 ]; - actual = z[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.notEqual( actual, z, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/to-fancy/test/test.get.subsequence.js b/to-fancy/test/test.get.subsequence.js deleted file mode 100644 index 35bfbc63a..000000000 --- a/to-fancy/test/test.get.subsequence.js +++ /dev/null @@ -1,342 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var Int32Array = require( './../../int32' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting subsequence indexing expressions (generic)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = ':'; - expected = [ 1, 2, 3, 4 ]; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = ':2'; - expected = [ 1, 2 ]; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = '1:3'; - expected = [ 2, 3 ]; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = '::2'; - expected = [ 1, 3 ]; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = '-1::-2'; - expected = [ 4, 2 ]; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting subsequence indexing expressions (typed)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = ':'; - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = ':2'; - expected = new Int32Array( [ 1, 2 ] ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = '1:3'; - expected = new Int32Array( [ 2, 3 ] ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = '::2'; - expected = new Int32Array( [ 1, 3 ] ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = '-1::-2'; - expected = new Int32Array( [ 4, 2 ] ); - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.notEqual( actual, x, 'different reference' ); - t.notEqual( actual, y, 'different reference' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function returns an array-like object which returns an empty array when provided a subsequence indexing expression which is out-of-bounds (generic)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = []; - - s = '10:20'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = '-20:-10'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = ':-20'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function returns an array-like object which returns an empty array when provided a subsequence indexing expression which is out-of-bounds (typed)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [] ); - - s = '10:20'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = '-20:-10'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = ':-20'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which returns an empty array when provided a subsequence indexing expression which is out-of-bounds (generic)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - expected = []; - - s = '10:20'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = '-20:-10'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = ':-20'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which returns an empty array when provided a subsequence indexing expression which is out-of-bounds (typed)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - expected = new Int32Array( [] ); - - s = '10:20'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = '-20:-10'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - s = ':-20'; - actual = y[ s ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided a subsequence indexing expression which is out-of-bounds (generic)', opts, function test( t ) { - var x; - var y; - var s; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - s = (x.length+i) + ':' + (x.length+10); - t.throws( badValue( s ), RangeError, 'throws an error when provided ' + s ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided a subsequence indexing expression which is out-of-bounds (typed)', opts, function test( t ) { - var x; - var y; - var s; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - s = (x.length+i) + ':' + (x.length+10); - t.throws( badValue( s ), RangeError, 'throws an error when provided ' + s ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - var v = y[ value ]; // eslint-disable-line no-unused-vars - }; - } -}); diff --git a/to-fancy/test/test.js b/to-fancy/test/test.js deleted file mode 100644 index c9cc57a85..000000000 --- a/to-fancy/test/test.js +++ /dev/null @@ -1,47 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var ArrayIndex = require( './../../index' ); -var array2fancy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a `factory` method', function test( t ) { - t.strictEqual( hasOwnProp( array2fancy, 'factory' ), true, 'has property' ); - t.strictEqual( typeof array2fancy.factory, 'function', 'has method' ); - t.end(); -}); - -tape( 'attached to the main export is an `ArrayIndex` constructor', function test( t ) { - t.strictEqual( hasOwnProp( array2fancy, 'idx' ), true, 'has property' ); - t.strictEqual( array2fancy.idx, ArrayIndex, 'returns expected value' ); - t.end(); -}); diff --git a/to-fancy/test/test.main.js b/to-fancy/test/test.main.js deleted file mode 100644 index 4f332687a..000000000 --- a/to-fancy/test/test.main.js +++ /dev/null @@ -1,405 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var Int32Array = require( './../../int32' ); -var propertiesIn = require( '@stdlib/utils/properties-in' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like value', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - array2fancy( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like value (options)', function test( t ) { - var values; - var i; - - values = [ - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - array2fancy( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - array2fancy( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an invalid option', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - array2fancy( [ 1, 2, 3 ], { - 'strict': value - }); - }; - } -}); - -tape( 'the function returns an array-like object which satisfies the same instance check (generic)', function test( t ) { - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - t.notEqual( y, x, 'different reference' ); - t.strictEqual( y instanceof Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an array-like object which satisfies the same instance check (typed)', function test( t ) { - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - t.notEqual( y, x, 'different reference' ); - t.strictEqual( y instanceof Int32Array, true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an array-like object having the same properties, both own and inherited, as the input array (generic)', function test( t ) { - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - t.deepEqual( propertiesIn( y ), propertiesIn( x ), 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an array-like object having the same properties, both own and inherited, as the input array (typed)', function test( t ) { - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - t.deepEqual( propertiesIn( y ), propertiesIn( x ), 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting bracket syntax for element retrieval (generic)', function test( t ) { - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - for ( i = 0; i < x.length; i++ ) { - t.strictEqual( y[ i ], x[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting bracket syntax for element retrieval (typed)', function test( t ) { - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - for ( i = 0; i < x.length; i++ ) { - t.strictEqual( y[ i ], x[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting the calling of input array methods (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 2, 4, 6, 8 ]; - actual = y.map( fcn ); - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function fcn( v ) { - return v * 2; - } -}); - -tape( 'the function returns an array-like object supporting the calling of input array methods (typed)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 2, 4, 6, 8 ] ); - actual = y.map( fcn ); - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function fcn( v ) { - return v * 2; - } -}); - -tape( 'the function returns an array-like object supporting the return of array instances supporting slice expressions (generic)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var z; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 1, 2, 3, 4 ]; - actual = y.slice(); - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.strictEqual( x[ ':' ], void 0, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - actual = y[ ':' ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - expected = [ 1, 2, 3, 4 ]; - actual = z[ ':' ]; - - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting the return of array instances supporting slice expressions (typed)', opts, function test( t ) { - var expected; - var actual; - var x; - var y; - var z; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y.slice(); - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.strictEqual( x[ ':' ], void 0, 'returns expected value' ); - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = y[ ':' ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - z = actual; - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - actual = z[ ':' ]; - - t.strictEqual( actual instanceof Int32Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting constructor access (generic)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = []; - actual = new y.constructor(); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - actual = new y.constructor( 1 ); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.strictEqual( actual.length, 1, 'returns expected value' ); - - expected = [ 1, 2 ]; - actual = new y.constructor( 1, 2 ); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3 ]; - actual = new y.constructor( 1, 2, 3 ); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4 ]; - actual = new y.constructor( 1, 2, 3, 4 ); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5 ]; - actual = new y.constructor( 1, 2, 3, 4, 5 ); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - actual = new y.constructor( 1, 2, 3, 4, 5, 6 ); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7 ]; - actual = new y.constructor( 1, 2, 3, 4, 5, 6, 7 ); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - actual = new y.constructor( 1, 2, 3, 4, 5, 6, 7, 8 ); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; - actual = new y.constructor( 1, 2, 3, 4, 5, 6, 7, 8, 9 ); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; - actual = new y.constructor( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - expected = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ]; - actual = new y.constructor( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ); - t.strictEqual( actual instanceof Array, true, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/to-fancy/test/test.set.boolean_array.js b/to-fancy/test/test.set.boolean_array.js deleted file mode 100644 index 6e568121b..000000000 --- a/to-fancy/test/test.set.boolean_array.js +++ /dev/null @@ -1,1563 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint32Array = require( './../../uint32' ); -var Uint16Array = require( './../../uint16' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var BooleanArray = require( './../../bool' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting boolean array assignment (generic)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = [ 5, 6, 3, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = [ 1, 5, 6, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = [ 5, 2, 6, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting boolean array assignment ("unknown" dtype, accessor)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = [ 5, 6, 3, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = [ 1, 5, 6, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = [ 5, 2, 6, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting boolean array assignment (int32)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Int32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Int32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Int32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting boolean array assignment (uint32)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Uint32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Uint32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Uint32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Uint32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Uint32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting boolean array assignment (float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Float64Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Float64Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Float64Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Float64Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting boolean array assignment (complex128)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ idx ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted boolean array assignment (generic, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = [ 5, 5, 5, 5 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = [ 5, 5, 3, 4 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = [ 1, 5, 5, 4 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = [ 5, 2, 5, 4 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted boolean array assignment (generic, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = [ 5, 5, 5, 5 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = [ 5, 5, 3, 4 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = [ 1, 5, 5, 4 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = [ 5, 2, 5, 4 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted boolean array assignment (float64, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Float64Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Float64Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Float64Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Float64Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted boolean array assignment (float64, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Float64Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Float64Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Float64Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Float64Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted boolean array assignment (int32, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Int32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Int32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Int32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Int32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Int32Array( [ 1, 5, 3, 5 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted boolean array assignment (int32, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Int32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Int32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Int32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Int32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted boolean array assignment (uint32, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Uint32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Uint32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Uint32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Uint32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted boolean array assignment (uint32, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Uint32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Uint32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Uint32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Uint32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted boolean array assignment (complex128, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted boolean array assignment (complex128, complex scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted boolean array assignment (complex128, real scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Complex128Array( [ 9, 0, 9, 0, 9, 0, 9, 0 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Complex128Array( [ 9, 0, 9, 0, 5, 6, 7, 8 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Complex128Array( [ 1, 2, 9, 0, 9, 0, 7, 8 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Complex128Array( [ 9, 0, 3, 4, 9, 0, 7, 8 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (generic, float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = [ 5, 6, 3, 4 ]; - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = [ 1, 5, 6, 4 ]; - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = [ 5, 2, 6, 4 ]; - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (float64, float32)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Float64Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Float32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Float64Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Float64Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Float64Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (int32, int8)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Int8Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Int32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Int32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Int32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (uint32, uint16)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Uint32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Uint16Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Uint32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Uint32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Uint32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (complex128, complex64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ idx ] = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (complex128, float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Complex128Array( [ 9, 0, 10, 0, 11, 0, 12, 0 ] ); - y[ idx ] = new Float64Array( [ 9, 10, 11, 12 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Complex128Array( [ 17, 0, 18, 0, 5, 6, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Complex128Array( [ 1, 2, 17, 0, 18, 0, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Complex128Array( [ 17, 0, 3, 4, 18, 0, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (float32, float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Float32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Float32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Float32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Float32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (complex64, complex128)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ] ); - expected = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ idx ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, true, false, false ] ) ); - expected = new Complex64Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ false, true, true, false ] ); - expected = new Complex64Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new BooleanArray( [ true, false, true, false ] ) ); - expected = new Complex64Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (generic)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': true - }); - - values = [ - [], - [ 5, 6 ], - [ 5, 6, 7 ], - [ 5, 6, 7, 8, 9 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (int32)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': true - }); - - values = [ - new Int32Array( [] ), - new Int32Array( [ 5, 6 ] ), - new Int32Array( [ 5, 6, 7 ] ), - new Int32Array( [ 5, 6, 7, 8, 9 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (float64)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': true - }); - - values = [ - new Complex128Array( [ 5, 6 ] ), - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (complex128)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': true - }); - - values = [ - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int32)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': true - }); - - values = [ - new Uint32Array( [ 1 ] ), - new Uint32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int8)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Int8Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': true - }); - - values = [ - new Int32Array( [ 1 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - 999999, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (uint32)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': true - }); - - values = [ - new Int32Array( [ 1 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - -3, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (generic)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': false - }); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = [ 9, 10, 11, 12 ]; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (typed)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': false - }); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = new Int32Array( [ 9, 10, 11, 12 ] ); - }; - } -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (generic)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': true - }); - expected = [ 5, 6, 7, 8 ]; - - y[ idx ] = [ 5, 6, 7, 8 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - expected = [ 9, 10, 11, 12 ]; - - y[ idx ] = [ 9, 10, 11, 12 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (typed)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ true, true, true, true ], { - 'persist': true - }); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - - y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - expected = new Int32Array( [ 9, 10, 11, 12 ] ); - - y[ idx ] = new Int32Array( [ 9, 10, 11, 12 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); diff --git a/to-fancy/test/test.set.integer_array.js b/to-fancy/test/test.set.integer_array.js deleted file mode 100644 index 2c26a6121..000000000 --- a/to-fancy/test/test.set.integer_array.js +++ /dev/null @@ -1,1918 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint32Array = require( './../../uint32' ); -var Uint16Array = require( './../../uint16' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting integer array assignment (generic)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = [ 5, 6, 3, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = [ 1, 5, 6, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = [ 5, 2, 6, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = [ 1, 6, 3, 5 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting integer array assignment ("unknown" dtype, accessor)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = [ 5, 6, 3, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = [ 1, 5, 6, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = [ 5, 2, 6, 4 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = [ 1, 6, 3, 5 ]; - y[ idx ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting integer array assignment (int32)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Int32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Int32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Int32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Int32Array( [ 1, 6, 3, 5 ] ); - y[ idx ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting integer array assignment (uint32)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Uint32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Uint32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Uint32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Uint32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Uint32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Uint32Array( [ 1, 6, 3, 5 ] ); - y[ idx ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting integer array assignment (float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Float64Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Float64Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Float64Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Float64Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Float64Array( [ 1, 6, 3, 5 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting integer array assignment (complex128)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ idx ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Complex128Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted integer array assignment (generic, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = [ 5, 5, 5, 5 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = [ 5, 5, 3, 4 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = [ 1, 5, 5, 4 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = [ 5, 2, 5, 4 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = [ 1, 5, 3, 5 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted integer array assignment (generic, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = [ 5, 5, 5, 5 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = [ 5, 5, 3, 4 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = [ 1, 5, 5, 4 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = [ 5, 2, 5, 4 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = [ 1, 5, 3, 5 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted integer array assignment (float64, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Float64Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Float64Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Float64Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Float64Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Float64Array( [ 1, 5, 3, 5 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted integer array assignment (float64, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Float64Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Float64Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Float64Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Float64Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Float64Array( [ 1, 5, 3, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted integer array assignment (int32, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Int32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Int32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Int32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Int32Array( [ 1, 5, 3, 5 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted integer array assignment (int32, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Int32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Int32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Int32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Int32Array( [ 1, 5, 3, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted integer array assignment (uint32, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Uint32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Uint32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Uint32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Uint32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Uint32Array( [ 1, 5, 3, 5 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted integer array assignment (uint32, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Uint32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Uint32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Uint32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Uint32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Uint32Array( [ 1, 5, 3, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted integer array assignment (complex128, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Complex128Array( [ 1, 2, 9, 10, 5, 6, 9, 10 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted integer array assignment (complex128, complex scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Complex128Array( [ 1, 2, 9, 10, 5, 6, 9, 10 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted integer array assignment (complex128, real scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Complex128Array( [ 9, 0, 9, 0, 9, 0, 9, 0 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Complex128Array( [ 9, 0, 9, 0, 5, 6, 7, 8 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Complex128Array( [ 1, 2, 9, 0, 9, 0, 7, 8 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Complex128Array( [ 9, 0, 3, 4, 9, 0, 7, 8 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Complex128Array( [ 1, 2, 9, 0, 5, 6, 9, 0 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (generic, float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = [ 5, 6, 3, 4 ]; - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = [ 1, 5, 6, 4 ]; - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = [ 5, 2, 6, 4 ]; - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = [ 1, 6, 3, 5 ]; - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (float64, float32)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Float64Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Float32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Float64Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Float64Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Float64Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Float64Array( [ 1, 6, 3, 5 ] ); - y[ idx ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (int32, int8)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Int8Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Int32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Int32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Int32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Int32Array( [ 1, 6, 3, 5 ] ); - y[ idx ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (uint32, uint16)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Uint32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Uint16Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Uint32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Uint32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Uint32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Uint32Array( [ 1, 6, 3, 5 ] ); - y[ idx ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (complex128, complex64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ idx ] = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Complex128Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); - y[ idx ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (complex128, float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Complex128Array( [ 9, 0, 10, 0, 11, 0, 12, 0 ] ); - y[ idx ] = new Float64Array( [ 9, 10, 11, 12 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1 ] ); - expected = new Complex128Array( [ 17, 0, 18, 0, 5, 6, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Complex128Array( [ 1, 2, 17, 0, 18, 0, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 2 ] ); - expected = new Complex128Array( [ 17, 0, 3, 4, 18, 0, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Complex128Array( [ 1, 2, 18, 0, 5, 6, 17, 0 ] ); - y[ idx ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (float32, float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Float32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Float32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Float32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Float32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Float32Array( [ 1, 6, 3, 5 ] ); - y[ idx ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (complex64, complex128)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ] ); - expected = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ idx ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 1 ] ) ); - expected = new Complex64Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 1, 2 ] ); - expected = new Complex64Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Int32Array( [ 0, 2 ] ) ); - expected = new Complex64Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Complex64Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (generic)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - for ( i = 0; i < 10; i++ ) { - idx = array2fancy.idx( [ x.length+i ] ); - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 5; - }; - } -}); - -tape( 'by default, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (typed)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - for ( i = 0; i < 10; i++ ) { - idx = array2fancy.idx( [ x.length+i ] ); - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 5; - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (generic)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - idx = array2fancy.idx( [ x.length+i ] ); - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 5; - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (typed)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - idx = array2fancy.idx( [ x.length+i ] ); - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 5; - }; - } -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (generic)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - for ( i = 0; i < 10; i++ ) { - idx = array2fancy.idx( [ x.length+i ] ); - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 5; - }; - } -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which throws an error when provided an integer array containing an index which is out-of-bounds (typed)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - for ( i = 0; i < 10; i++ ) { - idx = array2fancy.idx( [ x.length+i ] ); - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx.data ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 5; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (generic)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': true - }); - - values = [ - [], - [ 5, 6 ], - [ 5, 6, 7 ], - [ 5, 6, 7, 8, 9 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (int32)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': true - }); - - values = [ - new Int32Array( [] ), - new Int32Array( [ 5, 6 ] ), - new Int32Array( [ 5, 6, 7 ] ), - new Int32Array( [ 5, 6, 7, 8, 9 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (float64)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': true - }); - - values = [ - new Complex128Array( [ 5, 6 ] ), - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (complex128)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': true - }); - - values = [ - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int32)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': true - }); - - values = [ - new Uint32Array( [ 1 ] ), - new Uint32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int8)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Int8Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': true - }); - - values = [ - new Int32Array( [ 1 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - 999999, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (uint32)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': true - }); - - values = [ - new Int32Array( [ 1 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - -3, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (generic)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': false - }); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = [ 9, 10, 11, 12 ]; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (typed)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': false - }); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = new Int32Array( [ 9, 10, 11, 12 ] ); - }; - } -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (generic)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': true - }); - expected = [ 5, 6, 7, 8 ]; - - y[ idx ] = [ 5, 6, 7, 8 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - expected = [ 9, 10, 11, 12 ]; - - y[ idx ] = [ 9, 10, 11, 12 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (typed)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ 0, 1, 2, 3 ], { - 'persist': true - }); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - - y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - expected = new Int32Array( [ 9, 10, 11, 12 ] ); - - y[ idx ] = new Int32Array( [ 9, 10, 11, 12 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); diff --git a/to-fancy/test/test.set.integers.js b/to-fancy/test/test.set.integers.js deleted file mode 100644 index 5c84cb2f7..000000000 --- a/to-fancy/test/test.set.integers.js +++ /dev/null @@ -1,688 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var Uint32Array = require( './../../uint32' ); -var Int8Array = require( './../../int8' ); -var Int32Array = require( './../../int32' ); -var Float64Array = require( './../../float64' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element assignment (generic, positive integer indices)', function test( t ) { - var expected; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 2, 4, 6, 8 ]; - - for ( i = 0; i < x.length; i++ ) { - y[ i ] *= 2; - t.strictEqual( y[ i ], x[ i ], 'returns expected value' ); - t.strictEqual( y[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element assignment (int32, positive integer indices)', function test( t ) { - var expected; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 2, 4, 6, 8 ] ); - - for ( i = 0; i < x.length; i++ ) { - y[ i ] *= 2; - t.strictEqual( y[ i ], x[ i ], 'returns expected value' ); - t.strictEqual( y[ i ], expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element assignment (bool, positive integer indices)', function test( t ) { - var expected; - var x; - var y; - var i; - - x = new BooleanArray( [ 0, 1, 0, 1 ] ); - y = array2fancy( x ); - - expected = new BooleanArray( [ 1, 1, 1, 1 ] ); - - for ( i = 0; i < x.length; i++ ) { - y[ i ] = true; - t.strictEqual( y[ i ], x.get( i ), 'returns expected value' ); - t.strictEqual( y[ i ], expected.get( i ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element assignment (complex128, positive integer indices)', function test( t ) { - var expected; - var x; - var y; - var v; - var i; - var j; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - for ( i = 0; i < x.length; i++ ) { - j = 2 * i; - v = new Complex128( j+9, j+10 ); - y[ i ] = v; - } - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting floating-point downcasting (complex64, positive integer indices)', function test( t ) { - var expected; - var x; - var y; - var v; - var i; - var j; - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - for ( i = 0; i < x.length; i++ ) { - j = 2 * i; - v = new Complex128( j+9, j+10 ); - y[ i ] = v; - } - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting floating-point upcasting (complex128, positive integer indices)', function test( t ) { - var expected; - var x; - var y; - var i; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 0, 10, 0, 11, 0, 12, 0 ] ); - - for ( i = 0; i < x.length; i++ ) { - y[ i ] = i + 9; - } - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element assignment (generic, negative integer indices)', opts, function test( t ) { - var expected; - var x; - var y; - var i; - var j; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 2, 4, 6, 8 ]; - - for ( i = 0; i < x.length; i++ ) { - j = i - x.length; - y[ j ] *= 2; - t.strictEqual( y[ j ], x[ i ], 'returns expected value' ); - t.strictEqual( y[ j ], expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element assignment (int32, negative integer indices)', opts, function test( t ) { - var expected; - var x; - var y; - var i; - var j; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 2, 4, 6, 8 ] ); - - for ( i = 0; i < x.length; i++ ) { - j = i - x.length; - y[ j ] *= 2; - t.strictEqual( y[ j ], x[ i ], 'returns expected value' ); - t.strictEqual( y[ j ], expected[ i ], 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element assignment (bool, negative integer indices)', function test( t ) { - var expected; - var x; - var y; - var i; - var j; - - x = new BooleanArray( [ 0, 1, 0, 1 ] ); - y = array2fancy( x ); - - expected = new BooleanArray( [ 1, 1, 1, 1 ] ); - - for ( i = 0; i < x.length; i++ ) { - j = i - x.length; - y[ j ] = true; - t.strictEqual( y[ j ], x.get( i ), 'returns expected value' ); - t.strictEqual( y[ j ], expected.get( i ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting individual element assignment (complex128, negative integer indices)', function test( t ) { - var expected; - var x; - var y; - var v; - var i; - var j; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - for ( i = 0; i < x.length; i++ ) { - j = 2 * i; - v = new Complex128( j+9, j+10 ); - y[ i-x.length ] = v; - } - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting floating-point downcasting (complex64, negative integer indices)', function test( t ) { - var expected; - var x; - var y; - var v; - var i; - var j; - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - for ( i = 0; i < x.length; i++ ) { - j = 2 * i; - v = new Complex128( j+9, j+10 ); - y[ i-x.length ] = v; - } - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting floating-point upcasting (complex128, negative integer indices)', function test( t ) { - var expected; - var x; - var y; - var i; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 0, 10, 0, 11, 0, 12, 0 ] ); - - for ( i = 0; i < x.length; i++ ) { - y[ i-x.length ] = i + 9; - } - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - t.end(); -}); - -tape( 'by default, the function returns an array-like object which performs normal property assignment when provided an integer index which is out-of-bounds (generic, positive integer indices)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - y[ idx ] = i; - t.strictEqual( y[ idx ], i, 'returns expected value' ); - } - t.end(); -}); - -tape( 'by default, the function returns an array-like object which performs normal property assignment when provided an integer index which is out-of-bounds (int32, positive integer indices)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - y[ idx ] = i; - - // Normal behavior for typed arrays is to NOT support out-of-bounds assignment: - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'by default, the function returns an array-like object which performs normal property assignment when provided an integer index which is out-of-bounds (generic, negative integer indices)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - y[ idx ] = i; - t.strictEqual( y[ idx ], i, 'returns expected value' ); - } - t.end(); -}); - -tape( 'by default, the function returns an array-like object which performs normal property assignment when provided an integer index which is out-of-bounds (int32, negative integer indices)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - y[ idx ] = i; - - // Normal behavior for typed arrays is to NOT support out-of-bounds assignment: - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which performs normal property assignment when provided an integer index which is out-of-bounds (generic, positive integer indices)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - y[ idx ] = i; - t.strictEqual( y[ idx ], i, 'returns expected value' ); - } - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which performs normal property assignment when provided an integer index which is out-of-bounds (int32, positive integer indices)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - y[ idx ] = i; - - // Normal behavior for typed arrays is to NOT support out-of-bounds assignment: - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which performs normal property assignment when provided an integer index which is out-of-bounds (generic, negative integer indices)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - y[ idx ] = i; - t.strictEqual( y[ idx ], i, 'returns expected value' ); - } - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which performs normal property assignment when provided an integer index which is out-of-bounds (int32, negative integer indices)', function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - y[ idx ] = i; - - // Normal behavior for typed arrays is to NOT support out-of-bounds assignment: - t.strictEqual( y[ idx ], void 0, 'returns expected value' ); - } - t.end(); -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer index which is out-of-bounds (generic, positive integer indices)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer index which is out-of-bounds (int32, positive integer indices)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - idx = x.length + i; - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer index which is out-of-bounds (generic, negative integer indices)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided an integer index which is out-of-bounds (int32, negative integer indices)', opts, function test( t ) { - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - idx = -( i + x.length + 1 ); - t.throws( badValue( idx ), RangeError, 'throws an error when provided ' + idx ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (float64)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ 0 ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int32)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ 0 ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int8)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int8Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - 99999, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ 0 ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (uint32)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - -3, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ 0 ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (bool)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new BooleanArray( [ 0, 1, 0, 1 ] ); - y = array2fancy( x ); - - values = [ - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - null, - 1 - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ 0 ] = value; - }; - } -}); diff --git a/to-fancy/test/test.set.invalid.js b/to-fancy/test/test.set.invalid.js deleted file mode 100644 index 90b3ac1f6..000000000 --- a/to-fancy/test/test.set.invalid.js +++ /dev/null @@ -1,285 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var Int32Array = require( './../../int32' ); -var Uint8Array = require( './../../uint8' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid serialized slice (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - 'Slice(a,b,c)', - 'Slice(1.5)', - 'Slice(0,1,0)' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid serialized slice (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - 'Slice(a,b,c)', - 'Slice(1.5)', - 'Slice(0,1,0)' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid subsequence indexing expression (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - 'a:b:c', - ':1.5', - '0:1:0', - ':::', - '0:1:1:2' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid subsequence indexing expression (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - 'a:b:c', - ':1.5', - '0:1:0', - ':::', - '0:1:1:2' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid serialized array index (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - 'ArrayIndex<9999999>', - 'ArrayIndex<9999999999>' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an invalid serialized array index (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - 'ArrayIndex<9999999>', - 'ArrayIndex<9999999999>' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an unsupported array index (generic)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'cache': { - 'get': get - } - }); - - values = [ - array2fancy.idx( [ 0, 1, 2, 3 ] ), - array2fancy.idx( [ true, false, true, false ] ), - array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } - - function get() { - return { - 'data': [], - 'type': 'beep', - 'dtype': 'generic' - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when provided an unsupported array index (typed)', opts, function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'cache': { - 'get': get - } - }); - - values = [ - array2fancy.idx( [ 0, 1, 2, 3 ] ), - array2fancy.idx( [ true, false, true, false ] ), - array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 0; - }; - } - - function get() { - return { - 'data': [], - 'type': 'beep', - 'dtype': 'generic' - }; - } -}); diff --git a/to-fancy/test/test.set.mask_array.js b/to-fancy/test/test.set.mask_array.js deleted file mode 100644 index 93e980811..000000000 --- a/to-fancy/test/test.set.mask_array.js +++ /dev/null @@ -1,1563 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint32Array = require( './../../uint32' ); -var Uint16Array = require( './../../uint16' ); -var Uint8Array = require( './../../uint8' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting mask array assignment (generic)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = [ 5, 6, 3, 4 ]; - y[ idx ] = [ 5, 6, 0, 0 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = [ 1, 5, 6, 4 ]; - y[ idx ] = [ 0, 5, 6, 0 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = [ 5, 2, 6, 4 ]; - y[ idx ] = [ 5, 0, 6, 0 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting mask array assignment ("unknown" dtype, accessor)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = [ 5, 6, 3, 4 ]; - y[ idx ] = [ 5, 6, 0, 0 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = [ 1, 5, 6, 4 ]; - y[ idx ] = [ 0, 5, 6, 0 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = [ 5, 2, 6, 4 ]; - y[ idx ] = [ 5, 0, 6, 0 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting mask array assignment (int32)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Int32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Int32Array( [ 5, 6, 0, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Int32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Int32Array( [ 0, 5, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Int32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Int32Array( [ 5, 0, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting mask array assignment (uint32)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Uint32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Uint32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Uint32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Uint32Array( [ 5, 6, 0, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Uint32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Uint32Array( [ 0, 5, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Uint32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Uint32Array( [ 5, 0, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting mask array assignment (float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Float64Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Float64Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6, 0, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Float64Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 0, 5, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Float64Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 0, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting mask array assignment (complex128)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ idx ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20, 0, 0, 0, 0 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 0, 0, 17, 18, 19, 20, 0, 0 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 0, 0, 19, 20, 0, 0 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted mask array assignment (generic, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = [ 5, 5, 5, 5 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = [ 5, 5, 3, 4 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = [ 1, 5, 5, 4 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = [ 5, 2, 5, 4 ]; - y[ idx ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted mask array assignment (generic, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = [ 5, 5, 5, 5 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = [ 5, 5, 3, 4 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = [ 1, 5, 5, 4 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = [ 5, 2, 5, 4 ]; - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted mask array assignment (float64, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Float64Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Float64Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Float64Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Float64Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted mask array assignment (float64, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Float64Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Float64Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Float64Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Float64Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted mask array assignment (int32, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Int32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Int32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Int32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Int32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( [ -1, -3 ] ); - expected = new Int32Array( [ 1, 5, 3, 5 ] ); - y[ idx ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted mask array assignment (int32, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Int32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Int32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Int32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Int32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted mask array assignment (uint32, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Uint32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Uint32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Uint32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Uint32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted mask array assignment (uint32, scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Uint32Array( [ 5, 5, 5, 5 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Uint32Array( [ 5, 5, 3, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Uint32Array( [ 1, 5, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Uint32Array( [ 5, 2, 5, 4 ] ); - y[ idx ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted mask array assignment (complex128, array)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted mask array assignment (complex128, complex scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); - y[ idx ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted mask array assignment (complex128, real scalar)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Complex128Array( [ 9, 0, 9, 0, 9, 0, 9, 0 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Complex128Array( [ 9, 0, 9, 0, 5, 6, 7, 8 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Complex128Array( [ 1, 2, 9, 0, 9, 0, 7, 8 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Complex128Array( [ 9, 0, 3, 4, 9, 0, 7, 8 ] ); - y[ idx ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (generic, float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = [ 5, 6, 3, 4 ]; - y[ idx ] = new Float64Array( [ 5, 6, 0, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = [ 1, 5, 6, 4 ]; - y[ idx ] = new Float64Array( [ 0, 5, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = [ 5, 2, 6, 4 ]; - y[ idx ] = new Float64Array( [ 5, 0, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (float64, float32)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Float64Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Float32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Float64Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Float32Array( [ 5, 6, 0, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Float64Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Float32Array( [ 0, 5, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Float64Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Float32Array( [ 5, 0, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (int32, int8)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Int8Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Int32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Int8Array( [ 5, 6, 0, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Int32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Int8Array( [ 0, 5, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Int32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Int8Array( [ 5, 0, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (uint32, uint16)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Uint32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Uint16Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Uint32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Uint16Array( [ 5, 6, 0, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Uint32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Uint16Array( [ 0, 5, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Uint32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Uint16Array( [ 5, 0, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (complex128, complex64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ idx ] = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex64Array( [ 17, 18, 19, 20, 0, 0, 0, 0 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex64Array( [ 0, 0, 17, 18, 19, 20, 0, 0 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex64Array( [ 17, 18, 0, 0, 19, 20, 0, 0 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (complex128, float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Complex128Array( [ 9, 0, 10, 0, 11, 0, 12, 0 ] ); - y[ idx ] = new Float64Array( [ 9, 10, 11, 12 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Complex128Array( [ 17, 0, 18, 0, 5, 6, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 17, 18, 0, 0 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Complex128Array( [ 1, 2, 17, 0, 18, 0, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 0, 17, 18, 0 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Complex128Array( [ 17, 0, 3, 4, 18, 0, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 17, 0, 18, 0 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (float32, float64)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Float32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Float32Array( [ 5, 6, 3, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 6, 0, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Float32Array( [ 1, 5, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 0, 5, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Float32Array( [ 5, 2, 6, 4 ] ); - y[ idx ] = new Float64Array( [ 5, 0, 6, 0 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (complex64, complex128)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ) ); - expected = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ idx ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 1, 1 ] ) ); - expected = new Complex64Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 19, 20, 0, 0, 0, 0 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 1, 0, 0, 1 ] ) ); - expected = new Complex64Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 0, 0, 17, 18, 19, 20, 0, 0 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 1, 0, 1 ] ) ); - expected = new Complex64Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ idx ] = new Complex128Array( [ 17, 18, 0, 0, 19, 20, 0, 0 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (generic)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': true - }); - - values = [ - [], - [ 5, 6 ], - [ 5, 6, 7 ], - [ 5, 6, 7, 8, 9 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (int32)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': true - }); - - values = [ - new Int32Array( [] ), - new Int32Array( [ 5, 6 ] ), - new Int32Array( [ 5, 6, 7 ] ), - new Int32Array( [ 5, 6, 7, 8, 9 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (float64)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': true - }); - - values = [ - new Complex128Array( [ 5, 6 ] ), - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (complex128)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': true - }); - - values = [ - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int32)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': true - }); - - values = [ - new Uint32Array( [ 1 ] ), - new Uint32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int8)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Int8Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': true - }); - - values = [ - new Int32Array( [ 1 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - 999999, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (uint32)', function test( t ) { - var values; - var idx; - var x; - var y; - var i; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': true - }); - - values = [ - new Int32Array( [ 1 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - -3, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - - array2fancy.idx.free( idx ); - - t.end(); - - function badValue( value ) { - return function badValue() { - y[ idx ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (generic)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': false - }); - expected = [ 5, 6, 7, 8 ]; - y[ idx ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = [ 9, 10, 11, 12 ]; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when unable to resolve an index array (typed)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': false - }); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.throws( badValue( idx ), Error, 'throws an error' ); - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = new Int32Array( [ 9, 10, 11, 12 ] ); - }; - } -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (generic)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': true - }); - expected = [ 5, 6, 7, 8 ]; - - y[ idx ] = [ 5, 6, 7, 8 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - expected = [ 9, 10, 11, 12 ]; - - y[ idx ] = [ 9, 10, 11, 12 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); - -tape( 'the function returns an array-like object which supports persisted index arrays (typed)', opts, function test( t ) { - var expected; - var idx; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - idx = array2fancy.idx( new Uint8Array( [ 0, 0, 0, 0 ] ), { - 'persist': true - }); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - - y[ idx ] = new Int32Array( [ 5, 6, 7, 8 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - expected = new Int32Array( [ 9, 10, 11, 12 ] ); - - y[ idx ] = new Int32Array( [ 9, 10, 11, 12 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - array2fancy.idx.free( idx ); - - t.end(); -}); diff --git a/to-fancy/test/test.set.properties.js b/to-fancy/test/test.set.properties.js deleted file mode 100644 index 2b9ae5721..000000000 --- a/to-fancy/test/test.set.properties.js +++ /dev/null @@ -1,122 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' ); -var Symbol = require( '@stdlib/symbol/ctor' ); -var Int32Array = require( './../../int32' ); -var array2fancy = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting expected property assignment (generic)', function test( t ) { - var sym; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - x.foo = 'a'; - x.bar = 'b'; - - y = array2fancy( x ); - - t.strictEqual( y.foo, x.foo, 'returns expected value' ); - t.strictEqual( y.bar, x.bar, 'returns expected value' ); - t.strictEqual( y.beep, void 0, 'returns expected value' ); - t.strictEqual( y.boop, void 0, 'returns expected value' ); - - y.foo = 1; - y.bar = 2; - y.beep = true; - y.boop = false; - - t.strictEqual( x.foo, 1, 'returns expected value' ); - t.strictEqual( x.bar, 2, 'returns expected value' ); - t.strictEqual( x.beep, true, 'returns expected value' ); - t.strictEqual( x.boop, false, 'returns expected value' ); - - t.strictEqual( y.foo, 1, 'returns expected value' ); - t.strictEqual( y.bar, 2, 'returns expected value' ); - t.strictEqual( y.beep, true, 'returns expected value' ); - t.strictEqual( y.boop, false, 'returns expected value' ); - - if ( hasSymbolSupport() ) { - sym = Symbol( 'foo' ); - t.strictEqual( x[ sym ], void 0, 'returns expected value' ); - t.strictEqual( y[ sym ], void 0, 'returns expected value' ); - - y[ sym ] = 'bar'; - t.strictEqual( x[ sym ], 'bar', 'returns expected value' ); - t.strictEqual( y[ sym ], 'bar', 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an array-like object supporting expected property assignment (typed)', function test( t ) { - var sym; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - x.foo = 'a'; - x.bar = 'b'; - - y = array2fancy( x ); - - t.strictEqual( y.foo, x.foo, 'returns expected value' ); - t.strictEqual( y.bar, x.bar, 'returns expected value' ); - t.strictEqual( y.beep, void 0, 'returns expected value' ); - t.strictEqual( y.boop, void 0, 'returns expected value' ); - - y.foo = 1; - y.bar = 2; - y.beep = true; - y.boop = false; - - t.strictEqual( x.foo, 1, 'returns expected value' ); - t.strictEqual( x.bar, 2, 'returns expected value' ); - t.strictEqual( x.beep, true, 'returns expected value' ); - t.strictEqual( x.boop, false, 'returns expected value' ); - - t.strictEqual( y.foo, 1, 'returns expected value' ); - t.strictEqual( y.bar, 2, 'returns expected value' ); - t.strictEqual( y.beep, true, 'returns expected value' ); - t.strictEqual( y.boop, false, 'returns expected value' ); - - if ( hasSymbolSupport() ) { - sym = Symbol( 'foo' ); - t.strictEqual( x[ sym ], void 0, 'returns expected value' ); - t.strictEqual( y[ sym ], void 0, 'returns expected value' ); - - y[ sym ] = 'bar'; - t.strictEqual( x[ sym ], 'bar', 'returns expected value' ); - t.strictEqual( y[ sym ], 'bar', 'returns expected value' ); - } - t.end(); -}); diff --git a/to-fancy/test/test.set.slice.js b/to-fancy/test/test.set.slice.js deleted file mode 100644 index 0fc8109aa..000000000 --- a/to-fancy/test/test.set.slice.js +++ /dev/null @@ -1,1878 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var Slice = require( '@stdlib/slice/ctor' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint32Array = require( './../../uint32' ); -var Uint16Array = require( './../../uint16' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment (generic)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice(); - expected = [ 5, 6, 7, 8 ]; - y[ s ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = [ 5, 6, 3, 4 ]; - y[ s ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = [ 1, 5, 6, 4 ]; - y[ s ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = [ 5, 2, 6, 4 ]; - y[ s ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = [ 1, 6, 3, 5 ]; - y[ s ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment ("unknown" dtype, accessor)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - s = new Slice(); - expected = [ 5, 6, 7, 8 ]; - y[ s ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - s = new Slice( 2 ); - expected = [ 5, 6, 3, 4 ]; - y[ s ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - s = new Slice( 1, 3 ); - expected = [ 1, 5, 6, 4 ]; - y[ s ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - s = new Slice( null, null, 2 ); - expected = [ 5, 2, 6, 4 ]; - y[ s ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - s = new Slice( -1, null, -2 ); - expected = [ 1, 6, 3, 5 ]; - y[ s ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment (int32)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ s ] = new Int32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Int32Array( [ 5, 6, 3, 4 ] ); - y[ s ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Int32Array( [ 1, 5, 6, 4 ] ); - y[ s ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Int32Array( [ 5, 2, 6, 4 ] ); - y[ s ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Int32Array( [ 1, 6, 3, 5 ] ); - y[ s ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment (uint32)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Uint32Array( [ 5, 6, 7, 8 ] ); - y[ s ] = new Uint32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Uint32Array( [ 5, 6, 3, 4 ] ); - y[ s ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Uint32Array( [ 1, 5, 6, 4 ] ); - y[ s ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Uint32Array( [ 5, 2, 6, 4 ] ); - y[ s ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Uint32Array( [ 1, 6, 3, 5 ] ); - y[ s ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment (float64)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Float64Array( [ 5, 6, 7, 8 ] ); - y[ s ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Float64Array( [ 5, 6, 3, 4 ] ); - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Float64Array( [ 1, 5, 6, 4 ] ); - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Float64Array( [ 5, 2, 6, 4 ] ); - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Float64Array( [ 1, 6, 3, 5 ] ); - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment (complex128)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ s ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ s ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ s ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ s ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Complex128Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); - y[ s ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (generic, array)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice(); - expected = [ 5, 5, 5, 5 ]; - y[ s ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = [ 5, 5, 3, 4 ]; - y[ s ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = [ 1, 5, 5, 4 ]; - y[ s ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = [ 5, 2, 5, 4 ]; - y[ s ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = [ 1, 5, 3, 5 ]; - y[ s ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (generic, scalar)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice(); - expected = [ 5, 5, 5, 5 ]; - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = [ 5, 5, 3, 4 ]; - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = [ 1, 5, 5, 4 ]; - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = [ 5, 2, 5, 4 ]; - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = [ 1, 5, 3, 5 ]; - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (float64, array)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Float64Array( [ 5, 5, 5, 5 ] ); - y[ s ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Float64Array( [ 5, 5, 3, 4 ] ); - y[ s ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Float64Array( [ 1, 5, 5, 4 ] ); - y[ s ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Float64Array( [ 5, 2, 5, 4 ] ); - y[ s ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Float64Array( [ 1, 5, 3, 5 ] ); - y[ s ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (float64, scalar)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Float64Array( [ 5, 5, 5, 5 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Float64Array( [ 5, 5, 3, 4 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Float64Array( [ 1, 5, 5, 4 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Float64Array( [ 5, 2, 5, 4 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Float64Array( [ 1, 5, 3, 5 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (int32, array)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Int32Array( [ 5, 5, 5, 5 ] ); - y[ s ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Int32Array( [ 5, 5, 3, 4 ] ); - y[ s ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Int32Array( [ 1, 5, 5, 4 ] ); - y[ s ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Int32Array( [ 5, 2, 5, 4 ] ); - y[ s ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Int32Array( [ 1, 5, 3, 5 ] ); - y[ s ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (int32, scalar)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Int32Array( [ 5, 5, 5, 5 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Int32Array( [ 5, 5, 3, 4 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Int32Array( [ 1, 5, 5, 4 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Int32Array( [ 5, 2, 5, 4 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Int32Array( [ 1, 5, 3, 5 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (uint32, array)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Uint32Array( [ 5, 5, 5, 5 ] ); - y[ s ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Uint32Array( [ 5, 5, 3, 4 ] ); - y[ s ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Uint32Array( [ 1, 5, 5, 4 ] ); - y[ s ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Uint32Array( [ 5, 2, 5, 4 ] ); - y[ s ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Uint32Array( [ 1, 5, 3, 5 ] ); - y[ s ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (uint32, scalar)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Uint32Array( [ 5, 5, 5, 5 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Uint32Array( [ 5, 5, 3, 4 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Uint32Array( [ 1, 5, 5, 4 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Uint32Array( [ 5, 2, 5, 4 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Uint32Array( [ 1, 5, 3, 5 ] ); - y[ s ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (complex128, array)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); - y[ s ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); - y[ s ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); - y[ s ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); - y[ s ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Complex128Array( [ 1, 2, 9, 10, 5, 6, 9, 10 ] ); - y[ s ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (complex128, complex scalar)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); - y[ s ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); - y[ s ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); - y[ s ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); - y[ s ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Complex128Array( [ 1, 2, 9, 10, 5, 6, 9, 10 ] ); - y[ s ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (complex128, real scalar)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Complex128Array( [ 9, 0, 9, 0, 9, 0, 9, 0 ] ); - y[ s ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Complex128Array( [ 9, 0, 9, 0, 5, 6, 7, 8 ] ); - y[ s ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Complex128Array( [ 1, 2, 9, 0, 9, 0, 7, 8 ] ); - y[ s ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Complex128Array( [ 9, 0, 3, 4, 9, 0, 7, 8 ] ); - y[ s ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Complex128Array( [ 1, 2, 9, 0, 5, 6, 9, 0 ] ); - y[ s ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (generic, float64)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice(); - expected = [ 5, 6, 7, 8 ]; - y[ s ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = [ 5, 6, 3, 4 ]; - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = [ 1, 5, 6, 4 ]; - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = [ 5, 2, 6, 4 ]; - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = [ 1, 6, 3, 5 ]; - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (float64, float32)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Float64Array( [ 5, 6, 7, 8 ] ); - y[ s ] = new Float32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Float64Array( [ 5, 6, 3, 4 ] ); - y[ s ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Float64Array( [ 1, 5, 6, 4 ] ); - y[ s ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Float64Array( [ 5, 2, 6, 4 ] ); - y[ s ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Float64Array( [ 1, 6, 3, 5 ] ); - y[ s ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (int32, int8)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ s ] = new Int8Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Int32Array( [ 5, 6, 3, 4 ] ); - y[ s ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Int32Array( [ 1, 5, 6, 4 ] ); - y[ s ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Int32Array( [ 5, 2, 6, 4 ] ); - y[ s ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Int32Array( [ 1, 6, 3, 5 ] ); - y[ s ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (uint32, uint16)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Uint32Array( [ 5, 6, 7, 8 ] ); - y[ s ] = new Uint16Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Uint32Array( [ 5, 6, 3, 4 ] ); - y[ s ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Uint32Array( [ 1, 5, 6, 4 ] ); - y[ s ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Uint32Array( [ 5, 2, 6, 4 ] ); - y[ s ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Uint32Array( [ 1, 6, 3, 5 ] ); - y[ s ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (complex128, complex64)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ s ] = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ s ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ s ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ s ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Complex128Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); - y[ s ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (complex128, float64)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Complex128Array( [ 9, 0, 10, 0, 11, 0, 12, 0 ] ); - y[ s ] = new Float64Array( [ 9, 10, 11, 12 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Complex128Array( [ 17, 0, 18, 0, 5, 6, 7, 8 ] ); - y[ s ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Complex128Array( [ 1, 2, 17, 0, 18, 0, 7, 8 ] ); - y[ s ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Complex128Array( [ 17, 0, 3, 4, 18, 0, 7, 8 ] ); - y[ s ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Complex128Array( [ 1, 2, 18, 0, 5, 6, 17, 0 ] ); - y[ s ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (float32, float64)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Float32Array( [ 5, 6, 7, 8 ] ); - y[ s ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Float32Array( [ 5, 6, 3, 4 ] ); - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Float32Array( [ 1, 5, 6, 4 ] ); - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Float32Array( [ 5, 2, 6, 4 ] ); - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Float32Array( [ 1, 6, 3, 5 ] ); - y[ s ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (complex64, complex128)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice(); - expected = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ s ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 2 ); - expected = new Complex64Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ s ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( 1, 3 ); - expected = new Complex64Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ s ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( null, null, 2 ); - expected = new Complex64Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ s ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - s = new Slice( -1, null, -2 ); - expected = new Complex64Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); - y[ s ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function returns an array-like object which falls back to normal property assignment when provided a slice which is out-of-bounds (generic)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( 10, 20 ); - y[ s ] = [ 5 ]; // note: broadcast compatible with empty slice - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( -20, -10 ); - y[ s ] = [ 5 ]; - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - s = new Slice( -20 ); - y[ s ] = [ 5 ]; - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function returns an array-like object which leaves the array unchanged when provided a slice which is out-of-bounds (int32)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( 10, 20 ); - y[ s ] = new Int32Array( [ 5 ] ); // note: broadcast compatible with empty slice - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -20, -10 ); - y[ s ] = new Int32Array( [ 5 ] ); - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - s = new Slice( -20 ); - y[ s ] = new Int32Array( [ 5 ] ); - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which leaves the array unchanged when provided a slice which is out-of-bounds (generic)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - s = new Slice( 10, 20 ); - y[ s ] = [ 5 ]; // note: broadcast compatible with empty slice - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - s = new Slice( -20, -10 ); - y[ s ] = [ 5 ]; - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - s = new Slice( -20 ); - y[ s ] = [ 5 ]; - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which leaves the array unchanged when provided a slice which is out-of-bounds (int32)', opts, function test( t ) { - var expected; - var x; - var y; - var s; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - s = new Slice( 10, 20 ); - y[ s ] = new Int32Array( [ 5 ] ); // note: broadcast compatible with empty slice - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - s = new Slice( -20, -10 ); - y[ s ] = new Int32Array( [ 5 ] ); - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - s = new Slice( -20 ); - y[ s ] = new Int32Array( [ 5 ] ); - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided a slice which is out-of-bounds (generic)', opts, function test( t ) { - var x; - var y; - var s; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - s = new Slice( x.length+i, x.length+10 ); - t.throws( badValue( s ), RangeError, 'throws an error when provided ' + s ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 5; - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided a slice which is out-of-bounds (int32)', opts, function test( t ) { - var x; - var y; - var s; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - s = new Slice( x.length+i, x.length+10 ); - t.throws( badValue( s ), RangeError, 'throws an error when provided ' + s ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 5; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (generic)', function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - [ 5, 6 ], - [ 5, 6, 7 ], - [ 5, 6, 7, 8, 9 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ new Slice() ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (generic, out-of-bounds slice)', function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - [ 5, 6 ], - [ 5, 6, 7 ], - [ 5, 6, 7, 8 ], // note: this is as expected, as a zero-element slice is only compatible with either a zero- or one-element assigned value - [ 5, 6, 7, 8, 9 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ new Slice( 10, 20 ) ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (int32)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Int32Array( [ 5, 6 ] ), - new Int32Array( [ 5, 6, 7 ] ), - new Int32Array( [ 5, 6, 7, 8, 9 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ new Slice() ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (int32, out-of-bounds slice)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Int32Array( [ 5, 6 ] ), - new Int32Array( [ 5, 6, 7 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), // note: this is as expected, as a zero-element slice is only compatible with either a zero- or one-element assigned value - new Int32Array( [ 5, 6, 7, 8, 9 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ new Slice( 10, 20 ) ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (float64)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Complex128Array( [ 5, 6 ] ), - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ new Slice() ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (complex128)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - values = [ - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ new Slice() ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int32)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Uint32Array( [ 1 ] ), - new Uint32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ new Slice() ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int8)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int8Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Int32Array( [ 1 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - 999999, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ new Slice() ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (uint32)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Int32Array( [ 1 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - -3, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ new Slice() ] = value; - }; - } -}); diff --git a/to-fancy/test/test.set.subsequence.js b/to-fancy/test/test.set.subsequence.js deleted file mode 100644 index 9bd2ce9f5..000000000 --- a/to-fancy/test/test.set.subsequence.js +++ /dev/null @@ -1,1711 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var hasProxySupport = require( '@stdlib/assert/has-proxy-support' ); -var isSameComplex128Array = require( '@stdlib/assert/is-same-complex128array' ); -var isSameComplex64Array = require( '@stdlib/assert/is-same-complex64array' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint32Array = require( './../../uint32' ); -var Uint16Array = require( './../../uint16' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var toAccessorArray = require( './../../base/to-accessor-array' ); -var array2fancy = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': !hasProxySupport() -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2fancy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment (generic)', opts, function test( t ) { - var expected; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 6, 7, 8 ]; - y[ ':' ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 6, 3, 4 ]; - y[ ':2' ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 1, 5, 6, 4 ]; - y[ '1:3' ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 2, 6, 4 ]; - y[ '::2' ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 1, 6, 3, 5 ]; - y[ '-1::-2' ] = [ 5, 6 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment ("unknown" dtype, accessor)', opts, function test( t ) { - var expected; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - expected = [ 5, 6, 7, 8 ]; - y[ ':' ] = [ 5, 6, 7, 8 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - expected = [ 5, 6, 3, 4 ]; - y[ ':2' ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - expected = [ 1, 5, 6, 4 ]; - y[ '1:3' ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - expected = [ 5, 2, 6, 4 ]; - y[ '::2' ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( toAccessorArray( x ) ); - - expected = [ 1, 6, 3, 5 ]; - y[ '-1::-2' ] = [ 5, 6 ]; - - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment (int32)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ ':' ] = new Int32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 6, 3, 4 ] ); - y[ ':2' ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 1, 5, 6, 4 ] ); - y[ '1:3' ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 2, 6, 4 ] ); - y[ '::2' ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 1, 6, 3, 5 ] ); - y[ '-1::-2' ] = new Int32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment (uint32)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 6, 7, 8 ] ); - y[ ':' ] = new Uint32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 6, 3, 4 ] ); - y[ ':2' ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 1, 5, 6, 4 ] ); - y[ '1:3' ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 2, 6, 4 ] ); - y[ '::2' ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 1, 6, 3, 5 ] ); - y[ '-1::-2' ] = new Uint32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment (float64)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 6, 7, 8 ] ); - y[ ':' ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 6, 3, 4 ] ); - y[ ':2' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 1, 5, 6, 4 ] ); - y[ '1:3' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 2, 6, 4 ] ); - y[ '::2' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 1, 6, 3, 5 ] ); - y[ '-1::-2' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting slice assignment (complex128)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ ':' ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ ':2' ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ '1:3' ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ '::2' ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); - y[ '-1::-2' ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (generic, array)', opts, function test( t ) { - var expected; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 5, 5, 5 ]; - y[ ':' ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 5, 3, 4 ]; - y[ ':2' ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 1, 5, 5, 4 ]; - y[ '1:3' ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 2, 5, 4 ]; - y[ '::2' ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 1, 5, 3, 5 ]; - y[ '-1::-2' ] = [ 5 ]; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (generic, scalar)', opts, function test( t ) { - var expected; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 5, 5, 5 ]; - y[ ':' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 5, 3, 4 ]; - y[ ':2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 1, 5, 5, 4 ]; - y[ '1:3' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 2, 5, 4 ]; - y[ '::2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 1, 5, 3, 5 ]; - y[ '-1::-2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (float64, array)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 5, 5, 5 ] ); - y[ ':' ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 5, 3, 4 ] ); - y[ ':2' ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 1, 5, 5, 4 ] ); - y[ '1:3' ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 2, 5, 4 ] ); - y[ '::2' ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 1, 5, 3, 5 ] ); - y[ '-1::-2' ] = new Float64Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (float64, scalar)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 5, 5, 5 ] ); - y[ ':' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 5, 3, 4 ] ); - y[ ':2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 1, 5, 5, 4 ] ); - y[ '1:3' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 2, 5, 4 ] ); - y[ '::2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 1, 5, 3, 5 ] ); - y[ '-1::-2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (int32, array)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 5, 5, 5 ] ); - y[ ':' ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 5, 3, 4 ] ); - y[ ':2' ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 1, 5, 5, 4 ] ); - y[ '1:3' ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 2, 5, 4 ] ); - y[ '::2' ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 1, 5, 3, 5 ] ); - y[ '-1::-2' ] = new Int32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (int32, scalar)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 5, 5, 5 ] ); - y[ ':' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 5, 3, 4 ] ); - y[ ':2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 1, 5, 5, 4 ] ); - y[ '1:3' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 2, 5, 4 ] ); - y[ '::2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 1, 5, 3, 5 ] ); - y[ '-1::-2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (uint32, array)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 5, 5, 5 ] ); - y[ ':' ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 5, 3, 4 ] ); - y[ ':2' ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 1, 5, 5, 4 ] ); - y[ '1:3' ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 2, 5, 4 ] ); - y[ '::2' ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 1, 5, 3, 5 ] ); - y[ '-1::-2' ] = new Uint32Array( [ 5 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (uint32, scalar)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 5, 5, 5 ] ); - y[ ':' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 5, 3, 4 ] ); - y[ ':2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 1, 5, 5, 4 ] ); - y[ '1:3' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 2, 5, 4 ] ); - y[ '::2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 1, 5, 3, 5 ] ); - y[ '-1::-2' ] = 5; - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (complex128, array)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); - y[ ':' ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); - y[ ':2' ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); - y[ '1:3' ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); - y[ '::2' ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 9, 10, 5, 6, 9, 10 ] ); - y[ '-1::-2' ] = new Complex128Array( [ 9, 10 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (complex128, complex scalar)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 10, 9, 10, 9, 10, 9, 10 ] ); - y[ ':' ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 10, 9, 10, 5, 6, 7, 8 ] ); - y[ ':2' ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 9, 10, 9, 10, 7, 8 ] ); - y[ '1:3' ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 10, 3, 4, 9, 10, 7, 8 ] ); - y[ '::2' ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 9, 10, 5, 6, 9, 10 ] ); - y[ '-1::-2' ] = new Complex128( 9, 10 ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting broadcasted slice assignment (complex128, real scalar)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 0, 9, 0, 9, 0, 9, 0 ] ); - y[ ':' ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 0, 9, 0, 5, 6, 7, 8 ] ); - y[ ':2' ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 9, 0, 9, 0, 7, 8 ] ); - y[ '1:3' ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 0, 3, 4, 9, 0, 7, 8 ] ); - y[ '::2' ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 9, 0, 5, 6, 9, 0 ] ); - y[ '-1::-2' ] = 9; - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (generic, float64)', opts, function test( t ) { - var expected; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 6, 7, 8 ]; - y[ ':' ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 6, 3, 4 ]; - y[ ':2' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 1, 5, 6, 4 ]; - y[ '1:3' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 5, 2, 6, 4 ]; - y[ '::2' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - expected = [ 1, 6, 3, 5 ]; - y[ '-1::-2' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (float64, float32)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 6, 7, 8 ] ); - y[ ':' ] = new Float32Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 6, 3, 4 ] ); - y[ ':2' ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 1, 5, 6, 4 ] ); - y[ '1:3' ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 5, 2, 6, 4 ] ); - y[ '::2' ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float64Array( [ 1, 6, 3, 5 ] ); - y[ '-1::-2' ] = new Float32Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (int32, int8)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 6, 7, 8 ] ); - y[ ':' ] = new Int8Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 6, 3, 4 ] ); - y[ ':2' ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 1, 5, 6, 4 ] ); - y[ '1:3' ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 5, 2, 6, 4 ] ); - y[ '::2' ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Int32Array( [ 1, 6, 3, 5 ] ); - y[ '-1::-2' ] = new Int8Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (uint32, uint16)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 6, 7, 8 ] ); - y[ ':' ] = new Uint16Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 6, 3, 4 ] ); - y[ ':2' ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 1, 5, 6, 4 ] ); - y[ '1:3' ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 5, 2, 6, 4 ] ); - y[ '::2' ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Uint32Array( [ 1, 6, 3, 5 ] ); - y[ '-1::-2' ] = new Uint16Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (complex128, complex64)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ ':' ] = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ ':2' ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ '1:3' ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ '::2' ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); - y[ '-1::-2' ] = new Complex64Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting casting (complex128, float64)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 9, 0, 10, 0, 11, 0, 12, 0 ] ); - y[ ':' ] = new Float64Array( [ 9, 10, 11, 12 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 17, 0, 18, 0, 5, 6, 7, 8 ] ); - y[ ':2' ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 17, 0, 18, 0, 7, 8 ] ); - y[ '1:3' ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 17, 0, 3, 4, 18, 0, 7, 8 ] ); - y[ '::2' ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex128Array( [ 1, 2, 18, 0, 5, 6, 17, 0 ] ); - y[ '-1::-2' ] = new Float64Array( [ 17, 18 ] ); - - t.strictEqual( isSameComplex128Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (float32, float64)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float32Array( [ 5, 6, 7, 8 ] ); - y[ ':' ] = new Float64Array( [ 5, 6, 7, 8 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float32Array( [ 5, 6, 3, 4 ] ); - y[ ':2' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float32Array( [ 1, 5, 6, 4 ] ); - y[ '1:3' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float32Array( [ 5, 2, 6, 4 ] ); - y[ '::2' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Float32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - expected = new Float32Array( [ 1, 6, 3, 5 ] ); - y[ '-1::-2' ] = new Float64Array( [ 5, 6 ] ); - - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array-like object supporting downcasting of floating-point arrays (complex64, complex128)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex64Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - y[ ':' ] = new Complex128Array( [ 9, 10, 11, 12, 13, 14, 15, 16 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex64Array( [ 17, 18, 19, 20, 5, 6, 7, 8 ] ); - y[ ':2' ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex64Array( [ 1, 2, 17, 18, 19, 20, 7, 8 ] ); - y[ '1:3' ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex64Array( [ 17, 18, 3, 4, 19, 20, 7, 8 ] ); - y[ '::2' ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - x = new Complex64Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - expected = new Complex64Array( [ 1, 2, 19, 20, 5, 6, 17, 18 ] ); - y[ '-1::-2' ] = new Complex128Array( [ 17, 18, 19, 20 ] ); - - t.strictEqual( isSameComplex64Array( y, expected ), true, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function returns an array-like object which falls back to normal property assignment when provided a slice which is out-of-bounds (generic)', opts, function test( t ) { - var expected; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - y[ '10:20' ] = [ 5 ]; // note: broadcast compatible with empty slice - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - y[ '-20:-10' ] = [ 5 ]; - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - y[ ':-20' ] = [ 5 ]; - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'by default, the function returns an array-like object which leaves the array unchanged when provided a slice which is out-of-bounds (int32)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - y[ '10:20' ] = new Int32Array( [ 5 ] ); // note: broadcast compatible with empty slice - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - y[ '-20:-10' ] = new Int32Array( [ 5 ] ); - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - y[ ':-20' ] = new Int32Array( [ 5 ] ); - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which leaves the array unchanged when provided a slice which is out-of-bounds (generic)', opts, function test( t ) { - var expected; - var x; - var y; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - y[ '10:20' ] = [ 5 ]; // note: broadcast compatible with empty slice - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - y[ '-20:-10' ] = [ 5 ]; - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': false - }); - - y[ ':-20' ] = [ 5 ]; - - expected = [ 1, 2, 3, 4 ]; - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `false`, the function returns an array-like object which leaves the array unchanged when provided a slice which is out-of-bounds (int32)', opts, function test( t ) { - var expected; - var x; - var y; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - y[ '10:20' ] = new Int32Array( [ 5 ] ); // note: broadcast compatible with empty slice - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - y[ '-20:-10' ] = new Int32Array( [ 5 ] ); - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': false - }); - - y[ ':-20' ] = new Int32Array( [ 5 ] ); - - expected = new Int32Array( [ 1, 2, 3, 4 ] ); - t.deepEqual( y, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided a slice which is out-of-bounds (generic)', opts, function test( t ) { - var x; - var y; - var s; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - s = ( x.length+i ) + ':' + ( x.length+10 ); - t.throws( badValue( s ), RangeError, 'throws an error when provided ' + s ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 5; - }; - } -}); - -tape( 'when `strict` is `true`, the function returns an array-like object which throws an error when provided a slice which is out-of-bounds (int32)', opts, function test( t ) { - var x; - var y; - var s; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x, { - 'strict': true - }); - - for ( i = 0; i < 10; i++ ) { - s = ( x.length+i ) + ':' + ( x.length+10 ); - t.throws( badValue( s ), RangeError, 'throws an error when provided ' + s ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ value ] = 5; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (generic)', function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - [ 5, 6 ], - [ 5, 6, 7 ], - [ 5, 6, 7, 8, 9 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ ':' ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (generic, out-of-bounds slice)', function test( t ) { - var values; - var x; - var y; - var i; - - x = [ 1, 2, 3, 4 ]; - y = array2fancy( x ); - - values = [ - [ 5, 6 ], - [ 5, 6, 7 ], - [ 5, 6, 7, 8 ], // note: this is as expected, as a zero-element slice is only compatible with either a zero- or one-element assigned value - [ 5, 6, 7, 8, 9 ] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ '10:20' ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (int32)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Int32Array( [ 5, 6 ] ), - new Int32Array( [ 5, 6, 7 ] ), - new Int32Array( [ 5, 6, 7, 8, 9 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ ':' ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to assign a broadcast-incompatible array (int32, out-of-bounds slice)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Int32Array( [ 5, 6 ] ), - new Int32Array( [ 5, 6, 7 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), // note: this is as expected, as a zero-element slice is only compatible with either a zero- or one-element assigned value - new Int32Array( [ 5, 6, 7, 8, 9 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ '10:20' ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (float64)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Float64Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Complex128Array( [ 5, 6 ] ), - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ ':' ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (complex128)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Complex128Array( [ 1, 2, 3, 4, 5, 6, 7, 8 ] ); - y = array2fancy( x ); - - values = [ - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ ':' ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int32)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Uint32Array( [ 1 ] ), - new Uint32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ ':' ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (int8)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Int8Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Int32Array( [ 1 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - 999999, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ ':' ] = value; - }; - } -}); - -tape( 'the function returns an array-like object which throws an error when attempting to perform an unsafe cast (uint32)', function test( t ) { - var values; - var x; - var y; - var i; - - x = new Uint32Array( [ 1, 2, 3, 4 ] ); - y = array2fancy( x ); - - values = [ - new Int32Array( [ 1 ] ), - new Int32Array( [ 5, 6, 7, 8 ] ), - new Float64Array( [ 1 ] ), - new Float64Array( [ 5, 6, 7, 8 ] ), - new Float32Array( [ 1 ] ), - new Float32Array( [ 5, 6, 7, 8 ] ), - new Complex128Array( [ 5, 6 ] ), - -3, - 3.14, - -3.14, - new Complex128( 5, 6 ), - '5', - true, - false - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - y[ ':' ] = value; - }; - } -}); diff --git a/to-fancy/test/test.validate.js b/to-fancy/test/test.validate.js deleted file mode 100644 index 68910ccd7..000000000 --- a/to-fancy/test/test.validate.js +++ /dev/null @@ -1,161 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var validate = require( './../lib/validate.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof validate, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an error if not provided an options object', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, values[i] ); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `strict` option which is not a boolean', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'strict': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns an error if provided a `cache` option which is not valid', function test( t ) { - var values; - var err; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - err = validate( {}, { - 'cache': values[i] - }); - t.strictEqual( err instanceof TypeError, true, 'returns an error when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function returns `null` if all options are valid', function test( t ) { - var expected; - var options; - var opts; - var err; - - options = { - 'strict': true, - 'cache': { - 'get': get - } - }; - opts = {}; - - expected = { - 'strict': true, - 'cache': options.cache - }; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, expected, 'returns expected value' ); - - t.end(); - - function get() { - // No-op... - } -}); - -tape( 'the function ignores unrecognized options', function test( t ) { - var options; - var opts; - var err; - - options = { - 'beep': 'boop', - 'foo': 5, - 'bar': {} - }; - - opts = {}; - - err = validate( opts, options ); - - t.strictEqual( err, null, 'returns expected value' ); - t.deepEqual( opts, {}, 'returns expected value' ); - - t.end(); -}); diff --git a/to-iterator-right/README.md b/to-iterator-right/README.md deleted file mode 100644 index cba1a5312..000000000 --- a/to-iterator-right/README.md +++ /dev/null @@ -1,244 +0,0 @@ - - -# array2iteratorRight - -> Create an iterator from an array-like object, iterating from right to left. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var array2iteratorRight = require( '@stdlib/array/to-iterator-right' ); -``` - -#### array2iteratorRight( src\[, mapFcn\[, thisArg]] ) - -Returns an iterator which iterates from right to left over each element in an array-like `object`. - -```javascript -var it = array2iteratorRight( [ 1, 2, 3, 4 ] ); -// returns - -var v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 2 - -// ... -``` - -The returned iterator protocol-compliant object has the following properties: - -- **next**: function which returns an iterator protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the iterator is finished. -- **return**: function which closes an iterator and returns a single (optional) argument in an iterator protocol-compliant object. - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function fcn( v ) { - return v * 10.0; -} - -var it = array2iteratorRight( [ 1, 2, 3, 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 40.0 - -v = it.next().value; -// returns 30.0 - -v = it.next().value; -// returns 20.0 - -// ... -``` - -The invoked function is provided three arguments: - -- **value**: iterated value. -- **index**: iterated value index. -- **src**: source array-like object. - -```javascript -function fcn( v, i ) { - return v * (i+1); -} - -var it = array2iteratorRight( [ 1, 2, 3, 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 16 - -v = it.next().value; -// returns 9 - -v = it.next().value; -// returns 4 - -// ... -``` - -To set the callback function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return v * 10.0; -} - -var ctx = { - 'count': 0 -}; - -var it = array2iteratorRight( [ 1, 2, 3, 4 ], fcn, ctx ); -// returns - -var v = it.next().value; -// returns 40.0 - -v = it.next().value; -// returns 30.0 - -v = it.next().value; -// returns 20.0 - -var count = ctx.count; -// returns 3 -``` - - - - - - - -
- -## Notes - -- If an environment supports `Symbol.iterator`, the returned iterator is iterable. -- If provided a generic `array`, the returned iterator does **not** ignore holes. To achieve greater performance for sparse arrays, use [`@stdlib/array/to-sparse-iterator-right`][@stdlib/array/to-sparse-iterator-right]. -- A returned iterator does **not** copy a provided array-like `object`. To ensure iterable reproducibility, copy a provided array-like `object` **before** creating an iterator. Otherwise, any changes to the contents of an array-like `object` will be reflected in the returned iterator. -- In environments supporting `Symbol.iterator`, the function **explicitly** does **not** invoke an array's `@@iterator` method, regardless of whether this method is defined. To convert an array to an implementation defined iterator, invoke this method directly. -- The returned iterator supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]). - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var array2iteratorRight = require( '@stdlib/array/to-iterator-right' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 100 ), randu ); - -// Create an iterator from the array which scales iterated values: -var it = array2iteratorRight( arr, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-iterator-right/benchmark/benchmark.js b/to-iterator-right/benchmark/benchmark.js deleted file mode 100644 index 43f2ca35c..000000000 --- a/to-iterator-right/benchmark/benchmark.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var array2iteratorRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var iter; - var i; - - values = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - values[ 0 ] = i; - iter = array2iteratorRight( values ); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - values.length = b.iterations; - - iter = array2iteratorRight( values ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( z !== void 0 ) { - b.fail( 'should be undefined' ); - } - } - b.toc(); - if ( z !== void 0 ) { - b.fail( 'should be undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration,map', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - values.length = b.iterations; - - iter = array2iteratorRight( values, transform ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return i; - } -}); diff --git a/to-iterator-right/docs/repl.txt b/to-iterator-right/docs/repl.txt deleted file mode 100644 index f16c01791..000000000 --- a/to-iterator-right/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( src[, mapFcn[, thisArg]] ) - Returns an iterator which iterates from right to left over the elements of - an array-like object. - - When invoked, an input function is provided three arguments: - - - value: iterated value. - - index: iterated value index. - - src: source array-like object. - - If an environment supports Symbol.iterator, the returned iterator is - iterable. - - If an environment supports Symbol.iterator, the function explicitly does not - invoke an array's `@@iterator` method, regardless of whether this method is - defined. To convert an array to an implementation defined iterator, invoke - this method directly. - - Parameters - ---------- - src: ArrayLikeObject - Array-like object from which to create the iterator. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - iterator: Object - Iterator. - - iterator.next(): Function - Returns an iterator protocol-compliant object containing the next - iterated value (if one exists) and a boolean flag indicating whether the - iterator is finished. - - iterator.return( [value] ): Function - Finishes an iterator and returns a provided value. - - Examples - -------- - > var it = {{alias}}( [ 1, 2, 3, 4 ] ); - > var v = it.next().value - 4 - > v = it.next().value - 3 - - See Also - -------- - diff --git a/to-iterator-right/docs/types/index.d.ts b/to-iterator-right/docs/types/index.d.ts deleted file mode 100644 index f2e7d012b..000000000 --- a/to-iterator-right/docs/types/index.d.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Returns an iterator which iterates from right to left over each element in an array-like object. -* -* ## Notes -* -* - For dynamic array resizing, the only behavior made intentionally consistent with iterating from left to right is when elements are pushed onto the beginning (end) of an array. In other words, iterating from left to right combined with `[].push()` is consistent with iterating from right to left combined with `[].unshift()`. -* -* @param src - input value -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns iterator -* -* @example -* var iter = array2iteratorRight( [ 1, 2, 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 4 -* -* v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 2 -* -* // ... -*/ -declare function array2iteratorRight( src: ArrayLike, mapFcn?: MapFunction, thisArg?: any ): Iterator; - - -// EXPORTS // - -export = array2iteratorRight; diff --git a/to-iterator-right/docs/types/test.ts b/to-iterator-right/docs/types/test.ts deleted file mode 100644 index a1fa0cf72..000000000 --- a/to-iterator-right/docs/types/test.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import array2iteratorRight = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - array2iteratorRight( [ 1, 2, 3, 4 ] ); // $ExpectType Iterator - array2iteratorRight( [ 1, 2, 3, 4 ], times10 ); // $ExpectType Iterator - array2iteratorRight( [ 1, 2, 3, 4 ], times10, {} ); // $ExpectType Iterator -} - -// The compiler throws an error if the function is provided a first argument which is not array-like... -{ - array2iteratorRight( 123 ); // $ExpectError - array2iteratorRight( true ); // $ExpectError - array2iteratorRight( false ); // $ExpectError - array2iteratorRight( {} ); // $ExpectError - array2iteratorRight( null ); // $ExpectError - array2iteratorRight( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function... -{ - array2iteratorRight( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - array2iteratorRight( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - array2iteratorRight( [ 1, 2, 3, 4 ], [] ); // $ExpectError - array2iteratorRight( [ 1, 2, 3, 4 ], {} ); // $ExpectError - array2iteratorRight( [ 1, 2, 3, 4 ], true ); // $ExpectError - array2iteratorRight( [ 1, 2, 3, 4 ], false ); // $ExpectError - array2iteratorRight( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - array2iteratorRight(); // $ExpectError - array2iteratorRight( [ 1, 2, 3, 4 ], times10, {}, 123 ); // $ExpectError -} diff --git a/to-iterator-right/examples/index.js b/to-iterator-right/examples/index.js deleted file mode 100644 index 3a4979cb3..000000000 --- a/to-iterator-right/examples/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( './../../float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var array2iteratorRight = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 100 ), randu ); - -// Create an iterator from the array which scales iterated values: -var it = array2iteratorRight( arr, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} diff --git a/to-iterator-right/lib/index.js b/to-iterator-right/lib/index.js deleted file mode 100644 index e50d8d15c..000000000 --- a/to-iterator-right/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an iterator from an array-like object, iterating from right to left. -* -* @module @stdlib/array/to-iterator-right -* -* @example -* var array2iteratorRight = require( '@stdlib/array/to-iterator-right' ); -* -* var iter = array2iteratorRight( [ 1, 2, 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 4 -* -* v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 2 -* -* // ... -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-iterator-right/lib/main.js b/to-iterator-right/lib/main.js deleted file mode 100644 index 4adb126b5..000000000 --- a/to-iterator-right/lib/main.js +++ /dev/null @@ -1,187 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isAccessorArray = require( './../../base/assert/is-accessor-array' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var getter = require( './../../base/getter' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns an iterator which iterates from right to left over each element in an array-like object. -* -* ## Notes -* -* - For dynamic array resizing, the only behavior made intentionally consistent with iterating from left to right is when elements are pushed onto the beginning (end) of an array. In other words, iterating from left to right combined with `[].push()` is consistent with iterating from right to left combined with `[].unshift()`. -* -* @param {Collection} src - input value -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} second argument must be a function -* @returns {Iterator} iterator -* -* @example -* var iter = array2iteratorRight( [ 1, 2, 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 4 -* -* v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 2 -* -* // ... -*/ -function array2iteratorRight( src ) { - var thisArg; - var iter; - var FLG; - var fcn; - var len; - var get; - var dt; - var i; - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); - } - if ( arguments.length > 1 ) { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - len = src.length; - i = len; - - // Create an iterator protocol-compliant object: - iter = {}; - if ( fcn ) { - setReadOnly( iter, 'next', next1 ); - } else { - setReadOnly( iter, 'next', next2 ); - } - setReadOnly( iter, 'return', end ); - - // If an environment supports `Symbol.iterator`, make the iterator iterable: - if ( iteratorSymbol ) { - setReadOnly( iter, iteratorSymbol, factory ); - } - // Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc): - dt = dtype( src ); - if ( isAccessorArray( src ) ) { - get = accessorGetter( dt ); - } else { - get = getter( dt ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next1() { - i += src.length - len - 1; // accounts for a dynamic array - len = src.length; - if ( FLG || i < 0 ) { - FLG = true; - return { - 'done': true - }; - } - return { - 'value': fcn.call( thisArg, get( src, i ), i, src ), - 'done': false - }; - } - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next2() { - i += src.length - len - 1; // accounts for a dynamic array - len = src.length; - if ( FLG || i < 0 ) { - FLG = true; - return { - 'done': true - }; - } - return { - 'value': get( src, i ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - if ( fcn ) { - return array2iteratorRight( src, fcn, thisArg ); - } - return array2iteratorRight( src ); - } -} - - -// EXPORTS // - -module.exports = array2iteratorRight; diff --git a/to-iterator-right/package.json b/to-iterator-right/package.json deleted file mode 100644 index b869dd856..000000000 --- a/to-iterator-right/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/to-iterator-right", - "version": "0.0.0", - "description": "Create an iterator from an array-like object, iterating from right to left.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "arr", - "typed-array", - "typed array", - "iterator", - "iterate", - "iteration", - "iter", - "to", - "convert" - ] -} diff --git a/to-iterator-right/test/test.js b/to-iterator-right/test/test.js deleted file mode 100644 index 20f19b48c..000000000 --- a/to-iterator-right/test/test.js +++ /dev/null @@ -1,492 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var noop = require( '@stdlib/utils/noop' ); -var array2iteratorRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2iteratorRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - array2iteratorRight( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - array2iteratorRight( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - array2iteratorRight( [ 1, 2, 3, 4 ], value ); - }; - } -}); - -tape( 'the function returns an iterator protocol-compliant object, iterating from right to left', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - - it = array2iteratorRight( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object, iterating from right to left (array-like object)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - - it = array2iteratorRight( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = array2iteratorRight( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (array-like)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - - it = array2iteratorRight( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var it; - var r; - - it = array2iteratorRight( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument; callback)', function test( t ) { - var it; - var r; - - it = array2iteratorRight( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var it; - var r; - - it = array2iteratorRight( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument; callback)', function test( t ) { - var it; - var r; - - it = array2iteratorRight( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable', function test( t ) { - var array2iteratorRight; - var values; - var it1; - var it2; - var i; - - array2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = array2iteratorRight( values ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (callback)', function test( t ) { - var array2iteratorRight; - var values; - var it1; - var it2; - var i; - - array2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = array2iteratorRight( values, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable"', function test( t ) { - var array2iteratorRight; - var it; - - array2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = array2iteratorRight( [ 1, 2, 3, 4 ] ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (callback)', function test( t ) { - var array2iteratorRight; - var it; - - array2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = array2iteratorRight( [ 1, 2, 3, 4 ], scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/to-iterator/README.md b/to-iterator/README.md deleted file mode 100644 index 3823ca6b9..000000000 --- a/to-iterator/README.md +++ /dev/null @@ -1,250 +0,0 @@ - - -# array2iterator - -> Create an iterator from an array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var array2iterator = require( '@stdlib/array/to-iterator' ); -``` - -#### array2iterator( src\[, mapFcn\[, thisArg]] ) - -Returns an iterator which iterates over each element in an array-like `object`. - -```javascript -var it = array2iterator( [ 1, 2, 3, 4 ] ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 3 - -// ... -``` - -The returned iterator protocol-compliant object has the following properties: - -- **next**: function which returns an iterator protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the iterator is finished. -- **return**: function which closes an iterator and returns a single (optional) argument in an iterator protocol-compliant object. - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function fcn( v ) { - return v * 10.0; -} - -var it = array2iterator( [ 1, 2, 3, 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 10.0 - -v = it.next().value; -// returns 20.0 - -v = it.next().value; -// returns 30.0 - -// ... -``` - -The invoked function is provided three arguments: - -- **value**: iterated value. -- **index**: iterated value index. -- **src**: source array-like object. - -```javascript -function fcn( v, i ) { - return v * (i+1); -} - -var it = array2iterator( [ 1, 2, 3, 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 9 - -// ... -``` - -To set the callback function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return v * 10.0; -} - -var ctx = { - 'count': 0 -}; - -var it = array2iterator( [ 1, 2, 3, 4 ], fcn, ctx ); -// returns - -var v = it.next().value; -// returns 10.0 - -v = it.next().value; -// returns 20.0 - -v = it.next().value; -// returns 30.0 - -var count = ctx.count; -// returns 3 -``` - - - - - - - -
- -## Notes - -- If an environment supports `Symbol.iterator`, the returned iterator is iterable. -- If provided a generic `array`, the returned iterator does **not** ignore holes. To achieve greater performance for sparse arrays, use [`@stdlib/array/to-sparse-iterator`][@stdlib/array/to-sparse-iterator]. -- A returned iterator does **not** copy a provided array-like `object`. To ensure iterable reproducibility, copy a provided array-like `object` **before** creating an iterator. Otherwise, any changes to the contents of an array-like `object` will be reflected in the returned iterator. -- In environments supporting `Symbol.iterator`, the function **explicitly** does **not** invoke an array's `@@iterator` method, regardless of whether this method is defined. To convert an array to an implementation defined iterator, invoke this method directly. -- The returned iterator supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]). - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var array2iterator = require( '@stdlib/array/to-iterator' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 100 ), randu ); - -// Create an iterator from the array which scales iterated values: -var it = array2iterator( arr, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-iterator/benchmark/benchmark.js b/to-iterator/benchmark/benchmark.js deleted file mode 100644 index e59e77b14..000000000 --- a/to-iterator/benchmark/benchmark.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var array2iterator = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var iter; - var i; - - values = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - values[ 0 ] = i; - iter = array2iterator( values ); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - values.length = b.iterations; - - iter = array2iterator( values ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( z !== void 0 ) { - b.fail( 'should be undefined' ); - } - } - b.toc(); - if ( z !== void 0 ) { - b.fail( 'should be undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration,map', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - values.length = b.iterations; - - iter = array2iterator( values, transform ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return i; - } -}); diff --git a/to-iterator/docs/repl.txt b/to-iterator/docs/repl.txt deleted file mode 100644 index a84a4d0d2..000000000 --- a/to-iterator/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( src[, mapFcn[, thisArg]] ) - Returns an iterator which iterates over the elements of an array-like - object. - - When invoked, an input function is provided three arguments: - - - value: iterated value. - - index: iterated value index. - - src: source array-like object. - - If an environment supports Symbol.iterator, the returned iterator is - iterable. - - If an environment supports Symbol.iterator, the function explicitly does not - invoke an array's `@@iterator` method, regardless of whether this method is - defined. To convert an array to an implementation defined iterator, invoke - this method directly. - - Parameters - ---------- - src: ArrayLikeObject - Array-like object from which to create the iterator. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - iterator: Object - Iterator. - - iterator.next(): Function - Returns an iterator protocol-compliant object containing the next - iterated value (if one exists) and a boolean flag indicating whether the - iterator is finished. - - iterator.return( [value] ): Function - Finishes an iterator and returns a provided value. - - Examples - -------- - > var it = {{alias}}( [ 1, 2, 3, 4 ] ); - > var v = it.next().value - 1 - > v = it.next().value - 2 - - See Also - -------- - diff --git a/to-iterator/docs/types/index.d.ts b/to-iterator/docs/types/index.d.ts deleted file mode 100644 index d5e6f59c0..000000000 --- a/to-iterator/docs/types/index.d.ts +++ /dev/null @@ -1,100 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Returns an iterator which iterates over each element in an array-like object. -* -* @param src - input value -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns iterator -* -* @example -* var iter = array2iterator( [ 1, 2, 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 1 -* -* v = iter.next().value; -* // returns 2 -* -* v = iter.next().value; -* // returns 3 -* -* // ... -*/ -declare function array2iterator( src: ArrayLike, mapFcn?: MapFunction, thisArg?: any ): Iterator; - - -// EXPORTS // - -export = array2iterator; diff --git a/to-iterator/docs/types/test.ts b/to-iterator/docs/types/test.ts deleted file mode 100644 index 561feb716..000000000 --- a/to-iterator/docs/types/test.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import array2iterator = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - array2iterator( [ 1, 2, 3, 4 ] ); // $ExpectType Iterator - array2iterator( [ 1, 2, 3, 4 ], times10 ); // $ExpectType Iterator - array2iterator( [ 1, 2, 3, 4 ], times10, {} ); // $ExpectType Iterator -} - -// The compiler throws an error if the function is provided a first argument which is not array-like... -{ - array2iterator( 123 ); // $ExpectError - array2iterator( true ); // $ExpectError - array2iterator( false ); // $ExpectError - array2iterator( {} ); // $ExpectError - array2iterator( null ); // $ExpectError - array2iterator( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function... -{ - array2iterator( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - array2iterator( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - array2iterator( [ 1, 2, 3, 4 ], [] ); // $ExpectError - array2iterator( [ 1, 2, 3, 4 ], {} ); // $ExpectError - array2iterator( [ 1, 2, 3, 4 ], true ); // $ExpectError - array2iterator( [ 1, 2, 3, 4 ], false ); // $ExpectError - array2iterator( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - array2iterator(); // $ExpectError - array2iterator( [ 1, 2, 3, 4 ], times10, {}, 123 ); // $ExpectError -} diff --git a/to-iterator/examples/index.js b/to-iterator/examples/index.js deleted file mode 100644 index c7f3c665a..000000000 --- a/to-iterator/examples/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( './../../float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var array2iterator = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 100 ), randu ); - -// Create an iterator from the array which scales iterated values: -var it = array2iterator( arr, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} diff --git a/to-iterator/lib/index.js b/to-iterator/lib/index.js deleted file mode 100644 index 210a4c98a..000000000 --- a/to-iterator/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an iterator from an array-like object. -* -* @module @stdlib/array/to-iterator -* -* @example -* var array2iterator = require( '@stdlib/array/to-iterator' ); -* -* var iter = array2iterator( [ 1, 2, 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 1 -* -* v = iter.next().value; -* // returns 2 -* -* v = iter.next().value; -* // returns 3 -* -* // ... -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-iterator/lib/main.js b/to-iterator/lib/main.js deleted file mode 100644 index 88522a809..000000000 --- a/to-iterator/lib/main.js +++ /dev/null @@ -1,177 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isAccessorArray = require( './../../base/assert/is-accessor-array' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var getter = require( './../../base/getter' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns an iterator which iterates over each element in an array-like object. -* -* @param {Collection} src - input value -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} second argument must be a function -* @returns {Iterator} iterator -* -* @example -* var iter = array2iterator( [ 1, 2, 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 1 -* -* v = iter.next().value; -* // returns 2 -* -* v = iter.next().value; -* // returns 3 -* -* // ... -*/ -function array2iterator( src ) { - var thisArg; - var iter; - var FLG; - var fcn; - var get; - var dt; - var i; - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); - } - if ( arguments.length > 1 ) { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - if ( fcn ) { - setReadOnly( iter, 'next', next1 ); - } else { - setReadOnly( iter, 'next', next2 ); - } - setReadOnly( iter, 'return', end ); - - // If an environment supports `Symbol.iterator`, make the iterator iterable: - if ( iteratorSymbol ) { - setReadOnly( iter, iteratorSymbol, factory ); - } - // Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc): - dt = dtype( src ); - if ( isAccessorArray( src ) ) { - get = accessorGetter( dt ); - } else { - get = getter( dt ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next1() { - i += 1; - if ( FLG || i >= src.length ) { - return { - 'done': true - }; - } - return { - 'value': fcn.call( thisArg, get( src, i ), i, src ), - 'done': false - }; - } - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next2() { - i += 1; - if ( FLG || i >= src.length ) { - return { - 'done': true - }; - } - return { - 'value': get( src, i ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - if ( fcn ) { - return array2iterator( src, fcn, thisArg ); - } - return array2iterator( src ); - } -} - - -// EXPORTS // - -module.exports = array2iterator; diff --git a/to-iterator/package.json b/to-iterator/package.json deleted file mode 100644 index b2b4d6a7e..000000000 --- a/to-iterator/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/to-iterator", - "version": "0.0.0", - "description": "Create an iterator from an array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "arr", - "typed-array", - "typed array", - "iterator", - "iterate", - "iteration", - "iter", - "to", - "convert" - ] -} diff --git a/to-iterator/test/test.js b/to-iterator/test/test.js deleted file mode 100644 index 80a28dce3..000000000 --- a/to-iterator/test/test.js +++ /dev/null @@ -1,616 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var noop = require( '@stdlib/utils/noop' ); -var Complex64Array = require( './../../complex64' ); -var realf = require( '@stdlib/complex/float32/real' ); -var imagf = require( '@stdlib/complex/float32/imag' ); -var Complex64 = require( '@stdlib/complex/float32/ctor' ); -var array2iterator = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof array2iterator, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - array2iterator( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - array2iterator( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - array2iterator( [ 1, 2, 3, 4 ], value ); - }; - } -}); - -tape( 'the function returns an iterator protocol-compliant object', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = array2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (array-like object)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = array2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (accessors)', function test( t ) { - var expected; - var actual; - var values; - var it; - var v1; - var v2; - var r; - var i; - - values = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - expected = [ - { - 'value': new Complex64( 1.0, 2.0 ), - 'done': false - }, - { - 'value': new Complex64( 3.0, 4.0 ), - 'done': false - }, - { - 'value': new Complex64( 5.0, 6.0 ), - 'done': false - }, - { - 'value': new Complex64( 7.0, 8.0 ), - 'done': false - }, - { - 'done': true - } - ]; - - it = array2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'object', 'returns an object' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.equal( actual.length, expected.length, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - v1 = actual[ i ]; - v2 = expected[ i ]; - if ( i < expected.length-1 ) { - t.equal( realf( v1.value ), realf( v2.value ), 'returns expected value' ); - t.equal( imagf( v1.value ), imagf( v2.value ), 'returns expected value' ); - } - t.equal( v1.done, v2.done, 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = array2iterator( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (array-like)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - - it = array2iterator( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (accessors)', function test( t ) { - var expected; - var actual; - var values; - var it; - var v1; - var v2; - var r; - var i; - - values = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); - expected = [ - { - 'value': new Complex64( 2.0, 4.0 ), - 'done': false - }, - { - 'value': new Complex64( 6.0, 8.0 ), - 'done': false - }, - { - 'value': new Complex64( 10.0, 12.0 ), - 'done': false - }, - { - 'value': new Complex64( 14.0, 16.0 ), - 'done': false - }, - { - 'done': true - } - ]; - - it = array2iterator( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'object', 'returns an object' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.equal( actual.length, expected.length, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - v1 = actual[ i ]; - v2 = expected[ i ]; - if ( i < expected.length-1 ) { - t.equal( realf( v1.value ), realf( v2.value ), 'returns expected value' ); - t.equal( imagf( v1.value ), imagf( v2.value ), 'returns expected value' ); - } - t.equal( v1.done, v2.done, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return new Complex64( realf( v )*2.0, imagf( v )*2.0 ); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var it; - var r; - - it = array2iterator( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument; callback)', function test( t ) { - var it; - var r; - - it = array2iterator( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var it; - var r; - - it = array2iterator( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument; callback)', function test( t ) { - var it; - var r; - - it = array2iterator( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable', function test( t ) { - var array2iterator; - var values; - var it1; - var it2; - var i; - - array2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = array2iterator( values ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (callback)', function test( t ) { - var array2iterator; - var values; - var it1; - var it2; - var i; - - array2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = array2iterator( values, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable"', function test( t ) { - var array2iterator; - var it; - - array2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = array2iterator( [ 1, 2, 3, 4 ] ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (callback)', function test( t ) { - var array2iterator; - var it; - - array2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = array2iterator( [ 1, 2, 3, 4 ], scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/to-json/README.md b/to-json/README.md deleted file mode 100644 index 4104b8850..000000000 --- a/to-json/README.md +++ /dev/null @@ -1,310 +0,0 @@ - - -# typedarray2json - -> Return a [JSON][json] representation of a typed array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var typedarray2json = require( '@stdlib/array/to-json' ); -``` - -#### typedarray2json( typedarray ) - -Returns a [JSON][json] representation of a typed array. - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); - -var arr = new Float64Array( [ 5.0, 3.0 ] ); - -var json = typedarray2json( arr ); -/* returns - { - 'type': 'Float64Array', - 'data': [ 5.0, 3.0 ] - } -*/ -``` - -For guidance on reviving a JSON-serialized typed array, see [`reviver()`][@stdlib/array/reviver]. - -
- - - - - -
- -## Notes - -- Supported typed array types: - - - [`Float64Array`][@stdlib/array/float64] - - [`Float32Array`][@stdlib/array/float32] - - [`Complex128Array`][@stdlib/array/complex128] - - [`Complex64Array`][@stdlib/array/complex64] - - [`BooleanArray`][@stdlib/array/bool] - - [`Int32Array`][@stdlib/array/int32] - - [`Uint32Array`][@stdlib/array/uint32] - - [`Int16Array`][@stdlib/array/int16] - - [`Uint16Array`][@stdlib/array/uint16] - - [`Int8Array`][@stdlib/array/int8] - - [`Uint8Array`][@stdlib/array/uint8] - - [`Uint8ClampedArray`][@stdlib/array/uint8c] - -- The implementation provides basic support for custom typed arrays and sets the `type` field to the closest known typed array type. - - - - ```javascript - class CustomArray extends Float64Array() { - constructor( data ) { - super( data ); - } - } - - var arr = new CustomArray( [ 5.0, 3.0 ] ); - - var json = typedarray2json( arr ); - /* returns - { - 'type': 'Float64Array', - 'data': [ 5.0, 3.0 ] - } - */ - ``` - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var Float32Array = require( '@stdlib/array/float32' ); -var Int32Array = require( '@stdlib/array/int32' ); -var Uint32Array = require( '@stdlib/array/uint32' ); -var Int16Array = require( '@stdlib/array/int16' ); -var Uint16Array = require( '@stdlib/array/uint16' ); -var Int8Array = require( '@stdlib/array/int8' ); -var Uint8Array = require( '@stdlib/array/uint8' ); -var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -var Complex64Array = require( '@stdlib/array/complex64' ); -var Complex128Array = require( '@stdlib/array/complex128' ); -var BooleanArray = require( '@stdlib/array/bool' ); -var typedarray2json = require( '@stdlib/array/to-json' ); - -var arr = new Float64Array( [ 5.0, 3.0 ] ); -var json = typedarray2json( arr ); -/* returns - { - 'type': 'Float64Array', - 'data': [ 5.0, 3.0 ] - } -*/ - -arr = new Float32Array( [ 5.0, -3.0 ] ); -json = typedarray2json( arr ); -/* returns - { - 'type': 'Float32Array', - 'data': [ 5.0, -3.0 ] - } -*/ - -arr = new Complex128Array( [ 5.0, 3.0 ] ); -json = typedarray2json( arr ); -/* returns - { - 'type': 'Complex128Array', - 'data': [ 5.0, 3.0 ] - } -*/ - -arr = new Complex64Array( [ 5.0, 3.0 ] ); -json = typedarray2json( arr ); -/* returns - { - 'type': 'Complex64Array', - 'data': [ 5.0, 3.0 ] - } -*/ - -arr = new BooleanArray( [ true, false ] ); -json = typedarray2json( arr ); -/* returns - { - 'type': 'BooleanArray', - 'data': [ 1, 0 ] - } -*/ - -arr = new Int32Array( [ -5, 3 ] ); -json = typedarray2json( arr ); -/* returns - { - 'type': 'Int32Array', - 'data': [ -5, 3 ] - } -*/ - -arr = new Uint32Array( [ 5, 3 ] ); -json = typedarray2json( arr ); -/* returns - { - 'type': 'Uint32Array', - 'data': [ 5, 3 ] - } -*/ - -arr = new Int16Array( [ -5, 3 ] ); -json = typedarray2json( arr ); -/* returns - { - 'type': 'Int16Array', - 'data': [ -5, 3 ] - } -*/ - -arr = new Uint16Array( [ 5, 3 ] ); -json = typedarray2json( arr ); -/* returns - { - 'type': 'Uint16Array', - 'data': [ 5, 3 ] - } -*/ - -arr = new Int8Array( [ -5, 3 ] ); -json = typedarray2json( arr ); -/* returns - { - 'type': 'Int8Array', - 'data': [ -5, 3 ] - } -*/ - -arr = new Uint8Array( [ 5, 3 ] ); -json = typedarray2json( arr ); -/* returns - { - 'type': 'Uint8Array', - 'data': [ 5, 3 ] - } -*/ - -arr = new Uint8ClampedArray( [ 5, 3 ] ); -json = typedarray2json( arr ); -/* returns - { - 'type': 'Uint8ClampedArray', - 'data': [ 5, 3 ] - } -*/ -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-json/benchmark/benchmark.js b/to-json/benchmark/benchmark.js deleted file mode 100644 index ff30b64ba..000000000 --- a/to-json/benchmark/benchmark.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../float64' ); -var randu = require( '@stdlib/random/base/randu' ); -var pkg = require( './../package.json' ).name; -var typedarray2json = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var o; - var i; - - arr = new Float64Array( [ randu(), randu() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = typedarray2json( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/to-json/benchmark/benchmark.length.js b/to-json/benchmark/benchmark.length.js deleted file mode 100644 index b1e874a8d..000000000 --- a/to-json/benchmark/benchmark.length.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randu = require( '@stdlib/random/base/randu' ); -var Float64Array = require( './../../float64' ); -var pkg = require( './../package.json' ).name; -var typedarray2json = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr; - var i; - - arr = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - arr[ i ] = randu(); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var o; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - o = typedarray2json( arr ); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof o !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/to-json/docs/repl.txt b/to-json/docs/repl.txt deleted file mode 100644 index 27b1d6ec7..000000000 --- a/to-json/docs/repl.txt +++ /dev/null @@ -1,48 +0,0 @@ - -{{alias}}( arr ) - Returns a JSON representation of a typed array. - - The following typed array types are supported: - - - Float64Array - - Float32Array - - Int32Array - - Uint32Array - - Int16Array - - Uint16Array - - Int8Array - - Uint8Array - - Uint8ClampedArray - - Complex64Array - - Complex128Array - - BooleanArray - - The returned JSON object has the following properties: - - - type: typed array type. - - data: typed array data as a generic array. - - The implementation supports custom typed arrays and sets the `type` field to - the closest known typed array type. - - Parameters - ---------- - arr: TypedArray - Typed array to serialize. - - Returns - ------- - out: Object - JSON representation. - - Examples - -------- - > var arr = new {{alias:@stdlib/array/float64}}( 2 ); - > arr[ 0 ] = 5.0; - > arr[ 1 ] = 3.0; - > var json = {{alias}}( arr ) - { 'type': 'Float64Array', 'data': [ 5.0, 3.0 ] } - - See Also - -------- - diff --git a/to-json/docs/types/index.d.ts b/to-json/docs/types/index.d.ts deleted file mode 100644 index 83b55c95f..000000000 --- a/to-json/docs/types/index.d.ts +++ /dev/null @@ -1,69 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { RealOrComplexTypedArray } from '@stdlib/types/array'; - -/** -* Typed array data type. -*/ -type dtype = 'Float64Array' | 'Float32Array' | 'Int32Array' | 'Uint32Array' | 'Int16Array' | 'Uint16Array' | 'Int8Array' | 'Uint8Array' | 'Uint8ClampedArray' | 'Complex64Array' | 'Complex128Array' | 'BooleanArray'; - -/** -* JSON representation of typed array. -*/ -interface JSONRepresentation { - /** - * Typed array type. - */ - type: dtype; - - /** - * Typed array data as a generic array. - */ - data: Array; -} - -/** -* Returns a JSON representation of a typed array. -* -* ## Notes -* -* - We build a JSON object representing a typed array similar to how Node.js `Buffer` objects are represented. See [Buffer][1]. -* -* [1]: https://nodejs.org/api/buffer.html#buffer_buf_tojson -* -* @param arr - typed array to serialize -* @returns JSON representation -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var arr = new Float64Array( [ 5.0, 3.0 ] ); -* var json = typedarray2json( arr ); -* // returns { 'type': 'Float64Array', 'data': [ 5.0, 3.0 ] } -*/ -declare function typedarray2json( arr: RealOrComplexTypedArray ): JSONRepresentation; - - -// EXPORTS // - -export = typedarray2json; diff --git a/to-json/docs/types/test.ts b/to-json/docs/types/test.ts deleted file mode 100644 index 509be675c..000000000 --- a/to-json/docs/types/test.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 typedarray2json = require( './index' ); - - -// TESTS // - -// The function returns a JSON representation... -{ - const x = new Float64Array( 10 ); - - typedarray2json( x ); // $ExpectType JSONRepresentation -} - -// The compiler throws an error if the function is provided a first argument which is not array-like... -{ - typedarray2json( 'abc' ); // $ExpectError - typedarray2json( 123 ); // $ExpectError - typedarray2json( true ); // $ExpectError - typedarray2json( false ); // $ExpectError - typedarray2json( {} ); // $ExpectError - typedarray2json( [] ); // $ExpectError - typedarray2json( null ); // $ExpectError - typedarray2json( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = new Float64Array( 10 ); - - typedarray2json(); // $ExpectError - typedarray2json( x, 3 ); // $ExpectError -} diff --git a/to-json/examples/index.js b/to-json/examples/index.js deleted file mode 100644 index ccd81318a..000000000 --- a/to-json/examples/index.js +++ /dev/null @@ -1,141 +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. -*/ - -'use strict'; - -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var typedarray2json = require( './../lib' ); - -var arr = new Float64Array( [ 5.0, 3.0 ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'Float64Array', - 'data': [ 5.0, 3.0 ] - } -*/ - -arr = new Float32Array( [ 5.0, -3.0 ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'Float32Array', - 'data': [ 5.0, -3.0 ] - } -*/ - -arr = new Complex128Array( [ 5.0, -3.0 ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'Complex128Array', - 'data': [ 5.0, -3.0 ] - } -*/ - -arr = new Complex64Array( [ 5.0, -3.0 ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'Complex64Array', - 'data': [ 5.0, -3.0 ] - } -*/ - -arr = new BooleanArray( [ true, false ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'BooleanArray', - 'data': [ 1, 0 ] - } -*/ - -arr = new Int32Array( [ -5, 3 ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'Int32Array', - 'data': [ -5, 3 ] - } -*/ - -arr = new Uint32Array( [ 5, 3 ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'Uint32Array', - 'data': [ 5, 3 ] - } -*/ - -arr = new Int16Array( [ -5, 3 ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'Int16Array', - 'data': [ -5, 3 ] - } -*/ - -arr = new Uint16Array( [ 5, 3 ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'Uint16Array', - 'data': [ 5, 3 ] - } -*/ - -arr = new Int8Array( [ -5, 3 ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'Int8Array', - 'data': [ -5, 3 ] - } -*/ - -arr = new Uint8Array( [ 5, 3 ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'Uint8Array', - 'data': [ 5, 3 ] - } -*/ - -arr = new Uint8ClampedArray( [ 5, 3 ] ); -console.log( typedarray2json( arr ) ); -/* => - { - 'type': 'Uint8ClampedArray', - 'data': [ 5, 3 ] - } -*/ diff --git a/to-json/lib/ctors.js b/to-json/lib/ctors.js deleted file mode 100644 index 9e967bdfa..000000000 --- a/to-json/lib/ctors.js +++ /dev/null @@ -1,57 +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. -*/ - -'use strict'; - -// MODULES // - -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Float32Array = require( './../../float32' ); -var Float64Array = require( './../../float64' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); - - -// MAIN // - -var CTORS = [ - [ Float64Array, 'Float64Array' ], - [ Float32Array, 'Float32Array' ], - [ Int32Array, 'Int32Array' ], - [ Uint32Array, 'Uint32Array' ], - [ Int16Array, 'Int16Array' ], - [ Uint16Array, 'Uint16Array' ], - [ Int8Array, 'Int8Array' ], - [ Uint8Array, 'Uint8Array' ], - [ Uint8ClampedArray, 'Uint8ClampedArray' ], - [ Complex64Array, 'Complex64Array' ], - [ Complex128Array, 'Complex128Array' ], - [ BooleanArray, 'BooleanArray' ] -]; - - -// EXPORTS // - -module.exports = CTORS; diff --git a/to-json/lib/index.js b/to-json/lib/index.js deleted file mode 100644 index f81c35cfc..000000000 --- a/to-json/lib/index.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a JSON representation of a typed array. -* -* @module @stdlib/array/to-json -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* var typedarray2json = require( '@stdlib/array/to-json' ); -* -* var arr = new Float64Array( [ 5.0, 3.0 ] ); -* var json = typedarray2json( arr ); -* // returns { 'type': 'Float64Array', 'data': [ 5.0, 3.0 ] } -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-json/lib/main.js b/to-json/lib/main.js deleted file mode 100644 index 4bb521148..000000000 --- a/to-json/lib/main.js +++ /dev/null @@ -1,86 +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. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var format = require( '@stdlib/string/format' ); -var typeName = require( './type.js' ); - - -// MAIN // - -/** -* Returns a JSON representation of a typed array. -* -* ## Notes -* -* - We build a JSON object representing a typed array similar to how Node.js `Buffer` objects are represented. See [Buffer][1]. -* -* [1]: https://nodejs.org/api/buffer.html#buffer_buf_tojson -* -* @param {TypedArray} arr - typed array to serialize -* @throws {TypeError} first argument must be a typed array -* @returns {Object} JSON representation -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var arr = new Float64Array( [ 5.0, 3.0 ] ); -* var json = typedarray2json( arr ); -* // returns { 'type': 'Float64Array', 'data': [ 5.0, 3.0 ] } -*/ -function typedarray2json( arr ) { - var data; - var out; - var i; - - if ( isTypedArray( arr ) ) { - data = arr; - } else if ( isComplexTypedArray( arr ) ) { - if ( arr.BYTES_PER_ELEMENT === 8 ) { - data = reinterpret64( arr, 0 ); - } else { // arr.BYTES_PER_ELEMENT === 16 - data = reinterpret128( arr, 0 ); - } - } else if ( isBooleanArray( arr ) ) { - data = reinterpretBoolean( arr, 0 ); - } else { - throw new TypeError( format( 'invalid argument. Must provide a typed array. Value: `%s`.', arr ) ); - } - out = { - 'type': typeName( arr ), - 'data': [] - }; - for ( i = 0; i < data.length; i++ ) { - out.data.push( data[ i ] ); - } - return out; -} - - -// EXPORTS // - -module.exports = typedarray2json; diff --git a/to-json/lib/type.js b/to-json/lib/type.js deleted file mode 100644 index 23e3d1ba2..000000000 --- a/to-json/lib/type.js +++ /dev/null @@ -1,70 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var instanceOf = require( '@stdlib/assert/instance-of' ); -var ctorName = require( '@stdlib/utils/constructor-name' ); -var getPrototypeOf = require( '@stdlib/utils/get-prototype-of' ); -var CTORS = require( './ctors.js' ); - - -// MAIN // - -/** -* Returns the typed array type. -* -* @private -* @param {TypedArray} arr - typed array -* @returns {(string|void)} typed array type -* -* @example -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var arr = new Float64Array( 5 ); -* var str = typeName( arr ); -* // returns 'Float64Array' -*/ -function typeName( arr ) { - var v; - var i; - - // Check for typed array objects from the same realm (same Node.js `vm` or same `Window` object)... - for ( i = 0; i < CTORS.length; i++ ) { - if ( instanceOf( arr, CTORS[ i ][ 0 ] ) ) { - return CTORS[ i ][ 1 ]; - } - } - // Walk the prototype tree until we find an object having a desired native class... - while ( arr ) { - v = ctorName( arr ); - for ( i = 0; i < CTORS.length; i++ ) { - if ( v === CTORS[ i ][ 1 ] ) { - return CTORS[ i ][ 1 ]; - } - } - arr = getPrototypeOf( arr ); - } -} - - -// EXPORTS // - -module.exports = typeName; diff --git a/to-json/package.json b/to-json/package.json deleted file mode 100644 index b71509663..000000000 --- a/to-json/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/to-json", - "version": "0.0.0", - "description": "Return a JSON representation of a typed array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "arr", - "typed-array", - "typed array", - "serialize", - "marshal", - "tojson", - "json", - "to", - "convert" - ] -} diff --git a/to-json/test/fixtures/custom.proto.js b/to-json/test/fixtures/custom.proto.js deleted file mode 100644 index 516981e15..000000000 --- a/to-json/test/fixtures/custom.proto.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Float64Array = require( './../../../float64' ); -var defineProperty = require( '@stdlib/utils/define-property' ); - - -// MAIN // - -/** -* Creates a CustomTypedArray class. -* -* @private -* @param {TypedArray} ctor - typed array constructor -* @returns {CustomTypedArray} constructor -*/ -function createClass( ctor ) { - if ( !ctor ) { - ctor = Float64Array; - } - /** - * Create a new object which prototypically inherits from a typed array constructor. - * - * @private - * @constructor - * @param {Array} data - array data - * @returns {CustomTypedArray} custom typed array instance - */ - function CustomTypedArray( data ) { - var i; - for ( i = 0; i < data.length; i++ ) { - this[ i ] = data[ i ]; - } - defineProperty( this, 'length', { - 'configurable': false, - 'enumerable': true, - 'writable': false, - 'value': data.length - }); - return this; - } - - /** - * Create a prototype which inherits from the parent prototype. - */ - CustomTypedArray.prototype = Object.create( ctor.prototype ); - - /** - * Set the constructor. - */ - CustomTypedArray.prototype.constructor = CustomTypedArray; - - return CustomTypedArray; -} - - -// EXPORTS // - -module.exports = createClass; diff --git a/to-json/test/fixtures/custom.subclass.js b/to-json/test/fixtures/custom.subclass.js deleted file mode 100644 index 0bc231901..000000000 --- a/to-json/test/fixtures/custom.subclass.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Creates a CustomTypedArray class constructor. Note that we use function generation so that tests may be run in browsers not supporting ES2015 classes. This function may be loaded in non-ES2015 environments, but should only be invoked when ES2015 classes are supported. -* -* @private -* @param {string} ctor - typed array constructor name -* @returns {Function} constructor -*/ -function createClass( ctor ) { - var str = ''; - if ( !ctor ) { - ctor = 'Float64Array'; - } - str += '(function create() {'; - str += 'class CustomTypedArray extends '+ctor+' {'; - str += 'constructor( data ) {'; - str += 'super( data );'; - str += '}'; - str += '}'; - str += 'return CustomTypedArray;'; - str += '})()'; - return eval( str ); // eslint-disable-line no-eval -} - - -// EXPORTS // - -module.exports = createClass; diff --git a/to-json/test/test.ctors.js b/to-json/test/test.ctors.js deleted file mode 100644 index 7e3bca949..000000000 --- a/to-json/test/test.ctors.js +++ /dev/null @@ -1,35 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isArray = require( '@stdlib/assert/is-array' ); -var CTORS = require( './../lib/ctors.js' ); - - -// TESTS // - -tape( 'typed array constructors are exposed via an exported array', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( isArray( CTORS ), true, 'export is an array' ); - t.ok( CTORS.length > 0, 'has length > 0' ); - t.end(); -}); diff --git a/to-json/test/test.js b/to-json/test/test.js deleted file mode 100644 index dfdd48138..000000000 --- a/to-json/test/test.js +++ /dev/null @@ -1,294 +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. -*/ - -'use strict'; - -// MODULES // - -var vm = require( 'vm' ); // TODO: handle in-browser tests -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert/is-browser' ); -var hasClassSupport = require( '@stdlib/assert/has-class-support' ); -var isPlainObject = require( '@stdlib/assert/is-plain-object' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Float32Array = require( './../../float32' ); -var Float64Array = require( './../../float64' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var toJSON = require( './../lib' ); - - -// FIXTURES // - -var createClass1 = require( './fixtures/custom.proto.js' ); -var createClass2 = require( './fixtures/custom.subclass.js' ); - - -// VARIABLES // - -var hasClasses = hasClassSupport(); -var opts = { - 'skip': false -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof toJSON, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if provided anything other than a typed array instance, the function will throw an error', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false, - [], - {}, - function noop() {}, - new Date(), - /.*/ - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), Error, 'throws when provided a ' + (typeof values[i]) ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - toJSON( value ); - }; - } -}); - -tape( 'the function returns a JSON object', function test( t ) { - var json; - var arr; - - arr = new Float64Array( [ 5.0, 3.0 ] ); - json = toJSON( arr ); - t.strictEqual( isPlainObject( json ), true, 'returns an object' ); - t.end(); -}); - -tape( 'the JSON object includes a typed array type', function test( t ) { - var expected; - var values; - var json; - var i; - - values = [ - new Float64Array( 1 ), - new Float32Array( 1 ), - new Int32Array( 1 ), - new Uint32Array( 1 ), - new Int16Array( 1 ), - new Uint16Array( 1 ), - new Int8Array( 1 ), - new Uint8Array( 1 ), - new Uint8ClampedArray( 1 ), - new Complex64Array( 1 ), - new Complex128Array( 1 ), - new BooleanArray( 1 ) - ]; - - expected = [ - 'Float64Array', - 'Float32Array', - 'Int32Array', - 'Uint32Array', - 'Int16Array', - 'Uint16Array', - 'Int8Array', - 'Uint8Array', - 'Uint8ClampedArray', - 'Complex64Array', - 'Complex128Array', - 'BooleanArray' - ]; - - for ( i = 0; i < values.length; i++ ) { - json = toJSON( values[ i ] ); - t.strictEqual( json.type, expected[ i ], 'type equal to ' + expected[ i ] ); - } - t.end(); -}); - -tape( 'the JSON object includes a data property', function test( t ) { - var expected; - var values; - var json; - var i; - - values = [ - new Float64Array( [ 1.0 ] ), - new Float32Array( [ 2.0 ] ), - new Int32Array( [ 3.0 ] ), - new Uint32Array( [ 4.0 ] ), - new Int16Array( [ 5.0 ] ), - new Uint16Array( [ 6.0 ] ), - new Int8Array( [ 7.0 ] ), - new Uint8Array( [ 8.0 ] ), - new Uint8ClampedArray( [ 9.0 ] ), - new Complex64Array( [ 1.0, 2.0 ] ), - new Complex128Array( [ 1.0, 2.0 ] ), - new BooleanArray( [ true, false ] ) - ]; - - expected = [ - [ 1.0 ], - [ 2.0 ], - [ 3.0 ], - [ 4.0 ], - [ 5.0 ], - [ 6.0 ], - [ 7.0 ], - [ 8.0 ], - [ 9.0 ], - [ 1.0, 2.0 ], - [ 1.0, 2.0 ], - [ 1, 0 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - json = toJSON( values[ i ] ); - t.deepEqual( json.data, expected[ i ], 'has expected property value' ); - } - t.end(); -}); - -tape( 'custom typed arrays are supported (proto)', function test( t ) { - var CustomTypedArray; - var types; - var ctors; - var json; - var arr; - var i; - - ctors = [ - Float64Array, - Float32Array, - Int32Array, - Uint32Array, - Int16Array, - Uint16Array, - Int8Array, - Uint8Array, - Uint8ClampedArray - ]; - - types = [ - 'Float64Array', - 'Float32Array', - 'Int32Array', - 'Uint32Array', - 'Int16Array', - 'Uint16Array', - 'Int8Array', - 'Uint8Array', - 'Uint8ClampedArray' - ]; - - for ( i = 0; i < ctors.length; i++ ) { - CustomTypedArray = createClass1( ctors[ i ] ); - arr = new CustomTypedArray( [ 5.0, 3.0 ] ); - json = toJSON( arr ); - t.strictEqual( json.type, types[ i ], 'type equal to ' + types[ i ] ); - t.deepEqual( json.data, [ 5.0, 3.0 ], 'has expected value' ); - } - t.end(); -}); - -opts.skip = !hasClasses; -tape( 'custom typed arrays are supported (subclass; ES2015)', opts, function test( t ) { - var CustomTypedArray; - var ctors; - var json; - var arr; - var i; - - ctors = [ - 'Float64Array', - 'Float32Array', - 'Int32Array', - 'Uint32Array', - 'Int16Array', - 'Uint16Array', - 'Int8Array', - 'Uint8Array', - 'Uint8ClampedArray' - ]; - - for ( i = 0; i < ctors.length; i++ ) { - CustomTypedArray = createClass2( ctors[ i ] ); - arr = new CustomTypedArray( [ 5.0, 3.0 ] ); - json = toJSON( arr ); - t.strictEqual( json.type, ctors[ i ], 'type equal to ' + ctors[ i ] ); - t.deepEqual( json.data, [ 5.0, 3.0 ], 'has expected value' ); - } - t.end(); -}); - -opts.skip = IS_BROWSER; -tape( 'the function supports serializing a typed array from a different realm', opts, function test( t ) { - var json; - var arr; - - arr = vm.runInNewContext( 'new Float64Array( [ 5.0, 3.0 ] )', { - 'Float64Array': Float64Array - }); - json = toJSON( arr ); - - t.strictEqual( json.type, 'Float64Array', 'returns expected value' ); - t.deepEqual( json.data, [ 5.0, 3.0 ], 'returns expected value' ); - - t.end(); -}); - -opts.skip = IS_BROWSER; -tape( 'the function supports serializing an object from a different realm which inherits from a typed array', opts, function test( t ) { - var json; - var arr; - - arr = vm.runInNewContext( 'function Arr( data ) { Object.defineProperty( this, "length", {"configurable":false,"enumerable":true,"writable":false,"value":data.length}); for ( var i = 0; i < data.length; i++ ) { this[ i ] = data[ i ]; }; return this; }; Arr.prototype = Object.create( Float64Array.prototype ); Arr.prototype.constructor = Arr; new Arr( [ 5.0, 3.0 ] );', { - 'Float64Array': Float64Array - }); - json = toJSON( arr ); - - t.strictEqual( json.type, 'Float64Array', 'returns expected value' ); - t.deepEqual( json.data, [ 5.0, 3.0 ], 'returns expected value' ); - - t.end(); -}); diff --git a/to-json/test/test.type.js b/to-json/test/test.type.js deleted file mode 100644 index 0cea582ae..000000000 --- a/to-json/test/test.type.js +++ /dev/null @@ -1,162 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Float32Array = require( './../../float32' ); -var Float64Array = require( './../../float64' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var typeName = require( './../lib/type.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typeName, 'function', 'export is a function' ); - t.end(); -}); - -tape( 'if provided a typed array, the function returns the closest typed array type', function test( t ) { - var expected; - var values; - var i; - - values = [ - new Float64Array( [ 5.0, 3.0 ] ), - new Float32Array( [ 5.0, 3.0 ] ), - new Int32Array( [ 5, 3 ] ), - new Uint32Array( [ 5, 3 ] ), - new Int16Array( [ 5, 3 ] ), - new Uint16Array( [ 5, 3 ] ), - new Int8Array( [ 5, 3 ] ), - new Uint8Array( [ 5, 3 ] ), - new Uint8ClampedArray( [ 5, 3 ] ), - new Complex64Array( [ 5.0, 3.0 ] ), - new Complex128Array( [ 5.0, 3.0 ] ), - new BooleanArray( [ true, false ] ) - ]; - - expected = [ - 'Float64Array', - 'Float32Array', - 'Int32Array', - 'Uint32Array', - 'Int16Array', - 'Uint16Array', - 'Int8Array', - 'Uint8Array', - 'Uint8ClampedArray', - 'Complex64Array', - 'Complex128Array', - 'BooleanArray' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( typeName( values[i] ), expected[ i ], 'returns the constructor name: ' + expected[ i ] ); - } - t.end(); -}); - -tape( 'if provided a typed array from a different realm, the function returns the closest typed array type', function test( t ) { - var typeName; - var expected; - var values; - var i; - - typeName = proxyquire( './../lib/type.js', { - '@stdlib/assert/instance-of': instanceOf - }); - - values = [ - new Float64Array( [ 5.0, 3.0 ] ), - new Float32Array( [ 5.0, 3.0 ] ), - new Int32Array( [ 5, 3 ] ), - new Uint32Array( [ 5, 3 ] ), - new Int16Array( [ 5, 3 ] ), - new Uint16Array( [ 5, 3 ] ), - new Int8Array( [ 5, 3 ] ), - new Uint8Array( [ 5, 3 ] ), - new Uint8ClampedArray( [ 5, 3 ] ), - new Complex64Array( [ 5.0, 3.0 ] ), - new Complex128Array( [ 5.0, 3.0 ] ), - new BooleanArray( [ true, false ] ) - ]; - - expected = [ - 'Float64Array', - 'Float32Array', - 'Int32Array', - 'Uint32Array', - 'Int16Array', - 'Uint16Array', - 'Int8Array', - 'Uint8Array', - 'Uint8ClampedArray', - 'Complex64Array', - 'Complex128Array', - 'BooleanArray' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( typeName( values[i] ), expected[ i ], 'returns the constructor name: ' + expected[ i ] ); - } - t.end(); - - function instanceOf() { - // Mocks comparing values from different realms... - return false; - } -}); - -tape( 'if not provided a typed array, the function returns `undefined`', function test( t ) { - var values; - var i; - - values = [ - '5', - NaN, - 5, - true, - false, - null, - void 0, - [], - {}, - function noop() {}, - function typedarray() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( typeName( values[i] ), void 0, 'returns expected value' ); - } - t.end(); -}); diff --git a/to-sparse-iterator-right/README.md b/to-sparse-iterator-right/README.md deleted file mode 100644 index 0d2700e16..000000000 --- a/to-sparse-iterator-right/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# sparsearray2iteratorRight - -> Create an iterator from a sparse array-like object, iterating from right to left. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var sparsearray2iteratorRight = require( '@stdlib/array/to-sparse-iterator-right' ); -``` - -#### sparsearray2iteratorRight( src\[, mapFcn\[, thisArg]] ) - -Returns an iterator which iterates from right to left over each element in a sparse array-like `object`. - - - -```javascript -var it = sparsearray2iteratorRight( [ 1, , , 4 ] ); -// returns - -var v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - -The returned iterator protocol-compliant object has the following properties: - -- **next**: function which returns an iterator protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the iterator is finished. -- **return**: function which closes an iterator and returns a single (optional) argument in an iterator protocol-compliant object. - -To invoke a function for each `src` value, provide a callback function. - - - -```javascript -function fcn( v ) { - return v * 10.0; -} - -var it = sparsearray2iteratorRight( [ 1, 2, , 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 40.0 - -v = it.next().value; -// returns 20.0 - -// ... -``` - -The invoked function is provided three arguments: - -- **value**: iterated value. -- **index**: iterated value index. -- **src**: source array-like object. - - - -```javascript -function fcn( v, i ) { - return v * (i+1); -} - -var it = sparsearray2iteratorRight( [ 1, 2, , 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 16 - -v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 1 -``` - -To set the callback function execution context, provide a `thisArg`. - - - -```javascript -function fcn( v ) { - this.count += 1; - return v * 10.0; -} - -var ctx = { - 'count': 0 -}; - -var it = sparsearray2iteratorRight( [ 1, 2, , 4 ], fcn, ctx ); -// returns - -var v = it.next().value; -// returns 40.0 - -v = it.next().value; -// returns 20.0 - -var count = ctx.count; -// returns 2 -``` - - - - - - - -
- -## Notes - -- If an environment supports `Symbol.iterator`, the returned iterator is iterable. -- If provided a generic `array`, the returned iterator **ignores** holes (i.e., `undefined` values). To iterate over all generic `array` elements, use [`@stdlib/array/to-iterator-right`][@stdlib/array/to-iterator-right]. -- A returned iterator does **not** copy a provided array-like `object`. To ensure iterable reproducibility, copy a provided array-like `object` **before** creating an iterator. Otherwise, any changes to the contents of an array-like `object` will be reflected in the returned iterator. -- In environments supporting `Symbol.iterator`, the function **explicitly** does **not** invoke an array's `@@iterator` method, regardless of whether this method is defined. To convert an array to an implementation defined iterator, invoke this method directly. -- The returned iterator supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]). - -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var sparsearray2iteratorRight = require( '@stdlib/array/to-sparse-iterator-right' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array partially filled with random numbers: -var arr = new Array( 100 ); -var i; -for ( i = 0; i < arr.length; i += 2 ) { - arr[ i ] = randu(); -} - -// Create an iterator from the array which scales iterated values: -var it = sparsearray2iteratorRight( arr, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-sparse-iterator-right/benchmark/benchmark.js b/to-sparse-iterator-right/benchmark/benchmark.js deleted file mode 100644 index 3cbe22222..000000000 --- a/to-sparse-iterator-right/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var sparsearray2iteratorRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var iter; - var i; - - values = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - values[ 0 ] = i; - iter = sparsearray2iteratorRight( values ); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - for ( i = 0; i < b.iterations; i++ ) { - values.push( i ); - } - - iter = sparsearray2iteratorRight( values ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration,map', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - for ( i = 0; i < b.iterations; i++ ) { - values.push( i ); - } - - iter = sparsearray2iteratorRight( values, transform ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return i; - } -}); diff --git a/to-sparse-iterator-right/docs/repl.txt b/to-sparse-iterator-right/docs/repl.txt deleted file mode 100644 index 3e9002c14..000000000 --- a/to-sparse-iterator-right/docs/repl.txt +++ /dev/null @@ -1,56 +0,0 @@ - -{{alias}}( src[, mapFcn[, thisArg]] ) - Returns an iterator which iterates from right to left over the elements of a - sparse array-like object. - - The returned iterator skips elements which are undefined. - - When invoked, an input function is provided three arguments: - - - value: iterated value. - - index: iterated value index. - - src: source array-like object. - - If an environment supports Symbol.iterator, the returned iterator is - iterable. - - If an environment supports Symbol.iterator, the function explicitly does not - invoke an array's `@@iterator` method, regardless of whether this method is - defined. To convert an array to an implementation defined iterator, invoke - this method directly. - - Parameters - ---------- - src: ArrayLikeObject - Sparse array-like object from which to create the iterator. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - iterator: Object - Iterator. - - iterator.next(): Function - Returns an iterator protocol-compliant object containing the next - iterated value (if one exists) and a boolean flag indicating whether the - iterator is finished. - - iterator.return( [value] ): Function - Finishes an iterator and returns a provided value. - - Examples - -------- - > var it = {{alias}}( [ 1, 2, , 4 ] ); - > var v = it.next().value - 4 - > v = it.next().value - 2 - - See Also - -------- - diff --git a/to-sparse-iterator-right/docs/types/index.d.ts b/to-sparse-iterator-right/docs/types/index.d.ts deleted file mode 100644 index 9565ea892..000000000 --- a/to-sparse-iterator-right/docs/types/index.d.ts +++ /dev/null @@ -1,102 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Returns an iterator which iterates from right to left over each element in a sparse array-like object. -* -* ## Notes -* -* - For dynamic array resizing, the only behavior made intentionally consistent with iterating from left to right is when elements are pushed onto the beginning (end) of an array. In other words, iterating from left to right combined with `[].push()` is consistent with iterating from right to left combined with `[].unshift()`. -* -* @param src - input value -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns iterator -* -* @example -* var iter = sparsearray2iteratorRight( [ 1, , 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 4 -* -* v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 1 -*/ -declare function sparsearray2iteratorRight( src: ArrayLike, mapFcn?: MapFunction, thisArg?: any ): Iterator; - - -// EXPORTS // - -export = sparsearray2iteratorRight; diff --git a/to-sparse-iterator-right/docs/types/test.ts b/to-sparse-iterator-right/docs/types/test.ts deleted file mode 100644 index 8575e6b68..000000000 --- a/to-sparse-iterator-right/docs/types/test.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 sparsearray2iteratorRight = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - sparsearray2iteratorRight( [ 1, 2, 3, 4 ] ); // $ExpectType Iterator - sparsearray2iteratorRight( [ 1, 2, 3, 4 ], times10 ); // $ExpectType Iterator - sparsearray2iteratorRight( [ 1, 2, 3, 4 ], times10, {} ); // $ExpectType Iterator -} - -// The compiler throws an error if the function is provided a first argument which is not array-like... -{ - sparsearray2iteratorRight( 123 ); // $ExpectError - sparsearray2iteratorRight( true ); // $ExpectError - sparsearray2iteratorRight( false ); // $ExpectError - sparsearray2iteratorRight( {} ); // $ExpectError - sparsearray2iteratorRight( null ); // $ExpectError - sparsearray2iteratorRight( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function... -{ - sparsearray2iteratorRight( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - sparsearray2iteratorRight( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - sparsearray2iteratorRight( [ 1, 2, 3, 4 ], [] ); // $ExpectError - sparsearray2iteratorRight( [ 1, 2, 3, 4 ], {} ); // $ExpectError - sparsearray2iteratorRight( [ 1, 2, 3, 4 ], true ); // $ExpectError - sparsearray2iteratorRight( [ 1, 2, 3, 4 ], false ); // $ExpectError - sparsearray2iteratorRight( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - sparsearray2iteratorRight(); // $ExpectError - sparsearray2iteratorRight( [ 1, 2, 3, 4 ], times10, {}, 123 ); // $ExpectError -} diff --git a/to-sparse-iterator-right/examples/index.js b/to-sparse-iterator-right/examples/index.js deleted file mode 100644 index 6afa6697d..000000000 --- a/to-sparse-iterator-right/examples/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var sparsearray2iteratorRight = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array partially filled with random numbers: -var arr = new Array( 100 ); -var i; -for ( i = 0; i < arr.length; i += 2 ) { - arr[ i ] = randu(); -} - -// Create an iterator from the array which scales iterated values: -var it = sparsearray2iteratorRight( arr, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} diff --git a/to-sparse-iterator-right/lib/index.js b/to-sparse-iterator-right/lib/index.js deleted file mode 100644 index ad638b129..000000000 --- a/to-sparse-iterator-right/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an iterator from a sparse array-like value, iterating from right to left. -* -* @module @stdlib/array/to-sparse-iterator-right -* -* @example -* var sparsearray2iteratorRight = require( '@stdlib/array/to-sparse-iterator-right' ); -* -* var iter = sparsearray2iteratorRight( [ 1, , 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 4 -* -* v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 1 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-sparse-iterator-right/lib/main.js b/to-sparse-iterator-right/lib/main.js deleted file mode 100644 index d193dbf00..000000000 --- a/to-sparse-iterator-right/lib/main.js +++ /dev/null @@ -1,201 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isAccessorArray = require( './../../base/assert/is-accessor-array' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var getter = require( './../../base/getter' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns an iterator which iterates from right to left over each element in a sparse array-like object. -* -* ## Notes -* -* - For dynamic array resizing, the only behavior made intentionally consistent with iterating from left to right is when elements are pushed onto the beginning (end) of an array. In other words, iterating from left to right combined with `[].push()` is consistent with iterating from right to left combined with `[].unshift()`. -* -* @param {Collection} src - input value -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} second argument must be a function -* @returns {Iterator} iterator -* -* @example -* var iter = sparsearray2iteratorRight( [ 1, , 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 4 -* -* v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 1 -*/ -function sparsearray2iteratorRight( src ) { - var thisArg; - var iter; - var FLG; - var fcn; - var len; - var get; - var dt; - var i; - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); - } - if ( arguments.length > 1 ) { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - len = src.length; - i = len; - - // Create an iterator protocol-compliant object: - iter = {}; - if ( fcn ) { - setReadOnly( iter, 'next', next1 ); - } else { - setReadOnly( iter, 'next', next2 ); - } - setReadOnly( iter, 'return', end ); - - // If an environment supports `Symbol.iterator`, make the iterator iterable: - if ( iteratorSymbol ) { - setReadOnly( iter, iteratorSymbol, factory ); - } - // Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc): - dt = dtype( src ); - if ( isAccessorArray( src ) ) { - get = accessorGetter( dt ); - } else { - get = getter( dt ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next1() { - if ( FLG ) { - return { - 'done': true - }; - } - i += src.length - len - 1; // accounts for a dynamic array - len = src.length; - while ( i >= 0 && get( src, i ) === void 0 ) { - i -= 1; - } - if ( i < 0 ) { - FLG = true; - return { - 'done': true - }; - } - return { - 'value': fcn.call( thisArg, get( src, i ), i, src ), - 'done': false - }; - } - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next2() { - if ( FLG ) { - return { - 'done': true - }; - } - i += src.length - len - 1; // accounts for a dynamic array - len = src.length; - while ( i >= 0 && get( src, i ) === void 0 ) { - i -= 1; - } - if ( i < 0 ) { - FLG = true; - return { - 'done': true - }; - } - return { - 'value': get( src, i ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - if ( fcn ) { - return sparsearray2iteratorRight( src, fcn, thisArg ); - } - return sparsearray2iteratorRight( src ); - } -} - - -// EXPORTS // - -module.exports = sparsearray2iteratorRight; diff --git a/to-sparse-iterator-right/package.json b/to-sparse-iterator-right/package.json deleted file mode 100644 index e9838bdbf..000000000 --- a/to-sparse-iterator-right/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/array/to-sparse-iterator-right", - "version": "0.0.0", - "description": "Create an iterator from a sparse array-like object, iterating from right to left.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "arr", - "sparse", - "holes", - "typed-array", - "typed array", - "iterator", - "iterate", - "iteration", - "iter", - "to", - "convert" - ] -} diff --git a/to-sparse-iterator-right/test/test.js b/to-sparse-iterator-right/test/test.js deleted file mode 100644 index 0a7f3e645..000000000 --- a/to-sparse-iterator-right/test/test.js +++ /dev/null @@ -1,730 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var noop = require( '@stdlib/utils/noop' ); -var sparsearray2iteratorRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sparsearray2iteratorRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sparsearray2iteratorRight( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sparsearray2iteratorRight( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sparsearray2iteratorRight( [ 1, 2, 3, 4 ], value ); - }; - } -}); - -tape( 'the function returns an iterator protocol-compliant object', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iteratorRight( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (empty array)', function test( t ) { - var expected; - var actual; - var values; - var it; - - values = new Array( 1e5 ); - expected = [ - { - 'done': true - } - ]; - - it = sparsearray2iteratorRight( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (empty end)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = new Array( 4 ); - - // Leave the last element empty: - for ( i = 0; i < values.length-1; i++ ) { - values[ i ] = i + 1; - } - expected = [ - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iteratorRight( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (empty start)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = new Array( 4 ); - - // Leave the first element empty: - for ( i = 1; i < values.length; i++ ) { - values[ i ] = i + 1; - } - - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iteratorRight( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (empty start+end)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = new Array( 4 ); - - // Leave the first and last elements empty: - for ( i = 1; i < values.length-1; i++ ) { - values[ i ] = i + 1; - } - - expected = [ - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iteratorRight( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (array-like object)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '1': 2, - '2': 3, - '3': 4 - }; - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iteratorRight( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = new Array( 4 ); - - // Leave the last element empty: - for ( i = 0; i < values.length-1; i++ ) { - values[ i ] = i + 1; - } - - it = sparsearray2iteratorRight( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-1, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (array-like)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '3': 4 - }; - - it = sparsearray2iteratorRight( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-1, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object', function test( t ) { - var expected; - var values; - var actual; - var it; - var i; - - values = [ 1, , 3, 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iteratorRight( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - actual.push( it.next() ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (callback)', function test( t ) { - var expected; - var values; - var actual; - var it; - var i; - - values = [ 1, 2, , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ - { - 'value': 16, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iteratorRight( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - actual.push( it.next() ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var it; - var r; - - it = sparsearray2iteratorRight( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument; callback)', function test( t ) { - var it; - var r; - - it = sparsearray2iteratorRight( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var it; - var r; - - it = sparsearray2iteratorRight( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument; callback)', function test( t ) { - var it; - var r; - - it = sparsearray2iteratorRight( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable', function test( t ) { - var sparsearray2iteratorRight; - var values; - var it1; - var it2; - var i; - - sparsearray2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = sparsearray2iteratorRight( values ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (callback)', function test( t ) { - var sparsearray2iteratorRight; - var values; - var it1; - var it2; - var i; - - sparsearray2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = sparsearray2iteratorRight( values, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable"', function test( t ) { - var sparsearray2iteratorRight; - var it; - - sparsearray2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = sparsearray2iteratorRight( [ 1, 2, 3, 4 ] ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (callback)', function test( t ) { - var sparsearray2iteratorRight; - var it; - - sparsearray2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = sparsearray2iteratorRight( [ 1, 2, 3, 4 ], scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/to-sparse-iterator/README.md b/to-sparse-iterator/README.md deleted file mode 100644 index 314deda4d..000000000 --- a/to-sparse-iterator/README.md +++ /dev/null @@ -1,245 +0,0 @@ - - -# sparsearray2iterator - -> Create an iterator from a sparse array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var sparsearray2iterator = require( '@stdlib/array/to-sparse-iterator' ); -``` - -#### sparsearray2iterator( src\[, mapFcn\[, thisArg]] ) - -Returns an iterator which iterates over each element in a sparse array-like `object`. - - - -```javascript -var it = sparsearray2iterator( [ 1, , , 4 ] ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 4 - -var bool = it.next().done; -// returns true -``` - -The returned iterator protocol-compliant object has the following properties: - -- **next**: function which returns an iterator protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the iterator is finished. -- **return**: function which closes an iterator and returns a single (optional) argument in an iterator protocol-compliant object. - -To invoke a function for each `src` value, provide a callback function. - - - -```javascript -function fcn( v ) { - return v * 10.0; -} - -var it = sparsearray2iterator( [ 1, , 3, 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 10.0 - -v = it.next().value; -// returns 30.0 - -// ... -``` - -The invoked function is provided three arguments: - -- **value**: iterated value. -- **index**: iterated value index. -- **src**: source array-like object. - - - -```javascript -function fcn( v, i ) { - return v * (i+1); -} - -var it = sparsearray2iterator( [ 1, 2, , 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 16 -``` - -To set the callback function execution context, provide a `thisArg`. - - - -```javascript -function fcn( v ) { - this.count += 1; - return v * 10.0; -} - -var ctx = { - 'count': 0 -}; - -var it = sparsearray2iterator( [ 1, , 3, 4 ], fcn, ctx ); -// returns - -var v = it.next().value; -// returns 10.0 - -v = it.next().value; -// returns 30.0 - -var count = ctx.count; -// returns 2 -``` - - - - - - - -
- -## Notes - -- If an environment supports `Symbol.iterator`, the returned iterator is iterable. -- If provided a generic `array`, the returned iterator **ignores** holes (i.e., `undefined` values). To iterate over all generic `array` elements, use [`@stdlib/array/to-iterator`][@stdlib/array/to-iterator]. -- A returned iterator does **not** copy a provided array-like `object`. To ensure iterable reproducibility, copy a provided array-like `object` **before** creating an iterator. Otherwise, any changes to the contents of an array-like `object` will be reflected in the returned iterator. -- In environments supporting `Symbol.iterator`, the function **explicitly** does **not** invoke an array's `@@iterator` method, regardless of whether this method is defined. To convert an array to an implementation defined iterator, invoke this method directly. -- The returned iterator supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]). - -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var sparsearray2iterator = require( '@stdlib/array/to-sparse-iterator' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array partially filled with random numbers: -var arr = new Array( 100 ); -var i; -for ( i = 0; i < arr.length; i += 2 ) { - arr[ i ] = randu(); -} - -// Create an iterator from the array which scales iterated values: -var it = sparsearray2iterator( arr, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-sparse-iterator/benchmark/benchmark.js b/to-sparse-iterator/benchmark/benchmark.js deleted file mode 100644 index 7419dc87c..000000000 --- a/to-sparse-iterator/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var sparsearray2iterator = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var iter; - var i; - - values = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - values[ 0 ] = i; - iter = sparsearray2iterator( values ); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - for ( i = 0; i < b.iterations; i++ ) { - values.push( i ); - } - - iter = sparsearray2iterator( values ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration,map', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - for ( i = 0; i < b.iterations; i++ ) { - values.push( i ); - } - - iter = sparsearray2iterator( values, transform ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return i; - } -}); diff --git a/to-sparse-iterator/docs/repl.txt b/to-sparse-iterator/docs/repl.txt deleted file mode 100644 index 0f3e77e3d..000000000 --- a/to-sparse-iterator/docs/repl.txt +++ /dev/null @@ -1,56 +0,0 @@ - -{{alias}}( src[, mapFcn[, thisArg]] ) - Returns an iterator which iterates over the elements of a sparse array-like - object. - - The returned iterator skips elements which are undefined. - - When invoked, an input function is provided three arguments: - - - value: iterated value. - - index: iterated value index. - - src: source array-like object. - - If an environment supports Symbol.iterator, the returned iterator is - iterable. - - If an environment supports Symbol.iterator, the function explicitly does not - invoke an array's `@@iterator` method, regardless of whether this method is - defined. To convert an array to an implementation defined iterator, invoke - this method directly. - - Parameters - ---------- - src: ArrayLikeObject - Sparse array-like object from which to create the iterator. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - iterator: Object - Iterator. - - iterator.next(): Function - Returns an iterator protocol-compliant object containing the next - iterated value (if one exists) and a boolean flag indicating whether the - iterator is finished. - - iterator.return( [value] ): Function - Finishes an iterator and returns a provided value. - - Examples - -------- - > var it = {{alias}}( [ 1, , 3, 4 ] ); - > var v = it.next().value - 1 - > v = it.next().value - 3 - - See Also - -------- - diff --git a/to-sparse-iterator/docs/types/index.d.ts b/to-sparse-iterator/docs/types/index.d.ts deleted file mode 100644 index f09478fc2..000000000 --- a/to-sparse-iterator/docs/types/index.d.ts +++ /dev/null @@ -1,98 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Returns an iterator which iterates over each element in a sparse array-like object. -* -* @param src - input value -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns iterator -* -* @example -* var iter = sparsearray2iterator( [ 1, , 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 1 -* -* v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 4 -*/ -declare function sparsearray2iterator( src: ArrayLike, mapFcn?: MapFunction, thisArg?: any ): Iterator; - - -// EXPORTS // - -export = sparsearray2iterator; diff --git a/to-sparse-iterator/docs/types/test.ts b/to-sparse-iterator/docs/types/test.ts deleted file mode 100644 index 226ad1136..000000000 --- a/to-sparse-iterator/docs/types/test.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 sparsearray2iterator = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - sparsearray2iterator( [ 1, 2, 3, 4 ] ); // $ExpectType Iterator - sparsearray2iterator( [ 1, 2, 3, 4 ], times10 ); // $ExpectType Iterator - sparsearray2iterator( [ 1, 2, 3, 4 ], times10, {} ); // $ExpectType Iterator -} - -// The compiler throws an error if the function is provided a first argument which is not array-like... -{ - sparsearray2iterator( 123 ); // $ExpectError - sparsearray2iterator( true ); // $ExpectError - sparsearray2iterator( false ); // $ExpectError - sparsearray2iterator( {} ); // $ExpectError - sparsearray2iterator( null ); // $ExpectError - sparsearray2iterator( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function... -{ - sparsearray2iterator( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - sparsearray2iterator( [ 1, 2, 3, 4 ], 123 ); // $ExpectError - sparsearray2iterator( [ 1, 2, 3, 4 ], [] ); // $ExpectError - sparsearray2iterator( [ 1, 2, 3, 4 ], {} ); // $ExpectError - sparsearray2iterator( [ 1, 2, 3, 4 ], true ); // $ExpectError - sparsearray2iterator( [ 1, 2, 3, 4 ], false ); // $ExpectError - sparsearray2iterator( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - sparsearray2iterator(); // $ExpectError - sparsearray2iterator( [ 1, 2, 3, 4 ], times10, {}, 123 ); // $ExpectError -} diff --git a/to-sparse-iterator/examples/index.js b/to-sparse-iterator/examples/index.js deleted file mode 100644 index 304c3b28c..000000000 --- a/to-sparse-iterator/examples/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var sparsearray2iterator = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array partially filled with random numbers: -var arr = new Array( 100 ); -var i; -for ( i = 0; i < arr.length; i += 2 ) { - arr[ i ] = randu(); -} - -// Create an iterator from the array which scales iterated values: -var it = sparsearray2iterator( arr, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} diff --git a/to-sparse-iterator/lib/index.js b/to-sparse-iterator/lib/index.js deleted file mode 100644 index e7c4cb3c6..000000000 --- a/to-sparse-iterator/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an iterator from a sparse array-like value. -* -* @module @stdlib/array/to-sparse-iterator -* -* @example -* var sparsearray2iterator = require( '@stdlib/array/to-sparse-iterator' ); -* -* var iter = sparsearray2iterator( [ 1, , 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 1 -* -* v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 4 -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-sparse-iterator/lib/main.js b/to-sparse-iterator/lib/main.js deleted file mode 100644 index bf8c6c5be..000000000 --- a/to-sparse-iterator/lib/main.js +++ /dev/null @@ -1,197 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isAccessorArray = require( './../../base/assert/is-accessor-array' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var getter = require( './../../base/getter' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns an iterator which iterates over each element in a sparse array-like object. -* -* @param {Collection} src - input value -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} second argument must be a function -* @returns {Iterator} iterator -* -* @example -* var iter = sparsearray2iterator( [ 1, , 3, 4 ] ); -* -* var v = iter.next().value; -* // returns 1 -* -* v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 4 -*/ -function sparsearray2iterator( src ) { - var thisArg; - var iter; - var FLG; - var fcn; - var get; - var dt; - var i; - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); - } - if ( arguments.length > 1 ) { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - if ( fcn ) { - setReadOnly( iter, 'next', next1 ); - } else { - setReadOnly( iter, 'next', next2 ); - } - setReadOnly( iter, 'return', end ); - - // If an environment supports `Symbol.iterator`, make the iterator iterable: - if ( iteratorSymbol ) { - setReadOnly( iter, iteratorSymbol, factory ); - } - // Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc): - dt = dtype( src ); - if ( isAccessorArray( src ) ) { - get = accessorGetter( dt ); - } else { - get = getter( dt ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next1() { - var len; - if ( FLG ) { - return { - 'done': true - }; - } - len = src.length; - i += 1; - while ( i < len && get( src, i ) === void 0 ) { - i += 1; - } - if ( i >= len ) { - FLG = true; - return { - 'done': true - }; - } - return { - 'value': fcn.call( thisArg, get( src, i ), i, src ), - 'done': false - }; - } - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next2() { - var len; - if ( FLG ) { - return { - 'done': true - }; - } - len = src.length; - i += 1; - while ( i < len && get( src, i ) === void 0 ) { - i += 1; - } - if ( i >= len ) { - FLG = true; - return { - 'done': true - }; - } - return { - 'value': get( src, i ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - if ( fcn ) { - return sparsearray2iterator( src, fcn, thisArg ); - } - return sparsearray2iterator( src ); - } -} - - -// EXPORTS // - -module.exports = sparsearray2iterator; diff --git a/to-sparse-iterator/package.json b/to-sparse-iterator/package.json deleted file mode 100644 index eb9e33c20..000000000 --- a/to-sparse-iterator/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/array/to-sparse-iterator", - "version": "0.0.0", - "description": "Create an iterator from a sparse array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "arr", - "sparse", - "holes", - "typed-array", - "typed array", - "iterator", - "iterate", - "iteration", - "iter", - "to", - "convert" - ] -} diff --git a/to-sparse-iterator/test/test.js b/to-sparse-iterator/test/test.js deleted file mode 100644 index 05d2abd46..000000000 --- a/to-sparse-iterator/test/test.js +++ /dev/null @@ -1,730 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var noop = require( '@stdlib/utils/noop' ); -var sparsearray2iterator = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sparsearray2iterator, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sparsearray2iterator( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sparsearray2iterator( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - sparsearray2iterator( [ 1, 2, 3, 4 ], value ); - }; - } -}); - -tape( 'the function returns an iterator protocol-compliant object', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (empty array)', function test( t ) { - var expected; - var actual; - var values; - var it; - - values = new Array( 1e5 ); - expected = [ - { - 'done': true - } - ]; - - it = sparsearray2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (empty end)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = new Array( 4 ); - - // Leave the last element empty: - for ( i = 0; i < values.length-1; i++ ) { - values[ i ] = i + 1; - } - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (empty start)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = new Array( 4 ); - - // Leave the first element empty: - for ( i = 1; i < values.length; i++ ) { - values[ i ] = i + 1; - } - - expected = [ - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (empty start+end)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = new Array( 4 ); - - // Leave the first and last elements empty: - for ( i = 1; i < values.length-1; i++ ) { - values[ i ] = i + 1; - } - - expected = [ - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (array-like object)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '1': 2, - '2': 3, - '3': 4 - }; - expected = [ - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = new Array( 4 ); - - // Leave the last element empty: - for ( i = 0; i < values.length-1; i++ ) { - values[ i ] = i + 1; - } - - it = sparsearray2iterator( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-1, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (array-like)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '3': 4 - }; - - it = sparsearray2iterator( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-1, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object', function test( t ) { - var expected; - var values; - var actual; - var it; - var i; - - values = [ 1, , 3, 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - actual.push( it.next() ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (callback)', function test( t ) { - var expected; - var values; - var actual; - var it; - var i; - - values = [ 1, 2, , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'value': 16, - 'done': false - }, - { - 'done': true - } - ]; - - it = sparsearray2iterator( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - actual.push( it.next() ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var it; - var r; - - it = sparsearray2iterator( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument; callback)', function test( t ) { - var it; - var r; - - it = sparsearray2iterator( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var it; - var r; - - it = sparsearray2iterator( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument; callback)', function test( t ) { - var it; - var r; - - it = sparsearray2iterator( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable', function test( t ) { - var sparsearray2iterator; - var values; - var it1; - var it2; - var i; - - sparsearray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = sparsearray2iterator( values ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (callback)', function test( t ) { - var sparsearray2iterator; - var values; - var it1; - var it2; - var i; - - sparsearray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = sparsearray2iterator( values, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable"', function test( t ) { - var sparsearray2iterator; - var it; - - sparsearray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = sparsearray2iterator( [ 1, 2, 3, 4 ] ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (callback)', function test( t ) { - var sparsearray2iterator; - var it; - - sparsearray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = sparsearray2iterator( [ 1, 2, 3, 4 ], scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/to-strided-iterator/README.md b/to-strided-iterator/README.md deleted file mode 100644 index b05e19152..000000000 --- a/to-strided-iterator/README.md +++ /dev/null @@ -1,251 +0,0 @@ - - -# Strided Iterator - -> Create an [iterator][mdn-iterator-protocol] from a strided array-like object. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var stridedarray2iterator = require( '@stdlib/array/to-strided-iterator' ); -``` - -#### stridedarray2iterator( N, src, stride, offset\[, mapFcn\[, thisArg]] ) - -Returns an [iterator][mdn-iterator-protocol] which iterates over elements in an array-like `object` according to specified stride parameters. - -```javascript -var values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - -var N = 4; -var stride = -2; -var offset = 6; - -var it = stridedarray2iterator( N, values, stride, offset ); -// returns - -var v = it.next().value; -// returns 7 - -v = it.next().value; -// returns 5 - -v = it.next().value; -// returns 3 - -// ... -``` - -The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties: - -- **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the [iterator][mdn-iterator-protocol] is finished. -- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an iterator protocol-compliant object. - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function fcn( v ) { - return v * 10.0; -} - -var it = stridedarray2iterator( 4, [ 1, 2, 3, 4 ], 1, 0, fcn ); -// returns - -var v = it.next().value; -// returns 10.0 - -v = it.next().value; -// returns 20.0 - -v = it.next().value; -// returns 30.0 - -// ... -``` - -The invoked function is provided four arguments: - -- **value**: iterated value. -- **index**: iterated value index. -- **n**: iteration count (zero-based). -- **src**: source array-like object. - -```javascript -function fcn( v, i ) { - return v * (i+1); -} - -var it = stridedarray2iterator( 4, [ 1, 2, 3, 4 ], 1, 0, fcn ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 9 - -// ... -``` - -To set the callback function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return v * 10.0; -} - -var ctx = { - 'count': 0 -}; - -var it = stridedarray2iterator( 4, [ 1, 2, 3, 4 ], 1, 0, fcn, ctx ); -// returns - -var v = it.next().value; -// returns 10.0 - -v = it.next().value; -// returns 20.0 - -v = it.next().value; -// returns 30.0 - -var count = ctx.count; -// returns 3 -``` - - - - - - - -
- -## Notes - -- If an environment supports `Symbol.iterator`, the returned [iterator][mdn-iterator-protocol] is iterable. -- If provided a generic `array`, the returned [iterator][mdn-iterator-protocol] does **not** ignore holes. To achieve greater performance for sparse arrays, use a custom [iterator][mdn-iterator-protocol]. -- A returned [iterator][mdn-iterator-protocol] does **not** copy a provided array-like `object`. To ensure iterable reproducibility, copy a provided array-like `object` **before** creating an [iterator][mdn-iterator-protocol]. Otherwise, any changes to the contents of an array-like `object` will be reflected in the returned [iterator][mdn-iterator-protocol]. -- In environments supporting `Symbol.iterator`, the function **explicitly** does **not** invoke an array's `@@iterator` method, regardless of whether this method is defined. To convert an array to an implementation defined [iterator][mdn-iterator-protocol], invoke this method directly. -- The returned [iterator][mdn-iterator-protocol] supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]). - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var stridedarray2iterator = require( '@stdlib/array/to-strided-iterator' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 100 ), randu ); - -// Create an iterator which scales every fourth value in reverse order: -var it = stridedarray2iterator( 25, arr, -4, 99, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-strided-iterator/benchmark/benchmark.js b/to-strided-iterator/benchmark/benchmark.js deleted file mode 100644 index 1a4b1da40..000000000 --- a/to-strided-iterator/benchmark/benchmark.js +++ /dev/null @@ -1,115 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var stridedarray2iterator = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var iter; - var N; - var i; - - values = [ 1, 2, 3, 4 ]; - N = values.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - values[ 0 ] = i; - iter = stridedarray2iterator( N, values, 1, 0 ); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration', function benchmark( b ) { - var values; - var iter; - var N; - var z; - var i; - - values = []; - values.length = b.iterations; - N = values.length; - - iter = stridedarray2iterator( N, values, 1, 0 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( z !== void 0 ) { - b.fail( 'should be undefined' ); - } - } - b.toc(); - if ( z !== void 0 ) { - b.fail( 'should be undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration,map', function benchmark( b ) { - var values; - var iter; - var N; - var z; - var i; - - values = []; - values.length = b.iterations; - N = values.length; - - iter = stridedarray2iterator( N, values, 1, 0, transform ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return i; - } -}); diff --git a/to-strided-iterator/docs/repl.txt b/to-strided-iterator/docs/repl.txt deleted file mode 100644 index bb9609caf..000000000 --- a/to-strided-iterator/docs/repl.txt +++ /dev/null @@ -1,64 +0,0 @@ - -{{alias}}( N, src, stride, offset[, mapFcn[, thisArg]] ) - Returns an iterator which iterates over elements of an array-like object - according to specified stride parameters. - - When invoked, an input function is provided four arguments: - - - value: iterated value. - - index: iterated value index. - - n: iteration count (zero-based). - - src: source array-like object. - - If an environment supports Symbol.iterator, the returned iterator is - iterable. - - If an environment supports Symbol.iterator, the function explicitly does not - invoke an array's `@@iterator` method, regardless of whether this method is - defined. To convert an array to an implementation defined iterator, invoke - this method directly. - - Parameters - ---------- - N: integer - Number of values to iterate. - - src: ArrayLikeObject - Array-like object from which to create the iterator. - - stride: integer - Stride length. - - offset: integer - Starting index. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - iterator: Object - Iterator. - - iterator.next(): Function - Returns an iterator protocol-compliant object containing the next - iterated value (if one exists) and a boolean flag indicating whether the - iterator is finished. - - iterator.return( [value] ): Function - Finishes an iterator and returns a provided value. - - Examples - -------- - > var it = {{alias}}( 2, [ 1, 2, 3, 4 ], -2, 3 ); - > var v = it.next().value - 4 - > v = it.next().value - 2 - - See Also - -------- - diff --git a/to-strided-iterator/docs/types/index.d.ts b/to-strided-iterator/docs/types/index.d.ts deleted file mode 100644 index 09ce0689b..000000000 --- a/to-strided-iterator/docs/types/index.d.ts +++ /dev/null @@ -1,124 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param n - iteration count (zero-based) -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, n: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param n - iteration count (zero-based) -* @param src - source array-like object -* @returns iterator value -*/ -type Quaternary = ( value: any, index: number, n: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param n - iteration count (zero-based) -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary | Quaternary; - -/** -* Returns an iterator which iterates over elements in an array-like object according to specified stride parameters. -* -* @param N - number of values to iterate -* @param src - input value -* @param stride - stride length -* @param offset - starting index -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @throws first argument must be a nonnegative integer -* @throws third argument must be an integer -* @throws fourth argument must be a nonnegative integer -* @returns iterator -* -* @example -* var values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* -* var N = 4; -* var stride = -2; -* var offset = 6; -* -* var iter = stridedarray2iterator( N, values, stride, offset ); -* -* var v = iter.next().value; -* // returns 7 -* -* v = iter.next().value; -* // returns 5 -* -* v = iter.next().value; -* // returns 3 -* -* // ... -*/ -declare function stridedarray2iterator( N: number, src: ArrayLike, stride: number, offset: number, mapFcn?: MapFunction, thisArg?: any ): Iterator; - - -// EXPORTS // - -export = stridedarray2iterator; diff --git a/to-strided-iterator/docs/types/test.ts b/to-strided-iterator/docs/types/test.ts deleted file mode 100644 index 721a86d40..000000000 --- a/to-strided-iterator/docs/types/test.ts +++ /dev/null @@ -1,99 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 stridedarray2iterator = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, 3 ); // $ExpectType Iterator - stridedarray2iterator( 4, [ 1, 2, 3, 4, 5, 6, 7, 8 ], -2, 6, times10 ); // $ExpectType Iterator - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, 3, times10, {} ); // $ExpectType Iterator -} - -// The compiler throws an error if the function is provided a first argument which is not a number... -{ - stridedarray2iterator( 'abc', [ 1, 2, 3, 4 ], -2, 3 ); // $ExpectError - stridedarray2iterator( true, [ 1, 2, 3, 4 ], -2, 3 ); // $ExpectError - stridedarray2iterator( false, [ 1, 2, 3, 4 ], -2, 3 ); // $ExpectError - stridedarray2iterator( {}, [ 1, 2, 3, 4 ], -2, 3 ); // $ExpectError - stridedarray2iterator( null, [ 1, 2, 3, 4 ], -2, 3 ); // $ExpectError - stridedarray2iterator( undefined, [ 1, 2, 3, 4 ], -2, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not array-like... -{ - stridedarray2iterator( 2, 123, -2, 3 ); // $ExpectError - stridedarray2iterator( 2, true, -2, 3 ); // $ExpectError - stridedarray2iterator( 2, false, -2, 3 ); // $ExpectError - stridedarray2iterator( 2, {}, -2, 3 ); // $ExpectError - stridedarray2iterator( 2, null, -2, 3 ); // $ExpectError - stridedarray2iterator( 2, undefined, -2, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a number... -{ - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], 'abc', 3 ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], true, 3 ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], false, 3 ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], {}, 3 ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], null, 3 ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, 'abc' ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, true ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, false ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, {} ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, null ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a map function... -{ - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, 3, 'abc' ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, 3, 123 ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, 3, [] ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, 3, {} ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, 3, true ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, 3, false ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, 3, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - stridedarray2iterator(); // $ExpectError - stridedarray2iterator( 2 ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ] ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2 ); // $ExpectError - stridedarray2iterator( 2, [ 1, 2, 3, 4 ], -2, 3, times10, {}, 123 ); // $ExpectError -} diff --git a/to-strided-iterator/examples/index.js b/to-strided-iterator/examples/index.js deleted file mode 100644 index 02a4cc83b..000000000 --- a/to-strided-iterator/examples/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Float64Array = require( './../../float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var stridedarray2iterator = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 100 ), randu ); - -// Create an iterator which scales every fourth value in reverse order: -var it = stridedarray2iterator( 25, arr, -4, 99, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} diff --git a/to-strided-iterator/lib/index.js b/to-strided-iterator/lib/index.js deleted file mode 100644 index a87036811..000000000 --- a/to-strided-iterator/lib/index.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an iterator from a strided array-like value. -* -* @module @stdlib/array/to-strided-iterator -* -* @example -* var stridedarray2iterator = require( '@stdlib/array/to-strided-iterator' ); -* -* var values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* -* var N = 4; -* var stride = -2; -* var offset = 6; -* -* var iter = stridedarray2iterator( N, values, stride, offset ); -* -* var v = iter.next().value; -* // returns 7 -* -* v = iter.next().value; -* // returns 5 -* -* v = iter.next().value; -* // returns 3 -* -* // ... -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-strided-iterator/lib/main.js b/to-strided-iterator/lib/main.js deleted file mode 100644 index aaef30318..000000000 --- a/to-strided-iterator/lib/main.js +++ /dev/null @@ -1,208 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var isAccessorArray = require( './../../base/assert/is-accessor-array' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var getter = require( './../../base/getter' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns an iterator which iterates over elements in an array-like object according to specified stride parameters. -* -* @param {NonNegativeInteger} N - number of values to iterate -* @param {Collection} src - input value -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be an array-like object -* @throws {TypeError} third argument must be an integer -* @throws {TypeError} fourth argument must be a nonnegative integer -* @throws {TypeError} fifth argument must be a function -* @returns {Iterator} iterator -* -* @example -* var values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; -* -* var N = 4; -* var stride = -2; -* var offset = 6; -* -* var iter = stridedarray2iterator( N, values, stride, offset ); -* -* var v = iter.next().value; -* // returns 7 -* -* v = iter.next().value; -* // returns 5 -* -* v = iter.next().value; -* // returns 3 -* -* // ... -*/ -function stridedarray2iterator( N, src, stride, offset ) { - var thisArg; - var iter; - var FLG; - var fcn; - var idx; - var get; - var dt; - var i; - if ( !isNonNegativeInteger( N ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', N ) ); - } - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be an array-like object. Value: `%s`.', src ) ); - } - if ( !isInteger( stride ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be an integer. Value: `%s`.', stride ) ); - } - if ( !isNonNegativeInteger( offset ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%s`.', offset ) ); - } - if ( arguments.length > 4 ) { - fcn = arguments[ 4 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fifth argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 5 ]; - } - idx = offset; - i = -1; - - // Create an iterator protocol-compliant object: - iter = {}; - if ( fcn ) { - setReadOnly( iter, 'next', next1 ); - } else { - setReadOnly( iter, 'next', next2 ); - } - setReadOnly( iter, 'return', end ); - - // If an environment supports `Symbol.iterator`, make the iterator iterable: - if ( iteratorSymbol ) { - setReadOnly( iter, iteratorSymbol, factory ); - } - // Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc): - dt = dtype( src ); - if ( isAccessorArray( src ) ) { - get = accessorGetter( dt ); - } else { - get = getter( dt ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next1() { - var v; - i += 1; - if ( FLG || i >= N ) { - return { - 'done': true - }; - } - v = fcn.call( thisArg, get( src, idx ), idx, i, src ); - idx += stride; - return { - 'value': v, - 'done': false - }; - } - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next2() { - var v; - i += 1; - if ( FLG || i >= N ) { - return { - 'done': true - }; - } - v = get( src, idx ); - idx += stride; - return { - 'value': v, - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function end( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - if ( fcn ) { - return stridedarray2iterator( N, src, stride, offset, fcn, thisArg ); // eslint-disable-line max-len - } - return stridedarray2iterator( N, src, stride, offset ); - } -} - - -// EXPORTS // - -module.exports = stridedarray2iterator; diff --git a/to-strided-iterator/package.json b/to-strided-iterator/package.json deleted file mode 100644 index 6cf7f0abb..000000000 --- a/to-strided-iterator/package.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "@stdlib/array/to-strided-iterator", - "version": "0.0.0", - "description": "Create an iterator from a strided array-like object.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "arr", - "typed-array", - "typed array", - "iterator", - "iterate", - "iteration", - "iter", - "to", - "convert", - "strided", - "stride", - "view", - "ndarray", - "multidimensional" - ] -} diff --git a/to-strided-iterator/test/test.js b/to-strided-iterator/test/test.js deleted file mode 100644 index b312cc599..000000000 --- a/to-strided-iterator/test/test.js +++ /dev/null @@ -1,760 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var noop = require( '@stdlib/utils/noop' ); -var stridedarray2iterator = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof stridedarray2iterator, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedarray2iterator( value, [ 1, 2, 3 ], 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not a nonnegative integer (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedarray2iterator( value, [ 1, 2, 3 ], 1, 0, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedarray2iterator( 1, value, 1, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedarray2iterator( 1, value, 1, 0, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not an integer', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedarray2iterator( 1, [ 1, 2, 3 ], value, 0 ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not an integer (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedarray2iterator( 1, [ 1, 2, 3 ], value, 0, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is not a nonnegative integer', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedarray2iterator( 1, [ 1, 2, 3 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is not a nonnegative integer (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - -5, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedarray2iterator( 1, [ 1, 2, 3 ], 1, value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a fifth argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - stridedarray2iterator( 1, [ 1, 2, 3, 4 ], 1, 0, value ); - }; - } -}); - -tape( 'the function returns an iterator protocol-compliant object', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - expected = [ - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'value': 5, - 'done': false - }, - { - 'value': 6, - 'done': false - }, - { - 'done': true - } - ]; - - it = stridedarray2iterator( 4, values, 1, 2 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < 4; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (array-like object)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = { - 'length': 8, - '0': 1, - '1': 2, - '2': 3, - '3': 4, - '4': 5, - '5': 6, - '6': 7, - '7': 8 - }; - expected = [ - { - 'value': 8, - 'done': false - }, - { - 'value': 7, - 'done': false - }, - { - 'value': 6, - 'done': false - }, - { - 'value': 5, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = stridedarray2iterator( 5, values, -1, 7 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < 5; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = stridedarray2iterator( 4, values, -1, 3, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = [ 4, 6, 6, 4 ]; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i, n ) { - v *= n + 1; - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (array-like)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - - it = stridedarray2iterator( 4, values, 1, 0, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = [ 1, 4, 9, 16 ]; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object', function test( t ) { - var expected; - var values; - var actual; - var it; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = stridedarray2iterator( 4, values, 1, 0 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - actual.push( it.next() ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (callback)', function test( t ) { - var expected; - var values; - var actual; - var it; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'value': 9, - 'done': false - }, - { - 'value': 16, - 'done': false - }, - { - 'done': true - } - ]; - - it = stridedarray2iterator( 4, values, 1, 0, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - actual.push( it.next() ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var it; - var r; - - it = stridedarray2iterator( 4, [ 1, 2, 3, 4 ], 1, 0 ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument; callback)', function test( t ) { - var it; - var r; - - it = stridedarray2iterator( 4, [ 1, 2, 3, 4 ], 1, 0, scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var it; - var r; - - it = stridedarray2iterator( 4, [ 1, 2, 3, 4 ], 1, 0 ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument; callback)', function test( t ) { - var it; - var r; - - it = stridedarray2iterator( 4, [ 1, 2, 3, 4 ], 1, 0, scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable', function test( t ) { - var stridedarray2iterator; - var values; - var it1; - var it2; - var i; - - stridedarray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = stridedarray2iterator( 4, values, 1, 0 ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (callback)', function test( t ) { - var stridedarray2iterator; - var values; - var it1; - var it2; - var i; - - stridedarray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = stridedarray2iterator( 4, values, 1, 0, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable"', function test( t ) { - var stridedarray2iterator; - var it; - - stridedarray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = stridedarray2iterator( 4, [ 1, 2, 3, 4 ], 1, 0 ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (callback)', function test( t ) { - var stridedarray2iterator; - var it; - - stridedarray2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = stridedarray2iterator( 4, [ 1, 2, 3, 4 ], 1, 0, scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/to-view-iterator-right/README.md b/to-view-iterator-right/README.md deleted file mode 100644 index 84c6cfa84..000000000 --- a/to-view-iterator-right/README.md +++ /dev/null @@ -1,325 +0,0 @@ - - -# arrayview2iteratorRight - -> Create an iterator from an array-like object view, iterating from right to left. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var arrayview2iteratorRight = require( '@stdlib/array/to-view-iterator-right' ); -``` - -#### arrayview2iteratorRight( src\[, begin\[, end]]\[, mapFcn\[, thisArg]] ) - -Returns an iterator which iterates from right to left over each element in an array-like `object` view. - -```javascript -var it = arrayview2iteratorRight( [ 1, 2, 3, 4 ] ); -// returns - -var v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 2 - -// ... -``` - -The returned iterator protocol-compliant object has the following properties: - -- **next**: function which returns an iterator protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the iterator is finished. -- **return**: function which closes an iterator and returns a single (optional) argument in an iterator protocol-compliant object. - -The `begin` and `end` arguments define the starting (inclusive) and ending (non-inclusive) indices of the array view. By default, the returned iterator starts iterating from the last element in an array-like `object` (i.e., from the "end"). To specify an alternative view end, provide an `end` argument (non-inclusive). - -```javascript -var it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 0, 3 ); -// returns - -var v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - -If `end` is less than `0`, the first iterated value is resolved relative to the last view element. For example, the following generates the same behavior as in the previous example - -```javascript -var it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 0, -1 ); -// returns - -var v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - -By default, the returned iterator iterates through the first element in an array-like `object` view. To specify an alternative view beginning, provide a `begin` argument (inclusive). - -```javascript -var it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1 ); -// returns - -var v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 2 - -var bool = it.next().done; -// returns true -``` - -If `begin` is less than `0`, the last iterated value is resolved relative to the last view element. For example, the following generates the same behavior as in the previous example - -```javascript -var it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], -3 ); -// returns - -var v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 2 - -var bool = it.next().done; -// returns true -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function fcn( v ) { - return v * 10.0; -} - -var it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 40.0 - -v = it.next().value; -// returns 30.0 - -v = it.next().value; -// returns 20.0 - -// ... -``` - -The invoked function is provided four arguments: - -- **value**: iterated value. -- **index**: iterated value index. -- **n**: iteration count (zero-based). -- **src**: source array-like object. - -```javascript -function fcn( v, i ) { - return v * (i+1); -} - -var it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 16 - -v = it.next().value; -// returns 9 - -v = it.next().value; -// returns 4 - -// ... -``` - -To set the callback function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return v * 10.0; -} - -var ctx = { - 'count': 0 -}; - -var it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], fcn, ctx ); -// returns - -var v = it.next().value; -// returns 40.0 - -v = it.next().value; -// returns 30.0 - -v = it.next().value; -// returns 20.0 - -var count = ctx.count; -// returns 3 -``` - - - - - - - -
- -## Notes - -- If an environment supports `Symbol.iterator`, the returned iterator is iterable. -- If provided a generic `array`, the returned iterator does **not** ignore holes. To achieve greater performance for sparse arrays, use a custom iterator. -- A returned iterator does **not** copy a provided array-like `object`. To ensure iterable reproducibility, copy a provided array-like `object` **before** creating an iterator. Otherwise, any changes to the contents of an array-like `object` will be reflected in the returned iterator. -- In environments supporting `Symbol.iterator`, the function **explicitly** does **not** invoke an array's `@@iterator` method, regardless of whether this method is defined. To convert an array to an implementation defined iterator, invoke this method directly. -- The returned iterator supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]). - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var arrayview2iteratorRight = require( '@stdlib/array/to-view-iterator-right' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 100 ), randu ); - -// Create an iterator from an array view which scales iterated values: -var it = arrayview2iteratorRight( arr, 40, 60, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-view-iterator-right/benchmark/benchmark.js b/to-view-iterator-right/benchmark/benchmark.js deleted file mode 100644 index 699761b04..000000000 --- a/to-view-iterator-right/benchmark/benchmark.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var arrayview2iteratorRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var iter; - var i; - - values = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - values[ 0 ] = i; - iter = arrayview2iteratorRight( values ); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - values.length = b.iterations; - - iter = arrayview2iteratorRight( values ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( z !== void 0 ) { - b.fail( 'should be undefined' ); - } - } - b.toc(); - if ( z !== void 0 ) { - b.fail( 'should be undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration,map', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - values.length = b.iterations; - - iter = arrayview2iteratorRight( values, transform ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return i; - } -}); diff --git a/to-view-iterator-right/docs/repl.txt b/to-view-iterator-right/docs/repl.txt deleted file mode 100644 index b6a5e3d43..000000000 --- a/to-view-iterator-right/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( src[, begin[, end]][, mapFcn[, thisArg]] ) - Returns an iterator which iterates from right to left over the elements of - an array-like object view. - - When invoked, an input function is provided four arguments: - - - value: iterated value. - - index: iterated value index. - - n: iteration count (zero-based). - - src: source array-like object. - - If an environment supports Symbol.iterator, the returned iterator is - iterable. - - If an environment supports Symbol.iterator, the function explicitly does not - invoke an array's `@@iterator` method, regardless of whether this method is - defined. To convert an array to an implementation defined iterator, invoke - this method directly. - - Parameters - ---------- - src: ArrayLikeObject - Array-like object from which to create the iterator. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: src.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - iterator: Object - Iterator. - - iterator.next(): Function - Returns an iterator protocol-compliant object containing the next - iterated value (if one exists) and a boolean flag indicating whether the - iterator is finished. - - iterator.return( [value] ): Function - Finishes an iterator and returns a provided value. - - Examples - -------- - > var it = {{alias}}( [ 1, 2, 3, 4 ], 1, 3 ); - > var v = it.next().value - 3 - > v = it.next().value - 2 - - See Also - -------- - diff --git a/to-view-iterator-right/docs/types/index.d.ts b/to-view-iterator-right/docs/types/index.d.ts deleted file mode 100644 index 59fa0e86c..000000000 --- a/to-view-iterator-right/docs/types/index.d.ts +++ /dev/null @@ -1,149 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Returns an iterator which iterates from right to left over each element in an array-like object view. -* -* @param src - input value -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns iterator -* -* @example -* function fcn( v ) { -* return v * 10.0; -* } -* -* var iter = arrayview2iteratorRight( [ 1, 2, 3, 4 ], fcn ); -* -* var v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 2 -* -* var bool = iter.next().done; -* // returns true -*/ -declare function arrayview2iteratorRight( src: ArrayLike, mapFcn?: MapFunction, thisArg?: any ): Iterator; - -/** -* Returns an iterator which iterates from right to left over each element in an array-like object view. -* -* @param src - input value -* @param begin - starting **view** index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns iterator -* -* @example -* var iter = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1 ); -* -* var v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 2 -* -* var bool = iter.next().done; -* // returns false -*/ -declare function arrayview2iteratorRight( src: ArrayLike, begin: number, mapFcn?: MapFunction, thisArg?: any ): Iterator; - -/** -* Returns an iterator which iterates from right to left over each element in an array-like object view. -* -* @param src - input value -* @param begin - starting **view** index (inclusive) (default: 0) -* @param end - ending **view** index (non-inclusive) (default: src.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns iterator -* -* @example -* var iter = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 3 ); -* -* var v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 2 -* -* var bool = iter.next().done; -* // returns true -*/ -declare function arrayview2iteratorRight( src: ArrayLike, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Iterator; - - -// EXPORTS // - -export = arrayview2iteratorRight; diff --git a/to-view-iterator-right/docs/types/test.ts b/to-view-iterator-right/docs/types/test.ts deleted file mode 100644 index 6f74bf33c..000000000 --- a/to-view-iterator-right/docs/types/test.ts +++ /dev/null @@ -1,86 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arrayview2iteratorRight = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - arrayview2iteratorRight( [ 1, 2, 3, 4 ] ); // $ExpectType Iterator - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 2, times10 ); // $ExpectType Iterator - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 2, times10, {} ); // $ExpectType Iterator -} - -// The compiler throws an error if the function is provided a first argument which is not array-like... -{ - arrayview2iteratorRight( 123 ); // $ExpectError - arrayview2iteratorRight( true ); // $ExpectError - arrayview2iteratorRight( false ); // $ExpectError - arrayview2iteratorRight( {} ); // $ExpectError - arrayview2iteratorRight( null ); // $ExpectError - arrayview2iteratorRight( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number or function... -{ - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], [] ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], {} ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], true ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], false ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not number or function... -{ - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 'abc' ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, [] ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, {} ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, true ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, false ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a function... -{ - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 0, 2, 'abc' ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 0, 2, 123 ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 0, 2, [] ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 0, 2, {} ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 0, 2, true ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 0, 2, false ); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 0, 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - arrayview2iteratorRight(); // $ExpectError - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 2, times10, {}, 123 ); // $ExpectError -} diff --git a/to-view-iterator-right/examples/index.js b/to-view-iterator-right/examples/index.js deleted file mode 100644 index ac71da0a0..000000000 --- a/to-view-iterator-right/examples/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( './../../float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var arrayview2iteratorRight = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 100 ), randu ); - -// Create an iterator from an array view which scales iterated values: -var it = arrayview2iteratorRight( arr, 40, 60, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} diff --git a/to-view-iterator-right/lib/index.js b/to-view-iterator-right/lib/index.js deleted file mode 100644 index 6db09fc10..000000000 --- a/to-view-iterator-right/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an iterator from an array-like object view, iterating from right to left. -* -* @module @stdlib/array/to-view-iterator-right -* -* @example -* var arrayview2iteratorRight = require( '@stdlib/array/to-view-iterator-right' ); -* -* var iter = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 3 ); -* -* var v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 2 -* -* var bool = iter.next().done; -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-view-iterator-right/lib/main.js b/to-view-iterator-right/lib/main.js deleted file mode 100644 index dbb4f5dd3..000000000 --- a/to-view-iterator-right/lib/main.js +++ /dev/null @@ -1,231 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var isAccessorArray = require( './../../base/assert/is-accessor-array' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var getter = require( './../../base/getter' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns an iterator which iterates from right to left over each element in an array-like object view. -* -* @param {Collection} src - input value -* @param {integer} [begin=0] - starting **view** index (inclusive) -* @param {integer} [end=src.length] - ending **view** index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} second argument must be either an integer (starting index) or a function -* @throws {TypeError} third argument must be either an integer (ending index) or a function -* @throws {TypeError} fourth argument must be a function -* @returns {Iterator} iterator -* -* @example -* var iter = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 3 ); -* -* var v = iter.next().value; -* // returns 3 -* -* v = iter.next().value; -* // returns 2 -* -* var bool = iter.next().done; -* // returns true -*/ -function arrayview2iteratorRight( src ) { - var thisArg; - var begin; - var nargs; - var iter; - var FLG; - var fcn; - var end; - var get; - var dt; - var i; - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); - } - nargs = arguments.length; - if ( nargs === 1 ) { - begin = 0; - end = src.length; - } else if ( nargs === 2 ) { - if ( isFunction( arguments[ 1 ] ) ) { - begin = 0; - fcn = arguments[ 1 ]; - } else { - begin = arguments[ 1 ]; - } - end = src.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 1 ] ) ) { - begin = 0; - end = src.length; - fcn = arguments[ 1 ]; - thisArg = arguments[ 2 ]; - } else if ( isFunction( arguments[ 2 ] ) ) { - begin = arguments[ 1 ]; - end = src.length; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 1 ]; - end = arguments[ 2 ]; - } - } else { // nargs >= 4 - begin = arguments[ 1 ]; - end = arguments[ 2 ]; - fcn = arguments[ 3 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 4 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either an integer (starting view index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (ending view index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = src.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > src.length ) { - end = src.length; - } - if ( begin < 0 ) { - begin = src.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - i = end; - - // Create an iterator protocol-compliant object: - iter = {}; - if ( fcn ) { - setReadOnly( iter, 'next', next1 ); - } else { - setReadOnly( iter, 'next', next2 ); - } - setReadOnly( iter, 'return', finish ); - - // If an environment supports `Symbol.iterator`, make the iterator iterable: - if ( iteratorSymbol ) { - setReadOnly( iter, iteratorSymbol, factory ); - } - // Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc): - dt = dtype( src ); - if ( isAccessorArray( src ) ) { - get = accessorGetter( dt ); - } else { - get = getter( dt ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next1() { - i -= 1; - if ( FLG || i < begin ) { - return { - 'done': true - }; - } - return { - 'value': fcn.call( thisArg, get( src, i ), i, end-i-1, src ), - 'done': false - }; - } - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next2() { - i -= 1; - if ( FLG || i < begin ) { - return { - 'done': true - }; - } - return { - 'value': get( src, i ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function finish( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - if ( fcn ) { - return arrayview2iteratorRight( src, begin, end, fcn, thisArg ); - } - return arrayview2iteratorRight( src, begin, end ); - } -} - - -// EXPORTS // - -module.exports = arrayview2iteratorRight; diff --git a/to-view-iterator-right/package.json b/to-view-iterator-right/package.json deleted file mode 100644 index 7933d12da..000000000 --- a/to-view-iterator-right/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/to-view-iterator-right", - "version": "0.0.0", - "description": "Create an iterator from an array-like object view, iterating from right to left.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "arr", - "view", - "slice", - "reverse", - "typed-array", - "typed array", - "iterator", - "iterate", - "iteration", - "iter", - "to", - "convert" - ] -} diff --git a/to-view-iterator-right/test/test.js b/to-view-iterator-right/test/test.js deleted file mode 100644 index 5dbff1e97..000000000 --- a/to-view-iterator-right/test/test.js +++ /dev/null @@ -1,1490 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var noop = require( '@stdlib/utils/noop' ); -var arrayview2iteratorRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arrayview2iteratorRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iteratorRight( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (begin)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iteratorRight( value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (begin+callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iteratorRight( value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (begin+end)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iteratorRight( value, 1, 3 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (begin+end+callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iteratorRight( value, 1, 3, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iteratorRight( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is neither an integer nor a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iteratorRight( [ 1, 2, 3, 4 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an integer (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iteratorRight( [ 1, 2, 3, 4 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not an integer (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 3, value ); - }; - } -}); - -tape( 'the function returns an iterator protocol-compliant object', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iteratorRight( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iteratorRight( values, 2 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin+end)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iteratorRight( values, 1, 3 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin+end)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iteratorRight( values, 1, 3000 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin<0)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iteratorRight( values, -3 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin<0)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iteratorRight( values, -300 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin<0+end)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iteratorRight( values, -3, 3 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin+end<0)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iteratorRight( values, 1, -1 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin+end<0)', function test( t ) { - var expected; - var actual; - var values; - var it; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'done': true - } - ]; - - it = arrayview2iteratorRight( values, 0, -3000 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin<0+end<0)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iteratorRight( values, -3, -1 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (array-like object)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = [ - { - 'value': 4, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 1, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iteratorRight( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iteratorRight( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (context)', function test( t ) { - var expected; - var values; - var ctx; - var it; - var r; - var i; - - ctx = { - 'count': 0 - }; - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iteratorRight( values, scale, ctx ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.equal( ctx.count, values.length, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iteratorRight( values, 1, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-1, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iteratorRight( values, -3, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-1, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin+end)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iteratorRight( values, 0, 2, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-2, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin+end<0)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iteratorRight( values, 0, -2, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-2, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin<0+end<0)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iteratorRight( values, -3, -1, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-2, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin+end<0)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iteratorRight( values, 1, -1, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-2, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (array-like)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - - it = arrayview2iteratorRight( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var it; - var r; - - it = arrayview2iteratorRight( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument; callback)', function test( t ) { - var it; - var r; - - it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var it; - var r; - - it = arrayview2iteratorRight( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument; callback)', function test( t ) { - var it; - var r; - - it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable', function test( t ) { - var arrayview2iteratorRight; - var values; - var it1; - var it2; - var i; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iteratorRight( values ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (begin)', function test( t ) { - var arrayview2iteratorRight; - var values; - var it1; - var it2; - var i; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iteratorRight( values, 1 ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (begin+end)', function test( t ) { - var arrayview2iteratorRight; - var values; - var it1; - var it2; - var i; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iteratorRight( values, 1, 3 ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (callback)', function test( t ) { - var arrayview2iteratorRight; - var values; - var it1; - var it2; - var i; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iteratorRight( values, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (begin+callback)', function test( t ) { - var arrayview2iteratorRight; - var values; - var it1; - var it2; - var i; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iteratorRight( values, 1, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (begin+end+callback)', function test( t ) { - var arrayview2iteratorRight; - var values; - var it1; - var it2; - var i; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iteratorRight( values, 1, 3, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable"', function test( t ) { - var arrayview2iteratorRight; - var it; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iteratorRight( [ 1, 2, 3, 4 ] ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (begin)', function test( t ) { - var arrayview2iteratorRight; - var it; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1 ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (begin+end)', function test( t ) { - var arrayview2iteratorRight; - var it; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 3 ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (callback)', function test( t ) { - var arrayview2iteratorRight; - var it; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (begin+callback)', function test( t ) { - var arrayview2iteratorRight; - var it; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (begin+end+callback)', function test( t ) { - var arrayview2iteratorRight; - var it; - - arrayview2iteratorRight = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iteratorRight( [ 1, 2, 3, 4 ], 1, 3, scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/to-view-iterator/README.md b/to-view-iterator/README.md deleted file mode 100644 index eaa6625a3..000000000 --- a/to-view-iterator/README.md +++ /dev/null @@ -1,325 +0,0 @@ - - -# arrayview2iterator - -> Create an iterator from an array-like object view. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var arrayview2iterator = require( '@stdlib/array/to-view-iterator' ); -``` - -#### arrayview2iterator( src\[, begin\[, end]]\[, mapFcn\[, thisArg]] ) - -Returns an iterator which iterates over each element in an array-like `object` view. - -```javascript -var it = arrayview2iterator( [ 1, 2, 3, 4 ] ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 3 - -// ... -``` - -The returned iterator protocol-compliant object has the following properties: - -- **next**: function which returns an iterator protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the iterator is finished. -- **return**: function which closes an iterator and returns a single (optional) argument in an iterator protocol-compliant object. - -By default, the returned iterator begins iterating from the first element in an array-like `object`. To specify an alternative starting index, provide a `begin` argument (inclusive). - -```javascript -var it = arrayview2iterator( [ 1, 2, 3, 4 ], 1 ); -// returns - -var v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 4 - -var bool = it.next().done; -// returns true -``` - -If `begin` is less than `0`, the starting index is resolved relative to the last element. For example, the following generates the same behavior as in the previous example - -```javascript -var it = arrayview2iterator( [ 1, 2, 3, 4 ], -3 ); -// returns - -var v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 3 - -v = it.next().value; -// returns 4 - -var bool = it.next().done; -// returns true -``` - -By default, the returned iterator iterates until the last element in an array-like `object`. To specify an alternative ending index, provide an `end` argument (non-inclusive). - -```javascript -var it = arrayview2iterator( [ 1, 2, 3, 4 ], 0, 3 ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 3 - -var bool = it.next().done; -// returns true -``` - -If `end` is less than `0`, the ending index is resolved relative to the last element. For example, the following generates the same behavior as in the previous example - -```javascript -var it = arrayview2iterator( [ 1, 2, 3, 4 ], 0, -1 ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -v = it.next().value; -// returns 3 - -var bool = it.next().done; -// returns true -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function fcn( v ) { - return v * 10.0; -} - -var it = arrayview2iterator( [ 1, 2, 3, 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 10.0 - -v = it.next().value; -// returns 20.0 - -v = it.next().value; -// returns 30.0 - -// ... -``` - -The invoked function is provided four arguments: - -- **value**: iterated value. -- **index**: iterated value index. -- **n**: iteration count (zero-based). -- **src**: source array-like object. - -```javascript -function fcn( v, i ) { - return v * (i+1); -} - -var it = arrayview2iterator( [ 1, 2, 3, 4 ], fcn ); -// returns - -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 4 - -v = it.next().value; -// returns 9 - -// ... -``` - -To set the callback function execution context, provide a `thisArg`. - -```javascript -function fcn( v ) { - this.count += 1; - return v * 10.0; -} - -var ctx = { - 'count': 0 -}; - -var it = arrayview2iterator( [ 1, 2, 3, 4 ], fcn, ctx ); -// returns - -var v = it.next().value; -// returns 10.0 - -v = it.next().value; -// returns 20.0 - -v = it.next().value; -// returns 30.0 - -var count = ctx.count; -// returns 3 -``` - - - - - - - -
- -## Notes - -- If an environment supports `Symbol.iterator`, the returned iterator is iterable. -- If provided a generic `array`, the returned iterator does **not** ignore holes. To achieve greater performance for sparse arrays, use a custom iterator. -- A returned iterator does **not** copy a provided array-like `object`. To ensure iterable reproducibility, copy a provided array-like `object` **before** creating an iterator. Otherwise, any changes to the contents of an array-like `object` will be reflected in the returned iterator. -- In environments supporting `Symbol.iterator`, the function **explicitly** does **not** invoke an array's `@@iterator` method, regardless of whether this method is defined. To convert an array to an implementation defined iterator, invoke this method directly. -- The returned iterator supports array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]). - -
- - - - - -
- -## Examples - - - -```javascript -var Float64Array = require( '@stdlib/array/float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var arrayview2iterator = require( '@stdlib/array/to-view-iterator' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 100 ), randu ); - -// Create an iterator from an array view which scales iterated values: -var it = arrayview2iterator( arr, 40, 60, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/to-view-iterator/benchmark/benchmark.js b/to-view-iterator/benchmark/benchmark.js deleted file mode 100644 index 29f5eba2e..000000000 --- a/to-view-iterator/benchmark/benchmark.js +++ /dev/null @@ -1,109 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); -var isIteratorLike = require( '@stdlib/assert/is-iterator-like' ); -var pkg = require( './../package.json' ).name; -var arrayview2iterator = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var iter; - var i; - - values = [ 1, 2, 3, 4 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - values[ 0 ] = i; - iter = arrayview2iterator( values ); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isIteratorLike( iter ) ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - values.length = b.iterations; - - iter = arrayview2iterator( values ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( z !== void 0 ) { - b.fail( 'should be undefined' ); - } - } - b.toc(); - if ( z !== void 0 ) { - b.fail( 'should be undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::iteration,map', function benchmark( b ) { - var values; - var iter; - var z; - var i; - - values = []; - values.length = b.iterations; - - iter = arrayview2iterator( values, transform ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - z = iter.next().value; - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( isnan( z ) ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return i; - } -}); diff --git a/to-view-iterator/docs/repl.txt b/to-view-iterator/docs/repl.txt deleted file mode 100644 index 8271875e7..000000000 --- a/to-view-iterator/docs/repl.txt +++ /dev/null @@ -1,63 +0,0 @@ - -{{alias}}( src[, begin[, end]][, mapFcn[, thisArg]] ) - Returns an iterator which iterates over the elements of an array-like object - view. - - When invoked, an input function is provided four arguments: - - - value: iterated value. - - index: iterated value index. - - n: iteration count (zero-based). - - src: source array-like object. - - If an environment supports Symbol.iterator, the returned iterator is - iterable. - - If an environment supports Symbol.iterator, the function explicitly does not - invoke an array's `@@iterator` method, regardless of whether this method is - defined. To convert an array to an implementation defined iterator, invoke - this method directly. - - Parameters - ---------- - src: ArrayLikeObject - Array-like object from which to create the iterator. - - begin: integer (optional) - Starting index (inclusive). When negative, determined relative to the - last element. Default: 0. - - end: integer (optional) - Ending index (non-inclusive). When negative, determined relative to the - last element. Default: src.length. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - iterator: Object - Iterator. - - iterator.next(): Function - Returns an iterator protocol-compliant object containing the next - iterated value (if one exists) and a boolean flag indicating whether the - iterator is finished. - - iterator.return( [value] ): Function - Finishes an iterator and returns a provided value. - - Examples - -------- - > var it = {{alias}}( [ 1, 2, 3, 4 ], 1, 3 ); - > var v = it.next().value - 2 - > v = it.next().value - 3 - - See Also - -------- - diff --git a/to-view-iterator/docs/types/index.d.ts b/to-view-iterator/docs/types/index.d.ts deleted file mode 100644 index ed9929a9f..000000000 --- a/to-view-iterator/docs/types/index.d.ts +++ /dev/null @@ -1,149 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { ArrayLike } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type Ternary = ( value: any, index: number, src: ArrayLike ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @param src - source array-like object -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary | Ternary; - -/** -* Returns an iterator which iterates over each element in an array-like object view. -* -* @param src - input value -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns iterator -* -* @example -* function fcn( v ) { -* return v * 10.0; -* } -* -* var iter = arrayview2iterator( [ 1, 2, 3, 4 ], fcn ); -* -* var v = iter.next().value; -* // returns 10 -* -* v = iter.next().value; -* // returns 20 -* -* var bool = iter.next().done; -* // returns false -*/ -declare function arrayview2iterator( src: ArrayLike, mapFcn?: MapFunction, thisArg?: any ): Iterator; - -/** -* Returns an iterator which iterates over each element in an array-like object view. -* -* @param src - input value -* @param begin - starting index (inclusive) (default: 0) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns iterator -* -* @example -* var iter = arrayview2iterator( [ 1, 2, 3, 4 ], 1 ); -* -* var v = iter.next().value; -* // returns 2 -* -* v = iter.next().value; -* // returns 3 -* -* var bool = iter.next().done; -* // returns false -*/ -declare function arrayview2iterator( src: ArrayLike, begin: number, mapFcn?: MapFunction, thisArg?: any ): Iterator; - -/** -* Returns an iterator which iterates over each element in an array-like object view. -* -* @param src - input value -* @param begin - starting index (inclusive) (default: 0) -* @param end - ending index (non-inclusive) (default: src.length) -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns iterator -* -* @example -* var iter = arrayview2iterator( [ 1, 2, 3, 4 ], 1, 3 ); -* -* var v = iter.next().value; -* // returns 2 -* -* v = iter.next().value; -* // returns 3 -* -* var bool = iter.next().done; -* // returns true -*/ -declare function arrayview2iterator( src: ArrayLike, begin: number, end: number, mapFcn?: MapFunction, thisArg?: any ): Iterator; - - -// EXPORTS // - -export = arrayview2iterator; diff --git a/to-view-iterator/docs/types/test.ts b/to-view-iterator/docs/types/test.ts deleted file mode 100644 index 1ee78dd45..000000000 --- a/to-view-iterator/docs/types/test.ts +++ /dev/null @@ -1,86 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arrayview2iterator = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - arrayview2iterator( [ 1, 2, 3, 4 ] ); // $ExpectType Iterator - arrayview2iterator( [ 1, 2, 3, 4 ], 1, 2, times10 ); // $ExpectType Iterator - arrayview2iterator( [ 1, 2, 3, 4 ], 1, 2, times10, {} ); // $ExpectType Iterator -} - -// The compiler throws an error if the function is provided a first argument which is not array-like... -{ - arrayview2iterator( 123 ); // $ExpectError - arrayview2iterator( true ); // $ExpectError - arrayview2iterator( false ); // $ExpectError - arrayview2iterator( {} ); // $ExpectError - arrayview2iterator( null ); // $ExpectError - arrayview2iterator( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number or function... -{ - arrayview2iterator( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], [] ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], {} ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], true ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], false ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not number or function... -{ - arrayview2iterator( [ 1, 2, 3, 4 ], 1, 'abc' ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 1, [] ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 1, {} ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 1, true ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 1, false ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 1, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a function... -{ - arrayview2iterator( [ 1, 2, 3, 4 ], 0, 2, 'abc' ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 0, 2, 123 ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 0, 2, [] ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 0, 2, {} ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 0, 2, true ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 0, 2, false ); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 0, 2, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - arrayview2iterator(); // $ExpectError - arrayview2iterator( [ 1, 2, 3, 4 ], 1, 2, times10, {}, 123 ); // $ExpectError -} diff --git a/to-view-iterator/examples/index.js b/to-view-iterator/examples/index.js deleted file mode 100644 index bdb667117..000000000 --- a/to-view-iterator/examples/index.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Float64Array = require( './../../float64' ); -var inmap = require( '@stdlib/utils/inmap' ); -var randu = require( '@stdlib/random/base/randu' ); -var arrayview2iterator = require( './../lib' ); - -function scale( v, i ) { - return v * (i+1); -} - -// Create an array filled with random numbers: -var arr = inmap( new Float64Array( 100 ), randu ); - -// Create an iterator from an array view which scales iterated values: -var it = arrayview2iterator( arr, 40, 60, scale ); - -// Perform manual iteration... -var v; -while ( true ) { - v = it.next(); - if ( v.done ) { - break; - } - console.log( v.value ); -} diff --git a/to-view-iterator/lib/index.js b/to-view-iterator/lib/index.js deleted file mode 100644 index 6c98dfdfd..000000000 --- a/to-view-iterator/lib/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create an iterator from an array-like object view. -* -* @module @stdlib/array/to-view-iterator -* -* @example -* var arrayview2iterator = require( '@stdlib/array/to-view-iterator' ); -* -* var iter = arrayview2iterator( [ 1, 2, 3, 4 ], 1, 3 ); -* -* var v = iter.next().value; -* // returns 2 -* -* v = iter.next().value; -* // returns 3 -* -* var bool = iter.next().done; -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/to-view-iterator/lib/main.js b/to-view-iterator/lib/main.js deleted file mode 100644 index a7b042e0c..000000000 --- a/to-view-iterator/lib/main.js +++ /dev/null @@ -1,231 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var isCollection = require( '@stdlib/assert/is-collection' ); -var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; -var isAccessorArray = require( './../../base/assert/is-accessor-array' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var accessorGetter = require( './../../base/accessor-getter' ); -var getter = require( './../../base/getter' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Returns an iterator which iterates over each element in an array-like object view. -* -* @param {Collection} src - input value -* @param {integer} [begin=0] - starting index (inclusive) -* @param {integer} [end=src.length] - ending index (non-inclusive) -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an array-like object -* @throws {TypeError} second argument must be either an integer (starting index) or a function -* @throws {TypeError} third argument must be either an integer (ending index) or a function -* @throws {TypeError} fourth argument must be a function -* @returns {Iterator} iterator -* -* @example -* var iter = arrayview2iterator( [ 1, 2, 3, 4 ], 1, 3 ); -* -* var v = iter.next().value; -* // returns 2 -* -* v = iter.next().value; -* // returns 3 -* -* var bool = iter.next().done; -* // returns true -*/ -function arrayview2iterator( src ) { - var thisArg; - var begin; - var nargs; - var iter; - var FLG; - var fcn; - var end; - var get; - var dt; - var i; - if ( !isCollection( src ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) ); - } - nargs = arguments.length; - if ( nargs === 1 ) { - begin = 0; - end = src.length; - } else if ( nargs === 2 ) { - if ( isFunction( arguments[ 1 ] ) ) { - begin = 0; - fcn = arguments[ 1 ]; - } else { - begin = arguments[ 1 ]; - } - end = src.length; - } else if ( nargs === 3 ) { - if ( isFunction( arguments[ 1 ] ) ) { - begin = 0; - end = src.length; - fcn = arguments[ 1 ]; - thisArg = arguments[ 2 ]; - } else if ( isFunction( arguments[ 2 ] ) ) { - begin = arguments[ 1 ]; - end = src.length; - fcn = arguments[ 2 ]; - } else { - begin = arguments[ 1 ]; - end = arguments[ 2 ]; - } - } else { // nargs >= 4 - begin = arguments[ 1 ]; - end = arguments[ 2 ]; - fcn = arguments[ 3 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 4 ]; - } - if ( !isInteger( begin ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be either an integer (starting index) or a function. Value: `%s`.', begin ) ); - } - if ( !isInteger( end ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be either an integer (ending index) or a function. Value: `%s`.', end ) ); - } - if ( end < 0 ) { - end = src.length + end; - if ( end < 0 ) { - end = 0; - } - } else if ( end > src.length ) { - end = src.length; - } - if ( begin < 0 ) { - begin = src.length + begin; - if ( begin < 0 ) { - begin = 0; - } - } - i = begin - 1; - - // Create an iterator protocol-compliant object: - iter = {}; - if ( fcn ) { - setReadOnly( iter, 'next', next1 ); - } else { - setReadOnly( iter, 'next', next2 ); - } - setReadOnly( iter, 'return', finish ); - - // If an environment supports `Symbol.iterator`, make the iterator iterable: - if ( iteratorSymbol ) { - setReadOnly( iter, iteratorSymbol, factory ); - } - // Resolve an accessor for retrieving array elements (e.g., to accommodate `Complex64Array`, etc): - dt = dtype( src ); - if ( isAccessorArray( src ) ) { - get = accessorGetter( dt ); - } else { - get = getter( dt ); - } - return iter; - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next1() { - i += 1; - if ( FLG || i >= end ) { - return { - 'done': true - }; - } - return { - 'value': fcn.call( thisArg, get( src, i ), i, i-begin, src ), - 'done': false - }; - } - - /** - * Returns an iterator protocol-compliant object containing the next iterated value. - * - * @private - * @returns {Object} iterator protocol-compliant object - */ - function next2() { - i += 1; - if ( FLG || i >= end ) { - return { - 'done': true - }; - } - return { - 'value': get( src, i ), - 'done': false - }; - } - - /** - * Finishes an iterator. - * - * @private - * @param {*} [value] - value to return - * @returns {Object} iterator protocol-compliant object - */ - function finish( value ) { - FLG = true; - if ( arguments.length ) { - return { - 'value': value, - 'done': true - }; - } - return { - 'done': true - }; - } - - /** - * Returns a new iterator. - * - * @private - * @returns {Iterator} iterator - */ - function factory() { - if ( fcn ) { - return arrayview2iterator( src, begin, end, fcn, thisArg ); - } - return arrayview2iterator( src, begin, end ); - } -} - - -// EXPORTS // - -module.exports = arrayview2iterator; diff --git a/to-view-iterator/package.json b/to-view-iterator/package.json deleted file mode 100644 index fe5cffa5a..000000000 --- a/to-view-iterator/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/array/to-view-iterator", - "version": "0.0.0", - "description": "Create an iterator from an array-like object 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", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "utils", - "util", - "utilities", - "utility", - "typed", - "array", - "arr", - "view", - "slice", - "typed-array", - "typed array", - "iterator", - "iterate", - "iteration", - "iter", - "to", - "convert" - ] -} diff --git a/to-view-iterator/test/test.js b/to-view-iterator/test/test.js deleted file mode 100644 index 74df8447c..000000000 --- a/to-view-iterator/test/test.js +++ /dev/null @@ -1,1490 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var iteratorSymbol = require( '@stdlib/symbol/iterator' ); -var noop = require( '@stdlib/utils/noop' ); -var arrayview2iterator = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arrayview2iterator, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iterator( value ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (begin)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iterator( value, 1 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (begin+callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iterator( value, 1, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (begin+end)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iterator( value, 1, 3 ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (begin+end+callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iterator( value, 1, 3, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a first argument which is not an array-like object (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iterator( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is neither an integer nor a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iterator( [ 1, 2, 3, 4 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not an integer (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iterator( [ 1, 2, 3, 4 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is neither an integer nor a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iterator( [ 1, 2, 3, 4 ], 1, value ); - }; - } -}); - -tape( 'the function throws an error if provided a third argument which is not an integer (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iterator( [ 1, 2, 3, 4 ], 1, value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a fourth argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - arrayview2iterator( [ 1, 2, 3, 4 ], 1, 3, value ); - }; - } -}); - -tape( 'the function returns an iterator protocol-compliant object', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iterator( values, 2 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < 2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin+end)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iterator( values, 1, 3 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < 2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin+end)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iterator( values, 1, 3000 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin<0)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iterator( values, -3 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin<0)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iterator( values, -300 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin<0+end)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iterator( values, -3, 3 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin+end<0)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iterator( values, 1, -1 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin+end<0)', function test( t ) { - var expected; - var actual; - var values; - var it; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'done': true - } - ]; - - it = arrayview2iterator( values, 0, -3000 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (begin<0+end<0)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - expected = [ - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iterator( values, -3, -1 ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object (array-like object)', function test( t ) { - var expected; - var actual; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - expected = [ - { - 'value': 1, - 'done': false - }, - { - 'value': 2, - 'done': false - }, - { - 'value': 3, - 'done': false - }, - { - 'value': 4, - 'done': false - }, - { - 'done': true - } - ]; - - it = arrayview2iterator( values ); - t.equal( it.next.length, 0, 'has zero arity' ); - - actual = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - actual.push( r ); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - actual.push( it.next() ); - - t.deepEqual( actual, expected, 'returns expected values' ); - t.end(); -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iterator( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (context)', function test( t ) { - var expected; - var values; - var ctx; - var it; - var r; - var i; - - ctx = { - 'count': 0 - }; - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iterator( values, scale, ctx ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.equal( ctx.count, values.length, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iterator( values, 1, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-1, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin<0)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iterator( values, -3, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-1; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-1, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin+end)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iterator( values, 1, 3, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-2, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin<0+end)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iterator( values, -3, 3, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-2, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin<0+end<0)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iterator( values, -3, -1, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-2, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (begin+end<0)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = [ 1, 2, 3, 4 ]; - - it = arrayview2iterator( values, 1, -1, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length-2; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length-2, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the function returns an iterator protocol-compliant object which supports invoking a provided function for each iterated value (array-like)', function test( t ) { - var expected; - var values; - var it; - var r; - var i; - - values = { - 'length': 4, - '0': 1, - '1': 2, - '2': 3, - '3': 4 - }; - - it = arrayview2iterator( values, scale ); - t.equal( it.next.length, 0, 'has zero arity' ); - - expected = []; - for ( i = 0; i < values.length; i++ ) { - r = it.next(); - t.equal( r.value, expected[ i ], 'returns expected value' ); - t.equal( typeof r.done, 'boolean', 'returns a boolean' ); - } - t.equal( expected.length, values.length, 'has expected length' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - v *= i + 1; - expected.push( v ); - return v; - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument)', function test( t ) { - var it; - var r; - - it = arrayview2iterator( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (no argument; callback)', function test( t ) { - var it; - var r; - - it = arrayview2iterator( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument)', function test( t ) { - var it; - var r; - - it = arrayview2iterator( [ 1, 2, 3, 4 ] ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned iterator has a `return` method for closing an iterator (argument; callback)', function test( t ) { - var it; - var r; - - it = arrayview2iterator( [ 1, 2, 3, 4 ], scale ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.next(); - t.equal( typeof r.value, 'number', 'returns a number' ); - t.equal( r.done, false, 'returns expected value' ); - - r = it.return( 'finished' ); - t.equal( r.value, 'finished', 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - r = it.next(); - t.equal( r.value, void 0, 'returns expected value' ); - t.equal( r.done, true, 'returns expected value' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable', function test( t ) { - var arrayview2iterator; - var values; - var it1; - var it2; - var i; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iterator( values ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (begin)', function test( t ) { - var arrayview2iterator; - var values; - var it1; - var it2; - var i; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iterator( values, 1 ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (begin+end)', function test( t ) { - var arrayview2iterator; - var values; - var it1; - var it2; - var i; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iterator( values, 1, 3 ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (callback)', function test( t ) { - var arrayview2iterator; - var values; - var it1; - var it2; - var i; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iterator( values, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (begin+callback)', function test( t ) { - var arrayview2iterator; - var values; - var it1; - var it2; - var i; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iterator( values, 1, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment supports `Symbol.iterator`, the returned iterator is iterable (begin+end+callback)', function test( t ) { - var arrayview2iterator; - var values; - var it1; - var it2; - var i; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' - }); - - values = [ 1, 2, 3, 4 ]; - - it1 = arrayview2iterator( values, 1, 3, scale ); - t.equal( typeof it1[ '__ITERATOR_SYMBOL__' ], 'function', 'has method' ); - t.equal( it1[ '__ITERATOR_SYMBOL__' ].length, 0, 'has zero arity' ); - - it2 = it1[ '__ITERATOR_SYMBOL__' ](); - t.equal( typeof it2, 'object', 'returns an object' ); - t.equal( typeof it2.next, 'function', 'has method' ); - t.equal( typeof it2.return, 'function', 'has method' ); - - for ( i = 0; i < values.length; i++ ) { - t.equal( it2.next().value, it1.next().value, 'returns expected value' ); - } - t.end(); - - function scale( v ) { - return v * 10.0; - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable"', function test( t ) { - var arrayview2iterator; - var it; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iterator( [ 1, 2, 3, 4 ] ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (begin)', function test( t ) { - var arrayview2iterator; - var it; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iterator( [ 1, 2, 3, 4 ], 1 ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (begin+end)', function test( t ) { - var arrayview2iterator; - var it; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iterator( [ 1, 2, 3, 4 ], 1, 3 ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (callback)', function test( t ) { - var arrayview2iterator; - var it; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iterator( [ 1, 2, 3, 4 ], scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (begin+callback)', function test( t ) { - var arrayview2iterator; - var it; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iterator( [ 1, 2, 3, 4 ], 1, scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'if an environment does not support `Symbol.iterator`, the returned iterator is not "iterable" (begin+end+callback)', function test( t ) { - var arrayview2iterator; - var it; - - arrayview2iterator = proxyquire( './../lib/main.js', { - '@stdlib/symbol/iterator': false - }); - - it = arrayview2iterator( [ 1, 2, 3, 4 ], 1, 3, scale ); - t.equal( it[ iteratorSymbol ], void 0, 'does not have property' ); - - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/typed-complex-ctors/README.md b/typed-complex-ctors/README.md deleted file mode 100644 index 989107722..000000000 --- a/typed-complex-ctors/README.md +++ /dev/null @@ -1,142 +0,0 @@ - - -# Constructors - -> Complex typed array constructors. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ctors = require( '@stdlib/array/typed-complex-ctors' ); -``` - -#### ctors( dtype ) - -Returns a complex typed array constructor for a specified data type. - -```javascript -var ctor = ctors( 'complex128' ); -// returns -``` - -The function returns constructors for the following data types: - -- `complex64`: single-precision floating-point complex numbers. -- `complex128`: double-precision floating-point complex numbers. - -If provided an unknown or unsupported data type, the function returns `null`. - -```javascript -var ctor = ctors( 'float64' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/typed-complex-dtypes' ); -var ctors = require( '@stdlib/array/typed-complex-ctors' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-complex-ctors/benchmark/benchmark.js b/typed-complex-ctors/benchmark/benchmark.js deleted file mode 100644 index 5492c41b9..000000000 --- a/typed-complex-ctors/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var dtypes = require( './../../typed-complex-dtypes' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var ctors = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var ctor; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ctor = ctors( DTYPES[ i%DTYPES.length ] ); - if ( typeof ctor !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( ctor ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-complex-ctors/docs/repl.txt b/typed-complex-ctors/docs/repl.txt deleted file mode 100644 index 26678259c..000000000 --- a/typed-complex-ctors/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( dtype ) - Returns a complex typed array constructor. - - The function returns constructors for the following data types: - - - complex64: single-precision floating-point complex numbers. - - complex128: double-precision floating-point complex numbers. - - Parameters - ---------- - dtype: string - Data type. - - Returns - ------- - out: Function|null - Complex typed array constructor. - - Examples - -------- - > var ctor = {{alias}}( 'complex64' ) - - > ctor = {{alias}}( 'float32' ) - null - - See Also - -------- - diff --git a/typed-complex-ctors/docs/types/index.d.ts b/typed-complex-ctors/docs/types/index.d.ts deleted file mode 100644 index 395627922..000000000 --- a/typed-complex-ctors/docs/types/index.d.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); - -/** -* Returns a `Complex128Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'complex128' ); -* // returns -*/ -declare function ctors( dtype: 'complex128' ): typeof Complex128Array; - -/** -* Returns a `Complex64Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'complex64' ); -* // returns -*/ -declare function ctors( dtype: 'complex64' ): typeof Complex64Array; - -/** -* Returns a complex typed array constructor. -* -* @param dtype - data type -* @returns constructor or null -* -* @example -* var ctor = ctors( 'complex128' ); -* // returns -* -* @example -* var ctor = ctors( 'float64' ); -* // returns null -*/ -declare function ctors( dtype: string ): Function | null; - - -// EXPORTS // - -export = ctors; diff --git a/typed-complex-ctors/docs/types/test.ts b/typed-complex-ctors/docs/types/test.ts deleted file mode 100644 index 833338c18..000000000 --- a/typed-complex-ctors/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import ctors = require( './index' ); - - -// TESTS // - -// The function returns a function or null.. -{ - ctors( 'complex128' ); // $ExpectType Complex128ArrayConstructor - ctors( 'complex64' ); // $ExpectType Complex64ArrayConstructor - ctors( 'float' ); // $ExpectType Function | null -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ctors(); // $ExpectError - ctors( 'complex128', 3 ); // $ExpectError -} diff --git a/typed-complex-ctors/examples/index.js b/typed-complex-ctors/examples/index.js deleted file mode 100644 index c72b9537d..000000000 --- a/typed-complex-ctors/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../typed-complex-dtypes' ); -var ctors = require( './../lib' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} diff --git a/typed-complex-ctors/lib/ctors.js b/typed-complex-ctors/lib/ctors.js deleted file mode 100644 index 7e99df7a6..000000000 --- a/typed-complex-ctors/lib/ctors.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); - - -// MAIN // - -// Mapping from data types to constructors... -var ctors = { - 'complex128': Complex128Array, - 'complex64': Complex64Array -}; - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-complex-ctors/lib/index.js b/typed-complex-ctors/lib/index.js deleted file mode 100644 index 72fa15b61..000000000 --- a/typed-complex-ctors/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Complex typed array constructors. -* -* @module @stdlib/array/typed-complex-ctors -* -* @example -* var ctors = require( '@stdlib/array/typed-complex-ctors' ); -* -* var ctor = ctors( 'complex128' ); -* // returns -* -* ctor = ctors( 'float64' ); -* // returns null -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-complex-ctors/lib/main.js b/typed-complex-ctors/lib/main.js deleted file mode 100644 index 83f8cc723..000000000 --- a/typed-complex-ctors/lib/main.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var table = require( './ctors.js' ); - - -// MAIN // - -/** -* Returns a complex typed array constructor. -* -* @param {string} dtype - data type -* @returns {(Function|null)} constructor or null -* -* @example -* var ctor = ctors( 'complex128' ); -* // returns -* -* @example -* var ctor = ctors( 'float64' ); -* // returns null -*/ -function ctors( dtype ) { - return table[ dtype ] || null; -} - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-complex-ctors/package.json b/typed-complex-ctors/package.json deleted file mode 100644 index 128401b9f..000000000 --- a/typed-complex-ctors/package.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "name": "@stdlib/array/typed-complex-ctors", - "version": "0.0.0", - "description": "Complex typed array constructors.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "typed array", - "typed-array", - "typed", - "dtypes", - "dtype", - "data", - "type", - "complex", - "cmplx", - "structure", - "constructors", - "constructor", - "ctors", - "ctor", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-complex-ctors/test/test.js b/typed-complex-ctors/test/test.js deleted file mode 100644 index ee76e0bf1..000000000 --- a/typed-complex-ctors/test/test.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-complex-dtypes' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ctors = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctors, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns complex typed array constructors', function test( t ) { - var expected; - var dtypes; - var ctor; - var i; - - dtypes = [ - 'complex128', - 'complex64' - ]; - expected = [ - Complex128Array, - Complex64Array - ]; - for ( i = 0; i < dtypes.length; i++ ) { - ctor = ctors( dtypes[ i ] ); - t.strictEqual( ctor, expected[ i ], 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'the function returns a constructor for each supported complex typed array data type', function test( t ) { - var DTYPES; - var ctor; - var i; - - DTYPES = dtypes(); - for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - - // Note: this is a weak test for a "constructor" - t.strictEqual( isFunction( ctor ), true, 'returns a function for ' + DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'binary', - 'buffer', - 'buf', - 'generic', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits', - 'float64', - 'float32', - 'uint32', - 'int32', - 'uint16', - 'int16', - 'uint8', - 'uint8c', - 'int8' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( ctors( dtypes[i] ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/typed-complex-dtypes/README.md b/typed-complex-dtypes/README.md deleted file mode 100644 index e07d02cb0..000000000 --- a/typed-complex-dtypes/README.md +++ /dev/null @@ -1,145 +0,0 @@ - - -# Data Types - -> List of complex typed array data types. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var dtypes = require( '@stdlib/array/typed-complex-dtypes' ); -``` - -#### dtypes() - -Returns a list of complex typed array data types. - -```javascript -var out = dtypes(); -// e.g., returns [ 'complex64', ... ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( '@stdlib/array/typed-complex-dtypes' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'complex64' ); -// returns true - -bool = isdtype( 'complex128' ); -// returns true - -bool = isdtype( 'uint8' ); -// returns false - -bool = isdtype( 'beep' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-complex-dtypes/benchmark/benchmark.js b/typed-complex-dtypes/benchmark/benchmark.js deleted file mode 100644 index ebfc4ee6c..000000000 --- a/typed-complex-dtypes/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var pkg = require( './../package.json' ).name; -var dtypes = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dtypes(); - if ( out.length < 2 ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-complex-dtypes/docs/repl.txt b/typed-complex-dtypes/docs/repl.txt deleted file mode 100644 index 033d6f081..000000000 --- a/typed-complex-dtypes/docs/repl.txt +++ /dev/null @@ -1,17 +0,0 @@ - -{{alias}}() - Returns a list of complex typed array data types. - - Returns - ------- - out: Array - List of complex typed array data types. - - Examples - -------- - > var out = {{alias}}() - - - See Also - -------- - diff --git a/typed-complex-dtypes/docs/types/index.d.ts b/typed-complex-dtypes/docs/types/index.d.ts deleted file mode 100644 index 834a4d027..000000000 --- a/typed-complex-dtypes/docs/types/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { ComplexFloatingPointDataType as DataType } from '@stdlib/types/array'; - -/** -* Returns a list of complex typed array data types. -* -* @returns list of complex typed array data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'complex64', ... ] -*/ -declare function dtypes(): Array; - - -// EXPORTS // - -export = dtypes; diff --git a/typed-complex-dtypes/docs/types/test.ts b/typed-complex-dtypes/docs/types/test.ts deleted file mode 100644 index e88b6ef95..000000000 --- a/typed-complex-dtypes/docs/types/test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 dtypes = require( './index' ); - - -// TESTS // - -// The function returns a string array.. -{ - dtypes(); // $ExpectType ComplexFloatingPointDataType[] -} - -// The compiler throws an error if the function is provided arguments... -{ - dtypes( 1 ); // $ExpectError - dtypes( 1, 2 ); // $ExpectError -} diff --git a/typed-complex-dtypes/examples/index.js b/typed-complex-dtypes/examples/index.js deleted file mode 100644 index ce0f9de13..000000000 --- a/typed-complex-dtypes/examples/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( './../lib' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'complex64' ); -console.log( bool ); -// => true - -bool = isdtype( 'complex128' ); -console.log( bool ); -// => true - -bool = isdtype( 'uint16' ); -console.log( bool ); -// => false - -bool = isdtype( 'beep' ); -console.log( bool ); -// => false diff --git a/typed-complex-dtypes/lib/index.js b/typed-complex-dtypes/lib/index.js deleted file mode 100644 index 54e110f5e..000000000 --- a/typed-complex-dtypes/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Return a list of complex typed array data types. -* -* @module @stdlib/array/typed-complex-dtypes -* -* @example -* var dtypes = require( '@stdlib/array/typed-complex-dtypes' ); -* -* var list = dtypes(); -* // e.g., returns [ 'complex64', ... ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-complex-dtypes/lib/main.js b/typed-complex-dtypes/lib/main.js deleted file mode 100644 index 4ebd8cf60..000000000 --- a/typed-complex-dtypes/lib/main.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var dt = require( './../../dtypes' ); - - -// MAIN // - -/** -* Returns a list of complex typed array data types. -* -* @returns {StringArray} list of complex typed array data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'complex64', ... ] -*/ -function dtypes() { - return dt( 'complex_floating_point' ); -} - - -// EXPORTS // - -module.exports = dtypes; diff --git a/typed-complex-dtypes/package.json b/typed-complex-dtypes/package.json deleted file mode 100644 index 6676c7ce2..000000000 --- a/typed-complex-dtypes/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/array/typed-complex-dtypes", - "version": "0.0.0", - "description": "List of complex typed array data types.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "typed", - "array", - "complex", - "cmplx", - "dtypes", - "dtype", - "data", - "type", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-complex-dtypes/test/test.js b/typed-complex-dtypes/test/test.js deleted file mode 100644 index 04560b6a3..000000000 --- a/typed-complex-dtypes/test/test.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dt = require( './../../dtypes' ); -var dtypes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dtypes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a list of complex typed array data types', function test( t ) { - var expected; - var actual; - - expected = dt( 'complex_floating_point' ); - actual = dtypes(); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/typed-complex/README.md b/typed-complex/README.md deleted file mode 100644 index dfbd13e41..000000000 --- a/typed-complex/README.md +++ /dev/null @@ -1,221 +0,0 @@ - - -# Complex Typed Arrays - -> Create a complex number typed array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var complexarray = require( '@stdlib/array/typed-complex' ); -``` - -#### complexarray( \[dtype] ) - -Creates a complex number typed array having a specified data type `dtype`. - -```javascript -var arr = complexarray(); -// returns -``` - -The function recognizes the following data types: - -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers - -By default, the output complex number typed array data type is `complex128`. To specify an alternative data type, provide a `dtype` argument. - -```javascript -var arr = complexarray( 'complex64' ); -// returns -``` - -#### complexarray( length\[, dtype] ) - -Returns a complex number typed array having a specified `length`. - -```javascript -var arr1 = complexarray( 5 ); -// returns - -var arr2 = complexarray( 5, 'complex64' ); -// returns -``` - -#### complexarray( complexarray\[, dtype] ) - -Creates a complex number typed array from another complex number typed array. - -```javascript -var arr1 = complexarray( [ 5.0, -3.0, 2.0, 1.0 ] ); -// returns - -var arr2 = complexarray( arr1 ); -// returns - -var arr3 = complexarray( arr1, 'complex64' ); -// returns -``` - -#### complexarray( obj\[, dtype] ) - -Creates a complex number typed array from an array-like object or iterable. - -```javascript -var arr1 = complexarray( [ 0.5, 0.5, 0.5, 0.5 ] ); -// returns - -var arr2 = complexarray( [ 0.5, 0.5, 0.5, 0.5 ], 'complex64' ); -// returns -``` - -If a provided array-like object contains interleaved real and imaginary components, the array-like object must have a length which is a multiple of two. - -#### complexarray( buffer\[, byteOffset\[, length]]\[, dtype] ) - -Returns a complex number typed array view of an [`ArrayBuffer`][mdn-arraybuffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); -var buf = new ArrayBuffer( 64 ); - -var arr1 = complexarray( buf ); -// returns - -var arr2 = complexarray( buf, 'complex64' ); -// returns - -var arr3 = complexarray( buf, 32 ); -// returns - -var arr4 = complexarray( buf, 32, 'complex64' ); -// returns - -var arr5 = complexarray( buf, 32, 1 ); -// returns - -var arr6 = complexarray( buf, 24, 4, 'complex64' ); -// returns -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var gfillBy = require( '@stdlib/blas/ext/base/gfill-by' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var complexarray = require( '@stdlib/array/typed-complex' ); - -function rand() { - var re = discreteUniform( -10, 10 ); - var im = discreteUniform( -10, 10 ); - return new Complex128( re, im ); -} - -// Create a new complex number typed array: -var arr = complexarray( 100, 'complex128' ); - -// Fill the array with random complex numbers: -gfillBy( arr.length, arr, 1, rand ); - -// Reinterpret the complex number array as a `Float64Array`: -var view = reinterpret128( arr, 0 ); - -// View the results: -console.log( view ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-complex/benchmark/benchmark.js b/typed-complex/benchmark/benchmark.js deleted file mode 100644 index b711b5904..000000000 --- a/typed-complex/benchmark/benchmark.js +++ /dev/null @@ -1,83 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var complexarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = complexarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = complexarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = complexarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-complex/benchmark/benchmark.length.complex128.js b/typed-complex/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 7e28e4691..000000000 --- a/typed-complex/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var complexarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = complexarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/typed-complex/benchmark/benchmark.length.complex64.js b/typed-complex/benchmark/benchmark.length.complex64.js deleted file mode 100644 index f7713153c..000000000 --- a/typed-complex/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var complexarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = complexarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/typed-complex/docs/repl.txt b/typed-complex/docs/repl.txt deleted file mode 100644 index 06edbe778..000000000 --- a/typed-complex/docs/repl.txt +++ /dev/null @@ -1,137 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a complex typed array. - - The function supports the following data types: - - - complex128: double-precision complex floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - The default typed array data type is `complex128`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'complex128'. - - Returns - ------- - out: ComplexArray - A complex number typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'complex64' ) - - - -{{alias}}( length[, dtype] ) - Returns a complex number typed array having a specified length. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'complex128'. - - Returns - ------- - out: ComplexArray - A complex number typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - - > arr = {{alias}}( 5, 'complex64' ) - - - -{{alias}}( complexarray[, dtype] ) - Creates a complex number typed array from another complex number typed - array. - - Parameters - ---------- - complexarray: ComplexArray - Complex number typed array from which to generate another complex number - typed array. - - dtype: string (optional) - Data type. Default: 'complex128'. - - Returns - ------- - out: ComplexArray - A complex number typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'complex64' ) - - - -{{alias}}( obj[, dtype] ) - Creates a complex number typed array from an array-like object or iterable. - - If an array-like object contains interleaved real and imaginary components, - the array-like object must have a length which is a multiple of two. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate an array. - - dtype: string (optional) - Data type. Default: 'complex128'. - - Returns - ------- - out: ComplexArray - A complex number typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'complex64' ) - - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a complex number typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first array element. - Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'complex128'. - - Returns - ------- - out: ComplexArray - A complex number typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 64 ); - > var arr = {{alias}}( buf, 0, 8, 'complex64' ) - - - See Also - -------- - diff --git a/typed-complex/docs/types/index.d.ts b/typed-complex/docs/types/index.d.ts deleted file mode 100644 index f6c407df6..000000000 --- a/typed-complex/docs/types/index.d.ts +++ /dev/null @@ -1,171 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { ArrayLike, ComplexTypedArray, ComplexFloatingPointDataTypeMap as DataTypeMap } from '@stdlib/types/array'; -import ArrayBuffer = require( './../../../buffer' ); - -/** -* Creates a complex number typed array. -* -* @param dtype - data type (default: 'complex128') -* @returns complex number typed array -* -* @example -* var arr = complexarray(); -* // returns -* -* @example -* var arr = complexarray( 'complex64'); -* // returns -*/ -declare function complexarray( dtype?: T ): DataTypeMap[T]; - -/** -* Creates a complex number typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'complex128') -* @returns typed array -* -* @example -* var arr = complexarray( 2 ); -* // returns -* -* @example -* var arr = complexarray( 2, 'complex64' ); -* // returns -*/ -declare function complexarray( length: number, dtype?: T ): DataTypeMap[T]; - -/** -* Creates a complex number typed array. -* -* @param complexarray - complex number typed array from which to generate another complex number typed array -* @param dtype - data type (default: 'complex128') -* @returns complex number typed array -* -* @example -* var arr = complexarray( new Complex128Array( 2 ) ); -* // returns -* -* @example -* var arr = complexarray( new Complex128Array( 2 ), 'complex64' ); -* // returns -*/ -declare function complexarray( complexarray: ComplexTypedArray, dtype?: T ): DataTypeMap[T]; - -/** -* Creates a complex number typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'complex128') -* @throws array length must be a multiple of two -* @returns complex number typed array -* -* @example -* var arr = complexarray( [ 0.5, 0.5 ] ); -* // returns -* -* @example -* var arr = complexarray( [ 5, -3 ], 'complex64' ); -* // returns -*/ -declare function complexarray( obj: ArrayLike | Iterable, dtype?: T ): DataTypeMap[T]; - -/** -* Creates a complex number typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'complex128') -* @returns complex number typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf, 'complex64' ); -* // returns -*/ -declare function complexarray( buffer: ArrayBuffer, dtype?: T ): DataTypeMap[T]; - -/** -* Creates a complex number typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first array element (default: 0) -* @param dtype - data type (default: 'complex128') -* @returns complex number typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf, 16 ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf, 16, 'complex64' ); -* // returns -*/ -declare function complexarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): DataTypeMap[T]; - -/** -* Creates a complex number typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'complex128') -* @returns complex number typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 64 ); -* var arr = complexarray( buf, 16, 2 ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 64 ); -* var arr = complexarray( buf, 16, 2, 'complex64' ); -* // returns -*/ -declare function complexarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): DataTypeMap[T]; - - -// EXPORTS // - -export = complexarray; diff --git a/typed-complex/docs/types/test.ts b/typed-complex/docs/types/test.ts deleted file mode 100644 index 33077f3b1..000000000 --- a/typed-complex/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 complexarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - complexarray(); // $ExpectType Complex128Array - complexarray( 'complex64' ); // $ExpectType Complex64Array - complexarray( 10, 'complex64' ); // $ExpectType Complex64Array - complexarray( [ 1, 2, 3 ], 'complex128' ); // $ExpectType Complex128Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - complexarray( true ); // $ExpectError - complexarray( false ); // $ExpectError - complexarray( {} ); // $ExpectError - complexarray( null ); // $ExpectError - complexarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 64 ); - complexarray( buf, 16, 2, 'complex128', {} ); // $ExpectError -} diff --git a/typed-complex/examples/index.js b/typed-complex/examples/index.js deleted file mode 100644 index d812af158..000000000 --- a/typed-complex/examples/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 gfillBy = require( '@stdlib/blas/ext/base/gfill-by' ); -var Complex128 = require( '@stdlib/complex/float64/ctor' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var complexarray = require( './../lib' ); - -function rand() { - var re = discreteUniform( -10, 10 ); - var im = discreteUniform( -10, 10 ); - return new Complex128( re, im ); -} - -// Create a new complex number typed array: -var arr = complexarray( 100, 'complex128' ); - -// Fill the array with random complex numbers: -gfillBy( arr.length, arr, 1, rand ); - -// Reinterpret the complex number array as a `Float64Array`: -var view = reinterpret128( arr, 0 ); - -// View the results: -console.log( view ); diff --git a/typed-complex/lib/index.js b/typed-complex/lib/index.js deleted file mode 100644 index 0255ea944..000000000 --- a/typed-complex/lib/index.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a complex number typed array. -* -* @module @stdlib/array/typed-complex -* -* @example -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var arr = complexarray(); -* // returns -* -* @example -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var arr = complexarray( 2 ); -* // returns -* -* @example -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var arr = complexarray( 2, 'complex64' ); -* // returns -* -* @example -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var arr = complexarray( [ 0.5, 0.5 ] ); -* // returns -* -* @example -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var arr = complexarray( [ 5.0, -3.0 ], 'complex64' ); -* // returns -* -* @example -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var arr1 = complexarray( [ 5.0, 3.0 ], 'complex64' ); -* var arr2 = complexarray( arr1 ); -* // returns -* -* @example -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var arr1 = complexarray( [ 5.0, 3.0 ], 'complex128' ); -* var arr2 = complexarray( arr1, 'complex64' ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf, 'complex64' ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf, 16 ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf, 16, 'complex64' ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var buf = new ArrayBuffer( 64 ); -* var arr = complexarray( buf, 16, 2 ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var complexarray = require( '@stdlib/array/typed-complex' ); -* -* var buf = new ArrayBuffer( 64 ); -* var arr = complexarray( buf, 16, 2, 'complex64' ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-complex/lib/main.js b/typed-complex/lib/main.js deleted file mode 100644 index 8603b9d3a..000000000 --- a/typed-complex/lib/main.js +++ /dev/null @@ -1,149 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var ctors = require( './../../typed-complex-ctors' ); -var defaults = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.complex_floating_point' ); - - -// MAIN // - -/** -* Creates a complex number typed array. -* -* @param {(NonNegativeInteger|ComplexArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="complex128"] - data type -* @throws {TypeError} must provide a recognized data type -* @returns {ComplexArray} typed array -* -* @example -* var arr = complexarray(); -* // returns -* -* @example -* var arr = complexarray( 2 ); -* // returns -* -* @example -* var arr = complexarray( 2, 'complex64' ); -* // returns -* -* @example -* var arr = complexarray( [ 0.5, 0.5 ] ); -* // returns -* -* @example -* var arr = complexarray( [ 5.0, -3.0 ], 'complex64' ); -* // returns -* -* @example -* var arr1 = complexarray( [ 5.0, 3.0 ], 'complex64' ); -* var arr2 = complexarray( arr1 ); -* // returns -* -* @example -* var arr1 = complexarray( [ 5.0, 3.0 ], 'complex128' ); -* var arr2 = complexarray( arr1, 'complex64' ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf, 'complex64' ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf, 16 ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = complexarray( buf, 16, 'complex64' ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 64 ); -* var arr = complexarray( buf, 16, 2 ); -* // returns -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 64 ); -* var arr = complexarray( buf, 16, 2, 'complex64' ); -* // returns -*/ -function complexarray() { - var nargs; - var dtype; - var ctor; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - return new ctor( arguments[0] ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = complexarray; diff --git a/typed-complex/package.json b/typed-complex/package.json deleted file mode 100644 index 0b889539f..000000000 --- a/typed-complex/package.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "name": "@stdlib/array/typed-complex", - "version": "0.0.0", - "description": "Create a complex number typed array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "complex64array", - "complex128array", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "complex", - "cmplx" - ] -} diff --git a/typed-complex/test/test.js b/typed-complex/test/test.js deleted file mode 100644 index d52419a62..000000000 --- a/typed-complex/test/test.js +++ /dev/null @@ -1,603 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var Float64Array = require( './../../float64' ); -var ArrayBuffer = require( './../../buffer' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var complexarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof complexarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'complexarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - complexarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'complexarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - complexarray( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'complexarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - complexarray( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (complex typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'complexarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - complexarray( new Complex64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'complexarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - complexarray( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'complexarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - complexarray( new ArrayBuffer( 32 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'complexarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - complexarray( new ArrayBuffer( 32 ), 0, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'complexarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - complexarray( new ArrayBuffer( 32 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a complex number typed array (default)', function test( t ) { - var arr = complexarray(); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex128)', function test( t ) { - var arr = complexarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex64)', function test( t ) { - var arr = complexarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (default, length)', function test( t ) { - var arr = complexarray( 10 ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex128, length)', function test( t ) { - var arr = complexarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex64, length)', function test( t ) { - var arr = complexarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (default, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = complexarray( arr ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = complexarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = complexarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a complex number typed array (default, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = complexarray( arr ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = complexarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = complexarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a complex number typed array (default, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = complexarray( arr ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = complexarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = complexarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a complex number typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = complexarray( buf ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex128, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = complexarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = complexarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 64 ); - var out = complexarray( buf, 16 ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 64 ); - var out = complexarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = complexarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 64 ); - var out = complexarray( buf, 16, 2 ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 64 ); - var out = complexarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a complex number typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = complexarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.end(); -}); diff --git a/typed-ctors/README.md b/typed-ctors/README.md deleted file mode 100644 index a867b8af6..000000000 --- a/typed-ctors/README.md +++ /dev/null @@ -1,146 +0,0 @@ - - -# Constructors - -> Typed array constructors. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ctors = require( '@stdlib/array/typed-ctors' ); -``` - -#### ctors( dtype ) - -Returns a typed array constructor for a specified data type. - -```javascript -var ctor = ctors( 'float64' ); -// returns -``` - -The function returns constructors for the following data types: - -- `float32`: single-precision floating-point numbers. -- `float64`: double-precision floating-point numbers. -- `complex64`: single-precision complex floating-point numbers. -- `complex128`: double-precision complex floating-point numbers. -- `bool`: boolean values. -- `int16`: signed 16-bit integers. -- `int32`: signed 32-bit integers. -- `int8`: signed 8-bit integers. -- `uint16`: unsigned 16-bit integers. -- `uint32`: unsigned 32-bit integers. -- `uint8`: unsigned 8-bit integers. -- `uint8c`: unsigned clamped 8-bit integers. - -If provided an unknown or unsupported data type, the function returns `null`. - -```javascript -var ctor = ctors( 'float' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/typed-dtypes' ); -var ctors = require( '@stdlib/array/typed-ctors' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-ctors/benchmark/benchmark.js b/typed-ctors/benchmark/benchmark.js deleted file mode 100644 index 9e0dd2263..000000000 --- a/typed-ctors/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var dtypes = require( './../../typed-dtypes' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var ctors = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var ctor; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ctor = ctors( DTYPES[ i%DTYPES.length ] ); - if ( typeof ctor !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( ctor ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-ctors/docs/repl.txt b/typed-ctors/docs/repl.txt deleted file mode 100644 index e7a9fcc59..000000000 --- a/typed-ctors/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( dtype ) - Returns a typed array constructor. - - The function returns constructors for the following data types: - - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - bool: boolean values. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - Returns - ------- - out: Function|null - Typed array constructor. - - Examples - -------- - > var ctor = {{alias}}( 'float64' ) - - > ctor = {{alias}}( 'float' ) - null - - See Also - -------- - diff --git a/typed-ctors/docs/types/index.d.ts b/typed-ctors/docs/types/index.d.ts deleted file mode 100644 index e798a0f8c..000000000 --- a/typed-ctors/docs/types/index.d.ts +++ /dev/null @@ -1,188 +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. -*/ - -// TypeScript Version: 4.1 - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import BooleanArray = require( './../../../bool' ); - -/** -* Returns a `Float64Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -*/ -declare function ctors( dtype: 'float64' ): typeof Float64Array; - -/** -* Returns a `Float32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'float32' ); -* // returns -*/ -declare function ctors( dtype: 'float32' ): typeof Float32Array; - -/** -* Returns a `Complex128Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'complex128' ); -* // returns -*/ -declare function ctors( dtype: 'complex128' ): typeof Complex128Array; - -/** -* Returns a `Complex64Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'complex64' ); -* // returns -*/ -declare function ctors( dtype: 'complex64' ): typeof Complex64Array; - -/** -* Returns a `BooleanArray` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'bool' ); -* // returns -*/ -declare function ctors( dtype: 'bool' ): typeof BooleanArray; - -/** -* Returns an `Int32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int32' ); -* // returns -*/ -declare function ctors( dtype: 'int32' ): typeof Int32Array; - -/** -* Returns an `Int16Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int16' ); -* // returns -*/ -declare function ctors( dtype: 'int16' ): typeof Int16Array; - -/** -* Returns an `Int8Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int8' ); -* // returns -*/ -declare function ctors( dtype: 'int8' ): typeof Int8Array; - -/** -* Returns a `Uint32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint32' ); -* // returns -*/ -declare function ctors( dtype: 'uint32' ): typeof Uint32Array; - -/** -* Returns a `Uint16Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint16' ); -* // returns -*/ -declare function ctors( dtype: 'uint16' ): typeof Uint16Array; - -/** -* Returns a `Uint8Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint8' ); -* // returns -*/ -declare function ctors( dtype: 'uint8' ): typeof Uint8Array; - -/** -* Returns a `Uint8ClampedArray` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint8c' ); -* // returns -*/ -declare function ctors( dtype: 'uint8c' ): typeof Uint8ClampedArray; - -/** -* Returns a typed array constructor. -* -* @param dtype - data type -* @returns constructor or null -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -* -* @example -* var ctor = ctors( 'float' ); -* // returns null -*/ -declare function ctors( dtype: string ): Function | null; - - -// EXPORTS // - -export = ctors; diff --git a/typed-ctors/docs/types/test.ts b/typed-ctors/docs/types/test.ts deleted file mode 100644 index d96259b72..000000000 --- a/typed-ctors/docs/types/test.ts +++ /dev/null @@ -1,45 +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. -*/ - -import ctors = require( './index' ); - - -// TESTS // - -// The function returns a function or null.. -{ - ctors( 'float64' ); // $ExpectType Float64ArrayConstructor - ctors( 'float32' ); // $ExpectType Float32ArrayConstructor - ctors( 'complex128' ); // $ExpectType Complex128ArrayConstructor - ctors( 'complex64' ); // $ExpectType Complex64ArrayConstructor - ctors( 'bool' ); // $ExpectType BooleanArrayConstructor - ctors( 'int32' ); // $ExpectType Int32ArrayConstructor - ctors( 'int16' ); // $ExpectType Int16ArrayConstructor - ctors( 'int8' ); // $ExpectType Int8ArrayConstructor - ctors( 'uint32' ); // $ExpectType Uint32ArrayConstructor - ctors( 'uint16' ); // $ExpectType Uint16ArrayConstructor - ctors( 'uint8' ); // $ExpectType Uint8ArrayConstructor - ctors( 'uint8c' ); // $ExpectType Uint8ClampedArrayConstructor - ctors( 'float' ); // $ExpectType Function | null -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ctors(); // $ExpectError - ctors( 'int32', 3 ); // $ExpectError -} diff --git a/typed-ctors/examples/index.js b/typed-ctors/examples/index.js deleted file mode 100644 index 20cfa25aa..000000000 --- a/typed-ctors/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../typed-dtypes' ); -var ctors = require( './../lib' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} diff --git a/typed-ctors/lib/ctors.js b/typed-ctors/lib/ctors.js deleted file mode 100644 index 83bb1429f..000000000 --- a/typed-ctors/lib/ctors.js +++ /dev/null @@ -1,58 +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. -*/ - -'use strict'; - -// MODULES // - -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); - - -// MAIN // - -// Mapping from data types to constructors... -var ctors = { - 'float64': Float64Array, - 'float32': Float32Array, - 'int16': Int16Array, - 'int32': Int32Array, - 'int8': Int8Array, - 'uint16': Uint16Array, - 'uint32': Uint32Array, - 'uint8': Uint8Array, - 'uint8c': Uint8ClampedArray, - 'complex64': Complex64Array, - 'complex128': Complex128Array, - 'bool': BooleanArray -}; - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-ctors/lib/index.js b/typed-ctors/lib/index.js deleted file mode 100644 index e26c8c4db..000000000 --- a/typed-ctors/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructors. -* -* @module @stdlib/array/typed-ctors -* -* @example -* var ctors = require( '@stdlib/array/typed-ctors' ); -* -* var ctor = ctors( 'float64' ); -* // returns -* -* ctor = ctors( 'int' ); -* // returns null -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-ctors/lib/main.js b/typed-ctors/lib/main.js deleted file mode 100644 index d045f901b..000000000 --- a/typed-ctors/lib/main.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var table = require( './ctors.js' ); - - -// MAIN // - -/** -* Returns a typed array constructor. -* -* @param {string} dtype - data type -* @returns {(Function|null)} constructor or null -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -* -* @example -* var ctor = ctors( 'float' ); -* // returns null -*/ -function ctors( dtype ) { - return table[ dtype ] || null; -} - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-ctors/package.json b/typed-ctors/package.json deleted file mode 100644 index 1ce679c27..000000000 --- a/typed-ctors/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@stdlib/array/typed-ctors", - "version": "0.0.0", - "description": "Typed array constructors.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "typed array", - "typed-array", - "typed", - "dtypes", - "dtype", - "data", - "type", - "structure", - "constructors", - "constructor", - "ctors", - "ctor", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-ctors/test/test.js b/typed-ctors/test/test.js deleted file mode 100644 index d0098d936..000000000 --- a/typed-ctors/test/test.js +++ /dev/null @@ -1,128 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var dtypes = require( './../../typed-dtypes' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var BooleanArray = require( './../../bool' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ctors = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctors, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns typed array constructors', function test( t ) { - var expected; - var dtypes; - var ctor; - var i; - - dtypes = [ - 'float64', - 'float32', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c', - 'complex64', - 'complex128', - 'bool' - ]; - expected = [ - Float64Array, - Float32Array, - Int16Array, - Int32Array, - Int8Array, - Uint16Array, - Uint32Array, - Uint8Array, - Uint8ClampedArray, - Complex64Array, - Complex128Array, - BooleanArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - ctor = ctors( dtypes[ i ] ); - t.strictEqual( ctor, expected[ i ], 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'the function returns a constructor for each supported typed array data type', function test( t ) { - var DTYPES; - var ctor; - var i; - - DTYPES = dtypes(); - for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - - // Note: this is a weak test for a "constructor" - t.strictEqual( isFunction( ctor ), true, 'returns a function for ' + DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'binary', - 'buffer', - 'buf', - 'generic', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( ctors( dtypes[i] ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/typed-dtypes/README.md b/typed-dtypes/README.md deleted file mode 100644 index ddf28f28a..000000000 --- a/typed-dtypes/README.md +++ /dev/null @@ -1,139 +0,0 @@ - - -# Data Types - -> List of typed array data types. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var dtypes = require( '@stdlib/array/typed-dtypes' ); -``` - -#### dtypes() - -Returns a list of typed array data types. - -```javascript -var out = dtypes(); -// e.g., returns [ 'float32', ... ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( '@stdlib/array/typed-dtypes' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'float64' ); -// returns true - -bool = isdtype( 'int16' ); -// returns true - -bool = isdtype( 'uint8' ); -// returns true - -bool = isdtype( 'beep' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-dtypes/benchmark/benchmark.js b/typed-dtypes/benchmark/benchmark.js deleted file mode 100644 index 331cee048..000000000 --- a/typed-dtypes/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var pkg = require( './../package.json' ).name; -var dtypes = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dtypes(); - if ( out.length < 9 ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-dtypes/docs/repl.txt b/typed-dtypes/docs/repl.txt deleted file mode 100644 index c53b7ea24..000000000 --- a/typed-dtypes/docs/repl.txt +++ /dev/null @@ -1,17 +0,0 @@ - -{{alias}}() - Returns a list of typed array data types. - - Returns - ------- - out: Array - List of typed array data types. - - Examples - -------- - > var out = {{alias}}() - - - See Also - -------- - diff --git a/typed-dtypes/docs/types/index.d.ts b/typed-dtypes/docs/types/index.d.ts deleted file mode 100644 index a42666ea0..000000000 --- a/typed-dtypes/docs/types/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedDataType as DataType } from '@stdlib/types/array'; - -/** -* Returns a list of typed array data types. -* -* @returns list of typed array data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'float32', ... ] -*/ -declare function dtypes(): Array; - - -// EXPORTS // - -export = dtypes; diff --git a/typed-dtypes/docs/types/test.ts b/typed-dtypes/docs/types/test.ts deleted file mode 100644 index 873807c7c..000000000 --- a/typed-dtypes/docs/types/test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 dtypes = require( './index' ); - - -// TESTS // - -// The function returns a string array.. -{ - dtypes(); // $ExpectType TypedDataType[] -} - -// The compiler throws an error if the function is provided arguments... -{ - dtypes( 1 ); // $ExpectError - dtypes( 1, 2 ); // $ExpectError -} diff --git a/typed-dtypes/examples/index.js b/typed-dtypes/examples/index.js deleted file mode 100644 index dffc96660..000000000 --- a/typed-dtypes/examples/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( './../lib' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'float64' ); -console.log( bool ); -// => true - -bool = isdtype( 'int8' ); -console.log( bool ); -// => true - -bool = isdtype( 'uint16' ); -console.log( bool ); -// => true - -bool = isdtype( 'beep' ); -console.log( bool ); -// => false diff --git a/typed-dtypes/lib/index.js b/typed-dtypes/lib/index.js deleted file mode 100644 index ff86c9299..000000000 --- a/typed-dtypes/lib/index.js +++ /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. -*/ - -'use strict'; - -/** -* Return a list of typed array data types. -* -* @module @stdlib/array/typed-dtypes -* -* @example -* var dtypes = require( '@stdlib/array/typed-dtypes' ); -* -* var list = dtypes(); -* // e.g., returns [ 'float32', ... ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-dtypes/lib/main.js b/typed-dtypes/lib/main.js deleted file mode 100644 index f10c1a6c6..000000000 --- a/typed-dtypes/lib/main.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var dt = require( './../../dtypes' ); - - -// MAIN // - -/** -* Returns a list of typed array data types. -* -* @returns {StringArray} list of typed array data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'float32', ... ] -*/ -function dtypes() { - return dt( 'typed' ); -} - - -// EXPORTS // - -module.exports = dtypes; diff --git a/typed-dtypes/package.json b/typed-dtypes/package.json deleted file mode 100644 index e54c50f12..000000000 --- a/typed-dtypes/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/typed-dtypes", - "version": "0.0.0", - "description": "List of typed array data types.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "typed", - "array", - "dtypes", - "dtype", - "data", - "type", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-dtypes/test/test.js b/typed-dtypes/test/test.js deleted file mode 100644 index 4b79abc8c..000000000 --- a/typed-dtypes/test/test.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dt = require( './../../dtypes' ); -var dtypes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dtypes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a list of typed array data types', function test( t ) { - var expected; - var actual; - - expected = dt( 'typed' ); - actual = dtypes(); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/typed-float-ctors/README.md b/typed-float-ctors/README.md deleted file mode 100644 index 66bf3e252..000000000 --- a/typed-float-ctors/README.md +++ /dev/null @@ -1,126 +0,0 @@ - - -# Constructors - -> Floating-point typed array constructors. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ctors = require( '@stdlib/array/typed-float-ctors' ); -``` - -#### ctors( dtype ) - -Returns a floating-point typed array constructor for a specified data type. - -```javascript -var ctor = ctors( 'float64' ); -// returns -``` - -The function returns constructors for the following data types: - -- `float32`: single-precision floating-point numbers. -- `float64`: double-precision floating-point numbers. -- `complex64`: single-precision complex floating-point numbers. -- `complex128`: double-precision complex floating-point numbers. - -If provided an unknown or unsupported data type, the function returns `null`. - -```javascript -var ctor = ctors( 'float' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/typed-float-dtypes' ); -var ctors = require( '@stdlib/array/typed-float-ctors' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-float-ctors/benchmark/benchmark.js b/typed-float-ctors/benchmark/benchmark.js deleted file mode 100644 index cb2d90bd3..000000000 --- a/typed-float-ctors/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-float-dtypes' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var ctors = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var ctor; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ctor = ctors( DTYPES[ i%DTYPES.length ] ); - if ( typeof ctor !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( ctor ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-float-ctors/docs/repl.txt b/typed-float-ctors/docs/repl.txt deleted file mode 100644 index b80331b83..000000000 --- a/typed-float-ctors/docs/repl.txt +++ /dev/null @@ -1,31 +0,0 @@ - -{{alias}}( dtype ) - Returns a floating-point typed array constructor. - - The function returns constructors for the following data types: - - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - Parameters - ---------- - dtype: string - Data type. - - Returns - ------- - out: Function|null - Typed array constructor. - - Examples - -------- - > var ctor = {{alias}}( 'float64' ) - - > ctor = {{alias}}( 'float' ) - null - - See Also - -------- - diff --git a/typed-float-ctors/docs/types/index.d.ts b/typed-float-ctors/docs/types/index.d.ts deleted file mode 100644 index 9b5e7992d..000000000 --- a/typed-float-ctors/docs/types/index.d.ts +++ /dev/null @@ -1,91 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); - -/** -* Returns a `Float64Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -*/ -declare function ctors( dtype: 'float64' ): typeof Float64Array; - -/** -* Returns a `Float32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'float32' ); -* // returns -*/ -declare function ctors( dtype: 'float32' ): typeof Float32Array; - -/** -* Returns a `Complex128Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'complex128' ); -* // returns -*/ -declare function ctors( dtype: 'complex128' ): typeof Complex128Array; - -/** -* Returns a `Complex64Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'complex64' ); -* // returns -*/ -declare function ctors( dtype: 'complex64' ): typeof Complex64Array; - -/** -* Returns a floating-point typed array constructor. -* -* @param dtype - data type -* @returns constructor or null -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -* -* @example -* var ctor = ctors( 'float' ); -* // returns null -*/ -declare function ctors( dtype: string ): Function | null; - - -// EXPORTS // - -export = ctors; diff --git a/typed-float-ctors/docs/types/test.ts b/typed-float-ctors/docs/types/test.ts deleted file mode 100644 index 41c670b38..000000000 --- a/typed-float-ctors/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import ctors = require( './index' ); - - -// TESTS // - -// The function returns a function or null.. -{ - ctors( 'float64' ); // $ExpectType Float64ArrayConstructor - ctors( 'float32' ); // $ExpectType Float32ArrayConstructor - ctors( 'complex128' ); // $ExpectType Complex128ArrayConstructor - ctors( 'complex64' ); // $ExpectType Complex64ArrayConstructor - ctors( 'float' ); // $ExpectType Function | null -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ctors(); // $ExpectError - ctors( 'float64', 3 ); // $ExpectError -} diff --git a/typed-float-ctors/examples/index.js b/typed-float-ctors/examples/index.js deleted file mode 100644 index 8d6b3f27a..000000000 --- a/typed-float-ctors/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../typed-float-dtypes' ); -var ctors = require( './../lib' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} diff --git a/typed-float-ctors/lib/ctors.js b/typed-float-ctors/lib/ctors.js deleted file mode 100644 index feeb0cf70..000000000 --- a/typed-float-ctors/lib/ctors.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); - - -// MAIN // - -// Mapping from data types to constructors... -var ctors = { - 'float64': Float64Array, - 'float32': Float32Array, - 'complex128': Complex128Array, - 'complex64': Complex64Array -}; - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-float-ctors/lib/index.js b/typed-float-ctors/lib/index.js deleted file mode 100644 index 8e3000369..000000000 --- a/typed-float-ctors/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Floating-point typed array constructors. -* -* @module @stdlib/array/typed-float-ctors -* -* @example -* var ctors = require( '@stdlib/array/typed-float-ctors' ); -* -* var ctor = ctors( 'float64' ); -* // returns -* -* ctor = ctors( 'int' ); -* // returns null -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-float-ctors/lib/main.js b/typed-float-ctors/lib/main.js deleted file mode 100644 index 4640e851f..000000000 --- a/typed-float-ctors/lib/main.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var table = require( './ctors.js' ); - - -// MAIN // - -/** -* Returns a floating-point typed array constructor. -* -* @param {string} dtype - data type -* @returns {(Function|null)} constructor or null -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -* -* @example -* var ctor = ctors( 'float' ); -* // returns null -*/ -function ctors( dtype ) { - return table[ dtype ] || null; -} - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-float-ctors/package.json b/typed-float-ctors/package.json deleted file mode 100644 index a02305b5e..000000000 --- a/typed-float-ctors/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@stdlib/array/typed-float-ctors", - "version": "0.0.0", - "description": "Floating-point typed array constructors.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "typed array", - "typed-array", - "typed", - "dtypes", - "dtype", - "data", - "type", - "structure", - "constructors", - "constructor", - "ctors", - "ctor", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-float-ctors/test/test.js b/typed-float-ctors/test/test.js deleted file mode 100644 index 9e3208c82..000000000 --- a/typed-float-ctors/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-float-dtypes' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ctors = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctors, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns typed array constructors', function test( t ) { - var expected; - var dtypes; - var ctor; - var i; - - dtypes = [ - 'float64', - 'float32', - 'complex128', - 'complex64' - ]; - expected = [ - Float64Array, - Float32Array, - Complex128Array, - Complex64Array - ]; - for ( i = 0; i < dtypes.length; i++ ) { - ctor = ctors( dtypes[ i ] ); - t.strictEqual( ctor, expected[ i ], 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'the function returns a constructor for each supported typed array data type', function test( t ) { - var DTYPES; - var ctor; - var i; - - DTYPES = dtypes(); - for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - - // Note: this is a weak test for a "constructor" - t.strictEqual( isFunction( ctor ), true, 'returns a function for ' + DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'binary', - 'buffer', - 'buf', - 'generic', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( ctors( dtypes[i] ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/typed-float-dtypes/README.md b/typed-float-dtypes/README.md deleted file mode 100644 index fbcf4cf61..000000000 --- a/typed-float-dtypes/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# Data Types - -> List of typed array floating-point data types. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var dtypes = require( '@stdlib/array/typed-float-dtypes' ); -``` - -#### dtypes() - -Returns a list of typed array floating-point data types. - -```javascript -var out = dtypes(); -// e.g., returns [ 'float32', ... ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( '@stdlib/array/typed-float-dtypes' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'float64' ); -// returns true - -bool = isdtype( 'complex128' ); -// returns true - -bool = isdtype( 'float32' ); -// returns true - -bool = isdtype( 'beep' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-float-dtypes/benchmark/benchmark.js b/typed-float-dtypes/benchmark/benchmark.js deleted file mode 100644 index 0df6510b7..000000000 --- a/typed-float-dtypes/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var pkg = require( './../package.json' ).name; -var dtypes = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dtypes(); - if ( out.length <= 2 ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-float-dtypes/docs/repl.txt b/typed-float-dtypes/docs/repl.txt deleted file mode 100644 index f35ce8700..000000000 --- a/typed-float-dtypes/docs/repl.txt +++ /dev/null @@ -1,17 +0,0 @@ - -{{alias}}() - Returns a list of typed array floating-point data types. - - Returns - ------- - out: Array - List of typed array floating-point data types. - - Examples - -------- - > var out = {{alias}}() - - - See Also - -------- - diff --git a/typed-float-dtypes/docs/types/index.d.ts b/typed-float-dtypes/docs/types/index.d.ts deleted file mode 100644 index cb80383e3..000000000 --- a/typed-float-dtypes/docs/types/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { FloatingPointDataType as DataType } from '@stdlib/types/array'; - -/** -* Returns a list of typed array floating-point data types. -* -* @returns list of typed array floating-point data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'float32', ... ] -*/ -declare function dtypes(): Array; - - -// EXPORTS // - -export = dtypes; diff --git a/typed-float-dtypes/docs/types/test.ts b/typed-float-dtypes/docs/types/test.ts deleted file mode 100644 index 72bb91673..000000000 --- a/typed-float-dtypes/docs/types/test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 dtypes = require( './index' ); - - -// TESTS // - -// The function returns a string array.. -{ - dtypes(); // $ExpectType FloatingPointDataType[] -} - -// The compiler throws an error if the function is provided arguments... -{ - dtypes( 1 ); // $ExpectError - dtypes( 1, 2 ); // $ExpectError -} diff --git a/typed-float-dtypes/examples/index.js b/typed-float-dtypes/examples/index.js deleted file mode 100644 index 7917242b8..000000000 --- a/typed-float-dtypes/examples/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( './../lib' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'float64' ); -console.log( bool ); -// => true - -bool = isdtype( 'complex128' ); -console.log( bool ); -// => true - -bool = isdtype( 'float32' ); -console.log( bool ); -// => true - -bool = isdtype( 'beep' ); -console.log( bool ); -// => false diff --git a/typed-float-dtypes/lib/index.js b/typed-float-dtypes/lib/index.js deleted file mode 100644 index 342e7b145..000000000 --- a/typed-float-dtypes/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a list of typed array floating-point data types. -* -* @module @stdlib/array/typed-float-dtypes -* -* @example -* var dtypes = require( '@stdlib/array/typed-float-dtypes' ); -* -* var list = dtypes(); -* // e.g., returns [ 'float32', 'float64', 'complex64', 'complex128' ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-float-dtypes/lib/main.js b/typed-float-dtypes/lib/main.js deleted file mode 100644 index 9148c293c..000000000 --- a/typed-float-dtypes/lib/main.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var dt = require( './../../dtypes' ); - - -// MAIN // - -/** -* Returns a list of typed array floating-point data types. -* -* @returns {StringArray} list of typed array floating-point data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'float32', ... ] -*/ -function dtypes() { - return dt( 'floating_point' ); -} - - -// EXPORTS // - -module.exports = dtypes; diff --git a/typed-float-dtypes/package.json b/typed-float-dtypes/package.json deleted file mode 100644 index 57d288d44..000000000 --- a/typed-float-dtypes/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/typed-float-dtypes", - "version": "0.0.0", - "description": "List of typed array floating-point data types.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "typed", - "array", - "dtypes", - "dtype", - "data", - "type", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-float-dtypes/test/test.js b/typed-float-dtypes/test/test.js deleted file mode 100644 index 87ee20e3f..000000000 --- a/typed-float-dtypes/test/test.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dt = require( './../../dtypes' ); -var dtypes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dtypes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a list of typed array floating-point data types', function test( t ) { - var expected; - var actual; - - expected = dt( 'floating_point' ); - actual = dtypes(); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/typed-integer-ctors/README.md b/typed-integer-ctors/README.md deleted file mode 100644 index 7a58a4e29..000000000 --- a/typed-integer-ctors/README.md +++ /dev/null @@ -1,129 +0,0 @@ - - -# Constructors - -> Integer-valued typed array constructors. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ctors = require( '@stdlib/array/typed-integer-ctors' ); -``` - -#### ctors( dtype ) - -Returns an integer-valued typed array constructor for a specified data type. - -```javascript -var ctor = ctors( 'int32' ); -// returns -``` - -The function returns constructors for the following data types: - -- `int16`: signed 16-bit integers. -- `int32`: signed 32-bit integers. -- `int8`: signed 8-bit integers. -- `uint16`: unsigned 16-bit integers. -- `uint32`: unsigned 32-bit integers. -- `uint8`: unsigned 8-bit integers. -- `uint8c`: unsigned clamped 8-bit integers. - -If provided an unknown or unsupported data type, the function returns `null`. - -```javascript -var ctor = ctors( 'int' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/typed-integer-dtypes' ); -var ctors = require( '@stdlib/array/typed-integer-ctors' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-integer-ctors/benchmark/benchmark.js b/typed-integer-ctors/benchmark/benchmark.js deleted file mode 100644 index c0585ee15..000000000 --- a/typed-integer-ctors/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-integer-dtypes' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var ctors = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var ctor; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ctor = ctors( DTYPES[ i%DTYPES.length ] ); - if ( typeof ctor !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( ctor ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-integer-ctors/docs/repl.txt b/typed-integer-ctors/docs/repl.txt deleted file mode 100644 index 7c2c70458..000000000 --- a/typed-integer-ctors/docs/repl.txt +++ /dev/null @@ -1,34 +0,0 @@ - -{{alias}}( dtype ) - Returns an integer-valued typed array constructor. - - The function returns constructors for the following data types: - - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - Returns - ------- - out: Function|null - Typed array constructor. - - Examples - -------- - > var ctor = {{alias}}( 'int32' ) - - > ctor = {{alias}}( 'int' ) - null - - See Also - -------- - diff --git a/typed-integer-ctors/docs/types/index.d.ts b/typed-integer-ctors/docs/types/index.d.ts deleted file mode 100644 index 75f344024..000000000 --- a/typed-integer-ctors/docs/types/index.d.ts +++ /dev/null @@ -1,124 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns an `Int32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int32' ); -* // returns -*/ -declare function ctors( dtype: 'int32' ): typeof Int32Array; - -/** -* Returns an `Int16Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int16' ); -* // returns -*/ -declare function ctors( dtype: 'int16' ): typeof Int16Array; - -/** -* Returns an `Int8Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int8' ); -* // returns -*/ -declare function ctors( dtype: 'int8' ): typeof Int8Array; - -/** -* Returns a `Uint32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint32' ); -* // returns -*/ -declare function ctors( dtype: 'uint32' ): typeof Uint32Array; - -/** -* Returns a `Uint16Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint16' ); -* // returns -*/ -declare function ctors( dtype: 'uint16' ): typeof Uint16Array; - -/** -* Returns a `Uint8Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint8' ); -* // returns -*/ -declare function ctors( dtype: 'uint8' ): typeof Uint8Array; - -/** -* Returns a `Uint8ClampedArray` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint8c' ); -* // returns -*/ -declare function ctors( dtype: 'uint8c' ): typeof Uint8ClampedArray; - -/** -* Returns an integer-valued typed array constructor. -* -* @param dtype - data type -* @returns constructor or null -* -* @example -* var ctor = ctors( 'int32' ); -* // returns -* -* @example -* var ctor = ctors( 'int' ); -* // returns null -*/ -declare function ctors( dtype: string ): Function | null; - - -// EXPORTS // - -export = ctors; diff --git a/typed-integer-ctors/docs/types/test.ts b/typed-integer-ctors/docs/types/test.ts deleted file mode 100644 index 4649207dd..000000000 --- a/typed-integer-ctors/docs/types/test.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import ctors = require( './index' ); - - -// TESTS // - -// The function returns a function or null.. -{ - ctors( 'int32' ); // $ExpectType Int32ArrayConstructor - ctors( 'int16' ); // $ExpectType Int16ArrayConstructor - ctors( 'int8' ); // $ExpectType Int8ArrayConstructor - ctors( 'uint32' ); // $ExpectType Uint32ArrayConstructor - ctors( 'uint16' ); // $ExpectType Uint16ArrayConstructor - ctors( 'uint8' ); // $ExpectType Uint8ArrayConstructor - ctors( 'uint8c' ); // $ExpectType Uint8ClampedArrayConstructor - ctors( 'int' ); // $ExpectType Function | null -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ctors(); // $ExpectError - ctors( 'int32', 3 ); // $ExpectError -} diff --git a/typed-integer-ctors/examples/index.js b/typed-integer-ctors/examples/index.js deleted file mode 100644 index 34d66deaa..000000000 --- a/typed-integer-ctors/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../typed-integer-dtypes' ); -var ctors = require( './../lib' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} diff --git a/typed-integer-ctors/lib/ctors.js b/typed-integer-ctors/lib/ctors.js deleted file mode 100644 index fc640426c..000000000 --- a/typed-integer-ctors/lib/ctors.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); - - -// MAIN // - -// Mapping from data types to constructors... -var ctors = { - 'int16': Int16Array, - 'int32': Int32Array, - 'int8': Int8Array, - 'uint16': Uint16Array, - 'uint32': Uint32Array, - 'uint8': Uint8Array, - 'uint8c': Uint8ClampedArray -}; - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-integer-ctors/lib/index.js b/typed-integer-ctors/lib/index.js deleted file mode 100644 index 3cade4852..000000000 --- a/typed-integer-ctors/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Integer-valued typed array constructors. -* -* @module @stdlib/array/typed-integer-ctors -* -* @example -* var ctors = require( '@stdlib/array/typed-integer-ctors' ); -* -* var ctor = ctors( 'int32' ); -* // returns -* -* ctor = ctors( 'int' ); -* // returns null -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-integer-ctors/lib/main.js b/typed-integer-ctors/lib/main.js deleted file mode 100644 index 387829505..000000000 --- a/typed-integer-ctors/lib/main.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var table = require( './ctors.js' ); - - -// MAIN // - -/** -* Returns an integer-valued typed array constructor. -* -* @param {string} dtype - data type -* @returns {(Function|null)} constructor or null -* -* @example -* var ctor = ctors( 'int32' ); -* // returns -* -* @example -* var ctor = ctors( 'int' ); -* // returns null -*/ -function ctors( dtype ) { - return table[ dtype ] || null; -} - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-integer-ctors/package.json b/typed-integer-ctors/package.json deleted file mode 100644 index f4546c584..000000000 --- a/typed-integer-ctors/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@stdlib/array/typed-integer-ctors", - "version": "0.0.0", - "description": "Integer-valued typed array constructors.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "typed array", - "typed-array", - "typed", - "dtypes", - "dtype", - "data", - "type", - "structure", - "constructors", - "constructor", - "ctors", - "ctor", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-integer-ctors/test/test.js b/typed-integer-ctors/test/test.js deleted file mode 100644 index a852edd83..000000000 --- a/typed-integer-ctors/test/test.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-integer-dtypes' ); -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ctors = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctors, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns typed array constructors', function test( t ) { - var expected; - var dtypes; - var ctor; - var i; - - dtypes = [ - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - expected = [ - Int16Array, - Int32Array, - Int8Array, - Uint16Array, - Uint32Array, - Uint8Array, - Uint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - ctor = ctors( dtypes[ i ] ); - t.strictEqual( ctor, expected[ i ], 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'the function returns a constructor for each supported typed array data type', function test( t ) { - var DTYPES; - var ctor; - var i; - - DTYPES = dtypes(); - for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - - // Note: this is a weak test for a "constructor" - t.strictEqual( isFunction( ctor ), true, 'returns a function for ' + DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'binary', - 'buffer', - 'buf', - 'generic', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( ctors( dtypes[i] ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/typed-integer-dtypes/README.md b/typed-integer-dtypes/README.md deleted file mode 100644 index 714e61791..000000000 --- a/typed-integer-dtypes/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# Data Types - -> List of typed array integer data types. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var dtypes = require( '@stdlib/array/typed-integer-dtypes' ); -``` - -#### dtypes() - -Returns a list of typed array integer data types. - -```javascript -var out = dtypes(); -// e.g., returns [ 'int16', ... ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( '@stdlib/array/typed-integer-dtypes' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'int32' ); -// returns true - -bool = isdtype( 'int16' ); -// returns true - -bool = isdtype( 'uint8' ); -// returns true - -bool = isdtype( 'beep' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-integer-dtypes/benchmark/benchmark.js b/typed-integer-dtypes/benchmark/benchmark.js deleted file mode 100644 index 0df6510b7..000000000 --- a/typed-integer-dtypes/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var pkg = require( './../package.json' ).name; -var dtypes = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dtypes(); - if ( out.length <= 2 ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-integer-dtypes/docs/repl.txt b/typed-integer-dtypes/docs/repl.txt deleted file mode 100644 index d1e78b21d..000000000 --- a/typed-integer-dtypes/docs/repl.txt +++ /dev/null @@ -1,17 +0,0 @@ - -{{alias}}() - Returns a list of typed array integer data types. - - Returns - ------- - out: Array - List of typed array integer data types. - - Examples - -------- - > var out = {{alias}}() - - - See Also - -------- - diff --git a/typed-integer-dtypes/docs/types/index.d.ts b/typed-integer-dtypes/docs/types/index.d.ts deleted file mode 100644 index 992b010b7..000000000 --- a/typed-integer-dtypes/docs/types/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { IntegerDataType as DataType } from '@stdlib/types/array'; - -/** -* Returns a list of typed array integer data types. -* -* @returns list of typed array integer data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'int16', ... ] -*/ -declare function dtypes(): Array; - - -// EXPORTS // - -export = dtypes; diff --git a/typed-integer-dtypes/docs/types/test.ts b/typed-integer-dtypes/docs/types/test.ts deleted file mode 100644 index d833942e3..000000000 --- a/typed-integer-dtypes/docs/types/test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 dtypes = require( './index' ); - - -// TESTS // - -// The function returns a string array.. -{ - dtypes(); // $ExpectType IntegerDataType[] -} - -// The compiler throws an error if the function is provided arguments... -{ - dtypes( 1 ); // $ExpectError - dtypes( 1, 2 ); // $ExpectError -} diff --git a/typed-integer-dtypes/examples/index.js b/typed-integer-dtypes/examples/index.js deleted file mode 100644 index 6b5cbdc8c..000000000 --- a/typed-integer-dtypes/examples/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( './../lib' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'int32' ); -console.log( bool ); -// => true - -bool = isdtype( 'int8' ); -console.log( bool ); -// => true - -bool = isdtype( 'uint16' ); -console.log( bool ); -// => true - -bool = isdtype( 'beep' ); -console.log( bool ); -// => false diff --git a/typed-integer-dtypes/lib/index.js b/typed-integer-dtypes/lib/index.js deleted file mode 100644 index 2cac16b60..000000000 --- a/typed-integer-dtypes/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a list of typed array integer data types. -* -* @module @stdlib/array/typed-integer-dtypes -* -* @example -* var dtypes = require( '@stdlib/array/typed-integer-dtypes' ); -* -* var list = dtypes(); -* // e.g., returns [ 'int16', ... ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-integer-dtypes/lib/main.js b/typed-integer-dtypes/lib/main.js deleted file mode 100644 index 90fdfd737..000000000 --- a/typed-integer-dtypes/lib/main.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var dt = require( './../../dtypes' ); - - -// MAIN // - -/** -* Returns a list of typed array integer data types. -* -* @returns {StringArray} list of typed array integer data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'int16', ... ] -*/ -function dtypes() { - return dt( 'integer' ); -} - - -// EXPORTS // - -module.exports = dtypes; diff --git a/typed-integer-dtypes/package.json b/typed-integer-dtypes/package.json deleted file mode 100644 index 7e1b80d98..000000000 --- a/typed-integer-dtypes/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/typed-integer-dtypes", - "version": "0.0.0", - "description": "List of typed array integer data types.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "typed", - "array", - "dtypes", - "dtype", - "data", - "type", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-integer-dtypes/test/test.js b/typed-integer-dtypes/test/test.js deleted file mode 100644 index 4a3829e58..000000000 --- a/typed-integer-dtypes/test/test.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dt = require( './../../dtypes' ); -var dtypes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dtypes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a list of typed array data types', function test( t ) { - var expected; - var actual; - - expected = dt( 'integer' ); - actual = dtypes(); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/typed-real-ctors/README.md b/typed-real-ctors/README.md deleted file mode 100644 index 6635e4d3d..000000000 --- a/typed-real-ctors/README.md +++ /dev/null @@ -1,146 +0,0 @@ - - -# Constructors - -> Typed array constructors. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ctors = require( '@stdlib/array/typed-real-ctors' ); -``` - -#### ctors( dtype ) - -Returns a typed array constructor for a specified data type. - -```javascript -var ctor = ctors( 'float64' ); -// returns -``` - -The function returns constructors for the following data types: - -- `float32`: single-precision floating-point numbers. -- `float64`: double-precision floating-point numbers. -- `int16`: signed 16-bit integers. -- `int32`: signed 32-bit integers. -- `int8`: signed 8-bit integers. -- `uint16`: unsigned 16-bit integers. -- `uint32`: unsigned 32-bit integers. -- `uint8`: unsigned 8-bit integers. -- `uint8c`: unsigned clamped 8-bit integers. - -If provided an unknown or unsupported data type, the function returns `null`. - -```javascript -var ctor = ctors( 'float' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/typed-real-dtypes' ); -var ctors = require( '@stdlib/array/typed-real-ctors' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-real-ctors/benchmark/benchmark.js b/typed-real-ctors/benchmark/benchmark.js deleted file mode 100644 index 5e2b2828f..000000000 --- a/typed-real-ctors/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-real-dtypes' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var ctors = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var ctor; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ctor = ctors( DTYPES[ i%DTYPES.length ] ); - if ( typeof ctor !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( ctor ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-real-ctors/docs/repl.txt b/typed-real-ctors/docs/repl.txt deleted file mode 100644 index 335f22ad7..000000000 --- a/typed-real-ctors/docs/repl.txt +++ /dev/null @@ -1,36 +0,0 @@ - -{{alias}}( dtype ) - Returns a typed array constructor. - - The function returns constructors for the following data types: - - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - Returns - ------- - out: Function|null - Typed array constructor. - - Examples - -------- - > var ctor = {{alias}}( 'float64' ) - - > ctor = {{alias}}( 'float' ) - null - - See Also - -------- - diff --git a/typed-real-ctors/docs/types/index.d.ts b/typed-real-ctors/docs/types/index.d.ts deleted file mode 100644 index e1a44c546..000000000 --- a/typed-real-ctors/docs/types/index.d.ts +++ /dev/null @@ -1,148 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a `Float64Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -*/ -declare function ctors( dtype: 'float64' ): typeof Float64Array; - -/** -* Returns a `Float32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'float32' ); -* // returns -*/ -declare function ctors( dtype: 'float32' ): typeof Float32Array; - -/** -* Returns an `Int32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int32' ); -* // returns -*/ -declare function ctors( dtype: 'int32' ): typeof Int32Array; - -/** -* Returns an `Int16Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int16' ); -* // returns -*/ -declare function ctors( dtype: 'int16' ): typeof Int16Array; - -/** -* Returns an `Int8Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int8' ); -* // returns -*/ -declare function ctors( dtype: 'int8' ): typeof Int8Array; - -/** -* Returns a `Uint32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint32' ); -* // returns -*/ -declare function ctors( dtype: 'uint32' ): typeof Uint32Array; - -/** -* Returns a `Uint16Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint16' ); -* // returns -*/ -declare function ctors( dtype: 'uint16' ): typeof Uint16Array; - -/** -* Returns a `Uint8Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint8' ); -* // returns -*/ -declare function ctors( dtype: 'uint8' ): typeof Uint8Array; - -/** -* Returns a `Uint8ClampedArray` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint8c' ); -* // returns -*/ -declare function ctors( dtype: 'uint8c' ): typeof Uint8ClampedArray; - -/** -* Returns a typed array constructor. -* -* @param dtype - data type -* @returns constructor or null -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -* -* @example -* var ctor = ctors( 'float' ); -* // returns null -*/ -declare function ctors( dtype: string ): Function | null; - - -// EXPORTS // - -export = ctors; diff --git a/typed-real-ctors/docs/types/test.ts b/typed-real-ctors/docs/types/test.ts deleted file mode 100644 index 8137a9474..000000000 --- a/typed-real-ctors/docs/types/test.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import ctors = require( './index' ); - - -// TESTS // - -// The function returns a function or null.. -{ - ctors( 'float64' ); // $ExpectType Float64ArrayConstructor - ctors( 'float32' ); // $ExpectType Float32ArrayConstructor - ctors( 'int32' ); // $ExpectType Int32ArrayConstructor - ctors( 'int16' ); // $ExpectType Int16ArrayConstructor - ctors( 'int8' ); // $ExpectType Int8ArrayConstructor - ctors( 'uint32' ); // $ExpectType Uint32ArrayConstructor - ctors( 'uint16' ); // $ExpectType Uint16ArrayConstructor - ctors( 'uint8' ); // $ExpectType Uint8ArrayConstructor - ctors( 'uint8c' ); // $ExpectType Uint8ClampedArrayConstructor - ctors( 'float' ); // $ExpectType Function | null -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ctors(); // $ExpectError - ctors( 'int32', 3 ); // $ExpectError -} diff --git a/typed-real-ctors/examples/index.js b/typed-real-ctors/examples/index.js deleted file mode 100644 index 04769e089..000000000 --- a/typed-real-ctors/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../typed-real-dtypes' ); -var ctors = require( './../lib' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} diff --git a/typed-real-ctors/lib/ctors.js b/typed-real-ctors/lib/ctors.js deleted file mode 100644 index b8e8bd513..000000000 --- a/typed-real-ctors/lib/ctors.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); - - -// MAIN // - -// Mapping from data types to constructors... -var ctors = { - 'float64': Float64Array, - 'float32': Float32Array, - 'int16': Int16Array, - 'int32': Int32Array, - 'int8': Int8Array, - 'uint16': Uint16Array, - 'uint32': Uint32Array, - 'uint8': Uint8Array, - 'uint8c': Uint8ClampedArray -}; - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-real-ctors/lib/index.js b/typed-real-ctors/lib/index.js deleted file mode 100644 index d79084f98..000000000 --- a/typed-real-ctors/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructors. -* -* @module @stdlib/array/typed-real-ctors -* -* @example -* var ctors = require( '@stdlib/array/typed-real-ctors' ); -* -* var ctor = ctors( 'float64' ); -* // returns -* -* ctor = ctors( 'int' ); -* // returns null -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-real-ctors/lib/main.js b/typed-real-ctors/lib/main.js deleted file mode 100644 index d1db79899..000000000 --- a/typed-real-ctors/lib/main.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var table = require( './ctors.js' ); - - -// MAIN // - -/** -* Returns a typed array constructor. -* -* @param {string} dtype - data type -* @returns {(Function|null)} constructor or null -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -* -* @example -* var ctor = ctors( 'float' ); -* // returns null -*/ -function ctors( dtype ) { - return table[ dtype ] || null; -} - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-real-ctors/package.json b/typed-real-ctors/package.json deleted file mode 100644 index c0fb2d4a6..000000000 --- a/typed-real-ctors/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@stdlib/array/typed-real-ctors", - "version": "0.0.0", - "description": "Typed array constructors.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "typed array", - "typed-array", - "typed", - "dtypes", - "dtype", - "data", - "type", - "structure", - "constructors", - "constructor", - "ctors", - "ctor", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-real-ctors/test/test.js b/typed-real-ctors/test/test.js deleted file mode 100644 index d401a7160..000000000 --- a/typed-real-ctors/test/test.js +++ /dev/null @@ -1,119 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-real-dtypes' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ctors = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctors, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns typed array constructors', function test( t ) { - var expected; - var dtypes; - var ctor; - var i; - - dtypes = [ - 'float64', - 'float32', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - expected = [ - Float64Array, - Float32Array, - Int16Array, - Int32Array, - Int8Array, - Uint16Array, - Uint32Array, - Uint8Array, - Uint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - ctor = ctors( dtypes[ i ] ); - t.strictEqual( ctor, expected[ i ], 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'the function returns a constructor for each supported typed array data type', function test( t ) { - var DTYPES; - var ctor; - var i; - - DTYPES = dtypes(); - for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - - // Note: this is a weak test for a "constructor" - t.strictEqual( isFunction( ctor ), true, 'returns a function for ' + DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'binary', - 'buffer', - 'buf', - 'generic', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( ctors( dtypes[i] ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/typed-real-dtypes/README.md b/typed-real-dtypes/README.md deleted file mode 100644 index 866bedf3b..000000000 --- a/typed-real-dtypes/README.md +++ /dev/null @@ -1,139 +0,0 @@ - - -# Data Types - -> List of typed array real-valued data types. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var dtypes = require( '@stdlib/array/typed-real-dtypes' ); -``` - -#### dtypes() - -Returns a list of typed array real-valued data types. - -```javascript -var out = dtypes(); -// e.g., returns [ 'float32', ... ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( '@stdlib/array/typed-real-dtypes' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'float64' ); -// returns true - -bool = isdtype( 'int16' ); -// returns true - -bool = isdtype( 'uint8' ); -// returns true - -bool = isdtype( 'beep' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-real-dtypes/benchmark/benchmark.js b/typed-real-dtypes/benchmark/benchmark.js deleted file mode 100644 index b4e58baa4..000000000 --- a/typed-real-dtypes/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var pkg = require( './../package.json' ).name; -var dtypes = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dtypes(); - if ( out.length < 9 ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-real-dtypes/docs/repl.txt b/typed-real-dtypes/docs/repl.txt deleted file mode 100644 index 430bd693e..000000000 --- a/typed-real-dtypes/docs/repl.txt +++ /dev/null @@ -1,17 +0,0 @@ - -{{alias}}() - Returns a list of typed array real-valued data types. - - Returns - ------- - out: Array - List of typed array data types. - - Examples - -------- - > var out = {{alias}}() - - - See Also - -------- - diff --git a/typed-real-dtypes/docs/types/index.d.ts b/typed-real-dtypes/docs/types/index.d.ts deleted file mode 100644 index bef865a50..000000000 --- a/typed-real-dtypes/docs/types/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { RealDataType as DataType } from '@stdlib/types/array'; - -/** -* Returns a list of typed array real-valued data types. -* -* @returns list of typed array data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'float32', ... ] -*/ -declare function dtypes(): Array; - - -// EXPORTS // - -export = dtypes; diff --git a/typed-real-dtypes/docs/types/test.ts b/typed-real-dtypes/docs/types/test.ts deleted file mode 100644 index 3ddca3afe..000000000 --- a/typed-real-dtypes/docs/types/test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 dtypes = require( './index' ); - - -// TESTS // - -// The function returns a string array.. -{ - dtypes(); // $ExpectType RealDataType[] -} - -// The compiler throws an error if the function is provided arguments... -{ - dtypes( 1 ); // $ExpectError - dtypes( 1, 2 ); // $ExpectError -} diff --git a/typed-real-dtypes/examples/index.js b/typed-real-dtypes/examples/index.js deleted file mode 100644 index df9a237cd..000000000 --- a/typed-real-dtypes/examples/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( './../lib' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'float64' ); -console.log( bool ); -// => true - -bool = isdtype( 'int8' ); -console.log( bool ); -// => true - -bool = isdtype( 'uint16' ); -console.log( bool ); -// => true - -bool = isdtype( 'beep' ); -console.log( bool ); -// => false diff --git a/typed-real-dtypes/lib/index.js b/typed-real-dtypes/lib/index.js deleted file mode 100644 index 10162cc58..000000000 --- a/typed-real-dtypes/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a list of typed array real-valued data types. -* -* @module @stdlib/array/typed-real-dtypes -* -* @example -* var dtypes = require( '@stdlib/array/typed-real-dtypes' ); -* -* var list = dtypes(); -* // e.g., returns [ 'float32', ... ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-real-dtypes/lib/main.js b/typed-real-dtypes/lib/main.js deleted file mode 100644 index 1bee4c1b6..000000000 --- a/typed-real-dtypes/lib/main.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var dt = require( './../../dtypes' ); - - -// MAIN // - -/** -* Returns a list of typed array real-valued data types. -* -* @returns {StringArray} list of typed array data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'float32', ... ] -*/ -function dtypes() { - return dt( 'real' ); -} - - -// EXPORTS // - -module.exports = dtypes; diff --git a/typed-real-dtypes/package.json b/typed-real-dtypes/package.json deleted file mode 100644 index a9c84d30c..000000000 --- a/typed-real-dtypes/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/typed-real-dtypes", - "version": "0.0.0", - "description": "List of typed array real-valued data types.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "typed", - "array", - "dtypes", - "dtype", - "data", - "type", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-real-dtypes/test/test.js b/typed-real-dtypes/test/test.js deleted file mode 100644 index 96f373ab0..000000000 --- a/typed-real-dtypes/test/test.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dt = require( './../../dtypes' ); -var dtypes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dtypes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a list of typed array real-valued data types', function test( t ) { - var expected; - var actual; - - expected = dt( 'real' ); - actual = dtypes(); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/typed-real-float-ctors/README.md b/typed-real-float-ctors/README.md deleted file mode 100644 index 90731beec..000000000 --- a/typed-real-float-ctors/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# Constructors - -> Real-valued floating-point typed array constructors. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ctors = require( '@stdlib/array/typed-real-float-ctors' ); -``` - -#### ctors( dtype ) - -Returns a real-valued floating-point typed array constructor for a specified data type. - -```javascript -var ctor = ctors( 'float64' ); -// returns -``` - -The function returns constructors for the following data types: - -- `float32`: single-precision floating-point numbers. -- `float64`: double-precision floating-point numbers. - -If provided an unknown or unsupported data type, the function returns `null`. - -```javascript -var ctor = ctors( 'float' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/typed-real-float-dtypes' ); -var ctors = require( '@stdlib/array/typed-real-float-ctors' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-real-float-ctors/benchmark/benchmark.js b/typed-real-float-ctors/benchmark/benchmark.js deleted file mode 100644 index 186c9790b..000000000 --- a/typed-real-float-ctors/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-real-float-dtypes' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var ctors = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var ctor; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ctor = ctors( DTYPES[ i%DTYPES.length ] ); - if ( typeof ctor !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( ctor ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-real-float-ctors/docs/repl.txt b/typed-real-float-ctors/docs/repl.txt deleted file mode 100644 index e0feb1cec..000000000 --- a/typed-real-float-ctors/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( dtype ) - Returns a real-valued floating-point typed array constructor. - - The function returns constructors for the following data types: - - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - Parameters - ---------- - dtype: string - Data type. - - Returns - ------- - out: Function|null - Typed array constructor. - - Examples - -------- - > var ctor = {{alias}}( 'float64' ) - - > ctor = {{alias}}( 'float' ) - null - - See Also - -------- - diff --git a/typed-real-float-ctors/docs/types/index.d.ts b/typed-real-float-ctors/docs/types/index.d.ts deleted file mode 100644 index 43b60eead..000000000 --- a/typed-real-float-ctors/docs/types/index.d.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a `Float64Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -*/ -declare function ctors( dtype: 'float64' ): typeof Float64Array; - -/** -* Returns a `Float32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'float32' ); -* // returns -*/ -declare function ctors( dtype: 'float32' ): typeof Float32Array; - -/** -* Returns a real-valued floating-point typed array constructor. -* -* @param dtype - data type -* @returns constructor or null -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -* -* @example -* var ctor = ctors( 'float' ); -* // returns null -*/ -declare function ctors( dtype: string ): Function | null; - - -// EXPORTS // - -export = ctors; diff --git a/typed-real-float-ctors/docs/types/test.ts b/typed-real-float-ctors/docs/types/test.ts deleted file mode 100644 index 67bcbf2fc..000000000 --- a/typed-real-float-ctors/docs/types/test.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import ctors = require( './index' ); - - -// TESTS // - -// The function returns a function or null.. -{ - ctors( 'float64' ); // $ExpectType Float64ArrayConstructor - ctors( 'float32' ); // $ExpectType Float32ArrayConstructor - ctors( 'float' ); // $ExpectType Function | null -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ctors(); // $ExpectError - ctors( 'float64', 3 ); // $ExpectError -} diff --git a/typed-real-float-ctors/examples/index.js b/typed-real-float-ctors/examples/index.js deleted file mode 100644 index 74257115b..000000000 --- a/typed-real-float-ctors/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../typed-real-float-dtypes' ); -var ctors = require( './../lib' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} diff --git a/typed-real-float-ctors/lib/ctors.js b/typed-real-float-ctors/lib/ctors.js deleted file mode 100644 index 1651dc499..000000000 --- a/typed-real-float-ctors/lib/ctors.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); - - -// MAIN // - -// Mapping from data types to constructors... -var ctors = { - 'float64': Float64Array, - 'float32': Float32Array -}; - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-real-float-ctors/lib/index.js b/typed-real-float-ctors/lib/index.js deleted file mode 100644 index 8d5b36618..000000000 --- a/typed-real-float-ctors/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Real-valued floating-point typed array constructors. -* -* @module @stdlib/array/typed-real-float-ctors -* -* @example -* var ctors = require( '@stdlib/array/typed-real-float-ctors' ); -* -* var ctor = ctors( 'float64' ); -* // returns -* -* ctor = ctors( 'int' ); -* // returns null -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-real-float-ctors/lib/main.js b/typed-real-float-ctors/lib/main.js deleted file mode 100644 index 703a0c95d..000000000 --- a/typed-real-float-ctors/lib/main.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var table = require( './ctors.js' ); - - -// MAIN // - -/** -* Returns a real-valued floating-point typed array constructor. -* -* @param {string} dtype - data type -* @returns {(Function|null)} constructor or null -* -* @example -* var ctor = ctors( 'float64' ); -* // returns -* -* @example -* var ctor = ctors( 'float' ); -* // returns null -*/ -function ctors( dtype ) { - return table[ dtype ] || null; -} - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-real-float-ctors/package.json b/typed-real-float-ctors/package.json deleted file mode 100644 index 8c4b881d2..000000000 --- a/typed-real-float-ctors/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@stdlib/array/typed-real-float-ctors", - "version": "0.0.0", - "description": "Real-valued floating-point typed array constructors.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "typed array", - "typed-array", - "typed", - "dtypes", - "dtype", - "data", - "type", - "structure", - "constructors", - "constructor", - "ctors", - "ctor", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-real-float-ctors/test/test.js b/typed-real-float-ctors/test/test.js deleted file mode 100644 index 28650880d..000000000 --- a/typed-real-float-ctors/test/test.js +++ /dev/null @@ -1,98 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-real-float-dtypes' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ctors = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctors, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns typed array constructors', function test( t ) { - var expected; - var dtypes; - var ctor; - var i; - - dtypes = [ - 'float64', - 'float32' - ]; - expected = [ - Float64Array, - Float32Array - ]; - for ( i = 0; i < dtypes.length; i++ ) { - ctor = ctors( dtypes[ i ] ); - t.strictEqual( ctor, expected[ i ], 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'the function returns a constructor for each supported typed array data type', function test( t ) { - var DTYPES; - var ctor; - var i; - - DTYPES = dtypes(); - for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - - // Note: this is a weak test for a "constructor" - t.strictEqual( isFunction( ctor ), true, 'returns a function for ' + DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'binary', - 'buffer', - 'buf', - 'generic', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( ctors( dtypes[i] ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/typed-real-float-dtypes/README.md b/typed-real-float-dtypes/README.md deleted file mode 100644 index 36d42067a..000000000 --- a/typed-real-float-dtypes/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# Data Types - -> List of typed array real-valued floating-point data types. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var dtypes = require( '@stdlib/array/typed-real-float-dtypes' ); -``` - -#### dtypes() - -Returns a list of typed array real-valued floating-point data types. - -```javascript -var out = dtypes(); -// e.g., returns [ 'float32', ... ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( '@stdlib/array/typed-real-float-dtypes' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'float64' ); -// returns true - -bool = isdtype( 'float32' ); -// returns true - -bool = isdtype( 'complex128' ); -// returns false - -bool = isdtype( 'beep' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-real-float-dtypes/benchmark/benchmark.js b/typed-real-float-dtypes/benchmark/benchmark.js deleted file mode 100644 index 5ca3dd715..000000000 --- a/typed-real-float-dtypes/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var pkg = require( './../package.json' ).name; -var dtypes = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dtypes(); - if ( out.length <= 1 ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-real-float-dtypes/docs/repl.txt b/typed-real-float-dtypes/docs/repl.txt deleted file mode 100644 index fc9b563a7..000000000 --- a/typed-real-float-dtypes/docs/repl.txt +++ /dev/null @@ -1,17 +0,0 @@ - -{{alias}}() - Returns a list of typed array real-valued floating-point data types. - - Returns - ------- - out: Array - List of typed array real-valued floating-point data types. - - Examples - -------- - > var out = {{alias}}() - - - See Also - -------- - diff --git a/typed-real-float-dtypes/docs/types/index.d.ts b/typed-real-float-dtypes/docs/types/index.d.ts deleted file mode 100644 index 8237c65f9..000000000 --- a/typed-real-float-dtypes/docs/types/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { RealFloatingPointDataType as DataType } from '@stdlib/types/array'; - -/** -* Returns a list of typed array real-valued floating-point data types. -* -* @returns list of typed array real-valued floating-point data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'float32', ... ] -*/ -declare function dtypes(): Array; - - -// EXPORTS // - -export = dtypes; diff --git a/typed-real-float-dtypes/docs/types/test.ts b/typed-real-float-dtypes/docs/types/test.ts deleted file mode 100644 index 38e2c071e..000000000 --- a/typed-real-float-dtypes/docs/types/test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 dtypes = require( './index' ); - - -// TESTS // - -// The function returns a string array.. -{ - dtypes(); // $ExpectType RealFloatingPointDataType[] -} - -// The compiler throws an error if the function is provided arguments... -{ - dtypes( 1 ); // $ExpectError - dtypes( 1, 2 ); // $ExpectError -} diff --git a/typed-real-float-dtypes/examples/index.js b/typed-real-float-dtypes/examples/index.js deleted file mode 100644 index ac1bee1c2..000000000 --- a/typed-real-float-dtypes/examples/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( './../lib' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'float64' ); -console.log( bool ); -// => true - -bool = isdtype( 'float32' ); -console.log( bool ); -// => true - -bool = isdtype( 'complex128' ); -console.log( bool ); -// => false - -bool = isdtype( 'beep' ); -console.log( bool ); -// => false diff --git a/typed-real-float-dtypes/lib/index.js b/typed-real-float-dtypes/lib/index.js deleted file mode 100644 index 418515af3..000000000 --- a/typed-real-float-dtypes/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a list of typed array real-valued floating-point data types. -* -* @module @stdlib/array/typed-real-float-dtypes -* -* @example -* var dtypes = require( '@stdlib/array/typed-real-float-dtypes' ); -* -* var list = dtypes(); -* // e.g., returns [ 'float32', ... ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-real-float-dtypes/lib/main.js b/typed-real-float-dtypes/lib/main.js deleted file mode 100644 index ca936308a..000000000 --- a/typed-real-float-dtypes/lib/main.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var dt = require( './../../dtypes' ); - - -// MAIN // - -/** -* Returns a list of typed array real-valued floating-point data types. -* -* @returns {StringArray} list of typed array real-valued floating-point data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'float32', ... ] -*/ -function dtypes() { - return dt( 'real_floating_point' ); -} - - -// EXPORTS // - -module.exports = dtypes; diff --git a/typed-real-float-dtypes/package.json b/typed-real-float-dtypes/package.json deleted file mode 100644 index b3040616b..000000000 --- a/typed-real-float-dtypes/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/typed-real-float-dtypes", - "version": "0.0.0", - "description": "List of typed array real-valued floating-point data types.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "typed", - "array", - "dtypes", - "dtype", - "data", - "type", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-real-float-dtypes/test/test.js b/typed-real-float-dtypes/test/test.js deleted file mode 100644 index 22b7ab7b0..000000000 --- a/typed-real-float-dtypes/test/test.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dt = require( './../../dtypes' ); -var dtypes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dtypes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a list of typed array real-valued floating-point data types', function test( t ) { - var expected; - var actual; - - expected = dt( 'real_floating_point' ); - actual = dtypes(); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/typed-real/README.md b/typed-real/README.md deleted file mode 100644 index c3f03ac45..000000000 --- a/typed-real/README.md +++ /dev/null @@ -1,236 +0,0 @@ - - -# Typed Arrays - -> Create a typed array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var realarray = require( '@stdlib/array/typed-real' ); -``` - -#### realarray( \[dtype] ) - -Creates a [typed array][mdn-typed-array] having a specified data type `dtype`. - -```javascript -var arr = realarray(); -// returns -``` - -The function recognizes the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `int32`: 32-bit two's complement signed integers -- `uint32`: 32-bit unsigned integers -- `int16`: 16-bit two's complement signed integers -- `uint16`: 16-bit unsigned integers -- `int8`: 8-bit two's complement signed integers -- `uint8`: 8-bit unsigned integers -- `uint8c`: 8-bit unsigned integers clamped to `0-255` - -By default, the output [typed array][mdn-typed-array] data type is `float64`. To specify an alternative data type, provide a `dtype` argument. - -```javascript -var arr = realarray( 'int32' ); -// returns -``` - -#### realarray( length\[, dtype] ) - -Returns a [typed array][mdn-typed-array] having a specified `length`. - -```javascript -var arr1 = realarray( 5 ); -// returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - -var arr2 = realarray( 5, 'uint8' ); -// returns [ 0, 0, 0, 0, 0 ] -``` - -#### realarray( realarray\[, dtype] ) - -Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - -```javascript -var arr1 = realarray( [ 5.0, -3.0, 2.0 ] ); -// returns [ 5.0, -3.0, 2.0 ] - -var arr2 = realarray( arr1 ); -// returns [ 5.0, -3.0, 2.0 ] - -var arr3 = realarray( arr1, 'int32' ); -// returns [ 5, -3, 2 ] -``` - -#### realarray( obj\[, dtype] ) - -Creates a [typed array][mdn-typed-array] from an array-like object or iterable. - -```javascript -var arr1 = realarray( [ 0.5, 0.5, 0.5 ] ); -// returns [ 0.5, 0.5, 0.5 ] - -var arr2 = realarray( [ 0.5, 0.5, 0.5 ], 'float32' ); -// returns [ 0.5, 0.5, 0.5 ] -``` - -#### realarray( buffer\[, byteOffset\[, length]]\[, dtype] ) - -Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][mdn-arraybuffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); -var buf = new ArrayBuffer( 32 ); - -var arr1 = realarray( buf ); -// returns [ 0.0, 0.0, 0.0, 0.0 ] - -var arr2 = realarray( buf, 'float32' ); -// returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] - -var arr3 = realarray( buf, 16 ); -// returns [ 0.0, 0.0 ] - -var arr4 = realarray( buf, 16, 'float32' ); -// returns [ 0.0, 0.0, 0.0, 0.0 ] - -var arr5 = realarray( buf, 16, 1 ); -// returns [ 0.0 ] - -var arr6 = realarray( buf, 10, 4, 'int16' ); -// returns [ 0, 0, 0, 0 ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var realarray = require( '@stdlib/array/typed-real' ); - -var arr = realarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-real/benchmark/benchmark.js b/typed-real/benchmark/benchmark.js deleted file mode 100644 index c1fc183cb..000000000 --- a/typed-real/benchmark/benchmark.js +++ /dev/null @@ -1,209 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var realarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-real/benchmark/benchmark.length.float32.js b/typed-real/benchmark/benchmark.length.float32.js deleted file mode 100644 index 7b314ea4b..000000000 --- a/typed-real/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var realarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/typed-real/benchmark/benchmark.length.float64.js b/typed-real/benchmark/benchmark.length.float64.js deleted file mode 100644 index b92107d29..000000000 --- a/typed-real/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var realarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/typed-real/benchmark/benchmark.length.int16.js b/typed-real/benchmark/benchmark.length.int16.js deleted file mode 100644 index a26a41698..000000000 --- a/typed-real/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var realarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/typed-real/benchmark/benchmark.length.int32.js b/typed-real/benchmark/benchmark.length.int32.js deleted file mode 100644 index c2107bc5c..000000000 --- a/typed-real/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var realarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/typed-real/benchmark/benchmark.length.int8.js b/typed-real/benchmark/benchmark.length.int8.js deleted file mode 100644 index 5478bc9bb..000000000 --- a/typed-real/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var realarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/typed-real/benchmark/benchmark.length.uint16.js b/typed-real/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 6ff01fc72..000000000 --- a/typed-real/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var realarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/typed-real/benchmark/benchmark.length.uint32.js b/typed-real/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 312a36afd..000000000 --- a/typed-real/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var realarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/typed-real/benchmark/benchmark.length.uint8.js b/typed-real/benchmark/benchmark.length.uint8.js deleted file mode 100644 index bfb8fa124..000000000 --- a/typed-real/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var realarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/typed-real/benchmark/benchmark.length.uint8c.js b/typed-real/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 605f557dc..000000000 --- a/typed-real/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var realarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = realarray( len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/typed-real/docs/repl.txt b/typed-real/docs/repl.txt deleted file mode 100644 index 6c93288b4..000000000 --- a/typed-real/docs/repl.txt +++ /dev/null @@ -1,139 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754). - - float32: single-precision floating-point numbers (IEEE 754). - - int32: 32-bit two's complement signed integers. - - uint32: 32-bit unsigned integers. - - int16: 16-bit two's complement signed integers. - - uint16: 16-bit unsigned integers. - - int8: 8-bit two's complement signed integers. - - uint8: 8-bit unsigned integers. - - uint8c: 8-bit unsigned integers clamped to 0-255. - - The default typed array data type is `float64`. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/typed-real/docs/types/index.d.ts b/typed-real/docs/types/index.d.ts deleted file mode 100644 index 9f18f6c2b..000000000 --- a/typed-real/docs/types/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { ArrayLike, TypedArray, RealDataType as DataType } from '@stdlib/types/array'; -import ArrayBuffer = require( './../../../buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = realarray(); -* // returns -* -* @example -* var arr = realarray( 'float32'); -* // returns -*/ -declare function realarray( dtype?: DataType ): TypedArray; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = realarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = realarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function realarray( length: number, dtype?: DataType ): TypedArray; - -/** -* Creates a typed array. -* -* @param realarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = realarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = realarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = realarray( [ 5, 3 ], 'int32' ); -* var arr2 = realarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = realarray( [ 5, 3 ], 'int32' ); -* var arr2 = realarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function realarray( realarray: TypedArray, dtype?: DataType ): TypedArray; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = realarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = realarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function realarray( obj: ArrayLike | Iterable, dtype?: DataType ): TypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function realarray( buffer: ArrayBuffer, dtype?: DataType ): TypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function realarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: DataType ): TypedArray; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = realarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = realarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function realarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: DataType ): TypedArray; - - -// EXPORTS // - -export = realarray; diff --git a/typed-real/docs/types/test.ts b/typed-real/docs/types/test.ts deleted file mode 100644 index 6403af5aa..000000000 --- a/typed-real/docs/types/test.ts +++ /dev/null @@ -1,45 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 realarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array.. -{ - realarray(); // $ExpectType TypedArray - realarray( 'float32' ); // $ExpectType TypedArray - realarray( 10, 'float32' ); // $ExpectType TypedArray - realarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType TypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - realarray( true ); // $ExpectError - realarray( false ); // $ExpectError - realarray( {} ); // $ExpectError - realarray( null ); // $ExpectError - realarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - realarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/typed-real/examples/index.js b/typed-real/examples/index.js deleted file mode 100644 index 9d8907574..000000000 --- a/typed-real/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var realarray = require( './../lib' ); - -var arr = realarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -console.log( arr ); diff --git a/typed-real/lib/index.js b/typed-real/lib/index.js deleted file mode 100644 index 082fea663..000000000 --- a/typed-real/lib/index.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a typed array. -* -* @module @stdlib/array/typed-real -* -* @example -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var arr = realarray(); -* // returns -* -* @example -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var arr = realarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var arr = realarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var arr = realarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var arr = realarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var arr1 = realarray( [ 5, 3 ], 'int32' ); -* var arr2 = realarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var arr1 = realarray( [ 5, 3 ], 'int32' ); -* var arr2 = realarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = realarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var realarray = require( '@stdlib/array/typed-real' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = realarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-real/lib/main.js b/typed-real/lib/main.js deleted file mode 100644 index 986da2b12..000000000 --- a/typed-real/lib/main.js +++ /dev/null @@ -1,149 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var ctors = require( './../../typed-ctors' ); -var defaults = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.real' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} must provide a recognized data type -* @returns {TypedArray} typed array -* -* @example -* var arr = realarray(); -* // returns -* -* @example -* var arr = realarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = realarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = realarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = realarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = realarray( [ 5, 3 ], 'int32' ); -* var arr2 = realarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = realarray( [ 5, 3 ], 'int32' ); -* var arr2 = realarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = realarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = realarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = realarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function realarray() { - var nargs; - var dtype; - var ctor; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - return new ctor( arguments[0] ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = realarray; diff --git a/typed-real/package.json b/typed-real/package.json deleted file mode 100644 index 6e6ff5e64..000000000 --- a/typed-real/package.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "name": "@stdlib/array/typed-real", - "version": "0.0.0", - "description": "Create a typed array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long" - ] -} diff --git a/typed-real/test/test.js b/typed-real/test/test.js deleted file mode 100644 index 04a526e7e..000000000 --- a/typed-real/test/test.js +++ /dev/null @@ -1,1005 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var ArrayBuffer = require( './../../buffer' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var realarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof realarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'realarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - realarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'realarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - realarray( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'realarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - realarray( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'realarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - realarray( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'realarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - realarray( new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'realarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - realarray( new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'realarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - realarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = realarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = realarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = realarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = realarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = realarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = realarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = realarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = realarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = realarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = realarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = realarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = realarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = realarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = realarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = realarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = realarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = realarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = realarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = realarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = realarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = realarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = realarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = realarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = realarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = realarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = realarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = realarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = realarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = realarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = realarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = realarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = realarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = realarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = realarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = realarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = realarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = realarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = realarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = realarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = realarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = realarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = realarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = realarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = realarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = realarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = realarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = realarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = realarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = realarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = realarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = realarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = realarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = realarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = realarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = realarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); diff --git a/typed-signed-integer-ctors/README.md b/typed-signed-integer-ctors/README.md deleted file mode 100644 index c2b32e062..000000000 --- a/typed-signed-integer-ctors/README.md +++ /dev/null @@ -1,125 +0,0 @@ - - -# Constructors - -> Signed integer typed array constructors. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ctors = require( '@stdlib/array/typed-signed-integer-ctors' ); -``` - -#### ctors( dtype ) - -Returns a signed integer typed array constructor for a specified data type. - -```javascript -var ctor = ctors( 'int32' ); -// returns -``` - -The function returns constructors for the following data types: - -- `int16`: signed 16-bit integers. -- `int32`: signed 32-bit integers. -- `int8`: signed 8-bit integers. - -If provided an unknown or unsupported data type, the function returns `null`. - -```javascript -var ctor = ctors( 'int' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/typed-signed-integer-dtypes' ); -var ctors = require( '@stdlib/array/typed-signed-integer-ctors' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-signed-integer-ctors/benchmark/benchmark.js b/typed-signed-integer-ctors/benchmark/benchmark.js deleted file mode 100644 index 2ecfb878c..000000000 --- a/typed-signed-integer-ctors/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-signed-integer-dtypes' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var ctors = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var ctor; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ctor = ctors( DTYPES[ i%DTYPES.length ] ); - if ( typeof ctor !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( ctor ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-signed-integer-ctors/docs/repl.txt b/typed-signed-integer-ctors/docs/repl.txt deleted file mode 100644 index 86311b862..000000000 --- a/typed-signed-integer-ctors/docs/repl.txt +++ /dev/null @@ -1,30 +0,0 @@ - -{{alias}}( dtype ) - Returns a signed integer typed array constructor. - - The function returns constructors for the following data types: - - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - Returns - ------- - out: Function|null - Typed array constructor. - - Examples - -------- - > var ctor = {{alias}}( 'int32' ) - - > ctor = {{alias}}( 'int' ) - null - - See Also - -------- - diff --git a/typed-signed-integer-ctors/docs/types/index.d.ts b/typed-signed-integer-ctors/docs/types/index.d.ts deleted file mode 100644 index 5a99f31f9..000000000 --- a/typed-signed-integer-ctors/docs/types/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns an `Int32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int32' ); -* // returns -*/ -declare function ctors( dtype: 'int32' ): typeof Int32Array; - -/** -* Returns an `Int16Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int16' ); -* // returns -*/ -declare function ctors( dtype: 'int16' ): typeof Int16Array; - -/** -* Returns an `Int8Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'int8' ); -* // returns -*/ -declare function ctors( dtype: 'int8' ): typeof Int8Array; - -/** -* Returns a signed integer typed array constructor. -* -* @param dtype - data type -* @returns constructor or null -* -* @example -* var ctor = ctors( 'int32' ); -* // returns -* -* @example -* var ctor = ctors( 'int' ); -* // returns null -*/ -declare function ctors( dtype: string ): Function | null; - - -// EXPORTS // - -export = ctors; diff --git a/typed-signed-integer-ctors/docs/types/test.ts b/typed-signed-integer-ctors/docs/types/test.ts deleted file mode 100644 index 1df80322f..000000000 --- a/typed-signed-integer-ctors/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import ctors = require( './index' ); - - -// TESTS // - -// The function returns a function or null.. -{ - ctors( 'int32' ); // $ExpectType Int32ArrayConstructor - ctors( 'int16' ); // $ExpectType Int16ArrayConstructor - ctors( 'int8' ); // $ExpectType Int8ArrayConstructor - ctors( 'int' ); // $ExpectType Function | null -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ctors(); // $ExpectError - ctors( 'int32', 3 ); // $ExpectError -} diff --git a/typed-signed-integer-ctors/examples/index.js b/typed-signed-integer-ctors/examples/index.js deleted file mode 100644 index e1a16e4f0..000000000 --- a/typed-signed-integer-ctors/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../typed-signed-integer-dtypes' ); -var ctors = require( './../lib' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} diff --git a/typed-signed-integer-ctors/lib/ctors.js b/typed-signed-integer-ctors/lib/ctors.js deleted file mode 100644 index a75a3af18..000000000 --- a/typed-signed-integer-ctors/lib/ctors.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); - - -// MAIN // - -// Mapping from data types to constructors... -var ctors = { - 'int16': Int16Array, - 'int32': Int32Array, - 'int8': Int8Array -}; - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-signed-integer-ctors/lib/index.js b/typed-signed-integer-ctors/lib/index.js deleted file mode 100644 index 597da25dc..000000000 --- a/typed-signed-integer-ctors/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Signed integer typed array constructors. -* -* @module @stdlib/array/typed-signed-integer-ctors -* -* @example -* var ctors = require( '@stdlib/array/typed-signed-integer-ctors' ); -* -* var ctor = ctors( 'int32' ); -* // returns -* -* ctor = ctors( 'int' ); -* // returns null -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-signed-integer-ctors/lib/main.js b/typed-signed-integer-ctors/lib/main.js deleted file mode 100644 index 1bd5add35..000000000 --- a/typed-signed-integer-ctors/lib/main.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var table = require( './ctors.js' ); - - -// MAIN // - -/** -* Returns a signed integer typed array constructor. -* -* @param {string} dtype - data type -* @returns {(Function|null)} constructor or null -* -* @example -* var ctor = ctors( 'int32' ); -* // returns -* -* @example -* var ctor = ctors( 'int' ); -* // returns null -*/ -function ctors( dtype ) { - return table[ dtype ] || null; -} - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-signed-integer-ctors/package.json b/typed-signed-integer-ctors/package.json deleted file mode 100644 index 1b8af95c9..000000000 --- a/typed-signed-integer-ctors/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@stdlib/array/typed-signed-integer-ctors", - "version": "0.0.0", - "description": "Signed integer typed array constructors.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "typed array", - "typed-array", - "typed", - "dtypes", - "dtype", - "data", - "type", - "structure", - "constructors", - "constructor", - "ctors", - "ctor", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-signed-integer-ctors/test/test.js b/typed-signed-integer-ctors/test/test.js deleted file mode 100644 index 44e24f21b..000000000 --- a/typed-signed-integer-ctors/test/test.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-signed-integer-dtypes' ); -var Int16Array = require( './../../int16' ); -var Int32Array = require( './../../int32' ); -var Int8Array = require( './../../int8' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ctors = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctors, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns typed array constructors', function test( t ) { - var expected; - var dtypes; - var ctor; - var i; - - dtypes = [ - 'int16', - 'int32', - 'int8' - ]; - expected = [ - Int16Array, - Int32Array, - Int8Array - ]; - for ( i = 0; i < dtypes.length; i++ ) { - ctor = ctors( dtypes[ i ] ); - t.strictEqual( ctor, expected[ i ], 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'the function returns a constructor for each supported typed array data type', function test( t ) { - var DTYPES; - var ctor; - var i; - - DTYPES = dtypes(); - for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - - // Note: this is a weak test for a "constructor" - t.strictEqual( isFunction( ctor ), true, 'returns a function for ' + DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'binary', - 'buffer', - 'buf', - 'generic', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( ctors( dtypes[i] ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/typed-signed-integer-dtypes/README.md b/typed-signed-integer-dtypes/README.md deleted file mode 100644 index ac2bebca5..000000000 --- a/typed-signed-integer-dtypes/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# Data Types - -> List of typed array signed integer data types. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var dtypes = require( '@stdlib/array/typed-signed-integer-dtypes' ); -``` - -#### dtypes() - -Returns a list of typed array signed integer data types. - -```javascript -var out = dtypes(); -// e.g., returns [ 'int16', ... ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( '@stdlib/array/typed-signed-integer-dtypes' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'int32' ); -// returns true - -bool = isdtype( 'int16' ); -// returns true - -bool = isdtype( 'uint8' ); -// returns false - -bool = isdtype( 'beep' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-signed-integer-dtypes/benchmark/benchmark.js b/typed-signed-integer-dtypes/benchmark/benchmark.js deleted file mode 100644 index 0df6510b7..000000000 --- a/typed-signed-integer-dtypes/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var pkg = require( './../package.json' ).name; -var dtypes = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dtypes(); - if ( out.length <= 2 ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-signed-integer-dtypes/docs/repl.txt b/typed-signed-integer-dtypes/docs/repl.txt deleted file mode 100644 index a46c67f8d..000000000 --- a/typed-signed-integer-dtypes/docs/repl.txt +++ /dev/null @@ -1,17 +0,0 @@ - -{{alias}}() - Returns a list of typed array signed integer data types. - - Returns - ------- - out: Array - List of typed array signed integer data types. - - Examples - -------- - > var out = {{alias}}() - - - See Also - -------- - diff --git a/typed-signed-integer-dtypes/docs/types/index.d.ts b/typed-signed-integer-dtypes/docs/types/index.d.ts deleted file mode 100644 index 8a6cbe9da..000000000 --- a/typed-signed-integer-dtypes/docs/types/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { SignedIntegerDataType as DataType } from '@stdlib/types/array'; - -/** -* Returns a list of typed array signed integer data types. -* -* @returns list of typed array signed integer data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'int16', ... ] -*/ -declare function dtypes(): Array; - - -// EXPORTS // - -export = dtypes; diff --git a/typed-signed-integer-dtypes/docs/types/test.ts b/typed-signed-integer-dtypes/docs/types/test.ts deleted file mode 100644 index 2f78d6810..000000000 --- a/typed-signed-integer-dtypes/docs/types/test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 dtypes = require( './index' ); - - -// TESTS // - -// The function returns a string array.. -{ - dtypes(); // $ExpectType SignedIntegerDataType[] -} - -// The compiler throws an error if the function is provided arguments... -{ - dtypes( 1 ); // $ExpectError - dtypes( 1, 2 ); // $ExpectError -} diff --git a/typed-signed-integer-dtypes/examples/index.js b/typed-signed-integer-dtypes/examples/index.js deleted file mode 100644 index 8c3e403c3..000000000 --- a/typed-signed-integer-dtypes/examples/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( './../lib' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'int32' ); -console.log( bool ); -// => true - -bool = isdtype( 'int8' ); -console.log( bool ); -// => true - -bool = isdtype( 'uint8' ); -console.log( bool ); -// => false - -bool = isdtype( 'beep' ); -console.log( bool ); -// => false diff --git a/typed-signed-integer-dtypes/lib/index.js b/typed-signed-integer-dtypes/lib/index.js deleted file mode 100644 index 50c27c34d..000000000 --- a/typed-signed-integer-dtypes/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a list of typed array signed integer data types. -* -* @module @stdlib/array/typed-signed-integer-dtypes -* -* @example -* var dtypes = require( '@stdlib/array/typed-signed-integer-dtypes' ); -* -* var list = dtypes(); -* // e.g., returns [ 'int16', ... ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-signed-integer-dtypes/lib/main.js b/typed-signed-integer-dtypes/lib/main.js deleted file mode 100644 index 7911a21dd..000000000 --- a/typed-signed-integer-dtypes/lib/main.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var dt = require( './../../dtypes' ); - - -// MAIN // - -/** -* Returns a list of typed array signed integer data types. -* -* @returns {StringArray} list of typed array signed integer data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'int16', ... ] -*/ -function dtypes() { - return dt( 'signed_integer' ); -} - - -// EXPORTS // - -module.exports = dtypes; diff --git a/typed-signed-integer-dtypes/package.json b/typed-signed-integer-dtypes/package.json deleted file mode 100644 index 2085a540d..000000000 --- a/typed-signed-integer-dtypes/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/typed-signed-integer-dtypes", - "version": "0.0.0", - "description": "List of typed array signed integer data types.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "typed", - "array", - "dtypes", - "dtype", - "data", - "type", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-signed-integer-dtypes/test/test.js b/typed-signed-integer-dtypes/test/test.js deleted file mode 100644 index ed02ae8f8..000000000 --- a/typed-signed-integer-dtypes/test/test.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dt = require( './../../dtypes' ); -var dtypes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dtypes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a list of typed array data types', function test( t ) { - var expected; - var actual; - - expected = dt( 'signed_integer' ); - actual = dtypes(); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/typed-unsigned-integer-ctors/README.md b/typed-unsigned-integer-ctors/README.md deleted file mode 100644 index 573448266..000000000 --- a/typed-unsigned-integer-ctors/README.md +++ /dev/null @@ -1,126 +0,0 @@ - - -# Constructors - -> Unsigned integer typed array constructors. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var ctors = require( '@stdlib/array/typed-unsigned-integer-ctors' ); -``` - -#### ctors( dtype ) - -Returns an unsigned integer typed array constructor for a specified data type. - -```javascript -var ctor = ctors( 'uint32' ); -// returns -``` - -The function returns constructors for the following data types: - -- `uint16`: unsigned 16-bit integers. -- `uint32`: unsigned 32-bit integers. -- `uint8`: unsigned 8-bit integers. -- `uint8c`: unsigned clamped 8-bit integers. - -If provided an unknown or unsupported data type, the function returns `null`. - -```javascript -var ctor = ctors( 'uint' ); -// returns null -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/typed-unsigned-integer-dtypes' ); -var ctors = require( '@stdlib/array/typed-unsigned-integer-ctors' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-unsigned-integer-ctors/benchmark/benchmark.js b/typed-unsigned-integer-ctors/benchmark/benchmark.js deleted file mode 100644 index 79fb0dd94..000000000 --- a/typed-unsigned-integer-ctors/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-unsigned-integer-dtypes' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var pkg = require( './../package.json' ).name; -var ctors = require( './../lib' ); - - -// VARIABLES // - -var DTYPES = dtypes(); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var ctor; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - ctor = ctors( DTYPES[ i%DTYPES.length ] ); - if ( typeof ctor !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( ctor ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-unsigned-integer-ctors/docs/repl.txt b/typed-unsigned-integer-ctors/docs/repl.txt deleted file mode 100644 index 65992800b..000000000 --- a/typed-unsigned-integer-ctors/docs/repl.txt +++ /dev/null @@ -1,31 +0,0 @@ - -{{alias}}( dtype ) - Returns an unsigned integer typed array constructor. - - The function returns constructors for the following data types: - - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - Returns - ------- - out: Function|null - Typed array constructor. - - Examples - -------- - > var ctor = {{alias}}( 'uint32' ) - - > ctor = {{alias}}( 'uint' ) - null - - See Also - -------- - diff --git a/typed-unsigned-integer-ctors/docs/types/index.d.ts b/typed-unsigned-integer-ctors/docs/types/index.d.ts deleted file mode 100644 index 8eb165a55..000000000 --- a/typed-unsigned-integer-ctors/docs/types/index.d.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Returns a `Uint32Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint32' ); -* // returns -*/ -declare function ctors( dtype: 'uint32' ): typeof Uint32Array; - -/** -* Returns a `Uint16Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint16' ); -* // returns -*/ -declare function ctors( dtype: 'uint16' ): typeof Uint16Array; - -/** -* Returns a `Uint8Array` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint8' ); -* // returns -*/ -declare function ctors( dtype: 'uint8' ): typeof Uint8Array; - -/** -* Returns a `Uint8ClampedArray` constructor. -* -* @param dtype - data type -* @returns constructor -* -* @example -* var ctor = ctors( 'uint8c' ); -* // returns -*/ -declare function ctors( dtype: 'uint8c' ): typeof Uint8ClampedArray; - -/** -* Returns an unsigned integer typed array constructor. -* -* @param dtype - data type -* @returns constructor or null -* -* @example -* var ctor = ctors( 'uint32' ); -* // returns -* -* @example -* var ctor = ctors( 'uint' ); -* // returns null -*/ -declare function ctors( dtype: string ): Function | null; - - -// EXPORTS // - -export = ctors; diff --git a/typed-unsigned-integer-ctors/docs/types/test.ts b/typed-unsigned-integer-ctors/docs/types/test.ts deleted file mode 100644 index a178b1b35..000000000 --- a/typed-unsigned-integer-ctors/docs/types/test.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import ctors = require( './index' ); - - -// TESTS // - -// The function returns a function or null.. -{ - ctors( 'uint32' ); // $ExpectType Uint32ArrayConstructor - ctors( 'uint16' ); // $ExpectType Uint16ArrayConstructor - ctors( 'uint8' ); // $ExpectType Uint8ArrayConstructor - ctors( 'uint8c' ); // $ExpectType Uint8ClampedArrayConstructor - ctors( 'uint' ); // $ExpectType Function | null -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - ctors(); // $ExpectError - ctors( 'uint32', 3 ); // $ExpectError -} diff --git a/typed-unsigned-integer-ctors/examples/index.js b/typed-unsigned-integer-ctors/examples/index.js deleted file mode 100644 index 89a06deb1..000000000 --- a/typed-unsigned-integer-ctors/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../typed-unsigned-integer-dtypes' ); -var ctors = require( './../lib' ); - -var DTYPES = dtypes(); -var ctor; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - console.log( ctor ); -} diff --git a/typed-unsigned-integer-ctors/lib/ctors.js b/typed-unsigned-integer-ctors/lib/ctors.js deleted file mode 100644 index 6a9216fee..000000000 --- a/typed-unsigned-integer-ctors/lib/ctors.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); - - -// MAIN // - -// Mapping from data types to constructors... -var ctors = { - 'uint16': Uint16Array, - 'uint32': Uint32Array, - 'uint8': Uint8Array, - 'uint8c': Uint8ClampedArray -}; - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-unsigned-integer-ctors/lib/index.js b/typed-unsigned-integer-ctors/lib/index.js deleted file mode 100644 index fd10ef052..000000000 --- a/typed-unsigned-integer-ctors/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Unsigned integer typed array constructors. -* -* @module @stdlib/array/typed-unsigned-integer-ctors -* -* @example -* var ctors = require( '@stdlib/array/typed-unsigned-integer-ctors' ); -* -* var ctor = ctors( 'uint32' ); -* // returns -* -* ctor = ctors( 'uint' ); -* // returns null -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-unsigned-integer-ctors/lib/main.js b/typed-unsigned-integer-ctors/lib/main.js deleted file mode 100644 index d5078f024..000000000 --- a/typed-unsigned-integer-ctors/lib/main.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var table = require( './ctors.js' ); - - -// MAIN // - -/** -* Returns an unsigned integer typed array constructor. -* -* @param {string} dtype - data type -* @returns {(Function|null)} constructor or null -* -* @example -* var ctor = ctors( 'uint32' ); -* // returns -* -* @example -* var ctor = ctors( 'uint' ); -* // returns null -*/ -function ctors( dtype ) { - return table[ dtype ] || null; -} - - -// EXPORTS // - -module.exports = ctors; diff --git a/typed-unsigned-integer-ctors/package.json b/typed-unsigned-integer-ctors/package.json deleted file mode 100644 index 58d8bef6d..000000000 --- a/typed-unsigned-integer-ctors/package.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "@stdlib/array/typed-unsigned-integer-ctors", - "version": "0.0.0", - "description": "Unsigned integer typed array constructors.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "array", - "typed array", - "typed-array", - "typed", - "dtypes", - "dtype", - "data", - "type", - "structure", - "constructors", - "constructor", - "ctors", - "ctor", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-unsigned-integer-ctors/test/test.js b/typed-unsigned-integer-ctors/test/test.js deleted file mode 100644 index a965e058a..000000000 --- a/typed-unsigned-integer-ctors/test/test.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dtypes = require( './../../typed-unsigned-integer-dtypes' ); -var Uint16Array = require( './../../uint16' ); -var Uint32Array = require( './../../uint32' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var ctors = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctors, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns typed array constructors', function test( t ) { - var expected; - var dtypes; - var ctor; - var i; - - dtypes = [ - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - expected = [ - Uint16Array, - Uint32Array, - Uint8Array, - Uint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - ctor = ctors( dtypes[ i ] ); - t.strictEqual( ctor, expected[ i ], 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'the function returns a constructor for each supported typed array data type', function test( t ) { - var DTYPES; - var ctor; - var i; - - DTYPES = dtypes(); - for ( i = 0; i < DTYPES.length; i++ ) { - ctor = ctors( DTYPES[ i ] ); - - // Note: this is a weak test for a "constructor" - t.strictEqual( isFunction( ctor ), true, 'returns a function for ' + DTYPES[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'binary', - 'buffer', - 'buf', - 'generic', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( ctors( dtypes[i] ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/typed-unsigned-integer-dtypes/README.md b/typed-unsigned-integer-dtypes/README.md deleted file mode 100644 index 7240e0576..000000000 --- a/typed-unsigned-integer-dtypes/README.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# Data Types - -> List of typed array unsigned integer data types. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var dtypes = require( '@stdlib/array/typed-unsigned-integer-dtypes' ); -``` - -#### dtypes() - -Returns a list of typed array unsigned integer data types. - -```javascript -var out = dtypes(); -// e.g., returns [ 'uint16', ... ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( '@stdlib/array/typed-unsigned-integer-dtypes' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'uint32' ); -// returns true - -bool = isdtype( 'uint16' ); -// returns true - -bool = isdtype( 'int16' ); -// returns false - -bool = isdtype( 'beep' ); -// returns false -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed-unsigned-integer-dtypes/benchmark/benchmark.js b/typed-unsigned-integer-dtypes/benchmark/benchmark.js deleted file mode 100644 index 0df6510b7..000000000 --- a/typed-unsigned-integer-dtypes/benchmark/benchmark.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var pkg = require( './../package.json' ).name; -var dtypes = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = dtypes(); - if ( out.length <= 2 ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isStringArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed-unsigned-integer-dtypes/docs/repl.txt b/typed-unsigned-integer-dtypes/docs/repl.txt deleted file mode 100644 index 1b4f57997..000000000 --- a/typed-unsigned-integer-dtypes/docs/repl.txt +++ /dev/null @@ -1,17 +0,0 @@ - -{{alias}}() - Returns a list of typed array unsigned integer data types. - - Returns - ------- - out: Array - List of typed array unsigned integer data types. - - Examples - -------- - > var out = {{alias}}() - - - See Also - -------- - diff --git a/typed-unsigned-integer-dtypes/docs/types/index.d.ts b/typed-unsigned-integer-dtypes/docs/types/index.d.ts deleted file mode 100644 index 440975a30..000000000 --- a/typed-unsigned-integer-dtypes/docs/types/index.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { UnsignedIntegerDataType as DataType } from '@stdlib/types/array'; - -/** -* Returns a list of typed array unsigned integer data types. -* -* @returns list of typed array unsigned integer data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'uint16', ... ] -*/ -declare function dtypes(): Array; - - -// EXPORTS // - -export = dtypes; diff --git a/typed-unsigned-integer-dtypes/docs/types/test.ts b/typed-unsigned-integer-dtypes/docs/types/test.ts deleted file mode 100644 index dac8fe20f..000000000 --- a/typed-unsigned-integer-dtypes/docs/types/test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 dtypes = require( './index' ); - - -// TESTS // - -// The function returns a string array.. -{ - dtypes(); // $ExpectType UnsignedIntegerDataType[] -} - -// The compiler throws an error if the function is provided arguments... -{ - dtypes( 1 ); // $ExpectError - dtypes( 1, 2 ); // $ExpectError -} diff --git a/typed-unsigned-integer-dtypes/examples/index.js b/typed-unsigned-integer-dtypes/examples/index.js deleted file mode 100644 index 58305dc3d..000000000 --- a/typed-unsigned-integer-dtypes/examples/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 indexOf = require( '@stdlib/utils/index-of' ); -var dtypes = require( './../lib' ); - -var DTYPES = dtypes(); - -function isdtype( str ) { - if ( indexOf( DTYPES, str ) === -1 ) { - return false; - } - return true; -} - -var bool = isdtype( 'uint32' ); -console.log( bool ); -// => true - -bool = isdtype( 'uint8' ); -console.log( bool ); -// => true - -bool = isdtype( 'int16' ); -console.log( bool ); -// => false - -bool = isdtype( 'beep' ); -console.log( bool ); -// => false diff --git a/typed-unsigned-integer-dtypes/lib/index.js b/typed-unsigned-integer-dtypes/lib/index.js deleted file mode 100644 index 04039217d..000000000 --- a/typed-unsigned-integer-dtypes/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return a list of typed array unsigned integer data types. -* -* @module @stdlib/array/typed-unsigned-integer-dtypes -* -* @example -* var dtypes = require( '@stdlib/array/typed-unsigned-integer-dtypes' ); -* -* var list = dtypes(); -* // e.g., returns [ 'uint16', ... ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed-unsigned-integer-dtypes/lib/main.js b/typed-unsigned-integer-dtypes/lib/main.js deleted file mode 100644 index 36106d1b1..000000000 --- a/typed-unsigned-integer-dtypes/lib/main.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var dt = require( './../../dtypes' ); - - -// MAIN // - -/** -* Returns a list of typed array unsigned integer data types. -* -* @returns {StringArray} list of typed array unsigned integer data types -* -* @example -* var list = dtypes(); -* // e.g., returns [ 'uint16', ... ] -*/ -function dtypes() { - return dt( 'unsigned_integer' ); -} - - -// EXPORTS // - -module.exports = dtypes; diff --git a/typed-unsigned-integer-dtypes/package.json b/typed-unsigned-integer-dtypes/package.json deleted file mode 100644 index 1e1403656..000000000 --- a/typed-unsigned-integer-dtypes/package.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "name": "@stdlib/array/typed-unsigned-integer-dtypes", - "version": "0.0.0", - "description": "List of typed array unsigned integer data types.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "typed", - "array", - "dtypes", - "dtype", - "data", - "type", - "utilities", - "utility", - "utils", - "util" - ], - "__stdlib__": {} -} diff --git a/typed-unsigned-integer-dtypes/test/test.js b/typed-unsigned-integer-dtypes/test/test.js deleted file mode 100644 index d84010835..000000000 --- a/typed-unsigned-integer-dtypes/test/test.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 dt = require( './../../dtypes' ); -var dtypes = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dtypes, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns a list of typed array data types', function test( t ) { - var expected; - var actual; - - expected = dt( 'unsigned_integer' ); - actual = dtypes(); - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); diff --git a/typed/README.md b/typed/README.md deleted file mode 100644 index de9363548..000000000 --- a/typed/README.md +++ /dev/null @@ -1,238 +0,0 @@ - - -# typedarray - -> Create a typed array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var typedarray = require( '@stdlib/array/typed' ); -``` - -#### typedarray( \[dtype] ) - -Creates a [typed array][mdn-typed-array] having a specified [data type][@stdlib/array/typed-dtypes]. - -```javascript -var arr = typedarray(); -// returns -``` - -By default, the output [typed array][mdn-typed-array] data type is `float64`. To specify an alternative data type, provide a [`dtype`][@stdlib/array/typed-dtypes] argument. - -```javascript -var arr = typedarray( 'int32' ); -// returns -``` - -#### typedarray( length\[, dtype] ) - -Returns a [typed array][mdn-typed-array] having a specified `length`. - -```javascript -var arr1 = typedarray( 5 ); -// returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - -var arr2 = typedarray( 5, 'uint8' ); -// returns [ 0, 0, 0, 0, 0 ] -``` - -#### typedarray( typedarray\[, dtype] ) - -Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - -```javascript -var arr1 = typedarray( [ 5.0, -3.0, 2.0 ] ); -// returns [ 5.0, -3.0, 2.0 ] - -var arr2 = typedarray( arr1 ); -// returns [ 5.0, -3.0, 2.0 ] - -var arr3 = typedarray( arr1, 'int32' ); -// returns [ 5, -3, 2 ] -``` - -#### typedarray( obj\[, dtype] ) - -Creates a [typed array][mdn-typed-array] from an array-like object or iterable. - -```javascript -var arr1 = typedarray( [ 0.5, 0.5, 0.5 ] ); -// returns [ 0.5, 0.5, 0.5 ] - -var arr2 = typedarray( [ 0.5, 0.5, 0.5 ], 'float32' ); -// returns [ 0.5, 0.5, 0.5 ] -``` - -If [`dtype`][@stdlib/array/typed-dtypes] is complex number data type and an array-like object contains interleaved real and imaginary components, the array-like object must have a length which is a multiple of two. - -#### typedarray( buffer\[, byteOffset\[, length]]\[, dtype] ) - -Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][mdn-arraybuffer]. - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); -var buf = new ArrayBuffer( 32 ); - -var arr1 = typedarray( buf ); -// returns [ 0.0, 0.0, 0.0, 0.0 ] - -var arr2 = typedarray( buf, 'float32' ); -// returns [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] - -var arr3 = typedarray( buf, 16 ); -// returns [ 0.0, 0.0 ] - -var arr4 = typedarray( buf, 16, 'float32' ); -// returns [ 0.0, 0.0, 0.0, 0.0 ] - -var arr5 = typedarray( buf, 16, 1 ); -// returns [ 0.0 ] - -var arr6 = typedarray( buf, 10, 4, 'int16' ); -// returns [ 0, 0, 0, 0 ] -``` - -
- - - - - -
- -## Notes - -- When providing a complex number array, if [`dtype`][@stdlib/array/typed-dtypes] is unspecified or the specified data type is not a complex number data type, the returned array contains interleaved real and imaginary components. - -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var typedarray = require( '@stdlib/array/typed' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/typed/benchmark/benchmark.js b/typed/benchmark/benchmark.js deleted file mode 100644 index 265d7f3f6..000000000 --- a/typed/benchmark/benchmark.js +++ /dev/null @@ -1,265 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'bool' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/typed/benchmark/benchmark.length.bool.js b/typed/benchmark/benchmark.length.bool.js deleted file mode 100644 index 08097a6f0..000000000 --- a/typed/benchmark/benchmark.length.bool.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isBooleanArray = require( '@stdlib/assert/is-booleanarray' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'bool' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isBooleanArray( arr ) ) { - b.fail( 'should return a boolean array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=bool,len='+len, f ); - } -} - -main(); diff --git a/typed/benchmark/benchmark.length.complex128.js b/typed/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 0d479fe6b..000000000 --- a/typed/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/typed/benchmark/benchmark.length.complex64.js b/typed/benchmark/benchmark.length.complex64.js deleted file mode 100644 index f0535a8c2..000000000 --- a/typed/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isComplexTypedArray = require( '@stdlib/assert/is-complex-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isComplexTypedArray( arr ) ) { - b.fail( 'should return a complex typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/typed/benchmark/benchmark.length.float32.js b/typed/benchmark/benchmark.length.float32.js deleted file mode 100644 index 316a3d1ef..000000000 --- a/typed/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/typed/benchmark/benchmark.length.float64.js b/typed/benchmark/benchmark.length.float64.js deleted file mode 100644 index 3693b12ac..000000000 --- a/typed/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/typed/benchmark/benchmark.length.int16.js b/typed/benchmark/benchmark.length.int16.js deleted file mode 100644 index 39946d32c..000000000 --- a/typed/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/typed/benchmark/benchmark.length.int32.js b/typed/benchmark/benchmark.length.int32.js deleted file mode 100644 index 32a75125c..000000000 --- a/typed/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/typed/benchmark/benchmark.length.int8.js b/typed/benchmark/benchmark.length.int8.js deleted file mode 100644 index fdd4fa3a4..000000000 --- a/typed/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/typed/benchmark/benchmark.length.uint16.js b/typed/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 1c92537b0..000000000 --- a/typed/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/typed/benchmark/benchmark.length.uint32.js b/typed/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 069fbf2a2..000000000 --- a/typed/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/typed/benchmark/benchmark.length.uint8.js b/typed/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 74f2179f5..000000000 --- a/typed/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/typed/benchmark/benchmark.length.uint8c.js b/typed/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 3b11bd993..000000000 --- a/typed/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var typedarray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = typedarray( len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/typed/docs/repl.txt b/typed/docs/repl.txt deleted file mode 100644 index 11b947d01..000000000 --- a/typed/docs/repl.txt +++ /dev/null @@ -1,125 +0,0 @@ - -{{alias}}( [dtype] ) - Creates a typed array. - - Parameters - ---------- - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}() - - > arr = {{alias}}( 'float32' ) - - - -{{alias}}( length[, dtype] ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}( 5 ) - [ 0.0, 0.0, 0.0, 0.0, 0.0 ] - > arr = {{alias}}( 5, 'int32' ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray[, dtype] ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = {{alias}}( [ 0.5, 0.5, 0.5 ] ); - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( obj[, dtype] ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var arr1 = [ 0.5, 0.5, 0.5 ]; - > var arr2 = {{alias}}( arr1, 'float32' ) - [ 0.5, 0.5, 0.5 ] - - -{{alias}}( buffer[, byteOffset[, length]][, dtype] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = {{alias}}( buf, 0, 4, 'float32' ) - [ 0.0, 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/typed/docs/types/index.d.ts b/typed/docs/types/index.d.ts deleted file mode 100644 index 7e1db6c6e..000000000 --- a/typed/docs/types/index.d.ts +++ /dev/null @@ -1,180 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/* eslint-disable @typescript-eslint/unified-signatures */ - -/// - -import { RealOrComplexTypedArray, TypedDataTypeMap, Collection } from '@stdlib/types/array'; -import ArrayBuffer = require( './../../../buffer' ); - -/** -* Creates a typed array. -* -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 'float32'); -* // returns -*/ -declare function typedarray( dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param length - typed array length -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( length: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param typedarray - typed array from which to generate another typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( new Float64Array( 2 ) ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( new Float64Array( 2 ), 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -*/ -declare function typedarray( typedarray: RealOrComplexTypedArray, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param obj - array-like object or iterable from which to generate a typed array -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -*/ -declare function typedarray( obj: Collection | Iterable, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, dtype?: T ): TypedDataTypeMap[T]; - -/** -* Creates a typed array. -* -* @param buffer - underlying ArrayBuffer -* @param byteOffset - integer byte offset specifying the location of the first typed array element (default: 0) -* @param length - view length; if not provided, the view spans from the byteOffset to the end of the underlying ArrayBuffer -* @param dtype - data type (default: 'float64') -* @returns typed array -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -declare function typedarray( buffer: ArrayBuffer, byteOffset?: number, length?: number, dtype?: T ): TypedDataTypeMap[T]; - - -// EXPORTS // - -export = typedarray; diff --git a/typed/docs/types/test.ts b/typed/docs/types/test.ts deleted file mode 100644 index 6377913aa..000000000 --- a/typed/docs/types/test.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ArrayBuffer = require( './../../../buffer' ); -import typedarray = require( './index' ); - - -// TESTS // - -// The function returns a typed array... -{ - typedarray(); // $ExpectType Float64Array - typedarray( [ 1, 2, 3 ] ); // $ExpectType Float64Array - typedarray( new ArrayBuffer( 10 ) ); // $ExpectType Float64Array - - typedarray( 'float32' ); // $ExpectType Float32Array - typedarray( 10, 'float32' ); // $ExpectType Float32Array - typedarray( [ 1, 2, 3 ], 'int32' ); // $ExpectType Int32Array -} - -// The compiler throws an error if the function is provided a first argument which is not a data type, number, array-like object, or typed array... -{ - typedarray( true ); // $ExpectError - typedarray( false ); // $ExpectError - typedarray( {} ); // $ExpectError - typedarray( null ); // $ExpectError - typedarray( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const buf = new ArrayBuffer( 32 ); - typedarray( buf, 8, 2, 'int32', {} ); // $ExpectError -} diff --git a/typed/examples/index.js b/typed/examples/index.js deleted file mode 100644 index 11add274b..000000000 --- a/typed/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var typedarray = require( './../lib' ); - -var arr = typedarray( 100, 'float64' ); - -var i; -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = randu() * 100.0; -} -console.log( arr ); diff --git a/typed/lib/index.js b/typed/lib/index.js deleted file mode 100644 index 97c1de867..000000000 --- a/typed/lib/index.js +++ /dev/null @@ -1,126 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a typed array. -* -* @module @stdlib/array/typed -* -* @example -* var typedarray = require( '@stdlib/array/typed' ); -* -* var arr = typedarray(); -* // returns -* -* @example -* var typedarray = require( '@stdlib/array/typed' ); -* -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array/typed' ); -* -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var typedarray = require( '@stdlib/array/typed' ); -* -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var typedarray = require( '@stdlib/array/typed' ); -* -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var typedarray = require( '@stdlib/array/typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var typedarray = require( '@stdlib/array/typed' ); -* -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var typedarray = require( '@stdlib/array/typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var typedarray = require( '@stdlib/array/typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var typedarray = require( '@stdlib/array/typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var typedarray = require( '@stdlib/array/typed' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var typedarray = require( '@stdlib/array/typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* var typedarray = require( '@stdlib/array/typed' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/typed/lib/main.js b/typed/lib/main.js deleted file mode 100644 index 5cb8a082b..000000000 --- a/typed/lib/main.js +++ /dev/null @@ -1,166 +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. -*/ - -'use strict'; - -// MODULES // - -var isString = require( '@stdlib/assert/is-string' ).isPrimitive; -var ctors = require( './../../typed-ctors' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var defaults = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); -var Complex64Array = ctors( 'complex64' ); -var Complex128Array = ctors( 'complex128' ); -var BooleanArray = ctors( 'bool' ); - - -// MAIN // - -/** -* Creates a typed array. -* -* @param {(NonNegativeInteger|ComplexArray|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer -* @param {NonNegativeInteger} [byteOffset=0] - byte offset -* @param {NonNegativeInteger} [length] - view length -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} must provide a recognized data type -* @returns {(ComplexArray|TypedArray)} typed array -* -* @example -* var arr = typedarray(); -* // returns -* -* @example -* var arr = typedarray( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = typedarray( [ 0.5, 0.5 ] ); -* // returns [ 0.5, 0.5 ] -* -* @example -* var arr = typedarray( [ 5, -3 ], 'int32' ); -* // returns [ 5, -3 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1 ); -* // returns [ 5.0, 3.0 ] -* -* @example -* var arr1 = typedarray( [ 5, 3 ], 'int32' ); -* var arr2 = typedarray( arr1, 'uint32' ); -* // returns [ 5, 3 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 'float32' ); -* // returns [ 0.0, 0.0, 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8 ); -* // returns [ 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 16 ); -* var arr = typedarray( buf, 8, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var ArrayBuffer = require( '@stdlib/array/buffer' ); -* -* var buf = new ArrayBuffer( 32 ); -* var arr = typedarray( buf, 8, 2, 'int32' ); -* // returns [ 0, 0 ] -*/ -function typedarray() { - var nargs; - var dtype; - var ctor; - var arg; - - nargs = arguments.length; - if ( nargs && isString( arguments[ nargs-1 ] ) ) { - nargs -= 1; - dtype = arguments[ nargs ]; - } else { - dtype = DEFAULT_DTYPE; - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) ); - } - if ( nargs <= 0 ) { - return new ctor( 0 ); - } - if ( nargs === 1 ) { - arg = arguments[ 0 ]; - - // Note: the following checks are not particularly robust, as `instanceof` will fail for cross-realm instances... - if ( arg instanceof Complex64Array ) { - arg = reinterpret64( arg, 0 ); - } else if ( arg instanceof Complex128Array ) { - arg = reinterpret128( arg, 0 ); - } else if ( arg instanceof BooleanArray ) { - arg = reinterpretBoolean( arg, 0 ); - } - return new ctor( arg ); - } - if ( nargs === 2 ) { - return new ctor( arguments[0], arguments[1] ); - } - return new ctor( arguments[0], arguments[1], arguments[2] ); -} - - -// EXPORTS // - -module.exports = typedarray; diff --git a/typed/package.json b/typed/package.json deleted file mode 100644 index b80e9e432..000000000 --- a/typed/package.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "name": "@stdlib/array/typed", - "version": "0.0.0", - "description": "Create a typed array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex64array", - "complex128array", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "complex", - "cmplx" - ] -} diff --git a/typed/test/test.js b/typed/test/test.js deleted file mode 100644 index f776d8b60..000000000 --- a/typed/test/test.js +++ /dev/null @@ -1,1575 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex128Array = require( './../../complex128' ); -var Complex64Array = require( './../../complex64' ); -var BooleanArray = require( './../../bool' ); -var ArrayBuffer = require( './../../buffer' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpretBoolean = require( '@stdlib/strided/base/reinterpret-boolean' ); -var typedarray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof typedarray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an unrecognized data type (only argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( 10, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new Float64Array( 10 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( [ 1, 2, 3 ], value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, value ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'typedarray', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - typedarray( new ArrayBuffer( 16 ), 0, 1, value ); - }; - } -}); - -tape( 'the function returns a typed array (default)', function test( t ) { - var arr = typedarray(); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64)', function test( t ) { - var arr = typedarray( 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32)', function test( t ) { - var arr = typedarray( 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128)', function test( t ) { - var arr = typedarray( 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64)', function test( t ) { - var arr = typedarray( 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool)', function test( t ) { - var arr = typedarray( 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32)', function test( t ) { - var arr = typedarray( 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32)', function test( t ) { - var arr = typedarray( 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16)', function test( t ) { - var arr = typedarray( 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16)', function test( t ) { - var arr = typedarray( 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8)', function test( t ) { - var arr = typedarray( 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8)', function test( t ) { - var arr = typedarray( 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c)', function test( t ) { - var arr = typedarray( 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, length)', function test( t ) { - var arr = typedarray( 10 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, length)', function test( t ) { - var arr = typedarray( 10, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, length)', function test( t ) { - var arr = typedarray( 10, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, length)', function test( t ) { - var arr = typedarray( 10, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, length)', function test( t ) { - var arr = typedarray( 10, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, length)', function test( t ) { - var arr = typedarray( 10, 'bool' ); - t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, length)', function test( t ) { - var arr = typedarray( 10, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, length)', function test( t ) { - var arr = typedarray( 10, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, length)', function test( t ) { - var arr = typedarray( 10, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, length)', function test( t ) { - var arr = typedarray( 10, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, length)', function test( t ) { - var arr = typedarray( 10, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, length)', function test( t ) { - var arr = typedarray( 10, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, length)', function test( t ) { - var arr = typedarray( 10, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, 10, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1.0, 2.0, 3.0, 4.0 ]; - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, array)', function test( t ) { - var view; - var arr; - var out; - - arr = [ 1, 0, 0, 1 ]; - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, array)', function test( t ) { - var arr = [ 1.0, 2.0, 3.0 ]; - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, typed array)', function test( t ) { - var arr = new Uint32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Uint8Array( [ 1, 0, 1, 0 ] ); - out = typedarray( arr, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( view[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( view[ 2 ], arr[ 2 ], 'returns expected value' ); - t.strictEqual( view[ 3 ], arr[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, typed array)', function test( t ) { - var arr = new Uint8ClampedArray( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, typed array)', function test( t ) { - var arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, typed array)', function test( t ) { - var arr = new Int8Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, typed array)', function test( t ) { - var arr = new Int16Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, typed array)', function test( t ) { - var arr = new Int32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, typed array)', function test( t ) { - var arr = new Float32Array( [ 1.0, 2.0, 3.0 ] ); - var out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], arr[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], arr[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], arr[ 2 ], 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret64( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret64( arr, 0 ); - viewY = reinterpret128( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, complex typed array)', function test( t ) { - var viewX; - var viewY; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - out = typedarray( arr, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - viewX = reinterpret128( arr, 0 ); - viewY = reinterpret64( out, 0 ); - t.strictEqual( viewY[ 0 ], viewX[ 0 ], 'returns expected value' ); - t.strictEqual( viewY[ 1 ], viewX[ 1 ], 'returns expected value' ); - t.strictEqual( viewY[ 2 ], viewX[ 2 ], 'returns expected value' ); - t.strictEqual( viewY[ 3 ], viewX[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, complex typed array)', function test( t ) { - var view; - var arr; - var out; - - arr = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - // Note: this is effectively a reinterpretation of the complex number array as an array of interleaved real and imaginary components - out = typedarray( arr, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - - view = reinterpret128( arr, 0 ); - t.strictEqual( out[ 0 ], view[ 0 ], 'returns expected value' ); - t.strictEqual( out[ 1 ], view[ 1 ], 'returns expected value' ); - t.strictEqual( out[ 2 ], view[ 2 ], 'returns expected value' ); - t.strictEqual( out[ 3 ], view[ 3 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 8 ); - out = typedarray( buf, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 4, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer)', function test( t ) { - var buf = new ArrayBuffer( 8 ); - var out = typedarray( buf, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 8, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 16, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 16 ); - out = typedarray( buf, 8, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 2 ); - out = typedarray( buf, 1, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 1, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 3, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 6, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 12, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.strictEqual( out[ 2 ], 0, 'returns expected value' ); - t.strictEqual( out[ 3 ], 0, 'returns expected value' ); - t.strictEqual( out[ 4 ], 0, 'returns expected value' ); - t.strictEqual( out[ 5 ], 0, 'returns expected value' ); - t.strictEqual( out[ 6 ], 0, 'returns expected value' ); - t.strictEqual( out[ 7 ], 0, 'returns expected value' ); - t.strictEqual( out[ 8 ], 0, 'returns expected value' ); - t.strictEqual( out[ 9 ], 0, 'returns expected value' ); - t.strictEqual( out[ 10 ], 0, 'returns expected value' ); - t.strictEqual( out[ 11 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (default, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2 ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 32 ); - var out = typedarray( buf, 8, 2, 'float64' ); - t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'float32' ); - t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0.0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 64 ); - out = typedarray( buf, 16, 2, 'complex128' ); - t.strictEqual( instanceOf( out, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret128( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=complex64, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 32 ); - out = typedarray( buf, 8, 2, 'complex64' ); - t.strictEqual( instanceOf( out, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpret64( out, 0 ); - t.strictEqual( view[ 0 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 2 ], 0.0, 'returns expected value' ); - t.strictEqual( view[ 3 ], 0.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { - var view; - var buf; - var out; - - buf = new ArrayBuffer( 4 ); - out = typedarray( buf, 1, 2, 'bool' ); - t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - - view = reinterpretBoolean( out, 0 ); - t.strictEqual( view[ 0 ], 0, 'returns expected value' ); - t.strictEqual( view[ 1 ], 0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int32' ); - t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint32' ); - t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int16' ); - t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint16' ); - t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'int8' ); - t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8' ); - t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns a typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { - var buf = new ArrayBuffer( 16 ); - var out = typedarray( buf, 4, 2, 'uint8c' ); - t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( out.length, 2, 'returns expected value' ); - t.strictEqual( out[ 0 ], 0, 'returns expected value' ); - t.strictEqual( out[ 1 ], 0, 'returns expected value' ); - t.end(); -}); diff --git a/uint16/README.md b/uint16/README.md deleted file mode 100644 index ec87637a9..000000000 --- a/uint16/README.md +++ /dev/null @@ -1,1473 +0,0 @@ - - -# Uint16Array - -> [Typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of 16-bit unsigned integers in the platform byte order. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Uint16Array = require( '@stdlib/array/uint16' ); -``` - -#### Uint16Array() - -A [typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of 16-bit unsigned integers in the platform byte order. - - - -```javascript -var arr = new Uint16Array(); -// returns -``` - -#### Uint16Array( length ) - -Returns a [typed array][mdn-typed-array] having a specified length. - - - -```javascript -var arr = new Uint16Array( 5 ); -// returns [ 0, 0, 0, 0, 0 ] -``` - -#### Uint16Array( typedarray ) - -Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - - - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 5.0, 5.0, 5.0 ] ); -var arr2 = new Uint16Array( arr1 ); -// returns [ 5, 5, 5 ] -``` - -#### Uint16Array( obj ) - -Creates a [typed array][mdn-typed-array] from an array-like `object` or iterable. - - - -```javascript -var arr = new Uint16Array( [ 5.0, 5.0, 5.0 ] ); -// returns [ 5, 5, 5 ] -``` - -#### Uint16Array( buffer\[, byteOffset\[, length]] ) - -Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 8 ); -var arr = new Uint16Array( buf, 0, 4 ); -// returns [ 0, 0, 0, 0 ] -``` - -* * * - -### Properties - - - -#### Uint16Array.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var nbytes = Uint16Array.BYTES_PER_ELEMENT; -// returns 2 -``` - - - -#### Uint16Array.name - -[Typed array][mdn-typed-array] constructor name. - - - -```javascript -var str = Uint16Array.name; -// returns 'Uint16Array' -``` - - - -#### Uint16Array.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Uint16Array( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Uint16Array.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Uint16Array( 5 ); -var byteLength = arr.byteLength; -// returns 10 -``` - - - -#### Uint16Array.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the [typed array][mdn-typed-array] from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var arr = new Uint16Array( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Uint16Array.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var arr = new Uint16Array( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 2 -``` - - - -#### Uint16Array.prototype.length - -**Read-only** property which returns the number of view elements. - - - -```javascript -var arr = new Uint16Array( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Uint16Array.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like `object` or an iterable. - -```javascript -var arr = Uint16Array.from( [ 1, 2 ] ); -// returns [ 1, 2 ] -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2; -} - -var arr = Uint16Array.from( [ 1, 2 ], mapFcn ); -// returns [ 2, 4 ] -``` - -A callback function is provided two arguments: - -- `value`: source value. -- `index`: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr = Uint16Array.from( [ 1, 2 ], mapFcn, ctx ); -// returns [ 2, 4 ] - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint16Array.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Uint16Array.of( 1, 2 ); -// returns [ 1, 2 ] -``` - - - -#### Uint16Array.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within an array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 3 ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( 3, 0, 2 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( -2, -5, -3 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - - - -#### Uint16Array.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - - - -```javascript -var arr = new Uint16Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.entries(); - -// Iterate over key-value pairs... -var v = it.next().value; -// returns [ 0, 1 ] - -v = it.next().value; -// returns [ 1, 2 ] - -var bool = it.next().done; -// returns true -``` - - - -#### Uint16Array.prototype.every( predicate\[, thisArg] ) - -Tests whether all array elements pass a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v <= 1 ); -} - -var arr = new Uint16Array( [ 1, 2 ] ); - -var bool = arr.every( predicate ); -// returns false -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 1 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint16Array( [ 1, 2 ] ); - -var bool = arr.every( predicate, ctx ); -// returns true - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint16Array.prototype.fill( value\[, start\[, end]] ) - -Fills an array from a `start` index to an `end` index (non-inclusive) with a provided `value`. - - - -```javascript -var arr = new Uint16Array( 2 ); - -// Set all array elements to the same value: -arr.fill( 2 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 2 - -// Set all array elements starting from the first index to the same value: -arr.fill( 3, 1 ); - -v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 3 - -// Set all array elements, except the last element, to the same value: -arr.fill( 4, 0, arr.length-1 ); - -v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 3 -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr = new Uint16Array( 2 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( 2, -arr.length, -1 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 0 -``` - - - -#### Uint16Array.prototype.filter( predicate\[, thisArg] ) - -Creates a new array (of the same data type as the host array) which includes those elements for which a `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [ 2, 3 ] -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns an empty array. - - - -```javascript -function predicate( v ) { - return ( v >= 10 ); -} - -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [] -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint16Array.prototype.find( predicate\[, thisArg] ) - -Returns the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v > 2 ); -} - -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns 3 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `undefined`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns undefined -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v > 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate, ctx ); -// returns 3 - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint16Array.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 3 ); -} - -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns 2 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `-1`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns -1 -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 3 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate, ctx ); -// returns 2 - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint16Array.prototype.forEach( fcn\[, thisArg] ) - -Invokes a callback for each array element. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var str = ''; - -function fcn( v, i ) { - str += i + ':' + v; - if ( i < arr.length-1 ) { - str += ' '; - } -} - -arr.forEach( fcn ); - -console.log( str ); -// => '0:1 1:2 2:3' -``` - -The callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn() { - this.count += 1; -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -arr.forEach( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint16Array.prototype.includes( searchElement\[, fromIndex] ) - -Returns a `boolean` indicating whether an array includes a search element. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 3 ); -// returns true - -bool = arr.includes( 0 ); -// returns false -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, 1 ); -// returns false -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, -2 ); -// returns false -``` - - - -#### Uint16Array.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the index of the first array element strictly equal to a search element. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 3 ); -// returns 2 - -idx = arr.indexOf( 0 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, 1 ); -// returns -1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, -2 ); -// returns -1 -``` - - - -#### Uint16Array.prototype.join( \[separator] ) - -Serializes an array by joining all array elements as a string. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var str = arr.join(); -// returns '1,2,3' -``` - -By default, the method delineates array elements using a comma `,`. To specify a custom separator, provide a `separator` string. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var str = arr.join( '|' ); -// returns '1|2|3' -``` - - - -#### Uint16Array.prototype.keys() - -Returns an iterator for iterating over array keys. - - - -```javascript -var arr = new Uint16Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.keys(); - -// Iterate over keys... -var v = it.next().value; -// returns 0 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - - - -#### Uint16Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the index of the last array element strictly equal to a search element, iterating from right to left. - - - -```javascript -var arr = new Uint16Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0 ); -// returns 3 - -idx = arr.lastIndexOf( 3 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = -1`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint16Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, 2 ); -// returns 1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint16Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, -3 ); -// returns 1 -``` - - - -#### Uint16Array.prototype.map( fcn\[, thisArg] ) - -Maps each array element to an element in a new array having the same data type as the host array. - - - -```javascript -function fcn( v ) { - return v * 2; -} - -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn ); -// returns [ 2, 4, 6 ] -``` - -A callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint16Array.prototype.reduce( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint16Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn ); -// returns 12 -``` - -If not provided an initial value, the method invokes a provided function with the first array element as the first argument and the second array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the first array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint16Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Uint16Array.prototype.reduceRight( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result, iterating from right to left. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint16Array( [ 2, 1, 3 ] ); - -var v = arr.reduceRight( fcn ); -// returns 8 -``` - -If not provided an initial value, the method invokes a provided function with the last array element as the first argument and the second-to-last array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the last array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint16Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Uint16Array.prototype.reverse() - -Reverses an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Uint16Array( [ 2, 0, 3 ] ); - -// Reverse the array: -arr.reverse(); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 0 - -v = arr[ 2 ]; -// returns 2 -``` - - - -#### Uint16Array.prototype.set( arr\[, offset] ) - -Sets array elements. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the first two array elements: -arr.set( [ 4, 5 ] ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the last two array elements: -arr.set( [ 4, 5 ], 1 ); - -var v = arr[ 1 ]; -// returns 4 - -v = arr[ 2 ]; -// returns 5 -``` - - - -#### Uint16Array.prototype.slice( \[begin\[, end]] ) - -Copies array elements to a new array with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice(); - -var bool = ( arr1 === arr2 ); -// returns false - -bool = ( arr1.buffer === arr2.buffer ); -// returns false - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 - -v = arr2[ 2 ]; -// returns 3 -``` - -By default, the method copies elements beginning with the first array element. To specify an alternative array index at which to begin copying, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 2 - -v = arr2[ 1 ]; -// returns 3 -``` - -By default, the method copies all array elements after `begin`. To specify an alternative array index at which to end copying, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 0, 2 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( -arr1.length, -1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - - - -#### Uint16Array.prototype.some( predicate\[, thisArg] ) - -Tests whether at least one array element passes a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr = new Uint16Array( [ 1, 2 ] ); - -var bool = arr.some( predicate ); -// returns true -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint16Array( [ 1, 1 ] ); - -var bool = arr.some( predicate, ctx ); -// returns false - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint16Array.prototype.sort( \[compareFunction] ) - -Sorts an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Uint16Array( [ 2, 3, 0 ] ); - -// Sort the array (in ascending order): -arr.sort(); - -var v = arr[ 0 ]; -// returns 0 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 3 -``` - -By default, the method sorts array elements in ascending order. To impose a custom order, provide a `compareFunction`. - - - -```javascript -function descending( a, b ) { - return b - a; -} - -var arr = new Uint16Array( [ 2, 3, 0 ] ); - -// Sort the array (in descending order): -arr.sort( descending ); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 0 -``` - -The comparison function is provided two array elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: - -- If the comparison function returns a value **less** than zero, then the method sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). -- If the comparison function returns a value **greater** than zero, then the method sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). -- If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. - - - -#### Uint16Array.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray(); -// returns [ 1, 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 1 ); -// returns [ 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 0, 2 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( -arr1.length, -1 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -If the method is unable to resolve indices to a non-empty array subsequence, the method returns an empty typed array. - - - -```javascript -var arr1 = new Uint16Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 10, -1 ); -// returns [] -``` - - - -#### Uint16Array.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific `string`. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var str = arr.toLocaleString(); -// returns '1,2,3' -``` - - - -#### Uint16Array.prototype.toString() - -Serializes an array as a `string`. - - - -```javascript -var arr = new Uint16Array( [ 1, 2, 3 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - - - -#### Uint16Array.prototype.values() - -Returns an iterator for iterating over array elements. - - - -```javascript -var arr = new Uint16Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.values(); - -// Iterate over array elements... -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -var bool = it.next().done; -// returns true -``` - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( '@stdlib/array/uint16' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/uint16/benchmark/benchmark.copy_within.js b/uint16/benchmark/benchmark.copy_within.js deleted file mode 100644 index 7c903c34f..000000000 --- a/uint16/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.copy_within.length.js b/uint16/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 84e9cd61c..000000000 --- a/uint16/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.data.js b/uint16/benchmark/benchmark.data.js deleted file mode 100644 index fb912ea2b..000000000 --- a/uint16/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.entries.js b/uint16/benchmark/benchmark.entries.js deleted file mode 100644 index 072c7c53b..000000000 --- a/uint16/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.every.js b/uint16/benchmark/benchmark.every.js deleted file mode 100644 index 93a5d357c..000000000 --- a/uint16/benchmark/benchmark.every.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/uint16/benchmark/benchmark.every.length.js b/uint16/benchmark/benchmark.every.length.js deleted file mode 100644 index 3340d9833..000000000 --- a/uint16/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.fill.js b/uint16/benchmark/benchmark.fill.js deleted file mode 100644 index f0983e0d6..000000000 --- a/uint16/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.fill.length.js b/uint16/benchmark/benchmark.fill.length.js deleted file mode 100644 index 33877794b..000000000 --- a/uint16/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.filter.js b/uint16/benchmark/benchmark.filter.js deleted file mode 100644 index e9d36969a..000000000 --- a/uint16/benchmark/benchmark.filter.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/uint16/benchmark/benchmark.filter.length.js b/uint16/benchmark/benchmark.filter.length.js deleted file mode 100644 index 6941c0a61..000000000 --- a/uint16/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.find.js b/uint16/benchmark/benchmark.find.js deleted file mode 100644 index 1d347e492..000000000 --- a/uint16/benchmark/benchmark.find.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint16/benchmark/benchmark.find.length.js b/uint16/benchmark/benchmark.find.length.js deleted file mode 100644 index b1cfa5ec7..000000000 --- a/uint16/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.find_index.js b/uint16/benchmark/benchmark.find_index.js deleted file mode 100644 index c1e86611c..000000000 --- a/uint16/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint16/benchmark/benchmark.find_index.length.js b/uint16/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 83fd164a2..000000000 --- a/uint16/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.for_each.js b/uint16/benchmark/benchmark.for_each.js deleted file mode 100644 index 67594f8de..000000000 --- a/uint16/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint16Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/uint16/benchmark/benchmark.for_each.length.js b/uint16/benchmark/benchmark.for_each.length.js deleted file mode 100644 index ed6ad3f5f..000000000 --- a/uint16/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint16Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.from.js b/uint16/benchmark/benchmark.from.js deleted file mode 100644 index 44de0b6ff..000000000 --- a/uint16/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint16Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/uint16/benchmark/benchmark.includes.js b/uint16/benchmark/benchmark.includes.js deleted file mode 100644 index 45b77212c..000000000 --- a/uint16/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.includes.length.js b/uint16/benchmark/benchmark.includes.length.js deleted file mode 100644 index 6bc43f188..000000000 --- a/uint16/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.index_of.js b/uint16/benchmark/benchmark.index_of.js deleted file mode 100644 index c3f4e8655..000000000 --- a/uint16/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.index_of.length.js b/uint16/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 70ae6f9c2..000000000 --- a/uint16/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.join.js b/uint16/benchmark/benchmark.join.js deleted file mode 100644 index bc8234cfc..000000000 --- a/uint16/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.join.length.js b/uint16/benchmark/benchmark.join.length.js deleted file mode 100644 index 94f15eab5..000000000 --- a/uint16/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.js b/uint16/benchmark/benchmark.js deleted file mode 100644 index 85f605e31..000000000 --- a/uint16/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.keys.js b/uint16/benchmark/benchmark.keys.js deleted file mode 100644 index d65e8f0f3..000000000 --- a/uint16/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.last_index_of.js b/uint16/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 318584ae6..000000000 --- a/uint16/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.last_index_of.length.js b/uint16/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 2f711a731..000000000 --- a/uint16/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.length.js b/uint16/benchmark/benchmark.length.js deleted file mode 100644 index a91be0152..000000000 --- a/uint16/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.map.js b/uint16/benchmark/benchmark.map.js deleted file mode 100644 index a6389e1de..000000000 --- a/uint16/benchmark/benchmark.map.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint16/benchmark/benchmark.map.length.js b/uint16/benchmark/benchmark.map.length.js deleted file mode 100644 index 460ac0681..000000000 --- a/uint16/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.of.js b/uint16/benchmark/benchmark.of.js deleted file mode 100644 index a82d4ffea..000000000 --- a/uint16/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint16Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint16Array( arr ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.properties.js b/uint16/benchmark/benchmark.properties.js deleted file mode 100644 index 7805cb961..000000000 --- a/uint16/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.reduce.js b/uint16/benchmark/benchmark.reduce.js deleted file mode 100644 index dd3dfdd13..000000000 --- a/uint16/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint16/benchmark/benchmark.reduce.length.js b/uint16/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 1023c9077..000000000 --- a/uint16/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.reduce_right.js b/uint16/benchmark/benchmark.reduce_right.js deleted file mode 100644 index ec3f69b91..000000000 --- a/uint16/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint16/benchmark/benchmark.reduce_right.length.js b/uint16/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index f2e544b70..000000000 --- a/uint16/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.reverse.js b/uint16/benchmark/benchmark.reverse.js deleted file mode 100644 index 4ead6ff88..000000000 --- a/uint16/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.reverse.length.js b/uint16/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 653f41a31..000000000 --- a/uint16/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.set.js b/uint16/benchmark/benchmark.set.js deleted file mode 100644 index 1598ea324..000000000 --- a/uint16/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint16Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint16Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint16Array( 2 ); - buf = new Uint16Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.set.length.js b/uint16/benchmark/benchmark.set.length.js deleted file mode 100644 index be2a0c9f5..000000000 --- a/uint16/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint16Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.slice.js b/uint16/benchmark/benchmark.slice.js deleted file mode 100644 index e5c0dbb54..000000000 --- a/uint16/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.slice.length.js b/uint16/benchmark/benchmark.slice.length.js deleted file mode 100644 index f5b60c8b5..000000000 --- a/uint16/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.some.js b/uint16/benchmark/benchmark.some.js deleted file mode 100644 index 6a9ede19e..000000000 --- a/uint16/benchmark/benchmark.some.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint16/benchmark/benchmark.some.length.js b/uint16/benchmark/benchmark.some.length.js deleted file mode 100644 index f5fc249e3..000000000 --- a/uint16/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.sort.js b/uint16/benchmark/benchmark.sort.js deleted file mode 100644 index ce9f91244..000000000 --- a/uint16/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 randi = require( '@stdlib/random/base/randi' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.sort.length.js b/uint16/benchmark/benchmark.sort.length.js deleted file mode 100644 index 5af89301b..000000000 --- a/uint16/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint16Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.subarray.js b/uint16/benchmark/benchmark.subarray.js deleted file mode 100644 index ecfbb3e8e..000000000 --- a/uint16/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.subarray.length.js b/uint16/benchmark/benchmark.subarray.length.js deleted file mode 100644 index b0931b06d..000000000 --- a/uint16/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint16Array = require( '@stdlib/assert/is-uint16array' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint16Array( out ) ) { - b.fail( 'should return a Uint16Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.to_locale_string.js b/uint16/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 2afdc4538..000000000 --- a/uint16/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.to_locale_string.length.js b/uint16/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index f08d59c6a..000000000 --- a/uint16/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.to_string.js b/uint16/benchmark/benchmark.to_string.js deleted file mode 100644 index 4e731b561..000000000 --- a/uint16/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/benchmark/benchmark.to_string.length.js b/uint16/benchmark/benchmark.to_string.length.js deleted file mode 100644 index 94478a001..000000000 --- a/uint16/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint16Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/uint16/benchmark/benchmark.values.js b/uint16/benchmark/benchmark.values.js deleted file mode 100644 index 5e39e6c16..000000000 --- a/uint16/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint16Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint16/docs/repl.txt b/uint16/docs/repl.txt deleted file mode 100644 index 26658c367..000000000 --- a/uint16/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 16-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 8 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 2 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint16Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 10 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 2 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint16Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint16Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/uint16/docs/types/index.d.ts b/uint16/docs/types/index.d.ts deleted file mode 100644 index fe62b6165..000000000 --- a/uint16/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -*/ -export = Uint16Array; diff --git a/uint16/docs/types/test.ts b/uint16/docs/types/test.ts deleted file mode 100644 index d6ec15eae..000000000 --- a/uint16/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint16Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint16Array( 10 ); // $ExpectType Uint16Array - new Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint16Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint16Array( 10 ); // $ExpectError - Uint16Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/uint16/examples/index.js b/uint16/examples/index.js deleted file mode 100644 index d0978bec8..000000000 --- a/uint16/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/uint16/lib/index.js b/uint16/lib/index.js deleted file mode 100644 index ce7e7ccb5..000000000 --- a/uint16/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 16-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array/uint16 -* -* @example -* var ctor = require( '@stdlib/array/uint16' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint16ArraySupport = require( '@stdlib/assert/has-uint16array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint16ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/uint16/lib/main.js b/uint16/lib/main.js deleted file mode 100644 index c6c4bcd94..000000000 --- a/uint16/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof Uint16Array === 'function' ) ? Uint16Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/uint16/lib/polyfill.js b/uint16/lib/polyfill.js deleted file mode 100644 index 0d55e2b7e..000000000 --- a/uint16/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 16-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/uint16/package.json b/uint16/package.json deleted file mode 100644 index 67a4a8776..000000000 --- a/uint16/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/uint16", - "version": "0.0.0", - "description": "Uint16Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "uint16array", - "uint16", - "uint16_t", - "integer", - "int", - "uint", - "unsigned", - "short" - ] -} diff --git a/uint16/test/test.copy_within.js b/uint16/test/test.copy_within.js deleted file mode 100644 index c8c3ab203..000000000 --- a/uint16/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasProp = require( '@stdlib/assert/has-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Uint16Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint16Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint16Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint16Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint16Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/uint16/test/test.js b/uint16/test/test.js deleted file mode 100644 index 4b0217462..000000000 --- a/uint16/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint16ArraySupport = require( '@stdlib/assert/has-uint16array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint16Arrays = hasUint16ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint16Array`, the export is an alias for `Uint16Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-uint16array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint16Arrays ) { - t.strictEqual( ctor, Uint16Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint16Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-uint16array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/uint16/test/test.polyfill.js b/uint16/test/test.polyfill.js deleted file mode 100644 index 9d6fcb190..000000000 --- a/uint16/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests diff --git a/uint32/README.md b/uint32/README.md deleted file mode 100644 index 97c2b0d66..000000000 --- a/uint32/README.md +++ /dev/null @@ -1,1473 +0,0 @@ - - -# Uint32Array - -> [Typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of 32-bit unsigned integers in the platform byte order. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Uint32Array = require( '@stdlib/array/uint32' ); -``` - -#### Uint32Array() - -A [typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of 32-bit unsigned integers in the platform byte order. - - - -```javascript -var arr = new Uint32Array(); -// returns -``` - -#### Uint32Array( length ) - -Returns a [typed array][mdn-typed-array] having a specified length. - - - -```javascript -var arr = new Uint32Array( 5 ); -// returns [ 0, 0, 0, 0, 0 ] -``` - -#### Uint32Array( typedarray ) - -Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - - - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 5.0, 5.0, 5.0 ] ); -var arr2 = new Uint32Array( arr1 ); -// returns [ 5, 5, 5 ] -``` - -#### Uint32Array( obj ) - -Creates a [typed array][mdn-typed-array] from an array-like `object` or iterable. - - - -```javascript -var arr = new Uint32Array( [ 5.0, 5.0, 5.0 ] ); -// returns [ 5, 5, 5 ] -``` - -#### Uint32Array( buffer\[, byteOffset\[, length]] ) - -Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 16 ); -var arr = new Uint32Array( buf, 0, 4 ); -// returns [ 0, 0, 0, 0 ] -``` - -* * * - -### Properties - - - -#### Uint32Array.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var nbytes = Uint32Array.BYTES_PER_ELEMENT; -// returns 4 -``` - - - -#### Uint32Array.name - -[Typed array][mdn-typed-array] constructor name. - - - -```javascript -var str = Uint32Array.name; -// returns 'Uint32Array' -``` - - - -#### Uint32Array.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Uint32Array( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Uint32Array.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Uint32Array( 5 ); -var byteLength = arr.byteLength; -// returns 20 -``` - - - -#### Uint32Array.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the [typed array][mdn-typed-array] from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var arr = new Uint32Array( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Uint32Array.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var arr = new Uint32Array( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 4 -``` - - - -#### Uint32Array.prototype.length - -**Read-only** property which returns the number of view elements. - - - -```javascript -var arr = new Uint32Array( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Uint32Array.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like `object` or an iterable. - -```javascript -var arr = Uint32Array.from( [ 1, 2 ] ); -// returns [ 1, 2 ] -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2; -} - -var arr = Uint32Array.from( [ 1, 2 ], mapFcn ); -// returns [ 2, 4 ] -``` - -A callback function is provided two arguments: - -- `value`: source value. -- `index`: source index.. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr = Uint32Array.from( [ 1, 2 ], mapFcn, ctx ); -// returns [ 2, 4 ] - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint32Array.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Uint32Array.of( 1, 2 ); -// returns [ 1, 2 ] -``` - - - -#### Uint32Array.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within an array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 3 ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( 3, 0, 2 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( -2, -5, -3 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - - - -#### Uint32Array.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - - - -```javascript -var arr = new Uint32Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.entries(); - -// Iterate over key-value pairs... -var v = it.next().value; -// returns [ 0, 1 ] - -v = it.next().value; -// returns [ 1, 2 ] - -var bool = it.next().done; -// returns true -``` - - - -#### Uint32Array.prototype.every( predicate\[, thisArg] ) - -Tests whether all array elements pass a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v <= 1 ); -} - -var arr = new Uint32Array( [ 1, 2 ] ); - -var bool = arr.every( predicate ); -// returns false -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 1 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint32Array( [ 1, 2 ] ); - -var bool = arr.every( predicate, ctx ); -// returns true - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint32Array.prototype.fill( value\[, start\[, end]] ) - -Fills an array from a `start` index to an `end` index (non-inclusive) with a provided `value`. - - - -```javascript -var arr = new Uint32Array( 2 ); - -// Set all array elements to the same value: -arr.fill( 2 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 2 - -// Set all array elements starting from the first index to the same value: -arr.fill( 3, 1 ); - -v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 3 - -// Set all array elements, except the last element, to the same value: -arr.fill( 4, 0, arr.length-1 ); - -v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 3 -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr = new Uint32Array( 2 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( 2, -arr.length, -1 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 0 -``` - - - -#### Uint32Array.prototype.filter( predicate\[, thisArg] ) - -Creates a new array (of the same data type as the host array) which includes those elements for which a `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [ 2, 3 ] -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns an empty array. - - - -```javascript -function predicate( v ) { - return ( v >= 10 ); -} - -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [] -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint32Array.prototype.find( predicate\[, thisArg] ) - -Returns the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v > 2 ); -} - -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns 3 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `undefined`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns undefined -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v > 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate, ctx ); -// returns 3 - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint32Array.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 3 ); -} - -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns 2 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `-1`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns -1 -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 3 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate, ctx ); -// returns 2 - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint32Array.prototype.forEach( fcn\[, thisArg] ) - -Invokes a callback for each array element. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var str = ''; - -function fcn( v, i ) { - str += i + ':' + v; - if ( i < arr.length-1 ) { - str += ' '; - } -} - -arr.forEach( fcn ); - -console.log( str ); -// => '0:1 1:2 2:3' -``` - -The callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn() { - this.count += 1; -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -arr.forEach( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint32Array.prototype.includes( searchElement\[, fromIndex] ) - -Returns a `boolean` indicating whether an array includes a search element. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 3 ); -// returns true - -bool = arr.includes( 0 ); -// returns false -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, 1 ); -// returns false -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, -2 ); -// returns false -``` - - - -#### Uint32Array.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the index of the first array element strictly equal to a search element. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 3 ); -// returns 2 - -idx = arr.indexOf( 0 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, 1 ); -// returns -1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, -2 ); -// returns -1 -``` - - - -#### Uint32Array.prototype.join( \[separator] ) - -Serializes an array by joining all array elements as a string. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var str = arr.join(); -// returns '1,2,3' -``` - -By default, the method delineates array elements using a comma `,`. To specify a custom separator, provide a `separator` string. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var str = arr.join( '|' ); -// returns '1|2|3' -``` - - - -#### Uint32Array.prototype.keys() - -Returns an iterator for iterating over array keys. - - - -```javascript -var arr = new Uint32Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.keys(); - -// Iterate over keys... -var v = it.next().value; -// returns 0 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - - - -#### Uint32Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the index of the last array element strictly equal to a search element, iterating from right to left. - - - -```javascript -var arr = new Uint32Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0 ); -// returns 3 - -idx = arr.lastIndexOf( 3 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = -1`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint32Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, 2 ); -// returns 1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint32Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, -3 ); -// returns 1 -``` - - - -#### Uint32Array.prototype.map( fcn\[, thisArg] ) - -Maps each array element to an element in a new array having the same data type as the host array. - - - -```javascript -function fcn( v ) { - return v * 2; -} - -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn ); -// returns [ 2, 4, 6 ] -``` - -A callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint32Array.prototype.reduce( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint32Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn ); -// returns 12 -``` - -If not provided an initial value, the method invokes a provided function with the first array element as the first argument and the second array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the first array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint32Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Uint32Array.prototype.reduceRight( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result, iterating from right to left. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint32Array( [ 2, 1, 3 ] ); - -var v = arr.reduceRight( fcn ); -// returns 8 -``` - -If not provided an initial value, the method invokes a provided function with the last array element as the first argument and the second-to-last array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the last array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint32Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Uint32Array.prototype.reverse() - -Reverses an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Uint32Array( [ 2, 0, 3 ] ); - -// Reverse the array: -arr.reverse(); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 0 - -v = arr[ 2 ]; -// returns 2 -``` - - - -#### Uint32Array.prototype.set( arr\[, offset] ) - -Sets array elements. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the first two array elements: -arr.set( [ 4, 5 ] ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the last two array elements: -arr.set( [ 4, 5 ], 1 ); - -var v = arr[ 1 ]; -// returns 4 - -v = arr[ 2 ]; -// returns 5 -``` - - - -#### Uint32Array.prototype.slice( \[begin\[, end]] ) - -Copies array elements to a new array with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice(); - -var bool = ( arr1 === arr2 ); -// returns false - -bool = ( arr1.buffer === arr2.buffer ); -// returns false - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 - -v = arr2[ 2 ]; -// returns 3 -``` - -By default, the method copies elements beginning with the first array element. To specify an alternative array index at which to begin copying, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 2 - -v = arr2[ 1 ]; -// returns 3 -``` - -By default, the method copies all array elements after `begin`. To specify an alternative array index at which to end copying, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 0, 2 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( -arr1.length, -1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - - - -#### Uint32Array.prototype.some( predicate\[, thisArg] ) - -Tests whether at least one array element passes a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr = new Uint32Array( [ 1, 2 ] ); - -var bool = arr.some( predicate ); -// returns true -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint32Array( [ 1, 1 ] ); - -var bool = arr.some( predicate, ctx ); -// returns false - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint32Array.prototype.sort( \[compareFunction] ) - -Sorts an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Uint32Array( [ 2, 3, 0 ] ); - -// Sort the array (in ascending order): -arr.sort(); - -var v = arr[ 0 ]; -// returns 0 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 3 -``` - -By default, the method sorts array elements in ascending order. To impose a custom order, provide a `compareFunction`. - - - -```javascript -function descending( a, b ) { - return b - a; -} - -var arr = new Uint32Array( [ 2, 3, 0 ] ); - -// Sort the array (in descending order): -arr.sort( descending ); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 0 -``` - -The comparison function is provided two array elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: - -- If the comparison function returns a value **less** than zero, then the method sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). -- If the comparison function returns a value **greater** than zero, then the method sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). -- If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. - - - -#### Uint32Array.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray(); -// returns [ 1, 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 1 ); -// returns [ 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 0, 2 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( -arr1.length, -1 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -If the method is unable to resolve indices to a non-empty array subsequence, the method returns an empty typed array. - - - -```javascript -var arr1 = new Uint32Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 10, -1 ); -// returns [] -``` - - - -#### Uint32Array.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific `string`. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var str = arr.toLocaleString(); -// returns '1,2,3' -``` - - - -#### Uint32Array.prototype.toString() - -Serializes an array as a `string`. - - - -```javascript -var arr = new Uint32Array( [ 1, 2, 3 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - - - -#### Uint32Array.prototype.values() - -Returns an iterator for iterating over array elements. - - - -```javascript -var arr = new Uint32Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.values(); - -// Iterate over array elements... -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -var bool = it.next().done; -// returns true -``` - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( '@stdlib/array/uint32' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/uint32/benchmark/benchmark.copy_within.js b/uint32/benchmark/benchmark.copy_within.js deleted file mode 100644 index c9ddce74d..000000000 --- a/uint32/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.copy_within.length.js b/uint32/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 1822878d2..000000000 --- a/uint32/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.data.js b/uint32/benchmark/benchmark.data.js deleted file mode 100644 index e29992213..000000000 --- a/uint32/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint32Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint32Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.entries.js b/uint32/benchmark/benchmark.entries.js deleted file mode 100644 index b14d89bd1..000000000 --- a/uint32/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint32Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.every.js b/uint32/benchmark/benchmark.every.js deleted file mode 100644 index 27e2f00d2..000000000 --- a/uint32/benchmark/benchmark.every.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/uint32/benchmark/benchmark.every.length.js b/uint32/benchmark/benchmark.every.length.js deleted file mode 100644 index 92bc5336d..000000000 --- a/uint32/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.fill.js b/uint32/benchmark/benchmark.fill.js deleted file mode 100644 index ad81b7bf2..000000000 --- a/uint32/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.fill.length.js b/uint32/benchmark/benchmark.fill.length.js deleted file mode 100644 index cd975c94b..000000000 --- a/uint32/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.filter.js b/uint32/benchmark/benchmark.filter.js deleted file mode 100644 index 2482f7986..000000000 --- a/uint32/benchmark/benchmark.filter.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/uint32/benchmark/benchmark.filter.length.js b/uint32/benchmark/benchmark.filter.length.js deleted file mode 100644 index 9f0be6f7e..000000000 --- a/uint32/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.find.js b/uint32/benchmark/benchmark.find.js deleted file mode 100644 index ed2e4fd0c..000000000 --- a/uint32/benchmark/benchmark.find.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint32/benchmark/benchmark.find.length.js b/uint32/benchmark/benchmark.find.length.js deleted file mode 100644 index 594f6f3af..000000000 --- a/uint32/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.find_index.js b/uint32/benchmark/benchmark.find_index.js deleted file mode 100644 index e724bed51..000000000 --- a/uint32/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint32/benchmark/benchmark.find_index.length.js b/uint32/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 6cbba8cef..000000000 --- a/uint32/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.for_each.js b/uint32/benchmark/benchmark.for_each.js deleted file mode 100644 index 8b5ae0152..000000000 --- a/uint32/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint32Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint32Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/uint32/benchmark/benchmark.for_each.length.js b/uint32/benchmark/benchmark.for_each.length.js deleted file mode 100644 index d888fdf76..000000000 --- a/uint32/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint32Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.from.js b/uint32/benchmark/benchmark.from.js deleted file mode 100644 index 4ff139dfa..000000000 --- a/uint32/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint32Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint32Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint32Array( arr ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint32Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint32Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint32Array( arr ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint32Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint32Array( arr ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint32Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint32Array( arr ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint32Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint32Array( arr ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint32Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint32Array( arr ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/uint32/benchmark/benchmark.includes.js b/uint32/benchmark/benchmark.includes.js deleted file mode 100644 index e161e273f..000000000 --- a/uint32/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.includes.length.js b/uint32/benchmark/benchmark.includes.length.js deleted file mode 100644 index 3472fabb9..000000000 --- a/uint32/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.index_of.js b/uint32/benchmark/benchmark.index_of.js deleted file mode 100644 index 7f04d9653..000000000 --- a/uint32/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.index_of.length.js b/uint32/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 9adbbeec5..000000000 --- a/uint32/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.join.js b/uint32/benchmark/benchmark.join.js deleted file mode 100644 index 74605f53f..000000000 --- a/uint32/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.join.length.js b/uint32/benchmark/benchmark.join.length.js deleted file mode 100644 index 8533a1299..000000000 --- a/uint32/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.js b/uint32/benchmark/benchmark.js deleted file mode 100644 index bcdf86913..000000000 --- a/uint32/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint32Array( arr ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.keys.js b/uint32/benchmark/benchmark.keys.js deleted file mode 100644 index e3d8e6567..000000000 --- a/uint32/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.last_index_of.js b/uint32/benchmark/benchmark.last_index_of.js deleted file mode 100644 index dd0e58474..000000000 --- a/uint32/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint32Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.last_index_of.length.js b/uint32/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index 03ab92e98..000000000 --- a/uint32/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.length.js b/uint32/benchmark/benchmark.length.js deleted file mode 100644 index 75638104c..000000000 --- a/uint32/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint32Array( arr ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.map.js b/uint32/benchmark/benchmark.map.js deleted file mode 100644 index b57414a6c..000000000 --- a/uint32/benchmark/benchmark.map.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint32/benchmark/benchmark.map.length.js b/uint32/benchmark/benchmark.map.length.js deleted file mode 100644 index 0fed7073d..000000000 --- a/uint32/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.of.js b/uint32/benchmark/benchmark.of.js deleted file mode 100644 index 4b7f085c2..000000000 --- a/uint32/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint32Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint32Array( arr ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.properties.js b/uint32/benchmark/benchmark.properties.js deleted file mode 100644 index 75282035b..000000000 --- a/uint32/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.reduce.js b/uint32/benchmark/benchmark.reduce.js deleted file mode 100644 index 1a8a08584..000000000 --- a/uint32/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint32/benchmark/benchmark.reduce.length.js b/uint32/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 36d875fb0..000000000 --- a/uint32/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.reduce_right.js b/uint32/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 22685d203..000000000 --- a/uint32/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint32/benchmark/benchmark.reduce_right.length.js b/uint32/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index fcba6798a..000000000 --- a/uint32/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.reverse.js b/uint32/benchmark/benchmark.reverse.js deleted file mode 100644 index 49e486c34..000000000 --- a/uint32/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.reverse.length.js b/uint32/benchmark/benchmark.reverse.length.js deleted file mode 100644 index bc78f719c..000000000 --- a/uint32/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.set.js b/uint32/benchmark/benchmark.set.js deleted file mode 100644 index fdcd920db..000000000 --- a/uint32/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint32Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint32Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint32Array( 2 ); - buf = new Uint32Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.set.length.js b/uint32/benchmark/benchmark.set.length.js deleted file mode 100644 index 8d28e8263..000000000 --- a/uint32/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint32Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.slice.js b/uint32/benchmark/benchmark.slice.js deleted file mode 100644 index 00e73452e..000000000 --- a/uint32/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.slice.length.js b/uint32/benchmark/benchmark.slice.length.js deleted file mode 100644 index e46ac89f5..000000000 --- a/uint32/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.some.js b/uint32/benchmark/benchmark.some.js deleted file mode 100644 index 3abaeec28..000000000 --- a/uint32/benchmark/benchmark.some.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint32/benchmark/benchmark.some.length.js b/uint32/benchmark/benchmark.some.length.js deleted file mode 100644 index 8b8b2a53a..000000000 --- a/uint32/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.sort.js b/uint32/benchmark/benchmark.sort.js deleted file mode 100644 index dd4f6a244..000000000 --- a/uint32/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 randi = require( '@stdlib/random/base/randi' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.sort.length.js b/uint32/benchmark/benchmark.sort.length.js deleted file mode 100644 index c40b6ec93..000000000 --- a/uint32/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint32Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.subarray.js b/uint32/benchmark/benchmark.subarray.js deleted file mode 100644 index 5014eb4da..000000000 --- a/uint32/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.subarray.length.js b/uint32/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 1bca9ab45..000000000 --- a/uint32/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint32Array = require( '@stdlib/assert/is-uint32array' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint32Array( out ) ) { - b.fail( 'should return a Uint32Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.to_locale_string.js b/uint32/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index e947d2ad6..000000000 --- a/uint32/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.to_locale_string.length.js b/uint32/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index a4da2c183..000000000 --- a/uint32/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.to_string.js b/uint32/benchmark/benchmark.to_string.js deleted file mode 100644 index 78c524a44..000000000 --- a/uint32/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/benchmark/benchmark.to_string.length.js b/uint32/benchmark/benchmark.to_string.length.js deleted file mode 100644 index af13a8cc7..000000000 --- a/uint32/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint32Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/uint32/benchmark/benchmark.values.js b/uint32/benchmark/benchmark.values.js deleted file mode 100644 index 3854804a6..000000000 --- a/uint32/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint32Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint32/docs/repl.txt b/uint32/docs/repl.txt deleted file mode 100644 index e8a0ace11..000000000 --- a/uint32/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 32-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint32Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint32Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint32Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint32Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint32Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint32Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 4 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint32Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 20 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 4 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint32Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint32Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint32Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/uint32/docs/types/index.d.ts b/uint32/docs/types/index.d.ts deleted file mode 100644 index e69775234..000000000 --- a/uint32/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 32-bit unsigned integers in the platform byte order. -*/ -export = Uint32Array; diff --git a/uint32/docs/types/test.ts b/uint32/docs/types/test.ts deleted file mode 100644 index da1550250..000000000 --- a/uint32/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint32Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint32Array( 10 ); // $ExpectType Uint32Array - new Uint32Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint32Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint32Array( 10 ); // $ExpectError - Uint32Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/uint32/examples/index.js b/uint32/examples/index.js deleted file mode 100644 index d0978bec8..000000000 --- a/uint32/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/uint32/lib/index.js b/uint32/lib/index.js deleted file mode 100644 index bf04214d6..000000000 --- a/uint32/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 32-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array/uint32 -* -* @example -* var ctor = require( '@stdlib/array/uint32' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint32ArraySupport = require( '@stdlib/assert/has-uint32array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint32ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/uint32/lib/main.js b/uint32/lib/main.js deleted file mode 100644 index 9ac4e62c7..000000000 --- a/uint32/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof Uint32Array === 'function' ) ? Uint32Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/uint32/lib/polyfill.js b/uint32/lib/polyfill.js deleted file mode 100644 index c20fe2edb..000000000 --- a/uint32/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 32-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/uint32/package.json b/uint32/package.json deleted file mode 100644 index c306da1d1..000000000 --- a/uint32/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/array/uint32", - "version": "0.0.0", - "description": "Uint32Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "uint32array", - "uint32", - "uint32_t", - "integer", - "int", - "uint", - "unsigned", - "long" - ] -} diff --git a/uint32/test/test.copy_within.js b/uint32/test/test.copy_within.js deleted file mode 100644 index a02b4a21f..000000000 --- a/uint32/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasProp = require( '@stdlib/assert/has-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Uint32Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint32Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint32Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint32Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint32Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint32Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint32Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint32Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint32Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint32Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint32Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint32Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/uint32/test/test.js b/uint32/test/test.js deleted file mode 100644 index 20fad8de9..000000000 --- a/uint32/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint32ArraySupport = require( '@stdlib/assert/has-uint32array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint32Arrays = hasUint32ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint32Array`, the export is an alias for `Uint32Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-uint32array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint32Arrays ) { - t.strictEqual( ctor, Uint32Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint32Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-uint32array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/uint32/test/test.polyfill.js b/uint32/test/test.polyfill.js deleted file mode 100644 index 9d6fcb190..000000000 --- a/uint32/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests diff --git a/uint8/README.md b/uint8/README.md deleted file mode 100644 index 13eb1bbed..000000000 --- a/uint8/README.md +++ /dev/null @@ -1,1473 +0,0 @@ - - -# Uint8Array - -> [Typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of 8-bit unsigned integers in the platform byte order. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Uint8Array = require( '@stdlib/array/uint8' ); -``` - -#### Uint8Array() - -A [typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of 8-bit unsigned integers in the platform byte order. - - - -```javascript -var arr = new Uint8Array(); -// returns -``` - -#### Uint8Array( length ) - -Returns a [typed array][mdn-typed-array] having a specified length. - - - -```javascript -var arr = new Uint8Array( 5 ); -// returns [ 0, 0, 0, 0, 0 ] -``` - -#### Uint8Array( typedarray ) - -Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - - - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 5.0, 5.0, 5.0 ] ); -var arr2 = new Uint8Array( arr1 ); -// returns [ 5, 5, 5 ] -``` - -#### Uint8Array( obj ) - -Creates a [typed array][mdn-typed-array] from an array-like `object` or iterable. - - - -```javascript -var arr = new Uint8Array( [ 5.0, 5.0, 5.0 ] ); -// returns [ 5, 5, 5 ] -``` - -#### Uint8Array( buffer\[, byteOffset\[, length]] ) - -Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 4 ); -var arr = new Uint8Array( buf, 0, 4 ); -// returns [ 0, 0, 0, 0 ] -``` - -* * * - -### Properties - - - -#### Uint8Array.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var nbytes = Uint8Array.BYTES_PER_ELEMENT; -// returns 1 -``` - - - -#### Uint8Array.name - -[Typed array][mdn-typed-array] constructor name. - - - -```javascript -var str = Uint8Array.name; -// returns 'Uint8Array' -``` - - - -#### Uint8Array.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Uint8Array( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Uint8Array.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Uint8Array( 5 ); -var byteLength = arr.byteLength; -// returns 5 -``` - - - -#### Uint8Array.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the [typed array][mdn-typed-array] from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var arr = new Uint8Array( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Uint8Array.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var arr = new Uint8Array( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 1 -``` - - - -#### Uint8Array.prototype.length - -**Read-only** property which returns the number of view elements. - - - -```javascript -var arr = new Uint8Array( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Uint8Array.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like `object` or an iterable. - -```javascript -var arr = Uint8Array.from( [ 1, 2 ] ); -// returns [ 1, 2 ] -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2; -} - -var arr = Uint8Array.from( [ 1, 2 ], mapFcn ); -// returns [ 2, 4 ] -``` - -A callback function is provided two arguments: - -- `value`: source value. -- `index`: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr = Uint8Array.from( [ 1, 2 ], mapFcn, ctx ); -// returns [ 2, 4 ] - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint8Array.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Uint8Array.of( 1, 2 ); -// returns [ 1, 2 ] -``` - - - -#### Uint8Array.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within an array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 3 ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( 3, 0, 2 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( -2, -5, -3 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - - - -#### Uint8Array.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - - - -```javascript -var arr = new Uint8Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.entries(); - -// Iterate over key-value pairs... -var v = it.next().value; -// returns [ 0, 1 ] - -v = it.next().value; -// returns [ 1, 2 ] - -var bool = it.next().done; -// returns true -``` - - - -#### Uint8Array.prototype.every( predicate\[, thisArg] ) - -Tests whether all array elements pass a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v <= 1 ); -} - -var arr = new Uint8Array( [ 1, 2 ] ); - -var bool = arr.every( predicate ); -// returns false -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 1 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint8Array( [ 1, 2 ] ); - -var bool = arr.every( predicate, ctx ); -// returns true - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint8Array.prototype.fill( value\[, start\[, end]] ) - -Fills an array from a `start` index to an `end` index (non-inclusive) with a provided `value`. - - - -```javascript -var arr = new Uint8Array( 2 ); - -// Set all array elements to the same value: -arr.fill( 2 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 2 - -// Set all array elements starting from the first index to the same value: -arr.fill( 3, 1 ); - -v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 3 - -// Set all array elements, except the last element, to the same value: -arr.fill( 4, 0, arr.length-1 ); - -v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 3 -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr = new Uint8Array( 2 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( 2, -arr.length, -1 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 0 -``` - - - -#### Uint8Array.prototype.filter( predicate\[, thisArg] ) - -Creates a new array (of the same data type as the host array) which includes those elements for which a `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [ 2, 3 ] -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns an empty array. - - - -```javascript -function predicate( v ) { - return ( v >= 10 ); -} - -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [] -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint8Array.prototype.find( predicate\[, thisArg] ) - -Returns the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v > 2 ); -} - -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns 3 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `undefined`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns undefined -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v > 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var v = arr.find( predicate, ctx ); -// returns 3 - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint8Array.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 3 ); -} - -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns 2 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `-1`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns -1 -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 3 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate, ctx ); -// returns 2 - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint8Array.prototype.forEach( fcn\[, thisArg] ) - -Invokes a callback for each array element. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var str = ''; - -function fcn( v, i ) { - str += i + ':' + v; - if ( i < arr.length-1 ) { - str += ' '; - } -} - -arr.forEach( fcn ); - -console.log( str ); -// => '0:1 1:2 2:3' -``` - -The callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn() { - this.count += 1; -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -arr.forEach( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint8Array.prototype.includes( searchElement\[, fromIndex] ) - -Returns a `boolean` indicating whether an array includes a search element. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 3 ); -// returns true - -bool = arr.includes( 0 ); -// returns false -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, 1 ); -// returns false -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, -2 ); -// returns false -``` - - - -#### Uint8Array.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the index of the first array element strictly equal to a search element. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 3 ); -// returns 2 - -idx = arr.indexOf( 0 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, 1 ); -// returns -1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, -2 ); -// returns -1 -``` - - - -#### Uint8Array.prototype.join( \[separator] ) - -Serializes an array by joining all array elements as a string. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var str = arr.join(); -// returns '1,2,3' -``` - -By default, the method delineates array elements using a comma `,`. To specify a custom separator, provide a `separator` string. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var str = arr.join( '|' ); -// returns '1|2|3' -``` - - - -#### Uint8Array.prototype.keys() - -Returns an iterator for iterating over array keys. - - - -```javascript -var arr = new Uint8Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.keys(); - -// Iterate over keys... -var v = it.next().value; -// returns 0 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - - - -#### Uint8Array.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the index of the last array element strictly equal to a search element, iterating from right to left. - - - -```javascript -var arr = new Uint8Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0 ); -// returns 3 - -idx = arr.lastIndexOf( 3 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = -1`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint8Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, 2 ); -// returns 1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint8Array( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, -3 ); -// returns 1 -``` - - - -#### Uint8Array.prototype.map( fcn\[, thisArg] ) - -Maps each array element to an element in a new array having the same data type as the host array. - - - -```javascript -function fcn( v ) { - return v * 2; -} - -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn ); -// returns [ 2, 4, 6 ] -``` - -A callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint8Array.prototype.reduce( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint8Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn ); -// returns 12 -``` - -If not provided an initial value, the method invokes a provided function with the first array element as the first argument and the second array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the first array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint8Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Uint8Array.prototype.reduceRight( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result, iterating from right to left. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint8Array( [ 2, 1, 3 ] ); - -var v = arr.reduceRight( fcn ); -// returns 8 -``` - -If not provided an initial value, the method invokes a provided function with the last array element as the first argument and the second-to-last array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the last array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint8Array( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Uint8Array.prototype.reverse() - -Reverses an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Uint8Array( [ 2, 0, 3 ] ); - -// Reverse the array: -arr.reverse(); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 0 - -v = arr[ 2 ]; -// returns 2 -``` - - - -#### Uint8Array.prototype.set( arr\[, offset] ) - -Sets array elements. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the first two array elements: -arr.set( [ 4, 5 ] ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the last two array elements: -arr.set( [ 4, 5 ], 1 ); - -var v = arr[ 1 ]; -// returns 4 - -v = arr[ 2 ]; -// returns 5 -``` - - - -#### Uint8Array.prototype.slice( \[begin\[, end]] ) - -Copies array elements to a new array with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice(); - -var bool = ( arr1 === arr2 ); -// returns false - -bool = ( arr1.buffer === arr2.buffer ); -// returns false - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 - -v = arr2[ 2 ]; -// returns 3 -``` - -By default, the method copies elements beginning with the first array element. To specify an alternative array index at which to begin copying, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 2 - -v = arr2[ 1 ]; -// returns 3 -``` - -By default, the method copies all array elements after `begin`. To specify an alternative array index at which to end copying, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 0, 2 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( -arr1.length, -1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - - - -#### Uint8Array.prototype.some( predicate\[, thisArg] ) - -Tests whether at least one array element passes a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr = new Uint8Array( [ 1, 2 ] ); - -var bool = arr.some( predicate ); -// returns true -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint8Array( [ 1, 1 ] ); - -var bool = arr.some( predicate, ctx ); -// returns false - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint8Array.prototype.sort( \[compareFunction] ) - -Sorts an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Uint8Array( [ 2, 3, 0 ] ); - -// Sort the array (in ascending order): -arr.sort(); - -var v = arr[ 0 ]; -// returns 0 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 3 -``` - -By default, the method sorts array elements in ascending order. To impose a custom order, provide a `compareFunction`. - - - -```javascript -function descending( a, b ) { - return b - a; -} - -var arr = new Uint8Array( [ 2, 3, 0 ] ); - -// Sort the array (in descending order): -arr.sort( descending ); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 0 -``` - -The comparison function is provided two array elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: - -- If the comparison function returns a value **less** than zero, then the method sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). -- If the comparison function returns a value **greater** than zero, then the method sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). -- If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. - - - -#### Uint8Array.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray(); -// returns [ 1, 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 1 ); -// returns [ 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 0, 2 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( -arr1.length, -1 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -If the method is unable to resolve indices to a non-empty array subsequence, the method returns an empty typed array. - - - -```javascript -var arr1 = new Uint8Array( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 10, -1 ); -// returns [] -``` - - - -#### Uint8Array.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific `string`. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var str = arr.toLocaleString(); -// returns '1,2,3' -``` - - - -#### Uint8Array.prototype.toString() - -Serializes an array as a `string`. - - - -```javascript -var arr = new Uint8Array( [ 1, 2, 3 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - - - -#### Uint8Array.prototype.values() - -Returns an iterator for iterating over array elements. - - - -```javascript -var arr = new Uint8Array( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.values(); - -// Iterate over array elements... -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -var bool = it.next().done; -// returns true -``` - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( '@stdlib/array/uint8' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/uint8/benchmark/benchmark.copy_within.js b/uint8/benchmark/benchmark.copy_within.js deleted file mode 100644 index fd94b2546..000000000 --- a/uint8/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.copy_within.length.js b/uint8/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index 7dd8aae09..000000000 --- a/uint8/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.data.js b/uint8/benchmark/benchmark.data.js deleted file mode 100644 index c494b681f..000000000 --- a/uint8/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint8Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint8Array( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.entries.js b/uint8/benchmark/benchmark.entries.js deleted file mode 100644 index fefbd5789..000000000 --- a/uint8/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint8Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.every.js b/uint8/benchmark/benchmark.every.js deleted file mode 100644 index d22cc45df..000000000 --- a/uint8/benchmark/benchmark.every.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/uint8/benchmark/benchmark.every.length.js b/uint8/benchmark/benchmark.every.length.js deleted file mode 100644 index f89c9abb4..000000000 --- a/uint8/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.fill.js b/uint8/benchmark/benchmark.fill.js deleted file mode 100644 index ba36b1313..000000000 --- a/uint8/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.fill.length.js b/uint8/benchmark/benchmark.fill.length.js deleted file mode 100644 index 010fbc572..000000000 --- a/uint8/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.filter.js b/uint8/benchmark/benchmark.filter.js deleted file mode 100644 index 1dae0041e..000000000 --- a/uint8/benchmark/benchmark.filter.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/uint8/benchmark/benchmark.filter.length.js b/uint8/benchmark/benchmark.filter.length.js deleted file mode 100644 index 37014c675..000000000 --- a/uint8/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.find.js b/uint8/benchmark/benchmark.find.js deleted file mode 100644 index 5327e0eba..000000000 --- a/uint8/benchmark/benchmark.find.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint8/benchmark/benchmark.find.length.js b/uint8/benchmark/benchmark.find.length.js deleted file mode 100644 index c3628e400..000000000 --- a/uint8/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.find_index.js b/uint8/benchmark/benchmark.find_index.js deleted file mode 100644 index b4d8cd424..000000000 --- a/uint8/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint8/benchmark/benchmark.find_index.length.js b/uint8/benchmark/benchmark.find_index.length.js deleted file mode 100644 index bf124a993..000000000 --- a/uint8/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.for_each.js b/uint8/benchmark/benchmark.for_each.js deleted file mode 100644 index 404a9c9df..000000000 --- a/uint8/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint8Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint8Array( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/uint8/benchmark/benchmark.for_each.length.js b/uint8/benchmark/benchmark.for_each.length.js deleted file mode 100644 index a7ef3a42a..000000000 --- a/uint8/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint8Array( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.from.js b/uint8/benchmark/benchmark.from.js deleted file mode 100644 index abe60a051..000000000 --- a/uint8/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8Array( arr ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8Array( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8Array( arr ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8Array.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8Array( arr ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8Array.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8Array( arr ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8Array.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8Array( arr ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8Array.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8Array( arr ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/uint8/benchmark/benchmark.includes.js b/uint8/benchmark/benchmark.includes.js deleted file mode 100644 index 12a1656c8..000000000 --- a/uint8/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.includes.length.js b/uint8/benchmark/benchmark.includes.length.js deleted file mode 100644 index fdb98c85a..000000000 --- a/uint8/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.index_of.js b/uint8/benchmark/benchmark.index_of.js deleted file mode 100644 index 8fa6d85b4..000000000 --- a/uint8/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.index_of.length.js b/uint8/benchmark/benchmark.index_of.length.js deleted file mode 100644 index dd76a68ac..000000000 --- a/uint8/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.join.js b/uint8/benchmark/benchmark.join.js deleted file mode 100644 index 958aa5489..000000000 --- a/uint8/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.join.length.js b/uint8/benchmark/benchmark.join.length.js deleted file mode 100644 index c25d21214..000000000 --- a/uint8/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.js b/uint8/benchmark/benchmark.js deleted file mode 100644 index f2514f53b..000000000 --- a/uint8/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint8Array( arr ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.keys.js b/uint8/benchmark/benchmark.keys.js deleted file mode 100644 index 2c70df05e..000000000 --- a/uint8/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.last_index_of.js b/uint8/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 0e80fc654..000000000 --- a/uint8/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint8Array( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.last_index_of.length.js b/uint8/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index b36aa4c73..000000000 --- a/uint8/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.length.js b/uint8/benchmark/benchmark.length.js deleted file mode 100644 index e40be57e4..000000000 --- a/uint8/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint8Array( arr ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.map.js b/uint8/benchmark/benchmark.map.js deleted file mode 100644 index 106bc1204..000000000 --- a/uint8/benchmark/benchmark.map.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint8/benchmark/benchmark.map.length.js b/uint8/benchmark/benchmark.map.length.js deleted file mode 100644 index f0200bd57..000000000 --- a/uint8/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.of.js b/uint8/benchmark/benchmark.of.js deleted file mode 100644 index 6aaa2bf40..000000000 --- a/uint8/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8Array.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8Array( arr ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.properties.js b/uint8/benchmark/benchmark.properties.js deleted file mode 100644 index 891b634f6..000000000 --- a/uint8/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.reduce.js b/uint8/benchmark/benchmark.reduce.js deleted file mode 100644 index 21498da83..000000000 --- a/uint8/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint8/benchmark/benchmark.reduce.length.js b/uint8/benchmark/benchmark.reduce.length.js deleted file mode 100644 index 82c3ceb41..000000000 --- a/uint8/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.reduce_right.js b/uint8/benchmark/benchmark.reduce_right.js deleted file mode 100644 index e452af1d4..000000000 --- a/uint8/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint8/benchmark/benchmark.reduce_right.length.js b/uint8/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index 6e1b422e3..000000000 --- a/uint8/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.reverse.js b/uint8/benchmark/benchmark.reverse.js deleted file mode 100644 index 84bcc28b5..000000000 --- a/uint8/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.reverse.length.js b/uint8/benchmark/benchmark.reverse.length.js deleted file mode 100644 index e5e360eec..000000000 --- a/uint8/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.set.js b/uint8/benchmark/benchmark.set.js deleted file mode 100644 index 59827e1ee..000000000 --- a/uint8/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint8Array( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint8Array( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint8Array( 2 ); - buf = new Uint8Array( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.set.length.js b/uint8/benchmark/benchmark.set.length.js deleted file mode 100644 index 052293f44..000000000 --- a/uint8/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint8Array( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.slice.js b/uint8/benchmark/benchmark.slice.js deleted file mode 100644 index 874b535e5..000000000 --- a/uint8/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.slice.length.js b/uint8/benchmark/benchmark.slice.length.js deleted file mode 100644 index 78e2b7e1d..000000000 --- a/uint8/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.some.js b/uint8/benchmark/benchmark.some.js deleted file mode 100644 index f20c59cad..000000000 --- a/uint8/benchmark/benchmark.some.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint8/benchmark/benchmark.some.length.js b/uint8/benchmark/benchmark.some.length.js deleted file mode 100644 index 647c0768d..000000000 --- a/uint8/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.sort.js b/uint8/benchmark/benchmark.sort.js deleted file mode 100644 index 4d36b9d6d..000000000 --- a/uint8/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 randi = require( '@stdlib/random/base/randi' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.sort.length.js b/uint8/benchmark/benchmark.sort.length.js deleted file mode 100644 index ca66eda09..000000000 --- a/uint8/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint8Array( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.subarray.js b/uint8/benchmark/benchmark.subarray.js deleted file mode 100644 index 2c91017e9..000000000 --- a/uint8/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.subarray.length.js b/uint8/benchmark/benchmark.subarray.length.js deleted file mode 100644 index e353f0178..000000000 --- a/uint8/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8Array = require( '@stdlib/assert/is-uint8array' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8Array( out ) ) { - b.fail( 'should return a Uint8Array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.to_locale_string.js b/uint8/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index 7631518ac..000000000 --- a/uint8/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.to_locale_string.length.js b/uint8/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 824ebc296..000000000 --- a/uint8/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.to_string.js b/uint8/benchmark/benchmark.to_string.js deleted file mode 100644 index 75f8bcb25..000000000 --- a/uint8/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/benchmark/benchmark.to_string.length.js b/uint8/benchmark/benchmark.to_string.length.js deleted file mode 100644 index de8020da3..000000000 --- a/uint8/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8Array( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/uint8/benchmark/benchmark.values.js b/uint8/benchmark/benchmark.values.js deleted file mode 100644 index f59323841..000000000 --- a/uint8/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8Array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8/docs/repl.txt b/uint8/docs/repl.txt deleted file mode 100644 index d27af9beb..000000000 --- a/uint8/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 8-bit unsigned integers in the platform byte order. - - Returns - ------- - out: Uint8Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint8Array - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint8Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint8Array - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint8Array - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 4 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint8Array - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint8Array - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 1 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint8Array' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 5 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 1 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint8Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint8Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns `null`. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint8Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint8Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint8Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns `null`. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint8Array - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, a array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint8Array - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint8Array - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/uint8/docs/types/index.d.ts b/uint8/docs/types/index.d.ts deleted file mode 100644 index e55ca0b0e..000000000 --- a/uint8/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order. -*/ -export = Uint8Array; diff --git a/uint8/docs/types/test.ts b/uint8/docs/types/test.ts deleted file mode 100644 index 9b5061dfb..000000000 --- a/uint8/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint8Array = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint8Array( 10 ); // $ExpectType Uint8Array - new Uint8Array( [ 2, 5, 5, 7 ] ); // $ExpectType Uint8Array -} - -// The constructor function has to be invoked with `new`... -{ - Uint8Array( 10 ); // $ExpectError - Uint8Array( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/uint8/examples/index.js b/uint8/examples/index.js deleted file mode 100644 index d0978bec8..000000000 --- a/uint8/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/uint8/lib/index.js b/uint8/lib/index.js deleted file mode 100644 index 84bbddeac..000000000 --- a/uint8/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order. -* -* @module @stdlib/array/uint8 -* -* @example -* var ctor = require( '@stdlib/array/uint8' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint8ArraySupport = require( '@stdlib/assert/has-uint8array-support' ); -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint8ArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/uint8/lib/main.js b/uint8/lib/main.js deleted file mode 100644 index c19ff14ed..000000000 --- a/uint8/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof Uint8Array === 'function' ) ? Uint8Array : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/uint8/lib/polyfill.js b/uint8/lib/polyfill.js deleted file mode 100644 index 6b806341e..000000000 --- a/uint8/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 8-bit unsigned integers in the platform byte order. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/uint8/package.json b/uint8/package.json deleted file mode 100644 index 49ec4b627..000000000 --- a/uint8/package.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "name": "@stdlib/array/uint8", - "version": "0.0.0", - "description": "Uint8Array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "uint8array", - "uint8", - "uint8_t", - "integer", - "int", - "uint", - "unsigned", - "byte", - "octet" - ] -} diff --git a/uint8/test/test.copy_within.js b/uint8/test/test.copy_within.js deleted file mode 100644 index 56d67eea3..000000000 --- a/uint8/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasProp = require( '@stdlib/assert/has-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Uint8Array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint8Array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint8Array( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint8Array( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8Array( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8Array( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8Array( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8Array( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8Array( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8Array( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8Array( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8Array( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/uint8/test/test.js b/uint8/test/test.js deleted file mode 100644 index 12f6f7e43..000000000 --- a/uint8/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint8ArraySupport = require( '@stdlib/assert/has-uint8array-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint8Arrays = hasUint8ArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint8Array`, the export is an alias for `Uint8Array`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-uint8array-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint8Arrays ) { - t.strictEqual( ctor, Uint8Array, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint8Array`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-uint8array-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/uint8/test/test.polyfill.js b/uint8/test/test.polyfill.js deleted file mode 100644 index 9d6fcb190..000000000 --- a/uint8/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests diff --git a/uint8c/README.md b/uint8c/README.md deleted file mode 100644 index 5820c7763..000000000 --- a/uint8c/README.md +++ /dev/null @@ -1,1473 +0,0 @@ - - -# Uint8ClampedArray - -> [Typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of 8-bit unsigned integers in the platform byte order clamped to 0-255. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); -``` - -#### Uint8ClampedArray() - -A [typed array][mdn-typed-array] constructor which returns a [typed array][mdn-typed-array] representing an array of 8-bit unsigned integers in the platform byte order clamped to `0-255`. - - - -```javascript -var arr = new Uint8ClampedArray(); -// returns -``` - -#### Uint8ClampedArray( length ) - -Returns a [typed array][mdn-typed-array] having a specified length. - - - -```javascript -var arr = new Uint8ClampedArray( 5 ); -// returns [ 0, 0, 0, 0, 0 ] -``` - -#### Uint8ClampedArray( typedarray ) - -Creates a [typed array][mdn-typed-array] from another [typed array][mdn-typed-array]. - - - -```javascript -var Float32Array = require( '@stdlib/array/float32' ); - -var arr1 = new Float32Array( [ 5.0, 5.0, 5.0 ] ); -var arr2 = new Uint8ClampedArray( arr1 ); -// returns [ 5, 5, 5 ] -``` - -#### Uint8ClampedArray( obj ) - -Creates a [typed array][mdn-typed-array] from an array-like `object` or iterable. - - - -```javascript -var arr = new Uint8ClampedArray( [ 5.0, 5.0, 5.0 ] ); -// returns [ 5, 5, 5 ] -``` - -#### Uint8ClampedArray( buffer\[, byteOffset\[, length]] ) - -Returns a [typed array][mdn-typed-array] view of an [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var ArrayBuffer = require( '@stdlib/array/buffer' ); - -var buf = new ArrayBuffer( 4 ); -var arr = new Uint8ClampedArray( buf, 0, 4 ); -// returns [ 0, 0, 0, 0 ] -``` - -* * * - -### Properties - - - -#### Uint8ClampedArray.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var nbytes = Uint8ClampedArray.BYTES_PER_ELEMENT; -// returns 1 -``` - - - -#### Uint8ClampedArray.name - -[Typed array][mdn-typed-array] constructor name. - - - -```javascript -var str = Uint8ClampedArray.name; -// returns 'Uint8ClampedArray' -``` - - - -#### Uint8ClampedArray.prototype.buffer - -**Read-only** property which returns the [`ArrayBuffer`][@stdlib/array/buffer] referenced by the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Uint8ClampedArray( 5 ); -var buf = arr.buffer; -// returns -``` - - - -#### Uint8ClampedArray.prototype.byteLength - -**Read-only** property which returns the length (in bytes) of the [typed array][mdn-typed-array]. - - - -```javascript -var arr = new Uint8ClampedArray( 5 ); -var byteLength = arr.byteLength; -// returns 5 -``` - - - -#### Uint8ClampedArray.prototype.byteOffset - -**Read-only** property which returns the offset (in bytes) of the [typed array][mdn-typed-array] from the start of its [`ArrayBuffer`][@stdlib/array/buffer]. - - - -```javascript -var arr = new Uint8ClampedArray( 5 ); -var byteOffset = arr.byteOffset; -// returns 0 -``` - - - -#### Uint8ClampedArray.prototype.BYTES_PER_ELEMENT - -Number of bytes per view element. - - - -```javascript -var arr = new Uint8ClampedArray( 5 ); -var nbytes = arr.BYTES_PER_ELEMENT; -// returns 1 -``` - - - -#### Uint8ClampedArray.prototype.length - -**Read-only** property which returns the number of view elements. - - - -```javascript -var arr = new Uint8ClampedArray( 5 ); -var len = arr.length; -// returns 5 -``` - -* * * - -### Methods - - - -#### Uint8ClampedArray.from( src\[, map\[, thisArg]] ) - -Creates a new typed array from an array-like `object` or an iterable. - -```javascript -var arr = Uint8ClampedArray.from( [ 1, 2 ] ); -// returns [ 1, 2 ] -``` - -To invoke a function for each `src` value, provide a callback function. - -```javascript -function mapFcn( v ) { - return v * 2; -} - -var arr = Uint8ClampedArray.from( [ 1, 2 ], mapFcn ); -// returns [ 2, 4 ] -``` - -A callback function is provided two arguments: - -- `value`: source value. -- `index`: source index. - -To set the callback execution context, provide a `thisArg`. - -```javascript -function mapFcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr = Uint8ClampedArray.from( [ 1, 2 ], mapFcn, ctx ); -// returns [ 2, 4 ] - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint8ClampedArray.of( element0\[, element1\[, ...elementN]] ) - -Creates a new typed array from a variable number of arguments. - -```javascript -var arr = Uint8ClampedArray.of( 1, 2 ); -// returns [ 1, 2 ] -``` - - - -#### Uint8ClampedArray.prototype.copyWithin( target, start\[, end] ) - -Copies a sequence of elements within an array starting at `start` and ending at `end` (non-inclusive) to the position starting at `target`. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3, 4, 5 ] ); - -// Copy the last two elements to the first two elements: -arr.copyWithin( 0, 3 ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, `end` equals the number of array elements (i.e., one more than the last array index). To limit the sequence length, provide an `end` argument. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( 3, 0, 2 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - -When a `target`, `start`, and/or `end` index is negative, the respective index is determined relative to the last array element. The following example achieves the same behavior as the previous example: - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3, 4, 5 ] ); - -// Copy the first two elements to the last two elements: -arr.copyWithin( -2, -5, -3 ); - -var v = arr[ 3 ]; -// returns 1 - -v = arr[ 4 ]; -// returns 2 -``` - - - -#### Uint8ClampedArray.prototype.entries() - -Returns an iterator for iterating over array key-value pairs. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.entries(); - -// Iterate over key-value pairs... -var v = it.next().value; -// returns [ 0, 1 ] - -v = it.next().value; -// returns [ 1, 2 ] - -var bool = it.next().done; -// returns true -``` - - - -#### Uint8ClampedArray.prototype.every( predicate\[, thisArg] ) - -Tests whether all array elements pass a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v <= 1 ); -} - -var arr = new Uint8ClampedArray( [ 1, 2 ] ); - -var bool = arr.every( predicate ); -// returns false -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 1 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint8ClampedArray( [ 1, 2 ] ); - -var bool = arr.every( predicate, ctx ); -// returns true - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint8ClampedArray.prototype.fill( value\[, start\[, end]] ) - -Fills an array from a `start` index to an `end` index (non-inclusive) with a provided `value`. - - - -```javascript -var arr = new Uint8ClampedArray( 2 ); - -// Set all array elements to the same value: -arr.fill( 2 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 2 - -// Set all array elements starting from the first index to the same value: -arr.fill( 3, 1 ); - -v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 3 - -// Set all array elements, except the last element, to the same value: -arr.fill( 4, 0, arr.length-1 ); - -v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 3 -``` - -When a `start` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr = new Uint8ClampedArray( 2 ); - -// Set all array elements, except the last element, to the same value: -arr.fill( 2, -arr.length, -1 ); - -var v = arr[ 0 ]; -// returns 2 - -v = arr[ 1 ]; -// returns 0 -``` - - - -#### Uint8ClampedArray.prototype.filter( predicate\[, thisArg] ) - -Creates a new array (of the same data type as the host array) which includes those elements for which a `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [ 2, 3 ] -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns an empty array. - - - -```javascript -function predicate( v ) { - return ( v >= 10 ); -} - -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate ); -// returns [] -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.filter( predicate, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint8ClampedArray.prototype.find( predicate\[, thisArg] ) - -Returns the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v > 2 ); -} - -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns 3 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `undefined`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var v = arr.find( predicate ); -// returns undefined -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v > 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var v = arr.find( predicate, ctx ); -// returns 3 - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint8ClampedArray.prototype.findIndex( predicate\[, thisArg] ) - -Returns the index of the first array element for which a provided `predicate` function returns a truthy value. - - - -```javascript -function predicate( v ) { - return ( v >= 3 ); -} - -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns 2 -``` - -If a `predicate` function does not return a truthy value for any array element, the method returns `-1`. - - - -```javascript -function predicate( v ) { - return ( v < 1 ); -} - -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate ); -// returns -1 -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 3 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var idx = arr.findIndex( predicate, ctx ); -// returns 2 - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint8ClampedArray.prototype.forEach( fcn\[, thisArg] ) - -Invokes a callback for each array element. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var str = ''; - -function fcn( v, i ) { - str += i + ':' + v; - if ( i < arr.length-1 ) { - str += ' '; - } -} - -arr.forEach( fcn ); - -console.log( str ); -// => '0:1 1:2 2:3' -``` - -The callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn() { - this.count += 1; -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -arr.forEach( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint8ClampedArray.prototype.includes( searchElement\[, fromIndex] ) - -Returns a `boolean` indicating whether an array includes a search element. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var bool = arr.includes( 3 ); -// returns true - -bool = arr.includes( 0 ); -// returns false -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, 1 ); -// returns false -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var bool = arr.includes( 1, -2 ); -// returns false -``` - - - -#### Uint8ClampedArray.prototype.indexOf( searchElement\[, fromIndex] ) - -Returns the index of the first array element strictly equal to a search element. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 3 ); -// returns 2 - -idx = arr.indexOf( 0 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = 0`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, 1 ); -// returns -1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var idx = arr.indexOf( 1, -2 ); -// returns -1 -``` - - - -#### Uint8ClampedArray.prototype.join( \[separator] ) - -Serializes an array by joining all array elements as a string. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var str = arr.join(); -// returns '1,2,3' -``` - -By default, the method delineates array elements using a comma `,`. To specify a custom separator, provide a `separator` string. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var str = arr.join( '|' ); -// returns '1|2|3' -``` - - - -#### Uint8ClampedArray.prototype.keys() - -Returns an iterator for iterating over array keys. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.keys(); - -// Iterate over keys... -var v = it.next().value; -// returns 0 - -v = it.next().value; -// returns 1 - -var bool = it.next().done; -// returns true -``` - - - -#### Uint8ClampedArray.prototype.lastIndexOf( searchElement\[, fromIndex] ) - -Returns the index of the last array element strictly equal to a search element, iterating from right to left. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0 ); -// returns 3 - -idx = arr.lastIndexOf( 3 ); -// returns -1 -``` - -By default, the method searches the entire array (`fromIndex = -1`). To begin searching from a specific array index, provide a `fromIndex`. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, 2 ); -// returns 1 -``` - -When a `fromIndex` is negative, the starting index is resolved relative to the last array element. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 0, 2, 0, 1 ] ); - -var idx = arr.lastIndexOf( 0, -3 ); -// returns 1 -``` - - - -#### Uint8ClampedArray.prototype.map( fcn\[, thisArg] ) - -Maps each array element to an element in a new array having the same data type as the host array. - - - -```javascript -function fcn( v ) { - return v * 2; -} - -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn ); -// returns [ 2, 4, 6 ] -``` - -A callback is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function fcn( v ) { - this.count += 1; - return v * 2; -} - -var ctx = { - 'count': 0 -}; - -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.map( fcn, ctx ); - -var n = ctx.count; -// returns 3 -``` - - - -#### Uint8ClampedArray.prototype.reduce( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint8ClampedArray( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn ); -// returns 12 -``` - -If not provided an initial value, the method invokes a provided function with the first array element as the first argument and the second array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the first array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint8ClampedArray( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Uint8ClampedArray.prototype.reduceRight( fcn\[, initialValue] ) - -Applies a function against an accumulator and each element in an array and returns the accumulated result, iterating from right to left. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint8ClampedArray( [ 2, 1, 3 ] ); - -var v = arr.reduceRight( fcn ); -// returns 8 -``` - -If not provided an initial value, the method invokes a provided function with the last array element as the first argument and the second-to-last array element as the second argument. - -If provided an initial value, the method invokes a provided function with the initial value as the first argument and the last array element as the second argument. - - - -```javascript -function fcn( acc, v ) { - return acc + ( v*v ); -} - -var arr = new Uint8ClampedArray( [ 2, 1, 3 ] ); - -var v = arr.reduce( fcn, 0 ); -// returns 14 -``` - -A callback is provided four arguments: - -- `acc`: accumulated result. -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - - - -#### Uint8ClampedArray.prototype.reverse() - -Reverses an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Uint8ClampedArray( [ 2, 0, 3 ] ); - -// Reverse the array: -arr.reverse(); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 0 - -v = arr[ 2 ]; -// returns 2 -``` - - - -#### Uint8ClampedArray.prototype.set( arr\[, offset] ) - -Sets array elements. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the first two array elements: -arr.set( [ 4, 5 ] ); - -var v = arr[ 0 ]; -// returns 4 - -v = arr[ 1 ]; -// returns 5 -``` - -By default, the method starts writing values at the first array index. To specify an alternative index, provide an index `offset`. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); -// returns [ 1, 2, 3 ] - -// Set the last two array elements: -arr.set( [ 4, 5 ], 1 ); - -var v = arr[ 1 ]; -// returns 4 - -v = arr[ 2 ]; -// returns 5 -``` - - - -#### Uint8ClampedArray.prototype.slice( \[begin\[, end]] ) - -Copies array elements to a new array with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice(); - -var bool = ( arr1 === arr2 ); -// returns false - -bool = ( arr1.buffer === arr2.buffer ); -// returns false - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 - -v = arr2[ 2 ]; -// returns 3 -``` - -By default, the method copies elements beginning with the first array element. To specify an alternative array index at which to begin copying, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 2 - -v = arr2[ 1 ]; -// returns 3 -``` - -By default, the method copies all array elements after `begin`. To specify an alternative array index at which to end copying, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( 0, 2 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.slice( -arr1.length, -1 ); - -var len = arr2.length; -// returns 2 - -var v = arr2[ 0 ]; -// returns 1 - -v = arr2[ 1 ]; -// returns 2 -``` - - - -#### Uint8ClampedArray.prototype.some( predicate\[, thisArg] ) - -Tests whether at least one array element passes a test implemented by a `predicate` function. - - - -```javascript -function predicate( v ) { - return ( v >= 2 ); -} - -var arr = new Uint8ClampedArray( [ 1, 2 ] ); - -var bool = arr.some( predicate ); -// returns true -``` - -A `predicate` function is provided three arguments: - -- `value`: array element. -- `index`: array index. -- `arr`: array on which the method is invoked. - -To set the callback execution context, provide a `thisArg`. - - - -```javascript -function predicate( v ) { - this.count += 1; - return ( v >= 2 ); -} - -var ctx = { - 'count': 0 -}; - -var arr = new Uint8ClampedArray( [ 1, 1 ] ); - -var bool = arr.some( predicate, ctx ); -// returns false - -var n = ctx.count; -// returns 2 -``` - - - -#### Uint8ClampedArray.prototype.sort( \[compareFunction] ) - -Sorts an array **in-place** (thus mutating the array on which the method is invoked). - - - -```javascript -var arr = new Uint8ClampedArray( [ 2, 3, 0 ] ); - -// Sort the array (in ascending order): -arr.sort(); - -var v = arr[ 0 ]; -// returns 0 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 3 -``` - -By default, the method sorts array elements in ascending order. To impose a custom order, provide a `compareFunction`. - - - -```javascript -function descending( a, b ) { - return b - a; -} - -var arr = new Uint8ClampedArray( [ 2, 3, 0 ] ); - -// Sort the array (in descending order): -arr.sort( descending ); - -var v = arr[ 0 ]; -// returns 3 - -v = arr[ 1 ]; -// returns 2 - -v = arr[ 2 ]; -// returns 0 -``` - -The comparison function is provided two array elements, `a` and `b`, per invocation, and its return value determines the sort order as follows: - -- If the comparison function returns a value **less** than zero, then the method sorts `a` to an index lower than `b` (i.e., `a` should come **before** `b`). -- If the comparison function returns a value **greater** than zero, then the method sorts `a` to an index higher than `b` (i.e., `b` should come **before** `a`). -- If the comparison function returns **zero**, then the relative order of `a` and `b` _should_ remain unchanged. - - - -#### Uint8ClampedArray.prototype.subarray( \[begin\[, end]] ) - -Creates a new typed array view over the same underlying [`ArrayBuffer`][@stdlib/array/buffer] and with the same underlying data type as the host array. - - - -```javascript -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray(); -// returns [ 1, 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view beginning with the first array element. To specify an alternative array index at which to begin, provide a `begin` index (inclusive). - - - -```javascript -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 1 ); -// returns [ 2, 3 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -By default, the method creates a typed array view which includes all array elements after `begin`. To limit the number of array elements after `begin`, provide an `end` index (exclusive). - - - -```javascript -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 0, 2 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -When a `begin` and/or `end` index is negative, the respective index is determined relative to the last array element. - - - -```javascript -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( -arr1.length, -1 ); -// returns [ 1, 2 ] - -var bool = ( arr1.buffer === arr2.buffer ); -// returns true -``` - -If the method is unable to resolve indices to a non-empty array subsequence, the method returns an empty typed array. - - - -```javascript -var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var arr2 = arr1.subarray( 10, -1 ); -// returns [] -``` - - - -#### Uint8ClampedArray.prototype.toLocaleString( \[locales\[, options]] ) - -Serializes an array as a locale-specific `string`. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var str = arr.toLocaleString(); -// returns '1,2,3' -``` - - - -#### Uint8ClampedArray.prototype.toString() - -Serializes an array as a `string`. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2, 3 ] ); - -var str = arr.toString(); -// returns '1,2,3' -``` - - - -#### Uint8ClampedArray.prototype.values() - -Returns an iterator for iterating over array elements. - - - -```javascript -var arr = new Uint8ClampedArray( [ 1, 2 ] ); - -// Create an iterator: -var it = arr.values(); - -// Iterate over array elements... -var v = it.next().value; -// returns 1 - -v = it.next().value; -// returns 2 - -var bool = it.next().done; -// returns true -``` - -
- - - -* * * - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( '@stdlib/array/uint8c' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/uint8c/benchmark/benchmark.copy_within.js b/uint8c/benchmark/benchmark.copy_within.js deleted file mode 100644 index e2731bd2b..000000000 --- a/uint8c/benchmark/benchmark.copy_within.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':copyWithin', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.copy_within.length.js b/uint8c/benchmark/benchmark.copy_within.length.js deleted file mode 100644 index bd70626c5..000000000 --- a/uint8c/benchmark/benchmark.copy_within.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr[ 0 ] = v; - arr = arr.copyWithin( 1, 0 ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':copyWithin:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.data.js b/uint8c/benchmark/benchmark.data.js deleted file mode 100644 index 5cbb9007f..000000000 --- a/uint8c/benchmark/benchmark.data.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get,index', function benchmark( b ) { - var arr; - var N; - var v; - var i; - - arr = new Uint8ClampedArray( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr[ i%N ]; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::set,index', function benchmark( b ) { - var arr; - var N; - var i; - - arr = new Uint8ClampedArray( 2 ); - N = arr.length; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%N ] = i; - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] || arr[ 1 ] !== arr[ 1 ] ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.entries.js b/uint8c/benchmark/benchmark.entries.js deleted file mode 100644 index 0b2af25f1..000000000 --- a/uint8c/benchmark/benchmark.entries.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':entries', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint8ClampedArray( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.entries(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.every.js b/uint8c/benchmark/benchmark.every.js deleted file mode 100644 index c2dea91d5..000000000 --- a/uint8c/benchmark/benchmark.every.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:every', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/uint8c/benchmark/benchmark.every.length.js b/uint8c/benchmark/benchmark.every.length.js deleted file mode 100644 index 0ec674645..000000000 --- a/uint8c/benchmark/benchmark.every.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.every( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':every:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.fill.js b/uint8c/benchmark/benchmark.fill.js deleted file mode 100644 index d98109597..000000000 --- a/uint8c/benchmark/benchmark.fill.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':fill', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.fill.length.js b/uint8c/benchmark/benchmark.fill.length.js deleted file mode 100644 index 60c5757ae..000000000 --- a/uint8c/benchmark/benchmark.fill.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = i % 128; - arr = arr.fill( v ); - if ( arr[ 0 ] !== v ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( arr[ 0 ] !== arr[ 0 ] ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':fill:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.filter.js b/uint8c/benchmark/benchmark.filter.js deleted file mode 100644 index e1c52ee72..000000000 --- a/uint8c/benchmark/benchmark.filter.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); - -bench( pkg+'::this_context:filter', function benchmark( b ) { - var arr; - var out; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v >= 0; - } -}); diff --git a/uint8c/benchmark/benchmark.filter.length.js b/uint8c/benchmark/benchmark.filter.length.js deleted file mode 100644 index dffa04ec8..000000000 --- a/uint8c/benchmark/benchmark.filter.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value >= 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.filter( predicate ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':filter:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.find.js b/uint8c/benchmark/benchmark.find.js deleted file mode 100644 index d1f8b3431..000000000 --- a/uint8c/benchmark/benchmark.find.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:find', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate, {} ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint8c/benchmark/benchmark.find.length.js b/uint8c/benchmark/benchmark.find.length.js deleted file mode 100644 index bbdca5941..000000000 --- a/uint8c/benchmark/benchmark.find.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - tuple length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.find( predicate ); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof out !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':find:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.find_index.js b/uint8c/benchmark/benchmark.find_index.js deleted file mode 100644 index 439909a4e..000000000 --- a/uint8c/benchmark/benchmark.find_index.js +++ /dev/null @@ -1,82 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:findIndex', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate, {} ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint8c/benchmark/benchmark.find_index.length.js b/uint8c/benchmark/benchmark.find_index.length.js deleted file mode 100644 index 5aadd9b11..000000000 --- a/uint8c/benchmark/benchmark.find_index.length.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.findIndex( predicate ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':findIndex:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.for_each.js b/uint8c/benchmark/benchmark.for_each.js deleted file mode 100644 index 0666c43c2..000000000 --- a/uint8c/benchmark/benchmark.for_each.js +++ /dev/null @@ -1,88 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint8ClampedArray( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); - -bench( pkg+'::this_context:forEach', function benchmark( b ) { - var count; - var arr; - var N; - var i; - - arr = new Uint8ClampedArray( 2 ); - N = arr.length; - - count = 0; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn, {} ); - if ( count !== N*(i+1) ) { - b.fail( 'unexpected result' ); - } - } - b.toc(); - if ( count !== N*i ) { - b.fail( 'unexpected result' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn() { - count += 1; - } -}); diff --git a/uint8c/benchmark/benchmark.for_each.length.js b/uint8c/benchmark/benchmark.for_each.length.js deleted file mode 100644 index e24aed6a8..000000000 --- a/uint8c/benchmark/benchmark.for_each.length.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var count; - var arr; - - arr = new Uint8ClampedArray( len ); - count = 0; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr.forEach( fcn ); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - } - b.toc(); - if ( count !== count ) { - b.fail( 'should not be NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - /** - * Callback invoked for each tuple element. - * - * @private - */ - function fcn() { - count += 1; - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':forEach:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.from.js b/uint8c/benchmark/benchmark.from.js deleted file mode 100644 index 9ed431a30..000000000 --- a/uint8c/benchmark/benchmark.from.js +++ /dev/null @@ -1,237 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 ITERATOR_SYMBOL = require( '@stdlib/symbol/iterator' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// VARIABLES // - -var opts = { - 'skip': ( ITERATOR_SYMBOL === null ) -}; - - -// MAIN // - -bench( pkg+'::typed_array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8ClampedArray( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8ClampedArray.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( arr ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = new Uint8ClampedArray( [ 1, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8ClampedArray.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( arr ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::array:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8ClampedArray.from( buf ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( arr ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array,clbk:from', function benchmark( b ) { - var buf; - var arr; - var i; - - buf = [ 1, 2 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8ClampedArray.from( buf, clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( arr ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function clbk( v ) { - return v + 1; - } -}); - -bench( pkg+'::iterable:from', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8ClampedArray.from( createIterable() ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( arr ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 0, - 'done': false - }; - } - return { - 'done': true - }; - } - } -}); - -bench( pkg+'::iterable,clbk:from:', opts, function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8ClampedArray.from( createIterable(), clbk ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( arr ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function createIterable() { - var out; - var i; - - out = {}; - out[ ITERATOR_SYMBOL ] = iterator; - - i = 0; - - return out; - - function iterator() { - return { - 'next': next - }; - } - - function next() { - i += 1; - if ( i <= 2 ) { - return { - 'value': 1, - 'done': false - }; - } - return { - 'done': true - }; - } - } - - function clbk( v ) { - return v + 1; - } -}); diff --git a/uint8c/benchmark/benchmark.includes.js b/uint8c/benchmark/benchmark.includes.js deleted file mode 100644 index b709e50ca..000000000 --- a/uint8c/benchmark/benchmark.includes.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':includes', function benchmark( b ) { - var bool; - var arr; - var v; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.includes.length.js b/uint8c/benchmark/benchmark.includes.length.js deleted file mode 100644 index d6ff5c71f..000000000 --- a/uint8c/benchmark/benchmark.includes.length.js +++ /dev/null @@ -1,96 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - bool = arr.includes( v ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':includes:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.index_of.js b/uint8c/benchmark/benchmark.index_of.js deleted file mode 100644 index 8cb378320..000000000 --- a/uint8c/benchmark/benchmark.index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':indexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint8ClampedArray( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.index_of.length.js b/uint8c/benchmark/benchmark.index_of.length.js deleted file mode 100644 index 9b55a7f8e..000000000 --- a/uint8c/benchmark/benchmark.index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.indexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':indexOf:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.join.js b/uint8c/benchmark/benchmark.join.js deleted file mode 100644 index ee4ac6254..000000000 --- a/uint8c/benchmark/benchmark.join.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':join', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.join.length.js b/uint8c/benchmark/benchmark.join.length.js deleted file mode 100644 index 7b7c9d89f..000000000 --- a/uint8c/benchmark/benchmark.join.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i % 127; - out = arr.join(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':join:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.js b/uint8c/benchmark/benchmark.js deleted file mode 100644 index 19af7aad1..000000000 --- a/uint8c/benchmark/benchmark.js +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( arr ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.keys.js b/uint8c/benchmark/benchmark.keys.js deleted file mode 100644 index 9f472e0b5..000000000 --- a/uint8c/benchmark/benchmark.keys.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':keys', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.keys(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.last_index_of.js b/uint8c/benchmark/benchmark.last_index_of.js deleted file mode 100644 index 97746402a..000000000 --- a/uint8c/benchmark/benchmark.last_index_of.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':lastIndexOf', function benchmark( b ) { - var out; - var arr; - var v; - var i; - - arr = new Uint8ClampedArray( 2 ); - - // Benchmark worst case scenario... - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.last_index_of.length.js b/uint8c/benchmark/benchmark.last_index_of.length.js deleted file mode 100644 index e509fd027..000000000 --- a/uint8c/benchmark/benchmark.last_index_of.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = (i%127) + 1; - out = arr.lastIndexOf( v ); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - } - b.toc(); - if ( out !== -1 ) { - b.fail( 'should return -1' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':lastIndexOf:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.length.js b/uint8c/benchmark/benchmark.length.js deleted file mode 100644 index faf73d883..000000000 --- a/uint8c/benchmark/benchmark.length.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var ctor = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = new ctor( len ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( arr ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.map.js b/uint8c/benchmark/benchmark.map.js deleted file mode 100644 index a28681c85..000000000 --- a/uint8c/benchmark/benchmark.map.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); - -bench( pkg+'::this_context:map', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn, {} ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint8c/benchmark/benchmark.map.length.js b/uint8c/benchmark/benchmark.map.length.js deleted file mode 100644 index 40011ea58..000000000 --- a/uint8c/benchmark/benchmark.map.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Maps an array element to a new value. -* -* @private -* @param {*} value - array element -* @returns {*} new value -*/ -function fcn( value ) { - return value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.map( fcn ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':map:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.of.js b/uint8c/benchmark/benchmark.of.js deleted file mode 100644 index 41b32ac8a..000000000 --- a/uint8c/benchmark/benchmark.of.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':of', function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = Uint8ClampedArray.of( i, 2 ); - if ( arr.length !== 2 ) { - b.fail( 'should have length 2' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( arr ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.properties.js b/uint8c/benchmark/benchmark.properties.js deleted file mode 100644 index ca8f308ce..000000000 --- a/uint8c/benchmark/benchmark.properties.js +++ /dev/null @@ -1,145 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayBuffer = require( '@stdlib/assert/is-arraybuffer' ); -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::get:buffer', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.buffer; - if ( typeof v !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isArrayBuffer( v ) ) { - b.fail( 'should return an ArrayBuffer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteLength', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteLength; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:byteOffset', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.byteOffset; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:BYTES_PER_ELEMENT', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.BYTES_PER_ELEMENT; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::get:length', function benchmark( b ) { - var arr; - var v; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: the following may be optimized away due to loop invariant code motion and/or other compiler optimizations, rendering this benchmark meaningless... - v = arr.length; - if ( v !== v ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( !isNonNegativeInteger( v ) ) { - b.fail( 'should return a nonnegative integer' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.reduce.js b/uint8c/benchmark/benchmark.reduce.js deleted file mode 100644 index b28a5ddb1..000000000 --- a/uint8c/benchmark/benchmark.reduce.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduce', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint8c/benchmark/benchmark.reduce.length.js b/uint8c/benchmark/benchmark.reduce.length.js deleted file mode 100644 index eb3e2e507..000000000 --- a/uint8c/benchmark/benchmark.reduce.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduce( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduce:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.reduce_right.js b/uint8c/benchmark/benchmark.reduce_right.js deleted file mode 100644 index 0e2cefa21..000000000 --- a/uint8c/benchmark/benchmark.reduce_right.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( acc, v ) { - return acc + v + 1; - } -}); - -bench( pkg+'::initial_value:reduceRight', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn, 3 ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function fcn( v ) { - return v + 1; - } -}); diff --git a/uint8c/benchmark/benchmark.reduce_right.length.js b/uint8c/benchmark/benchmark.reduce_right.length.js deleted file mode 100644 index cd48ec9e8..000000000 --- a/uint8c/benchmark/benchmark.reduce_right.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Updates an accumulated value. -* -* @private -* @param {*} acc - accumulated value -* @param {*} value - array element -* @returns {*} accumulated value -*/ -function fcn( acc, value ) { - return acc + value + 1; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.reduceRight( fcn ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reduceRight:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.reverse.js b/uint8c/benchmark/benchmark.reverse.js deleted file mode 100644 index 17e6ec0e9..000000000 --- a/uint8c/benchmark/benchmark.reverse.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':reverse', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.reverse.length.js b/uint8c/benchmark/benchmark.reverse.length.js deleted file mode 100644 index 6e77be0c7..000000000 --- a/uint8c/benchmark/benchmark.reverse.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.reverse(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':reverse:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.set.js b/uint8c/benchmark/benchmark.set.js deleted file mode 100644 index f4076722b..000000000 --- a/uint8c/benchmark/benchmark.set.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = []; - for ( i = 0; i < 10; i++ ) { - values.push( i ); - } - N = values.length; - - arr = new Uint8ClampedArray( 2 ); - buf = [ 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array:set', function benchmark( b ) { - var values; - var buf; - var arr; - var N; - var v; - var i; - - values = new Uint8ClampedArray( 20 ); - N = values.length; - for ( i = 0; i < N; i++ ) { - values[ i ] = i; - } - - arr = new Uint8ClampedArray( 2 ); - buf = new Uint8ClampedArray( 1 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - buf[ 0 ] = values[ i%N ]; - v = arr.set( buf ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.set.length.js b/uint8c/benchmark/benchmark.set.length.js deleted file mode 100644 index 8aa893881..000000000 --- a/uint8c/benchmark/benchmark.set.length.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var values; - var arr1; - var arr2; - var arr; - var N; - var i; - - arr1 = []; - arr2 = []; - for ( i = 0; i < len; i++ ) { - arr1.push( randi() ); - arr2.push( randi() ); - } - arr = new Uint8ClampedArray( len ); - - values = [ - arr1, - arr2 - ]; - N = values.length; - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var v; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = arr.set( values[ i%N ] ); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - } - b.toc(); - if ( typeof v !== 'undefined' ) { - b.fail( 'should return undefined' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':set:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.slice.js b/uint8c/benchmark/benchmark.slice.js deleted file mode 100644 index d1e0cda9a..000000000 --- a/uint8c/benchmark/benchmark.slice.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':slice', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.slice.length.js b/uint8c/benchmark/benchmark.slice.length.js deleted file mode 100644 index 82e5f6915..000000000 --- a/uint8c/benchmark/benchmark.slice.length.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.slice(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':slice:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.some.js b/uint8c/benchmark/benchmark.some.js deleted file mode 100644 index ad545e25e..000000000 --- a/uint8c/benchmark/benchmark.some.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); - -bench( pkg+'::this_context:some', function benchmark( b ) { - var bool; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate, {} ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function predicate( v ) { - return v > 0; - } -}); diff --git a/uint8c/benchmark/benchmark.some.length.js b/uint8c/benchmark/benchmark.some.length.js deleted file mode 100644 index 79f4623f1..000000000 --- a/uint8c/benchmark/benchmark.some.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a boolean indicating whether an array element passes a test. -* -* @private -* @param {*} value - value to test -* @returns {boolean} boolean indicating whether an array element passes a test -*/ -function predicate( value ) { - return value > 0; -} - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - bool = arr.some( predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':some:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.sort.js b/uint8c/benchmark/benchmark.sort.js deleted file mode 100644 index 291a17351..000000000 --- a/uint8c/benchmark/benchmark.sort.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 randi = require( '@stdlib/random/base/randi' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':sort', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( [ randi(), randi() ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.sort.length.js b/uint8c/benchmark/benchmark.sort.length.js deleted file mode 100644 index cc5197865..000000000 --- a/uint8c/benchmark/benchmark.sort.length.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var randi = require( '@stdlib/random/base/randi' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var data; - var arr; - var i; - - data = []; - for ( i = 0; i < len; i++ ) { - data.push( randi() ); - } - arr = new Uint8ClampedArray( data ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ i%len ] = randi(); - out = arr.sort(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':sort:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.subarray.js b/uint8c/benchmark/benchmark.subarray.js deleted file mode 100644 index 6fac854ff..000000000 --- a/uint8c/benchmark/benchmark.subarray.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':subarray', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.subarray.length.js b/uint8c/benchmark/benchmark.subarray.length.js deleted file mode 100644 index 70c5d0c4c..000000000 --- a/uint8c/benchmark/benchmark.subarray.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isUint8ClampedArray = require( '@stdlib/assert/is-uint8clampedarray' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arr.subarray(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isUint8ClampedArray( out ) ) { - b.fail( 'should return a Uint8ClampedArray' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':subarray:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.to_locale_string.js b/uint8c/benchmark/benchmark.to_locale_string.js deleted file mode 100644 index d214048ed..000000000 --- a/uint8c/benchmark/benchmark.to_locale_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toLocaleString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.to_locale_string.length.js b/uint8c/benchmark/benchmark.to_locale_string.length.js deleted file mode 100644 index 0963f1db0..000000000 --- a/uint8c/benchmark/benchmark.to_locale_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toLocaleString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toLocaleString:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.to_string.js b/uint8c/benchmark/benchmark.to_string.js deleted file mode 100644 index 0eb5fa464..000000000 --- a/uint8c/benchmark/benchmark.to_string.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':toString', function benchmark( b ) { - var out; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/benchmark/benchmark.to_string.length.js b/uint8c/benchmark/benchmark.to_string.length.js deleted file mode 100644 index d0eaa01f2..000000000 --- a/uint8c/benchmark/benchmark.to_string.length.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var arr = new Uint8ClampedArray( len ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr[ 0 ] = i; - out = arr.toString(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 5; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':toString:len='+len, f ); - } -} - -main(); diff --git a/uint8c/benchmark/benchmark.values.js b/uint8c/benchmark/benchmark.values.js deleted file mode 100644 index 64345b080..000000000 --- a/uint8c/benchmark/benchmark.values.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pkg = require( './../package.json' ).name; -var Uint8ClampedArray = require( './../lib' ); - - -// MAIN // - -bench( pkg+':values', function benchmark( b ) { - var iter; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - iter = arr.values(); - if ( typeof iter !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof iter !== 'object' || typeof iter.next !== 'function' ) { - b.fail( 'should return an iterator protocol-compliant object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/uint8c/docs/repl.txt b/uint8c/docs/repl.txt deleted file mode 100644 index 25c9a7d60..000000000 --- a/uint8c/docs/repl.txt +++ /dev/null @@ -1,953 +0,0 @@ - -{{alias}}() - A typed array constructor which returns a typed array representing an array - of 8-bit unsigned integers in the platform byte order clamped to 0-255. - - Returns - ------- - out: Uint8ClampedArray - A typed array. - - Examples - -------- - > var arr = new {{alias}}() - - - -{{alias}}( length ) - Returns a typed array having a specified length. - - Parameters - ---------- - length: integer - Typed array length. - - Returns - ------- - out: Uint8ClampedArray - A typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ) - [ 0, 0, 0, 0, 0 ] - - -{{alias}}( typedarray ) - Creates a typed array from another typed array. - - Parameters - ---------- - typedarray: TypedArray - Typed array from which to generate another typed array. - - Returns - ------- - out: Uint8ClampedArray - A typed array. - - Examples - -------- - > var arr1 = new {{alias:@stdlib/array/int32}}( [ 5, 5, 5 ] ); - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( obj ) - Creates a typed array from an array-like object or iterable. - - Parameters - ---------- - obj: Object - Array-like object or iterable from which to generate a typed array. - - Returns - ------- - out: Uint8ClampedArray - A typed array. - - Examples - -------- - > var arr1 = [ 5.0, 5.0, 5.0 ]; - > var arr2 = new {{alias}}( arr1 ) - [ 5, 5, 5 ] - - -{{alias}}( buffer[, byteOffset[, length]] ) - Returns a typed array view of an ArrayBuffer. - - Parameters - ---------- - buffer: ArrayBuffer - Underlying ArrayBuffer. - - byteOffset: integer (optional) - Integer byte offset specifying the location of the first typed array - element. Default: 0. - - length: integer (optional) - View length. If not provided, the view spans from the byteOffset to - the end of the underlying ArrayBuffer. - - Returns - ------- - out: Uint8ClampedArray - A typed array. - - Examples - -------- - > var buf = new {{alias:@stdlib/array/buffer}}( 4 ); - > var arr = new {{alias}}( buf, 0, 4 ) - [ 0, 0, 0, 0 ] - - -{{alias}}.from( src[, map[, thisArg]] ) - Creates a new typed array from an array-like object or an iterable. - - A callback is provided the following arguments: - - - value: source value. - - index: source index. - - Parameters - ---------- - src: ArrayLike|Iterable - Source of array elements. - - map: Function (optional) - Callback to invoke for each source element. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint8ClampedArray - A typed array. - - Examples - -------- - > function mapFcn( v ) { return v * 2; }; - > var arr = {{alias}}.from( [ 1, 2 ], mapFcn ) - [ 2, 4 ] - - -{{alias}}.of( element0[, element1[, ...elementN]] ) - Creates a new typed array from a variable number of arguments. - - Parameters - ---------- - element0: number - Array element. - - element1: number (optional) - Array element. - - elementN: ...number (optional) - Array elements. - - Returns - ------- - out: Uint8ClampedArray - A typed array. - - Examples - -------- - > var arr = {{alias}}.of( 1, 2 ) - [ 1, 2 ] - - -{{alias}}.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > {{alias}}.BYTES_PER_ELEMENT - 1 - - -{{alias}}.name - Typed array constructor name. - - Examples - -------- - > {{alias}}.name - 'Uint8ClampedArray' - - -{{alias}}.prototype.buffer - Read-only property which returns the ArrayBuffer referenced by the typed - array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.buffer - - - -{{alias}}.prototype.byteLength - Read-only property which returns the length (in bytes) of the typed array. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteLength - 5 - - -{{alias}}.prototype.byteOffset - Read-only property which returns the offset (in bytes) of the typed array - from the start of its ArrayBuffer. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.byteOffset - 0 - - -{{alias}}.prototype.BYTES_PER_ELEMENT - Number of bytes per view element. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.BYTES_PER_ELEMENT - 1 - - -{{alias}}.prototype.length - Read-only property which returns the number of view elements. - - Examples - -------- - > var arr = new {{alias}}( 5 ); - > arr.length - 5 - - -{{alias}}.prototype.copyWithin( target, start[, end] ) - Copies a sequence of elements within the array starting at `start` and - ending at `end` (non-inclusive) to the position starting at `target`. - - Parameters - ---------- - target: integer - Target start index position. - - start: integer - Source start index position. - - end: integer (optional) - Source end index position. Default: out.length. - - Returns - ------- - out: Uint8ClampedArray - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > arr.copyWithin( 3, 0, 2 ); - > arr[ 3 ] - 1 - > arr[ 4 ] - 2 - - -{{alias}}.prototype.entries() - Returns an iterator for iterating over array key-value pairs. - - Returns - ------- - iter: Iterator - Iterator for iterating over array key-value pairs. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.entries(); - > it.next().value - [ 0, 1 ] - > it.next().value - [ 1, 2 ] - > it.next().done - true - - -{{alias}}.prototype.every( predicate[, thisArg] ) - Tests whether all array elements pass a test implemented by a predicate - function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether all array elements pass. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v <= 1 ); }; - > arr.every( predicate ) - false - - -{{alias}}.prototype.fill( value[, start[, end]] ) - Fills an array from a start index to an end index (non-inclusive) with a - provided value. - - Parameters - ---------- - value: number - Fill value. - - start: integer (optional) - Start index. If less than zero, the start index is resolved relative to - the last array element. Default: 0. - - end: integer (optional) - End index (non-inclusive). If less than zero, the end index is resolved - relative to the last array element. Default: out.length. - - Returns - ------- - out: Uint8ClampedArray - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > arr.fill( 3 ); - > arr[ 0 ] - 3 - > arr[ 1 ] - 3 - - -{{alias}}.prototype.filter( predicate[, thisArg] ) - Creates a new array which includes those elements for which a predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - If a predicate function does not return a truthy value for any array - element, the method returns an empty array. - - Parameters - ---------- - predicate: Function - Predicate function which filters array elements. If a predicate function - returns a truthy value, an array element is included in the output - array; otherwise, an array element is not included in the output array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint8ClampedArray - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > var arr2 = arr1.filter( predicate ); - > arr2.length - 2 - - -{{alias}}.prototype.find( predicate[, thisArg] ) - Returns the first array element for which a provided predicate function - returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `undefined`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - value: number|undefined - Array element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var v = arr.find( predicate ) - 3 - - -{{alias}}.prototype.findIndex( predicate[, thisArg] ) - Returns the index of the first array element for which a provided predicate - function returns a truthy value. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - If a predicate function never returns a truthy value, the method returns - `-1`. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function predicate( v ) { return ( v > 2 ); }; - > var idx = arr.findIndex( predicate ) - 2 - - -{{alias}}.prototype.forEach( fcn[, thisArg] ) - Invokes a callback for each array element. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - fcn: Function - Function to invoke for each array element. - - thisArg: Any (optional) - Callback execution context. - - Examples - -------- - > var arr = new {{alias}}( [ 3, 2, 1 ] ); - > var str = ' '; - > function fcn( v, i ) { str += i + ':' + v + ' '; }; - > arr.forEach( fcn ); - > str - ' 0:3 1:2 2:1 ' - - -{{alias}}.prototype.includes( searchElement[, fromIndex] ) - Returns a boolean indicating whether an array includes a search element. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - bool: boolean - Boolean indicating whether an array includes a search element. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var bool = arr.includes( 4 ) - false - > bool = arr.includes( 3 ) - true - - -{{alias}}.prototype.indexOf( searchElement[, fromIndex] ) - Returns the index of the first array element strictly equal to a search - element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: 0. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > var idx = arr.indexOf( 4 ) - -1 - > idx = arr.indexOf( 3 ) - 2 - - -{{alias}}.prototype.join( [separator] ) - Serializes an array by joining all array elements as a string. - - Parameters - ---------- - separator: string (optional) - String delineating array elements. Default: ','. - - Returns - ------- - str: string - Array serialized as a string. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.join( '|' ) - '1|2|3' - - -{{alias}}.prototype.keys() - Returns an iterator for iterating over array keys. - - Returns - ------- - iter: Iterator - Iterator for iterating over array keys. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.keys(); - > it.next().value - 0 - > it.next().value - 1 - > it.next().done - true - - -{{alias}}.prototype.lastIndexOf( searchElement[, fromIndex] ) - Returns the index of the last array element strictly equal to a search - element. - - The method iterates from the last array element to the first array element. - - If unable to locate a search element, the method returns `-1`. - - Parameters - ---------- - searchElement: number - Search element. - - fromIndex: integer (optional) - Array index from which to begin searching. If provided a negative value, - the method resolves the start index relative to the last array element. - Default: -1. - - Returns - ------- - idx: integer - Array index. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 0, 2, 0, 1 ] ); - > var idx = arr.lastIndexOf( 3 ) - -1 - > idx = arr.lastIndexOf( 0 ) - 3 - - -{{alias}}.prototype.map( fcn[, thisArg] ) - Maps each array element to an element in a new typed array. - - A provided function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - The returned array has the same data type as the host array. - - Parameters - ---------- - fcn: Function - Function which maps array elements to elements in the new array. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - out: Uint8ClampedArray - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( v ) { return v * 2; }; - > var arr2 = arr1.map( fcn ) - [ 2, 4, 6 ] - - -{{alias}}.prototype.reduce( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the first array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the first array element as the first argument and the second array - element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduce( fcn, 0 ) - 14 - - -{{alias}}.prototype.reduceRight( fcn[, initialValue] ) - Applies a function against an accumulator and each element in an array and - returns the accumulated result, iterating from right to left. - - The provided function is provided the following arguments: - - - acc: accumulated result. - - value: current array element. - - index: index of the current array element. - - arr: array on which the method is invoked. - - If provided an initial value, the method invokes a provided function with - the initial value as the first argument and the last array element as the - second argument. - - If not provided an initial value, the method invokes a provided function - with the last array element as the first argument and the second-to-last - array element as the second argument. - - Parameters - ---------- - fcn: Function - Function to apply. - - initialValue: Any (optional) - Initial accumulation value. - - Returns - ------- - out: Any - Accumulated result. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > function fcn( acc, v ) { return acc + (v*v); }; - > var v = arr.reduceRight( fcn, 0 ) - 14 - - -{{alias}}.prototype.reverse() - Reverses an array *in-place*. - - This method mutates the array on which the method is invoked. - - Returns - ------- - out: Uint8ClampedArray - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ) - - > arr.reverse() - [ 3, 2, 1 ] - - -{{alias}}.prototype.set( arr[, offset] ) - Sets array elements. - - Parameters - ---------- - arr: ArrayLike - Source array containing array values to set. - - offset: integer (optional) - Array index at which to start writing values. Default: 0. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.set( [ 4, 4 ], 1 ); - > arr[ 1 ] - 4 - > arr[ 2 ] - 4 - - -{{alias}}.prototype.slice( [begin[, end]] ) - Copies array elements to a new array with the same underlying data type as - the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint8ClampedArray - A typed array. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3 ] ); - > var arr2 = arr1.slice( 1 ); - > arr2.length - 2 - > arr2[ 0 ] - 2 - > arr2[ 1 ] - 3 - - -{{alias}}.prototype.some( predicate[, thisArg] ) - Tests whether at least one array element passes a test implemented by a - predicate function. - - A predicate function is provided the following arguments: - - - value: array element. - - index: array index. - - arr: array on which the method is invoked. - - Parameters - ---------- - predicate: Function - Predicate function which tests array elements. If a predicate function - returns a truthy value, an array element passes; otherwise, an array - element fails. - - thisArg: Any (optional) - Callback execution context. - - Returns - ------- - bool: boolean - Boolean indicating whether at least one array element passes. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > function predicate( v ) { return ( v > 1 ); }; - > arr.some( predicate ) - true - - -{{alias}}.prototype.sort( [compareFunction] ) - Sorts an array *in-place*. - - The comparison function is provided two array elements per invocation: `a` - and `b`. - - The comparison function return value determines the sort order as follows: - - - If the comparison function returns a value less than zero, then the method - sorts `a` to an index lower than `b` (i.e., `a` should come *before* `b`). - - - If the comparison function returns a value greater than zero, then the - method sorts `a` to an index higher than `b` (i.e., `b` should come *before* - `a`). - - - If the comparison function returns zero, then the relative order of `a` - and `b` should remain unchanged. - - This method mutates the array on which the method is invoked. - - Parameters - ---------- - compareFunction: Function (optional) - Function which specifies the sort order. The default sort order is - ascending order. - - Returns - ------- - out: Uint8ClampedArray - Modified array. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 0, 2, 1 ] ); - > arr.sort() - [ 0, 1, 1, 2, 2 ] - - -{{alias}}.prototype.subarray( [begin[, end]] ) - Creates a new typed array over the same underlying ArrayBuffer and with the - same underlying data type as the host array. - - If the method is unable to resolve indices to a non-empty array subsequence, - the method returns an empty typed array. - - Parameters - ---------- - begin: integer (optional) - Start element index (inclusive). If less than zero, the start index is - resolved relative to the last array element. Default: 0. - - end: integer (optional) - End element index (exclusive). If less than zero, the end index is - resolved relative to the last array element. Default: arr.length. - - Returns - ------- - out: Uint8ClampedArray - A new typed array view. - - Examples - -------- - > var arr1 = new {{alias}}( [ 1, 2, 3, 4, 5 ] ); - > var arr2 = arr1.subarray( 2 ) - [ 3, 4, 5 ] - - -{{alias}}.prototype.toLocaleString( [locales[, options]] ) - Serializes an array as a locale-specific string. - - Parameters - ---------- - locales: string|Array (optional) - A BCP 47 language tag, or an array of such tags. - - options: Object (optional) - Options. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toLocaleString() - '1,2,3' - - -{{alias}}.prototype.toString() - Serializes an array as a string. - - Returns - ------- - str: string - A typed array string representation. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2, 3 ] ); - > arr.toString() - '1,2,3' - - -{{alias}}.prototype.values() - Returns an iterator for iterating over array elements. - - Returns - ------- - iter: Iterator - Iterator for iterating over array elements. - - Examples - -------- - > var arr = new {{alias}}( [ 1, 2 ] ); - > it = arr.values(); - > it.next().value - 1 - > it.next().value - 2 - > it.next().done - true - - - See Also - -------- - diff --git a/uint8c/docs/types/index.d.ts b/uint8c/docs/types/index.d.ts deleted file mode 100644 index 516251ee3..000000000 --- a/uint8c/docs/types/index.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -// EXPORTS // - -/** -* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order clamped to 0-255. -*/ -export = Uint8ClampedArray; diff --git a/uint8c/docs/types/test.ts b/uint8c/docs/types/test.ts deleted file mode 100644 index 3a113febc..000000000 --- a/uint8c/docs/types/test.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* eslint-disable @typescript-eslint/no-unused-expressions */ - -import Uint8ClampedArray = require( './index' ); - - -// TESTS // - -// The function returns a typed array instance... -{ - new Uint8ClampedArray( 10 ); // $ExpectType Uint8ClampedArray - new Uint8ClampedArray( [ 2, 5, 5, 7 ] ); // $ExpectType Uint8ClampedArray -} - -// The constructor function has to be invoked with `new`... -{ - Uint8ClampedArray( 10 ); // $ExpectError - Uint8ClampedArray( [ 2, 5, 5, 7 ] ); // $ExpectError -} diff --git a/uint8c/examples/index.js b/uint8c/examples/index.js deleted file mode 100644 index d0978bec8..000000000 --- a/uint8c/examples/index.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var ctor = require( './../lib' ); - -var arr; -var i; - -arr = new ctor( 10 ); -for ( i = 0; i < arr.length; i++ ) { - arr[ i ] = round( randu()*100.0 ); -} -console.log( arr ); diff --git a/uint8c/lib/index.js b/uint8c/lib/index.js deleted file mode 100644 index 2d7e79f2d..000000000 --- a/uint8c/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Typed array constructor which returns a typed array representing an array of 8-bit unsigned integers in the platform byte order clamped to 0-255. -* -* @module @stdlib/array/uint8c -* -* @example -* var ctor = require( '@stdlib/array/uint8c' ); -* -* var arr = new ctor( 10 ); -* // returns -*/ - -// MODULES // - -var hasUint8ClampedArraySupport = require( '@stdlib/assert/has-uint8clampedarray-support' ); // eslint-disable-line id-length -var builtin = require( './main.js' ); -var polyfill = require( './polyfill.js' ); - - -// MAIN // - -var ctor; -if ( hasUint8ClampedArraySupport() ) { - ctor = builtin; -} else { - ctor = polyfill; -} - - -// EXPORTS // - -module.exports = ctor; diff --git a/uint8c/lib/main.js b/uint8c/lib/main.js deleted file mode 100644 index ea97aa459..000000000 --- a/uint8c/lib/main.js +++ /dev/null @@ -1,28 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -var ctor = ( typeof Uint8ClampedArray === 'function' ) ? Uint8ClampedArray : void 0; // eslint-disable-line stdlib/require-globals - - -// EXPORTS // - -module.exports = ctor; diff --git a/uint8c/lib/polyfill.js b/uint8c/lib/polyfill.js deleted file mode 100644 index 76e599e06..000000000 --- a/uint8c/lib/polyfill.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// TODO: write polyfill - -// MAIN // - -/** -* Typed array which represents an array of 8-bit unsigned integers in the platform byte order clamped to 0-255. -* -* @throws {Error} not implemented -*/ -function polyfill() { - throw new Error( 'not implemented' ); -} - - -// EXPORTS // - -module.exports = polyfill; diff --git a/uint8c/package.json b/uint8c/package.json deleted file mode 100644 index 1ac54931e..000000000 --- a/uint8c/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@stdlib/array/uint8c", - "version": "0.0.0", - "description": "Uint8ClampedArray.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "array", - "typed", - "typed array", - "typed-array", - "uint8clampedarray", - "uint8clamped", - "clamped", - "uint8", - "uint8_t", - "integer", - "int", - "uint", - "unsigned", - "byte", - "octet" - ] -} diff --git a/uint8c/test/test.copy_within.js b/uint8c/test/test.copy_within.js deleted file mode 100644 index 386560bf0..000000000 --- a/uint8c/test/test.copy_within.js +++ /dev/null @@ -1,320 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 hasProp = require( '@stdlib/assert/has-property' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var Uint8ClampedArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof Uint8ClampedArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'a typed array instance has a `copyWithin` method for copying a sequence of elements within a typed array', function test( t ) { - var arr = new Uint8ClampedArray( 2 ); - t.strictEqual( hasProp( arr, 'copyWithin' ), true, 'has property' ); - t.strictEqual( isFunction( arr.copyWithin ), true, 'has method' ); - t.end(); -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0 ); - }; - } -}); - -tape( 'the method throws an error if invoked with a `this` context which is not a typed array instance (end)', function test( t ) { - var values; - var arr; - var i; - - arr = new Uint8ClampedArray( 2 ); - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [] - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - return arr.copyWithin.call( value, 3, 0, 5 ); - }; - } -}); - -tape( 'the method copies a sequence of elements within a typed array', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8ClampedArray( arr ); - p.copyWithin( 0, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative target)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8ClampedArray( arr ); - p.copyWithin( -p.length, 3 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8ClampedArray( arr ); - p.copyWithin( 0, -2 ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (end=length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8ClampedArray( arr ); - p.copyWithin( 0, 3, p.length ); - - // Overwritten: - t.strictEqual( p[ 0 ], 3, 'returns expected value' ); - t.strictEqual( p[ 1 ], 4, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (non-inclusive end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8ClampedArray( arr ); - p.copyWithin( 2, 0, 2 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (negative end)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8ClampedArray( arr ); - p.copyWithin( 2, 0, -3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - - // Remain the same: - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target >= length)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8ClampedArray( arr ); - p.copyWithin( p.length, 3 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - t.strictEqual( p[ 2 ], 2, 'returns expected value' ); - t.strictEqual( p[ 3 ], 3, 'returns expected value' ); - t.strictEqual( p[ 4 ], 4, 'returns expected value' ); - - t.end(); -}); - -tape( 'the method copies a sequence of elements within a typed array (target > start)', function test( t ) { - var arr; - var p; - - arr = [ - 0, - 1, - 2, - 3, - 4 - ]; - - p = new Uint8ClampedArray( arr ); - p.copyWithin( 2, 0 ); - - // Remain the same: - t.strictEqual( p[ 0 ], 0, 'returns expected value' ); - t.strictEqual( p[ 1 ], 1, 'returns expected value' ); - - // Overwritten: - t.strictEqual( p[ 2 ], 0, 'returns expected value' ); - t.strictEqual( p[ 3 ], 1, 'returns expected value' ); - t.strictEqual( p[ 4 ], 2, 'returns expected value' ); - - t.end(); -}); diff --git a/uint8c/test/test.js b/uint8c/test/test.js deleted file mode 100644 index 4da60c6c5..000000000 --- a/uint8c/test/test.js +++ /dev/null @@ -1,80 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var hasUint8ClampedArraySupport = require( '@stdlib/assert/has-uint8clampedarray-support' ); -var polyfill = require( './../lib/polyfill.js' ); -var ctor = require( './../lib' ); - - -// VARIABLES // - -var hasUint8ClampedArrays = hasUint8ClampedArraySupport(); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'if an environment supports `Uint8ClampedArray`, the export is an alias for `Uint8ClampedArray`', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-uint8clampedarray-support': isTrue, - './main.js': Mock - }); - t.strictEqual( Foo, Mock, 'returns builtin' ); - - if ( hasUint8ClampedArrays ) { - t.strictEqual( ctor, Uint8ClampedArray, 'is alias' ); // eslint-disable-line stdlib/require-globals - } - - t.end(); - - function Mock() { - return this; - } - - function isTrue() { - return true; - } -}); - -tape( 'if an environment does not support `Uint8ClampedArray`, the export is a polyfill', function test( t ) { - var Foo; - - Foo = proxyquire( './../lib', { - '@stdlib/assert/has-uint8clampedarray-support': isFalse - }); - - t.strictEqual( Foo, polyfill, 'returns polyfill' ); - t.end(); - - function isFalse() { - return false; - } -}); diff --git a/uint8c/test/test.polyfill.js b/uint8c/test/test.polyfill.js deleted file mode 100644 index 9d6fcb190..000000000 --- a/uint8c/test/test.polyfill.js +++ /dev/null @@ -1,44 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var ctor = require( './../lib/polyfill.js' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ctor, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error when invoked', function test( t ) { - t.throws( foo, Error, 'throws an error' ); - t.end(); - - function foo() { - var f = new ctor(); // eslint-disable-line no-unused-vars - } -}); - -// TODO: tests diff --git a/zero-to-like/README.md b/zero-to-like/README.md deleted file mode 100644 index 633f65c01..000000000 --- a/zero-to-like/README.md +++ /dev/null @@ -1,178 +0,0 @@ - - -# zeroToLike - -> Generate a linearly spaced numeric array whose elements increment by `1` starting from zero and having the same length and data type as a provided input array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var zeroToLike = require( '@stdlib/array/zero-to-like' ); -``` - -#### zeroToLike( x\[, dtype] ) - -Generates a linearly spaced numeric array whose elements increment by `1` starting from zero and having the same length and data type as a provided input array `x`. - -```javascript -var arr = zeroToLike( [ 0, 0, 0, 0, 0 ] ); -// returns [ 0, 1, 2, 3, 4 ] -``` - -The function recognizes the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers -- `int32`: 32-bit two's complement signed integers -- `uint32`: 32-bit unsigned integers -- `int16`: 16-bit two's complement signed integers -- `uint16`: 16-bit unsigned integers -- `int8`: 8-bit two's complement signed integers -- `uint8`: 8-bit unsigned integers -- `uint8c`: 8-bit unsigned integers clamped to `0-255` -- `generic`: generic JavaScript values - -By default, the output array data type is inferred from the provided array `x`. To return an array having a different data type, provide a `dtype` argument. - -```javascript -var arr = zeroToLike( [ 0, 0, 0, 0, 0 ], 'int32' ); -// returns [ 0, 1, 2, 3, 4 ] -``` - -
- - - - - -
- -## Notes - -- For complex number arrays, each element of the returned array has an imaginary component equal to `0`. - -
- - - - - -
- -## Examples - - - -```javascript -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroToLike = require( '@stdlib/array/zero-to-like' ); - -// Generate an array of random numbers: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 10, 100, 200, opts ); - -// Generate an array of indices: -var idx = zeroToLike( x ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort the index array according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, idx, 1 ); - -console.log( x ); -console.log( idx ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/zero-to-like/benchmark/benchmark.js b/zero-to-like/benchmark/benchmark.js deleted file mode 100644 index 467e2cb97..000000000 --- a/zero-to-like/benchmark/benchmark.js +++ /dev/null @@ -1,317 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex128' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8c' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'generic' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/zero-to-like/benchmark/benchmark.length.complex128.js b/zero-to-like/benchmark/benchmark.length.complex128.js deleted file mode 100644 index cf4a4ac8a..000000000 --- a/zero-to-like/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex128' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/benchmark/benchmark.length.complex64.js b/zero-to-like/benchmark/benchmark.length.complex64.js deleted file mode 100644 index f4f6c80a8..000000000 --- a/zero-to-like/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/benchmark/benchmark.length.float32.js b/zero-to-like/benchmark/benchmark.length.float32.js deleted file mode 100644 index 3a3a12094..000000000 --- a/zero-to-like/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/benchmark/benchmark.length.float64.js b/zero-to-like/benchmark/benchmark.length.float64.js deleted file mode 100644 index 89d95fc61..000000000 --- a/zero-to-like/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/benchmark/benchmark.length.generic.js b/zero-to-like/benchmark/benchmark.length.generic.js deleted file mode 100644 index 85332bab0..000000000 --- a/zero-to-like/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/benchmark/benchmark.length.int16.js b/zero-to-like/benchmark/benchmark.length.int16.js deleted file mode 100644 index 0eca96e65..000000000 --- a/zero-to-like/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/benchmark/benchmark.length.int32.js b/zero-to-like/benchmark/benchmark.length.int32.js deleted file mode 100644 index 50f6a77ff..000000000 --- a/zero-to-like/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/benchmark/benchmark.length.int8.js b/zero-to-like/benchmark/benchmark.length.int8.js deleted file mode 100644 index 18f9ea557..000000000 --- a/zero-to-like/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/benchmark/benchmark.length.uint16.js b/zero-to-like/benchmark/benchmark.length.uint16.js deleted file mode 100644 index df29c977e..000000000 --- a/zero-to-like/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/benchmark/benchmark.length.uint32.js b/zero-to-like/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 02bd2060a..000000000 --- a/zero-to-like/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/benchmark/benchmark.length.uint8.js b/zero-to-like/benchmark/benchmark.length.uint8.js deleted file mode 100644 index ec101076c..000000000 --- a/zero-to-like/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/benchmark/benchmark.length.uint8c.js b/zero-to-like/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 8d67dd6b8..000000000 --- a/zero-to-like/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,95 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zeroToLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8c' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroToLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/zero-to-like/docs/repl.txt b/zero-to-like/docs/repl.txt deleted file mode 100644 index 6c86b632d..000000000 --- a/zero-to-like/docs/repl.txt +++ /dev/null @@ -1,45 +0,0 @@ - -{{alias}}( x[, dtype] ) - Generates a linearly spaced numeric array whose elements increment by 1 - starting from zero and having the same length and data type as a provided - input array. - - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754). - - float32: single-precision floating-point numbers (IEEE 754). - - complex128: double-precision complex floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - int32: 32-bit two's complement signed integers. - - uint32: 32-bit unsigned integers. - - int16: 16-bit two's complement signed integers. - - uint16: 16-bit unsigned integers. - - int8: 8-bit two's complement signed integers. - - uint8: 8-bit unsigned integers. - - uint8c: 8-bit unsigned integers clamped to 0-255. - - generic: generic JavaScript values. - - Parameters - ---------- - x: TypedArray|Array - Input array. - - dtype: string (optional) - Data type. If not provided, the output array data type is inferred from - the input array. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( [ 0, 0 ] ) - [ 0, 1 ] - > arr = {{alias}}( [ 0, 0 ], 'float32' ) - [ 0.0, 1.0 ] - - See Also - -------- - diff --git a/zero-to-like/docs/types/index.d.ts b/zero-to-like/docs/types/index.d.ts deleted file mode 100644 index 88f15b241..000000000 --- a/zero-to-like/docs/types/index.d.ts +++ /dev/null @@ -1,494 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Complex128Array, Complex64Array, AnyArray, NumericDataType } from '@stdlib/types/array'; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'float64' ); -* // returns [ 0.0, 1.0 ] -*/ -declare function zeroToLike( x: AnyArray, dtype: 'float64' ): Float64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'float32' ); -* // returns [ 0.0, 1.0 ] -*/ -declare function zeroToLike( x: AnyArray, dtype: 'float32' ): Float32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'complex128' ); -* // returns -*/ -declare function zeroToLike( x: AnyArray, dtype: 'complex128' ): Complex128Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'complex64' ); -* // returns -*/ -declare function zeroToLike( x: AnyArray, dtype: 'complex64' ): Complex64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'int32' ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: AnyArray, dtype: 'int32' ): Int32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'int16' ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: AnyArray, dtype: 'int16' ): Int16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'int8' ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: AnyArray, dtype: 'int8' ): Int8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'uint32' ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: AnyArray, dtype: 'uint32' ): Uint32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'uint16' ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: AnyArray, dtype: 'uint16' ): Uint16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'uint8' ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: AnyArray, dtype: 'uint8' ): Uint8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'uint8c' ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: AnyArray, dtype: 'uint8c' ): Uint8ClampedArray; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x, 'generic' ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: AnyArray, dtype: 'generic' ): Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x ); -* // returns [ 0.0, 1.0 ] -*/ -declare function zeroToLike( x: Float64Array, dtype?: NumericDataType ): Float64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x ); -* // returns [ 0.0, 1.0 ] -*/ -declare function zeroToLike( x: Float32Array, dtype?: NumericDataType ): Float32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex128' ); -* // returns -* -* var y = zeroToLike( x ); -* // returns -*/ -declare function zeroToLike( x: Complex128Array, dtype?: NumericDataType ): Complex128Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* ## Notes -* -* - Each element has an imaginary component equal to `0`. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'complex64' ); -* // returns -* -* var y = zeroToLike( x ); -* // returns -*/ -declare function zeroToLike( x: Complex64Array, dtype?: NumericDataType ): Complex64Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int32' ); -* // returns [ 0, 0 ] -* -* var y = zeroToLike( x ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: Int32Array, dtype?: NumericDataType ): Int32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int16' ); -* // returns [ 0, 0 ] -* -* var y = zeroToLike( x ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: Int16Array, dtype?: NumericDataType ): Int16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'int8' ); -* // returns [ 0, 0 ] -* -* var y = zeroToLike( x ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: Int8Array, dtype?: NumericDataType ): Int8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint32' ); -* // returns [ 0, 0 ] -* -* var y = zeroToLike( x ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: Uint32Array, dtype?: NumericDataType ): Uint32Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint16' ); -* // returns [ 0, 0 ] -* -* var y = zeroToLike( x ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: Uint16Array, dtype?: NumericDataType ): Uint16Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint8' ); -* // returns [ 0, 0 ] -* -* var y = zeroToLike( x ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: Uint8Array, dtype?: NumericDataType ): Uint8Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'uint8c' ); -* // returns [ 0, 0 ] -* -* var y = zeroToLike( x ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: Uint8ClampedArray, dtype?: NumericDataType ): Uint8ClampedArray; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'generic' ); -* // returns [ 0, 0 ] -* -* var y = zeroToLike( x ); -* // returns [ 0, 1 ] -*/ -declare function zeroToLike( x: Array, dtype?: NumericDataType ): Array; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns linearly spaced numeric array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zeroToLike( x ); -* // returns [ 0.0, 1.0 ] -*/ -declare function zeroToLike( x: AnyArray, dtype?: NumericDataType ): AnyArray; - - -// EXPORTS // - -export = zeroToLike; diff --git a/zero-to-like/docs/types/test.ts b/zero-to-like/docs/types/test.ts deleted file mode 100644 index 7e3519923..000000000 --- a/zero-to-like/docs/types/test.ts +++ /dev/null @@ -1,89 +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. -*/ - -import Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import zeroToLike = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - zeroToLike( [ 0, 0 ] ); // $ExpectType number[] - zeroToLike( new Float64Array( [ 0, 0 ] ) ); // $ExpectType Float64Array - zeroToLike( new Float32Array( [ 0, 0 ] ) ); // $ExpectType Float32Array - zeroToLike( new Complex128Array( [ 0, 0 ] ) ); // $ExpectType Complex128Array - zeroToLike( new Complex64Array( [ 0, 0 ] ) ); // $ExpectType Complex64Array - zeroToLike( new Int32Array( [ 0, 0 ] ) ); // $ExpectType Int32Array - zeroToLike( new Int16Array( [ 0, 0 ] ) ); // $ExpectType Int16Array - zeroToLike( new Int8Array( [ 0, 0 ] ) ); // $ExpectType Int8Array - zeroToLike( new Uint32Array( [ 0, 0 ] ) ); // $ExpectType Uint32Array - zeroToLike( new Uint16Array( [ 0, 0 ] ) ); // $ExpectType Uint16Array - zeroToLike( new Uint8Array( [ 0, 0 ] ) ); // $ExpectType Uint8Array - zeroToLike( new Uint8ClampedArray( [ 0, 0 ] ) ); // $ExpectType Uint8ClampedArray - - zeroToLike( [ 0, 0 ], 'float64' ); // $ExpectType Float64Array - zeroToLike( [ 0, 0 ], 'float32' ); // $ExpectType Float32Array - zeroToLike( [ 0, 0 ], 'complex128' ); // $ExpectType Complex128Array - zeroToLike( [ 0, 0 ], 'complex64' ); // $ExpectType Complex64Array - zeroToLike( [ 0, 0 ], 'int32' ); // $ExpectType Int32Array - zeroToLike( [ 0, 0 ], 'int16' ); // $ExpectType Int16Array - zeroToLike( [ 0, 0 ], 'int8' ); // $ExpectType Int8Array - zeroToLike( [ 0, 0 ], 'uint32' ); // $ExpectType Uint32Array - zeroToLike( [ 0, 0 ], 'uint16' ); // $ExpectType Uint16Array - zeroToLike( [ 0, 0 ], 'uint8' ); // $ExpectType Uint8Array - zeroToLike( [ 0, 0 ], 'uint8c' ); // $ExpectType Uint8ClampedArray - zeroToLike( [ 0, 0 ], 'generic' ); // $ExpectType number[] -} - -// The compiler throws an error if the function is not provided an array or typed array for the first argument... -{ - zeroToLike( '5' ); // $ExpectError - zeroToLike( false ); // $ExpectError - zeroToLike( true ); // $ExpectError - zeroToLike( null ); // $ExpectError - zeroToLike( undefined ); // $ExpectError - zeroToLike( {} ); // $ExpectError - zeroToLike( ( x: number ): number => x ); // $ExpectError - - zeroToLike( '5', 'float32' ); // $ExpectError - zeroToLike( false, 'float32' ); // $ExpectError - zeroToLike( true, 'float32' ); // $ExpectError - zeroToLike( null, 'float32' ); // $ExpectError - zeroToLike( undefined, 'float32' ); // $ExpectError - zeroToLike( {}, 'float32' ); // $ExpectError - zeroToLike( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - zeroToLike( [ 0, 0 ], '10' ); // $ExpectError - zeroToLike( [ 0, 0 ], 10 ); // $ExpectError - zeroToLike( [ 0, 0 ], false ); // $ExpectError - zeroToLike( [ 0, 0 ], true ); // $ExpectError - zeroToLike( [ 0, 0 ], null ); // $ExpectError - zeroToLike( [ 0, 0 ], [] ); // $ExpectError - zeroToLike( [ 0, 0 ], {} ); // $ExpectError - zeroToLike( [ 0, 0 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeroToLike( [ 0, 0 ], 'float64', 1 ); // $ExpectError -} diff --git a/zero-to-like/examples/index.js b/zero-to-like/examples/index.js deleted file mode 100644 index d8c05a407..000000000 --- a/zero-to-like/examples/index.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroToLike = require( './../lib' ); - -// Generate an array of random numbers: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 10, 100, 200, opts ); - -// Generate an array of indices: -var idx = zeroToLike( x ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort the index array according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, idx, 1 ); - -console.log( x ); -console.log( idx ); diff --git a/zero-to-like/lib/index.js b/zero-to-like/lib/index.js deleted file mode 100644 index 3032ff47e..000000000 --- a/zero-to-like/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Generate a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @module @stdlib/array/zero-to-like -* -* @example -* var zeroToLike = require( '@stdlib/array/zero-to-like' ); -* -* var arr = zeroToLike( [ 0.0, 0.0 ] ); -* // returns [ 0.0, 1.0 ] -* -* @example -* var zeroToLike = require( '@stdlib/array/zero-to-like' ); -* -* var arr = zeroToLike( [ 0.0, 0.0 ], 'float32' ); -* // returns [ 0.0, 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/zero-to-like/lib/main.js b/zero-to-like/lib/main.js deleted file mode 100644 index 29adb602c..000000000 --- a/zero-to-like/lib/main.js +++ /dev/null @@ -1,61 +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. -*/ - -'use strict'; - -// MODULES // - -var zeroTo = require( './../../zero-to' ); -var dtype = require( './../../dtype' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array. -* -* @param {(TypedArray|Array|ComplexArray)} x - input array -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} first argument must be an array or typed array -* @throws {TypeError} second argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = zeroToLike( [ 0.0, 0.0 ] ); -* // returns [ 0.0, 1.0 ] -* -* @example -* var arr = zeroToLike( [ 0.0, 0.0 ], 'float32' ); -* // returns [ 0.0, 1.0 ] -*/ -function zeroToLike( x ) { - var dt = dtype( x ); // delegate input argument validation to dtype resolution - if ( dt === null ) { - throw new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) ); - } - if ( arguments.length > 1 ) { - dt = arguments[ 1 ]; - } - return zeroTo( x.length, dt ); -} - - -// EXPORTS // - -module.exports = zeroToLike; diff --git a/zero-to-like/package.json b/zero-to-like/package.json deleted file mode 100644 index ab0d2129a..000000000 --- a/zero-to-like/package.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "name": "@stdlib/array/zero-to-like", - "version": "0.0.0", - "description": "Generate a linearly spaced numeric array whose elements increment by 1 starting from zero and having the same length and data type as a provided input array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "fill", - "filled", - "matlab", - "linear", - "linspace", - "sequence", - "increment", - "unitspace" - ] -} diff --git a/zero-to-like/test/test.js b/zero-to-like/test/test.js deleted file mode 100644 index 70c1aa1c0..000000000 --- a/zero-to-like/test/test.js +++ /dev/null @@ -1,524 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var zeroToLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeroToLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeroToLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeroToLike( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeroToLike', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeroToLike( [], value ); - }; - } -}); - -tape( 'the function returns a filled array (float64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float32Array( 5 ); - expected = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); - - arr = zeroToLike( x, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (float32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float32Array( 5 ); - expected = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); - - arr = zeroToLike( x, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (complex128)', function test( t ) { - var expected; - var arr; - var x; - - x = new Complex128Array( 4 ); - expected = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 4 ); - expected = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - arr = zeroToLike( x, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (complex64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Complex64Array( 4 ); - expected = new Float32Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 4 ); - expected = new Float32Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - arr = zeroToLike( x, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (int32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int32Array( 5 ); - expected = new Int32Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int32Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint32Array( 5 ); - expected = new Uint32Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint32Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (int16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int16Array( 5 ); - expected = new Int16Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int16Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint16Array( 5 ); - expected = new Uint16Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint16Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (int8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int8Array( 5 ); - expected = new Int8Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int8Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint8Array( 5 ); - expected = new Uint8Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint8Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (uint8c)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint8ClampedArray( 5 ); - expected = new Uint8ClampedArray( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint8ClampedArray( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroToLike( x, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (generic)', function test( t ) { - var expected; - var arr; - var x; - - x = [ 0, 0, 0, 0, 0 ]; - expected = [ 0, 1, 2, 3, 4 ]; - - arr = zeroToLike( x ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = [ 0, 1, 2, 3, 4 ]; - - arr = zeroToLike( x, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/zero-to/README.md b/zero-to/README.md deleted file mode 100644 index 60bb8b4e1..000000000 --- a/zero-to/README.md +++ /dev/null @@ -1,181 +0,0 @@ - - -# zeroTo - -> Generate a linearly spaced numeric array whose elements increment by `1` starting from zero. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var zeroTo = require( '@stdlib/array/zero-to' ); -``` - -#### zeroTo( n\[, dtype] ) - -Generates a linearly spaced numeric array whose elements increment by `1` starting from zero. - -```javascript -var arr = zeroTo( 5 ); -// returns [ 0.0, 1.0, 2.0, 3.0, 4.0 ] -``` - -If `n == 0`, the function returns an empty array. - -```javascript -var arr = zeroTo( 0 ); -// returns [] -``` - -The function recognizes the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers -- `int32`: 32-bit two's complement signed integers -- `uint32`: 32-bit unsigned integers -- `int16`: 16-bit two's complement signed integers -- `uint16`: 16-bit unsigned integers -- `int8`: 8-bit two's complement signed integers -- `uint8`: 8-bit unsigned integers -- `uint8c`: 8-bit unsigned integers clamped to `0-255` -- `generic`: generic JavaScript values - -By default, the output array data type is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative data type, provide a `dtype` argument. - -```javascript -var arr = zeroTo( 5, 'int32' ); -// returns [ 0, 1, 2, 3, 4 ] -``` - -
- - - - - -
- -## Notes - -- For complex number arrays, each element of the returned array has an imaginary component equal to `0`. - -
- - - - - -
- -## Examples - - - -```javascript -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( '@stdlib/array/zero-to' ); - -// Generate an array of random numbers: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 10, 100, 200, opts ); - -// Generate an array of indices: -var idx = zeroTo( x.length, opts.dtype ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort the index array according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, idx, 1 ); - -console.log( x ); -console.log( idx ); -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/zero-to/benchmark/benchmark.js b/zero-to/benchmark/benchmark.js deleted file mode 100644 index d3f48e0cf..000000000 --- a/zero-to/benchmark/benchmark.js +++ /dev/null @@ -1,264 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( 0, 'generic' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/zero-to/benchmark/benchmark.length.complex128.js b/zero-to/benchmark/benchmark.length.complex128.js deleted file mode 100644 index f33aae512..000000000 --- a/zero-to/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/zero-to/benchmark/benchmark.length.complex64.js b/zero-to/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e46658829..000000000 --- a/zero-to/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/zero-to/benchmark/benchmark.length.float32.js b/zero-to/benchmark/benchmark.length.float32.js deleted file mode 100644 index 9bb252d01..000000000 --- a/zero-to/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/zero-to/benchmark/benchmark.length.float64.js b/zero-to/benchmark/benchmark.length.float64.js deleted file mode 100644 index e48bda063..000000000 --- a/zero-to/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/zero-to/benchmark/benchmark.length.generic.js b/zero-to/benchmark/benchmark.length.generic.js deleted file mode 100644 index 73d0ad6dd..000000000 --- a/zero-to/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'generic' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/zero-to/benchmark/benchmark.length.int16.js b/zero-to/benchmark/benchmark.length.int16.js deleted file mode 100644 index b49a5d588..000000000 --- a/zero-to/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/zero-to/benchmark/benchmark.length.int32.js b/zero-to/benchmark/benchmark.length.int32.js deleted file mode 100644 index 51f2f53b5..000000000 --- a/zero-to/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/zero-to/benchmark/benchmark.length.int8.js b/zero-to/benchmark/benchmark.length.int8.js deleted file mode 100644 index d5cb7cbd7..000000000 --- a/zero-to/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/zero-to/benchmark/benchmark.length.uint16.js b/zero-to/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 786ea71f5..000000000 --- a/zero-to/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/zero-to/benchmark/benchmark.length.uint32.js b/zero-to/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 0336f99ce..000000000 --- a/zero-to/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/zero-to/benchmark/benchmark.length.uint8.js b/zero-to/benchmark/benchmark.length.uint8.js deleted file mode 100644 index a9b389a98..000000000 --- a/zero-to/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/zero-to/benchmark/benchmark.length.uint8c.js b/zero-to/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index ad5ca190b..000000000 --- a/zero-to/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeroTo = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeroTo( len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/zero-to/docs/repl.txt b/zero-to/docs/repl.txt deleted file mode 100644 index fd2cae9db..000000000 --- a/zero-to/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( n[, dtype] ) - Generates a linearly spaced numeric array whose elements increment by 1 - starting from zero. - - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754). - - float32: single-precision floating-point numbers (IEEE 754). - - complex128: double-precision complex floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - int32: 32-bit two's complement signed integers. - - uint32: 32-bit unsigned integers. - - int16: 16-bit two's complement signed integers. - - uint16: 16-bit unsigned integers. - - int8: 8-bit two's complement signed integers. - - uint8: 8-bit unsigned integers. - - uint8c: 8-bit unsigned integers clamped to 0-255. - - generic: generic JavaScript values. - - The default array data type is `float64`. - - If `n` is equal to zero, the function returns an empty array. - - Parameters - ---------- - n: integer - Number of elements. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 2 ) - [ 0.0, 1.0 ] - > arr = {{alias}}( 2, 'float32' ) - [ 0.0, 1.0 ] - - See Also - -------- - diff --git a/zero-to/docs/types/index.d.ts b/zero-to/docs/types/index.d.ts deleted file mode 100644 index 93e2a1695..000000000 --- a/zero-to/docs/types/index.d.ts +++ /dev/null @@ -1,45 +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. -*/ - -// TypeScript Version: 4.1 - -/// - -import { NumericAndGenericDataTypeMap } from '@stdlib/types/array'; - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param n - number of elements -* @param dtype - data type (default: 'float64') -* @returns linearly spaced numeric array -* -* @example -* var arr = zeroTo( 2 ); -* // returns [ 0.0, 1.0 ] -* -* @example -* var arr = zeroTo( 2, 'float32' ); -* // returns [ 0.0, 1.0 ] -*/ -declare function zeroTo = 'float64'>( n: number, dtype?: T ): NumericAndGenericDataTypeMap[T]; - - -// EXPORTS // - -export = zeroTo; diff --git a/zero-to/docs/types/test.ts b/zero-to/docs/types/test.ts deleted file mode 100644 index c2e7ef807..000000000 --- a/zero-to/docs/types/test.ts +++ /dev/null @@ -1,77 +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. -*/ - -import zeroTo = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - zeroTo( 10 ); // $ExpectType Float64Array - zeroTo( 10, 'float64' ); // $ExpectType Float64Array - zeroTo( 10, 'float32' ); // $ExpectType Float32Array - zeroTo( 10, 'complex128' ); // $ExpectType Complex128Array - zeroTo( 10, 'complex64' ); // $ExpectType Complex64Array - zeroTo( 10, 'int32' ); // $ExpectType Int32Array - zeroTo( 10, 'int16' ); // $ExpectType Int16Array - zeroTo( 10, 'int8' ); // $ExpectType Int8Array - zeroTo( 10, 'uint32' ); // $ExpectType Uint32Array - zeroTo( 10, 'uint16' ); // $ExpectType Uint16Array - zeroTo( 10, 'uint8' ); // $ExpectType Uint8Array - zeroTo( 10, 'uint8c' ); // $ExpectType Uint8ClampedArray - zeroTo( 10, 'generic' ); // $ExpectType number[] -} - -// The compiler throws an error if the function is not provided a number for the first argument... -{ - zeroTo( '5' ); // $ExpectError - zeroTo( false ); // $ExpectError - zeroTo( true ); // $ExpectError - zeroTo( null ); // $ExpectError - zeroTo( undefined ); // $ExpectError - zeroTo( [] ); // $ExpectError - zeroTo( {} ); // $ExpectError - zeroTo( ( x: number ): number => x ); // $ExpectError - - zeroTo( '5', 'float32' ); // $ExpectError - zeroTo( false, 'float32' ); // $ExpectError - zeroTo( true, 'float32' ); // $ExpectError - zeroTo( null, 'float32' ); // $ExpectError - zeroTo( undefined, 'float32' ); // $ExpectError - zeroTo( [], 'float32' ); // $ExpectError - zeroTo( {}, 'float32' ); // $ExpectError - zeroTo( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - zeroTo( 10, '10' ); // $ExpectError - zeroTo( 10, 10 ); // $ExpectError - zeroTo( 10, false ); // $ExpectError - zeroTo( 10, true ); // $ExpectError - zeroTo( 10, null ); // $ExpectError - zeroTo( 10, [] ); // $ExpectError - zeroTo( 10, {} ); // $ExpectError - zeroTo( 10, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeroTo( 10, 'float64', 1 ); // $ExpectError -} diff --git a/zero-to/examples/index.js b/zero-to/examples/index.js deleted file mode 100644 index 4d7218b12..000000000 --- a/zero-to/examples/index.js +++ /dev/null @@ -1,41 +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. -*/ - -'use strict'; - -var sort2hp = require( '@stdlib/blas/ext/base/gsort2hp' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var zeroTo = require( './../lib' ); - -// Generate an array of random numbers: -var opts = { - 'dtype': 'generic' -}; -var x = discreteUniform( 10, 100, 200, opts ); - -// Generate an array of indices: -var idx = zeroTo( x.length, opts.dtype ); - -// Create a temporary array to avoid mutation: -var tmp = x.slice(); - -// Sort the index array according to the sort order of `x`: -sort2hp( x.length, 1, tmp, 1, idx, 1 ); - -console.log( x ); -console.log( idx ); diff --git a/zero-to/lib/index.js b/zero-to/lib/index.js deleted file mode 100644 index fc035baab..000000000 --- a/zero-to/lib/index.js +++ /dev/null @@ -1,46 +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. -*/ - -'use strict'; - -/** -* Generate a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @module @stdlib/array/zero-to -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var arr = zeroTo( 2 ); -* // returns [ 0.0, 1.0 ] -* -* @example -* var zeroTo = require( '@stdlib/array/zero-to' ); -* -* var arr = zeroTo( 2, 'float32' ); -* // returns [ 0.0, 1.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/zero-to/lib/main.js b/zero-to/lib/main.js deleted file mode 100644 index 537bf3db7..000000000 --- a/zero-to/lib/main.js +++ /dev/null @@ -1,73 +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. -*/ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var base = require( './../../base/zero-to' ); -var zeros = require( './../../zeros' ); -var defaults = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// MAIN // - -/** -* Generates a linearly spaced numeric array whose elements increment by 1 starting from zero. -* -* @param {NonNegativeInteger} n - number of elements -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = zeroTo( 2 ); -* // returns [ 0.0, 1.0 ] -* -* @example -* var arr = zeroTo( 2, 'float32' ); -* // returns [ 0.0, 1.0 ] -*/ -function zeroTo( n ) { - var dtype; - if ( !isNonNegativeInteger( n ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', n ) ); - } - if ( arguments.length > 1 ) { - dtype = arguments[ 1 ]; - if ( dtype === 'generic' ) { - return base( n ); - } - } else { - dtype = DEFAULT_DTYPE; - } - return base.assign( zeros( n, dtype ), 1, 0 ); // defer dtype validation to `zeros` -} - - -// EXPORTS // - -module.exports = zeroTo; diff --git a/zero-to/package.json b/zero-to/package.json deleted file mode 100644 index fc235b417..000000000 --- a/zero-to/package.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "name": "@stdlib/array/zero-to", - "version": "0.0.0", - "description": "Generate a linearly spaced numeric array whose elements increment by 1 starting from zero.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "fill", - "filled", - "matlab", - "linear", - "linspace", - "sequence", - "increment", - "unitspace" - ] -} diff --git a/zero-to/test/test.js b/zero-to/test/test.js deleted file mode 100644 index c7632da7d..000000000 --- a/zero-to/test/test.js +++ /dev/null @@ -1,396 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var zeroTo = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeroTo, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeroTo( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeroTo( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeroTo', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeroTo( 10, value ); - }; - } -}); - -tape( 'the function returns a filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); - - arr = zeroTo( 5 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); - - arr = zeroTo( 5, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); - - arr = zeroTo( 5, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - arr = zeroTo( 4, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ); - - arr = zeroTo( 4, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroTo( 5, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroTo( 5, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroTo( 5, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroTo( 5, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroTo( 5, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroTo( 5, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 1, 2, 3, 4 ] ); - - arr = zeroTo( 5, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 1, 2, 3, 4 ]; - - arr = zeroTo( 5, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'if `n` is zero, the function returns an empty array', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [] ); - arr = zeroTo( 0 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Float64Array( [] ); - arr = zeroTo( 0, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Float32Array( [] ); - arr = zeroTo( 0, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Int32Array( [] ); - arr = zeroTo( 0, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Int16Array( [] ); - arr = zeroTo( 0, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Int8Array( [] ); - arr = zeroTo( 0, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Uint32Array( [] ); - arr = zeroTo( 0, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Uint16Array( [] ); - arr = zeroTo( 0, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Uint8Array( [] ); - arr = zeroTo( 0, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Uint8ClampedArray( [] ); - arr = zeroTo( 0, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Complex128Array( [] ); - arr = zeroTo( 0, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = new Complex64Array( [] ); - arr = zeroTo( 0, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - expected = []; - arr = zeroTo( 0, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - - t.end(); -}); diff --git a/zeros-like/README.md b/zeros-like/README.md deleted file mode 100644 index b8d47d0f9..000000000 --- a/zeros-like/README.md +++ /dev/null @@ -1,171 +0,0 @@ - - -# zerosLike - -> Create a zero-filled array having the same length and data type as a provided array. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var zerosLike = require( '@stdlib/array/zeros-like' ); -``` - -#### zerosLike( x\[, dtype] ) - -Creates a zero-filled array having the same length and data type as a provided array `x`. - -```javascript -var x = [ 1, 2, 3, 4, 5 ]; - -var arr = zerosLike( x ); -// returns [ 0, 0, 0, 0, 0 ] -``` - -The function supports the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers -- `int32`: 32-bit two's complement signed integers -- `uint32`: 32-bit unsigned integers -- `int16`: 16-bit two's complement signed integers -- `uint16`: 16-bit unsigned integers -- `int8`: 8-bit two's complement signed integers -- `uint8`: 8-bit unsigned integers -- `uint8c`: 8-bit unsigned integers clamped to `0-255` -- `generic`: generic JavaScript values - -By default, the output array data type is inferred from the provided array `x`. To return an array having a different data type, provide a `dtype` argument. - -```javascript -var x = [ 0, 0 ]; - -var arr = zerosLike( x, 'int32' ); -// returns [ 0, 0 ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var zeros = require( '@stdlib/array/zeros' ); -var zerosLike = require( '@stdlib/array/zeros-like' ); - -// Create a zero-filled array: -var x = zeros( 4, 'complex128' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate additional zero-filled arrays... -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - y = zerosLike( x, dt[ i ] ); - console.log( y ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/zeros-like/benchmark/benchmark.js b/zeros-like/benchmark/benchmark.js deleted file mode 100644 index 38c7d6004..000000000 --- a/zeros-like/benchmark/benchmark.js +++ /dev/null @@ -1,317 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'float32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex128' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'complex64' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint32' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint16' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'int8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'uint8c' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var x; - var i; - - x = zeros( 0, 'generic' ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/zeros-like/benchmark/benchmark.length.complex128.js b/zeros-like/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 2352873f7..000000000 --- a/zeros-like/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex128' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/benchmark/benchmark.length.complex64.js b/zeros-like/benchmark/benchmark.length.complex64.js deleted file mode 100644 index a9a1d9245..000000000 --- a/zeros-like/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'complex64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/benchmark/benchmark.length.float32.js b/zeros-like/benchmark/benchmark.length.float32.js deleted file mode 100644 index 7ed1a09f9..000000000 --- a/zeros-like/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/benchmark/benchmark.length.float64.js b/zeros-like/benchmark/benchmark.length.float64.js deleted file mode 100644 index 50004bcff..000000000 --- a/zeros-like/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'float64' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/benchmark/benchmark.length.generic.js b/zeros-like/benchmark/benchmark.length.generic.js deleted file mode 100644 index 61dcbdb61..000000000 --- a/zeros-like/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'generic' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/benchmark/benchmark.length.int16.js b/zeros-like/benchmark/benchmark.length.int16.js deleted file mode 100644 index fc0168367..000000000 --- a/zeros-like/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/benchmark/benchmark.length.int32.js b/zeros-like/benchmark/benchmark.length.int32.js deleted file mode 100644 index 3bb3d1c05..000000000 --- a/zeros-like/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/benchmark/benchmark.length.int8.js b/zeros-like/benchmark/benchmark.length.int8.js deleted file mode 100644 index 4fb506214..000000000 --- a/zeros-like/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'int8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/benchmark/benchmark.length.uint16.js b/zeros-like/benchmark/benchmark.length.uint16.js deleted file mode 100644 index f0d78c667..000000000 --- a/zeros-like/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint16' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/benchmark/benchmark.length.uint32.js b/zeros-like/benchmark/benchmark.length.uint32.js deleted file mode 100644 index 3fcd6b8e1..000000000 --- a/zeros-like/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint32' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/benchmark/benchmark.length.uint8.js b/zeros-like/benchmark/benchmark.length.uint8.js deleted file mode 100644 index f379a0278..000000000 --- a/zeros-like/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/benchmark/benchmark.length.uint8c.js b/zeros-like/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 7e6c284aa..000000000 --- a/zeros-like/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,95 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var zeros = require( './../../zeros' ); -var pkg = require( './../package.json' ).name; -var zerosLike = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x = zeros( len, 'uint8c' ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zerosLike( x ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/zeros-like/docs/repl.txt b/zeros-like/docs/repl.txt deleted file mode 100644 index 4bb0bc0d5..000000000 --- a/zeros-like/docs/repl.txt +++ /dev/null @@ -1,45 +0,0 @@ - -{{alias}}( x[, dtype] ) - Returns a zero-filled array having the same length and data type as a - provided input array. - - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754). - - float32: single-precision floating-point numbers (IEEE 754). - - complex128: double-precision complex floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - int32: 32-bit two's complement signed integers. - - uint32: 32-bit unsigned integers. - - int16: 16-bit two's complement signed integers. - - uint16: 16-bit unsigned integers. - - int8: 8-bit two's complement signed integers. - - uint8: 8-bit unsigned integers. - - uint8c: 8-bit unsigned integers clamped to 0-255. - - generic: generic JavaScript values. - - Parameters - ---------- - x: TypedArray|Array - Input array. - - dtype: string (optional) - Data type. If not provided, the output array data type is inferred from - the input array. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var x = new {{alias:@stdlib/array/float64}}( 2 ); - > var y = {{alias}}( x ) - [ 0.0, 0.0 ] - > y = {{alias}}( x, 'float32' ) - [ 0.0, 0.0 ] - - See Also - -------- - diff --git a/zeros-like/docs/types/index.d.ts b/zeros-like/docs/types/index.d.ts deleted file mode 100644 index dc82b05ba..000000000 --- a/zeros-like/docs/types/index.d.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { NumericAndGenericDataTypeMap, AnyArray, TypedArray, ComplexTypedArray } from '@stdlib/types/array'; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'generic' ); -* // returns [ 0, 0 ] -* -* var y = zerosLike( x ); -* // returns [ 0, 0 ] -*/ -declare function zerosLike( x: Array ): Array; - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* @param x - input array from which to derive the output array length -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x ); -* // returns [ 0.0, 0.0 ] -*/ -declare function zerosLike( x: T ): T; - -/** -* Creates a zero-filled array having the same length as a provided input array. -* -* The function supports the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param x - input array from which to derive the output array length -* @param dtype - data type -* @returns zero-filled array -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var x = zeros( 2, 'float64' ); -* // returns [ 0.0, 0.0 ] -* -* var y = zerosLike( x, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function zerosLike>( x: AnyArray, dtype: T ): NumericAndGenericDataTypeMap[T]; - - -// EXPORTS // - -export = zerosLike; diff --git a/zeros-like/docs/types/test.ts b/zeros-like/docs/types/test.ts deleted file mode 100644 index dbb0481ff..000000000 --- a/zeros-like/docs/types/test.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 Complex128Array = require( './../../../complex128' ); -import Complex64Array = require( './../../../complex64' ); -import zerosLike = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - zerosLike( [ 0, 0 ] ); // $ExpectType number[] - zerosLike( new Float64Array( [ 0, 0 ] ) ); // $ExpectType Float64Array - zerosLike( new Float32Array( [ 0, 0 ] ) ); // $ExpectType Float32Array - zerosLike( new Complex128Array( [ 0, 0 ] ) ); // $ExpectType Complex128Array - zerosLike( new Complex64Array( [ 0, 0 ] ) ); // $ExpectType Complex64Array - zerosLike( new Int32Array( [ 0, 0 ] ) ); // $ExpectType Int32Array - zerosLike( new Int16Array( [ 0, 0 ] ) ); // $ExpectType Int16Array - zerosLike( new Int8Array( [ 0, 0 ] ) ); // $ExpectType Int8Array - zerosLike( new Uint32Array( [ 0, 0 ] ) ); // $ExpectType Uint32Array - zerosLike( new Uint16Array( [ 0, 0 ] ) ); // $ExpectType Uint16Array - zerosLike( new Uint8Array( [ 0, 0 ] ) ); // $ExpectType Uint8Array - zerosLike( new Uint8ClampedArray( [ 0, 0 ] ) ); // $ExpectType Uint8ClampedArray - zerosLike( [ 'a', 'b', 'c' ] ); // $ExpectType number[] - - zerosLike( [ 0, 0 ], 'float64' ); // $ExpectType Float64Array - zerosLike( [ 0, 0 ], 'float32' ); // $ExpectType Float32Array - zerosLike( [ 0, 0 ], 'complex128' ); // $ExpectType Complex128Array - zerosLike( [ 0, 0 ], 'complex64' ); // $ExpectType Complex64Array - zerosLike( [ 0, 0 ], 'int32' ); // $ExpectType Int32Array - zerosLike( [ 0, 0 ], 'int16' ); // $ExpectType Int16Array - zerosLike( [ 0, 0 ], 'int8' ); // $ExpectType Int8Array - zerosLike( [ 0, 0 ], 'uint32' ); // $ExpectType Uint32Array - zerosLike( [ 0, 0 ], 'uint16' ); // $ExpectType Uint16Array - zerosLike( [ 0, 0 ], 'uint8' ); // $ExpectType Uint8Array - zerosLike( [ 0, 0 ], 'uint8c' ); // $ExpectType Uint8ClampedArray - zerosLike( [ 0, 0 ], 'generic' ); // $ExpectType number[] - zerosLike( new Int32Array( [ 0, 0 ] ), 'generic' ); // $ExpectType number[] - zerosLike( [ 'a', 'b', 'c' ], 'generic' ); // $ExpectType number[] - zerosLike( [ 'a', 'b', 'c' ], 'float64' ); // $ExpectType Float64Array -} - -// The compiler throws an error if the function is not provided an array or typed array for the first argument... -{ - zerosLike( '5' ); // $ExpectError - zerosLike( 5 ); // $ExpectError - zerosLike( false ); // $ExpectError - zerosLike( true ); // $ExpectError - zerosLike( null ); // $ExpectError - zerosLike( undefined ); // $ExpectError - zerosLike( {} ); // $ExpectError - zerosLike( ( x: number ): number => x ); // $ExpectError - - zerosLike( '5', 'float32' ); // $ExpectError - zerosLike( 5, 'float32' ); // $ExpectError - zerosLike( false, 'float32' ); // $ExpectError - zerosLike( true, 'float32' ); // $ExpectError - zerosLike( null, 'float32' ); // $ExpectError - zerosLike( undefined, 'float32' ); // $ExpectError - zerosLike( {}, 'float32' ); // $ExpectError - zerosLike( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - zerosLike( [ 0, 0 ], '10' ); // $ExpectError - zerosLike( [ 0, 0 ], 10 ); // $ExpectError - zerosLike( [ 0, 0 ], false ); // $ExpectError - zerosLike( [ 0, 0 ], true ); // $ExpectError - zerosLike( [ 0, 0 ], null ); // $ExpectError - zerosLike( [ 0, 0 ], [] ); // $ExpectError - zerosLike( [ 0, 0 ], {} ); // $ExpectError - zerosLike( [ 0, 0 ], ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zerosLike( [ 0, 0 ], 'float64', 1 ); // $ExpectError -} diff --git a/zeros-like/examples/index.js b/zeros-like/examples/index.js deleted file mode 100644 index 3daa75e3c..000000000 --- a/zeros-like/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../dtypes' ); -var zeros = require( './../../zeros' ); -var zerosLike = require( './../lib' ); - -// Create a zero-filled array: -var x = zeros( 4, 'complex128' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate additional zero-filled arrays... -var y; -var i; -for ( i = 0; i < dt.length; i++ ) { - y = zerosLike( x, dt[ i ] ); - console.log( y ); -} diff --git a/zeros-like/lib/index.js b/zeros-like/lib/index.js deleted file mode 100644 index 89d8604a2..000000000 --- a/zeros-like/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled array having the same length and data type as a provided input array. -* -* @module @stdlib/array/zeros-like -* -* @example -* var zerosLike = require( '@stdlib/array/zeros-like' ); -* -* var arr = zerosLike( [ 0.0, 0.0 ] ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var zerosLike = require( '@stdlib/array/zeros-like' ); -* -* var arr = zerosLike( [ 0.0, 0.0 ], 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/zeros-like/lib/main.js b/zeros-like/lib/main.js deleted file mode 100644 index 835f4f9eb..000000000 --- a/zeros-like/lib/main.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var format = require( '@stdlib/string/format' ); -var dtype = require( './../../dtype' ); -var zeros = require( './../../zeros' ); - - -// MAIN // - -/** -* Creates a zero-filled array having the same length and data type as a provided input array. -* -* @param {(Array|TypedArray|ComplexArray)} x - input array -* @param {string} [dtype] - data type -* @throws {TypeError} first argument must be an array or typed array -* @throws {TypeError} second argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = zerosLike( [ 0.0, 0.0 ] ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = zerosLike( [ 0.0, 0.0 ], 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -function zerosLike( x ) { - var dt = dtype( x ); // delegate input argument validation to dtype resolution - if ( dt === null ) { - throw new TypeError( format( 'invalid argument. First argument must be either an array, typed array, or complex typed array. Value: `%s`.', x ) ); - } - if ( arguments.length > 1 ) { - dt = arguments[ 1 ]; - } - return zeros( x.length, dt ); -} - - -// EXPORTS // - -module.exports = zerosLike; diff --git a/zeros-like/package.json b/zeros-like/package.json deleted file mode 100644 index e1bf6c35b..000000000 --- a/zeros-like/package.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "name": "@stdlib/array/zeros-like", - "version": "0.0.0", - "description": "Create a zero-filled array having the same length and data type as a provided array.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "fill", - "filled", - "zeros" - ] -} diff --git a/zeros-like/test/test.js b/zeros-like/test/test.js deleted file mode 100644 index 292c0a4d3..000000000 --- a/zeros-like/test/test.js +++ /dev/null @@ -1,524 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var zerosLike = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zerosLike, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zerosLike( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than an array having a supported data type for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zerosLike( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zerosLike', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zerosLike( [], value ); - }; - } -}); - -tape( 'the function returns a zero-filled array (float64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float32Array( 5 ); - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zerosLike( x, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (float32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float32Array( 5 ); - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zerosLike( x, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (complex128)', function test( t ) { - var expected; - var arr; - var x; - - x = new Complex128Array( 2 ); - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 2 ); - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zerosLike( x, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (complex64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Complex64Array( 2 ); - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 2 ); - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zerosLike( x, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (int32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int32Array( 5 ); - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (uint32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint32Array( 5 ); - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (int16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int16Array( 5 ); - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (uint16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint16Array( 5 ); - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (int8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Int8Array( 5 ); - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (uint8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint8Array( 5 ); - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (uint8c)', function test( t ) { - var expected; - var arr; - var x; - - x = new Uint8ClampedArray( 5 ); - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = zerosLike( x, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (generic)', function test( t ) { - var expected; - var arr; - var x; - - x = [ 1, 2, 3, 4, 5 ]; - expected = [ 0, 0, 0, 0, 0 ]; - - arr = zerosLike( x ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - var x; - - x = new Float64Array( 5 ); - expected = [ 0, 0, 0, 0, 0 ]; - - arr = zerosLike( x, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/zeros/README.md b/zeros/README.md deleted file mode 100644 index 0a99392e2..000000000 --- a/zeros/README.md +++ /dev/null @@ -1,165 +0,0 @@ - - -# zeros - -> Create a zero-filled array having a specified length. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var zeros = require( '@stdlib/array/zeros' ); -``` - -#### zeros( length\[, dtype] ) - -Creates a zero-filled array having a specified length. - -```javascript -var arr = zeros( 2 ); -// returns [ 0.0, 0.0 ] -``` - -The function recognizes the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers -- `int32`: 32-bit two's complement signed integers -- `uint32`: 32-bit unsigned integers -- `int16`: 16-bit two's complement signed integers -- `uint16`: 16-bit unsigned integers -- `int8`: 8-bit two's complement signed integers -- `uint8`: 8-bit unsigned integers -- `uint8c`: 8-bit unsigned integers clamped to `0-255` -- `generic`: generic JavaScript values - -By default, the output array data type is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative data type, provide a `dtype` argument. - -```javascript -var arr = zeros( 2, 'int32' ); -// returns [ 0, 0 ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var dtypes = require( '@stdlib/array/dtypes' ); -var zeros = require( '@stdlib/array/zeros' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( 4, dt[ i ] ); - console.log( arr ); -} -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/zeros/benchmark/benchmark.js b/zeros/benchmark/benchmark.js deleted file mode 100644 index 72815b814..000000000 --- a/zeros/benchmark/benchmark.js +++ /dev/null @@ -1,264 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0 ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'float64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'float32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'complex128' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'complex64' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'int32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'uint32' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'int16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'uint16' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'int8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'uint8' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'uint8c' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var arr; - var i; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( 0, 'generic' ); - if ( arr.length !== 0 ) { - b.fail( 'should have length 0' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/zeros/benchmark/benchmark.length.complex128.js b/zeros/benchmark/benchmark.length.complex128.js deleted file mode 100644 index 7ad205513..000000000 --- a/zeros/benchmark/benchmark.length.complex128.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'complex128' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex128,len='+len, f ); - } -} - -main(); diff --git a/zeros/benchmark/benchmark.length.complex64.js b/zeros/benchmark/benchmark.length.complex64.js deleted file mode 100644 index e74437258..000000000 --- a/zeros/benchmark/benchmark.length.complex64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'complex64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArrayLike( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=complex64,len='+len, f ); - } -} - -main(); diff --git a/zeros/benchmark/benchmark.length.float32.js b/zeros/benchmark/benchmark.length.float32.js deleted file mode 100644 index 3c2ffa731..000000000 --- a/zeros/benchmark/benchmark.length.float32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'float32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float32,len='+len, f ); - } -} - -main(); diff --git a/zeros/benchmark/benchmark.length.float64.js b/zeros/benchmark/benchmark.length.float64.js deleted file mode 100644 index 043c5db00..000000000 --- a/zeros/benchmark/benchmark.length.float64.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'float64' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=float64,len='+len, f ); - } -} - -main(); diff --git a/zeros/benchmark/benchmark.length.generic.js b/zeros/benchmark/benchmark.length.generic.js deleted file mode 100644 index aa54ea855..000000000 --- a/zeros/benchmark/benchmark.length.generic.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isArray = require( '@stdlib/assert/is-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'generic' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=generic,len='+len, f ); - } -} - -main(); diff --git a/zeros/benchmark/benchmark.length.int16.js b/zeros/benchmark/benchmark.length.int16.js deleted file mode 100644 index bca1e3883..000000000 --- a/zeros/benchmark/benchmark.length.int16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'int16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int16,len='+len, f ); - } -} - -main(); diff --git a/zeros/benchmark/benchmark.length.int32.js b/zeros/benchmark/benchmark.length.int32.js deleted file mode 100644 index 44dfff8ef..000000000 --- a/zeros/benchmark/benchmark.length.int32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'int32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int32,len='+len, f ); - } -} - -main(); diff --git a/zeros/benchmark/benchmark.length.int8.js b/zeros/benchmark/benchmark.length.int8.js deleted file mode 100644 index 29b5956f1..000000000 --- a/zeros/benchmark/benchmark.length.int8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'int8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=int8,len='+len, f ); - } -} - -main(); diff --git a/zeros/benchmark/benchmark.length.uint16.js b/zeros/benchmark/benchmark.length.uint16.js deleted file mode 100644 index 70721e630..000000000 --- a/zeros/benchmark/benchmark.length.uint16.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'uint16' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint16,len='+len, f ); - } -} - -main(); diff --git a/zeros/benchmark/benchmark.length.uint32.js b/zeros/benchmark/benchmark.length.uint32.js deleted file mode 100644 index d89e487c7..000000000 --- a/zeros/benchmark/benchmark.length.uint32.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'uint32' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint32,len='+len, f ); - } -} - -main(); diff --git a/zeros/benchmark/benchmark.length.uint8.js b/zeros/benchmark/benchmark.length.uint8.js deleted file mode 100644 index 8281bcaff..000000000 --- a/zeros/benchmark/benchmark.length.uint8.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'uint8' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8,len='+len, f ); - } -} - -main(); diff --git a/zeros/benchmark/benchmark.length.uint8c.js b/zeros/benchmark/benchmark.length.uint8c.js deleted file mode 100644 index 0ceb4119b..000000000 --- a/zeros/benchmark/benchmark.length.uint8c.js +++ /dev/null @@ -1,93 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 pow = require( '@stdlib/math/base/special/pow' ); -var isTypedArray = require( '@stdlib/assert/is-typed-array' ); -var pkg = require( './../package.json' ).name; -var zeros = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var arr; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = zeros( len, 'uint8c' ); - if ( arr.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isTypedArray( arr ) ) { - b.fail( 'should return a typed array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':dtype=uint8c,len='+len, f ); - } -} - -main(); diff --git a/zeros/docs/repl.txt b/zeros/docs/repl.txt deleted file mode 100644 index 6a593202a..000000000 --- a/zeros/docs/repl.txt +++ /dev/null @@ -1,44 +0,0 @@ - -{{alias}}( length[, dtype] ) - Returns a zero-filled array having a specified length. - - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754). - - float32: single-precision floating-point numbers (IEEE 754). - - complex128: double-precision complex floating-point numbers. - - complex64: single-precision complex floating-point numbers. - - int32: 32-bit two's complement signed integers. - - uint32: 32-bit unsigned integers. - - int16: 16-bit two's complement signed integers. - - uint16: 16-bit unsigned integers. - - int8: 8-bit two's complement signed integers. - - uint8: 8-bit unsigned integers. - - uint8c: 8-bit unsigned integers clamped to 0-255. - - generic: generic JavaScript values. - - The default array data type is `float64`. - - Parameters - ---------- - length: integer - Array length. - - dtype: string (optional) - Data type. Default: 'float64'. - - Returns - ------- - out: TypedArray|Array - Output array. - - Examples - -------- - > var arr = {{alias}}( 2 ) - [ 0.0, 0.0 ] - > arr = {{alias}}( 2, 'float32' ) - [ 0.0, 0.0 ] - - See Also - -------- - diff --git a/zeros/docs/types/index.d.ts b/zeros/docs/types/index.d.ts deleted file mode 100644 index 848339a51..000000000 --- a/zeros/docs/types/index.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { NumericAndGenericDataTypeMap } from '@stdlib/types/array'; - -/** -* Creates a zero-filled array having a specified length. -* -* The function recognizes the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* -* @param length - array length -* @param dtype - data type (default: 'float64') -* @returns zero-filled array -* -* @example -* var arr = zeros( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -declare function zeros = 'float64'>( length: number, dtype?: T ): NumericAndGenericDataTypeMap[T]; - - -// EXPORTS // - -export = zeros; diff --git a/zeros/docs/types/test.ts b/zeros/docs/types/test.ts deleted file mode 100644 index a41620a03..000000000 --- a/zeros/docs/types/test.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 zeros = require( './index' ); - - -// TESTS // - -// The function returns an array or typed array... -{ - zeros( 10 ); // $ExpectType Float64Array - zeros( 10, 'float64' ); // $ExpectType Float64Array - zeros( 10, 'float32' ); // $ExpectType Float32Array - zeros( 10, 'complex128' ); // $ExpectType Complex128Array - zeros( 10, 'complex64' ); // $ExpectType Complex64Array - zeros( 10, 'int32' ); // $ExpectType Int32Array - zeros( 10, 'int16' ); // $ExpectType Int16Array - zeros( 10, 'int8' ); // $ExpectType Int8Array - zeros( 10, 'uint32' ); // $ExpectType Uint32Array - zeros( 10, 'uint16' ); // $ExpectType Uint16Array - zeros( 10, 'uint8' ); // $ExpectType Uint8Array - zeros( 10, 'uint8c' ); // $ExpectType Uint8ClampedArray - zeros( 10, 'generic' ); // $ExpectType number[] -} - -// The compiler throws an error if the function is not provided a number for the first argument... -{ - zeros( '5' ); // $ExpectError - zeros( false ); // $ExpectError - zeros( true ); // $ExpectError - zeros( null ); // $ExpectError - zeros( undefined ); // $ExpectError - zeros( [] ); // $ExpectError - zeros( {} ); // $ExpectError - zeros( ( x: number ): number => x ); // $ExpectError - - zeros( '5', 'float32' ); // $ExpectError - zeros( false, 'float32' ); // $ExpectError - zeros( true, 'float32' ); // $ExpectError - zeros( null, 'float32' ); // $ExpectError - zeros( undefined, 'float32' ); // $ExpectError - zeros( [], 'float32' ); // $ExpectError - zeros( {}, 'float32' ); // $ExpectError - zeros( ( x: number ): number => x, 'float32' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type... -{ - zeros( 10, '10' ); // $ExpectError - zeros( 10, 10 ); // $ExpectError - zeros( 10, false ); // $ExpectError - zeros( 10, true ); // $ExpectError - zeros( 10, null ); // $ExpectError - zeros( 10, [] ); // $ExpectError - zeros( 10, {} ); // $ExpectError - zeros( 10, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - zeros( 10, 'float64', 1 ); // $ExpectError -} diff --git a/zeros/examples/index.js b/zeros/examples/index.js deleted file mode 100644 index 5f2b2de6d..000000000 --- a/zeros/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( './../../dtypes' ); -var zeros = require( './../lib' ); - -// Get a list of array data types: -var dt = dtypes(); - -// Generate zero-filled arrays... -var arr; -var i; -for ( i = 0; i < dt.length; i++ ) { - arr = zeros( 4, dt[ i ] ); - console.log( arr ); -} diff --git a/zeros/lib/index.js b/zeros/lib/index.js deleted file mode 100644 index fe14f3f4e..000000000 --- a/zeros/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled array having a specified length. -* -* @module @stdlib/array/zeros -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var arr = zeros( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var zeros = require( '@stdlib/array/zeros' ); -* -* var arr = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/zeros/lib/main.js b/zeros/lib/main.js deleted file mode 100644 index 1bebe3b1c..000000000 --- a/zeros/lib/main.js +++ /dev/null @@ -1,78 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; -var ctors = require( './../../ctors' ); -var gzeros = require( './../../base/zeros' ); -var defaults = require( './../../defaults' ); -var format = require( '@stdlib/string/format' ); - - -// VARIABLES // - -var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); - - -// MAIN // - -/** -* Creates a zero-filled array having a specified length. -* -* @param {NonNegativeInteger} length - array length -* @param {string} [dtype="float64"] - data type -* @throws {TypeError} first argument must be a nonnegative integer -* @throws {TypeError} second argument must be a recognized data type -* @returns {(TypedArray|Array|ComplexArray)} array or typed array -* -* @example -* var arr = zeros( 2 ); -* // returns [ 0.0, 0.0 ] -* -* @example -* var arr = zeros( 2, 'float32' ); -* // returns [ 0.0, 0.0 ] -*/ -function zeros( length ) { - var dtype; - var ctor; - if ( !isNonNegativeInteger( length ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', length ) ); - } - if ( arguments.length > 1 ) { - dtype = arguments[ 1 ]; - } else { - dtype = DEFAULT_DTYPE; - } - if ( dtype === 'generic' ) { - return gzeros( length ); - } - ctor = ctors( dtype ); - if ( ctor === null ) { - throw new TypeError( format( 'invalid argument. Second argument must be a recognized data type. Value: `%s`.', dtype ) ); - } - return new ctor( length ); // WARNING: we assume that, apart from 'generic', the constructors for supported array data types are zero-filled by default -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/zeros/package.json b/zeros/package.json deleted file mode 100644 index 4f8e94fb1..000000000 --- a/zeros/package.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "name": "@stdlib/array/zeros", - "version": "0.0.0", - "description": "Create a zero-filled array having a specified length.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdtypes", - "types", - "data", - "structure", - "typed", - "array", - "typed array", - "typed-array", - "vector", - "ndarray", - "matrix", - "float64array", - "float32array", - "int32array", - "uint32array", - "int16array", - "uint16array", - "int8array", - "uint8array", - "uint8clampedarray", - "complex128array", - "complex64array", - "complex128", - "complex64", - "complex", - "cmplx", - "float64", - "double", - "precision", - "double-precision", - "single", - "float", - "single-precision", - "float32", - "ieee754", - "integer", - "int32", - "signed", - "unsigned", - "uint32", - "int16", - "uint16", - "int8", - "uint8", - "uint8c", - "clamped", - "short", - "long", - "generic", - "fill", - "filled", - "zeros" - ] -} diff --git a/zeros/test/test.js b/zeros/test/test.js deleted file mode 100644 index 8fec8f75e..000000000 --- a/zeros/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 Float64Array = require( './../../float64' ); -var Float32Array = require( './../../float32' ); -var Int32Array = require( './../../int32' ); -var Uint32Array = require( './../../uint32' ); -var Int16Array = require( './../../int16' ); -var Uint16Array = require( './../../uint16' ); -var Int8Array = require( './../../int8' ); -var Uint8Array = require( './../../uint8' ); -var Uint8ClampedArray = require( './../../uint8c' ); -var Complex64Array = require( './../../complex64' ); -var Complex128Array = require( './../../complex128' ); -var reinterpret64 = require( '@stdlib/strided/base/reinterpret-complex64' ); -var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' ); -var instanceOf = require( '@stdlib/assert/instance-of' ); -var zeros = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof zeros, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( value ); - }; - } -}); - -tape( 'the function throws an error if provided a value other than a nonnegative integer for the first argument (dtype)', function test( t ) { - var values; - var i; - - values = [ - '5', - -3, - 3.14, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( value, 'float32' ); - }; - } -}); - -tape( 'the function throws an error if provided an unrecognized data type', function test( t ) { - var values; - var i; - - values = [ - '5', - 'beep', - 'zeros', - 'Int32', - 'Uint32', - 'Int16', - 'Uint16', - 'Int8', - 'Uint8', - 'Uint8c', - 'uint8_clamped', - 'Float64', - 'Float32', - 'FLOAT64', - 'FLOAT32', - 'GENERIC' - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - zeros( 10, value ); - }; - } -}); - -tape( 'the function returns a zero-filled array (default)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 5 ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float64)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 5, 'float64' ); - t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=float32)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 5, 'float32' ); - t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex128)', function test( t ) { - var expected; - var arr; - - expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 2, 'complex128' ); - t.strictEqual( instanceOf( arr, Complex128Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret128( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=complex64)', function test( t ) { - var expected; - var arr; - - expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - arr = zeros( 2, 'complex64' ); - t.strictEqual( instanceOf( arr, Complex64Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length/2, 'returns expected value' ); - t.deepEqual( reinterpret64( arr, 0 ), expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int32)', function test( t ) { - var expected; - var arr; - - expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zeros( 5, 'int32' ); - t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint32)', function test( t ) { - var expected; - var arr; - - expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zeros( 5, 'uint32' ); - t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int16)', function test( t ) { - var expected; - var arr; - - expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zeros( 5, 'int16' ); - t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint16)', function test( t ) { - var expected; - var arr; - - expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zeros( 5, 'uint16' ); - t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=int8)', function test( t ) { - var expected; - var arr; - - expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zeros( 5, 'int8' ); - t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8)', function test( t ) { - var expected; - var arr; - - expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); - - arr = zeros( 5, 'uint8' ); - t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=uint8c)', function test( t ) { - var expected; - var arr; - - expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); - - arr = zeros( 5, 'uint8c' ); - t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns a zero-filled array (dtype=generic)', function test( t ) { - var expected; - var arr; - - expected = [ 0, 0, 0, 0, 0 ]; - - arr = zeros( 5, 'generic' ); - t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); - t.strictEqual( arr.length, expected.length, 'returns expected value' ); - t.deepEqual( arr, expected, 'returns expected value' ); - - t.end(); -});